ccMatchScalesDlg.cpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #include "ccMatchScalesDlg.h"
  18. //Qt
  19. #include <QListWidgetItem>
  20. #include <QDoubleValidator>
  21. //system
  22. #include <assert.h>
  23. ccMatchScalesDlg::ccMatchScalesDlg( const ccHObject::Container& entities,
  24. int defaultSelectedIndex/*=0*/,
  25. QWidget* parent/*=nullptr*/)
  26. : QDialog(parent, Qt::Tool)
  27. , Ui::MatchScalesDialog()
  28. {
  29. setupUi(this);
  30. for (size_t i=0; i<entities.size(); ++i)
  31. {
  32. //add one line per entity in the combo-box
  33. listWidget->insertItem(static_cast<int>(i), new QListWidgetItem(QString("%1 (ID=%2)").arg(entities[i]->getName()).arg(entities[i]->getUniqueID())));
  34. }
  35. //default selection
  36. if (defaultSelectedIndex >= 0 && static_cast<size_t>(defaultSelectedIndex) < entities.size())
  37. listWidget->setItemSelected(listWidget->item(defaultSelectedIndex),true);
  38. rmsDifferenceLineEdit->setValidator(new QDoubleValidator(rmsDifferenceLineEdit));
  39. }
  40. int ccMatchScalesDlg::getSelectedIndex() const
  41. {
  42. //get selected items
  43. QList<QListWidgetItem*> list = listWidget->selectedItems();
  44. return list.empty() ? -1 : listWidget->row(list.front());
  45. }
  46. void ccMatchScalesDlg::setSelectedAlgorithm(ccLibAlgorithms::ScaleMatchingAlgorithm algorithm)
  47. {
  48. switch(algorithm)
  49. {
  50. case ccLibAlgorithms::BB_MAX_DIM:
  51. bbMaxDimRadioButton->setChecked(true);
  52. return;
  53. case ccLibAlgorithms::BB_VOLUME:
  54. bbVolumeRadioButton->setChecked(true);
  55. return;
  56. case ccLibAlgorithms::PCA_MAX_DIM:
  57. pcaRadioButton->setChecked(true);
  58. return;
  59. case ccLibAlgorithms::ICP_SCALE:
  60. icpRadioButton->setChecked(true);
  61. return;
  62. default:
  63. assert(false);
  64. break;
  65. }
  66. }
  67. ccLibAlgorithms::ScaleMatchingAlgorithm ccMatchScalesDlg::getSelectedAlgorithm() const
  68. {
  69. if (bbMaxDimRadioButton->isChecked())
  70. {
  71. return ccLibAlgorithms::BB_MAX_DIM;
  72. }
  73. else if (bbVolumeRadioButton->isChecked())
  74. {
  75. return ccLibAlgorithms::BB_VOLUME;
  76. }
  77. else if (pcaRadioButton->isChecked())
  78. {
  79. return ccLibAlgorithms::PCA_MAX_DIM;
  80. }
  81. else if (icpRadioButton->isChecked())
  82. {
  83. return ccLibAlgorithms::ICP_SCALE;
  84. }
  85. assert(false);
  86. return ccLibAlgorithms::PCA_MAX_DIM;
  87. }