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
 ImageEnVect Region selection
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

rswyman@docuxplorer.com

USA
156 Posts

Posted - Sep 07 2018 :  20:56:08  Show Profile  Reply
Hi All,

How can I set a selected region and then delete all object within that region?

Thanks
Ron

xequte

39053 Posts

Posted - Sep 07 2018 :  22:47:47  Show Profile  Reply
Hi Ron

If EnableRangeObjectsSelection is enabled, then you can drag select objects. Iterate through the SelObjects array and remove them.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

rswyman@docuxplorer.com

USA
156 Posts

Posted - Sep 08 2018 :  08:18:35  Show Profile  Reply
Hi Nigel,

I tried this but SelObjectsCount is always zero.


fImageEnVect.EnableRangeObjectsSelection := true;
fImageEnVect.Select(x, y, width, height);
for ii := 0 to fImageEnVect.SelObjectsCount -1 do begin
  hObj := fImageEnVect.SelObjects[ii];
  fImageEnVect.RemoveObject(hObj);
end;
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 08 2018 :  11:36:07  Show Profile  Reply
Set fImageEnVect.EnableRangeObjectsSelection to true before making a selection with the mouse. After you select objects with the mouse then call your procedure:
for ii := 0 to fImageEnVect.SelObjectsCount -1 do begin
  hObj := fImageEnVect.SelObjects[ii];
  fImageEnVect.RemoveObject(hObj);
end;

This works as expected here, meaning the selected objects are removed.

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

rswyman@docuxplorer.com

USA
156 Posts

Posted - Sep 08 2018 :  13:16:23  Show Profile  Reply
Thanks Bill, but this process is being executed without the mouse / user interaction but programmatically. So the question still stands, how do I select a group of objects via (x, y, width and height) / region?

Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 08 2018 :  14:13:23  Show Profile  Reply
fImageEnVect.Select(x, y, width, height);

I think this just makes a rectangular selection rubberband and probably does not operate like selection of objects with the mouse. Unfortunately I have never tried to select objects within rectangular coordinates but you might want to search the archives to see if this is described in some post. I do not see a method to select all the objects inside of a TRect and I do not know if such a method even exists.

Try taking a look at Group/UnGroup objects in the help file. This may help but I am not sure about it.

If not then Nigel may have some ideas on how to select objects inside of a TRect or maybe even adding a method to do so. For now I guess I can not be of assistance to achieve this programmatically.

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

rswyman@docuxplorer.com

USA
156 Posts

Posted - Sep 08 2018 :  15:09:43  Show Profile  Reply
Thanks for the effort Bill!
Go to Top of Page

xequte

39053 Posts

Posted - Sep 09 2018 :  00:55:59  Show Profile  Reply
Hi

There is no automated way to programmatically do this, but you can just iterate through all of your objects, getting there GetObjRect, and compare to your selection rect using IntersectRect. If they overlap then select the object.

https://www.imageen.com/help/TImageEnVect.GetObjRect.html
http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.Types.IntersectRect


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

rswyman@docuxplorer.com

USA
156 Posts

Posted - Sep 09 2018 :  08:22:48  Show Profile  Reply
Here is a sample of the final result.


aRect1.Left := x;
aRect1.Top := y;
aRect1.Right := x+width;
aRect1.Bottom := y+Height;
for ii := (fImageEnVect.ObjectsCount -1) downto 0 do begin
   hobj := fImageEnVect.GetObjFromIndex(ii);
   fImageEnVect.GetObjRect(hobj, aRect2);
   IntersectRect(resultRect,aRect1, aRect2);
   if (resultRect.Left <> 0) and (resultRect.Top <> 0) and
      (resultRect.Bottom <> 0) and (resultRect.Right <> 0) then begin
     fImageEnVect.RemoveObject(ii);
    end;
end;


Thank You.
Go to Top of Page

xequte

39053 Posts

Posted - Sep 09 2018 :  15:25:56  Show Profile  Reply
Nice Ronald,

Note that you can also just use the boolean result of IntersectRect:

If IntersectRect(resultRect,aRect1, aRect2) then...

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

rswyman@docuxplorer.com

USA
156 Posts

Posted - Sep 09 2018 :  16:16:59  Show Profile  Reply
ok, thx!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: