Salome HOME
5d5b89239a486d643b0e42343cd8e57f99f14d33
[modules/med.git] / src / MEDCalculator / MEDCalculatorBrowserStep.cxx
1 // Copyright (C) 2007-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDCalculatorBrowserStep.hxx"
22
23 #include <sstream>
24
25 using namespace MEDCoupling;
26
27 MEDCalculatorBrowserStep::~MEDCalculatorBrowserStep()
28 {
29 }
30
31 //  Equal to int operator
32 //  Used to compare the time step id with input argument.
33 //  Return if equal or not.
34 bool MEDCalculatorBrowserStep::operator==(int ts)
35 {
36   return _time_step==ts;
37 }
38
39 //  Equal to int operator
40 //  Used to compare the time step id with input argument.
41 //  Return if equal or not.
42 bool MEDCalculatorBrowserStep::operator==(int ts) const
43 {
44   return _time_step==ts;
45 }
46
47 //  Equal to bool operator
48 //  To test if this time step is selected or not comparing to a boolean
49 //  Return if it has the same statement or not.
50 bool MEDCalculatorBrowserStep::operator==(bool sel)
51 {
52   return sel==_selection;
53 }
54
55 //  str method
56 //  Construct a std::string to print this time step, using std::cout for example
57 //  Put x or o for selected or not
58 //  Add time step id value ( time value )
59 //  Return a std::string
60 std::string MEDCalculatorBrowserStep::str()
61 {
62   std::ostringstream res;
63   _selection?res<<"x ":res<<"o ";
64   res << _time_step << "," << _order;
65   res << " (";
66   res << _time_value;
67   res << ")";
68   return res.str();
69 }
70
71 //  Select this time step setting selection flag to true
72 void MEDCalculatorBrowserStep::select()
73 {
74   _selection = true;
75 }
76
77 //  Unselect this time step setting selection flag to false
78 void MEDCalculatorBrowserStep::unselect()
79 {
80   _selection = false;
81 }
82
83 //  Return if this time step is selected or not
84 bool MEDCalculatorBrowserStep::isSelected()
85 {
86   return _selection;
87 }
88
89 //  Return the timestep id
90 int MEDCalculatorBrowserStep::getTimeStep() const
91 {
92   return _time_step;
93 }
94
95 //  Return the time value
96 const double& MEDCalculatorBrowserStep::getTimeValue() const
97 {
98   return _time_value;
99 }
100
101 //  Return the name of the support meshing
102 const std::string& MEDCalculatorBrowserStep::getCorrespondingMeshFromStep() const
103 {
104   return _mesh;
105 }