3 #ifndef vtkSMProxyPropertyInternals_h
4 #define vtkSMProxyPropertyInternals_h
45 std::map<void*, unsigned long> ObserverIds;
47 void UpdateProducerConsumerLinks()
49 if (this->Self ==
nullptr || this->Self->
GetParent() ==
nullptr ||
50 this->PreviousProxies == this->Proxies)
58 typedef std::set<vtkSMProxy*> proxy_set;
59 proxy_set previous_proxies(this->PreviousProxies.begin(), this->PreviousProxies.end());
60 proxy_set proxies(this->Proxies.begin(), this->Proxies.end());
63 std::set_difference(previous_proxies.begin(), previous_proxies.end(), proxies.begin(),
64 proxies.end(), std::insert_iterator<proxy_set>(removed, removed.begin()));
65 for (proxy_set::iterator iter = removed.begin(); iter != removed.end(); ++iter)
72 this->ObserverIds.erase(producer);
75 producer->RemoveConsumer(
self, self->GetParent());
76 self->GetParent()->RemoveProducer(
self, producer);
82 std::set_difference(proxies.begin(), proxies.end(), previous_proxies.begin(),
83 previous_proxies.end(), std::insert_iterator<proxy_set>(added, added.begin()));
84 for (proxy_set::iterator iter = added.begin(); iter != added.end(); ++iter)
91 this->ObserverIds[producer] = producer->
AddObserver(
96 self->GetParent()->AddProducer(
self, producer);
99 this->PreviousProxies = this->Proxies;
102 bool CheckedValueChanged()
105 this->UpdateProducerConsumerLinks();
124 this->UncheckedProxies.push_back(proxy);
125 this->UncheckedPorts.push_back(
port);
132 this->Proxies.push_back(proxy);
133 this->Ports.push_back(
port);
134 return this->CheckedValueChanged();
139 SmartVectorOfProxies::iterator iter = this->Proxies.begin();
140 VectorOfUInts::iterator iter2 = this->Ports.begin();
141 for (; iter != this->Proxies.end() && iter2 != this->Ports.end(); ++iter, ++iter2)
143 if (iter->GetPointer() == proxy)
145 this->Proxies.erase(iter);
146 this->Ports.erase(iter2);
147 return this->CheckedValueChanged();
156 if (this->Proxies.size() != count)
158 this->Proxies.resize(count);
159 this->Ports.resize(count);
160 return this->CheckedValueChanged();
167 if (this->UncheckedProxies.size() != count)
169 this->UncheckedProxies.resize(count);
170 this->UncheckedPorts.resize(count);
178 if (!this->Proxies.empty())
180 this->Proxies.clear();
182 return this->CheckedValueChanged();
189 if (!this->UncheckedProxies.empty())
191 this->UncheckedProxies.clear();
192 this->UncheckedPorts.clear();
201 if (
static_cast<unsigned int>(this->Proxies.size()) >
index && this->Proxies[
index] == proxy &&
206 if (
static_cast<unsigned int>(this->Proxies.size()) <=
index)
208 this->Proxies.resize(
index + 1);
209 this->Ports.resize(
index + 1);
211 this->Proxies[
index] = proxy;
213 return this->CheckedValueChanged();
218 if (
static_cast<unsigned int>(this->UncheckedProxies.size()) >
index &&
219 this->UncheckedProxies[
index] == proxy && this->UncheckedPorts[
index] ==
port)
223 if (
static_cast<unsigned int>(this->UncheckedProxies.size()) <=
index)
225 this->UncheckedProxies.resize(
index + 1);
226 this->UncheckedPorts.resize(
index + 1);
228 this->UncheckedProxies[
index] = proxy;
234 bool Set(
unsigned int count,
vtkSMProxy** proxies,
const unsigned int* ports =
nullptr)
240 newPorts.insert(newPorts.end(), ports, ports + count);
244 newPorts.resize(count);
246 if (this->Proxies != newValues || this->Ports != newPorts)
248 this->Proxies = newValues;
249 this->Ports = newPorts;
250 return this->CheckedValueChanged();
258 if (this->Proxies != otherProxies || this->Ports != otherPorts)
260 this->Proxies = otherProxies;
261 this->Ports = otherPorts;
262 return this->CheckedValueChanged();
270 if (this->UncheckedProxies != otherProxies || this->UncheckedPorts != otherPorts)
272 this->UncheckedProxies = otherProxies;
273 this->UncheckedPorts = otherPorts;
284 SmartVectorOfProxies::iterator iter =
285 std::find(this->Proxies.begin(), this->Proxies.end(), proxy);
286 return (iter != this->Proxies.end());
297 return (
index <
static_cast<unsigned int>(this->Proxies.size())
298 ? this->Proxies[
index].GetPointer()
304 if (!this->UncheckedProxies.empty())
306 return (
index <
static_cast<unsigned int>(this->UncheckedProxies.size())
307 ? this->UncheckedProxies[
index].GetPointer()
310 return this->
Get(index);
313 unsigned int GetPort(
unsigned int index)
const
315 return (
index <
static_cast<unsigned int>(this->Ports.size()) ? this->Ports[
index] : 0);
319 if (!this->UncheckedPorts.empty())
321 return (
index <
static_cast<unsigned int>(this->UncheckedPorts.size())
322 ? this->UncheckedPorts[
index]
331 bool WriteTo(paraview_protobuf::Variant* variant)
const
333 variant->set_type(Variant::INPUT);
334 for (SmartVectorOfProxies::const_iterator iter = this->Proxies.begin();
335 iter != this->Proxies.end(); ++iter)
339 proxy->CreateVTKObjects();
340 variant->add_proxy_global_id(proxy->GetGlobalID());
344 variant->add_proxy_global_id(0);
347 for (VectorOfUInts::const_iterator iter = this->Ports.begin(); iter != this->Ports.end();
350 variant->add_port_number(*iter);
359 assert(variant.proxy_global_id_size() == variant.port_number_size());
360 for (
int cc = 0,
max = variant.proxy_global_id_size(); cc <
max; cc++)
362 vtkTypeUInt32 gid = variant.proxy_global_id(cc);
363 unsigned int port = variant.port_number(cc);
376 if (proxy !=
nullptr || gid == 0)
378 proxies.push_back(proxy);
379 ports.push_back(
port);