Gui: initialize _bbox with correct default values and fix incorrect label postions if ratio of width/height is less than 1
This commit is contained in:
@@ -48,7 +48,7 @@ SO_NODE_SOURCE(SoFCColorGradient)
|
||||
/*!
|
||||
Constructor.
|
||||
*/
|
||||
SoFCColorGradient::SoFCColorGradient() : _bbox(4.0f, -4.0f, 4.5f, 4.0f), _precision(3)
|
||||
SoFCColorGradient::SoFCColorGradient() : _bbox(5.0f, -4.0f, 5.5f, 4.0f), _precision(3)
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCColorGradient);
|
||||
coords = new SoCoordinate3;
|
||||
@@ -88,9 +88,11 @@ void SoFCColorGradient::setMarkerLabel(const SoMFString& label)
|
||||
|
||||
int num = label.getNum();
|
||||
if (num > 1) {
|
||||
float fStep = 8.0f / ((float)num - 1);
|
||||
SbVec2f maxPt = _bbox.getMax();
|
||||
SbVec2f minPt = _bbox.getMin();
|
||||
float fStep = (maxPt[1] - minPt[1]) / ((float)num - 1);
|
||||
SoTransform* trans = new SoTransform;
|
||||
trans->translation.setValue(_bbox.getMax()[0] + 0.1f, _bbox.getMax()[1] - 0.05f + fStep, 0.0f);
|
||||
trans->translation.setValue(maxPt[0] + 0.1f, maxPt[1] - 0.05f + fStep, 0.0f);
|
||||
labels->addChild(trans);
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
|
||||
Reference in New Issue
Block a user