diff --git a/CHANGELOG b/CHANGELOG index 89db1f6..07409a9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ -2.23.3 +2.23.0 + - feat: add zoom-in functionality for contour plots (#211) - fix: cache selected event per dataset in QuickView (#196) - enh: add new logo (scope view and block matrix) 2.22.2 diff --git a/dcscope/gui/analysis/ana_plot.py b/dcscope/gui/analysis/ana_plot.py index 5535e8f..4294e1f 100644 --- a/dcscope/gui/analysis/ana_plot.py +++ b/dcscope/gui/analysis/ana_plot.py @@ -118,6 +118,7 @@ def read_pipeline_state(self): "contour": { "enabled": self.groupBox_contour.isChecked(), "legend": self.checkBox_legend.isChecked(), + "zoomin": self.checkBox_zoomin.isChecked(), "line widths": [self.doubleSpinBox_lw_1.value(), self.doubleSpinBox_lw_2.value(), ], diff --git a/dcscope/gui/analysis/ana_plot.ui b/dcscope/gui/analysis/ana_plot.ui index 5a2456e..2337f7f 100644 --- a/dcscope/gui/analysis/ana_plot.ui +++ b/dcscope/gui/analysis/ana_plot.ui @@ -7,7 +7,7 @@ 0 0 627 - 934 + 936 @@ -26,14 +26,14 @@ - QComboBox::AdjustToContents + QComboBox::SizeAdjustPolicy::AdjustToContents - Qt::Horizontal + Qt::Orientation::Horizontal @@ -52,8 +52,7 @@ Duplicate - - .. + @@ -66,8 +65,7 @@ Remove - - .. + @@ -76,7 +74,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -152,7 +150,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -228,7 +226,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -277,7 +275,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -311,7 +309,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -365,7 +363,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -431,7 +429,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -458,7 +456,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -483,7 +481,7 @@ - QLayout::SetDefaultConstraint + QLayout::SizeConstraint::SetDefaultConstraint @@ -519,7 +517,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -534,7 +532,7 @@ - QLayout::SetMinimumSize + QLayout::SizeConstraint::SetMinimumSize @@ -598,7 +596,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -692,7 +690,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -712,7 +710,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -914,7 +912,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -936,7 +934,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -958,13 +956,20 @@ + + + + Zoom-in + + + - Qt::Vertical + Qt::Orientation::Vertical @@ -979,7 +984,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -999,10 +1004,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed diff --git a/dcscope/gui/pipeline_plot.py b/dcscope/gui/pipeline_plot.py index a242408..cac4eb4 100644 --- a/dcscope/gui/pipeline_plot.py +++ b/dcscope/gui/pipeline_plot.py @@ -361,6 +361,11 @@ def redraw(self, dslist, slot_states, plot_state, hash_flag=None): else: legend = None for rtdc_ds, ss in zip(dslist, slot_states): + if plot_state["contour"].get("zoomin", False): + zoomin_contours(dslist=dslist, + plot_item=self, + plot_state=plot_state + ) con = add_contour(plot_item=self, rtdc_ds=rtdc_ds, plot_state=plot_state, @@ -471,6 +476,33 @@ def add_label(text, anchor_parent, text_halign="center", text_valign="center", label.setPos(x + dx, y + dy) +def zoomin_contours(dslist, plot_item, plot_state, margin_per=5): + """Zoom-in contour data if enabled""" + x_min, x_max, y_min, y_max = 0, 0, 0, 0 + # compute all contours + contours_list = [compute_contours(plot_state, ds) for ds in dslist] + # flatten list of contours + all_points = np.vstack([np.vstack(c) for conts in contours_list + for c in conts]) + + if all_points.size > 0: + x_min = np.min(all_points[:, 0]) + x_max = np.max(all_points[:, 0]) + y_min = np.min(all_points[:, 1]) + y_max = np.max(all_points[:, 1]) + + # Add margin + x_margin = (x_max - x_min) * margin_per*0.01 + y_margin = (y_max - y_min) * margin_per*0.01 + + # Set view range with margins + plot_item.setRange( + xRange=(x_min - x_margin, x_max + x_margin), + yRange=(y_min - y_margin, y_max + y_margin), + padding=0 + ) + + def add_contour(plot_item, plot_state, rtdc_ds, slot_state, legend=None): contours = compute_contours(plot_state=plot_state, rtdc_ds=rtdc_ds) con = plot_state["contour"] diff --git a/dcscope/pipeline/plot.py b/dcscope/pipeline/plot.py index 1a4eb5a..bd75727 100644 --- a/dcscope/pipeline/plot.py +++ b/dcscope/pipeline/plot.py @@ -44,6 +44,7 @@ "contour": { "enabled": True, "legend": False, # display plot legend + "zoomin": False, # enable zoom-in functionality "line widths": [3.0, 1.5], # contour line widths [pt] "line styles": ["solid", "dashed"], "percentiles": [95.0, 50.0], @@ -97,6 +98,7 @@ "contour": { "enabled": bool, "legend": bool, + "zoomin": bool, "line widths": (float,), "line styles": (["solid", "dashed", "dotted"],), "percentiles": (float,),