Back to index

salome-med  6.5.0
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See or email :
00018 //
00023 #include "MedCalculatorDefines.hxx"
00024 #include "MEDCalculatorBrowserStep.hxx"
00026 #include "InterpKernelException.hxx"
00027 #include "MEDCouplingRefCountObject.hxx"
00029 #include <string>
00030 #include <vector>
00032 //  This class correspond to a MED field of a file
00033 //  It contains the field name, the components, the time steps and selection methods
00034 //  It's used to select a field, it's components and time steps
00035 namespace ParaMEDMEM
00036 {
00037   class MEDCalculatorBrowserStep;//  top prevent cross include
00038   class MEDCALCULATOR_EXPORT MEDCalculatorBrowserField
00039   {
00040   public :
00041     MEDCalculatorBrowserField(const char* nm);
00042     ~MEDCalculatorBrowserField();
00043     MEDCalculatorBrowserField(const char *fname, const char *fieldName);
00044     bool operator==(const std::string&);//  Equal to string operator, to test if fieldname of this field is the same as input argument
00045     bool operator==(bool);//  Equal to bool operator, to use with std::find on std::vector<CalculatorBrowserField> to find selected fields
00046     std::string str();//  Return a std::string corresponding to x/o (selected or not) Field fieldname \n steps
00047     void selectStep(int);//  Select a specific time step according to its id
00048     void selectAllSteps();//  Select all time steps
00049     void unselectStep(int);//  Unselect a specific time step according to its id
00050     void unselectAllSteps();// Unselect all time steps
00051     void selectComponent(int);//  Select a specific component according to its id
00052     void selectAllComponents();//  Select all components
00053     void unselectComponent(int);//  Unselect a specific component according to its id
00054     void unselectAllComponents();// Unselect all components
00055     bool isSelected();//  Return if this field is selected or not, i.e. selection flag to true or false
00056     const std::string& getFileName() const { return _file_name; }
00057     TypeOfField getType() const { return _type; }
00058     const std::string& getName() const;//  Return fieldname
00059     const std::vector<MEDCalculatorBrowserStep>& getSteps() const;//  Return a copy of the steps vector
00060     void setSteps(const std::vector<MEDCalculatorBrowserStep>& steps);
00061     const std::vector<std::string>& getComponents() const;//  Return the components vector
00062     const std::vector<bool>& getSelectedComponents() const;//  Return the selected components vector
00063     const double& getTimeValue(int) const;//  Return the time value of the time step with id equal to input
00064     unsigned int getStepsSize() const;//  Return the number of time steps
00065     unsigned int getComponentsSize() const;//  Return the number of components
00066     void addStep(int,double);//  Add a time step to steps vector with (id, time value)
00067     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
00068     const std::string& getCorrespondingMeshFromStep(int) const;//  Return a std::string which contains the mesh name used by the time steps (id) as supporting meshes
00069     void setComponentName(int,const std::string&);//  Change the name of a component
00070     bool isAnySelection() const;
00071     void setMeshName(const std::string& m);
00072     MEDCalculatorBrowserField getSelectedTimeSteps() const throw(INTERP_KERNEL::Exception);
00073   private:
00074     std::string _name;// field name
00075     std::string _file_name;// file name
00076     TypeOfField _type;
00077     std::vector<MEDCalculatorBrowserStep> _steps;// liste of time steps
00078     std::vector<std::string> _components;//  list of components
00079     std::vector<bool> _selected_components;//  list of selected components, by default, all
00080     bool _selection;//  select flag
00081     std::vector<std::string> _corresponding_meshes;//  vector containing all the meshes name used by time steps as support
00082   };
00083 }
00085 #endif