Salome HOME
Profile object realization. OCC Viewer embeded into the profile dialog box.
[modules/hydro.git] / src / HYDROCurveCreator / OCCViewer_ViewWidget.h
1 // File:        OCCViewer_ViewWidget.h
2 // Created:     26 Jul 2012
3 // Author:      Natalia ERMOLAEVA
4 // Copyright:   CEA 2011
5
6 #ifndef OCCVIEWER_VIEWWIDGET_H
7 #define OCCVIEWER_VIEWWIDGET_H
8
9 #include "CurveCreator_Macro.hxx"
10
11 #include <QCursor>
12 #include <QFrame>
13 #include <QColor>
14
15 #include <QtxAction.h>
16 #include <QtxMultiAction.h>
17
18 #include <OCCViewer_ViewWindow.h>
19 #include <V3d_Viewer.hxx>
20 #include <AIS_InteractiveContext.hxx>
21 #include <AIS_Trihedron.hxx>
22 #include <TopoDS_Shape.hxx>
23
24 class OCCViewer_ViewPort3d;
25 class QPushButton;
26 class QToolBar;
27
28 class Handle(V3d_Viewer);
29
30 #ifdef WIN32
31 #pragma warning ( disable:4251 )
32 #endif
33
34 // ---------------- OCC view widget --------
35 class CURVECREATOR_EXPORT OCCViewer_ViewWidget : public QFrame
36 {
37   Q_OBJECT
38
39 public:
40   OCCViewer_ViewWidget(QWidget* parent);
41   ~OCCViewer_ViewWidget();
42
43   bool      eventFilter(QObject* watched, QEvent* e);
44
45   void      reset();
46   void      Display(const TopoDS_Shape shape, const bool theShaded,
47                     const QColor& shapeColor);
48
49 private slots:
50   void      onActivated();
51   void      onTrihChanged();
52   void      onFrontView();
53   void      onBackView();
54   void      onTopView();
55   void      onBottomView();
56   void      onLeftView();
57   void      onRightView();
58
59 private:
60   enum OperationType{ NOTHING, FITALLVIEW, WINDOWFIT, ZOOMVIEW, PANVIEW, PANGLOBAL,
61                       ROTATE };
62
63   void      createActions();
64   void      viewZFitAll();
65   void      activateZoom();
66   void      activateWindowFit();
67   void      activateRotation();
68   void      activatePanning();
69   void      activateGlPanning();
70   OperationType getButtonState(QMouseEvent* theEvent);
71   void      viewerFitAll(const bool theUpdate = true);
72
73   void vpMousePressEvent  (QMouseEvent* theEvent);
74   void vpMouseReleaseEvent(QMouseEvent* theEvent);
75   void vpMouseMoveEvent   (QMouseEvent* theEvent);
76
77   void drawRect();
78   void resetState();
79   bool transformRequested() { return myOperation != NOTHING; }
80   bool setTransformRequested (OperationType op);
81   void clearViewer(const bool theUpdate = true);
82
83   typedef enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, TrihId,
84                  FrontId, BackId, TopId, BottomId, LeftId, RightId, None } ButtonsType;
85   typedef QMap<ButtonsType, QtxAction*> ActionsMap;
86
87 private:
88   OCCViewer_ViewPort3d*          myViewPort;
89   Handle(V3d_Viewer)             myV3dViewer;
90 #if OCC_VERSION_LARGE <= 0x06060000 
91   Handle(V3d_Viewer)             myV3dCollector;
92 #endif
93   Handle(AIS_InteractiveContext) myAISContext;
94   Handle(AIS_Trihedron)          myTrihedron;
95
96   QtxMultiAction       *myZoomBtns, *myPanBtns, *myProjBtns;
97   QToolBar*            myToolBar;
98   OperationType        myOperation;
99
100   ActionsMap           myButsMap;
101   QCursor              myCursor;
102   QRect                myRect;
103
104   double                myCurScale;
105   bool                  myCursorIsHand;
106   bool                  myDrawRect;
107   int                   myStartX;
108   int                   myStartY;
109   int                   myCurrX;
110   int                   myCurrY;
111   OCCViewer_ViewWindow::RotationPointType myCurrPointType;
112   gp_Pnt                mySelectedPoint;
113   bool                  myShowTrihedron;
114 };
115
116 #endif