CAD Viewer
Public Slots | Signals | Public Member Functions | Private Attributes | List of all members
MainWindow Class Reference

CAD viewer class. More...

#include "mainwindow.h"

Inheritance diagram for MainWindow:
Inheritance graph
[legend]
Collaboration diagram for MainWindow:
Collaboration graph
[legend]

Public Slots

void handleButton ()
 This function is used to handle a button being pressed. More...
 
void handleButton2 ()
 This function is used to handle a button being pressed. More...
 
void handleTreeClicked ()
 This function is used to handle a the tree being clicked. More...
 
void on_actionOpen_File_triggered ()
 This function is used to handle the open file button being pressed. More...
 
void on_actionItem_Options_triggered ()
 This function is used to handle item options. More...
 
void ResetCamera ()
 This function is used to Reset the camera. More...
 
void updateRenderFromTree (const QModelIndex &index)
 This function is used to Update the render from the tree. More...
 
void updateRender ()
 This function is used to Update the render. More...
 
void on_actionStart_VR_triggered ()
 start the VR session More...
 
void on_actionStop_VR_triggered ()
 stop the VR session More...
 
void on_actionAdd_New_Item_triggered ()
 this function is used to add a new child to the tree More...
 
void on_actionHelp_triggered ()
 this function opens the help dialog More...
 
void on_actionReset_triggered ()
 this function is used to reset the viewer More...
 
void rotateModelX ()
 this function is used to rotate the model in the vtk viewer in the x axis More...
 
void rotateModelY ()
 this function is used to rotate the model in the vtk viewer in the y axis More...
 
void rotateModelZ ()
 this function is used to rotate the model in the vtk viewer in the z axis More...
 
void resetSliders ()
 this function is used to reset Sliders More...
 
void ShrinkFilter ()
 this function is used to apply the shrink filter. More...
 
void ClipFilter ()
 this function is used to apply the clip filter. More...
 
void on_actionResetPosition_triggered ()
 this function is used to reset the objects position More...
 
void on_actionResetColours_triggered ()
 this function is used to reset the objects colours More...
 
void on_action180Rotate_triggered ()
 this function is used to flip the objects by 180 degrees More...
 
void on_actionSaveRender_triggered ()
 Save image of the render. More...
 
void on_actionPrint_triggered ()
 print image More...
 
void ModifyLighting ()
 change lighting of the render More...
 
void on_actionBackground_triggered ()
 change background colour of the render More...
 
void handleRotation_x1 ()
 handles clockwise rotation buttons in the x axis for VR More...
 
void handleRotation_x2 ()
 handles stop rotation buttons in the x axis for VR More...
 
void handleRotation_x3 ()
 handles anti clockwise rotation buttons in the x axis for VR More...
 
void handleRotation_y1 ()
 handles clockwise rotation buttons in the y axis for VR More...
 
void handleRotation_y2 ()
 handles stop rotation buttons in the y axis for VR More...
 
void handleRotation_y3 ()
 handles anti clockwise rotation buttons in the y axis for VR More...
 
void handleRotation_z1 ()
 handles clockwise rotation buttons in the z axis for VR More...
 
void handleRotation_z2 ()
 handles stop rotation buttons in the z axis for VR More...
 
void handleRotation_z3 ()
 handles anti clockwise rotation buttons in the z axis for VR More...
 
void changeRotationSpeed ()
 handles the rotation speed slider More...
 
void ColourPicker ()
 handles the colour picker More...
 
void clipFilterSlider ()
 handles clip filter More...
 

Signals

void statusUpdateMessage (const QString &message, int timeout)
 This function is used to send a message to the status bar. More...
 

Public Member Functions

 MainWindow (QWidget *parent=nullptr)
 Constructor for the CAD viewer. More...
 
 ~MainWindow ()
 Deconstructor for the CAD viewer. More...
 
void FullRotation ()
 This function is used to set the model part list. More...
 

Private Attributes

Ui::MainWindow * ui
 ui is the user interface More...
 
ModelPartListpartList
 partList is the list of parts More...
 
vtkSmartPointer< vtkRenderer > renderer
 renderer is the vtk renderer More...
 
vtkSmartPointer< vtkGenericOpenGLRenderWindow > renderWindow
 renderWindow is the vtk render window More...
 
vtkSmartPointer< vtkLight > light
 light is the vtk light More...
 
VRRenderThreadVR_Render
 VR_Render is the VR render thread. More...
 
QString StoredFileName
 StoredFileName is the name of the file. More...
 
bool VR_Running = false
 VR_Running is a bool to check if VR is running. More...
 
int k = 0
 k is a counter for the VR rotation More...
 
int previous_value
 previous_value is the previous value of the slider More...
 
double red
 
double green
 
double blue
 red, green, blue are the rgb values for the colour picker More...
 
double RotationSpeedValue = 1.0
 RotationSpeedValue is the rotation speed value. More...
 
int VR_RotationX = 0
 VR_RotationX is the VR rotation in the x axis. More...
 
int VR_RotationY = 0
 VR_RotationY is the VR rotation in the y axis. More...
 
int VR_RotationZ = 0
 VR_RotationZ is the VR rotation in the z axis. More...
 

Detailed Description

CAD viewer class.

This class is the main window for the CAD viewer that the use interfaces with.

Date
2023-5-5
Author
K.Baskaran, E.Roongwarasopit, J.Moules, N.Srinivasan, G.Downing

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( QWidget *  parent = nullptr)

Constructor for the CAD viewer.

Parameters
parentis the parent widget

This is the constructor for the mainWindow class. first the treeview is linked to add an options section. next the slots are connected to respective handlers. A inital render is created and added to the treeview.

Here is the call graph for this function:

◆ ~MainWindow()

MainWindow::~MainWindow ( )

Deconstructor for the CAD viewer.

This is the destructor for the mainWindow class.

Member Function Documentation

◆ changeRotationSpeed

void MainWindow::changeRotationSpeed ( )
slot

handles the rotation speed slider

Parameters
[in]void
Returns
void
Note
rotation for VR only

This function is used to change the rotation speed of the model. First the VR_running flag is checked to see if VR is running. if it is, rotation speed is interpreted by the slider. the VR renderer then issues command to update the rotation speed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClipFilter

void MainWindow::ClipFilter ( )
slot

this function is used to apply the clip filter.

Parameters
[in]void
Returns
void
Note
is applied to the selected part in the treeview.

This function is used to apply a clip filter. First the index is retrieved from the treeview and the selected part is retrieved from the index. Next the status bar is updated with a message. the clip filter is applied to the selected part and the renderer is rendered. the render window is rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clipFilterSlider

void MainWindow::clipFilterSlider ( )
slot

handles clip filter

Parameters
[in]void
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ColourPicker

void MainWindow::ColourPicker ( )
slot

handles the colour picker

Parameters
[in]void
Returns
void

This function is used to generate a colour picker dialog box. First the status bar is updated with a message. the current index is retrieved form the tree view. the selected part is retrieved from the index. a new colour dialog box is created. the options of the colour dialog box are set. if the dialog box is accepted, the colour is retrieved and set to the selected part. the colour is set to the selected part.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FullRotation()

void MainWindow::FullRotation ( )

This function is used to set the model part list.

This function is used to rotate the model 180 degrees. First the status bar is updated with a message. Next the current index of the treeview is retrieved and the selected part is retrieved from the index. that information is then forgotten about. the render is updated and the camera moved 180 degrees.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleButton

void MainWindow::handleButton ( )
slot

This function is used to handle a button being pressed.

New Item Button Pushed. This function shows a message at the bottom left corner of the application indicating that the New Item button was pushed. Once pushed, the New Item function is called.

Parameters
[in]void
Returns
void
Note
Called by GUI when button pressed
Used add new item to the tree

This functions is used to add a new item to the tree view. it is called by a button on the GUI. An update message is produced. The function on_actionAdd_New_Item_triggered() is called.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleButton2

void MainWindow::handleButton2 ( )
slot

This function is used to handle a button being pressed.

Parameters
[in]void
Returns
void
Note
Called by GUI when button pressed
used to open dialog box for part settings

This functions opens the dialog box for part options. first the status bar is updated with a message. next a dialog box is created. information about the part is loaded to the dialog. after the user has finished with the dialog the information is retrieved and the part is updated. the status bar is updated with the file name. the colour of the model is set. the render window is rendered and the camera is reset.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_x1

void MainWindow::handleRotation_x1 ( )
slot

handles clockwise rotation buttons in the x axis for VR

Parameters
[in]void
Returns
void
Note
rotation for VR only

This function is used to rotate the VR model in the x axis clockwise. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to rotate the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_x2

void MainWindow::handleRotation_x2 ( )
slot

handles stop rotation buttons in the x axis for VR

Parameters
[in]void
Returns
Note
rotation for VR only

This function is used to stop the VR model from rotating in the x axis. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to stop rotating the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_x3

void MainWindow::handleRotation_x3 ( )
slot

handles anti clockwise rotation buttons in the x axis for VR

Parameters
[in]void
Returns

This function is used to rotate the VR model in the x axis anticlockwise. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to rotate the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_y1

void MainWindow::handleRotation_y1 ( )
slot

handles clockwise rotation buttons in the y axis for VR

Parameters
[in]void
Returns
Note
rotation for VR only

This function is used to rotate the VR model in the y axis clockwise. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to rotate the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_y2

void MainWindow::handleRotation_y2 ( )
slot

handles stop rotation buttons in the y axis for VR

Parameters
[in]void
Returns
Note
rotation for VR only

This function is used to stop the VR model from rotating in the y axis. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to stop rotating the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_y3

void MainWindow::handleRotation_y3 ( )
slot

handles anti clockwise rotation buttons in the y axis for VR

Parameters
[in]void
Returns
Note
rotation for VR only

This function is used to rotate the VR model in the y axis anticlockwise. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to rotate the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_z1

void MainWindow::handleRotation_z1 ( )
slot

handles clockwise rotation buttons in the z axis for VR

Parameters
[in]void
Returns
Note
rotation for VR only

This function is used to rotate the VR model in the z axis clockwise. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to rotate the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_z2

void MainWindow::handleRotation_z2 ( )
slot

handles stop rotation buttons in the z axis for VR

Parameters
[in]void
Returns
Note
rotation for VR only

This function is used to stop the VR model from rotating in the z axis. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to stop rotating the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRotation_z3

void MainWindow::handleRotation_z3 ( )
slot

handles anti clockwise rotation buttons in the z axis for VR

Parameters
[in]void
Returns
void
Note
rotation for VR only

This function is used to rotate the VR model in the z axis anticlockwise. First the VR_running flag is checked to see if VR is running. if it is, the VR render is issued a command to rotate the model.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleTreeClicked

void MainWindow::handleTreeClicked ( )
slot

This function is used to handle a the tree being clicked.

Parameters
[in]void
Returns
void
Note
Called by GUI when tree clicked
used to display options for the selected part

This function is used to handle the tree being clicked. the current index of the tree is retrieved and the selected part is retrieved from the index.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ModifyLighting

void MainWindow::ModifyLighting ( )
slot

change lighting of the render

Parameters
[in]void
Returns
void

This function is used to modify the lighting of the scene. first the value of the status bar is retrieved and converted to a string. This is displayed in a message. a new light is created and the intensity is set. the current index of the treeview is retrieved and the selected part is retrieved from the index. the actor and light are added to the renderer. the render window is rendered. the previous value is set to the slider value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_action180Rotate_triggered

void MainWindow::on_action180Rotate_triggered ( )
slot

this function is used to flip the objects by 180 degrees

Parameters
[in]void
Returns
void
Note
different implementation for VR

This function is used to rotate the model 180 degrees. This is now obsolete.

Here is the call graph for this function:

◆ on_actionAdd_New_Item_triggered

void MainWindow::on_actionAdd_New_Item_triggered ( )
slot

this function is used to add a new child to the tree

Parameters
[in]void
Returns
void
Note
Called by the menu bar

This function is used to add a new item to the tree view. when called the current index of the treeview is retrieved and the selected part is retrieved from the index. a new child is created and added to the selected part.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_actionBackground_triggered

void MainWindow::on_actionBackground_triggered ( )
slot

change background colour of the render

Parameters
[in]void
Returns
void
Note
called by the menu bar requires png file

This function is used to add a background image. first the status bar is updated with a message. next a file dialog box is opened to select a file. a file is selected by the user. the image is read and added to the renderer. the render window is rendered. the camera is reset. the render is updated.

◆ on_actionHelp_triggered

void MainWindow::on_actionHelp_triggered ( )
slot

this function opens the help dialog

Parameters
[in]void
Returns
void
Note
Called by the menu bar

This function is used to show a help dialog box. a new dialog box is created, and its status is displayed in the status bar

◆ on_actionItem_Options_triggered

void MainWindow::on_actionItem_Options_triggered ( )
slot

This function is used to handle item options.

Parameters
[in]void
Returns
void
Note
Called by gui when in right click menu on the tree
used to open dialog box for part settings
is a wrapper for handleButton2()

This function is used to handle the save file action.

Here is the call graph for this function:

◆ on_actionOpen_File_triggered

void MainWindow::on_actionOpen_File_triggered ( )
slot

This function is used to handle the open file button being pressed.

Parameters
[in]void
Returns
void
Note
Called by GUI when button pressed
used to open a file

This function is used to handle the open file action. First current index of the treeview is retrieved and the selected part is retrieved from the index. Next a file dialog box is opened to select a file. a file is selected by the user. all files selected are itterated through and added to the treeview. the render is updated and the camera is reset.

Here is the call graph for this function:

◆ on_actionPrint_triggered

void MainWindow::on_actionPrint_triggered ( )
slot

print image

Parameters
[in]void
Returns
void
Note
called by the menu bar

This function is used to print a render of the model. First a new printer is created and a new print dialog box is created. if the dialog is accepted, a new painter is created and the pixmap is retrieved and drawn. the painter is ended.

◆ on_actionReset_triggered

void MainWindow::on_actionReset_triggered ( )
slot

this function is used to reset the viewer

Parameters
[in]void
Returns
void

This function is used to reset the model. first the status bar is updated with a message. next the current index of the treeview is retrieved and the selected part is retrieved from the index. the colour of the selected part is set. the visibility of the selected part is set to true. the colours of the model are reset. the actor is rotated. the render is updated. the camera is reset. the render window is rendered. the sliders are reset. if the selected part has children, the function is recursively called for each child. the render is updated. the camera is reset. the render window is rendered. the sliders are reset.

Here is the call graph for this function:

◆ on_actionResetColours_triggered

void MainWindow::on_actionResetColours_triggered ( )
slot

this function is used to reset the objects colours

Parameters
[in]void
Returns
void

This function is used to reset the colour of the model. first a message is displayed in the status bar. next the index of the part is retrieved from the treeview and the selected part is retrieved from the index. the number of children is retrieved. if the part has no children, the colour of the selected part is set and the render is updated. the camera is reset and the render window is rendered. if the part has children, the colour of the selected part is set for each child and the render is updated. the camera is reset and the render window is rendered.

Here is the call graph for this function:

◆ on_actionResetPosition_triggered

void MainWindow::on_actionResetPosition_triggered ( )
slot

this function is used to reset the objects position

Parameters
[in]void
Returns
void

This function is used to reset the position of the model. first the index of the part is retrieved from the treeview. the selected part is retrieved from the index. the number of children is retrieved. if the part has no children, the actor is rotated and the render is updated. the camera is reset and the render window is rendered. if the part has children, the actor is rotated for each child and the render is updated. the camera is reset and the render window is rendered.

Here is the call graph for this function:

◆ on_actionSaveRender_triggered

void MainWindow::on_actionSaveRender_triggered ( )
slot

Save image of the render.

Parameters
[in]void
Returns
void
Note
Called by the menu bar

This function is used to save a render of the model. First a file dialog box is opened to select a file to save to. Next the pixmap is retrieved and saved to the file.

◆ on_actionStart_VR_triggered

void MainWindow::on_actionStart_VR_triggered ( )
slot

start the VR session

Parameters
[in]void
Returns
void
Note
Called by the menu bar

This function is used to start the VR viewer. first the status bar is updated with a message. next the VR viewer is started. The actors are made off line to run in the thread and are added to the VR render. the VR render is started.

Here is the call graph for this function:

◆ on_actionStop_VR_triggered

void MainWindow::on_actionStop_VR_triggered ( )
slot

stop the VR session

Parameters
[in]void
Returns
void
Note
Called by the menu bar

This function is used to stop the VR viewer when the stop VR action is triggered. first the status bar is updated with a message. next the VR render is destroyed. the VR running flag is set to false.

Here is the call graph for this function:

◆ ResetCamera

void MainWindow::ResetCamera ( )
slot

This function is used to Reset the camera.

Parameters
[in]void
Returns
void
Note
Called by the menu bar

This function is used to reset the camera. by setting the azimuth and elevation of the camera to 30 and resetting the camera clipping range.

◆ resetSliders

void MainWindow::resetSliders ( )
slot

this function is used to reset Sliders

Parameters
[in]void
Returns
void

This function is used to reset the sliders. the value of each slider is set to 0.

Here is the caller graph for this function:

◆ rotateModelX

void MainWindow::rotateModelX ( )
slot

this function is used to rotate the model in the vtk viewer in the x axis

Parameters
[in]void
Returns
void
Note
different implementation for VR

This function is used to rotate the model in the X axis.first the index of the part is retrieved from the treeview. the selected part is retrieved from the index. the value of the slider is retrieved and converted to a string. the number of children is retrieved. if the part has no children, the actor is rotated and the render is updated. the camera is reset and the render window is rendered. if the part has children, the actor is rotated for each child and the render is updated. the camera is reset and the render window is rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotateModelY

void MainWindow::rotateModelY ( )
slot

this function is used to rotate the model in the vtk viewer in the y axis

Parameters
[in]void
Returns
void
Note
different implementation for VR

This function is used to rotate the model in the Y axis.first the index of the part is retrieved from the treeview. the selected part is retrieved from the index. the value of the slider is retrieved and converted to a string. the number of children is retrieved. if the part has no children, the actor is rotated and the render is updated. the camera is reset and the render window is rendered. if the part has children, the actor is rotated for each child and the render is updated. the camera is reset and the render window is rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotateModelZ

void MainWindow::rotateModelZ ( )
slot

this function is used to rotate the model in the vtk viewer in the z axis

Parameters
[in]void
Returns
void
Note
different implementation for VR

This function is used to rotate the model in the Z axis. first the index of the part is retrieved from the treeview. the selected part is retrieved from the index. the value of the slider is retrieved and converted to a string. the number of children is retrieved. if the part has no children, the actor is rotated and the render is updated. the camera is reset and the render window is rendered. if the part has children, the actor is rotated for each child and the render is updated. the camera is reset and the render window is rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShrinkFilter

void MainWindow::ShrinkFilter ( )
slot

this function is used to apply the shrink filter.

Parameters
[in]void
Returns
void
Note
is applied to the selected part in the treeview.

This function is used to apply a shrink filter. First the index is retrieved from the treeview and the selected part is retrieved from the index. Next the status bar is updated with a message. the shrink filter is applied to the selected part and the renderer is rendered. the render window is rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statusUpdateMessage

void MainWindow::statusUpdateMessage ( const QString &  message,
int  timeout 
)
signal

This function is used to send a message to the status bar.

Parameters
[in]messageis the message to be sent
[in]timeoutis the time the message is displayed for
[out]printsmessage to status bar
Returns
void
Note
Called by the GUI
Here is the caller graph for this function:

◆ updateRender

void MainWindow::updateRender ( )
slot

This function is used to Update the render.

Parameters
[in]void
Returns
void
Note
is a wrapper for updateRenderFromTree(const QModelIndex &index)

This function is used to update the render. first all view props are removed from the renderer and the render is updated from the tree. the renderer is rendered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateRenderFromTree

void MainWindow::updateRenderFromTree ( const QModelIndex &  index)
slot

This function is used to Update the render from the tree.

Parameters
[in]indexis the index of the tree
Returns
void
Note
Called by the tree

This function is used to update the render from the tree. if the index passed is valid then the selected part is retrieved from the index. the new actor is added and other camera settings are set. if the index has children, the function is recursively called for each child.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ blue

double MainWindow::blue
private

red, green, blue are the rgb values for the colour picker

◆ green

double MainWindow::green
private

◆ k

int MainWindow::k = 0
private

k is a counter for the VR rotation

◆ light

vtkSmartPointer<vtkLight> MainWindow::light
private

light is the vtk light

◆ partList

ModelPartList* MainWindow::partList
private

partList is the list of parts

◆ previous_value

int MainWindow::previous_value
private

previous_value is the previous value of the slider

◆ red

double MainWindow::red
private

◆ renderer

vtkSmartPointer<vtkRenderer> MainWindow::renderer
private

renderer is the vtk renderer

◆ renderWindow

vtkSmartPointer<vtkGenericOpenGLRenderWindow> MainWindow::renderWindow
private

renderWindow is the vtk render window

◆ RotationSpeedValue

double MainWindow::RotationSpeedValue = 1.0
private

RotationSpeedValue is the rotation speed value.

◆ StoredFileName

QString MainWindow::StoredFileName
private

StoredFileName is the name of the file.

◆ ui

Ui::MainWindow* MainWindow::ui
private

ui is the user interface

◆ VR_Render

VRRenderThread* MainWindow::VR_Render
private

VR_Render is the VR render thread.

◆ VR_RotationX

int MainWindow::VR_RotationX = 0
private

VR_RotationX is the VR rotation in the x axis.

◆ VR_RotationY

int MainWindow::VR_RotationY = 0
private

VR_RotationY is the VR rotation in the y axis.

◆ VR_RotationZ

int MainWindow::VR_RotationZ = 0
private

VR_RotationZ is the VR rotation in the z axis.

◆ VR_Running

bool MainWindow::VR_Running = false
private

VR_Running is a bool to check if VR is running.


The documentation for this class was generated from the following files: