Version: 9.12.0
GraphicsView_Viewer.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2023 CEA, EDF, 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:
81 
82 protected:
83  virtual GraphicsView_ViewTransformer* createTransformer( int );
84  virtual GraphicsView_ViewFrame* createViewFrame( SUIT_Desktop* theDesktop, QWidget* theWidget );
85 
86  virtual void onTransformationStarted();
87  virtual void onTransformationFinished();
88 
89 protected slots:
90  virtual void onKeyEvent( QKeyEvent* );
91  virtual void onMouseEvent( QGraphicsSceneMouseEvent* );
92  virtual void onWheelEvent( QGraphicsSceneWheelEvent* );
93 
94  virtual void onSketchingFinished( QPainterPath );
95 
96  virtual void onSelectionDone( GV_SelectionChangeStatus );
97  virtual void onSelectionCancel();
98 
99  virtual void onChangeBgColor();
100 
101  // testing ImageViewer
102  /*
103  void onAddImage();
104  void onRemoveImages();
105  void onBringToFront();
106  void onSendToBack();
107  void onBringForward();
108  void onSendBackward();
109  void onPrsProperties();
110  void onTestFuseOperator();
111  void onTestCropOperatorPrepare();
112  void onTestCropOperatorPerform( QPainterPath thePath );
113  */
114 
115 protected:
116  virtual void handleKeyPress( QKeyEvent* );
117  virtual void handleKeyRelease( QKeyEvent* );
118  virtual void handleMouseMove( QGraphicsSceneMouseEvent* );
119  virtual void handleMousePress( QGraphicsSceneMouseEvent* );
120  virtual void handleMouseRelease( QGraphicsSceneMouseEvent* );
121  virtual void handleWheel( QGraphicsSceneWheelEvent* );
122 
123  // testing ImageViewer
124  enum QueueOperation { BringToFront, SendToBack, BringForward, SendBackward };
126 
127 protected:
131 
133 };
134 
135 #endif
#define GRAPHICSVIEW_API
Definition: GraphicsView.h:29
GV_SelectionChangeStatus
Definition: GraphicsView_Defs.h:30
Definition: GraphicsView_Scene.h:34
Definition: GraphicsView_Selector.h:37
Definition: GraphicsView_ViewFrame.h:44
Definition: GraphicsView_ViewPort.h:41
Definition: GraphicsView_ViewTransformer.h:38
Definition: GraphicsView_Viewer.h:48
QueueOperation
Definition: GraphicsView_Viewer.h:124
@ BringForward
Definition: GraphicsView_Viewer.h:124
GraphicsView_Selector * mySelector
Definition: GraphicsView_Viewer.h:128
virtual QString getType() const
Definition: GraphicsView_Viewer.h:61
GraphicsView_ViewTransformer * myTransformer
Definition: GraphicsView_Viewer.h:129
static QString Type()
Definition: GraphicsView_Viewer.h:62
void selectionChanged(GV_SelectionChangeStatus)
bool isInitialized() const
Definition: GraphicsView_Viewer.h:75
bool myIsInitialized
Definition: GraphicsView_Viewer.h:132
TransformType
Definition: GraphicsView_Viewer.h:52
@ FitWidth
Definition: GraphicsView_Viewer.h:53
@ FitAll
Definition: GraphicsView_Viewer.h:52
void processQueueOperation(const QueueOperation)
QWidget * myWidget
Definition: GraphicsView_Viewer.h:130
Definition: SUIT_Desktop.h:47
Definition: SUIT_ViewModel.h:47
virtual void contextMenuPopup(QMenu *)
Definition: SUIT_ViewModel.h:69
virtual SUIT_ViewWindow * createView(SUIT_Desktop *theDesktop)
Definition: SUIT_ViewModel.cxx:77
Definition: SUIT_ViewWindow.h:42
int Type
Definition: VTKViewer_Actor.h:62