00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PEEKABOT_SLIDER_HH_INCLUDED
00025 #define PEEKABOT_SLIDER_HH_INCLUDED
00026
00027
00028 #include <boost/any.hpp>
00029 #include <boost/function.hpp>
00030 #include <boost/lexical_cast.hpp>
00031 #include <Eigen/Core>
00032 #include <Eigen/Geometry>
00033
00034 #include "Joint.hh"
00035 #include "HandlerInformer.hh"
00036 #include "ScopedHandler.hh"
00037
00038
00039 namespace peekabot
00040 {
00041
00051 class Slider : public Joint
00052 {
00053 public:
00054 Slider();
00055
00056 Slider(ScopedHandler *handler);
00057
00058 virtual ~Slider() throw();
00059
00070 Slider(const Eigen::Vector3f &axis);
00071
00081 void set_axis(
00082 const Eigen::Vector3f &axis,
00083 CoordinateSystem coord_sys = PARENT_COORDINATES) throw();
00084
00088 const Eigen::Vector3f &get_axis() const throw();
00089
00090 virtual void accept(ObjectVisitor *visitor) throw();
00091
00092 virtual ObjectType get_object_type() const;
00093
00094 virtual Eigen::Transform3f calculate_dof_transform(float value)
00095 const throw();
00096
00099
00100 typedef boost::signals2::signal<void ()> AxisSetSignal;
00101
00102 inline AxisSetSignal &axis_set_signal()
00103 {
00104 return m_axis_set_signal;
00105 }
00106
00108
00109 protected:
00110 virtual PropMap &get_prop_adapters();
00111
00112 private:
00113 static void create_prop_adapters(PropMap &adapters);
00114
00117
00118 static void start_handler(
00119 const std::string & name,
00120 XMLHandler::AttributeMap &attributes,
00121 ScopedHandler *handler) throw();
00122
00123 void axis_start_handler(
00124 const std::string & name,
00125 XMLHandler::AttributeMap &attributes,
00126 ScopedHandler *handler)
00127 throw();
00128
00129 void axis_cdata_handler(
00130 CoordinateSystem coord_sys,
00131 const std::string &cdata,
00132 ScopedHandler *handler)
00133 throw(std::domain_error, std::runtime_error, boost::bad_any_cast);
00134
00138 void min_start_handler(
00139 const std::string & name,
00140 XMLHandler::AttributeMap &attributes,
00141 ScopedHandler *handler)
00142 throw();
00143
00147 void max_start_handler(
00148 const std::string & name,
00149 XMLHandler::AttributeMap &attributes,
00150 ScopedHandler *handler)
00151 throw();
00152
00156 void initial_start_handler(
00157 const std::string & name,
00158 XMLHandler::AttributeMap &attributes,
00159 ScopedHandler *handler)
00160 throw();
00161
00165 void offset_start_handler(
00166 const std::string & name,
00167 XMLHandler::AttributeMap &attributes,
00168 ScopedHandler *handler)
00169 throw();
00170
00175 template<class T>
00176 static void generic_cdata_handler(
00177 const std::string &cdata,
00178 ScopedHandler *handler,
00179 boost::function<void (T)> f)
00180 {
00181 f( boost::lexical_cast<T>(cdata) );
00182 }
00183
00192 static void invoke_on_end_element(
00193 ScopedHandler::TagScope &dof_scope,
00194 boost::function<void (float)> f, float val);
00195
00197
00198
00199 private:
00208 Eigen::Vector3f m_axis;
00209
00210 AxisSetSignal m_axis_set_signal;
00211
00212 static HandlerInformer ms_handler_informer;
00213 };
00214 }
00215
00216 #endif // PEEKABOT_SLIDER_HH_INCLUDED