#include "HYDROData_ChannelAltitude.h"
#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepLib_MakePolygon.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
PrsDefinition& thePrs,
double theEquiDistance,
bool ReverseXCoord)
+{
+ return internalCreatePresentations( true, theGuideLine, theProfile, TopoDS_Wire(), gp_Pnt(), thePrs, theEquiDistance, ReverseXCoord);
+}
+
+bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
+ double LC,
+ double deltaZ,
+ double coteZ,
+ PrsDefinition& thePrs,
+ double theEquiDistance,
+ bool ReverseXCoord)
+{
+ Handle(HYDROData_Profile) theProfile;
+ TopoDS_Wire W;
+ gp_Pnt MP;
+
+ gp_Pnt2d A1(-0.75*LC, coteZ-LC/2.0), A2(0.75*LC, coteZ -LC/2.0), B1(-LC/2.0, coteZ), B2(LC/2.0, coteZ), C(0, coteZ+deltaZ);
+ gp_Pnt A1_3d(A1.X(), 0, A1.Y()), A2_3d(A2.X(), 0, A2.Y()), B1_3d(B1.X(), 0, B1.Y()), B2_3d(B2.X(), 0, B2.Y()), C_3d(C.X(), 0, C.Y());
+ BRepLib_MakePolygon PM;
+ PM.Add(A1_3d);
+ PM.Add(B1_3d);
+ PM.Add(C_3d);
+ PM.Add(B2_3d);
+ PM.Add(A2_3d);
+ W = PM.Wire();
+ return internalCreatePresentations( false, theGuideLine, theProfile, W, MP, thePrs, theEquiDistance, ReverseXCoord);
+}
+
+bool HYDROData_Channel::internalCreatePresentations( bool mode,
+ const Handle(HYDROData_Polyline3D)& theGuideLine,
+ const Handle(HYDROData_Profile)& theProfile,
+ const TopoDS_Wire& theProfWire,
+ const gp_Pnt& theMiddlePnt,
+ PrsDefinition& thePrs,
+ double theEquiDistance,
+ bool ReverseXCoord)
{
// Check input parameters
- if ( theGuideLine.IsNull() || theProfile.IsNull() ) {
+ if ( theGuideLine.IsNull() )
+ {
return false;
}
+ if (mode && theProfile.IsNull() || !mode && theProfWire.IsNull() )
+ return false;
TopoDS_Wire aPathWire = TopoDS::Wire( theGuideLine->GetShape3D() );
- TopoDS_Wire aProfileWire;
- if (!ReverseXCoord)
- aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, false) ); //temp force rebuild
- else
- aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, true));
+ TopoDS_Wire aProfileWire = theProfWire;
+ //ignore ReverseXCoord if mode is false
+ if (mode)
+ {
+ 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;
}
}
// Get the profile middle point ( 3D )
- gp_Pnt aMiddlePoint( theProfile->GetMiddlePoint( true ) );
+ gp_Pnt aMiddlePoint = theMiddlePnt;
+ if (mode)
+ {
+ aMiddlePoint = theProfile->GetMiddlePoint( true );
+ }
// Translate the profile to each point on the guide line ( 3D )
Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aNbPoints );
HYDROData_ArtificialObject::Update();
Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
- Handle(HYDROData_Profile) aProfile = GetProfile();
PrsDefinition aResultPrs;
double anEquiDistance = GetEquiDistance();
if (!aChannelAlt.IsNull())
invDirection = aChannelAlt->GetInvertDirection();
- if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) )
- return;
+ if (GetProfileMode())
+ {
+ Handle(HYDROData_Profile) aProfile = GetProfile();
+ if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) )
+ return;
+ }
+ else
+ {
+ double lc = GetLCValue();
+ double deltaz = GetDeltaZValue();
+ double cotez = GetCoteZValue();
+ if ( !CreatePresentations( aGuideLine, lc, deltaz, cotez, aResultPrs, anEquiDistance, invDirection ) )
+ return;
+ }
SetShape3D( aResultPrs.myPrs3D );
SetTopShape( aResultPrs.myPrs2D );
{
return GetDouble( DataTag_EquiDistance, 1.0 );
}
+
+void HYDROData_Channel::SetLCValue( double val )
+{
+ SetDouble( DataTag_LC, val );
+}
+
+double HYDROData_Channel::GetLCValue() const
+{
+ return GetDouble( DataTag_LC, 1.0 );
+}
+
+void HYDROData_Channel::SetDeltaZValue( double val )
+{
+ SetDouble( DataTag_DeltaZ, val );
+}
+
+double HYDROData_Channel::GetDeltaZValue() const
+{
+ return GetDouble( DataTag_DeltaZ, 1.0 );
+}
+
+void HYDROData_Channel::SetCoteZValue( double val )
+{
+ SetDouble( DataTag_CoteZ, val );
+}
+
+double HYDROData_Channel::GetCoteZValue() const
+{
+ return GetDouble( DataTag_CoteZ, 1.0 );
+}
+
+void HYDROData_Channel::SetProfileMode( bool mode )
+{
+ SetInteger( DataTag_ProfileMode, (bool)mode );
+}
+
+bool HYDROData_Channel::GetProfileMode() const
+{
+ return (bool)GetInteger( DataTag_ProfileMode, 1 );
+}
DataTag_GuideLine,
DataTag_Profile,
DataTag_EquiDistance,
+ DataTag_ProfileMode,
+ DataTag_LC,
+ DataTag_DeltaZ,
+ DataTag_CoteZ
};
public:
/**
* Creates the presentations(2D and 3D) by given guide line and profile.
*/
+
HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
const Handle(HYDROData_Profile)& theProfile,
PrsDefinition& thePrs,
- double theEquiDistance,
+ double theEquiDistance,
+ bool ReverseXCoord = false);
+
+ HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
+ double LC,
+ double deltaZ,
+ double coteZ,
+ PrsDefinition& thePrs,
+ double theEquiDistance,
bool ReverseXCoord = false);
+protected:
+ static bool internalCreatePresentations( bool mode,
+ const Handle(HYDROData_Polyline3D)& theGuideLine,
+ const Handle(HYDROData_Profile)& theProfile,
+ const TopoDS_Wire& theProfWire,
+ const gp_Pnt& theMiddlePnt,
+ PrsDefinition& thePrs,
+ double theEquiDistance,
+ bool ReverseXCoord);
+
public:
/**
HYDRODATA_EXPORT void SetEquiDistance( double );
HYDRODATA_EXPORT double GetEquiDistance() const;
+
+ HYDRODATA_EXPORT void SetLCValue( double );
+ HYDRODATA_EXPORT double GetLCValue() const;
+
+ HYDRODATA_EXPORT void SetDeltaZValue( double );
+ HYDRODATA_EXPORT double GetDeltaZValue() const;
+
+ HYDRODATA_EXPORT void SetCoteZValue( double );
+ HYDRODATA_EXPORT double GetCoteZValue() const;
+
+ HYDRODATA_EXPORT void SetProfileMode( bool );
+ HYDRODATA_EXPORT bool GetProfileMode() const;
+
protected:
/**
* Returns the type of child altitude object.
connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
+ connect( myLCVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) );
+ connect( myDeltaZVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) );
+ connect( myCoteZVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) );
+
connect( myProfileModeButton, SIGNAL( toggled( bool ) ), this, SLOT( onProfileModeChanged( bool ) ) );
myProfileModeButton->setChecked(true);
}
myCoteZValLabel->setVisible(true);
myCoteZVal->setVisible(true);
}
+ emit CreatePreview();
}
bool HYDROGUI_ChannelDlg::getProfileMode()
myInvertDirection->setChecked(isChecked);
}
+double HYDROGUI_ChannelDlg::getLCValue() const
+{
+ return myLCVal->value();
+}
+
+void HYDROGUI_ChannelDlg::setLCValue( double val )
+{
+ myLCVal->setValue( val );
+}
+
+double HYDROGUI_ChannelDlg::getDeltaZValue() const
+{
+ return myDeltaZVal->value();
+}
+
+void HYDROGUI_ChannelDlg::setDeltaZValue( double val )
+{
+ myDeltaZVal->setValue( val );
+}
+double HYDROGUI_ChannelDlg::getCoteZValue() const
+{
+ return myCoteZVal->value();
+}
+
+void HYDROGUI_ChannelDlg::setCoteZValue( double val )
+{
+ myCoteZVal->setValue( val );
+}
\ No newline at end of file
void setInvertDirection( bool isChecked );
bool getProfileMode();
-
-
+
+ double getLCValue() const;
+ void setLCValue( double );
+
+ double getDeltaZValue() const;
+ void setDeltaZValue( double );
+
+ double getCoteZValue() const;
+ void setCoteZValue( double );
signals:
void CreatePreview();
}
QString aGuideLineName = aPanel->getGuideLineName();
- QString aProfileName = aPanel->getProfileName();
+
+ bool profileMode = aPanel->getProfileMode();
+ QString aProfileName;
+ double lc=0, deltaz=0, cotez=0;
+
+ if (profileMode)
+ {
+ aProfileName = aPanel->getProfileName();
+ }
+ else
+ {
+ lc = aPanel->getLCValue();
+ deltaz = aPanel->getDeltaZValue();
+ cotez = aPanel->getCoteZValue();
+ }
+
+
/*if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() )
{
myEditedObject->RemoveGuideLine();
myEditedObject->RemoveGuideLine();
myEditedObject->SetGuideLine( aGuideLine );
- Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
- if ( aProfile.IsNull() )
+ myEditedObject->SetProfileMode(profileMode);
+
+ if (profileMode)
{
- theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" );
- return false;
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
+ if ( aProfile.IsNull() )
+ {
+ theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" );
+ return false;
+ }
+ myEditedObject->RemoveProfile();
+ myEditedObject->SetProfile( aProfile );
+ myEditedObject->SetLCValue(0);
+ myEditedObject->SetDeltaZValue(0);
+ myEditedObject->SetCoteZValue(0);
+ }
+ else
+ {
+ myEditedObject->RemoveProfile();
+ myEditedObject->SetLCValue(lc);
+ myEditedObject->SetDeltaZValue(deltaz);
+ myEditedObject->SetCoteZValue(cotez);
}
- myEditedObject->RemoveProfile();
- myEditedObject->SetProfile( aProfile );
myEditedObject->SetEquiDistance( aPanel->getEquiDistance() );
///
Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject();
Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
+ bool aProfMode = aPanel->getProfileMode();
HYDROData_Channel::PrsDefinition aPrsDef;
- if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, aPanel->getEquiDistance() ) )
+ bool stat = false;
+ double eqDist = aPanel->getEquiDistance();
+ if (aProfMode)
+ stat = HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, eqDist);
+ else
+ {
+ double lc = aPanel->getLCValue();
+ double deltaz = aPanel->getDeltaZValue();
+ double cotez = aPanel->getCoteZValue();
+ stat = HYDROData_Channel::CreatePresentations( aGuideLine, lc, deltaz, cotez, aPrsDef, eqDist);
+ }
+ if ( !stat )
{
erasePreview();
return;