MCPcopy Create free account
hub / github.com/alandefreitas/matplotplusplus / gnuplot

Method gnuplot

source/matplot/backend/gnuplot.cpp:45–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 bool gnuplot::consumes_gnuplot_commands() { return true; }
44
45 gnuplot::gnuplot() {
46 // 1st option: terminal in GNUTERM environment variable
47#if defined(_MSC_VER)
48 char *environment_terminal;
49 size_t len;
50 errno_t err = _dupenv_s(&environment_terminal, &len, "GNUTERM");
51 const bool env_found = err == 0 && environment_terminal != nullptr;
52#else
53 char *environment_terminal = std::getenv("GNUTERM");
54 bool env_found = environment_terminal != nullptr;
55#endif
56 if (env_found) {
57 if (terminal_is_available(environment_terminal)) {
58 terminal_ = environment_terminal;
59 }
60#if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__)
61 } else if (terminal_is_available("wxt")) {
62 // 2nd option: wxt on windows, even if not default
63 terminal_ = "wxt";
64#endif
65 } else if (terminal_is_available("qt")) {
66 // 3rd option: qt
67 terminal_ = "qt";
68 } else {
69 // 4rd option: default terminal type
70 terminal_ = default_terminal_type();
71 }
72
73 // Open the gnuplot pipe_
74 int perr;
75 if constexpr (windows_should_persist_by_default) {
76 perr = pipe_.open("gnuplot --persist");
77 } else {
78 perr = pipe_.open("gnuplot");
79 }
80
81 // Check if everything is OK
82 if (perr != 0 || !pipe_.opened()) {
83 std::cerr << "Opening the gnuplot failed: ";
84 std::cerr << pipe_.error() << std::endl;
85 std::cerr << "Please install gnuplot 5.2.6+: http://www.gnuplot.info"
86 << std::endl;
87 }
88 }
89
90 gnuplot::~gnuplot() {
91 if constexpr (dont_let_it_close_too_fast) {

Callers

nothing calls this directly

Calls 2

openedMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected