a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
SlhaValuePlotLine.cpp
Go to the documentation of this file.
1/*
2 * SlhaValuePlotLine.cpp
3 *
4 * Created on: Mar 22, 2015
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2015 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#include "../../include/SSP/SlhaValuePlotLine.hpp"
15
16namespace LHPC
17{
18 namespace SLHA
19 {
20 std::string SlhaValuePlotLine::joinerColor( "black" );
22 '0',
23 3,
24 1,
25 "",
26 "-",
27 "",
28 "-",
29 "e" );
30
31 SlhaValuePlotLine::SlhaValuePlotLine( double const slhaValue,
32 double const columnCenterPosition,
33 double const columnLineWidth,
34 double const columnPairOffset,
35 double const labelJoinerWidth,
36 std::string const& labelString,
37 bool const labelLeftOfColumn,
38 SlhaValueLineColoring const* lineColoring ) :
39 slhaValue( slhaValue ),
40 leftEndHorizontalPosition( columnCenterPosition
41 - (0.5 * ( columnLineWidth
42 + columnPairOffset ) ) ),
43 rightEndHorizontalPosition( leftEndHorizontalPosition
44 + columnLineWidth),
45 labelVerticalPosition( slhaValue ),
46 labelHorizontalPosition( leftEndHorizontalPosition
47 - labelJoinerWidth ),
48 labelString( labelString ),
49 labelLeftOfColumn( labelLeftOfColumn ),
50 valueAbovePlotRange( false ),
51 lineColoring( lineColoring )
52 {
54 {
55 leftEndHorizontalPosition += columnPairOffset;
56 rightEndHorizontalPosition += columnPairOffset;
58 = ( rightEndHorizontalPosition + labelJoinerWidth );
59 }
60 }
61
63 SlhaValuePlotLine const& copySource ) :
64 slhaValue( copySource.slhaValue ),
65 leftEndHorizontalPosition( copySource.leftEndHorizontalPosition ),
66 rightEndHorizontalPosition( copySource.rightEndHorizontalPosition ),
67 labelVerticalPosition( copySource.labelVerticalPosition ),
68 labelHorizontalPosition( copySource.labelHorizontalPosition ),
69 labelString( copySource.labelString ),
70 labelLeftOfColumn( copySource.labelLeftOfColumn ),
71 valueAbovePlotRange( copySource.valueAbovePlotRange ),
72 lineColoring( copySource.lineColoring )
73 {
74 // This constructor is just an initialization list.
75 }
76
78 {
79 // The lineColoring pointer is not deleted by this object, as then copies
80 // of this object (and there is a lot of copying and deleting of old
81 // SlhaValuePlotLine objects in the course of std::list objects being
82 // copied during std::vector re-allocations) could not use the pointer.
83 }
84
85
86 // This writes input to have gnuplot print the line label correctly.
87 void SlhaValuePlotLine::writeLabel( std::ofstream& gnuplotCommandFile )
88 {
89 std::string gnuplotLabelString( "{" );
90 // This case only should be center-justified.
92 {
93 gnuplotLabelString.append( labelString );
94 }
95 else if( labelLeftOfColumn )
96 {
97 gnuplotLabelString.append( "{" );
98 gnuplotLabelString.append( labelString );
99 gnuplotLabelString.append( "}{\\phantom{" );
100 gnuplotLabelString.append( labelString );
101 gnuplotLabelString.append( "}}" );
102 }
103 else
104 {
105 gnuplotLabelString.append( "{\\phantom{" );
106 gnuplotLabelString.append( labelString );
107 gnuplotLabelString.append( "}{" );
108 gnuplotLabelString.append( labelString );
109 gnuplotLabelString.append( "}}" );
110 }
111 gnuplotLabelString.append( "}" );
112
113 gnuplotCommandFile
114 << "set label '" << gnuplotLabelString << "' at "
115 << labelHorizontalPosition << ", " << labelVerticalPosition << std::endl;
116 }
117
118 // This writes the line as a segment or series of segments defined as
119 // lines themselves in gnuplotDataFile, using gnuplotLineIndex to keep
120 // handles on the lines and their styles.
121 void SlhaValuePlotLine::writeLineData( int& gnuplotLineIndex,
122 std::ofstream& gnuplotDataFile,
123 std::ofstream& gnuplotCommandFile )
124 {
125 // The "joiner" from the label to the end of the line is a separate line.
127 {
128 SlhaValueLineColoring::AddLine( gnuplotLineIndex,
129 gnuplotDataFile,
130 gnuplotCommandFile,
134 slhaValue,
135 joinerColor );
136 }
137 else
138 {
139 SlhaValueLineColoring::AddLine( gnuplotLineIndex,
140 gnuplotDataFile,
141 gnuplotCommandFile,
143 slhaValue,
146 joinerColor );
147 }
148
150 {
151 lineColoring->writeLineData( gnuplotLineIndex,
152 gnuplotDataFile,
153 gnuplotCommandFile,
155 slhaValue,
157 }
158
159 }
160
161 } /* namespace SLHA */
162} /* namespace LHPC */
virtual void writeLineData(int &gnuplotLineIndex, std::ofstream &gnuplotDataFile, std::ofstream &gnuplotCommandFile, double const leftEndHorizontalPosition, double const lineVerticalPositon, double const rightEndHorizontalPosition) const =0
static void AddLine(int &gnuplotLineIndex, std::ofstream &gnuplotDataFile, std::ofstream &gnuplotCommandFile, double const leftEndHorizontalPosition, double const leftEndVerticalPosition, double const rightEndHorizontalPosition, double const rightEndVerticalPosition, std::string const &lineColor)
void writeLabel(std::ofstream &gnuplotCommandFile)
SlhaValueLineColoring const * lineColoring
SlhaValuePlotLine(double const slhaValue, double const columnCenterPosition, double const columnLineWidth, double const columnPairOffset, double const labelJoinerWidth, std::string const &labelString, bool const labelLeftOfColumn, SlhaValueLineColoring const *lineColoring)
void writeLineData(int &gnuplotLineIndex, std::ofstream &gnuplotDataFile, std::ofstream &gnuplotCommandFile)
static BOL::StringParser const overlargeValuePrinter