00001
00002
00003
00004 #include <getopt.h>
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 #include <iostream>
00008
00009 #include <QApplication>
00010 #include "PSQt/GUIMain.h"
00011 #include "PSQt/GUIImageViewer.h"
00012 #include "PSQt/WdgDirTree.h"
00013 #include "PSQt/WdgFile.h"
00014 #include "PSQt/WdgImage.h"
00015 #include "PSQt/WdgColorTable.h"
00016 #include "PSQt/WdgGeoTree.h"
00017 #include "PSQt/WdgGeo.h"
00018 #include "PSQt/WdgPointPos.h"
00019 #include "PSQt/Frame.h"
00020 #include "PSQt/ThreadTimer.h"
00021 #include "PSQt/allinone.h"
00022 #include "PSQt/Logger.h"
00023 #include "PSQt/GUILogger.h"
00024 #include "PSQt/WdgColorBar.h"
00025 #include "PSQt/WdgRadHist.h"
00026 #include "PSQt/WdgSpecHist.h"
00027
00028
00029
00030 void usage(char* name) {
00031 std::cout << "Usage: " << name << " [-g <geo-fname>] [-i <image-array-fname>] [-L <logger-level>] [-h] [<test-number>]"
00032 << "\n -g <geo-fname> - (string) geometry file name"
00033 << "\n -i <image-array-fname> - (string) image n-d array text file name"
00034 << "\n -x <x-center-offset> - (unsigned) image center x-coordinate offset in pixels"
00035 << "\n -y <y-center-offset> - (unsigned) image center y-coordinate offset in pixels"
00036 << "\n -L <logger-level> - (string) verbosity level can be DEBUG, INFO, WARNING, CRITICAL, ERROR"
00037 << "\n -h - this help message"
00038 << '\n';
00039 }
00040
00041
00042 int main( int argc, char **argv )
00043 {
00044
00045 cout << "Command line:";
00046 for(int i = 0; i < argc; i++) cout << " " << argv[i]; cout << '\n';
00047
00048
00049 char *ivalue = NULL;
00050 char *gvalue = NULL;
00051 char *xvalue = NULL;
00052 char *yvalue = NULL;
00053 char *Lvalue = NULL;
00054 int c;
00055 extern char *optarg;
00056 extern int optind, optopt;
00057
00058 while ((c = getopt(argc, argv, ":g:i:x:y:L:h")) != -1)
00059 switch (c)
00060 {
00061 case 'g':
00062 gvalue = optarg;
00063 printf ("-g: gvalue = %s, (string) file name for geometry\n",gvalue);
00064 break;
00065 case 'i':
00066 ivalue = optarg;
00067 printf ("-i: ivalue = %s, (string) file name for image n-d array\n",ivalue);
00068 break;
00069 case 'x':
00070 xvalue = optarg;
00071 printf ("-x: xvalue = %s, (unsigned) image center x-coordinate offset in pixels\n",xvalue);
00072 break;
00073 case 'y':
00074 yvalue = optarg;
00075 printf ("-y: yvalue = %s, (unsigned) image center y-coordinate offset in pixels\n",yvalue);
00076 break;
00077 case 'L':
00078 Lvalue = optarg;
00079 printf ("-L: Lvalue = %s, (string) possible values: DEBUG, INFO, WARNING, CRITICAL, ERROR, NONE\n",Lvalue);
00080 break;
00081 case 'h':
00082
00083 usage(argv[0]);
00084 return EXIT_SUCCESS;
00085 case ':':
00086 printf ("(:) Option -%c requires an argument.\n", optopt);
00087 usage(argv[0]);
00088 return EXIT_FAILURE;
00089 case '?':
00090 printf ("(?): Option -%c is not recognized.\n", optopt);
00091 usage(argv[0]);
00092 return EXIT_FAILURE;
00093 default:
00094 printf ("default: You should not reach this point... Option \"-%c\" is not recognized.\n", optopt);
00095 abort ();
00096 }
00097
00098
00099
00100
00101 for (int index = optind; index < argc; index++)
00102 printf ("Non-option argument \"%s\"\n", argv[index]);
00103
00104
00105
00106
00107
00108 std::string gfname = (gvalue) ? gvalue : std::string();
00109 std::string ifname = (ivalue) ? ivalue : std::string();
00110 unsigned xcent = (xvalue) ? unsigned(atoi(xvalue)) : 2000;
00111 unsigned ycent = (yvalue) ? unsigned(atoi(yvalue)) : 2000;
00112 PSQt::LEVEL level = (Lvalue) ? PSQt::levelFromString(std::string(Lvalue)) : PSQt::INFO;
00113
00114 cout << "\nStart app with input parameters\n" << std::setw(31) << setfill('=') << '='
00115 << "\n geometry : " << gfname
00116 << "\n image array : " << ifname
00117 << "\n image center offset x : " << xcent
00118 << "\n image center offset y : " << ycent
00119 << "\n logger level : " << PSQt::strLevel(level)
00120 << '\n';
00121
00122
00123
00124 QApplication app( argc, argv );
00125
00126 const bool do_print = false;
00127 PSQt::ThreadTimer* t1 = new PSQt::ThreadTimer(0, 5, do_print); t1 -> start();
00128 PSQt::ThreadTimer* t2 = new PSQt::ThreadTimer(0, 60, do_print); t2 -> start();
00129
00130 if(argc==2) {
00131 if(atoi(argv[1])==1) { PSQt::GUIMain* w = new PSQt::GUIMain(0,PSQt::INFO); w->show(); }
00132 else if(atoi(argv[1])==2) { PSQt::MyWidget* w = new PSQt::MyWidget(); w->show(); }
00133 else if(atoi(argv[1])==3) { PSQt::WdgFile* w = new PSQt::WdgFile(); w->show(); }
00134 else if(atoi(argv[1])==4) { PSQt::WdgImage* w = new PSQt::WdgImage(0); w->show(); }
00135 else if(atoi(argv[1])==5) { PSQt::WdgColorTable* w = new PSQt::WdgColorTable(); w->show(); }
00136 else if(atoi(argv[1])==6) { PSQt::GUIImageViewer* w = new PSQt::GUIImageViewer(); w->show(); }
00137 else if(atoi(argv[1])==7) { PSQt::WdgDirTree* w = new PSQt::WdgDirTree(); w->show(); }
00138 else if(atoi(argv[1])==8) { PSQt::WdgGeoTree* w = new PSQt::WdgGeoTree(); w->show(); }
00139 else if(atoi(argv[1])==9) { PSQt::WdgGeo* w = new PSQt::WdgGeo(); w->show(); }
00140 else if(atoi(argv[1])==10){ PSQt::GUILogger* w = new PSQt::GUILogger(); w->show(); }
00141 else if(atoi(argv[1])==11){ PSQt::WdgPointPos* w = new PSQt::WdgPointPos(); w->show(); }
00142 else if(atoi(argv[1])==12){ PSQt::WdgColorBar* w = new PSQt::WdgColorBar(); w->show(); }
00143 else if(atoi(argv[1])==13){ PSQt::WdgRadHist* w = new PSQt::WdgRadHist(); w->show(); }
00144 else if(atoi(argv[1])==14){ PSQt::WdgSpecHist* w = new PSQt::WdgSpecHist(); w->show(); }
00145 else {cout << "Input argument \"" << argv[1] << "\" is not recognized...\n"; return 0;}
00146 }
00147 else {
00148 PSQt::GUIMain* w = new PSQt::GUIMain(0, level, gfname, ifname, xcent, ycent); w->show();
00149 }
00150
00151 return app.exec();
00152 }