From ea0ae4cd7c72db182fe942ab694dfebea424e134 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 3 Oct 2017 10:48:45 +0300 Subject: [PATCH] refs #1327: debug of scaling operations --- src/HYDROGUI/HYDROGUI_BathymetryOp.cxx | 36 +++++++++-- src/HYDROGUI/HYDROGUI_BathymetryOp.h | 1 + .../HYDROGUI_BathymetrySelectionOp.cxx | 12 +++- src/HYDROGUI/HYDROGUI_OCCDisplayer.h | 6 +- src/HYDROGUI/HYDROGUI_Operations.cxx | 10 ++- src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx | 1 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 64 +++++++++++++++++++ 7 files changed, 116 insertions(+), 14 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx index cee53f3e..0c45c2d7 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetryOp.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -36,11 +37,13 @@ HYDROGUI_BathymetryLimitsDlg::HYDROGUI_BathymetryLimitsDlg( QWidget* 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 ); + layout->addWidget( new QLabel( tr( "Min value" ) ), 0, 0 ); + layout->addWidget( new QLabel( tr( "Max value" ) ), 1, 0 ); myMin = new QtxDoubleSpinBox( this ); + myMin->setRange( -1000, 1000 ); myMax = new QtxDoubleSpinBox( this ); + myMax->setRange( -1000, 1000 ); layout->addWidget( myMin, 0, 1 ); layout->addWidget( myMax, 1, 1 ); @@ -50,12 +53,12 @@ HYDROGUI_BathymetryLimitsDlg::HYDROGUI_BathymetryLimitsDlg( QWidget* theParent ) layout->addWidget( aBtnFrame, 2, 0, 1, 2 ); QPushButton* ok = new QPushButton( tr( "OK" ), this ); - QPushButton* cancel = new QPushButton( tr( "CANCEL" ), 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() ) ); + connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); } HYDROGUI_BathymetryLimitsDlg::~HYDROGUI_BathymetryLimitsDlg() @@ -83,7 +86,7 @@ void HYDROGUI_BathymetryLimitsDlg::SetMinMax( double theMin, double theMax ) HYDROGUI_BathymetryOp::HYDROGUI_BathymetryOp( HYDROGUI_Module* theModule, int theMode ) -: HYDROGUI_Operation( theModule ), myMode( theMode ) +: HYDROGUI_Operation( theModule ), myMode( theMode ), myIsActivate( false ) { } @@ -91,6 +94,7 @@ HYDROGUI_BathymetryOp::~HYDROGUI_BathymetryOp() { } +OCCViewer_Viewer* getViewer( HYDROGUI_Module* theModule ); Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule ); QList getShownBathymetries( HYDROGUI_Module* theModule ); @@ -119,7 +123,12 @@ OCCViewer_ViewWindow* HYDROGUI_BathymetryOp::activeViewWindow() const void HYDROGUI_BathymetryOp::activate( bool isActivate ) { -QList baths = getShownBathymetries( module() ); + if( myIsActivate==isActivate ) + return; + + myIsActivate = isActivate; + QList baths = getShownBathymetries( module() ); + bool isUpdateCS = false; switch( myMode ) { @@ -133,8 +142,11 @@ QList baths = getShownBathymetries( module() ); case BathymetryRescaleSelectionId: { if( isActivate ) + { foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) bath->GetShape()->RescaleBySelection(); + isUpdateCS = true; + } commit(); break; } @@ -142,8 +154,11 @@ QList baths = getShownBathymetries( module() ); case BathymetryRescaleVisibleId: { if( isActivate ) + { foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) bath->GetShape()->RescaleByVisible( activeViewWindow() ); + isUpdateCS = true; + } commit(); break; } @@ -172,6 +187,8 @@ QList baths = getShownBathymetries( module() ); max = dlg.GetMax(); foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) bath->GetShape()->Rescale( min, max ); + + isUpdateCS = true; commit(); } else @@ -183,9 +200,16 @@ QList baths = getShownBathymetries( module() ); case BathymetryRescaleDefaultId: { if( isActivate ) + { foreach( Handle(HYDROGUI_BathymetryPrs) bath, baths ) bath->GetShape()->RescaleDefault(); + isUpdateCS = true; + } + commit(); break; } } + + if( isUpdateCS ) + module()->getOCCDisplayer()->UpdateColorScale( getViewer( module() ) ); } diff --git a/src/HYDROGUI/HYDROGUI_BathymetryOp.h b/src/HYDROGUI/HYDROGUI_BathymetryOp.h index b85ecd19..705a54e6 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryOp.h +++ b/src/HYDROGUI/HYDROGUI_BathymetryOp.h @@ -44,6 +44,7 @@ protected: private: int myMode; + bool myIsActivate; }; diff --git a/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx index 76d4dcc0..2aeb9daa 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetrySelectionOp.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -49,13 +50,17 @@ bool HYDROGUI_BathymetrySelectionOp::isValid( SUIT_Operation* theOtherOp ) const return ( aBathOp != 0 ); } -Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule ) +OCCViewer_Viewer* getViewer( HYDROGUI_Module* theModule ) { LightApp_Application* app = theModule->getApp(); OCCViewer_ViewManager* mgr = dynamic_cast ( app->getViewManager( OCCViewer_Viewer::Type(), true ) ); - Handle(AIS_InteractiveContext) ctx = mgr->getOCCViewer()->getAISContext(); - return ctx; + return mgr->getOCCViewer(); +} + +Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule ) +{ + return getViewer( theModule )->getAISContext(); } QList getShownBathymetries( HYDROGUI_Module* theModule ) @@ -99,6 +104,7 @@ void HYDROGUI_BathymetrySelectionOp::activateSelection( bool isActive ) { bath->ClearSelected(); bath->SetAutoHilight( Standard_True ); + bath->GetShape()->TextLabels( false ); ctx->Deactivate( bath ); } ctx->CloseLocalContext( -1, Standard_True ); diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h index 92e20c81..27595447 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h @@ -82,6 +82,8 @@ public: */ Handle(AIS_ColorScale) GetColorScale( const int theViewerId ); + void UpdateColorScale( const OCCViewer_Viewer* ); + protected: /** * \brief Erase all viewer objects. @@ -108,15 +110,11 @@ protected: const int theViewerId, const bool theIsForced, const bool theDoFitAll ); - -protected: /** * \brief Purge all invalid objects in the viewer. * \param theViewerId viewer identifier */ void purgeObjects( const int theViewerId ); - - void UpdateColorScale( const OCCViewer_Viewer* ); private: /** diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index cb4ad520..b1c58801 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -796,7 +796,15 @@ void HYDROGUI_Module::onBathymetrySelection() if( isChecked ) startOperation( BathymetrySelectionId ); else - operation( BathymetrySelectionId )->abort(); + { + LightApp_Operation* op = operation( BathymetryTextId ); + if( op ) + op->abort(); + + op = operation( BathymetrySelectionId ); + if( op ) + op->abort(); + } } void HYDROGUI_Module::onBathymetryText() diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx index da2a12b7..cf9a3681 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx @@ -228,6 +228,7 @@ void HYDROGUI_ShapeBathymetry::Rescale( double theMin, double theMax ) getContext()->ClearSelected(); myMin = qMin( theMin, theMax ); myMax = qMax( theMin, theMax ); + setToUpdateColorScale( true ); getAISObject()->Redisplay(); } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 391221f9..ca53fe75 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -971,6 +971,26 @@ Would you like to remove all references from the image? DSK_BATHYMETRY_SELECTION Selection on bathymetry + + DSK_BATHYMETRY_TEXT + Z-Values on bathymetry + + + DSK_BATHYMETRY_RESCALE_SELECTION + Rescale bathymetry by selection + + + DSK_BATHYMETRY_RESCALE_VISIBLE + Rescale bathymetry by visible range + + + DSK_BATHYMETRY_RESCALE_USER + Custom rescale bathymetry + + + DSK_BATHYMETRY_RESCALE_DEFAULT + Default rescale bathymetry + DSK_IMPORT_IMAGE Import image @@ -1320,6 +1340,26 @@ Would you like to remove all references from the image? MEN_BATHYMETRY_SELECTION Selection on bathymetry + + MEN_BATHYMETRY_TEXT + Z-Values on bathymetry + + + MEN_BATHYMETRY_RESCALE_SELECTION + Rescale bathymetry by selection + + + MEN_BATHYMETRY_RESCALE_VISIBLE + Rescale bathymetry by visible range + + + MEN_BATHYMETRY_RESCALE_USER + Custom rescale bathymetry + + + MEN_BATHYMETRY_RESCALE_DEFAULT + Default rescale bathymetry + MEN_IMPORT_IMAGE Import image @@ -1633,6 +1673,30 @@ Would you like to remove all references from the image? STB_BATHYMETRY_SELECTION Selection on bathymetry + + + STB_BATHYMETRY_RESCALE_SELECTION + + Rescale bathymetry by selection + + + + STB_BATHYMETRY_RESCALE_VISIBLE + + Rescale bathymetry by visible range + + + + STB_BATHYMETRY_RESCALE_USER + + Custom rescale bathymetry + + + + STB_BATHYMETRY_RESCALE_DEFAULT + + Default rescale bathymetry + STB_IMPORT_IMAGE Import image -- 2.39.2