#include "HYDROGUI_Tool.h"
#include <HYDROData_Lambert93.h>
+#include <HYDROData_Image.h>
#include <SUIT_FileDlg.h>
#include <SUIT_ResourceMgr.h>
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* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_CARTESIAN" ), myTransformGroup );
- QRadioButton* aManualLambertBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), 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( aManualCartesianBtn, ManualCartesian );
- myModeGroup->addButton( aManualLambertBtn, ManualLambert );
- 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( aManualCartesianBtn, 0, 0 );
- aModeLayout->addWidget( aManualLambertBtn, 1, 0 );
+ aModeLayout->addWidget( aManualLambertBtn, 0, 0 );
+ aModeLayout->addWidget( aManualCartesianBtn, 1, 0 );
aModeLayout->addWidget( aRefImageBtn, 2, 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( "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 );
connect( myRefImage, SIGNAL( activated( const QString& ) ),
this, SLOT( onRefImageActivated( const QString& ) ) );
- setTransformationMode( ManualLambert );
+ setTransformationMode( HYDROData_Image::ManualLambert );
setMinimumWidth( 350 );
}
HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
{
- delete myFileNameGroup;
- delete myImageNameGroup;
- delete myTransformGroup;
}
void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
myTransformGroup->setEnabled( false );
myRefImage->clear();
- setTransformationMode( ManualLambert );
+ 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 );