Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update the scale range widget with the new scale widget
  • Loading branch information
3nids committed Jan 9, 2015
1 parent 3310efb commit abb2510
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 59 deletions.
64 changes: 16 additions & 48 deletions src/gui/qgsscalerangewidget.cpp
Expand Up @@ -21,8 +21,6 @@
QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
: QWidget( parent )
, mCanvas( 0 )
, mMaximumScaleSetCurrentPushButton( 0 )
, mMinimumScaleSetCurrentPushButton( 0 )
{
mLayout = new QGridLayout( this );
mLayout->setContentsMargins( 0, 0, 0, 0 );
Expand All @@ -43,19 +41,21 @@ QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
mMaximumScaleIconLabel = new QLabel( this );
mMaximumScaleIconLabel->setPixmap( QgsApplication::getThemePixmap( "/mActionZoomIn.svg" ) );

mMinimumScaleComboBox = new QgsScaleComboBox( this );
mMaximumScaleComboBox = new QgsScaleComboBox( this );
mMinimumScaleWidget = new QgsScaleWidget( this );
mMaximumScaleWidget = new QgsScaleWidget( this );
mMinimumScaleWidget->setShowCurrentScaleButton( true );
mMaximumScaleWidget->setShowCurrentScaleButton( true );
reloadProjectScales();
// add start, add comprehension of scales by settings fake ordered values
mMinimumScaleComboBox->setCurrentIndex( 2 );
mMaximumScaleComboBox->setCurrentIndex( mMinimumScaleComboBox->currentIndex() + 2 );
mMinimumScaleWidget->setScale( 1 / 100000 );
mMaximumScaleWidget->setScale( 1 / 1000 );

mLayout->addWidget( minLbl, 0, 0, 2, 1 );
mLayout->addWidget( mMinimumScaleIconLabel, 0, 1 );
mLayout->addWidget( mMinimumScaleComboBox, 0, 2 );
mLayout->addWidget( mMinimumScaleWidget, 0, 2 );
mLayout->addWidget( maxLbl, 0, 3, 2, 1 );
mLayout->addWidget( mMaximumScaleIconLabel, 0, 4 );
mLayout->addWidget( mMaximumScaleComboBox, 0, 5 );
mLayout->addWidget( mMaximumScaleWidget, 0, 5 );

mLayout->setColumnStretch( 0, 0 );
mLayout->setColumnStretch( 1, 0 );
Expand All @@ -75,56 +75,35 @@ void QgsScaleRangeWidget::reloadProjectScales()
if ( projectScales )
{
QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
mMinimumScaleComboBox->updateScales( scalesList );
mMaximumScaleComboBox->updateScales( scalesList );
mMinimumScaleWidget->updateScales( scalesList );
mMaximumScaleWidget->updateScales( scalesList );
}
}

void QgsScaleRangeWidget::setMapCanvas( QgsMapCanvas *mapCanvas )
{
if ( mMinimumScaleSetCurrentPushButton )
{
delete mMinimumScaleSetCurrentPushButton;
mMinimumScaleSetCurrentPushButton = 0;
}
if ( mMaximumScaleSetCurrentPushButton )
{
delete mMaximumScaleSetCurrentPushButton;
mMaximumScaleSetCurrentPushButton = 0;
}

if ( !mapCanvas )
return;

mCanvas = mapCanvas;

mMinimumScaleSetCurrentPushButton = new QPushButton( tr( "current" ), this );
connect( mMinimumScaleSetCurrentPushButton, SIGNAL( clicked() ), this, SLOT( setMinScaleFromCanvas() ) );
mMaximumScaleSetCurrentPushButton = new QPushButton( tr( "current" ), this );
connect( mMaximumScaleSetCurrentPushButton, SIGNAL( clicked() ), this, SLOT( setMaxScaleFromCanvas() ) );

mLayout->addWidget( mMinimumScaleSetCurrentPushButton, 1, 2 );
mLayout->addWidget( mMaximumScaleSetCurrentPushButton, 1, 5 );
mMinimumScaleWidget->setMapCanvas( mapCanvas );
mMaximumScaleWidget->setMapCanvas( mapCanvas );
}

void QgsScaleRangeWidget::setMinimumScale( double scale )
{
mMinimumScaleComboBox->setScale( scale );
mMinimumScaleWidget->setScale( scale );
}

double QgsScaleRangeWidget::minimumScale()
{
return mMinimumScaleComboBox->scale();
return mMinimumScaleWidget->scale();
}

void QgsScaleRangeWidget::setMaximumScale( double scale )
{
mMaximumScaleComboBox->setScale( scale );
mMaximumScaleWidget->setScale( scale );
}

double QgsScaleRangeWidget::maximumScale()
{
return mMaximumScaleComboBox->scale();
return mMaximumScaleWidget->scale();
}

double QgsScaleRangeWidget::minimumScaleDenom()
Expand All @@ -143,14 +122,3 @@ void QgsScaleRangeWidget::setScaleRange( double min, double max )
setMinimumScale( min );
}

void QgsScaleRangeWidget::setMinScaleFromCanvas()
{
mMinimumScaleComboBox->setScale( 1.0 / mCanvas->mapSettings().scale() );
}

void QgsScaleRangeWidget::setMaxScaleFromCanvas()
{
mMaximumScaleComboBox->setScale( 1.0 / mCanvas->mapSettings().scale() );
}


14 changes: 3 additions & 11 deletions src/gui/qgsscalerangewidget.h
Expand Up @@ -18,13 +18,11 @@

#include <QGridLayout>
#include <QLabel>
#include <QPushButton>


#include "qgscollapsiblegroupbox.h"
#include "qgsmaplayer.h"
#include "qgsmapcanvas.h"
#include "qgsscalecombobox.h"
#include "qgsscalewidget.h"


class GUI_EXPORT QgsScaleRangeWidget : public QWidget
Expand Down Expand Up @@ -64,10 +62,6 @@ class GUI_EXPORT QgsScaleRangeWidget : public QWidget

void setScaleRange( double min, double max );

private slots:
void setMaxScaleFromCanvas();
void setMinScaleFromCanvas();

private:
//! pointer to the map canvas used for current buttons.
QgsMapCanvas* mCanvas;
Expand All @@ -76,10 +70,8 @@ class GUI_EXPORT QgsScaleRangeWidget : public QWidget
QGridLayout* mLayout;
QLabel* mMaximumScaleIconLabel;
QLabel* mMinimumScaleIconLabel;
QPushButton* mMaximumScaleSetCurrentPushButton;
QPushButton* mMinimumScaleSetCurrentPushButton;
QgsScaleComboBox* mMaximumScaleComboBox;
QgsScaleComboBox* mMinimumScaleComboBox;
QgsScaleWidget* mMaximumScaleWidget;
QgsScaleWidget* mMinimumScaleWidget;
};

#endif // QGSSCALERANGEWIDGET_H

0 comments on commit abb2510

Please sign in to comment.