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