1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __MEDCALCULATORBROWSERFIELD_HXX__
22 #define __MEDCALCULATORBROWSERFIELD_HXX__
24 #include "MedCalculatorDefines.hxx"
25 #include "MEDCalculatorBrowserStep.hxx"
27 #include "InterpKernelException.hxx"
28 #include "MEDCouplingRefCountObject.hxx"
33 // This class correspond to a MED field of a file
34 // It contains the field name, the components, the time steps and selection methods
35 // It's used to select a field, it's components and time steps
38 class MEDCalculatorBrowserStep;// top prevent cross include
39 class MEDCALCULATOR_EXPORT MEDCalculatorBrowserField
42 MEDCalculatorBrowserField(const char* nm);
43 ~MEDCalculatorBrowserField();
44 MEDCalculatorBrowserField(const char *fname, const char *fieldName);
45 bool operator==(const std::string&);// Equal to string operator, to test if fieldname of this field is the same as input argument
46 bool operator==(bool);// Equal to bool operator, to use with std::find on std::vector<CalculatorBrowserField> to find selected fields
47 std::string str();// Return a std::string corresponding to x/o (selected or not) Field fieldname \n steps
48 void selectStep(int);// Select a specific time step according to its id
49 void selectAllSteps();// Select all time steps
50 void unselectStep(int);// Unselect a specific time step according to its id
51 void unselectAllSteps();// Unselect all time steps
52 void selectComponent(int);// Select a specific component according to its id
53 void selectAllComponents();// Select all components
54 void unselectComponent(int);// Unselect a specific component according to its id
55 void unselectAllComponents();// Unselect all components
56 bool isSelected();// Return if this field is selected or not, i.e. selection flag to true or false
57 const std::string& getFileName() const { return _file_name; }
58 TypeOfField getType() const { return _type; }
59 const std::string& getName() const;// Return fieldname
60 const std::vector<MEDCalculatorBrowserStep>& getSteps() const;// Return a copy of the steps vector
61 void setSteps(const std::vector<MEDCalculatorBrowserStep>& steps);
62 const std::vector<std::string>& getComponents() const;// Return the components vector
63 const std::vector<bool>& getSelectedComponents() const;// Return the selected components vector
64 const double& getTimeValue(int) const;// Return the time value of the time step with id equal to input
65 unsigned int getStepsSize() const;// Return the number of time steps
66 unsigned int getComponentsSize() const;// Return the number of components
67 void addStep(int,double);// Add a time step to steps vector with (id, time value)
68 const std::vector<std::string>& getCorrespondingMeshesFromField() const;// Return a std::vector of std::string which contains all the meshes name used by all the time steps as supporting meshes
69 const std::string& getCorrespondingMeshFromStep(int) const;// Return a std::string which contains the mesh name used by the time steps (id) as supporting meshes
70 void setComponentName(int,const std::string&);// Change the name of a component
71 bool isAnySelection() const;
72 void setMeshName(const std::string& m);
73 MEDCalculatorBrowserField getSelectedTimeSteps() const throw(INTERP_KERNEL::Exception);
75 std::string _name;// field name
76 std::string _file_name;// file name
78 std::vector<MEDCalculatorBrowserStep> _steps;// liste of time steps
79 std::vector<std::string> _components;// list of components
80 std::vector<bool> _selected_components;// list of selected components, by default, all
81 bool _selection;// select flag
82 std::vector<std::string> _corresponding_meshes;// vector containing all the meshes name used by time steps as support