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 27 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 32 of file VtkVisTabWidget.cpp.

32 : QWidget(parent)
33{
34 setupUi(this);
35
36 this->scaleZ->setValidator(new QDoubleValidator(0, 100, 8, this));
37
38 this->transX->setValidator(new QDoubleValidator(this));
39 this->transY->setValidator(new QDoubleValidator(this));
40 this->transZ->setValidator(new QDoubleValidator(this));
41
42 connect(this->vtkVisPipelineView, SIGNAL(requestViewUpdate()), this,
43 SIGNAL(requestViewUpdate()));
44
45 connect(this->vtkVisPipelineView, SIGNAL(itemSelected(VtkVisPipelineItem*)),
46 this, SLOT(setActiveItem(VtkVisPipelineItem*)));
47
48 connect(this->activeScalarComboBox,
49 SIGNAL(currentIndexChanged(const QString&)), this,
50 SLOT(SetActiveAttributeOnItem(const QString&)));
51}
An item in the VtkVisPipeline containing a graphic object to be visualized.
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 249 of file VtkVisTabWidget.cpp.

250{
251 auto* layout =
252 static_cast<QFormLayout*>(this->scrollAreaWidgetContents->layout());
253 while (layout->count())
254 {
255 delete layout->takeAt(0)->widget();
256 }
257
258 QMap<QString, QVariant>* propMap = nullptr;
259 QMap<QString, QList<QVariant>>* propVecMap = nullptr;
260 VtkAlgorithmProperties* algProps = item->getVtkProperties();
261
262 if (algProps == nullptr)
263 WARN("VtkAlgorithmProperties null!");
264
265 // Retrieve algorithm properties
266 if (item->compositeFilter())
267 {
268 propMap = item->compositeFilter()->GetAlgorithmUserProperties();
269 propVecMap =
271 }
272 else
273 {
274 if (algProps)
275 {
276 propMap = algProps->GetAlgorithmUserProperties();
277 propVecMap = algProps->GetAlgorithmUserVectorProperties();
278 }
279 }
280
281 // Select appropriate GUI element and set connect for each property
282 if (propMap)
283 {
284 QMapIterator<QString, QVariant> i(*propMap);
285 while (i.hasNext())
286 {
287 i.next();
288 QString key = i.key();
289 QVariant value = i.value();
290
293 switch (value.type())
294 {
295 case QVariant::Double:
296 lineEdit = new VtkAlgorithmPropertyLineEdit(
297 QString::number(value.toDouble()), key,
298 QVariant::Double, algProps);
299 connect(lineEdit, SIGNAL(editingFinished()), this,
300 SIGNAL(requestViewUpdate()));
301 layout->addRow(key, lineEdit);
302 break;
303
304 case QVariant::Int:
305 lineEdit = new VtkAlgorithmPropertyLineEdit(
306 QString::number(value.toInt()), key, QVariant::Int,
307 algProps);
308 connect(lineEdit, SIGNAL(editingFinished()), this,
309 SIGNAL(requestViewUpdate()));
310 layout->addRow(key, lineEdit);
311 break;
312
313 case QVariant::Bool:
314 checkbox = new VtkAlgorithmPropertyCheckbox(value.toBool(),
315 key, algProps);
316 connect(checkbox, SIGNAL(stateChanged(int)), this,
317 SIGNAL(requestViewUpdate()));
318 layout->addRow(key, checkbox);
319 break;
320
321 default:
322 break;
323 }
324 }
325 }
326
327 if (propVecMap)
328 {
329 QMapIterator<QString, QList<QVariant>> i(*propVecMap);
330 while (i.hasNext())
331 {
332 i.next();
333 QString key = i.key();
334 QList<QVariant> values = i.value();
335
336 if (!values.empty())
337 {
338 QList<QString> valuesAsString;
339 foreach (QVariant variant, values)
340 valuesAsString.push_back(variant.toString());
341
344 valuesAsString, key, values.front().type(), algProps);
345 connect(vectorEdit, SIGNAL(editingFinished()), this,
346 SIGNAL(requestViewUpdate()));
347 layout->addRow(key, vectorEdit);
348 }
349 }
350 }
351}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
Contains properties for the visualization of objects as VtkVisPipelineItems.
QMap< QString, QVariant > * GetAlgorithmUserProperties() const
Returns a map of user properties.
QMap< QString, QList< QVariant > > * GetAlgorithmUserVectorProperties() const
Returns a map of vector user properties.
This checkbox sets a user property on the given VtkAlgorithmProperties object automatically.
This QLineEdit sets a user property on the given VtkAlgorithmProperties object automatically.
This edit widget consists of several QLineEdit to set a user vector property on the given VtkAlgorith...
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 353 of file VtkVisTabWidget.cpp.

354{
355 QStringList dataSetAttributesList = item->getScalarArrayNames();
356 dataSetAttributesList.push_back("Solid Color"); // all scalars switched off
357 this->activeScalarComboBox->blockSignals(true);
358 this->activeScalarComboBox->clear();
359 this->activeScalarComboBox->insertItems(0, dataSetAttributesList);
360 this->activeScalarComboBox->blockSignals(false);
361 QString active_array_name = item->GetActiveAttribute();
362 QList<QString>::iterator it = dataSetAttributesList.begin();
363 if (active_array_name.length() == 0)
364 {
365 item->SetActiveAttribute(*it);
366 }
367 else
368 {
369 int idx(0);
370 for (it = dataSetAttributesList.begin();
371 it != dataSetAttributesList.end();
372 ++it)
373 {
374 if (active_array_name.compare((*it).right((*it).length() - 2)) == 0)
375 {
376 this->activeScalarComboBox->setCurrentIndex(idx);
377 break;
378 }
379
380 idx++;
381 }
382 }
383}
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 53 of file VtkVisTabWidget.cpp.

54{
56 const QString selected_array_name =
57 this->activeScalarComboBox->currentText();
58 props->RemoveLookupTable(selected_array_name);
59 _item->SetActiveAttribute(selected_array_name);
60}
void RemoveLookupTable(const QString &array_name)
Removes the lookup table for the given scalar.
VtkVisPipelineItem * _item

References _item, VtkVisPipelineItem::getVtkProperties(), VtkAlgorithmProperties::RemoveLookupTable(), and VtkVisPipelineItem::SetActiveAttribute().

◆ on_diffuseColorPickerButton_colorPicked

void VtkVisTabWidget::on_diffuseColorPickerButton_colorPicked ( QColor color)
protectedslot

Definition at line 155 of file VtkVisTabWidget.cpp.

156{
157 static_cast<vtkActor*>(_item->actor())
158 ->GetProperty()
159 ->SetDiffuseColor(color.redF(), color.greenF(), color.blueF());
160
161 emit requestViewUpdate();
162}
vtkProp3D * actor() const
Returns the actor as vtkProp3D.

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

◆ on_edgeColorPickerButton_colorPicked

void VtkVisTabWidget::on_edgeColorPickerButton_colorPicked ( QColor color)
protectedslot

Definition at line 184 of file VtkVisTabWidget.cpp.

185{
186 static_cast<vtkActor*>(_item->actor())
187 ->GetProperty()
188 ->SetEdgeColor(color.redF(), color.greenF(), color.blueF());
189 emit requestViewUpdate();
190}

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

◆ on_opacitySlider_sliderMoved

void VtkVisTabWidget::on_opacitySlider_sliderMoved ( int value)
protectedslot

Definition at line 192 of file VtkVisTabWidget.cpp.

193{
194 static_cast<vtkActor*>(_item->actor())
195 ->GetProperty()
196 ->SetOpacity(value / 100.0);
197 emit requestViewUpdate();
198}

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

◆ on_scaleZ_textChanged

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

Definition at line 200 of file VtkVisTabWidget.cpp.

201{
202 bool ok = true;
203 double scale = text.toDouble(&ok);
204
205 // If z scale becomes zero, the object becomes invisible
206 if (ok && scale != 0.0)
207 {
208 _item->setScale(1.0, 1.0, scale);
209
210 for (int i = 0; i < _item->childCount(); i++)
211 {
212 VtkVisPipelineItem* childItem = _item->child(i);
213 if (childItem)
214 {
215 auto* colorFilter =
216 dynamic_cast<VtkCompositeColorByHeightFilter*>(
217 childItem->compositeFilter());
218 if (colorFilter)
219 {
220 VtkColorByHeightFilter::SafeDownCast(
221 colorFilter->GetOutputAlgorithm())
222 ->SetTableRangeScaling(scale);
223 }
224 }
225 }
226
227 emit requestViewUpdate();
228 }
229}
virtual int childCount() const
Definition TreeItem.cpp:65
This filter colors the input by the points z-value.
virtual void setScale(double x, double y, double z) const
Scales the data in visualisation-space. This function is empty and needs to be implemented by derived...
VtkVisPipelineItem * child(int row) const
Returns a VtkVisPipelineItem.
void scale(PETScVector &x, PetscScalar const a)
Definition LinAlg.cpp:44

References _item, VtkVisPipelineItem::child(), TreeItem::childCount(), VtkVisPipelineItem::compositeFilter(), requestViewUpdate(), and VtkVisPipelineItem::setScale().

◆ on_transX_textChanged

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

Definition at line 45 of file VtkVisTabWidget.h.

46 {
47 Q_UNUSED(text);
48 this->translateItem();
49 }

References translateItem().

◆ on_transY_textChanged

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

Definition at line 50 of file VtkVisTabWidget.h.

51 {
52 Q_UNUSED(text);
53 this->translateItem();
54 }

References translateItem().

◆ on_transZ_textChanged

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

Definition at line 55 of file VtkVisTabWidget.h.

56 {
57 Q_UNUSED(text);
58 this->translateItem();
59 }

References translateItem().

◆ on_visibleEdgesCheckBox_stateChanged

void VtkVisTabWidget::on_visibleEdgesCheckBox_stateChanged ( int state)
protectedslot

Definition at line 164 of file VtkVisTabWidget.cpp.

165{
166 if (state == Qt::Checked)
167 {
168 static_cast<vtkActor*>(_item->actor())
169 ->GetProperty()
170 ->SetEdgeVisibility(1);
171 edgeColorPickerButton->setEnabled(true);
172 }
173 else
174 {
175 static_cast<vtkActor*>(_item->actor())
176 ->GetProperty()
177 ->SetEdgeVisibility(0);
178 edgeColorPickerButton->setEnabled(false);
179 }
180
181 emit requestViewUpdate();
182}

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

◆ requestViewUpdate

◆ SetActiveAttributeOnItem

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

Definition at line 385 of file VtkVisTabWidget.cpp.

386{
388 emit requestViewUpdate();
389}

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

Referenced by VtkVisTabWidget().

◆ setActiveItem

void VtkVisTabWidget::setActiveItem ( VtkVisPipelineItem * item)
protectedslot

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

Definition at line 62 of file VtkVisTabWidget.cpp.

63{
64 if (item)
65 {
66 _item = item;
67 transformTabWidget->setEnabled(true);
68
69 auto* transform_filter =
70 dynamic_cast<vtkTransformFilter*>(_item->transformFilter());
71 if (transform_filter) // if data set
72 {
73 actorPropertiesGroupBox->setEnabled(true);
74 vtkProperty* vtkProps =
75 static_cast<vtkActor*>(_item->actor())->GetProperty();
76 diffuseColorPickerButton->setColor(vtkProps->GetDiffuseColor());
77 visibleEdgesCheckBox->setChecked(vtkProps->GetEdgeVisibility());
78 edgeColorPickerButton->setColor(vtkProps->GetEdgeColor());
79 opacitySlider->setValue(
80 static_cast<int>(vtkProps->GetOpacity() * 100.0));
81
82 auto* transform =
83 static_cast<vtkTransform*>(transform_filter->GetTransform());
84 if (transform)
85 {
86 double scale[3];
87 transform->GetScale(scale);
88 double trans[3];
89 transform->GetPosition(trans);
90
91 // switch signals off for just filling in text-boxes after
92 // clicking on an item
93 this->scaleZ->blockSignals(true);
94 this->transX->blockSignals(true);
95 this->transY->blockSignals(true);
96 this->transZ->blockSignals(true);
97 this->scaleZ->setText(QString::number(scale[2]));
98 this->transX->setText(QString::number(trans[0] / scale[0]));
99 this->transY->setText(QString::number(trans[1] / scale[1]));
100 this->transZ->setText(QString::number(trans[2] / scale[2]));
101 this->scaleZ->blockSignals(false);
102 this->transX->blockSignals(false);
103 this->transY->blockSignals(false);
104 this->transZ->blockSignals(false);
105 // switch signals back on
106 }
108
109 // Set to last active attribute
110 QString activeAttribute = _item->GetActiveAttribute();
111 if (activeAttribute.length() > 0)
112 {
113 for (int i = 0; i < this->activeScalarComboBox->count(); i++)
114 {
115 QString itemText = this->activeScalarComboBox->itemText(i);
116 if (itemText.compare(activeAttribute) == 0)
117 {
118 this->activeScalarComboBox->setCurrentIndex(i);
119 break;
120 }
121 }
122 }
123 }
124 else // if image
125 {
126 const VtkVisImageItem* img = static_cast<VtkVisImageItem*>(_item);
127 actorPropertiesGroupBox->setEnabled(false);
128 auto* transform =
129 static_cast<vtkImageChangeInformation*>(img->transformFilter());
130 double trans[3];
131 transform->GetOriginTranslation(trans);
132 this->transX->blockSignals(true);
133 this->transY->blockSignals(true);
134 this->transZ->blockSignals(true);
135 this->transX->setText(QString::number(trans[0]));
136 this->transY->setText(QString::number(trans[1]));
137 this->transZ->setText(QString::number(trans[2]));
138 this->transX->blockSignals(false);
139 this->transY->blockSignals(false);
140 this->transZ->blockSignals(false);
141 }
142
143 this->buildProportiesDialog(item);
144
145 emit requestViewUpdate();
146 }
147 else
148 {
149 actorPropertiesGroupBox->setEnabled(false);
150 transformTabWidget->setEnabled(false);
151 this->activeScalarComboBox->clear();
152 }
153}
An item in the VtkVisPipeline containing an image to be visualized.
vtkAlgorithm * transformFilter() const override
virtual vtkAlgorithm * transformFilter() const =0
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, VtkVisPipelineItem::actor(), buildProportiesDialog(), buildScalarArrayComboBox(), VtkVisPipelineItem::GetActiveAttribute(), requestViewUpdate(), VtkVisImageItem::transformFilter(), and VtkVisPipelineItem::transformFilter().

Referenced by VtkVisTabWidget().

◆ translateItem()

void VtkVisTabWidget::translateItem ( )
private

Definition at line 231 of file VtkVisTabWidget.cpp.

232{
233 bool okX(true);
234 bool okY(true);
235 bool okZ(true);
236 double trans[3];
237
238 trans[0] = transX->text().toDouble(&okX);
239 trans[1] = transY->text().toDouble(&okY);
240 trans[2] = transZ->text().toDouble(&okZ);
241
242 if (okX && okY && okZ)
243 {
244 _item->setTranslation(trans[0], trans[1], trans[2]);
245 emit requestViewUpdate();
246 }
247}
virtual void setTranslation(double x, double y, double z) const
Translates the item in visualisation-space. This function is empty and needs to be implemented by der...

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

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: