]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Optimization of Viewer performance up to two times
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 22 Sep 2015 08:12:45 +0000 (11:12 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 22 Sep 2015 08:12:45 +0000 (11:12 +0300)
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/NewGeom/NewGeom_SalomeViewer.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_WorkshopListener.cpp

index 80aabe71f1af66e6b9cbf413b3a1eef2b7707528..75d99535b6478adbd4926051cf2f006e18f5e243 100644 (file)
@@ -159,13 +159,13 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj)
 
 void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
 {
-  blockUpdateViewer(true);
+  //blockUpdateViewer(true);
 
   static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
   Events_Loop::loop()->flush(anEvent);
 
-  blockUpdateViewer(false);
+  //blockUpdateViewer(false);
 }
 
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
index 0494aeec96a58da2715bab9d36ab4e87c6a32d52..636abd69f2a5638603e1932edcad61801aa6da24 100644 (file)
@@ -301,7 +301,8 @@ void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double th
       aView3d->SetTwist( theTwist );
       aView3d->FitAll(0.01, true);
       aView3d->SetZSize(0.);
-      aView3d->DepthFitAll();
+      if (aView3d->Depth() < 0.1)
+        aView3d->DepthFitAll();
     }
   }
 }
@@ -395,7 +396,9 @@ void NewGeom_SalomeViewer::Zfitall()
   OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
   if (aView) {
     OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
-    aWnd->getViewPort()->getView()->ZFitAll();
-    aWnd->getViewPort()->getView()->DepthFitAll();
+    Handle(V3d_View) aView3d = aWnd->getViewPort()->getView();
+    aView3d->ZFitAll();
+    if (aView3d->Depth() < 0.1)
+      aView3d->DepthFitAll();
   }
 }
\ No newline at end of file
index 67f1bcf7a857a65ddb98e52e1014dca3bf21bc97..00ba380b2216d5624896f44d52a18310c95cd36f 100755 (executable)
@@ -323,11 +323,12 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     mySketchMgr->stopNestedSketch(theOperation);
   }
 
-  if (isModified) {
-    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-    XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
-    aDisplayer->updateViewer();
-  }
+  //VSV: Viewer is updated on feature update and redisplay
+  //if (isModified) {
+  //  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+  //  XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+  //  aDisplayer->updateViewer();
+  //}
   mySketchMgr->onShowConstraintsToggle(myHasConstraintShown);
 }
 
index e4df553d7cbe92289ce95475453f4205dde148df..e28724ddc37d179bc79105bfd74af476d9c6ac96 100644 (file)
@@ -181,7 +181,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   // 6. Update sketcher actions
   XGUI_ActionsMgr* anActMgr = workshop()->actionsMgr();
   anActMgr->update();
-  myWorkshop->viewer()->update();
+  //VSV myWorkshop->viewer()->update();
 }
 
 std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
@@ -289,7 +289,7 @@ void PartSet_WidgetSketchLabel::activateCustom()
   connect(workshop()->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
   activateFilters(true);
 
-  aDisp->updateViewer();
+  //VSV aDisp->updateViewer();
 }
 
 void PartSet_WidgetSketchLabel::deactivate()
index 7f5932011a1da79c11a9d3e1e57fdcdf125ab3dd..b41682090e2d05791671aa6a051422a0220738bd 100644 (file)
@@ -363,8 +363,9 @@ void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
   for (; anIt != aLast; anIt++) {
     deactivate(*anIt, false);
   }
-  if (theUpdateViewer)
-    updateViewer();
+  //VSV It seems that there is no necessity to update viewer on deactivation
+  //if (theUpdateViewer)
+  //  updateViewer();
 }
 
 void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
@@ -439,12 +440,15 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrL
   }
 
   AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
+  bool isActivationChanged = false;
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
-    activate(anAISIO, myActiveSelectionModes, false);
+    if (activate(anAISIO, myActiveSelectionModes, false))
+      isActivationChanged = true;
   }
-  if (theUpdateViewer)
-    updateViewer();
+  // VSV It seems that there is no necessity to update viewer on activation
+  //if (theUpdateViewer && isActivationChanged)
+  //  updateViewer();
 }
 
 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
@@ -691,6 +695,7 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
 
 void XGUI_Displayer::updateViewer() const
 {
+  static int ai = 0;
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull() && myEnableUpdateViewer) {
     myWorkshop->viewer()->Zfitall();
@@ -940,14 +945,15 @@ bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
   return ::canBeShaded(anAIS);
 }
 
-void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
+bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
                               const QIntList& theModes,
                               const bool theUpdateViewer) const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext.IsNull() || theIO.IsNull())
-    return;
-
+    return false;
+  
+  bool isActivationChanged = false;
   // deactivate object in all modes, which are not in the list of activation
   // It seems that after the IO deactivation the selected state of the IO's owners
   // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
@@ -976,8 +982,10 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
     // the selection from the previous activation modes should be cleared manually (#26172)
     theIO->ClearSelected();
     aContext->LocalContext()->ClearOutdatedSelection(theIO, true);
-    if (theUpdateViewer)
-      updateViewer();
+    // For performance issues
+    //if (theUpdateViewer)
+    //  updateViewer();
+    isActivationChanged = true;
   }
 
   // loading the interactive object allowing the decomposition
@@ -999,10 +1007,12 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
         //aContext->Load(anAISIO, aMode, true);
         if (!aModesActivatedForIO.contains(aMode)) {
           activateAIS(theIO, aMode, theUpdateViewer);
+          isActivationChanged = true;
         }
       }
     }
   }
+  return isActivationChanged;
 }
 
 bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
index 9e853afb0eaefbc54464c9c7136441c5b361ee0b..c4ac99b1cde9cd6a71df4aa90a9fd55eae9379f7 100644 (file)
@@ -253,7 +253,8 @@ private:
   /// Activates the interactive object in the local context.
   /// \param theIO an interactive object
   /// \param theModes - modes on which it has to be activated (can be empty)
-  void activate(const Handle(AIS_InteractiveObject)& theIO, const QIntList& theModes,
+  /// \return a flag is object activated or not
+  bool activate(const Handle(AIS_InteractiveObject)& theIO, const QIntList& theModes,
                 const bool theUpdateViewer) const;
 
   /// Deactivates the given object (not allow selection)
index b18cff14aec60199dbfc2dd097653f174c83ba1b..293b9c0634ac8ee066bda81ecd6d2f9b32f481c2 100644 (file)
@@ -55,7 +55,8 @@ void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ,
     aView3d->SetTwist( theTwist );
     aView3d->FitAll(0.01, true);
     aView3d->SetZSize(0.);
-    aView3d->DepthFitAll();
+    if (aView3d->Depth() < 0.1)
+      aView3d->DepthFitAll();
   }
 }
 
@@ -331,8 +332,10 @@ void XGUI_ViewerProxy::Zfitall()
     AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
     AppElements_ViewWindow* aView = aViewer->activeViewWindow();
     if (aView) {
-      aView->v3dView()->ZFitAll();
-      aView->v3dView()->DepthFitAll();
+      Handle(V3d_View) aView3d = aView->v3dView();
+      aView3d->ZFitAll();
+      if (aView3d->Depth() < 0.1)
+        aView3d->DepthFitAll();
     }
   }
 }
\ No newline at end of file
index ee65e8a099d9d366cfeb7ca632d9c981906f2086..434b6cdd837fb015de84211a1eb4f12a4920c7fb 100755 (executable)
@@ -357,10 +357,12 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
     }
   }
   if (aRedisplayed) {
+    customizeCurrentObject();
+    //VSV FitAll updated viewer by it self
     if (aFirstVisualizedBody)
       myWorkshop->viewer()->fitAll();
-    customizeCurrentObject();
-    aDisplayer->updateViewer();
+    else 
+      aDisplayer->updateViewer();
   }
 }
 //******************************************************
@@ -415,10 +417,12 @@ void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_O
   //if (myObjectBrowser)
   //  myObjectBrowser->processEvent(theMsg);
   if (aDisplayed) {
+    customizeCurrentObject();
+    //VSV FitAll updated viewer by it self
     if (aFirstVisualizedBody)
       myWorkshop->viewer()->fitAll();
-    customizeCurrentObject();
-    workshop()->displayer()->updateViewer();
+    else
+      workshop()->displayer()->updateViewer();
   }
   //if (aHasPart) { // TODO: Avoid activate last part on loading of document
   //  activateLastPart();