Salome HOME
Fix for the 21110: EDF 1714 GEOM: Low efficiency of the explode compared with "create...
authorrnv <rnv@opencascade.com>
Fri, 18 May 2012 13:27:44 +0000 (13:27 +0000)
committerrnv <rnv@opencascade.com>
Fri, 18 May 2012 13:27:44 +0000 (13:27 +0000)
src/EntityGUI/EntityGUI_SubShapeDlg.cxx
src/GEOMBase/GEOMBase_Helper.cxx
src/GEOMBase/GEOMBase_Helper.h

index 46f13f672476cdce058cfe7e14e82b683cad8d78..5facd0411d670a70ec61535b861213b2c875ca46 100644 (file)
@@ -259,8 +259,10 @@ bool EntityGUI_SubShapeDlg::ClickOnApply()
         return false;  /* aborted */
     }
   }
-
-  bool isOk = onAccept();
+  
+  setIsDisableBrowsing( true );
+  bool isOk = onAccept( true, true, false );
+  setIsDisableBrowsing( false );
 
   // restore selection, corresponding to current selection mode
   SubShapeToggled();
@@ -667,7 +669,10 @@ int EntityGUI_SubShapeDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& th
 //=================================================================================
 void EntityGUI_SubShapeDlg::activateSelection()
 {
-  erasePreview(false);
+  bool isApply = ((QPushButton*)sender() == buttonApply());
+  
+  if(!isApply)
+    erasePreview(false);
 
   // local selection
   if (!myObject->_is_nil() && !isAllSubShapes())
@@ -692,44 +697,46 @@ void EntityGUI_SubShapeDlg::activateSelection()
       }
     }
 
-    int prevDisplayMode = aDisplayer->SetDisplayMode(0);
+    if(!isApply) {
+      int prevDisplayMode = aDisplayer->SetDisplayMode(0);
 
-    SUIT_ViewWindow* aViewWindow = 0;
-    SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
-    if (activeStudy)
-      aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-    if (aViewWindow == 0) return;
+      SUIT_ViewWindow* aViewWindow = 0;
+      SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
+      if (activeStudy)
+        aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+      if (aViewWindow == 0) return;
 
-    SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
-    if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
-        aViewManager->getType() != SVTK_Viewer::Type())
-      return;
+      SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
+      if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
+          aViewManager->getType() != SVTK_Viewer::Type())
+        return;
 
-    SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
-    SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
-    if (aView == 0) return;
+      SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
+      SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
+      if (aView == 0) return;
 
-    //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
+      //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
 
-    TopTools_IndexedMapOfShape aSubShapesMap;
-    TopExp::MapShapes(myShape, aSubShapesMap);
-    CORBA::String_var aMainEntry = myObject->GetStudyEntry();
-    QString anEntryBase = aMainEntry.in();
+      TopTools_IndexedMapOfShape aSubShapesMap;
+      TopExp::MapShapes(myShape, aSubShapesMap);
+      CORBA::String_var aMainEntry = myObject->GetStudyEntry();
+      QString anEntryBase = aMainEntry.in();
 
-    TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
-    for (; anExp.More(); anExp.Next())
-    {
-      TopoDS_Shape aSubShape = anExp.Current();
-      int index = aSubShapesMap.FindIndex(aSubShape);
-      QString anEntry = anEntryBase + QString("_%1").arg(index);
+      TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
+      for (; anExp.More(); anExp.Next())
+      {
+        TopoDS_Shape aSubShape = anExp.Current();
+        int index = aSubShapesMap.FindIndex(aSubShape);
+        QString anEntry = anEntryBase + QString("_%1").arg(index);
 
-      SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
-      if (aPrs) {
-        displayPreview(aPrs, true, false); // append, do not update
+        SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
+        if (aPrs) {
+          displayPreview(aPrs, true, false); // append, do not update
+        }
       }
+      aDisplayer->UpdateViewer();
+      aDisplayer->SetDisplayMode(prevDisplayMode);
     }
-    aDisplayer->UpdateViewer();
-    aDisplayer->SetDisplayMode(prevDisplayMode);
   }
 
   globalSelection(GEOM_ALLSHAPES);
index 006e6a391de5333a96a6e54a6fd52c7dbac6d766..8fea8899a1412835239205a225a7c55a3a3b4c19 100755 (executable)
@@ -89,7 +89,8 @@ GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
 //================================================================
 GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
   : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ),
-    myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true )
+    myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ),
+    myIsDisableBrowsing(false)
 {
 }
 
@@ -812,7 +813,7 @@ bool GEOMBase_Helper::checkViewWindow()
 //            It perfroms user input validation, then it
 //            performs a proper operation and manages transactions, etc.
 //================================================================
-bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
+bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, bool erasePreviewFlag )
 {
   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
   if ( !appStudy ) 
@@ -837,8 +838,9 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
     showError( msg );
     return false;
   }
-
-  erasePreview( false );
+  
+  if(erasePreviewFlag)
+    erasePreview( false );
 
   bool result = false;
 
@@ -899,7 +901,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
           commitCommand();
           updateObjBrowser();
           if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) {
-            if( LightApp_Application* aLightApp = dynamic_cast<LightApp_Application*>( anApp ) )
+            LightApp_Application* aLightApp = dynamic_cast<LightApp_Application*>( anApp );
+            if(aLightApp && !isDisableBrowsing() )
               aLightApp->browseObjects( anEntryList, isApplyAndClose(), isOptimizedBrowsing() );
             anApp->putInfo( QObject::tr("GEOM_PRP_DONE") );
           }
index 1b93bd1ce3a34681fa4258e9c905ab9d64c9813a..5d32fd26813b7932fe442e87fadc14865d586480 100755 (executable)
@@ -117,7 +117,7 @@ protected:
   SalomeApp_Study* getStudy  () const;
   bool checkViewWindow ();
 
-  bool onAccept( const bool publish = true, const bool useTransaction = true );
+  bool onAccept( const bool publish = true, const bool useTransaction = true, bool erasePreviewFlag = true);
   // This method should be called from "OK" button handler.
   // <publish> == true means that objects returned by execute() 
   // should be published in a study.
@@ -190,6 +190,9 @@ protected:
   
   virtual void                setIsWaitCursorEnabled( const bool theFlag ) {myIsWaitCursorEnabled = theFlag;}
   virtual bool                isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;}
+  virtual void                setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; }
+  virtual bool                isDisableBrowsing() const { return myIsDisableBrowsing; }
+  
 
 private:
   QString                     getEntry( GEOM::GEOM_Object_ptr ) const;
@@ -210,6 +213,8 @@ private:
   bool                        myIsApplyAndClose;
   bool                        myIsOptimizedBrowsing;
   bool                        myIsWaitCursorEnabled;
+  bool                        myIsDisableBrowsing;  //This flag enable/disable selection 
+                                                    //in the Object Browser newly created objects.
 
 };