ICF 3.1.1.10
Technical documentation of ICF Libraries
CSceneProviderGuiComp.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/QtGlobal>
11#include <QtWidgets/QGraphicsView>
12#include <QtWidgets/QGraphicsScene>
13#include <QtWidgets/QGraphicsSceneResizeEvent>
14#include <QtWidgets/QGraphicsSceneWheelEvent>
15
16// ICF includes
23#include <GeneratedFiles/icmpstr/ui_CSceneProviderGuiComp.h>
24
25
26namespace icmpstr
27{
28
29
31 public istdgui::TDesignerGuiCompBase<Ui::CSceneProviderGuiComp>,
32 virtual public ibase::ICommandsProvider,
33 virtual public ISceneProvider,
34 virtual public i2d::ISceneController
35{
36 Q_OBJECT
37public:
39
72
73 I_BEGIN_COMPONENT(CSceneProviderGuiComp);
74 I_REGISTER_INTERFACE(ibase::ICommandsProvider);
75 I_REGISTER_INTERFACE(ISceneProvider);
76 I_REGISTER_INTERFACE(i2d::ISceneController);
77 I_ASSIGN(m_allowWidgetResizeAttrPtr, "AllowWidgetResize", "Allow resize of QWidet object (should be disabled if this GUI size is managed by layout)", true, false);
78 I_ASSIGN(m_sceneIdAttrPtr, "SceneId", "ID allowing identifying this scene", true, 0);
79 I_ASSIGN(m_useAntialiasingAttrPtr, "UseAntialiasing", "Enables using of antialiasing", false, false);
80 I_ASSIGN(m_fitModeAttrPtr, "FitMode", "Set fit automatic mode for the scene\n 0 - no fit (default)\n 1 - isotropic (reduction)\n 2 - isotropic\n 3 - anisotropic", false, 0);
81 I_ASSIGN(m_isotropyFactorAttrPtr, "IsotropyFactor", "Describe type of isotropic transformation: 0 - letterbox, 1 - full", true, 0);
82 I_ASSIGN_MULTI_0(m_dropConsumersCompPtr, "DropConsumers", "List of consumers for the drop event", false);
83 I_ASSIGN(m_backgroundModeAttrPtr, "BackgroundMode", "Mode of background drawing:\n 0 - normal window\n 1 - solid color\n 2 - grid\n 3 - checkerboard\n 4 - dot grid\n 5 - transparent", true, 0);
84 I_ASSIGN(m_gridSizeAttrPtr, "GridSize", "Size of grid, it is used also for background", true, 20);
85 I_ASSIGN(m_isAlignmentEnabledAttrPtr, "IsAlignmentEnabled", "If true, grid alignment will be enabled", true, false);
86 I_ASSIGN(m_sceneWidthAttrPtr, "SceneWidth", "Logical with of scene", false, 1000);
87 I_ASSIGN(m_sceneHeightAttrPtr, "SceneHeight", "Logical height of scene", false, 1000);
88 I_ASSIGN(m_allowSelectAllAttrPtr, "AllowSelectAll", "If true, command 'Select All' will be enabled", true, false);
89 I_END_COMPONENT;
90
92
93 double GetIsotropyFactor() const;
94 void SetIsotropyFactor(double factor);
95
96 // reimplemented (ibase::ICommandsProvider)
98
99 // reimplemented (icmpstr::ISceneProvider)
100 int GetSceneId() const override;
101 QGraphicsScene* GetScene() const override;
102 bool GetSceneAlignment(double& distance) const override;
103 int GetSceneFlags() const override;
104
105 // reimplemented (i2d::ISceneController)
106 int GetSceneRestrictionFlags() const override;
107 FittingMode GetFitMode() const override;
108 bool SetFitMode(FittingMode fitMode) override;
109 bool IsFullScreenMode() const override;
110 bool SetFullScreenMode(bool isFullScreen) override;
111 double GetScale() const override;
112 bool SetScale(int scaleMode = SM_SET, double value = 1.0) override;
113
114protected:
118 class CScene: public QGraphicsScene
119 {
120 public:
121 typedef QGraphicsScene BaseClass;
122
124
125 protected:
126 void DrawGrid(QPainter& painter, const QRectF& rect, bool useDot = false);
127
128 // reimplemented (QGraphicsScene)
129 virtual void drawBackground(QPainter* painter, const QRectF& rect);
130 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* eventPtr);
131 virtual void dropEvent(QGraphicsSceneDragDropEvent* eventPtr);
132 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* eventPtr);
133
134 private:
135 CSceneProviderGuiComp& m_parent;
136 };
137
138 virtual bool OnResize(QResizeEvent* eventPtr);
139 virtual bool OnWheelEvent(QGraphicsSceneWheelEvent* eventPtr);
140 virtual bool OnKeyReleaseEvent(QKeyEvent* eventPtr);
141 virtual bool OnMouseDoubleClickEvent(QEvent* eventPtr);
142
143 void ScaleView(double scaleFactor);
145
147
148 bool HasDropConsumerForFormat(const QStringList& formats) const;
149 void DelegateDropEvent(const QMimeData& data, QGraphicsSceneDragDropEvent* eventPtr);
151
152 // reimplemented (istdgui::CGuiComponentBase)
153 void OnGuiCreated() override;
154 void OnRetranslate() override;
155
156 // reimplemented (icomp::CComponentBase)
157 void OnComponentCreated() override;
158 void OnComponentDestroyed() override;
159
160 // reimplemented (QObject)
161 bool eventFilter(QObject* sourcePtr, QEvent* eventPtr) override;
162
163Q_SIGNALS:
164 void zoomChanged(double);
165 void embeddedRegistrySelected(const QByteArray&);
166
167protected Q_SLOTS:
168#ifndef QT_NO_PRINTER
169 void OnPrint();
170#endif
176 void OnAutoFit(bool isAutoScale);
178
179private:
180 std::unique_ptr<QGraphicsScene> m_scenePtr;
181
182 FittingMode m_fitMode;
183
184 bool m_isFullScreenMode;
185 bool m_isZoomIgnored;
186
189#ifndef QT_NO_PRINTER
190 istdgui::CHierarchicalCommand m_printCommand;
191#endif
193 istdgui::CHierarchicalCommand m_selectAllCommand;
195 istdgui::CHierarchicalCommand m_autoFitToViewCommand;
196 istdgui::CHierarchicalCommand m_fitToViewCommand;
197 istdgui::CHierarchicalCommand m_fitToImageCommand;
198 istdgui::CHierarchicalCommand m_resetZoomCommand;
199
200 I_MULTIREF(istdgui::IDropConsumer, m_dropConsumersCompPtr);
201
202 I_ATTR(bool, m_allowWidgetResizeAttrPtr);
203 I_ATTR(int, m_sceneIdAttrPtr);
204 I_ATTR(bool, m_useAntialiasingAttrPtr);
205 I_ATTR(int, m_fitModeAttrPtr);
206 I_ATTR(double, m_isotropyFactorAttrPtr);
207 I_ATTR(int, m_backgroundModeAttrPtr);
208 I_ATTR(double, m_gridSizeAttrPtr);
209 I_ATTR(bool, m_isAlignmentEnabledAttrPtr);
210 I_ATTR(double, m_sceneWidthAttrPtr);
211 I_ATTR(double, m_sceneHeightAttrPtr);
212 I_ATTR(bool, m_allowSelectAllAttrPtr);
213
214 QWidget* m_savedParentWidgetPtr;
215 QTransform m_savedViewTransform;
216
217 double m_isotropyFactor;
218};
219
220
221// inline protected methods
222
227
228
229} // namespace icmpstr
230
231
Interface for scene manipulation and query the restrictions.
@ SM_SET
Simple set, old scale will be replaced with the new value.
FittingMode
Vieport scale fitting mode.
Interface for a provider of the heriarchical commands.
Implementation of QGraphicsScene with own background drawing to provide rastered backgrounds.
void DrawGrid(QPainter &painter, const QRectF &rect, bool useDot=false)
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *eventPtr)
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *eventPtr)
CScene(CSceneProviderGuiComp *parentPtr)
virtual void drawBackground(QPainter *painter, const QRectF &rect)
virtual void dropEvent(QGraphicsSceneDragDropEvent *eventPtr)
bool GetSceneAlignment(double &distance) const override
Get parameters of grid alignment.
virtual bool OnMouseDoubleClickEvent(QEvent *eventPtr)
void SetFittedScale(FittingMode mode)
void DelegateDropEvent(const QMimeData &data, QGraphicsSceneDragDropEvent *eventPtr)
int GetSceneFlags() const override
Get scene's paremeter info.
int GetSceneId() const override
Get ID indentifing this scene.
istdgui::CHierarchicalCommand & GetCommandsRootRef()
bool eventFilter(QObject *sourcePtr, QEvent *eventPtr) override
void OnComponentDestroyed() override
bool IsFullScreenMode() const override
Check if full screen mode is enabled.
virtual bool OnKeyReleaseEvent(QKeyEvent *eventPtr)
bool SetFullScreenMode(bool isFullScreen) override
Set full screen mode on/off.
FittingMode GetFitMode() const override
Get vieport scale fitting mode.
@ BM_GRID
Grid of horizontal and vertical lines.
@ BM_CHECKERBOARD
Checkerboard pattern.
@ BM_SOLID
Filled with solid color.
@ BM_TRANSPARENT
Transparent background.
@ BM_NORMAL
Standard window backround.
virtual bool OnResize(QResizeEvent *eventPtr)
void OnGuiCreated() override
Called just after GUI is initialized.
int GetSceneRestrictionFlags() const override
Get the restriction flags, to tell the scene manipulator, what can be changed on the scene.
bool SetFitMode(FittingMode fitMode) override
Set vieport scale fitting mode.
void embeddedRegistrySelected(const QByteArray &)
bool HasDropConsumerForFormat(const QStringList &formats) const
virtual bool OnWheelEvent(QGraphicsSceneWheelEvent *eventPtr)
void ScaleView(double scaleFactor)
const ibase::IHierarchicalCommand * GetCommands() const override
Get list of menu commands.
void OnRetranslate() override
Called when non-GUI elements (like commands) should be retranslated.
void SetIsotropyFactor(double factor)
double GetScale() const override
Get actual scale factor.
istdgui::TDesignerGuiCompBase< Ui::CSceneProviderGuiComp > BaseClass
void OnAutoFit(bool isAutoScale)
void OnComponentCreated() override
QGraphicsScene * GetScene() const override
Called when items should be removed from specified scene.
bool SetScale(int scaleMode=SM_SET, double value=1.0) override
Set or modify scale factor.
Interface for GUI objects managing scene.
Common interface to define the hierarchical graph structures.
Implementation of hierarchical command based on QAction from Qt.
Interface for objects which can receive dragged objects.
Base class for all Qt GUI components, which use the Qt designer's UI.
This package contains (Qt based) implementations of compositor components.

© Witold Gantzke and Kirill Lepskiy