TaskImage: fix issues
This commit is contained in:
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user