25 mComboBoxMinScale->setScale( 0.0000001 );
26 mComboBoxMaxScale->setScale( 1 );
27 mSpinBoxMinSize->setShowClearButton(
false );
28 mSpinBoxMaxSize->setShowClearButton(
false );
29 connect( mCheckBoxMinScale, SIGNAL( toggled(
bool ) ),
this, SLOT( configureMinComboBox() ) );
30 connect( mCheckBoxMaxScale, SIGNAL( toggled(
bool ) ),
this, SLOT( configureMaxComboBox() ) );
31 connect( mComboBoxMinScale, SIGNAL( scaleChanged() ),
this, SLOT( configureMaxComboBox() ) );
32 connect( mComboBoxMaxScale, SIGNAL( scaleChanged() ),
this, SLOT( configureMinComboBox() ) );
34 connect( mCheckBoxMinSize, SIGNAL( toggled(
bool ) ), mSpinBoxMinSize, SLOT(
setEnabled(
bool ) ) );
35 connect( mCheckBoxMaxSize, SIGNAL( toggled(
bool ) ), mSpinBoxMaxSize, SLOT(
setEnabled(
bool ) ) );
40 mComboBoxMinScale->setScale( scale.
minScale > 0.0 ? scale.
minScale : 0.0000001 );
41 mCheckBoxMinScale->setChecked( scale.
minScale > 0.0 );
42 mComboBoxMinScale->setEnabled( scale.
minScale > 0.0 );
44 mCheckBoxMaxScale->setChecked( scale.
maxScale > 0.0 );
45 mComboBoxMaxScale->setEnabled( scale.
maxScale > 0.0 );
49 mSpinBoxMinSize->setValue( scale.
minSizeMM );
53 mSpinBoxMaxSize->setValue( scale.
maxSizeMM );
58 mComboBoxMinScale->setMapCanvas( canvas );
59 mComboBoxMinScale->setShowCurrentScaleButton(
true );
60 mComboBoxMaxScale->setMapCanvas( canvas );
61 mComboBoxMaxScale->setShowCurrentScaleButton(
true );
64 void QgsMapUnitScaleDialog::configureMinComboBox()
66 mComboBoxMinScale->setEnabled( mCheckBoxMinScale->isChecked() );
67 if ( mCheckBoxMinScale->isChecked() && mComboBoxMinScale->scale() > mComboBoxMaxScale->scale() )
69 mComboBoxMinScale->setScale( mComboBoxMaxScale->scale() );
73 void QgsMapUnitScaleDialog::configureMaxComboBox()
75 mComboBoxMaxScale->setEnabled( mCheckBoxMaxScale->isChecked() );
76 if ( mCheckBoxMaxScale->isChecked() && mComboBoxMaxScale->scale() < mComboBoxMinScale->scale() )
78 mComboBoxMaxScale->setScale( mComboBoxMinScale->scale() );
85 scale.
minScale = mCheckBoxMinScale->isChecked() ? mComboBoxMinScale->scale() : 0;
86 scale.
maxScale = mCheckBoxMaxScale->isChecked() ? mComboBoxMaxScale->scale() : 0;
88 scale.
minSizeMM = mSpinBoxMinSize->value();
90 scale.
maxSizeMM = mSpinBoxMaxSize->value();
101 mMapScaleButton->setVisible(
false );
102 mMapScaleButton->setToolTip(
tr(
"Adjust scaling range" ) );
107 connect( mUnitCombo, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( toggleUnitRangeButton() ) );
108 connect( mMapScaleButton, SIGNAL( clicked() ),
this, SLOT( showDialog() ) );
109 connect( mUnitCombo, SIGNAL( currentIndexChanged(
int ) ),
this, SIGNAL(
changed() ) );
115 mUnitCombo->addItems( units );
116 mMapUnitIdx = mapUnitIdx;
150 if ( mUnitCombo->count() == 0 )
153 QVariant currentData = mUnitCombo->itemData( mUnitCombo->currentIndex() );
165 mUnitCombo->setCurrentIndex( unitIndex );
171 int idx = mUnitCombo->findData(
QVariant((
int ) unit ) );
172 mUnitCombo->setCurrentIndex( idx == -1 ? 0 : idx );
180 void QgsUnitSelectionWidget::showDialog()
183 if ( mUnitScaleDialog->
exec() != QDialog::Accepted )
190 if ( scale != newScale )
197 void QgsUnitSelectionWidget::toggleUnitRangeButton()
205 mMapScaleButton->setVisible( mMapUnitIdx != -1 && mUnitCombo->currentIndex() == mMapUnitIdx );
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
OutputUnit
The unit of the output.
QgsMapUnitScale getMapUnitScale() const
Returns the map unit scale.
The output shall be in pixels.
QgsMapUnitScaleDialog(QWidget *parent=nullptr)
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
double maxScale
The maximum scale, or 0.0 if unset.
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
Mixed units in symbol layers.
The output shall be in millimeters.
int toInt(bool *ok) const
The ouput shall be a percentage of another measurement (eg canvas size, feature size) ...
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale.
Dialog allowing the user to choose the minimum and maximum scale of an object in map units...
The output shall be in map unitx.
bool blockSignals(bool block)
bool contains(const T &value) const
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
Struct for storing maximum and minimum scales for measurements in map units.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
double minScale
The minimum scale, or 0.0 if unset.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.