RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
gui.ndarray_model.NdarrayModel Class Reference

A Qt model for Numpy ndarray objects that can be used with QTableView widgets. More...

Inheritance diagram for gui.ndarray_model.NdarrayModel:

Public Member Functions

 __init__ (self, Optional[numpy.ndarray] data=None, *args, **kwargs)
 
Optional[numpy.ndarray] get_array_data (self)
 Get the internal numpy array data.
 
 set_array_data (self, Optional[numpy.ndarray] data)
 Set the internal numpy ndarray and signal the parts of the data that have been effectively changed in the model.
 
int rowCount (self, QModelIndex parent=QModelIndex())
 Return the number of rows in the ndarray.
 
int columnCount (self, QModelIndex parent=QModelIndex())
 Return the number of columns in the ndarray.
 
QModelIndex index (self, int row, int column, QModelIndex parent=QModelIndex())
 Creates an index into the model for a given row and column.
 
Qt.ItemFlags flags (self, QModelIndex index)
 Returns property flags for an element of the ndarray indicated by index.
 
 data (self, QModelIndex index, int role=Qt.DisplayRole)
 Returns the data for a specific cell in the model identified by the index and for a specific role (the display role by default).
 
bool setData (self, QModelIndex index, value, int role=Qt.DisplayRole)
 Sets the data value for a specific cell in the model identified by the index and for a specific role.
 
 headerData (self, int section, Qt.Orientation orientation, int role=Qt.DisplayRole)
 Returns information about a column or row depending on the orientation.
 
bool insertRows (self, int position, int rows, QModelIndex parent=QModelIndex())
 Inserts count new rows into the model before the given row.
 
bool insertColumns (self, int position, int columns, QModelIndex parent=QModelIndex())
 Inserts count new columns into the model before the given column.
 
bool removeRows (self, int position, int rows, QModelIndex parent=QModelIndex())
 Removes count rows starting with the given row from the model.
 
bool removeColumns (self, int position, int columns, QModelIndex parent=QModelIndex())
 Removes count columns starting with the given column from the model.
 
bool moveRows (self, QModelIndex source_parent, int source_row, int count, QModelIndex destination_parent, int destination_child)
 Moves one or more rows in the table model.
 
bool moveColumns (self, QModelIndex source_parent, int source_column, int count, QModelIndex destination_parent, int destination_child)
 Moves one or more columns in the table model.
 
Qt.DropActions supportedDropActions (self)
 Returns the drop actions supported by the model, in this case copy and move.
 
 setItemData (self, index, roles)
 Update data for a particular index for one or more roles.
 
list mimeTypes (self)
 Extends the mime types supported by the model with text/plain to allow external drag and drop.
 
bool dropMimeData (self, QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent)
 Handle the data supplied by a drag and drop operation.
 
QMimeData mimeData (self, list[QModelIndex] indexes)
 Extends the mime data by the model with text/plain to allow drag and drop to external applications.
 

Protected Attributes

 _array_data = None
 

Detailed Description

A Qt model for Numpy ndarray objects that can be used with QTableView widgets.

This customised model is optimised to handle large ndarrays by accessing the data directly from an existing ndarray instance.

Constructor & Destructor Documentation

◆ __init__()

gui.ndarray_model.NdarrayModel.__init__ ( self,
Optional[numpy.ndarray] data = None,
* args,
** kwargs )

Member Function Documentation

◆ columnCount()

int gui.ndarray_model.NdarrayModel.columnCount ( self,
QModelIndex parent = QModelIndex() )

Return the number of columns in the ndarray.

◆ data()

gui.ndarray_model.NdarrayModel.data ( self,
QModelIndex index,
int role = Qt.DisplayRole )

Returns the data for a specific cell in the model identified by the index and for a specific role (the display role by default).

◆ dropMimeData()

bool gui.ndarray_model.NdarrayModel.dropMimeData ( self,
QMimeData data,
Qt.DropAction action,
int row,
int column,
QModelIndex parent )

Handle the data supplied by a drag and drop operation.

Returns True if the data and action were handled by the model and False otherwise.

◆ flags()

Qt.ItemFlags gui.ndarray_model.NdarrayModel.flags ( self,
QModelIndex index )

Returns property flags for an element of the ndarray indicated by index.

The flags indicate the elements are enabled, selectable, editable dragable and dropable.

◆ get_array_data()

Optional[numpy.ndarray] gui.ndarray_model.NdarrayModel.get_array_data ( self)

Get the internal numpy array data.

◆ headerData()

gui.ndarray_model.NdarrayModel.headerData ( self,
int section,
Qt.Orientation orientation,
int role = Qt.DisplayRole )

Returns information about a column or row depending on the orientation.

◆ index()

QModelIndex gui.ndarray_model.NdarrayModel.index ( self,
int row,
int column,
QModelIndex parent = QModelIndex() )

Creates an index into the model for a given row and column.

Note that parent must always be QModelIndex() for a table model such as this one.

◆ insertColumns()

bool gui.ndarray_model.NdarrayModel.insertColumns ( self,
int position,
int columns,
QModelIndex parent = QModelIndex() )

Inserts count new columns into the model before the given column.

If column is 0, the columns are prepended to any existing columns. If column is columnCount(), the columns are appended to any existing columns.

Note that parent must always be QModelIndex().

Returns True if the columns were successfully inserted; otherwise returns False.

◆ insertRows()

bool gui.ndarray_model.NdarrayModel.insertRows ( self,
int position,
int rows,
QModelIndex parent = QModelIndex() )

Inserts count new rows into the model before the given row.

If row is 0, the rows are prepended to any existing rows in the parent. If row is rowCount(), the rows are appended to any existing rows in the parent.

Note that parent must always be QModelIndex().

Returns True if the rows were successfully inserted; otherwise returns False.

◆ mimeData()

QMimeData gui.ndarray_model.NdarrayModel.mimeData ( self,
list[QModelIndex] indexes )

Extends the mime data by the model with text/plain to allow drag and drop to external applications.

◆ mimeTypes()

list gui.ndarray_model.NdarrayModel.mimeTypes ( self)

Extends the mime types supported by the model with text/plain to allow external drag and drop.

◆ moveColumns()

bool gui.ndarray_model.NdarrayModel.moveColumns ( self,
QModelIndex source_parent,
int source_column,
int count,
QModelIndex destination_parent,
int destination_child )

Moves one or more columns in the table model.

Returns True if the columns were moved successfully and False otherwise.

◆ moveRows()

bool gui.ndarray_model.NdarrayModel.moveRows ( self,
QModelIndex source_parent,
int source_row,
int count,
QModelIndex destination_parent,
int destination_child )

Moves one or more rows in the table model.

Returns True if the rows were moved successfully and False otherwise.

◆ removeColumns()

bool gui.ndarray_model.NdarrayModel.removeColumns ( self,
int position,
int columns,
QModelIndex parent = QModelIndex() )

Removes count columns starting with the given column from the model.

Note that parent must always be QModelIndex().

Returns True if the columns were successfully removed; otherwise returns False.

◆ removeRows()

bool gui.ndarray_model.NdarrayModel.removeRows ( self,
int position,
int rows,
QModelIndex parent = QModelIndex() )

Removes count rows starting with the given row from the model.

Note that parent must always be QModelIndex().

Returns True if the rows were successfully removed; otherwise returns False.

◆ rowCount()

int gui.ndarray_model.NdarrayModel.rowCount ( self,
QModelIndex parent = QModelIndex() )

Return the number of rows in the ndarray.

◆ set_array_data()

gui.ndarray_model.NdarrayModel.set_array_data ( self,
Optional[numpy.ndarray] data )

Set the internal numpy ndarray and signal the parts of the data that have been effectively changed in the model.

◆ setData()

bool gui.ndarray_model.NdarrayModel.setData ( self,
QModelIndex index,
value,
int role = Qt.DisplayRole )

Sets the data value for a specific cell in the model identified by the index and for a specific role.

Should normally use the Qt.EditRole.

Returns
True if the model was successfully updated and False otherwise.

◆ setItemData()

gui.ndarray_model.NdarrayModel.setItemData ( self,
index,
roles )

Update data for a particular index for one or more roles.

Parameters
indexThe model index of the table cell that should be updated.
rolesA dictionary of role and value pairs, i.e. the data per role to be updated.

Returns True if data was updated successfully for at least one role and False otherwise.

◆ supportedDropActions()

Qt.DropActions gui.ndarray_model.NdarrayModel.supportedDropActions ( self)

Returns the drop actions supported by the model, in this case copy and move.

Member Data Documentation

◆ _array_data

gui.ndarray_model.NdarrayModel._array_data = None
protected

The documentation for this class was generated from the following file: