vtkSMProxy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkSMProxy.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
130 #ifndef vtkSMProxy_h
131 #define vtkSMProxy_h
132 
133 #include "vtkClientServerID.h" // needed for vtkClientServerID
134 #include "vtkRemotingServerManagerModule.h" //needed for exports
135 #include "vtkSMRemoteObject.h"
136 
137 struct vtkSMProxyInternals;
138 
140 class vtkPVInformation;
141 class vtkSMLoadStateContext;
142 class vtkPVXMLElement;
143 class vtkSMDocumentation;
144 class vtkSMProperty;
145 class vtkSMPropertyGroup;
147 class vtkSMProxyLocator;
148 class vtkSMProxyManager;
150 class vtkSMProxyObserver;
151 
153 {
154 public:
155  static vtkSMProxy* New();
157  void PrintSelf(ostream& os, vtkIndent indent) override;
158 
159  // Description:
160  // Set or override a key/value pair as annotation to that proxy.
161  // If the value is nullptr, this method is equivalent to RemoveAnnotation(key)
162  void SetAnnotation(const char* key, const char* value);
163 
168  const char* GetAnnotation(const char* key);
169 
173  void RemoveAnnotation(const char* key);
174 
178  void RemoveAllAnnotations();
179 
183  bool HasAnnotation(const char* key);
184 
188  int GetNumberOfAnnotations();
189 
193  const char* GetAnnotationKeyAt(int index);
194 
199  void SetLocation(vtkTypeUInt32) override;
200 
205  virtual vtkSMProperty* GetProperty(const char* name)
206  {
207  return this->GetProperty(name, /*self-only*/ 0);
208  }
209 
215  virtual vtkSMProperty* GetProperty(const char* name, int selfOnly);
216 
224  const char* GetPropertyName(vtkSMProperty* prop);
225 
231  virtual void UpdateVTKObjects();
232 
238  virtual void RecreateVTKObjects();
239 
241 
247  bool UpdateProperty(const char* name) { return this->UpdateProperty(name, 0); }
248  bool UpdateProperty(const char* name, int force);
250 
254  void InvokeCommand(const char* name) { this->UpdateProperty(name, 1); }
255 
257 
260  vtkGetStringMacro(VTKClassName);
262 
264 
269  vtkSetStringMacro(VTKClassName);
271 
275  virtual vtkSMPropertyIterator* NewPropertyIterator();
276 
282  unsigned int GetNumberOfConsumers();
283 
289  vtkSMProxy* GetConsumerProxy(unsigned int idx);
290 
296  vtkSMProperty* GetConsumerProperty(unsigned int idx);
297 
302  unsigned int GetNumberOfProducers();
303 
307  vtkSMProxy* GetProducerProxy(unsigned int idx);
308 
314  vtkSMProperty* GetProducerProperty(unsigned int idx);
315 
317 
322  vtkGetStringMacro(XMLName);
324 
326 
331  vtkGetStringMacro(XMLGroup);
333 
335 
341  vtkGetStringMacro(XMLLabel);
343 
348  virtual void UpdatePropertyInformation();
349 
354  virtual void UpdatePropertyInformation(vtkSMProperty* prop);
355 
363  virtual void MarkAllPropertiesAsModified();
364 
371  virtual void ResetPropertiesToXMLDefaults();
372 
379  virtual void ResetPropertiesToDomainDefaults();
380 
382  {
383  DEFAULT = 0,
384  ONLY_XML = 1,
385  ONLY_DOMAIN = 2
386  };
387 
397  virtual void ResetPropertiesToDefault(ResetPropertiesMode mode = DEFAULT);
398 
402  enum
403  {
404  COPY_PROXY_PROPERTY_VALUES_BY_REFERENCE = 0,
405 
406  COPY_PROXY_PROPERTY_VALUES_BY_CLONING // < No longer supported!!!
407  };
408 
410 
423  void Copy(vtkSMProxy* src);
424  void Copy(vtkSMProxy* src, const char* exceptionClass);
425  virtual void Copy(vtkSMProxy* src, const char* exceptionClass, int proxyPropertyCopyFlag);
427 
431  virtual void MarkModified(vtkSMProxy* modifiedProxy);
432 
434 
437  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
439 
441 
449  vtkGetObjectMacro(Hints, vtkPVXMLElement);
451 
453 
456  vtkGetMacro(ObjectsCreated, int);
458 
467  void InitializeAndCopyFromProxy(vtkSMProxy* source);
468 
473  virtual void MarkDirty(vtkSMProxy* modifiedProxy);
474 
479  vtkObjectBase* GetClientSideObject();
480 
482 
487  bool GatherInformation(vtkPVInformation* information);
488  bool GatherInformation(vtkPVInformation* information, vtkTypeUInt32 location);
490 
499  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root);
503  virtual vtkPVXMLElement* SaveXMLState(vtkPVXMLElement* root, vtkSMPropertyIterator* iter);
504 
512  virtual int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator);
513 
515 
520  void PrototypeOn() override;
521  void PrototypeOff() override;
522  void SetPrototype(bool undo) override;
524 
530  void UpdateSelfAndAllInputs();
531 
536  bool GetIsSubProxy();
537 
542  vtkSMProxy* GetParentProxy();
543 
549  vtkSMProxy* GetTrueParentProxy();
550 
558  void EnableLocalPushOnly() override;
559 
564  void DisableLocalPushOnly() override;
565 
570  const vtkSMMessage* GetFullState() override;
571 
579  void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator) override;
580 
584  vtkSMPropertyGroup* GetPropertyGroup(size_t index) const;
585 
589  size_t GetNumberOfPropertyGroups() const;
590 
592 
607  void SetLogName(const char* name);
608  vtkGetStringMacro(LogName);
610 
614  const char* GetLogNameOrDefault();
615 
616  bool GetPropertiesModified() { return this->PropertiesModified; }
617 
618 protected:
619  vtkSMProxy();
620  ~vtkSMProxy() override;
621 
625  void ExecuteStream(
626  const vtkClientServerStream& msg, bool ignore_errors = false, vtkTypeUInt32 location = 0);
627 
628  // Any method changing the annotations will trigger this method that will
629  // update the local full state as well as sending the annotation state part
630  // to the session.
631  virtual void UpdateAndPushAnnotationState();
632 
634 
637  virtual const vtkClientServerStream& GetLastResult();
638  virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
640 
647  virtual void AddProperty(const char* name, vtkSMProperty* prop);
648 
652  virtual void MarkConsumersAsDirty(vtkSMProxy* modifiedProxy);
653 
662  virtual void MarkDirtyFromProducer(
663  vtkSMProxy* modifiedProxy, vtkSMProxy* producer, vtkSMProperty* property);
664 
675  void MarkInputsAsDirty();
676 
678 
684  friend class vtkSMCameraLink;
685  friend class vtkSMCompoundProxy;
688  friend class vtkSMInputProperty;
693  friend class vtkSMProperty;
694  friend class vtkSMPropertyIterator;
695  friend class vtkSMProxyObserver;
696  friend class vtkSMProxyProperty;
697  friend class vtkSMProxyRegisterUndoElement;
698  friend class vtkSMProxyUnRegisterUndoElement;
700  friend class vtkSMSourceProxy;
701  friend class vtkSMStateLoader;
702  friend class vtkSMStateLocator;
703  friend class vtkSMUndoRedoStateLoader;
704  friend class vtkSMViewProxy;
706 
708 
713  vtkSetStringMacro(XMLName);
715 
717 
722  vtkSetStringMacro(XMLGroup);
724 
726 
732  vtkSetStringMacro(XMLLabel);
734 
736 
743  vtkSetStringMacro(XMLSubProxyName);
745 
751  virtual void CreateVTKObjects();
752 
758  void RemoveAllObservers();
759 
781  virtual void SetPropertyModifiedFlag(const char* name, int flag);
782 
788  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
789 
793  void RemoveSubProxy(const char* name);
794 
798  vtkSMProxy* GetSubProxy(const char* name);
799 
803  vtkSMProxy* GetSubProxy(unsigned int index);
804 
809  const char* GetSubProxyName(unsigned int index);
810 
815  const char* GetSubProxyName(vtkSMProxy*);
816 
820  unsigned int GetNumberOfSubProxies();
821 
826  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
827 
831  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
832 
836  virtual void RemoveAllConsumers();
837 
842  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
843 
847  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
848 
858  virtual void PostUpdateData(bool using_cache);
859 
864  void PostUpdateDataSelfOnly(bool using_cache);
865 
869  bool WarnIfDeprecated();
870 
876  virtual void UpdatePipelineInformation();
877 
878  // When an algorithm proxy is marked modified, NeedsUpdate is
879  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
880  // This is used to keep track of data information validity.
882 
884 
888  vtkSMProperty* NewProperty(const char* name);
889  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
891 
896  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
897 
904 
909 
911 
915  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
916  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
918 
926  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
927  const char* exposed_name, int overrideOK = 0);
928 
932  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
933 
935 
942  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = nullptr);
943 
953 
957  virtual void SetLogNameInternal(
958  const char* name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains);
959 
961 
964  vtkSetStringMacro(SIClassName);
965  vtkGetStringMacro(SIClassName);
966  char* SIClassName;
968 
970  char* XMLGroup;
971  char* XMLName;
972  char* XMLLabel;
977 
984 
990 
994  bool ArePropertiesModified();
995 
996  void SetHints(vtkPVXMLElement* hints);
997  void SetDeprecated(vtkPVXMLElement* deprecated);
998 
999  void SetXMLElement(vtkPVXMLElement* element);
1001 
1005 
1006  // Cached version of State
1008 
1009  // Flag used to break consumer loops.
1011 
1013 
1016  vtkSMProxy(const vtkSMProxy&) = delete;
1017  void operator=(const vtkSMProxy&) = delete;
1018 
1019 private:
1020  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
1021 
1022  friend class vtkSMProxyInfo;
1023 
1024  char* LogName;
1025  std::string DefaultLogName;
1026 };
1027 
1042 {
1043 public:
1045  : SIOBJECT(proxy)
1046  {
1047  }
1048 };
1049 
1065 {
1066  vtkSMProxy* Reference;
1068  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1069 
1070 public:
1072  : Reference(proxy)
1073  {
1074  }
1075 };
1077  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1078 
1079 #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:247
This defines a stream manipulator for the vtkClientServerStream that can be used to indicate to the i...
Definition: vtkSMProxy.h:1064
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:1071
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:1041
superclass for all SM properties
bool GetPropertiesModified()
Definition: vtkSMProxy.h:616
char * XMLGroup
Definition: vtkSMProxy.h:970
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:973
int InMarkModified
Definition: vtkSMProxy.h:1010
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1044
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:975
name
int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element) override
Read attributes from an XML element.
vtkSMMessage * State
Definition: vtkSMProxy.h:1007
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:1002
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:974
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:1012
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:971
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:152
int InUpdateVTKObjects
Avoids calls to UpdateVTKObjects in UpdateVTKObjects.
Definition: vtkSMProxy.h:983
void InvokeCommand(const char *name)
Convenience method equivalent to UpdateProperty(name, 1).
Definition: vtkSMProxy.h:254
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:1015
bool NeedsUpdate
Definition: vtkSMProxy.h:881
int DoNotModifyProperty
Definition: vtkSMProxy.h:976
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:205
vtkPVXMLElement * XMLElement
Definition: vtkSMProxy.h:1000
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1014
char * VTKClassName
Definition: vtkSMProxy.h:969
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:695
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:989
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:972
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:1004
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:965
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:1003