SMILX  1.01
milxModelViewer.cpp
1 /*=========================================================================
2 Program: SMILI
3 Module: milxModelViewer.cxx
4 Author: Shekhar Chandra
5 Language: C++
6 Created: 15 August 2012
7 
8 Copyright: (c) 2012 CSIRO, Australia.
9 
10 This software is protected by international copyright laws.
11 Any unauthorised copying, distribution or reverse engineering is prohibited.
12 
13 Licence:
14 All rights in this Software are reserved to CSIRO. You are only permitted
15 to have this Software in your possession and to make use of it if you have
16 agreed to a Software License with CSIRO.
17 
18 BioMedIA Lab: http://www.ict.csiro.au/BioMedIA/
19 =========================================================================*/
20 //Qt
21 #include <QApplication>
22 #include <QMainWindow>
23 /*=========================================================================
24  The Software is copyright (c) Commonwealth Scientific and Industrial Research Organisation (CSIRO)
25  ABN 41 687 119 230.
26  All rights reserved.
27 
28  Licensed under the CSIRO BSD 3-Clause License
29  You may not use this file except in compliance with the License.
30  You may obtain a copy of the License in the file LICENSE.md or at
31 
32  https://stash.csiro.au/projects/SMILI/repos/smili/browse/license.txt
33 
34  Unless required by applicable law or agreed to in writing, software
35  distributed under the License is distributed on an "AS IS" BASIS,
36  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37  See the License for the specific language governing permissions and
38  limitations under the License.
39 =========================================================================*/
40 #include "milxQtFile.h"
41 #include "milxQtModel.h"
42 
43 int main(int argc, char *argv[])
44 {
45  QApplication app(argc,argv);
46  QMainWindow mainWindow;
47 
48  QPixmap icon(":resources/smilx_icon.png");
49  app.setWindowIcon(QIcon(icon));
50 
51  if (argc < 2)
52  {
53  cerr << "milxModelViewer Application:" << endl;
54  cerr << "For quick and fast display of model/surface/polydata files." << endl;
55  cerr << "View configuration always matches sMILX settings wherever possible." << endl;
56  cerr << "Usage:" << endl;
57  cerr << "<Model Filename> " << endl;
58  return EXIT_FAILURE;
59  }
60 
61  std::string inputSurfaceFilename = argv[1];
62 
63  //Load the vertex table from CSV file
64  milxQtModel *model = new milxQtModel(&mainWindow); //app takes ownership so need to be on stack, not heap
65  milxQtFile *reader = new milxQtFile(&mainWindow);
66  bool success = reader->openModel(inputSurfaceFilename.c_str(), model);
67 
68  if(!success)
69  {
70  cerr << "Error opening model file." << endl;
71  return EXIT_FAILURE;
72  }
73 
74  model->generateModel();
75 
76  //Setup size
77  QSize desktopSize = qApp->desktop()->availableGeometry().size();
78  int newWidth = 2.0*desktopSize.width()/3.0 + 0.5;
79  int newHeight = 4.0*desktopSize.height()/5.0 + 0.5;
80  int xOffset = (desktopSize.width()-newWidth)/2.0;
81  int yOffset = (desktopSize.height()-newHeight)/2.0;
82  mainWindow.resize( QSize(newWidth, newHeight) );
83  mainWindow.move( QPoint(xOffset, yOffset) );
84 
85  //Setup view to match sMILX
86  QSettings settings("Shekhar Chandra", "milxQt");
87  int defaultViewMode = 2; //axial
88  int defaultOrientationTypeMode = 0; //radiological
89  model->setView(settings.value("defaultView", defaultViewMode).toInt());
90  model->setDefaultOrientation(settings.value("defaultOrientationType", defaultOrientationTypeMode).toInt());
91 
92  //Setup menu
93  QMenuBar *menuBar = new QMenuBar(&mainWindow);
94  //File
95  QMenu *menuFile = menuBar->addMenu("File");
96  model->createMenu(menuFile);
97  QAction *actionExit = menuFile->addAction("Exit");
98  QObject::connect(actionExit, SIGNAL(activated()), &mainWindow, SLOT(close()));
99  mainWindow.setMenuBar(menuBar);
100 
101  model->colourMapToJet();
102 
103  mainWindow.setWindowTitle("milxModelViewer");
104  mainWindow.setCentralWidget(model);
105  mainWindow.show();
106 
107  return app.exec();
108 }
virtual void createMenu(QMenu *menu)
Create the menu for the data in this object. Used for context menu and file menus.
bool openModel(const QString filename, vtkPolyData *data)
Opens a model file, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *...
Definition: milxQtFile.cpp:752
This class represents the MILX Qt File I/O object using VTK/ITK/Qt.
Definition: milxQtFile.h:60
This class represents the MILX Qt Model/Mesh Display object using VTK.
Definition: milxQtModel.h:115
void setDefaultOrientation(int orientMode)
Change orientation mode to one of the supported standards. Default: Radiological. ...
void generateModel(float red=defaultColour, float green=defaultColour, float blue=defaultColour)
Generates the model so that its ready for display. It requires that data has been set or assigned alr...
void setView(int viewMode)
Change view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
int main(int argc, char *argv[])
virtual void colourMapToJet(double minRange=0.0, double maxRange=0.0)
Change the colour map to Jet.