-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScalarDialog.cpp
More file actions
144 lines (129 loc) · 3.99 KB
/
ScalarDialog.cpp
File metadata and controls
144 lines (129 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//##########################################################################
//# #
//# CLOUDCOMPARE PLUGIN: ColorimetricSegmenter #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: Tri-Thien TRUONG, Ronan COLLIER, Mathieu LETRONE #
//# #
//##########################################################################
#include "ScalarDialog.h"
//common
#include <ccPickingHub.h>
#include <ccGenericPointCloud.h>
//Qt
#include <QCheckBox>
ScalarDialog::ScalarDialog(ccPickingHub* pickingHub, QWidget* parent)
: QDialog(parent)
, Ui::ScalarDialog()
, m_pickingHub(pickingHub)
{
assert(pickingHub);
setModal(false);
setupUi(this);
//Link between Ui and actions
connect(pointPickingButton_first, &QCheckBox::toggled, this, &ScalarDialog::pickPoint_first);
connect(pointPickingButton_second, &QCheckBox::toggled, this, &ScalarDialog::pickPoint_second);
//auto disable picking mode on quit
connect(this, &QDialog::finished, [&]()
{
if (pointPickingButton_first->isChecked()) pointPickingButton_first->setChecked(false);
if (pointPickingButton_second->isChecked()) pointPickingButton_second->setChecked(false);
}
);
}
/*
Method for the first picking point functionnality
*/
void ScalarDialog::pickPoint_first(bool state)
{
if (!m_pickingHub)
{
return;
}
if (state)
{
if (!m_pickingHub->addListener(this, true))
{
ccLog::Error("Can't start the picking process (another tool is using it)");
state = false;
}
}
else
{
m_pickingHub->removeListener(this);
}
pointPickingButton_first->blockSignals(true);
pointPickingButton_first->setChecked(state);
pointPickingButton_first->blockSignals(false);
}
/*
Method for the second picking point functionnality
*/
void ScalarDialog::pickPoint_second(bool state)
{
if (!m_pickingHub)
{
return;
}
if (state)
{
if (!m_pickingHub->addListener(this, true))
{
ccLog::Error("Can't start the picking process (another tool is using it)");
state = false;
}
}
else
{
m_pickingHub->removeListener(this);
}
pointPickingButton_second->blockSignals(true);
pointPickingButton_second->setChecked(state);
pointPickingButton_second->blockSignals(false);
}
/*
Method applied after a point is picked by picking point functionnality
*/
void ScalarDialog::onItemPicked(const PickedItem& pi)
{
if (!pi.entity || !m_pickingHub)
{
return;
}
if (pi.entity->isKindOf(CC_TYPES::POINT_CLOUD))
{
ccGenericPointCloud* cloud = static_cast<ccGenericPointCloud*>(pi.entity);
if (cloud->hasDisplayedScalarField())
{
//Get the scalar value of the picked point
const ScalarType scalarValue = cloud->getPointScalarValue(pi.itemIndex);
ccLog::Print(QString("%0 point picked: %1 - SF value = %2")
.arg(pointPickingButton_first->isChecked() ? "First" : "Second")
.arg(pi.itemIndex)
.arg(scalarValue)
);
if (pointPickingButton_first->isChecked())
{
first->setValue(scalarValue);
pointPickingButton_first->setChecked(false);
}
else
{
second->setValue(scalarValue);
pointPickingButton_second->setChecked(false);
}
}
else
{
ccLog::Print("This point cloud doesn't have an active scalar field");
}
}
}