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 
413 
416  vtkGetStringMacro(XMLLabel);
418 
420 
426  vtkGetStringMacro(XMLName);
428 
430 
435  vtkGetMacro(Repeatable, int);
437 
439 
447  vtkGetObjectMacro(Hints, vtkPVXMLElement);
448  void SetHints(vtkPVXMLElement* hints);
450 
452 
455  void Modified() override
456  {
457  if (this->BlockModifiedEvents)
458  {
459  this->PendingModifiedEvents = true;
460  }
461  else
462  {
463  this->Superclass::Modified();
464  this->PendingModifiedEvents = false;
465  }
466  }
468 
474  vtkSMProxy* GetParent();
475 
476  // Flag used to ignore property when building Proxy state for Undo/Redo state.
477  // The default value is false.
478  virtual bool IsStateIgnored() { return this->StateIgnored; }
479 
485  virtual bool IsValueDefault() { return false; }
486 
492  bool HasDomainsWithRequiredProperties();
493 
497  virtual void ClearUncheckedElements() {}
498 
499 protected:
500  vtkSMProperty();
501  ~vtkSMProperty() override;
502 
504  friend class vtkSMProxy;
505  friend class vtkSMSubPropertyIterator;
506  friend class vtkSMDomainIterator;
507  friend class vtkSMSourceProxy;
508  friend class vtkSMDomain;
510 
514  virtual void WriteTo(vtkSMMessage* msg);
515 
519  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
520 
525  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
526 
531  virtual void UpdateAllInputs(){};
532 
534 
540  vtkSetStringMacro(XMLName);
542 
547  vtkSMProperty* NewProperty(const char* name);
548 
553  void AddDependent(vtkSMDomain* dom);
554 
558  void RemoveAllDependents();
559 
574  void UpdateDomains();
575 
581  virtual void SaveState(
582  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
587  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
588 
592  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
593 
597  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
598 
600 
601  char* Command;
602 
604 
609 
610  char* XMLName;
611  char* XMLLabel;
612  vtkSetStringMacro(XMLLabel);
613 
614  char* PanelVisibility;
616  char* PanelWidget;
618 
620 
621  vtkSetMacro(InformationOnly, int);
622  int InformationOnly;
623 
624  vtkSetMacro(IgnoreSynchronization, int);
626 
627  vtkSMInformationHelper* InformationHelper;
628 
629  void SetInformationProperty(vtkSMProperty* ip);
631 
633  void SetDocumentation(vtkSMDocumentation*);
634 
636 
638 
641  bool SetBlockModifiedEvents(bool block)
642  {
643  bool prev = this->BlockModifiedEvents;
644  this->BlockModifiedEvents = block;
645  return prev;
646  }
648 
650 
654  vtkGetMacro(PendingModifiedEvents, bool);
656 
657  // Proxy is not reference-counted to avoid reference loops.
658  void SetParent(vtkSMProxy* proxy);
659 
661 
662  // Flag used to ignore property when building Proxy state for Undo/Redo state.
663  // The default value is false.
665  vtkSetMacro(StateIgnored, bool);
666  vtkBooleanMacro(StateIgnored, bool);
667 
668  // Links for properties that "subscribe" to changes to this property.
670 
671 private:
672  vtkSMProperty(const vtkSMProperty&) = delete;
673  void operator=(const vtkSMProperty&) = delete;
674 
675  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
676  // domains change.
677  void InvokeDomainModifiedEvent();
678 
679  bool PendingModifiedEvents;
680  bool BlockModifiedEvents;
681 };
682 
683 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
684  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
685  { \
686  (void)SM_PROPERTY; \
687  typedef type SM_TT; \
688  call; \
689  }
690 /* clang-format off */
691 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
692  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
693  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
694  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
695  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
696 /* clang-format on */
697 
698 template <class DomainType>
700 {
701  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
702  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
703  {
704  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
705  {
706  return domain;
707  }
708  }
709  return nullptr;
710 }
711 #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.
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