NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
savecontroller.h
1 // Performs saving/loading motions
2 // Author: Dmytro Pavlichenko <dm.mark999@gmail.com>
3 
4 #ifndef SAVE_CONTROLLER_H
5 #define SAVE_CONTROLLER_H
6 
7 #include <trajectory_editor/headerview.h>
8 #include <trajectory_editor/frameview.h>
9 #include <trajectory_editor/jointperspective.h>
10 
11 #include <QObject>
12 #include <QMessageBox>
13 #include <QFileDialog>
14 #include <QInputDialog>
15 #include <QTime>
16 
17 #include <ros/package.h>
18 #include <ros/console.h>
19 
20 #include <motion_file/motionfile.h>
21 
22 class SaveController : public QObject
23 {
24  Q_OBJECT
25 public:
26  typedef boost::shared_ptr<motionfile::Keyframe> KeyframePtr;
27 
28  SaveController(HeaderView *view, joint_perspective::PerspectiveManager *manager);
29  ~SaveController();
30 
31  // Return path to motion. Empty string if operation failed
32  QString newMotion(motionfile::Motion &motion);
33  QString open(motionfile::Motion &motion);
34  QString open(motionfile::Motion &motion, QString path);
35 
36  void save(motionfile::Motion &motion);
37  void saveAs(motionfile::Motion &motion);
38  void saveMirroredAs(motionfile::Motion &original_motion, motionfile::Motion &mirrored);
39  void saveBackup(motionfile::Motion &motion); // Save backup in /tmp/trajectory_editor
40 
41 Q_SIGNALS:
42  void newPath(QString path);
43  void modelChanged(std::string model_path, std::vector<std::string> &new_joint_list);
44 
45 private:
46  KeyframePtr firstFrame(unsigned joints_amount);
47  std::string getFileNameFromPath(QString path);
48  void showMessageBox(QString title, QString text);
49 
50  bool isMotionValid(motionfile::Motion &motion);
51 
52  // Mirror values of specified joint to create a mirrored motion
53  void mirrorValues(KeyframePtr frame, KeyframePtr mirrored, std::string
54  left, std::string right, bool swap, bool invert, std::vector<std::string> jointList);
55 
56 private:
57  HeaderView *m_header_view;
58  joint_perspective::PerspectiveManager *m_perspective_manager;
59 };
60 
61 #endif // SAVE_CONTROLLER_H