[Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
openBrain
Posts: 4867
Joined: Fri Nov 09, 2018 5:38 pm

Re: Sketcher - Auto Remove Redundants - disabling - Feature request

Postby openBrain » Sun May 31, 2020 8:15 pm

chrisb wrote:
Sun May 31, 2020 8:08 pm
HoWil wrote:
Sun May 31, 2020 6:57 pm
[*]The solver-messages have to be updated after clicking the 'Reference' check-box.
they do it here.
I confirm the solver message isn't updated here till I validate the dialog. Will have a look.
openBrain
Posts: 4867
Joined: Fri Nov 09, 2018 5:38 pm

Re: Sketcher - Auto Remove Redundants - disabling - Feature request

Postby openBrain » Sun May 31, 2020 8:30 pm

HoWil wrote:
Sun May 31, 2020 6:57 pm
[*]The solver-messages have to be updated after clicking the 'Reference' check-box.
PR submitted
chrisb
Posts: 28961
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Postby chrisb » Sun May 31, 2020 9:36 pm

I see what you mean; I had in these cases used a recompute, but that performs already an update on the object.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
abdullah
Posts: 3578
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher - Auto Remove Redundants - disabling - Feature request

Postby abdullah » Tue Jun 02, 2020 5:37 pm

openBrain wrote:
Sun May 31, 2020 8:30 pm
HoWil wrote:
Sun May 31, 2020 6:57 pm
[*]The solver-messages have to be updated after clicking the 'Reference' check-box.
PR submitted
Hi there!

I have reviewed the PR.

As far as I am trying to reproduce the issue, it appears that it only happens if the AutoUpdate checkbox is checked.

The reason is that if the AutoUpdate checkbox is not checked, the SketchObject::setDriving function already executes a solve() operation:

Code: Select all

int SketchObject::setDriving(int ConstrId, bool isdriving)
{
    const std::vector<Constraint *> &vals = this->Constraints.getValues();

    int ret = testDrivingChange(ConstrId, isdriving);

    if(ret < 0)
        return ret;

    // copy the list
    std::vector<Constraint *> newVals(vals);
    // clone the changed Constraint
    Constraint *constNew = vals[ConstrId]->clone();
    constNew->isDriving = isdriving;
    newVals[ConstrId] = constNew;
    this->Constraints.setValues(newVals);
    if (!isdriving)
        setExpression(Constraints.createPath(ConstrId), boost::shared_ptr<App::Expression>());
    delete constNew;

    if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
        solve();

    return 0;
}
The PR as it stands executes an unnecessary solve when the AutoUpdate checkbox is unchecked, and a necessary solve() when the checkbox is checked. Please consider the following option:

Code: Select all

void EditDatumDialog::drivingToggled(bool state)
{
    if (state) {
        ui_ins_datum->labelEdit->setToLastUsedValue();
    }
    sketch->setDriving(ConstrNbr, !state);
    
    if(!sketch->noRecomputes)
    	sketch->solve();
}
openBrain
Posts: 4867
Joined: Fri Nov 09, 2018 5:38 pm

Re: Sketcher - Auto Remove Redundants - disabling - Feature request

Postby openBrain » Tue Jun 02, 2020 6:38 pm

abdullah wrote:
Tue Jun 02, 2020 5:37 pm
The PR as it stands executes an unnecessary solve when the AutoUpdate checkbox is unchecked, and a necessary solve() when the checkbox is checked. Please consider the following option:
Totally agree. I have to admit that it was some kind of a lazy PR where I just fixed the problem the quick way. :)
Should I update the PR or would you just update the code and thus I'll kill the PR ?
openBrain
Posts: 4867
Joined: Fri Nov 09, 2018 5:38 pm

Re: [Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Postby openBrain » Tue Jun 02, 2020 7:59 pm

PR updated
chrisb
Posts: 28961
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Postby chrisb » Tue Jun 02, 2020 10:00 pm

I never have autoupdate enabled, nevertheless it didn't update the solver messages. I will see what this pull request will bring.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
openBrain
Posts: 4867
Joined: Fri Nov 09, 2018 5:38 pm

Re: [Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Postby openBrain » Tue Jun 02, 2020 10:02 pm

chrisb wrote:
Tue Jun 02, 2020 10:00 pm
I never have autoupdate enabled, nevertheless it didn't update the solver messages. I will see what this pull request will bring.
Just the solver message to be updated in the background when toggling on/off the "Reference" checkbox in a dimension dialog. ;)
chrisb
Posts: 28961
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Postby chrisb » Tue Jun 02, 2020 10:42 pm

I was on the wrong track again. I don't know if this case is handled by your update:
Take this sketch:
Snip macro screenshot-925600.png
Snip macro screenshot-925600.png (3.06 KiB) Viewed 174 times
Adding a 20mm horizontal constraint to the selected point creates a message saying that this is not allowed. After that the constraint is deleted, but the solver's error messages stays. A recompute fixes it, but that will not always be required.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
abdullah
Posts: 3578
Joined: Sun May 04, 2014 3:16 pm

Re: [Feature request #4067] Sketcher - Auto Remove Redundants - disabling - Feature request

Postby abdullah » Wed Jun 03, 2020 5:11 pm

chrisb wrote:
Tue Jun 02, 2020 10:42 pm
I was on the wrong track again. I don't know if this case is handled by your update:
Take this sketch:
Snip macro screenshot-925600.png
Adding a 20mm horizontal constraint to the selected point creates a message saying that this is not allowed. After that the constraint is deleted, but the solver's error messages stays. A recompute fixes it, but that will not always be required.
git commit 21cbceba5ae0f5690e1863c89d94085ac99e28ad