Salome HOME
Profile dialog backgound like it is in OCC viewer.
[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   OCCViewer_ViewPort3d* getViewPort();
40
41   bool      eventFilter(QObject* watched, QEvent* e);
42
43   void      reset();
44   void      Display(const TopoDS_Shape shape, const bool theShaded,
45                     const QColor& shapeColor);
46
47 private slots:
48   void      onActivated();
49   void      onTrihChanged();
50   void      onFrontView();
51   void      onBackView();
52   void      onTopView();
53   void      onBottomView();
54   void      onLeftView();
55   void      onRightView();
56
57 private:
58   enum OperationType{ NOTHING, FITALLVIEW, WINDOWFIT, ZOOMVIEW, PANVIEW, PANGLOBAL,
59                       ROTATE };
60
61   void      createActions();
62   void      viewZFitAll();
63   void      activateZoom();
64   void      activateWindowFit();
65   void      activateRotation();
66   void      activatePanning();
67   void      activateGlPanning();
68   OperationType getButtonState(QMouseEvent* theEvent);
69   void      viewerFitAll(const bool theUpdate = true);
70
71   void vpMousePressEvent  (QMouseEvent* theEvent);
72   void vpMouseReleaseEvent(QMouseEvent* theEvent);
73   void vpMouseMoveEvent   (QMouseEvent* theEvent);
74
75   void drawRect();
76   void resetState();
77   bool transformRequested() { return myOperation != NOTHING; }
78   bool setTransformRequested (OperationType op);
79   void clearViewer(const bool theUpdate = true);
80
81   typedef enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, TrihId,
82                  FrontId, BackId, TopId, BottomId, LeftId, RightId, None } ButtonsType;
83   typedef QMap<ButtonsType, QtxAction*> ActionsMap;
84
85 private:
86   OCCViewer_ViewPort3d*          myViewPort;
87   Handle(V3d_Viewer)             myV3dViewer;
88 #if OCC_VERSION_LARGE <= 0x06060000 
89   Handle(V3d_Viewer)             myV3dCollector;
90 #endif
91   Handle(AIS_InteractiveContext) myAISContext;
92   Handle(AIS_Trihedron)          myTrihedron;
93
94   QtxMultiAction       *myZoomBtns, *myPanBtns, *myProjBtns;
95   QToolBar*            myToolBar;
96   OperationType        myOperation;
97
98   ActionsMap           myButsMap;
99   QCursor              myCursor;
100   QRect                myRect;
101
102   double                myCurScale;
103   bool                  myCursorIsHand;
104   bool                  myDrawRect;
105   int                   myStartX;
106   int                   myStartY;
107   int                   myCurrX;
108   int                   myCurrY;
109   OCCViewer_ViewWindow::RotationPointType myCurrPointType;
110   gp_Pnt                mySelectedPoint;
111   bool                  myShowTrihedron;
112 };
113
114 #endif