#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <QStringList>
+#include <QColor>
#include <Geom_BSplineCurve.hxx>
template<class T> void append( std::vector<T>& theList, const std::vector<T>& theList2 )
for( int i=0, n=aCurves.size(); i<n; i++ )
{
std::vector<TopoDS_Shape> 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;
std::vector<TopoDS_Shape> aPolylines(1);
aPolylines[0] = aWireSet;
- CreatePolylines(theDoc, theName, aPolylines, false);
+ CreatePolylines( theDoc, theName, aPolylines, false, QColor() );
return true;
}
}
}
- CreatePolylines(theDoc, thePolyline->GetName(), aResult, true);
+ CreatePolylines( theDoc, thePolyline->GetName(), aResult, true, thePolyline->GetWireColor() );
return true;
}
bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
const QString& theNamePrefix,
const std::vector<TopoDS_Shape>& theShapes,
- bool isUseIndices )
+ bool isUseIndices,
+ const QColor& theColor )
{
if( theDoc.IsNull() )
return false;
{
aPolyline->SetName( theNamePrefix );
}
+
+ if( theColor.isValid() )
+ aPolyline->SetWireColor( theColor );
}
return true;
}
static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
const QString& theNamePrefix,
const std::vector<TopoDS_Shape>& theShape,
- bool isUseIndices );
+ bool isUseIndices,
+ const QColor& theColor );
};
#endif
return Quantity_Color( r, g, b, Quantity_TOC_RGB );
}
+QColor HYDROData_Tool::toQtColor( const Quantity_Color& theColor )
+{
+ int r = 255 * theColor.Red();
+ int g = 255 * theColor.Green();
+ int b = 255 * theColor.Blue();
+ return QColor( r, g, b );
+}
+
std::ostream& operator<<( std::ostream& theStream, const QString& theText )
{
theStream << theText.toStdString();
static TCollection_ExtendedString toExtString( const QString& );
static QString toQString( const TCollection_ExtendedString& );
- static Quantity_Color toOccColor( const QColor& );
+ static Quantity_Color toOccColor( const QColor& );
+ static QColor toQtColor( const Quantity_Color& );
};
inline bool ValuesEquals( const double& theFirst, const double& theSecond )
context()->EraseAll( Standard_False );
myKey = theKey;
+
+ if( theShape.IsNull() )
+ return;
+
int i = 0;
if( theShape.ShapeType()==TopAbs_SHELL )
{
aDoc->Close();
}
+
+void test_HYDROData_PolylineXY::testSplit_refs_627()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+ Handle(HYDROData_PolylineXY) aPolyline =
+ Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ aPolyline->SetName( "test" );
+
+ QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+ TopoDS_Wire aWire = Wire( aCoords, false );
+ aPolyline->SetShape( aWire );
+ aPolyline->SetWireColor( Qt::red );
+
+ gp_Pnt2d aPnt( 20, 20 );
+
+ HYDROData_PolylineOperator anOp;
+ CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) );
+
+ TestViewer::show( TopoDS_Shape(), 0, true, "Split_Polylines_Colors" );
+ HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ Handle(HYDROData_PolylineXY) anObj = Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() );
+ if( aPolyline->Label() != anObj->Label() )
+ TestViewer::show( anObj->GetShape(), 0, true, anObj->GetWireColor() );
+ }
+ 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() );
+ 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() );
+ 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() );
+ anIt2.Next();
+ CPPUNIT_ASSERT_EQUAL( false, anIt2.More() );
+ anIt2.Next();
+}
CPPUNIT_TEST( testPolyline );
CPPUNIT_TEST( testCopy );
CPPUNIT_TEST( testSplit_refs_624 );
+ CPPUNIT_TEST( testSplit_refs_627 );
CPPUNIT_TEST( test_presentation );
CPPUNIT_TEST( test_extraction_immersible_zone );
CPPUNIT_TEST( test_extraction_channel_refs_611 );
void testCopy();
void testSplit_refs_624();
+ void testSplit_refs_627();
void test_extraction_immersible_zone();
void test_extraction_channel_refs_611();