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 
450  bool IsDeprecated() { return this->Deprecated != nullptr; }
451 
460  void InitializeAndCopyFromProxy(vtkSMProxy* source);
461 
466  virtual void MarkDirty(vtkSMProxy* modifiedProxy);
467 
472  vtkObjectBase* GetClientSideObject();
473 
475 
480  bool GatherInformation(vtkPVInformation* information);
481  bool GatherInformation(vtkPVInformation* information, vtkTypeUInt32 location);
483 
492  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root);
496  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root, vtkSMPropertyIterator* iter);
497 
505  virtual int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator);
506 
508 
513  void PrototypeOn() override;
514  void PrototypeOff() override;
515  void SetPrototype(bool undo) override;
517 
523  void UpdateSelfAndAllInputs();
524 
529  bool GetIsSubProxy();
530 
535  vtkSMProxy* GetParentProxy();
536 
542  vtkSMProxy* GetTrueParentProxy();
543 
551  void EnableLocalPushOnly() override;
552 
557  void DisableLocalPushOnly() override;
558 
563  const vtkSMMessage* GetFullState() override;
564 
572  void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator) override;
573 
577  vtkSMPropertyGroup* GetPropertyGroup(size_t index) const;
578 
582  size_t GetNumberOfPropertyGroups() const;
583 
585 
600  void SetLogName(const char* name);
601  vtkGetStringMacro(LogName);
603 
607  const char* GetLogNameOrDefault();
608 
609  bool GetPropertiesModified() { return this->PropertiesModified; }
610 
614  virtual std::vector<std::string> GetPropertiesWithDifferentValues(vtkSMProxy* otherProxy);
615 
616 protected:
617  vtkSMProxy();
618  ~vtkSMProxy() override;
619 
623  void ExecuteStream(
624  const vtkClientServerStream& msg, bool ignore_errors = false, vtkTypeUInt32 location = 0);
625 
626  // Any method changing the annotations will trigger this method that will
627  // update the local full state as well as sending the annotation state part
628  // to the session.
629  virtual void UpdateAndPushAnnotationState();
630 
632 
635  virtual const vtkClientServerStream& GetLastResult();
636  virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
638 
645  virtual void AddProperty(const char* name, vtkSMProperty* prop);
646 
650  virtual void MarkConsumersAsDirty(vtkSMProxy* modifiedProxy);
651 
660  virtual void MarkDirtyFromProducer(
661  vtkSMProxy* modifiedProxy, vtkSMProxy* producer, vtkSMProperty* property);
662 
673  void MarkInputsAsDirty();
674 
676 
682  friend class vtkSMCameraLink;
683  friend class vtkSMCompoundProxy;
686  friend class vtkSMInputProperty;
691  friend class vtkSMProperty;
692  friend class vtkSMPropertyIterator;
693  friend class vtkSMProxyObserver;
694  friend class vtkSMProxyProperty;
695  friend class vtkSMProxyRegisterUndoElement;
696  friend class vtkSMProxyUnRegisterUndoElement;
698  friend class vtkSMSourceProxy;
699  friend class vtkSMStateLoader;
700  friend class vtkSMStateLocator;
701  friend class vtkSMUndoRedoStateLoader;
702  friend class vtkSMViewProxy;
704 
706 
711  vtkSetStringMacro(XMLName);
713 
715 
720  vtkSetStringMacro(XMLGroup);
722 
724 
730  vtkSetStringMacro(XMLLabel);
732 
734 
741  vtkSetStringMacro(XMLSubProxyName);
743 
749  virtual void CreateVTKObjects();
750 
756  void RemoveAllObservers();
757 
779  virtual void SetPropertyModifiedFlag(const char* name, int flag);
780 
786  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
787 
791  void RemoveSubProxy(const char* name);
792 
796  vtkSMProxy* GetSubProxy(const char* name);
797 
801  vtkSMProxy* GetSubProxy(unsigned int index);
802 
807  const char* GetSubProxyName(unsigned int index);
808 
813  const char* GetSubProxyName(vtkSMProxy*);
814 
818  unsigned int GetNumberOfSubProxies();
819 
824  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
825 
829  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
830 
834  virtual void RemoveAllConsumers();
835 
840  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
841 
845  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
846 
856  virtual void PostUpdateData(bool using_cache);
857 
862  void PostUpdateDataSelfOnly(bool using_cache);
863 
867  bool WarnIfDeprecated();
868 
872  bool LoadPluginIfEnsured();
873 
879  virtual void UpdatePipelineInformation();
880 
881  // When an algorithm proxy is marked modified, NeedsUpdate is
882  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
883  // This is used to keep track of data information validity.
885 
887 
891  vtkSMProperty* NewProperty(const char* name);
892  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
894 
899  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
900 
907 
912 
914 
918  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
919  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
921 
929  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
930  const char* exposed_name, int overrideOK = 0);
931 
935  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
936 
938 
945  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = nullptr);
946 
956 
960  virtual void SetLogNameInternal(
961  const char* name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains);
962 
964 
967  vtkSetStringMacro(SIClassName);
968  vtkGetStringMacro(SIClassName);
969  char* SIClassName;
971 
973  char* XMLGroup;
974  char* XMLName;
975  char* XMLLabel;
980 
987 
993 
997  bool ArePropertiesModified();
998 
999  void SetHints(vtkPVXMLElement* hints);
1000  void SetDeprecated(vtkPVXMLElement* deprecated);
1001 
1006  void SetEnsurePluginLoaded(vtkPVXMLElement* ensurePluginLoaded);
1007 
1008  void SetXMLElement(vtkPVXMLElement* element);
1010 
1015 
1016  // Cached version of State
1018 
1019  // Flag used to break consumer loops.
1021 
1023 
1026  vtkSMProxy(const vtkSMProxy&) = delete;
1027  void operator=(const vtkSMProxy&) = delete;
1028 
1029 private:
1030  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
1031 
1032  friend class vtkSMProxyInfo;
1033 
1034  char* LogName;
1035  std::string DefaultLogName;
1036 };
1037 
1052 {
1053 public:
1055  : SIOBJECT(proxy)
1056  {
1057  }
1058 };
1059 
1075 {
1076  vtkSMProxy* Reference;
1078  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1079 
1080 public:
1082  : Reference(proxy)
1083  {
1084  }
1085 };
1087  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1088 
1089 #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:1074
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:1081
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:1051
superclass for all SM properties
bool GetPropertiesModified()
Definition: vtkSMProxy.h:609
vtkPVXMLElement * EnsurePluginLoaded
Definition: vtkSMProxy.h:1014
char * XMLGroup
Definition: vtkSMProxy.h:973
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:450
singleton/facade to vtkSMSessionProxyManager
char * XMLSubProxyName
Definition: vtkSMProxy.h:976
int InMarkModified
Definition: vtkSMProxy.h:1020
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1054
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:978
name
int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element) override
Read attributes from an XML element.
vtkSMMessage * State
Definition: vtkSMProxy.h:1017
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:1011
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:977
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:1022
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:974
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:986
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:1025
bool NeedsUpdate
Definition: vtkSMProxy.h:884
int DoNotModifyProperty
Definition: vtkSMProxy.h:979
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
void SetEnsurePluginLoaded(vtkPVXMLElement *ensurePluginLoaded)
Set the "EnsurePluginLoaded" XML element that is used in LoadPluginIfEnsured.
vtkPVXMLElement * XMLElement
Definition: vtkSMProxy.h:1009
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1024
char * VTKClassName
Definition: vtkSMProxy.h:972
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:693
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:992
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:975
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:1013
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:968
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:1012