vtkSMProxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
118 #ifndef vtkSMProxy_h
119 #define vtkSMProxy_h
120 
121 #include "vtkClientServerID.h" // needed for vtkClientServerID
122 #include "vtkRemotingServerManagerModule.h" //needed for exports
123 #include "vtkSMRemoteObject.h"
124 
125 struct vtkSMProxyInternals;
126 
128 class vtkPVInformation;
129 class vtkSMLoadStateContext;
130 class vtkPVXMLElement;
131 class vtkSMDocumentation;
132 class vtkSMProperty;
133 class vtkSMPropertyGroup;
135 class vtkSMProxyLocator;
136 class vtkSMProxyManager;
138 class vtkSMProxyObserver;
139 
140 class VTKREMOTINGSERVERMANAGER_EXPORT vtkSMProxy : public vtkSMRemoteObject
141 {
142 public:
143  static vtkSMProxy* New();
145  void PrintSelf(ostream& os, vtkIndent indent) override;
146 
148 
152  vtkSetMacro(ThreadedUpdate, bool);
153  vtkGetMacro(ThreadedUpdate, bool);
154  vtkBooleanMacro(ThreadedUpdate, bool);
156 
157  // Description:
158  // Set or override a key/value pair as annotation to that proxy.
159  // If the value is nullptr, this method is equivalent to RemoveAnnotation(key)
160  void SetAnnotation(const char* key, const char* value);
161 
166  const char* GetAnnotation(const char* key);
167 
171  void RemoveAnnotation(const char* key);
172 
176  void RemoveAllAnnotations();
177 
181  bool HasAnnotation(const char* key);
182 
186  int GetNumberOfAnnotations();
187 
191  const char* GetAnnotationKeyAt(int index);
192 
197  void SetLocation(vtkTypeUInt32) override;
198 
203  virtual vtkSMProperty* GetProperty(const char* name)
204  {
205  return this->GetProperty(name, /*self-only*/ 0);
206  }
207 
213  virtual vtkSMProperty* GetProperty(const char* name, int selfOnly);
214 
222  const char* GetPropertyName(vtkSMProperty* prop);
223 
229  virtual void UpdateVTKObjects();
230 
236  virtual void RecreateVTKObjects();
237 
239 
245  bool UpdateProperty(const char* name) { return this->UpdateProperty(name, 0); }
246  bool UpdateProperty(const char* name, int force);
248 
252  void InvokeCommand(const char* name) { this->UpdateProperty(name, 1); }
253 
257  vtkGetMacro(NeedsUpdate, bool);
258 
260 
263  vtkGetStringMacro(VTKClassName);
265 
267 
272  vtkSetStringMacro(VTKClassName);
274 
278  virtual vtkSMPropertyIterator* NewPropertyIterator();
279 
285  unsigned int GetNumberOfConsumers();
286 
292  vtkSMProxy* GetConsumerProxy(unsigned int idx);
293 
299  vtkSMProperty* GetConsumerProperty(unsigned int idx);
300 
305  unsigned int GetNumberOfProducers();
306 
310  vtkSMProxy* GetProducerProxy(unsigned int idx);
311 
317  vtkSMProperty* GetProducerProperty(unsigned int idx);
318 
320 
325  vtkGetStringMacro(XMLName);
327 
329 
334  vtkGetStringMacro(XMLGroup);
336 
338 
344  vtkGetStringMacro(XMLLabel);
346 
351  virtual void UpdatePropertyInformation();
352 
357  virtual void UpdatePropertyInformation(vtkSMProperty* prop);
358 
366  virtual void MarkAllPropertiesAsModified();
367 
374  virtual void ResetPropertiesToXMLDefaults();
375 
382  virtual void ResetPropertiesToDomainDefaults();
383 
385  {
386  DEFAULT = 0,
387  ONLY_XML = 1,
388  ONLY_DOMAIN = 2
389  };
390 
400  virtual void ResetPropertiesToDefault(ResetPropertiesMode mode = DEFAULT);
401 
405  enum
406  {
407  COPY_PROXY_PROPERTY_VALUES_BY_REFERENCE = 0,
408 
409  COPY_PROXY_PROPERTY_VALUES_BY_CLONING // < No longer supported!!!
410  };
411 
413 
426  void Copy(vtkSMProxy* src);
427  void Copy(vtkSMProxy* src, const char* exceptionClass);
428  virtual void Copy(vtkSMProxy* src, const char* exceptionClass, int proxyPropertyCopyFlag);
430 
434  virtual void MarkModified(vtkSMProxy* modifiedProxy);
435 
437 
440  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
442 
444 
452  vtkGetObjectMacro(Hints, vtkPVXMLElement);
454 
456 
459  vtkGetMacro(ObjectsCreated, int);
461 
465  bool IsDeprecated() { return this->Deprecated != nullptr; }
466 
475  void InitializeAndCopyFromProxy(vtkSMProxy* source);
476 
481  virtual void MarkDirty(vtkSMProxy* modifiedProxy);
482 
487  vtkObjectBase* GetClientSideObject();
488 
490 
495  bool GatherInformation(vtkPVInformation* information);
496  bool GatherInformation(vtkPVInformation* information, vtkTypeUInt32 location);
498 
507  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root);
511  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root, vtkSMPropertyIterator* iter);
512 
520  virtual int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator);
521 
523 
528  void PrototypeOn() override;
529  void PrototypeOff() override;
530  void SetPrototype(bool undo) override;
532 
538  void UpdateSelfAndAllInputs();
539 
544  bool GetIsSubProxy();
545 
550  vtkSMProxy* GetParentProxy();
551 
557  vtkSMProxy* GetTrueParentProxy();
558 
566  void EnableLocalPushOnly() override;
567 
572  void DisableLocalPushOnly() override;
573 
578  const vtkSMMessage* GetFullState() override;
579 
587  void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator) override;
588 
592  vtkSMPropertyGroup* GetPropertyGroup(size_t index) const;
593 
597  size_t GetNumberOfPropertyGroups() const;
598 
600 
615  void SetLogName(const char* name);
616  vtkGetStringMacro(LogName);
618 
622  const char* GetLogNameOrDefault();
623 
624  bool GetPropertiesModified() { return this->PropertiesModified; }
625 
629  virtual std::vector<std::string> GetPropertiesWithDifferentValues(vtkSMProxy* otherProxy);
630 
631 protected:
632  vtkSMProxy();
633  ~vtkSMProxy() override;
634 
638  virtual void ExecuteStream(const vtkClientServerStream& msg, bool ignore_errors = false,
639  vtkTypeUInt32 location = 0, bool threadedStream = false);
640 
641  // Any method changing the annotations will trigger this method that will
642  // update the local full state as well as sending the annotation state part
643  // to the session.
644  virtual void UpdateAndPushAnnotationState();
645 
647 
650  virtual const vtkClientServerStream& GetLastResult();
651  virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
653 
660  virtual void AddProperty(const char* name, vtkSMProperty* prop);
661 
665  virtual void MarkConsumersAsDirty(vtkSMProxy* modifiedProxy);
666 
675  virtual void MarkDirtyFromProducer(
676  vtkSMProxy* modifiedProxy, vtkSMProxy* producer, vtkSMProperty* property);
677 
688  void MarkInputsAsDirty();
689 
691 
697  friend class vtkSMCameraLink;
698  friend class vtkSMCompoundProxy;
701  friend class vtkSMInputProperty;
706  friend class vtkSMProperty;
707  friend class vtkSMPropertyIterator;
708  friend class vtkSMProxyObserver;
709  friend class vtkSMProxyProperty;
710  friend class vtkSMProxyRegisterUndoElement;
711  friend class vtkSMProxyUnRegisterUndoElement;
713  friend class vtkSMSourceProxy;
714  friend class vtkSMStateLoader;
715  friend class vtkSMStateLocator;
716  friend class vtkSMUndoRedoStateLoader;
717  friend class vtkSMViewProxy;
719 
721 
726  vtkSetStringMacro(XMLName);
728 
730 
735  vtkSetStringMacro(XMLGroup);
737 
739 
745  vtkSetStringMacro(XMLLabel);
747 
749 
756  vtkSetStringMacro(XMLSubProxyName);
758 
764  virtual void CreateVTKObjects();
765 
771  void RemoveAllObservers();
772 
794  virtual void SetPropertyModifiedFlag(const char* name, int flag);
795 
801  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
802 
806  void RemoveSubProxy(const char* name);
807 
811  vtkSMProxy* GetSubProxy(const char* name);
812 
816  vtkSMProxy* GetSubProxy(unsigned int index);
817 
822  const char* GetSubProxyName(unsigned int index);
823 
828  const char* GetSubProxyName(vtkSMProxy*);
829 
833  unsigned int GetNumberOfSubProxies();
834 
839  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
840 
844  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
845 
849  virtual void RemoveAllConsumers();
850 
855  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
856 
860  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
861 
871  virtual void PostUpdateData(bool using_cache);
872 
877  void PostUpdateDataSelfOnly(bool using_cache);
878 
882  bool WarnIfDeprecated();
883 
887  bool LoadPluginIfEnsured();
888 
894  virtual void UpdatePipelineInformation();
895 
896  // When an algorithm proxy is marked modified, NeedsUpdate is
897  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
898  // This is used to keep track of data information validity.
900 
902 
906  vtkSMProperty* NewProperty(const char* name);
907  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
909 
914  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
915 
922 
927 
929 
933  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
934  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
936 
944  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
945  const char* exposed_name, int overrideOK = 0);
946 
950  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
951 
953 
960  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = nullptr);
961 
971 
975  virtual void SetLogNameInternal(
976  const char* name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains);
977 
979 
982  vtkSetStringMacro(SIClassName);
983  vtkGetStringMacro(SIClassName);
984  char* SIClassName;
986 
988  char* XMLGroup;
989  char* XMLName;
990  char* XMLLabel;
995 
1002 
1008 
1012  bool ArePropertiesModified();
1013 
1014  void SetHints(vtkPVXMLElement* hints);
1015  void SetDeprecated(vtkPVXMLElement* deprecated);
1016 
1021  void SetEnsurePluginLoaded(vtkPVXMLElement* ensurePluginLoaded);
1022 
1023  void SetXMLElement(vtkPVXMLElement* element);
1025 
1030 
1031  // Cached version of State
1033 
1034  // Flag used to break consumer loops.
1036 
1038 
1041  vtkSMProxy(const vtkSMProxy&) = delete;
1042  void operator=(const vtkSMProxy&) = delete;
1043 
1044 private:
1045  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
1046 
1047  friend class vtkSMProxyInfo;
1048 
1049  char* LogName;
1050  std::string DefaultLogName;
1051  bool ThreadedUpdate = false;
1052 };
1053 
1067 class VTKREMOTINGSERVERMANAGER_EXPORT SIPROXY : public SIOBJECT
1068 {
1069 public:
1071  : SIOBJECT(proxy)
1072  {
1073  }
1074 };
1075 
1090 class VTKREMOTINGSERVERMANAGER_EXPORT VTKOBJECT
1091 {
1092  vtkSMProxy* Reference;
1093  friend VTKREMOTINGSERVERMANAGER_EXPORT vtkClientServerStream& operator<<(
1094  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1095 
1096 public:
1098  : Reference(proxy)
1099  {
1100  }
1101 };
1102 VTKREMOTINGSERVERMANAGER_EXPORT vtkClientServerStream& operator<<(
1103  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1104 
1105 #endif
virtual void PostUpdateData(bool using_cache)
This method is called after the algorithm(s) (if any) associated with this proxy execute.
bool UpdateProperty(const char *name)
Update the value of one property (pushed to the server) if it is modified.
Definition: vtkSMProxy.h:245
This defines a stream manipulator for the vtkClientServerStream that can be used to indicate to the i...
Definition: vtkSMProxy.h:1090
vtkSMProperty * NewProperty(const char *name)
Creates a new property and initializes it by calling ReadXMLAttributes() with the right XML element...
virtual void RemoveConsumer(vtkSMProperty *property, vtkSMProxy *proxy)
Remove the property,proxy pair from the list of consumers.
virtual int CreateSubProxiesAndProperties(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element)
void RemoveAllObservers()
iterates over a subset of a proxy&#39;s properties
location
virtual void UpdatePipelineInformation()
This method simply iterates over subproxies and calls UpdatePipelineInformation() on them...
void CreateVTKObjects() override
Called at the end of CreateVTKObjects().
virtual void PrototypeOff()
Allow user to set the remote object to be discard for Undo/Redo action.
void AppendPropertyGroup(vtkSMPropertyGroup *group)
Adds a property groups.
virtual void AddConsumer(vtkSMProperty *property, vtkSMProxy *proxy)
Called by a proxy property, this adds the property,proxy pair to the list of consumers.
vtkSMProxy * GetSubProxy(const char *name)
Returns a sub-proxy.
property representing pointer(s) to vtkObject(s)
void ExposeSubProxyProperty(const char *subproxy_name, const char *property_name, const char *exposed_name, int overrideOK=0)
Expose a subproxy property from the base proxy.
VTKOBJECT(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1097
virtual void LoadState(const vtkSMMessage *msg, vtkSMProxyLocator *locator)
This method is used to initialise the object to the given state If the definitionOnly Flag is set to ...
void SetupSharedProperties(vtkSMProxy *subproxy, vtkPVXMLElement *element)
Read attributes from an XML element.
virtual void PrototypeOn()
Allow user to set the remote object to be discard for Undo/Redo action.
virtual void EnableLocalPushOnly()
Allow to switch off any push of state change to the server for that particular object.
virtual void SetLocation(vtkTypeUInt32)
Get/Set the location where the underlying VTK-objects are created.
Superclass for all view proxies.
This defines a stream manipulator for the vtkClientServerStream that can be used to indicate to the i...
Definition: vtkSMProxy.h:1067
superclass for all SM properties
bool GetPropertiesModified()
Definition: vtkSMProxy.h:624
vtkPVXMLElement * EnsurePluginLoaded
Definition: vtkSMProxy.h:1029
char * XMLGroup
Definition: vtkSMProxy.h:988
virtual void SetPropertyModifiedFlag(const char *name, int flag)
Note on property modified flags: The modified flag of each property associated with a proxy is stored...
iterates over the properties of a proxy
void RemoveProducer(vtkSMProperty *property, vtkSMProxy *proxy)
Remove the property,proxy pair from the list of producers.
Store messages for the interpreter.
bool ArePropertiesModified()
Indicates if any properties are modified.
void AddSubProxy(const char *name, vtkSMProxy *proxy, int overrideOK=0)
Add a sub-proxy.
bool IsDeprecated()
Returns true if the proxy has a deprecation tag.
Definition: vtkSMProxy.h:465
singleton/facade to vtkSMSessionProxyManager
char * XMLSubProxyName
Definition: vtkSMProxy.h:991
int InMarkModified
Definition: vtkSMProxy.h:1035
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1070
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:993
name
int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element) override
Read attributes from an XML element.
vtkSMMessage * State
Definition: vtkSMProxy.h:1032
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:1026
virtual void SetLogNameInternal(const char *name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains)
Internal method used by SetLogName
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
void RebuildStateForProperties()
vtkSMProxy tracks state of properties on this proxy in an internal State object.
This defines a manipulator for the vtkClientServerStream that can be used to indicate to the interpre...
virtual void DisableLocalPushOnly()
Enable the given remote object to communicate its state normally to the server location.
bool LoadPluginIfEnsured()
If a proxy need to ensure a plugin is loaded, make sure it is.
int ObjectsCreated
Definition: vtkSMProxy.h:992
void AddProducer(vtkSMProperty *property, vtkSMProxy *proxy)
Called by an proxy/input property to add property, proxy pair to the list of producers.
VTKREMOTINGSERVERMANAGER_EXPORT vtkClientServerStream & operator<<(vtkClientServerStream &stream, const VTKOBJECT &manipulator)
Preselection enables the user to inspect cells/points without actually selecting them.
proxy for a VTK source on a server
virtual void UpdatePropertyInformationInternal(vtkSMProperty *prop=nullptr)
Called to update the property information on the property.
void LinkProperty(vtkSMProperty *inputProperty, vtkSMProperty *outputProperty)
Links properties such that when inputProperty&#39;s checked or unchecked values are changed, the outputProperty&#39;s corresponding values are also changed.
void SetDeprecated(vtkPVXMLElement *deprecated)
vtkWeakPointer< vtkSMProxy > ParentProxy
Definition: vtkSMProxy.h:1037
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:989
source
void SetupExposedProperties(const char *subproxy_name, vtkPVXMLElement *element)
Read attributes from an XML element.
const char * GetSubProxyName(unsigned int index)
Returns the name used to store sub-proxy.
a proxy excapsulation a pipeline of proxies.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
int InUpdateVTKObjects
Avoids calls to UpdateVTKObjects in UpdateVTKObjects.
Definition: vtkSMProxy.h:1001
void InvokeCommand(const char *name)
Convenience method equivalent to UpdateProperty(name, 1).
Definition: vtkSMProxy.h:252
virtual const vtkSMMessage * GetFullState()
This method return the full object state that can be used to create that object from scratch...
is used to locate proxies referred to in state xmls while loading state files.
vtkSMProxyObserver * SubProxyObserver
Definition: vtkSMProxy.h:1040
bool NeedsUpdate
Definition: vtkSMProxy.h:899
int DoNotModifyProperty
Definition: vtkSMProxy.h:994
virtual void ExecuteSubProxyEvent(vtkSMProxy *o, unsigned long event, void *data)
Handle events fired by subproxies.
class providing access to the documentation for a vtkSMProxy.
virtual vtkSMProperty * GetProperty(const char *name)
Return the property with the given name.
Definition: vtkSMProxy.h:203
void SetEnsurePluginLoaded(vtkPVXMLElement *ensurePluginLoaded)
Set the "EnsurePluginLoaded" XML element that is used in LoadPluginIfEnsured.
vtkPVXMLElement * XMLElement
Definition: vtkSMProxy.h:1024
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1039
char * VTKClassName
Definition: vtkSMProxy.h:987
virtual void RemoveAllConsumers()
Remove all consumers.
Utility class to load state from XML.
baseclass for all proxy-objects that have counter parts on server as well as client processes...
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
void SetXMLElement(vtkPVXMLElement *element)
index
virtual void SetPrototype(bool)
Allow user to set the remote object to be discard for Undo/Redo action.
unsigned int GetNumberOfSubProxies()
Returns the number of sub-proxies.
static vtkSMSessionObject * New()
friend class vtkSMProxyObserver
These classes have been declared as friends to minimize the public interface exposed by vtkSMProxy...
Definition: vtkSMProxy.h:708
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:1007
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:990
void PrintSelf(ostream &os, vtkIndent indent) override
iterates over the properties of a proxy
void RemoveSubProxy(const char *name)
Remove a sub-proxy.
proxy representing inputs to a filter
vtkPVXMLElement * Deprecated
Definition: vtkSMProxy.h:1028
Class used to retrieve a given message state based on its GlobalID.
char * SIClassName
SIClassName identifies the classname for the helper on the server side.
Definition: vtkSMProxy.h:983
void PostUpdateDataSelfOnly(bool using_cache)
This is called by PostUpdateData to only update state for this proxy without iterative over producers...
vtkSMPropertyGroup * NewPropertyGroup(vtkPVXMLElement *propElement)
Parses the XML to create a new property group.
vtkPVXMLElement * Hints
Definition: vtkSMProxy.h:1027