Beispiel #1
0
    def __init__(self, parent=None):
        super(Lcnc_3dGraphics, self).__init__(parent)
        glnav.GlNavBase.__init__(self)

        def C(s):
            a = self.colors[s + "_alpha"]
            s = self.colors[s]
            return [int(x * 255) for x in s + (a, )]

        # requires linuxcnc running before laoding this widget
        inifile = os.environ.get('INI_FILE_NAME', '/dev/null')

        # if status is not available then we are probably
        # displaying in designer so fake it
        stat = linuxcnc.stat()
        try:
            stat.poll()
        except:
            LOG.warning(
                'linuxcnc staus failed, Assuming linuxcnc is not running so using fake status for a XYZ machine'
            )
            stat = fakeStatus()

        self.inifile = linuxcnc.ini(inifile)
        self.logger = linuxcnc.positionlogger(linuxcnc.stat(),
                                              C('backplotjog'),
                                              C('backplottraverse'),
                                              C('backplotfeed'),
                                              C('backplotarc'),
                                              C('backplottoolchange'),
                                              C('backplotprobing'),
                                              self.get_geometry())
        # start tracking linuxcnc position so we can plot it
        _thread.start_new_thread(self.logger.start, (.01, ))
        glcanon.GlCanonDraw.__init__(self, stat, self.logger)

        # set defaults
        self.current_view = 'p'
        self.fingerprint = ()
        self.select_primed = None
        self.lat = 0
        self.minlat = -90
        self.maxlat = 90

        self._current_file = None
        self.highlight_line = None
        self.program_alpha = False
        self.use_joints_mode = False
        self.use_commanded = True
        self.show_limits = True
        self.show_extents_option = True
        self.gcode_properties = None
        self.show_live_plot = True
        self.show_velocity = True
        self.metric_units = True
        self.show_program = True
        self.show_rapids = True
        self.use_relative = True
        self.show_tool = True
        self.show_lathe_radius = False
        self.show_dtg = True
        self.grid_size = 0.0
        temp = self.inifile.find("DISPLAY", "LATHE")
        self.lathe_option = bool(temp == "1" or temp == "True"
                                 or temp == "true")
        self.foam_option = bool(self.inifile.find("DISPLAY", "FOAM"))
        self.show_offsets = False
        self.show_overlay = False
        self.enable_dro = False
        self.use_default_controls = True
        self.mouse_btn_mode = 0
        self.cancel_rotate = False
        self.use_gradient_background = False
        self.gradient_color1 = (0.0, 0.0, 1)
        self.gradient_color2 = (0.0, 0.0, 0.0)
        self.a_axis_wrapped = self.inifile.find("AXIS_A", "WRAPPED_ROTARY")
        self.b_axis_wrapped = self.inifile.find("AXIS_B", "WRAPPED_ROTARY")
        self.c_axis_wrapped = self.inifile.find("AXIS_C", "WRAPPED_ROTARY")

        live_axis_count = 0
        for i, j in enumerate("XYZABCUVW"):
            if self.stat.axis_mask & (1 << i) == 0: continue
            live_axis_count += 1
        self.num_joints = int(
            self.inifile.find("KINS", "JOINTS") or live_axis_count)

        self.object = 0
        self.xRot = 0
        self.yRot = 0
        self.zRot = 0

        self.Green = QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
        self.inhibit_selection = True

        self.dro_in = "% 9.4f"
        self.dro_mm = "% 9.3f"
        self.dro_deg = "% 9.2f"
        self.dro_vel = "   Vel:% 9.2F"
        self.addTimer()
Beispiel #2
0
    def __init__(self, parent=None):
        super(Lcnc_3dGraphics, self).__init__(parent)
        glnav.GlNavBase.__init__(self)

        def C(s):
            a = self.colors[s + "_alpha"]
            s = self.colors[s]
            return [int(x * 255) for x in s + (a, )]

        # requires linuxcnc running before loading this widget
        inifile = os.environ.get('INI_FILE_NAME', '/dev/null')

        # if status is not available then we are probably
        # displaying in designer so fake it
        stat = linuxcnc.stat()
        try:
            stat.poll()
        except:
            LOG.warning(
                'linuxcnc status failed, Assuming linuxcnc is not running so using fake status for a XYZ machine'
            )
            stat = fakeStatus()

        self.inifile = linuxcnc.ini(inifile)
        self.foam_option = bool(self.inifile.find("DISPLAY", "FOAM"))
        try:
            trajcoordinates = self.inifile.find("TRAJ",
                                                "COORDINATES").lower().replace(
                                                    " ", "")
        except:
            trajcoordinates = "unknown"
            #raise SystemExit("Missing [TRAJ]COORDINATES")
        kinsmodule = self.inifile.find("KINS", "KINEMATICS")

        self.logger = linuxcnc.positionlogger(linuxcnc.stat(),
                                              C('backplotjog'),
                                              C('backplottraverse'),
                                              C('backplotfeed'),
                                              C('backplotarc'),
                                              C('backplottoolchange'),
                                              C('backplotprobing'),
                                              self.get_geometry(),
                                              self.foam_option)
        # start tracking linuxcnc position so we can plot it
        _thread.start_new_thread(self.logger.start, (.01, ))
        glcanon.GlCanonDraw.__init__(self, stat, self.logger)
        glcanon.GlCanonDraw.init_glcanondraw(self,
                                             trajcoordinates=trajcoordinates,
                                             kinsmodule=kinsmodule)

        # set defaults
        self.display_loaded = False
        self.current_view = 'p'
        self.fingerprint = ()
        self.select_primed = None
        self.lat = 0
        self.minlat = -90
        self.maxlat = 90

        self._current_file = None
        self.highlight_line = None
        self.program_alpha = False
        self.use_joints_mode = True
        self.use_commanded = True
        self.show_limits = True
        self.show_extents_option = True
        self.gcode_properties = None
        self.show_live_plot = True
        self.show_velocity = True
        self.metric_units = True
        self.show_program = True
        self.show_rapids = True
        self.use_relative = True
        self.show_tool = True
        self.show_lathe_radius = False
        self.show_dtg = True
        self.grid_size = 0.0
        temp = self.inifile.find("DISPLAY", "LATHE")
        self.lathe_option = bool(temp == "1" or temp == "True"
                                 or temp == "true")

        self.show_offsets = False
        self.show_overlay = False
        self.enable_dro = False
        self.use_default_controls = True
        self.mouse_btn_mode = 0
        self.cancel_rotate = False
        self.use_gradient_background = False
        self.gradient_color1 = (0.0, 0.0, 1)
        self.gradient_color2 = (0.0, 0.0, 0.0)
        self.a_axis_wrapped = self.inifile.find("AXIS_A", "WRAPPED_ROTARY")
        self.b_axis_wrapped = self.inifile.find("AXIS_B", "WRAPPED_ROTARY")
        self.c_axis_wrapped = self.inifile.find("AXIS_C", "WRAPPED_ROTARY")

        live_axis_count = 0
        for i, j in enumerate("XYZABCUVW"):
            if self.stat.axis_mask & (1 << i) == 0: continue
            live_axis_count += 1
        self.num_joints = int(
            self.inifile.find("KINS", "JOINTS") or live_axis_count)

        # initialize variables for user view
        self.presetViewSettings(v=None, z=0, x=0, y=0, lat=None, lon=None)
        # allow anyone else to preset user view with better settings
        self._presetFlag = False

        self.object = 0
        self.xRot = 0
        self.yRot = 0
        self.zRot = 0

        self.Green = QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
        self.inhibit_selection = True

        self.dro_in = "% 9.4f"
        self.dro_mm = "% 9.3f"
        self.dro_deg = "% 9.2f"
        self.dro_vel = "   Vel:% 9.2F"
        self._font = 'monospace bold 16'
        self.addTimer()
        self._buttonList = [Qt.LeftButton, Qt.MiddleButton, Qt.RightButton]
        self._invertWheelZoom = False