]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Import image dialog is fixed: selection point in the reference image and crashes...
authorrkv <rkv@opencascade.com>
Thu, 24 Oct 2013 12:55:20 +0000 (12:55 +0000)
committerrkv <rkv@opencascade.com>
Thu, 24 Oct 2013 12:55:20 +0000 (12:55 +0000)
src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.h
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx

index 4251a04c178ea74e9472c6ada1ba8523302792e6..f326790d17f0ed1de013aab808ba1fa03554bed3 100644 (file)
@@ -54,7 +54,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
 
   // Import image from file
-  myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
+  myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ), this );
 
   QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
 
@@ -72,7 +72,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   aFileNameLayout->addWidget( aBrowseBtn );
 
   // Image name
-  myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) );
+  myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this );
 
   QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup );
   myImageName = new QLineEdit( myImageNameGroup );
@@ -84,7 +84,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   anImageNameLayout->addWidget( myImageName );
 
   // Transform image
-  myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ) );
+  myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ), this );
 
   // Make a pixmap for arrow
   QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) );
@@ -108,7 +108,11 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
 
   myRefImage = new QComboBox( myTransformGroup );
 
-  QGridLayout* aModeLayout = new QGridLayout();
+  QGridLayout* aTransformLayout = new QGridLayout( myTransformGroup );
+  aTransformLayout->setMargin( 5 );
+  aTransformLayout->setSpacing( 5 );
+
+  QGridLayout* aModeLayout = new QGridLayout( myTransformGroup );
   aModeLayout->setMargin( 0 );
   aModeLayout->setSpacing( 5 );
   aModeLayout->addWidget( aManualCartesianBtn, 0, 0 );
@@ -117,15 +121,12 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   aModeLayout->addWidget( myRefImage,          2, 1 );
   aModeLayout->setColumnStretch( 1, 1 );
 
-  QGridLayout* aTransformLayout = new QGridLayout( myTransformGroup );
-  aTransformLayout->setMargin( 5 );
-  aTransformLayout->setSpacing( 5 );
   aTransformLayout->addLayout( aModeLayout, 0, 0, 1, 9 );
 
   QLabel* aImageCSLabel = new QLabel( tr( "IMAGE_CS" ), myTransformGroup );
-  QLabel* aGeodesicLabel = new QLabel( "GEODESIC", myTransformGroup );
-  QLabel* aLambertLabel = new QLabel( "LAMBERT93", myTransformGroup );
-  QLabel* aRefImageLabel = new QLabel( "REFERENCE_IMAGE_CS", myTransformGroup );
+  QLabel* aGeodesicLabel = new QLabel( tr( "GEODESIC" ), myTransformGroup );
+  QLabel* aLambertLabel = new QLabel( tr( "LAMBERT93" ), myTransformGroup );
+  QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE_CS" ), myTransformGroup );
 
   aTransformLayout->addWidget( aImageCSLabel,  2, 1 );
   aTransformLayout->addWidget( aGeodesicLabel, 2, 3, 1, 6 );
@@ -308,9 +309,6 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
 
 HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
 {
-  delete myFileNameGroup;
-  delete myImageNameGroup;
-  delete myTransformGroup;
 }
 
 void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
index 6db630212db27aff3c2232f8e92191543b4839d5..dabeaad10cc3f0a3c3b3b2f484b93fbb96cde800 100644 (file)
@@ -496,7 +496,7 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
       {
         aViewPort = aViewer->getActiveViewPort();
         connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ),
-                 this, SLOT( onPointSelected() ) );
+                 this, SLOT( onRefPointSelected() ) );
       }
     }
   }
@@ -564,6 +564,11 @@ void HYDROGUI_ImportImageOp::onPointSelected()
   onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() );
 }
 
+void HYDROGUI_ImportImageOp::onRefPointSelected()
+{
+  onPointSelected( true );
+}
+
 void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage )
 {
   HYDROGUI_PrsImage* aPrs = theIsRefImage ? myRefPreviewPrs : myPreviewPrs;
@@ -599,32 +604,37 @@ void HYDROGUI_ImportImageOp::closePreview()
 
 void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr )
 {
-  // It's very strange, but without calling this method (it's quite safe) a crash is stably reproduced.
-  // Scenario: create any non-Graphics view, activate import op, click apply.
-  // Result: a few SIGSEGVs coming from processEvents(), then crash.
   if( aViewMgr )
   {
+    GraphicsView_ViewPort* aViewPort = 0;
     if( GraphicsView_Viewer* aViewer = aViewMgr->getViewer() )
     {
-      if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
-      {
-        aViewPort->onBoundingRectChanged();
-      }
+      aViewPort = aViewer->getActiveViewPort();
     }
     disconnect( aViewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
                 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
 
     // Nullify appropriate presentation pointer
+    HYDROGUI_PrsImage* aPrs;
     switch ( module()->getViewManagerRole( aViewMgr ) )
     {
       case HYDROGUI_Module::VMR_ReferenceImage:
+        aPrs = myRefPreviewPrs;
         myRefPreviewPrs = 0;
         break;
       case HYDROGUI_Module::VMR_TransformImage:
+        aPrs = myPreviewPrs;
         myPreviewPrs = 0;
     }
 
-    // Delete the view and all its presentations
+    // Remove the appropriate presentation from the view
+    if( aPrs && aViewPort )
+    {
+      aViewPort->removeItem( aPrs );
+      delete aPrs;
+    }
+
+    // Delete the view
     module()->getApp()->removeViewManager( aViewMgr ); // aViewMgr is deleted here
     aViewMgr = 0;
   }
index c931a9dac71b1a0bf00fa663ca64bf0e42779abd..2a3ada8fc5cd9ca010fc4719f2e8f678c02abdc0 100644 (file)
@@ -62,6 +62,7 @@ protected slots:
   void                       onLastViewClosed( SUIT_ViewManager* );
 
   void                       onPointSelected();
+  void                       onRefPointSelected();
   void                       onPointSelected( bool theIsRefImage );
 
 private:
index 986dce2d55a4fbe05289291e97d8d25ff8030184..32edca357e3bdeac0404669be8cbcc336a24bdc0 100644 (file)
@@ -396,7 +396,7 @@ void HYDROGUI_Module::update( const int flags )
     // the selection in the object browser.
     // Note: processEvents() should be called after updateGV(),
     // otherwise the application crashes from time to time.
-    qApp->processEvents(); 
+    //RKV: qApp->processEvents(); 
     getApp()->updateObjectBrowser( true );
   }
 
index 0ab14c6b371f66d70a64f6ee6d576946275db8ca..d1655f3c411ba05c8726579c0b87e5d4a8951283 100644 (file)
@@ -202,7 +202,7 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
       ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
     if ( aViewWindow )
     {
-      QApplication::processEvents(); //Process the draw events for viewer
+      //RKV: QApplication::processEvents(); //Process the draw events for viewer
       aViewWindow->onFitAll();
     }
   }