Salome HOME
fix mirrored display on import image, and abort on apply transformation. TODO: check...
authorPaul RASCLE <paul.rascle@openfields.fr>
Mon, 12 Oct 2020 21:10:23 +0000 (23:10 +0200)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:09:38 +0000 (17:09 +0100)
src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_PrsImage.cxx
src/HYDROGUI/HYDROGUI_PrsImageFrame.cxx

index 4922ee13fd3bda04ffb4ebb060f3681ab38f5356..b7bdf7dbc9c13cf6e5c7e5b721662becbd1dfb69 100644 (file)
@@ -48,6 +48,9 @@
 #include <QToolButton>
 #include <QCheckBox>
 
+#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 )
       {
index 5b16a0e4dccdabd3f069ad3902a71fcfe92bae4c..bb8854fbd0ea6f236bb460862e4176740abf7ad6 100644 (file)
@@ -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<GraphicsView_ViewManager*>( 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<GraphicsView_ViewManager*>( 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;
     }
index 6a5fe4a12534e72d6a9d58d0b2cd3a9e86fa931d..d7d0b5675ce982befce921d9d2988483e837d448 100644 (file)
@@ -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;
index 30a691257307807e5cff77423127545426d6ef4a..2dce8e563379232b87ed01f876773aaba551b71e 100644 (file)
@@ -22,6 +22,9 @@
 
 #include <QPainter>
 
+#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() );
 }