CVisualRegistryEditorComp.h
Go to the documentation of this file.
1 #ifndef icmpstr_CVisualRegistryEditorComp_included
2 #define icmpstr_CVisualRegistryEditorComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QObject>
7 #include <QtCore/QTimer>
8 
9 // ACF includes
10 #include <istd/TPointerVector.h>
11 #include <ifile/IFilePersistence.h>
13 #include <icomp/IRegistry.h>
14 #include <icomp/IMetaInfoManager.h>
15 #include <icomp/IPackagesManager.h>
17 #include <idoc/IHelpViewer.h>
18 #include <idoc/IDocumentManager.h>
21 #include <iqtgui/IDropConsumer.h>
25 #include <icmpstr/ISceneProvider.h>
26 
27 #include <GeneratedFiles/icmpstr/ui_CVisualRegistryEditorComp.h>
28 
29 
30 namespace icmpstr
31 {
32 
33 class CRegistryElementShape;
34 class CVisualRegistryElement;
35 class CVisualRegistry;
36 
37 
39  public iqtgui::TDesignerGuiObserverCompBase<Ui::CVisualRegistryEditorComp, icomp::IRegistry>,
40  virtual public iqtgui::IDropConsumer,
41  virtual public ibase::ICommandsProvider,
43 {
44  Q_OBJECT
45 
46 public:
48 
49  I_BEGIN_BASE_COMPONENT(CVisualRegistryEditorCompBase);
50  I_ASSIGN(m_sceneProviderCompPtr, "SceneProvider", "Display view where graphical objects will be shown", true, "SceneProvider");
51  I_ASSIGN_TO(m_sceneProviderGuiCompPtr, m_sceneProviderCompPtr, true);
52  I_ASSIGN(m_registryCodeSaverCompPtr, "RegistryCodeSaver", "Export registry to C++ code file", false, "RegistryCodeSaver");
53  I_ASSIGN(m_registryPreviewCompPtr, "RegistryPreview", "Executes preview of the registry", false, "RegistryPreview");
54  I_ASSIGN(m_metaInfoManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
55  I_ASSIGN_TO(m_metaInfoManagerModelCompPtr, m_metaInfoManagerCompPtr, false);
56  I_ASSIGN(m_packagesManagerCompPtr, "PackagesManager", "Access to information about package files", false, "PackagesManager");
57  I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Show help of selected component using its address", false, "QuickHelpGui");
58  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager allowing to load files on double click", false, "DocumentManager");
59  I_ASSIGN(m_consistencyInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
60  I_ASSIGN(m_registryTopologyGuiCompPtr, "RegistryTopologyGui", "GUI for showing the registry component topology", false, "RegistryTopologyGui");
61  I_ASSIGN_TO(m_registryObserverCompPtr, m_registryTopologyGuiCompPtr, false);
62  I_ASSIGN(m_registryValidationStatusCompPtr, "RegistryValidationStatus", "Visual status of registry validation", false, "RegistryValidationStatus");
63  I_ASSIGN_TO(m_registryValidationStatusModelCompPtr, m_registryValidationStatusCompPtr, false);
64  I_END_COMPONENT;
65 
66 protected:
67  I_REF(ifile::IFilePersistence, m_registryCodeSaverCompPtr);
68  I_REF(IRegistryPreview, m_registryPreviewCompPtr);
69  I_REF(icomp::IMetaInfoManager, m_metaInfoManagerCompPtr);
70  I_REF(imod::IModel, m_metaInfoManagerModelCompPtr);
71  I_REF(icomp::IPackagesManager, m_packagesManagerCompPtr);
72  I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
73  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
74  I_REF(IRegistryConsistInfo, m_consistencyInfoCompPtr);
75  I_REF(iqtgui::IGuiObject, m_registryTopologyGuiCompPtr);
76  I_REF(imod::IObserver, m_registryObserverCompPtr);
77  I_REF(iqtgui::IVisualStatus, m_registryValidationStatusCompPtr);
78  I_REF(imod::IModel, m_registryValidationStatusModelCompPtr);
79  I_REF(ISceneProvider, m_sceneProviderCompPtr);
80  I_REF(iqtgui::IGuiObject, m_sceneProviderGuiCompPtr);
81 };
82 
83 
85 {
86  Q_OBJECT
87 
88 public:
90 
91  I_BEGIN_COMPONENT(CVisualRegistryEditorComp);
92  I_REGISTER_INTERFACE(ibase::ICommandsProvider);
93  I_REGISTER_INTERFACE(iqtgui::IDropConsumer);
94  I_REGISTER_INTERFACE(imod::IObserver);
95  I_REGISTER_INTERFACE(iqtgui::IGuiObject);
96  I_REGISTER_SUBELEMENT(SelectionInfo);
97  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, IElementSelectionInfo, ExtractSelectionInfo);
98  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, imod::IModel, ExtractSelectionInfo);
99  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, istd::IChangeable, ExtractSelectionInfo);
100  I_END_COMPONENT;
101 
103 
104  // font getters used by CRegistryElementShape
105  const QFont& GetElementNameFont() const;
106  const QFont& GetElementDetailFont() const;
107 
110 
115  bool TryOpenComponent(const CVisualRegistryElement& registryElement);
116 
121  void SetAcceptedMimeTypes(const QStringList& mimeTypes);
122 
123  // reimplemented (ibase::ICommandsProvider)
124  virtual const ibase::IHierarchicalCommand* GetCommands() const;
125 
126  // reimplemented (iqtgui::IDropConsumer)
127  virtual QStringList GetAcceptedMimeIds() const;
128  virtual void OnDropFinished(const QMimeData& mimeData, QEvent* eventPtr);
129 
130 protected:
131  enum GroupId
132  {
133  GI_COMPONENT = 0x5430,
139  };
140 
145  class EnvironmentObserver: public imod::TSingleModelObserverBase<icomp::IMetaInfoManager>
146  {
147  public:
149 
150  protected:
151  // reimplemented (imod::TSingleModelObserverBase)
152  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
153 
154  private:
155  CVisualRegistryEditorComp& m_parent;
156  };
157 
162 
168  QGraphicsItem* AddShapeToScene(iser::ISerializable* elementPtr) const;
169  void AddConnectorsToScene();
170  void AddConnector(
171  CRegistryElementShape& sourceShape,
172  const QByteArray& referenceComponentId,
173  const QByteArray& attributeId,
174  bool isFactory = false);
175 
180  const QByteArray& elementId,
181  const icomp::CComponentAddress& address,
182  const i2d::CVector2d& position);
183 
189  void ConnectReferences(const QByteArray& componentRole);
190 
195 
196  void DoRetranslate();
197 
198  virtual bool OnDropObject(const QMimeData& data, QGraphicsSceneDragDropEvent* eventPtr);
199  virtual void UpdateScene();
200 
201  // reimplemented (imod::CMultiModelDispatcherBase)
202  virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet);
203 
204  // reimplemented (iqtgui::TGuiObserverWrap)
205  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
206 
207  // reimplemented (imod::CSingleModelObserverBase)
208  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
209  virtual bool OnModelDetached(imod::IModel* modelPtr);
210 
211  // reimplemented (icomp::CGuiComponentBase)
212  virtual void OnRetranslate();
213 
214  // reimplemented (icomp::CComponentBase)
215  virtual void OnComponentCreated();
216  virtual void OnComponentDestroyed();
217 
218 protected Q_SLOTS:
219  void OnSelectionChanged();
220 
221  void OnCutCommand();
222  void OnCopyCommand();
223  void OnPasteCommand();
224  void OnRemoveComponent();
225  void OnRenameComponent();
226  void NewEmbeddedComponent();
227  void ToEmbeddedComponent();
229  void OnExportToCode();
230  void OnExecute();
231  void OnAbort();
232  void OnExecutionTimerTick();
233  void OnShowRegistryTopology();
234 
246  void UpdateEmbeddedRegistryView(const QByteArray& id);
247 
248  // reimplemented (iqtgui::CGuiComponentBase)
249  virtual void OnGuiCreated();
250  virtual void OnGuiDestroyed();
251 
252 private:
253  class SelectionInfoImpl: virtual public IElementSelectionInfo
254  {
255  public:
256  void SetParent(CVisualRegistryEditorComp* parentPtr);
257 
258  // reimplemented (icmpstr::IElementSelectionInfo)
259  virtual icomp::IRegistry* GetSelectedRegistry() const;
260  virtual Elements GetSelectedElements() const;
261 
262  private:
263  CVisualRegistryEditorComp* m_parentPtr;
264  };
265 
266  friend class imod::TModelWrap<SelectionInfoImpl>;
267 
268  // static template methods for subelement access
269  template <class InterfaceType>
270  static InterfaceType* ExtractSelectionInfo(CVisualRegistryEditorComp& component)
271  {
272  return &component.m_selectionInfo;
273  }
274 
275  iqtgui::CHierarchicalCommand m_rootMenuCommand;
276  iqtgui::CHierarchicalCommand m_editMenu;
277  iqtgui::CHierarchicalCommand m_cutCommand;
278  iqtgui::CHierarchicalCommand m_copyCommand;
279  iqtgui::CHierarchicalCommand m_pasteCommand;
280  iqtgui::CHierarchicalCommand m_removeComponentCommand;
281  iqtgui::CHierarchicalCommand m_registryMenu;
282  iqtgui::CHierarchicalCommand m_renameComponentCommand;
283  iqtgui::CHierarchicalCommand m_newEmbeddedRegistryCommand;
284  iqtgui::CHierarchicalCommand m_toEmbeddedRegistryCommand;
285  iqtgui::CHierarchicalCommand m_removeEmbeddedRegistryCommand;
286  iqtgui::CHierarchicalCommand m_exportToCodeCommand;
287  iqtgui::CHierarchicalCommand m_executeRegistryCommand;
288  iqtgui::CHierarchicalCommand m_abortRegistryCommand;
289  iqtgui::CHierarchicalCommand m_showRegistryTopologyCommand;
290 
291  QTimer m_executionObserverTimer;
292 
293  QFont m_elementNameFont;
294  QFont m_elementDetailFont;
295 
296  typedef QSet<QByteArray> ElementIds;
297  ElementIds m_selectedElementIds;
298 
299  EnvironmentObserver m_environmentObserver;
300 
301  imod::TModelWrap<SelectionInfoImpl> m_selectionInfo;
302 
303  QByteArray m_embeddedRegistryId;
304  QGraphicsScene* m_scenePtr;
305  QStringList m_acceptedMimeTypes;
306 
307  istd::TPointerVector<QToolButton> m_embeddedButtons;
308  QSpacerItem* m_buttonSpacerPtr;
309 };
310 
311 
312 // inline methods
313 
315 {
316  return m_metaInfoManagerCompPtr.GetPtr();
317 }
318 
319 
321 {
322  return m_consistencyInfoCompPtr.GetPtr();
323 }
324 
325 
326 } // namespace icmpstr
327 
328 
329 #endif // !icmpstr_CVisualRegistryEditorComp_included
330 
331 
virtual void OnDropFinished(const QMimeData &mimeData, QEvent *eventPtr)
virtual bool OnDropObject(const QMimeData &data, QGraphicsSceneDragDropEvent *eventPtr)
bool TryOpenComponent(const CVisualRegistryElement &registryElement)
Try to open the composite component's registry in a new window.
void OnEmbeddedComponentButtonClicked()
Selects (checks) a button representing an embedded composition.
void AddConnector(CRegistryElementShape &sourceShape, const QByteArray &referenceComponentId, const QByteArray &attributeId, bool isFactory=false)
virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet)
virtual const ibase::IHierarchicalCommand * GetCommands() const
QGraphicsItem * AddShapeToScene(iser::ISerializable *elementPtr) const
Create instance of shape representing some element.
const QFont & GetElementNameFont() const
CVisualRegistryEditorCompBase BaseClass
EnvironmentObserver(CVisualRegistryEditorComp *parentPtr)
Interface for GUI objects managing scene.
void UpdateComponentSelection()
Update component selection and related menu actions.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Visualization of geometrical registry elements.
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
iqtgui::TDesignerGuiObserverCompBase< Ui::CVisualRegistryEditorComp, icomp::IRegistry > BaseClass
virtual bool OnModelDetached(imod::IModel *modelPtr)
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
const QFont & GetElementDetailFont() const
icomp::IRegistryElement * TryCreateComponent(const QByteArray &elementId, const icomp::CComponentAddress &address, const i2d::CVector2d &position)
Used on drop/paste action.
const icomp::IMetaInfoManager * GetMetaInfoManager() const
void UpdateEmbeddedRegistryButtons()
Clear and fill the embedded registry button box (used when the number of registry elements changes) ...
void UpdateEmbeddedRegistryView(const QByteArray &id)
Update the scene to display currently selected embedded composition.
virtual QStringList GetAcceptedMimeIds() const
const IRegistryConsistInfo * GetRegistryConsistInfo() const
void SetAcceptedMimeTypes(const QStringList &mimeTypes)
Set accepted mime types.
void ConnectReferences(const QByteArray &componentRole)
Used by TryCreateComponent() when an existing component is pasted (?) to update attributes referencin...
icomp::IRegistry * GetSelectedRegistry() const
Get root or embedded registry that is currently selected in the editor.
Interface containing all information about registry selected element.

© 2007-2017 Witold Gantzke and Kirill Lepskiy