def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) self.on = 0 self.renew = 1 self.distanceWidget = vtk.vtkDistanceWidget() self.obsTag = self.distanceWidget.AddObserver("EndInteractionEvent", self.onPlacePoint) self.representation = vtkbxd.vtkDistanceRepresentationScaled2D() self.representation.SetScaleX(1.0) self.representation.SetScaleZ(1.0) self.distanceWidget.SetRepresentation(self.representation) self.renderer = self.parent.getRenderer() iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.distanceWidget.SetInteractor(iactor) self.picker = vtk.vtkCellPicker() self.currentPlane = None #self.picker.SetTolerance(0.05) #self.updateRendering() self.filterDesc = "Measure distance in 3D view"
def __init__(self, parent, visualizer, **kws): """ Initialization """ VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = {"TrackFile": "Tracks file", #"AllTracks": "Show all tracks", \ "MinLength": "Min. length of track (# of timepoints)", "SphereRadius": "Sphere radius", "TubeRadius": "Tube radius", "SameStartingPoint": "Visualize tracks starting from same point"} self.showTracks = [] self.lineMapper = vtk.vtkPolyDataMapper() self.sphereMapper = vtk.vtkPolyDataMapper() self.firstMapper = vtk.vtkPolyDataMapper() self.lastMapper = vtk.vtkPolyDataMapper() self.currentMapper = vtk.vtkPolyDataMapper() self.actors = [] self.renderer = self.parent.getRenderer() #iactor = self.wxrenwin.GetRenderWindow().GetInteractor() lib.messenger.connect(None, "visualize_tracks", self.onVisualizeTracks) self.filterDesc = "Visualize created motion tracks"
def __init__(self, parent, visualizer, **kws): """ Method: __init__(parent) Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) self.on = 0 self.renew = 1 self.mapper = vtk.vtkPolyDataMapper() self.eventDesc = "Rendering Camera Path" self.spline = spline = vtk.vtkSplineWidget() self.spline.GetLineProperty().SetColor(1, 0, 0) self.spline.GetHandleProperty().SetColor(0, 1, 0) self.spline.SetResolution(1000) #TODO: endInteraction is in GUI.Urmas.SplineEditor self.spline.AddObserver("EndInteractionEvent", self.endInteraction) self.spline.AddObserver("InteractionEvent", self.endInteraction) #TODO: iren is in GUI.Urmas.SplineEditor self.spline.SetInteractor(self.iren) #self.spline.On() #self.spline.SetEnabled(1) self.renderer = self.parent.getRenderer()
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 #self.name = "Clipping Plane" self.parent = parent self.on = 0 self.renew = 1 self.currentPlane = None self.clipped = 0 self.clippedModules = [] self.planeWidget = vtk.vtkPlaneWidget() self.planeWidget.AddObserver("InteractionEvent", self.clipVolumeRendering) self.planeWidget.SetResolution(20) self.planeWidget.SetRepresentationToOutline() self.planeWidget.NormalToXAxisOn() self.renderer = self.parent.getRenderer() self.plane = vtk.vtkPlane() iactor = parent.wxrenwin.GetRenderWindow().GetInteractor() self.planeWidget.SetInteractor(iactor) VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = {"ShowControl": "Show controls", "AllModules": "Clip all modules", "ClippedModule": "Module to clip"} self.filterDesc = "Clip rendering using a plane"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) #self.name = "Scale bar" self.renew = 1 self.mapper = vtk.vtkDataSetMapper() self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.width = 10 self.widthPx = 100 self.voxelSize = (1, 1, 1) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.actor) self.polyLine = vtk.vtkPolyLine() #self.mapper.SetInput(self.polyLine.GetOutput()) self.actor.GetProperty().SetColor(1, 1, 1) self.textActor = vtk.vtkTextActor() #self.textActor.ScaledTextOn() self.renderer.AddActor2D(self.textActor) iactor = self.wxrenwin.GetRenderWindow().GetInteractor() style = iactor.GetInteractorStyle() # style.AddObserver("StartInteractionEvent",self.updateLine) style.AddObserver("EndInteractionEvent", self.updateRendering)
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 #self.name = "Clipping Plane" self.parent = parent self.on = 0 self.renew = 1 self.currentPlane = None self.clipped = 0 self.clippedModules = [] self.planeWidget = vtk.vtkPlaneWidget() self.planeWidget.AddObserver("InteractionEvent", self.clipVolumeRendering) self.planeWidget.SetResolution(20) self.planeWidget.SetRepresentationToOutline() self.planeWidget.NormalToXAxisOn() self.renderer = self.parent.getRenderer() self.plane = vtk.vtkPlane() iactor = parent.wxrenwin.GetRenderWindow().GetInteractor() self.planeWidget.SetInteractor(iactor) VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = { "ShowControl": "Show controls", "AllModules": "Clip all modules", "ClippedModule": "Module to clip" } self.filterDesc = "Clip rendering using a plane"
def __init__(self, parent, visualizer, **kws): """ Method: __init__(parent) Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) #self.name = "Arbitrary Slices" self.on = 0 self.renew = 1 self.mapper = vtk.vtkPolyDataMapper() self.outline = vtk.vtkOutlineFilter() self.outlineMapper = vtk.vtkPolyDataMapper() self.outlineActor = vtk.vtkActor() self.outlineActor.SetMapper(self.outlineMapper) self.picker = vtk.vtkCellPicker() self.picker.SetTolerance(0.5) self.planes = [] self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.outlineActor) self.ctf = None self.origin = None self.spacing = None self.extent = None
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) self.on = 0 self.renew = 1 self.mapper = vtk.vtkPolyDataMapper() self.eventDesc = "Rendering orthogonal slices" self.outline = vtk.vtkOutlineFilter() self.outlineMapper = vtk.vtkPolyDataMapper() self.outlineActor = vtk.vtkActor() self.outlineActor.SetMapper(self.outlineMapper) self.picker = vtk.vtkCellPicker() self.picker.SetTolerance(0.005) self.planeWidgetX = vtk.vtkImagePlaneWidget() self.planeWidgetX.DisplayTextOn() self.planeWidgetX.SetPicker(self.picker) self.planeWidgetX.SetKeyPressActivationValue("x") #self.planeWidgetX.UserControlledLookupTableOn() self.prop1 = self.planeWidgetX.GetPlaneProperty() #self.prop1.SetColor(1, 0, 0) self.planeWidgetX.SetResliceInterpolateToCubic() self.planeWidgetY = vtk.vtkImagePlaneWidget() self.planeWidgetY.DisplayTextOn() self.planeWidgetY.SetPicker(self.picker) self.planeWidgetY.SetKeyPressActivationValue("y") self.prop2 = self.planeWidgetY.GetPlaneProperty() self.planeWidgetY.SetResliceInterpolateToCubic() #self.planeWidgetY.UserControlledLookupTableOn() #self.prop2.SetColor(1, 1, 0) # for the z-slice, turn off texture interpolation: # interpolation is now nearest neighbour, to demonstrate # cross-hair cursor snapping to pixel centers self.planeWidgetZ = vtk.vtkImagePlaneWidget() self.planeWidgetZ.DisplayTextOn() self.planeWidgetZ.SetPicker(self.picker) self.planeWidgetZ.SetKeyPressActivationValue("z") self.prop3 = self.planeWidgetZ.GetPlaneProperty() #self.prop3.SetColor(1, 0, 1) #self.planeWidgetZ.UserControlledLookupTableOn() self.planeWidgetZ.SetResliceInterpolateToCubic() self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.outlineActor) self.useOutline = 1 iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.planeWidgetX.SetInteractor(iactor) self.planeWidgetY.SetInteractor(iactor) self.planeWidgetZ.SetInteractor(iactor) lib.messenger.connect(None, "zslice_changed", self.setZ) self.filterDesc = "View orthogonal slices"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.init = False VisualizationModule.__init__(self, parent, visualizer, numberOfInputs=(2, 2), **kws) # self.name = "Surface Rendering" self.normals = vtk.vtkPolyDataNormals() self.smooth = None self.volumeModule = None self.scalarRange = (0, 255) for i in range(1, 3): self.setInputChannel(i, i) self.eventDesc = "Rendering iso-surface" self.decimate = vtk.vtkDecimatePro() self.mapper = vtk.vtkPolyDataMapper() self.mapper2 = vtk.vtkPolyDataMapper() self.contour = vtk.vtkMarchingCubes() self.contour2 = vtk.vtkDiscreteMarchingCubes() self.descs = { "Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals\n", "Simplify": "Simplify surface", "PreserveTopology": "Preserve topology", "Transparency": "Surface transparency", "Distance": "Distance to consider inside", "MarkColor": "Mark in/outside objects with colors", } self.actor = self.lodActor = vtk.vtkLODActor() self.lodActor.SetMapper(self.mapper) self.lodActor.SetNumberOfCloudPoints(10000) self.actor2 = vtk.vtkLODActor() self.actor2.SetMapper(self.mapper2) self.actor2.SetNumberOfCloudPoints(10000) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.lodActor) self.renderer.AddActor(self.actor2) lib.messenger.connect(None, "highlight_object", self.onHighlightObject)
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 self.renew = 1 self.mapper = vtk.vtkPolyDataMapper() self.axes = None VisualizationModule.__init__(self, parent, visualizer, **kws) iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.descs = {"X": "X axis", "Y": "Y axis", "Z": "Z axis"} self.axes = axes = vtk.vtkAxesActor() axes.SetShaftTypeToCylinder() axes.SetXAxisLabelText("X") axes.SetYAxisLabelText("Y") axes.SetZAxisLabelText("Z") axes.SetTotalLength(2.0, 2.0, 2.0) self.length = math.sqrt(2.0**2 + 2.0**2 + 2.0**2) tprop = vtk.vtkTextProperty() tprop.ItalicOn() tprop.ShadowOn() tprop.SetFontFamilyToTimes() axes.GetXAxisCaptionActor2D().SetCaptionTextProperty(tprop) tprop2 = vtk.vtkTextProperty() tprop2.ShallowCopy(tprop) axes.GetYAxisCaptionActor2D().SetCaptionTextProperty(tprop2) tprop3 = vtk.vtkTextProperty() tprop3.ShallowCopy(tprop) axes.GetZAxisCaptionActor2D().SetCaptionTextProperty(tprop3) self.renderer = self.parent.getRenderer() self.actor = self.axes self.marker = vtk.vtkOrientationMarkerWidget() self.marker.SetOutlineColor(0.93, 0.57, 0.13) self.marker.SetOrientationMarker(axes) self.marker.SetViewport(0.0, 0.0, 0.2, 0.2) self.marker.SetInteractor(iactor) self.marker.SetEnabled(1) self.marker.InteractiveOff() self.filterDesc = "Add axes in 3D view"
def __init__(self, parent, visualizer, **kws): """ Initialization """ VisualizationModule.__init__(self, parent, visualizer, **kws) # self.name = "Surface Rendering" # for i in range(1, 3): # self.setInputChannel(i, i) self.normals = vtk.vtkPolyDataNormals() self.smooth = None self.volumeModule = None self.scalarRange = (0, 255) self.eventDesc = "Rendering iso-surface" self.decimate = vtk.vtkDecimatePro() self.setMethod(1) self.init = 0 self.mapper = vtk.vtkPolyDataMapper() self.descs = { "Method": "Surface rendering method", "Gaussian": "Smooth surface with gaussian smoothing", "Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals\n", "Simplify": "Simplify surface", "PreserveTopology": "Preserve topology", "IsoValue": "Iso value", "SurfaceRangeBegin": "Generate surfaces in range:\n", "SurfaceAmnt": "Number of surfaces", "Transparency": "Surface transparency", "MultipleSurfaces": "Visualize multiple surfaces", "SolidColor": "Color surface with max. intensity", } self.actor = self.lodActor = vtk.vtkLODActor() self.lodActor.SetMapper(self.mapper) self.lodActor.SetNumberOfCloudPoints(10000) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.lodActor) # self.updateRendering() self.filterDesc = "Create and visualize iso-surface"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.init = False VisualizationModule.__init__(self, parent, visualizer, numberOfInputs = (2,2), **kws) #self.name = "Surface Rendering" self.normals = vtk.vtkPolyDataNormals() self.smooth = None self.volumeModule = None self.scalarRange = (0, 255) for i in range(1, 3): self.setInputChannel(i, i) self.eventDesc = "Rendering iso-surface" self.decimate = vtk.vtkDecimatePro() self.mapper = vtk.vtkPolyDataMapper() self.mapper2 = vtk.vtkPolyDataMapper() self.contour = vtk.vtkMarchingCubes() self.contour2 = vtk.vtkDiscreteMarchingCubes() self.descs = { "Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals\n", "Simplify": "Simplify surface", "PreserveTopology": "Preserve topology", "Transparency": "Surface transparency","Distance":"Distance to consider inside", "MarkColor":"Mark in/outside objects with colors" } self.actor = self.lodActor = vtk.vtkLODActor() self.lodActor.SetMapper(self.mapper) self.lodActor.SetNumberOfCloudPoints(10000) self.actor2 = vtk.vtkLODActor() self.actor2.SetMapper(self.mapper2) self.actor2.SetNumberOfCloudPoints(10000) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.lodActor) self.renderer.AddActor(self.actor2) lib.messenger.connect(None, "highlight_object", self.onHighlightObject)
def __init__(self, parent, visualizer, **kws): """ Initialization """ VisualizationModule.__init__(self, parent, visualizer, **kws) #self.name = "Surface Rendering" #for i in range(1, 3): # self.setInputChannel(i, i) self.normals = vtk.vtkPolyDataNormals() self.smooth = None self.volumeModule = None self.scalarRange = (0, 255) self.eventDesc = "Rendering iso-surface" self.decimate = vtk.vtkDecimatePro() self.setMethod(1) self.init = 0 self.mapper = vtk.vtkPolyDataMapper() self.descs = { "Method": "Surface rendering method", "Gaussian": "Smooth surface with gaussian smoothing", "Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals\n", "Simplify": "Simplify surface", "PreserveTopology": "Preserve topology", "IsoValue": "Iso value", "SurfaceRangeBegin": "Generate surfaces in range:\n", "SurfaceAmnt": "Number of surfaces", "Transparency": "Surface transparency", "MultipleSurfaces": "Visualize multiple surfaces", "SolidColor": "Color surface with max. intensity" } self.actor = self.lodActor = vtk.vtkLODActor() self.lodActor.SetMapper(self.mapper) self.lodActor.SetNumberOfCloudPoints(10000) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.lodActor) #self.updateRendering() self.filterDesc = "Create and visualize iso-surface"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) self.on = 0 self.renew = 1 self.angleWidget = vtk.vtkAngleWidget() self.obsTag = self.angleWidget.AddObserver("EndInteractionEvent", self.onPlacePoint) self.angleWidget.CreateDefaultRepresentation() self.representation = self.angleWidget.GetRepresentation() self.renderer = self.parent.getRenderer() iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.angleWidget.SetInteractor(iactor) self.picker = vtk.vtkCellPicker() #self.picker.SetTolerance(0.05) self.filterDesc = "Measure angle in 3D view"
def __init__(self, parent, visualizer, **kws): """ Initialization """ VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = { "Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals", "Slice": "Select slice to be warped", "Scale": "Scale factor for warping" } self.luminance = vtk.vtkImageLuminance() #DataGeometry filter, image to polygons self.geometry = vtk.vtkImageDataGeometryFilter() self.colorMapper = None #warp scalars! self.warp = vtk.vtkWarpScalar() self.warp.SetScaleFactor(-0.1) #merge image and new warped data self.merge = vtk.vtkMergeFilter() self.normals = vtk.vtkPolyDataNormals() self.normals.SetFeatureAngle(90) #first the mapper self.mapper = vtk.vtkPolyDataMapper() #make the actor from the mapper self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.actor) # iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.filterDesc = "Visualize 2D slice as 3D map"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.boxWidget = None VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = { "ShowControls": "Show controls", "ClippedModule": "Module to clip", "AllModules": "Clip all modules", "InsideOut": "Clip from outside" } boxWidget = self.boxWidget = vtk.vtkBoxWidget() self.cut = 0 self.clippedMappers = [] self.renderer = self.parent.getRenderer() iactor = parent.wxrenwin.GetRenderWindow().GetInteractor() self.boxWidget.SetInteractor(iactor) self.boxWidget.SetPlaceFactor(1.0) outlineProperty = boxWidget.GetOutlineProperty() outlineProperty.SetRepresentationToWireframe() outlineProperty.SetAmbient(1.0) outlineProperty.SetAmbientColor(1, 1, 1) outlineProperty.SetLineWidth(3) selectedOutlineProperty = boxWidget.GetSelectedOutlineProperty() selectedOutlineProperty.SetRepresentationToWireframe() selectedOutlineProperty.SetAmbient(1.0) selectedOutlineProperty.SetAmbientColor(1, 0, 0) selectedOutlineProperty.SetLineWidth(3) # iactor = self.wxrenwin.GetRenderWindow().GetInteractor() boxWidget.AddObserver("InteractionEvent", self.clipVolumeRender) self.renew = 0 self.filterDesc = "Clip rendering using a box"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.boxWidget = None VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = {"ShowControls": "Show controls", "ClippedModule": "Module to clip", "AllModules": "Clip all modules", "InsideOut": "Clip from outside"} boxWidget = self.boxWidget = vtk.vtkBoxWidget() self.cut = 0 self.clippedMappers = [] self.renderer = self.parent.getRenderer() iactor = parent.wxrenwin.GetRenderWindow().GetInteractor() self.boxWidget.SetInteractor(iactor) self.boxWidget.SetPlaceFactor(1.0) outlineProperty = boxWidget.GetOutlineProperty() outlineProperty.SetRepresentationToWireframe() outlineProperty.SetAmbient(1.0) outlineProperty.SetAmbientColor(1, 1, 1) outlineProperty.SetLineWidth(3) selectedOutlineProperty = boxWidget.GetSelectedOutlineProperty() selectedOutlineProperty.SetRepresentationToWireframe() selectedOutlineProperty.SetAmbient(1.0) selectedOutlineProperty.SetAmbientColor(1, 0, 0) selectedOutlineProperty.SetLineWidth(3) # iactor = self.wxrenwin.GetRenderWindow().GetInteractor() boxWidget.AddObserver("InteractionEvent", self.clipVolumeRender) self.renew = 0 self.filterDesc = "Clip rendering using a box"
def __init__(self, parent, visualizer, **kws): """ Initialization """ VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = {"Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals", "Slice": "Select slice to be warped", "Scale": "Scale factor for warping"} self.luminance = vtk.vtkImageLuminance() #DataGeometry filter, image to polygons self.geometry = vtk.vtkImageDataGeometryFilter() self.colorMapper = None #warp scalars! self.warp = vtk.vtkWarpScalar() self.warp.SetScaleFactor(-0.1) #merge image and new warped data self.merge = vtk.vtkMergeFilter() self.normals = vtk.vtkPolyDataNormals() self.normals.SetFeatureAngle (90) #first the mapper self.mapper = vtk.vtkPolyDataMapper() #make the actor from the mapper self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.renderer = self.parent.getRenderer() self.renderer.AddActor(self.actor) # iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.filterDesc = "Visualize 2D slice as 3D map"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.modes = [ "Ray casting", "Texture mapping", "3D texture mapping", "Maximum intensity projection" ] self.haveVolpro = 0 self.mapper = None conf = Configuration.getConfiguration() self.defaultMode = conf.getConfigItem("DefaultVolumeMode", "Rendering") if self.defaultMode != None: self.defaultMode = int(self.defaultMode) else: self.defaultMode = RAYCAST try: volpro = vtk.vtkVolumeProMapper() self.haveVolpro = 0 if volpro.GetNumberOfBoards(): self.haveVolpro = 1 except: self.haveVolpro = 0 if self.haveVolpro: self.modes.append("Minimum intensity projection") self.colorTransferFunction = None self.otf, self.otf2 = vtk.vtkPiecewiseFunction( ), vtk.vtkPiecewiseFunction() otf2 = self.otf2 otf = self.otf otf2.AddPoint(0, 0.0) otf2.AddPoint(255, 1.0) otf.AddPoint(0, 0.0) otf.AddPoint(255, 0.2) self.otfs = [self.otf, self.otf, self.otf, self.otf2, self.otf] self.volumeProperty = vtk.vtkVolumeProperty() self.volume = vtk.vtkVolume() self.actor = self.volume self.volume.SetProperty(self.volumeProperty) VisualizationModule.__init__(self, parent, visualizer, **kws) self.mapper = None #self.name = "Volume Rendering" self.setParameter("Quality", 10) self.parameters["Method"] = RAYCAST if self.defaultMode != None: self.parameters["Method"] = int(self.defaultMode) self.volumeProperty.SetScalarOpacity( self.otfs[self.parameters["Method"]]) self.descs = {"Palette": "", "Method": "", "Interpolation": "Interpolation", \ "NearestNeighbor": "Nearest Neighbour", "Linear": "Linear", \ "Quality": "", "QualityValue": "Maximum number of planes:", \ "UseVolumepro": "Use VolumePro acceleration", \ "UseShading": "Use shading" } self.eventDesc = "Rendering volume" self.qualityRange = 0, 10 self.volumeAdded = False self.mapperUpdated = False self.setShading(0) self.vtkObjects = ["otf", "otf2"] #self.updateRendering() lib.messenger.connect(None, "switch_datasets", self.onSwitchDatasets) self.filterDesc = "Volume render input data"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.modes = ["Ray casting", "Texture mapping", "3D texture mapping", "Maximum intensity projection"] self.haveVolpro = 0 self.mapper = None conf = Configuration.getConfiguration() self.defaultMode = conf.getConfigItem("DefaultVolumeMode", "Rendering") if self.defaultMode != None: self.defaultMode = int(self.defaultMode) else: self.defaultMode = RAYCAST try: volpro = vtk.vtkVolumeProMapper() self.haveVolpro = 0 if volpro.GetNumberOfBoards(): self.haveVolpro = 1 except: self.haveVolpro = 0 if self.haveVolpro: self.modes.append("Minimum intensity projection") self.colorTransferFunction = None self.otf, self.otf2 = vtk.vtkPiecewiseFunction(), vtk.vtkPiecewiseFunction() otf2 = self.otf2 otf = self.otf otf2.AddPoint(0, 0.0) otf2.AddPoint(255, 1.0) otf.AddPoint(0, 0.0) otf.AddPoint(255, 0.2) self.otfs = [self.otf, self.otf, self.otf, self.otf2, self.otf] self.volumeProperty = vtk.vtkVolumeProperty() self.volume = vtk.vtkVolume() self.actor = self.volume self.volume.SetProperty(self.volumeProperty) VisualizationModule.__init__(self, parent, visualizer, **kws) self.mapper = None #self.name = "Volume Rendering" self.setParameter("Quality", 10) self.parameters["Method"] = RAYCAST if self.defaultMode != None: self.parameters["Method"] = int(self.defaultMode) self.volumeProperty.SetScalarOpacity(self.otfs[self.parameters["Method"]]) self.descs = {"Palette": "", "Method": "", "Interpolation": "Interpolation", \ "NearestNeighbor": "Nearest Neighbour", "Linear": "Linear", \ "Quality": "", "QualityValue": "Maximum number of planes:", \ "UseVolumepro": "Use VolumePro acceleration", \ "UseShading": "Use shading" } self.eventDesc = "Rendering volume" self.qualityRange = 0, 10 self.volumeAdded = False self.mapperUpdated = False self.setShading(0) self.vtkObjects = ["otf", "otf2"] #self.updateRendering() lib.messenger.connect(None, "switch_datasets", self.onSwitchDatasets) self.filterDesc = "Volume render input data"
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.actorsInitialized = False VisualizationModule.__init__(self, parent, visualizer, **kws) self.descs = {"FileName": "PDB file", "SphereRadius": "Sphere radius", "TubeRadius": "Tube radius"} self.enabled = 1 self.mapper = vtk.vtkPolyDataMapper() self.mapper.UseLookupTableScalarRangeOff() self.mapper.SetScalarVisibility(1) self.mapper.SetScalarModeToDefault() #make the actor from the mapper self.actor = vtk.vtkLODActor() self.actor.GetProperty().SetRepresentationToSurface() self.actor.GetProperty().SetInterpolationToGouraud() self.actor.GetProperty().SetColor(1,1,1) self.actor.GetProperty().SetAmbient(0.15) self.actor.GetProperty().SetDiffuse(0.85) self.actor.GetProperty().SetSpecular(0.1) self.actor.GetProperty().SetSpecularPower(100) self.actor.GetProperty().SetSpecularColor(1,1,1) self.actor.GetProperty().SetColor(1,1,1) self.actor.SetNumberOfCloudPoints(30000) self.actor.SetMapper(self.mapper) self.reader = vtk.vtkPDBReader() self.renderer = self.parent.getRenderer() self.tubeFilter = vtk.vtkTubeFilter() self.tubeFilter.SetNumberOfSides(8) self.tubeFilter.SetCapping(0) self.tubeFilter.SetRadius(0.2) self.tubeFilter.SetVaryRadius(0) self.tubeFilter.SetRadiusFactor(10) self.mapper2 = vtk.vtkPolyDataMapper() self.mapper2.UseLookupTableScalarRangeOff() self.mapper2.SetScalarVisibility(1) self.mapper2.SetScalarModeToDefault() self.tubeActor = vtk.vtkLODActor() self.tubeActor.SetMapper(self.mapper2) self.tubeActor.GetProperty().SetRepresentationToSurface() self.tubeActor.GetProperty().SetInterpolationToGouraud() self.tubeActor.GetProperty().SetColor(1,1,1) self.tubeActor.GetProperty().SetAmbient(0.15) self.tubeActor.GetProperty().SetDiffuse(0.85) self.tubeActor.GetProperty().SetSpecular(0.1) self.tubeActor.GetProperty().SetSpecularPower(100) self.tubeActor.GetProperty().SetSpecularColor(1,1,1) self.tubeActor.SetNumberOfCloudPoints(30000) self.sphereSource = vtk.vtkSphereSource() self.sphereSource.SetCenter(0,0,0) self.sphereSource.SetRadius(1) self.sphereSource.SetThetaResolution(8) self.sphereSource.SetStartTheta(0) self.sphereSource.SetEndTheta(360) self.sphereSource.SetPhiResolution(8) self.sphereSource.SetStartPhi(0) self.sphereSource.SetEndPhi(180) self.glyph3D = vtk.vtkGlyph3D() self.glyph3D.SetOrient(1) self.glyph3D.SetColorMode(1) self.glyph3D.SetScaleMode(2) self.glyph3D.SetScaleFactor(.25) self.glyph3D.SetSource(self.sphereSource.GetOutput()) self.filterDesc = "Visualize Protein Data Bank file"