X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_PolylineOperator.cxx;h=b991bf7f6992a0728f13c55e2e93e11940eb3cea;hb=cde2ec476486fcd7c9b7b38ce814c648d73e7fd3;hp=a5768945013f69a6b08bf9cbfd60248161d63cbc;hpb=373e0c62c8707f9cfd43796069c9665665375627;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index a5768945..b991bf7f 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include template void append( std::vector& theList, const std::vector& theList2 ) @@ -81,8 +82,9 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD for( int i=0, n=aCurves.size(); i aCurvesList; - Split(aCurves[i], thePoint, theTolerance, aCurvesList); - bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), aCurvesList, true ); + Split( aCurves[i], thePoint, theTolerance, aCurvesList ); + bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), + aCurvesList, true, thePolyline->GetWireColor() ); isOK = isOK && isLocalOK; } return isOK; @@ -161,7 +163,10 @@ bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theD std::vector aPolylines(1); aPolylines[0] = aWireSet; - CreatePolylines(theDoc, theName, aPolylines, false); + QString aName = theName; + if( aName.isEmpty() ) + aName = "merged"; + CreatePolylines( theDoc, aName, aPolylines, true, QColor() ); return true; } @@ -217,19 +222,19 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD aCurve.Intersect(aToolCurves[aTSI], aParams); } - std::deque aSplittedCurves; - theIsIntersected |= aCurve.Cut(aParams, aSplittedCurves); + std::deque aSplitCurves; + theIsIntersected |= aCurve.Cut(aParams, aSplitCurves); std::deque::const_iterator aCIt = - aSplittedCurves.begin(); + aSplitCurves.begin(); std::deque::const_iterator aLastCIt = - aSplittedCurves.end(); + aSplitCurves.end(); for (; aCIt != aLastCIt; ++aCIt) { aResult.push_back(aCIt->Wire()); } } - CreatePolylines(theDoc, thePolyline->GetName(), aResult, true); + CreatePolylines( theDoc, thePolyline->GetName(), aResult, true, thePolyline->GetWireColor() ); return true; } @@ -281,7 +286,8 @@ void HYDROData_PolylineOperator::Split( bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc, const QString& theNamePrefix, const std::vector& theShapes, - bool isUseIndices ) + bool isUseIndices, + const QColor& theColor ) { if( theDoc.IsNull() ) return false; @@ -300,14 +306,20 @@ bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Docume if( isUseIndices ) { QString aNewName = theNamePrefix + "_" + QString::number( anIndex ); - if( theDoc->FindObjectByName( aNewName ).IsNull() ) // the object with such a name is not found - aPolyline->SetName( aNewName ); - anIndex++; + while( !theDoc->FindObjectByName( aNewName ).IsNull() ) // the object with such a name is not found + { + anIndex++; + aNewName = theNamePrefix + "_" + QString::number( anIndex ); + } + aPolyline->SetName( aNewName ); } else { aPolyline->SetName( theNamePrefix ); } + + if( theColor.isValid() ) + aPolyline->SetWireColor( theColor ); } return true; }