From 9341b16ef36f05343f4717ba42765951a50fef5f Mon Sep 17 00:00:00 2001 From: ana Date: Mon, 8 Aug 2016 19:34:54 +0300 Subject: [PATCH] Fix for "0023306: [EDF 8444] Mesh controls behavior" issue. --- src/OBJECT/SMESH_Actor.cxx | 43 +++++++++++++++++++++++++++-- src/OBJECT/SMESH_Actor.h | 1 + src/OBJECT/SMESH_ActorDef.h | 1 + src/OBJECT/SMESH_ScalarBarActor.cxx | 38 ++++++++++++++++--------- src/OBJECT/SMESH_ScalarBarActor.h | 7 +++++ src/SMESHGUI/SMESHGUI.cxx | 3 ++ src/SMESHGUI/SMESH_msg_en.ts | 28 +++++++++++++++++++ 7 files changed, 105 insertions(+), 16 deletions(-) diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index b0136d8e4..4006b506d 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -988,28 +988,33 @@ SetControlMode( eControl theMode, bool theCheckEntityMode ) vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); + bool aShowOnlyScalarBarTitle = false; if(aNbCells){ myControlMode = theMode; switch(myControlMode){ case eFreeNodes: case eCoincidentNodes: myNodeExtActor->SetExtControlMode(myFunctor); + aShowOnlyScalarBarTitle = true; break; case eFreeEdges: case eFreeBorders: case eCoincidentElems1D: my1DExtActor->SetExtControlMode(myFunctor); + aShowOnlyScalarBarTitle = true; break; case eFreeFaces: case eBareBorderFace: case eOverConstrainedFace: case eCoincidentElems2D: my2DExtActor->SetExtControlMode(myFunctor); + aShowOnlyScalarBarTitle = true; break; case eBareBorderVolume: case eOverConstrainedVolume: case eCoincidentElems3D: my3DExtActor->SetExtControlMode(myFunctor); + aShowOnlyScalarBarTitle = true; break; case eLength2D: case eMultiConnection2D: @@ -1020,6 +1025,7 @@ SetControlMode( eControl theMode, bool theCheckEntityMode ) myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable); UpdateDistribution(); } + myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle); } if(theCheckEntityMode) { @@ -1057,6 +1063,9 @@ SetControlMode( eControl theMode, bool theCheckEntityMode ) SetEntityMode(eVolumes); } } + QString aTitle = QString(myScalarBarActor->GetTitle()); + aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities())); + myScalarBarActor->SetTitle(aTitle.toLatin1().constData()); } else { @@ -1081,6 +1090,34 @@ SetControlMode( eControl theMode, bool theCheckEntityMode ) Update(); } +int +SMESH_ActorDef:: +GetNumberControlEntities(){ + SMESH_DeviceActor* anAct = NULL; + switch(myControlMode){ + case eFreeNodes: + case eCoincidentNodes: + anAct = myNodeExtActor; + break; + case eFreeEdges: + case eFreeBorders: + case eCoincidentElems1D: + anAct = my1DExtActor; + break; + case eFreeFaces: + case eBareBorderFace: + case eOverConstrainedFace: + case eCoincidentElems2D: + anAct = my2DExtActor; + break; + case eBareBorderVolume: + case eOverConstrainedVolume: + case eCoincidentElems3D: + anAct = my3DExtActor; + break; + } + return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1; +} void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){ @@ -1424,10 +1461,10 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){ case eLength2D: case eMultiConnection2D: my1DExtActor->VisibilityOn(); - default: - if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells()) - myScalarBarActor->VisibilityOn(); + break; } + if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells()) + myScalarBarActor->VisibilityOn(); } if(myRepresentation != ePoint) diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index 5fc9a92b9..abe27bb4e 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -150,6 +150,7 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor virtual void SetControlMode(eControl theMode) = 0; virtual eControl GetControlMode() = 0; virtual SMESH::Controls::FunctorPtr GetFunctor() = 0; + virtual int GetNumberControlEntities() = 0; virtual SMESH_ScalarBarActor* GetScalarBarActor() = 0; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 927199488..eb3654ab2 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -207,6 +207,7 @@ class SMESH_ActorDef : public SMESH_Actor virtual bool GetFacesOrientation3DVectors(); virtual void SetControlMode(eControl theMode); + virtual int GetNumberControlEntities(); virtual eControl GetControlMode(){ return myControlMode;} virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; } diff --git a/src/OBJECT/SMESH_ScalarBarActor.cxx b/src/OBJECT/SMESH_ScalarBarActor.cxx index 92a8a94b4..1f5b00b63 100644 --- a/src/OBJECT/SMESH_ScalarBarActor.cxx +++ b/src/OBJECT/SMESH_ScalarBarActor.cxx @@ -115,6 +115,9 @@ SMESH_ScalarBarActor::SMESH_ScalarBarActor() { // By default monocolor myDistributionColoringType = SMESH_MONOCOLOR_TYPE; + + // By default scalar map is shown + myTitleOnlyVisibility = false; // rnv end } @@ -194,19 +197,20 @@ int SMESH_ScalarBarActor::RenderOverlay(vtkViewport *viewport) { renderedSomething += this->TitleActor->RenderOverlay(viewport); } - this->ScalarBarActor->RenderOverlay(viewport); - this->myDistributionActor->RenderOverlay(viewport); - if( this->TextActors == NULL) - { - vtkWarningMacro(<<"Need a mapper to render a scalar bar"); - return renderedSomething; - } + if (!myTitleOnlyVisibility) { + this->ScalarBarActor->RenderOverlay(viewport); + this->myDistributionActor->RenderOverlay(viewport); + if( this->TextActors == NULL) + { + vtkWarningMacro(<<"Need a mapper to render a scalar bar"); + return renderedSomething; + } - for (i=0; iNumberOfLabels; i++) - { - renderedSomething += this->TextActors[i]->RenderOverlay(viewport); - } - + for (i=0; iNumberOfLabels; i++) + { + renderedSomething += this->TextActors[i]->RenderOverlay(viewport); + } + } renderedSomething = (renderedSomething > 0)?(1):(0); return renderedSomething; @@ -574,7 +578,7 @@ int SMESH_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport) // rnv begin // Customization of the vtkScalarBarActor to show distribution histogram. - if(myNbValues[i] && myDistributionColoringType == SMESH_MULTICOLOR_TYPE && GetDistributionVisibility() && distrVisibility) + if(myDistributionColoringType == SMESH_MULTICOLOR_TYPE && GetDistributionVisibility() && distrVisibility) { rgb = distColors->GetPointer(3*dcCount); //write into array directly rgb[0] = rgba[0]; @@ -920,3 +924,11 @@ void SMESH_ScalarBarActor::SetDistributionColor (double rgb[3]) { void SMESH_ScalarBarActor::GetDistributionColor (double rgb[3]) { myDistributionActor->GetProperty()->GetColor(rgb); } + +void SMESH_ScalarBarActor::SetTitleOnlyVisibility( bool theTitleOnlyVisibility) { + myTitleOnlyVisibility = theTitleOnlyVisibility; +} + +bool SMESH_ScalarBarActor::GetTitleOnlyVisibility() { + return myTitleOnlyVisibility; +} diff --git a/src/OBJECT/SMESH_ScalarBarActor.h b/src/OBJECT/SMESH_ScalarBarActor.h index 4dda0ad52..ffc91bb11 100644 --- a/src/OBJECT/SMESH_ScalarBarActor.h +++ b/src/OBJECT/SMESH_ScalarBarActor.h @@ -192,7 +192,13 @@ class SMESHOBJECT_EXPORT SMESH_ScalarBarActor: public vtkActor2D { // Get Distribution Color void GetDistributionColor (double rgb[3]); + // Description: + // Set visibility status of scalar map + void SetTitleOnlyVisibility( bool ); + // Description: + // Get visibility status of scalar map + bool GetTitleOnlyVisibility(); protected: SMESH_ScalarBarActor(); @@ -237,6 +243,7 @@ class SMESHOBJECT_EXPORT SMESH_ScalarBarActor: public vtkActor2D { vtkPolyDataMapper2D* myDistributionMapper; //Distribution mapper std::vector myNbValues; //Nb values for the range int myDistributionColoringType; //Distribution color type (monocolor or multicolor) + bool myTitleOnlyVisibility; //Show scalar map or not private: SMESH_ScalarBarActor(const SMESH_ScalarBarActor&); // Not implemented. diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 075b3eb54..6aff7a098 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1668,6 +1668,9 @@ namespace if ( anActor->GetControlMode() != aControl ) anActor->SetControlMode( aControl ); QString functorName = functorToString( anActor->GetFunctor() ); + int anEntitiesCount = anActor->GetNumberControlEntities(); + if (anEntitiesCount >= 0) + functorName = functorName + ": " + QString::number(anEntitiesCount); anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() ); SMESH::RepaintCurrentView(); #ifndef DISABLE_PLOT2DVIEWER diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 5392e5504..76a91b73b 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -63,6 +63,34 @@ AREA_ELEMENTS Area + + FREE_NODES + Free nodes + + + FREE_EDGES + Free edges + + + FREE_FACES + Free faces + + + BARE_BORDER_FACE + Faces with bare border + + + OVER_CONSTRAINED_FACE + Over-constrained faces + + + BARE_BORDER_VOLUME + Volumes with bare border + + + OVER_CONSTRAINED_VOLUME + Over-constrained volumes + MIN_DIAG_ELEMENTS Minimum diagonal -- 2.39.2