~choreonoid/choreonoid/debian

« back to all changes in this revision

Viewing changes to src/PoseSeqPlugin/PoseSeqViewBase.h

  • Committer: Thomas Moulard
  • Date: 2012-10-23 12:43:24 UTC
  • Revision ID: git-v1:351cf736ad49bc7a9a7b9767dee760a013517a5d
Tags: upstream/1.1.0
ImportedĀ UpstreamĀ versionĀ 1.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*! @file
 
2
  @author Shin'ichiro Nakaoka
 
3
*/
 
4
 
 
5
#ifndef CNOID_CHOREOGRAPHY_POSE_SEQ_VIEW_BASE_H_INCLUDED
 
6
#define CNOID_CHOREOGRAPHY_POSE_SEQ_VIEW_BASE_H_INCLUDED
 
7
 
 
8
#include "PoseSeqItem.h"
 
9
#include <cnoid/View>
 
10
#include <cnoid/ConnectionSet>
 
11
#include <cnoid/TimeBar>
 
12
#include <cnoid/Archive>
 
13
#include <cnoid/MenuManager>
 
14
#include <cnoid/Link>
 
15
#include <cnoid/Button>
 
16
#include <cnoid/ButtonGroup>
 
17
#include <cnoid/SpinBox>
 
18
#include <cnoid/BodyItem>
 
19
#include <cnoid/LinkTreeWidget>
 
20
#include <QBoxLayout>
 
21
#include <QLabel>
 
22
#include <boost/signal.hpp>
 
23
#include <boost/function.hpp>
 
24
#include <boost/dynamic_bitset.hpp>
 
25
#include <ostream>
 
26
#include <set>
 
27
 
 
28
 
 
29
namespace cnoid {
 
30
 
 
31
    class PoseSelectionDialog; /// \todo this should be independent ?
 
32
    class LinkPositionAdjustmentDialog; /// \todo this should be independent ?
 
33
    class YawOrientationRotationDialog;
 
34
        
 
35
    class PoseSeqViewBase : public boost::signals::trackable
 
36
    {
 
37
    public:
 
38
        PoseSeqViewBase(View* view);
 
39
        ~PoseSeqViewBase();
 
40
 
 
41
        View* view;
 
42
        std::ostream& os;
 
43
 
 
44
        QString textForEmptyName;
 
45
 
 
46
        PoseSeqItemPtr currentPoseSeqItem;
 
47
        PoseSeqPtr seq;
 
48
        bool isSelectedPoseMoving;
 
49
        BodyItemPtr currentBodyItem;
 
50
        BodyPtr body;
 
51
        double currentTime;
 
52
        double timeScale;
 
53
 
 
54
        PoseSeq::iterator currentPoseIter;
 
55
 
 
56
        struct PoseIterTimeComp {
 
57
            bool operator()(const PoseSeq::iterator it1, const PoseSeq::iterator it2) {
 
58
                return it1->time() < it2->time();
 
59
            }
 
60
        };
 
61
        typedef std::multiset<PoseSeq::iterator, PoseIterTimeComp> PoseIterSet;
 
62
        PoseIterSet selectedPoseIters;
 
63
 
 
64
        PoseSeqPtr copiedPoses;
 
65
 
 
66
        ConnectionSet poseSeqConnections;
 
67
        boost::signals::connection connectionOfBodyKinematicStateEdited;
 
68
 
 
69
        ConnectionSet linkTreeAttributeChangeConnections;
 
70
 
 
71
        TimeBar* timeBar;
 
72
        boost::signals::connection connectionOfTimeChanged;
 
73
 
 
74
        LinkTreeWidget* linkTreeWidget;
 
75
        int baseLinkColumn;
 
76
        ButtonGroup* baseLinkRadioGroup;
 
77
        int validPartColumn;
 
78
        int stationaryPointColumn;
 
79
        int ikPartColumn;
 
80
        boost::dynamic_bitset<> possibleIkLinkFlag;
 
81
        LinkTreeItem* zmpRow;
 
82
        
 
83
        PosePtr poseForDefaultStateSetting;
 
84
 
 
85
        QLabel currentItemLabel;
 
86
        CheckBox timeSyncCheck;
 
87
            
 
88
        ToolButton insertPoseButton;
 
89
        ToolButton updateButton;
 
90
        ToggleToolButton updateAllToggle;
 
91
        ToolButton deleteButton;
 
92
        CheckBox autoUpdateModeCheck;
 
93
        DoubleSpinBox transitionTimeSpin;
 
94
 
 
95
        struct ChildrenState
 
96
        {
 
97
            ChildrenState()
 
98
                : validChildExists(false), allChildrenAreValid(true),
 
99
                  childWithStationaryPointExists(false), allChildrenAreStationaryPoints(true) { }
 
100
            bool validChildExists;
 
101
            bool allChildrenAreValid;
 
102
            bool childWithStationaryPointExists;
 
103
            bool allChildrenAreStationaryPoints;
 
104
        };
 
105
 
 
106
        Menu popupMenu;
 
107
        MenuManager menuManager;
 
108
 
 
109
        PoseSelectionDialog* poseSelectionDialog;
 
110
        LinkPositionAdjustmentDialog* linkPositionAdjustmentDialog;
 
111
        YawOrientationRotationDialog* yawOrientationRotationDialog;
 
112
 
 
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);
 
133
 
 
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();
 
144
        
 
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);
 
157
 
 
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);
 
169
 
 
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);
 
182
 
 
183
        void onInterpolationParametersChanged();
 
184
        void onItemSelectionChanged(const ItemList<PoseSeqItem>& selectedItems);
 
185
 
 
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);
 
193
    };
 
194
}
 
195
 
 
196
#endif