Skip to content

Commit

Permalink
[GRASS] region pen options moved to GRASS options
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Aug 20, 2015
1 parent faa32f3 commit bed703e
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 130 deletions.
1 change: 1 addition & 0 deletions src/plugins/grass/qgsgrass_plugin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<file alias="grass_new_point.png">themes/default/grass_new_point.png</file>
<file alias="grass_new_vector_layer.png">themes/default/grass_new_vector_layer.png</file>
<file alias="grass_open_mapset.png">themes/default/grass_open_mapset.png</file>
<file alias="grass_options_region.png">themes/default/grass_options_region.png</file>
<file alias="grass_region_edit.png">themes/default/grass_region_edit.png</file>
<file alias="grass_region.png">themes/default/grass_region.png</file>
<file alias="grass_set_region.png">themes/default/grass_set_region.png</file>
Expand Down
28 changes: 5 additions & 23 deletions src/plugins/grass/qgsgrassplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,7 @@ void QgsGrassPlugin::initGui()
this, SLOT( setEditAction() ) );

connect( QgsGrass::instance(), SIGNAL( mapsetChanged() ), SLOT( mapsetChanged() ) );

// Init Region symbology
mRegionPen.setColor( QColor( settings.value( "/GRASS/region/color", "#ff0000" ).toString() ) );
mRegionPen.setWidth( settings.value( "/GRASS/region/width", 0 ).toInt() );
mRegionBand->setColor( mRegionPen.color() );
mRegionBand->setWidth( mRegionPen.width() );
connect( QgsGrass::instance(), SIGNAL( regionPenChanged() ), SLOT( displayRegion() ) );

mapsetChanged();

Expand Down Expand Up @@ -486,6 +481,10 @@ void QgsGrassPlugin::displayRegion()

QgsRectangle rect( QgsPoint( window.west, window.north ), QgsPoint( window.east, window.south ) );

QPen regionPen = QgsGrass::regionPen();
mRegionBand->setColor( regionPen.color() );
mRegionBand->setWidth( regionPen.width() );

QgsGrassRegionEdit::drawRegion( mCanvas, mRegionBand, rect, &mCoordinateTransform );
}

Expand Down Expand Up @@ -536,23 +535,6 @@ void QgsGrassPlugin::regionClosed()
mRegion = 0;
}

QPen & QgsGrassPlugin::regionPen()
{
return mRegionPen;
}

void QgsGrassPlugin::setRegionPen( QPen & pen )
{
mRegionPen = pen;

mRegionBand->setColor( mRegionPen.color() );
mRegionBand->setWidth( mRegionPen.width() );

QSettings settings;
settings.setValue( "/GRASS/region/color", mRegionPen.color().name() );
settings.setValue( "/GRASS/region/width", ( int ) mRegionPen.width() );
}

void QgsGrassPlugin::openMapset()
{
// QgsDebugMsg("entered.");
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/grass/qgsgrassplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "qgscoordinatereferencesystem.h"
#include "qgscoordinatetransform.h"
#include <QObject>
#include <QPen>


class QgsGrassTools;
class QgsGrassNewMapset;
Expand Down Expand Up @@ -75,10 +73,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
//! Destructor
virtual ~QgsGrassPlugin();

//! Get Region Pen
QPen & regionPen( void );
//! Set Region Pen
void setRegionPen( QPen & );
//! Get an icon from the active theme if possible
static QIcon getThemeIcon( const QString &theName );

Expand Down Expand Up @@ -139,8 +133,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin

//! Pointer to Display region acction
QAction *mRegionAction;
//! Region width
QPen mRegionPen;
//! Region dialog
QgsGrassRegion *mRegion;
// Region rubber band
Expand Down
25 changes: 0 additions & 25 deletions src/plugins/grass/qgsgrassregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,31 +258,6 @@ QgsGrassRegion::QgsGrassRegion( QgsGrassPlugin *plugin, QgisInterface *iface,
connect( mEWRes, SIGNAL( editingFinished() ), this, SLOT( EWResChanged() ) );
connect( mRows, SIGNAL( editingFinished() ), this, SLOT( rowsChanged() ) );
connect( mCols, SIGNAL( editingFinished() ), this, SLOT( colsChanged() ) );

// Symbology
QPen pen = mPlugin->regionPen();
mColorButton->setContext( "gui" );
mColorButton->setColorDialogTitle( tr( "Select color" ) );
mColorButton->setColor( pen.color() );
connect( mColorButton, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) );

mWidthSpinBox->setValue( pen.width() );
connect( mWidthSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeWidth() ) );
}

void QgsGrassRegion::changeColor( const QColor& color )
{
QPen pen = mPlugin->regionPen();
pen.setColor( color );
mPlugin->setRegionPen( pen );
}

void QgsGrassRegion::changeWidth( void )
{
QPen pen = mPlugin->regionPen();

pen.setWidth( mWidthSpinBox->value() );
mPlugin->setRegionPen( pen );
}

QString QgsGrassRegion::formatEdge( double v )
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/grass/qgsgrassregion.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ class QgsGrassRegion: public QDialog, private Ui::QgsGrassRegionBase

void radioChanged( void );

void changeColor( const QColor& color );
void changeWidth( void );

void restorePosition( void );

//! Called when the capture finished to refresh the mWindow values
Expand Down
68 changes: 0 additions & 68 deletions src/plugins/grass/qgsgrassregionbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -160,67 +160,6 @@ or change the following values</string>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Border</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="textLabel7">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="textLabel6">
<property name="text">
<string>Width</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="mWidthSpinBox"/>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QgsColorButtonV2" name="mColorButton">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -232,13 +171,6 @@ or change the following values</string>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsColorButtonV2</class>
<extends>QToolButton</extends>
<header>qgscolorbuttonv2.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/providers/grass/qgsgrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,23 @@ void QgsGrass::setModulesConfig( bool custom, const QString &customDir )
}
}

QPen QgsGrass::regionPen()
{
QSettings settings;
QPen pen;
pen.setColor( QColor( settings.value( "/GRASS/region/color", "#ff0000" ).toString() ) );
pen.setWidthF( settings.value( "/GRASS/region/width", 0 ).toFloat() );
return pen;
}

void QgsGrass::setRegionPen( const QPen & pen )
{
QSettings settings;
settings.setValue( "/GRASS/region/color", pen.color().name() );
settings.setValue( "/GRASS/region/width", pen.widthF() );
emit regionPenChanged();
}

bool QgsGrass::modulesDebug()
{
QSettings settings;
Expand Down
8 changes: 8 additions & 0 deletions src/providers/grass/qgsgrass.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define QGSGRASS_H

#include <QMutex>
#include <QPen>

#include <setjmp.h>

Expand Down Expand Up @@ -471,6 +472,10 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject

void setModulesConfig( bool custom, const QString &customDir );

static QPen regionPen();

void setRegionPen( const QPen & pen );

// Modules UI debug
static bool modulesDebug();

Expand Down Expand Up @@ -501,6 +506,9 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject
/** Emitted when modules debug mode changed */
void modulesDebugChanged();

/** Emitted when region pen changed */
void regionPenChanged();

private:
static int initialized; // Set to 1 after initialization
static bool active; // is active mode
Expand Down
13 changes: 13 additions & 0 deletions src/providers/grass/qgsgrassoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ QgsGrassOptions::QgsGrassOptions( QWidget *parent )

mImportExternalCheckBox->setChecked( settings.value( mImportSettingsPath + "/external", true ).toBool() );

// Region
QPen regionPen = QgsGrass::regionPen();
mRegionColorButton->setContext( "gui" );
mRegionColorButton->setColorDialogTitle( tr( "Select color" ) );
mRegionColorButton->setColor( regionPen.color() );
mRegionWidthSpinBox->setValue( regionPen.width() );

restoreOptionsBaseUi();
}

Expand Down Expand Up @@ -87,4 +94,10 @@ void QgsGrassOptions::saveOptions()
mCrsTransformationComboBox->itemData( mCrsTransformationComboBox->currentIndex() ).toInt() );

settings.setValue( mImportSettingsPath + "/external", mImportExternalCheckBox->isChecked() );

// Region
QPen regionPen = QgsGrass::regionPen();
regionPen.setColor( mRegionColorButton->color() );
regionPen.setWidthF( mRegionWidthSpinBox->value() );
QgsGrass::instance()->setRegionPen( regionPen );
}
Loading

0 comments on commit bed703e

Please sign in to comment.