Gui: add SoColorBarLabel as workaround for a Coin3D bug

This commit is contained in:
wmayer
2022-06-07 19:42:04 +02:00
parent 80982cf87b
commit b9db257558
4 changed files with 49 additions and 2 deletions

View File

@@ -35,6 +35,7 @@
#endif
#include "SoFCColorGradient.h"
#include "SoTextLabel.h"
#include "DlgSettingsColorGradientImp.h"
#include "MainWindow.h"
#include "MDIView.h"
@@ -98,7 +99,7 @@ void SoFCColorGradient::setMarkerLabel(const SoMFString& label)
for (int i = 0; i < num; i++) {
SoTransform* trans = new SoTransform;
SoBaseColor* color = new SoBaseColor;
SoText2 * text2 = new SoText2;
SoText2 * text2 = new SoColorBarLabel;
trans->translation.setValue(0, -fStep, 0);
color->rgb.setValue(0, 0, 0);

View File

@@ -124,6 +124,7 @@ void Gui::SoFCDB::init()
SoVRMLAction ::initClass();
SoSkipBoundingGroup ::initClass();
SoTextLabel ::initClass();
SoColorBarLabel ::initClass();
SoStringLabel ::initClass();
SoFrameLabel ::initClass();
TranslateManip ::initClass();

View File

@@ -298,6 +298,33 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
// ------------------------------------------------------
SO_NODE_SOURCE(SoColorBarLabel)
void SoColorBarLabel::initClass()
{
SO_NODE_INIT_CLASS(SoColorBarLabel, SoText2, "Text2");
}
SoColorBarLabel::SoColorBarLabel()
{
SO_NODE_CONSTRUCTOR(SoColorBarLabel);
}
void SoColorBarLabel::computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center)
{
inherited::computeBBox(action, box, center);
if (!box.hasVolume()) {
SbViewVolume vv = SoViewVolumeElement::get(action->getState());
// workaround for https://github.com/coin3d/coin/issues/417:
// extend by 2 percent
vv.scaleWidth(1.02f);
SoViewVolumeElement::set(action->getState(), this, vv);
inherited::computeBBox(action, box, center);
}
}
// ------------------------------------------------------
SO_NODE_SOURCE(SoStringLabel)
void SoStringLabel::initClass()

View File

@@ -32,6 +32,7 @@
#include <Inventor/manips/SoTransformManip.h>
#include <Inventor/nodes/SoImage.h>
#include <Inventor/nodes/SoText2.h>
#include <FCGlobal.h>
namespace Gui {
@@ -54,10 +55,27 @@ public:
SoSFFloat frameSize;
protected:
virtual ~SoTextLabel() {};
virtual ~SoTextLabel() {}
virtual void GLRender(SoGLRenderAction *action);
};
/**
* A text label for the color bar.
* @author Werner Mayer
*/
class GuiExport SoColorBarLabel : public SoText2 {
typedef SoText2 inherited;
SO_NODE_HEADER(SoColorBarLabel);
public:
static void initClass();
SoColorBarLabel();
protected:
void computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center) override;
};
class GuiExport SoStringLabel : public SoNode {
typedef SoNode inherited;