Skip to content
Permalink
Browse files
region tag to force region use, especially import/export
git-svn-id: http://svn.osgeo.org/qgis/trunk@5431 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed May 9, 2006
1 parent 35d8cb3 commit 721727586653e072664c78a616a5fb0c481cbc71
Showing with 65 additions and 11 deletions.
  1. +46 −11 src/plugins/grass/qgsgrassmodule.cpp
  2. +19 −0 src/plugins/grass/qgsgrassmodule.h
@@ -809,31 +809,31 @@ bool QgsGrassModuleStandardOptions::usesRegion ()
#ifdef QGISDEBUG
std::cerr << "QgsGrassModuleStandardOptions::usesRegion()" << std::endl;
#endif

for ( int i = 0; i < mItems.size(); i++ )
{
if ( typeid(*(mItems[i])) == typeid (QgsGrassModuleInput) )
{
QgsGrassModuleInput *item =
dynamic_cast<QgsGrassModuleInput *>(mItems[i]);

if ( item->type() == QgsGrassModuleInput::Raster )
if ( item->useRegion() )
return true;
}

/* It only make sense to check input, right?
* Output has no region yet */
if ( typeid(*(mItems[i])) == typeid (QgsGrassModuleOption) )
{
QgsGrassModuleOption *item =
dynamic_cast<QgsGrassModuleOption *> ( mItems[i] );

if ( item->isOutput()
&& item->outputType() == QgsGrassModuleOption::Raster )
{
if ( item->usesRegion() )
return true;
}
}
}

std::cerr << "NO usesRegion()" << std::endl;
return false;
}

@@ -1583,6 +1583,23 @@ QgsGrassModuleOption::QgsGrassModuleOption ( QgsGrassModule *module, QString key
}
}
}

mUsesRegion = false;
QString region = qdesc.attribute("region");
if ( region.length() > 0 )
{
if ( region == "yes" )
mUsesRegion = true;
}
else
{
std::cerr << "\n\n\n\n**************************" << std::endl;
std::cerr << "isOutput = " << isOutput() << std::endl;
std::cerr << "mOutputType = " << mOutputType << std::endl;
if ( isOutput() && mOutputType == Raster )
mUsesRegion = true;
}
std::cerr << "mUsesRegion = " << mUsesRegion << std::endl;
}

void QgsGrassModuleOption::addLineEdit()
@@ -1908,8 +1925,11 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
QSizePolicy:: Preferred );
l->addWidget ( mLayerComboBox );

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

@@ -1943,6 +1963,18 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
connect ( mapInput, SIGNAL(valueChanged()), this, SLOT(updateQgisLayers()) );
}
}

mUsesRegion = false;
if ( region.length() > 0 )
{
if ( region == "yes" )
mUsesRegion = true;
}
else
{
if ( type() == Raster )
mUsesRegion = true;
}

// Fill in QGIS layers
updateQgisLayers();
@@ -1952,7 +1984,7 @@ bool QgsGrassModuleInput::useRegion()
{
std::cerr << "QgsGrassModuleInput::useRegion()" << std::endl;

if ( mType == Raster && mRegionButton &&
if ( mUsesRegion && mType == Raster && mRegionButton &&
mRegionButton->isChecked() )
{
return true;
@@ -2344,8 +2376,11 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput (

// Connect to canvas
QgsMapCanvas *canvas = mModule->qgisIface()->getMapCanvas();
connect ( canvas, SIGNAL(addedLayer(QgsMapLayer *)), this, SLOT(updateQgisLayers()) );
connect ( canvas, SIGNAL(removedLayer(QString)), this, SLOT(updateQgisLayers()) );

// It seems that addedLayer/removedLayer does not work
//connect ( canvas, SIGNAL(addedLayer(QgsMapLayer *)), this, SLOT(updateQgisLayers()) );
//connect ( canvas, SIGNAL(removedLayer(QString)), this, SLOT(updateQgisLayers()) );
connect ( canvas, SIGNAL(layersChanged()), this, SLOT(updateQgisLayers()) );

// Fill in QGIS layers
updateQgisLayers();
@@ -290,6 +290,9 @@ class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget

//! List of all flags. Necessary for scripts.
QStringList mFlagNames;

//! Use of region defined in qgm
bool mUsesRegion;
};

/*! \class QgsGrassModuleItem
@@ -397,6 +400,11 @@ class QgsGrassModuleOption: public QGroupBox, public QgsGrassModuleItem
//! Current value
QString value();

//! Does this options causes use of region?
// Raster input/output uses region by default
// Use of region can be forced by 'region' attribute in qgm
bool usesRegion() { return mUsesRegion; }

public slots:
// Add new line edit for multiple options
void addLineEdit();
@@ -441,6 +449,9 @@ public slots:

// Layout inside box
QVBoxLayout *mLayout;

//! Uses region
bool mUsesRegion;
};
/********************** QgsGrassModuleFlag ************************/
/*! \class QgsGrassModuleFlag
@@ -503,6 +514,11 @@ class QgsGrassModuleInput: public QGroupBox, public QgsGrassModuleItem

QString ready() ;

//! Does this options causes use of region?
// Raster input/output uses region by default
// Use of region can be forced by 'region' attribute in qgm
bool usesRegion() { return mUsesRegion; }

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

@@ -563,6 +579,9 @@ public slots:

//! The imput map will be updated -> must be from current mapset
bool mUpdate;

//! Uses region
bool mUsesRegion;
};

/*********************** QgsGrassModuleGdalInput **********************/

0 comments on commit 7217275

Please sign in to comment.