From c6c1f5406f16c6fea8e6809ef1f5ad047fa92eb7 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Mon, 12 Oct 2020 23:10:23 +0200 Subject: [PATCH] fix mirrored display on import image, and abort on apply transformation. TODO: check more... --- src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx | 5 ++++ src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 29 ++++++++++++++++++++---- src/HYDROGUI/HYDROGUI_PrsImage.cxx | 10 ++++++++ src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx | 9 ++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 4922ee13..b7bdf7db 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -48,6 +48,9 @@ #include #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ), myIsInitialized( false ) @@ -525,6 +528,7 @@ void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationData const bool theIsOnlyInput, const bool theIsRefImage ) { + DEBTRACE("setTransformationDataMap " << theIsOnlyInput << " " << theIsRefImage); blockSignalsGeodesic( true ); blockSignalsCartesian( true ); for( int aPointType = HYDROGUI_PrsImage::PointA; @@ -538,6 +542,7 @@ void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationData QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ]; aPointX->setValue( aData.ImagePoint.x() ); aPointY->setValue( aData.ImagePoint.y() ); + DEBTRACE("aPointX " << aData.ImagePoint.x() << " aPointY " << aData.ImagePoint.y()); if( !theIsOnlyInput && !theIsRefImage ) { diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 5b16a0e4..bb8854fb 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -534,7 +534,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, // must be done after all checks and before calling SetVisible() method below if ( isApplyAndClose() ) { - DEBTRACE("closePreview"); + //DEBTRACE("closePreview"); closePreview(); } @@ -645,6 +645,10 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image:: { if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) { + DEBTRACE("myPreviewViewManager exists"); +// QTransform transform; +// transform.scale(1.0, -1.0); +// aViewPort->setTransform(transform, false); aViewPort->onBoundingRectChanged(); aViewPort->fitAll(); } @@ -664,6 +668,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image:: dynamic_cast( anApp->createViewManager( GraphicsView_Viewer::Type() ) ); if( myPreviewViewManager ) { + DEBTRACE("myPreviewViewManager created " << myPreviewViewManager); connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); @@ -673,8 +678,12 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image:: { if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) { + DEBTRACE("aViewPort " << aViewPort); //aViewPort->setMousePositionEnabled( true ); //ouv: temporarily commented + QTransform transform; + transform.scale(1.0, -1.0); + aViewPort->setTransform(transform, false); aViewPort->addItem( myPreviewPrs ); aViewPort->fitAll(); @@ -748,7 +757,7 @@ void HYDROGUI_ImportImageOp::onPointCoordChanged( bool theIsRef, void HYDROGUI_ImportImageOp::onModeActivated( int theMode ) { - DEBTRACE("onModeActivated"); + DEBTRACE("onModeActivated " << theMode); HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); QString aRefImageName; @@ -764,16 +773,18 @@ void HYDROGUI_ImportImageOp::onModeActivated( int theMode ) if( myRefViewManager ) { closeView( myRefViewManager ); + myRefViewManager = 0; } } } void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) { - DEBTRACE("onRefImageActivated"); + DEBTRACE("onRefImageActivated " << theName.toStdString()); if( theName.isEmpty() ) { if( myRefViewManager ) closeView( myRefViewManager ); + myRefViewManager = 0; return; } @@ -796,6 +807,7 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) dynamic_cast( anApp->createViewManager( GraphicsView_Viewer::Type() ) ); if( myRefViewManager ) { + DEBTRACE("myRefViewManager created " << myRefViewManager); connect( myRefViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); @@ -812,6 +824,9 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) if( !aViewPort ) return; + QTransform transform; + transform.scale(1.0, -1.0); + aViewPort->setTransform(transform, false); size_t aViewId = (size_t)myRefViewManager->getViewer(); @@ -891,7 +906,7 @@ void HYDROGUI_ImportImageOp::onRefPointSelected() void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage ) { - DEBTRACE("onPointSelected"); + DEBTRACE("onPointSelected " << theIsRefImage); HYDROGUI_PrsImage* aPrs = theIsRefImage ? myRefPreviewPrs : myPreviewPrs; if( !aPrs ) return; @@ -919,7 +934,9 @@ void HYDROGUI_ImportImageOp::closePreview() { DEBTRACE("closePreview"); closeView( myPreviewViewManager ); + myPreviewViewManager = 0; closeView( myRefViewManager ); + myRefViewManager = 0; if( myActiveViewManager ) HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager ); @@ -927,7 +944,7 @@ void HYDROGUI_ImportImageOp::closePreview() void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr ) { - DEBTRACE("closeView"); + DEBTRACE("closeView " << aViewMgr); if( aViewMgr ) { GraphicsView_ViewPort* aViewPort = 0; @@ -943,10 +960,12 @@ void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr ) switch ( module()->getViewManagerRole( aViewMgr ) ) { case HYDROGUI_Module::VMR_ReferenceImage: + DEBTRACE(" myRefPreviewPrs = 0"); aPrs = myRefPreviewPrs; myRefPreviewPrs = 0; break; case HYDROGUI_Module::VMR_TransformImage: + DEBTRACE(" myPreviewPrs = 0"); aPrs = myPreviewPrs; myPreviewPrs = 0; } diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index 6a5fe4a1..d7d0b567 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -153,6 +153,7 @@ void HYDROGUI_PrsImage::updateTransformationPoint( const int thePointType, const bool theIsY, const int theValue ) { + DEBTRACE("updateTransformationPoint " << thePointType << " theIsY " << theIsY << " theValue " << theValue); if( myTransformationPointMap.find( thePointType ) != myTransformationPointMap.end() ) { TransformationPoint& aTransformationPoint = myTransformationPointMap[ thePointType ]; @@ -187,6 +188,7 @@ QRectF HYDROGUI_PrsImage::boundingRect() const //================================================================ void HYDROGUI_PrsImage::compute() { + DEBTRACE("compute"); if( !myPixmapItem ) { myPixmapItem = new QGraphicsPixmapItem( this ); @@ -213,6 +215,11 @@ void HYDROGUI_PrsImage::compute() myCaptionItem->setPos( 0, -30 ); myCaptionItem->setVisible( false ); +// QTransform transform; +// transform.scale(1.0, -1.0); +// this->setTransform(transform, false); +// //this->setViewTransform(transform); + myPrsImageFrame->compute(); } @@ -346,6 +353,9 @@ QGraphicsItemGroup* HYDROGUI_PrsImage::createPointItem( const QString& theCaptio aGroupItem->addToGroup( aPointItem ); aGroupItem->addToGroup( aCaptionItem ); aGroupItem->setVisible( false ); +// QTransform transform; +// transform.scale(1.0, -1.0); // retourne le point et sa lettre +// aGroupItem->setTransform(transform, true); aGroupItem->setFlag( QGraphicsItem::ItemIgnoresTransformations ); return aGroupItem; diff --git a/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx b/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx index 30a69125..2dce8e56 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx @@ -22,6 +22,9 @@ #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + #define FRAME_Z_VALUE 1000 #define ANCHOR_RADIUS 3 #define EPSILON 1e-6 @@ -75,6 +78,7 @@ QRectF HYDROGUI_PrsImageFrame::boundingRect() const //================================================================ void HYDROGUI_PrsImageFrame::compute() { + DEBTRACE("compute"); if( myAnchorMap.isEmpty() ) { for( int aType = TopLeft; aType <= BottomRight; aType++ ) @@ -89,6 +93,9 @@ void HYDROGUI_PrsImageFrame::compute() setZValue( FRAME_Z_VALUE ); computeAnchorItems(); +// QTransform transform; +// transform.scale(-0.5, 1.0); +// this->setTransform(transform, false); updateVisibility(); } @@ -128,6 +135,8 @@ void HYDROGUI_PrsImageFrame::computeAnchorItems() //================================================================ void HYDROGUI_PrsImageFrame::updateVisibility() { + if (myPrsImage) + DEBTRACE("updateVisibility " << myPrsImage->isSelected()); setVisible( myPrsImage && myPrsImage->isSelected() ); } -- 2.39.2