⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 series.pas

📁 第三方控件:PaintGrid.pas 网格型仪表控件源文件 Mymeter.pas 圆型仪表控件源文件 Project1是这两个控件的使用范例。 该
💻 PAS
📖 第 1 页 / 共 5 页
字号:
         With Canvas do
         begin
           if Transparency>0 then
              if View3D then
                 tmpBlend:=BeginBlending(RectFromRectZ(tmpR,StartZ),Transparency)  // 6.01
              else
                 tmpBlend:=BeginBlending(tmpR,Transparency)  // 6.01
           else
              tmpBlend:=nil;

           if View3D then
           begin
             RectangleWithZ(tmpR,StartZ);
             if SupportsFullRotation then RectangleWithZ(tmpR,EndZ);
           end
           else
           begin
             if FGradient.Visible then
             begin
               FGradient.Draw(Canvas,tmpR);  // 5.03
               if Pen.Style<>psClear then
               begin
                 Brush.Style:=bsClear;
                 Rectangle(tmpR);
               end;
             end
             else Rectangle(tmpR);
           end;

           if Transparency>0 then
              EndBlending(tmpBlend);
         end;


         if LinePen.Visible and (not FAreaLinesPen.Visible) then
         begin
           Canvas.AssignVisiblePen(LinePen);
           if YMandatory then
              if FInvertedStairs then
              begin
                Canvas.LineWithZ(OldX,Y,X,Y,StartZ);
                Canvas.LineWithZ(OldX,OldY,OldX,Y,StartZ);
              end
              else
              begin
                Canvas.LineWithZ(OldX,OldY,X,OldY,StartZ);
                Canvas.LineWithZ(X-1,OldY,X-1,Y,StartZ);
              end
           else
              if FInvertedStairs then
              begin
                Canvas.LineWithZ(X,OldY,X,Y,StartZ);
                Canvas.LineWithZ(OldX,OldY,X,OldY,StartZ);
              end
              else
              begin
                Canvas.LineWithZ(OldX,OldY,OldX,Y,StartZ);
                Canvas.LineWithZ(OldX,Y,X,Y,StartZ);
              end;
         end;

       end
       else // not in "stairs" mode...
       With Canvas do
       begin

         if YMandatory then
         begin
           tmpP[0]:=TeePoint(OldX,OldBottomPos);
           tmpP[3]:=TeePoint(X,BottomPos);
         end
         else
         begin
           tmpP[0]:=TeePoint(OldBottomPos,OldY);
           tmpP[3]:=TeePoint(BottomPos,Y);
         end;

         tmpP[1]:=TeePoint(OldX,OldY);
         tmpP[2]:=TeePoint(X,Y);

         if Transparency>0 then
            tmpBlend:=Canvas.BeginBlending(RectFromPoints(tmpP),Transparency)
         else
            tmpBlend:=nil;

         if View3D then
         begin
           if (View3DOptions.Rotation>90) and (View3DOptions.Rotation<270) then
              tmpZ:=EndZ
           else
              tmpZ:=StartZ;

           if FGradient.Visible then
              FGradient.Draw(Canvas,tmpP,tmpZ)
           else
              PlaneWithZ(tmpP,tmpZ);
         end
         else // 5.02
         begin
           if FGradient.Visible then { 5.03 }
           begin
             ClipPolygon(tmpP,4);

             tmpMax:=CalcPosValue(MandatoryValueList.MaxValue);
             tmpMin:=CalcPosValue(MandatoryValueList.MinValue);

             if YMandatory then tmpR:=TeeRect(OldX,tmpMax,X,tmpMin)
                           else tmpR:=TeeRect(tmpMin,OldY,tmpMax,Y);

             FGradient.Draw(Canvas,tmpR);
             UnClipRectangle;

             Brush.Style:=bsClear;

             if Pen.Style<>psClear then
                if YMandatory then DoVertLine(OldX,OldY,OldBottomPos)
                              else DoHorizLine(OldBottomPos,OldX,OldY);

           end
           else Polygon(tmpP);
         end;

         if Transparency>0 then
            Canvas.EndBlending(tmpBlend);

         if SupportsFullRotation then PlaneWithZ(tmpP,EndZ);

         if LinePen.Visible then
         begin
           AssignVisiblePen(LinePen);
           LineWithZ(OldX,OldY,X,Y,StartZ);
         end;
       end;
     end;
   end;

   Procedure DrawPoint(DrawOldPointer:Boolean);
   var tmpPoint     : TPoint;
       tmpOldP      : TPoint;
       tmpDifX      : Integer;
       P4           : TFourPoints;
       OldDarkColor : TColor;
       tmpDark3D    : Boolean;
   begin
     if ((x<>OldX) or (y<>OldY)) and (tmpColor<>clNone) then { <-- if not null }
     with ParentChart,Canvas do
     begin
       if View3D then
       Begin
         { 3D }
         if FDrawArea or FDrawLine then
         begin
           AssignVisiblePen(LinePen);

           if FColorEachLine or FDrawArea then
              OldDarkColor:=GetAreaBrushColor(tmpColor)
           else
              OldDarkColor:=SeriesColor;  // 6.01

           if Brush.Color<>OldDarkColor then
              Brush.Color:=OldDarkColor;

           if Brush.Style<>LineBrush then
              Brush.Style:=LineBrush;

           if Assigned(Self.Brush.Image.Graphic) then
              Brush.Bitmap:=Self.Brush.Image.Bitmap;

           tmpPoint.X:=X;
           tmpPoint.Y:=Y;
           tmpOldP.X :=OldX;
           tmpOldP.Y :=OldY;

           if FStairs then
           Begin
             if FInvertedStairs then { or LastValue=FirstValueIndex }
             begin
               if FDark3D then Brush.Color:=ApplyDark(Brush.Color,DarkColorQuantity);

               if YMandatory then
                  RectangleZ( tmpOldP.X,tmpOldP.Y, Y,StartZ,EndZ)
               else
                  RectangleY( tmpPoint.X, tmpPoint.Y,OldX,StartZ,EndZ);

               if FDark3D then Brush.Color:=OldDarkColor;

               if YMandatory then
                  RectangleY( tmpPoint.X, tmpPoint.Y,OldX,StartZ,EndZ)
               else
                  RectangleZ( X, tmpOldP.Y, Y, StartZ, EndZ);
             end
             else
             begin
               if YMandatory then
                  RectangleY( tmpOldP.X, tmpOldP.Y, X, StartZ, EndZ)
               else
                  RectangleZ( OldX, tmpOldP.Y, Y, StartZ, EndZ);

               if FDark3D then Brush.Color:=ApplyDark(Brush.Color,DarkColorQuantity);

               if YMandatory then
                  RectangleZ( tmpPoint.X,tmpPoint.Y, OldY,StartZ,EndZ)
               else
                  RectangleY( OldX, tmpPoint.Y, X,StartZ,EndZ);

               if FDark3D then Brush.Color:=OldDarkColor;
             end;
           end
           else
           begin
             if (FLineHeight>0) and (not FDrawArea) then
             begin
               P4[0]:=tmpPoint;
               P4[1]:=tmpOldP;
               P4[2].X:=tmpOldP.X;
               P4[2].Y:=tmpOldP.Y+FLineHeight;
               P4[3].X:=tmpPoint.X;
               P4[3].Y:=tmpPoint.Y+FLineHeight;
               PlaneFour3D(P4,StartZ,StartZ);
               if IsLastValue then
                  RectangleZ(tmpPoint.X,tmpPoint.Y,tmpPoint.Y+FLineHeight,StartZ,EndZ);
             end;

             tmpDark3D:=FDark3D and (not SupportsFullRotation);
             if tmpDark3D then
             begin
               tmpDifX:=tmpPoint.X-tmpOldP.X;
               if (tmpDifX<>0) and
                  (tmpDark3DRatio<>0) and
                  ((tmpOldP.Y-tmpPoint.Y)/tmpDifX > tmpDark3DRatio) then
               begin
                 Brush.Color:=ApplyDark(Brush.Color,DarkColorQuantity);
                 if (FLineHeight>0) and (not FDrawArea) then {special case}
                 begin
                   Inc(tmpPoint.Y,FLineHeight);
                   Inc(tmpOldP.Y,FLineHeight);
                 end;
               end;
             end;

             if Monochrome then Brush.Color:=clWhite;

             Plane3D(tmpPoint,tmpOldP,StartZ,EndZ);

             if tmpDark3D then Brush.Color:=OldDarkColor;
           end;
         end;
       end;

       if FDrawArea then
       Begin { area }
         Brush.Color:=GetAreaBrushColor(tmpColor);

         if (FAreaLinesPen.Color=clTeeColor) or (not FAreaLinesPen.Visible) then
            AssignVisiblePenColor(FAreaLinesPen,tmpColor)
         else
            AssignVisiblePen(FAreaLinesPen);

         InternalDrawArea(Brush.Color);
       end
       else
       if (not View3D) and FDrawLine then
       begin // line 2D
         if ColorEachPoint and ColorEachLine then
            LinePrepareCanvas(Canvas,tmpColor)
         else
            LinePrepareCanvas(Canvas,SeriesColor);

         if FStairs then
         begin
           if FInvertedStairs then DoVertLine(OldX,OldY,Y)
                              else DoHorizLine(OldX,X,OldY);
           LineTo(X,Y);
         end
         else Line(OldX,OldY,X,Y);
       end;
     end;

     { pointers }
     if FPointer.Visible and DrawOldPointer then
     begin
       if OldColor<>clNone then { <-- if not null }
          DrawPointer(OldX,OldY,OldColor,Pred(ValueIndex));

       if IsLastValue and (tmpColor<>clNone) then {<-- if not null }
          DrawPointer(X,Y,tmpColor,ValueIndex);
     end;
   end;

var tmpFirst : Integer;
Begin
  With ParentChart.Canvas do
  Begin
    tmpColor:=ValueColor[ValueIndex];
    X:=CalcXPos(ValueIndex);
    Y:=CalcYPos(ValueIndex);

    if Pen.Color<>clBlack then { 5.02 }
       Pen.Color:=clBlack;

    if tmpColor<>Brush.Color then { 5.02 }
       Brush.Color:=tmpColor;

    if OldColor=clNone then { if null }
    begin
      OldX:=X;
      OldY:=Y;
    end;

    BottomPos:=GetOriginPos(ValueIndex);

    tmpFirst:=FirstDisplayedIndex;
    if DrawValuesForward then IsLastValue:=ValueIndex=LastValueIndex
                         else IsLastValue:=ValueIndex=FirstValueIndex;

    if ValueIndex=tmpFirst then { first point }
    Begin
      if FDark3D then
      With ParentChart do
         if SeriesWidth3D<>0 then
            tmpDark3DRatio:=Abs(SeriesHeight3D/SeriesWidth3D)
         else
            tmpDark3DRatio:=1;

      if (tmpFirst=FirstValueIndex) and (ValueIndex>0) then
      Begin  { previous point outside left }
        if FDrawArea then
        begin
          OldX:=CalcXPos(Pred(ValueIndex));
          OldY:=CalcYPos(Pred(ValueIndex));
          OldBottomPos:=GetOriginPos(Pred(ValueIndex));
        end
        else
        begin
          if GetHorizAxis.Inverted then OldX:=ParentChart.ChartRect.Right
                                   else OldX:=ParentChart.ChartRect.Left;

          if FStairs Then
             OldY:=CalcYPos(Pred(ValueIndex))
          else
             OldY:=CalcYPosLeftRight(GetHorizAxis.CalcPosPoint(OldX),Pred(ValueIndex))
        end;

        if not IsNull(Pred(ValueIndex)) then DrawPoint(False);
      end;

      if IsLastValue and FPointer.Visible then
         DrawPointer(X,Y,tmpColor,ValueIndex);

      if SupportsFullRotation and FDrawArea and ParentChart.View3D then
         RectangleZ(X,Y,BottomPos,StartZ,EndZ);
    end
    else DrawPoint(True);

    OldX:=X;
    OldY:=Y;
    OldBottomPos:=BottomPos;
    OldColor:=tmpColor;
  end;
end;

Procedure TCustomSeries.DrawPointer(AX,AY:Integer; AColor:TColor; ValueIndex:Integer);
var tmpStyle : TSeriesPointerStyle;
begin
  Pointer.PrepareCanvas(ParentChart.Canvas,AColor);
  if Assigned(FOnGetPointerStyle) then tmpStyle:=FOnGetPointerStyle(Self,ValueIndex)
                                  else tmpStyle:=Pointer.Style;
  Pointer.Draw(AX,AY,AColor,tmpStyle);
end;

class Function TCustomSeries.GetEditorClass:String;
Begin
  result:='TCustomSeriesEditor'; { <-- dont translate ! }
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -