Skip to content

Commit

Permalink
renamed FloatWithUnit -> WidgetFloatWithUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Dec 14, 2023
1 parent 4f59430 commit ed1d0f3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 36 deletions.
4 changes: 2 additions & 2 deletions weldx_widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Weldx widgets."""
from .generic import WidgetSaveButton, WidgetTimeSeries
from .widget_factory import FloatWithUnit, WidgetLabeledTextInput
from .widget_factory import WidgetFloatWithUnit, WidgetLabeledTextInput
from .widget_gas import WidgetShieldingGas
from .widget_gmaw import WidgetGMAW
from .widget_groove_sel import WidgetGrooveSelection, WidgetGrooveSelectionTCPMovement
Expand All @@ -13,7 +13,7 @@
WidgetLabeledTextInput,
WidgetSaveButton,
WidgetGMAW,
FloatWithUnit, # TODO: rename
WidgetFloatWithUnit,
]
__all__ = map(str, (x.__name__ for x in __all__))

Expand Down
9 changes: 0 additions & 9 deletions weldx_widgets/widget_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
class WeldxImportExport(abc.ABC):
"""Abstract import and export interfaces for weldx data exchange."""

@staticmethod
@functools.lru_cache
def _get_schema_path(schema) -> Path:
return get_schema_path(schema)

def get_schema_path(self) -> Path:
"""Resolve the actual schema to a path."""
return WeldxImportExport._get_schema_path(self.schema)

@abc.abstractmethod
def from_tree(self, tree: dict):
"""Fill the widget with given state dictionary."""
Expand Down
2 changes: 1 addition & 1 deletion weldx_widgets/widget_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def text_value(self, value):
self.text.value = value


class FloatWithUnit(WidgetMyHBox):
class WidgetFloatWithUnit(WidgetMyHBox):
"""Widget grouping a float with unit."""

def __init__(self, text, unit, value: float = 0.0, min=0):
Expand Down
4 changes: 2 additions & 2 deletions weldx_widgets/widget_gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from weldx.tags.aws import GasComponent, ShieldingGasForProcedure, ShieldingGasType
from weldx_widgets.widget_base import WidgetMyVBox
from weldx_widgets.widget_factory import (
FloatWithUnit,
WidgetFloatWithUnit,
button_layout,
description_layout,
)
Expand Down Expand Up @@ -140,7 +140,7 @@ class WidgetShieldingGas(WidgetMyVBox):
# TODO: this could in principle be used multiple times for all positions
# e.g. torch, trailing, backing
def __init__(self, position="torch"):
self.flowrate = FloatWithUnit("Flow rate", "l/min", value=20)
self.flowrate = WidgetFloatWithUnit("Flow rate", "l/min", value=20)
self.gas_components = WidgetSimpleGasSelection()

children = [self.gas_components, self.flowrate]
Expand Down
20 changes: 10 additions & 10 deletions weldx_widgets/widget_gmaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from weldx_widgets.generic import WidgetTimeSeries
from weldx_widgets.widget_base import WeldxImportExport, WidgetMyVBox
from weldx_widgets.widget_factory import (
FloatWithUnit,
WidgetFloatWithUnit,
WidgetLabeledTextInput,
make_title,
)
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(self, tag: str, meta=None):

self.manufacturer = WidgetLabeledTextInput("Manufacturer", "Fronius")
self.power_source = WidgetLabeledTextInput("Power source", "TPS 500i")
self.wire_feedrate = FloatWithUnit(
self.wire_feedrate = WidgetFloatWithUnit(
text="Wire feed rate", value=10, min=0, unit="m/min"
)
children = [
Expand Down Expand Up @@ -98,14 +98,14 @@ class ProcessPulsed(WidgetMyVBox):
"""Widget for pulsed processes."""

def __init__(self, kind="UI"):
self.pulse_duration = FloatWithUnit("Pulse duration", value=5.0, unit="ms")
self.pulse_frequency = FloatWithUnit("Pulse frequency", value=100.0, unit="Hz")
self.base_current = FloatWithUnit("Base current", value=60.0, unit="A")
self.pulse_duration = WidgetFloatWithUnit("Pulse duration", value=5.0, unit="ms")
self.pulse_frequency = WidgetFloatWithUnit("Pulse frequency", value=100.0, unit="Hz")
self.base_current = WidgetFloatWithUnit("Base current", value=60.0, unit="A")

if kind == "UI":
self.pulsed_dim = FloatWithUnit("Pulse voltage", "V", 40)
self.pulsed_dim = WidgetFloatWithUnit("Pulse voltage", "V", 40)
elif kind == "II":
self.pulsed_dim = FloatWithUnit("Pulse current", "A", 300)
self.pulsed_dim = WidgetFloatWithUnit("Pulse current", "A", 300)
else:
raise ValueError(f"unknown kind: {kind}")
self.kind = kind
Expand Down Expand Up @@ -179,8 +179,8 @@ def __init__(self):
self.voltage = WidgetTimeSeries(
base_data="40.0, 20.0", base_unit="V", time_data="0.0, 10.0", time_unit="s"
)
self.impedance = FloatWithUnit(text="Impedance", value=10, unit="percent")
self.characteristic = FloatWithUnit("Characteristic", value=5, unit="V/A")
self.impedance = WidgetFloatWithUnit(text="Impedance", value=10, unit="percent")
self.characteristic = WidgetFloatWithUnit("Characteristic", value=5, unit="V/A")

super().__init__(
children=[
Expand Down Expand Up @@ -227,7 +227,7 @@ class WidgetWire(WidgetMyVBox):
heading_level = 4

def __init__(self):
self.diameter = FloatWithUnit("Diameter", unit="mm", min=0, value=1.2)
self.diameter = WidgetFloatWithUnit("Diameter", unit="mm", min=0, value=1.2)
self.wire_class = WidgetLabeledTextInput("Class", "G 42 2 C/M G4Si1")

# TODO: consider a tree like editing widget for metadata.
Expand Down
24 changes: 12 additions & 12 deletions weldx_widgets/widget_groove_sel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from weldx_widgets.generic import download_button
from weldx_widgets.widget_base import WeldxImportExport, WidgetMyHBox, WidgetMyVBox
from weldx_widgets.widget_factory import (
FloatWithUnit,
WidgetFloatWithUnit,
WidgetLabeledTextInput,
description_layout,
make_title,
Expand Down Expand Up @@ -87,13 +87,13 @@ def __init__(self):
# program directly to his/her computer.
self._html_dl_button = HTML()

self.profile_raster_width = FloatWithUnit(
self.profile_raster_width = WidgetFloatWithUnit(
"Profile raster width",
value=2,
unit="mm",
# tooltip="Target distance between the individual points of a profile",
)
self.trace_raster_width = FloatWithUnit(
self.trace_raster_width = WidgetFloatWithUnit(
"Trace raster width",
value=30,
unit="mm",
Expand Down Expand Up @@ -154,7 +154,7 @@ class WidgetMetal(WidgetMyVBox):
def __init__(self):
self.common_name = WidgetLabeledTextInput("Common name", "S355J2+N")
self.standard = WidgetLabeledTextInput("Standard", "DIN EN 10225-2:2011")
self.thickness = FloatWithUnit("Thickness", value=30, unit="mm")
self.thickness = WidgetFloatWithUnit("Thickness", value=30, unit="mm")
children = [
make_title("Base metal", heading_level=4),
self.common_name,
Expand Down Expand Up @@ -261,7 +261,7 @@ def groove_obj(self, value: IsoBaseGroove):
with contextlib.ExitStack() as stack:
for k, v in self.groove_obj.parameters().items():
mapped_k = self._groove_obj._mapping[k]
widget: FloatWithUnit = gui_params[mapped_k]
widget: WidgetFloatWithUnit = gui_params[mapped_k]
stack.enter_context(widget.silence_events())

widget.quantity = v
Expand Down Expand Up @@ -326,11 +326,11 @@ def _create_groove_dropdown(self):
else:
text = t
if "angle" in item:
param_widgets[item] = FloatWithUnit(text=text, unit="°", value=45)
param_widgets[item] = WidgetFloatWithUnit(text=text, unit="°", value=45)
elif "workpiece_thickness" in item:
param_widgets[item] = FloatWithUnit(text=text, unit="mm", value=15)
param_widgets[item] = WidgetFloatWithUnit(text=text, unit="mm", value=15)
else:
param_widgets[item] = FloatWithUnit(text=text, unit="mm", value=5)
param_widgets[item] = WidgetFloatWithUnit(text=text, unit="mm", value=5)
param_widgets[item].mapping = item

groove_list = list(_groove_name_to_type.keys())
Expand Down Expand Up @@ -405,15 +405,15 @@ def __init__(self):
self.last_plot: Optional[CoordinateSystemManagerVisualizerK3D] = None
self.groove_sel = WidgetGrooveSelection()

self.seam_length = FloatWithUnit("Seam length", value=300, min=0, unit="mm")
self.seam_length = WidgetFloatWithUnit("Seam length", value=300, min=0, unit="mm")
self.seam_length.observe_float_value(self.create_csm_and_plot)
self.seam_length.observe_unit(self.create_csm_and_plot)

self.tcp_y = FloatWithUnit("TCP-y", unit="mm")
self.tcp_z = FloatWithUnit("TCP-z", unit="mm")
self.tcp_y = WidgetFloatWithUnit("TCP-y", unit="mm")
self.tcp_z = WidgetFloatWithUnit("TCP-z", unit="mm")
# TODO: compute weld speed accordingly to chosen groove area!
# TODO: consider setting it read-only??
self.weld_speed = FloatWithUnit("weld speed", value=6, unit="mm/s")
self.weld_speed = WidgetFloatWithUnit("weld speed", value=6, unit="mm/s")
self.base_metal = WidgetMetal()
self.geometry_export = WidgetCADExport()
self.additional_params = (
Expand Down

0 comments on commit ed1d0f3

Please sign in to comment.