OGS
VtkVisTabWidget Class Reference

Detailed Description

Contains a QTreeView of the VtkVisPipeline and a properties panel for adjusting vtkAlgorithms rendering and filter settings.

Definition at line 15 of file VtkVisTabWidget.h.

#include <VtkVisTabWidget.h>

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

Signals

void requestViewUpdate ()
 Is emitted when a property was changed.

Public Member Functions

 VtkVisTabWidget (QWidget *parent=nullptr)
 Constructor.

Protected Slots

void setActiveItem (VtkVisPipelineItem *item)
 Updates the property panels to show information on the given VtkVisPipelineItem.
void on_arrayResetPushButton_clicked ()
void on_diffuseColorPickerButton_colorPicked (QColor color)
void on_visibleEdgesCheckBox_stateChanged (int state)
void on_edgeColorPickerButton_colorPicked (QColor color)
void on_opacitySlider_sliderMoved (int value)
void on_scaleZ_textChanged (const QString &text)
void on_transX_textChanged (const QString &text)
void on_transY_textChanged (const QString &text)
void on_transZ_textChanged (const QString &text)
void SetActiveAttributeOnItem (const QString &name)

Private Member Functions

void buildProportiesDialog (VtkVisPipelineItem *item)
 Reads the algorithm properties of the given pipeline item and builds a dialog for adjusting these properties in the GUI.
void buildScalarArrayComboBox (VtkVisPipelineItem *item)
 Reads the scalar arrays of the given vtk-object and constructs content for the scalar array selection box.
void translateItem ()

Private Attributes

VtkVisPipelineItem_item {nullptr}

Constructor & Destructor Documentation

◆ VtkVisTabWidget()

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

Constructor.

Definition at line 21 of file VtkVisTabWidget.cpp.

21 : QWidget(parent)
22{
23 setupUi(this);
24
25 this->scaleZ->setValidator(new QDoubleValidator(0, 100, 8, this));
26
27 this->transX->setValidator(new QDoubleValidator(this));
28 this->transY->setValidator(new QDoubleValidator(this));
29 this->transZ->setValidator(new QDoubleValidator(this));
30
31 connect(this->vtkVisPipelineView, SIGNAL(requestViewUpdate()), this,
32 SIGNAL(requestViewUpdate()));
33
34 connect(this->vtkVisPipelineView, SIGNAL(itemSelected(VtkVisPipelineItem*)),
35 this, SLOT(setActiveItem(VtkVisPipelineItem*)));
36
37 connect(this->activeScalarComboBox,
38 SIGNAL(currentIndexChanged(const QString&)), this,
39 SLOT(SetActiveAttributeOnItem(const QString&)));
40}
void setActiveItem(VtkVisPipelineItem *item)
Updates the property panels to show information on the given VtkVisPipelineItem.
void SetActiveAttributeOnItem(const QString &name)
void requestViewUpdate()
Is emitted when a property was changed.

References requestViewUpdate(), SetActiveAttributeOnItem(), and setActiveItem().

Member Function Documentation

◆ buildProportiesDialog()

void VtkVisTabWidget::buildProportiesDialog ( VtkVisPipelineItem * item)
private

Reads the algorithm properties of the given pipeline item and builds a dialog for adjusting these properties in the GUI.

Definition at line 238 of file VtkVisTabWidget.cpp.

239{
240 auto* layout =
241 static_cast<QFormLayout*>(this->scrollAreaWidgetContents->layout());
242 while (layout->count())
243 {
244 delete layout->takeAt(0)->widget();
245 }
246
247 QMap<QString, QVariant>* propMap = nullptr;
248 QMap<QString, QList<QVariant>>* propVecMap = nullptr;
249 VtkAlgorithmProperties* algProps = item->getVtkProperties();
250
251 if (algProps == nullptr)
252 WARN("VtkAlgorithmProperties null!");
253
254 // Retrieve algorithm properties
255 if (item->compositeFilter())
256 {
257 propMap = item->compositeFilter()->GetAlgorithmUserProperties();
258 propVecMap =
260 }
261 else
262 {
263 if (algProps)
264 {
265 propMap = algProps->GetAlgorithmUserProperties();
266 propVecMap = algProps->GetAlgorithmUserVectorProperties();
267 }
268 }
269
270 // Select appropriate GUI element and set connect for each property
271 if (propMap)
272 {
273 QMapIterator<QString, QVariant> i(*propMap);
274 while (i.hasNext())
275 {
276 i.next();
277 QString key = i.key();
278 QVariant value = i.value();
279
280 VtkAlgorithmPropertyLineEdit* lineEdit;
281 VtkAlgorithmPropertyCheckbox* checkbox;
282 switch (value.type())
283 {
284 case QVariant::Double:
285 lineEdit = new VtkAlgorithmPropertyLineEdit(
286 QString::number(value.toDouble()), key,
287 QVariant::Double, algProps);
288 connect(lineEdit, SIGNAL(editingFinished()), this,
289 SIGNAL(requestViewUpdate()));
290 layout->addRow(key, lineEdit);
291 break;
292
293 case QVariant::Int:
294 lineEdit = new VtkAlgorithmPropertyLineEdit(
295 QString::number(value.toInt()), key, QVariant::Int,
296 algProps);
297 connect(lineEdit, SIGNAL(editingFinished()), this,
298 SIGNAL(requestViewUpdate()));
299 layout->addRow(key, lineEdit);
300 break;
301
302 case QVariant::Bool:
303 checkbox = new VtkAlgorithmPropertyCheckbox(value.toBool(),
304 key, algProps);
305 connect(checkbox, SIGNAL(stateChanged(int)), this,
306 SIGNAL(requestViewUpdate()));
307 layout->addRow(key, checkbox);
308 break;
309
310 default:
311 break;
312 }
313 }
314 }
315
316 if (propVecMap)
317 {
318 QMapIterator<QString, QList<QVariant>> i(*propVecMap);
319 while (i.hasNext())
320 {
321 i.next();
322 QString key = i.key();
323 QList<QVariant> values = i.value();
324
325 if (!values.empty())
326 {
327 QList<QString> valuesAsString;
328 foreach (QVariant variant, values)
329 valuesAsString.push_back(variant.toString());
330
331 VtkAlgorithmPropertyVectorEdit* vectorEdit =
332 new VtkAlgorithmPropertyVectorEdit(
333 valuesAsString, key, values.front().type(), algProps);
334 connect(vectorEdit, SIGNAL(editingFinished()), this,
335 SIGNAL(requestViewUpdate()));
336 layout->addRow(key, vectorEdit);
337 }
338 }
339 }
340}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
QMap< QString, QVariant > * GetAlgorithmUserProperties() const
Returns a map of user properties.
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties() const
Returns a map of vector user properties.
VtkAlgorithmProperties * getVtkProperties() const
Returns the VtkAlgorithmProperties.
VtkCompositeFilter * compositeFilter() const
Returns the composite filter.

References VtkVisPipelineItem::compositeFilter(), VtkAlgorithmProperties::GetAlgorithmUserProperties(), VtkAlgorithmProperties::GetAlgorithmUserVectorProperties(), VtkVisPipelineItem::getVtkProperties(), requestViewUpdate(), and WARN().

Referenced by setActiveItem().

◆ buildScalarArrayComboBox()

void VtkVisTabWidget::buildScalarArrayComboBox ( VtkVisPipelineItem * item)
private

Reads the scalar arrays of the given vtk-object and constructs content for the scalar array selection box.

Definition at line 342 of file VtkVisTabWidget.cpp.

343{
344 QStringList dataSetAttributesList = item->getScalarArrayNames();
345 dataSetAttributesList.push_back("Solid Color"); // all scalars switched off
346 this->activeScalarComboBox->blockSignals(true);
347 this->activeScalarComboBox->clear();
348 this->activeScalarComboBox->insertItems(0, dataSetAttributesList);
349 this->activeScalarComboBox->blockSignals(false);
350 QString active_array_name = item->GetActiveAttribute();
351 QList<QString>::iterator it = dataSetAttributesList.begin();
352 if (active_array_name.length() == 0)
353 {
354 item->SetActiveAttribute(*it);
355 }
356 else
357 {
358 int idx(0);
359 for (it = dataSetAttributesList.begin();
360 it != dataSetAttributesList.end();
361 ++it)
362 {
363 if (active_array_name.compare((*it).right((*it).length() - 2)) == 0)
364 {
365 this->activeScalarComboBox->setCurrentIndex(idx);
366 break;
367 }
368
369 idx++;
370 }
371 }
372}
QStringList getScalarArrayNames() const
Returns a list of array names prefixed with P- or C- for point and cell data.
virtual QString GetActiveAttribute() const
virtual void SetActiveAttribute(const QString &str)

References VtkVisPipelineItem::GetActiveAttribute(), VtkVisPipelineItem::getScalarArrayNames(), and VtkVisPipelineItem::SetActiveAttribute().

Referenced by setActiveItem().

◆ on_arrayResetPushButton_clicked

void VtkVisTabWidget::on_arrayResetPushButton_clicked ( )
protectedslot

Definition at line 42 of file VtkVisTabWidget.cpp.

43{
44 VtkAlgorithmProperties* props = _item->getVtkProperties();
45 const QString selected_array_name =
46 this->activeScalarComboBox->currentText();
47 props->RemoveLookupTable(selected_array_name);
48 _item->SetActiveAttribute(selected_array_name);
49}
void RemoveLookupTable(const QString &array_name)
Removes the lookup table for the given scalar.
VtkVisPipelineItem * _item

References _item, and VtkAlgorithmProperties::RemoveLookupTable().

◆ on_diffuseColorPickerButton_colorPicked

void VtkVisTabWidget::on_diffuseColorPickerButton_colorPicked ( QColor color)
protectedslot

Definition at line 144 of file VtkVisTabWidget.cpp.

145{
146 static_cast<vtkActor*>(_item->actor())
147 ->GetProperty()
148 ->SetDiffuseColor(color.redF(), color.greenF(), color.blueF());
149
150 emit requestViewUpdate();
151}

References _item, and requestViewUpdate().

◆ on_edgeColorPickerButton_colorPicked

void VtkVisTabWidget::on_edgeColorPickerButton_colorPicked ( QColor color)
protectedslot

Definition at line 173 of file VtkVisTabWidget.cpp.

174{
175 static_cast<vtkActor*>(_item->actor())
176 ->GetProperty()
177 ->SetEdgeColor(color.redF(), color.greenF(), color.blueF());
178 emit requestViewUpdate();
179}

References _item, and requestViewUpdate().

◆ on_opacitySlider_sliderMoved

void VtkVisTabWidget::on_opacitySlider_sliderMoved ( int value)
protectedslot

Definition at line 181 of file VtkVisTabWidget.cpp.

182{
183 static_cast<vtkActor*>(_item->actor())
184 ->GetProperty()
185 ->SetOpacity(value / 100.0);
186 emit requestViewUpdate();
187}

References _item, and requestViewUpdate().

◆ on_scaleZ_textChanged

void VtkVisTabWidget::on_scaleZ_textChanged ( const QString & text)
protectedslot

Definition at line 189 of file VtkVisTabWidget.cpp.

190{
191 bool ok = true;
192 double scale = text.toDouble(&ok);
193
194 // If z scale becomes zero, the object becomes invisible
195 if (ok && scale != 0.0)
196 {
197 _item->setScale(1.0, 1.0, scale);
198
199 for (int i = 0; i < _item->childCount(); i++)
200 {
201 VtkVisPipelineItem* childItem = _item->child(i);
202 if (childItem)
203 {
204 auto* colorFilter =
205 dynamic_cast<VtkCompositeColorByHeightFilter*>(
206 childItem->compositeFilter());
207 if (colorFilter)
208 {
209 VtkColorByHeightFilter::SafeDownCast(
210 colorFilter->GetOutputAlgorithm())
211 ->SetTableRangeScaling(scale);
212 }
213 }
214 }
215
216 emit requestViewUpdate();
217 }
218}
void scale(PETScVector &x, PetscScalar const a)
Definition LinAlg.cpp:37

References _item, VtkVisPipelineItem::compositeFilter(), and requestViewUpdate().

◆ on_transX_textChanged

void VtkVisTabWidget::on_transX_textChanged ( const QString & text)
inlineprotectedslot

Definition at line 33 of file VtkVisTabWidget.h.

34 {
35 Q_UNUSED(text);
36 this->translateItem();
37 }

References translateItem().

◆ on_transY_textChanged

void VtkVisTabWidget::on_transY_textChanged ( const QString & text)
inlineprotectedslot

Definition at line 38 of file VtkVisTabWidget.h.

39 {
40 Q_UNUSED(text);
41 this->translateItem();
42 }

References translateItem().

◆ on_transZ_textChanged

void VtkVisTabWidget::on_transZ_textChanged ( const QString & text)
inlineprotectedslot

Definition at line 43 of file VtkVisTabWidget.h.

44 {
45 Q_UNUSED(text);
46 this->translateItem();
47 }

References translateItem().

◆ on_visibleEdgesCheckBox_stateChanged

void VtkVisTabWidget::on_visibleEdgesCheckBox_stateChanged ( int state)
protectedslot

Definition at line 153 of file VtkVisTabWidget.cpp.

154{
155 if (state == Qt::Checked)
156 {
157 static_cast<vtkActor*>(_item->actor())
158 ->GetProperty()
159 ->SetEdgeVisibility(1);
160 edgeColorPickerButton->setEnabled(true);
161 }
162 else
163 {
164 static_cast<vtkActor*>(_item->actor())
165 ->GetProperty()
166 ->SetEdgeVisibility(0);
167 edgeColorPickerButton->setEnabled(false);
168 }
169
170 emit requestViewUpdate();
171}

References _item, and requestViewUpdate().

◆ requestViewUpdate

◆ SetActiveAttributeOnItem

void VtkVisTabWidget::SetActiveAttributeOnItem ( const QString & name)
protectedslot

Definition at line 374 of file VtkVisTabWidget.cpp.

375{
376 _item->SetActiveAttribute(name);
377 emit requestViewUpdate();
378}

References _item, and requestViewUpdate().

Referenced by VtkVisTabWidget().

◆ setActiveItem

void VtkVisTabWidget::setActiveItem ( VtkVisPipelineItem * item)
protectedslot

Updates the property panels to show information on the given VtkVisPipelineItem.

Definition at line 51 of file VtkVisTabWidget.cpp.

52{
53 if (item)
54 {
55 _item = item;
56 transformTabWidget->setEnabled(true);
57
58 auto* transform_filter =
59 dynamic_cast<vtkTransformFilter*>(_item->transformFilter());
60 if (transform_filter) // if data set
61 {
62 actorPropertiesGroupBox->setEnabled(true);
63 vtkProperty* vtkProps =
64 static_cast<vtkActor*>(_item->actor())->GetProperty();
65 diffuseColorPickerButton->setColor(vtkProps->GetDiffuseColor());
66 visibleEdgesCheckBox->setChecked(vtkProps->GetEdgeVisibility());
67 edgeColorPickerButton->setColor(vtkProps->GetEdgeColor());
68 opacitySlider->setValue(
69 static_cast<int>(vtkProps->GetOpacity() * 100.0));
70
71 auto* transform =
72 static_cast<vtkTransform*>(transform_filter->GetTransform());
73 if (transform)
74 {
75 double scale[3];
76 transform->GetScale(scale);
77 double trans[3];
78 transform->GetPosition(trans);
79
80 // switch signals off for just filling in text-boxes after
81 // clicking on an item
82 this->scaleZ->blockSignals(true);
83 this->transX->blockSignals(true);
84 this->transY->blockSignals(true);
85 this->transZ->blockSignals(true);
86 this->scaleZ->setText(QString::number(scale[2]));
87 this->transX->setText(QString::number(trans[0] / scale[0]));
88 this->transY->setText(QString::number(trans[1] / scale[1]));
89 this->transZ->setText(QString::number(trans[2] / scale[2]));
90 this->scaleZ->blockSignals(false);
91 this->transX->blockSignals(false);
92 this->transY->blockSignals(false);
93 this->transZ->blockSignals(false);
94 // switch signals back on
95 }
97
98 // Set to last active attribute
99 QString activeAttribute = _item->GetActiveAttribute();
100 if (activeAttribute.length() > 0)
101 {
102 for (int i = 0; i < this->activeScalarComboBox->count(); i++)
103 {
104 QString itemText = this->activeScalarComboBox->itemText(i);
105 if (itemText.compare(activeAttribute) == 0)
106 {
107 this->activeScalarComboBox->setCurrentIndex(i);
108 break;
109 }
110 }
111 }
112 }
113 else // if image
114 {
115 const VtkVisImageItem* img = static_cast<VtkVisImageItem*>(_item);
116 actorPropertiesGroupBox->setEnabled(false);
117 auto* transform =
118 static_cast<vtkImageChangeInformation*>(img->transformFilter());
119 double trans[3];
120 transform->GetOriginTranslation(trans);
121 this->transX->blockSignals(true);
122 this->transY->blockSignals(true);
123 this->transZ->blockSignals(true);
124 this->transX->setText(QString::number(trans[0]));
125 this->transY->setText(QString::number(trans[1]));
126 this->transZ->setText(QString::number(trans[2]));
127 this->transX->blockSignals(false);
128 this->transY->blockSignals(false);
129 this->transZ->blockSignals(false);
130 }
131
132 this->buildProportiesDialog(item);
133
134 emit requestViewUpdate();
135 }
136 else
137 {
138 actorPropertiesGroupBox->setEnabled(false);
139 transformTabWidget->setEnabled(false);
140 this->activeScalarComboBox->clear();
141 }
142}
vtkAlgorithm * transformFilter() const override
void buildProportiesDialog(VtkVisPipelineItem *item)
Reads the algorithm properties of the given pipeline item and builds a dialog for adjusting these pro...
void buildScalarArrayComboBox(VtkVisPipelineItem *item)
Reads the scalar arrays of the given vtk-object and constructs content for the scalar array selection...

References _item, buildProportiesDialog(), buildScalarArrayComboBox(), requestViewUpdate(), and VtkVisImageItem::transformFilter().

Referenced by VtkVisTabWidget().

◆ translateItem()

void VtkVisTabWidget::translateItem ( )
private

Definition at line 220 of file VtkVisTabWidget.cpp.

221{
222 bool okX(true);
223 bool okY(true);
224 bool okZ(true);
225 double trans[3];
226
227 trans[0] = transX->text().toDouble(&okX);
228 trans[1] = transY->text().toDouble(&okY);
229 trans[2] = transZ->text().toDouble(&okZ);
230
231 if (okX && okY && okZ)
232 {
233 _item->setTranslation(trans[0], trans[1], trans[2]);
234 emit requestViewUpdate();
235 }
236}

References _item, and requestViewUpdate().

Referenced by on_transX_textChanged(), on_transY_textChanged(), and on_transZ_textChanged().

Member Data Documentation

◆ _item


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