#include "HYDROData_ShapesTool.h"
#include "HYDROData_Stream.h"
#include "HYDROData_Tool.h"
+#include "HYDROData_ChannelAltitude.h"
#include <BRepBuilderAPI_MakeWire.hxx>
bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
const Handle(HYDROData_Profile)& theProfile,
PrsDefinition& thePrs,
- double theEquiDistance )
+ double theEquiDistance,
+ bool ReverseXCoord)
{
// Check input parameters
if ( theGuideLine.IsNull() || theProfile.IsNull() ) {
}
TopoDS_Wire aPathWire = TopoDS::Wire( theGuideLine->GetShape3D() );
- TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetShape3D() );
+ TopoDS_Wire aProfileWire;
+ if (!ReverseXCoord)
+ aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, false) ); //temp force rebuild
+ else
+ aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, true));
if ( aPathWire.IsNull() || aProfileWire.IsNull() ) {
return false;
}
PrsDefinition aResultPrs;
double anEquiDistance = GetEquiDistance();
- if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance ) )
+
+ bool invDirection = false;
+ Handle(HYDROData_IAltitudeObject) anObjAltitude = GetAltitudeObject();
+ Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude);
+ if (!aChannelAlt.IsNull())
+ invDirection = aChannelAlt->GetInvertDirection();
+
+ if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) )
return;
SetShape3D( aResultPrs.myPrs3D );
HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
const Handle(HYDROData_Profile)& theProfile,
PrsDefinition& thePrs,
- double theEquiDistance );
+ double theEquiDistance,
+ bool ReverseXCoord = false);
public:
#include "HYDROData_PolylineXY.h"
#include "HYDROData_ProfileUZ.h"
#include "HYDROData_Profile.h"
+#include <TDataStd_Integer.hxx>
#define _DEVDEBUG_
#include "HYDRO_trace.hxx"
distance *= aSign;
DEBTRACE("distance to guideline " << distance);
-
+
+ if (GetInvertDirection())
+ distance*=-1;
+
// get delta altitude on section (supposed symmetric) from guideline distance (aParam)
double delta = 0;
int i1 = 0;
}
if ((i1 == 0) && (i2 == 0))
{
- DEBTRACE("Projection aborted: non centered profile");
+ DEBTRACE("Projection aborted : non centered profile");
return aResAltitude;
}
else if (i1 == 0) // distance < - profile width
}
+void HYDROData_ChannelAltitude::SetInvertDirection(bool IsInverted)
+{
+ if ( GetInvertDirection() == IsInverted )
+ return;
+
+ TDataStd_Integer::Set( myLab.FindChild( DataTag_InvertDirection ), (Standard_Integer)IsInverted );
+}
+
+bool HYDROData_ChannelAltitude::GetInvertDirection() const
+{
+ bool aRes = false;
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_InvertDirection, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) anIntVal;
+ if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) )
+ aRes = (bool)anIntVal->Get();
+ }
+
+ return aRes;
+}
enum DataTag
{
DataTag_First = HYDROData_IAltitudeObject::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_InvertDirection, ///< flag for inversion of direction
};
public:
HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
int theMethod =0) const;
+ HYDRODATA_EXPORT void SetInvertDirection(bool IsInverted);
+
+ HYDRODATA_EXPORT bool GetInvertDirection() const;
+
protected:
friend class HYDROData_Iterator;
return aWire;
}
-TopoDS_Shape HYDROData_Profile::GetShape3D() const
+TopoDS_Shape HYDROData_Profile::GetShape3D(bool forceRebuild, bool reverseXCoord) const
{
+ if (forceRebuild)
+ return CreateProfileWire( true, reverseXCoord );
TopoDS_Shape aShape = HYDROData_Object::GetShape3D();
if( aShape.IsNull() )
- aShape = CreateProfileWire( true );
+ aShape = CreateProfileWire( true, reverseXCoord );
return aShape;
}
-TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) const
+TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints, bool reverseXCoord ) const
{
TopoDS_Wire aWire;
Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false );
{
ProfilePoints aProfilePoints = GetProfilePoints( false, canUseDefaultPoints );
HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 );
-
+ if (reverseXCoord)
+ {
+ for ( int i = 1; i <= aProfilePoints.Size() ; i++ )
+ {
+ gp_XYZ& aPoint = aProfilePoints.ChangeValue(i);
+ aPoint.ChangeCoord(1) = -aPoint.X();
+ }
+ }
aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints );
}
return aWire;
/**
* Returns the 3d shape of the object.
*/
- HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D(bool forceRebuild = false, bool reverseXCoord = false) const;
/**
* Updates profile 3D presentation.
*/
HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
- TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints ) const;
+ TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints, bool reverseXCoord = false) const;
static void ProjectProfilePoints( ProfilePoints& thePoints );
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
+#include <QCheckBox>
#include <QtxDoubleSpinBox.h>
HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
myEquiDistance->setValue( 1.0 );
myEquiDistance->setSingleStep( 1.0 );
+ myInvertDirection = new QCheckBox(aParamGroup);
+ myInvertDirection->setChecked(false);
+
QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
aParamsLayout->setMargin( 5 );
aParamsLayout->setSpacing( 5 );
aParamsLayout->addWidget( myProfiles, 1, 1 );
aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 2, 0 );
aParamsLayout->addWidget( myEquiDistance, 2, 1 );
+ aParamsLayout->addWidget( new QLabel( tr( "INVERT_DIRECTION" ), aParamGroup ), 3, 0 );
+ aParamsLayout->addWidget( myInvertDirection, 3, 1 );
// Common
addWidget( myObjectNameGroup );
{
myEquiDistance->setValue( theValue );
}
+
+bool HYDROGUI_ChannelDlg::getInvertDirection() const
+{
+ return myInvertDirection->isChecked();
+}
+
+void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked )
+{
+ myInvertDirection->setChecked(isChecked);
+}
+
class QComboBox;
class QGroupBox;
class QLineEdit;
+class QCheckBox;
class QtxDoubleSpinBox;
class HYDROGUI_ChannelDlg : public HYDROGUI_InputPanel
double getEquiDistance() const;
void setEquiDistance( double );
+
+ bool getInvertDirection() const;
+ void setInvertDirection( bool isChecked );
+
signals:
void CreatePreview();
QComboBox* myProfiles;
QtxDoubleSpinBox* myEquiDistance;
+ QCheckBox* myInvertDirection;
};
#endif
#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
+#include <HYDROData_ChannelAltitude.h>
#include <TopoDS.hxx>
else
aPanel->setEquiDistance( 1.0 );
+ if( !myEditedObject.IsNull() )
+ {
+ bool invDirection = false;
+ Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject();
+ Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude);
+ if (!aChannelAlt.IsNull())
+ invDirection = aChannelAlt->GetInvertDirection();
+ aPanel->setInvertDirection( invDirection );
+ }
+ else
+ aPanel->setInvertDirection( false );
+
aPanel->blockSignals( false );
onCreatePreview();
myEditedObject->RemoveProfile();
myEditedObject->SetProfile( aProfile );
myEditedObject->SetEquiDistance( aPanel->getEquiDistance() );
+ ///
+ Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject();
+ Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude);
+ if (!aChannelAlt.IsNull())
+ aChannelAlt->SetInvertDirection(aPanel->getInvertDirection());
}
if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
<source>EQUI_DISTANCE</source>\r
<translation>Equidistance</translation>\r
</message>\r
+ <message>
+ <source>INVERT_DIRECTION</source>
+ <translation>Invert direction</translation>
+ </message>
</context>\r
\r
<context>\r