1 // Copyright (C) 2010-2011 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.
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
20 #include "vtkMedSelection.h"
22 #include "vtkObjectFactory.h"
23 #include "vtkStringArray.h"
30 class vtkMedSelectionInternals
33 map< string, bool > Status;
34 vector< string > Keys;
37 // vtkCxxRevisionMacro(vtkMedSelection, "$Revision$")
38 vtkStandardNewMacro(vtkMedSelection)
40 vtkMedSelection::vtkMedSelection()
42 this->Internals = new vtkMedSelectionInternals();
45 vtkMedSelection::~vtkMedSelection()
47 delete this->Internals;
50 void vtkMedSelection::Initialize()
52 this->Internals->Status.clear();
53 this->Internals->Keys.clear();
56 void vtkMedSelection::AddKey(const char* key)
58 if(this->Internals->Status.find(key) != this->Internals->Status.end())
62 this->Internals->Keys.push_back(key);
63 this->Internals->Status[key] = 1;
66 void vtkMedSelection::SetKeyStatus(const char* key, int status)
68 if(this->Internals->Status.find(key) == this->Internals->Status.end())
72 this->Internals->Status[key] = status;
75 int vtkMedSelection::GetKeyStatus(const char* key)
77 if(this->Internals->Status.find(key) == this->Internals->Status.end())
81 return this->Internals->Status[key];
84 const char* vtkMedSelection::GetKey(int index)
86 if(index < 0 || index >= this->Internals->Keys.size())
90 return this->Internals->Keys[index].c_str();
93 int vtkMedSelection::GetNumberOfKey()
95 return this->Internals->Keys.size();
98 int vtkMedSelection::KeyExists(const char *key)
100 return this->Internals->Status.find(key)
101 != this->Internals->Status.end();
104 void vtkMedSelection::RemoveKeyByIndex(int index)
106 if(index < 0 || index >= this->Internals->Keys.size())
110 string name = this->Internals->Keys[index];
111 this->Internals->Status.erase(name);
112 this->Internals->Keys.erase(this->Internals->Keys.begin() + index);
115 void vtkMedSelection::PrintSelf(ostream& os, vtkIndent indent)
117 this->Superclass::PrintSelf(os, indent);