itom
Loading...
Searching...
No Matches
AbstractFigure.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
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 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26*********************************************************************** */
27
28#ifndef ABSTRACTFIGURE_H
29#define ABSTRACTFIGURE_H
30
31#include "plotCommon.h"
32#include "AbstractNode.h"
33
34#include "../common/apiFunctionsGraphInc.h"
35#include "../common/apiFunctionsInc.h"
36
37#include <qmainwindow.h>
38#include <qlabel.h>
39#include <qtoolbar.h>
40#include <qevent.h>
41#include <qdockwidget.h>
42#include <qscopedpointer.h>
43
44class QPropertyEditorWidget; //forward declaration
45
46#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONPLOT_MOC) //only moc this file in itomCommonQtLib but not in other libraries or executables linking against this itomCommonQtLib
47
48//place this macro in the header file of the designer plugin widget class right before the first section (e.g. public:)
49#define DESIGNER_PLUGIN_ITOM_API \
50 protected: \
51 void importItomApi(void** apiPtr) \
52 {ito::ITOM_API_FUNCS = apiPtr;} \
53 void importItomApiGraph(void** apiPtr) \
54 { ito::ITOM_API_FUNCS_GRAPH = apiPtr;} \
55 public: \
56 //.
57
58namespace ito {
59
60class AbstractFigure; //forward declaration
61class AbstractFigurePrivate; //forward declaration
62
63class ITOMCOMMONPLOT_EXPORT AbstractFigure : public QMainWindow, public AbstractNode
64{
65 Q_OBJECT
66
67 Q_PROPERTY(bool toolbarVisible READ getToolbarVisible WRITE setToolbarVisible DESIGNABLE true USER true)
68 Q_PROPERTY(bool contextMenuEnabled READ getContextMenuEnabled WRITE setContextMenuEnabled DESIGNABLE true)
69 Q_PROPERTY(bool renderLegend READ getLegendRender WRITE setLegendRender DESIGNABLE true)
70
71 Q_CLASSINFO("prop://toolbarVisible", "Toggles the visibility of the toolbar of the plot.")
72 Q_CLASSINFO("prop://contextMenuEnabled", "Defines whether the context menu of the plot should be enabled or not.")
73 Q_CLASSINFO("prop://renderLegend", "If this property is true, the legend are included in pixelmaps renderings.")
74
75 Q_CLASSINFO("slot://getPlotID", "Return window ID of this plot {int}.")
76 Q_CLASSINFO("slot://refreshPlot", "Triggers an update of the current plot window.")
77
78 public:
79 enum WindowMode
80 {
81 ModeInItomFigure,
82 ModeStandaloneInUi,
83 ModeStandaloneWindow
84 };
85
86 enum UnitLabelStyle
87 {
88 UnitLabelSlash, // x-axis / m -> corresponds to DIN461
89 UnitLabelKeywordIn, // x-axis in m -> corresponds to DIN461
90 UnitLabelSquareBrackets // x-axis [m] -> does not correspond to DIN461
91 };
92
93 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
94 //values are always accessible.
95 Q_ENUM(WindowMode)
96 Q_ENUM(UnitLabelStyle)
97
98 struct ToolBarItem {
99 ToolBarItem() : toolbar(NULL), visible(1), section(0), key("") {}
100 QToolBar *toolbar;
101 bool visible;
102 int section;
103 Qt::ToolBarArea area;
104 QString key;
105 };
106
107 struct ToolboxItem {
108 ToolboxItem() : toolbox(NULL), key("") {}
109 QDockWidget *toolbox;
110 Qt::DockWidgetArea area;
111 QString key;
112 };
113
114 AbstractFigure(const QString &itomSettingsFile, WindowMode windowMode = ModeStandaloneInUi, QWidget *parent = 0);
115 virtual ~AbstractFigure();
116
117 virtual bool event(QEvent *e);
118 void setApiFunctionGraphBasePtr(void **apiFunctionGraphBasePtr);
119 void setApiFunctionBasePtr(void **apiFunctionBasePtr);
120 void ** getApiFunctionGraphBasePtr(void) { return m_apiFunctionsGraphBasePtr; }
121 void ** getApiFunctionBasePtr(void) { return m_apiFunctionsBasePtr; }
122
123 virtual RetVal update(void) = 0;
125 //properties
126 virtual void setToolbarVisible(bool visible);
127 virtual bool getToolbarVisible() const;
128 virtual void setContextMenuEnabled(bool show) = 0;
129 virtual bool getContextMenuEnabled() const = 0;
130
131 QDockWidget *getPropertyDockWidget() const;
132
133 virtual bool getLegendRender() const { return false;}
134 virtual void setLegendRender(const bool val) { return;}
135
136 QList<QMenu*> getMenus() const;
137 QList<AbstractFigure::ToolBarItem> getToolbars() const;
138 QList<AbstractFigure::ToolboxItem> getToolboxes() const; //the first toolbox is always the property dock widget
139 void setWindowTitleExtension(const QString& title); /*< call this method if the window title should be changed. This emits the signal windowTitleChanged which is connected to the plot window.*/
140
141 protected:
142
143 virtual RetVal init() { return retOk; } //this method is called from after construction and after that the api pointers have been transmitted
144
145 virtual void importItomApi(void** apiPtr) = 0;
146 virtual void importItomApiGraph(void** apiPtr) = 0;
148 void addToolBar(QToolBar *toolbar, const QString &key, Qt::ToolBarArea area = Qt::TopToolBarArea, int section = 1);
149 void addToolBarBreak(const QString &key, Qt::ToolBarArea area = Qt::TopToolBarArea);
151 void addToolbox(QDockWidget *toolbox, const QString &key, Qt::DockWidgetArea area = Qt::RightDockWidgetArea);
152 bool removeToolbox(const QString &key);
154 void showToolBar(const QString &key);
155 void hideToolBar(const QString &key);
157 void addMenu(QMenu *menu);
159 void updatePropertyDock();
160 void setPropertyObservedObject(QObject* obj);
162 RetVal initialize();
163
164 RetVal registerShortcutActions();
166 WindowMode getWindowMode() const;
167
168 QString getItomSettingsFile() const;
169
170 void **m_apiFunctionsGraphBasePtr;
171 void **m_apiFunctionsBasePtr;
172
173 private:
174 QScopedPointer<AbstractFigurePrivate> d_ptr;
176
177 private slots:
178 inline void mnuShowToolbar(bool /*checked*/) { setToolbarVisible(true); }
179 void mnuShowProperties(bool checked);
181 void toolBoxDestroyed(QObject *object);
182 void toolBarDestroyed(QObject *object);
183
184 void actionChanged();
185
186 public slots:
187 int getPlotID();
188 void refreshPlot() { update(); }
189
190 signals:
191 void windowTitleModified(QString windowTitleSuffix);
192};
193
194} // namespace ito
195
196#endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC)
197
198#endif // ABSTRACTFIGURE_H
The QPropertyEditorWidget offers an easy to use mechanism to visualize properties of a class inherite...
Definition QPropertyEditorWidget.h:67
Definition AbstractFigure.h:64
virtual void importItomApiGraph(void **apiPtr)=0
void mnuShowToolbar(bool)
Definition AbstractFigure.h:178
Q_DECLARE_PRIVATE(AbstractFigure)
void windowTitleModified(QString windowTitleSuffix)
virtual RetVal update(void)=0
update of this node if the values of all changed input channels are propagated to the corresponding i...
virtual void importItomApi(void **apiPtr)=0
Every plot designer plugin in itom, that should be able to open dependent sub-plots (e....
Definition AbstractNode.h:222
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40
Definition AbstractFigure.h:98
Definition AbstractFigure.h:107