50 #include "QtPrincipalAxisDialog.hh" 64 static Vec4f byte2float(
unsigned char r,
unsigned char g,
unsigned char b) {
65 return Vec4f(r/255.0, g/255.0, b/255.0, 1.0);
68 static float colorSchemeDistance(
const QtPrincipalAxisDialog::ColorScheme a,
69 const QtPrincipalAxisDialog::ColorScheme b) {
72 for (
int i = 0; i < 3; ++i) {
73 result += (a[i] - b[i]).norm();
79 const QtPrincipalAxisDialog::ColorScheme QtPrincipalAxisDialog::color_schemes_[3] = {
80 { byte2float(232, 28, 23), byte2float(0, 110, 225), byte2float(0, 179, 0) },
81 { byte2float(26, 178, 0), byte2float(17, 0, 255), byte2float(204, 77, 0) },
82 { byte2float(255, 53, 139), byte2float(1, 176, 240), byte2float(174, 238, 0) },
84 static const size_t N_COLOR_SCHEMES = 3;
87 QtPrincipalAxisDialog::
103 if( pnode_.draw_style_ == PrincipalAxisNode::DS_3D)
104 drawStyle3D->setChecked(
true);
106 drawStyle2D->setChecked(
true);
108 if( pnode_.color_mode_ == PrincipalAxisNode::CM_Axis)
109 colorModeAxis->setChecked(
true);
111 colorModeSign->setChecked(
true);
113 showTensor1->setChecked( pnode_.show_tensor_component_[0] > 0);
114 showTensor2->setChecked( pnode_.show_tensor_component_[1] > 0);
115 showTensor3->setChecked( pnode_.show_tensor_component_[2] > 0);
117 showTensor1B->setChecked( pnode_.show_tensor_component_[0] > 1);
118 showTensor2B->setChecked( pnode_.show_tensor_component_[1] > 1);
119 showTensor3B->setChecked( pnode_.show_tensor_component_[2] > 1);
123 maxDrawRadius->setText(d.setNum(pnode_.max_draw_radius_));
124 minDrawRadius->setText(d.setNum(pnode_.min_draw_radius_));
125 radiusScale->setText (d.setNum(pnode_.cylinder_radius_scale_));
126 minSpacing->setText (d.setNum(pnode_.min_spacing_));
129 pnode_.get_axes_colors(cs);
138 QtPrincipalAxisDialog::
142 if( drawStyle3D->isChecked() )
143 pnode_.draw_style_ = PrincipalAxisNode::DS_3D;
145 pnode_.draw_style_ = PrincipalAxisNode::DS_2D;
148 if( colorModeAxis->isChecked())
149 pnode_.color_mode_ = PrincipalAxisNode::CM_Axis;
151 pnode_.color_mode_ = PrincipalAxisNode::CM_Sign;
155 pnode_.show_tensor_component_[0] = showTensor1->isChecked();
156 pnode_.show_tensor_component_[1] = showTensor2->isChecked();
157 pnode_.show_tensor_component_[2] = showTensor3->isChecked();
160 if( showTensor1B->isChecked())
161 pnode_.show_tensor_component_[0] = 2;
162 if( showTensor2B->isChecked())
163 pnode_.show_tensor_component_[1] = 2;
164 if( showTensor3B->isChecked())
165 pnode_.show_tensor_component_[2] = 2;
168 pnode_.max_draw_radius_ = maxDrawRadius->text().toDouble();
169 pnode_.min_draw_radius_ = minDrawRadius->text().toDouble();
170 pnode_.cylinder_radius_scale_ = radiusScale->text().toDouble();
171 pnode_.min_spacing_ = minSpacing->text().toDouble();
173 pnode_.set_axes_colors(getSelectedColorScheme());
175 pnode_.auto_update_range();
183 QtPrincipalAxisDialog::
195 QtPrincipalAxisDialog::
201 const QtPrincipalAxisDialog::ColorScheme &QtPrincipalAxisDialog::getSelectedColorScheme() {
202 if (colorscheme_1_rb->isChecked()) {
203 return color_schemes_[0];
204 }
else if (colorscheme_2_rb->isChecked()) {
205 return color_schemes_[1];
206 }
else if (colorscheme_3_rb->isChecked()) {
207 return color_schemes_[2];
210 return color_schemes_[0];
214 void QtPrincipalAxisDialog::setColorScheme(ColorScheme cs) {
215 float best_match = std::numeric_limits<float>::infinity();
216 size_t best_match_i = std::numeric_limits<size_t>::max();
218 for (
size_t i = 0; i < N_COLOR_SCHEMES; ++i) {
219 float match = colorSchemeDistance(cs, color_schemes_[i]);
220 if (match < best_match) {
226 switch (best_match_i) {
228 colorscheme_1_rb->setChecked(
true);
231 colorscheme_2_rb->setChecked(
true);
234 colorscheme_3_rb->setChecked(
true);
Namespace providing different geometric functions concerning angles.
VectorT< float, 4 > Vec4f