From: asl Date: Fri, 13 Dec 2013 07:19:25 +0000 (+0000) Subject: bug #234: projection of polyline X-Git-Tag: BR_hydro_v_0_5~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=744516a87297bacc7bd9c4d86f0898f1ca455793;p=modules%2Fhydro.git bug #234: projection of polyline --- diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index df700b22..d855bc21 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -140,6 +140,7 @@ void HYDROGUI_ObjSelector::OnSelectionChanged() void HYDROGUI_ObjSelector::SetName( const QString& theName ) { myObjName->setText( theName ); + emit selectionChanged(); } QString HYDROGUI_ObjSelector::GetName() const diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.h b/src/HYDROGUI/HYDROGUI_ObjSelector.h index 5846aed6..63cf857d 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.h +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.h @@ -61,6 +61,8 @@ signals: */ void alreadySelected( const QString& theName ); + void selectionChanged(); + protected: virtual void paintEvent( QPaintEvent* ); virtual bool hitButton( const QPoint& thePnt ) const; diff --git a/src/HYDROGUI/HYDROGUI_Poly3DDlg.cxx b/src/HYDROGUI/HYDROGUI_Poly3DDlg.cxx index 5cbf6235..ed4f67f3 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_Poly3DDlg.cxx @@ -49,19 +49,24 @@ HYDROGUI_Poly3DDlg::HYDROGUI_Poly3DDlg( HYDROGUI_Module* theModule, const QStrin // Parameters QGroupBox* aParamGroup = new QGroupBox( tr( "PARAMETERS" ) ); - myProfileLabel = new QLabel( tr( "PROFILE" ), aParamGroup ); - myProfile = new HYDROGUI_ObjSelector( theModule, KIND_PROFILE, aParamGroup ); - myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup ); myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup ); + myProfileLabel = new QLabel( tr( "PROFILE" ), aParamGroup ); + myProfile = new HYDROGUI_ObjSelector( theModule, KIND_PROFILE, aParamGroup ); + + myBathLabel = new QLabel( tr( "BATH" ), aParamGroup ); + myBath = new HYDROGUI_ObjSelector( theModule, KIND_BATHYMETRY, aParamGroup ); + QGridLayout* aParamLayout = new QGridLayout( aParamGroup ); aParamLayout->setMargin( 5 ); aParamLayout->setSpacing( 5 ); - aParamLayout->addWidget( myProfileLabel, 0, 0 ); - aParamLayout->addWidget( myProfile, 0, 1 ); - aParamLayout->addWidget( myPolylineLabel, 1, 0 ); - aParamLayout->addWidget( myPolyline, 1, 1 ); + aParamLayout->addWidget( myPolylineLabel, 0, 0 ); + aParamLayout->addWidget( myPolyline, 0, 1 ); + aParamLayout->addWidget( myProfileLabel, 1, 0 ); + aParamLayout->addWidget( myProfile, 1, 1 ); + aParamLayout->addWidget( myBathLabel, 2, 0 ); + aParamLayout->addWidget( myBath, 2, 1 ); // Common addWidget( aNameGroup ); @@ -69,6 +74,9 @@ HYDROGUI_Poly3DDlg::HYDROGUI_Poly3DDlg( HYDROGUI_Module* theModule, const QStrin addStretch(); setMode( myIsEdit ); + + connect( myProfile, SIGNAL( selectionChanged() ), this, SLOT( OnSelectionChanged() ) ); + connect( myBath, SIGNAL( selectionChanged() ), this, SLOT( OnSelectionChanged() ) ); } HYDROGUI_Poly3DDlg::~HYDROGUI_Poly3DDlg() @@ -97,19 +105,23 @@ QString HYDROGUI_Poly3DDlg::getResultName() const return myName->text(); } -void HYDROGUI_Poly3DDlg::setSelectedObjects( const QString& theName1, - const QString& theName2 ) +void HYDROGUI_Poly3DDlg::setSelectedObjects( const QString& theNamePoly, + const QString& theNameProfile, + const QString& theNameBath ) { - myProfile->SetName( theName1 ); - myPolyline->SetName( theName2 ); + myPolyline->SetName( theNamePoly ); + myProfile->SetName( theNameProfile ); + myBath->SetName( theNameBath ); } -bool HYDROGUI_Poly3DDlg::getSelectedObjects( QString& theName1, - QString& theName2 ) const +bool HYDROGUI_Poly3DDlg::getSelectedObjects( QString& theNamePoly, + QString& theNameProfile, + QString& theNameBath ) const { - theName1 = myProfile->GetName(); - theName2 = myPolyline->GetName(); - return !theName1.isEmpty() && !theName2.isEmpty(); + theNamePoly = myPolyline->GetName(); + theNameProfile = myProfile->GetName(); + theNameBath = myBath->GetName(); + return !theNamePoly.isEmpty() && ( !theNameProfile.isEmpty() || theNameBath.isEmpty() ); } void HYDROGUI_Poly3DDlg::setPreselectedObject( const QString& theName ) @@ -118,3 +130,11 @@ void HYDROGUI_Poly3DDlg::setPreselectedObject( const QString& theName ) myPolyline->SetChecked( true ); myPolyline->SetName( QString() ); } + +void HYDROGUI_Poly3DDlg::OnSelectionChanged() +{ + if( sender()==myProfile && !myProfile->GetName().isEmpty() ) + myBath->Clear(); + if( sender()==myBath && !myBath->GetName().isEmpty() ) + myProfile->Clear(); +} diff --git a/src/HYDROGUI/HYDROGUI_Poly3DDlg.h b/src/HYDROGUI/HYDROGUI_Poly3DDlg.h index e8aaced1..98e49dd2 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DDlg.h +++ b/src/HYDROGUI/HYDROGUI_Poly3DDlg.h @@ -46,23 +46,31 @@ public: void setResultName( const QString& theName ); QString getResultName() const; - void setSelectedObjects( const QString& theName1, - const QString& theName2 ); - bool getSelectedObjects( QString& theName1, - QString& theName2 ) const; + void setSelectedObjects( const QString& theNamePoly, + const QString& theNameProfile, + const QString& theNameBath ); + bool getSelectedObjects( QString& theNamePoly, + QString& theNameProfile, + QString& theNameBath ) const; void setPreselectedObject( const QString& theName ); +protected slots: + void OnSelectionChanged(); + private: bool myIsEdit; QLineEdit* myName; + QLabel* myPolylineLabel; + HYDROGUI_ObjSelector* myPolyline; + QLabel* myProfileLabel; HYDROGUI_ObjSelector* myProfile; - QLabel* myPolylineLabel; - HYDROGUI_ObjSelector* myPolyline; + QLabel* myBathLabel; + HYDROGUI_ObjSelector* myBath; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx index 0b0e1dea..74ea159a 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx +++ b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -73,16 +74,20 @@ void HYDROGUI_Poly3DOp::startOperation() } aPanel->setResultName( aPoly3DName ); - QString aSelectedName1, aSelectedName2; + QString aPolyName, aProfileName, aBathName; if( myIsEdit && !myEditedObject.IsNull() ) { - Handle(HYDROData_Entity) anObject1 = myEditedObject->GetProfileUZ()->GetFatherObject(); - if( !anObject1.IsNull() ) - aSelectedName1 = anObject1->GetName(); - Handle(HYDROData_Entity) anObject2 = myEditedObject->GetPolylineXY(); - if( !anObject2.IsNull() ) - aSelectedName2 = anObject2->GetName(); - aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 ); + Handle(HYDROData_Entity) aProfile = myEditedObject->GetProfileUZ()->GetFatherObject(); + if( !aProfile.IsNull() ) + aProfileName = aProfile->GetName(); + + Handle(HYDROData_Entity) aPoly = myEditedObject->GetPolylineXY(); + if( !aPoly.IsNull() ) + aPolyName = aPoly->GetName(); + + //TODO: use bathymetry from data model + + aPanel->setSelectedObjects( aPolyName, aProfileName, aBathName ); } else if( !myIsEdit ) { @@ -105,8 +110,8 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, if( aResultName.isEmpty() ) return false; - QString aSelectedName1, aSelectedName2; - if( !aPanel->getSelectedObjects( aSelectedName1, aSelectedName2 ) ) + QString aPolyName, aProfileName, aBathName; + if( !aPanel->getSelectedObjects( aPolyName, aProfileName, aBathName ) ) return false; if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != aResultName ) ) @@ -120,17 +125,21 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, } } - Handle(HYDROData_Entity) anObject1 = - HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_PROFILE ) ; - Handle(HYDROData_Entity) anObject2 = - HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_POLYLINEXY ); - if( anObject1.IsNull() || anObject2.IsNull() ) + Handle(HYDROData_Entity) aProfileEnt = + HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ; + Handle(HYDROData_Entity) aPolyEnt = + HYDROGUI_Tool::FindObjectByName( module(), aPolyName, KIND_POLYLINEXY ); + Handle(HYDROData_Entity) aBathEnt = + HYDROGUI_Tool::FindObjectByName( module(), aBathName, KIND_BATHYMETRY ); + + if( aPolyEnt.IsNull() || ( aPolyEnt.IsNull() && aBathEnt.IsNull() ) ) return false; - Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( anObject1 ); - Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( anObject2 ); + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aProfileEnt ); + Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( aBathEnt ); + Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aPolyEnt ); - if( aProfile.IsNull() || aPolyline.IsNull() ) + if( aProfile.IsNull() || ( aPolyline.IsNull() && aBath.IsNull() ) ) return false; Handle(HYDROData_ProfileUZ) aProfileUZ = aProfile->GetProfileUZ(); @@ -155,6 +164,7 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, aResult->SetName( aResultName ); aResult->SetProfileUZ( aProfileUZ ); aResult->SetPolylineXY( aPolyline ); + //TODO: set bathymetry if( !myIsEdit ) { @@ -166,8 +176,8 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, if( !myIsEdit ) { size_t aViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() ); - module()->setObjectVisible( aViewId, anObject1, false ); - module()->setObjectVisible( aViewId, anObject2, false ); + module()->setObjectVisible( aViewId, aPolyline, false ); + module()->setObjectVisible( aViewId, aProfile, false ); module()->setObjectVisible( aViewId, aResult, true ); } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index b53101fe..a64b53a4 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1240,6 +1240,10 @@ file cannot be correctly imported for a Bathymetry definition. PROFILE Profile + + BATH + Bathymetry +