source: trunk/MagicSoft/Cosy/telesto.cc@ 8973

Last change on this file since 8973 was 8973, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 5.7 KB
Line 
1#include <TROOT.h>
2#include <TClass.h>
3#include <TSystem.h>
4#include <TGClient.h>
5#include <TApplication.h>
6#include <TObjectTable.h>
7
8#include "MAGIC.h"
9
10#include "MLog.h"
11#include "MLogManip.h"
12
13//#include "MEnv.h"
14#include "MArgs.h"
15#include "MArray.h"
16#include "MParContainer.h"
17//#include "MDirIter.h"
18
19#include "TPointGui.h"
20//#include "MStatusDisplay.h"
21
22//#include "MSequence.h"
23//#include "MJStar.h"
24
25using namespace std;
26
27static void StartUpMessage()
28{
29 gLog << all << endl;
30
31 // 1 2 3 4 5 6
32 // 123456789012345678901234567890123456789012345678901234567890
33 gLog << "========================================================" << endl;
34 gLog << " Telesto - COSY" << endl;
35 gLog << " Telesto - Telescope TPoint organizer" << endl;
36 gLog << " Compiled with ROOT v" << ROOT_RELEASE << " on <" << __DATE__ << ">" << endl;
37 gLog << "========================================================" << endl;
38 gLog << endl;
39}
40
41static void Usage()
42{
43 // 1 2 3 4 5 6 7 8
44 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
45 gLog << all << endl;
46 gLog << "Sorry the usage is:" << endl;
47 gLog << " telestop [file.txt|file.col [pointing.mod]]" << endl << endl;
48 gLog << " Arguments:" << endl;
49 gLog << " file.txt|file.col A collection of files or a file with tpoints" << endl;
50 gLog << " pointing.mod A pointing model to load at startup" << endl << endl;
51 gLog << " Root Options:" << endl;
52 gLog << " -b Batch mode (no graphical output to screen)" << endl<<endl;
53 gLog << " Options:" << endl;
54 gLog.Usage();
55// gLog << " --debug-env=0 Disable debugging setting resources <default>" << endl;
56// gLog << " --debug-env[=1] Display untouched resources after program execution" << endl;
57// gLog << " --debug-env=2 Display untouched resources after eventloop setup" << endl;
58// gLog << " --debug-env=3 Debug setting resources from resource file and command line" << endl;
59 gLog << " --debug-mem Debug memory usage" << endl << endl;
60// gLog << " --rc=Name:option Set or overwrite a resource of the resource file." << endl;
61 gLog << " (Note, that this option can be used multiple times." << endl;
62 gLog << endl;
63 gLog << " Output options:" << endl;
64// gLog << " -q Quit when job is finished" << endl;
65// gLog << " -f Force overwrite of existing files" << endl;
66 gLog << endl;
67 gLog << " --version, -V Show startup message with version number" << endl;
68 gLog << " -?, -h, --help This help" << endl << endl;
69 gLog << "Background:" << endl;
70 gLog << " Telesto is a moon of Saturn. It was discovered by Smith, Reitsema," << endl;
71 gLog << " Larson and Fountain in 1980 from ground-based observations, and was" << endl;
72 gLog << " provisionally designated S/1980 S 13." << endl;
73 gLog << " In 1983 it was officially named after Telesto of Greek mythology. It" << endl;
74 gLog << " is also designated as Saturn XIII or Tethys B." << endl;
75 gLog << " Telesto is co-orbital with Tethys, residing in Tethys' leading" << endl;
76 gLog << " Lagrangian point (L4). This relationship was first identified by" << endl;
77 gLog << " Seidelmann et al. The moon Calypso also resides in the other" << endl;
78 gLog << " (trailing) lagrangian point of Tethys, 60 deg in the other direction." << endl;
79 gLog << " The Cassini probe performed a distant flyby of Telesto on Oct. 11," << endl;
80 gLog << " 2005. The resulting images show that its surface is surprisingly" << endl;
81 gLog << " smooth, devoid of small impact craters." << endl << endl;
82}
83
84int main(int argc, char **argv)
85{
86 if (!MARS::CheckRootVer())
87 return 0xff;
88
89 MLog::RedirectErrorHandler(MLog::kColor);
90
91 //
92 // Evaluate arguments
93 //
94 MArgs arg(argc, argv, kTRUE);
95 gLog.Setup(arg);
96
97 StartUpMessage();
98
99 if (arg.HasOnly("-V") || arg.HasOnly("--version"))
100 return 0;
101
102 if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
103 {
104 Usage();
105 return 2;
106 }
107
108 const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
109
110 //
111 // check for the right usage of the program (number of arguments)
112 //
113 if (arg.GetNumArguments()>2)
114 {
115 gLog << warn << "WARNING - Wrong number of arguments..." << endl;
116 Usage();
117 return 2;
118 }
119
120 TString fname=arg.GetArgumentStr(0);
121 TString mod =arg.GetArgumentStr(1);
122
123 //
124 // check for the right usage of the program (number of options)
125 //
126 if (arg.GetNumOptions()>0)
127 {
128 gLog << warn << "WARNING - Unknown commandline options..." << endl;
129 arg.Print("options");
130 gLog << endl;
131 return 2;
132 }
133
134// MArray::Class()->IgnoreTObjectStreamer();
135// MParContainer::Class()->IgnoreTObjectStreamer();
136
137 TApplication app("telesto", &argc, argv);
138 if (!gClient || gROOT->IsBatch())
139 {
140 gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
141 return 1;
142 }
143
144 if (kDebugMem)
145 TObject::SetObjectStat(kTRUE);
146
147 TPointGui *gui = new TPointGui(fname, mod);
148 gui->SetExitLoopOnClose();
149
150 // Wait until the user decides to exit the application
151 app.Run(kFALSE);
152
153 if (TObject::GetObjectStat())
154 {
155 TObject::SetObjectStat(kFALSE);
156 gObjectTable->Print();
157 }
158
159 return 0;
160}
Note: See TracBrowser for help on using the repository browser.