# Install the export set for use with the install-tree
INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
FILE ${PROJECT_NAME}Targets.cmake)
+
+
+
+SET(_bin_scripts bin/hydro_setenv.py)
+SALOME_INSTALL_SCRIPTS("${_bin_scripts}" ${SALOME_INSTALL_SCRIPT_SCRIPTS})
+
--- /dev/null
+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+
+import os
+
+def set_env( args ):
+ os.environ["SALOME_MODULES_ORDER"] = "HYDRO,GEOM,SMESH"
+ pass
#
ADD_SUBDIRECTORY(gui)
+ADD_SUBDIRECTORY(examples)
IMPLEMENT_STANDARD_HANDLE(HYDROData_ArtificialObject,HYDROData_Object)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ArtificialObject,HYDROData_Object)
-HYDROData_ArtificialObject::HYDROData_ArtificialObject()
-: HYDROData_Object()
+HYDROData_ArtificialObject::HYDROData_ArtificialObject( Geometry theGeometry )
+: HYDROData_Object( theGeometry )
{
}
* Creates new object in the internal data structure. Use higher level objects
* to create objects with real content.
*/
- HYDRODATA_EXPORT HYDROData_ArtificialObject();
+ HYDRODATA_EXPORT HYDROData_ArtificialObject( Geometry );
/**
* Destructs properties of the object and object itself, removes it from the document.
aCoordsArray->SetValue( i * 3 + 2, aPoint.Z() );
}
- SetToUpdate( true );
+ Changed( Geom_Z );
}
HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints(bool IsConvertToGlobal) const
void HYDROData_Bathymetry::RemoveAltitudePoints()
{
- TDF_Label aLabel = myLab.FindChild(DataTag_AltitudePoints, false);
- if (!aLabel.IsNull())
- {
- aLabel.ForgetAllAttributes();
- SetToUpdate(true);
- }
+ TDF_Label aLabel = myLab.FindChild( DataTag_AltitudePoints, false );
+ if ( !aLabel.IsNull() )
+ {
+ aLabel.ForgetAllAttributes();
+ Changed( Geom_Z );
+ }
}
void interpolateAltitudeForPoints( const gp_XY& thePoint,
TDataStd_Integer::Set( myLab.FindChild( DataTag_AltitudesInverted ), (Standard_Integer)theIsInverted );
- SetToUpdate( true );
+ Changed( Geom_Z );
if ( !theIsUpdate )
return;
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
HYDROData_CalculationCase::HYDROData_CalculationCase()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d_and_groups )
{
}
AddReferenceObject( theObject, DataTag_GeometryObject );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
return true;
}
RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_CalculationCase::RemoveGeometryObjects()
ClearReferenceObjects( DataTag_GeometryObject );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup )
AddReferenceObject( theGroup, DataTag_GeometryGroup );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_Groups );
return true;
}
RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_Groups );
}
void HYDROData_CalculationCase::RemoveGeometryGroups()
ClearReferenceObjects( DataTag_GeometryGroup );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_Groups );
}
void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
SetReferenceObject( thePolyline, DataTag_Polyline );
// Indicate model of the need to update zones splitting
- SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() );
+ if( !IsEqual( aPrevPolyline, thePolyline ) )
+ Changed( Geom_2d );
}
Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const
ClearReferenceObjects( DataTag_Polyline );
// Indicate model of the need to update zones splitting
- SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
+ Changed( Geom_2d );
}
void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
// Indicate model of the need to update land covers partition
- SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() );
+ if( !IsEqual( aPrevStricklerTable, theStricklerTable ) )
+ Changed( Geom_No );
}
Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
ClearReferenceObjects( DataTag_StricklerTable );
// Indicate model of the need to update land covers partition
- SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() );
+ Changed( Geom_No );
}
bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& theLandCover )
AddReferenceObject( theLandCover, DataTag_LandCover );
// Indicate model of the need to update land covers partition
- SetToUpdate( true );
+ Changed( Geom_No );
return true;
}
RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover );
// Indicate model of the need to update land cover partition
- SetToUpdate( true );
+ Changed( Geom_No );
}
void HYDROData_CalculationCase::RemoveLandCovers()
ClearReferenceObjects( DataTag_LandCover );
// Indicate model of the need to update land cover partition
- SetToUpdate( true );
+ Changed( Geom_No );
}
Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone,
if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
{
Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF, theLandCover );
- theRegion->CopyTo( aNewRegion );
+ theRegion->CopyTo( aNewRegion, true );
aFatherCalc->RemoveRegion( theRegion, theLandCover );
// Indicate model of the need to update splitting
if ( theIsSetToUpdate ) {
- SetToUpdate( true );
+ Changed( Geom_2d );
}
}
HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
}
QString HYDROData_CalculationCase::DumpRules() const
TDataStd_Integer::Set( aModeLab, ( int ) theMode );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
}
HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
TDataStd_Integer::Set( aModeLab, ( int ) theMode );
// Indicate model of the need to update land covers partition
- SetToUpdate( true );
+ Changed( Geom_No );
}
HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const
#include "HYDROData_ShapesTool.h"
#include "HYDROData_Pipes.h"
#include "HYDROData_Stream.h"
+#include "HYDROData_Tool.h"
#include <BRepBuilderAPI_MakeWire.hxx>
HYDROData_Channel::HYDROData_Channel()
-: HYDROData_ArtificialObject()
+: HYDROData_ArtificialObject( Geom_3d )
{
}
SetReferenceObject( theGuideLine, DataTag_GuideLine );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
return true;
}
ClearReferenceObjects( DataTag_GuideLine );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
}
bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
SetReferenceObject( theProfile, DataTag_Profile );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
return true;
}
ClearReferenceObjects( DataTag_Profile );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ Changed( Geom_3d );
}
ObjectKind HYDROData_Channel::getAltitudeObjectType() const
{
DEBTRACE("HYDROData_Channel::getAltitudeObjectType");
return KIND_CHANNEL_ALTITUDE;
+ //return KIND_STREAM_ALTITUDE;
}
+TopoDS_Shape HYDROData_Channel::GetLeftShape() const
+{
+ HYDROData_SequenceOfObjects aGroups = GetGroups();
+ return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 1);
+}
+
+TopoDS_Shape HYDROData_Channel::GetRightShape() const
+{
+ HYDROData_SequenceOfObjects aGroups = GetGroups();
+ return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 2);
+}
*/
HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+ /**
+ * Returns the left edge of the channel.
+ */
+ HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const;
+
+ /**
+ * Returns the right edge of the channel.
+ */
+ HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const;
+
/**
* Update the shape presentations of stream.
* Call this method whenever you made changes for channel data.
HYDROData_Confluence::HYDROData_Confluence()
-: HYDROData_NaturalObject()
+: HYDROData_NaturalObject( Geom_3d )
{
}
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_DummyObject3D,HYDROData_Entity)
HYDROData_DummyObject3D::HYDROData_DummyObject3D()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_3d )
{
}
#define _DEVDEBUG_
#include "HYDRO_trace.hxx"
-static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
+//static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared)
void HYDROData_Entity::Update()
{
- SetToUpdate( false );
+ ClearChanged();
}
void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy )
return QVariant();
}
-void HYDROData_Entity::SetToUpdate( bool theFlag )
+void HYDROData_Entity::ClearChanged()
{
- if ( IsMustBeUpdated() == theFlag )
+ TDataStd_Integer::Set( myLab.FindChild( DataTag_GeomChange ), 0 );
+}
+
+int HYDROData_Entity::GetGeomChangeFlag() const
+{
+ int aGeomChangeFlag = 0;
+ Handle(TDataStd_Integer) aGeomChangeAttr;
+ TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange );
+ aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr );
+ if ( !aGeomChangeAttr.IsNull() )
+ aGeomChangeFlag = aGeomChangeAttr->Get();
+ return aGeomChangeFlag;
+}
+
+void HYDROData_Entity::Changed( Geometry theChangedGeometry )
+{
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if( aDocument.IsNull() )
return;
- if ( theFlag )
- {
- TDataStd_UAttribute::Set( myLab, GUID_MUST_BE_UPDATED );
+ int aGeomChangeFlag = 0;
+ Handle(TDataStd_Integer) aGeomChangeAttr;
+ TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange );
+ aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr );
+ if ( !aGeomChangeAttr.IsNull() )
+ aGeomChangeFlag = aGeomChangeAttr->Get();
+
+ int aBitsToChange = ( myGeom & theChangedGeometry );
+ if( aBitsToChange == 0 )
+ return;
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
- if ( !aDocument.IsNull() )
+ aGeomChangeFlag = ( aGeomChangeFlag | aBitsToChange );
+ TDataStd_Integer::Set( aGeomChangeLab, aGeomChangeFlag );
+
+ HYDROData_Iterator anIter( aDocument );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Entity) anObject = anIter.Current();
+ HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects();
+ for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i )
{
- // Change the states of this and all depended objects
- HYDROData_Tool::SetMustBeUpdatedObjects( aDocument );
+ Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i );
+ if( aRefObject->Label()==myLab )
+ anObject->Changed( theChangedGeometry );
}
}
- else
- {
- myLab.ForgetAttribute( GUID_MUST_BE_UPDATED );
- }
}
-bool HYDROData_Entity::IsMustBeUpdated() const
+bool HYDROData_Entity::IsMustBeUpdated( Geometry theGeom ) const
{
- return myLab.IsAttribute( GUID_MUST_BE_UPDATED );
+ return ( ( GetGeomChangeFlag() & theGeom ) != 0 );
}
bool HYDROData_Entity::CanBeUpdated() const
return true;
}
-HYDROData_Entity::HYDROData_Entity()
+HYDROData_Entity::HYDROData_Entity( Geometry theGeom )
+ : myGeom( theGeom )
{
}
{
}
-void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const
+void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
if ( aDocument.IsNull() ) {
TDF_CopyLabel aCopy(myLab, theDestination->Label());
aCopy.Perform();
- // generate a new unique name for the clone object:
- // case 1: Image_1 -> Image_2
- // case 2: ImageObj -> ImageObj_1
- QString aName = theDestination->GetName();
- QString aPrefix = aName;
- if( aName.contains( '_' ) ) { // case 1
- QString aSuffix = aName.section( '_', -1 );
- bool anIsInteger = false;
- aSuffix.toInt( &anIsInteger );
- if( anIsInteger )
- aPrefix = aName.section( '_', 0, -2 );
- } else { // case 2
- aPrefix = aName;
- }
+ if( isGenerateNewName )
+ {
+ // generate a new unique name for the clone object:
+ // case 1: Image_1 -> Image_2
+ // case 2: ImageObj -> ImageObj_1
+ QString aName = theDestination->GetName();
+ QString aPrefix = aName;
+ if( aName.contains( '_' ) ) { // case 1
+ QString aSuffix = aName.section( '_', -1 );
+ bool anIsInteger = false;
+ aSuffix.toInt( &anIsInteger );
+ if( anIsInteger )
+ aPrefix = aName.section( '_', 0, -2 );
+ } else { // case 2
+ aPrefix = aName;
+ }
- aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix );
- theDestination->SetName( aName );
+ aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix );
+ theDestination->SetName( aName );
+ }
}
Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
*/
class HYDROData_Entity : public MMgt_TShared
{
-
protected:
-
/**
* Enumeration of tags corresponding to the persistent object parameters.
*/
{
DataTag_First = 0, ///< first tag, to reserve
DataTag_ZLevel, ///< z-level of object presentation
+ DataTag_GeomChange,
+ };
+
+public:
+ enum Geometry
+ {
+ Geom_No = 1,
+ Geom_2d = 2,
+ Geom_Z = 4,
+ Geom_Groups = 8,
+
+ Geom_3d = Geom_2d | Geom_Z,
+ Geom_2d_and_groups = Geom_2d | Geom_Groups,
+ Geom_All = Geom_3d | Geom_Groups | Geom_No,
};
public:
/**
* Updates the name of this object.
*/
- HYDRODATA_EXPORT virtual void SetName( const QString& theName );
+ HYDRODATA_EXPORT void SetName( const QString& theName );
/**
* Returns the name of this object valid for Python script.
HYDRODATA_EXPORT virtual QVariant GetDataVariant();
- /**
- * Sets the "MustBeUpdated" flag: if object is depended on updated features.
- * \param theFlag is true for objects that must be updated, false for up-to-date
- */
- HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
- /**
- * Returns the "MustBeUpdated" flag: is object data must be updated or not
- * \returns false if object is up to date
- */
- HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
+ HYDRODATA_EXPORT virtual void ClearChanged();
+ HYDRODATA_EXPORT virtual void Changed( Geometry );
+
+ HYDRODATA_EXPORT bool IsMustBeUpdated( Geometry ) const;
/**
* Returns flag indicating that object is updateble or not.
* Objects must be the same type.
* \param theDestination initialized object (from any document) - target of copying
*/
- HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
+ HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const;
/**
* Returns the label of this object.
* Creates new object in the internal data structure. Use higher level objects
* to create objects with real content.
*/
- HYDRODATA_EXPORT HYDROData_Entity();
+ HYDRODATA_EXPORT HYDROData_Entity( Geometry );
/**
* Destructs properties of the object and object itself, removes it from the document.
const QColor& theColor,
const QColor& theDefaultColor,
const QString& theMethod ) const;
-
protected:
Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
const bool theIsCreate ) const;
+ int GetGeomChangeFlag() const;
+
protected:
/// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
TDF_Label myLab; ///< label of this object
+ Geometry myGeom;
};
#endif
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IAltitudeObject, HYDROData_Entity)
HYDROData_IAltitudeObject::HYDROData_IAltitudeObject()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_Z )
{
}
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
HYDROData_IPolyline::HYDROData_IPolyline()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d )
{
}
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Image, HYDROData_Entity)
HYDROData_Image::HYDROData_Image()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d )
{
}
void HYDROData_Image::Update()
{
- bool anIsToUpdate = IsMustBeUpdated();
+ bool anIsToUpdate = IsMustBeUpdated( Geom_2d );
HYDROData_Entity::Update();
UpdateTrsf();
}
- SetToUpdate( false );
+ ClearChanged();
}
bool HYDROData_Image::IsHas2dPrs() const
SaveByteArray(0, aData, anImage.byteCount());
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_Image::LoadImage( const QString& theFilePath )
TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
QString HYDROData_Image::GetFilePath() const
anArray->SetValue(8, theTrsf.m32());
anArray->SetValue(9, theTrsf.m33());
- SetToUpdate( true );
+ Changed( Geom_2d );
}
QTransform HYDROData_Image::Trsf() const
QImage anImage = Image();
if ( anImage.isNull() )
{
- SetToUpdate( false );
+ ClearChanged();
return;
}
SetGlobalPoints( ManualCartesian, aTrsfPointA, aTrsfPointB, aTrsfPointC );
- SetToUpdate( false );
+ ClearChanged();
}
void HYDROData_Image::SetLocalPoints( const QPoint& thePointA,
if ( theIsUpdate )
UpdateTrsf();
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_Image::GetLocalPoints( QPoint& thePointA,
if ( theIsUpdate )
UpdateTrsf();
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_Image::GetGlobalPoints( TransformationMode& theMode,
void HYDROData_Image::SetTrsfMode( const TransformationMode& theMode )
{
TDataStd_Integer::Set( myLab.FindChild( DataTag_TrsfMode ), (int)theMode );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const
void HYDROData_Image::SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage )
{
SetReferenceObject( theRefImage, DataTag_TrsfImage );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
Handle(HYDROData_Image) HYDROData_Image::GetTrsfReferenceImage() const
void HYDROData_Image::RemoveTrsfReferenceImage()
{
RemoveReferenceObject( DataTag_TrsfImage );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_Image::AppendReference( const Handle(HYDROData_Entity)& theReferenced )
{
AddReferenceObject( theReferenced, 0 );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
int HYDROData_Image::NbReferences() const
const int theIndex, Handle(HYDROData_Entity) theReferenced)
{
SetReferenceObject( theReferenced, 0, theIndex );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_Image::RemoveReference(const int theIndex)
{
RemoveReferenceObject( 0, theIndex );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_Image::ClearReferences()
{
ClearReferenceObjects( 0 );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_Image::SetOperatorName( const QString theOpName )
{
TCollection_AsciiString anAsciiStr( theOpName.toStdString().c_str() );
TDataStd_AsciiString::Set( myLab.FindChild( DataTag_Operator ), anAsciiStr );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
QString HYDROData_Image::OperatorName() const
void HYDROData_Image::SetArgs(const QByteArray& theArgs)
{
SaveByteArray(DataTag_Operator, theArgs.constData(), theArgs.length());
- SetToUpdate( true );
+ Changed( Geom_2d );
}
QByteArray HYDROData_Image::Args() const
} else {
myLab.ForgetAttribute(GUID_SELF_SPLITTED);
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_Image::IsSelfSplitted() const
HYDROData_ImmersibleZone::HYDROData_ImmersibleZone()
-: HYDROData_NaturalObject()
+: HYDROData_NaturalObject( Geom_2d )
{
}
void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
{
+ if( IsEqual( GetPolyline(), thePolyline ) )
+ return;
+
SetReferenceObject( thePolyline, DataTag_Polyline );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
Handle(HYDROData_PolylineXY) HYDROData_ImmersibleZone::GetPolyline() const
void HYDROData_ImmersibleZone::RemovePolyline()
{
ClearReferenceObjects( DataTag_Polyline );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LandCover, HYDROData_Entity )
HYDROData_LandCover::HYDROData_LandCover()
+: HYDROData_Entity( Geom_2d )
{
}
void HYDROData_LandCover::SetPolylines( const HYDROData_SequenceOfObjects& thePolylines )
{
SetReferenceObjects( thePolylines, DataTag_Polylines );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
HYDROData_SequenceOfObjects HYDROData_LandCover::GetPolylines() const
IMPLEMENT_STANDARD_HANDLE(HYDROData_NaturalObject,HYDROData_Object)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_NaturalObject,HYDROData_Object)
-HYDROData_NaturalObject::HYDROData_NaturalObject()
-: HYDROData_Object()
+HYDROData_NaturalObject::HYDROData_NaturalObject( Geometry theGeometry )
+: HYDROData_Object( theGeometry )
{
}
* Creates new object in the internal data structure. Use higher level objects
* to create objects with real content.
*/
- HYDRODATA_EXPORT HYDROData_NaturalObject();
+ HYDRODATA_EXPORT HYDROData_NaturalObject( Geometry );
/**
* Destructs properties of the object and object itself, removes it from the document.
IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity)
-HYDROData_Object::HYDROData_Object()
-: HYDROData_Entity()
+HYDROData_Object::HYDROData_Object( Geometry theGeometry )
+ : HYDROData_Entity( theGeometry )
{
}
void HYDROData_Object::Update()
{
- removeTopShape();
- removeShape3D();
- removeGroupObjects();
+ if( IsMustBeUpdated( Geom_2d ) )
+ {
+ removeTopShape();
+ removeGroupObjects();
+ }
+ if( IsMustBeUpdated( Geom_3d ) )
+ removeShape3D();
+
checkAndSetAltitudeObject();
HYDROData_Entity::Update();
}
return aResSeq;
}
-void HYDROData_Object::SetToUpdate( bool theFlag )
+void HYDROData_Object::Changed( Geometry theChangedGeometry )
{
- HYDROData_Entity::SetToUpdate( theFlag );
+ HYDROData_Entity::Changed( theChangedGeometry );
Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D();
if ( !anObject3D.IsNull() )
- anObject3D->SetToUpdate( theFlag );
+ anObject3D->Changed( theChangedGeometry );
}
void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
SetReferenceObject( theAltitude, DataTag_AltitudeObject );
- // Indicate model of the need to update object
- SetToUpdate( true );
+ // #636: In the case of the altitude object change the geometry of the main object is not changed,
+ // to the object should not be marked as updated
+ //SetToUpdate( true );
return true;
}
ClearReferenceObjects( DataTag_AltitudeObject );
- // Indicate model of the need to update object
- SetToUpdate( true );
+ // #636: In the case of the altitude object change the geometry of the main object is not changed,
+ // to the object should not be marked as updated
+ //SetToUpdate( true );
}
void HYDROData_Object::SetFillingColor( const QColor& theColor )
* Sets the "MustBeUpdated" flag: if object is depended on updated features.
* Reimplemented to update the state of child 3D object.
*/
- HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
+ HYDRODATA_EXPORT virtual void Changed( Geometry );
/**
* Creates new object in the internal data structure. Use higher level objects
* to create objects with real content.
*/
- HYDRODATA_EXPORT HYDROData_Object();
+ HYDRODATA_EXPORT HYDROData_Object( Geometry );
/**
* Destructs properties of the object and object itself, removes it from the document.
HYDROData_Obstacle::HYDROData_Obstacle()
-: HYDROData_ArtificialObject()
+: HYDROData_ArtificialObject( Geom_3d )
{
}
HYDROData_Polyline3D::HYDROData_Polyline3D()
-: HYDROData_Object()
+: HYDROData_Object( Geom_3d )
{
}
updateChildProfilePoints();
// Indicate model of the need to update the polyline presentation
- SetToUpdate( true );
+ Changed( Geom_2d );
return true;
}
ClearReferenceObjects( DataTag_PolylineXY );
// Indicate model of the need to update the polyline presentation
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theProfile )
RemoveAltitudeObject();
// Indicate model of the need to update the polyline presentation
- SetToUpdate( true );
+ Changed( Geom_Z );
return true;
}
ClearReferenceObjects( DataTag_ProfileUZ );
// Indicate model of the need to update the polyline presentation
- SetToUpdate( true );
+ Changed( Geom_Z );
}
bool HYDROData_Polyline3D::SetAltitudeObject(
if ( !IsEditable() )
{
// If polyline is not editable we no need to update it wire
- SetToUpdate( false );
+ ClearChanged();
return;
}
aTypesList->Append( theSectionType );
aClosuresList->Append( theIsClosed );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
-
- SetToUpdate( true );
}
HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
removePointsLists( theSectionIndex );
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_PolylineXY::RemoveSections()
{
removeSectionsLists();
removePointsLists();
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
}
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
}
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_PolylineXY::SetPoints( const int theSectionIndex,
}
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex, bool IsConvertToGlobal ) const
}
SetPoints( i, aPoints );
}
- SetToUpdate( true );
+ Changed( Geom_2d );
}
void HYDROData_PolylineXY::Transform( const QTransform& theTrsf )
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Profile, HYDROData_Object)
HYDROData_Profile::HYDROData_Profile()
-: HYDROData_Object()
+: HYDROData_Object( Geom_3d )
{
}
anArray->SetValue( 0, aLPoint.X() );
anArray->SetValue( 1, aLPoint.Y() );
- SetToUpdate( true );
+ Changed( Geom_3d );
}
bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal,
anArray->SetValue( 0, aLPoint.X() );
anArray->SetValue( 1, aLPoint.Y() );
- SetToUpdate( true );
+ Changed( Geom_3d );
}
bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal,
if ( !aLastLabel.IsNull() )
aLastLabel.ForgetAllAttributes();
- SetToUpdate( true );
+ Changed( Geom_3d );
}
Handle(HYDROData_ProfileUZ) HYDROData_Profile::GetProfileUZ( const bool theIsCreate ) const
if ( !aProfileUZ.IsNull() )
{
aProfileUZ->RemoveSections();
- SetToUpdate( true );
+ Changed( Geom_3d );
}
}
aProfileUZ->AddPoint( 0, aPoint );
}
- SetToUpdate( true );
+ Changed( Geom_3d );
}
HYDROData_ProfileUZ::PointsList HYDROData_Profile::GetParametricPoints() const
HYDROData_Region::HYDROData_Region()
- : HYDROData_Entity()
+ : HYDROData_Entity( Geom_2d )
{
}
if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab )
{
Handle(HYDROData_Zone) aNewZone = addNewZone( aDocument, "", TopoDS_Face(), QStringList() );
- theZone->CopyTo( aNewZone );
+ theZone->CopyTo( aNewZone, false );
// To prevent changing of stored shape
aNewZone->SetShape( theZone->GetShape() );
HYDROData_River::HYDROData_River()
-: HYDROData_NaturalObject()
+: HYDROData_NaturalObject( Geom_3d )
{
}
HYDROData_ShapesGroup::HYDROData_ShapesGroup()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_Groups )
{
}
HYDROData_Stream::HYDROData_Stream()
-: HYDROData_NaturalObject()
+: HYDROData_NaturalObject( Geom_3d )
{
}
return true;
}
-TopoDS_Shape getShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups,
- const int theGroupId )
-{
- TopoDS_Shape aResShape;
- if ( theGroups.Length() != 4 )
- return aResShape;
-
- Handle(HYDROData_ShapesGroup) aGroup =
- Handle(HYDROData_ShapesGroup)::DownCast( theGroups.Value( theGroupId ) );
- if ( aGroup.IsNull() )
- return aResShape;
-
- TopTools_SequenceOfShape aGroupShapes;
- aGroup->GetShapes( aGroupShapes );
-
- if ( !aGroupShapes.IsEmpty() )
- aResShape = aGroupShapes.First();
-
- return aResShape;
-}
-
TopoDS_Shape HYDROData_Stream::GetLeftShape() const
{
HYDROData_SequenceOfObjects aGroups = GetGroups();
- return getShapeFromGroup( aGroups, 1 );
+ return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 1);
}
TopoDS_Shape HYDROData_Stream::GetRightShape() const
{
HYDROData_SequenceOfObjects aGroups = GetGroups();
- return getShapeFromGroup( aGroups, 2 );
+ return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 2);
}
TopoDS_Shape HYDROData_Stream::GetInletShape() const
{
HYDROData_SequenceOfObjects aGroups = GetGroups();
- return getShapeFromGroup( aGroups, 3 );
+ return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 3);
}
TopoDS_Shape HYDROData_Stream::GetOutletShape() const
{
HYDROData_SequenceOfObjects aGroups = GetGroups();
- return getShapeFromGroup( aGroups, 4 );
+ return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 4);
}
QColor HYDROData_Stream::getDefaultFillingColor() const
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,
return isOK;
}
-void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const
+void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const
{
// Get the document
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
}
// Call base method
- HYDROData_Entity::CopyTo( theDestination );
+ HYDROData_Entity::CopyTo( theDestination, isGenerateNewName );
Handle(HYDROData_Stream) aStreamCopy =
Handle(HYDROData_Stream)::DownCast( theDestination );
/**
*
*/
- HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
+ HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const;
/**
#include "HYDROData_StreamAltitude.h"
+#include "HYDROData_Channel.h"
#include "HYDROData_Document.h"
#include "HYDROData_Profile.h"
#include "HYDROData_Stream.h"
#include <Precision.hxx>
+#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <Geom_Line.hxx>
{
}
-Standard_Real getAltitudeFromProfile( const Handle(HYDROData_Profile)& theProfile,
- const Standard_Real& theLeftDist,
- const Standard_Real& theRightDist )
+bool IsPointBetweenEdges( const gp_Pnt& aFirstPnt1, const gp_Pnt& aLastPnt1,
+ const gp_Pnt& aFirstPnt2, const gp_Pnt& aLastPnt2,
+ const gp_Pnt& thePoint) {
+ BRepBuilderAPI_MakeEdge aLeftMakeEdge( aFirstPnt1, aLastPnt1 );
+ BRepBuilderAPI_MakeEdge aBotMakeEdge( aLastPnt1, aLastPnt2 );
+ BRepBuilderAPI_MakeEdge aRightMakeEdge( aLastPnt2, aFirstPnt2 );
+ BRepBuilderAPI_MakeEdge aTopMakeEdge( aFirstPnt2, aFirstPnt1 );
+
+ BRepBuilderAPI_MakeWire aMakeWire( aLeftMakeEdge.Edge(), aBotMakeEdge.Edge(),
+ aRightMakeEdge.Edge(), aTopMakeEdge.Edge() );
+
+ BRepBuilderAPI_MakeFace aMakeFace( aMakeWire.Wire() );
+
+ TopoDS_Face aFace = aMakeFace.Face();
+#ifdef DEB_CLASS2D
+ TopoDS_Compound aCmp;
+ BRep_Builder aBB;
+ aBB.MakeCompound(aCmp);
+ aBB.Add(aCmp, aFace);
+ BRepBuilderAPI_MakeVertex aMk(thePoint);
+ aBB.Add(aCmp, aMk.Vertex());
+ BRepTools::Write(aCmp, "ProfileFace.brep");
+#endif
+
+ gp_XY anXY( thePoint.X(), thePoint.Y() );
+ TopAbs_State aPointState = HYDROData_Tool::ComputePointState(anXY, aFace);
+
+#ifdef DEB_CLASS2D
+ cout << "Point status is = " << aPointState <<endl;
+#endif
+ return aPointState != TopAbs_OUT;
+}
+
+Standard_Real getAltitudeFromWire( const TopoDS_Wire& theWire,
+ const Standard_Real& theLeftDist,
+ const Standard_Real& theRightDist )
{
Standard_Real aResAlt = 0.0;
gp_XY aFirstPoint, aLastPoint;
- if ( !theProfile->GetLeftPoint( aFirstPoint, false ) ||
- !theProfile->GetRightPoint( aLastPoint, false ) )
- return aResAlt;
-
- gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 );
- gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0 );
-
+ TopoDS_Vertex aFirstVertex, aLastVertex;
+ TopExp::Vertices( theWire, aFirstVertex, aLastVertex );
+
+ gp_Pnt aPnt1( BRep_Tool::Pnt( aFirstVertex ) );
+ aPnt1.SetZ( 0 );
+ gp_Pnt aPnt2( BRep_Tool::Pnt( aLastVertex ) );
+ aPnt2.SetZ( 0 );
+
Standard_Real aProfileDist = aPnt1.Distance( aPnt2 );
Standard_Real aCoeff = aProfileDist / ( theLeftDist + theRightDist );
gp_Pnt anIntPoint( aPnt1.XYZ() + ( aCoeff * theLeftDist ) * gp_Dir( gp_Vec( aPnt1, aPnt2 ) ).XYZ() );
- gp_Lin aPointLine( anIntPoint, gp::DZ() );
-
- gp_Pnt aPrevPoint;
- gp_Lin aPrevNormal;
- HYDROData_Profile::ProfilePoints aProfilePoints = theProfile->GetProfilePoints( false );
- for ( int i = 1, n = aProfilePoints.Length(); i <= n; ++i )
- {
- gp_Pnt aProfPoint( aProfilePoints.Value( i ) );
-
- Standard_Real aDist = aPointLine.Distance( aProfPoint );
- if ( aDist <= gp::Resolution() )
- {
- // We found the intersected point
- aResAlt = aProfPoint.Z();
- break;
- }
-
- gp_Lin aNormal = aPointLine.Normal( aProfPoint );
- if ( i == 1 )
- {
- aPrevNormal = aNormal;
- aPrevPoint = aProfPoint;
- continue;
- }
-
- if ( aPrevNormal.Direction().Dot( aNormal.Direction() ) < 0 )
- {
- // We found the intersected edge
- gp_Lin anEdgeLine( aPrevPoint, gp_Dir( gp_Vec( aPrevPoint, aProfPoint ) ) );
-
- Extrema_ExtElC anExtrema( aPointLine, anEdgeLine, Precision::Angular() );
- if ( !anExtrema.IsParallel() )
- {
- Extrema_POnCurv aFirstPnt, aSecPnt;
- anExtrema.Points( 1, aFirstPnt, aSecPnt );
-
- const gp_Pnt& anIntPnt = aSecPnt.Value();
- aResAlt = anIntPnt.Z();
-
- break;
- }
- }
-
- aPrevNormal = aNormal;
- aPrevPoint = aProfPoint;
- }
-
- return aResAlt;
+ return HYDROData_Tool::GetAltitudeForWire( theWire,
+ gp_XY(anIntPoint.X(), anIntPoint.Y()),
+ 1E-2,
+ 1E-2,
+ HYDROData_IAltitudeObject::GetInvalidAltitude() );
}
-bool HYDROData_StreamAltitude::getBoundaryProfilesForPoint(
- const gp_XY& thePoint,
- Handle(HYDROData_Profile)& theLeftProfile,
- Handle(HYDROData_Profile)& theRightProfile ) const
+bool HYDROData_StreamAltitude::getBoundaryWiresForPoint(
+ const gp_XY& thePoint,
+ TopoDS_Wire& theLeftWire,
+ TopoDS_Wire& theRightWire ) const
{
- Handle(HYDROData_Stream) aStream =
- Handle(HYDROData_Stream)::DownCast( GetFatherObject() );
- if ( aStream.IsNull() )
- return false;
+ gp_Pnt aTestPnt( thePoint.X(), thePoint.Y(), 0 );
- HYDROData_SequenceOfObjects aStreamProfiles = aStream->GetProfiles();
- if ( aStreamProfiles.Length() < 2 )
+ Handle(HYDROData_Object) anObject =
+ Handle(HYDROData_Object)::DownCast( GetFatherObject() );
+ if ( anObject.IsNull() ) {
return false;
+ }
- Handle(HYDROData_Profile) aPrevProfile;
- gp_Pnt aPrevPnt1, aPrevPnt2;
- for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i )
- {
- Handle(HYDROData_Profile) aProfile =
- Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) );
- if ( aProfile.IsNull() )
- continue;
-
- gp_XY aFirstPoint, aLastPoint;
- if ( !aProfile->GetLeftPoint( aFirstPoint, false ) ||
- !aProfile->GetRightPoint( aLastPoint, false ) )
- continue;
+ if ( anObject->GetKind() == KIND_STREAM ) {
+ Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( anObject );
+ if ( aStream.IsNull() )
+ return false;
- gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 );
- gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0 );
+ HYDROData_SequenceOfObjects aStreamProfiles = aStream->GetProfiles();
+ if ( aStreamProfiles.Length() < 2 )
+ return false;
- if ( !aPrevProfile.IsNull() )
+ Handle(HYDROData_Profile) aPrevProfile;
+ gp_Pnt aPrevPnt1, aPrevPnt2;
+ for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i )
{
- BRepBuilderAPI_MakeEdge aLeftMakeEdge( aPrevPnt1, aPrevPnt2 );
- BRepBuilderAPI_MakeEdge aBotMakeEdge( aPrevPnt2, aPnt2 );
- BRepBuilderAPI_MakeEdge aRightMakeEdge( aPnt2, aPnt1 );
- BRepBuilderAPI_MakeEdge aTopMakeEdge( aPnt1, aPrevPnt1 );
-
- BRepBuilderAPI_MakeWire aMakeWire( aLeftMakeEdge.Edge(), aBotMakeEdge.Edge(),
- aRightMakeEdge.Edge(), aTopMakeEdge.Edge() );
-
- BRepBuilderAPI_MakeFace aMakeFace( aMakeWire.Wire() );
-
- TopoDS_Face aProfilesFace = aMakeFace.Face();
-#ifdef DEB_CLASS2D
- TopoDS_Compound aCmp;
- BRep_Builder aBB;
- aBB.MakeCompound(aCmp);
- aBB.Add(aCmp, aProfilesFace);
- gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
- BRepBuilderAPI_MakeVertex aMk(aPnt);
- aBB.Add(aCmp, aMk.Vertex());
- BRepTools::Write(aCmp, "ProfileFace.brep");
-#endif
-
- TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aProfilesFace);
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) );
+ if ( aProfile.IsNull() )
+ continue;
+
+ gp_XY aFirstPoint, aLastPoint;
+ if ( !aProfile->GetLeftPoint( aFirstPoint, false ) ||
+ !aProfile->GetRightPoint( aLastPoint, false ) )
+ continue;
+
+ gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 );
+ gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0 );
+
+ if ( !aPrevProfile.IsNull() )
+ {
+ if ( IsPointBetweenEdges( aPrevPnt1, aPrevPnt2, aPnt1, aPnt2, aTestPnt ) )
+ {
+ theLeftWire = TopoDS::Wire( aPrevProfile->GetShape3D() );
+ theRightWire = TopoDS::Wire( aProfile->GetShape3D() );
+ break;
+ }
+ }
-#ifdef DEB_CLASS2D
- cout << "Point status is = " << aPointState <<endl;
-#endif
- if ( aPointState != TopAbs_OUT )
- {
- theLeftProfile = aPrevProfile;
- theRightProfile = aProfile;
- break;
+ aPrevProfile = aProfile;
+ aPrevPnt1 = aPnt1;
+ aPrevPnt2 = aPnt2;
+ }
+ } else if ( anObject->GetKind() == KIND_CHANNEL ) {
+ Handle(HYDROData_Channel) aChannel = Handle(HYDROData_Channel)::DownCast( anObject );
+ if ( aChannel.IsNull() )
+ return false;
+
+ TopTools_ListOfShape aWiresList;
+ TopExp_Explorer anExp( aChannel->GetShape3D(), TopAbs_WIRE );
+ for ( ; anExp.More(); anExp.Next() ) {
+ if(!anExp.Current().IsNull()) {
+ const TopoDS_Wire& aWire = TopoDS::Wire( anExp.Current() );
+ aWiresList.Append( aWire );
}
}
- aPrevProfile = aProfile;
- aPrevPnt1 = aPnt1;
- aPrevPnt2 = aPnt2;
+ if ( aWiresList.Extent() < 2 )
+ return false;
+
+ TopoDS_Wire aPrevWire;
+ gp_Pnt aPrevPnt1, aPrevPnt2;
+
+ TopTools_ListIteratorOfListOfShape anIt( aWiresList );
+ for ( ; anIt.More(); anIt.Next() ) {
+ TopoDS_Wire& aWire = TopoDS::Wire( anIt.Value() );
+ if ( aWire.IsNull() )
+ continue;
+
+ TopoDS_Vertex aFirstVertex, aLastVertex;
+ TopExp::Vertices( aWire, aFirstVertex, aLastVertex );
+
+ gp_Pnt aPnt1( BRep_Tool::Pnt( aFirstVertex ) );
+ aPnt1.SetZ( 0 );
+ gp_Pnt aPnt2( BRep_Tool::Pnt( aLastVertex ) );
+ aPnt2.SetZ( 0 );
+
+ if ( !aPrevWire.IsNull() ) {
+ if ( IsPointBetweenEdges( aPrevPnt1, aPrevPnt2, aPnt1, aPnt2, aTestPnt ) ) {
+ theLeftWire = aPrevWire;
+ theRightWire = aWire;
+ break;
+ }
+ }
+
+ aPrevWire = aWire;
+ aPrevPnt1 = aPnt1;
+ aPrevPnt2 = aPnt2;
+ }
}
- return !theLeftProfile.IsNull() && !theRightProfile.IsNull();
+ return !theLeftWire.IsNull() && !theRightWire.IsNull();
}
double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) const
DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << ")");
double aResAltitude = GetInvalidAltitude();
- Handle(HYDROData_Stream) aStream =
- Handle(HYDROData_Stream)::DownCast( GetFatherObject() );
- if ( aStream.IsNull() )
+ Handle(HYDROData_Object) anObject =
+ Handle(HYDROData_Object)::DownCast( GetFatherObject() );
+ if ( anObject.IsNull() )
{
- DEBTRACE("aStream.IsNull()");
+ DEBTRACE("aStream.IsNull()");
return aResAltitude;
}
-
- TopoDS_Shape aStreamShape = aStream->GetTopShape();
- if ( aStreamShape.IsNull() )
+ TopoDS_Shape aTopShape = anObject->GetTopShape();
+ if ( aTopShape.IsNull() )
{
- DEBTRACE("aStreamShape.IsNull()");
+ DEBTRACE("aTopShape.IsNull()");
return aResAltitude;
}
- TopExp_Explorer aStreamFaceExp( aStreamShape, TopAbs_FACE );
- if ( !aStreamFaceExp.More() )
+ TopExp_Explorer aFaceExp( aTopShape, TopAbs_FACE );
+ if ( !aFaceExp.More() )
{
- DEBTRACE("!aStreamFaceExp.More()");
+ DEBTRACE("!aFaceExp.More()");
return aResAltitude;
}
// Get only face because of 2d profile wires is in compound
- TopoDS_Face aStreamFace = TopoDS::Face( aStreamFaceExp.Current() );
+ TopoDS_Face aFace = TopoDS::Face( aFaceExp.Current() );
- // Check if point is inside of stream presentation
- TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aStreamFace);
+ // Check if point is inside of stream/channel presentation
+ TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aFace);
#ifdef DEB_CLASS2D
cout << "Point status is = " << aPointState <<endl;
TopoDS_Compound aCmp;
BRep_Builder aBB;
aBB.MakeCompound(aCmp);
- aBB.Add(aCmp, aStreamFace);
+ aBB.Add(aCmp, aFace);
gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
BRepBuilderAPI_MakeVertex aMk(aPnt);
aBB.Add(aCmp, aMk.Vertex());
return aResAltitude;
}
+ TopoDS_Edge aLeftEdge, aRightEdge;
+
+ if ( anObject->GetKind() == KIND_STREAM ) {
+ Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream)::DownCast( GetFatherObject() );
+ if ( !aStream.IsNull() ) {
+ aLeftEdge = TopoDS::Edge( aStream->GetLeftShape() );
+ aRightEdge = TopoDS::Edge( aStream->GetRightShape() );
+ }
+ } else if ( anObject->GetKind() == KIND_CHANNEL ) {
+ Handle(HYDROData_Channel) aChannel =
+ Handle(HYDROData_Channel)::DownCast( GetFatherObject() );
+ if ( !aChannel.IsNull() ) {
+ aLeftEdge = TopoDS::Edge( aChannel->GetLeftShape() );
+ aRightEdge = TopoDS::Edge( aChannel->GetRightShape() );
+ }
+ }
+
// Find the two profiles between which the point is lies
- Handle(HYDROData_Profile) aLeftProfile, aRightProfile;
- if ( !getBoundaryProfilesForPoint( thePoint, aLeftProfile, aRightProfile ) )
+ TopoDS_Wire aLeftWire, aRightWire;
+ if ( !getBoundaryWiresForPoint( thePoint, aLeftWire, aRightWire ) )
{
- DEBTRACE("!getBoundaryProfilesForPoint( thePoint, aLeftProfile, aRightProfile )");
- return aResAltitude;
+ DEBTRACE("!getBoundaryProfilesForPoint( thePoint, aLeftProfile, aRightProfile )");
+ return aResAltitude;
}
// Find the projections of point to borders of stream
gp_XYZ aPointToTest( thePoint.X(), thePoint.Y(), 0.0 );
-
- TopoDS_Edge aStreamLeftEdge = TopoDS::Edge( aStream->GetLeftShape() );
- TopoDS_Edge aStreamRightEdge = TopoDS::Edge( aStream->GetRightShape() );
-
+
Standard_Real aFirst = 0.0, aLast = 0.0;
- Handle(Geom_Curve) anEdgeLeftCurve = BRep_Tool::Curve( aStreamLeftEdge, aFirst, aLast );
- Handle(Geom_Curve) anEdgeRightCurve = BRep_Tool::Curve( aStreamRightEdge, aFirst, aLast );
+ Handle(Geom_Curve) anEdgeLeftCurve = BRep_Tool::Curve( aLeftEdge, aFirst, aLast );
+ Handle(Geom_Curve) anEdgeRightCurve = BRep_Tool::Curve( aRightEdge, aFirst, aLast );
GeomAPI_ProjectPointOnCurve aLeftProject( aPointToTest, anEdgeLeftCurve );
GeomAPI_ProjectPointOnCurve aRightProject( aPointToTest, anEdgeRightCurve );
+ int aNbPoints1 = aRightProject.NbPoints();
+ int aNbPoints2 = aLeftProject.NbPoints();
+ if ( aNbPoints1 < 1 || aNbPoints2 < 1)
+ return aResAltitude;
Standard_Real aLeftDist = aLeftProject.LowerDistance();
Standard_Real aRightDist = aRightProject.LowerDistance();
// Find the altitude in profiles
- Standard_Real aLeftAlt = getAltitudeFromProfile( aLeftProfile, aLeftDist, aRightDist );
- Standard_Real aRightAlt = getAltitudeFromProfile( aRightProfile, aLeftDist, aRightDist );
+ Standard_Real aLeftAlt, aRightAlt;
+ gp_Pnt aLeftProfileP1, aLeftProfileP2, aRightProfileP1, aRightProfileP2;
+ aLeftAlt = getAltitudeFromWire( aLeftWire, aLeftDist, aRightDist );
+ aRightAlt = getAltitudeFromWire( aRightWire, aLeftDist, aRightDist );
+
+ TopoDS_Vertex aFirstVertex, aLastVertex;
+ TopExp::Vertices( aLeftWire, aFirstVertex, aLastVertex );
+ aLeftProfileP1 = BRep_Tool::Pnt( aFirstVertex );
+ aLeftProfileP2 = BRep_Tool::Pnt( aLastVertex );
+
+ TopExp::Vertices( aRightWire, aFirstVertex, aLastVertex );
+ aRightProfileP1 = BRep_Tool::Pnt( aFirstVertex );
+ aRightProfileP2 = BRep_Tool::Pnt( aLastVertex );
// Interpolate altitudes
// Left profile line ( the segment between the firts and the last profile point )
- HYDROData_Profile::ProfilePoints aLeftProfilePoints = aLeftProfile->GetProfilePoints( false );
- gp_Pnt aLeftProfileP1( aLeftProfilePoints.First() );
aLeftProfileP1.SetZ( 0 );
- gp_Pnt aLeftProfileP2( aLeftProfilePoints.Last() );
aLeftProfileP2.SetZ( 0 );
gp_Vec aLeftProfileVec( aLeftProfileP1, aLeftProfileP2 );
Handle(Geom_Line) aLeftProfileLine = new Geom_Line( gp_Ax1( aLeftProfileP1, aLeftProfileVec ) );
// Right profile line
- HYDROData_Profile::ProfilePoints aRightProfilePoints = aRightProfile->GetProfilePoints( false );
- gp_Pnt aRightProfileP1( aRightProfilePoints.First() );
aRightProfileP1.SetZ( 0 );
- gp_Pnt aRightProfileP2( aRightProfilePoints.Last() );
aRightProfileP2.SetZ( 0 );
gp_Vec aRightProfileVec( aRightProfileP1, aRightProfileP2 );
Handle(Geom_Line) aRightProfileLine = new Geom_Line( gp_Ax1( aRightProfileP1, aRightProfileVec ) );
#include "HYDROData_IAltitudeObject.h"
-class Handle(HYDROData_Profile);
DEFINE_STANDARD_HANDLE(HYDROData_StreamAltitude, HYDROData_IAltitudeObject)
+class TopoDS_Wire;
/**\class HYDROData_StreamAltitude
* \brief Class that stores/retreives information about the stream altitude.
protected:
- bool getBoundaryProfilesForPoint( const gp_XY& thePoint,
- Handle(HYDROData_Profile)& theLeftProfile,
- Handle(HYDROData_Profile)& theRightProfile ) const;
+ bool getBoundaryWiresForPoint( const gp_XY& thePoint,
+ TopoDS_Wire& theLeftWire,
+ TopoDS_Wire& theRightWire ) const;
protected:
IMPLEMENT_STANDARD_HANDLE( HYDROData_StricklerTable, HYDROData_Entity )
IMPLEMENT_STANDARD_RTTIEXT( HYDROData_StricklerTable, HYDROData_Entity )
- HYDROData_StricklerTable::HYDROData_StricklerTable()
+HYDROData_StricklerTable::HYDROData_StricklerTable()
+: HYDROData_Entity( Geom_No )
{
}
#include "HYDROData_Image.h"
#include "HYDROData_Iterator.h"
#include "HYDROData_NaturalObject.h"
+#include "HYDROData_ShapesGroup.h"
#include <QFile>
#include <QStringList>
#include <BRepAdaptor_Surface.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <BRep_Tool.hxx>
+#include <Geom_Curve.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopExp_Explorer.hxx>
static int aMaxNameId = std::numeric_limits<int>::max();
anOutStream << aWriteStr << theSep << theSep;
}
-void HYDROData_Tool::SetMustBeUpdatedObjects(
- const Handle(HYDROData_Document)& theDoc )
-{
- bool anIsChanged = true;
-
- // iterate until there is no changes because objects on all level of dependency must be updated
- while ( anIsChanged )
- {
- anIsChanged = false;
-
- HYDROData_Iterator anIter( theDoc );
- for ( ; anIter.More(); anIter.Next() )
- {
- Handle(HYDROData_Entity) anObject = anIter.Current();
- if ( anObject.IsNull() || anObject->IsMustBeUpdated() )
- continue;
-
- HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects();
- for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i )
- {
- Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i );
- if ( aRefObject.IsNull() || !aRefObject->IsMustBeUpdated() )
- continue;
-
- anObject->SetToUpdate( true );
- anIsChanged = true;
- break;
- }
- }
- }
-}
-
QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
const QString& thePrefix,
const QStringList& theUsedNames,
BRepTopAdaptor_FClass2d aClassifier( theFace, toluv );
aState = aClassifier.Perform( gp_Pnt2d(aU1, aV1), Standard_False );
return aState;
+}
+
+double HYDROData_Tool::GetAltitudeForEdge( const TopoDS_Edge& theEdge,
+ const gp_XY& thePoint,
+ double theParameterTolerance,
+ double theSquareDistanceTolerance,
+ double theInvalidAltitude )
+{
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve( theEdge, aFirst, aLast );
+ if( aCurve.IsNull() )
+ return theInvalidAltitude;
+
+ gp_Pnt aFirstPnt, aLastPnt;
+
+ aCurve->D0( aFirst, aFirstPnt );
+ aCurve->D0( aLast, aLastPnt );
+
+ gp_Pnt2d aFirstPnt2d( aFirstPnt.X(), aFirstPnt.Y() );
+ gp_Pnt2d aLastPnt2d( aLastPnt.X(), aLastPnt.Y() );
+
+ double aFirstDist = 0;
+ double aLastDist = aFirstPnt2d.SquareDistance( aLastPnt2d );
+ double aNecDist = aFirstPnt2d.SquareDistance( thePoint );
+
+ while( fabs( aLast - aFirst ) > theParameterTolerance )
+ {
+ double aMid = ( aFirst + aLast ) / 2;
+ gp_Pnt aMidPnt;
+ aCurve->D0( aMid, aMidPnt );
+ double aDist = aFirstPnt2d.SquareDistance( gp_Pnt2d( aMidPnt.X(), aMidPnt.Y() ) );
+
+ if( aDist < aNecDist )
+ aFirst = aMid;
+ else
+ aLast = aMid;
+ }
+
+ double aMid = ( aFirst + aLast ) / 2;
+ gp_Pnt aMidPnt;
+ aCurve->D0( aMid, aMidPnt );
+
+ gp_Pnt2d aMidPnt2d( aMidPnt.X(), aMidPnt.Y() );
+ if( aMidPnt2d.SquareDistance( thePoint ) < theSquareDistanceTolerance )
+ return aMidPnt.Z();
+ else
+ return theInvalidAltitude;
+}
+
+double HYDROData_Tool::GetAltitudeForWire( const TopoDS_Wire& theWire,
+ const gp_XY& thePoint,
+ double theParameterTolerance,
+ double theSquareDistanceTolerance,
+ double theInvalidAltitude )
+{
+ TopExp_Explorer anExp( theWire, TopAbs_EDGE );
+ for( ; anExp.More(); anExp.Next() )
+ {
+ double anAltitude = GetAltitudeForEdge( TopoDS::Edge( anExp.Current() ), thePoint,
+ theParameterTolerance, theSquareDistanceTolerance, theInvalidAltitude );
+ if( anAltitude != theInvalidAltitude )
+ return anAltitude;
+ }
+ return theInvalidAltitude;
+}
+
+TopoDS_Shape HYDROData_Tool::getFirstShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups,
+ const int theGroupId )
+{
+ TopoDS_Shape aResShape;
+ if ( theGroupId < 1 || theGroupId > theGroups.Length() )
+ return aResShape;
+
+ Handle(HYDROData_ShapesGroup) aGroup =
+ Handle(HYDROData_ShapesGroup)::DownCast( theGroups.Value( theGroupId ) );
+ if ( aGroup.IsNull() )
+ return aResShape;
+
+ TopTools_SequenceOfShape aGroupShapes;
+ aGroup->GetShapes( aGroupShapes );
+
+ if ( !aGroupShapes.IsEmpty() )
+ aResShape = aGroupShapes.First();
+
+ return aResShape;
}
\ No newline at end of file
class TopoDS_Shape;
class TopTools_SequenceOfShape;
class Handle(HYDROData_Document);
+class TopoDS_Edge;
+class TopoDS_Wire;
class HYDRODATA_EXPORT HYDROData_Tool {
const QStringList& theStrings,
const QString& theSep = "\n" );
- /**
- * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
- * \param theDoc document where this operation is performed
- */
- static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
-
/**
* \brief Generate name for new object.
* \param theDoc document
static TopAbs_State ComputePointState( const gp_XY& thePnt2d,
const TopoDS_Face& theFace );
+
+ static double GetAltitudeForEdge( const TopoDS_Edge& theEdge,
+ const gp_XY& thePoint,
+ double theParameterTolerance,
+ double theSquareDistanceTolerance,
+ double theInvalidAltitude );
+ static double GetAltitudeForWire( const TopoDS_Wire& theWire,
+ const gp_XY& thePoint,
+ double theParameterTolerance,
+ double theSquareDistanceTolerance,
+ double theInvalidAltitude );
+
+ /**
+ * \brief Returns the first shape from the group.
+ * \param theGroups the list of groups
+ * \param theGroupId the group id
+ */
+ static TopoDS_Shape getFirstShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups,
+ const int theGroupId );
};
inline bool ValuesEquals( const double& theFirst, const double& theSecond )
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_VisualState, HYDROData_Entity)
HYDROData_VisualState::HYDROData_VisualState()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_No )
{
}
HYDROData_Zone::HYDROData_Zone()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d )
{
myInterpolator = NULL;
}
Handle(HYDROData_Bathymetry) aBathymetry2 =
Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
- aBathymetry1->CopyTo( aBathymetry2 );
+ aBathymetry1->CopyTo( aBathymetry2, true );
if ( anIsFileCreated )
{
Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
- anObj->CopyTo(aCopy);
+ anObj->CopyTo(aCopy, true);
// check the copied object has same name as original
CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
// copy image to the new one
Handle(HYDROData_Image) anImage3 =
Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE));
- anImage1->CopyTo(anImage3);
+ anImage1->CopyTo(anImage3, true);
// check all fields are correctly copied
CPPUNIT_ASSERT(anImage1->Image() == anImage3->Image());
Handle(HYDROData_PolylineXY) aPolyline2 =
Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY));
- aPolyline1->CopyTo(aPolyline2);
+ aPolyline1->CopyTo(aPolyline2, true);
aDoc->Close();
bool HYDROGUI_CalculationOp::confirmRegionsChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
bool HYDROGUI_CalculationOp::confirmOrderChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
bool HYDROGUI_CalculationOp::confirmRuleChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
bool HYDROGUI_CalculationOp::confirmModeChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with land cover zones
bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with land cover zones
bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with land cover zones
bool HYDROGUI_CalculationOp::confirmLandCoverRuleChange() const
{
// Check if the case is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with land cover zones
}
}
aPanel->setStricklerTableNames( aList, anEntryList );
- bool anUpdateState = myEditedObject->IsMustBeUpdated();
+ //@ASL: bool anUpdateState = myEditedObject->IsMustBeUpdated();
if ( !aList.isEmpty() )
aPanel->setStricklerTable( aList.at( 0 ), false );
- myEditedObject->SetToUpdate( anUpdateState );
+ //@ASL: myEditedObject->SetToUpdate( anUpdateState );
// Fill in list widget with all available land covers
aSeq = HYDROGUI_Tool::GetLandCovers( module() );
if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
{
// Set objects in the specified order
- if( myEditedObject->IsMustBeUpdated() )
+ if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
{
myEditedObject->RemoveGeometryObjects();
foreach ( const QString& aName, aPanel->getAllGeomObjects() )
if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
{
// Set objects in the specified order
- if( myEditedObject->IsMustBeUpdated() )
+ if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
{
myEditedObject->RemoveLandCovers();
foreach ( const QString& aName, aPanel->getAllLandCovers() )
}
aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
- if ( myEditedObject->IsMustBeUpdated() )
+ if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
{
myShowZones = true;
myEditedObject->Update();
aGroupsNames.append( aGroup->GetName() );
}
}
- if( myEditedObject->IsMustBeUpdated() ) {
+ if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) {
for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
Handle(HYDROData_ShapesGroup) aGeomGroup =
Handle(HYDROData_ShapesGroup)::DownCast( aSeq.Value( anIndex ) );
aPanel->setAvailableGroups( aGroupsNames );
aPanel->includeGroups( aList );
- bool isUpdated = myEditedObject->IsMustBeUpdated();
+ //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated();
}
void HYDROGUI_CalculationOp::onAddGroups()
isConfirmed = confirmOrderChange();
if( isConfirmed )
- myEditedObject->SetToUpdate( true );
+ myEditedObject->Changed( HYDROData_Entity::Geom_2d );
}
void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed )
isConfirmed = confirmLandCoverOrderChange();
if( isConfirmed )
- myEditedObject->SetToUpdate( true );
+ myEditedObject->Changed( HYDROData_Entity::Geom_No );
}
void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
isConfirmed = confirmRuleChange();
if( isConfirmed )
- myEditedObject->SetToUpdate( true );
+ myEditedObject->Changed( HYDROData_Entity::Geom_2d );
}
void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed )
isConfirmed = confirmLandCoverRuleChange();
if( isConfirmed )
- myEditedObject->SetToUpdate( true );
+ myEditedObject->Changed( HYDROData_Entity::Geom_No );
}
void HYDROGUI_CalculationOp::onRegenerateColors()
myEditedObject->SetProfile( aProfile );
}
- if ( myEditedObject->IsMustBeUpdated() )
+ if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
myEditedObject->Update();
erasePreview();
Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind );
if( !aClone.IsNull() )
{
- anObject->CopyTo( aClone );
+ anObject->CopyTo( aClone, true );
anIsChanged = true;
// remove Z layer
if( theId == NameId )
{
Handle(HYDROData_Entity) aDataObject = modelObject();
- if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() )
+ if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
{
aFont.setItalic( true );
aFont.setBold( true );
if ( !aColor.isValid() )
{
Handle(HYDROData_Entity) aDataObject = modelObject();
- if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() )
+ if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
{
switch ( theRole )
{
}
else
{
- QString aNeedUpdate( aDataObject->IsMustBeUpdated() ? "M_" : "" );
+ QString aNeedUpdate( aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ? "M_" : "" );
int anObjectKind = (int)aDataObject->GetKind();
if ( anObjectKind == KIND_DUMMY_3D )
return true;
// Check if the land cover object is already modified or not
- bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
if ( !isConfirmed )
{
// If not modified check if the land cover has already defined polylines
anIsVisibleInSelection |= aVisibility;
anIsHiddenInSelection |= !aVisibility;
- if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
+ if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
{
anIsMustObjectBeUpdated = true;
}
#include <TopoDS_Vertex.hxx>
#include <BRepBndLib.hxx>
#include <Precision.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <Prs3d_LineAspect.hxx>
IMPLEMENT_STANDARD_HANDLE (HYDROGUI_Polyline, AIS_Shape)
IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape)
{
}
+Handle( Graphic3d_ArrayOfPolylines ) BuildEdgePresentation( const TopoDS_Edge& theEdge, double theDeviation )
+{
+ BRepAdaptor_Curve aCurveAdaptor( theEdge );
+ GCPnts_QuasiUniformDeflection aPnts( aCurveAdaptor, theDeviation );
+
+ Handle( Graphic3d_ArrayOfPolylines ) anArray;
+ if( !aPnts.IsDone() )
+ return anArray;
+
+ int n = aPnts.NbPoints();
+ anArray = new Graphic3d_ArrayOfPolylines( n );
+ for( int i=1; i<=n; i++ )
+ anArray->AddVertex( aPnts.Value( i ) );
+
+ return anArray;
+}
+
void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPrs,
const Standard_Integer aMode)
{
- AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+ //AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+
+ aPrs->Clear();
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs );
+ Handle(Graphic3d_AspectLine3d) anAspect = Attributes()->FaceBoundaryAspect()->Aspect();
+ aGroup->SetGroupPrimitivesAspect( anAspect );
+
+ TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE );
+ for ( ; Exp1.More(); Exp1.Next() )
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() );
+ Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, 0.1 );
+ if( !anArray.IsNull() )
+ aGroup->AddPrimitiveArray ( anArray );
+ }
+
TopExp_Explorer Exp ( myshape, TopAbs_EDGE );
for ( ; Exp.More(); Exp.Next() ) {
}
// At first we update the child u,z profile object
- aProfileUZ->SetToUpdate( true );
+ aProfileUZ->Changed( HYDROData_Entity::Geom_2d );
aProfileUZ->Update();
// And now we update our edited object
myEditedObject->SetHydraulicAxis( aHydAxis );
myEditedObject->SetProfiles( aRefProfiles, false );
- if ( myEditedObject->IsMustBeUpdated() )
+ if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
myEditedObject->Update();
if ( !myIsEdit )
updateObject( anObject, theMapOfTreated );
}
- if ( !myIsForced && !theObject->IsMustBeUpdated() )
+ if ( !myIsForced && !theObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
return;
theObject->Update();
myViewManager->setViewModel( aViewer );// custom view model, which extends SALOME_View interface
- aViewer->enableMultiselection( false );
+ //aViewer->enableMultiselection( false );
SUIT_ViewWindow* aViewWin = myViewManager->createViewWindow();
aViewer->setStaticTrihedronDisplayed( false );
%End
public:
+ enum Geometry
+ {
+ Geom_No = 1,
+ Geom_2d = 2,
+ Geom_Z = 4,
+ Geom_Groups = 8,
+
+ Geom_3d = 6,
+ Geom_2d_and_groups = 10,
+ };
/**
* Returns the kind of this object. Must be redefined in all objects of known type.
*/
virtual QVariant GetDataVariant();
-
- /**
- * Sets the "MustBeUpdated" flag: if object is depended on updated features.
- * \param theFlag is true for objects that must be updated, false for up-to-date
- */
- virtual void SetToUpdate( bool theFlag );
-
- /**
- * Returns the "MustBeUpdated" flag: is object data must be updated or not
- * \returns false if object is up to date
- */
- virtual bool IsMustBeUpdated() const;
-
/**
* Returns flag indicating that object is updateble or not.
*/
*/
virtual void Remove();
-
- /**
- * Copies all properties of this to the destinated object.
- * Objects must be the same type.
- * \param theDestination initialized object (from any document) - target of copying
- */
- void CopyTo( HYDROData_Entity theDestination ) const [void ( const Handle_HYDROData_Entity& )];
- %MethodCode
- Handle(HYDROData_Entity) aCopyTo = createHandle( a0 );
- if ( !aCopyTo.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Entity::CopyTo( aCopyTo ):
- sipCpp->CopyTo( aCopyTo );
- Py_END_ALLOW_THREADS
- }
- %End
-
/**
* Returns father object. For object created under root document label
* this method always return NULL object.
* Creates new object in the internal data structure. Use higher level objects
* to create objects with real content.
*/
- HYDROData_Entity();
+ HYDROData_Entity( Geometry );
/**
* Destructs properties of the object and object itself, removes it from the document.