OGS
ProcessView Class Referencefinal

Detailed Description

A view for FEM-Conditions (Initial- & Boundary Conditions / Source Terms) with a number of additional information such as Process Type, Distribution, etc.

See also
ConditionModel, CondItem

Definition at line 29 of file ProcessView.h.

#include <ProcessView.h>

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

Signals

void itemSelectionChanged (QItemSelection const &selected, QItemSelection const &deselected)
 
void conditionRemoved (QString const &, QString const &)
 
void processVarRemoved (QString const &)
 
void clearConditionView ()
 
void processVarSelected (DataHolderLib::FemCondition *cond)
 
void conditionSelected (DataHolderLib::FemCondition *cond)
 

Public Member Functions

 ProcessView (QWidget *parent=nullptr)
 Constructor. More...
 
void updateView ()
 Update the view to visualise changes made to the underlying data. More...
 

Protected Slots

void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 Instructions if the selection of items in the view has changed. More...
 

Private Slots

void on_Clicked (QModelIndex idx)
 
void removeCondition ()
 
void removeProcessVar ()
 

Private Member Functions

void contextMenuEvent (QContextMenuEvent *e) override
 
bool isProcessVarItem (const QModelIndex &idx) const
 
bool isConditionItem (const QModelIndex &idx) const
 

Constructor & Destructor Documentation

◆ ProcessView()

ProcessView::ProcessView ( QWidget *  parent = nullptr)
explicit

Constructor.

Definition at line 23 of file ProcessView.cpp.

23 : QTreeView(parent) {}

Member Function Documentation

◆ clearConditionView

void ProcessView::clearConditionView ( )
signal

◆ conditionRemoved

void ProcessView::conditionRemoved ( QString const &  ,
QString const &   
)
signal

Referenced by removeCondition().

◆ conditionSelected

void ProcessView::conditionSelected ( DataHolderLib::FemCondition cond)
signal

Referenced by selectionChanged().

◆ contextMenuEvent()

void ProcessView::contextMenuEvent ( QContextMenuEvent *  e)
overrideprivate

Actions to be taken after a right mouse click is performed in the station view.

Definition at line 71 of file ProcessView.cpp.

72 {
73  Q_UNUSED(event);
74 
75  const QModelIndex idx(this->selectionModel()->currentIndex());
76  QMenu menu;
77 
78  if (isProcessVarItem(idx))
79  {
80  // QAction* saveCondAction = menu.addAction("Save FEM Conditions...");
81  QAction* removeProcessVarAction =
82  menu.addAction("Remove process variable");
83  // connect(saveCondAction, SIGNAL(triggered()), this,
84  // SLOT(saveConditions()));
85  connect(removeProcessVarAction, SIGNAL(triggered()), this,
86  SLOT(removeProcessVar()));
87  }
88  else if (isConditionItem(idx))
89  {
90  QAction* removeCondAction = menu.addAction("Remove condition");
91  connect(removeCondAction, SIGNAL(triggered()), this,
92  SLOT(removeCondition()));
93  // QAction* editCondAction = menu.addAction("Edit condition");
94  // connect(editCondAction, SIGNAL(triggered()), this,
95  // SLOT(editCondition())); else editCondAction->setEnabled(false);
96  }
97 
98  menu.exec(event->globalPos());
99 }
bool isProcessVarItem(const QModelIndex &idx) const
bool isConditionItem(const QModelIndex &idx) const
void removeProcessVar()
void removeCondition()

References isConditionItem(), isProcessVarItem(), removeCondition(), and removeProcessVar().

◆ isConditionItem()

bool ProcessView::isConditionItem ( const QModelIndex &  idx) const
private

Definition at line 158 of file ProcessView.cpp.

159 {
160  return (dynamic_cast<CondItem*>(
161  static_cast<ProcessModel*>(this->model())->getItem(idx)) !=
162  nullptr);
163 }
A TreeItem containing a boundary condition or source term.
Definition: CondItem.h:26
A model implementing a tree structure for process-relevant information such as process types,...
Definition: ProcessModel.h:36

Referenced by contextMenuEvent().

◆ isProcessVarItem()

bool ProcessView::isProcessVarItem ( const QModelIndex &  idx) const
private

Definition at line 151 of file ProcessView.cpp.

152 {
153  return (dynamic_cast<ProcessVarItem*>(
154  static_cast<ProcessModel*>(this->model())->getItem(idx)) !=
155  nullptr);
156 }
A TreeItem representing process variable information.

Referenced by contextMenuEvent().

◆ itemSelectionChanged

void ProcessView::itemSelectionChanged ( QItemSelection const &  selected,
QItemSelection const &  deselected 
)
signal

Referenced by selectionChanged().

◆ on_Clicked

void ProcessView::on_Clicked ( QModelIndex  idx)
privateslot

Definition at line 33 of file ProcessView.cpp.

34 {
35  qDebug("%d, %d", idx.parent().row(), idx.row());
36 }

◆ processVarRemoved

void ProcessView::processVarRemoved ( QString const &  )
signal

Referenced by removeProcessVar().

◆ processVarSelected

void ProcessView::processVarSelected ( DataHolderLib::FemCondition cond)
signal

Referenced by selectionChanged().

◆ removeCondition

void ProcessView::removeCondition ( )
privateslot

Definition at line 101 of file ProcessView.cpp.

102 {
103  CondItem* item = dynamic_cast<CondItem*>(
104  static_cast<ProcessModel*>(this->model())
105  ->getItem(this->selectionModel()->currentIndex()));
106  if (item)
107  {
108  emit clearConditionView();
109  emit conditionRemoved(
110  QString::fromStdString(item->getCondition()->getProcessVarName()),
111  item->getName());
112  }
113 }
QString const getName() const
Definition: CondItem.h:38
DataHolderLib::FemCondition * getCondition() const
Returns the FEM Condition associated with the item.
Definition: CondItem.h:36
std::string const getProcessVarName() const
Returns the name of the associated process variable.
Definition: FemCondition.h:47
void conditionRemoved(QString const &, QString const &)
void clearConditionView()

References clearConditionView(), conditionRemoved(), CondItem::getCondition(), CondItem::getName(), and DataHolderLib::FemCondition::getProcessVarName().

Referenced by contextMenuEvent().

◆ removeProcessVar

void ProcessView::removeProcessVar ( )
privateslot

Definition at line 115 of file ProcessView.cpp.

116 {
117  ProcessVarItem* item = dynamic_cast<ProcessVarItem*>(
118  static_cast<ProcessModel*>(this->model())
119  ->getItem(this->selectionModel()->currentIndex()));
120  if (item)
121  {
122  emit clearConditionView();
123  emit processVarRemoved(item->getName());
124  }
125 }
QString getName() const
void processVarRemoved(QString const &)

References clearConditionView(), ProcessVarItem::getName(), and processVarRemoved().

Referenced by contextMenuEvent().

◆ selectionChanged

void ProcessView::selectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
overrideprotectedslot

Instructions if the selection of items in the view has changed.

Definition at line 38 of file ProcessView.cpp.

40 {
41  if (!selected.isEmpty())
42  {
43  emit clearConditionView();
44  const QModelIndex idx = *(selected.indexes().begin());
45 
46  if (idx.parent().isValid()) // not root node
47  {
48  CondItem const* const item = dynamic_cast<CondItem*>(
49  static_cast<ProcessModel*>(this->model())->getItem(idx));
50  if (item != nullptr)
51  {
52  emit conditionSelected(item->getCondition());
53  }
54  }
55  else
56  {
57  CondItem const* const item = dynamic_cast<CondItem*>(
58  static_cast<ProcessModel*>(this->model())
59  ->getItem(idx)
60  ->child(0));
61  if (item != nullptr)
62  {
63  emit processVarSelected(item->getCondition());
64  }
65  }
66  }
67  emit itemSelectionChanged(selected, deselected);
68  QTreeView::selectionChanged(selected, deselected);
69 }
void conditionSelected(DataHolderLib::FemCondition *cond)
void itemSelectionChanged(QItemSelection const &selected, QItemSelection const &deselected)
void processVarSelected(DataHolderLib::FemCondition *cond)

References clearConditionView(), conditionSelected(), CondItem::getCondition(), itemSelectionChanged(), and processVarSelected().

◆ updateView()

void ProcessView::updateView ( )

Update the view to visualise changes made to the underlying data.

Definition at line 25 of file ProcessView.cpp.

26 {
27  setAlternatingRowColors(true);
28  resizeColumnToContents(0);
29  setColumnWidth(1, 50);
30  setColumnWidth(2, 50);
31 }

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