Commit Graph

1631 Commits

Author SHA1 Message Date
Syres916
a7ffe6eb83 [Sketcher] Improve Solver Message Visibility...
...when using dark(er) style sheets.
See discussion https://forum.freecadweb.org/viewtopic.php?f=3&t=50094
2020-09-13 12:52:28 +02:00
luz paz
4344f6bc08 Fix typos in source comments
Found via `codespell`
2020-08-29 19:14:13 +02:00
wmayer
45d28c2367 Sketcher: workaround for cursor pixmaps created from SVG icons 2020-08-19 19:59:13 +02:00
Vanuan
7a0aec1210 High DPI support: Convert sketcher cursors to SVG
Remove xpm
2020-08-19 19:59:13 +02:00
wmayer
1c432fd617 Sketcher: [skip ci] add function to sketch validation panel to remove degenerated geometry 2020-08-13 17:24:10 +02:00
wmayer
023f779772 Sketcher: [skip ci] remove superfluous semicolons 2020-08-13 16:30:07 +02:00
luz paz
59e3ea096e Crowdin: Merge new translations [skip-ci] 2020-08-07 17:17:35 +02:00
wmayer
6cf5119b55 Part: [skip ci] move grid handling from ViewProvider2DObject to ViewProvider2DObjectGrid 2020-08-07 17:11:02 +02:00
wmayer
da5bd6594b Part: [skip ci] move grid handling from ViewProvider2DObject to ViewProvider2DObjectGrid 2020-08-07 16:48:07 +02:00
0penBrain
86658c339a [GUI/Sketcher] Add option to disable grid auto-sizing based on shape boundbox
Sketcher makes use of this option to self-manage the overall grid size
2020-08-07 13:30:42 +02:00
wmayer
4dd32ce143 LGTM: [skip ci] fix: Missing header guard 2020-07-27 11:16:41 +02:00
wmayer
dc65b055e5 LGTM: [skip ci] fix: Empty branch of conditional
An empty block after a conditional can be a sign of an omission and can decrease maintainability of the code.
Such blocks should contain an explanatory comment to aid future maintainers.
2020-07-26 15:49:14 +02:00
wmayer
1a16cde1f5 Coverity: Structurally/Logically dead code 2020-07-20 17:34:28 +02:00
wmayer
e83dd3c0ce Coverity: Using invalid iterator 2020-07-20 17:34:27 +02:00
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