File indexing completed on 2025-01-05 03:59:25
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2008 Torsten Rahn <tackat@kde.org> 0004 // 0005 0006 #ifndef MARBLE_MAP_SCALE_FLOAT_ITEM_H 0007 #define MARBLE_MAP_SCALE_FLOAT_ITEM_H 0008 0009 #include "AbstractFloatItem.h" 0010 #include "DialogConfigurationInterface.h" 0011 0012 namespace Ui 0013 { 0014 class MapScaleConfigWidget; 0015 } 0016 0017 namespace Marble 0018 { 0019 0020 /** 0021 * @short The class that creates a map scale. 0022 */ 0023 class MapScaleFloatItem : public AbstractFloatItem, 0024 public DialogConfigurationInterface 0025 { 0026 Q_OBJECT 0027 Q_PLUGIN_METADATA(IID "org.kde.marble.MapScaleFloatItem") 0028 Q_INTERFACES( Marble::RenderPluginInterface ) 0029 Q_INTERFACES( Marble::DialogConfigurationInterface ) 0030 MARBLE_PLUGIN( MapScaleFloatItem ) 0031 0032 public: 0033 0034 explicit MapScaleFloatItem( const MarbleModel *marbleModel = nullptr ); 0035 ~MapScaleFloatItem() override; 0036 0037 QStringList backendTypes() const override; 0038 0039 QString name() const override; 0040 0041 QString guiString() const override; 0042 0043 QString nameId() const override; 0044 0045 QString version() const override; 0046 0047 QString description() const override; 0048 0049 QString copyrightYears() const override; 0050 0051 QVector<PluginAuthor> pluginAuthors() const override; 0052 0053 QIcon icon () const override; 0054 0055 void initialize () override; 0056 0057 bool isInitialized () const override; 0058 0059 void setProjection( const ViewportParams *viewport ) override; 0060 0061 void paintContent( QPainter *painter ) override; 0062 0063 QDialog *configDialog() override; 0064 0065 protected: 0066 0067 void contextMenuEvent( QWidget *w, QContextMenuEvent *e ) override; 0068 void toolTipEvent( QHelpEvent *e ) override; 0069 0070 private Q_SLOTS: 0071 0072 void readSettings(); 0073 void writeSettings(); 0074 void toggleRatioScaleVisibility(); 0075 void toggleMinimized(); 0076 0077 private: 0078 0079 void calcScaleBar(); 0080 0081 private: 0082 0083 QDialog* m_configDialog; 0084 Ui::MapScaleConfigWidget* ui_configWidget; 0085 0086 int m_radius; 0087 0088 QString m_target; 0089 0090 int m_leftBarMargin; 0091 int m_rightBarMargin; 0092 int m_scaleBarWidth; 0093 int m_viewportWidth; 0094 int m_scaleBarHeight; 0095 qreal m_scaleBarDistance; 0096 0097 qreal m_pixel2Length; 0098 int m_bestDivisor; 0099 int m_pixelInterval; 0100 int m_valueInterval; 0101 0102 QString m_ratioString; 0103 0104 bool m_scaleInitDone; 0105 0106 bool m_showRatioScale; 0107 0108 QMenu* m_contextMenu; 0109 0110 QAction* m_minimizeAction; 0111 bool m_minimized; 0112 int m_widthScaleFactor; 0113 }; 0114 0115 } // namespace Marble 0116 0117 #endif // MARBLE_MAP_SCALE_FLOAT_ITEM_H