Back to index

salome-paravis  6.5.0
vtkMedSelection.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-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
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "vtkMedSelection.h"
00021 
00022 #include "vtkObjectFactory.h"
00023 #include "vtkStringArray.h"
00024 
00025 #include <map>
00026 #include <string>
00027 #include <vector>
00028 using namespace std;
00029 
00030 class vtkMedSelectionInternals
00031 {
00032 public :
00033   map< string, bool > Status;
00034   vector< string > Keys;
00035 };
00036 
00037 vtkCxxRevisionMacro(vtkMedSelection, "$Revision: 1.1.4.5.2.1 $")
00038 vtkStandardNewMacro(vtkMedSelection)
00039 
00040 vtkMedSelection::vtkMedSelection()
00041 {
00042   this->Internals = new vtkMedSelectionInternals();
00043 }
00044 
00045 vtkMedSelection::~vtkMedSelection()
00046 {
00047   delete this->Internals;
00048 }
00049 
00050 void  vtkMedSelection::Initialize()
00051 {
00052   this->Internals->Status.clear();
00053   this->Internals->Keys.clear();
00054 }
00055 
00056 void  vtkMedSelection::AddKey(const char* key)
00057 {
00058   if(this->Internals->Status.find(key) != this->Internals->Status.end())
00059     {
00060     return ;
00061     }
00062   this->Internals->Keys.push_back(key);
00063   this->Internals->Status[key] = 1;
00064 }
00065 
00066 void  vtkMedSelection::SetKeyStatus(const char* key, int status)
00067 {
00068   if(this->Internals->Status.find(key) == this->Internals->Status.end())
00069     {
00070     this->AddKey(key);
00071     }
00072   this->Internals->Status[key] = status;
00073 }
00074 
00075 int vtkMedSelection::GetKeyStatus(const char* key)
00076 {
00077   if(this->Internals->Status.find(key) == this->Internals->Status.end())
00078     {
00079     return 0;
00080     }
00081   return this->Internals->Status[key];
00082 }
00083 
00084 const char* vtkMedSelection::GetKey(int index)
00085 {
00086   if(index < 0  || index >= this->Internals->Keys.size())
00087     {
00088     return NULL;
00089     }
00090   return this->Internals->Keys[index].c_str();
00091 }
00092 
00093 int vtkMedSelection::GetNumberOfKey()
00094 {
00095   return this->Internals->Keys.size();
00096 }
00097 
00098 int vtkMedSelection::KeyExists(const char *key)
00099 {
00100   return this->Internals->Status.find(key)
00101       != this->Internals->Status.end();
00102 }
00103 
00104 void  vtkMedSelection::RemoveKeyByIndex(int index)
00105 {
00106   if(index < 0  || index >= this->Internals->Keys.size())
00107     {
00108     return;
00109     }
00110   string name = this->Internals->Keys[index];
00111   this->Internals->Status.erase(name);
00112   this->Internals->Keys.erase(this->Internals->Keys.begin() + index);
00113 }
00114 
00115 void vtkMedSelection::PrintSelf(ostream& os, vtkIndent indent)
00116 {
00117   this->Superclass::PrintSelf(os, indent);
00118 }