VR CAD Viewer 1.0
Qt and VTK application for loading and visualising CAD models with VR support
Loading...
Searching...
No Matches
ModelPart.h
Go to the documentation of this file.
1
6#ifndef VIEWER_MODELPART_H
7#define VIEWER_MODELPART_H
8
9#include <QString>
10#include <QList>
11#include <QVariant>
12
13#include <vtkSmartPointer.h>
14#include <vtkMapper.h>
15#include <vtkActor.h>
16#include <vtkSTLReader.h>
17#include <vtkColor.h>
18#include <vtkShrinkFilter.h>
19#include <vtkClipDataSet.h>
20#include <vtkPlane.h>
21#include <vtkDataSetMapper.h>
22#include <vtkDataSet.h>
23
30class ModelPart {
31public:
37 ModelPart(const QList<QVariant>& data, ModelPart* parent = nullptr);
38
42 ~ModelPart();
43
55 ModelPart* child(int row);
56
62 int childCount() const;
68 int columnCount() const;
69
75 QVariant data(int column) const;
76
77
83 void set( int column, const QVariant& value );
84
90
95 int row() const;
96
97
104 void setColour(const unsigned char R, const unsigned char G, const unsigned char B);
105
110 unsigned char getColourR();
111
116 unsigned char getColourG();
117
122 unsigned char getColourB();
123
128 void setVisible(bool isVisible);
129
134 bool visible();
135
141
147
153
159 bool removeChild(int row);
160
161 // Shrink filter for VR rendering
167 void setShrinkFilter(bool enabled, double factor);
168
173 bool shrinkFilterEnabled() const;
174
179 double shrinkFactor() const;
180
184 void updatePipeline();
185
189 void updateVRPipeline();
190
191 // Clip filter for VR rendering
192
200 void setClipFilter(bool enabled, int axis, double value, bool invert);
201
206 bool clipFilterEnabled() const;
207
212 int clipAxis() const;
213
218 double clipValue() const;
219
224 bool clipInvert() const;
225
226private:
227 QList<ModelPart*> m_childItems;
228 QList<QVariant> m_itemData;
229 ModelPart* m_parentItem;
231 /* These are some typical properties that I think the part will need, you might
232 * want to add you own.
233 */
234 bool isVisible;
235 unsigned char colourR;
236 unsigned char colourG;
237 unsigned char colourB;
239 /* These are vtk properties that will be used to load/render a model of this part,
240 * commented out for now but will be used later
241 */
248 // Shrink filter for VR rendering
249 bool applyShrinkFilter;
250 double shrinkFilterFactor;
252
253 // Clip filter for VR rendering
254 bool applyClipFilter;
255 int clipFilterAxis;
256 double clipFilterValue;
257 bool invertClipFilter;
261 vtkSmartPointer<vtkDataSet> vrFilteredData;
262
263};
264
265
266#endif
267
Represents one CAD model part in the application.
Definition ModelPart.h:30
int row() const
Gets this item's row number relative to its parent.
Definition ModelPart.cpp:112
int clipAxis() const
Gets the axis used by the clip filter.
Definition ModelPart.cpp:290
~ModelPart()
Deletes the model part and its child items.
Definition ModelPart.cpp:48
vtkSmartPointer< vtkActor > getNewActor()
Creates a separate actor for VR rendering.
Definition ModelPart.cpp:463
QVariant data(int column) const
Gets the data stored in a given column.
Definition ModelPart.cpp:83
void updatePipeline()
Updates the main VTK rendering pipeline after filter/property changes.
Definition ModelPart.cpp:174
double clipValue() const
Gets the clip filter value.
Definition ModelPart.cpp:295
unsigned char getColourB()
Gets the green colour value.
Definition ModelPart.cpp:141
void set(int column, const QVariant &value)
Sets the data stored in a given column.
Definition ModelPart.cpp:95
bool shrinkFilterEnabled() const
Checks whether the shrink filter is enabled.
Definition ModelPart.cpp:263
vtkSmartPointer< vtkActor > getActor()
Gets the actor used for normal GUI rendering.
Definition ModelPart.cpp:340
unsigned char getColourG()
Gets the green colour value.
Definition ModelPart.cpp:137
double shrinkFactor() const
Gets the shrink filter factor.
Definition ModelPart.cpp:268
void appendChild(ModelPart *item)
Adds a child item to this model part.
Definition ModelPart.cpp:53
void setClipFilter(bool enabled, int axis, double value, bool invert)
Sets the clip filter used for rendering.
Definition ModelPart.cpp:274
void setShrinkFilter(bool enabled, double factor)
Sets the shrink filter used for rendering.
Definition ModelPart.cpp:253
bool clipFilterEnabled() const
Checks whether the clip filter is enabled.
Definition ModelPart.cpp:285
bool visible()
Gets whether the model part is visible.
Definition ModelPart.cpp:167
void loadSTL(QString fileName)
Loads an STL file for this model part.
Definition ModelPart.cpp:305
int columnCount() const
Gets the number of data columns.
Definition ModelPart.cpp:77
void updateVRPipeline()
Updates the VR rendering pipeline after filter/property changes.
Definition ModelPart.cpp:351
void setVisible(bool isVisible)
Sets whether the model part is visible.
Definition ModelPart.cpp:147
ModelPart * parentItem()
Gets the parent item.
Definition ModelPart.cpp:105
bool clipInvert() const
Checks whether the clip filter is inverted.
Definition ModelPart.cpp:300
void setColour(const unsigned char R, const unsigned char G, const unsigned char B)
Sets the RGB colour of the model part.
Definition ModelPart.cpp:122
int childCount() const
Gets the number of child items.
Definition ModelPart.cpp:70
bool removeChild(int row)
Removes a child item at a given row.
Definition ModelPart.cpp:331
unsigned char getColourR()
Gets the red colour value.
Definition ModelPart.cpp:133
ModelPart * child(int row)
Gets the child item at a given row.
Definition ModelPart.cpp:62