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
 How to convert an Obj Shp to Selection at the...

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
yogiyang Posted - Mar 17 2017 : 07:29:56
Hello,

I am using ImageEnVect to allow user to draw a rectangle shape and the press a button to create selection of the size of the shape at the same location where the shape is placed but I am not able to get the selection at the same location.

I am using following code:
MyX := ievMain.ObjLeft[SelectedObjID];
    MyY := ievMain.ObjTop[SelectedObjID];
    MyW := ievMain.ObjWidth[SelectedObjID];
    MyH := ievMain.ObjHeight[SelectedObjID];

    ievMain.Select(MyX, MyY, MyW, MyH);

I have tried setting Selection Base to both but still not result.

How to get the functionality as described above?

TIA


Yogi Yang
6   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - Mar 28 2017 : 10:26:30
Hello Bill,

You code works like a charm!

It skipped my mind that we have to convert/calculate objects coordinates using XBmp2Scr.

I was under the impression that Object coordinates can be used directly for selection.

Once again, Thanks.


Yogi Yang
xequte Posted - Mar 19 2017 : 23:41:04
Thanks Bill,


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Mar 19 2017 : 18:32:34
I managed to get it to function correctly. The problem (incorrect coordinates) was caused because I converted coordinates to Bitmap coordinates and I should have used ClientArea coordinates to set the selection. In my test project the SelectionBase property is iesbClientArea.
procedure TForm1.CreateSelectionFromObject1Click(Sender: TObject);
var
  i: Integer;
  iHObj: Integer;
  iLeft: Integer;
  iTop: Integer;
  iWidth: Integer;
  iHeight: Integer;
  iRight: Integer;
  iBottom: Integer;
begin
  ImageEnVect1.LockUpdate;
  for i := 0 to ImageEnVect1.ObjectsCount - 1 do
  begin
    iHObj := ImageEnVect1.GetObjFromIndex(i);
    if ImageEnVect1.IsSelObject(iHObj) then
    begin
      iLeft := ImageEnVect1.ObjLeft[iHObj];
      iTop := ImageEnVect1.ObjTop[iHObj];
      iWidth := ImageEnVect1.ObjWidth[iHObj];
      iHeight := ImageEnVect1.ObjHeight[iHObj];
      iRight := iLeft + iWidth;
      iBottom := iTop + iHeight;
      ImageEnVect1.UnSelObject(iHObj);
      ImageEnVect1.Select(ImageEnVect1.XBmp2Scr(iLeft), ImageEnVect1.YBmp2Scr(iTop), ImageEnVect1.XBmp2Scr(iRight),
        ImageEnVect1.YBmp2Scr(iBottom), iespReplace);
      ImageEnVect1.UnLockUpdate;
    end;
    Exit;
  end;
end;

After the procedure is executed a selection appears on top of the object. If you move the object you will see both the object and the selection. This code seems to work perfectly even if the image is zoomed.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Mar 19 2017 : 04:28:47
Hi Yogi

Is the selection out by OffsetX x OffsetY?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Mar 18 2017 : 00:47:29
Hello Bill,

Thanks for your inputs. I will try them.

Let us see, what Nigel has to say about this issue...

Actually it should work as expected as we are reading the coordinates from a vector object and trying to create a selection using them.

 
ievMain.Select(MyX, MyY, MyX + MyW, MyY + MyH);


I think this is not necessary as I am reading the coordinates from and existing object. But I will give this a try though.

Once again thanks for your inputs and suggestions.

TIA


Yogi Yang
w2m Posted - Mar 17 2017 : 14:14:38
I can not get it to function well either. I can set the selection, but the coordinates are not correct. I have no idea why. I even tried to convert XY to Bitmap coordinates without success. However, your XY coordinates are incorrect.
MyX := ievMain.ObjLeft[SelectedObjID];
MyY := ievMain.ObjTop[SelectedObjID];
MyW := ievMain.ObjWidth[SelectedObjID];
MyH := ievMain.ObjHeight[SelectedObjID];

ievMain.Select(MyX, MyY, MyX + MyW, MyY + MyH);

I guess I am having a bad day, I should be able to get it to work.
ImageEnVect.LockUpdate and ImageEnVect.UnLockUpdate may be necessary to see the selection. Without that I do not even see a selection.

procedure TForm1.dxBarButton1Click(Sender: TObject);
var
  i: Integer;
  iLeft: integer;
  iTop: integer;
  iX: Integer;
  iY: Integer;
  iX2: Integer;
  iY2: Integer;
  iWidth: Integer;
  iHeight: Integer;
  iHObj: Integer;
begin
  if Assigned(cxPageControl1.ActivePage) then
  begin
    ImageEnVect := TImageEnVect(cxPageControl1.ActivePage.Controls[0]);
    if Assigned(ImageEnVect) then
    begin
      ImageEnVect.LockUpdate;
      for i := 0 to ImageEnVect.ObjectsCount - 1 do
      begin
        iHObj := ImageEnVect.GetObjFromIndex(i);
        if ImageEnVect.IsSelObject(iHObj) then
        begin
          iLeft := ImageEnVect.ObjLeft[iHObj];
          iTop := ImageEnVect.ObjTop[iHObj];
          iX := ImageEnVect.XScr2Bmp(iLeft);
          iY := ImageEnVect.YScr2Bmp(iTop);
          iWidth := ImageEnVect.XScr2Bmp(ImageEnVect.ObjWidth[iHObj]);
          iHeight := ImageEnVect.YScr2Bmp(ImageEnVect.ObjHeight[iHObj]);
          iX2 := iX + iWidth;
          iY2 := iY + iHeight;
          ImageEnVect.UnSelObject(iHObj);
          ImageEnVect.Select(iX, iY, iX2, iY2, iespReplace);
          ImageEnVect.UnLockUpdate;
        end;
        Exit;
      end;
    end;
  end;
end;

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