CAD Viewer
mainwindow.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
9 //---------------------------------------------------------------------------//
10 
11 //---------------------------------------------------------------------------//
12 // preprocessor directives
13 //---------------------------------------------------------------------------//
14 
15 #ifndef MAINWINDOW_H
16 #define MAINWINDOW_H
17 
18 #include <QMainWindow>
19 #include <QString>
20 #include <QtCore>
21 #include <QAction>
22 #include <QFileInfo>
23 #include <QFileDialog>
24 #include "../Model/ModelPart.h"
25 #include "../Model/ModelPartList.h"
26 #include "../OptionDialog/optiondialog.h"
27 #include "vtkRenderer.h"
28 #include "vtkGenericOpenGLRenderWindow.h"
29 #include "vtkCamera.h"
30 #include "vtkPolyDataMapper.h"
31 #include "vtkCylinderSource.h"
32 #include "vtkProperty.h"
33 #include "../VR/VRRenderThread.h"
34 #include "../Help_Dialog/help.h"
35 #include <vtkPNGReader.h>
36 #include <vtkImageActor.h>
37 #include <vtkRenderWindowInteractor.h>
38 #include <vtkTexture.h>
39 #include <vtkImageData.h>
40 #include <QPixmap>
41 #include "QtPrintSupport/qprinter.h"
42 #include "QtPrintSupport/qprintdialog.h"
43 #include <QPainter>
44 
45 // mainwindow.h
46 #include <vtkShrinkFilter.h>
47 #include <vtkClipDataSet.h>
48 #include <vtkDataSetMapper.h>
49 #include <QColorDialog>
50 
51 //---------------------------------------------------------------------------//
52 // Class Deceleration
53 //---------------------------------------------------------------------------//
54 
55 QT_BEGIN_NAMESPACE
56 namespace Ui
57 {
58  class MainWindow;
59 }
60 QT_END_NAMESPACE
61 
66 class MainWindow : public QMainWindow
67 {
68  Q_OBJECT
69 
70 public:
71 
74  MainWindow(QWidget *parent = nullptr);
75 
77  ~MainWindow();
78 
80  void FullRotation();
81  //--------------------------------------------------
82 public slots:
94  void handleButton();
95 
101  void handleButton2();
102 
108  void handleTreeClicked();
109 
116 
124 
129  void ResetCamera();
130 
135  void updateRenderFromTree(const QModelIndex &index);
136 
141  void updateRender();
142 
148 
154 
160 
166 
171 
176  void rotateModelX();
177 
182  void rotateModelY();
183 
188  void rotateModelZ();
189 
193  void resetSliders();
194 
199  void ShrinkFilter();
200 
205  void ClipFilter();
206 
211 
216 
222 
228 
234 
238  void ModifyLighting();
239 
245 
250  void handleRotation_x1();
251 
256  void handleRotation_x2();
257 
261  void handleRotation_x3();
262 
263 
268  void handleRotation_y1();
269 
274  void handleRotation_y2();
275 
280  void handleRotation_y3();
281 
286  void handleRotation_z1();
287 
292  void handleRotation_z2();
293 
298  void handleRotation_z3();
299 
304  void changeRotationSpeed();
305 
309  void ColourPicker();
310 
314  void clipFilterSlider();
315 
316 signals:
323  void statusUpdateMessage(const QString &message, int timeout);
324 
325 private:
326  Ui::MainWindow *ui;
328 
329  //********
330  vtkSmartPointer<vtkRenderer> renderer;
331  vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow;
332  vtkSmartPointer<vtkLight> light;
333 
335 
336  QString StoredFileName;
337 
338  bool VR_Running = false;
339  int k = 0;
341  double red, green, blue;
342 
343  double RotationSpeedValue = 1.0;
344  //********
345 
346  int VR_RotationX = 0;
347  int VR_RotationY = 0;
348  int VR_RotationZ = 0;
349 };
350 
351 #endif // MAINWINDOW_H
CAD viewer class.
Definition: mainwindow.h:67
vtkSmartPointer< vtkRenderer > renderer
renderer is the vtk renderer
Definition: mainwindow.h:330
void handleRotation_x1()
handles clockwise rotation buttons in the x axis for VR
Definition: mainwindow.cpp:712
void handleRotation_y2()
handles stop rotation buttons in the y axis for VR
Definition: mainwindow.cpp:752
void handleRotation_x2()
handles stop rotation buttons in the x axis for VR
Definition: mainwindow.cpp:722
void rotateModelZ()
this function is used to rotate the model in the vtk viewer in the z axis
Definition: mainwindow.cpp:439
void handleButton()
This function is used to handle a button being pressed.
Definition: mainwindow.cpp:99
void handleTreeClicked()
This function is used to handle a the tree being clicked.
Definition: mainwindow.cpp:149
QString StoredFileName
StoredFileName is the name of the file.
Definition: mainwindow.h:336
void on_actionAdd_New_Item_triggered()
this function is used to add a new child to the tree
Definition: mainwindow.cpp:244
void handleRotation_y3()
handles anti clockwise rotation buttons in the y axis for VR
Definition: mainwindow.cpp:762
void on_actionPrint_triggered()
print image
Definition: mainwindow.cpp:697
double red
Definition: mainwindow.h:341
void ModifyLighting()
change lighting of the render
Definition: mainwindow.cpp:358
void rotateModelX()
this function is used to rotate the model in the vtk viewer in the x axis
Definition: mainwindow.cpp:497
void handleRotation_z3()
handles anti clockwise rotation buttons in the z axis for VR
Definition: mainwindow.cpp:792
Ui::MainWindow * ui
ui is the user interface
Definition: mainwindow.h:326
VRRenderThread * VR_Render
VR_Render is the VR render thread.
Definition: mainwindow.h:334
void on_actionOpen_File_triggered()
This function is used to handle the open file button being pressed.
Definition: mainwindow.cpp:158
int VR_RotationZ
VR_RotationZ is the VR rotation in the z axis.
Definition: mainwindow.h:348
void updateRenderFromTree(const QModelIndex &index)
This function is used to Update the render from the tree.
Definition: mainwindow.cpp:207
vtkSmartPointer< vtkLight > light
light is the vtk light
Definition: mainwindow.h:332
ModelPartList * partList
partList is the list of parts
Definition: mainwindow.h:327
void on_action180Rotate_triggered()
this function is used to flip the objects by 180 degrees
Definition: mainwindow.cpp:608
void changeRotationSpeed()
handles the rotation speed slider
Definition: mainwindow.cpp:802
void on_actionHelp_triggered()
this function opens the help dialog
Definition: mainwindow.cpp:257
double blue
red, green, blue are the rgb values for the colour picker
Definition: mainwindow.h:341
double green
Definition: mainwindow.h:341
void handleRotation_y1()
handles clockwise rotation buttons in the y axis for VR
Definition: mainwindow.cpp:742
void on_actionResetColours_triggered()
this function is used to reset the objects colours
Definition: mainwindow.cpp:573
void ShrinkFilter()
this function is used to apply the shrink filter.
Definition: mainwindow.cpp:633
vtkSmartPointer< vtkGenericOpenGLRenderWindow > renderWindow
renderWindow is the vtk render window
Definition: mainwindow.h:331
double RotationSpeedValue
RotationSpeedValue is the rotation speed value.
Definition: mainwindow.h:343
void on_actionBackground_triggered()
change background colour of the render
Definition: mainwindow.cpp:333
int VR_RotationX
VR_RotationX is the VR rotation in the x axis.
Definition: mainwindow.h:346
void statusUpdateMessage(const QString &message, int timeout)
This function is used to send a message to the status bar.
void on_actionStart_VR_triggered()
start the VR session
Definition: mainwindow.cpp:274
int k
k is a counter for the VR rotation
Definition: mainwindow.h:339
void clipFilterSlider()
handles clip filter
Definition: mainwindow.cpp:841
MainWindow(QWidget *parent=nullptr)
Constructor for the CAD viewer.
Definition: mainwindow.cpp:24
void on_actionReset_triggered()
this function is used to reset the viewer
Definition: mainwindow.cpp:383
void updateRender()
This function is used to Update the render.
Definition: mainwindow.cpp:236
void rotateModelY()
this function is used to rotate the model in the vtk viewer in the y axis
Definition: mainwindow.cpp:468
void on_actionSaveRender_triggered()
Save image of the render.
Definition: mainwindow.cpp:686
int previous_value
previous_value is the previous value of the slider
Definition: mainwindow.h:340
void on_actionStop_VR_triggered()
stop the VR session
Definition: mainwindow.cpp:307
void ClipFilter()
this function is used to apply the clip filter.
Definition: mainwindow.cpp:659
void handleRotation_z1()
handles clockwise rotation buttons in the z axis for VR
Definition: mainwindow.cpp:772
void on_actionResetPosition_triggered()
this function is used to reset the objects position
Definition: mainwindow.cpp:534
void handleButton2()
This function is used to handle a button being pressed.
Definition: mainwindow.cpp:106
void on_actionItem_Options_triggered()
This function is used to handle item options.
Definition: mainwindow.cpp:193
int VR_RotationY
VR_RotationY is the VR rotation in the y axis.
Definition: mainwindow.h:347
void ResetCamera()
This function is used to Reset the camera.
Definition: mainwindow.cpp:199
void FullRotation()
This function is used to set the model part list.
Definition: mainwindow.cpp:620
void handleRotation_x3()
handles anti clockwise rotation buttons in the x axis for VR
Definition: mainwindow.cpp:732
~MainWindow()
Deconstructor for the CAD viewer.
Definition: mainwindow.cpp:93
void handleRotation_z2()
handles stop rotation buttons in the z axis for VR
Definition: mainwindow.cpp:782
bool VR_Running
VR_Running is a bool to check if VR is running.
Definition: mainwindow.h:338
void ColourPicker()
handles the colour picker
Definition: mainwindow.cpp:815
void resetSliders()
this function is used to reset Sliders
Definition: mainwindow.cpp:526
Definition: ModelPartList.h:26
Definition: VRRenderThread.h:34
Definition: help.h:25