#include <TDataStd_ExtStringList.hxx>
#include <TDataStd_IntegerList.hxx>
#include <TDataStd_RealList.hxx>
+#include <TDataStd_IntegerArray.hxx>
#include <TopoDS_Shape.hxx>
#include <QColor>
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
aSectLabel.ForgetAllAttributes();
}
}
+
+bool HYDROData_IPolyline::GetSectionColor( const int theSectionIndex, QColor &theColor) const
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, false );
+ if ( aLabel.IsNull() )
+ return false;
+
+ TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
+ if ( aSectLabel.IsNull() )
+ return false;
+
+ Handle(TDataStd_IntegerArray) aColorArray;
+
+ if ( aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ {
+ theColor.setRed( aColorArray->Value( 1 ) );
+ theColor.setGreen( aColorArray->Value( 2 ) );
+ theColor.setBlue( aColorArray->Value( 3 ) );
+ theColor.setAlpha( aColorArray->Value( 4 ) );
+ }
+}
+
+void HYDROData_IPolyline::SetSectionColor( const int theSectionIndex,
+ const QColor& theColor )
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, true );
+ if ( aLabel.IsNull() )
+ return;
+
+ TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, true );
+ if ( aSectLabel.IsNull() )
+ return;
+
+ Handle(TDataStd_IntegerArray) aColorArray;
+
+ if ( !aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ aColorArray = TDataStd_IntegerArray::Set( aSectLabel, 1, 4 );
+
+ aColorArray->SetValue( 1, theColor.red() );
+ aColorArray->SetValue( 2, theColor.green() );
+ aColorArray->SetValue( 3, theColor.blue() );
+ aColorArray->SetValue( 4, theColor.alpha() );
+}
+
+void HYDROData_IPolyline::removeSectionColor( const int theSectionIndex ) const
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, false );
+ if ( aLabel.IsNull() )
+ return;
+
+ if ( theSectionIndex < 0 )
+ {
+ aLabel.ForgetAllAttributes();
+ }
+ else
+ {
+ TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
+ if ( !aSectLabel.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() );
+}