def checkFont(self,name,value):
     if (value == None):
          pass
     elif isNumber(value,min=1):
          value=int(value)
          # try to see if font exists
          nm = vcs.getfontname(value)
     elif isinstance(value,str):
          value = vcs.getfontnumber(value)
     else:
          nms = vcs.listelements("font")
          raise ValueError, 'Error for attribute %s: The font attribute values must be a valid font number or a valid font name. valid names are: %s' % (name,', '.join(nms))
     return value
Exemple #2
0
    def __init__(self, interactor, label, dp, configurator):
        self.label = label
        self.display = dp
        super(LabelEditor, self).__init__(interactor, label, configurator)

        self.toolbar = vcs.vtk_ui.Toolbar(self.interactor,
                                          "%s Options" % label.member)
        template = vcs.gettemplate(dp.template)

        self.actor = get_actor(self.label, self.display)

        tprop = self.actor.GetTextProperty()
        self.real_bg = tprop.GetBackgroundColor()
        self.real_bg_opacity = tprop.GetBackgroundOpacity()

        tprop.SetBackgroundColor(contrasting_color(*tprop.GetColor()))
        tprop.SetBackgroundOpacity(.85)

        text_types_name = template.name + "_" + label.member

        try:
            self.tt = vcs.gettexttable(text_types_name)
            self.to = vcs.gettextorientation(text_types_name)
        except ValueError:
            self.tt = vcs.createtexttable(text_types_name, label.texttable)
            self.to = vcs.createtextorientation(text_types_name,
                                                label.textorientation)

        self.height_button = self.toolbar.add_slider_button(
            self.to.height, 1, 100, "Height", update=self.update_height)

        halign = self.toolbar.add_button(
            ["Left Align", "Center Align", "Right Align"], action=self.halign)
        valign = self.toolbar.add_button(
            ["Top Align", "Half Align", "Bottom Align"], action=self.valign)

        halign.set_state(self.to.halign)
        valign.set_state(__valign_map__[self.to.valign])

        self.angle_button = self.toolbar.add_slider_button(
            self.to.angle, 0, 360, "Angle", update=self.update_angle)

        self.picker = None
        self.toolbar.add_button(["Change Color"], action=self.change_color)
        # Adds itself to self.toolbar automatically
        FontEditor(self.toolbar,
                   self.set_font,
                   current_font=vcs.getfontname(self.tt.font))
        self.toolbar.show()
        self.label.texttable = self.tt.name
        self.label.textorientation = self.to.name
Exemple #3
0
def checkFont(self, name, value):
    if (value == None):
        pass
    elif isNumber(value, min=1):
        value = int(value)
        # try to see if font exists
        nm = vcs.getfontname(value)
    elif isinstance(value, str):
        value = vcs.getfontnumber(value)
    else:
        nms = vcs.listelements("font")
        checkedRaise(
            self, value, ValueError,
            'Error for attribute %s: The font attribute values must be a valid font number or a valid font name. valid names are: %s'
            % (name, ', '.join(nms)))
    return value
Exemple #4
0
    def __init__(self, interactor, label, dp, configurator):
        self.label = label
        self.display = dp
        super(LabelEditor, self).__init__(interactor, label, configurator)

        self.toolbar = vcs.vtk_ui.Toolbar(
            self.interactor,
            "%s Options" %
            label.member)
        template = vcs.gettemplate(dp.template)

        self.actor = get_actor(self.label, self.display)

        tprop = self.actor.GetTextProperty()
        self.real_bg = tprop.GetBackgroundColor()
        self.real_bg_opacity = tprop.GetBackgroundOpacity()

        tprop.SetBackgroundColor(contrasting_color(*tprop.GetColor()))
        tprop.SetBackgroundOpacity(.85)

        text_types_name = template.name + "_" + label.member

        try:
            self.tt = vcs.gettexttable(text_types_name)
            self.to = vcs.gettextorientation(text_types_name)
        except ValueError:
            self.tt = vcs.createtexttable(text_types_name, label.texttable)
            self.to = vcs.createtextorientation(
                text_types_name,
                label.textorientation)

        self.height_button = self.toolbar.add_slider_button(
            self.to.height,
            1,
            100,
            "Height",
            update=self.update_height)

        halign = self.toolbar.add_button(
            ["Left Align", "Center Align", "Right Align"], action=self.halign)
        valign = self.toolbar.add_button(
            ["Top Align", "Half Align", "Bottom Align"], action=self.valign)

        halign.set_state(self.to.halign)
        valign.set_state(__valign_map__[self.to.valign])

        self.angle_button = self.toolbar.add_slider_button(
            self.to.angle,
            0,
            360,
            "Angle",
            update=self.update_angle)

        self.picker = None
        self.toolbar.add_button(["Change Color"], action=self.change_color)
        # Adds itself to self.toolbar automatically
        FontEditor(self.toolbar, self.set_font,
                   current_font=vcs.getfontname(self.tt.font))
        self.toolbar.show()
        self.label.texttable = self.tt.name
        self.label.textorientation = self.to.name
Exemple #5
0
    def __init__(self, interactor, text, index, dp, configurator):

        self.interactor = interactor
        self.text = text

        self.display = dp
        self.actors = dp.backend["vtk_backend_text_actors"]

        self.index = index
        self.configurator = configurator

        for actor in self.actors:
            actor.SetVisibility(0)

        self.textboxes = None

        self.toolbar = Toolbar(self.interactor, "Text Options")
        self.toolbar.add_slider_button(
            text.height,
            1,
            100,
            "Height",
            update=self.update_height)

        halign = self.toolbar.add_button(
            ["Left Align", "Center Align", "Right Align"], action=self.halign)
        valign = self.toolbar.add_button(
            ["Top Align", "Half Align", "Bottom Align"], action=self.valign)
        halign.set_state(self.text.halign)
        valign.set_state(__valign_map__[self.text.valign])

        self.toolbar.add_slider_button(
            text.angle,
            0,
            360,
            "Angle",
            update=self.update_angle)

        self.picker = None
        self.toolbar.add_button(["Change Color"], action=self.change_color)
        self.toolbar.show()

        # Adds itself to self.toolbar automatically
        FontEditor(self.toolbar, self.set_font,
                   current_font=vcs.getfontname(text.font))

        prop = vtkTextProperty()
        prop.SetBackgroundColor(.87, .79, .55)
        prop.SetBackgroundOpacity(1)
        prop.SetColor(0, 0, 0)
        prop.SetVerticalJustificationToTop()
        self.tooltip = Label(
            self.interactor,
            "%s + Click to place new text." %
            ("Cmd" if sys.platform == "darwin" else "Ctrl"),
            textproperty=prop)
        self.tooltip.left = 0
        self.tooltip.top = self.interactor.GetRenderWindow(
        ).GetSize()[1] - self.tooltip.get_dimensions()[1]
        self.tooltip.show()
        super(TextEditor, self).__init__()
        self.register()
        self.update()