~choreonoid/choreonoid/debian

« back to all changes in this revision

Viewing changes to src/Base/GraphWidget.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
/**
 
2
   @author Shin'ichiro Nakaoka
 
3
*/
 
4
 
 
5
#ifndef CNOID_GUIBASE_GRAPH_WIDGET_H_INCLUDED
 
6
#define CNOID_GUIBASE_GRAPH_WIDGET_H_INCLUDED
 
7
 
 
8
#include <cnoid/Archive>
 
9
#include <string>
 
10
#include <vector>
 
11
#include <boost/shared_ptr.hpp>
 
12
#include <boost/function.hpp>
 
13
#include <boost/signals.hpp>
 
14
#include <QWidget>
 
15
#include <QLabel>
 
16
 
 
17
#include "exportdecl.h"
 
18
 
 
19
 
 
20
namespace cnoid {
 
21
 
 
22
    class View;
 
23
    class ToolBar;
 
24
    class Archive;
 
25
    class GraphDataHandler;
 
26
    class GraphDataHandlerImpl;
 
27
    class GraphWidgetImpl;
 
28
    
 
29
    typedef boost::shared_ptr<GraphDataHandler> GraphDataHandlerPtr;
 
30
    
 
31
    class CNOID_EXPORT GraphDataHandler
 
32
    {
 
33
      public:
 
34
 
 
35
        GraphDataHandler();
 
36
        ~GraphDataHandler();
 
37
 
 
38
        void setColor(float r, float g, float b);
 
39
        void setLabel(const std::string& label);
 
40
        void setFrameProperties(int numFrames, double frameRate, double offset = 0.0);
 
41
 
 
42
        void setValueLimits(double lower, double upper);
 
43
        void setVelocityLimits(double lower, double upper);
 
44
 
 
45
        void addVerticalLine(double x, const std::string& label);
 
46
        void addHorizontalLine(double y, const std::string& label);
 
47
        void clearLines();
 
48
        
 
49
        void update();
 
50
 
 
51
        typedef boost::function<void(int frame, int size, double* out_values)> DataRequestCallback;
 
52
        void setDataRequestCallback(DataRequestCallback callback);
 
53
 
 
54
        typedef boost::function<void(int frame, int size, double* values)> DataModifiedCallback;
 
55
        void setDataModifiedCallback(DataModifiedCallback callback);
 
56
 
 
57
      private:
 
58
        
 
59
        friend class GraphWidgetImpl;
 
60
 
 
61
        GraphDataHandlerImpl* impl;
 
62
    };
 
63
 
 
64
 
 
65
    class CNOID_EXPORT GraphWidget : public QWidget, public boost::signals::trackable
 
66
    {
 
67
      public:
 
68
 
 
69
        GraphWidget(View* parentView);
 
70
        ~GraphWidget();
 
71
 
 
72
        void addDataHandler(GraphDataHandlerPtr handler);
 
73
        void clearDataHandlers();
 
74
 
 
75
        void setRenderingTypes(bool showOriginalValues, bool showVelocities, bool showAccelerations);
 
76
        void getRenderingTypes(bool& showOriginalValues, bool& showVelocities, bool& showAccelerations);
 
77
 
 
78
        bool setCursorPosition(double pos);
 
79
 
 
80
        void setTimeBarSyncMode(bool on);
 
81
        bool isTimeBarSyncMode();
 
82
        
 
83
        enum ScrollMode { OFF, CONTINUOUS, PAGE };
 
84
        void setAutoScrollMode(ScrollMode on);
 
85
        ScrollMode autoScrollMode();
 
86
        
 
87
        void setVerticalValueRange(double lower, double upper);
 
88
        void getVerticalValueRange(double& lower, double& upper);
 
89
 
 
90
        void setLineWidth(double width);
 
91
        double getLineWidth();
 
92
 
 
93
        void showRulers(bool show);
 
94
        bool showsRulers();
 
95
        
 
96
        void showLimits(bool show);
 
97
        bool showsLimits();
 
98
        
 
99
        void showGrid(bool show);
 
100
        bool showsGrid();
 
101
        
 
102
        void setGridSize(double width, double height);
 
103
        void getGridSize(double& width, double& height);
 
104
        
 
105
        void setControlPointStep(int step, int offset = 0);
 
106
        void getControlPointStep(int& step, int& offset);
 
107
        
 
108
        void highlightControlPoints(bool on);
 
109
        bool highlightsControlPoints();
 
110
 
 
111
        enum Mode { VIEW_MODE, EDIT_MODE };
 
112
        void changeMode(Mode mode);
 
113
        Mode mode();
 
114
 
 
115
        enum EditMode { FREE_LINE_MODE, LINE_MODE };
 
116
        void changeEditMode(EditMode mode);
 
117
        EditMode editMode();
 
118
 
 
119
        QLabel& statusLabel();
 
120
 
 
121
        virtual bool storeState(Archive& archive);
 
122
        virtual bool restoreState(const Archive& archive);
 
123
 
 
124
      protected:
 
125
        virtual bool eventFilter(QObject* obj, QEvent* event);
 
126
 
 
127
      private:
 
128
 
 
129
        friend class GraphDataHandler;
 
130
        
 
131
        GraphWidgetImpl* impl;
 
132
    };
 
133
 
 
134
}
 
135
 
 
136
 
 
137
#endif
 
138