For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

SelectMgr_ViewerSelector

Shawn Chang's picture
Forums: 

Hi:

Handle(SelectMgr_ViewerSelector) aSelector;
Handle(SelectMgr_EntityOwner) aOwner;
for (aSelector->Init();aSelector->More();aSelector->Next())
{
Standard_Integer initpick = aSelector->NbPicked();
}

I failed. The program just stopped at for.... Does anyone know? Thanks a lot.

Sincerely
shawn

Francois Lauzon's picture

Hello Shawn,

From the code you have here, your aSelector Handle is not initialized so it is pointing to a null pointer.

Francois.

Shawn Chang's picture

Hi:
Thanks for your response. I have added like the following before "for" loop.
aSelector->InitSelect(x,y);
I still failed. I added those codes in CXXXXView3d::InputEvent(....).
If InitSelect(x,y) is not initialized. How do I do?

Sincerely shawn

Francois Lauzon's picture

Hi Shawn, have you tested your handle to see if it's null?

if (aSelector.IsNull())

cout

??

That looks like it might be that.

Francois.

Shawn Chang's picture

Hi Francois:
There is no IsNull() function existing in SelectMgr_ViewerSelector. And, It seems I can't use SelectMgr_ViewerSelector class. I guess it should be SelectMgr_ViewerSelector3d. I have used it. The building and execution did work; but, I got zero object selected. I think it may be view problem. Have you been used SelectMgr_ViewerSelector3d or SelectMgr_ViewerSelector2d? if yes. Does it work for you? thanks a lot.

Sincerely shawn

Sergey RUIN's picture

Hi shawn,

Did you use SelectMgr_SelectionManager to load selectable objects?

And why use SelectMgr_ViewerSelector directly? AIS_InteractiveContext provides a lot high level API methods to manage the selection and higlighting.

Best Regards

Sergey

Shawn Chang's picture

Hi:
If there are several duplicated or very closing objects. I have to change view to hilight one of them. I am trying to find a way that I can detect objects amount(numbers) when I click mouse.
I read online_document. In SelectMgr_ViewerSelector, it mention about "Two tools are available to find and select objects found at a given position in the view. If you want to select the owners of all the objects detected at point x,y," That is the reason I don't use AIS. Can you help me? Thanks a lot.

Sincerely Shawn

Sergey RUIN's picture

Hi,

If I were you I'd use AIS. On mouse click I'd get StdSelect_ViewerSelector3d filled with drawn objects in the current selection mode through method MainSelector() of AIS_InteractiveContext, it's ready for iteration in order to find all Objects that can be considered as selected for the current mouse coordinates.

Regards

Sergey

Shawn Chang's picture

Hi Sergey: It is great. I can get the amount of objects. I have one more question. How can I make linking with AIS_InteractiveContext? Because I need switch to hilight one of those objects. Thanks a lot.

Sincerely shawn

Sergey RUIN's picture

Hello Shawn,

From EntityOwner you can get SelectableObject using method Selectable. This will be AIS_InteractiveObject (look at it inheritance). So you may use AIS_InteractiveContext method Hilight to hilight chosen object.

Regards

Sergey

Shawn Chang's picture

Hi Sergey:
I have tried Hilight() method. But, I get one error message:
error C2664: 'Hilight' : cannot convert parameter 1 from 'class Handle_SelectMgr_SelectableObject' to 'const class Handle_AIS_InteractiveObject &'

Reason: cannot convert from 'class Handle_SelectMgr_SelectableObject' to 'const class Handle_AIS_InteractiveObject'

No constructor could take the source type, or constructor overload resolution was ambiguous Error executing cl.exe.
Thanks a lot.

Sincerely shawn

Shawn Chang's picture

Dear Sergey:
Just ignore my question. I get it. But, I still have problem in switching.
First, Does it have priority for objects? I try to use Standard_Integer priority = TheObject->SelectionPriority(); I always get -1;
Second, I try to use Hilight() and Unhilight(). The following is my partial code:
Handle(StdSelect_ViewerSelector3d) aSelect = ...
aSelect = myAISContext->MainSelector();
for ....
{
Handle(AIS_InteractiveObject) TheObject = ....
...
if (myAISContext->IsHilighted(TheObject))
{
myAISContext->Unhilight(TheObject);
nohilight = True;
}
else
if (nohilight)
myAISContext->Hilight(TheObject);
...
aSelect->Next();
}
The View did switch to hilight another object. I also try to set color to those objects. I try to use myAISContext->UpdateCurrentViewer(). It seems only update first one I selected object; the others doesn't be changed.
My ideal is if it exists priority for objects that I select. I hope that I can according to priority objects know which object is current hilighted. Then, set Hilight(next priority object).
Thanks a lot.

Sincerely Shawn

Shawn Chang's picture

Dear Sergey:
My problems are almost done. But, I find one question. If I use shiftselect() to select objects. How can I unhilight those objects that are used Hilight() to hilight object? Thanks very much.

Sincerely shawn

Sergey RUIN's picture

Hello Shawn,

When you use ShiftSelect, Hilight/Unhilight is done by context, you don't have to call Hilight().

Regards

Sergey

Shawn Chang's picture

Dear Sergey:
If I use select() or shiftselect() to select objects. When I click mouse on any place one screen. The selected objects will be unhilighted by context according to you said. But, if one of the selected object are behind the object. I couldn't use that way to unhilight it. That me give you steps I was done:
1. use select() to select one object.
2. use MainSelector() to get how many objects.
3. Unhilight() the first object and then, Hilight() to another object. UpdateCurrentViewer().
4. shiftselect() another object.
5. repeat 3 and 4 steps.
6. select() another object or click mouse on other place without selecting object on the screen.

For 6 step, it should no object that are hilighted on the screen. Am I right? But, I couldn't cancel selected objects on the screen. When I just move mouse through selected objects or select the range that cover whole selected objects. Those objects will automatically unhilight. I don't know why? Can you help me? Thanks a lot.

Sincerely Shawn

Sergey's picture

Hi Shawn,

Instead of methods Hilight/Unhilight use AddOrRemoveCurrentObject as it modifies selection status of InteractiveObject

Best Regards

Sergey

Shawn Chang's picture

Dear Sergey: Great! Thank you very much.

Sincerely shawn

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.