OGS
|
A model for the StationTreeView implementing a tree as a double-linked list.
A model for the StationTreeView implementing a tree as a double-linked list. In addition to a simple TreeModel each item also contains a 2D / 3D GraphicsItem for visualization.
Definition at line 42 of file StationTreeModel.h.
#include <StationTreeModel.h>
Public Member Functions | |
StationTreeModel (QObject *parent=nullptr) | |
~StationTreeModel () override | |
void | addStationList (QString listName, const std::vector< GeoLib::Point * > *stations) |
const std::vector< ModelTreeItem * > & | getLists () |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
void | removeStationList (QModelIndex index) |
void | removeStationList (const std::string &name) |
void | setNameForItem (const std::string &stn_vec_name, std::size_t id, std::string const &item_name) |
GeoLib::Station * | stationFromIndex (const QModelIndex &index, QString &listName) const |
vtkPolyDataAlgorithm * | vtkSource (const std::string &name) const |
Public Member Functions inherited from TreeModel | |
TreeModel (QObject *parent=nullptr) | |
~TreeModel () override | |
QVariant | data (const QModelIndex &index, int role) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
TreeItem * | getItem (const QModelIndex &index) const |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
QModelIndex | parent (const QModelIndex &index) const override |
bool | removeRows (int position, int count, const QModelIndex &parent) override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
TreeItem * | rootItem () const |
Private Attributes | |
std::vector< ModelTreeItem * > | _lists |
Additional Inherited Members | |
Public Slots inherited from TreeModel | |
void | updateData () |
Protected Attributes inherited from TreeModel | |
TreeItem * | _rootItem |
|
explicit |
Constructor.
Definition at line 26 of file StationTreeModel.cpp.
References TreeModel::_rootItem.
|
overridedefault |
void StationTreeModel::addStationList | ( | QString | listName, |
const std::vector< GeoLib::Point * > * | stations ) |
Inserts a subtree under _rootItem.
listName | Name of the new subtree. If no name is given a default name is assigned. |
stations | The list with stations to be added as children of that subtree |
Definition at line 139 of file StationTreeModel.cpp.
References _lists, TreeModel::_rootItem, TreeItem::appendChild(), getName(), and TreeModel::rowCount().
Referenced by GEOModels::addStationVec(), and GEOModels::updateGeometry().
|
inline |
|
override |
Returns the model index of an item in the tree.
row | The row where the item is located |
column | The column where the item is located |
parent | The parent of the item |
Definition at line 46 of file StationTreeModel.cpp.
References TreeModel::_rootItem, TreeItem::child(), TreeModel::parent(), and BaseItem::setModelIndex().
Referenced by removeStationList(), and stationFromIndex().
void StationTreeModel::removeStationList | ( | const std::string & | name | ) |
Removes the TreeItem with the given name including all its children
Definition at line 206 of file StationTreeModel.cpp.
References _lists, and removeStationList().
void StationTreeModel::removeStationList | ( | QModelIndex | index | ) |
Removes the TreeItem with the given Index including all its children
Definition at line 183 of file StationTreeModel.cpp.
References _lists, TreeModel::getItem(), index(), TreeModel::parent(), and TreeModel::removeRows().
Referenced by removeStationList(), GEOModels::removeStationVec(), and GEOModels::updateGeometry().
void StationTreeModel::setNameForItem | ( | const std::string & | stn_vec_name, |
std::size_t | id, | ||
std::string const & | item_name ) |
Definition at line 114 of file StationTreeModel.cpp.
References _lists, TreeItem::child(), and TreeItem::setData().
Referenced by MainWindow::showStationNameDialog().
GeoLib::Station * StationTreeModel::stationFromIndex | ( | const QModelIndex & | index, |
QString & | listName ) const |
Returns the Station-Object of the ModelTreeItem with the given index and the name of the list this station belongs to.
index | Index of the requested item |
listName | Here, the method will put the name of the list this station belongs to. |
Definition at line 87 of file StationTreeModel.cpp.
References TreeItem::data(), index(), and TreeItem::parentItem().
vtkPolyDataAlgorithm * StationTreeModel::vtkSource | ( | const std::string & | name | ) | const |
Definition at line 101 of file StationTreeModel.cpp.
References _lists, TreeModel::data(), and BaseItem::vtkSource().
Referenced by VtkVisPipeline::addPipelineItem(), StationTreeView::displayStratigraphy(), VtkVisPipeline::removeSourceItem(), and StationTreeView::writeStratigraphiesAsImages().
|
private |
Definition at line 63 of file StationTreeModel.h.
Referenced by addStationList(), getLists(), removeStationList(), removeStationList(), setNameForItem(), and vtkSource().