Choreonoid  1.5
GraphWidget.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_GRAPH_WIDGET_H
6 #define CNOID_BASE_GRAPH_WIDGET_H
7 
8 #include <cnoid/Archive>
9 #include <string>
10 #include <vector>
11 #include <boost/shared_ptr.hpp>
12 #include <boost/function.hpp>
13 #include <QWidget>
14 #include <QLabel>
15 #include "exportdecl.h"
16 
17 namespace cnoid {
18 
19 class View;
20 class ToolBar;
21 class Archive;
22 class GraphDataHandler;
23 class GraphDataHandlerImpl;
24 class GraphWidgetImpl;
25 
26 typedef boost::shared_ptr<GraphDataHandler> GraphDataHandlerPtr;
27 
29 {
30 public:
33 
34  void setID(int id) { this->id = id; }
35  int getID() const { return id; }
36 
37  void setColor(float r, float g, float b);
38  void setLabel(const std::string& label);
39 
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  int id;
60 
61  friend class GraphWidgetImpl;
62 
63  GraphDataHandlerImpl* impl;
64 };
65 
66 
67 class CNOID_EXPORT GraphWidget : public QWidget
68 {
69 public:
70 
71  GraphWidget(View* parentView);
72  ~GraphWidget();
73 
74  void addDataHandler(GraphDataHandlerPtr handler);
75  void clearDataHandlers();
76 
77  void setRenderingTypes(bool showOriginalValues, bool showVelocities, bool showAccelerations);
78  void getRenderingTypes(bool& showOriginalValues, bool& showVelocities, bool& showAccelerations);
79 
80  bool setCursorPosition(double pos);
81 
82  void setTimeBarSyncMode(bool on);
83  bool isTimeBarSyncMode();
84 
85  enum ScrollMode { OFF, CONTINUOUS, PAGE };
86  void setAutoScrollMode(ScrollMode on);
87  ScrollMode autoScrollMode();
88 
89  void setVerticalValueRange(double lower, double upper);
90  void getVerticalValueRange(double& lower, double& upper);
91 
92  void setLineWidth(double width);
93  double getLineWidth();
94 
95  void showRulers(bool show);
96  bool showsRulers();
97 
98  void showLimits(bool show);
99  bool showsLimits();
100 
101  void showGrid(bool show);
102  bool showsGrid();
103 
104  void setGridSize(double width, double height);
105  void getGridSize(double& width, double& height);
106 
107  void setControlPointStep(int step, int offset = 0);
108  void getControlPointStep(int& step, int& offset);
109 
110  void highlightControlPoints(bool on);
111  bool highlightsControlPoints();
112 
113  enum Mode { VIEW_MODE, EDIT_MODE };
114  void changeMode(Mode mode);
115  Mode mode();
116 
117  enum EditMode { FREE_LINE_MODE, LINE_MODE };
118  void changeEditMode(EditMode mode);
119  EditMode editMode();
120 
121  QLabel& statusLabel();
122 
123  bool saveImage(const std::string& filename);
124 
125  virtual bool storeState(Archive& archive);
126  virtual bool restoreState(const Archive& archive);
127 
128 protected:
129  virtual bool eventFilter(QObject* obj, QEvent* event);
130 
131 private:
132 
133  friend class GraphDataHandler;
134 
135  GraphWidgetImpl* impl;
136 };
137 
138 }
139 
140 #endif
ScrollMode
Definition: GraphWidget.h:85
Definition: Archive.h:21
boost::function< void(int frame, int size, double *out_values)> DataRequestCallback
Definition: GraphWidget.h:51
boost::function< void(int frame, int size, double *values)> DataModifiedCallback
Definition: GraphWidget.h:54
Mode
Definition: GraphWidget.h:113
boost::shared_ptr< GraphDataHandler > GraphDataHandlerPtr
Definition: GraphWidget.h:24
Definition: GraphWidget.h:67
Definition: GraphWidget.h:28
void setID(int id)
Definition: GraphWidget.h:34
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
EditMode
Definition: GraphWidget.h:117
int getID() const
Definition: GraphWidget.h:35
Definition: View.h:28
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
Definition: GraphWidget.h:113