]> SALOME platform Git repositories - samples/hello.git/commitdiff
Salome HOME
Merge Python 3 porting.
authorrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 15:43:54 +0000 (18:43 +0300)
committerrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 15:43:54 +0000 (18:43 +0300)
CMakeLists.txt
bin/test_hello.py
doc/input/index.doc
doc/static/footer.html
idl/HELLO_Gen.idl
resources/HELLOCatalog.xml.in
src/HELLO/CMakeLists.txt
src/HELLO/HELLO.cxx
src/HELLO/HELLO.hxx
src/HELLOGUI/HELLOGUI.cxx

index b3bdbbc4132b077c9c918271f86bc58265d963da..5135f53f03415c5ceccffb2a0c1511176f1dd789 100755 (executable)
@@ -35,7 +35,7 @@ SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 # Common CMake macros
 # ===================
index 1fe929939860426c00978c43b369d2e7d8a690d5..94efb8d811a29f41e016b9b80ec706f5844bbdbe 100755 (executable)
@@ -31,27 +31,27 @@ hello = salome.lcc.FindOrLoadComponent('FactoryServer', 'HELLO')
 
 # test HELLO module
 print("Say hello to John: should be OK")
-if hello.hello(salome.myStudy, "John") != HELLO_ORB.OP_OK:
+if hello.hello("John") != HELLO_ORB.OP_OK:
     print("ERROR: wrong operation code is returned")
 else:
     print("OK")
 print("Say hello to John: should answer 'already met'")
-if hello.hello(salome.myStudy, "John") != HELLO_ORB.OP_ERR_ALREADY_MET:
+if hello.hello("John") != HELLO_ORB.OP_ERR_ALREADY_MET:
     print("ERROR: wrong operation code is returned")
 else:
     print("OK")
 print("Say goodbye to Margaret: should answer 'did not meet yet'")
-if hello.goodbye(salome.myStudy, "Margaret") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
+if hello.goodbye("Margaret") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
     print("ERROR: wrong operation code is returned")
 else:
     print("OK")
 print("Say hello to John: should be OK")
-if hello.goodbye(salome.myStudy, "John") != HELLO_ORB.OP_OK:
+if hello.goodbye("John") != HELLO_ORB.OP_OK:
     print("ERROR: wrong operation code is returned")
 else:
     print("OK")
 print("Say hello to John: should answer 'did not meet yet'")
-if hello.goodbye(salome.myStudy, "John") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
+if hello.goodbye("John") != HELLO_ORB.OP_ERR_DID_NOT_MEET:
     print("ERROR: wrong operation code is returned")
 else:
     print("OK")
index 3811601e7b340468be5b3c70d7fca2d7e8131797..a49d21b7914be6020313de985e6bdb235e2ebde4 100644 (file)
@@ -28,7 +28,7 @@ The example module chosen to illustrate the process of SALOME module
 development is very simple. The module contains a single
 component and this component provides several services called \b
 hello and \b goodbye. 
-Each of these functions accepts a reference to the SALOME study and
+Each of these functions accepts
 a character string as the arguments and returns the status of the operation.
 The component also provides a simple GUI.
 
@@ -447,11 +447,11 @@ In particular, \a HELLO class implements \a hello() and \a goodbye() functions
 that are defined in the IDL interface \a HELLO_ORB::HELLO_Gen.
 
 \code
-HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO::hello( const char* name )
 {
 ...
 }
-HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO::goodbye( const char* name )
 {
 ...
 }
@@ -727,9 +727,6 @@ CORBA service.
 \code
 void HELLOGUI::hello()
 {
-  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
-  _PTR(Study) studyDS = study->studyDS();
-
   // request user name
   bool ok;
   QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HELLO_TITLE" ), tr( "QUE_ENTER_NAME" ),
@@ -737,7 +734,7 @@ void HELLOGUI::hello()
 
   if ( ok && !name.trimmed().isEmpty() ) {
     // say hello to SALOME
-    HELLO_ORB::status status = engine()->hello( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+    HELLO_ORB::status status = engine()->hello( (const char*)name.toLatin1() );
 
     // update Object browser
     getApp()->updateObjectBrowser(true);
@@ -802,7 +799,7 @@ void HELLOGUI::goodbye()
 
   if ( !name.trimmed().isEmpty() ) {
     // say goodby to SALOME
-    HELLO_ORB::status status = engine()->goodbye( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+    HELLO_ORB::status status = engine()->goodbye( (const char*)name.toLatin1() );
 
     // update Object browser
     getApp()->updateObjectBrowser(true);
@@ -991,7 +988,7 @@ by means of the \a container variable:
 >> salome.salome_init()
 >> import HELLO_ORB
 >> c = container.load_impl("HELLO", "HELLO")
->> c.hello(salome.myStudy, "Christian")
+>> c.hello("Christian")
 </pre>
 
 The last instruction invokes HELLO module's service \a hello(). Proceed as
@@ -1033,7 +1030,7 @@ is contained in the \c runHELLO.py \a test() function.
     import salome
     salome.salome_init()
     c = test(clt)
-    c.hello(salome.myStudy, "Christian")
+    c.hello("Christian")
 </pre>
 
 The test function creates the LifeCycle object. It then asks for the
index 91afd6cc8ab252063767ab204030ae63dd6ee52b..7cf11feba01a088027958a2e4c7639c64f7adb19 100755 (executable)
@@ -4,7 +4,7 @@
   <ul>
     $navpath
     <li class="footer">
-      Copyright &copy; 2007-2016  CEA/DEN, EDF R&amp;D, OPEN CASCADE<br>
+      Copyright &copy; 2007-2017  CEA/DEN, EDF R&amp;D, OPEN CASCADE<br>
       Copyright &copy; 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS<br>
     </li>
   </ul>
index 1dfbc73f5b6ca099bf91ca053d70638b00a4e835..f009318685fd0d5a0d417748bfe53b5c5a5fddf7 100644 (file)
@@ -56,20 +56,18 @@ module HELLO_ORB
   {
     /*!
       \brief Say hello to \a name
-      \param study SALOME study
       \param name person's name
       \return operation status
      */
-    status hello( in SALOMEDS::Study study, in string name )
+    status hello( in string name )
       raises (SALOME::SALOME_Exception);
 
     /*!
       \brief Say goodbye to \a name
-      \param study SALOME study
       \param name person's name
       \return operation status
      */
-    status goodbye( in SALOMEDS::Study study, in string name )
+    status goodbye( in string name )
       raises (SALOME::SALOME_Exception);
 
     /*!
index a6d104c44ce3c5a754076e24f23a9fad21e656a2..949d7ba0215c0bd37e6349e277b8ffcbd8be8670 100644 (file)
@@ -42,7 +42,6 @@
             <component-author>Vadim SANDLER</component-author>
             <component-version>@SALOMEHELLO_VERSION@</component-version>
             <component-comment>Sample module</component-comment>
-            <component-multistudy>1</component-multistudy>
             <component-impltype>1</component-impltype>
             <component-icone>HELLO.png</component-icone>
             <constraint></constraint>
                         <service-comment>Hello function</service-comment>
                         <service-by-default>1</service-by-default>
                         <inParameter-list>
-                            <inParameter>
-                                <inParameter-name>study</inParameter-name>
-                                <inParameter-type>Study</inParameter-type>
-                                <inParameter-comment>study</inParameter-comment>
-                            </inParameter>
                             <inParameter>
                                 <inParameter-name>name</inParameter-name>
                                 <inParameter-type>string</inParameter-type>
                         <service-comment>Goodbye function</service-comment>
                         <service-by-default>0</service-by-default>
                         <inParameter-list>
-                            <inParameter>
-                                <inParameter-name>study</inParameter-name>
-                                <inParameter-type>Study</inParameter-type>
-                                <inParameter-comment>study</inParameter-comment>
-                            </inParameter>
                             <inParameter>
                                 <inParameter-name>name</inParameter-name>
                                 <inParameter-type>string</inParameter-type>
index cc43c35a3336963e15db645d0116f6723d907022..f005bccc5fa37def8518de231bad26daa5a26cd4 100644 (file)
@@ -37,6 +37,7 @@ SET(_link_LIBRARIES
   ${KERNEL_SalomeIDLKernel}
   ${KERNEL_OpUtil}
   ${KERNEL_SalomeContainer}
+  ${KERNEL_SalomeKernelHelpers}
   SalomeIDLHELLO
 )
 
index 16c3a293aeabb9a1e0058bcc9dc787a640ec5128..85c02c4e8a358caf59e6a74329f9de92e3ed6779 100755 (executable)
@@ -23,6 +23,7 @@
 #include "HELLO.hxx"
 #include "HELLO_version.h"
 
+#include <SALOME_KernelServices.hxx>
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
@@ -73,11 +74,10 @@ HELLO::~HELLO()
 
 /*!
   \brief Say hello to \a name
-  \param study SALOME study
   \param name person's name
   \return operation status
 */
-HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO::hello( const char* name )
 {
   // set exception handler to catch unexpected CORBA exceptions
   Unexpect aCatch(SALOME_SalomeException);
@@ -85,23 +85,24 @@ HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
   // set result status to error initially
   HELLO_ORB::status result = HELLO_ORB::OP_ERR_UNKNOWN;
 
+  SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
   // check if reference to study is valid
-  if ( !CORBA::is_nil( study ) ) {
+  if ( !CORBA::is_nil( aStudy ) ) {
     // get full object path
     std::string fullName = studyName( name );
     // check if the object with the same name is already registered in the study
-    SALOMEDS::SObject_var sobj = study->FindObjectByPath( fullName.c_str() );
+    SALOMEDS::SObject_var sobj = aStudy->FindObjectByPath( fullName.c_str() );
     if ( !CORBA::is_nil( sobj ) ) {
       // person is already registered in the study -> ERROR
       result = HELLO_ORB::OP_ERR_ALREADY_MET;
     }
     else {
       // person is not registered yet -> register
-      SALOMEDS::StudyBuilder_var     studyBuilder   = study->NewBuilder();          // study builder
-      SALOMEDS::UseCaseBuilder_var   useCaseBuilder = study->GetUseCaseBuilder();   // use case builder
+      SALOMEDS::StudyBuilder_var     studyBuilder   = aStudy->NewBuilder();          // study builder
+      SALOMEDS::UseCaseBuilder_var   useCaseBuilder = aStudy->GetUseCaseBuilder();   // use case builder
 
       // find HELLO component; create it if not found
-      SALOMEDS::SComponent_var father = study->FindComponent( "HELLO" );
+      SALOMEDS::SComponent_var father = aStudy->FindComponent( "HELLO" );
       if ( CORBA::is_nil( father ) ) {
        // create component
        father = studyBuilder->NewComponent( "HELLO" ); 
@@ -139,11 +140,10 @@ HELLO_ORB::status HELLO::hello( SALOMEDS::Study_ptr study, const char* name )
 
 /*!
   \brief Say goodbye to \a name
-  \param study SALOME study
   \param name person's name
   \return operation status
 */
-HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
+HELLO_ORB::status HELLO::goodbye( const char* name )
 {
   // set exception handler to catch unexpected CORBA exceptions
   Unexpect aCatch(SALOME_SalomeException);
@@ -151,8 +151,9 @@ HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
   // set result status to error initially
   HELLO_ORB::status result = HELLO_ORB::OP_ERR_UNKNOWN;
 
+  SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
   // check if reference to study is valid
-  if ( !CORBA::is_nil( study ) ) {
+  if ( !CORBA::is_nil( aStudy ) ) {
     // get full object path
     std::string fullName = studyName( name );
 
@@ -161,9 +162,9 @@ HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
 
     // check if the object with the same name is registered in the study
     // find all objects with same name
-    SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();            // study builder
-    SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); // use case builder
-    SALOMEDS::SObject_var sobj = study->FindObjectByPath( fullName.c_str() );
+    SALOMEDS::StudyBuilder_var studyBuilder = aStudy->NewBuilder();            // study builder
+    SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder(); // use case builder
+    SALOMEDS::SObject_var sobj = aStudy->FindObjectByPath( fullName.c_str() );
     while ( !CORBA::is_nil( sobj ) ) {
       std::list<SALOMEDS::SObject_var> toRemove;
       toRemove.push_back( sobj );
@@ -186,7 +187,7 @@ HELLO_ORB::status HELLO::goodbye( SALOMEDS::Study_ptr study, const char* name )
        // set operation status to OK as at least one object is removed
        result = HELLO_ORB::OP_OK;
       }
-      sobj = study->FindObjectByPath( fullName.c_str() );
+      sobj = aStudy->FindObjectByPath( fullName.c_str() );
     }
   }
   
@@ -210,9 +211,9 @@ void HELLO::copyOrMove( const HELLO_ORB::object_list& what,
 {
   if ( CORBA::is_nil( where ) ) return; // bad parent
 
-  SALOMEDS::Study_var study = where->GetStudy();                               // study
-  SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();               // study builder
-  SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();    // use case builder
+  SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
+  SALOMEDS::StudyBuilder_var studyBuilder = aStudy->NewBuilder();               // study builder
+  SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder();    // use case builder
   SALOMEDS::SComponent_var father = where->GetFatherComponent();               // father component
   std::string dataType = father->ComponentDataType();
   if ( dataType != "HELLO" ) return; // not a HELLO component
index 36b2350a2528763d35e165b5052a36e4cfcfaedb..7b61e1423d02a9100137a865be30b235cf1756e2 100644 (file)
@@ -50,8 +50,8 @@ public:
         const char* interfaceName );
   virtual ~HELLO();
 
-  HELLO_ORB::status hello  ( SALOMEDS::Study_ptr study, const char* name );
-  HELLO_ORB::status goodbye( SALOMEDS::Study_ptr study, const char* name );
+  HELLO_ORB::status hello  ( const char* name );
+  HELLO_ORB::status goodbye( const char* name );
   void              copyOrMove( const HELLO_ORB::object_list& what,
                                SALOMEDS::SObject_ptr where,
                                CORBA::Long row, CORBA::Boolean isCopy );
index 8eccb308395a5ef7942f768cafc31bab2bf703be..f40eca03305a3c9a0215ca6984c10a0b236f1d4e 100644 (file)
@@ -93,7 +93,7 @@ HELLO_ORB::HELLO_Gen_var HELLOGUI::engine()
   Perform general module initialization (like creation of actions,
   menus, toolbars, etc).
 
-  \note This function is invoked only once per study, when the module
+  \note This function is invoked only once, when the module
   is first time activated by the user.
   The study associated with the application might not exist
   (created or opened) when this function is invoked, so it is not
@@ -765,9 +765,6 @@ void HELLOGUI::testMe()
 */
 void HELLOGUI::hello()
 {
-  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
-  _PTR(Study) studyDS = study->studyDS();
-
   // request user name
   bool ok;
   QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HELLO_TITLE" ), tr( "QUE_ENTER_NAME" ),
@@ -775,7 +772,7 @@ void HELLOGUI::hello()
 
   if ( ok && !name.trimmed().isEmpty() ) {
     // say hello to SALOME
-    HELLO_ORB::status status = engine()->hello( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+    HELLO_ORB::status status = engine()->hello( (const char*)name.toLatin1() );
 
     // update Object browser
     getApp()->updateObjectBrowser(true);
@@ -843,7 +840,7 @@ void HELLOGUI::goodbye()
 
   if ( !name.trimmed().isEmpty() ) {
     // say goodby to SALOME
-    HELLO_ORB::status status = engine()->goodbye( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
+    HELLO_ORB::status status = engine()->goodbye( (const char*)name.toLatin1() );
 
     // update Object browser
     getApp()->updateObjectBrowser(true);