TaskImage: fix issues

This commit is contained in:
Paddle
2023-04-12 14:06:55 +02:00
parent 6460b24b6c
commit 246014dddd
3 changed files with 17 additions and 6 deletions

View File

@@ -1021,3 +1021,12 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
glPopAttrib();
state->pop();
}
void SoDatumLabel::setPoints(SbVec3f p1, SbVec3f p2)
{
pnts.setNum(2);
SbVec3f* verts = pnts.startEditing();
verts[0] = p1;
verts[1] = p2;
pnts.finishEditing();
}

View File

@@ -60,6 +60,10 @@ public:
static void initClass();
SoDatumLabel();
/*The points have to be on XY plane, ie they need to be 2D points.
To draw on other planes, you need to attach a SoTransform to the SoDatumLabel (or parent).*/
void setPoints(SbVec3f p1, SbVec3f p2);
SoMFString string;
SoSFColor textColor;
SoSFEnum datumtype;

View File

@@ -540,6 +540,7 @@ void InteractiveScale::collectPoint(const SbVec3f& pos3d)
if (points.empty()) {
points.push_back(pos3d);
measureLabel->setPoints(getCoordsOnImagePlane(pos3d), getCoordsOnImagePlane(pos3d));
root->addChild(measureLabel);
}
else if (points.size() == 1) {
@@ -608,12 +609,7 @@ void InteractiveScale::getMousePosition(void * ud, SoEventCallback * ecb)
valueStr = quantity.getUserString(factor, unitStr);
scale->measureLabel->string = SbString(valueStr.toUtf8().constData());
//Update the SoDatumLabel. It needs 2D points!
scale->measureLabel->pnts.setNum(2);
SbVec3f* verts = scale->measureLabel->pnts.startEditing();
verts[0] = scale->getCoordsOnImagePlane(scale->points[0]);
verts[1] = scale->getCoordsOnImagePlane(pos3d);
scale->measureLabel->pnts.finishEditing();
scale->measureLabel->setPoints(scale->getCoordsOnImagePlane(scale->points[0]), scale->getCoordsOnImagePlane(pos3d));
}
}
@@ -672,6 +668,8 @@ void InteractiveScale::setPlacement(Base::Placement plc)
double x, y, z, w;
placement.getRotation().getValue(x, y, z, w);
transform->rotation.setValue(x, y, z, w);
Base::Vector3d pos = placement.getPosition();
transform->translation.setValue(pos.x, pos.y, pos.z);
Base::Vector3d RN(0, 0, 1);
RN = placement.getRotation().multVec(RN);