Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLine.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <vector>
4
5#include "TROOT.h"
6#include "TFile.h"
7#include "TLine.h"
8
9#include "Jeep/JContainer.hh"
10#include "Jeep/JProperties.hh"
11#include "Jeep/JParser.hh"
12#include "Jeep/JMessage.hh"
13
14
15/**
16 * Auxiliary data structure for line.
17 */
18struct JLine {
19
20 /**
21 * Read line from input stream.
22 *
23 * \param in input stream
24 * \param line line
25 * \return input stream
26 */
27 friend inline std::istream& operator>>(std::istream& in, JLine& line)
28 {
29 return in >> line.x1 >> line.y1 >> line.x2 >> line.y2;
30 }
31
32 /**
33 * Write line to output stream.
34 *
35 * \param out output stream
36 * \param line line
37 * \return output stream
38 */
39 friend inline std::ostream& operator<<(std::ostream& out, const JLine& line)
40 {
41 return out << line.x1 << ' ' << line.y1 << ' ' << line.x2 << ' ' << line.y2;
42 }
43
44 double x1;
45 double y1;
46 double x2;
47 double y2;
48};
49
50
51/**
52 * \file
53 * Auxiliary program to create TLine.
54 * \author mdejong
55 */
56int main(int argc, char **argv)
57{
58 using namespace std;
59 using namespace JPP;
60
61 typedef JContainer< vector<JLine> > JParameters_t;
62
63 string outputFile;
64 JParameters_t parameters;
65 Color_t color = kBlack;
66 Style_t style = kSolid;
67 Width_t width = 2;
68 int debug;
69
70 try {
71
72 JProperties properties;
73
74 properties.insert(gmake_property(color));
75 properties.insert(gmake_property(style));
76 properties.insert(gmake_property(width));
77
78 JParser<> zap("Auxiliary program to create TLine.");
79
80 zap['o'] = make_field(outputFile);
81 zap['p'] = make_field(parameters, "x1 y1 x2 y2");
82 zap['@'] = make_field(properties, "line attributes") = JPARSER::initialised();
83 zap['d'] = make_field(debug) = 1;
84
85 zap(argc, argv);
86 }
87 catch(const exception &error) {
88 FATAL(error.what() << endl);
89 }
90
91
92 TFile out(outputFile.c_str(), "recreate");
93
94 for (size_t i = 0; i != parameters.size(); ++i) {
95
96 TLine* p = new TLine(parameters[i].x1, parameters[i].y1, parameters[i].x2, parameters[i].y2);
97
98 p->SetLineColor(color);
99 p->SetLineStyle(style);
100 p->SetLineWidth(width);
101
102 out.WriteTObject(p);
103 }
104
105 out.Write();
106 out.Close();
107}
Container I/O.
string outputFile
int main(int argc, char **argv)
Definition JLine.cc:56
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition JContainer.hh:42
Auxiliary data structure for line.
Definition JLine.cc:18
friend std::istream & operator>>(std::istream &in, JLine &line)
Read line from input stream.
Definition JLine.cc:27
double y2
Definition JLine.cc:47
friend std::ostream & operator<<(std::ostream &out, const JLine &line)
Write line to output stream.
Definition JLine.cc:39
double x2
Definition JLine.cc:46
double y1
Definition JLine.cc:45
double x1
Definition JLine.cc:44
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68