Salome HOME
bos #32216 [CEA] GUI ergonomic: navigation cube.
authorjfa <jfa@opencascade.com>
Wed, 14 Dec 2022 11:17:22 +0000 (14:17 +0300)
committerjfa <jfa@opencascade.com>
Fri, 24 Feb 2023 14:33:50 +0000 (14:33 +0000)
16 files changed:
doc/salome/gui/images/occviewer_toolbar.png
doc/salome/gui/images/pref_salome_occviewer.png
doc/salome/gui/input/occ_3d_viewer.rst
doc/salome/gui/input/setting_preferences.rst
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/OCCViewer/CMakeLists.txt
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/occ_view_viewcube.png [new file with mode: 0755]
src/SOCC/SOCC_ViewModel.cxx

index d4b293757cf7577d743962d21ed1ee810255250b..54eca424d0e0666f097f0ec0753c7ac23b66b6c2 100644 (file)
Binary files a/doc/salome/gui/images/occviewer_toolbar.png and b/doc/salome/gui/images/occviewer_toolbar.png differ
index ef121f6c74005a6ad60b62b5bc4e506ebb5b20ab..7bc2de5e8b6491fce280f729144bc0e89f7fe3ad 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_occviewer.png and b/doc/salome/gui/images/pref_salome_occviewer.png differ
index 4f21231ccf0d3ee9ab77cfe8462d60a61949ac85..bd63288fc5d02d6a71fd09b416445a140c2c2bef 100644 (file)
@@ -53,6 +53,13 @@ ____
 
 ____
 
+.. image:: ../../../../src/OCCViewer/resources/occ_view_viewcube.png
+       :align: center
+
+**Show/Hide view cube** - shows or hides navigation cube.
+
+____
+
 .. image:: ../../../../src/OCCViewer/resources/occ_view_preselection.png
        :align: center
 
index 306b7a1725d7b51ec6e21bb57dd16d2c9636e2d4..80f3e6318b16f7ab880f35e3c802e54c2a9c1130 100644 (file)
@@ -175,6 +175,16 @@ OCC 3D Viewer Preferences
   - **Color** - allows to change the color of light source.
   - **Dx, Dy, Dz** - sets direction coordinates.
 
+- **Navigation Cube** - allows to manage parameters of navigation cube.
+
+  - **Show navigation cube on start** - if checked, navigation cube will appear in a new occ viewer.
+  - **Animation duration (sec)** - duration of animation of camera rotation.
+  - **Customize navigation cube appearance** - if checked, below defined parameters will be used instead of default ones.
+  - **Cube color** - color of the navigation cube.
+  - **Text color** - color of text on the navigation cube faces.
+  - **Cube size** - size of the navigation cube.
+  - **Show navigation cube axes** - show navigation cube own axes.
+
 .. _vtk_preferences:
 
 VTK 3D Viewer Preferences
index 718efbd13a7afadb5b5605ae9bde1557c5043899..49972104e670860d5d1f733e978ac0b3e0d199b7 100644 (file)
@@ -2855,6 +2855,41 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( "step", 0.1, light_dz );
   // ... "Light source" group <<end>>
 
+  // ... "View cube" group <<start>>
+  int occViewCubeGroup = pref->addPreference( tr( "PREF_GROUP_VIEWCUBE" ), occGroup );
+  pref->setItemProperty( "columns", 2, occViewCubeGroup );
+  // .... -> show view cube on viewer start
+  pref->addPreference( tr( "PREF_VIEWCUBE_SHOW" ), occViewCubeGroup,
+               LightApp_Preferences::Bool, "OCCViewer", "viewcube_show" );
+  // .... -> view cube duration of animation (sec)
+  int viewcube_dur = pref->addPreference( tr( "PREF_VIEWCUBE_DURATION" ), occViewCubeGroup,
+               LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_duration" );
+  pref->setItemProperty( "min", 0.1, viewcube_dur );
+  pref->setItemProperty( "max", 10.0, viewcube_dur );
+  pref->setItemProperty( "step", 0.1, viewcube_dur );
+  // .... -> show view cube axes
+  pref->addPreference( tr( "PREF_VIEWCUBE_AXES" ), occViewCubeGroup,
+               LightApp_Preferences::Bool, "OCCViewer", "viewcube_axes" );
+  // ... "View cube" group <<end>>
+
+  // ... "View cube default (OCCT) attributes" group <<start>>
+  int occViewCubeAttrsGroup = pref->addPreference( tr( "PREF_VIEWCUBE_CUSTOM" ), occGroup,
+               LightApp_Preferences::Auto, "OCCViewer", "viewcube_custom" );
+  pref->setItemProperty( "columns", 2, occViewCubeAttrsGroup );
+  // .... -> box color
+  pref->addPreference( tr( "PREF_VIEWCUBE_COLOR" ), occViewCubeAttrsGroup,
+               LightApp_Preferences::Color, "OCCViewer", "viewcube_color" );
+  // .... -> view cube size
+  int viewcube_size = pref->addPreference( tr( "PREF_VIEWCUBE_SIZE" ), occViewCubeAttrsGroup,
+               LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_size" );
+  pref->setItemProperty( "min",  30.0, viewcube_size );
+  pref->setItemProperty( "max", 100.0, viewcube_size );
+  pref->setItemProperty( "step", 10.0, viewcube_size );
+  // .... -> text color
+  pref->addPreference( tr( "PREF_VIEWCUBE_TEXTCOLOR" ), occViewCubeAttrsGroup,
+               LightApp_Preferences::Color, "OCCViewer", "viewcube_text_color" );
+  // ... "View cube" group <<end>>
+
   // ... -> empty frame (for layout) <<start>>
   int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
   pref->setItemProperty( "margin",  0, occGen );
@@ -3640,6 +3675,24 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
   }
 #endif
 
+#ifndef DISABLE_OCCVIEWER
+  if ( sec == QString( "OCCViewer" ) && param.contains( "viewcube" ) )
+  {
+    QList<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> it( lst );
+    while ( it.hasNext() )
+    {
+      SUIT_ViewModel* vm = it.next()->getViewModel();
+      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+        continue;
+
+      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+      occVM->setViewCubeParamsFromPreferences();
+    }
+  }
+#endif
+
   if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
   {
     int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
index 4643e5859a556f6d254705cba1c02e0bb993fd78..98cf244856823622c197bb17ccbbc525326f6a5f 100644 (file)
     <parameter name="xz_background"   value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
     <parameter name="yz_background"   value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
     <parameter name="xy_background"   value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
+    <parameter name="viewcube_show"       value="true"/>
+    <parameter name="viewcube_axes"       value="false"/>
+    <parameter name="viewcube_custom"     value="false"/>
+    <parameter name="viewcube_color"      value="255, 255, 255"/>
+    <parameter name="viewcube_size"       value="70.0"/>
+    <parameter name="viewcube_text_color" value="0, 0, 0"/>
+    <parameter name="viewcube_duration"   value="0.5"/>
  </section>
  <section name="VTKViewer" >
     <!-- VTK viewer preferences -->
index 1a159cacfc06a7bfc6669c017902469930d823d9..15d27efdf5e0cc57484e6d2a31000bd1350c6af2 100644 (file)
@@ -952,6 +952,40 @@ The changes will be applied on the next application session.</translation>
         <source>PREF_LIGHT_COLOR</source>
         <translation>Color</translation>
     </message>
+
+    <message>
+        <source>PREF_GROUP_VIEWCUBE</source>
+        <translation>Navigation Cube</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_SHOW</source>
+        <translation>Show navigation cube on start</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_AXES</source>
+        <translation>Show navigation cube axes</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_CUSTOM</source>
+        <translation>Customize navigation cube appearance</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_COLOR</source>
+        <translation>Cube color</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_SIZE</source>
+        <translation>Cube size</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_TEXTCOLOR</source>
+        <translation>Text color</translation>
+    </message>
+    <message>
+        <source>PREF_VIEWCUBE_DURATION</source>
+        <translation>Animation duration (sec)</translation>
+    </message>
+
     <message>
         <source>TOT_CLOSE</source>
         <translation>Close</translation>
index 16ac35dc49fbc20bc40fc610abe09f0f9664d048..35d4eaa2d12d6be12e631480137c45b3d880ca6f 100644 (file)
@@ -144,6 +144,7 @@ SET(_other_RESOURCES
   resources/occ_view_style_switch.png
   resources/occ_view_top.png
   resources/occ_view_triedre.png
+  resources/occ_view_viewcube.png
   resources/occ_view_zoom.png
   resources/occ_view_zooming_style_switch.png
   resources/occ_view_ray_tracing.png
index cfa22e46f9529462db39ccced1ea6354c17dd0ae..f5711547926e9ccb7ef73daa14b7d4997299e080 100644 (file)
@@ -171,6 +171,10 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
     }
   }
 
+  /* create view cube */
+  myViewCube  = new AIS_ViewCube();
+  setViewCubeParamsFromPreferences();
+
   // set interaction style to standard
   myInteractionStyle = 0;
 
@@ -483,9 +487,15 @@ void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
 
 void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
 {
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
   setTrihedronShown( true );
+
+  bool showViewCube = true;
+  if ( resMgr ) showViewCube = resMgr->booleanValue( "OCCViewer", "viewcube_show", true );
+  setViewCubeShown( showViewCube );
+
   bool showStaticTrihedron = true;
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
   viewPort->showStaticTrihedron( showStaticTrihedron );
 }
@@ -1288,19 +1298,19 @@ void OCCViewer_Viewer::setColorScaleShown( const bool on )
 }
 
 /*!
-  Changes visibility of trihedron to opposite
+  \return true if trihedron is visible
 */
-void OCCViewer_Viewer::toggleTrihedron()
+bool OCCViewer_Viewer::isTrihedronVisible() const
 {
-  setTrihedronShown( !isTrihedronVisible() );
+  return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
 }
 
 /*!
-  \return true if trihedron is visible
+  \return true if view cube is visible
 */
-bool OCCViewer_Viewer::isTrihedronVisible() const
+bool OCCViewer_Viewer::isViewCubeVisible() const
 {
-  return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
+  return !myViewCube.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myViewCube );
 }
 
 /*!
@@ -1326,6 +1336,70 @@ void OCCViewer_Viewer::setTrihedronShown( const bool on )
   }
 }
 
+/*!
+  Sets visibility state of view cube
+  \param on - new state
+*/
+
+void OCCViewer_Viewer::setViewCubeShown( const bool on )
+{
+  if ( myViewCube.IsNull() )
+    return;
+
+  if ( on ) {
+    myAISContext->Display( myViewCube,
+                           0 /*wireframe*/,
+                           0 /* selection mode */,
+                           Standard_True /* update viewer*/,
+                           AIS_DS_Displayed /* display status */);
+  }
+  else {
+    myAISContext->Erase( myViewCube, Standard_True );
+  }
+}
+
+/*!
+  Set View Cube parameters from preferences
+*/
+void OCCViewer_Viewer::setViewCubeParamsFromPreferences()
+{
+  // Resource manager
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  if (!resMgr || myViewCube.IsNull())
+    return;
+
+  bool isVisibleVC = isVisible(myViewCube);
+
+  if (resMgr->booleanValue("OCCViewer", "viewcube_custom", false)) {
+    // Use custom settings from preferences
+    QColor aColor;
+
+    // Box color
+    aColor = resMgr->colorValue("OCCViewer", "viewcube_color", QColor(255, 255, 255));
+    myViewCube->SetBoxColor(OCCViewer::color(aColor));
+
+    // Size
+    myViewCube->SetSize(resMgr->doubleValue("OCCViewer", "viewcube_size", 70.0));
+
+    // Text color
+    aColor = resMgr->colorValue("OCCViewer", "viewcube_text_color", QColor(0, 0, 0));
+    myViewCube->SetTextColor(OCCViewer::color(aColor));
+  }
+  else {
+    myViewCube->ResetStyles();
+  }
+
+  // Axes
+  myViewCube->SetDrawAxes(resMgr->booleanValue("OCCViewer", "viewcube_axes", false));
+
+  // Animation duration (sec)
+  myViewCube->SetDuration(resMgr->doubleValue("OCCViewer", "viewcube_duration", 0.5));
+
+  // Update the viewer
+  if (isVisibleVC)
+    myAISContext->Redisplay( myViewCube, Standard_True);
+}
+
 /*!
   \return trihedron size
 */
index 16241e70629e4422855f4c9a6ee8a84c50b4d3cc..1527b03aca9a5f8b881ecacc06833be4905b2b0d 100644 (file)
@@ -37,6 +37,7 @@
 #include <V3d_View.hxx>
 #include <AIS_ColorScale.hxx>
 #include <AIS_Trihedron.hxx>
+#include <AIS_ViewCube.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <Graphic3d_SequenceOfHClipPlane.hxx>
@@ -134,7 +135,6 @@ public:
   //! returns true if 3d Trihedron in viewer was created
   bool                            trihedronActivated() const { return !myTrihedron.IsNull(); }
 
-  void                            toggleTrihedron();
   bool                            isTrihedronVisible() const;
   virtual void                    setTrihedronShown( const bool );
 
@@ -149,6 +149,11 @@ public:
 
   void                            updateTrihedron();
   
+  // View Cube methods
+  bool                            viewCubeActivated() const { return !myViewCube.IsNull(); }
+  bool                            isViewCubeVisible() const;
+  virtual void                    setViewCubeShown( const bool );
+  void                            setViewCubeParamsFromPreferences();
 
   virtual OCCViewer_ViewWindow*   createSubWindow();
 
@@ -169,6 +174,7 @@ public:
   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
   Handle(AIS_ColorScale)          getColorScale()  const { return myColorScale; }
   Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
+  Handle(AIS_ViewCube)            getViewCube()    const { return myViewCube; }
 
   int                             getTopLayerId();
 
@@ -275,6 +281,7 @@ protected:
   Handle(V3d_Viewer)              myV3dViewer;
   Handle(AIS_ColorScale)          myColorScale;
   Handle(AIS_Trihedron)           myTrihedron;
+  Handle(AIS_ViewCube)            myViewCube;
   Handle(AIS_InteractiveContext)  myAISContext;
 
   int                             myInteractionStyle;
index 3deb777cde4091dadb6b92d118732d3adf8d3658..94a9f8a08490e3c3f2f028d58c178902d9bbe1bb 100644 (file)
@@ -1404,6 +1404,16 @@ void OCCViewer_ViewWindow::createActions()
     toolMgr()->registerAction( aAction, TrihedronShowId );
   }
 
+  if (myModel->viewCubeActivated()) {
+    aAction = new QtxAction(tr("MNU_SHOW_VIEWCUBE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_VIEWCUBE" ) ),
+                             tr( "MNU_SHOW_VIEWCUBE" ), 0, this);
+    aAction->setCheckable( true );
+    aAction->setChecked( aResMgr->booleanValue( "OCCViewer", "viewcube_show", true ) );
+    aAction->setStatusTip(tr("DSC_SHOW_VIEWCUBE"));
+    connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onViewCubeShow(bool)));
+    toolMgr()->registerAction( aAction, ViewCubeShowId );
+  }
+
   // Scale
   aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
                            tr( "MNU_SCALING" ), 0, this);
@@ -1564,6 +1574,9 @@ void OCCViewer_ViewWindow::createToolBar()
   if( myModel->trihedronActivated() )
     toolMgr()->append( TrihedronShowId, tid );
 
+  if( myModel->viewCubeActivated() )
+    toolMgr()->append( ViewCubeShowId, tid );
+
   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
   aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
   aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
@@ -2100,6 +2113,8 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base
     myModel->setTrihedronShown( anItem.isVisible );
     myModel->setTrihedronSize( anItem.size );
 
+    myModel->setViewCubeShown( anItem.vcIsVisible );
+
     // graduated trihedron
     bool anIsVisible = anItem.gtIsVisible;
     OCCViewer_AxisWidget::AxisData anAxisData[3];
@@ -2167,6 +2182,14 @@ void OCCViewer_ViewWindow::onTrihedronShow(bool show)
   myModel->setTrihedronShown(show);
 }
 
+/*!
+  \brief Called when action "show/hide view cube" is activated.
+*/
+void OCCViewer_ViewWindow::onViewCubeShow(bool show)
+{
+  myModel->setViewCubeShown(show);
+}
+
 /*!
   \brief Toggles preselection (highlighting) on/off
 */
@@ -2523,6 +2546,8 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const
   bool isShown = myModel->isTrihedronVisible();
   double size = myModel->trihedronSize();
 
+  bool isVCShown = myModel->isViewCubeVisible();
+
   QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
 
   viewAspect params;
@@ -2541,9 +2566,14 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const
   params.scaleY   = aScaleY;
   params.scaleZ   = aScaleZ;
   params.name     = aName;
+
+  // trihedron
   params.isVisible= isShown;
   params.size     = size;
 
+  // view cube
+  params.vcIsVisible= isVCShown;
+
   // graduated trihedron
   bool anIsVisible = false;
   OCCViewer_AxisWidget::AxisData anAxisData[3];
index 451aa008af1bd639516da5894558496e2bd0c06d..b77bbfc23eadeb139bc5e666d8e03993f89e7b63 100644 (file)
@@ -60,8 +60,11 @@ public:
   double   scaleY;
   double   scaleZ;
   QString    name;
+  // trihedron
   bool     isVisible;
   double   size;
+  // view cube
+  bool     vcIsVisible;
   // graduated trihedron
   bool    gtIsVisible;
   bool    gtDrawNameX;
@@ -116,6 +119,7 @@ public:
     name(),
     isVisible( false ),
     size( 0.0 ),
+    vcIsVisible( false ),
     gtIsVisible( false ),
     gtDrawNameX( false ), gtDrawNameY( false ), gtDrawNameZ( false ),
     gtNameX(), gtNameY(), gtNameZ(), 
@@ -144,16 +148,17 @@ class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow
 
 public:
   enum ActionId { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
-         ChangeRotationPointId, RotationId,
-         FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
-        ResetId, CloneId, ClippingId, MemId, RestoreId,
-         TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
-        SwitchInteractionStyleId, SwitchZoomingStyleId, 
-        SwitchPreselectionId, SwitchSelectionId,
-        MaximizedId, SynchronizeId, ReturnTo3dViewId,
-        OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId,
-   RectangleSelectionStyleId, PolygonSelectionStyleId, CircleSelectionStyleId,
-        UserId };
+                  ChangeRotationPointId, RotationId,
+                  FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
+                  ResetId, CloneId, ClippingId, MemId, RestoreId,
+                  TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
+                  SwitchInteractionStyleId, SwitchZoomingStyleId, 
+                  SwitchPreselectionId, SwitchSelectionId,
+                  MaximizedId, SynchronizeId, ReturnTo3dViewId,
+                  OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId,
+                  RectangleSelectionStyleId, PolygonSelectionStyleId, CircleSelectionStyleId,
+                  ViewCubeShowId,
+                  UserId };
 
   enum OperationType{ NOVIEWOP, PANVIEW, ZOOMVIEW, ROTATE, 
                       PANGLOBAL, WINDOWFIT, FITALLVIEW, FITSELECTION, RESETVIEW,
@@ -314,6 +319,7 @@ public slots:
   virtual void onMemorizeView();
   virtual void onRestoreView();
   virtual void onTrihedronShow(bool);
+  virtual void onViewCubeShow(bool);
   virtual void setRestoreFlag();
   virtual void onSwitchInteractionStyle( bool on );
   virtual void onSwitchZoomingStyle( bool on );
index 465a7b7a790657a14949302d0b1c3e7c5bd47332..2c8c639e2fb292674e02a58274c814f5d9dbb444 100644 (file)
         <source>ICON_OCCVIEWER_VIEW_TRIHEDRON</source>
         <translation>occ_view_triedre.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_VIEWCUBE</source>
+        <translation>occ_view_viewcube.png</translation>
+    </message>
     <message>
         <source>ICON_OCCVIEWER_SCALING</source>
         <translation>occ_view_scaling.png</translation>
index 2b87be75fa228b1f90a2a92c2c77148806d1e0b2..ee90a41c316d8e3e2ef689ba1855e0ae52fa0d3b 100644 (file)
         <source>DSC_SHOW_TRIHEDRE</source>
         <translation>Show/Hide trihedron in the current view</translation>
     </message>
+    <message>
+        <source>MNU_SHOW_VIEWCUBE</source>
+        <translation>Show/Hide navigation cube</translation>
+    </message>
+    <message>
+        <source>DSC_SHOW_VIEWCUBE</source>
+        <translation>Show/Hide navigation cube in the current view</translation>
+    </message>
     <message>
         <source>MNU_ROTATE_VIEW</source>
         <translation>Rotation</translation>
diff --git a/src/OCCViewer/resources/occ_view_viewcube.png b/src/OCCViewer/resources/occ_view_viewcube.png
new file mode 100755 (executable)
index 0000000..9018a43
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_viewcube.png differ
index 0824b455806bb0078eac94222eb3c192870921c6..5c2c598026b18f27a7beecd743a9c12650bc6f47 100644 (file)
@@ -412,14 +412,17 @@ void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced )
   Handle(AIS_InteractiveContext) ic = getAISContext();
 
   // check if trihedron is displayed
-  Standard_Boolean isTrihedronDisplayed = ic->IsDisplayed( getTrihedron() );
+  Standard_Boolean isTrihedronDisplayed = isTrihedronVisible();
+  Standard_Boolean isViewCubeDisplayed  = isViewCubeVisible();
 
   // get objects to be erased (all currently displayed objects)
   AIS_ListOfInteractive aList;
   ic->DisplayedObjects( aList );
   AIS_ListIteratorOfListOfInteractive anIter( aList );
   for ( ; anIter.More(); anIter.Next() ) {
-    if ( (isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) ) )
+    if ( isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) )
+      continue;
+    if ( isViewCubeDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_ViewCube ) )
       continue;
 
     // erase an object
@@ -515,6 +518,10 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const std::list<i
         for( it = sel_modes.begin(); it != sel_modes.end(); ++it )
           ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)*it ) );
       }
+      else if ( anAIS->DynamicType() == STANDARD_TYPE(AIS_ViewCube) )
+      {
+        ic->Activate( anAIS, 0 );
+      }
       else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) )
       {
         ic->Load( anAIS, -1 );