X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_BathymetryOp.cxx;h=cee53f3ec05fb13de152fd1f77972905a7e36869;hb=6074577ddf7ed43a22093a51d50d53b99adaea5e;hp=787053cf5a3a5dfe4266cb27eefa45e25a250853;hpb=f193301282670fecb290c9cda36fdc356d1667de;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx index 787053cf..cee53f3e 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx @@ -18,6 +18,69 @@ // #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +HYDROGUI_BathymetryLimitsDlg::HYDROGUI_BathymetryLimitsDlg( QWidget* theParent ) + : QDialog( theParent ) +{ + QGridLayout* layout = new QGridLayout(); + setLayout( layout ); + + layout->addWidget( new QLabel( tr( "MIN_VALUE" ) ), 0, 0 ); + layout->addWidget( new QLabel( tr( "MAX_VALUE" ) ), 1, 0 ); + + myMin = new QtxDoubleSpinBox( this ); + myMax = new QtxDoubleSpinBox( this ); + + layout->addWidget( myMin, 0, 1 ); + layout->addWidget( myMax, 1, 1 ); + + QFrame* aBtnFrame = new QFrame( this ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnFrame ); + layout->addWidget( aBtnFrame, 2, 0, 1, 2 ); + + QPushButton* ok = new QPushButton( tr( "OK" ), this ); + QPushButton* cancel = new QPushButton( tr( "CANCEL" ), this ); + aBtnLayout->addWidget( ok ); + aBtnLayout->addWidget( cancel ); + + connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( ok, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +HYDROGUI_BathymetryLimitsDlg::~HYDROGUI_BathymetryLimitsDlg() +{ +} + +double HYDROGUI_BathymetryLimitsDlg::GetMin() const +{ + return myMin->value(); +} + +double HYDROGUI_BathymetryLimitsDlg::GetMax() const +{ + return myMax->value(); +} + +void HYDROGUI_BathymetryLimitsDlg::SetMinMax( double theMin, double theMax ) +{ + myMin->setValue( theMin ); + myMax->setValue( theMax ); +} + + + + HYDROGUI_BathymetryOp::HYDROGUI_BathymetryOp( HYDROGUI_Module* theModule, int theMode ) : HYDROGUI_Operation( theModule ), myMode( theMode ) @@ -28,12 +91,101 @@ HYDROGUI_BathymetryOp::~HYDROGUI_BathymetryOp() { } +Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule ); +QList getShownBathymetries( HYDROGUI_Module* theModule ); + void HYDROGUI_BathymetryOp::startOperation() { - //TODO + activate( true ); +} + +void HYDROGUI_BathymetryOp::commitOperation() +{ + activate( false ); } void HYDROGUI_BathymetryOp::abortOperation() { - //TODO + activate( false ); +} + +OCCViewer_ViewWindow* HYDROGUI_BathymetryOp::activeViewWindow() const +{ + LightApp_Application* app = module()->getApp(); + OCCViewer_ViewManager* mgr = dynamic_cast + ( app->getViewManager( OCCViewer_Viewer::Type(), true ) ); + return dynamic_cast( mgr->getActiveView() ); +} + +void HYDROGUI_BathymetryOp::activate( bool isActivate ) +{ +QList baths = getShownBathymetries( module() ); + + switch( myMode ) + { + case BathymetryTextId: + { + foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) + bath->GetShape()->TextLabels( isActivate ); + break; + } + + case BathymetryRescaleSelectionId: + { + if( isActivate ) + foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) + bath->GetShape()->RescaleBySelection(); + commit(); + break; + } + + case BathymetryRescaleVisibleId: + { + if( isActivate ) + foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) + bath->GetShape()->RescaleByVisible( activeViewWindow() ); + commit(); + break; + } + + case BathymetryRescaleUserId: + { + if( isActivate ) + { + double min=0, max=0, lmin=0, lmax=0; + bool first = true; + foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) + { + bath->GetShape()->GetRange( lmin, lmax ); + if( first || lmin < min ) + min = lmin; + if( first || lmax > max ) + max = lmax; + first = false; + } + + HYDROGUI_BathymetryLimitsDlg dlg( module()->getApp()->desktop() ); + dlg.SetMinMax( min, max ); + if( dlg.exec()==QDialog::Accepted ) + { + min = dlg.GetMin(); + max = dlg.GetMax(); + foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) + bath->GetShape()->Rescale( min, max ); + commit(); + } + else + abort(); + break; + } + } + + case BathymetryRescaleDefaultId: + { + if( isActivate ) + foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) + bath->GetShape()->RescaleDefault(); + break; + } + } }