Salome HOME
Allow explicitly enable / disable draw rect (rubber band) mode in OCC viewer NewGEOM_1.4.0_a
authorvsr <vsr@opencascade.com>
Fri, 9 Oct 2015 12:15:18 +0000 (15:15 +0300)
committervsr <vsr@opencascade.com>
Mon, 12 Oct 2015 10:05:39 +0000 (13:05 +0300)
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h

index 70e253b63a624abf80814b44a63079ea943c6da7..e4c3ec9047d76d5e10570266e01cc3908f7b5b6e 100644 (file)
@@ -708,3 +708,12 @@ void OCCViewer_ViewFrame::enablePreselection( bool isEnabled )
     aView->enablePreselection(isEnabled); 
   }
 }
+
+bool OCCViewer_ViewFrame::enableDrawMode( bool on )
+{
+  bool prev = false;
+  foreach (OCCViewer_ViewWindow* aView, myViews) {
+    prev = prev || aView->enableDrawMode( on ); 
+  }
+  return prev;
+}
index 8c04813980faf52b080c59ac2d4bfa7495dd8984..e7bb37726c5303a5a0261baec16c0900620c490a 100644 (file)
@@ -107,6 +107,8 @@ public:
   virtual bool isPreselectionEnabled() const { return getView(MAIN_VIEW)->isPreselectionEnabled(); }
   virtual void enablePreselection( bool );
 
+  virtual bool enableDrawMode( bool );
+
   virtual void setViewManager( SUIT_ViewManager* );
 
   virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); }
index 1b2f96cbed45bdae5f0f0f4747e574d926857581..282cc5721933e52ccead81b2d65fc2e56e55b4e9 100755 (executable)
@@ -1544,3 +1544,22 @@ void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
     myClippingDlg = theDlg;
   }
 }
+
+
+bool OCCViewer_Viewer::enableDrawMode( bool on )
+{
+  //!! To be done for view windows
+  if ( !myViewManager )
+    return false;
+
+  bool prev = false;
+  QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+    if ( win ) {
+      prev = prev || win->enableDrawMode( on ); 
+    }
+  }
+  return prev;
+}
index 0115104bfdb1a2666d6ca7aefe215b418ac82952..a8eba563e43e1f423cc71ca321830cfd53a96c2c 100755 (executable)
@@ -179,6 +179,8 @@ public:
   void                            enableMultiselection(bool isEnable);
   bool                            isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
 
+  bool                            enableDrawMode( bool on );
+
   void                            setClippingColor( const QColor& );
   QColor                          clippingColor() const;
 
index fb65e7d33264fceaa833cc575f8fbb327bc5534f..a0e96792bba525452df09cffa38363629dd3dc4c 100755 (executable)
@@ -243,6 +243,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
   myModel = theModel;
   myRestoreFlag = 0;
   myEnableDrawMode = false;
+  myDrawRectEnabled = true;
   myDrawRect=false;
   updateEnabledDrawMode();
   myScalingDlg = 0;
@@ -420,13 +421,25 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
   return SUIT_ViewWindow::eventFilter(watched, e);
 }
 
+/*!
+  \brief Enable / disable draw rect (rubber band) mode
+*/
+bool OCCViewer_ViewWindow::enableDrawMode( bool on )
+{
+  bool prev = myDrawRectEnabled;
+  myDrawRectEnabled = on;
+  updateEnabledDrawMode();
+  return prev;
+}
+
 /*!
   \brief Update state of enable draw mode state.
 */
 void OCCViewer_ViewWindow::updateEnabledDrawMode()
 {
+  myEnableDrawMode = myDrawRectEnabled;
   if ( myModel )
-    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
+    myEnableDrawMode = myEnableDrawMode && myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
 }
 
 /*!
index dff660d7233df0ba2aa3ab9bc365aa9186917b33..51f6b92b06e636043d5abfdaf4adbe66a7dd494b 100755 (executable)
@@ -186,6 +186,8 @@ public:
   
   virtual void initLayout();
 
+  virtual bool enableDrawMode( bool );
+
   virtual void updateEnabledDrawMode();
 
   virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
@@ -396,6 +398,7 @@ protected:
   bool                  myCursorIsHand;                 
   bool                  myDrawRect;           // set when a rect is used for selection or magnify 
   bool                  myEnableDrawMode;
+  bool                  myDrawRectEnabled;
   bool                  myPaintersRedrawing;  // set to draw with external painters  
   bool                  IsSketcherStyle;
   bool                  myIsKeyFree;