/* 辅助函数-初始化六个子面板及各个面板上的内容 */	
void initChildPanels(void){
	/* 循环创建六个Panel */
	CPanels[0] = createChildPanel("xAxls-Accelerator", 0);
	CPanels[1] = createChildPanel("yAxls-Accelerator", 1);
	CPanels[2] = createChildPanel("zAxls-Accelerator", 2);
	CPanels[3] = createChildPanel("xAxls-Gyro", 3);
	CPanels[4] = createChildPanel("yAxls-Gyro", 4);
	CPanels[5] = createChildPanel("zAxls-Gyro", 5);
	for(int i = 0; i<validMonNum; i++){
		DisplayPanel (CPanels[i]);	
	}
	//在子Panel上创建图表,设置Graph属性,准备显示数据
	for(int i=0; i<validMonNum; i++){
		PGraphs[i] = NewCtrl(CPanels[i], CTRL_STRIP_CHART, 0, 0,0);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_WIDTH, cWidth);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_HEIGHT, cHeight);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_PLOT_BGCOLOR, plotBakgColor);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_GRID_COLOR, plotGridColor);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_EDGE_STYLE, VAL_FLAT_EDGE);		
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_SCROLL_MODE, VAL_CONTINUOUS);
		SetAxisScalingMode(CPanels[i], PGraphs[i], VAL_LEFT_YAXIS, graphScaleMode, yAxisRange[0], yAxisRange[1]);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_POINTS_PER_SCREEN, 50);
		//SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_YFORMAT,VAL_FLOATING_PT_FORMAT);
		SetTraceAttribute(CPanels[i],PGraphs[i], 1, ATTR_TRACE_COLOR, plotLineColor);
		//SetTraceAttribute(CPanels[i],PGraphs[i], 1, ATTR_PLOT_STYLE, VAL_CONNECTED_POINTS);
		SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_ANTI_ALIASED_PLOTS, 1);
	}
	manageGraphCallbackFunc();
	
}
示例#2
0
STD_ERROR	DLLEXPORT	GRAPH_Plot( void *Data , int iYAxisPrecision )
{
	STD_ERROR		StdError			=	{0};

	int			panel				=	0;
	
	int			numberOfPoints		=	0,
				numberOfTraces		=	0,
				maxNumberOfPoints	=	0;
	
	int			index				=	0,
				tempIndex			=	0, 
				totalIndex			=	0, 
				PlotIndex			=	0;
	
	int			*pPointCounter		=	NULL;
				
	double		*pSinglePlot		=	NULL;
	
	double		lfCurrentX			=	0.0,
				lfStepX				=	0.0;
	
	double		lfY_axis_min		=	0.0,
				lfY_axis_max		=	0.0;
	
	tsPlotGraphData		*pData					=	NULL;
	
	IF ( (Data == NULL) , "Pointer passed NULL");
	
	pData = (tsPlotGraphData*)Data;
	
	IF( ( pData->TraceList == NULL ) , "No traces added.");
	IF( ( pData->numberOfTraces == 0 ) , "No traces added.");

	panel = pData->panel;
	
	numberOfTraces = pData->numberOfTraces;
	
	lfCurrentX = pData->start_x;
	
	if ( pData->numberOfPoints )
		lfStepX = ( pData->stop_x - pData->start_x ) / (double)(pData->numberOfPoints-1);  
	else
		lfStepX = pData->stop_x - pData->start_x;
	
	ProcessDrawEvents();
	
	numberOfPoints = pData->numberOfPoints;
	
	if ( numberOfPoints == 0 )
	{
		for ( index = 0 ; index < numberOfTraces  ; index++ ) 
			if ( pData->TraceList[index].numberOfPoints > numberOfPoints )
				numberOfPoints = pData->TraceList[index].numberOfPoints;
		
	}
	
	maxNumberOfPoints = numberOfPoints * numberOfTraces;
	
	CALLOC_ERR( pSinglePlot , maxNumberOfPoints+128 , sizeof(double));
	CALLOC_ERR( pPointCounter , numberOfTraces+1 , sizeof(int));
		
	IF (( pSinglePlot == NULL ), "Can't allocate Memory.");    
	IF (( pPointCounter == NULL ), "Can't allocate Memory.");  
	
	SetCtrlAttribute ( panel , pData->control , ATTR_NUM_TRACES , numberOfTraces ); 
	
	SetCtrlAttribute ( panel , pData->control , ATTR_SCROLL_MODE , VAL_CONTINUOUS );	
	SetCtrlAttribute (panel, pData->control, ATTR_GRID_COLOR, VAL_BLACK);
		
	SetCtrlAttribute ( panel , pData->control , ATTR_POINTS_PER_SCREEN , numberOfPoints );
	
	lfY_axis_min = pData->y_axis_min;
	lfY_axis_max = pData->y_axis_max;
	
	if (( IsNotANumber (lfY_axis_min) == 0 ) && ( IsNotANumber (lfY_axis_max) == 0 ) && ( fabs( lfY_axis_min ) > 1E-20 ) && ( fabs( lfY_axis_max ) > 1E-20 ))
	{
		SetAxisScalingMode (panel, pData->control, VAL_LEFT_YAXIS,VAL_MANUAL, lfY_axis_min , lfY_axis_max); 
	}
	
	SetAxisScalingMode (panel, pData->control, VAL_BOTTOM_XAXIS ,VAL_MANUAL, pData->start_x , lfStepX ); 

	SetCtrlAttribute (panel, pData->control, ATTR_YPRECISION , iYAxisPrecision );
		
	if ( pData->szY_AxisName )
		SetCtrlAttribute  ( panel , pData->control , ATTR_YNAME , pData->szY_AxisName );
	
	if ( pData->szX_AxisName ) 
		SetCtrlAttribute  (panel, pData->control , ATTR_XNAME , pData->szX_AxisName );
	
	SetCtrlAttribute ( panel , pData->control , ATTR_LEGEND_NUM_VISIBLE_ITEMS , numberOfTraces );
	
	for ( index = 0 ; index < numberOfTraces  ; index++ ) 
	{
		SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_COLOR , pData->TraceList[index].trace_color );
		SetTraceAttributeEx ( panel , pData->control , index+1 , ATTR_TRACE_LG_TEXT , pData->TraceList[index].szTraceName ); 
	
		SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_LG_TEXT_COLOR , VAL_BLACK );
		SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_LG_VISIBLE , 1 );
		
		if ( pData->TraceList[index].iThickness > 0 )
			SetTraceAttribute (panel, pData->control, index+1 ,ATTR_TRACE_THICKNESS, pData->TraceList[index].iThickness );
		
		SetTraceAttribute ( panel , pData->control , index+1 , ATTR_TRACE_VISIBLE , 1 );
	}
	
	for ( PlotIndex = 0 ; PlotIndex < numberOfPoints  ; PlotIndex++ ) 
	{
		for ( index = 0 ; index < numberOfTraces  ; index++ ) 
		{
			if ( ( lfCurrentX >= pData->TraceList[index].start_x ) && ( pPointCounter[index] < pData->TraceList[index].numberOfPoints ) && ( pPointCounter[index] < numberOfPoints ))
			{
				tempIndex = pPointCounter[index] + pData->TraceList[index].startTraceFromIndex;
				
				pSinglePlot[totalIndex++] = pData->TraceList[index].Trace[tempIndex];
				
				pPointCounter[index]++;
			}
			else
			{
				tempIndex = pData->TraceList[index].startTraceFromIndex;
				
				pSinglePlot[totalIndex++] = pData->TraceList[index].Trace[tempIndex];
				
				pPointCounter[index]++;
			}
		}
		
		lfCurrentX += lfStepX;
	}
	
	PlotStripChart ( panel , pData->control , pSinglePlot , totalIndex , 0 , 0 , VAL_DOUBLE );
	
Error:
	
	if ( pSinglePlot )
		free(pSinglePlot);
	
	if ( pPointCounter )
		free( pPointCounter );
	
	ProcessDrawEvents();  
	
	return StdError;
}