15 #ifndef vtkSMProxyPropertyInternals_h 16 #define vtkSMProxyPropertyInternals_h 46 SmartVectorOfProxies Proxies;
47 SmartVectorOfProxies PreviousProxies;
50 WeakVectorOfProxies UncheckedProxies;
53 VectorOfUInts PreviousPorts;
54 VectorOfUInts UncheckedPorts;
56 std::map<void*, unsigned long> ObserverIds;
59 void UpdateProducerConsumerLinks()
61 if (this->Self ==
nullptr || this->Self->
GetParent() ==
nullptr ||
62 this->PreviousProxies == this->Proxies)
70 typedef std::set<vtkSMProxy*> proxy_set;
71 proxy_set previous_proxies(this->PreviousProxies.begin(), this->PreviousProxies.end());
72 proxy_set proxies(this->Proxies.begin(), this->Proxies.end());
75 std::set_difference(previous_proxies.begin(), previous_proxies.end(), proxies.begin(),
76 proxies.end(), std::insert_iterator<proxy_set>(removed, removed.begin()));
77 for (proxy_set::iterator iter = removed.begin(); iter != removed.end(); ++iter)
84 this->ObserverIds.erase(producer);
87 producer->RemoveConsumer(
self, self->GetParent());
88 self->GetParent()->RemoveProducer(
self, producer);
94 std::set_difference(proxies.begin(), proxies.end(), previous_proxies.begin(),
95 previous_proxies.end(), std::insert_iterator<proxy_set>(added, added.begin()));
96 for (proxy_set::iterator iter = added.begin(); iter != added.end(); ++iter)
103 this->ObserverIds[producer] = producer->
AddObserver(
108 self->GetParent()->AddProducer(
self, producer);
111 this->PreviousProxies = this->Proxies;
114 bool CheckedValueChanged()
117 this->UpdateProducerConsumerLinks();
136 this->UncheckedProxies.push_back(proxy);
137 this->UncheckedPorts.push_back(
port);
144 this->Proxies.push_back(proxy);
145 this->Ports.push_back(
port);
146 return this->CheckedValueChanged();
151 SmartVectorOfProxies::iterator iter = this->Proxies.begin();
152 VectorOfUInts::iterator iter2 = this->Ports.begin();
153 for (; iter != this->Proxies.end() && iter2 != this->Ports.end(); ++iter, ++iter2)
155 if (iter->GetPointer() == proxy)
157 this->Proxies.erase(iter);
158 this->Ports.erase(iter2);
159 return this->CheckedValueChanged();
168 if (this->Proxies.size() != count)
170 this->Proxies.resize(count);
171 this->Ports.resize(count);
172 return this->CheckedValueChanged();
179 if (this->UncheckedProxies.size() != count)
181 this->UncheckedProxies.resize(count);
182 this->UncheckedPorts.resize(count);
190 if (this->Proxies.size() > 0)
192 this->Proxies.clear();
194 return this->CheckedValueChanged();
201 if (this->UncheckedProxies.size() > 0)
203 this->UncheckedProxies.clear();
204 this->UncheckedPorts.clear();
213 if (static_cast<unsigned int>(this->Proxies.size()) > index && this->Proxies[index] == proxy &&
214 this->Ports[index] ==
port)
218 if (static_cast<unsigned int>(this->Proxies.size()) <= index)
220 this->Proxies.resize(index + 1);
221 this->Ports.resize(index + 1);
223 this->Proxies[index] = proxy;
224 this->Ports[index] =
port;
225 return this->CheckedValueChanged();
230 if (static_cast<unsigned int>(this->UncheckedProxies.size()) > index &&
231 this->UncheckedProxies[index] == proxy && this->UncheckedPorts[index] ==
port)
235 if (static_cast<unsigned int>(this->UncheckedProxies.size()) <= index)
237 this->UncheckedProxies.resize(index + 1);
238 this->UncheckedPorts.resize(index + 1);
240 this->UncheckedProxies[index] = proxy;
241 this->UncheckedPorts[index] =
port;
246 bool Set(
unsigned int count,
vtkSMProxy** proxies,
const unsigned int* ports =
nullptr)
248 SmartVectorOfProxies newValues(proxies, proxies + count);
249 VectorOfUInts newPorts;
252 newPorts.insert(newPorts.end(), ports, ports + count);
256 newPorts.resize(count);
258 if (this->Proxies != newValues || this->Ports != newPorts)
260 this->Proxies = newValues;
261 this->Ports = newPorts;
262 return this->CheckedValueChanged();
268 bool SetProxies(
const SmartVectorOfProxies& otherProxies,
const VectorOfUInts& otherPorts)
270 if (this->Proxies != otherProxies || this->Ports != otherPorts)
272 this->Proxies = otherProxies;
273 this->Ports = otherPorts;
274 return this->CheckedValueChanged();
282 if (this->UncheckedProxies != otherProxies || this->UncheckedPorts != otherPorts)
284 this->UncheckedProxies = otherProxies;
285 this->UncheckedPorts = otherPorts;
296 SmartVectorOfProxies::iterator iter =
297 std::find(this->Proxies.begin(), this->Proxies.end(), proxy);
298 return (iter != this->Proxies.end());
301 const SmartVectorOfProxies&
GetProxies()
const {
return this->Proxies; }
303 const VectorOfUInts&
GetPorts()
const {
return this->Ports; }
309 return (index < static_cast<unsigned int>(this->Proxies.size())
310 ? this->Proxies[index].GetPointer()
316 if (this->UncheckedProxies.size() > 0)
318 return (index < static_cast<unsigned int>(this->UncheckedProxies.size())
319 ? this->UncheckedProxies[index].GetPointer()
322 return this->
Get(index);
325 unsigned int GetPort(
unsigned int index)
const 327 return (index < static_cast<unsigned int>(this->Ports.size()) ? this->Ports[index] : 0);
331 if (this->UncheckedPorts.size() > 0)
333 return (index < static_cast<unsigned int>(this->UncheckedPorts.size())
334 ? this->UncheckedPorts[index]
343 bool WriteTo(paraview_protobuf::Variant* variant)
const 345 variant->set_type(Variant::INPUT);
346 for (SmartVectorOfProxies::const_iterator iter = this->Proxies.begin();
347 iter != this->Proxies.end(); ++iter)
351 proxy->CreateVTKObjects();
352 variant->add_proxy_global_id(proxy->GetGlobalID());
356 variant->add_proxy_global_id(0);
359 for (VectorOfUInts::const_iterator iter = this->Ports.begin(); iter != this->Ports.end();
362 variant->add_port_number(*iter);
369 SmartVectorOfProxies proxies;
371 assert(variant.proxy_global_id_size() == variant.port_number_size());
372 for (
int cc = 0,
max = variant.proxy_global_id_size(); cc <
max; cc++)
374 vtkTypeUInt32 gid = variant.proxy_global_id(cc);
375 unsigned int port = variant.port_number(cc);
388 if (proxy !=
nullptr || gid == 0)
390 proxies.push_back(proxy);
391 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 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 Set(unsigned int index, vtkSMProxy *proxy, unsigned int port=0)
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 NULL;.
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)
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
bool Resize(unsigned int count)