IOCOMP IPLOT控件

IOCOMP IPLOT控件IPLOT实现的功能:(1)鼠标拖动、滚动滑轮控制界面的缩放、平移编辑器界面实现DataView->General->AxesControl->Enabeled勾上DataView->General->AxesControl->MouseStyle选择X-Axis;DataView->General->AxesControl->WheelStyle选择X-A

大家好,欢迎来到IT知识分享网。IPLOT实现的功能:

(1)鼠标拖动、滚动滑轮控制界面的缩放、平移


编辑器界面实现


DataView->General->Axes Control->Enabeled 勾上


DataView->General->Axes Control->Mouse Style 选择 X-Axis;


DataView->General->Axes Control->Wheel Style 选择 X-Axis;

(2)控制添加数据后,图形界面初始化位置,如X、y轴的起始位置,结束位置等


IPlot2->XAxis[0]->TrackingEnabled=True;

    IPlot2->XAxis[0]->TrackingStyle =iptsExpandCollapse;

    IPlot2->XAxis[0]->TrackingAlignFirstStyle=ipafsAuto;

    IPlot2->XAxis[0]->RestoreValuesOnResume=True;




(3)界面支持柱形图以及各种曲线的绘制,如一张图形上想要柱形图和曲线图同时显示

        IPlot2->Channel[i]->BarEnabled=True;   //柱形图显示

        IPlot2->Channel[i]->BarWidth=5;

        IPlot2->Channel[i]->BarBrushColor=clRed;


IPlot2->Channel[i]->TraceVisible = True;  //曲线显示




(4)捕捉曲线的位置,提示鼠标当前坐标值


void __fastcall TForm_Main::IPlot2MouseMoveDataView(int Index,

      TShiftState Shift, int X, int Y)


{

      IPlot2->DataCursor[0]->Pointer1Position = (X-IPlot2->XAxis[0]->MinPixels)*100.0/(IPlot2->XAxis[0]->MaxPixels-IPlot2->XAxis[0]->MinPixels);

      int MinIndex= GetMinDistance(Y);//找出距离最近的曲线

      if(MinIndex!=-1)


{


  float xData=  IPlot2->Channel[MinIndex]->DataCursorXValue;


  float yData=  IPlot2->Channel[MinIndex]->DataCursorYValue;


  IPlot2->Annotation[0]->ChannelName = IPlot2->Channel[MinIndex]->Name;


  IPlot2->Annotation[0]->Visible=true;


  int index =IPlot2->GetYAxisIndexByName(IPlot2->Channel[MinIndex]->YAxisName);


  FLOAT max= IPlot2->YAxis[index]->Max;  


  


  IPlot2->Annotation[0]->Text=FormatDateTime(“hh:mm”,IPlot2->Channel[MinIndex]->DataCursorXValue)+”,”+IPlot2->Channel[MinIndex]->DataCursorYText;


  


  IPlot2->Annotation[0]->X = xData;


  IPlot2->Annotation[0]->Y = yData;


}


else


{


  IPlot2->Annotation[0]->Visible=false;


}


}











int  __fastcall TForm_Main::GetMinDistance(int Y)


{



//判断当前哪个与当前鼠标位置最近 对位置进行排序


int BarPixel=-1;


int SumPixel=-1;


int QofCom=-1;


int HostInt=-1;


int ClientInt=-1;


for(int i=0;i<CurCoordDataList->Count;i++)


{


  Coordinate *PCoordinate=(Coordinate *)CurCoordDataList->Items[i];


  if(PCoordinate->index>=0 && PCoordinate->index<=4 && PCoordinate->ydata>0)


  {


  float yData=IPlot2->Channel[PCoordinate->index]->DataCursorYValue;


  BarPixel=abs(IPlot2->YAxis[0]->PositionToPixels(yData)-Y);


  }


  if(PCoordinate->index==5)


  {


  float yData=IPlot2->Channel[PCoordinate->index]->DataCursorYValue;


  SumPixel=abs(IPlot2->YAxis[0]->PositionToPixels(yData)-Y);


  }


if(PCoordinate->index==6)


  {


  float yData=IPlot2->Channel[PCoordinate->index]->DataCursorYValue;


  QofCom=abs(IPlot2->YAxis[1]->PositionToPixels(yData)-Y);


  }


if(PCoordinate->index==7)


  {


  float yData=IPlot2->Channel[PCoordinate->index]->DataCursorYValue;


  HostInt=abs(IPlot2->YAxis[2]->PositionToPixels(yData)-Y);


  }


if(PCoordinate->index==8)


  {


  float yData=IPlot2->Channel[PCoordinate->index]->DataCursorYValue;


  ClientInt=abs(IPlot2->YAxis[2]->PositionToPixels(yData)-Y);


  }


}


int Distance[5]={BarPixel,SumPixel,QofCom,HostInt,ClientInt};


//找出最近的位置


int min=20;


int index=-1;


for( int i=0;i<5;i++)


{


 if(Distance[i]<min && Distance[i]>0)


 {


min=Distance[i];


index=i;


 }


}


if(min>10 || min<0)


{


  index=-1;


}


return index;


}

(5)支持多条X轴、多条Y轴


int indexX= IPlot2->AddXAxis();//添加X轴Y轴


int indexY= IPlot2->AddYAxis();

(6)支持空数据


IPlot->Channel[0]->AddXY(XData,YData);
//正常数据


IPlot->Channel[0]->AddEmpty(XData);
//零


IPlot->Channel[0]->AddNull(XData);
//空数据




(7)控制界面上显示元素的位置、内容等等 例如自定义Y轴刻度


//Y轴刻度自定义


void __fastcall TForm_Main::IPlot2YAxisCustomizeLabel(int Index,

      double Value, AnsiString &ALabel)


{


  const float SmallAmount = 0.000000000001;


  if(Index==3)


  {


 if (Value < ( 50 + SmallAmount) && Value > ( 50 – SmallAmount))  ALabel = “50 (4)”;


 if (Value < ( 100 + SmallAmount) && Value > ( 100 – SmallAmount))  ALabel = “100 (8)”;


 if (Value < ( 150 + SmallAmount) && Value > ( 150 – SmallAmount))  ALabel = “150 (12)”;


 if (Value < ( 200 + SmallAmount) && Value > ( 200 – SmallAmount))  ALabel = “200 (16)”;


  }


}

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/24138.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信