]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
IMP 0019918: Re-open popup for imported shapes. Enable for multiple selection.
authorjfa <jfa@opencascade.com>
Thu, 16 Oct 2008 13:03:43 +0000 (13:03 +0000)
committerjfa <jfa@opencascade.com>
Thu, 16 Oct 2008 13:03:43 +0000 (13:03 +0000)
src/GEOMGUI/GeometryGUI.cxx
src/TransformationGUI/TransformationGUI.cxx

index d1ffd70c259ceab291cf900787c807de37828fa8..208ae29326e691414ed762d5391f13503e76ff49 100644 (file)
@@ -1624,7 +1624,7 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
     return;
 
   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
-  const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
+  //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
 
   // disable non-OCC viewframe menu commands
 //  action( 404 )->setEnabled( ViewOCC ); // SKETCHER
@@ -1723,26 +1723,37 @@ LightApp_Selection* GeometryGUI::createSelection() const
 void GeometryGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
 {
   SalomeApp_Module::contextMenuPopup( client, menu, title );
+
   SALOME_ListIO lst;
   getApp()->selectionMgr()->selectedObjects( lst );
+  if (lst.Extent() < 1)
+    return;
+
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+  _PTR(Study) study = appStudy->studyDS();
 
-  if (lst.Extent() == 1) {
-    Handle(SALOME_InteractiveObject) io = lst.First();
-    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
-    _PTR(Study) study = appStudy->studyDS();
+  bool isImported = true;
+  SALOME_ListIteratorOfListIO anIt (lst);
+  for (; anIt.More() && isImported; anIt.Next()) {
+    Handle(SALOME_InteractiveObject) io = anIt.Value();
     _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
     if (aSObj) {
-      // Set context menu title
-      if (client == "OCCViewer" || client == "VTKViewer")
-        title = QString(aSObj->GetName().c_str());
+      if (lst.Extent() == 1) {
+        // Set context menu title
+        if (client == "OCCViewer" || client == "VTKViewer")
+          title = QString(aSObj->GetName().c_str());
+      }
 
-      // Reload imported shape
       CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
       GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
-      if (!CORBA::is_nil(aGeomObj) && aGeomObj->GetType() == GEOM_IMPORT)
-        action(5029)->addTo(menu);
+      if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
+        isImported = false;
     }
   }
+
+  if (isImported) {
+    action(5029)->addTo(menu); // Reload imported shape
+  }
 }
 
 void GeometryGUI::createPreferences()
index 1c5cfe1c81bb0a2ca710c0e595a0cdcb7e7e5822..dab45510ad3c153effcb236e64d5962f32e63112 100644 (file)
@@ -39,6 +39,7 @@
 #include <LightApp_SelectionMgr.h>
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
+#include <SALOME_ListIteratorOfListIO.hxx>
 
 #include "TransformationGUI_MultiTranslationDlg.h"   // Method MULTI TRANSLATION
 #include "TransformationGUI_MultiRotationDlg.h"      // Method MULTI ROTATION
@@ -108,56 +109,45 @@ bool TransformationGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
     break;
   case 5029: // RELOAD IMPORTED SHAPE
     {
+      SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+
+      GEOM::GEOM_ITransformOperations_var anOp =
+        GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
+      if (anOp->_is_nil()) return false;
+
+      GEOM_Displayer aDisp (anAppStudy);
+      SUIT_Desktop* desk = app->desktop();
+      QPtrList<SUIT_ViewWindow> wnds = desk->windows();
+
       LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
       SALOME_ListIO aSelList;
       aSelMgr->selectedObjects(aSelList);
-      if (aSelList.Extent() == 1) {
+
+      SALOME_ListIteratorOfListIO aSelIt (aSelList);
+      for (; aSelIt.More(); aSelIt.Next()) {
+        Handle(SALOME_InteractiveObject) io = aSelIt.Value();
         Standard_Boolean testResult = Standard_False;
-        GEOM::GEOM_Object_var aGeomObj =
-          GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
+        GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject(io, testResult);
         if (testResult) {
-          SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
-          GEOM::GEOM_ITransformOperations_var anOp =
-            GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
-          if (!anOp->_is_nil()) {
-            anOp->RecomputeObject(aGeomObj);
-            GEOM_Displayer aDisp (anAppStudy);
-            //aDisp.Redisplay(aSelList.First());
-            //aDisp.Display(aSelList.First());
-            Handle(SALOME_InteractiveObject) theIO = aSelList.First();
-            SUIT_Desktop* desk = app->desktop();
-            QPtrList<SUIT_ViewWindow> wnds = desk->windows();
-            SUIT_ViewWindow* wnd;
-            for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
-            {
-              SUIT_ViewManager* vman = wnd->getViewManager();
-              if ( vman )
-              {
-                SUIT_ViewModel* vmodel = vman->getViewModel();
-                if ( vmodel )
-                {
-                  SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
-                  if ( view )
-                  {
-                    //if (view->isVisible(theIO) || view == GetActiveView())
-                    if (view->isVisible(theIO))
-                    {
-                      //SALOME_Prs* prs = view->CreatePrs( theIO->getEntry() );
-                      //if ( prs ) {
-                      //  prs->Update(&aDisp);
-                      //  view->Repaint();
-                      //}
-                      aDisp.Erase(theIO, false, false, view);
-                      aDisp.Display(theIO, true, view);
-                    }
+          anOp->RecomputeObject(aGeomObj);
+
+          SUIT_ViewWindow* wnd;
+          for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
+          {
+            if (SUIT_ViewManager* vman = wnd->getViewManager()) {
+              if (SUIT_ViewModel* vmodel = vman->getViewModel()) {
+                if (SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel)) {
+                  if (view->isVisible(io)) {
+                    aDisp.Erase(io, false, false, view);
+                    aDisp.Display(io, true, view);
                   }
+                  // ? Redisplay subshapes ?
                 }
               }
             }
-            // ? Redisplay subshapes ?
           }
         }
-      }
+      } // for (; aSelIt.More(); aSelIt.Next())
     }
     break;
   default: