11#include "ns3/assert.h"
40 Data(
const std::string& title);
89 m_extra(m_defaultExtra)
174 Data2d(
const std::string& title);
187 m_style(m_defaultStyle),
188 m_errorBars(m_defaultErrorBars)
215 if (!m_title.empty())
217 os <<
" title \"" << m_title <<
"\"";
229 os <<
" with points";
232 os <<
" with xerrorbars";
235 os <<
" with yerrorbars";
238 os <<
" with xyerrorbars";
246 os <<
" with linespoints";
249 os <<
" with errorlines";
252 os <<
" with yerrorlines";
255 os <<
" with xyerrorlines";
263 os <<
" with impulses";
269 os <<
" with fsteps";
272 os <<
" with histeps";
275 os <<
" with filledcurve";
279 if (!m_extra.empty())
281 os <<
" " << m_extra;
288 for (
auto i = m_pointset.begin();
i != m_pointset.end(); ++
i)
299 os <<
i->x <<
" " <<
i->y << std::endl;
302 os <<
i->x <<
" " <<
i->y <<
" " <<
i->dx << std::endl;
305 os <<
i->x <<
" " <<
i->y <<
" " <<
i->dy << std::endl;
308 os <<
i->x <<
" " <<
i->y <<
" " <<
i->dx <<
" " <<
i->dy << std::endl;
317 os <<
"e" << std::endl;
329 return m_pointset.empty();
469 if (!m_title.empty())
471 os <<
" title \"" << m_title <<
"\"";
474 if (!m_extra.empty())
476 os <<
" " << m_extra;
523 Data3d(
const std::string& title);
536 m_style(m_defaultStyle)
554 if (!m_style.empty())
556 os <<
" " << m_style;
559 if (!m_title.empty())
561 os <<
" title \"" << m_title <<
"\"";
564 if (!m_extra.empty())
566 os <<
" " << m_extra;
573 for (
auto i = m_pointset.begin();
i != m_pointset.end(); ++
i)
581 os <<
i->x <<
" " <<
i->y <<
" " <<
i->z << std::endl;
583 os <<
"e" << std::endl;
589 return m_pointset.empty();
682 if (!m_title.empty())
684 os <<
" title \"" << m_title <<
"\"";
687 if (!m_extra.empty())
689 os <<
" " << m_extra;
723 m_generateOneOutputFile(
false),
724 m_dataFileDatasetIndex(0)
738 if (
dotpos == std::string::npos)
850 "Cannot mix 'plot' and 'splot' GnuplotDatasets.");
921 throw(std::range_error(
"Gnuplot id is out of range"));
937 os <<
"set terminal " <<
m_terminal << std::endl;
void AddEmptyLine()
Add an empty line in the data output sequence.
static void SetDefaultStyle(Style style)
Change default style for all newly created objects.
static Style m_defaultStyle
default plot style
ErrorBars
Whether errorbars should be used for this dataset.
static void SetDefaultErrorBars(ErrorBars errorBars)
Change default errorbars style for all newly created objects.
void SetErrorBars(ErrorBars errorBars)
static ErrorBars m_defaultErrorBars
default error bars type
std::vector< Point > PointSet
The set of points in the dataset.
void SetStyle(Style style)
void Add(double x, double y)
Style
The plotting style to use for this dataset.
Gnuplot2dDataset(const std::string &title="Untitled")
void SetFunction(const std::string &function)
Gnuplot2dFunction(const std::string &title="Untitled", const std::string &function="")
void AddEmptyLine()
Add an empty line in the data output sequence.
Gnuplot3dDataset(const std::string &title="Untitled")
std::vector< Point > PointSet
The set of points in the dataset.
void Add(double x, double y, double z)
static void SetDefaultStyle(const std::string &style)
Change default style for all newly created objects.
void SetStyle(const std::string &style)
static std::string m_defaultStyle
default plot style
Gnuplot3dFunction(const std::string &title="Untitled", const std::string &function="")
void SetFunction(const std::string &function)
std::string m_outputFilename
Output file name.
GnuplotCollection(const std::string &outputFilename)
void AddPlot(const Gnuplot &plot)
void SetTerminal(const std::string &terminal)
Gnuplot & GetPlot(unsigned int id)
Return a pointer to one of the added plots.
std::string m_terminal
Gnuplot "terminal" to use.
Plots m_plots
Plots in the collection.
void GenerateOutput(std::ostream &os)
Abstract class to store a plot line to be used by ns3::Gnuplot.
GnuplotDataset(const GnuplotDataset &original)
Reference-counting copy constructor.
static std::string m_defaultExtra
Extra gnuplot parameters set on every newly created dataset.
static void SetDefaultExtra(const std::string &extra)
Change extra formatting style parameters for newly created objects.
GnuplotDataset & operator=(const GnuplotDataset &original)
Reference-counting assignment operator.
void SetExtra(const std::string &extra)
Add extra formatting parameters to this dataset.
Data * m_data
Reference counted data object.
void SetTitle(const std::string &title)
Change line title.
~GnuplotDataset()
Reference-counting destructor.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
std::string m_yLegend
Y axis legend.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
std::string m_terminal
Gnuplot "terminal" to use.
std::string m_extra
extra parameters for the plot
unsigned int m_dataFileDatasetIndex
Data set index to plot.
void AppendExtra(const std::string &extra)
Datasets m_datasets
Data sets.
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
std::string m_title
Plot title.
void SetDataFileDatasetIndex(unsigned int index)
Sets the current data stream index in the data file.
std::string m_xLegend
X axis legend.
std::string m_outputFilename
Output file name.
Gnuplot(const std::string &outputFilename="", const std::string &title="")
void SetExtra(const std::string &extra)
void SetTitle(const std::string &title)
void SetOutputFilename(const std::string &outputFilename)
bool m_generateOneOutputFile
true if only one plot will be generated
static std::string DetectTerminal(const std::string &filename)
Crude attempt to auto-detect the correct terminal setting by inspecting the filename's extension.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure storing the data to for a 2D plot.
Style m_style
The plotting style to use for this dataset.
void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const override
Print the inline data file contents trailing the plot command.
void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const override
Prints the plot description used as argument to (s)plot.
PointSet m_pointset
The set of points in this data set.
bool IsEmpty() const override
Checks to see if this GnuplotDataset is empty.
Data2d(const std::string &title)
Initializes with the values from m_defaultStyle and m_defaultErrorBars.
std::string GetCommand() const override
Returns the plot type ("plot" or "splot").
ErrorBars m_errorBars
Whether errorbars should be used for this dataset.
bool empty
the point is empty
Structure storing the function to be used for a 2D plot.
std::string GetCommand() const override
Returns the plot type ("plot" or "splot").
void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const override
Print the inline data file contents trailing the plot command.
Function2d(const std::string &title, const std::string &function)
Initializes with the function and title.
void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const override
Prints the plot description used as argument to (s)plot.
std::string m_function
Function to use.
bool IsEmpty() const override
Checks to see if this GnuplotDataset is empty.
Structure storing the data for a 3D plot.
std::string GetCommand() const override
Returns the plot type ("plot" or "splot").
bool IsEmpty() const override
Checks to see if this GnuplotDataset is empty.
void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const override
Prints the plot description used as argument to (s)plot.
void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const override
Print the inline data file contents trailing the plot command.
std::string m_style
The plotting style to use for this dataset.
PointSet m_pointset
The set of points in this data set.
Data3d(const std::string &title)
Initializes with value from m_defaultStyle.
bool empty
the point is empty
Structure storing the function to be used for a 3D plot.
bool IsEmpty() const override
Checks to see if this GnuplotDataset is empty.
std::string m_function
Function to use.
void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const override
Prints the plot description used as argument to (s)plot.
Function3d(const std::string &title, const std::string &function)
Initializes with the function and title.
void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const override
Print the inline data file contents trailing the plot command.
std::string GetCommand() const override
Returns the plot type ("plot" or "splot").
Structure storing the data to plot.
unsigned int m_references
ref/unref counter for garbage collection
std::string m_extra
Extra parameters for the plot.
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const =0
Prints the plot description used as argument to (s)plot.
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const =0
Print the inline data file contents trailing the plot command.
virtual bool IsEmpty() const =0
Checks to see if this GnuplotDataset is empty.
Data(const std::string &title)
Initializes the reference counter to 1 and sets m_title and m_extra.
std::string m_title
Dataset title.
virtual std::string GetCommand() const =0
Returns the plot type ("plot" or "splot").