+
+void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
+{
+ myEntityState = eAllEntity;
+
+ if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
+ myEntityState &= ~e0DElements;
+ theMode &= ~e0DElements;
+ }
+
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
+ myEntityState &= ~eBallElem;
+ theMode &= ~eBallElem;
+ }
+
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
+ myEntityState &= ~eEdges;
+ theMode &= ~eEdges;
+ }
+
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
+ myEntityState &= ~eFaces;
+ theMode &= ~eFaces;
+ }
+
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
+ myEntityState &= ~eVolumes;
+ theMode &= ~eVolumes;
+ }
+
+ if (!theMode) {
+ if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
+ theMode |= e0DElements;
+
+ if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
+ theMode |= eBallElem;
+
+ if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
+ theMode |= eEdges;
+
+ if(myVisualObj->GetNbEntities(SMDSAbs_Face))
+ theMode |= eFaces;
+
+ if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
+ theMode |= eVolumes;
+ }
+
+ myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
+
+ myEntityMode = theMode;
+ VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
+ aFilter = myBaseActor->GetExtractUnstructuredGrid();
+ aFilter->ClearRegisteredCellsWithType();
+ aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+
+ VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
+ aHightFilter->ClearRegisteredCellsWithType();
+ aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+
+ if (myEntityMode & e0DElements) {
+ if (MYDEBUG) MESSAGE("0D ELEMENTS");
+ aFilter->RegisterCellsWithType(VTK_VERTEX);
+ aHightFilter->RegisterCellsWithType(VTK_VERTEX);
+ }
+
+ if (myEntityMode & eBallElem) {
+ aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
+ }
+
+ if (myEntityMode & eEdges) {
+ if (MYDEBUG) MESSAGE("EDGES");
+ aFilter->RegisterCellsWithType(VTK_LINE);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
+
+ aHightFilter->RegisterCellsWithType(VTK_LINE);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
+ }
+
+ if (myEntityMode & eFaces) {
+ if (MYDEBUG) MESSAGE("FACES");
+ aFilter->RegisterCellsWithType(VTK_TRIANGLE);
+ aFilter->RegisterCellsWithType(VTK_POLYGON);
+ aFilter->RegisterCellsWithType(VTK_QUAD);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
+ aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
+ aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
+
+ aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
+ aHightFilter->RegisterCellsWithType(VTK_POLYGON);
+ aHightFilter->RegisterCellsWithType(VTK_QUAD);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
+ aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
+ aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
+ }
+
+ if (myEntityMode & eVolumes) {
+ if (MYDEBUG) MESSAGE("VOLUMES");
+ aFilter->RegisterCellsWithType(VTK_TETRA);
+ aFilter->RegisterCellsWithType(VTK_VOXEL);
+ aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
+ aFilter->RegisterCellsWithType(VTK_WEDGE);
+ aFilter->RegisterCellsWithType(VTK_PYRAMID);
+ aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
+ aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
+ aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
+//#ifdef VTK_HAVE_POLYHEDRON
+ aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
+//#endif
+
+ aHightFilter->RegisterCellsWithType(VTK_TETRA);
+ aHightFilter->RegisterCellsWithType(VTK_VOXEL);
+ aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
+ aHightFilter->RegisterCellsWithType(VTK_WEDGE);
+ aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
+ aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
+ aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
+ aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
+//#ifdef VTK_HAVE_POLYHEDRON
+ aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
+//#endif
+ }
+ aFilter->Update();
+ if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
+ SetVisibility(GetVisibility(),false);
+}
+
+void SMESH_ActorDef::SetRepresentation (int theMode)
+{
+ int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
+ int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
+ int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
+ int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
+ int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
+
+ if (theMode < 0) {
+ myRepresentation = eSurface;
+ if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
+ myRepresentation = eEdge;
+ } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
+ myRepresentation = ePoint;
+ }
+ } else {
+ switch (theMode) {
+ case eEdge:
+ if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
+ break;
+ case eSurface:
+ if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
+ break;
+ }
+ myRepresentation = theMode;
+ }
+
+ if (!GetUnstructuredGrid()->GetNumberOfCells())
+ myRepresentation = ePoint;
+
+ if (myIsShrunk) {
+ if (myRepresentation == ePoint) {
+ UnShrink();
+ myIsShrunk = true;
+ } else {
+ SetShrink();
+ }
+ }
+
+ myPickableActor = myBaseActor;
+ myNodeActor->SetVisibility(false);
+ myNodeExtActor->SetVisibility(false);
+ vtkProperty *aProp = NULL, *aBackProp = NULL;
+ vtkProperty *aPropVN = NULL, *aPropVR = NULL;
+ SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
+ SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
+ switch (myRepresentation) {
+ case ePoint:
+ myPickableActor = myNodeActor;
+ myNodeActor->SetVisibility(true);
+ aQuadraticMode = SMESH_Actor::eLines;
+ aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
+ aReperesent = SMESH_DeviceActor::ePoint;
+ break;
+ case eEdge:
+ aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
+ aReperesent = SMESH_DeviceActor::eInsideframe;
+ break;
+ case eSurface:
+ aProp = mySurfaceProp;
+ aBackProp = myBackSurfaceProp;
+ aPropVN = myNormalVProp;
+ aPropVR = myReversedVProp;
+ aReperesent = SMESH_DeviceActor::eSurface;
+ break;
+ }
+
+ my2DActor->SetProperty(aProp);
+ my2DActor->SetBackfaceProperty(aBackProp);
+ my2DActor->SetRepresentation(aReperesent);
+
+ if(aQuadraticMode == SMESH_Actor::eLines)
+ my2DActor->SetQuadraticArcMode(false);
+ else if(aQuadraticMode == SMESH_Actor::eArcs)
+ my2DActor->SetQuadraticArcMode(true);
+
+ my2DExtActor->SetRepresentation(aReperesent);
+
+ my3DActor->SetProperty(aPropVN);
+ my3DActor->SetBackfaceProperty(aPropVR);
+ my3DActor->SetRepresentation(aReperesent);
+
+
+ my1DExtActor->SetVisibility(false);
+ my2DExtActor->SetVisibility(false);
+ my3DExtActor->SetVisibility(false);
+
+ my0DActor->SetRepresentation(aReperesent);
+ myBallActor->SetRepresentation(aReperesent);
+
+ switch(myControlMode){
+ case eLength:
+ case eMultiConnection:
+ aProp = aBackProp = my1DProp;
+ if(myRepresentation != ePoint)
+ aReperesent = SMESH_DeviceActor::eInsideframe;
+ break;
+ }
+
+ if(aQuadraticMode == SMESH_Actor::eLines)
+ my1DActor->SetQuadraticArcMode(false);
+ else if(aQuadraticMode == SMESH_Actor::eArcs)
+ my1DActor->SetQuadraticArcMode(true);
+
+ my1DActor->SetProperty(aProp);
+ my1DActor->SetBackfaceProperty(aBackProp);
+ my1DActor->SetRepresentation(aReperesent);
+
+ my1DExtActor->SetRepresentation(aReperesent);
+
+ if(myIsPointsVisible)
+ myPickableActor = myNodeActor;
+ if(GetPointRepresentation())
+ myNodeActor->SetVisibility(true);
+
+ SetMapper(myPickableActor->GetMapper());
+
+ SetVisibility(GetVisibility(),false);
+
+ Modified();
+}
+
+
+void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
+ if ( myIsPointsVisible == theIsPointsVisible )
+ return;
+ myIsPointsVisible = theIsPointsVisible;
+ SetRepresentation(GetRepresentation());
+}
+
+bool SMESH_ActorDef::GetPointRepresentation(){
+ return myIsPointsVisible || myNodeActor->GetPointsLabeled();
+}
+
+
+void SMESH_ActorDef::UpdateHighlight(){
+ myHighlitableActor->SetHighlited(false);
+ myHighlitableActor->SetVisibility(false);
+ bool anIsVisible = GetVisibility();
+
+ switch(myRepresentation){
+ case SMESH_DeviceActor::eSurface:
+ case SMESH_DeviceActor::eWireframe:
+ {
+ if(myIsHighlighted) {
+ myHighlitableActor->SetProperty(myHighlightProp);
+ }else if(myIsPreselected){
+ myHighlitableActor->SetProperty(myPreselectProp);
+ } else if(anIsVisible){
+ (myRepresentation == eSurface) ?
+ myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
+ }
+ if(GetUnstructuredGrid()->GetNumberOfCells()) {
+ myHighlitableActor->SetHighlited(anIsVisible);
+ myHighlitableActor->GetExtractUnstructuredGrid()->
+ SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
+ myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
+ }
+ myHighlitableActor->SetVisibility(anIsVisible);
+ break;
+ }
+ case SMESH_DeviceActor::ePoint:
+ {
+ if(myIsHighlighted) {
+ myNodeActor->SetProperty(myHighlightProp);
+ }else if(myIsPreselected) {
+ myNodeActor->SetProperty(myPreselectProp);
+ } else if(anIsVisible) {
+ myNodeActor->SetProperty(myNodeProp);
+ }
+ myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
+ myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
+ break;
+ }
+ }
+}
+
+
+void SMESH_ActorDef::highlight(bool theHighlight){
+ if ( myIsHighlighted == theHighlight )
+ return;
+ myIsHighlighted = theHighlight;
+ UpdateHighlight();
+}
+
+
+void SMESH_ActorDef::SetPreSelected(bool thePreselect){
+ if ( myIsPreselected == thePreselect )
+ return;
+ myIsPreselected = thePreselect;
+ UpdateHighlight();
+}
+
+
+// From vtkFollower
+int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
+{
+ if (myPickableActor->GetIsOpaque())
+ {
+ vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
+ this->Render(ren);
+ return 1;
+ }
+ return 0;
+}
+
+
+int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
+{
+ if (!myPickableActor->GetIsOpaque())
+ {
+ vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
+ this->Render(ren);
+ return 1;
+ }
+ return 0;
+}
+
+
+void SMESH_ActorDef::Render(vtkRenderer *ren){
+ unsigned long aTime = myTimeStamp->GetMTime();
+ unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
+ unsigned long aClippingTime = myImplicitBoolean->GetMTime();
+ if(anObjTime > aTime || aClippingTime > aTime)
+ Update();
+}
+
+
+void SMESH_ActorDef::Update(){
+ if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
+
+ if(GetControlMode() != eNone) {
+ unsigned long aTime = myTimeStamp->GetMTime();
+ unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
+ if (anObjTime > aTime)
+ SetControlMode(GetControlMode(),false);
+ }
+
+ if(myNodeActor)
+ myNodeActor->UpdateLabels();
+
+ if(my0DActor)
+ my0DActor->UpdateLabels();
+
+ if(myBallActor)
+ myBallActor->UpdateLabels();
+
+ if(my1DActor)
+ my1DActor->UpdateLabels();
+
+ if(my2DActor)
+ my2DActor->UpdateLabels();
+
+ if(my3DActor)
+ my3DActor->UpdateLabels();
+
+ if(myIsFacesOriented){
+ SetFacesOriented(myIsFacesOriented);
+ }
+
+ if(myVisualObj->GetEntitiesFlag()) {
+ myEntityMode |= myVisualObj->GetEntitiesState();
+ }
+
+ SetEntityMode(GetEntityMode());
+ SetVisibility(GetVisibility());
+
+ myTimeStamp->Modified();
+ Modified();
+}
+
+
+void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
+ SALOME_Actor::ReleaseGraphicsResources(renWin);
+
+ myPickableActor->ReleaseGraphicsResources(renWin);
+}
+
+
+static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b){
+ double* aColor = theProperty->GetColor();
+ r = aColor[0];
+ g = aColor[1];
+ b = aColor[2];
+}
+
+
+void SMESH_ActorDef::SetOpacity(double theValue){
+ mySurfaceProp->SetOpacity(theValue);
+ myBackSurfaceProp->SetOpacity(theValue);
+ myNormalVProp->SetOpacity(theValue);
+ myReversedVProp->SetOpacity(theValue);
+ myEdgeProp->SetOpacity(theValue);
+ myOutLineProp->SetOpacity(theValue);
+ myNodeProp->SetOpacity(theValue);
+
+ my1DProp->SetOpacity(theValue);
+ my0DProp->SetOpacity(theValue);
+ myBallProp->SetOpacity(theValue);
+}
+
+
+double SMESH_ActorDef::GetOpacity(){
+ return mySurfaceProp->GetOpacity();
+}
+
+
+void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta){
+ mySurfaceProp->SetColor(r,g,b);
+ my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+ if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+ if( aGroupObj->GetElementType() == SMDSAbs_Face )
+ myNameActor->SetBackgroundColor(r,g,b);
+
+ myDeltaBrightness = delta;
+ QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
+ myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
+ Modified();
+}
+
+void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta){
+ ::GetColor(mySurfaceProp,r,g,b);
+ delta = myDeltaBrightness;
+}
+
+void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta){
+ myNormalVProp->SetColor(r,g,b);
+ my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+ if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+ if( aGroupObj->GetElementType() == SMDSAbs_Volume )
+ myNameActor->SetBackgroundColor(r,g,b);
+
+ myDeltaVBrightness = delta;
+ QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
+ myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
+ Modified();
+}
+
+void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta){
+ ::GetColor(myNormalVProp,r,g,b);
+ delta = myDeltaVBrightness;
+}
+
+void SMESH_ActorDef::SetEdgeColor(double r,double g,double b){
+ myEdgeProp->SetColor(r,g,b);
+ my1DProp->SetColor(r,g,b);
+ my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+ if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+ if( aGroupObj->GetElementType() == SMDSAbs_Edge )
+ myNameActor->SetBackgroundColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b){
+ ::GetColor(myEdgeProp,r,g,b);
+}
+
+void SMESH_ActorDef::SetOutlineColor(double r,double g,double b){
+ myOutLineProp->SetColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b){
+ ::GetColor(myOutLineProp,r,g,b);
+}
+
+
+void SMESH_ActorDef::SetNodeColor(double r,double g,double b){
+ myNodeProp->SetColor(r,g,b);
+ myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+ if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+ if( aGroupObj->GetElementType() == SMDSAbs_Node )
+ myNameActor->SetBackgroundColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b){
+ ::GetColor(myNodeProp,r,g,b);
+}
+
+void SMESH_ActorDef::Set0DColor(double r,double g,double b){
+ my0DProp->SetColor(r,g,b);
+ if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+ if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
+ myNameActor->SetBackgroundColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b){
+ ::GetColor(my0DProp,r,g,b);
+}
+
+void SMESH_ActorDef::SetBallColor(double r,double g,double b){
+ myBallProp->SetColor(r,g,b);
+ if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+ if( aGroupObj->GetElementType() == SMDSAbs_Ball )
+ myNameActor->SetBackgroundColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b){
+ ::GetColor(myBallProp,r,g,b);
+}
+
+void SMESH_ActorDef::SetHighlightColor(double r,double g,double b){
+ myHighlightProp->SetColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b){
+ ::GetColor(myHighlightProp,r,g,b);
+}
+
+void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b){
+ myPreselectProp->SetColor(r,g,b);
+ Modified();
+}
+
+void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b){
+ ::GetColor(myPreselectProp,r,g,b);
+}
+
+
+double SMESH_ActorDef::GetLineWidth(){
+ return myEdgeProp->GetLineWidth();
+}
+
+
+void SMESH_ActorDef::SetLineWidth(double theVal){
+ myEdgeProp->SetLineWidth(theVal);
+
+ my1DProp->SetLineWidth(theVal + aLineWidthInc);
+ my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
+ my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
+ my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
+ myOutLineProp->SetLineWidth(theVal);
+ myHighlightProp->SetLineWidth(theVal);
+ myPreselectProp->SetLineWidth(theVal);
+ Modified();
+}
+
+double SMESH_ActorDef::GetOutlineWidth()
+{
+ return myOutLineProp->GetLineWidth();
+}
+
+void SMESH_ActorDef::SetOutlineWidth(double theVal)
+{
+ myOutLineProp->SetLineWidth(theVal);
+ Modified();
+}
+
+void SMESH_ActorDef::Set0DSize(double theVal){
+ my0DProp->SetPointSize(theVal);
+ myHighlightProp->SetPointSize(theVal);
+ myPreselectProp->SetPointSize(theVal);
+
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
+ aCustom->Set0DSize(theVal);
+ }
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
+ aCustom->Set0DSize(theVal);
+ }
+
+ Modified();
+}
+
+double SMESH_ActorDef::Get0DSize(){
+ return my0DProp->GetPointSize();
+}
+
+void SMESH_ActorDef::SetBallSize(double theVal){
+ myBallProp->SetPointSize(theVal);
+
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
+ aCustom->SetBallSize(theVal);
+ }
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
+ aCustom->SetBallSize(theVal);
+ }
+
+ Modified();
+}
+
+double SMESH_ActorDef::GetBallSize(){
+ return myBallProp->GetPointSize();
+}
+
+double SMESH_ActorDef::GetBallScale()
+{
+ return myBallActor->GetBallScale();
+}
+
+void SMESH_ActorDef::SetBallScale( double theVal )
+{
+ myBallActor->SetBallScale( theVal );
+}
+
+int SMESH_ActorDef::GetObjDimension( const int theObjId )
+{
+ return myVisualObj->GetElemDimension( theObjId );
+}
+
+bool
+SMESH_ActorDef::
+IsImplicitFunctionUsed() const
+{
+ return myBaseActor->IsImplicitFunctionUsed();
+}
+
+void
+SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
+{
+ myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+}
+
+vtkIdType
+SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
+{
+ if(thePlane){
+ myImplicitBoolean->GetFunction()->AddItem(thePlane);
+ myCippingPlaneCont.push_back(thePlane);
+ if(!IsImplicitFunctionUsed())
+ SetImplicitFunctionUsed(true);
+ myNodeActor->UpdateLabels();
+ }
+ return myCippingPlaneCont.size();
+}
+
+void
+SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
+{
+ if(thePlane)
+ myPlaneCollection->AddItem( thePlane );
+}
+
+void
+SMESH_ActorDef::SetOpenGLClippingPlane()
+{
+ // before use this method you must add clipping planes using method
+ // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
+ if( !myPlaneCollection->GetNumberOfItems() )
+ return;
+
+ // It is necessary to set plane collection for each mapper of actor
+ // and update current inputs of mapper
+ myNodeActor->SetPlaneCollection( myPlaneCollection );
+ myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ myBaseActor->SetPlaneCollection( myPlaneCollection );
+ myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ myHighlitableActor->SetPlaneCollection( myPlaneCollection );
+ myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my1DActor->SetPlaneCollection( myPlaneCollection );
+ my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my2DActor->SetPlaneCollection( myPlaneCollection );
+ my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ myNodeExtActor->SetPlaneCollection( myPlaneCollection );
+ myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my0DActor->SetPlaneCollection( myPlaneCollection );
+ my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ myBallActor->SetPlaneCollection( myPlaneCollection );
+ myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my1DExtActor->SetPlaneCollection( myPlaneCollection );
+ my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my2DExtActor->SetPlaneCollection( myPlaneCollection );
+ my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my3DActor->SetPlaneCollection( myPlaneCollection );
+ my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ my3DExtActor->SetPlaneCollection( myPlaneCollection );
+ my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
+ if(IsShrunk())
+ SetShrink();
+ else
+ Modified();
+}
+
+void
+SMESH_ActorDef::
+RemoveAllClippingPlanes()
+{
+ myPlaneCollection->RemoveAllItems();
+ myImplicitBoolean->GetFunction()->RemoveAllItems();
+ myImplicitBoolean->GetFunction()->Modified(); // VTK bug
+ myCippingPlaneCont.clear();
+ SetImplicitFunctionUsed(false);
+ myNodeActor->UpdateLabels();
+}
+
+vtkIdType
+SMESH_ActorDef::
+GetNumberOfClippingPlanes()
+{
+ return myCippingPlaneCont.size();
+}
+
+vtkPlane*
+SMESH_ActorDef::
+GetClippingPlane(vtkIdType theID)
+{
+ if(theID >= myCippingPlaneCont.size())
+ return NULL;
+ return myCippingPlaneCont[theID].Get();
+}
+
+void SMESH_ActorDef::UpdateScalarBar()
+{
+ SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
+ if( !mgr )
+ return;
+
+ vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
+
+ QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
+ aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
+
+ aScalarBarTitleProp->SetFontFamilyToArial();
+
+ if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
+ {
+ QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
+ if ( f.family() == "Arial" )
+ aScalarBarTitleProp->SetFontFamilyToArial();
+ else if ( f.family() == "Courier" )
+ aScalarBarTitleProp->SetFontFamilyToCourier();
+ else if ( f.family() == "Times" )
+ aScalarBarTitleProp->SetFontFamilyToTimes();
+
+ if ( f.bold() )
+ aScalarBarTitleProp->BoldOn();
+ else
+ aScalarBarTitleProp->BoldOff();
+
+ if ( f.italic() )
+ aScalarBarTitleProp->ItalicOn();
+ else
+ aScalarBarTitleProp->ItalicOff();
+
+ if ( f.overline() )
+ aScalarBarTitleProp->ShadowOn();
+ else
+ aScalarBarTitleProp->ShadowOff();
+ }
+
+ myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
+ aScalarBarTitleProp->Delete();
+
+ vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
+
+ aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
+ aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
+
+ aScalarBarLabelProp->SetFontFamilyToArial();
+ if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
+ {
+ QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
+ if( f.family() == "Arial" )
+ aScalarBarLabelProp->SetFontFamilyToArial();
+ else if( f.family() == "Courier" )
+ aScalarBarLabelProp->SetFontFamilyToCourier();
+ else if( f.family() == "Times" )
+ aScalarBarLabelProp->SetFontFamilyToTimes();
+
+ if ( f.bold() )
+ aScalarBarLabelProp->BoldOn();
+ else
+ aScalarBarLabelProp->BoldOff();
+
+ if ( f.italic() )
+ aScalarBarLabelProp->ItalicOn();
+ else
+ aScalarBarLabelProp->ItalicOff();
+
+ if( f.overline() )
+ aScalarBarLabelProp->ShadowOn();
+ else
+ aScalarBarLabelProp->ShadowOff();
+ }
+
+ myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
+ aScalarBarLabelProp->Delete();
+
+ bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
+ QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
+ if( horiz )
+ myScalarBarActor->SetOrientationToHorizontal();
+ else
+ myScalarBarActor->SetOrientationToVertical();
+
+
+ double aXVal = horiz ? 0.20 : 0.01;
+ if( mgr->hasValue( "SMESH", name + "x" ) )
+ aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
+
+ double aYVal = horiz ? 0.01 : 0.1;
+ if( mgr->hasValue( "SMESH", name + "y" ) )
+ aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
+ myScalarBarActor->SetPosition( aXVal, aYVal );
+
+ double aWVal = horiz ? 0.60 : 0.10;
+ if( mgr->hasValue( "SMESH", name + "width" ) )
+ aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
+ myScalarBarActor->SetWidth( aWVal );
+
+ double aHVal = horiz ? 0.12 : 0.80;
+ if( mgr->hasValue( "SMESH", name + "height" ) )
+ aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
+ myScalarBarActor->SetHeight( aHVal );
+
+ int anIntVal = 5;
+ if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
+ anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
+ myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
+
+ anIntVal = 64;
+ if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
+ anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
+ myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
+
+ bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
+ myScalarBarActor->SetDistributionVisibility(distributionVisibility);
+
+ int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
+ myScalarBarActor->SetDistributionColoringType(coloringType);
+
+ QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
+ QColor(255, 255, 255));
+ double rgb[3];
+ rgb[0]= distributionColor.red()/255.;
+ rgb[1]= distributionColor.green()/255.;
+ rgb[2]= distributionColor.blue()/255.;
+ myScalarBarActor->SetDistributionColor(rgb);
+
+
+}
+
+void SMESH_ActorDef::UpdateDistribution()
+{
+ if(SMESH::Controls::NumericalFunctor* fun =
+ dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
+ {
+ int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
+ std::vector<int> nbEvents;
+ std::vector<double> funValues;
+ SMESH_VisualObjDef::TEntityList elems;
+ if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
+ dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
+ std::vector<int> elemIds;
+ for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
+ elemIds.push_back( (*e)->GetID());
+ vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
+ double * range = lookupTable->GetRange();
+ bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
+ fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
+ myScalarBarActor->SetDistribution(nbEvents);
+ }
+}
+
+void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
+{
+ switch(theMode) {
+ case SMESH_Actor::eLines :
+ myHighlitableActor->SetQuadraticArcMode(false);
+ my2DActor->SetQuadraticArcMode(false);
+ my1DActor->SetQuadraticArcMode(false);
+ break;
+ case SMESH_Actor::eArcs :
+ myHighlitableActor->SetQuadraticArcMode(true);
+ if(GetRepresentation() != SMESH_Actor::ePoint) {
+ my2DActor->SetQuadraticArcMode(true);
+ my1DActor->SetQuadraticArcMode(true);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+
+SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
+{
+ if(myHighlitableActor->GetQuadraticArcMode())
+ return SMESH_Actor::eArcs;
+ else
+ return SMESH_Actor::eLines;
+}
+
+void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
+{
+ SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
+ myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
+ myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
+}
+
+void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
+{
+ SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
+ myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
+ myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
+ myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
+}
+
+#ifndef DISABLE_PLOT2DVIEWER
+SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
+
+ if(my2dHistogram)
+ my2dHistogram->clearAllPoints();
+
+ if(SMESH::Controls::NumericalFunctor* fun =
+ dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
+ {
+
+ if(!my2dHistogram) {
+ my2dHistogram = new SPlot2d_Histogram();
+ Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
+ my2dHistogram->setIO(anIO);
+ }
+
+ int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
+ std::vector<int> nbEvents;
+ std::vector<double> funValues;
+ SMESH_VisualObjDef::TEntityList elems;
+ if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
+ dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
+ std::vector<int> elemIds;
+
+ for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
+ elemIds.push_back( (*e)->GetID());
+
+ vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
+ double * range = lookupTable->GetRange();
+ bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
+ fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
+
+ for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
+ my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
+
+ if(funValues.size() >= 2)
+ my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
+
+ }
+
+ //Color of the histogram
+ if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
+ my2dHistogram->setAutoAssign(true);
+ else {
+ double rgb[3];
+ myScalarBarActor->GetDistributionColor(rgb);
+ QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
+ my2dHistogram->setColor(aColor);
+
+ }
+
+ return my2dHistogram;
+}
+#endif