00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <stdlib.h>
00040 #include <stdio.h>
00041
00042 #include <OSGConfig.h>
00043
00044 #include "OSGSwitch.h"
00045
00046 #include <OSGDrawAction.h>
00047 #include <OSGRenderAction.h>
00048 #include <OSGIntersectAction.h>
00049
00050 OSG_USING_NAMESPACE
00051
00055
00056
00057
00058 void Switch::changed(BitVector whichField, UInt32 origin)
00059 {
00060 Inherited::changed(whichField, origin);
00061 }
00062
00063
00064
00065
00066 void Switch::dump( UInt32 OSG_CHECK_ARG(uiIndent),
00067 const BitVector OSG_CHECK_ARG(bvFlags )) const
00068 {
00069 SLOG << "Dump Switch NI" << std::endl;
00070 }
00071
00072
00073
00074
00075 Switch::Switch(void) :
00076 Inherited()
00077 {
00078 }
00079
00080 Switch::Switch(const Switch &source) :
00081 Inherited(source)
00082 {
00083 }
00084
00085
00086
00087
00088 Switch::~Switch(void)
00089 {
00090 }
00091
00092
00093
00094
00095 Action::ResultE Switch::draw(Action *action)
00096 {
00097 Action::ResultE returnValue = Action::Continue;
00098
00099 DrawActionBase *da = dynamic_cast<DrawActionBase *>(action);
00100
00101 if((getChoice() >= 0 ) &&
00102 (UInt32(getChoice()) < action->getNNodes()))
00103 {
00104 da->useNodeList();
00105
00106 if(da->isVisible(action->getNode(getChoice()).getCPtr()))
00107 {
00108 da->addNode(action->getNode(getChoice()));
00109 }
00110 }
00111 else if(getChoice() == ALL)
00112 {
00113 if(da->selectVisibles() == 0)
00114 returnValue = Action::Skip;
00115 }
00116 else
00117 {
00118 returnValue = Action::Skip;
00119 }
00120
00121 return returnValue;
00122 }
00123
00124 Action::ResultE Switch::intersect(Action *action)
00125 {
00126 Action::ResultE returnValue = Action::Continue;
00127
00128 IntersectAction *da = dynamic_cast<IntersectAction *>(action);
00129
00130 if((getChoice() >= 0 ) &&
00131 (UInt32(getChoice()) < action->getNNodes()))
00132 {
00133 da->addNode(action->getNode(getChoice()));
00134 }
00135 else if(getChoice() == ALL)
00136 {
00137 returnValue = Action::Continue;
00138 }
00139 else
00140 {
00141 returnValue = Action::Skip;
00142 }
00143
00144 return returnValue;
00145 }
00146
00147
00148
00149
00150 void Switch::initMethod(void)
00151 {
00152 DrawAction::registerEnterDefault(
00153 getClassType(),
00154 osgTypedMethodFunctor2BaseCPtrRef<Action::ResultE,
00155 SwitchPtr ,
00156 CNodePtr ,
00157 Action *>(&Switch::draw));
00158
00159 RenderAction::registerEnterDefault(
00160 getClassType(),
00161 osgTypedMethodFunctor2BaseCPtrRef<Action::ResultE,
00162 SwitchPtr ,
00163 CNodePtr ,
00164 Action *>(&Switch::draw));
00165
00166 IntersectAction::registerEnterDefault(
00167 getClassType(),
00168 osgTypedMethodFunctor2BaseCPtrRef<Action::ResultE,
00169 SwitchPtr ,
00170 CNodePtr ,
00171 Action *>(&Switch::intersect));
00172 }
00173
00174
00175
00176
00177
00178 #ifdef __sgi
00179 #pragma set woff 1174
00180 #endif
00181
00182 #ifdef OSG_LINUX_ICC
00183 #pragma warning( disable : 177 )
00184 #endif
00185
00186 namespace
00187 {
00188 static Char8 cvsid_cpp[] = "@(#)$Id: $";
00189 static Char8 cvsid_hpp[] = OSGSWITCH_HEADER_CVSID;
00190 static Char8 cvsid_inl[] = OSGSWITCH_INLINE_CVSID;
00191 }