ViewProvider: 3 fixed visual layers implementation

==================================================

Naive 3 layer implementation to enable the removal of current rendering order.

Layers is conceived to be much more powerful, when combining User Layers, which
work at structural level (conceptually grouping of geometry by the user) and visual
layers (which control the representation of parts of User layers).

However, that implementation will take quite some time and effort to get it right.

This commit enables 3 layers:
1. Normal layer (legacy one)
2. Discontinuous layer (experimental layer which discontinuous edges)
3. Hidden layer (a normal layer which is hidden)

One geometry can be added to one and only one visual layer at a given time.

So this enables to hide geometry (by assigning it to the hidden layer), which is
useful for selection when lines are overlapping, acting as a work-around for the
rendering order. It also allows to rework the rendering order (without the user
being affected), which is also necessary for the final visual layers implementation.
This commit is contained in:
Abdullah Tahiri
2023-02-28 16:17:54 +01:00
committed by abdullahtahiriyo
parent dbdd04e05b
commit d1be41efe0

View File

@@ -323,6 +323,14 @@ ViewProviderSketch::ViewProviderSketch()
ADD_PROPERTY_TYPE(EditingWorkbench,("SketcherWorkbench"),"Visibility automation",(App::PropertyType)(App::Prop_ReadOnly),"Name of the workbench to activate when editing this sketch.");
ADD_PROPERTY_TYPE(VisualLayerList, (VisualLayer()), "Layers", (App::PropertyType)(App::Prop_ReadOnly), "Information about the Visual Representation of layers");
// 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);
@@ -2619,17 +2627,6 @@ void ViewProviderSketch::scaleBSplinePoleCirclesAndUpdateSolverAndSketchObjectGe
tempGeo[GeoId] = GeometryFacade::getFacade(tmpcircle, true); // this is the circle that will be drawn, with the updated vradius, the facade takes ownership and will deallocate.
}
// save scale factor for any prospective dragging operation
// 1. Solver must be updated, in case a dragging operation starts
// 2. if temp geometry is being used (with memory allocation), then the copy we have here must be updated. If
// no temp geometry is being used, then the normal geometry must be updated.
{// make solver be ready for a dragging operation
auto vpext = std::make_unique<SketcherGui::ViewProviderSketchGeometryExtension>();
vpext->setRepresentationFactor(scalefactor);
getSketchObject()->updateSolverExtension(GeoId, std::move(vpext));
}
if(!circle->hasExtension(SketcherGui::ViewProviderSketchGeometryExtension::getClassTypeId()))
{
// It is ok to add this kind of extension to a const geometry because:
@@ -2643,6 +2640,16 @@ void ViewProviderSketch::scaleBSplinePoleCirclesAndUpdateSolverAndSketchObjectGe
circle->getExtension(SketcherGui::ViewProviderSketchGeometryExtension::getClassTypeId()).lock()));
vpext->setRepresentationFactor(scalefactor);
// save scale factor for any prospective dragging operation
// 1. Solver must be updated, in case a dragging operation starts
// 2. if temp geometry is being used (with memory allocation), then the copy we have here must be updated. If
// no temp geometry is being used, then the normal geometry must be updated.
// make solver be ready for a dragging operation
auto solverext = vpext->copy();
getSketchObject()->updateSolverExtension(GeoId, std::move(solverext));
}
break;
}