Example #1
0
    def makeCustomAxes(self, outline, outlinefilter):
        """ create custom axes """
        prop = vtk.vtkProperty()
        prop.SetColor(self.fgColor)

        x = vtk.vtkAxisActor()
        x.SetAxisTypeToX()
        # x.SetAxisPositionToMinMin()
        x.SetCamera(self.renderer.GetActiveCamera())
        x.SetBounds(outline.GetBounds())
        x.SetProperty(prop)
        x.SetRange(self.XLimit)
        x.SetPoint1(outline.GetBounds()[0], outline.GetBounds()[2], outline.GetBounds()[4])
        x.SetPoint2(outline.GetBounds()[1], outline.GetBounds()[2], outline.GetBounds()[4])

        return x
    cloud_r.SetBackground(0., 0., 0.)
    cloud_r.SetViewport(0, 0, 1.0, 1.0)
    integrateClouds(ldr_map, imu_transforms, cloud_r, start_fn, num_fn, step,
                    params)

    if '--export' in sys.argv:
        exportData()
        sys.exit(0)

    # Render Window
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(cloud_r)
    renderWindow.SetSize(1200, 600)

    axisActor = vtk.vtkAxisActor()
    axisActor.SetGridlineXLength(5)
    axisActor.SetGridlineYLength(5)
    axisActor.SetGridlineZLength(5)
    #axisActor.DrawGridpolysOn()
    #axisActor.DrawInnerGridlinesOn()
    cloud_r.AddActor(axisActor)

    # Interactor
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)
    mouseInteractor = vtk.vtkInteractorStyleTrackballCamera()
    renderWindowInteractor.SetInteractorStyle(mouseInteractor)
    renderWindow.Render()

    renderWindowInteractor.AddObserver('KeyPressEvent', keypress)
Example #3
0
    # this has been flipped for the q50
    
    cloud_r.SetBackground(0., 0., 0.)
    cloud_r.SetViewport(0,0,1.0,1.0)
    integrateClouds(ldr_map, imu_transforms, cloud_r, start_fn, num_fn, step, params)

    if '--export' in sys.argv:
      exportData()
      sys.exit(0)

    # Render Window
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(cloud_r)
    renderWindow.SetSize(1200, 600)

    axisActor = vtk.vtkAxisActor()
    axisActor.SetGridlineXLength(5)
    axisActor.SetGridlineYLength(5)
    axisActor.SetGridlineZLength(5)
    #axisActor.DrawGridpolysOn()
    #axisActor.DrawInnerGridlinesOn()
    cloud_r.AddActor(axisActor)

    # Interactor
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)
    mouseInteractor = vtk.vtkInteractorStyleTrackballCamera()
    renderWindowInteractor.SetInteractorStyle(mouseInteractor)
    renderWindow.Render()

    renderWindowInteractor.AddObserver('KeyPressEvent', keypress)
Example #4
0
	def addWidgets(self,opt=None):
		if opt is not None:
			if opt.has_key('caption'):
				self.caption=opt['caption']
			if opt.has_key('showAxes'):
				self.showAxes=opt['showAxes']
			if opt.has_key('showCompass'):
				self.showCompass=opt['showCompass']
			if opt.has_key('showScalarBar'):
				self.showScalarBar=opt['showScalarBar']
			if opt.has_key('showXYPlane'):
				self.showXYPlane=opt['showXYPlane']
			if opt.has_key('showYZPlane'):
				self.showYZPlane=opt['showYZPlane']
			if opt.has_key('showZXPlane'):
				self.showZXPlane=opt['showZXPlane']
			if opt.has_key('xlabel'):
				self.xlabel=opt['xlabel']
			if opt.has_key('ylabel'):
				self.ylabel=opt['ylabel']
			if opt.has_key('ylabel'):
				self.zlabel=opt['zlabel']
			if opt.has_key('xrange'):
				self.xrange=opt['xrange']
			if opt.has_key('yrange'):
				self.yrange=opt['yrange']
			if opt.has_key('zrange'):
				self.zrange=opt['zrange']


		prn=1000.
		pc=-prn
		plXY = vtk.vtkPlaneSource()
		plXY.SetPoint1(prn,-prn,0)
		plXY.SetPoint2(-prn,prn,0)
		plXY.SetOrigin(pc,pc,0)
		plXY.SetCenter(0,0,0)
		plXYmap = vtk.vtkPolyDataMapper()
		plXYmap.SetInput(plXY.GetOutput())
		plXYact = vtk.vtkActor()
		plXYact.SetMapper(plXYmap)
		plXYact.GetProperty().SetOpacity(0.1)

		plYZ = vtk.vtkPlaneSource()
		plYZ.SetCenter(0,pc,pc)
		plYZ.SetPoint1(0,prn,-prn)
		plYZ.SetPoint2(0,-prn,prn)
		plYZmap = vtk.vtkPolyDataMapper()
		plYZmap.SetInput(plYZ.GetOutput())
		plYZact = vtk.vtkActor()
		plYZact.SetMapper(plYZmap)
		plYZact.GetProperty().SetOpacity(0.1)

		plZX = vtk.vtkPlaneSource()
		plZX.SetCenter(pc,0,pc)
		plZX.SetPoint1(prn,0,-prn)
		plZX.SetPoint2(-prn,0,prn)
		plZXmap = vtk.vtkPolyDataMapper()
		plZXmap.SetInput(plZX.GetOutput())
		plZXact = vtk.vtkActor()
		plZXact.SetMapper(plZXmap)
		plZXact.GetProperty().SetOpacity(0.1)

		ax=vtk.vtkAxesActor()
		ax.GetXAxisCaptionActor2D().GetProperty().SetColor(0,0,0)
		ax.GetYAxisCaptionActor2D().GetProperty().SetColor(0,0,0)
		ax.GetZAxisCaptionActor2D().GetProperty().SetColor(0,0,0)

		xa=vtk.vtkAxisActor()
		xa.SetPoint1(0,0,0)
		xa.SetPoint2(1000,0,0)
		xa.SetRange((0,1000))
		xa.SetBounds(-1.0, 1000.0, -1.0, 1.0, -1.0, 1.0)

		self.ow=vtk.vtkOrientationMarkerWidget()
		textActor = vtk.vtkTextActor()
		textActor.GetTextProperty().SetFontSize ( 22 )
		textActor.SetPosition2( 100, 100 )
		textActor.SetInput(r'DESICOS VIEWER: '+str(self.caption)+r' Scaling: '+str(self.scalingFactor))
		textActor.GetTextProperty().SetColor ( 0.0,0.0,0.0 )
	

			
		if self.showXYPlane:
			self.ren.AddActor(plXYact)
		if self.showYZPlane:
			self.ren.AddActor(plYZact)
		if self.showZXPlane:
			self.ren.AddActor(plZXact)
		if self.showCaption:
			self.ren.AddActor2D( textActor )
		if self.showScalarBar:
			self.scalar_bar = vtk.vtkScalarBarActor()
			self.scalar_bar.SetOrientationToHorizontal()
			self.scalar_bar.SetLookupTable(self.lut)
			self.scalar_bar.SetTitle("Imperfection value");
			self.scalar_bar.SetNumberOfLabels(11)
			self.scalar_bar.GetProperty().SetColor ( 0.0,0.0,0.0 )
			self.scalar_bar_widget = vtk.vtkScalarBarWidget()
			self.scalar_bar_widget.SetInteractor(self.iren)
			self.scalar_bar_widget.SetScalarBarActor(self.scalar_bar)
			self.scalar_bar_widget.On()
		if self.showCompass:
			self.ow.SetOrientationMarker(ax)
			self.ow.SetInteractor(self.iren)
#			self.ow.SetViewport( 0.0, 0.0, 0.4, 0.4 )
			self.ow.SetEnabled( 1 )
			self.ow.InteractiveOn()
		if self.showAxes:
			c=vtk.vtkCubeAxesActor()
			c.SetBounds(self.boundBox)
			c.SetXTitle(self.xlabel)
			c.SetYTitle(self.ylabel)
			c.SetZTitle(self.zlabel)

			if self.xrange is not None:
				c.SetXAxisRange(self.xrange)
			if self.yrange is not None:
				c.SetYAxisRange(self.yrange)
			if self.zrange is not None:
				c.SetZAxisRange(self.zrange)
			c.GetProperty().SetColor(0., 0., 0.)
			c.SetCamera(self.ren.GetActiveCamera())
			self.ren.AddActor(c)
Example #5
0
def main():
    colors = vtk.vtkNamedColors()

    source = vtk.vtkSphereSource()
    source.SetPhiResolution(31)
    source.SetThetaResolution(31)
    source.Update()
    bounds = source.GetOutput().GetBounds()
    print("Bounds: " + str(bounds[0]) + ", " + str(bounds[2]) + ", " +
          str(bounds[3]) + ", " + str(bounds[1]) + ", " + str(bounds[3]) +
          ", " + str(bounds[5]))
    center = source.GetOutput().GetCenter()
    print("Center: " + str(center[0]) + ", " + str(center[1]) + ", " +
          str(center[2]))

    # Create the axis actor
    axis = vtk.vtkAxisActor()
    axis.SetPoint1(-1.1, 0.0, 0.0)
    axis.SetPoint2(1.1, 0.0, 0.0)
    axis.SetTickLocationToBoth()
    axis.SetAxisTypeToX()
    axis.SetTitle("A Sphere")
    axis.SetTitleScale(0.2)
    axis.TitleVisibilityOn()

    axis.SetMajorTickSize(0.05)
    axis.SetMinorTickSize(1)
    axis.DrawGridlinesOff()
    axis.GetTitleTextProperty().SetColor(colors.GetColor3d("banana"))
    axis.GetLabelTextProperty().SetColor(colors.GetColor3d("orange"))

    labels = vtk.vtkStringArray()
    labels.SetNumberOfTuples(1)
    labels.SetValue(0, "x Axis")

    axis.SetLabels(labels)
    axis.SetLabelScale(.1)
    axis.MinorTicksVisibleOn()
    axis.SetDeltaMajor(0, .1)
    axis.SetCalculateTitleOffset(0)
    axis.SetCalculateLabelOffset(0)

    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(source.GetOutputPort())

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    # actor.GetProperty().SetDiffuseColor(colors.GetColor4d("Tomato"))
    actor.GetProperty().SetDiffuseColor(colors.GetColor3d("Tomato"))

    # Create the RenderWindow, Renderer and both Actors
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renderWindow.SetWindowName("AxisActor")

    interactor = vtk.vtkRenderWindowInteractor()
    interactor.SetRenderWindow(renderWindow)

    axis.SetCamera(renderer.GetActiveCamera())

    renderer.AddActor(actor)
    renderer.AddActor(axis)

    #  renderer.SetBackground(colors.GetColor4d("SlateGray"))
    renderer.SetBackground(colors.GetColor3d("SlateGray"))
    renderWindow.SetSize(640, 480)
    renderer.ResetCamera()
    renderer.ResetCameraClippingRange()

    # render the image
    renderWindow.Render()

    interactor.Initialize()
    interactor.Start()