import linuxcnc
from pyqtgraph import Qt

from qtpy import uic
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QWidget, QMessageBox

from qtpyvcp.actions.program_actions import load as loadProgram
from qtpyvcp.plugins import getPlugin
from qtpyvcp.utilities import logger

from qtpyvcp_conversational_gcode.ops.gcode_file import GCodeFile

LOG = logger.getLogger(__name__)

STATUS = getPlugin('status')
TOOL_TABLE = getPlugin('tooltable')

INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
PROGRAM_PREFIX = os.path.expandvars(
    os.path.expanduser(INI_FILE.find('DISPLAY', 'PROGRAM_PREFIX') or '/tmp'))
DEFAULT_SPINDLE_SPEED = float(
    INI_FILE.find('DISPLAY', 'DEFAULT_SPINDLE_SPEED') or 0.000)
DEFAULT_LINEAR_VELOCITY = float(
    INI_FILE.find('DISPLAY', 'DEFAULT_LINEAR_VELOCITY') or 0.000)


class ConversationalBaseWidget(QWidget):
    def __init__(self, parent=None, ui_file=''):
        super(ConversationalBaseWidget, self).__init__(parent)
        uic.loadUi(os.path.join(os.path.dirname(__file__), ui_file), self)
Ejemplo n.º 2
0
import linuxcnc
from qtpy.QtWidgets import QComboBox

from qtpyvcp.utilities.settings import setting

# Set up logging
from qtpyvcp.utilities import logger
LOG = logger.getLogger(__name__)

from qtpyvcp.actions.base_actions import setTaskMode
from qtpyvcp.plugins import getPlugin

STATUS = getPlugin('status')
STAT = STATUS.stat

from qtpyvcp.utilities.info import Info
INFO = Info()
CMD = linuxcnc.command()


# -------------------------------------------------------------------------
# E-STOP action
# -------------------------------------------------------------------------
class estop:
    """E-Stop action group"""
    @staticmethod
    def activate():
        """Set E-Stop active"""
        LOG.debug("Setting state red<ESTOP>")
        CMD.state(linuxcnc.STATE_ESTOP)
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        super(NotificationWidget, self).__init__(parent)
        self.notification_channel = getPlugin("notifications")

        self.main_layout = QVBoxLayout()
        self.button_layout = QHBoxLayout()

        self.all_button = QPushButton()
        self.info_button = QPushButton()
        self.warn_button = QPushButton()
        self.error_button = QPushButton()
        self.debug_button = QPushButton()
        self.clear_button = QPushButton()

        self.all_button.setText("all")
        self.info_button.setText("info")
        self.warn_button.setText("warn")
        self.error_button.setText("error")
        self.debug_button.setText("debug")
        self.clear_button.setText("clear")

        self.all_button.setCheckable(True)
        self.info_button.setCheckable(True)
        self.warn_button.setCheckable(True)
        self.error_button.setCheckable(True)
        self.debug_button.setCheckable(True)

        self.all_button.setChecked(True)
        self.info_button.setChecked(False)
        self.warn_button.setChecked(False)
        self.error_button.setChecked(False)
        self.debug_button.setChecked(False)

        self.clear_button.clicked.connect(self.clear_all_notifications)

        self.button_layout.addWidget(self.all_button)
        self.button_layout.addWidget(self.info_button)
        self.button_layout.addWidget(self.warn_button)
        self.button_layout.addWidget(self.error_button)
        self.button_layout.addWidget(self.debug_button)
        self.button_layout.addWidget(self.clear_button)

        self.notification_name = QLabel()
        self.notification_name.setAlignment(Qt.AlignCenter)
        self.notification_name.setText("All Notifications")

        self.all_notification_view = QListView()

        self.all_notification_model = QStandardItemModel(
            self.all_notification_view)
        self.all_notification_model_proxy = QSortFilterProxyModel(
            self.all_notification_view)

        self.all_notification_model_proxy.setSourceModel(
            self.all_notification_model)

        # self.all_notification_view.setModel(self.all_notification_model)
        self.all_notification_view.setModel(self.all_notification_model_proxy)

        self.all_notifications = list()

        self.main_layout.addWidget(self.notification_name)
        self.main_layout.addWidget(self.all_notification_view)
        self.main_layout.addLayout(self.button_layout)

        self.setLayout(self.main_layout)

        self.notification_channel.info_message.notify(self.on_info_message)
        self.notification_channel.warn_message.notify(self.on_warn_message)
        self.notification_channel.error_message.notify(self.on_error_message)
        self.notification_channel.debug_message.notify(self.on_debug_message)

        self.all_button.clicked.connect(self.show_all_notifications)
        self.info_button.clicked.connect(self.show_info_notifications)
        self.warn_button.clicked.connect(self.show_warn_notifications)
        self.error_button.clicked.connect(self.show_error_notifications)
        self.debug_button.clicked.connect(self.show_debug_notifications)
Ejemplo n.º 4
0
#
#   QtPyVCP is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with QtPyVCP.  If not, see <http://www.gnu.org/licenses/>.

import os

from qtpy.QtWidgets import QLabel
from qtpy.QtCore import Slot, Property

from qtpyvcp.plugins import getPlugin
STATUS = getPlugin('status')
POSITION = getPlugin('position')

from qtpyvcp.widgets import VCPWidget

IN_DESIGNER = os.getenv('DESIGNER') != None

class Axis(object):
    ALL = -1
    X, Y, Z, A, B, C, U, V, W = range(9)

class Units(object):
    Program = 0 # Use program units
    Inch = 1    # CANON_UNITS_INCHES=1
    Metric = 2  # CANON_UNITS_MM=2
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(SmartDro, self).__init__(parent)
        uic.loadUi(UI_FILE, self)
        self.STATUS = getPlugin('status')

        self.STATUS.interp_state.notify(self.__update_ui)
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        super(MyMainWindow, self).__init__(*args, **kwargs)

        self.vtkbackplot.setViewPath()

        self._initialMainPage = MainScreenPage.MAIN
        self._initialLeftTopPage = 0
        self._pageBeforeCodesOpen = 0

        self.btnManual.clicked.connect(self.setManualScreen)
        self.btnMdi.clicked.connect(self.setMdiScreen)
        self.btnProgram.clicked.connect(self.setProgramScreen)
        self.btnLoadGCode.clicked.connect(self.loadGCode)
        self.buttonChangeProgram.clicked.connect(self.changeProgram)
        self.buttonGroupMdi.buttonClicked.connect(self.mdiHandleKeys)
        self.btnTools.clicked.connect(self.showToolsPage)
        self.btnOffsets.clicked.connect(self.showOffsetsPage)
        self.btnProbing.clicked.connect(self.showProbingPage)
        self.btnSettings.clicked.connect(self.showSettingsPage)
        self.btnStatus.clicked.connect(self.showStatusPage)
        self.btnActiveCodes.clicked.connect(self.showCodesPage)
        self.probewizardwidget.probingCodeReady.connect(self.loadGCode)
        self.probewizardwidget.probingFinished.connect(
            self.handleProbingFinished)
        self.spindlewidget.measureTool.connect(self.toggleMeasureFlag)
        self.notificationswidget.notificationsCleared.connect(
            self.hideNotifications)
        self.btnToolTouchOff.clicked.connect(self.toolTouchOff)
        self.applyYOffsetCheckBox.clicked.connect(self.applyYOffset)

        self.STATUS = getPlugin('status')
        self.STATUS.gcodes.notify(self.setActiveCodesButtonText)
        self.STATUS.mcodes.notify(self.setActiveCodesButtonText)
        self.setActiveCodesButtonText()

        self.STATUS.task_mode.notify(self.setMainButtonsState)
        self.STATUS.interp_state.notify(self.setMainButtonsState)
        self.setMainButtonsState()

        self.STATUS.tool_in_spindle.notify(self.resetMeasureFlag)

        self.comp = hal.component('mindovercnc')
        self.comp.addPin(MindOverCncHalPins.MEASURE_TOOL, 'bit', 'in')
        self.comp.addPin(MindOverCncHalPins.TOOL_PROBE_X, 'float', 'out')
        self.comp.addPin(MindOverCncHalPins.TOOL_PROBE_Y, 'float', 'out')
        self.comp.addPin(MindOverCncHalPins.TOOL_PROBE_Z, 'float', 'out')
        self.comp.addPin(MindOverCncHalPins.MAX_Z_TRAVEL, 'float', 'out')
        self.comp.addPin(MindOverCncHalPins.SPINDLE_NOSE_HEIGHT, 'float',
                         'out')
        self.comp.addPin(MindOverCncHalPins.FAST_PROBE_RATE, 'float', 'out')
        self.comp.addPin(MindOverCncHalPins.RETRACT_DISTANCE, 'float', 'out')
        self.comp.addPin(MindOverCncHalPins.SLOW_PROBE_RATE, 'float', 'out')

        self.comp.addPin(MindOverCncHalPins.TOUCH_PROBE_PLUGGED, 'bit', 'in')
        self.comp.addPin(MindOverCncHalPins.TOUCH_PROBE_TRIPPED, 'bit', 'in')
        self.comp.addListener(MindOverCncHalPins.TOUCH_PROBE_PLUGGED,
                              self.onProbePlugged)
        self.comp.addListener(MindOverCncHalPins.TOUCH_PROBE_TRIPPED,
                              self.onProbeTripped)
        self.comp.ready()

        self.updateHalPinsWithCurrentSettings()
Ejemplo n.º 7
0
    def __init__(self,
                 parent=None,
                 opts=None,
                 ui_file=None,
                 stylesheet=None,
                 maximize=False,
                 fullscreen=False,
                 position=None,
                 size=None,
                 confirm_exit=True,
                 title=None,
                 menu='default'):

        super(VCPMainWindow, self).__init__(parent)

        if opts is None:
            opts = qtpyvcp.OPTIONS

        self.setWindowTitle(title)

        self.app = QApplication.instance()
        self.status = getPlugin('status')

        self.confirm_exit = confirm_exit if opts.confirm_exit is None else opts.confirm_exit

        # Load the UI file AFTER defining variables, otherwise the values
        # set in QtDesigner get overridden by the default values
        if ui_file is not None:
            self.loadUi(ui_file)
            self.initUi()

        if menu is not None:
            try:
                # delete any preexisting menuBar added in QtDesigner
                # because it shadows the QMainWindow.menuBar() method
                del self.menuBar
            except AttributeError:
                pass

            if menu == 'default':
                menu = qtpyvcp.CONFIG.get('default_menubar', [])

            self.setMenuBar(self.buildMenuBar(menu))

        if title is not None:
            self.setWindowTitle(title)

        if stylesheet is not None:
            self.loadStylesheet(stylesheet)

        maximize = opts.maximize if opts.maximize is not None else maximize
        if maximize:
            QTimer.singleShot(0, self.showMaximized)

        fullscreen = opts.fullscreen if opts.fullscreen is not None else fullscreen
        if fullscreen:
            QTimer.singleShot(0, self.showFullScreen)

        if opts.hide_menu_bar:
            self.menuBar().hide()

        size = opts.size or size
        if size:
            try:
                width, height = size.lower().split('x')
                self.resize(int(width), int(height))
            except:
                LOG.exception('Error parsing --size argument: %s', size)

        pos = opts.position or position
        if pos:
            try:
                xpos, ypos = pos.lower().split('x')
                self.move(int(xpos), int(ypos))
            except:
                LOG.exception('Error parsing --position argument: %s', pos)

        QShortcut(QKeySequence("F11"), self, self.toggleFullscreen)
        self.app.focusChanged.connect(self.focusChangedEvent)