Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDCalculator / MEDCalculatorBrowserStep.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
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.
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
20 #include "MEDCalculatorBrowserStep.hxx"
21
22 #include <sstream>
23
24 using namespace ParaMEDMEM;
25
26 MEDCalculatorBrowserStep::~MEDCalculatorBrowserStep()
27 {
28 }
29
30 //  Equal to int operator
31 //  Used to compare the time step id with input argument.
32 //  Return if equal or not.
33 bool MEDCalculatorBrowserStep::operator==(int ts)
34 {
35   return _time_step==ts;
36 }
37
38 //  Equal to int operator
39 //  Used to compare the time step id with input argument.
40 //  Return if equal or not.
41 bool MEDCalculatorBrowserStep::operator==(int ts) const
42 {
43   return _time_step==ts;
44 }
45
46 //  Equal to bool operator
47 //  To test if this time step is selected or not comparing to a boolean
48 //  Return if it has the same statement or not.
49 bool MEDCalculatorBrowserStep::operator==(bool sel)
50 {
51   return sel==_selection;
52 }
53
54 //  str method
55 //  Construct a std::string to print this time step, using std::cout for example
56 //  Put x or o for selected or not
57 //  Add time step id value ( tiem value )
58 //  Return a std::string
59 std::string MEDCalculatorBrowserStep::str()
60 {
61   std::ostringstream res;
62   _selection?res<<"x ":res<<"o ";
63   res << _time_step << "," << _order;
64   res << " (";
65   res << _time_value;
66   res << ")";
67   return res.str();
68 }
69
70 //  Select this time step setting selection flag to true
71 void MEDCalculatorBrowserStep::select()
72 {
73   _selection = true;
74 }
75
76 //  Unselect this time step setting selection flag to false
77 void MEDCalculatorBrowserStep::unselect()
78 {
79   _selection = false;
80 }
81
82 //  Return if this time step is selected or not
83 bool MEDCalculatorBrowserStep::isSelected()
84 {
85   return _selection;
86 }
87
88 //  Return the timestep id
89 int MEDCalculatorBrowserStep::getTimeStep() const
90 {
91   return _time_step;
92 }
93
94 //  Return the time value
95 const double& MEDCalculatorBrowserStep::getTimeValue() const
96 {
97   return _time_value;
98 }
99
100 //  Return the name of the support meshing
101 const std::string& MEDCalculatorBrowserStep::getCorrespondingMeshFromStep() const
102 {
103   return _mesh;
104 }