Salome HOME
Creat\Edit stream operation.
[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 class Handle(AIS_InteractiveContext);
26
27 #ifdef WIN32
28 #pragma warning ( disable:4251 )
29 #endif
30
31 // ---------------- OCC view widget --------
32 class CURVECREATOR_EXPORT OCCViewer_ViewWidget : public QFrame
33 {
34   Q_OBJECT
35
36 public:
37   typedef enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, TrihId,
38                  FrontId, BackId, TopId, BottomId, LeftId, RightId, None } ButtonsType;
39
40   OCCViewer_ViewWidget(QWidget* parent, const bool isUseMultiAction = true);
41   ~OCCViewer_ViewWidget();
42
43   OCCViewer_ViewPort3d* getViewPort();
44   Handle(AIS_InteractiveContext) getAISContext() { return myAISContext; }
45
46   bool      eventFilter(QObject* watched, QEvent* e);
47
48   void      reset();
49   void      Display(const TopoDS_Shape shape, const bool theShaded,
50                     const QColor& shapeColor);
51
52   enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane};
53
54   void       set2dMode( Mode2dType );
55   Mode2dType get2dMode() const { return my2dMode; }
56
57   QAction*   action( const ButtonsType& theId );
58
59 public slots:
60   void      onActivated();
61   void      onTrihChanged();
62   void      onFrontView();
63   void      onBackView();
64   void      onTopView();
65   void      onBottomView();
66   void      onLeftView();
67   void      onRightView();
68
69 signals:
70   void      mouseMoving( QMouseEvent* theEvent );
71   void      mousePressed( QMouseEvent* theEvent );
72   void      mouseReleased( QMouseEvent* theEvent );
73
74 private:
75   enum OperationType{ NOTHING, FITALLVIEW, WINDOWFIT, ZOOMVIEW, PANVIEW, PANGLOBAL,
76                       ROTATE };
77
78   void      createActions();
79   void      viewZFitAll();
80   void      activateZoom();
81   void      activateWindowFit();
82   void      activateRotation();
83   void      activatePanning();
84   void      activateGlPanning();
85   OperationType getButtonState(QMouseEvent* theEvent);
86   void      viewerFitAll(const bool theUpdate = true);
87
88   void vpMousePressEvent  (QMouseEvent* theEvent);
89   void vpMouseReleaseEvent(QMouseEvent* theEvent);
90   void vpMouseMoveEvent   (QMouseEvent* theEvent);
91
92   void drawRect();
93   void resetState();
94   bool transformRequested() { return myOperation != NOTHING; }
95   bool setTransformRequested (OperationType op);
96   void clearViewer(const bool theUpdate = true);
97
98   typedef QMap<ButtonsType, QtxAction*> ActionsMap;
99
100 private:
101   OCCViewer_ViewPort3d*          myViewPort;
102   Handle(V3d_Viewer)             myV3dViewer;
103 #if OCC_VERSION_LARGE <= 0x06060000 
104   Handle(V3d_Viewer)             myV3dCollector;
105 #endif
106   Handle(AIS_InteractiveContext) myAISContext;
107   Handle(AIS_Trihedron)          myTrihedron;
108
109   QtxMultiAction       *myZoomBtns, *myPanBtns, *myProjBtns;
110   QToolBar*            myToolBar;
111   OperationType        myOperation;
112
113   ActionsMap           myButsMap;
114   QCursor              myCursor;
115   QRect                myRect;
116
117   double                myCurScale;
118   bool                  myCursorIsHand;
119   bool                  myDrawRect;
120   int                   myStartX;
121   int                   myStartY;
122   int                   myCurrX;
123   int                   myCurrY;
124   OCCViewer_ViewWindow::RotationPointType myCurrPointType;
125   gp_Pnt                mySelectedPoint;
126   bool                  myShowTrihedron;
127
128   Mode2dType            my2dMode;
129   bool                  myUseMultiAction;
130 };
131
132 #endif