#include <TColStd_Array1OfReal.hxx>
#include <TColStd_ListOfReal.hxx>
#include <TColStd_ListIteratorOfListOfReal.hxx>
-#include <TCollection_CompareOfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TopTools_HArray1OfShape.hxx>
-#include <SortTools_QuickSortOfReal.hxx>
-
#include <QColor>
#include <QStringList>
+#include <QVector>
//#define DEB_STREAM 1
#ifdef DEB_STREAM
typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Stream,HYDROData_NaturalObject)
HYDROData_Stream::HYDROData_Stream()
-: HYDROData_NaturalObject()
+: HYDROData_NaturalObject( Geom_3d )
{
}
{
}
-QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Stream::DumpToPython( const QString& thePyScriptPath,
+ MapOfTreatedObjects& theTreatedObjects ) const
{
QStringList aResList = dumpObjectCreation( theTreatedObjects );
QString aName = GetObjPyName();
Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
- setPythonReferenceObject( theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
+ setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
for ( int i = 1, aNb = aSeqOfProfiles.Size(); i <= aNb; ++i )
{
const Handle(HYDROData_Entity) aProfile = aSeqOfProfiles.Value( i );
- setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" );
+ setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aProfile, "AddProfile" );
}
// Set bottom polyline if exists
const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline();
if ( !aBottomPolyline.IsNull() ) {
- setPythonReferenceObject( theTreatedObjects, aResList, aBottomPolyline, "SetBottomPolyline" );
+ setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBottomPolyline, "SetBottomPolyline" );
}
aResList << QString( "" );
- aResList << QString( "%1.Update();" ).arg( aName );
+ aResList << QString( "%1.Update()" ).arg( aName );
aResList << QString( "" );
return aResList;
anOutGroup->AddShape( aResultPrs.myOutlet );
}
-QColor HYDROData_Stream::DefaultFillingColor()
+QColor HYDROData_Stream::DefaultFillingColor() const
{
return QColor( Qt::green );
}
-QColor HYDROData_Stream::DefaultBorderColor()
+QColor HYDROData_Stream::DefaultBorderColor() const
{
return QColor( Qt::transparent );
}
return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 4);
}
-QColor HYDROData_Stream::getDefaultFillingColor() const
-{
- return DefaultFillingColor();
-}
-
-QColor HYDROData_Stream::getDefaultBorderColor() const
-{
- return DefaultBorderColor();
-}
-
bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
{
if ( !IsValidAsAxis( theAxis ) )
updateProfilesOrder();
// Indicate model of the need to update the stream presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
return true;
}
RemoveProfiles();
// Indicate model of the need to update the stream presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
}
bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile,
insertProfileInToOrder( theProfile, aProfileIndex );
// Indicate model of the need to update the stream presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
return true;
}
SetReferenceObjects( theProfiles, DataTag_Profile );
if ( anIsToUpdate )
- SetToUpdate( true );
+ Changed( Geom_3d );
}
return true;
removeParameter( aProfileIndex );
// Indicate model of the need to update the stream presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
return true;
}
void HYDROData_Stream::RemoveProfiles()
{
- bool anIsToUpdate = IsMustBeUpdated() || NbReferenceObjects( DataTag_Profile ) > 0;
-
ClearReferenceObjects( DataTag_Profile );
// Remove the parameters array
removeParametersArray();
// Indicate model of the need to update the stream presentation
- SetToUpdate( anIsToUpdate );
+ Changed( Geom_3d );
}
void HYDROData_Stream::insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
if ( aList.IsEmpty() )
return;
- TColStd_Array1OfReal anArr( 1, aList.Extent() );
+ QVector<double> anArr( aList.Extent() );
TColStd_ListIteratorOfListOfReal it( aList );
for ( int j = 1; it.More(); it.Next(), j++ )
- anArr( j ) = it.Value();
+ anArr[j-1] = it.Value();
// sorting
if ( aList.Extent() > 1 )
{
- TCollection_CompareOfReal Compar;
- SortTools_QuickSortOfReal::Sort( anArr, Compar );
+ //TCollection_CompareOfReal Compar;
+ //SortTools_QuickSortOfReal::Sort( anArr, Compar );
+ std::sort( anArr.begin(), anArr.end() );
- for (int j = 1; j <= anArr.Length(); j++) {
- const Standard_Real aKey = anArr(j);
+ for (int j = 1; j <= anArr.size(); j++) {
+ const Standard_Real aKey = anArr[j-1];
const Handle(HYDROData_Profile)& aProfile = aDM.Find(aKey);
insertProfileInToOrder( aProfile );
}
return KIND_STREAM_ALTITUDE;
}
-void HYDROData_Stream::setParametersArray( const TColStd_Array1OfReal& theArray )
+void HYDROData_Stream::setParametersArray( const QVector<double>& theArray )
{
- if ( theArray.Length() == 0 )
+ if ( theArray.size() == 0 )
{
removeParametersArray();
return;
TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray );
+ int n = theArray.size();
Handle(TDataStd_RealArray) aParamsArray =
- TDataStd_RealArray::Set( aLabel, theArray.Lower(), theArray.Upper() );
-
- for ( int i = theArray.Lower(), n = theArray.Upper(); i <= n; ++i )
+ TDataStd_RealArray::Set( aLabel, 1, n );
+ for ( int i = 0; i < n; ++i )
{
- const Standard_Real& aParam = theArray( i );
- aParamsArray->SetValue( i, aParam );
+ const Standard_Real& aParam = theArray[i];
+ aParamsArray->SetValue( i+1, aParam );
}
}
{
aResIndex = 0;
- TColStd_Array1OfReal aNewArr( anArr->Lower(), anArr->Upper() + 1 );
+ QVector<double> aNewArr( anArr->Upper() );
bool isInserted = false;
for ( int i = anArr->Lower(), j = i, n = anArr->Upper(); i <= n; ++i, ++j )
}
else
{
- aNewArr( j ) = theParam;
+ aNewArr[j-1] = theParam;
isInserted = true;
++j;
}
}
- aNewArr( j ) = aStoredParam;
+ aNewArr[j-1] = aStoredParam;
}
if ( !isInserted )
{
aResIndex = -1;
- aNewArr( aNewArr.Upper() ) = theParam;
+ aNewArr[aNewArr.size()-1] = theParam;
}
setParametersArray( aNewArr );
}
else
{
- TColStd_Array1OfReal aNewArr( 1, 1 );
- aNewArr.SetValue( 1, theParam );
+ QVector<double> aNewArr( 1 );
+ aNewArr[0] = theParam;
setParametersArray( aNewArr );
}
return;
}
- TColStd_Array1OfReal aNewArr( aParamsArray->Lower(), aParamsArray->Upper() - 1 );
+ QVector<double> aNewArr( aParamsArray->Upper() - 2 );
for ( int i = aParamsArray->Lower(), j = i, k = 0, n = aParamsArray->Upper(); i <= n; ++i, ++k )
{
if ( k == theIndex )
continue;
- aNewArr.SetValue( j, aStoredParam );
+ aNewArr[j-1] = aStoredParam;
++j;
}
#endif
return true;
-}
\ No newline at end of file
+}