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 
247  vtkGetMacro(NeedsUpdate, bool);
248 
250 
253  vtkGetStringMacro(VTKClassName);
255 
257 
262  vtkSetStringMacro(VTKClassName);
264 
268  virtual vtkSMPropertyIterator* NewPropertyIterator();
269 
275  unsigned int GetNumberOfConsumers();
276 
282  vtkSMProxy* GetConsumerProxy(unsigned int idx);
283 
289  vtkSMProperty* GetConsumerProperty(unsigned int idx);
290 
295  unsigned int GetNumberOfProducers();
296 
300  vtkSMProxy* GetProducerProxy(unsigned int idx);
301 
307  vtkSMProperty* GetProducerProperty(unsigned int idx);
308 
310 
315  vtkGetStringMacro(XMLName);
317 
319 
324  vtkGetStringMacro(XMLGroup);
326 
328 
334  vtkGetStringMacro(XMLLabel);
336 
341  virtual void UpdatePropertyInformation();
342 
347  virtual void UpdatePropertyInformation(vtkSMProperty* prop);
348 
356  virtual void MarkAllPropertiesAsModified();
357 
364  virtual void ResetPropertiesToXMLDefaults();
365 
372  virtual void ResetPropertiesToDomainDefaults();
373 
375  {
376  DEFAULT = 0,
377  ONLY_XML = 1,
378  ONLY_DOMAIN = 2
379  };
380 
390  virtual void ResetPropertiesToDefault(ResetPropertiesMode mode = DEFAULT);
391 
395  enum
396  {
397  COPY_PROXY_PROPERTY_VALUES_BY_REFERENCE = 0,
398 
399  COPY_PROXY_PROPERTY_VALUES_BY_CLONING // < No longer supported!!!
400  };
401 
403 
416  void Copy(vtkSMProxy* src);
417  void Copy(vtkSMProxy* src, const char* exceptionClass);
418  virtual void Copy(vtkSMProxy* src, const char* exceptionClass, int proxyPropertyCopyFlag);
420 
424  virtual void MarkModified(vtkSMProxy* modifiedProxy);
425 
427 
430  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
432 
434 
442  vtkGetObjectMacro(Hints, vtkPVXMLElement);
444 
446 
449  vtkGetMacro(ObjectsCreated, int);
451 
455  bool IsDeprecated() { return this->Deprecated != nullptr; }
456 
465  void InitializeAndCopyFromProxy(vtkSMProxy* source);
466 
471  virtual void MarkDirty(vtkSMProxy* modifiedProxy);
472 
477  vtkObjectBase* GetClientSideObject();
478 
480 
485  bool GatherInformation(vtkPVInformation* information);
486  bool GatherInformation(vtkPVInformation* information, vtkTypeUInt32 location);
488 
497  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root);
501  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root, vtkSMPropertyIterator* iter);
502 
510  virtual int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator);
511 
513 
518  void PrototypeOn() override;
519  void PrototypeOff() override;
520  void SetPrototype(bool undo) override;
522 
528  void UpdateSelfAndAllInputs();
529 
534  bool GetIsSubProxy();
535 
540  vtkSMProxy* GetParentProxy();
541 
547  vtkSMProxy* GetTrueParentProxy();
548 
556  void EnableLocalPushOnly() override;
557 
562  void DisableLocalPushOnly() override;
563 
568  const vtkSMMessage* GetFullState() override;
569 
577  void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator) override;
578 
582  vtkSMPropertyGroup* GetPropertyGroup(size_t index) const;
583 
587  size_t GetNumberOfPropertyGroups() const;
588 
590 
605  void SetLogName(const char* name);
606  vtkGetStringMacro(LogName);
608 
612  const char* GetLogNameOrDefault();
613 
614  bool GetPropertiesModified() { return this->PropertiesModified; }
615 
619  virtual std::vector<std::string> GetPropertiesWithDifferentValues(vtkSMProxy* otherProxy);
620 
621 protected:
622  vtkSMProxy();
623  ~vtkSMProxy() override;
624 
628  virtual void ExecuteStream(
629  const vtkClientServerStream& msg, bool ignore_errors = false, vtkTypeUInt32 location = 0);
630 
631  // Any method changing the annotations will trigger this method that will
632  // update the local full state as well as sending the annotation state part
633  // to the session.
634  virtual void UpdateAndPushAnnotationState();
635 
637 
640  virtual const vtkClientServerStream& GetLastResult();
641  virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
643 
650  virtual void AddProperty(const char* name, vtkSMProperty* prop);
651 
655  virtual void MarkConsumersAsDirty(vtkSMProxy* modifiedProxy);
656 
665  virtual void MarkDirtyFromProducer(
666  vtkSMProxy* modifiedProxy, vtkSMProxy* producer, vtkSMProperty* property);
667 
678  void MarkInputsAsDirty();
679 
681 
687  friend class vtkSMCameraLink;
688  friend class vtkSMCompoundProxy;
691  friend class vtkSMInputProperty;
696  friend class vtkSMProperty;
697  friend class vtkSMPropertyIterator;
698  friend class vtkSMProxyObserver;
699  friend class vtkSMProxyProperty;
700  friend class vtkSMProxyRegisterUndoElement;
701  friend class vtkSMProxyUnRegisterUndoElement;
703  friend class vtkSMSourceProxy;
704  friend class vtkSMStateLoader;
705  friend class vtkSMStateLocator;
706  friend class vtkSMUndoRedoStateLoader;
707  friend class vtkSMViewProxy;
709 
711 
716  vtkSetStringMacro(XMLName);
718 
720 
725  vtkSetStringMacro(XMLGroup);
727 
729 
735  vtkSetStringMacro(XMLLabel);
737 
739 
746  vtkSetStringMacro(XMLSubProxyName);
748 
754  virtual void CreateVTKObjects();
755 
761  void RemoveAllObservers();
762 
784  virtual void SetPropertyModifiedFlag(const char* name, int flag);
785 
791  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
792 
796  void RemoveSubProxy(const char* name);
797 
801  vtkSMProxy* GetSubProxy(const char* name);
802 
806  vtkSMProxy* GetSubProxy(unsigned int index);
807 
812  const char* GetSubProxyName(unsigned int index);
813 
818  const char* GetSubProxyName(vtkSMProxy*);
819 
823  unsigned int GetNumberOfSubProxies();
824 
829  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
830 
834  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
835 
839  virtual void RemoveAllConsumers();
840 
845  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
846 
850  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
851 
861  virtual void PostUpdateData(bool using_cache);
862 
867  void PostUpdateDataSelfOnly(bool using_cache);
868 
872  bool WarnIfDeprecated();
873 
877  bool LoadPluginIfEnsured();
878 
884  virtual void UpdatePipelineInformation();
885 
886  // When an algorithm proxy is marked modified, NeedsUpdate is
887  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
888  // This is used to keep track of data information validity.
890 
892 
896  vtkSMProperty* NewProperty(const char* name);
897  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
899 
904  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
905 
912 
917 
919 
923  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
924  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
926 
934  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
935  const char* exposed_name, int overrideOK = 0);
936 
940  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
941 
943 
950  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = nullptr);
951 
961 
965  virtual void SetLogNameInternal(
966  const char* name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains);
967 
969 
972  vtkSetStringMacro(SIClassName);
973  vtkGetStringMacro(SIClassName);
974  char* SIClassName;
976 
978  char* XMLGroup;
979  char* XMLName;
980  char* XMLLabel;
985 
992 
998 
1002  bool ArePropertiesModified();
1003 
1004  void SetHints(vtkPVXMLElement* hints);
1005  void SetDeprecated(vtkPVXMLElement* deprecated);
1006 
1011  void SetEnsurePluginLoaded(vtkPVXMLElement* ensurePluginLoaded);
1012 
1013  void SetXMLElement(vtkPVXMLElement* element);
1015 
1020 
1021  // Cached version of State
1023 
1024  // Flag used to break consumer loops.
1026 
1028 
1031  vtkSMProxy(const vtkSMProxy&) = delete;
1032  void operator=(const vtkSMProxy&) = delete;
1033 
1034 private:
1035  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
1036 
1037  friend class vtkSMProxyInfo;
1038 
1039  char* LogName;
1040  std::string DefaultLogName;
1041 };
1042 
1057 {
1058 public:
1060  : SIOBJECT(proxy)
1061  {
1062  }
1063 };
1064 
1080 {
1081  vtkSMProxy* Reference;
1083  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1084 
1085 public:
1087  : Reference(proxy)
1088  {
1089  }
1090 };
1092  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1093 
1094 #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:1079
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:1086
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:1056
superclass for all SM properties
bool GetPropertiesModified()
Definition: vtkSMProxy.h:614
vtkPVXMLElement * EnsurePluginLoaded
Definition: vtkSMProxy.h:1019
char * XMLGroup
Definition: vtkSMProxy.h:978
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:455
singleton/facade to vtkSMSessionProxyManager
char * XMLSubProxyName
Definition: vtkSMProxy.h:981
int InMarkModified
Definition: vtkSMProxy.h:1025
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1059
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:983
name
int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element) override
Read attributes from an XML element.
vtkSMMessage * State
Definition: vtkSMProxy.h:1022
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:1016
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:982
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:1027
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:979
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:991
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:1030
bool NeedsUpdate
Definition: vtkSMProxy.h:889
int DoNotModifyProperty
Definition: vtkSMProxy.h:984
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:1014
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1029
char * VTKClassName
Definition: vtkSMProxy.h:977
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:698
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:997
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:980
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:1018
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:973
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:1017