DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
main.cxx
Go to the documentation of this file.
1 // VTK Viewer
2 // Written 2012 Hal Canary <http://cs.unc.edu/~hal>
3 // Copyright 2012 University of North Carolina at Chapel Hill.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License"); you
6 // may not use this file except in compliance with the License. You
7 // may obtain a copy of the License at
8 //
9 // LICENSE.md in this repository or
10 // http://www.apache.org/licenses/LICENSE-2.0
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
15 // implied. See the License for the specific language governing
16 // permissions and limitations under the License.
17 
18 #include <QObject>
19 #include <QString>
20 #include <QApplication>
21 #include <QMainWindow>
22 #include <QAction>
23 #include <QShortcut>
24 
25 #include "VTKViewer.h"
26 
27 static void makeShortcut(
28  int key, QWidget & parent, QWidget & target, const char * slot) {
29  QObject::connect(
30  new QShortcut(QKeySequence(key), &parent),
31  SIGNAL(activated()), &target, slot);
32 }
33 
34 int main(int argc, char ** argv) {
35  if (argc == 1 || (argc==2 && (argv[1]==std::string("-h") || argv[1]==std::string("--help"))) )
36  {
37  std::cout
38  << "\nDescription: visualize vtk files.\n"
39  << "\nUseage: \n " << argv[0]
40  << " FILE [MORE FILES...]\n\n"
41  "Supported File Formats:\n"
42  " *.vtk - VTK Legacy File\n"
43  " *.vtp - VTK Polygonal Data File\n"
44  " *.ply - Stanford Polygon File\n"
45  " *.obj - Wavefront Object file\n"
46  " *.stl - Stereolithography File\n"
47  " *.pdb - Protein Data Bank File\n"
48  " *.vtu - VTK Unstructured Grid Data File\n"
49  "Controls:\n"
50  " 's' - surface\n"
51  " 'w' - wireframe\n"
52  " 'r' - reset and center camera\n"
53  " 'ctrl-q' - quit\n"
54  " 'ctrl-r' - toggle rotation\n"
55  " 'ctrl-s' - toggle stereo mode\n"
56  " 'ctrl-t' - change stereo type\n"
57  " 'ctrl-p' - screenshot\n\n"
58  "More Info:\n"
59  " https://github.com/HalCanary/vtkviewer\n\n";
60  return 0;
61  }
62 
63  QApplication app(argc, argv);
64  QMainWindow mw;
65  mw.setWindowTitle("VTK Viewer");
66  VTKViewer v;
67 
68  makeShortcut(Qt::CTRL + Qt::Key_Q, mw, mw, SLOT(close()));
69  makeShortcut(Qt::CTRL + Qt::Key_R, mw, v, SLOT(toggleRotate()));
70  makeShortcut(Qt::CTRL + Qt::Key_S, mw, v, SLOT(toggleStereo()));
71  makeShortcut(Qt::CTRL + Qt::Key_T, mw, v, SLOT(nextStereoType()));
72  makeShortcut(Qt::CTRL + Qt::Key_P, mw, v, SLOT(screenshot()));
73 
74  mw.setCentralWidget(&v);
75  for (int i = 1; i < argc; ++i)
76  {
77  v.add(argv[i]);
78  }
79  // mw.showMaximized();
80  mw.show();
81  return app.exec();
82 }
static void makeShortcut(int key, QWidget &parent, QWidget &target, const char *slot)
Definition: main.cxx:27
void add(vtkPolyData *polyData)
Definition: VTKViewer.cxx:255
int main(int argc, char **argv)
Definition: main.cxx:34