Salome HOME
Fix problem with table of contents resizing
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasView.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SUPERVGUI_CanvasView.h
23 //  Author : Natalia KOPNOVA
24 //  Module : SUPERV
25
26 #ifndef SUPERVGUI_CanvasView_H
27 #define SUPERVGUI_CanvasView_H
28
29 #include "SUPERVGUI_Canvas.h"
30 #include <qpopupmenu.h>
31
32 //VRV: porting on Qt 3.0.5
33 #if QT_VERSION >= 0x030005
34 #include <qcursor.h> 
35 #endif
36 //VRV: porting on Qt 3.0.5
37
38 class SUPERVGUI_Main;
39 class SUPERVGUI_CanvasLink;
40 class SUPERVGUI_CanvasLinkBuilder;
41
42 class SUPERVGUI_CanvasView: public QCanvasView {
43   Q_OBJECT
44
45   public:
46     SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGUI_Main* theMain);
47     virtual ~SUPERVGUI_CanvasView();
48
49     SUPERVGUI_Main* getMain() const { return myMain; }
50     
51     void ActivatePanning();
52     void ResetView();
53
54     bool isAnyLinkCreating() const { return myIsLinkCreating; }
55     void startSketch(SUPERVGUI_CanvasPort* thePort);
56
57   signals:
58     void objectCreated(); // mkr : PAL8237
59
60   public slots:
61     void addToStudy();
62     void onTimeout();
63     void zoomIn();
64     void zoomOut();
65     void zoomReset();
66     void fitAll();
67     void fitWithinRect();
68     void changeBackground();
69
70   protected:
71     void contentsMouseMoveEvent(QMouseEvent* theEvent);
72     void contentsMouseReleaseEvent(QMouseEvent* theEvent); 
73     void contentsMousePressEvent(QMouseEvent* theEvent); 
74     void contentsMouseDoubleClickEvent(QMouseEvent* theEvent); 
75
76   private slots:
77     void onDestroyed(QObject* theObject);
78   // new link creation
79     void cancelSketch();
80     void deletePoint();
81     void setOrthoMode();
82
83   private:
84     void setHilighted(SUPERVGUI_CanvasLink* theLink);
85     void endSketch(SUPERVGUI_CanvasPort* thePort);
86
87     bool isHavingStreamPort() const;
88
89     SUPERVGUI_Main* myMain;
90     QPopupMenu*     myPopup;
91     int             myAddStudyItem;
92     int             myPasteNodeItem;
93     int             myDSParamsItem;
94     QPopupMenu*     mySketchPopup;
95     int             myDelPntItem;
96     int             myOrtoItem;
97     int             myShowToolBarItem;
98
99     bool         myIsPanBtnClicked;
100     bool         myIsPanActivated;
101     bool         myIsFitWRActivated;
102     bool         myIsZoomActivated;
103     bool         myIsLinkCreating;
104
105     QCanvasItem*      myCurrentItem;
106     QPoint            myPoint;
107     QCanvasRectangle* mySelectedRect;
108     QCursor           myCursor;
109
110     QTimer*  myTimer;   
111     QPoint   myGlobalPoint;
112     int myDX;
113     int myDY;
114
115     SUPERVGUI_CanvasLink* myHilighted;
116     SUPERVGUI_CanvasLinkBuilder* myLinkBuilder;
117 };
118
119 #endif