sciplot  0.3.1
A modern C++ plotting library powered by gnuplot
TicsSpecs.hpp
1 // sciplot - a modern C++ scientific plotting library powered by gnuplot
2 // https://github.com/sciplot/sciplot
3 //
4 // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
5 //
6 // Copyright (c) 2018-2021 Allan Leal
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 // sciplot includes
29 #include <sciplot/Default.hpp>
30 #include <sciplot/Utils.hpp>
31 #include <sciplot/specs/TicsSpecsBaseOf.hpp>
32 
33 namespace sciplot
34 {
35 
37 class TicsSpecs : public TicsSpecsBaseOf<TicsSpecs>
38 {
39  public:
41  TicsSpecs();
42 
44  auto stackFront() -> TicsSpecs&;
45 
47  auto stackBack() -> TicsSpecs&;
48 
50  auto repr() const -> std::string;
51 
52  private:
54  std::string m_depth;
55 };
56 
59 {
60  stackFront();
61 }
62 
64 {
65  m_depth = "front";
66  return *this;
67 }
68 
70 {
71  m_depth = "back";
72  return *this;
73 }
74 
75 inline auto TicsSpecs::repr() const -> std::string
76 {
77  const auto baserepr = TicsSpecsBaseOf<TicsSpecs>::repr();
78 
79  if (isHidden())
80  return baserepr;
81 
82  std::stringstream ss;
83  ss << baserepr << " ";
84  ss << m_depth;
85  return internal::removeExtraWhitespaces(ss.str());
86 }
87 
88 } // namespace sciplot
auto stackFront() -> TicsSpecs &
Set the tics to be displayed on the front of all plot elements.
Definition: TicsSpecs.hpp:63
auto repr() const -> std::string
Convert this TicsSpecs object into a gnuplot formatted string.
Definition: TicsSpecs.hpp:75
The class used to attach common tic options to a type that also specifies tic options.
Definition: TicsSpecsBaseOf.hpp:41
auto repr() const -> std::string
Convert this TicsSpecsBaseOf object into a gnuplot formatted string.
Definition: TicsSpecsBaseOf.hpp:209
auto isHidden() const -> bool
Return true if the underlying plot element is hidden.
Definition: ShowSpecsOf.hpp:81
TicsSpecs()
Construct a default TicsSpecs instance.
Definition: TicsSpecs.hpp:57
The class used to specify options for tics.
Definition: TicsSpecs.hpp:38
auto stackBack() -> TicsSpecs &
Set the tics to be displayed on the back of all plot elements.
Definition: TicsSpecs.hpp:69