【问题标题】:Can TChart create a cylinder/pipe/tube with surface coloring similar to the TColorGridSeriesTChart 可以创建表面着色类似于 TColorGridSeries 的圆柱体/管道/管吗
【发布时间】:2017-08-31 16:37:16
【问题描述】:

环境 使用 Delphi 的 RAD Studio 10.1 Berlin TeeChart Pro v2017.22 170619 IntraWeb 14.1.14

我正在使用 IntraWeb 创建一个网页来显示各种图像。最近请求的其中之一是具有我控制的表面颜色轮廓/渐变的 3D 管道/管图像,如以下概念图像所示:

。

我需要能够旋转、平移和缩放此图像。我希望有一种方法可以使用 TeeChart 来实现这一点。

据我所知,TChart 仅支持表面网格,而不支持对象上的 3D 表面。

我想使用 TeeChart,但对其他可能性持开放态度。我一直在寻找其他可能支持此功能的组件,但没有找到。

我已经研究过使用 FMX 的可能性,但 IntraWeb 是一个 VCL 应用程序。我知道 FMX 已在 VCL 中使用,所以这是可能的。但是,如果这是可能的,我不确定是否可以创建具有彩色表面轮廓/渐变的管道。

【问题讨论】:

    标签: delphi pipe teechart


    【解决方案1】:

    关于交互性,如果您想旋转系列(而不是图像),我不确定您是否可以将事件从 Intraweb 转发到图表以进行旋转。

    • 一个选项是使用TVoluemPipeSeries。即:

      uses TeeGLCanvas, TeeVolumePipe;
      
      procedure TForm1.FormCreate(Sender: TObject);
      begin
        Chart1.Canvas:=TGLCanvas.Create;
      
        Chart1.Legend.Visible:=False;
        Chart1.Chart3DPercent:=100;
        Chart1.Aspect.Orthogonal:=False;
        Chart1.Aspect.Rotation:=230;
      
        with Chart1.AddSeries(TVolumePipeSeries) as TVolumePipeSeries do
        begin
          FillSampleValues;
          Pen.Color:=Chart1.Canvas.ColorFrom(Pen.Color,150);
        end;
      end;
      

    • 另一种选择是使用两个TSurfaceSeries。即:

      uses TeeSurfa, Math;
      
      var topSurface, bottomSurface: TSurfaceSeries;
      
      procedure TForm1.FormCreate(Sender: TObject);
      var nRev, countZ, i, z: Integer;
          alpha, x, y: Double;
      begin
        Chart1.Legend.Visible:=False;
        Chart1.Chart3DPercent:=100;
        Chart1.Aspect.Orthogonal:=False;
        Chart1.Aspect.Zoom:=80;
        Chart1.Aspect.Rotation:=320;
        Chart1.Aspect.Elevation:=350;
        Chart1.Walls.Visible:=False;
        Chart1.Axes.Visible:=False;
      
        nRev:=50;
        countZ:=20;
      
        bottomSurface:=Chart1.AddSeries(TSurfaceSeries) as TSurfaceSeries;
        topSurface:=Chart1.AddSeries(TSurfaceSeries) as TSurfaceSeries;
      
        topSurface.IrregularGrid:=True;
        topSurface.XValues.Order:=loNone;
        topSurface.YValues.Order:=loNone;
        topSurface.Pen.Color:=Chart1.Canvas.ColorFrom(bottomSurface.Pen.Color,150);
      
        bottomSurface.IrregularGrid:=True;
        bottomSurface.XValues.Order:=loNone;
        bottomSurface.YValues.Order:=loNone;
        bottomSurface.Pen.Color:=Chart1.Canvas.ColorFrom(bottomSurface.Pen.Color,150);
      
        for z:=0 to countZ-1 do
        begin
          for i:=0 to nRev-1 do
          begin
            alpha:=DegToRad(i*360/nRev);
            x:=Cos(alpha);
            y:=Sin(alpha);
      
            if alpha<DegToRad(180) then
              topSurface.AddXYZ(x, y, z, '', RGB(random(255), random(255), random(255)))
            else
              bottomSurface.AddXYZ(x, y, z, '', RGB(random(255), random(255), random(255)));
          end;
      
          bottomSurface.AddXYZ(topSurface.XValues.MaxValue, Sin(ArcCos(topSurface.XValues.MaxValue)), z, '', RGB(random(255), random(255), random(255)));
          bottomSurface.AddXYZ(topSurface.XValues.MinValue, Sin(ArcCos(topSurface.XValues.MinValue)), z, '', RGB(random(255), random(255), random(255)));
        end;
      end;
      

    【讨论】:

    • 与两个表面相比,TeeVolumePipe 的渲染速度相当慢,我也看不到获得渐变颜色的方法。如何让两个表面在颜色之间显示平滑渐变,以获得原始图像中的轮廓效果?
    • 上面的 TVoluemPipeSeries 示例由于 OpenGL 初始化而运行缓慢。完成后,速度很快。
    • 在示例中,我为TSurfaceSeries 单元格设置了随机颜色。你可以设置使用你的调色板来设置你想要的颜色
    猜你喜欢
    • 2014-01-14
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 2010-11-24
    • 2013-12-22
    • 1970-01-01
    相关资源
    最近更新 更多