| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
|
| 3 |
/*************************************************************************** |
| 4 |
* Copyright (c) 2024 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 5 |
* * |
| 6 |
* This file is part of FreeCAD. * |
| 7 |
* * |
| 8 |
* FreeCAD is free software: you can redistribute it and/or modify it * |
| 9 |
* under the terms of the GNU Lesser General Public License as * |
| 10 |
* published by the Free Software Foundation, either version 2.1 of the * |
| 11 |
* License, or (at your option) any later version. * |
| 12 |
* * |
| 13 |
* FreeCAD is distributed in the hope that it will be useful, but * |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 16 |
* Lesser General Public License for more details. * |
| 17 |
* * |
| 18 |
* You should have received a copy of the GNU Lesser General Public * |
| 19 |
* License along with FreeCAD. If not, see * |
| 20 |
* <https://www.gnu.org/licenses/>. * |
| 21 |
* * |
| 22 |
**************************************************************************/ |
| 23 |
|
| 24 |
|
| 25 |
#include <Inventor/actions/SoCallbackAction.h> |
| 26 |
#include <Inventor/actions/SoGetBoundingBoxAction.h> |
| 27 |
#include <Inventor/actions/SoGetPrimitiveCountAction.h> |
| 28 |
#include <Inventor/actions/SoGLRenderAction.h> |
| 29 |
#include <Inventor/actions/SoPickAction.h> |
| 30 |
#include <Inventor/elements/SoModelMatrixElement.h> |
| 31 |
|
| 32 |
#include "SoFCTransform.h" |
| 33 |
|
| 34 |
|
| 35 |
using namespace Gui; |
| 36 |
|
| 37 |
SO_NODE_SOURCE(SoFCTransform) |
| 38 |
|
| 39 |
void SoFCTransform::initClass() |
| 40 |
{ |
| 41 |
SO_NODE_INIT_CLASS(SoFCTransform, SoTransform, "Transform"); |
| 42 |
} |
| 43 |
|
| 44 |
SoFCTransform::SoFCTransform() |
| 45 |
{ |
| 46 |
SO_NODE_CONSTRUCTOR(SoFCTransform); |
| 47 |
} |
| 48 |
|
| 49 |
void SoFCTransform::GLRender(SoGLRenderAction* action) |
| 50 |
{ |
| 51 |
SoFCTransform::doAction(action); |
| 52 |
} |
| 53 |
|
| 54 |
void SoFCTransform::callback(SoCallbackAction* action) |
| 55 |
{ |
| 56 |
SoFCTransform::doAction(action); |
| 57 |
} |
| 58 |
|
| 59 |
void SoFCTransform::pick(SoPickAction* action) |
| 60 |
{ |
| 61 |
SoFCTransform::doAction(action); |
| 62 |
} |
| 63 |
|
| 64 |
void SoFCTransform::getPrimitiveCount(SoGetPrimitiveCountAction* action) |
| 65 |
{ |
| 66 |
SoFCTransform::doAction(action); |
| 67 |
} |
| 68 |
|
| 69 |
void SoFCTransform::getBoundingBox(SoGetBoundingBoxAction* action) |
| 70 |
{ |
| 71 |
SoFCTransform::doAction(action); |
| 72 |
} |
| 73 |
|
| 74 |
void SoFCTransform::doAction(SoAction* action) |
| 75 |
{ |
| 76 |
SbMatrix matrix; |
| 77 |
matrix.setTransform( |
| 78 |
this->translation.getValue(), |
| 79 |
this->rotation.getValue(), |
| 80 |
this->scaleFactor.getValue(), |
| 81 |
this->scaleOrientation.getValue(), |
| 82 |
this->center.getValue() |
| 83 |
); |
| 84 |
|
| 85 |
// This is different to SoTransform::doAction() where model matrix |
| 86 |
// is always set |
| 87 |
if (matrix != SbMatrix::identity()) { |
| 88 |
SoModelMatrixElement::mult(action->getState(), this, matrix); |
| 89 |
} |
| 90 |
} |