#include "HYDROGUI_ImportImageDlg.h"
#include "HYDROGUI_PrsImage.h"
+#include "HYDROGUI_Tool.h"
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <QDoubleValidator>
#include <QFileDialog>
#include <QGroupBox>
+#include <QIntValidator>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
// Import image from file
- QGroupBox* aFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
+ myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
- QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileGroup );
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
- myFileName = new QLineEdit( aFileGroup );
+ myFileName = new QLineEdit( myFileNameGroup );
myFileName->setReadOnly( true );
- QToolButton* aBrowseBtn = new QToolButton( aFileGroup );
+ QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
- QBoxLayout* aFileLayout = new QHBoxLayout( aFileGroup );
- 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" ) );
QString aPointStr;
switch( aPointType )
{
- case HYDROGUI_PrsImage::PointA: aPointStr = tr( "POINT_A" ); break;
- case HYDROGUI_PrsImage::PointB: aPointStr = tr( "POINT_B" ); break;
- case HYDROGUI_PrsImage::PointC: aPointStr = tr( "POINT_C" ); break;
+ case HYDROGUI_PrsImage::PointA: aPointStr = tr( "ACTIVATE_POINT_A_SELECTION" ); break;
+ case HYDROGUI_PrsImage::PointB: aPointStr = tr( "ACTIVATE_POINT_B_SELECTION" ); break;
+ case HYDROGUI_PrsImage::PointC: aPointStr = tr( "ACTIVATE_POINT_C_SELECTION" ); break;
}
QPushButton* aPointBtn = new QPushButton( aPointStr, myMappingGroup );
aPointBtn->setCheckable( true );
- QLabel* aPointXLabel = new QLabel( tr( "X" ), myMappingGroup );
- QLabel* aPointYLabel = new QLabel( tr( "Y" ), myMappingGroup );
+ QLabel* aPointXLabel = new QLabel( "X", myMappingGroup );
+ QLabel* aPointYLabel = new QLabel( "Y", myMappingGroup );
- QLineEdit* aPointX1 = new QLineEdit( myMappingGroup );
- QLineEdit* aPointY1 = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointX = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointY = new QLineEdit( myMappingGroup );
- aPointX1->setReadOnly( true );
- aPointY1->setReadOnly( true );
+ aPointX->setReadOnly( true );
+ aPointY->setReadOnly( true );
//QLabel* aPointArrowLabel = new QLabel( ">", myMappingGroup );
QLabel* aPointArrowLabel = new QLabel( myMappingGroup );
aPointArrowLabel->setPicture( anArrowPicture );
- QLineEdit* aPointX2 = new QLineEdit( myMappingGroup );
- QLineEdit* aPointY2 = new QLineEdit( myMappingGroup );
-
- QDoubleValidator* aDoubleValidator = new QDoubleValidator();
- aPointX2->setValidator( aDoubleValidator );
- aPointY2->setValidator( aDoubleValidator );
-
- int aRow = 3 * aPointType;
- aMappingLayout->addWidget( aPointBtn, aRow, 0, 2, 1 );
- aMappingLayout->addWidget( aPointXLabel, aRow, 1 );
- aMappingLayout->addWidget( aPointX1, aRow, 2 );
- aMappingLayout->addWidget( aPointArrowLabel, aRow, 3, 2, 1 );
- aMappingLayout->addWidget( aPointX2, aRow, 4 );
- aMappingLayout->addWidget( aPointYLabel, aRow + 1, 1 );
- aMappingLayout->addWidget( aPointY1, aRow + 1, 2 );
- aMappingLayout->addWidget( aPointY2, aRow + 1, 4 );
+ QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), myMappingGroup );
+ QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), myMappingGroup );
+ QLabel* aPointXMinLabel = new QLabel( "'", myMappingGroup );
+ QLabel* aPointYMinLabel = new QLabel( "'", myMappingGroup );
+ QLabel* aPointXSecLabel = new QLabel( "\"", myMappingGroup );
+ QLabel* aPointYSecLabel = new QLabel( "\"", myMappingGroup );
+
+ QLineEdit* aPointXDeg = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointYDeg = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointXMin = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointYMin = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointXSec = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointYSec = new QLineEdit( myMappingGroup );
+
+ QIntValidator* aXDegValidator = new QIntValidator( -180, 180, this );
+ QIntValidator* aYDegValidator = new QIntValidator( -90, 90, this );
+ QIntValidator* aMinValidator = new QIntValidator( 0, 59, this );
+ QDoubleValidator* aSecValidator = new QDoubleValidator( 0, 59.9999, 4, this );
+
+ aPointXDeg->setValidator( aXDegValidator );
+ aPointYDeg->setValidator( aYDegValidator );
+ aPointXMin->setValidator( aMinValidator );
+ aPointYMin->setValidator( aMinValidator );
+ aPointXSec->setValidator( aSecValidator );
+ aPointYSec->setValidator( aSecValidator );
+
+ int aRow = 4 * aPointType;
+ aMappingLayout->addWidget( aPointBtn, aRow, 0, 1, 9 );
+
+ aMappingLayout->addWidget( aPointXLabel, aRow + 1, 0 );
+ aMappingLayout->addWidget( aPointX, aRow + 1, 1 );
+ aMappingLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 );
+ aMappingLayout->addWidget( aPointXDeg, aRow + 1, 3 );
+ aMappingLayout->addWidget( aPointXDegLabel, aRow + 1, 4 );
+ aMappingLayout->addWidget( aPointXMin, aRow + 1, 5 );
+ aMappingLayout->addWidget( aPointXMinLabel, aRow + 1, 6 );
+ aMappingLayout->addWidget( aPointXSec, aRow + 1, 7 );
+ aMappingLayout->addWidget( aPointXSecLabel, aRow + 1, 8 );
+
+ aMappingLayout->addWidget( aPointYLabel, aRow + 2, 0 );
+ aMappingLayout->addWidget( aPointY, aRow + 2, 1 );
+ aMappingLayout->addWidget( aPointYDeg, aRow + 2, 3 );
+ aMappingLayout->addWidget( aPointYDegLabel, aRow + 2, 4 );
+ aMappingLayout->addWidget( aPointYMin, aRow + 2, 5 );
+ aMappingLayout->addWidget( aPointYMinLabel, aRow + 2, 6 );
+ aMappingLayout->addWidget( aPointYSec, aRow + 2, 7 );
+ aMappingLayout->addWidget( aPointYSecLabel, aRow + 2, 8 );
if( aPointType != HYDROGUI_PrsImage::PointC )
{
QFrame* aLine = new QFrame( myMappingGroup );
aLine->setFrameShape( QFrame::HLine );
aLine->setFrameShadow( QFrame::Sunken );
- aMappingLayout->addWidget( aLine, aRow + 2, 0, 1, 5 );
+ aMappingLayout->addWidget( aLine, aRow + 3, 0, 1, 9 );
}
myPointBtnMap[ aPointType ] = aPointBtn;
- myPointX1Map[ aPointType ] = aPointX1;
- myPointY1Map[ aPointType ] = aPointY1;
- myPointX2Map[ aPointType ] = aPointX2;
- myPointY2Map[ aPointType ] = aPointY2;
+ myPointXMap[ aPointType ] = aPointX;
+ myPointYMap[ aPointType ] = aPointY;
+ myPointXDegMap[ aPointType ] = aPointXDeg;
+ myPointYDegMap[ aPointType ] = aPointYDeg;
+ myPointXMinMap[ aPointType ] = aPointXMin;
+ myPointYMinMap[ aPointType ] = aPointYMin;
+ myPointXSecMap[ aPointType ] = aPointXSec;
+ myPointYSecMap[ aPointType ] = aPointYSec;
connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) );
}
+ aMappingLayout->setColumnStretch( 1, 1 ); // x
+ aMappingLayout->setColumnStretch( 3, 1 ); // degrees
+ aMappingLayout->setColumnStretch( 5, 1 ); // minutes
+ aMappingLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
// Common
- addWidget( aFileGroup, 0, 0 );
- addWidget( myMappingGroup, 1, 0 );
-
- setRowStretch();
+ addWidget( myFileNameGroup );
+ addWidget( myImageNameGroup );
+ addWidget( myMappingGroup );
+ addStretch();
connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
}
{
}
+void HYDROGUI_ImportImageDlg::setIsEdit( const bool 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++ )
{
aBtn->setChecked( false );
aBtn->blockSignals( anIsBlocked );
- myPointX1Map[ aPointType ]->clear();
- myPointY1Map[ aPointType ]->clear();
- myPointX2Map[ aPointType ]->clear();
- myPointY2Map[ aPointType ]->clear();
+ myPointXMap[ aPointType ]->clear();
+ myPointYMap[ aPointType ]->clear();
+ myPointXDegMap[ aPointType ]->clear();
+ myPointYDegMap[ aPointType ]->clear();
+ myPointXMinMap[ aPointType ]->clear();
+ myPointYMinMap[ aPointType ]->clear();
+ myPointXSecMap[ aPointType ]->clear();
+ myPointYSecMap[ aPointType ]->clear();
}
myMappingGroup->setEnabled( false );
}
-void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap )
+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 )
{
for( int aPointType = HYDROGUI_PrsImage::PointA;
aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
if( theMap.contains( aPointType ) )
{
const TransformationData& aData = theMap[ aPointType ];
- myPointX1Map[ aPointType ]->setText( QString::number( aData.first.x() ) );
- myPointY1Map[ aPointType ]->setText( QString::number( aData.first.y() ) );
+ myPointXMap[ aPointType ]->setText( QString::number( aData.first.x() ) );
+ myPointYMap[ aPointType ]->setText( QString::number( aData.first.y() ) );
+
+ if( !theIsOnlyInput )
+ {
+ QPointF aPoint = aData.second;
+ int aXDeg = 0, aYDeg = 0;
+ int aXMin = 0, aYMin = 0;
+ double aXSec = 0, aYSec = 0;
+ HYDROGUI_Tool::DoubleToLambert( aPoint.x(), aXDeg, aXMin, aXSec );
+ HYDROGUI_Tool::DoubleToLambert( aPoint.y(), aYDeg, aYMin, aYSec );
+
+ myPointXDegMap[ aPointType ]->setText( QString::number( aXDeg ) );
+ myPointYDegMap[ aPointType ]->setText( QString::number( aYDeg ) );
+ myPointXMinMap[ aPointType ]->setText( QString::number( aXMin ) );
+ myPointYMinMap[ aPointType ]->setText( QString::number( aYMin ) );
+ myPointXSecMap[ aPointType ]->setText( QString::number( aXSec ) );
+ myPointYSecMap[ aPointType ]->setText( QString::number( aYSec ) );
+ }
}
}
}
for( int aPointType = HYDROGUI_PrsImage::PointA;
aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
{
- bool anIsOk = false;
- int aX1 = myPointX1Map[ aPointType ]->text().toInt( &anIsOk );
- if( !anIsOk )
- return false;
-
- anIsOk = false;
- int aY1 = myPointY1Map[ aPointType ]->text().toInt( &anIsOk );
- if( !anIsOk )
- return false;
-
- anIsOk = false;
- double aX2 = myPointX2Map[ aPointType ]->text().toDouble( &anIsOk );
- if( !anIsOk )
- return false;
-
- anIsOk = false;
- double aY2 = myPointY2Map[ aPointType ]->text().toDouble( &anIsOk );
- if( !anIsOk )
- return false;
+ bool anIsOk[8];
+ for( int i = 0; i < 8; i++ )
+ anIsOk[ i ] = false;
+
+ int aX1 = myPointXMap[ aPointType ]->text().toInt( &anIsOk[0] );
+ int aY1 = myPointYMap[ aPointType ]->text().toInt( &anIsOk[1] );
+ int aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] );
+ int aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] );
+ int aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] );
+ int aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] );
+ double aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] );
+ double aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] );
+
+ for( int i = 0; i < 8; i++ )
+ if( !anIsOk[ i ] )
+ return false;
+
+ double aX2 = 0, aY2 = 0;
+ HYDROGUI_Tool::LambertToDouble( aXDeg, aXMin, aXSec, aX2 );
+ HYDROGUI_Tool::LambertToDouble( aYDeg, aYMin, aYSec, aY2 );
TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ) );
theMap[ aPointType ] = aData;
void HYDROGUI_ImportImageDlg::initializePointSelection()
{
myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
-}
-void HYDROGUI_ImportImageDlg::synchronizeTransformedPoints()
-{
- for( int aPointType = HYDROGUI_PrsImage::PointA;
- aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
- {
- myPointX2Map[ aPointType ]->setText( myPointX1Map[ aPointType ]->text() );
- myPointY2Map[ aPointType ]->setText( myPointY1Map[ aPointType ]->text() );
- }
+ // ouv: tmp
+ myPointXDegMap[ HYDROGUI_PrsImage::PointA ]->setText( "50" );
+ myPointXMinMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+ myPointXSecMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+ myPointYDegMap[ HYDROGUI_PrsImage::PointA ]->setText( "50" );
+ myPointYMinMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+ myPointYSecMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+
+ myPointXDegMap[ HYDROGUI_PrsImage::PointB ]->setText( "50" );
+ myPointXMinMap[ HYDROGUI_PrsImage::PointB ]->setText( "1" );
+ myPointXSecMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" );
+ myPointYDegMap[ HYDROGUI_PrsImage::PointB ]->setText( "50" );
+ myPointYMinMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" );
+ myPointYSecMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" );
+
+ myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setText( "50" );
+ myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" );
+ myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" );
+ myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setText( "50" );
+ myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setText( "1" );
+ myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" );
}
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() )
{
- myFileName->setText( aFileName );
- emit createPreview( aFileName );
- myMappingGroup->setEnabled( true );
+ QImage anImage( aFileName );
+ if( !anImage.isNull() )
+ {
+ myFileName->setText( aFileName );
+ emit createPreview( anImage );
+ myImageNameGroup->setEnabled( true );
+ myMappingGroup->setEnabled( true );
+ }
}
}