GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
ExportMethod.hpp
Go to the documentation of this file.
1 // This file is part of GranOO, a workbench for DEM simulation.
2 //
3 // Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4 // <damien.andre@unilim.fr>
5 // - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6 // <jean-luc.charles@ensam.eu>
7 // - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8 // <jeremie.girardot@ensam.eu>
9 // - Cedric Hubert LAMIH/UPHF, Valenciennes France
10 // <cedric.hubert@uphf.fr>
11 // - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12 // <ivan.iordanoff@ensam.eu>
13 //
14 // Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15 //
16 // This program is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29 
30 #ifndef _libCore_ExportMethod_hpp_
31 #define _libCore_ExportMethod_hpp_
32 
33 #include <string>
34 #include <vector>
35 #include <functional>
36 
37 #include "GranOO3/Core/Color.hpp"
38 
39 namespace GranOO3
40 {
41  namespace Core
42  {
43 
44  //Base Class
46  {
47  public:
48  static std::string get_separator();
49 
50  static std::vector<ExportMethod*>& get_all() {
51  static std::vector<ExportMethod*> instance;
52  return instance;
53  }
54 
55  public:
56  ExportMethod(const std::string& key,
57  const std::string& unit,
58  const std::function<double ()>& function);
59  virtual ~ExportMethod();
60 
61  const std::string& get_key() const;
62  const std::string& get_unit() const;
63  std::function<double ()> get_function() const;
64  double get_min() const;
65  double get_max() const;
66 
67  double& get_min_by_ref();
68  double& get_max_by_ref();
69 
70  void set_min(double);
71  void set_max(double);
72 
73  void apply_color(double val, Core::Color& color) const;
74  void apply_line_width(double val, float& lineWidth) const;
75 
76 
77 
78  virtual void update_min_max() = 0;
79  virtual void update_min() = 0;
80  virtual void update_max() = 0;
81  virtual void scan_and_apply_color() = 0;
82  virtual void scan_and_apply_line_width() = 0;
83 
84  private:
86 
87  protected:
88  std::string key_;
89  std::string unit_;
90  std::function<double ()> function_;
91  double min_;
92  double max_;
93  };
94 
95 
96 
97  }
98 }
99 
100 
101 
102 #endif
Definition: Color.hpp:44
Definition: ExportMethod.hpp:46
double get_max() const
Definition: ExportMethod.cpp:80
double & get_min_by_ref()
Definition: ExportMethod.cpp:85
double & get_max_by_ref()
Definition: ExportMethod.cpp:90
double min_
Definition: ExportMethod.hpp:91
void set_max(double)
Definition: ExportMethod.cpp:100
void apply_color(double val, Core::Color &color) const
Definition: ExportMethod.cpp:120
virtual void update_min()=0
virtual ~ExportMethod()
Definition: ExportMethod.cpp:56
std::string unit_
Definition: ExportMethod.hpp:89
double max_
Definition: ExportMethod.hpp:92
virtual void update_min_max()=0
std::function< double()> get_function() const
Definition: ExportMethod.cpp:70
void apply_line_width(double val, float &lineWidth) const
Definition: ExportMethod.cpp:105
static std::string get_separator()
Definition: ExportMethod.cpp:40
static std::vector< ExportMethod * > & get_all()
Definition: ExportMethod.hpp:50
virtual void scan_and_apply_line_width()=0
double get_min() const
Definition: ExportMethod.cpp:75
std::string key_
Definition: ExportMethod.hpp:88
void set_min(double)
Definition: ExportMethod.cpp:95
const std::string & get_key() const
Definition: ExportMethod.cpp:60
virtual void scan_and_apply_color()=0
virtual void update_max()=0
const std::string & get_unit() const
Definition: ExportMethod.cpp:65
std::function< double()> function_
Definition: ExportMethod.hpp:90
Definition: Common.hpp:198