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"
16 #include "idoc/IHelpViewer.h"
17 #include "idoc/IDocumentManager.h"
20 #include "iqtgui/IDropConsumer.h"
24 #include "icmpstr/ISceneProvider.h"
25 
26 #include "GeneratedFiles/icmpstr/ui_CVisualRegistryEditorComp.h"
27 
28 
29 namespace icmpstr
30 {
31 
32 class CRegistryElementShape;
33 class CVisualRegistryElement;
34 class CVisualRegistry;
35 
36 
38  public iqtgui::TDesignerGuiObserverCompBase<Ui::CVisualRegistryEditorComp, icomp::IRegistry>,
39  virtual public iqtgui::IDropConsumer,
40  virtual public ibase::ICommandsProvider,
42 {
43  Q_OBJECT
44 
45 public:
47 
48  I_BEGIN_COMPONENT(CVisualRegistryEditorComp);
49  I_REGISTER_INTERFACE(ibase::ICommandsProvider);
50  I_REGISTER_INTERFACE(iqtgui::IDropConsumer);
51  I_REGISTER_INTERFACE(imod::IObserver);
52  I_REGISTER_INTERFACE(iqtgui::IGuiObject);
53  I_REGISTER_SUBELEMENT(SelectionInfo);
54  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, IElementSelectionInfo, ExtractSelectionInfo);
55  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, imod::IModel, ExtractSelectionInfo);
56  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, istd::IChangeable, ExtractSelectionInfo);
57  I_ASSIGN(m_sceneProviderCompPtr, "SceneProvider", "Display view where graphical objects will be shown", true, "SceneProvider");
58  I_ASSIGN_TO(m_sceneProviderGuiCompPtr, m_sceneProviderCompPtr, true);
59  I_ASSIGN(m_registryCodeSaverCompPtr, "RegistryCodeSaver", "Export registry to C++ code file", false, "RegistryCodeSaver");
60  I_ASSIGN(m_registryPreviewCompPtr, "RegistryPreview", "Executes preview of the registry", false, "RegistryPreview");
61  I_ASSIGN(m_envManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
62  I_ASSIGN_TO(m_envManagerModelCompPtr, m_envManagerCompPtr, false);
63  I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Show help of selected component using its address", false, "QuickHelpGui");
64  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager allowing to load files on double click", false, "DocumentManager");
65  I_ASSIGN(m_consistencyInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
66  I_ASSIGN(m_registryTopologyGuiCompPtr, "RegistryTopologyGui", "GUI for showing the registry component topology", false, "RegistryTopologyGui");
67  I_ASSIGN_TO(m_registryObserverCompPtr, m_registryTopologyGuiCompPtr, false);
68  I_ASSIGN(m_registryValidationStatusCompPtr, "RegistryValidationStatus", "Visual status of registry validation", false, "RegistryValidationStatus");
69  I_ASSIGN_TO(m_registryValidationStatusModelCompPtr, m_registryValidationStatusCompPtr, false);
70  I_END_COMPONENT;
71 
73 
74  // font getters used by CRegistryElementShape
75  const QFont& GetElementNameFont() const;
76  const QFont& GetElementDetailFont() const;
77 
80 
85  bool TryOpenComponent(const CVisualRegistryElement& registryElement);
86 
91  void SetAcceptedMimeTypes(const QStringList& mimeTypes);
92 
93  // reimplemented (ibase::ICommandsProvider)
94  virtual const ibase::IHierarchicalCommand* GetCommands() const;
95 
96  // reimplemented (iqtgui::IDropConsumer)
97  virtual QStringList GetAcceptedMimeIds() const;
98  virtual void OnDropFinished(const QMimeData& mimeData, QEvent* eventPtr);
99 
100 protected:
101  enum GroupId
102  {
103  GI_COMPONENT = 0x5430,
109  };
110 
111  class EnvironmentObserver: public imod::TSingleModelObserverBase<icomp::IComponentEnvironmentManager>
112  {
113  public:
115 
116  protected:
117  // reimplemented (imod::TSingleModelObserverBase)
118  virtual void OnUpdate(int updateFlags, istd::IPolymorphic* updateParamsPtr);
119 
120  private:
121  CVisualRegistryEditorComp& m_parent;
122  };
123 
128 
134  QGraphicsItem* AddShapeToScene(iser::ISerializable* elementPtr) const;
135  void AddConnectorsToScene();
136  void AddConnector(
137  CRegistryElementShape& sourceShape,
138  const QByteArray& referenceComponentId,
139  const QByteArray& attributeId,
140  bool isFactory = false);
141 
146  const QByteArray& elementId,
147  const icomp::CComponentAddress& address,
148  const i2d::CVector2d& position);
149 
155  void ConnectReferences(const QByteArray& componentRole);
156 
161 
162  void DoRetranslate();
163 
164  virtual bool OnDropObject(const QMimeData& data, QGraphicsSceneDragDropEvent* eventPtr);
165  virtual void UpdateScene(int updateFlags);
166 
167  // reimplemented (imod::CMultiModelDispatcherBase)
168  virtual void OnModelChanged(int modelId, int changeFlags, istd::IPolymorphic* updateParamsPtr);
169 
170  // reimplemented (iqtgui::TGuiObserverWrap)
171  virtual void UpdateGui(int updateFlags);
172 
173  // reimplemented (imod::CSingleModelObserverBase)
174  virtual bool OnAttached(imod::IModel* modelPtr);
175  virtual bool OnDetached(imod::IModel* modelPtr);
176 
177  // reimplemented (icomp::CComponentBase)
178  virtual void OnComponentCreated();
179  virtual void OnComponentDestroyed();
180 
181 protected Q_SLOTS:
182  void OnSelectionChanged();
183 
184  void OnCutCommand();
185  void OnCopyCommand();
186  void OnPasteCommand();
187  void OnRemoveComponent();
188  void OnRenameComponent();
189  void NewEmbeddedComponent();
190  void ToEmbeddedComponent();
192  void OnExportToCode();
193  void OnExecute();
194  void OnAbort();
195  void OnExecutionTimerTick();
196  void OnShowRegistryTopology();
197 
209  void UpdateEmbeddedRegistryView(const QByteArray& id);
210 
211  // reimplemented (iqtgui::CGuiComponentBase)
212  virtual void OnGuiCreated();
213  virtual void OnGuiDestroyed();
214 
215 private:
216  class SelectionInfoImpl: virtual public IElementSelectionInfo
217  {
218  public:
219  void SetParent(CVisualRegistryEditorComp* parentPtr);
220 
221  // reimplemented (icmpstr::IElementSelectionInfo)
222  virtual icomp::IRegistry* GetSelectedRegistry() const;
223  virtual Elements GetSelectedElements() const;
224 
225  private:
226  CVisualRegistryEditorComp* m_parentPtr;
227  };
228 
229  friend class imod::TModelWrap<SelectionInfoImpl>;
230 
231  // static template methods for subelement access
232  template <class InterfaceType>
233  static InterfaceType* ExtractSelectionInfo(CVisualRegistryEditorComp& component)
234  {
235  return &component.m_selectionInfo;
236  }
237 
238  I_REF(ifile::IFilePersistence, m_registryCodeSaverCompPtr);
239  I_REF(IRegistryPreview, m_registryPreviewCompPtr);
240  I_REF(icomp::IComponentEnvironmentManager, m_envManagerCompPtr);
241  I_REF(imod::IModel, m_envManagerModelCompPtr);
242  I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
243  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
244  I_REF(IRegistryConsistInfo, m_consistencyInfoCompPtr);
245  I_REF(iqtgui::IGuiObject, m_registryTopologyGuiCompPtr);
246  I_REF(imod::IObserver, m_registryObserverCompPtr);
247  I_REF(iqtgui::IVisualStatus, m_registryValidationStatusCompPtr);
248  I_REF(imod::IModel, m_registryValidationStatusModelCompPtr);
249  I_REF(ISceneProvider, m_sceneProviderCompPtr);
250  I_REF(iqtgui::IGuiObject, m_sceneProviderGuiCompPtr);
251 
252  iqtgui::CHierarchicalCommand m_rootMenuCommand;
253  iqtgui::CHierarchicalCommand m_editMenu;
254  iqtgui::CHierarchicalCommand m_cutCommand;
255  iqtgui::CHierarchicalCommand m_copyCommand;
256  iqtgui::CHierarchicalCommand m_pasteCommand;
257  iqtgui::CHierarchicalCommand m_removeComponentCommand;
258  iqtgui::CHierarchicalCommand m_registryMenu;
259  iqtgui::CHierarchicalCommand m_renameComponentCommand;
260  iqtgui::CHierarchicalCommand m_newEmbeddedRegistryCommand;
261  iqtgui::CHierarchicalCommand m_toEmbeddedRegistryCommand;
262  iqtgui::CHierarchicalCommand m_removeEmbeddedRegistryCommand;
263  iqtgui::CHierarchicalCommand m_exportToCodeCommand;
264  iqtgui::CHierarchicalCommand m_executeRegistryCommand;
265  iqtgui::CHierarchicalCommand m_abortRegistryCommand;
266  iqtgui::CHierarchicalCommand m_showRegistryTopologyCommand;
267 
268  QTimer m_executionObserverTimer;
269 
270  QFont m_elementNameFont;
271  QFont m_elementDetailFont;
272 
273  typedef QSet<QByteArray> ElementIds;
274  ElementIds m_selectedElementIds;
275 
276  EnvironmentObserver m_environmentObserver;
277 
278  imod::TModelWrap<SelectionInfoImpl> m_selectionInfo;
279 
280  QByteArray m_embeddedRegistryId;
281  QGraphicsScene* m_scenePtr;
282  QStringList m_acceptedMimeTypes;
283 
284  istd::TPointerVector<QToolButton> m_embeddedButtons;
285  QSpacerItem* m_buttonSpacerPtr;
286 
287  // static attributes
288  static iser::CArchiveTag s_elementsListTag;
289  static iser::CArchiveTag s_elementTag;
290  static iser::CArchiveTag s_elementIdTag;
291  static iser::CArchiveTag s_elementAddressTag;
292  static iser::CArchiveTag s_elementCenterTag;
293 };
294 
295 
296 // inline methods
297 
299 {
300  return m_envManagerCompPtr.GetPtr();
301 }
302 
303 
305 {
306  return m_consistencyInfoCompPtr.GetPtr();
307 }
308 
309 
310 } // namespace icmpstr
311 
312 
313 #endif // !icmpstr_CVisualRegistryEditorComp_included
314 
315 
virtual void OnDropFinished(const QMimeData &mimeData, QEvent *eventPtr)
I_ASSIGN_TO(m_sceneProviderGuiCompPtr, m_sceneProviderCompPtr, true)
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 const ibase::IHierarchicalCommand * GetCommands() const
QGraphicsItem * AddShapeToScene(iser::ISerializable *elementPtr) const
Create instance of shape representing some element.
virtual void OnModelChanged(int modelId, int changeFlags, istd::IPolymorphic *updateParamsPtr)
const QFont & GetElementNameFont() const
EnvironmentObserver(CVisualRegistryEditorComp *parentPtr)
Interface for GUI objects managing scene.
void UpdateComponentSelection()
Update component selection and related menu actions.
iqtgui::TDesignerGuiObserverCompBase< Ui::CVisualRegistryEditorComp, icomp::IRegistry > BaseClass2
Visualization of geometrical registry elements.
virtual void UpdateGui(int updateFlags)
const QFont & GetElementDetailFont() const
icomp::IRegistryElement * TryCreateComponent(const QByteArray &elementId, const icomp::CComponentAddress &address, const i2d::CVector2d &position)
Used on drop/paste action.
virtual bool OnDetached(imod::IModel *modelPtr)
void UpdateEmbeddedRegistryButtons()
Clear and fill the embedded registry button box (used when the number of registry elements changes) ...
virtual void OnUpdate(int updateFlags, istd::IPolymorphic *updateParamsPtr)
void UpdateEmbeddedRegistryView(const QByteArray &id)
Update the scene to display currently selected embedded composition.
const icomp::IComponentEnvironmentManager * GetEnvironmentManager() const
virtual bool OnAttached(imod::IModel *modelPtr)
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.
I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, IElementSelectionInfo, ExtractSelectionInfo)
virtual void UpdateScene(int updateFlags)

© 2007-2011 Witold Gantzke and Kirill Lepskiy