itom 1.3.0
D:/git-itom/sources/itom/Qitom/widgets/figureWidget.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef FIGUREWIDGET_H
00024 #define FIGUREWIDGET_H
00025 
00026 #include "abstractDockWidget.h"
00027 
00028 #include "common/sharedStructures.h"
00029 #include "DataObject/dataobj.h"
00030 #if ITOM_POINTCLOUDLIBRARY > 0
00031 #include "../../PointCloud/pclStructures.h"
00032 #endif
00033 #include "common/addInInterface.h"
00034 
00035 #include <qgridlayout.h>
00036 #include <qsharedpointer.h>
00037 #include <qpointer.h>
00038 #include <qaction.h>
00039 #include <qmenu.h>
00040 #include <qevent.h>
00041 #include <qsignalmapper.h>
00042 
00043 namespace ito {
00044 
00045 class FigureWidget : public AbstractDockWidget
00046 {
00047     Q_OBJECT
00048 
00049     Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
00050 
00051 
00052 public:
00053     FigureWidget(const QString &title, bool docked, bool isDockAvailable, int rows, int cols, QWidget *parent = 0, Qt::WindowFlags flags = 0);
00054     ~FigureWidget();
00055 
00056     RetVal plot(QSharedPointer<ito::DataObject> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00057 #if ITOM_POINTCLOUDLIBRARY > 0
00058     RetVal plot(QSharedPointer<ito::PCLPointCloud> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00059     RetVal plot(QSharedPointer<ito::PCLPolygonMesh> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00060 #endif
00061     RetVal liveImage(QPointer<AddInDataIO> cam, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00062 
00063     RetVal loadDesignerWidget(int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00064 
00065     QWidget *getSubplot(int index) const;
00066 
00067     RetVal changeCurrentSubplot(int newIndex);
00068 
00069     //---------------------------------
00070     // setter / getter
00071     //---------------------------------
00072     void setFigHandle(QSharedPointer<unsigned int> figHandle) { m_guardedFigHandle = figHandle; }
00073 
00074 
00075     inline int rows() const { return m_rows; };
00076     inline int cols() const { return m_cols; };
00077 
00078 protected:
00079 
00080     QWidget* prepareWidget(const QString &plotClassName, int areaRow, int areaCol, RetVal &retval);
00081 
00082     void createActions();
00083     void createMenus();
00084     void createToolBars();
00085     void createStatusBar();
00086     void updateActions();
00087     void updatePythonActions(){ updateActions(); }
00088 
00089     void closeEvent(QCloseEvent *event); // { event->accept(); };
00090 
00091     //bool eventFilter(QObject *obj, QEvent *event);
00092 
00093     QSharedPointer<ito::Param> getParamByInvoke(ito::AddInBase* addIn, const QString &paramName, ito::RetVal &retval);
00094 
00095 private:
00096     QGridLayout *m_pGrid;
00097     QWidget *m_pCenterWidget;
00098 
00099     QMenu *m_menuWindow;
00100     QMenu *m_menuSubplot;
00101     QAction *m_firstSysAction;
00102 
00103     QActionGroup *m_pSubplotActions;
00104 
00105     int m_rows;
00106     int m_cols;
00107     int m_curIdx;
00108 
00109     QSharedPointer<unsigned int> m_guardedFigHandle; //this figure holds it own reference, this is deleted if this figure is closed by a close-event or if the close-method is called.
00110 
00111     QMap< QObject*, QList<QAction*> > m_menuStack;
00112 
00113     QVector<QWidget*> m_widgets;
00114 
00115 signals:
00116     
00117 private slots:
00118     void mnu_subplotActionsTriggered(QAction *action);
00119 };
00120 
00121 } //end namespace ito
00122 
00123 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends