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 
141 {
142 public:
143  static vtkSMProxy* New();
145  void PrintSelf(ostream& os, vtkIndent indent) override;
146 
147  // Description:
148  // Set or override a key/value pair as annotation to that proxy.
149  // If the value is nullptr, this method is equivalent to RemoveAnnotation(key)
150  void SetAnnotation(const char* key, const char* value);
151 
156  const char* GetAnnotation(const char* key);
157 
161  void RemoveAnnotation(const char* key);
162 
166  void RemoveAllAnnotations();
167 
171  bool HasAnnotation(const char* key);
172 
176  int GetNumberOfAnnotations();
177 
181  const char* GetAnnotationKeyAt(int index);
182 
187  void SetLocation(vtkTypeUInt32) override;
188 
193  virtual vtkSMProperty* GetProperty(const char* name)
194  {
195  return this->GetProperty(name, /*self-only*/ 0);
196  }
197 
203  virtual vtkSMProperty* GetProperty(const char* name, int selfOnly);
204 
212  const char* GetPropertyName(vtkSMProperty* prop);
213 
219  virtual void UpdateVTKObjects();
220 
226  virtual void RecreateVTKObjects();
227 
229 
235  bool UpdateProperty(const char* name) { return this->UpdateProperty(name, 0); }
236  bool UpdateProperty(const char* name, int force);
238 
242  void InvokeCommand(const char* name) { this->UpdateProperty(name, 1); }
243 
245 
248  vtkGetStringMacro(VTKClassName);
250 
252 
257  vtkSetStringMacro(VTKClassName);
259 
263  virtual vtkSMPropertyIterator* NewPropertyIterator();
264 
270  unsigned int GetNumberOfConsumers();
271 
277  vtkSMProxy* GetConsumerProxy(unsigned int idx);
278 
284  vtkSMProperty* GetConsumerProperty(unsigned int idx);
285 
290  unsigned int GetNumberOfProducers();
291 
295  vtkSMProxy* GetProducerProxy(unsigned int idx);
296 
302  vtkSMProperty* GetProducerProperty(unsigned int idx);
303 
305 
310  vtkGetStringMacro(XMLName);
312 
314 
319  vtkGetStringMacro(XMLGroup);
321 
323 
329  vtkGetStringMacro(XMLLabel);
331 
336  virtual void UpdatePropertyInformation();
337 
342  virtual void UpdatePropertyInformation(vtkSMProperty* prop);
343 
351  virtual void MarkAllPropertiesAsModified();
352 
359  virtual void ResetPropertiesToXMLDefaults();
360 
367  virtual void ResetPropertiesToDomainDefaults();
368 
370  {
371  DEFAULT = 0,
372  ONLY_XML = 1,
373  ONLY_DOMAIN = 2
374  };
375 
385  virtual void ResetPropertiesToDefault(ResetPropertiesMode mode = DEFAULT);
386 
390  enum
391  {
392  COPY_PROXY_PROPERTY_VALUES_BY_REFERENCE = 0,
393 
394  COPY_PROXY_PROPERTY_VALUES_BY_CLONING // < No longer supported!!!
395  };
396 
398 
411  void Copy(vtkSMProxy* src);
412  void Copy(vtkSMProxy* src, const char* exceptionClass);
413  virtual void Copy(vtkSMProxy* src, const char* exceptionClass, int proxyPropertyCopyFlag);
415 
419  virtual void MarkModified(vtkSMProxy* modifiedProxy);
420 
422 
425  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
427 
429 
437  vtkGetObjectMacro(Hints, vtkPVXMLElement);
439 
441 
444  vtkGetMacro(ObjectsCreated, int);
446 
455  void InitializeAndCopyFromProxy(vtkSMProxy* source);
456 
461  virtual void MarkDirty(vtkSMProxy* modifiedProxy);
462 
467  vtkObjectBase* GetClientSideObject();
468 
470 
475  bool GatherInformation(vtkPVInformation* information);
476  bool GatherInformation(vtkPVInformation* information, vtkTypeUInt32 location);
478 
487  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root);
491  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root, vtkSMPropertyIterator* iter);
492 
500  virtual int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator);
501 
503 
508  void PrototypeOn() override;
509  void PrototypeOff() override;
510  void SetPrototype(bool undo) override;
512 
518  void UpdateSelfAndAllInputs();
519 
524  bool GetIsSubProxy();
525 
530  vtkSMProxy* GetParentProxy();
531 
537  vtkSMProxy* GetTrueParentProxy();
538 
546  void EnableLocalPushOnly() override;
547 
552  void DisableLocalPushOnly() override;
553 
558  const vtkSMMessage* GetFullState() override;
559 
567  void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator) override;
568 
572  vtkSMPropertyGroup* GetPropertyGroup(size_t index) const;
573 
577  size_t GetNumberOfPropertyGroups() const;
578 
580 
595  void SetLogName(const char* name);
596  vtkGetStringMacro(LogName);
598 
602  const char* GetLogNameOrDefault();
603 
604  bool GetPropertiesModified() { return this->PropertiesModified; }
605 
606 protected:
607  vtkSMProxy();
608  ~vtkSMProxy() override;
609 
613  void ExecuteStream(
614  const vtkClientServerStream& msg, bool ignore_errors = false, vtkTypeUInt32 location = 0);
615 
616  // Any method changing the annotations will trigger this method that will
617  // update the local full state as well as sending the annotation state part
618  // to the session.
619  virtual void UpdateAndPushAnnotationState();
620 
622 
625  virtual const vtkClientServerStream& GetLastResult();
626  virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
628 
635  virtual void AddProperty(const char* name, vtkSMProperty* prop);
636 
640  virtual void MarkConsumersAsDirty(vtkSMProxy* modifiedProxy);
641 
650  virtual void MarkDirtyFromProducer(
651  vtkSMProxy* modifiedProxy, vtkSMProxy* producer, vtkSMProperty* property);
652 
663  void MarkInputsAsDirty();
664 
666 
672  friend class vtkSMCameraLink;
673  friend class vtkSMCompoundProxy;
676  friend class vtkSMInputProperty;
681  friend class vtkSMProperty;
682  friend class vtkSMPropertyIterator;
683  friend class vtkSMProxyObserver;
684  friend class vtkSMProxyProperty;
685  friend class vtkSMProxyRegisterUndoElement;
686  friend class vtkSMProxyUnRegisterUndoElement;
688  friend class vtkSMSourceProxy;
689  friend class vtkSMStateLoader;
690  friend class vtkSMStateLocator;
691  friend class vtkSMUndoRedoStateLoader;
692  friend class vtkSMViewProxy;
694 
696 
701  vtkSetStringMacro(XMLName);
703 
705 
710  vtkSetStringMacro(XMLGroup);
712 
714 
720  vtkSetStringMacro(XMLLabel);
722 
724 
731  vtkSetStringMacro(XMLSubProxyName);
733 
739  virtual void CreateVTKObjects();
740 
746  void RemoveAllObservers();
747 
769  virtual void SetPropertyModifiedFlag(const char* name, int flag);
770 
776  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
777 
781  void RemoveSubProxy(const char* name);
782 
786  vtkSMProxy* GetSubProxy(const char* name);
787 
791  vtkSMProxy* GetSubProxy(unsigned int index);
792 
797  const char* GetSubProxyName(unsigned int index);
798 
803  const char* GetSubProxyName(vtkSMProxy*);
804 
808  unsigned int GetNumberOfSubProxies();
809 
814  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
815 
819  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
820 
824  virtual void RemoveAllConsumers();
825 
830  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
831 
835  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
836 
846  virtual void PostUpdateData(bool using_cache);
847 
852  void PostUpdateDataSelfOnly(bool using_cache);
853 
857  bool WarnIfDeprecated();
858 
864  virtual void UpdatePipelineInformation();
865 
866  // When an algorithm proxy is marked modified, NeedsUpdate is
867  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
868  // This is used to keep track of data information validity.
870 
872 
876  vtkSMProperty* NewProperty(const char* name);
877  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
879 
884  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
885 
892 
897 
899 
903  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
904  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
906 
914  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
915  const char* exposed_name, int overrideOK = 0);
916 
920  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
921 
923 
930  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = nullptr);
931 
941 
945  virtual void SetLogNameInternal(
946  const char* name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains);
947 
949 
952  vtkSetStringMacro(SIClassName);
953  vtkGetStringMacro(SIClassName);
954  char* SIClassName;
956 
958  char* XMLGroup;
959  char* XMLName;
960  char* XMLLabel;
965 
972 
978 
982  bool ArePropertiesModified();
983 
984  void SetHints(vtkPVXMLElement* hints);
985  void SetDeprecated(vtkPVXMLElement* deprecated);
986 
987  void SetXMLElement(vtkPVXMLElement* element);
989 
993 
994  // Cached version of State
996 
997  // Flag used to break consumer loops.
999 
1001 
1004  vtkSMProxy(const vtkSMProxy&) = delete;
1005  void operator=(const vtkSMProxy&) = delete;
1006 
1007 private:
1008  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
1009 
1010  friend class vtkSMProxyInfo;
1011 
1012  char* LogName;
1013  std::string DefaultLogName;
1014 };
1015 
1030 {
1031 public:
1033  : SIOBJECT(proxy)
1034  {
1035  }
1036 };
1037 
1053 {
1054  vtkSMProxy* Reference;
1056  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1057 
1058 public:
1060  : Reference(proxy)
1061  {
1062  }
1063 };
1065  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1066 
1067 #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:235
This defines a stream manipulator for the vtkClientServerStream that can be used to indicate to the i...
Definition: vtkSMProxy.h:1052
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:1059
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.
#define VTKREMOTINGSERVERMANAGER_EXPORT
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:1029
superclass for all SM properties
bool GetPropertiesModified()
Definition: vtkSMProxy.h:604
char * XMLGroup
Definition: vtkSMProxy.h:958
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.
singleton/facade to vtkSMSessionProxyManager
char * XMLSubProxyName
Definition: vtkSMProxy.h:961
int InMarkModified
Definition: vtkSMProxy.h:998
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1032
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:963
name
int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element) override
Read attributes from an XML element.
vtkSMMessage * State
Definition: vtkSMProxy.h:995
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:990
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.
int ObjectsCreated
Definition: vtkSMProxy.h:962
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:1000
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:959
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:971
void InvokeCommand(const char *name)
Convenience method equivalent to UpdateProperty(name, 1).
Definition: vtkSMProxy.h:242
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:1003
bool NeedsUpdate
Definition: vtkSMProxy.h:869
int DoNotModifyProperty
Definition: vtkSMProxy.h:964
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:193
vtkPVXMLElement * XMLElement
Definition: vtkSMProxy.h:988
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1002
char * VTKClassName
Definition: vtkSMProxy.h:957
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)
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:683
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:977
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:960
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:992
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:953
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:991