#include "HYDROGUI_Tool.h"
#include <HYDROData_Lambert93.h>
+#include <HYDROData_Image.h>
#include <SUIT_FileDlg.h>
#include <SUIT_ResourceMgr.h>
#include <QPushButton>
#include <QRadioButton>
#include <QToolButton>
+#include <QCheckBox>
HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle )
: HYDROGUI_InputPanel( theModule, theTitle ),
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 );
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 );
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" ) );
aPainter.drawPixmap( 0, 0, anArrowPixmap );
aPainter.end();
- QRadioButton* aManualLambertBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), myTransformGroup );
- QRadioButton* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_CARTESIAN" ), myTransformGroup );
+ QRadioButton* aManualLambertBtn = new QRadioButton( tr( "MANUALLY_GEODESIC" ), myTransformGroup );
+ QRadioButton* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), myTransformGroup );
QRadioButton* aRefImageBtn = new QRadioButton( tr( "BY_REFERENCE_IMAGE" ), myTransformGroup );
myModeGroup = new QButtonGroup( myTransformGroup );
- myModeGroup->addButton( aManualLambertBtn, ManualLambert );
- myModeGroup->addButton( aManualCartesianBtn, ManualCartesian );
- myModeGroup->addButton( aRefImageBtn, RefImage );
+ myModeGroup->addButton( aManualLambertBtn, HYDROData_Image::ManualLambert );
+ myModeGroup->addButton( aManualCartesianBtn, HYDROData_Image::ManualCartesian );
+ myModeGroup->addButton( aRefImageBtn, HYDROData_Image::ReferenceImage );
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( aManualLambertBtn, 0, 0 );
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( 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 );
+ aTransformLayout->addWidget( aLambertLabel, 2, 3, 1, 6 );
+ aTransformLayout->addWidget( aRefImageLabel, 2, 3, 1, 6 );
+
+ connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setVisible ( bool ) ) );
+ connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) );
+ connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) );
+ connect( aManualLambertBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setVisible ( bool ) ) );
+ connect( aManualLambertBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) );
+ connect( aManualLambertBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) );
+ connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setVisible ( bool ) ) );
+ connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) );
+ connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) );
+
for( int aPointType = HYDROGUI_PrsImage::PointA;
aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
{
QtxIntSpinBox* aRefPointX = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later
QtxIntSpinBox* aRefPointY = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later
- int aRow = 4 * aPointType + 2;
- aTransformLayout->addWidget( aPointBtn, aRow, 0, 1, 9 );
+ int aRow = 4 * aPointType + 3;
+ if ( aPointType == HYDROGUI_PrsImage::PointC )
+ {
+ myPointCEnabler = new QCheckBox( myTransformGroup );
+ aTransformLayout->addWidget( myPointCEnabler, aRow, 0, 1, 2, Qt::AlignHCenter );
+ aTransformLayout->addWidget( aPointBtn, aRow, 2, 1, 7 );
+ }
+ else
+ {
+ aTransformLayout->addWidget( aPointBtn, aRow, 0, 1, 9 );
+ }
aTransformLayout->addWidget( aPointXLabel, aRow + 1, 0 );
aTransformLayout->addWidget( aPointX, aRow + 1, 1 );
connect( aRefPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
connect( aRefPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
}
+
+ // Connect checkbox enabling point C
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointBtnMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+ connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
+
aTransformLayout->setColumnStretch( 1, 1 ); // double
aTransformLayout->setColumnStretch( 3, 1 ); // degrees
aTransformLayout->setColumnStretch( 5, 1 ); // minutes
connect( myRefImage, SIGNAL( activated( const QString& ) ),
this, SLOT( onRefImageActivated( const QString& ) ) );
- setTransformationMode( ManualLambert );
+ setTransformationMode( HYDROData_Image::ManualLambert );
setMinimumWidth( 350 );
}
myCartPointXMap[ aPointType ]->clear();
myCartPointYMap[ aPointType ]->clear();
}
+ myPointCEnabler->setChecked( true );
+ myPointCEnabler->toggle();
myTransformGroup->setEnabled( false );
myRefImage->clear();
- setTransformationMode( ManualCartesian );
+ setTransformationMode( HYDROData_Image::ManualLambert );
myPrsPointDataList.clear();
return myImageName->text();
}
+void HYDROGUI_ImportImageDlg::setRefImageName( const QString& theName )
+{
+ myRefImage->setCurrentIndex( myRefImage->findText( theName ) );
+}
+
+QString HYDROGUI_ImportImageDlg::getRefImageName() const
+{
+ return myRefImage->currentText();
+}
+
QString HYDROGUI_ImportImageDlg::getFileName() const
{
return myFileName->text();
return myModeGroup->checkedId();
}
+void HYDROGUI_ImportImageDlg::setByTwoPoints( const bool theIsByTwoPoints )
+{
+ myPointCEnabler->setChecked( !theIsByTwoPoints );
+}
+
+bool HYDROGUI_ImportImageDlg::isByTwoPoints() const
+{
+ return !myPointCEnabler->isChecked();
+}
+
void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
const bool theIsOnlyInput,
const bool theIsRefImage )
return true;
}
-QString HYDROGUI_ImportImageDlg::getRefImageName() const
-{
- return myRefImage->currentText();
-}
-
void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList )
{
myPrsPointDataList = theList;
if( !myPrsPointDataList.isEmpty() )
{
- myModeGroup->button( RefImage )->setEnabled( true );
+ myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( true );
myRefImage->clear();
myRefImage->addItem( "" ); // first empty item
myRefImage->addItem( anIter.next().first );
}
else
- myModeGroup->button( RefImage )->setEnabled( false );
+ myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( false );
}
void HYDROGUI_ImportImageDlg::initializePointSelection()
blockSignalsCartesian( false );
}
+HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
+ const int theMode,
+ const QPoint& theLocalPoint,
+ const QPointF& theGlobalPoint )
+{
+ TransformationData aResTrsfData;
+ aResTrsfData.ImagePoint = theLocalPoint;
+
+ double arx = theGlobalPoint.x();
+ double ary = theGlobalPoint.y();
+ if ( theMode == HYDROData_Image::ManualLambert )
+ {
+ // Lambert to Cartesian
+ double aXCart = 0, aYCart = 0;
+ HYDROData_Lambert93::toXY( arx, ary, aXCart, aYCart );
+
+ aResTrsfData.LambertPoint = theGlobalPoint;
+ aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart );
+ }
+ else if ( theMode == HYDROData_Image::ManualCartesian )
+ {
+ // Cartesian to Lambert
+ double aLonDeg = 0, aLatDeg = 0;
+ HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg );
+
+ aResTrsfData.CartesianPoint = theGlobalPoint;
+ aResTrsfData.LambertPoint = QPointF( aLonDeg, aLatDeg );
+ }
+
+ return aResTrsfData;
+}
+
void HYDROGUI_ImportImageDlg::onBrowse()
{
QString aFilter( tr( "IMAGE_FILTER" ) );
void HYDROGUI_ImportImageDlg::onModeActivated( int theMode )
{
- bool anIsManualLambert = theMode == ManualLambert;
- bool anIsManualCartesian = theMode == ManualCartesian;
- bool anIsRefImage = theMode == RefImage;
+ bool anIsManualLambert = theMode == HYDROData_Image::ManualLambert;
+ bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian;
+ bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage;
myRefImage->setEnabled( anIsRefImage );