初级会员
- 积分
- 100
- 金钱
- 100
- 注册时间
- 2020-10-12
- 在线时间
- 20 小时
|
这是我用emwin的GRAPH控件做的界面,想向里填充数据坐标,绘制图线,但是下载到板子后还是只有孤零零的坐标系 没有坐标点 也没有函数图象 有没有大神给看下代码啊?
GRAPH_DATA_Handle Graphdata;
GUI_POINT DPoint[]={
{100,100},
{40,20},
{20,0}
};
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Graph1", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "Graph", ID_GRAPH_0, 50, 15, 690, 400, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Height", ID_TEXT_0, 15, 25, 40, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Weight", ID_TEXT_1, 700, 420, 40, 20, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
// USER START (Optionally insert additional variables)
// USER END
WM_HWIN hItem;
GRAPH_SCALE_Handle hScaleV;
GRAPH_SCALE_Handle hScaleH;
switch (pMsg->MsgId) {
// USER START (Optionally insert additional message handling)
// USER END
case WM_INIT_DIALOG:
/* 初始化Framewin控件 */
hItem = pMsg->hWin;
FRAMEWIN_SetText(hItem, "a");
// FRAMEWIN_SetFont(hItem, &XBF12_Font);
FRAMEWIN_SetTextColor(hItem, GUI_BLACK);
FRAMEWIN_SetTextAlign(hItem,GUI_TA_HCENTER);
FRAMEWIN_AddCloseButton(hItem,FRAMEWIN_BUTTON_RIGHT,2); //添加关闭按钮
/* 初始化Graph控件 */
hItem = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_0);
GRAPH_SetColor(hItem, GUI_WHITE, GRAPH_CI_BK);
GRAPH_SetColor(hItem, GUI_BLACK, GRAPH_CI_GRID);
GRAPH_SetBorder(hItem, 30, 0, 10, 10);
GRAPH_SetGridDistX(hItem, 50);
GRAPH_SetGridDistY(hItem, 20);//从一个网格线到下一个网格线的距离
GRAPH_SetLineStyleH(hItem, GUI_LS_DOT);//网格线线型
GRAPH_SetLineStyleV(hItem, GUI_LS_DOT);
GRAPH_SetGridVis(hItem, 1);
/* 创建垂直刻度对象 */
hScaleV = GRAPH_SCALE_Create( 30, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20);//从一个刻度线到另一个刻度线的距离
GRAPH_AttachScale(hItem, hScaleV);
GRAPH_SCALE_SetTextColor(hScaleV, GUI_BLACK);
GRAPH_SCALE_SetFactor(hScaleV, 1);
/* 创建水平刻度对象 */
hScaleH = GRAPH_SCALE_Create(390, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 100);
GRAPH_SCALE_SetTextColor(hScaleH, GUI_BLACK);
GRAPH_AttachScale(hItem, hScaleH);
GRAPH_SCALE_SetFactor(hScaleH, 0.2);
/* 创建数据对象 */
// Graphdata = GRAPH_DATA_XY_Create(GUI_RED, 600, 0, 0);
// GRAPH_DATA_XY_AddPoint(Graphdata,);
int i=0;
GRAPH_DATA_XY_Create(GUI_GREEN,GUI_COUNTOF(DPoint),DPoint,GUI_COUNTOF(DPoint));
GRAPH_DATA_XY_AddPoint(Graphdata,DPoint);
GRAPH_DATA_XY_SetLineStyle(Graphdata,GUI_LS_SOLID);
GRAPH_AttachData(hItem, Graphdata);
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateGraph1
*/
WM_HWIN CreateGraph1(void);
WM_HWIN CreateGraph1(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
void Graph1DLG_Demo(void)
{
WM_HWIN hWin;
hWin=CreateGraph1();
while(1)
{
GUI_Delay(100);
}
}
|
|