All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent eafd18dac0
commit 25c3ba7338
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -22,21 +22,21 @@
#include <FCConfig.h>
# ifdef FC_OS_WIN32
#ifdef FC_OS_WIN32
# include <windows.h>
# endif
# ifdef FC_OS_MACOSX
#endif
#ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# else
#else
# include <GL/gl.h>
# endif
# include <QFontMetrics>
# include <QPainter>
# include <QPen>
# include <Inventor/actions/SoGLRenderAction.h>
# include <Inventor/bundles/SoMaterialBundle.h>
# include <Inventor/elements/SoLazyElement.h>
# include <Inventor/misc/SoState.h>
#endif
#include <QFontMetrics>
#include <QPainter>
#include <QPen>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/bundles/SoMaterialBundle.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/misc/SoState.h>
#include <Inventor/C/basic.h>
#include <Inventor/draggers/SoTranslate2Dragger.h>
@@ -68,7 +68,7 @@ void SoTextLabel::initClass()
SoTextLabel::SoTextLabel()
{
SO_NODE_CONSTRUCTOR(SoTextLabel);
SO_NODE_ADD_FIELD(backgroundColor, (SbVec3f(1.0f,1.0f,1.0f)));
SO_NODE_ADD_FIELD(backgroundColor, (SbVec3f(1.0f, 1.0f, 1.0f)));
SO_NODE_ADD_FIELD(background, (true));
SO_NODE_ADD_FIELD(frameSize, (10.0f));
}
@@ -76,10 +76,11 @@ SoTextLabel::SoTextLabel()
/**
* Renders the label.
*/
void SoTextLabel::GLRender(SoGLRenderAction *action)
void SoTextLabel::GLRender(SoGLRenderAction* action)
{
if (!this->shouldGLRender(action))
if (!this->shouldGLRender(action)) {
return;
}
// only draw text without background
if (!this->background.getValue()) {
@@ -87,7 +88,7 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
return;
}
SoState * state = action->getState();
SoState* state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
@@ -99,10 +100,10 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
if (!SoCullElement::cullTest(state, box, true)) {
SoMaterialBundle mb(action);
mb.sendFirst();
const SbMatrix & mat = SoModelMatrixElement::get(state);
const SbMatrix & projmatrix = (mat * SoViewingMatrixElement::get(state) *
SoProjectionMatrixElement::get(state));
const SbViewportRegion & vp = SoViewportRegionElement::get(state);
const SbMatrix& mat = SoModelMatrixElement::get(state);
const SbMatrix& projmatrix
= (mat * SoViewingMatrixElement::get(state) * SoProjectionMatrixElement::get(state));
const SbViewportRegion& vp = SoViewportRegionElement::get(state);
SbVec2s vpsize = vp.getViewportSizePixels();
// font stuff
@@ -123,45 +124,45 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
// returns the sizes in form of the bounding box. These values can be
// reverse-engineered to get width and height.
state->push();
SoModelMatrixElement::set(state,this,SbMatrix::identity());
SoViewingMatrixElement::set(state,this,SbMatrix::identity());
SoProjectionMatrixElement::set(state,this,SbMatrix::identity());
SoModelMatrixElement::set(state, this, SbMatrix::identity());
SoViewingMatrixElement::set(state, this, SbMatrix::identity());
SoProjectionMatrixElement::set(state, this, SbMatrix::identity());
SbViewVolume vv;
vv.ortho(-1,1,-1,1,-1,1);
SoViewVolumeElement::set(state,this,vv);
vv.ortho(-1, 1, -1, 1, -1, 1);
SoViewVolumeElement::set(state, this, vv);
SbBox3f box;
SbVec3f center;
this->computeBBox(action, box, center);
state->pop();
float xmin,ymin,zmin,xmax,ymax,zmax;
box.getBounds(xmin,ymin,zmin,xmax,ymax,zmax);
SbVec3f v0(xmin,ymax,zmax);
SbVec3f v1(xmax,ymax,zmax);
SbVec3f v2(xmax,ymin,zmax);
SbVec3f v3(xmin,ymin,zmax);
vv.projectToScreen(v0,v0);
vv.projectToScreen(v1,v1);
vv.projectToScreen(v2,v2);
vv.projectToScreen(v3,v3);
float xmin, ymin, zmin, xmax, ymax, zmax;
box.getBounds(xmin, ymin, zmin, xmax, ymax, zmax);
SbVec3f v0(xmin, ymax, zmax);
SbVec3f v1(xmax, ymax, zmax);
SbVec3f v2(xmax, ymin, zmax);
SbVec3f v3(xmin, ymin, zmax);
vv.projectToScreen(v0, v0);
vv.projectToScreen(v1, v1);
vv.projectToScreen(v2, v2);
vv.projectToScreen(v3, v3);
float width,height;
width = (v1[0]-v0[0])*vpsize[0];
height = (v1[1]-v3[1])*vpsize[1];
float width, height;
width = (v1[0] - v0[0]) * vpsize[0];
height = (v1[1] - v3[1]) * vpsize[1];
switch (this->justification.getValue()) {
case SoText2::RIGHT:
nilpoint[0] -= width;
break;
case SoText2::CENTER:
nilpoint[0] -= 0.5f*width;
break;
default:
break;
case SoText2::RIGHT:
nilpoint[0] -= width;
break;
case SoText2::CENTER:
nilpoint[0] -= 0.5f * width;
break;
default:
break;
}
if (lines > 1) {
nilpoint[1] -= (float(lines-1)/(float)lines*height);
nilpoint[1] -= (float(lines - 1) / (float)lines * height);
}
SbVec3f toppoint = nilpoint;
@@ -176,7 +177,7 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
glPushMatrix();
glLoadIdentity();
glOrtho(0, vpsize[0], 0, vpsize[1], -1.0f, 1.0f);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
state->push();
@@ -194,10 +195,10 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
// draw background
glColor3f(color[0], color[1], color[2]);
glBegin(GL_QUADS);
glVertex3f(nilpoint[0]-fs,nilpoint[1]-fs,0.0f);
glVertex3f(toppoint[0]+fs,nilpoint[1]-fs,0.0f);
glVertex3f(toppoint[0]+fs,toppoint[1]+fs,0.0f);
glVertex3f(nilpoint[0]-fs,toppoint[1]+fs,0.0f);
glVertex3f(nilpoint[0] - fs, nilpoint[1] - fs, 0.0f);
glVertex3f(toppoint[0] + fs, nilpoint[1] - fs, 0.0f);
glVertex3f(toppoint[0] + fs, toppoint[1] + fs, 0.0f);
glVertex3f(nilpoint[0] - fs, toppoint[1] + fs, 0.0f);
glEnd();
// pop old state
@@ -205,7 +206,7 @@ void SoTextLabel::GLRender(SoGLRenderAction *action)
glPopAttrib();
state->pop();
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
// Pop old GL matrix state.
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@@ -232,7 +233,7 @@ SoColorBarLabel::SoColorBarLabel()
SO_NODE_CONSTRUCTOR(SoColorBarLabel);
}
void SoColorBarLabel::computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center)
void SoColorBarLabel::computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center)
{
inherited::computeBBox(action, box, center);
if (!box.hasVolume()) {
@@ -258,7 +259,7 @@ SoStringLabel::SoStringLabel()
{
SO_NODE_CONSTRUCTOR(SoStringLabel);
SO_NODE_ADD_FIELD(string, (""));
SO_NODE_ADD_FIELD(textColor, (SbVec3f(1.0f,1.0f,1.0f)));
SO_NODE_ADD_FIELD(textColor, (SbVec3f(1.0f, 1.0f, 1.0f)));
SO_NODE_ADD_FIELD(name, ("Helvetica"));
SO_NODE_ADD_FIELD(size, (12));
}
@@ -266,10 +267,10 @@ SoStringLabel::SoStringLabel()
/**
* Renders the open edges only.
*/
void SoStringLabel::GLRender(SoGLRenderAction *action)
void SoStringLabel::GLRender(SoGLRenderAction* action)
{
QOpenGLWidget* window;
SoState * state = action->getState();
SoState* state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
SoGLWidgetElement::get(state, window);
@@ -282,7 +283,7 @@ void SoStringLabel::GLRender(SoGLRenderAction *action)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1,1,-1,1,-1,1);
glOrtho(-1, 1, -1, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
@@ -297,19 +298,20 @@ void SoStringLabel::GLRender(SoGLRenderAction *action)
font.setFamily(QLatin1String(this->name.getValue()));
font.setPixelSize(this->size.getValue());
glBlendFunc(GL_ONE,GL_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_SRC_ALPHA);
// text color
SbColor color = this->textColor.getValue();
glColor4f(color[0], color[1], color[2], 1);
const SbMatrix & mat = SoModelMatrixElement::get(state);
const SbMatrix & projmatrix = (mat * SoViewingMatrixElement::get(state) *
SoProjectionMatrixElement::get(state));
const SbMatrix& mat = SoModelMatrixElement::get(state);
const SbMatrix& projmatrix
= (mat * SoViewingMatrixElement::get(state) * SoProjectionMatrixElement::get(state));
SbVec3f nil(0.0f, 0.0f, 0.0f);
projmatrix.multVecMatrix(nil, nil);
QStringList list;
for (int i=0; i<this->string.getNum(); i++)
for (int i = 0; i < this->string.getNum(); i++) {
list << QLatin1String(this->string[i].getString());
}
// Leave 2D screen mode
glPopAttrib();
@@ -334,8 +336,8 @@ SoFrameLabel::SoFrameLabel()
{
SO_NODE_CONSTRUCTOR(SoFrameLabel);
SO_NODE_ADD_FIELD(string, (""));
SO_NODE_ADD_FIELD(textColor, (SbVec3f(1.0f,1.0f,1.0f)));
SO_NODE_ADD_FIELD(backgroundColor, (SbVec3f(0.0f,0.333f,1.0f)));
SO_NODE_ADD_FIELD(textColor, (SbVec3f(1.0f, 1.0f, 1.0f)));
SO_NODE_ADD_FIELD(backgroundColor, (SbVec3f(0.0f, 0.333f, 1.0f)));
SO_NODE_ADD_FIELD(justification, (LEFT));
SO_NODE_ADD_FIELD(name, ("Helvetica"));
SO_NODE_ADD_FIELD(size, (12));
@@ -343,26 +345,21 @@ SoFrameLabel::SoFrameLabel()
SO_NODE_ADD_FIELD(border, (true));
SO_NODE_ADD_FIELD(backgroundUseBaseColor, (false));
SO_NODE_ADD_FIELD(textUseBaseColor, (false));
//SO_NODE_ADD_FIELD(image, (SbVec2s(0,0), 0, NULL));
// SO_NODE_ADD_FIELD(image, (SbVec2s(0,0), 0, NULL));
}
void SoFrameLabel::setIcon(const QPixmap &pixMap)
void SoFrameLabel::setIcon(const QPixmap& pixMap)
{
iconPixmap = pixMap;
drawImage();
}
void SoFrameLabel::notify(SoNotList * list)
void SoFrameLabel::notify(SoNotList* list)
{
SoField *f = list->getLastField();
if (f == &this->string ||
f == &this->textColor ||
f == &this->backgroundColor ||
f == &this->justification ||
f == &this->name ||
f == &this->size ||
f == &this->frame ||
f == &this->border) {
SoField* f = list->getLastField();
if (f == &this->string || f == &this->textColor || f == &this->backgroundColor
|| f == &this->justification || f == &this->name || f == &this->size || f == &this->frame
|| f == &this->border) {
drawImage();
}
@@ -384,14 +381,14 @@ void SoFrameLabel::drawImage()
int h = fm.height() * num;
const SbColor& b = backgroundColor.getValue();
QColor backgroundBrush;
backgroundBrush.setRgbF(b[0],b[1],b[2]);
backgroundBrush.setRgbF(b[0], b[1], b[2]);
const SbColor& t = textColor.getValue();
QColor front;
front.setRgbF(t[0],t[1],t[2]);
const QPen borderPen(QColor(0,0,127), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
front.setRgbF(t[0], t[1], t[2]);
const QPen borderPen(QColor(0, 0, 127), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QStringList lines;
for (int i=0; i<num; i++) {
for (int i = 0; i < num; i++) {
QString line = QString::fromUtf8(s[i].getString());
w = std::max<int>(w, QtTools::horizontalAdvance(fm, line));
lines << line;
@@ -406,12 +403,12 @@ void SoFrameLabel::drawImage()
if (!iconPixmap.isNull()) {
drawIcon = true;
iconImg = iconPixmap.toImage();
widthIcon = iconImg.width() + 2*padding;
heightIcon = iconImg.height() + 2*padding;
widthIcon = iconImg.width() + 2 * padding;
heightIcon = iconImg.height() + 2 * padding;
}
int widthText = w + 2*padding;
int heightText = h + 2*padding;
int widthText = w + 2 * padding;
int heightText = h + 2 * padding;
int widthTotal = widthText + widthIcon;
int heightTotal = heightText > heightIcon ? heightText : heightIcon;
int paddingTextV = (heightTotal - h) / 2;
@@ -433,18 +430,21 @@ void SoFrameLabel::drawImage()
}
if (drawIcon) {
painter.drawImage(QPoint(padding, paddingIconV), iconImg);
painter.drawImage(QPoint(padding, paddingIconV), iconImg);
}
painter.setPen(front);
Qt::Alignment align = Qt::AlignVCenter;
if (justification.getValue() == 0)
if (justification.getValue() == 0) {
align = Qt::AlignVCenter | Qt::AlignLeft;
else if (justification.getValue() == 1)
}
else if (justification.getValue() == 1) {
align = Qt::AlignVCenter | Qt::AlignRight;
else
}
else {
align = Qt::AlignVCenter | Qt::AlignHCenter;
}
QString text = lines.join(QLatin1String("\n"));
painter.setFont(font);
painter.drawText(widthIcon + padding, paddingTextV, w, h, align, text);
@@ -458,7 +458,7 @@ void SoFrameLabel::drawImage()
/**
* Renders the open edges only.
*/
void SoFrameLabel::GLRender(SoGLRenderAction *action)
void SoFrameLabel::GLRender(SoGLRenderAction* action)
{
if (backgroundUseBaseColor.getValue()) {
@@ -486,11 +486,9 @@ void SoFrameLabel::GLRender(SoGLRenderAction *action)
SO_NODE_SOURCE(TranslateManip)
void
TranslateManip::initClass()
void TranslateManip::initClass()
{
SO_NODE_INIT_CLASS(TranslateManip, SoTransformManip,
"TransformManip");
SO_NODE_INIT_CLASS(TranslateManip, SoTransformManip, "TransformManip");
}
TranslateManip::TranslateManip()