20 #include <QApplication>    21 #include <QMainWindow>    28     int key, QWidget & parent, QWidget & target, 
const char * slot) {
    30       new QShortcut(QKeySequence(key), &parent),
    31       SIGNAL(activated()), &target, slot);
    34 int main(
int argc, 
char ** argv) {
    35   if (argc == 1 || (argc==2 && (argv[1]==std::string(
"-h") || argv[1]==std::string(
"--help"))) )
    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"    52       "  'r' - reset and center camera\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"    59       "  https://github.com/HalCanary/vtkviewer\n\n";
    63   QApplication app(argc, argv);
    65   mw.setWindowTitle(
"VTK Viewer");
    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()));
    74   mw.setCentralWidget(&v);
    75   for (
int i = 1; i < argc; ++i)
 static void makeShortcut(int key, QWidget &parent, QWidget &target, const char *slot)
 
void add(vtkPolyData *polyData)
 
int main(int argc, char **argv)