2
@author Shin'ichiro Nakaoka
5
#ifndef CNOID_CHOREOGRAPHY_POSE_SEQ_VIEW_BASE_H_INCLUDED
6
#define CNOID_CHOREOGRAPHY_POSE_SEQ_VIEW_BASE_H_INCLUDED
8
#include "PoseSeqItem.h"
10
#include <cnoid/ConnectionSet>
11
#include <cnoid/TimeBar>
12
#include <cnoid/Archive>
13
#include <cnoid/MenuManager>
15
#include <cnoid/Button>
16
#include <cnoid/ButtonGroup>
17
#include <cnoid/SpinBox>
18
#include <cnoid/BodyItem>
19
#include <cnoid/LinkTreeWidget>
22
#include <boost/signal.hpp>
23
#include <boost/function.hpp>
24
#include <boost/dynamic_bitset.hpp>
31
class PoseSelectionDialog; /// \todo this should be independent ?
32
class LinkPositionAdjustmentDialog; /// \todo this should be independent ?
33
class YawOrientationRotationDialog;
35
class PoseSeqViewBase : public boost::signals::trackable
38
PoseSeqViewBase(View* view);
44
QString textForEmptyName;
46
PoseSeqItemPtr currentPoseSeqItem;
48
bool isSelectedPoseMoving;
49
BodyItemPtr currentBodyItem;
54
PoseSeq::iterator currentPoseIter;
56
struct PoseIterTimeComp {
57
bool operator()(const PoseSeq::iterator it1, const PoseSeq::iterator it2) {
58
return it1->time() < it2->time();
61
typedef std::multiset<PoseSeq::iterator, PoseIterTimeComp> PoseIterSet;
62
PoseIterSet selectedPoseIters;
64
PoseSeqPtr copiedPoses;
66
ConnectionSet poseSeqConnections;
67
boost::signals::connection connectionOfBodyKinematicStateEdited;
69
ConnectionSet linkTreeAttributeChangeConnections;
72
boost::signals::connection connectionOfTimeChanged;
74
LinkTreeWidget* linkTreeWidget;
76
ButtonGroup* baseLinkRadioGroup;
78
int stationaryPointColumn;
80
boost::dynamic_bitset<> possibleIkLinkFlag;
83
PosePtr poseForDefaultStateSetting;
85
QLabel currentItemLabel;
86
CheckBox timeSyncCheck;
88
ToolButton insertPoseButton;
89
ToolButton updateButton;
90
ToggleToolButton updateAllToggle;
91
ToolButton deleteButton;
92
CheckBox autoUpdateModeCheck;
93
DoubleSpinBox transitionTimeSpin;
98
: validChildExists(false), allChildrenAreValid(true),
99
childWithStationaryPointExists(false), allChildrenAreStationaryPoints(true) { }
100
bool validChildExists;
101
bool allChildrenAreValid;
102
bool childWithStationaryPointExists;
103
bool allChildrenAreStationaryPoints;
107
MenuManager menuManager;
109
PoseSelectionDialog* poseSelectionDialog;
110
LinkPositionAdjustmentDialog* linkPositionAdjustmentDialog;
111
YawOrientationRotationDialog* yawOrientationRotationDialog;
113
PoseSeq::iterator insertPose();
114
PoseSeq::iterator insertPronunSymbol();
115
PoseSeq::iterator insertPoseUnit(PoseUnitPtr poseUnit);
116
PoseIterSet::iterator findPoseIterInSelected(PoseSeq::iterator poseIter);
117
bool toggleSelection(PoseSeq::iterator poseIter, bool adding, bool changeTime);
118
void selectAllPoses();
119
void selectAllPosesAfterCurrentPosition();
120
void selectAllPosesBeforeCurrentPosition();
121
void selectPosesHavingSelectedLinks();
122
void selectPosesJustHavingSelectedLinks();
123
void removeSelectedPartsFromKeyPoses();
124
void doAutomaticInterpolationUpdate();
125
void updateLinkTreeModel();
126
bool deleteSelectedPoses();
127
bool cutSelectedPoses();
128
bool copySelectedPoses();
129
bool pasteCopiedPoses(double timeToPaste);
130
bool moveSelectedPoses(double time0);
131
bool modifyTransitionTimeOfSelectedPoses(double ttime);
132
void popupContextMenu(QMouseEvent* event);
134
void onSelectSpecifiedKeyPosesActivated();
135
void onPoseSelectionDialogAccepted();
136
void onAdjustStepPositionsActivated();
137
void onRotateYawOrientationsActivated();
138
void onYawOrientationRotationDialogAccepted();
139
void onAdjustWaistPositionActivated();
140
void onLinkPositionAdjustmentDialogAccepted();
141
void onUpdateKeyposesWithBalancedTrajectoriesActivated();
142
void onFlipPosesActivated();
143
void countSelectedKeyPoses();
145
virtual void onLinkTreeUpdateRequest(bool isInitialCreation);
146
virtual void setCurrentPoseSeqItem(PoseSeqItemPtr poseSeqItem);
147
virtual void onTimeScaleChanged();
148
virtual void onSelectedPosesModified();
149
virtual void onDeleteButtonClicked();
150
virtual void onPoseInserted(PoseSeq::iterator it, bool isMoving);
151
virtual void onPoseRemoving(PoseSeq::iterator it, bool isMoving);
152
virtual void onPoseModified(PoseSeq::iterator it);
153
virtual bool onTimeChanged(double time) = 0;
154
virtual void onInsertPoseButtonClicked() = 0;
155
virtual bool restoreState(const Archive& archive);
156
virtual bool storeState(Archive& archive);
158
void onViewActivated();
159
void onViewDeactivated();
160
void onTimeSyncCheckToggled();
161
void setupOperationParts();
162
void setupLinkTreeWidget();
163
bool isChecked(LinkTreeItem* item, int column);
164
void setChecked(LinkTreeItem* item, int column, bool checked);
165
void setCheckState(LinkTreeItem* item, int column, Qt::CheckState state);
166
void initializeLinkTree();
167
void initializeLinkTreeIkLinkColumn();
168
void initializeLinkTreeTraverse(QTreeWidgetItem* parentItem);
170
void togglePoseAttribute(boost::function<bool(PosePtr& pose)> toggleFunction);
171
void onBaseLinkRadioClicked();
172
bool setBaseLink(PosePtr& pose, Link* link);
173
void onValidPartCheckClicked(LinkTreeItem* item, Qt::CheckState checkState);
174
bool toggleZmp(PosePtr& pose, bool on);
175
bool toggleLink(PosePtr& pose, LinkTreeItem* item, Link* link, bool partOn, bool ikOn);
176
bool togglePart(PosePtr& pose, LinkTreeItem* item, bool on);
177
void onStationaryPointCheckClicked(LinkTreeItem* linkTreeItem, Qt::CheckState checkState);
178
bool toggleZmpStationaryPoint(PosePtr& pose, bool on);
179
bool toggleStationaryPoint(PosePtr& pose, Link* link, bool on);
180
bool togglePartStationaryPoints(PosePtr& pose, LinkTreeItem* item, bool on);
181
void onIkPartCheckClicked(LinkTreeItem* item, Qt::CheckState checkState);
183
void onInterpolationParametersChanged();
184
void onItemSelectionChanged(const ItemList<PoseSeqItem>& selectedItems);
186
void setCurrentItemName(ItemPtr item);
187
void onBodyKinematicStateEdited();
188
void onUpdateButtonClicked();
189
void setCurrentBodyStateToSelectedPoses(bool onlySelected);
190
bool setCurrentBodyStateToPose(PosePtr& pose, bool onlySelected);
191
bool setCurrentLinkStateToIkLink(Link* link, Pose::LinkInfo* linkInfo);
192
ChildrenState updateLinkTreeModelSub(LinkTreeItem* item, Body* body, const Pose& pose);