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