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 <QtGui/QGridLayout>
44 #include <QtGui/QKeyEvent>
45 #include <QtGui/QLineEdit>
46 #include <QtGui/QColor>
48 #define TPLDIALOG_P_PATTERN_W 11
58 : QObject( parent ), m_mDisplay( parent )
69 if( event->type() == QEvent::Enter )
73 else if( event->type() == QEvent::Leave )
77 else if( event->type() == QEvent::KeyPress )
81 emit(
keyPressed( ((QKeyEvent*)event)->key() ) );
89 : m_acqType( InvalidAcquisitionT )
114 QWidget* parent, Qt::WindowFlags f )
115 : QDialog( parent, f ),
121 if( inLayer1Ptr.get() == 0 )
throw te::qt::widgets::Exception(
122 "Invalid data set layer pointer" );
123 if( inLayer1Ptr.get() == 0 )
throw te::qt::widgets::Exception(
124 "Invalid data set layer pointer" );
126 m_uiPtr =
new Ui::TiePointsLocatorForm;
133 m_advDialogPtr->m_inputParameters.m_inMaskRaster1Ptr =
m_raster1;
134 m_advDialogPtr->m_inputParameters.m_inMaskRaster2Ptr =
m_raster2;
136 QGridLayout* gridLayout1 =
new QGridLayout(
m_uiPtr->m_image1Frame );
137 QGridLayout* gridLayout2 =
new QGridLayout(
m_uiPtr->m_image2Frame );
146 std::list< te::map::AbstractLayerPtr > layerList1;
160 std::list< te::map::AbstractLayerPtr > layerList2;
209 m_uiPtr->m_referenceBand1ComboBox->addItem( QString::number( band1Idx ) );
211 for(
unsigned band2Idx = 0 ; band2Idx < m_raster2->getNumberOfBands() ;
213 m_uiPtr->m_referenceBand2ComboBox->addItem( QString::number( band2Idx ) );
229 if( ( line == col ) || ( line == ( TPLDIALOG_P_PATTERN_W - col - 1 ) ) )
278 TPContainerT::const_iterator itB =
m_tiePoints.begin();
279 const TPContainerT::const_iterator itE =
m_tiePoints.end();
284 tiePoints.push_back( itB->second.m_tiePoint );
310 auxEnvelope1.m_llx, auxEnvelope1.m_lly, r1LLX, r1LLY );
312 auxEnvelope1.m_urx, auxEnvelope1.m_ury, r1URX, r1URY );
330 auxEnvelope2.m_llx, auxEnvelope2.m_lly, r2LLX, r2LLY );
332 auxEnvelope2.m_urx, auxEnvelope2.m_ury, r2URX, r2URY );
345 m_uiPtr->m_referenceBand1ComboBox->currentText().toUInt() );
347 m_uiPtr->m_referenceBand2ComboBox->currentText().toUInt() );
353 unsigned int manualTPNumber = 0;
355 TPContainerT::const_iterator itB =
m_tiePoints.begin();
356 const TPContainerT::const_iterator itE =
m_tiePoints.end();
357 double coordDiffX = 0;
358 double coordDiffY = 0;
364 coordDiffX = itB->second.m_tiePoint.first.x -
365 itB->second.m_tiePoint.second.x;
366 coordDiffY = itB->second.m_tiePoint.first.y -
367 itB->second.m_tiePoint.second.y;
369 (
unsigned int)std::ceil( std::sqrt( ( coordDiffX * coordDiffX ) +
370 ( coordDiffY * coordDiffY ) ) ) );
388 if( algorithmInstance.
initialize( inputParams ) )
390 if( algorithmInstance.
execute( outputParams ) )
392 const unsigned int tpsNmb = (
unsigned int)
400 for(
unsigned int tpIdx = 0 ; tpIdx < tpsNmb ; ++tpIdx )
415 m_uiPtr->m_tiePointsTableWidget->selectAll();
420 m_uiPtr->m_tiePointsTableWidget->clearSelection();
426 m_uiPtr->m_tiePointsTableWidget->rowCount();
427 QTableWidgetItem* itemPtr = 0;
428 unsigned int tpID = 0;
429 TPContainerT::iterator deletionIt;
431 for(
int row = 0 ; row < rowCount ; ++row )
433 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
435 if( itemPtr->isSelected() )
437 tpID = itemPtr->text().toUInt();
459 if( ( !
m_uiPtr->m_x1LineEdit->text().isEmpty() ) &&
460 ( !
m_uiPtr->m_y1LineEdit->text().isEmpty() ) &&
461 ( !
m_uiPtr->m_x2LineEdit->text().isEmpty() ) &&
462 ( !
m_uiPtr->m_y2LineEdit->text().isEmpty() ) )
508 (
double)coordinate.rx(), (double)coordinate.ry() );
510 m_uiPtr->m_currentImage1LineLineEdit->setText( QString::number(
512 m_uiPtr->m_currentImage1ColumnLineEdit->setText( QString::number(
519 (
double)coordinate.rx(), (double)coordinate.ry() );
521 m_uiPtr->m_currentImage2LineLineEdit->setText( QString::number(
523 m_uiPtr->m_currentImage2ColumnLineEdit->setText( QString::number(
533 TPContainerT::const_iterator tPIt =
m_tiePoints.begin();
534 const TPContainerT::const_iterator tPItEnd =
m_tiePoints.end();
536 while( tPIt != tPItEnd )
538 transParams.
m_tiePoints.push_back( tPIt->second.m_tiePoint );
542 std::auto_ptr< te::gm::GeometricTransformation > transfPtr(
545 if( transfPtr.get() )
547 if( ! transfPtr->initialize( transParams ) )
553 m_uiPtr->m_tiePointsTableWidget->blockSignals(
true );
555 const int rowCount =
m_uiPtr->m_tiePointsTableWidget->rowCount();
557 for(
int row = rowCount - 1 ; row >= 0 ; --row )
559 m_uiPtr->m_tiePointsTableWidget->removeRow( row );
566 m_uiPtr->m_tiePointsTableWidget->setSortingEnabled(
false );
567 double currTPError = 0;
568 QTableWidgetItem* newItemPtr = 0;
570 while( tPIt != tPItEnd )
573 currTPError = transfPtr.get() ? transfPtr->getDirectMappingError(
576 currentRow =
m_uiPtr->m_tiePointsTableWidget->rowCount();
578 m_uiPtr->m_tiePointsTableWidget->insertRow( currentRow );
580 newItemPtr =
new QTableWidgetItem( QString::number( tPIt->first ) );
581 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
582 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 0, newItemPtr );
584 newItemPtr =
new QTableWidgetItem( QString::number( currTPError ) );
585 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
586 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 1, newItemPtr );
590 newItemPtr =
new QTableWidgetItem( QString( tr(
"Manual" ) ) );
594 newItemPtr =
new QTableWidgetItem( QString( tr(
"Automatic" ) ) );
596 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
597 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 2, newItemPtr );
599 newItemPtr =
new QTableWidgetItem( QString::number( currTP.first.x ) );
600 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
601 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 3, newItemPtr );
603 newItemPtr =
new QTableWidgetItem( QString::number( currTP.first.y ) );
604 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
605 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 4, newItemPtr );
607 newItemPtr =
new QTableWidgetItem( QString::number( currTP.second.x ) );
608 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
609 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 5, newItemPtr );
611 newItemPtr =
new QTableWidgetItem( QString::number( currTP.second.y ) );
612 newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
613 m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 6, newItemPtr );
618 m_uiPtr->m_tiePointsTableWidget->setSortingEnabled(
true );
619 m_uiPtr->m_tiePointsTableWidget->sortByColumn( 1, Qt::DescendingOrder );
622 m_uiPtr->m_tiePointsTableWidget->blockSignals(
false );
637 const int rowCount =
m_uiPtr->m_tiePointsTableWidget->rowCount();
638 QTableWidgetItem* itemPtr = 0;
639 TPContainerT::const_iterator it;
641 for(
int row = 0 ; row < rowCount ; ++row )
643 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
649 if( itemPtr->isSelected() )
651 transParamsSelectedTP.
m_tiePoints.push_back( tiePoint );
655 transParamsUnselectedTP.
m_tiePoints.push_back( tiePoint );
658 transParamsAllTP.
m_tiePoints.push_back( tiePoint );
663 std::auto_ptr< te::gm::GeometricTransformation > transfAllTPPtr(
665 if( transfAllTPPtr.get() )
667 if( ! transfAllTPPtr->initialize( transParamsAllTP ) )
668 transfAllTPPtr.reset();
671 std::auto_ptr< te::gm::GeometricTransformation > transfSelectedTPPtr(
673 if( transfSelectedTPPtr.get() )
675 if( ! transfSelectedTPPtr->initialize( transParamsSelectedTP ) )
676 transfSelectedTPPtr.reset();
679 std::auto_ptr< te::gm::GeometricTransformation > transfUnselectedTPPtr(
681 if( transfUnselectedTPPtr.get() )
683 if( ! transfUnselectedTPPtr->initialize( transParamsUnselectedTP ) )
684 transfUnselectedTPPtr.reset();
689 m_uiPtr->m_tiePointsNumberLineEdit->setText( QString::number(
692 if( transfAllTPPtr.get() )
693 m_uiPtr->m_transformationRMSEAllLineEdit->setText( QString::number(
694 transfAllTPPtr->getDirectMapRMSE() ) );
696 m_uiPtr->m_transformationRMSEAllLineEdit->setText(
"N/A");
698 if( transfSelectedTPPtr.get() )
699 m_uiPtr->m_transformationRMSESelectedLineEdit->setText( QString::number(
700 transfSelectedTPPtr->getDirectMapRMSE() ) );
702 m_uiPtr->m_transformationRMSESelectedLineEdit->setText(
"N/A");
704 if( transfUnselectedTPPtr.get() )
705 m_uiPtr->m_transformationRMSEunselectedLineEdit->setText( QString::number(
706 transfUnselectedTPPtr->getDirectMapRMSE() ) );
708 m_uiPtr->m_transformationRMSEunselectedLineEdit->setText(
"N/A");
739 mapDisplayExtent.
m_lly, mapDisplayExtent.
m_urx,
740 mapDisplayExtent.
m_ury );
745 m_uiPtr->m_tiePointsTableWidget->rowCount();
746 QTableWidgetItem* itemPtr = 0;
747 unsigned int tpID = 0;
748 TPContainerT::iterator tiePointsIt;
752 for(
int row = 0 ; row < rowCount ; ++row )
754 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
756 if( itemPtr->isSelected() )
767 tpID = itemPtr->text().toUInt();
773 tiePointsIt->second.m_tiePoint.first.x, tiePointsIt->second.m_tiePoint.first.y,
774 auxCoord2D.
x, auxCoord2D.
y );
776 auxPoint.
setX( auxCoord2D.
x );
777 auxPoint.
setY( auxCoord2D.
y );
779 canvasInstance.draw( &auxPoint );
788 auxCoord2D.
x, auxCoord2D.
y );
790 auxPoint.
setX( auxCoord2D.
x );
791 auxPoint.
setY( auxCoord2D.
y );
796 canvasInstance.draw( &auxPoint );
809 mapDisplayExtent.
m_lly, mapDisplayExtent.
m_urx,
810 mapDisplayExtent.
m_ury );
815 m_uiPtr->m_tiePointsTableWidget->rowCount();
816 QTableWidgetItem* itemPtr = 0;
817 unsigned int tpID = 0;
818 TPContainerT::iterator tiePointsIt;
822 for(
int row = 0 ; row < rowCount ; ++row )
824 itemPtr =
m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
826 if( itemPtr->isSelected() )
837 tpID = itemPtr->text().toUInt();
843 tiePointsIt->second.m_tiePoint.second.x, tiePointsIt->second.m_tiePoint.second.y,
844 auxCoord2D.
x, auxCoord2D.
y );
846 auxPoint.
setX( auxCoord2D.
x );
847 auxPoint.
setY( auxCoord2D.
y );
849 canvasInstance.draw( &auxPoint );
TiePointAcquisitionType m_acqType
Acquisition type.
TPContainerT m_tiePoints
Internal tie-points container.
te::qt::widgets::ZoomLeftAndRightClick * m_zoomClickEvent1
Input raster 2 pointer.
void setX(const double &x)
It sets the Point x-coordinate value.
void on_autoAcquireTiePointsPushButton_clicked()
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-pionts (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
virtual void setResizePolicy(const ResizePolicy &policy)
Sets the resize policy to this map display.
void on_addPushButton_clicked()
Ui::TiePointsLocatorForm * m_uiPtr
CoordTracking * m_coordTracking2
Coord tracking (map display 2);.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
void getTiePoints(std::vector< te::gm::GTParameters::TiePoint > &tiePoints) const
Get the current acquired tie-points.
void refreshMapDisplay1()
Refresh map display 1.
void on_okPushButton_clicked()
void on_mapDisplay2_extentChanged()
A dialog used to execute tie points location.
TiePointsLocatorDialogMDEventFilter(te::qt::widgets::MapDisplay *parent)
unsigned int m_raster2TargetAreaWidth
The raster 2 target area width (default:0 - The entire raster will be considered).
void setY(const double &y)
It sets the Point y-coordinate value.
te::map::DataSetLayerPtr m_inLayer1Ptr
Grid * getGrid()
It returns the raster grid.
std::vector< unsigned int > m_inRaster1Bands
Bands to be used from the input raster 1.
void on_mapDisplay1_coordTracked(QPointF &coordinate)
void on_deleteSelectedPushButton_clicked()
unsigned int m_raster2TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
TiePointsLocatorDialog(const te::map::DataSetLayerPtr &inLayer1Ptr, const te::map::DataSetLayerPtr &inLayer2Ptr, QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a basic dialog which is a child of parent, with widget flags set to f. ...
te::rst::Raster * m_raster1
Input data set layer 2 pointer.
This class implements a concrete tool to geographic zoom operation using the left and right mouse cli...
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
Automatic acquisition type.
An utility struct for representing 2D coordinates.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
void on_mapDisplay1_keyPressed(int key)
~TiePointsLocatorDialog()
Destructor.
void on_mapDisplay2_keyPressed(int key)
te::map::DataSetLayerPtr m_inLayer2Ptr
Input data set layer 1 pointer.
te::gm::GTParameters::TiePoint m_lastTrackedTiePoint
The last mouse tracked tie-point by analysing the mouse move over the map areas.
CoordTracking * m_coordTracking1
Coord tracking (map display 1);.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
std::vector< TiePoint > m_tiePoints
Tie points.
void on_tiePointsTableWidget_itemSelectionChanged()
TiePointsLocator input parameters.
te::rst::Raster * m_raster2
Input raster 1 pointer.
double m_lly
Lower left corner y-coordinate.
te::color::RGBAColor ** m_selectedPointPattern
The display draw pattern used for selected points.
te::qt::widgets::MapDisplay * m_mapDisplay2
Map display 2.
int getSRID() const
Returns the raster spatial reference system identifier.
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
void on_unselectAllPushButton_clicked()
void on_mapDisplay2_coordTracked(QPointF &coordinate)
TEMAPEXPORT te::rst::Raster * GetRaster(DataSetLayer *layer)
It gets the raster referenced by the given data set layer.
double m_ury
Upper right corner y-coordinate.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
unsigned int m_maxR1ToR2Offset
The maximum offset (pixels units) between a raster 1 point end the respective raster 2 point (default...
~TiePointsLocatorDialogMDEventFilter()
virtual void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
A canvas built on top of Qt.
unsigned int m_raster2TargetAreaLineStart
The first line of the raster 2 target area to process (default:0 - The entire raster will be consider...
A point with x and y coordinate values.
te::color::RGBAColor ** m_tempPointPattern
The display draw pattern used for temporary points.
te::qt::widgets::ZoomLeftAndRightClick * m_zoomClickEvent2
Zoom click event (map display 2).
unsigned int m_raster1TargetAreaLineStart
The first line of the raster 1 target area to process (default:0 - The entire raster will be consider...
double m_urx
Upper right corner x-coordinate.
unsigned int m_raster2TargetAreaHeight
The raster 2 target area height (default:0 - The entire raster will be considered).
A widget to control the display of a set of layers.
boost::intrusive_ptr< DataSetLayer > DataSetLayerPtr
std::string m_geomTransfName
The name of the geometric transformation used to ensure tie-points consistency (see each te::gm::GTFa...
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
te::rp::TiePointsLocator::InputParameters m_inputParameters
The current parameters.
TiePointsLocatorAdvancedDialog * m_advDialogPtr
User interface.
const TiePointData & operator=(const TiePointData &other)
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
std::vector< unsigned int > m_inRaster2Bands
Bands to be used from the input raster 2.
void transformationInfoUpdate()
Uptate the current transformation information widgets.
virtual void setSRID(const int &srid, bool doRefresh=true)
It sets a new Spatial Reference System to be used by the Map Display.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
bool eventFilter(QObject *watched, QEvent *event)
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
A dialog used to execute tie points location advanced options.
#define TPLDIALOG_P_PATTERN_W
te::gm::GTParameters::TiePoint m_lastSelectedTiePoint
The last mouse tracked tie-point by pressing any key over the map areas.
double m_llx
Lower left corner x-coordinate.
This class implements a concrete tool to geographic coordinate tracking on mouse move operation...
unsigned int m_raster1TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
void tiePointsTableUpdate()
Uptate the tie-points table widget.
unsigned int m_raster1TargetAreaWidth
The raster 1 target area width (default:0 - The entire raster will be considered).
2D Geometric transformation parameters.
unsigned int m_lastInsertedTPID
A ID counter for new tie pointes inserted into m_tiePoints;.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
bool m_lastSelectedTiePointHasFirstOk
true if the last selected tie-point has the first part set;
te::rst::Raster const * m_inRaster1Ptr
Input raster 1.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
te::gm::GTParameters::TiePoint m_tiePoint
Tie point coordinates.
TiePointsLocatorDialogMDEventFilter * m_mDEventFilter2
Map display 2 event filter.
An Envelope defines a 2D rectangular region.
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
A event filter to handle map display events.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
A dialog used to execute tie points location advanced options.
void refreshMapDisplay2()
Refresh map display 2.
unsigned int m_raster1TargetAreaHeight
The raster 1 target area height (default:0 - The entire raster will be considered).
te::qt::widgets::MapDisplay * m_mDisplay
te::qt::widgets::MapDisplay * m_mapDisplay1
Map display 1.
te::rst::Raster const * m_inRaster2Ptr
Input raster 2.
te::color::RGBAColor ** m_unselectedPointPattern
The display draw pattern used for unselected points.
TiePointsLocatorDialogMDEventFilter * m_mDEventFilter1
Map display 1 event filter.
void on_advancedOptionsPushButton_clicked()
void on_selectAllPushButton_clicked()
TiePointsLocator output parameters.
void on_mapDisplay1_extentChanged()