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