SplineEditor (hwx.gui)¶
Compsite widget to edit a math.Spline
Contains:
- A Table on the left to enter the X, Y values
- A Plot on the left to visualize and drag the values
- Buttons on the top of the table to add/insert/remove values and read/write csv
Like other widgets you can specify a command parameter that is a method that gets called when the spline changes.
- Inherits:
Properties¶
Public Methods¶
clearSelection (self) createContents (self) decorateContents (self) deleteSelected (self) enableDragAndDrop (self, *widgets) getSelectedRows (self) layoutContents (self) okToDrop (self, fname) onDrop (self, fname) onPlotSelected (self, points) onSplineModified (self, selectRow=None, fitPlot=’selected’) onTableSelected (self, rows) readCsv (self, fname=None) selectRow (self, row) setSpline (self, spline, clearSelection=True, fitPlot=True) writeCsv (self, fname=None)
Property Details¶
-
interpolationMethod
()¶
The interpolation method.
-
interpolationNpts
()¶
The number of samples to generate.
-
spline
()
The spline object.
Method Details¶
-
clearSelection
(self)¶
Unselects all table rows and plot points.
-
createContents
(self)¶
Creates the contents for the SplineEditor.
-
decorateContents
(self)¶
Called when cells from the table are selected so we can disable the the delete button if needed.
-
deleteSelected
(self)¶
Called if the user hits the <Del> key or clicks the delete button to delete the selected points.
-
enableDragAndDrop
(self, *widgets)¶
Enables dragging and dropping of csv file into the SplineEditor.
param widgets: | The widgets to be enabled drag and drop. |
---|---|
type widgets: | collection |
-
getSelectedRows
(self)¶
Returns a list of indices of the selected rows.
-
layoutContents
(self)¶
Creates the layout for the SplineEditor.
-
okToDrop
(self, fname)¶
Returns if the file dropped is a csv file.
param fname: | CSV file path. |
---|---|
type fname: | str |
returns: | True if the file to dropped is a csv file, otherwise False |
rtype: | bool |
-
onDrop
(self, fname)¶
Reads the csv file on drop.
param fname: | CSV file path. |
---|---|
type fname: | str |
-
onPlotSelected
(self, points)¶
Called when user selects points in the plot to select the corresponding table rows.
param points: | The selected from user points in the plot. |
---|---|
type points: | Union[Point, list[Point]] |
-
onSplineModified
(self, selectRow=None, fitPlot='selected')¶
Called when the the spline changes, that happens when:
- A table cell value was changed.
- A plot point was modified (mouse up, not drag).
- One of the buttons was clicked.
param selectRow: | |
---|---|
The row index to select the modified spline from the table. | |
type selectRow: | int |
param fitPlot: | The points of the plot to fit. |
type fitPlot: | str |
-
onTableSelected
(self, rows)¶
Called when user selects cells in the table to select the corresponding plot points.
param rows: | The selected row or list of row indices from the table. |
---|---|
type rows: | Union[int, list[int]] |
-
readCsv
(self, fname=None)¶
Reads spline data from a csv file.
param fname: | The CSV file path. |
---|---|
type fname: | str |
-
selectRow
(self, row)¶
Selects the table row and plot point for the specified row.
param row: | A single index of the table or list of indices. |
---|---|
type row: | Union[int, list] |
-
setSpline
(self, spline, clearSelection=True, fitPlot=True)¶
Sets the specified spline in SplineEditor table and plot.
param spline: | The spline containing x/y values to be set. |
---|---|
type spline: | Spline |
param clearSelection: | |
Determines whether to remove selection from the SplineEditor. | |
type clearSelection: | |
bool, optional | |
param fitPlot: | Determines whether to fit the plot inside SplineEditor plot. |
type fitPlot: | bool, optional |
-
writeCsv
(self, fname=None)¶
Writes a csv file containing the values.
param fname: | CSV file path. |
---|---|
type fname: | str |