26 #ifdef G4VIS_BUILD_OI_DRIVER
36 #include <HEPVis/misc/SoStyleCache.h>
38 #include <Inventor/nodes/SoMaterial.h>
39 #include <Inventor/nodes/SoDrawStyle.h>
40 #include <Inventor/nodes/SoLightModel.h>
41 #include <Inventor/nodes/SoResetTransform.h>
44 SoStyleCache::SoStyleCache(
53 fMaterials =
new SoGroup;
55 fLineStyles =
new SoGroup;
56 addChild(fLineStyles);
57 fLightModels =
new SoGroup;
58 addChild(fLightModels);
59 fResetTransform =
new SoResetTransform;
60 addChild(fResetTransform);
63 SoStyleCache::~SoStyleCache(
70 SoMaterial* SoStyleCache::getMaterial(
77 int number = fMaterials->getNumChildren();
78 for(
int index=0;index<number;index++) {
79 SoMaterial* material = (SoMaterial*)fMaterials->getChild(index);
80 if( (material->diffuseColor[0]==aRGB) &&
81 (material->transparency[0]==aTransparency) ) {
85 SoMaterial* material =
new SoMaterial;
86 material->diffuseColor.setValue(aRGB);
87 material->transparency.setValue(aTransparency);
88 fMaterials->addChild(material);
92 SoMaterial* SoStyleCache::getMaterial(
101 SbColor aRGB(aRed,aGreen,aBlue);
102 int number = fMaterials->getNumChildren();
103 for(
int index=0;index<number;index++) {
104 SoMaterial* material = (SoMaterial*)fMaterials->getChild(index);
105 if( (material->diffuseColor[0]==aRGB) &&
106 (material->transparency[0]==aTransparency) ) {
110 SoMaterial* material =
new SoMaterial;
111 material->diffuseColor.setValue(aRGB);
112 material->transparency.setValue(aTransparency);
113 fMaterials->addChild(material);
158 SoDrawStyle* SoStyleCache::getLineStyle(
159 unsigned short aPattern
165 int number = fLineStyles->getNumChildren();
166 for(
int index=0;index<number;index++) {
167 SoDrawStyle* drawStyle = (SoDrawStyle*)fLineStyles->getChild(index);
168 if( (drawStyle->style.getValue()==SoDrawStyle::LINES) &&
169 (drawStyle->lineWidth.getValue()==aWidth) &&
170 (drawStyle->linePattern.getValue()==aPattern) ) {
174 SoDrawStyle* drawStyle =
new SoDrawStyle;
175 drawStyle->style.setValue(SoDrawStyle::LINES);
176 drawStyle->lineWidth.setValue(aWidth);
177 drawStyle->linePattern.setValue(aPattern);
178 fLineStyles->addChild(drawStyle);
182 SoLightModel* SoStyleCache::getLightModelPhong(
187 SoLightModel* lightModel =
new SoLightModel;
188 lightModel->model.setValue(SoLightModel::PHONG);
189 fLightModels->addChild(lightModel);
193 SoLightModel* SoStyleCache::getLightModelBaseColor(
198 SoLightModel* lightModel =
new SoLightModel;
199 lightModel->model.setValue(SoLightModel::BASE_COLOR);
200 fLightModels->addChild(lightModel);
204 SoResetTransform* SoStyleCache::getResetTransform(
209 return fResetTransform;