Author Topic: Selection by 'Crossing Window'  (Read 15369 times)

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Selection by 'Crossing Window'
« on: May 19, 2016, 07:45:32 am »
Following on from this thread; http://www.cambam.co.uk/forum/index.php?topic=5714.msg45464#msg45464

Normal selection:

left click the mouse and drag a box around the required items. any items fully enclosed by the drag box will be selected.

'Crossing Window' selection:

While holding the 'Ctrl' key, left click the mouse and drag a box over the required items. any items touched by the drag box or fully enclosed by the drag box will be selected.

Only objects on visible layers will be selected

If the view is rotated then it may not work as expected.

Version 1.0 attached

1. Download the zip file
2. extract the zip file to get 'CrossingWindow.dll'
3. move the dll file into CamBam's 'Plugins' folder
4. restart CamBam

Edit:
version 1.1 attached.

Edit:
version 1.2 attached.

Edit:
version 1.3 attached.

Now you press and hold the 'X' key then left click and drag a marquee across the objects to select.

To deselect an object, use the same method as with the normal selection marquee, i.e. ctrl + left click the object

« Last Edit: May 20, 2016, 14:21:46 pm by EddyCurrent »
Filmed in Supermarionation

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8969
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #1 on: May 19, 2016, 09:18:48 am »
DAWM, Man!  You're a .dll-writin' foo, aren't you?

Eddy, thanks!  I somehow had expected this to shuffle forward to Andy. 

LLoyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #2 on: May 19, 2016, 12:49:56 pm »
. . .
Eddy, thanks!  I somehow had expected this to shuffle forward to Andy.  

LLoyd

I probably have more time to fiddle about with these things than Andy does but I'm sure my efforts are far more verbose than his would be.
Also I already had some of the required code, in rough form, from other projects.
« Last Edit: May 19, 2016, 12:54:38 pm by EddyCurrent »
Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Selection by 'Crossing Window'
« Reply #3 on: May 19, 2016, 16:14:44 pm »
Hello,

Nice job Eddy  ;D

++
David

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Selection by 'Crossing Window'
« Reply #4 on: May 19, 2016, 16:26:55 pm »
Hello,

A small video that show a bug ; example file attached.

http://screencast.com/t/czPkzr3Ax

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #5 on: May 19, 2016, 18:50:13 pm »
David,

It's not a bug as such.  :D

The plugin works by creating two rectangles, the first one is the drag box marquee rectangle and the second is created from each object's 'extents'. If those rectangles overlap then the object is selected.

In your example, imagine the extents rectangle of the, 'polyline that should not be selected', and it can be seen that it would overlap your marquee rectangles.

The work around, if it's possible, would be to find a position for the marquee that did not overlap all the extents rectangles.     

This is the piece of code;

 if (dragBox.Overlaps(entityBox, 0.0)) 

The 0.0 is a tolerance value.
Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Selection by 'Crossing Window'
« Reply #6 on: May 19, 2016, 19:11:19 pm »
Hello,

Ah ok, I understand ;)

But I need to do more experiments because now, it wont works at all, even after I restart CB ... strange  ???

Also I had some strange result when using ctrl + clic to deselect something ... and I can test more, because it is at this time that the plugin stop working .... more experiments later ;)

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #7 on: May 19, 2016, 19:20:08 pm »
David,

Strangely it won't work with your file or another file I loaded  ??? but it does work if I create a new file and use it before saving.

It might be something to do with hooking into the mouse events.
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #8 on: May 19, 2016, 19:38:48 pm »
No, a stupid error on my part  ::)

I always use these lines;

 public static ICADView view = CamBamUI.MainUI.ActiveView;
 public static CADFile myfile = view.CADFile;

but what I forgot to do was assign any new cadfile to them, so they were still looking at the previous cadfile.

I even helped Lloyd with the same thing not too long ago; http://www.cambam.co.uk/forum/index.php?topic=5586.msg44681#msg44681
too much excitement and rush to get it finished I think.  :D

Update added v1.1

Also regarding your video, this crossing window would work;
« Last Edit: May 19, 2016, 20:12:48 pm by EddyCurrent »
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #9 on: May 20, 2016, 08:25:51 am »

Also I had some strange result when using ctrl + clic to deselect something ... and I can test more, because it is at this time that the plugin stop working .... more experiments later ;)

++
David

David,

Thank you for your excellent testing and feedback, new version 1.2 attached and this has fixed those issues.
Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Selection by 'Crossing Window'
« Reply #10 on: May 20, 2016, 13:46:43 pm »
Hello,

Better  :D

Now, try that:

create 3 shapes and select them

- use the ctrl + rubber box to deselect one object ... the result is that the object that must be deselected remain selected and all other objects become unselected.

- in the same idea, if you try to deselect an object by ctrl + clic, you must take care that the mouse don't move at all. If it move, even a bit, you obtain the same result as above.

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #11 on: May 20, 2016, 14:03:36 pm »
Hello,

- use the ctrl + rubber box to deselect one object ... the result is that the object that must be deselected remain selected and all other objects become unselected.

++
David

No, to deselect an object you would not use crtl + rubber band, you would use ctrl + left click the object

I think I created a problem for myself by using the Ctrl key for this plugin, maybe I'll try a different key.
« Last Edit: May 20, 2016, 14:24:19 pm by EddyCurrent »
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #12 on: May 20, 2016, 14:22:49 pm »
Version 1.3 attached to first post.

Changed the key from ctrl to X

Now you press and hold the 'X' key then left click and drag a marquee across the objects to select.

Everything else appears consistent with the normal selection marquee method.
Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Selection by 'Crossing Window'
« Reply #13 on: May 20, 2016, 14:43:03 pm »
Hello,

Quote
I think I created a problem for myself by using the Ctrl key for this plugin, maybe I'll try a different key.

Yes, sometimes it creates interference with the normal use of ctrl

I don't know if it is possible to do with CB, but in AutoCAD, when you draw the selection box from left to right only fully contained objects are selected and if you draw the box from right to left you get the selection of partially contained objects.

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Selection by 'Crossing Window'
« Reply #14 on: May 20, 2016, 14:52:34 pm »
Yes it would be possible I think.

If  X start position of marquee is <  X end position then normal selection
If  X start position of marquee is >  X end position then crossing window selection

But I didn't want to use that idea because sometimes it's better to drag the marquee a different way without automatically invoking one or the other selection methods.
« Last Edit: May 20, 2016, 14:59:22 pm by EddyCurrent »
Filmed in Supermarionation