#include <TDF_ListIteratorOfLabelList.hxx>
#include <QPainterPath>
+#include <QStringList>
// tage of the child of my label that contains information about the operator
static const Standard_GUID GUID_MUST_BE_UPDATED("6647e1f7-1971-4c5a-86c7-11ff0291452d");
+#define PYTHON_POLYLINE_ID "2"
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline, HYDROData_Object)
{
}
+/**
+ * Dump object to Python script representation.
+ */
+QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList;
+
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+ if ( aDocument.IsNull() )
+ return aResList;
+
+ QString aDocName = aDocument->GetDocPyName();
+ QString aPolylineName = GetName();
+
+ aResList << QString( "%1 = %2.CreateObject( %3 );" )
+ .arg( aPolylineName ).arg( aDocName ).arg( PYTHON_POLYLINE_ID );
+ aResList << QString( "%1.SetName( \"%1\" );" ).arg( aPolylineName );
+
+ // Set polilyne dimension
+
+ aResList << QString( "" );
+
+ int aDim = getDimension();
+ aResList << QString( "%1.setDimension( %2 );" )
+ .arg( aPolylineName ).arg( aDim );
+
+ // Set polilyne data
+
+ PolylineData aPolylineData = getPolylineData();
+ if ( !aPolylineData.isEmpty() )
+ {
+ QString aPolylineDataName = "polyline_data";
+
+ aResList << QString( "" );
+ aResList << QString( "%1 = [];" ).arg( aPolylineDataName );
+
+ PolylineData::const_iterator aDataIt = aPolylineData.constBegin();
+ for ( ; aDataIt != aPolylineData.constEnd(); ++aDataIt )
+ {
+ const PolylineSection& aSection = *aDataIt;
+
+ QString aPolylineSectName = "polyline_section";
+
+ aResList << QString( "" );
+ aResList << QString( "%1 = PolylineSection();" ).arg( aPolylineSectName );
+
+ QString aCoordsStr;
+ foreach( const double& aCoordVal, aSection.myCoords )
+ aCoordsStr += QString::number( aCoordVal ) + ", ";
+ aCoordsStr.remove( aCoordsStr.length() - 2, 2 );
+
+ aResList << QString( "" );
+
+ aResList << QString( "%1.mySectionName = \"%2\";" )
+ .arg( aPolylineSectName )
+ .arg( TCollection_AsciiString( aSection.mySectionName ).ToCString() );
+ aResList << QString( "%1.myType = %2;" )
+ .arg( aPolylineSectName ).arg( aSection.myType );
+ aResList << QString( "%1.myIsClosed = %2;" )
+ .arg( aPolylineSectName ).arg( aSection.myIsClosed );
+ aResList << QString( "%1.myCoords = [ %2 ];" )
+ .arg( aPolylineSectName ).arg( aCoordsStr );
+
+ aResList << QString( "%1.append( %2 );" )
+ .arg( aPolylineDataName ).arg( aPolylineSectName );
+ }
+
+ aResList << QString( "%1.setPolylineData( %2 );" )
+ .arg( aPolylineName ).arg( aPolylineDataName );
+ }
+
+ return aResList;
+}
+
/**
* Return polyline dimension
* \return polyline dimension. 2 or 3 is valid. 0 is invalid.
* Replace current polyline data by new sections list
* \param theSections the sections list
*/
-void HYDROData_Polyline::setPolylineData( const QList<PolylineSection>& theSections )
+void HYDROData_Polyline::setPolylineData( const PolylineData& theSections )
{
//Keep dimension
int aDim = getDimension();
* Return polyline data
* \return polyline section list
*/
-QList<PolylineSection> HYDROData_Polyline::getPolylineData()
+HYDROData_Polyline::PolylineData HYDROData_Polyline::getPolylineData() const
{
int aSectCnt;
- QList<PolylineSection> aRes;
+ PolylineData aRes;
//Get sections size array handle
TDF_Label aLab = myLab.FindChild( DataTag_SectionsSize );
Handle(TDataStd_IntegerArray) aSizeArray;
int aDim = getDimension();
if( ( aDim != 2 ) && ( aDim != 3) )
return aPath;
- QList<PolylineSection> aSects = getPolylineData();
+ PolylineData aSects = getPolylineData();
for( int i = 0 ; i < aSects.size() ; i++ ){
int aPntCnt = aSects[i].myCoords.size()/aDim;
if( aPntCnt ){
DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
-struct PolylineSection{
+struct PolylineSection
+{
public:
enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
*/
class HYDROData_Polyline : public HYDROData_Object
{
+public:
+
+ typedef QList<PolylineSection> PolylineData;
+
protected:
/**
* Enumeration of tags corresponding to the persistent object parameters.
*/
HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
+ /**
+ * Dump object to Python script representation.
+ */
+ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
/**
* Replace current polyline data by new sections list
* \param theSections the sections list
*/
- HYDRODATA_EXPORT void setPolylineData( const QList<PolylineSection>& theSections );
+ HYDRODATA_EXPORT void setPolylineData( const PolylineData& theSections );
/**
* Return polyline data
* \return polyline section list
*/
- HYDRODATA_EXPORT QList<PolylineSection> getPolylineData();
+ HYDRODATA_EXPORT PolylineData getPolylineData() const;
/**
* Return polyline dimension