28 #include "../Exception.h" 29 #include "../canvas/MapDisplay.h" 30 #include "../canvas/Canvas.h" 31 #include "../../widgets/tools/ZoomLeftAndRightClick.h" 32 #include "../../widgets/tools/CoordTracking.h" 33 #include "../../../raster/Grid.h" 34 #include "../../../geometry/GTFactory.h" 35 #include "../../../geometry/Point.h" 36 #include "../../../geometry/Envelope.h" 37 #include "../../../maptools/Utils.h" 38 #include "../../../rp/TiePointsLocator.h" 40 #include <ui_TiePointsLocatorForm.h> 42 #include <QtCore/QString> 43 #include <QGridLayout> 48 #define TPLDIALOG_P_PATTERN_W 11 58 :
QObject( parent ), m_mDisplay( parent )
68 if( event->type() == QEvent::Enter )
72 else if( event->type() == QEvent::Leave )
76 else if( event->type() == QEvent::KeyPress )
80 emit(
keyPressed( ((QKeyEvent*)event)->key() ) );
88 : m_acqType( InvalidAcquisitionT )
111 QWidget* parent, Qt::WindowFlags f )
118 if( inLayer1Ptr.get() == nullptr )
throw te::qt::widgets::Exception(
119 "Invalid data set layer pointer" );
120 if( inLayer1Ptr.get() == nullptr )
throw te::qt::widgets::Exception(
121 "Invalid data set layer pointer" );
123 m_uiPtr =
new Ui::TiePointsLocatorForm;
130 m_advDialogPtr->m_inputParameters.m_inMaskRaster1Ptr =
m_raster1;
131 m_advDialogPtr->m_inputParameters.m_inMaskRaster2Ptr =
m_raster2;
133 QGridLayout* gridLayout1 =
new QGridLayout(
m_uiPtr->m_image1Frame );
134 QGridLayout* gridLayout2 =
new QGridLayout(
m_uiPtr->m_image2Frame );
143 std::list< te::map::AbstractLayerPtr > layerList1;
157 std::list< te::map::AbstractLayerPtr > layerList2;
206 m_uiPtr->m_referenceBand1ComboBox->addItem( QString::number( band1Idx ) );
208 for(
unsigned band2Idx = 0 ; band2Idx < m_raster2->getNumberOfBands() ;
210 m_uiPtr->m_referenceBand2ComboBox->addItem( QString::number( band2Idx ) );
226 if( (
line ==
col ) || (
line == ( TPLDIALOG_P_PATTERN_W -
col - 1 ) ) )
275 TPContainerT::const_iterator itB =
m_tiePoints.begin();
276 const TPContainerT::const_iterator itE =
m_tiePoints.end();
281 tiePoints.push_back( itB->second.m_tiePoint );
307 auxEnvelope1.m_llx, auxEnvelope1.m_lly, r1LLX, r1LLY );
309 auxEnvelope1.m_urx, auxEnvelope1.m_ury, r1URX, r1URY );
327 auxEnvelope2.m_llx, auxEnvelope2.m_lly, r2LLX, r2LLY );
329 auxEnvelope2.m_urx, auxEnvelope2.m_ury, r2URX, r2URY );
342 m_uiPtr->m_referenceBand1ComboBox->currentText().toUInt() );
344 m_uiPtr->m_referenceBand2ComboBox->currentText().toUInt() );
350 unsigned int manualTPNumber = 0;
352 TPContainerT::const_iterator itB =
m_tiePoints.begin();
353 const TPContainerT::const_iterator itE =
m_tiePoints.end();
379 if( algorithmInstance.
initialize( inputParams ) )
381 if( algorithmInstance.
execute( outputParams ) )
383 const unsigned int tpsNmb =
static_cast<unsigned int>(outputParams.
m_tiePoints.size());
390 for(
unsigned int tpIdx = 0 ; tpIdx < tpsNmb ; ++tpIdx )
405 m_uiPtr->m_tiePointsTableWidget->selectAll();
410 m_uiPtr->m_tiePointsTableWidget->clearSelection();
416 m_uiPtr->m_tiePointsTableWidget->rowCount();
417 QTableWidgetItem* itemPtr =
nullptr;
418 unsigned int tpID = 0;
419 TPContainerT::iterator deletionIt;
421 for(
int row = 0 ; row < rowCount ; ++row )
423 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
425 if( itemPtr->isSelected() )
427 tpID = itemPtr->text().toUInt();
449 if( ( !
m_uiPtr->m_x1LineEdit->text().isEmpty() ) &&
450 ( !
m_uiPtr->m_y1LineEdit->text().isEmpty() ) &&
451 ( !
m_uiPtr->m_x2LineEdit->text().isEmpty() ) &&
452 ( !
m_uiPtr->m_y2LineEdit->text().isEmpty() ) )
498 (
double)coordinate.rx(), (double)coordinate.ry() );
500 m_uiPtr->m_currentImage1LineLineEdit->setText( QString::number(
502 m_uiPtr->m_currentImage1ColumnLineEdit->setText( QString::number(
509 (
double)coordinate.rx(), (double)coordinate.ry() );
511 m_uiPtr->m_currentImage2LineLineEdit->setText( QString::number(
513 m_uiPtr->m_currentImage2ColumnLineEdit->setText( QString::number(
523 TPContainerT::const_iterator tPIt =
m_tiePoints.begin();
524 const TPContainerT::const_iterator tPItEnd =
m_tiePoints.end();
526 while( tPIt != tPItEnd )
528 transParams.
m_tiePoints.push_back( tPIt->second.m_tiePoint );
532 std::unique_ptr< te::gm::GeometricTransformation > transfPtr(
535 if( transfPtr.get() )
537 if( ! transfPtr->initialize( transParams ) )
543 m_uiPtr->m_tiePointsTableWidget->blockSignals(
true );
545 const int rowCount =
m_uiPtr->m_tiePointsTableWidget->rowCount();
547 for(
int row = rowCount - 1 ; row >= 0 ; --row )
549 m_uiPtr->m_tiePointsTableWidget->removeRow( row );
556 m_uiPtr->m_tiePointsTableWidget->setSortingEnabled(
false );
557 double currTPError = 0;
558 QTableWidgetItem* newItemPtr =
nullptr;
560 while( tPIt != tPItEnd )
563 currTPError = transfPtr.get() ? transfPtr->getDirectMappingError(
566 currentRow =
m_uiPtr->m_tiePointsTableWidget->rowCount();
568 m_uiPtr->m_tiePointsTableWidget->insertRow( currentRow );
570 newItemPtr =
new QTableWidgetItem( QString::number( tPIt->first ) );
571 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
572 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 0, newItemPtr );
574 newItemPtr =
new QTableWidgetItem( QString::number( currTPError ) );
575 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
576 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 1, newItemPtr );
580 newItemPtr =
new QTableWidgetItem( QString( tr(
"Manual" ) ) );
584 newItemPtr =
new QTableWidgetItem( QString( tr(
"Automatic" ) ) );
586 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
587 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 2, newItemPtr );
589 newItemPtr =
new QTableWidgetItem( QString::number( currTP.first.x ) );
590 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
591 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 3, newItemPtr );
593 newItemPtr =
new QTableWidgetItem( QString::number( currTP.first.y ) );
594 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
595 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 4, newItemPtr );
597 newItemPtr =
new QTableWidgetItem( QString::number( currTP.second.x ) );
598 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
599 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 5, newItemPtr );
601 newItemPtr =
new QTableWidgetItem( QString::number( currTP.second.y ) );
602 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
603 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 6, newItemPtr );
608 m_uiPtr->m_tiePointsTableWidget->setSortingEnabled(
true );
609 m_uiPtr->m_tiePointsTableWidget->sortByColumn( 1, Qt::DescendingOrder );
612 m_uiPtr->m_tiePointsTableWidget->blockSignals(
false );
627 const int rowCount =
m_uiPtr->m_tiePointsTableWidget->rowCount();
628 QTableWidgetItem* itemPtr =
nullptr;
629 TPContainerT::const_iterator it;
631 for(
int row = 0 ; row < rowCount ; ++row )
633 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
639 if( itemPtr->isSelected() )
641 transParamsSelectedTP.
m_tiePoints.push_back( tiePoint );
645 transParamsUnselectedTP.
m_tiePoints.push_back( tiePoint );
648 transParamsAllTP.
m_tiePoints.push_back( tiePoint );
653 std::unique_ptr< te::gm::GeometricTransformation > transfAllTPPtr(
655 if( transfAllTPPtr.get() )
657 if( ! transfAllTPPtr->initialize( transParamsAllTP ) )
658 transfAllTPPtr.reset();
661 std::unique_ptr< te::gm::GeometricTransformation > transfSelectedTPPtr(
663 if( transfSelectedTPPtr.get() )
665 if( ! transfSelectedTPPtr->initialize( transParamsSelectedTP ) )
666 transfSelectedTPPtr.reset();
669 std::unique_ptr< te::gm::GeometricTransformation > transfUnselectedTPPtr(
671 if( transfUnselectedTPPtr.get() )
673 if( ! transfUnselectedTPPtr->initialize( transParamsUnselectedTP ) )
674 transfUnselectedTPPtr.reset();
679 m_uiPtr->m_tiePointsNumberLineEdit->setText( QString::number(
682 if( transfAllTPPtr.get() )
683 m_uiPtr->m_transformationRMSEAllLineEdit->setText( QString::number(
684 transfAllTPPtr->getDirectMapRMSE() ) );
686 m_uiPtr->m_transformationRMSEAllLineEdit->setText(
"N/A");
688 if( transfSelectedTPPtr.get() )
689 m_uiPtr->m_transformationRMSESelectedLineEdit->setText( QString::number(
690 transfSelectedTPPtr->getDirectMapRMSE() ) );
692 m_uiPtr->m_transformationRMSESelectedLineEdit->setText(
"N/A");
694 if( transfUnselectedTPPtr.get() )
695 m_uiPtr->m_transformationRMSEunselectedLineEdit->setText( QString::number(
696 transfUnselectedTPPtr->getDirectMapRMSE() ) );
698 m_uiPtr->m_transformationRMSEunselectedLineEdit->setText(
"N/A");
729 mapDisplayExtent.
m_lly, mapDisplayExtent.
m_urx,
730 mapDisplayExtent.
m_ury );
735 m_uiPtr->m_tiePointsTableWidget->rowCount();
736 QTableWidgetItem* itemPtr =
nullptr;
737 unsigned int tpID = 0;
738 TPContainerT::iterator tiePointsIt;
742 for(
int row = 0 ; row < rowCount ; ++row )
744 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
746 if( itemPtr->isSelected() )
757 tpID = itemPtr->text().toUInt();
763 tiePointsIt->second.m_tiePoint.first.x, tiePointsIt->second.m_tiePoint.first.y,
764 auxCoord2D.
x, auxCoord2D.
y );
766 auxPoint.
setX( auxCoord2D.
x );
767 auxPoint.
setY( auxCoord2D.
y );
769 canvasInstance.draw( &auxPoint );
778 auxCoord2D.
x, auxCoord2D.
y );
780 auxPoint.
setX( auxCoord2D.
x );
781 auxPoint.
setY( auxCoord2D.
y );
786 canvasInstance.draw( &auxPoint );
799 mapDisplayExtent.
m_lly, mapDisplayExtent.
m_urx,
800 mapDisplayExtent.
m_ury );
805 m_uiPtr->m_tiePointsTableWidget->rowCount();
806 QTableWidgetItem* itemPtr =
nullptr;
807 unsigned int tpID = 0;
808 TPContainerT::iterator tiePointsIt;
812 for(
int row = 0 ; row < rowCount ; ++row )
814 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
816 if( itemPtr->isSelected() )
827 tpID = itemPtr->text().toUInt();
833 tiePointsIt->second.m_tiePoint.second.x, tiePointsIt->second.m_tiePoint.second.y,
834 auxCoord2D.
x, auxCoord2D.
y );
836 auxPoint.
setX( auxCoord2D.
x );
837 auxPoint.
setY( auxCoord2D.
y );
839 canvasInstance.draw( &auxPoint );
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-points (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
std::vector< TiePoint > m_tiePoints
Tie points.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
double m_urx
Upper right corner x-coordinate.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
#define TPLDIALOG_P_PATTERN_W
An utility struct for representing 2D coordinates.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
double m_llx
Lower left corner x-coordinate.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
A dialog used to execute tie points location advanced options.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
Grid * getGrid()
It returns the raster grid.
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
TiePointsLocator output parameters.
double m_lly
Lower left corner y-coordinate.
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
int getSRID() const
Returns the raster spatial reference system identifier.
void setX(const double &x)
It sets the Point x-coordinate value.
double m_ury
Upper right corner y-coordinate.
boost::intrusive_ptr< DataSetLayer > DataSetLayerPtr
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
2D Geometric transformation parameters.
void setY(const double &y)
It sets the Point y-coordinate value.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
A dialog used to execute tie points location.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.