[Solved] How to remove an auxiliary shape from the preview?

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

[Solved] How to remove an auxiliary shape from the preview?

Post by CVH » Sat Feb 08, 2025 1:04 pm

The case:

In the drawing an incomplete ellipse arc is indicated as first stage of an interactive tool.
Because incomplete and an active option in the Option Toolbar the full ellipse is added as auxiliary shape in .prototype.getAuxPreview
Just to give the user an idea of how the ellipse would look like as full ellipse.

Cursor position changes and this.updatePreview(); is called on regular base. By default the clear flag is false.

When we clear the option on the Option Toolbar the full ellipse auxiliary shape is not required.
:arrow: The problem is that the auxiliary full ellipse is not removed ... :oops:


On changing the option by its shortcut to cleared:
First thing that happens is updating the internal flag according the option checkbox: false.
As last we call this.updatePreview(true);
Explanation:
  • Parameters: clear True to clear the preview first.
    This is necessary if the preview is updated not as a result of a mouse move event,
    e.g. when changing action parameters in the options toolbar.
EAction.prototype.updatePreview(true) clear the preview: di.clearPreview();
-> This effectively removes former preview shapes, solutions only valid for a full ellipse.
Calls this.getOperation(true); in preview mode and adds the returned operation: di.previewOperation(op);
-> Adding only the solutions that are valid for the ellipse arc.
Calls this.getAuxPreview(); for auxiliary shapes.
-> Depending on the flag and if the shape was an ellipse arc this generates the full ellipse auxiliary shape.
:arrow: The flag was cleared ... No full ellipse RShape is created and such is no longer added as auxiliary shape.
As last it calls this.getHighlightedEntities(); what is empty at this stage and then di.repaintViews();

:!: Even not included the former full ellipse remains displayed as auxiliary shape.
By no means I can remove it once it was added before.

From a previous use in cleared state, activating the options works as intended.
Clearing it has no effect.
I can throttle back with an escape event and re-indicated the ellipse arc entity.
Starting over new, the auxiliary shapes are correct.
Until I set the option an clear it again ...

What must be done to regenerate the correct preview including only the intended and new auxiliary shapes?

Regards,
CVH
Last edited by CVH on Mon Feb 10, 2025 6:11 am, edited 1 time in total.

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: How to remove an auxiliary shape from the preview?

Post by CVH » Sun Feb 09, 2025 8:57 am

A visual example then ...

Made .prototype.getAuxPreview() reporting that the full ellipse auxiliary shape was included or not.
Just cleared the option flag and the shape is no longer included as auxiliary shape.

:arrow: It is still showing, even after 3 extra updates on mouse events.
How to remove this auxiliary shape?

EllipseNormals_AUX_Issue.png
EllipseNormals_AUX_Issue.png (24.03 KiB) Viewed 51924 times

For the record:
The 3 blue lines are normal to the ellipse arc.
They form a right angle with the ellipse at a perpendicular point.
By definition they are also tangent to the ellipse evolute.

For the indicated point there are thus 3 equally valid perpendicular points ... Instead of None

Inside the evolute a fourth solution exist for a full ellipse ... With the option active.
Outside the evolute there are typically 2 solutions for a full ellipse.
Solutions for a full ellipse are filtered in the case of a limited ellipse arc.
The nearest is thus no solution for this ellipse arc, the other 3 end on the arc shape.

Regards,
CVH

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: [Solved] How to remove an auxiliary shape from the preview?

Post by CVH » Mon Feb 10, 2025 6:45 am

Kinda solved but the what and why eludes me.

It probably has to do with how the array of shapes was constructed.

Inspecting this with comparing the arrays reveals no differences.
None of the variants failed in EAction.prototype.updatePreview .. di.addAuxShapeToPreview(...)
I can iterate through the arrays just the same as updatePreview does and the tested lists of shapes seem to be correct.

I rearranged the code for the auxiliary shapes a bit and miraculously it behaved as intended. :o
Streamlined that using steady shapes and it failed again.
  • In detail:
    The evolute and axes of a selected ellipse remain the same and don't have to be regenerated each mouse event.
    But as stored elements they failed again.
It worked out before so ...
After a few trials with how the shapes were collected in an array, it behaved back as intended.

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”