1 # Copyright (C) 2010-2014 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author: Adrien Bruneton (CEA)
21 r""" This module is a direct forward to the initial 'simple' module of ParaView.
22 On top of that it also establishes a connection to a valid PVServer whose address
23 is provided by the PARAVIS engine.
26 from paraview.simple import *
27 import paraview.servermanager # local import - see test on 'fromGUI' below
28 import paravis ## Triggers the "FindOrLoadCompo(PARAVIS)"
31 print "[PARAVIS] %s" % msg
33 def SalomeConnectToPVServer():
34 __my_log("Connecting to PVServer ...")
37 server_url = paravis.myParavisEngine.FindOrStartPVServer(0)
38 # Extract host and port from URL:
39 a = server_url.split(':')
41 host, port = b[-1], int(a[-1])
43 except Exception as e:
44 __my_log("*******************************************")
45 __my_log("** Could not connect to a running PVServer!")
46 __my_log("*******************************************")
48 __my_log("Connected to %s!" % server_url)
50 # Automatically connect to the right PVServer when not inside SALOME GUI:
51 if not paraview.fromGUI:
52 SalomeConnectToPVServer()