本文整理汇总了Python中vtk.qt4.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor类的典型用法代码示例。如果您正苦于以下问题:Python QVTKRenderWindowInteractor类的具体用法?Python QVTKRenderWindowInteractor怎么用?Python QVTKRenderWindowInteractor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QVTKRenderWindowInteractor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupUi
def setupUi(self, MainWindow, renWinList):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(501, 596)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtGui.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.splitter = QtGui.QSplitter(self.centralwidget)
self.splitter.setOrientation(QtCore.Qt.Vertical)
self.splitter.setObjectName("splitter")
self.qvtkWidget_1 = QVTKRenderWindowInteractor(self.splitter, rw=renWinList[1])
self.qvtkWidget_1.setObjectName("qvtkWidget_1")
self.qvtkWidget_0 = QVTKRenderWindowInteractor(self.splitter, rw=renWinList[0])
self.qvtkWidget_0.setObjectName("qvtkWidget_0")
self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 501, 22))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionExit = QtGui.QAction(MainWindow)
self.actionExit.setObjectName("actionExit")
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例2: Ui_MainWindow
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(10, 230, 121, 41))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/rc/Resource/Science.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.vtkWidget = QVTKRenderWindowInteractor(self.centralwidget)
self.vtkWidget.setGeometry(QtCore.QRect(200, 100, 521, 391))
self.vtkWidget.setObjectName(_fromUtf8("widget"))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 23))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton.setText(_translate("MainWindow", "PushButton", None))
示例3: __init__
def __init__(self, parent):
QVTKRenderWindowInteractor.__init__(self, parent)
self.renderer = vtk.vtkRenderer()
self.GetRenderWindow().AddRenderer(self.renderer)
interactor = vtk.vtkInteractorStyleSwitch()
self._Iren.SetInteractorStyle(interactor)
self.surface = None
# Remainng calls set up axes.
tprop = vtk.vtkTextProperty()
tprop.SetColor(1,1,1)
# Create a faint outline to go with the axes.
self.outline = vtk.vtkOutlineFilter()
# Initially set up with a box as input. This will be changed
# to a plot once the user clicks something.
self.box = vtk.vtkBox()
self.box.SetBounds(0,10,0,10,0,10)
sample = vtk.vtkSampleFunction()
sample.SetImplicitFunction(self.box)
sample.SetSampleDimensions(2,2,2)
sample.SetModelBounds(0,10,0,10,0,5)
sample.ComputeNormalsOff()
self.outline.SetInputConnection(sample.GetOutputPort())
mapOutline = vtk.vtkPolyDataMapper()
mapOutline.SetInputConnection(self.outline.GetOutputPort())
self.outlineActor = vtk.vtkActor()
self.outlineActor.SetMapper(mapOutline)
self.outlineActor.GetProperty().SetColor(1,1,1)
self.outlineActor.GetProperty().SetOpacity(.25)
self.renderer.AddActor(self.outlineActor)
self.axes = vtk.vtkCubeAxesActor2D()
self.axes.SetCamera(self.renderer.GetActiveCamera())
self.axes.SetFlyModeToOuterEdges()
self.axes.SetLabelFormat("%6.4g")
self.axes.SetFontFactor(0.8)
self.axes.SetAxisTitleTextProperty(tprop)
self.axes.SetAxisLabelTextProperty(tprop)
self.axes.SetXLabel("MPI Rank")
self.axes.SetYLabel("Progress")
self.axes.SetZLabel("Effort")
self.axes.SetInput(sample.GetOutput())
self.renderer.AddViewProp(self.axes)
# Keep original camera around in case it gets changed
self.originalCamera = self.renderer.GetActiveCamera()
self.renderer.GetActiveCamera().Pitch(90) # Want effort to be vertical
self.renderer.GetActiveCamera().OrthogonalizeViewUp()
self.renderer.ResetCamera()
self.renderer.GetActiveCamera().Elevation(15) # Be slightly above the data
示例4: Ui_MainWindow
class Ui_MainWindow(object):
def setupUi(self, MainWindow, renWin):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(400, 450)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.vtkWidget = QVTKRenderWindowInteractor(self.centralwidget, rw=renWin)
self.vtkWidget.setObjectName(_fromUtf8("vtkWidget"))
self.verticalLayout.addWidget(self.vtkWidget)
self.horizontalSlider = QtGui.QSlider(self.centralwidget)
self.horizontalSlider.setMinimum(0)
self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider.setObjectName(_fromUtf8("horizontalSlider"))
self.verticalLayout.addWidget(self.horizontalSlider)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.label = QtGui.QLabel(self.centralwidget)
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label.setObjectName(_fromUtf8("label"))
self.horizontalLayout.addWidget(self.label)
self.comboBox = QtGui.QComboBox(self.centralwidget)
self.comboBox.setObjectName(_fromUtf8("comboBox"))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.horizontalLayout.addWidget(self.comboBox)
self.verticalLayout.addLayout(self.horizontalLayout)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1100, 22))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuFile = QtGui.QMenu(self.menubar)
self.menuFile.setObjectName(_fromUtf8("menuFile"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.actionOpen = QtGui.QAction(MainWindow)
self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
self.actionExit = QtGui.QAction(MainWindow)
self.actionExit.setObjectName(_fromUtf8("actionExit"))
self.menuFile.addAction(self.actionOpen)
self.menuFile.addAction(self.actionExit)
self.menubar.addAction(self.menuFile.menuAction())
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Diffusion Embedding", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "Transition style:", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(0, QtGui.QApplication.translate("MainWindow", "Alternating Axes", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(1, QtGui.QApplication.translate("MainWindow", "Diagonal", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(2, QtGui.QApplication.translate("MainWindow", "Simple", None, QtGui.QApplication.UnicodeUTF8))
self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8))
self.actionOpen.setText(QtGui.QApplication.translate("MainWindow", "Open", None, QtGui.QApplication.UnicodeUTF8))
self.actionOpen.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8))
self.actionExit.setText(QtGui.QApplication.translate("MainWindow", "Exit", None, QtGui.QApplication.UnicodeUTF8))
self.actionExit.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+Q", None, QtGui.QApplication.UnicodeUTF8))
示例5: keyPressEvent
def keyPressEvent(self, ev):
if ev.key() == QtCore.Qt.Key_Up:
if self.pick_radius > -1:
self.pick_radius += 1
if ev.key() == QtCore.Qt.Key_Down:
if self.pick_radius > 0:
self.pick_radius -= 1
QVTKRenderWindowInteractor.keyPressEvent(self, ev)
示例6: __init__
def __init__(self, widget, graph, app=None, parent = None):
QVTKRenderWindowInteractor.__init__(self, widget)
self._vta_graph = graph
self._scoresim = None
self._scores = None
self._graph = None
self.actor = None
self.app = app
self.pick_radius = 0
示例7: setupUi
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(800, 600)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.verticalLayout_3 = QtGui.QVBoxLayout()
self.verticalLayout_3.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.label = QtGui.QLabel(Form)
self.label.setObjectName(_fromUtf8("label"))
self.verticalLayout.addWidget(self.label)
self.leftVtk = QVTKRenderWindowInteractor(Form)
self.leftVtk.setObjectName(_fromUtf8("leftVtk"))
self.verticalLayout.addWidget(self.leftVtk)
self.verticalLayout.setStretch(1, 1)
self.horizontalLayout.addLayout(self.verticalLayout)
self.verticalLayout_2 = QtGui.QVBoxLayout()
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.label_2 = QtGui.QLabel(Form)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.verticalLayout_2.addWidget(self.label_2)
self.rightVtk = QVTKRenderWindowInteractor(Form)
self.rightVtk.setObjectName(_fromUtf8("rightVtk"))
self.verticalLayout_2.addWidget(self.rightVtk)
self.verticalLayout_2.setStretch(1, 1)
self.horizontalLayout.addLayout(self.verticalLayout_2)
self.verticalLayout_3.addLayout(self.horizontalLayout)
self.tabWidget = QtGui.QTabWidget(Form)
self.tabWidget.setTabShape(QtGui.QTabWidget.Triangular)
self.tabWidget.setTabsClosable(False)
self.tabWidget.setMovable(False)
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.okienkowanieTab = QtGui.QWidget()
self.okienkowanieTab.setObjectName(_fromUtf8("okienkowanieTab"))
self.tabWidget.addTab(self.okienkowanieTab, _fromUtf8(""))
self.cannyTab = QtGui.QWidget()
self.cannyTab.setObjectName(_fromUtf8("cannyTab"))
self.tabWidget.addTab(self.cannyTab, _fromUtf8(""))
self.verticalLayout_3.addWidget(self.tabWidget)
self.loadImage = QtGui.QPushButton(Form)
self.loadImage.setObjectName(_fromUtf8("loadImage"))
self.verticalLayout_3.addWidget(self.loadImage)
self.verticalLayout_3.setStretch(0, 2)
self.verticalLayout_3.setStretch(1, 1)
self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 1, 1)
self.retranslateUi(Form)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(Form)
示例8: __init__
def __init__(self, parent=None):
super(QCDATWidget, self).__init__(parent=parent)
self.setAcceptDrops(True)
self.mRenWin = vtk.vtkRenderWindow()
self.iren = QVTKRenderWindowInteractor(parent=self, rw=self.mRenWin)
self.canvas = None
self.canvasLayout = QtGui.QVBoxLayout()
self.canvasLayout.addWidget(self.iren)
self.setLayout(self.canvasLayout)
self.becameVisible = partial(self.visiblityChanged.emit, True)
self.becameHidden = partial(self.visiblityChanged.emit, False)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding))
self.visiblityChanged.connect(self.manageCanvas)
self.dragTarget = QtGui.QWidget(self)
self.dragTarget.hide()
self.dragLayout = QtGui.QHBoxLayout()
self.dragTarget.setLayout(self.dragLayout)
self.plots = []
# Creates and hooks up the initial PlotInfo widget
self.addedPlot()
# Just need a callable that returns something
self.toolBarType = lambda x: None
示例9: mouseDoubleClickEvent
def mouseDoubleClickEvent(self, ev):
picker = self.GetRenderWindow().GetInteractor().GetPicker()
# Get the location of the click (in window coordinates)
pos = self.GetRenderWindow().GetInteractor().GetEventPosition()
#picker.SetTolerance(0.0005)
picker.Pick( pos[0], pos[1], 0, self.GetRenderWindow().GetRenderers().GetFirstRenderer() )
#print 'Cell id is: ' + str( picker.GetCellId() )
#print 'Point id is: ' + str( picker.GetPointId() )
actors = picker.GetActors()
screenPos = picker.GetSelectionPoint()
worldPosition = picker.GetPickPosition()
data = picker.GetDataSet()
'''
print pickPos
print screenPos
print actors
print actors.GetLastItem()
'''
#print 'data: ' + str( data )
self.__addVolumeSelectedActor(worldPosition)
av = self.app.active_vol
cellid = picker.GetPointId()
#if self._graph is not None and cellid != -1 :
try:
self._graph.update_figure( cellid, self._scoresim, self._scores, \
self.app._vdata[av].pt_id_ijk, \
self.pat_data_img_data_list, radius=self.pick_radius )
except:
pass
QVTKRenderWindowInteractor.mousePressEvent(self, ev)
self.update()
示例10: Ui_TestbedWindow
class Ui_TestbedWindow(object):
def setupUi(self, TestbedWindow):
TestbedWindow.setObjectName(_fromUtf8("TestbedWindow"))
TestbedWindow.resize(789, 590)
TestbedWindow.setWindowTitle(QtGui.QApplication.translate("TestbedWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.centralwidget = QtGui.QWidget(TestbedWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.renderView = QVTKRenderWindowInteractor(self.centralwidget)
self.renderView.setGeometry(QtCore.QRect(0, 0, 781, 541))
self.renderView.setObjectName(_fromUtf8("renderView"))
TestbedWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(TestbedWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 789, 27))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuData = QtGui.QMenu(self.menubar)
self.menuData.setTitle(QtGui.QApplication.translate("TestbedWindow", "Data", None, QtGui.QApplication.UnicodeUTF8))
self.menuData.setObjectName(_fromUtf8("menuData"))
TestbedWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(TestbedWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
TestbedWindow.setStatusBar(self.statusbar)
self.actionLoad = QtGui.QAction(TestbedWindow)
self.actionLoad.setCheckable(False)
self.actionLoad.setText(QtGui.QApplication.translate("TestbedWindow", "Load...", None, QtGui.QApplication.UnicodeUTF8))
self.actionLoad.setToolTip(QtGui.QApplication.translate("TestbedWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Sans Serif\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-style:italic;\">Load dataset</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.actionLoad.setShortcut(QtGui.QApplication.translate("TestbedWindow", "F2", None, QtGui.QApplication.UnicodeUTF8))
self.actionLoad.setObjectName(_fromUtf8("actionLoad"))
self.menuData.addAction(self.actionLoad)
self.menubar.addAction(self.menuData.menuAction())
self.retranslateUi(TestbedWindow)
QtCore.QMetaObject.connectSlotsByName(TestbedWindow)
def retranslateUi(self, TestbedWindow):
pass
示例11: setupVtkRendering
def setupVtkRendering(self):
self.vtkWidget = QVTKRenderWindowInteractor(self)
self.ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
self.ren.ResetCamera()
self.ren.GetActiveCamera().ParallelProjectionOn()
self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
# layout
vlayout = QVBoxLayout()
vlayout.addWidget(self.vtkWidget)
self.setLayout(vlayout)
示例12: initGUI
def initGUI(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setWindowTitle("Simple Dicom Viewer")
#self.dicomReader = vtk.vtkDICOMImageReader()
#self.dicomReader = vtkgdcm.vtkGDCMImageReader()
self.show()
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.ui.numpyLayout.addWidget(self.toolbar)
self.ui.numpyLayout.addWidget(self.canvas)
self.vtkWidget = QVTKRenderWindowInteractor(self.ui.imageFrame)
self.vtkWidget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
#self.ui.imageLayout.removeWidget(self.ui.dicomSlider)
self.ui.imageLayout.addWidget(self.vtkWidget)
#self.ui.imageLayout.addWidget(self.ui.dicomSlider)
self.disableSlider()
self.viewer= vtk.vtkImageViewer()
#self.viewer.SetupInteractor(MyInteractor())
self.vtkWidget.GetRenderWindow().AddRenderer(self.viewer.GetRenderer())
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
#self.iren.SetRenderWindow(self.vtkWidget.GetRenderWindow())
self.drag = False
self.measuring = False
self.iren.AddObserver("LeftButtonPressEvent", self.leftClick)
self.iren.AddObserver("LeftButtonReleaseEvent", self.leftRelease)
self.iren.AddObserver("EnterEvent", self.mouseEntered)
self.iren.AddObserver("LeaveEvent", self.mouseLeft)
self.iren.AddObserver("MouseMoveEvent", self.mouseMoved)
示例13: setupUi
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(912, 640)
#centralWidget
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.m_label = QtGui.QLabel(self.centralWidget)
self.m_label.setGeometry(QtCore.QRect(750, 70, 91, 17))
self.m_label.setObjectName(_fromUtf8("m_label"))
self.m_pushButton = QtGui.QPushButton(self.centralWidget)
self.m_pushButton.setGeometry(QtCore.QRect(740, 110, 99, 27))
self.m_pushButton.setObjectName(_fromUtf8("m_pushButton"))
#vtkWidget
self.m_widget = QVTKRenderWindowInteractor(self.centralWidget)
self.m_widget.setGeometry(QtCore.QRect(60, 60, 591, 501))
self.m_widget.setObjectName(_fromUtf8("m_widget"))
self.setvtkWidget()
MainWindow.setCentralWidget(self.centralWidget)
#menuBar
self.menuBar = QtGui.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 912, 25))
self.menuBar.setObjectName(_fromUtf8("menuBar"))
MainWindow.setMenuBar(self.menuBar)
#toolBar
self.mainToolBar = QtGui.QToolBar(MainWindow)
self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
#statusBar
self.statusBar = QtGui.QStatusBar(MainWindow)
self.statusBar.setObjectName(_fromUtf8("statusBar"))
MainWindow.setStatusBar(self.statusBar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例14: __init__
def __init__(self, input_file_widget, execution_widget, qt_app, application):
QtGui.QWidget.__init__(self)
self.input_file_widget = input_file_widget
self.qt_app = qt_app
self.application = application
self.plane = vtk.vtkPlane()
self.plane.SetOrigin(-1000, 0, 0)
self.plane.SetNormal(1, 0, 0)
self.exodus_result = None
# The multiple (from adaptivity)
self.exodus_results = []
self.timestep_to_exodus_result = {}
self.file_name = None
self.setupLuts()
# The multiple (from adaptivity) file names we know of
self.file_names = []
self.current_max_timestep = 0
# Whether or not there is new data to read
self.new_stuff_to_read = False
self.timer = QtCore.QTimer()
self.timer.stop()
self.timer.setInterval(100)
self.timer.timeout.connect(self._updateData)
self.execution_widget = execution_widget
self.execution_widget.run_started.connect(self._runStarted)
self.execution_widget.run_stopped.connect(self._runStopped)
self.execution_widget.timestep_begin.connect(self._timestepBegin)
self.execution_widget.timestep_end.connect(self._timestepEnd)
self.main_layout = QtGui.QHBoxLayout()
# self.main_layout.setSpacing(0)
self.right_layout = QtGui.QVBoxLayout()
self.left_layout = QtGui.QVBoxLayout()
self.left_widget = QtGui.QWidget()
self.left_widget.setMaximumWidth(1)
self.left_widget.setLayout(self.left_layout)
self.left_layout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
self.main_layout.addWidget(self.left_widget)
self.right_layout.setStretchFactor(self.left_layout, 0.01)
self.main_layout.addLayout(self.right_layout)
# self.setMinimumWidth(700)
self.setLayout(self.main_layout)
self.vtkwidget = QVTKRenderWindowInteractor(self)
# self.vtkwidget.setMinimumHeight(300)
# Create background, default to the gradient look
self.renderer = vtk.vtkRenderer()
self._showBlackBackgroundChanged(0)
self.renderer.ResetCamera()
self.right_layout.addWidget(self.vtkwidget)
self.right_layout.setStretchFactor(self.vtkwidget, 100)
self.vtkwidget.show()
self.vtkwidget.GetRenderWindow().AddRenderer(self.renderer)
self.vtkwidget.GetRenderWindow().GetInteractor().SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
self.vtkwidget.Initialize()
self.vtkwidget.Start()
self.first = True
self.exodus_result = None
self.has_displacements = False
self.current_displacement_magnitude = 1.0
self.current_scale_x_magnitude = 1.0
self.current_scale_y_magnitude = 1.0
self.current_scale_z_magnitude = 1.0
self.current_variable = None
self.current_component = None
# Holds a mapping of variable name to contour choices so they can be restored when variables are selected
self.contour_choices = {}
# If we are currently restoring contours then don't save the intermediate ones
self.currently_restoring_contours = False
self.setupControls()
self.modifyUI()
示例15: VtkFgBgDisplayWidget
class VtkFgBgDisplayWidget(QFrame):
def __init__(self, parent=None):
super(VtkFgBgDisplayWidget, self).__init__(parent)
self.imVtkBg = None
self.imVtkFg = None
self.matrix4x4 = vtk.vtkMatrix4x4()
self.matrix4x4.DeepCopy((
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
))
self.reslice = vtk.vtkImageReslice()
self.reslice.SetOutputDimensionality(3)
self.reslice.SetResliceAxes(self.matrix4x4)
self.reslice.SetInterpolationModeToLinear()
self.setupVtkRendering()
def setupVtkRendering(self):
self.vtkWidget = QVTKRenderWindowInteractor(self)
self.ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
self.ren.ResetCamera()
self.ren.GetActiveCamera().ParallelProjectionOn()
self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
# layout
vlayout = QVBoxLayout()
vlayout.addWidget(self.vtkWidget)
self.setLayout(vlayout)
def initialize(self):
self.iren.Initialize()
@staticmethod
def convertNpyToVtk(imgNpy):
assert(imgNpy.dtype == np.uint8)
nx, ny, nz = imgNpy.shape
dataImporter = vtk.vtkImageImport()
dataString = imgNpy.tostring(order='F')
dataImporter.CopyImportVoidPointer(dataString, len(dataString))
dataImporter.SetDataScalarTypeToUnsignedChar()
dataImporter.SetNumberOfScalarComponents(1)
dataImporter.SetDataExtent(0, nx-1, 0, ny-1, 0, nz-1)
dataImporter.SetWholeExtent(0, nx-1, 0, ny-1, 0, nz-1)
dataImporter.Update()
return dataImporter.GetOutput()
def setMatrix(self, matrix):
if matrix is not None:
assert(matrix.shape == (4, 4))
self.setMatrixTuple(tuple(matrix.flatten()))
def setMatrixTuple(self, matrix):
if matrix is not None:
assert(len(matrix) == 16)
self.matrix4x4.DeepCopy(matrix)
def render(self):
# self.ren.Render()
self.ren.ResetCamera()
def setDirection(self, direction):
if direction == 0:
# X-Y plane
self.ren.GetActiveCamera().SetPosition(0, 0, -1)
self.ren.GetActiveCamera().SetFocalPoint(0, 0, 0)
self.ren.GetActiveCamera().SetViewUp(-1, 0, 0)
elif direction == 1:
# X-Z plane
self.ren.GetActiveCamera().SetPosition(0, -1, 0)
self.ren.GetActiveCamera().SetFocalPoint(0, 0, 0)
self.ren.GetActiveCamera().SetViewUp(0, 0, -1)
elif direction == 2:
# Y-Z plane
self.ren.GetActiveCamera().SetPosition(-1, 0, 0)
self.ren.GetActiveCamera().SetFocalPoint(0, 0, 0)
self.ren.GetActiveCamera().SetViewUp(0, 0, -1)
def update(self):
self.vtkWidget.update()
super(VtkFgBgDisplayWidget, self).update()