Skip to content

Commit 1f86b97

Browse files
Fix CropReturn Dialog logic and behavior
See internal merge request 100
2 parents 0ab00a9 + 9a4d11c commit 1f86b97

File tree

11 files changed

+143
-100
lines changed

11 files changed

+143
-100
lines changed

VelodyneHDL/Testing/TestReader.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ bool testPointCount(vtkSmartPointer<vtkPolyData>& frame, std::istream& is)
135135
//-----------------------------------------------------------------------------
136136
bool testCropSettings(vtkSmartPointer<vtkPolyData>& frame, std::istream& is)
137137
{
138-
bool cropEnabled, cropInside;
138+
bool cropEnabled, cropOutside;
139139
double ptcropregion[6];
140-
is >> cropEnabled >> cropInside;
140+
is >> cropEnabled >> cropOutside;
141141
for(int i = 0; i < 6; ++i)
142142
{
143143
is >> ptcropregion[i];
144144
}
145145

146146
reader->SetCropReturns(cropEnabled);
147-
reader->SetCropInside(cropInside);
147+
reader->SetCropOutside(cropOutside);
148148
reader->SetCropRegion(ptcropregion);
149149

150150
return true;

VelodyneHDL/python/veloview/applogic.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ def onCropReturns(show = True):
16151615
dialog = vvCropReturnsDialog(getMainWindow())
16161616

16171617
cropEnabled = False
1618-
cropInside = False
1618+
cropOutside = False
16191619
firstCorner = QtGui.QVector3D()
16201620
secondCorner = QtGui.QVector3D()
16211621

@@ -1624,29 +1624,35 @@ def onCropReturns(show = True):
16241624

16251625
if reader is not None:
16261626
cropEnabled = reader.CropReturns
1627-
cropInside = reader.CropInside
1627+
cropOutside = reader.CropOutside
16281628
firstCorner = QtGui.QVector3D(reader.CropRegion[0], reader.CropRegion[2], reader.CropRegion[4])
16291629
secondCorner = QtGui.QVector3D(reader.CropRegion[1], reader.CropRegion[3], reader.CropRegion[5])
16301630

16311631
if sensor is not None:
16321632
cropEnabled = sensor.CropReturns
1633-
cropInside = sensor.CropInside
1633+
cropOutside = sensor.CropOutside
16341634
firstCorner = QtGui.QVector3D(sensor.CropRegion[0], sensor.CropRegion[2], sensor.CropRegion[4])
16351635
secondCorner = QtGui.QVector3D(sensor.CropRegion[1], sensor.CropRegion[3], sensor.CropRegion[5])
16361636

16371637
#show the dialog box
16381638
if show:
1639-
dialog.croppingEnabled = cropEnabled
1640-
dialog.cropInside = cropInside
1639+
dialog.cropOutside = cropOutside
16411640
dialog.firstCorner = firstCorner
16421641
dialog.secondCorner = secondCorner
1642+
dialog.croppingEnabled = cropEnabled
1643+
# Enforce the call to dialog.croppingEnabled."onChanged" even if dialog.croppingEnabled == cropEnabled
1644+
dialog.croppingEnabled = not dialog.croppingEnabled
1645+
dialog.croppingEnabled = not dialog.croppingEnabled
1646+
1647+
# update the dialog configuration
1648+
dialog.UpdateDialogWithCurrentSetting()
16431649

16441650
if not dialog.exec_():
16451651
return
16461652

16471653
if reader is not None:
16481654
reader.CropReturns = dialog.croppingEnabled
1649-
reader.CropInside = dialog.cropInside
1655+
reader.CropOutside = dialog.cropOutside
16501656
reader.GetClientSideObject().SetCropMode(dialog.GetCropMode())
16511657
p1 = dialog.firstCorner
16521658
p2 = dialog.secondCorner
@@ -1656,7 +1662,7 @@ def onCropReturns(show = True):
16561662

16571663
if sensor is not None:
16581664
sensor.CropReturns = dialog.croppingEnabled
1659-
sensor.CropInside = dialog.cropInside
1665+
sensor.CropOutside = dialog.cropOutside
16601666
p1 = dialog.firstCorner
16611667
p2 = dialog.secondCorner
16621668
sensor.CropRegion = [p1.x(), p2.x(), p1.y(), p2.y(), p1.z(), p2.z()]

VelodyneHDL/vtkVelodyneHDLReader.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class vtkVelodyneHDLReader::vtkInternal
374374
this->ApplyTransform = 0;
375375
this->PointsSkip = 0;
376376
this->CropReturns = false;
377-
this->CropInside = false;
377+
this->CropOutside = false;
378378
this->CropRegion[0] = this->CropRegion[1] = 0.0;
379379
this->CropRegion[2] = this->CropRegion[3] = 0.0;
380380
this->CropRegion[4] = this->CropRegion[5] = 0.0;
@@ -485,7 +485,7 @@ class vtkVelodyneHDLReader::vtkInternal
485485
bool UseIntraFiringAdjustment;
486486

487487
bool CropReturns;
488-
bool CropInside;
488+
bool CropOutside;
489489
bool AlreadyWarnAboutCalibration;
490490
double CropRegion[6];
491491
double distanceResolutionM;
@@ -812,11 +812,11 @@ void vtkVelodyneHDLReader::SetCropReturns(int crop)
812812
}
813813

814814
//-----------------------------------------------------------------------------
815-
void vtkVelodyneHDLReader::SetCropInside(int crop)
815+
void vtkVelodyneHDLReader::SetCropOutside(int crop)
816816
{
817-
if (!this->Internal->CropInside == !!crop)
817+
if (!this->Internal->CropOutside == !!crop)
818818
{
819-
this->Internal->CropInside = !!crop;
819+
this->Internal->CropOutside = !!crop;
820820
this->Modified();
821821
}
822822
}
@@ -1335,8 +1335,8 @@ bool vtkVelodyneHDLReader::vtkInternal::shouldBeCroppedOut(double pos[3],double
13351335
bool pointOutsideOfBox = pos[0] >= this->CropRegion[0] && pos[0] <= this->CropRegion[1] &&
13361336
pos[1] >= this->CropRegion[2] && pos[1] <= this->CropRegion[3] &&
13371337
pos[2] >= this->CropRegion[4] && pos[2] <= this->CropRegion[5];
1338-
return ((pointOutsideOfBox && !this->CropInside) ||
1339-
(!pointOutsideOfBox && this->CropInside));
1338+
return ((pointOutsideOfBox && this->CropOutside) ||
1339+
(!pointOutsideOfBox && !this->CropOutside));
13401340
break;
13411341
}
13421342
case Spherical:
@@ -1354,8 +1354,8 @@ bool vtkVelodyneHDLReader::vtkInternal::shouldBeCroppedOut(double pos[3],double
13541354
pointInsideOfBounds = (theta >= this->CropRegion[0] || theta <= this->CropRegion[1]) &&
13551355
R >= this->CropRegion[4] && R <= this->CropRegion[5];
13561356
}
1357-
return ((pointInsideOfBounds && !this->CropInside) ||
1358-
(!pointInsideOfBounds && this->CropInside));
1357+
return ((pointInsideOfBounds && this->CropOutside) ||
1358+
(!pointInsideOfBounds && !this->CropOutside));
13591359
break;
13601360
}
13611361
case Cylindric:

VelodyneHDL/vtkVelodyneHDLReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class VTK_EXPORT vtkVelodyneHDLReader : public vtkPolyDataAlgorithm
135135
void SetPointsSkip(int);
136136

137137
void SetCropReturns(int);
138-
void SetCropInside(int);
138+
void SetCropOutside(int);
139139
void SetCropRegion(double[6]);
140140
void SetCropRegion(double, double, double, double, double, double);
141141
void SetCropMode(int cropMode);

VelodyneHDL/vtkVelodyneHDLSource.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,11 @@ void vtkVelodyneHDLSource::SetCropReturns(int cr)
953953
}
954954

955955
//-----------------------------------------------------------------------------
956-
void vtkVelodyneHDLSource::SetCropInside(int ci)
956+
void vtkVelodyneHDLSource::SetCropOutside(int ci)
957957
{
958958
boost::lock_guard<boost::mutex> lock(this->Internal->Consumer->ReaderMutex);
959959

960-
this->Internal->Consumer->GetReader()->SetCropInside(ci);
960+
this->Internal->Consumer->GetReader()->SetCropOutside(ci);
961961
this->Modified();
962962
}
963963

VelodyneHDL/vtkVelodyneHDLSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class VTK_EXPORT vtkVelodyneHDLSource : public vtkPolyDataAlgorithm
9090
double GetDistanceResolutionM();
9191

9292
void SetCropReturns(int);
93-
void SetCropInside(int);
93+
void SetCropOutside(int);
9494
void SetCropRegion(double[6]);
9595
void SetCropRegion(double, double, double, double, double, double);
9696

VelodyneHDL/vvCropReturnsDialog.cxx

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ void vvCropReturnsDialog::pqInternal::saveSettings()
6969
this->CropGroupBox->isChecked());
7070

7171
this->Settings->setValue(
72-
"VelodyneHDLPlugin/CropReturnsDialog/CropInside",
73-
this->CropInsideCheckBox->isChecked());
72+
"VelodyneHDLPlugin/CropReturnsDialog/CropOutside",
73+
this->CropOutsideCheckBox->isChecked());
7474

7575
this->Settings->setValue(
7676
"VelodyneHDLPlugin/CropReturnsDialog/FirstCornerX",
@@ -120,10 +120,10 @@ void vvCropReturnsDialog::pqInternal::restoreSettings()
120120
"VelodyneHDLPlugin/CropReturnsDialog/EnableCropping",
121121
false).toBool());
122122

123-
this->CropInsideCheckBox->setChecked(
123+
this->CropOutsideCheckBox->setChecked(
124124
this->Settings->value(
125-
"VelodyneHDLPlugin/CropReturnsDialog/CropInside",
126-
this->CropInsideCheckBox->isChecked()).toBool());
125+
"VelodyneHDLPlugin/CropReturnsDialog/CropOutside",
126+
this->CropOutsideCheckBox->isChecked()).toBool());
127127

128128
this->X1SpinBox->setValue (
129129
this->Settings->value(
@@ -193,9 +193,10 @@ vvCropReturnsDialog::vvCropReturnsDialog(QWidget *p)
193193
connect(this->Internal->noneRadioButton,SIGNAL(clicked()),this,SLOT(onNoneToggled()));
194194
connect(this->Internal->cartesianRadioButton,SIGNAL(clicked()),this,SLOT(onCartesianToggled()));
195195
connect(this->Internal->sphericalRadioButton,SIGNAL(clicked()),this,SLOT(onSphericalToggled()));
196+
connect(this->Internal->CropGroupBox, SIGNAL(clicked()), this, SLOT(onCropGroupBoxToggled()));
196197

197-
// Without configuration file, the none mode is set by default
198-
this->Internal->noneRadioButton->setChecked(true);
198+
// Without configuration file, the cartesian mode is set by default
199+
this->Internal->cartesianRadioButton->setChecked(true);
199200
this->Internal->restoreSettings();
200201
}
201202

@@ -217,15 +218,15 @@ void vvCropReturnsDialog::setCroppingEnabled(bool checked)
217218
}
218219

219220
//-----------------------------------------------------------------------------
220-
bool vvCropReturnsDialog::cropInside() const
221+
bool vvCropReturnsDialog::cropOutside() const
221222
{
222-
return this->Internal->CropInsideCheckBox->isChecked();
223+
return this->Internal->CropOutsideCheckBox->isChecked();
223224
}
224225

225226
//-----------------------------------------------------------------------------
226-
void vvCropReturnsDialog::setCropInside(bool checked)
227+
void vvCropReturnsDialog::setCropOutside(bool checked)
227228
{
228-
this->Internal->CropInsideCheckBox->setChecked(checked);
229+
this->Internal->CropOutsideCheckBox->setChecked(checked);
229230
}
230231

231232
//-----------------------------------------------------------------------------
@@ -330,9 +331,9 @@ void vvCropReturnsDialog::pqInternal::SetSphericalSettings()
330331
this->ActivateSpinBox();
331332
// change the labels
332333
// list of unicode symbol : http://sites.psu.edu/symbolcodes/languages/ancient/greek/greekchart/
333-
this->XLabel->setText(QString("theta ") + QString((QChar)0x03b8)); // theta symbol
334-
this->YLabel->setText(QString("phi ") + QString((QChar)0x03c6)); //phi symbol
335-
this->ZLabel->setText("R");
334+
this->XLabel->setText("Rotational angle");
335+
this->YLabel->setText("Vertical angle");
336+
this->ZLabel->setText("Distance");
336337

337338
// Here we take the spherical coordinates used in mathematics (and not physic)
338339
// (r,theta,phi)
@@ -354,15 +355,9 @@ void vvCropReturnsDialog::pqInternal::SetSphericalSettings()
354355
this->Z1SpinBox->setMinimum(0);
355356
this->Z2SpinBox->setMinimum(0);
356357
this->ZDoubleRangeSlider.setMinimum(0);
357-
this->Z1SpinBox->setMaximum(1000);
358-
this->Z2SpinBox->setMaximum(1000);
359-
this->ZDoubleRangeSlider.setMaximum(1000);
360-
361-
// Hide phi selection since the laser
362-
// selection does almost the same thing
363-
this->Y1SpinBox->setDisabled(true);
364-
this->Y2SpinBox->setDisabled(true);
365-
this->YDoubleRangeSlider.setDisabled(true);
358+
this->Z1SpinBox->setMaximum(120);
359+
this->Z2SpinBox->setMaximum(120);
360+
this->ZDoubleRangeSlider.setMaximum(120);
366361
}
367362

368363
//-----------------------------------------------------------------------------
@@ -382,7 +377,7 @@ void vvCropReturnsDialog::pqInternal::SetCartesianSettings()
382377
this->XDoubleRangeSlider.setMinimum(minV);
383378
this->X1SpinBox->setMaximum(maxV);
384379
this->X2SpinBox->setMaximum(maxV);
385-
this->XDoubleRangeSlider.setMaximumValue(maxV);
380+
this->XDoubleRangeSlider.setMaximum(maxV);
386381
// Y [-10000,10000]
387382
this->Y1SpinBox->setMinimum(minV);
388383
this->Y2SpinBox->setMinimum(minV);
@@ -397,19 +392,13 @@ void vvCropReturnsDialog::pqInternal::SetCartesianSettings()
397392
this->Z1SpinBox->setMaximum(maxV);
398393
this->Z2SpinBox->setMaximum(maxV);
399394
this->ZDoubleRangeSlider.setMaximum(maxV);
400-
401-
// Activate the Y SpinBox since the Spherical
402-
// settings desactivate it
403-
this->Y1SpinBox->setDisabled(false);
404-
this->Y2SpinBox->setDisabled(false);
405-
this->YDoubleRangeSlider.setDisabled(false);
406395
}
407396

408397
//-----------------------------------------------------------------------------
409398
void vvCropReturnsDialog::onNoneToggled()
410399
{
411400
this->Internal->DesactivateSpinBox();
412-
this->Internal->CropInsideCheckBox->setChecked(false);
401+
this->Internal->CropOutsideCheckBox->setChecked(false);
413402
}
414403

415404
//-----------------------------------------------------------------------------
@@ -458,7 +447,7 @@ void vvCropReturnsDialog::pqInternal::ActivateSpinBox()
458447
this->YDoubleRangeSlider.setDisabled(false);
459448
this->ZDoubleRangeSlider.setDisabled(false);
460449

461-
this->CropInsideCheckBox->setDisabled(false);
450+
this->CropOutsideCheckBox->setDisabled(false);
462451
}
463452

464453
//-----------------------------------------------------------------------------
@@ -569,7 +558,7 @@ void vvCropReturnsDialog::pqInternal::DesactivateSpinBox()
569558
this->YDoubleRangeSlider.setDisabled(true);
570559
this->ZDoubleRangeSlider.setDisabled(true);
571560

572-
this->CropInsideCheckBox->setDisabled(true);
561+
this->CropOutsideCheckBox->setDisabled(true);
573562
}
574563

575564
//-----------------------------------------------------------------------------
@@ -644,4 +633,32 @@ void vvCropReturnsDialog::pqInternal::updateRangeValues(bool isSliderMode)
644633
void vvCropReturnsDialog::onSpinBoxChanged(double value)
645634
{
646635
this->Internal->updateRangeValues(false);
636+
}
637+
638+
//-----------------------------------------------------------------------------
639+
void vvCropReturnsDialog::onCropGroupBoxToggled()
640+
{
641+
this->Internal->X1SpinBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
642+
this->Internal->X2SpinBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
643+
this->Internal->Y1SpinBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
644+
this->Internal->Y2SpinBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
645+
this->Internal->Z1SpinBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
646+
this->Internal->Z2SpinBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
647+
this->Internal->XDoubleRangeSlider.setDisabled(!this->Internal->CropGroupBox->isChecked());
648+
this->Internal->YDoubleRangeSlider.setDisabled(!this->Internal->CropGroupBox->isChecked());
649+
this->Internal->ZDoubleRangeSlider.setDisabled(!this->Internal->CropGroupBox->isChecked());
650+
this->Internal->noneRadioButton->setDisabled(!this->Internal->CropGroupBox->isChecked());
651+
this->Internal->cartesianRadioButton->setDisabled(!this->Internal->CropGroupBox->isChecked());
652+
this->Internal->sphericalRadioButton->setDisabled(!this->Internal->CropGroupBox->isChecked());
653+
this->Internal->CropOutsideCheckBox->setDisabled(!this->Internal->CropGroupBox->isChecked());
654+
}
655+
656+
//-----------------------------------------------------------------------------
657+
void vvCropReturnsDialog::UpdateDialogWithCurrentSetting()
658+
{
659+
this->onCropGroupBoxToggled();
660+
if (this->Internal->noneRadioButton->isChecked())
661+
{
662+
this->onNoneToggled();
663+
}
647664
}

VelodyneHDL/vvCropReturnsDialog.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,29 @@ class VelodyneHDLPlugin_EXPORT vvCropReturnsDialog : public QDialog
2323
{
2424
Q_OBJECT
2525
Q_PROPERTY(bool croppingEnabled READ croppingEnabled WRITE setCroppingEnabled)
26-
Q_PROPERTY(bool cropInside READ cropInside WRITE setCropInside)
26+
Q_PROPERTY(bool cropOutside READ cropOutside WRITE setCropOutside)
2727
Q_PROPERTY(QVector3D firstCorner READ firstCorner WRITE setFirstCorner)
2828
Q_PROPERTY(QVector3D secondCorner READ secondCorner WRITE setSecondCorner)
29+
Q_PROPERTY(QVector3D secondCorner READ secondCorner WRITE setSecondCorner)
2930

3031
public:
3132
vvCropReturnsDialog(QWidget *p=0);
3233
virtual ~vvCropReturnsDialog();
3334

3435
bool croppingEnabled() const;
35-
bool cropInside() const;
36+
bool cropOutside() const;
3637

3738
void setCroppingEnabled(bool);
38-
void setCropInside(bool);
39+
void setCropOutside(bool);
3940

4041
QVector3D firstCorner() const;
4142
QVector3D secondCorner() const;
4243

4344
void setFirstCorner(QVector3D);
4445
void setSecondCorner(QVector3D);
4546

47+
Q_INVOKABLE void UpdateDialogWithCurrentSetting();
48+
4649
Q_INVOKABLE int GetCropMode() const;
4750

4851
public slots:
@@ -51,6 +54,7 @@ public slots:
5154
void onCartesianToggled();
5255
void onSphericalToggled();
5356
void onSliderBoxToggled();
57+
void onCropGroupBoxToggled();
5458
void onSpinBoxChanged(double value);
5559
void onXSliderChanged(double vmin, double vmax);
5660
void onYSliderChanged(double vmin, double vmax);

0 commit comments

Comments
 (0)