Salome HOME
Merge remote branch 'origin/V7_dev'
[modules/gui.git] / src / SalomeApp / pluginsdemo / salome_plugins.py
index edb361b5f4f34c9dfdfa8b843eb8736dcb76f378..c532de866ca020f2fb9798945ea40f8f8f08eeaa 100755 (executable)
@@ -1,10 +1,10 @@
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,7 +26,13 @@ DEMO_IS_ACTIVATED = False
 if DEMO_IS_ACTIVATED:
   # Check that GEOM and SMESH modules are present
   try:
-    import geompy, smesh
+    import GEOM
+    from salome.geom import geomBuilder
+    geompy = geomBuilder.New(salome.myStudy)
+    
+    import SMESH, SALOMEDS
+    from salome.smesh import smeshBuilder
+    smesh =  smeshBuilder.New(salome.myStudy)
   except:
     DEMO_IS_ACTIVATED = False
 
@@ -38,11 +44,12 @@ if DEMO_IS_ACTIVATED:
   import salome
 
   def trihedron(context):
-      import geompy
+      import GEOM
+      from salome.geom import geomBuilder
 
       # Intialize the geompy factory with the active study
       activeStudy = context.study
-      geompy.init_geom(activeStudy)
+      geompy = geomBuilder.New(activeStudy)
 
       # Create the objects
       Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
@@ -65,11 +72,12 @@ if DEMO_IS_ACTIVATED:
   # -------------------------------------------------------------------------
   # Example 1 bis: creation of basic objects and automatic display
   def trihedron_withdisplay(context):
-      import geompy
+      import GEOM
+      from salome.geom import geomBuilder
 
       # Intialize the geompy factory with the active study
       activeStudy = context.study
-      geompy.init_geom(activeStudy)
+      geompy = geomBuilder.New(activeStudy)
 
       # Create the objects
       Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
@@ -183,7 +191,7 @@ if DEMO_IS_ACTIVATED:
       global tubebuilder, xalome
       global dialogWithApply, activeStudy
       global previewShapeEntry, deletePreviewShape
-      global DEFAULT_FOLDER_NAME,DEFAULT_SHAPE_NAME 
+      global DEFAULT_FOLDER_NAME,DEFAULT_SHAPE_NAME
 
       dialogWithApply.accept()
 
@@ -194,7 +202,7 @@ if DEMO_IS_ACTIVATED:
       shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
       entry = xalome.addToStudy(activeStudy, shape, DEFAULT_SHAPE_NAME, DEFAULT_FOLDER_NAME)
       xalome.displayShape(entry)
-      
+
   def rejectCallback():
       """Action to be done when click on Cancel"""
       global dialogWithApply, previewShapeEntry, deletePreviewShape
@@ -262,13 +270,15 @@ def runSalomeShellSession(context):
     version = salome_version.getVersion(full=True)
     kernel_appli_dir = os.environ['KERNEL_ROOT_DIR']
     command = ""
-    if os.path.exists("/usr/bin/xterm"):
-      command = 'xterm -T "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir)
-    elif os.path.exists("/usr/bin/gnome-terminal"):
-      command = 'gnome-terminal -t "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir)
+    if os.path.exists("/usr/bin/gnome-terminal"):
+      command = 'gnome-terminal -t "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
+    elif os.path.exists("/usr/bin/konsole"):
+      command = 'PATH="/usr/bin:/sbin:/bin" LD_LIBRARY_PATH="" konsole -e "%s/salome shell" &'%(kernel_appli_dir)
+    elif os.path.exists("/usr/bin/xterm"):
+      command = 'xterm -T "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
     else:
-      print "Neither xterm nor gnome-terminal is installed."
-    
+      print "Neither xterm nor gnome-terminal nor konsole is installed."
+
     if command is not "":
       try:
         subprocess.check_call(command, shell = True)