Skip to content

Commit 6b8f32f

Browse files
committed
allow point insertion when unattended mode
1 parent de79e04 commit 6b8f32f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

plotpy/tools/curve.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import numpy as np
1010
from guidata.dataset import ChoiceItem, DataSet, FloatItem, IntItem
11+
from guidata.qthelpers import execenv
1112
from guidata.widgets.arrayeditor import ArrayEditor
1213
from qtpy import QtCore as QC
1314
from qtpy import QtGui as QG
@@ -846,18 +847,17 @@ def insert_point_at_selection(
846847
param.index = self.__idx
847848
param.value = self.__y[self.__idx - 1 : self.__idx + 1].mean()
848849

849-
if not param.edit():
850-
return
850+
if param.edit() or execenv.unattended:
851+
insertion_index: int = param.index + param.index_offset # type: ignore
852+
new_x: float = self.__x[insertion_index - 1 : insertion_index + 1].mean()
853+
self.__x = np.insert(self.__x, insertion_index, new_x) # type: ignore
854+
self.__y = np.insert(self.__y, insertion_index, param.value) # type: ignore
855+
curve_item.set_data(self.__x, self.__y)
856+
new_pos = axes_to_canvas(curve_item, new_x, param.value) # type: ignore
857+
self.__current_location_marker.move_local_point_to(
858+
0, QC.QPointF(*new_pos) # type: ignore
859+
)
851860

852-
insertion_index: int = param.index + param.index_offset # type: ignore
853-
new_x: float = self.__x[insertion_index - 1 : insertion_index + 1].mean()
854-
self.__x = np.insert(self.__x, insertion_index, new_x) # type: ignore
855-
self.__y = np.insert(self.__y, insertion_index, param.value) # type: ignore
856-
curve_item.set_data(self.__x, self.__y)
857-
new_pos = axes_to_canvas(curve_item, new_x, param.value) # type: ignore
858-
self.__current_location_marker.move_local_point_to(
859-
0, QC.QPointF(*new_pos) # type: ignore
860-
)
861861

862862
def __get_plot(self, filter: StatefulEventFilter) -> BasePlot:
863863
"""Get plot. Simple method to avoid type checking errors

0 commit comments

Comments
 (0)