Core: SoShapeScale fix weird scaling on viewport resize. See https://github.com/FreeCAD/FreeCAD/issues/18382#issuecomment-2527623758
This commit is contained in:
@@ -85,24 +85,26 @@ SoShapeScale::initClass()
|
||||
void
|
||||
SoShapeScale::GLRender(SoGLRenderAction * action)
|
||||
{
|
||||
SoState * state = action->getState();
|
||||
|
||||
SoScale * scale = static_cast<SoScale*>(this->getAnyPart(SbName("scale"), true));
|
||||
auto* scale = static_cast<SoScale*>(this->getAnyPart(SbName("scale"), true));
|
||||
if (!this->active.getValue()) {
|
||||
SbVec3f v(1.0f, 1.0f, 1.0f);
|
||||
if (scale->scaleFactor.getValue() != v)
|
||||
if (scale->scaleFactor.getValue() != v){
|
||||
scale->scaleFactor = v;
|
||||
}
|
||||
}
|
||||
else {
|
||||
SoState* state = action->getState();
|
||||
const SbViewportRegion & vp = SoViewportRegionElement::get(state);
|
||||
const SbViewVolume & vv = SoViewVolumeElement::get(state);
|
||||
|
||||
SbVec3f center(0.0f, 0.0f, 0.0f);
|
||||
float nsize = this->scaleFactor.getValue() / float(vp.getViewportSizePixels()[1]);
|
||||
float nsize = this->scaleFactor.getValue() / float(vp.getViewportSizePixels()[0]);
|
||||
SoModelMatrixElement::get(state).multVecMatrix(center, center); // world coords
|
||||
float sf = vv.getWorldToScreenScale(center, nsize);
|
||||
SbVec3f v(sf, sf, sf);
|
||||
if (scale->scaleFactor.getValue() != v)
|
||||
if (scale->scaleFactor.getValue() != v){
|
||||
scale->scaleFactor = v;
|
||||
}
|
||||
}
|
||||
|
||||
inherited::GLRender(action);
|
||||
|
||||
@@ -78,7 +78,6 @@ void ViewProviderDatum::attach(App::DocumentObject* pcObject)
|
||||
{
|
||||
ViewProviderGeometryObject::attach(pcObject);
|
||||
|
||||
float defaultSz = ViewProviderCoordinateSystem::defaultSize();
|
||||
|
||||
// Create an external separator
|
||||
auto sep = new SoSeparator();
|
||||
@@ -93,8 +92,8 @@ void ViewProviderDatum::attach(App::DocumentObject* pcObject)
|
||||
|
||||
// Setup font size
|
||||
auto font = new SoFont();
|
||||
float fontRatio = 4.0f;
|
||||
font->size.setValue(defaultSz / fontRatio);
|
||||
static const float size = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetFloat("DatumFontSize", 15.0);
|
||||
font->size.setValue(size);
|
||||
sep->addChild(font);
|
||||
|
||||
// Create the selection node
|
||||
@@ -135,7 +134,7 @@ void ViewProviderDatum::attach(App::DocumentObject* pcObject)
|
||||
// Scale feature to the given size
|
||||
float sz = App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
|
||||
->GetFloat("LocalCoordinateSystemSize", 2.0); // NOLINT
|
||||
->GetFloat("LocalCoordinateSystemSize", 1.0); // NOLINT
|
||||
|
||||
soScale->setPart("shape", sep);
|
||||
soScale->scaleFactor = sz;
|
||||
|
||||
@@ -79,7 +79,7 @@ void ViewProviderLine::attach(App::DocumentObject *obj) {
|
||||
noRole = true;
|
||||
}
|
||||
|
||||
static const float size = ViewProviderCoordinateSystem::defaultSize();
|
||||
static const float size = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetFloat("DatumLineSize", 70.0);
|
||||
|
||||
SbVec3f verts[2];
|
||||
if (noRole) {
|
||||
|
||||
@@ -92,7 +92,7 @@ void ViewProviderPlane::attach(App::DocumentObject * obj) {
|
||||
noRole = true;
|
||||
}
|
||||
|
||||
static const float size = ViewProviderCoordinateSystem::defaultSize() * 0.6; //NOLINT
|
||||
static const float size = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetFloat("DatumPlaneSize", 40.0);
|
||||
static const float startSize = 0.25 * size; //NOLINT
|
||||
|
||||
|
||||
|
||||
@@ -59,8 +59,9 @@ void ViewProviderPoint::attach(App::DocumentObject * obj) {
|
||||
pCoords->point.setValue(point);
|
||||
sep->addChild(pCoords);
|
||||
|
||||
static const float size = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetFloat("DatumPointSize", 2.5);
|
||||
auto sphere = new SoSphere();
|
||||
sphere->radius.setValue(1.0);
|
||||
sphere->radius.setValue(size);
|
||||
sep->addChild(sphere);
|
||||
|
||||
// Add pick style to define how the point can be selected
|
||||
|
||||
@@ -999,7 +999,7 @@ class ViewProviderGroundedJoint:
|
||||
if groundedObj is None:
|
||||
return
|
||||
|
||||
self.scaleFactor = 1.5
|
||||
self.scaleFactor = 3.0
|
||||
|
||||
lockpadColorInt = Preferences.preferences().GetUnsigned("AssemblyConstraints", 0xCC333300)
|
||||
self.lockpadColor = coin.SoBaseColor()
|
||||
|
||||
@@ -43,7 +43,7 @@ class SoSwitchMarker(coin.SoSwitch):
|
||||
super().__init__() # Initialize the SoSwitch base class
|
||||
|
||||
self.axis_thickness = 3
|
||||
self.scaleFactor = 20
|
||||
self.scaleFactor = 40
|
||||
|
||||
view_params = App.ParamGet("User parameter:BaseApp/Preferences/View")
|
||||
param_x_axis_color = view_params.GetUnsigned("AxisXColor", 0xCC333300)
|
||||
|
||||
@@ -255,7 +255,7 @@ ViewProviderPath::ViewProviderPath()
|
||||
pArrow->set("zAxis.appearance.drawStyle", "style INVISIBLE");
|
||||
pArrow->set("zHead.transform", "translation 0 0 0");
|
||||
pArrowScale->setPart("shape", pArrow);
|
||||
pArrowScale->scaleFactor = 1.0f;
|
||||
pArrowScale->scaleFactor = 2.0f;
|
||||
pArrowGroup->addChild(pArrowScale);
|
||||
|
||||
pcArrowSwitch->addChild(pArrowGroup);
|
||||
|
||||
@@ -330,7 +330,7 @@ class HoldingTagMarker:
|
||||
self.sphere = coin.SoSphere()
|
||||
self.scale = coin.SoType.fromName("SoShapeScale").createInstance()
|
||||
self.scale.setPart("shape", self.sphere)
|
||||
self.scale.scaleFactor.setValue(7)
|
||||
self.scale.scaleFactor.setValue(14)
|
||||
self.material = coin.SoMaterial()
|
||||
self.sep.addChild(self.pos)
|
||||
self.sep.addChild(self.material)
|
||||
|
||||
@@ -150,7 +150,7 @@ class ViewProvider:
|
||||
|
||||
self.sca = coin.SoType.fromName("SoShapeScale").createInstance()
|
||||
self.sca.setPart("shape", self.axs)
|
||||
self.sca.scaleFactor.setValue(1) # Keep or adjust if needed
|
||||
self.sca.scaleFactor.setValue(2) # Keep or adjust if needed
|
||||
|
||||
self.mat = coin.SoMaterial()
|
||||
# Set sphere color to bright yellow
|
||||
@@ -161,7 +161,7 @@ class ViewProvider:
|
||||
self.scs = coin.SoType.fromName("SoShapeScale").createInstance()
|
||||
self.scs.setPart("shape", self.sph)
|
||||
# Increase the scaleFactor to make the sphere larger
|
||||
self.scs.scaleFactor.setValue(10) # Adjust this value as needed
|
||||
self.scs.scaleFactor.setValue(20) # Adjust this value as needed
|
||||
|
||||
self.sep.addChild(self.sca)
|
||||
self.sep.addChild(self.mat)
|
||||
|
||||
Reference in New Issue
Block a user