Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

LoadWalkControl.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_LoadWalkControl_h
00003 #define INCLUDED_LoadWalkControl_h
00004 
00005 #include "FileBrowserControl.h"
00006 #include "Motion/WalkMC.h"
00007 #include "Shared/Config.h"
00008 #include <string>
00009 
00010 //! When activated, loads a set of walk parameters from a file specified by user
00011 class LoadWalkControl : public FileBrowserControl {
00012 public:
00013   //! constructor, pass the MC_ID of the WalkMC which you want to save
00014   LoadWalkControl(const std::string& n, MC_ID w)
00015     : FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->motion.root), walk_id(w), thewalk(NULL)
00016   {
00017     setFilter("*.prm");
00018   }
00019 
00020   //! constructor, pass a pointer to the WalkMC which you want to save
00021   LoadWalkControl(const std::string& n, WalkMC * awalk)
00022     : FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->portPath(config->motion.root)), walk_id(invalid_MC_ID), thewalk(awalk)
00023   {
00024     setFilter("*.prm");
00025   }
00026 
00027   //! destructor
00028   virtual ~LoadWalkControl() {}
00029 
00030 protected:
00031   //!does the actual loading of the MotionSequence
00032   virtual ControlBase* selectedFile(const std::string& f) {
00033     MC_ID id = thewalk==NULL?walk_id:thewalk->getID();
00034     WalkMC* walk=thewalk;
00035     if(id!=invalid_MC_ID)
00036       walk = (WalkMC*)motman->checkoutMotion(id);
00037     if(walk==NULL)
00038       serr->printf("Invalid walk for loading\n");
00039     else {
00040       walk->loadFile(f.c_str());
00041       if(id!=invalid_MC_ID)
00042         motman->checkinMotion(id);
00043     }
00044     return NULL;
00045   }
00046 
00047   MC_ID walk_id; //!< the MC_ID of the walk to load into
00048   WalkMC * thewalk; //!< the walk to load into (if NULL, check walk_id)
00049 
00050 private:
00051   LoadWalkControl(const LoadWalkControl&); //!< don't call
00052   LoadWalkControl operator=(const LoadWalkControl&); //!< don't call
00053 };
00054 
00055 /*! @file
00056  * @brief Defines LoadWalkControl, which when activated, loads a set of walk parameters from a file read from cin.
00057  * @author ejt (Creator)
00058  */
00059 
00060 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:44 2016 by Doxygen 1.6.3