CAD Viewer
|
Model Part class. More...
#include "ModelPart.h"
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... | |
ModelPart * | child (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... | |
ModelPart * | parentItem () |
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 |
ModelPart * | m_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 |
Model Part class.
This class is the main window for the CAD viewer that the use interfaces with.
ModelPart::ModelPart | ( | const QList< QVariant > & | data, |
ModelPart * | parent = nullptr |
||
) |
Constructor for model part.
data | is a List (array) of strings for each property of this item (part name and visiblity in our case |
parent | is the parent of this item (one level up in tree) |
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 | ( | ) |
void ModelPart::appendChild | ( | ModelPart * | item | ) |
Append a child item to this item.
item | Pointer to child object (must already be allocated using new) |
This function is responsible for appending a child item to the ModelPart object.
ModelPart * ModelPart::child | ( | int | row | ) |
child at position 'row' below this item
row | is the row number (below this item) |
This function is responsible for returning a child item from the ModelPart object. if the row is not valid, nullptr is returned
int ModelPart::childCount | ( | ) | const |
Get number of children of this item.
This function is responsible for returning the number of child items from the ModelPart object.
void ModelPart::clipfilters | ( | bool | state, |
int | clipVal, | ||
int | normalVal | ||
) |
Apply clip filter to model.
state | is 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.
int ModelPart::columnCount | ( | ) | const |
Get number of data items (2 - part name and visibility string) in this case.
This function is responsible for returning the number of columns from the ModelPart object.
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.
column | is column index |
This function is responsible for returning the data from the ModelPart object. if the column is not valid, noexpt is returned.
vtkSmartPointer< vtkActor > ModelPart::getActor | ( | ) |
Return the actor.
This function is responsible for returning the actor of the ModelPart object.
unsigned char ModelPart::getColourB | ( | ) |
Get Blue colour component of this part.
This function is responsible for returning the blue colour of the ModelPart object.
unsigned char ModelPart::getColourG | ( | ) |
Get Green colour component of this part.
This function is responsible for returning the green colour of the ModelPart object.
unsigned char ModelPart::getColourR | ( | ) |
Get Red colour component of this part.
This function is responsible for returning the red colour of the ModelPart object.
QString ModelPart::getFileName | ( | ) |
Get file name.
This function is responsible for returning the file name of the ModelPart object.
vtkSmartPointer< vtkMapper > ModelPart::getMapper | ( | ) |
Return the mapper.
This function is responsible for returning the mapper of the ModelPart object.
vtkActor * ModelPart::getNewActor | ( | ) |
Return new actor for use in VR.
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.
vtkSmartPointer< vtkSTLReader > ModelPart::getReader | ( | ) |
Return the reader to get the file source.
This function is responsible for returning the mapper of the ModelPart object.
void ModelPart::loadSTL | ( | QString | fileName | ) |
Load STL file.
fileName | is 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.
ModelPart * ModelPart::parentItem | ( | ) |
@briefGet pointer to parent item
This function is responsible for returning the parent item from the ModelPart object.
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.
void ModelPart::refreshModelVR | ( | ) |
Refresh the VR model.
This function refresh VR model. This is now obsolete
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.
void ModelPart::resetColoursOfVRModel | ( | ) |
Reset the colours of the VR model.
This function resets the colours of the VR model. This is now obsolete
void ModelPart::rotateActorX | ( | double | sliderValue | ) |
Rotate actor in the X axis by a given value.
sliderValue | is 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.
void ModelPart::rotateActorY | ( | double | sliderValue | ) |
Rotate actor in the Y axis by a given value.
sliderValue | is 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.
void ModelPart::rotateActorZ | ( | double | sliderValue | ) |
Rotate actor in the Z axis by a given value.
sliderValue | is 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.
void ModelPart::rotateVRActorX | ( | double | sliderValue | ) |
Rotate VR actor in the X axis by a given value.
void ModelPart::rotateVRActorY | ( | double | sliderValue | ) |
Rotate VR actor in the Y axis by a given value.
void ModelPart::rotateVRActorZ | ( | double | sliderValue | ) |
Rotate VR actor in the Z axis by a given value.
int ModelPart::row | ( | ) | const |
Get row index of item, relative to parent item.
This function is responsible for returning the row number from the ModelPart object. if no parent item exists, the function returns 0.
void ModelPart::set | ( | int | column, |
const QVariant & | value | ||
) |
Default function required by Qt to allow setting of part. properties within treeview.
column | is the index of the property to set |
value | is 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
void ModelPart::setColour | ( | const unsigned char | R, |
const unsigned char | G, | ||
const unsigned char | B | ||
) |
Set colour of this part.
R | red colour component value between 0 and 255 |
G | green colour component value between 0 and 255 |
B | blue 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.
void ModelPart::setColoursOfModel | ( | double | r, |
double | g, | ||
double | b | ||
) |
set colours of the model
r | is the red colour component |
g | is the green colour component |
b | is 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.
void ModelPart::setFileName | ( | QString | filename | ) |
Set file name.
filename | is teh new name of the file |
This function is responsible for setting the file name of the ModelPart object.
void ModelPart::setVisible | ( | bool | isVisible | ) |
Set visible flag.
isVisible | sets visible/non-visible |
This function is responsible for setting the visibility of the ModelPart object.
void ModelPart::shrinkfilters | ( | bool | state | ) |
Apply shrink filter to model.
state | is 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.
bool ModelPart::visible | ( | ) |
Get visible flag.
This function is responsible for returning the visibility of the ModelPart object.
|
private |
Actor for rendering
|
private |
Colour components for this part
|
private |
User defineable colour
|
private |
Datafile from which part loaded
|
private |
Full path to file
|
private |
|
private |
Gaussian filter for rendering
|
private |
True/false to indicate if should be visible in model rendering
|
private |
List (array) of child items
|
private |
List (array of column data for item
|
private |
Pointer to parent
|
private |
Mapper for rendering
|
private |
Actor for rendering
|
private |
Mapper for rendering
|
private |
Property for rendering
|
private |
Transform for rendering
|
private |
Property for rendering
|
private |
|
private |
True/false to indicate if should be visible in model rendering
|
private |
Transform for rendering