Commit Graph

22259 Commits

Author SHA1 Message Date
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
Abdullah Tahiri
72fa70add8 Sketcher: Adapt GeometryFacade and ExternalGeometryFacade to new SketchGeometryExtension 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
858d29f163 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
Abdullah Tahiri
2b35a7eec4 Sketcher: GeometryFacade and ExternalGeometryFacade nullptr creation
====================================================================

If the Part::Geometry * is nullptr, then it is convenient to have a
std::unique<GeometryFacade> that contains a nullptr too, because many
functions check for a Part::Geometry being a nullptr.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
858abd99ca Sketcher: GeometryTypedFacade and GeometryFacade convenience functions
======================================================================

GeometryFacade is added the ability to get the construction status via static function, for
convenience in situations where only the construction status is necessary and a geometry facade
would not be otherwise necessary.

A new type GeometryTypedFacade is added, for situations in which the specific Part::Geometry derived
type is known (or is to be created). This Typed version enables to directly access the Geometry derived
class without the need for casting, as well as the SketchGeometryExtension information.

For example, this is possible:

auto HLineF = GeometryTypedFacade<Part::GeomLineSegment>::getTypedFacade(HLine);
HLine->getTypedGeometry()->setPoints(Base::Vector3d(0,0,0),Base::Vector3d(1,0,0));

If a facade is requested without passing an Part::Geometry derived object, the constructor
of the indicated geometry type is called with any parameter passed as argument (emplace style):

auto HLine = GeometryTypedFacade<Part::GeomLineSegment>::getTypedFacade();
HLine->getTypedGeometry()->setPoints(Base::Vector3d(0,0,0),Base::Vector3d(1,0,0));
HLine->setConstruction(true);
ExternalGeo.push_back(HLine->getGeometry());

Using either GeometryFacade or GeometryTypedFacade is probably a matter of style and of the specific situation.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
6b05767a0c Sketcher: ExternalGeometryExtension - refactor flag string to type in static function 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
ec5976ec28 Part: GeometryMigrationExtension classes
========================================

This is a light-weight c++ only geometry extension to enable migration of information that was stored within
the Part WB and should be migrated to another WB (for example Sketcher WB)

It is designed so that a single extension can migrate different types of data (current and future).

When new data needs to be migrated, first a new enum bit is to be added to the class enum and new data members are to
be added to store the information within GeometryMigrationExtension class.

In the Restore() function restoring the data to be migrated, a GeometryMigrationExtension extension is added to the
geometry to be migrated with the data information and the corresponding enum bit set.

In the object to receive the migration data, onDocumentRestored() it is checked whether an extension of type
GeometryMigrationExtension is present, if yes, it is checked whether a bit used for migration is set and, if yes,
the data is retrieved and the GeometryMigrationExtension extension (preferably) removed from the Geometry object.
2020-12-10 18:34:06 +01:00
Abdullah Tahiri
6a02496860 Part: Geometry - Add non-const getters for extensions 2020-12-10 18:34:06 +01:00
Abdullah Tahiri
90dea635ac Part: Geometry refactor member copy
===================================

Encapsulate Part::Geometry data member copy process in a single function (copyNonTag).

Part::Geometry derived classes need not know the specifics of the data member of Part::Geometry.

Change the delegation of the copy of extensions from clone() to copyNonTag. Because clone() relies on
copy() and now copy() of Part::Geometry data member relies on copyNonTag(), there is no actual change
to the clone() functionality, but the copy() funcionality gains the copy of the extensions via copyNonTag().
2020-12-10 18:34:06 +01:00
luz paz
6ffe65c915 AddonManager: Sort .qrc file
[skip ci]
2020-12-10 11:57:25 +01:00
luz paz
7c43b059df Part: fix header uniformity + trailing whitespace
[skip ci]
2020-12-10 11:56:55 +01:00
wmayer
ed063646ed PD: [skip ci] fix invalid strings 2020-12-09 16:59:34 +01:00
wmayer
a99a601948 Gui: [skip ci] Fix Qt warning 'Unable to set geometry ...' 2020-12-09 16:22:14 +01:00
wmayer
56b4837a83 Main: [skip ci] handle C++ exception in main() function 2020-12-09 15:38:06 +01:00
Yorik van Havre
84f56393d3 Draft: Better layout of the Draft SetStyle task panel 2020-12-09 14:42:50 +01:00
Yorik van Havre
d03262cc41 Arch: Fixed typo (Awming->Awning) 2020-12-09 11:54:35 +01:00
wmayer
065f3fafa9 [skip ci] avoid to let Coin redefine several HAVE_ macros 2020-12-08 19:06:09 +01:00
wmayer
daea30341e App: [skip ci] by default disable transactions on recompute 2020-12-08 13:17:16 +01:00
wmayer
78c6cc1362 Import: [skip ci] fixes #0004477: Can't import .STEP files with cyrillic symbols 2020-12-07 17:54:17 +01:00
Yorik van Havre
b082c813f8 Merge pull request #4068 from aapo-aapo/TD-Spreadsheet-fix
[TD] TechDraw DrawViewSpreadsheet fix
2020-12-07 14:15:01 +01:00
bitacovir
1d3113ebda Add SVG icons for ten Std File Menu Commands
This commit adds SVG files with icons for these commands. Also, it makes the necessary changes on CommandDoc.cpp, CommandWindow.cpp, CommandStd.cpp and resource.qrc files.
2020-12-06 18:25:20 -03:00
sliptonic
983e513704 Merge pull request #4089 from mlampert/feature/thread-milling
Path: Feature/thread milling
2020-12-05 13:16:53 -06:00
Aapo
72d003f102 [TD] Make DrawViewSpreadSheet respect DrawPage::redrawCommand() update mechanism. 2020-12-05 00:50:20 +02:00
Aapo
6803af4dc4 [TD] Fix column index range checking bug in std::string DrawViewSpreadsheet::getSheetImage(void) 2020-12-05 00:50:19 +02:00
luz paz
71726a11d0 FEM: Added instructions to fem.dox file 2020-12-04 17:50:05 +01:00
luz paz
f4a65dcbb6 FEM: doxygen 2020-12-04 17:50:00 +01:00
Mark O'Donovan
bc3f90663e Remove unused variable in DrawViewDimension.cpp 2020-12-04 17:13:56 +01:00