Commit Graph

154 Commits

Author SHA1 Message Date
Mino-Tsuzuku
e70fde5773 Draft: Fix several SVG import bugs (#20293)
* Fix #19422 SVG: use tag create wrong size object
Fix #19072 SVG: import <defs> keyword as object without <use>
and Fix bug that not reported, <symbol> keyword as object without <use>
and Fix bug that not reported, nested use tag not import correctly.
 To do this. I make preprocessor that replace use tag to it's referenced object.
and remove symbol tag and defs tag from loaded svg.
 there is a subeffect, name of imported object that related to symbol tag is changed.

* Fix  incorrect import when use tag nesting context.

* fix error when use tag not exist.

* rebased aprospero PR20293.
fix several bugs.
1,x and y attribute of use tag is not processed under certain condition.
2,Doesn't finish importing when referenced ID is not exist.
3,Doesn't finish importing when use tag use href instead of xlink:href

* Refactor: Use data.get() for cleaner dictionary key handling

* Refactored code for simplicity following suggested changes.

* Add <a> tag support.( <a>tag  is  almost same with <g> tag at visual effect )

* Correct mistakes in the if condition handling href and xlink:href

* Modify the code to retain the original namespace definitions, as removing all namespaces may cause incorrect importing process.
2025-06-09 23:44:37 +02:00
aprospero
f3fe554af7 importSVG - Path generation Overhaul (#20749)
* add precision Parameter for importSVG to preferences

* rewrite svgpath import

reorganize the existing svg interpretation code snippets by dividing the responsibilities for data provision and actual shape generation.
That bears the opportunity to optimize the resulting construction data regarding consistency and precision.

* create cuts from inner paths

organize paths in a tree structure where completely contained paths are children of their sorrounding paths

In a second step the even depth paths are cut with their respective (uneven depth) children.

* move svg path import logic into its own module

* Restructure how the import result is controlled by preferences.

* reintroduce alternative transform function

Using transformGeometry() on shapes results in degenerations like lines mutating to bsplines of 1st order. For non-orthogonal Transformations this can't be avoided. But for orthogonal transformations (the majority) we can apply those transformations without degeneration.

The necessary function including fallback to transformGeometry() is already in the code but was disabled due to a regression.

See: https://tracker.freecad.org/view.php?id=2062

Associated commits: f045df1e 2509e59b d4f3cb72

I reactivate the code since the degeneration of paths seems a bigger issue to me than misformed svg files producing incorrect measurements. Degenrated paths are often the culprit for later arising 3D-calculation errors.

* avoid path degeneration by keeping scale transformations uniform

* repair style application on shapes

the style should be based on the configured svgstyle mode in the svgimport preferences.

* improve logging of face generation.

* refactor: rename _precision_step to _tolerance

naming according to example set in draft utils.

* fix: indentation

* spelling
2025-04-25 16:44:03 +02:00
Chris Hennes
1a2070c36f Merge pull request #19636 from kadet1090/color-in-base
Base: Move App::Color to Base
2025-03-02 16:36:40 -06:00
Mino-Tsuzuku
a29895dd3c fix #19723 SVG: transform attribute is not handled collectly (#19845)
* * Move pyopen with encoding to utils.
 and modify all importing library to use pyopen with encoding.
with this change, DXF OCA AirfoilDAT with multibyte sequence always read as utf-8.

* Fix SVG transform attribute is not handler collectly.
2025-03-01 19:06:46 -06:00
Roy-043
c0f0fa1d94 Draft: fix alignment of sketches in SVG and legacy DXF export
Fixes #5990
Supersedes #13652

This solution only works for sketches. The export of other planar objects remains the same.

This is similar to the way the C++ DXF exporter handles things. What is different here is that if multiple sketches are exported they are assumed to have the same normal, and their position relative to each other is preserved.
2025-02-24 17:13:51 +00:00
Kacper Donat
13fbab9e42 Base: Move App::Color to Base
Every basic data type is stored in Base module, color is standing out as
one that does not. Moving it to Base opens possibilities to integrate it
better with the rest of FreeCAD.
2025-02-17 21:10:26 +01:00
Mino-Tsuzuku
0ce232b38a * Move pyopen with encoding to utils. (#19377)
and modify all importing library to use pyopen with encoding.
with this change, DXF OCA AirfoilDAT with multibyte sequence always read as utf-8.
2025-02-04 11:33:43 +01:00
Mino-Tsuzuku
9e5508513c #18458 fix SVG import error at non-utf8 native environment. (#19280) 2025-01-30 13:13:56 +01:00
bgbsww
94aad208bc Make python Regex Strings raw to avoid py3.12 SyntaxError 2024-09-30 17:42:49 +02:00
Dov Grobgeld
e66e90b512 Fix run time errors with python3.12 and pyside6 (#13337)
* Change pyopen=open expression to from builtins import open as pyopen

---------

Co-authored-by: Adrián Insaurralde Avalos <36372335+adrianinsaval@users.noreply.github.com>
2024-04-30 00:28:01 -04:00
Kevin Martin
78eba96f1c Replace deprecated escapes with valid ones 2024-02-02 08:58:49 -05:00
Ladislav Michl
839fb17649 Draft: Use widgets from QtWidgets 2024-01-25 14:27:38 +01:00
Roy-043
16e5835aa6 Draft: implement new get_param functions (step 4)
See #11677
2023-12-13 19:39:35 +01:00
Yorik van Havre
f5cd6d91d2 Draft: Fixed linewidths in SVG export - fixes #6034 2023-10-27 13:04:40 +02:00
Roy-043
5187bc0a28 Draft: importSVG: handle viewBox in mm (PR10929 fix was not correct) 2023-10-22 17:51:14 +02:00
Roy-043
44e01fac12 Draft: importSVG: handle viewBox in mm
Forum topic:
https://forum.freecad.org/viewtopic.php?t=81696
2023-10-04 11:03:36 +02:00
Roy-043
25960b42f3 Draft: importSVG.py: check and fix path faces
Fixes #10659.
2023-09-12 23:16:41 +02:00
Yorik van Havre
f8f2d4c21c Draft: Skip SVG import DPI dialog if a unit is specified in the file - fixes #6653 (#9533) 2023-05-13 21:18:59 +02:00
Yorik van Havre
58335e7a93 Draft: Support group styles in SVG import - fixes #6900 (#9522)
* Draft: Support group styles in SVG import - fixes #6900

* Draft: SVG importer - apply styleto polylines
2023-05-13 21:01:04 +02:00
0penBrain
c171723a7f Draft: Improve color handling of SVG geometry importer
Handle 'none' color => Default to black (+ print message)
 Handle #RRGGBBAA color => Return alpha (+ print, message)
 Handle 'rgba(float, float, float, float) => Return alpha (+ print message)
 Reorganize function to return ASAP + print warning if unknown color format
2023-04-26 21:00:37 +02:00
luzpaz
38a01939e0 Migrate domain name from freecadweb to freecad (#9352)
* Migrate domain name from freecadweb to freecad
* Migrate src/Mod/Material files
* Migrate Stylesheet related files
* Migrate *.svg files
* Migrate miscellaneous files
* Migrate some build files
* Migrate recently added TD AR_IRAM template files

Closes #6415
2023-04-24 15:19:20 -05:00
mosfet80
e9c1a1600a [Draft] Remove obsolete code related to Drawing WB
* [Draft] Remove obsolete code related to Drawing WB




remove unused elif

* [Draft] Remove obsolete code related to the Drawing WB

* Update preferences-draftvisual.ui

Also remove the template label.

* Update utils.py

Remove reference to "template"

* Remove Draft_Drawing.svg from Draft.qrc

---------

Co-authored-by: Roy-043 <info@b-k-g.nl>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
2023-04-03 16:36:23 +02:00
Roy-043
b5ade2c085 [Draft] Remove obsolete decode code (#9106) 2023-03-28 21:03:33 +02:00
luzpaz
95070bded4 Draft: Fix 'testing inequality to None' syntax (#7275)
* Draft: Fix 'testing inequality to None' syntax 

- Substitute `is not None` for `!= None`
- Trim trailing whitespace on touched files
2022-07-30 00:26:56 +02:00
Chris Hennes
3aa2920e33 Draft: fix SVG rotation around non-origin center
Fixes #6869
2022-05-16 11:10:04 -05:00
Roy
84b3003e8e Draft: Housekeeping: call 'make' functions with new name (4) 2022-02-20 22:31:08 -06:00
Roy-043
6f970b197f Draft: Fix importSVG.py: wrong position for certain ellipses (#5297)
Ellipses and elliptical arcs with a y radius larger than their x radius would end up in the wrong position.
2022-01-06 17:02:41 +01:00
Chris Hennes
26ce308cf1 [DRAFT] Add call to super().__init__ where missing
Identified by LGTM. The toplevel superclass does initialize one data
member to an empty array, but this didn't appear to cause any problems.
2021-02-27 18:21:54 +01:00
vocx-fc
2ce3629443 Draft: importSVG considers Shape-less objects for export
If the object has a `Shape` it uses its bounding box to enlarge
the page size of the SVG. If it does not have a `Shape`
("Draft Text", "Draft Dimension", other `App::FeaturePython`)
it uses `Draft.get_bbox` to calculate one bounding box
from the viewprovider if possible.
2020-09-30 12:06:48 +02:00
vocx-fc
17ff22c721 Draft: improve style and indentation of getSVG function
Also rename `getSVG` to `get_svg`.

Instead of testing `obj.isDerivedFrom('Part::Feature')`
we test for a Shape, `hasattr(obj, 'Shape')`.
This is to support the SVG generation of `App::Links`.
2020-09-03 11:40:50 +02:00
vocx-fc
9de3c4143a Draft: add warning message in case the radius is negative 2020-07-07 10:14:04 +02:00
Yorik van Havre
4d90327a97 Draft: Fixed further regressions 2020-04-21 12:46:08 +02:00
vocx-fc
863e1a879e Draft: importSVG.py, FreeCADGui with interface only
Also small fixes in imports and spacing
2020-04-07 18:12:06 +02:00
Bernd Hahnebach
41cf28d1fb Draft: SVG import, encode fix 2020-01-10 12:39:33 +01:00
luz.paz
8cfa85cf18 Draft: [skip ci] Fix header uniformity
This PR fixes header uniformity across all Draft files
2019-12-27 00:16:12 +01:00
0penBrain
90825d290a Improve Inkscape version parsing in SVG import 2019-12-06 14:35:59 -03:00
0penBrain
47dfe708d9 Improve Python compatibility
According remark which I agree with
2019-11-29 14:52:29 +01:00
0penBrain
82931b4368 Fix bad 'pt' unit definition
'pt' unit has been defined as 1.25 px while it is 4/3 px (~1.33 px).
Relates to issue #4200
Relates to Syres916@469e01d (despite bug always existed, even before this commit)
Source : https://oreillymedia.github.io/Using_SVG/guide/units.html
2019-11-29 14:52:29 +01:00
vocx-fc
bb96ff25df Draft: importSVG, commit 19f87739 accidentally introduced blady merged code that produced syntax errors; then 1ad65467 tried to fix it by removing the syntax errors; however a large block of text needs to be removed as well; this was supposed to happen in pull request #2418; however, that pull request no longer merges cleanly so it was withdrawn; this commit finally fixes the problem. 2019-08-14 14:41:58 -03:00
luz.paz
020a66cddf Fix misc. typos
Found via `codespell -q 3 -I ../fc-word-whitelist.txt -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 -L od,orign,orginx,orginy`
2019-08-14 14:36:53 -03:00
Yorik van Havre
b2a32125bc Draft: Fixed leftover from badly merged commit 2019-08-12 19:46:40 -03:00
Yorik van Havre
59863f4432 Merge branch 'misc-typos' of https://github.com/luzpaz/FreeCAD into luzpaz-misc-typos 2019-08-09 18:52:31 -03:00
vocx-fc
3e48aec60f Draft: importSVG.py, commented out or removed unused variables. Quality of code checked with flake8 --ignore=E226,E266,E401,W503 2019-08-09 18:46:46 -03:00
vocx-fc
45bc9a73bb Draft: importSVG.py, use auxiliary variables to reduce the length of the lines, particualrly the lines with regular expressions which search quantities in strings 2019-08-09 18:46:46 -03:00
vocx-fc
6b4e3b274f Draft: importSVG.py, use auxiliary variables to reduce the length of the lines, and make the code more readable 2019-08-09 18:46:46 -03:00
vocx-fc
a5909173a5 Draft: importSVG.py, use auxiliary variables to reduce the length of the lines, avoid too many nested parentheses, and make the code more readable 2019-08-09 18:46:46 -03:00
vocx-fc
5de106b2b3 Draft: importSVG.py, test for FreeCAD.GuiUp to confirm that the interface is up; the old check doesn't work; show the Qt dialog only if the interface exist, otherwise assume 96 dpi 2019-08-09 18:46:46 -03:00
vocx-fc
dd8d3fb3c6 Draft: importSVG.py, improved spacing, used auxiliary variables to reduce the line length and clean up the code 2019-08-09 18:46:46 -03:00
vocx-fc
0d6fba6355 Draft: importSVG.py, improved spacing, used auxiliary variables to reduce the line length and clean up the code 2019-08-09 18:46:46 -03:00
vocx-fc
00b8ed29b3 Draft: importSVG.py, 4 space indentation, 8/8 translateVec, getMatrix 2019-08-09 18:46:46 -03:00