iLand
mainwindow.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19
20#ifndef MAINWINDOW_H
21#define MAINWINDOW_H
22
23#if QT_VERSION < 0x050000
24#include <QtGui>
25#else
26#include <QtWidgets>
27#endif
28#include <vector>
29
30#include "grid.h"
31#include "tree.h"
32
33#include "modelcontroller.h"
34#include "paintarea.h"
35#include "viewport.h"
36
37class QQuickView;
38class Model;
39class Tree;
40class ResourceUnit;
41class MapGrid;
42class LayeredGridBase;
43class Colors;
44
45
46namespace Ui
47{
48 class MainWindowClass;
49}
50
51class MainWindow : public QMainWindow
52{
53 Q_OBJECT
54
55public:
56 MainWindow(QWidget *parent = 0);
57 // logging
58 static QPlainTextEdit* logSpace() { return mLogSpace; }
59 static QTextStream* logStream() { return mLogStream;}
61 Ui::MainWindowClass *uiclass() {return ui; }
62 Colors *ruler() { return mRulerColors; }
63public slots:
64 void repaint();
65 void yearSimulated(int year);
66 void modelFinished(QString errorMessage);
67 void checkModelState();
68 void bufferedLog(bool bufferLog);
69 QImage screenshot();
70 void paintGrid(MapGrid *map_grid,
71 const QString &name=QString(),
72 const GridViewType view_type=GridViewRainbow,
73 double min_val=0., double max_val=1.);
74 void paintGrid(const FloatGrid *grid,
75 const QString &name=QString(),
76 const GridViewType view_type=GridViewRainbow,
77 double min_val=0., double max_val=1.);
78 void addLayers(const LayeredGridBase *layer, const QString &name);
79
80 void addPaintLayers(QObject *handler, const QStringList names, const QVector<GridViewType> view_types=QVector<GridViewType>());
81 void removePaintLayers(QObject *handler);
82
83 void removeLayers(const LayeredGridBase *layer);
84
85 // set the next object to paint by name
86 void setPaintGrid(const QString grid_name);
87
88 void setViewport(QPointF center_point, double scale_px_per_m);
89 void setUIshortcuts(QVariantMap shortcuts);
90
91protected:
92 void closeEvent(QCloseEvent *event);
93
94private:
95 Ui::MainWindowClass *ui;
96 ModelController mRemoteControl;
97 QLabel *mStatusLabel;
98 QQuickView *mRuler;
99 Colors *mRulerColors;
100 // setup
101 void labelMessage(const QString message) { if (mStatusLabel) mStatusLabel->setText(message);}
102 void setupModel();
103 void readwriteCycle();
104 // paint
105 void updatePaintGridList();
107 PaintObject mPaintNext;
108 QMap<QString, PaintObject> mPaintList;
109 void paintGrid(QPainter &painter, PaintObject &object);
110
111 static QPlainTextEdit *mLogSpace;
112 static QTextStream *mLogStream;
113 void loadPicusIniFile(const QString &fileName);
114 // painter functions
115 void paintFON(QPainter &painter, QRect rect);
116 void paintMapGrid(QPainter &painter,
117 MapGrid *map_grid, const FloatGrid *float_grid, const Grid<double> *double_grid,
118 const GridViewType view_type,
119 double min_val=0., double max_val=1.,
120 bool shading=false);
121 Viewport vp;
122 QString dumpTreelist();
123 void applyCycles(int cycle_count=1);
124
125 void showTreeDetails(Tree* tree);
126 void showResourceUnitDetails(const ResourceUnit *ru);
127 bool showABEDetails(const QPointF &coord);
128
129 void readSettings();
130 void writeSettings();
131 // logging and outputs
132 void setupFileLogging(const bool do_start);
133 void batchLog(const QString s);
134 // visualization helper grid
135 Grid<float> mRegenerationGrid;
136 //recent file menu
137 void recentFileMenu();
138 QList<QString> mRecentFileList;
139
140private slots:
141 void automaticRun();
142 void updateLabel();
143
144 void on_actionWarning_triggered() { on_actionDebug_triggered(); }
145 void on_actionError_triggered() { on_actionDebug_triggered(); }
146 void on_actionInfo_triggered() { on_actionDebug_triggered(); }
147 void on_actionDebug_triggered();
148 void on_actionSnag_Dynamics_triggered();
149 void on_action_debugEstablishment_triggered();
150 void on_selectJavaScript_clicked();
151 void on_actionClearDebugOutput_triggered();
152 void on_pbLogFilterClear_clicked();
153 void on_pbFilterExecute_clicked();
154 void on_pbLogClearText_clicked();
155 void on_pbLogToClipboard_clicked();
156 void on_actionDaily_responses_Output_triggered();
157 void on_actionAbout_triggered();
158 void on_actionOnline_ressources_triggered();
159 void on_actionTimers_triggered();
160 void on_actionOutput_table_description_triggered();
161 void on_actionWater_Output_triggered();
162 void on_actionStop_triggered();
163 void on_actionPause_triggered();
164 void on_scriptCommand_returnPressed();
165 void on_reloadJavaScript_clicked();
166 void on_actionShow_Debug_Messages_triggered(bool checked);
167 void on_actionDynamic_Output_triggered();
168 void on_pbExecExpression_clicked();
169 void on_pbCalculateExpression_clicked();
170 void on_actionReload_triggered();
171 void on_actionRun_one_year_triggered();
172 void on_actionTree_NPP_triggered();
173 void on_actionSelect_Data_Types_triggered();
174 void on_actionTree_Growth_triggered();
175 void on_actionTree_Partition_triggered();
176 void on_action_debugSapling_triggered();
177 void on_actionModelRun_triggered();
178 void on_actionModelDestroy_triggered();
179 void on_actionModelCreate_triggered();
180 void on_actionFON_grid_triggered();
181 void on_actionTreelist_triggered();
182 void on_actionImageToClipboard_triggered();
183 void on_openFile_clicked();
184 void on_pbSetAsDebug_clicked();
185
186
187 void on_actionEdit_XML_settings_triggered();
188
189 void repaintArea(QPainter &painter);
190 void mouseClick(const QPoint& pos);
191 void mouseMove(const QPoint& pos);
192 void mouseDrag(const QPoint& from, const QPoint &to, const Qt::MouseButton button);
193 void mouseWheel(const QPoint& pos, int steps);
194 void executeJS(QString code);
195 void on_visFon_toggled();
196 void on_visDomGrid_toggled();
197 void on_visImpact_toggled();
198 void on_visImpact_clicked() { on_visFon_toggled(); } // force repeaint
199 void on_visSeeds_clicked() { on_visFon_toggled(); } // force repeaint
200 void on_visRegeneration_clicked() { on_visFon_toggled(); } // force repeaint
201 void on_visRegenNew_clicked() { on_visFon_toggled(); } // force repaint
202 void on_visResourceUnits_clicked() { on_visFon_toggled(); } // force repaint
203 void on_visOtherGrid_clicked() { on_visFon_toggled(); } // force repaint
204 void on_visShading_clicked() {on_visFon_toggled(); }
205 void on_actionPerformance_triggered();
206 void on_scriptCommandHistory_currentIndexChanged(int index);
207 void on_actionTest_triggered();
208 void on_pbReloadQml_clicked();
209 void on_actionExit_triggered();
210 void on_actionOpen_triggered();
211 //recent file menu
212 void menuRecent_Files();
213 void on_lJSShortcuts_linkActivated(const QString &link);
214
215 void on_actionShow_full_extent_triggered();
216 void on_actionRepaint_triggered();
217 void on_checkXMLFile_clicked();
218 void on_actionSave_regeneration_grid_triggered();
219 void on_pbLoadTree_clicked();
220 void on_otherGridTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
221 void on_dataTree_itemDoubleClicked(QTreeWidgetItem *item, int column);
222};
223
224#endif // MAINWINDOW_H
Definition: colors.h:29
Definition: layeredgrid.h:32
The main window of the iLand viewer.
Definition: mainwindow.h:21
void setPaintGrid(const QString grid_name)
Definition: mainwindow.cpp:589
void setUIshortcuts(QVariantMap shortcuts)
set the viewport (like interactive with mouse)
Definition: mainwindow.cpp:1945
void checkModelState()
Definition: mainwindow.cpp:442
void removePaintLayers(QObject *handler)
Definition: mainwindow.cpp:562
void closeEvent(QCloseEvent *event)
Definition: mainwindow.cpp:1964
void modelFinished(QString errorMessage)
Definition: mainwindow.cpp:1648
void addPaintLayers(QObject *handler, const QStringList names, const QVector< GridViewType > view_types=QVector< GridViewType >())
Definition: mainwindow.cpp:545
void bufferedLog(bool bufferLog)
Definition: mainwindow.cpp:196
void repaint()
force a repaint of the main drawing area
Definition: mainwindow.cpp:435
void addLayers(const LayeredGridBase *layer, const QString &name)
Definition: mainwindow.cpp:524
void removeLayers(const LayeredGridBase *layer)
Definition: mainwindow.cpp:577
MainWindow(QWidget *parent=0)
static QPlainTextEdit * logSpace()
Definition: mainwindow.h:58
void setViewport(QPointF center_point, double scale_px_per_m)
set the viewport of the main viewing window center_point is the point to zoom to (world coordinates),...
Definition: mainwindow.cpp:1925
Ui::MainWindowClass * uiclass()
Definition: mainwindow.h:61
void yearSimulated(int year)
Definition: mainwindow.cpp:1637
Colors * ruler()
Definition: mainwindow.h:62
QImage screenshot()
create a screenshot of the main painting area
Definition: mainwindow.cpp:1917
static QTextStream * logStream()
Definition: mainwindow.h:59
void paintGrid(MapGrid *map_grid, const QString &name=QString(), const GridViewType view_type=GridViewRainbow, double min_val=0., double max_val=1.)
Definition: mainwindow.cpp:599
Definition: mapgrid.h:32
Definition: modelcontroller.h:32
Main object of the iLand model composited of various sub models / sub components.
Definition: model.h:90
ResourceUnit is the spatial unit that encapsulates a forest stand and links to several environmental ...
Definition: resourceunit.h:49
A tree is the basic simulation entity of iLand and represents a single tree.
Definition: tree.h:44
Handles coordinaive transforation between grids (based on real-world metric coordinates).
Definition: viewport.h:24
GridViewType
Definition: grid.h:193
@ GridViewRainbow
Definition: grid.h:193
Definition: mainwindow.h:16
Definition: paintarea.h:28