[Sketcher]make cursor coord display unit aware
This commit is contained in:
@@ -1125,9 +1125,13 @@ public:
|
||||
endpoint = EditCurve[0] + length * Base::Vector2d(cos(angle),sin(angle));
|
||||
}
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f, %.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(endpoint, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (%s, %.s°)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(endpoint, text);
|
||||
}
|
||||
|
||||
EditCurve[1] = endpoint;
|
||||
drawEdit(EditCurve);
|
||||
@@ -1674,9 +1678,13 @@ public:
|
||||
endpoint = EditCurve[0] + length * Base::Vector2d(cos(angle),sin(angle));
|
||||
}
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f, %.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(endpoint, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle *180.0 / M_PI, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(endpoint, text);
|
||||
}
|
||||
|
||||
EditCurve[1] = endpoint;
|
||||
drawEdit(EditCurve);
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "DrawSketchHandler.h"
|
||||
#include "ViewProviderSketch.h"
|
||||
#include "CommandConstraints.h"
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace SketcherGui;
|
||||
using namespace Sketcher;
|
||||
@@ -957,9 +958,13 @@ void DrawSketchHandler::drawDirectionAtCursor(const Base::Vector2d & position, c
|
||||
float length = (position - origin).Length();
|
||||
float angle = (position - origin).GetAngle(Base::Vector2d(1.f,0.f));
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(position, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(position, text);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSketchHandler::drawEditMarkers(const std::vector<Base::Vector2d> &EditMarkers, unsigned int augmentationlevel)
|
||||
|
||||
@@ -81,9 +81,13 @@ public:
|
||||
float radius = (onSketchPos - EditCurve[0]).Length();
|
||||
float angle = atan2f(dy_ , dx_);
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fdeg)", radius, angle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
@@ -106,9 +110,13 @@ public:
|
||||
// Display radius and arc angle
|
||||
float radius = (onSketchPos - EditCurve[0]).Length();
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fdeg)", radius, arcAngle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2d(0.0,0.0))) {
|
||||
@@ -283,9 +291,13 @@ public:
|
||||
|
||||
// Display radius and start angle
|
||||
// This lineAngle will report counter-clockwise from +X, not relatively
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fdeg)", (float) radius, (float) lineAngle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string angleString = angleToDisplayFormat(lineAngle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
@@ -353,9 +365,13 @@ public:
|
||||
CenterPoint.y + radius*sin(angle));
|
||||
}
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fdeg)", (float) radius, (float) arcAngle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2d(0.0,0.0),
|
||||
|
||||
@@ -75,9 +75,12 @@ public:
|
||||
// Display radius for user
|
||||
float radius = (onSketchPos - EditCurve[0]).Length();
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", radius,radius);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
text.sprintf(" (R%s, R%s)", radiusString.c_str(), radiusString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos - centerPoint,
|
||||
@@ -106,9 +109,13 @@ public:
|
||||
EditCurve[17] = EditCurve[16];
|
||||
|
||||
// Display radius for user
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", a, b);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
text.sprintf(" (R%s, R%s)", aString.c_str(), bString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
@@ -145,9 +152,14 @@ public:
|
||||
// EditCurve[17] = EditCurve[16];
|
||||
|
||||
// Display radii and angle for user
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR,%.1fdeg)", a, b, arcAngle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, R%s, %s)", aString.c_str(), bString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr4, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
|
||||
@@ -65,10 +65,12 @@ public:
|
||||
|
||||
// Display radius for user
|
||||
float radius = (onSketchPos - centerPoint).Length();
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", radius,radius);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
text.sprintf(" (R%s, R%s)", radiusString.c_str(), radiusString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f,0.f),
|
||||
@@ -97,15 +99,19 @@ public:
|
||||
}
|
||||
|
||||
// Display radius for user
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", a, b);
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
text.sprintf(" (R%s, R%s)", aString.c_str(), bString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
renderSuggestConstraintsCursor(sugConstr3);
|
||||
return;
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
renderSuggestConstraintsCursor(sugConstr3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Mode==STATUS_SEEK_Fourth) {
|
||||
@@ -144,9 +150,13 @@ public:
|
||||
}
|
||||
|
||||
// Display radius for user
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", a, b);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
text.sprintf(" (R%s, R%s)", aString.c_str(), bString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
}
|
||||
else {
|
||||
arcAngle=0.;
|
||||
|
||||
@@ -68,10 +68,12 @@ public:
|
||||
|
||||
// Display radius for user
|
||||
float radius = (onSketchPos - focusPoint).Length();
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (F%.1f)", radius);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
text.sprintf(" (F%s)", radiusString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
@@ -101,9 +103,12 @@ public:
|
||||
}
|
||||
|
||||
// Display radius for user
|
||||
SbString text;
|
||||
text.sprintf(" (F%.1f)", focal);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string focalString = lengthToDisplayFormat(focal, 1);
|
||||
text.sprintf(" (F%s)", focalString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
|
||||
@@ -143,9 +148,12 @@ public:
|
||||
EditCurve[i] = Base::Vector2d(axisPoint.x + rx, axisPoint.y + ry);
|
||||
}
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (F%.1f)", focal);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string focalString = lengthToDisplayFormat(focal, 1);
|
||||
text.sprintf(" (F%s)", focalString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
}
|
||||
else {
|
||||
arcAngle=0.;
|
||||
|
||||
@@ -357,9 +357,13 @@ private:
|
||||
float length = (position - BSplinePoles.back()).Length();
|
||||
float angle = (position - BSplinePoles.back()).GetAngle(Base::Vector2d(1.f,0.f));
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1fdeg)", length, (angle != -FLOAT_MAX) ? angle * 180 / M_PI : 0);
|
||||
setPositionText(position, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat((angle != -FLOAT_MAX) ? angle * 180 / M_PI : 0, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(position, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,10 +67,12 @@ public:
|
||||
|
||||
// Display radius for user
|
||||
float radius = (onSketchPos - EditCurve[0]).Length();
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR)", radius);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
text.sprintf(" (R%s)", radiusString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos - EditCurve[0],
|
||||
@@ -212,9 +214,13 @@ public:
|
||||
|
||||
// Display radius and start angle
|
||||
// This lineAngle will report counter-clockwise from +X, not relatively
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fdeg)", (float) radius, (float) lineAngle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string angleString = angleToDisplayFormat( lineAngle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (Mode == STATUS_SEEK_Second) {
|
||||
|
||||
@@ -120,9 +120,12 @@ public:
|
||||
|
||||
// Display radius for user
|
||||
float semiMajorRadius = a * 2;
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", semiMajorRadius,semiMajorRadius);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string majorString = lengthToDisplayFormat(semiMajorRadius, 1);
|
||||
text.sprintf(" (R%s, R%s)", majorString.c_str(), majorString);
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(editCurve);
|
||||
// Suggestions for ellipse and curves are disabled because many tangent constraints
|
||||
@@ -137,9 +140,13 @@ public:
|
||||
approximateEllipse();
|
||||
|
||||
// Display radius for user
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", a, b);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
text.sprintf(" (R%s, R%s)", aString.c_str(), bString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(editCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2d(0.f,0.f),
|
||||
@@ -161,9 +168,12 @@ public:
|
||||
|
||||
// Display radius for user
|
||||
float semiMajorRadius = a * 2;
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", semiMajorRadius,semiMajorRadius);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string majorString = lengthToDisplayFormat(semiMajorRadius, 1);
|
||||
text.sprintf(" (R%s, R%s)", majorString.c_str(), majorString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(editCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos - centroid,
|
||||
@@ -176,9 +186,13 @@ public:
|
||||
approximateEllipse();
|
||||
|
||||
// Display radius for user
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fR)", a, b);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
text.sprintf(" (R%s, R%s)", aString.c_str(), bString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(editCurve);
|
||||
if (seekAutoConstraint(sugConstr3, onSketchPos, onSketchPos - centroid,
|
||||
|
||||
@@ -55,9 +55,13 @@ public:
|
||||
else if (Mode==STATUS_SEEK_Second){
|
||||
float length = (onSketchPos - EditCurve[0]).Length();
|
||||
float angle = (onSketchPos - EditCurve[0]).GetAngle(Base::Vector2d(1.f,0.f));
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
EditCurve[1] = onSketchPos;
|
||||
drawEdit(EditCurve);
|
||||
|
||||
@@ -194,9 +194,13 @@ public:
|
||||
float length = (EditCurve[1] - EditCurve[0]).Length();
|
||||
float angle = (EditCurve[1] - EditCurve[0]).GetAngle(Base::Vector2d(1.f,0.f));
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(EditCurve[1], text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(EditCurve[1], text);
|
||||
}
|
||||
|
||||
if (TransitionMode == TRANSITION_MODE_Free) {
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos - EditCurve[0])) {
|
||||
@@ -272,9 +276,13 @@ public:
|
||||
|
||||
drawEdit(EditCurve);
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR,%.1fdeg)", std::abs(arcRadius), arcAngle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(std::abs(arcRadius), 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / M_PI, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
renderSuggestConstraintsCursor(sugConstr2);
|
||||
|
||||
@@ -81,9 +81,13 @@ public:
|
||||
const float radius = dV.Length();
|
||||
const float angle = ( 180.0 / M_PI ) * atan2( dV.y, dV.x );
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR %.1fdeg)", radius, angle );
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f,0.f))) {
|
||||
|
||||
@@ -68,9 +68,13 @@ public:
|
||||
if(constructionMethod == Diagonal) {
|
||||
float dx = onSketchPos.x - EditCurve[0].x;
|
||||
float dy = onSketchPos.y - EditCurve[0].y;
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f x %.1f)", dx, dy);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string dxString = lengthToDisplayFormat(dx, 1);
|
||||
std::string dyString = lengthToDisplayFormat(dy, 1);
|
||||
text.sprintf(" (%s x %s)", dxString.c_str(), dyString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
EditCurve[2] = onSketchPos;
|
||||
EditCurve[1] = Base::Vector2d(onSketchPos.x ,EditCurve[0].y);
|
||||
@@ -80,9 +84,13 @@ public:
|
||||
else if (constructionMethod == CenterAndCorner) {
|
||||
float dx = onSketchPos.x - center.x;
|
||||
float dy = onSketchPos.y - center.y;
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f x %.1f)", dx, dy);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string dxString = lengthToDisplayFormat(dx, 1);
|
||||
std::string dyString = lengthToDisplayFormat(dy, 1);
|
||||
text.sprintf(" (%s x %s)", dxString.c_str(), dyString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
EditCurve[0] = center - (onSketchPos - center);
|
||||
EditCurve[1] = Base::Vector2d(EditCurve[0].x,onSketchPos.y);
|
||||
@@ -375,9 +383,14 @@ public:
|
||||
// close the curve
|
||||
EditCurve[36] = EditCurve[0];
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR %.1fX %.1fY)", radius, lengthX, lengthY);
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(radius, 1);
|
||||
std::string xString = lengthToDisplayFormat(lengthX, 1);
|
||||
std::string yString = lengthToDisplayFormat(lengthY, 1);
|
||||
text.sprintf(" (R%s X%s Y%s)", radiusString.c_str(), xString.c_str(), yString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f, 0.f))) {
|
||||
|
||||
@@ -119,9 +119,13 @@ public:
|
||||
}
|
||||
EditCurve[34] = EditCurve[0];
|
||||
|
||||
SbString text;
|
||||
text.sprintf(" (%.1fR %.1fL)", r, sqrt(dx * dx + dy * dy));
|
||||
setPositionText(onSketchPos, text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string rString = lengthToDisplayFormat(r, 1);
|
||||
std::string sqrtString = lengthToDisplayFormat(sqrt(dx * dx + dy * dy), 1);
|
||||
text.sprintf(" (R%s L%s))", rString.c_str(), sqrtString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
|
||||
drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(dx, dy), AutoConstraint::VERTEX_NO_TANGENCY)) {
|
||||
|
||||
@@ -98,6 +98,8 @@
|
||||
|
||||
#include "EditModeCoinManager.h"
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace SketcherGui;
|
||||
using namespace Sketcher;
|
||||
|
||||
@@ -492,9 +494,13 @@ void EditModeCoinManager::setPositionText(const Base::Vector2d &Pos, const SbStr
|
||||
|
||||
void EditModeCoinManager::setPositionText(const Base::Vector2d &Pos)
|
||||
{
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1f)", Pos.x, Pos.y);
|
||||
setPositionText(Pos,text);
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string xString = lengthToDisplayFormat(Pos.x, 1);
|
||||
std::string yString = lengthToDisplayFormat(Pos.y, 1);
|
||||
text.sprintf(" (%s, %s)", xString.c_str(), yString.c_str());
|
||||
setPositionText(Pos,text);
|
||||
}
|
||||
}
|
||||
|
||||
void EditModeCoinManager::resetPositionText()
|
||||
|
||||
@@ -151,6 +151,8 @@ void SketcherSettingsDisplay::saveSettings()
|
||||
ui->continueMode->onSave();
|
||||
ui->constraintMode->onSave();
|
||||
ui->checkBoxHideUnits->onSave();
|
||||
ui->checkBoxShowCursorCoords->onSave();
|
||||
ui->checkBoxUseSystemDecimals->onSave();
|
||||
ui->checkBoxShowDimensionalName->onSave();
|
||||
ui->prefDimensionalStringFormat->onSave();
|
||||
ui->checkBoxTVHideDependent->onSave();
|
||||
@@ -175,6 +177,8 @@ void SketcherSettingsDisplay::loadSettings()
|
||||
ui->continueMode->onRestore();
|
||||
ui->constraintMode->onRestore();
|
||||
ui->checkBoxHideUnits->onRestore();
|
||||
ui->checkBoxShowCursorCoords->onRestore();
|
||||
ui->checkBoxUseSystemDecimals->onRestore();
|
||||
ui->checkBoxShowDimensionalName->onRestore();
|
||||
ui->prefDimensionalStringFormat->onRestore();
|
||||
ui->checkBoxTVHideDependent->onRestore();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>553</height>
|
||||
<height>664</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -20,47 +20,6 @@
|
||||
<string>Sketch editing</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_0">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>182</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>EditSketcherFontSize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="EditSketcherFontSize">
|
||||
<property name="toolTip">
|
||||
<string>Font size used for labels and constraints.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>17</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EditSketcherFontSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="minimumSize">
|
||||
@@ -108,6 +67,151 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="SegmentsPerGeometry">
|
||||
<property name="toolTip">
|
||||
<string>The number of polygons used for geometry approximation.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SegmentsPerGeometry</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxShowDimensionalName">
|
||||
<property name="toolTip">
|
||||
<string>If checked, displays the name on dimensional constraints (if exists).</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show dimensional constraint name with format</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowDimensionalName</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="Gui::PrefLineEdit" name="prefDimensionalStringFormat">
|
||||
<property name="toolTip">
|
||||
<string>The format of the dimensional constraint string presentation.
|
||||
Defaults to: %N = %V
|
||||
|
||||
%N - name parameter
|
||||
%V - dimension value</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%N = %V</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>%N = %V</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DimensionalStringFormat</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Segments per geometry</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>SegmentsPerGeometry</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="continueMode">
|
||||
<property name="toolTip">
|
||||
<string>The current sketcher creation tool will remain active after creation.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Geometry creation "Continue Mode"</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ContinuousCreationMode</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="EditSketcherFontSize">
|
||||
<property name="toolTip">
|
||||
<string>Font size used for labels and constraints.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>17</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EditSketcherFontSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxHideUnits">
|
||||
<property name="toolTip">
|
||||
<string>Base length units will not be displayed in constraints or cursor coordinates.
|
||||
Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide base length units for supported unit systems</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>HideUnits</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_0">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>182</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>EditSketcherFontSize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@@ -128,32 +232,41 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Segments per geometry</string>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="constraintMode">
|
||||
<property name="toolTip">
|
||||
<string>The current constraint creation tool will remain active after creation.</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>SegmentsPerGeometry</cstring>
|
||||
<property name="text">
|
||||
<string>Constraint creation "Continue Mode"</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ContinuousConstraintMode</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="SegmentsPerGeometry">
|
||||
<item row="8" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxShowCursorCoords">
|
||||
<property name="toolTip">
|
||||
<string>The number of polygons used for geometry approximation.</string>
|
||||
<string>Cursor position coordinates will be displayed beside cursor while editing sketch.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
<property name="text">
|
||||
<string>Show coodinates beside cursor while editing</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SegmentsPerGeometry</cstring>
|
||||
<cstring>ShowCursorCoords</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -176,94 +289,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="continueMode">
|
||||
<item row="9" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxUseSystemDecimals">
|
||||
<property name="toolTip">
|
||||
<string>The current sketcher creation tool will remain active after creation.</string>
|
||||
<string>Cursor coordinates will use the system decimals setting instead of the short form.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Geometry creation "Continue Mode"</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<string>Use system decimals setting for cursor coordinates</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ContinuousCreationMode</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="constraintMode">
|
||||
<property name="toolTip">
|
||||
<string>The current constraint creation tool will remain active after creation.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Constraint creation "Continue Mode"</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ContinuousConstraintMode</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxHideUnits">
|
||||
<property name="toolTip">
|
||||
<string>Base length units will not be displayed in constraints.
|
||||
Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide base length units for supported unit systems</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>HideUnits</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxShowDimensionalName">
|
||||
<property name="toolTip">
|
||||
<string>If checked, displays the name on dimensional constraints (if exists).</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show dimensional constraint name with format</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowDimensionalName</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="Gui::PrefLineEdit" name="prefDimensionalStringFormat">
|
||||
<property name="text">
|
||||
<string notr="true">%N = %V</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>%N = %V</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The format of the dimensional constraint string presentation.
|
||||
Defaults to: %N = %V
|
||||
|
||||
%N - name parameter
|
||||
%V - dimension value</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<string>DimensionalStringFormat</string>
|
||||
<cstring>UseSystemDecimals</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
@@ -386,7 +421,7 @@ Defaults to: %N = %V
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxTVForceOrtho">
|
||||
<property name="toolTip">
|
||||
<string>When entering edit mode, force orthographic view of camera.
|
||||
Works only when "Restore camera position after editing" is enabled.</string>
|
||||
Works only when "Restore camera position after editing" is enabled.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Force orthographic camera when entering edit</string>
|
||||
@@ -476,19 +511,14 @@ Then objects are only visible behind the sketch plane.</string>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
@@ -496,6 +526,11 @@ Then objects are only visible behind the sketch plane.</string>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>EditSketcherFontSize</tabstop>
|
||||
|
||||
@@ -29,8 +29,11 @@
|
||||
# include <QPainter>
|
||||
#endif
|
||||
|
||||
#include <Base/Quantity.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Base/UnitsSchema.h>
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
@@ -50,8 +53,6 @@
|
||||
|
||||
#include "ViewProviderSketch.h"
|
||||
#include "DrawSketchHandler.h"
|
||||
#include "ui_InsertDatum.h"
|
||||
#include "EditDatumDialog.h"
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -423,3 +424,148 @@ void SketcherGui::ConstraintToAttachment(Sketcher::GeoElementId element, Sketche
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//convenience functions for cursor display
|
||||
bool SketcherGui::hideUnits()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/Sketcher");
|
||||
return hGrp->GetBool("HideUnits", false);
|
||||
}
|
||||
|
||||
bool SketcherGui::showCursorCoords()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/Sketcher");
|
||||
return hGrp->GetBool("ShowCursorCoords", true); //true for testing. set to false for prod.
|
||||
}
|
||||
|
||||
bool SketcherGui::useSystemDecimals()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/Sketcher");
|
||||
return hGrp->GetBool("UseSystemDecimals", true);
|
||||
}
|
||||
|
||||
//convert value to display format %0.[digits]f. Units are displayed if
|
||||
//preference "ShowUnits" is true, or if the unit schema in effect uses
|
||||
//multiple units (ex. Ft/In). Digits parameter is ignored for multi-unit
|
||||
//schemata
|
||||
//TODO:: if the user string is delivered in 1.23e45 format, this might not work
|
||||
// correctly.
|
||||
std::string SketcherGui::lengthToDisplayFormat(double value, int digits)
|
||||
{
|
||||
Base::Quantity asQuantity;
|
||||
asQuantity.setValue(value);
|
||||
asQuantity.setUnit(Base::Unit::Length);
|
||||
QString qUserString = asQuantity.getUserString();
|
||||
if ( Base::UnitsApi::isMultiUnitLength() ||
|
||||
(!hideUnits() && useSystemDecimals()) ) {
|
||||
//just return the user string
|
||||
return Base::Tools::toStdString(qUserString);
|
||||
}
|
||||
|
||||
//find the unit of measure
|
||||
double factor = 1.0;
|
||||
QString qUnitString;
|
||||
QString qtranslate = Base::UnitsApi::schemaTranslate(asQuantity, factor, qUnitString);
|
||||
QString unitPart = QString::fromUtf8(" ") + qUnitString;
|
||||
|
||||
//get the numeric part of the user string
|
||||
QRegularExpression rxNoUnits(QString::fromUtf8("(.*) \\D*$")); // text before space + any non digits at end of string
|
||||
QRegularExpressionMatch match = rxNoUnits.match(qUserString);
|
||||
if (!match.hasMatch()) {
|
||||
//no units in userString?
|
||||
return Base::Tools::toStdString(qUserString);
|
||||
}
|
||||
QString matched = match.captured(1); //matched is the numeric part of user string
|
||||
int dpPos = matched.indexOf(QLocale().decimalPoint());
|
||||
if (dpPos < 0) {
|
||||
//no decimal separator (ie an integer), return all the digits
|
||||
if (hideUnits()) {
|
||||
return Base::Tools::toStdString(matched);
|
||||
} else {
|
||||
return Base::Tools::toStdString(matched + unitPart);
|
||||
}
|
||||
}
|
||||
|
||||
//real number
|
||||
if (useSystemDecimals() &&
|
||||
hideUnits() ) {
|
||||
//return just the numeric part of the user string
|
||||
return Base::Tools::toStdString(matched);
|
||||
}
|
||||
|
||||
//real number and not using system decimals
|
||||
int requiredLength = dpPos + digits + 1;
|
||||
if (requiredLength > matched.size()) {
|
||||
//just take the whole thing
|
||||
requiredLength = matched.size();
|
||||
}
|
||||
QString numericPart = matched.left(requiredLength);
|
||||
if (hideUnits()) {
|
||||
return Base::Tools::toStdString(numericPart);
|
||||
}
|
||||
return Base::Tools::toStdString(numericPart + unitPart);
|
||||
}
|
||||
|
||||
//convert value to display format %0.[digits]f. Units are always displayed for
|
||||
//angles - 123.456° or 12°34'56". Digits parameter is ignored for multi-unit
|
||||
//schemata. Note small differences between this method and lengthToDisplyFormat
|
||||
//TODO:: if the user string is delivered in 1.23e45 format, this might not work
|
||||
// correctly.
|
||||
std::string SketcherGui::angleToDisplayFormat(double value, int digits)
|
||||
{
|
||||
Base::Quantity asQuantity;
|
||||
asQuantity.setValue(value);
|
||||
asQuantity.setUnit(Base::Unit::Angle);
|
||||
QString qUserString = asQuantity.getUserString();
|
||||
if ( Base::UnitsApi::isMultiUnitAngle() ) {
|
||||
//just return the user string
|
||||
//Coin SbString doesn't handle utf8 well, so we convert to ascii
|
||||
QString schemeMinute = QString::fromUtf8("\xE2\x80\xB2"); //prime symbol
|
||||
QString schemeSecond = QString::fromUtf8("\xE2\x80\xB3"); //double prime symbol
|
||||
QString escapeMinute = QString::fromLatin1("\'"); //substitute ascii single quote
|
||||
QString escapeSecond = QString::fromLatin1("\""); //substitute ascii double quote
|
||||
QString displayString = qUserString.replace(schemeMinute, escapeMinute);
|
||||
displayString = displayString.replace(schemeSecond, escapeSecond);
|
||||
return Base::Tools::toStdString(displayString);
|
||||
}
|
||||
|
||||
//we always use use U+00B0 (°) as the unit of measure for angles in
|
||||
//single unit schema. Will need a change to support rads or grads.
|
||||
QString qUnitString = QString::fromUtf8("°");
|
||||
|
||||
//get the numeric part of the user string
|
||||
QRegularExpression rxNoUnits(QString::fromUtf8("(.*)\\D*$")); // text before any non digits at end of string
|
||||
QRegularExpressionMatch match = rxNoUnits.match(qUserString);
|
||||
if (!match.hasMatch()) {
|
||||
//no units in userString?
|
||||
return Base::Tools::toStdString(qUserString);
|
||||
}
|
||||
QString matched = match.captured(1); //matched is the numeric part of user string
|
||||
int dpPos = matched.indexOf(QLocale().decimalPoint());
|
||||
if (dpPos < 0) {
|
||||
//no decimal separator (ie an integer), return all the digits
|
||||
return Base::Tools::toStdString(matched + qUnitString);
|
||||
}
|
||||
|
||||
//real number
|
||||
if (useSystemDecimals() ) {
|
||||
//return just the numeric part of the user string + degree symbol
|
||||
return Base::Tools::toStdString(matched + qUnitString);
|
||||
}
|
||||
|
||||
//real number and not using system decimals
|
||||
int requiredLength = dpPos + digits + 1;
|
||||
if (requiredLength > matched.size()) {
|
||||
//just take the whole thing
|
||||
requiredLength = matched.size();
|
||||
}
|
||||
QString numericPart = matched.left(requiredLength);
|
||||
return Base::Tools::toStdString(numericPart + qUnitString);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
#ifndef SKETCHERGUI_Recompute_H
|
||||
#define SKETCHERGUI_Recompute_H
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Mod/Sketcher/App/GeoEnum.h>
|
||||
#include "AutoConstraint.h"
|
||||
|
||||
@@ -34,8 +36,12 @@ namespace App {
|
||||
|
||||
namespace Gui {
|
||||
class DocumentObject;
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace Part {
|
||||
class Geometry;
|
||||
}
|
||||
namespace Sketcher {
|
||||
enum class PointPos : int;
|
||||
class SketchObject;
|
||||
@@ -123,6 +129,13 @@ void removeRedundantHorizontalVertical(Sketcher::SketchObject* psketch,
|
||||
|
||||
void ConstraintToAttachment(Sketcher::GeoElementId element, Sketcher::GeoElementId attachment, double distance, App::DocumentObject* obj);
|
||||
|
||||
//convenience functions for cursor coodinates
|
||||
bool hideUnits();
|
||||
bool showCursorCoords();
|
||||
bool useSystemDecimals();
|
||||
std::string lengthToDisplayFormat(double value, int digits);
|
||||
std::string angleToDisplayFormat(double value, int digits);
|
||||
|
||||
}
|
||||
|
||||
/// converts a 2D vector into a 3D vector in the XY plane
|
||||
@@ -139,5 +152,6 @@ auto toPointerVector(const std::vector<std::unique_ptr<T>> & vector) {
|
||||
|
||||
return vp;
|
||||
}
|
||||
|
||||
#endif // SKETCHERGUI_Recompute_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user