feat: consolidate units to Metric/Imperial with unit-aware dialogs
Some checks failed
CI / lint (push) Has been cancelled
CI / test (macos-latest, 3.10) (push) Has been cancelled
CI / test (macos-latest, 3.11) (push) Has been cancelled
CI / test (macos-latest, 3.12) (push) Has been cancelled
CI / test (ubuntu-latest, 3.10) (push) Has been cancelled
CI / test (ubuntu-latest, 3.11) (push) Has been cancelled
CI / test (ubuntu-latest, 3.12) (push) Has been cancelled
CI / test (windows-latest, 3.10) (push) Has been cancelled
CI / test (windows-latest, 3.11) (push) Has been cancelled
CI / test (windows-latest, 3.12) (push) Has been cancelled
Some checks failed
CI / lint (push) Has been cancelled
CI / test (macos-latest, 3.10) (push) Has been cancelled
CI / test (macos-latest, 3.11) (push) Has been cancelled
CI / test (macos-latest, 3.12) (push) Has been cancelled
CI / test (ubuntu-latest, 3.10) (push) Has been cancelled
CI / test (ubuntu-latest, 3.11) (push) Has been cancelled
CI / test (ubuntu-latest, 3.12) (push) Has been cancelled
CI / test (windows-latest, 3.10) (push) Has been cancelled
CI / test (windows-latest, 3.11) (push) Has been cancelled
CI / test (windows-latest, 3.12) (push) Has been cancelled
- core/units: two dominant systems (Metric m/kN, Imperial ft/kip) with display conversion helpers, legacy 4-system migration in ProjectMeta - dialogs/docks: unit-aware material, section, case, load, grid and results labels; diagram renderer unit labels; render controls update - docs: add consistent_units.md; regen examples/*.osmodel artifacts - tests: update persistence/phase8/project/unit-labels for new systems
This commit is contained in:
parent
13bb5d1d91
commit
d01a5957b7
99 changed files with 3143 additions and 976 deletions
|
|
@ -42,7 +42,7 @@ def test_is_rotation_dof_ndf6() -> None:
|
|||
|
||||
@pytest.mark.gui
|
||||
def test_si_translation_labels(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
v = PushoverCurveView(units=UnitSystem.SI_M_N, ndf=6)
|
||||
v = PushoverCurveView(units=UnitSystem.METRIC, ndf=6)
|
||||
qtbot.addWidget(v)
|
||||
v.set_results(_pushover(control_dof=1))
|
||||
assert "m" in v._plot.getAxis("bottom").labelText
|
||||
|
|
@ -53,7 +53,7 @@ def test_si_translation_labels(qtbot) -> None: # type: ignore[no-untyped-def]
|
|||
|
||||
@pytest.mark.gui
|
||||
def test_si_rotation_labels_show_curvature_and_moment(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
v = PushoverCurveView(units=UnitSystem.SI_M_N, ndf=3)
|
||||
v = PushoverCurveView(units=UnitSystem.METRIC, ndf=3)
|
||||
qtbot.addWidget(v)
|
||||
v.set_results(_pushover(control_dof=3))
|
||||
assert "1/m" in v._plot.getAxis("bottom").labelText
|
||||
|
|
@ -65,7 +65,7 @@ def test_si_rotation_labels_show_curvature_and_moment(qtbot) -> None: # type: i
|
|||
@pytest.mark.gui
|
||||
def test_us_in_kip_rotation_labels(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
"""kip-in Moment-Curvature project must NOT show cm / kN anywhere."""
|
||||
v = PushoverCurveView(units=UnitSystem.US_IN_KIP, ndf=3)
|
||||
v = PushoverCurveView(units=UnitSystem.IMPERIAL, ndf=3)
|
||||
qtbot.addWidget(v)
|
||||
v.set_results(_pushover(control_dof=3))
|
||||
x_label = v._plot.getAxis("bottom").labelText
|
||||
|
|
@ -78,7 +78,7 @@ def test_us_in_kip_rotation_labels(qtbot) -> None: # type: ignore[no-untyped-de
|
|||
|
||||
@pytest.mark.gui
|
||||
def test_us_in_kip_translation_labels(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
v = PushoverCurveView(units=UnitSystem.US_IN_KIP, ndf=3)
|
||||
v = PushoverCurveView(units=UnitSystem.IMPERIAL, ndf=3)
|
||||
qtbot.addWidget(v)
|
||||
v.set_results(_pushover(control_dof=1))
|
||||
assert "in" in v._plot.getAxis("bottom").labelText
|
||||
|
|
@ -90,7 +90,7 @@ def test_no_auto_scaling_applied_to_values(qtbot) -> None: # type: ignore[no-un
|
|||
"""Regression: earlier versions divided base_shear by 1000 to
|
||||
display kN. The values must now be drawn exactly as stored so
|
||||
kip-in users don't see nonsense scaling."""
|
||||
v = PushoverCurveView(units=UnitSystem.US_IN_KIP, ndf=3)
|
||||
v = PushoverCurveView(units=UnitSystem.IMPERIAL, ndf=3)
|
||||
qtbot.addWidget(v)
|
||||
r = _pushover(control_dof=3)
|
||||
v.set_results(r)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from otko.core import UnitSystem # noqa: E402
|
|||
@pytest.mark.gui
|
||||
def test_status_bar_combo_lists_all_unit_systems(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
from otko.views.main_window import MainWindow
|
||||
|
||||
mw = MainWindow()
|
||||
qtbot.addWidget(mw)
|
||||
assert mw._units_combo.count() == len(list(UnitSystem))
|
||||
|
|
@ -20,25 +21,27 @@ def test_status_bar_combo_lists_all_unit_systems(qtbot) -> None: # type: ignore
|
|||
@pytest.mark.gui
|
||||
def test_status_bar_combo_reflects_project_units(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
from otko.views.main_window import MainWindow
|
||||
|
||||
mw = MainWindow()
|
||||
qtbot.addWidget(mw)
|
||||
mw._vm.new_project()
|
||||
mw._vm.project.meta.units = UnitSystem.US_IN_KIP
|
||||
mw._vm.project.meta.units = UnitSystem.IMPERIAL
|
||||
mw._sync_units_combo()
|
||||
assert mw._units_combo.currentData() == UnitSystem.US_IN_KIP
|
||||
assert mw._units_combo.currentData() == UnitSystem.IMPERIAL
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def test_status_bar_combo_write_updates_project(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
"""Changing the combo writes through to project.meta.units."""
|
||||
from otko.views.main_window import MainWindow
|
||||
|
||||
mw = MainWindow()
|
||||
qtbot.addWidget(mw)
|
||||
mw._vm.new_project()
|
||||
# Default is SI_M_N — switch to US_IN_KIP via the combo.
|
||||
target_idx = mw._units_combo.findData(UnitSystem.US_IN_KIP)
|
||||
# Default is Metric — switch to Imperial via the combo.
|
||||
target_idx = mw._units_combo.findData(UnitSystem.IMPERIAL)
|
||||
mw._units_combo.setCurrentIndex(target_idx)
|
||||
assert mw._vm.project.meta.units == UnitSystem.US_IN_KIP
|
||||
assert mw._vm.project.meta.units == UnitSystem.IMPERIAL
|
||||
assert mw._vm.is_dirty
|
||||
|
||||
|
||||
|
|
@ -46,6 +49,7 @@ def test_status_bar_combo_write_updates_project(qtbot) -> None: # type: ignore[
|
|||
def test_status_bar_combo_no_project_noop(qtbot) -> None: # type: ignore[no-untyped-def]
|
||||
"""Before a project is loaded, changing the combo is a no-op."""
|
||||
from otko.views.main_window import MainWindow
|
||||
|
||||
mw = MainWindow()
|
||||
qtbot.addWidget(mw)
|
||||
# No crash even with no project.
|
||||
|
|
|
|||
Loading…
Reference in a new issue