]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
IMP 0019918: Re-open popup for imported shapes.
authorjfa <jfa@opencascade.com>
Thu, 2 Oct 2008 13:54:43 +0000 (13:54 +0000)
committerjfa <jfa@opencascade.com>
Thu, 2 Oct 2008 13:54:43 +0000 (13:54 +0000)
doc/salome/gui/GEOM/images/geomimport_reopen.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/import_export.doc
idl/GEOM_Gen.idl
src/GEOMGUI/GEOM_msg_en.po
src/GEOMGUI/GeometryGUI.cxx
src/GEOM_I/GEOM_ITransformOperations_i.cc
src/GEOM_I/GEOM_ITransformOperations_i.hh
src/TransformationGUI/TransformationGUI.cxx

diff --git a/doc/salome/gui/GEOM/images/geomimport_reopen.png b/doc/salome/gui/GEOM/images/geomimport_reopen.png
new file mode 100644 (file)
index 0000000..9d6745d
Binary files /dev/null and b/doc/salome/gui/GEOM/images/geomimport_reopen.png differ
index 8a5219ebee2af6fc6036ace6d9554b9a864dbd9b..25eb1ae6741d219c2ea9fef59d1018962df38715 100644 (file)
@@ -22,6 +22,14 @@ Select the required file and click \b Open. Your file will be imported in
 the module and its contents (geometrical object) will be displayed in
 the <b>Object Browser</b>.
 
+\note You can re-open ones imported shape from the initial file, if
+the file has been changed on disk. Use for that item
+<b>Reload From Disk</b> from context menu of imported
+shape. Reloaded shape will have the same representation parameters
+like before this operation.
+
+\image html geomimport_reopen.png
+
 \n <em>To export geometrical objects into a BREP, IGES, STEP
 file:</em>
 
index c130973fb3d19d11e472298aea967829c1dcc63d..38f10ca6e7fa21b7816b1d79aec3c1a0a19f7252 100644 (file)
@@ -792,6 +792,13 @@ module GEOM
     GEOM_Object PositionShapeCopy (in GEOM_Object theObject,
                                   in GEOM_Object theStartLCS,
                                   in GEOM_Object theEndLCS);
+
+    /*!
+     *  Recompute the shape from its arguments.
+     *  \param theObject The object to be recomputed.
+     *  \return theObject.
+     */
+    GEOM_Object RecomputeObject (in GEOM_Object theObject);
   };
 
   /*!
index 20cd3b6735431b890373020ea616fa7502d42e76..43c6e908a050427c18577f4c26e0101c1343cb8b 100644 (file)
@@ -2482,6 +2482,12 @@ msgstr "Edit"
 msgid "STB_GROUP_EDIT"
 msgstr "Edit a group"
 
+msgid "MEN_RELOAD_IMPORTED"
+msgstr "Reload From Disk"
+
+msgid "STB_RELOAD_IMPORTED"
+msgstr "Reload imported shape from its original place on disk"
+
 msgid "MEN_BLOCKS"
 msgstr "Blocks"
 
index 2b95749ba74152644c234d8f2a5b1b900f9d3303..d1ffd70c259ceab291cf900787c807de37828fa8 100644 (file)
@@ -71,6 +71,7 @@
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 
+#include "GEOMImpl_Types.hxx"
 
 extern "C" {
   Standard_EXPORT CAM_Module* createModule() {
@@ -488,7 +489,8 @@ void GeometryGUI::OnGUIEvent( int id )
           id == 5025 ||  // MENU TRANSFORMATION - SCALE
           id == 5026 ||  // MENU TRANSFORMATION - OFFSET
           id == 5027 ||  // MENU TRANSFORMATION - MULTI-TRANSLATION
-          id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
+          id == 5028 ||  // MENU TRANSFORMATION - MULTI-ROTATION
+           id == 5029 ) { // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
 #ifndef WNT
        library = getLibrary( "libTransformationGUI.so" );
 #else
@@ -825,6 +827,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 5026, "OFFSET" );
   createGeomAction( 5027, "MUL_TRANSLATION" );
   createGeomAction( 5028, "MUL_ROTATION" );
+  createGeomAction( 5029, "RELOAD_IMPORTED" );
 
   createGeomAction( 503, "PARTITION" );
   createGeomAction( 504, "ARCHIMEDE" );
@@ -1722,13 +1725,23 @@ void GeometryGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QSt
   SalomeApp_Module::contextMenuPopup( client, menu, title );
   SALOME_ListIO lst;
   getApp()->selectionMgr()->selectedObjects( lst );
-  if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
+
+  if (lst.Extent() == 1) {
     Handle(SALOME_InteractiveObject) io = lst.First();
-    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
     _PTR(Study) study = appStudy->studyDS();
-    _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
-    if ( obj )
-      title = QString( obj->GetName().c_str() );
+    _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
+    if (aSObj) {
+      // 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);
+    }
   }
 }
 
index 1dff38932f8e899b28db428d2fe0e7a531f9c0c4..338e901ebcf85bb62462b301923e22b17da6fc1b 100644 (file)
@@ -1252,3 +1252,39 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
 
   return GetObject(anObject);
 }
+
+//=============================================================================
+/*!
+ *  RecomputeObject
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
+                                             (GEOM::GEOM_Object_ptr theObject)
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  if (theObject == NULL) return aGEOMObject._retn();
+
+  //check if the object is a subshape
+  //if (!theObject->IsMainShape()) {
+  //  GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
+  //  return aGEOMObject._retn();
+  //}
+
+  aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
+
+  //Get the object itself
+  CORBA::String_var anEntry = theObject->GetEntry();
+  Handle(GEOM_Object) anObject =
+    GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), anEntry);
+  if (anObject.IsNull()) return aGEOMObject._retn();
+
+  //Perform the recomputation
+  Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
+  if (aLastFunction.IsNull()) return aGEOMObject._retn();
+  GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
+
+  return aGEOMObject._retn();
+}
index 848e5077b7e627e48f7aced283c5b11d0e62a219..ccfdc50e1097cb21df7c001b23c0405e899c1ef7 100644 (file)
@@ -151,6 +151,7 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i :
                                               GEOM::GEOM_Object_ptr thePoint1,
                                               GEOM::GEOM_Object_ptr thePoint2);
 
+  GEOM::GEOM_Object_ptr RecomputeObject (GEOM::GEOM_Object_ptr theObject);
 
   ::GEOMImpl_ITransformOperations* GetOperations() { return (::GEOMImpl_ITransformOperations*)GetImpl(); }
 };
index eb69c9037a216077a410643b9c9ee1d3a2e6476b..1c5cfe1c81bb0a2ca710c0e595a0cdcb7e7e5822 100644 (file)
 //  $Header$
 
 #include "TransformationGUI.h"
-#include "GeometryGUI.h"
 
-#include "SUIT_Session.h"
-#include "SUIT_Desktop.h"
+#include <GEOMBase.h>
+#include "GeometryGUI.h"
 
-#include "SalomeApp_Application.h"
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewModel.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
 
 #include "TransformationGUI_MultiTranslationDlg.h"   // Method MULTI TRANSLATION
 #include "TransformationGUI_MultiRotationDlg.h"      // Method MULTI ROTATION
@@ -100,6 +106,60 @@ bool TransformationGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case 5028: // MULTI ROTATION
     aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent, "" );
     break;
+  case 5029: // RELOAD IMPORTED SHAPE
+    {
+      LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+      SALOME_ListIO aSelList;
+      aSelMgr->selectedObjects(aSelList);
+      if (aSelList.Extent() == 1) {
+        Standard_Boolean testResult = Standard_False;
+        GEOM::GEOM_Object_var aGeomObj =
+          GEOMBase::ConvertIOinGEOMObject(aSelList.First(), 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);
+                    }
+                  }
+                }
+              }
+            }
+            // ? Redisplay subshapes ?
+          }
+        }
+      }
+    }
+    break;
   default:
     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
     break;