vtkSMProperty.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
128 #ifndef vtkSMProperty_h
129 #define vtkSMProperty_h
130 
131 #include "vtkRemotingServerManagerModule.h" //needed for exports
132 #include "vtkSMDomainIterator.h" // needed for vtkSMDomainIterator
133 #include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
134 #include "vtkSMObject.h"
135 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
136 #include "vtkWeakPointer.h" // needed for vtkWeakPointer
137 
139 class vtkPVXMLElement;
140 class vtkSMDocumentation;
141 class vtkSMDomain;
142 class vtkSMDomainIterator;
143 class vtkSMInformationHelper;
144 class vtkSMPropertyLink;
145 class vtkSMProxy;
146 class vtkSMProxyLocator;
147 
149 
151 {
152 public:
153  static vtkSMProperty* New();
154  vtkTypeMacro(vtkSMProperty, vtkSMObject);
155  void PrintSelf(ostream& os, vtkIndent indent) override;
156 
158 
162  vtkSetStringMacro(Command);
163  vtkGetStringMacro(Command);
165 
167 
172  vtkSetMacro(ImmediateUpdate, int);
173  vtkGetMacro(ImmediateUpdate, int);
175 
184  int IsInDomains();
185 
194  int IsInDomains(vtkSMDomain** domain);
195 
200  void UnRegister(vtkObjectBase* obj) override;
201 
206  vtkSMDomainIterator* NewDomainIterator();
207 
212  vtkSMDomain* GetDomain(const char* name);
213 
217  vtkSMDomain* FindDomain(const char* classname);
218 
234  template <class DomainType>
235  inline DomainType* FindDomain();
236 
241  unsigned int GetNumberOfDomains();
242 
244 
248  vtkGetMacro(InformationOnly, int);
250 
252 
257  vtkGetMacro(IgnoreSynchronization, int);
259 
261 
266  vtkGetObjectMacro(InformationProperty, vtkSMProperty);
268 
274  void AddDomain(const char* name, vtkSMDomain* dom);
275 
280  virtual void AddLinkedProperty(vtkSMProperty* targetProperty);
281 
285  virtual void RemoveLinkedProperty(vtkSMProperty* targetProperty);
286 
295  virtual void RemoveFromSourceLink();
296 
298 
302  vtkSetMacro(Animateable, int);
303  vtkGetMacro(Animateable, int);
305 
307 
312  vtkSetMacro(IsInternal, int);
313  vtkGetMacro(IsInternal, int);
315 
317 
320  vtkSetMacro(NoCustomDefault, int);
321  vtkGetMacro(NoCustomDefault, int);
323 
325 
335  vtkSetStringMacro(PanelVisibility);
336  vtkGetStringMacro(PanelVisibility);
338 
340 
344  vtkSetStringMacro(PanelVisibilityDefaultForRepresentation);
345  vtkGetStringMacro(PanelVisibilityDefaultForRepresentation);
347 
349 
352  vtkSetStringMacro(PanelWidget);
353  vtkGetStringMacro(PanelWidget);
355 
357 
360  vtkSetStringMacro(DisableSubTrace);
361  vtkGetStringMacro(DisableSubTrace);
363 
368  virtual void Copy(vtkSMProperty* src);
369 
371 
376  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
378 
383  void ResetToDefault();
384 
390  virtual void ResetToXMLDefaults() {}
391 
416  virtual bool ResetToDomainDefaults(bool use_unchecked_values = false);
417 
423  bool ResetToSettings(double priority);
424 
426 
429  vtkGetStringMacro(XMLLabel);
431 
433 
439  vtkGetStringMacro(XMLName);
441 
443 
448  vtkGetMacro(Repeatable, int);
450 
452 
460  vtkGetObjectMacro(Hints, vtkPVXMLElement);
461  void SetHints(vtkPVXMLElement* hints);
463 
465 
472  vtkGetObjectMacro(Deprecated, vtkPVXMLElement);
473  void SetDeprecated(vtkPVXMLElement* deprecated);
475 
477 
480  void Modified() override
481  {
482  if (this->BlockModifiedEvents)
483  {
484  this->PendingModifiedEvents = true;
485  }
486  else
487  {
488  this->Superclass::Modified();
489  this->PendingModifiedEvents = false;
490  }
491  }
493 
499  vtkSMProxy* GetParent();
500 
501  // Flag used to ignore property when building Proxy state for Undo/Redo state.
502  // The default value is false.
503  virtual bool IsStateIgnored() { return this->StateIgnored; }
504 
510  virtual bool IsValueDefault() { return false; }
511 
517  bool HasDomainsWithRequiredProperties();
518 
522  virtual void ClearUncheckedElements() {}
523 
524 protected:
525  vtkSMProperty();
526  ~vtkSMProperty() override;
527 
529  friend class vtkSMProxy;
530  friend class vtkSMSubPropertyIterator;
531  friend class vtkSMDomainIterator;
532  friend class vtkSMSourceProxy;
533  friend class vtkSMDomain;
535 
539  virtual void WriteTo(vtkSMMessage* msg);
540 
544  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
545 
550  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
551 
556  virtual void UpdateAllInputs(){};
557 
559 
565  vtkSetStringMacro(XMLName);
567 
572  vtkSMProperty* NewProperty(const char* name);
573 
578  void AddDependent(vtkSMDomain* dom);
579 
583  void RemoveAllDependents();
584 
599  void UpdateDomains();
600 
606  virtual void SaveState(
607  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
612  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
613 
617  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
618 
622  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
623 
627  bool WarnIfDeprecated();
628 
629  vtkPVXMLElement* Hints = nullptr;
630  vtkPVXMLElement* Deprecated = nullptr;
631 
632  char* Command;
633 
635 
640 
641  char* XMLName;
642  char* XMLLabel;
643  vtkSetStringMacro(XMLLabel);
644 
645  char* PanelVisibility;
647  char* PanelWidget;
649 
651 
652  vtkSetMacro(InformationOnly, int);
653  int InformationOnly;
654 
655  vtkSetMacro(IgnoreSynchronization, int);
657 
658  vtkSMInformationHelper* InformationHelper;
659 
660  void SetInformationProperty(vtkSMProperty* ip);
662 
664  void SetDocumentation(vtkSMDocumentation*);
665 
667 
669 
672  bool SetBlockModifiedEvents(bool block)
673  {
674  bool prev = this->BlockModifiedEvents;
675  this->BlockModifiedEvents = block;
676  return prev;
677  }
679 
681 
685  vtkGetMacro(PendingModifiedEvents, bool);
687 
688  // Proxy is not reference-counted to avoid reference loops.
689  void SetParent(vtkSMProxy* proxy);
690 
692 
693  // Flag used to ignore property when building Proxy state for Undo/Redo state.
694  // The default value is false.
696  vtkSetMacro(StateIgnored, bool);
697  vtkBooleanMacro(StateIgnored, bool);
698 
699  // Links for properties that "subscribe" to changes to this property.
701 
702 private:
703  vtkSMProperty(const vtkSMProperty&) = delete;
704  void operator=(const vtkSMProperty&) = delete;
705 
706  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
707  // domains change.
708  void InvokeDomainModifiedEvent();
709 
710  bool PendingModifiedEvents;
711  bool BlockModifiedEvents;
712 };
713 
714 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
715  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
716  { \
717  (void)SM_PROPERTY; \
718  typedef type SM_TT; \
719  call; \
720  }
721 /* clang-format off */
722 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
723  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
724  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
725  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
726  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
727 /* clang-format on */
728 
729 template <class DomainType>
731 {
732  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
733  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
734  {
735  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
736  {
737  return domain;
738  }
739  }
740  return nullptr;
741 }
742 #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:38
virtual bool IsStateIgnored()
superclass for most server manager classes
Definition: vtkSMObject.h:17
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...
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:140
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.
priority
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