Import LinuxCNC source tree
This commit is contained in:
271
share/qtvcp/panels/test_dial/test_dial.ui
Normal file
271
share/qtvcp/panels/test_dial/test_dial.ui
Normal file
@@ -0,0 +1,271 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>221</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>221</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLCDNumber" name="lcdNumber_1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="smallDecimalPoint">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="digitCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="segmentStyle">
|
||||
<enum>QLCDNumber::Flat</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="HALLabel" name="hallabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>test</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="scaleText" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textSpaceSample" stdset="0">
|
||||
<string> -10000.0000</string>
|
||||
</property>
|
||||
<property name="bit_pin_type" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="s32_pin_type" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="float_pin_type" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textTemplate" stdset="0">
|
||||
<string>%0.4f</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="Dial" name="dial_1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>44</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="notchesVisible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="pin_name" stdset="0">
|
||||
<string>unscaled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>221</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuScale">
|
||||
<property name="title">
|
||||
<string>Range</string>
|
||||
</property>
|
||||
<addaction name="actionSet_50_50"/>
|
||||
<addaction name="actionSet_100_100"/>
|
||||
<addaction name="actionSet_1000_1000"/>
|
||||
<addaction name="actionSet_0_100"/>
|
||||
<addaction name="actionSet_0_360"/>
|
||||
<addaction name="actionSet_0_1000"/>
|
||||
</widget>
|
||||
<addaction name="menuScale"/>
|
||||
</widget>
|
||||
<action name="actionSet_50_50">
|
||||
<property name="text">
|
||||
<string>+- 50</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_100_100">
|
||||
<property name="text">
|
||||
<string>+-100</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_0_100">
|
||||
<property name="text">
|
||||
<string>0-100</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_0_1000">
|
||||
<property name="text">
|
||||
<string>0-1000</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_1000_1000">
|
||||
<property name="text">
|
||||
<string>+- 1000</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_0_360">
|
||||
<property name="text">
|
||||
<string>0-360</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Dial</class>
|
||||
<extends>QDial</extends>
|
||||
<header>qtvcp.widgets.simple_widgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>HALLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>qtvcp.widgets.hal_label</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>menubar</sender>
|
||||
<signal>triggered(QAction*)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>actionTriggered()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>38</x>
|
||||
<y>12</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>148</x>
|
||||
<y>153</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>dial_1</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>lcdNumber_1</receiver>
|
||||
<slot>display(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>75</x>
|
||||
<y>74</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>99</x>
|
||||
<y>39</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>dial_1</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>valueChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>75</x>
|
||||
<y>114</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>0</x>
|
||||
<y>153</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>actionTriggered()</slot>
|
||||
<slot>valueChanged()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
156
share/qtvcp/panels/test_dial/test_dial_handler.py
Normal file
156
share/qtvcp/panels/test_dial/test_dial_handler.py
Normal file
@@ -0,0 +1,156 @@
|
||||
############################
|
||||
# **** IMPORT SECTION **** #
|
||||
############################
|
||||
import sys
|
||||
from qtpy.QtCore import *
|
||||
from qtpy.QtGui import *
|
||||
from qtpy.QtWidgets import *
|
||||
from qtvcp.core import Status
|
||||
from qtvcp.widgets.simple_widgets import DoubleScale
|
||||
from qtvcp.widgets.hal_selectionbox import HALSelectionBox
|
||||
|
||||
###########################################
|
||||
# **** instantiate libraries section **** #
|
||||
###########################################
|
||||
STATUS = Status()
|
||||
###################################
|
||||
# **** HANDLER CLASS SECTION **** #
|
||||
###################################
|
||||
|
||||
class HandlerClass:
|
||||
|
||||
########################
|
||||
# **** INITIALIZE **** #
|
||||
########################
|
||||
# widgets allows access to widgets from the qtvcp files
|
||||
# at this point the widgets and hal pins are not instantiated
|
||||
def __init__(self, halcomp,widgets,paths):
|
||||
self.w = widgets
|
||||
self.h = halcomp
|
||||
|
||||
##########################################
|
||||
# Special Functions called from QTVCP
|
||||
##########################################
|
||||
|
||||
# at this point:
|
||||
# the widgets are instantiated.
|
||||
# the HAL pins are built but HAL is not set ready
|
||||
def initialized__(self):
|
||||
|
||||
# containers
|
||||
w = QWidget()
|
||||
w.setContentsMargins(0,0,0,0)
|
||||
|
||||
hbox = QHBoxLayout(w)
|
||||
hbox.setContentsMargins(0,0,0,0)
|
||||
|
||||
self.spinbox = DoubleScale()
|
||||
self.spinbox.hal_init('scaled')
|
||||
self.spinbox.setDecimals(4)
|
||||
self.spinbox.floatOutput.connect(self.updateLabel)
|
||||
hbox.addWidget(self.spinbox)
|
||||
|
||||
le = QLineEdit()
|
||||
le.setMaximumWidth(80)
|
||||
le.setText(self.h.comp.getprefix())
|
||||
|
||||
cb = HALSelectionBox()
|
||||
cb.setShowTypes([cb.SIGNALS])
|
||||
cb.setSignalTypes([cb.HAL_FLOAT], driven = [False,True])
|
||||
cb.hal_init()
|
||||
cb.currentTextChanged.connect(self.signalSelected)
|
||||
hbox.addWidget(cb)
|
||||
|
||||
# add those to the corner of the right tab widget
|
||||
self.w.menubar.setCornerWidget(w)
|
||||
|
||||
# make sure scalewidgets get proper starting values
|
||||
self.w.dial_1.valueChanged.emit(self.w.dial_1.value())
|
||||
|
||||
self.w.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||
self.w.setWindowTitle('{}'.format(self.h.comp.getprefix()))
|
||||
|
||||
########################
|
||||
# callbacks from STATUS #
|
||||
########################
|
||||
|
||||
#######################
|
||||
# callbacks from form #
|
||||
#######################
|
||||
def actionTriggered(self, data):
|
||||
if data == self.w.actionSet_50_50:
|
||||
self.w.dial_1.setMinimum(-50)
|
||||
self.w.dial_1.setMaximum(50)
|
||||
self.w.setWindowTitle('(+-50)')
|
||||
elif data == self.w.actionSet_100_100:
|
||||
self.w.dial_1.setMinimum(-100)
|
||||
self.w.dial_1.setMaximum(100)
|
||||
self.w.setWindowTitle('(+-100)')
|
||||
elif data == self.w.actionSet_1000_1000:
|
||||
self.w.dial_1.setMinimum(-1000)
|
||||
self.w.dial_1.setMaximum(1000)
|
||||
self.w.setWindowTitle('(+-1000)')
|
||||
elif data == self.w.actionSet_0_100:
|
||||
self.w.dial_1.setMinimum(0)
|
||||
self.w.dial_1.setMaximum(100)
|
||||
self.w.setWindowTitle('(0-100)')
|
||||
elif data == self.w.actionSet_0_360:
|
||||
self.w.dial_1.setMinimum(0)
|
||||
self.w.dial_1.setMaximum(360)
|
||||
self.w.setWindowTitle('(0-360)')
|
||||
elif data == self.w.actionSet_0_1000:
|
||||
self.w.dial_1.setMinimum(0)
|
||||
self.w.dial_1.setMaximum(1000)
|
||||
self.w.setWindowTitle('(0-1000)')
|
||||
|
||||
def valueChanged(self, value):
|
||||
self.spinbox.setInput(value)
|
||||
|
||||
#####################
|
||||
# general functions #
|
||||
#####################
|
||||
|
||||
def updateLabel(self,v):
|
||||
self.w.hallabel.setDisplay(v)
|
||||
|
||||
def signalSelected(self, sig):
|
||||
pname = self.spinbox.get_full_pinname(self.spinbox.hal_pin_f)
|
||||
if sig == 'None':
|
||||
self.h.hal.disconnect(pname)
|
||||
else:
|
||||
# suppress error messages
|
||||
l = self.h.hal.get_msg_level()
|
||||
self.h.hal.set_msg_level(0)
|
||||
|
||||
res = self.h.hal.connect(pname,sig)
|
||||
if res:
|
||||
self.h.hal.disconnect(pname)
|
||||
self.h.hal.connect(pname,sig)
|
||||
|
||||
# restore error messages
|
||||
self.h.hal.set_msg_level(l)
|
||||
|
||||
#####################
|
||||
# KEY BINDING CALLS #
|
||||
#####################
|
||||
|
||||
###########################
|
||||
# **** closing event **** #
|
||||
###########################
|
||||
|
||||
##############################
|
||||
# required class boiler code #
|
||||
##############################
|
||||
|
||||
def __getitem__(self, item):
|
||||
return getattr(self, item)
|
||||
def __setitem__(self, item, value):
|
||||
return setattr(self, item, value)
|
||||
|
||||
|
||||
################################
|
||||
# required handler boiler code #
|
||||
################################
|
||||
|
||||
def get_handlers(halcomp,widgets,paths):
|
||||
return [HandlerClass(halcomp,widgets,paths)]
|
||||
Reference in New Issue
Block a user