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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 9.2.p3)


  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 #ifdef G4VIS_BUILD_OI_DRIVER
                                                   >>  27 
 26 /*----------------------------HEPVis----------     28 /*----------------------------HEPVis----------------------------------------*/
 27 /*                                                 29 /*                                                                          */
 28 /* Node:             SoStyleCache                  30 /* Node:             SoStyleCache                                           */
 29 /* Author:           Guy Barrand                   31 /* Author:           Guy Barrand                                            */
 30 /*                                                 32 /*                                                                          */
 31 /*--------------------------------------------     33 /*--------------------------------------------------------------------------*/
 32                                                    34 
 33 // this :                                          35 // this :
 34 #include <HEPVis/misc/SoStyleCache.h>              36 #include <HEPVis/misc/SoStyleCache.h>
 35                                                    37 
 36 #include <Inventor/nodes/SoMaterial.h>             38 #include <Inventor/nodes/SoMaterial.h>
 37 #include <Inventor/nodes/SoDrawStyle.h>            39 #include <Inventor/nodes/SoDrawStyle.h>
 38 #include <Inventor/nodes/SoLightModel.h>           40 #include <Inventor/nodes/SoLightModel.h>
 39 #include <Inventor/nodes/SoResetTransform.h>       41 #include <Inventor/nodes/SoResetTransform.h>
 40                                                    42 
 41 //////////////////////////////////////////////     43 //////////////////////////////////////////////////////////////////////////////
 42 SoStyleCache::SoStyleCache(                        44 SoStyleCache::SoStyleCache(
 43 )                                                  45 ) 
 44 :fMaterials(0)                                     46 :fMaterials(0)
 45 ,fLineStyles(0)                                    47 ,fLineStyles(0)
 46 ,fLightModels(0)                                   48 ,fLightModels(0)
 47 ,fResetTransform(0)                                49 ,fResetTransform(0)
 48 //////////////////////////////////////////////     50 //////////////////////////////////////////////////////////////////////////////
 49 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     51 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 50 {                                                  52 {
 51   fMaterials = new SoGroup;                        53   fMaterials = new SoGroup;
 52   addChild(fMaterials);                            54   addChild(fMaterials);
 53   fLineStyles = new SoGroup;                       55   fLineStyles = new SoGroup;
 54   addChild(fLineStyles);                           56   addChild(fLineStyles);
 55   fLightModels = new SoGroup;                      57   fLightModels = new SoGroup;
 56   addChild(fLightModels);                          58   addChild(fLightModels);
 57   fResetTransform = new SoResetTransform;          59   fResetTransform = new SoResetTransform;
 58   addChild(fResetTransform);                       60   addChild(fResetTransform);
 59 }                                                  61 }
 60 //////////////////////////////////////////////     62 //////////////////////////////////////////////////////////////////////////////
 61 SoStyleCache::~SoStyleCache(                       63 SoStyleCache::~SoStyleCache(
 62 )                                                  64 ) 
 63 //////////////////////////////////////////////     65 //////////////////////////////////////////////////////////////////////////////
 64 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     66 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 65 {                                                  67 {
 66 }                                                  68 }
 67 //////////////////////////////////////////////     69 //////////////////////////////////////////////////////////////////////////////
 68 SoMaterial* SoStyleCache::getMaterial(             70 SoMaterial* SoStyleCache::getMaterial(
 69  const SbColor& aRGB                               71  const SbColor& aRGB
 70 ,float aTransparency                               72 ,float aTransparency
 71 )                                                  73 ) 
 72 //////////////////////////////////////////////     74 //////////////////////////////////////////////////////////////////////////////
 73 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     75 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 74 {                                                  76 {
 75   int number = fMaterials->getNumChildren();       77   int number = fMaterials->getNumChildren();
 76   for(int index=0;index<number;index++) {          78   for(int index=0;index<number;index++) { 
 77     SoMaterial* material = (SoMaterial*)fMater     79     SoMaterial* material = (SoMaterial*)fMaterials->getChild(index);
 78     if( (material->diffuseColor[0]==aRGB) &&       80     if( (material->diffuseColor[0]==aRGB) &&
 79         (material->transparency[0]==aTranspare     81         (material->transparency[0]==aTransparency) ) {
 80       return material;                             82       return material;
 81     }                                              83     }
 82   }                                                84   }
 83   SoMaterial* material = new SoMaterial;           85   SoMaterial* material = new SoMaterial;
 84   material->diffuseColor.setValue(aRGB);           86   material->diffuseColor.setValue(aRGB);
 85   material->transparency.setValue(aTransparenc     87   material->transparency.setValue(aTransparency);
 86   fMaterials->addChild(material);                  88   fMaterials->addChild(material);
 87   return material;                                 89   return material;
 88 }                                                  90 }
 89 //////////////////////////////////////////////     91 //////////////////////////////////////////////////////////////////////////////
 90 SoMaterial* SoStyleCache::getMaterial(             92 SoMaterial* SoStyleCache::getMaterial(
 91  float aRed                                        93  float aRed
 92 ,float aGreen                                      94 ,float aGreen
 93 ,float aBlue                                       95 ,float aBlue
 94 ,float aTransparency                               96 ,float aTransparency
 95 )                                                  97 ) 
 96 //////////////////////////////////////////////     98 //////////////////////////////////////////////////////////////////////////////
 97 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     99 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 98 {                                                 100 {
 99   SbColor aRGB(aRed,aGreen,aBlue);                101   SbColor aRGB(aRed,aGreen,aBlue);
100   int number = fMaterials->getNumChildren();      102   int number = fMaterials->getNumChildren();
101   for(int index=0;index<number;index++) {         103   for(int index=0;index<number;index++) { 
102     SoMaterial* material = (SoMaterial*)fMater    104     SoMaterial* material = (SoMaterial*)fMaterials->getChild(index);
103     if( (material->diffuseColor[0]==aRGB) &&      105     if( (material->diffuseColor[0]==aRGB) &&
104         (material->transparency[0]==aTranspare    106         (material->transparency[0]==aTransparency) ) {
105       return material;                            107       return material;
106     }                                             108     }
107   }                                               109   }
108   SoMaterial* material = new SoMaterial;          110   SoMaterial* material = new SoMaterial;
109   material->diffuseColor.setValue(aRGB);          111   material->diffuseColor.setValue(aRGB);
110   material->transparency.setValue(aTransparenc    112   material->transparency.setValue(aTransparency);
111   fMaterials->addChild(material);                 113   fMaterials->addChild(material);
112   return material;                                114   return material;
113 }                                                 115 }
114 /*                                                116 /*
115 //////////////////////////////////////////////    117 //////////////////////////////////////////////////////////////////////////////
116 SoDrawStyle* SoStyleCache::getLineStyle(          118 SoDrawStyle* SoStyleCache::getLineStyle(
117  SbLineStyle aStyle                               119  SbLineStyle aStyle
118 ,float aWidth                                     120 ,float aWidth
119 )                                                 121 ) 
120 //////////////////////////////////////////////    122 //////////////////////////////////////////////////////////////////////////////
121 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    123 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
122 {                                                 124 {
123   unsigned short pattern = 0xFFFF;                125   unsigned short pattern = 0xFFFF;
124   switch(aStyle) {                                126   switch(aStyle) {
125   case SbLineDashed:                              127   case SbLineDashed:
126     pattern = 0x00FF;                             128     pattern = 0x00FF;
127     break;                                        129     break;
128   case SbLineDotted:                              130   case SbLineDotted:
129     pattern = 0x0101;                             131     pattern = 0x0101;
130     break;                                        132     break;
131   case SbLineDashDotted:                          133   case SbLineDashDotted:
132     pattern = 0x1C47;                             134     pattern = 0x1C47;
133     break;                                        135     break;
134   default: //SbLineSolid:                         136   default: //SbLineSolid:
135     pattern = 0xFFFF;                             137     pattern = 0xFFFF;
136     break;                                        138     break;
137   }                                               139   }
138   int number = fLineStyles->getNumChildren();     140   int number = fLineStyles->getNumChildren();
139   for(int index=0;index<number;index++) {         141   for(int index=0;index<number;index++) { 
140     SoDrawStyle* drawStyle = (SoDrawStyle*)fLi    142     SoDrawStyle* drawStyle = (SoDrawStyle*)fLineStyles->getChild(index);
141     if( (drawStyle->style.getValue()==SoDrawSt    143     if( (drawStyle->style.getValue()==SoDrawStyle::LINES) &&
142         (drawStyle->lineWidth.getValue()==aWid    144         (drawStyle->lineWidth.getValue()==aWidth) &&
143         (drawStyle->linePattern.getValue()==pa    145         (drawStyle->linePattern.getValue()==pattern) ) {
144       return drawStyle;                           146       return drawStyle;
145     }                                             147     }
146   }                                               148   }
147   SoDrawStyle* drawStyle = new SoDrawStyle;       149   SoDrawStyle* drawStyle = new SoDrawStyle;
148   drawStyle->style.setValue(SoDrawStyle::LINES    150   drawStyle->style.setValue(SoDrawStyle::LINES);
149   drawStyle->lineWidth.setValue(aWidth);          151   drawStyle->lineWidth.setValue(aWidth);
150   drawStyle->linePattern.setValue(pattern);       152   drawStyle->linePattern.setValue(pattern);
151   fLineStyles->addChild(drawStyle);               153   fLineStyles->addChild(drawStyle);
152   return drawStyle;                               154   return drawStyle;
153 }                                                 155 }
154 */                                                156 */
155 //////////////////////////////////////////////    157 //////////////////////////////////////////////////////////////////////////////
156 SoDrawStyle* SoStyleCache::getLineStyle(          158 SoDrawStyle* SoStyleCache::getLineStyle(
157  unsigned short aPattern                          159  unsigned short aPattern
158 ,float aWidth                                     160 ,float aWidth
159 )                                                 161 ) 
160 //////////////////////////////////////////////    162 //////////////////////////////////////////////////////////////////////////////
161 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    163 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
162 {                                                 164 {
163   int number = fLineStyles->getNumChildren();     165   int number = fLineStyles->getNumChildren();
164   for(int index=0;index<number;index++) {         166   for(int index=0;index<number;index++) { 
165     SoDrawStyle* drawStyle = (SoDrawStyle*)fLi    167     SoDrawStyle* drawStyle = (SoDrawStyle*)fLineStyles->getChild(index);
166     if( (drawStyle->style.getValue()==SoDrawSt    168     if( (drawStyle->style.getValue()==SoDrawStyle::LINES) &&
167         (drawStyle->lineWidth.getValue()==aWid    169         (drawStyle->lineWidth.getValue()==aWidth) &&
168         (drawStyle->linePattern.getValue()==aP    170         (drawStyle->linePattern.getValue()==aPattern) ) {
169       return drawStyle;                           171       return drawStyle;
170     }                                             172     }
171   }                                               173   }
172   SoDrawStyle* drawStyle = new SoDrawStyle;       174   SoDrawStyle* drawStyle = new SoDrawStyle;
173   drawStyle->style.setValue(SoDrawStyle::LINES    175   drawStyle->style.setValue(SoDrawStyle::LINES);
174   drawStyle->lineWidth.setValue(aWidth);          176   drawStyle->lineWidth.setValue(aWidth);
175   drawStyle->linePattern.setValue(aPattern);      177   drawStyle->linePattern.setValue(aPattern);
176   fLineStyles->addChild(drawStyle);               178   fLineStyles->addChild(drawStyle);
177   return drawStyle;                               179   return drawStyle;
178 }                                                 180 }
179 //////////////////////////////////////////////    181 //////////////////////////////////////////////////////////////////////////////
180 SoLightModel* SoStyleCache::getLightModelPhong    182 SoLightModel* SoStyleCache::getLightModelPhong(
181 )                                                 183 ) 
182 //////////////////////////////////////////////    184 //////////////////////////////////////////////////////////////////////////////
183 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    185 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
184 {                                                 186 {
185   SoLightModel* lightModel = new SoLightModel;    187   SoLightModel* lightModel = new SoLightModel;
186   lightModel->model.setValue(SoLightModel::PHO    188   lightModel->model.setValue(SoLightModel::PHONG);
187   fLightModels->addChild(lightModel);             189   fLightModels->addChild(lightModel);
188   return lightModel;                              190   return lightModel;
189 }                                                 191 }
190 //////////////////////////////////////////////    192 //////////////////////////////////////////////////////////////////////////////
191 SoLightModel* SoStyleCache::getLightModelBaseC    193 SoLightModel* SoStyleCache::getLightModelBaseColor(
192 )                                                 194 ) 
193 //////////////////////////////////////////////    195 //////////////////////////////////////////////////////////////////////////////
194 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    196 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
195 {                                                 197 {
196   SoLightModel* lightModel = new SoLightModel;    198   SoLightModel* lightModel = new SoLightModel;
197   lightModel->model.setValue(SoLightModel::BAS    199   lightModel->model.setValue(SoLightModel::BASE_COLOR);
198   fLightModels->addChild(lightModel);             200   fLightModels->addChild(lightModel);
199   return lightModel;                              201   return lightModel;
200 }                                                 202 }
201 //////////////////////////////////////////////    203 //////////////////////////////////////////////////////////////////////////////
202 SoResetTransform* SoStyleCache::getResetTransf    204 SoResetTransform* SoStyleCache::getResetTransform(
203 )                                                 205 ) 
204 //////////////////////////////////////////////    206 //////////////////////////////////////////////////////////////////////////////
205 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    207 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
206 {                                                 208 {
207   return fResetTransform;                         209   return fResetTransform;
208 }                                                 210 }
                                                   >> 211 
                                                   >> 212 #endif
209                                                   213