TTeePolygon

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
mpv
Newbie
Newbie
Posts: 6
Joined: Thu Sep 24, 2009 12:00 am

TTeePolygon

Post by mpv » Mon Sep 26, 2011 11:38 am

Hi,

I want to dray a polygon and fill it with a calculated bitmap.
I followed an example from your site along these lines:

var
ASerie: TMapSeries;
APol: TTeePolygon;
begin
ASerie:=TMapSeries.Create(Chart1);
ASerie.ParentChart:=Chart1;
ASerie.Pen.Color:=clWhite; // color of polygon line
APol:=ASerie.Shapes.Add;
APol.Color:=clRed; // color inside polygon
APol.Points.Clear;
for n := 1 to 10 do
APol.Points.AddXY(x,y);
end;

In this case, the inside of the polygon will be solid red.
Is there a way to paint it with a custom bitmap ?

Regards, Matt

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TTeePolygon

Post by Narcís » Mon Sep 26, 2011 2:37 pm

Hi Matt,

You can assign a bitmap to the TMapSeries, for example:

Code: Select all

uses TeeMapSeries;

procedure TForm1.FormCreate(Sender: TObject);
var
  ASerie  : TMapSeries;
  APol    : TTeePolygon;
  MyBmp   : TBitmap;
begin
  MyBmp:=TBitmap.Create;
  MyBmp.LoadFromFile('c:\temp\rocks.bmp');

  ASerie:=TMapSeries.Create(Chart1);
  ASerie.ParentChart:=Chart1;
  ASerie.Pen.Color:=clWhite; // color of polygon line
  ASerie.Brush.Bitmap:=MyBmp;

  APol:=ASerie.Shapes.Add;
  APol.Points.Clear;

  with APol.Points do
  begin
    AddXY(1,1);
    AddXY(1,10);
    AddXY(10,10);
    AddXY(10,1);
  end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mpv
Newbie
Newbie
Posts: 6
Joined: Thu Sep 24, 2009 12:00 am

Re: TTeePolygon

Post by mpv » Mon Oct 03, 2011 9:23 pm

Thanks Narcis, that works. I obviously used the wrong brush here.
I would like to add some marks for the polygon, but I have only managed to get a single mark in the middle for the TMapSeries.
Is it at all possible to add marks to points of a polygon?

As a workaround, I could add a number of line series, which would have the same points, and use these to generate the marks from.

Regards, Matt

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TTeePolygon

Post by Yeray » Wed Oct 05, 2011 8:16 am

Hello Matt,

As you've seen, the TMapSeries shows a mark for each shape, in the centre of the shape.
If you want a mark at each point/edge, the easiest solution would be using an extra series (like a TPointSeries) with a point for each edge. Here it is a simple example:

Code: Select all

uses TeeMapSeries, Series;

procedure TForm1.FormCreate(Sender: TObject);
var
  ASerie  : TMapSeries;
  AMSerie : TPointSeries;
  APol    : TTeePolygon;
  MyBmp   : TBitmap;
  i       : Integer;
begin
  Chart1.Legend.Visible:=false;
  Chart1.View3D:=false;

  MyBmp:=TBitmap.Create;
  MyBmp.LoadFromFile('c:\temp\rocks.bmp');

  ASerie:=TMapSeries.Create(Chart1);
  ASerie.ParentChart:=Chart1;
  ASerie.Pen.Color:=clWhite; // color of polygon line
  ASerie.Brush.Bitmap:=MyBmp;

  AMSerie:=TPointSeries.Create(Chart1);
  AMSerie.ParentChart:=Chart1;
  AMSerie.Marks.Visible:=true;
  AMSerie.Marks.Style:=smsXY;
  AMSerie.Pointer.Visible:=false;

  APol:=ASerie.Shapes.Add;
  APol.Points.Clear;
  with APol.Points do
  begin
    AddXY(1,1);
    AddXY(1,10);
    AddXY(10,10);
    AddXY(10,1);

    for i:=0 to Count-1 do
      AMSerie.AddXY(XValue[i], YValue[i]);
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply