Selection

Technical discussions
Post Reply
Peter_R341
Posts: 3
Joined: Sun Jul 28, 2013 8:23 am

Selection

Post by Peter_R341 »

Hi. Is there a way to manage the selection outside the component, in order to
make multiselect possible in View mode? I do not see this in help

Thanks
Peter

Andy_r_723
Posts: 6
Joined: Fri Jul 26, 2013 9:44 am

Re: Selection

Post by Andy_r_723 »

Hi Peter
For verticies and simplexes you can do it using Advanced > Edit > Select in the right-click menu. There is a notification. Do not remember right now see the help. I could not find how to do it for objects either. I managed to get it working by maintaining a list in my app and using multiple clicks.

There is CurrentObjectChanged event in the control on click on an object. It works only I believe if you switch to modify mode with IViewModal.SetViewMode(2)

Another way could be using something like object picking from the Pick sample, but still probably some coding to be done

Cheers
Andy

Peter_R341
Posts: 3
Joined: Sun Jul 28, 2013 8:23 am

Re: Selection

Post by Peter_R341 »

Thank you, Andy!

nickz
Site Admin
Posts: 206
Joined: Fri Jul 26, 2013 3:58 am

Re: Selection

Post by nickz »

Hi

That was a good point. Two more ways to handle multiple selection:

Quick: The objects can be selected in Model explorer and there is an event which notifies about what was selected. See “Selection Notification” at http://www.dynoinsight.com/Help/Component/Explorer.aspx

Good: To select several objects with a rectangle (probably after zooming out):

a) Draw a rectangle yourself. The easiest way to do it is inside a ClientDraw handler. Search for *ClientDraw* in samples there are plenty of examples. This way your will not need to add any objects.

b) Implement MouseDown/Up/Move event handlers (See “Events” at http://www.dynoinsight.com/Help/KernCADProps.aspx ) to process location and size of the rectangle

c) Inside MouseMove handler construct the rectangle. See details below.

d) Loop through all objects in the model (details below) and calculate the minimal sphere containing it using location of the local frame as centre of the sphere and dimensions of half of diagonal of the bounding box obtained via IMetrics.GetDimentions()

e) This sphere projects to the rectangle as a circle of the same radius. So you consider object selected if the circle is fully inside the rectangle, which is easy to check.

f) To calculate the projection in e) you need only projection of the centre obtain global frame expressed in frame aligned to the screen: KernelCAD > GetView() > IView > IFrame > IFrameEx. (http://www.dynoinsight.com/Help/ModelVi ... lobalFrame ) Use IFrameEx.ToGlobal() to convert the centre of the bounding sphere to eye frame. Take its first two coordinates. This will be the centre of the projected circle.

Each step is quite simple. The mouse handling events have screen (pixels) coordinates. To convert them to 3D coordinates for the rectangle mentioned in c) use ILookEx.ScreenTo3D() obtained via: KernelCAD > GetView() > IView > ILookEx

To loop through all objects independently of child/parent hierarchy obtain array of them via IModel > IPropertyArray. IArray iArrFlat = (IArray)GetProperty("FlatObjectArray");

I hope we will be able to add this in the nearest updates

Regards
Nick

nickz
Site Admin
Posts: 206
Joined: Fri Jul 26, 2013 3:58 am

Re: Selection

Post by nickz »

Hello everyone

We just have added in update 4.1.3525 selection of multiple objects: In contex menu Advanced>Edit>Select there is new Objects option. It allows selection of objects with a rectangle. The objects can be deleted right away using Delete key or application can receive list of selected objects as ISection items and do any custom processing.

This is done via KernelCAD event. The notification is not enabled by default. Use
IKCContext iContext = (IKCContext)m_iView;
iContext.SetBoolParam((int)E3DBoolParams.e3DBoolParamWantSelectEvent, true); (C#)
to enable it.

See OnKernelCadEvent handler in C# and C++ Pick samples for an example of accessing the list. Help topic: http://www.dynoinsight.com/Help/Compone ... Event.aspx

When the selection is cleared by end user KernelCAD raises same event with an empty list

Regards
Nick

Post Reply