Go to the documentation of this file.00001 #include <QApplication>
00002
00003 #include "DGVMainVTK.h"
00004
00006 void processArgs(int argcount, char *argvars[], QString &filename, int &interval, bool &verbose, bool &scale);
00007
00008 int main(int argc, char *argv[])
00009 {
00010 QApplication app(argc,argv);
00011 bool verboseMode = false, scaling = false;
00012 QString name;
00013
00014 cerr << ">| Surface Plot Animator" << endl;
00015 cerr << ">| Copyright Shekhar S. Chandra, 2008" << endl;
00016
00017
00019 int interval = 1;
00020 processArgs(argc,argv,name,interval,verboseMode,scaling);
00021
00022
00024 DGVMainVTK MainWindow;
00025
00027 MainWindow.show();
00028 qApp->processEvents();
00029 if(!MainWindow.loadFile(name))
00030 {
00031 cerr << ">| ERROR Loading File: " << name.toStdString() << endl;
00032 MainWindow.done();
00033 return app.exec();
00034 }
00035 DGVImageVTK *image = MainWindow.activeImage();
00036
00037 DGVSurfacePlotVTK *splot = new DGVSurfacePlotVTK(&MainWindow);
00038
00039 splot->setConsole(MainWindow.getConsole());
00040 qApp->processEvents();
00041 if(image->isVolume())
00042 {
00043 MainWindow.getConsole()->printWarning("Valid volume found, so animating surface plot.");
00044
00045 MainWindow.working();
00046
00048 DGVVolumePlotVTK *volume = image->getVolume();
00049
00050 splot->setName("Surface Animation");
00051 if(scaling)
00052 splot->autoScaleSurface(true);
00053 splot->animateFromSlices(&volume->data(),interval);
00054 MainWindow.displaySurfacePlot(splot);
00055 MainWindow.done();
00056 }
00057 else
00058 {
00059 MainWindow.getConsole()->printWarning("Not a volume, so not animating.");
00060
00061 MainWindow.working();
00062 splot->setName("Surface Plot");
00063 splot->SetInput(image->GetOutput());
00064 splot->generatePlot();
00065 splot->generateAxes();
00066 MainWindow.displaySurfacePlot(splot);
00067 MainWindow.done();
00068 }
00069
00070
00071 return app.exec();
00072 }
00073
00074
00075 void processArgs(int argcount, char *argvars[], QString &filename, int &interval, bool &verbose, bool &scale)
00076 {
00077 QString tmpStr;
00078
00079 if(argcount == 3)
00080 {
00081 filename = argvars[1];
00082 tmpStr = argvars[2];
00083 interval = tmpStr.toInt();
00084 tmpStr = "";
00085 }
00086 else if(argcount > 3)
00087 {
00088 filename = argvars[1];
00089 tmpStr = argvars[2];
00090 interval = tmpStr.toInt();
00091 tmpStr = "";
00092 for(int j = 3; j < argcount; j++)
00093 tmpStr += argvars[j];
00094 if(tmpStr.contains("--verbose",Qt::CaseInsensitive))
00095 verbose = true;
00096 if(tmpStr.contains("--scale",Qt::CaseInsensitive))
00097 scale = true;
00098 }
00099 else
00100 {
00101 printf(">| Usage: %s <Image> <Interval (ms)> [--verbose] [--scale]\n",argvars[0]);
00102 printf(">| Loads a 3D image stack and displays animated Surface plot at an\n");
00103 printf(">| Interval provided in milliseconds (ms).\n");
00104 printf(">| [--verbose] argument is optional and outputs all posible data.\n");
00105 printf(">| [--scale] argument is optional and enables scaling of the surface always.\n");
00106 exit(EXIT_FAILURE);
00107 }
00108 }