QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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
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 "moc_qgsscalevisibilitydialog.cpp"
22#include "qgsscalerangewidget.h"
23
24
25QgsScaleVisibilityDialog::QgsScaleVisibilityDialog( QWidget *parent, const QString &title, QgsMapCanvas *mapCanvas )
26 : QDialog( parent )
27{
28 if ( !title.isEmpty() )
29 {
30 setWindowTitle( title );
31 }
32
33 QGridLayout *dlgLayout = new QGridLayout( this );
34 //dlgLayout->setContentsMargins( 0, 0, 0, 0 );
35
36 mGroupBox = new QGroupBox( this );
37 mGroupBox->setCheckable( true );
38 mGroupBox->setTitle( tr( "Scale visibility " ) );
39
40 QGridLayout *gbLayout = new QGridLayout( mGroupBox );
41 //gbLayout->setContentsMargins( 0, 0, 0, 0 );
42
43 mScaleWidget = new QgsScaleRangeWidget( this );
44 if ( mapCanvas )
45 {
46 mScaleWidget->setMapCanvas( mapCanvas );
47 }
48 gbLayout->addWidget( mScaleWidget, 0, 0 );
49
50 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this );
51 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
52 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
53
54 dlgLayout->addWidget( mGroupBox, 0, 0 );
55 dlgLayout->addWidget( buttonBox, 1, 0 );
56}
57
58void QgsScaleVisibilityDialog::setScaleVisibility( bool hasScaleVisibility )
59{
60 mGroupBox->setChecked( hasScaleVisibility );
61}
62
64{
65 return mGroupBox->isChecked();
66}
67
69{
70 mScaleWidget->setMinimumScale( minScale );
71}
72
74{
75 return mScaleWidget->minimumScale();
76}
77
79{
80 mScaleWidget->setMaximumScale( maxScale );
81}
82
84{
85 return mScaleWidget->maximumScale();
86}
Map canvas is a class for displaying all GIS data types on a canvas.
A widget allowing entry of a range of map scales, e.g.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas which will be used for the current scale buttons.
void setMinimumScale(double scale)
Set the minimum scale (i.e.
void setMaximumScale(double scale)
Set the maximum scale (i.e.
void setMaximumScale(double scale)
Set the maximum scale, or 0 to indicate the minimum is not set.
void setScaleVisibility(bool hasScaleVisibility)
Set whether scale based visibility is enabled.
void setMinimumScale(double scale)
Set the minimum scale, or 0 to indicate the minimum is not set.
QgsScaleVisibilityDialog(QWidget *parent=nullptr, const QString &title=QString(), QgsMapCanvas *mapCanvas=nullptr)
Constructor for QgsScaleVisibilityDialog, with specified dialog title.