itom  3.0.0
figureWidget.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef FIGUREWIDGET_H
24 #define FIGUREWIDGET_H
25 
26 #include "abstractDockWidget.h"
27 
28 #include "common/sharedStructures.h"
29 #include "DataObject/dataobj.h"
30 #if ITOM_POINTCLOUDLIBRARY > 0
31 #include "../../PointCloud/pclStructures.h"
32 #endif
33 #include "common/addInInterface.h"
34 
35 #include <qgridlayout.h>
36 #include <qsharedpointer.h>
37 #include <qpointer.h>
38 #include <qaction.h>
39 #include <qmenu.h>
40 #include <qevent.h>
41 #include <qsignalmapper.h>
42 
43 namespace ito {
44 
46 {
47  Q_OBJECT
48 
49  Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
50  Q_PROPERTY(QColor currentBorderColor READ currentBorderColor WRITE setCurrentBorderColor)
51 
52 
53 public:
54  FigureWidget(const QString &title, bool docked, bool isDockAvailable, int rows, int cols, QWidget *parent = 0, Qt::WindowFlags flags = 0);
55  ~FigureWidget();
56 
57  RetVal plot(QSharedPointer<ito::DataObject> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
58 #if ITOM_POINTCLOUDLIBRARY > 0
59  RetVal plot(QSharedPointer<ito::PCLPointCloud> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
60  RetVal plot(QSharedPointer<ito::PCLPolygonMesh> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
61 #endif
62  RetVal liveImage(QPointer<AddInDataIO> cam, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
63 
64  RetVal loadDesignerWidget(int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
65 
66  QWidget *getSubplot(int index) const;
67 
68  RetVal changeCurrentSubplot(int newIndex);
69 
70  //---------------------------------
71  // setter / getter
72  //---------------------------------
73  void setFigHandle(QSharedPointer<unsigned int> figHandle) { m_guardedFigHandle = figHandle; }
74 
75 
76  inline int rows() const { return m_rows; };
77  inline int cols() const { return m_cols; };
78 
79  QColor currentBorderColor() const { return m_currentBorderColor; }
80  void setCurrentBorderColor(QColor color);
81 
82 protected:
83 
84  QWidget* prepareWidget(const QString &plotClassName, int areaRow, int areaCol, RetVal &retval);
85  void setMenusVisible(const QWidget *widget, bool visible);
86 
87  void createActions();
88  void createMenus();
89  void createToolBars();
90  void createStatusBar();
91  void updateActions();
92  void updatePythonActions(){ updateActions(); }
93 
94  void closeEvent(QCloseEvent *event); // { event->accept(); };
95 
96  //bool eventFilter(QObject *obj, QEvent *event);
97 
98  QSharedPointer<ito::Param> getParamByInvoke(ito::AddInBase* addIn, const QString &paramName, ito::RetVal &retval);
99 
100 private:
101  QGridLayout *m_pGrid;
102  QWidget *m_pCenterWidget;
103 
104  QMenu *m_menuWindow;
105  QMenu *m_menuSubplot;
106  QAction *m_firstSysAction;
107 
108  QActionGroup *m_pSubplotActions;
109 
110  int m_rows;
111  int m_cols;
112  int m_curIdx;
113 
114  QColor m_currentBorderColor;
115 
116  QSharedPointer<unsigned int> m_guardedFigHandle; //this figure holds its own reference, this is deleted if this figure is closed by a close-event or if the close-method is called.
117 
118  QMap< QObject*, QList<QAction*> > m_menuStack;
119 
120  QVector<QWidget*> m_widgets;
121 
122 signals:
123 
124 private slots:
125  void mnu_subplotActionsTriggered(QAction *action);
126 };
127 
128 } //end namespace ito
129 
130 #endif
Definition: figureWidget.h:45
void closeEvent(QCloseEvent *event)
closeEvent invoked if this AbstractDockWidget should be closed
Definition: figureWidget.cpp:104
Class for managing status values (like errors or warning)
Definition: retVal.h:54
Base class for all plugins.
Definition: addInInterface.h:356
Definition: apiFunctionsGraph.cpp:39
abstract dock widget class which inherits QDockWidget. The content of QDockWidget consists of an inst...
Definition: abstractDockWidget.h:45
bool docked() const
Definition: abstractDockWidget.h:86
~FigureWidget()
destructor
Definition: figureWidget.cpp:93