A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
gnuplot.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 INRIA, 2008 Timo Bingmann
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Original Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
* Enhancements: Timo Bingmann <timo.bingmann@student.kit.edu>
20
*/
21
#ifndef GNUPLOT_H
22
#define GNUPLOT_H
23
24
#include <string>
25
#include <vector>
26
#include <utility>
27
28
namespace
ns3 {
29
38
class
GnuplotDataset
39
{
40
public
:
41
45
GnuplotDataset
(
const
GnuplotDataset
& original);
46
50
~GnuplotDataset
();
51
55
GnuplotDataset
&
operator=
(
const
GnuplotDataset
& original);
56
61
void
SetTitle
(
const
std::string& title);
62
67
static
void
SetDefaultExtra
(
const
std::string& extra);
68
73
void
SetExtra
(
const
std::string& extra);
74
75
protected
:
76
79
friend
class
Gnuplot
;
80
84
static
std::string
m_defaultExtra
;
85
89
struct
Data
;
90
95
GnuplotDataset
(
struct
Data
*
data
);
96
100
struct
Data
*
m_data
;
101
};
102
107
class
Gnuplot2dDataset
:
public
GnuplotDataset
108
{
109
public
:
113
enum
Style
{
114
LINES
,
115
POINTS
,
116
LINES_POINTS
,
117
DOTS
,
118
IMPULSES
,
119
STEPS
,
120
FSTEPS
,
121
HISTEPS
,
122
};
123
127
enum
ErrorBars
{
128
NONE
,
129
X
,
130
Y
,
131
XY
132
};
133
140
Gnuplot2dDataset
(
const
std::string& title =
"Untitled"
);
141
146
static
void
SetDefaultStyle
(
enum
Style
style);
147
151
void
SetStyle
(
enum
Style
style);
152
157
static
void
SetDefaultErrorBars
(
enum
ErrorBars
errorBars);
158
167
void
SetErrorBars
(
enum
ErrorBars
errorBars);
168
175
void
Add
(
double
x
,
double
y);
176
184
void
Add
(
double
x
,
double
y,
double
errorDelta);
185
194
void
Add
(
double
x
,
double
y,
double
xErrorDelta,
double
yErrorDelta);
195
200
void
AddEmptyLine
();
201
202
private
:
203
204
struct
Point
{
205
bool
empty
;
206
double
x
;
207
double
y
;
208
double
dx
;
209
double
dy
;
210
};
211
212
typedef
std::vector<struct Point>
PointSet
;
213
214
static
enum
Style
m_defaultStyle
;
215
static
enum
ErrorBars
m_defaultErrorBars
;
216
218
struct
Data2d
;
219
};
220
227
class
Gnuplot2dFunction
:
public
GnuplotDataset
228
{
229
public
:
237
Gnuplot2dFunction
(
const
std::string& title =
"Untitled"
,
const
std::string&
function
=
""
);
238
242
void
SetFunction
(
const
std::string&
function
);
243
244
private
:
245
247
struct
Function2d
;
248
};
249
254
class
Gnuplot3dDataset
:
public
GnuplotDataset
255
{
256
public
:
263
Gnuplot3dDataset
(
const
std::string& title =
"Untitled"
);
264
269
static
void
SetDefaultStyle
(
const
std::string& style);
270
274
void
SetStyle
(
const
std::string& style);
275
283
void
Add
(
double
x
,
double
y,
double
z);
284
289
void
AddEmptyLine
();
290
291
private
:
292
293
struct
Point
{
294
bool
empty
;
295
double
x
,
y
,
z
;
296
};
297
298
typedef
std::vector<struct Point>
PointSet
;
299
300
static
std::string
m_defaultStyle
;
301
303
struct
Data3d
;
304
};
305
313
class
Gnuplot3dFunction
:
public
GnuplotDataset
314
{
315
public
:
323
Gnuplot3dFunction
(
const
std::string& title =
"Untitled"
,
const
std::string&
function
=
""
);
324
328
void
SetFunction
(
const
std::string&
function
);
329
330
private
:
331
333
struct
Function3d
;
334
};
335
343
class
Gnuplot
344
{
345
public
:
352
Gnuplot
(
const
std::string& outputFilename=
""
,
const
std::string& title =
""
);
353
359
static
std::string
DetectTerminal
(
const
std::string& filename);
360
365
void
SetTerminal
(
const
std::string& terminal);
366
370
void
SetTitle
(
const
std::string& title);
371
376
void
SetLegend
(
const
std::string& xLegend,
const
std::string& yLegend);
377
381
void
SetExtra
(
const
std::string& extra);
382
386
void
AppendExtra
(
const
std::string& extra);
387
391
void
AddDataset
(
const
GnuplotDataset
& dataset);
392
397
void
GenerateOutput
(std::ostream &os)
const
;
398
399
private
:
400
typedef
std::vector<GnuplotDataset>
Datasets
;
401
402
std::string
m_outputFilename
;
403
std::string
m_terminal
;
404
405
Datasets
m_datasets
;
406
407
std::string
m_title
;
408
std::string
m_xLegend
;
409
std::string
m_yLegend
;
410
std::string
m_extra
;
411
};
412
417
class
GnuplotCollection
418
{
419
public
:
425
GnuplotCollection
(
const
std::string& outputFilename);
426
431
void
SetTerminal
(
const
std::string& terminal);
432
436
void
AddPlot
(
const
Gnuplot
& plot);
437
443
Gnuplot
&
GetPlot
(
unsigned
int
id
);
444
449
void
GenerateOutput
(std::ostream &os)
const
;
450
451
private
:
452
typedef
std::vector<Gnuplot>
Plots
;
453
454
std::string
m_outputFilename
;
455
std::string
m_terminal
;
456
457
Plots
m_plots
;
458
};
459
460
}
// namespace ns3
461
462
#endif
/* GNUPLOT_H */
src
tools
model
gnuplot.h
Generated on Tue Nov 13 2012 10:32:23 for ns-3 by
1.8.1.2