1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/*=========================================================================
Program: ParaView
Module: vtkSMDomainIterator.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkSMDomainIterator.h"
#include "vtkObjectFactory.h"
#include "vtkSMProperty.h"
#include "vtkSMPropertyInternals.h"
vtkStandardNewMacro(vtkSMDomainIterator);
struct vtkSMDomainIteratorInternals
{
vtkSMPropertyInternals::DomainMap::iterator DomainIterator;
};
//---------------------------------------------------------------------------
vtkSMDomainIterator::vtkSMDomainIterator()
{
this->Property = 0;
this->Internals = new vtkSMDomainIteratorInternals;
}
//---------------------------------------------------------------------------
vtkSMDomainIterator::~vtkSMDomainIterator()
{
if (this->Property)
{
this->Property->Delete();
}
delete this->Internals;
}
//---------------------------------------------------------------------------
void vtkSMDomainIterator::SetProperty(vtkSMProperty* proxy)
{
if (this->Property != proxy)
{
if (this->Property != NULL) { this->Property->UnRegister(this); }
this->Property = proxy;
if (this->Property != NULL)
{
this->Property->Register(this);
this->Begin();
}
this->Modified();
}
}
//---------------------------------------------------------------------------
void vtkSMDomainIterator::Begin()
{
if (!this->Property)
{
vtkErrorMacro("Property is not set. Can not perform operation: Begin()");
return;
}
this->Internals->DomainIterator =
this->Property->PInternals->Domains.begin();
}
//---------------------------------------------------------------------------
int vtkSMDomainIterator::IsAtEnd()
{
if (!this->Property)
{
vtkErrorMacro("Property is not set. Can not perform operation: IsAtEnd()");
return 1;
}
if ( this->Internals->DomainIterator ==
this->Property->PInternals->Domains.end() )
{
return 1;
}
return 0;
}
//---------------------------------------------------------------------------
void vtkSMDomainIterator::Next()
{
if (!this->Property)
{
vtkErrorMacro("Property is not set. Can not perform operation: Next()");
return;
}
if (this->Internals->DomainIterator !=
this->Property->PInternals->Domains.end())
{
this->Internals->DomainIterator++;
return;
}
}
//---------------------------------------------------------------------------
const char* vtkSMDomainIterator::GetKey()
{
if (!this->Property)
{
vtkErrorMacro("Property is not set. Can not perform operation: GetKey()");
return 0;
}
if (this->Internals->DomainIterator !=
this->Property->PInternals->Domains.end())
{
return this->Internals->DomainIterator->first.c_str();
}
return 0;
}
//---------------------------------------------------------------------------
vtkSMDomain* vtkSMDomainIterator::GetDomain()
{
if (!this->Property)
{
vtkErrorMacro("Property is not set. Can not perform operation: GetProperty()");
return 0;
}
if (this->Internals->DomainIterator !=
this->Property->PInternals->Domains.end())
{
return this->Internals->DomainIterator->second.GetPointer();
}
return 0;
}
//---------------------------------------------------------------------------
void vtkSMDomainIterator::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Property: " << this->Property << endl;
}
|