Repository: FreeCAD/FreeCAD
File: src/Mod/Sketcher/Gui/ViewProviderSketch.cpp (C++)

Code before:
    layers.emplace_back();                // Normal layer
    layers.emplace_back(0x7E7E);          // Discontinuous line layer
    layers.emplace_back(0xFFFF, 3, false);// Hidden layer

    VisualLayerList.setValues(std::move(layers));

    // Default values that will be overridden by preferences (if existing)
    PointSize.setValue(4);

    // visibility automation and other parameters: update parameter and property defaults to follow
    // preferences
    pObserver->initParameters();
    pObserver->subscribeToParameters();

    sPixmap = "Sketcher_Sketch";

    // rubberband selection
    rubberband = std::make_unique<Gui::Rubberband>();

    cameraSensor.setFunction(&ViewProviderSketch::camSensCB);

    updateColorPropertiesVisibility();

    pcSketchFacesToggle->addChild(pcSketchFaces);

    blockContextMenu = false;
}

ViewProviderSketch::~ViewProviderSketch()
{
    connectionToolWidget.disconnect();
}

void ViewProviderSketch::slotUndoDocument(const Gui::Document& /*doc*/)
{
    // Note 1: this slot is only operative during edit mode (see signal connection/disconnection)
    // Note 2: ViewProviderSketch::UpdateData does not generate updates during undo/redo
    //         transactions as mid-transaction data may not be in a valid state (e.g. constraints
    //         may reference invalid geometry). However undo/redo notify SketchObject after the
    //         undo/redo and before this slot is called.
    // Note 3: Note that recomputes are no longer inhibited during the call to this slot.
    forceUpdateData();
}

void ViewProviderSketch::slotRedoDocument(const Gui::Document& /*doc*/)
{
    // Note 1: this slot is only operative during edit mode (see signal connection/disconnection)
    // Note 2: ViewProviderSketch::UpdateData does not generate updates during undo/redo
    //         transactions as mid-transaction data may not be in a valid state (e.g. constraints
    //         may reference invalid geometry). However undo/redo notify SketchObject after the
    //         undo/redo and before this slot is called.

Review comment (suggestion):
This should be initialized as part of the constructor initializer list -- I can't make it as a suggestion in GitHub since it's really two changes (removing these lines and adding it above). I will do it manually during the merge.

Code after:
        "If true, this sketch will be colored based on user preferences. Turn it off to set color explicitly.");

    // TODO: This is part of a naive minimal implementation to substitute rendering order
    // Three equally visual layers to enable/disable layer.
    std::vector<VisualLayer> layers;
    layers.emplace_back();                // Normal layer
    layers.emplace_back(0x7E7E);          // Discontinuous line layer
    layers.emplace_back(0xFFFF, 3, false);// Hidden layer

    VisualLayerList.setValues(std::move(layers));

    // Default values that will be overridden by preferences (if existing)
    PointSize.setValue(4);

    // visibility automation and other parameters: update parameter and property defaults to follow
    // preferences
    pObserver->initParameters();
    pObserver->subscribeToParameters();

    sPixmap = "Sketcher_Sketch";

    // rubberband selection
    rubberband = std::make_unique<Gui::Rubberband>();

    cameraSensor.setFunction(&ViewProviderSketch::camSensCB);

    updateColorPropertiesVisibility();

    pcSketchFacesToggle->addChild(pcSketchFaces);
}

ViewProviderSketch::~ViewProviderSketch()
{
    connectionToolWidget.disconnect();
}

void ViewProviderSketch::slotUndoDocument(const Gui::Document& /*doc*/)
{
    // Note 1: this slot is only operative during edit mode (see signal connection/disconnection)
    // Note 2: ViewProviderSketch::UpdateData does not generate updates during undo/redo
    //         transactions as mid-transaction data may not be in a valid state (e.g. constraints
    //         may reference invalid geometry). However undo/redo notify SketchObject after the
    //         undo/redo and before this slot is called.
    // Note 3: Note that recomputes are no longer inhibited during the call to this slot.
    forceUpdateData();
}

void ViewProviderSketch::slotRedoDocument(const Gui::Document& /*doc*/)
{
    // Note 1: this slot is only operative during edit mode (see signal connection/disconnection)
    // Note 2: ViewProviderSketch::UpdateData does not generate updates during undo/redo