OGS
VtkAddFilterDialog.cpp
Go to the documentation of this file.
1
15// ** INCLUDES **
16#include "VtkAddFilterDialog.h"
17
18#include <vtkContourFilter.h>
19#include <vtkOutlineFilter.h>
20#include <vtkTransformFilter.h>
21
22#include <QModelIndex>
23
24#include "BaseLib/Logging.h"
25#include "VtkCompositeFilter.h"
26#include "VtkFilterFactory.h"
27#include "VtkVisImageItem.h"
28#include "VtkVisPipeline.h"
29#include "VtkVisPipelineItem.h"
30#include "VtkVisPointSetItem.h"
31
33 QModelIndex parentIndex,
34 QDialog* parent /*= 0*/)
35 : QDialog(parent), _pipeline(pipeline), _parentIndex(parentIndex)
36{
37 setupUi(this);
38 filterListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
39
40 auto* parentItem =
41 static_cast<VtkVisPipelineItem*>(_pipeline.getItem(parentIndex));
42 vtkDataObject* parentDataObject =
43 parentItem->algorithm()->GetOutputDataObject(0);
44 int parentDataObjectType = parentDataObject->GetDataObjectType();
45
46 QVector<VtkFilterInfo> filterList = VtkFilterFactory::GetFilterList();
47 foreach (VtkFilterInfo filter, filterList)
48 {
49 // Check for suitable filters (see vtkDataSet inheritance diagram)
50 int inputType = filter.inputDataObjectType;
51 if ((inputType == parentDataObjectType) ||
52 (inputType == VTK_POINT_SET &&
53 parentDataObjectType != VTK_IMAGE_DATA) ||
54 (inputType == VTK_IMAGE_DATA &&
55 (parentDataObjectType == VTK_STRUCTURED_POINTS ||
56 parentDataObjectType == VTK_UNIFORM_GRID)))
57 {
58 new QListWidgetItem(filter.readableName, filterListWidget);
59 }
60 }
61
62 // On double clicking an item the dialog gets accepted
63 connect(filterListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
64 this->buttonBox, SIGNAL(accepted()));
65}
66
68{
69 QVector<VtkFilterInfo> filterList = VtkFilterFactory::GetFilterList();
70 QString filterName;
71 foreach (VtkFilterInfo filter, filterList)
72 {
73 if (filter.readableName.compare(
74 filterListWidget->currentItem()->text()) == 0)
75 {
76 filterName = filter.name;
77 break;
78 }
79 }
80 auto* parentItem =
82 QList<QVariant> itemData;
83 itemData << filterListWidget->currentItem()->text() << true;
84
85 VtkCompositeFilter* filter;
86 if (dynamic_cast<VtkVisImageItem*>(parentItem))
87 {
89 filterName, parentItem->algorithm());
90 }
91 else
92 {
94 filterName, parentItem->transformFilter());
95 }
96
98 if (filter)
99 {
100 if (filter->GetOutputDataObjectType() == VTK_IMAGE_DATA)
101 {
102 item = new VtkVisImageItem(filter, parentItem, itemData);
103 }
104 else
105 {
106 item = new VtkVisPointSetItem(filter, parentItem, itemData);
107 }
108 }
109 else
110 {
111 vtkAlgorithm* algorithm =
113 if (algorithm)
114 {
115 item = new VtkVisPointSetItem(algorithm, parentItem, itemData);
116 }
117 else
118 {
119 ERR("VtkFilterFactory cannot create {:s}.",
120 filterName.toStdString());
121 return;
122 }
123 }
125}
126
128{
130 {
131 if (filter.readableName.compare(
132 filterListWidget->item(currentRow)->text()) == 0)
133 {
134 QString desc = filter.description;
135 desc = desc + QString("\n\nThis filter outputs ") +
136 filter.OutputDataObjectTypeAsString() +
137 QString("\n\nFilter class name: ") + filter.name;
138
139 this->filterDescTextEdit->setText(desc);
140 continue;
141 }
142 }
143}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
Definition of the VtkAddFilterDialog class.
Definition of the VtkCompositeFilter class.
Definition of the VtkFilterFactory class.
Definition of the VtkVisImageItem class.
Definition of the VtkVisPipelineItem class.
Definition of the VtkVisPipeline class.
Definition of the VtkVisPointSetItem class.
TreeItem * getItem(const QModelIndex &index) const
VtkAddFilterDialog(VtkVisPipeline &pipeline, QModelIndex parentIndex, QDialog *parent=nullptr)
VtkVisPipeline & _pipeline
void on_filterListWidget_currentRowChanged(int currentRow)
Is used to combine several filter in one VtkVisPipelineItem. You can use vtk filter and custom filter...
static QVector< VtkFilterInfo > GetFilterList()
Returns all registered filters. New VtkCompositeFilter or filter inherited from VtkAlgorithmPropertie...
static VtkCompositeFilter * CreateCompositeFilter(QString type, vtkAlgorithm *inputAlgorithm)
Creates a composite filter by name.
static vtkAlgorithm * CreateSimpleFilter(QString type)
Creates a normal filter name.
An item in the VtkVisPipeline containing an image to be visualized.
An item in the VtkVisPipeline containing a graphic object to be visualized.
vtkAlgorithm * algorithm() const
Returns the algorithm object.
VtkVisPipeline manages the VTK visualization. It is a TreeModel and provides functions for adding and...
void addPipelineItem(MeshModel *model, const QModelIndex &idx)
Adds the given Model to the pipeline.
An item in the VtkVisPipeline containing a point set object to be visualized.
Holds meta information about a filter.