Merge pull request #11267 from Ondsel-Development/pw_translate

[Sketcher] Translate DSH : replacement for rectangular array / move / copy / clone
This commit is contained in:
Chris Hennes
2024-02-12 13:24:08 -06:00
committed by GitHub
14 changed files with 1604 additions and 82 deletions

View File

@@ -70,6 +70,7 @@ SET(SketcherGui_SRCS
DrawSketchHandlerBSplineByInterpolation.h
DrawSketchHandlerPoint.h
DrawSketchHandlerFillet.h
DrawSketchHandlerTranslate.h
DrawSketchHandlerTrimming.h
DrawSketchHandlerExtend.h
DrawSketchHandlerSplitting.h

View File

@@ -54,6 +54,7 @@
#include "Utils.h"
#include "ViewProviderSketch.h"
#include "DrawSketchHandlerTranslate.h"
#include "DrawSketchHandlerOffset.h"
#include "DrawSketchHandlerRotate.h"
#include "DrawSketchHandlerScale.h"
@@ -2622,6 +2623,39 @@ bool CmdSketcherScale::isActive()
return isCommandActive(getActiveGuiDocument(), true);
}
// Translate / rectangular pattern tool =======================================================
DEF_STD_CMD_A(CmdSketcherTranslate)
CmdSketcherTranslate::CmdSketcherTranslate()
: Command("Sketcher_Translate")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Array transform");
sToolTipText = QT_TR_NOOP("Translate selected geometries. Enable creation of i * j copies.");
sWhatsThis = "Sketcher_Translate";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_Translate";
sAccel = "W";
eType = ForEdit;
}
void CmdSketcherTranslate::activated(int iMsg)
{
Q_UNUSED(iMsg);
std::vector<int> listOfGeoIds = getListOfSelectedGeoIds(true);
if (!listOfGeoIds.empty()) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerTranslate(listOfGeoIds));
}
getSelection().clearSelection();
}
bool CmdSketcherTranslate::isActive()
{
return isCommandActive(getActiveGuiDocument(), true);
}
void CreateSketcherCommandsConstraintAccel()
{
@@ -2638,6 +2672,7 @@ void CreateSketcherCommandsConstraintAccel()
rcCmdMgr.addCommand(new CmdSketcherSelectElementsAssociatedWithConstraints());
rcCmdMgr.addCommand(new CmdSketcherSelectElementsWithDoFs());
rcCmdMgr.addCommand(new CmdSketcherRestoreInternalAlignmentGeometry());
rcCmdMgr.addCommand(new CmdSketcherTranslate());
rcCmdMgr.addCommand(new CmdSketcherOffset());
rcCmdMgr.addCommand(new CmdSketcherRotate());
rcCmdMgr.addCommand(new CmdSketcherScale());

View File

@@ -183,6 +183,14 @@ private:
toolWidgetManager.secondKeyShortcut();
}
if (key == SoKeyboardEvent::R && !pressed && !this->isLastState()) {
toolWidgetManager.thirdKeyShortcut();
}
if (key == SoKeyboardEvent::F && !pressed && !this->isLastState()) {
toolWidgetManager.fourthKeyShortcut();
}
if (key == SoKeyboardEvent::TAB && !pressed) {
toolWidgetManager.tabShortcut();
}

View File

@@ -123,7 +123,8 @@ protected:
std::vector<std::unique_ptr<Gui::EditableDatumLabel>> onViewParameters;
// NOLINTEND
bool init = false; // true if the controls have been initialised.
bool init = false; // true if the controls have been initialised.
int parameterWithFocus = 0; // track the index of the parameter having the focus
/** @name Named indices for controlling on-view controls */
//@{
@@ -147,7 +148,6 @@ private:
Base::Vector2d prevCursorPosition;
Base::Vector2d lastControlEnforcedPosition;
int onViewIndexWithFocus = 0; // track the index of the on-view parameter having the focus
int nOnViewParameter = OnViewParametersT::defaultMethodSize();
/// Class to keep track of colors used by the on-view parameters
@@ -444,6 +444,12 @@ public:
virtual void secondKeyShortcut()
{}
virtual void thirdKeyShortcut()
{}
virtual void fourthKeyShortcut()
{}
virtual void tabShortcut()
{
passFocusToNextOnViewParameter();
@@ -514,8 +520,8 @@ protected:
virtual void afterEnforceControlParameters()
{
// Give focus to current on-view parameter. In case user interacted outside of 3dview.
if (onViewIndexWithFocus >= 0) {
setFocusToOnViewParameter(onViewIndexWithFocus);
if (parameterWithFocus >= 0) {
setFocusToOnViewParameter(parameterWithFocus);
}
}
@@ -599,7 +605,7 @@ protected:
double val,
const Base::Unit& unit = Base::Unit::Length)
{
bool visible = ovpVisibilityManager.isVisible(onViewParameters[index].get());
bool visible = isOnViewParameterVisible(index);
if (visible) {
onViewParameters[index]->setSpinboxValue(val, unit);
@@ -614,7 +620,7 @@ protected:
ovpVisibilityManager.resetDynamicOverride();
bool firstOfMode = true;
onViewIndexWithFocus = -1;
parameterWithFocus = -1;
for (size_t i = 0; i < onViewParameters.size(); i++) {
@@ -627,11 +633,11 @@ protected:
else {
if (firstOfMode) {
onViewIndexWithFocus = static_cast<int>(i);
parameterWithFocus = static_cast<int>(i);
firstOfMode = false;
}
bool visible = ovpVisibilityManager.isVisible(onViewParameters[i].get());
bool visible = isOnViewParameterVisible(i);
if (visible) {
onViewParameters[i]->activate();
@@ -646,52 +652,46 @@ protected:
}
/// This function gives the focus to a spinbox and tracks the focus.
void setFocusToOnViewParameter(unsigned int onviewparameterindex)
bool setFocusToOnViewParameter(unsigned int onviewparameterindex)
{
if (onviewparameterindex < onViewParameters.size()) {
bool visible =
ovpVisibilityManager.isVisible(onViewParameters[onviewparameterindex].get());
bool visible = isOnViewParameterVisible(onviewparameterindex);
if (visible) {
onViewParameters[onviewparameterindex]->setFocusToSpinbox();
parameterWithFocus = static_cast<int>(onviewparameterindex);
return true;
}
onViewIndexWithFocus = static_cast<int>(onviewparameterindex);
}
return false;
}
/// Switches focus to the next parameter in the current state machine.
void passFocusToNextOnViewParameter()
{
unsigned int index = onViewIndexWithFocus + 1;
unsigned int index = parameterWithFocus + 1;
if (index >= onViewParameters.size()) {
index = 0;
}
bool visible = ovpVisibilityManager.isVisible(onViewParameters[index].get());
while (index < onViewParameters.size()) {
if (isOnViewParameterOfCurrentMode(index)) {
if (visible) {
setFocusToOnViewParameter(index);
auto trySetFocus = [this](unsigned int& idx) -> bool {
while (idx < onViewParameters.size()) {
if (isOnViewParameterOfCurrentMode(idx) && isOnViewParameterVisible(idx)) {
setFocusToOnViewParameter(idx);
return true;
}
return;
idx++;
}
index++;
}
// There is no more onViewParameter after onViewIndexWithFocus + 1 in this mode
return false;
};
// So we go back to start.
index = 0;
while (index < onViewParameters.size()) {
if (isOnViewParameterOfCurrentMode(index)) {
setFocusToOnViewParameter(index);
return;
}
index++;
if (!trySetFocus(index)) {
// We have not found a parameter in this mode after current.
// So we go back to start and retry.
index = 0;
trySetFocus(index);
}
// At that point if no onViewParameter is found, there is none.
@@ -713,12 +713,17 @@ protected:
&& getState(onviewparameterindex) < handler->state();
}
bool isOnViewParameterVisible(unsigned int onviewparameterindex)
{
return ovpVisibilityManager.isVisible(onViewParameters[onviewparameterindex].get());
}
/** Resets the on-view parameter controls */
void resetOnViewParameters()
{
nOnViewParameter = OnViewParametersT::size(handler->constructionMethod());
initNOnViewParameters(nOnViewParameter);
onViewIndexWithFocus = 0;
parameterWithFocus = 0;
configureOnViewParameters();
}

View File

@@ -100,6 +100,7 @@ private:
using Connection = boost::signals2::connection;
Connection connectionParameterFocusOut;
Connection connectionParameterValueChanged;
Connection connectionCheckboxCheckedChanged;
Connection connectionComboboxSelectionChanged;
@@ -127,6 +128,7 @@ public:
~DrawSketchDefaultWidgetController() override
{
connectionParameterFocusOut.disconnect();
connectionParameterValueChanged.disconnect();
connectionCheckboxCheckedChanged.disconnect();
connectionComboboxSelectionChanged.disconnect();
@@ -148,6 +150,12 @@ public:
ControllerBase::finishControlsChanged();
}
void parameterFocusOut(int parameterindex)
{
Q_UNUSED(parameterindex);
passFocusToNextParameter();
}
/** boost slot triggering when a checkbox has changed in the widget
* It is intended to remote control the DrawSketchDefaultWidgetHandler
*/
@@ -220,7 +228,7 @@ public:
Q_UNUSED(onSketchPos)
}
/** on first shortcut, it toggles the first checkbox if there is go. Must be specialised if
/** on first shortcut, it toggles the first checkbox if there is one. Must be specialised if
* this is not intended */
void firstKeyShortcut() override
{
@@ -230,7 +238,7 @@ public:
}
}
/** on second shortcut, it toggles the second checkbox if there is go. Must be specialised if
/** on second shortcut, it toggles the second checkbox if there is one. Must be specialised if
* this is not intended */
void secondKeyShortcut() override
{
@@ -240,6 +248,32 @@ public:
}
}
/** on third shortcut, it toggles the third checkbox if there is one. Must be specialised if
* this is not intended */
void thirdKeyShortcut() override
{
if (nCheckbox >= 3) {
auto thirdchecked = toolWidget->getCheckboxChecked(WCheckbox::ThirdBox);
toolWidget->setCheckboxChecked(WCheckbox::ThirdBox, !thirdchecked);
}
}
/** on fourth shortcut, it toggles the fourth checkbox if there is one. Must be specialised if
* this is not intended */
void fourthKeyShortcut() override
{
if (nCheckbox >= 4) {
auto fourthchecked = toolWidget->getCheckboxChecked(WCheckbox::FourthBox);
toolWidget->setCheckboxChecked(WCheckbox::FourthBox, !fourthchecked);
}
}
/** on tab, we cycle through OVP and widget parameters */
void tabShortcut() override
{
passFocusToNextParameter();
}
//@}
protected:
@@ -262,6 +296,57 @@ protected:
/// Automatic default method update in combobox
void doConstructionMethodChanged() override
{}
/// here we can pass focus to either OVP or widget parameters.
void setFocusToParameter(unsigned int parameterindex)
{
// To be able to cycle through OVP and widget, we use a parameter index that goes from
// 0 to (onViewParameters.size() + nParameter)
if (!ControllerBase::setFocusToOnViewParameter(parameterindex)) {
parameterindex = parameterindex - ControllerBase::onViewParameters.size();
if (parameterindex < static_cast<unsigned int>(nParameter)) {
toolWidget->setParameterFocus(parameterindex);
ControllerBase::parameterWithFocus =
ControllerBase::onViewParameters.size() + parameterindex;
}
}
}
/// Here we can pass focus to either OVP or widget parameters.
void passFocusToNextParameter()
{
unsigned int index = ControllerBase::parameterWithFocus + 1;
if (index >= ControllerBase::onViewParameters.size() + nParameter) {
index = 0;
}
auto trySetFocus = [this](unsigned int& idx) -> bool {
while (idx < ControllerBase::onViewParameters.size()) {
if (ControllerBase::isOnViewParameterOfCurrentMode(idx)
&& ControllerBase::isOnViewParameterVisible(idx)) {
setFocusToParameter(idx);
return true;
}
idx++;
}
if (idx < ControllerBase::onViewParameters.size() + nParameter) {
setFocusToParameter(idx);
return true;
}
return false;
};
if (!trySetFocus(index)) {
// We have not found a parameter in this mode after current.
// So we go back to start and retry.
index = 0;
trySetFocus(index);
}
// At that point if no onViewParameter is found, there is none.
}
//@}
private:
@@ -270,6 +355,9 @@ private:
{
toolWidget = static_cast<SketcherToolDefaultWidget*>(widget); // NOLINT
connectionParameterFocusOut = toolWidget->registerParameterFocusOut(
std::bind(&DrawSketchDefaultWidgetController::parameterFocusOut, this, sp::_1));
connectionParameterValueChanged = toolWidget->registerParameterValueChanged(
std::bind(&DrawSketchDefaultWidgetController::parameterValueChanged,
this,
@@ -292,6 +380,7 @@ private:
/// Resets the widget
void resetDefaultWidget()
{
boost::signals2::shared_connection_block parameter_focus_block(connectionParameterFocusOut);
boost::signals2::shared_connection_block parameter_block(connectionParameterValueChanged);
boost::signals2::shared_connection_block checkbox_block(connectionCheckboxCheckedChanged);
boost::signals2::shared_connection_block combobox_block(connectionComboboxSelectionChanged);

View File

@@ -286,7 +286,7 @@ template<>
void DSHPolygonController::firstKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::First);
toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value + 1);
toolWidget->setParameterWithoutPassingFocus(WParameter::First, value + 1);
}
template<>
@@ -294,7 +294,7 @@ void DSHPolygonController::secondKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::First);
if (value > 3.0) { // NOLINT
toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value - 1);
toolWidget->setParameterWithoutPassingFocus(WParameter::First, value - 1);
}
}

View File

@@ -456,7 +456,7 @@ template<>
void DSHRotateController::firstKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::First);
toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value + 1);
toolWidget->setParameterWithoutPassingFocus(WParameter::First, value + 1);
}
template<>
@@ -464,7 +464,7 @@ void DSHRotateController::secondKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::First);
if (value > 0.0) {
toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value - 1);
toolWidget->setParameterWithoutPassingFocus(WParameter::First, value - 1);
}
}

View File

@@ -0,0 +1,726 @@
/***************************************************************************
* Copyright (c) 2022 Boyer Pierre-Louis <pierrelouis.boyer@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef SKETCHERGUI_DrawSketchHandlerTranslate_H
#define SKETCHERGUI_DrawSketchHandlerTranslate_H
#include <QApplication>
#include <Gui/BitmapFactory.h>
#include <Gui/Notifications.h>
#include <Gui/Command.h>
#include <Gui/CommandT.h>
#include <Mod/Sketcher/App/GeometryFacade.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include "DrawSketchDefaultWidgetController.h"
#include "DrawSketchControllableHandler.h"
#include "GeometryCreationMode.h"
#include "Utils.h"
using namespace Sketcher;
namespace SketcherGui
{
class DrawSketchHandlerTranslate;
using DSHTranslateController =
DrawSketchDefaultWidgetController<DrawSketchHandlerTranslate,
StateMachines::ThreeSeekEnd,
/*PAutoConstraintSize =*/0,
/*OnViewParametersT =*/OnViewParameters<6>,
/*WidgetParametersT =*/WidgetParameters<2>,
/*WidgetCheckboxesT =*/WidgetCheckboxes<1>,
/*WidgetComboboxesT =*/WidgetComboboxes<0>>;
using DSHTranslateControllerBase = DSHTranslateController::ControllerBase;
using DrawSketchHandlerTranslateBase = DrawSketchControllableHandler<DSHTranslateController>;
class DrawSketchHandlerTranslate: public DrawSketchHandlerTranslateBase
{
friend DSHTranslateController;
friend DSHTranslateControllerBase;
public:
explicit DrawSketchHandlerTranslate(std::vector<int> listOfGeoIds)
: listOfGeoIds(listOfGeoIds)
, deleteOriginal(false)
, cloneConstraints(false)
, numberOfCopies(0)
, secondNumberOfCopies(1)
{}
DrawSketchHandlerTranslate(const DrawSketchHandlerTranslate&) = delete;
DrawSketchHandlerTranslate(DrawSketchHandlerTranslate&&) = delete;
DrawSketchHandlerTranslate& operator=(const DrawSketchHandlerTranslate&) = delete;
DrawSketchHandlerTranslate& operator=(DrawSketchHandlerTranslate&&) = delete;
~DrawSketchHandlerTranslate() override = default;
private:
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
{
switch (state()) {
case SelectMode::SeekFirst: {
referencePoint = onSketchPos;
} break;
case SelectMode::SeekSecond: {
firstTranslationPoint = onSketchPos;
firstTranslationVector = toVector3d(firstTranslationPoint - referencePoint);
CreateAndDrawShapeGeometry();
} break;
case SelectMode::SeekThird: {
secondTranslationPoint = onSketchPos;
secondTranslationVector = toVector3d(secondTranslationPoint - referencePoint);
CreateAndDrawShapeGeometry();
} break;
default:
break;
}
}
void executeCommands() override
{
try {
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Translate geometries"));
createShape(false);
commandAddShapeGeometryAndConstraints();
if (deleteOriginal) {
deleteOriginalGeos();
}
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
e.ReportException();
Gui::NotifyError(sketchgui,
QT_TRANSLATE_NOOP("Notifications", "Error"),
QT_TRANSLATE_NOOP("Notifications", "Failed to translate"));
Gui::Command::abortCommand();
THROWM(Base::RuntimeError,
QT_TRANSLATE_NOOP(
"Notifications",
"Tool execution aborted") "\n") // This prevents constraints from being
// applied on non existing geometry
}
}
void createAutoConstraints() override
{
// none
}
std::string getToolName() const override
{
return "DSH_Translate";
}
QString getCrosshairCursorSVGName() const override
{
return QString::fromLatin1("Sketcher_Pointer_Create_Translate");
}
std::unique_ptr<QWidget> createWidget() const override
{
return std::make_unique<SketcherToolDefaultWidget>();
}
bool isWidgetVisible() const override
{
return true;
};
QPixmap getToolIcon() const override
{
return Gui::BitmapFactory().pixmap("Sketcher_Translate");
}
QString getToolWidgetText() const override
{
return QString(QObject::tr("Translate parameters"));
}
void onButtonPressed(Base::Vector2d onSketchPos) override
{
this->updateDataAndDrawToPosition(onSketchPos);
if (state() == SelectMode::SeekSecond && secondNumberOfCopies == 1) {
setState(SelectMode::End);
}
else {
this->moveToNextMode();
}
}
void activated() override
{
DrawSketchDefaultHandler::activated();
continuousMode = false;
}
bool canGoToNextMode() override
{
if (state() == SelectMode::SeekSecond
&& firstTranslationVector.Length() < Precision::Confusion()) {
// Prevent validation of null translation.
return false;
}
if (state() == SelectMode::SeekThird
&& secondTranslationVector.Length() < Precision::Confusion()
&& secondNumberOfCopies > 1) {
return false;
}
return true;
}
void angleSnappingControl() override
{
if (state() == SelectMode::SeekSecond || state() == SelectMode::SeekThird) {
setAngleSnapping(true, referencePoint);
}
else {
setAngleSnapping(false);
}
}
private:
std::vector<int> listOfGeoIds;
Base::Vector2d referencePoint, firstTranslationPoint, secondTranslationPoint;
Base::Vector3d firstTranslationVector, secondTranslationVector;
bool deleteOriginal, cloneConstraints;
int numberOfCopies, secondNumberOfCopies;
void deleteOriginalGeos()
{
std::stringstream stream;
for (size_t j = 0; j < listOfGeoIds.size() - 1; j++) {
stream << listOfGeoIds[j] << ",";
}
stream << listOfGeoIds[listOfGeoIds.size() - 1];
try {
Gui::cmdAppObjectArgs(sketchgui->getObject(),
"delGeometries([%s])",
stream.str().c_str());
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
}
void createShape(bool onlyeditoutline) override
{
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
ShapeGeometry.clear();
int numberOfCopiesToMake = numberOfCopies;
if (numberOfCopies == 0) {
numberOfCopiesToMake = 1;
deleteOriginal = 1;
}
else {
deleteOriginal = 0;
}
for (int k = 0; k < secondNumberOfCopies; k++) {
for (int i = 0; i <= numberOfCopiesToMake; i++) {
if ((k == 0 && i == 0)) {
continue;
}
Base::Vector3d vec = firstTranslationVector * i + secondTranslationVector * k;
for (auto& geoId : listOfGeoIds) {
const Part::Geometry* pGeo = Obj->getGeometry(geoId);
auto geoUniquePtr = std::unique_ptr<Part::Geometry>(pGeo->copy());
Part::Geometry* geo = geoUniquePtr.get();
if (isCircle(*geo)) {
Part::GeomCircle* circle = static_cast<Part::GeomCircle*>(geo); // NOLINT
circle->setCenter(circle->getCenter() + vec);
}
else if (isArcOfCircle(*geo)) {
Part::GeomArcOfCircle* arc =
static_cast<Part::GeomArcOfCircle*>(geo); // NOLINT
arc->setCenter(arc->getCenter() + vec);
}
else if (isEllipse(*geo)) {
Part::GeomEllipse* ellipse =
static_cast<Part::GeomEllipse*>(geo); // NOLINT
ellipse->setCenter(ellipse->getCenter() + vec);
}
else if (isArcOfEllipse(*geo)) {
Part::GeomArcOfEllipse* aoe =
static_cast<Part::GeomArcOfEllipse*>(geo); // NOLINT
aoe->setCenter(aoe->getCenter() + vec);
}
else if (isArcOfHyperbola(*geo)) {
Part::GeomArcOfHyperbola* aoh =
static_cast<Part::GeomArcOfHyperbola*>(geo); // NOLINT
aoh->setCenter(aoh->getCenter() + vec);
}
else if (isArcOfParabola(*geo)) {
Part::GeomArcOfParabola* aop =
static_cast<Part::GeomArcOfParabola*>(geo); // NOLINT
aop->setCenter(aop->getCenter() + vec);
}
else if (isLineSegment(*geo)) {
auto* line = static_cast<Part::GeomLineSegment*>(geo); // NOLINT
line->setPoints(line->getStartPoint() + vec, line->getEndPoint() + vec);
}
else if (isBSplineCurve(*geo)) {
auto* bSpline = static_cast<Part::GeomBSplineCurve*>(geo); // NOLINT
std::vector<Base::Vector3d> poles = bSpline->getPoles();
for (size_t p = 0; p < poles.size(); p++) {
poles[p] = poles[p] + vec;
}
bSpline->setPoles(poles);
}
else if (isPoint(*geo)) {
auto* point = static_cast<Part::GeomPoint*>(geo); // NOLINT
point->setPoint(point->getPoint() + vec);
}
ShapeGeometry.emplace_back(std::move(geoUniquePtr));
}
}
}
if (onlyeditoutline) {
// Add the lines to show angle
if (firstTranslationVector.Length() > Precision::Confusion()) {
addLineToShapeGeometry(toVector3d(referencePoint),
toVector3d(firstTranslationPoint),
true);
}
if (secondTranslationVector.Length() > Precision::Confusion()) {
addLineToShapeGeometry(toVector3d(referencePoint),
toVector3d(secondTranslationPoint),
true);
}
}
else {
int firstCurveCreated = getHighestCurveIndex() + 1;
int size = static_cast<int>(listOfGeoIds.size());
const std::vector<Sketcher::Constraint*>& vals = Obj->Constraints.getValues();
// avoid applying equal several times if cloning distanceX and distanceY of the
// same part.
std::vector<int> geoIdsWhoAlreadyHasEqual = {};
for (auto& cstr : vals) {
int firstIndex = indexOfGeoId(listOfGeoIds, cstr->First);
int secondIndex = indexOfGeoId(listOfGeoIds, cstr->Second);
int thirdIndex = indexOfGeoId(listOfGeoIds, cstr->Third);
for (int k = 0; k < secondNumberOfCopies; k++) {
for (int i = 0; i <= numberOfCopiesToMake; i++) {
if (k == 0 && i == 0) {
continue;
}
int firstIndexi = firstCurveCreated + firstIndex + size * (i - 1)
+ size * (numberOfCopiesToMake + 1) * k;
int secondIndexi = firstCurveCreated + secondIndex + size * (i - 1)
+ size * (numberOfCopiesToMake + 1) * k;
int thirdIndexi = firstCurveCreated + thirdIndex + size * (i - 1)
+ size * (numberOfCopiesToMake + 1) * k;
auto newConstr = std::unique_ptr<Constraint>(cstr->copy());
newConstr->First = firstIndexi;
if ((cstr->Type == Symmetric || cstr->Type == Tangent
|| cstr->Type == Perpendicular || cstr->Type == Angle)
&& firstIndex >= 0 && secondIndex >= 0 && thirdIndex >= 0) {
newConstr->Second = secondIndexi;
newConstr->Third = thirdIndexi;
}
else if ((cstr->Type == Coincident || cstr->Type == Tangent
|| cstr->Type == Symmetric || cstr->Type == Perpendicular
|| cstr->Type == Parallel || cstr->Type == Equal
|| cstr->Type == Angle || cstr->Type == PointOnObject
|| cstr->Type == InternalAlignment)
&& firstIndex >= 0 && secondIndex >= 0
&& thirdIndex == GeoEnum::GeoUndef) {
newConstr->Second = secondIndexi;
}
else if ((cstr->Type == Radius || cstr->Type == Diameter
|| cstr->Type == Weight)
&& firstIndex >= 0) {
if (deleteOriginal || !cloneConstraints) {
newConstr->setValue(cstr->getValue());
}
else {
newConstr->Type = Equal;
newConstr->First = cstr->First;
newConstr->Second = firstIndexi;
}
}
else if ((cstr->Type == Distance || cstr->Type == DistanceX
|| cstr->Type == DistanceY)
&& firstIndex >= 0 && secondIndex >= 0) {
if (!deleteOriginal && cloneConstraints
&& cstr->First == cstr->Second) { // only line distances
if (indexOfGeoId(geoIdsWhoAlreadyHasEqual, secondIndexi) != -1) {
continue;
}
newConstr->Type = Equal;
newConstr->First = cstr->First;
newConstr->Second = secondIndexi;
geoIdsWhoAlreadyHasEqual.push_back(secondIndexi);
}
else {
newConstr->Second = secondIndexi;
}
}
else if ((cstr->Type == Block) && firstIndex >= 0) {
newConstr->First = firstIndexi;
}
else {
continue;
}
ShapeConstraints.push_back(std::move(newConstr));
}
}
}
}
}
};
template<>
auto DSHTranslateControllerBase::getState(int labelindex) const
{
switch (labelindex) {
case OnViewParameter::First:
case OnViewParameter::Second:
return SelectMode::SeekFirst;
break;
case OnViewParameter::Third:
case OnViewParameter::Fourth:
return SelectMode::SeekSecond;
break;
case OnViewParameter::Fifth:
case OnViewParameter::Sixth:
return SelectMode::SeekThird;
break;
default:
THROWM(Base::ValueError, "OnViewParameter index without an associated machine state")
}
}
template<>
void DSHTranslateController::firstKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::First);
toolWidget->setParameterWithoutPassingFocus(WParameter::First, value + 1);
}
template<>
void DSHTranslateController::secondKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::First);
if (value > 0.0) {
toolWidget->setParameterWithoutPassingFocus(WParameter::First, value - 1);
}
}
template<>
void DSHTranslateController::thirdKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::Second);
toolWidget->setParameterWithoutPassingFocus(WParameter::Second, value + 1);
}
template<>
void DSHTranslateController::fourthKeyShortcut()
{
auto value = toolWidget->getParameter(WParameter::Second);
if (value > 1.0) {
toolWidget->setParameterWithoutPassingFocus(WParameter::Second, value - 1);
}
}
template<>
void DSHTranslateController::configureToolWidget()
{
if (!init) { // Code to be executed only upon initialisation
toolWidget->setCheckboxLabel(
WCheckbox::FirstBox,
QApplication::translate("TaskSketcherTool_c1_translate", "Clone constraints"));
toolWidget->setCheckboxToolTip(
WCheckbox::FirstBox,
QApplication::translate(
"TaskSketcherTool_c1_translate",
"This concerns the datum constraints like distances. If you activate Clone, "
"then the tool will copy the datum. Else it will try to replace them with "
"equalities between the initial geometries and the new copies."));
}
onViewParameters[OnViewParameter::First]->setLabelType(Gui::SoDatumLabel::DISTANCEX);
onViewParameters[OnViewParameter::Second]->setLabelType(Gui::SoDatumLabel::DISTANCEY);
onViewParameters[OnViewParameter::Third]->setLabelType(
Gui::SoDatumLabel::DISTANCE,
Gui::EditableDatumLabel::Function::Dimensioning);
onViewParameters[OnViewParameter::Fourth]->setLabelType(
Gui::SoDatumLabel::ANGLE,
Gui::EditableDatumLabel::Function::Dimensioning);
onViewParameters[OnViewParameter::Fifth]->setLabelType(
Gui::SoDatumLabel::DISTANCE,
Gui::EditableDatumLabel::Function::Dimensioning);
onViewParameters[OnViewParameter::Sixth]->setLabelType(
Gui::SoDatumLabel::ANGLE,
Gui::EditableDatumLabel::Function::Dimensioning);
toolWidget->setParameterLabel(
WParameter::First,
QApplication::translate("TaskSketcherTool_p3_translate", "Copies (+'U'/-'J')"));
toolWidget->setParameterLabel(
WParameter::Second,
QApplication::translate("TaskSketcherTool_p5_translate", "Rows (+'R'/-'F')"));
toolWidget->setParameter(OnViewParameter::First, 0.0);
toolWidget->setParameter(OnViewParameter::Second, 1.0);
toolWidget->configureParameterUnit(OnViewParameter::First, Base::Unit());
toolWidget->configureParameterUnit(OnViewParameter::Second, Base::Unit());
toolWidget->configureParameterMin(OnViewParameter::First, 0.0); // NOLINT
toolWidget->configureParameterMin(OnViewParameter::Second, 0.0); // NOLINT
toolWidget->configureParameterMax(OnViewParameter::First, 9999.0); // NOLINT
toolWidget->configureParameterMax(OnViewParameter::Second, 9999.0); // NOLINT
toolWidget->configureParameterDecimals(OnViewParameter::First, 0);
toolWidget->configureParameterDecimals(OnViewParameter::Second, 0);
}
template<>
void DSHTranslateController::adaptDrawingToParameterChange(int parameterindex, double value)
{
switch (parameterindex) {
case WParameter::First:
handler->numberOfCopies = floor(abs(value));
break;
case WParameter::Second:
handler->secondNumberOfCopies = floor(abs(value));
break;
}
}
template<>
void DSHTranslateController::adaptDrawingToCheckboxChange(int checkboxindex, bool value)
{
switch (checkboxindex) {
case WCheckbox::FirstBox: {
handler->cloneConstraints = value;
} break;
}
}
template<>
void DSHTranslateControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchPos)
{
switch (handler->state()) {
case SelectMode::SeekFirst: {
if (onViewParameters[OnViewParameter::First]->isSet) {
onSketchPos.x = onViewParameters[OnViewParameter::First]->getValue();
}
if (onViewParameters[OnViewParameter::Second]->isSet) {
onSketchPos.y = onViewParameters[OnViewParameter::Second]->getValue();
}
} break;
case SelectMode::SeekSecond: {
Base::Vector2d dir = onSketchPos - handler->referencePoint;
if (dir.Length() < Precision::Confusion()) {
dir.x = 1.0; // if direction null, default to (1,0)
}
double length = dir.Length();
if (onViewParameters[OnViewParameter::Third]->isSet) {
length = onViewParameters[OnViewParameter::Third]->getValue();
if (length < Precision::Confusion()) {
unsetOnViewParameter(onViewParameters[OnViewParameter::Third].get());
return;
}
onSketchPos = handler->referencePoint + length * dir.Normalize();
}
if (onViewParameters[OnViewParameter::Fourth]->isSet) {
double angle = onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180;
onSketchPos.x = handler->referencePoint.x + cos(angle) * length;
onSketchPos.y = handler->referencePoint.y + sin(angle) * length;
}
} break;
case SelectMode::SeekThird: {
Base::Vector2d dir = onSketchPos - handler->referencePoint;
if (dir.Length() < Precision::Confusion()) {
dir.x = 1.0; // if direction null, default to (1,0)
}
double length = dir.Length();
if (onViewParameters[OnViewParameter::Fifth]->isSet) {
length = onViewParameters[OnViewParameter::Fifth]->getValue();
if (length < Precision::Confusion()) {
unsetOnViewParameter(onViewParameters[OnViewParameter::Fifth].get());
return;
}
onSketchPos = handler->referencePoint + length * dir.Normalize();
}
if (onViewParameters[OnViewParameter::Sixth]->isSet) {
double angle = onViewParameters[OnViewParameter::Sixth]->getValue() * M_PI / 180;
onSketchPos.x = handler->referencePoint.x + cos(angle) * length;
onSketchPos.y = handler->referencePoint.y + sin(angle) * length;
}
} break;
default:
break;
}
}
template<>
void DSHTranslateController::adaptParameters(Base::Vector2d onSketchPos)
{
switch (handler->state()) {
case SelectMode::SeekFirst: {
if (!onViewParameters[OnViewParameter::First]->isSet) {
setOnViewParameterValue(OnViewParameter::First, onSketchPos.x);
}
if (!onViewParameters[OnViewParameter::Second]->isSet) {
setOnViewParameterValue(OnViewParameter::Second, onSketchPos.y);
}
bool sameSign = onSketchPos.x * onSketchPos.y > 0.;
onViewParameters[OnViewParameter::First]->setLabelAutoDistanceReverse(!sameSign);
onViewParameters[OnViewParameter::Second]->setLabelAutoDistanceReverse(sameSign);
onViewParameters[OnViewParameter::First]->setPoints(Base::Vector3d(),
toVector3d(onSketchPos));
onViewParameters[OnViewParameter::Second]->setPoints(Base::Vector3d(),
toVector3d(onSketchPos));
} break;
case SelectMode::SeekSecond: {
if (!onViewParameters[OnViewParameter::Third]->isSet) {
onViewParameters[OnViewParameter::Third]->setSpinboxValue(
(onSketchPos - handler->referencePoint).Length());
}
Base::Vector2d vec2d = Base::Vector2d(handler->firstTranslationVector.x,
handler->firstTranslationVector.y);
double angle = vec2d.Angle();
double range = angle * 180 / M_PI;
if (!onViewParameters[OnViewParameter::Fourth]->isSet) {
onViewParameters[OnViewParameter::Fourth]->setSpinboxValue(range,
Base::Unit::Angle);
}
Base::Vector3d start = toVector3d(handler->referencePoint);
Base::Vector3d end = toVector3d(onSketchPos);
onViewParameters[OnViewParameter::Third]->setPoints(start, end);
onViewParameters[OnViewParameter::Fourth]->setPoints(start, Base::Vector3d());
onViewParameters[OnViewParameter::Fourth]->setLabelRange(angle);
} break;
case SelectMode::SeekThird: {
if (!onViewParameters[OnViewParameter::Fifth]->isSet) {
onViewParameters[OnViewParameter::Fifth]->setSpinboxValue(
(onSketchPos - handler->referencePoint).Length());
}
Base::Vector2d vec2d = Base::Vector2d(handler->secondTranslationVector.x,
handler->secondTranslationVector.y);
double angle = vec2d.Angle();
double range = angle * 180 / M_PI;
if (!onViewParameters[OnViewParameter::Sixth]->isSet) {
setOnViewParameterValue(OnViewParameter::Sixth, range, Base::Unit::Angle);
}
Base::Vector3d start = toVector3d(handler->referencePoint);
Base::Vector3d end = toVector3d(onSketchPos);
onViewParameters[OnViewParameter::Fifth]->setPoints(start, end);
onViewParameters[OnViewParameter::Sixth]->setPoints(start, Base::Vector3d());
onViewParameters[OnViewParameter::Sixth]->setLabelRange(angle);
} break;
default:
break;
}
}
template<>
void DSHTranslateController::doChangeDrawSketchHandlerMode()
{
switch (handler->state()) {
case SelectMode::SeekFirst: {
if (onViewParameters[OnViewParameter::First]->isSet
&& onViewParameters[OnViewParameter::Second]->isSet) {
handler->setState(SelectMode::SeekSecond);
}
} break;
case SelectMode::SeekSecond: {
if (onViewParameters[OnViewParameter::Third]->isSet
&& onViewParameters[OnViewParameter::Fourth]->isSet) {
if (handler->secondNumberOfCopies == 1) {
handler->setState(SelectMode::End);
}
else {
handler->setState(SelectMode::SeekThird);
}
}
} break;
case SelectMode::SeekThird: {
if (onViewParameters[OnViewParameter::Fifth]->isSet
&& onViewParameters[OnViewParameter::Sixth]->isSet) {
handler->setState(SelectMode::End);
}
} break;
default:
break;
}
}
} // namespace SketcherGui
#endif // SKETCHERGUI_DrawSketchHandlerTranslate_H

View File

@@ -239,6 +239,7 @@
<file>icons/pointers/Sketcher_Pointer_Create_Periodic_BSplineByInterpolation.svg</file>
<file>icons/pointers/Sketcher_Pointer_Create_Point.svg</file>
<file>icons/pointers/Sketcher_Pointer_Create_PointFillet.svg</file>
<file>icons/pointers/Sketcher_Pointer_Create_Translate.svg</file>
<file>icons/pointers/Sketcher_Pointer_Create_Offset.svg</file>
<file>icons/pointers/Sketcher_Pointer_Create_Rotate.svg</file>
<file>icons/pointers/Sketcher_Pointer_Create_Scale.svg</file>
@@ -302,6 +303,7 @@
<file>icons/tools/Sketcher_Offset.svg</file>
<file>icons/tools/Sketcher_OffsetArc.svg</file>
<file>icons/tools/Sketcher_OffsetIntersection.svg</file>
<file>icons/tools/Sketcher_Translate.svg</file>
</qresource>
<qresource>
<file>icons/dialogs/Sketcher_Settings.svg</file>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
height="64"
width="64"
id="svg12"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs16">
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path4362" />
</marker>
</defs>
<g
id="crosshair"
style="stroke:#ffffff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter">
<path
d="m16,3v9m0,8v9m-13-13h9m8,0h9"
id="path9" />
</g>
<g
id="g1"
transform="translate(-3.458469,-1.3832893)">
<path
style="fill:none;stroke:#cc0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 43.992747,29.448698 v 23.19836"
id="path6036-4" />
<circle
cx="43.992748"
cy="29.448698"
r="5"
id="circle6"
style="fill:none;stroke:#cc0000;stroke-width:2" />
<circle
cx="43.992748"
cy="52.647057"
r="5"
id="circle1"
style="fill:none;stroke:#cc0000;stroke-width:2" />
</g>
<g
id="g3"
transform="translate(-18.92419,3.3529434)">
<path
style="fill:none;stroke:#cc0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 43.992747,29.448698 v 23.19836"
id="path1" />
<circle
cx="43.992748"
cy="29.448698"
r="5"
id="circle2"
style="fill:none;stroke:#cc0000;stroke-width:2" />
<circle
cx="43.992748"
cy="52.647057"
r="5"
id="circle3"
style="fill:none;stroke:#cc0000;stroke-width:2" />
</g>
<g
id="g5"
transform="translate(12.007252,-6.119522)">
<path
style="fill:none;stroke:#cc0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 43.992747,29.448698 v 23.19836"
id="path3" />
<circle
cx="43.992748"
cy="29.448698"
r="5"
id="circle4"
style="fill:none;stroke:#cc0000;stroke-width:2" />
<circle
cx="43.992748"
cy="52.647057"
r="5"
id="circle5"
style="fill:none;stroke:#cc0000;stroke-width:2" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,585 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64"
height="64"
id="svg2869"
version="1.1"
viewBox="0 0 64 64"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs2871">
<linearGradient
id="linearGradient62">
<stop
style="stop-color:#d3d7cf;stop-opacity:1;"
offset="0"
id="stop62" />
<stop
style="stop-color:#eeeeec;stop-opacity:1;"
offset="1"
id="stop61" />
</linearGradient>
<linearGradient
id="linearGradient5">
<stop
style="stop-color:#ef2929;stop-opacity:1;"
offset="0"
id="stop19" />
<stop
style="stop-color:#ef2929;stop-opacity:0;"
offset="1"
id="stop20" />
</linearGradient>
<linearGradient
id="swatch18">
<stop
style="stop-color:#ef2929;stop-opacity:1;"
offset="0"
id="stop18" />
</linearGradient>
<linearGradient
id="swatch15">
<stop
style="stop-color:#3d0000;stop-opacity:1;"
offset="0"
id="stop15" />
</linearGradient>
<linearGradient
id="linearGradient5-1">
<stop
style="stop-color:#ef2929;stop-opacity:1;"
offset="0"
id="stop5" />
<stop
style="stop-color:#ef2929;stop-opacity:0;"
offset="1"
id="stop6" />
</linearGradient>
<linearGradient
id="linearGradient3836-9">
<stop
style="stop-color:#a40000;stop-opacity:1"
offset="0"
id="stop3838-8" />
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="1"
id="stop3840-1" />
</linearGradient>
<linearGradient
id="linearGradient3836-9-3">
<stop
style="stop-color:#a40000;stop-opacity:1"
offset="0"
id="stop3838-8-5" />
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="1"
id="stop3840-1-6" />
</linearGradient>
<linearGradient
y2="5"
x2="-22"
y1="18"
x1="-18"
gradientUnits="userSpaceOnUse"
id="linearGradient3082"
xlink:href="#linearGradient3836-9-3" />
<linearGradient
id="linearGradient3836-9-7">
<stop
style="stop-color:#a40000;stop-opacity:1"
offset="0"
id="stop3838-8-0" />
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="1"
id="stop3840-1-9" />
</linearGradient>
<linearGradient
y2="5"
x2="-22"
y1="18"
x1="-18"
gradientUnits="userSpaceOnUse"
id="linearGradient3082-3"
xlink:href="#linearGradient3836-9-7" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient3801-1-3"
gradientUnits="userSpaceOnUse"
x1="-18"
y1="18"
x2="-22"
y2="5"
gradientTransform="matrix(0.76342439,0,0,0.75750425,-4.596389,2.7525637)" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient3801-1-3-2"
gradientUnits="userSpaceOnUse"
x1="-18"
y1="18"
x2="-22"
y2="5"
gradientTransform="matrix(0.84956703,0,0,0.84301394,-2.927337,1.7790378)" />
<linearGradient
xlink:href="#linearGradient3838"
id="linearGradient3844"
x1="36"
y1="1039.3622"
x2="32"
y2="1003.3622"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2.0563921e-6,-988.36218)" />
<linearGradient
id="linearGradient3838">
<stop
style="stop-color:#d3d7cf;stop-opacity:1;"
offset="0"
id="stop3840" />
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="1"
id="stop3842" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3830"
id="linearGradient3836"
x1="36"
y1="1037.3622"
x2="32"
y2="1005.3622"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2.0563921e-6,-988.36218)" />
<linearGradient
id="linearGradient3830">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3832" />
<stop
style="stop-color:#d3d7cf;stop-opacity:1;"
offset="1"
id="stop3834" />
</linearGradient>
<linearGradient
x1="10.504496"
y1="16.48678"
x2="5.9349072"
y2="1.6356685"
id="linearGradient-1"
gradientTransform="scale(0.99999018,1.0000098)"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#A40000"
offset="0%"
id="stop6-9" />
<stop
stop-color="#EF2929"
offset="100%"
id="stop8" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3815"
id="linearGradient3856"
gradientUnits="userSpaceOnUse"
x1="80"
y1="58"
x2="79"
y2="42" />
<linearGradient
id="linearGradient3815">
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="0"
id="stop3817" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop3819" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3841"
id="linearGradient3858"
gradientUnits="userSpaceOnUse"
x1="109"
y1="51"
x2="105"
y2="38" />
<linearGradient
id="linearGradient3841">
<stop
style="stop-color:#204a87;stop-opacity:1"
offset="0"
id="stop3843" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop3845" />
</linearGradient>
<linearGradient
y2="5"
x2="-22"
y1="18"
x1="-18"
gradientTransform="matrix(0.77114848,0,0,0.77113937,-4.4090973,2.5859051)"
gradientUnits="userSpaceOnUse"
id="linearGradient3898"
xlink:href="#linearGradient3836-9-3" />
<linearGradient
xlink:href="#linearGradient3815"
id="linearGradient3978"
gradientUnits="userSpaceOnUse"
x1="-15"
y1="37"
x2="-19"
y2="37"
gradientTransform="rotate(135.18861,5.7426909,37.969029)" />
<linearGradient
xlink:href="#linearGradient17"
id="linearGradient3898-0"
x1="37.429146"
y1="41.590584"
x2="24.483221"
y2="4.9104676"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient17">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop16" />
<stop
style="stop-color:#ffffff;stop-opacity:0"
offset="1"
id="stop17" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient17"
id="linearGradient3856-9"
x1="22.84341"
y1="4.8241611"
x2="30.783579"
y2="28.644661"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient2">
<stop
style="stop-color:#73d216;stop-opacity:1;"
offset="0"
id="stop1" />
<stop
style="stop-color:#8ae234;stop-opacity:1;"
offset="1"
id="stop2" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient3187"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.53559025,0,0,0.53556875,-6.4812797,2.8041108)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient3155"
gradientUnits="userSpaceOnUse"
x1="-24.890066"
y1="10.114055"
x2="-12.869251"
y2="13.649589" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient3157"
gradientUnits="userSpaceOnUse"
x1="-25.073793"
y1="8.5160742"
x2="-11.638764"
y2="13.465822" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient53"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
y2="13.649589"
x2="-12.869251"
y1="10.114055"
x1="-24.890066"
gradientUnits="userSpaceOnUse"
id="linearGradient3091"
xlink:href="#linearGradient3836-9-3" />
<linearGradient
gradientTransform="rotate(-135,22.98116,18.358513)"
y2="13.465822"
x2="-11.638764"
y1="8.5160742"
x1="-25.073793"
gradientUnits="userSpaceOnUse"
id="linearGradient3093"
xlink:href="#linearGradient3836-9-3" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient3792-1"
x1="22"
y1="27"
x2="9"
y2="30"
gradientUnits="userSpaceOnUse" />
<linearGradient
xlink:href="#linearGradient62"
id="linearGradient3792"
x1="18"
y1="39"
x2="12"
y2="11"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3786">
<stop
style="stop-color:#4e9a06;stop-opacity:1"
offset="0"
id="stop3788" />
<stop
style="stop-color:#8ae234;stop-opacity:1"
offset="1"
id="stop3790" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3786"
id="linearGradient3896"
x1="20.785244"
y1="58.824768"
x2="12.00527"
y2="36.247696"
gradientUnits="userSpaceOnUse" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient63"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient65"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient76"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient77"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
id="linearGradient78"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
</defs>
<metadata
id="metadata2874">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>[maxwxyz]</dc:title>
</cc:Agent>
</dc:creator>
<dc:relation>https://www.freecad.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_CreateArc.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<dc:date>2023-12-19</dc:date>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer3"
style="display:inline"
transform="translate(0,-1.1650101)">
<g
id="g78"
transform="translate(0.99999179,-2.00013)">
<g
transform="translate(-25,15.16501)"
id="g3529-4">
<path
id="path3491-6"
d="M 56,8 V 32"
style="fill:none;stroke:#151819;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path3491-4-07"
d="M 56,8 V 32"
style="fill:none;stroke:#d3d7cf;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path3491-4-1-17"
d="M 55,8 V 32"
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,46.548272,14.762768)"
id="g63"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path62"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient63);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path63"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,46.548272,38.762768)"
id="g71"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path70"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient77);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path71"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
</g>
<g
id="g79">
<g
transform="translate(-3.0000002,3.1650101)"
id="g3529-2">
<path
id="path3491-0"
d="M 56,8 V 32"
style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path3491-4-0"
d="M 56,8 V 32"
style="fill:none;stroke:#d3d7cf;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path3491-4-1-1"
d="M 55,8 V 32"
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,68.548264,2.762638)"
id="g65"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path64"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient65);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path65"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,68.548264,26.762638)"
id="g73"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path72"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient76);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path73"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
</g>
<g
id="g80">
<g
transform="translate(-45,23.16501)"
id="g3529-7">
<path
id="path3491-7"
d="M 56,8 V 32"
style="fill:none;stroke:#162c02;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path3491-4-7"
d="M 56,8 V 32"
style="fill:none;stroke:#73d216;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path3491-4-1-3"
d="M 55,8 V 32"
style="fill:none;stroke:#8ae234;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,26.548264,46.762638)"
id="g69"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path68"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient78);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path69"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,26.548264,22.762638)"
id="g53"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path52"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient53);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path53"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -157,6 +157,16 @@ bool SketcherToolDefaultWidget::eventFilter(QObject* object, QEvent* event)
}
}
}
else if (event->type() == QEvent::FocusOut) {
for (int i = 0; i < nParameters; i++) {
auto parameterSpinBox = getParameterSpinBox(i);
if (object == parameterSpinBox) {
signalParameterFocusOut(i);
break;
}
}
}
return false;
}
@@ -200,10 +210,10 @@ void SketcherToolDefaultWidget::parameterOne_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::First] = true;
setParameterFontStyle(Parameter::First, FontStyle::Bold);
/*setParameterFontStyle(Parameter::First, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Second);
}
}*/
signalParameterValueChanged(Parameter::First, val);
}
}
@@ -211,10 +221,6 @@ void SketcherToolDefaultWidget::parameterTwo_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Second] = true;
setParameterFontStyle(Parameter::Second, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Third);
}
signalParameterValueChanged(Parameter::Second, val);
}
}
@@ -222,10 +228,6 @@ void SketcherToolDefaultWidget::parameterThree_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Third] = true;
setParameterFontStyle(Parameter::Third, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Fourth);
}
signalParameterValueChanged(Parameter::Third, val);
}
}
@@ -233,10 +235,6 @@ void SketcherToolDefaultWidget::parameterFour_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Fourth] = true;
setParameterFontStyle(Parameter::Fourth, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Fifth);
}
signalParameterValueChanged(Parameter::Fourth, val);
}
}
@@ -244,10 +242,6 @@ void SketcherToolDefaultWidget::parameterFive_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Fifth] = true;
setParameterFontStyle(Parameter::Fifth, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Sixth);
}
signalParameterValueChanged(Parameter::Fifth, val);
}
}
@@ -255,10 +249,6 @@ void SketcherToolDefaultWidget::parameterSix_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Sixth] = true;
setParameterFontStyle(Parameter::Sixth, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Seventh);
}
signalParameterValueChanged(Parameter::Sixth, val);
}
}
@@ -266,10 +256,6 @@ void SketcherToolDefaultWidget::parameterSeven_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Seventh] = true;
setParameterFontStyle(Parameter::Seventh, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Eighth);
}
signalParameterValueChanged(Parameter::Seventh, val);
}
}
@@ -277,10 +263,6 @@ void SketcherToolDefaultWidget::parameterEight_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Eighth] = true;
setParameterFontStyle(Parameter::Eighth, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Ninth);
}
signalParameterValueChanged(Parameter::Eighth, val);
}
}
@@ -288,10 +270,6 @@ void SketcherToolDefaultWidget::parameterNine_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Ninth] = true;
setParameterFontStyle(Parameter::Ninth, FontStyle::Bold);
if (!blockParameterFocusPassing) {
setParameterFocus(Parameter::Tenth);
}
signalParameterValueChanged(Parameter::Ninth, val);
}
}
@@ -299,7 +277,6 @@ void SketcherToolDefaultWidget::parameterTen_valueChanged(double val)
{
if (!blockParameterSlots) {
isSet[Parameter::Tenth] = true;
setParameterFontStyle(Parameter::Tenth, FontStyle::Bold);
signalParameterValueChanged(Parameter::Tenth, val);
}
}
@@ -316,7 +293,7 @@ void SketcherToolDefaultWidget::initNParameters(int nparameters, QObject* filter
setParameterVisible(i, (i < nparameters));
setParameter(i, 0.F);
setParameterFilteringObject(i, filteringObject);
setParameterFontStyle(i, FontStyle::Italic);
// setParameterFontStyle(i, FontStyle::Italic);
}
setParameterFocus(Parameter::First);

View File

@@ -154,6 +154,12 @@ public:
void setComboboxPrefEntry(int comboboxindex, const std::string& prefEntry);
void restoreComboboxPref(int comboboxindex);
template<typename F>
boost::signals2::connection registerParameterFocusOut(F&& fn)
{
return signalParameterFocusOut.connect(std::forward<F>(fn));
}
template<typename F>
boost::signals2::connection registerParameterValueChanged(F&& fn)
{
@@ -211,6 +217,7 @@ private:
private:
std::unique_ptr<Ui_SketcherToolDefaultWidget> ui;
boost::signals2::signal<void(int parameterindex)> signalParameterFocusOut;
boost::signals2::signal<void(int parameterindex, double value)> signalParameterValueChanged;
boost::signals2::signal<void(int checkboxindex, bool value)> signalCheckboxCheckedChanged;
boost::signals2::signal<void(int comboindex, int value)> signalComboboxSelectionChanged;

View File

@@ -537,10 +537,7 @@ inline void SketcherAddWorkbenchTools<Gui::MenuItem>(Gui::MenuItem& consaccel)
<< "Sketcher_Rotate"
<< "Sketcher_Scale"
<< "Sketcher_Symmetry"
<< "Sketcher_Clone"
<< "Sketcher_Copy"
<< "Sketcher_Move"
<< "Sketcher_RectangularArray"
<< "Sketcher_Translate"
<< "Sketcher_RemoveAxesAlignment"
<< "Separator"
<< "Sketcher_DeleteAllGeometry"
@@ -567,8 +564,7 @@ inline void SketcherAddWorkbenchTools<Gui::ToolBarItem>(Gui::ToolBarItem& consac
<< "Sketcher_Rotate"
<< "Sketcher_Scale"
<< "Sketcher_Symmetry"
<< "Sketcher_CompCopy"
<< "Sketcher_RectangularArray"
<< "Sketcher_Translate"
<< "Sketcher_RemoveAxesAlignment";
}