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 
155 class VTKREMOTINGSERVERMANAGER_EXPORT vtkSMProperty : public vtkSMObject
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 
186  int IsInDomains();
187 
193  int IsInDomains(vtkSMDomain** domain);
194 
199  void UnRegister(vtkObjectBase* obj) override;
200 
205  vtkSMDomainIterator* NewDomainIterator();
206 
211  vtkSMDomain* GetDomain(const char* name);
212 
216  vtkSMDomain* FindDomain(const char* classname);
217 
233  template <class DomainType>
234  inline DomainType* FindDomain();
235 
240  unsigned int GetNumberOfDomains();
241 
243 
247  vtkGetMacro(InformationOnly, int);
249 
251 
256  vtkGetMacro(IgnoreSynchronization, int);
258 
260 
265  vtkGetObjectMacro(InformationProperty, vtkSMProperty);
267 
273  void AddDomain(const char* name, vtkSMDomain* dom);
274 
279  virtual void AddLinkedProperty(vtkSMProperty* targetProperty);
280 
284  virtual void RemoveLinkedProperty(vtkSMProperty* targetProperty);
285 
294  virtual void RemoveFromSourceLink();
295 
297 
301  vtkSetMacro(Animateable, int);
302  vtkGetMacro(Animateable, int);
304 
306 
311  vtkSetMacro(IsInternal, int);
312  vtkGetMacro(IsInternal, int);
314 
316 
319  vtkSetMacro(NoCustomDefault, int);
321 
323 
326  vtkGetMacro(NoCustomDefault, int);
328 
330 
340  vtkSetStringMacro(PanelVisibility)
342 
344 
347  vtkGetStringMacro(PanelVisibility)
349 
351 
355  vtkSetStringMacro(PanelVisibilityDefaultForRepresentation)
357 
359 
363  vtkGetStringMacro(PanelVisibilityDefaultForRepresentation)
365 
367 
370  vtkSetStringMacro(PanelWidget)
372 
374 
377  vtkGetStringMacro(PanelWidget)
379 
381 
384  vtkSetStringMacro(DisableSubTrace)
386 
388 
391  vtkGetStringMacro(DisableSubTrace)
393 
398  virtual void Copy(vtkSMProperty* src);
399 
401 
406  vtkGetObjectMacro(Documentation, vtkSMDocumentation);
408 
413  void ResetToDefault();
414 
420  virtual void ResetToXMLDefaults() {}
421 
430  virtual bool ResetToDomainDefaults(bool use_unchecked_values = false);
431 
433 
436  vtkGetStringMacro(XMLLabel);
438 
440 
446  vtkGetStringMacro(XMLName);
448 
450 
455  vtkGetMacro(Repeatable, int);
457 
459 
467  vtkGetObjectMacro(Hints, vtkPVXMLElement);
468  void SetHints(vtkPVXMLElement* hints);
470 
472 
475  void Modified() override
476  {
477  if (this->BlockModifiedEvents)
478  {
479  this->PendingModifiedEvents = true;
480  }
481  else
482  {
483  this->Superclass::Modified();
484  this->PendingModifiedEvents = false;
485  }
486  }
488 
494  vtkSMProxy* GetParent();
495 
496  // Flag used to ignore property when building Proxy state for Undo/Redo state.
497  // The default value is false.
498  virtual bool IsStateIgnored() { return this->StateIgnored; }
499 
505  virtual bool IsValueDefault() { return false; }
506 
512  bool HasDomainsWithRequiredProperties();
513 
517  virtual void ClearUncheckedElements() {}
518 
523  static const char* CreateNewPrettyLabel(const char* name);
524 
525 protected:
526  vtkSMProperty();
527  ~vtkSMProperty() override;
528 
530  friend class vtkSMProxy;
531  friend class vtkSMSubPropertyIterator;
532  friend class vtkSMDomainIterator;
533  friend class vtkSMSourceProxy;
534  friend class vtkSMDomain;
536 
540  virtual void WriteTo(vtkSMMessage* msg);
541 
545  virtual void ReadFrom(const vtkSMMessage*, int vtkNotUsed(message_offset), vtkSMProxyLocator*){};
546 
551  virtual int ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element);
552 
557  virtual void UpdateAllInputs(){};
558 
560 
566  vtkSetStringMacro(XMLName);
568 
573  vtkSMProperty* NewProperty(const char* name);
574 
579  void AddDependent(vtkSMDomain* dom);
580 
584  void RemoveAllDependents();
585 
597  void UpdateDomains();
598 
604  virtual void SaveState(
605  vtkPVXMLElement* parent, const char* property_name, const char* uid, int saveDomains = 1);
610  virtual void SaveStateValues(vtkPVXMLElement* propertyElement);
611 
615  virtual void SaveDomainState(vtkPVXMLElement* propertyElement, const char* uid);
616 
620  virtual int LoadState(vtkPVXMLElement* element, vtkSMProxyLocator* loader);
621 
623 
624  char* Command;
625 
627 
632 
633  char* XMLName;
634  char* XMLLabel;
635  vtkSetStringMacro(XMLLabel);
636 
637  char* PanelVisibility;
639  char* PanelWidget;
641 
643 
644  vtkSetMacro(InformationOnly, int);
645  int InformationOnly;
646 
647  vtkSetMacro(IgnoreSynchronization, int);
649 
650  vtkSMInformationHelper* InformationHelper;
651 
652  void SetInformationProperty(vtkSMProperty* ip);
654 
656  void SetDocumentation(vtkSMDocumentation*);
657 
659 
661 
664  bool SetBlockModifiedEvents(bool block)
665  {
666  bool prev = this->BlockModifiedEvents;
667  this->BlockModifiedEvents = block;
668  return prev;
669  }
671 
673 
677  vtkGetMacro(PendingModifiedEvents, bool);
679 
680  // Proxy is not reference-counted to avoid reference loops.
681  void SetParent(vtkSMProxy* proxy);
682 
684 
685  // Flag used to ignore property when building Proxy state for Undo/Redo state.
686  // The default value is false.
688  vtkSetMacro(StateIgnored, bool);
689  vtkBooleanMacro(StateIgnored, bool);
690 
691  // Links for properties that "subscribe" to changes to this property.
693 
694 private:
695  vtkSMProperty(const vtkSMProperty&) = delete;
696  void operator=(const vtkSMProperty&) = delete;
697 
698  // Callback to fire vtkCommand::DomainModifiedEvent every time any of the
699  // domains change.
700  void InvokeDomainModifiedEvent();
701 
706  void CreateAndSetPrettyLabel(const char* name);
707 
708  bool PendingModifiedEvents;
709  bool BlockModifiedEvents;
710 };
711 
712 #define vtkSMPropertyTemplateMacroCase(typeSMProperty, type, prop, call) \
713  if (typeSMProperty* SM_PROPERTY = typeSMProperty::SafeDownCast(prop)) \
714  { \
715  (void)SM_PROPERTY; \
716  typedef type SM_TT; \
717  call; \
718  }
719 /* clang-format off */
720 #define vtkSMVectorPropertyTemplateMacro(prop, call) \
721  vtkSMPropertyTemplateMacroCase(vtkSMDoubleVectorProperty, double, prop, call) \
722  vtkSMPropertyTemplateMacroCase(vtkSMIntVectorProperty, int, prop, call) \
723  vtkSMPropertyTemplateMacroCase(vtkSMIdTypeVectorProperty, vtkIdType, prop, call) \
724  vtkSMPropertyTemplateMacroCase(vtkSMStringVectorProperty, vtkStdString, prop, call)
725 /* clang-format on */
726 
727 template <class DomainType>
729 {
731  for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
732  {
733  if (DomainType* domain = DomainType::SafeDownCast(iter->GetDomain()))
734  {
735  return domain;
736  }
737  }
738  return nullptr;
739 }
740 #endif
vtkSMProperty * InformationProperty
static vtkSmartPointer< T > Take(T *t)
iterates over domains of a property
vtkSMDomainIterator * DomainIterator
vtkSMPropertyLink * Links
superclass for all SM properties
void Modified() override
Overridden to support blocking of modified events.
Store messages for the interpreter.
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
vtkSMDomainIterator * NewDomainIterator()
Creates, initializes and returns a new domain iterator.
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'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