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>
28 #include <iqt2d/IViewExtender.h>
29 #include <iqt2d/IViewProvider.h>
30 
31 // ACF-Solutions includes
32 #include <iinsp/IInspectionTask.h>
34 #include <GeneratedFiles/iqtinsp/ui_CInspectionTaskGuiComp.h>
35 
36 
37 namespace iqtinsp
38 {
39 
40 
43  Ui::CInspectionTaskGuiComp, iinsp::IInspectionTask>
44 {
45 public:
47  Ui::CInspectionTaskGuiComp, iinsp::IInspectionTask> BaseClass;
48 
49  I_BEGIN_BASE_COMPONENT(CInspectionTaskGuiCompBase);
50  I_ASSIGN_MULTI_0(m_namesAttrPtr, "Names", "List of of GUI names", false);
51  I_ASSIGN(m_useHorizontalLayoutAttrPtr, "UseHorizontalLayout", "Use horizontal layout for tool box design", true, false);
52  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);
53  I_ASSIGN(m_designTypeAttrPtr, "DesignType", "Type of design:\n* 1 - tool box\n* 2 - tab", true, 1);
54  I_ASSIGN(m_useVerticalSpacerAttrPtr, "UseVerticalSpacer", "Insert vertical spacer to shrunk the space at the bottom", true, true);
55  I_END_COMPONENT;
56 
57 protected:
58  I_MULTITEXTATTR(m_namesAttrPtr);
59  I_ATTR(bool, m_useHorizontalLayoutAttrPtr);
60  I_ATTR(int, m_tabOrientationAttrPtr);
61  I_ATTR(int, m_designTypeAttrPtr);
62  I_ATTR(bool, m_useVerticalSpacerAttrPtr);
63  I_ATTR(int, m_inspectionTaskIndexAttrPtr);
64 };
65 
66 
68  public iqtgui::TRestorableGuiWrap< TResultShapeCreatorWrap<CInspectionTaskGuiCompBase> >,
70 {
71  Q_OBJECT
72 
73 public:
75 
76  enum DataRole
77  {
78  DR_TASK_INDEX = Qt::UserRole + 1,
81  };
82 
83  enum
84  {
87  };
88 
89  I_BEGIN_COMPONENT(CInspectionTaskGuiComp);
90  I_ASSIGN_MULTI_0(m_editorsCompPtr, "Editors", "List of GUI's for subtask parameters edition", true);
91  I_ASSIGN_TO(m_editorGuisCompPtr, m_editorsCompPtr, true);
92  I_ASSIGN_TO(m_editorObserversCompPtr, m_editorsCompPtr, true);
93  I_ASSIGN_TO(m_editorViewExtendersCompPtr, m_editorsCompPtr, false);
94  I_ASSIGN_MULTI_0(m_editorVisualInfosCompPtr, "EditorVisualInfos", "List editor visual informations for each editor", false);
95  I_ASSIGN_TO(m_editorVisualModelsCompPtr, m_editorVisualInfosCompPtr, false);
96  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);
97  I_ASSIGN_TO(m_previewObserversCompPtr, m_previewGuisCompPtr, false);
98  I_ASSIGN_TO(m_previewSceneProvidersCompPtr, m_previewGuisCompPtr, false);
99  I_ASSIGN(m_paramsLoaderCompPtr, "ParamsLoader", "Loader for the parameter set", false, "ParamsLoader");
100  I_ASSIGN(m_generalParamsGuiCompPtr, "GeneralParamsGui", "Gui of general parameters", false, "GeneralParamsGui");
101  I_ASSIGN_TO(m_generalParamsObserverCompPtr, m_generalParamsGuiCompPtr, false);
102  I_ASSIGN_TO(m_generalParamsEditorCompPtr, m_generalParamsGuiCompPtr, false);
103  I_ASSIGN(m_resultShapeFactoryCompPtr, "ResultShapeFactory", "Creates shapes to display on preview (if iqt2d::IViewProvider is used)", false, "ResultShapeFactory");
104  I_ASSIGN(m_settingsKeyAttrPtr, "SettingsKey", "Key for saving/restoring of the layout information in the registry", true, "Settings");
105  I_END_COMPONENT;
106 
108 
109  // reimplemented (imod::IObserver)
110  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
111  virtual bool OnModelDetached(imod::IModel* modelPtr);
112 
113 protected:
114  void UpdateProcessingState();
115  void UpdateVisualElements();
116 
117  // reimplemented (iqtgui::TRestorableGuiWrap)
118  virtual void OnRestoreSettings(const QSettings& settings);
119  virtual void OnSaveSettings(QSettings& settings) const;
120 
121  // reimplemented (iqtgui::TGuiObserverWrap)
122  virtual void UpdateModel() const;
123  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
124 
125  // reimplemented (iqtgui::CGuiComponentBase)
126  virtual void OnGuiCreated();
127  virtual void OnGuiDestroyed();
128  virtual void OnGuiHidden();
129  virtual void OnGuiRetranslate();
130 
131  // reimplemented (imod::CMultiModelDispatcherBase)
132  virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet);
133 
134 protected Q_SLOTS:
135  void OnEditorChanged(int index);
136  void OnAutoTest();
139  void OnLoadParams();
140  void OnSaveParams();
141  void OnCopyAll();
142  void OnPasteAll();
143  void OnCopyCurrent();
144  void OnPasteCurrent();
146  void on_MessageList_itemDoubleClicked(QTreeWidgetItem* item, int column);
147 
148 Q_SIGNALS:
149  void DoAutoTest();
150 
151 private:
152  typedef QSet<int> ShapeIndices;
153 
154  void AddTaskMessagesToLog(const ilog::IMessageContainer& messageContainer, int taskIndex, bool isAuxiliary);
155  void UpdateTaskMessages();
156  void DoUpdateEditor(int taskIndex);
157  void ActivateTaskShapes(int taskIndex, const ShapeIndices& shapeIndices, bool useAuxiliary);
158  void CreateMenu();
159  void UpdateMenu();
160  bool CopyTaskParametersToClipboard(iser::ISerializable* objectPtr, const char* mimeType) const;
161  bool ReadTaskParametersFromClipboard(iser::ISerializable* objectPtr, const char* mimeType);
162 
166  QString GetSettingsKey() const;
167 
168  // static methods
169  static QIcon GetCategoryIcon(istd::IInformationProvider::InformationCategory category);
170 
171 private:
172  I_MULTIREF(imod::IModelEditor, m_editorsCompPtr);
173  I_MULTIREF(iqtgui::IGuiObject, m_editorGuisCompPtr);
174  I_MULTIREF(imod::IObserver, m_editorObserversCompPtr);
175  I_MULTIREF(iqt2d::IViewExtender, m_editorViewExtendersCompPtr);
176  I_MULTIREF(iqtgui::IVisualStatus, m_editorVisualInfosCompPtr);
177  I_MULTIREF(imod::IModel, m_editorVisualModelsCompPtr);
178  I_MULTIREF(iqtgui::IGuiObject, m_previewGuisCompPtr);
179  I_MULTIREF(imod::IObserver, m_previewObserversCompPtr);
180  I_MULTIREF(iqt2d::IViewProvider, m_previewSceneProvidersCompPtr);
181  I_REF(ifile::IFilePersistence, m_paramsLoaderCompPtr);
182  I_REF(iqtgui::IGuiObject, m_generalParamsGuiCompPtr);
183  I_REF(imod::IObserver, m_generalParamsObserverCompPtr);
184  I_REF(imod::IModelEditor, m_generalParamsEditorCompPtr);
185  I_REF(iview::IShapeFactory, m_resultShapeFactoryCompPtr);
186  I_ATTR(QByteArray, m_settingsKeyAttrPtr);
187 
188  int m_currentGuiIndex;
189  bool m_testStarted;
190 
191  typedef QMap<int, int> GuiMap;
192  GuiMap m_tabToStackIndexMap; // map GUI index (for editors) to stack index (for preview GUI)
193  GuiMap m_stackIndexToTabMap; // map stack index (for preview GUI) to GUI index (for editors)
194  GuiMap m_tabToGuiIndexMap; // map tab index to editor index
195 
196  typedef QMap<int, ilog::CMessageContainer> ResultMessagesMap;
197  ResultMessagesMap m_resultMessagesMap;
198  ResultMessagesMap m_tempMessagesMap;
199 
200  typedef QMap<int, istd::TPointerVector<iview::IShape> > ResultShapesMap; // Map GUI index to list of result shapes
201  ResultShapesMap m_resultShapesMap;
202  ResultShapesMap m_tempShapesMap;
203 
204  typedef QSet<imod::IModelEditor*> EditorsList;
205  EditorsList m_editorsList;
206 
207  QToolBox* m_toolBoxPtr;
208  QTabWidget* m_tabWidgetPtr;
209  QStackedWidget* m_stackedWidgetPtr;
210  QButtonGroup* m_buttonGroupPtr;
211 
212  QAction* m_copyAllActionPtr;
213  QAction* m_pasteAllActionPtr;
214  QAction* m_copyCurrentTaskActionPtr;
215  QAction* m_pasteCurrentTaskActionPtr;
216  QAction* m_loadAllActionPtr;
217  QAction* m_saveAllActionPtr;
218 };
219 
220 
221 } // namespace iqtinsp
222 
223 
224 #endif // !iqtinsp_CInspectionTaskGuiComp_included
225 
226 
virtual void OnRestoreSettings(const QSettings &settings)
iqtgui::TRestorableGuiWrap< TResultShapeCreatorWrap< CInspectionTaskGuiCompBase > > BaseClass
virtual bool OnModelDetached(imod::IModel *modelPtr)
iqtgui::TDesignerGuiObserverCompBase< Ui::CInspectionTaskGuiComp, iinsp::IInspectionTask > BaseClass
virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet)
void on_MessageList_itemDoubleClicked(QTreeWidgetItem *item, int column)
Representation of complete inspection task.
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
virtual void UpdateModel() const
virtual void OnSaveSettings(QSettings &settings) const

© 2007-2017 Witold Gantzke and Kirill Lepskiy