00001 #ifndef INCLUDED_SaveWalkControl_h
00002 #define INCLUDED_SaveWalkControl_h
00003
00004 #include "StringInputControl.h"
00005 #include "Motion/MotionManager.h"
00006 #include "Motion/WalkMC.h"
00007 #include <string>
00008
00009
00010 class SaveWalkControl : public StringInputControl {
00011 public:
00012
00013 SaveWalkControl(const std::string& n, MotionManager::MC_ID w) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in /ms/data/motion)..."), walk_id(w), thewalk(NULL) {}
00014
00015 SaveWalkControl(const std::string& n, WalkMC * awalk) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in /ms/data/motion)..."), walk_id(MotionManager::invalid_MC_ID), thewalk(awalk) {}
00016
00017 virtual ~SaveWalkControl() {}
00018
00019 virtual ControlBase * takeInput(const std::string& msg) {
00020 if(msg.size()>0) {
00021 std::string filename;
00022 if(msg[0]=='/')
00023 filename=msg;
00024 else
00025 filename=config->motion.root+"/"+msg;
00026 MotionManager::MC_ID id = thewalk==NULL?walk_id:thewalk->getID();
00027 WalkMC* walk=thewalk;
00028 if(id!=MotionManager::invalid_MC_ID)
00029 walk = (WalkMC*)motman->checkoutMotion(id);
00030 if(walk==NULL)
00031 serr->printf("Invalid walk for saving\n");
00032 else {
00033 walk->SaveFile(filename.c_str());
00034 motman->checkinMotion(id);
00035 }
00036 }
00037 return StringInputControl::takeInput(msg);
00038 }
00039
00040 protected:
00041 MotionManager::MC_ID walk_id;
00042 WalkMC * thewalk;
00043
00044 private:
00045 SaveWalkControl(const SaveWalkControl&);
00046 SaveWalkControl operator=(const SaveWalkControl&);
00047 };
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #endif