OGS
FemConditionModel.cpp
Go to the documentation of this file.
1 
11 #include "FemConditionModel.h"
12 
15 #include "Base/TreeItem.h"
16 
21 {
22  QList<QVariant> root_data;
23  delete _rootItem;
24  root_data << "Parameter"
25  << "Value";
26  _rootItem = new TreeItem(root_data, nullptr);
27 }
28 
30 {
31  beginResetModel();
32  this->clearView();
33 
34  QList<QVariant> cond_data;
35  cond_data << QString::fromStdString(cond->getConditionClassStr()) + ":"
36  << QString::fromStdString(cond->getParamName());
37  TreeItem* cond_item = new TreeItem(cond_data, _rootItem);
38  _rootItem->appendChild(cond_item);
39 
40  QList<QVariant> type_data;
41  std::string type_str;
42  if (cond->getConditionClassStr() == "Boundary Condition")
43  {
45  static_cast<DataHolderLib::BoundaryCondition*>(cond)->getType());
46  }
47  else if (cond->getConditionClassStr() == "Source Term")
48  {
50  static_cast<DataHolderLib::SourceTerm*>(cond)->getType());
51  }
52  type_data << "Type:" << QString::fromStdString(type_str);
53  TreeItem* type_item = new TreeItem(type_data, cond_item);
54  cond_item->appendChild(type_item);
55 
56  QString const obj_class_str =
58  ? "Mesh:"
59  : "Geometry:";
60  QList<QVariant> obj_class_data;
61  obj_class_data << "Set on " + obj_class_str
62  << QString::fromStdString(cond->getBaseObjName());
63  TreeItem* obj_class_item = new TreeItem(obj_class_data, cond_item);
64  cond_item->appendChild(obj_class_item);
65 
66  QString const obj_str =
68  ? "Mesh array:"
69  : "Geo-Object:";
70  QString const name_str =
72  ? QString::fromStdString(cond->getParamName())
73  : QString::fromStdString(cond->getObjName());
74  QList<QVariant> obj_data;
75  obj_data << obj_str << name_str;
76  TreeItem* obj_item = new TreeItem(obj_data, cond_item);
77  cond_item->appendChild(obj_item);
78 
79  endResetModel();
80 }
81 
83 {
84  beginResetModel();
85  this->clearView();
86 
88 
89  QList<QVariant> pvar_data;
90  pvar_data << "Process variable:" << QString::fromStdString(var.name);
91  TreeItem* pvar_item = new TreeItem(pvar_data, _rootItem);
92  _rootItem->appendChild(pvar_item);
93 
94  QList<QVariant> order_data;
95  order_data << "Order:" << QString::number(var.order);
96  TreeItem* order_item = new TreeItem(order_data, pvar_item);
97  pvar_item->appendChild(order_item);
98 
99  QList<QVariant> comp_data;
100  comp_data << "Number of components:" << QString::number(var.components);
101  TreeItem* comp_item = new TreeItem(comp_data, pvar_item);
102  pvar_item->appendChild(comp_item);
103 
104  endResetModel();
105 }
106 
108 {
109  beginResetModel();
111  endResetModel();
112 }
Definition of the TreeItem class.
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.
Definition: FemCondition.h:40
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)
Definition: FemCondition.h:59
BaseObjType getBaseObjType() const
Specifies if the condition is set a geometry or on a mesh.
Definition: FemCondition.h:56
std::string const getObjName() const
Returns the name of the geometric object.
Definition: FemCondition.h:62
std::string const getParamName() const
Returns the name of the parameter associated with the condition.
Definition: FemCondition.h:53
ProcessVariable const & getProcessVar() const
Returns the numerical order of the process variable.
Definition: FemCondition.h:50
Managing data associated with a source term.
Definition: SourceTerm.h:19
static std::string convertTypeToString(ConditionType type)
Converts the type enum into a string.
Definition: SourceTerm.cpp:37
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:28
virtual int childCount() const
Definition: TreeItem.cpp:65
void appendChild(TreeItem *item)
Definition: TreeItem.cpp:42
bool removeChildren(int position, int count)
Definition: TreeItem.cpp:124
A hierarchical model for a tree implemented as a double-linked list.
Definition: TreeModel.h:30
TreeItem * _rootItem
Definition: TreeModel.h:58