SMILX  1.01
milxQtShapeModel.h
1 /*=========================================================================
2  The Software is copyright (c) Commonwealth Scientific and Industrial Research Organisation (CSIRO)
3  ABN 41 687 119 230.
4  All rights reserved.
5 
6  Licensed under the CSIRO BSD 3-Clause License
7  You may not use this file except in compliance with the License.
8  You may obtain a copy of the License in the file LICENSE.md or at
9 
10  https://stash.csiro.au/projects/SMILI/repos/smili/browse/license.txt
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 =========================================================================*/
18 #ifndef MILXQTSHAPEMODEL_H
19 #define MILXQTSHAPEMODEL_H
20 
21 //milxSSM3D
22 #include <itkStatisticalShapeTimepointModel.h>
23 
24 #include <milxQtAliases.h>
25 #include <milxQtRenderWindow.h>
26 #include <milxQtModel.h>
27 
28 typedef itk::StatisticalShapeModelBase<double> ShapeModelBaseType;
29 typedef itk::StatisticalShapeTimepointModel<double> ShapeModelType;
30 
32 {
33  Q_OBJECT
34 
35 public:
37  milxQtShapeModel(QWidget *theParent = 0, bool contextSystem = true);
39  virtual ~milxQtShapeModel();
40 
45  inline virtual bool isLoaded()
46  { return m_loaded; }
47 
48 public slots:
55  void LoadModel(const QString filename);
62  inline virtual void openModel(const QString filename)
63  {
64  LoadModel(filename);
65  }
72  inline virtual void SaveModel(const QString filename)
73  {
74  m_StandardSSM->Update();
75  m_StandardSSM->SaveModel(filename.toStdString().c_str());
76  }
83  inline virtual void saveModel(const QString filename)
84  {
85  SaveModel(filename);
86  }
87 
92  virtual void SetInputCollection(vtkPolyDataCollection* meshes);
99  virtual void SetInputCollection(vtkPolyDataCollection* meshes, QStringList &filenames);
104  inline void SetPrecision(float modePrecision)
105  {
106  m_SSM->SetPrecision(modePrecision);
107  }
112  inline void AddShape(vtkPolyData *shape)
113  { m_SSM->AddShape(shape); }
118  inline vtkPolyData* GetShape(unsigned int index)
119  { return m_SSM->GetShape(index); }
124  inline vtkPolyData* GetAlignedShape(unsigned int index)
125  { return m_SSM->GetProcrustesAlignedSurface(index); }
130  inline vtkPolyData* GetProcrustesAlignedSurface(unsigned int index)
131  { return m_SSM->GetProcrustesAlignedSurface(index); }
132 
137  inline vtkPolyData* GetMeanShape()
138  {
139  if(m_modelled) return m_SSM->GetMeanShape();
140  return NULL;
141  }
146  QPointer<milxQtModel> getMeanModel();
151  inline int GetNumberOfModes()
152  {
153  if(m_modelled) return m_SSM->GetNumberOfModes();
154  return -1;
155  }
160  inline int GetNumberOfShapes()
161  { return m_SSM->GetNumberOfShapes(); }
166  inline QList< int > getCaseIDs()
167  { return m_caseIDs; }
171  virtual vtkDataSet* GetDataSet();
172 
177  virtual void createMenu(QMenu *menu);
178 
183  virtual void generateSSM();
188  virtual void generateMeanModel(vtkSmartPointer<vtkPolyData> shape = NULL);
193  void generateModels(const bool display = true);
200  void generateAlignedModels(const bool display = true);
207  virtual void generateModes();
208  virtual void generateCollectionBasedOnMode();
215  void generateVectorField();
222  void generateTensorField();
227  void generateCorrespondences();
228 
233  void mean();
238  void aligned();
243  void original();
248  void modesAsVectors();
253  void modesAsTensors();
258  void modesAsCollection();
263  void procrustes();
268  void alignment();
273  void alignedMeshes();
278  void originalMeshes();
283  void pointIds();
290  void coordinates();
298  void replaceOriginal();
303  void correspondences();
304 
312  void compactness();
319  void specificity();
326  void generalisability();
331  void eigenvalues();
336  void eigenmodes();
341  void parameters();
342 
343 signals:
348  void collectionAvailable(vtkPolyDataCollection*, QStringList&);
353  void resultAvailable(milxQtRenderWindow*);
358  void resultAvailable(milxQtModel*);
359 
360 protected:
361  bool m_loaded;
362  bool m_modelled;
363  bool m_meaned;
366  bool m_modes;
367  bool m_vector;
368  bool m_tensor;
370  int m_mode;
371 
372  //----Context----
373  QAction* actionMean;
374  QAction* actionAligned;
375  QAction* actionOriginal;
379  //-------------
380  QAction* actionAlignment;
383  QAction* actionPointIDs;
384  QAction* actionCoordinates;
385  QAction* actionCorrespond;
386  //-------------
388  //----Plot----
389  QMenu* plotMenu;
390  QAction* actionCompact;
391  QAction* actionSpecificity;
392  QAction* actionGeneralise;
393  QAction* actionValues;
394  QAction* actionModes;
395  QAction* actionParameters;
396  //----Procrustes----
397  QMenu* alignMenu;
398  QActionGroup* alignGroup;
399  QAction* actionRigid;
400  QAction* actionSimilarity;
401  QAction* actionAffine;
402 
403  ShapeModelType::Pointer m_StandardSSM;
404  ShapeModelBaseType::Pointer m_SSM;
405 
406  QList< int > m_caseIDs;
407  QList< QPointer<milxQtModel> > m_models;
408  QList< QPointer<milxQtModel> > m_alignedModels;
409 
410  QPointer<milxQtModel> m_meanModel;
411  QPointer<milxQtModel> m_modesVectorModel;
412  QPointer<milxQtModel> m_modesTensorModel;
413  QPointer<milxQtModel> m_correspondences;
414 
419  virtual void updateLookupTable();
420  virtual void reset();
421  void outputSnapshots(const QString filename);
426  void createActions();
431  void createConnections();
436  void setupTooltips();
441  void contextMenuEvent(QContextMenuEvent *event);
442 
443 private:
444 
445 };
446 
447 #endif // MILXQTSHAPEMODEL_H
virtual void createMenu(QMenu *menu)
Create the menu for the data in this object. Used for context menu and file menus.
QPointer< milxQtModel > m_modesVectorModel
Vector Model of the modes.
QAction * actionGeneralise
generalisibility error plot action
QAction * actionAlignment
alignment check action
QAction * actionCoordinates
coordinates check action
QList< int > getCaseIDs()
Returns the case IDs for the SSM. Assumes that an SSM has been loaded.
QAction * actionModesAsCollection
modes collection action
virtual void saveModel(const QString filename)
Saves a model as an SSM (*.ssm) file.
int m_mode
Mode being viewed.
QAction * actionOriginal
original points action
bool m_tensor
Tensors generated?
This file defines all the defines, aliases and frequently used functions and variables.
This class represents the MILX Qt Render Window Display object using QVTK.
bool m_alignedShapesModelled
Shapes were generated?
QMenu * plotMenu
Plot menu for SSM analysis.
QAction * actionModesAsTensors
modes action
QAction * actionReplaceOriginal
correspondence check action
void createConnections()
Create the connections for context menu etc.
QAction * actionSimilarity
similarity Procrustes action
QAction * actionCompact
compactness plot action
vtkPolyData * GetShape(unsigned int index)
Gets the shape at index in the SSM.
QAction * actionAligned
aligned points action
QPointer< milxQtModel > m_modesTensorModel
Tensor Model of the modes.
QActionGroup * alignGroup
Procrustes align gp action.
virtual vtkDataSet * GetDataSet()
Get the data, Implement in derived class that uses data derived from vtkDataSet, like vtkPolyData or ...
bool m_modes
Modes been generated?
QList< QPointer< milxQtModel > > m_models
Original Models in the SSM.
virtual void updateLookupTable()
Implement this into your derived class to ensure the new colourmap is passed on to your viewing data ...
QAction * actionOriginalMeshes
original meshes output action
QAction * actionModesAsVectors
modes action
QAction * actionCorrespond
correspondence check action
bool m_meaned
Mean generated?
bool m_modelled
SSM Modelled?
QAction * actionAlignedMeshes
alignmed meshes output action
QAction * actionModes
primary modes plot action
This class represents the MILX Qt Model/Mesh Display object using VTK.
Definition: milxQtModel.h:115
vtkPolyData * GetProcrustesAlignedSurface(unsigned int index)
Gets the shape at index in the SSM. Same as GetAlignedShape().
QAction * actionRigid
rigid Procrustes action
QPointer< milxQtModel > m_correspondences
Hedgehog display of the correspondences.
int GetNumberOfModes()
Returns the number of modes in the Statistical Shape Model according to the precision set...
void AddShape(vtkPolyData *shape)
Adds the shape to the SSM, once done adding shapes, call generateSSM() to get the SSM...
virtual void openModel(const QString filename)
Loads a model as an SSM (*.ssm) file. Alias same as LoadModel().
bool m_correspond
Hedgehog generated?
void contextMenuEvent(QContextMenuEvent *event)
The context menu setup member.
ShapeModelType::Pointer m_StandardSSM
The Statistical Shape Model.
QAction * actionSpecificity
specificity plot action
void createActions()
Create the actions for context menu etc.
void reset()
Reset the rendering, camera and windowing.
ShapeModelBaseType::Pointer m_SSM
The Statistical Shape Model Base Class.
QMenu * alignMenu
Plot menu for SSM alignment.
int GetNumberOfShapes()
Returns the number of shapes in the Statistical Shape Model. Assumes SSM has been generated (via gene...
QPointer< milxQtModel > m_meanModel
Model of the mean.
bool m_vector
Vectors generated?
QAction * actionPointIDs
point ids check action
void SetPrecision(float modePrecision)
Assigns the reduction factor of the modes, i.e the number of modes required to quantify modePrecision...
#define MILXQT_PLUGIN_EXPORT
Define Windows Plugin DLL importing.
QAction * actionValues
primary modes plot action
QAction * actionMean
mean action
bool m_loaded
Shapes loaded?
virtual bool isLoaded()
Is the model loaded successfully?
vtkPolyData * GetMeanShape()
Returns the mean shape of the Statistical Shape Model. Assumes SSM has been generated (via generateSS...
QAction * actionAffine
affine Procrustes action
QList< QPointer< milxQtModel > > m_alignedModels
Aligned Models in the SSM.
QList< int > m_caseIDs
A list of case IDs corresponding to the models in the SSM.
vtkPolyData * GetAlignedShape(unsigned int index)
Gets the shape at index in the SSM.
QAction * actionParameters
training shape parameters plot action
bool m_shapesModelled
Shapes were generated?
virtual void SaveModel(const QString filename)
Saves a model as an SSM (*.ssm) file. MILX-MSK like call.