Skip to content
Permalink
Browse files

set region to input option

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5083 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 23, 2006
1 parent 3af9d40 commit 6f3766e7c422ab6438812e8c799a2001bd60795c
Showing with 77 additions and 10 deletions.
  1. +68 −7 src/plugins/grass/qgsgrassmodule.cpp
  2. +9 −3 src/plugins/grass/qgsgrassmodule.h
@@ -580,9 +580,13 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
break;
}

QStringList mm = item->currentMap().split("@");
QString map = mm.at(0);
QString mapset = QgsGrass::getDefaultMapset();
if ( mm.size() > 1 ) mapset = mm.at(1);
if ( !QgsGrass::mapRegion ( mapType,
QgsGrass::getDefaultGisdbase(),
QgsGrass::getDefaultLocation(), "", item->currentMap(),
QgsGrass::getDefaultLocation(), mapset, map,
&window ) )
{
QMessageBox::warning( 0, "Warning", "Cannot check region "
@@ -623,13 +627,13 @@ bool QgsGrassModuleStandardOptions::inputRegion ( struct Cell_head *window, bool
continue;
}

// TODO all flag

struct Cell_head mapWindow;

QgsGrassModuleInput *item = dynamic_cast<QgsGrassModuleInput *>
(mItems[i]);

if ( !all && !item->useRegion() ) continue;

int mapType;
switch ( item->type() ) {
case QgsGrassModuleInput::Raster :
@@ -640,9 +644,13 @@ bool QgsGrassModuleStandardOptions::inputRegion ( struct Cell_head *window, bool
break;
}

QStringList mm = item->currentMap().split("@");
QString map = mm.at(0);
QString mapset = QgsGrass::getDefaultMapset();
if ( mm.size() > 1 ) mapset = mm.at(1);
if ( !QgsGrass::mapRegion ( mapType,
QgsGrass::getDefaultGisdbase(),
QgsGrass::getDefaultLocation(), "", item->currentMap(),
QgsGrass::getDefaultLocation(), mapset, map,
&mapWindow ) )
{
QMessageBox::warning( 0, "Warning", "Cannot set region "
@@ -676,6 +684,26 @@ bool QgsGrassModuleStandardOptions::inputRegion ( struct Cell_head *window, bool
return true;
}

bool QgsGrassModuleStandardOptions::requestsRegion()
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassModuleStandardOptions::requestsRegion()" << std::endl;
#endif

for ( int i = 0; i < mItems.size(); i++ )
{
if ( typeid(*(mItems[i])) != typeid (QgsGrassModuleInput) ) {
continue;
}

QgsGrassModuleInput *item = dynamic_cast<QgsGrassModuleInput *>
(mItems[i]);

if ( item->useRegion() ) return true;
}
return false;
}

bool QgsGrassModuleStandardOptions::usesRegion ()
{
#ifdef QGISDEBUG
@@ -1559,10 +1587,11 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
QgsGrassModuleStandardOptions *options, QString key,
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
QWidget * parent)
: Q3GroupBox ( 1, Qt::Vertical, parent ),
: QGroupBox ( parent ),
QgsGrassModuleItem ( module, key, qdesc, gdesc, gnode ),
mModuleStandardOptions(options),
mUpdate(false), mVectorTypeOption(0), mVectorLayerOption(0)
mUpdate(false), mVectorTypeOption(0), mVectorLayerOption(0),
mRegionButton(0)
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassModuleInput::QgsGrassModuleInput" << std::endl;
@@ -1692,7 +1721,26 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
mUpdate = true;
}

mLayerComboBox = new QComboBox ( this );
QHBoxLayout *l = new QHBoxLayout (this);
mLayerComboBox = new QComboBox ();
mLayerComboBox->setSizePolicy (QSizePolicy::Expanding,
QSizePolicy:: Preferred );
l->addWidget ( mLayerComboBox );

if ( mType == Raster &&
QgsGrass::versionMajor() >= 6 && QgsGrass::versionMinor() >= 1 )
{
QString iconPath = QgsApplication::themePath() + "/grass/";

mRegionButton = new QPushButton(
QIcon(iconPath+"grass_set_region.png"), "" );

mRegionButton->setToolTip ( "Use region of this map" );
mRegionButton->setCheckable ( true );
mRegionButton->setSizePolicy (QSizePolicy::Minimum,
QSizePolicy:: Preferred );
l->addWidget ( mRegionButton );
}

// Of course, activated(int) is not enough, but there is no signal BEFORE the cobo is opened
//connect ( mLayerComboBox, SIGNAL( activated(int) ), this, SLOT(updateQgisLayers()) );
@@ -1719,6 +1767,19 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
updateQgisLayers();
}

bool QgsGrassModuleInput::useRegion()
{
std::cerr << "QgsGrassModuleInput::useRegion()" << std::endl;

if ( mType == Raster && mRegionButton &&
mRegionButton->isChecked() )
{
return true;
}

return false;
}

void QgsGrassModuleInput::updateQgisLayers()
{
#ifdef QGISDEBUG
@@ -197,7 +197,7 @@ class QgsGrassModuleOptions
virtual bool usesRegion() { return false; }

//! One or more input maps were swithched on to be used as region
bool requestsRegion() { return false; }
virtual bool requestsRegion() { return false; }

//! Check region
// return empty list
@@ -261,7 +261,7 @@ class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget
QStringList output(int type);
QStringList checkRegion();
bool usesRegion();
bool requestsRegion() { return false; } // TODO
bool requestsRegion();
bool inputRegion( struct Cell_head *window, bool all );

private:
@@ -455,7 +455,7 @@ class QgsGrassModuleFlag: public QCheckBox, public QgsGrassModuleItem
/*! \class QgsGrassModuleInput
* \brief Class representing raster or vector module input
*/
class QgsGrassModuleInput: public Q3GroupBox, public QgsGrassModuleItem
class QgsGrassModuleInput: public QGroupBox, public QgsGrassModuleItem
{
Q_OBJECT;

@@ -487,6 +487,9 @@ class QgsGrassModuleInput: public Q3GroupBox, public QgsGrassModuleItem

QString ready() ;

//! Should be used region of this input
bool useRegion();

int type() { return mType; }

public slots:
@@ -519,6 +522,9 @@ public slots:
//! Combobox for QGIS layers
QComboBox *mLayerComboBox;

//! Region button
QPushButton *mRegionButton;

//! Optional map option id, if defined, only the layers from the
// map currently selected in that option are available.
// This is used by nodes layer option for networks.

0 comments on commit 6f3766e

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