原创 Labwindows/cvi8.5学习日志(45)----xy轴设置

2010-8-4 12:34 4392 12 12 分类: 软件与OS


e4a60f4e-8c51-4366-a841-7da23637cea0.jpg


//*****************************************************************************
// Labwindows/cvi8.5  设置图片显示的X-Y轴
// 需要在仿真调试的时候认真体会
// szlihongtao
// 2010-08-04
//***************************************************************************** 
#include <cvirte.h>  
#include <userint.h>
#include "XY.h"
//*****************************************************************************
static int panelHandle;
double arr[1024];
unsigned short int i;
//***************************************************************************** 
int main (int argc, char *argv[])
{
 if (InitCVIRTE (0, argv, 0) == 0)
  return -1; /* out of memory */
 if ((panelHandle = LoadPanel (0, "XY.uir", PANEL)) < 0)
  return -1;
 DisplayPanel (panelHandle);
 RunUserInterface ();
 DiscardPanel (panelHandle);
 return 0;
}
//*****************************************************************************  
int CVICALLBACK func_exit (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_COMMIT:
   QuitUserInterface (0);
   break;
 }
 return 0;
}
//***************************************************************************** 
int CVICALLBACK func_draw (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_COMMIT:
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_LABEL_TEXT, "输出特性图");
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XNAME, "X轴的名字");
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_YNAME, "Y轴的名字");  
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XPRECISION, 1);  // 小数点位数
                  
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XMAP_MODE, VAL_LOG); // 对数显示 
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XMAP_MODE, VAL_LINEAR); // 线性显示 
   
    
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XDIVISIONS, 6); // X轴等分为6格
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XAXIS_OFFSET,5.0); // X轴加入5.0的偏移量,偏移量不需要乘以增益
   
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XAXIS_GAIN, 2.0); // X轴增益
 
 
   SetAxisScalingMode(panelHandle,PANEL_GRAPH,VAL_BOTTOM_XAXIS,VAL_MANUAL,0,120);
     
   //SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_XAXIS_GAIN, 2.0); // X轴的提示数字放大为2倍数
//------------------------------------------------------------------------------------------------------------ 
// Y轴参数设置
//------------------------------------------------------------------------------------------------------------  
   
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_YPRECISION, 0);  // 小数点位数
      SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_YAXIS_GAIN, 2.0);  
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_YDIVISIONS, 10); // Y轴等分为10格
   SetAxisScalingMode(panelHandle,PANEL_GRAPH,VAL_LEFT_YAXIS ,VAL_MANUAL,8,400);
   SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_YAXIS_OFFSET,99.0); // 
               
      for(i=0;i<1024;++i)
         arr=4*i;
   
   PlotY (panelHandle, PANEL_GRAPH, arr, 80, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
   
   break;
 }
 return 0;
}
//*****************************************************************************
//*****************************************************************************
//*****************************************************************************

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
12
关闭 站长推荐上一条 /3 下一条