CSceneProviderGuiComp.h
Go to the documentation of this file.
1 #ifndef icmpstr_CSceneProviderGuiComp_included
2 #define icmpstr_CSceneProviderGuiComp_included
3 
4 
5 // Qt includes
6 #include<QtCore/QtGlobal>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QGraphicsView>
9 #include <QtWidgets/QGraphicsScene>
10 #include <QtWidgets/QGraphicsSceneResizeEvent>
11 #include <QtWidgets/QGraphicsSceneWheelEvent>
12 #else
13 #include <QtGui/QGraphicsView>
14 #include <QtGui/QGraphicsScene>
15 #include <QtGui/QGraphicsSceneResizeEvent>
16 #include <QtGui/QGraphicsSceneWheelEvent>
17 #endif
18 
19 // ACF includes
20 #include "i2d/ISceneController.h"
22 #include "iqtgui/IDropConsumer.h"
25 
26 // ACF-Solutions includes
27 #include "icmpstr/ISceneProvider.h"
28 #include "GeneratedFiles/icmpstr/ui_CSceneProviderGuiComp.h"
29 
30 
31 namespace icmpstr
32 {
33 
34 
36  public iqtgui::TDesignerGuiCompBase<Ui::CSceneProviderGuiComp>,
37  virtual public ibase::ICommandsProvider,
38  virtual public ISceneProvider,
39  virtual public i2d::ISceneController
40 {
41  Q_OBJECT
42 public:
44 
46  {
51 
56 
61 
66 
71 
76  };
77 
78  I_BEGIN_COMPONENT(CSceneProviderGuiComp);
79  I_REGISTER_INTERFACE(ibase::ICommandsProvider);
80  I_REGISTER_INTERFACE(ISceneProvider);
81  I_REGISTER_INTERFACE(i2d::ISceneController);
82  I_ASSIGN(m_allowWidgetResizeAttrPtr, "AllowWidgetResize", "Allow resize of QWidet object (should be disabled if this GUI size is managed by layout)", true, false);
83  I_ASSIGN(m_sceneIdAttrPtr, "SceneId", "ID allowing identifying this scene", true, 0);
84  I_ASSIGN(m_useAntialiasingAttrPtr, "UseAntialiasing", "Enables using of antialiasing", false, false);
85  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);
86  I_ASSIGN(m_isotropyFactorAttrPtr, "IsotropyFactor", "Describe type of isotropic transformation: 0 - letterbox, 1 - full", true, 0);
87  I_ASSIGN_MULTI_0(m_dropConsumersCompPtr, "DropConsumers", "List of consumers for the drop event", false);
88  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);
89  I_ASSIGN(m_gridSizeAttrPtr, "GridSize", "Size of grid, it is used also for background", true, 20);
90  I_ASSIGN(m_isAlignmentEnabledAttrPtr, "IsAlignmentEnabled", "If true, grid alignment will be enabled", true, false);
91  I_ASSIGN(m_sceneWidthAttrPtr, "SceneWidth", "Logical with of scene", false, 1000);
92  I_ASSIGN(m_sceneHeightAttrPtr, "SceneHeight", "Logical height of scene", false, 1000);
93  I_ASSIGN(m_allowSelectAllAttrPtr, "AllowSelectAll", "If true, command 'Select All' will be enabled", true, false);
94  I_END_COMPONENT;
95 
97 
98  double GetIsotropyFactor() const;
99  void SetIsotropyFactor(double factor);
100 
101  // reimplemented (ibase::ICommandsProvider)
102  virtual const ibase::IHierarchicalCommand* GetCommands() const;
103 
104  // reimplemented (icmpstr::ISceneProvider)
105  virtual int GetSceneId() const;
106  virtual QGraphicsScene* GetScene() const;
107  virtual bool GetSceneAlignment(double& distance) const;
108  virtual int GetSceneFlags() const;
109 
110  // reimplemented (i2d::ISceneController)
111  virtual int GetSceneRestrictionFlags() const;
112  virtual FitMode GetFitMode() const;
113  virtual bool SetFitMode(FitMode fitMode);
114  virtual bool IsFullScreenMode() const;
115  virtual bool SetFullScreenMode(bool isFullScreen);
116  virtual double GetScale() const;
117  virtual bool SetScale(int scaleMode = SM_SET, double value = 1.0);
118 
119 protected:
123  class CScene: public QGraphicsScene
124  {
125  public:
126  typedef QGraphicsScene BaseClass;
127 
128  CScene(CSceneProviderGuiComp* parentPtr);
129 
130  protected:
131  void DrawGrid(QPainter& painter, const QRectF& rect, bool useDot = false);
132 
133  // reimplemented (QGraphicsScene)
134  virtual void drawBackground(QPainter* painter, const QRectF & rect);
135  virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * eventPtr);
136  virtual void dropEvent(QGraphicsSceneDragDropEvent * eventPtr);
137  virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * eventPtr);
138 
139  private:
140  CSceneProviderGuiComp& m_parent;
141  };
142 
143  virtual bool OnResize(QResizeEvent* eventPtr);
144  virtual bool OnWheelEvent(QGraphicsSceneWheelEvent* eventPtr);
145  virtual bool OnKeyReleaseEvent(QKeyEvent* eventPtr);
146  virtual bool OnMouseDoubleClickEvent(QEvent* eventPtr);
147 
148  void ScaleView(double scaleFactor);
149  void SetFittedScale(FitMode mode);
150 
152 
153  bool HasDropConsumerForFormat(const QStringList& formats) const;
154  void DelegateDropEvent(const QMimeData& data, QGraphicsSceneDragDropEvent* eventPtr);
155  void ResetScene();
156 
157  // reimplemented (iqtgui::CGuiComponentBase)
158  virtual void OnGuiCreated();
159  virtual void OnRetranslate();
160 
161  // reimplemented (icomp::CComponentBase)
162  virtual void OnComponentCreated();
163  virtual void OnComponentDestroyed();
164 
165  // reimplemented (QObject)
166  virtual bool eventFilter(QObject* sourcePtr, QEvent* eventPtr);
167 
168 Q_SIGNALS:
169  void zoomChanged(double);
170  void embeddedRegistrySelected(const QByteArray&);
171 
172 protected Q_SLOTS:
173  void OnPrint();
174  void OnZoomIncrement();
175  void OnZoomDecrement();
176  void OnFitToView();
177  void OnFitToShapes();
178  void OnResetScale();
179  void OnAutoFit(bool isAutoScale);
180  void OnSelectAllShapes();
181 
182 private:
184 
185  FitMode m_fitMode;
186 
187  bool m_isFullScreenMode;
188  bool m_isZoomIgnored;
189 
190  iqtgui::CHierarchicalCommand m_commands;
191  iqtgui::CHierarchicalCommand m_fileMenu;
192  iqtgui::CHierarchicalCommand m_printCommand;
193  iqtgui::CHierarchicalCommand m_editMenu;
194  iqtgui::CHierarchicalCommand m_selectAllCommand;
195  iqtgui::CHierarchicalCommand m_viewMenu;
196  iqtgui::CHierarchicalCommand m_autoFitToViewCommand;
197  iqtgui::CHierarchicalCommand m_fitToViewCommand;
198  iqtgui::CHierarchicalCommand m_fitToImageCommand;
199  iqtgui::CHierarchicalCommand m_resetZoomCommand;
200 
201  I_MULTIREF(iqtgui::IDropConsumer, m_dropConsumersCompPtr);
202 
203  I_ATTR(bool, m_allowWidgetResizeAttrPtr);
204  I_ATTR(int, m_sceneIdAttrPtr);
205  I_ATTR(bool, m_useAntialiasingAttrPtr);
206  I_ATTR(int, m_fitModeAttrPtr);
207  I_ATTR(double, m_isotropyFactorAttrPtr);
208  I_ATTR(int, m_backgroundModeAttrPtr);
209  I_ATTR(double, m_gridSizeAttrPtr);
210  I_ATTR(bool, m_isAlignmentEnabledAttrPtr);
211  I_ATTR(double, m_sceneWidthAttrPtr);
212  I_ATTR(double, m_sceneHeightAttrPtr);
213  I_ATTR(bool, m_allowSelectAllAttrPtr);
214 
215  QWidget* m_savedParentWidgetPtr;
216  QMatrix m_savedViewTransform;
217 
218  double m_isotropyFactor;
219 };
220 
221 
222 // inline protected methods
223 
225 {
226  return m_commands;
227 }
228 
229 
230 } // namespace icmpstr
231 
232 
233 #endif // !icmpstr_CSceneProviderGuiComp_included
234 
235 
void OnAutoFit(bool isAutoScale)
virtual bool eventFilter(QObject *sourcePtr, QEvent *eventPtr)
virtual int GetSceneRestrictionFlags() const
void DrawGrid(QPainter &painter, const QRectF &rect, bool useDot=false)
virtual bool OnMouseDoubleClickEvent(QEvent *eventPtr)
virtual bool OnKeyReleaseEvent(QKeyEvent *eventPtr)
virtual bool SetScale(int scaleMode=SM_SET, double value=1.0)
Interface for GUI objects managing scene.
void DelegateDropEvent(const QMimeData &data, QGraphicsSceneDragDropEvent *eventPtr)
void embeddedRegistrySelected(const QByteArray &)
virtual int GetSceneFlags() const
Get scene's paremeter info.
virtual QGraphicsScene * GetScene() const
Called when items should be removed from specified scene.
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *eventPtr)
virtual bool OnWheelEvent(QGraphicsSceneWheelEvent *eventPtr)
void SetIsotropyFactor(double factor)
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *eventPtr)
virtual double GetScale() const
virtual FitMode GetFitMode() const
virtual void OnComponentDestroyed()
Grid of horizontal and vertical lines.
virtual bool SetFitMode(FitMode fitMode)
virtual bool IsFullScreenMode() const
double GetIsotropyFactor() const
void SetFittedScale(FitMode mode)
virtual bool OnResize(QResizeEvent *eventPtr)
void ScaleView(double scaleFactor)
virtual const ibase::IHierarchicalCommand * GetCommands() const
Implementation of QGraphicsScene with own background drawing to provide rastered backgrounds.
virtual bool SetFullScreenMode(bool isFullScreen)
virtual bool GetSceneAlignment(double &distance) const
Get parameters of grid alignment.
virtual void dropEvent(QGraphicsSceneDragDropEvent *eventPtr)
virtual int GetSceneId() const
Get ID indentifing this scene.
iqtgui::TDesignerGuiCompBase< Ui::CSceneProviderGuiComp > BaseClass
bool HasDropConsumerForFormat(const QStringList &formats) const
iqtgui::CHierarchicalCommand & GetCommandsRootRef()
virtual void drawBackground(QPainter *painter, const QRectF &rect)
CScene(CSceneProviderGuiComp *parentPtr)

© 2007-2011 Witold Gantzke and Kirill Lepskiy