Sketcher Bug fix: Arrows for symmetry constraint are back

The arrows were there in the code, but at a certain point, code was written to set the this->imgHeight value programatically, based on
whether it had text or not. As symmetry constraint does not have text the variable failed to initialize. Being zero, it did not pass
the ASSERT in the render function, so it was not rendered.

This includes Werner's fix for improver cast of a SoRayPickAction to SoGLRenderAction:
SbVec2s vp_size = static_cast<SoGLRenderAction*>(action)->getViewportRegion().getWindowSize();
to
SbVec2s vp_size = SoViewportRegionElement::get(state).getWindowSize();

At least sometimes tt is a SoRayPickAction because:

When you move with the mouse over the sketcher (when in edit mode) you enter the method ViewProviderSketch::mouseMove.
Inside there the method getPointOnRay is called to get a picked point underneath the cursor. Inside the latter method
an instance of SoRayPickAction is created to traverse the scene graph. After a long cascade of function calls you
finally enter SoDatumLabel::generatePrimitives(SoAction*).
This commit is contained in:
Abdullah Tahiri 2014-08-27 14:58:35 +02:00 committed by wmayer
parent fdb7de1dda
commit 0adfa0a7ed
2 changed files with 13 additions and 3 deletions

View File

@ -338,8 +338,8 @@ void SoDatumLabel::generatePrimitives(SoAction * action)
SoState *state = action->getState();
const SbViewVolume & vv = SoViewVolumeElement::get(state);
float scale = vv.getWorldToScreenScale(SbVec3f(0.f,0.f,0.f), 1.0f);
SbVec2s vp_size = static_cast<SoGLRenderAction*>(action)->getViewportRegion().getWindowSize();
scale /= float(vp_size[0]);
SbVec2s vp_size = SoViewportRegionElement::get(state).getWindowSize();
scale /= float(vp_size[0]);
SbVec3f dir = (p2-p1);
dir.normalize();
@ -458,6 +458,14 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
this->imgHeight = scale * (float) (srch);
this->imgWidth = aspectRatio * (float) this->imgHeight;
}
if (this->datumtype.getValue() == SYMMETRIC) {
// For the symmetry constraint that does not have text, but does have arrows
//this->imgHeight = 3.36f;
//this->imgWidth = 5.26f;
this->imgHeight = 1.5f;
this->imgWidth = 1.5f;
}
// Get the points stored in the pnt field
const SbVec3f *pnts = this->pnts.getValues(0);

View File

@ -1483,7 +1483,9 @@ std::set<int> ViewProviderSketch::detectPreselectionConstr(const SoPickedPoint *
} else {
// Assume second icon was hit
constrIds = static_cast<SoInfo *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID));
if(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID<sep->getNumChildren()){
constrIds = static_cast<SoInfo *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID));
}
}
if(constrIds) {
QString constrIdsStr = QString::fromAscii(constrIds->string.getValue().getString());