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>
|
||||
|
||||
DoubleEdit::DoubleEdit(QWidget* parent = nullptr)
|
||||
: QLineEdit(parent)
|
||||
DoubleEdit::DoubleEdit(QWidget *parent)
|
||||
: QLineEdit()
|
||||
{
|
||||
QDoubleValidator* validator = new QDoubleValidator(parent);
|
||||
validator = new QDoubleValidator(this);
|
||||
validator->setLocale(QLocale::C);
|
||||
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"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,19 @@
|
|||
# define CGAL_DOUBLE_EDIT_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
class QDoubleValidator;
|
||||
class CGAL_DOUBLE_EDIT_EXPORT DoubleEdit : public QLineEdit {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSpinBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include "CGAL_double_edit.h"
|
||||
#include <QSlider>
|
||||
|
||||
#include <map>
|
||||
|
|
@ -619,17 +619,14 @@ public Q_SLOTS:
|
|||
scales->setRange (1, 99);
|
||||
scales->setValue (5);
|
||||
|
||||
QDoubleSpinBox* voxel_size = dialog.add<QDoubleSpinBox> ("Voxel size (0 for automatic):");
|
||||
voxel_size->setRange (0.0, 10000.0);
|
||||
voxel_size->setValue (0.0);
|
||||
voxel_size->setSingleStep (0.01);
|
||||
DoubleEdit* voxel_size = dialog.add<DoubleEdit> ("Voxel size (0 for automatic):");
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
float vsize = float(voxel_size->value());
|
||||
float vsize = float(voxel_size->text().toDouble());
|
||||
if (vsize == 0.f)
|
||||
vsize = -1.f; // auto value
|
||||
|
||||
|
|
@ -921,10 +918,9 @@ public Q_SLOTS:
|
|||
subdivisions->setRange (1, 9999);
|
||||
subdivisions->setValue (16);
|
||||
|
||||
QDoubleSpinBox* smoothing = dialog.add<QDoubleSpinBox> ("Regularization weight: ");
|
||||
smoothing->setRange (0.0, 100.0);
|
||||
smoothing->setValue (0.5);
|
||||
smoothing->setSingleStep (0.1);
|
||||
DoubleEdit* smoothing = dialog.add<DoubleEdit> ("Regularization weight: ");
|
||||
|
||||
smoothing->setText(tr("%1").arg(0.5));
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
|
@ -932,7 +928,7 @@ public Q_SLOTS:
|
|||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
CGAL::Real_timer t;
|
||||
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();
|
||||
std::cerr << "Graph Cut classification computed in " << t.time() << " second(s)" << std::endl;
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
|
@ -1371,10 +1367,8 @@ public Q_SLOTS:
|
|||
QSpinBox* trials = dialog.add<QSpinBox> ("Number of trials: ", "trials");
|
||||
trials->setRange (1, 99999);
|
||||
trials->setValue (500);
|
||||
QDoubleSpinBox* rate = dialog.add<QDoubleSpinBox> ("Learning rate: ", "learning_rate");
|
||||
rate->setRange (0.00001, 10000.0);
|
||||
rate->setValue (0.001);
|
||||
rate->setDecimals (5);
|
||||
DoubleEdit* rate = dialog.add<DoubleEdit> ("Learning rate: ", "learning_rate");
|
||||
rate->setText(tr("%1").arg(0.001));
|
||||
QSpinBox* batch = dialog.add<QSpinBox> ("Batch size: ", "batch_size");
|
||||
batch->setRange (1, 2000000000);
|
||||
batch->setValue (1000);
|
||||
|
|
|
|||
|
|
@ -910,7 +910,7 @@ void Cluster_classification::train(int classifier, const QMultipleInputDialog& d
|
|||
m_neural_network->train (training,
|
||||
dialog.get<QCheckBox>("restart")->isChecked(),
|
||||
dialog.get<QSpinBox>("trials")->value(),
|
||||
dialog.get<QDoubleSpinBox>("learning_rate")->value(),
|
||||
dialog.get<DoubleEdit>("learning_rate")->value(),
|
||||
dialog.get<QSpinBox>("batch_size")->value(),
|
||||
hidden_layers);
|
||||
|
||||
|
|
|
|||
|
|
@ -800,7 +800,7 @@ void Point_set_item_classification::train(int classifier, const QMultipleInputDi
|
|||
m_neural_network->train (training,
|
||||
dialog.get<QCheckBox>("restart")->isChecked(),
|
||||
dialog.get<QSpinBox>("trials")->value(),
|
||||
dialog.get<QDoubleSpinBox>("learning_rate")->value(),
|
||||
dialog.get<DoubleEdit>("learning_rate")->value(),
|
||||
dialog.get<QSpinBox>("batch_size")->value(),
|
||||
hidden_layers);
|
||||
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ void Surface_mesh_item_classification::train (int classifier, const QMultipleInp
|
|||
m_neural_network->train (training,
|
||||
dialog.get<QCheckBox>("restart")->isChecked(),
|
||||
dialog.get<QSpinBox>("trials")->value(),
|
||||
dialog.get<QDoubleSpinBox>("learning_rate")->value(),
|
||||
dialog.get<DoubleEdit>("learning_rate")->value(),
|
||||
dialog.get<QSpinBox>("batch_size")->value(),
|
||||
hidden_layers);
|
||||
|
||||
|
|
|
|||
|
|
@ -110,44 +110,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="minBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="maxBox">
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
<widget class="DoubleEdit" name="minBox">
|
||||
<property name="text">
|
||||
<string>0,00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</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>
|
||||
<widget class="DoubleEdit" name="maxBox">
|
||||
<property name="text">
|
||||
<string>2,00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
@ -223,6 +197,13 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>DoubleEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>CGAL_double_edit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
|||
|
|
@ -443,9 +443,6 @@ public:
|
|||
connect(dock_widget->deleteButton, &QPushButton::clicked,
|
||||
this, &DisplayPropertyPlugin::delete_group);
|
||||
|
||||
connect(dock_widget->resetButton, &QPushButton::pressed,
|
||||
this, &DisplayPropertyPlugin::resetRampExtremas);
|
||||
|
||||
dock_widget->zoomToMaxButton->setEnabled(false);
|
||||
dock_widget->zoomToMinButton->setEnabled(false);
|
||||
Scene* scene_obj =static_cast<Scene*>(scene);
|
||||
|
|
@ -464,29 +461,6 @@ private Q_SLOTS:
|
|||
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()
|
||||
{
|
||||
Scene_heat_item* h_item = nullptr;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
#include <QMultipleInputDialog.h>
|
||||
#include <QDoubleSpinBox>
|
||||
#include "CGAL_double_edit.h"
|
||||
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
|
|
@ -821,19 +821,15 @@ protected Q_SLOTS:
|
|||
return;
|
||||
|
||||
QMultipleInputDialog dialog ("Region Selection Parameters", mw);
|
||||
QDoubleSpinBox* epsilon = dialog.add<QDoubleSpinBox> ("Epsilon: ");
|
||||
epsilon->setRange (0.00001, 1000000.);
|
||||
epsilon->setDecimals (5);
|
||||
DoubleEdit* epsilon = dialog.add<DoubleEdit> ("Epsilon: ");
|
||||
if (rg_epsilon < 0.)
|
||||
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: ");
|
||||
cluster_epsilon->setRange (0.00001, 1000000.);
|
||||
cluster_epsilon->setDecimals (5);
|
||||
DoubleEdit* cluster_epsilon = dialog.add<DoubleEdit> ("Cluster epsilon: ");
|
||||
if (rg_cluster_epsilon < 0.)
|
||||
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: ");
|
||||
normal_threshold->setRange (0, 90);
|
||||
|
|
@ -842,8 +838,8 @@ protected Q_SLOTS:
|
|||
|
||||
if (dialog.exec())
|
||||
{
|
||||
rg_epsilon = epsilon->value();
|
||||
rg_cluster_epsilon = cluster_epsilon->value();
|
||||
rg_epsilon = epsilon->text().toDouble();
|
||||
rg_cluster_epsilon = cluster_epsilon->text().toDouble();
|
||||
rg_normal_threshold = normal_threshold->value();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue