ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvScaleDlg.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "ecvScaleDlg.h"
9 
10 // semi persistent parameters
11 static CCVector3d s_lastScales(1.0, 1.0, 1.0);
12 static bool s_allAtOnce = true;
13 static bool s_keepInPlace = false;
14 static bool s_rescaleGlobalShift = true;
15 
16 ccScaleDlg::ccScaleDlg(QWidget* parent /*=0*/)
17  : QDialog(parent), Ui::ScaleDialog() {
18  setupUi(this);
19 
20  connect(sameForAllCheckBox, &QCheckBox::toggled, this,
22  connect(fxSpinBox,
23  static_cast<void (QDoubleSpinBox::*)(double)>(
24  &QDoubleSpinBox::valueChanged),
25  this, &ccScaleDlg::fxUpdated);
26 
27  // restore semi-persistent parameters
28  sameForAllCheckBox->setChecked(s_allAtOnce);
29  keepInPlaceCheckBox->setChecked(s_keepInPlace);
30  rescaleGlobalShiftCheckBox->setChecked(s_rescaleGlobalShift);
31  fzSpinBox->setValue(s_lastScales.z);
32  fySpinBox->setValue(s_lastScales.y);
33  fxSpinBox->setValue(
34  s_lastScales.x); // always last in case 'same for all' is checked!
35 }
36 
38  s_allAtOnce = sameForAllCheckBox->isChecked();
42 }
43 
44 void ccScaleDlg::fxUpdated(double val) {
45  if (sameForAllCheckBox->isChecked()) {
46  fySpinBox->setValue(val);
47  fzSpinBox->setValue(val);
48  }
49 }
50 
52  return CCVector3d(fxSpinBox->value(), fySpinBox->value(),
53  fzSpinBox->value());
54 }
55 
57  return keepInPlaceCheckBox->isChecked();
58 }
59 
61  return rescaleGlobalShiftCheckBox->isChecked();
62 }
63 
65  if (state) {
66  fySpinBox->setValue(fxSpinBox->value());
67  fzSpinBox->setValue(fxSpinBox->value());
68  }
69  fySpinBox->setEnabled(!state);
70  fzSpinBox->setEnabled(!state);
71 }
Vector3Tpl< double > CCVector3d
Double 3D Vector.
Definition: CVGeom.h:804
Type y
Definition: CVGeom.h:137
Type x
Definition: CVGeom.h:137
Type z
Definition: CVGeom.h:137
void saveState()
Saves state.
Definition: ecvScaleDlg.cpp:37
bool keepInPlace() const
Whether the entity should be 'kept in place' or not.
Definition: ecvScaleDlg.cpp:56
ccScaleDlg(QWidget *parent=0)
Default constructor.
Definition: ecvScaleDlg.cpp:16
void fxUpdated(double)
Definition: ecvScaleDlg.cpp:44
bool rescaleGlobalShift() const
Whether the Global shift should be rescaled as well.
Definition: ecvScaleDlg.cpp:60
CCVector3d getScales() const
Returns scales.
Definition: ecvScaleDlg.cpp:51
void allDimsAtOnceToggled(bool)
Definition: ecvScaleDlg.cpp:64
static bool s_keepInPlace
Definition: ecvScaleDlg.cpp:13
static CCVector3d s_lastScales(1.0, 1.0, 1.0)
static bool s_allAtOnce
Definition: ecvScaleDlg.cpp:12
static bool s_rescaleGlobalShift
Definition: ecvScaleDlg.cpp:14