From d47ca8dce1de4da09f250c015916282e6c1b325d Mon Sep 17 00:00:00 2001 From: sln Date: Tue, 9 Dec 2008 12:46:35 +0000 Subject: [PATCH] 0013557: field values display Now you can display values applied to the cells or nodes of 3D presentation intended for visualization of calculation data. New methods are provided in actor. This class is chaged for storing parameters of labels and update actor accordinly --- src/VISU_I/VISU_ColoredPrs3d_i.cc | 218 +++++++++++++++++++++++++++++- src/VISU_I/VISU_ColoredPrs3d_i.hh | 59 ++++++++ src/VISU_I/VISU_GaussPoints_i.cc | 17 +++ src/VISU_I/VISU_ScalarMap_i.cc | 16 +++ 4 files changed, 308 insertions(+), 2 deletions(-) diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index daa06daa..44605b54 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -1586,7 +1586,7 @@ VISU::ColoredPrs3d_i myIsBoldTitle = f.bold(); myIsItalicTitle = f.italic(); - myIsShadowTitle = f.underline(); + myIsShadowTitle = f.overline(); } QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); @@ -1611,7 +1611,7 @@ VISU::ColoredPrs3d_i myIsBoldLabel = f.bold(); myIsItalicLabel = f.italic(); - myIsShadowLabel = f.underline(); + myIsShadowLabel = f.overline(); } QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); @@ -1621,7 +1621,41 @@ VISU::ColoredPrs3d_i myLabelColor[0] = aLabelColor.red() / 255.; myLabelColor[1] = aLabelColor.green() / 255.; myLabelColor[2] = aLabelColor.blue() / 255.; + + // Parameters of labels displaed field values + myValLblFontType = VTK_ARIAL; + myIsBoldValLbl = true; + myIsItalicValLbl = myIsShadowValLbl = false; + myValLblFontSize = 12; + if( aResourceMgr->hasValue( "VISU", "values_labeling_font" ) ) + { + // family + QFont f = aResourceMgr->fontValue( "VISU", "values_labeling_font" ); + if ( f.family() == "Arial" ) + myValLblFontType = VTK_ARIAL; + else if ( f.family() == "Courier" ) + myValLblFontType = VTK_COURIER; + else if ( f.family() == "Times" ) + myValLblFontType = VTK_TIMES; + + // size + if ( f.pointSize() > -1 ) + myValLblFontSize = f.pointSize(); + + // color + QColor aColor = aResourceMgr->colorValue( + "VISU", "values_labeling_color", QColor( 255, 255, 255 ) ); + myValLblFontColor[ 0 ] = aColor.red() / 255.; + myValLblFontColor[ 1 ] = aColor.green() / 255.; + myValLblFontColor[ 2 ] = aColor.blue()/ 255.; + + // bold, italic, shadow + myIsBoldValLbl = f.bold(); + myIsItalicValLbl = f.italic(); + myIsShadowValLbl = f.overline(); + } + return this; } @@ -1731,6 +1765,18 @@ VISU::ColoredPrs3d_i } } } + + // Parameters of labels displayed field values + + myValLblFontType = VISU::Storable::FindValue( theMap, "myValLblFontType", "0" ).toInt(); + myIsBoldValLbl = VISU::Storable::FindValue( theMap, "myIsBoldValLbl", "1" ).toInt(); + myIsItalicValLbl = VISU::Storable::FindValue( theMap, "myIsItalicValLbl", "0" ).toInt(); + myIsShadowValLbl = VISU::Storable::FindValue( theMap, "myIsShadowValLbl", "0" ).toInt(); + myValLblFontSize = VISU::Storable::FindValue( theMap, "myValLblFontSize", "12" ).toDouble(); + myValLblFontColor[ 0 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[0]", "1" ).toFloat(); + myValLblFontColor[ 1 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[1]", "1" ).toFloat(); + myValLblFontColor[ 2 ] = VISU::Storable::FindValue( theMap, "myValLblFontColor[2]", "1" ).toFloat(); + return this; } @@ -1790,6 +1836,18 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] ); Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] ); Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] ); + + // Parameters of labels displayed field values + + Storable::DataToStream( theStr, "myValLblFontType", myValLblFontType ); + Storable::DataToStream( theStr, "myIsBoldValLbl", myIsBoldValLbl ); + Storable::DataToStream( theStr, "myIsItalicValLbl", myIsItalicValLbl ); + Storable::DataToStream( theStr, "myIsShadowValLbl", myIsShadowValLbl ); + Storable::DataToStream( theStr, "myValLblFontSize", myValLblFontSize ); + Storable::DataToStream( theStr, "myValLblFontColor[0]", myValLblFontColor[ 0 ] ); + Storable::DataToStream( theStr, "myValLblFontColor[1]", myValLblFontColor[ 1 ] ); + Storable::DataToStream( theStr, "myValLblFontColor[2]", myValLblFontColor[ 2 ] ); + std::ostringstream aGeomNameList; std::string aMeshName = GetCMeshName(); @@ -1943,3 +2001,159 @@ VISU::ColoredPrs3d_i } //---------------------------------------------------------------------------- + + +int +VISU::ColoredPrs3d_i +::GetValLblFontType() const +{ + return myValLblFontType; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetValLblFontType( const int theType ) +{ + if ( myValLblFontType == theType ) + return; + + VISU::TSetModified aModified( this ); + + myValLblFontType = theType; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +double +VISU::ColoredPrs3d_i +::GetValLblFontSize() const +{ + return myValLblFontSize; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetValLblFontSize( const double theSize ) +{ + if ( VISU::CheckIsSameValue( myValLblFontSize, theSize ) ) + return; + + VISU::TSetModified aModified( this ); + + myValLblFontSize = theSize; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::GetValLblFontColor( vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB ) const +{ + theR = myValLblFontColor[ 0 ]; + theG = myValLblFontColor[ 1 ]; + theB = myValLblFontColor[ 2 ]; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetValLblFontColor( const vtkFloatingPointType theR, + const vtkFloatingPointType theG, + const vtkFloatingPointType theB ) +{ + if ( VISU::CheckIsSameValue( myValLblFontColor[ 0 ], theR ) && + VISU::CheckIsSameValue( myValLblFontColor[ 1 ], theG ) && + VISU::CheckIsSameValue (myValLblFontColor[ 2 ], theB ) ) + return; + + VISU::TSetModified aModified(this); + + myValLblFontColor[ 0 ] = theR; + myValLblFontColor[ 1 ] = theG; + myValLblFontColor[ 2 ] = theB; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +bool +VISU::ColoredPrs3d_i +::IsBoldValLbl() const +{ + return myIsBoldValLbl; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetBoldValLbl( const bool theVal ) +{ + if ( myIsBoldValLbl == theVal ) + return; + + VISU::TSetModified aModified( this ); + + myIsBoldValLbl = theVal; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +bool +VISU::ColoredPrs3d_i +::IsItalicValLbl() const +{ + return myIsItalicValLbl; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetItalicValLbl( const bool theVal ) +{ + if ( myIsItalicValLbl == theVal ) + return; + + VISU::TSetModified aModified( this ); + + myIsItalicValLbl = theVal; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + +bool +VISU::ColoredPrs3d_i +::IsShadowValLbl() const +{ + return myIsShadowValLbl; +} + +//---------------------------------------------------------------------------- + +void +VISU::ColoredPrs3d_i +::SetShadowValLbl( const bool theVal ) +{ + if ( myIsShadowValLbl == theVal ) + return; + + VISU::TSetModified aModified( this ); + + myIsShadowValLbl = theVal; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- + diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index df1e0c84..73cd4807 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -581,6 +581,58 @@ namespace VISU return myColoredPL; } + virtual + int + GetValLblFontType() const; + + virtual + void + SetValLblFontType( const int theType ); + + virtual + double + GetValLblFontSize() const; + + virtual + void + SetValLblFontSize( const double theSize ); + + virtual + bool + IsBoldValLbl() const; + + virtual + void + SetBoldValLbl( const bool theVal ); + + virtual + bool + IsItalicValLbl() const; + + virtual + void + SetItalicValLbl( const bool theVal ); + + virtual + bool + IsShadowValLbl() const; + + virtual + void + SetShadowValLbl( const bool theVal ); + + virtual + void + GetValLblFontColor( vtkFloatingPointType& theR, + vtkFloatingPointType& theG, + vtkFloatingPointType& theB ) const; + + virtual + void + SetValLblFontColor( const vtkFloatingPointType theR, + const vtkFloatingPointType theG, + const vtkFloatingPointType theB ); + //---------------------------------------------------------------------------- protected: /*! @@ -713,6 +765,13 @@ namespace VISU bool myIsDistributionVisible; // RKV + // Result labels + int myValLblFontType; + double myValLblFontSize; + bool myIsBoldValLbl; + bool myIsItalicValLbl; + bool myIsShadowValLbl; + vtkFloatingPointType myValLblFontColor[ 3 ]; }; diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 8039cbc6..ef1f7427 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -1000,7 +1000,24 @@ VISU::GaussPoints_i theActor->SetRepresentation( VTK_POINTS ); else theActor->SetRepresentation( VTK_SURFACE ); + + // Update values labels + + vtkTextProperty* aProp = anActor->GetsValLabelsProps(); + if ( aProp ) + { + aProp->SetFontFamily( GetValLblFontType() ); + aProp->SetFontSize( GetValLblFontSize() ); + aProp->SetBold( IsBoldValLbl() ); + aProp->SetItalic( IsItalicValLbl() ); + aProp->SetShadow( IsShadowValLbl() ); + + vtkFloatingPointType anRGB[ 3 ]; + GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + } } + TSuperClass::UpdateActor(theActor); } diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index db272f3d..1ef187fe 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -491,6 +491,22 @@ VISU::ScalarMap_i anActor->SetBarVisibility(myShowBar); aScalarBar->Modified(); + + // Update values labels + + vtkTextProperty* aProp = anActor->GetsValLabelsProps(); + if ( aProp ) + { + aProp->SetFontFamily( GetValLblFontType() ); + aProp->SetFontSize( GetValLblFontSize() ); + aProp->SetBold( IsBoldValLbl() ); + aProp->SetItalic( IsItalicValLbl() ); + aProp->SetShadow( IsShadowValLbl() ); + + vtkFloatingPointType anRGB[ 3 ]; + GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); + } } TSuperClass::UpdateActor(theActor); } -- 2.39.2