QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsscalevisibilitydialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscalevisibilitydialog.cpp
3  --------------------------------------
4  Date : 20.05.2014
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 #include <QGridLayout>
17 #include <QDialogButtonBox>
18 
19 
21 #include "qgsscalerangewidget.h"
22 
23 
24 QgsScaleVisibilityDialog::QgsScaleVisibilityDialog( QWidget *parent, const QString &title, QgsMapCanvas *mapCanvas )
25  : QDialog( parent )
26 {
27  if ( !title.isEmpty() )
28  {
29  setWindowTitle( title );
30  }
31 
32  QGridLayout *dlgLayout = new QGridLayout( this );
33  //dlgLayout->setContentsMargins( 0, 0, 0, 0 );
34 
35  mGroupBox = new QGroupBox( this );
36  mGroupBox->setCheckable( true );
37  mGroupBox->setTitle( tr( "Scale visibility " ) );
38 
39  QGridLayout *gbLayout = new QGridLayout( mGroupBox );
40  //gbLayout->setContentsMargins( 0, 0, 0, 0 );
41 
42  mScaleWidget = new QgsScaleRangeWidget( this );
43  if ( mapCanvas )
44  {
45  mScaleWidget->setMapCanvas( mapCanvas );
46  }
47  gbLayout->addWidget( mScaleWidget, 0, 0 );
48 
49  QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this );
50  connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
51  connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
52 
53  dlgLayout->addWidget( mGroupBox, 0, 0 );
54  dlgLayout->addWidget( buttonBox, 1, 0 );
55 }
56 
57 void QgsScaleVisibilityDialog::setScaleVisiblity( bool hasScaleVisibility )
58 {
59  mGroupBox->setChecked( hasScaleVisibility );
60 }
61 
63 {
64  return mGroupBox->isChecked();
65 }
66 
68 {
69  mScaleWidget->setMinimumScale( minScale );
70 }
71 
73 {
74  return mScaleWidget->minimumScale();
75 }
76 
78 {
79  mScaleWidget->setMaximumScale( maxScale );
80 }
81 
83 {
84  return mScaleWidget->maximumScale();
85 }
qgsscalevisibilitydialog.h
QgsScaleVisibilityDialog::setScaleVisiblity
void setScaleVisiblity(bool hasScaleVisibility)
Set whether scale based visibility is enabled.
Definition: qgsscalevisibilitydialog.cpp:57
qgsscalerangewidget.h
QgsScaleVisibilityDialog::maximumScale
double maximumScale
Definition: qgsscalevisibilitydialog.h:37
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsScaleRangeWidget::maximumScale
double maximumScale
Definition: qgsscalerangewidget.h:36
QgsScaleVisibilityDialog::minimumScale
double minimumScale
Definition: qgsscalevisibilitydialog.h:36
QgsScaleRangeWidget::setMaximumScale
void setMaximumScale(double scale)
Set the maximum scale (i.e.
Definition: qgsscalerangewidget.cpp:104
QgsScaleVisibilityDialog::setMinimumScale
void setMinimumScale(double scale)
Set the minimum scale, or 0 to indicate the minimum is not set.
Definition: qgsscalevisibilitydialog.cpp:67
QgsScaleRangeWidget::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas which will be used for the current scale buttons.
Definition: qgsscalerangewidget.cpp:88
QgsScaleVisibilityDialog::hasScaleVisibility
bool hasScaleVisibility
Definition: qgsscalevisibilitydialog.h:35
QgsScaleVisibilityDialog::setMaximumScale
void setMaximumScale(double scale)
Set the maximum scale, or 0 to indicate the minimum is not set.
Definition: qgsscalevisibilitydialog.cpp:77
QgsScaleRangeWidget
Definition: qgsscalerangewidget.h:32
QgsScaleVisibilityDialog::QgsScaleVisibilityDialog
QgsScaleVisibilityDialog(QWidget *parent=nullptr, const QString &title=QString(), QgsMapCanvas *mapCanvas=nullptr)
Constructor for QgsScaleVisibilityDialog, with specified dialog title.
Definition: qgsscalevisibilitydialog.cpp:24
QgsScaleRangeWidget::setMinimumScale
void setMinimumScale(double scale)
Set the minimum scale (i.e.
Definition: qgsscalerangewidget.cpp:94
QgsScaleRangeWidget::minimumScale
double minimumScale
Definition: qgsscalerangewidget.h:35