vtkSMVRInteractorStyleProxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef vtkSMVRInteractorStyleProxy_h
5 #define vtkSMVRInteractorStyleProxy_h
6 
7 #include "vtkCommand.h" // For UserEvent
8 #include "vtkPVIncubatorCAVEInteractionStylesModule.h" // for export macro
9 #include <vtkSMProxy.h>
10 
11 #include <map>
12 #include <string>
13 #include <vector>
14 
15 class vtkPVXMLElement;
16 class vtkSMProxyLocator;
17 class vtkSMProxy;
19 class vtkStringList;
20 struct vtkVREvent;
21 
22 class VTKPVINCUBATORCAVEINTERACTIONSTYLES_EXPORT vtkSMVRInteractorStyleProxy : public vtkSMProxy
23 {
24 public:
27  void PrintSelf(ostream& os, vtkIndent indent) override;
28 
29  // Description:
30  // Get the vector size of the controlled property this style expects, e.g. a
31  // 4x4 matrix will be 16, a 3D vector will be 3, etc. This is used to limit
32  // the number of options presented to the user when prompting for a property.
33  // This is NOT checked internally by SetControlledPropertyName.
34  //
35  // A value of -1 means no filtering will be done, and all available properties
36  // will be shown.
37  virtual int GetControlledPropertySize() { return -1; }
38 
39  virtual void SetControlledProxy(vtkSMProxy*);
40  vtkGetObjectMacro(ControlledProxy, vtkSMProxy);
41 
42  vtkSetStringMacro(ControlledPropertyName);
43  vtkGetStringMacro(ControlledPropertyName);
44 
45  virtual bool HandleEvent(const vtkVREvent& event);
46 
51  virtual bool Update();
52 
53  // Description:
54  // Get a list of defined roles for each output type.
55  void GetValuatorRoles(vtkStringList*);
56  void GetButtonRoles(vtkStringList*);
57  void GetTrackerRoles(vtkStringList*);
58 
59  // Description:
60  // Get the number of roles defined for each output type.
61  int GetNumberOfValuatorRoles();
62  int GetNumberOfButtonRoles();
63  int GetNumberOfTrackerRoles();
64 
65  // Description:
66  // Get the role of the input with the given name. If the name is not
67  // set or recognized, an empty string is returned.
68  std::string GetValuatorRole(const std::string& name);
69  std::string GetButtonRole(const std::string& name);
70  std::string GetTrackerRole(const std::string& name);
71 
72  // Description:
73  // Add a new input role to the interactor style.
74  void AddValuatorRole(const std::string& role);
75  void AddButtonRole(const std::string& role);
76  void AddTrackerRole(const std::string& role);
77 
78  void ClearAllRoles();
79 
80  // Description:
81  // Set/Get the name of the input that fulfills the specified role.
82  bool SetValuatorName(const std::string& role, const std::string& name);
83  std::string GetValuatorName(const std::string& role);
84  bool SetButtonName(const std::string& role, const std::string& name);
85  std::string GetButtonName(const std::string& role);
86  bool SetTrackerName(const std::string& role, const std::string& name);
87  std::string GetTrackerName(const std::string& role);
88 
90  virtual bool Configure(vtkPVXMLElement* child, vtkSMProxyLocator*);
91 
93  virtual vtkPVXMLElement* SaveConfiguration();
94 
95  enum
96  {
97  INTERACTOR_STYLE_REQUEST_CONFIGURE = vtkCommand::UserEvent + 7370
98  };
99 
100 protected:
102  virtual ~vtkSMVRInteractorStyleProxy();
103 
104  virtual void HandleButton(const vtkVREvent& event);
105  virtual void HandleValuator(const vtkVREvent& event);
106  virtual void HandleTracker(const vtkVREvent& event);
107 
108  static std::vector<std::string> Tokenize(std::string input);
109 
112 
113  typedef std::map<std::string, std::string> StringMap;
114  StringMap Valuators;
115  StringMap Buttons;
116  StringMap Trackers;
117  void MapKeysToStringList(const StringMap& source, vtkStringList* target);
118  bool SetValueInMap(StringMap& map_, const std::string& key, const std::string& value);
119  std::string GetValueInMap(const StringMap& map_, const std::string& key);
120  std::string GetKeyInMap(const StringMap& map_, const std::string& value);
121 
122 private:
124  void operator=(const vtkSMVRInteractorStyleProxy&) = delete;
125 };
126 
127 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void Update()
std::map< std::string, std::string > StringMap
name
property representing a vector of doubles
static vtkSMProxy * 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.
void operator=(const vtkSMProxy &)=delete
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
Manages allocation and freeing for a string list.
Definition: vtkStringList.h:18