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 
616  void UpdateDomains();
617 
623  virtual void SaveState(
624  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
629  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
630 
634  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
635 
639  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
640 
642 
643  char* Command;
644 
646 
651 
652  char* XMLName;
653  char* XMLLabel;
654  vtkSetStringMacro(XMLLabel);
655 
656  char* PanelVisibility;
658  char* PanelWidget;
660 
662 
663  vtkSetMacro(InformationOnly, int);
664  int InformationOnly;
665 
666  vtkSetMacro(IgnoreSynchronization, int);
668 
669  vtkSMInformationHelper* InformationHelper;
670 
671  void SetInformationProperty(vtkSMProperty* ip);
673 
675  void SetDocumentation(vtkSMDocumentation*);
676 
678 
680 
683  bool SetBlockModifiedEvents(bool block)
684  {
685  bool prev = this->BlockModifiedEvents;
686  this->BlockModifiedEvents = block;
687  return prev;
688  }
690 
692 
696  vtkGetMacro(PendingModifiedEvents, bool);
698 
699  // Proxy is not reference-counted to avoid reference loops.
700  void SetParent(vtkSMProxy* proxy);
701 
703 
704  // Flag used to ignore property when building Proxy state for Undo/Redo state.
705  // The default value is false.
707  vtkSetMacro(StateIgnored, bool);
708  vtkBooleanMacro(StateIgnored, bool);
709 
710  // Links for properties that "subscribe" to changes to this property.
712 
713 private:
714  vtkSMProperty(const vtkSMProperty&) = delete;
715  void operator=(const vtkSMProperty&) = delete;
716 
717  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
718  // domains change.
719  void InvokeDomainModifiedEvent();
720 
725  void CreateAndSetPrettyLabel(const char* name);
726 
727  bool PendingModifiedEvents;
728  bool BlockModifiedEvents;
729 };
730 
731 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
732  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
733  { \
734  (void)SM_PROPERTY; \
735  typedef type SM_TT; \
736  call; \
737  }
738 /* clang-format off */
739 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
740  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
741  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
742  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
743  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
744 /* clang-format on */
745 
746 template <class DomainType>
748 {
749  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
750  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
751  {
752  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
753  {
754  return domain;
755  }
756  }
757  return nullptr;
758 }
759 #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