vtkSMProperty.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkSMProperty.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 =========================================================================*/
133 #ifndef vtkSMProperty_h
134 #define vtkSMProperty_h
135 
136 #include "vtkRemotingServerManagerModule.h" //needed for exports
137 #include "vtkSMDomainIterator.h" // needed for vtkSMDomainIterator
138 #include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
139 #include "vtkSMObject.h"
140 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
141 #include "vtkWeakPointer.h" // needed for vtkWeakPointer
142 
144 class vtkPVXMLElement;
145 class vtkSMDocumentation;
146 class vtkSMDomain;
147 class vtkSMDomainIterator;
148 class vtkSMInformationHelper;
149 class vtkSMPropertyLink;
150 class vtkSMProxy;
151 class vtkSMProxyLocator;
152 
154 
156 {
157 public:
158  static vtkSMProperty* New();
159  vtkTypeMacro(vtkSMProperty, vtkSMObject);
160  void PrintSelf(ostream& os, vtkIndent indent) override;
161 
163 
167  vtkSetStringMacro(Command);
168  vtkGetStringMacro(Command);
170 
172 
177  vtkSetMacro(ImmediateUpdate, int);
178  vtkGetMacro(ImmediateUpdate, int);
180 
189  int IsInDomains();
190 
199  int IsInDomains(vtkSMDomain** domain);
200 
205  void UnRegister(vtkObjectBase* obj) override;
206 
211  vtkSMDomainIterator* NewDomainIterator();
212 
217  vtkSMDomain* GetDomain(const char* name);
218 
222  vtkSMDomain* FindDomain(const char* classname);
223 
239  template <class DomainType>
240  inline DomainType* FindDomain();
241 
246  unsigned int GetNumberOfDomains();
247 
249 
253  vtkGetMacro(InformationOnly, int);
255 
257 
262  vtkGetMacro(IgnoreSynchronization, int);
264 
266 
271  vtkGetObjectMacro(InformationProperty, vtkSMProperty);
273 
279  void AddDomain(const char* name, vtkSMDomain* dom);
280 
285  virtual void AddLinkedProperty(vtkSMProperty* targetProperty);
286 
290  virtual void RemoveLinkedProperty(vtkSMProperty* targetProperty);
291 
300  virtual void RemoveFromSourceLink();
301 
303 
307  vtkSetMacro(Animateable, int);
308  vtkGetMacro(Animateable, int);
310 
312 
317  vtkSetMacro(IsInternal, int);
318  vtkGetMacro(IsInternal, int);
320 
322 
325  vtkSetMacro(NoCustomDefault, int);
327 
329 
332  vtkGetMacro(NoCustomDefault, int);
334 
336 
346  vtkSetStringMacro(PanelVisibility)
348 
350 
353  vtkGetStringMacro(PanelVisibility)
355 
357 
361  vtkSetStringMacro(PanelVisibilityDefaultForRepresentation)
363 
365 
369  vtkGetStringMacro(PanelVisibilityDefaultForRepresentation)
371 
373 
376  vtkSetStringMacro(PanelWidget)
378 
380 
383  vtkGetStringMacro(PanelWidget)
385 
387 
390  vtkSetStringMacro(DisableSubTrace)
392 
394 
397  vtkGetStringMacro(DisableSubTrace)
399 
404  virtual void Copy(vtkSMProperty* src);
405 
407 
412  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
414 
419  void ResetToDefault();
420 
426  virtual void ResetToXMLDefaults() {}
427 
446  virtual bool ResetToDomainDefaults(bool use_unchecked_values = false);
447 
449 
452  vtkGetStringMacro(XMLLabel);
454 
456 
462  vtkGetStringMacro(XMLName);
464 
466 
471  vtkGetMacro(Repeatable, int);
473 
475 
483  vtkGetObjectMacro(Hints, vtkPVXMLElement);
484  void SetHints(vtkPVXMLElement* hints);
486 
488 
491  void Modified() override
492  {
493  if (this->BlockModifiedEvents)
494  {
495  this->PendingModifiedEvents = true;
496  }
497  else
498  {
499  this->Superclass::Modified();
500  this->PendingModifiedEvents = false;
501  }
502  }
504 
510  vtkSMProxy* GetParent();
511 
512  // Flag used to ignore property when building Proxy state for Undo/Redo state.
513  // The default value is false.
514  virtual bool IsStateIgnored() { return this->StateIgnored; }
515 
521  virtual bool IsValueDefault() { return false; }
522 
528  bool HasDomainsWithRequiredProperties();
529 
533  virtual void ClearUncheckedElements() {}
534 
539  static const char* CreateNewPrettyLabel(const char* name);
540 
541 protected:
542  vtkSMProperty();
543  ~vtkSMProperty() override;
544 
546  friend class vtkSMProxy;
547  friend class vtkSMSubPropertyIterator;
548  friend class vtkSMDomainIterator;
549  friend class vtkSMSourceProxy;
550  friend class vtkSMDomain;
552 
556  virtual void WriteTo(vtkSMMessage* msg);
557 
561  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
562 
567  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
568 
573  virtual void UpdateAllInputs(){};
574 
576 
582  vtkSetStringMacro(XMLName);
584 
589  vtkSMProperty* NewProperty(const char* name);
590 
595  void AddDependent(vtkSMDomain* dom);
596 
600  void RemoveAllDependents();
601 
613  void UpdateDomains();
614 
620  virtual void SaveState(
621  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
626  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
627 
631  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
632 
636  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
637 
639 
640  char* Command;
641 
643 
648 
649  char* XMLName;
650  char* XMLLabel;
651  vtkSetStringMacro(XMLLabel);
652 
653  char* PanelVisibility;
655  char* PanelWidget;
657 
659 
660  vtkSetMacro(InformationOnly, int);
661  int InformationOnly;
662 
663  vtkSetMacro(IgnoreSynchronization, int);
665 
666  vtkSMInformationHelper* InformationHelper;
667 
668  void SetInformationProperty(vtkSMProperty* ip);
670 
672  void SetDocumentation(vtkSMDocumentation*);
673 
675 
677 
680  bool SetBlockModifiedEvents(bool block)
681  {
682  bool prev = this->BlockModifiedEvents;
683  this->BlockModifiedEvents = block;
684  return prev;
685  }
687 
689 
693  vtkGetMacro(PendingModifiedEvents, bool);
695 
696  // Proxy is not reference-counted to avoid reference loops.
697  void SetParent(vtkSMProxy* proxy);
698 
700 
701  // Flag used to ignore property when building Proxy state for Undo/Redo state.
702  // The default value is false.
704  vtkSetMacro(StateIgnored, bool);
705  vtkBooleanMacro(StateIgnored, bool);
706 
707  // Links for properties that "subscribe" to changes to this property.
709 
710 private:
711  vtkSMProperty(const vtkSMProperty&) = delete;
712  void operator=(const vtkSMProperty&) = delete;
713 
714  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
715  // domains change.
716  void InvokeDomainModifiedEvent();
717 
722  void CreateAndSetPrettyLabel(const char* name);
723 
724  bool PendingModifiedEvents;
725  bool BlockModifiedEvents;
726 };
727 
728 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
729  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
730  { \
731  (void)SM_PROPERTY; \
732  typedef type SM_TT; \
733  call; \
734  }
735 /* clang-format off */
736 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
737  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
738  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
739  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
740  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
741 /* clang-format on */
742 
743 template <class DomainType>
745 {
746  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
747  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
748  {
749  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
750  {
751  return domain;
752  }
753  }
754  return nullptr;
755 }
756 #endif
vtkSMProperty * InformationProperty
static vtkSmartPointer< T > Take(T *t)
iterates over domains of a property
vtkSMDomainIterator * DomainIterator
vtkSMPropertyLink * Links
#define VTKREMOTINGSERVERMANAGER_EXPORT
superclass for all SM properties
void Modified() override
Overridden to support blocking of modified events.
Store messages for the interpreter.
name
DomainType * FindDomain()
Same as FindDomain(classname), except the classname is deduced from the type.
vtkSMInformationHelper * InformationHelper
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
virtual void UnRegister(vtkObjectBase *o)
represents the possible values a property can have
Definition: vtkSMDomain.h:49
virtual bool IsStateIgnored()
superclass for most server manager classes
Definition: vtkSMObject.h:29
proxy for a VTK source on a server
int IgnoreSynchronization
virtual void Modified()
char * PanelWidget
char * PanelVisibility
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkPVXMLElement * Hints
bool SetBlockModifiedEvents(bool block)
Block/unblock modified events, returns the current state of the block flag.
virtual void ReadFrom(const vtkSMMessage *, int vtkNotUsed(message_offset), vtkSMProxyLocator *)
Let the property read and set its content from the stream.
vtkSMDocumentation * Documentation
This is the concrete implementation for the Undo element for a property modification event...
static vtkSMObject * New()
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152
is used to locate proxies referred to in state xmls while loading state files.
vtkWeakPointer< vtkSMProxy > Proxy
class providing access to the documentation for a vtkSMProxy.
vtkSMPropertyInternals * PInternals
virtual void ResetToXMLDefaults()
For properties that support specifying defaults in XML configuration, this method will reset the prop...
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
char * PanelVisibilityDefaultForRepresentation
virtual bool IsValueDefault()
Returns true if the property&#39;s value is different from the default value.
virtual void ClearUncheckedElements()
Use this method to clear unchecked values set of this property.
char * DisableSubTrace
virtual void UpdateAllInputs()
Update all proxies referred by this property (if any).
void PrintSelf(ostream &os, vtkIndent indent) override