mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
set region to input option
git-svn-id: http://svn.osgeo.org/qgis/trunk@5083 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
b8c82ab884
commit
f8aa37e5dc
@ -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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ private:
|
||||
/*! \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 @@ public:
|
||||
|
||||
QString ready() ;
|
||||
|
||||
//! Should be used region of this input
|
||||
bool useRegion();
|
||||
|
||||
int type() { return mType; }
|
||||
|
||||
public slots:
|
||||
@ -519,6 +522,9 @@ private:
|
||||
//! 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user