Commit Graph

22285 Commits

Author SHA1 Message Date
Markus Lampert
c955bf4a4e Fixed v-carve depth calculation in the presence of a bottom diameter, added unit tests and cleaned up the v-bit parameter naming. 2020-12-13 11:31:58 -08:00
luz paz
68eba58e64 Mesh: Uniformity fixes [skip ci]
* Sort Mesh.qrc
* Capital Case .svg files
* Rename Tree_Mesh.svg to Mesh_Tree.svg
* Make appropriate changes in the source regarding said name changes
2020-12-13 17:08:22 +01:00
wmayer
ddbd7696ce Py: [skip ci] replace PyList_Append with Py::List::append 2020-12-13 16:45:06 +01:00
wmayer
a152cd2d96 Py: [skip ci] replace PyList_Append with Py::List::append 2020-12-13 16:44:14 +01:00
wmayer
aec9d5f07a Py: fix memory leaks by incorrect use of PyList_Append 2020-12-13 16:30:04 +01:00
Abdullah Tahiri
512d5c6141 Sketcher: Ensure that ViewProvider Geometry extensions is correctly initialised 2020-12-12 16:18:57 +01:00
Abdullah Tahiri
3f6fed377b Sketcher: refactor unnecessary dir/angle conversion 2020-12-12 16:18:57 +01:00
Abdullah Tahiri
c2108911d6 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
luz paz
c4b1ec01ba Main: fix header uniformity + trailing whitespace
[skip ci]
2020-12-12 08:17:58 +01:00
luz paz
cb58706e80 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
be11a92f4e PD: [skip ci] in wizard shaft handle case where Plot module is not available 2020-12-11 16:09:01 +01:00
wmayer
1bc39542d3 Part: [skip ci] support of keywords in Part.GeometrySurface.toBSpline() 2020-12-11 14:40:09 +01:00
tomate44
f5f349fac8 Part:Surface.toBSpline use OCC MaxDegree instead of fixed value. 2020-12-11 14:05:08 +01:00
tomate44
75a2f471ea Part: update GeomSurface.toBSpline doc 2020-12-11 14:05:08 +01:00
tomate44
e7c06e8483 Part: add default values to GeomSurface.toBSpline() 2020-12-11 14:05:08 +01:00
Chris Hennes
5f37274ce1 [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
luz paz
2a8c1271d5 Draft: fix header uniformity + trailing whitespace
[skip ci]
2020-12-11 13:19:49 +01:00
wmayer
4a8fac9147 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
ea3ecf4054 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
9add3ba199 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
40c0f0aa01 Sketcher: refactor onDocumentRestored() 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
f33aab5f5e 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
4aa91f0f26 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
2c0faabb6f Sketcher: GeometryFacade - Remove Debuging code 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
c08d4d9dff 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
51eb55081c Sketcher: GeometryFacadePy - testGeometryMode Python interface 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
cfd5cfd6c7 Sketcher: SketchGeometryExtensionPy getConstruction from extension 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
11d4d6c18e 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
4e199bd23e Sketcher: Fix construction migration 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
a624a35af1 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
395a0f19b4 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
316a8b635d 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
6f63796efb 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
40c8af8014 Sketcher: GeometryFacadePyImp - no longer checking if a point is construction to set construction status 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
d96769e6d7 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
be8e5ac338 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
00cf07d1dd Sketcher: GeometryFacade - isInternalType static convenience function 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
2197db04e5 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
95c1a262b7 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
8080e8df90 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
e5eff3f06b 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
593ade1604 Sketcher: GeometryFacade convenience function isAlignedGeometry() 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
ffe2ecaa4a 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
02737a3b5b 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
eb929ad217 Sketcher: Extend GeometryFacade and ExternaGeometryFacade to GeometryMode 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
092a1ee39d Sketcher: SketchGeometryExtensionPy - add testGeometryMode/setGeometryMode interface 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
cd77e7ad2c Sketcher: SketchGeometryExtensionPy getBlocked Python interface 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
9abbbd2b55 Sketcher: SketchGeometryExtension refactor GeometryMode type from string
========================================================================

getGeometryModeFromName
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
e230e60d5f 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
91ac9d2951 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