KurusView  1.0
KView.h
1 #ifndef KURUSVIEW_KVIEW_H
2 #define KURUSVIEW_KVIEW_H
3 
4 #include <QWidget>
5 #include <QVBoxLayout>
6 #include <QFrame>
7 #include <QColor>
8 #include <QSettings>
9 #include <QString>
10 
11 #include <QVTKOpenGLWidget.h>
12 #include <vtkSmartPointer.h>
13 #include <vtkDataSetMapper.h>
14 #include <vtkClipDataSet.h>
15 #include <vtkShrinkFilter.h>
16 #include <vtkDistanceWidget.h>
17 #include <vtkAlgorithm.h>
18 #include <vtkSTLReader.h>
19 
20 #include "MModel.h"
21 
22 // wrap the class in Ui::
23 namespace Ui {
24  class View;
25 }
26 
32 class KView final : public QWidget {
33 public:
35  QString borderColor;
36  QVBoxLayout *verticalLayout;
37  QVTKOpenGLWidget *qVTKWidget;
38  std::shared_ptr<MModel> model;
39 
45  vtkSmartPointer<vtkAlgorithm> vtkModel;
46 
48  vtkSmartPointer<vtkSTLReader> STLModel;
49 
51  vtkSmartPointer<vtkDataSetMapper> mapper;
52 
54  std::vector<vtkSmartPointer<vtkAlgorithm>> filters;
55 
57  vtkSmartPointer<vtkClipDataSet> clipFilter;
58 
60  vtkSmartPointer<vtkShrinkFilter> shrinkFilter;
61 
63  int lightIntensity, lightSpecularity, modelOpacity, structure;
64  QString backgroundColour, modelColour, modelBackFaceColor;
65  bool isClipped, isShrunk, gridLinesEnabled, measurementEnabled;
66  double density, volume, weight;
67  size_t numOfCells;
68  MVector centreOfGrav;
69  vtkSmartPointer<vtkDistanceWidget> distanceWidget;
70  QString filePath;
71  std::shared_ptr<QSettings> viewSettings;
72 
81  explicit KView(const QString &filePath, QWidget *parent = nullptr);
82 
89  ~KView() final;
90 
94  void buildVTKModelFromMod();
95 
100  void loadSTLModel();
101 
105  void buildChain();
106 
114  bool toggleShrinkFilter(bool enable, double shrinkFactor = NULL);
115 
121  void toggleClipFilter(bool enable);
122 
127  static unsigned short int getCount();
128 
133  void setModelColor(const QColor &color = nullptr);
134 
139  void setModelBackFaceColor(const QColor &color);
140 
146  void setBackgroundColor(const QColor &color);
147 
151  void resetColour();
152 
157  void setLightIntensity(int value);
158 
163  void setLightSpecularity(int value);
164 
169  void setModelOpacity(int value);
170 
174  void resetLighting();
175 
180  void toggleGridLines(bool enable);
181 
186  void toggleMeasurement(bool enable);
187 
192  void setStructure(int selectedStructure);
193 
198  bool save();
199 
203  void saveAs();
204 
205 private:
206 
211  static unsigned short int ViewInstanceCount;
212 
218  QString borderColors[4] = {"red", "blue", "cyan", "magenta"};
219 
223  void gridlinesInit();
224 
228  void populateSettings();
229 
230 };
231 
232 
233 #endif //KURUSVIEW_KVIEW_H
int lightIntensity
model properties
Definition: KView.h:63
Definition: dialog.h:7
QString borderColor
reconsider member visibility, use accessors
Definition: KView.h:35
View class - abstracts all rendering duties. Has no effect on UI elements, which are handled by Model...
Definition: KView.h:32
vtkSmartPointer< vtkAlgorithm > vtkModel
vtkModel - Unstructured grid containing all the cells of the model.
Definition: KView.h:45
vtkSmartPointer< vtkClipDataSet > clipFilter
clipFilter - global instance of clipFilter
Definition: KView.h:57
vtkSmartPointer< vtkDataSetMapper > mapper
mapper - sole rendering mapper
Definition: KView.h:51
std::vector< vtkSmartPointer< vtkAlgorithm > > filters
filters - list or active filters.
Definition: KView.h:54
Definition: MVector.h:19
vtkSmartPointer< vtkSTLReader > STLModel
STLModel - STL model source.
Definition: KView.h:48
vtkSmartPointer< vtkShrinkFilter > shrinkFilter
shrinkFilter - global instance of shrinkFilter
Definition: KView.h:60