Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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/JProperties.hh"
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * Auxiliary data structure for line.
15  */
16 struct JText {
17 
18  /**
19  * Read text from input stream.
20  *
21  * \param in input stream
22  * \param text text
23  * \return input stream
24  */
25  friend inline std::istream& operator>>(std::istream& in, JText& text)
26  {
27  in >> text.x1 >> text.y1;
28 
29  return getline(in, text.text);
30  }
31 
32  /**
33  * Write text to output stream.
34  *
35  * \param out output stream
36  * \param text text
37  * \return output stream
38  */
39  friend inline std::ostream& operator<<(std::ostream& out, const JText& text)
40  {
41  return out << text.x1 << ' ' << text.y1 << ' ' << text.text;
42  }
43 
44  double x1;
45  double y1;
46  std::string text;
47 };
48 
49 
50 /**
51  * \file
52  * Auxiliary program to create TText.
53  * \author mdejong
54  */
55 int main(int argc, char **argv)
56 {
57  using namespace std;
58 
59  string outputFile;
61  Short_t align = 22;
62  Float_t angle = 0.0;
63  Color_t color = kBlack;
64  Font_t font = 43;
65  Float_t size = 40;
66  int debug;
67 
68  try {
69 
70  JProperties properties;
71 
72  properties.insert(gmake_property(align));
73  properties.insert(gmake_property(angle));
74  properties.insert(gmake_property(color));
75  properties.insert(gmake_property(font));
76  properties.insert(gmake_property(size));
77 
78  JParser<> zap("Auxiliary program to create TText.");
79 
80  zap['o'] = make_field(outputFile);
81  zap['p'] = make_field(parameters, "x1 y1 text");
82  zap['@'] = make_field(properties, "text 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  TText* p = new TText(parameters.x1, parameters.y1, parameters.text.c_str());
95 
96  p->SetTextAlign(align);
97  p->SetTextAngle(angle);
98  p->SetTextColor(color);
99  p->SetTextFont (font);
100  p->SetTextSize (size);
101 
102  out.WriteTObject(p);
103 
104  out.Write();
105  out.Close();
106 }
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
double y1
Definition: JText.cc:45
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
Definition: JProperties.hh:496
Auxiliary data structure for line.
Definition: JText.cc:16
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
Utility class to parse parameter values.
friend std::istream & operator>>(std::istream &in, JText &text)
Read text from input stream.
Definition: JText.cc:25
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
std::string text
Definition: JText.cc:46
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
double x1
Definition: JText.cc:44
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
friend std::ostream & operator<<(std::ostream &out, const JText &text)
Write text to output stream.
Definition: JText.cc:39
int debug
debug level