Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/database/include/Inventor/elements/SoOverrideElement.h
Go to the documentation of this file.
00001 /*
00002  *
00003  *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  * 
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027  *  Mountain View, CA  94043, or:
00028  * 
00029  *  http://www.sgi.com 
00030  * 
00031  *  For further information regarding this notice, see: 
00032  * 
00033  *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034  *
00035  */
00036 
00037 
00038 /*
00039  * Copyright (C) 1995-96   Silicon Graphics, Inc.
00040  *
00041  _______________________________________________________________________
00042  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00043  |
00044  |   $Revision: 1.1.1.1 $
00045  |
00046  |   Description:
00047  |      This file defines the SoOverrideElement class.
00048  |
00049  |   Author(s)          : Roger Chickering, Gavin Bell
00050  |
00051  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00052  _______________________________________________________________________
00053  */
00054 
00055 #ifndef  _SO_OVERRIDE_ELEMENT
00056 #define  _SO_OVERRIDE_ELEMENT
00057 
00058 #include <Inventor/elements/SoSubElement.h>
00059 
00065 #define SO_GET_OVERRIDE(flag) \
00066     const SoOverrideElement *elt; \
00067     elt = (const SoOverrideElement *) \
00068         getConstElement(state, classStackIndex); \
00069     return elt->flags & flag;
00070 
00074 #define SO_SET_OVERRIDE(flag) \
00075     SoOverrideElement   *elt; \
00076     elt = (SoOverrideElement *)getElement(state, classStackIndex); \
00077     if (override) \
00078         elt->flags |= flag; \
00079     else \
00080         elt->flags &= ~flag;
00081 
00093 
00094 SoEXTENDER class INVENTOR_API SoOverrideElement : public SoElement {
00095 
00096     SO_ELEMENT_HEADER(SoOverrideElement);
00097 
00098     enum {
00099         AMBIENT_COLOR   = 0x1,
00100         COLOR_INDEX     = 0x2,
00101         COMPLEXITY      = 0x4,
00102         COMPLEXITY_TYPE = 0x8,
00103         CREASE_ANGLE    = 0x10,
00104         DIFFUSE_COLOR   = 0x20,
00105         TRANSPARENCY    = 0x20, 
00106         DRAW_STYLE      = 0x40,
00107         EMISSIVE_COLOR  = 0x80,
00108         FONT_NAME       = 0x100,
00109         FONT_SIZE       = 0x200,
00110         LIGHT_MODEL     = 0x400,
00111         LINE_PATTERN    = 0x800,
00112         LINE_WIDTH      = 0x1000,
00113         MATERIAL_BINDING= 0x2000, 
00114         POINT_SIZE      = 0x4000,
00115         PICK_STYLE      = 0x8000,
00116         SHAPE_HINTS     = 0x10000,
00117         SHININESS       = 0x20000,
00118         SPECULAR_COLOR  = 0x40000,
00119         POLYGON_OFFSET  = 0x80000
00120     };
00121 
00122   public:
00124     virtual void        init(SoState *state);
00125 
00127     virtual SbBool      matches(const SoElement *elt) const;
00128 
00131     virtual void        push(SoState *state);
00132 
00136 
00138     static SbBool       getAmbientColorOverride(SoState *state)
00139         { SO_GET_OVERRIDE(AMBIENT_COLOR); }
00140 
00142     static SbBool       getColorIndexOverride(SoState *state)
00143         { SO_GET_OVERRIDE(COLOR_INDEX); }
00144 
00146     static SbBool       getComplexityOverride(SoState *state)
00147         { SO_GET_OVERRIDE(COMPLEXITY); }
00148 
00150     static SbBool       getComplexityTypeOverride(SoState *state)
00151         { SO_GET_OVERRIDE(COMPLEXITY_TYPE); }
00152 
00154     static SbBool       getCreaseAngleOverride(SoState *state)
00155         { SO_GET_OVERRIDE(CREASE_ANGLE); }
00156 
00158     static SbBool       getDiffuseColorOverride(SoState *state)
00159         { SO_GET_OVERRIDE(DIFFUSE_COLOR); }
00160 
00162     static SbBool       getDrawStyleOverride(SoState *state)
00163         { SO_GET_OVERRIDE(DRAW_STYLE); }
00164 
00166     static SbBool       getEmissiveColorOverride(SoState *state)
00167         { SO_GET_OVERRIDE(EMISSIVE_COLOR); }
00168 
00170     static SbBool       getFontNameOverride(SoState *state)
00171         { SO_GET_OVERRIDE(FONT_NAME); }
00172 
00174     static SbBool       getFontSizeOverride(SoState *state)
00175         { SO_GET_OVERRIDE(FONT_SIZE); }
00176 
00178     static SbBool       getLightModelOverride(SoState *state)
00179         { SO_GET_OVERRIDE(LIGHT_MODEL); }
00180 
00182     static SbBool       getLinePatternOverride(SoState *state)
00183         { SO_GET_OVERRIDE(LINE_PATTERN); }
00184 
00186     static SbBool       getLineWidthOverride(SoState *state)
00187         { SO_GET_OVERRIDE(LINE_WIDTH); }
00188         
00190     static SbBool       getMaterialBindingOverride(SoState *state)
00191         { SO_GET_OVERRIDE(MATERIAL_BINDING); }
00192 
00194     static SbBool       getPointSizeOverride(SoState *state)
00195         { SO_GET_OVERRIDE(POINT_SIZE); }
00196 
00198     static SbBool       getPickStyleOverride(SoState *state)
00199         { SO_GET_OVERRIDE(PICK_STYLE); }
00200 
00202     static SbBool       getShapeHintsOverride(SoState *state)
00203         { SO_GET_OVERRIDE(SHAPE_HINTS); }
00204 
00206     static SbBool       getShininessOverride(SoState *state)
00207         { SO_GET_OVERRIDE(SHININESS); }
00208 
00210     static SbBool       getSpecularColorOverride(SoState *state)
00211         { SO_GET_OVERRIDE(SPECULAR_COLOR); }
00212 
00214     static SbBool       getTransparencyOverride(SoState *state)
00215         { SO_GET_OVERRIDE(TRANSPARENCY); }
00216 
00218     static SbBool       getPolygonOffsetOverride(SoState *state)
00219         { SO_GET_OVERRIDE(POLYGON_OFFSET); }
00220 
00224 
00226     static void         setAmbientColorOverride(SoState *state, SoNode *,
00227                                                 SbBool override)
00228         { SO_SET_OVERRIDE(AMBIENT_COLOR); }
00229 
00231     static void         setColorIndexOverride(SoState *state, SoNode *,
00232                                               SbBool override)
00233         { SO_SET_OVERRIDE(COLOR_INDEX); }
00234 
00236     static void         setComplexityOverride(SoState *state, SoNode *,
00237                                               SbBool override)
00238         { SO_SET_OVERRIDE(COMPLEXITY); }
00239     
00241     static void         setComplexityTypeOverride(SoState *state, SoNode *,
00242                                                   SbBool override)
00243         { SO_SET_OVERRIDE(COMPLEXITY_TYPE); }
00244     
00246     static void         setCreaseAngleOverride(SoState *state, SoNode *,
00247                                                SbBool override)
00248         { SO_SET_OVERRIDE(CREASE_ANGLE); }
00249 
00251     static void         setDiffuseColorOverride(SoState *state, SoNode *,
00252                                                 SbBool override);
00253 
00255     static void         setDrawStyleOverride(SoState *state, SoNode *,
00256                                              SbBool override)
00257         { SO_SET_OVERRIDE(DRAW_STYLE); }
00258 
00260     static void         setEmissiveColorOverride(SoState *state, SoNode *,
00261                                                  SbBool override)
00262         { SO_SET_OVERRIDE(EMISSIVE_COLOR); }
00263 
00265     static void         setFontNameOverride(SoState *state, SoNode *,
00266                                             SbBool override)
00267         { SO_SET_OVERRIDE(FONT_NAME); }
00268 
00270     static void         setFontSizeOverride(SoState *state, SoNode *,
00271                                             SbBool override)
00272         { SO_SET_OVERRIDE(FONT_SIZE); }
00273 
00275     static void         setLightModelOverride(SoState *state, SoNode *,
00276                                               SbBool override)
00277         { SO_SET_OVERRIDE(LIGHT_MODEL); }
00278 
00280     static void         setLinePatternOverride(SoState *state, SoNode *,
00281                                                SbBool override)
00282         { SO_SET_OVERRIDE(LINE_PATTERN); }
00283 
00285     static void         setLineWidthOverride(SoState *state, SoNode *,
00286                                              SbBool override)
00287         { SO_SET_OVERRIDE(LINE_WIDTH); }                                     
00288                                              
00290     static void         setMaterialBindingOverride(SoState *state, SoNode *,
00291                                             SbBool override);                                
00292     
00294     static void         setPickStyleOverride(SoState *state, SoNode *,
00295                                             SbBool override)
00296         { SO_SET_OVERRIDE(PICK_STYLE); }
00297     
00299     static void         setPointSizeOverride(SoState *state, SoNode *,
00300                                              SbBool override)
00301         { SO_SET_OVERRIDE(POINT_SIZE); }
00302 
00304     static void         setShapeHintsOverride(SoState *state, SoNode *,
00305                                               SbBool override)
00306         { SO_SET_OVERRIDE(SHAPE_HINTS); }
00307     
00309     static void         setShininessOverride(SoState *state, SoNode *,
00310                                              SbBool override)
00311         { SO_SET_OVERRIDE(SHININESS); }
00312     
00314     static void         setSpecularColorOverride(SoState *state, SoNode *,
00315                                                  SbBool override)
00316         { SO_SET_OVERRIDE(SPECULAR_COLOR); }
00317     
00319     static void         setTransparencyOverride(SoState *state, SoNode *,
00320                                                  SbBool override);
00321 
00323     static void         setPolygonOffsetOverride(SoState *state, SoNode *,
00324                                                  SbBool override)
00325          { SO_SET_OVERRIDE(POLYGON_OFFSET); }
00326 
00328     virtual void        print(FILE *fp) const;
00329 
00330   SoINTERNAL public:
00332     static void         initClass();
00333 
00335     virtual SoElement   *copyMatchInfo() const;
00336     
00337   private:
00339     void pFlag(FILE *, const char *, int) const;
00340 
00341     uint32_t flags;
00342 };
00343 
00344 #endif /* _SO_OVERRIDE_ELEMENT */
00345