[all] Use NVI design pattern for drawVisual#3931
Merged
alxbilger merged 22 commits intoJul 6, 2023
Merged
Conversation
…ode; Signed-off-by: Damien Marchal <damien.marchal@univ-lille1.fr>
alxbilger
reviewed
Jun 13, 2023
Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
…or.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
Contributor
Author
|
@alxbilger thank for the review. |
…al' into pr-use-pattern-nvi-for-drawvisual
Contributor
Author
|
Do everyone agrees on having the conditions I moved up into the NVI VisualModel::drawVisual() and with the one I added into the VisualVisitor ? Eg: void VisualModel::drawVisual(const VisualParams* vparams)
{
// don't draw if specified not to do so in the user interface
if (!vparams->displayFlags().getShowVisualModels())
return;
// don't draw if the component is not in valid state (we can change the condition so Loading/Unknow states are drawn differently)
if( d_componentState.getValue() == sofa::core::objectmodel::ComponentState::Invalid )
return;
// don't draw if this component is specifically configured to be disabled (It is questionnable to have a data for that).
// having a d_enable on Base would be better.
if (!d_draw.getValue())
return;
// RAI to be sure the states changed during the rendering don't leaks
const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle();
doDrawVisual(vparams);
} |
alxbilger
reviewed
Jun 15, 2023
Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
alxbilger
requested changes
Jun 15, 2023
hugtalbot
reviewed
Jun 21, 2023
alxbilger
reviewed
Jun 23, 2023
Contributor
|
[ci-build][with-all-tests] |
hugtalbot
reviewed
Jun 28, 2023
Contributor
Author
|
CI passed... |
…h other components
alxbilger
requested changes
Jun 29, 2023
Contributor
alxbilger
left a comment
There was a problem hiding this comment.
Now that you have renamed d_draw into d_enable, you need to deprecate d_draw in the derived classes instead of removing them.
…stea of "draw" and "visible"
…the component if disable.
alxbilger
requested changes
Jul 4, 2023
hugtalbot
reviewed
Jul 5, 2023
Comment on lines
+44
to
+45
| if( d_componentState.getValue() == sofa::core::objectmodel::ComponentState::Invalid ) | ||
| return; |
Contributor
There was a problem hiding this comment.
It should be :
Suggested change
| if( d_componentState.getValue() == sofa::core::objectmodel::ComponentState::Invalid ) | |
| return; | |
| if( !this->isComponentStateValid() ) | |
| return; |
However, this will invalidate all components which do not support their componentState
Contributor
Author
There was a problem hiding this comment.
So ? It looks like you are making a suggestion of change but saying it will not work the same.
Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
Contributor
|
[ci-build][with-all-tests] |
bakpaul
pushed a commit
to bakpaul/sofa
that referenced
this pull request
Feb 23, 2024
* Implement the drawVisual method using the NVI pattern to factorize access control. * Propagate the change. * FIXUP * [Sofa.Core] Refactor VisualVisitor::processVisualModel to factorize code; Signed-off-by: Damien Marchal <damien.marchal@univ-lille1.fr> * FIXUP * Adds a transitional "virtual" keyword on drawVisual to not break third party plugin. * Update Sofa/framework/Core/src/sofa/core/visual/VisualModel.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> * Update Sofa/framework/Simulation/Core/src/sofa/simulation/VisualVisitor.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> * FIX alignement * Update Sofa/framework/Core/src/sofa/core/visual/VisualModel.h Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> * FIXUP * Add proper deprecation of "visible" flag in OglLabel * FIXUP * Implement top level control of drawWireFrame * [all] Rename d_draw by d_enable VisualModel to make it consistent with other components * Use the newly introduced RemovedData to manage the use of "enable" instea of "draw" and "visible" * Test for d_enable before d_componentState == Valid to avoid updating the component if disable. * Fix OglLable_test to remove the "visible" attribute; * Update Sofa/framework/Config/src/sofa/config.h.in Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> --------- Signed-off-by: Damien Marchal <damien.marchal@univ-lille1.fr> Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
This was referenced Jul 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Actually what we called "delegate" pattern (the one we used to think about to fix the "call-super" anti-pattern) is often refereed on intenret as Non Virtual Interface (a pattern very similar to the Template Method Pattern).
Here is a attempt to see it in use on VisualModel::drawVisual;
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if