Commit Graph

2222 Commits

Author SHA1 Message Date
Abdullah Tahiri
14d682c6c3 Sketcher: Fix edit curve drawing for bounded curves 2022-03-15 13:16:48 +01:00
Abdullah Tahiri
1aab305577 Sketcher: DrawSketchHandler draw multiple edit curves
=====================================================

Extension of the framework to draw an arbitrary curve in draw sketch handlers, so that
a plurality of curves can be handled.

DrawSketchHandler is extended to additionally offer drawing several curves:
- void drawEdit(const std::list<std::vector<Base::Vector2d>> &list);
- void drawEdit(const std::vector<Part::Geometry *> &geometries);

A new class, CurveConverter, enables to convert individual Part::Geometry or vectors of them
to appropriate vectors or list of vectors of Vector2d representing the curves. This can be
used in a specific DrawSketchHandler to combine Part::Geometries and arbritary curves.
2022-03-14 16:02:49 +01:00
Yorik van Havre
a55ee61840 Merged crowdin translations 2022-03-14 12:21:01 +01:00
wmayer
0f9768fb33 Fix coverity issue:
* CID 332682: Resource leak
* CID 350607: Resource leak
* CID 332677: Resource leak
2022-03-14 11:35:04 +01:00
Abdullah Tahiri
ee98a3d87f Sketcher: Some code comments 2022-03-13 19:28:38 +01:00
Abdullah Tahiri
23f18505f2 Sketcher: Redraw constraints on wheel event
===========================================

https://forum.freecadweb.org/viewtopic.php?p=577585#p577585
2022-03-13 11:33:52 +01:00
Ajinkya Dahale
9007662425 [Sketcher] Fix "toggle internal geo" on multi-selection
Some deleted GeoIds can stay in selection and GeoIds can change as some objects
are deleted.
2022-03-13 06:58:40 +01:00
Abdullah Tahiri
bba7c89c2a Sketcher: Coverity 332695 - unlikely array indexing with negative value 2022-03-12 21:14:19 +01:00
Abdullah Tahiri
bcfa246943 Sketcher: Coverity 332679 - logically dead code removed 2022-03-12 21:14:19 +01:00
Abdullah Tahiri
341cf32369 Sketcher: Coverity 332685, 332686, 332696
=========================================

Detected by coverity as unchanged variable (constant intended).

It was actually an unnecessary variable that prevented correct command committing.
2022-03-12 21:14:19 +01:00
Abdullah Tahiri
c8a57fb9b4 Sketcher: Coverity 350601 - possible resource leak 2022-03-12 21:14:19 +01:00
Abdullah Tahiri
963cae4a0b Sketcher: Coverity 350637 - unhandled exception in noexcept destructor 2022-03-12 21:14:19 +01:00
Abdullah Tahiri
bd84e883cf Sketcher: Coverity 350641 - unhandled exception in noexcept destructor 2022-03-12 21:14:19 +01:00
Abdullah Tahiri
7294d4d7a3 Sketcher: move comment to right position 2022-03-12 18:45:16 +01:00
Abdullah Tahiri
5e88ee99f5 Sketcher: BSpline code review and fix
=====================================

- Avoid using EditCurve for the double use of storing the pole positions and the last mouse position. Split into individual vector for poles and previous cursor position (with appropriate names).
- Store all pole geoids to better show the intend of the code.
- Avoid indexing when referring the last inserted value of a std::vector, use back() instead.
- Encapsulate code to draw the bspline polygon and the cursor text to the given position. This allow to select the right function for every case, while avoiding unclear names, such as "mousemove()".
- Refactor code to finish command, to avoid calling unclear names such as "releasebutton" to better show the intend of the function call.
- Ensure deleted pole does not appear anymore in the scenograph.
2022-03-12 15:47:50 +01:00
Ajinkya Dahale
201ef90a89 [Sketcher] Constrain first pole when created
By doing this, duplicate radius constraints are not made when deleting and
redefining second pole.
2022-03-09 16:43:47 +01:00
Ajinkya Dahale
f10ccfc0fb [Sketcher] Safeguard against spurious pre-selection
Preselection is sometimes not updated under some circumstances
1. when deleting an object through python;
2. before autoconstraint when deleting previous pole in bspline creation mode.

When the preselected curve is the deleted object, segfault/crash can happen.
2022-03-09 16:43:47 +01:00
Ajinkya Dahale
3fa1735088 [Sketcher] Redraw correctly on pole delete in "create b-spline"
This ensures that the last preview line drawn is always at the cursor and that
the coordinates are always w.r.t. the last defined pole.
2022-03-09 16:43:47 +01:00
Uwe
4f5c29edd6 [Gui] Quarter: remove unused includes 2022-03-09 01:12:15 +01:00
wmayer
b02cb69baa Sketch: [skip ci] fix linking error with MSVC
For more details see: https://forum.freecadweb.org/viewtopic.php?f=10&t=66939
2022-03-09 01:11:15 +01:00
Uwe
554635cc7d [Gui] rename the Qt header list 2022-03-07 20:35:38 +01:00
wmayer
8f786ea6ef Gui: Optimize includes to reduce compile time 2022-03-07 20:29:18 +01:00
Yorik van Havre
2cff977548 Merged crowdin translations 2022-03-07 14:55:22 +01:00
Ajinkya Dahale
5bfe90b2aa [Sketcher] Check for b-spline before starting knot insertion "mode"
The DrawSketchHandler will otherwise give confusing error messages.
2022-03-07 14:27:28 +01:00
Ajinkya Dahale
ec132dc2e4 [Sketcher] Remove "incomplete" from insert knot command
I had kept the qualifier there when developing the tool and forgot to remove it. At this time the tool is fairly well-developed.
2022-03-06 16:25:08 +01:00
Ajinkya Dahale
ec2522130b [Sketcher] Allow deleting last knot during B-Spline creation 2022-03-06 16:14:07 +01:00
Ajinkya Dahale
c6f19758d1 [Sketcher] Reduce duplicate code in DrawSketchHandlerBSpline 2022-03-06 16:14:07 +01:00
wmayer
5e0cfc64ee App: use forward declarations 2022-03-04 21:09:46 +01:00
wmayer
1cbecdf122 App: use forward declaration to reduce compile time 2022-03-04 17:27:53 +01:00
Abdullah Tahiri
79f52556f4 Sketcher: Clean up old crosshair code
====================================

- Remove old unconnected code
- Move member functions to correct cpp file
2022-03-04 06:26:46 +01:00
Abdullah Tahiri
8de93cfaf7 Sketcher: GeoElementId VAxis fix - windows 2022-03-02 15:00:40 +01:00
Abdullah Tahiri
5d0e40a2ca Sketcher: Fix GeoElementId VAxis 2022-03-02 07:54:24 +01:00
Abdullah Tahiri
261efeb5e8 Sketcher: GeoElementId - isCurve and PosIdAsInt members 2022-03-02 07:53:07 +01:00
mosfet80
0b3bb1d365 Update SketchObject.cpp
Initialize variable
2022-03-01 17:42:23 +01:00
0penBrain
430166b7fc Sketch: Fix algorithm seeking for missing coincidences in Validate 2022-02-28 14:52:55 +01:00
wmayer
947f9cfbaa Sketch: [skip ci] add unit test to detect missing point-on-point constraints 2022-02-28 14:50:35 +01:00
Ajinkya Dahale
06f290e311 [Sketcher] Allow setting B-Spline degree at creation 2022-02-27 16:48:23 +01:00
Ajinkya Dahale
35373434bc [Sketcher] Create internal geometry after converting to NURBS
The control points are needed to edit the converted B-Spline
2022-02-25 18:45:12 +01:00
Ajinkya Dahale
a4955a27bf [Sketcher] Correct NURB to NURBS
The S in NURBS stands for Spline
2022-02-25 18:22:01 +01:00
wmayer
8302883843 Sketcher: fix crash in function 'Convert to B-Spline'
See also the forum thread: https://forum.freecadweb.org/viewtopic.php?f=19&t=66470
2022-02-24 12:54:11 +01:00
Ajinkya Dahale
61a7654094 [Sketcher] Allow multiplicity change of B-Spline end knots
The first and last knots (which are often also poles) of a B-Spline are not
represented in sketcher as knots, but as end points of the curve. This creates a
problem when we want to change the multiplicities of those knots. As a
workaround, these points are treated differently.

NOTE: While it is technically possible to have end knots in a non-periodic
spline with degree <= degree of the curve, `Geom_BSplineCurve::RemoveKnot()`
fails for the first and last knots, so we are stuck with this. So, this commit
effectively only makes knot multiplicity change possible for periodic splines.
For non-periodic splines this commit just changes the confusing "no knot is
selected" message to an unhelpful "multiplicity modification failed".
2022-02-19 16:10:43 +01:00
Ajinkya Dahale
0a02853bb7 [Sketcher] Fix some strings in CommandConstraints.cpp 2022-02-19 16:10:43 +01:00
Ajinkya Dahale
cc8ec6dbd3 [Sketcher] Use knot insertion pointer when using that tool
Icon courtesy @bitacovir, adapted from https://forum.freecadweb.org/viewtopic.php?f=34&t=66262&p=572480#p572471.
2022-02-18 16:05:54 +01:00
Ajinkya Dahale
054f99d5bc [Sketcher] Use point-and-click for knot insertion
Here, point and click means we can move the cursor around and select a point on
the curve, instead of having to enter a value in a dialog (just like we do for
geometry creation and constraints). Continuous mode is also supported, but these
only apply to one B-Spline which should selected before pressing the tool button.

A `DrawSketchHandlerBSplineInsertKnot` is created to handle all the graphical aspects.

Finer control may be desirable but that awaits tool settings task box or similar
changes where keyboard input can be used.

Made some changes as per comments by @abdullahtahiriyo. Also change `activated`
to follow recent NVI changes.
2022-02-18 16:05:54 +01:00
Uwe
fe44ae7ae5 [Sketch] ViewProviderSketch: add missing include 2022-02-18 03:27:53 +01:00
Uwe
4e974190bf [Sketch] ViewProviderSketch: remove unused includes
- also sort the includes
2022-02-18 03:15:27 +01:00
wmayer
f7392d47b9 Sketcher: fix warnings:
* fix -Winconsistent-missing-override
* fix -Woverloaded-virtual that is also a bug because the DrawSketchHandlerArcOfParabola didn't set the suitable mouse cursor
2022-02-17 21:14:37 +01:00
Abdullah Tahiri
f7741d4399 DrawSketchHandler: activation and deactivation via NVI pattern
==============================================================

With the introduction of overridable default behaviour for commands, it makes sense to keep control of the execution path of the activation and deactivation.

Non-virtual interface pattern enforces execution control of the virtual functions, while allowing the behaviour to be overriden in a case by case basis.
2022-02-17 19:37:48 +01:00
wmayer
bb2872d5de Sketch: make sure that Attachment editor shows up in the context-menu 2022-02-17 19:27:11 +01:00
0penBrain
3eb233dc37 [Sketcher] Fix typo 2022-02-17 16:17:04 +01:00