/** * @RDE_HEADER@ * An Input Widget for coordinates * $Id$ * $HeadURL$ * $Author$ * * Created by Christian Ehrlicher, SLSE, 2016-09-08 */ #pragma once #include #include #include class QToolButton; namespace LtsCoordWidget { class LtsCoordInputWidgetHandler; class LTSCOORDWIDGET_EXPORT LtsCoordWidget : public QWidget { Q_OBJECT public: enum class DisplayType { MGRS5,// display coordinate as MGRS with 5 digits (= m) MGRS7,// display coordinate as MGRS with 7 digits (= mm) UTM, // display coordinate as UTM WGS84, // display coordinate as WGS84 (degree) MGRS = DisplayType::MGRS5 // display coordinate as MGRS (default precision = MGRS5) }; Q_ENUM(DisplayType) Q_PROPERTY(DisplayType displayType READ displayType WRITE setDisplayType) Q_PROPERTY(bool withResetButton READ withResetButton WRITE setWithResetButton) Q_PROPERTY(bool showToolTip READ showToolTip WRITE setShowToolTip) Q_PROPERTY(bool mgrsSquareEditable READ mgrsSquareEditable WRITE setMgrsSquareEditable) /** * @brief Create a new LtsCoordWidget with default display type (= MGRS) */ explicit LtsCoordWidget(QWidget *parent = nullptr) : LtsCoordWidget(LtsCoordWidget::DisplayType::MGRS, parent) {} /** * @brief Create a new LtsCoordWidget with given display type */ explicit LtsCoordWidget(DisplayType dt, QWidget *parent = nullptr); QPointF coordinate() const; DisplayType displayType() const; bool withResetButton() const; bool showToolTip() const; bool mgrsSquareEditable() const; bool event(QEvent *event) override; public Q_SLOTS: /** * @brief Set the current visible coordinate * @param geoCoord the coordinate to display (in wgs84, radian) * @param bUseAsDefaultValue if true, the reset button will be visible and reset to the given value if pressed */ void setCoordinate(const QPointF &geoCoord, bool bUseAsDefaultValue = true); void setCoordinate(double lon, double lat, bool bUseAsDefaultValue = true); void setDisplayType(LtsCoordWidget::DisplayType dt); void setWithResetButton(bool bWith); void setShowToolTip(bool bShow); void setMgrsSquareEditable(bool bEditable); void setWithSurroundingMgrsSquares(bool bEnable); void setMgrsSquares(const QVector &geoCoords); void clear(); Q_SIGNALS: void coordinateChanged(const QPointF &newGeoCoord); void invalidCoordinate(); private: void rebuildUi(); void updateToolTip(); private Q_SLOTS: void onResetToDefaultCoordinate(); private: bool m_bWithResetButton = false; bool m_bShowToolTip = true; bool m_bMgrsSquareEditable = false; LtsCoordWidget::DisplayType m_displayType = LtsCoordWidget::DisplayType::MGRS; LtsCoordInputWidgetHandler *m_inputWidgetHandler = nullptr; QPointF m_coordinate; QPointF m_defaultCoordinate; }; }