CAD Viewer
ModelPart.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
9 //---------------------------------------------------------------------------//
10 
11 //---------------------------------------------------------------------------//
12 // preprocessor directives
13 //---------------------------------------------------------------------------//
14 #pragma once
15 
16 #ifndef VIEWER_MODELPART_H
17 #define VIEWER_MODELPART_H
18 
19 #include <QString>
20 #include <QList>
21 #include <QVariant>
22 
23 #include <vtkSmartPointer.h>
24 #include <vtkMapper.h>
25 #include <vtkActor.h>
26 #include <vtkSTLReader.h>
27 #include <vtkColor.h>
28 #include <vtkPolyDataMapper.h>
29 #include <vtkLight.h>
30 #include <vtkNamedColors.h>
31 #include <vtkProperty.h>
32 #include <vtkImageGaussianSmooth.h>
33 #include <vtkTransform.h>
34 #include <vtkPlane.h>
35 #include <vtkClipDataSet.h>
36 
37 #include <vtkShrinkFilter.h>
38 #include <vtkClipDataSet.h>
39 #include <vtkDataSetMapper.h>
40 #include <vtkPlane.h>
41 
42 //---------------------------------------------------------------------------//
43 // Class Declarations
44 //---------------------------------------------------------------------------//
45 
50 class ModelPart
51 {
52 public:
57  ModelPart(const QList<QVariant> &data, ModelPart *parent = nullptr);
58 
61  ~ModelPart();
62 
66  void appendChild(ModelPart *item);
67 
71  ModelPart *child(int row);
72 
75  int childCount() const;
76 
79  int columnCount() const;
80 
84  QVariant data(int column) const;
85 
89  void set(int column, const QVariant &value);
90 
94 
97  int row() const;
98 
103  void setColour(const unsigned char R, const unsigned char G, const unsigned char B);
104 
107  void setFileName(QString filename);
108 
111  QString getFileName();
112 
115  unsigned char getColourR();
116 
119  unsigned char getColourG();
120 
123  unsigned char getColourB();
124 
127  void setVisible(bool isVisible);
128 
131  bool visible();
132 
135  void loadSTL(QString fileName);
136 
138  void refreshModel();
139 
141  void refreshModelVR();
142 
145  void rotateActorX(double sliderValue);
146 
149  void rotateActorY(double sliderValue);
150 
153  void rotateActorZ(double sliderValue);
154 
156  void resetColoursOfModel();
157 
159  void resetColoursOfVRModel();
160 
162  void rotateVRActorX(double sliderValue);
163 
165  void rotateVRActorY(double sliderValue);
166 
168  void rotateVRActorZ(double sliderValue);
169 
172  vtkSmartPointer<vtkSTLReader> getReader();
173 
176  vtkSmartPointer<vtkActor> getActor();
177 
180  vtkSmartPointer<vtkMapper> getMapper();
181 
184  vtkActor *getNewActor();
185 
188  void shrinkfilters(bool state);
189 
192  void clipfilters(bool state, int clipVal, int normalVal);
193 
198  void setColoursOfModel(double r, double g, double b);
199 
200 private:
201  QList<ModelPart *> m_childItems;
202  QList<QVariant> m_itemData;
205  bool isVisible;
207  int r, g, b;
209  vtkSmartPointer<vtkSTLReader> file;
210  vtkSmartPointer<vtkMapper> mapper;
211  vtkSmartPointer<vtkActor> actor;
212  vtkColor3<unsigned char> colour;
214  vtkSmartPointer<vtkMapper> newMapper;
215  vtkSmartPointer<vtkActor> newActor;
216  vtkSmartPointer<vtkProperty> newProperty;
218  vtkSmartPointer<vtkImageGaussianSmooth> gaussian_filter;
220  vtkSmartPointer<vtkTransform> transform;
221  vtkSmartPointer<vtkTransform> newTransform;
222  vtkSmartPointer<vtkProperty> property;
225 };
226 
227 #endif
228 #pragma once
Model Part class.
Definition: ModelPart.h:51
int row() const
Get row index of item, relative to parent item.
Definition: ModelPart.cpp:91
bool renderVisible
Definition: ModelPart.h:206
~ModelPart()
Destructor for model part.
Definition: ModelPart.cpp:33
QList< ModelPart * > m_childItems
Definition: ModelPart.h:201
void shrinkfilters(bool state)
Apply shrink filter to model.
Definition: ModelPart.cpp:357
void rotateActorY(double sliderValue)
Rotate actor in the Y axis by a given value.
Definition: ModelPart.cpp:335
QVariant data(int column) const
Return the data item at a particular column for this item. i.e. either part name of visibility....
Definition: ModelPart.cpp:67
vtkSmartPointer< vtkActor > newActor
Definition: ModelPart.h:215
vtkSmartPointer< vtkMapper > mapper
Definition: ModelPart.h:210
void rotateVRActorY(double sliderValue)
Rotate VR actor in the Y axis by a given value.
unsigned char getColourB()
Get Blue colour component of this part.
Definition: ModelPart.cpp:131
void set(int column, const QVariant &value)
Default function required by Qt to allow setting of part. properties within treeview.
Definition: ModelPart.cpp:76
void rotateActorX(double sliderValue)
Rotate actor in the X axis by a given value.
Definition: ModelPart.cpp:324
int b
Definition: ModelPart.h:207
vtkSmartPointer< vtkMapper > newMapper
Definition: ModelPart.h:214
void rotateVRActorX(double sliderValue)
Rotate VR actor in the X axis by a given value.
void refreshModel()
Refresh the model.
Definition: ModelPart.cpp:207
vtkSmartPointer< vtkActor > getActor()
Return the actor.
Definition: ModelPart.cpp:177
unsigned char getColourG()
Get Green colour component of this part.
Definition: ModelPart.cpp:125
ModelPart * m_parentItem
Definition: ModelPart.h:203
QString FileNameFullPath
Definition: ModelPart.h:224
ModelPart(const QList< QVariant > &data, ModelPart *parent=nullptr)
Constructor for model part.
Definition: ModelPart.cpp:22
vtkSmartPointer< vtkTransform > transform
Definition: ModelPart.h:220
void appendChild(ModelPart *item)
Append a child item to this item.
Definition: ModelPart.cpp:39
bool visible()
Get visible flag.
Definition: ModelPart.cpp:144
void clipfilters(bool state, int clipVal, int normalVal)
Apply clip filter to model.
Definition: ModelPart.cpp:370
void resetColoursOfModel()
Reset the colours of the model.
Definition: ModelPart.cpp:251
vtkSmartPointer< vtkTransform > newTransform
Definition: ModelPart.h:221
void setFileName(QString filename)
Set file name.
Definition: ModelPart.cpp:107
int g
Definition: ModelPart.h:207
vtkSmartPointer< vtkSTLReader > file
Definition: ModelPart.h:209
void loadSTL(QString fileName)
Load STL file.
Definition: ModelPart.cpp:150
int columnCount() const
Get number of data items (2 - part name and visibility string) in this case.
Definition: ModelPart.cpp:61
void setVisible(bool isVisible)
Set visible flag.
Definition: ModelPart.cpp:137
ModelPart * parentItem()
Definition: ModelPart.cpp:85
vtkSmartPointer< vtkActor > actor
Definition: ModelPart.h:211
vtkSmartPointer< vtkProperty > property
Definition: ModelPart.h:222
QList< QVariant > m_itemData
Definition: ModelPart.h:202
void refreshModelVR()
Refresh the VR model.
Definition: ModelPart.cpp:299
void setColour(const unsigned char R, const unsigned char G, const unsigned char B)
Set colour of this part.
Definition: ModelPart.cpp:99
void resetColoursOfVRModel()
Reset the colours of the VR model.
Definition: ModelPart.cpp:278
void rotateActorZ(double sliderValue)
Rotate actor in the Z axis by a given value.
Definition: ModelPart.cpp:346
void rotateVRActorZ(double sliderValue)
Rotate VR actor in the Z axis by a given value.
vtkSmartPointer< vtkSTLReader > getReader()
Return the reader to get the file source.
Definition: ModelPart.cpp:183
vtkActor * getNewActor()
Return new actor for use in VR.
Definition: ModelPart.cpp:195
int childCount() const
Get number of children of this item.
Definition: ModelPart.cpp:55
void setColoursOfModel(double r, double g, double b)
set colours of the model
Definition: ModelPart.cpp:232
vtkColor3< unsigned char > colour
Definition: ModelPart.h:212
vtkSmartPointer< vtkImageGaussianSmooth > gaussian_filter
Definition: ModelPart.h:218
vtkSmartPointer< vtkProperty > newProperty
Definition: ModelPart.h:216
vtkSmartPointer< vtkMapper > getMapper()
Return the mapper.
Definition: ModelPart.cpp:189
unsigned char getColourR()
Get Red colour component of this part.
Definition: ModelPart.cpp:119
ModelPart * child(int row)
child at position 'row' below this item
Definition: ModelPart.cpp:46
bool isVisible
Definition: ModelPart.h:205
QString getFileName()
Get file name.
Definition: ModelPart.cpp:113
int r
Definition: ModelPart.h:207