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
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/VIEW/DIALOGS/fieldLinesDialog.h>
#include <BALL/VIEW/KERNEL/common.h>
#include <BALL/VIEW/KERNEL/mainControl.h>
#include <QtWidgets/QLabel>
namespace BALL
{
namespace VIEW
{
FieldLinesDialog::FieldLinesDialog(QWidget* parent, const char* name)
: QDialog(parent),
Ui::FieldLinesDialogData(),
FieldLineCreator()
{
#ifdef BALL_VIEW_DEBUG
Log.error() << "new FieldLinesDialog " << this << std::endl;
#endif
setupUi(this);
// signals and slots connections
connect( ok_button, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( cancel_button, SIGNAL( clicked() ), this, SLOT( reject() ) );
setObjectName(name);
}
FieldLinesDialog::~FieldLinesDialog()
{
#ifdef BALL_VIEW_DEBUG
Log.error() << "deleting FieldLinesDialog " << this << std::endl;
#endif
}
float FieldLinesDialog::getTolerance()
{
return ascii(tolerance->text()).toFloat();
}
Size FieldLinesDialog::getInterpolationSteps()
{
return ascii(interpolation_steps->text()).toUnsignedInt();
}
Size FieldLinesDialog::getMaxSteps()
{
return ascii(max_steps->text()).toUnsignedInt();
}
Size FieldLinesDialog::getIcosaederInterplationSteps()
{
return start_points_per_atom->value();
}
float FieldLinesDialog::getAtomsDistance()
{
return (float)atom_distance->value() / 10.0;
}
void FieldLinesDialog::accept()
{
try
{
ascii(tolerance->text()).toFloat();
ascii(interpolation_steps->text()).toUnsignedInt();
ascii(max_steps->text()).toUnsignedInt();
}
catch(...)
{
getMainControl()->setStatusbarText((String)tr("No valid floating point numbers"), true);
return;
}
if (Maths::isZero(getTolerance()))
{
getMainControl()->setStatusbarText((String)tr("Tolerance too low!"), true);
Log.error() << String(tr("Tolerance")) + ": " + String(getTolerance()) + " !" << std::endl;
return;
}
tolerance_ = getTolerance();
atom_distance_ = getAtomsDistance();
icosaeder_steps_ = getIcosaederInterplationSteps();
max_steps_ = getMaxSteps();
interpolation_steps_ = getInterpolationSteps();
use_atoms_ = !getSeedMode();
monte_carlo_nr_lines_ = getMonteCarloNumberLines();
QDialog::accept();
}
Position FieldLinesDialog::getSeedMode()
{
return seed_mode_tab_widget->currentIndex();
}
Size FieldLinesDialog::getMonteCarloNumberLines()
{
return monte_carlo_number_lines->value();
}
} } // namespaces
|