ParaView
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 "vtkPVServerManagerCoreModule.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 
152 class VTKPVSERVERMANAGERCORE_EXPORT vtkSMProxy : public vtkSMRemoteObject
153 {
154 public:
155  static vtkSMProxy* New();
157  void PrintSelf(ostream& os, vtkIndent indent);
158 
159  // Descritpion:
160  // Set or override a key/value pair as annotation to that proxy.
161  // If the value is NULL, 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  virtual void SetLocation(vtkTypeUInt32);
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  virtual void PrototypeOn();
521  virtual void PrototypeOff();
522  virtual void SetPrototype(bool undo);
524 
530  void UpdateSelfAndAllInputs();
531 
536  bool GetIsSubProxy();
537 
542  vtkSMProxy* GetParentProxy();
543 
549  vtkSMProxy* GetTrueParentProxy();
550 
558  virtual void EnableLocalPushOnly();
559 
564  virtual void DisableLocalPushOnly();
565 
572  virtual const vtkSMMessage* GetFullState();
573 
581  virtual void LoadState(const vtkSMMessage* msg, vtkSMProxyLocator* locator);
582 
586  vtkSMPropertyGroup* GetPropertyGroup(size_t index) const;
587 
591  size_t GetNumberOfPropertyGroups() const;
592 
593 protected:
594  vtkSMProxy();
595  ~vtkSMProxy();
596 
600  void ExecuteStream(
601  const vtkClientServerStream& msg, bool ignore_errors = false, vtkTypeUInt32 location = 0);
602 
603  // Any method changing the annotations will trigger this method that will
604  // update the local full state as well as sending the annotation state part
605  // to the session.
606  virtual void UpdateAndPushAnnotationState();
607 
609 
612  virtual const vtkClientServerStream& GetLastResult();
613  virtual const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location);
615 
622  virtual void AddProperty(const char* name, vtkSMProperty* prop);
623 
627  virtual void MarkConsumersAsDirty(vtkSMProxy* modifiedProxy);
628 
630 
636  friend class vtkSMCameraLink;
637  friend class vtkSMCompoundProxy;
639  friend class vtkSMInputProperty;
641  friend class vtkSMPart;
642  friend class vtkSMProperty;
643  friend class vtkSMPropertyIterator;
646  friend class vtkSMProxyObserver;
647  friend class vtkSMProxyProperty;
648  friend class vtkSMProxyRegisterUndoElement;
649  friend class vtkSMProxyUnRegisterUndoElement;
650  friend class vtkSMSourceProxy;
651  friend class vtkSMUndoRedoStateLoader;
653  friend class vtkSMStateLocator;
656 
658 
663  vtkSetStringMacro(XMLName);
665 
667 
672  vtkSetStringMacro(XMLGroup);
674 
676 
682  vtkSetStringMacro(XMLLabel);
684 
686 
693  vtkSetStringMacro(XMLSubProxyName);
695 
701  virtual void CreateVTKObjects();
702 
708  void RemoveAllObservers();
709 
731  virtual void SetPropertyModifiedFlag(const char* name, int flag);
732 
738  void AddSubProxy(const char* name, vtkSMProxy* proxy, int overrideOK = 0);
739 
743  void RemoveSubProxy(const char* name);
744 
748  vtkSMProxy* GetSubProxy(const char* name);
749 
753  vtkSMProxy* GetSubProxy(unsigned int index);
754 
759  const char* GetSubProxyName(unsigned int index);
760 
765  const char* GetSubProxyName(vtkSMProxy*);
766 
770  unsigned int GetNumberOfSubProxies();
771 
776  virtual void AddConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
777 
781  virtual void RemoveConsumer(vtkSMProperty* property, vtkSMProxy* proxy);
782 
786  virtual void RemoveAllConsumers();
787 
792  void AddProducer(vtkSMProperty* property, vtkSMProxy* proxy);
793 
797  void RemoveProducer(vtkSMProperty* property, vtkSMProxy* proxy);
798 
804  virtual void PostUpdateData();
805 
809  bool WarnIfDeprecated();
810 
816  virtual void UpdatePipelineInformation();
817 
818  // When an algorithm proxy is marked modified, NeedsUpdate is
819  // set to true. In PostUpdateData(), NeedsUpdate is set to false.
820  // This is used to keep track of data information validity.
822 
824 
828  vtkSMProperty* NewProperty(const char* name);
829  vtkSMProperty* NewProperty(const char* name, vtkPVXMLElement* propElement);
831 
836  void LinkProperty(vtkSMProperty* inputProperty, vtkSMProperty* outputProperty);
837 
844 
846 
850  void SetupExposedProperties(const char* subproxy_name, vtkPVXMLElement* element);
851  void SetupSharedProperties(vtkSMProxy* subproxy, vtkPVXMLElement* element);
853 
861  void ExposeSubProxyProperty(const char* subproxy_name, const char* property_name,
862  const char* exposed_name, int overrideOK = 0);
863 
867  virtual void ExecuteSubProxyEvent(vtkSMProxy* o, unsigned long event, void* data);
868 
870 
877  virtual void UpdatePropertyInformationInternal(vtkSMProperty* prop = NULL);
878 
880 
883  vtkSetStringMacro(SIClassName);
884  vtkGetStringMacro(SIClassName);
885  char* SIClassName;
887 
889  char* XMLGroup;
890  char* XMLName;
891  char* XMLLabel;
896 
903 
909 
913  bool ArePropertiesModified();
914 
915  void SetHints(vtkPVXMLElement* hints);
916  void SetDeprecated(vtkPVXMLElement* deprecated);
917 
918  void SetXMLElement(vtkPVXMLElement* element);
920 
924 
925  // Cached version of State
927 
928  // Flag used to break consumer loops.
930 
931  vtkWeakPointer<vtkSMProxy> ParentProxy;
932 
933 protected:
936  vtkSMProxy(const vtkSMProxy&) VTK_DELETE_FUNCTION;
937  void operator=(const vtkSMProxy&) VTK_DELETE_FUNCTION;
938 
939 private:
940  vtkSMProperty* SetupExposedProperty(vtkPVXMLElement* propertyElement, const char* subproxy_name);
941 };
942 
956 class VTKPVSERVERMANAGERCORE_EXPORT SIPROXY : public SIOBJECT
957 {
958 public:
960  : SIOBJECT(proxy)
961  {
962  }
963 };
964 
979 class VTKPVSERVERMANAGERCORE_EXPORT VTKOBJECT
980 {
981  vtkSMProxy* Reference;
982  friend VTKPVSERVERMANAGERCORE_EXPORT vtkClientServerStream& operator<<(
983  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
984 
985 public:
987  : Reference(proxy)
988  {
989  }
990 };
991 VTKPVSERVERMANAGERCORE_EXPORT vtkClientServerStream& operator<<(
992  vtkClientServerStream& stream, const VTKOBJECT& manipulator);
993 
994 #endif
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:979
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)
iterates over a subset of a proxy&#39;s properties
virtual void UpdatePropertyInformationInternal(vtkSMProperty *prop=NULL)
Called to update the property information on the property.
virtual void PrototypeOff()
Allow user to set the remote object to be discard for Undo/Redo action.
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:986
void RemoveAllObservers()
Cleanup code.
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 ...
virtual void PostUpdateData()
Overwritten from superclass to invoke.
void SetupSharedProperties(vtkSMProxy *subproxy, vtkPVXMLElement *element)
Read attributes from an XML element.
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.
This defines a stream manipulator for the vtkClientServerStream that can be used to indicate to the i...
Definition: vtkSMProxy.h:956
superclass for all SM properties
char * XMLGroup
Definition: vtkSMProxy.h:889
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:892
VTKPVSERVERMANAGERCORE_EXPORT vtkClientServerStream & operator<<(vtkClientServerStream &stream, const VTKOBJECT &manipulator)
int InMarkModified
Definition: vtkSMProxy.h:929
SIPROXY(vtkSMProxy *proxy)
Definition: vtkSMProxy.h:959
bool WarnIfDeprecated()
If a proxy is deprecated, prints a warning.
int DoNotUpdateImmediately
Definition: vtkSMProxy.h:894
vtkSMMessage * State
Definition: vtkSMProxy.h:926
vtkSMDocumentation * Documentation
Definition: vtkSMProxy.h:921
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
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 normaly to the server location.
virtual void CreateVTKObjects()
Call superclass&#39; and then assigns a new executive (vtkCompositeDataPipeline)
int ObjectsCreated
Definition: vtkSMProxy.h:893
void AddProducer(vtkSMProperty *property, vtkSMProxy *proxy)
Called by an proxy/input property to add property, proxy pair to the list of producers.
proxy for a VTK source on a server
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:931
deserializes proxies from their Protobuf states.
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
char * XMLName
Definition: vtkSMProxy.h:890
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.
virtual void UpdatePipelineInformation()
Calls UpdateInformation() on all sources.
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:902
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.
virtual int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element)
Read attributes from an XML element.
vtkSMProxyObserver * SubProxyObserver
Definition: vtkSMProxy.h:935
bool NeedsUpdate
Definition: vtkSMProxy.h:821
int DoNotModifyProperty
Definition: vtkSMProxy.h:895
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:919
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:934
char * VTKClassName
Definition: vtkSMProxy.h:888
void PrintSelf(ostream &os, vtkIndent indent)
virtual void RemoveAllConsumers()
Remove all consumers.
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:646
void SetHints(vtkPVXMLElement *hints)
bool PropertiesModified
Flag used to help speed up UpdateVTKObjects and ArePropertiesModified calls.
Definition: vtkSMProxy.h:908
Superclass for information objects.
char * XMLLabel
Definition: vtkSMProxy.h:891
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:923
Class used to retreive a given message state based on its GlobalID.
char * SIClassName
SIClassName identifies the classname for the helper on the server side.
Definition: vtkSMProxy.h:884
vtkSMPropertyGroup * NewPropertyGroup(vtkPVXMLElement *propElement)
Parses the XML to create a new property group.
vtkPVXMLElement * Hints
Definition: vtkSMProxy.h:922