Sketcher: DSH - new cursor drawing functions

This commit is contained in:
Abdullah Tahiri
2023-11-11 07:01:21 +01:00
committed by abdullahtahiriyo
parent 4c888b6afe
commit e73d8e2e96
2 changed files with 38 additions and 6 deletions

View File

@@ -1144,16 +1144,45 @@ void DrawSketchHandler::drawPositionAtCursor(const Base::Vector2d& position)
void DrawSketchHandler::drawDirectionAtCursor(const Base::Vector2d& position,
const Base::Vector2d& origin)
{
if (!showCursorCoords()) {
return;
}
float length = (position - origin).Length();
float angle = (position - origin).GetAngle(Base::Vector2d(1.f, 0.f));
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);
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::drawWidthHeightAtCursor(const Base::Vector2d& position,
const double val1,
const double val2)
{
if (!showCursorCoords()) {
return;
}
SbString text;
std::string val1String = lengthToDisplayFormat(val1, 1);
std::string val2String = lengthToDisplayFormat(val2, 1);
text.sprintf(" (%s x %s)", val1String.c_str(), val2String.c_str());
setPositionText(position, text);
}
void DrawSketchHandler::drawDoubleAtCursor(const Base::Vector2d& position, const double val)
{
if (!showCursorCoords()) {
return;
}
SbString text;
std::string doubleString = lengthToDisplayFormat(val, 1);
text.sprintf(" (%s)", doubleString.c_str());
setPositionText(position, text);
}
std::unique_ptr<QWidget> DrawSketchHandler::createToolWidget() const

View File

@@ -282,6 +282,9 @@ protected:
void drawPositionAtCursor(const Base::Vector2d& position);
void drawDirectionAtCursor(const Base::Vector2d& position, const Base::Vector2d& origin);
void
drawWidthHeightAtCursor(const Base::Vector2d& position, const double val1, const double val2);
void drawDoubleAtCursor(const Base::Vector2d& position, const double radius);
int getPreselectPoint() const;
int getPreselectCurve() const;