Commit Graph

1617 Commits

Author SHA1 Message Date
wmayer
2ee8ad1854 Coverity: Division or modulo by float zero 2020-07-20 17:34:26 +02:00
wmayer
0b45b11344 Coverity: Resource leak 2020-07-20 17:34:24 +02:00
mwganson
2bfc6301bc [Sketcher] add python command sketch.getGeoVertexIndex(int index) -- returns tuple (geoId, posId) of vertex at that index in the sketch. usage example: (geoId, posId) = App.ActiveDocument.Sketch.getGeoVertexIndex(int(Gui.Selection.getSelectionEx()[0].SubElementNames[0][6:])-1) 2020-07-19 05:50:12 +02:00
wmayer
2b97a10323 PVS: V1046 Unsafe usage of the 'bool' and 'int' types together in the operation '&='. 2020-07-18 10:59:28 +02:00
wmayer
cbb5f99ade PVS: V730 Not all members of a class are initialized inside the constructor 2020-07-18 10:59:27 +02:00
luz paz
3dfae3ba46 Merged crowdin translations 2020-07-13 14:49:45 +02:00
Yorik van Havre
fbfe821e8c Updated master ts files 2020-07-13 13:20:21 +02:00
luz paz
83f34a1e5b Fix Crowdin typos and various other typos/grammar [skip ci]
Found via codespell v2.0.dev0  
```
codespell -q 3 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,ba,beginn,behaviour,bloaded,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,commen,connexion,currenty,dof,doubleclick,dum,eiter,elemente,ende,feld,finde,findf,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,orgin,orginx,orginy,ot,pard,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,uint,unter,vertexes,wallthickness,whitespaces -S ./.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
```
2020-07-12 11:42:27 +02:00
Abdullah Tahiri
39b81e40a9 Sketcher: fix access to isPerformingTransaction on null pointer
===============================================================

Fixes this crash:
https://forum.freecadweb.org/viewtopic.php?f=3&t=48414#p414255
2020-07-07 18:09:55 +02:00
Thomas Gimpel
33841eb827 Sketcher: fix crash, when cloning element having a non-driving distance, radius, diameter or angle constraint; fixes #4393 2020-07-03 20:38:06 +02:00
Abdullah Tahiri
31b1ad874f Sketcher: Augment malformed constraint messages
===============================================

Enable a user recomputing an object/document to identify which sketch has the malformed constraints.
2020-07-02 19:54:15 +02:00
wmayer
ebbcdf5ff7 Sketcher: [skip ci] fixes -Wmaybe-uninitialized 2020-07-01 19:50:40 +02:00
Abdullah Tahiri
c35d8be9a3 Sketcher: Check invalid constraint indices in unmanaged operations
==================================================================

It is possible to bypass SketchObject in modifying geometry and constraints. Like in here:
https://forum.freecadweb.org/viewtopic.php?f=3&t=41326&start=20#p408409

This leads to unexpected behaviour and even crashes.

With this commit the new mechanism of constraint indices check is leveraged in cases not involving SketchObject operations (aka managed operations).

Direct assignment of properties from Python (sketcher unmanaged operations), undergo this extra indices check.

When indices in constraints are outside the geometry range, the constraints are shown as empty and the error is shown in the report window.
2020-07-01 14:04:25 +02:00
Abdullah Tahiri
ee21985e25 Sketcher: PropertyConstraintList input data validation
======================================================

PropertyConstraintList is provided with the ability to check its constraints indices against
a minimum and a maximum, and set an invalidindex status.

In this status, the getValues returns an emptylist, as in the case with invalid geometry types.
2020-07-01 14:04:25 +02:00
Abdullah Tahiri
7055b5ef0f GCS: Prevent that reference constraints affect the result of a redundant solving
================================================================================

Solves the part of this described bug relating to reference constraints affecting the diagnosis of redundant constraints:
https://forum.freecadweb.org/viewtopic.php?p=410195#p410195
2020-07-01 14:04:25 +02:00
Abdullah Tahiri
ffaa92d29b GCS: Add debug code to identify the popularity contest selected redundant that is removed 2020-07-01 14:04:25 +02:00
Abdullah Tahiri
926625b678 Sketcher: Use move semantics wherever sensible
==============================================

Take advantage of PropertyGeometryList setValues() move overload in order to make code more readable and prevent
memory leaks (mostly by inadvertedly not deleting cloned geometry and constraints).

PropertyGeometryList and PropertyConstraintList are vectors of heap allocated pointers. Copying a vector
makes a shallow copy, not a deep copy (the pointers are the same in the copy).

For property management, setValues() function taking a const reference effectively make a deep copy of all
pointed objects. This means that heap allocated pointers of the client class passed to these functions must be
released by the client. While this sounds sensible, forgetting to is easy. In the cases where the developer
remembered to release these pointers, extra code is needed just for memory management.

This commit does not seek a substantial performance increase that would justify rewritting the code, although code
may be slightly faster sometimes.

Functions where setValues() is conditional are not changed to move semantics, as it makes no sense to make a deep copy to sometimes
perform a second deep copy later on. This code still uses const ref setValues().

CHECKS performed to refactored functions with this commit:

1) That the vector is NOT used after moving its content.

2) That whereever there is a clone(), there must be EITHER
    -a std::move if using rvalue setValues()
    OR
    - a delete to free the heap memory after setValues if using the const ref setValues()

3) That memory is released if an exception occurred.

N.B.: A couple of memory leaks are fixed in this commit too.
2020-07-01 14:04:25 +02:00
Abdullah Tahiri
fe993abc35 PropertyConstraintList: refactor setValue 2020-07-01 14:04:25 +02:00
Abdullah Tahiri
ac167aa850 Sketcher: ViewProviderSketch inhibit update if internal transaction is ongoing
==============================================================================

Inhibit ViewProviderSketch updateData with invalid data (internal transaction).

Trigger update internally for internal transactions in SketchObject via touched()
so as to trigger updateData.

This leads to a reduction of updateData calls.
2020-07-01 14:04:25 +02:00
Abdullah Tahiri
3941b69170 Sketcher: Internal Transaction Support and ensure valid constraint geometry indices
===================================================================================

On changing the geometry property (for example from Python), the constraints geometry indices was not rebuild in order to avoid
redundant and unnecessary rebuilds. However, this might cause crashes, as the status of the sketch (or its properties) may be invalid.

It also refactors into OnChanged common functionality.

This commit does NOT solve that the user may be inserting invalid geometry indices to the First/Second/Third of Constraints (invalid input).
Only makes sure that geometry indices (geometry types) of PropertyConstraintList match the geometry.

Solution:

1. Force the rebuild of the constraint geometry indices upon assignment of new Geometry.
2. Force the rebuild of the constraint geometry indices upon assigment of constraints, if they result in invalid geometry indices.
3. Introduce the concept of internal transaction to avoid those rebuilds, checks and updates in case of an ongoing internal transaction,
thereby preventing them as it was done before introducing 1 and 2 (in the case of SketchObject internal transactions).
2020-07-01 14:04:25 +02:00
wmayer
f3b460e42e boost: fix for boost < 1.60 2020-06-15 19:38:39 +02:00
wmayer
f5a5bf7900 Sketcher: [skip ci] fix -Winconsistent-missing-override 2020-06-14 16:36:46 +02:00
wmayer
76f818d017 Sketcher: [skip ci] add security checks before accessing pointer 2020-06-14 16:23:16 +02:00
Abdullah Tahiri
58e459cde1 TaskDlgEditSketch: Remove unnecessary recompute
===============================================

On Undo/Redo there should not be an unconditional recompute.

The need for this recompute is probably related to the fact that PropertyConstraintList
has invalid geometry keys.
2020-06-14 14:44:28 +02:00
Abdullah Tahiri
7ae2fc7b05 Sketcher: ViewProviderSketch delay updateData on undo/redo transactions
=======================================================================

On App:Document::undo, applchn is called on every transactional object (e.g. properties) affected, which
calls Paste on the property.

Each of the properties of SketchObject cause a call to SketchObject::OnChanged, and App::DocumentObject::OnChanged, the latter
calling onChangeProperty, which signals the viewprovider from Gui::Document::slotChangedObject via ViewProviderSketch::updateData.

This causes that the ViewProvider is updated when Constraints and Geometry indexes are not matching.

The solution proposed has three parts:
1. First, at ViewProvider::updateData update is prevented while undo/redo transaction is performed by checking isPerformingTransaction()
2. Second, the onUndoRedoFinished() mechanism of SketchObject causes the call of updateData when it solves the sketch (and sets the solved geometry)
3. Third, Gui::Document::signalUndoDocument and Gui::Document::signalRedoDocument (via the slots in ViewProviderSketch) are
used to perform the recompute of the ViewProvider when the undo/redo transaction is finished if needed.
2020-06-14 14:44:28 +02:00
Abdullah Tahiri
8ef32eab8b Sketcher: onUndoRedoFinished implementation and request
=======================================================

The sketchobject is now left in a known status after undo/redo transaction
2020-06-14 14:44:28 +02:00
wmayer
1ee3d79d7c Qt5: 'int QFontMetrics::width' is deprecated since Qt 5.11: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] 2020-06-12 17:51:33 +02:00
wmayer
4ec45b545e boost 1.73.0: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated 2020-06-12 17:51:33 +02:00
wmayer
b143194f9d Qt5: 'static bool QPixmapCache::find(const QString&, QPixmap&)' is deprecated: Use bool find(const QString &, QPixmap *) instead [-Wdeprecated-declarations] 2020-06-12 17:51:33 +02:00
wmayer
bb86fe18e6 Sketcher: [skip ci] fix -Wimplicit-fallthrough= 2020-06-10 13:09:58 +02:00
wmayer
27b6066beb clang/gcc/cmake: move handling of suppressed deprecated-copy warnings from source file to CMake file to more easily support gcc 10 2020-06-09 15:30:42 +02:00
wmayer
200c7c7e00 [skip ci] include missing boost header 2020-06-07 17:21:37 +02:00
Abdullah Tahiri
21cbceba5a Sketcher: Fix solver failure when setting datum results in wrong solver information
===================================================================================

fixes:
https://forum.freecadweb.org/viewtopic.php?p=404945#p405014
2020-06-03 19:07:50 +02:00
0penBrain
eede55f75b [Sketcher] Solver message updated when toggling driving in datum dialog 2020-06-03 18:30:37 +02:00
Abdullah Tahiri
c7b963d991 Sketcher: Avoid PointOnObject Autoconstraint on BSpline
=======================================================

fixes #4295

PointOnObject autoconstraint for BSplines is currently not supported, this
commit prevents malformed autoconstraint creation.
2020-06-02 19:08:06 +02:00
Abdullah Tahiri
f086580013 Sketcher: Make setposition text unpickable
==========================================

fixes #4272

The setposition text string was being picked interfering with preselection of autoconstraints.

Merit for the solution goes to Werner:
https://forum.freecadweb.org/viewtopic.php?f=10&t=47092&p=404519#p404519
2020-06-01 19:56:01 +02:00
Abdullah Tahiri
28222fe066 Sketcher: Fix undo on moving geometry
=====================================

fixes #3842
2020-05-31 20:53:07 +02:00
Abdullah Tahiri
08854bcc71 Sketcher: Fix for failure of constraint substitution
====================================================

fixes #4105

When a constraint substitution is present, a solve must precede any call to the redundant removal to update the solver information.
2020-05-29 14:19:42 +02:00
Abdullah Tahiri
0c5fc74e35 Sketcher: Fixing Driving constraint apparent redundancy
=======================================================

When adding a reference constraint of type radius or diameter to an external geometry using the method of select the
continuous mode method (select tool first, click geometry afterwards), with ActiveUpdate checked, there was a missing
solving to bring the solver information in line with the Driven constraint.

fixes #4054
2020-05-28 19:10:22 +02:00
Abdullah Tahiri
c457ce613e Sketcher: ViewProvider Grid control
===================================

Encapsulation of grid internals in ViewProviderObject2D, while allowing control via property changes and protected functions.
2020-05-27 19:25:47 +02:00
0penBrain
da33ffc062 [Sketcher] Grid is displayed in 3D view only if sketch is visible 2020-05-27 19:25:47 +02:00
0penBrain
811a44643c [Sketcher] Local settings are correctly restored ; fixes #3952,#4058 2020-05-27 19:25:47 +02:00
0penBrain
9d9aaf680f [Sketcher] Grid snapping is enabled only if grid is shown 2020-05-27 19:25:47 +02:00
0penBrain
6a6c34480a [Sketcher] 'Avoid redundant autoconstraint' is processed only if 'Autoconstraints' is active 2020-05-27 19:25:47 +02:00
0penBrain
286a692ca9 [Sketcher] Move general settings widget enable/disable logic in TaskSketcherGeneral so ...
... all options are freely accessible in the preferences editor ...
 ... eg. no need to check 'Show Grid' to customize grid size or snap
 Also remove the sparse automatical saving to preferences from sketcher Task pane ...
 ... (some settings were saved, some not)
2020-05-27 19:25:47 +02:00
0penBrain
399f5de906 [Sketcher] Fix catching of rendering order change
model()->layoutChanged signal didn't work at all, was never emitted by widget
 Replaced with an eventFilter catching ChildRemoved to further emit the signal
2020-05-27 19:25:47 +02:00
0penBrain
4c9fc11cb6 [Sketcher] Fix saving/loading of rendering order
Wasn't working at all
 Now saved only from preferences editor
2020-05-27 19:25:47 +02:00
0penBrain
9862670cf2 [Sketcher] Simplify general settings management 2020-05-27 19:25:47 +02:00
0penBrain
5b76419d58 [Sketcher] Fix grid size initialization ; fixes #4055 2020-05-27 19:25:47 +02:00
0penBrain
cd2f5a00e8 [Sketcher] Add missing 'Auto remove redundant' to preferences 2020-05-27 19:25:47 +02:00