I want to write a tool using the C++ MicroStationAPI supplied with the V8i SDK. The tool should accept multiple point elements (e.g. cells, zero-length lines). Once user has chosen, say, four or more point elements, she resets to start a calculation involving that element set.
My tool works for fences and selection sets. What I can't figure out is how to let user select a point element, and then to continue selecting similar elements.
I can see the result of the first select — the tool builds an ElementAgenda containing that element. But then it continues to OnElementModify then restarts itself.
How do I write a pick tool that will build an ElementAgenda of more than one element?
Jon is this thread of any help - "MStnElementSetTool and OnElementModify() repeat processing"?
I just eliminated the NeedPointForDynamics() to get the default "true" returned, and now the OnElementModify() isn't called repeatedly for the members in the fence.
Thanks, but the topic of that thread is fence processing. My question is about a user selecting multiple elements, and the tool building a list (ElementAgenda) of those elements. Once the user has finished picking elements, she signals in some way (e.g. reset) that the list should be processed.
Regards, Jon Summers LA Solutions
I've got a tool (thanks to Brien Bastings) that requires the selection of two elements before processing vis OnElementModify(). The key parts are included below. Not sure about how to do an "open ended" series of picks....
/*---------------------------------------------------------------------------------**//*** @bsimethod+---------------+---------------+---------------+---------------+---------------+------*/virtual bool TwoPickTool::SetupForModify (MstnButtonEventCP ev, bool isDynamics) override { //printf("TwoPickTool::SetupForModify\n"); // Called before each dynamics frame and once for final accept. if (GetElemAgendaP ()->GetCount () < 2) return false; // false if not enough input to process elements...
//printf("TwoPickTool::SetupForModify, Calling DoComputeResult\n"); return DoComputeResult (ev); // use the clicked points to build a lineString }/*---------------------------------------------------------------------------------**//*** @bsimethod+---------------+---------------+---------------+---------------+---------------+------*/virtual bool TwoPickTool::WantAdditionalLocate (MstnButtonEventCP ev) override { if (NULL == ev) return true; // This is a multi-locate tool... // Require a MINIMUM of 2 elements, if control is down select additional elements... return (GetElemAgendaP ()->GetCount () < 2 || ev->IsControlKey ()); }
/*---------------------------------------------------------------------------------**//*** @bsimethod+---------------+---------------+---------------+---------------+---------------+------*/virtual bool TwoPickTool::OnModifierKeyTransition (bool wentDown, int key) override { // Control key state change, may need to enable/disable auto-locate, change cursor, prompts. etc. if (TOGGLESELECT_MODKEY != key) // if not the CTRL key return false; // true to refresh view decorations or update dynamics if (GetElemAgendaP ()->GetCount () < 2) // if < 2 elements picked return false; // true to refresh view decorations or update dynamics SetupForLocate (wentDown ? 1 : 2); // update prompt return true; // true to refresh view decorations or update dynamics }
(Sorry for the lousy formatting...)
Bruce
Answer Verified By: Jon Summers
Thanks Bruce
WantAdditionalLocate() should do the trick, while Jon can react on the reset state instead of counting the number of elements. The OnModifierKeyTransition() method might be helpful too, but only if you want to react on the CTRL/ALT keys.
The multiple overrides are not always easy to identify.
Thanks to all who contributed answers to my questions about a tool inherited from the MicroStationAPI MstnElementSetTool.
The tool I developed is a Convex Hull generator, which I've published on our web site.
I wrote it to demonstrate several things …
How to get it?thanks
mingwen ge said:How to get it?thanks
Get what? The source code? Using search feature on Jon's web, the right URL seems to be this one ;-)
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
mingwen ge said:How to get it?
Jan spotted the broken link, which I've updated in my post above.
Note that the orginal code was for MicroStation V8i; the code in Jan's link is for MicroStation CONNECT.