- QString c = e->getCommand().toLower();
-
- if (RS_COMMANDS->checkCommand("help", c)) {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
- + getAvailableCommands().join(", "));
- }
- return;
- }
-
- if (RS_COMMANDS->checkCommand("reversed", c)) {
- e->accept();
- setReversed(!isReversed());
-
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->requestOptions(this, true, true);
- }
- return;
- }
-
- switch (getStatus()) {
-
- case SetRadius: {
- bool ok;
- double r = RS_Math::eval(c, &ok);
- if (ok==true) {
- data.radius = r;
- setStatus(SetAngle1);
- } else {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- }
- }
- }
- break;
-
- case SetAngle1: {
- bool ok;
- double a = RS_Math::eval(c, &ok);
- if (ok==true) {
- data.angle1 = RS_Math::deg2rad(a);
- setStatus(SetAngle2);
- } else {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- }
- }
- }
- break;
-
- case SetAngle2: {
- if (RS_COMMANDS->checkCommand("angle", c)) {
- setStatus(SetIncAngle);
- } else if (RS_COMMANDS->checkCommand("chord length", c)) {
- setStatus(SetChordLength);
- } else {
- bool ok;
- double a = RS_Math::eval(c, &ok);
- if (ok==true) {
- data.angle2 = RS_Math::deg2rad(a);
- trigger();
- } else {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- }
- }
- }
- }
- break;
-
- case SetIncAngle: {
- bool ok;
- double a = RS_Math::eval(c, &ok);
- if (ok==true) {
- data.angle2 = data.angle1 + RS_Math::deg2rad(a);
- trigger();
- } else {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- }
- }
- }
- break;
-
- case SetChordLength: {
- bool ok;
- double l = RS_Math::eval(c, &ok);
- if (ok==true) {
- if (fabs(l/(2*data.radius))<=1.0) {
- data.angle2 = data.angle1 + asin(l/(2*data.radius)) * 2;
- trigger();
- } else {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(
- tr("Not a valid chord length"));
- }
- }
- } else {
- if (RS_DIALOGFACTORY!=NULL) {
- RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- }
- }
- }
- break;
-
- default:
- break;
- }
+ QString c = e->getCommand().toLower();
+
+ if (RS_COMMANDS->checkCommand("help", c))
+ {
+ if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ + getAvailableCommands().join(", "));
+ return;
+ }
+
+ if (RS_COMMANDS->checkCommand("reversed", c))
+ {
+ e->accept();
+ setReversed(!isReversed());
+
+ if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->requestOptions(this, true, true);
+ return;
+ }
+
+ switch (getStatus())
+ {
+ case SetRadius: {
+ bool ok;
+ double r = RS_Math::eval(c, &ok);
+
+ if (ok == true)
+ {
+ data.radius = r;
+ setStatus(SetAngle1);
+ }
+ else if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+ }
+ break;
+
+ case SetAngle1: {
+ bool ok;
+ double a = RS_Math::eval(c, &ok);
+
+ if (ok == true)
+ {
+ data.angle1 = RS_Math::deg2rad(a);
+ setStatus(SetAngle2);
+ }
+ else if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+ }
+ break;
+
+ case SetAngle2:
+
+ if (RS_COMMANDS->checkCommand("angle", c))
+ setStatus(SetIncAngle);
+ else if (RS_COMMANDS->checkCommand("chord length", c))
+ setStatus(SetChordLength);
+ else
+ {
+ bool ok;
+ double a = RS_Math::eval(c, &ok);
+
+ if (ok == true)
+ {
+ data.angle2 = RS_Math::deg2rad(a);
+ trigger();
+ }
+ else if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+ }
+ break;
+
+ case SetIncAngle: {
+ bool ok;
+ double a = RS_Math::eval(c, &ok);
+
+ if (ok == true)
+ {
+ data.angle2 = data.angle1 + RS_Math::deg2rad(a);
+ trigger();
+ }
+ else if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+ }
+ break;
+
+ case SetChordLength: {
+ bool ok;
+ double l = RS_Math::eval(c, &ok);
+
+ if (ok == true)
+ {
+ if (fabs(l / (2 * data.radius)) <= 1.0)
+ {
+ data.angle2 = data.angle1 + asin(l / (2 * data.radius)) * 2;
+ trigger();
+ }
+ else if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(
+ tr("Not a valid chord length"));
+
+ }
+ else if (RS_DIALOGFACTORY != NULL)
+ RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
+ }
+ break;
+
+ default:
+ break;
+ }