OGS
FemConditionModel.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "FemConditionModel.h"
5
8#include "Base/TreeItem.h"
9
14{
15 QList<QVariant> root_data;
16 delete _rootItem;
17 root_data << "Parameter"
18 << "Value";
19 _rootItem = new TreeItem(root_data, nullptr);
20}
21
23{
24 beginResetModel();
25 this->clearView();
26
27 QList<QVariant> cond_data;
28 cond_data << QString::fromStdString(cond->getConditionClassStr()) + ":"
29 << QString::fromStdString(cond->getParamName());
30 TreeItem* cond_item = new TreeItem(cond_data, _rootItem);
31 _rootItem->appendChild(cond_item);
32
33 QList<QVariant> type_data;
34 std::string type_str;
35 if (cond->getConditionClassStr() == "Boundary Condition")
36 {
38 static_cast<DataHolderLib::BoundaryCondition*>(cond)->getType());
39 }
40 else if (cond->getConditionClassStr() == "Source Term")
41 {
43 static_cast<DataHolderLib::SourceTerm*>(cond)->getType());
44 }
45 type_data << "Type:" << QString::fromStdString(type_str);
46 TreeItem* type_item = new TreeItem(type_data, cond_item);
47 cond_item->appendChild(type_item);
48
49 QString const obj_class_str =
51 ? "Mesh:"
52 : "Geometry:";
53 QList<QVariant> obj_class_data;
54 obj_class_data << "Set on " + obj_class_str
55 << QString::fromStdString(cond->getBaseObjName());
56 TreeItem* obj_class_item = new TreeItem(obj_class_data, cond_item);
57 cond_item->appendChild(obj_class_item);
58
59 QString const obj_str =
61 ? "Mesh array:"
62 : "Geo-Object:";
63 QString const name_str =
65 ? QString::fromStdString(cond->getParamName())
66 : QString::fromStdString(cond->getObjName());
67 QList<QVariant> obj_data;
68 obj_data << obj_str << name_str;
69 TreeItem* obj_item = new TreeItem(obj_data, cond_item);
70 cond_item->appendChild(obj_item);
71
72 endResetModel();
73}
74
76{
77 beginResetModel();
78 this->clearView();
79
81
82 QList<QVariant> pvar_data;
83 pvar_data << "Process variable:" << QString::fromStdString(var.name);
84 TreeItem* pvar_item = new TreeItem(pvar_data, _rootItem);
85 _rootItem->appendChild(pvar_item);
86
87 QList<QVariant> order_data;
88 order_data << "Order:" << QString::number(var.order);
89 TreeItem* order_item = new TreeItem(order_data, pvar_item);
90 pvar_item->appendChild(order_item);
91
92 QList<QVariant> comp_data;
93 comp_data << "Number of components:" << QString::number(var.components);
94 TreeItem* comp_item = new TreeItem(comp_data, pvar_item);
95 pvar_item->appendChild(comp_item);
96
97 endResetModel();
98}
99
101{
102 beginResetModel();
103 _rootItem->removeChildren(0, _rootItem->childCount());
104 endResetModel();
105}
static std::string convertTypeToString(ConditionType type)
Converts a string specifying the type into an enum.
Base class for boundary conditions, initial conditions and source terms.
virtual std::string const getConditionClassStr() const =0
Returns the type of condition for displaying purposes.
std::string getBaseObjName() const
Returns the name of the base object (i.e. geometry or mesh)
BaseObjType getBaseObjType() const
Specifies if the condition is set a geometry or on a mesh.
std::string const getObjName() const
Returns the name of the geometric object.
ProcessVariable const & getProcessVar() const
Returns the numerical order of the process variable.
std::string const getParamName() const
Returns the name of the parameter associated with the condition.
Managing data associated with a source term.
static std::string convertTypeToString(ConditionType type)
Converts the type enum into a string.
FemConditionModel(QObject *parent=nullptr)
void setFemCondition(DataHolderLib::FemCondition *cond)
Displays information on a boundary condition or source term.
void clearView()
Clears the tree.
void setProcessVariable(DataHolderLib::FemCondition *cond)
Displays information on a process variable.
Objects nodes for the TreeModel.
Definition TreeItem.h:17
void appendChild(TreeItem *item)
Definition TreeItem.cpp:31
QModelIndex parent(const QModelIndex &index) const override
Definition TreeModel.cpp:70
TreeModel(QObject *parent=nullptr)
Definition TreeModel.cpp:15
TreeItem * _rootItem
Definition TreeModel.h:47