Salome HOME
Workaround for the problem that the local selection may be initialized without openin...
authormpv <mpv@opencascade.com>
Thu, 1 Jun 2017 10:19:31 +0000 (13:19 +0300)
committermpv <mpv@opencascade.com>
Thu, 1 Jun 2017 10:19:31 +0000 (13:19 +0300)
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx

index 3285f015edb5c3f80f7d8009e1102150c7fe6fbb..0b0ce6a972ce90068697e07fc09bdc8d91d5bb4a 100644 (file)
@@ -120,7 +120,8 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   myIsRelative(true),
   myTopLayerId( 0 ),
   myTrihedronSize(100),
-  myClippingDlg (NULL)
+  myClippingDlg (NULL),
+  myIsUseLocalSelection(false)
 {
   // init CasCade viewers
   myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() );
@@ -454,7 +455,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
     break;
   case  Qt::Key_N:
     if ( isPreselectionEnabled() ) {
-      if ( getAISContext()->HasOpenedContext() )
+      if ( useLocalSelection() )
        getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
     }
     break;
@@ -1355,6 +1356,27 @@ OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
   return new OCCViewer_ViewWindow(0,  this);
 }
 
+/*!
+  Sets using local selection state
+  \param theIsUseLocalSelection - state
+*/
+void OCCViewer_Viewer::setUseLocalSelection(bool theIsUseLocalSelection)
+{
+  myIsUseLocalSelection = theIsUseLocalSelection;
+}
+
+/* 
+ * Returns true if local context is opened or view model local state is set
+ */
+bool OCCViewer_Viewer::useLocalSelection() const
+{
+  if (myIsUseLocalSelection)
+    return true;
+
+  Handle(AIS_InteractiveContext) ic = getAISContext();
+  return !ic.IsNull() && ic->HasOpenedContext();
+}
+
 // obsolete  
 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
 {
index 63db7700b2b4dec9694189bbdc6a2f121da08fd1..329bb05bd9702c905daf3c8f9859078771af65a2 100755 (executable)
@@ -132,6 +132,9 @@ public:
 
   virtual OCCViewer_ViewWindow*   createSubWindow();
 
+  void                            setUseLocalSelection(bool theIsUseLocalSelection);
+  bool                            useLocalSelection() const;
+
 public:
   Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
@@ -279,7 +282,7 @@ protected:
   QString                         myClippingTexture;
   bool                            myTextureModulated;
   double                          myClippingTextureScale;
-
+  bool                            myIsUseLocalSelection;
 };
 
 #ifdef WIN32
index a4bce4220b4e3d0040794c9f2ae7b8446b4b8331..b7d38eab49be69f63253aab47394ac671d7f5760 100644 (file)
@@ -393,7 +393,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
 
         if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) {
           Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-          if ( isPreselectionEnabled() && ic->HasOpenedContext() ) {
+          if ( isPreselectionEnabled() && myModel->useLocalSelection() ) {
             if ( aEvent->delta() > 0 ) {
               ic->HilightNextDetected( myViewPort->getView() );
             } else {