From: ouv Date: Fri, 7 Aug 2009 10:12:39 +0000 (+0000) Subject: Issue 0020306: EDF 981 VISU : Color of edges of a surface frame representation X-Git-Tag: V5_1_main_20090812 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b6b2c32c11e994275369c176a7b3cb77d6061c8;p=modules%2Fvisu.git Issue 0020306: EDF 981 VISU : Color of edges of a surface frame representation --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 1d7e7640..12efbee1 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -781,6 +781,16 @@ module VISU { */ GaussMetric GetGaussMetric(); + /*! + * Sets the color of mesh links. + * \param theColor The color of the links. This parameter is taken from Color enumeration. + */ + void SetLinkColor(in SALOMEDS::Color theColor); + + /*! + * Gets the color of mesh links. + */ + SALOMEDS::Color GetLinkColor(); }; //------------------------------------------------------- diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index d168f5b7..3aee730b 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -60,6 +60,7 @@ + diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 51e3ed80..028eaf8c 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -317,6 +317,14 @@ VISU_ScalarMapAct myEdgeActor->SetTransform(theTransform); } +//---------------------------------------------------------------------------- +vtkProperty* +VISU_ScalarMapAct +::GetEdgeProperty() +{ + return myEdgeActor->GetProperty(); +} + //---------------------------------------------------------------------------- void VISU_ScalarMapAct @@ -456,6 +464,7 @@ VISU_ScalarMapAct SetBarVisibility(anActor->GetBarVisibility()); myPointsActor->DeepCopy( anActor->myPointsActor ); SetShading(anActor->IsShading()); + GetEdgeProperty()->DeepCopy(anActor->GetEdgeProperty()); } } diff --git a/src/OBJECT/VISU_ScalarMapAct.h b/src/OBJECT/VISU_ScalarMapAct.h index b399f21d..e98af5fe 100644 --- a/src/OBJECT/VISU_ScalarMapAct.h +++ b/src/OBJECT/VISU_ScalarMapAct.h @@ -61,6 +61,10 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor void SetTransform(VTKViewer_Transform* theTransform); + virtual + vtkProperty* + GetEdgeProperty(); + virtual void SetShrinkable(bool theIsShrinkable); diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 16a5edf9..1d07e3b4 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -161,6 +161,10 @@ number of time stamps or number of components is not the same! VISU_DISP_ONLY Display only on creation + + VISU_EDGE_COLOR + Edge Color + VISU_FEATURE_EDGES Feature edges diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index bbaaa4e7..8c724922 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1305,10 +1305,17 @@ VisuGUI return; VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d); - if(!aMesh) + VISU::ScalarMap_i* aScalarMap = dynamic_cast(aPrs3d); + if(!aMesh && !aScalarMap) return; - SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor; + SALOMEDS::Color anOldColor, aNewColor; + if (aMesh) + anOldColor = aMesh->GetLinkColor(); + else if (aScalarMap) + anOldColor = aScalarMap->GetLinkColor(); + + QColor aColor (int(255*anOldColor.R), int(255*anOldColor.G), int(255*anOldColor.B)); @@ -1317,8 +1324,11 @@ VisuGUI aNewColor.R = aColorNew.red()/255.; aNewColor.G = aColorNew.green()/255.; aNewColor.B = aColorNew.blue()/255.; - aMesh->SetLinkColor(aNewColor); - RecreateActor(this, aMesh); + if (aMesh) + aMesh->SetLinkColor(aNewColor); + else + aScalarMap->SetLinkColor(aNewColor); + RecreateActor(this, aPrs3d); } } @@ -3123,7 +3133,7 @@ VisuGUI // "Properties" submenu mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" ); - mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" ); + mgr->setRule( action( VISU_EDGE_COLOR ), aRule + aSurfFrameType + " and representation='VISU::SURFACEFRAME'" ); mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'" " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) " "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" ); @@ -3968,6 +3978,9 @@ void VisuGUI::createPreferences() setPreferenceProperty( maxAngle, "max", 90 ); + addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" ); + addPreference( "", representGr, LightApp_Preferences::Space ); + addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" ); sp = addPreference( "", representGr, LightApp_Preferences::Space ); diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 4d008943..94573944 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -455,6 +455,10 @@ namespace VISU } theStr<GetLinkColor(); + theStr<IsRangeFixed()) theStr<GetMin()<<", "<GetMax()<<")"<colorValue( "VISU", "edge_color", QColor( 255, 255, 255 ) ); + SALOMEDS::Color aLinkColor; + aLinkColor.R = aColor.red()/255.; + aLinkColor.G = aColor.green()/255.; + aLinkColor.B = aColor.blue()/255.; + SetLinkColor(aLinkColor); my2DQuadPrsType = VISU::Quadratic2DPresentationType(VISU::GetResourceMgr()->integerValue( "VISU", "quadratic_mode", 0)); } diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 450c8d99..92a3e43c 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -33,6 +33,7 @@ #include "VISU_ScalarMapAct.h" #include "VISU_ScalarMapPL.hxx" #include "VISU_LookupTable.hxx" +#include "VISU_PipeLineUtils.hxx" #include "VISU_ScalarBarActor.hxx" #include "VISU_Convertor.hxx" @@ -96,6 +97,20 @@ VISU::ScalarMap_i return aResult; } +//---------------------------------------------------------------------------- +namespace +{ + bool + IsSameColor(const SALOMEDS::Color& theLeft, + const SALOMEDS::Color& theRight) + { + return + VISU::CheckIsSameValue(theLeft.R, theRight.R) && + VISU::CheckIsSameValue(theLeft.G, theRight.G) && + VISU::CheckIsSameValue(theLeft.B, theRight.B); + } +} + //---------------------------------------------------------------------------- int VISU::ScalarMap_i::myNbPresent = 0; @@ -227,6 +242,13 @@ VISU::ScalarMap_i else SetScaling(VISU::LINEAR); + QColor aColor = aResourceMgr->colorValue( "VISU", "edge_color", QColor( 255, 255, 255 ) ); + SALOMEDS::Color aLinkColor; + aLinkColor.R = aColor.red()/255.; + aLinkColor.G = aColor.green()/255.; + aLinkColor.B = aColor.blue()/255.; + SetLinkColor(aLinkColor); + int aGaussMetric = aResourceMgr->integerValue("VISU", "scalar_gauss_metric", 0); SetGaussMetric((VISU::GaussMetric)aGaussMetric); @@ -258,6 +280,12 @@ VISU::ScalarMap_i SetGaussMetric(VISU::GaussMetric(VISU::Storable::FindValue(theMap,"myGaussMetric").toInt())); + SALOMEDS::Color aLinkColor; + aLinkColor.R = VISU::Storable::FindValue(theMap,"myLinkColor.R").toDouble(); + aLinkColor.G = VISU::Storable::FindValue(theMap,"myLinkColor.G").toDouble(); + aLinkColor.B = VISU::Storable::FindValue(theMap,"myLinkColor.B").toDouble(); + SetLinkColor(aLinkColor); + // Check if the icon needs to be updated, update if necessary SALOMEDS::Study_var aStudy = theSObject->GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); @@ -282,6 +310,11 @@ VISU::ScalarMap_i Storable::DataToStream( theStr, "myScaling", GetScaling() ); Storable::DataToStream( theStr, "myShowBar", (IsBarVisible()? 1:0) ); Storable::DataToStream( theStr, "myGaussMetric", int(GetGaussMetric()) ); + + SALOMEDS::Color aLinkColor = GetLinkColor(); + Storable::DataToStream( theStr, "myLinkColor.R", aLinkColor.R ); + Storable::DataToStream( theStr, "myLinkColor.G", aLinkColor.G ); + Storable::DataToStream( theStr, "myLinkColor.B", aLinkColor.B ); } @@ -304,6 +337,28 @@ VISU::ScalarMap_i (GetSpecificPL(), &VISU_ColoredPL::SetScaling, theScaling)); } +//---------------------------------------------------------------------------- +void +VISU::ScalarMap_i +::SetLinkColor(const SALOMEDS::Color& theColor) +{ + if(IsSameColor(myLinkColor, theColor)) + return; + + VISU::TSetModified aModified(this); + + myLinkColor = theColor; + myParamsTime.Modified(); +} + +//---------------------------------------------------------------------------- +SALOMEDS::Color +VISU::ScalarMap_i +::GetLinkColor() +{ + return myLinkColor; +} + //---------------------------------------------------------------------------- VISU::GaussMetric VISU::ScalarMap_i @@ -543,6 +598,10 @@ VISU::ScalarMap_i GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] ); } + + // Update edge property + SALOMEDS::Color aLinkColor = GetLinkColor(); + anActor->GetEdgeProperty()->SetColor(aLinkColor.R, aLinkColor.G, aLinkColor.B); } TSuperClass::UpdateActor(theActor); } diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index aba260e0..aa0b4644 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -76,6 +76,15 @@ namespace VISU void SetScaling(VISU::Scaling theScaling); + //---------------------------------------------------------------------------- + virtual + void + SetLinkColor(const SALOMEDS::Color& theColor); + + virtual + SALOMEDS::Color + GetLinkColor(); + //---------------------------------------------------------------------------- virtual VISU::GaussMetric @@ -202,6 +211,7 @@ namespace VISU private: VISU_ScalarMapPL* myScalarMapPL; + SALOMEDS::Color myLinkColor; bool myShowBar; }; }