]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Call fitAll on display of first object
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 24 Dec 2014 16:08:22 +0000 (19:08 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 24 Dec 2014 16:08:22 +0000 (19:08 +0300)
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 8d113e9d1eec0a1e2efa070116aa0c794d3aa5a1..d892ccf706b3d094dc831519622279f7b8e91d52 100644 (file)
@@ -499,7 +499,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
       myDisplayer->erase(aObj, false);
     else {
       if (myDisplayer->isVisible(aObj))  {
-        myDisplayer->display(aObj, false);  // In order to update presentation
+        displayObject(aObj);  // In order to update presentation
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
           if (aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
@@ -510,7 +510,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
           // Display only current operation results if operation has preview
           if (aOperation->hasObject(aObj)/* && aOperation->hasPreview()*/) {
-            myDisplayer->display(aObj, false);
+            displayObject(aObj);
             // Deactivate object of current operation from selection
             if (myDisplayer->isActive(aObj))
               myDisplayer->deactivate(aObj);
@@ -539,7 +539,7 @@ void XGUI_Workshop::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpd
     } else if (myOperationMgr->hasOperation()) {
       ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
       if (aOperation->hasObject(*aIt)) {  // Display only current operation results
-        myDisplayer->display(*aIt, false);
+        displayObject(*aIt);
         isDisplayed = true;
       }
     }
@@ -600,14 +600,10 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   hidePropertyPanel();
   myPropertyPanel->cleanContent();
 
-  // Activate objects created by current operation
-  //FeaturePtr aFeature = theOperation->feature();
-  //myDisplayer->activate(aFeature);
-  //const std::list<ResultPtr>& aResults = aFeature->results();
-  //std::list<ResultPtr>::const_iterator aIt;
-  //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-  //  myDisplayer->activate(*aIt);
-  //}
+  // Activate objects created by current operation 
+  // in order to clean selection modes
+  QIntList aModes;
+  myDisplayer->activateObjects(aModes);
   myModule->operationStopped(theOperation);
 }
 
@@ -1306,7 +1302,7 @@ void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
   foreach (ObjectPtr aObj, theList)
   {
     if (isVisible) {
-      myDisplayer->display(aObj, false);
+      displayObject(aObj);
     } else {
       myDisplayer->erase(aObj, false);
     }
@@ -1355,7 +1351,7 @@ void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc)
 void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup)
 {
   for (int i = 0; i < theDoc->size(theGroup); i++)
-    myDisplayer->display(theDoc->object(theGroup, i), false);
+    displayObject(theDoc->object(theGroup, i));
 }
 
 //**************************************************************
@@ -1379,3 +1375,16 @@ void XGUI_Workshop::closeDocument()
   aMgr->closeAll();
   objectBrowser()->clearContent();
 }
+
+//**************************************************************
+void XGUI_Workshop::displayObject(ObjectPtr theObj)
+{
+  ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObj);
+  if (aBody.get() != NULL) {
+    int aNb = myDisplayer->objectsCount();
+    myDisplayer->display(theObj, false);
+    if (aNb == 0)
+      viewer()->fitAll();
+  } else 
+    myDisplayer->display(theObj, false);
+}
\ No newline at end of file
index 4db6052fe75adebdd0ddf4239698addb4f2e89d6..d2423262c0d08803c5a1fe2d56e54363706bffda 100644 (file)
@@ -289,6 +289,10 @@ signals:
   // Creates Dock widgets: Object browser and Property panel
   void createDockWidgets();
 
+  /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
+  void displayObject(ObjectPtr theObj);
+
+private:
   AppElements_MainWindow* myMainWindow;
   ModuleBase_IModule* myModule;
   XGUI_ObjectsBrowser* myObjectBrowser;