mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
30
ParaView-5.0.1/Examples/PythonClient/eventdriver.py
Normal file
30
ParaView-5.0.1/Examples/PythonClient/eventdriver.py
Normal file
@ -0,0 +1,30 @@
|
||||
from PyQt4 import QtCore, QtNetwork, QtGui
|
||||
|
||||
def exit():
|
||||
import sys
|
||||
sys.exit(0)
|
||||
|
||||
def sendMessage():
|
||||
global sock, timer
|
||||
|
||||
bl = QtCore.QByteArray()
|
||||
out = QtCore.QDataStream(bl, QtCore.QIODevice.WriteOnly)
|
||||
out.writeDouble(10)
|
||||
|
||||
sock.write(bl)
|
||||
|
||||
timer.start(30)
|
||||
|
||||
|
||||
app = QtGui.QApplication(['Event Driver'])
|
||||
|
||||
sock = QtNetwork.QTcpSocket()
|
||||
sock.connectToHost("localhost", 12345)
|
||||
sock.disconnected.connect(exit)
|
||||
|
||||
timer = QtCore.QTimer()
|
||||
timer.setSingleShot(True)
|
||||
timer.timeout.connect(sendMessage)
|
||||
timer.start(30)
|
||||
|
||||
app.exec_()
|
||||
85
ParaView-5.0.1/Examples/PythonClient/pvpytonapp.py
Normal file
85
ParaView-5.0.1/Examples/PythonClient/pvpytonapp.py
Normal file
@ -0,0 +1,85 @@
|
||||
from PyQt4 import QtCore, QtGui, QtNetwork
|
||||
from paraview import simple as pvsimple
|
||||
from vtk.qt4 import QVTKRenderWindowInteractor
|
||||
|
||||
class ParaViewClient(QtCore.QObject):
|
||||
|
||||
def __init__(self, port, serverHost=None, serverPort=11111):
|
||||
|
||||
self.tcpServer = QtNetwork.QTcpServer()
|
||||
if not self.tcpServer.listen(QtNetwork.QHostAddress.Any, port):
|
||||
print 'Could not list on port %d' % port
|
||||
return
|
||||
self.tcpServer.newConnection.connect(self.acceptClient)
|
||||
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setSingleShot(True)
|
||||
self.timer.timeout.connect(self.render)
|
||||
|
||||
if serverHost:
|
||||
pvsimple.Connect(serverHost, serverPort)
|
||||
self.createPipeline()
|
||||
|
||||
self.setupManipulators()
|
||||
|
||||
self.widget = \
|
||||
QVTKRenderWindowInteractor.QVTKRenderWindowInteractor(\
|
||||
rw=self.renderView.GetRenderWindow(),
|
||||
iren=self.renderView.GetInteractor())
|
||||
self.widget.Initialize()
|
||||
self.widget.Start()
|
||||
self.widget.show()
|
||||
|
||||
pvsimple.Render(self.renderView)
|
||||
|
||||
def setupManipulators(self):
|
||||
cm = self.renderView.GetProperty("CameraManipulators")
|
||||
cm.AddProxy(pvsimple.servermanager.rendering.TrackballRotate().SMProxy)
|
||||
|
||||
zoom = pvsimple.servermanager.rendering.TrackballZoom()
|
||||
zoom.Button = 'Right Button'
|
||||
cm.AddProxy(zoom.SMProxy)
|
||||
|
||||
pan = pvsimple.servermanager.rendering.TrackballPan1()
|
||||
pan.Button = 'Center Button'
|
||||
cm.AddProxy(pan.SMProxy)
|
||||
|
||||
pan2 = pvsimple.servermanager.rendering.TrackballPan1()
|
||||
pan2.Button = 'Left Button'
|
||||
pan2.Shift = True
|
||||
pan2.Control = True
|
||||
cm.AddProxy(pan2.SMProxy)
|
||||
|
||||
self.renderView.UpdateVTKObjects()
|
||||
|
||||
def createPipeline(self):
|
||||
pass
|
||||
|
||||
def acceptClient(self):
|
||||
self.connection = self.tcpServer.nextPendingConnection()
|
||||
self.connection.readyRead.connect(self.readData)
|
||||
self.tcpServer.close()
|
||||
|
||||
def render(self):
|
||||
pvsimple.Render(self.renderView)
|
||||
|
||||
def readData(self):
|
||||
instr = QtCore.QDataStream(self.connection)
|
||||
if self.connection.bytesAvailable >= 8:
|
||||
self.renderView.GetActiveCamera().Azimuth(instr.readDouble())
|
||||
if not self.timer.isActive():
|
||||
self.timer.start(30)
|
||||
if self.connection.bytesAvailable() >= 8:
|
||||
QtCore.QTimer.singleShot(30, self.readData)
|
||||
|
||||
if __name__ == '__main__':
|
||||
class SimpleClient(ParaViewClient):
|
||||
def createPipeline(self):
|
||||
self.renderView = pvsimple.CreateRenderView()
|
||||
|
||||
pvsimple.Sphere()
|
||||
pvsimple.Show()
|
||||
app = QtGui.QApplication(['ParaView Python App'])
|
||||
#s = ParaViewClient(12345, 'localhost')
|
||||
s = SimpleClient(12345)
|
||||
app.exec_()
|
||||
Reference in New Issue
Block a user