itom 2.2.1
K:/git-itom/sources/itom/Qitom/widgets/figureWidget.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet 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     Q_PROPERTY(QColor currentBorderColor READ currentBorderColor WRITE setCurrentBorderColor)
00051 
00052 
00053 public:
00054     FigureWidget(const QString &title, bool docked, bool isDockAvailable, int rows, int cols, QWidget *parent = 0, Qt::WindowFlags flags = 0);
00055     ~FigureWidget();
00056 
00057     RetVal plot(QSharedPointer<ito::DataObject> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00058 #if ITOM_POINTCLOUDLIBRARY > 0
00059     RetVal plot(QSharedPointer<ito::PCLPointCloud> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00060     RetVal plot(QSharedPointer<ito::PCLPolygonMesh> dataObj, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00061 #endif
00062     RetVal liveImage(QPointer<AddInDataIO> cam, int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00063 
00064     RetVal loadDesignerWidget(int areaRow, int areaCol, const QString &className, QWidget **canvasWidget);
00065 
00066     QWidget *getSubplot(int index) const;
00067 
00068     RetVal changeCurrentSubplot(int newIndex);
00069 
00070     //---------------------------------
00071     // setter / getter
00072     //---------------------------------
00073     void setFigHandle(QSharedPointer<unsigned int> figHandle) { m_guardedFigHandle = figHandle; }
00074 
00075 
00076     inline int rows() const { return m_rows; };
00077     inline int cols() const { return m_cols; };
00078 
00079     QColor currentBorderColor() const { return m_currentBorderColor; }
00080     void setCurrentBorderColor(QColor color);
00081 
00082 protected:
00083 
00084     QWidget* prepareWidget(const QString &plotClassName, int areaRow, int areaCol, RetVal &retval);
00085     void setMenusVisible(const QWidget *widget, bool visible);
00086 
00087     void createActions();
00088     void createMenus();
00089     void createToolBars();
00090     void createStatusBar();
00091     void updateActions();
00092     void updatePythonActions(){ updateActions(); }
00093 
00094     void closeEvent(QCloseEvent *event); // { event->accept(); };
00095 
00096     //bool eventFilter(QObject *obj, QEvent *event);
00097 
00098     QSharedPointer<ito::Param> getParamByInvoke(ito::AddInBase* addIn, const QString &paramName, ito::RetVal &retval);
00099 
00100 private:
00101     QGridLayout *m_pGrid;
00102     QWidget *m_pCenterWidget;
00103 
00104     QMenu *m_menuWindow;
00105     QMenu *m_menuSubplot;
00106     QAction *m_firstSysAction;
00107 
00108     QActionGroup *m_pSubplotActions;
00109 
00110     int m_rows;
00111     int m_cols;
00112     int m_curIdx;
00113 
00114     QColor m_currentBorderColor;
00115 
00116     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.
00117 
00118     QMap< QObject*, QList<QAction*> > m_menuStack;
00119 
00120     QVector<QWidget*> m_widgets;
00121 
00122 signals:
00123     
00124 private slots:
00125     void mnu_subplotActionsTriggered(QAction *action);
00126 };
00127 
00128 } //end namespace ito
00129 
00130 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends