3 #ifndef vtkSMProxyPropertyInternals_h 4 #define vtkSMProxyPropertyInternals_h 36 SmartVectorOfProxies Proxies;
37 SmartVectorOfProxies PreviousProxies;
40 WeakVectorOfProxies UncheckedProxies;
41 WeakVectorOfProxies DefaultProxies;
44 VectorOfUInts PreviousPorts;
45 VectorOfUInts UncheckedPorts;
46 VectorOfUInts DefaultPorts;
48 std::map<void*, unsigned long> ObserverIds;
50 void UpdateProducerConsumerLinks()
52 if (this->Self ==
nullptr || this->Self->
GetParent() ==
nullptr ||
53 this->PreviousProxies == this->Proxies)
61 typedef std::set<vtkSMProxy*> proxy_set;
62 proxy_set previous_proxies(this->PreviousProxies.begin(), this->PreviousProxies.end());
63 proxy_set proxies(this->Proxies.begin(), this->Proxies.end());
66 std::set_difference(previous_proxies.begin(), previous_proxies.end(), proxies.begin(),
67 proxies.end(), std::insert_iterator<proxy_set>(removed, removed.begin()));
68 for (proxy_set::iterator iter = removed.begin(); iter != removed.end(); ++iter)
75 this->ObserverIds.erase(producer);
78 producer->RemoveConsumer(
self, self->GetParent());
79 self->GetParent()->RemoveProducer(
self, producer);
85 std::set_difference(proxies.begin(), proxies.end(), previous_proxies.begin(),
86 previous_proxies.end(), std::insert_iterator<proxy_set>(added, added.begin()));
87 for (proxy_set::iterator iter = added.begin(); iter != added.end(); ++iter)
94 this->ObserverIds[producer] = producer->
AddObserver(
99 self->GetParent()->AddProducer(
self, producer);
102 this->PreviousProxies = this->Proxies;
105 bool CheckedValueChanged()
108 this->UpdateProducerConsumerLinks();
127 this->UncheckedProxies.push_back(proxy);
128 this->UncheckedPorts.push_back(
port);
135 this->Proxies.push_back(proxy);
136 this->Ports.push_back(
port);
137 return this->CheckedValueChanged();
142 SmartVectorOfProxies::iterator iter = this->Proxies.begin();
143 VectorOfUInts::iterator iter2 = this->Ports.begin();
144 for (; iter != this->Proxies.end() && iter2 != this->Ports.end(); ++iter, ++iter2)
146 if (iter->GetPointer() == proxy)
148 this->Proxies.erase(iter);
149 this->Ports.erase(iter2);
150 return this->CheckedValueChanged();
159 if (this->Proxies.size() != count)
161 this->Proxies.resize(count);
162 this->Ports.resize(count);
163 return this->CheckedValueChanged();
170 if (this->UncheckedProxies.size() != count)
172 this->UncheckedProxies.resize(count);
173 this->UncheckedPorts.resize(count);
181 if (!this->Proxies.empty())
183 this->Proxies.clear();
185 return this->CheckedValueChanged();
192 if (!this->UncheckedProxies.empty())
194 this->UncheckedProxies.clear();
195 this->UncheckedPorts.clear();
204 this->DefaultProxies.clear();
205 this->DefaultPorts.clear();
207 size_t count = this->Proxies.size();
208 this->DefaultProxies.resize(count);
209 this->DefaultPorts.resize(count);
211 for (
size_t i = 0; i < count; ++i)
213 this->DefaultProxies[i] = this->Proxies[i].Get();
214 this->DefaultPorts[i] = this->Ports[i];
221 size_t count = this->Proxies.size();
222 if (this->DefaultProxies.size() != count || this->DefaultPorts.size() != count)
227 for (
size_t i = 0; i < count; ++i)
230 if (this->Proxies[i].
Get() != this->DefaultProxies[i].Get() ||
231 this->Ports[i] != this->DefaultPorts[i])
245 if (!prop->IsValueDefault() && !prop->GetIsInternal())
259 if (static_cast<unsigned int>(this->Proxies.size()) > index && this->Proxies[index] == proxy &&
260 this->Ports[index] ==
port)
264 if (static_cast<unsigned int>(this->Proxies.size()) <= index)
266 this->Proxies.resize(index + 1);
267 this->Ports.resize(index + 1);
269 this->Proxies[index] = proxy;
270 this->Ports[index] =
port;
271 return this->CheckedValueChanged();
276 if (static_cast<unsigned int>(this->UncheckedProxies.size()) > index &&
277 this->UncheckedProxies[index] == proxy && this->UncheckedPorts[index] ==
port)
281 if (static_cast<unsigned int>(this->UncheckedProxies.size()) <= index)
283 this->UncheckedProxies.resize(index + 1);
284 this->UncheckedPorts.resize(index + 1);
286 this->UncheckedProxies[index] = proxy;
287 this->UncheckedPorts[index] =
port;
292 bool Set(
unsigned int count,
vtkSMProxy** proxies,
const unsigned int* ports =
nullptr)
294 SmartVectorOfProxies newValues(proxies, proxies + count);
295 VectorOfUInts newPorts;
298 newPorts.insert(newPorts.end(), ports, ports + count);
302 newPorts.resize(count);
304 if (this->Proxies != newValues || this->Ports != newPorts)
306 this->Proxies = newValues;
307 this->Ports = newPorts;
308 return this->CheckedValueChanged();
314 bool SetProxies(
const SmartVectorOfProxies& otherProxies,
const VectorOfUInts& otherPorts)
316 if (this->Proxies != otherProxies || this->Ports != otherPorts)
318 this->Proxies = otherProxies;
319 this->Ports = otherPorts;
320 return this->CheckedValueChanged();
328 if (this->UncheckedProxies != otherProxies || this->UncheckedPorts != otherPorts)
330 this->UncheckedProxies = otherProxies;
331 this->UncheckedPorts = otherPorts;
342 SmartVectorOfProxies::iterator iter =
343 std::find(this->Proxies.begin(), this->Proxies.end(), proxy);
344 return (iter != this->Proxies.end());
347 const SmartVectorOfProxies&
GetProxies()
const {
return this->Proxies; }
349 const VectorOfUInts&
GetPorts()
const {
return this->Ports; }
355 return (index < static_cast<unsigned int>(this->Proxies.size())
356 ? this->Proxies[index].GetPointer()
362 if (!this->UncheckedProxies.empty())
364 return (index < static_cast<unsigned int>(this->UncheckedProxies.size())
365 ? this->UncheckedProxies[index].GetPointer()
368 return this->
Get(index);
371 unsigned int GetPort(
unsigned int index)
const 373 return (index < static_cast<unsigned int>(this->Ports.size()) ? this->Ports[index] : 0);
377 if (!this->UncheckedPorts.empty())
379 return (index < static_cast<unsigned int>(this->UncheckedPorts.size())
380 ? this->UncheckedPorts[index]
389 bool WriteTo(paraview_protobuf::Variant* variant)
const 391 variant->set_type(Variant::INPUT);
392 for (SmartVectorOfProxies::const_iterator iter = this->Proxies.begin();
393 iter != this->Proxies.end(); ++iter)
397 proxy->CreateVTKObjects();
398 variant->add_proxy_global_id(proxy->GetGlobalID());
402 variant->add_proxy_global_id(0);
405 for (VectorOfUInts::const_iterator iter = this->Ports.begin(); iter != this->Ports.end();
408 variant->add_port_number(*iter);
415 SmartVectorOfProxies proxies;
417 assert(variant.proxy_global_id_size() == variant.port_number_size());
418 for (
int cc = 0,
max = variant.proxy_global_id_size(); cc <
max; cc++)
420 vtkTypeUInt32 gid = variant.proxy_global_id(cc);
421 unsigned int port = variant.port_number(cc);
434 if (proxy !=
nullptr || gid == 0)
436 proxies.push_back(proxy);
437 ports.push_back(port);
bool ResizeUnchecked(unsigned int count)
const VectorOfUInts & GetUncheckedPorts() const
vtkPPInternals(vtkSMProxyProperty *self)
static bool CanCreateProxy()
When we load ProxyManager state we want Proxy/InputProperty to be able to create the corresponding mi...
virtual vtkSMProperty * GetProperty()
Returns the property at the current iterator position.
virtual void AddConsumer(vtkSMProperty *property, vtkSMProxy *proxy)
Called by a proxy property, this adds the property,proxy pair to the list of consumers.
property representing pointer(s) to vtkObject(s)
bool IsValueDefault(bool recursive)
bool Set(unsigned int index, vtkSMProxy *proxy, unsigned int port=0)
virtual int IsAtEnd()
Returns true if iterator points past the end of the collection.
unsigned long AddObserver(unsigned long event, vtkCommand *, float priority=0.0f)
vtkSMProxy * GetUnchecked(unsigned int index) const
void RemoveObserver(unsigned long tag)
std::vector< unsigned int > VectorOfUInts
const SmartVectorOfProxies & GetProxies() const
virtual vtkSMProxy * LocateProxy(vtkTypeUInt32 globalID)
Locate a proxy with the given "name".
bool ReadFrom(const paraview_protobuf::Variant &variant, vtkSMProxyLocator *locator)
bool SetProxies(const SmartVectorOfProxies &otherProxies, const VectorOfUInts &otherPorts)
bool IsAdded(vtkSMProxy *proxy)
bool Set(unsigned int count, vtkSMProxy **proxies, const unsigned int *ports=nullptr)
bool Remove(vtkSMProxy *proxy)
static vtkSMProxy * SafeDownCast(vtkObject *o)
bool WriteTo(paraview_protobuf::Variant *variant) const
void OnUpdateDataEvent()
Called when a producer fires the vtkCommand::UpdateDataEvent.
This class is used by vtkSMProxyProperty to keep track of the proxies.
const VectorOfUInts & GetPorts() const
bool SetUncheckedProxies(const WeakVectorOfProxies &otherProxies, const VectorOfUInts &otherPorts)
vtkObject * GetRemoteObject(vtkTypeUInt32 globalid)
Return a vtkSMRemoteObject given its global id if any otherwise return nullptr;.
proxy for a VTK object(s) on a server
is used to locate proxies referred to in state xmls while loading state files.
bool SetUnchecked(unsigned int index, vtkSMProxy *proxy, unsigned int port=0)
bool Add(vtkSMProxy *proxy, unsigned int port=0)
void ResetDefaultsToCurrent()
virtual void Begin()
Go to the first property.
vtkSMProxy * GetParent()
Get the proxy to which this property belongs.
virtual vtkSMSession * GetSession()
Get/Set the session on wihch this object exists.
bool AddUnchecked(vtkSMProxy *proxy, unsigned int port=0)
unsigned int GetUncheckedPort(unsigned int index) const
unsigned int GetPort(unsigned int index) const
const WeakVectorOfProxies & GetUncheckedProxies() const
std::vector< vtkWeakPointer< vtkSMProxy > > WeakVectorOfProxies
std::vector< vtkSmartPointer< vtkSMProxy > > SmartVectorOfProxies
vtkSMProxy * Get(unsigned int index) const
virtual void Next()
Move to the next property.
bool Resize(unsigned int count)