ICF 3.0.5.47
Technical documentation of ICF Libraries
CVisualRegistryEditorComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QObject>
11#include <QtCore/QTimer>
12
13// ICF includes
14#include <istd/TPointerVector.h>
17#include <icomp/IRegistry.h>
21#include <idoc/IHelpViewer.h>
30
31#include <GeneratedFiles/icmpstr/ui_CVisualRegistryEditorComp.h>
32
33
34namespace icmpstr
35{
36
37class CRegistryElementShape;
38class CVisualRegistryElement;
39class CVisualRegistry;
40
41
43 public istdgui::TDesignerGuiObserverCompBase<Ui::CVisualRegistryEditorComp, icomp::IRegistry>,
44 virtual public istdgui::IDropConsumer,
45 virtual public ibase::ICommandsProvider
46{
47 Q_OBJECT
48
49public:
51
52 I_BEGIN_BASE_COMPONENT(CVisualRegistryEditorCompBase);
53 I_ASSIGN(m_sceneProviderCompPtr, "SceneProvider", "Display view where graphical objects will be shown", true, "SceneProvider");
54 I_ASSIGN_TO(m_sceneProviderGuiCompPtr, m_sceneProviderCompPtr, true);
55 I_ASSIGN(m_registryCodeSaverCompPtr, "RegistryCodeSaver", "Export registry to C++ code file", false, "RegistryCodeSaver");
56 I_ASSIGN(m_registryPreviewCompPtr, "RegistryPreview", "Executes preview of the registry", false, "RegistryPreview");
57 I_ASSIGN(m_metaInfoManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
58 I_ASSIGN_TO(m_metaInfoManagerModelCompPtr, m_metaInfoManagerCompPtr, false);
59 I_ASSIGN(m_packagesManagerCompPtr, "PackagesManager", "Access to information about package files", false, "PackagesManager");
60 I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Show help of selected component using its address", false, "QuickHelpGui");
61 I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager allowing to load files on double click", false, "DocumentManager");
62 I_ASSIGN(m_consistencyInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
63 I_ASSIGN(m_registryTopologyGuiCompPtr, "RegistryTopologyGui", "GUI for showing the registry component topology", false, "RegistryTopologyGui");
64 I_ASSIGN_TO(m_registryObserverCompPtr, m_registryTopologyGuiCompPtr, false);
65 I_ASSIGN(m_registryValidationStatusCompPtr, "RegistryValidationStatus", "Visual status of registry validation", false, "RegistryValidationStatus");
66 I_ASSIGN_TO(m_registryValidationStatusModelCompPtr, m_registryValidationStatusCompPtr, false);
67 I_END_COMPONENT;
68
69protected:
70 I_REF(ifile::IFilePersistence, m_registryCodeSaverCompPtr);
71 I_REF(IRegistryPreview, m_registryPreviewCompPtr);
72 I_REF(icomp::IMetaInfoManager, m_metaInfoManagerCompPtr);
73 I_REF(imod::IModel, m_metaInfoManagerModelCompPtr);
74 I_REF(icomp::IPackagesManager, m_packagesManagerCompPtr);
75 I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
76 I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
77 I_REF(IRegistryConsistInfo, m_consistencyInfoCompPtr);
78 I_REF(istdgui::IGuiObject, m_registryTopologyGuiCompPtr);
79 I_REF(imod::IObserver, m_registryObserverCompPtr);
80 I_REF(istdgui::IVisualStatus, m_registryValidationStatusCompPtr);
81 I_REF(imod::IModel, m_registryValidationStatusModelCompPtr);
82 I_REF(ISceneProvider, m_sceneProviderCompPtr);
83 I_REF(istdgui::IGuiObject, m_sceneProviderGuiCompPtr);
84};
85
86
90{
91 Q_OBJECT
92
93public:
95
96 I_BEGIN_COMPONENT(CVisualRegistryEditorComp);
97 I_REGISTER_INTERFACE(ibase::ICommandsProvider);
98 I_REGISTER_INTERFACE(istdgui::IDropConsumer);
99 I_REGISTER_INTERFACE(imod::IObserver);
100 I_REGISTER_INTERFACE(istdgui::IGuiObject);
101 I_REGISTER_SUBELEMENT(SelectionInfo);
102 I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, IElementSelectionInfo, ExtractSelectionInfo);
103 I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, imod::IModel, ExtractSelectionInfo);
104 I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, istd::IChangeable, ExtractSelectionInfo);
105 I_END_COMPONENT;
106
108
109 // font getters used by CRegistryElementShape
110 const QFont& GetElementNameFont() const;
111 const QFont& GetElementDetailFont() const;
112
115
120 bool TryOpenComponent(const CVisualRegistryElement& registryElement);
121
126 void SetAcceptedMimeTypes(const QStringList& mimeTypes);
127
128 // reimplemented (ibase::ICommandsProvider)
130
131 // reimplemented (istdgui::IDropConsumer)
132 QStringList GetAcceptedMimeIds() const override;
133 void OnDropFinished(const QMimeData& mimeData, QEvent* eventPtr) override;
134
135protected:
145
150 class EnvironmentObserver: public imod::TSingleModelObserverBase<icomp::IMetaInfoManager>
151 {
152 public:
154
155 protected:
156 // reimplemented (imod::TSingleModelObserverBase)
157 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
158
159 private:
161 };
162
167
173 QGraphicsItem* AddShapeToScene(iser::ISerializable* elementPtr) const;
176 CRegistryElementShape& sourceShape,
177 const QByteArray& referenceComponentId,
178 const QByteArray& attributeId,
179 bool isFactory = false);
180
185 const QByteArray& elementId,
186 const icomp::CComponentAddress& address,
187 const i2d::CVector2d& position);
188
194 void ConnectReferences(const QByteArray& componentRole);
195
200
202
210 void UpdateEmbeddedRegistryView(const QByteArray& id);
211
212 virtual bool OnDropObject(const QMimeData& data, QGraphicsSceneDragDropEvent* eventPtr);
213 virtual void UpdateScene();
214
215 // reimplemented (imod::CMultiModelDispatcherBase)
216 void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
217
218 // reimplemented (istdgui::TGuiObserverWrap)
219 void UpdateGui(const istd::IChangeable::ChangeSet& changeSet) override;
220
221 // reimplemented (imod::CSingleModelObserverBase)
222 bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
223 bool OnModelDetached(imod::IModel* modelPtr) override;
224
225 // reimplemented (icomp::CGuiComponentBase)
226 void OnRetranslate() override;
227
228 // reimplemented (icomp::CComponentBase)
229 void OnComponentCreated() override;
230 void OnComponentDestroyed() override;
231
232 // reimplemented (istdgui::CGuiComponentBase)
233 void OnGuiCreated() override;
234 void OnGuiDestroyed() override;
235
236protected Q_SLOTS:
238
248 void OnExecute();
249 void OnAbort();
252
257
258private:
259 class SelectionInfoImpl: virtual public IElementSelectionInfo
260 {
261 public:
262 void SetParent(CVisualRegistryEditorComp* parentPtr);
263
264 // reimplemented (icmpstr::IElementSelectionInfo)
265 virtual icomp::IRegistry* GetSelectedRegistry() const;
266 virtual Elements GetSelectedElements() const;
267
268 private:
269 CVisualRegistryEditorComp* m_parentPtr;
270 };
271
272 friend class imod::TModelWrap<SelectionInfoImpl>;
273
274 // static template methods for subelement access
275 template <class InterfaceType>
276 static InterfaceType* ExtractSelectionInfo(CVisualRegistryEditorComp& component)
277 {
278 return &component.m_selectionInfo;
279 }
280
281 istdgui::CHierarchicalCommand m_rootMenuCommand;
284 istdgui::CHierarchicalCommand m_copyCommand;
285 istdgui::CHierarchicalCommand m_pasteCommand;
286 istdgui::CHierarchicalCommand m_removeComponentCommand;
287 istdgui::CHierarchicalCommand m_registryMenu;
288 istdgui::CHierarchicalCommand m_renameComponentCommand;
289 istdgui::CHierarchicalCommand m_newEmbeddedRegistryCommand;
290 istdgui::CHierarchicalCommand m_toEmbeddedRegistryCommand;
291 istdgui::CHierarchicalCommand m_removeEmbeddedRegistryCommand;
292 istdgui::CHierarchicalCommand m_exportToCodeCommand;
293 istdgui::CHierarchicalCommand m_executeRegistryCommand;
294 istdgui::CHierarchicalCommand m_abortRegistryCommand;
295 istdgui::CHierarchicalCommand m_showRegistryTopologyCommand;
296
297 QTimer m_executionObserverTimer;
298
299 QFont m_elementNameFont;
300 QFont m_elementDetailFont;
301
302 typedef QSet<QByteArray> ElementIds;
303 ElementIds m_selectedElementIds;
304
305 EnvironmentObserver m_environmentObserver;
306
308
309 QByteArray m_embeddedRegistryId;
310 QGraphicsScene* m_scenePtr;
311 QStringList m_acceptedMimeTypes;
312
313 istd::TPointerVector<QToolButton> m_embeddedButtons;
314 QSpacerItem* m_buttonSpacerPtr;
315};
316
317
318// inline methods
319
321{
322 return m_metaInfoManagerCompPtr.get();
323}
324
325
327{
328 return m_consistencyInfoCompPtr.get();
329}
330
331
332} // namespace icmpstr
333
334
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Interface for a provider of the heriarchical commands.
Visualization of geometrical registry elements.
EnvironmentObserver(CVisualRegistryEditorComp *parentPtr)
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
istdgui::TDesignerGuiObserverCompBase< Ui::CVisualRegistryEditorComp, icomp::IRegistry > BaseClass
const icomp::IMetaInfoManager * GetMetaInfoManager() const
icomp::IRegistryElement * TryCreateComponent(const QByteArray &elementId, const icomp::CComponentAddress &address, const i2d::CVector2d &position)
Used on drop/paste action.
const QFont & GetElementNameFont() const
const ibase::IHierarchicalCommand * GetCommands() const override
Get list of menu commands.
void AddConnector(CRegistryElementShape &sourceShape, const QByteArray &referenceComponentId, const QByteArray &attributeId, bool isFactory=false)
void OnEmbeddedComponentButtonClicked()
Selects (checks) a button representing an embedded composition.
void OnDropFinished(const QMimeData &mimeData, QEvent *eventPtr) override
Notification about drop action finish.
bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
This call back function will be called, if an observable object is about to be attached.
bool OnModelDetached(imod::IModel *modelPtr) override
This call back function will be called, if an observable object is about to be detached.
virtual bool OnDropObject(const QMimeData &data, QGraphicsSceneDragDropEvent *eventPtr)
CVisualRegistryEditorCompBase BaseClass
void OnRetranslate() override
Called when non-GUI elements (like commands) should be retranslated.
void OnGuiDestroyed() override
Called just before GUI is released.
const QFont & GetElementDetailFont() const
void OnGuiCreated() override
Called just after GUI is initialized.
QGraphicsItem * AddShapeToScene(iser::ISerializable *elementPtr) const
Create instance of shape representing some element.
void UpdateEmbeddedRegistryView(const QByteArray &id)
Update the scene to display currently selected embedded composition.
void UpdateGui(const istd::IChangeable::ChangeSet &changeSet) override
void ConnectReferences(const QByteArray &componentRole)
Used by TryCreateComponent() when an existing component is pasted (?) to update attributes referencin...
void UpdateEmbeddedRegistryButtons()
Clear and fill the embedded registry button box (used when the number of registry elements changes)
QStringList GetAcceptedMimeIds() const override
Get the list of the possible mime IDs, which are accepted by the consumer.
void SetAcceptedMimeTypes(const QStringList &mimeTypes)
Set accepted mime types.
icomp::IRegistry * GetSelectedRegistry() const
Get root or embedded registry that is currently selected in the editor.
void UpdateComponentSelection()
Update component selection and related menu actions.
bool TryOpenComponent(const CVisualRegistryElement &registryElement)
Try to open the composite component's registry in a new window.
void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet) override
Called when some model observed by dispatcher will be changed.
const IRegistryConsistInfo * GetRegistryConsistInfo() const
Interface containing all information about registry selected element.
QMap< QByteArray, const icomp::IRegistry::ElementInfo * > Elements
Interface for GUI objects managing scene.
Represents global address of component.
Represents element of registry describing component parameters.
Interface representing information stored in component registry.
Definition IRegistry.h:30
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept.
Allow to show help document to specified object or text.
Definition IHelpViewer.h:25
Interface providing loading and saving of data objects.
Generic implementation of a data model changes notifier.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:29
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition IObserver.h:30
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:28
Basic implementation for a single model observer with binding to concrete data object interface.
Common class for all classes which objects can be archived or restored from archive.
Set of change flags (its IDs).
Definition IChangeable.h:38
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
Common interface to define the hierarchical graph structures.
Implementation of a pointer container, which controls the live cycle of the pointer object.
Implementation of hierarchical command based on QAction from Qt.
Interface for objects which can receive dragged objects.
Common interface for GUI objects using in component context.
Definition IGuiObject.h:27
Extends standard information provider to provide additional visual informations.
Base class for all Qt GUI components.
This package contains (Qt based) implementations of compositor components.

© Witold Gantzke and Kirill Lepskiy