📄 qgsgrassmodule.h
字号:
//Added by qt3to4:#include <QPixmap>#include <QCloseEvent>#include <Q3Frame>/*************************************************************************** qgsgrassmodule.h ------------------- begin : March, 2005 copyright : (C) 2005 by Radim Blazek email : blazek@itc.it ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#ifndef QGSGRASSMODULE_H#define QGSGRASSMODULE_Hclass QCloseEvent;class QString;class QStringList;class Q3GroupBox;class Q3Frame;class Q3ListView;class QDomNode;class QDomElement;class QComboBox;class QLineEdit;class QPixmap;class QValidator;#include <vector>#include <q3groupbox.h>#include <qcheckbox.h>#include <q3process.h>#include <QGroupBox>//#include <QLayout>#include <QVBoxLayout>#include <QProcess>// Must be here, so that it is included to moc file#include "qgsvectorlayer.h"class QgisInterface;class QgsMapCanvas;class QgsGrassProvider;class QgsGrassTools;class QgsGrassModuleItem;class QgsGrassModuleOptions; class QgsGrassModuleStandardOptions; #include "ui_qgsgrassmodulebase.h"#include <QDialog>/*! \class QgsGrassModule * \brief Interface to GRASS modules. * */class QgsGrassModule: public QDialog, private Ui::QgsGrassModuleBase { Q_OBJECT;public: //! Constructor QgsGrassModule ( QgsGrassTools *tools, QString moduleName, QgisInterface *iface, QString path, QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 ); //! Destructor ~QgsGrassModule(); //! Returns module label for module description path static QString label ( QString path ); /** \brief Returns pixmap representing the module * \param path module path without .qgm extension */ static QPixmap pixmap ( QString path, int height ); //! Find element in GRASS module description by key, if not found, returned element is null static QDomNode nodeByKey ( QDomElement gDocElem, QString key ); //! Returns pointer to QGIS interface QgisInterface *qgisIface(); // ! Options widget QgsGrassModuleOptions *options() { return mOptions; } // ! List of directories in PATH variable + current directory on Windows static QStringList mExecPath; static bool mExecPathInited; // ! Find in exec path // returns full path or null string // appends automaticaly .exe on Windows static QString findExec ( QString file ); // ! Check if file is in mExecPath static bool inExecPath ( QString file ); // ! Get executable + arguments. Executable is returned as first string. // On Window if the module is script the executable will be path to shell // Returns empty list if not found. static QStringList execArguments ( QString module );public slots: //! Run the module with current options void on_mRunButton_clicked() { run(); } void run (); //! Close the module tab void on_mCloseButton_clicked() { close(); } void close (); //! Show output in map view void on_mViewButton_clicked() { viewOutput(); } void viewOutput (); //! Running process finished void finished (int exitCode, QProcess::ExitStatus exitStatus ); //! Read module's standard output void readStdout(); //! Read module's standard error void readStderr();private: //! Pointer to the QGIS interface object QgisInterface *mIface; //! Pointer to canvas QgsMapCanvas *mCanvas; //! Pointer to GRASS Tools QgsGrassTools *mTools; //! Module definition file path (.qgm file) QString mPath; //! Name of module executable QString mXName; //! Path to module executable QString mXPath; //! Parent widget QWidget *mParent; //! Running GRASS module QProcess mProcess; //! QGIS directory QString mAppDir; //! Pointer to options widget QgsGrassModuleOptions *mOptions; //! Last raster output QStringList mOutputRaster; //! Last vector output QStringList mOutputVector; //! True if the module successfully finished bool mSuccess;};/*! \class QgsGrassModuleOptions * \brief Widget with GRASS options. * */class QgsGrassModuleOptions{public: //! Constructor QgsGrassModuleOptions ( QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface ); //! Destructor virtual ~QgsGrassModuleOptions(); //! Get module options as list of arguments for QProcess virtual QStringList arguments(); //! Check if output exists // return empty list // return list of existing output maps virtual QStringList checkOutput() { return QStringList() ; } //! Freeze output vector maps used in QGIS on Windows virtual void freezeOutput() { return; } //! Thaw output vector maps used in QGIS on Windows virtual void thawOutput() { return; } //! Check if option is ready // Returns empty string or error message virtual QStringList ready() { return QStringList() ; } //! Get list of current output maps virtual QStringList output(int type) { return QStringList() ; } //! Has raster input or output virtual bool usesRegion() { return false; } //! One or more input maps were switched on to be used as region virtual bool requestsRegion() { return false; } //! Check region // return empty list // return list of input maps (both raster and vector) outside region virtual QStringList checkRegion() { return QStringList() ; } //! Get region covering all input maps // \param all true all input maps // \param all false only the mas which were switched on virtual bool inputRegion( struct Cell_head *window, bool all ) { return false; } // ! Flag names virtual QStringList flagNames() { return QStringList() ; }protected: //! Pointer to the QGIS interface object QgisInterface *mIface; //! Pointer to canvas QgsMapCanvas *mCanvas; //! Pointer to GRASS Tools QgsGrassTools *mTools; //! Pointer to GRASS module QgsGrassModule *mModule; //! Parent widget QWidget *mParent; //! QGIS directory QString mAppDir;};/*! \class QgsGrassModuleStandardOptions * \brief Widget with GRASS standard options. * */class QgsGrassModuleStandardOptions: public QgsGrassModuleOptions, QWidget {public: //! Constructor QgsGrassModuleStandardOptions ( QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface, QString xname, QDomElement docElem, QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 ); //! Destructor ~QgsGrassModuleStandardOptions(); //! Get module options as list of arguments for QProcess QStringList arguments(); // ! Get item by ID QgsGrassModuleItem *item(QString id); // Reimplemented methods from QgsGrassModuleOptions QStringList checkOutput(); void freezeOutput(); void thawOutput(); QStringList ready() ; QStringList output(int type); QStringList checkRegion(); bool usesRegion(); bool requestsRegion(); bool inputRegion( struct Cell_head *window, bool all ); QStringList flagNames() { return mFlagNames; }private: //! Name of module executable QString mXName; //! Path to module executable QString mXPath; //! Option items std::vector<QgsGrassModuleItem*> mItems; //! List of all flags. Necessary for scripts. QStringList mFlagNames; //! Use of region defined in qgm bool mUsesRegion;};/*! \class QgsGrassModuleItem * \brief GRASS module option */class QgsGrassModuleItem{public: /*! \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file * \param gnode option node in GRASS module XML description file */ QgsGrassModuleItem ( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode ); //! Destructor virtual ~QgsGrassModuleItem(); //! Is the item hidden bool hidden(); //! Retruns list of options which will be passed to module virtual QStringList options(); //! Item's key QString key() { return mKey; } //! Item's id QString id() { return mId; } //! Check if otpion is ready // Returns empty string or error message virtual QString ready() { return QString() ; }protected: //! Pointer to GRASS module QgsGrassModule *mModule; //! Option key, for flags without '-' QString mKey; //! Optional option id used by other options which depend on this QString mId; //! GRASS description QString mDescription; //! Hidden option or displayed bool mHidden; //! Predefined answer from config QString mAnswer;private:};/****************** QgsGrassModuleOption ************************//*! \class QgsGrassModuleOption * \brief GRASS option */class QgsGrassModuleOption: public QGroupBox, public QgsGrassModuleItem{ Q_OBJECT;public: /*! \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ QgsGrassModuleOption ( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, QWidget * parent = 0 ); //! Destructor ~QgsGrassModuleOption(); //! Control option enum ControlType { NoControl, LineEdit, ComboBox, SpinBox, CheckBoxes }; //! Control option enum ValueType { Double, Integer, String }; //! Output type enum OutputType { None, Vector, Raster }; //! Retruns list of options which will be passed to module virtual QStringList options(); //! True if this option is output bool isOutput() { return mIsOutput; } //! Returns output type int outputType() { return mOutputType; } //! If output, check if current output exists // Returns emppty string or name of existing output QString outputExists(); QString ready() ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -