Skip to content
Permalink
Browse files

[GRASS] region pen options moved to GRASS options

  • Loading branch information
blazek committed Aug 20, 2015
1 parent faa32f3 commit bed703ebfe2d9d39e633200038764a01c7391f8b
@@ -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>
@@ -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();

@@ -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 );
}

@@ -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.");
@@ -19,8 +19,6 @@
#include "qgscoordinatereferencesystem.h"
#include "qgscoordinatetransform.h"
#include <QObject>
#include <QPen>


class QgsGrassTools;
class QgsGrassNewMapset;
@@ -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 );

@@ -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
@@ -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 )
@@ -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
@@ -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>
@@ -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>
Binary file not shown.
@@ -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;
@@ -17,6 +17,7 @@
#define QGSGRASS_H

#include <QMutex>
#include <QPen>

#include <setjmp.h>

@@ -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();

@@ -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
@@ -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();
}

@@ -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 );
}

0 comments on commit bed703e

Please sign in to comment.
You can’t perform that action at this time.