3 #ifndef vtkSMProxyPropertyInternals_h 4 #define vtkSMProxyPropertyInternals_h 35 SmartVectorOfProxies Proxies;
36 SmartVectorOfProxies PreviousProxies;
39 WeakVectorOfProxies UncheckedProxies;
42 VectorOfUInts PreviousPorts;
43 VectorOfUInts UncheckedPorts;
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 &&
202 this->Ports[index] ==
port)
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;
212 this->Ports[index] =
port;
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;
229 this->UncheckedPorts[index] =
port;
234 bool Set(
unsigned int count,
vtkSMProxy** proxies,
const unsigned int* ports =
nullptr)
236 SmartVectorOfProxies newValues(proxies, proxies + count);
237 VectorOfUInts newPorts;
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();
256 bool SetProxies(
const SmartVectorOfProxies& otherProxies,
const VectorOfUInts& otherPorts)
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());
289 const SmartVectorOfProxies&
GetProxies()
const {
return this->Proxies; }
291 const VectorOfUInts&
GetPorts()
const {
return this->Ports; }
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);
357 SmartVectorOfProxies proxies;
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);
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 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)
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)