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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenInventor/src/SoStyleCache.cc (Version 11.3.0) and /visualization/OpenInventor/src/SoStyleCache.cc (Version 11.0.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*----------------------------HEPVis----------     26 /*----------------------------HEPVis----------------------------------------*/
 27 /*                                                 27 /*                                                                          */
 28 /* Node:             SoStyleCache                  28 /* Node:             SoStyleCache                                           */
 29 /* Author:           Guy Barrand                   29 /* Author:           Guy Barrand                                            */
 30 /*                                                 30 /*                                                                          */
 31 /*--------------------------------------------     31 /*--------------------------------------------------------------------------*/
 32                                                    32 
 33 // this :                                          33 // this :
 34 #include <HEPVis/misc/SoStyleCache.h>              34 #include <HEPVis/misc/SoStyleCache.h>
 35                                                    35 
 36 #include <Inventor/nodes/SoMaterial.h>             36 #include <Inventor/nodes/SoMaterial.h>
 37 #include <Inventor/nodes/SoDrawStyle.h>            37 #include <Inventor/nodes/SoDrawStyle.h>
 38 #include <Inventor/nodes/SoLightModel.h>           38 #include <Inventor/nodes/SoLightModel.h>
 39 #include <Inventor/nodes/SoResetTransform.h>       39 #include <Inventor/nodes/SoResetTransform.h>
 40                                                    40 
 41 //////////////////////////////////////////////     41 //////////////////////////////////////////////////////////////////////////////
 42 SoStyleCache::SoStyleCache(                        42 SoStyleCache::SoStyleCache(
 43 )                                                  43 ) 
 44 :fMaterials(0)                                     44 :fMaterials(0)
 45 ,fLineStyles(0)                                    45 ,fLineStyles(0)
 46 ,fLightModels(0)                                   46 ,fLightModels(0)
 47 ,fResetTransform(0)                                47 ,fResetTransform(0)
 48 //////////////////////////////////////////////     48 //////////////////////////////////////////////////////////////////////////////
 49 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     49 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 50 {                                                  50 {
 51   fMaterials = new SoGroup;                        51   fMaterials = new SoGroup;
 52   addChild(fMaterials);                            52   addChild(fMaterials);
 53   fLineStyles = new SoGroup;                       53   fLineStyles = new SoGroup;
 54   addChild(fLineStyles);                           54   addChild(fLineStyles);
 55   fLightModels = new SoGroup;                      55   fLightModels = new SoGroup;
 56   addChild(fLightModels);                          56   addChild(fLightModels);
 57   fResetTransform = new SoResetTransform;          57   fResetTransform = new SoResetTransform;
 58   addChild(fResetTransform);                       58   addChild(fResetTransform);
 59 }                                                  59 }
 60 //////////////////////////////////////////////     60 //////////////////////////////////////////////////////////////////////////////
 61 SoStyleCache::~SoStyleCache(                       61 SoStyleCache::~SoStyleCache(
 62 )                                                  62 ) 
 63 //////////////////////////////////////////////     63 //////////////////////////////////////////////////////////////////////////////
 64 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     64 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 65 {                                                  65 {
 66 }                                                  66 }
 67 //////////////////////////////////////////////     67 //////////////////////////////////////////////////////////////////////////////
 68 SoMaterial* SoStyleCache::getMaterial(             68 SoMaterial* SoStyleCache::getMaterial(
 69  const SbColor& aRGB                               69  const SbColor& aRGB
 70 ,float aTransparency                               70 ,float aTransparency
 71 )                                                  71 ) 
 72 //////////////////////////////////////////////     72 //////////////////////////////////////////////////////////////////////////////
 73 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     73 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 74 {                                                  74 {
 75   int number = fMaterials->getNumChildren();       75   int number = fMaterials->getNumChildren();
 76   for(int index=0;index<number;index++) {          76   for(int index=0;index<number;index++) { 
 77     SoMaterial* material = (SoMaterial*)fMater     77     SoMaterial* material = (SoMaterial*)fMaterials->getChild(index);
 78     if( (material->diffuseColor[0]==aRGB) &&       78     if( (material->diffuseColor[0]==aRGB) &&
 79         (material->transparency[0]==aTranspare     79         (material->transparency[0]==aTransparency) ) {
 80       return material;                             80       return material;
 81     }                                              81     }
 82   }                                                82   }
 83   SoMaterial* material = new SoMaterial;           83   SoMaterial* material = new SoMaterial;
 84   material->diffuseColor.setValue(aRGB);           84   material->diffuseColor.setValue(aRGB);
 85   material->transparency.setValue(aTransparenc     85   material->transparency.setValue(aTransparency);
 86   fMaterials->addChild(material);                  86   fMaterials->addChild(material);
 87   return material;                                 87   return material;
 88 }                                                  88 }
 89 //////////////////////////////////////////////     89 //////////////////////////////////////////////////////////////////////////////
 90 SoMaterial* SoStyleCache::getMaterial(             90 SoMaterial* SoStyleCache::getMaterial(
 91  float aRed                                        91  float aRed
 92 ,float aGreen                                      92 ,float aGreen
 93 ,float aBlue                                       93 ,float aBlue
 94 ,float aTransparency                               94 ,float aTransparency
 95 )                                                  95 ) 
 96 //////////////////////////////////////////////     96 //////////////////////////////////////////////////////////////////////////////
 97 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     97 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 98 {                                                  98 {
 99   SbColor aRGB(aRed,aGreen,aBlue);                 99   SbColor aRGB(aRed,aGreen,aBlue);
100   int number = fMaterials->getNumChildren();      100   int number = fMaterials->getNumChildren();
101   for(int index=0;index<number;index++) {         101   for(int index=0;index<number;index++) { 
102     SoMaterial* material = (SoMaterial*)fMater    102     SoMaterial* material = (SoMaterial*)fMaterials->getChild(index);
103     if( (material->diffuseColor[0]==aRGB) &&      103     if( (material->diffuseColor[0]==aRGB) &&
104         (material->transparency[0]==aTranspare    104         (material->transparency[0]==aTransparency) ) {
105       return material;                            105       return material;
106     }                                             106     }
107   }                                               107   }
108   SoMaterial* material = new SoMaterial;          108   SoMaterial* material = new SoMaterial;
109   material->diffuseColor.setValue(aRGB);          109   material->diffuseColor.setValue(aRGB);
110   material->transparency.setValue(aTransparenc    110   material->transparency.setValue(aTransparency);
111   fMaterials->addChild(material);                 111   fMaterials->addChild(material);
112   return material;                                112   return material;
113 }                                                 113 }
114 /*                                                114 /*
115 //////////////////////////////////////////////    115 //////////////////////////////////////////////////////////////////////////////
116 SoDrawStyle* SoStyleCache::getLineStyle(          116 SoDrawStyle* SoStyleCache::getLineStyle(
117  SbLineStyle aStyle                               117  SbLineStyle aStyle
118 ,float aWidth                                     118 ,float aWidth
119 )                                                 119 ) 
120 //////////////////////////////////////////////    120 //////////////////////////////////////////////////////////////////////////////
121 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    121 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
122 {                                                 122 {
123   unsigned short pattern = 0xFFFF;                123   unsigned short pattern = 0xFFFF;
124   switch(aStyle) {                                124   switch(aStyle) {
125   case SbLineDashed:                              125   case SbLineDashed:
126     pattern = 0x00FF;                             126     pattern = 0x00FF;
127     break;                                        127     break;
128   case SbLineDotted:                              128   case SbLineDotted:
129     pattern = 0x0101;                             129     pattern = 0x0101;
130     break;                                        130     break;
131   case SbLineDashDotted:                          131   case SbLineDashDotted:
132     pattern = 0x1C47;                             132     pattern = 0x1C47;
133     break;                                        133     break;
134   default: //SbLineSolid:                         134   default: //SbLineSolid:
135     pattern = 0xFFFF;                             135     pattern = 0xFFFF;
136     break;                                        136     break;
137   }                                               137   }
138   int number = fLineStyles->getNumChildren();     138   int number = fLineStyles->getNumChildren();
139   for(int index=0;index<number;index++) {         139   for(int index=0;index<number;index++) { 
140     SoDrawStyle* drawStyle = (SoDrawStyle*)fLi    140     SoDrawStyle* drawStyle = (SoDrawStyle*)fLineStyles->getChild(index);
141     if( (drawStyle->style.getValue()==SoDrawSt    141     if( (drawStyle->style.getValue()==SoDrawStyle::LINES) &&
142         (drawStyle->lineWidth.getValue()==aWid    142         (drawStyle->lineWidth.getValue()==aWidth) &&
143         (drawStyle->linePattern.getValue()==pa    143         (drawStyle->linePattern.getValue()==pattern) ) {
144       return drawStyle;                           144       return drawStyle;
145     }                                             145     }
146   }                                               146   }
147   SoDrawStyle* drawStyle = new SoDrawStyle;       147   SoDrawStyle* drawStyle = new SoDrawStyle;
148   drawStyle->style.setValue(SoDrawStyle::LINES    148   drawStyle->style.setValue(SoDrawStyle::LINES);
149   drawStyle->lineWidth.setValue(aWidth);          149   drawStyle->lineWidth.setValue(aWidth);
150   drawStyle->linePattern.setValue(pattern);       150   drawStyle->linePattern.setValue(pattern);
151   fLineStyles->addChild(drawStyle);               151   fLineStyles->addChild(drawStyle);
152   return drawStyle;                               152   return drawStyle;
153 }                                                 153 }
154 */                                                154 */
155 //////////////////////////////////////////////    155 //////////////////////////////////////////////////////////////////////////////
156 SoDrawStyle* SoStyleCache::getLineStyle(          156 SoDrawStyle* SoStyleCache::getLineStyle(
157  unsigned short aPattern                          157  unsigned short aPattern
158 ,float aWidth                                     158 ,float aWidth
159 )                                                 159 ) 
160 //////////////////////////////////////////////    160 //////////////////////////////////////////////////////////////////////////////
161 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    161 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
162 {                                                 162 {
163   int number = fLineStyles->getNumChildren();     163   int number = fLineStyles->getNumChildren();
164   for(int index=0;index<number;index++) {         164   for(int index=0;index<number;index++) { 
165     SoDrawStyle* drawStyle = (SoDrawStyle*)fLi    165     SoDrawStyle* drawStyle = (SoDrawStyle*)fLineStyles->getChild(index);
166     if( (drawStyle->style.getValue()==SoDrawSt    166     if( (drawStyle->style.getValue()==SoDrawStyle::LINES) &&
167         (drawStyle->lineWidth.getValue()==aWid    167         (drawStyle->lineWidth.getValue()==aWidth) &&
168         (drawStyle->linePattern.getValue()==aP    168         (drawStyle->linePattern.getValue()==aPattern) ) {
169       return drawStyle;                           169       return drawStyle;
170     }                                             170     }
171   }                                               171   }
172   SoDrawStyle* drawStyle = new SoDrawStyle;       172   SoDrawStyle* drawStyle = new SoDrawStyle;
173   drawStyle->style.setValue(SoDrawStyle::LINES    173   drawStyle->style.setValue(SoDrawStyle::LINES);
174   drawStyle->lineWidth.setValue(aWidth);          174   drawStyle->lineWidth.setValue(aWidth);
175   drawStyle->linePattern.setValue(aPattern);      175   drawStyle->linePattern.setValue(aPattern);
176   fLineStyles->addChild(drawStyle);               176   fLineStyles->addChild(drawStyle);
177   return drawStyle;                               177   return drawStyle;
178 }                                                 178 }
179 //////////////////////////////////////////////    179 //////////////////////////////////////////////////////////////////////////////
180 SoLightModel* SoStyleCache::getLightModelPhong    180 SoLightModel* SoStyleCache::getLightModelPhong(
181 )                                                 181 ) 
182 //////////////////////////////////////////////    182 //////////////////////////////////////////////////////////////////////////////
183 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    183 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
184 {                                                 184 {
185   SoLightModel* lightModel = new SoLightModel;    185   SoLightModel* lightModel = new SoLightModel;
186   lightModel->model.setValue(SoLightModel::PHO    186   lightModel->model.setValue(SoLightModel::PHONG);
187   fLightModels->addChild(lightModel);             187   fLightModels->addChild(lightModel);
188   return lightModel;                              188   return lightModel;
189 }                                                 189 }
190 //////////////////////////////////////////////    190 //////////////////////////////////////////////////////////////////////////////
191 SoLightModel* SoStyleCache::getLightModelBaseC    191 SoLightModel* SoStyleCache::getLightModelBaseColor(
192 )                                                 192 ) 
193 //////////////////////////////////////////////    193 //////////////////////////////////////////////////////////////////////////////
194 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    194 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
195 {                                                 195 {
196   SoLightModel* lightModel = new SoLightModel;    196   SoLightModel* lightModel = new SoLightModel;
197   lightModel->model.setValue(SoLightModel::BAS    197   lightModel->model.setValue(SoLightModel::BASE_COLOR);
198   fLightModels->addChild(lightModel);             198   fLightModels->addChild(lightModel);
199   return lightModel;                              199   return lightModel;
200 }                                                 200 }
201 //////////////////////////////////////////////    201 //////////////////////////////////////////////////////////////////////////////
202 SoResetTransform* SoStyleCache::getResetTransf    202 SoResetTransform* SoStyleCache::getResetTransform(
203 )                                                 203 ) 
204 //////////////////////////////////////////////    204 //////////////////////////////////////////////////////////////////////////////
205 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    205 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
206 {                                                 206 {
207   return fResetTransform;                         207   return fResetTransform;
208 }                                                 208 }
209                                                   209