CInspectionTaskGuiComp.h
Go to the documentation of this file.
1 #ifndef iqtinsp_CInspectionTaskGuiComp_included
2 #define iqtinsp_CInspectionTaskGuiComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QString>
7 #include <QtCore/QMap>
8 #include <QtCore/QSet>
9 #include<QtCore/QtGlobal>
10 #if QT_VERSION >= 0x050000
11 #include <QtWidgets/QToolBox>
12 #include <QtWidgets/QTabWidget>
13 #else
14 #include <QtGui/QToolBox>
15 #include <QtGui/QTabWidget>
16 #endif
17 
18 // ACF includes
19 #include "istd/TPointerVector.h"
22 #include "ifile/IFilePersistence.h"
23 #include "ilog/CMessageContainer.h"
24 #include "iview/IShape.h"
25 #include "iview/IShapeFactory.h"
27 #include "iqt2d/IViewExtender.h"
28 #include "iqt2d/IViewProvider.h"
29 
30 // ACF-Solutions includes
31 #include "iinsp/IInspectionTask.h"
32 #include "GeneratedFiles/iqtinsp/ui_CInspectionTaskGuiComp.h"
33 
34 
35 namespace iqtinsp
36 {
37 
38 
39 class CInspectionTaskGuiCompBase: public iqtgui::TDesignerGuiObserverCompBase<Ui::CInspectionTaskGuiComp, iinsp::IInspectionTask>
40 {
41 public:
43 
44  I_BEGIN_BASE_COMPONENT(CInspectionTaskGuiCompBase);
45  I_ASSIGN_MULTI_0(m_namesAttrPtr, "Names", "List of of gui names", false);
46  I_ASSIGN(m_useHorizontalLayoutAttrPtr, "UseHorizontalLayout", "Use horizontal layout for tool box design", true, false);
47  I_ASSIGN(m_tabOrientationAttrPtr, "TabBarOrientation", "Orientation of the tab bar for tab design\n 0 - North\n 1 - South\n 2 - West\n 3 - East", true, 0);
48  I_ASSIGN(m_designTypeAttrPtr, "DesignType", "Type of design:\n* 1 - tool box\n* 2 - tab", true, 1);
49  I_ASSIGN(m_useVerticalSpacerAttrPtr, "UseVerticalSpacer", "Insert vertical spacer to shrunk the space at the bottom", true, true);
50  I_END_COMPONENT;
51 
52 protected:
53  I_MULTIATTR(QString, m_namesAttrPtr);
54  I_ATTR(bool, m_useHorizontalLayoutAttrPtr);
55  I_ATTR(int, m_tabOrientationAttrPtr);
56  I_ATTR(int, m_designTypeAttrPtr);
57  I_ATTR(bool, m_useVerticalSpacerAttrPtr);
58  I_ATTR(int, m_inspectionTaskIndexAttrPtr);
59 };
60 
61 
65 {
66  Q_OBJECT
67 
68 public:
70 
71  enum DataRole
72  {
73  DR_TASK_INDEX = Qt::UserRole + 1,
75  };
76 
77  I_BEGIN_COMPONENT(CInspectionTaskGuiComp);
78  I_ASSIGN_MULTI_0(m_editorsCompPtr, "Editors", "List of GUI's for subtask parameters edition", true);
79  I_ASSIGN_TO(m_editorGuisCompPtr, m_editorsCompPtr, true);
80  I_ASSIGN_TO(m_editorObserversCompPtr, m_editorsCompPtr, true);
81  I_ASSIGN_TO(m_editorViewExtendersCompPtr, m_editorsCompPtr, false);
82  I_ASSIGN_MULTI_0(m_editorVisualInfosCompPtr, "EditorVisualInfos", "List editor visual informations for each editor", false);
83  I_ASSIGN_TO(m_editorVisualModelsCompPtr, m_editorVisualInfosCompPtr, false);
84  I_ASSIGN_MULTI_0(m_previewGuisCompPtr, "PreviewGuis", "List of GUI's used as preview of subtask results (the same GUI object can be reused many times)", true);
85  I_ASSIGN_TO(m_previewObserversCompPtr, m_previewGuisCompPtr, false);
86  I_ASSIGN_TO(m_previewSceneProvidersCompPtr, m_previewGuisCompPtr, false);
87  I_ASSIGN(m_resultShapeFactoryCompPtr, "ResultShapeFactory", "Creates shapes to display on preview (if iqt2d::IViewProvider is used)", false, "ResultShapeFactory");
88  I_ASSIGN(m_paramsLoaderCompPtr, "ParamsLoader", "Loader for the parameter set", false, "ParamsLoader");
89  I_ASSIGN(m_generalParamsGuiCompPtr, "GeneralParamsGui", "Gui of general parameters", false, "GeneralParamsGui");
90  I_ASSIGN_TO(m_generalParamsObserverCompPtr, m_generalParamsGuiCompPtr, false);
91  I_ASSIGN_TO(m_generalParamsEditorCompPtr, m_generalParamsGuiCompPtr, false);
92  I_END_COMPONENT;
93 
95 
96  // reimplemented (imod::IModelEditor)
97  virtual void UpdateModel() const;
98  virtual void UpdateEditor(int updateFlags = 0);
99 
100  // reimplemented (imod::IObserver)
101  virtual bool OnAttached(imod::IModel* modelPtr);
102  virtual bool OnDetached(imod::IModel* modelPtr);
103 
104 protected:
105  void UpdateProcessingState();
106  void UpdateVisualElements();
107 
108  // reimplemented (iqtgui::CGuiComponentBase)
109  virtual void OnGuiCreated();
110  virtual void OnGuiDestroyed();
111  virtual void OnGuiHidden();
112 
113  // reimplemented (imod::CMultiModelDispatcherBase)
114  virtual void OnModelChanged(int modelId, int changeFlags, istd::IPolymorphic* updateParamsPtr);
115 
116 protected Q_SLOTS:
117  void OnEditorChanged(int index);
118  void OnAutoTest();
121  void OnLoadParams();
122  void OnSaveParams();
123  void OnCopyAll();
124  void OnPasteAll();
125  void OnCopyCurrent();
126  void OnPasteCurrent();
128  void on_MessageList_itemDoubleClicked(QTreeWidgetItem* item, int column);
129 
130 Q_SIGNALS:
131  void DoAutoTest();
132 
133 private:
134  void AddTaskMessagesToLog(const ilog::IMessageContainer& messageContainer, int taskIndex);
135  void UpdateTaskMessages();
136  void DoUpdateEditor(int taskIndex);
137  void ActivateTaskShapes(int taskIndex);
138  void CreateMenu();
139  void UpdateMenu();
140  bool CopyTaskParametersToClipboard(iser::ISerializable* objectPtr, const char* mimeType) const;
141  bool ReadTaskParametersFromClipboard(iser::ISerializable* objectPtr, const char* mimeType);
142 
143  // static methods
144  static QIcon GetCategoryIcon(istd::IInformationProvider::InformationCategory category);
145 
146 private:
147  I_MULTIREF(imod::IModelEditor, m_editorsCompPtr);
148  I_MULTIREF(iqtgui::IGuiObject, m_editorGuisCompPtr);
149  I_MULTIREF(imod::IObserver, m_editorObserversCompPtr);
150  I_MULTIREF(iqt2d::IViewExtender, m_editorViewExtendersCompPtr);
151  I_MULTIREF(iqtgui::IVisualStatus, m_editorVisualInfosCompPtr);
152  I_MULTIREF(imod::IModel, m_editorVisualModelsCompPtr);
153  I_MULTIREF(iqtgui::IGuiObject, m_previewGuisCompPtr);
154  I_MULTIREF(imod::IObserver, m_previewObserversCompPtr);
155  I_MULTIREF(iqt2d::IViewProvider, m_previewSceneProvidersCompPtr);
156  I_REF(iview::IShapeFactory, m_resultShapeFactoryCompPtr);
157  I_REF(ifile::IFilePersistence, m_paramsLoaderCompPtr);
158  I_REF(iqtgui::IGuiObject, m_generalParamsGuiCompPtr);
159  I_REF(imod::IObserver, m_generalParamsObserverCompPtr);
160  I_REF(imod::IModelEditor, m_generalParamsEditorCompPtr);
161 
162  int m_currentGuiIndex;
163  bool m_testStarted;
164 
165  typedef QMap<int, int> GuiMap;
166  GuiMap m_tabToStackIndexMap; // map GUI index (for editors) to stack index (for preview GUI)
167  GuiMap m_stackIndexToTabMap; // map stack index (for preview GUI) to GUI index (for editors)
168  GuiMap m_tabToGuiIndexMap; // map tab index to editor index
169 
170  typedef QMap<int, ilog::CMessageContainer> ResultMessagesMap;
171  ResultMessagesMap m_resultMessagesMap;
172 
173  typedef QMap<int, istd::TPointerVector<iview::IShape> > ResultShapesMap; // Map GUI index to list of result shapes
174  ResultShapesMap m_resultShapesMap;
175 
176  typedef QSet<imod::IModelEditor*> EditorsList;
177  EditorsList m_editorsList;
178 
179  QToolBox* m_toolBoxPtr;
180  QTabWidget* m_tabWidgetPtr;
181  QStackedWidget* m_stackedWidgetPtr;
182  QButtonGroup* m_buttonGroupPtr;
183 
184  QAction* m_copyAllActionPtr;
185  QAction* m_pasteAllActionPtr;
186  QAction* m_copyCurrentTaskActionPtr;
187  QAction* m_pasteCurrentTaskActionPtr;
188  QAction* m_loadAllActionPtr;
189  QAction* m_saveAllActionPtr;
190 };
191 
192 
193 } // namespace iqtinsp
194 
195 
196 #endif // !iqtinsp_CInspectionTaskGuiComp_included
197 
198 
virtual bool OnDetached(imod::IModel *modelPtr)
void on_MessageList_itemDoubleClicked(QTreeWidgetItem *item, int column)
CInspectionTaskGuiCompBase BaseClass
I_ASSIGN_TO(m_editorGuisCompPtr, m_editorsCompPtr, true)
virtual void UpdateEditor(int updateFlags=0)
virtual void OnModelChanged(int modelId, int changeFlags, istd::IPolymorphic *updateParamsPtr)
virtual void UpdateModel() const
iqtgui::TDesignerGuiObserverCompBase< Ui::CInspectionTaskGuiComp, iinsp::IInspectionTask > BaseClass
virtual bool OnAttached(imod::IModel *modelPtr)

© 2007-2011 Witold Gantzke and Kirill Lepskiy