0031518: Samples - update QtWidget samples to use AIS_ViewController
[occt.git] / samples / qt / Common / src / View.h
index 8274454..4268d5e 100755 (executable)
@@ -8,13 +8,14 @@
 #include <Standard_WarningsRestore.hxx>
 
 #include <AIS_InteractiveContext.hxx>
+#include <AIS_ViewController.hxx>
 #include <V3d_View.hxx>
 
 class TopoDS_Shape;
 class QRubberBand;
 
 //class COMMONSAMPLE_EXPORT View: public QWidget
-class View: public QWidget
+class View: public QWidget, protected AIS_ViewController
 {
     Q_OBJECT
 protected:
@@ -95,6 +96,7 @@ protected:
     virtual void                  mousePressEvent( QMouseEvent* );
     virtual void                  mouseReleaseEvent(QMouseEvent* );
     virtual void                  mouseMoveEvent( QMouseEvent* );
+    virtual void                  wheelEvent (QWheelEvent* );
 
     virtual void                  addItemInPopup( QMenu* );
 
@@ -103,48 +105,41 @@ protected:
     void                                  activateCursor( const CurrentAction3d );
     void                                  Popup( const int x, const int y );
     CurrentAction3d                       getCurrentMode();
+    void                                  updateView();
 
-    virtual void                          onLButtonDown( const int nFlags, const QPoint point );
-    virtual void                          onMButtonDown( const int nFlags, const QPoint point );
-    virtual void                          onRButtonDown( const int nFlags, const QPoint point );
-    virtual void                          onLButtonUp( Qt::MouseButtons nFlags, const QPoint point );
-    virtual void                          onMButtonUp( Qt::MouseButtons nFlags, const QPoint point );
-    virtual void                          onRButtonUp( Qt::MouseButtons nFlags, const QPoint point );
-    virtual void                          onMouseMove( Qt::MouseButtons nFlags, const QPoint point );
+    //! Setup mouse gestures.
+    void defineMouseGestures();
+
+    //! Set current action.
+    void setCurrentAction (CurrentAction3d theAction)
+    {
+      myCurrentMode = theAction;
+      defineMouseGestures();
+    }
+
+    //! Handle selection changed event.
+    void OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx,
+                             const Handle(V3d_View)& theView) Standard_OVERRIDE;
 
 private:
     void                          initCursors();
     void                          initViewActions();
     void                          initRaytraceActions();
-    void                          DragEvent( const int x, const int y, const int TheState );
-    void                          InputEvent( const int x, const int y );
-    void                          MoveEvent( const int x, const int y );
-    void                          MultiMoveEvent( const int x, const int y );
-    void                          MultiDragEvent( const int x, const int y, const int TheState );
-    void                          MultiInputEvent( const int x, const int y );
-    void                          DrawRectangle( const int MinX, const int MinY,
-                                                 const int MaxX, const int MaxY, const bool Draw );
-
 private:
     bool                            myIsRaytracing;
     bool                            myIsShadowsEnabled;
     bool                            myIsReflectionsEnabled;
     bool                            myIsAntialiasingEnabled;
 
-    bool                            myDrawRect;           // set when a rect is used for selection or magnify 
     Handle(V3d_View)                myView;
     Handle(AIS_InteractiveContext)  myContext;
+    AIS_MouseGestureMap             myDefaultGestures;
+    Graphic3d_Vec2i                 myClickPos;
     CurrentAction3d                 myCurrentMode;
-    Standard_Integer                myXmin;
-    Standard_Integer                myYmin;
-    Standard_Integer                myXmax;
-    Standard_Integer                myYmax;
     Standard_Real                   myCurZoom;
-    Standard_Boolean                myHlrModeIsOn;
     QList<QAction*>*                myViewActions;
     QList<QAction*>*                myRaytraceActions;
     QMenu*                          myBackMenu;
-    QRubberBand*                    myRectBand; //!< selection rectangle rubber band
 };
 
 #endif