~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to plugins/grass/qgsgrassmodule.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Halasz
  • Date: 2005-11-05 16:04:45 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051105160445-l0g4isz5bc9yehet
Tags: 0.7.4-1
* New upstream release
* Build GRASS support in qgis-plugin-grass package (Closes: #248649)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                              qgsgrasstools.h 
 
3
                             -------------------
 
4
    begin                : March, 2005
 
5
    copyright            : (C) 2005 by Radim Blazek
 
6
    email                : blazek@itc.it
 
7
 ***************************************************************************/
 
8
/***************************************************************************
 
9
 *                                                                         *
 
10
 *   This program is free software; you can redistribute it and/or modify  *
 
11
 *   it under the terms of the GNU General Public License as published by  *
 
12
 *   the Free Software Foundation; either version 2 of the License, or     *
 
13
 *   (at your option) any later version.                                   *
 
14
 *                                                                         *
 
15
 ***************************************************************************/
 
16
#ifndef QGSGRASSMODULE_H
 
17
#define QGSGRASSMODULE_H
 
18
 
 
19
class QCloseEvent;
 
20
class QString;
 
21
class QStringList;
 
22
class QGroupBox;
 
23
class QVGroupBox;
 
24
class QFrame;
 
25
class QListView;
 
26
class QDomNode;
 
27
class QDomElement;
 
28
class QComboBox;
 
29
class QLineEdit;
 
30
class QPixmap;
 
31
 
 
32
#include <vector>
 
33
#include <qgroupbox.h>
 
34
#include <qvgroupbox.h>
 
35
#include <qcheckbox.h>
 
36
#include <qprocess.h>
 
37
 
 
38
// Must be here, so that it is included to moc file
 
39
#include "../../src/qgisapp.h"
 
40
#include "../../src/qgisiface.h"
 
41
 
 
42
class QgsGrassProvider;
 
43
class QgsGrassTools;
 
44
class QgsGrassModuleItem;
 
45
#include "qgsgrassmodulebase.h"
 
46
 
 
47
/*! \class QgsGrassModule
 
48
 *  \brief Interface to GRASS modules.
 
49
 *
 
50
 */
 
51
class QgsGrassModule: public QgsGrassModuleBase 
 
52
{
 
53
    Q_OBJECT;
 
54
 
 
55
public:
 
56
    //! Constructor
 
57
    QgsGrassModule ( QgsGrassTools *tools, QgisApp *qgisApp, QgisIface *iface,  
 
58
                   QString path, QWidget * parent = 0, const char * name = 0, WFlags f = 0 );
 
59
 
 
60
    //! Destructor
 
61
    ~QgsGrassModule();
 
62
 
 
63
    //! Returns module label for module description path
 
64
    static QString label ( QString path );
 
65
 
 
66
    /** \brief Returns pixmap representing the module 
 
67
     * \param path module path without .qgm extension
 
68
     */
 
69
    static QPixmap pixmap ( QString path, int height );
 
70
 
 
71
    //! Find element in GRASS module description by key, if not found, returned element is null
 
72
    static QDomNode nodeByKey ( QDomElement gDocElem, QString key );
 
73
 
 
74
    //! Returns pointer to QGIS interface 
 
75
    QgisIface *qgisIface();
 
76
 
 
77
    //! Returns pointer to QGIS application
 
78
    QgisApp *qgisApp();
 
79
 
 
80
public slots:
 
81
    //! Run the module with current options
 
82
    void run ();
 
83
 
 
84
    //! Close the module tab
 
85
    void close ();
 
86
 
 
87
    //! Running process finished
 
88
    void finished ();
 
89
 
 
90
    //! Read module's standard output
 
91
    void readStdout();
 
92
 
 
93
    //! Read module's standard error
 
94
    void readStderr();
 
95
 
 
96
private:
 
97
    //! QGIS application
 
98
    QgisApp *mQgisApp;
 
99
 
 
100
    //! Pointer to the QGIS interface object
 
101
    QgisIface *mIface;
 
102
 
 
103
    //! Pointer to canvas
 
104
    QgsMapCanvas *mCanvas;
 
105
 
 
106
    //! Pointer to GRASS Tools 
 
107
    QgsGrassTools *mTools;
 
108
 
 
109
    //! Module definition file path (.qgm file)
 
110
    QString mPath;
 
111
 
 
112
    //! Name of module executable 
 
113
    QString mXName;
 
114
 
 
115
    //! Path to module executable 
 
116
    QString mXPath;
 
117
 
 
118
    //! Parent widget
 
119
    QWidget *mParent;
 
120
 
 
121
    //! Option items
 
122
    std::vector<QgsGrassModuleItem*> mItems;
 
123
 
 
124
    //! Running GRASS module
 
125
    QProcess mProcess;
 
126
 
 
127
    //! QGIS directory
 
128
    QString mAppDir;
 
129
};
 
130
 
 
131
/*! \class QgsGrassModuleItem
 
132
 *  \brief GRASS module option
 
133
 */
 
134
class QgsGrassModuleItem
 
135
{
 
136
public:
 
137
    /*! \brief Constructor
 
138
     * \param qdesc option element in QGIS module description XML file
 
139
     * \param gdesc GRASS module XML description file
 
140
     * \param gnode option node in GRASS module XML description file
 
141
     */
 
142
    QgsGrassModuleItem ( QgsGrassModule *module, QString key, 
 
143
                         QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode );
 
144
 
 
145
    //! Destructor
 
146
    virtual ~QgsGrassModuleItem();
 
147
 
 
148
    //! Is the item hidden
 
149
    bool hidden();
 
150
 
 
151
    //! Retruns list of options which will be passed to module
 
152
    virtual QStringList options(); 
 
153
 
 
154
protected:
 
155
 
 
156
    //! Pointer to GRASS module
 
157
    QgsGrassModule *mModule;
 
158
 
 
159
    //! Option key, for flags without '-'
 
160
    QString mKey;
 
161
 
 
162
    //! GRASS description
 
163
    QString mDescription;
 
164
 
 
165
    //! Hidden option or displayed
 
166
    bool mHidden;
 
167
 
 
168
    //! Predefined answer from config
 
169
    QString mAnswer;
 
170
private:
 
171
 
 
172
};
 
173
 
 
174
/*! \class QgsGrassModuleOption
 
175
 *  \brief  GRASS option 
 
176
 */
 
177
class QgsGrassModuleOption: public QVGroupBox, public QgsGrassModuleItem
 
178
{
 
179
    Q_OBJECT;
 
180
 
 
181
public:
 
182
    /*! \brief Constructor
 
183
     * \param qdesc option element in QGIS module description XML file
 
184
     * \param gdesc GRASS module XML description file
 
185
     */
 
186
    QgsGrassModuleOption ( QgsGrassModule *module, QString key,
 
187
                          QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
 
188
                          QWidget * parent = 0 );
 
189
 
 
190
    //! Destructor
 
191
    ~QgsGrassModuleOption();
 
192
 
 
193
    //! Control option
 
194
    enum ControlType { LineEdit, ComboBox, SpinBox, CheckBoxes };
 
195
    
 
196
    //! Retruns list of options which will be passed to module
 
197
    virtual QStringList options(); 
 
198
    
 
199
 
 
200
private:
 
201
    //! Control type
 
202
    ControlType mControlType;
 
203
    
 
204
    //! Combobox
 
205
    QComboBox *mComboBox;
 
206
 
 
207
    //! Vector of values for combobox
 
208
    std::vector<QString> mValues;
 
209
 
 
210
    //! Check boxes
 
211
    std::vector<QCheckBox*> mCheckBoxes;
 
212
    
 
213
    //! Combobox
 
214
    QLineEdit *mLineEdit;
 
215
};
 
216
 
 
217
/*! \class QgsGrassModuleFlag
 
218
 *  \brief  GRASS flag
 
219
 */
 
220
class QgsGrassModuleFlag: public QCheckBox, public QgsGrassModuleItem
 
221
{
 
222
    Q_OBJECT;
 
223
 
 
224
public:
 
225
    /*! \brief Constructor
 
226
     * \param qdesc option element in QGIS module description XML file
 
227
     * \param gdesc GRASS module XML description file
 
228
     */
 
229
    QgsGrassModuleFlag ( QgsGrassModule *module, QString key,
 
230
                          QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
 
231
                          QWidget * parent = 0 );
 
232
 
 
233
    //! Destructor
 
234
    ~QgsGrassModuleFlag();
 
235
    //! Retruns list of options which will be passed to module
 
236
    virtual QStringList options(); 
 
237
private:
 
238
};
 
239
 
 
240
/*! \class QgsGrassModuleInput
 
241
 *  \brief Class representing raster or vector module input
 
242
 */
 
243
class QgsGrassModuleInput: public QVGroupBox, public QgsGrassModuleItem
 
244
{
 
245
    Q_OBJECT;
 
246
 
 
247
public:
 
248
    /*! \brief Constructor
 
249
     * \param qdesc option element in QGIS module description XML file
 
250
     * \param gdesc GRASS module XML description file
 
251
     */
 
252
    QgsGrassModuleInput ( QgsGrassModule *module, QString key,
 
253
                          QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
 
254
                          QWidget * parent = 0 );
 
255
 
 
256
    //! Destructor
 
257
    ~QgsGrassModuleInput();
 
258
 
 
259
    enum Type { Vector, Raster };
 
260
 
 
261
    //! Retruns list of options which will be passed to module
 
262
    virtual QStringList options(); 
 
263
 
 
264
public slots:
 
265
    //! Fill combobox with currently available maps in QGIS canvas
 
266
    void updateQgisLayers();
 
267
 
 
268
private:
 
269
    //! Input type
 
270
    Type mType;
 
271
 
 
272
    //! Vector type mask read from option defined by "typeoption" tag, used for QGIS layers in combo
 
273
    //  + type mask defined in configuration fil
 
274
    int mVectorTypeMask;    
 
275
 
 
276
    //! Name of vector type option associated with this input
 
277
    QString mVectorTypeOption;
 
278
    
 
279
    //! Name of vector layer option associated with this input
 
280
    QString mVectorLayerOption;
 
281
    
 
282
    //! Combobox for QGIS layers
 
283
    QComboBox *mLayerComboBox;
 
284
 
 
285
    //! Vector of map@mapset in the combobox
 
286
    std::vector<QString> mMaps;
 
287
    
 
288
    //! Type of vector in the combobox
 
289
    std::vector<QString> mVectorTypes;
 
290
    
 
291
    //! Layers of vector in the combobox
 
292
    std::vector<QString> mVectorLayers;
 
293
 
 
294
    //! The imput map will be updated -> must be from current mapset
 
295
    bool mUpdate;
 
296
};
 
297
#endif // QGSGRASSMODULE_H