ccOrthoSectionGenerationDlg.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "ccOrthoSectionGenerationDlg.h"
  18. //system
  19. #include <cmath>
  20. ccOrthoSectionGenerationDlg::ccOrthoSectionGenerationDlg(QWidget* parent/*=nullptr*/)
  21. : QDialog(parent, Qt::Tool)
  22. , Ui::OrthoSectionGenerationDlg()
  23. , m_pathLength(0)
  24. {
  25. setupUi(this);
  26. connect(stepDoubleSpinBox, qOverload<double> (&QDoubleSpinBox::valueChanged), this, &ccOrthoSectionGenerationDlg::onStepChanged);
  27. }
  28. void ccOrthoSectionGenerationDlg::setPathLength(double l)
  29. {
  30. m_pathLength = l;
  31. pathLengthLineEdit->setText(QString::number(l));
  32. stepDoubleSpinBox->setValue(l/9);
  33. widthDoubleSpinBox->setValue(l/5);
  34. }
  35. void ccOrthoSectionGenerationDlg::setAutoSaveAndRemove(bool state)
  36. {
  37. autoSaveAndRemoveCheckBox->setChecked(state);
  38. }
  39. bool ccOrthoSectionGenerationDlg::autoSaveAndRemove() const
  40. {
  41. return autoSaveAndRemoveCheckBox->isChecked();
  42. }
  43. void ccOrthoSectionGenerationDlg::setGenerationStep(double s)
  44. {
  45. stepDoubleSpinBox->setValue(s);
  46. }
  47. void ccOrthoSectionGenerationDlg::setSectionsWidth(double w)
  48. {
  49. widthDoubleSpinBox->setValue(w);
  50. }
  51. double ccOrthoSectionGenerationDlg::getGenerationStep() const
  52. {
  53. return stepDoubleSpinBox->value();
  54. }
  55. double ccOrthoSectionGenerationDlg::getSectionsWidth() const
  56. {
  57. return widthDoubleSpinBox->value();
  58. }
  59. void ccOrthoSectionGenerationDlg::onStepChanged(double step)
  60. {
  61. if (step < 0)
  62. return;
  63. unsigned count = step < 1.0e-6 ? 1 : 1 + static_cast<unsigned>(m_pathLength / step); //static_cast is equivalent to floor if value >= 0
  64. sectionCountLineEdit->setText(QString::number(count));
  65. }