itom  4.1.0
figureWidget.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, 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 <qsize.h>
42 #include <qsignalmapper.h>
43 
44 namespace ito {
45 
47 {
48  Q_OBJECT
49 
50  Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
51  Q_PROPERTY(QColor currentBorderColor READ currentBorderColor WRITE setCurrentBorderColor)
52 
53 
54 public:
55  FigureWidget(const QString &title, bool docked, bool isDockAvailable, int rows, int cols, QWidget *parent = 0, Qt::WindowFlags flags = 0);
56  ~FigureWidget();
57 
58  RetVal plot(QSharedPointer<ito::DataObject> dataObj,
59  QSharedPointer<ito::DataObject> xAxisObj,
60  int areaRow, int areaCol,
61  const QString &className,
62  QWidget **canvasWidget);
63 #if ITOM_POINTCLOUDLIBRARY > 0
64  RetVal plot(QSharedPointer<ito::PCLPointCloud> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
65  RetVal plot(QSharedPointer<ito::PCLPolygonMesh> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
66 #endif
67  RetVal liveImage(QPointer<AddInDataIO> cam, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
68 
69  RetVal loadDesignerWidget(int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
70 
71  QWidget *getSubplot(int index) const;
72 
73  RetVal changeCurrentSubplot(int newIndex);
74 
75  virtual QSize defaultSize() const;
76 
77  //---------------------------------
78  // setter / getter
79  //---------------------------------
80  void setFigHandle(QSharedPointer<unsigned int> figHandle) { m_guardedFigHandle = figHandle; }
81 
82 
83  inline int rows() const { return m_rows; };
84  inline int cols() const { return m_cols; };
85 
86  QColor currentBorderColor() const { return m_currentBorderColor; }
87  void setCurrentBorderColor(QColor color);
88 
89 protected:
90 
91  QWidget* prepareWidget(const QString &plotClassName, int areaRow, int areaCol, RetVal &retval);
92  void setMenusVisible(const QWidget *widget, bool visible);
93 
94  void createActions();
95  void createMenus();
96  void createToolBars();
97  void createStatusBar();
98  void updateActions();
99  void updatePythonActions(){ updateActions(); }
100 
101  void closeEvent(QCloseEvent *event); // { event->accept(); };
102 
103  //bool eventFilter(QObject *obj, QEvent *event);
104 
105  QSharedPointer<ito::Param> getParamByInvoke(ito::AddInBase* addIn, const QString &paramName, ito::RetVal &retval);
106 
107 private:
108  QGridLayout *m_pGrid;
109  QWidget *m_pCenterWidget;
110 
111  QMenu *m_menuWindow;
112  QMenu *m_menuSubplot;
113  QAction *m_firstSysAction;
114 
115  QActionGroup *m_pSubplotActions;
116 
117  int m_rows;
118  int m_cols;
119  int m_curIdx;
120 
121  QColor m_currentBorderColor;
122 
123  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.
124 
125  QMap< QObject*, QList<QAction*> > m_menuStack;
126 
127  QVector<QWidget*> m_widgets;
128 
129 signals:
130 
131 private slots:
132  void mnu_subplotActionsTriggered(QAction *action);
133 };
134 
135 } //end namespace ito
136 
137 #endif
Definition: figureWidget.h:46
void closeEvent(QCloseEvent *event)
closeEvent invoked if this AbstractDockWidget should be closed
Definition: figureWidget.cpp:119
Class for managing status values (like errors or warning)
Definition: retVal.h:54
Base class for all plugins.
Definition: addInInterface.h:385
Definition: apiFunctionsGraph.cpp:39
abstract dock widget class which inherits QDockWidget. The content of QDockWidget consists of an inst...
Definition: abstractDockWidget.h:54
virtual QSize defaultSize() const
returns the default size of this figure widget
Definition: figureWidget.cpp:106
bool docked() const
Definition: abstractDockWidget.h:128
~FigureWidget()
destructor
Definition: figureWidget.cpp:100