diff --git a/.github/codespellignore b/.github/codespellignore index 5691d0a7d9..3a315545fc 100644 --- a/.github/codespellignore +++ b/.github/codespellignore @@ -4,88 +4,66 @@ aline alle alledges alocation -als -ang anid +anormal apoints +appy ba beginn -behaviour bloaded bottome -byteorder -calculater -cancelled -cancelling -cas -cascade -centimetre childrens childs -colour -colours -commen connexion currenty -dof +curvelinear doubleclick dum eiter -elemente ende -feld +extaction finde -findf +findn +fle +fo freez +froms hist -iff indicies -initialisation -initialise -initialised -initialises -initialisiert inout ist -kilometre lod mantatory +mata methode -metres -millimetre modell nd -noe +nin normale normaly -nto numer -oder ontop -orgin -orginx -orginy ot -pard parm parms -pres programm -que +propt rady recurrance rougly -seperator +seh serie -sinc +som strack substraction +sur te thist -thru tread -uint -unter +ue +uptodate +usind +vas vertexes wallthickness -whitespaces \ No newline at end of file +zuser \ No newline at end of file diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index 068a2a6221..cb8760a25c 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -27,5 +27,5 @@ jobs: with: check_filenames: true ignore_words_file: .github/codespellignore - skip: ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml,./build/ + skip: ./.git,*.po,*.ts,*,svg,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml,./build/ path: ${{ steps.changed-files.outputs.all_changed_files }} \ No newline at end of file diff --git a/src/Mod/Draft/draftutils/gui_utils.py b/src/Mod/Draft/draftutils/gui_utils.py index 4884f93850..0799ddc7cd 100644 --- a/src/Mod/Draft/draftutils/gui_utils.py +++ b/src/Mod/Draft/draftutils/gui_utils.py @@ -43,7 +43,7 @@ import FreeCAD as App import draftutils.utils as utils from draftutils.messages import _msg, _wrn, _err -from draftutils.translate import _tr, translate +from draftutils.translate import translate if App.GuiUp: import FreeCADGui as Gui @@ -78,7 +78,7 @@ def get_3d_view(): if v: return v[0] - _wrn(_tr("No graphical interface")) + _wrn(translate("draft", "No graphical interface")) return None @@ -155,7 +155,7 @@ def autogroup(obj): return matrix = parent.getSubObject(sub, retType=4) if matrix.hasScale() == 1: - err = translate("Draft", + err = translate("draft", "Unable to insert new object into " "a scaled part") App.Console.PrintMessage(err) @@ -264,7 +264,7 @@ def dim_symbol(symbol=None, invert=False): elif symbol == 4: return dim_dash((-1.5, -1.5, 0), (1.5, 1.5, 0)) else: - _wrn(_tr("Symbol not implemented. Use a default symbol.")) + _wrn(translate("draft", "Symbol not implemented. Using a default symbol.")) return coin.SoSphere() @@ -330,7 +330,7 @@ def remove_hidden(objectslist): if obj.ViewObject: if not obj.ViewObject.isVisible(): newlist.remove(obj) - _msg(_tr("Visibility off; removed from list: ") + obj.Label) + _msg(translate("draft", "Visibility off; removed from list: ") + obj.Label) return newlist @@ -600,13 +600,13 @@ def load_texture(filename, size=None, gui=App.GuiUp): p = QtGui.QImage(filename) if p.isNull(): - _wrn("load_texture: " + _tr("image is Null")) + _wrn("load_texture: " + translate("draft", "image is Null")) if not os.path.exists(filename): raise FileNotFoundError(-1, - _tr("filename does not exist " - "on the system or " - "on the resource file"), + translate("draft", "filename does not exist " + "on the system or " + "in the resource file"), filename) # This is buggy so it was de-activated. @@ -665,7 +665,7 @@ def load_texture(filename, size=None, gui=App.GuiUp): return None except Exception as exc: _wrn(str(exc)) - _wrn("load_texture: " + _tr("unable to load texture")) + _wrn("load_texture: " + translate("draft", "unable to load texture")) return None else: return img @@ -717,7 +717,7 @@ def get_bbox(obj, debug=False): found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft", "No active document. Aborting.")) return None if isinstance(obj, str): @@ -726,7 +726,7 @@ def get_bbox(obj, debug=False): found, obj = utils.find_object(obj, doc) if not found: _msg("obj: {}".format(obj_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft", "Wrong input: object not in document.")) return None if debug: @@ -735,7 +735,7 @@ def get_bbox(obj, debug=False): if (not hasattr(obj, "ViewObject") or not obj.ViewObject or not hasattr(obj.ViewObject, "RootNode")): - _err(_tr("Does not have 'ViewObject.RootNode'.")) + _err(translate("draft", "Does not have 'ViewObject.RootNode'.")) # For Draft Dimensions # node = obj.ViewObject.Proxy.node diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 835218a7c5..11353dabc4 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -41,7 +41,7 @@ import PySide.QtCore as QtCore import FreeCAD as App from draftutils.messages import _msg, _wrn, _err, _log -from draftutils.translate import _tr +from draftutils.translate import translate # TODO: move the functions that require the graphical interface # This module should not import any graphical commands; those should be @@ -647,20 +647,20 @@ def print_shape(shape): shape : Part::TopoShape Any topological shape in an object, usually obtained from `obj.Shape`. """ - _msg(_tr("Solids:") + " {}".format(len(shape.Solids))) - _msg(_tr("Faces:") + " {}".format(len(shape.Faces))) - _msg(_tr("Wires:") + " {}".format(len(shape.Wires))) - _msg(_tr("Edges:") + " {}".format(len(shape.Edges))) - _msg(_tr("Vertices:") + " {}".format(len(shape.Vertexes))) + _msg(translate("draft", "Solids:") + " {}".format(len(shape.Solids))) + _msg(translate("draft", "Faces:") + " {}".format(len(shape.Faces))) + _msg(translate("draft", "Wires:") + " {}".format(len(shape.Wires))) + _msg(translate("draft", "Edges:") + " {}".format(len(shape.Edges))) + _msg(translate("draft", "Vertices:") + " {}".format(len(shape.Vertexes))) if shape.Faces: for f in range(len(shape.Faces)): - _msg(_tr("Face") + " {}:".format(f)) + _msg(translate("draft", "Face") + " {}:".format(f)) for v in shape.Faces[f].Vertexes: _msg(" {}".format(v.Point)) elif shape.Wires: for w in range(len(shape.Wires)): - _msg(_tr("Wire") + " {}:".format(w)) + _msg(translate("draft", "Wire") + " {}:".format(w)) for v in shape.Wires[w].Vertexes: _msg(" {}".format(v.Point)) else: @@ -692,11 +692,11 @@ def compare_objects(obj1, obj2): if obj1.TypeId != obj2.TypeId: _msg("'{0}' ({1}), '{2}' ({3}): ".format(obj1.Name, obj1.TypeId, obj2.Name, obj2.TypeId) - + _tr("different types") + " (TypeId)") + + translate("draft", "different types") + " (TypeId)") elif getType(obj1) != getType(obj2): _msg("'{0}' ({1}), '{2}' ({3}): ".format(obj1.Name, get_type(obj1), obj2.Name, get_type(obj2)) - + _tr("different types") + " (Proxy.Type)") + + translate("draft", "different types") + " (Proxy.Type)") else: for p in obj1.PropertiesList: if p in obj2.PropertiesList: @@ -704,15 +704,15 @@ def compare_objects(obj1, obj2): pass elif p == "Placement": delta = obj1.Placement.Base.sub(obj2.Placement.Base) - text = _tr("Objects have different placements. " - "Distance between the two base points: ") + text = translate("draft", "Objects have different placements. " + "Distance between the two base points: ") _msg(text + str(delta.Length)) else: if getattr(obj1, p) != getattr(obj2, p): - _msg("'{}' ".format(p) + _tr("has a different value")) + _msg("'{}' ".format(p) + translate("draft", "has a different value")) else: _msg("{} ".format(p) - + _tr("doesn't exist in one of the objects")) + + translate("draft", "doesn't exist in one of the objects")) compareObjects = compare_objects @@ -824,13 +824,13 @@ def filter_objects_for_modifiers(objects, isCopied=False): if parent.isDerivedFrom("Part::Feature"): parents.append(parent.Name) if len(parents) > 1: - warningMessage = _tr("%s shares a base with %d other objects. Please check if you want to modify this.") % (obj.Name,len(parents) - 1) + warningMessage = translate("draft", "%s shares a base with %d other objects. Please check if you want to modify this.") % (obj.Name,len(parents) - 1) App.Console.PrintError(warningMessage) if App.GuiUp: Gui.getMainWindow().showMessage(warningMessage, 0) filteredObjects.append(obj.Base) elif hasattr(obj,"Placement") and obj.getEditorMode("Placement") == ["ReadOnly"] and not isCopied: - App.Console.PrintError(_tr("%s cannot be modified because its placement is readonly.") % obj.Name) + App.Console.PrintError(translate("draft", "%s cannot be modified because its placement is readonly.") % obj.Name) continue else: filteredObjects.append(obj) @@ -974,7 +974,7 @@ def find_doc(doc=None): doc = App.getDocument(doc) except NameError: _msg("document: {}".format(doc)) - _err(_tr("Wrong input: unknown document.")) + _err(translate("draft", "Wrong input: unknown document.")) return not FOUND, None return FOUND, doc @@ -1011,7 +1011,7 @@ def find_object(obj, doc=None): found, doc = find_doc(doc) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft", "No active document. Aborting.")) return not FOUND, None if isinstance(obj, str): @@ -1050,15 +1050,12 @@ def use_instead(function, version=""): If we don't know when this command will be deprecated then we should not give a version. """ - text = "This function will be deprecated in " - text2 = "This function will be deprecated. " - text3 = "Please use " - if version: - _wrn(_tr(text) + "{}. ".format(version) - + _tr(text3) + "'{}'.".format(function)) + _wrn(translate("draft", "This function will be deprecated in ") + + "{}. ".format(version) + + translate("draft", "Please use ") + "'{}'.".format(function)) else: - _wrn(_tr(text2) - + _tr(text3) + "'{}'.".format(function)) + _wrn(translate("draft", "This function will be deprecated. ") + + translate("draft", "Please use ") + "'{}'.".format(function)) ## @} diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index 23cbd25cee..914ba2a851 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -61,6 +61,7 @@ PROPERTY_SOURCE(PartDesign::FeatureExtrude, PartDesign::ProfileBased) FeatureExtrude::FeatureExtrude() { + signedLengthConstraint = { -DBL_MAX, DBL_MAX, 1.0 }; } short FeatureExtrude::mustExecute() const diff --git a/src/Mod/PartDesign/App/FeatureExtrude.h b/src/Mod/PartDesign/App/FeatureExtrude.h index 70e73e1e1c..f09457dde0 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.h +++ b/src/Mod/PartDesign/App/FeatureExtrude.h @@ -47,6 +47,8 @@ public: App::PropertyLength Offset; App::PropertyLinkSub ReferenceAxis; + App::PropertyQuantityConstraint::Constraints signedLengthConstraint; + /** @name methods override feature */ //@{ short mustExecute() const; diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index 033891ebc6..72e77dfda0 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -66,15 +66,14 @@ Pad::Pad() ADD_PROPERTY_TYPE(Type, (0L), "Pad", App::Prop_None, "Pad type"); Type.setEnums(TypeEnums); - ADD_PROPERTY_TYPE(Length, (100.0), "Pad", App::Prop_None,"Pad length"); - ADD_PROPERTY_TYPE(Length2, (100.0), "Pad", App::Prop_None,"Second Pad length"); + ADD_PROPERTY_TYPE(Length, (100.0), "Pad", App::Prop_None, "Pad length"); + ADD_PROPERTY_TYPE(Length2, (100.0), "Pad", App::Prop_None, "Pad length in 2nd direction"); ADD_PROPERTY_TYPE(UseCustomVector, (false), "Pad", App::Prop_None, "Use custom vector for pad direction"); ADD_PROPERTY_TYPE(Direction, (Base::Vector3d(1.0, 1.0, 1.0)), "Pad", App::Prop_None, "Pad direction vector"); ADD_PROPERTY_TYPE(ReferenceAxis, (0), "Pad", App::Prop_None, "Reference axis of direction"); ADD_PROPERTY_TYPE(AlongSketchNormal, (true), "Pad", App::Prop_None, "Measure pad length along the sketch normal direction"); ADD_PROPERTY_TYPE(UpToFace, (0), "Pad", App::Prop_None, "Face where pad will end"); ADD_PROPERTY_TYPE(Offset, (0.0), "Pad", App::Prop_None, "Offset from face in which pad will end"); - static const App::PropertyQuantityConstraint::Constraints signedLengthConstraint = {-DBL_MAX, DBL_MAX, 1.0}; Offset.setConstraints(&signedLengthConstraint); // Remove the constraints and keep the type to allow to accept negative values diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index 329de73bdb..962563f518 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -63,18 +63,17 @@ Pocket::Pocket() { addSubType = FeatureAddSub::Subtractive; - ADD_PROPERTY_TYPE(Type,((long)0),"Pocket",App::Prop_None,"Pocket type"); + ADD_PROPERTY_TYPE(Type, ((long)0), "Pocket", App::Prop_None, "Pocket type"); Type.setEnums(TypeEnums); - ADD_PROPERTY_TYPE(Length,(100.0),"Pocket",App::Prop_None,"Pocket length"); - ADD_PROPERTY_TYPE(Length2,(100.0),"Pocket",App::Prop_None,"P"); + ADD_PROPERTY_TYPE(Length, (100.0), "Pocket", App::Prop_None, "Pocket length"); + ADD_PROPERTY_TYPE(Length2, (100.0), "Pocket", App::Prop_None, "Pocket length in 2nd direction"); ADD_PROPERTY_TYPE(UseCustomVector, (false), "Pocket", App::Prop_None, "Use custom vector for pocket direction"); ADD_PROPERTY_TYPE(Direction, (Base::Vector3d(1.0, 1.0, 1.0)), "Pocket", App::Prop_None, "Pocket direction vector"); ADD_PROPERTY_TYPE(ReferenceAxis, (0), "Pocket", App::Prop_None, "Reference axis of direction"); ADD_PROPERTY_TYPE(AlongSketchNormal, (true), "Pocket", App::Prop_None, "Measure pocket length along the sketch normal direction"); - ADD_PROPERTY_TYPE(UpToFace,(0),"Pocket",App::Prop_None,"Face where pocket will end"); - ADD_PROPERTY_TYPE(Offset,(0.0),"Pocket",App::Prop_None,"Offset from face in which pocket will end"); - static const App::PropertyQuantityConstraint::Constraints signedLengthConstraint = {-DBL_MAX, DBL_MAX, 1.0}; - Offset.setConstraints ( &signedLengthConstraint ); + ADD_PROPERTY_TYPE(UpToFace, (0), "Pocket", App::Prop_None, "Face where pocket will end"); + ADD_PROPERTY_TYPE(Offset, (0.0), "Pocket", App::Prop_None, "Offset from face in which pocket will end"); + Offset.setConstraints(&signedLengthConstraint); // Remove the constraints and keep the type to allow to accept negative values // https://forum.freecadweb.org/viewtopic.php?f=3&t=52075&p=448410#p447636 diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index 36f0b41387..520f97ed33 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -522,6 +522,7 @@ void TaskExtrudeParameters::onMidplaneChanged(bool on) { PartDesign::FeatureExtrude* extrude = static_cast(vp->getObject()); extrude->Midplane.setValue(on); + ui->checkBoxReversed->setEnabled(!on); tryRecomputeFeature(); } @@ -529,6 +530,7 @@ void TaskExtrudeParameters::onReversedChanged(bool on) { PartDesign::FeatureExtrude* extrude = static_cast(vp->getObject()); extrude->Reversed.setValue(on); + ui->checkBoxMidplane->setEnabled(!on); // update the direction tryRecomputeFeature(); updateDirectionEdits(); @@ -618,16 +620,6 @@ void TaskExtrudeParameters::translateFaceName() } } -double TaskExtrudeParameters::getLength(void) const -{ - return ui->lengthEdit->value().getValue(); -} - -double TaskExtrudeParameters::getLength2(void) const -{ - return ui->lengthEdit2->value().getValue(); -} - double TaskExtrudeParameters::getOffset(void) const { return ui->offsetEdit->value().getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h index 7d178612c0..5c9a40de98 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.h @@ -89,8 +89,6 @@ protected: App::PropertyLinkSub* propReferenceAxis; void getReferenceAxis(App::DocumentObject*& obj, std::vector& sub) const; - double getLength(void) const; - double getLength2(void) const; bool getAlongSketchNormal(void) const; bool getCustom(void) const; std::string getReferenceAxis(void) const; diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index e17053f7e6..52f6309f87 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -89,7 +89,6 @@ void TaskPadParameters::updateUI(int index) bool isMidplaneEnabled = false; bool isMidplaneVisible = false; bool isReversedEnabled = false; - bool isReversedVisible = false; bool isFaceEditEnabled = false; Modes mode = static_cast(index); @@ -97,20 +96,15 @@ void TaskPadParameters::updateUI(int index) if (mode == Modes::Dimension) { isLengthEditVisible = true; ui->lengthEdit->selectNumber(); - // Make sure that the spin box has the focus to get key events - // Calling setFocus() directly doesn't work because the spin box is not - // yet visible. QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection); isMidplaneEnabled = !ui->checkBoxReversed->isChecked(); isMidplaneVisible = true; // Reverse only makes sense if Midplane is not true isReversedEnabled = !ui->checkBoxMidplane->isChecked(); - isReversedVisible = true; } else if (mode == Modes::ToLast || mode == Modes::ToFirst) { isOffsetEditVisible = true; isReversedEnabled = true; - isReversedVisible = true; } else if (mode == Modes::ToFace) { isOffsetEditVisible = true; @@ -120,15 +114,11 @@ void TaskPadParameters::updateUI(int index) if (ui->lineFaceName->property("FeatureName").isNull()) onButtonFace(true); isReversedEnabled = true; - isReversedVisible = true; } else if (mode == Modes::TwoDimensions) { isLengthEditVisible = true; isLengthEdit2Visible = true; - isMidplaneEnabled = !ui->checkBoxReversed->isChecked(); - isMidplaneVisible = true; - isReversedEnabled = !ui->checkBoxMidplane->isChecked(); - isReversedVisible = true; + isReversedEnabled = true; } ui->lengthEdit->setVisible( isLengthEditVisible ); @@ -144,7 +134,6 @@ void TaskPadParameters::updateUI(int index) ui->checkBoxMidplane->setVisible( isMidplaneVisible ); ui->checkBoxReversed->setEnabled( isReversedEnabled ); - ui->checkBoxReversed->setVisible( isReversedVisible ); ui->lengthEdit2->setVisible( isLengthEdit2Visible ); ui->lengthEdit2->setEnabled( isLengthEdit2Visible ); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index d7302fae08..f25cd3cfce 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -88,7 +88,8 @@ void TaskPocketParameters::updateUI(int index) bool isLengthEdit2Visible = false; bool isOffsetEditVisible = false; bool isOffsetEditEnabled = true; - bool isMidplateEnabled = false; + bool isMidplaneEnabled = false; + bool isMidplaneVisible = false; bool isReversedEnabled = false; bool isFaceEditEnabled = false; @@ -97,18 +98,16 @@ void TaskPocketParameters::updateUI(int index) if (mode == Modes::Dimension) { isLengthEditVisible = true; ui->lengthEdit->selectNumber(); - // Make sure that the spin box has the focus to get key events - // Calling setFocus() directly doesn't work because the spin box is not - // yet visible. QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection); - isMidplateEnabled = true; + isMidplaneVisible = true; + isMidplaneEnabled = true; // Reverse only makes sense if Midplane is not true isReversedEnabled = !ui->checkBoxMidplane->isChecked(); } else if (mode == Modes::ThroughAll) { isOffsetEditVisible = true; isOffsetEditEnabled = false; // offset may have some meaning for through all but it doesn't work - isMidplateEnabled = true; + isMidplaneEnabled = true; isReversedEnabled = !ui->checkBoxMidplane->isChecked(); } else if (mode == Modes::ToFirst) { @@ -146,7 +145,8 @@ void TaskPocketParameters::updateUI(int index) ui->offsetEdit->setEnabled( isOffsetEditVisible && isOffsetEditEnabled ); ui->labelOffset->setVisible( isOffsetEditVisible ); - ui->checkBoxMidplane->setEnabled( isMidplateEnabled ); + ui->checkBoxMidplane->setEnabled( isMidplaneEnabled ); + ui->checkBoxMidplane->setVisible(isMidplaneVisible); ui->checkBoxReversed->setEnabled( isReversedEnabled );