TiePointsLocatorDialog.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/widgets/rp/TiePointsLocatorDialog.cpp
22 
23  \brief A dialog used to execute tie points location.
24 */
25 
26 #include "TiePointsLocatorDialog.h"
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"
39 
40 #include <ui_TiePointsLocatorForm.h>
41 
42 #include <QtCore/QString>
43 #include <QGridLayout>
44 #include <QKeyEvent>
45 #include <QLineEdit>
46 #include <QColor>
47 
48 #define TPLDIALOG_P_PATTERN_W 11
49 
50 namespace te
51 {
52  namespace qt
53  {
54  namespace widgets
55  {
58  : QObject( parent ), m_mDisplay( parent )
59  {
60  }
61 
64 
66  QObject* /*watched*/, QEvent* event)
67  {
68  if( event->type() == QEvent::Enter )
69  {
70  m_mDisplay->grabKeyboard();
71  }
72  else if( event->type() == QEvent::Leave )
73  {
74  m_mDisplay->releaseKeyboard();
75  }
76  else if( event->type() == QEvent::KeyPress )
77  {
78  if( m_mDisplay->underMouse() )
79  {
80  emit( keyPressed( ((QKeyEvent*)event)->key() ) );
81  }
82  }
83 
84  return false;
85  }
86 
88  : m_acqType( InvalidAcquisitionT )
89  {
90  }
91 
94  {
95  operator=( other );
96  }
97 
99 
102  {
103  m_acqType = other.m_acqType;
104  m_tiePoint = other.m_tiePoint;
105  return other;
106  }
107 
109  const te::map::DataSetLayerPtr& inLayer1Ptr,
110  const te::map::DataSetLayerPtr& inLayer2Ptr,
111  QWidget* parent, Qt::WindowFlags f )
112  : QDialog( parent, f ),
113  m_inLayer1Ptr( inLayer1Ptr ),
114  m_inLayer2Ptr( inLayer2Ptr ),
116  m_lastInsertedTPID( 0 )
117  {
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" );
122 
123  m_uiPtr = new Ui::TiePointsLocatorForm;
124  m_uiPtr->setupUi(this);
125 
128 
130  m_advDialogPtr->m_inputParameters.m_inMaskRaster1Ptr = m_raster1;
131  m_advDialogPtr->m_inputParameters.m_inMaskRaster2Ptr = m_raster2;
132 
133  QGridLayout* gridLayout1 = new QGridLayout( m_uiPtr->m_image1Frame );
134  QGridLayout* gridLayout2 = new QGridLayout( m_uiPtr->m_image2Frame );
135 
136  // map display 1
137 
139  m_uiPtr->m_image1Frame->size(), m_uiPtr->m_image1Frame );
140  m_mapDisplay1->setMouseTracking ( true );
141  gridLayout1->addWidget( m_mapDisplay1 );
143  std::list< te::map::AbstractLayerPtr > layerList1;
144  layerList1.push_back( m_inLayer1Ptr );
145  m_mapDisplay1->setLayerList( layerList1 );
147  te::gm::Envelope displayExtent1(*(m_raster1->getExtent()));
148  m_mapDisplay1->setExtent( displayExtent1 );
149 
150  // map display 2
151 
153  m_uiPtr->m_image2Frame->size(), m_uiPtr->m_image2Frame );
154  m_mapDisplay2->setMouseTracking ( true );
155  gridLayout2->addWidget( m_mapDisplay2 );
157  std::list< te::map::AbstractLayerPtr > layerList2;
158  layerList2.push_back( m_inLayer2Ptr );
159  m_mapDisplay2->setLayerList( layerList2 );
160  m_mapDisplay2->setSRID(m_raster2->getSRID());
161  te::gm::Envelope displayExtent2(*(m_raster2->getExtent()));
162  m_mapDisplay1->setExtent( displayExtent2 );
163 
164  // Events
165 
168 
171 
174 
175  m_mapDisplay1->installEventFilter( m_zoomClickEvent1 );
176  m_mapDisplay2->installEventFilter( m_zoomClickEvent2 );
177 
178  m_mapDisplay1->installEventFilter( m_coordTracking1 );
179  m_mapDisplay2->installEventFilter( m_coordTracking2 );
180 
181  m_mapDisplay1->installEventFilter( m_mDEventFilter1 );
182  m_mapDisplay2->installEventFilter( m_mDEventFilter2 );
183 
184 
185  // Signals & slots
186 
187  connect(m_uiPtr->m_okPushButton, SIGNAL(clicked()), this, SLOT(on_okPushButton_clicked()));
188  connect(m_uiPtr->m_autoAcquireTiePointsPushButton, SIGNAL(clicked()), this, SLOT(on_autoAcquireTiePointsPushButton_clicked()));
189  connect(m_uiPtr->m_selectAllPushButton, SIGNAL(clicked()), this, SLOT(on_selectAllPushButton_clicked()));
190  connect(m_uiPtr->m_unselectAllPushButton, SIGNAL(clicked()), this, SLOT(on_unselectAllPushButton_clicked()));
191  connect(m_uiPtr->m_deleteSelectedPushButton, SIGNAL(clicked()), this, SLOT(on_deleteSelectedPushButton_clicked()));
192  connect(m_uiPtr->m_advancedOptionsPushButton, SIGNAL(clicked()), this, SLOT(on_advancedOptionsPushButton_clicked()));
193  connect(m_uiPtr->m_addPushButton, SIGNAL(clicked()), this, SLOT(on_addPushButton_clicked()));
194  connect(m_coordTracking1, SIGNAL(coordTracked(QPointF&)), this, SLOT(on_mapDisplay1_coordTracked(QPointF&)));
195  connect(m_coordTracking2, SIGNAL(coordTracked(QPointF&)), this, SLOT(on_mapDisplay2_coordTracked(QPointF&)));
196  connect(m_mDEventFilter1, SIGNAL(keyPressed(int)), this, SLOT(on_mapDisplay1_keyPressed(int)));
197  connect(m_mDEventFilter2, SIGNAL(keyPressed(int)), this, SLOT(on_mapDisplay2_keyPressed(int)));
198  connect(m_uiPtr->m_tiePointsTableWidget, SIGNAL(itemSelectionChanged()), this, SLOT(on_tiePointsTableWidget_itemSelectionChanged()));
199  connect(m_mapDisplay1, SIGNAL(extentChanged()), this, SLOT(on_mapDisplay1_extentChanged()));
200  connect(m_mapDisplay2, SIGNAL(extentChanged()), this, SLOT(on_mapDisplay2_extentChanged()));
201 
202  // fill form
203 
204  for( unsigned band1Idx = 0 ; band1Idx < m_raster1->getNumberOfBands() ;
205  ++band1Idx )
206  m_uiPtr->m_referenceBand1ComboBox->addItem( QString::number( band1Idx ) );
207 
208  for( unsigned band2Idx = 0 ; band2Idx < m_raster2->getNumberOfBands() ;
209  ++band2Idx )
210  m_uiPtr->m_referenceBand2ComboBox->addItem( QString::number( band2Idx ) );
211 
212  // create points draw patterns
213 
217 
218  for( unsigned int line = 0 ; line < TPLDIALOG_P_PATTERN_W ; ++line )
219  {
223 
224  for( unsigned int col = 0 ; col < TPLDIALOG_P_PATTERN_W ; ++col )
225  {
226  if( ( line == col ) || ( line == ( TPLDIALOG_P_PATTERN_W - col - 1 ) ) )
227  {
228  m_selectedPointPattern[ line ][ col ].setColor( 255, 0, 0, TE_OPAQUE );
229  m_unselectedPointPattern[ line ][ col ].setColor( 0, 255, 0, TE_OPAQUE );
230  m_tempPointPattern[ line ][ col ].setColor( 0, 0, 255, TE_OPAQUE );
231  }
232  else
233  {
237  }
238  }
239  }
240  }
241 
243  {
244  // assuring that the keyboard is released from the map displays
245 
246  m_mapDisplay1->releaseKeyboard();
247  m_mapDisplay2->releaseKeyboard();
248 
249  delete m_raster1;
250  delete m_raster2;
251 
252  // delete points draw patterns
253 
254  for( unsigned int line = 0 ; line < TPLDIALOG_P_PATTERN_W ; ++line )
255  {
256  delete[] m_selectedPointPattern[ line ];
257  delete[] m_unselectedPointPattern[ line ];
258  delete[] m_tempPointPattern[ line ];
259  }
260 
261  delete[] m_selectedPointPattern;
262  delete[] m_unselectedPointPattern;
263  delete[] m_tempPointPattern;
264 
265  // detroying the UI
266 
267  delete m_uiPtr;
268  }
269 
270  void TiePointsLocatorDialog::getTiePoints( std::vector< te::gm::GTParameters::TiePoint >&
271  tiePoints ) const
272  {
273  tiePoints.clear();
274 
275  TPContainerT::const_iterator itB = m_tiePoints.begin();
276  const TPContainerT::const_iterator itE = m_tiePoints.end();
277  tiePoints.reserve( m_tiePoints.size() );
278 
279  while( itB != itE )
280  {
281  tiePoints.push_back( itB->second.m_tiePoint );
282  ++itB;
283  }
284  }
285 
287  {
288  close();
289  }
290 
292  {
293  // creating the algorithm parameters
294 
297 
298  inputParams.m_inRaster1Ptr = m_raster1;
299  inputParams.m_inRaster2Ptr = m_raster2;
300 
301  te::gm::Envelope auxEnvelope1( m_mapDisplay1->getExtent() );
302  double r1LLX = 0;
303  double r1LLY = 0;
304  double r1URX = 0;
305  double r1URY = 0;
306  inputParams.m_inRaster1Ptr->getGrid()->geoToGrid(
307  auxEnvelope1.m_llx, auxEnvelope1.m_lly, r1LLX, r1LLY );
308  inputParams.m_inRaster1Ptr->getGrid()->geoToGrid(
309  auxEnvelope1.m_urx, auxEnvelope1.m_ury, r1URX, r1URY );
310  inputParams.m_raster1TargetAreaColStart = (unsigned int)std::max( 0.0,
311  r1LLX );
312  inputParams.m_raster1TargetAreaLineStart = (unsigned int)std::max( 0.0,
313  r1URY );
314  inputParams.m_raster1TargetAreaWidth = ( (unsigned int)std::min(
315  (double)inputParams.m_inRaster1Ptr->getNumberOfColumns(),
316  r1URX ) ) - inputParams.m_raster1TargetAreaColStart + 1;
317  inputParams.m_raster1TargetAreaHeight = ( (unsigned int)std::min(
318  (double)inputParams.m_inRaster1Ptr->getNumberOfRows(),
319  r1LLY ) ) - inputParams.m_raster1TargetAreaColStart + 1;
320 
321  te::gm::Envelope auxEnvelope2( m_mapDisplay2->getExtent() );
322  double r2LLX = 0;
323  double r2LLY = 0;
324  double r2URX = 0;
325  double r2URY = 0;
326  inputParams.m_inRaster2Ptr->getGrid()->geoToGrid(
327  auxEnvelope2.m_llx, auxEnvelope2.m_lly, r2LLX, r2LLY );
328  inputParams.m_inRaster2Ptr->getGrid()->geoToGrid(
329  auxEnvelope2.m_urx, auxEnvelope2.m_ury, r2URX, r2URY );
330  inputParams.m_raster2TargetAreaColStart = (unsigned int)std::max( 0.0,
331  r2LLX );
332  inputParams.m_raster2TargetAreaLineStart = (unsigned int)std::max( 0.0,
333  r2URY );
334  inputParams.m_raster2TargetAreaWidth = ( (unsigned int)std::min(
335  (double)inputParams.m_inRaster2Ptr->getNumberOfColumns(),
336  r2URX ) ) - inputParams.m_raster2TargetAreaColStart + 1;
337  inputParams.m_raster2TargetAreaHeight = ( (unsigned int)std::min(
338  (double)inputParams.m_inRaster2Ptr->getNumberOfRows(),
339  r2LLY ) ) - inputParams.m_raster2TargetAreaColStart + 1;
340 
341  inputParams.m_inRaster1Bands.push_back(
342  m_uiPtr->m_referenceBand1ComboBox->currentText().toUInt() );
343  inputParams.m_inRaster2Bands.push_back(
344  m_uiPtr->m_referenceBand2ComboBox->currentText().toUInt() );
345 
347 
348  // Looking for manual inserted tie-points for an initial estimate
349 
350  unsigned int manualTPNumber = 0;
351 
352  TPContainerT::const_iterator itB = m_tiePoints.begin();
353  const TPContainerT::const_iterator itE = m_tiePoints.end();
354 
355  while( itB != itE )
356  {
357  if( itB->second.m_acqType == TiePointData::ManualAcquisitionT )
358  {
359 // inputParams.m_maxR1ToR2Offset += std::max( inputParams.m_maxR1ToR2Offset,
360 // (unsigned int)std::ceil( std::sqrt( ( coordDiffX * coordDiffX ) +
361 // ( coordDiffY * coordDiffY ) ) ) );
362  ++manualTPNumber;
363  }
364 
365  ++itB;
366  }
367 
368 // if( inputParams.m_maxR1ToR2Offset > 0 )
369 // {
370 // inputParams.m_maxR1ToR2Offset /= manualTPNumber;
371 // inputParams.m_maxR1ToR2Offset += ( ( inputParams.m_maxR1ToR2Offset * 10 )
372 // / 100 );
373 // }
374 
375  // Executing the algorithm
376 
377  te::rp::TiePointsLocator algorithmInstance;
378 
379  if( algorithmInstance.initialize( inputParams ) )
380  {
381  if( algorithmInstance.execute( outputParams ) )
382  {
383  const unsigned int tpsNmb = static_cast<unsigned int>(outputParams.m_tiePoints.size());
384 
385  if( tpsNmb )
386  {
387  TiePointData auxTpData;
389 
390  for( unsigned int tpIdx = 0 ; tpIdx < tpsNmb ; ++tpIdx )
391  {
393  auxTpData.m_tiePoint = outputParams.m_tiePoints[ tpIdx ];
394  m_tiePoints[ m_lastInsertedTPID ] = auxTpData;
395  }
396 
398  }
399  }
400  }
401  }
402 
404  {
405  m_uiPtr->m_tiePointsTableWidget->selectAll();
406  }
407 
409  {
410  m_uiPtr->m_tiePointsTableWidget->clearSelection();
411  }
412 
414  {
415  const int rowCount =
416  m_uiPtr->m_tiePointsTableWidget->rowCount();
417  QTableWidgetItem* itemPtr = nullptr;
418  unsigned int tpID = 0;
419  TPContainerT::iterator deletionIt;
420 
421  for( int row = 0 ; row < rowCount ; ++row )
422  {
423  itemPtr = m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
424 
425  if( itemPtr->isSelected() )
426  {
427  tpID = itemPtr->text().toUInt();
428  deletionIt = m_tiePoints.find( tpID );
429  assert( deletionIt != m_tiePoints.end() );
430  m_tiePoints.erase( deletionIt );
431  }
432  }
433 
434  if( m_tiePoints.empty() )
435  {
436  m_lastInsertedTPID = 0;
437  }
438 
440  }
441 
443  {
444  m_advDialogPtr->exec();
445  }
446 
448  {
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() ) )
453  {
454  TiePointData auxTpData;
456  auxTpData.m_tiePoint.first.x = m_uiPtr->m_x1LineEdit->text().toDouble();
457  auxTpData.m_tiePoint.first.y = m_uiPtr->m_y1LineEdit->text().toDouble();
458  auxTpData.m_tiePoint.second.x = m_uiPtr->m_x2LineEdit->text().toDouble();
459  auxTpData.m_tiePoint.second.y = m_uiPtr->m_y2LineEdit->text().toDouble();
460 
462  m_tiePoints[ m_lastInsertedTPID ] = auxTpData;
463 
465  }
466  }
467 
469  {
472 
474  }
475 
477  {
479  {
481 
483 
484  TiePointData auxTpData;
487 
489  m_tiePoints[ m_lastInsertedTPID ] = auxTpData;
490 
492  }
493  }
494 
496  {
498  (double)coordinate.rx(), (double)coordinate.ry() );
499 
500  m_uiPtr->m_currentImage1LineLineEdit->setText( QString::number(
501  m_lastTrackedTiePoint.first.y ) );
502  m_uiPtr->m_currentImage1ColumnLineEdit->setText( QString::number(
503  m_lastTrackedTiePoint.first.x ) );
504  }
505 
507  {
509  (double)coordinate.rx(), (double)coordinate.ry() );
510 
511  m_uiPtr->m_currentImage2LineLineEdit->setText( QString::number(
512  m_lastTrackedTiePoint.second.y ) );
513  m_uiPtr->m_currentImage2ColumnLineEdit->setText( QString::number(
514  m_lastTrackedTiePoint.second.x ) );
515  }
516 
518  {
519  // building the geometric transformation
520 
521  te::gm::GTParameters transParams;
522 
523  TPContainerT::const_iterator tPIt = m_tiePoints.begin();
524  const TPContainerT::const_iterator tPItEnd = m_tiePoints.end();
525 
526  while( tPIt != tPItEnd )
527  {
528  transParams.m_tiePoints.push_back( tPIt->second.m_tiePoint );
529  ++tPIt;
530  }
531 
532  std::unique_ptr< te::gm::GeometricTransformation > transfPtr(
534 
535  if( transfPtr.get() )
536  {
537  if( ! transfPtr->initialize( transParams ) )
538  transfPtr.reset();
539  }
540 
541  // updating the tie points table
542 
543  m_uiPtr->m_tiePointsTableWidget->blockSignals( true );
544 
545  const int rowCount = m_uiPtr->m_tiePointsTableWidget->rowCount();
546 
547  for( int row = rowCount - 1 ; row >= 0 ; --row )
548  {
549  m_uiPtr->m_tiePointsTableWidget->removeRow( row );
550  }
551 
552  if( ! m_tiePoints.empty() )
553  {
554  tPIt = m_tiePoints.begin();
555  int currentRow = 0;
556  m_uiPtr->m_tiePointsTableWidget->setSortingEnabled( false );
557  double currTPError = 0;
558  QTableWidgetItem* newItemPtr = nullptr;
559 
560  while( tPIt != tPItEnd )
561  {
562  const te::gm::GTParameters::TiePoint& currTP = tPIt->second.m_tiePoint;
563  currTPError = transfPtr.get() ? transfPtr->getDirectMappingError(
564  currTP ) : 0.0;
565 
566  currentRow = m_uiPtr->m_tiePointsTableWidget->rowCount();
567 
568  m_uiPtr->m_tiePointsTableWidget->insertRow( currentRow );
569 
570  newItemPtr = new QTableWidgetItem( QString::number( tPIt->first ) );
571  newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
572  m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 0, newItemPtr );
573 
574  newItemPtr = new QTableWidgetItem( QString::number( currTPError ) );
575  newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
576  m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 1, newItemPtr );
577 
578  if( tPIt->second.m_acqType == TiePointData::ManualAcquisitionT )
579  {
580  newItemPtr = new QTableWidgetItem( QString( tr( "Manual" ) ) );
581  }
582  else
583  {
584  newItemPtr = new QTableWidgetItem( QString( tr( "Automatic" ) ) );
585  }
586  newItemPtr->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
587  m_uiPtr->m_tiePointsTableWidget->setItem( currentRow, 2, newItemPtr );
588 
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 );
592 
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 );
596 
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 );
600 
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 );
604 
605  ++tPIt;
606  }
607 
608  m_uiPtr->m_tiePointsTableWidget->setSortingEnabled( true );
609  m_uiPtr->m_tiePointsTableWidget->sortByColumn( 1, Qt::DescendingOrder );
610  }
611 
612  m_uiPtr->m_tiePointsTableWidget->blockSignals( false );
613 
617  }
618 
620  {
621  // creating the transformations parameters
622 
623  te::gm::GTParameters transParamsAllTP;
624  te::gm::GTParameters transParamsSelectedTP;
625  te::gm::GTParameters transParamsUnselectedTP;
626 
627  const int rowCount = m_uiPtr->m_tiePointsTableWidget->rowCount();
628  QTableWidgetItem* itemPtr = nullptr;
629  TPContainerT::const_iterator it;
630 
631  for( int row = 0 ; row < rowCount ; ++row )
632  {
633  itemPtr = m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
634  it = m_tiePoints.find( itemPtr->text().toUInt() );
635  assert( it != m_tiePoints.end() );
636 
637  const te::gm::GTParameters::TiePoint& tiePoint = it->second.m_tiePoint;
638 
639  if( itemPtr->isSelected() )
640  {
641  transParamsSelectedTP.m_tiePoints.push_back( tiePoint );
642  }
643  else
644  {
645  transParamsUnselectedTP.m_tiePoints.push_back( tiePoint );
646  }
647 
648  transParamsAllTP.m_tiePoints.push_back( tiePoint );
649  }
650 
651  // instantiating the transformations
652 
653  std::unique_ptr< te::gm::GeometricTransformation > transfAllTPPtr(
655  if( transfAllTPPtr.get() )
656  {
657  if( ! transfAllTPPtr->initialize( transParamsAllTP ) )
658  transfAllTPPtr.reset();
659  }
660 
661  std::unique_ptr< te::gm::GeometricTransformation > transfSelectedTPPtr(
663  if( transfSelectedTPPtr.get() )
664  {
665  if( ! transfSelectedTPPtr->initialize( transParamsSelectedTP ) )
666  transfSelectedTPPtr.reset();
667  }
668 
669  std::unique_ptr< te::gm::GeometricTransformation > transfUnselectedTPPtr(
671  if( transfUnselectedTPPtr.get() )
672  {
673  if( ! transfUnselectedTPPtr->initialize( transParamsUnselectedTP ) )
674  transfUnselectedTPPtr.reset();
675  }
676 
677  // updating widgets
678 
679  m_uiPtr->m_tiePointsNumberLineEdit->setText( QString::number(
680  m_tiePoints.size() ) );
681 
682  if( transfAllTPPtr.get() )
683  m_uiPtr->m_transformationRMSEAllLineEdit->setText( QString::number(
684  transfAllTPPtr->getDirectMapRMSE() ) );
685  else
686  m_uiPtr->m_transformationRMSEAllLineEdit->setText("N/A");
687 
688  if( transfSelectedTPPtr.get() )
689  m_uiPtr->m_transformationRMSESelectedLineEdit->setText( QString::number(
690  transfSelectedTPPtr->getDirectMapRMSE() ) );
691  else
692  m_uiPtr->m_transformationRMSESelectedLineEdit->setText("N/A");
693 
694  if( transfUnselectedTPPtr.get() )
695  m_uiPtr->m_transformationRMSEunselectedLineEdit->setText( QString::number(
696  transfUnselectedTPPtr->getDirectMapRMSE() ) );
697  else
698  m_uiPtr->m_transformationRMSEunselectedLineEdit->setText("N/A");
699  }
700 
702  {
703  te::gm::Envelope auxEnvelope( m_mapDisplay1->getExtent() );
704  m_mapDisplay1->setExtent( auxEnvelope );
705  }
706 
708  {
709  te::gm::Envelope auxEnvelope( m_mapDisplay2->getExtent() );
710  m_mapDisplay2->setExtent( auxEnvelope );
711  }
712 
714  {
718  }
719 
721  {
722  const te::gm::Envelope& mapDisplayExtent =
724 
725  m_mapDisplay1->getDraftPixmap()->fill(Qt::transparent);
726 
728  canvasInstance.setWindow( mapDisplayExtent.m_llx,
729  mapDisplayExtent.m_lly, mapDisplayExtent.m_urx,
730  mapDisplayExtent.m_ury );
731 
732  // Drawing the colected points
733 
734  const int rowCount =
735  m_uiPtr->m_tiePointsTableWidget->rowCount();
736  QTableWidgetItem* itemPtr = nullptr;
737  unsigned int tpID = 0;
738  TPContainerT::iterator tiePointsIt;
739  te::gm::Point auxPoint;
740  te::gm::Coord2D auxCoord2D;
741 
742  for( int row = 0 ; row < rowCount ; ++row )
743  {
744  itemPtr = m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
745 
746  if( itemPtr->isSelected() )
747  {
748  canvasInstance.setPointPattern( m_selectedPointPattern,
750  }
751  else
752  {
753  canvasInstance.setPointPattern( m_unselectedPointPattern,
755  }
756 
757  tpID = itemPtr->text().toUInt();
758 
759  tiePointsIt = m_tiePoints.find( tpID );
760  assert( tiePointsIt != m_tiePoints.end() );
761 
763  tiePointsIt->second.m_tiePoint.first.x, tiePointsIt->second.m_tiePoint.first.y,
764  auxCoord2D.x, auxCoord2D.y );
765 
766  auxPoint.setX( auxCoord2D.x );
767  auxPoint.setY( auxCoord2D.y );
768 
769  canvasInstance.draw( &auxPoint );
770  }
771 
772  // Drawing the selected temporary point
773 
775  {
778  auxCoord2D.x, auxCoord2D.y );
779 
780  auxPoint.setX( auxCoord2D.x );
781  auxPoint.setY( auxCoord2D.y );
782 
783  canvasInstance.setPointPattern( m_tempPointPattern,
785 
786  canvasInstance.draw( &auxPoint );
787  }
788  }
789 
791  {
792  const te::gm::Envelope& mapDisplayExtent =
794 
795  m_mapDisplay2->getDraftPixmap()->fill(Qt::transparent);
796 
798  canvasInstance.setWindow( mapDisplayExtent.m_llx,
799  mapDisplayExtent.m_lly, mapDisplayExtent.m_urx,
800  mapDisplayExtent.m_ury );
801 
802  // Drawing the colected points
803 
804  const int rowCount =
805  m_uiPtr->m_tiePointsTableWidget->rowCount();
806  QTableWidgetItem* itemPtr = nullptr;
807  unsigned int tpID = 0;
808  TPContainerT::iterator tiePointsIt;
809  te::gm::Point auxPoint;
810  te::gm::Coord2D auxCoord2D;
811 
812  for( int row = 0 ; row < rowCount ; ++row )
813  {
814  itemPtr = m_uiPtr->m_tiePointsTableWidget->item( row, 0 );
815 
816  if( itemPtr->isSelected() )
817  {
818  canvasInstance.setPointPattern( m_selectedPointPattern,
820  }
821  else
822  {
823  canvasInstance.setPointPattern( m_unselectedPointPattern,
825  }
826 
827  tpID = itemPtr->text().toUInt();
828 
829  tiePointsIt = m_tiePoints.find( tpID );
830  assert( tiePointsIt != m_tiePoints.end() );
831 
833  tiePointsIt->second.m_tiePoint.second.x, tiePointsIt->second.m_tiePoint.second.y,
834  auxCoord2D.x, auxCoord2D.y );
835 
836  auxPoint.setX( auxCoord2D.x );
837  auxPoint.setY( auxCoord2D.y );
838 
839  canvasInstance.draw( &auxPoint );
840  }
841  }
842  } // namespace qt
843  } // namespace qt
844 } // namespace te
845 
TiePointsLocatorDialogMDEventFilter * m_mDEventFilter1
Map display 1 event filter.
void refreshMapDisplay2()
Refresh map display 2.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
This class implements a concrete tool to geographic zoom operation using the left and right mouse cli...
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.
Definition: GTParameters.h:95
double y
y-coordinate.
Definition: Coord2D.h:114
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
Definition: RGBAColor.h:341
std::vector< unsigned int > m_inRaster2Bands
Bands to be used from the input raster 2.
A event filter to handle map display events.
unsigned int m_raster2TargetAreaLineStart
The first line of the raster 2 target area to process (default:0 - The entire raster will be consider...
double x
x-coordinate.
Definition: Coord2D.h:113
te::qt::widgets::MapDisplay * m_mapDisplay1
Map display 1.
te::rp::TiePointsLocator::InputParameters m_inputParameters
The current parameters.
void MapDisplay()
It retrieves data from a data source, create a set of layer and show map display. ...
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
unsigned int m_lastInsertedTPID
A ID counter for new tie pointes inserted into m_tiePoints;.
te::rst::Raster const * m_inRaster2Ptr
Input raster 2.
te::qt::widgets::MapDisplay * m_mapDisplay2
Map display 2.
void refreshMapDisplay1()
Refresh map display 1.
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.
A widget to control the display of a set of layers.
#define TPLDIALOG_P_PATTERN_W
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
CoordTracking * m_coordTracking2
Coord tracking (map display 2);.
te::qt::widgets::ZoomLeftAndRightClick * m_zoomClickEvent2
Zoom click event (map display 2).
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
te::color::RGBAColor ** m_tempPointPattern
The display draw pattern used for temporary points.
unsigned int line
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
unsigned int m_raster1TargetAreaHeight
The raster 1 target area height (default:0 - The entire raster will be considered).
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).
double m_llx
Lower left corner x-coordinate.
void tiePointsTableUpdate()
Uptate the tie-points table widget.
virtual void setResizePolicy(const ResizePolicy &policy)
Sets the resize policy to this map display.
A point with x and y coordinate values.
Definition: Point.h:50
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.
te::color::RGBAColor ** m_unselectedPointPattern
The display draw pattern used for unselected points.
std::vector< unsigned int > m_inRaster1Bands
Bands to be used from the input raster 1.
CoordTracking * m_coordTracking1
Coord tracking (map display 1);.
URI C++ Library.
Definition: Attributes.h:37
TiePointsLocatorDialogMDEventFilter * m_mDEventFilter2
Map display 2 event filter.
TiePointsLocatorAdvancedDialog * m_advDialogPtr
User interface.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
te::gm::GTParameters::TiePoint m_lastSelectedTiePoint
The last mouse tracked tie-point by pressing any key over the map areas.
Grid * getGrid()
It returns the raster grid.
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. ...
This class implements a concrete tool to geographic coordinate tracking on mouse move operation...
Definition: CoordTracking.h:52
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
TiePointAcquisitionType m_acqType
Acquisition type.
TiePointsLocator output parameters.
te::rst::Raster const * m_inRaster1Ptr
Input raster 1.
double m_lly
Lower left corner y-coordinate.
Tie points locator.
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.
unsigned int m_raster1TargetAreaWidth
The raster 1 target area width (default:0 - The entire raster will be considered).
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:145
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
unsigned int m_raster1TargetAreaLineStart
The first line of the raster 1 target area to process (default:0 - The entire raster will be consider...
te::rst::Raster * m_raster2
Input raster 1 pointer.
double m_ury
Upper right corner y-coordinate.
te::map::DataSetLayerPtr m_inLayer2Ptr
Input data set layer 1 pointer.
unsigned int m_raster2TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
unsigned int m_raster2TargetAreaHeight
The raster 2 target area height (default:0 - The entire raster will be considered).
A dialog used to execute tie points location advanced options.
boost::intrusive_ptr< DataSetLayer > DataSetLayerPtr
Definition: DataSetLayer.h:148
TiePointsLocatorDialogMDEventFilter(te::qt::widgets::MapDisplay *parent)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
bool m_lastSelectedTiePointHasFirstOk
true if the last selected tie-point has the first part set;
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
void getTiePoints(std::vector< te::gm::GTParameters::TiePoint > &tiePoints) const
Get the current acquired tie-points.
te::qt::widgets::ZoomLeftAndRightClick * m_zoomClickEvent1
Input raster 2 pointer.
2D Geometric transformation parameters.
Definition: GTParameters.h:50
std::string m_geomTransfName
The name of the geometric transformation used to ensure tie-points consistency (see each te::gm::GTFa...
te::gm::GTParameters::TiePoint m_lastTrackedTiePoint
The last mouse tracked tie-point by analysing the mouse move over the map areas.
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:159
te::rst::Raster * m_raster1
Input data set layer 2 pointer.
TPContainerT m_tiePoints
Internal tie-points container.
virtual void setSRID(const int &srid, bool doRefresh=true)
It sets a new Spatial Reference System to be used by the Map Display.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
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 dialog used to execute tie points location.
unsigned int m_raster1TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
unsigned int m_raster2TargetAreaWidth
The raster 2 target area width (default:0 - The entire raster will be considered).
te::color::RGBAColor ** m_selectedPointPattern
The display draw pattern used for selected points.
const TiePointData & operator=(const TiePointData &other)
unsigned int col
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
void transformationInfoUpdate()
Uptate the current transformation information widgets.
te::gm::GTParameters::TiePoint m_tiePoint
Tie point coordinates.