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
}
}
-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() )
}
}
-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() )
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() );
+}
DataTag_Points,
DataTag_Sections,
DataTag_PolylineShape,
- DataTag_WireColor,
+ DataTag_WireColor, //DEPRECATED; DataTag_SectionColors for coloring of individual section of polyline
DataTag_SectionColors,
};
/**
* 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.
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;
void removePointsLists( const int theSectionIndex = -1 ) const;
+ void setPythonPolylineSectionColor( QStringList& theScript,
+ const int theSectIndex,
+ const QColor& theColor ) const;
protected:
std::vector<TopoDS_Wire> aCurves;
GetWires(thePolyline, aCurves);
bool isOK = true;
+
+ std::vector<QColor> 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<n; i++ )
{
std::vector<TopoDS_Shape> aCurvesList;
Split( aCurves[i], thePoint, theTolerance, aCurvesList );
- bool isLocalOK = CreatePolylines( theDoc, thePolyline, aCurvesList, true );
+ NCollection_IndexedDataMap<Handle(HYDROData_PolylineXY), TopoDS_Shape> 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;
}
return false;
}
+ std::vector<QColor> aSectColors;
+ int nbSec = thePolyline->NbSections();
+
+
+
const int aPSCount = aCurves.size();
const int aTSCount = aToolCurves.size();
std::vector<TopoDS_Shape> 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 <TopoDS_Shape, QColor, TopTools_ShapeMapHasher> W2Color;
+
for (int aPSI = 0; aPSI < aPSCount; ++aPSI)
{
HYDROData_TopoCurve aCurve;
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<Handle(HYDROData_PolylineXY), TopoDS_Shape> 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;
}
bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
const Handle( HYDROData_PolylineXY )& theOldPolyline,
const std::vector<TopoDS_Shape>& theShapes,
- bool isUseIndices )
+ bool isUseIndices,
+ NCollection_IndexedDataMap<Handle(HYDROData_PolylineXY), TopoDS_Shape>& outPoly2Sh)
{
if( theDoc.IsNull() )
return false;
if ( theOldPolyline.IsNull() )
return false;
const QString& theNamePrefix = theOldPolyline->GetName();
- const QColor& theColor = theOldPolyline->GetWireColor();
int n = theShapes.size();
DEBTRACE("theShapes.size() "<< n);
aPolyline->SetName( theNamePrefix );
}
- if( theColor.isValid() )
- aPolyline->SetWireColor( theColor );
+ outPoly2Sh.Add(aPolyline, theShapes[i]);
}
return true;
}
#include <Geom2d_Curve.hxx>
#include <gp_Pnt2d.hxx>
#include <vector>
+#include <NCollection_IndexedDataMap.hxx>
class HYDROData_Document;
class HYDROData_TopoCurve;
static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
const Handle( HYDROData_PolylineXY )& theOldPolyline,
const std::vector<TopoDS_Shape>& theShape,
- bool isUseIndices );
+ bool isUseIndices,
+ NCollection_IndexedDataMap<Handle(HYDROData_PolylineXY), TopoDS_Shape>& outPoly2Sh);
};
#endif
// 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() )
{
}
}
// all input wires in the <aSectionWiresList>
- 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 );
}
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 );
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;
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 );
+ }
}
}
}
QList<Handle(AIS_InteractiveObject)> 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 );
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 )
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)
{
}
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
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 );
#include <AIS_Shape.hxx>
#include <QList>
+#include <NCollection_IndexedDataMap.hxx>
+#include <Quantity_Color.hxx>
+#include <TopTools_ShapeMapHasher.hxx>
class TopoDS_Shape;
class TopoDS_Edge;
( const TopoDS_Shape& theShape, int theType, int theSize );
static void update( const QList<Handle(AIS_InteractiveObject)>&, int theType, int theSize );
+ NCollection_IndexedDataMap<TopoDS_Shape, Quantity_Color, TopTools_ShapeMapHasher> myShapeToColor;
+
+ bool GetColorOfSubShape(const TopoDS_Shape& SubShape, Quantity_Color& outColor);
+
public:
DEFINE_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape);
+
};
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,
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
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) );
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 );
}
}
- if ( !myIsEdit )
- {
- aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
- }
+ //if ( !myIsEdit )
+ //{
+ // aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
+ //}
// Update the wire of polyline
aPolylineObj->Update();
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;
}
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) ) )
{
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopExp_Explorer.hxx>
+#include <TopExp.hxx>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
}
}
- QColor aWireColor = aPolyline->GetWireColor();
- setBorderColor( aWireColor, false, false );
+ //QColor aWireColor = aPolyline->GetWireColor();
+ std::vector<QColor> 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;i<nbSec;i++)
+ {
+ const TopoDS_Shape& CW = MW(i+1);
+ Quantity_Color aFColor( getQuantityColorVal( aSectColors[i].red() ),
+ getQuantityColorVal( aSectColors[i].green() ),
+ getQuantityColorVal( aSectColors[i].blue() ),
+ Quantity_TOC_RGB );
+ aPShape->myShapeToColor.Add(CW, aFColor);
+ }
+ }
+ }
+ }
+ }
+
+ //if ( theToDisplay && isVisible() && !myContext.IsNull() )
+ // displayShape( false );
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
{
}
}
- QColor aWireColor = aPolyline->GetWireColor();
+ //QColor aWireColor = aPolyline->GetWireColor();
//setBorderColor( aWireColor, false, false );
}
else if ( anObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
*/
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:
/**
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 = Wire2d( aCoords, false );
- aPolyline->SetShape( aWire );
+
+ //QList<double> aCoords = QList<double>() << 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 );
{
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();