OGS
ProcessModel Class Referencefinal

Detailed Description

A model implementing a tree structure for process-relevant information such as process types, FEM-Conditions (BCs, ICs, STs), etc. as a double-linked list.

See also
TreeModel, ProcessView, TreeItem, CondObjectListItem

Definition at line 34 of file ProcessModel.h.

#include <ProcessModel.h>

Inheritance diagram for ProcessModel:
[legend]
Collaboration diagram for ProcessModel:
[legend]

Public Slots

void addBoundaryConditions (std::vector< std::unique_ptr< DataHolderLib::BoundaryCondition > > const &conditions)
 Adds vector of Boundary Conditions to the model.
 
void addSourceTerms (std::vector< std::unique_ptr< DataHolderLib::SourceTerm > > const &conditions)
 Adds vector of Source Terms to the model.
 
void addCondition (DataHolderLib::FemCondition *condition)
 Adds a single FEM Conditions to the model.
 
ProcessVarItemaddProcessVar (QString const &name)
 Adds a process to the model.
 
void removeCondition (QString const &process_var, QString const &param)
 Removes FEMConditions from the the model.
 
void removeProcessVariable (QString const &name)
 Removes a process variable incl all associated conditions from the model.
 
void clearModel ()
 Removes the complete content from the model.
 
void updateModel ()
 Updates the model based on the ProjectData-object.
 
- Public Slots inherited from TreeModel
void updateData ()
 

Public Member Functions

 ProcessModel (DataHolderLib::Project &project, QObject *parent=nullptr)
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
- 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
 
TreeItemgetItem (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
 
TreeItemrootItem () const
 

Private Member Functions

void addConditionItem (DataHolderLib::FemCondition *cond, ProcessVarItem *parent)
 Adds a new FEM condition to the condition tree model.
 
ProcessVarItemgetProcessVarItem (QString const &process_var_name) const
 
void removeCondition (ProcessVarItem *process_var, QString const &param_name)
 Removes FEMConditions from the the model.
 

Private Attributes

DataHolderLib::Project_project
 

Additional Inherited Members

- Protected Attributes inherited from TreeModel
TreeItem_rootItem
 

Constructor & Destructor Documentation

◆ ProcessModel()

ProcessModel::ProcessModel ( DataHolderLib::Project & project,
QObject * parent = nullptr )
explicit

Definition at line 24 of file ProcessModel.cpp.

25 : TreeModel(parent), _project(project)
26{
27 QList<QVariant> rootData;
28 delete _rootItem;
29 rootData << "Name"
30 << "Value"
31 << ""
32 << ""
33 << "";
34 _rootItem = new TreeItem(rootData, nullptr);
35}
DataHolderLib::Project & _project
Objects nodes for the TreeModel.
Definition TreeItem.h:28
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:81
TreeModel(QObject *parent=nullptr)
Definition TreeModel.cpp:26
TreeItem * _rootItem
Definition TreeModel.h:58

References TreeModel::_rootItem.

Member Function Documentation

◆ addBoundaryConditions

void ProcessModel::addBoundaryConditions ( std::vector< std::unique_ptr< DataHolderLib::BoundaryCondition > > const & conditions)
slot

Adds vector of Boundary Conditions to the model.

Returns the vtk source object for the specified subtree of a process with the given name.

Definition at line 67 of file ProcessModel.cpp.

70{
71 for (auto& cond : conditions)
72 {
73 addCondition(cond.get());
74 }
75}
void addCondition(DataHolderLib::FemCondition *condition)
Adds a single FEM Conditions to the model.

References addCondition().

Referenced by updateModel().

◆ addCondition

void ProcessModel::addCondition ( DataHolderLib::FemCondition * condition)
slot

Adds a single FEM Conditions to the model.

Definition at line 56 of file ProcessModel.cpp.

57{
58 QString const name(QString::fromStdString(condition->getProcessVarName()));
59 ProcessVarItem* process_var(getProcessVarItem(name));
60 if (process_var == nullptr)
61 {
62 process_var = addProcessVar(name);
63 }
64 addConditionItem(condition, process_var);
65}
std::string const getProcessVarName() const
Returns the name of the associated process variable.
ProcessVarItem * addProcessVar(QString const &name)
Adds a process to the model.
ProcessVarItem * getProcessVarItem(QString const &process_var_name) const
void addConditionItem(DataHolderLib::FemCondition *cond, ProcessVarItem *parent)
Adds a new FEM condition to the condition tree model.
A TreeItem representing process variable information.

References addConditionItem(), addProcessVar(), getProcessVarItem(), and DataHolderLib::FemCondition::getProcessVarName().

Referenced by addBoundaryConditions(), and addSourceTerms().

◆ addConditionItem()

void ProcessModel::addConditionItem ( DataHolderLib::FemCondition * cond,
ProcessVarItem * parent )
private

Adds a new FEM condition to the condition tree model.

Definition at line 44 of file ProcessModel.cpp.

46{
47 QList<QVariant> item_data;
48
49 item_data << QString::fromStdString(cond->getParamName())
50 << QString::fromStdString(cond->getConditionClassStr());
51
52 auto* cond_item = new CondItem(item_data, parent, cond);
53 parent->appendChild(cond_item);
54}
A TreeItem containing a boundary condition or source term.
Definition CondItem.h:26
virtual std::string const getConditionClassStr() const =0
Returns the type of condition for displaying purposes.
std::string const getParamName() const
Returns the name of the parameter associated with the condition.

References DataHolderLib::FemCondition::getConditionClassStr(), DataHolderLib::FemCondition::getParamName(), and TreeModel::parent().

Referenced by addCondition().

◆ addProcessVar

ProcessVarItem * ProcessModel::addProcessVar ( QString const & name)
slot

Adds a process to the model.

Definition at line 86 of file ProcessModel.cpp.

87{
88 beginResetModel();
89 QList<QVariant> process_var_data;
90 process_var_data << QVariant(name) << "";
91 auto* process_var = new ProcessVarItem(process_var_data, _rootItem);
92 _rootItem->appendChild(process_var);
93 endResetModel();
94 return process_var;
95}
void appendChild(TreeItem *item)
Definition TreeItem.cpp:42

References TreeModel::_rootItem, and TreeItem::appendChild().

Referenced by addCondition().

◆ addSourceTerms

void ProcessModel::addSourceTerms ( std::vector< std::unique_ptr< DataHolderLib::SourceTerm > > const & conditions)
slot

Adds vector of Source Terms to the model.

Definition at line 77 of file ProcessModel.cpp.

79{
80 for (auto& cond : conditions)
81 {
82 addCondition(cond.get());
83 }
84}

References addCondition().

Referenced by updateModel().

◆ clearModel

void ProcessModel::clearModel ( )
slot

Removes the complete content from the model.

Definition at line 168 of file ProcessModel.cpp.

169{
170 int const n_process_vars = _rootItem->childCount();
171 for (int i = n_process_vars; i >= 0; --i)
172 {
173 auto* pv_item = dynamic_cast<ProcessVarItem*>(_rootItem->child(i));
174 removeProcessVariable(pv_item->getName());
175 }
176}
void removeProcessVariable(QString const &name)
Removes a process variable incl all associated conditions from the model.
virtual int childCount() const
Definition TreeItem.cpp:65
TreeItem * child(int row) const
Definition TreeItem.cpp:52

References TreeModel::_rootItem, TreeItem::child(), TreeItem::childCount(), and removeProcessVariable().

◆ columnCount()

int ProcessModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 37 of file ProcessModel.cpp.

38{
39 Q_UNUSED(parent)
40
41 return 2;
42}

References TreeModel::parent().

◆ getProcessVarItem()

ProcessVarItem * ProcessModel::getProcessVarItem ( QString const & process_var_name) const
private

Definition at line 97 of file ProcessModel.cpp.

98{
99 int const n_children(_rootItem->childCount());
100 for (int i = 0; i < n_children; ++i)
101 {
102 auto* item(dynamic_cast<ProcessVarItem*>(_rootItem->child(i)));
103 if (item != nullptr && item->getName() == name)
104 {
105 return item;
106 }
107 }
108 return nullptr;
109}

References TreeModel::_rootItem, TreeItem::child(), and TreeItem::childCount().

Referenced by addCondition(), removeCondition(), and removeProcessVariable().

◆ removeCondition() [1/2]

void ProcessModel::removeCondition ( ProcessVarItem * process_var,
QString const & param_name )
private

Removes FEMConditions from the the model.

Definition at line 111 of file ProcessModel.cpp.

113{
114 int const n_conditions = process_var->childCount();
115 for (int i = 0; i < n_conditions; ++i)
116 {
117 CondItem const* const cond =
118 dynamic_cast<CondItem*>(process_var->child(i));
119 if (cond->getCondition()->getParamName() != param_name.toStdString())
120 {
121 continue;
122 }
123
124 process_var->removeChildren(i, 1);
125 return;
126 }
127}
DataHolderLib::FemCondition * getCondition() const
Returns the FEM Condition associated with the item.
Definition CondItem.h:36
bool removeChildren(int position, int count)
Definition TreeItem.cpp:124

References TreeItem::child(), TreeItem::childCount(), CondItem::getCondition(), DataHolderLib::FemCondition::getParamName(), and TreeItem::removeChildren().

◆ removeCondition [2/2]

void ProcessModel::removeCondition ( QString const & process_var,
QString const & param )
slot

Removes FEMConditions from the the model.

Definition at line 129 of file ProcessModel.cpp.

131{
132 beginResetModel();
133 ProcessVarItem* pv_item(getProcessVarItem(process_var));
134 if (pv_item == nullptr)
135 {
136 return;
137 }
138
139 removeCondition(pv_item, param);
140 _project.removeBoundaryCondition(process_var.toStdString(),
141 param.toStdString());
142 _project.removeSourceTerm(process_var.toStdString(), param.toStdString());
143 endResetModel();
144}
void removeSourceTerm(std::string const &primary_var_name, std::string const &param_name)
Remove one source term.
Definition Project.cpp:139
void removeBoundaryCondition(std::string const &primary_var_name, std::string const &param_name)
Removes one boundary condition.
Definition Project.cpp:123
void removeCondition(QString const &process_var, QString const &param)
Removes FEMConditions from the the model.

References _project, getProcessVarItem(), DataHolderLib::Project::removeBoundaryCondition(), removeCondition(), and DataHolderLib::Project::removeSourceTerm().

Referenced by removeCondition(), and removeProcessVariable().

◆ removeProcessVariable

void ProcessModel::removeProcessVariable ( QString const & name)
slot

Removes a process variable incl all associated conditions from the model.

Definition at line 146 of file ProcessModel.cpp.

147{
148 beginResetModel();
149 ProcessVarItem* pv_item(getProcessVarItem(name));
150 if (pv_item == nullptr)
151 {
152 return;
153 }
154
155 int const n_conds = pv_item->childCount();
156 for (int i = n_conds - 1; i >= 0; --i)
157 {
158 removeCondition(pv_item,
159 static_cast<CondItem*>(pv_item->child(i))->getName());
160 }
161
162 _project.removePrimaryVariable(name.toStdString());
163 int const idx = pv_item->row();
164 _rootItem->removeChildren(idx, 1);
165 endResetModel();
166}
QString const getName() const
Definition CondItem.h:38
void removePrimaryVariable(std::string const &primary_var_name)
Removes a primary variable incl. all associated conditions.
Definition Project.cpp:100

References _project, TreeModel::_rootItem, TreeItem::child(), TreeItem::childCount(), CondItem::getName(), getProcessVarItem(), TreeItem::removeChildren(), removeCondition(), DataHolderLib::Project::removePrimaryVariable(), and TreeItem::row().

Referenced by clearModel().

◆ updateModel

void ProcessModel::updateModel ( )
slot

Updates the model based on the ProjectData-object.

Definition at line 178 of file ProcessModel.cpp.

179{
182}
std::vector< std::unique_ptr< SourceTerm > > const & getSourceTerms() const
Returns the vector of source terms.
Definition Project.h:87
std::vector< std::unique_ptr< BoundaryCondition > > const & getBoundaryConditions() const
Returns the vector of boundary conditions.
Definition Project.h:81
void addBoundaryConditions(std::vector< std::unique_ptr< DataHolderLib::BoundaryCondition > > const &conditions)
Adds vector of Boundary Conditions to the model.
void addSourceTerms(std::vector< std::unique_ptr< DataHolderLib::SourceTerm > > const &conditions)
Adds vector of Source Terms to the model.

References _project, addBoundaryConditions(), addSourceTerms(), DataHolderLib::Project::getBoundaryConditions(), and DataHolderLib::Project::getSourceTerms().

Member Data Documentation

◆ _project

DataHolderLib::Project& ProcessModel::_project
private

Definition at line 89 of file ProcessModel.h.

Referenced by removeCondition(), removeProcessVariable(), and updateModel().


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