1
/**************************************************************************\
3
* This file is part of the Coin 3D visualization library.
4
* Copyright (C) 1998-2005 by Systems in Motion. All rights reserved.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* ("GPL") version 2 as published by the Free Software Foundation.
9
* See the file LICENSE.GPL at the root directory of this source
10
* distribution for additional information about the GNU GPL.
12
* For using Coin with software that can not be combined with the GNU
13
* GPL, and for taking advantage of the additional benefits of our
14
* support services, please contact Systems in Motion about acquiring
15
* a Coin Professional Edition License.
17
* See <URL:http://www.coin3d.org/> for more information.
19
* Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
20
* <URL:http://www.sim.no/>.
22
\**************************************************************************/
26
#include <Inventor/errors/SoDebugError.h>
27
#include <Inventor/actions/SoGLRenderAction.h>
28
#include <Inventor/actions/SoPickAction.h>
29
#include <Inventor/actions/SoRayPickAction.h>
30
#include <Inventor/actions/SoGetMatrixAction.h>
31
#include <Inventor/elements/SoModelMatrixElement.h>
32
#include <Inventor/SoPath.h>
34
#include <Inventor/Qt/nodes/SoGuiPane.h>
35
#include <Inventor/Qt/nodes/SoGuiPosition.h>
37
// *************************************************************************
39
SO_NODE_SOURCE(SoGuiPosition);
42
SoGuiPosition::initClass(void)
44
SO_NODE_INIT_CLASS(SoGuiPosition, SoTransformation, "Transformation");
47
SoGuiPosition::SoGuiPosition(void)
49
SO_NODE_CONSTRUCTOR(SoGuiPosition);
50
SO_NODE_ADD_FIELD(position, (SbVec3f(0.0f, 0.0f, 0.0f)));
53
SoGuiPosition::~SoGuiPosition(void)
58
SoGuiPosition::doAction(SoAction * action)
61
// SoDebugError::postInfo("SoGuiPosition::doAction", "invoked by %s", action->getTypeId().getName().getString());
62
SoGuiPane * pane = NULL;
63
const SoFullPath * path = (const SoFullPath *) action->getCurPath();
64
for ( i = path->getLength() - 1; (i >= 0) && (pane == NULL); i-- ) {
65
SoNode * node = path->getNode(i);
67
if ( node->isOfType(SoGuiPane::getClassTypeId()) ) pane = (SoGuiPane *) node;
70
SoDebugError::postInfo("SoGuiPosition::GLRender", "SoGuiPosition only works below an SoGuiPane node");
73
pane->moveTo(action->getState(), this->position.getValue());
77
SoGuiPosition::GLRender(SoGLRenderAction * action)
79
this->doAction(action);
83
SoGuiPosition::pick(SoPickAction * action)
85
this->doAction(action);
89
SoGuiPosition::rayPick(SoRayPickAction * action)
91
this->doAction(action);
95
SoGuiPosition::getMatrix(SoGetMatrixAction * action)
97
SoDebugError::postInfo("SoGuiPosition::getMatrix", "invoked");
99
SoGuiPane * pane = NULL;
100
const SoFullPath * path = (const SoFullPath *) action->getCurPath();
101
for ( i = path->getLength() - 1; (i >= 0) && (pane == NULL); i-- ) {
102
SoNode * node = path->getNode(i);
104
if ( node->isOfType(SoGuiPane::getClassTypeId()) ) pane = (SoGuiPane *) node;
106
if ( pane == NULL ) {
107
SoDebugError::postInfo("SoGuiPosition::getMatrix", "SoGuiPosition only works below an SoGuiPane node");
110
pane->applyMoveTo(action, this->position.getValue());