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
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGGL.h>
00049
00050 #include "OSGDrawActionBase.h"
00051 #include "OSGWindow.h"
00052
00053 #include "OSGLineChunk.h"
00054
00055 OSG_USING_NAMESPACE
00056
00057
00058
00059
00060
00073
00074
00075
00076
00077 StateChunkClass LineChunk::_class("Line");
00078
00079
00080
00081
00082
00083 void LineChunk::initMethod (void)
00084 {
00085 Inherited::initMethod();
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 LineChunk::LineChunk(void) :
00100 Inherited()
00101 {
00102 }
00103
00104 LineChunk::LineChunk(const LineChunk &source) :
00105 Inherited(source)
00106 {
00107 }
00108
00109 LineChunk::~LineChunk(void)
00110 {
00111 }
00112
00113
00114
00115 const StateChunkClass *LineChunk::getClass(void) const
00116 {
00117 return &_class;
00118 }
00119
00120
00121
00122 void LineChunk::changed(BitVector whichField, UInt32 origin)
00123 {
00124 Inherited::changed(whichField, origin);
00125 }
00126
00127
00128
00129 void LineChunk::dump( UInt32 ,
00130 const BitVector ) const
00131 {
00132 SLOG << "Dump LineChunk NI" << std::endl;
00133 }
00134
00135
00136
00137
00138 void LineChunk::activate(DrawActionBase *, UInt32)
00139 {
00140 if(_sfWidth.getValue() != 1)
00141 {
00142 glLineWidth(_sfWidth.getValue());
00143 }
00144
00145 if(_sfStipplePattern.getValue() != 0xffffu)
00146 {
00147 glLineStipple(_sfStippleRepeat.getValue(),
00148 _sfStipplePattern.getValue());
00149 glEnable(GL_LINE_STIPPLE);
00150 }
00151
00152 if(_sfSmooth.getValue())
00153 {
00154 glEnable(GL_LINE_SMOOTH);
00155 }
00156 }
00157
00158 void LineChunk::changeFrom( DrawActionBase *act, StateChunk * old_chunk, UInt32 index )
00159 {
00160 old_chunk->deactivate( act, index );
00161 activate( act, index );
00162 }
00163
00164 void LineChunk::deactivate ( DrawActionBase *, UInt32 )
00165 {
00166 if(_sfWidth.getValue() != 1)
00167 {
00168 glLineWidth(1);
00169 }
00170
00171 if(_sfStipplePattern.getValue() != 0xffffu)
00172 {
00173 glDisable(GL_LINE_STIPPLE);
00174 }
00175
00176 if(_sfSmooth.getValue())
00177 {
00178 glDisable(GL_LINE_SMOOTH);
00179 }
00180 }
00181
00182
00183
00184 Real32 LineChunk::switchCost(StateChunk *)
00185 {
00186 return 0;
00187 }
00188
00192 bool LineChunk::operator < (const StateChunk &other) const
00193 {
00194 return this < &other;
00195 }
00196
00200 bool LineChunk::operator == (const StateChunk &other) const
00201 {
00202 LineChunk const *tother = dynamic_cast<LineChunk const*>(&other);
00203
00204 if(!tother)
00205 return false;
00206
00207 if(tother == this)
00208 return true;
00209
00210 if(getWidth() != tother->getWidth() ||
00211 getStipplePattern() != tother->getStipplePattern() ||
00212 getSmooth() != tother->getSmooth() )
00213 return false;
00214
00215 return true;
00216 }
00217
00221 bool LineChunk::operator != (const StateChunk &other) const
00222 {
00223 return ! (*this == other);
00224 }
00225
00226
00227
00228
00229
00230 #ifdef __sgi
00231 #pragma set woff 1174
00232 #endif
00233
00234 #ifdef OSG_LINUX_ICC
00235 #pragma warning( disable : 177 )
00236 #endif
00237
00238 namespace
00239 {
00240 static char cvsid_cpp[] = "@(#)$Id: $";
00241 static char cvsid_hpp[] = OSGLINECHUNK_HEADER_CVSID;
00242 static char cvsid_inl[] = OSGLINECHUNK_INLINE_CVSID;
00243 }
00244
00245 #ifdef __sgi
00246 #pragma reset woff 1174
00247 #endif
00248