Back to index

salome-paravis  6.5.0
vtkSMMedGroupSelectionDomain.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 "vtkSMMedGroupSelectionDomain.h"
00021 
00022 #include "vtkObjectFactory.h"
00023 #include "vtkSMStringVectorProperty.h"
00024 #include "vtkStringList.h"
00025 
00026 #include <string>
00027 using std::string;
00028 
00029 vtkStandardNewMacro(vtkSMMedGroupSelectionDomain);
00030 
00031 vtkSMMedGroupSelectionDomain::vtkSMMedGroupSelectionDomain()
00032 {
00033 }
00034 
00035 vtkSMMedGroupSelectionDomain::~vtkSMMedGroupSelectionDomain()
00036 {
00037 }
00038 
00039 int vtkSMMedGroupSelectionDomain::SetDefaultValues(vtkSMProperty* prop)
00040 {
00041   vtkSMStringVectorProperty* svp = vtkSMStringVectorProperty::SafeDownCast(prop);
00042   if(!svp || this->GetNumberOfRequiredProperties() == 0)
00043     {
00044     return this->Superclass::SetDefaultValues(prop);
00045     }
00046 
00047   // info property has default values
00048   vtkSMStringVectorProperty* isvp = vtkSMStringVectorProperty::SafeDownCast(
00049     prop->GetInformationProperty());
00050   if (isvp)
00051     {
00052     vtkStringList* proplist = vtkStringList::New();
00053     svp->SetNumberOfElements(0);
00054     svp->SetNumberOfElementsPerCommand(2);
00055     for(int id=0; id<isvp->GetNumberOfElements(); id++)
00056       {
00057       string elem = isvp->GetElement(id);
00058       proplist->AddString(elem.c_str());
00059       if(elem.find("/OnCell/") != string::npos)
00060         {
00061         proplist->AddString("1");
00062         }
00063       else
00064         {
00065         proplist->AddString("0");
00066         }
00067       }
00068     svp->SetElements(proplist);
00069     proplist->Delete();
00070     }
00071 
00072   return 1;
00073 }
00074 
00075 void vtkSMMedGroupSelectionDomain::PrintSelf(ostream& os, vtkIndent indent)
00076 {
00077   this->Superclass::PrintSelf(os, indent);
00078 }