itom 1.3.0
D:/git-itom/sources/itom/Qitom/organizer/designerWidgetOrganizer.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 DESIGNERWIDGETORGANIZER_H
00024 #define DESIGNERWIDGETORGANIZER_H
00025 
00026 #include "../../common/sharedStructures.h"
00027 #include "../../common/sharedStructuresGraphics.h"
00028 #include "../models/PlugInModel.h"
00029 #include "plot/AbstractItomDesignerPlugin.h"
00030 
00031 #include <qobject.h>
00032 #include <qlist.h>
00033 #include <qtranslator.h>
00034 
00035 class QPluginLoader; //forward declaration
00036 
00037 namespace ito
00038 {
00039 
00040 class DummyItomDesignerPlugin : public AbstractItomDesignerPlugin
00041 {
00042 public:
00043     QString name() const { return ""; }
00044     QString group() const { return ""; }
00045     QString toolTip() const { return ""; }
00046     QString whatsThis() const { return ""; }
00047     QString includeFile() const { return ""; }
00048     QIcon icon() const { return QIcon(); }
00049 
00050     bool isContainer() const { return false; }
00051 
00052     QWidget *createWidget(QWidget *parent) { return NULL; }
00053 
00054     DummyItomDesignerPlugin(QObject *parent) : AbstractItomDesignerPlugin(parent) {}
00055     virtual QWidget *createWidgetWithMode(ito::AbstractFigure::WindowMode winMode, QWidget *parent) { return NULL; }
00056 };
00057 
00058 struct FigurePlugin
00059 {
00060     FigurePlugin() : filename(""), classname(""), plotDataTypes(DataObjLine), plotFeatures(Static), factory(NULL) {}
00061     QString filename;
00062     QString classname;
00063     PlotDataTypes plotDataTypes;
00064     PlotDataFormats plotDataFormats;
00065     PlotFeatures plotFeatures;
00066     QIcon icon;
00067     QPluginLoader *factory;
00068 };
00069 
00070 struct FigureCategory
00071 {
00072 public:
00073     FigureCategory(const QString description, const PlotDataTypes allowedPlotDataTypes, const PlotDataFormats allowedPlotDataFormats, const PlotFeatures requiredPlotFeatures, const PlotFeatures excludedPlotFeatures, const QString defaultClassName)
00074         : m_description(description),
00075         m_allowedPlotDataTypes(allowedPlotDataTypes),
00076         m_allowedPlotDataFormats(allowedPlotDataFormats),
00077         m_requiredPlotFeatures(requiredPlotFeatures),
00078         m_excludedPlotFeatures(excludedPlotFeatures),
00079         m_defaultClassName(defaultClassName)
00080     {
00081     }
00082 
00083     FigureCategory() : m_description("") {}
00084 
00085     QString         m_description;
00086     PlotDataTypes   m_allowedPlotDataTypes;
00087     PlotDataFormats m_allowedPlotDataFormats;
00088     PlotFeatures    m_requiredPlotFeatures;
00089     PlotFeatures    m_excludedPlotFeatures;
00090     QString         m_defaultClassName;
00091 };
00092 
00093 class DesignerWidgetOrganizer : public QObject
00094 {
00095     Q_OBJECT
00096 
00097 public:
00098     
00099     DesignerWidgetOrganizer(ito::RetVal &retValue);
00100     ~DesignerWidgetOrganizer();
00101 
00102     const QList<PluginLoadStatus> getPluginLoadStatus() const { return m_pluginLoadStatus; }
00103     const QMap<QString, FigureCategory> getFigureCategories() const { return m_figureCategories; }
00104 
00105     bool figureClassExists( const QString &className );
00106     ito::RetVal figureClassMinimumRequirementCheck( const QString &className, int plotDataTypesMask, int plotDataFormatsMask, int plotFeaturesMask, bool *ok = NULL );
00107     QList<FigurePlugin> getPossibleFigureClasses( int plotDataTypesMask, int plotDataFormatsMask, int plotFeaturesMask );
00108     QList<FigurePlugin> getPossibleFigureClasses( const FigureCategory &figureCat );
00109     QString getFigureClass( const QString &figureCategory, const QString &defaultClassName, ito::RetVal &retVal );
00110     RetVal setFigureDefaultClass( const QString &figureCategory, const QString &defaultClassName);
00111     QStringList getPlotInputTypes(const int plotInputType);
00112     QStringList getPlotType(const int plotType);
00113     QStringList getPlotFeatures(const int plotFeatures);
00114     QStringList getPlotDataFormats(const int plotDataFormats);
00115 
00116     QWidget* createWidget(const QString &className, QWidget *parentWidget, const QString &name = QString(), AbstractFigure::WindowMode winMode = AbstractFigure::ModeStandaloneInUi);
00117 
00118 protected:
00119     RetVal scanDesignerPlugins();
00120 
00121 private:
00122     QList<FigurePlugin> m_figurePlugins;
00123     QList<PluginLoadStatus> m_pluginLoadStatus;
00124     QMap<QString, FigureCategory> m_figureCategories;
00125     QVector<QTranslator*> m_Translator;
00126 
00127 signals:
00128 
00129 public slots:
00130 
00131 private slots:
00132 
00133 };
00134 
00135 } //namespace ito
00136 
00137 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends