14#include "../../include/SSP/SlhaValuePlotter.hpp"
23 "LHPC_SlhaPlotter_gnuplot.input" );
35 generalControlsXml(
"" ),
36 columnDefinitionsXml(
"" ),
39 columnPairOffset( 10.0 ),
40 useAbsoluteValues( false ),
41 verticalAxisLabel(
"" ),
42 verticalAxisScaling( -1.0 ),
43 verticalAxisUpperRange( -1.0 ),
44 labelHeightFractionOfRange( -1.0 ),
45 horizontalAxisLabel(
"" ),
55 labelShuffleDistance( -1.0 ),
56 fullColumnWidth( -1.0 ),
57 lineColoringPointers()
79 throw std::runtime_error(
"Could not open "
81 +
" as valid XML file." );
87 for(
size_t deletionIndex( 0 );
117 "VerticalAxisScaling" ) )
124 "VerticalAxisUpperRange" ) )
137 "HorizontalAxisLabel" ) )
264 throw std::runtime_error(
"Could not parse <SpecificInput>." );
280 for( std::vector< std::list< SlhaValuePlotLine > >::iterator
285 for( std::list< SlhaValuePlotLine >::iterator
286 whichLine( whichColumn->begin() );
287 whichLine != whichColumn->end();
307 for( std::vector< std::list< SlhaValuePlotLine > >::iterator
316 std::vector< SlhaValuePlotLine* > leftLabels;
317 std::vector< SlhaValuePlotLine* > rightLabels;
318 for( std::list< SlhaValuePlotLine >::iterator
319 columnLine( whichColumn->begin() );
320 columnLine != whichColumn->end();
323 if( columnLine->hasLabelOnLeftOfColumn() )
325 leftLabels.push_back( &(*columnLine) );
329 rightLabels.push_back( &(*columnLine) );
350 if( !( gnuplotDataFile.is_open()
352 gnuplotCommandFile.is_open() ) )
354 throw std::runtime_error(
"Could not open "
358 +
" as temporary files!" );
362 <<
"set term epslatex color solid"
364 << std::endl <<
"set format x \"\""
367 << std::endl <<
"unset xtics"
368 << std::endl <<
"set ytics out"
371 int gnuplotLineIndex( 0 );
373 for(
int columnIndex(
columnSet.size() - 1);
377 for( std::list< SlhaValuePlotLine >::iterator
378 columnLine(
columnSet[ columnIndex ].begin() );
379 columnLine !=
columnSet[ columnIndex ].end();
382 columnLine->writeLineData( gnuplotLineIndex,
384 gnuplotCommandFile );
385 columnLine->writeLabel( gnuplotCommandFile );
389 gnuplotDataFile.close();
396 <<
"' index 0 notitle with lines ls 1";
397 for(
int lineIndex( 1 );
398 lineIndex < gnuplotLineIndex;
403 <<
"' index " << lineIndex
404 <<
" notitle with lines ls " << ( lineIndex + 1 );
406 gnuplotCommandFile << std::endl;
407 gnuplotCommandFile.close();
410 if( !(latexFile.is_open()) )
412 throw std::runtime_error(
"Could not open "
414 +
".tex as a temporary file!" );
417 <<
"\\documentclass{article}" << std::endl
418 <<
"\\usepackage{graphics}" << std::endl
419 <<
"\\newlength\\labelmover" << std::endl
420 <<
"\\begin{document}" << std::endl
421 <<
"\\pagestyle{empty}" << std::endl
422 <<
"\\begin{center}" << std::endl
424 <<
"\\end{center}" << std::endl
425 <<
"\\end{document}" << std::endl;
432 bool const shouldCleanUp )
434 int systemReturn( 0 );
457 systemReturn = system( (
moveCommand + plotFilename).c_str() );
460 if( systemReturn == -1 )
464 <<
"Call to \"system\" returned -1. No idea what to do with that.";
465 std::cout << std::endl;
476 if( xmlParser.
loadString( columnDefinitionXml ) )
478 columnSet.push_back( std::list< SlhaValuePlotLine >() );
490 throw std::runtime_error(
"Could not parse <ColumnDefinition>." );
500 double slhaValue( 0.0 );
501 std::string labelString(
"" );
502 bool labelLeftOfColumn(
true );
506 if( xmlParser.
loadString( lineDefinitionXml ) )
516 ( slhaValue < 0.0 ) )
518 slhaValue = -slhaValue;
532 labelLeftOfColumn = ( whichSide.compare(
"left" ) == 0 );
536 std::map< std::string, std::string >
const&
538 std::map< std::string, std::string >::const_iterator
539 attributeFinder( lineAttributes.find(
"DrawType" ) );
540 if( attributeFinder != lineAttributes.end() )
548 throw std::runtime_error(
549 "Unknown \"DrawType\" in <LineColor>." );
558 columnCenterPosition,
570 std::vector< SlhaValuePlotLine* >& labelSet )
574 if( labelSet.size() > 1 )
578 bool notYetFinishedShuffling(
true );
583 std::vector< SlhaValuePlotLine* >::iterator
584 lowerLine( labelSet.begin() );
585 std::vector< SlhaValuePlotLine* >::iterator upperLine( lowerLine );
587 while( notYetFinishedShuffling
589 ( remainingShuffles > 0 ) )
591 notYetFinishedShuffling =
false;
595 lowerLine = labelSet.begin();
598 if( (*lowerLine)->getLabelPosition() <
labelHeight )
600 notYetFinishedShuffling =
true;
605 upperLine = lowerLine;
609 while( upperLine < labelSet.end() )
611 if( ( (*upperLine)->getLabelPosition()
612 - (*lowerLine)->getLabelPosition() ) <
labelHeight )
618 notYetFinishedShuffling =
true;
628 labelAverage( 0.5 * ( (*upperLine)->getLabelPosition()
629 + (*lowerLine)->getLabelPosition() ) );
630 (*lowerLine)->setLabelPosition( labelAverage
632 (*upperLine)->setLabelPosition( labelAverage
646 notYetFinishedShuffling =
true;
std::map< std::string, std::string > const & getCurrentElementAttributes()
bool loadString(std::string const stringToParse)
bool currentElementNameMatches(std::string const &comparisonString) const
std::string getTrimmedCurrentElementContent() const
bool openRootElementOfFile(std::string const &fileName)
static void transformToLowercase(std::string &stringToTransform)
static double stringToDouble(std::string const &stringToInterpret)
double labelShuffleDistance
static double const flatBitWidth
void addColumnLine(std::string lineDefinitionXml, LHPC::SlhaSimplisticInterpreter &slhaParser)
std::string verticalAxisLabel
static double const labelSeparationShuffleFactor
std::string deleteCommand
double labelHeightFractionOfRange
static std::string const fullLatexBaseName
std::string generalControlsXml
SlhaValuePlotter(std::string const &xmlInputFilename)
std::vector< SlhaValueLineColoring * > lineColoringPointers
static std::string const gnuplotDataFileName
void executeCommands(std::string plotFilename, bool const shouldCleanUp)
void parseGeneralControls()
double verticalAxisUpperRange
static int const maximumLabelFloatingShuffles
static std::string const gnuplotTexBaseName
void prepareTemporaryInputFiles()
std::string gnuplotCommand
static double const automaticScaleFactor
std::string ps2epsCommand
std::string horizontalAxisLabel
static std::string const gnuplotCommandFileName
SlhaValueLineColoring * getNewLineColoring(std::string const &drawType, std::string const &xmlBody, LHPC::SlhaSimplisticInterpreter &slhaParser)
void addNewColumn(std::string columnDefinitionXml, LHPC::SlhaSimplisticInterpreter &slhaParser)
double verticalAxisScaling
void setUpVerticalRange(double const largestValueFound)
std::vector< std::list< SlhaValuePlotLine > > columnSet
void floatLabelsFromOneSide(std::vector< SlhaValuePlotLine * > &labelSet)
std::string columnDefinitionsXml
double getDouble(std::string blockNameAndIndices)