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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Polyline point editing
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

chaenam choe

Korea
3 Posts

Posted - Dec 23 2020 :  00:06:07  Show Profile  Reply
after drawing polyline as attached image I would like to move one of the polyline point with text layer following to that point.
I created as below...

procedure TfmAnalyzer.ImageEnView2LayerNotify(Sender: TObject; layer: Integer;
  event: TIELayerEvent);
var
  i, cnt, idx : Integer;
  pt : TPoint;
  X,Y : Integer;
begin
  if event = ielCreated then begin
    with TIEPolylineLayer(ImageEnView2.CurrentLayer) do begin
      cnt := PointCount;
      for i := 0 to cnt - 1 do begin
        X := GetPoint(i, iepbBitmap).X;
        Y := GetPoint(i, iepbBitmap).Y;
        ImageEnView2.LayersAdd(ielkText, X+30, Y, 300, 70);
        TIETextLayer(ImageEnView2.CurrentLayer).Name := 'TXTL_' + IntToStr(i);
        TIETextLayer(ImageEnView2.CurrentLayer).Text := IntToStr(i+1) + ': ' + IntToStr(X) + '/' + IntToStr(Y);
        TIETextLayer(ImageEnView2.CurrentLayer).BorderColor := clBlack;
        TIETextLayer(ImageEnView2.CurrentLayer).BorderWidth := 2;
        TIETextLayer(ImageEnView2.CurrentLayer).FillColor := clWhite;
        TIETextLayer(ImageEnView2.CurrentLayer).Alignment := iejCenter;
        TIETextLayer(ImageEnView2.CurrentLayer).Layout := ielCenter;
        TIETextLayer(ImageEnView2.CurrentLayer).Font.Size := 30;
      end;
    end;
    ImageEnView2.Update();
    POLY_DONE := True;
  end;
end;

I tried with OnLayerNotify event, OnLayerNotifyEx, OnLayerMoveSize...but I get errors...
My code is ...

    if (ImageEnView2.Layers[layer].Kind = ielkPolyline) and (event = ielMovedPoint) then begin
      ShowMessage('point moved...');
        cnt := TIEPolylineLayer(ImageEnView2.CurrentLayer).PointCount;
        ShowMessage(IntToStr(cnt));
        for i := 0 to cnt - 1 do begin
          X := TIEPolylineLayer(ImageEnView2.CurrentLayer).GetPoint(i, iepbBitmap).X;
          X := TIEPolylineLayer(ImageEnView2.CurrentLayer).GetPoint(i, iepbBitmap).Y;
          idx := ImageEnView2.LayersNameToIndex('TXTL_' + IntToStr(i), False);
          ImageEnView2.Layers[idx].PosX := X + 30;
          ImageEnView2.Layers[idx].PosY := Y;
          TIETextLayer(ImageEnView2.Layers[idx]).Text := IntToStr(i+1) + ': ' + IntToStr(X) + '/' + IntToStr(Y);
        end;
        ImageEnView2.Update();
    end;


what am I wrong? what should I do?
Any idea will be happy...
thanks.



xequte

38198 Posts

Posted - Dec 28 2020 :  18:34:56  Show Profile  Reply
Hi

Your code works fine here, except the line:

X := TIEPolylineLayer(ImageEnView2.CurrentLayer).GetPoint(i, iepbBitmap).Y;

Should read:

Y := TIEPolylineLayer(ImageEnView2.CurrentLayer).GetPoint(i, iepbBitmap).Y;


Note: Also, for safety, you should always check that layer >=0 if you use LayerNotifyEx

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: