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 
542  static const char* CreateNewPrettyLabel(const char* name);
543 
544 protected:
545  vtkSMProperty();
546  ~vtkSMProperty() override;
547 
549  friend class vtkSMProxy;
550  friend class vtkSMSubPropertyIterator;
551  friend class vtkSMDomainIterator;
552  friend class vtkSMSourceProxy;
553  friend class vtkSMDomain;
555 
559  virtual void WriteTo(vtkSMMessage* msg);
560 
564  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
565 
570  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
571 
576  virtual void UpdateAllInputs(){};
577 
579 
585  vtkSetStringMacro(XMLName);
587 
592  vtkSMProperty* NewProperty(const char* name);
593 
598  void AddDependent(vtkSMDomain* dom);
599 
603  void RemoveAllDependents();
604 
619  void UpdateDomains();
620 
626  virtual void SaveState(
627  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
632  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
633 
637  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
638 
642  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
643 
645 
646  char* Command;
647 
649 
654 
655  char* XMLName;
656  char* XMLLabel;
657  vtkSetStringMacro(XMLLabel);
658 
659  char* PanelVisibility;
661  char* PanelWidget;
663 
665 
666  vtkSetMacro(InformationOnly, int);
667  int InformationOnly;
668 
669  vtkSetMacro(IgnoreSynchronization, int);
671 
672  vtkSMInformationHelper* InformationHelper;
673 
674  void SetInformationProperty(vtkSMProperty* ip);
676 
678  void SetDocumentation(vtkSMDocumentation*);
679 
681 
683 
686  bool SetBlockModifiedEvents(bool block)
687  {
688  bool prev = this->BlockModifiedEvents;
689  this->BlockModifiedEvents = block;
690  return prev;
691  }
693 
695 
699  vtkGetMacro(PendingModifiedEvents, bool);
701 
702  // Proxy is not reference-counted to avoid reference loops.
703  void SetParent(vtkSMProxy* proxy);
704 
706 
707  // Flag used to ignore property when building Proxy state for Undo/Redo state.
708  // The default value is false.
710  vtkSetMacro(StateIgnored, bool);
711  vtkBooleanMacro(StateIgnored, bool);
712 
713  // Links for properties that "subscribe" to changes to this property.
715 
716 private:
717  vtkSMProperty(const vtkSMProperty&) = delete;
718  void operator=(const vtkSMProperty&) = delete;
719 
720  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
721  // domains change.
722  void InvokeDomainModifiedEvent();
723 
728  void CreateAndSetPrettyLabel(const char* name);
729 
730  bool PendingModifiedEvents;
731  bool BlockModifiedEvents;
732 };
733 
734 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
735  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
736  { \
737  (void)SM_PROPERTY; \
738  typedef type SM_TT; \
739  call; \
740  }
741 /* clang-format off */
742 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
743  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
744  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
745  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
746  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, std::string, prop, call)
747 /* clang-format on */
748 
749 template <class DomainType>
751 {
752  auto iter = vtkSmartPointer<vtkSMDomainIterator>::Take(this->NewDomainIterator());
753  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
754  {
755  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
756  {
757  return domain;
758  }
759  }
760  return nullptr;
761 }
762 #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