From 2c7a183c127b169bf0d08c30d493d66f2bd8465f Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 9 Aug 2013 11:23:03 +0000 Subject: [PATCH] 1) Edit Image operation 2) Some minor fixes --- src/HYDROData/HYDROData_Image.cxx | 51 ++++- src/HYDROData/HYDROData_Image.h | 32 +++ src/HYDROGUI/CMakeLists.txt | 10 +- src/HYDROGUI/HYDROGUI_DataModel.cxx | 7 +- src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx | 237 +++++++++++++++------- src/HYDROGUI/HYDROGUI_ImportImageDlg.h | 20 +- src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 122 +++++++---- src/HYDROGUI/HYDROGUI_ImportImageOp.h | 11 +- src/HYDROGUI/HYDROGUI_Module.cxx | 19 +- src/HYDROGUI/HYDROGUI_Operations.cxx | 17 +- src/HYDROGUI/HYDROGUI_Operations.h | 7 +- src/HYDROGUI/HYDROGUI_PrsImage.cxx | 11 + src/HYDROGUI/HYDROGUI_PrsImage.h | 2 + src/HYDROGUI/HYDROGUI_Tool.cxx | 55 +++++ src/HYDROGUI/HYDROGUI_Tool.h | 32 ++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 30 ++- 16 files changed, 511 insertions(+), 152 deletions(-) diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 0d1da676..8fe96f68 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -9,8 +9,12 @@ #include #include -// tage of the child of my label that contains information about the operator -static const int TAG_OPERATOR = 1; +// tag of the child of my label that contains information about the operator +static const int TAG_OPERATOR = 1; + +// tag of the child of my label that contains information transformation points +static const int TAG_TRSF_POINTS = 2; + static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000"); IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object) @@ -92,6 +96,49 @@ QTransform HYDROData_Image::Trsf() return aTrsf; } +void HYDROData_Image::SetTrsfPoints(const QPoint& thePointAIn, + const QPoint& thePointBIn, + const QPoint& thePointCIn, + const QPointF& thePointAOut, + const QPointF& thePointBOut, + const QPointF& thePointCOut) +{ + Handle(TDataStd_RealArray) anArray; + if (!myLab.FindChild(TAG_TRSF_POINTS).FindAttribute(TDataStd_RealArray::GetID(), anArray)) { + anArray = TDataStd_RealArray::Set(myLab.FindChild(TAG_TRSF_POINTS), 1, 12); + } + anArray->SetValue(1, thePointAIn.x()); + anArray->SetValue(2, thePointAIn.y()); + anArray->SetValue(3, thePointBIn.x()); + anArray->SetValue(4, thePointBIn.y()); + anArray->SetValue(5, thePointCIn.x()); + anArray->SetValue(6, thePointCIn.y()); + anArray->SetValue(7, thePointAOut.x()); + anArray->SetValue(8, thePointAOut.y()); + anArray->SetValue(9, thePointBOut.x()); + anArray->SetValue(10, thePointBOut.y()); + anArray->SetValue(11, thePointCOut.x()); + anArray->SetValue(12, thePointCOut.y()); +} + +void HYDROData_Image::TrsfPoints(QPoint& thePointAIn, + QPoint& thePointBIn, + QPoint& thePointCIn, + QPointF& thePointAOut, + QPointF& thePointBOut, + QPointF& thePointCOut) +{ + Handle(TDataStd_RealArray) anArray; + if (myLab.FindChild(TAG_TRSF_POINTS).FindAttribute(TDataStd_RealArray::GetID(), anArray)) { + thePointAIn = QPointF( anArray->Value(1), anArray->Value(2) ).toPoint(); + thePointBIn = QPointF( anArray->Value(3), anArray->Value(4) ).toPoint(); + thePointCIn = QPointF( anArray->Value(5), anArray->Value(6) ).toPoint(); + thePointAOut = QPointF( anArray->Value(7), anArray->Value(8) ); + thePointBOut = QPointF( anArray->Value(9), anArray->Value(10) ); + thePointCOut = QPointF( anArray->Value(11), anArray->Value(12) ); + } +} + void HYDROData_Image::AppendReference(Handle(HYDROData_Image) theReferenced) { Handle(TDataStd_ReferenceList) aRefs; diff --git a/src/HYDROData/HYDROData_Image.h b/src/HYDROData/HYDROData_Image.h index 167d8b54..dda1648b 100644 --- a/src/HYDROData/HYDROData_Image.h +++ b/src/HYDROData/HYDROData_Image.h @@ -46,6 +46,38 @@ public: */ HYDRODATA_EXPORT QTransform Trsf(); + /** + * Stores the image transformation points (3 input + 3 output) + * \param thePointAIn input point A + * \param thePointBIn input point B + * \param thePointCIn input point C + * \param thePointAOut output point A + * \param thePointBOut output point B + * \param thePointCOut output point C + */ + HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointAIn, + const QPoint& thePointBIn, + const QPoint& thePointCIn, + const QPointF& thePointAOut, + const QPointF& thePointBOut, + const QPointF& thePointCOut); + + /** + * Returns the image transformation points (3 input + 3 output) + * \param thePointAIn input point A + * \param thePointBIn input point B + * \param thePointCIn input point C + * \param thePointAOut output point A + * \param thePointBOut output point B + * \param thePointCOut output point C + */ + HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointAIn, + QPoint& thePointBIn, + QPoint& thePointCIn, + QPointF& thePointAOut, + QPointF& thePointBOut, + QPointF& thePointCOut); + /** * Appends reference to other image. * \param theReferenced the image referenced by this diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index f5cc14cf..4595c918 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -10,13 +10,13 @@ set(PROJECT_HEADERS HYDROGUI_GVSelector.h HYDROGUI_ImportImageDlg.h HYDROGUI_ImportImageOp.h - HYDROGUI_PolylineOp.h - HYDROGUI_PolylineDlg.h HYDROGUI_InputPanel.h HYDROGUI_Module.h HYDROGUI_ObjSelector.h HYDROGUI_Operation.h HYDROGUI_Operations.h + HYDROGUI_PolylineDlg.h + HYDROGUI_PolylineOp.h HYDROGUI_Prs.h HYDROGUI_PrsDriver.h HYDROGUI_PrsImage.h @@ -38,20 +38,20 @@ set(PROJECT_SOURCES HYDROGUI_GVSelector.cxx HYDROGUI_ImportImageDlg.cxx HYDROGUI_ImportImageOp.cxx - HYDROGUI_PolylineDlg.cxx - HYDROGUI_PolylineOp.cxx HYDROGUI_InputPanel.cxx HYDROGUI_Module.cxx HYDROGUI_ObjSelector.cxx HYDROGUI_Operation.cxx HYDROGUI_Operations.cxx - HYDROGUI_TwoImagesDlg.cxx + HYDROGUI_PolylineDlg.cxx + HYDROGUI_PolylineOp.cxx HYDROGUI_Prs.cxx HYDROGUI_PrsDriver.cxx HYDROGUI_PrsImage.cxx HYDROGUI_PrsImageDriver.cxx HYDROGUI_PrsImageFrame.cxx HYDROGUI_Tool.cxx + HYDROGUI_TwoImagesDlg.cxx HYDROGUI_TwoImagesOp.cxx ) diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 4108df40..461b493c 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -197,11 +198,11 @@ void HYDROGUI_DataModel::update( const int theStudyId ) LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, "POLYLINES" ); - HYDROData_Iterator aPolyIterator( aDocument, KIND_IMAGE ); + HYDROData_Iterator aPolyIterator( aDocument, KIND_POLYLINE ); for( ; aPolyIterator.More(); aPolyIterator.Next() ) { - Handle(HYDROData_Image) aPolylineObj = - Handle(HYDROData_Image)::DownCast( anIterator.Current() ); + Handle(HYDROData_Polyline) aPolylineObj = + Handle(HYDROData_Polyline)::DownCast( anIterator.Current() ); if( !aPolylineObj.IsNull() ) createObject( aPolylineRootObj, aPolylineObj ); } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index b8f1ddeb..7a5d089e 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_ImportImageDlg.h" #include "HYDROGUI_PrsImage.h" +#include "HYDROGUI_Tool.h" #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -44,17 +46,17 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); // Import image from file - QGroupBox* aFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) ); + myFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) ); - QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileGroup ); + QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileGroup ); - myFileName = new QLineEdit( aFileGroup ); + myFileName = new QLineEdit( myFileGroup ); myFileName->setReadOnly( true ); - QToolButton* aBrowseBtn = new QToolButton( aFileGroup ); + QToolButton* aBrowseBtn = new QToolButton( myFileGroup ); aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); - QBoxLayout* aFileLayout = new QHBoxLayout( aFileGroup ); + QBoxLayout* aFileLayout = new QHBoxLayout( myFileGroup ); aFileLayout->setMargin( 5 ); aFileLayout->setSpacing( 5 ); aFileLayout->addWidget( aFileNameLabel ); @@ -85,62 +87,101 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co 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( myFileGroup, 0, 0 ); addWidget( myMappingGroup, 1, 0 ); setRowStretch(); @@ -152,6 +193,12 @@ HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg() { } +void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit ) +{ + myFileGroup->setVisible( !theIsEdit ); + myMappingGroup->setEnabled( theIsEdit ); +} + void HYDROGUI_ImportImageDlg::reset() { myFileName->clear(); @@ -163,15 +210,20 @@ void HYDROGUI_ImportImageDlg::reset() 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::setTransformationDataMap( const TransformationDataMap& theMap, + const bool theIsOnlyInput ) { for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) @@ -179,8 +231,25 @@ void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationData 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 ) ); + } } } } @@ -191,25 +260,26 @@ bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& t 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; @@ -220,27 +290,44 @@ bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& t 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 ); + //QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter ); + QString aFileName = "W:/Work/HYDRO/doc/samples/1.bmp"; if( !aFileName.isEmpty() ) { - myFileName->setText( aFileName ); - emit createPreview( aFileName ); - myMappingGroup->setEnabled( true ); + QImage anImage( aFileName ); + if( !anImage.isNull() ) + { + myFileName->setText( aFileName ); + emit createPreview( anImage ); + myMappingGroup->setEnabled( true ); + } } } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h index 49efc9ec..a1dcbda5 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h @@ -42,31 +42,37 @@ public: HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_ImportImageDlg(); + void setIsEdit( const bool theIsEdit ); void reset(); - void setTransformationDataMap( const TransformationDataMap& theMap ); + void setTransformationDataMap( const TransformationDataMap& theMap, + const bool theIsOnlyInput = false ); bool getTransformationDataMap( TransformationDataMap& theMap ) const; void initializePointSelection(); - void synchronizeTransformedPoints(); protected slots: void onBrowse(); void onPointBtnToggled( bool ); signals: - void createPreview( QString ); + void createPreview( QImage ); void activatePointSelection( int ); private: + QGroupBox* myFileGroup; QLineEdit* myFileName; QGroupBox* myMappingGroup; QMap myPointBtnMap; - QMap myPointX1Map; - QMap myPointY1Map; - QMap myPointX2Map; - QMap myPointY2Map; + QMap myPointXMap; + QMap myPointYMap; + QMap myPointXDegMap; + QMap myPointYDegMap; + QMap myPointXMinMap; + QMap myPointYMinMap; + QMap myPointXSecMap; + QMap myPointYSecMap; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 21ab2da2..2ab7cec6 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -22,13 +22,14 @@ #include "HYDROGUI_ImportImageOp.h" +#include "HYDROGUI_DataModel.h" #include "HYDROGUI_ImportImageDlg.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_PrsImage.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" #include -#include #include #include @@ -37,14 +38,17 @@ #include #include -HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule ) +HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule, + const bool theIsEdit ) : HYDROGUI_Operation( theModule ), + myIsEdit( theIsEdit ), + myEditedObject( 0 ), myActiveViewManager( 0 ), myPreviewViewManager( 0 ), myPreviewPrs( 0 ), myPointType( HYDROGUI_PrsImage::None ) { - setName( tr( "IMPORT_IMAGE" ) ); + setName( theIsEdit ? tr( "EDIT_IMAGE" ) : tr( "IMPORT_IMAGE" ) ); } HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp() @@ -57,13 +61,52 @@ void HYDROGUI_ImportImageOp::startOperation() HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); aPanel->reset(); + aPanel->setIsEdit( myIsEdit ); + + if( myIsEdit ) + { + myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !myEditedObject.IsNull() ) + { + QImage anImage = myEditedObject->Image(); + + QPoint aPointA1, aPointB1, aPointC1; + QPointF aPointA2, aPointB2, aPointC2; + myEditedObject->TrsfPoints( aPointA1, aPointB1, aPointC1, + aPointA2, aPointB2, aPointC2 ); + + onCreatePreview( anImage ); + + if( myPreviewPrs ) + { + HYDROGUI_PrsImage::TransformationPointMap aPointMap = + myPreviewPrs->getTransformationPointMap(); + if( !aPointMap.isEmpty() ) + { + aPointMap[ HYDROGUI_PrsImage::PointA ].Point = aPointA1; + aPointMap[ HYDROGUI_PrsImage::PointB ].Point = aPointB1; + aPointMap[ HYDROGUI_PrsImage::PointC ].Point = aPointC1; + myPreviewPrs->setTransformationPointMap( aPointMap ); + } + } + + HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap; + aDataMap[ HYDROGUI_PrsImage::PointA ] = + HYDROGUI_ImportImageDlg::TransformationData( aPointA1, aPointA2 ); + aDataMap[ HYDROGUI_PrsImage::PointB ] = + HYDROGUI_ImportImageDlg::TransformationData( aPointB1, aPointB2 ); + aDataMap[ HYDROGUI_PrsImage::PointC ] = + HYDROGUI_ImportImageDlg::TransformationData( aPointC1, aPointC2 ); + ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap ); + } + } } HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const { HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() ); - connect( aPanel, SIGNAL( createPreview( QString ) ), - this, SLOT( onCreatePreview( QString ) ) ); + connect( aPanel, SIGNAL( createPreview( QImage ) ), + this, SLOT( onCreatePreview( QImage ) ) ); connect( aPanel, SIGNAL( activatePointSelection( int ) ), this, SLOT( onActivatePointSelection( int ) ) ); return aPanel; @@ -78,19 +121,27 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags ) if( !anIsOk || !myPreviewPrs ) return false; - double xa1 = aMap[ HYDROGUI_PrsImage::PointA ].first.x(); - double ya1 = aMap[ HYDROGUI_PrsImage::PointA ].first.y(); - double xb1 = aMap[ HYDROGUI_PrsImage::PointB ].first.x(); - double yb1 = aMap[ HYDROGUI_PrsImage::PointB ].first.y(); - double xc1 = aMap[ HYDROGUI_PrsImage::PointC ].first.x(); - double yc1 = aMap[ HYDROGUI_PrsImage::PointC ].first.y(); + QPoint aPointA1 = aMap[ HYDROGUI_PrsImage::PointA ].first; + QPoint aPointB1 = aMap[ HYDROGUI_PrsImage::PointB ].first; + QPoint aPointC1 = aMap[ HYDROGUI_PrsImage::PointC ].first; - double xa2 = aMap[ HYDROGUI_PrsImage::PointA ].second.x(); - double ya2 = aMap[ HYDROGUI_PrsImage::PointA ].second.y(); - double xb2 = aMap[ HYDROGUI_PrsImage::PointB ].second.x(); - double yb2 = aMap[ HYDROGUI_PrsImage::PointB ].second.y(); - double xc2 = aMap[ HYDROGUI_PrsImage::PointC ].second.x(); - double yc2 = aMap[ HYDROGUI_PrsImage::PointC ].second.y(); + QPointF aPointA2 = aMap[ HYDROGUI_PrsImage::PointA ].second; + QPointF aPointB2 = aMap[ HYDROGUI_PrsImage::PointB ].second; + QPointF aPointC2 = aMap[ HYDROGUI_PrsImage::PointC ].second; + + double xa1 = aPointA1.x(); + double ya1 = aPointA1.y(); + double xb1 = aPointB1.x(); + double yb1 = aPointB1.y(); + double xc1 = aPointC1.x(); + double yc1 = aPointC1.y(); + + double xa2 = aPointA2.x(); + double ya2 = aPointA2.y(); + double xb2 = aPointB2.x(); + double yb2 = aPointB2.y(); + double xc2 = aPointC2.x(); + double yc2 = aPointC2.y(); QTransform aTransform1( xa1, ya1, 1, xb1, yb1, 1, xc1, yc1, 1 ); QTransform aTransform2( xa2, ya2, 1, xb2, yb2, 1, xc2, yc2, 1 ); @@ -101,24 +152,30 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags ) closePreview(); - int aStudyId = module()->getStudyId(); - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); - if( aDocument.IsNull() ) - return false; + Handle(HYDROData_Image) anImageObj; + if( myIsEdit ) + anImageObj = myEditedObject; + else + anImageObj = Handle(HYDROData_Image)::DownCast( doc()->CreateObject( KIND_IMAGE ) ); - Handle(HYDROData_Image) anImageObj = - Handle(HYDROData_Image)::DownCast( aDocument->CreateObject( KIND_IMAGE ) ); if( anImageObj.IsNull() ) return false; - static int ImageId = 0; - anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) ); + if( !myIsEdit ) + { + static int ImageId = 0; + anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) ); + } anImageObj->SetImage( anImage ); anImageObj->SetTrsf( aTransform ); + + anImageObj->SetTrsfPoints( aPointA1, aPointB1, aPointC1, + aPointA2, aPointB2, aPointC2 ); + anImageObj->SetVisibility( true ); - theUpdateFlags = UF_Model | UF_Viewer; + theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced; return true; } @@ -127,17 +184,14 @@ void HYDROGUI_ImportImageOp::processCancel() closePreview(); } -void HYDROGUI_ImportImageOp::onCreatePreview( QString theFileName ) +void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) { LightApp_Application* anApp = module()->getApp(); myActiveViewManager = anApp->activeViewManager(); - myPreviewPrs = new HYDROGUI_PrsImage( 0 ); // no data object - - QImage anImage( theFileName ); - myPreviewPrs->setImage( anImage ); - + myPreviewPrs = new HYDROGUI_PrsImage( myIsEdit ? myEditedObject : 0 ); + myPreviewPrs->setImage( theImage ); myPreviewPrs->compute(); myPreviewViewManager = @@ -165,8 +219,6 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QString theFileName ) aPanel->initializePointSelection(); onPointSelected(); - - aPanel->synchronizeTransformedPoints(); } void HYDROGUI_ImportImageOp::onActivatePointSelection( int thePointType ) @@ -193,7 +245,7 @@ void HYDROGUI_ImportImageOp::onPointSelected() aDataMap[ aPointType ] = aData; } - ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap ); + ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap, true ); } void HYDROGUI_ImportImageOp::closePreview() diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index 04a0f704..bdb58867 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -25,6 +25,10 @@ #include "HYDROGUI_Operation.h" +#include + +#include + class GraphicsView_ViewManager; class SUIT_ViewManager; @@ -36,7 +40,7 @@ class HYDROGUI_ImportImageOp : public HYDROGUI_Operation Q_OBJECT public: - HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule ); + HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule, const bool theIsEdit ); virtual ~HYDROGUI_ImportImageOp(); protected: @@ -48,7 +52,7 @@ protected: virtual void processCancel(); protected slots: - void onCreatePreview( QString ); + void onCreatePreview( QImage ); void onActivatePointSelection( int ); void onPointSelected(); @@ -56,6 +60,9 @@ private: void closePreview(); private: + bool myIsEdit; + Handle(HYDROData_Image) myEditedObject; + SUIT_ViewManager* myActiveViewManager; GraphicsView_ViewManager* myPreviewViewManager; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index aaefcdfb..9a377428 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -141,6 +141,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsVisibleInSelection = false; bool anIsHiddenInSelection = false; + bool anIsImage = false; + foreach( SUIT_DataOwner* aSUITOwner, anOwners ) { if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) @@ -148,14 +150,24 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() ); if( !anObject.IsNull() ) { + anIsSelection = true; + bool aVisibility = anObject->GetVisibility(); anIsVisibleInSelection |= aVisibility; anIsHiddenInSelection |= !aVisibility; - anIsSelection = true; + + if( anObject->GetKind() == KIND_IMAGE ) + anIsImage = true; } } } + if( anOwners.count() == 1 && anIsImage ) + { + theMenu->addAction( action( EditImageId ) ); + theMenu->addSeparator(); + } + if( anIsSelection ) { theMenu->addAction( action( DeleteId ) ); @@ -262,7 +274,7 @@ void HYDROGUI_Module::customEvent( QEvent* e ) { if( GraphicsView_Viewer* aViewer = dynamic_cast( aViewFrame->getViewer() ) ) { - update( UF_Viewer | UF_GV_Forced ); + //update( UF_Viewer | UF_GV_Forced ); // ouv: to do aViewer->activateTransform( GraphicsView_Viewer::FitAll ); if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) @@ -270,6 +282,9 @@ void HYDROGUI_Module::customEvent( QEvent* e ) aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect ); aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu ); aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection ); + + // ouv: tmp + aViewPort->setMousePositionEnabled( true ); } } } diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 76724404..5913dd23 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -26,9 +26,9 @@ #include "HYDROGUI_DeleteOp.h" #include "HYDROGUI_ImportImageOp.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_PolylineOp.h" #include "HYDROGUI_ShowHideOp.h" #include "HYDROGUI_TwoImagesOp.h" -#include "HYDROGUI_PolylineOp.h" #include "HYDROGUI_UpdateFlags.h" #include @@ -63,11 +63,11 @@ QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffi void HYDROGUI_Module::createActions() { createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); - createAction( FuseId, "FUSE_IMAGES" ); - createAction( CutId, "CUT_IMAGES" ); - + createAction( EditImageId, "EDIT_IMAGE" ); createAction( PolylineId, "POLYLINE" ); + createAction( FuseId, "FUSE_IMAGES" ); + createAction( CutId, "CUT_IMAGES" ); createAction( DeleteId, "DELETE", "", Qt::Key_Delete ); @@ -87,9 +87,9 @@ void HYDROGUI_Module::createMenus() int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu ); createMenu( ImportImageId, aHydroId, -1, -1 ); + createMenu( PolylineId, aHydroId, -1, -1 ); createMenu( FuseId, aHydroId, -1, -1 ); createMenu( CutId, aHydroId, -1, -1 ); - createMenu( PolylineId, aHydroId, -1, -1 ); } void HYDROGUI_Module::createPopups() @@ -203,8 +203,11 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const switch( theId ) { case ImportImageId: - anOp = new HYDROGUI_ImportImageOp( aModule ); + case EditImageId: + anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId ); break; + case PolylineId: + anOp = new HYDROGUI_PolylineOp( aModule ); case FuseId: anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse ); break; @@ -221,8 +224,6 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case HideAllId: anOp = new HYDROGUI_ShowHideOp( aModule, theId ); break; - case PolylineId: - anOp = new HYDROGUI_PolylineOp( aModule ); } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 632b0261..22eca2ed 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -26,22 +26,19 @@ enum OperationId { FirstId = 0, - UndoId, RedoId, - ImportImageId, + EditImageId, + PolylineId, FuseId, CutId, - DeleteId, - ShowId, ShowOnlyId, ShowAllId, HideId, HideAllId, - PolylineId, }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index fa75c25e..d92d0e37 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -109,6 +109,17 @@ void HYDROGUI_PrsImage::setTransformationPointMode( const int theMode ) computeTransformationPoints(); } +//================================================================ +// Function : setTransformationPointMap +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setTransformationPointMap( const TransformationPointMap& theMap ) +{ + myTransformationPointMap = theMap; + if( !theMap.isEmpty() ) + computeTransformationPoints(); +} + //================================================================ // Function : boundingRect // Purpose : diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h index 8f385185..651c787c 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.h +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -57,6 +57,8 @@ public: bool getIsTransformationPointPreview() const; void setTransformationPointMode( const int theMode ); + + void setTransformationPointMap( const TransformationPointMap& theMap ); const TransformationPointMap& getTransformationPointMap() const { return myTransformationPointMap; } public: diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 28072d7c..dbe77659 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -31,6 +31,8 @@ #include #include +#include +#include #include @@ -126,6 +128,29 @@ Handle(TCollection_HExtendedString) HYDROGUI_Tool::ToHExtString( const QString& return new TCollection_HExtendedString( ToExtString( src ) ); } +void HYDROGUI_Tool::LambertToDouble( const int theDegrees, + const int theMinutes, + const double theSeconds, + double& theCoord ) +{ + // ouv: check the case of negative degrees + theCoord = theDegrees * 3600 + theMinutes * 60 + theSeconds; +} + +void HYDROGUI_Tool::DoubleToLambert( const double theCoord, + int& theDegrees, + int& theMinutes, + double& theSeconds ) +{ + // ouv: check the case of negative degrees + theDegrees = int( theCoord / 3600 ); + + double aRemainder = theCoord - theDegrees * 3600; + theMinutes = int( aRemainder / 60 ); + + theSeconds = aRemainder - theMinutes * 60; +} + void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule, SUIT_ViewManager* theViewManager ) { @@ -190,3 +215,33 @@ GraphicsView_ObjectList HYDROGUI_Tool::GetPrsList( GraphicsView_ViewPort* theVie } return aList; } + +HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module* theModule ) +{ + HYDROData_SequenceOfObjects aSeq; + + HYDROGUI_DataModel* aModel = theModule->getDataModel(); + + SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr(); + SUIT_DataOwnerPtrList anOwners; + aSelectionMgr->selected( anOwners ); + + foreach( SUIT_DataOwner* aSUITOwner, anOwners ) + { + if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) + { + Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry(), KIND_UNKNOWN ); + if( !anObject.IsNull() ) + aSeq.Append( anObject ); + } + } + return aSeq; +} + +Handle(HYDROData_Object) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theModule ) +{ + HYDROData_SequenceOfObjects aSeq = GetSelectedObjects( theModule ); + if( !aSeq.IsEmpty() ) + return aSeq.First(); + return NULL; +} diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index 41d7fe2f..dc2427b7 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -86,6 +86,22 @@ public: */ static Handle(TCollection_HExtendedString) ToHExtString( const QString& ); + /** + * \brief Encode the Lambert93 coordinates to the absolute double value + */ + static void LambertToDouble( const int theDegrees, + const int theMinutes, + const double theSeconds, + double& theCoord ); + + /** + * \brief Decode the Lambert93 coordinates from the absolute double value + */ + static void DoubleToLambert( const double theCoord, + int& theDegrees, + int& theMinutes, + double& theSeconds ); + /** * \brief Set the specified view manager to be active on the desktop. * \param theModule module @@ -114,11 +130,25 @@ public: const GraphicsView_ObjectList& theObjects ); /** - * \brief Get list of HYDRO presentations from the specified viewport + * \brief Get list of HYDRO presentations from the specified viewport. * \param theViewPort viewport * \return list of HYDRO presentations */ static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort ); + + /** + * \brief Get list of the selected data objects. + * \param theModule module + * \return list of the selected data objects + */ + static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule ); + + /** + * \brief Get the selected data object (first in the selected list). + * \param theModule module + * \return selected data object + */ + static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule ); }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 46403e91..3fe2979d 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -75,20 +75,24 @@ Mapping - POINT_A - Point A + ACTIVATE_POINT_A_SELECTION + Activate point A selection - POINT_B - Point B + ACTIVATE_POINT_B_SELECTION + Activate point B selection - POINT_C - Point C + ACTIVATE_POINT_C_SELECTION + Activate point C selection HYDROGUI_ImportImageOp + + EDIT_IMAGE + Edit image + IMPORT_IMAGE Import image @@ -108,6 +112,10 @@ DSK_DELETE Delete + + DSK_EDIT_IMAGE + Edit image + DSK_FUSE_IMAGES Fuse images @@ -164,6 +172,10 @@ MEN_DESK_HYDRO HYDRO + + MEN_EDIT_IMAGE + Edit image + MEN_FUSE_IMAGES Fuse images @@ -212,6 +224,10 @@ STB_DELETE Delete + + STB_EDIT_IMAGE + Edit image + STB_FUSE_IMAGES Fuse images @@ -229,7 +245,7 @@ Import image - STB_IMPORT_IMAGE + STB_POLYLINE Create polyline -- 2.39.2