OpticConstraints: Adding Snell's law

Fix AngleViaPoint to support new derivative calculation technique.

OpticConstraints: Adding Snell's law. Fix AngleViaPoint to support new derivative calculation technique.

Snell's law constraint added to GCS, but not yet exposed and cannot be
tested.
Since the way CalculateNormal() returns derivatives had changed,
AngleViaPoint constraint needed modifications. Nothing serious.

OpticConstraints: SnellsLaw progress

Addable through python. Fix math. Some quick-and-dirty visual stuff to
get rid of hangs and to see the constraint in action.

OpticConstraints: SnellsLaw: flipping logic fix

OpticConstraints: SnellsLaw progress

Added toolbar button. Allowed editing a datum by doubleclick. New error
message approach during constraint creation.

OpticConstraints: SnellsLaw

OpticConstraints: SnellsLaw: list label improvement

OpticConstraints: SnellsLaw: fix after rebase

OpticConstraints: SnellsLaw: expose helper constraints

Snell's law internally is made of three constraints: point-on-object,
coincident and the Snell's sin/sin. They were all buried under one UI
constraint. Exposing them allows to construct reflection and
birefringence on the point (attempting to do so used to result in
redundant constraints and was often not functional at all).
This commit breaks compatibility with older files.

OpticConstraints: SnellsLaw: small refactor of math

Placing the duplicated code of error and gradient calculation into a
private method.

OpticConstraints: SnellsLaw: fix datum edit unit

OpticConstraints: SnellsLaw: fix datum edit bug

After previous fix, the dimensionless value was not accepted (the
constraint's value did not change, the changes were ignored).
This commit is contained in:
DeepSOIC
2014-12-11 23:30:58 +03:00
committed by wmayer
parent 88578489fb
commit cf4e9df78d
16 changed files with 510 additions and 57 deletions

View File

@@ -75,7 +75,8 @@ void EditDatumDialog::exec(bool atCursor)
Constr->Type == Sketcher::DistanceX ||
Constr->Type == Sketcher::DistanceY ||
Constr->Type == Sketcher::Radius ||
Constr->Type == Sketcher::Angle) {
Constr->Type == Sketcher::Angle ||
Constr->Type == Sketcher::SnellsLaw) {
if (sketch->hasConflicts()) {
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Distance constraint"),
@@ -106,6 +107,11 @@ void EditDatumDialog::exec(bool atCursor)
ui_ins_datum.label->setText(tr("Radius:"));
ui_ins_datum.labelEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/SketcherLength"));
}
else if (Constr->Type == Sketcher::SnellsLaw) {
dlg.setWindowTitle(tr("Refractive index ratio", "Constraint_SnellsLaw"));
ui_ins_datum.label->setText(tr("Ratio n2/n1:", "Constraint_SnellsLaw"));
ui_ins_datum.labelEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/SketcherRefrIndexRatio"));
}
else {
dlg.setWindowTitle(tr("Insert length"));
init_val.setUnit(Base::Unit::Length);
@@ -134,7 +140,7 @@ void EditDatumDialog::exec(bool atCursor)
if (dlg.exec()) {
Base::Quantity newQuant = ui_ins_datum.labelEdit->value();
if (newQuant.isQuantity()) {
if (newQuant.isQuantity() || (Constr->Type == Sketcher::SnellsLaw && newQuant.isDimensionless())) {
// save the value for the history
ui_ins_datum.labelEdit->pushToHistory();