1 | #include <TROOT.h>
|
---|
2 | #include <TClass.h>
|
---|
3 | #include <TGClient.h>
|
---|
4 | #include <TApplication.h>
|
---|
5 |
|
---|
6 | #include "MLog.h"
|
---|
7 | #include "MLogManip.h"
|
---|
8 |
|
---|
9 | #include "MArgs.h"
|
---|
10 |
|
---|
11 | #include "MStatusDisplay.h"
|
---|
12 |
|
---|
13 | using namespace std;
|
---|
14 |
|
---|
15 | static void StartUpMessage()
|
---|
16 | {
|
---|
17 | // 1 2 3 4 5
|
---|
18 | // 12345678901234567890123456789012345678901234567890
|
---|
19 | gLog << endl;
|
---|
20 | gLog << "showplot --- Mars V" << MARSVER << " compiled on <" << __DATE__ << "> using ROOT v" << ROOTVER << endl;
|
---|
21 | gLog << endl;
|
---|
22 | }
|
---|
23 |
|
---|
24 | static void Usage()
|
---|
25 | {
|
---|
26 | // 1 2 3 4 5 6 7 8
|
---|
27 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
---|
28 | gLog << all << endl;
|
---|
29 | gLog << "Sorry the usage is:" << endl;
|
---|
30 | gLog << " showplot [options] filename" << endl << endl;
|
---|
31 | gLog << " Arguments:" << endl;
|
---|
32 | gLog << " filename Input file containing an MStatusArray" << endl << endl;
|
---|
33 | gLog << " Root Options:" << endl;
|
---|
34 | gLog << " -b Batch mode (no graphical output to screen)" << endl<<endl;
|
---|
35 | gLog << " Options: "<< endl;
|
---|
36 | gLog.Usage();
|
---|
37 | gLog << " -q Quit when job is finished" << endl;
|
---|
38 | gLog << endl;
|
---|
39 | gLog << " Output Options: "<< endl;
|
---|
40 | gLog << " --save-as-ps[=filename] Save plots as postscript" << endl;
|
---|
41 | gLog << " --save-as-gif[=filename] Save plots as gif files" << endl;
|
---|
42 | gLog << " --save-as-C[=filename] Save plots as root scripts" << endl;
|
---|
43 | gLog << " --tab=num Save only tab number num" << endl << endl;
|
---|
44 | gLog << "Description:" << endl;
|
---|
45 | gLog << " Use showplot to display a MStatusArray in an MStatusDisplay." << endl;
|
---|
46 | gLog << " MStatusArrays are typically written by programs showing data" << endl;
|
---|
47 | gLog << " check plots, like callisto." << endl;
|
---|
48 | gLog << endl;
|
---|
49 | }
|
---|
50 |
|
---|
51 | int main(int argc, char **argv)
|
---|
52 | {
|
---|
53 | StartUpMessage();
|
---|
54 |
|
---|
55 | //
|
---|
56 | // Evaluate arguments
|
---|
57 | //
|
---|
58 | MArgs arg(argc, argv);
|
---|
59 |
|
---|
60 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
---|
61 | {
|
---|
62 | Usage();
|
---|
63 | return -1;
|
---|
64 | }
|
---|
65 |
|
---|
66 | gLog.Setup(arg);
|
---|
67 |
|
---|
68 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
---|
69 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
---|
70 |
|
---|
71 | const Int_t kTab = arg.GetIntAndRemove("--tab=", -1);
|
---|
72 |
|
---|
73 | const Bool_t kSaveAsPs = arg.HasOnlyAndRemove("--save-as-ps") || arg.Has("--save-as-ps=");
|
---|
74 | const Bool_t kSaveAsGif = arg.HasOnlyAndRemove("--save-as-gif") || arg.Has("--save-as-gif=");
|
---|
75 | const Bool_t kSaveAsC = arg.HasOnlyAndRemove("--save-as-C") || arg.Has("--save-as-C=");
|
---|
76 |
|
---|
77 | TString kNamePs = arg.GetStringAndRemove("--save-as-ps=");
|
---|
78 | TString kNameGif = arg.GetStringAndRemove("--save-as-gif=");
|
---|
79 | TString kNameC = arg.GetStringAndRemove("--save-as-C=");
|
---|
80 |
|
---|
81 |
|
---|
82 | //
|
---|
83 | // check for the right usage of the program
|
---|
84 | //
|
---|
85 | if (arg.GetNumArguments()!=1)
|
---|
86 | {
|
---|
87 | Usage();
|
---|
88 | return -1;
|
---|
89 | }
|
---|
90 |
|
---|
91 | TApplication app("Callisto", &argc, argv);
|
---|
92 | if (gROOT->IsBatch() || !gClient)
|
---|
93 | {
|
---|
94 | gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
---|
95 | return 1;
|
---|
96 | }
|
---|
97 |
|
---|
98 | //
|
---|
99 | // Process filenames
|
---|
100 | //
|
---|
101 | const TString kInput = arg.GetArgumentStr(0);
|
---|
102 |
|
---|
103 | if (kNamePs.IsNull() && kSaveAsPs)
|
---|
104 | kNamePs = kInput;
|
---|
105 | if (kNameGif.IsNull() && kSaveAsGif)
|
---|
106 | kNameGif = kInput;
|
---|
107 | if (kNameC.IsNull() && kSaveAsC)
|
---|
108 | kNameC = kInput;
|
---|
109 |
|
---|
110 | //
|
---|
111 | // Update frequency by default = 1Hz
|
---|
112 | //
|
---|
113 | MStatusDisplay *d = new MStatusDisplay;
|
---|
114 |
|
---|
115 | // From now on each 'Exit' means: Terminate the application
|
---|
116 | d->SetTitle(kInput);
|
---|
117 | d->Open(kInput);
|
---|
118 |
|
---|
119 | if (kSaveAsPs)
|
---|
120 | d->SaveAsPS(kTab, kNamePs);
|
---|
121 | if (kSaveAsGif)
|
---|
122 | d->SaveAsGIF(kTab, kNameGif);
|
---|
123 | if (kSaveAsC)
|
---|
124 | d->SaveAsC(kTab, kNameC);
|
---|
125 |
|
---|
126 | if (kBatch || kQuit)
|
---|
127 | {
|
---|
128 | delete d;
|
---|
129 | return 0;
|
---|
130 | }
|
---|
131 |
|
---|
132 | // From now on each 'Close' means: Terminate the application
|
---|
133 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
---|
134 |
|
---|
135 | // Wait until the user decides to exit the application
|
---|
136 | app.Run(kFALSE);
|
---|
137 | return 0;
|
---|
138 | }
|
---|