X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_ScalarBarActor.cxx;h=a45696d7e9a4e6059276eb03d76a41930f92f374;hp=19d46896b3ee0735886d8ce2e03dd2ddba822f11;hb=417aadaeeab60c5256b8fde16509c975b3023112;hpb=ae29d465091933df101dfac6ae99d3becf4efde7 diff --git a/src/OBJECT/SMESH_ScalarBarActor.cxx b/src/OBJECT/SMESH_ScalarBarActor.cxx index 19d46896b..a45696d7e 100644 --- a/src/OBJECT/SMESH_ScalarBarActor.cxx +++ b/src/OBJECT/SMESH_ScalarBarActor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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; @@ -320,20 +324,20 @@ int SMESH_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport) // rnv begin // Customization of the vtkScalarBarActor to show distribution histogram. - bool distrVisibility = (numColors == this->myNbValues.size()); - vtkPoints *distrPts; - vtkCellArray *distrPolys; + bool distrVisibility = (numColors == (int)this->myNbValues.size()); + vtkPoints *distrPts = 0; + vtkCellArray *distrPolys = 0; vtkUnsignedCharArray *distColors = 0; int numDistrPts = 0, numPositiveVal=0, maxValue=0; if(!distrVisibility) vtkDebugMacro(<<" Distribution invisible, because numColors == this->myNbValues.size()"); - if (distrVisibility && GetDistributionVisibility()) { - for( i=0 ;iGetPointer(3*dcCount); //write into array directly - rgb[0] = rgba[0]; - rgb[1] = rgba[1]; - rgb[2] = rgba[2]; - dcCount++; - } + if ( myDistributionColoringType == SMESH_MULTICOLOR_TYPE && + GetDistributionVisibility() && + distrVisibility && + myNbValues[i] > 0 ) + { + rgb = distColors->GetPointer(3*dcCount); //write into array directly + rgb[0] = rgba[0]; + rgb[1] = rgba[1]; + rgb[2] = rgba[2]; + dcCount++; } + } // Now position everything properly // @@ -820,7 +827,7 @@ void SMESH_ScalarBarActor::AllocateAndSizeLabels(int *labelSize, int targetWidth, targetHeight; // rnv begin // Customization of the vtkScalarBarActor to show distribution histogram. - bool distrVisibility = this->MaximumNumberOfColors == this->myNbValues.size(); + bool distrVisibility = ( this->MaximumNumberOfColors == (int) this->myNbValues.size() ); double coef; if( GetDistributionVisibility() && distrVisibility ) if(this->Orientation == VTK_ORIENT_VERTICAL) @@ -856,40 +863,39 @@ void SMESH_ScalarBarActor::AllocateAndSizeLabels(int *labelSize, } //---------------------------------------------------------------------------- -void SMESH_ScalarBarActor::SizeTitle(int *titleSize, - int *size, - vtkViewport *viewport) +void SMESH_ScalarBarActor::SizeTitle(int *titleSize, + int *size, + vtkViewport *viewport) { titleSize[0] = titleSize[1] = 0; if (this->Title == NULL || !strlen(this->Title)) - { + { return; - } + } int targetWidth, targetHeight; - + targetWidth = size[0]; // rnv begin // Customization of the vtkScalarBarActor to show distribution histogram. - bool distrVisibility = this->MaximumNumberOfColors == this->myNbValues.size(); + bool distrVisibility = ( this->MaximumNumberOfColors == (int) this->myNbValues.size() ); double coef; - if( GetDistributionVisibility() && distrVisibility ) + if ( GetDistributionVisibility() && distrVisibility ) coef=0.18; - else + else coef=0.25; if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - targetHeight = (int)(0.1*size[1]); - } + { + targetHeight = (int)(0.1*size[1]); + } else - { - targetHeight = (int)(coef*size[1]); - } + { + targetHeight = (int)(coef*size[1]); + } - this->TitleMapper->SetConstrainedFontSize( - viewport, targetWidth, targetHeight); + this->TitleMapper->SetConstrainedFontSize(viewport, targetWidth, targetHeight); this->TitleMapper->GetSize(viewport, titleSize); } @@ -921,3 +927,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; +}