- if(highlight && !ishighlighted) {
- ishighlighted=true;
- // build highlight property is necessary
- if(HighlightProperty==NULL) {
- HighlightProperty = vtkProperty::New();
- HighlightProperty->SetAmbient(0.5);
- HighlightProperty->SetDiffuse(0.3);
- HighlightProperty->SetSpecular(0.2);
- HighlightProperty->SetRepresentationToSurface();
- HighlightProperty->SetAmbientColor(1, 1, 1);
- HighlightProperty->SetDiffuseColor(1, 1, 1);
- HighlightProperty->SetSpecularColor(0.5, 0.5, 0.5);
- }
-
- this->Property = HighlightProperty;
-
- }
- else if (!highlight) {
- if(ishighlighted) {
- ishighlighted=false;
- if(myDisplayMode==1) {
- //unhilight in shading
- this->Property = ShadingProperty;
- }
- else {
- //unhilight in wireframe
- this->Property = WireframeProperty;
- }
- }
- }
+ // theProps[0] -- front material properties
+ // theProps[1] -- back material properties (if exist)
+ // If there are no back material properties,
+ // we get front material properties as back material
+
+ double aCoefnt;
+
+ // Set reflection coefficients
+ aCoefnt = theProps[0]->GetAmbient();
+ myShadingFaceProp->SetAmbient(aCoefnt);
+ myVertexActor->GetProperty()->SetAmbient(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetAmbient();
+ myShadingBackFaceProp->SetAmbient(aCoefnt);
+
+ // Set diffuse coefficients
+ aCoefnt = theProps[0]->GetDiffuse();
+ myShadingFaceProp->SetDiffuse(aCoefnt);
+ myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetDiffuse();
+ myShadingBackFaceProp->SetDiffuse(aCoefnt);
+
+ // Set specular coefficients
+ aCoefnt = theProps[0]->GetSpecular();
+ myShadingFaceProp->SetSpecular(aCoefnt);
+ myVertexActor->GetProperty()->SetSpecular(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetSpecular();
+ myShadingBackFaceProp->SetSpecular(aCoefnt);
+
+
+ double* aColor;
+
+ // Set reflection colors
+ aColor = theProps[0]->GetAmbientColor();
+ myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
+ myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
+ if ( aSize == 2 )
+ aColor = theProps[1]->GetAmbientColor();
+ myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
+
+ // Set diffuse colors
+ aColor = theProps[0]->GetDiffuseColor();
+ myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
+ myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
+ if ( aSize == 2 )
+ aColor = theProps[1]->GetDiffuseColor();
+ myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
+
+ // Set specular colors
+ aColor = theProps[0]->GetSpecularColor();
+ myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
+ myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
+ if ( aSize == 2 )
+ aColor = theProps[1]->GetSpecularColor();
+ myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
+
+ // Set shininess
+ aCoefnt = theProps[0]->GetSpecularPower();
+ myShadingFaceProp->SetSpecularPower(aCoefnt);
+ myVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
+ if ( aSize == 2 )
+ aCoefnt = theProps[1]->GetSpecularPower();
+ myShadingBackFaceProp->SetSpecularPower(aCoefnt);
+
+ // Set back face material property
+ myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer());