Skip to content

Commit

Permalink
add basic expert concet
Browse files Browse the repository at this point in the history
The expert table isn't yet hooked up
  • Loading branch information
tlambert03 committed Oct 11, 2024
1 parent e881e4d commit 444397f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
23 changes: 20 additions & 3 deletions src/pymmcore_widgets/config_presets/_oc_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
QPushButton,
QSpacerItem,
QSplitter,
QTabWidget,
QVBoxLayout,
QWidget,
)
from superqt.utils import signals_blocked

from pymmcore_widgets.control._objective_widget import ObjectivesWidget
from pymmcore_widgets.device_properties import PropertyBrowser
from pymmcore_widgets.device_properties._device_property_table import (
DevicePropertyTable,
)
Expand Down Expand Up @@ -213,9 +215,20 @@ def __init__(
right_splitter.setStretchFactor(1, 1)
right_splitter.setStretchFactor(2, 0)

Check warning on line 216 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L209-L216

Added lines #L209 - L216 were not covered by tests

self.expert_table = PropertyBrowser(parent=self, mmcore=self._core)
self.expert_table._prop_table.setRowsCheckable(True)
self.expert_table._device_filters.setShowReadOnly(False)
self.expert_table._device_filters._read_only_checkbox.hide()
self.expert_table._device_filters.setShowPreInitProps(False)
self.expert_table._device_filters._pre_init_checkbox.hide()

Check warning on line 223 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L218-L223

Added lines #L218 - L223 were not covered by tests

basic_expert_tabs = QTabWidget(self)
basic_expert_tabs.addTab(right_splitter, "Basic")
basic_expert_tabs.addTab(self.expert_table, "Expert")

Check warning on line 227 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L225-L227

Added lines #L225 - L227 were not covered by tests

layout = QHBoxLayout(self)
layout.addLayout(left_layout)
layout.addWidget(right_splitter, 1)
layout.addWidget(basic_expert_tabs, 1)

Check warning on line 231 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L229-L231

Added lines #L229 - L231 were not covered by tests

self.resize(1080, 920)

Check warning on line 233 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L233

Added line #L233 was not covered by tests

Expand Down Expand Up @@ -309,6 +322,10 @@ def _current_settings(self) -> list[Setting]:
return [Setting(*k, v) for k, v in tmp.items()]

Check warning on line 322 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L322

Added line #L322 was not covered by tests


def is_not_objective(prop: DeviceProperty) -> bool:
return not any(x in prop.device for x in prop.core.guessObjectiveDevices())

Check warning on line 326 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L326

Added line #L326 was not covered by tests


def light_path_predicate(prop: DeviceProperty) -> bool | None:
devtype = prop.deviceType()
if devtype in (

Check warning on line 331 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L330-L331

Added lines #L330 - L331 were not covered by tests
Expand All @@ -324,7 +341,7 @@ def light_path_predicate(prop: DeviceProperty) -> bool | None:
return False
if devtype == DeviceType.Shutter and prop.name == Keyword.State.value:
return False
if any(x in prop.device for x in prop.core.guessObjectiveDevices()):
if not is_not_objective(prop):
return False
return None

Check warning on line 346 in src/pymmcore_widgets/config_presets/_oc_dialog.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/config_presets/_oc_dialog.py#L338-L346

Added lines #L338 - L346 were not covered by tests

Expand Down Expand Up @@ -375,7 +392,7 @@ def _show_all_toggled(self, checked: bool) -> None:
exclude_devices=(DeviceType.Camera, DeviceType.Core),
include_read_only=False,
include_pre_init=False,
predicate=light_path_predicate if not checked else None,
predicate=light_path_predicate if not checked else is_not_objective,
)

def settings(self) -> Iterable[tuple[str, str, str]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _on_item_changed(self, item: QTableWidgetItem) -> None:
color.setAlpha(255)
font.setBold(True)
else:
color.setAlpha(175)
color.setAlpha(130)
font.setBold(False)
item.setForeground(color)
item.setFont(font)
Expand Down Expand Up @@ -206,9 +206,9 @@ def filterDevices(
if result is False:
self.hideRow(row)
continue

Check warning on line 208 in src/pymmcore_widgets/device_properties/_device_property_table.py

View check run for this annotation

Codecov / codecov/patch

src/pymmcore_widgets/device_properties/_device_property_table.py#L205-L208

Added lines #L205 - L208 were not covered by tests
if result is True:
self.showRow(row)
continue
# if result is True:
# self.showRow(row)
# continue
# for None: fall through to other filters
if (
(prop.isReadOnly() and not include_read_only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"cameras": (DeviceType.CameraDevice,),
"shutters": (DeviceType.ShutterDevice,),
"stages": (DeviceType.StageDevice,),
"core": (DeviceType.CoreDevice,),
"wheels, turrets, etc.": (DeviceType.StateDevice,),
}
_d: set[DeviceType] = set.union(*(set(i) for i in DevTypeLabels.values()))
Expand Down

0 comments on commit 444397f

Please sign in to comment.