SoContextReport.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00055
00056 #ifdef __COIN__
00057 SoAudioRenderAction::addMethod(SoContextReport::getClassTypeId(), SoContextReport::callDoAction);
00058 #endif
00059 }
00060
00061
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
00156 if( i == index.getNum())
00157 return;
00158 }
00159
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 }