Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GraphicsView_Viewer.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef GRAPHICSVIEW_VIEWER_H
21 #define GRAPHICSVIEW_VIEWER_H
22 
23 #include "GraphicsView.h"
24 
25 #include "GraphicsView_Defs.h"
26 
27 #include <SUIT_ViewModel.h>
28 
29 #include <QPainterPath>
30 
31 class QGraphicsSceneMouseEvent;
32 class QGraphicsSceneWheelEvent;
33 class QKeyEvent;
34 
35 class SUIT_ViewWindow;
36 
38 class GraphicsView_Scene;
42 
43 /*
44  Class : GraphicsView_Viewer
45  Description : View model of the graphics view
46 */
48 {
49  Q_OBJECT
50 
51 public:
52  enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
53  Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 };
54 public:
55  GraphicsView_Viewer( const QString& title, QWidget* widget = NULL );
57 
58 public:
60 
61  virtual QString getType() const { return Type(); }
62  static QString Type() { return "GraphicsView"; }
63 
64  virtual void contextMenuPopup( QMenu* );
65 
66 public:
67  GraphicsView_Selector* getSelector();
68 
69  GraphicsView_ViewFrame* getActiveView() const;
70  GraphicsView_ViewPort* getActiveViewPort() const;
71  GraphicsView_Scene* getActiveScene() const;
72 
73  void activateTransform( int );
74 
75  bool isInitialized() const { return myIsInitialized; }
76  void setIsInitialized( bool );
77 
78 signals:
79  void selectionChanged( GV_SelectionChangeStatus );
80  void wheelScaleChanged();
81 
82 protected:
83  virtual GraphicsView_ViewTransformer* createTransformer( int );
84 
85  virtual void onTransformationStarted();
86  virtual void onTransformationFinished();
87 
88 protected slots:
89  virtual void onKeyEvent( QKeyEvent* );
90  virtual void onMouseEvent( QGraphicsSceneMouseEvent* );
91  virtual void onWheelEvent( QGraphicsSceneWheelEvent* );
92 
93  virtual void onSketchingFinished( QPainterPath );
94 
95  virtual void onSelectionDone( GV_SelectionChangeStatus );
96  virtual void onSelectionCancel();
97 
98  virtual void onChangeBgColor();
99 
100  // testing ImageViewer
101  /*
102  void onAddImage();
103  void onRemoveImages();
104  void onBringToFront();
105  void onSendToBack();
106  void onBringForward();
107  void onSendBackward();
108  void onPrsProperties();
109  void onTestFuseOperator();
110  void onTestCropOperatorPrepare();
111  void onTestCropOperatorPerform( QPainterPath thePath );
112  */
113 
114 private:
115  void handleKeyPress( QKeyEvent* );
116  void handleKeyRelease( QKeyEvent* );
117  void handleMouseMove( QGraphicsSceneMouseEvent* );
118  void handleMousePress( QGraphicsSceneMouseEvent* );
119  void handleMouseRelease( QGraphicsSceneMouseEvent* );
120  void handleWheel( QGraphicsSceneWheelEvent* );
121 
122  // testing ImageViewer
123  enum QueueOperation { BringToFront, SendToBack, BringForward, SendBackward };
124  void processQueueOperation( const QueueOperation );
125 
126 protected:
130 
132 };
133 
134 #endif