From 64c772da5a9dd285f16f1f7efa07bb4c7fbdd4c3 Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 16 Nov 2007 13:02:19 +0000 Subject: [PATCH] Color Number (Color Group) parameter is returned for compatibility --- src/DriverMED/DriverMED_Family.cxx | 14 ++++++++-- src/DriverMED/DriverMED_Family.h | 4 +++ src/SMESH/Makefile.am | 2 -- src/SMESH/SMESH_Group.hxx | 9 ------- src/SMESHDS/Makefile.am | 2 -- src/SMESHDS/SMESHDS_GroupBase.cxx | 36 ++++++++++++++++++++++--- src/SMESHDS/SMESHDS_GroupBase.hxx | 16 ++++++----- src/SMESH_I/SMESH_Gen_i.cxx | 5 +--- src/SMESH_I/SMESH_Group_i.cxx | 43 ++++++++++++++++++++++++++++-- src/SMESH_I/SMESH_Group_i.hxx | 3 +++ 10 files changed, 103 insertions(+), 31 deletions(-) diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index 46ae65491..25646c67c 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -217,7 +217,11 @@ DriverMED_Family ColorMap aColorMap; for (aGroupsIter = theGroups.begin(); aGroupsIter != theGroups.end(); aGroupsIter++) { - SALOMEDS::Color aColor = (*aGroupsIter)->GetColor(); + Quantity_Color aQColor = (*aGroupsIter)->GetColor(); + SALOMEDS::Color aColor; + aColor.R = aQColor.Red(); + aColor.G = aQColor.Green(); + aColor.B = aQColor.Blue(); bool isFound = false; for (ColorMap::iterator aColorIter = aColorMap.begin(); aColorIter != aColorMap.end(); aColorIter++) @@ -418,8 +422,14 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup, const ColorMap& theCol ColorMap::const_iterator aColorIter = theColorMap.begin(); for (; aColorIter != theColorMap.end(); aColorIter++) { + Quantity_Color aGroupQColor = theGroup->GetColor(); + SALOMEDS::Color aGroupColor; + aGroupColor.R = aGroupQColor.Red(); + aGroupColor.G = aGroupQColor.Green(); + aGroupColor.B = aGroupQColor.Blue(); + SALOMEDS::Color aColor = aColorIter->second; - if( CompareColors( theGroup->GetColor(), aColor ) ) + if( CompareColors( aGroupColor, aColor ) ) { myGroupAttributVal = aColorIter->first; break; diff --git a/src/DriverMED/DriverMED_Family.h b/src/DriverMED/DriverMED_Family.h index 1925a3471..34ada3db0 100644 --- a/src/DriverMED/DriverMED_Family.h +++ b/src/DriverMED/DriverMED_Family.h @@ -38,6 +38,10 @@ #include #include +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + #define REST_NODES_FAMILY 1 #define REST_EDGES_FAMILY -1 #define REST_FACES_FAMILY -2 diff --git a/src/SMESH/Makefile.am b/src/SMESH/Makefile.am index ec7035606..8ea7e5734 100644 --- a/src/SMESH/Makefile.am +++ b/src/SMESH/Makefile.am @@ -87,8 +87,6 @@ libSMESHimpl_la_CPPFLAGS = \ $(GEOM_CXX_FLAGS) \ $(BOOST_CPPFLAGS) \ $(CAS_CPPFLAGS) \ - $(CORBA_CXXFLAGS) \ - $(CORBA_INCLUDES) \ @HDF5_INCLUDES@ \ -I$(srcdir)/../Controls \ -I$(srcdir)/../Driver \ diff --git a/src/SMESH/SMESH_Group.hxx b/src/SMESH/SMESH_Group.hxx index b90a798dd..76f9cc079 100644 --- a/src/SMESH/SMESH_Group.hxx +++ b/src/SMESH/SMESH_Group.hxx @@ -35,10 +35,6 @@ #include #include -#include "SALOMEconfig.h" -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - class SMESHDS_GroupBase; class SMESH_Mesh; @@ -59,9 +55,6 @@ class SMESH_EXPORT SMESH_Group SMESHDS_GroupBase * GetGroupDS () { return myGroupDS; } - void SetColor (const SALOMEDS::Color& theColor) { myColor = theColor; } - SALOMEDS::Color GetColor() const { return myColor; } - private: SMESH_Group (const SMESH_Group& theOther); // prohibited copy constructor @@ -70,8 +63,6 @@ class SMESH_EXPORT SMESH_Group SMESHDS_GroupBase * myGroupDS; std::string myName; - int myColorNumber; - SALOMEDS::Color myColor; }; #endif diff --git a/src/SMESHDS/Makefile.am b/src/SMESHDS/Makefile.am index 4e8c2247e..23da89e2e 100644 --- a/src/SMESHDS/Makefile.am +++ b/src/SMESHDS/Makefile.am @@ -61,8 +61,6 @@ dist_libSMESHDS_la_SOURCES = \ libSMESHDS_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ - $(CORBA_CXXFLAGS) \ - $(CORBA_INCLUDES) \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../SMDS diff --git a/src/SMESHDS/SMESHDS_GroupBase.cxx b/src/SMESHDS/SMESHDS_GroupBase.cxx index da7b0da13..5221743a9 100644 --- a/src/SMESHDS/SMESHDS_GroupBase.cxx +++ b/src/SMESHDS/SMESHDS_GroupBase.cxx @@ -43,9 +43,7 @@ SMESHDS_GroupBase::SMESHDS_GroupBase (const int theID, myID(theID), myMesh(theMesh), myType(theType), myStoreName(""), myCurIndex(0), myCurID(-1) { - myColor.R = 0.f; - myColor.G = 0.f; - myColor.B = 0.f; + myColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB ); } //============================================================================= @@ -151,3 +149,35 @@ void SMESHDS_GroupBase::SetType(SMDSAbs_ElementType theType) { myType = theType; } + +//======================================================================= +//function : SetType +//purpose : +//======================================================================= + +void SMESHDS_GroupBase::SetColorGroup(int theColorGroup) +{ + if( theColorGroup < 0 || theColorGroup > 360 ) + { + MESSAGE("SMESHDS_GroupBase::SetColorGroup : Value must be in range [0,360]"); + return; + } + + Quantity_Color aColor( (double)theColorGroup, 1.0, 1.0, Quantity_TOC_HLS ); + SetColor( aColor ); +} + +//======================================================================= +//function : SetType +//purpose : +//======================================================================= + +int SMESHDS_GroupBase::GetColorGroup() const +{ + Quantity_Color aColor = GetColor(); + double aHue = aColor.Hue(); + if( aHue < 0 ) + return 0; + return (int)( aHue ); +} + diff --git a/src/SMESHDS/SMESHDS_GroupBase.hxx b/src/SMESHDS/SMESHDS_GroupBase.hxx index 48fd79120..7e2d521e0 100644 --- a/src/SMESHDS/SMESHDS_GroupBase.hxx +++ b/src/SMESHDS/SMESHDS_GroupBase.hxx @@ -32,11 +32,9 @@ #include #include "SMDSAbs_ElementType.hxx" #include "SMDS_MeshElement.hxx" - -#include "SALOMEconfig.h" -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include + class SMESHDS_Mesh; class SMESHDS_EXPORT SMESHDS_GroupBase @@ -72,11 +70,15 @@ class SMESHDS_EXPORT SMESHDS_GroupBase virtual ~SMESHDS_GroupBase() {} - void SetColor (const SALOMEDS::Color& theColor) + void SetColor (const Quantity_Color& theColor) { myColor = theColor;} - SALOMEDS::Color GetColor() const + Quantity_Color GetColor() const { return myColor;} + + void SetColorGroup (int theColorGroup); + + int GetColorGroup() const; protected: const SMDS_MeshElement* findInMesh (const int theID) const; @@ -96,7 +98,7 @@ class SMESHDS_EXPORT SMESHDS_GroupBase int myCurIndex; int myCurID; SMDS_ElemIteratorPtr myIterator; - SALOMEDS::Color myColor; + Quantity_Color myColor; }; #endif diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 7e04c6408..7d57ff916 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -3502,10 +3502,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, double* anRGB = new double[ size ]; aDataset->ReadFromDisk( anRGB ); aDataset->CloseOnDisk(); - SALOMEDS::Color aColor; - aColor.R = anRGB[0]; - aColor.G = anRGB[1]; - aColor.B = anRGB[2]; + Quantity_Color aColor( anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB ); aGroupBaseDS->SetColor( aColor ); } diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 72fb27045..9f4c705f3 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -428,7 +428,15 @@ SALOMEDS::Color SMESH_GroupBase_i::GetColor() { SMESHDS_GroupBase* aGroupDS = GetGroupDS(); if (aGroupDS) - return aGroupDS->GetColor(); + { + Quantity_Color aQColor = aGroupDS->GetColor(); + SALOMEDS::Color aColor; + aColor.R = aQColor.Red(); + aColor.G = aQColor.Green(); + aColor.B = aQColor.Blue(); + + return aColor; + } MESSAGE("get color of a group"); return SALOMEDS::Color(); } @@ -442,7 +450,38 @@ void SMESH_GroupBase_i::SetColor(const SALOMEDS::Color& color) { SMESHDS_GroupBase* aGroupDS = GetGroupDS(); if (aGroupDS) - return aGroupDS->SetColor(color); + { + Quantity_Color aQColor( color.R, color.G, color.B, Quantity_TOC_RGB ); + return aGroupDS->SetColor(aQColor); + } MESSAGE("set color of a group"); return ; } + +//============================================================================= +/*! + * + */ +//============================================================================= +CORBA::Long SMESH_GroupBase_i::GetColorNumber() +{ + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->GetColorGroup(); + MESSAGE("get color number of a group"); + return 0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color) +{ + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->SetColorGroup(color); + MESSAGE("set color number of a group"); + return ; +} diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index ea94e9703..2ed372adb 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -78,6 +78,9 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: void SetColor(const SALOMEDS::Color& color); SALOMEDS::Color GetColor(); + void SetColorNumber(CORBA::Long color); + CORBA::Long GetColorNumber(); + private: SMESH_Mesh_i* myMeshServant; int myLocalID; -- 2.39.2