1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
50 #include "OSGWindow.h"
52 #include "OSGLineChunk.h"
56 // Documentation for this class is emited in the
57 // OSGLineChunkBase.cpp file.
58 // To modify it, please change the .fcd file (OSGLineChunk.fcd) and
59 // regenerate the base file.
61 /***************************************************************************\
63 \***************************************************************************/
65 StateChunkClass
LineChunk::_class("Line", 1, 50);
67 /***************************************************************************\
69 \***************************************************************************/
71 void LineChunk::initMethod(InitPhase ePhase
)
73 Inherited::initMethod(ePhase
);
76 /***************************************************************************\
78 \***************************************************************************/
80 /*-------------------------------------------------------------------------*\
82 \*-------------------------------------------------------------------------*/
84 /*------------- constructors & destructors --------------------------------*/
87 LineChunk::LineChunk(void) :
92 LineChunk::LineChunk(const LineChunk
&source
) :
97 LineChunk::~LineChunk(void)
101 /*------------------------- Chunk Class Access ---------------------------*/
103 const StateChunkClass
*LineChunk::getClass(void) const
108 /*------------------------------- Sync -----------------------------------*/
110 void LineChunk::changed(ConstFieldMaskArg whichField
,
114 Inherited::changed(whichField
, origin
, details
);
117 /*------------------------------ Output ----------------------------------*/
119 void LineChunk::dump( UInt32
,
120 const BitVector
) const
122 SLOG
<< "Dump LineChunk NI" << std::endl
;
126 /*------------------------------ State ------------------------------------*/
128 void LineChunk::activate(DrawEnv
*pEnv
, UInt32
)
130 pEnv
->incNumChunkChanges();
132 if(_sfWidth
.getValue() != 1)
134 glLineWidth(_sfWidth
.getValue());
137 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
138 if(_sfStipplePattern
.getValue() != 0xffffu
)
140 glLineStipple(_sfStippleRepeat
.getValue(),
141 _sfStipplePattern
.getValue());
142 glEnable(GL_LINE_STIPPLE
);
147 if(_sfSmooth
.getValue())
149 glEnable(GL_LINE_SMOOTH
);
154 void LineChunk::changeFrom(DrawEnv
*pEnv
,
155 StateChunk
*old_chunk
,
158 old_chunk
->deactivate(pEnv
, index
);
160 activate(pEnv
, index
);
163 void LineChunk::deactivate(DrawEnv
*, UInt32
)
165 if(_sfWidth
.getValue() != 1)
170 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
171 if(_sfStipplePattern
.getValue() != 0xffffu
)
173 glDisable(GL_LINE_STIPPLE
);
178 if(_sfSmooth
.getValue())
180 glDisable(GL_LINE_SMOOTH
);
185 /*-------------------------- Comparison -----------------------------------*/
187 Real32
LineChunk::switchCost(StateChunk
*)
192 /** \brief assignment
195 bool LineChunk::operator <(const StateChunk
&other
) const
197 return this < &other
;
203 bool LineChunk::operator ==(const StateChunk
&other
) const
205 LineChunk
const *tother
= dynamic_cast<LineChunk
const*>(&other
);
213 if(getWidth() != tother
->getWidth() ||
214 getStipplePattern() != tother
->getStipplePattern() ||
215 getSmooth() != tother
->getSmooth() )
226 bool LineChunk::operator != (const StateChunk
&other
) const
228 return ! (*this == other
);