CAD Viewer
Public Member Functions | Private Attributes | List of all members
ModelPart Class Reference

Model Part class. More...

#include "ModelPart.h"

Collaboration diagram for ModelPart:
Collaboration graph
[legend]

Public Member Functions

 ModelPart (const QList< QVariant > &data, ModelPart *parent=nullptr)
 Constructor for model part. More...
 
 ~ModelPart ()
 Destructor for model part. More...
 
void appendChild (ModelPart *item)
 Append a child item to this item. More...
 
ModelPartchild (int row)
 child at position 'row' below this item More...
 
int childCount () const
 Get number of children of this item. More...
 
int columnCount () const
 Get number of data items (2 - part name and visibility string) in this case. More...
 
QVariant data (int column) const
 Return the data item at a particular column for this item. i.e. either part name of visibility. used by Qt when displaying tree. More...
 
void set (int column, const QVariant &value)
 Default function required by Qt to allow setting of part. properties within treeview. More...
 
ModelPartparentItem ()
 
int row () const
 Get row index of item, relative to parent item. More...
 
void setColour (const unsigned char R, const unsigned char G, const unsigned char B)
 Set colour of this part. More...
 
void setFileName (QString filename)
 Set file name. More...
 
QString getFileName ()
 Get file name. More...
 
unsigned char getColourR ()
 Get Red colour component of this part. More...
 
unsigned char getColourG ()
 Get Green colour component of this part. More...
 
unsigned char getColourB ()
 Get Blue colour component of this part. More...
 
void setVisible (bool isVisible)
 Set visible flag. More...
 
bool visible ()
 Get visible flag. More...
 
void loadSTL (QString fileName)
 Load STL file. More...
 
void refreshModel ()
 Refresh the model. More...
 
void refreshModelVR ()
 Refresh the VR model. More...
 
void rotateActorX (double sliderValue)
 Rotate actor in the X axis by a given value. More...
 
void rotateActorY (double sliderValue)
 Rotate actor in the Y axis by a given value. More...
 
void rotateActorZ (double sliderValue)
 Rotate actor in the Z axis by a given value. More...
 
void resetColoursOfModel ()
 Reset the colours of the model. More...
 
void resetColoursOfVRModel ()
 Reset the colours of the VR model. More...
 
void rotateVRActorX (double sliderValue)
 Rotate VR actor in the X axis by a given value. More...
 
void rotateVRActorY (double sliderValue)
 Rotate VR actor in the Y axis by a given value. More...
 
void rotateVRActorZ (double sliderValue)
 Rotate VR actor in the Z axis by a given value. More...
 
vtkSmartPointer< vtkSTLReader > getReader ()
 Return the reader to get the file source. More...
 
vtkSmartPointer< vtkActor > getActor ()
 Return the actor. More...
 
vtkSmartPointer< vtkMapper > getMapper ()
 Return the mapper. More...
 
vtkActor * getNewActor ()
 Return new actor for use in VR. More...
 
void shrinkfilters (bool state)
 Apply shrink filter to model. More...
 
void clipfilters (bool state, int clipVal, int normalVal)
 Apply clip filter to model. More...
 
void setColoursOfModel (double r, double g, double b)
 set colours of the model More...
 

Private Attributes

QList< ModelPart * > m_childItems
 
QList< QVariant > m_itemData
 
ModelPartm_parentItem
 
bool isVisible
 
bool renderVisible
 
int r
 
int g
 
int b
 
vtkSmartPointer< vtkSTLReader > file
 
vtkSmartPointer< vtkMapper > mapper
 
vtkSmartPointer< vtkActor > actor
 
vtkColor3< unsigned char > colour
 
vtkSmartPointer< vtkMapper > newMapper
 
vtkSmartPointer< vtkActor > newActor
 
vtkSmartPointer< vtkProperty > newProperty
 
vtkSmartPointer< vtkImageGaussianSmooth > gaussian_filter
 
vtkSmartPointer< vtkTransform > transform
 
vtkSmartPointer< vtkTransform > newTransform
 
vtkSmartPointer< vtkProperty > property
 
QString FileNameFullPath
 

Detailed Description

Model Part 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

◆ ModelPart()

ModelPart::ModelPart ( const QList< QVariant > &  data,
ModelPart parent = nullptr 
)

Constructor for model part.

Parameters
datais a List (array) of strings for each property of this item (part name and visiblity in our case
parentis the parent of this item (one level up in tree)
Returns
void

This function is the constructor for the ModelPart class and is responsible for creating the ModelPart object. default colours are set, and information saved to private variables

◆ ~ModelPart()

ModelPart::~ModelPart ( )

Destructor for model part.

Returns
void

This function is the destructor for the ModelPart class and is responsible for deleting the ModelPart object.

Member Function Documentation

◆ appendChild()

void ModelPart::appendChild ( ModelPart item)

Append a child item to this item.

Parameters
itemPointer to child object (must already be allocated using new)
Returns
void

This function is responsible for appending a child item to the ModelPart object.

Here is the caller graph for this function:

◆ child()

ModelPart * ModelPart::child ( int  row)

child at position 'row' below this item

Parameters
rowis the row number (below this item)
Returns
pointer to the item requested.

This function is responsible for returning a child item from the ModelPart object. if the row is not valid, nullptr is returned

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

◆ childCount()

int ModelPart::childCount ( ) const

Get number of children of this item.

Returns
number of children

This function is responsible for returning the number of child items from the ModelPart object.

Here is the caller graph for this function:

◆ clipfilters()

void ModelPart::clipfilters ( bool  state,
int  clipVal,
int  normalVal 
)

Apply clip filter to model.

Parameters
stateis the state of the checkbox

This functions applies the clip filter. if no actor exits the function returns. the filter sits in between the mapper and the file. re-routing the input connection via the clip filter. A plane is also created to clip the model.

Here is the caller graph for this function:

◆ columnCount()

int ModelPart::columnCount ( ) const

Get number of data items (2 - part name and visibility string) in this case.

Returns
number of visible data columns

This function is responsible for returning the number of columns from the ModelPart object.

Here is the caller graph for this function:

◆ data()

QVariant ModelPart::data ( int  column) const

Return the data item at a particular column for this item. i.e. either part name of visibility. used by Qt when displaying tree.

Parameters
columnis column index
Returns
the QVariant (represents string)

This function is responsible for returning the data from the ModelPart object. if the column is not valid, noexpt is returned.

Here is the caller graph for this function:

◆ getActor()

vtkSmartPointer< vtkActor > ModelPart::getActor ( )

Return the actor.

Returns
pointer to the actor

This function is responsible for returning the actor of the ModelPart object.

Here is the caller graph for this function:

◆ getColourB()

unsigned char ModelPart::getColourB ( )

Get Blue colour component of this part.

Returns
blue colour component as unsigned char

This function is responsible for returning the blue colour of the ModelPart object.

Here is the caller graph for this function:

◆ getColourG()

unsigned char ModelPart::getColourG ( )

Get Green colour component of this part.

Returns
green colour component as unsigned char

This function is responsible for returning the green colour of the ModelPart object.

Here is the caller graph for this function:

◆ getColourR()

unsigned char ModelPart::getColourR ( )

Get Red colour component of this part.

Returns
red colour component as unsigned char

This function is responsible for returning the red colour of the ModelPart object.

Here is the caller graph for this function:

◆ getFileName()

QString ModelPart::getFileName ( )

Get file name.

Returns
file name as string

This function is responsible for returning the file name of the ModelPart object.

◆ getMapper()

vtkSmartPointer< vtkMapper > ModelPart::getMapper ( )

Return the mapper.

Returns
pointer to the mapper

This function is responsible for returning the mapper of the ModelPart object.

◆ getNewActor()

vtkActor * ModelPart::getNewActor ( )

Return new actor for use in VR.

Returns
pointer to new actor

This function is responsible for creating a new actor of the ModelPart object. This is done by creating a new mapper. setting the input connection to the file that is the source. A new actor is created and the mapper set. The property is set to the actor.

Here is the caller graph for this function:

◆ getReader()

vtkSmartPointer< vtkSTLReader > ModelPart::getReader ( )

Return the reader to get the file source.

Returns
pointer to the reader

This function is responsible for returning the mapper of the ModelPart object.

◆ loadSTL()

void ModelPart::loadSTL ( QString  fileName)

Load STL file.

Parameters
fileNameis the name of the file to load

This function is responsible for loading the STL file of the ModelPart object. first a STL reader is created. the file name is set and the file updated. A mapper is created and the input connection set to the file that is the source. An actor is created and the mapper set. The colour of the actor is set and the property is created. The ambient, diffuse, specular and specular power are set. The property is set to the actor.

Here is the caller graph for this function:

◆ parentItem()

ModelPart * ModelPart::parentItem ( )

@briefGet pointer to parent item

Returns
pointer to parent item

This function is responsible for returning the parent item from the ModelPart object.

Here is the caller graph for this function:

◆ refreshModel()

void ModelPart::refreshModel ( )

Refresh the model.

This function refreshes the model after an update. This is done by setting the mapper to the actor. A new property is created and the ambient, diffuse, specular and specular power are set. The property is set to the actor. The colour of the actor is set and the opacity is set.

◆ refreshModelVR()

void ModelPart::refreshModelVR ( )

Refresh the VR model.

This function refresh VR model. This is now obsolete

◆ resetColoursOfModel()

void ModelPart::resetColoursOfModel ( )

Reset the colours of the model.

This function is responsible for resetting the colour of the ModelPart object. if no actor exits the function returns. the colours of the actor are set and the opacity is set. The ambient, diffuse, specular and specular power are set.

Here is the caller graph for this function:

◆ resetColoursOfVRModel()

void ModelPart::resetColoursOfVRModel ( )

Reset the colours of the VR model.

This function resets the colours of the VR model. This is now obsolete

◆ rotateActorX()

void ModelPart::rotateActorX ( double  sliderValue)

Rotate actor in the X axis by a given value.

Parameters
sliderValueis the value to rotate by

This function rotates a model about the x axis. if no actor exits the function returns. a vtkTransform is created and the actor is rotated.

Here is the caller graph for this function:

◆ rotateActorY()

void ModelPart::rotateActorY ( double  sliderValue)

Rotate actor in the Y axis by a given value.

Parameters
sliderValueis the value to rotate by

This function rotates a model about the y axis. if no actor exits the function returns. a vtkTransform is created and the actor is rotated.

Here is the caller graph for this function:

◆ rotateActorZ()

void ModelPart::rotateActorZ ( double  sliderValue)

Rotate actor in the Z axis by a given value.

Parameters
sliderValueis the value to rotate by

This function rotates a model about the z axis. if no actor exits the function returns. a vtkTransform is created and the actor is rotated.

Here is the caller graph for this function:

◆ rotateVRActorX()

void ModelPart::rotateVRActorX ( double  sliderValue)

Rotate VR actor in the X axis by a given value.

◆ rotateVRActorY()

void ModelPart::rotateVRActorY ( double  sliderValue)

Rotate VR actor in the Y axis by a given value.

◆ rotateVRActorZ()

void ModelPart::rotateVRActorZ ( double  sliderValue)

Rotate VR actor in the Z axis by a given value.

◆ row()

int ModelPart::row ( ) const

Get row index of item, relative to parent item.

Returns
row index

This function is responsible for returning the row number from the ModelPart object. if no parent item exists, the function returns 0.

Here is the caller graph for this function:

◆ set()

void ModelPart::set ( int  column,
const QVariant &  value 
)

Default function required by Qt to allow setting of part. properties within treeview.

Parameters
columnis the index of the property to set
valueis the value to apply

This function is responsible for returning the row number from the ModelPart object. if the parent item does not exist, the functions returns

Here is the caller graph for this function:

◆ setColour()

void ModelPart::setColour ( const unsigned char  R,
const unsigned char  G,
const unsigned char  B 
)

Set colour of this part.

Parameters
Rred colour component value between 0 and 255
Ggreen colour component value between 0 and 255
Bblue colour component value between 0 and 255

This function is responsible for setting the colour of the ModelPart object. RBG values are passed in as parameters and saved to the object.

Here is the caller graph for this function:

◆ setColoursOfModel()

void ModelPart::setColoursOfModel ( double  r,
double  g,
double  b 
)

set colours of the model

Parameters
ris the red colour component
gis the green colour component
bis the blue colour component

This function is responsible for setting the colour of the ModelPart object. if no actor exits the function returns. the colours of the actor are set and the opacity is set.

Here is the caller graph for this function:

◆ setFileName()

void ModelPart::setFileName ( QString  filename)

Set file name.

Parameters
filenameis teh new name of the file

This function is responsible for setting the file name of the ModelPart object.

Here is the caller graph for this function:

◆ setVisible()

void ModelPart::setVisible ( bool  isVisible)

Set visible flag.

Parameters
isVisiblesets visible/non-visible

This function is responsible for setting the visibility of the ModelPart object.

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

◆ shrinkfilters()

void ModelPart::shrinkfilters ( bool  state)

Apply shrink filter to model.

Parameters
stateis the state of the checkbox

This functions applies the shrink filter. if no actor exits the function returns. the filter sits in between the mapper and the file. re-routing the input connection via the shrink filter.

Here is the caller graph for this function:

◆ visible()

bool ModelPart::visible ( )

Get visible flag.

Returns
visible flag as boolean

This function is responsible for returning the visibility of the ModelPart object.

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

Member Data Documentation

◆ actor

vtkSmartPointer<vtkActor> ModelPart::actor
private

Actor for rendering

◆ b

int ModelPart::b
private

Colour components for this part

◆ colour

vtkColor3<unsigned char> ModelPart::colour
private

User defineable colour

◆ file

vtkSmartPointer<vtkSTLReader> ModelPart::file
private

Datafile from which part loaded

◆ FileNameFullPath

QString ModelPart::FileNameFullPath
private

Full path to file

◆ g

int ModelPart::g
private

◆ gaussian_filter

vtkSmartPointer<vtkImageGaussianSmooth> ModelPart::gaussian_filter
private

Gaussian filter for rendering

◆ isVisible

bool ModelPart::isVisible
private

True/false to indicate if should be visible in model rendering

◆ m_childItems

QList<ModelPart *> ModelPart::m_childItems
private

List (array) of child items

◆ m_itemData

QList<QVariant> ModelPart::m_itemData
private

List (array of column data for item

◆ m_parentItem

ModelPart* ModelPart::m_parentItem
private

Pointer to parent

◆ mapper

vtkSmartPointer<vtkMapper> ModelPart::mapper
private

Mapper for rendering

◆ newActor

vtkSmartPointer<vtkActor> ModelPart::newActor
private

Actor for rendering

◆ newMapper

vtkSmartPointer<vtkMapper> ModelPart::newMapper
private

Mapper for rendering

◆ newProperty

vtkSmartPointer<vtkProperty> ModelPart::newProperty
private

Property for rendering

◆ newTransform

vtkSmartPointer<vtkTransform> ModelPart::newTransform
private

Transform for rendering

◆ property

vtkSmartPointer<vtkProperty> ModelPart::property
private

Property for rendering

◆ r

int ModelPart::r
private

◆ renderVisible

bool ModelPart::renderVisible
private

True/false to indicate if should be visible in model rendering

◆ transform

vtkSmartPointer<vtkTransform> ModelPart::transform
private

Transform for rendering


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