opensurgsim
BoolToScalar.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DEVICES_DEVICEFILTERS_BOOLTOSCALAR_H
17 #define SURGSIM_DEVICES_DEVICEFILTERS_BOOLTOSCALAR_H
18 
19 #include "SurgSim/Devices/DeviceFilters/DeviceFilter.h"
20 #include "SurgSim/Framework/Timer.h"
21 
22 namespace SurgSim
23 {
24 namespace DataStructures
25 {
26 class DataGroupCopier;
27 }
28 
29 namespace Devices
30 {
31 
32 SURGSIM_STATIC_REGISTRATION(BoolToScalar);
33 
37 class BoolToScalar : public DeviceFilter
38 {
39 public:
41  explicit BoolToScalar(const std::string& name);
42 
44  ~BoolToScalar();
45 
46  SURGSIM_CLASSNAME(SurgSim::Devices::BoolToScalar);
47 
48  void initializeInput(const std::string& device, const DataStructures::DataGroup& inputData) override;
49 
50  void filterInput(const std::string& device, const DataStructures::DataGroup& dataToFilter,
51  DataStructures::DataGroup* result) override;
52 
55  void setScale(double val);
56 
58  double getScale() const;
59 
62  void setRange(const std::pair<double, double>& val);
63 
65  std::pair<double, double> getRange() const;
66 
69  void setClamping(bool val);
70 
72  bool isClamping();
73 
76  void setIncreaseField(const std::string& val);
77 
79  std::string getIncreaseField() const;
80 
83  void setDecreaseField(const std::string& val);
84 
86  std::string getDecreaseField() const;
87 
90  void setScalar(double val);
91 
93  double getScalar() const;
94 
98  void setTargetField(const std::string& val);
99 
101  std::string getTargetField() const;
102 
103 private:
104  bool m_isClamping;
105 
106  double m_value;
107 
108  double m_scale;
109 
110  std::pair<double, double> m_range;
111 
112  std::string m_increaseField;
113  std::string m_decreaseField;
114  std::string m_targetField;
115 
116  Framework::Timer m_timer;
117 
118  std::shared_ptr<DataStructures::DataGroupCopier> m_copier;
119 
120 };
121 
122 }; // namespace Devices
123 }; // namespace SurgSim
124 
125 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A device filter can be connected between a device and the InputConsumerInterface (e.g., InputComponent) and/or the OutputProducerInterface (e.g., OutputComponent), and can alter the data being passed from/to the device.
Definition: DeviceFilter.h:37
Timer class, measures execution times.
Definition: Timer.h:31
A collection of NamedData objects.
Definition: DataGroup.h:68
Maps the on and off state of two boolean values to the increase and decrease of a scalar field...
Definition: BoolToScalar.h:37