def make_glyph(ren, pos, message):
    """vtkTextActor3D does almost exactly what I need, even
    multi-lines, although the documentation claims otherwise.

    Only thing I need now is to be able to query the bounds of the
    generated texture image.

    From experiments with the sphere at the origin, it does seem that
    setting the font size to x-points, makes the text line, from the
    bottom-most feature to the top-most, x-world units high.  I don't
    know how to get to the inter-line spacing yet though...
    """
    ta = vtk.vtkTextActor3D()
    ta.SetInput(message)

    tprop = ta.GetTextProperty()
    tprop.SetFontFamilyToArial()
    #tprop.SetVerticalJustificationToCentered()
    tprop.SetFontSize(32)
    tprop.SetBold(0)
    tprop.SetItalic(0)
    tprop.SetShadow(0)
    tprop.SetColor((0,0,0))

    ta.SetPosition((pos[0], pos[1],0))
    #ta.SetPosition((pos[0], pos[1]))

    #ta.UpdateImageActor()

    # I have *NO* idea why I have to this, but if I don't,  I get the
    # following error message with "What ghte hell" (it's the 'g'):
    # 
    # RuntimeError: ERROR: In ..\..\..\archive\VTK\
    # Filtering\vtkStreamingDemandDrivenPipeline.cxx, line 698
    # vtkStreamingDemandDrivenPipeline (0182B9B0): The update extent 
    # specified in the information for output port 0 on algorithm 
    # vtkTrivialProducer(01829DA8) is 0 255 0 63 0 0, which is 
    # outside the whole extent 0 255 0 31 0 0.
    # investigation shows that the DisplayExtent of the imageactor is
    # indeed larger than the wholeextent of the imagedata, although
    # these two are set to be equal in the UpdateImageActor.
    #ta.GetImageActor().SetDisplayExtent(ta.GetImageData().GetWholeExtent())


    ren.AddActor(ta)


    ss = vtk.vtkSphereSource()
    ss.SetRadius(32)
    sm = vtk.vtkPolyDataMapper()
    sm.SetInput(ss.GetOutput())
    sa = vtk.vtkActor()
    sa.SetMapper(sm)
    sa.SetPosition((pos[0],pos[1],0))
    ren.AddActor(sa)

    return ta
Пример #2
0
        def AddOneTextActor(baseTextProp):
            name = "ia"
            self.textActors[name] = vtk.vtkTextActor3D()
            # This adjustment is needed to reduce the difference
            # between the Tcl and Python versions.
            self.textActors[name].SetOrigin(0, -0.127878, 0)

            tprop = self.textActors[name].GetTextProperty()
            tprop.ShallowCopy(baseTextProp)
            tprop.SetColor(1, 0, 0)
def make_glyph(ren, pos, message):
    """vtkTextActor3D does almost exactly what I need, even
    multi-lines, although the documentation claims otherwise.

    Only thing I need now is to be able to query the bounds of the
    generated texture image.

    From experiments with the sphere at the origin, it does seem that
    setting the font size to x-points, makes the text line, from the
    bottom-most feature to the top-most, x-world units high.  I don't
    know how to get to the inter-line spacing yet though...
    """
    ta = vtk.vtkTextActor3D()
    ta.SetInput(message)

    tprop = ta.GetTextProperty()
    tprop.SetFontFamilyToArial()
    #tprop.SetVerticalJustificationToCentered()
    tprop.SetFontSize(32)
    tprop.SetBold(0)
    tprop.SetItalic(0)
    tprop.SetShadow(0)
    tprop.SetColor((0, 0, 0))

    ta.SetPosition((pos[0], pos[1], 0))
    #ta.SetPosition((pos[0], pos[1]))

    #ta.UpdateImageActor()

    # I have *NO* idea why I have to this, but if I don't,  I get the
    # following error message with "What ghte hell" (it's the 'g'):
    #
    # RuntimeError: ERROR: In ..\..\..\archive\VTK\
    # Filtering\vtkStreamingDemandDrivenPipeline.cxx, line 698
    # vtkStreamingDemandDrivenPipeline (0182B9B0): The update extent
    # specified in the information for output port 0 on algorithm
    # vtkTrivialProducer(01829DA8) is 0 255 0 63 0 0, which is
    # outside the whole extent 0 255 0 31 0 0.
    # investigation shows that the DisplayExtent of the imageactor is
    # indeed larger than the wholeextent of the imagedata, although
    # these two are set to be equal in the UpdateImageActor.
    #ta.GetImageActor().SetDisplayExtent(ta.GetImageData().GetWholeExtent())

    ren.AddActor(ta)

    ss = vtk.vtkSphereSource()
    ss.SetRadius(32)
    sm = vtk.vtkPolyDataMapper()
    sm.SetInput(ss.GetOutput())
    sa = vtk.vtkActor()
    sa.SetMapper(sm)
    sa.SetPosition((pos[0], pos[1], 0))
    ren.AddActor(sa)

    return ta
        def AddOneTextActor(baseTextProp):
            name = "ia"
            self.textActors[name] = vtk.vtkTextActor3D()
            # This adjustment is needed to reduce the difference
            # between the Tcl and Python versions.
            self.textActors[name].SetOrigin(0, -0.127878, 0)


            tprop = self.textActors[name].GetTextProperty()
            tprop.ShallowCopy(baseTextProp)
            tprop.SetColor(1,0,0)
def make_glyph(ren, pos, message):
    ta = vtk.vtkTextActor3D()
    ta.SetInput(message)

    tprop = ta.GetTextProperty()
    tprop.SetFontFamilyToArial()
    tprop.SetFontSize(32)
    tprop.SetBold(0)
    tprop.SetItalic(0)
    tprop.SetShadow(0)
    tprop.SetColor((0, 0, 0))

    ta.SetPosition((pos[0], pos[1], 0))

    ren.AddActor(ta)
Пример #6
0
def make_glyph(ren, pos, message):
    ta = vtk.vtkTextActor3D()
    ta.SetInput(message)

    tprop = ta.GetTextProperty()
    tprop.SetFontFamilyToArial()
    tprop.SetFontSize(32)
    tprop.SetBold(0)
    tprop.SetItalic(0)
    tprop.SetShadow(0)
    tprop.SetColor((0, 0, 0))

    ta.SetPosition((pos[0], pos[1], 0))

    ren.AddActor(ta)
Пример #7
0
 def __init__(self):
     super(MyGraphicsView, self).__init__()
     self.mWidget = vtk.QVTKWidget2()
     self.setViewport(self.mWidget)
     self.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate)
     self.mScene = MyOpenGLScene(self.mWidget.context())
     self.setScene(self.mScene)
     self.mRen = vtk.vtkRenderer()
     self.mRen.SetBackground(0, 0, 0)
     self.mRen.SetBackground2(1, 1, 1)
     self.mRen.SetGradientBackground(1)
     textActor = vtk.vtkTextActor3D()
     textActor.SetInput("Qt & VTK!!")
     self.mRen.AddViewProp(textActor)
     self.mRen.ResetCamera()
     self.mWidget.GetRenderWindow().AddRenderer(self.mRen)
     self.mWidget.GetRenderWindow().SetSwapBuffers(0)
Пример #8
0
 def __init__(self):
   super(MyGraphicsView, self).__init__()
   self.mWidget = vtk.QVTKWidget2()
   self.setViewport(self.mWidget)
   self.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate)
   self.mScene = MyOpenGLScene(self.mWidget.context())
   self.setScene(self.mScene)
   self.mRen = vtk.vtkRenderer()
   self.mRen.SetBackground(0,0,0)
   self.mRen.SetBackground2(1,1,1)
   self.mRen.SetGradientBackground(1)
   textActor = vtk.vtkTextActor3D()
   textActor.SetInput("Qt & VTK!!")
   self.mRen.AddViewProp(textActor)
   self.mRen.ResetCamera()
   self.mWidget.GetRenderWindow().AddRenderer(self.mRen)
   self.mWidget.GetRenderWindow().SetSwapBuffers(0)
Пример #9
0
def Show(func, pos=(0, 0, 0)):
    global R
    PFS = vtk.vtkParametricFunctionSource()
    PFS.SetParametricFunction(func)
    M = vtk.vtkPolyDataMapper()
    M.SetInputConnection(PFS.GetOutputPort())
    A = vtk.vtkActor()
    A.SetPosition(pos)
    A.SetMapper(M)
    A.SetProperty(P1)
    A.SetBackfaceProperty(P2)
    R.AddActor(A)
    TA3 = vtk.vtkTextActor3D()
    TA3.SetInput(func.GetClassName().replace('vtkParametric', ''))
    TA3.GetTextProperty().SetFontSize(20)
    TA3.SetScale(.02)
    TA3.SetPosition(pos[0], pos[1] - 2, pos[2] + .1)
    R.AddActor(TA3)
    return A
Пример #10
0
    def __init__(self, canvas, position, numInputs, numOutputs,
                 labelList, module_instance):
        # parent constructor
        DeVIDECanvasObject.__init__(self, canvas, position)

        # we'll fill this out later
        self._size = (0,0)
        self._numInputs = numInputs
        self.inputLines = [None] * self._numInputs
        self._numOutputs = numOutputs
        # be careful with list concatenation!
        self.outputLines = [[] for i in range(self._numOutputs)]
        self._labelList = labelList
        self.module_instance = module_instance
        # usually 2-element list.  elem0 is 0 for input port and 1 for
        # output port.  elem1 is the index.
        self.draggedPort = None
        self.enteredPort = None
        self.selected = False
        self.blocked = False

        # we'll collect the glyph and its ports in this assembly
        self.prop1 = vtk.vtkAssembly()
        # the main body glyph
        self._beb = BeveledEdgeBlock()
        self._selection_block = FilledBlock()
        self._blocked_block = FilledBlock()

        self._rbsa = vtk.vtkActor()
        # and of course the label
        self._tsa = vtk.vtkTextActor3D()

        self._iportssa = \
            [(vtk.vtkCubeSource(),vtk.vtkActor()) for _ in
                range(self._numInputs)]

        self._oportssa = \
            [(vtk.vtkCubeSource(),vtk.vtkActor()) for _ in
                range(self._numOutputs)]

        self._create_geometry()
        self.update_geometry()
Пример #11
0
    def __init__(self, canvas, position, numInputs, numOutputs, labelList,
                 module_instance):
        # parent constructor
        DeVIDECanvasObject.__init__(self, canvas, position)

        # we'll fill this out later
        self._size = (0, 0)
        self._numInputs = numInputs
        self.inputLines = [None] * self._numInputs
        self._numOutputs = numOutputs
        # be careful with list concatenation!
        self.outputLines = [[] for i in range(self._numOutputs)]
        self._labelList = labelList
        self.module_instance = module_instance
        # usually 2-element list.  elem0 is 0 for input port and 1 for
        # output port.  elem1 is the index.
        self.draggedPort = None
        self.enteredPort = None
        self.selected = False
        self.blocked = False

        # we'll collect the glyph and its ports in this assembly
        self.prop1 = vtk.vtkAssembly()
        # the main body glyph
        self._beb = BeveledEdgeBlock()
        self._selection_block = FilledBlock()
        self._blocked_block = FilledBlock()

        self._rbsa = vtk.vtkActor()
        # and of course the label
        self._tsa = vtk.vtkTextActor3D()

        self._iportssa = \
            [(vtk.vtkCubeSource(),vtk.vtkActor()) for _ in
                range(self._numInputs)]

        self._oportssa = \
            [(vtk.vtkCubeSource(),vtk.vtkActor()) for _ in
                range(self._numOutputs)]

        self._create_geometry()
        self.update_geometry()
Пример #12
0
        def AddManyTextActors(baseTextProp):
            lut = vtk.vtkColorTransferFunction()
            lut.SetColorSpaceToHSV()
            lut.AddRGBPoint(0.0, 0.0, 1.0, 1.0)
            lut.AddRGBPoint(1.0, 1.0, 1.0, 1.0)

            for i in range(0, 10):
                name = "ia" + str(i)

                self.textActors[name] = vtk.vtkTextActor3D()
                self.textActors[name].SetOrientation(0, i*36, 0)
                #self.textActors[name].SetPosition(math.cos(i * 0.0314), 0, 0)
                # This adjustment is needed to reduce the diffierence
                # between the Tcl and Python versions.
                self.textActors[name].SetOrigin(0, -0.127878, 0)

                tprop = self.textActors[name].GetTextProperty()
                tprop.ShallowCopy(baseTextProp)
                value = i / 10.0
                tprop.SetColor(lut.GetColor(value))

            del lut
        def AddManyTextActors(baseTextProp):
            lut = vtk.vtkColorTransferFunction()
            lut.SetColorSpaceToHSV()
            lut.AddRGBPoint(0.0, 0.0, 1.0, 1.0)
            lut.AddRGBPoint(1.0, 1.0, 1.0, 1.0)

            for i in range(0, 10):
                name = "ia" + str(i)

                self.textActors[name] = vtk.vtkTextActor3D()
                self.textActors[name].SetOrientation(0, i*36, 0)
                #self.textActors[name].SetPosition(math.cos(i * 0.0314), 0, 0)
                # This adjustment is needed to reduce the diffierence
                # between the Tcl and Python versions.
                self.textActors[name].SetOrigin(0, -0.127878, 0)

                tprop = self.textActors[name].GetTextProperty()
                tprop.ShallowCopy(baseTextProp)
                value = i / 10.0
                tprop.SetColor(lut.GetColor(value))

            del lut
Пример #14
0
 def __init__(self, screen_log):
     self.name = ""
     self.x_pos = 0
     self.y_pos = 0
     self.height = 0.0
     self.max_load = 1
     self.max_jobs = 1
     self.up_state = True
     self.rgb = [0.0, 0.0, 0.0]
     self.grid_scale = 6.0
     self.box_scale = 4.0
     self.box_actor = vtkActor()
     self.label_actor = vtkTextActor3D()
     self.state = None
     self.num_processors = None
     self.properties = None
     self.jobs = []
     self.status = {}
     self.box = vtkCubeSource()
     self.norm_jobs = 0.0
     self.norm_load = 0.0
     self.screen_log = screen_log
     self.logger = logging.getLogger("")
Пример #15
0
def Show(data,pos=(0,0,0)):
    # Show a vtkData by creating a Mapper, an Actor
    # and inserting the Actor in the Renderer.
    # also add a text label with the data classname
    global R
    if data.IsA('vtkPolyData'):
        M = vtk.vtkPolyDataMapper()
    else:
        M = vtk.vtkDataSetMapper()
    M.SetInputData( data )
    A = vtk.vtkActor()
    A.SetMapper(M)
    A.GetProperty().EdgeVisibilityOn()
    A.GetProperty().SetEdgeColor(.3,.3,.3)
    A.SetPosition(pos)    
    TA3 = vtk.vtkTextActor3D()
    TA3.SetInput(data.GetClassName())
    TA3.GetTextProperty().SetFontSize(24)
    TA3.SetScale(.02)
    TA3.SetPosition(pos[0], pos[1]-1, pos[2]+.1)
    R.AddActor(TA3)
    R.AddActor(A)
    return A
Пример #16
0
and acts as a convenient wrapper for a vtkTextMapper/vtkActor2D pair.
Set the text property/attributes through the vtkTextProperty associated
to this actor.
'''

TA = vtk.vtkTextActor()
TA.SetInput('TextActor')
TA.GetTextProperty().SetFontSize(24)
R.AddActor(TA)

'''
vtkTextActor3D: An actor that displays text.
The input text is rendered into a buffer, which in turn
is used as a texture applied onto a quad (a vtkImageActor is used under the hood).
'''
TA3 = vtk.vtkTextActor3D()
TA3.SetInput('TextActor3D')
TA3.GetTextProperty().SetFontSize(24)
TA3.SetScale(.01)
R.AddActor(TA3)

'''
vtkVectorText: create polygonal text
vtkVectorText generates vtkPolyData from an input text string.
Besides the ASCII alphanumeric characters a-z,A-Z, 0-9, vtkVectorText also supports ASCII punctuation marks.
(The supported ASCII character set are the codes (33-126) inclusive.)
The only control character supported is the line feed character "\n", which advances to a new line.
To use thie class, you normally couple it with a vtkPolyDataMapper and a vtkActor.
In this case you would use the vtkActors transformation methods to position, orient, and scale the text.
You may also wish to use a vtkFollower to orient the text so that it always faces the camera.
'''