ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Programmatically create TIELineLayer

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
c.basso Posted - Jun 21 2017 : 01:48:44
Hi,
I'm trying to use TIELineLayer.
I need to allow user to create a line in the same mode as he can create line using
MouseInteractVt:= [miPutLine];
My need is to allow diagonal line creation with label.
As with TIELineLayer it creates a box with an horizontal line inside, and after that I have to rotate it to get a diagonal line,
I'm trying to ovverride this mode doing this:

I set:
MouseInteractVt:= [miPutLine];
The user draw the line (diagonal, horizontal, ...)
I read the Line rect,
and I create a TIELineLayer with same line plus my label.

I know how to set MouseInteract:= [miCreateLineLayers] to create line layers,
but how to create programmatically a line layer?

Thanks

Claudio
1   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Jun 21 2017 : 09:50:24
I made a small demo that shows how to create a line layer with TImageEnVect. Each time you click on the TImageEnVect a new line layer is created if the AddLine button is down. If the AddLine button is not down each time you select a layer the properties of the line layer is obtained and the color controls and the line layer height is set to the properties of the selected layer.

This demo does not include rotating the line layer but you should be able to easily add that function.

Here is the code:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, hyieutils, iexBitmaps, hyiedefs, iesettings, iexLayers, iexRulers, ieview,
  imageenview, ievect, Vcl.Buttons, Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    AddLine1: TSpeedButton;
    ImageEnVect1: TImageEnVect;
    Label1: TLabel;
    LineLayerBorderColor1: TColorBox;
    Label2: TLabel;
    LineLayerFillColor1: TColorBox;
    Label3: TLabel;
    LineLayerGradientFillColor1: TColorBox;
    Label4: TLabel;
    LineLayerBorderWidth1: TEdit;
    UpDown1: TUpDown;
    procedure ImageEnVect1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure AddLine1Click(Sender: TObject);
    procedure LineLayerBorderColor1Click(Sender: TObject);
    procedure LineLayerFillColor1Click(Sender: TObject);
    procedure LineLayerGradientFillColor1Click(Sender: TObject);
    procedure LineLayerBorderWidth1Change(Sender: TObject);
  private
    { Private declarations }
    procedure GetLineLayerParameters;
    procedure SetLineLayerParameters;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AddLine1Click(Sender: TObject);
begin
  if AddLine1.Down then
    ImageEnVect1.MouseInteract := ImageEnVect1.MouseInteract + [miMoveLayers, miResizeLayers]
  else
    ImageEnVect1.MouseInteract := [miMoveLayers, miResizeLayers];
end;

procedure TForm1.GetLineLayerParameters;
begin
  if (ImageEnVect1.CurrentLayer is TIELineLayer) then
  begin
    LineLayerBorderColor1.Selected := TIELineLayer(ImageEnVect1.CurrentLayer).BorderColor;
    LineLayerFillColor1.Selected := TIELineLayer(ImageEnVect1.CurrentLayer).FillColor;
    LineLayerGradientFillColor1.Selected := TIELineLayer(ImageEnVect1.CurrentLayer).FillColor2;
    LineLayerBorderWidth1.Text := IntToStr(TIELineLayer(ImageEnVect1.CurrentLayer).BorderWidth);
  end;
end;

procedure TForm1.SetLineLayerParameters;
begin
  if (ImageEnVect1.CurrentLayer is TIELineLayer) then
  begin
    TIELineLayer(ImageEnVect1.CurrentLayer).BorderColor := LineLayerBorderColor1.Selected;
    TIELineLayer(ImageEnVect1.CurrentLayer).FillColor := LineLayerFillColor1.Selected;
    TIELineLayer(ImageEnVect1.CurrentLayer).FillColor2 := LineLayerGradientFillColor1.Selected;
    TIELineLayer(ImageEnVect1.CurrentLayer).BorderWidth := StrToInt(LineLayerBorderWidth1.Text);
    ImageEnVect1.Layers[ImageEnVect1.LayersCurrent].Height := StrToInt(LineLayerBorderWidth1.Text);
    ImageEnVect1.Update;
    ImageEnVect1.IEBitmap.Modified := True;
  end;
end;

procedure TForm1.ImageEnVect1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
begin
  if (ImageEnVect1.CurrentLayer is TIELineLayer) then
      GetLineLayerParameters;
end;

procedure TForm1.ImageEnVect1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  iLayer: Integer;
begin
  if (AddLine1.Down) and (ImageEnVect1.MouseCapture) then
  begin
    Screen.Cursor := crHourglass;
    try
      iLayer := ImageEnVect1.LayersAdd(ielkLine);
      ImageEnVect1.Layers[iLayer].Name := 'Line Layer';
      ImageEnVect1.Layers[iLayer].PosX := X;
      ImageEnVect1.Layers[iLayer].PosY := Y;
      ImageEnVect1.Layers[iLayer].Height := StrToInt(LineLayerBorderWidth1.Text);
      ImageEnVect1.Layers[iLayer].Selectable := True;
      SetLineLayerParameters;
      ImageEnVect1.IEBitmap.Modified := True;
    finally
      Screen.Cursor := crDefault;
    end;
  end
  else
  begin
    if (ImageEnVect1.CurrentLayer is TIELineLayer) then
      GetLineLayerParameters;
  end;
end;

procedure TForm1.LineLayerBorderColor1Click(Sender: TObject);
begin
  SetLineLayerParameters;
end;

procedure TForm1.LineLayerBorderWidth1Change(Sender: TObject);
begin
  SetLineLayerParameters;
end;

procedure TForm1.LineLayerFillColor1Click(Sender: TObject);
begin
  SetLineLayerParameters;
end;

procedure TForm1.LineLayerGradientFillColor1Click(Sender: TObject);
begin
  SetLineLayerParameters;
end;

end.


Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development