Ejemplo n.º 1
0
    def __init__(self, parent=None, inputObjectName=""):
        super(ProbeParamInputWidget, self).__init__(parent)
        uic.loadUi(UI_FILE, self)

        labelSetting = getSetting("probewizard." + inputObjectName)
        if labelSetting != None:
            self.param_label.setText(labelSetting.__doc__ + ":")

        self.param_input.setObjectName(inputObjectName)
        valueSetting = getSetting("probewizard." + inputObjectName)
        if valueSetting != None:
            self.param_input.setText(str(valueSetting.value))
Ejemplo n.º 2
0
    def __init__(self, camera, path_actor):
        super(ProgramBoundsActor, self).__init__()

        self.path_actor = path_actor

        """
        for k, v in VTKBackPlot.__dict__.items():
            if "function" in str(v):
                LOG.debug(k)

        for attr_name in dir(VTKBackPlot):
            attr_value = getattr(VTKBackPlot, attr_name)
            LOG.debug(attr_name, attr_value, callable(attr_value))

        LOG.debug(dir(VTKBackPlot))
        testit = getattr(VTKBackPlot, '_enableProgramTicks')
        LOG.debug('enableProgramTicks {}'.format(testit))
        """

        self.SetBounds(self.path_actor.GetBounds())

        self.SetCamera(camera)

        self.SetXLabelFormat("%6.3f")
        self.SetYLabelFormat("%6.3f")
        self.SetZLabelFormat("%6.3f")

        self.SetFlyModeToStaticEdges()

        self.GetTitleTextProperty(0).SetColor(1.0, 0.0, 0.0)
        self.GetLabelTextProperty(0).SetColor(1.0, 0.0, 0.0)

        self.GetTitleTextProperty(1).SetColor(0.0, 1.0, 0.0)
        self.GetLabelTextProperty(1).SetColor(0.0, 1.0, 0.0)

        self.GetTitleTextProperty(2).SetColor(0.0, 0.0, 1.0)
        self.GetLabelTextProperty(2).SetColor(0.0, 0.0, 1.0)

        if not IN_DESIGNER:
            bounds = getSetting('backplot.show-program-bounds')
            self.showProgramBounds(bounds and bounds.value)

            ticks = getSetting('backplot.show-program-ticks')
            self.showProgramTicks(ticks and ticks.value)

            labels = getSetting('backplot.show-program-labels')
            self.showProgramLabels(labels and labels.value)
Ejemplo n.º 3
0
    def __init__(self, camera, path_actor):
        super(ProgramBoundsActor, self).__init__()

        self.path_actor = path_actor
        """
        for k, v in VTKBackPlot.__dict__.items():
            if "function" in str(v):
                LOG.debug(k)

        for attr_name in dir(VTKBackPlot):
            attr_value = getattr(VTKBackPlot, attr_name)
            LOG.debug(attr_name, attr_value, callable(attr_value))
        
        LOG.debug(dir(VTKBackPlot))
        testit = getattr(VTKBackPlot, '_enableProgramTicks')
        LOG.debug('enableProgramTicks {}'.format(testit))
        """

        self.SetCamera(camera)

        self.SetNumberOfLabels(3)

        x_min, x_max, y_min, y_max, z_min, z_max = self.path_actor.GetBounds()

        self.SetBounds(x_min, x_max, y_min, y_max, z_min, z_max)

        corner_offset = 0.0
        self.SetCornerOffset(corner_offset)

        self.SetUseRanges(1)

        self.SetRanges(0, x_max - x_min, 0, y_max - y_min, 0, z_max - z_min)

        self.SetLabelFormat("%6.3f")

        self.SetFlyModeToOuterEdges()

        self.SetScaling(False)
        self.SetShowActualBounds(1)

        x_actor = self.GetXAxisActor2D()
        y_actor = self.GetYAxisActor2D()
        z_actor = self.GetZAxisActor2D()

        x_actor.SetLabelFactor(5)
        y_actor.SetLabelFactor(5)
        z_actor.SetLabelFactor(5)

        label_properties = self.GetAxisLabelTextProperty()

        label_properties.SetOrientation(30)
        label_properties.SetLineOffset(5)

        self.SetAxisLabelTextProperty(label_properties)

        if not IN_DESIGNER:
            bounds = getSetting('backplot.show-program-bounds')
            self.showProgramBounds(bounds and bounds.value)
Ejemplo n.º 4
0
    def initialize(self):
        getattr(self.pos, self._ref_typ.name).notify(self.updateValue)
        self.updateValue()

        if self._is_lathe:
            self.status.gcodes.notify(self.updateDiameterMode)

        if self._use_global_fmt_settings:

            self.in_fmt_setting = getSetting('dro.inch-format')
            self.mm_fmt_setting = getSetting('dro.millimeter-format')
            self.deg_fmt_setting = getSetting('dro.degree-format')
            self.lathe_mode_setting = getSetting('dro.lathe-radius-mode')

            try:
                self.in_fmt_setting.notify(self.setInchFormat)
                self.mm_fmt_setting.notify(self.setMillimeterFormat)
                self.deg_fmt_setting.notify(self.setDegreeFormat)
                self.lathe_mode_setting.notify(self.setLatheMode)

            except AttributeError:  # settings not found
                pass
Ejemplo n.º 5
0
    def getMenuAction(self, menu, title='notitle', action_name='noaction',
                      args=[], kwargs={}):
        # ToDo: Clean this up, it is very hacky
        env = {'app': QApplication.instance(),
               'win': self,
               'action': actions,
               }

        if action_name is not None:

            if action_name.startswith('settings.'):
                setting_id = action_name[len('settings.'):]
                setting = getSetting(setting_id)

                if setting:
                    if setting.enum_options is not None:
                        submenu = QMenu(parent=self, title=title)

                        group = QActionGroup(self)
                        group.setExclusive(True)
                        group.triggered.connect(lambda a: setting.setValue(a.data()))

                        def update(group, val):
                            for act in group.actions():
                                if act.data() == val:
                                    act.setChecked(True)
                                    break

                        for num, opt in enumerate(setting.enum_options):

                            act = QAction(parent=self, text=opt)
                            act.setCheckable(True)
                            if setting.value == num:
                                act.setChecked(True)

                            act.setData(num)
                            setting.notify(lambda v: update(group, v))

                            act.setActionGroup(group)
                            submenu.addAction(act)
                        menu.addMenu(submenu)

                    elif setting.value_type == bool:
                        # works for bool settings
                        menu_action = QAction(parent=self, text=title)
                        menu_action.setCheckable(True)
                        menu_action.triggered.connect(setting.setValue)
                        setting.notify(menu_action.setChecked)
                        menu.addAction(menu_action)

                    return

            try:
                menu_action = QAction(parent=self, text=title)

                mod, action = action_name.split('.', 1)
                method = getattr(env.get(mod, self), action)
                if menu_action.isCheckable():
                    menu_action.triggered.connect(method)
                else:
                    menu_action.triggered.connect(lambda checked: method(*args, **kwargs))

                menu.addAction(menu_action)
                return
            except:
                pass

            try:
                menu_action = QAction(parent=self, text=title)
                actions.bindWidget(menu_action, action_name)
                menu.addAction(menu_action)
                return
            except actions.InvalidAction:
                LOG.exception('Error binding menu action %s', action_name)

        menu_action = QAction(parent=self, text=title)
        msg = "The <b>{}</b> action specified for the " \
              "<b>{}</b> menu item could not be triggered. " \
              "Check the YAML config file for errors." \
              .format(action_name or '', title.replace('&', ''))
        menu_action.triggered.connect(lambda: QMessageBox.critical(self, "Menu Action Error!", msg))
        menu.addAction(menu_action)