]> OCCT Git - occt.git/commitdiff
0031658: Inspector - using AIS_ViewController in View package
authornds <nds@opencascade.com>
Thu, 10 Sep 2020 03:46:26 +0000 (06:46 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 10 Sep 2020 15:15:06 +0000 (18:15 +0300)
- View: using AIS_ViewController, AIS_ViewCube.

20 files changed:
tools/DFBrowser/DFBrowser_Window.cxx
tools/ShapeView/ShapeView_Window.cxx
tools/VInspector/VInspector_Window.cxx
tools/View/View.qrc
tools/View/View_Displayer.cxx
tools/View/View_Displayer.hxx
tools/View/View_ToolActionType.hxx
tools/View/View_ToolBar.cxx
tools/View/View_ViewActionType.hxx
tools/View/View_Widget.cxx
tools/View/View_Widget.hxx
tools/View/View_Window.cxx
tools/View/View_Window.hxx
tools/View/icons/cursor_rotate.png [deleted file]
tools/View/icons/cursor_zoom.png [deleted file]
tools/View/icons/view_cube.png [new file with mode: 0644]
tools/View/icons/view_fitarea.png [deleted file]
tools/View/icons/view_pan.png [deleted file]
tools/View/icons/view_rotate.png [deleted file]
tools/View/icons/view_zoom.png [deleted file]

index 01b100b1899111e4e0f7b1cecedafa8e0b99e818..f0415e5ecae936c4a40df54ea1272bb2d3827e47 100644 (file)
@@ -57,7 +57,6 @@
 #include <inspector/View_Displayer.hxx>
 #include <inspector/View_ToolBar.hxx>
 #include <inspector/View_Viewer.hxx>
-#include <inspector/View_Widget.hxx>
 #include <inspector/View_Window.hxx>
 
 #include <TDF_Tool.hxx>
@@ -194,7 +193,7 @@ DFBrowser_Window::DFBrowser_Window()
 
   // view
   myViewWindow = new View_Window (myMainWindow);
-  myViewWindow->ViewWidget()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
+  myViewWindow->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
 
   QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
   aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
index bfe8d34ecabb9666c87732caadb98f15933803c8..d6f54d75cc4cd24f428c2f91b08d2dfc7b1c5ea6 100644 (file)
@@ -31,7 +31,6 @@
 #include <inspector/View_Displayer.hxx>
 #include <inspector/View_PresentationType.hxx>
 #include <inspector/View_ToolBar.hxx>
-#include <inspector/View_Widget.hxx>
 #include <inspector/View_Window.hxx>
 #include <inspector/View_Viewer.hxx>
 
@@ -129,7 +128,7 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
   connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
   aVisibilityState->SetDisplayer (myViewWindow->Displayer());
   aVisibilityState->SetPresentationType (View_PresentationType_Main);
-  myViewWindow->ViewWidget()->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
+  myViewWindow->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
 
   QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
   aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
index 1991dbe6316682cea6ac2faf7f2c56e06ef80d0b..17fc850e6dd16e3e6ed5b49d4daa4256e5e1c732 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <AIS_Shape.hxx>
 #include <BRepBuilderAPI_MakeVertex.hxx>
+#include <V3d_Viewer.hxx>
 
 #include <inspector/Convert_Tools.hxx>
 
@@ -48,6 +49,7 @@
 #include <inspector/View_PreviewParameters.hxx>
 #include <inspector/View_Widget.hxx>
 #include <inspector/View_Window.hxx>
+#include <inspector/View_Viewer.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QApplication>
@@ -892,7 +894,7 @@ Handle(AIS_InteractiveContext) VInspector_Window::createView()
   Handle(AIS_InteractiveContext) aContext = View_Viewer::CreateStandardViewer();
 
   myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true);
-  myViewWindow->ViewWidget()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
+  myViewWindow->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
   myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
   myViewWindow->show();
 
index 89d2f9a795803b44bd4484f98cadf6a87865598f..d403f34bb9e6f7c4c1a1aa32502f89e0f2770b0e 100644 (file)
@@ -1,18 +1,13 @@
 <!DOCTYPE RCC><RCC version="1.0">
     <qresource>
-        <file>icons/cursor_rotate.png</file>
-        <file>icons/cursor_zoom.png</file>
         <file>icons/keep_view_off.png</file>
         <file>icons/keep_view_on.png</file>
         <file>icons/trihedron.png</file>
         <file>icons/view_clear.png</file>
+        <file>icons/view_cube.png</file>
         <file>icons/view_dm_shading.png</file>
         <file>icons/view_dm_wireframe.png</file>
         <file>icons/view_fitall.png</file>
-        <file>icons/view_fitarea.png</file>
-        <file>icons/view_pan.png</file>
-        <file>icons/view_rotate.png</file>
-        <file>icons/view_zoom.png</file>
     </qresource>
 </RCC>
 
index 72c1c28ec738a30821a818d0bddb5a6d597d00e4..82592275d70709aeb867e80ee3efa373c6e2061a 100644 (file)
@@ -20,6 +20,7 @@
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_Trihedron.hxx>
+#include <AIS_ViewCube.hxx>
 #include <Geom_Axis2Placement.hxx>
 #include <Prs3d_PointAspect.hxx>
 #include <V3d_View.hxx>
@@ -230,6 +231,28 @@ void View_Displayer::DisplayDefaultTrihedron (const Standard_Boolean toDisplay,
     GetContext()->Erase (aTrihedron, theToUpdateViewer);
 }
 
+// =======================================================================
+// function : DisplayViewCube
+// purpose :
+// =======================================================================
+void View_Displayer::DisplayViewCube (const Standard_Boolean toDisplay, const bool theToUpdateViewer)
+{
+  if (myViewCube.IsNull() && toDisplay)
+  {
+    myViewCube = new AIS_ViewCube();
+    myViewCube->SetSize (35.0);
+    myViewCube->SetBoxColor (Quantity_NOC_GRAY50);
+  }
+
+  if (myViewCube.IsNull())
+    return;
+
+  if (toDisplay)
+    GetContext()->Display (myViewCube, theToUpdateViewer);
+  else
+    GetContext()->Erase (myViewCube, theToUpdateViewer);
+}
+
 // =======================================================================
 // function : SetVisible
 // purpose :
index da1f029a46c11372f0b7b9c86aaa6204379de606..3ba29968d8a3e87b60bc260b1b4e1775209d0e0e 100644 (file)
@@ -28,6 +28,7 @@
 #include <inspector/View_DisplayActionType.hxx>
 
 class AIS_Trihedron;
+class AIS_ViewCube;
 class V3d_View;
 class View_DisplayPreview;
 
@@ -121,6 +122,11 @@ public:
   //! \param isToUpdateView boolean state if viewer should be updated
   Standard_EXPORT void DisplayDefaultTrihedron (const Standard_Boolean toDisplay, const bool theToUpdateViewer);
 
+  //! Displays presentation of view cube, create it by the first call
+  //! \param toDisplay flag to display presentation if true, or erase it
+  //! \param isToUpdateView boolean state if viewer should be updated
+  Standard_EXPORT void DisplayViewCube (const Standard_Boolean toDisplay, const bool theToUpdateViewer);
+
   //! Sets shape visible/invisible
   //! \theShape shape instance
   //! \theState visibility state
@@ -186,7 +192,8 @@ private:
   View_DisplayPreview* myDisplayPreview; //!< class for preview display
 
   Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
-  Handle(AIS_Trihedron) myDefaultTrihedron; //!< NULL presentation until the first display
+  Handle(AIS_Trihedron) myDefaultTrihedron; //!< trihedron presentation for the current context
+  Handle(AIS_ViewCube) myViewCube; //!< view cube presentation for current context
 
   NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive>> myDisplayed; //!< visualized presentations
   NCollection_DataMap<View_PresentationType, Quantity_Color> myColorAttributes; //!< color properties of presentations
index a518d2ba541e47e786fadb82a381d8b3eb5332f3..b2b0d0d4cb89182aeb9cfb280342843cabe05db7 100644 (file)
@@ -22,7 +22,8 @@ enum View_ToolActionType
   View_ToolActionType_KeepViewId,    //!< Do not clear previously shown presentations
   View_ToolActionType_KeepViewOffId, //!< Do show only for new displayed presentation
   View_ToolActionType_ClearViewId,   //!< Erase all displayed presentations
-  View_ToolActionType_Trihedron      //!< Display/Erase trihedron presentation
+  View_ToolActionType_Trihedron,     //!< Display/Erase trihedron presentation
+  View_ToolActionType_ViewCube       //!< Display/Erase view cube presentation
 };
 
 #endif
index 7887ebbed6f999214e98d8775322760af5d5d526..e23b402ee3ca2f4cb034e90c405dd1e3c39e522f 100644 (file)
@@ -69,6 +69,13 @@ View_ToolBar::View_ToolBar (QWidget* theParent, const bool isUseKeepView)
   myActionsMap[View_ToolActionType_Trihedron]->setCheckable (true);
   myActionsMap[View_ToolActionType_Trihedron]->setChecked (false);
 
+  myActionsMap[View_ToolActionType_ViewCube] = new QToolButton (theParent);
+  myActionsMap[View_ToolActionType_ViewCube]->setIcon (QIcon (":/icons/view_cube.png"));
+  myActionsMap[View_ToolActionType_ViewCube]->setToolTip (tr ("View Cube display"));
+  myActionsMap[View_ToolActionType_ViewCube]->setCheckable (true);
+  myActionsMap[View_ToolActionType_ViewCube]->setChecked (false);
+
+
   if (isUseKeepView)
   {
     myActionsMap[View_ToolActionType_KeepViewId] = new QToolButton (theParent);
index 1f3288fa5f4caf953096cbf016b0be121f3991cc..d970c3554dba7fc590fb185d919a75614725e61e 100644 (file)
 //! Actions of view widget
 enum View_ViewActionType
 {
-  View_ViewActionType_FitAllId,  //!< fits the view to wrap the bounding box of displayed objects
-  View_ViewActionType_FitAreaId, //!< zoom the view to the given area
-  View_ViewActionType_ZoomId,    //!< zoom in/out the view by some delta
-  View_ViewActionType_PanId,     //!< move position of the view camera
-  View_ViewActionType_RotationId, //!< rotate the view
+  View_ViewActionType_FitAllId,     //!< fits the view to wrap the bounding box of displayed objects
   View_ViewActionType_DisplayModeId //!< change display mode of visualized presentations (to wireframe or shading)
 };
 
index 878b19f708739cf5dfbb29d119772a6615cb7d7a..e0c88e05a726856bda4f15ae5a26d91b21b313af 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <inspector/View_Widget.hxx>
 
+#include <AIS_ViewController.hxx>
 #include <Geom_Axis2Placement.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
 
 #include <Xw_Window.hxx>
 #endif
 
-// the key for multi selection :
-#define MULTISELECTIONKEY Qt::ShiftModifier
-// the key for shortcut (use to activate dynamic onRotate, panning)
-#define CASCADESHORTCUTKEY Qt::ControlModifier
-// for elastic bean selection
-#define ValZWMin 1
-
 // =======================================================================
 // function :  Constructor
 // purpose :
 View_Widget::View_Widget (QWidget* theParent,
                           const Handle(AIS_InteractiveContext)& theContext,
                           const bool isFitAllActive)
-: QWidget (theParent), myCurrentMode (View_CurrentAction3d_Nothing), myFirst (true), myDefaultWidth (-1),
-  myDefaultHeight (-1), myViewIsEnabled (true), myXmin (0), myYmin (0), myXmax (0), myYmax (0), myDragButtonDownX (0),
-  myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0),
+: QWidget (theParent), myFirst (true), myDefaultWidth (-1),
+  myDefaultHeight (-1), myViewIsEnabled (true),
   myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
 {
   myViewer = new View_Viewer (View_Viewer::DefaultColor());
   if (!theContext.IsNull())
+  {
     myViewer->InitViewer (theContext);
+  }
   else
   {
     myViewer->InitViewer (myViewer->CreateStandardViewer());
   }
+  myController = new AIS_ViewController();
 
   setAttribute (Qt::WA_PaintOnScreen);
   setAttribute (Qt::WA_NoSystemBackground);
@@ -87,7 +83,6 @@ View_Widget::View_Widget (QWidget* theParent,
 
   initViewActions();
   ((View_ToolButton*)myFitAllAction)->SetButtonChecked (isFitAllActive);
-  initCursors();
 }
 
 // =======================================================================
@@ -204,8 +199,7 @@ void View_Widget::SetEnabledView (const bool theIsEnabled)
   if (myViewer->GetView())
     myViewer->GetView()->SetBackgroundColor (theIsEnabled ? View_Viewer::DefaultColor()
                                                           : View_Viewer::DisabledColor());
-  for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
-    ViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
+  ViewAction (View_ViewActionType_DisplayModeId)->setEnabled (theIsEnabled);
 }
 
 // =======================================================================
@@ -254,53 +248,6 @@ void View_Widget::onCheckedStateChanged (bool isOn)
     emit checkedStateChanged(View_ViewActionType_FitAllId, isOn);
 }
 
-// =======================================================================
-// function : OnUpdateToggled
-// purpose :
-// =======================================================================
-void View_Widget::OnUpdateToggled (bool isOn)
-{
-  QAction* aSentByAction = (QAction*)sender();
-
-  if (aSentByAction == myViewActions[View_ViewActionType_DisplayModeId])
-  {
-    aSentByAction->setIcon (isOn ? QIcon (":/icons/view_dm_wireframe.png")
-                          : QIcon (":/icons/view_dm_shading.png"));
-    return;
-  }
-
-  if (!isOn)
-    return;
-
-  for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_RotationId; anActionId++)
-  {
-    QAction* anAction = myViewActions[(View_ViewActionType)anActionId];
-    if ((anAction == myViewActions[View_ViewActionType_FitAreaId]) ||
-        (anAction == myViewActions[View_ViewActionType_ZoomId]) ||
-        (anAction == myViewActions[View_ViewActionType_PanId]) ||
-        (anAction == myViewActions[View_ViewActionType_RotationId]))
-    {
-      if (anAction && (anAction != aSentByAction))
-      {
-        anAction->setChecked (false);
-      }
-      else
-      {
-        if (aSentByAction == myViewActions[View_ViewActionType_FitAreaId])
-          setActiveCursor (View_CursorMode_HandCursor);
-        else if (aSentByAction == myViewActions[View_ViewActionType_ZoomId])
-          setActiveCursor (View_CursorMode_ZoomCursor);
-        else if (aSentByAction == myViewActions[View_ViewActionType_PanId])
-          setActiveCursor (View_CursorMode_PanCursor);
-        else if (aSentByAction == myViewActions[View_ViewActionType_RotationId])
-          setActiveCursor (View_CursorMode_RotationCursor);
-        else
-          setActiveCursor (View_CursorMode_DefaultCursor);
-      }
-    }
-  }
-}
-
 // =======================================================================
 // function : initViewActions
 // purpose :
@@ -315,31 +262,8 @@ void View_Widget::initViewActions()
   createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
   myFitAllAction->setDefaultAction (ViewAction (View_ViewActionType_FitAllId));
 
-  createAction (View_ViewActionType_FitAreaId, ":/icons/view_fitarea.png", tr ("Fit Area"), SLOT (OnFitArea()), true);
-  createAction (View_ViewActionType_ZoomId, ":/icons/view_zoom.png", tr ("Zoom"), SLOT (OnZoom()), true);
-  createAction (View_ViewActionType_PanId, ":/icons/view_pan.png", tr ("Pan"), SLOT (OnPan()), true);
-  createAction (View_ViewActionType_RotationId, ":/icons/view_rotate.png", tr ("Rotation"), SLOT (OnRotate()), true);
   createAction (View_ViewActionType_DisplayModeId, ":/icons/view_dm_shading.png", tr ("Display Mode"),
                 SIGNAL (displayModeClicked()), true);
-
-  for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_RotationId; anActionId++)
-    connect (myViewActions[(View_ViewActionType)anActionId], SIGNAL (toggled(bool)), this, SLOT (OnUpdateToggled(bool)));
-}
-
-// =======================================================================
-// function : initCursors
-// purpose :
-// =======================================================================
-void View_Widget::initCursors()
-{
-  if (!myCursors.empty())
-    return;
-
-  myCursors[View_CursorMode_DefaultCursor] = QCursor (Qt::ArrowCursor);
-  myCursors[View_CursorMode_HandCursor] = QCursor (Qt::PointingHandCursor);
-  myCursors[View_CursorMode_PanCursor] = QCursor (Qt::SizeAllCursor);
-  myCursors[View_CursorMode_ZoomCursor] = QCursor(QIcon (":/icons/cursor_zoom.png").pixmap (20, 20));
-  myCursors[View_CursorMode_RotationCursor] = QCursor(QIcon (":/icons/cursor_rotate.png").pixmap (20, 20));
 }
 
 // =======================================================================
@@ -348,439 +272,41 @@ void View_Widget::initCursors()
 // =======================================================================
 void View_Widget::mousePressEvent (QMouseEvent* theEvent)
 {
-  if (theEvent->button() == Qt::LeftButton)
-    processLeftButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-  else if (theEvent->button() == Qt::MidButton)
-    processMiddleButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-  else if (theEvent->button() == Qt::RightButton)
-    processRightButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-}
-
-// =======================================================================
-// function : mouseReleaseEvent
-// purpose :
-// =======================================================================
-void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
-{
-  if (theEvent->button() == Qt::LeftButton)
-    processLeftButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-  else if (theEvent->button() == Qt::MidButton)
-    processMiddleButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-  else if (theEvent->button() == Qt::RightButton)
-    processRightButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-}
-
-// =======================================================================
-// function : mouseMoveEvent
-// purpose :
-// =======================================================================
-void View_Widget::mouseMoveEvent (QMouseEvent* theEvent)
-{
-  processMouseMove (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
-}
-
-// =======================================================================
-// function : activateCursor
-// purpose :
-// =======================================================================
-void View_Widget::activateCursor (const View_CurrentAction3d theMode)
-{
-  switch (theMode)
-  {
-    case View_CurrentAction3d_DynamicPanning:
-    {
-      setActiveCursor (View_CursorMode_PanCursor);
-      break;
-    }
-    case View_CurrentAction3d_DynamicZooming:
-    {
-      setActiveCursor (View_CursorMode_ZoomCursor);
-      break;
-    }
-    case View_CurrentAction3d_DynamicRotation:
-    {
-      setActiveCursor (View_CursorMode_RotationCursor);
-      break;
-    }
-    case View_CurrentAction3d_WindowZooming:
-    {
-      setActiveCursor (View_CursorMode_HandCursor);
-      break;
-    }
-    case View_CurrentAction3d_Nothing:
-    default:
-    {
-      setActiveCursor (View_CursorMode_DefaultCursor);
-      break;
-    }
-  }
-}
-
-// =======================================================================
-// function : processLeftButtonDown
-// purpose :
-// =======================================================================
-void View_Widget::processLeftButtonDown (const int theFlags, const QPoint thePoint)
-{
-  //  save the current mouse coordinate in min
-  myXmin = thePoint.x();
-  myYmin = thePoint.y();
-  myXmax = thePoint.x();
-  myYmax = thePoint.y();
-
-  if (theFlags & CASCADESHORTCUTKEY)
-  {
-    myCurrentMode = View_CurrentAction3d_DynamicZooming;
-    OnUpdateToggled(true);
-  }
-  else
-  {
-    switch (myCurrentMode)
-    {
-      case View_CurrentAction3d_Nothing:
-      {
-        if (theFlags & MULTISELECTIONKEY)
-          processDragMultiEvent (myXmax, myYmax, View_DragMode_ButtonDown);
-        else
-          processDragEvent (myXmax, myYmax, View_DragMode_ButtonDown);
-        break;
-      }
-      case View_CurrentAction3d_DynamicZooming:
-      case View_CurrentAction3d_WindowZooming:
-      case View_CurrentAction3d_DynamicPanning:
-        break;
-      case View_CurrentAction3d_DynamicRotation:
-      {
-        myViewer->GetView()->StartRotation (thePoint.x(), thePoint.y());
-        break;
-      }
-      default:
-      {
-        throw Standard_ProgramError ("View_Widget::processLeftButtonDown : Incompatible Current Mode");
-        break;
-      }
-    }
-  }
-  activateCursor (myCurrentMode);
-  emit leftButtonDown(thePoint.x(), thePoint.y());
-}
-
-// =======================================================================
-// function : processMiddleButtonDown
-// purpose :
-// =======================================================================
-void View_Widget::processMiddleButtonDown (const int theFlags, const QPoint /*thePoint*/)
-{
-  if (theFlags & CASCADESHORTCUTKEY) {
-    myCurrentMode = View_CurrentAction3d_DynamicPanning;
-    OnUpdateToggled(true);
-  }
-  activateCursor (myCurrentMode);
-}
-
-// =======================================================================
-// function : processRightButtonDown
-// purpose :
-// =======================================================================
-void View_Widget::processRightButtonDown (const int theFlags, const QPoint thePoint)
-{
-  if (theFlags & CASCADESHORTCUTKEY)
-  {
-    myCurrentMode = View_CurrentAction3d_DynamicRotation;
-    myViewer->GetView()->StartRotation (thePoint.x(), thePoint.y());
-    OnUpdateToggled(true);
-  }
-  else
-  {
-    popup (thePoint.x(), thePoint.y());
-  }
-  activateCursor (myCurrentMode);
-}
-
-// =======================================================================
-// function : processLeftButtonUp
-// purpose :
-// =======================================================================
-void View_Widget::processLeftButtonUp (const int theFlags, const QPoint thePoint)
-{
-  switch (myCurrentMode)
-  {
-    case View_CurrentAction3d_Nothing:
-    {
-      if (thePoint.x() == myXmin && thePoint.y() == myYmin)
-      {
-        // no offset between down and up --> selectEvent
-        myXmax = thePoint.x();
-        myYmax = thePoint.y();
-        if (theFlags & MULTISELECTIONKEY)
-          processInputMultiEvent (thePoint.x(), thePoint.y());
-        else
-          processInputEvent (thePoint.x(), thePoint.y());
-      }
-      else
-      {
-        drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
-        myXmax = thePoint.x();
-        myYmax = thePoint.y();
-        if (theFlags & MULTISELECTIONKEY)
-          processDragMultiEvent (thePoint.x(), thePoint.y(), View_DragMode_ButtonUp);
-        else
-          processDragEvent (thePoint.x(), thePoint.y(), View_DragMode_ButtonUp);
-      }
-      break;
-    }
-    case View_CurrentAction3d_DynamicZooming:
-    break;
-    case View_CurrentAction3d_WindowZooming:
-    {
-      drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
-      myXmax = thePoint.x();
-      myYmax = thePoint.y();
-      if ((abs(myXmin - myXmax) > ValZWMin) ||
-          (abs(myYmin - myYmax) > ValZWMin))
-        myViewer->GetView()->WindowFitAll (myXmin, myYmin, myXmax, myYmax);
-      break;
-    }
-    case View_CurrentAction3d_DynamicPanning:
-    break;
-    case View_CurrentAction3d_DynamicRotation:
-    break;
-    default:
-    {
-      throw Standard_ProgramError("View_Widget::processLeftButtonUp : Incompatible Current Mode");
-      break;
-    }
-  }
-  myDragButtonDownX = 0;
-  myDragButtonDownY = 0;
-  myDragMultiButtonDownX = 0;
-  myDragMultiButtonDownY = 0;
-
-  emit selectionChanged();
-  emit leftButtonUp(thePoint.x(), thePoint.y());
-}
-
-// =======================================================================
-// function : processMiddleButtonUp
-// purpose :
-// =======================================================================
-void View_Widget::processMiddleButtonUp (const int /*theFlags*/, const QPoint /*thePoint*/)
-{
-  myCurrentMode = View_CurrentAction3d_Nothing;
-  activateCursor (myCurrentMode);
-}
-
-// =======================================================================
-// function : processRightButtonUp
-// purpose :
-// =======================================================================
-void View_Widget::processRightButtonUp (const int /*theFlags*/, const QPoint thePoint)
-{
-  if (myCurrentMode == View_CurrentAction3d_Nothing)
-  {
-    popup (thePoint.x(), thePoint.y());
-  }
-  else
-    myCurrentMode = View_CurrentAction3d_Nothing;
-  activateCursor (myCurrentMode);
-}
-
-// =======================================================================
-// function : processMouseMove
-// purpose :
-// =======================================================================
-void View_Widget::processMouseMove (const int theFlags, const QPoint thePoint)
-{
-  if (theFlags & Qt::LeftButton || theFlags & Qt::RightButton || theFlags & Qt::MidButton)
+  if (myController->PressMouseButton (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
+                                      keyMouse (theEvent->button()),
+                                      keyFlag (theEvent->modifiers()),
+                                      Standard_False))
   {
-    switch (myCurrentMode)
-    {
-      case View_CurrentAction3d_Nothing:
-      {
-        myXmax = thePoint.x();
-        myYmax = thePoint.y();
-        drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
-        if (theFlags & MULTISELECTIONKEY)
-          processDragMultiEvent (myXmax, myYmax, View_DragMode_ButtonMove);
-        else
-          processDragEvent (myXmax, myYmax, View_DragMode_ButtonMove);
-        drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True);
-        break;
-      }
-      case View_CurrentAction3d_DynamicZooming:
-      {
-        myViewer->GetView()->Zoom (myXmax, myYmax, thePoint.x(), thePoint.y());
-        myXmax = thePoint.x();
-        myYmax = thePoint.y();
-        break;
-      }
-      case View_CurrentAction3d_WindowZooming:
-      {
-        myXmax = thePoint.x();
-        myYmax = thePoint.y();
-        drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
-        drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True);
-        break;
-      }
-      case View_CurrentAction3d_DynamicPanning:
-      {
-        myViewer->GetView()->Pan (thePoint.x() - myXmax, myYmax - thePoint.y());
-        myXmax = thePoint.x();
-        myYmax = thePoint.y();
-        break;
-      }
-      case View_CurrentAction3d_DynamicRotation:
-      {
-        myViewer->GetView()->Rotation (thePoint.x(), thePoint.y());
-        myViewer->GetView()->Redraw();
-        break;
-      }
-      default:
-      {
-        throw Standard_ProgramError("View_Widget::processMouseMove : Incompatible Current Mode");
-        break;
-      }
-    }
+    myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
   }
-  else
-  {
-    myXmax = thePoint.x();
-    myYmax = thePoint.y();
-    if (theFlags & MULTISELECTIONKEY)
-      processMoveMultiEvent (thePoint.x(), thePoint.y());
-     else
-      processMoveEvent (thePoint.x(), thePoint.y());
-  }
-  emit moveTo (thePoint.x(), thePoint.y());
 }
 
 // =======================================================================
-// function : processDragEvent
-// purpose :
-// =======================================================================
-void View_Widget::processDragEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState)
-{
-  //myDragButtonDownX = 0;
-  //myDragButtonDownY = 0;
-
-  switch (theState)
-  {
-    case View_DragMode_ButtonDown:
-    {
-      myDragButtonDownX = theX;
-      myDragButtonDownY = theY;
-      break;
-    }
-    case View_DragMode_ButtonMove:
-    break;
-    case View_DragMode_ButtonUp:
-    {
-      myViewer->GetContext()->Select (myDragButtonDownX, myDragButtonDownY, theX, theY, myViewer->GetView(), Standard_True);
-      emit selectionChanged();
-      break;
-    }
-    default:
-      break;
-  }
-}
-
-// =======================================================================
-// function : processInputEvent
-// purpose :
-// =======================================================================
-void View_Widget::processInputEvent (const Standard_Integer/* theX*/, const Standard_Integer/* theY*/)
-{
-  myViewer->GetContext()->Select (Standard_True);
-  emit selectionChanged();
-}
-
-// =======================================================================
-// function : processMoveEvent
-// purpose :
-// =======================================================================
-void View_Widget::processMoveEvent (const Standard_Integer theX, const Standard_Integer theY)
-{
-  if (myViewer->GetView())
-    myViewer->GetContext()->MoveTo (theX, theY, myViewer->GetView(), Standard_True);
-}
-
-// =======================================================================
-// function : processDragMultiEvent
+// function : mouseReleaseEvent
 // purpose :
 // =======================================================================
-void View_Widget::processDragMultiEvent (const Standard_Integer theX, const Standard_Integer theY,
-                                         const View_DragMode& theState)
+void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
 {
-  switch (theState)
+  if (myController->ReleaseMouseButton (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
+                                        keyMouse (theEvent->button()),
+                                        keyFlag (theEvent->modifiers()),
+                                        Standard_False))
   {
-    case View_DragMode_ButtonDown:
-    {
-      myDragMultiButtonDownX = theX;
-      myDragMultiButtonDownY = theY;
-      break;
-    }
-    case View_DragMode_ButtonMove:
-    {
-      myViewer->GetContext()->ShiftSelect (myDragMultiButtonDownX, myDragMultiButtonDownY, theX, theY,
-                                           myViewer->GetView(), Standard_True);
-      emit selectionChanged();
-      break;
-    }
-    case View_DragMode_ButtonUp:
-    default:
-      break;
+    myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
   }
 }
 
 // =======================================================================
-// function : processInputMultiEvent
-// purpose :
-// =======================================================================
-void View_Widget::processInputMultiEvent (const Standard_Integer /*theX*/, const Standard_Integer /*theY*/)
-{
-  myViewer->GetContext()->ShiftSelect (Standard_True);
-  emit selectionChanged();
-}
-
-// =======================================================================
-// function : drawRectangle
+// function : mouseMoveEvent
 // purpose :
 // =======================================================================
-void View_Widget::drawRectangle (const Standard_Integer theMinX, const Standard_Integer MinY,
-                                 const Standard_Integer MaxX, const Standard_Integer MaxY,
-                                 const Standard_Boolean theToDraw)
+void View_Widget::mouseMoveEvent (QMouseEvent* theEvent)
 {
-  Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
+  myController->UpdateMousePosition (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
+                                     keyMouse (theEvent->button()),
+                                     keyFlag (theEvent->modifiers()), Standard_False);
 
-  StoredMinX = (theMinX < MaxX) ? theMinX : MaxX;
-  StoredMinY = (MinY < MaxY) ? MinY : MaxY;
-  StoredMaxX = (theMinX > MaxX) ? theMinX : MaxX;
-  StoredMaxY = (MinY > MaxY) ? MinY : MaxY;
-
-  QRect aRect;
-  aRect.setRect(StoredMinX, StoredMinY, abs (StoredMaxX-StoredMinX), abs (StoredMaxY-StoredMinY));
-
-  if (!myRectBand) 
-  {
-    myRectBand = new QRubberBand (QRubberBand::Rectangle, this);
-    myRectBand->setStyle (QStyleFactory::create ("windows"));
-    myRectBand->setGeometry (aRect);
-    myRectBand->show();
-  }
-
-  if (myIsRectVisible && !theToDraw) // move or up  : erase at the old position
-  {
-    myRectBand->hide();
-    delete myRectBand;
-    myRectBand = 0;
-    myIsRectVisible = false;
-  }
-
-  if (theToDraw) // move : draw
-  {
-    myIsRectVisible = true;
-    myRectBand->setGeometry (aRect);
-  }
+  myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
 }
 
 // =======================================================================
@@ -801,11 +327,34 @@ void View_Widget::createAction (const View_ViewActionType theActionId, const QSt
 }
 
 // =======================================================================
-// function : setActiveCursor
+// function : keyFlag
 // purpose :
 // =======================================================================
-void View_Widget::setActiveCursor (const View_CursorMode& theMode)
+Aspect_VKeyFlags View_Widget::keyFlag (const int theModifierId)
 {
-  QCursor aCursor = myCursors[theMode];
-  setCursor (myCursors[theMode]);
+  switch (theModifierId)
+  {
+    case Qt::NoModifier:      return Aspect_VKeyFlags_NONE;
+    case Qt::ShiftModifier:   return Aspect_VKeyFlags_SHIFT;
+    case Qt::ControlModifier: return Aspect_VKeyFlags_CTRL;
+    default: break;
+  }
+  return Aspect_VKeyFlags_NONE;
+}
+
+// =======================================================================
+// function : keyMouse
+// purpose :
+// =======================================================================
+Aspect_VKeyMouse View_Widget::keyMouse (const int theButtonId)
+{
+  switch (theButtonId)
+  {
+    case Qt::NoButton:    return Aspect_VKeyMouse_NONE;
+    case Qt::LeftButton:  return Aspect_VKeyMouse_LeftButton;
+    case Qt::RightButton: return Aspect_VKeyMouse_RightButton;
+    case Qt::MidButton:   return Aspect_VKeyMouse_MiddleButton;
+    default: break;
+  }
+  return Aspect_VKeyMouse_NONE;
 }
index 3fd7fdb069cfe32dd1505de6fcfc7811e0e9e06c..b882f32619070f273ff6cd59d4bca929735c8081 100644 (file)
@@ -17,6 +17,8 @@
 #define View_View_H
 
 #include <AIS_InteractiveContext.hxx>
+#include <AIS_ViewController.hxx>
+#include <Aspect_VKeyFlags.hxx>
 #include <V3d_View.hxx>
 #include <inspector/View_ViewActionType.hxx>
 #include <inspector/View_Viewer.hxx>
@@ -31,8 +33,6 @@
 
 class View_Viewer;
 
-class QRubberBand;
-
 //! \class View_Widget
 //! \brief It is a Qt control that visualizes content of OCCT 3D view
 //! It creates control and actions of manipulating of this view,
@@ -41,38 +41,8 @@ class QRubberBand;
 class View_Widget : public QWidget
 {
   Q_OBJECT
-protected:
-
-  //! Enumeration defines manipulating actions of the widget
-  enum View_CurrentAction3d
-  {
-    View_CurrentAction3d_Nothing, //!< Empty action
-    View_CurrentAction3d_DynamicZooming, //!< Zoom action
-    View_CurrentAction3d_WindowZooming, //!< Zoom action using rectangle
-    View_CurrentAction3d_DynamicPanning, //!< Panning action
-    View_CurrentAction3d_DynamicRotation //!< Rotation action
-  };
-
-  //! Enumeration defines cursor kind
-  enum View_CursorMode
-  {
-    View_CursorMode_DefaultCursor, //!< default Qt cursor
-    View_CursorMode_HandCursor, //!< hand cursor
-    View_CursorMode_PanCursor, //!< panning cursor
-    View_CursorMode_ZoomCursor, //!< zoom cursor
-    View_CursorMode_RotationCursor //!< onRotate cursor
-  };
-
-  //! Enumeration defines drag mode
-  enum View_DragMode
-  {
-    View_DragMode_ButtonDown, //!< theState == -1  button down
-    View_DragMode_ButtonMove, //!< theState ==  0  move
-    View_DragMode_ButtonUp //< theState ==  1  button up
-  };
 
 public:
-
   //! Constructor
   Standard_EXPORT View_Widget (QWidget* theParent,
                                const Handle(AIS_InteractiveContext)& theContext,
@@ -154,21 +124,6 @@ signals:
   //! Sends a signal about selection change if the left mouse button is pressed and current action does not process it
   void selectionChanged();
 
-  //! Sends a signal about moving to the point in the view
-  //! \param theX X mouse position in pixels
-  //! \param theY Y mouse position in pixels
-  void  moveTo (const int theX, const int theY);
-
-  //! Sends a signal about up the left mouse button down
-  //! \param theX X mouse position in pixels
-  //! \param theY Y mouse position in pixels
-  void leftButtonDown (const int theX, const int theY);
-
-  //! Sends a signal about up the left mouse button up
-  //! \param theX X mouse position in pixels
-  //! \param theY Y mouse position in pixels
-  void leftButtonUp (const int theX, const int theY);
-
   //! Sends a signal about display mode change
   void displayModeClicked();
 
@@ -182,29 +137,11 @@ public slots:
   //! Fits all the V3d view and redraw view
   void OnFitAll() { myViewer->GetView()->FitAll(); }
 
-  //! Stores state about fitting all to use it by the mouse move
-  void OnFitArea() { myCurrentMode = View_CurrentAction3d_WindowZooming; }
-
-  //! Stores state about zoom to use it by the mouse move
-  void OnZoom() { myCurrentMode = View_CurrentAction3d_DynamicZooming; }
-
-  //! Stores state about pan to use it by the mouse move
-  void OnPan() { myCurrentMode = View_CurrentAction3d_DynamicPanning; }
-
-  //! Stores state about onRotate to use it by the mouse move
-  void OnRotate() { myCurrentMode = View_CurrentAction3d_DynamicRotation; }
-
   //! Updates states of widget actions
   //! 
   //! - if the state is checked, uncheck all other actions
   Standard_EXPORT void onCheckedStateChanged (bool isOn);
 
-  //! Updates states of tool actions:
-  //! - if the action is display mode, it changes an icon for action(wireframe or shading)
-  //! - if the state is checked, uncheck all other actions
-  //! \param isOn boolean value about check
-  Standard_EXPORT void OnUpdateToggled (bool isOn);
-
 protected:
 
   //! Avoids Qt standard execution of this method, redraw V3d view
@@ -232,99 +169,11 @@ protected:
   //! Creates view actions and fills an internal map
   void initViewActions();
 
-  //! Creates cursors and fills an internal map
-  void initCursors();
-
-  //! Sets widget cursor by the action type
-  //! \param theMode an active action mode
-  void activateCursor (const View_CurrentAction3d theMode);
-
-  //! Activates cursor of the active operation, perform drag, onRotate depending on mode,
-  //! stores the point position in xmin/xmax and ymin/ymax
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processLeftButtonDown (const int theFlags, const QPoint thePoint);
-
-  //! Activates cursor of the active operation and performs dynamic pan if it is active
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processMiddleButtonDown (const int theFlags, const QPoint thePoint);
-
-  //! Activates cursor of the active operation, build popup menu
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processRightButtonDown (const int theFlags, const QPoint thePoint);
-
-  //! Performs the active operation or performs Input/Drag event processing, emits selection changed signal
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processLeftButtonUp (const int  theFlags, const QPoint thePoint);
-
-  //! Changes the active operation to None
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processMiddleButtonUp (const int  theFlags, const QPoint thePoint);
-
-  //! Calls popup menu build and changes the active operation to None
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processRightButtonUp (const int  theFlags, const QPoint thePoint);
-
-  //! Performs active operation or draws rectangle of zoom
-  //! \param theFlags an event buttons and modifiers
-  //! \param thePoint a clicked point
-  void processMouseMove (const int  theFlags, const QPoint thePoint);
-
-  //! Performs selection: store clicked point by botton down, call Select by button up
-  //! Emits signal about selection changed
-  //! \param theX a horizontal position of mouse event
-  //! \param theX a vertical position of mouse event
-  //! \param theState a mouse button state: down, move or up
-  void processDragEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState);
-
-  //! Performs selection in context without parameter, it means the selection of picked object
-  //! \param theX a horizontal position of mouse event
-  //! \param theX a vertical position of mouse event
-  void processInputEvent (const Standard_Integer theX, const Standard_Integer theY);
-
-  //! Calls MoveTo of the context for the parameter coordinates
-  //! \param theX a horizontal position of mouse event
-  //! \param theX a vertical position of mouse event
-  void processMoveEvent (const Standard_Integer theX, const Standard_Integer theY);
-
-  //! Empty: template to process mouse move with multi selection key pressed
-  //! \param theX a horizontal position of mouse event
-  //! \param theX a vertical position of mouse event
-  void processMoveMultiEvent (const Standard_Integer theX, const Standard_Integer theY)
-  { (void)theX; (void)theY; }
-
-  //! Performs selection: store clicked point by botton down, call ShiftSelect by button move
-  //! Emits signal about selection changed
-  //! \param theX a horizontal position of mouse event
-  //! \param theX a vertical position of mouse event
-  //! \param theState a mouse button state: down, move or up
-  void processDragMultiEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState);
-
-  //! Performs shift selection in context without parameter, it means the selection of picked object
-  //! \param theX a horizontal position of mouse event
-  //! \param theX a vertical position of mouse event
-  void processInputMultiEvent (const Standard_Integer theX, const Standard_Integer theY);
-
   //! Empty: template to create popup menu
   //! \param theX a horizontal position of mouse event
   //! \param theX a vertical position of mouse event
   void popup (const Standard_Integer theX, const Standard_Integer theY) { (void)theX; (void)theY; }
 
-  //! Draws Qt rectangle for the given area (e.g. for panning operation)
-  //! \param theMinX a minimal X coordinate
-  //! \param theMinY a minimal Y coordinate
-  //! \param theMinZ a minimal Z coordinate
-  //! \param theMaxX a maximum X coordinate
-  //! \param theMaxY a maximum Y coordinate
-  //! \param theMaxZ a maximum Z coordinate
-  //! \param theToDraw state whether the rectangle should be visualized or hidden
-  void drawRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY, const Standard_Integer theMaxX,
-                      const Standard_Integer theMaxY, const Standard_Boolean theToDraw);
 private:
   //! Creates action and stores it in a map of actions
   //! \param theActionId an identifier of action in internal map
@@ -336,38 +185,32 @@ private:
                      const char* theSlot, const bool isCheckable = false,
                      const QString& theToolBar = QString(), const QString& theStatusBar = QString());
 
-  //! Sets active action cursor for application
-  //! \param theMode a cursor mode
-  void setActiveCursor (const View_CursorMode& theMode);
+private:
+  //! Converts Qt modifier key to Aspect key flag
+  //! \param theModifierId the event modifier
+  static Aspect_VKeyFlags keyFlag (const int theModifierId);
+
+  //! Converts Qt button key to Aspect key mouse
+  //! \param theButtonId the event button
+  static Aspect_VKeyMouse keyMouse (const int theButtonId);
 
 private:
 
   View_Viewer* myViewer; //!< connector to context, V3d viewer and V3d View
+  AIS_ViewController* myController; //!< controller to process view actions
+
   QToolButton* myFitAllAction; //!< widget for fit all, processed double click to perform action automatically
   QMap<View_ViewActionType, QAction*> myViewActions; //!< tool bar view actions
-  QMap<View_CursorMode, QCursor> myCursors; //!< possible cursors for view actions
 
-  View_CurrentAction3d myCurrentMode; //!< an active action mode for viewer
   Standard_Boolean myFirst; //!< flag to Init view by the first resize/paint call
   Standard_Integer myDefaultWidth; //!< default width for the first sizeHint
   Standard_Integer myDefaultHeight; //!< default height for the first sizeHint
   Standard_Boolean myViewIsEnabled; //!< flag if the view and tool bar view actions are enabled/disabled
-  Standard_Integer myXmin; //!< cached X minimal position by mouse press event
-  Standard_Integer myYmin; //!< cached Y minimal position by mouse press event
-  Standard_Integer myXmax; //!< cached X maximum position by mouse press event
-  Standard_Integer myYmax; //!< cached Y maximum position by mouse press event
-  Standard_Integer myDragButtonDownX; //!< cached X button down by drag event
-  Standard_Integer myDragButtonDownY; //!< cached Y button down by drag event
-  Standard_Integer myDragMultiButtonDownX; //!< cached X button down by multi drag event
-  Standard_Integer myDragMultiButtonDownY; //!< cached Y button down by multi drag event
-  Standard_Boolean myIsRectVisible; //!< true if rectangle is visible now
-  QRubberBand* myRectBand; //!< selection rectangle rubber band
 
   Standard_Boolean myHasInitProj; //!< is initial camera position defined
   Standard_Real myInitVx; //!< initial camera position on X
   Standard_Real myInitVy; //!< initial camera position on Y
   Standard_Real myInitVz; //!< initial camera position on Z
-
 };
 
 #endif
index f47cbeb9c2d9722cb183f2ebd27043af18f274b9..beb4cda431b7019627d0a2933bb5456413e55951 100644 (file)
@@ -69,8 +69,7 @@ View_Window::View_Window (QWidget* theParent,
   myActionsToolBar->setOrientation (Qt::Vertical);
 
   myActionsToolBar->addWidget (myView-> GetWidget (View_ViewActionType_FitAllId));
-  for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
-    myActionsToolBar->addAction (myView->ViewAction ((View_ViewActionType)anActionId));
+  myActionsToolBar->addAction (myView->ViewAction (View_ViewActionType_DisplayModeId));
 
   aViewLayout->addWidget (myActionsToolBar, 1, 0);
   aViewLayout->addWidget (myView, 1, 1);
@@ -96,6 +95,33 @@ void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_Int
   ViewToolBar()->SetContext (View_ContextType_External, theContext);
 }
 
+// =======================================================================
+// function : SetPredefinedSize
+// purpose :
+// =======================================================================
+void View_Window::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
+{
+  myView->SetPredefinedSize (theDefaultWidth, theDefaultHeight);
+}
+
+// =======================================================================
+// function : SetInitProj
+// purpose :
+// =======================================================================
+void View_Window::SetInitProj (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
+{
+  myView->SetInitProj (theVx, theVy, theVz);
+}
+
+// =======================================================================
+// function : View
+// purpose :
+// =======================================================================
+Handle(V3d_View) View_Window::View() const
+{
+  return myView->GetViewer()->GetView();
+}
+
 // =======================================================================
 // function : SaveState
 // purpose :
@@ -105,7 +131,7 @@ void View_Window::SaveState (View_Window* theView, QMap<QString, QString>& theIt
 {
   QStringList aCameraDirection;
   Standard_Real aVX, aVY, aVZ;
-  Handle(V3d_View) aView = theView->ViewWidget()->GetViewer()->GetView();
+  Handle(V3d_View) aView = theView->View();
   if (aView.IsNull())
     return;
 
@@ -135,7 +161,7 @@ bool View_Window::RestoreState (View_Window* theView, const QString& theKey, con
       Standard_Real aVY = aValues.at (1).toDouble();
       Standard_Real aVZ = aValues.at (2).toDouble();
 
-      theView->ViewWidget()->SetInitProj (aVX, aVY, aVZ);
+      theView->SetInitProj (aVX, aVY, aVZ);
     }
     return true;
   }
@@ -196,6 +222,12 @@ void View_Window::onToolBarActionClicked (const int theActionId)
       myDisplayer->DisplayDefaultTrihedron (myViewToolBar->IsActionChecked (theActionId), Standard_True);
       break;
     }
+    case View_ToolActionType_ViewCube:
+    {
+      myDisplayer->DisplayViewCube (myViewToolBar->IsActionChecked (theActionId), Standard_True);
+      break;
+    }
+
     case View_ToolActionType_KeepViewId:
     {
       myDisplayer->KeepPresentations (myViewToolBar->IsActionChecked (theActionId));
index b270f816d339ac0c92567dc45b689867d050f1b7..8d85646fbc9f0ebabe4a75aacbb7d5d72d84514c 100644 (file)
@@ -64,6 +64,18 @@ public:
   //! \param theContext an AIS context
   Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
 
+  //! Sets default size that is used in sizeHint when the widget is firstly show
+  Standard_EXPORT void SetPredefinedSize (int theDefaultWidth, int theDefaultHeight);
+
+  //! Sets initial camera position
+  //! \param theVx direction on Ox
+  //! \param theVy direction on Oy
+  //! \param theVz direction on Oz
+  Standard_EXPORT void SetInitProj (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz);
+
+  //! Returns an active view
+  Standard_EXPORT Handle(V3d_View) View() const;
+
   //! Saves state of view window in a container in form: key, value. It saves:
   //! - visibility of columns,
   //! - columns width
diff --git a/tools/View/icons/cursor_rotate.png b/tools/View/icons/cursor_rotate.png
deleted file mode 100644 (file)
index a3cb0c1..0000000
Binary files a/tools/View/icons/cursor_rotate.png and /dev/null differ
diff --git a/tools/View/icons/cursor_zoom.png b/tools/View/icons/cursor_zoom.png
deleted file mode 100644 (file)
index 0020fea..0000000
Binary files a/tools/View/icons/cursor_zoom.png and /dev/null differ
diff --git a/tools/View/icons/view_cube.png b/tools/View/icons/view_cube.png
new file mode 100644 (file)
index 0000000..d373c4b
Binary files /dev/null and b/tools/View/icons/view_cube.png differ
diff --git a/tools/View/icons/view_fitarea.png b/tools/View/icons/view_fitarea.png
deleted file mode 100644 (file)
index f20f5c0..0000000
Binary files a/tools/View/icons/view_fitarea.png and /dev/null differ
diff --git a/tools/View/icons/view_pan.png b/tools/View/icons/view_pan.png
deleted file mode 100644 (file)
index 68343b8..0000000
Binary files a/tools/View/icons/view_pan.png and /dev/null differ
diff --git a/tools/View/icons/view_rotate.png b/tools/View/icons/view_rotate.png
deleted file mode 100644 (file)
index 7e5d013..0000000
Binary files a/tools/View/icons/view_rotate.png and /dev/null differ
diff --git a/tools/View/icons/view_zoom.png b/tools/View/icons/view_zoom.png
deleted file mode 100644 (file)
index 1b50a37..0000000
Binary files a/tools/View/icons/view_zoom.png and /dev/null differ