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 "vtkParaViewDeprecation.h" // for PARAVIEW_DEPRECATED_IN_5_12_0
132 #include "vtkRemotingServerManagerModule.h" //needed for exports
133 #include "vtkSMDomainIterator.h" // needed for vtkSMDomainIterator
134 #include "vtkSMMessageMinimal.h" // needed for vtkSMMessage
135 #include "vtkSMObject.h"
136 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
137 #include "vtkWeakPointer.h" // needed for vtkWeakPointer
138 
140 class vtkPVXMLElement;
141 class vtkSMDocumentation;
142 class vtkSMDomain;
143 class vtkSMDomainIterator;
144 class vtkSMInformationHelper;
145 class vtkSMPropertyLink;
146 class vtkSMProxy;
147 class vtkSMProxyLocator;
148 
150 
152 {
153 public:
154  static vtkSMProperty* New();
155  vtkTypeMacro(vtkSMProperty, vtkSMObject);
156  void PrintSelf(ostream& os, vtkIndent indent) override;
157 
159 
163  vtkSetStringMacro(Command);
164  vtkGetStringMacro(Command);
166 
168 
173  vtkSetMacro(ImmediateUpdate, int);
174  vtkGetMacro(ImmediateUpdate, int);
176 
185  int IsInDomains();
186 
195  int IsInDomains(vtkSMDomain** domain);
196 
201  void UnRegister(vtkObjectBase* obj) override;
202 
207  vtkSMDomainIterator* NewDomainIterator();
208 
213  vtkSMDomain* GetDomain(const char* name);
214 
218  vtkSMDomain* FindDomain(const char* classname);
219 
235  template <class DomainType>
236  inline DomainType* FindDomain();
237 
242  unsigned int GetNumberOfDomains();
243 
245 
249  vtkGetMacro(InformationOnly, int);
251 
253 
258  vtkGetMacro(IgnoreSynchronization, int);
260 
262 
267  vtkGetObjectMacro(InformationProperty, vtkSMProperty);
269 
275  void AddDomain(const char* name, vtkSMDomain* dom);
276 
281  virtual void AddLinkedProperty(vtkSMProperty* targetProperty);
282 
286  virtual void RemoveLinkedProperty(vtkSMProperty* targetProperty);
287 
296  virtual void RemoveFromSourceLink();
297 
299 
303  vtkSetMacro(Animateable, int);
304  vtkGetMacro(Animateable, int);
306 
308 
313  vtkSetMacro(IsInternal, int);
314  vtkGetMacro(IsInternal, int);
316 
318 
321  vtkSetMacro(NoCustomDefault, int);
322  vtkGetMacro(NoCustomDefault, int);
324 
326 
336  vtkSetStringMacro(PanelVisibility);
337  vtkGetStringMacro(PanelVisibility);
339 
341 
345  vtkSetStringMacro(PanelVisibilityDefaultForRepresentation);
346  vtkGetStringMacro(PanelVisibilityDefaultForRepresentation);
348 
350 
353  vtkSetStringMacro(PanelWidget);
354  vtkGetStringMacro(PanelWidget);
356 
358 
361  vtkSetStringMacro(DisableSubTrace);
362  vtkGetStringMacro(DisableSubTrace);
364 
369  virtual void Copy(vtkSMProperty* src);
370 
372 
377  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
379 
384  void ResetToDefault();
385 
391  virtual void ResetToXMLDefaults() {}
392 
411  virtual bool ResetToDomainDefaults(bool use_unchecked_values = false);
412 
414 
417  vtkGetStringMacro(XMLLabel);
419 
421 
427  vtkGetStringMacro(XMLName);
429 
431 
436  vtkGetMacro(Repeatable, int);
438 
440 
448  vtkGetObjectMacro(Hints, vtkPVXMLElement);
449  void SetHints(vtkPVXMLElement* hints);
451 
453 
456  void Modified() override
457  {
458  if (this->BlockModifiedEvents)
459  {
460  this->PendingModifiedEvents = true;
461  }
462  else
463  {
464  this->Superclass::Modified();
465  this->PendingModifiedEvents = false;
466  }
467  }
469 
475  vtkSMProxy* GetParent();
476 
477  // Flag used to ignore property when building Proxy state for Undo/Redo state.
478  // The default value is false.
479  virtual bool IsStateIgnored() { return this->StateIgnored; }
480 
486  virtual bool IsValueDefault() { return false; }
487 
493  bool HasDomainsWithRequiredProperties();
494 
498  virtual void ClearUncheckedElements() {}
499 
508  "Use vtkSMObject::CreatePrettyLabel(const std::string& name) instead.")
509  static const char* CreateNewPrettyLabel(const char* name);
510 
511 protected:
512  vtkSMProperty();
513  ~vtkSMProperty() override;
514 
516  friend class vtkSMProxy;
517  friend class vtkSMSubPropertyIterator;
518  friend class vtkSMDomainIterator;
519  friend class vtkSMSourceProxy;
520  friend class vtkSMDomain;
522 
526  virtual void WriteTo(vtkSMMessage* msg);
527 
531  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
532 
537  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
538 
543  virtual void UpdateAllInputs(){};
544 
546 
552  vtkSetStringMacro(XMLName);
554 
559  vtkSMProperty* NewProperty(const char* name);
560 
565  void AddDependent(vtkSMDomain* dom);
566 
570  void RemoveAllDependents();
571 
586  void UpdateDomains();
587 
593  virtual void SaveState(
594  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
599  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
600 
604  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
605 
609  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
610 
612 
613  char* Command;
614 
616 
621 
622  char* XMLName;
623  char* XMLLabel;
624  vtkSetStringMacro(XMLLabel);
625 
626  char* PanelVisibility;
628  char* PanelWidget;
630 
632 
633  vtkSetMacro(InformationOnly, int);
634  int InformationOnly;
635 
636  vtkSetMacro(IgnoreSynchronization, int);
638 
639  vtkSMInformationHelper* InformationHelper;
640 
641  void SetInformationProperty(vtkSMProperty* ip);
643 
645  void SetDocumentation(vtkSMDocumentation*);
646 
648 
650 
653  bool SetBlockModifiedEvents(bool block)
654  {
655  bool prev = this->BlockModifiedEvents;
656  this->BlockModifiedEvents = block;
657  return prev;
658  }
660 
662 
666  vtkGetMacro(PendingModifiedEvents, bool);
668 
669  // Proxy is not reference-counted to avoid reference loops.
670  void SetParent(vtkSMProxy* proxy);
671 
673 
674  // Flag used to ignore property when building Proxy state for Undo/Redo state.
675  // The default value is false.
677  vtkSetMacro(StateIgnored, bool);
678  vtkBooleanMacro(StateIgnored, bool);
679 
680  // Links for properties that "subscribe" to changes to this property.
682 
683 private:
684  vtkSMProperty(const vtkSMProperty&) = delete;
685  void operator=(const vtkSMProperty&) = delete;
686 
687  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
688  // domains change.
689  void InvokeDomainModifiedEvent();
690 
691  bool PendingModifiedEvents;
692  bool BlockModifiedEvents;
693 };
694 
695 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
696  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
697  { \
698  (void)SM_PROPERTY; \
699  typedef type SM_TT; \
700  call; \
701  }
702 /* clang-format off */
703 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
704  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
705  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
706  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
707  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
708 /* clang-format on */
709 
710 template <class DomainType>
712 {
713  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
714  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
715  {
716  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
717  {
718  return domain;
719  }
720  }
721  return nullptr;
722 }
723 #endif
vtkSMProperty * InformationProperty
#define PARAVIEW_DEPRECATED_IN_5_12_0(reason)
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