4 #ifndef KEYFRAME_MODEL_H
5 #define KEYFRAME_MODEL_H
7 #include <QAbstractListModel>
8 #include <QItemSelection>
10 #include <motion_file/motionfile.h>
12 #include <trajectory_editor/jointperspective.h>
13 #include <trajectory_editor/robotdisplay.h>
14 #include <trajectory_editor/headerview.h>
16 class KeyframeModel :
public QAbstractListModel
20 typedef boost::shared_ptr<motionfile::Keyframe> KeyframePtr;
22 explicit KeyframeModel(QObject* parent = 0);
23 virtual ~KeyframeModel();
25 int rowCount(
const QModelIndex &parent = QModelIndex())
const;
27 void removeFrame(
unsigned position);
28 void moveFrame(
unsigned position,
int direction);
30 void copySelectedFrames(QModelIndexList selectedIndexes);
31 void insertCopiedFrames();
34 void setMotion(motionfile::Motion motion);
36 joint_perspective::PerspectiveManager* getPerspectiveManager();
38 KeyframePtr getCurrentFrameCopy();
40 motionfile::Motion& getMotion();
41 motionfile::Motion getMotionCopy();
42 std::vector<std::string> getJointList();
45 bool hasUnsavedChanges();
48 void setViewSelection(
int row);
49 void setViewSelection(QItemSelection selection);
50 void updateCurrentFileLabel(QString newTitle);
52 void currentFrameChanged(KeyframePtr frame);
53 void jointListChanged(std::vector<std::string> list);
54 void perspectiveChanged(
const joint_perspective::JointPerspective& perspective);
56 void headerDataChanged(HeaderData);
59 void gotRules(
const std::vector<motionfile::Rule> &rules);
61 void updateRobot(std::vector<std::string> &joint_list, std::vector<double> &joint_positions);
62 void modelChanged(std::string model_path);
64 void getInverseLimits(
bool &limit,
double &epsilon);
67 void addFrame(
int row);
68 void showMotionInFolder();
70 void updateHeaderData(HeaderData);
71 void updateRobotDisplay();
73 void handleIndexChange(
const QModelIndex& index);
74 void handleChangeEffortForAllFrames(std::vector<int> indexes,
double newEffort);
75 void handleUpdateFrame();
76 void handeFrameLoaded(KeyframePtr frame);
77 void disableFrame(
unsigned position);
79 void handleTabChange(
int id);
81 void applyRule(
double delta,
int rule_id);
85 int idToPosition(
int id);
86 void setCurrentFrame(KeyframePtr frame);
88 KeyframePtr createFrame();
89 KeyframePtr createFrame(KeyframePtr oldFrame,
bool copyNameAndID =
false);
91 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
92 QStringList mimeTypes()
const;
93 QMimeData* mimeData(
const QModelIndexList &indexes)
const;
94 Qt::DropActions supportedDropActions()
const;
95 Qt::ItemFlags flags(
const QModelIndex &index)
const;
97 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent);
98 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex());
99 void insertRow(
int row, KeyframePtr frame,
const QModelIndex &parent = QModelIndex());
102 joint_perspective::PerspectiveManager *m_perspective_manager;
104 motionfile::Motion m_motion;
105 KeyframePtr m_current_frame;
108 std::string m_canonic_dump;
112 std::vector<KeyframePtr> m_copied_frames;
113 std::vector<std::string> m_copied_joint_list;