mirror of https://github.com/CGAL/cgal
WIP Replace all double spin box. Remove resetRampButton as it hase become useless at some point.
This commit is contained in:
parent
d76a984aee
commit
3b54dc2f92
|
|
@ -2,13 +2,36 @@
|
||||||
|
|
||||||
#include <QDoubleValidator>
|
#include <QDoubleValidator>
|
||||||
|
|
||||||
DoubleEdit::DoubleEdit(QWidget* parent = nullptr)
|
DoubleEdit::DoubleEdit(QWidget *parent)
|
||||||
: QLineEdit(parent)
|
: QLineEdit()
|
||||||
{
|
{
|
||||||
QDoubleValidator* validator = new QDoubleValidator(parent);
|
validator = new QDoubleValidator(this);
|
||||||
validator->setLocale(QLocale::C);
|
validator->setLocale(QLocale::C);
|
||||||
this->setValidator(validator);
|
this->setValidator(validator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoubleEdit::~DoubleEdit()
|
||||||
|
{
|
||||||
|
delete validator;
|
||||||
|
}
|
||||||
|
double DoubleEdit::value() const
|
||||||
|
{
|
||||||
|
return this->text().toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoubleEdit::setValue(double d)
|
||||||
|
{
|
||||||
|
this->setText(tr("%1").arg(d));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoubleEdit::setMinimum(double d)
|
||||||
|
{
|
||||||
|
this->validator->setBottom(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoubleEdit::setMaximum(double d)
|
||||||
|
{
|
||||||
|
this->validator->setTop(d);
|
||||||
|
}
|
||||||
#include "CGAL_double_edit.moc"
|
#include "CGAL_double_edit.moc"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,19 @@
|
||||||
# define CGAL_DOUBLE_EDIT_EXPORT Q_DECL_IMPORT
|
# define CGAL_DOUBLE_EDIT_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class QDoubleValidator;
|
||||||
class CGAL_DOUBLE_EDIT_EXPORT DoubleEdit : public QLineEdit {
|
class CGAL_DOUBLE_EDIT_EXPORT DoubleEdit : public QLineEdit {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DoubleEdit(QWidget *parent);
|
DoubleEdit(QWidget* parent = nullptr);
|
||||||
|
~DoubleEdit();
|
||||||
|
double value() const;
|
||||||
|
void setValue(double d);
|
||||||
|
void setMinimum(double d);
|
||||||
|
void setMaximum(double d);
|
||||||
|
private:
|
||||||
|
QDoubleValidator* validator;
|
||||||
};
|
};
|
||||||
#endif // CGAL_DOUBLE_EDIT_H
|
#endif // CGAL_DOUBLE_EDIT_H
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QDoubleSpinBox>
|
#include "CGAL_double_edit.h"
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
@ -619,17 +619,14 @@ public Q_SLOTS:
|
||||||
scales->setRange (1, 99);
|
scales->setRange (1, 99);
|
||||||
scales->setValue (5);
|
scales->setValue (5);
|
||||||
|
|
||||||
QDoubleSpinBox* voxel_size = dialog.add<QDoubleSpinBox> ("Voxel size (0 for automatic):");
|
DoubleEdit* voxel_size = dialog.add<DoubleEdit> ("Voxel size (0 for automatic):");
|
||||||
voxel_size->setRange (0.0, 10000.0);
|
|
||||||
voxel_size->setValue (0.0);
|
|
||||||
voxel_size->setSingleStep (0.01);
|
|
||||||
|
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
float vsize = float(voxel_size->value());
|
float vsize = float(voxel_size->text().toDouble());
|
||||||
if (vsize == 0.f)
|
if (vsize == 0.f)
|
||||||
vsize = -1.f; // auto value
|
vsize = -1.f; // auto value
|
||||||
|
|
||||||
|
|
@ -921,10 +918,9 @@ public Q_SLOTS:
|
||||||
subdivisions->setRange (1, 9999);
|
subdivisions->setRange (1, 9999);
|
||||||
subdivisions->setValue (16);
|
subdivisions->setValue (16);
|
||||||
|
|
||||||
QDoubleSpinBox* smoothing = dialog.add<QDoubleSpinBox> ("Regularization weight: ");
|
DoubleEdit* smoothing = dialog.add<DoubleEdit> ("Regularization weight: ");
|
||||||
smoothing->setRange (0.0, 100.0);
|
|
||||||
smoothing->setValue (0.5);
|
smoothing->setText(tr("%1").arg(0.5));
|
||||||
smoothing->setSingleStep (0.1);
|
|
||||||
|
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|
@ -932,7 +928,7 @@ public Q_SLOTS:
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
CGAL::Real_timer t;
|
CGAL::Real_timer t;
|
||||||
t.start();
|
t.start();
|
||||||
run (classif, 2, std::size_t(subdivisions->value()), smoothing->value());
|
run (classif, 2, std::size_t(subdivisions->value()), smoothing->text().toDouble());
|
||||||
t.stop();
|
t.stop();
|
||||||
std::cerr << "Graph Cut classification computed in " << t.time() << " second(s)" << std::endl;
|
std::cerr << "Graph Cut classification computed in " << t.time() << " second(s)" << std::endl;
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
@ -1371,10 +1367,8 @@ public Q_SLOTS:
|
||||||
QSpinBox* trials = dialog.add<QSpinBox> ("Number of trials: ", "trials");
|
QSpinBox* trials = dialog.add<QSpinBox> ("Number of trials: ", "trials");
|
||||||
trials->setRange (1, 99999);
|
trials->setRange (1, 99999);
|
||||||
trials->setValue (500);
|
trials->setValue (500);
|
||||||
QDoubleSpinBox* rate = dialog.add<QDoubleSpinBox> ("Learning rate: ", "learning_rate");
|
DoubleEdit* rate = dialog.add<DoubleEdit> ("Learning rate: ", "learning_rate");
|
||||||
rate->setRange (0.00001, 10000.0);
|
rate->setText(tr("%1").arg(0.001));
|
||||||
rate->setValue (0.001);
|
|
||||||
rate->setDecimals (5);
|
|
||||||
QSpinBox* batch = dialog.add<QSpinBox> ("Batch size: ", "batch_size");
|
QSpinBox* batch = dialog.add<QSpinBox> ("Batch size: ", "batch_size");
|
||||||
batch->setRange (1, 2000000000);
|
batch->setRange (1, 2000000000);
|
||||||
batch->setValue (1000);
|
batch->setValue (1000);
|
||||||
|
|
|
||||||
|
|
@ -910,7 +910,7 @@ void Cluster_classification::train(int classifier, const QMultipleInputDialog& d
|
||||||
m_neural_network->train (training,
|
m_neural_network->train (training,
|
||||||
dialog.get<QCheckBox>("restart")->isChecked(),
|
dialog.get<QCheckBox>("restart")->isChecked(),
|
||||||
dialog.get<QSpinBox>("trials")->value(),
|
dialog.get<QSpinBox>("trials")->value(),
|
||||||
dialog.get<QDoubleSpinBox>("learning_rate")->value(),
|
dialog.get<DoubleEdit>("learning_rate")->value(),
|
||||||
dialog.get<QSpinBox>("batch_size")->value(),
|
dialog.get<QSpinBox>("batch_size")->value(),
|
||||||
hidden_layers);
|
hidden_layers);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -800,7 +800,7 @@ void Point_set_item_classification::train(int classifier, const QMultipleInputDi
|
||||||
m_neural_network->train (training,
|
m_neural_network->train (training,
|
||||||
dialog.get<QCheckBox>("restart")->isChecked(),
|
dialog.get<QCheckBox>("restart")->isChecked(),
|
||||||
dialog.get<QSpinBox>("trials")->value(),
|
dialog.get<QSpinBox>("trials")->value(),
|
||||||
dialog.get<QDoubleSpinBox>("learning_rate")->value(),
|
dialog.get<DoubleEdit>("learning_rate")->value(),
|
||||||
dialog.get<QSpinBox>("batch_size")->value(),
|
dialog.get<QSpinBox>("batch_size")->value(),
|
||||||
hidden_layers);
|
hidden_layers);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ void Surface_mesh_item_classification::train (int classifier, const QMultipleInp
|
||||||
m_neural_network->train (training,
|
m_neural_network->train (training,
|
||||||
dialog.get<QCheckBox>("restart")->isChecked(),
|
dialog.get<QCheckBox>("restart")->isChecked(),
|
||||||
dialog.get<QSpinBox>("trials")->value(),
|
dialog.get<QSpinBox>("trials")->value(),
|
||||||
dialog.get<QDoubleSpinBox>("learning_rate")->value(),
|
dialog.get<DoubleEdit>("learning_rate")->value(),
|
||||||
dialog.get<QSpinBox>("batch_size")->value(),
|
dialog.get<QSpinBox>("batch_size")->value(),
|
||||||
hidden_layers);
|
hidden_layers);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,44 +110,18 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="minBox"/>
|
<widget class="DoubleEdit" name="minBox">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>0,00</string>
|
||||||
<widget class="QDoubleSpinBox" name="maxBox">
|
|
||||||
<property name="value">
|
|
||||||
<double>2.000000000000000</double>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0">
|
<widget class="DoubleEdit" name="maxBox">
|
||||||
<item>
|
<property name="text">
|
||||||
<spacer name="horizontalSpacer">
|
<string>2,00</string>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Horizontal</enum>
|
</widget>
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="resetButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Compute Ramp Extremas</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Reset</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoRepeat">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
@ -223,6 +197,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>DoubleEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>CGAL_double_edit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
||||||
|
|
@ -443,9 +443,6 @@ public:
|
||||||
connect(dock_widget->deleteButton, &QPushButton::clicked,
|
connect(dock_widget->deleteButton, &QPushButton::clicked,
|
||||||
this, &DisplayPropertyPlugin::delete_group);
|
this, &DisplayPropertyPlugin::delete_group);
|
||||||
|
|
||||||
connect(dock_widget->resetButton, &QPushButton::pressed,
|
|
||||||
this, &DisplayPropertyPlugin::resetRampExtremas);
|
|
||||||
|
|
||||||
dock_widget->zoomToMaxButton->setEnabled(false);
|
dock_widget->zoomToMaxButton->setEnabled(false);
|
||||||
dock_widget->zoomToMinButton->setEnabled(false);
|
dock_widget->zoomToMinButton->setEnabled(false);
|
||||||
Scene* scene_obj =static_cast<Scene*>(scene);
|
Scene* scene_obj =static_cast<Scene*>(scene);
|
||||||
|
|
@ -464,29 +461,6 @@ private Q_SLOTS:
|
||||||
dock_widget->raise(); }
|
dock_widget->raise(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetRampExtremas()
|
|
||||||
{
|
|
||||||
Scene_surface_mesh_item* item =
|
|
||||||
qobject_cast<Scene_surface_mesh_item*>(scene->item(scene->mainSelectionIndex()));
|
|
||||||
if(!item)
|
|
||||||
return;
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
item->face_graph()->collect_garbage();
|
|
||||||
bool ok;
|
|
||||||
switch(dock_widget->propertyBox->currentIndex())
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
ok = resetAngles(item);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ok = resetScaledJacobian(item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
if(!ok)
|
|
||||||
QMessageBox::warning(mw, "Error", "You must first run colorize once to initialize the values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void colorize()
|
void colorize()
|
||||||
{
|
{
|
||||||
Scene_heat_item* h_item = nullptr;
|
Scene_heat_item* h_item = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <QMultipleInputDialog.h>
|
#include <QMultipleInputDialog.h>
|
||||||
#include <QDoubleSpinBox>
|
#include "CGAL_double_edit.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -821,19 +821,15 @@ protected Q_SLOTS:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMultipleInputDialog dialog ("Region Selection Parameters", mw);
|
QMultipleInputDialog dialog ("Region Selection Parameters", mw);
|
||||||
QDoubleSpinBox* epsilon = dialog.add<QDoubleSpinBox> ("Epsilon: ");
|
DoubleEdit* epsilon = dialog.add<DoubleEdit> ("Epsilon: ");
|
||||||
epsilon->setRange (0.00001, 1000000.);
|
|
||||||
epsilon->setDecimals (5);
|
|
||||||
if (rg_epsilon < 0.)
|
if (rg_epsilon < 0.)
|
||||||
rg_epsilon = (std::max)(0.00001, 0.005 * scene->len_diagonal());
|
rg_epsilon = (std::max)(0.00001, 0.005 * scene->len_diagonal());
|
||||||
epsilon->setValue (rg_epsilon);
|
epsilon->setText(tr("%1").arg(rg_epsilon));
|
||||||
|
|
||||||
QDoubleSpinBox* cluster_epsilon = dialog.add<QDoubleSpinBox> ("Cluster epsilon: ");
|
DoubleEdit* cluster_epsilon = dialog.add<DoubleEdit> ("Cluster epsilon: ");
|
||||||
cluster_epsilon->setRange (0.00001, 1000000.);
|
|
||||||
cluster_epsilon->setDecimals (5);
|
|
||||||
if (rg_cluster_epsilon < 0.)
|
if (rg_cluster_epsilon < 0.)
|
||||||
rg_cluster_epsilon = (std::max)(0.00001, 0.03 * scene->len_diagonal());
|
rg_cluster_epsilon = (std::max)(0.00001, 0.03 * scene->len_diagonal());
|
||||||
cluster_epsilon->setValue (rg_cluster_epsilon);
|
cluster_epsilon->setText(tr("%1").arg(rg_cluster_epsilon));
|
||||||
|
|
||||||
QSpinBox* normal_threshold = dialog.add<QSpinBox> ("Normal threshold: ");
|
QSpinBox* normal_threshold = dialog.add<QSpinBox> ("Normal threshold: ");
|
||||||
normal_threshold->setRange (0, 90);
|
normal_threshold->setRange (0, 90);
|
||||||
|
|
@ -842,8 +838,8 @@ protected Q_SLOTS:
|
||||||
|
|
||||||
if (dialog.exec())
|
if (dialog.exec())
|
||||||
{
|
{
|
||||||
rg_epsilon = epsilon->value();
|
rg_epsilon = epsilon->text().toDouble();
|
||||||
rg_cluster_epsilon = cluster_epsilon->value();
|
rg_cluster_epsilon = cluster_epsilon->text().toDouble();
|
||||||
rg_normal_threshold = normal_threshold->value();
|
rg_normal_threshold = normal_threshold->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue