CEBL  2.1
RobotPie.cpp
Go to the documentation of this file.
1 /* RobotPie.cpp
2  * \author Jeshua Bratman
3  *
4  * Simple keyboard interface for CEBL.
5  * Types the name of a class when it is selected.
6  */
7 
8 
9 #include "RobotPie.hpp"
10 #include "../X11Controller.hpp"
11 #include "../../TextUtils.hpp"
12 
13 
15 {
16 
17 }
18 
19 
21 {
22  if(c == -1)
24  else
25  {
28  selectPie(c);
29  }
30 }
31 
32 void RobotPie::selectPie(int c)
33 {
34  X11Controller x;
35 
36  if(!x.displayIsOpen())
37  return;
38 
39  if(commands.size() > unsigned(c))
40  {
41  x.stringSend(commands[c].c_str());
42  }
43 }
44 
45 //------------------------------------------------------------
46 
47 
48 std::map<std::string,CEBL::Param> RobotPie::getParamsList()
49 {
50  std::map<std::string,CEBL::Param> params;
51  for(int i=0;i<num_classes;i++)
52  {
53  string current = "";
54  if(commands.size() > unsigned(i))
55  current = this->commands[i];
56 
57  CEBL::Param temp("Command for " + TextUtils::IntToString(i),
58  "text to type when this class is selected",
59  current);
60 
61  params[current] = temp;
62  }
63  return params;
64 }
65 void RobotPie::setParamsList(std::map<std::string,CEBL::Param> p)
66 {
67  map<std::string, CEBL::Param>::iterator it;
68  for(it = p.begin(); it!=p.end(); ++it)
69  {
70  this->commands.push_back(it->second.getString());
71  }
73 }