Commit Graph

23324 Commits

Author SHA1 Message Date
Abdullah Tahiri
f84df4e944 Arch: Make ArchWall use Sketcher GeometryFacade 2020-12-13 15:36:59 +01:00
Abdullah Tahiri
02a8af773f Sketcher: Ensure that ViewProvider Geometry extensions is correctly initialised 2020-12-12 16:18:57 +01:00
Abdullah Tahiri
384783dfee Sketcher: refactor unnecessary dir/angle conversion 2020-12-12 16:18:57 +01:00
Abdullah Tahiri
1255eb2587 Sketcher: ViewProvider fix Weight length when dragging
https://forum.freecadweb.org/viewtopic.php?f=10&t=51716&sid=d469aaf654946813912b9419f4fc529f&start=60#p456814
2020-12-12 16:18:57 +01:00
wmayer
6b92793a28 CMake: [skip ci] use FILTER of list command only for v3.6 or later 2020-12-12 10:53:20 +01:00
luz paz
c52df25cf4 Main: fix header uniformity + trailing whitespace
[skip ci]
2020-12-12 08:17:58 +01:00
luz paz
a8c3b239b8 Fix various typos [skip ci]
Found via `codespell v2.1.dev0`  
```
codespell -q 3 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,apoints,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-12-12 08:07:47 +01:00
wmayer
0aa38c44f4 PD: [skip ci] in wizard shaft handle case where Plot module is not available 2020-12-11 16:09:01 +01:00
wmayer
2052b24652 Part: [skip ci] support of keywords in Part.GeometrySurface.toBSpline() 2020-12-11 14:40:09 +01:00
tomate44
54e2364634 Part:Surface.toBSpline use OCC MaxDegree instead of fixed value. 2020-12-11 14:05:08 +01:00
tomate44
89e90f8ad5 Part: update GeomSurface.toBSpline doc 2020-12-11 14:05:08 +01:00
tomate44
c8202e38ad Part: add default values to GeomSurface.toBSpline() 2020-12-11 14:05:08 +01:00
Chris Hennes
39a03ab4e5 [Web] Close stale file handle in exec()
Eliminate the Python interpreter warning about failure to close a stale handle when using the `exec(open('%s').read()` idiom, enclosing it in a `with` clause.
2020-12-11 13:22:35 +01:00
Przemo Firszt
9d67962458 Fix fedora COPR builds
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
2020-12-11 13:20:34 +01:00
luz paz
fc99ff2def Draft: fix header uniformity + trailing whitespace
[skip ci]
2020-12-11 13:19:49 +01:00
wmayer
9e8dcbf963 Part: [skip ci] fix memory leaks
+ add convenience function GeometryExtension::copyPyObject()
+ make sure to destroy the clone when leaving getGeometry()
2020-12-11 12:05:28 +01:00
Chris Hennes
533814dd0f Silence Qt/Windows setGeometry Warning
Add the optional Qt::MSWindowsFixedSizeDialogHint parameter to all uses of the QInputDialog::getX static functions to silence a Qt/Windows debug mode warning about QWindowsWindow::setGeometry: Unable to set geometry. Increase the size of the unit calculator to eliminate the same warning. Finally, call adjustSize() on the "Unsaved Changes" dialog to silence the warning.
2020-12-11 09:58:09 +01:00
Abdullah Tahiri
1c7c25392d Sketcher/Part: Python handling of GeometryExtensions without a Python counterpart
=================================================================================

Some geometry extensions do not provide a PyObject as they do not have a Python counterpart
as it would serve no purpose to have it.

This commit handles this situation making sure to provide the right error to Python
or to ignore the extension where appropriate.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
32d8992830 Sketcher: refactor onDocumentRestored() 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
a3a9d29e38 Sketcher: Reduce ViewProviderUpdates when deleting Internal Alignment Geometry
==============================================================================

Deletion of a geometry having internal alignment geometry (B-Spline, Ellipse, ...)
involves calling a geometry deletion operation for each internal aligment constraint
in addition to the one of the geometry.

Before this commit, an update call was performed for each of these operations. Now,
there is a single update trigger operation after all the geometries are deleted.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
8fb16b5305 Sketcher: SketchGeometryExtension - Do not store ID
===================================================

Currently the ID is a unique number without an specific use and it is
conceived to be taken over by future RT's Sketcher PRs.

Because of this, and not to interfere with RT's implementation, it is
not stored, but will be restored if attribute available.

Unrelated:
Similarly, ExternalGeometryExtension is also there conceived for RT's
future sketcher PRs, but it is not used.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
366f63d9f9 Sketcher: GeometryFacade - Remove Debuging code 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
642c1ef76a Sketcher: ExternalGeometryFacadePy Python interface
===================================================

- Add get/set InternalType
- ExternalGeometryFacadePy: Add get/set Blocked - squash me
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
8dd191d945 Sketcher: GeometryFacadePy - testGeometryMode Python interface 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
a7f848050d Sketcher: SketchGeometryExtensionPy getConstruction from extension 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
8ffa978f3b Part/Sketcher: GeometryExtension/GeometryPersistentExtension split
==================================================================

GeometryExtension was originally designed to be serializable (save/restore). However,
GeometryMigrationExtension and ViewProviderSketchGeometryExtension have demonstrated the
usefulness of runtime-only GeometryExtensions.

The problem with runtime-only extensions being of a serializable type (GeometryExtension before
this commit) arises when Part::Geometry is to serialize the extensions and serialise the number
of extensions the geometry has. If runtime-only GeometryExtensions do not save a tag, then the
restore mechanism will expect more extensions that are actually in the XML file.

This commit makes GeometryExtension by default not serializable and deriving directly from
Base::BaseClass. A new class GeometryPersistentExtension is created, deriving from GeometryExtension
to provide serialisation. All Extensions requiring serialization derive from GeometryPersistentExtension
and those not requiring it from GeometryExtension directly.

This commit adapts all extensions to the new situation:
Part: GeometryDefaultExtension
Part: GeometryMigrationExtension
Sketcher: ViewProvierSketchGeometryExtension
Sketcher: SketchGeometryExtension and ExternalGeometryExtension
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
00b8c13562 Sketcher: Fix construction migration 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
cf73ec8d44 Sketcher - Construction Migration - step 4: Migration function from legacy construction geometry to extension
==============================================================================================================

This function is charged with receiving the construction information in a
GeometryMigrationExtension and setting the right data members of SketchGeometryExtension.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
994bd9d92b Part/Sketcher - Construction Migration - step 3: Removal of Geometry construction data member
=============================================================================================

This commits removes the Geometry construction data member and adapts sketcher code to use
GeometryFacade to access construction information via the SketchGeometryExtension.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
850a71d3c7 Sketcher - Construction Migration - step 2: Adapt GeometryFacade to retrieve construction from extension
========================================================================================================

Access to the Construction state from facade is now obtained from the extension data.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
ff9eac966c Sketcher - Construction Migration - step 1: SketchGeometryExtension add construction enum
================================================================================

First step towards migration - Create Construction Geometry Mode in Extension
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
e96085be55 Sketcher: GeometryFacadePyImp - no longer checking if a point is construction to set construction status 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
5a5e47560f Sketcher: Refactor for GCS magic numbers
========================================

- A small refactor to eliminate GCS magic numbers from Sketch.cpp.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
be61ad123e GCS: Simple refactor magic numbers into enum
============================================

A new enum to remove magic numbers for constraint tags.

A previous version of the commit introduced more magic numbers, which
demonstrated not to be up for the task.

About the Tag numbers:
- Positive Tags identify a higher level constraint form which the solver constraint originates
- Negative Tags represent temporary constraints, used for example in moving operations, these
have a different handling in component splitting, see GCS::initSolution. Lifetime is defined by
the container object via GCS::clearByTag
- Hardcoded value -1 is used for these constraints.The effect is parameters are not truly enforced
  (it gives a nice effect when dragging the edge of an unconstrained circle, that the center won't
  move if the edge can be dragged, and only when/if the edge cannot be dragged,  e.g. radius constraint,
  the center is moved).
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
bb64e15c14 Sketcher: GeometryFacade - isInternalType static convenience function 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
ac7185b088 Sketcher: Viewprovider B-Spline pole representation factor
==========================================================

Previously for Weights, ViewProviderSketch used getScaleFactor. This caused that upon zoom change
the Weights would not increase progresively, rather the would grow on the next redraw. Additionally,
upon substantial zoom out, the poles would grow several times bigger than the B-Spline.

This commit uses a new geometry extension intended only for ViewProviderSketch, to store a geometry
specific representation scale factor. This is calculated as a function of the B-Spline length. The
extension does not serialise to disk. It is just intended for runtime.

Dragging from the edge when the radius is constrained gives a wrong cosmetic result, because the representation circle and the
real value of the weight are different (by a scale factor). This commit prevents dragging on the edge in the most representative
cases where the radius is constrained.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
f0d5d5739c Sketcher: Unit independent pole weight for B-Splines (Weight constraint)
========================================================================

Until now BSpline poles were circles relying on physical length units. This lead to several
problems:
- While the BSpline weight follows the circle size, weights do not have length units, but are adimensinal
- As representation of the BSpline depends on the physical size of the circle, the numerical value to be
  set to a pole circle differs from the numerical value of the weight.

The present commit:
1. Separates pole circle representation (physical size), from the numerical value used in the radius constraint,
so that the value in the constraint is the weight, the value representation is a factor of the weight value (in this
commit is getScaleFactor(), but this will change in the next commit). Dragging accounts for this scale factor too.
2. While Radius constraint button is used to constraint a B-Spline weight as before, this creates a Weight constraint,
which is a new type of constraint. This is done so that the value is truly adimensional and is so presented in all kind
of editors that rely on the units indicated by the constraint. It is obviously also shown as adimensional (thus without units),
in the 3D view and in the datum dialogs.
3. Because the circle of the pole of a B-Spline is not a geometric circle, but a graphical representation of the pole and how
it affects the corresponding B-Spline, constraint creation commands are limited so that no point on object, tangent, perpendicular
or SnellLaw constraints can be created on a B-Spline weight circle. This is also the case for the Diameter constraint, which won't
accept the circle. Equality constraints work either on only circles or only weights, but not on a mixture of them.

Bonus: This commit fixes a bug in master, that using the select equality constraint then click in two geometric elements mode, you
could make a circle equal to an ellipse resulting in malformed solver constraints.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
2ba211f2cf Sketcher: ViewProvider - Show Internal aligment geometry in different color
===========================================================================

The aim is to easily differentiate a circle that is a normal circle from a circle that is internal geometry, no matter
if the normal circle is construction or not.

The underlying reason is that next commits will introduce a different treatment for internal geometry circles being B-Spline
poles, to which a new constraint Weight instead of a normal radius constraint will be applied, even though the representation
continues to be as circles.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
7893e42c92 Sketcher: Constraint-Driven geometry status
============================================

This is a new concept which originates from the new ability of sketcher geometry to store a geometry state via
geometry extensions.

The idea is that some geometry state is enforced via constraints (InternalAlignment constraints and Block constraint) which
effectively set the state. However, it is convenient to have direct access of the geometry state from the geometry for representation
(ViewProvider) and for the solver. This is the constraint-driven geometry state concept.

The addition/removal of the constraint defines the life cycle of the geometry state and is responsible for setting and removing
the state, so that geometry state and constraint are kept synchronised.

The life cycle is completed with proper serialisation of the geometry state.

In summary:
1. Upon restore, the stored state is restored and any migration is handled to set the status for legacy files (backwards compatibility)
2. Functionality adding constraints (of the relevant type) calls addGeometryState to set the status
3. Functionality removing constraints (of the relevant type) calls removeGeometryState to remove the status
4. Save mechanism will ensure persistance of the geometry state
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
0a875c785d Sketcher: GeometryFacade convenience function isAlignedGeometry() 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
2dc8743bbb Sketcher: Sketch solver interface using geometry state extension for BSpline knot checks
========================================================================================

Until this commit, B-Spline knots were stored, and checked at solver level as sketch points GeomPoints having the
construction status set to true.

This behaviour is removed to eventually enable normal non-construction points to define the shape out of edit mode.

This commit leverages the new mechanism for the solver interface.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
38f9b7f041 Sketcher: After restore migration mechanism
===========================================================

The introduction of the ability of the geometry extensions to store information leads opens new
possibilities to the sketcher, which may require migration of previous versions of the sketcher.

A striking example is the migration of the GeomPoint+Construction to mark a B-Spline knot to a proper
geometry state based on the sketch geometr extension.

It also enables to make aware the geometry of the Blocked status, by restoring the geometr blocked
status.

This commit defines an scheleton for this mechanism.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
57a1df83d7 Sketcher: Extend GeometryFacade and ExternaGeometryFacade to GeometryMode 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
3c0bebf4f8 Sketcher: SketchGeometryExtensionPy - add testGeometryMode/setGeometryMode interface 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
e2d55c3cea Sketcher: SketchGeometryExtensionPy getBlocked Python interface 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
d125007726 Sketcher: SketchGeometryExtension refactor GeometryMode type from string
========================================================================

getGeometryModeFromName
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
077e77ee82 Sketcher: SketchGeometryExtension - New GeometryMode flags
==========================================================

Geometry mode flags are intended to store geometry state, such as Blocked status.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
818ffa91ce Sketcher: SketchGeometryExtension refactor InternalGeometry string conversion
=============================================================================

Minor refactoring to centralise string to enum conversion in a single place
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
4391b3217f Sketcher: Adapt GeometryFacade and ExternalGeometryFacade to new SketchGeometryExtension 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
f3ffcd6c4a Sketcher: Geometry Extension for Internal Alignment Geometry
============================================================

This commit extends SketchGeometryExtension to store within a Geometry if it is an internal aligment geometry
and which type.
2020-12-10 18:34:06 +01:00