Studierstube 4 Documentation Project

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

SoContextReport.cpp

Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (C) 2000-2003  Vienna University of Technology
00003  *
00004  * This framework is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This framework is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this framework; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * For further information please contact Dieter Schmalstieg under
00019  * <schmalstieg@ims.tuwien.ac.at> or write to Dieter Schmalstieg,
00020  * Vienna University of Technology, Favoritenstr. 9-11/188, A1040 Vienna,
00021  * Austria.
00022  * ========================================================================
00023  * PROJECT: Studierstube
00024  * ======================================================================== */
00031  /* ======================================================================= */
00032 
00033 #include <Inventor/actions/SoCallbackAction.h>
00034 #include <Inventor/actions/SoGLRenderAction.h>
00035 #include <Inventor/actions/SoGetBoundingBoxAction.h>
00036 #include <Inventor/actions/SoGetMatrixAction.h>
00037 #include <Inventor/actions/SoHandleEventAction.h>
00038 #include <Inventor/actions/SoPickAction.h>
00039 #include <Inventor/actions/SoSearchAction.h>
00040 #ifdef __COIN__
00041 #include <Inventor/actions/SoAudioRenderAction.h>
00042 #endif
00043 
00044 #include <stb/components/starlight/SoContextElement.h>
00045 #include <stb/components/starlight/SoContextReport.h>
00046 
00047 
00048 SO_NODE_SOURCE(SoContextReport);
00049 
00050 void SoContextReport::initClass()
00051 {
00052     SO_NODE_INIT_CLASS(SoContextReport, SoNode, "Node");
00053 
00054     // explicitly add to the SoHandle3DEventAction method table
00055     // SoHandle3DEventAction::addMethod(SoContextReport::getClassTypeId(), SoContextReport::callDoAction);
00056 #ifdef __COIN__
00057     SoAudioRenderAction::addMethod(SoContextReport::getClassTypeId(), SoContextReport::callDoAction);
00058 #endif
00059 }
00060 
00061 // constructor
00062 
00063 SoContextReport::SoContextReport()
00064 {
00065     SO_NODE_CONSTRUCTOR(SoContextReport);
00066 
00067     SO_NODE_ADD_FIELD(index, (""));
00068     SO_NODE_ADD_FIELD(value, (""));
00069     SO_NODE_ADD_FIELD(defaultValue, (""));
00070 
00071     index.deleteValues(0);
00072     value.deleteValues(0);
00073     defaultValue.deleteValues(0);
00074 
00075     index.setDefault(TRUE);
00076     value.setDefault(TRUE);
00077     defaultValue.setDefault(TRUE);
00078 
00079     isBuiltIn = TRUE;
00080 }
00081 
00082 SoContextReport::~SoContextReport()
00083 {
00084 }
00085 
00086 void SoContextReport::GLRender(SoGLRenderAction *action)
00087 {
00088     doAction(action);
00089 }
00090 
00091 void SoContextReport::callback(SoCallbackAction *action)
00092 {
00093     doAction(action);
00094 }
00095 
00096 void SoContextReport::getBoundingBox(SoGetBoundingBoxAction *action)
00097 {
00098     doAction(action);
00099 }
00100 
00101 void SoContextReport::handleEvent(SoHandleEventAction *action)
00102 {
00103     doAction(action);
00104 }
00105 
00106 void SoContextReport::pick(SoPickAction *action)
00107 {
00108     doAction(action);
00109 }
00110 
00111 void SoContextReport::getMatrix(SoGetMatrixAction *action)
00112 {
00113     doAction(action);
00114 }
00115 
00116 void SoContextReport::search(SoSearchAction *action)
00117 {
00118     doAction(action);
00119     SoNode::search(action);
00120 }
00121 
00122 void SoContextReport::callDoAction(SoAction * action, SoNode * node)
00123 {
00124     node->doAction( action );
00125 }
00126 
00127 void SoContextReport::doAction(SoAction *action)
00128 {
00129     int i;
00130     SoState * state = action->getState();
00131 
00132     if( index.getNum() == value.getNum() )
00133     {
00134         for( i = 0; i < index.getNum(); i++ )
00135         {
00136             if( SoContextElement::isSet(state, index[i]) == TRUE )
00137             {
00138                 if( SoContextElement::get(state, index[i]) != value[i] )
00139                     break;
00140             }
00141             else
00142             {
00143                 if( defaultValue.getNum() < i )
00144                 {
00145                     if( value[i] != "" )
00146                         break;
00147                 }
00148                 else
00149                 {
00150                     if( value[i] != defaultValue[i] )
00151                         break;
00152                 }
00153             }
00154         }
00155         // if all are equal then do nothing
00156         if( i == index.getNum())
00157             return;
00158     }
00159     // otherwise set value from the context
00160     value.setNum( index.getNum());
00161     SbString * data = value.startEditing();
00162     for( i = 0; i < index.getNum(); i++ )
00163     {
00164         if( SoContextElement::isSet(state, index[i]) == TRUE )
00165         {
00166             data[i] = SoContextElement::get(state, index[i]);
00167         }
00168         else
00169         {
00170             data[i] = ( defaultValue.getNum() < i )?(""):(defaultValue[i]);
00171         }
00172     }
00173     value.finishEditing();
00174 }
 This page was generated at Wed Oct 27 13:00:09 2010 for Studierstube 4 by Doxygen.
 If you have any comments, please send a message to schmalstieg#icg.tu-graz.ac.at.
www.studierstube.org