-// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "GEOM_EdgeSource.h"
#include "GEOM_WireframeFace.h"
#include "GEOM_ShadingFace.h"
+#include "GEOM_PainterPolyDataMapper.h"
#include "SVTK_Actor.h"
#include <OCC2VTK_Tools.h>
#endif
GEOM_Actor::GEOM_Actor():
+ isOnlyVertex(false),
+
+ myDeflection(-1),
+ myIsForced(false),
+
// myDisplayMode(eWireframe),
myIsSelected(false),
myVectorMode(false),
+
myVertexActor(GEOM_DeviceActor::New(),true),
myVertexSource(GEOM_VertexSource::New(),true),
myHighlightActor(GEOM_DeviceActor::New(),true),
myAppendFilter(vtkAppendPolyData::New(),true),
- myPolyDataMapper(vtkPolyDataMapper::New(),true),
+ // Use mapper as an instance of GEOM_PainterPolyDataMapper class
+ // to prevent drawing of mappers' content (due to an empty definition
+ // of GEOM_PainterPolyDataMapper::RenderPiece(...)).
+ // !!! Presentation of GEOM_Actor is drawing only with help of actors
+ // defined in this class !!!
+ myPolyDataMapper(GEOM_PainterPolyDataMapper::New(),true),
myHighlightProp(vtkProperty::New()),
myPreHighlightProp(vtkProperty::New()),
- myShadingFaceProp(vtkProperty::New()),
- isOnlyVertex(false)
+ myShadingFaceProp(vtkProperty::New())
{
#ifdef MYDEBUG
MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
aProperty->SetPointSize(3);
aProperty->SetColor(1, 1, 0);
- myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput());
+ myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput());
myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutput(),false);
aProperty = myIsolatedEdgeActor->GetProperty();
aProperty->SetRepresentation(VTK_WIREFRAME);
aProperty->SetColor(1, 0, 0);
- myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput());
+ myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput());
myOneFaceEdgeActor->SetInput(myOneFaceEdgeSource->GetOutput(),false);
aProperty = myOneFaceEdgeActor->GetProperty();
aProperty->SetRepresentation(VTK_WIREFRAME);
myShadingFaceActor->SetInput(myShadingFaceSource->GetOutput(),true);
- myShadingFaceProp->SetRepresentation(VTK_SURFACE);
+ myShadingFaceProp->SetRepresentation(VTKViewer::Representation::Surface);
myShadingFaceProp->SetInterpolationToGouraud();
myShadingFaceProp->SetAmbient(1.0);
myShadingFaceProp->SetDiffuse(1.0);
myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
+ StoreBoundaryColors();
+
+ myNbIsos[0] = -1;
+ myNbIsos[1] = -1;
+
// Toggle display mode
setDisplayMode(0); // WIRE FRAME
SetVectorMode(0); //
-
}
setDisplayMode(int theMode)
{
#ifdef MYDEBUG
- MESSAGE ( "GEOM_Actor::SetDisplayMode = "<<theMode );
+ MESSAGE ( "GEOM_Actor::setDisplayMode = "<<theMode );
#endif
+
+ if ( theMode == (int)eWireframe ) {
+ RestoreIsoNumbers();
+ // Restore wireframe edges colors
+ RestoreBoundaryColors();
+ }
+ else if ( theMode == (int)eShading || theMode == (int)eShadingWithEdges ) {
+ // Temporary store number of iso lines in order to recover its later
+ // when display mode is achnged to 'Wirefame' or 'Shading'.
+ // Iso lines are not displayed in 'Shading with edges' mode.
+ StoreIsoNumbers();
+
+ // Reset number of iso lines to 0
+ ResetIsoNumbers();
+
+ if ( theMode == (int)eShadingWithEdges ) {
+ // Store wireframe edges colors
+ StoreBoundaryColors();
+
+ // Coloring edges
+ myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0],
+ myEdgesInShadingColor[1],
+ myEdgesInShadingColor[2]);
+ myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0],
+ myEdgesInShadingColor[1],
+ myEdgesInShadingColor[2]);
+ mySharedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0],
+ myEdgesInShadingColor[1],
+ myEdgesInShadingColor[2]);
+ //SetModified();
+ } else {
+ myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+ myEdgesInWireframeColor[1],
+ myEdgesInWireframeColor[2]);
+ }
+ }
+
VTKViewer_Actor::setDisplayMode(theMode);
SetVisibility(GetVisibility());
}
this->myHighlightActor->SetVisibility(theVisibility && (myIsSelected || myIsPreselected));
- myShadingFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eShading) && (!myIsSelected || !myIsPreselected));
- myWireframeFaceActor->SetVisibility(theVisibility && (myDisplayMode ==(int)eWireframe) && !myIsSelected);
+ myShadingFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eShading || myDisplayMode == (int)eShadingWithEdges) && (!myIsSelected || !myIsPreselected));
+ myWireframeFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe) && !myIsSelected);
- mySharedEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
- myOneFaceEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
+ mySharedEdgeActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe || myDisplayMode == (int)eShadingWithEdges) && !myIsSelected);
+ myOneFaceEdgeActor->SetVisibility(theVisibility && (myDisplayMode == (int)eWireframe || myDisplayMode == (int)eShadingWithEdges) && !myIsSelected);
myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected);
- myVertexActor->SetVisibility(theVisibility && !myIsSelected);// must be added new mode points
+ myVertexActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);// must be added new mode points
}
myWireframeFaceActor->SetProperty(Prop);
}
+
+vtkProperty* GEOM_Actor::GetWireframeProperty()
+{
+ return myWireframeFaceActor->GetProperty();
+}
+
void GEOM_Actor::SetShadingProperty(vtkProperty* Prop)
{
#ifdef MYDEBUG
}
+vtkProperty* GEOM_Actor::GetShadingProperty()
+{
+ return myShadingFaceProp;
+}
+
+
void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
{
#ifdef MYDEBUG
}
switch(myDisplayMode){
- case 0://wireframe
+ case eWireframe://wireframe
myPreHighlightProp->SetRepresentationToWireframe();
myHighlightProp->SetRepresentationToWireframe();
break;
- case 1://shading
+ case eShading://shading
+ case eShadingWithEdges://shading with edges
myPreHighlightProp->SetRepresentationToSurface();
myHighlightProp->SetRepresentationToSurface();
+ myShadingFaceProp->SetRepresentationToSurface();
break;
}
#ifdef MYDEBUG
MESSAGE ( this << " GEOM_Actor::highlight highlight="<<highlight );
#endif
- SALOME_Actor::highlight(highlight);
+ SALOME_Actor::highlight(highlight);
}
void GEOM_Actor::SetOpacity(vtkFloatingPointType opa)
{
// enk:tested OK
myShadingFaceProp->SetColor(r,g,b); // shading color (Shading)
- myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe)
myVertexActor->GetProperty()->SetColor(r,g,b); // vertex actor (Shading/Wireframe)
- myOneFaceEdgeActor->GetProperty()->SetColor(r,g,b); // standalone face edge color (Wireframe)
- mySharedEdgeActor->GetProperty()->SetColor(r,g,b); // share edge color (Wireframe)
+ if ( myDisplayMode != (int)eShadingWithEdges ) {
+ myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe)
+ myOneFaceEdgeActor->GetProperty()->SetColor(r,g,b); // standalone face edge color (Wireframe)
+ mySharedEdgeActor->GetProperty()->SetColor(r,g,b); // share edge color (Wireframe)
+ }
+
+ StoreBoundaryColors();
}
void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
b = aRGB[2];
}
+void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
+{
+ // we set material properties as back and front material
+ double aCoefnt;
+
+ // Set reflection coefficients
+ aCoefnt = theProps[0]->GetAmbient();
+ myShadingFaceProp->SetAmbient(aCoefnt);
+ myVertexActor->GetProperty()->SetAmbient(aCoefnt);
+
+ // Set diffuse coefficients
+ aCoefnt = theProps[0]->GetDiffuse();
+ myShadingFaceProp->SetDiffuse(aCoefnt);
+ myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
+
+ // Set specular coefficients
+ aCoefnt = theProps[0]->GetSpecular();
+ myShadingFaceProp->SetSpecular(aCoefnt);
+ myVertexActor->GetProperty()->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]);
+
+ // Set diffuse colors
+ aColor = theProps[0]->GetDiffuseColor();
+ myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
+ myVertexActor->GetProperty()->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]);
+
+ // Set shininess
+ aCoefnt = theProps[0]->GetSpecularPower();
+ myShadingFaceProp->SetSpecularPower(aCoefnt);
+ myVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
+}
+
+vtkProperty* GEOM_Actor::GetMaterial()
+{
+ return myShadingFaceProp;
+}
+
bool GEOM_Actor::IsInfinitive()
{
return ((bool)myShape.Infinite() || isOnlyVertex);
#ifdef MYDEBUG
MESSAGE ( this << " GEOM_Actor::Highlight myIsSelected="<<myIsSelected );
#endif
-
+
+ if ( myDisplayMode == (int)eShading || myDisplayMode == (int)eShadingWithEdges ) {
+ if ( theIsHighlight )
+ RestoreIsoNumbers();
+ else
+ // Reset number of iso lines to 0
+ ResetIsoNumbers();
+ }
+
SALOME_Actor::Highlight(theIsHighlight); // this method call ::highlight(theIsHighlight) in the end
SetVisibility(GetVisibility());
}
if ( !GetPickable() )
return false;
+ if ( myDisplayMode == (int)eShading || myDisplayMode == (int)eShadingWithEdges ) {
+ if ( theIsHighlight )
+ RestoreIsoNumbers();
+ else
+ // Reset number of iso lines to 0
+ ResetIsoNumbers();
+ }
+
myPreHighlightActor->SetVisibility( false );
bool anIsPreselected = myIsPreselected;
this->Transform->Pop();
}
+void GEOM_Actor::SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
+{
+ myEdgesInShadingColor[0] = r;
+ myEdgesInShadingColor[1] = g;
+ myEdgesInShadingColor[2] = b;
+}
+
+void GEOM_Actor::StoreIsoNumbers()
+{
+ myWireframeFaceSource->GetNbIso(myNbIsos[0], myNbIsos[1]);
+}
+
+void GEOM_Actor::SetIsosWidth(const int width) {
+ myWireframeFaceActor->GetProperty()->SetLineWidth(width);
+}
+
+int GEOM_Actor::GetIsosWidth() const {
+ return (int)myWireframeFaceActor->GetProperty()->GetLineWidth();
+}
+
+void GEOM_Actor::SetWidth(const int width) {
+ myIsolatedEdgeActor->GetProperty()->SetLineWidth(width);
+ myOneFaceEdgeActor->GetProperty()->SetLineWidth(width);
+ mySharedEdgeActor->GetProperty()->SetLineWidth(width);
+ myHighlightProp->SetLineWidth(width);
+ myPreHighlightProp->SetLineWidth(width+1);
+}
+
+int GEOM_Actor::GetWidth() const {
+ return (int)myIsolatedEdgeActor->GetProperty()->GetLineWidth();
+}
+
+void GEOM_Actor::RestoreIsoNumbers()
+{
+ if ( myNbIsos[0] > 0 || myNbIsos[1] > 0 )
+ // Restore number of U and (or) V iso lines
+ myWireframeFaceSource->SetNbIso(myNbIsos);
+}
+
+void GEOM_Actor::ResetIsoNumbers()
+{
+ int aNb[2] = {0, 0};
+ myWireframeFaceSource->SetNbIso(aNb);
+}
+
+void GEOM_Actor::StoreBoundaryColors()
+{
+ myShadingFaceProp->GetColor(myEdgesInWireframeColor);
+
+}
+
+void GEOM_Actor::RestoreBoundaryColors()
+{
+ myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+ myEdgesInWireframeColor[1],
+ myEdgesInWireframeColor[2]);
+ myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+ myEdgesInWireframeColor[1],
+ myEdgesInWireframeColor[2]);
+ mySharedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0],
+ myEdgesInWireframeColor[1],
+ myEdgesInWireframeColor[2]);
+}