summaryrefslogtreecommitdiff
path: root/examples/gui/demo_plot.c
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-11-26 02:42:52 +0000
committer[email protected] <[email protected]>2012-11-26 02:42:52 +0000
commit62447b2cd84b529f7dbf6712c29d7ac4ff0c1e12 (patch)
tree399aa1bbc0d4c632d7dc2804ed76e5c62b5cec27 /examples/gui/demo_plot.c
parent9789907ca1b4c43ee34fac6e94e5a48f76aaca3c (diff)
sync RTGUI with github(https://github.com/RT-Thread/RTGUI) 9ae08379da5b698d6facc40bd0415de2e254ae9c
As always, full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2449 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/gui/demo_plot.c')
-rw-r--r--examples/gui/demo_plot.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/examples/gui/demo_plot.c b/examples/gui/demo_plot.c
index 51f4471d1b..fa524aefa7 100644
--- a/examples/gui/demo_plot.c
+++ b/examples/gui/demo_plot.c
@@ -1,5 +1,5 @@
-
#include <rtgui/widgets/plot.h>
+#include <rtgui/widgets/plot_curve.h>
#include "demo_view.h"
@@ -34,30 +34,39 @@ struct rtgui_container* demo_plot(void)
cnt = demo_view("���߻�ͼ");
+ plot = rtgui_plot_create();
+
curve1 = rtgui_plot_curve_create();
- curve1->y_data = sin_ydata;
- curve1->length = sizeof(sin_ydata)/sizeof(sin_ydata[0]);
+ rtgui_plot_curve_set_y(curve1, sin_ydata);
+ RTGUI_MV_MODEL(curve1)->length = sizeof(sin_ydata)/sizeof(sin_ydata[0]);
+ curve1->min_x = 0;
+ curve1->max_x = sizeof(sin_ydata)/sizeof(sin_ydata[0]);
+ curve1->min_y = -100;
+ curve1->min_y = 100;
curve1->color = red;
-
- plot = rtgui_plot_create(curve1);
+ rtgui_mv_model_add_view(RTGUI_MV_MODEL(curve1), RTGUI_MV_VIEW(plot));
curve2 = rtgui_plot_curve_create();
- curve2->y_data = cos_ydata;
- curve2->length = sizeof(cos_ydata)/sizeof(cos_ydata[0]);
+ rtgui_plot_curve_set_y(curve2, cos_ydata);
+ RTGUI_MV_MODEL(curve2)->length = sizeof(cos_ydata)/sizeof(cos_ydata[0]);
+ curve2->min_x = 0;
+ curve2->max_x = sizeof(cos_ydata)/sizeof(cos_ydata[0]);
+ curve1->min_y = -50;
+ curve1->min_y = 50;
curve2->color = blue;
- rtgui_plot_append_curve(plot, curve2);
+ rtgui_mv_model_add_view(RTGUI_MV_MODEL(curve2), RTGUI_MV_VIEW(plot));
curve3 = rtgui_plot_curve_create();
- curve3->x_data = cos_ydata;
- curve3->y_data = sin_ydata;
- curve3->length = sizeof(sin_ydata)/sizeof(sin_ydata[0]);
+ rtgui_plot_curve_set_x(curve3, cos_ydata);
+ rtgui_plot_curve_set_y(curve3, sin_ydata);
+ RTGUI_MV_MODEL(curve3)->length = sizeof(sin_ydata)/sizeof(sin_ydata[0]);
curve3->color = black;
- rtgui_plot_append_curve(plot, curve3);
+ rtgui_mv_model_add_view(RTGUI_MV_MODEL(curve3), RTGUI_MV_VIEW(plot));
rtgui_widget_get_rect(RTGUI_WIDGET(cnt), &rect);
rtgui_widget_set_rect(RTGUI_WIDGET(plot), &rect);
- rtgui_plot_set_base_point(plot,
- rtgui_rect_width(rect)/3, rtgui_rect_height(rect)/2);
+ rtgui_plot_set_base(plot,
+ -rtgui_rect_width(rect)/3, rtgui_rect_height(rect)/2);
rtgui_container_add_child(cnt, RTGUI_WIDGET(plot));