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 
410  virtual bool ResetToDomainDefaults(bool use_unchecked_values = false);
411 
417  bool ResetToSettings(double priority);
418 
420 
423  vtkGetStringMacro(XMLLabel);
425 
427 
433  vtkGetStringMacro(XMLName);
435 
437 
442  vtkGetMacro(Repeatable, int);
444 
446 
454  vtkGetObjectMacro(Hints, vtkPVXMLElement);
455  void SetHints(vtkPVXMLElement* hints);
457 
459 
462  void Modified() override
463  {
464  if (this->BlockModifiedEvents)
465  {
466  this->PendingModifiedEvents = true;
467  }
468  else
469  {
470  this->Superclass::Modified();
471  this->PendingModifiedEvents = false;
472  }
473  }
475 
481  vtkSMProxy* GetParent();
482 
483  // Flag used to ignore property when building Proxy state for Undo/Redo state.
484  // The default value is false.
485  virtual bool IsStateIgnored() { return this->StateIgnored; }
486 
492  virtual bool IsValueDefault() { return false; }
493 
499  bool HasDomainsWithRequiredProperties();
500 
504  virtual void ClearUncheckedElements() {}
505 
506 protected:
507  vtkSMProperty();
508  ~vtkSMProperty() override;
509 
511  friend class vtkSMProxy;
512  friend class vtkSMSubPropertyIterator;
513  friend class vtkSMDomainIterator;
514  friend class vtkSMSourceProxy;
515  friend class vtkSMDomain;
517 
521  virtual void WriteTo(vtkSMMessage* msg);
522 
526  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
527 
532  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
533 
538  virtual void UpdateAllInputs(){};
539 
541 
547  vtkSetStringMacro(XMLName);
549 
554  vtkSMProperty* NewProperty(const char* name);
555 
560  void AddDependent(vtkSMDomain* dom);
561 
565  void RemoveAllDependents();
566 
581  void UpdateDomains();
582 
588  virtual void SaveState(
589  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
594  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
595 
599  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
600 
604  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
605 
607 
608  char* Command;
609 
611 
616 
617  char* XMLName;
618  char* XMLLabel;
619  vtkSetStringMacro(XMLLabel);
620 
621  char* PanelVisibility;
623  char* PanelWidget;
625 
627 
628  vtkSetMacro(InformationOnly, int);
629  int InformationOnly;
630 
631  vtkSetMacro(IgnoreSynchronization, int);
633 
634  vtkSMInformationHelper* InformationHelper;
635 
636  void SetInformationProperty(vtkSMProperty* ip);
638 
640  void SetDocumentation(vtkSMDocumentation*);
641 
643 
645 
648  bool SetBlockModifiedEvents(bool block)
649  {
650  bool prev = this->BlockModifiedEvents;
651  this->BlockModifiedEvents = block;
652  return prev;
653  }
655 
657 
661  vtkGetMacro(PendingModifiedEvents, bool);
663 
664  // Proxy is not reference-counted to avoid reference loops.
665  void SetParent(vtkSMProxy* proxy);
666 
668 
669  // Flag used to ignore property when building Proxy state for Undo/Redo state.
670  // The default value is false.
672  vtkSetMacro(StateIgnored, bool);
673  vtkBooleanMacro(StateIgnored, bool);
674 
675  // Links for properties that "subscribe" to changes to this property.
677 
678 private:
679  vtkSMProperty(const vtkSMProperty&) = delete;
680  void operator=(const vtkSMProperty&) = delete;
681 
682  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
683  // domains change.
684  void InvokeDomainModifiedEvent();
685 
686  bool PendingModifiedEvents;
687  bool BlockModifiedEvents;
688 };
689 
690 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
691  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
692  { \
693  (void)SM_PROPERTY; \
694  typedef type SM_TT; \
695  call; \
696  }
697 /* clang-format off */
698 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
699  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
700  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
701  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
702  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
703 /* clang-format on */
704 
705 template <class DomainType>
707 {
708  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
709  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
710  {
711  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
712  {
713  return domain;
714  }
715  }
716  return nullptr;
717 }
718 #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:37
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...
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: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