1 // Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef GRAPHICSVIEW_VIEWER_H
21 #define GRAPHICSVIEW_VIEWER_H
23 #include "GraphicsView.h"
25 #include "GraphicsView_Defs.h"
27 #include <SUIT_ViewModel.h>
29 #include <QPainterPath>
31 class QGraphicsSceneMouseEvent;
32 class QGraphicsSceneWheelEvent;
35 class SUIT_ViewWindow;
37 class GraphicsView_Selector;
38 class GraphicsView_Scene;
39 class GraphicsView_ViewTransformer;
40 class GraphicsView_ViewFrame;
41 class GraphicsView_ViewPort;
44 Class : GraphicsView_Viewer
45 Description : View model of the graphics view
47 class GRAPHICSVIEW_API GraphicsView_Viewer: public SUIT_ViewModel
52 enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
53 Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 };
55 GraphicsView_Viewer( const QString& title );
56 ~GraphicsView_Viewer();
59 virtual SUIT_ViewWindow* createView( SUIT_Desktop* );
61 virtual QString getType() const { return Type(); }
62 static QString Type() { return "GraphicsView"; }
64 virtual void contextMenuPopup( QMenu* );
67 GraphicsView_Selector* getSelector();
69 GraphicsView_ViewFrame* getActiveView() const;
70 GraphicsView_ViewPort* getActiveViewPort() const;
71 GraphicsView_Scene* getActiveScene() const;
73 void activateTransform( int );
75 bool isInitialized() const { return myIsInitialized; }
76 void setIsInitialized( bool );
79 void selectionChanged( GV_SelectionChangeStatus );
80 void wheelScaleChanged();
83 virtual GraphicsView_ViewTransformer* createTransformer( int );
85 virtual void onTransformationStarted();
86 virtual void onTransformationFinished();
89 virtual void onKeyEvent( QKeyEvent* );
90 virtual void onMouseEvent( QGraphicsSceneMouseEvent* );
91 virtual void onWheelEvent( QGraphicsSceneWheelEvent* );
93 virtual void onSketchingFinished( QPainterPath );
95 virtual void onSelectionDone( GV_SelectionChangeStatus );
96 virtual void onSelectionCancel();
98 virtual void onChangeBgColor();
100 // testing ImageViewer
103 void onRemoveImages();
104 void onBringToFront();
106 void onBringForward();
107 void onSendBackward();
108 void onPrsProperties();
109 void onTestFuseOperator();
110 void onTestCropOperatorPrepare();
111 void onTestCropOperatorPerform( QPainterPath thePath );
115 void handleKeyPress( QKeyEvent* );
116 void handleKeyRelease( QKeyEvent* );
117 void handleMouseMove( QGraphicsSceneMouseEvent* );
118 void handleMousePress( QGraphicsSceneMouseEvent* );
119 void handleMouseRelease( QGraphicsSceneMouseEvent* );
120 void handleWheel( QGraphicsSceneWheelEvent* );
122 // testing ImageViewer
123 enum QueueOperation { BringToFront, SendToBack, BringForward, SendBackward };
124 void processQueueOperation( const QueueOperation );
127 GraphicsView_Selector* mySelector;
128 GraphicsView_ViewTransformer* myTransformer;
130 bool myIsInitialized;