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;
692  friend class vtkSMProperty;
693  friend class vtkSMPropertyIterator;
694  friend class vtkSMProxyObserver;
695  friend class vtkSMProxyProperty;
696  friend class vtkSMProxyRegisterUndoElement;
697  friend class vtkSMProxyUnRegisterUndoElement;
699  friend class vtkSMSourceProxy;
700  friend class vtkSMStateLoader;
701  friend class vtkSMStateLocator;
702  friend class vtkSMUndoRedoStateLoader;
703  friend class vtkSMViewProxy;
705 
707 
712  vtkSetStringMacro(XMLName);
714 
716 
721  vtkSetStringMacro(XMLGroup);
723 
725 
731  vtkSetStringMacro(XMLLabel);
733 
735 
742  vtkSetStringMacro(XMLSubProxyName);
744 
750  virtual void CreateVTKObjects();
751 
757  void RemoveAllObservers();
758 
780  virtual void SetPropertyModifiedFlag(const char* name, int flag);
781 
787  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
788 
792  void RemoveSubProxy(const char* name);
793 
797  vtkSMProxy* GetSubProxy(const char* name);
798 
802  vtkSMProxy* GetSubProxy(unsigned int index);
803 
808  const char* GetSubProxyName(unsigned int index);
809 
814  const char* GetSubProxyName(vtkSMProxy*);
815 
819  unsigned int GetNumberOfSubProxies();
820 
825  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
826 
830  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
831 
835  virtual void RemoveAllConsumers();
836 
841  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
842 
846  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
847 
857  virtual void PostUpdateData(bool using_cache);
858 
863  void PostUpdateDataSelfOnly(bool using_cache);
864 
868  bool WarnIfDeprecated();
869 
875  virtual void UpdatePipelineInformation();
876 
877  // When an algorithm proxy is marked modified, NeedsUpdate is
878  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
879  // This is used to keep track of data information validity.
881 
883 
887  vtkSMProperty* NewProperty(const char* name);
888  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
890 
895  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
896 
903 
908 
910 
914  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
915  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
917 
925  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
926  const char* exposed_name, int overrideOK = 0);
927 
931  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
932 
934 
941  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = nullptr);
942 
952 
956  virtual void SetLogNameInternal(
957  const char* name, bool propagate_to_subproxies, bool propagate_to_proxylistdomains);
958 
960 
963  vtkSetStringMacro(SIClassName);
964  vtkGetStringMacro(SIClassName);
965  char* SIClassName;
967 
969  char* XMLGroup;
970  char* XMLName;
971  char* XMLLabel;
976 
983 
989 
993  bool ArePropertiesModified();
994 
995  void SetHints(vtkPVXMLElement* hints);
996  void SetDeprecated(vtkPVXMLElement* deprecated);
997 
998  void SetXMLElement(vtkPVXMLElement* element);
1000 
1004 
1005  // Cached version of State
1007 
1008  // Flag used to break consumer loops.
1010 
1012 
1015  vtkSMProxy(const vtkSMProxy&) = delete;
1016  void operator=(const vtkSMProxy&) = delete;
1017 
1018 private:
1019  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
1020 
1021  friend class vtkSMProxyInfo;
1022 
1023  char* LogName;
1024  std::string DefaultLogName;
1025 };
1026 
1041 {
1042 public:
1044  : SIOBJECT(proxy)
1045  {
1046  }
1047 };
1048 
1064 {
1065  vtkSMProxy* Reference;
1067  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1068 
1069 public:
1071  : Reference(proxy)
1072  {
1073  }
1074 };
1076  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
1077 
1078 #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:1063
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:1070
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:1040
superclass for all SM properties
bool GetPropertiesModified()
Definition: vtkSMProxy.h:616
char * XMLGroup
Definition: vtkSMProxy.h:969
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:972
int InMarkModified
Definition: vtkSMProxy.h:1009
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:1043
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:974
name
int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element) override
Read attributes from an XML element.
vtkSMMessage * State
Definition: vtkSMProxy.h:1006
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:1001
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:973
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)
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:1011
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:970
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:982
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:1014
bool NeedsUpdate
Definition: vtkSMProxy.h:880
int DoNotModifyProperty
Definition: vtkSMProxy.h:975
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:999
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1013
char * VTKClassName
Definition: vtkSMProxy.h:968
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:694
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:988
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:971
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:1003
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:964
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:1002