Salome HOME
Observe Image operation.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageDlg.cxx
index 7a5d089e663bbd342b14755e19d7314a9ef64f85..47c7f13a3166ecd2d4e425c0c3c4e3ba57a9784b 100644 (file)
@@ -46,22 +46,34 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
 
   // Import image from file
-  myFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
+  myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
 
-  QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileGroup );
+  QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
 
-  myFileName = new QLineEdit( myFileGroup );
+  myFileName = new QLineEdit( myFileNameGroup );
   myFileName->setReadOnly( true );
 
-  QToolButton* aBrowseBtn = new QToolButton( myFileGroup );
+  QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
   aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
 
-  QBoxLayout* aFileLayout = new QHBoxLayout( myFileGroup );
-  aFileLayout->setMargin( 5 );
-  aFileLayout->setSpacing( 5 );
-  aFileLayout->addWidget( aFileNameLabel );
-  aFileLayout->addWidget( myFileName );
-  aFileLayout->addWidget( aBrowseBtn );
+  QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
+  aFileNameLayout->setMargin( 5 );
+  aFileNameLayout->setSpacing( 5 );
+  aFileNameLayout->addWidget( aFileNameLabel );
+  aFileNameLayout->addWidget( myFileName );
+  aFileNameLayout->addWidget( aBrowseBtn );
+
+  // Image name
+  myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) );
+
+  QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup );
+  myImageName = new QLineEdit( myImageNameGroup );
+
+  QBoxLayout* anImageNameLayout = new QHBoxLayout( myImageNameGroup );
+  anImageNameLayout->setMargin( 5 );
+  anImageNameLayout->setSpacing( 5 );
+  anImageNameLayout->addWidget( anImageNameLabel );
+  anImageNameLayout->addWidget( myImageName );
 
   // Mapping
   myMappingGroup = new QGroupBox( tr( "MAPPING" ) );
@@ -181,10 +193,10 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   aMappingLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
 
   // Common
-  addWidget( myFileGroup, 0, 0 );
-  addWidget( myMappingGroup, 1, 0 );
-
-  setRowStretch();
+  addWidget( myFileNameGroup );
+  addWidget( myImageNameGroup );
+  addWidget( myMappingGroup );
+  addStretch();
 
   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
 }
@@ -195,13 +207,16 @@ HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
 
 void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
 {
-  myFileGroup->setVisible( !theIsEdit );
+  myFileNameGroup->setVisible( !theIsEdit );
+  myImageNameGroup->setEnabled( theIsEdit );
   myMappingGroup->setEnabled( theIsEdit );
 }
 
 void HYDROGUI_ImportImageDlg::reset()
 {
   myFileName->clear();
+  myImageName->clear();
+  myImageNameGroup->setEnabled( false );
   for( int aPointType = HYDROGUI_PrsImage::PointA;
        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
   {
@@ -222,6 +237,16 @@ void HYDROGUI_ImportImageDlg::reset()
   myMappingGroup->setEnabled( false );
 }
 
+void HYDROGUI_ImportImageDlg::setImageName( const QString& theName )
+{
+  myImageName->setText( theName );
+}
+
+QString HYDROGUI_ImportImageDlg::getImageName() const
+{
+  return myImageName->text();
+}
+
 void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
                                                         const bool theIsOnlyInput )
 {
@@ -317,8 +342,11 @@ void HYDROGUI_ImportImageDlg::initializePointSelection()
 void HYDROGUI_ImportImageDlg::onBrowse()
 {
   QString aFilter( tr( "IMAGE_FILTER" ) );
-  //QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter );
+#ifdef OUV_DEBUG // to remove
   QString aFileName = "W:/Work/HYDRO/doc/samples/1.bmp";
+#else
+  QString aFileName = QFileDialog::getOpenFileName( this, tr( "IMPORT_IMAGE_FROM_FILE" ), "", aFilter );
+#endif
   if( !aFileName.isEmpty() )
   {
     QImage anImage( aFileName );
@@ -326,6 +354,7 @@ void HYDROGUI_ImportImageDlg::onBrowse()
     {
       myFileName->setText( aFileName );
       emit createPreview( anImage );
+      myImageNameGroup->setEnabled( true );
       myMappingGroup->setEnabled( true );
     }
   }