#include <PositionProxy.h>
Inheritance diagram for gadget::PositionProxy:


Public Methods | |
| PositionProxy () | |
| virtual | ~PositionProxy () |
| virtual void | updateData () |
| Updates the proxy's copy of the data. More... | |
| virtual vpr::Interval | getTimeStamp () const |
| Returns time of last update. More... | |
| gmtl::Matrix44f | getData (float scaleFactor=gadget::PositionUnitConversion::ConvertToFeet) const |
| PositionData * | getPositionData () |
| Gets the actual PositionData. More... | |
| int | getUnit () const |
| Returns this device's subunit number. More... | |
| Position * | getPositionPtr () |
| Return the Position pointer held by this proxy. More... | |
| bool | config (jccl::ConfigElementPtr element) |
| Configures the proxy. More... | |
| virtual Input * | getProxiedInputDevice () |
| Returns a pointer to the base class of the devices being proxied. More... | |
Static Public Methods | |
| std::string | getElementType () |
| Returns the string rep of the element type used to config this device. More... | |
A PositionProxy always points to a positional device and subUnit number, the inputgroup can therefore keep an array of these around and treat them as positional devices which only return a single subDevice's amount of data. (one POS_DATA)
Definition at line 66 of file PositionProxy.h.
|
|
Definition at line 69 of file PositionProxy.h.
00069 : mUnitNum(-1)
00070 {;}
|
|
|
Definition at line 72 of file PositionProxy.h.
00072 {;}
|
|
|
Updates the proxy's copy of the data. Copies the device data to local storage, and transform it if necessary. Reimplemented from gadget::Proxy. Definition at line 148 of file PositionProxy.cpp. References gadget::Proxy::mStupified, and gadget::TypedProxy< Position >::mTypedDevice.
00149 {
00150 if((!mStupified) && (mTypedDevice != NULL))
00151 {
00152 mPositionData = (mTypedDevice->getPositionData (mUnitNum));
00153
00154 // Create a vector to hold all 1 of our position data samples.
00155 std::vector<PositionData> temp_sample(1, mPositionData);
00156
00157 // Apply all the positional filters
00158 for(std::vector<PositionFilter*>::iterator i = mPositionFilters.begin(); i != mPositionFilters.end(); ++i)
00159 {
00160 (*i)->apply(temp_sample);
00161 }
00162
00163 // Now that the filters have been applied to our sample, copy it back
00164 // over to mPositionData.
00165 mPositionData = temp_sample[0];
00166
00167 // --- CACHE FEET Scaling ---- //
00168 mPosMatrix_feet = mPositionData.getPosition();
00169 gmtl::Vec3f trans; // SCALE: to feet
00170 gmtl::setTrans(trans, mPosMatrix_feet); // Get the translational vector
00171 trans *= gadget::PositionUnitConversion::ConvertToFeet; // Scale the translation and set the value again
00172 gmtl::setTrans(mPosMatrix_feet, trans);
00173 }
00174 }
|
|
|
Returns time of last update.
Implements gadget::Proxy. Definition at line 81 of file PositionProxy.h.
00082 {
00083 return mPositionData.getTime();
00084 }
|
|
|
Definition at line 117 of file PositionProxy.cpp.
00118 {
00119 gmtl::Matrix44f ret_mat;
00120
00121 if(mStupified)
00122 {
00123 //gmtl::identity(mPositionData.mPosData);
00124 //ret_mat = mPositionData.mPosData;
00125 gmtl::identity(ret_mat);
00126 }
00127 else if(gmtl::Math::isEqual(scaleFactor, 1.0f, 0.01f))
00128 {
00129 ret_mat = mPositionData.mPosData;
00130 }
00131 else if(gmtl::Math::isEqual(scaleFactor, gadget::PositionUnitConversion::ConvertToFeet, 0.01f))
00132 {
00133 ret_mat = mPosMatrix_feet;
00134 }
00135 else // Convert using scale factor
00136 {
00137 ret_mat = mPositionData.getPosition();
00138 gmtl::Vec3f trans;
00139 gmtl::setTrans(trans, ret_mat); // Get the translational vector
00140 trans *= scaleFactor; // Scale the translation and set the value again
00141 gmtl::setTrans(ret_mat, trans);
00142 }
00143
00144 return ret_mat;
00145 }
|
|
|
Gets the actual PositionData.
Definition at line 97 of file PositionProxy.h.
00098 {
00099 return &mPositionData;
00100 }
|
|
|
Returns this device's subunit number.
Definition at line 103 of file PositionProxy.h.
00104 {
00105 return mUnitNum;
00106 }
|
|
|
Return the Position pointer held by this proxy.
Definition at line 109 of file PositionProxy.h.
00110 {
00111 if(!mStupified)
00112 {
00113 return mTypedDevice;
00114 }
00115 else
00116 {
00117 return NULL;
00118 }
00119 }
|
|
|
Returns the string rep of the element type used to config this device. Used by the Input Manager to find elements that construct devices. Reimplemented from gadget::Proxy. Definition at line 54 of file PositionProxy.cpp. Referenced by config.
00055 {
00056 return "position_proxy";
00057 }
|
|
|
Configures the proxy.
Reimplemented from gadget::Proxy. Definition at line 59 of file PositionProxy.cpp. References gadgetDBG_INPUT_MGR, getElementType, gadget::TypedProxy< Position >::mDeviceName, and gadget::TypedProxy< Position >::refresh.
00060 {
00061 vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
00062 std::string("------------------ Position PROXY config() -----------------\n"),
00063 std::string("\n"));
00064 vprASSERT(element->getID() == getElementType());
00065
00066 if ( ! Proxy::config(element) )
00067 {
00068 return false;
00069 }
00070
00071 mUnitNum = element->getProperty<int>("unit");
00072 mDeviceName = element->getProperty<std::string>("device");
00073
00074 // --- Configure filters --- //
00075 unsigned num_filters = element->getNum("position_filters");
00076
00077 vprDEBUG_OutputGuard(vprDBG_ALL, vprDBG_VERB_LVL,
00078 std::string("PositionProxy::config: ") +
00079 element->getName() + std::string(":") +
00080 element->getID() + std::string("\n"),
00081 std::string("PositionProxy::config: done.\n") );
00082
00083 vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL) << "Num filters: " << num_filters << std::endl << vprDEBUG_FLUSH;
00084
00085 jccl::ConfigElementPtr cur_filter;
00086 PositionFilter* new_filter(NULL);
00087
00088 for(unsigned i=0;i<num_filters;++i)
00089 {
00090 cur_filter = element->getProperty<jccl::ConfigElementPtr>("position_filters",i);
00091 vprASSERT(cur_filter.get() != NULL);
00092
00093 std::string filter_id = cur_filter->getID();
00094 vprDEBUG( vprDBG_ALL, vprDBG_VERB_LVL)
00095 << " Filter [" << i << "]: Type:" << filter_id << std::endl
00096 << vprDEBUG_FLUSH;
00097
00098 new_filter = PositionFilterFactory::instance()->createObject(filter_id);
00099 if(new_filter != NULL)
00100 {
00101 new_filter->config(cur_filter);
00102 mPositionFilters.push_back(new_filter);
00103 }
00104 else
00105 {
00106 vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL) << " NULL Filter!!!" << std::endl << vprDEBUG_FLUSH;
00107 }
00108 } // if have filters
00109
00110 // --- SETUP PROXY with INPUT MGR ---- //
00111 refresh();
00112
00113 return true;
00114 }
|
|
|
Returns a pointer to the base class of the devices being proxied.
Implements gadget::Proxy. Definition at line 125 of file PositionProxy.h.
00126 {
00127 if ((NULL == mTypedDevice) || (mStupified))
00128 {
00129 return NULL;
00130 }
00131
00132 Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
00133 vprASSERT((ret_val != NULL) && "Cross-cast in PositionProxy failed");
00134 return ret_val;
00135 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002