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 13 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 13 of file FemConditionModel.cpp.

14{
15 QList<QVariant> root_data;
16 delete _rootItem;
17 root_data << "Parameter"
18 << "Value";
19 _rootItem = new TreeItem(root_data, nullptr);
20}
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

References TreeModel::TreeModel(), TreeModel::_rootItem, and TreeModel::parent().

Member Function Documentation

◆ clearView

void FemConditionModel::clearView ( )
slot

Clears the tree.

Definition at line 100 of file FemConditionModel.cpp.

101{
102 beginResetModel();
103 _rootItem->removeChildren(0, _rootItem->childCount());
104 endResetModel();
105}

References TreeModel::_rootItem.

Referenced by setFemCondition(), and setProcessVariable().

◆ columnCount()

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

Definition at line 20 of file FemConditionModel.h.

22 {
23 return 2;
24 }

◆ setFemCondition

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

Displays information on a boundary condition or source term.

Definition at line 22 of file FemConditionModel.cpp.

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}
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)
BaseObjType getBaseObjType() const
Specifies if the condition is set a geometry or on a mesh.
std::string const getParamName() const
Returns the name of the parameter associated with the condition.
static std::string convertTypeToString(ConditionType type)
Converts the type enum into a string.
void clearView()
Clears the tree.
void appendChild(TreeItem *item)
Definition TreeItem.cpp:31

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 75 of file FemConditionModel.cpp.

76{
77 beginResetModel();
78 this->clearView();
79
80 DataHolderLib::ProcessVariable const& var(cond->getProcessVar());
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}
ProcessVariable const & getProcessVar() const
Returns the numerical order of the process variable.

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: