[CONNECT C++] Locating Elements using DgnElementSetTool

When AutoLocate is enabled, as the cursor is moved over elements in the model, those elements are filtered trough _OnPostLocate() where you can accept or reject the element. Is there a function to override BEFORE _OnPostLocate() gets called - like a "_OnPreLocate()"? I wish to set a flag to indicate that there is either a "valid" element for my tool, or not. I can set the flag for "IsValidElement" in _OnPostLocate(), however, as the user moves the cursor "off" the element (prior to a datapoint) I need to "unset" that flag. I'm currently using _OnModelMotion() to "unset" it but I'm wondering if there is a better way to do that, or a better location.

Parents
  • I wish to set a flag to indicate that there is either a "valid" element for my tool, or not.

    This is why _OnPostLocate exists so I don't understand why you believe you need something other than the return status from this method. If you reject the element, you get to show the user a tool tip explaining why, and it won't get added to the tools agenda if the user goes ahead and does a data point, i.e. a data point shouldn't advance your tools state.

    -B



  • The issue is(was) how to "clear" my flag that indicated a possible valid element. Take this example:

    User moves cursor in view, not locating any element. Flag indicates "not valid". Now user moves over element, _OnPostlocate() fires and returns "true"- flag set to indicate "valid element" (based on some color/style/weight/level criteria). Now user decides to move cursor OFF/AWAY from that element. Once the cursor is moved OFF/AWAY from that candidate element, _OnPostLocate() is not called, so "valid element" flag cannot be reset in _OnPostLocate(). Once the cursor moves over other elements, then _OnPostLocate() can be used to reset the flag, but since that function is not called when just moving the cursor around the view (and not over an element), I was wondering how to "reset" my flag. I currently reset it in _OnModelModtion(). Just wondering if there is a better way to do that...

  • I don't get why you need a "valid element" flag, where do you check it?

    -B



  • The "flag" is essentially the ElementRef of the located (not yet accepted) "valid" element. It's used in the dynamics function: When the ElementRef is NULL, draw my widget at the view's 0 degree angle. When the cursor moves over a "valid" element, the dynamics function reads the ElementRef (if non-zero) and extracts endpoints and tangents, and uses that info to force the widget to the closest end and rotate to the tangent of the endpoint. If the user moves the cursor "off" that element, the saved ElementRef is set back to NULL and the widget is drawn at the view's 0 degree angle once again. The question is the best method to reset that ElementRef back to NULL when it's moved away from a "valid" located element. If I don't reset, then the dynamics continues to draw the widget at the angle of the LAST "valid" located element.

  • You can ask AccuSnap for the current auto-locate hit in your dynamics function. If it returns nullptr, that means you rejected the element(s) under the cursor in your _OnPostLocate method.

    HitPathP hit = AccuSnap::GetInstance().CurrHit();

    -B



    Answer Verified By: Bruce Reeves SRNS 

Reply Children
No Data