]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
add method NameChanged to update title name
authormpa <mpa@opencascade.com>
Thu, 24 Nov 2016 13:43:42 +0000 (16:43 +0300)
committermpa <mpa@opencascade.com>
Thu, 24 Nov 2016 13:43:42 +0000 (16:43 +0300)
doc/salome/kernel_salome.dox
src/Basics/Basics_DirUtils.cxx
src/KERNEL_PY/Help.py
src/KERNEL_PY/PyInterp.py
src/KERNEL_PY/__init__.py
src/KERNEL_PY/salome_study.py
src/SALOMEDS/SALOMEDS_Client.cxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx

index 1ca3018026608f5fc7decbd36c91a99f3c8e9ad3..4fea5880dccce25f27dad6f660d35ed332d90987 100644 (file)
@@ -179,7 +179,7 @@ window. The output for each object includes its entry ID, name, IOR
 (if there is one) and referenced object ID (for references). I.e.
 this is the same data the user can see in the Object Browser columns.
 \code
-salome.DumpStudy(salome.myStudy)
+salome.DumpStudy()
 \endcode
 
 \li \b IDToSObject() Get SALOMEDS object by its entry ID.
index 38020be9a3dc0e70591de81b48700e16c4860c44..a6ee8c0e378b61b4537369bce9251d5987fd4b25 100644 (file)
@@ -57,7 +57,7 @@ namespace Kernel_Utils
 
     pos = tmp_str.rfind( _extension_ );
     if( !with_extension && pos >= 0 )
-      tmp_str = pos < (int)file_path.size()-1 ? file_path.substr( 0, pos ) : "";
+      tmp_str = pos < (int)tmp_str.size()-1 ? tmp_str.substr( 0, pos ) : "";
 
     return tmp_str;
   }
index 7cebb8f6568417668dc4061cf13e59728ab73e01..4fd4a5e56a0cf224ff1cb668f682e6688ba5172d 100755 (executable)
@@ -75,7 +75,7 @@ variables:
                            methods : defined in SALOMEDS.idl
                                                          
 methods:
-  salome.DumpStudy(study) : Dump a study, given the ior
+  salome.DumpStudy() : Dump a study, given the ior
 ---
 '''
         print doc_salome
index 8e4595e65af18cf46bae799182d3ae78b9ff1cc7..3c0787e4ca410374f49d1a069f1d483aec7a9f7a 100755 (executable)
@@ -35,9 +35,10 @@ from SALOME_NamingServicePy import *
 
     #--------------------------------------------------------------------------
 
-def DumpComponent(Study, SO, offset):
-    it = Study.NewChildIterator(SO)
-    Builder = Study.NewBuilder()
+def DumpComponent(SO, offset):
+    global myStudy
+    it = myStudy.NewChildIterator(SO)
+    Builder = myStudy.NewBuilder()
     while it.More():
         CSO = it.Value()
         it.Next()
@@ -60,18 +61,19 @@ def DumpComponent(Study, SO, offset):
                 a = a + "  "
                 ofs = ofs +1
             print a + ">" + RefSO.GetID()
-        DumpComponent(Study, CSO, offset+2)
+        DumpComponent(CSO, offset+2)
 
     #--------------------------------------------------------------------------
 
-def DumpStudy(Study):
-    itcomp = Study.NewComponentIterator()
+def DumpStudy():
+    global myStudy
+    itcomp = myStudy.NewComponentIterator()
     while itcomp.More():
         SC = itcomp.Value()
         itcomp.Next()
         name = SC.ComponentDataType()
         print "-> ComponentDataType is " + name
-        DumpComponent(Study, SC, 1)
+        DumpComponent(SC, 1)
         
 
     #--------------------------------------------------------------------------
index 31adec9dd9484877f43c0e6fd0e454e5217c53fc..e5d7c008ed80714f152e89d86d6ea02449aed500 100755 (executable)
@@ -167,7 +167,7 @@ myStudy, myStudyName=None,None
 salome_initial=1
 def salome_init(embedded=0):
     """
-    Performs only once SALOME general purpose intialisation for scripts.
+    Performs only once SALOME general purpose initialization for scripts.
     Provides:
     orb             reference to CORBA
     lcc             a LifeCycleCorba instance
@@ -210,12 +210,11 @@ def salome_close():
     try:
         # study can be clear either from GUI or directly with salome.myStudy.Clear()
         myStudy.Clear()
+        myStudy.Init()
     except:
         pass
     salome_initial=1
     salome_iapp_close()
-    salome_study_close()
-    myStudy, myStudyName=None,None
     pass
 
 
index bec5c191b83ca8648fd49347441017a8135c20af..f249057f9397132f08aa98b55b976bbf89fa52a5 100755 (executable)
@@ -36,8 +36,9 @@ myStudyName = None
 
 #--------------------------------------------------------------------------
 
-def DumpComponent(Study, SO, Builder,offset):
-  it = Study.NewChildIterator(SO)
+def DumpComponent(SO, Builder,offset):
+  global myStudy
+  it = myStudy.NewChildIterator(SO)
   while it.More():
     CSO = it.Value()
     a=offset*"--" + ">" + CSO.GetID()
@@ -56,17 +57,18 @@ def DumpComponent(Study, SO, Builder,offset):
 
 #--------------------------------------------------------------------------
 
-def DumpStudy(Study):
+def DumpStudy():
     """
     Dump a study, given the ior
     """
-    itcomp = Study.NewComponentIterator()
-    Builder = Study.NewBuilder()
+    global myStudy
+    itcomp = myStudy.NewComponentIterator()
+    Builder = myStudy.NewBuilder()
     while itcomp.More():
       SC = itcomp.Value()
       name = SC.ComponentDataType()
       print "-> ComponentDataType is " + name
-      DumpComponent(Study, SC,Builder, 1)
+      DumpComponent(SC,Builder, 1)
       itcomp.Next()
 
 #--------------------------------------------------------------------------
@@ -84,6 +86,7 @@ def IDToObject(id):
     return myObj
 
 def ObjectToSObject(obj):
+    global myStudy
     mySO = None
     if obj is not None:
         ior =  orb.object_to_string(obj)
@@ -115,6 +118,7 @@ def generateName(prefix = None):
     #--------------------------------------------------------------------------
 
 def PersistentPresentation(theSO, theWithID):
+    global myStudy
     # put the sobject's content (with subchildren) to the string
     aResult = ""
     attrs = theSO.GetAllAttributes()
@@ -268,18 +272,9 @@ def FindFileInDataDir(filename):
 
 def openStudy(theStudyPath):
     print "openStudy"
-    salome.myStudy.Open(theStudyPath)
-    theStudyName = salome.myStudy._get_Name()
-    print theStudyPath, theStudyName
-    return theStudyName
-
-    #--------------------------------------------------------------------------
-def clearStudy():
     global myStudy
-    print "clearStudy"
-    myStudy.Clear()
-    myStudy = None
-    pass
+    myStudy.Open(theStudyPath)
+    print theStudyPath, myStudy._get_Name()
 
     #--------------------------------------------------------------------------
 
@@ -305,12 +300,10 @@ def salome_study_init(theStudyPath=None):
         if verbose(): print "Study found"
         pass
 
-    # get study name
+    import types
+    if theStudyPath and type(theStudyPath) == types.StringType:
+        openStudy(theStudyPath)
+
     myStudyName = myStudy._get_Name()
 
     return myStudy, myStudyName
-
-def salome_study_close():
-    global myStudy, myStudyName
-    myStudy, myStudyName = None, None
-    pass
index 006d0b7f7974202f9712e06d33103d96692b2dfe..fd365b9109e65a4748a81fa88bb681e0fc90d017 100644 (file)
@@ -269,7 +269,7 @@ int main(int argc, char** argv)
 
     SALOME_NamingService * salomens = new SALOME_NamingService(orb);
 
-    MESSAGE("Create New Study ");
+    MESSAGE("Find Study ");
     CORBA::Object_ptr obj2 = salomens->Resolve("Study");
     SALOMEDS::Study_var myStudy = SALOMEDS::Study::_narrow(obj2);
 
index 8091ece62cdff95838cda0e743fb24c5ae055783..3f0e83c50e9c7bac00dccc0622fbf47007bcf4b5 100644 (file)
@@ -269,6 +269,9 @@ void SALOMEDS_Study_i::Init()
   _impl->setNotifier(_notifier);
   _impl->setGenObjRegister( _genObjRegister );
 
+  // update desktop title with new study name
+  NameChanged();
+
   // Notify GUI that study was created
   SALOME_NamingService *aNamingService = KERNEL::getNamingService();
   CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
@@ -371,6 +374,9 @@ bool SALOMEDS_Study_i::Open(const char* aUrl)
 
   bool res = _impl->Open(std::string(aUrl));
 
+  // update desktop title with new study name
+  NameChanged();
+
   if ( !res )
     THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
   return res;
@@ -1064,6 +1070,9 @@ void SALOMEDS_Study_i::URL(const char* url)
   SALOMEDS::Locker lock; 
   // URL is specified as IDL attribute: user exception cannot be raised
   _impl->URL(std::string((char*)url));
+
+  // update desktop title with new study name
+  NameChanged();
 }
 
 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry) 
@@ -1772,3 +1781,19 @@ CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::L
   isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
   return reinterpret_cast<CORBA::LongLong>(_impl);
 }
+
+void SALOMEDS_Study_i::NameChanged()
+{
+  // Notify GUI that the name of study was changed
+  SALOME_NamingService *aNamingService = KERNEL::getNamingService();
+  CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
+  SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
+  if ( !CORBA::is_nil(aSession) ) {
+    std::stringstream ss;
+    ss << "studyNameChanged";
+    std::string str = ss.str();
+    SALOMEDS::unlock();
+    aSession->emitMessageOneWay(str.c_str());
+    SALOMEDS::lock();
+  }
+}
index 20b3bd6d2cb1f6f46dca2daf53f32fd961bfccf0..cfe22e2653e61cde30ccd61d892a748bea5b99a0 100644 (file)
@@ -50,6 +50,8 @@
 class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study
 {
 private:
+
+  void                            NameChanged();
   CORBA::ORB_var                 _orb;
   SALOMEDSImpl_Study*            _impl;  
   SALOMEDS_StudyBuilder_i*       _builder;