22 #include "ns3/assert.h"
42 Data(
const std::string& title);
62 bool generateOneOutputFile,
63 unsigned int dataFileDatasetIndex,
64 std::string &dataFileName)
const = 0;
70 virtual void PrintDataFile (std::ostream &os,
bool generateOneOutputFile)
const = 0;
76 virtual bool IsEmpty ()
const = 0;
82 m_extra (m_defaultExtra)
100 : m_data (original.m_data)
113 if (
this != &original)
155 Data2d(
const std::string& title);
159 bool generateOneOutputFile,
160 unsigned int dataFileDatasetIndex,
161 std::string &dataFileName)
const;
162 virtual void PrintDataFile (std::ostream &os,
bool generateOneOutputFile)
const;
168 m_style (m_defaultStyle),
169 m_errorBars (m_defaultErrorBars)
181 bool generateOneOutputFile,
182 unsigned int dataFileDatasetIndex,
183 std::string &dataFileName)
const
187 if (generateOneOutputFile)
193 os <<
"\"" << dataFileName <<
"\" index " << dataFileDatasetIndex;
197 os <<
" title \"" << m_title <<
"\"";
207 os <<
" with points";
210 os <<
" with xerrorbars";
213 os <<
" with yerrorbars";
216 os <<
" with xyerrorbars";
224 os <<
" with linespoints";
227 os <<
" with errorlines";
230 os <<
" with yerrorlines";
233 os <<
" with xyerrorlines";
241 os <<
" with impulses";
247 os <<
" with fsteps";
250 os <<
" with histeps";
255 os <<
" " << m_extra;
261 for (PointSet::const_iterator i = m_pointset.begin ();
262 i != m_pointset.end (); ++i)
269 switch (m_errorBars) {
271 os << i->x <<
" " << i->y << std::endl;
274 os << i->x <<
" " << i->y <<
" " << i->dx << std::endl;
277 os << i->x <<
" " << i->y <<
" " << i->dy << std::endl;
280 os << i->x <<
" " << i->y <<
" " << i->dx <<
" " << i->dy << std::endl;
287 if (generateOneOutputFile)
289 os <<
"e" << std::endl;
301 return (m_pointset.size () == 0);
333 reinterpret_cast<Data2d*
>(
m_data)->m_errorBars = errorBars;
347 reinterpret_cast<Data2d*
>(
m_data)->m_pointset.push_back (data);
354 reinterpret_cast<Data2d*>(
m_data)->m_errorBars ==
Y );
360 data.
dx = errorDelta;
361 data.
dy = errorDelta;
362 reinterpret_cast<Data2d*
>(
m_data)->m_pointset.push_back (data);
374 data.
dx = xErrorDelta;
375 data.
dy = yErrorDelta;
376 reinterpret_cast<Data2d*
>(
m_data)->m_pointset.push_back (data);
384 reinterpret_cast<Data2d*
>(
m_data)->m_pointset.push_back (data);
398 Function2d(
const std::string& title,
const std::string&
function);
402 bool generateOneOutputFile,
403 unsigned int dataFileDatasetIndex,
404 std::string &dataFileName)
const;
405 virtual void PrintDataFile (std::ostream &os,
bool generateOneOutputFile)
const;
411 m_function (function)
423 bool generateOneOutputFile,
424 unsigned int dataFileDatasetIndex,
425 std::string &dataFileName)
const
430 os <<
" title \"" << m_title <<
"\"";
433 os <<
" " << m_extra;
473 Data3d(
const std::string& title);
477 bool generateOneOutputFile,
478 unsigned int dataFileDatasetIndex,
479 std::string &dataFileName)
const;
480 virtual void PrintDataFile (std::ostream &os,
bool generateOneOutputFile)
const;
486 m_style (m_defaultStyle)
498 bool generateOneOutputFile,
499 unsigned int dataFileDatasetIndex,
500 std::string &dataFileName)
const
505 os <<
" " << m_style;
508 os <<
" title \"" << m_title <<
"\"";
511 os <<
" " << m_extra;
517 for (PointSet::const_iterator i = m_pointset.begin ();
518 i != m_pointset.end (); ++i)
525 os << i->x <<
" " << i->y <<
" " << i->z << std::endl;
527 os <<
"e" << std::endl;
533 return (m_pointset.size () == 0);
564 reinterpret_cast<Data3d*
>(
m_data)->m_pointset.push_back (data);
572 reinterpret_cast<Data3d*
>(
m_data)->m_pointset.push_back (data);
586 Function3d(
const std::string& title,
const std::string&
function);
590 bool generateOneOutputFile,
591 unsigned int dataFileDatasetIndex,
592 std::string &dataFileName)
const;
593 virtual void PrintDataFile (std::ostream &os,
bool generateOneOutputFile)
const;
599 m_function (function)
611 bool generateOneOutputFile,
612 unsigned int dataFileDatasetIndex,
613 std::string &dataFileName)
const
618 os <<
" title \"" << m_title <<
"\"";
621 os <<
" " << m_extra;
651 : m_outputFilename (outputFilename),
652 m_terminal ( DetectTerminal (outputFilename) ),
654 m_generateOneOutputFile (false),
655 m_dataFileDatasetIndex (0)
666 std::string::size_type dotpos = filename.rfind (
'.');
667 if (dotpos == std::string::npos)
return "";
669 if (filename.substr (dotpos) ==
".png") {
672 else if (filename.substr (dotpos) ==
".pdf") {
730 std::ostream &osData,
731 std::string dataFileName)
734 osControl <<
"set terminal " <<
m_terminal << std::endl;
740 osControl <<
"set title \"" <<
m_title <<
"\"" << std::endl;
743 osControl <<
"set xlabel \"" <<
m_xLegend <<
"\"" << std::endl;
746 osControl <<
"set ylabel \"" <<
m_yLegend <<
"\"" << std::endl;
749 osControl <<
m_extra << std::endl;
757 std::string command =
m_datasets.begin ()->m_data->GetCommand ();
759 for (Datasets::const_iterator i =
m_datasets.begin () + 1;
763 "Cannot mix 'plot' and 'splot' GnuplotDatasets.");
766 osControl << command <<
" ";
774 isDataEmpty = i->m_data->IsEmpty ();
779 i->m_data->PrintExpression (osControl,
793 osControl << std::endl;
812 : m_outputFilename (outputFilename),
813 m_terminal (
Gnuplot::DetectTerminal (outputFilename) )
833 throw(std::range_error (
"Gnuplot id is out of range"));
845 os <<
"set terminal " <<
m_terminal << std::endl;
850 for (Plots::iterator i =
m_plots.begin (); i !=
m_plots.end (); ++i)
852 i->GenerateOutput (os);
858 std::string dataFileName)
864 osControl <<
"set terminal " <<
m_terminal << std::endl;
869 for (Plots::iterator i =
m_plots.begin (); i !=
m_plots.end (); ++i)
871 i->GenerateOutput (osControl, osData, dataFileName);