UTILLib 2.0
Common C++ library with utilities.
Loading...
Searching...
No Matches
gnuplot.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Ingemar Hedvall
3 * SPDX-License-Identifier: MIT
4 */
5
18#pragma once
19#include <string>
20
21#include "util/csvwriter.h"
22
23namespace util::plot {
24
29enum class GnuTerminal {
30 wxt = 0
31};
32
40class GnuPlot {
41 public:
49 virtual ~GnuPlot() = default;
50
56 [[nodiscard]] const std::string& ExePath() const { return exe_path_; }
57
63 [[nodiscard]] const std::string& Name() const { return name_; }
64
71 void Name(const std::string& name) { name_ = name; }
72
78 [[nodiscard]] const std::string& Path() const { return path_; }
79
85 void Path(const std::string& path) { path_ = path; }
86
92 [[nodiscard]] std::string FileName() const;
93
99 [[nodiscard]] std::string CsvFileName() const;
100
106 [[nodiscard]] std::string CreateScript() const;
107
113
118 void Show();
119
125 CsvWriter& CsvFile() { return data_file_; }
126
127 private:
128 std::string exe_path_;
129 std::string name_;
130 std::string
131 path_;
132
133 GnuTerminal terminal_ = GnuTerminal::wxt;
134
135 std::string title_;
136 size_t x_size_ = 1200;
137 size_t y_size_ = 800;
138
139 std::string x_label_;
140 std::string y_label_;
141 std::string x2_label_;
142 std::string y2_label_;
143
144 CsvWriter data_file_;
145
146 void MakeScript(std::ostream& script) const;
147};
148
149} // namespace util::plot
Simple writer interface when creating a CSV file (comma separated value).
Definition csvwriter.h:36
void Path(const std::string &path)
Path where report are saved.
Definition gnuplot.h:85
const std::string & ExePath() const
Returns the full path to the gnuplot application.
Definition gnuplot.h:56
virtual ~GnuPlot()=default
Destructor.
std::string CreateScript() const
Creates a script string.
std::string CsvFileName() const
Returns the full path of the CSV file.
const std::string & Name() const
Name of the gnuplot report.
Definition gnuplot.h:63
void Show()
Shows the plot on the screen.
GnuPlot()
Constructor.
const std::string & Path() const
Path where reports are saved.
Definition gnuplot.h:78
void Name(const std::string &name)
Name of the gnuplot report If the plot report shall be saved, this defines the name of the gnuplot fi...
Definition gnuplot.h:71
std::string FileName() const
Returns the full path to the gnuplot script file.
void SaveScript()
Creates and saves the gnuplot script in a file.
CsvWriter & CsvFile()
Returns a reference to a CSV writer object.
Definition gnuplot.h:125
Defines a simple API when creating a comma separated value (CSV) file.
The plot namespace is used for plotting related classes and functions.
Definition csvwriter.h:16
GnuTerminal
Types of gnuplot output devices.
Definition gnuplot.h:29
@ wxt
wxWidgets window
Definition gnuplot.h:30