cherish
MainWindow.h
1 #ifndef MAINWINDOW
2 #define MAINWINDOW
3 
4 #include <QMainWindow>
5 #include <QMdiArea>
6 #include <QDesktopWidget>
7 #include <QTableWidget>
8 #include <QTabWidget>
9 #include <QListWidget>
10 #include <QMenuBar>
11 #include <QUndoStack>
12 #include <QUndoView>
13 #include <QToolButton>
14 #include <QWidgetAction>
15 #include <QFileSystemModel>
16 #include <QColorDialog>
17 #include <QAction>
18 #include <QObject>
19 #include <QString>
20 
21 #include <osg/ref_ptr>
22 #include <osg/Camera>
23 
24 #include "RootScene.h"
25 #include "Settings.h"
26 #include "GLWidget.h"
27 #include "CameraProperties.h"
28 #include "ListWidget.h"
29 #include "TreeWidget.h"
30 #include "ListView.h"
31 #include "PhotoModel.h"
32 #include "Data.h"
33 
37 class BookmarkAction : public QAction
38 {
39  Q_OBJECT
40 public:
41  BookmarkAction(const QString& name, QObject* parent)
42  : QAction(name, parent)
43  {
44  this->connect(this, SIGNAL(triggered(bool)), this, SLOT(onTriggered()));
45  }
46 
47 public slots:
48  void onTriggered()
49  {
50  emit triggeredName(this->text());
51  }
52 
53 signals:
54  void triggeredName(const QString& name);
55 };
56 
57 
61 class MainWindow : public QMainWindow {
62  Q_OBJECT
63 
64 public:
66  explicit MainWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0);
67 
69  ~MainWindow();
70 
72  static MainWindow& instance();
73 
75  const RootScene* getRootScene() const;
76 
78  entity::Canvas* getCanvasCurrent() const;
79 
81  osg::Camera* getCamera() const;
82 
85  void setCameraView(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, const double& fov2);
86 
88  bool getStrokeFogFactor() const;
89 
91  QPixmap getScreenshot(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up);
92 
94  int getViewportWidth() const;
95 
97  int getViewportHeight() const;
98 
100  osg::Vec4f getCurrentColor() const;
101 
104  double getFOV2() const;
105 
107  BookmarkWidget* getBookmarkWidget();
108 
110  void openFile(const QString& fname);
111 
112 public slots:
114  void onSetTabletActivity(bool active);
115 
117  void onRequestUpdate();
118 
120  void onAutoSwitchMode(cher::MOUSE_MODE mode);
121 
123  void onRequestBookmarkSet(int row);
124 
126  void onDeleteBookmark(const QModelIndex &index);
127 
129  void onDeleteCanvas(const QModelIndex& index);
130 
132  void onDeletePhoto(const QModelIndex& index);
133 
135  void onVisibilitySetCanvas(int index);
136 
138  void onMoveBookmark(const QModelIndex &index);
139 
141  void onApplyStateBookmark(const QModelIndex& index);
142 
144  void onBookmarkAddedToWidget(const QModelIndex &, int first, int last);
145 
147  void onBookmarkRemovedFromWidget(const QModelIndex &, int first, int last);
148 
150  void onMouseModeSet(cher::MOUSE_MODE mode);
151 
153  void onPhotoTransparencyPlus(const QModelIndex& index);
154 
156  void onPhotoTransparencyMinus(const QModelIndex& index);
157 
159  void onPhotoPushed(int parent, int start, int, int destination, int);
160 
162  void onRequestSceneData(entity::SceneState* state);
163 
165  void onRequestSceneStateSet(entity::SceneState* state);
166 
168  void onRequestSceneToolStatus(bool& visibility);
169 
171  void onImportPhoto(const QString& path, const QString& fileName);
172 
178  void onRequestCanvasCreate(const osg::Vec3f& eye, const osg::Vec3f& center, const osg::Vec3f& up);
179 
182  void onCanvasClicked(const QModelIndex& index);
183 
184 protected slots:
185  /* NOTE: there should be no private slots, since all are used for unit tests */
186  void onFileNew();
187  void onFileOpen();
188  void onFileSave();
189  void onFileSaveAs();
190  void onFileExport();
191  void onFileImage();
192  void onFilePhotoBase();
193  void onFileClose();
194  void onFileExit();
195 
196  void onCut();
197  void onCopy();
198  void onPaste();
199  void onTools();
200 
201  void onCameraOrbit();
202  void onCameraZoom();
203  void onCameraPan();
204  void onCameraAperture();
205  void onHomeView();
206  void onViewAllCanvas();
207 
208  void onSelect();
209  void onSelect3d();
210  void onErase();
211  void onDelete();
212  void onSketch();
213  void onPolygon();
214  void onLineSegment();
215 
216  void onNewCanvasClone();
217  void onNewCanvasXY();
218  void onNewCanvasYZ();
219  void onNewCanvasZY();
220  void onNewCanvasXZ();
221  void onNewCanvasOrtho();
222  void onNewCanvasSeparate();
223  void onNewCanvasStandard();
224  void onNewCanvasCoaxial();
225  void onNewCanvasParallel();
226  void onNewCanvasRing();
227 
228 // void onCanvasOffset();
229 // void onCanvasRotate();
230  void onCanvasEdit();
231 
232  void onImageMove();
233  void onImageRotate();
234  void onImageScale();
235  void onImageFlipH();
236  void onImageFlipV();
237 
238  void onStrokesPush();
239 
240  void onBookmark();
241  void onBookmarkNew();
242  void onBookmarkSketch();
243  void onBookmarkEdit(const QString& name);
244 
245  void onStrokeFogFactor();
246 
247 protected:
248  void initializeActions();
249  void initializeMenus();
250  void initializeToolbars();
251  void initializeCallbacks(); // for ctor
252  bool loadSceneFromFile();
253 
254  bool importPhoto(QString& fileName);
255  void setSceneState(const entity::SceneState* state);
256 
261  void addMenuBookmark(const QString& name);
262 
263  QMdiArea* m_mdiArea;
264 
265  QTabWidget* m_tabWidget;
266  BookmarkWidget* m_bookmarkWidget;
267  CanvasPhotoWidget* m_canvasWidget;
268  PhotoWidget* m_photoWidget;
269  PhotoModel* m_photoModel;
270 
271 
272  // http://doc.qt.io/qt-5/qtwidgets-tools-undoframework-example.html
273  QUndoStack* m_undoStack;
274 
275  QMenuBar* m_menuBar;
276  QMenu* m_submenuBookmarks;
277  osg::ref_ptr<RootScene> m_rootScene; // main scene graph
278  QUndoStack* m_viewStack;
279  GLWidget* m_glWidget;
280 
281  // FILE actions
282  QAction * m_actionNewFile, * m_actionClose, * m_actionExit,
283  * m_actionImportImage, * m_actionOpenFile, * m_actionSaveFile,
284  * m_actionSaveAsFile, * m_actionExportAs, * m_actionPhotoBase;
285 
286  // EDIT actions
287  QAction * m_actionUndo, * m_actionRedo, * m_actionCut, * m_actionCopy,
288  * m_actionPaste, * m_actionDelete,
289  * m_actionTools;
290 
291  /* CAMERA actions */
292  QAction * m_actionOrbit, * m_actionPan, * m_actionZoom
293  , * m_actionPrevView, * m_actionNextView, * m_actionBookmark/*, * m_actionBookmarkNew*/
294  , * m_actionBookmarkSketch , * m_actionCameraSettings, * m_actionHomeView, * m_actionViewAllCanvas;
295 
296  // SCENE actions
297  QAction * m_actionSketch, * m_actionEraser, * m_actionSelect, * m_actionSelect3d, * m_actionPolygon
298  , * m_actionLinesegment
299  // New Canvas sub-menu
300  , * m_actionCanvasClone, * m_actionCanvasXY, * m_actionCanvasYZ, * m_actionCanvasZY, * m_actionCanvasXZ
301  , * m_actionCanvasOrtho, * m_actionCanvasSeparate
302  // New Canvas Set sub-menu
303  , * m_actionSetStandard
304 // , * m_actionSetParallel, * m_actionSetCoaxial, * m_actionSetRing
305  // Edit Canvas
306  , * m_actionCanvasEdit
307  // Edit Strokes
308  , * m_actionStrokesPush
309  ;
310 
311  // OPTION actions
312  QAction* m_actionStrokeFogFactor;
313 
314  CameraProperties* m_cameraProperties;
315 
316  QColorDialog* m_colorDialog;
317 
318  static MainWindow* m_instance;
319 };
320 
321 #endif // MAINWINDOW
322 
Definition: PhotoModel.h:17
Definition: Canvas.h:31
Contains all the entities that will appear on the scene: both user scene and utility entities (i...
Definition: RootScene.h:46
MOUSE_MODE
Definition: Settings.h:97
A proxy class connecting QOpenGLWidget with the content of RootScene; and also to transmit events...
Definition: GLWidget.h:52
Settings is a configuration variables file for Cherish: enums, consts, defaults. Contains settings su...
Class that serves as a local image file browser and allows to view all the image file of a given dire...
Definition: ListView.h:14
Re-defined QTreeWidget that contains info on canvases and their photos. Contains method to obtain cor...
Definition: TreeWidget.h:12
Widget that contains camera aperture properties.
Definition: CameraProperties.h:15
Action to edit bookmark data which was created by means of SVMData.
Definition: MainWindow.h:37
Re-defined QMainWindow that contains all the GUI elements such as GLWidget, menu bars, tool bars and other widgets.
Definition: MainWindow.h:61
Re-defined QListWidget that contains a method to obtain the corresponding delegate.
Definition: ListWidget.h:18
A class to describe the current state of the scene, e.g., state of switches.
Definition: SceneState.h:29