zoukankan      html  css  js  c++  java
  • 关于TVrScope的显示问题

    项目里用到了TMS的工控控件TMS Instrumentation Workshop ,其中TVrScope简单波形显示控件的波形显示老是不理想,程序里怎么设置也不对,只好看控件源码了,创建显示点的函数procedureTVrScope.CreateGraph;调用了取显示值函数functionTVrScope.GetPlotValue(var S: string): Integer;

    functionTVrScope.GetPlotValue(var S: string): Integer;
    var
     P: Integer;
    begin
     Result := 0;
     P := StrToInt(Copy(S, 1, Fixed));
     Delete(S, 1, Fixed);
     
     
     //Result := SolveForY(P - FMinValue, FMaxValue - FMinValue);
     //Result := Height - SolveForX(Result, Height);
     
     
     if FMaxValue <> FMinValue then
        Result := Height -Round(Height*P/(FMaxValue-FMinValue)) - 1;
     
     
     if Result < 0 then
        Result := 0;
    end;

    原来的取点方法只适用于固定的Min和Max的情况,程序里因为显示波形的控件高度只有50,而要显示的数据范围比较大,只能动态设置Min和Max。

    functionTVrScope.GetPlotValue(var S: string): Integer;
    var
     P: Integer;
    begin
     Result := 0;
     P := StrToInt(Copy(S, 1, Fixed));
     Delete(S, 1, Fixed);
     
     
     //Result := SolveForY(P - FMinValue, FMaxValue - FMinValue);
     //Result := Height - SolveForX(Result, Height);
     
     //这里修改
     //if FMaxValue <> FMinValue then
     //  Result := Height -Round(Height*P/(FMaxValue-FMinValue)) - 1;
     
     if FMaxValue <> FMinValue then
        Result:=Round(Height /(FMaxValue-FMinValue) *(FMaxValue - P))+1;
     
     if Result < 0 then
        Result := 0;
    end;

    这样显示才对。


    这个控件要显示的一系列值是用一个字符串缓存的,每个值默认存为10个长度字符。取出后删除10个字符,新值增加10个字符,还有StrToInt()和IntToStr(),

    这样的效率?

  • 相关阅读:
    ListNode Java创建链表
    Remove Nth Node From End of List LeetCode Java
    Rotate List LeetCode Java
    LeetCode刷题感想
    Swap Nodes in Pairs LeetCode Java
    Reverse Nodes in k-Group LeetCode Java
    334. Increasing Triplet Subsequence
    300. Longest Increasing Subsequence
    130. Surrounded Regions
    200. Number of Islands
  • 原文地址:https://www.cnblogs.com/jankerxp/p/7774037.html
Copyright © 2011-2022 走看看