From 7fcd7955f1f7d10e37e5460567491542ce207b26 Mon Sep 17 00:00:00 2001 From: isn Date: Fri, 7 Dec 2018 18:21:56 +0300 Subject: [PATCH] lot 3 - coloring of section in OCC view see also refs #1838 --- src/HYDROData/HYDROData_IPolyline.cxx | 23 ++++- src/HYDROData/HYDROData_IPolyline.h | 12 ++- src/HYDROData/HYDROData_PolylineOperator.cxx | 87 +++++++++++++++--- src/HYDROData/HYDROData_PolylineOperator.h | 4 +- src/HYDROData/HYDROData_PolylineXY.cxx | 86 +++++++++++------ src/HYDROGUI/HYDROGUI_Polyline.cxx | 61 +++++++++--- src/HYDROGUI/HYDROGUI_Polyline.h | 13 ++- src/HYDROGUI/HYDROGUI_PolylineOp.cxx | 12 +-- src/HYDROGUI/HYDROGUI_SetColorOp.cxx | 17 +++- src/HYDROGUI/HYDROGUI_Shape.cxx | 45 ++++++++- src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx | 2 +- src/HYDROPy/HYDROData_IPolyline.sip | 11 +++ .../linux/Split_Polylines_Colors.png | Bin 5722 -> 3263 bytes .../win32/Split_Polylines_Colors.png | Bin 4906 -> 3983 bytes src/HYDRO_tests/test_HYDROData_PolylineXY.cxx | 41 +++++++-- 15 files changed, 328 insertions(+), 86 deletions(-) diff --git a/src/HYDROData/HYDROData_IPolyline.cxx b/src/HYDROData/HYDROData_IPolyline.cxx index 1ec97913..ddd6908a 100644 --- a/src/HYDROData/HYDROData_IPolyline.cxx +++ b/src/HYDROData/HYDROData_IPolyline.cxx @@ -41,7 +41,11 @@ HYDROData_IPolyline::~HYDROData_IPolyline() void HYDROData_IPolyline::SetWireColor( const QColor& theColor ) { - SetColor( theColor, DataTag_WireColor ); + //SetColor( theColor, DataTag_WireColor ); //DEPRECATED; + //set theColor for all sections + int nbSec = NbSections(); + for (int i = 0; i < nbSec; i++) + SetSectionColor(i, theColor); } QColor HYDROData_IPolyline::GetWireColor() const @@ -168,7 +172,7 @@ void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const } } -bool HYDROData_IPolyline::getSectionColor( const int theSectionIndex, QColor &theColor) const +bool HYDROData_IPolyline::GetSectionColor( const int theSectionIndex, QColor &theColor) const { TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, false ); if ( aLabel.IsNull() ) @@ -189,8 +193,8 @@ bool HYDROData_IPolyline::getSectionColor( const int theSectionIndex, QColor &th } } -void HYDROData_IPolyline::setSectionColor( const int theSectionIndex, - const QColor& theColor ) const +void HYDROData_IPolyline::SetSectionColor( const int theSectionIndex, + const QColor& theColor ) { TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, true ); if ( aLabel.IsNull() ) @@ -228,3 +232,14 @@ void HYDROData_IPolyline::removeSectionColor( const int theSectionIndex ) const aSectLabel.ForgetAllAttributes(); } } + + void HYDROData_IPolyline::setPythonPolylineSectionColor( QStringList& theScript, + const int theSectIndex, + const QColor& theColor ) const +{ + QString anObjName = GetObjPyName(); + theScript << QString( "%1.SetSectionColor( %2, QColor( %3, %4, %5, %6 ) )" ) + .arg( anObjName ).arg( theSectIndex ) + .arg( theColor.red() ).arg( theColor.green() ) + .arg( theColor.blue() ).arg( theColor.alpha() ); +} diff --git a/src/HYDROData/HYDROData_IPolyline.h b/src/HYDROData/HYDROData_IPolyline.h index c8916d4c..5795ce4b 100644 --- a/src/HYDROData/HYDROData_IPolyline.h +++ b/src/HYDROData/HYDROData_IPolyline.h @@ -51,7 +51,7 @@ protected: DataTag_Points, DataTag_Sections, DataTag_PolylineShape, - DataTag_WireColor, + DataTag_WireColor, //DEPRECATED; DataTag_SectionColors for coloring of individual section of polyline DataTag_SectionColors, }; @@ -68,7 +68,7 @@ public: /** * Returns wire color of object. */ - HYDRODATA_EXPORT virtual QColor GetWireColor() const; + HYDRODATA_EXPORT virtual QColor GetWireColor() const; //DEPRECATED /** * Returns default wire color for new object. @@ -191,10 +191,9 @@ public: HYDRODATA_EXPORT TopoDS_Shape GetShape() const; HYDRODATA_EXPORT void SetShape( const TopoDS_Shape& theShape ); - HYDRODATA_EXPORT void setSectionColor( const int theSectionIndex, - const QColor& theColor ) const; + HYDRODATA_EXPORT virtual void SetSectionColor( const int theSectionIndex, const QColor& theColor ); - HYDRODATA_EXPORT bool getSectionColor( const int theSectionIndex, QColor &theColor) const; + HYDRODATA_EXPORT virtual bool GetSectionColor( const int theSectionIndex, QColor &theColor) const; HYDRODATA_EXPORT void removeSectionColor( const int theSectionIndex = -1 ) const; @@ -215,6 +214,9 @@ protected: void removePointsLists( const int theSectionIndex = -1 ) const; + void setPythonPolylineSectionColor( QStringList& theScript, + const int theSectIndex, + const QColor& theColor ) const; protected: diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index 41d0f7c8..1b0c8985 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -86,13 +86,40 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD std::vector aCurves; GetWires(thePolyline, aCurves); bool isOK = true; + + std::vector aSectColors; + int nbSec = thePolyline->NbSections(); + for (int i = 0; i < nbSec; i++) + { + QColor aColor; + thePolyline->GetSectionColor(i, aColor); + aSectColors.push_back(aColor); + } + + bool bsetColor = aCurves.size() == aSectColors.size(); for( int i=0, n=aCurves.size(); i aCurvesList; Split( aCurves[i], thePoint, theTolerance, aCurvesList ); - bool isLocalOK = CreatePolylines( theDoc, thePolyline, aCurvesList, true ); + NCollection_IndexedDataMap outPoly2Sh; + bool isLocalOK = CreatePolylines( theDoc, thePolyline, aCurvesList, true, outPoly2Sh ); isOK = isOK && isLocalOK; + if (bsetColor) + { + QColor aColor = aSectColors[i]; + if( aColor.isValid() ) + { + for (int j=1;j<=outPoly2Sh.Extent();j++) + { + const Handle(HYDROData_PolylineXY)& Poly = outPoly2Sh.FindKey(j); + int nbSec = Poly->NbSections(); + for (int k = 0; k < nbSec; k++) + Poly->SetSectionColor(k, aColor); + } + } + } } + return isOK; } @@ -212,9 +239,27 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD return false; } + std::vector aSectColors; + int nbSec = thePolyline->NbSections(); + + + const int aPSCount = aCurves.size(); const int aTSCount = aToolCurves.size(); std::vector aResult; + + bool bSetColor = aPSCount == nbSec; + if (bSetColor) + { + for (int i = 0; i < nbSec; i++) + { + QColor aColor; + thePolyline->GetSectionColor(i, aColor); + aSectColors.push_back(aColor); + } + } + NCollection_DataMap W2Color; + for (int aPSI = 0; aPSI < aPSCount; ++aPSI) { HYDROData_TopoCurve aCurve; @@ -238,16 +283,35 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD aSplitCurves.end(); for (int iw=0; aCIt != aLastCIt; ++aCIt, iw++) { - std::stringstream brepName; - brepName << "theSplitWire_"; - brepName << iw; - brepName << ".brep"; - BRepTools::Write(aCIt->Wire() , brepName.str().c_str() ); - aResult.push_back(aCIt->Wire()); + //std::stringstream brepName; + //brepName << "theSplitWire_"; + //brepName << iw; + //brepName << ".brep"; + //BRepTools::Write(aCIt->Wire() , brepName.str().c_str() ); + const TopoDS_Wire& aW = aCIt->Wire(); + if (bSetColor) + W2Color.Bind(aW, aSectColors[aPSI]); + aResult.push_back(aW); } } - CreatePolylines( theDoc, thePolyline, aResult, true ); + NCollection_IndexedDataMap outPoly2Sh; + CreatePolylines( theDoc, thePolyline, aResult, true, outPoly2Sh ); + + for (int j=1;j<=outPoly2Sh.Extent();j++) + { + const Handle(HYDROData_PolylineXY)& Poly = outPoly2Sh.FindKey(j); + const TopoDS_Shape& Sh = outPoly2Sh.FindFromIndex(j); + + int nbSec = Poly->NbSections(); + for (int k = 0; k < nbSec; k++) + { + const QColor* color = W2Color.Seek(Sh); + if (color) + Poly->SetSectionColor(k, *color); + } + } + return true; } @@ -301,7 +365,8 @@ void HYDROData_PolylineOperator::Split( bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc, const Handle( HYDROData_PolylineXY )& theOldPolyline, const std::vector& theShapes, - bool isUseIndices ) + bool isUseIndices, + NCollection_IndexedDataMap& outPoly2Sh) { if( theDoc.IsNull() ) return false; @@ -309,7 +374,6 @@ bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Docume if ( theOldPolyline.IsNull() ) return false; const QString& theNamePrefix = theOldPolyline->GetName(); - const QColor& theColor = theOldPolyline->GetWireColor(); int n = theShapes.size(); DEBTRACE("theShapes.size() "<< n); @@ -338,8 +402,7 @@ bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Docume aPolyline->SetName( theNamePrefix ); } - if( theColor.isValid() ) - aPolyline->SetWireColor( theColor ); + outPoly2Sh.Add(aPolyline, theShapes[i]); } return true; } diff --git a/src/HYDROData/HYDROData_PolylineOperator.h b/src/HYDROData/HYDROData_PolylineOperator.h index 6fea4512..ff64142a 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.h +++ b/src/HYDROData/HYDROData_PolylineOperator.h @@ -23,6 +23,7 @@ #include #include #include +#include class HYDROData_Document; class HYDROData_TopoCurve; @@ -85,7 +86,8 @@ protected: static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc, const Handle( HYDROData_PolylineXY )& theOldPolyline, const std::vector& theShape, - bool isUseIndices ); + bool isUseIndices, + NCollection_IndexedDataMap& outPoly2Sh); }; #endif diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index cd7a7100..54c418ac 100644 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -149,8 +149,17 @@ QStringList HYDROData_PolylineXY::DumpToPython( const QString& thePyScript // Set the wire color QStringList aWireColorDef; - QColor aWireColor = GetWireColor(); - setPythonObjectColor( aWireColorDef, aWireColor, DefaultWireColor(), "SetWireColor" ); + //QColor aWireColor = GetWireColor(); + //setPythonObjectColor( aWireColorDef, aWireColor, DefaultWireColor(), "SetWireColor" ); + + int nbSec = NbSections(); + for (int i = 0; i < nbSec; i++) + { + QColor aColor; + GetSectionColor(i, aColor); + setPythonPolylineSectionColor(aWireColorDef, i, aColor ); + //aWireColorDef << ""; + } if ( !aWireColorDef.isEmpty() ) { @@ -829,42 +838,59 @@ void HYDROData_PolylineXY::Update() } } // all input wires in the - Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape; - Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape; - TopTools_ListIteratorOfListOfShape it(aSectionWiresList); - for(;it.More();it.Next()) - { - TopExp_Explorer it2(it.Value(), TopAbs_EDGE); - for(;it2.More();it2.Next()) - aSeqEdges->Append(it2.Current()); - } + TopoDS_Shape aResult; BRep_Builder aBB; TopoDS_Compound aCmp; - TopoDS_Shape aResult; aBB.MakeCompound(aCmp); - if(aSeqEdges->Length() >1) + if (aSectionWiresList.Size() == 1) + aResult = aSectionWiresList.First(); + else if (aSectionWiresList.Size() > 1) { - ShapeAnalysis_FreeBounds::ConnectEdgesToWires( aSeqEdges, 1E-5, Standard_True, aSeqWires ); - - if( aSeqWires->Length()==1 ) - aResult = aSeqWires->Value( 1 ); - else + TopTools_ListIteratorOfListOfShape it(aSectionWiresList); + for(;it.More();it.Next()) { - for (Standard_Integer i = 1; i <= aSeqWires->Length();i++) - { - const TopoDS_Shape& aS1 = aSeqWires->Value(i); - aBB.Add(aCmp, aS1); - } - aResult = aCmp; + aBB.Add(aCmp, it.Value()); } + aResult = aCmp; } - else if (aSeqEdges->Length() == 1) - { - BRepBuilderAPI_MakeWire mkWire (TopoDS::Edge(aSeqEdges->Value(1))); - if (mkWire.IsDone()) - aResult = mkWire.Wire(); - } + + //Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape; + //Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape; + //TopTools_ListIteratorOfListOfShape it(aSectionWiresList); + //for(;it.More();it.Next()) + //{ + // TopExp_Explorer it2(it.Value(), TopAbs_EDGE); + // for(;it2.More();it2.Next()) + // aSeqEdges->Append(it2.Current()); + //} + // + //BRep_Builder aBB; + //TopoDS_Compound aCmp; + //TopoDS_Shape aResult; + //aBB.MakeCompound(aCmp); + //if(aSeqEdges->Length() >1) + //{ + // ShapeAnalysis_FreeBounds::ConnectEdgesToWires( aSeqEdges, 1E-5, Standard_True, aSeqWires ); + // + // if( aSeqWires->Length()==1 ) + // aResult = aSeqWires->Value( 1 ); + // else + // { + // for (Standard_Integer i = 1; i <= aSeqWires->Length();i++) + // { + // const TopoDS_Shape& aS1 = aSeqWires->Value(i); + // aBB.Add(aCmp, aS1); + // } + // aResult = aCmp; + // } + //} + //else if (aSeqEdges->Length() == 1) + //{ + // BRepBuilderAPI_MakeWire mkWire (TopoDS::Edge(aSeqEdges->Value(1))); + // if (mkWire.IsDone()) + // aResult = mkWire.Wire(); + //} SetShape( aResult ); } diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx index edc05ccc..0119af16 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.cxx +++ b/src/HYDROGUI/HYDROGUI_Polyline.cxx @@ -62,12 +62,28 @@ Handle( Graphic3d_ArrayOfPolylines ) BuildEdgePresentation( const TopoDS_Edge& t return anArray; } +bool HYDROGUI_Polyline::GetColorOfSubShape(const TopoDS_Shape& SubShape, Quantity_Color& outColor) +{ + for (int i=1; i<=myShapeToColor.Extent();i++) + { + const TopoDS_Shape& aCurShape = myShapeToColor.FindKey(i); + TopTools_IndexedMapOfShape aSubShMap; + TopExp::MapShapes(aCurShape, aSubShMap); + if (aSubShMap.Contains(SubShape)) + { + outColor = myShapeToColor(i); + return true; + } + } + return false; +} + void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPrs, const Standard_Integer aMode) { //AIS_Shape::Compute(aPresentationManager, aPrs, aMode); - //return; + // return; aPrs->Clear(); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs ); @@ -78,7 +94,6 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre anWidth =2; Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d( aColor, aType, anWidth ); - TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE ); Bnd_Box BB; BRepBndLib::AddClose(myshape, BB); double xmin, xmax, ymin, ymax, zmin, zmax; @@ -89,14 +104,27 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre double minSide = Min(Abs(xmax - xmin), Abs(ymax - ymin)); devCoeff = minSide > 50 ? 0.05 : minSide / 3000; } - for ( ; Exp1.More(); Exp1.Next() ) + + TopExp_Explorer Exp ( myshape, TopAbs_WIRE ); + for ( ; Exp.More(); Exp.Next() ) { - TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() ); - Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, devCoeff ); - if( !anArray.IsNull() ) + TopoDS_Shape W = Exp.Current(); + TopExp_Explorer Exp1 (W, TopAbs_EDGE ); + Quantity_Color aWCol = aColor; //from drawer + if (myShapeToColor.Contains(W)) + { + Quantity_Color aWCol = myShapeToColor.FindFromKey(W); + anAspect = new Graphic3d_AspectLine3d( aWCol, aType, anWidth ); + } + for ( ; Exp1.More(); Exp1.Next() ) { - aGroup->SetPrimitivesAspect( anAspect ); - aGroup->AddPrimitiveArray( anArray ); + TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() ); + Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, devCoeff); + if( !anArray.IsNull() ) + { + aGroup->SetPrimitivesAspect( anAspect ); + aGroup->AddPrimitiveArray( anArray ); + } } } } @@ -107,7 +135,8 @@ QList HYDROGUI_Polyline::createPresentations QList shapes; // 1. Main shape - shapes.append( new HYDROGUI_Polyline( theShape ) ); + Handle(HYDROGUI_Polyline) aMPoly = new HYDROGUI_Polyline( theShape ); + shapes.append( aMPoly ); // 2. Shapes for direction arrows on edges TopExp_Explorer Exp ( theShape, TopAbs_EDGE ); @@ -116,7 +145,7 @@ QList HYDROGUI_Polyline::createPresentations TopoDS_Edge anEdge = TopoDS::Edge(Exp.Current()); if ( !anEdge.IsNull() ) { - Handle(HYDROGUI_Arrow) arrow = new HYDROGUI_Arrow( anEdge ); + Handle(HYDROGUI_Arrow) arrow = new HYDROGUI_Arrow( anEdge, aMPoly ); if( theType>=0 ) arrow->SetType( (HYDROGUI_Arrow::Type)theType ); if( theSize>=0 ) @@ -149,8 +178,8 @@ void HYDROGUI_Polyline::update( const QList& theO IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Arrow, AIS_Shape) -HYDROGUI_Arrow::HYDROGUI_Arrow( const TopoDS_Edge& edge ) - : AIS_Shape( edge ), myType( Cone ), mySize( 35 ) + HYDROGUI_Arrow::HYDROGUI_Arrow( const TopoDS_Edge& edge, const Handle(HYDROGUI_Polyline)& polyline ) + : AIS_Shape( edge ), myType( Cone ), mySize( 35 ), myParentPoly (polyline) { } @@ -178,6 +207,11 @@ void HYDROGUI_Arrow::SetSize( int theSize ) mySize = qMax( theSize, 0 ); } +const Handle(HYDROGUI_Polyline)& HYDROGUI_Arrow::getParentPolyline() const +{ + return myParentPoly; +} + void HYDROGUI_Arrow::BoundingBox (Bnd_Box& theBndBox) { //Nothing to change, we consider arrow as object with empty bounding box @@ -239,6 +273,9 @@ void HYDROGUI_Arrow::Compute( const Handle(PrsMgr_PresentationManager3d)& aPrese Attributes()->LineAspect()->Aspect()->Values( aColor, aType, anWidth ); anWidth = 1; + const Handle(HYDROGUI_Polyline)& aParentPoly = getParentPolyline(); + aParentPoly->GetColorOfSubShape(anEdge, aColor); + if( myType==Cone ) { Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d( aColor, aType, anWidth ); diff --git a/src/HYDROGUI/HYDROGUI_Polyline.h b/src/HYDROGUI/HYDROGUI_Polyline.h index 06f2ec44..be993fe6 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.h +++ b/src/HYDROGUI/HYDROGUI_Polyline.h @@ -21,6 +21,9 @@ #include #include +#include +#include +#include class TopoDS_Shape; class TopoDS_Edge; @@ -39,8 +42,13 @@ public: ( const TopoDS_Shape& theShape, int theType, int theSize ); static void update( const QList&, int theType, int theSize ); + NCollection_IndexedDataMap myShapeToColor; + + bool GetColorOfSubShape(const TopoDS_Shape& SubShape, Quantity_Color& outColor); + public: DEFINE_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape); + }; class HYDROGUI_Arrow : public AIS_Shape @@ -48,7 +56,7 @@ class HYDROGUI_Arrow : public AIS_Shape public: enum Type { None, Triangle, Cone }; - HYDROGUI_Arrow( const TopoDS_Edge& edge ); + HYDROGUI_Arrow( const TopoDS_Edge& edge, const Handle(HYDROGUI_Polyline)& polyline ); virtual ~HYDROGUI_Arrow(); virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, @@ -63,12 +71,15 @@ public: int GetSize() const; void SetSize( int ); + const Handle(HYDROGUI_Polyline)& getParentPolyline() const; + public: DEFINE_STANDARD_RTTIEXT(HYDROGUI_Arrow, AIS_Shape); private: Type myType; int mySize; + Handle(HYDROGUI_Polyline) myParentPoly; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index ff4205b1..9c3ffd7e 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -185,7 +185,7 @@ void HYDROGUI_PolylineOp::startOperation() Quantity_Color aColor = CurveCreator_Utils::getRandColor(); QColor aQColor = CurveCreator_Utils::colorConv(aColor); - myEditedObject->getSectionColor(i-1, aQColor); + myEditedObject->GetSectionColor(i-1, aQColor); myCurve->addSectionInternal( aSectName.toStdString(), aCurveType, aSectClosure, aCurveCoords, CurveCreator_Utils::colorConv(aQColor) ); @@ -359,7 +359,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, aPolylineObj->AddSection( aSectName, aSectType, aSectClosure ); Quantity_Color aColor = myCurve->getColorSection(i); - aPolylineObj->setSectionColor(i, CurveCreator_Utils::colorConv(aColor)); + aPolylineObj->SetSectionColor(i, CurveCreator_Utils::colorConv(aColor)); // Add the points from section CurveCreator::Coordinates aCurveCoords = myCurve->getCoords( i ); @@ -382,10 +382,10 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, } } - if ( !myIsEdit ) - { - aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() ); - } + //if ( !myIsEdit ) + //{ + // aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() ); + //} // Update the wire of polyline aPolylineObj->Update(); diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx index 73263527..eb52c47e 100644 --- a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx @@ -96,7 +96,12 @@ void HYDROGUI_SetColorOp::startOperation() Handle(HYDROData_IPolyline) aPolyObject = Handle(HYDROData_IPolyline)::DownCast( myEditedObject ); - aFirstColor = aPolyObject->GetWireColor(); + //aFirstColor = aPolyObject->GetWireColor(); + + if (aPolyObject->NbSections() > 0) + aPolyObject->GetSectionColor(0, aFirstColor); + else + aFirstColor = aPolyObject->GetWireColor(); anIsOneColor = true; } @@ -159,7 +164,15 @@ bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags, Handle(HYDROData_IPolyline) aPolyObject = Handle(HYDROData_IPolyline)::DownCast( myEditedObject ); - aPolyObject->SetWireColor( aFirstColor ); + //aPolyObject->SetWireColor( aFirstColor ); + int nbSec = aPolyObject->NbSections(); + if (nbSec > 0) + { + for (int i = 0; i < nbSec; i++) + aPolyObject->SetSectionColor(i, aFirstColor); + } + else + aPolyObject->SetWireColor( aFirstColor ); } else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) ) { diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 27568465..69158160 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -185,8 +186,48 @@ void HYDROGUI_Shape::update( bool isUpdateViewer, } } - QColor aWireColor = aPolyline->GetWireColor(); - setBorderColor( aWireColor, false, false ); + //QColor aWireColor = aPolyline->GetWireColor(); + std::vector aSectColors; + //TODO backward comp. with old aWireColor?? + int nbSec = aPolyline->NbSections(); + for (int i = 0; i < nbSec; i++) + { + QColor aColor; + aPolyline->GetSectionColor(i, aColor); + aSectColors.push_back(aColor); + } + + // + //setBorderColor( aWireColor, false, false ); + + foreach( Handle(AIS_InteractiveObject) aShape, myShapes ) + { + if( !myTopoShape.IsNull() ) + { + Handle(HYDROGUI_Polyline) aPShape = Handle(HYDROGUI_Polyline)::DownCast( aShape ); + bool WireOrCmp = myTopoShape.ShapeType() == TopAbs_WIRE || myTopoShape.ShapeType() == TopAbs_COMPOUND; + if ( !aPShape.IsNull() && WireOrCmp) + { + TopTools_IndexedMapOfShape MW; + TopExp::MapShapes(myTopoShape, TopAbs_WIRE, MW); + if (MW.Extent() == nbSec) + { + for (int i=0;imyShapeToColor.Add(CW, aFColor); + } + } + } + } + } + + //if ( theToDisplay && isVisible() && !myContext.IsNull() ) + // displayShape( false ); } else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) ) { diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx index 487cc470..ce016a55 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx +++ b/src/HYDROGUI/HYDROGUI_VTKPrsShape.cxx @@ -148,7 +148,7 @@ void HYDROGUI_VTKPrsShape::buildShape() } } - QColor aWireColor = aPolyline->GetWireColor(); + //QColor aWireColor = aPolyline->GetWireColor(); //setBorderColor( aWireColor, false, false ); } else if ( anObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) ) diff --git a/src/HYDROPy/HYDROData_IPolyline.sip b/src/HYDROPy/HYDROData_IPolyline.sip index cb455acd..0960af1a 100644 --- a/src/HYDROPy/HYDROData_IPolyline.sip +++ b/src/HYDROPy/HYDROData_IPolyline.sip @@ -68,6 +68,17 @@ public: */ static QColor DefaultWireColor(); + /** + * Sets color for section of polyline. + */ + virtual void SetSectionColor( const int theSectionIndex, const QColor& theColor ); + + /** + * Returns color of section of polyline. + */ + virtual bool GetSectionColor( const int theSectionIndex, QColor &theColor ) const; + + public: /** diff --git a/src/HYDRO_tests/reference_data/linux/Split_Polylines_Colors.png b/src/HYDRO_tests/reference_data/linux/Split_Polylines_Colors.png index 98177d9911e6dd0514467e35bd86356c74fcb622..eb2d07c69df5d77dc52f181398a2c66465b6111d 100644 GIT binary patch literal 3263 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYU<&471B!guShN{PaTa()7BevL9RXp+soH$f z3=BMlo-U3d6?5L+I>>uiL4@_7|C4{wWnKr`GbT=*$#w6jPt-$7#L1)2#gAj z2FPe)7|jTyCBtZ`I9el&)`p|C;b?6*S{n}k+AwB0`-bxQa==c5{ib6-#TXbmDw!|A literal 5722 zcmd^Ddpwlc|3A+&!#pF*AWX;%xhzekcGHr}lhT$H(Yln&po_lSmP;EFp23n-YIT_+ zwEIfhN~82zN<2aeMaxD~DFz|A-!H#|HJiR(zu*4<`(s{n&hwn}dA~oO_jx{_b54xy zmhWVwRHOg^G8;Fnvjc#_0RXkfB;k|J48J?@kM6U<*&hIgG5pCRB|Cre20%%AmD*4ZW$SGd*pRMPe59g z?>NF+chjYUeemJMSDz$O98qeD#?8n_#)rorP|9KeBG6ENRob&h!d4kUZH*E#i#4o4 zss;}9--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/Split_Polylines_Colors.png index 7bcb35d0d420488e27c60d70343cc11e83333191..fc98137fe370c36171509d2f970f32c0c095138c 100644 GIT binary patch literal 3983 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYV2a>i1B%QlYbpRzoCO|{#S9F5M?jcysy3fA z0|URKr;B4q#hkZy{X3>t${zTbu99QTaZ)HE;E5YcQ}xRY7f(j$AL=+I#A}tbt%KQ5 zXNQZlreYO`)mApg1^ z%kL}G>h3=`HfVotd*1kbz68)EKwvg&<5jr^e{-p}i&^Ix7&gfDTApWRV9@$EVRu<> zO$WHd31W`xm_VYE~ntr13R!_nGs zv^E?Gwc$yol(e*GZ>zt*`S*n4#rJ3~WnrU}pDtMeL7AN~6JdilTm*$fO3dQ2_;J|I<=mOG2f%D&CLI*%2o z(zD@1&+hW~|DHWLIeB+jH6PGOHO526dNDgTly6OEU`Ti@q>w%R_y=HygEY#Ioobe~ zEP68g_xJbq8-VUIm$$3=FIU5c~jX=R&EA{ z6C45z3<{e+F&f$Rv=vT20Cax11F*?IfdSa?H`10?@Xp^`BrV3kkW&TZaC^_&yXS%B z8DKZzCX#k#kd7X(4ki|$nKcV7PPD(T|FOOGz3!XZU3+VPe+%E9clXy(VRgTl%9*A4 z_xJt1w=MT}++CnA&(C`|d)BO5rQhD%%uYWy=jX*UXU^P@PpbubbFZYln{j#izda?_ zpPrsxzbWSQ{e88+_b$D?+<*SRcNZ7C$49UG%E%B=@78>NLG9O% zwK%iXdwSpfoyE_mYi~4TV0hiFtuXuMB!-=(udkgCe`WCf{r&w_udb}TtG(3@DBI3( z^UObSh3Dty{yyj>`{>Wl&-ro|1qsLBym@1-UCP72aE+gFQ(0>N!`i1)!}o0|`F*Tc z`ts?G?|>fIw<-1XG~M!dcYanRB|X~C&CR_(s;`uhp`kRh#>9UAjvs&S%{I^f_oemT zU&*gl=H}nueg2)6mUgf1<4*>L8yPW-k-Niw6gwPq&)@s??@?LneS31tzWIOOXZGjw z}@Mc%b&kf|0Duqa=OX4oA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>?U zavYbVk0I8Tj|_*k?i3%OoCQGixS`PwRjT|4 ZiSe%6(kg$PKLt@BXzb*`!~RV2zX2MAZjJx| diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index abc72f65..7ed3645f 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -300,9 +300,21 @@ void test_HYDROData_PolylineXY::test_split_refs_627() Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); aPolyline->SetName( "test" ); - QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire2d( aCoords, false ); - aPolyline->SetShape( aWire ); + + //QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; + aPolyline->AddSection( "", HYDROData_PolylineXY::SECTION_POLYLINE, false ); + aPolyline->AddPoint( 0, gp_XY( 10, 10 ) ); + aPolyline->AddPoint( 0, gp_XY( 20, 10 ) ); + aPolyline->AddPoint( 0, gp_XY( 20, 20 ) ); + aPolyline->AddPoint( 0, gp_XY( 10, 20 ) ); + aPolyline->Update(); + + + //TopoDS_Wire aWire = Wire2d( aCoords, false ); + //aPolyline->SetShape( aWire ); + TopoDS_Shape aW = aPolyline->GetShape(); + CPPUNIT_ASSERT (aW.ShapeType() == TopAbs_WIRE); + aPolyline->SetWireColor( Qt::red ); gp_Pnt2d aPnt( 20, 20 ); @@ -316,25 +328,34 @@ void test_HYDROData_PolylineXY::test_split_refs_627() { Handle(HYDROData_PolylineXY) anObj = Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); if( aPolyline->Label() != anObj->Label() ) - TestViewer::show( anObj->GetShape(), 0, true, anObj->GetWireColor() ); + { + QColor color; + anObj->GetSectionColor(0, color); + TestViewer::show( anObj->GetShape(), 0, true, color ); + } } CPPUNIT_ASSERT_IMAGES HYDROData_Iterator anIt2( aDoc, KIND_POLYLINEXY ); CPPUNIT_ASSERT_EQUAL( true, anIt2.More() ); CPPUNIT_ASSERT_EQUAL( QString( "test" ), anIt2.Current()->GetName() ); - CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), - Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() ); + + QColor color1, color2, color3; + Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetSectionColor(0, color1); + + CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), color1); anIt2.Next(); CPPUNIT_ASSERT_EQUAL( true, anIt2.More() ); CPPUNIT_ASSERT_EQUAL( QString( "test_1" ), anIt2.Current()->GetName() ); - CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), - Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() ); + + Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetSectionColor(0, color2); + CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), color2 ); + anIt2.Next(); CPPUNIT_ASSERT_EQUAL( true, anIt2.More() ); CPPUNIT_ASSERT_EQUAL( QString( "test_2" ), anIt2.Current()->GetName() ); - CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), - Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() ); + Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetSectionColor(0, color3); + CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), color3 ); anIt2.Next(); CPPUNIT_ASSERT_EQUAL( false, anIt2.More() ); anIt2.Next(); -- 2.39.2