#include #include #include #include "TROOT.h" #include "TFile.h" #include "TLine.h" #include "Jeep/JContainer.hh" #include "Jeep/JProperties.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * Auxiliary data structure for line. */ struct JLine { /** * Read line from input stream. * * \param in input stream * \param line line * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JLine& line) { return in >> line.x1 >> line.y1 >> line.x2 >> line.y2; } /** * Write line to output stream. * * \param out output stream * \param line line * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JLine& line) { return out << line.x1 << ' ' << line.y1 << ' ' << line.x2 << ' ' << line.y2; } double x1; double y1; double x2; double y2; }; /** * \file * Auxiliary program to create TLine. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JContainer< vector > JParameters_t; string outputFile; JParameters_t parameters; Color_t color = kBlack; Style_t style = kSolid; Width_t width = 2; int debug; try { JProperties properties; properties.insert(gmake_property(color)); properties.insert(gmake_property(style)); properties.insert(gmake_property(width)); JParser<> zap("Auxiliary program to create TLine."); zap['o'] = make_field(outputFile); zap['p'] = make_field(parameters, "x1 y1 x2 y2"); zap['@'] = make_field(properties, "line attributes") = JPARSER::initialised(); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } TFile out(outputFile.c_str(), "recreate"); for (size_t i = 0; i != parameters.size(); ++i) { TLine* p = new TLine(parameters[i].x1, parameters[i].y1, parameters[i].x2, parameters[i].y2); p->SetLineColor(color); p->SetLineStyle(style); p->SetLineWidth(width); out.WriteTObject(p); } out.Write(); out.Close(); }