Merge pull request #15528 from ppphp/move_some_inventor

refactor: move some nodes to Inventor folder
This commit is contained in:
Chris Hennes
2024-11-22 12:20:50 -05:00
committed by GitHub
28 changed files with 545 additions and 553 deletions

View File

@@ -1016,12 +1016,15 @@ SOURCE_GROUP("View3D\\Viewprovider" FILES ${Viewprovider_SRCS})
# The Inventor sources
SET(Inventor_CPP_SRCS
Inventor/SoDrawingGrid.cpp
Inventor/SoAutoZoomTranslation.cpp
Inventor/MarkerBitmaps.cpp
Inventor/SmSwitchboard.cpp
SoFCBackgroundGradient.cpp
SoFCBoundingBox.cpp
Inventor/So3DAnnotation.cpp
Inventor/SoAutoZoomTranslation.cpp
Inventor/SoAxisCrossKit.cpp
Inventor/SoDrawingGrid.cpp
Inventor/SoFCBackgroundGradient.cpp
Inventor/SoFCBoundingBox.cpp
Inventor/SoMouseWheelEvent.cpp
SoFCColorBar.cpp
SoFCColorBarNotifier.cpp
SoFCColorGradient.cpp
@@ -1036,23 +1039,22 @@ SET(Inventor_CPP_SRCS
SoFCSelectionAction.cpp
SoFCVectorizeSVGAction.cpp
SoFCVectorizeU3DAction.cpp
So3DAnnotation.cpp
SoAxisCrossKit.cpp
SoTextLabel.cpp
SoDatumLabel.cpp
SoTouchEvents.cpp
SoMouseWheelEvent.cpp
SoFCCSysDragger.cpp
ArcEngine.cpp
)
SET(Inventor_SRCS
${Inventor_CPP_SRCS}
Inventor/SoDrawingGrid.h
Inventor/SoAutoZoomTranslation.h
Inventor/MarkerBitmaps.h
Inventor/SmSwitchboard.h
SoFCBackgroundGradient.h
SoFCBoundingBox.h
Inventor/SoAutoZoomTranslation.h
Inventor/SoAxisCrossKit.h
Inventor/SoDrawingGrid.h
Inventor/SoFCBackgroundGradient.h
Inventor/SoFCBoundingBox.h
Inventor/SoMouseWheelEvent.h
SoFCColorBar.h
SoFCColorBarNotifier.h
SoFCColorGradient.h
@@ -1067,11 +1069,9 @@ SET(Inventor_SRCS
SoFCSelectionAction.h
SoFCVectorizeSVGAction.h
SoFCVectorizeU3DAction.h
SoAxisCrossKit.h
SoTextLabel.h
SoDatumLabel.h
SoTouchEvents.h
SoMouseWheelEvent.h
SoFCCSysDragger.h
ArcEngine.h
)
@@ -1310,7 +1310,7 @@ SET(FreeCADGui_SRCS
${Dock_Windows_SRCS}
${Editor_SRCS}
${Help_SRCS}
${Inventor_SRCS}
${Inventor_CPP_SRCS}
${Language_SRCS}
${Propertyeditor_SRCS}
${Task_View_SRCS}

View File

@@ -65,6 +65,7 @@
#include "Document.h"
#include "FileDialog.h"
#include "ImageView.h"
#include "Inventor/SoAxisCrossKit.h"
#include "Macro.h"
#include "MainWindow.h"
#include "NavigationStyle.h"
@@ -73,7 +74,6 @@
#include "SceneInspector.h"
#include "Selection.h"
#include "SelectionObject.h"
#include "SoAxisCrossKit.h"
#include "SoFCOffscreenRenderer.h"
#include "TextureMapping.h"
#include "Tools.h"

View File

@@ -23,11 +23,14 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QtOpenGL>
#ifdef FC_OS_MACOSX
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#include <Inventor/elements/SoCacheElement.h>
#endif
#include "SoFCDB.h"
#include "So3DAnnotation.h"
using namespace Gui;

View File

@@ -23,9 +23,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# ifdef FC_OS_WIN32
# include <windows.h>
# endif
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# else

View File

@@ -1,120 +1,120 @@
/***************************************************************************
* Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_SOSHAPESCALE_H
#define GUI_SOSHAPESCALE_H
#include <Inventor/fields/SoSFColor.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/fields/SoSFString.h>
#include <Inventor/fields/SoSFVec3f.h>
#include <Inventor/nodekits/SoBaseKit.h>
#include <Inventor/nodes/SoShape.h>
#include <FCGlobal.h>
class SbViewport;
class SoState;
class SbColor;
class SbVec2s;
namespace Gui {
class GuiExport SoShapeScale : public SoBaseKit {
using inherited = SoBaseKit;
SO_KIT_HEADER(SoShapeScale);
SO_KIT_CATALOG_ENTRY_HEADER(topSeparator);
SO_KIT_CATALOG_ENTRY_HEADER(scale);
SO_KIT_CATALOG_ENTRY_HEADER(shape);
public:
SoShapeScale();
static void initClass();
SoSFFloat active;
SoSFFloat scaleFactor;
protected:
void GLRender(SoGLRenderAction * action) override;
~SoShapeScale() override;
};
class GuiExport SoAxisCrossKit : public SoBaseKit {
using inherited = SoBaseKit;
SO_KIT_HEADER(SoAxisCrossKit);
SO_KIT_CATALOG_ENTRY_HEADER(xAxis);
SO_KIT_CATALOG_ENTRY_HEADER(xHead);
SO_KIT_CATALOG_ENTRY_HEADER(yAxis);
SO_KIT_CATALOG_ENTRY_HEADER(yHead);
SO_KIT_CATALOG_ENTRY_HEADER(zAxis);
SO_KIT_CATALOG_ENTRY_HEADER(zHead);
public:
SoAxisCrossKit();
// Overrides default method. All the parts are shapeKits,
// so this node will not affect the state.
SbBool affectsState() const override;
void addWriteReference(SoOutput * out, SbBool isfromfield = false) override;
void getBoundingBox(SoGetBoundingBoxAction * action) override;
static void initClass();
private:
// Constructor calls to build and set up parts.
void createAxes();
~SoAxisCrossKit() override;
};
class GuiExport SoRegPoint : public SoShape {
using inherited = SoShape;
SO_NODE_HEADER(SoRegPoint);
public:
static void initClass();
SoRegPoint();
void notify(SoNotList * node) override;
SoSFVec3f base;
SoSFVec3f normal;
SoSFFloat length;
SoSFColor color;
SoSFString text;
protected:
~SoRegPoint() override;
void GLRender(SoGLRenderAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
void generatePrimitives(SoAction *action) override;
private:
SoSeparator* root;
};
} // namespace Gui
#endif // GUI_SOSHAPESCALE_H
/***************************************************************************
* Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_SOSHAPESCALE_H
#define GUI_SOSHAPESCALE_H
#include <Inventor/fields/SoSFColor.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/fields/SoSFString.h>
#include <Inventor/fields/SoSFVec3f.h>
#include <Inventor/nodekits/SoBaseKit.h>
#include <Inventor/nodes/SoShape.h>
#include <FCGlobal.h>
class SbViewport;
class SoState;
class SbColor;
class SbVec2s;
namespace Gui {
class GuiExport SoShapeScale : public SoBaseKit {
using inherited = SoBaseKit;
SO_KIT_HEADER(SoShapeScale);
SO_KIT_CATALOG_ENTRY_HEADER(topSeparator);
SO_KIT_CATALOG_ENTRY_HEADER(scale);
SO_KIT_CATALOG_ENTRY_HEADER(shape);
public:
SoShapeScale();
static void initClass();
SoSFFloat active;
SoSFFloat scaleFactor;
protected:
void GLRender(SoGLRenderAction * action) override;
~SoShapeScale() override;
};
class GuiExport SoAxisCrossKit : public SoBaseKit {
using inherited = SoBaseKit;
SO_KIT_HEADER(SoAxisCrossKit);
SO_KIT_CATALOG_ENTRY_HEADER(xAxis);
SO_KIT_CATALOG_ENTRY_HEADER(xHead);
SO_KIT_CATALOG_ENTRY_HEADER(yAxis);
SO_KIT_CATALOG_ENTRY_HEADER(yHead);
SO_KIT_CATALOG_ENTRY_HEADER(zAxis);
SO_KIT_CATALOG_ENTRY_HEADER(zHead);
public:
SoAxisCrossKit();
// Overrides default method. All the parts are shapeKits,
// so this node will not affect the state.
SbBool affectsState() const override;
void addWriteReference(SoOutput * out, SbBool isfromfield = false) override;
void getBoundingBox(SoGetBoundingBoxAction * action) override;
static void initClass();
private:
// Constructor calls to build and set up parts.
void createAxes();
~SoAxisCrossKit() override;
};
class GuiExport SoRegPoint : public SoShape {
using inherited = SoShape;
SO_NODE_HEADER(SoRegPoint);
public:
static void initClass();
SoRegPoint();
void notify(SoNotList * node) override;
SoSFVec3f base;
SoSFVec3f normal;
SoSFFloat length;
SoSFColor color;
SoSFString text;
protected:
~SoRegPoint() override;
void GLRender(SoGLRenderAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
void generatePrimitives(SoAction *action) override;
private:
SoSeparator* root;
};
} // namespace Gui
#endif // GUI_SOSHAPESCALE_H

View File

@@ -23,7 +23,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QObject>
# include <Inventor/actions/SoGLRenderAction.h>
# include <Inventor/elements/SoCacheElement.h>
# include <Inventor/elements/SoLazyElement.h>
@@ -31,13 +30,12 @@
# include <Inventor/elements/SoProjectionMatrixElement.h>
# include <Inventor/elements/SoViewingMatrixElement.h>
# include <Inventor/elements/SoViewportRegionElement.h>
#endif
#ifdef FC_OS_MACOSX
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include "SoDrawingGrid.h"
@@ -179,14 +177,14 @@ SoDrawingGrid::GLRenderOffPath(SoGLRenderAction *)
void
SoDrawingGrid::generatePrimitives(SoAction* action)
{
Q_UNUSED(action);
(void)action;
}
void
SoDrawingGrid::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
{
Q_UNUSED(action);
Q_UNUSED(box);
Q_UNUSED(center);
(void)action;
(void)box;
(void)center;
//SoState* state = action->getState();
}

View File

@@ -1,272 +1,270 @@
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#include <Inventor/SbBox.h>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/misc/SoState.h>
#include <Inventor/nodes/SoText2.h>
#include <Inventor/nodes/SoTransform.h>
#include <iostream>
#include <string>
#endif
#include "SoFCBoundingBox.h"
using namespace Gui;
SO_NODE_SOURCE(SoFCBoundingBox)
// vertices used to create a box
static const int32_t bBoxVerts[8][3] =
{
{0, 0, 0},
{1, 0, 0},
{1, 1, 0},
{0, 1, 0},
{0, 0, 1},
{1, 0, 1},
{1, 1, 1},
{0, 1, 1}
};
// indexes used to create the edges
static const int32_t bBoxEdges[36] =
{
0,1,-1, 1,2,-1, 2,3,-1, 3,0,-1,
4,5,-1, 5,6,-1, 6,7,-1, 7,4,-1,
0,4,-1, 1,5,-1, 2,6,-1, 3,7,-1
};
void SoFCBoundingBox::initClass ()
{
SO_NODE_INIT_CLASS(SoFCBoundingBox, SoShape, "Shape");
}
SoFCBoundingBox::SoFCBoundingBox ()
{
SO_NODE_CONSTRUCTOR(SoFCBoundingBox);
SO_NODE_ADD_FIELD(minBounds, (-1.0, -1.0, -1.0));
SO_NODE_ADD_FIELD(maxBounds, ( 1.0, 1.0, 1.0));
SO_NODE_ADD_FIELD(coordsOn, (true));
SO_NODE_ADD_FIELD(dimensionsOn, (true));
root = new SoSeparator();
auto bboxSep = new SoSeparator();
bboxCoords = new SoCoordinate3();
bboxCoords->point.setNum(8);
bboxSep->addChild(bboxCoords);
root->addChild(bboxSep);
// the lines of the box
bboxLines = new SoIndexedLineSet();
bboxLines->coordIndex.setNum(36);
bboxLines->coordIndex.setValues(0, 36, bBoxEdges);
bboxSep->addChild(bboxLines);
// create the text nodes, including a transform for each vertice offset
textSep = new SoSeparator();
for (int i = 0; i < 8; i++) {
auto temp = new SoSeparator();
auto trans = new SoTransform();
temp->addChild(trans);
auto text = new SoText2();
text->justification.setValue(SoText2::CENTER);
temp->addChild(text);
textSep->addChild(temp);
}
// create the text nodes, including a transform for each dimension
dimSep = new SoSeparator();
for (int i = 0; i < 3; i++) {
auto temp = new SoSeparator();
auto trans = new SoTransform();
temp->addChild(trans);
auto text = new SoText2();
text->justification.setValue(SoText2::CENTER);
temp->addChild(text);
dimSep->addChild(temp);
}
root->addChild(textSep);
root->addChild(dimSep);
root->ref();
}
SoFCBoundingBox::~SoFCBoundingBox ()
{
root->unref();
}
void SoFCBoundingBox::GLRender (SoGLRenderAction *action)
{
SbVec3f corner[2], ctr, *vptr;
SbBool coord, dimension;
// grab the current state
//SoState *state = action->getState();
if (!shouldGLRender(action))
return;
// get the latest values from the fields
corner[0] = minBounds.getValue();
corner[1] = maxBounds.getValue();
coord = coordsOn.getValue();
dimension = dimensionsOn.getValue();
// set the coordinates for the LineSet to point to
vptr = bboxCoords->point.startEditing();
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 3; j++) {
vptr[i][j] = corner[bBoxVerts[i][j]][j];
}
}
// if coord is true then set the text nodes
if (coord) {
ctr = (corner[1] - corner[0]) / 2.0f;
for (int i = 0; i < 8; i++) {
// create the string for the text
std::stringstream str;
str.precision(2);
str.setf(std::ios::fixed | std::ios::showpoint);
str << "(" << vptr[i][0] << "," << vptr[i][1] << "," << vptr[i][2] << ")";
SoSeparator *sep = static_cast<SoSeparator *>(textSep->getChild(i));
SoTransform *trans = static_cast<SoTransform *>(sep->getChild(0));
trans->translation.setValue(vptr[i].getValue());
SoText2* t = static_cast<SoText2 *>(sep->getChild(1));
t->string.setValue(str.str().c_str());
}
textSep->ref();
if (root->findChild(textSep) < 0)
root->addChild(textSep);
} else {
if (root->findChild(textSep) >= 0)
root->removeChild(textSep);
}
// if dimension is true then set the text nodes
if (dimension) {
ctr = (corner[1] - corner[0]) / 2.0f;
for (int i = 0; i < 3; i++) {
// create the string for the text
std::stringstream str;
str.precision(2);
str.setf(std::ios::fixed | std::ios::showpoint);
str << (2.0f * ctr[i]);
SoSeparator *sep = static_cast<SoSeparator *>(dimSep->getChild(i));
SoTransform *trans = static_cast<SoTransform *>(sep->getChild(0));
SbVec3f point = corner[0];
point[i] += ctr[i];
trans->translation.setValue(point.getValue());
SoText2* t = static_cast<SoText2 *>(sep->getChild(1));
t->string.setValue(str.str().c_str());
}
dimSep->ref();
if (root->findChild(dimSep) < 0)
root->addChild(dimSep);
} else {
if (root->findChild(dimSep) >= 0)
root->removeChild(dimSep);
}
bboxCoords->point.finishEditing();
// Avoid shading
SoState * state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
root->GLRender(action);
state->pop();
}
void SoFCBoundingBox::generatePrimitives (SoAction * /*action*/)
{
}
void SoFCBoundingBox::computeBBox (SoAction * /*action*/, SbBox3f &box, SbVec3f &center)
{
center = (minBounds.getValue() + maxBounds.getValue()) / 2.0f;
box.setBounds(minBounds.getValue(), maxBounds.getValue());
}
void SoFCBoundingBox::finish()
{
atexit_cleanup();
}
// ---------------------------------------------------------------
SO_NODE_SOURCE(SoSkipBoundingGroup)
/*!
Constructor.
*/
SoSkipBoundingGroup::SoSkipBoundingGroup()
{
SO_NODE_CONSTRUCTOR(SoSkipBoundingGroup);
SO_NODE_ADD_FIELD(mode, (INCLUDE_BBOX));
SO_NODE_DEFINE_ENUM_VALUE(Modes, INCLUDE_BBOX);
SO_NODE_DEFINE_ENUM_VALUE(Modes, EXCLUDE_BBOX);
SO_NODE_SET_SF_ENUM_TYPE (mode, Modes);
}
/*!
Destructor.
*/
SoSkipBoundingGroup::~SoSkipBoundingGroup() = default;
void
SoSkipBoundingGroup::initClass()
{
SO_NODE_INIT_CLASS(SoSkipBoundingGroup,SoGroup,"Group");
}
void SoSkipBoundingGroup::finish()
{
atexit_cleanup();
}
void SoSkipBoundingGroup::getBoundingBox(SoGetBoundingBoxAction *action)
{
if (mode.getValue() == INCLUDE_BBOX)
inherited::getBoundingBox(action);
}
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#include <Inventor/SbBox.h>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/misc/SoState.h>
#include <Inventor/nodes/SoText2.h>
#include <Inventor/nodes/SoTransform.h>
#endif
#include "SoFCBoundingBox.h"
using namespace Gui;
SO_NODE_SOURCE(SoFCBoundingBox)
// vertices used to create a box
static const int32_t bBoxVerts[8][3] =
{
{0, 0, 0},
{1, 0, 0},
{1, 1, 0},
{0, 1, 0},
{0, 0, 1},
{1, 0, 1},
{1, 1, 1},
{0, 1, 1}
};
// indexes used to create the edges
static const int32_t bBoxEdges[36] =
{
0,1,-1, 1,2,-1, 2,3,-1, 3,0,-1,
4,5,-1, 5,6,-1, 6,7,-1, 7,4,-1,
0,4,-1, 1,5,-1, 2,6,-1, 3,7,-1
};
void SoFCBoundingBox::initClass ()
{
SO_NODE_INIT_CLASS(SoFCBoundingBox, SoShape, "Shape");
}
SoFCBoundingBox::SoFCBoundingBox ()
{
SO_NODE_CONSTRUCTOR(SoFCBoundingBox);
SO_NODE_ADD_FIELD(minBounds, (-1.0, -1.0, -1.0));
SO_NODE_ADD_FIELD(maxBounds, ( 1.0, 1.0, 1.0));
SO_NODE_ADD_FIELD(coordsOn, (true));
SO_NODE_ADD_FIELD(dimensionsOn, (true));
root = new SoSeparator();
auto bboxSep = new SoSeparator();
bboxCoords = new SoCoordinate3();
bboxCoords->point.setNum(8);
bboxSep->addChild(bboxCoords);
root->addChild(bboxSep);
// the lines of the box
bboxLines = new SoIndexedLineSet();
bboxLines->coordIndex.setNum(36);
bboxLines->coordIndex.setValues(0, 36, bBoxEdges);
bboxSep->addChild(bboxLines);
// create the text nodes, including a transform for each vertice offset
textSep = new SoSeparator();
for (int i = 0; i < 8; i++) {
auto temp = new SoSeparator();
auto trans = new SoTransform();
temp->addChild(trans);
auto text = new SoText2();
text->justification.setValue(SoText2::CENTER);
temp->addChild(text);
textSep->addChild(temp);
}
// create the text nodes, including a transform for each dimension
dimSep = new SoSeparator();
for (int i = 0; i < 3; i++) {
auto temp = new SoSeparator();
auto trans = new SoTransform();
temp->addChild(trans);
auto text = new SoText2();
text->justification.setValue(SoText2::CENTER);
temp->addChild(text);
dimSep->addChild(temp);
}
root->addChild(textSep);
root->addChild(dimSep);
root->ref();
}
SoFCBoundingBox::~SoFCBoundingBox ()
{
root->unref();
}
void SoFCBoundingBox::GLRender (SoGLRenderAction *action)
{
SbVec3f corner[2], ctr, *vptr;
SbBool coord, dimension;
// grab the current state
//SoState *state = action->getState();
if (!shouldGLRender(action))
return;
// get the latest values from the fields
corner[0] = minBounds.getValue();
corner[1] = maxBounds.getValue();
coord = coordsOn.getValue();
dimension = dimensionsOn.getValue();
// set the coordinates for the LineSet to point to
vptr = bboxCoords->point.startEditing();
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 3; j++) {
vptr[i][j] = corner[bBoxVerts[i][j]][j];
}
}
// if coord is true then set the text nodes
if (coord) {
ctr = (corner[1] - corner[0]) / 2.0f;
for (int i = 0; i < 8; i++) {
// create the string for the text
std::stringstream str;
str.precision(2);
str.setf(std::ios::fixed | std::ios::showpoint);
str << "(" << vptr[i][0] << "," << vptr[i][1] << "," << vptr[i][2] << ")";
SoSeparator *sep = static_cast<SoSeparator *>(textSep->getChild(i));
SoTransform *trans = static_cast<SoTransform *>(sep->getChild(0));
trans->translation.setValue(vptr[i].getValue());
SoText2* t = static_cast<SoText2 *>(sep->getChild(1));
t->string.setValue(str.str().c_str());
}
textSep->ref();
if (root->findChild(textSep) < 0)
root->addChild(textSep);
} else {
if (root->findChild(textSep) >= 0)
root->removeChild(textSep);
}
// if dimension is true then set the text nodes
if (dimension) {
ctr = (corner[1] - corner[0]) / 2.0f;
for (int i = 0; i < 3; i++) {
// create the string for the text
std::stringstream str;
str.precision(2);
str.setf(std::ios::fixed | std::ios::showpoint);
str << (2.0f * ctr[i]);
SoSeparator *sep = static_cast<SoSeparator *>(dimSep->getChild(i));
SoTransform *trans = static_cast<SoTransform *>(sep->getChild(0));
SbVec3f point = corner[0];
point[i] += ctr[i];
trans->translation.setValue(point.getValue());
SoText2* t = static_cast<SoText2 *>(sep->getChild(1));
t->string.setValue(str.str().c_str());
}
dimSep->ref();
if (root->findChild(dimSep) < 0)
root->addChild(dimSep);
} else {
if (root->findChild(dimSep) >= 0)
root->removeChild(dimSep);
}
bboxCoords->point.finishEditing();
// Avoid shading
SoState * state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
root->GLRender(action);
state->pop();
}
void SoFCBoundingBox::generatePrimitives (SoAction * /*action*/)
{
}
void SoFCBoundingBox::computeBBox (SoAction * /*action*/, SbBox3f &box, SbVec3f &center)
{
center = (minBounds.getValue() + maxBounds.getValue()) / 2.0f;
box.setBounds(minBounds.getValue(), maxBounds.getValue());
}
void SoFCBoundingBox::finish()
{
atexit_cleanup();
}
// ---------------------------------------------------------------
SO_NODE_SOURCE(SoSkipBoundingGroup)
/*!
Constructor.
*/
SoSkipBoundingGroup::SoSkipBoundingGroup()
{
SO_NODE_CONSTRUCTOR(SoSkipBoundingGroup);
SO_NODE_ADD_FIELD(mode, (INCLUDE_BBOX));
SO_NODE_DEFINE_ENUM_VALUE(Modes, INCLUDE_BBOX);
SO_NODE_DEFINE_ENUM_VALUE(Modes, EXCLUDE_BBOX);
SO_NODE_SET_SF_ENUM_TYPE (mode, Modes);
}
/*!
Destructor.
*/
SoSkipBoundingGroup::~SoSkipBoundingGroup() = default;
void
SoSkipBoundingGroup::initClass()
{
SO_NODE_INIT_CLASS(SoSkipBoundingGroup,SoGroup,"Group");
}
void SoSkipBoundingGroup::finish()
{
atexit_cleanup();
}
void SoSkipBoundingGroup::getBoundingBox(SoGetBoundingBoxAction *action)
{
if (mode.getValue() == INCLUDE_BBOX)
inherited::getBoundingBox(action);
}

View File

@@ -1,106 +1,106 @@
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef COIN_SOFCBOUNDINGBOX_H
#define COIN_SOFCBOUNDINGBOX_H
#include <Inventor/actions/SoAction.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/fields/SoSFVec3f.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoShape.h>
#include <FCGlobal.h>
namespace Gui {
/**
* A subclass of SoShape used to create an axis aligned wire frame box based
* on the minBounds and maxBounds fields. The class also has a field which
* can be toggled on or off for displaying text coordinate labels at the
* vertices of the box.
* @note Original source are taken from http://www.wheatchex.com/projects/openinventor/bbox/BoundingBox.h and
* http://www.wheatchex.com/projects/openinventor/bbox/BoundingBox.cpp
* @date November 12th, 2001
* @author Josh Grant
*/
class GuiExport SoFCBoundingBox : public SoShape {
using inherited = SoShape;
SO_NODE_HEADER(Gui::SoFCBoundingBox);
public:
static void initClass();
static void finish();
public:
SoFCBoundingBox();
SoSFVec3f minBounds; /**< minimum box coordinates */
SoSFVec3f maxBounds; /**< maximum box coordinates */
SoSFBool coordsOn; /**< If true, the coordinates are displayed at each vertex */
SoSFBool dimensionsOn; /**< If true, the dimensions are displayed in x,y and z direction */
protected:
~SoFCBoundingBox() override;
void GLRender(SoGLRenderAction *action) override;
void generatePrimitives (SoAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
private:
SoSeparator *root, *textSep, *dimSep;
SoCoordinate3 *bboxCoords;
SoIndexedLineSet *bboxLines;
};
/**
* This is a special group node which must be defined to ignore bounding box actions.
* @author Werner Mayer
*/
class GuiExport SoSkipBoundingGroup : public SoGroup {
using inherited = SoGroup;
SO_NODE_HEADER(Gui::SoSkipBoundingGroup);
public:
static void initClass();
static void finish();
SoSkipBoundingGroup();
enum Modes {
INCLUDE_BBOX, EXCLUDE_BBOX
};
SoSFEnum mode;
void getBoundingBox(SoGetBoundingBoxAction *action) override;
protected:
~SoSkipBoundingGroup() override;
};
} // namespace Gui
#endif //COIN_SOFCBOUNDINGBOX_H
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef COIN_SOFCBOUNDINGBOX_H
#define COIN_SOFCBOUNDINGBOX_H
#include <Inventor/actions/SoAction.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/fields/SoSFVec3f.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoShape.h>
#include <FCGlobal.h>
namespace Gui {
/**
* A subclass of SoShape used to create an axis aligned wire frame box based
* on the minBounds and maxBounds fields. The class also has a field which
* can be toggled on or off for displaying text coordinate labels at the
* vertices of the box.
* @note Original source are taken from http://www.wheatchex.com/projects/openinventor/bbox/BoundingBox.h and
* http://www.wheatchex.com/projects/openinventor/bbox/BoundingBox.cpp
* @date November 12th, 2001
* @author Josh Grant
*/
class GuiExport SoFCBoundingBox : public SoShape {
using inherited = SoShape;
SO_NODE_HEADER(Gui::SoFCBoundingBox);
public:
static void initClass();
static void finish();
public:
SoFCBoundingBox();
SoSFVec3f minBounds; /**< minimum box coordinates */
SoSFVec3f maxBounds; /**< maximum box coordinates */
SoSFBool coordsOn; /**< If true, the coordinates are displayed at each vertex */
SoSFBool dimensionsOn; /**< If true, the dimensions are displayed in x,y and z direction */
protected:
~SoFCBoundingBox() override;
void GLRender(SoGLRenderAction *action) override;
void generatePrimitives (SoAction *action) override;
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override;
private:
SoSeparator *root, *textSep, *dimSep;
SoCoordinate3 *bboxCoords;
SoIndexedLineSet *bboxLines;
};
/**
* This is a special group node which must be defined to ignore bounding box actions.
* @author Werner Mayer
*/
class GuiExport SoSkipBoundingGroup : public SoGroup {
using inherited = SoGroup;
SO_NODE_HEADER(Gui::SoSkipBoundingGroup);
public:
static void initClass();
static void finish();
SoSkipBoundingGroup();
enum Modes {
INCLUDE_BBOX, EXCLUDE_BBOX
};
SoSFEnum mode;
void getBoundingBox(SoGetBoundingBoxAction *action) override;
protected:
~SoSkipBoundingGroup() override;
};
} // namespace Gui
#endif //COIN_SOFCBOUNDINGBOX_H

View File

@@ -27,8 +27,8 @@
# include <QApplication>
#endif
#include "Inventor/SoMouseWheelEvent.h"
#include "NavigationStyle.h"
#include "SoMouseWheelEvent.h"
#include "View3DInventorViewer.h"

View File

@@ -47,18 +47,17 @@
#include <App/Document.h>
#include <App/GeoFeature.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Document.h>
#include <Gui/Inventor/SoAxisCrossKit.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/SplitView3DInventor.h>
#include <Gui/Tools.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/ViewProviderGeometryObject.h>
#include <Gui/WaitCursor.h>
#include "ManualAlignment.h"
#include "BitmapFactory.h"
#include "SoAxisCrossKit.h"
#include "Tools.h"
using namespace Gui;

View File

@@ -43,11 +43,11 @@
#include "NavigationStyle.h"
#include "Application.h"
#include "Inventor/SoMouseWheelEvent.h"
#include "MenuManager.h"
#include "MouseSelection.h"
#include "NavigationAnimator.h"
#include "NavigationAnimation.h"
#include "SoMouseWheelEvent.h"
#include "View3DInventorViewer.h"
using namespace Gui;

View File

@@ -45,8 +45,8 @@
#include <QMouseEvent>
#include <QWheelEvent>
#include <Gui/SoMouseWheelEvent.h>
#include <Inventor/SbVec2s.h>
#include <Inventor/SoMouseWheelEvent.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/events/SoEvents.h>

View File

@@ -51,7 +51,7 @@
#include <Base/Quantity.h>
#include "SoFCCSysDragger.h"
#include "So3DAnnotation.h"
#include "Inventor/So3DAnnotation.h"
#include "MainWindow.h"
#include "SoFCDB.h"

View File

@@ -35,8 +35,6 @@
#include <Inventor/sensors/SoIdleSensor.h>
#include <FCGlobal.h>
#include "So3DAnnotation.h"
class SoCamera;
namespace Gui

View File

@@ -53,10 +53,6 @@
#include "GestureNavigationStyle.h"
#include "NavigationStyle.h"
#include "SelectionObject.h"
#include "So3DAnnotation.h"
#include "SoAxisCrossKit.h"
#include "SoFCBackgroundGradient.h"
#include "SoFCBoundingBox.h"
#include "SoFCColorBar.h"
#include "SoFCColorGradient.h"
#include "SoFCColorLegend.h"
@@ -67,13 +63,17 @@
#include "SoFCUnifiedSelection.h"
#include "SoFCVectorizeSVGAction.h"
#include "SoFCVectorizeU3DAction.h"
#include "SoMouseWheelEvent.h"
#include "SoTextLabel.h"
#include "SoDatumLabel.h"
#include "Inventor/MarkerBitmaps.h"
#include "Inventor/SmSwitchboard.h"
#include "Inventor/So3DAnnotation.h"
#include "Inventor/SoAutoZoomTranslation.h"
#include "Inventor/SoAxisCrossKit.h"
#include "Inventor/SoDrawingGrid.h"
#include "Inventor/SoFCBackgroundGradient.h"
#include "Inventor/SoFCBoundingBox.h"
#include "Inventor/SoMouseWheelEvent.h"
#include "propertyeditor/PropertyItem.h"
#include "ArcEngine.h"

View File

@@ -98,14 +98,14 @@
#include "Application.h"
#include "Document.h"
#include "GLPainter.h"
#include "Inventor/SoAxisCrossKit.h"
#include "Inventor/SoFCBackgroundGradient.h"
#include "Inventor/SoFCBoundingBox.h"
#include "MainWindow.h"
#include "Multisample.h"
#include "NaviCube.h"
#include "NavigationStyle.h"
#include "Selection.h"
#include "SoAxisCrossKit.h"
#include "SoFCBackgroundGradient.h"
#include "SoFCBoundingBox.h"
#include "SoFCDB.h"
#include "SoFCInteractiveElement.h"
#include "SoFCOffscreenRenderer.h"

View File

@@ -55,6 +55,7 @@
#include "Camera.h"
#include "Document.h"
#include "Inventor/SoMouseWheelEvent.h"
#include "NavigationStyle.h"
#include "PythonWrapper.h"
#include "SoFCDB.h"
@@ -62,7 +63,6 @@
#include "SoFCSelectionAction.h"
#include "SoFCVectorizeSVGAction.h"
#include "SoFCVectorizeU3DAction.h"
#include "SoMouseWheelEvent.h"
#include "View3DInventor.h"
#include "View3DInventorViewer.h"
#include "ViewProviderDocumentObject.h"

View File

@@ -41,7 +41,7 @@
#include <Base/Exception.h>
#include <Base/Matrix.h>
#include "SoMouseWheelEvent.h"
#include "Inventor/SoMouseWheelEvent.h"
#include "ViewProvider.h"
#include "ActionFunction.h"
#include "Application.h"

View File

@@ -32,18 +32,17 @@
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoFont.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSwitch.h>
#endif
#include <Inventor/nodes/SoResetTransform.h>
#include <App/GeoFeature.h>
#include <App/PropertyGeo.h>
#include "Application.h"
#include "Document.h"
#include "SoFCBoundingBox.h"
#include "Inventor/SoFCBoundingBox.h"
#include "SoFCSelection.h"
#include "View3DInventorViewer.h"
#include "ViewProviderGeometryObject.h"

View File

@@ -44,8 +44,8 @@
#include <Base/Stream.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/SoAxisCrossKit.h>
#include <Gui/SoFCBoundingBox.h>
#include <Gui/Inventor/SoAxisCrossKit.h>
#include <Gui/Inventor/SoFCBoundingBox.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Mod/CAM/App/FeaturePath.h>
#include <Mod/CAM/App/PathSegmentWalker.h>

View File

@@ -41,7 +41,7 @@
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Reader.h>
#include <Gui/SoFCBoundingBox.h>
#include <Gui/Inventor/SoFCBoundingBox.h>
#include "ViewProvider2DObject.h"

View File

@@ -50,7 +50,7 @@
#include <Gui/ViewProvider.h>
#include <Gui/ViewProviderDocumentObject.h>
#include <Gui/SoFCBoundingBox.h>
#include <Gui/Inventor/SoFCBoundingBox.h>
#include "ViewProviderGridExtension.h"

View File

@@ -44,7 +44,7 @@
#include <Base/Exception.h>
#include <Gui/Inventor/MarkerBitmaps.h>
#include <Gui/SoFCBoundingBox.h>
#include <Gui/Inventor/SoFCBoundingBox.h>
#include <Mod/Sketcher/App/Constraint.h>
#include <Mod/Sketcher/App/GeoList.h>