A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gnuplot.cc
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 #include "gnuplot.h"
22 #include "ns3/assert.h"
23 #include <ostream>
24 #include <stdexcept>
25 
26 namespace ns3 {
27 
28 // --- GnuplotDataset::Data ------------------------------------------------ //
29 
31 {
32  // *** Data Variables ***
33 
34  unsigned int m_references;
35 
36  std::string m_title;
37  std::string m_extra;
38 
42  Data(const std::string& title);
43 
45  virtual ~Data();
46 
50  virtual std::string GetCommand () const = 0;
51 
61  virtual void PrintExpression (std::ostream &os,
62  bool generateOneOutputFile,
63  unsigned int dataFileDatasetIndex,
64  std::string &dataFileName) const = 0;
65 
70  virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const = 0;
71 
76  virtual bool IsEmpty () const = 0;
77 };
78 
79 GnuplotDataset::Data::Data(const std::string& title)
80  : m_references (1),
81  m_title (title),
82  m_extra (m_defaultExtra)
83 {
84 }
85 
87 {
88 }
89 
90 // --- GnuplotDataset ------------------------------------------------------ //
91 
92 std::string GnuplotDataset::m_defaultExtra = "";
93 
95  : m_data (data)
96 {
97 }
98 
100  : m_data (original.m_data)
101 {
102  ++m_data->m_references;
103 }
104 
106 {
107  if (--m_data->m_references == 0)
108  delete m_data;
109 }
110 
112 {
113  if (this != &original)
114  {
115  if (--m_data->m_references == 0)
116  delete m_data;
117 
118  m_data = original.m_data;
119  ++m_data->m_references;
120  }
121  return *this;
122 }
123 
124 void
125 GnuplotDataset::SetTitle (const std::string& title)
126 {
127  m_data->m_title = title;
128 }
129 
130 void
131 GnuplotDataset::SetDefaultExtra (const std::string& extra)
132 {
133  m_defaultExtra = extra;
134 }
135 void
136 GnuplotDataset::SetExtra (const std::string& extra)
137 {
138  m_data->m_extra = extra;
139 }
140 
141 // --- Gnuplot2dDataset::Data2d -------------------------------------------- //
142 
144 {
145  // *** Data Variables ***
146 
149 
151 
155  Data2d(const std::string& title);
156 
157  virtual std::string GetCommand () const;
158  virtual void PrintExpression (std::ostream &os,
159  bool generateOneOutputFile,
160  unsigned int dataFileDatasetIndex,
161  std::string &dataFileName) const;
162  virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
163  virtual bool IsEmpty () const;
164 };
165 
166 Gnuplot2dDataset::Data2d::Data2d(const std::string& title)
167  : Data (title),
168  m_style (m_defaultStyle),
169  m_errorBars (m_defaultErrorBars)
170 {
171 }
172 
173 std::string
175 {
176  return "plot";
177 }
178 
179 void
181  bool generateOneOutputFile,
182  unsigned int dataFileDatasetIndex,
183  std::string &dataFileName) const
184 {
185  // Print the appropriate thing based on whether separate output and
186  // date files are being generated.
187  if (generateOneOutputFile)
188  {
189  os << "\"-\" ";
190  }
191  else
192  {
193  os << "\"" << dataFileName << "\" index " << dataFileDatasetIndex;
194  }
195 
196  if (m_title.size ())
197  os << " title \"" << m_title << "\"";
198 
199  switch (m_style) {
200  case LINES:
201  os << " with lines";
202  break;
203  case POINTS:
204  switch (m_errorBars)
205  {
206  case NONE:
207  os << " with points";
208  break;
209  case X:
210  os << " with xerrorbars";
211  break;
212  case Y:
213  os << " with yerrorbars";
214  break;
215  case XY:
216  os << " with xyerrorbars";
217  break;
218  }
219  break;
220  case LINES_POINTS:
221  switch (m_errorBars)
222  {
223  case NONE:
224  os << " with linespoints";
225  break;
226  case X:
227  os << " with errorlines";
228  break;
229  case Y:
230  os << " with yerrorlines";
231  break;
232  case XY:
233  os << " with xyerrorlines";
234  break;
235  }
236  break;
237  case DOTS:
238  os << " with dots";
239  break;
240  case IMPULSES:
241  os << " with impulses";
242  break;
243  case STEPS:
244  os << " with steps";
245  break;
246  case FSTEPS:
247  os << " with fsteps";
248  break;
249  case HISTEPS:
250  os << " with histeps";
251  break;
252  }
253 
254  if (m_extra.size ())
255  os << " " << m_extra;
256 }
257 
258 void
259 Gnuplot2dDataset::Data2d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
260 {
261  for (PointSet::const_iterator i = m_pointset.begin ();
262  i != m_pointset.end (); ++i)
263  {
264  if (i->empty) {
265  os << std::endl;
266  continue;
267  }
268 
269  switch (m_errorBars) {
270  case NONE:
271  os << i->x << " " << i->y << std::endl;
272  break;
273  case X:
274  os << i->x << " " << i->y << " " << i->dx << std::endl;
275  break;
276  case Y:
277  os << i->x << " " << i->y << " " << i->dy << std::endl;
278  break;
279  case XY:
280  os << i->x << " " << i->y << " " << i->dx << " " << i->dy << std::endl;
281  break;
282  }
283  }
284 
285  // Print the appropriate thing based on whether separate output and
286  // date files are being generated.
287  if (generateOneOutputFile)
288  {
289  os << "e" << std::endl;
290  }
291  else
292  {
293  os << std::endl;
294  os << std::endl;
295  }
296 }
297 
298 bool
300 {
301  return (m_pointset.size () == 0);
302 }
303 
304 // --- Gnuplot2dDataset ---------------------------------------------------- //
305 
308 
309 Gnuplot2dDataset::Gnuplot2dDataset (const std::string& title)
310  : GnuplotDataset ( new Data2d (title) )
311 {
312 }
313 
314 void
316 {
317  m_defaultStyle = style;
318 }
319 void
321 {
322  reinterpret_cast<Data2d*>(m_data)->m_style = style;
323 }
324 
325 void
327 {
328  m_defaultErrorBars = errorBars;
329 }
330 void
332 {
333  reinterpret_cast<Data2d*>(m_data)->m_errorBars = errorBars;
334 }
335 
336 void
337 Gnuplot2dDataset::Add (double x, double y)
338 {
339  NS_ASSERT (reinterpret_cast<Data2d*>(m_data)->m_errorBars == NONE);
340 
341  struct Point data;
342  data.empty = false;
343  data.x = x;
344  data.y = y;
345  data.dx = 0.0;
346  data.dy = 0.0;
347  reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
348 }
349 
350 void
351 Gnuplot2dDataset::Add (double x, double y, double errorDelta)
352 {
353  NS_ASSERT ( reinterpret_cast<Data2d*>(m_data)->m_errorBars == X ||
354  reinterpret_cast<Data2d*>(m_data)->m_errorBars == Y );
355 
356  struct Point data;
357  data.empty = false;
358  data.x = x;
359  data.y = y;
360  data.dx = errorDelta;
361  data.dy = errorDelta;
362  reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
363 }
364 
365 void
366 Gnuplot2dDataset::Add (double x, double y, double xErrorDelta, double yErrorDelta)
367 {
368  NS_ASSERT ( reinterpret_cast<Data2d*>(m_data)->m_errorBars == XY );
369 
370  struct Point data;
371  data.empty = false;
372  data.x = x;
373  data.y = y;
374  data.dx = xErrorDelta;
375  data.dy = yErrorDelta;
376  reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
377 }
378 
379 void
381 {
382  struct Point data;
383  data.empty = true;
384  reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
385 }
386 
387 // --- Gnuplot2dFunction::Function2d --------------------------------------- //
388 
390 {
391  // *** Data Variables ***
392 
393  std::string m_function;
394 
398  Function2d(const std::string& title, const std::string& function);
399 
400  virtual std::string GetCommand () const;
401  virtual void PrintExpression (std::ostream &os,
402  bool generateOneOutputFile,
403  unsigned int dataFileDatasetIndex,
404  std::string &dataFileName) const;
405  virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
406  virtual bool IsEmpty () const;
407 };
408 
409 Gnuplot2dFunction::Function2d::Function2d(const std::string& title, const std::string& function)
410  : Data (title),
411  m_function (function)
412 {
413 }
414 
415 std::string
417 {
418  return "plot";
419 }
420 
421 void
423  bool generateOneOutputFile,
424  unsigned int dataFileDatasetIndex,
425  std::string &dataFileName) const
426 {
427  os << m_function;
428 
429  if (m_title.size ())
430  os << " title \"" << m_title << "\"";
431 
432  if (m_extra.size ())
433  os << " " << m_extra;
434 }
435 
436 void
437 Gnuplot2dFunction::Function2d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
438 {
439 }
440 
441 bool
443 {
444  return false;
445 }
446 
447 // --- Gnuplot2dFunction --------------------------------------------------- //
448 
449 Gnuplot2dFunction::Gnuplot2dFunction (const std::string& title, const std::string& function)
450  : GnuplotDataset ( new Function2d (title, function) )
451 {
452 }
453 
454 void
455 Gnuplot2dFunction::SetFunction (const std::string& function)
456 {
457  reinterpret_cast<Function2d*>(m_data)->m_function = function;
458 }
459 
460 // --- Gnuplot3dDataset::Data3d -------------------------------------------- //
461 
463 {
464  // *** Data Variables ***
465 
466  std::string m_style;
467 
469 
473  Data3d(const std::string& title);
474 
475  virtual std::string GetCommand () const;
476  virtual void PrintExpression (std::ostream &os,
477  bool generateOneOutputFile,
478  unsigned int dataFileDatasetIndex,
479  std::string &dataFileName) const;
480  virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
481  virtual bool IsEmpty () const;
482 };
483 
484 Gnuplot3dDataset::Data3d::Data3d(const std::string& title)
485  : Data (title),
486  m_style (m_defaultStyle)
487 {
488 }
489 
490 std::string
492 {
493  return "splot";
494 }
495 
496 void
498  bool generateOneOutputFile,
499  unsigned int dataFileDatasetIndex,
500  std::string &dataFileName) const
501 {
502  os << "\"-\" ";
503 
504  if (m_style.size ())
505  os << " " << m_style;
506 
507  if (m_title.size ())
508  os << " title \"" << m_title << "\"";
509 
510  if (m_extra.size ())
511  os << " " << m_extra;
512 }
513 
514 void
515 Gnuplot3dDataset::Data3d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
516 {
517  for (PointSet::const_iterator i = m_pointset.begin ();
518  i != m_pointset.end (); ++i)
519  {
520  if (i->empty) {
521  os << std::endl;
522  continue;
523  }
524 
525  os << i->x << " " << i->y << " " << i->z << std::endl;
526  }
527  os << "e" << std::endl;
528 }
529 
530 bool
532 {
533  return (m_pointset.size () == 0);
534 }
535 
536 // --- Gnuplot3dDataset ---------------------------------------------------- //
537 
538 std::string Gnuplot3dDataset::m_defaultStyle = "";
539 
540 Gnuplot3dDataset::Gnuplot3dDataset (const std::string& title)
541  : GnuplotDataset ( new Data3d (title) )
542 {
543 }
544 
545 void
546 Gnuplot3dDataset::SetDefaultStyle (const std::string& style)
547 {
548  m_defaultStyle = style;
549 }
550 void
551 Gnuplot3dDataset::SetStyle (const std::string& style)
552 {
553  reinterpret_cast<Data3d*>(m_data)->m_style = style;
554 }
555 
556 void
557 Gnuplot3dDataset::Add (double x, double y, double z)
558 {
559  struct Point data;
560  data.empty = false;
561  data.x = x;
562  data.y = y;
563  data.z = z;
564  reinterpret_cast<Data3d*>(m_data)->m_pointset.push_back (data);
565 }
566 
567 void
569 {
570  struct Point data;
571  data.empty = true;
572  reinterpret_cast<Data3d*>(m_data)->m_pointset.push_back (data);
573 }
574 
575 // --- Gnuplot3dFunction::Function3d --------------------------------------- //
576 
578 {
579  // *** Data Variables ***
580 
581  std::string m_function;
582 
586  Function3d(const std::string& title, const std::string& function);
587 
588  virtual std::string GetCommand () const;
589  virtual void PrintExpression (std::ostream &os,
590  bool generateOneOutputFile,
591  unsigned int dataFileDatasetIndex,
592  std::string &dataFileName) const;
593  virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
594  virtual bool IsEmpty () const;
595 };
596 
597 Gnuplot3dFunction::Function3d::Function3d(const std::string& title, const std::string& function)
598  : Data (title),
599  m_function (function)
600 {
601 }
602 
603 std::string
605 {
606  return "splot";
607 }
608 
609 void
611  bool generateOneOutputFile,
612  unsigned int dataFileDatasetIndex,
613  std::string &dataFileName) const
614 {
615  os << m_function;
616 
617  if (m_title.size ())
618  os << " title \"" << m_title << "\"";
619 
620  if (m_extra.size ())
621  os << " " << m_extra;
622 }
623 
624 void
625 Gnuplot3dFunction::Function3d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
626 {
627 }
628 
629 bool
631 {
632  return false;
633 }
634 
635 // --- Gnuplot3dFunction --------------------------------------------------- //
636 
637 Gnuplot3dFunction::Gnuplot3dFunction (const std::string& title, const std::string& function)
638  : GnuplotDataset ( new Function3d (title, function) )
639 {
640 }
641 
642 void
643 Gnuplot3dFunction::SetFunction (const std::string& function)
644 {
645  reinterpret_cast<Function3d*>(m_data)->m_function = function;
646 }
647 
648 // ------------------------------------------------------------------------- //
649 
650 Gnuplot::Gnuplot (const std::string& outputFilename, const std::string& title)
651  : m_outputFilename (outputFilename),
652  m_terminal ( DetectTerminal (outputFilename) ),
653  m_title (title),
654  m_generateOneOutputFile (false),
655  m_dataFileDatasetIndex (0)
656 {
657 }
658 
659 void Gnuplot::SetOutputFilename (const std::string& outputFilename)
660 {
661  m_outputFilename = outputFilename;
662 }
663 
664 std::string Gnuplot::DetectTerminal (const std::string& filename)
665 {
666  std::string::size_type dotpos = filename.rfind ('.');
667  if (dotpos == std::string::npos) return "";
668 
669  if (filename.substr (dotpos) == ".png") {
670  return "png";
671  }
672  else if (filename.substr (dotpos) == ".pdf") {
673  return "pdf";
674  }
675 
676  return "";
677 }
678 
679 void
680 Gnuplot::SetTerminal (const std::string& terminal)
681 {
682  m_terminal = terminal;
683 }
684 
685 void
686 Gnuplot::SetTitle (const std::string& title)
687 {
688  m_title = title;
689 }
690 
691 void
692 Gnuplot::SetLegend (const std::string& xLegend, const std::string& yLegend)
693 {
694  m_xLegend = xLegend;
695  m_yLegend = yLegend;
696 }
697 
698 void
699 Gnuplot::SetExtra (const std::string& extra)
700 {
701  m_extra = extra;
702 }
703 
704 void
705 Gnuplot::AppendExtra (const std::string& extra)
706 {
707  m_extra += "\n";
708  m_extra += extra;
709 }
710 
711 void
713 {
714  m_datasets.push_back (dataset);
715 }
716 
717 void
718 Gnuplot::GenerateOutput (std::ostream &os)
719 {
720  // If this version of this function is called, it is assumed that a
721  // single output file is being generated.
723 
724  // Send the gnuplot metadata to the same stream as the data stream.
725  GenerateOutput (os, os, "");
726 }
727 
728 void
729 Gnuplot::GenerateOutput (std::ostream &osControl,
730  std::ostream &osData,
731  std::string dataFileName)
732 {
733  if (m_terminal.size ())
734  osControl << "set terminal " << m_terminal << std::endl;
735 
736  if (m_outputFilename.size ())
737  osControl << "set output \"" << m_outputFilename << "\"" << std::endl;
738 
739  if (m_title.size ())
740  osControl << "set title \"" << m_title << "\"" << std::endl;
741 
742  if (m_xLegend.size ())
743  osControl << "set xlabel \"" << m_xLegend << "\"" << std::endl;
744 
745  if (m_yLegend.size ())
746  osControl << "set ylabel \"" << m_yLegend << "\"" << std::endl;
747 
748  if (m_extra.size ())
749  osControl << m_extra << std::endl;
750 
751  if (m_datasets.empty ())
752  return;
753 
754  // Determine the GetCommand() values of all datasets included. Check that all
755  // are equal and print the command.
756 
757  std::string command = m_datasets.begin ()->m_data->GetCommand ();
758 
759  for (Datasets::const_iterator i = m_datasets.begin () + 1;
760  i != m_datasets.end (); ++i)
761  {
762  NS_ASSERT_MSG (command == i->m_data->GetCommand (),
763  "Cannot mix 'plot' and 'splot' GnuplotDatasets.");
764  }
765 
766  osControl << command << " ";
767 
768  // Print all dataset expressions
769 
770  bool isDataEmpty;
771  for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end ();)
772  {
773  // Only print the dataset if it's not empty.
774  isDataEmpty = i->m_data->IsEmpty ();
775  if (!isDataEmpty)
776  {
777  // Print the appropriate expression based on whether we are
778  // generating separate output and date files.
779  i->m_data->PrintExpression (osControl,
782  dataFileName);
783 
785  }
786 
787  i++;
788  if (i != m_datasets.end () && !isDataEmpty)
789  {
790  osControl << ", ";
791  }
792  }
793  osControl << std::endl;
794 
795  // followed by the inline datafile.
796 
797  for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end (); i++)
798  {
799  i->m_data->PrintDataFile (osData, m_generateOneOutputFile);
800  }
801 }
802 
803 void
805 {
806  m_dataFileDatasetIndex = index;
807 }
808 
809 // ------------------------------------------------------------------------- //
810 
811 GnuplotCollection::GnuplotCollection (const std::string& outputFilename)
812  : m_outputFilename (outputFilename),
813  m_terminal ( Gnuplot::DetectTerminal (outputFilename) )
814 {
815 }
816 
817 void
818 GnuplotCollection::SetTerminal (const std::string& terminal)
819 {
820  m_terminal = terminal;
821 }
822 
823 void
825 {
826  m_plots.push_back (plot);
827 }
828 
829 Gnuplot&
830 GnuplotCollection::GetPlot (unsigned int id)
831 {
832  if (id >= m_plots.size ())
833  throw(std::range_error ("Gnuplot id is out of range"));
834  else
835  return m_plots[id];
836 }
837 
838 void
840 {
841  // If this version of this function is called, it is assumed that a
842  // single output file is being generated.
843 
844  if (m_terminal.size ())
845  os << "set terminal " << m_terminal << std::endl;
846 
847  if (m_outputFilename.size ())
848  os << "set output \"" << m_outputFilename << "\"" << std::endl;
849 
850  for (Plots::iterator i = m_plots.begin (); i != m_plots.end (); ++i)
851  {
852  i->GenerateOutput (os);
853  }
854 }
855 
856 void
857 GnuplotCollection::GenerateOutput (std::ostream &osControl, std::ostream &osData,
858 std::string dataFileName)
859 {
860  // If this version of this function is called, it is assumed that
861  // separate output and date files are being generated.
862 
863  if (m_terminal.size ())
864  osControl << "set terminal " << m_terminal << std::endl;
865 
866  if (m_outputFilename.size ())
867  osControl << "set output \"" << m_outputFilename << "\"" << std::endl;
868 
869  for (Plots::iterator i = m_plots.begin (); i != m_plots.end (); ++i)
870  {
871  i->GenerateOutput (osControl, osData, dataFileName);
872  }
873 }
874 
875 // ------------------------------------------------------------------------- //
876 
877 } // namespace ns3
void AppendExtra(const std::string &extra)
Definition: gnuplot.cc:705
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Definition: gnuplot.cc:497
Function3d(const std::string &title, const std::string &function)
Definition: gnuplot.cc:597
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Definition: gnuplot.cc:515
void SetTitle(const std::string &title)
Change line title.
Definition: gnuplot.cc:125
Abstract class to store a plot line to be used by ns3::Gnuplot.
Definition: gnuplot.h:38
Gnuplot(const std::string &outputFilename="", const std::string &title="")
Definition: gnuplot.cc:650
Gnuplot2dDataset(const std::string &title="Untitled")
Definition: gnuplot.cc:309
static void SetDefaultExtra(const std::string &extra)
Change extra formatting style parameters for newly created objects.
Definition: gnuplot.cc:131
void Add(double x, double y, double z)
Definition: gnuplot.cc:557
enum ErrorBars m_errorBars
Definition: gnuplot.cc:148
unsigned int m_references
Definition: gnuplot.cc:34
#define NS_ASSERT(condition)
Definition: assert.h:64
GnuplotDataset & operator=(const GnuplotDataset &original)
Definition: gnuplot.cc:111
virtual std::string GetCommand() const
Definition: gnuplot.cc:174
static std::string m_defaultExtra
Extra gnuplot parameters set on every newly created dataset.
Definition: gnuplot.h:84
void SetFunction(const std::string &function)
Definition: gnuplot.cc:455
void AddDataset(const GnuplotDataset &dataset)
Definition: gnuplot.cc:712
virtual bool IsEmpty() const =0
virtual bool IsEmpty() const
Definition: gnuplot.cc:531
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Definition: gnuplot.cc:422
Data3d(const std::string &title)
Definition: gnuplot.cc:484
std::vector< struct Point > PointSet
Definition: gnuplot.h:298
void SetExtra(const std::string &extra)
Add extra formatting parameters to this dataset.
Definition: gnuplot.cc:136
void SetErrorBars(enum ErrorBars errorBars)
Definition: gnuplot.cc:331
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const =0
std::string m_xLegend
Definition: gnuplot.h:442
std::string m_outputFilename
Definition: gnuplot.h:436
virtual std::string GetCommand() const
Definition: gnuplot.cc:416
void SetOutputFilename(const std::string &outputFilename)
Definition: gnuplot.cc:659
struct Data * m_data
Definition: gnuplot.h:100
Data2d(const std::string &title)
Definition: gnuplot.cc:166
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition: gnuplot.h:343
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Definition: gnuplot.cc:610
void SetTitle(const std::string &title)
Definition: gnuplot.cc:686
static std::string m_defaultStyle
Definition: gnuplot.h:300
uint8_t data[writeSize]
Gnuplot3dDataset(const std::string &title="Untitled")
Definition: gnuplot.cc:540
Function2d(const std::string &title, const std::string &function)
Definition: gnuplot.cc:409
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Definition: gnuplot.cc:625
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition: gnuplot.cc:718
void Add(double x, double y)
Definition: gnuplot.cc:337
Gnuplot2dFunction(const std::string &title="Untitled", const std::string &function="")
Definition: gnuplot.cc:449
Gnuplot3dFunction(const std::string &title="Untitled", const std::string &function="")
Definition: gnuplot.cc:637
void AddPlot(const Gnuplot &plot)
Definition: gnuplot.cc:824
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Definition: gnuplot.cc:692
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Definition: gnuplot.cc:437
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Definition: gnuplot.cc:259
static void SetDefaultErrorBars(enum ErrorBars errorBars)
Definition: gnuplot.cc:326
virtual std::string GetCommand() const =0
GnuplotCollection(const std::string &outputFilename)
Definition: gnuplot.cc:811
void GenerateOutput(std::ostream &os)
Definition: gnuplot.cc:839
static void SetDefaultStyle(enum Style style)
Definition: gnuplot.cc:315
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Definition: gnuplot.cc:180
Datasets m_datasets
Definition: gnuplot.h:439
std::vector< struct Point > PointSet
Definition: gnuplot.h:212
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const =0
void SetStyle(enum Style style)
Definition: gnuplot.cc:320
void SetExtra(const std::string &extra)
Definition: gnuplot.cc:699
void SetStyle(const std::string &style)
Definition: gnuplot.cc:551
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
std::string m_outputFilename
Definition: gnuplot.h:505
std::string m_extra
Definition: gnuplot.h:444
virtual bool IsEmpty() const
Definition: gnuplot.cc:442
void SetTerminal(const std::string &terminal)
Definition: gnuplot.cc:818
unsigned int m_dataFileDatasetIndex
Definition: gnuplot.h:448
std::string m_terminal
Definition: gnuplot.h:506
void SetFunction(const std::string &function)
Definition: gnuplot.cc:643
std::string m_title
Definition: gnuplot.h:441
virtual std::string GetCommand() const
Definition: gnuplot.cc:491
GnuplotDataset(const GnuplotDataset &original)
Definition: gnuplot.cc:99
bool m_generateOneOutputFile
Definition: gnuplot.h:446
virtual std::string GetCommand() const
Definition: gnuplot.cc:604
static void SetDefaultStyle(const std::string &style)
Definition: gnuplot.cc:546
static std::string DetectTerminal(const std::string &filename)
Definition: gnuplot.cc:664
std::string m_yLegend
Definition: gnuplot.h:443
static enum Style m_defaultStyle
Definition: gnuplot.h:214
void SetDataFileDatasetIndex(unsigned int index)
Sets the current data stream index in the data file.
Definition: gnuplot.cc:804
std::string m_terminal
Definition: gnuplot.h:437
void SetTerminal(const std::string &terminal)
Definition: gnuplot.cc:680
Data(const std::string &title)
Definition: gnuplot.cc:79
virtual ~Data()
Required.
Definition: gnuplot.cc:86
virtual bool IsEmpty() const
Definition: gnuplot.cc:630
Gnuplot & GetPlot(unsigned int id)
Definition: gnuplot.cc:830
static enum ErrorBars m_defaultErrorBars
Definition: gnuplot.h:215
virtual bool IsEmpty() const
Definition: gnuplot.cc:299