QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsscalewidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscalewidget.h
3  --------------------------------------
4  Date : 08.01.2015
5  Copyright : (C) 2014 Denis Rouzaud
6  Email : [email protected]
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 #ifndef QGSSCALEWIDGET_H
17 #define QGSSCALEWIDGET_H
18 
19 #include <QWidget>
20 #include <QToolButton>
21 
22 
23 #include "qgsscalecombobox.h"
24 
25 class QgsMapCanvas;
26 
31 class GUI_EXPORT QgsScaleWidget : public QWidget
32 {
33  Q_OBJECT
34  Q_PROPERTY( bool showCurrentScaleButton READ showCurrentScaleButton WRITE setShowCurrentScaleButton )
35 
36  public:
37  explicit QgsScaleWidget( QWidget *parent = 0 );
38 
39  virtual ~QgsScaleWidget();
40 
43  void setShowCurrentScaleButton( bool showCurrentScaleButton );
44  bool showCurrentScaleButton() { return mShowCurrentScaleButton;}
45 
47  void setMapCanvas( QgsMapCanvas* canvas );
48 
50  QString scaleString() { return mScaleComboBox->scaleString(); }
52  bool setScaleString( QString scaleTxt ) { return mScaleComboBox->setScaleString( scaleTxt ); }
54  double scale() { return mScaleComboBox->scale();}
56  void setScale( double scale ) { return mScaleComboBox->setScale( scale ); }
57 
59  // Performs rounding, so an exact representation is not to
60  // be expected.
61  static QString toString( double scale ) { return QgsScaleComboBox::toString( scale ); }
63  static double toDouble( QString scaleString, bool *ok = 0 ) { return QgsScaleComboBox::toDouble( scaleString, ok ); }
64 
65  public slots:
66  void updateScales( const QStringList &scales = QStringList() ) { return mScaleComboBox->updateScales( scales ); }
67 
69  void setScaleFromCanvas();
70 
71  signals:
73  void scaleChanged();
74 
75  private:
76  QgsScaleComboBox* mScaleComboBox;
77  QToolButton* mCurrentScaleButton;
78  QgsMapCanvas* mCanvas;
79  bool mShowCurrentScaleButton;
80 };
81 
82 #endif // QGSSCALEWIDGET_H