use contrib gnuplot code
This commit is contained in:
@@ -1,112 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "gnuplot.h"
|
||||
#include <ostream>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
GnuplotDataset::GnuplotDataset (std::string title)
|
||||
: m_title (title),
|
||||
m_style (LINES)
|
||||
{}
|
||||
void
|
||||
GnuplotDataset::SetStyle (enum Style style)
|
||||
{
|
||||
m_style = style;
|
||||
}
|
||||
void
|
||||
GnuplotDataset::Add (double x, double y)
|
||||
{
|
||||
m_dataset.push_back (std::make_pair (x,y));
|
||||
}
|
||||
|
||||
Gnuplot::Gnuplot (std::string pngFilename)
|
||||
: m_pngFilename (pngFilename)
|
||||
{}
|
||||
|
||||
Gnuplot::~Gnuplot ()
|
||||
{
|
||||
for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end (); i++)
|
||||
{
|
||||
delete *i;
|
||||
}
|
||||
m_datasets.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
Gnuplot::AddDataset (const GnuplotDataset &dataset)
|
||||
{
|
||||
m_datasets.push_back (new GnuplotDataset (dataset));
|
||||
}
|
||||
|
||||
void
|
||||
Gnuplot::GenerateOutput (std::ostream &os)
|
||||
{
|
||||
os << "set terminal png" << std::endl;
|
||||
os << "set output '" << m_pngFilename << "'" << std::endl;
|
||||
os << "plot ";
|
||||
for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end ();)
|
||||
{
|
||||
os << "'-' title '" << (*i)->m_title << "'";
|
||||
switch ((*i)->m_style) {
|
||||
case GnuplotDataset::LINES:
|
||||
os << " with lines";
|
||||
break;
|
||||
case GnuplotDataset::POINTS:
|
||||
os << " with points";
|
||||
break;
|
||||
case GnuplotDataset::LINES_POINTS:
|
||||
os << " with linespoints";
|
||||
break;
|
||||
case GnuplotDataset::DOTS:
|
||||
os << " with dots";
|
||||
break;
|
||||
case GnuplotDataset::IMPULSES:
|
||||
os << " with impulses";
|
||||
break;
|
||||
case GnuplotDataset::STEPS:
|
||||
os << " with steps";
|
||||
break;
|
||||
case GnuplotDataset::FSTEPS:
|
||||
os << " with fsteps";
|
||||
break;
|
||||
case GnuplotDataset::HISTEPS:
|
||||
os << " with histeps";
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
if (i != m_datasets.end ())
|
||||
{
|
||||
os << ", ";
|
||||
}
|
||||
}
|
||||
os << std::endl;
|
||||
for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end (); i++)
|
||||
{
|
||||
for (GnuplotDataset::Dataset::const_iterator j = (*i)->m_dataset.begin ();
|
||||
j != (*i)->m_dataset.end (); j++)
|
||||
{
|
||||
os << j->first << " " << j->second << std::endl;
|
||||
}
|
||||
os << "e" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef GNUPLOT_H
|
||||
#define GNUPLOT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class GnuplotDataset
|
||||
{
|
||||
public:
|
||||
enum Style {
|
||||
LINES,
|
||||
POINTS,
|
||||
LINES_POINTS,
|
||||
DOTS,
|
||||
IMPULSES,
|
||||
STEPS,
|
||||
FSTEPS,
|
||||
HISTEPS,
|
||||
};
|
||||
|
||||
GnuplotDataset (std::string title);
|
||||
void SetStyle (enum Style style);
|
||||
void Add (double x, double y);
|
||||
private:
|
||||
friend class Gnuplot;
|
||||
typedef std::vector<std::pair<double,double> > Dataset;
|
||||
Dataset m_dataset;
|
||||
std::string m_title;
|
||||
enum Style m_style;
|
||||
};
|
||||
|
||||
class Gnuplot
|
||||
{
|
||||
public:
|
||||
Gnuplot (std::string pngFilename);
|
||||
~Gnuplot ();
|
||||
|
||||
void AddDataset (const GnuplotDataset &dataset);
|
||||
|
||||
void GenerateOutput (std::ostream &os);
|
||||
private:
|
||||
typedef std::vector<GnuplotDataset *> Datasets;
|
||||
Datasets m_datasets;
|
||||
std::string m_pngFilename;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* GNUPLOT_H */
|
||||
@@ -13,7 +13,6 @@ def build(bld):
|
||||
'tag-registry.cc',
|
||||
'pcap-writer.cc',
|
||||
'data-rate.cc',
|
||||
'gnuplot.cc',
|
||||
'error-model.cc',
|
||||
]
|
||||
|
||||
@@ -31,6 +30,5 @@ def build(bld):
|
||||
'packet-metadata.h',
|
||||
'pcap-writer.h',
|
||||
'data-rate.h',
|
||||
'gnuplot.h',
|
||||
'error-model.h',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user