OGS
FemConditionModel Class Reference

Detailed Description

A model for the display of information from boundary conditions and source terms.

See also
TreeModel, FemConditionView, TreeItem

Definition at line 20 of file FemConditionModel.h.

#include <FemConditionModel.h>

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

Public Slots

void clearView ()
 Clears the tree.
 
void setFemCondition (DataHolderLib::FemCondition *cond)
 Displays information on a boundary condition or source term.
 
void setProcessVariable (DataHolderLib::FemCondition *cond)
 Displays information on a process variable.
 
- Public Slots inherited from TreeModel
void updateData ()
 

Public Member Functions

 FemConditionModel (QObject *parent=nullptr)
 
int columnCount (const QModelIndex &=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
 

Additional Inherited Members

- Protected Attributes inherited from TreeModel
TreeItem_rootItem
 

Constructor & Destructor Documentation

◆ FemConditionModel()

FemConditionModel::FemConditionModel ( QObject *  parent = nullptr)
explicit

Constructor.

Definition at line 20 of file FemConditionModel.cpp.

21{
22 QList<QVariant> root_data;
23 delete _rootItem;
24 root_data << "Parameter"
25 << "Value";
26 _rootItem = new TreeItem(root_data, nullptr);
27}
Objects nodes for the TreeModel.
Definition: TreeItem.h:28
A hierarchical model for a tree implemented as a double-linked list.
Definition: TreeModel.h:30
QModelIndex parent(const QModelIndex &index) const override
Definition: TreeModel.cpp:81
TreeItem * _rootItem
Definition: TreeModel.h:58

References TreeModel::_rootItem.

Member Function Documentation

◆ clearView

void FemConditionModel::clearView ( )
slot

Clears the tree.

Definition at line 107 of file FemConditionModel.cpp.

108{
109 beginResetModel();
111 endResetModel();
112}
virtual int childCount() const
Definition: TreeItem.cpp:65
bool removeChildren(int position, int count)
Definition: TreeItem.cpp:124

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

Referenced by setFemCondition(), and setProcessVariable().

◆ columnCount()

int FemConditionModel::columnCount ( const QModelIndex &  = QModelIndex()) const
inlineoverride

Definition at line 27 of file FemConditionModel.h.

29 {
30 return 2;
31 }

◆ setFemCondition

void FemConditionModel::setFemCondition ( DataHolderLib::FemCondition cond)
slot

Displays information on a boundary condition or source term.

Definition at line 29 of file FemConditionModel.cpp.

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}
static std::string convertTypeToString(ConditionType type)
Converts a string specifying the type into an enum.
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
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
void clearView()
Clears the tree.
void appendChild(TreeItem *item)
Definition: TreeItem.cpp:42

References TreeModel::_rootItem, TreeItem::appendChild(), clearView(), DataHolderLib::BoundaryCondition::convertTypeToString(), DataHolderLib::SourceTerm::convertTypeToString(), DataHolderLib::FemCondition::getBaseObjName(), DataHolderLib::FemCondition::getBaseObjType(), DataHolderLib::FemCondition::getConditionClassStr(), DataHolderLib::FemCondition::getObjName(), DataHolderLib::FemCondition::getParamName(), and DataHolderLib::MESH.

◆ setProcessVariable

void FemConditionModel::setProcessVariable ( DataHolderLib::FemCondition cond)
slot

Displays information on a process variable.

Definition at line 82 of file FemConditionModel.cpp.

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}
ProcessVariable const & getProcessVar() const
Returns the numerical order of the process variable.
Definition: FemCondition.h:50

References TreeModel::_rootItem, TreeItem::appendChild(), clearView(), DataHolderLib::ProcessVariable::components, DataHolderLib::FemCondition::getProcessVar(), DataHolderLib::ProcessVariable::name, and DataHolderLib::ProcessVariable::order.


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