Fix for "0023306: [EDF 8444] Mesh controls behavior" issue.

This commit is contained in:
ana 2016-08-08 19:34:54 +03:00
parent b3cb4c5a57
commit 9341b16ef3
7 changed files with 105 additions and 16 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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; }

View File

@ -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; i<this->NumberOfLabels; i++)
{
renderedSomething += this->TextActors[i]->RenderOverlay(viewport);
}
for (i=0; i<this->NumberOfLabels; 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;
}

View File

@ -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<int> 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.

View File

@ -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

View File

@ -63,6 +63,34 @@
<source>AREA_ELEMENTS</source>
<translation>Area</translation>
</message>
<message>
<source>FREE_NODES</source>
<translation>Free nodes</translation>
</message>
<message>
<source>FREE_EDGES</source>
<translation>Free edges</translation>
</message>
<message>
<source>FREE_FACES</source>
<translation>Free faces</translation>
</message>
<message>
<source>BARE_BORDER_FACE</source>
<translation>Faces with bare border</translation>
</message>
<message>
<source>OVER_CONSTRAINED_FACE</source>
<translation>Over-constrained faces</translation>
</message>
<message>
<source>BARE_BORDER_VOLUME</source>
<translation>Volumes with bare border</translation>
</message>
<message>
<source>OVER_CONSTRAINED_VOLUME</source>
<translation>Over-constrained volumes</translation>
</message>
<message>
<source>MIN_DIAG_ELEMENTS</source>
<translation>Minimum diagonal</translation>