21 #include "milxQtRenderWindow.h" 23 #include <vtkPoints.h> 24 #include <vtkCellArray.h> 25 #include <vtkPointData.h> 26 #include <vtkDataArray.h> 27 #include <vtkFloatArray.h> 28 #include <vtkPolyData.h> 29 #include <vtkProperty.h> 30 #include <vtkAlgorithmOutput.h> 31 #include <vtkTransform.h> 32 #include <vtkAbstractTransform.h> 33 #include <vtkMutableUndirectedGraph.h> 34 #include <vtkOutlineFilter.h> 35 #include <vtkCubeAxesActor.h> 37 #include <vtkLabeledDataMapper.h> 38 #include <vtkActor2D.h> 39 #include <vtkImageActor.h> 41 #include <vtkPolyDataMapper.h> 42 #include <vtkLODActor.h> 44 #include "milxModel.h" 46 static const int defaultChannelValue = 192;
47 static const float defaultColour = defaultChannelValue/255.0;
124 milxQtModel(QWidget *theParent = 0,
bool contextSystem =
true);
137 return prefix + QFileInfo(name).fileName();
144 void AddInput(vtkSmartPointer<vtkPolyData> mesh);
149 void AddArray(vtkSmartPointer<vtkDataArray> array);
154 void SetInput(vtkSmartPointer<vtkPolyData> mesh);
176 void SetPoints(vtkSmartPointer<vtkPoints> modelPoints);
181 void SetPolys(vtkSmartPointer<vtkCellArray> modelPolys);
186 void SetScalars(vtkSmartPointer<vtkDataArray> modelScalars);
192 { model.SetActiveScalars(nameOfArray); }
197 void RemoveScalars();
202 void SetVectors(vtkSmartPointer<vtkDataArray> modelVectors);
207 void SetTransform(vtkSmartPointer<vtkTransform> transform);
212 void SetGraph(vtkSmartPointer<vtkMutableUndirectedGraph> graph);
221 if(modelled) modelActor->GetProperty()->SetOpacity(opacity);
231 vtkSmartPointer<vtkPolyData> GetPolyDataInput();
236 vtkSmartPointer<vtkPolyData> GetOutput();
237 #if VTK_MAJOR_VERSION <=5 244 return model.GetProducerPort();
261 return modelLabelsActor;
277 return model.GetNumberOfPoints();
285 return model.GetNumberOfArrays();
293 return model.GetPoints();
301 return model.GetScalars();
309 return model.GetVectors();
317 return model.GetNormals();
325 return model.GetTensors();
332 return model.Result();
340 modelMapper->SetScalarRange(range);
341 modelMapper->SetLookupTable(lookupTable);
342 modelMapper->Update();
350 model.Result()->GetScalarRange(range);
361 modelMapper->SetScalarRange( model.Result()->GetScalarRange() );
369 return model.Result()->GetPoints()->GetPoint(
id);
377 return vtkAbstractTransform::SafeDownCast(model.GetTransform());
387 if(modelled)
return modelActor->GetProperty()->GetOpacity();
414 if(modelled) modelMapper->ImmediateModeRenderingOn();
437 generateModel(colourRed, colourGreen, colourBlue);
443 void toggleInterpolation(
bool quiet =
false);
444 inline void interpolateDisplay(
bool quiet =
false)
445 { toggleInterpolation(quiet); }
446 inline void disableInterpolateDisplay(
bool quiet =
false)
447 { interpAct->setChecked(
false); interpolateDisplay(quiet); }
448 inline void enableInterpolateDisplay(
bool quiet =
false)
449 { interpAct->setChecked(
true); interpolateDisplay(quiet); }
454 void toggleSpecular(
bool quiet =
false);
455 inline void specularDisplay(
bool quiet =
false)
456 { toggleSpecular(quiet); }
457 inline void disableSpecularDisplay(
bool quiet =
false)
458 { specularAct->setChecked(
false); specularDisplay(quiet); }
459 inline void enableSpecularDisplay(
bool quiet =
false)
460 { specularAct->setChecked(
true); specularDisplay(quiet); }
476 coordinate& centroid();
481 double centroidSize(
bool average =
false);
486 vnl_matrix<double>& covarianceMatrix();
493 void undoProcessing();
508 void decimate(
double factor = 0.0);
513 void quadricDecimate(
double factor = 0.0);
518 void clusterDecimate();
523 void renameScalars(QString newName =
"");
528 void threshold(
double lowValue = 0.0,
double upValue = 0.0);
533 void thresholdScalars(
double lowValue = 0.0,
double upValue = 0.0,
double outsideVal = 0.0);
538 void thresholdScalarsBinary(
double lowValue = 0.0,
double upValue = 0.0,
double insideVal = 1.0,
double outsideVal = 0.0);
543 void maskScalars(QString filename =
"");
553 void smooth(
int iterations = 0);
561 void smoothSinc(
int iterations = 0);
571 void transform(QString filename =
"",
bool inverse =
false);
576 void loadScalars(QString filename =
"");
581 void removeScalars();
601 void matchInfo(QString filename =
"",
bool rescale =
true,
double factor = 1.0);
606 void registerICP(QString filename =
"",
bool similarity =
false);
613 void registerLandmarks(QString filename =
"",
bool similarity =
false);
628 virtual void selectPointsInContour();
633 virtual void weightGaussianFromContour(
float stddev = -1.0,
float clampValue = -1.0);
643 void changeColour(
float red = -1,
float green = -1,
float blue = -1);
650 void changeOpacity(
float opacity = -1);
657 void normals(
const bool turnOn =
false);
662 void rotate(
bool xAxis =
false,
bool yAxis =
false,
bool zAxis =
false,
float angle = 90);
667 void flip(
bool xAxis =
false,
bool yAxis =
false,
bool zAxis =
false);
677 void enableOutline(vtkDataObject *dataOutline = NULL);
682 void disableOutline();
687 void outlineDisplay();
692 void enableCubeAxes(
double *range = NULL,
double *bounds = NULL);
697 void disableCubeAxes();
702 void cubeAxesDisplay(
double *range = NULL);
707 void removeOverlays();
714 virtual void enableScale(QString title =
"",
const bool quiet =
false,
double minRange = 0.0,
double maxRange = 0.0,
int noOfLabels = 3);
721 virtual void scaleDisplay(
const bool forceDisplay =
false);
726 void outputScalars(QString filename =
"");
746 void showArray(QAction * action);
747 void showArray(
const QString arrayName);
766 void generateDelaunayGraph(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
771 void generateDelaunay2DTriangulation();
776 void generateDelaunayTriangulation(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
782 void generateVertices(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
788 void generateVerticesAs(
const GlyphType glyphType = Circle,
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
794 void generateTubes(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
800 inline void generateEdges(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour)
802 generateTubes(red, blue, green);
811 void generatePointModel(
double newScale = 1.0,
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
819 void generateSampledPoints(
float distance = 0.0,
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
827 void generateVectorField(
double newScale = 0.0,
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
835 void generateTensorField(
double newScale = 0.0,
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
843 void generateStreamLines(vtkSmartPointer<vtkImageData> seeds,
float timestep = 0.0);
851 void generateHedgehog(
double newScale = 0.0,
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
857 void generateNormals(
int pointNormals = 0);
864 void generateModel(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
869 void generateLabels();
874 void generatePointIDsScalars();
881 void generatePoints(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
887 void generateWireframe(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
894 void generateSurface(
float red = defaultColour,
float green = defaultColour,
float blue = defaultColour);
899 void generateIsoSurface(vtkSmartPointer<vtkImageData> img,
int contourNumber = -1,
double value = 0.0);
904 void generatePolyDataFromImage(vtkSmartPointer<vtkImageData> img);
909 void generateKMeansClustering(
int numberOfClusters = 0);
914 void generateQuantisedPoints(
float quantiseFactor = 0.0);
921 void generateCappedBoundaries();
926 void generateRegionLabels();
931 void generateElevation();
949 void surfaceToImage(vtkSmartPointer<vtkPolyData> );
982 coordinate modelCentroid;
1100 void setupTooltips();
1110 QMenu* basicContextMenu();
1115 QMenu* generationMenu();
1120 QMenu* operationsMenu();
1125 QMenu* transformsMenu();
1130 QMenu* scalarsMenu();
1135 QMenu* arraysMenu();
1138 QPointer<milxQtModel> normalsModel;
1139 QPointer<milxQtModel> centroidModel;
1140 QPointer<milxQtModel> outlineModel;
1143 #endif // MILXQTMODEL_H virtual void createMenu(QMenu *menu)
Create the menu for the data in this object. Used for context menu and file menus.
QAction * infoAct
Action for showing the model info.
float colourRed
Saved colour, used for refresh etc.
vtkSmartPointer< vtkLODActor > delaunayActor
Delaunay triangulator actor.
QAction * gradientAct
Action for calculating gradient of the scalars of a model.
QAction * genKmeansAct
Action for calculating k-means clustering of points in a model.
QAction * normalsAct
Action for showing the normals of a model.
QAction * outlineAct
show outline action
QActionGroup * arrayGroup
Grouping for check boxes.
QAction * voxeliseAct
Action for voxelising surface.
virtual void enableScale(QString title="", const bool quiet=false, double minRange=0.0, double maxRange=0.0, int noOfLabels=3)
Enable scale bar display with the title provided.
vtkSmartPointer< vtkActor2D > modelLabelsActor
Label Actor.
QAction * maskScalarsAct
Action for masking scalar values on model.
vtkSmartPointer< vtkActor2D > GetActor2D()
Returns the VTK actor 2D used.
QAction * overlaysAct
removes actors/overlays action
QAction * weightAct
produce Gaussian weights from contour
QAction * textureAct
Action for extracting texture.
vtkSmartPointer< vtkAlgorithmOutput > GetOutputPort()
Returns the connection to the mesh data object (PolyData) used internally VTK style. Call after generate functions. EXPERIMENTAL.
vtkSmartPointer< vtkLODActor > modelActor
Model actor.
QAction * smoothSincAct
Action for smooth model.
QAction * pointsAct
Show points.
QAction * genVectorsAct
Action for generating vector fields.
vnl_matrix< double > modelCovarianceMatrix
Covariance matrix of the model.
vtkSmartPointer< vtkPolyDataMapper > modelMapper
Model mapper.
This class represents the MILX Qt Render Window Display object using QVTK.
QAction * scalarsAct
Action for loading scalars from another model.
QActionGroup * scalarsGroup
Grouping for scalars.
QAction * genDelaunayTri2DAct
Action for generating Delaunay triangulation.
QAction * genLabelsAct
Action for generating labels.
vtkSmartPointer< vtkDataArray > GetTensors()
Returns the tensors (3x3 matrix per vertex) of the model currently held.
vtkSmartPointer< vtkPoints > GetPoints()
Returns the points of the model currently held.
QAction * genReebGraph
Action for Reeb graphs of mesh.
vtkSmartPointer< vtkAbstractTransform > GetTransform()
Returns the transform of the model currently held.
void createConnections()
Create the connections for context menu etc.
QAction * surfaceAct
Show surface.
QAction * genTensorsAct
Action for generating vector fields.
void setLargeDataSetMode(bool large)
Set display mode to memory conserving and fast rendering (in most cases).
virtual vtkDataSet * GetDataSet()
Get the polydata data, return the vtkImageData object downcast to vtkDataSet, useful for getting scal...
QAction * smoothAct
Action for smooth model.
bool transformed
Transformed?
QAction * removeScalarsAct
Action for removing scalars from model.
virtual void contour()
Draw contour interactively.
bool largeMode
Large Data set mode enabled?
virtual void updateLookupTable()
Implement this into your derived class to ensure the new colourmap is passed on to your viewing data ...
virtual void viewToZXPlane()
Change view to zx-plane.
QAction * wireframeAct
Show wireframe.
QAction * quadricDecimateAct
Action for Quadric decimating model.
QAction * renameScalarsAct
Action for renaming scalars array.
float colourGreen
Saved colour, used for refresh etc.
QAction * registerLandmarkAct
Action for registering two models via landmark transform.
bool appended
Appended data present?
virtual void copyToContextMenu(QMenu *copyMenu)
Copies the menu, by duplicating the entries, to the context menu. Connections are assumed to be made ...
QAction * triAct
Action for triangulate model.
vtkSmartPointer< vtkOutlineFilter > outlineMesh
outline box
double * GetPoint(vtkIdType id)
Returns the point with id of the model currently held.
QAction * registerAct
Action for registering two models.
QAction * centroidAct
show centroid action
vtkIdType GetNumberOfPoints()
Returns the total number of points of the model currently held.
QAction * genQuantiseAct
Action for quantising points in a model.
bool modelled
Model has been generated?
This class represents the MILX Qt Model/Mesh Display object using VTK.
bool computedCovariance
Computed covariance matrix already?
QAction * genCapBoundaries
Action for capping the boundaries of a open mesh.
QAction * decimateAct
Action for decimating model.
QAction * specularAct
Action for changing the specular of a model to flat.
QAction * cleanAct
Action for cleaning model.
bool scalarsSet
Scalars set to points of mesh?
bool outlineBefore
scale displayed?
#define MILXQT_EXPORT
Define Windows DLL importing.
QAction * curvatureAct
Action for calculating mean curvation of a model.
void SetOpacity(double opacity)
Adjusts the opacity of the model in the display. 1.0 is totally opaque and 0.0 is completely transpar...
QAction * genDelaunayTriAct
Action for generating Delaunay triangulation.
void SetScalarRange(double range[2])
Set the scalar range of the model currently held.
float colourBlue
Saved colour, used for refresh etc.
virtual void updateCoords(vtkObject *obj)
Picks the coordinates and pixel value from the current mouse position in the window.
QAction * colourAct
Action for changing colours of a model.
QAction * cubeAxesAct
show cube axes action
QAction * genRegionLabels
Action for labelling unconnected regions of mesh.
void contextMenuEvent(QContextMenuEvent *event)
The context menu setup member.
vtkSmartPointer< vtkPolyDataMapper > GetMapper()
Returns the VTK mapper used.
bool cubeAxesBefore
scale displayed?
void createActions()
Create the actions for context menu etc.
QAction * thresholdScalarsAct
Action for thresholding scalar values on model.
QAction * clusterDecimateAct
Action for Cluster decimating model.
QAction * flipAct
Action for flipping surface.
bool computedCentroid
Computed centroid already?
QAction * genModelAct
Action for generating model.
virtual void scaleDisplay(const bool forceDisplay=false)
Toggles the scale bar display.
vtkSmartPointer< vtkPolyData > GetOutput()
Returns the mesh data object (PolyData) used internally VTK style.
QMenu * arrayMenu
arrays Menu
vtkSmartPointer< vtkDataArray > GetScalars()
Returns the scalars of the model currently held.
QAction * genVerticesAct
Action for generating vertices.
void reset()
Reset the display of the model, includes camera and regeneration.
void resetScalarRange()
Restores the scalar range of the model currently held to current max range for display.
bool labelled
Labels generated?
QAction * genPointModelAct
Action for generating labels.
QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Model" prefix.
QAction * selectPointsAct
select points within contour
QMenu * transformMenu
Transform Menu.
QMenu * scalarMenu
Context Menu.
QAction * genSamplesAct
Action for generating sampled points on mesh.
vtkSmartPointer< vtkActor > outlineActor
Outline box actor.
virtual void viewToZYPlane()
Change view to zy-plane.
QAction * thresholdScalarsBinaryAct
Action for binary thresholding scalar values on model.
vtkSmartPointer< vtkDataArray > GetVectors()
Returns the vectors of the model currently held.
void SetActiveScalars(std::string nameOfArray)
Sets the array of name as scalars for the model to be generated.
QMenu * showMenu
Camera Menu.
void Update()
Update the model currently held.
QAction * genNormalsAct
Action for generating normals.
void generateEdges(float red=defaultColour, float green=defaultColour, float blue=defaultColour)
Generates the tubes for the dataset. Arguments provided are for the colours of the tubes...
void append(milxQtModel *mdl)
Appends the provided model to current model.
QAction * genHedgehogAct
Action for generating Hedgehog fields.
QAction * thresholdAct
Action for thresholding model.
Represents a model (i.e. a model with cells and scalar values) and their common operations. Also allows batch operations on collection of models.
double GetOpacity()
Returns the opacity of the model in the display. 1.0 is totally opaque and 0.0 is completely transpar...
QAction * matchAct
Action for matching scale and centroids of two models.
QAction * outScalarsAct
Action for output of scalars.
virtual void viewToXYPlane()
Change view to xy-plane.
void ImmediateModeRenderingOn()
Improve rendering performance for large datasets. Assumes generateModel() has already been called...
milx::Model model
Actual model and its operations (from SMILI)
QMenu * generateMenu
Menu for generating viewing options.
void refresh()
Refresh the display of the model including widgets. Camera remains as is.
vtkSmartPointer< vtkDataArray > GetNormals()
Returns the normals of the model currently held.
QMenu * operateMenu
Operate Menu.
vtkSmartPointer< vtkLODActor > GetActor()
Returns the VTK actor used.
QAction * interpAct
Action for changing the interpolation of a model.
QAction * genDelaunayAct
Action for generating Delaunay graphs.
QActionGroup * displayGroup
Grouping for check boxes.
QAction * rotateAct
Action for rotating surface.
QAction * doAct
Action for undoing and redoing actions.
virtual void background(bool white=false)
Changes background to white.
vtkSmartPointer< vtkCubeAxesActor > cubeAxesActor
outline box
bool undidProcess
Undid a process?
void GetScalarRange(double range[2])
Get the scalar range of the model currently held.
QAction * genElevation
Action for elevation scalars of mesh.
QAction * genPointIDsAct
Action for generating labels.
vtkIdType GetNumberOfArrays()
Returns the total number of arrays in the model.
QAction * transformAct
Action for transforming model.