Compare commits

...

541 Commits

Author SHA1 Message Date
Zheng Lei 140236c774 Merge pull request #8124 from jerome992/development/toponaming
Fix selection in sketcher development/toponaming
2023-01-08 09:59:00 +08:00
Jerome cc3d7dfbf0 Fix selection in sketcher
https://forum.freecadweb.org/viewtopic.php?p=650988#p650988

* The function ViewProviderSketch::isSelected should not modifiy its
  incoming parameter
* ViewProviderSketch::rmvSelection, ViewProviderSketch::addSelection,
  ViewProviderSketch::addSelection2 have not called the convertSubName
  function.
* Should the the convertSubName not be called inside the function
  ViewProviderSketch::mouseButtonPressed, because now the convertSubName
  is called two times?
2023-01-03 22:18:44 +01:00
Zheng, Lei 112c15ed75 App: fix lost of element reference tracking on undo/redo 2022-12-12 10:47:16 +01:00
Uwe a08b04a079 [Part] TopoShapeEx.cpp: fix some whitespace issues
- as reported by the CI
2022-11-29 03:32:34 +01:00
Zheng Lei 811bf87d0e Topo Naming accumulated fixes (#7792)
* Part: fix Part.sortEdges()
 (Fixes realthunder/fcad_pcb#61)
* App: fix indexed element name parsing
* Part: avoid unnecessary wire making in TopoShape::makELoft/makEPipeShell()
2022-11-29 01:57:07 +01:00
Uwe 93c3ef7b2f [skip ci] .clang-format: shorthand loops
- disallow as we did before we had this format file
2022-11-22 03:13:17 +01:00
Uwe ad94f88217 [skip ci] [.clang] set pointer style to left
- since we added the .clang-format file we used Left for the pointer asterisk. It is annoying to get now all the time automatic diffs because the -clang file uses Right.
2022-11-11 05:20:33 +01:00
Uwe c2f7d03413 [.clang] use line break after case
- we used in the past line breaks after a case statements to better overview. This should be kept.
2022-11-11 05:20:33 +01:00
Zheng, Lei f2b2c8b4e7 Part: fix AttachEngine sub-element auto fix 2022-11-03 22:23:52 +01:00
Zheng, Lei f9688fbde7 Part: fix missing topo naming in FeatureExtrusion 2022-11-03 22:23:52 +01:00
Zheng, Lei 51621458b5 Change topo naming branch version in cmake
Limit the change only in src/Main
2022-10-28 07:42:54 +08:00
Uwe c25ed7e162 set version number to 0.20
- there was some confusion.
 Toponaming is FreeCAD 0.20.0 + toponaming, so neither 0.20.1 nor 0.21/master
2022-10-27 15:37:41 +02:00
Zheng, Lei 2a4335302f Remove special toponaming version string to avoid test failure 2022-10-27 15:53:44 +08:00
Zheng, Lei 69ed88ac2c Add new build option FREECAD_TOPONAMING_BRANDING
For differentiating releases of toponaming and master branch, with
branding_toponaming.xml specifying customized window icon, title, and
version number.

The build option is default ON in toponaming branch. For future merge
into master, change this option to OFF by default.
2022-10-27 09:44:19 +08:00
Zheng, Lei 1f946e6c9a Part: fix TopoShape::isLinearEdge() transformation 2022-10-26 17:08:37 +08:00
Zheng, Lei ac76ba280d Fix build warning
Build warning on MacOS homebrew caused by missing Standard_Version.hxx
2022-10-26 15:04:49 +08:00
Zheng, Lei ceab748ba1 Part: fix element mapping in TopoShape::fix()
Also change makEWires() to use fix()
2022-10-26 11:05:45 +08:00
wmayer e1232a5e6e CMake: [skip ci] fix deprecation warning about policy CMP0072 2022-10-26 02:51:27 +02:00
Zheng, Lei 5cc0693e61 Temporarily hardcode application name for TopoNaming branch 2022-10-23 11:08:12 +08:00
Uwe 387b19eed9 [.github] port recent changes from master 2022-10-22 15:45:33 +02:00
looooo 18ff9bcf26 add_definitions(-DSALOME_USE_64BIT_IDS) for smesh via config 2022-10-22 01:34:02 +02:00
looooo 5da8804871 extend find_package(SMESH) 2022-10-22 01:27:28 +02:00
Scott Mudge dbeb4d2f5d Fixed external SMESH cmake scripts, allowing netgen and gmsh compatibility with VTK 9
- moved base SMESH cmake logic to respective cmake script.
- allow BUILD_SMESH, regardless of external SMESH usage, for testing and so on.
2022-10-22 01:27:28 +02:00
Zheng, Lei d2d0b7f018 Fix build warning with OCC 7.6 2022-10-18 22:27:15 +08:00
Zheng, Lei c28d5659a0 Fix build error on MacOS 2022-10-18 22:27:15 +08:00
Uwe 812c1e0f56 [.clang] change a setting back to our "default"
- we used (since I am at FreeCAD) a line break after an if statement for better readability. I noticed that this rule on not in our .clang format causing unwanted diffs when using it (e.g. when coding using the Visual Studio IDE:)
2022-10-03 05:45:47 +02:00
Uwe 99f719e81c sync .gitignore with master 2022-10-01 06:03:52 +02:00
Uwe da58eb2681 StringHasher: some more Clang formattings 2022-10-01 06:00:34 +02:00
Uwe c084eef7a3 sync .clang and .github with master 2022-10-01 05:47:34 +02:00
Uwe 24036a8046 StringHasher: sanitize includes
- fix CI warning "parameter name 'a' is too short, expected at least 3 characters"
- fix some CI whitespace warnings
- some Clang formatting
2022-10-01 05:35:17 +02:00
Uwe db8729ec74 StringHasher: sanitize includes
- try to fix CI warning "Found C system header after other header."
- remove unneeded includes
- sort includes
2022-10-01 05:14:05 +02:00
Zheng, Lei 015d6396ff App: improve code quality of StringHasher 2022-10-01 04:49:07 +02:00
Zheng, Lei 6df100f5b7 Base: expose underlying_type in Flags 2022-10-01 04:49:07 +02:00
Zheng, Lei 7cb9ba470c Sketcher: fix various topo naming related problem 2022-09-25 20:25:25 +02:00
Zheng, Lei 1e6f84a59c App: suppress useless warning message 2022-09-25 20:25:25 +02:00
Zheng, Lei 2292eecb4e App: revert ComplexGeoData::getSubElementByName() 2022-09-25 20:25:25 +02:00
Zheng, Lei 5fc5203ff7 Part: fix tapered extrusion backward compatibility 2022-09-25 20:25:25 +02:00
Zheng, Lei e8547f7588 Gui: prompt user for recompute on recompute topo naming
Expose it as a preference option in

  General -> Document -> Do not prompt for recompute on restore.
2022-09-25 20:25:25 +02:00
Zheng, Lei eade03c006 Base: fix crash on logging Python call frame 2022-09-25 20:25:25 +02:00
Uwe cef5e6f4ab [Import] eventually fix compilation on MSVC 2022-09-16 15:53:09 +02:00
Uwe 9331c0d939 [import] attempt to fix compilation
- patch by @realthunder
- does not fix the problem, though
2022-09-16 02:40:20 +02:00
Uwe decc354b80 fix compiler warning 2022-09-16 02:39:15 +02:00
Zheng, Lei f24c64c96c Fix build warning 2022-09-15 13:37:39 +02:00
Zheng, Lei 689f6595fb Fix typo 2022-09-15 13:37:39 +02:00
Zheng, Lei 3a2e799300 Fix typo 2022-09-15 13:37:39 +02:00
Zheng, Lei c643e5e340 Sketcher: improve task panel for elements and constraints 2022-09-15 13:37:39 +02:00
Zheng, Lei 8ee6153f4b Sketcher: support new topo naming 2022-09-15 13:37:39 +02:00
Zheng, Lei bf38d42f15 Sketcher: add some icons 2022-09-15 13:37:39 +02:00
Zheng, Lei 6fa8bba4fd Part/Sketcher: change geometry extensions APIs for topo naming support 2022-09-15 13:37:39 +02:00
Zheng, Lei 33c85ba1f2 Part: improve efficiency of PropertyGeometryList 2022-09-15 13:37:39 +02:00
Zheng, Lei 9f200d4404 App/Part: add API Property::isSameContent()
A generate implementation of comparing property of any type.

Note, in the future, isSame() will be promoted to be an abstract API in
Property, and every type of property will have to provide an
implementation. isSameContent() can be used as a not so efficient
fallback.
2022-09-15 13:37:39 +02:00
Uwe 50f6650fac [skip CI] fix 2 typos reported by spellchecker 2022-09-14 14:22:29 +02:00
Zheng, Lei 5db5fc3886 Fix build error
error: ambiguous overload for ‘operator==’ (operand types are ‘App::StringHasher* const’ and ‘const StringHasherRef’ {aka ‘const Base::Reference<App::StringHasher>’})
2022-09-05 12:06:06 +05:00
Zheng, Lei 28ca0cf7b1 Fix typo 2022-09-05 12:06:06 +05:00
Zheng, Lei b470cfeaf1 Fix build for OCC < 7.6 2022-09-05 12:06:06 +05:00
Zheng, Lei 352678f4e2 Part: fix history tracing in static function getElementColor() 2022-09-05 12:06:06 +05:00
Zheng, Lei f87ed0c454 PartDesign: retag external bound shape in SubShapeBinder 2022-09-05 12:06:06 +05:00
Zheng, Lei c42a4cb21c App: force retag shape of linked object
The re-tagging is necessary for trace geometry element history to linked
object, which is required for Part::ViewProviderPartExt color mapping.
2022-09-05 12:06:06 +05:00
Zheng, Lei f638619964 Import: improve STEP color support using topo naming 2022-09-05 12:06:06 +05:00
Zheng, Lei 8dc3b71989 Part: improve per geometry element coloring through topo naming 2022-09-05 12:06:06 +05:00
Zheng, Lei 4984bd9f05 Gui: add API ViewProvider::updateColors()
Used in TaskElementColors for general handling of per geometry element
coloring.
2022-09-05 12:06:06 +05:00
Zheng, Lei 27c893f71f Part: support new topo naming in Part features
Most of the new topo naming code can be disabled by defining Macro
FC_NO_ELEMENT_MAP
2022-09-05 12:06:06 +05:00
Zheng, Lei 6c51bebf14 Part: improve Attacher with new topo naming
Make use of the shadow subname (i.e. the new topo naming) stored inside
PropertyLinkSubList for more robust geometry element referecing. And
rely on Part::Feature::getRelatedElements() to deduce missing geometry
elements.
2022-09-05 12:06:06 +05:00
Zheng, Lei 32d45ac97d App/Part: fix App::Link visibility detection in PartFeature::getTopoShape() 2022-09-05 12:06:06 +05:00
Zheng, Lei a46cc55da1 App/Gui: add APIs for for efficient extension iteration
ExtensionContainer::foreach/query/callExtension()
2022-09-05 12:06:06 +05:00
Zheng, Lei d11bec9688 App: change API signature DocumentObjectExtension::extensionIsElementVisible 2022-09-05 12:06:06 +05:00
Zheng, Lei 0069419c8b Part: re-enable topo naming version checking 2022-09-05 12:06:06 +05:00
Zheng, Lei b06c0ccd86 Fix typo 2022-09-05 12:06:06 +05:00
Zheng, Lei c85023415a Fix build error for OCC < 7.6 2022-09-03 00:36:31 +05:00
Zheng, Lei db858e1f0a Fix typos 2022-09-03 00:36:31 +05:00
Zheng, Lei 010a632e5d Part: change exception type for TopoShape::getSubTopoShape()
Same for TopoShapePy.getElement()
2022-09-03 00:36:31 +05:00
Zheng, Lei 9d7793ecb9 App: change main StringHasher storage policy
Only save to XML if asked explicitly
2022-09-03 00:36:31 +05:00
Zheng, Lei 418ebb7958 Part: change topo naming storage policy
Only save to XML if asked explicitly
2022-09-03 00:36:31 +05:00
Zheng, Lei e30f7bf920 Gui: fix tree view expansion restore 2022-09-03 00:36:31 +05:00
Zheng, Lei 1b26292d3c Part: Temporarily disable topo naming version check 2022-09-03 00:36:31 +05:00
Zheng, Lei 0afcf099df Part: refactor TopoShape to support new topological naming
The topological naming aware member functions are all located in a new
source file TopoShapeEx.cpp. The core algorithm of generate the names is
in TopoShape::makESHAPE(). Check out the following wiki article for more
details.

https://github.com/realthunder/FreeCAD_assembly3/wiki/Topological-Naming-Algorithm

Note that the actual name encoding is slightly changed to improve
efficiency, but the algorithm is mostly the same.
2022-09-03 00:36:31 +05:00
Zheng, Lei 691c0709be App: improve convenience class SubObjectT 2022-09-03 00:36:31 +05:00
Zheng, Lei 05d35e1e6f Part: move legacy ShapeHistory code 2022-09-03 00:36:31 +05:00
Zheng, Lei 1edab5611b Part: add API Geometry::isSame()
For comparing if two geometries are the same. Exposed to Python with a
method of the same name. The API will be used by TopoShape to search
shape by geometry to make topological naming more robust.
2022-09-03 00:36:31 +05:00
Zheng, Lei e5beb5ab2b App: add APIs in ComplexGeoData for element name mapping
These are the fundation for storing and querying the new topological
naming of geometry element.

To get an overview of this fundation, please check out the following article
https://github.com/realthunder/FreeCAD_assembly3/wiki/Topological-Naming

There are some changes in topo naming internal storage, which changes
from plain string to two dedicated class IndexedName (for indexed
geometry element name) and MappedName. These two classes are created to
improve topological naming performance in terms of speed, runtime
memory, and persistence storage size.
2022-09-03 00:36:31 +05:00
Zheng, Lei c67d9b0ee9 App: change API signature ComplexGeoData::getElementTypes() 2022-09-03 00:36:31 +05:00
Zheng, Lei 6ce250ddf8 App: add API PropertyContainer::onEarlyChange()
Also add DocumentObject::signalEarlyChanged, triggered before
Document::signalChangedObject
2022-09-03 00:36:31 +05:00
Zheng, Lei 75acf045a6 App: add API beforeSave()
Added in class Property and class PropertyContainer to allow customized
processing before saving.
2022-09-03 00:36:31 +05:00
Zheng, Lei 2a254e937f App/Gui: add convenience API getFullName/getOwnerDocument()
in App::Property and App::PropertyContainer, implemented in
App::Document/DocumentObject, and Gui::ViewProviderDocumentObject
2022-09-03 00:36:31 +05:00
Zheng, Lei 444de2c8af App: add string table
General purpose string table to avoid saving duplicated text string
multiple times.. Mainly used by topological naming to compress model
histroy. But can be used for other purpose as well, e.g.  to strore
documentation of dynamic property.
2022-09-03 00:36:31 +05:00
Zheng, Lei fd60f29965 Cloud: fix file save/restore due to Base::Reader/Writer changes 2022-09-03 00:36:31 +05:00
Zheng, Lei 217c8630f6 Base: support saving/restoring binary/text stream inside xml
This commit is split out from realthunder/FreeCAD#a2579bff, which
introduced support of saving FreeCAD document as directory. This commit
only include relavent changes for efficient storage of topological
naming. Full support of directory saving will be added in another PR.

The specific changes needed for topological naming storge is the proper
support of XML characters content in Base::XMLReader and Base::Writer.
Use XMLReader::beginCharStream() to stream either binary or text data.
Binary data will be base64 encoded on the fly with user defined line
size. The base64 string is stored as plain character content inside the
current XML element. Text data is stored inside CDATA section with
automatic detection and handling of CDATA end tag inside the text. Be
WARNED though, there is no validation of text character yet. The caller
must ensure the input text is valid UTF8.

Topological naming uses text stream. The change introduced here also
affects App::PropertyFileIncluded, Gui::TreeWidget (for persistence of
tree item expansion status), Path::Toolpath, Points::PointKernel, and
Spreadsheet::Cell. The changes by right shouldn't cause any backward
compatibility issue.

Another relatively small change that is not so relavant to topo naming
is the support of hierarchical XMLReader, which allows the top level
reader to centralize control of mult-file-reading that might be added by
lower level xml reader. This change is included here because of
difficulty in splitting the functionality apart from the streaming
changes.  Note that this change breaks Mod/Cloud module, which will be
fixed in follow up patches.
2022-09-03 00:36:31 +05:00
Zheng, Lei dc48c5debd Base: improve class 'Handle' efficiency
By replacing dynamic allocated QAtomicInt with std::atomic and making
most code inlined.
2022-09-03 00:36:31 +05:00
Uwe a8606ce05c [.github] try to get the checks also for the 0-20 branch 2022-07-24 06:13:47 +02:00
Uwe adbe29f1dc [.github] disable tidy checks for now
- as requested in https://github.com/FreeCAD/FreeCAD/pull/7152#issuecomment-1193176866
2022-07-24 06:13:47 +02:00
Uwe 3b09334501 [.github] disable clang checks for now
see https://github.com/FreeCAD/FreeCAD/pull/7152#issuecomment-1193167296
2022-07-24 06:13:47 +02:00
Floriansimmer e909322fb9 Github: basic check CI Run (#7152)
* Github: basic check CI Run

- trailing Whitespace
- tab
- string based QT connections
- Cpplint
- pylint
- Black
- clang-format
- Codespell
- clang-tidy
- clazy (+QT6 Checks)
- Report
2022-07-24 06:13:47 +02:00
mosfet80 a304bcc59a Git ignore hidden files with defined exceptions (#7108)
* git ignore all hidden files

* Removal file with non-existent link

* git Ignore all hidden files except .gitignore

* Set exceptions in gitignore
2022-07-24 06:13:47 +02:00
luz paz 83d0fa6730 README: added revisions
[skip ci]
2022-07-02 16:43:56 +02:00
luzpaz 9d54041102 TPN: Modify README.md of toponaming branch to help orientate testers (#7049)
Co-authored-by: luzpaz <luzpaz@github.com>  
Co-authored-by: Ajinkya Dahale <AjinkyaDahale@users.noreply.github.com>
2022-07-01 03:42:44 +02:00
andrea 1021098106 remove unused boost files 2022-07-01 03:18:36 +02:00
Uwe 7001caea9a [FEM] [skip CI] fix a typo
- spot by the spellchecker CI
2022-07-01 03:12:15 +02:00
Uwe 3d597b797a [AddonMgr] [skip CI] fix typo
- spot by the spellchecker CI
2022-07-01 03:10:47 +02:00
Uwe 13db192fca [Gui] [skip CI] update for DlgProjectInformation.ui
- done automatically by Qt Designer
2022-07-01 03:09:50 +02:00
andrea dc57327e7f fIx Cmake Messages 2022-07-01 02:51:48 +02:00
wmayer 75d8371d2b Arch: [skip ci] fix unit test 2022-06-30 23:00:31 +02:00
wmayer 9b2b0e0acf modernize C++: replace boost::function with std::function 2022-06-30 20:31:55 +02:00
wmayer c7c43fcf4b Core: fix minor issues:
+ fix issues found by clang's clazy tool
+ fix cppcoreguidelines-pro-type-member-init
  * Make sure that all class members are initialized in the constructor
2022-06-30 16:31:16 +02:00
Wanderer Fan 2949ab1a2b [TD]remove unused code 2022-06-30 08:50:33 -04:00
Wanderer Fan fdcfd4c565 [TD]Navigation Styles - context menu handling & std cursors 2022-06-30 08:50:33 -04:00
Wanderer Fan 866da5980c [TD]fix Dimension export to DXF 2022-06-30 08:50:07 -04:00
Wanderer Fan 460d153d6c [TD]Include CosmeticLines in Dxf 2022-06-30 08:50:07 -04:00
Abdullah Tahiri 2326186428 Sketcher: Bug fix SolverGeometryExtension
=========================================

Index access at zero size vector cause due to incorrect check.
2022-06-30 13:58:21 +02:00
wmayer b50e0485d9 Test: ignore UnicodeEncodeError in TestMetadata.test_file_path 2022-06-30 13:32:29 +02:00
wmayer 317c6afd45 Mesh: fix (Qt) issues found by clang's clazy tool 2022-06-30 13:14:03 +02:00
wmayer a427c1e99e Base: [skip ci] fix slight regression caused with d162d9371 2022-06-30 13:13:00 +02:00
Yorik van Havre e916f8afbb Arch: Fixed test to work without the Drawing module 2022-06-30 11:38:22 +02:00
sliptonic 59b945dcc3 Merge pull request #7111 from sliptonic/bug/camoticsimport
[PATH] Another camotics import bug.
2022-06-29 16:37:48 -05:00
wmayer d5921e08ec fix (Qt) issues found by clang's clazy tool:
+ -Wclazy-incorrect-emit
+ -Wclazy-strict-iterators
+ -Wclazy-overloaded-signal
+ -Wclazy-qstring-arg
+ -Wclazy-unused-non-trivial-variable
+ -Wclazy-container-anti-pattern
+ -Wclazy-range-loop-reference
+ -Wclazy-const-signal-or-slot
+ -Wclazy-detaching-temporary
+ -Wclazy-qfileinfo-exists
2022-06-29 21:00:54 +02:00
wmayer 898b1007b9 Test: use codecs.open in TestMetadata.test_file_path 2022-06-29 15:51:42 +02:00
wmayer 7b377a216b Gui: remove workaround for spnav 0.23 due to build failure with musl libc 2022-06-29 15:19:18 +02:00
wmayer 82bbe47d68 Test: set encoding to utf-8 in TestMetadata.test_file_path 2022-06-29 12:28:02 +02:00
wmayer 22829f8a24 App: issue #7112: Addon manager does not work on windows with special characters in the username 2022-06-29 11:25:06 +02:00
wmayer 448b1ec9f3 Test: [skip ci] test file path with utf-8 <-> utf-16 conversion 2022-06-29 11:23:15 +02:00
wmayer 9a70b165cc App: fixes #7102: Undo/Redo of PropertyEnumeration fails with MSVC 2022-06-29 09:59:18 +02:00
sliptonic e428337ffc Another import bug. This time if --version doesn't return a patch number. 2022-06-28 15:57:01 -05:00
wmayer e07cfa09bb Test: extend test for enumeration 2022-06-28 21:24:19 +02:00
Abdullah Tahiri 9763ed29e2 Split DSHs from CommandCreateGeo 2022-06-28 19:29:47 +02:00
Abdullah Tahiri 19230c83ef Remove obsolete DSH Tools - CloseShape and ConnectLines 2022-06-28 19:29:35 +02:00
Abdullah Tahiri 3678a525a2 DrawSketchHandler: Cursor rework and preselect at point functionalities 2022-06-28 19:29:19 +02:00
Abdullah Tahiri 2cf0c49955 DrawSketchHandler: mechanism to update the cursor 2022-06-28 19:29:07 +02:00
Abdullah Tahiri f16c3f36a9 DrawSketchHandler: Functions to draw cursor position and direction 2022-06-28 19:28:56 +02:00
Abdullah Tahiri b80cd6a417 DrawSketchHandler: refactor crosshairCursor
======================================================

-DrawSketchHandler manages both cursor bitmap setting and unsetting
2022-06-28 19:28:18 +02:00
Abdullah Tahiri c6459bb7d3 Utils refactor w/o commandcreategeo 2022-06-28 19:28:06 +02:00
Abdullah Tahiri 9da0f369b1 Utils: Conversion from 2d vector into XY plane 3d vector 2022-06-28 19:27:46 +02:00
Abdullah Tahiri 3cd34e1c38 Sketcher-Utils: vector of smart pointers to vector of pointers 2022-06-28 19:27:37 +02:00
Abdullah Tahiri bae8050fac Sketcher-Utils: Refactor common code up 2022-06-28 19:27:20 +02:00
Paddle f99abec58e Sketcher: Create Geometry ConstraintToAttachment function 2022-06-28 19:27:04 +02:00
Abdullah Tahiri 80cd03cded Sketcher: Cleanup obsolete DrawSketchHandlers 2022-06-28 19:22:58 +02:00
Abdullah Tahiri df50dca01b PythonConverter-Sketcher: A class to convert sketcher geometries and constraints into the commands to generate them
===================================================================================================================

This class does not currently support all sketcher geometry and constraints, but it supports the most common types.
2022-06-28 18:59:06 +02:00
Abdullah Tahiri c6aa3c91e6 ViewProviderSketch: Cursor movement and preselection at sketch coordinates
===============================================================================

- Support to programatically move the cursor to sketch coordinates
- Support to try preselection at a given sketch coordinates
2022-06-28 18:58:47 +02:00
Abdullah Tahiri 473c2efc38 Sketcher: SketchObject - Add ability to diagnose constraint redundancy before addition
======================================================================================

It preserves the SketchObject properties. Therefore it does not trigger any property update, redraws, ...
2022-06-28 18:58:15 +02:00
Abdullah Tahiri f2c1f35aaf Sketcher: SolverGeometryExtension and sketch parameter information improvements
===============================================================================

* SolverGeometryExtension is extended to:
- Enable to determine whether the x or the y of a point is a dependent or independent parameter
- Extend SolverExtension to provide information on individual edge parameters
- Convenience access to DoF status

* Sketch (solver interface) is extended to store geometry parameter dependency state, for these reasons:

Geometry and Constraint solver information is generated when performing a full solve() [QR decomposition + minimization(e.g. DogLeg)].

Constraint information remains in the sketch object (not SketchObject, but sketch), which is then retrieved by SketchObject.

Geometry information is incorporated to the deep copy of Geometry that the sketch object comprises. However, this information is only
available outside the sketch object, if the Geometry property of SketchObject is assigned. This is always the situation after a successful
full solve. However, it is not the case in a successful temporary minimal diagnosis (here succesful relates to conflicting/redundant constraints and
convergence).

The lightweight solution is to keep a (shallow) copy of the SolverGeometryExtensions (shared pointer) to be retrieved by GeoId, which is what is provided.
2022-06-28 18:57:17 +02:00
Yorik van Havre d847d309b0 Merge pull request #7109 from Roy-043/Draft-Fix-default-fillmode-in-DraftGui.py
Draft: Fix default fillmode in DraftGui.py
2022-06-28 15:50:21 +02:00
Roy-043 bc37be0c54 Draft: Fix default fillmode in DraftGui.py 2022-06-28 15:42:28 +02:00
wmayer 779128b5f4 Gui: get rid of some const_cast 2022-06-28 15:26:02 +02:00
tomate44 3af5cfaed6 Part: add method to project point on curve 2022-06-28 12:58:49 +02:00
wmayer 9a3258c9da Part: move BiArcs algorithm to its own class 2022-06-28 12:42:15 +02:00
wmayer 9de8b33bb4 Part: fix GeomBSplineCurve::toBiArcs
If tangent of start and end point are parallel then also check a tangent in between to make sure that it can be considered a straight line
See https://forum.freecadweb.org/viewtopic.php?f=8&t=69710
2022-06-28 11:26:35 +02:00
Uwe 0c797ae6a8 [Base] remove unused MSC code
this part was initially part of #7036 but then accidentally reverted
2022-06-28 00:58:12 +02:00
mosfet80 d162d9371c Remove old msc ver. Freecad 0.20 require 64 bit and windows 7 or higher. For this reason, msc libraries less than 1800 will no longer be used. (#7036)
* remove msc<1800
2022-06-28 00:42:33 +02:00
sliptonic d13db0ea4c Merge pull request #7096 from sliptonic/bug/camotics
[Path] Fix import error if camotics not installed.
2022-06-27 08:53:26 -05:00
Yorik van Havre 657f04908f Merge pull request #7105 from Roy-043/Draft-Fix-align-working-plane-to-DatumPlane-bug
Draft: Fix align working plane to DatumPlane bug
2022-06-27 11:52:31 +02:00
Yorik van Havre 27bfa083b2 Update src/Mod/Draft/draftguitools/gui_selectplane.py
Co-authored-by: 0penBrain <48731257+0penBrain@users.noreply.github.com>
2022-06-27 11:51:51 +02:00
Roy-043 d69888b74d Draft: Fix align working plane to DatumPlane bug 2022-06-27 10:26:59 +02:00
Uwe e8f3227191 [FEM] fix point filter initialization issue
- on opening the task dialog of existing point filter, the point value must be displayed
2022-06-27 01:07:36 +02:00
Uwe 3a86b17194 [TD] fix linker error with MSVC
patch by @wwmayer: https://forum.freecadweb.org/viewtopic.php?p=605472#p605472
many thanks!
2022-06-26 22:38:49 +02:00
sliptonic a84220cd21 Also check that the module imports correctly 2022-06-26 14:09:28 -05:00
wmayer 8acfd5bce7 TD: minor fixes:
* remove superfluous semi-colons
* if a method is declared override then the keyword virtual should be dropped
2022-06-26 15:51:43 +02:00
wmayer 175ecbc50f Draft: handle the absence of the Drawing module in the unit tests 2022-06-26 12:07:48 +02:00
Abdullah Tahiri 8ee773362e Sketcher: Fix warning not all enum handled in switch 2022-06-26 06:39:10 +02:00
Abdullah Tahiri 073bf3215c Sketcher: Constraints - add ability to generate constraint type string 2022-06-25 19:18:15 +02:00
sliptonic 1f07083d4a Merge pull request #6760 from Russ4262/fix/dressup_leadinout
Path: Fixes #6693 - Add Z and K values to arc commands
2022-06-25 12:10:48 -05:00
Abdullah Tahiri cd208c5477 Part: Geometry - Add Ellipse minor radio convenience function 2022-06-25 19:03:11 +02:00
Abdullah Tahiri 6a06f60ee3 Part: Geometry - function to get the conic axis direction 2022-06-25 19:03:11 +02:00
wmayer 7db925d991 App: fix memory leaks in Enumeration class and simplify code 2022-06-25 18:18:57 +02:00
wmayer d7313598aa CMake: disable Drawing module by default 2022-06-25 18:10:06 +02:00
wmayer 02bc430fac Draft: handle the absence of the Drawing module in the unit tests 2022-06-25 18:05:23 +02:00
wmayer 2b04b01edc cppcoreguidelines-special-member-functions
* disable move constructor and move assignment for several core classes
2022-06-25 17:46:48 +02:00
wmayer 6b6df27df8 C++ core guidelines:
* ES.87: Don’t add redundant == or != to conditions
2022-06-25 17:38:57 +02:00
sliptonic 45b9f2a7aa Fix import error if camotics not installed. 2022-06-25 10:25:08 -05:00
wmayer 7de296b60e cppcoreguidelines-pro-type-union-access
According to https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ru-pun using union for type-punning is undefined behaviour.
  See also https://en.wikipedia.org/wiki/Type_punning#Use_of_union. Replace it with std::memcpy.
2022-06-25 17:17:04 +02:00
marioalexis 14668197d1 Base: Minor changes in some Python docstrings 2022-06-25 17:12:06 +02:00
Uwe 999f3b85ee [PD] re-add accidentally removed code in commit 93525ff7 2022-06-25 16:44:44 +02:00
Uwe 1b2f0063a1 [PD] Hole initialization bugfix
- by default there is no hole head cut and therefore its parameter must be initialized as read-only (will be enably when user sets a head cut)

- also fix a typo

- also fix a UI file issue (automatically done by Qt Designer)
2022-06-25 16:36:50 +02:00
Wanderer Fan 175d2cf2dd [TD]remove build depend on DrawingWB 2022-06-25 10:22:30 -04:00
wmayer 4ec9c381d4 Part: re-add dropped parameter (93525ff7eb) 2022-06-25 16:14:14 +02:00
Kuzemko Alexsandr 0cd8fb12f3 [Part] Fix display "labelfillet" name for Chamfer and Fillet (#7083)
* Fix display "labelfillet" name for Chamfer and Fillet
* Synchronize options name with PartDesign_Chamfer. Proposed by  @Roy-043
@Roy-043 https://github.com/FreeCAD/FreeCAD/pull/7074#issuecomment-1165303970
2022-06-25 15:04:15 +02:00
andrea 93525ff7eb removed references to OCC<7 2022-06-25 14:29:24 +02:00
wmayer e9890c0798 Gui/Mod: replace several reinterpret_cast with static_cast 2022-06-25 11:36:55 +02:00
Uwe 360b4282f7 [PD] Hole dialog fixes
- when there is no profile the change of the hole cut type was not handled
- for the deprecated hole cut types it must also be possible to use custom values
2022-06-25 03:31:27 +02:00
wmayer 1aa897d450 Fem: remove some superfluous const_cast 2022-06-24 19:43:33 +02:00
wmayer 8573d9f8b2 TD: fix possible dangling pointer in QGIHighlight 2022-06-24 17:39:33 +02:00
wmayer 5234d9bc67 App: add pure virtual methods to PropertyGeometry to delegate it to the geometry of sub-classes
Following the law of Demeter add some wrapper methods to PropertyGeometry and implement them in sub-classes. As a side-effect this makes some const_cast obsolete
2022-06-24 16:15:02 +02:00
wmayer f87d9bd626 Part: [skip ci] remove superfluous const_cast 2022-06-24 16:10:09 +02:00
Wanderer Fan 9894964eb6 [TD]implement navigation styles 2022-06-24 10:03:02 -04:00
wmayer e53e231677 Gui: remove some superfluous const_cast 2022-06-24 14:48:52 +02:00
wmayer c955372ecf cppcoreguidelines-pro-type-union-access
According to https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md using union for type-punning is undefined behaviour.
 Replace it with std::memcpy
2022-06-24 14:29:50 +02:00
Yorik van Havre 393352387d Merge pull request #7071 from Roy-043/Draft-Fix-Placement-in-make_sketch
Draft: Fix Sketch Placement in make_sketch (issue #7058)
2022-06-24 13:53:33 +02:00
Yorik van Havre 830b3944db Merge pull request #7067 from Kuzma30/add_ts
Crowdin Add "new" WB to translations.
2022-06-24 13:50:43 +02:00
Uwe 15e3e86c5a [.github] next try to make bug reporting rule clear 2022-06-24 03:03:53 +02:00
Uwe b12e7a8ad6 [.github] make bug reporting rule clear 2022-06-24 03:00:42 +02:00
Benjamin Alterauge ad8bb4dc69 GeomBSplineCurve: Add interpolate without tangents
Now with description

Periodic selectable
2022-06-24 02:25:55 +02:00
mosfet80 620c273c4e Boost version <=1.60 is never used in freecad 0.20 (#7038)
* Boost version 1.60 is never used in freecad 0.20
2022-06-24 02:20:26 +02:00
0penBrain b308da5387 [BUGFIX] Gui: fix mouse Gesture navigation mode
Regression introduced by commit c23a30b
2022-06-24 01:03:53 +02:00
Ajinkya Dahale 00e7eae6f8 [Sketcher] Use more segments while drawing splines
B-Splines can have an arbitrary number of pieces. Using the same number of
segments to draw a multi-piece spline can make the curve blocky.

This commit only changes the behavior in edit-mode.
2022-06-23 14:35:33 +02:00
marioalexis ad0f1147f7 Part: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis ea79771afd Import: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis a91e32a6f4 Mesh: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis 37511553f7 PartDesign: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis d298a7101c Path: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis 51f3727d3c Sketcher: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis f78412c75b Gui: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis ccfa6cd9e5 Main: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis 89803987a1 Base: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
marioalexis 22763c9e4f App: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
Adrian Insaurralde Avalos 69932742d2 Rename FindOpenCasCade.cmake to FindOCC.cmake
To fix a warning 'name passed to `find_package_handle_standard_args` (OCC) does not match'
2022-06-22 19:19:37 -04:00
ShuffleWire 4de0e8244e Base: add Const attribute to many MatrixPy methods
multiply(), determinant(), isOrthogonal(),
submatrix(), analyze() also get the const attribute
2022-06-22 19:16:38 -04:00
wmayer a527daa4b3 Part: add Const attribute to several methods in TopoShapePy 2022-06-22 16:58:56 +02:00
sliptonic 54a4e02514 Merge pull request #7075 from sliptonic/bug/camoticsgui
[Path] Missing camoticsgui file in the CMakelists.
2022-06-22 09:03:48 -05:00
sliptonic 012fe8d9b6 Missing camoticsgui file in the CMakelists. 2022-06-22 09:02:42 -05:00
wmayer 7de8a14b37 Base: add Const attribute to MatrixPy::inverse() 2022-06-22 13:49:11 +02:00
Roy-043 256c4cd086 Draft: Fix Placement in make_sketch 2022-06-22 12:11:47 +02:00
berniev 9e2ee47b01 created clang-format 2022-06-21 21:02:20 -04:00
marioalexis 82da0065c4 Base: Add function to get Python object types for SWIG interfaces 2022-06-21 21:01:37 -04:00
luzpaz b7cc7261b8 Stylesheets: fix typos
[skip ci]
2022-06-21 20:39:01 -04:00
Chris Hennes cd32457b60 Part: Add ShapeFix.hxx to precompiled header 2022-06-21 12:59:56 -05:00
sliptonic 818a890512 Merge pull request #7065 from sliptonic/feature/outputnaming
[Path] Enable improved output naming.
2022-06-21 10:58:12 -05:00
sliptonic 86fc7298a1 UI fixes 2022-06-21 10:36:12 -05:00
Kuzemko Alexsandr 40395a0a57 Crowdin Add Material to updatets.py script and create new Material.ts 2022-06-21 17:45:25 +03:00
Kuzemko Alexsandr 166306469a Add missing file. 2022-06-21 17:35:36 +03:00
Kuzemko Alexsandr e678620cbd Crowdin Update .ts files with current source. 2022-06-21 17:31:06 +03:00
Kuzemko Alexsandr a83fc8acd1 Crowdin Add no-sort option to lupdate. 2022-06-21 17:29:22 +03:00
Kuzemko Alexsandr 4b0c125d61 Crowdin Add Inspection WB to updatets.py script 2022-06-21 17:28:40 +03:00
Kuzemko Alexsandr 5f4ea420b0 Inspection Add more translation texts. 2022-06-21 17:22:15 +03:00
wmayer b70d8d3781 Part: expose ShapeFix_FixSmallSolid to Python 2022-06-21 15:47:27 +02:00
wmayer 4c2946c8a4 Part: expose ShapeFix_FixSmallFace to Python 2022-06-21 15:47:10 +02:00
wmayer 6843a461e6 Part: expose ShapeFix_Wireframe to Python 2022-06-21 15:46:51 +02:00
wmayer bbecc3f296 Part: expose ShapeFix_SplitTool to Python 2022-06-21 15:46:27 +02:00
wmayer 8c6ffc99e3 Part: expose ShapeFix_WireVertex to Python 2022-06-21 15:46:11 +02:00
wmayer 1ee1aee10e Part: expose ShapeFix_FreeBounds to Python 2022-06-21 15:45:55 +02:00
wmayer 125d5b6360 Part: expose ShapeFix_ShapeTolerance to Python 2022-06-21 15:45:36 +02:00
wmayer a0eb2e9de7 Part: expose ShapeFix_FaceConnect to Python 2022-06-21 15:45:10 +02:00
wmayer 4b44c54cfa Part: expose ShapeFix_SplitCommonVertex to Python 2022-06-21 15:44:50 +02:00
wmayer 4d4adb932b Part: expose ShapeFix_EdgeConnect to Python 2022-06-21 15:44:30 +02:00
wmayer 74c75b86a0 Part: workaround for missing include in OCC >= 7.5 2022-06-21 15:44:12 +02:00
wmayer 6cfd7d21e8 Part: fix typos 2022-06-21 15:43:47 +02:00
wmayer 8d56879305 Part: expose ShapeFix_Solid to Python 2022-06-21 15:43:31 +02:00
wmayer 4089cbfbf2 Part: expose ShapeFix_Edge to Python 2022-06-21 15:43:13 +02:00
wmayer ac421ffd0e Part: add convenience function to convert Placement into TopLoc_Location 2022-06-21 15:42:52 +02:00
wmayer 87db9dccb5 Part: expose ShapeFix_Shape to Python 2022-06-21 15:42:31 +02:00
wmayer 94f6279a67 Part: expose ShapeFix_Wire to Python 2022-06-21 15:41:44 +02:00
wmayer da4b05fdcc Part: expose ShapeFix_Shell to Python 2022-06-21 15:39:41 +02:00
wmayer b6cd635cc1 Part: expose ShapeFix and ShapeFix_Face to Python 2022-06-21 15:39:09 +02:00
wmayer f3e941a382 Part: start to expose ShapeFix framework to Python 2022-06-21 15:34:55 +02:00
wmayer 6b2882e01f Part: support of box selection in shape builder task panel 2022-06-21 15:30:31 +02:00
wmayer 8998c9847d Points: fixes #5785: a python method to convert a Shape into a point cloud without extra dialog but parameter 2022-06-21 15:25:53 +02:00
wmayer e7a9081097 Mesh: replace boost::bind with std::bind 2022-06-21 15:23:47 +02:00
wmayer b416c42d58 Tools: add script to create snapshots in headless mode 2022-06-21 12:55:17 +02:00
wmayer 0d34449613 Gui: expose SoQtOffscreenRenderer to Python 2022-06-21 12:55:17 +02:00
wmayer 0a4488462c Mesh: reduce the use of const_cast in Mesh module 2022-06-21 12:20:37 +02:00
sliptonic 9db32a3911 Merge pull request #7056 from Kuzma30/toolbit_tr
[Path] Add localization for PathToolBit and update Path.ts
2022-06-20 17:20:32 -05:00
sliptonic e1eeabc86c Merge pull request #6637 from sliptonic/feature/camotics
[Path] Feature/camotics
2022-06-20 13:48:54 -05:00
sliptonic 8dad6cf84d Resolving bugs and rebasing for 0.21 merge 2022-06-20 13:09:09 -05:00
wmayer 35919e2a75 Test: [skip ci] test for fixed Rotation::inverse() 2022-06-20 12:39:22 +02:00
wmayer 796d722072 Path: fix warning: extra ';' inside a struct/class [-Wextra-semi] 2022-06-20 11:34:31 +02:00
marioalexis b310a3e503 Base: Fix wrong function name in RotationPy documentation. 2022-06-20 02:12:16 +02:00
Uwe 0678946103 [core] update version number
NOTE: this is purposely version 0.21, despite the release goal is 1.0
Since we issue weekly builds, people might otherwise misunderstand the version

So first when the release goal is reached, FreeCAD becomes version 1.0
2022-06-20 00:56:55 +02:00
Kuzemko Alexsandr 4ccd24fe14 [Crowdin] Add new texts for translation from Path ToolBit 2022-06-19 20:49:37 +03:00
Kuzemko Alexsandr 7b02f492fa [Path] Add localization for PathToolBit 2022-06-19 20:47:07 +03:00
Uwe e9bb9afc3b [skip CI] [Path] fix typo
I just introduced
2022-06-19 18:43:50 +02:00
Uwe 68a499574a [Sketch] remove unnecessary Boolean comparisons 2022-06-19 18:35:52 +02:00
Uwe f4891488d3 [Path] remove a unnecessary Boolean comparison 2022-06-19 18:32:54 +02:00
Uwe dbea942dda [Image] remove more unnecessary Boolean comparisons 2022-06-19 18:32:06 +02:00
Uwe 967c7fff65 [Robot] remove unnecessary Boolean comparisons 2022-06-19 18:24:36 +02:00
Uwe 7c98361447 [Meh] Core: remove unnecessary Boolean comparisons - part 2/2 2022-06-19 18:22:22 +02:00
Uwe a922605821 [Meh] Core: remove unnecessary Boolean comparisons - part 1 2022-06-19 18:12:56 +02:00
Uwe 1a346722f8 [Meh] Gui: remove unnecessary Boolean comparisons 2022-06-19 18:00:46 +02:00
Uwe 4a052dc34a [Path] cleanup formatting of Area.cpp/.h
- MSVC always kind of "stumbled" over this file, therefore it was on my ToDo lost to let run MSVC's syntax unification over this file

- still many MSVC warnings, but now some less
2022-06-19 17:49:08 +02:00
sliptonic f94aecad70 Working on simulation
working on camotics with multiple file output and tests
2022-06-19 10:47:25 -05:00
Uwe 1adff3f917 [Path] remove unnecessary Boolean comparisons 2022-06-19 17:28:08 +02:00
Uwe b7097e4bd5 [Image] remove unnecessary Boolean comparisons 2022-06-19 17:13:25 +02:00
Uwe 28698a41e3 [Point] remove unnecessary Boolean comparisons 2022-06-19 17:10:55 +02:00
Uwe db9aeefea1 [Reverse Engineering] remove unnecessary Boolean comparisons 2022-06-19 17:07:02 +02:00
Uwe 9fcb98d9c6 Revert "remove unused python<3.6 code"
This reverts commit 0a6d271121.
2022-06-19 16:23:13 +02:00
Christoph Moench-Tegeder 60e419068b fix Expressions assignment for FreeBSD
Just like Apple, FreeBSD uses clang as it's main compiler, and thus
runs afoul of the same problem in src/App/PropertyExpressionEngine.cpp
like Apple (issue #5281): "error: no viable overloaded '='".
Extend the fix from #5281 for the BSDs (check macro FC_OS_BSD) -
at least OpenBSD uses clang, too (maybe this check should be reworked
to test for clang, but I can't test on Apple, so let's keep this fix
minimalistic).

References: #5281
2022-06-19 16:14:10 +02:00
marioalexis f64916dc5e Base: Set angle in Rotation::inverse function 2022-06-19 15:44:05 +02:00
andrea 0a6d271121 remove unused python<3.6 code 2022-06-19 15:33:44 +02:00
Uwe a4a8acd445 [TD] remove unnecessary Boolean comparisons 2022-06-19 15:20:03 +02:00
Uwe bbcc8b2c5c [Part] remove unnecessary Boolean comparisons 2022-06-19 15:19:13 +02:00
Uwe 063fd56f5f [App] remove unnecessary Boolean comparisons 2022-06-19 15:18:34 +02:00
Uwe 6b09da9ab6 [Base] remove unnecessary Boolean comparisons 2022-06-19 15:17:50 +02:00
Uwe c23a30b916 [Gui] remove unnecessary Boolean comparisons 2022-06-19 15:17:01 +02:00
Uwe 8e253cb4c8 [FEM] fix a variable casting
- reported by MSVC not to cast a float to a double but as double directly

- also remove some superfluous Boolean comparisons
2022-06-19 15:15:18 +02:00
Russell Johnson 8edc9b142d Path: Fixes #6693 - Add missing feed rate for G1 layer command 2022-06-18 20:57:54 -05:00
Russell Johnson 39abd5433e Path: Fixes #6693 - Add Z and K values to arc commands 2022-06-18 20:57:53 -05:00
sliptonic 642b261fb0 icon 2022-06-18 16:34:53 -05:00
sliptonic 64fe6c269a Fixes for output naming in path sanity 2022-06-18 16:34:53 -05:00
sliptonic 60cc7cfcf1 fix output elements 2022-06-18 16:34:53 -05:00
sliptonic 97a52a991a Improve the output splitting
Add ability to substitute tool name, op name, or fixture name in filename
Add unit tests
2022-06-18 16:34:52 -05:00
Wanderer Fan fb1a7af360 [TD]fix ProjGroup view spacing 2022-06-18 14:34:28 -04:00
Wanderer Fan 4b47d38eb6 [TD]fix dimension update on scale change 2022-06-18 14:34:28 -04:00
Uwe 81be38ea8d [Gui] View.cfg: fix typo 2022-06-17 01:30:11 +02:00
Uwe 08d1e382e1 [Gui] Add more general color settings to Preference Pack
- also sort the file entries
2022-06-17 01:23:09 +02:00
Uwe 5b6ba058a7 [Gui] Add more saving view data in Preference Pack
- it was reported that the user-visible settings like the NaviCube size etc. cannot be saved via a preferences pack
2022-06-17 01:21:28 +02:00
Chris Hennes 7814faa6fd Gui: Add saving view data in Preference Pack 2022-06-16 11:48:47 -05:00
wmayer 6c89e6dc73 Spreadsheet: add tests for merging cells and binding cells 2022-06-16 15:05:43 +02:00
Uwe 453abff2fe update screenshot in Readme
update screenshot to FC 0.20
2022-06-16 14:19:45 +02:00
Uwe a1a4b89ba8 Update Readme to FreeCAD 0.20 2022-06-16 13:05:53 +02:00
wmayer 7e79686986 Part: [skip ci] add tests for ruled surfaces 2022-06-16 11:48:27 +02:00
wmayer e89ebba736 plugin: do not exclude widget plugins from tarball 2022-06-15 12:23:48 +02:00
wmayer 79df90a45c Mesh: fixes #7018: 3mf created with FreeCAD cannot be loaded with PrusaSlicer 2022-06-14 18:55:05 +02:00
TotalCaesar659 d8ca3093d0 Update URL to HTTPS 2022-06-14 14:13:44 +02:00
wmayer b85e9b1fe4 Mesh: fixes #6902: Conda test errors 2022-06-14 11:32:07 +02:00
Uwe ea7efbf96b [Win installer] update information
- also refine a script
2022-06-14 03:43:04 +02:00
wmayer 68e337670e Fem: remove string from translation 2022-06-14 01:43:45 +02:00
wmayer 3158be46ad Fem: added signals and slots to notify when first function is added 2022-06-14 01:38:55 +02:00
Uwe 02b66ca461 [Win installer] refine deletion script
- remove more unnecessary files for the installer
2022-06-14 01:22:20 +02:00
Uwe 74c2ad4bf0 [FEM] point filter: use a LineEdit to output value
- that one copy the result to the clipboard
- also fix a typo
2022-06-14 01:21:17 +02:00
Uwe 522c91ce79 [FEM] next try to proper revert 2022-06-14 00:58:08 +02:00
Uwe e8d65c22d6 Revert "Fixing principal stress plots part 2"
This reverts commit 166eee5eed.
2022-06-14 00:40:51 +02:00
FEA-eng 166eee5eed Fixing principal stress plots part 2
https://forum.freecadweb.org/viewtopic.php?f=18&t=69385
2022-06-13 19:52:16 +02:00
FEA-eng 3af54a7dda Fixing principal stress plots part 1
https://forum.freecadweb.org/viewtopic.php?f=18&t=69385
2022-06-13 19:51:53 +02:00
wmayer 7fa294fd7a Fem: for PointMarker and DataMarker use the internal name instead of label, in customEvent() do not expect a fix name 2022-06-13 17:37:26 +02:00
wmayer 7400b11870 Fem: in FEM_PostFilterLinearizedStresses command do not use a hard-coded object name but that of the selected FemPostDataAlongLineFilter 2022-06-13 17:08:58 +02:00
wmayer 915371aa70 Fem: do not use the Label property but the internal name to access an FEM post object via Python 2022-06-13 17:01:38 +02:00
wmayer 7b225789da Fem: do not access the active document but the document the FEM post object is part of 2022-06-13 16:46:15 +02:00
wmayer c0cccf7f7e Gui: add overloaded version of cmdAppDocument and cmdGuiDocument() that has a string as first parameter 2022-06-13 15:21:55 +02:00
Chris Hennes 5219718eb0 GUI: Preliminary support for HiDPI splashscreen 2022-06-13 15:19:40 +02:00
marioalexis 4b1004b33a Base: Improve docstrings in BoundBoxPy.xml 2022-06-13 08:42:40 -04:00
wmayer 9aa14b36a3 Fem: use WeakPtrT classes instead of raw pointers to avoid possible dangling pointers and to avoid undefined behaviour if a wrong static_cast is performed 2022-06-13 14:21:18 +02:00
wmayer 876ef07480 Gui: implement '*' operator for weak pointer classes 2022-06-13 13:52:34 +02:00
wmayer 9e68e5f290 App: implement '*' operator for weak pointer classes 2022-06-13 13:52:21 +02:00
wmayer 27a36156f6 Fem: improve TaskPostDataAtPoint:
* refactor TaskPostDataAtPoint::on_Field_activated()
* show results in a label instead of message box to reduce clicks
* in output window also print field and position as the pure values are useless
2022-06-13 12:31:37 +02:00
wmayer 09f1b14cc9 Fem: remove several superfluous casts 2022-06-13 11:14:29 +02:00
wmayer e0487b62a6 Gui: [skip ci] set Std_LinkMakeRelative as WhatsThis name 2022-06-13 11:01:36 +02:00
wmayer 741fdc53c7 Base: unset flag to skip leading whitespaces when copying a file 2022-06-13 08:43:58 +02:00
Uwe 832f181ec0 [Gui] make What's This? work for sublinks 2022-06-13 02:42:37 +02:00
Uwe 2a8f85d95c [FEM] make post filter Ui std::unique_ptr 2022-06-13 01:59:46 +02:00
Uwe 227e568b4f [FEM] cut and clip filter: handle new functions
- on adding a new function, it should be used
- there is still a bug, see the added FIXME
2022-06-13 01:42:58 +02:00
Uwe f0e735ed33 [FEM] line filter resolution fix
a resolution of zero is senseless, thus set minimum to 1
2022-06-12 23:09:33 +02:00
Uwe ebd1afc5d9 [FEM] fix 2 crashes with line and scalar filter
- same crash origin like the crash fixed earlier today: https://github.com/FreeCAD/FreeCAD/commit/7b0b83a2e4
2022-06-12 22:18:59 +02:00
wmayer 9065058265 plugin: [skip ci] copy sizeHint handling to QuantitySpinBox implementation in QtDesigner plugin 2022-06-12 21:56:08 +02:00
wmayer 0a79760745 Gui: set a minimum width for quantity spin boxes in FEM dialogs to ignore the results of (minimum)sizeHint() 2022-06-12 20:25:40 +02:00
wmayer ac3390de12 Gui: add function to determine size that a quantity spin box would need to display a certain text 2022-06-12 20:01:41 +02:00
Kuzemko Alexsandr c2cfccf268 Crowdin Add some menu text for translation. 2022-06-12 13:02:41 -04:00
Uwe 505de3215b [GUI] fix screenshot watermark
as reported here: https://forum.freecadweb.org/viewtopic.php?p=601651#p601651
2022-06-12 18:39:14 +02:00
Uwe 4f91499ada [FEM] line filter, resolution tweak
- disable keyboard tracking for the resolution
2022-06-12 18:22:24 +02:00
Uwe 4813e30703 [FEM] fix line filter resolution
- when the resolution changes, the data must be refreshed for visualization and the plot
2022-06-12 18:18:26 +02:00
Uwe 8bbf9b8347 [Main] change URL
as reported in the forum: https://forum.freecadweb.org/viewtopic.php?p=601657#p601657
we should use our new URL
2022-06-12 18:12:28 +02:00
Uwe 3528c626e7 [FEM] fix plots of line filter
- when the line geometry changed, the axis data must be refreshed to get correct plots
2022-06-12 17:24:41 +02:00
Uwe a06cc956c5 [FEM] function dialogs size fix
- as suggested in https://github.com/FreeCAD/FreeCAD/commit/d4c180e9538d570a05849b22d4acc8f8624d0878#r75908012
the labels should have maximum size policy
2022-06-12 16:52:41 +02:00
Uwe e2856395a3 [FEM] remove hardcoding of spinbox sizes 2022-06-12 16:40:41 +02:00
Uwe a3a97d7b5e [FEM] fixes for line filter
- on changing a point coordinate, either by clicking a point or by changing the spinbox in the dialog, the color bar must be refreshed and data must be evaluated for all fields along the new line
2022-06-12 16:35:08 +02:00
Uwe 0c43dab796 [FEM] function dialogs fix
- keyboard tracking must be turned off
2022-06-12 16:25:02 +02:00
Uwe 298fb8983d [FEM] fix along line dialog
- as suggested in https://github.com/FreeCAD/FreeCAD/commit/d4c180e9538d570a05849b22d4acc8f8624d0878#r75908012
- keyboard tracking must be turned off
2022-06-12 16:17:21 +02:00
Zheng, Lei 75546946db Spreadsheet: fix border rendering for merged cells 2022-06-12 16:11:59 +02:00
Zheng, Lei 4d19e611f8 Spreadsheet: fix binding of merged cells 2022-06-12 16:11:59 +02:00
Zheng, Lei 47a5a6302e Spreadsheet: replace obsolete href with hiddenref in binding 2022-06-12 16:11:59 +02:00
Uwe 7b0b83a2e4 [FEM] fix crash with data point filter
- when the filter is upon another filter that e.g. clipped all data, we cannot access data
2022-06-12 14:56:54 +02:00
wmayer d81b016b2a PD: several fixes of shape binder:
* add action to context-menu to remove an element
* use an exclusive button group to avoid to have several buttons pressed at the same time
* allow to completely clear the support
* when pressing OK/Cancel then operate on the document the shape binder is part of (which isn't necessarily the active document)
* remove obsolete parameter from ViewProviderShapeBinder::highlightReferences()
2022-06-12 14:03:42 +02:00
wmayer 5a432fe9ac PD: allow to clear the shape when nullifying the Support property 2022-06-12 14:01:19 +02:00
Zheng, Lei e6a6d838a6 Spreadsheet: fix range selection 2022-06-12 13:51:09 +02:00
Yorik van Havre f3a8edcb5e Merge pull request #7004 from Roy-043/Arch-ArchSectionPlane-always-showed-plan-symbols-of-windows
Arch: ArchSectionPlane always showed plan symbols of windows
2022-06-12 11:58:40 +02:00
Yorik van Havre baa1105a53 Merged crowdin translations 2022-06-12 11:56:37 +02:00
Uwe 6c1c63cffe [FEM] point filter: fix data display for coordinate change
- not only by clicking the data must be shown, also by changing a single coordinate value in the dialog.
2022-06-12 04:51:19 +02:00
Uwe 9ef72fcd06 [FEM] fix color bar handling of point filter
- recoloring the gradient bar for a single point is senseless. One therefore already got dozens of errors that max = min in the console. Therefore don't recolor for point filters
2022-06-12 04:02:11 +02:00
Uwe 7521cfc7a0 [FEM] fix point filter output
fixes #7008:

- the point data must be read also when the center changed
- when the dialog is called it has only the value for the current field, thus recompute the feature to fill all fields with data
- on clicking on a mesh point display the value at the clicked position
- due to the object's recomputation at the start, a complete recomputation (for the whole pipeline) is needed on closing the dialog
2022-06-12 03:34:02 +02:00
Uwe 6d23205704 [FEM] fix display of point filter
- results of 1e8 or 1e-7 in fixed notation are almost unreadable, therefore use scientific notation if necessary
2022-06-12 01:05:26 +02:00
wmayer 30706f4d0f PD: allow to set object in shape binder dialog by typing its name 2022-06-12 00:38:48 +02:00
Uwe 6a877f7e29 [FEM] point filter: fix initialization issue
- we cannot assume to have a geometry at position (0, 0, 1) this initialize at (0, 0, 0)
- also don't hardcode the unit in the UI file

- also fix wrong property description
- property "Radius" is not used in the code and it seems it is only there as copy paste bug once the point filter was implemented. However close to a release, keep the property and just mention it is unused.
2022-06-12 00:25:58 +02:00
wmayer 007a5b351a PD: use WeakPtr to avoid any possible dangling pointers 2022-06-11 23:37:33 +02:00
VM4Dim 9010b88b22 Fix for non-Latin Group name in Tree View 2022-06-11 15:24:25 -04:00
wmayer a106f55ebe PD: show object label instead of internal name in shape binder dialog 2022-06-11 21:00:15 +02:00
wmayer b8434f2ddc Test: [skip ci] extend test for issue #6949 2022-06-11 16:10:09 +02:00
0penBrain 6e587d130d Expression: add unit test for issue #6948 2022-06-11 15:59:06 +02:00
0penBrain 38ec63cba1 [Bugfix] Expression: fix precedence+associativity management in parenthesis removal
Fixes #6948
2022-06-11 15:59:06 +02:00
wmayer fbb5555f27 Part: do not expect a face to be infinite if meshing it has failed
See https://forum.freecadweb.org/viewtopic.php?p=601240#p601240
2022-06-11 13:01:15 +02:00
Uwe 9b5aabe458 [FEM] fix unit handling of filter functions
- the function properties use already units but the dialogs were unitless
2022-06-11 04:54:51 +02:00
Uwe 9dc93b8f99 [skip CI] [FEM] sort UI file
I forgot to use our UI sorter
2022-06-11 04:46:21 +02:00
Uwe c8337118ba [skip CI] [FEM] whitespace and comments to keep overview 2022-06-11 04:28:21 +02:00
Uwe d13ecc1efa [Path] fix compilation with precompiled headers
- also sort includes to keep overview
2022-06-11 00:56:00 +02:00
Wanderer Fan 1b65b3f600 [TD]fix icons for dark schemes 2022-06-10 17:49:43 -04:00
Roy-043 f89f032231 Arch: ArchSectionPlane always showed plan symbols of windows 2022-06-10 22:32:45 +02:00
sliptonic 083a27dc68 Merge pull request #6886 from younghang/master
Path: Fix PointProjectionFailed
2022-06-10 09:06:38 -05:00
Uwe d4c180e953 [FEM] fix unit handling of line filter
- in contrary to other filters the properties have no unit handling
(there are several bugs in line filter and to fix them, unit handling is necessary)
2022-06-10 14:17:42 +02:00
Uwe fdaca02994 [skip CI] [FEM] fix initialization mistake
- initial point should be (0, 0, 0)
  (mistake introduced by me today)
2022-06-10 14:11:42 +02:00
Uwe 4c3c23776d [FEM] fix illegal storage access in point filter
- occurred when changing Field to "None"

- also remove doubled and unused code and add a blank line to separate the different filters in the code better
2022-06-10 13:16:23 +02:00
Yorik van Havre 19ffd1ca94 Merged crowdin translations 2022-06-10 11:03:57 +02:00
Yorik van Havre fa9c78611e Updated ts files 2022-06-10 10:29:18 +02:00
Uwe 825d95314e [FEM] fix unit handling of point result filter
- the App part used already units but the dialog worked unitless. This is error-prone and confusing. Therefore use unit widgets in the dialog.
- also fix issue that unit was not reset (after e.g. a temperature maybe a unitless strain should be shown)
2022-06-10 04:20:25 +02:00
Uwe 10c6d6eabf [skip CI] [PD] fix typo 2022-06-10 03:39:04 +02:00
Chris Hennes b54b3e6e32 Addon Manager: Fix bug in macro git repo 2022-06-09 19:50:05 -05:00
Uwe 6bb6bb4d24 [FEM] fix unit settings of data point filter 2022-06-10 02:42:17 +02:00
Uwe 8fb5ce3c43 [FEM] allow to copy and edit result data
- at the moment you cannot get the result data, for example to make your own plot. Also for the line you might want to have unequal x-steps etc. Especially for the data point filter not getting the data actually makes the tool quite useless.
- therefore set the properties to output
2022-06-10 02:41:08 +02:00
Uwe 43a14ab4df [FEM] fix result point filter upon line filter
having a point filter on a line filter is valid and useful, was maybe just forgotten once the line filter was added
2022-06-10 01:43:22 +02:00
Uwe dd00c46a8c [FEM] fix issue that all plot windows had the same name
- they all had the name "figure 1"
- thus make the name unique and this way also enable to have several plots open displaying different result types (for the line filter)
2022-06-10 00:55:02 +02:00
marioalexis 10edc03ec1 App: Clean up code in PropertyContainerPyImp.cpp 2022-06-09 18:46:41 -04:00
marioalexis 53e02bc851 App: Improve docstrings in PropertyContainerPy.xml 2022-06-09 18:46:41 -04:00
Uwe d17954276c [FEM] fix detached plot (#6998)
* [FEM] fix detached plot

the stress linearization plot is at the moment detached from FreeCAD's main window.
This PR fixes it the same way as in https://github.com/FreeCAD/FreeCAD/commit/920e8e046
2022-06-10 00:34:05 +02:00
Uwe c4fec57368 [FEM] fix linear filter plot (#6999)
* [FEM] fix linear filter plot

the plot one can create from within the linear filter is at the moment detached from FreeCAD's main window.
This PR fixes it the same way as in https://github.com/FreeCAD/FreeCAD/commit/920e8e046
2022-06-10 00:33:27 +02:00
marioalexis d8bf4dfeb9 App: Improve docstrings in MetadataPy.xml and fix memory leak 2022-06-09 17:48:45 -04:00
wmayer 7225e5f0ba App: issue #6892: FreeCAD fails to start 2022-06-09 15:40:37 +02:00
Yorik van Havre 68e8c19aaf Merged crowdin translations 2022-06-09 13:40:35 +02:00
wmayer 8d5a957eb0 Gui: use expresion 'keyboard shortcut' to avoid incorrect translation 2022-06-09 13:15:41 +02:00
wmayer e5fb5a6f27 Mesh: [skip ci] improve German translation 2022-06-09 12:56:43 +02:00
wmayer ecb1b3c3cc ReverseEngineering: [skip ci] improve German translation 2022-06-09 12:33:12 +02:00
wmayer 9a4ab21f2b FEM: improve German translation 2022-06-09 12:27:43 +02:00
Zheng Lei 9d7b7af48c Spreadsheet: fix range checking (#6997)
* App: add option to normalize a Range

- To make sure the range starts from top left and ends with bottom right
corner.
- Default is to not normalize on construction for backward compatibility.
-  fix range checking in range binding
2022-06-09 12:20:08 +02:00
wmayer 28c269cc5f Gui: improve German translation 2022-06-09 12:15:29 +02:00
Uwe 0f9ea612b6 [Spreadsheet] uniform and polish wording of binding feature 2022-06-09 02:14:14 +02:00
marioalexis 4148a33d15 Gui: Improve docstrings in AxisOriginPy.xml 2022-06-08 20:20:57 +02:00
marioalexis d7d22b1e7e App: Improve docstrings in GeoFeaturePy.xml 2022-06-08 19:20:04 +02:00
Zheng Lei 5864e17d9d Spreadsheet: improve range binding feature (#6995)
* Spreadsheet: improve range binding feature
2022-06-08 19:19:41 +02:00
0penBrain 920e8e0469 [FEM] Implement a better dialog layout management for histogram (#6989)
* [FEM] Implement a better dialog layout management for histogram
2022-06-08 16:51:01 +02:00
Chris Hennes c9cffae11d Sketcher: Tweak pluralization of DoF 2022-06-08 09:16:48 -05:00
Yorik van Havre c143d91978 Merge pull request #6991 from 0penBrain/draftGrid
Draft: fix grid spacing default initialization
2022-06-08 13:22:45 +02:00
wmayer f401cbe832 Part: in BRepOffsetAPI_MakeOffsetFix::MakeWire also consider the generated edges of the vertexes of the input shape 2022-06-08 13:02:07 +02:00
Yorik van Havre 2e4dcfc22a Generated ts files 2022-06-08 12:32:59 +02:00
Yorik van Havre b06f247f9f Merged crowdin translations 2022-06-08 12:28:54 +02:00
0penBrain e05e9a7247 Draft: fix grid spacing default initialization 2022-06-08 12:20:06 +02:00
Uwe 5792c502bf [TD] further dialog refinements to fix vertical spacing 2022-06-08 02:12:19 +02:00
Uwe ef1a835f4f [TD] fix dialog height settings 2022-06-08 02:05:44 +02:00
Uwe 18eb44d120 [TD] fix dialog height setting 2022-06-08 01:52:45 +02:00
Wanderer Fan d0323e13c1 [TD]add missing vertical spacer to ui 2022-06-07 19:18:39 -04:00
Wanderer Fan f31544dca8 [TD]missing vertical spacer in ui 2022-06-07 19:18:39 -04:00
Uwe f256e3caf4 [Gui] attempt to improve NaviCube rendering
When the NaviCube is relatively small, it looks clumsy on some screens. This PR tries to improve that.
2022-06-08 01:06:15 +02:00
marioalexis 0c6c3e5211 Base: Improve docstrings in PersistencePy.xml 2022-06-08 00:52:19 +02:00
Chris Hennes 9570d88a39 FEM: Enable translation of plot labels 2022-06-07 13:44:01 -05:00
Chris Hennes 6449e1bcf7 FEM: Enable translation of axis label 2022-06-07 13:10:42 -05:00
Chris Hennes 47bb1408da GUI: Add Vtk info to copied About data 2022-06-07 12:51:51 -05:00
wmayer 77627bbc23 Gui: add SoColorBarLabel as workaround for a Coin3D bug 2022-06-07 19:42:04 +02:00
Yorik van Havre b9b21ddac5 Merged crowdin translations 2022-06-07 13:34:53 +02:00
Yorik van Havre 242083bbf7 Merge pull request #6984 from Kuzma30/update_ts
Crowdin Run update.ts with latest source code.
2022-06-07 12:29:38 +02:00
Kuzemko Alexsandr eff8ecaafc Crowdin Run update.ts with latest source code. 2022-06-07 13:15:44 +03:00
wmayer 80bdc3f960 Gui: don't use cached value of color bar width if ratio of the canvas is less than 1.0 2022-06-07 11:30:00 +02:00
Wanderer Fan b4489422a5 [TD]abort dimensioning of spline edge 2022-06-06 18:47:51 -04:00
Wanderer Fan 8349a78dde [TD]fix icon in dialog 2022-06-06 18:47:51 -04:00
Chris Hennes fd47f2253a Draft: Fix menu text for Select Plane 2022-06-06 12:12:08 -05:00
wmayer 3cccd4d69e Gui: cache color bar width to avoid to compute it for every resize of the canvas 2022-06-06 19:11:00 +02:00
Kuzemko Alexsandr 721f253c59 Crowdin Update TechDraw.ts 2022-06-06 13:08:02 -04:00
Kuzemko Alexsandr 29cc754cfd [TD] Add ability to translate for some tooltip text. Fix incorrect use of tr(variable). 2022-06-06 13:08:02 -04:00
Chris Hennes af811b34b3 Addon Manager: Additional diagnostics for Macro updates 2022-06-06 11:46:56 -05:00
sliptonic 07422d2abe Merge pull request #6978 from sliptonic/bug/ghostpath
zero out Job.Path property if it exists
2022-06-06 11:43:13 -05:00
sliptonic 6462cdf231 zero out Job.Path property if it exists 2022-06-06 11:40:01 -05:00
Uwe 9156d591c9 [FEM] fix subsequent histogram plot call
fixes #6975
2022-06-06 18:26:18 +02:00
Uwe 4223e5d84d [skip CI] [Spreadsheet] change misleading word in dialog 2022-06-06 01:26:29 +02:00
Uwe 7955c0dfac [Spreadsheet] dialog fixes
- fixes to tooltips
- add 2 labels to make the dialog logic more clear
- remove non-functional help button
2022-06-06 00:46:42 +02:00
Wanderer Fan 681d961254 [TD]fix updating of shared view 2022-06-05 09:33:02 -04:00
Uwe 332cb9ec2f [FEM] fix wrong error message about comments
- fixes an annoying warning (that is output as error) about unused COMMENT
2022-06-05 13:42:41 +02:00
Uwe 34300c600f [FEM] add missing parser handling of '^' character (#6966)
* [FEM] add missing parser handling of '^' character

- it is common to use equations like "x^2" but one currently get only an error
- this PR fixes this by adding parsing support for the '^' character as power function

This way is it now also possible to calculate a root by e.g. "x^(0.5).
2022-06-05 13:13:49 +02:00
Kuzemko Alexsandr f7c64c7322 Crowdin Update Fem.ts 2022-06-05 12:38:12 +02:00
Uwe 7e638a624e [FEM] add missing tooltip
- should clarify the action of the button properly
2022-06-05 00:25:20 +02:00
Uwe b5b5375fe4 [FEM] result dialog: handle max shear stress
- max shear stress is supported but could not use in the Calculate section
- also sort the UI file with our sorting script
2022-06-05 00:12:51 +02:00
Uwe 23d65cc9f2 Merge branch 'master' of github.com:FreeCAD/FreeCAD 2022-06-04 22:42:13 +02:00
Uwe 75a8998432 [FEM] fix button text
- looking at the Git log this button never had a plot functionality
- for the discussion see: https://forum.freecadweb.org/viewtopic.php?f=18&t=69189
2022-06-04 22:41:58 +02:00
Ajinkya Dahale 6e97e9570c [Sketcher] Add missing newline 2022-06-04 22:35:55 +02:00
Kuzemko Alexsandr 27e3f3c153 Crowdin Update .ts after fixing script. 2022-06-04 15:09:19 -04:00
Kuzemko Alexsandr a42e1b0223 Crowdin Add full Part directory back to search path. 2022-06-04 15:09:19 -04:00
Kuzemko Alexsandr 176cf0d144 Part: Reformat JoinDeatures by Black, delete some comments. Reformat commented code too.
Now it proper recognize by lupdate.
2022-06-04 15:09:19 -04:00
Uwe 4d7e550d97 [FEM] fix results dialog equation input
- add missing tooltip and this way remove cryptic default input of the field
- since the field expects plain text, use a QPlainTextEdit
2022-06-04 19:58:31 +02:00
Uwe 3fe354718c [FEM] describe the tress variables
- there was no info what P1, P2 and P3 meant
- also rearrange to consume save horizontal space (was too wide on small screens)
2022-06-04 19:18:13 +02:00
Uwe 8567ef1849 [skip CI] [FEM] change strings to be consistent with the dialog 2022-06-04 19:06:14 +02:00
marioalexis 67c506d39e Base: Improve docstrings in VectorPy.xml 2022-06-04 15:39:05 +02:00
wmayer 9c8b21f5f4 Web: update browser commands after loading page 2022-06-04 13:21:41 +02:00
wmayer f37574e809 Base: raise TypeError if Vector is multiplied with unsupported type 2022-06-04 13:21:04 +02:00
wmayer 0d6b5b7f30 Base: use const char* 2022-06-04 13:20:07 +02:00
wmayer f7f85464a3 Base: include header in PCH 2022-06-04 13:18:08 +02:00
wmayer 31047be9fb Base: improve initialization according to cpp core guidelines 2022-06-04 13:17:27 +02:00
wmayer ca9355b5cb Base: remove redundant void 2022-06-04 13:14:55 +02:00
wmayer fc7f3f4e3d Base: avoid const_cast in FileInfo 2022-06-04 13:13:36 +02:00
Uwe 704feadc7c [skip CI] [FEM] fix typos 2022-06-04 01:33:34 +02:00
Uwe e41879c6ea [FEM] don't block FC by histogram plot window
fixes #6959
2022-06-04 01:28:55 +02:00
Wanderer Fan 2b0dd54fe7 [TD]fix preference file handling 2022-06-03 18:35:13 -04:00
Chris Hennes d73f9e3762 FEM: Add translation calls to task_result_mechanical.py 2022-06-03 11:42:52 -05:00
Uwe 134fa8b7ea [FEM] use proper histogram titles
- use for the histogram titles the same as in the CCX dialog and not our internal abbreviations
- in the CCX dialog don't use the term PEEQ but the common wording that also gives the user the info what this is about
2022-06-03 13:09:32 +02:00
Yorik van Havre e8f1bde367 Merged crowdin translations 2022-06-03 11:26:35 +02:00
Chris Hennes 2d32de3cd2 FEM: Tweak translatability of PEEQ 2022-06-02 16:26:05 -05:00
Wanderer Fan 56d289997c [TD]fix Dimension/Balloon movement 2022-06-02 16:33:25 -04:00
Chris Hennes 4dab407fbe Tools: Manually search for translatable files 2022-06-02 14:58:44 -05:00
Chris Hennes 34502193a2 i18n: Update TS files to ensure Python files are included 2022-06-02 14:57:49 -05:00
Chris Hennes d540de8bee i18n: TS files generated by lupdate 6.4.0dev 2022-06-02 13:41:37 -05:00
Chris Hennes acfbc72f50 Tools: Fix issues with updatets.py 2022-06-02 13:37:28 -05:00
Chris Hennes 3c1e446c2f Addon Manager: Don't translate placeholder text 2022-06-02 12:51:41 -05:00
Chris Hennes 2d5400f923 Sketcher: Fix typo in tooltip 2022-06-02 12:47:30 -05:00
Chris Hennes be16e1f52b Sketcher: Tweak tooltip language 2022-06-02 12:44:37 -05:00
Chris Hennes be8a4037db FEM: Fix typo 2022-06-02 10:49:55 -05:00
Wanderer Fan 977127012e [TD]fix misleading error messages 2022-06-02 11:39:21 -04:00
Chris Hennes 89432a969d TD: Set symbols to be non-translatable 2022-06-02 10:36:46 -05:00
Chris Hennes 7b204c01db Gui: Fix typo 2022-06-02 10:29:14 -05:00
marioalexis ee4f4e8cb7 Base: Improve docstrings in CoordinateSystemPy.xml 2022-06-02 16:26:31 +02:00
marioalexis 297e3520ec Base: Improve docstrings in TypePy.xml 2022-06-02 16:25:55 +02:00
Wanderer Fan 8891394d5a [TD]fix Rotation not applied 2022-06-02 09:09:53 -04:00
Wanderer Fan d223d4362c [TD]fix double draw on position change 2022-06-02 09:09:53 -04:00
Chris Hennes 213bf1ec61 Tools: Add Windows and Qt6 support to updatets.py 2022-06-01 21:30:27 -05:00
Chris Hennes d860c4bb2d PD: Fix w[z] plot in ShaftWizard 2022-06-01 19:48:42 -04:00
luz paz a0c0b2616c Fix various typos 2022-06-01 18:03:40 -04:00
Chris Hennes 07e38636b9 Addon Manager: Fix bug with updates being counted wrong 2022-06-01 15:01:38 -05:00
Chris Hennes a4b2bf584d Gui: Fix display of tooltips for GroupCommand
Fixes https://github.com/FreeCAD/FreeCAD-translations/issues/88 and https://github.com/FreeCAD/FreeCAD-translations/issues/72
2022-06-01 14:21:17 -05:00
Kuzemko Alexsandr 477eed10a4 [TD] Fix incorrect using of QT_TRANSLATE_NOOP in setText 2022-06-01 13:41:00 -04:00
Uwe 9946a3916e [FEM] TaskPostDataAtPoint: add missing support for electrostatics
- also update units to SI
2022-06-01 17:42:22 +02:00
Kuzemko Alexsandr a67701b85b Crowdin Add missing menu text for translation 2022-06-01 11:12:51 -04:00
Uwe 2de25dd04e [PD] fix Shaft wizard
- the functionality is now in FC's core, for more info see: https://forum.freecadweb.org/viewtopic.php?p=599044#p599044
and following
2022-06-01 16:13:09 +02:00
Kuzemko Alexsandr 3f04bf7b4d [TD] Add text to translate
This will fix https://github.com/FreeCAD/FreeCAD-translations/issues/47
2022-06-01 13:04:47 +02:00
wmayer 8c123bad50 App: add default macro directory to sys.path 2022-06-01 11:21:51 +02:00
Uwe eda43a2ef9 [Win installer] register all FC-specific file types
- to be able to get a clean system when uninstalling FC
2022-06-01 04:41:23 +02:00
Uwe 81d6401455 [Win installer] update website 2022-06-01 04:37:15 +02:00
Chris Hennes 5542bc9970 Addon Manager: Remove unnecessary translations 2022-05-31 20:35:10 -05:00
Chris Hennes 3dfb51d3ee Addon Manager: Expose pref page name to translate 2022-05-31 15:33:53 -05:00
marioalexis 79a5cde3b5 Base: Fix bad parse argument in AxisPyImp.cpp 2022-05-31 12:55:54 -04:00
Chris Hennes 33556d8a56 Part: Change _translate to translate 2022-05-31 10:05:44 -05:00
Chris Hennes b8952aaeb8 Image: Change _translate to translate 2022-05-31 10:05:22 -05:00
Kuzemko Alexsandr 819cfd7a11 [TD] Fix problem with translation (add TechDraw_ to context)
This will fix https://github.com/FreeCAD/FreeCAD-translations/issues 145-147
2022-05-31 09:30:48 -04:00
Yorik van Havre d447d75882 Merged crowdin translations 2022-05-31 13:31:52 +02:00
Kuzemko Alexsandr d920a5bf4d [Mesh] Add ability to translate
This fix https://github.com/FreeCAD/FreeCAD-translations/issues/53
2022-05-31 12:01:02 +02:00
marioalexis 35c872d4f2 Base: Improve docstrings in MatrixPy.xml 2022-05-31 11:48:04 +02:00
marioalexis 98cb5d50af Base: Fix undefined behaviour in row/col functions and code clean up 2022-05-31 11:48:04 +02:00
Kuzemko Alexsandr 62f65e12e2 Part: Change contex from AttachmentEditor to Part_EditAttachment
Add menu text "Create a copy" to translation
This may fix https://github.com/FreeCAD/FreeCAD-translations/issues/64
2022-05-31 11:25:44 +02:00
Chris Hennes f7b9a70ee5 Addon Manager: Build in error-checking in developer mode 2022-05-30 20:06:20 -05:00
Benjamin Alterauge 03f3852617 List all available test units, if none is selected.
From the command line (FreeCADCmd) only which not need the GUI.

A better description

Grammatically improvement

Use PrintMessage
2022-05-31 02:03:11 +02:00
Uwe 537acfdddd [Gui] code documentation of color bar 2022-05-31 01:59:54 +02:00
Chris Hennes 307cb3cda8 Gui: Check for Snap and add details to About 2022-05-30 13:19:02 -05:00
Kuzemko Alexsandr 0b574523e9 [TD] Fix redefine text in .ui (that has translation on crowdin) with English text without translation ability.
This will fix https://github.com/FreeCAD/FreeCAD-translations/issues/50
2022-05-30 10:41:00 -04:00
wmayer 8edb3e64cc Part: make DimensionLinear node kit unpickable
See forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=69056
2022-05-30 15:43:27 +02:00
Yorik van Havre e13e3bcea3 Merge pull request #6899 from 0penBrain/draftGrid
Draft: fix issues with grid spacing parameter
2022-05-30 15:31:18 +02:00
Kuzemko Alexsandr c2e34be393 Part: Fix Chamfer parameter and Fillet parameter title. Also rename variable to more informative in .ui.
This will resolve issues https://github.com/FreeCAD/FreeCAD-translations/issues/74
2022-05-30 15:01:33 +02:00
wmayer c5296fbb92 Gui: initialize _bbox with correct default values and fix incorrect label postions if ratio of width/height is less than 1 2022-05-30 14:08:33 +02:00
wmayer 1723196166 Gui: fix shrinking and shifting of color bar if ratio of width/height is smaller than one 2022-05-30 12:59:55 +02:00
wmayer 37d2492719 Gui: refactor SoFCColorGradient::setViewportSize and SoFCColorLegend::setViewportSize 2022-05-30 12:49:48 +02:00
Yorik van Havre 47125d8fda Arch: Fixed position of rectangles in IFC export 2022-05-30 10:36:05 +02:00
Yorik van Havre d3d96816ce Merged crowdin translations 2022-05-30 10:01:02 +02:00
Uwe 7907b0f8b3 [Gui] describe gradient code better
- to make it easier to see what is happening (not yet perfect since the start numbers 4.0 and 5.0 are not clear yet)
- avoid a jump of the gradient bar when decreasing window size
- return for now only the direct bar width 8will be tested thoroughly now on several PCs if this will work)
2022-05-30 04:08:19 +02:00
wmayer c4cd127499 Gui: fix number display issue of color bar 2022-05-30 03:39:48 +02:00
wmayer 919271ed5e Gui: fix visibility of front nodes when moving an object to Part container 2022-05-30 03:21:52 +02:00
Uwe 79c218ad9a [Gui] fix default color gradient numbering
as reported here: https://forum.freecadweb.org/viewtopic.php?p=598390#p598390
we must assure the user sees not by default get several gradient labels
showing the same and labels showing 0.000
2022-05-30 02:57:29 +02:00
Wanderer Fan 7b79c9697c [TD]prevent spurious recompute on click/drag 2022-05-29 13:19:34 -04:00
wmayer 30f8015e71 Part: expose ChFi2d_ChamferAPI to Python 2022-05-29 12:24:32 +02:00
wmayer f94ab3ec84 Part: expose ChFi2d_AnaFilletAlgo to Python 2022-05-29 11:31:43 +02:00
wmayer b47f8d2605 Part: move ChFi2d wrappers to own sub-directory 2022-05-29 11:05:55 +02:00
marioalexis 8e1a23eadf Base: Improve docstrings in RotationPy.xml 2022-05-29 10:34:59 +02:00
Mateusz Skowroński 391c9a6bbf buttonClicked(int id) is deprecated since Qt 5.15. Use idClicked(int id) instead. 2022-05-28 16:46:59 -04:00
wmayer bf6dbd4606 Gui: react on picked point when double or right-clicking color bar 2022-05-28 18:25:52 +02:00
Yorik van Havre 8676d67a87 merged crowdin translations 2022-05-28 12:16:47 +02:00
wmayer a80d9e5ef8 Fem: [skip ci] fix deleting Result object if its children has been deleted beforehand 2022-05-28 12:08:44 +02:00
wmayer b07be87677 Part: expose ChFi2d_FilletAPI to Python and move to ChFi2d module 2022-05-28 11:10:45 +02:00
wmayer bd853e5ef2 Part: expose ChFi2d_FilletAlgo to Python 2022-05-28 10:37:04 +02:00
Chris Hennes 4c2972cb23 AddonManager: Work around thread-safety issue in update 2022-05-27 15:24:34 -05:00
Uwe 975b8eac52 [skip CI] add missing line ending 2022-05-27 20:39:22 +02:00
Uwe 836c6b889a add description on how to build installer from self-compiled FC 2022-05-27 20:37:26 +02:00
0penBrain 4474db7f50 Draft: force length unit in grid spacing in SelectPlane 2022-05-25 09:54:34 +02:00
0penBrain ccdbf99341 Draft: fix issues with grid spacing parameter 2022-05-25 09:02:12 +02:00
younghang 18120f8bcd Merge branch 'master' into master 2022-05-18 09:39:04 +08:00
younghang a21a5a2032 Fix whitespace 2022-05-18 09:36:16 +08:00
younghang 5ae3a0866e Merge branch 'master' into master 2022-05-17 09:03:56 +08:00
younghang 07d7ced8ec Path: Fix PointProjectionFailed in rebaseWire() 2022-05-16 10:08:35 +08:00
younghang 7630ee024b fix PointProjectionFailed 2022-05-16 00:04:44 +08:00
1972 changed files with 672868 additions and 496766 deletions
+66
View File
@@ -0,0 +1,66 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: DontAlign
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: MultiLine
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 100
CompactNamespaces: false
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
ReflowComments: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never
+490
View File
@@ -0,0 +1,490 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,boost-*,bugprone-*,
performance-*,readability-*,portability-*,modernize-*,cppcoreguidelines-*,
concurrency-*,-modernize-use-trailing-return-type, -modernize-use-nodiscard'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
User: florians
CheckOptions:
- key: readability-suspicious-call-argument.PrefixSimilarAbove
value: '30'
- key: cppcoreguidelines-no-malloc.Reallocations
value: '::realloc'
- key: cppcoreguidelines-owning-memory.LegacyResourceConsumers
value: '::free;::realloc;::freopen;::fclose'
- key: bugprone-reserved-identifier.Invert
value: 'false'
- key: bugprone-narrowing-conversions.PedanticMode
value: 'false'
- key: bugprone-unused-return-value.CheckedFunctions
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname'
- key: modernize-use-auto.MinTypeNameLength
value: '5'
- key: cppcoreguidelines-macro-usage.CheckCapsOnly
value: 'false'
- key: readability-inconsistent-declaration-parameter-name.Strict
value: 'false'
- key: readability-suspicious-call-argument.DiceDissimilarBelow
value: '60'
- key: bugprone-assert-side-effect.IgnoredFunctions
value: __builtin_expect
- key: readability-suspicious-call-argument.Equality
value: 'true'
- key: bugprone-easily-swappable-parameters.QualifiersMix
value: 'false'
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
value: 'true'
- key: bugprone-argument-comment.CommentNullPtrs
value: '0'
- key: cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 'true'
- key: cppcoreguidelines-init-variables.IncludeStyle
value: llvm
- key: modernize-use-nodiscard.ReplacementString
value: '[[nodiscard]]'
- key: modernize-loop-convert.MakeReverseRangeHeader
value: ''
- key: readability-suspicious-call-argument.SuffixSimilarAbove
value: '30'
- key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion
value: 'true'
- key: bugprone-easily-swappable-parameters.IgnoredParameterNames
value: '"";iterator;Iterator;begin;Begin;end;End;first;First;last;Last;lhs;LHS;rhs;RHS'
- key: modernize-loop-convert.UseCxx20ReverseRanges
value: 'true'
- key: cppcoreguidelines-prefer-member-initializer.UseAssignment
value: 'false'
- key: performance-type-promotion-in-math-fn.IncludeStyle
value: llvm
- key: readability-function-cognitive-complexity.DescribeBasicIncrements
value: 'true'
- key: bugprone-suspicious-include.ImplementationFileExtensions
value: 'c;cc;cpp;cxx'
- key: modernize-loop-convert.MakeReverseRangeFunction
value: ''
- key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
value: 'true'
- key: bugprone-suspicious-missing-comma.SizeThreshold
value: '5'
- key: readability-identifier-naming.IgnoreFailedSplit
value: 'false'
- key: readability-qualified-auto.AddConstToQualified
value: 'true'
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
value: 'true'
- key: bugprone-string-constructor.WarnOnLargeLength
value: 'true'
- key: cppcoreguidelines-explicit-virtual-functions.OverrideSpelling
value: override
- key: readability-uppercase-literal-suffix.IgnoreMacros
value: 'true'
- key: modernize-make-shared.IgnoreMacros
value: 'true'
- key: bugprone-dynamic-static-initializers.HeaderFileExtensions
value: ';h;hh;hpp;hxx'
- key: bugprone-suspicious-enum-usage.StrictMode
value: 'false'
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: ''
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
value: '5'
- key: modernize-use-transparent-functors.SafeMode
value: 'false'
- key: readability-suspicious-call-argument.Levenshtein
value: 'true'
- key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
value: 'true'
- key: bugprone-string-constructor.LargeLengthThreshold
value: '8388608'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: 'false'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues
value: 'false'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: 'false'
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
value: ''
- key: performance-inefficient-vector-operation.EnableProto
value: 'false'
- key: modernize-make-shared.MakeSmartPtrFunction
value: 'std::make_shared'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: readability-suspicious-call-argument.PrefixDissimilarBelow
value: '25'
- key: readability-function-size.LineThreshold
value: '4294967295'
- key: bugprone-easily-swappable-parameters.MinimumLength
value: '2'
- key: portability-simd-intrinsics.Suggest
value: 'false'
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
value: ''
- key: modernize-use-override.IgnoreDestructors
value: 'false'
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
value: '<memory>'
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
value: 'true'
- key: readability-redundant-string-init.StringNames
value: '::std::basic_string_view;::std::basic_string'
- key: modernize-make-unique.IgnoreDefaultInitialization
value: 'true'
- key: modernize-use-emplace.ContainersWithPushBack
value: '::std::vector;::std::list;::std::deque'
- key: readability-magic-numbers.IgnoreBitFieldsWidths
value: 'true'
- key: modernize-make-unique.IncludeStyle
value: llvm
- key: modernize-use-override.OverrideSpelling
value: override
- key: readability-suspicious-call-argument.LevenshteinDissimilarBelow
value: '50'
- key: bugprone-argument-comment.CommentStringLiterals
value: '0'
- key: concurrency-mt-unsafe.FunctionSet
value: any
- key: readability-identifier-length.IgnoredExceptionVariableNames
value: '^[e]$'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: bugprone-reserved-identifier.AllowedIdentifiers
value: ''
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
value: 'false'
- key: readability-else-after-return.WarnOnUnfixable
value: 'true'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: modernize-use-emplace.IgnoreImplicitConstructors
value: 'false'
- key: cppcoreguidelines-macro-usage.IgnoreCommandLineMacros
value: 'true'
- key: readability-suspicious-call-argument.Substring
value: 'true'
- key: modernize-use-equals-delete.IgnoreMacros
value: 'true'
- key: readability-identifier-length.IgnoredVariableNames
value: ''
- key: readability-magic-numbers.IgnoreAllFloatingPointValues
value: 'false'
- key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
value: llvm
- key: readability-suspicious-call-argument.Abbreviations
value: 'arr=array;cnt=count;idx=index;src=source;stmt=statement;cpy=copy;dest=destination;dist=distancedst=distance;ptr=pointer;wdth=width;str=string;ln=line;srv=server;attr=attribute;ref=reference;buf=buffer;col=column;nr=number;vec=vector;len=length;elem=element;val=value;i=index;var=variable;hght=height;cl=client;num=number;pos=position;lst=list;addr=address'
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
value: 'false'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: performance-unnecessary-value-param.AllowedTypes
value: ''
- key: readability-uniqueptr-delete-release.PreferResetCall
value: 'false'
- key: readability-identifier-length.MinimumExceptionNameLength
value: '2'
- key: cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues
value: 'false'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths
value: 'true'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: cppcoreguidelines-no-malloc.Allocations
value: '::malloc;::calloc'
- key: bugprone-narrowing-conversions.IgnoreConversionFromTypes
value: ''
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: bugprone-suspicious-missing-comma.RatioThreshold
value: '0.200000'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 'false'
- key: readability-identifier-length.IgnoredParameterNames
value: '^[n]$'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 'false'
- key: cppcoreguidelines-init-variables.MathHeader
value: '<math.h>'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: bugprone-reserved-identifier.AggressiveDependentMemberLookup
value: 'false'
- key: readability-suspicious-call-argument.DiceSimilarAbove
value: '70'
- key: modernize-use-equals-default.IgnoreMacros
value: 'true'
- key: readability-suspicious-call-argument.Abbreviation
value: 'true'
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: 'false'
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: '2'
- key: modernize-use-emplace.SmartPointers
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
- key: cppcoreguidelines-no-malloc.Deallocations
value: '::free'
- key: bugprone-dangling-handle.HandleClasses
value: 'std::basic_string_view;std::experimental::basic_string_view'
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
value: 'false'
- key: readability-suspicious-call-argument.JaroWinklerSimilarAbove
value: '85'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: performance-unnecessary-copy-initialization.ExcludedContainerTypes
value: ''
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: 'true'
- key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
value: '3'
- key: readability-function-size.VariableThreshold
value: '4294967295'
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 'true'
- key: readability-identifier-naming.GetConfigPerFile
value: 'true'
- key: modernize-use-default-member-init.UseAssignment
value: 'false'
- key: readability-function-size.NestingThreshold
value: '4294967295'
- key: modernize-use-override.AllowOverrideAndFinal
value: 'false'
- key: cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes
value: ''
- key: readability-function-size.ParameterThreshold
value: '4294967295'
- key: modernize-pass-by-value.ValuesOnly
value: 'false'
- key: readability-function-cognitive-complexity.IgnoreMacros
value: 'false'
- key: modernize-loop-convert.IncludeStyle
value: llvm
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: 'false'
- key: bugprone-narrowing-conversions.WarnWithinTemplateInstantiation
value: 'false'
- key: cert-err33-c.CheckedFunctions
value: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
value: 'false'
- key: readability-redundant-smartptr-get.IgnoreMacros
value: 'true'
- key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal
value: 'false'
- key: readability-identifier-naming.AggressiveDependentMemberLookup
value: 'false'
- key: readability-identifier-length.MinimumParameterNameLength
value: '2'
- key: modernize-use-emplace.TupleTypes
value: '::std::pair;::std::tuple'
- key: modernize-use-emplace.TupleMakeFunctions
value: '::std::make_pair;::std::make_tuple'
- key: bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
value: 'true'
- key: cppcoreguidelines-owning-memory.LegacyResourceProducers
value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
- key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether
value: 'true'
- key: bugprone-argument-comment.StrictMode
value: '0'
- key: modernize-replace-random-shuffle.IncludeStyle
value: llvm
- key: modernize-use-bool-literals.IgnoreMacros
value: 'true'
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
value: 'true'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
value: ''
- key: modernize-avoid-bind.PermissiveParameterList
value: 'false'
- key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold
value: '1'
- key: readability-suspicious-call-argument.Suffix
value: 'true'
- key: readability-suspicious-call-argument.JaroWinklerDissimilarBelow
value: '75'
- key: modernize-use-noexcept.ReplacementString
value: ''
- key: modernize-use-override.FinalSpelling
value: final
- key: modernize-use-using.IgnoreMacros
value: 'true'
- key: cppcoreguidelines-explicit-virtual-functions.FinalSpelling
value: final
- key: readability-suspicious-call-argument.MinimumIdentifierNameLength
value: '3'
- key: bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion
value: 'true'
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: cppcoreguidelines-pro-type-member-init.UseAssignment
value: 'false'
- key: bugprone-suspicious-include.HeaderFileExtensions
value: ';h;hh;hpp;hxx'
- key: performance-no-automatic-move.AllowedTypes
value: ''
- key: readability-suspicious-call-argument.SubstringDissimilarBelow
value: '40'
- key: bugprone-argument-comment.CommentIntegerLiterals
value: '0'
- key: bugprone-stringview-nullptr.IncludeStyle
value: llvm
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: 'false'
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: bugprone-argument-comment.CommentFloatLiterals
value: '0'
- key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
value: '16'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: 'false'
- key: readability-else-after-return.WarnOnConditionVariables
value: 'true'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: readability-suspicious-call-argument.SuffixDissimilarBelow
value: '25'
- key: bugprone-argument-comment.CommentCharacterLiterals
value: '0'
- key: cppcoreguidelines-macro-usage.AllowedRegexp
value: '^DEBUG_*'
- key: readability-suspicious-call-argument.LevenshteinSimilarAbove
value: '66'
- key: cppcoreguidelines-narrowing-conversions.PedanticMode
value: 'false'
- key: modernize-make-shared.IgnoreDefaultInitialization
value: 'true'
- key: readability-suspicious-call-argument.JaroWinkler
value: 'true'
- key: bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources
value: 'true'
- key: modernize-make-shared.IncludeStyle
value: llvm
- key: readability-suspicious-call-argument.Prefix
value: 'true'
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
value: 'false'
- key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources
value: 'true'
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
value: ''
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: 'false'
- key: modernize-make-unique.IgnoreMacros
value: 'true'
- key: performance-for-range-copy.AllowedTypes
value: ''
- key: bugprone-argument-comment.CommentBoolLiterals
value: '0'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: bugprone-argument-comment.CommentUserDefinedLiterals
value: '0'
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: performance-inefficient-string-concatenation.StrictMode
value: 'false'
- key: readability-redundant-declaration.IgnoreMacros
value: 'true'
- key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes
value: 'bool;Bool;_Bool;it;It;iterator;Iterator;inputit;InputIt;forwardit;ForwardIt;bidirit;BidirIt;constiterator;const_iterator;Const_Iterator;Constiterator;ConstIterator;RandomIt;randomit;random_iterator;ReverseIt;reverse_iterator;reverse_const_iterator;ConstReverseIterator;Const_Reverse_Iterator;const_reverse_iterator;Constreverseiterator;constreverseiterator'
- key: modernize-make-unique.MakeSmartPtrFunction
value: 'std::make_unique'
- key: portability-restrict-system-includes.Includes
value: '*'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 'true'
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
value: '<memory>'
- key: bugprone-signal-handler.AsyncSafeFunctionSet
value: POSIX
- key: bugprone-easily-swappable-parameters.ModelImplicitConversions
value: 'true'
- key: readability-suspicious-call-argument.SubstringSimilarAbove
value: '50'
- key: cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation
value: 'false'
- key: readability-identifier-length.MinimumVariableNameLength
value: '2'
- key: cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth
value: 'true'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables
value: 'false'
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
value: 'false'
- key: modernize-use-noexcept.UseNoexceptFalse
value: 'true'
- key: readability-function-cognitive-complexity.Threshold
value: '25'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 'true'
- key: bugprone-argument-comment.IgnoreSingleArgument
value: '0'
- key: bugprone-narrowing-conversions.WarnOnEquivalentBitWidth
value: 'true'
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
value: 'false'
- key: performance-faster-string-find.StringLikeClasses
value: '::std::basic_string;::std::basic_string_view'
- key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
value: 'true'
- key: bugprone-assert-side-effect.CheckFunctionCalls
value: 'false'
- key: bugprone-string-constructor.StringNames
value: '::std::basic_string;::std::basic_string_view'
- key: bugprone-assert-side-effect.AssertMacros
value: assert,NSAssert,NSCAssert
- key: bugprone-exception-escape.IgnoredExceptions
value: ''
- key: bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons
value: 'true'
- key: modernize-use-default-member-init.IgnoreMacros
value: 'true'
- key: llvm-qualified-auto.AddConstToQualified
value: 'false'
- key: llvm-else-after-return.WarnOnConditionVariables
value: 'false'
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
value: 'true'
- key: modernize-raw-string-literal.DelimiterStem
value: lit
- key: readability-suspicious-call-argument.Dice
value: 'true'
- key: readability-identifier-length.IgnoredLoopCounterNames
value: '^[ijk_]$'
- key: modernize-raw-string-literal.ReplaceShorterLiterals
value: 'false'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: performance-inefficient-vector-operation.VectorLikeClasses
value: '::std::vector'
- key: modernize-use-auto.RemoveStars
value: 'false'
- key: bugprone-implicit-widening-of-multiplication-result.IncludeStyle
value: llvm
- key: portability-simd-intrinsics.Std
value: ''
- key: performance-unnecessary-value-param.IncludeStyle
value: llvm
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 'false'
- key: modernize-replace-disallow-copy-and-assign-macro.MacroName
value: DISALLOW_COPY_AND_ASSIGN
- key: llvm-else-after-return.WarnOnUnfixable
value: 'false'
...
+5 -3
View File
@@ -19,7 +19,9 @@ body:
id: forum_link
attributes:
label: Forums discussion
description: Please start a discussion about your issue at [the FreeCAD Forum](https://forum.freecad.org) and wait for confirmation there before creating an issue
description: |
Please start a discussion about your issue at [the FreeCAD Forum](https://forum.freecad.org) and wait for confirmation there before creating an issue.
**Note:** Bug reports without a prior forum discussion will most likely not be accepted.
placeholder: Paste link to forum discussion here
validations:
required: true
@@ -29,8 +31,8 @@ body:
label: Version
description: What version of FreeCAD are you running?
options:
- 0.19 (Release)
- 0.20 (Development)
- 0.20 (Release)
- 0.21 (Development)
validations:
required: true
- type: textarea
+1 -1
View File
@@ -9,6 +9,6 @@ Thank you for creating a pull request to contribute to FreeCAD! To ease integrat
- [ ] Commit messages include `issue #<id>` or `fixes #<id>` where `<id>` is the issue ID number from our [Issues database](https://github.com/FreeCAD/FreeCAD/issues) in case a particular commit solves or is related to an existing issue. Ex: `Draft: fix typos - fixes #4805`
And please remember to update the Wiki with the features added or changed once this PR is merged.
**Note**: If you don't have wiki access, then please mention your contribution on the [0.20 Changelog Forum Thread](https://forum.freecadweb.org/viewtopic.php?f=10&t=56135).
**Note**: If you don't have wiki access, then please mention your contribution on the [1.0 Changelog Forum Thread](https://forum.freecad.org/viewtopic.php?f=10&t=69438).
---
+4
View File
@@ -33,6 +33,7 @@ hist
indicies
inout
ist
itsel
lod
mantatory
mata
@@ -43,6 +44,7 @@ nin
normale
normaly
numer
oce
ontop
ot
parm
@@ -54,6 +56,7 @@ recurrance
rougly
seh
serie
siz
som
strack
substraction
@@ -62,6 +65,7 @@ te
thist
tread
ue
upto
uptodate
usind
vas
+15
View File
@@ -0,0 +1,15 @@
{
"problemMatcher": [
{
"owner": "black-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(would reformat (.*))$",
"file": 2,
"message": 1
}
]
}
]
}
+17
View File
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "clang",
"pattern": [
{
"regexp": "^(.+):([0-9]+):([0-9]+): (error|warning|note): (.+)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
+16
View File
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "codespell-matcher",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):(\\d+):\\s+(.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
+16
View File
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "cpplint",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):([0-9]+): (.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "grepMatcher-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):([0-9]+):(.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
+18
View File
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "pylint-error",
"severity": "error",
"pattern": [
{
"regexp": "^(.+?):([0-9]+):([0-9]+): ([([E|F][0-9]+): (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
+18
View File
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "pylint-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+?):([0-9]+):([0-9]+): ([^E|F][0-9]+): (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
File diff suppressed because it is too large Load Diff
+6 -4
View File
@@ -1,5 +1,9 @@
# file types to ignore
.*
!/.gitignore
!/.clang-format
!/.git-blame-ignore-revs
!/.gitattributes
*.DS_Store
*.pyc
*.obj
@@ -34,12 +38,10 @@ install_manifest.txt
/src/Tools/offlinedoc/localwiki/
/src/Tools/offlinedoc/*.txt
OpenSCAD_rc.py
/\.idea/
.tags
tags
/\.vscode/
# crowdin file
src/Tools/freecad.zip
tsupdate_stderr.log
tsupdate_stdout.log
files_to_translate.txt
+614
View File
@@ -0,0 +1,614 @@
[MAIN]
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Load and enable all available extensions. Use --list-extensions to see a list
# all available extensions.
#enable-all-extensions=
# In error mode, messages with a category besides ERROR or FATAL are
# suppressed, and no reports are done by default. Error mode is compatible with
# disabling specific errors.
#errors-only=
# Always return a 0 (non-error) status code, even if lint errors are found.
# This is primarily useful in continuous integration scripts.
#exit-zero=
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-allow-list=
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
# for backward compatibility.)
extension-pkg-whitelist=
# Return non-zero exit code if any of these messages/categories are detected,
# even if score is above --fail-under value. Syntax same as enable. Messages
# specified are enabled, while categories only check already-enabled messages.
fail-on=
# Specify a score threshold to be exceeded before program exits with error.
fail-under=10
# Interpret the stdin as a python script, whose filename needs to be passed as
# the module_or_package argument.
#from-stdin=
# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
ignore-paths=
# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths. The default value ignores Emacs file
# locks
ignore-patterns=^\.#
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
# avoid hangs.
jobs=1
# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
limit-inference-results=100
# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.10
# Discover python modules and packages in the file system subtree.
recursive=no
# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
# In verbose mode, extra non-checker-related info will be displayed.
#verbose=
[REPORTS]
# Python expression which should return a score less than or equal to 10. You
# have access to the variables 'fatal', 'error', 'warning', 'refactor',
# 'convention', and 'info' which contain the number of messages in each
# category, as well as 'statement' which is the total number of statements
# analyzed. This score is used by the global evaluation report (RP0004).
evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10))
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
#output-format=
# Tells whether to display a full report or only the messages.
reports=yes
# Activate the evaluation score.
score=yes
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE,
# UNDEFINED.
confidence=HIGH,
CONTROL_FLOW,
INFERENCE,
INFERENCE_FAILURE,
UNDEFINED
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
invalid-name,
wrong-import-order,
import-error,
undefined-variable
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member
[BASIC]
# Naming style matching correct argument names.
argument-naming-style=snake_case
# Regular expression matching correct argument names. Overrides argument-
# naming-style. If left empty, argument names will be checked with the set
# naming style.
#argument-rgx=
# Naming style matching correct attribute names.
attr-naming-style=snake_case
# Regular expression matching correct attribute names. Overrides attr-naming-
# style. If left empty, attribute names will be checked with the set naming
# style.
#attr-rgx=
# Bad variable names which should always be refused, separated by a comma.
bad-names=foo,
bar,
baz,
toto,
tutu,
tata
# Bad variable names regexes, separated by a comma. If names match any regex,
# they will always be refused
bad-names-rgxs=
# Naming style matching correct class attribute names.
class-attribute-naming-style=any
# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style. If left empty, class attribute names will be checked
# with the set naming style.
#class-attribute-rgx=
# Naming style matching correct class constant names.
class-const-naming-style=UPPER_CASE
# Regular expression matching correct class constant names. Overrides class-
# const-naming-style. If left empty, class constant names will be checked with
# the set naming style.
#class-const-rgx=
# Naming style matching correct class names.
class-naming-style=PascalCase
# Regular expression matching correct class names. Overrides class-naming-
# style. If left empty, class names will be checked with the set naming style.
#class-rgx=
# Naming style matching correct constant names.
const-naming-style=UPPER_CASE
# Regular expression matching correct constant names. Overrides const-naming-
# style. If left empty, constant names will be checked with the set naming
# style.
#const-rgx=
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming style matching correct function names.
function-naming-style=snake_case
# Regular expression matching correct function names. Overrides function-
# naming-style. If left empty, function names will be checked with the set
# naming style.
#function-rgx=
# Good variable names which should always be accepted, separated by a comma.
good-names=i,
j,
k,
ex,
Run,
_
# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
good-names-rgxs=
# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
# Naming style matching correct inline iteration names.
inlinevar-naming-style=any
# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style. If left empty, inline iteration names will be checked
# with the set naming style.
#inlinevar-rgx=
# Naming style matching correct method names.
method-naming-style=snake_case
# Regular expression matching correct method names. Overrides method-naming-
# style. If left empty, method names will be checked with the set naming style.
#method-rgx=
# Naming style matching correct module names.
module-naming-style=snake_case
# Regular expression matching correct module names. Overrides module-naming-
# style. If left empty, module names will be checked with the set naming style.
#module-rgx=
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty
# Regular expression matching correct type variable names. If left empty, type
# variable names will be checked with the set naming style.
#typevar-rgx=
# Naming style matching correct variable names.
variable-naming-style=snake_case
# Regular expression matching correct variable names. Overrides variable-
# naming-style. If left empty, variable names will be checked with the set
# naming style.
#variable-rgx=
[CLASSES]
# Warn about protected attribute access inside special methods
check-protected-access-in-special-methods=no
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
__new__,
setUp,
__post_init__
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=sys.exit,argparse.parse_error
[DESIGN]
# List of regular expressions of class ancestor names to ignore when counting
# public methods (see R0903)
exclude-too-few-public-methods=
# List of qualified class names to ignore when counting class parents (see
# R0901)
ignored-parents=
# Maximum number of arguments for function / method.
max-args=5
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
# Maximum number of branch for function / method body.
max-branches=12
# Maximum number of locals for function / method body.
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body.
max-returns=6
# Maximum number of statements in function / method body.
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
[EXCEPTIONS]
# Exceptions that will emit a warning when caught.
overgeneral-exceptions=BaseException,
Exception
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module.
max-module-lines=1000
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[IMPORTS]
# List of modules that can be imported at any level, not just the top level
# one.
allow-any-import-level=
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Deprecated modules which should not be used, separated by a comma.
deprecated-modules=
# Output a graph (.gv or any supported image format) of external dependencies
# to the given file (report RP0402 must not be disabled).
ext-import-graph=
# Output a graph (.gv or any supported image format) of all (i.e. internal and
# external) dependencies to the given file (report RP0402 must not be
# disabled).
import-graph=
# Output a graph (.gv or any supported image format) of internal dependencies
# to the given file (report RP0402 must not be disabled).
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
# Couples of modules and preferred modules, separated by a comma.
preferred-modules=
[LOGGING]
# The type of string formatting that logging methods do. `old` means using %
# formatting, `new` is for `{}` formatting.
logging-format-style=old
# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
# Regular expression of note tags to take in consideration.
notes-rgx=
[SIMILARITIES]
# Comments are removed from the similarity computation
ignore-comments=yes
# Docstrings are removed from the similarity computation
ignore-docstrings=yes
# Imports are removed from the similarity computation
ignore-imports=yes
# Signatures are removed from the similarity computation
ignore-signatures=yes
# Minimum lines number of a similarity.
min-similarity-lines=4
[SPELLING]
# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4
# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the 'python-enchant' package.
spelling-dict=
# List of comma separated words that should be considered directives if they
# appear at the beginning of a comment and should not be checked.
spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains the private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to the private dictionary (see the
# --spelling-private-dict-file option) instead of raising a message.
spelling-store-unknown-words=no
[STRING]
# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=no
# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
check-str-concat-over-line-jumps=no
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of symbolic message names to ignore for Mixin members.
ignored-checks-for-mixins=no-member,
not-async-context-manager,
not-context-manager,
attribute-defined-outside-init
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
# Regex pattern to define which classes are considered mixins.
mixin-class-rgx=.*[Mm]ixin
# List of decorators that change the signature of a decorated function.
signature-mutators=
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid defining new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of names allowed to shadow builtins
allowed-redefined-builtins=
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
_cb
# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
+3 -2
View File
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
# relates to FindOpenGL module
# and cache variables OPENGL_gl_LIBRARY, OPENGL_glu_LIBRARY
if (POLICY CMP0072)
cmake_policy(SET CMP0072 OLD)
set(OpenGL_GL_PREFERENCE LEGACY)
endif(POLICY CMP0072)
find_program(CCACHE_PROGRAM ccache) #This check should occur before project()
@@ -17,9 +17,10 @@ project(FreeCAD)
set(PACKAGE_VERSION_NAME "Vulcan")
set(PACKAGE_VERSION_MAJOR "0")
set(PACKAGE_VERSION_MINOR "20")
set(PACKAGE_VERSION_MINOR "21")
set(PACKAGE_VERSION_PATCH "0")
set(PACKAGE_VERSION_SUFFIX "dev") # either "dev" for development snapshot or "" (empty string)
set(FREECAD_VERSION_PATCH "0") # number of patch release (e.g. "4" for the 0.18.4 release)
set(FREECAD_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

+53 -8
View File
@@ -1,7 +1,50 @@
![Logo](https://www.freecadweb.org/images/logo.png)
<h6 align="center"><img src="FreeCAD-toponaming-logo.png"/></h6>
### Your own 3D parametric modeler
<h1 align="center">FreeCAD Topological Naming (toponaming) Branch</h1>
### About
This branch is dedicated to integrating code that improves the [topological naming problem](https://wiki.freecad.org/Topological_naming_problem) in FreeCAD. There have been several attempts to address it over the years within FreeCAD. In reality, toponaming is an issue that no modern CAD software is fully immune to. This is because the solutions are complex.
Thanks to an independent developer named Zheng Lei ('realthunder'), who has gone the farthest in the effort of fixing toponaming in FreeCAD, and has provided a proof of concept fix in his own branch named 'Link' branch.
* [@Realthunder](https://github.com/realthunder)'s Link branch: https://github.com/realthunder/FreeCAD
* Official FreeCAD main ('master') branch: https://github.com/FreeCAD/FreeCAD/
* Official FreeCAD toponaming git repository: https://github.com/FreeCAD/FreeCAD/tree/development/toponaming
### Objective
Per the FreeCAD developer meetings that occurred during the pre-release of v0.20, 'toponaming' was identified as one of the main targets for merge in the v0.21/v1.0 release cycle.
### Contributing
During this development cycle there will be nightly builds provided for testers to test and report results back to the developers.
<details>
<summary>Expand this section to learn about testing toponaming on different platforms/distros</summary>
#### Linux
##### Snap packages
A nightly Snap package of the 'toponaming' branch will be available to testers. Refer to the [Snap wiki page](https://wiki.freecad.org/Ubuntu_Snap#Notes)
#### Windows
TBD
#### macOS
TBD
#### FreeBSD
N/A
</details>
<!--
[Website](https://www.freecadweb.org) •
[Documentation](https://wiki.freecadweb.org) •
[Forum](https://forum.freecadweb.org/) •
@@ -11,7 +54,7 @@
[![Release](https://img.shields.io/github/release/freecad/freecad.svg)](https://github.com/freecad/freecad/releases/latest) [![Master][freecad-master-status]][gitlab-branch-master] [![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad) [![Gitter](https://img.shields.io/gitter/room/freecad/freecad.svg)](https://gitter.im/freecad/freecad?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/FreeCAD/FreeCAD.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/FreeCAD/FreeCAD/context:python) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/FreeCAD/FreeCAD.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/FreeCAD/FreeCAD/context:cpp) [![Liberapay](https://img.shields.io/liberapay/receives/FreeCAD.svg?logo=liberapay)](https://liberapay.com/FreeCAD)
![screenshot](https://wiki.freecadweb.org/images/thumb/7/72/Freecad016_screenshot1.jpg/800px-Freecad016_screenshot1.jpg)
<img src="https://user-images.githubusercontent.com/1828501/174066870-1692005b-f8d7-43fb-a289-6d2f07f73d7f.png" width="800"/>
Overview
--------
@@ -55,13 +98,13 @@ Other options are described at the [wiki Download page](https://wiki.freecadweb.
Build Status
------------
| Master | 0.19 | Translation |
| Master | 0.20 | Translation |
|:------:|:----:|:-----------:|
|[![Master][freecad-master-status]][gitlab-branch-master]|[![0.19][freecad-0.19-status]][gitlab-branch-0.19]|[![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad)|
|[![Master][freecad-master-status]][gitlab-branch-master]|[![0.20][freecad-0.20-status]][gitlab-branch-0.20]|[![Crowdin](https://d322cqt584bo4o.cloudfront.net/freecad/localized.svg)](https://crowdin.com/project/freecad)|
[freecad-0.19-status]: https://gitlab.com/freecad/FreeCAD-CI/badges/releases/FreeCAD-0-19/pipeline.svg
[freecad-0.20-status]: https://gitlab.com/freecad/FreeCAD-CI/badges/releases/FreeCAD-0-20/pipeline.svg
[freecad-master-status]: https://gitlab.com/freecad/FreeCAD-CI/badges/master/pipeline.svg
[gitlab-branch-0.19]: https://gitlab.com/freecad/FreeCAD-CI/-/commits/releases/FreeCAD-0-19
[gitlab-branch-0.20]: https://gitlab.com/freecad/FreeCAD-CI/-/commits/releases/FreeCAD-0-20
[gitlab-branch-master]: https://gitlab.com/freecad/FreeCAD-CI/-/commits/master
[travis-builds]: https://travis-ci.org/FreeCAD/FreeCAD/builds
@@ -99,7 +142,7 @@ To report an issue please:
For more detail see:
- [Wiki Page about the Bug Tracker](https://wiki.freecadweb.org/Tracker)
- [Bug Tracker](https://tracker.freecadweb.org)
- [Help Forum](http://forum.freecadweb.org/viewforum.php?f=3)
- [Help Forum](https://forum.freecadweb.org/viewforum.php?f=3)
Usage & Getting help
@@ -126,3 +169,5 @@ learning to use FreeCAD.
<img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/SVG/DO_Logo_horizontal_blue.svg" width="91px">
</a> and <a href="https://www.kipro-pcb.com/">KiCad Services Corp.</a>
</p>
-->
+39 -9
View File
@@ -5,28 +5,55 @@
# SMESH_INCLUDE_DIR - where the Salome SMESH include directory can be found
# SMESH_LIBRARIES - Link this to use Salome SMESH
#
# SMESH needs VTK
find_package(VTK REQUIRED)
# If this definition is not set, linker errors will occur against SMESH on 64 bit machines.
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DSALOME_USE_64BIT_IDS)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
IF (CMAKE_COMPILER_IS_GNUCC)
FIND_PATH(SMESH_INCLUDE_DIR SMESH_Mesh.hxx
# These are default search paths, why specify them?
# /usr/include
# /usr/local/include
PATH_SUFFIXES smesh
)
FIND_LIBRARY(SMESH_LIBRARY SMESH
# /usr/lib
# /usr/local/lib
PATH_SUFFIXES smesh SMESH smesh/SMESH
)
FIND_LIBRARY(SMESH_LIBRARY SMESH)
ELSE (CMAKE_COMPILER_IS_GNUCC)
# Not yet implemented
ENDIF (CMAKE_COMPILER_IS_GNUCC)
IF(SMESH_INCLUDE_DIR)
SET(SMESH_INC_ROOT "${SMESH_INCLUDE_DIR}/..")
# Append extra include dirs
SET(SMESH_INCLUDE_DIR
"${SMESH_INCLUDE_DIR};
${SMESH_INC_ROOT}/Controls;
${SMESH_INC_ROOT}/Driver;
${SMESH_INC_ROOT}/DriverDAT;
${SMESH_INC_ROOT}/DriverGMF;
${SMESH_INC_ROOT}/DriverSTL;
${SMESH_INC_ROOT}/DriverUNV;
${SMESH_INC_ROOT}/Geom;
${SMESH_INC_ROOT}/Kernel;
${SMESH_INC_ROOT}/MEFISTO2;
${SMESH_INC_ROOT}/MeshVSLink;
${SMESH_INC_ROOT}/Netgen;
${SMESH_INC_ROOT}/NETGENPlugin;
${SMESH_INC_ROOT}/SMDS;
${SMESH_INC_ROOT}/SMESHDS;
${SMESH_INC_ROOT}/SMESHUtils;
${SMESH_INC_ROOT}/StdMeshers;")
ELSE(SMESH_INCLUDE_DIR)
message(FATAL_ERROR "SMESH include directories not found!")
ENDIF(SMESH_INCLUDE_DIR)
SET(SMESH_FOUND FALSE)
IF(SMESH_LIBRARY)
SET(SMESH_FOUND TRUE)
GET_FILENAME_COMPONENT(SMESH_LIBRARY_DIR ${SMESH_LIBRARY} PATH)
set(SMESH_LIBRARIES
set(SMESH_LIBRARIES
${SMESH_LIBRARY_DIR}/libDriver.so
${SMESH_LIBRARY_DIR}/libDriverDAT.so
${SMESH_LIBRARY_DIR}/libDriverSTL.so
@@ -36,5 +63,8 @@ IF(SMESH_LIBRARY)
${SMESH_LIBRARY_DIR}/libSMESHDS.so
${SMESH_LIBRARY_DIR}/libStdMeshers.so
)
set(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES})
ELSE(SMESH_LIBRARY)
message(FATAL_ERROR "SMESH libraries NOT FOUND!")
ENDIF(SMESH_LIBRARY)
@@ -37,5 +37,5 @@ macro(CheckInterModuleDependencies)
REQUIRES_MODS(BUILD_SKETCHER BUILD_PART)
REQUIRES_MODS(BUILD_SPREADSHEET BUILD_DRAFT)
REQUIRES_MODS(BUILD_START BUILD_WEB)
REQUIRES_MODS(BUILD_TECHDRAW BUILD_PART BUILD_SPREADSHEET BUILD_DRAWING)
REQUIRES_MODS(BUILD_TECHDRAW BUILD_PART BUILD_SPREADSHEET)
endmacro(CheckInterModuleDependencies)
@@ -10,6 +10,7 @@ macro(InitializeFreeCADBuildOptions)
option(FREECAD_USE_EXTERNAL_KDL "Use system installed orocos-kdl instead of the bundled." OFF)
option(FREECAD_USE_FREETYPE "Builds the features using FreeType libs" ON)
option(FREECAD_BUILD_DEBIAN "Prepare for a build of a Debian package" OFF)
option(FREECAD_TOPONAMING_BRANDING "Enable branding for TopoNaming branch" ON)
option(BUILD_WITH_CONDA "Set ON if you build FreeCAD with conda" OFF)
option(BUILD_DYNAMIC_LINK_PYTHON "If OFF extension-modules do not link against python-libraries" ON)
option(INSTALL_TO_SITEPACKAGES "If ON the freecad root namespace (python) is installed into python's site-packages" OFF)
@@ -113,7 +114,7 @@ macro(InitializeFreeCADBuildOptions)
option(BUILD_ARCH "Build the FreeCAD Architecture module" ON)
option(BUILD_COMPLETE "Build the FreeCAD complete module" OFF)
option(BUILD_DRAFT "Build the FreeCAD draft module" ON)
option(BUILD_DRAWING "Build the FreeCAD drawing module" ON)
option(BUILD_DRAWING "Build the FreeCAD drawing module" OFF)
option(BUILD_IDF "Build the FreeCAD idf module" ON)
option(BUILD_IMAGE "Build the FreeCAD image module" ON)
option(BUILD_IMPORT "Build the FreeCAD import module" ON)
+8 -8
View File
@@ -27,7 +27,7 @@ macro(PrintFinalReport)
message(STATUS "pybind11: not enabled")
endif(DEFINED pybind11_FOUND)
message(STATUS "Boost: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} (${Boost_VERSION})")
message(STATUS "Boost: ${Boost_VERSION}")
message(STATUS "XercesC: ${XercesC_VERSION} [${XercesC_LIBRARIES}] [${XercesC_INCLUDE_DIRS}]")
@@ -41,10 +41,10 @@ macro(PrintFinalReport)
if(FREECAD_USE_EXTERNAL_SMESH)
message(STATUS "SMESH: ${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK}")
else(FREECAD_USE_EXTERNAL_SMESH)
message(STATUS "SMESH: build internal")
message(STATUS " MEDFile: ${MEDFILE_VERSION} [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]")
message(STATUS " HDF5: ${HDF5_VERSION}")
message(STATUS " VTK: ${VTK_VERSION}")
message(STATUS "SMESH: ${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK} build internal")
message(STATUS "MEDFile: ${MEDFILE_VERSION} [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]")
message(STATUS "HDF5: ${HDF5_VERSION}")
message(STATUS "VTK: ${VTK_VERSION}")
endif(FREECAD_USE_EXTERNAL_SMESH)
else(BUILD_SMESH)
message(STATUS "SMESH: do not build")
@@ -191,11 +191,11 @@ macro(PrintFinalReport)
if(DOXYGEN_FOUND)
message(STATUS "Doxygen: ${DOXYGEN_VERSION}")
message(STATUS " Language: ${DOXYGEN_LANGUAGE}")
message(STATUS "Language: ${DOXYGEN_LANGUAGE}")
if(COIN3D_DOC_FOUND)
message(STATUS " Coin3D_DOC: found [${COIN3D_DOC_PATH}]")
message(STATUS "Coin3D_DOC: found [${COIN3D_DOC_PATH}]")
else(COIN3D_DOC_FOUND)
message(STATUS " Coin3D_DOC: not found")
message(STATUS "Coin3D_DOC: not found")
endif(COIN3D_DOC_FOUND)
else(DOXYGEN_FOUND)
message(STATUS "Doxygen: not found")
+1 -1
View File
@@ -1,7 +1,7 @@
macro(SetupOpenCasCade)
# -------------------------------- OpenCasCade --------------------------------
find_package(OpenCasCade)
find_package(OCC)
if(NOT OCC_FOUND)
message(FATAL_ERROR "================================================================\n"
"Neither OpenCASCADE Community Edition nor OpenCASCADE was found!\n"
+13 -5
View File
@@ -119,13 +119,21 @@ macro(SetupSalomeSMESH)
else(NOT FREECAD_USE_EXTERNAL_SMESH)
find_package(SMESH CONFIG)
# If this definition is not set, linker errors will occur against SMESH on 64 bit machines.
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DSALOME_USE_64BIT_IDS)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(NOT SMESH_FOUND)
find_package(SMESH REQUIRED)
if(NOT SMESH_FOUND)
message(ERROR "================\n"
"SMESH not found.\n"
"================\n")
endif()
endif()
set (SMESH_INCLUDE_DIR ${SMESH_INCLUDE_PATH})
set(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES})
if(NOT SMESH_FOUND)
message(ERROR "================\n"
"SMESH not found.\n"
"================\n")
endif()
include_directories(${SMESH_INCLUDE_DIR})
endif()
+17 -4
View File
@@ -102,6 +102,7 @@
#include "OriginFeature.h"
#include "OriginGroupExtension.h"
#include "OriginGroupExtensionPy.h"
#include "StringHasherPy.h"
#include "Part.h"
#include "PartPy.h"
#include "Placement.h"
@@ -277,6 +278,7 @@ void Application::setupPythonTypes()
Base::Interpreter().addType(&Base::PlacementPy::Type, pAppModule, "Placement");
Base::Interpreter().addType(&Base::RotationPy::Type, pAppModule, "Rotation");
Base::Interpreter().addType(&Base::AxisPy::Type, pAppModule, "Axis");
Base::Interpreter().addType(&App::StringHasherPy::Type, pAppModule, "StringHasher");
// Note: Create an own module 'Base' which should provide the python
// binding classes from the base module. At a later stage we should
@@ -1127,7 +1129,8 @@ std::string Application::getUserMacroDir()
std::string Application::getResourceDir()
{
#ifdef RESOURCEDIR
std::string path(RESOURCEDIR);
// #6892: Conda may inject null characters => remove them
std::string path = std::string(RESOURCEDIR).c_str();
path.append("/");
QDir dir(QString::fromStdString(path));
if (dir.isAbsolute())
@@ -1141,7 +1144,8 @@ std::string Application::getResourceDir()
std::string Application::getLibraryDir()
{
#ifdef LIBRARYDIR
std::string path(LIBRARYDIR);
// #6892: Conda may inject null characters => remove them
std::string path = std::string(LIBRARYDIR).c_str();
QDir dir(QString::fromStdString(path));
if (dir.isAbsolute())
return path;
@@ -1154,7 +1158,8 @@ std::string Application::getLibraryDir()
std::string Application::getHelpDir()
{
#ifdef DOCDIR
std::string path(DOCDIR);
// #6892: Conda may inject null characters => remove them
std::string path = std::string(DOCDIR).c_str();
path.append("/");
QDir dir(QString::fromStdString(path));
if (dir.isAbsolute())
@@ -1901,6 +1906,9 @@ void Application::initTypes()
Data::ComplexGeoData ::init();
Data::Segment ::init();
App::StringID ::init();
App::StringHasher ::init();
// Properties
App ::Property ::init();
App ::PropertyContainer ::init();
@@ -2160,7 +2168,7 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v
("log-file", value<string>(), "Unlike --write-log this allows logging to an arbitrary file")
("user-cfg,u", value<string>(),"User config file to load/save user settings")
("system-cfg,s", value<string>(),"System config file to load/save system settings")
("run-test,t", value<string>() ,"Test case - or 0 for all")
("run-test,t", value<string>()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests.")
("module-path,M", value< vector<string> >()->composing(),"Additional module paths")
("python-path,P", value< vector<string> >()->composing(),"Additional python paths")
("single-instance", "Allow to run a single instance of the application")
@@ -2394,6 +2402,9 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
if ( "0" == testCase) {
testCase = "TestApp.All";
}
else if (testCase.empty()) {
testCase = "TestApp.PrintAll";
}
mConfig["TestCase"] = testCase;
mConfig["RunMode"] = "Internal";
mConfig["ScriptFileName"] = "FreeCADTest";
@@ -2457,6 +2468,8 @@ void Application::initConfig(int argc, char ** argv)
Branding brand;
QString binDir = QString::fromUtf8((mConfig["AppHomePath"] + "bin").c_str());
QFileInfo fi(binDir, QString::fromLatin1("branding.xml"));
if (!fi.exists())
fi = QFileInfo(binDir, QString::fromLatin1("branding_toponaming.xml"));
if (fi.exists() && brand.readFile(fi.absoluteFilePath())) {
Branding::XmlConfig cfg = brand.getUserDefines();
for (Branding::XmlConfig::iterator it = cfg.begin(); it != cfg.end(); ++it) {
+16 -16
View File
@@ -243,14 +243,14 @@ PyObject* Application::sOpenDocument(PyObject * /*self*/, PyObject *args, PyObje
char* Name;
PyObject *hidden = Py_False;
static char *kwlist[] = {"name","hidden",nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwd, "et|O", kwlist,
"utf-8", &Name, &hidden))
if (!PyArg_ParseTupleAndKeywords(args, kwd, "et|O!", kwlist,
"utf-8", &Name, &PyBool_Type, &hidden))
return nullptr;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
try {
// return new document
return (GetApplication().openDocument(EncodedName.c_str(),!PyObject_IsTrue(hidden))->getPyObject());
return (GetApplication().openDocument(EncodedName.c_str(),PyObject_IsTrue(hidden) ? false : true)->getPyObject());
}
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_IOError, e.what());
@@ -270,14 +270,14 @@ PyObject* Application::sNewDocument(PyObject * /*self*/, PyObject *args, PyObjec
PyObject *hidden = Py_False;
PyObject *temp = Py_False;
static char *kwlist[] = {"name","label","hidden","temp",nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwd, "|etetOO", kwlist,
"utf-8", &docName, "utf-8", &usrName, &hidden, &temp))
if (!PyArg_ParseTupleAndKeywords(args, kwd, "|etetO!O!", kwlist,
"utf-8", &docName, "utf-8", &usrName, &PyBool_Type, &hidden, &PyBool_Type, &temp))
return nullptr;
PY_TRY {
App::Document* doc = GetApplication().newDocument(docName, usrName,
!PyObject_IsTrue(hidden),
PyObject_IsTrue(temp));
PyObject_IsTrue(hidden) ? false : true,
PyObject_IsTrue(temp) ? true : false);
PyMem_Free(docName);
PyMem_Free(usrName);
return doc->getPyObject();
@@ -317,7 +317,7 @@ PyObject* Application::sCloseDocument(PyObject * /*self*/, PyObject *args)
return nullptr;
}
if (GetApplication().closeDocument(pstr) == false) {
if (!GetApplication().closeDocument(pstr)) {
PyErr_Format(PyExc_RuntimeError, "Closing the document '%s' failed", pstr);
return nullptr;
}
@@ -333,7 +333,7 @@ PyObject* Application::sSaveDocument(PyObject * /*self*/, PyObject *args)
Document* doc = GetApplication().getDocument(pDoc);
if ( doc ) {
if ( doc->save() == false ) {
if (!doc->save()) {
PyErr_Format(Base::PyExc_FC_GeneralError, "Cannot save document '%s'", pDoc);
return nullptr;
}
@@ -701,7 +701,7 @@ PyObject* Application::sGetUserMacroPath(PyObject * /*self*/, PyObject *args)
return nullptr;
std::string macroDir = Application::getUserMacroDir();
if (PyObject_IsTrue(actual)) {
if (PyObject_IsTrue(actual) ? true : false) {
macroDir = App::GetApplication().
GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
->GetASCII("MacroPath",macroDir.c_str());
@@ -732,7 +732,7 @@ PyObject* Application::sGetHomePath(PyObject * /*self*/, PyObject *args)
PyObject* Application::sListDocuments(PyObject * /*self*/, PyObject *args)
{
PyObject *sort = Py_False;
if (!PyArg_ParseTuple(args, "|O",&sort))
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &sort))
return nullptr;
PY_TRY {
PyObject *pDict = PyDict_New();
@@ -740,7 +740,7 @@ PyObject* Application::sListDocuments(PyObject * /*self*/, PyObject *args)
Base::PyObjectBase* pValue;
std::vector<Document*> docs = GetApplication().getDocuments();;
if(PyObject_IsTrue(sort))
if(PyObject_IsTrue(sort) ? true : false)
docs = Document::getDependentDocuments(docs,true);
for (auto doc : docs) {
@@ -942,11 +942,11 @@ PyObject *Application::sSetActiveTransaction(PyObject * /*self*/, PyObject *args
{
char *name;
PyObject *persist = Py_False;
if (!PyArg_ParseTuple(args, "s|O", &name,&persist))
if (!PyArg_ParseTuple(args, "s|O!", &name, &PyBool_Type, &persist))
return nullptr;
PY_TRY {
Py::Int ret(GetApplication().setActiveTransaction(name,PyObject_IsTrue(persist)));
Py::Int ret(GetApplication().setActiveTransaction(name,PyObject_IsTrue(persist) ? true : false));
return Py::new_reference_to(ret);
}PY_CATCH;
}
@@ -972,11 +972,11 @@ PyObject *Application::sCloseActiveTransaction(PyObject * /*self*/, PyObject *ar
{
PyObject *abort = Py_False;
int id = 0;
if (!PyArg_ParseTuple(args, "|Oi", &abort,&id))
if (!PyArg_ParseTuple(args, "|O!i", &PyBool_Type, &abort,&id))
return nullptr;
PY_TRY {
GetApplication().closeActiveTransaction(PyObject_IsTrue(abort),id);
GetApplication().closeActiveTransaction(PyObject_IsTrue(abort) ? true : false, id);
Py_Return;
} PY_CATCH;
}
+1
View File
@@ -50,6 +50,7 @@ Branding::Branding()
filter.push_back("SplashAlignment");
filter.push_back("SplashTextColor");
filter.push_back("SplashInfoColor");
filter.push_back("SplashInfoVersion");
filter.push_back("StartWorkbench");
+12
View File
@@ -87,6 +87,8 @@ else()
)
endif()
generate_from_xml(StringIDPy)
generate_from_xml(StringHasherPy)
generate_from_xml(DocumentPy)
generate_from_xml(DocumentObjectPy)
generate_from_xml(ExtensionPy)
@@ -109,6 +111,8 @@ generate_from_py(FreeCADInit InitScript.h)
generate_from_py(FreeCADTest TestScript.h)
SET(FreeCADApp_XML_SRCS
StringIDPy.xml
StringHasherPy.xml
ExtensionPy.xml
ExtensionContainerPy.xml
DocumentObjectExtensionPy.xml
@@ -131,7 +135,11 @@ SOURCE_GROUP("XML" FILES ${FreeCADApp_XML_SRCS})
# The document stuff
SET(Document_CPP_SRCS
Annotation.cpp
StringHasher.cpp
StringHasherPyImp.cpp
StringIDPyImp.cpp
Document.cpp
DocumentParams.cpp
DocumentObject.cpp
Extension.cpp
ExtensionPyImp.cpp
@@ -178,7 +186,9 @@ SET(Document_CPP_SRCS
SET(Document_HPP_SRCS
Annotation.h
StringHasher.h
Document.h
DocumentParams.h
DocumentObject.h
Extension.h
ExtensionContainer.h
@@ -263,6 +273,7 @@ SET(FreeCADApp_CPP_SRCS
AutoTransaction.cpp
Branding.cpp
ColorModel.cpp
MappedElement.cpp
ComplexGeoData.cpp
ComplexGeoDataPyImp.cpp
Enumeration.cpp
@@ -279,6 +290,7 @@ SET(FreeCADApp_HPP_SRCS
AutoTransaction.h
Branding.h
ColorModel.h
MappedElement.h
ComplexGeoData.h
Enumeration.h
Material.h
+2104 -16
View File
File diff suppressed because it is too large Load Diff
+269 -2
View File
@@ -24,9 +24,17 @@
#ifndef _AppComplexGeoData_h_
#define _AppComplexGeoData_h_
#include <cstring>
#include <memory>
#include <cctype>
#include <functional>
#include <QVector>
#include <Base/Handle.h>
#include <Base/Matrix.h>
#include <Base/Persistence.h>
#include "StringHasher.h"
#ifdef __GNUC__
# include <cstdint>
@@ -44,6 +52,16 @@ typedef BoundBox3<double> BoundBox3d;
namespace Data
{
class ElementMap;
typedef std::shared_ptr<ElementMap> ElementMapPtr;
typedef QVector<App::StringIDRef> ElementIDRefs;
class IndexedName;
class MappedName;
struct MappedElement;
struct MappedChildElements;
/** Segments
* Subelement type of the ComplexGeoData type
* It is used to split an object in further sub-parts.
@@ -83,7 +101,7 @@ public:
* List of different subelement types
* its NOT a list of the subelements itself
*/
virtual std::vector<const char*> getElementTypes() const=0;
virtual const std::vector<const char*>& getElementTypes() const=0;
virtual unsigned long countSubElements(const char* Type) const=0;
/// get the subelement by type and number
virtual Segment* getSubElement(const char* Type, unsigned long) const=0;
@@ -165,8 +183,12 @@ public:
//@{
/// Special prefix to mark the beginning of a mapped sub-element name
static const std::string &elementMapPrefix();
/// Special postfix to mark the following tag
/// Special postfix to mark the following tag encoded as hex number
static const std::string &tagPostfix();
/// Special postfix to mark the following tag encoded as decimal number
static const std::string &decTagPostfix();
/// Special postfix to mark the name includes encoding from an external object
static const std::string &externalTagPostfix();
/// Special postfix to mark the index of an array element
static const std::string &indexPostfix();
/// Special prefix to mark a missing element
@@ -191,12 +213,246 @@ public:
/// Find the start of an element name in a subname
static const char *findElementName(const char *subname);
/// Check if the given subname contains element name
static bool hasElementName(const char *subname) {
subname = findElementName(subname);
return subname && *subname;
}
/// Return the element name portion of the subname without mapping prefix
static inline const char *hasMappedElementName(const char *subname) {
return isMappedElement(findElementName(subname));
}
/** Get element indexed name
*
* @param name: the input name
* @param sid: optional output of and App::StringID involved forming this mapped name
*
* @return Returns an indexed name.
*/
IndexedName getIndexedName(const MappedName & name,
ElementIDRefs *sid = nullptr) const;
/** Get element mapped name
*
* @param name: the input name
* @param allowUnmapped: If the queried element is not mapped, then return
* an empty name if \c allowUnmapped is false, or
* else, return the indexed name.
* @param sid: optional output of and App::StringID involved forming this mapped name
* @return Returns the mapped name.
*/
MappedName getMappedName(const IndexedName & element,
bool allowUnmapped = false,
ElementIDRefs *sid = nullptr) const;
/** Return a pair of indexed name and mapped name
*
* @param name: the input name.
* @param sid: optional output of and App::StringID involved forming this
* mapped name
* @param copy: if true, copy the name string, or else use it as constant
* string, and caller must make sure the memory is not freed.
*
* @return Returns the MappedElement which contains both the indexed and
* mapped name.
*
* This function guesses whether the input name is an indexed name or
* mapped, and perform a lookup and return the names found. If the input
* name contains only alphabets and underscore followed by optional digits,
* it will be treated as indexed name. Or else, it will be treated as
* mapped name.
*/
MappedElement getElementName(const char * name,
ElementIDRefs *sid = nullptr,
bool copy = false) const;
/** Get mapped element with a given prefix */
std::vector<MappedElement> getElementNamesWithPrefix(const char *prefix) const;
/** Get mapped element names
*
* @param element: original element name with \c Type + \c Index
* @param needUnmapped: if true, return the original element name if no
* mapping is found
*
* @return a list of mapped names of the give element along with their
* associated string ID references
*/
std::vector<std::pair<MappedName, ElementIDRefs> >
getElementMappedNames(const IndexedName & element, bool needUnmapped=false) const;
/** Add a sub-element name mapping.
*
* @param element: the original \c Type + \c Index element name
* @param name: the mapped sub-element name. May or may not start with
* elementMapPrefix().
* @param sid: in case you use a hasher to hash the element name, pass in
* the string id reference using this parameter. You can have more than one
* string id associated with the same name.
* @param overwrite: if true, it will overwrite existing names
*
* @return Returns the stored mapped element name.
*
* An element can have multiple mapped names. However, a name can only be
* mapped to one element
*/
MappedName setElementName(const IndexedName & element,
const MappedName & name,
const ElementIDRefs * sid = nullptr,
bool overwrite = false);
void setMappedChildElements(const std::vector<MappedChildElements> & children);
std::vector<MappedChildElements> getMappedChildElements() const;
/** Convenience method to hash the main element name
*
* @param name: main element name
* @param sid: store any output string ID references
* @return the hashed element name;
*/
MappedName hashElementName(const MappedName & name, ElementIDRefs &sid) const;
/// Hash the child element map postfixes to shorten element name from hierarchical maps
void hashChildMaps();
/// Check if there is child element map
bool hasChildElementMap() const;
/// Reverse hashElementName()
MappedName dehashElementName(const MappedName & name) const;
/// Append the Tag (if and only if it is non zero) into the element map
virtual void reTagElementMap(long tag, App::StringHasherRef hasher, const char *postfix=0) {
(void)tag;
(void)hasher;
(void)postfix;
}
long getElementHistory(const char *name,
MappedName *original=0, std::vector<MappedName> *history=0) const;
long getElementHistory(const MappedName & name,
MappedName *original=0, std::vector<MappedName> *history=0) const;
void encodeElementName(char element_type, MappedName & name, std::ostringstream &ss,
ElementIDRefs *sids, const char* postfix=0, long tag=0, bool forceTag=false) const;
char elementType(const Data::MappedName &) const;
char elementType(const Data::IndexedName &) const;
char elementType(const char *name) const;
/** Reset/swap the element map
*
* @param elementMap: optional new element map
*
* @return Returns the existing element map.
*/
virtual ElementMapPtr resetElementMap(ElementMapPtr elementMap=ElementMapPtr()) {
_ElementMap.swap(elementMap);
return elementMap;
}
/// Get the entire element map
std::vector<MappedElement> getElementMap() const;
/// Set the entire element map
void setElementMap(const std::vector<MappedElement> &elements);
/// Get the current element map size
size_t getElementMapSize(bool flush=true) const;
/// Return the higher level element names of the given element
virtual std::vector<IndexedName> getHigherElements(const char *name, bool silent=false) const;
/// Return the current element map version
virtual std::string getElementMapVersion() const;
/// Return true to signal element map version change
virtual bool checkElementMapVersion(const char * ver) const;
/// Check if the given subname only contains an element name
static bool isElementName(const char *subname) {
return subname && *subname && findElementName(subname)==subname;
}
/** Extract tag and other information from a encoded element name
*
* @param name: encoded element name
* @param tag: optional pointer to receive the extracted tag
* @param len: optional pointer to receive the length field after the tag field.
* This gives the length of the previous hashsed element name starting
* from the beginning of the give element name.
* @param postfix: optional pointer to receive the postfix starting at the found tag field.
* @param type: optional pointer to receive the element type character
* @param negative: return negative tag as it is. If disabled, then always return positive tag.
* Negative tag is sometimes used for element disambiguation.
* @param recursive: recursively find the last non-zero tag
*
* @return Return the end position of the tag field, or return -1 if not found.
*/
static int findTagInElementName(const MappedName & name,
long *tag=0,
int *len=0,
std::string *postfix=0,
char *type=0,
bool negative=false,
bool recursive=true);
/** Element trace callback
*
* The callback has the following call signature
* (const std::string &name, size_t offset, long encodedTag, long tag) -> bool
*
* @param name: the current element name.
* @param offset: the offset skipping the encoded element name for the next iteration.
* @param encodedTag: the tag encoded inside the current element, which is usually the tag
* of the previous step in the shape history.
* @param tag: the tag of the current shape element.
*
* @sa traceElement()
*/
typedef std::function<bool(const MappedName &, int, long, long)> TraceCallback;
/** Iterate through the history of the give element name with a given callback
*
* @param name: the input element name
* @param cb: trace callback with call signature.
* @sa TraceCallback
*/
void traceElement(const MappedName &name, TraceCallback cb) const;
/** Flush an internal buffering for element mapping */
virtual void flushElementMap() const;
virtual unsigned long getElementMapReserve() const { return 0; }
//@}
/** @name Save/restore */
//@{
void Save (Base::Writer &writer) const;
void Restore(Base::XMLReader &reader);
void SaveDocFile(Base::Writer &writer) const;
void RestoreDocFile(Base::Reader &reader);
unsigned int getMemSize (void) const;
void setPersistenceFileName(const char *name) const;
virtual void beforeSave() const;
bool isRestoreFailed() const { return _restoreFailed; }
void resetRestoreFailure() const { _restoreFailed = true; }
//@}
public:
/// String hasher for element name shortening
mutable App::StringHasherRef Hasher;
protected:
virtual MappedName renameDuplicateElement(int index,
const IndexedName & element,
const IndexedName & element2,
const MappedName & name,
ElementIDRefs &sids);
void restoreStream(std::istream &s, std::size_t count);
/// from local to outside
inline Base::Vector3d transformToOutside(const Base::Vector3f& vec) const
@@ -215,8 +471,19 @@ protected:
static_cast<float>(tmp.y),
static_cast<float>(tmp.z));
}
public:
mutable long Tag;
protected:
ElementMapPtr elementMap(bool flush=true) const;
protected:
mutable std::string _PersistenceName;
mutable bool _restoreFailed = false;
private:
ElementMapPtr _ElementMap;
};
} //namespace App
+61
View File
@@ -64,6 +64,37 @@
<UserDocu>Apply a transformation to the underlying geometry</UserDocu>
</Documentation>
</Methode>
<Methode Name="setElementName" Keyword="true">
<Documentation>
<UserDocu>
setElementName(element,name=None,postfix=None,overwrite=False,sid=None), Set an element name
element : the original element name, e.g. Edge1, Vertex2
name : the new name for the element, None to remove the mapping
postfix : postfix of the name that will not be hashed
overwrite: if true, it will overwrite exiting name
sid : to hash the name any way you want, provide your own string id(s) in this parameter
An element can have multiple mapped names. However, a name can only be mapped
to one element
</UserDocu>
</Documentation>
</Methode>
<Methode Name="getElementName" Const="true">
<Documentation>
<UserDocu>getElementName(name,direction=0) - Return a mapped element name or reverse</UserDocu>
</Documentation>
</Methode>
<Methode Name="getElementIndexedName" Const="true">
<Documentation>
<UserDocu>getElementIndexedName(name) - Return the indexed element name</UserDocu>
</Documentation>
</Methode>
<Methode Name="getElementMappedName" Const="true">
<Documentation>
<UserDocu>getElementMappedName(name) - Return the mapped element name</UserDocu>
</Documentation>
</Methode>
<Attribute Name="BoundBox" ReadOnly="true">
<Documentation>
<UserDocu>Get the BoundBox of the object</UserDocu>
@@ -88,5 +119,35 @@
</Documentation>
<Parameter Name="Tag" Type="Int"/>
</Attribute>
<Attribute Name="Hasher">
<Documentation>
<UserDocu>Get/Set the string hasher of this object</UserDocu>
</Documentation>
<Parameter Name="Hasher" Type="Object" />
</Attribute>
<Attribute Name="ElementMapSize" ReadOnly="true">
<Documentation>
<UserDocu>Get the current element map size</UserDocu>
</Documentation>
<Parameter Name="ElementMapSize" Type="Int" />
</Attribute>
<Attribute Name="ElementMap">
<Documentation>
<UserDocu>Get/Set a dict of element mapping</UserDocu>
</Documentation>
<Parameter Name="ElementMap" Type="Dict" />
</Attribute>
<Attribute Name="ElementReverseMap" ReadOnly="true">
<Documentation>
<UserDocu>Get a dict of element reverse mapping</UserDocu>
</Documentation>
<Parameter Name="ElementReverseMap" Type="Dict" />
</Attribute>
<Attribute Name="ElementMapVersion" ReadOnly="true">
<Documentation>
<UserDocu>Element map version</UserDocu>
</Documentation>
<Parameter Name="ElementMapVersion" Type="String" />
</Attribute>
</PythonExport>
</GenerateModel>
+187 -3
View File
@@ -27,6 +27,7 @@
#endif
#include "ComplexGeoData.h"
#include "MappedElement.h"
// inclusion of the generated files (generated out of ComplexGeoDataPy.xml)
#include <App/ComplexGeoDataPy.h>
@@ -36,6 +37,8 @@
#include <Base/PlacementPy.h>
#include <Base/VectorPy.h>
#include <Base/GeometryPyCXX.h>
#include <App/StringHasherPy.h>
#include <App/StringIDPy.h>
using namespace Data;
using namespace Base;
@@ -51,10 +54,9 @@ PyObject* ComplexGeoDataPy::getElementTypes(PyObject *args)
if (!PyArg_ParseTuple(args, ""))
return nullptr;
std::vector<const char*> types = getComplexGeoDataPtr()->getElementTypes();
Py::List list;
for (auto it : types) {
list.append(Py::String(it));
for (const auto &type : getComplexGeoDataPtr()->getElementTypes()) {
list.append(Py::String(type));
}
return Py::new_reference_to(list);
}
@@ -302,6 +304,183 @@ PyObject* ComplexGeoDataPy::transformGeometry(PyObject *args)
}
}
PyObject* ComplexGeoDataPy::getElementName(PyObject *args)
{
char* input;
int direction = 0;
if (!PyArg_ParseTuple(args, "s|i", &input,&direction))
return NULL;
Data::MappedElement res = getComplexGeoDataPtr()->getElementName(input);
std::string s;
if (direction == 1)
return Py::new_reference_to(Py::String(res.name.toString(s)));
else if (direction == 0)
return Py::new_reference_to(Py::String(res.index.toString(s)));
else if (Data::IndexedName(input))
return Py::new_reference_to(Py::String(res.name.toString(s)));
else
return Py::new_reference_to(Py::String(res.index.toString(s)));
}
PyObject* ComplexGeoDataPy::getElementIndexedName(PyObject *args)
{
char* input;
PyObject *returnID = Py_False;
if (!PyArg_ParseTuple(args, "s|O", &input,&returnID))
return NULL;
ElementIDRefs ids;
Data::MappedElement res = getComplexGeoDataPtr()->getElementName(
input, PyObject_IsTrue(returnID)?&ids:nullptr);
std::string s;
Py::String name(res.index.toString(s));
if (!PyObject_IsTrue(returnID))
return Py::new_reference_to(name);
Py::List list;
for (auto &id : ids)
list.append(Py::Long(id.value()));
return Py::new_reference_to(Py::TupleN(name, list));
}
PyObject* ComplexGeoDataPy::getElementMappedName(PyObject *args)
{
char* input;
PyObject *returnID = Py_False;
if (!PyArg_ParseTuple(args, "s|O", &input,&returnID))
return NULL;
ElementIDRefs ids;
Data::MappedElement res = getComplexGeoDataPtr()->getElementName(
input, PyObject_IsTrue(returnID)?&ids:nullptr);
std::string s;
Py::String name(res.name.toString(s));
if (!PyObject_IsTrue(returnID))
return Py::new_reference_to(name);
Py::List list;
for (auto &id : ids)
list.append(Py::Long(id.value()));
return Py::new_reference_to(Py::TupleN(name, list));
}
PyObject *ComplexGeoDataPy::setElementName(PyObject *args, PyObject *kwds) {
const char *element;
const char *name = 0;
const char *postfix = 0;
int tag = 0;
PyObject *pySid = Py_None;
PyObject *overwrite = Py_False;
static char *kwlist[] = {"element", "name", "postfix", "overwrite", "sid", "tag", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|sssOOi", kwlist,
&element,&name,&postfix,&overwrite,&pySid,&tag))
return NULL;
ElementIDRefs sids;
if(pySid != Py_None) {
if(PyObject_TypeCheck(pySid,&App::StringIDPy::Type))
sids.push_back(static_cast<App::StringIDPy*>(pySid)->getStringIDPtr());
else if(PySequence_Check(pySid)) {
Py::Sequence seq(pySid);
for(auto it=seq.begin();it!=seq.end();++it) {
auto ptr = (*it).ptr();
if(PyObject_TypeCheck(ptr,&App::StringIDPy::Type))
sids.push_back(static_cast<App::StringIDPy*>(ptr)->getStringIDPtr());
else
throw Py::TypeError("expect StringID in sid sequence");
}
} else
throw Py::TypeError("expect sid to contain either StringID or sequence of StringID");
}
PY_TRY {
Data::IndexedName index(element, getComplexGeoDataPtr()->getElementTypes());
Data::MappedName mapped = Data::MappedName::fromRawData(name);
std::ostringstream ss;
getComplexGeoDataPtr()->encodeElementName(getComplexGeoDataPtr()->elementType(index),
mapped, ss, &sids, postfix, tag);
Data::MappedName res = getComplexGeoDataPtr()->setElementName(
index, mapped, &sids, PyObject_IsTrue(overwrite));
return Py::new_reference_to(Py::String(res.toString(0)));
}PY_CATCH
}
Py::Object ComplexGeoDataPy::getHasher() const {
auto self = getComplexGeoDataPtr();
if(!self->Hasher)
return Py::None();
return Py::Object(self->Hasher->getPyObject(),true);
}
Py::Dict ComplexGeoDataPy::getElementMap() const {
Py::Dict ret;
std::string s;
for(auto &v : getComplexGeoDataPtr()->getElementMap()) {
s.clear();
ret.setItem(v.name.toString(0), Py::String(v.index.toString(s)));
}
return ret;
}
void ComplexGeoDataPy::setElementMap(Py::Dict dict) {
std::vector<Data::MappedElement> map;
const auto & types = getComplexGeoDataPtr()->getElementTypes();
for(auto it=dict.begin();it!=dict.end();++it) {
const auto &value = *it;
if(!value.first.isString() || !value.second.isString())
throw Py::TypeError("expect only strings in the dict");
map.emplace_back(Data::MappedName(value.first.as_string().c_str()),
Data::IndexedName(Py::Object(value.second).as_string().c_str(), types));
}
getComplexGeoDataPtr()->setElementMap(map);
}
Py::Dict ComplexGeoDataPy::getElementReverseMap() const {
Py::Dict ret;
std::string s;
for(auto &v : getComplexGeoDataPtr()->getElementMap()) {
s.clear();
auto value = ret[Py::String(v.index.toString(s))];
Py::Object item(value);
if(item.isNone()) {
s.clear();
value = Py::String(v.name.toString(s));
} else if(item.isList()) {
Py::List list(item);
s.clear();
list.append(Py::String(v.name.toString(s)));
} else {
Py::List list;
list.append(item);
s.clear();
list.append(Py::String(v.name.toString(s)));
value = list;
}
}
return ret;
}
Py::Int ComplexGeoDataPy::getElementMapSize() const {
return Py::Int((long)getComplexGeoDataPtr()->getElementMapSize());
}
void ComplexGeoDataPy::setHasher(Py::Object obj) {
auto self = getComplexGeoDataPtr();
if(obj.isNone()) {
if(self->Hasher) {
self->Hasher = App::StringHasherRef();
self->resetElementMap();
}
}else if(PyObject_TypeCheck(obj.ptr(),&App::StringHasherPy::Type)) {
App::StringHasherRef ref(static_cast<App::StringHasherPy*>(obj.ptr())->getStringHasherPtr());
if(self->Hasher != ref) {
self->Hasher = ref;
self->resetElementMap();
}
}else
throw Py::TypeError("invalid type");
}
Py::Object ComplexGeoDataPy::getBoundBox() const
{
return Py::BoundingBox(getComplexGeoDataPtr()->getBoundBox());
@@ -334,6 +513,11 @@ void ComplexGeoDataPy::setPlacement(Py::Object arg)
}
}
Py::String ComplexGeoDataPy::getElementMapVersion() const
{
return Py::String(getComplexGeoDataPtr()->getElementMapVersion());
}
Py::Int ComplexGeoDataPy::getTag() const
{
return Py::Int(getComplexGeoDataPtr()->Tag);
+214 -37
View File
@@ -65,6 +65,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include <boost/algorithm/string.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/bimap.hpp>
#include <boost/graph/strong_components.hpp>
#ifdef USE_OLD_DAG
@@ -95,6 +96,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include <Base/Stream.h>
#include "Document.h"
#include "DocumentParams.h"
#include "Application.h"
#include "AutoTransaction.h"
#include "DocumentObserver.h"
@@ -106,6 +108,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include "MergeDocuments.h"
#include "Origin.h"
#include "OriginGroupExtension.h"
#include "StringHasher.h"
#include "Transactions.h"
#ifdef _MSC_VER
@@ -116,7 +119,6 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include <zipios++/zipoutputstream.h>
#include <zipios++/meta-iostreams.h>
FC_LOG_LEVEL_INIT("App", true, true, true)
using Base::Console;
@@ -151,8 +153,10 @@ typedef std::vector <size_t> Path;
namespace App {
typedef boost::bimap<StringHasherRef,int> HasherMap;
static bool _IsRestoring;
static bool _IsRelabeling;
// Pimpl class
struct DocumentP
{
@@ -178,6 +182,7 @@ struct DocumentP
unsigned int UndoMemSize;
unsigned int UndoMaxStackSize;
std::string programVersion;
mutable HasherMap hashers;
#ifdef USE_OLD_DAG
DependencyList DepList;
std::map<DocumentObject*,Vertex> VertexObjectList;
@@ -186,7 +191,15 @@ struct DocumentP
std::multimap<const App::DocumentObject*,
std::unique_ptr<App::DocumentObjectExecReturn> > _RecomputeLog;
StringHasherRef Hasher;
// restored files
std::set<std::string> files;
DocumentP() {
#ifdef FC_NO_RANDOM_ID
lastObjectId = 10;
#else
static std::random_device _RD;
static std::mt19937 _RGEN(_RD());
static std::uniform_int_distribution<> _RDIST(0,5000);
@@ -194,6 +207,8 @@ struct DocumentP
// copying shape from other document. It is probably better to randomize
// on each object ID.
lastObjectId = _RDIST(_RGEN);
#endif
Hasher.reset(new StringHasher);
activeObject = nullptr;
activeUndoTransaction = nullptr;
iTransactionMode = 0;
@@ -1466,7 +1481,6 @@ void Document::onChanged(const Property* prop)
// the Name property is a label for display purposes
if (prop == &Label) {
Base::FlagToggler<> flag(_IsRelabeling);
App::GetApplication().signalRelabelDocument(*this);
} else if(prop == &ShowHidden) {
App::GetApplication().signalShowHidden(*this);
@@ -1501,6 +1515,12 @@ void Document::onChanged(const Property* prop)
// recursive call of onChanged()
this->Uid.setValue(id);
}
} else if(prop == &UseHasher) {
for(auto obj : d->objectArray) {
auto geofeature = dynamic_cast<GeoFeature*>(obj);
if(geofeature && geofeature->getPropertyOfGeometry())
geofeature->enforceRecompute();
}
}
}
@@ -1508,8 +1528,8 @@ void Document::onBeforeChangeProperty(const TransactionalObject *Who, const Prop
{
if(Who->isDerivedFrom(App::DocumentObject::getClassTypeId()))
signalBeforeChangeObject(*static_cast<const App::DocumentObject*>(Who), *What);
if(!d->rollback && !_IsRelabeling) {
_checkTransaction(nullptr,What,__LINE__);
if(!d->rollback) {
_checkTransaction(nullptr, What, __LINE__);
if (d->activeUndoTransaction)
d->activeUndoTransaction->addObjectChange(Who,What);
}
@@ -1544,10 +1564,8 @@ Document::Document(const char *name)
Console().Log("+App::Document: %p\n",this);
#endif
std::string CreationDateString = Base::TimeInfo::currentDateTimeString();
std::string Author = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefAuthor","");
std::string AuthorComp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefCompany","");
std::string Author = DocumentParams::getprefAuthor();
std::string AuthorComp = DocumentParams::getprefCompany();
ADD_PROPERTY_TYPE(Label,("Unnamed"),0,Prop_None,"The name of the document");
ADD_PROPERTY_TYPE(FileName,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly),"The path to the file where the document is saved to");
ADD_PROPERTY_TYPE(CreatedBy,(Author.c_str()),0,Prop_None,"The creator of the document");
@@ -1568,8 +1586,7 @@ Document::Document(const char *name)
ADD_PROPERTY_TYPE(LicenseURL,("http://creativecommons.org/licenses/by/3.0/"),0,Prop_None,"URL to the license text/contract");
// license stuff
int licenseId = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetInt("prefLicenseType",0);
int licenseId = DocumentParams::getprefLicenseType();
std::string license;
std::string licenseUrl;
switch (licenseId) {
@@ -1614,13 +1631,17 @@ Document::Document(const char *name)
break;
}
licenseUrl = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetASCII("prefLicenseUrl", licenseUrl.c_str());
if(DocumentParams::getprefLicenseUrl().empty())
licenseUrl = DocumentParams::getprefLicenseUrl();
ADD_PROPERTY_TYPE(License,(license.c_str()),0,Prop_None,"License string of the Item");
ADD_PROPERTY_TYPE(LicenseURL,(licenseUrl.c_str()),0,Prop_None,"URL to the license text/contract");
ADD_PROPERTY_TYPE(ShowHidden,(false), 0,PropertyType(Prop_None),
"Whether to show hidden object items in the tree view");
ADD_PROPERTY_TYPE(UseHasher,(true), 0,PropertyType(Prop_Hidden),
"Whether to use hasher on topological naming");
if(!DocumentParams::getUseHasher())
UseHasher.setValue(false);
// this creates and sets 'TransientDir' in onChanged()
ADD_PROPERTY_TYPE(TransientDir,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly),
@@ -1690,11 +1711,31 @@ std::string Document::getTransientDirectoryName(const std::string& uuid, const s
void Document::Save (Base::Writer &writer) const
{
d->hashers.clear();
addStringHasher(d->Hasher);
writer.Stream() << "<Document SchemaVersion=\"4\" ProgramVersion=\""
<< App::Application::Config()["BuildVersionMajor"] << "."
<< App::Application::Config()["BuildVersionMinor"] << "R"
<< App::Application::Config()["BuildRevision"]
<< "\" FileVersion=\"" << writer.getFileVersion() << "\">" << endl;
<< "\" FileVersion=\"" << writer.getFileVersion()
<< "\" Uid=\"" << Uid.getValueStr()
<< "\" StringHasher=\"1\">\n";
writer.incInd();
if (writer.isForceXML())
d->Hasher->setPersistenceFileName(0);
else
d->Hasher->setPersistenceFileName("StringHasher.Table");
for (auto o : d->objectArray)
o->beforeSave();
beforeSave();
d->Hasher->Save(writer);
writer.decInd();
PropertyContainer::Save(writer);
@@ -1706,7 +1747,12 @@ void Document::Save (Base::Writer &writer) const
void Document::Restore(Base::XMLReader &reader)
{
int i,Cnt;
d->hashers.clear();
d->touchedObjs.clear();
addStringHasher(d->Hasher);
Base::ReaderContext rctx(getName());
setStatus(Document::PartialDoc,false);
reader.readElement("Document");
@@ -1723,6 +1769,11 @@ void Document::Restore(Base::XMLReader &reader)
reader.FileVersion = 0;
}
if (reader.hasAttribute("StringHasher")) {
Base::ReaderContext rctx("StringHasher");
d->Hasher->Restore(reader);
} else
d->Hasher->clear();
// When this document was created the FileName and Label properties
// were set to the absolute path or file name, respectively. To save
// the document to the file it was loaded from or to show the file name
@@ -1765,6 +1816,7 @@ void Document::Restore(Base::XMLReader &reader)
for (i=0 ;i<Cnt ;i++) {
reader.readElement("Feature");
string name = reader.getAttribute("name");
Base::ReaderContext rctx(name);
DocumentObject* pObj = getObject(name.c_str());
if (pObj) { // check if this feature has been registered
pObj->setStatus(ObjectStatus::Restore, true);
@@ -1787,6 +1839,36 @@ void Document::Restore(Base::XMLReader &reader)
reader.readEndElement("Document");
}
std::pair<bool,int> Document::addStringHasher(const StringHasherRef & hasher) const {
if (!hasher)
return std::make_pair(false, 0);
auto ret = d->hashers.left.insert(HasherMap::left_map::value_type(hasher,(int)d->hashers.size()));
if (ret.second)
hasher->clearMarks();
return std::make_pair(ret.second,ret.first->second);
}
StringHasherRef Document::getHasher() const {
return d->Hasher;
}
StringHasherRef Document::getStringHasher(int idx) const {
StringHasherRef hasher;
if(idx<0) {
if(UseHasher.getValue())
return d->Hasher;
return hasher;
}
auto it = d->hashers.right.find(idx);
if(it == d->hashers.right.end()) {
hasher = new StringHasher;
d->hashers.right.insert(HasherMap::right_map::value_type(idx,hasher));
}else
hasher = it->second;
return hasher;
}
struct DocExportStatus {
Document::ExportStatus status;
std::set<const App::DocumentObject*> objs;
@@ -1823,6 +1905,7 @@ Document::ExportStatus Document::isExporting(const App::DocumentObject *obj) con
void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, std::ostream& out) {
DocumentExporting exporting(obj);
d->hashers.clear();
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) {
for(auto o : obj) {
@@ -1859,6 +1942,7 @@ void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, std::
// write additional files
writer.writeFiles();
d->hashers.clear();
}
#define FC_ATTR_DEPENDENCIES "Dependencies"
@@ -2162,14 +2246,16 @@ Document::readObjects(Base::XMLReader& reader)
void Document::addRecomputeObject(DocumentObject *obj) {
if(testStatus(Status::Restoring) && obj) {
setStatus(Status::RecomputeOnRestore, true);
d->touchedObjs.insert(obj);
obj->touch();
obj->enforceRecompute();
}
}
std::vector<App::DocumentObject*>
Document::importObjects(Base::XMLReader& reader)
{
d->hashers.clear();
Base::FlagToggler<> flag(_IsRestoring,false);
Base::ObjectStatusLocker<Status, Document> restoreBit(Status::Restoring, this);
Base::ObjectStatusLocker<Status, Document> restoreBit2(Status::Importing, this);
@@ -2188,6 +2274,7 @@ Document::importObjects(Base::XMLReader& reader)
reader.FileVersion = 0;
}
Base::ReaderContext rctx(getName());
std::vector<App::DocumentObject*> objs = readObjects(reader);
for(auto o : objs) {
if(o && o->getNameInDocument()) {
@@ -2220,7 +2307,7 @@ Document::importObjects(Base::XMLReader& reader)
if(o && o->getNameInDocument())
o->setStatus(App::ObjImporting,false);
}
d->hashers.clear();
return objs;
}
@@ -2233,6 +2320,8 @@ unsigned int Document::getMemSize (void) const
for (it = d->objectArray.begin(); it != d->objectArray.end(); ++it)
size += (*it)->getMemSize();
size += d->Hasher->getMemSize();
// size of the document properties...
size += PropertyContainer::getMemSize();
@@ -2402,7 +2491,7 @@ private:
fn = str.str();
}
if (fi.renameFile(fn.c_str()) == false)
if (!fi.renameFile(fn.c_str()))
Base::Console().Warning("Cannot rename project file to backup file\n");
}
else {
@@ -2411,7 +2500,7 @@ private:
}
Base::FileInfo tmp(sourcename);
if (tmp.renameFile(targetname.c_str()) == false) {
if (!tmp.renameFile(targetname.c_str())) {
throw Base::FileException(
"Cannot rename tmp save file to project file", targetname);
}
@@ -2511,7 +2600,7 @@ private:
}
}
else {
if (renameFileNoErase(fi, fn+".FCBak") == false) {
if (!renameFileNoErase(fi, fn+".FCBak")) {
fn = fn + "-";
}
else {
@@ -2555,7 +2644,7 @@ private:
}
Base::FileInfo tmp(sourcename);
if (tmp.renameFile(targetname.c_str()) == false) {
if (!tmp.renameFile(targetname.c_str())) {
throw Base::FileException(
"Save interrupted: Cannot rename temporary file to project file", tmp);
}
@@ -2699,6 +2788,37 @@ bool Document::saveToFile(const char* filename) const
return true;
}
void Document::save(Base::Writer &writer, bool archive) const {
(void)archive;
writer.putNextEntry("Document.xml");
auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document");
if (hGrp->GetBool("SaveBinaryBrep", false)) {
writer.setMode("BinaryBrep");
writer.setPreferBinary(true);
} else if(writer.getFileVersion() > 1)
writer.setPreferBinary(false);
writer.Stream() << "<?xml version='1.0' encoding='utf-8'?>\n"
<< "<!--\n"
<< " FreeCAD Document, see http://www.freecadweb.org for more information...\n"
<< "-->\n";
Document::Save(writer);
// Special handling for Gui document.
signalSaveDocument(writer);
// write additional files
writer.writeFiles();
if (writer.hasErrors()) {
throw Base::FileException("Failed to write all data to file");
}
GetApplication().signalSaveDocument(*this);
}
bool Document::isAnyRestoring() {
return _IsRestoring;
}
@@ -2707,8 +2827,48 @@ bool Document::isAnyRestoring() {
void Document::restore (const char *filename,
bool delaySignal, const std::vector<std::string> &objNames)
{
if(!filename)
filename = FileName.getValue();
Base::FileInfo fi(filename);
if(fi.isDir()) {
fi.setFile(std::string(filename)+'/'+"Document.xml");
if(!fi.exists())
throw Base::FileException("Project file not found",fi.filePath());
}
std::unique_ptr<Base::Reader> _reader;
std::unique_ptr<Base::XMLReader> _xmlReader;
std::unique_ptr<zipios::ZipInputStream> zipstream;
std::string dirname;
if(fi.fileNamePure() == "Document" && fi.hasExtension("xml")) {
Base::FileInfo di(fi.dirPath());
_reader.reset(new Base::FileReader(fi,di.fileName()+"/Document.xml"));
_xmlReader.reset(new Base::XMLReader(*_reader));
} else {
// file.open(fi, std::ios::in | std::ios::binary);
// std::streambuf* buf = file.rdbuf();
// std::streamoff size = buf->pubseekoff(0, std::ios::end, std::ios::in);
// buf->pubseekoff(0, std::ios::beg, std::ios::in);
// if (size < 22) // an empty zip archive has 22 bytes
// throw Base::FileException("Invalid project file",filename);
zipstream.reset(new zipios::ZipInputStream(filename));
_reader.reset(new Base::ZipReader(*zipstream,filename));
_xmlReader.reset(new Base::XMLReader(*_reader));
}
restore(*_xmlReader, delaySignal, objNames);
}
void Document::restore(Base::XMLReader &reader,
bool delaySignal, const std::vector<std::string> &objNames)
{
if (!reader.isValid())
throw Base::FileException("Error reading project file", FileName.getValue());
clearUndos();
d->activeObject = nullptr;
d->files.clear();
bool signal = false;
Document *activeDoc = GetApplication().getActiveDocument();
@@ -2734,21 +2894,6 @@ void Document::restore (const char *filename,
GetApplication().setActiveDocument(this);
}
if(!filename)
filename = FileName.getValue();
Base::FileInfo fi(filename);
Base::ifstream file(fi, std::ios::in | std::ios::binary);
std::streambuf* buf = file.rdbuf();
std::streamoff size = buf->pubseekoff(0, std::ios::end, std::ios::in);
buf->pubseekoff(0, std::ios::beg, std::ios::in);
if (size < 22) // an empty zip archive has 22 bytes
throw Base::FileException("Invalid project file",filename);
zipios::ZipInputStream zipstream(file);
Base::XMLReader reader(filename, zipstream);
if (!reader.isValid())
throw Base::FileException("Error reading compression file",filename);
GetApplication().signalStartRestoreDocument(*this);
setStatus(Document::Restoring, true);
@@ -2758,6 +2903,8 @@ void Document::restore (const char *filename,
d->partialLoadObjects.emplace(name,true);
try {
Document::Restore(reader);
} catch (const Base::XMLParseException &) {
throw;
} catch (const Base::Exception& e) {
Base::Console().Error("Invalid Document.xml: %s\n", e.what());
setStatus(Document::RestoreError, true);
@@ -2771,7 +2918,13 @@ void Document::restore (const char *filename,
// Note: This file doesn't need to be available if the document has been created
// without GUI. But if available then follow after all data files of the App document.
signalRestoreDocument(reader);
reader.readFiles(zipstream);
reader.readFiles();
for(auto &f : reader.getFilenames()) {
FC_TRACE("document " << getName() << " file: " << f);
d->files.insert(f);
}
if (reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestore)) {
setStatus(Document::PartialRestore, true);
@@ -2919,10 +3072,19 @@ const char* Document::getName() const
return myName.c_str();
}
std::string Document::getFullName() const {
std::string Document::getFullName(bool python) const {
if(python) {
std::ostringstream ss;
ss << "FreeCAD.getDocument('" << myName << "')";
return ss.str();
}
return myName;
}
App::Document *Document::getOwnerDocument() const {
return const_cast<App::Document*>(this);
}
const char* Document::getProgramVersion() const
{
return d->programVersion.c_str();
@@ -3762,6 +3924,21 @@ const char * Document::getErrorDescription(const App::DocumentObject*Obj) const
return d->findRecomputeLog(Obj);
}
void Document::setErrorDescription(App::DocumentObject *Obj, const char *msg)
{
if (msg && msg[0] && Obj)
d->addRecomputeLog(msg, Obj);
}
void Document::setErrorDescription(App::Property *Prop, const char *msg)
{
if (msg && msg[0] && Prop) {
auto obj = Base::freecad_dynamic_cast<DocumentObject>(Prop->getContainer());
if (obj)
d->addRecomputeLog(msg, obj);
}
}
// call the recompute of the Feature and handle the exceptions and errors.
int Document::_recomputeFeature(DocumentObject* Feat)
{
+60 -3
View File
@@ -23,13 +23,22 @@
#ifndef APP_DOCUMENT_H
#define APP_DOCUMENT_H
#include <CXX/Objects.hxx>
#include <Base/Observer.h>
#include <Base/Persistence.h>
#include <Base/Type.h>
#include <Base/Handle.h>
#include "PropertyContainer.h"
#include "PropertyLinks.h"
#include "PropertyStandard.h"
#include <memory>
#include <map>
#include <vector>
class QByteArray;
namespace Base {
class Writer;
}
@@ -43,6 +52,8 @@ namespace App
class DocumentPy; // the python document class
class Application;
class Transaction;
class StringHasher;
typedef Base::Reference<StringHasher> StringHasherRef;
}
namespace App
@@ -68,6 +79,7 @@ public:
RestoreError = 10,
LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed
IgnoreErrorOnRecompute = 12, // Don't report errors if the recompute failed
RecomputeOnRestore = 13, // Mark pending recompute on restore for migration purpose
};
/** @name Properties */
@@ -109,6 +121,8 @@ public:
PropertyString TipName;
/// Whether to show hidden items in TreeView
PropertyBool ShowHidden;
/// Whether to use hasher on topological naming
PropertyBool UseHasher;
//@}
/** @name Signals of the document */
@@ -186,11 +200,13 @@ public:
bool save (void);
bool saveAs(const char* file);
bool saveCopy(const char* file) const;
void save(Base::Writer &writer, bool archive) const;
/// Restore the document from the file in Property Path
void restore (const char *filename=nullptr,
bool delaySignal=false, const std::vector<std::string> &objNames={});
bool afterRestore(bool checkPartial=false);
bool afterRestore(const std::vector<App::DocumentObject *> &, bool checkPartial=false);
/// Restore the document from a pre-constructed xml reader
void restore (Base::XMLReader &xmlReader,
bool delaySignal=false, const std::vector<std::string> &objNames={});
enum ExportStatus {
NotExporting,
Exporting,
@@ -343,6 +359,10 @@ public:
bool recomputeFeature(DocumentObject* Feat,bool recursive=false);
/// get the text of the error of a specified object
const char* getErrorDescription(const App::DocumentObject*) const;
/// set the text of the error of a specified object
void setErrorDescription(App::DocumentObject *, const char *);
/// set the text of the error of a specified object
void setErrorDescription(App::Property *, const char *);
/// return the status bits
bool testStatus(Status pos) const;
/// set the status bits
@@ -467,6 +487,38 @@ public:
(const App::DocumentObject* from, const App::DocumentObject* to) const;
//@}
/** Called by property during properly save its containing StringHasher
*
* @param hasher: the input hasher
* @return Returns a pair<bool,int>. Boolean member indicate if the
* StringHasher has been saved before. The Integer is the hasher index.
*
* The StringHasher object is designed to be shared among multiple objects.
* So, we must not save duplicate copies of the same hasher. And must be
* able to restore with the same sharing relationship. This function returns
* whether the hasher has been saved before by other objects, and the index
* of the hasher. If the hasher has not been saved before, the object must
* save the hasher by calling StringHasher::Save
*/
std::pair<bool,int> addStringHasher(const StringHasherRef & hasher) const;
/** Called by property to restore its containing StringHasher
*
* @param index: the index previously returned by calling addStringHasher()
* during save. Or if is negative, then return document's own string hasher
* if UseHasher is True
*
* @return Return the resulting string hasher.
*
* The caller is responsible to restore the hasher itself if it is the first
* owner of the hasher, i.e. return addStringHasher() returns true during
* save
*/
StringHasherRef getStringHasher(int index=-1) const;
/// Return the document's own hasher regardless of UseHasher
StringHasherRef getHasher() const;
/** Return the links to a given object
*
* @param links: holds the links found
@@ -493,7 +545,9 @@ public:
virtual PyObject *getPyObject(void) override;
virtual std::string getFullName() const override;
virtual std::string getFullName(bool python=false) const override;
virtual App::Document *getOwnerDocument() const override;
/// Indicate if there is any document restoring/importing
static bool isAnyRestoring();
@@ -512,6 +566,9 @@ protected:
/// Construction
Document(const char *name = "");
bool afterRestore(bool checkPartial=false);
bool afterRestore(const std::vector<App::DocumentObject *> &, bool checkPartial=false);
void _removeObject(DocumentObject* pcObject);
void _addObject(DocumentObject* pcObject, const char* pObjectName);
/// checks if a valid transaction is open
+78 -76
View File
@@ -165,14 +165,13 @@ App::DocumentObjectExecReturn* DocumentObject::executeExtensions()
{
//execute extensions but stop on error
this->setStatus(App::RecomputeExtension, false); // reset the flag
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : vector) {
auto ret = ext->extensionExecute();
if (ret != StdReturn)
return ret;
}
App::DocumentObjectExecReturn *res = StdReturn;
foreachExtension<DocumentObjectExtension>([&res](DocumentObjectExtension *ext) {
res = ext->extensionExecute();
return res != StdReturn;
});
return StdReturn;
return res;
}
bool DocumentObject::recomputeFeature(bool recursive)
@@ -234,16 +233,10 @@ bool DocumentObject::mustRecompute(void) const
short DocumentObject::mustExecute(void) const
{
if (ExpressionEngine.isTouched())
if (ExpressionEngine.isTouched()
|| queryExtension(&DocumentObjectExtension::extensionMustExecute))
return 1;
//ask all extensions
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : vector) {
if (ext->extensionMustExecute())
return 1;
}
return 0;
}
@@ -259,13 +252,24 @@ const char* DocumentObject::getStatusString(void) const
return "Valid";
}
std::string DocumentObject::getFullName() const {
if(!getDocument() || !pcNameInDocument)
return "?";
std::string name(getDocument()->getName());
name += '#';
name += *pcNameInDocument;
return name;
std::string DocumentObject::getFullName(bool python) const {
if(!getDocument() || !pcNameInDocument) {
if(python)
return std::string("None");
return std::string("?") + Base::Tools::getIdentifier(oldLabel);
}
std::ostringstream ss;
if(python) {
ss << "FreeCAD.getDocument('" << getDocument()->getName()
<< "').getObject('" << *pcNameInDocument << "')";
}else
ss << getDocument()->getName() << '#' << *pcNameInDocument;
return ss.str();
}
App::Document *DocumentObject::getOwnerDocument() const {
return _pDoc;
}
const char *DocumentObject::getNameInDocument() const
@@ -708,13 +712,13 @@ bool DocumentObject::removeDynamicProperty(const char* name)
auto expressions = ExpressionEngine.getExpressions();
std::vector<App::ObjectIdentifier> removeExpr;
for (auto it : expressions) {
for (const auto& it : expressions) {
if (it.first.getProperty() == prop) {
removeExpr.push_back(it.first);
}
}
for (auto it : removeExpr) {
for (const auto& it : removeExpr) {
ExpressionEngine.setValue(it, std::shared_ptr<Expression>());
}
@@ -723,9 +727,9 @@ bool DocumentObject::removeDynamicProperty(const char* name)
App::Property* DocumentObject::addDynamicProperty(
const char* type, const char* name, const char* group, const char* doc,
short attr, bool ro, bool hidden)
short attr, bool readonly, bool hidden)
{
auto prop = TransactionalObject::addDynamicProperty(type,name,group,doc,attr,ro,hidden);
auto prop = TransactionalObject::addDynamicProperty(type,name,group,doc,attr,readonly,hidden);
if(prop && _pDoc)
_pDoc->addOrRemovePropertyOfObject(this, prop, true);
return prop;
@@ -744,8 +748,7 @@ void DocumentObject::onBeforeChange(const Property* prop)
signalBeforeChange(*this,*prop);
}
/// get called by the container when a Property was changed
void DocumentObject::onChanged(const Property* prop)
void DocumentObject::onEarlyChange(const Property *prop)
{
if(GetApplication().isClosingAll())
return;
@@ -763,6 +766,15 @@ void DocumentObject::onChanged(const Property* prop)
}
}
signalEarlyChanged(*this, *prop);
}
/// get called by the container when a Property was changed
void DocumentObject::onChanged(const Property* prop)
{
if(GetApplication().isClosingAll())
return;
// Delay signaling view provider until the document object has handled the
// change
// if (_pDoc)
@@ -814,14 +826,13 @@ DocumentObject *DocumentObject::getSubObject(const char *subname,
PyObject **pyObj, Base::Matrix4D *mat, bool transform, int depth) const
{
DocumentObject *ret = nullptr;
auto exts = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : exts) {
if(ext->extensionGetSubObject(ret,subname,pyObj,mat,transform, depth))
return ret;
}
if(queryExtension(&DocumentObjectExtension::extensionGetSubObject, ret, subname, pyObj, mat, transform, depth))
return ret;
std::string name;
const char *dot=nullptr;
while(subname && *subname=='.')
++subname; // skip leading .
if(!subname || !(dot=strchr(subname,'.'))) {
ret = const_cast<DocumentObject*>(this);
}else if(subname[0]=='$') {
@@ -879,11 +890,7 @@ std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char *subnam
std::vector<std::string> DocumentObject::getSubObjects(int reason) const {
std::vector<std::string> ret;
auto exts = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : exts) {
if(ext->extensionGetSubObjects(ret,reason))
return ret;
}
callExtension(&DocumentObjectExtension::extensionGetSubObjects,ret,reason);
return ret;
}
@@ -919,11 +926,8 @@ DocumentObject *DocumentObject::getLinkedObject(
bool recursive, Base::Matrix4D *mat, bool transform, int depth) const
{
DocumentObject *ret = nullptr;
auto exts = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : exts) {
if(ext->extensionGetLinkedObject(ret,recursive,mat,transform,depth))
return ret;
}
if(queryExtension(&DocumentObjectExtension::extensionGetLinkedObject, ret, recursive, mat, transform, depth))
return ret;
if(transform && mat) {
auto pla = dynamic_cast<PropertyPlacement*>(getPropertyByName("Placement"));
if(pla)
@@ -934,8 +938,6 @@ DocumentObject *DocumentObject::getLinkedObject(
void DocumentObject::Save (Base::Writer &writer) const
{
if (this->getNameInDocument())
writer.ObjectName = this->getNameInDocument();
App::ExtensionContainer::Save(writer);
}
@@ -991,9 +993,7 @@ void DocumentObject::renameObjectIdentifiers(const std::map<ObjectIdentifier, Ob
void DocumentObject::onDocumentRestored()
{
//call all extensions
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : vector)
ext->onExtendedDocumentRestored();
callExtension(&DocumentObjectExtension::onExtendedDocumentRestored);
if(Visibility.testStatus(Property::Output))
Visibility.setStatus(Property::NoModify,true);
}
@@ -1006,25 +1006,19 @@ void DocumentObject::onUndoRedoFinished()
void DocumentObject::onSettingDocument()
{
//call all extensions
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : vector)
ext->onExtendedSettingDocument();
callExtension(&DocumentObjectExtension::onExtendedSettingDocument);
}
void DocumentObject::setupObject()
{
//call all extensions
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : vector)
ext->onExtendedSetupObject();
callExtension(&DocumentObjectExtension::onExtendedSetupObject);
}
void DocumentObject::unsetupObject()
{
//call all extensions
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
for(auto ext : vector)
ext->onExtendedUnsetupObject();
callExtension(&DocumentObjectExtension::onExtendedUnsetupObject);
}
void App::DocumentObject::_removeBackLink(DocumentObject* rmvObj)
@@ -1054,31 +1048,25 @@ void App::DocumentObject::_addBackLink(DocumentObject* newObj)
}
int DocumentObject::setElementVisible(const char *element, bool visible) {
for(auto ext : getExtensionsDerivedFromType<DocumentObjectExtension>()) {
int ret = ext->extensionSetElementVisible(element,visible);
if(ret>=0)
return ret;
}
return -1;
int res = -1;
foreachExtension<DocumentObjectExtension>([&res,element,visible](DocumentObjectExtension *ext) {
res = ext->extensionSetElementVisible(element,visible);
return res>=0;
});
return res;
}
int DocumentObject::isElementVisible(const char *element) const {
for(auto ext : getExtensionsDerivedFromType<DocumentObjectExtension>()) {
int ret = ext->extensionIsElementVisible(element);
if(ret>=0)
return ret;
}
return -1;
int res = -1;
foreachExtension<DocumentObjectExtension>([&res,element](DocumentObjectExtension *ext) {
res = ext->extensionIsElementVisible(element);
return res>=0;
});
return res;
}
bool DocumentObject::hasChildElement() const {
for(auto ext : getExtensionsDerivedFromType<DocumentObjectExtension>()) {
if(ext->extensionHasChildElement())
return true;
}
return false;
return queryExtension(&DocumentObjectExtension::extensionHasChildElement);
}
DocumentObject *DocumentObject::resolve(const char *subname,
@@ -1253,6 +1241,20 @@ bool DocumentObject::adjustRelativeLinks(
return touched;
}
std::string DocumentObject::getElementMapVersion(const App::Property *_prop, bool restored) const {
auto prop = Base::freecad_dynamic_cast<const PropertyComplexGeoData>(_prop);
if(!prop)
return std::string();
return prop->getElementMapVersion(restored);
}
bool DocumentObject::checkElementMapVersion(const App::Property *_prop, const char *ver) const {
auto prop = Base::freecad_dynamic_cast<const PropertyComplexGeoData>(_prop);
if(!prop)
return false;
return prop->checkElementMapVersion(ver);
}
const std::string &DocumentObject::hiddenMarker() {
static std::string marker("!hide");
return marker;
+21 -3
View File
@@ -66,7 +66,6 @@ enum ObjectStatus {
NoAutoExpand = 17, // disable tree item auto expand on selection for this object
PendingTransactionUpdate = 18, // mark that the object expects a call to onUndoRedoFinished() after transaction is finished.
RecomputeExtension = 19, // mark the object to recompute its extensions
TouchOnColorChange = 20, // inform view provider touch object on color change
};
/** Return object for feature execution
@@ -110,6 +109,8 @@ public:
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalBeforeChange;
/// signal on changed property of this object
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalChanged;
/// signal on changed property of this object before document scoped signalChangedObject
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalEarlyChanged;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
@@ -139,7 +140,8 @@ public:
/// returns the name that is safe to be exported to other document
std::string getExportName(bool forced=false) const;
/// Return the object full name of the form DocName#ObjName
virtual std::string getFullName() const override;
virtual std::string getFullName(bool python=false) const override;
virtual App::Document *getOwnerDocument() const override;
virtual bool isAttachedToDocument() const override;
virtual const char* detachFromDocument() override;
/// gets the document in which this Object is handled
@@ -287,6 +289,20 @@ public:
bool testIfLinkDAGCompatible(App::PropertyLinkSubList &linksTo) const;
bool testIfLinkDAGCompatible(App::PropertyLinkSub &linkTo) const;
/** Return the element map version of the geometry data stored in the given property
*
* @param prop: the geometry property to query for element map version
* @param restored: whether to query for the restored element map version.
* In case of version upgrade, the restored version may
* be different from the current version.
*
* @return Return the element map version string.
*/
virtual std::string getElementMapVersion(const App::Property *prop, bool restored=false) const;
/// Return true to signal re-generation of geometry element names
virtual bool checkElementMapVersion(const App::Property *prop, const char *ver) const;
public:
/** mustExecute
* We call this method to check if the object was modified to
@@ -442,7 +458,7 @@ public:
virtual App::Property* addDynamicProperty(
const char* type, const char* name=nullptr,
const char* group=nullptr, const char* doc=nullptr,
short attr=0, bool ro=false, bool hidden=false) override;
short attr=0, bool readonly=false, bool hidden=false) override;
/** Resolve the last document object referenced in the subname
*
@@ -600,6 +616,8 @@ protected:
virtual void onBeforeChange(const Property* prop) override;
/// get called by the container when a property was changed
virtual void onChanged(const Property* prop) override;
/// get called by the container when a property was changed
virtual void onEarlyChange(const Property* prop) override;
/// get called after a document has been fully restored
virtual void onDocumentRestored();
/// get called after an undo/redo transaction is finished
+1 -1
View File
@@ -96,7 +96,7 @@ public:
Base::Matrix4D *mat, bool transform, int depth) const;
virtual int extensionSetElementVisible(const char *, bool) {return -1;}
virtual int extensionIsElementVisible(const char *) {return -1;}
virtual int extensionIsElementVisible(const char *) const {return -1;}
virtual bool extensionHasChildElement() const {return false;}
};
+14 -14
View File
@@ -374,12 +374,12 @@ PyObject* DocumentObjectPy::evalExpression(PyObject *self, PyObject * args)
PyObject* DocumentObjectPy::recompute(PyObject *args)
{
PyObject *recursive=Py_False;
if (!PyArg_ParseTuple(args, "|O",&recursive))
PyObject *recursive = Py_False;
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &recursive))
return nullptr;
try {
bool ok = getDocumentObjectPtr()->recomputeFeature(PyObject_IsTrue(recursive));
bool ok = getDocumentObjectPtr()->recomputeFeature(PyObject_IsTrue(recursive) ? true : false);
return Py_BuildValue("O", (ok ? Py_True : Py_False));
}
catch (const Base::Exception& e) {
@@ -434,8 +434,8 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds)
short depth = 0;
static char *kwlist[] = {"subname", "retType", "matrix", "transform", "depth", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|hO!Oh", kwlist,
&obj, &retType, &Base::MatrixPy::Type, &pyMat, &doTransform, &depth))
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|hO!O!h", kwlist,
&obj, &retType, &Base::MatrixPy::Type, &pyMat, &PyBool_Type, &doTransform, &depth))
return nullptr;
if (retType < 0 || retType > 6) {
@@ -469,7 +469,7 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds)
return nullptr;
}
bool transform = PyObject_IsTrue(doTransform);
bool transform = PyObject_IsTrue(doTransform) ? true : false;
struct SubInfo {
App::DocumentObject *sobj;
@@ -578,8 +578,8 @@ PyObject* DocumentObjectPy::getLinkedObject(PyObject *args, PyObject *keywds)
PyObject *transform = Py_True;
short depth = 0;
static char *kwlist[] = {"recursive","matrix","transform","depth", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|OOOh", kwlist,
&recursive,&pyMat,&transform,&depth))
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|O!OO!h", kwlist,
&PyBool_Type,&recursive,&pyMat,&PyBool_Type,&transform,&depth))
return nullptr;
Base::Matrix4D _mat;
@@ -595,7 +595,7 @@ PyObject* DocumentObjectPy::getLinkedObject(PyObject *args, PyObject *keywds)
PY_TRY {
auto linked = getDocumentObjectPtr()->getLinkedObject(
PyObject_IsTrue(recursive), mat, PyObject_IsTrue(transform),depth);
PyObject_IsTrue(recursive) ? true : false, mat, PyObject_IsTrue(transform) ? true : false, depth);
if(!linked)
linked = getDocumentObjectPtr();
auto pyObj = Py::Object(linked->getPyObject(),true);
@@ -623,10 +623,10 @@ PyObject* DocumentObjectPy::setElementVisible(PyObject *args)
{
char *element = nullptr;
PyObject *visible = Py_True;
if (!PyArg_ParseTuple(args, "s|O", &element,&visible))
if (!PyArg_ParseTuple(args, "s|O!", &element, &PyBool_Type, &visible))
return nullptr;
PY_TRY {
return Py_BuildValue("h", getDocumentObjectPtr()->setElementVisible(element,PyObject_IsTrue(visible)));
return Py_BuildValue("h", getDocumentObjectPtr()->setElementVisible(element,PyObject_IsTrue(visible) ? true : false));
} PY_CATCH;
}
@@ -830,13 +830,13 @@ PyObject *DocumentObjectPy::resolveSubElement(PyObject *args)
const char *subname;
PyObject *append = Py_False;
int type = 0;
if (!PyArg_ParseTuple(args, "s|Oi",&subname,&append,&type))
if (!PyArg_ParseTuple(args, "s|O!i",&subname,&PyBool_Type,&append,&type))
return nullptr;
PY_TRY {
std::pair<std::string,std::string> elementName;
auto obj = GeoFeature::resolveElement(getDocumentObjectPtr(), subname,elementName,
PyObject_IsTrue(append),(GeoFeature::ElementNameType)type);
PyObject_IsTrue(append) ? true : false,(GeoFeature::ElementNameType)type);
Py::Tuple ret(3);
ret.setItem(0,obj?Py::Object(obj->getPyObject(),true):Py::None());
ret.setItem(1,Py::String(elementName.first));
@@ -866,7 +866,7 @@ PyObject *DocumentObjectPy::adjustRelativeLinks(PyObject *args) {
std::set<App::DocumentObject *> visited;
return Py::new_reference_to(Py::Boolean(
getDocumentObjectPtr()->adjustRelativeLinks(inList,
PyObject_IsTrue(recursive)?&visited:nullptr)));
PyObject_IsTrue(recursive) ? &visited : nullptr)));
}PY_CATCH
}
+217 -24
View File
@@ -24,10 +24,12 @@
#include "PreCompiled.h"
#include <Base/Tools.h>
#include <Base/Interpreter.h>
#include <App/DocumentObjectPy.h>
#include "Application.h"
#include "ComplexGeoData.h"
#include "Document.h"
#include "DocumentObject.h"
#include "DocumentObserver.h"
#include "GeoFeature.h"
@@ -199,6 +201,18 @@ bool DocumentObjectT::operator==(const DocumentObjectT &other) const {
&& property == other.property;
}
bool DocumentObjectT::operator<(const DocumentObjectT &other) const {
if(getDocumentName() < other.getDocumentName())
return true;
if(getDocumentName() > other.getDocumentName())
return false;
if(getObjectName() < other.getObjectName())
return true;
if(getObjectName() > other.getObjectName())
return false;
return getPropertyName() < other.getPropertyName();
}
Document* DocumentObjectT::getDocument() const
{
return GetApplication().getDocument(document.c_str());
@@ -298,6 +312,44 @@ SubObjectT::SubObjectT(const char *docName, const char *objName, const char *s)
{
}
SubObjectT::SubObjectT(const std::vector<App::DocumentObject*> &objs, const char *s)
{
if (objs.empty())
return;
static_cast<DocumentObjectT&>(*this) = objs.front();
std::ostringstream ss;
for (auto it = objs.begin()+1; it!=objs.end(); ++it) {
auto obj = *it;
if (!obj || !obj->getNameInDocument())
continue;
ss << obj->getNameInDocument() << ".";
}
if (s)
ss << s;
subname = ss.str();
}
SubObjectT::SubObjectT(std::vector<App::DocumentObject*>::const_iterator begin,
std::vector<App::DocumentObject*>::const_iterator end,
const char *s)
{
if (begin == end)
return;
static_cast<DocumentObjectT&>(*this) = *begin;
std::ostringstream ss;
for (auto it = begin+1; it != end; ++it) {
auto obj = *it;
if (!obj || !obj->getNameInDocument())
continue;
ss << obj->getNameInDocument() << ".";
}
if (s)
ss << s;
subname = ss.str();
}
bool SubObjectT::operator<(const SubObjectT &other) const {
if(getDocumentName() < other.getDocumentName())
return true;
@@ -357,45 +409,107 @@ void SubObjectT::setSubName(const char *s) {
subname = s?s:"";
}
bool SubObjectT::normalize()
{
std::ostringstream ss;
auto objs = getSubObjectList();
for (unsigned i=1; i<objs.size(); ++i)
ss << objs[i]->getNameInDocument() << ".";
if (objs.front()->getSubObject(ss.str().c_str()) != objs.back()) {
// something went wrong
return false;
}
ss << getOldElementName();
std::string sub = ss.str();
if (subname != sub) {
subname = std::move(sub);
return true;
}
return false;
}
SubObjectT App::SubObjectT::normalized() const
{
SubObjectT res(*this);
res.normalize();
return res;
}
const std::string &SubObjectT::getSubName() const {
return subname;
}
std::string SubObjectT::getSubNameNoElement() const {
return Data::ComplexGeoData::noElementName(subname.c_str());
std::string SubObjectT::getSubNameNoElement(bool withObjName) const {
if (!withObjName)
return Data::ComplexGeoData::noElementName(subname.c_str());
std::string res(getObjectName());
res += ".";
const char * element = Data::ComplexGeoData::findElementName(subname.c_str());
if(element)
return res.insert(res.size(), subname.c_str(), element - subname.c_str());
return res;
}
const char *SubObjectT::getElementName() const {
return Data::ComplexGeoData::findElementName(subname.c_str());
}
std::string SubObjectT::getNewElementName() const {
std::pair<std::string, std::string> element;
auto obj = getObject();
if(!obj)
return std::string();
GeoFeature::resolveElement(obj,subname.c_str(),element);
return std::move(element.first);
bool SubObjectT::hasSubObject() const {
return Data::ComplexGeoData::findElementName(subname.c_str()) != subname.c_str();
}
std::string SubObjectT::getOldElementName(int *index) const {
bool SubObjectT::hasSubElement() const {
auto element = getElementName();
return element && element[0];
}
std::string SubObjectT::getNewElementName(bool fallback) const {
const char *elementName = Data::ComplexGeoData::findElementName(subname.c_str());
if (!elementName || !elementName[0])
return std::string();
std::string name = Data::ComplexGeoData::newElementName(elementName);
if (name.size())
return name;
std::pair<std::string, std::string> element;
auto obj = getObject();
if(!obj)
return std::string();
GeoFeature::resolveElement(obj,subname.c_str(),element);
if(!index)
return std::move(element.second);
std::size_t pos = element.second.find_first_of("0123456789");
if(pos == std::string::npos)
*index = -1;
else {
*index = std::atoi(element.second.c_str()+pos);
element.second.resize(pos);
}
if (!element.first.empty() || !fallback)
return std::move(element.first);
return std::move(element.second);
}
std::string SubObjectT::getOldElementName(int *index, bool fallback) const {
const char *elementName = Data::ComplexGeoData::findElementName(subname.c_str());
if (!elementName || !elementName[0])
return std::string();
std::string name = Data::ComplexGeoData::oldElementName(elementName);
if (name.empty()) {
std::pair<std::string, std::string> element;
auto obj = getObject();
if(!obj)
return std::string();
GeoFeature::resolveElement(obj,subname.c_str(),element);
if (!element.second.empty())
name = std::move(element.second);
else if (fallback && !element.first.empty())
name = std::move(element.first);
else
return std::string();
}
if(index) {
std::size_t pos = name.find_first_of("0123456789");
if(pos == std::string::npos)
*index = -1;
else {
*index = std::atoi(name.c_str()+pos);
name.resize(pos);
}
}
return name;
}
App::DocumentObject *SubObjectT::getSubObject() const {
auto obj = getObject();
if(obj)
@@ -407,8 +521,8 @@ std::string SubObjectT::getSubObjectPython(bool force) const {
if(!force && subname.empty())
return getObjectPython();
std::stringstream str;
str << "(" << getObjectPython() << ",u'"
<< Base::Tools::escapedUnicodeFromUtf8(subname.c_str()) << "')";
str << "(" << getObjectPython() << ", '"
<< Base::Tools::escapeEncodeString(normalized().subname) << "')";
return str.str();
}
@@ -419,6 +533,38 @@ std::vector<App::DocumentObject*> SubObjectT::getSubObjectList() const {
return {};
}
SubObjectT SubObjectT::getParent() const {
const char *pos = Data::ComplexGeoData::findElementName(subname.c_str());
if (!pos || pos == subname.c_str())
return SubObjectT();
if(*pos != '.')
--pos;
if(--pos <= subname.c_str())
return SubObjectT();
bool found = false;
for(;pos!=subname.c_str();--pos) {
if(*pos != '.') {
found = true;
continue;
}
if(found)
return SubObjectT(getDocumentName().c_str(),
getObjectName().c_str(), std::string(subname.c_str(), pos+1).c_str());
}
return SubObjectT(getDocumentName().c_str(), getObjectName().c_str(), nullptr);
}
SubObjectT SubObjectT::getChild(const App::DocumentObject *child) const
{
if (getObjectName().empty())
return SubObjectT(child);
SubObjectT res = *this;
res.setSubName(getSubNameNoElement() + child->getNameInDocument() + ".");
return res;
}
std::string SubObjectT::getObjectFullName(const char *docName) const
{
std::ostringstream ss;
@@ -456,6 +602,43 @@ std::string SubObjectT::getSubObjectFullName(const char *docName) const
return ss.str();
}
PyObject *SubObjectT::getPyObject() const
{
auto obj = getObject();
if (!obj)
return Py::new_reference_to(Py::Object());
if (subname.empty())
return obj->getPyObject();
return Py::new_reference_to(Py::TupleN(
Py::asObject(obj->getPyObject()), Py::String(subname)));
}
void SubObjectT::setPyObject(PyObject *pyobj)
{
try {
if (!pyobj)
throw Base::ValueError("Invalid object");
if (PyObject_TypeCheck(pyobj, &App::DocumentObjectPy::Type)) {
this->operator=(static_cast<App::DocumentObjectPy*>(pyobj)->getDocumentObjectPtr());
return;
} else if (PySequence_Check(pyobj) && PySequence_Size(pyobj)==2) {
Py::Sequence seq(pyobj);
App::DocumentObject *obj;
PropertyString tmp;
if (PyObject_TypeCheck(seq[0].ptr(), &App::DocumentObjectPy::Type)) {
obj = static_cast<App::DocumentObjectPy*>(seq[0].ptr())->getDocumentObjectPtr();
tmp.setPyObject(seq[1].ptr());
this->operator=(App::SubObjectT(obj, tmp.getValue()));
return;
}
}
} catch (Py::Exception &) {
Base::PyException e;
} catch (...) {
}
throw Base::ValueError("Expect either document object or tuple(obj, subname)");
}
// -----------------------------------------------------------------------------
PropertyLinkT::PropertyLinkT()
@@ -593,7 +776,12 @@ bool DocumentWeakPtrT::expired() const noexcept
return (d->_document == nullptr);
}
App::Document* DocumentWeakPtrT::operator->() noexcept
App::Document* DocumentWeakPtrT::operator*() const noexcept
{
return d->_document;
}
App::Document* DocumentWeakPtrT::operator->() const noexcept
{
return d->_document;
}
@@ -686,7 +874,12 @@ DocumentObjectWeakPtrT& DocumentObjectWeakPtrT::operator= (App::DocumentObject*
return *this;
}
App::DocumentObject* DocumentObjectWeakPtrT::operator->() noexcept
App::DocumentObject* DocumentObjectWeakPtrT::operator*() const noexcept
{
return d->get();
}
App::DocumentObject* DocumentObjectWeakPtrT::operator->() const noexcept
{
return d->get();
}
+69 -8
View File
@@ -118,6 +118,8 @@ public:
void operator=(const Property*);
/*! Equality operator */
bool operator==(const DocumentObjectT&) const;
/*! Less than operator */
bool operator<(const DocumentObjectT &other) const;
/*! Get a pointer to the document or 0 if it doesn't exist any more. */
Document* getDocument() const;
@@ -182,6 +184,14 @@ public:
/*! Constructor */
SubObjectT(const char *docName, const char *objName, const char *subname);
/*! Constructor */
SubObjectT(const std::vector<App::DocumentObject*> & objs, const char *subname = nullptr);
/*! Constructor */
SubObjectT(std::vector<App::DocumentObject*>::const_iterator begin,
std::vector<App::DocumentObject*>::const_iterator end,
const char *subname = nullptr);
/*! Assignment operator */
SubObjectT &operator=(const SubObjectT&);
@@ -219,19 +229,32 @@ public:
* if it is different then the given 'doc'.
*/
std::string getSubObjectFullName(const char *docName=nullptr) const;
/// Return the subname path without sub-element
std::string getSubNameNoElement() const;
std::string getSubNameNoElement(bool withObjName=false) const;
/// Return the sub-element (Face, Edge, etc) of the subname path
const char *getElementName() const;
/// Return the new style sub-element name
std::string getNewElementName() const;
/// Check if there is any sub object reference
bool hasSubObject() const;
/// Check if there is any sub element reference
bool hasSubElement() const;
/** Return the new style sub-element name
*
* @param fallback: if true, then fallback to old style element name if
* there is no new style name.
*/
std::string getNewElementName(bool fallback=true) const;
/** Return the old style sub-element name
* @param index: if given, then return the element type, and extract the index
* @param fallback: if true, then fallback to new style element name if
* there is no old style name.
*/
std::string getOldElementName(int *index=nullptr) const;
std::string getOldElementName(int *index=nullptr, bool fallback=true) const;
/// Return the sub-object
DocumentObject *getSubObject() const;
@@ -241,8 +264,29 @@ public:
bool operator<(const SubObjectT &other) const;
/** Obtain a string to access the sub object using DocumentObject.getSubObject() API
*
* @param force: whether to call getSubObject() even if there is no subname
*/
std::string getSubObjectPython(bool force=true) const;
/** Normalize the subname path to use only the object internal name and old style element name
* @return Return whether the subname has been changed
*/
bool normalize();
/// Return a normalize copy of itself
SubObjectT normalized() const;
/// Return the parent object
SubObjectT getParent() const;
/// Return the child object
SubObjectT getChild(const App::DocumentObject *) const;
PyObject *getPyObject() const;
void setPyObject(PyObject *);
private:
std::string subname;
};
@@ -294,11 +338,16 @@ public:
* \return true if the managed object has already been deleted, false otherwise.
*/
bool expired() const noexcept;
/*!
* \brief operator *
* \return pointer to the document
*/
App::Document* operator*() const noexcept;
/*!
* \brief operator ->
* \return pointer to the document
*/
App::Document* operator->() noexcept;
App::Document* operator->() const noexcept;
private:
// disable
@@ -334,10 +383,15 @@ public:
*/
DocumentObjectWeakPtrT& operator= (App::DocumentObject* p);
/*!
* \brief operator ->
* \return pointer to the document
* \brief operator *
* \return pointer to the document object
*/
App::DocumentObject* operator->() noexcept;
App::DocumentObject* operator*() const noexcept;
/*!
* \brief operator ->
* \return pointer to the document object
*/
App::DocumentObject* operator->() const noexcept;
/*!
* \brief operator ==
* \return true if both objects are equal, false otherwise
@@ -400,6 +454,13 @@ public:
ptr = p;
return *this;
}
/*!
* \brief operator ->
* \return pointer to the document object
*/
T* operator*() const {
return ptr.get<T>();
}
/*!
* \brief operator ->
* \return pointer to the document object
File diff suppressed because it is too large Load Diff
+359
View File
@@ -0,0 +1,359 @@
/****************************************************************************
* Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#ifndef DOCUMENT_PARAMS_H
#define DOCUMENT_PARAMS_H
/*[[[cog
import DocumentParams
DocumentParams.declare()
]]]*/
// Auto generated code (Tools/params_utils.py:68)
#include <Base/Parameter.h>
#include <boost_signals2.hpp>
// Auto generated code (Tools/params_utils.py:74)
namespace App {
/** Convenient class to obtain App::Document related parameters
* The parameters are under group "User parameter:BaseApp/Preferences/Document"
*
* This class is auto generated by App/DocumentParams.py. Modify that file
* instead of this one, if you want to add any parameter. You need
* to install Cog Python package for code generation:
* @code
* pip install cogapp
* @endcode
*
* Once modified, you can regenerate the header and the source file,
* @code
* python3 -m cogapp -r App/DocumentParams.h App/DocumentParams.cpp
* @endcode
*
* You can add a new parameter by adding lines in App/DocumentParams.py. Available
* parameter types are 'Int, UInt, String, Bool, Float'. For example, to add
* a new Int type parameter,
* @code
* ParamInt(parameter_name, default_value, documentation, on_change=False)
* @endcode
*
* If there is special handling on parameter change, pass in on_change=True.
* And you need to provide a function implementation in App/DocumentParams.cpp with
* the following signature.
* @code
* void DocumentParams:on<parameter_name>Changed()
* @endcode
*/
class AppExport DocumentParams {
public:
static ParameterGrp::handle getHandle();
static boost::signals2::signal<void (const char*)> &signalParamChanged();
static void signalAll();
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter prefAuthor
static const std::string & getprefAuthor();
static const std::string & defaultprefAuthor();
static void removeprefAuthor();
static void setprefAuthor(const std::string &v);
static const char *docprefAuthor();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter prefSetAuthorOnSave
static const bool & getprefSetAuthorOnSave();
static const bool & defaultprefSetAuthorOnSave();
static void removeprefSetAuthorOnSave();
static void setprefSetAuthorOnSave(const bool &v);
static const char *docprefSetAuthorOnSave();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter prefCompany
static const std::string & getprefCompany();
static const std::string & defaultprefCompany();
static void removeprefCompany();
static void setprefCompany(const std::string &v);
static const char *docprefCompany();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter prefLicenseType
static const long & getprefLicenseType();
static const long & defaultprefLicenseType();
static void removeprefLicenseType();
static void setprefLicenseType(const long &v);
static const char *docprefLicenseType();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter prefLicenseUrl
static const std::string & getprefLicenseUrl();
static const std::string & defaultprefLicenseUrl();
static void removeprefLicenseUrl();
static void setprefLicenseUrl(const std::string &v);
static const char *docprefLicenseUrl();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter CompressionLevel
static const long & getCompressionLevel();
static const long & defaultCompressionLevel();
static void removeCompressionLevel();
static void setCompressionLevel(const long &v);
static const char *docCompressionLevel();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter CheckExtension
static const bool & getCheckExtension();
static const bool & defaultCheckExtension();
static void removeCheckExtension();
static void setCheckExtension(const bool &v);
static const char *docCheckExtension();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter ForceXML
static const long & getForceXML();
static const long & defaultForceXML();
static void removeForceXML();
static void setForceXML(const long &v);
static const char *docForceXML();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter SplitXML
static const bool & getSplitXML();
static const bool & defaultSplitXML();
static void removeSplitXML();
static void setSplitXML(const bool &v);
static const char *docSplitXML();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter PreferBinary
static const bool & getPreferBinary();
static const bool & defaultPreferBinary();
static void removePreferBinary();
static void setPreferBinary(const bool &v);
static const char *docPreferBinary();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter AutoRemoveFile
static const bool & getAutoRemoveFile();
static const bool & defaultAutoRemoveFile();
static void removeAutoRemoveFile();
static void setAutoRemoveFile(const bool &v);
static const char *docAutoRemoveFile();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter BackupPolicy
static const bool & getBackupPolicy();
static const bool & defaultBackupPolicy();
static void removeBackupPolicy();
static void setBackupPolicy(const bool &v);
static const char *docBackupPolicy();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter CreateBackupFiles
static const bool & getCreateBackupFiles();
static const bool & defaultCreateBackupFiles();
static void removeCreateBackupFiles();
static void setCreateBackupFiles(const bool &v);
static const char *docCreateBackupFiles();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter UseFCBakExtension
static const bool & getUseFCBakExtension();
static const bool & defaultUseFCBakExtension();
static void removeUseFCBakExtension();
static void setUseFCBakExtension(const bool &v);
static const char *docUseFCBakExtension();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter SaveBackupDateFormat
static const std::string & getSaveBackupDateFormat();
static const std::string & defaultSaveBackupDateFormat();
static void removeSaveBackupDateFormat();
static void setSaveBackupDateFormat(const std::string &v);
static const char *docSaveBackupDateFormat();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter CountBackupFiles
static const long & getCountBackupFiles();
static const long & defaultCountBackupFiles();
static void removeCountBackupFiles();
static void setCountBackupFiles(const long &v);
static const char *docCountBackupFiles();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter OptimizeRecompute
static const bool & getOptimizeRecompute();
static const bool & defaultOptimizeRecompute();
static void removeOptimizeRecompute();
static void setOptimizeRecompute(const bool &v);
static const char *docOptimizeRecompute();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter CanAbortRecompute
static const bool & getCanAbortRecompute();
static const bool & defaultCanAbortRecompute();
static void removeCanAbortRecompute();
static void setCanAbortRecompute(const bool &v);
static const char *docCanAbortRecompute();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter UseHasher
static const bool & getUseHasher();
static const bool & defaultUseHasher();
static void removeUseHasher();
static void setUseHasher(const bool &v);
static const char *docUseHasher();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter ViewObjectTransaction
static const bool & getViewObjectTransaction();
static const bool & defaultViewObjectTransaction();
static void removeViewObjectTransaction();
static void setViewObjectTransaction(const bool &v);
static const char *docViewObjectTransaction();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter WarnRecomputeOnRestore
static const bool & getWarnRecomputeOnRestore();
static const bool & defaultWarnRecomputeOnRestore();
static void removeWarnRecomputeOnRestore();
static void setWarnRecomputeOnRestore(const bool &v);
static const char *docWarnRecomputeOnRestore();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter NoPartialLoading
static const bool & getNoPartialLoading();
static const bool & defaultNoPartialLoading();
static void removeNoPartialLoading();
static void setNoPartialLoading(const bool &v);
static const char *docNoPartialLoading();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter ThumbnailNoBackground
static const bool & getThumbnailNoBackground();
static const bool & defaultThumbnailNoBackground();
static void removeThumbnailNoBackground();
static void setThumbnailNoBackground(const bool &v);
static const char *docThumbnailNoBackground();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter ThumbnailSampleSize
static const long & getThumbnailSampleSize();
static const long & defaultThumbnailSampleSize();
static void removeThumbnailSampleSize();
static void setThumbnailSampleSize(const long &v);
static const char *docThumbnailSampleSize();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter DuplicateLabels
static const bool & getDuplicateLabels();
static const bool & defaultDuplicateLabels();
static void removeDuplicateLabels();
static void setDuplicateLabels(const bool &v);
static const char *docDuplicateLabels();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter TransactionOnRecompute
static const bool & getTransactionOnRecompute();
static const bool & defaultTransactionOnRecompute();
static void removeTransactionOnRecompute();
static void setTransactionOnRecompute(const bool &v);
static const char *docTransactionOnRecompute();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter RelativeStringID
static const bool & getRelativeStringID();
static const bool & defaultRelativeStringID();
static void removeRelativeStringID();
static void setRelativeStringID(const bool &v);
static const char *docRelativeStringID();
//@}
// Auto generated code (Tools/params_utils.py:118)
//@{
/// Accessor for parameter EnableMaterialEdit
static const bool & getEnableMaterialEdit();
static const bool & defaultEnableMaterialEdit();
static void removeEnableMaterialEdit();
static void setEnableMaterialEdit(const bool &v);
static const char *docEnableMaterialEdit();
//@}
// Auto generated code (Tools/params_utils.py:146)
}; // class DocumentParams
} // namespace App
//[[[end]]]
#endif // DOCUMENT_PARAMS_H
+10 -10
View File
@@ -212,13 +212,13 @@ PyObject* DocumentPy::addObject(PyObject *args, PyObject *kwd)
PyObject* view=nullptr;
PyObject *attach=Py_False;
static char *kwlist[] = {"type","name","objProxy","viewProxy","attach","viewType",nullptr};
if (!PyArg_ParseTupleAndKeywords(args,kwd,"s|sOOOs",
kwlist, &sType,&sName,&obj,&view,&attach,&sViewType))
if (!PyArg_ParseTupleAndKeywords(args,kwd,"s|sOOO!s",
kwlist, &sType,&sName,&obj,&view,&PyBool_Type,&attach,&sViewType))
return nullptr;
DocumentObject *pcFtr = nullptr;
if (!obj || !PyObject_IsTrue(attach)) {
if (!obj || (PyObject_IsTrue(attach) ? false : true)) {
pcFtr = getDocumentPtr()->addObject(sType,sName,true,sViewType);
}
else {
@@ -248,7 +248,7 @@ PyObject* DocumentPy::addObject(PyObject *args, PyObject *kwd)
}
pyftr.setAttr("Proxy", pyobj);
if (PyObject_IsTrue(attach)) {
if (PyObject_IsTrue(attach) ? true : false) {
getDocumentPtr()->addObject(pcFtr,sName);
try {
@@ -307,7 +307,7 @@ PyObject* DocumentPy::removeObject(PyObject *args)
PyObject* DocumentPy::copyObject(PyObject *args)
{
PyObject *obj, *rec=Py_False, *retAll=Py_False;
if (!PyArg_ParseTuple(args, "O|OO",&obj,&rec,&retAll))
if (!PyArg_ParseTuple(args, "O|O!O!",&obj,&PyBool_Type,&rec,&PyBool_Type,&retAll))
return nullptr;
std::vector<App::DocumentObject*> objs;
@@ -333,7 +333,7 @@ PyObject* DocumentPy::copyObject(PyObject *args)
}
PY_TRY {
auto ret = getDocumentPtr()->copyObject(objs, PyObject_IsTrue(rec), PyObject_IsTrue(retAll));
auto ret = getDocumentPtr()->copyObject(objs, PyObject_IsTrue(rec) ? true : false, PyObject_IsTrue(retAll) ? true : false);
if (ret.size()==1 && single)
return ret[0]->getPyObject();
@@ -525,10 +525,10 @@ PyObject* DocumentPy::recompute(PyObject * args)
}
int options = 0;
if (PyObject_IsTrue(checkCycle))
if (PyObject_IsTrue(checkCycle) ? true : false)
options = Document::DepNoCycle;
int objectCount = getDocumentPtr()->recompute(objs, PyObject_IsTrue(force), nullptr, options);
int objectCount = getDocumentPtr()->recompute(objs, PyObject_IsTrue(force) ? true : false, nullptr, options);
// Document::recompute() hides possibly raised Python exceptions by its features
// So, check if an error is set and return null if yes
@@ -901,10 +901,10 @@ Py::List DocumentPy::getOutList(void) const
PyObject *DocumentPy::getDependentDocuments(PyObject *args) {
PyObject *sort = Py_True;
if (!PyArg_ParseTuple(args, "|O", &sort))
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &sort))
return nullptr;
PY_TRY {
auto docs = getDocumentPtr()->getDependentDocuments(PyObject_IsTrue(sort));
auto docs = getDocumentPtr()->getDependentDocuments(PyObject_IsTrue(sort) ? true : false);
Py::List ret;
for (auto doc : docs)
ret.append(Py::Object(doc->getPyObject(), true));
+111 -177
View File
@@ -28,76 +28,81 @@
#include <Base/Exception.h>
#include "Enumeration.h"
#include <string_view>
using namespace App;
namespace {
struct StringCopy : public Enumeration::Object {
StringCopy(const char* str) : d(str) {
}
const char* data() const {
return d.data();
}
bool isEqual(const char* str) const {
return d == str;
}
bool isCustom() const {
return true;
}
private:
std::string d;
};
struct StringView : public Enumeration::Object {
StringView(const char* str) : d(str) {
}
const char* data() const {
return d.data();
}
bool isEqual(const char* str) const {
return d == str;
}
bool isCustom() const {
return false;
}
private:
std::string_view d;
};
}
Enumeration::Enumeration()
: _EnumArray(nullptr), _ownEnumArray(false), _index(0), _maxVal(-1)
: _index(0)
{
}
Enumeration::Enumeration(const Enumeration &other)
: _EnumArray(nullptr), _ownEnumArray(false), _index(0), _maxVal(-1)
{
if (other._ownEnumArray) {
setEnums(other.getEnumVector());
} else {
_EnumArray = other._EnumArray;
}
_ownEnumArray = other._ownEnumArray;
enumArray = other.enumArray;
_index = other._index;
_maxVal = other._maxVal;
}
Enumeration::Enumeration(const char *valStr)
: _ownEnumArray(true), _index(0), _maxVal(0)
: _index(0)
{
_EnumArray = new const char*[2];
#if defined (_MSC_VER)
_EnumArray[0] = _strdup(valStr);
#else
_EnumArray[0] = strdup(valStr);
#endif
_EnumArray[1] = nullptr;
enumArray.push_back(std::make_shared<StringCopy>(valStr));
setValue(valStr);
}
Enumeration::Enumeration(const char **list, const char *valStr)
: _EnumArray(list), _ownEnumArray(false)
: _index(0)
{
findMaxVal();
while (list && *list) {
enumArray.push_back(std::make_shared < StringView>(*list));
list++;
}
setValue(valStr);
}
Enumeration::~Enumeration()
{
if (_ownEnumArray) {
if (_EnumArray != nullptr) {
tearDown();
}
}
}
void Enumeration::tearDown(void)
{
// Ugly...
for(char **plEnums = (char **)_EnumArray; *plEnums != nullptr; ++plEnums) {
// Delete C Strings first
free(*plEnums);
}
delete [] _EnumArray;
_EnumArray = nullptr;
_ownEnumArray = false;
_maxVal = -1;
enumArray.clear();
}
void Enumeration::setEnums(const char **plEnums)
{
if(plEnums == _EnumArray)
return;
std::string oldValue;
bool preserve = (isValid() && plEnums != nullptr);
if (preserve) {
@@ -106,23 +111,15 @@ void Enumeration::setEnums(const char **plEnums)
oldValue = str;
}
// set _ownEnumArray
if (isValid() && _ownEnumArray) {
tearDown();
enumArray.clear();
while (plEnums && *plEnums) {
enumArray.push_back(std::make_shared<StringView>(*plEnums));
plEnums++;
}
// set...
_EnumArray = plEnums;
// set _maxVal
findMaxVal();
// set _index
if (_index < 0)
_index = 0;
else if (_index > _maxVal)
_index = _maxVal;
if (preserve) {
setValue(oldValue);
}
@@ -143,30 +140,14 @@ void Enumeration::setEnums(const std::vector<std::string> &values)
oldValue = str;
}
if (isValid() && _ownEnumArray) {
tearDown();
}
_EnumArray = new const char*[values.size() + 1];
int i = 0;
enumArray.clear();
for (std::vector<std::string>::const_iterator it = values.begin(); it != values.end(); ++it) {
#if defined (_MSC_VER)
_EnumArray[i++] = _strdup(it->c_str());
#else
_EnumArray[i++] = strdup(it->c_str());
#endif
enumArray.push_back(std::make_shared<StringCopy>(it->c_str()));
}
_EnumArray[i] = nullptr; // null termination
// Other state variables
_maxVal = static_cast<int>(values.size() - 1);
_ownEnumArray = true;
// set _index
if (_index < 0)
_index = 0;
else if (_index > _maxVal)
_index = _maxVal;
if (preserve) {
setValue(oldValue);
}
@@ -174,36 +155,18 @@ void Enumeration::setEnums(const std::vector<std::string> &values)
void Enumeration::setValue(const char *value)
{
// using string methods without set, use setEnums(const char** plEnums) first!
//assert(_EnumArray);
if (!_EnumArray) {
_index = 0;
return;
}
int i = 0;
const char **plEnums = _EnumArray;
// search for the right entry
while (1) {
// end of list? set zero
if (*plEnums == nullptr) {
_index = 0;
_index = 0;
for (std::size_t i = 0; i < enumArray.size(); i++) {
if (enumArray[i]->isEqual(value)) {
_index = static_cast<int>(i);
break;
}
if (strcmp(*plEnums, value) == 0) {
_index = i;
break;
}
++plEnums;
++i;
}
}
void Enumeration::setValue(long value, bool checkRange)
{
if (value >= 0 && value <= _maxVal) {
if (value >= 0 && value < countItems()) {
_index = value;
} else {
if (checkRange) {
@@ -216,116 +179,104 @@ void Enumeration::setValue(long value, bool checkRange)
bool Enumeration::isValue(const char *value) const
{
// using string methods without set, use setEnums(const char** plEnums) first!
//assert(_EnumArray);
int i = getInt();
if (i == -1) {
return false;
} else {
return strcmp(_EnumArray[i], value) == 0;
return enumArray[i]->isEqual(value);
}
}
bool Enumeration::contains(const char *value) const
{
// using string methods without set, use setEnums(const char** plEnums) first!
//assert(_EnumArray);
if (!getEnums()) {
if (!isValid()) {
return false;
}
const char **plEnums = _EnumArray;
// search for the right entry
while (1) {
// end of list?
if (*plEnums == nullptr)
return false;
if (strcmp(*plEnums, value) == 0)
for (const auto& it : enumArray) {
if (it->isEqual(value))
return true;
++plEnums;
}
return false;
}
const char * Enumeration::getCStr(void) const
const char * Enumeration::getCStr() const
{
// using string methods without set, use setEnums(const char** plEnums) first!
//assert(_EnumArray);
if (!isValid() || _index < 0 || _index > _maxVal) {
if (!isValid() || _index < 0 || _index >= countItems()) {
return nullptr;
}
return _EnumArray[_index];
return enumArray[_index]->data();
}
int Enumeration::getInt(void) const
int Enumeration::getInt() const
{
if (!isValid() || _index < 0 || _index > _maxVal) {
if (!isValid() || _index < 0 || _index >= countItems()) {
return -1;
}
return _index;
}
std::vector<std::string> Enumeration::getEnumVector(void) const
std::vector<std::string> Enumeration::getEnumVector() const
{
// using string methods without set, use setEnums(const char** plEnums) first!
if (!_EnumArray)
return std::vector<std::string>();
std::vector<std::string> list;
for (const auto& it : enumArray)
list.emplace_back(it->data());
return list;
}
std::vector<std::string> result;
const char **plEnums = _EnumArray;
bool Enumeration::hasEnums() const
{
return (!enumArray.empty());
}
// end of list?
while (*plEnums != nullptr) {
result.push_back(*plEnums);
++plEnums;
bool Enumeration::isValid() const
{
return (!enumArray.empty() && _index >= 0 && _index < countItems());
}
int Enumeration::maxValue() const
{
int num = -1;
if (!enumArray.empty())
num = static_cast<int>(enumArray.size()) - 1;
return num;
}
bool Enumeration::isCustom() const
{
for (const auto& it : enumArray) {
if (it->isCustom())
return true;
}
return result;
}
const char ** Enumeration::getEnums(void) const
{
return _EnumArray;
}
bool Enumeration::isValid(void) const
{
return (_EnumArray != nullptr && _index >= 0 && _index <= _maxVal);
return false;
}
Enumeration & Enumeration::operator=(const Enumeration &other)
{
if (other._ownEnumArray) {
setEnums(other.getEnumVector());
} else {
_EnumArray = other._EnumArray;
}
if (this == &other)
return *this;
_ownEnumArray = other._ownEnumArray;
enumArray = other.enumArray;
_index = other._index;
_maxVal = other._maxVal;
return *this;
}
bool Enumeration::operator==(const Enumeration &other) const
{
if(_index != other._index || _maxVal != other._maxVal)
if (_index != other._index || enumArray.size() != other.enumArray.size()) {
return false;
if (_EnumArray == other._EnumArray)
return true;
for (int i=0; i<=_maxVal; ++i) {
if (_EnumArray[i] == other._EnumArray[i])
}
for (size_t i = 0; i < enumArray.size(); ++i) {
if (enumArray[i]->data() == other.enumArray[i]->data())
continue;
if (_EnumArray[i] == nullptr || other._EnumArray[i] == nullptr)
if (enumArray[i]->data() == nullptr || other.enumArray[i]->data() == nullptr)
return false;
if (strcmp(_EnumArray[i], other._EnumArray[i]) != 0)
if (!enumArray[i]->isEqual(other.enumArray[i]->data()))
return false;
}
return true;
@@ -340,24 +291,7 @@ bool Enumeration::operator==(const char *other) const
return (strcmp(getCStr(), other) == 0);
}
void Enumeration::findMaxVal(void)
int Enumeration::countItems() const
{
if (_EnumArray == nullptr) {
_maxVal = -1;
return;
}
const char **plEnums = _EnumArray;
// the NULL terminator doesn't belong to the range of
// valid values
int i = -1;
while (*(plEnums++) != nullptr) {
++i;
// very unlikely to have enums with more then 5000 entries!
assert(i < 5000);
}
_maxVal = i;
return static_cast<int>(enumArray.size());
}
+110 -114
View File
@@ -24,14 +24,13 @@
#ifndef BASE_ENUMERATION_H
#define BASE_ENUMERATION_H
#include <memory>
#include <string>
#include <vector>
#include <FCGlobal.h>
namespace App
{
class PropertyEnumeration;
/// A bidirectional string-integer mapping
/*!
* This is mainly intended for two purposes: working around the difficulty
@@ -52,144 +51,141 @@ namespace App
*/
class AppExport Enumeration
{
friend class App::PropertyEnumeration;
public:
class Object {
public:
/// Constructs an empty Enumeration object
Enumeration();
virtual ~Object() {}
virtual const char* data() const = 0;
virtual bool isEqual(const char*) const = 0;
virtual bool isCustom() const = 0;
};
/// Standard copy constructor
Enumeration(const Enumeration& other);
public:
/// Constructs an empty Enumeration object
Enumeration();
/// Constructs an Enumeration with a single element
Enumeration(const char *valStr);
/// Standard copy constructor
Enumeration(const Enumeration& other);
/// Constructs an Enumeration using val within list
Enumeration(const char **list, const char *valStr);
/// Constructs an Enumeration with a single element
Enumeration(const char *valStr);
/// Standard destructor
~Enumeration();
/// Constructs an Enumeration using val within list
Enumeration(const char **list, const char *valStr);
/** Sets the enumeration string list
* The list is a NULL terminated array of pointers to const
* char* strings.
* \code
* const char enums[] = {"Black","White","Other",NULL}
* \endcode
*
* If Enumeration was already valid, will attempt to preserve
* the string-representation value of the Enumeration
*
* Enumeration does not take ownership of the passed object
*/
void setEnums(const char **plEnums);
/// Standard destructor
~Enumeration();
/// Set all enum values as vector of strings
/*!
* This method causes the Enumeration to dynamically allocate
* it's own array of C Strings, which will be deleted by the
* destructor or subsequent calls to setEnums(). So, it is
* important to make sure the Enumeration stays in scope as
* long as values returned by getCStr are in use.
*
* If Enumeration was already valid, will attempt to preserve
* the string-representation value of the Enumeration
*/
void setEnums(const std::vector<std::string> &values);
/** Sets the enumeration string list
* The list is a NULL terminated array of pointers to const
* char* strings.
* \code
* const char enums[] = {"Black","White","Other",NULL}
* \endcode
*
* If Enumeration was already valid, will attempt to preserve
* the string-representation value of the Enumeration
*
* Enumeration does not take ownership of the passed object
*/
void setEnums(const char **plEnums);
/// Set the enum using a C string
void setValue(const char *value);
/// Set all enum values as vector of strings
/*!
* This method causes the Enumeration to dynamically allocate
* it's own array of C Strings, which will be deleted by the
* destructor or subsequent calls to setEnums(). So, it is
* important to make sure the Enumeration stays in scope as
* long as values returned by getCStr are in use.
*
* If Enumeration was already valid, will attempt to preserve
* the string-representation value of the Enumeration
*/
void setEnums(const std::vector<std::string> &values);
/// Overload of setValue(const char *value)
void setValue(const std::string &value) {setValue(value.c_str());}
/// Set the enum using a C string
void setValue(const char *value);
/// Set the enum using a long
/*!
* if checkRange is set to true, throws Base::ValueError when
* values are set out of range
*
* Checks for boundaries via assert()
*/
void setValue(long value, bool checkRange = false);
/// Overload of setValue(const char *value)
void setValue(const std::string &value) {setValue(value.c_str());}
/// Checks if the property is set to a certain string value
bool isValue(const char *value) const;
/// Set the enum using a long
/*!
* if checkRange is set to true, throws Base::ValueError when
* values are set out of range
*
* Checks for boundaries via assert()
*/
void setValue(long value, bool checkRange = false);
/// Checks if a string is included in the enumeration
bool contains(const char *value) const;
/// Checks if the property is set to a certain string value
bool isValue(const char *value) const;
/// Return the value as C string
/*!
* Returns NULL if the enumeration is invalid.
*/
const char * getCStr(void) const;
/// Checks if a string is included in the enumeration
bool contains(const char *value) const;
/// Return value as integer
/*!
* Returns -1 if the Enumeration isn't valid
*/
int getInt(void) const;
/// Return the value as C string
/*!
* Returns NULL if the enumeration is invalid.
*/
const char * getCStr() const;
/// get all possible enum values as vector of strings
std::vector<std::string> getEnumVector(void) const;
/// Return value as integer
/*!
* Returns -1 if the Enumeration isn't valid
*/
int getInt() const;
/// get pointer to the enum list
const char ** getEnums(void) const;
/// get all possible enum values as vector of strings
std::vector<std::string> getEnumVector() const;
/// Returns true if the instance is in a usable state
bool isValid(void) const;
/// returns true if the enum list is non-empty, false otherwise
bool hasEnums() const;
/// Returns the highest usable integer value for this enum
/*!
* Returns -1 if the enumeration is not valid according to isValid()
*/
int maxValue(void) const {return _maxVal;}
/// Returns true if the instance is in a usable state
bool isValid() const;
/// Assignment operator
Enumeration & operator=(const Enumeration &other);
/// Returns the highest usable integer value for this enum
/*!
* Returns -1 if the enumeration is not valid according to isValid()
*/
int maxValue() const;
/// true iff our string representation matches other's
/*!
* Returns false if either Enumeration is not valid.
*/
bool operator==(const Enumeration &other) const;
/// Returns true if any of the items is a user-defined string
bool isCustom() const;
/// true iff our string representation matches other
/*!
* Returns false if Enumeration is not valid.
*/
bool operator==(const char *other) const;
protected:
/// Returns true if instance was not initialized via static string list
bool isCustom(void) const {return _ownEnumArray;}
/// Assignment operator
Enumeration & operator=(const Enumeration &other);
/// Updates _maxVal
void findMaxVal(void);
/// true iff our string representation matches other's
/*!
* Returns false if either Enumeration is not valid.
*/
bool operator==(const Enumeration &other) const;
/// De-allocates memory used in _EnumArray
/*!
* Important to not call this unless this Enumeration owns array.
*/
void tearDown(void);
/// true iff our string representation matches other
/*!
* Returns false if Enumeration is not valid.
*/
bool operator==(const char *other) const;
protected:
private:
/// Handle to C Strings of possible enumeration values
const char **_EnumArray;
/// Number of items
int countItems() const;
/// Whether instance owns _EnumArray
bool _ownEnumArray;
private:
/// Handle to C Strings of possible enumeration values
using ObjectPtr = std::shared_ptr<Object>;
std::vector<ObjectPtr> enumArray;
/// Integer value of the enumeration
/*!
* This serves as an index into _EnumArray to get the string
* representation.
*/
int _index;
/// Integer value of the enumeration
/*!
* This serves as an index into enumArray to get the string
* representation.
*/
int _index;
/*! Cached result from findMaxVal()
* Value should either be the maximum allowable integer value for
* the Enumeration, or -1 if not initialized
*/
int _maxVal;
friend class PropertyEnumeration;
}; // class Enumeration
} // namespace App
+4 -4
View File
@@ -1517,7 +1517,7 @@ void OperatorExpression::_toString(std::ostream &s, bool persistent,int) const
leftOperator = static_cast<OperatorExpression*>(left)->op;
if (left->priority() < priority()) // Check on operator priority first
needsParens = true;
else if (leftOperator == op) { // Equal priority?
else if (leftOperator == op) { // Same operator ?
if (!isLeftAssociative())
needsParens = true;
//else if (!isCommutative())
@@ -1588,14 +1588,14 @@ void OperatorExpression::_toString(std::ostream &s, bool persistent,int) const
rightOperator = static_cast<OperatorExpression*>(right)->op;
if (right->priority() < priority()) // Check on operator priority first
needsParens = true;
else if (rightOperator == op) { // Equal priority?
else if (rightOperator == op) { // Same operator ?
if (!isRightAssociative())
needsParens = true;
else if (!isCommutative())
needsParens = true;
}
else if (right->priority() == priority()) {
if (!isRightAssociative())
else if (right->priority() == priority()) { // Same priority ?
if (!isRightAssociative() || rightOperator == MOD)
needsParens = true;
}
+21 -21
View File
@@ -43,7 +43,7 @@ ExtensionContainer::ExtensionContainer() {
ExtensionContainer::~ExtensionContainer() {
//we need to delete all dynamically added extensions
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.second->isPythonExtension())
delete entry.second;
}
@@ -56,7 +56,7 @@ void ExtensionContainer::registerExtension(Base::Type extension, Extension* ext)
//no duplicate extensions (including base classes)
if(hasExtension(extension)) {
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.first == extension || entry.first.isDerivedFrom(extension)) {
_extensions.erase(entry.first);
break;
@@ -73,7 +73,7 @@ bool ExtensionContainer::hasExtension(Base::Type t, bool derived) const {
bool found = _extensions.find(t) != _extensions.end();
if(!found && derived) {
//and for types derived from it, as they can be cast to the extension
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.first.isDerivedFrom(t))
return true;
}
@@ -85,7 +85,7 @@ bool ExtensionContainer::hasExtension(Base::Type t, bool derived) const {
bool ExtensionContainer::hasExtension(const std::string& name) const {
//and for types derived from it, as they can be cast to the extension
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.second->name() == name)
return true;
}
@@ -98,11 +98,11 @@ Extension* ExtensionContainer::getExtension(Base::Type t, bool derived, bool no_
auto result = _extensions.find(t);
if((result == _extensions.end()) && derived) {
//we need to check for derived types
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.first.isDerivedFrom(t))
return entry.second;
}
if(no_except)
if(no_except)
return nullptr;
//if we arrive here we don't have anything matching
throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available");
@@ -111,7 +111,7 @@ Extension* ExtensionContainer::getExtension(Base::Type t, bool derived, bool no_
return result->second;
}
else {
if(no_except)
if(no_except)
return nullptr;
//if we arrive here we don't have anything matching
throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available");
@@ -126,7 +126,7 @@ bool ExtensionContainer::hasExtensions() const {
Extension* ExtensionContainer::getExtension(const std::string& name) const {
//and for types derived from it, as they can be cast to the extension
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.second->name() == name)
return entry.second;
}
@@ -137,7 +137,7 @@ std::vector< Extension* > ExtensionContainer::getExtensionsDerivedFrom(Base::Typ
std::vector<Extension*> vec;
//and for types derived from it, as they can be cast to the extension
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
if(entry.first.isDerivedFrom(type))
vec.push_back(entry.second);
}
@@ -146,13 +146,13 @@ std::vector< Extension* > ExtensionContainer::getExtensionsDerivedFrom(Base::Typ
void ExtensionContainer::getPropertyList(std::vector< Property* >& List) const {
App::PropertyContainer::getPropertyList(List);
for(auto entry : _extensions)
for(const auto& entry : _extensions)
entry.second->extensionGetPropertyList(List);
}
void ExtensionContainer::getPropertyMap(std::map< std::string, Property* >& Map) const {
App::PropertyContainer::getPropertyMap(Map);
for(auto entry : _extensions)
for(const auto& entry : _extensions)
entry.second->extensionGetPropertyMap(Map);
}
@@ -161,7 +161,7 @@ Property* ExtensionContainer::getPropertyByName(const char* name) const {
if(prop)
return prop;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
auto prop = entry.second->extensionGetPropertyByName(name);
if(prop)
return prop;
@@ -176,7 +176,7 @@ short int ExtensionContainer::getPropertyType(const Property* prop) const {
if(res != 0)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyType(prop);
if(res != 0)
return res;
@@ -191,7 +191,7 @@ short int ExtensionContainer::getPropertyType(const char* name) const {
if(res != 0)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyType(name);
if(res != 0)
return res;
@@ -207,7 +207,7 @@ const char* ExtensionContainer::getPropertyName(const Property* prop) const {
if(res != nullptr)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyName(prop);
if(res != nullptr)
return res;
@@ -222,7 +222,7 @@ const char* ExtensionContainer::getPropertyGroup(const Property* prop) const {
if(res != nullptr)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyGroup(prop);
if(res != nullptr)
return res;
@@ -237,7 +237,7 @@ const char* ExtensionContainer::getPropertyGroup(const char* name) const {
if(res != nullptr)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyGroup(name);
if(res != nullptr)
return res;
@@ -253,7 +253,7 @@ const char* ExtensionContainer::getPropertyDocumentation(const Property* prop) c
if(res != nullptr)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyDocumentation(prop);
if(res != nullptr)
return res;
@@ -268,7 +268,7 @@ const char* ExtensionContainer::getPropertyDocumentation(const char* name) const
if(res != nullptr)
return res;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
res = entry.second->extensionGetPropertyDocumentation(name);
if(res != nullptr)
return res;
@@ -281,7 +281,7 @@ void ExtensionContainer::onChanged(const Property* prop) {
//inform all extensions about changed property. This includes all properties from the
//extended object (this) as well as all extension properties
for(auto entry : _extensions)
for(const auto& entry : _extensions)
entry.second->extensionOnChanged(prop);
App::PropertyContainer::onChanged(prop);
@@ -318,7 +318,7 @@ void ExtensionContainer::saveExtensions(Base::Writer& writer) const {
//save dynamic extensions
writer.incInd(); // indentation for 'Extensions'
writer.Stream() << writer.ind() << "<Extensions Count=\"" << _extensions.size() << "\">" << std::endl;
for(auto entry : _extensions) {
for(const auto& entry : _extensions) {
auto ext = entry.second;
writer.incInd(); // indentation for 'Extension name'
+63 -1
View File
@@ -132,12 +132,74 @@ public:
return static_cast<ExtensionT*>(getExtension(ExtensionT::getExtensionClassTypeId(),derived,no_except));
}
/** Helpers for iterator over extensions of a given type */
//@{
/** Helper structs to deduce the class type of a class function pointer type */
//@{
template<typename T> struct ClassOf {};
template<typename R, typename C>
struct ClassOf<R (C::*)>{ using type = C; };
//@}
/** Call an extension member function for each extension of the given type
* @param f: the member function pointer of some extension class
* @param args: variadic parameters passed to the member function
*/
template<typename F, class... Args>
void callExtension(F&& f, Args&&... args) const {
for (const auto &entry : _extensions) {
if(entry.first.isDerivedFrom(ClassOf<F>::type::getExtensionClassTypeId()))
(static_cast<typename ClassOf<F>::type*>(entry.second)->*f)(std::forward<Args>(args)...);
}
}
/** Query using an extension member function
* @param f: the member function pointer of some extension class
* @param args: variadic parameters passed to the member function
*
* @return Returns true if the iteratorion is terminated prematurely, or else false.
*
* The iteration over the contained extensions is terminated as soon as the
* extension method call returns true.
*/
template<typename F, class... Args>
bool queryExtension(F&& f, Args&&... args) const {
for (const auto &entry : _extensions) {
if(entry.first.isDerivedFrom(ClassOf<F>::type::getExtensionClassTypeId())) {
if((static_cast<typename ClassOf<F>::type*>(entry.second)->*f)(std::forward<Args>(args)...))
return true;
}
}
return false;
}
/** Invoke a callable for each extension of a given type
* @param f: the callable that accepts one argument of an extension, and
* returns any value that is convertible to boolean.
*
* @return Returns true if the iteratorion is terminated prematurely, or else false.
*
* The iteration over the contained extensions is terminated as soon as the
* extension method call returns true.
*/
template<typename T, typename F>
bool foreachExtension(F f) const {
for (const auto &entry : _extensions) {
if(entry.first.isDerivedFrom(T::getExtensionClassTypeId())) {
if(f(static_cast<T*>(entry.second)))
return true;
}
}
return false;
}
//get all extensions which have the given base class
std::vector<Extension*> getExtensionsDerivedFrom(Base::Type type) const;
template<typename ExtensionT>
std::vector<ExtensionT*> getExtensionsDerivedFromType() const {
std::vector<ExtensionT*> typevec;
for(auto entry : _extensions) {
for (const auto &entry : _extensions) {
if(entry.first.isDerivedFrom(ExtensionT::getExtensionClassTypeId()))
typevec.push_back(static_cast<ExtensionT*>(entry.second));
}
+2 -2
View File
@@ -174,11 +174,11 @@ PyObject* ExtensionContainerPy::hasExtension(PyObject *args) {
char *type;
PyObject *deriv = Py_True;
if (!PyArg_ParseTuple(args, "s|O", &type, &deriv))
if (!PyArg_ParseTuple(args, "s|O!", &type, &PyBool_Type, &deriv))
return nullptr;
//get the extension type asked for
bool derived = PyObject_IsTrue(deriv);
bool derived = PyObject_IsTrue(deriv) ? true : false;
Base::Type extension = Base::Type::fromName(type);
if (extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) {
std::stringstream str;
+5
View File
@@ -48,6 +48,11 @@ public:
}
virtual ~ExtensionPythonT() {
}
ExtensionPythonT(const ExtensionPythonT&) = delete;
ExtensionPythonT(ExtensionPythonT&&) = delete;
ExtensionPythonT& operator= (const ExtensionPythonT&) = delete;
ExtensionPythonT& operator= (ExtensionPythonT&&) = delete;
};
typedef ExtensionPythonT<App::Extension> ExtensionPython;
+5
View File
@@ -85,6 +85,11 @@ protected:
virtual void onSettingDocument() {
FeatureT::onSettingDocument();
}
FeatureCustomT(const FeatureCustomT&) = delete;
FeatureCustomT(FeatureCustomT&&) = delete;
FeatureCustomT& operator= (const FeatureCustomT&) = delete;
FeatureCustomT& operator= (FeatureCustomT&&) = delete;
};
} //namespace App
+6
View File
@@ -342,6 +342,12 @@ protected:
FeatureT::onDocumentRestored();
}
public:
FeaturePythonT(const FeaturePythonT&) = delete;
FeaturePythonT(FeaturePythonT&&) = delete;
FeaturePythonT& operator= (const FeaturePythonT&) = delete;
FeaturePythonT& operator= (FeaturePythonT&&) = delete;
private:
FeaturePythonImp* imp;
PropertyPythonObject Proxy;
+37 -4
View File
@@ -100,7 +100,7 @@ FeatureTest::FeatureTest()
ADD_PROPERTY_TYPE(TypeTransient,(4711),group,Prop_Transient ,"An example property which has the type 'Transient'" );
ADD_PROPERTY_TYPE(TypeNoRecompute,(4711),group,Prop_NoRecompute,"An example property which has the type 'NoRecompute'");
ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
"An example property which has the types 'Output', 'ReadOnly', and 'Hidden'");
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
ADD_PROPERTY(QuantityLength,(1.0));
QuantityLength.setUnit(Base::Unit::Length);
@@ -118,13 +118,46 @@ FeatureTest::~FeatureTest()
}
short FeatureTest::mustExecute(void) const
short FeatureTest::mustExecute() const
{
return DocumentObject::mustExecute();
}
DocumentObjectExecReturn *FeatureTest::execute(void)
DocumentObjectExecReturn *FeatureTest::execute()
{
// Enum handling
Enumeration enumObj1 = Enum.getEnum();
enumObj1.setValue(7, false);
enumObj1.setValue(4, true);
Enumeration enumObj2 = Enum.getEnum();
enumObj2.setValue(4, true);
Enumeration enumObj3(enumObj2);
const char* val = enumObj3.getCStr();
enumObj3.isValue(val);
enumObj3.getEnumVector();
Enumeration enumObj4("Single item");
enumObj4.setEnums(enums);
std::ignore = enumObj4 == enumObj2;
enumObj4.setEnums(nullptr);
enumObj4 = enumObj2;
std::ignore = enumObj4 == enumObj4.getCStr();
Enumeration enumObj5(enums, enums[3]);
enumObj5.isValue(enums[2]);
enumObj5.isValue(enums[3]);
enumObj5.contains(enums[1]);
Enumeration enumObj6;
enumObj6.setEnums(enums);
enumObj6.setValue(enums[1]);
std::vector<std::string> list;
list.emplace_back("Hello");
list.emplace_back("World");
enumObj6.setEnums(list);
enumObj6.setValue(list.back());
/*
doc=App.newDocument()
obj=doc.addObject("App::FeatureTest")
@@ -189,7 +222,7 @@ FeatureTestException::FeatureTestException()
ADD_PROPERTY(ExceptionType,(Base::Exception::getClassTypeId().getKey()) );
}
DocumentObjectExecReturn *FeatureTestException::execute(void)
DocumentObjectExecReturn *FeatureTestException::execute()
{
//ExceptionType;
throw Base::RuntimeError("FeatureTestException::execute(): Testexception ;-)");
+3 -1
View File
@@ -111,7 +111,8 @@ def InitApplications():
AddPath = FreeCAD.ConfigGet("AdditionalModulePaths").split(";")
HomeMod = FreeCAD.getUserAppDataDir()+"Mod"
HomeMod = os.path.realpath(HomeMod)
MacroDir = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro").GetString("MacroPath")
MacroStd = App.getUserMacroDir(False)
MacroDir = App.getUserMacroDir(True)
MacroMod = os.path.realpath(MacroDir+"/Mod")
SystemWideMacroDir = FreeCAD.getHomePath()+'Macro'
SystemWideMacroDir = os.path.realpath(SystemWideMacroDir)
@@ -278,6 +279,7 @@ def InitApplications():
for i in path:
Log(" " + i + "\n")
# add MacroDir to path (RFE #0000504)
sys.path.append(MacroStd)
sys.path.append(MacroDir)
# add SystemWideMacroDir to path
sys.path.append(SystemWideMacroDir)
+129 -8
View File
@@ -25,10 +25,15 @@
#include <App/GeoFeaturePy.h>
#include <Base/Console.h>
#include <App/Link.h>
#include "ComplexGeoData.h"
#include "Document.h"
#include "GeoFeature.h"
#include "GeoFeatureGroupExtension.h"
#include "ComplexGeoData.h"
#include "MappedElement.h"
FC_LOG_LEVEL_INIT("GeoFeature",true,true)
using namespace App;
@@ -43,6 +48,8 @@ PROPERTY_SOURCE(App::GeoFeature, App::DocumentObject)
GeoFeature::GeoFeature(void)
{
ADD_PROPERTY_TYPE(Placement,(Base::Placement()),nullptr,Prop_NoRecompute,nullptr);
ADD_PROPERTY_TYPE(_ElementMapVersion,(""),"Base",
(App::PropertyType)(Prop_Output|Prop_Hidden|Prop_Transient),"");
}
GeoFeature::~GeoFeature(void)
@@ -81,16 +88,48 @@ PyObject* GeoFeature::getPyObject(void)
}
std::pair<std::string,std::string> GeoFeature::getElementName(
const char *name, ElementNameType type) const
std::pair<std::string,std::string>
GeoFeature::getElementName(const char *name, ElementNameType type) const
{
(void)type;
std::pair<std::string,std::string> ret;
if(!name)
if(!name)
return ret;
ret.second = name;
auto prop = getPropertyOfGeometry();
if(!prop) return std::make_pair("", name);
auto geo = prop->getComplexData();
if(!geo) return std::make_pair("", name);
return _getElementName(name, geo->getElementName(name));
}
std::pair<std::string,std::string>
GeoFeature::_getElementName(const char *name, const Data::MappedElement &mapped) const
{
std::pair<std::string,std::string> ret;
if (mapped.index && mapped.name) {
std::ostringstream ss;
ss << Data::ComplexGeoData::elementMapPrefix()
<< mapped.name << '.' << mapped.index;
ret.first = ss.str();
mapped.index.toString(ret.second);
} else if (mapped.name) {
FC_TRACE("element mapped name " << name << " not found in " << getFullName());
ret.first = name;
const char *dot = strrchr(name,'.');
if(dot) {
// deliberately mangle the old style element name to signal a
// missing reference
ret.second = Data::ComplexGeoData::missingPrefix();
ret.second += dot+1;
}
} else {
mapped.index.toString(ret.second);
}
return ret;
}
@@ -99,6 +138,8 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
ElementNameType type, const DocumentObject *filter,
const char **_element, GeoFeature **geoFeature)
{
elementName.first.clear();
elementName.second.clear();
if(!obj || !obj->getNameInDocument())
return nullptr;
if(!subname)
@@ -108,11 +149,16 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
auto sobj = obj->getSubObject(subname);
if(!sobj)
return nullptr;
obj = sobj->getLinkedObject(true);
auto geo = dynamic_cast<GeoFeature*>(obj);
auto linked = sobj->getLinkedObject(true);
auto geo = Base::freecad_dynamic_cast<GeoFeature>(linked);
if(!geo && linked) {
auto ext = linked->getExtensionByType<LinkBaseExtension>(true);
if(ext)
geo = Base::freecad_dynamic_cast<GeoFeature>(ext->getTrueLinkedObject(true));
}
if(geoFeature)
*geoFeature = geo;
if(!obj || (filter && obj!=filter))
if(filter && geo!=filter)
return nullptr;
if(!element || !element[0]) {
if(append)
@@ -139,3 +185,78 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
return sobj;
}
bool GeoFeature::hasMissingElement(const char *subname) {
return Data::ComplexGeoData::hasMissingElement(subname);
if(!subname)
return false;
auto dot = strrchr(subname,'.');
if(!dot)
return subname[0]=='?';
return dot[1]=='?';
}
void GeoFeature::updateElementReference() {
auto prop = getPropertyOfGeometry();
if(!prop) return;
auto geo = prop->getComplexData();
if(!geo) return;
bool reset = false;
auto version = getElementMapVersion(prop);
if(_ElementMapVersion.getStrValue().empty())
_ElementMapVersion.setValue(version);
else if(_ElementMapVersion.getStrValue()!=version) {
reset = true;
_ElementMapVersion.setValue(version);
}
PropertyLinkBase::updateElementReferences(this,reset);
}
void GeoFeature::onChanged(const Property *prop) {
if(prop==getPropertyOfGeometry()) {
if(getDocument() && !getDocument()->testStatus(Document::Restoring)
&& !getDocument()->isPerformingTransaction())
{
updateElementReference();
}
}
DocumentObject::onChanged(prop);
}
void GeoFeature::onDocumentRestored() {
if(!getDocument()->testStatus(Document::Status::Importing))
_ElementMapVersion.setValue(getElementMapVersion(getPropertyOfGeometry(),true));
DocumentObject::onDocumentRestored();
}
const std::vector<std::string>&
GeoFeature::searchElementCache(const std::string &element,
bool checkGeometry,
double tol,
double atol) const
{
static std::vector<std::string> none;
(void)element;
(void)checkGeometry;
(void)tol;
(void)atol;
return none;
}
const std::vector<const char *>&
GeoFeature::getElementTypes(bool /*all*/) const
{
static std::vector<const char *> nil;
auto prop = getPropertyOfGeometry();
if (!prop)
return nil;
return prop->getComplexData()->getElementTypes();
}
std::vector<Data::IndexedName>
GeoFeature::getHigherElements(const char *element, bool silent) const
{
auto prop = getPropertyOfGeometry();
if (!prop)
return {};
return prop->getComplexData()->getHigherElements(element, silent);
}
+55 -3
View File
@@ -24,7 +24,9 @@
#ifndef APP_GEOFEATURE_H
#define APP_GEOFEATURE_H
#include <memory>
#include "DocumentObject.h"
#include "MappedElement.h"
#include "PropertyGeo.h"
@@ -40,6 +42,7 @@ class AppExport GeoFeature : public App::DocumentObject
public:
PropertyPlacement Placement;
PropertyString _ElementMapVersion;
/// Constructor
GeoFeature(void);
@@ -80,10 +83,17 @@ public:
* @param name: input name
* @param type: desired element name type to return
*
* @return a pair(newName,oldName). New element name may be empty.
* This function relies on ComplexGeoData::elementMapPrefix() to decide
* whether it is a forward query, i.e. mapped -> original, or reverse
* query. The reason being that, unlike ComplexGeoData who deals with the
* actual element map data, GeoFeature here sits at a higher level.
* GeoFeature should be dealing with whatever various PropertyLinkSub(s) is
* assigned.
*
* This function currently is does nothing. The new style element name
* generation will be added in the next batch of patches.
* This function is made virtual, so that inherited class can do something
* unusual, such as Sketcher::SketcherObject, which uses this to expose its
* private geometries without a corresponding TopoShape, and yet being
* source code compatible.
*/
virtual std::pair<std::string,std::string> getElementName(
const char *name, ElementNameType type=Normal) const;
@@ -107,6 +117,8 @@ public:
bool append=false, ElementNameType type=Normal,
const DocumentObject *filter=nullptr,const char **element=nullptr, GeoFeature **geo=nullptr);
static bool hasMissingElement(const char *subname);
/**
* @brief Calculates the placement in the global reference coordinate system
*
@@ -120,6 +132,46 @@ public:
* @return Base::Placement The transformation from the global reference coordinate system
*/
Base::Placement globalPlacement() const;
/** Search sub element using internal cached geometry
*
* @param element: element name
* @param checkGeometry: search element by comparing geometry
* @param tol: coordinate tolerance
* @param atol: angle tolerance
*
* @return Returns a list of found element reference to the new goemetry.
* The returned value will be invalidated when the geometry is changed.
*
* Before changing the property of geometry, GeoFeature will internally
* make a snapshot of all referenced element geometry. After change, user
* code may call this function to search for the new element name that
* reference to the same geometry of the old element.
*/
virtual const std::vector<std::string>& searchElementCache(const std::string &element,
bool checkGeometry = true,
double tol = 1e-7,
double atol = 1e-10) const;
/// Return the object that owns the shape that contains the give element name
virtual DocumentObject *getElementOwner(const Data::MappedName & /*name*/) const
{return nullptr;}
virtual const std::vector<const char *>& getElementTypes(bool all=true) const;
/// Return the higher level element names of the given element
virtual std::vector<Data::IndexedName> getHigherElements(const char *name, bool silent=false) const;
protected:
virtual void onChanged(const Property* prop);
virtual void onDocumentRestored();
void updateElementReference();
std::pair<std::string,std::string> _getElementName(const char *name, const Data::MappedElement &mapped) const;
private:
std::vector<Data::MappedElement> _elementMapCache;
std::string _elementMapVersion;
};
} //namespace App
+23 -14
View File
@@ -11,37 +11,46 @@
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Jürgen Riegel" EMail="FreeCAD@juergen-riegel.net" />
<UserDocu>This class does the whole placement and position handling</UserDocu>
<UserDocu>App.GeoFeature class.\n
Base class of all geometric document objects.
This class does the whole placement and position handling.
With the method `getPropertyOfGeometry` is possible to obtain
the main geometric property in general form, without reference
to any particular property name.</UserDocu>
</Documentation>
<Methode Name="getPaths">
<Documentation>
<UserDocu>returns all possible paths to the root of the document</UserDocu>
<UserDocu>getPaths()\n
Returns all possible paths to the root of the document.
Note: Not implemented.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getGlobalPlacement">
<Documentation>
<UserDocu>Returns the placement of the object in the global coordinate space, respecting all stacked relationships.
Note: This function is not available during recompute, as there the placements of parents can change
after the execution of this object, rendering the result wrong.</UserDocu>
<UserDocu>getGlobalPlacement() -> Base.Placement\n
Returns the placement of the object in the global coordinate space, respecting all stacked
relationships.
Note: This function is not available during recompute, as there the placements of parents
can change after the execution of this object, rendering the result wrong.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPropertyNameOfGeometry">
<Documentation>
<UserDocu>Returns the property name of the actual geometry or None.
For example for a part object it returns the value Shape,
for a mesh the value Mesh and so on.
<UserDocu>getPropertyNameOfGeometry() -> str or None\n
Returns the property name of the actual geometry.
For example for a Part feature it returns the value 'Shape', for a mesh feature the value
'Mesh' and so on.
If an object has no such property then None is returned.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPropertyOfGeometry">
<Documentation>
<UserDocu>Returns the property of the actual geometry or None.
For example for a part object it returns its Shape property,
for a mesh its Mesh property and so on.
<UserDocu>getPropertyOfGeometry() -> object or None\n
Returns the property of the actual geometry.
For example for a Part feature it returns its Shape property, for a Mesh feature its
Mesh property and so on.
If an object has no such property then None is returned.
Unlike to getPropertyNameOfGeometry this function returns the geometry,
not its name.
</UserDocu>
Unlike to getPropertyNameOfGeometry this function returns the geometry, not its name.</UserDocu>
</Documentation>
</Methode>
<CustomAttributes />
+3 -11
View File
@@ -256,12 +256,12 @@ PyObject* GroupExtensionPy::getObject(PyObject *args)
PyObject* GroupExtensionPy::hasObject(PyObject *args)
{
PyObject *object;
PyObject *recursivePy = nullptr;
int recursive = 0;
if (!PyArg_ParseTuple(args, "O!|O", &(DocumentObjectPy::Type), &object, &recursivePy))
PyObject *recursivePy = Py_False;
if (!PyArg_ParseTuple(args, "O!|O!", &(DocumentObjectPy::Type), &object, &PyBool_Type, &recursivePy))
return nullptr;
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
bool recursive = PyObject_IsTrue(recursivePy) ? true : false;
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object");
return nullptr;
@@ -270,14 +270,6 @@ PyObject* GroupExtensionPy::hasObject(PyObject *args)
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an object from another document with this group");
return nullptr;
}
if (recursivePy) {
recursive = PyObject_IsTrue(recursivePy);
if ( recursive == -1) {
// Note: shouldn't happen
PyErr_SetString(PyExc_ValueError, "The recursive parameter should be of boolean type");
return nullptr;
}
}
bool v = getGroupExtensionPtr()->hasObject(docObj->getDocumentObjectPtr(), recursive);
return PyBool_FromLong(v ? 1 : 0);
+78 -13
View File
@@ -232,14 +232,14 @@ void LinkBaseExtension::setProperty(int idx, Property *prop) {
case PropLinkMode: {
static const char *linkModeEnums[] = {"None","Auto Delete","Auto Link","Auto Unlink",nullptr};
auto propLinkMode = static_cast<PropertyEnumeration*>(prop);
if(!propLinkMode->getEnums())
if(!propLinkMode->hasEnums())
propLinkMode->setEnums(linkModeEnums);
break;
}
case PropLinkCopyOnChange: {
static const char *enums[] = {"Disabled","Enabled","Owned","Tracking",nullptr};
auto propEnum = static_cast<PropertyEnumeration*>(prop);
if(!propEnum->getEnums())
if(!propEnum->hasEnums())
propEnum->setEnums(enums);
break;
}
@@ -554,7 +554,7 @@ void LinkBaseExtension::syncCopyOnChange()
// so the last object will be the copy of the original linked object
auto newLinked = copiedObjs.back();
// We are coping from the original linked object and we've already mutated
// We are copying from the original linked object and we've already mutated
// it, so we need to copy all CopyOnChange properties from the mutated
// object to the new copy.
std::vector<App::Property*> propList;
@@ -905,7 +905,6 @@ void LinkBaseExtension::monitorOnChangeCopyObjects(
if (getLinkCopyOnChangeValue() == CopyOnChangeDisabled)
return;
for(auto obj : objs) {
obj->setStatus(App::ObjectStatus::TouchOnColorChange, true);
copyOnChangeSrcConns.push_back(obj->signalChanged.connect(
[this](const DocumentObject &, const Property &) {
if (auto prop = this->getLinkCopyOnChangeTouchedProperty()) {
@@ -1012,7 +1011,7 @@ int LinkBaseExtension::extensionSetElementVisible(const char *element, bool visi
return -1;
}
int LinkBaseExtension::extensionIsElementVisible(const char *element) {
int LinkBaseExtension::extensionIsElementVisible(const char *element) const {
int index = _getShowElementValue()?getElementIndex(element):getArrayIndex(element);
if(index>=0) {
auto propElementVis = getVisibilityListProperty();
@@ -1409,12 +1408,21 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char *
void LinkBaseExtension::checkGeoElementMap(const App::DocumentObject *obj,
const App::DocumentObject *linked, PyObject **pyObj, const char *postfix) const
{
if(!pyObj || !*pyObj || (!postfix && obj->getDocument()==linked->getDocument()) ||
!PyObject_TypeCheck(*pyObj, &Data::ComplexGeoDataPy::Type))
if(!pyObj || !*pyObj || !PyObject_TypeCheck(*pyObj, &Data::ComplexGeoDataPy::Type))
return;
// auto geoData = static_cast<Data::ComplexGeoDataPy*>(*pyObj)->getComplexGeoDataPtr();
// geoData->reTagElementMap(obj->getID(),obj->getDocument()->Hasher,postfix);
auto geoData = static_cast<Data::ComplexGeoDataPy*>(*pyObj)->getComplexGeoDataPtr();
std::string _postfix;
if (linked && obj && linked->getDocument() != obj->getDocument()) {
_postfix = Data::ComplexGeoData::externalTagPostfix();
if (postfix) {
if (!boost::starts_with(postfix, Data::ComplexGeoData::elementMapPrefix()))
_postfix += Data::ComplexGeoData::elementMapPrefix();
_postfix += postfix;
}
postfix = _postfix.c_str();
}
geoData->reTagElementMap(obj->getID(),obj->getDocument()->getStringHasher(),postfix);
}
void LinkBaseExtension::onExtendedUnsetupObject() {
@@ -2177,10 +2185,12 @@ void LinkBaseExtension::expandSubname(std::string &subname) const {
}
static bool isExcludedProperties(const char *name) {
#define CHECK_EXCLUDE_PROP(_name) if(strcmp(name,#_name)==0) return true;
CHECK_EXCLUDE_PROP(Shape);
CHECK_EXCLUDE_PROP(Proxy);
CHECK_EXCLUDE_PROP(Placement);
if (boost::equals(name, "Shape"))
return true;
if (boost::equals(name, "Proxy"))
return true;
if (boost::equals(name, "Placement"))
return true;
return false;
}
@@ -2204,6 +2214,61 @@ Property *LinkBaseExtension::extensionGetPropertyByName(const char* name) const
return nullptr;
}
std::vector<std::string> LinkBaseExtension::getHiddenSubnames(
const App::DocumentObject *obj, const char *prefix)
{
std::vector<std::string> res;
if(!obj || !obj->getNameInDocument())
return res;
PropertyLinkSubHidden *prop;
int depth=0;
while((prop=Base::freecad_dynamic_cast<PropertyLinkSubHidden>(
obj->getPropertyByName("ColoredElements"))))
{
for(auto &v : prop->getShadowSubs()) {
if(prefix && !boost::starts_with(v.first,prefix) && !boost::starts_with(v.second,prefix))
continue;
auto &s = v.second;
if(boost::ends_with(s,DocumentObject::hiddenMarker()))
res.push_back(s.substr(0,s.size()-DocumentObject::hiddenMarker().size()));
}
auto o = Base::freecad_dynamic_cast<DocumentObject>(prop->getContainer());
if(!o)
break;
o = o->getLinkedObject(false);
if(o==obj || !GetApplication().checkLinkDepth(++depth,true))
break;
obj = o;
}
return res;
}
bool LinkBaseExtension::isSubnameHidden(const App::DocumentObject *obj, const char *subname)
{
if(!obj || !obj->getNameInDocument() || !subname || !subname[0])
return false;
PropertyLinkSubHidden *prop;
int depth=0;
while((prop=Base::freecad_dynamic_cast<PropertyLinkSubHidden>(
obj->getPropertyByName("ColoredElements"))))
{
for(auto &v : prop->getShadowSubs()) {
if((boost::starts_with(v.first,subname) || boost::starts_with(v.second,subname))
&& boost::ends_with(v.second, DocumentObject::hiddenMarker()))
return true;
}
auto o = Base::freecad_dynamic_cast<DocumentObject>(prop->getContainer());
if(!o)
break;
o = o->getLinkedObject(false);
if(o==obj || !GetApplication().checkLinkDepth(++depth,true))
break;
obj = o;
}
return false;
}
bool LinkBaseExtension::isLinkMutated() const
{
return getLinkCopyOnChangeValue() != CopyOnChangeDisabled
+6 -1
View File
@@ -293,7 +293,7 @@ public:
virtual void onExtendedDocumentRestored() override;
virtual int extensionSetElementVisible(const char *, bool) override;
virtual int extensionIsElementVisible(const char *) override;
virtual int extensionIsElementVisible(const char *) const override;
virtual bool extensionHasChildElement() const override;
virtual PyObject* getExtensionPyObject(void) override;
@@ -304,6 +304,11 @@ public:
int getElementIndex(const char *subname, const char **psubname=nullptr) const;
void elementNameFromIndex(int idx, std::ostream &ss) const;
static std::vector<std::string> getHiddenSubnames(
const App::DocumentObject *obj, const char *prefix=0);
static bool isSubnameHidden(const App::DocumentObject *obj, const char *subname);
DocumentObject *getContainer();
const DocumentObject *getContainer() const;
+258
View File
@@ -0,0 +1,258 @@
/****************************************************************************
* Copyright (c) 2022 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cstdlib>
# include <unordered_set>
#endif
#include <QHash>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/functional/hash.hpp>
#include "DocumentObject.h"
#include "MappedElement.h"
using namespace Data;
struct ByteArray
{
ByteArray(const QByteArray &b)
:bytes(b)
{}
ByteArray(const ByteArray &other)
:bytes(other.bytes)
{}
ByteArray(ByteArray &&other)
:bytes(std::move(other.bytes))
{}
void mutate() const
{
QByteArray copy;
copy.append(bytes.constData(), bytes.size());
bytes = copy;
}
bool operator==(const ByteArray & other) const {
return bytes == other.bytes;
}
mutable QByteArray bytes;
};
struct ByteArrayHasher
{
std::size_t operator()(const ByteArray &bytes) const
{
return qHash(bytes.bytes);
}
std::size_t operator()(const QByteArray &bytes) const
{
return qHash(bytes);
}
};
void IndexedName::set(const char *name,
int len,
const std::vector<const char*> &types,
bool allowOthers)
{
static std::unordered_set<ByteArray, ByteArrayHasher> NameSet;
if (len < 0)
len = static_cast<int>(std::strlen(name));
int i;
for (i=len-1; i>=0; --i) {
if (name[i]<'0' || name[i]>'9')
break;
}
++i;
this->index = std::atoi(name+i);
for (int j=0; j<i; ++j) {
if (name[j] == '_'
|| (name[j] >= 'a' && name[j] <= 'z' )
|| (name[j] >= 'A' && name[j] <= 'Z'))
continue;
this->type = "";
return;
}
for (const char * type : types) {
int j=0;
for (const char *n=name, *t=type; *n; ++n) {
if (*n != *t || j >= i)
break;
++j;
++t;
if (!*t) {
this->type = type;
return;
}
}
}
if (allowOthers) {
auto res = NameSet.insert(QByteArray::fromRawData(name, i));
if (res.second)
res.first->mutate();
this->type = res.first->bytes.constData();
} else
this->type = "";
}
void MappedName::compact() const
{
auto self = const_cast<MappedName*>(this);
if (this->raw) {
self->data = QByteArray(self->data.constData(), self->data.size());
self->raw = false;
}
#if 0
static std::unordered_set<QByteArray, ByteArrayHasher> PostfixSet;
if (this->postfix.size()) {
auto res = PostfixSet.insert(this->postfix);
if (!res.second)
self->postfix = *res.first;
}
#endif
}
bool ElementNameComp::operator()(const MappedName &a, const MappedName &b) const {
size_t size = std::min(a.size(),b.size());
if(!size)
return a.size()<b.size();
size_t i=0;
if(b[0] == '#') {
if(a[0]!='#')
return true;
// If both string starts with '#', compare the following hex digits by
// its integer value.
int res = 0;
for(i=1;i<size;++i) {
unsigned char ac = (unsigned char)a[i];
unsigned char bc = (unsigned char)b[i];
if(std::isxdigit(bc)) {
if(!std::isxdigit(ac))
return true;
if(res==0) {
if(ac<bc)
res = -1;
else if(ac>bc)
res = 1;
}
}else if(std::isxdigit(ac))
return false;
else
break;
}
if(res < 0)
return true;
else if(res > 0)
return false;
for (; i<size; ++i) {
char ac = a[i];
char bc = b[i];
if (ac < bc)
return true;
if (ac > bc)
return false;
}
return a.size()<b.size();
}
else if (a[0] == '#')
return false;
// If the string does not start with '#', compare the non-digits prefix
// using lexical order.
for(i=0;i<size;++i) {
unsigned char ac = (unsigned char)a[i];
unsigned char bc = (unsigned char)b[i];
if(!std::isdigit(bc)) {
if(std::isdigit(ac))
return true;
if(ac<bc)
return true;
if(ac>bc)
return false;
} else if(!std::isdigit(ac)) {
return false;
} else
break;
}
// Then compare the following digits part by integer value
int res = 0;
for(;i<size;++i) {
unsigned char ac = (unsigned char)a[i];
unsigned char bc = (unsigned char)b[i];
if(std::isdigit(bc)) {
if(!std::isdigit(ac))
return true;
if(res==0) {
if(ac<bc)
res = -1;
else if(ac>bc)
res = 1;
}
}else if(std::isdigit(ac))
return false;
else
break;
}
if(res < 0)
return true;
else if(res > 0)
return false;
// Finally, compare the remaining tail using lexical order
for (; i<size; ++i) {
char ac = a[i];
char bc = b[i];
if (ac < bc)
return true;
if (ac > bc)
return false;
}
return a.size()<b.size();
}
HistoryItem::HistoryItem(App::DocumentObject *obj, const Data::MappedName &name)
:obj(obj),tag(0),element(name)
{
if(obj)
tag = obj->getID();
}
const std::string & MappedChildElements::prefix()
{
static std::string _prefix(ComplexGeoData::elementMapPrefix() + ":R");
return _prefix;
}
+847
View File
@@ -0,0 +1,847 @@
/****************************************************************************
* Copyright (c) 2022 Zheng, Lei (realthunder) <realthunder.dev@gmail.com>*
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#ifndef _AppMappedElement_h_
#define _AppMappedElement_h_
#include <cstring>
#include <memory>
#include <cctype>
#include <boost/algorithm/string/predicate.hpp>
#include <QByteArray>
#include <QHash>
#include "ComplexGeoData.h"
#include "StringHasher.h"
namespace App
{
class DocumentObject;
}
namespace Data
{
class AppExport IndexedName {
public:
explicit IndexedName(const char *name = nullptr, int _index = 0)
: index(0)
{
if (!name)
this->type = "";
else {
set(name);
if (_index)
this->index = _index;
}
}
IndexedName(const char *name,
const std::vector<const char*> & types,
bool allowOthers=true)
{
set(name, -1, types, allowOthers);
}
explicit IndexedName(const QByteArray & data)
{
set(data.constData(), data.size());
}
IndexedName(const IndexedName &other)
: type(other.type), index(other.index)
{}
static IndexedName fromConst(const char *name, int index) {
IndexedName res;
res.type = name;
res.index = index;
return res;
}
IndexedName & operator=(const IndexedName & other)
{
this->index = other.index;
this->type = other.type;
return *this;
}
friend std::ostream & operator<<(std::ostream & s, const IndexedName & e)
{
s << e.type;
if (e.index > 0)
s << e.index;
return s;
}
bool operator==(const IndexedName & other) const
{
return this->index == other.index
&& (this->type == other.type
|| std::strcmp(this->type, other.type)==0);
}
IndexedName & operator+=(int offset)
{
this->index += offset;
assert(this->index >= 0);
return *this;
}
IndexedName & operator++()
{
++this->index;
return *this;
}
IndexedName & operator--()
{
--this->index;
assert(this->index >= 0);
return *this;
}
bool operator!=(const IndexedName & other) const
{
return !(this->operator==(other));
}
const char * toString(std::string & s) const
{
// Note! s is not cleared on purpose.
std::size_t offset = s.size();
s += this->type;
if (this->index > 0)
s += std::to_string(this->index);
return s.c_str() + offset;
}
int compare(const IndexedName & other) const
{
int res = std::strcmp(this->type, other.type);
if (res)
return res;
if (this->index < other.index)
return -1;
if (this->index > other.index)
return 1;
return 0;
}
bool operator<(const IndexedName & other) const
{
return compare(other) < 0;
}
char operator[](int index) const
{
return this->type[index];
}
const char * getType() const { return this->type; }
int getIndex() const { return this->index; }
void setIndex(int index) { assert(index>=0); this->index = index; }
bool isNull() const { return !this->type[0]; }
explicit operator bool() const { return !isNull(); }
protected:
void set(const char *,
int len = -1,
const std::vector<const char *> &types = {},
bool allowOthers = true);
private:
const char * type;
int index;
};
class AppExport MappedName
{
public:
MappedName()
:raw(false)
{}
#if QT_VERSION >= 0x050200
MappedName(MappedName &&other)
:data(std::move(other.data))
,postfix(std::move(other.postfix))
,raw(other.raw)
{}
MappedName & operator=(MappedName &&other)
{
this->data = std::move(other.data);
this->postfix = std::move(other.postfix);
this->raw = other.raw;
return *this;
}
#endif
explicit MappedName(const char * name, int size = -1)
:raw(false)
{
if (!name) return;
if (boost::starts_with(name, ComplexGeoData::elementMapPrefix()))
name += ComplexGeoData::elementMapPrefix().size();
if (size < 0)
data = QByteArray(name);
else
data = QByteArray(name, size);
}
explicit MappedName(const std::string & name)
{
int size = name.size();
const char *n = name.c_str();
if (boost::starts_with(name, ComplexGeoData::elementMapPrefix())) {
n += ComplexGeoData::elementMapPrefix().size();
size -= ComplexGeoData::elementMapPrefix().size();
}
data = QByteArray(n, size);
}
explicit MappedName(const IndexedName & element)
:data(element.getType()), raw(false)
{
if (element.getIndex() > 0)
data += QByteArray::number(element.getIndex());
}
explicit MappedName(const App::StringIDRef & sid)
:raw(false)
{
sid.toBytes(this->data);
}
MappedName(const MappedName & other)
:data(other.data), postfix(other.postfix), raw(other.raw)
{}
MappedName(const MappedName & other, int from, int size = -1)
: raw(false)
{
append(other, from, size);
}
MappedName(const MappedName & other, const char *postfix)
:data(other.data + other.postfix)
,postfix(postfix)
,raw(false)
{}
static MappedName fromRawData(const char * name, int size = -1)
{
MappedName res;
if (name) {
res.data = QByteArray::fromRawData(name,
size>=0 ? size: qstrlen(name));
res.raw = true;
}
return res;
}
static MappedName fromRawData(const QByteArray & data)
{
return fromRawData(data.constData(), data.size());
}
static MappedName fromRawData(const MappedName &other, int from, int size = -1)
{
if (from < 0)
from = 0;
if (from >= other.size())
return MappedName();
if (from >= other.data.size())
return MappedName(other, from, size);
MappedName res;
res.raw = true;
if (size < 0)
size = other.size() - from;
if (size < other.data.size()-from)
res.data = QByteArray::fromRawData(
other.data.constData()+from, size);
else {
res.data = QByteArray::fromRawData(
other.data.constData()+from, other.data.size()-from);
size -= other.data.size() - from;
if (size == other.postfix.size())
res.postfix = other.postfix;
else if (size)
res.postfix.append(other.postfix.constData(), size);
}
return res;
}
MappedName & operator=(const MappedName & other)
{
this->data = other.data;
this->postfix = other.postfix;
this->raw = other.raw;
return *this;
}
MappedName & operator=(const std::string & other)
{
*this = MappedName(other);
return *this;
}
MappedName & operator=(const char * other)
{
*this = MappedName(other);
return *this;
}
friend std::ostream & operator<<(std::ostream & s, const MappedName & n)
{
s.write(n.data.constData(), n.data.size());
s.write(n.postfix.constData(), n.postfix.size());
return s;
}
bool operator==(const MappedName & other) const
{
if (this->size() != other.size())
return false;
if (this->data.size() == other.data.size())
return this->data == other.data && this->postfix == other.postfix;
const auto &a = this->data.size() < other.data.size() ? *this : other;
const auto &b = this->data.size() < other.data.size() ? other: *this;
if (!b.data.startsWith(a.data))
return false;
QByteArray tmp = QByteArray::fromRawData(
b.data.constData() + a.data.size(),
b.data.size() - a.data.size());
if (!a.postfix.startsWith(tmp))
return false;
tmp = QByteArray::fromRawData(
a.postfix.constData() + tmp.size(),
a.postfix.size() - tmp.size());
return tmp == b.postfix;
}
bool operator!=(const MappedName & other) const
{
return !(this->operator==(other));
}
MappedName operator+(const MappedName & other) const
{
MappedName res(*this);
res += other;
return res;
}
MappedName operator+(const char * other) const
{
MappedName res(*this);
res += other;
return res;
}
MappedName operator+(const std::string & other) const
{
MappedName res(*this);
res += other;
return res;
}
MappedName operator+(const QByteArray & other) const
{
MappedName res(*this);
res += other;
return res;
}
MappedName & operator+=(const char * other)
{
if (other && other[0])
this->postfix.append(other, -1);
return *this;
}
MappedName & operator+=(const std::string & other)
{
if (other.size()) {
this->postfix.reserve(this->postfix.size() + other.size());
this->postfix.append(other.c_str(), other.size());
}
return *this;
}
MappedName & operator+=(const QByteArray & other)
{
this->postfix += other;
return *this;
}
MappedName & operator+=(const MappedName & other)
{
append(other);
return *this;
}
void append(const char * d, int size = -1)
{
if (d && size) {
if (size < 0)
size = qstrlen(d);
if (empty())
this->data.append(d, size);
else
this->postfix.append(d, size);
}
}
void append(const MappedName & other, int from = 0, int size = -1)
{
if (from < 0)
from = 0;
else if (from > other.size())
return;
if (size < 0 || size + from > other.size())
size = other.size() - from;
int count = size;
if (from < other.data.size()) {
if (count > other.data.size() - from)
count = other.data.size() - from;
if (from == 0 && count == other.data.size() && this->empty()) {
this->data = other.data;
this->raw = other.raw;
} else
append(other.data.constData() + from, count);
from = 0;
size -= count;
} else
from -= other.data.size();
if (size) {
if (from == 0 && size == other.postfix.size()) {
if (this->empty())
this->data = other.postfix;
else if (this->postfix.isEmpty())
this->postfix = other.postfix;
else
this->postfix += other.postfix;
} else
append(other.postfix.constData() + from, size);
}
}
std::string toString(int from, int len=-1) const
{
std::string res;
return toString(res, from, len);
}
const char * toString(std::string &s, int from=0, int len=-1) const
{
std::size_t offset = s.size();
int count = this->size();
if (from < 0)
from = 0;
else if (from >= count)
return s.c_str()+s.size();
if (len < 0 || len > count - from)
len = count - from;
s.reserve(s.size() + len);
if (from < this->data.size()) {
count = this->data.size() - from;
if (len < count)
count = len;
s.append(this->data.constData()+from, count);
len -= count;
}
s.append(this->postfix.constData(), len);
return s.c_str() + offset;
}
const char * toConstString(int offset, int &size) const
{
if (offset < 0)
offset = 0;
if (offset > this->data.size()) {
offset -= this->data.size();
if (offset > this->postfix.size()) {
size = 0;
return "";
}
size = this->postfix.size() - offset;
return this->postfix.constData() + offset;
}
size = this->data.size() - offset;
return this->data.constData() + offset;
}
QByteArray toRawBytes(int offset=0, int size=-1) const
{
if (offset < 0)
offset = 0;
if (offset >= this->size())
return QByteArray();
if (size < 0 || size > this->size() - offset)
size = this->size() - offset;
if (offset >= this->data.size()) {
offset -= this->data.size();
return QByteArray::fromRawData(this->postfix.constData()+offset, size);
}
if (size <= this->data.size() - offset)
return QByteArray::fromRawData(this->data.constData()+offset, size);
QByteArray res(this->data.constData()+offset, this->data.size()-offset);
res.append(this->postfix.constData(), size - this->data.size() + offset);
return res;
}
const QByteArray & dataBytes() const
{
return this->data;
}
const QByteArray & postfixBytes() const
{
return this->postfix;
}
const char * constPostfix() const
{
return this->postfix.constData();
}
// No constData() because 'data' is allow to contain raw data, which may
// not end with 0.
#if 0
void char * constData() const
{
return this->data.constData();
}
#endif
QByteArray toBytes() const
{
if (this->postfix.isEmpty())
return this->data;
if (this->data.isEmpty())
return this->postfix;
return this->data + this->postfix;
}
IndexedName toIndexedName() const
{
if (this->postfix.isEmpty())
return IndexedName(this->data);
return IndexedName();
}
std::string toPrefixedString() const
{
std::string res;
toPrefixedString(res);
return res;
}
const char *toPrefixedString(std::string &buf) const
{
if (!toIndexedName())
buf += ComplexGeoData::elementMapPrefix();
toString(buf);
return buf.c_str();
}
int compare(const MappedName &other) const
{
int asize = this->size();
int bsize = other.size();
for (int i=0, count=std::min(asize, bsize); i<count; ++i) {
char a = this->operator[](i);
char b = other[i];
if (a < b)
return -1;
if (a > b)
return 1;
}
if (asize < bsize)
return -1;
if (asize > bsize)
return 1;
return 0;
}
bool operator<(const MappedName & other) const
{
return compare(other) < 0;
}
char operator[](int index) const
{
if (index >= this->data.size())
return this->postfix[index - this->data.size()];
return this->data[index];
}
int size() const
{
return this->data.size() + this->postfix.size();
}
bool empty() const
{
return this->data.isEmpty() && this->postfix.isEmpty();
}
bool isRaw() const
{
return this->raw;
}
MappedName copy() const
{
if (!this->raw)
return *this;
MappedName res;
res.data.append(this->data.constData(), this->data.size());
res.postfix = this->postfix;
return res;
}
void compact() const;
explicit operator bool() const
{
return !empty();
}
void clear()
{
this->data.clear();
this->postfix.clear();
this->raw = false;
}
int find(const char *d, int from = 0) const
{
if (!d)
return -1;
if (from < 0)
from = 0;
if (from < this->data.size()) {
int res = this->data.indexOf(d, from);
if (res >= 0)
return res;
from = 0;
} else
from -= this->data.size();
int res = this->postfix.indexOf(d, from);
if (res < 0)
return res;
return res + this->data.size();
}
int find(const std::string &d, int from = 0) const
{
return find(d.c_str(), from);
}
int rfind(const char *d, int from = -1) const
{
if (!d)
return -1;
if (from < 0 || from > this->postfix.size()) {
if (from > postfix.size())
from -= postfix.size();
int res = this->postfix.lastIndexOf(d, from);
if (res >= 0)
return res + this->data.size();
from = -1;
}
return this->data.lastIndexOf(d, from);
}
int rfind(const std::string &d, int from = -1) const
{
return rfind(d.c_str(), from);
}
bool endsWith(const char *s) const
{
if (!s)
return false;
if (this->postfix.size())
return this->postfix.endsWith(s);
return this->data.endsWith(s);
}
bool endsWith(const std::string &s) const
{
return endsWith(s.c_str());
}
bool startsWith(const QByteArray & s, int offset = 0) const
{
if (s.size() > size() - offset)
return false;
if (offset || (this->data.size() && this->data.size() < s.size()))
return toRawBytes(offset, s.size()) == s;
if (this->data.size())
return this->data.startsWith(s);
return this->postfix.startsWith(s);
}
bool startsWith(const char *s, int offset = 0) const
{
if (!s)
return false;
return startsWith(QByteArray::fromRawData(s, qstrlen(s)), offset);
}
bool startsWith(const std::string &s, int offset = 0) const
{
return startsWith(QByteArray::fromRawData(s.c_str(), s.size()), offset);
}
std::size_t hash() const
{
#if QT_VERSION >= 0x050000
return qHash(data, qHash(postfix));
#else
return qHash(data) ^ qHash(postfix);
#endif
}
private:
QByteArray data;
QByteArray postfix;
bool raw;
};
struct AppExport MappedElement
{
IndexedName index;
MappedName name;
MappedElement()
{}
MappedElement(const IndexedName & idx, const MappedName & n)
: index(idx), name(n)
{}
MappedElement(const MappedName & n, const IndexedName & idx)
: index(idx), name(n)
{}
MappedElement(const MappedElement & other)
: index(other.index), name(other.name)
{}
MappedElement(MappedElement && other)
: index(std::move(other.index)), name(std::move(other.name))
{}
MappedElement & operator=(MappedElement && other)
{
this->index = std::move(other.index);
this->name = std::move(other.name);
return *this;
}
MappedElement & operator=(const MappedElement & other)
{
this->index = other.index;
this->name = other.name;
return *this;
}
bool operator==(const MappedElement &other) const
{
return this->index == other.index && this->name == other.name;
}
bool operator!=(const MappedElement &other) const
{
return this->index != other.index || this->name != other.name;
}
bool operator<(const MappedElement &other) const
{
int res = this->index.compare(other.index);
if (res < 0)
return true;
if (res > 0)
return false;
return this->name < other.name;
}
};
struct AppExport HistoryItem {
App::DocumentObject *obj;
long tag;
Data::MappedName element;
Data::IndexedName index;
std::vector<Data::MappedName> intermediates;
HistoryItem(App::DocumentObject *obj, const Data::MappedName &name);
};
struct AppExport ElementNameComp {
/** Comparison function to make topo name more stable
*
* The sorting decompose the name into either of the following two forms
* '#' + hex_digits + tail
* non_digits + digits + tail
*
* The non-digits part is compared lexically, while the digits part is
* compared by its integer value.
*
* The reason for this is to prevent name with bigger digits (usually means
* comes late in history) comes early when sorting.
*/
bool operator()(const MappedName &a, const MappedName &b) const;
};
typedef QVector<App::StringIDRef> ElementIDRefs;
struct AppExport MappedChildElements
{
IndexedName indexedName;
int count;
int offset;
long tag;
ElementMapPtr elementMap;
QByteArray postfix;
ElementIDRefs sids;
static const std::string & prefix();
};
} //namespace Data
#endif
+5 -4
View File
@@ -41,8 +41,8 @@ namespace App {
class XMLMergeReader : public Base::XMLReader
{
public:
XMLMergeReader(std::map<std::string, std::string>& name, const char* FileName, std::istream& str)
: Base::XMLReader(FileName, str), nameMap(name)
XMLMergeReader(std::map<std::string, std::string>& name, Base::Reader &reader)
: Base::XMLReader(reader), nameMap(name)
{}
void addName(const char* s1, const char* s2)
@@ -152,7 +152,8 @@ MergeDocuments::importObjects(std::istream& input)
{
this->nameMap.clear();
this->stream = new zipios::ZipInputStream(input);
XMLMergeReader reader(this->nameMap,"<memory>", *stream);
Base::ZipReader zreader(*this->stream,std::string("<memory>"));
XMLMergeReader reader(this->nameMap, zreader);
reader.setVerbose(isVerbose());
std::vector<App::DocumentObject*> objs = appdoc->importObjects(reader);
@@ -166,7 +167,7 @@ void MergeDocuments::importObject(const std::vector<App::DocumentObject*>& o, Ba
{
objects = o;
Restore(r);
r.readFiles(*this->stream);
r.readFiles();
}
void MergeDocuments::exportObject(const std::vector<App::DocumentObject*>& o, Base::Writer & w)
+1 -1
View File
@@ -458,7 +458,7 @@ bool Metadata::satisfies(const Meta::Dependency& dep)
}
auto parsedExpression = App::Expression::parse(nullptr, dep.condition);
auto result = parsedExpression->eval();
if (boost::any_cast<bool> (result->getValueAsAny()) == false)
if (!boost::any_cast<bool> (result->getValueAsAny()))
return false;
}
+88 -62
View File
@@ -16,181 +16,207 @@
<Documentation>
<Author Licence="LGPL" Name="Chris Hennes" EMail="chennes@pioneerlibrarysystem.org" />
<UserDocu>
Metadata
A Metadata object reads an XML-formatted package metadata file and provides read-only access to its contents.
A single constructor is supported:
Metadata(file) -- Reads the XML file and provides access to the metadata it specifies.
</UserDocu>
<UserDocu>App.Metadata class.\n
A Metadata object reads an XML-formatted package metadata file and provides
read-only access to its contents.\n
The following constructors are supported:\n
Metadata()
Empty constructor.\n
Metadata(metadata)
Copy constructor.
metadata : App.Metadata\n
Metadata(file)
Reads the XML file and provides access to the metadata it specifies.
file : str\n XML file name.</UserDocu>
<DeveloperDocu>Metadata</DeveloperDocu>
</Documentation>
<Attribute Name="Name" ReadOnly="true">
<Documentation>
<UserDocu>String: the name of this item</UserDocu>
<UserDocu>String representing the name of this item.</UserDocu>
</Documentation>
<Parameter Name="Name" Type="Object" />
</Attribute>
<Attribute Name="Version" ReadOnly="true">
<Documentation>
<UserDocu>String: the version of this item in semantic triplet format</UserDocu>
<UserDocu>String representing the version of this item in semantic triplet format.</UserDocu>
</Documentation>
<Parameter Name="Version" Type="Object" />
</Attribute>
<Attribute Name="Description" ReadOnly="true">
<Documentation>
<UserDocu>String: the description of this item (text only, no markup allowed)</UserDocu>
<UserDocu>String representing the description of this item (text only, no markup allowed).</UserDocu>
</Documentation>
<Parameter Name="Description" Type="Object" />
</Attribute>
<Attribute Name="Maintainer" ReadOnly="true">
<Documentation>
<UserDocu>List of maintainer objects with 'name' and 'email' string attributes</UserDocu>
<UserDocu>List of maintainer objects with 'name' and 'email' string attributes.</UserDocu>
</Documentation>
<Parameter Name="Maintainer" Type="Object" />
</Attribute>
<Attribute Name="License" ReadOnly="true">
<Documentation>
<UserDocu>List of applicable licenses as objects with 'name' and 'file' string attributes</UserDocu>
<UserDocu>List of applicable licenses as objects with 'name' and 'file' string attributes.</UserDocu>
</Documentation>
<Parameter Name="License" Type="Object" />
</Attribute>
<Attribute Name="Urls" ReadOnly="true">
<Documentation>
<UserDocu>
List of URLs as objects with 'location' and 'type' string attributes, where type is one of:
* website
* repository
* bugtracker
* readme
* documentation
</UserDocu>
<UserDocu>List of URLs as objects with 'location' and 'type' string attributes, where type
is one of:
* website
* repository
* bugtracker
* readme
* documentation</UserDocu>
</Documentation>
<Parameter Name="Urls" Type="Object" />
</Attribute>
<Attribute Name="Author" ReadOnly="true">
<Documentation>
<UserDocu>List of author objects, each with a 'name' and a (potentially empty) 'email' string attribute</UserDocu>
<UserDocu>List of author objects, each with a 'name' and a (potentially empty) 'email'
string attribute.</UserDocu>
</Documentation>
<Parameter Name="Author" Type="Object" />
</Attribute>
<Attribute Name="Depend" ReadOnly="true">
<Documentation>
<UserDocu>
List of dependencies, as objects with the following attributes:
* package -- Required: must exactly match the contents of the 'name' element in the referenced package's package.xml file
* version_lt -- Optional: The dependency to the package is restricted to versions less than the stated version number
* version_lte -- Optional: The dependency to the package is restricted to versions less or equal than the stated version number
* version_eq -- Optional: The dependency to the package is restricted to a version equal than the stated version number
* version_gte -- Optional: The dependency to the package is restricted to versions greater or equal than the stated version number
* version_gt -- Optional: The dependency to the package is restricted to versions greater than the stated version number
* condition -- Optional: Conditional expression as documented in REP149
</UserDocu>
<UserDocu>List of dependencies, as objects with the following attributes:
* package
Required. Must exactly match the contents of the 'name' element in the
referenced package's package.xml file.
* version_lt
Optional. The dependency to the package is restricted to versions less than
the stated version number.
* version_lte
Optional. The dependency to the package is restricted to versions less or
equal than the stated version number.
* version_eq
Optional. The dependency to the package is restricted to a version equal
than the stated version number.
* version_gte
Optional. The dependency to the package is restricted to versions greater
or equal than the stated version number.
* version_gt
Optional. The dependency to the package is restricted to versions greater
than the stated version number.
* condition
Optional. Conditional expression as documented in REP149.</UserDocu>
</Documentation>
<Parameter Name="Depend" Type="Object" />
</Attribute>
<Attribute Name="Conflict" ReadOnly="true">
<Documentation>
<UserDocu>List of conflicts, format identical to dependencies</UserDocu>
<UserDocu>List of conflicts, format identical to dependencies.</UserDocu>
</Documentation>
<Parameter Name="Conflict" Type="Object" />
</Attribute>
<Attribute Name="Replace" ReadOnly="true">
<Documentation>
<UserDocu>List of things this item is considered by its author to replace: format identical to dependencies</UserDocu>
<UserDocu>List of things this item is considered by its author to replace. The format is
identical to dependencies.</UserDocu>
</Documentation>
<Parameter Name="Replace" Type="Object" />
</Attribute>
<Attribute Name="Tag" ReadOnly="true">
<Documentation>
<UserDocu>List of strings</UserDocu>
<UserDocu>List of strings.</UserDocu>
</Documentation>
<Parameter Name="Tag" Type="Object" />
</Attribute>
<Attribute Name="Icon" ReadOnly="true">
<Documentation>
<UserDocu>Relative path to an icon file</UserDocu>
<UserDocu>Relative path to an icon file.</UserDocu>
</Documentation>
<Parameter Name="Icon" Type="Object" />
</Attribute>
<Attribute Name="Classname" ReadOnly="true">
<Documentation>
<UserDocu>String: the name of the main Python class this item creates/represents</UserDocu>
<UserDocu>String representing the name of the main Python class this item
creates/represents.</UserDocu>
</Documentation>
<Parameter Name="Classname" Type="Object" />
</Attribute>
<Attribute Name="Subdirectory" ReadOnly="true">
<Documentation>
<UserDocu>String: the name of the subdirectory this content item is located in. If empty, the item is in a directory named the same as the content item.</UserDocu>
<UserDocu>String representing the name of the subdirectory this content item is located in.
If empty, the item is in a directory named the same as the content item.</UserDocu>
</Documentation>
<Parameter Name="Subdirectory" Type="Object" />
</Attribute>
<Attribute Name="File" ReadOnly="true">
<Documentation>
<UserDocu>A list of files associated with this item -- the meaning of each file is implementation-defined</UserDocu>
<UserDocu>List of files associated with this item.
The meaning of each file is implementation-defined.</UserDocu>
</Documentation>
<Parameter Name="File" Type="Object" />
</Attribute>
<Attribute Name="Content" ReadOnly="true">
<Documentation>
<UserDocu>A dictionary of lists of content items: defined recursively, each item is itself a Metadata object -- see package.xml file format documentation for details</UserDocu>
<UserDocu>Dictionary of lists of content items: defined recursively, each item is itself
a Metadata object.
See package.xml file format documentation for details.</UserDocu>
</Documentation>
<Parameter Name="Content" Type="Object" />
</Attribute>
<Attribute Name="FreeCADMin">
<Documentation>
<UserDocu>A string representing the minimum version of FreeCAD needed for this item. If unset it will be 0.0.0.</UserDocu>
<UserDocu>String representing the minimum version of FreeCAD needed for this item.
If unset it will be 0.0.0.</UserDocu>
</Documentation>
<Parameter Name="FreeCADMin" Type="Object" />
</Attribute>
<Attribute Name="FreeCADMax">
<Documentation>
<UserDocu>A string representing the maximum version of FreeCAD needed for this item. If unset it will be 0.0.0.</UserDocu>
<UserDocu>String representing the maximum version of FreeCAD needed for this item.
If unset it will be 0.0.0.</UserDocu>
</Documentation>
<Parameter Name="FreeCADMax" Type="Object" />
</Attribute>
<Methode Name="getLastSupportedFreeCADVersion">
<Documentation>
<UserDocu>getLastSupportedFreeCADVersion()
Search through all content package items, and determine if a maximum supported version of FreeCAD
is set. Returns None if no maximum version is set, or if *any* content item fails to provide a
maximum version (implying that that content item will work with all known versions).
</UserDocu>
<UserDocu>getLastSupportedFreeCADVersion() -> str or None\n
Search through all content package items, and determine if a maximum supported
version of FreeCAD is set.
Returns None if no maximum version is set, or if *any* content item fails to
provide a maximum version (implying that that content item will work with all
known versions).</UserDocu>
</Documentation>
</Methode>
<Methode Name="getFirstSupportedFreeCADVersion">
<Documentation>
<UserDocu>getFirstSupportedFreeCADVersion()
Search through all content package items, and determine if a minimum supported version of FreeCAD
is set. Returns 0.0 if no minimum version is set, or if *any* content item fails to provide a
minimum version (implying that that content item will work with all known versions -- technically
limited to 0.20 as the lowest known version since the metadata standard was added then).
</UserDocu>
<UserDocu>getFirstSupportedFreeCADVersion() -> str or None\n
Search through all content package items, and determine if a minimum supported
version of FreeCAD is set.
Returns 0.0 if no minimum version is set, or if *any* content item fails to
provide a minimum version (implying that that content item will work with all
known versions. Technically limited to 0.20 as the lowest known version since
the metadata standard was added then).</UserDocu>
</Documentation>
</Methode>
<Methode Name="supportsCurrentFreeCAD">
<Documentation>
<UserDocu>supportsCurrentFreeCAD()
Returns false if this metadata object directly indicates that it does not support the current
version of FreeCAD, or true if it makes no indication, or specifically indicates that it does
support the current version. Does not recurse into Content items.
</UserDocu>
<UserDocu>supportsCurrentFreeCAD() -> bool\n
Returns False if this metadata object directly indicates that it does not
support the current version of FreeCAD, or True if it makes no indication, or
specifically indicates that it does support the current version. Does not
recurse into Content items.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getGenericMetadata">
<Documentation>
<UserDocu>getGenericMetadata(name)
Get the list of GenericMetadata objects with key 'name'. Generic metadata objects are Python objects with
a string 'contents' and a dictionary of strings, 'attributes'. They represent unrecognized simple XML tags
in the metadata file.
</UserDocu>
<UserDocu>getGenericMetadata(name) -> list\n
Get the list of GenericMetadata objects with key 'name'.
Generic metadata objects are Python objects with a string 'contents' and a
dictionary of strings, 'attributes'. They represent unrecognized simple XML tags
in the metadata file.</UserDocu>
</Documentation>
</Methode>
+17 -10
View File
@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#include "Metadata.h"
#include <Base/FileInfo.h>
// inclusion of the generated files (generated out of MetadataPy.xml)
#include "MetadataPy.h"
@@ -34,7 +35,7 @@ XERCES_CPP_NAMESPACE_USE
// Returns a string which represents the object e.g. when printed in Python
std::string MetadataPy::representation(void) const
{
MetadataPy::PointerType ptr = reinterpret_cast<MetadataPy::PointerType>(_pcTwinPointer);
MetadataPy::PointerType ptr = getMetadataPtr();
std::stringstream str;
str << "Metadata [Name=(";
str << ptr->name();
@@ -64,10 +65,13 @@ int MetadataPy::PyInit(PyObject* args, PyObject* /*kwd*/)
// Main class constructor -- takes a file path, loads the metadata from it
PyErr_Clear();
const char* filename;
if (PyArg_ParseTuple(args, "s", &filename)) {
char* filename;
if (PyArg_ParseTuple(args, "et", "utf-8", &filename)) {
try {
auto md = new Metadata(filename);
std::string utf8Name = std::string(filename);
PyMem_Free(filename);
auto md = new Metadata(Base::FileInfo::stringToPath(utf8Name));
setTwinPointer(md);
return 0;
}
@@ -288,10 +292,11 @@ Py::Object MetadataPy::getContent(void) const
PyObject* MetadataPy::getGenericMetadata(PyObject* args)
{
const char* name;
if (!PyArg_ParseTuple(args, "s!", &name))
if (!PyArg_ParseTuple(args, "s", &name))
return nullptr;
auto gm = (*getMetadataPtr())[name];
auto pyGenericMetadata = new Py::List;
Py::List pyGenericMetadata;
for (const auto& item : gm) {
Py::Dict pyItem;
pyItem["contents"] = Py::String(item.contents);
@@ -300,12 +305,12 @@ PyObject* MetadataPy::getGenericMetadata(PyObject* args)
pyAttributes[attribute.first] = Py::String(attribute.second);
}
pyItem["attributes"] = pyAttributes;
pyGenericMetadata->append(pyItem);
pyGenericMetadata.append(pyItem);
}
return pyGenericMetadata->ptr();
return Py::new_reference_to(pyGenericMetadata);
}
Py::Object MetadataPy::getFreeCADMin() const
Py::Object MetadataPy::getFreeCADMin() const
{
return Py::String(getMetadataPtr()->freecadmin().str());
}
@@ -316,10 +321,11 @@ void MetadataPy::setFreeCADMin(Py::Object args)
PyObject* p = args.ptr();
if (!PyArg_ParseTuple(p, "s", &version))
return;
getMetadataPtr()->setFreeCADMin(App::Meta::Version(version));
}
Py::Object MetadataPy::getFreeCADMax() const
Py::Object MetadataPy::getFreeCADMax() const
{
return Py::String(getMetadataPtr()->freecadmax().str());
}
@@ -330,6 +336,7 @@ void MetadataPy::setFreeCADMax(Py::Object args)
PyObject* p = args.ptr();
if (!PyArg_ParseTuple(p, "s", &version))
return;
getMetadataPtr()->setFreeCADMax(App::Meta::Version(version));
}
+52 -14
View File
@@ -28,15 +28,18 @@
#endif
#include <atomic>
#include <Base/Exception.h>
#include <Base/Tools.h>
#include <Base/Writer.h>
#include <CXX/Objects.hxx>
#include "Application.h"
#include "Document.h"
#include "DocumentObject.h"
#include "Property.h"
#include "ObjectIdentifier.h"
#include "PropertyContainer.h"
using namespace App;
@@ -78,17 +81,40 @@ bool Property::isValidName(const char* name)
return name && name[0] != '\0';
}
std::string Property::getFullName() const {
std::string name;
if(myName) {
if(father)
name = father->getFullName() + ".";
void Property::SetRestoreError(const char * msg)
{
if (auto doc = father->getOwnerDocument())
doc->setErrorDescription(this, msg);
}
std::string Property::getFullName(bool python) const {
if(!myName || (python && !father))
return std::string(python?"None":"?");
std::ostringstream ss;
if(father)
ss << father->getFullName(python)
<< '.' << father->getPropertyPrefix();
ss << myName;
return ss.str();
}
std::string Property::getFileName(const char *postfix, const char *prefix) const {
std::ostringstream ss;
if(prefix)
ss << prefix;
if(!myName)
ss << "Property";
else {
std::string name = getFullName();
auto pos = name.find('#');
if(pos == std::string::npos)
ss << name;
else
name = "?.";
name += myName;
}else
return "?";
return name;
ss << (name.c_str()+pos+1);
}
if(postfix)
ss << postfix;
return ss.str();
}
short Property::getType(void) const
@@ -213,10 +239,15 @@ void Property::destroy(Property *p) {
void Property::touch()
{
if(GetApplication().isClosingAll())
return;
PropertyCleaner guard(this);
if (father)
father->onChanged(this);
StatusBits.set(Touched);
if (getName() && father) {
father->onEarlyChange(this);
father->onChanged(this);
}
}
void Property::setReadOnly(bool readOnly)
@@ -291,13 +322,20 @@ void Property::setStatus(Status pos, bool on) {
}
bool Property::isSame(const Property &other) const {
return isSameContent(other);
}
bool Property::isSameContent(const Property &other) const {
if(&other == this)
return true;
if(other.getTypeId() != getTypeId() || getMemSize() != other.getMemSize())
return false;
Base::StringWriter writer,writer2;
FC_STATIC Base::StringWriter writer,writer2;
writer.clear();
Save(writer);
writer2.clear();
other.Save(writer2);
return writer.getString() == writer2.getString();
}
+18 -1
View File
@@ -32,6 +32,10 @@
#include <string>
#include <FCGlobal.h>
// NOTE! define this to static thread_local if FreeCAD ever decides to use
// multi-threading recomputation.
#define FC_STATIC static
namespace Py {
class Object;
}
@@ -132,7 +136,10 @@ public:
*/
static bool isValidName(const char* name);
std::string getFullName() const;
/** Return a fully qualified property name that include its own's name
* @param python: if true, then return an expression for accessing this property in Python
*/
virtual std::string getFullName(bool python=false) const;
/// Get the class name of the associated property editor item
virtual const char* getEditorName(void) const { return ""; }
@@ -251,6 +258,8 @@ public:
/// Compare if this property has the same content as the given one
virtual bool isSame(const Property &other) const;
virtual void SetRestoreError(const char *) override;
/** Return a unique ID for the property
*
* The ID of a property is generated from a monotonically increasing
@@ -261,6 +270,11 @@ public:
*/
int64_t getID() const {return _id;}
/// Compare property by comparing their XML content
bool isSameContent(const Property &other) const;
virtual void beforeSave() const {}
friend class PropertyContainer;
friend struct PropertyData;
friend class DynamicProperty;
@@ -286,6 +300,9 @@ protected:
/// Verify a path for the current property
virtual void verifyPath(const App::ObjectIdentifier & p) const;
/// Return a file name suitable for saving this property
std::string getFileName(const char *postfix=0, const char *prefix=0) const;
private:
// forbidden
Property(const Property&);
+100 -28
View File
@@ -69,15 +69,15 @@ unsigned int PropertyContainer::getMemSize (void) const
App::Property* PropertyContainer::addDynamicProperty(
const char* type, const char* name, const char* group, const char* doc,
short attr, bool ro, bool hidden)
short attr, bool readonly, bool hidden)
{
return dynamicProps.addDynamicProperty(*this,type,name,group,doc,attr,ro,hidden);
return dynamicProps.addDynamicProperty(*this,type,name,group,doc,attr,readonly,hidden);
}
Property *PropertyContainer::getPropertyByName(const char* name) const
{
auto prop = dynamicProps.getDynamicPropertyByName(name);
if(prop)
if(prop)
return prop;
return getPropertyData().getPropertyByName(this,name);
}
@@ -121,7 +121,7 @@ short PropertyContainer::getPropertyType(const char *name) const
const char* PropertyContainer::getPropertyGroup(const Property* prop) const
{
auto group = dynamicProps.getPropertyGroup(prop);
if(group)
if(group)
return group;
return getPropertyData().getGroup(this,prop);
}
@@ -129,7 +129,7 @@ const char* PropertyContainer::getPropertyGroup(const Property* prop) const
const char* PropertyContainer::getPropertyGroup(const char *name) const
{
auto group = dynamicProps.getPropertyGroup(name);
if(group)
if(group)
return group;
return getPropertyData().getGroup(this,name);
}
@@ -137,7 +137,7 @@ const char* PropertyContainer::getPropertyGroup(const char *name) const
const char* PropertyContainer::getPropertyDocumentation(const Property* prop) const
{
auto doc = dynamicProps.getPropertyDocumentation(prop);
if(doc)
if(doc)
return doc;
return getPropertyData().getDocumentation(this,prop);
}
@@ -145,7 +145,7 @@ const char* PropertyContainer::getPropertyDocumentation(const Property* prop) co
const char* PropertyContainer::getPropertyDocumentation(const char *name) const
{
auto doc = dynamicProps.getPropertyDocumentation(name);
if(doc)
if(doc)
return doc;
return getPropertyData().getDocumentation(this,name);
}
@@ -221,15 +221,52 @@ void PropertyContainer::handleChangedPropertyType(XMLReader &reader, const char
PropertyData PropertyContainer::propertyData;
void PropertyContainer::Save (Base::Writer &writer) const
namespace App {
class PropertyContainerP
{
std::map<std::string,Property*> Map;
public:
std::map<std::string, Property*> propertyMap;
std::vector<Property*> transients;
void clear()
{
propertyMap.clear();
transients.clear();
}
};
struct PropertyContainerPGuard
{
PropertyContainerPGuard(PropertyContainerP & priv)
:priv(priv)
{}
~PropertyContainerPGuard()
{
priv.clear();
}
PropertyContainerP & priv;
};
}
void PropertyContainer::beforeSave() const
{
if (!_pimpl)
_pimpl.reset(new PropertyContainerP);
else
_pimpl->clear();
auto & Map = _pimpl->propertyMap;
auto & transients = _pimpl->transients;
getPropertyMap(Map);
std::vector<Property*> transients;
for(auto it=Map.begin();it!=Map.end();) {
auto prop = it->second;
if(prop->testStatus(Property::PropNoPersist)) {
if (prop->getContainer() != this
|| prop->testStatus(Property::PropNoPersist))
{
it = Map.erase(it);
continue;
}
@@ -239,9 +276,22 @@ void PropertyContainer::Save (Base::Writer &writer) const
{
transients.push_back(prop);
it = Map.erase(it);
}else
} else {
prop->beforeSave();
++it;
}
}
}
void PropertyContainer::Save (Base::Writer &writer) const
{
if (!_pimpl || _pimpl->propertyMap.empty())
beforeSave();
PropertyContainerPGuard guard(*_pimpl);
auto & Map = _pimpl->propertyMap;
auto & transients = _pimpl->transients;
writer.incInd(); // indentation for 'Properties Count'
writer.Stream() << writer.ind() << "<Properties Count=\"" << Map.size()
@@ -275,8 +325,8 @@ void PropertyContainer::Save (Base::Writer &writer) const
if(it->second->testStatus(Property::Transient)
|| it->second->getType() & Prop_Transient)
{
writer.Stream() << "</Property>\n";
writer.decInd();
writer.Stream() << "</Property>" << std::endl;
continue;
}
@@ -326,14 +376,21 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
reader.readElement("_Property");
Property* prop = getPropertyByName(reader.getAttribute("name"));
if(prop)
FC_TRACE("restore transient '" << prop->getName() << "'");
if(prop && reader.hasAttribute("status"))
prop->setStatusValue(reader.getAttributeAsUnsigned("status"));
FC_TRACE("restore transient '" << prop->getFullName() << "'");
if(prop && reader.hasAttribute("status")) {
decltype(Property::StatusBits) status(reader.getAttributeAsUnsigned("status"));
status.reset(Property::User1);
status.reset(Property::User2);
status.reset(Property::User3);
prop->setStatusValue(status.to_ulong());
}
}
for (int i=0 ;i<Cnt ;i++) {
reader.readElement("Property");
int guard;
reader.readElement("Property",&guard);
std::string PropName = reader.getAttribute("name");
Base::ReaderContext rctx(PropName);
std::string TypeName = reader.getAttribute("type");
// NOTE: We must also check the type of the current property because a
// subclass of PropertyContainer might change the type of a property but
@@ -346,7 +403,13 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
decltype(Property::StatusBits) status;
if(reader.hasAttribute("status")) {
status = decltype(status)(reader.getAttributeAsUnsigned("status"));
status = decltype(Property::StatusBits)(reader.getAttributeAsUnsigned("status"));
// User1~3 are currently reserved for various temporary usage.
// To avoid some potential problems, no persistence at the moment.
status.reset(Property::User1);
status.reset(Property::User2);
status.reset(Property::User3);
if(prop)
prop->setStatusValue(status.to_ulong());
}
@@ -357,10 +420,10 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
&& !status.test(Property::PropTransient)
&& !prop->testStatus(Property::PropTransient))
{
FC_TRACE("restore property '" << prop->getName() << "'");
FC_TRACE("restoring property " << prop->getFullName());
prop->Restore(reader);
}else
FC_TRACE("skip transient '" << prop->getName() << "'");
FC_TRACE("skip transient " << prop->getFullName());
}
// name matches but not the type
else if (prop) {
@@ -377,29 +440,38 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
reader.clearPartialRestoreProperty();
}
}
catch (const Base::XMLParseException&) {
catch (Base::XMLParseException &e) {
FC_ERR(e.what() << " while parsing " << getFullName() << '.' << PropName);
e.setReported(true);
throw; // re-throw
}
catch (const Base::RestoreError &) {
catch (const Base::RestoreError &e) {
e.ReportException();
reader.setPartialRestore(true);
reader.clearPartialRestoreProperty();
Base::Console().Error("Property %s of type %s was subject to a partial restore.\n",PropName.c_str(),TypeName.c_str());
FC_ERR(getFullName() << '.' << PropName << " (" << TypeName
<< "): was subject to a partial restore.");
}
catch (const Base::Exception &e) {
Base::Console().Error("%s\n", e.what());
e.ReportException();
FC_ERR(getFullName() << '.' << PropName << " (" << TypeName
<< ") restore error.");
}
catch (const std::exception &e) {
Base::Console().Error("%s\n", e.what());
FC_ERR(getFullName() << '.' << PropName << " (" << TypeName
<< ") restore error: " << e.what());
}
catch (const char* e) {
Base::Console().Error("%s\n", e);
FC_ERR(getFullName() << '.' << PropName << " (" << TypeName
<< ") restore error: " << e);
}
#ifndef FC_DEBUG
catch (...) {
Base::Console().Error("PropertyContainer::Restore: Unknown C++ exception thrown\n");
FC_ERR(getFullName() << '.' << PropName << " (" << TypeName
<< ") restore error: Unknown C++ exception thrown\n");
}
#endif
reader.readEndElement("Property");
reader.readEndElement("Property",&guard);
}
reader.readEndElement("Properties");
}
+25 -4
View File
@@ -40,6 +40,7 @@ namespace App
class Property;
class PropertyContainer;
class DocumentObject;
class Document;
class Extension;
enum PropertyType
@@ -135,6 +136,7 @@ struct AppExport PropertyData
void split(PropertyData *other);
};
class PropertyContainerP;
/** Base class of all classes with properties
*/
@@ -158,7 +160,17 @@ public:
virtual unsigned int getMemSize (void) const;
virtual std::string getFullName() const {return std::string();}
/** Return a fully qualified name for this container
* @param python: if true, then return an expression for accessing this container in Python
*/
virtual std::string getFullName(bool python=false) const {
(void)python;
return std::string();
}
/// Return owner document of this container
virtual App::Document *getOwnerDocument() const
{return nullptr;}
/// find a property by its name
virtual Property *getPropertyByName(const char* name) const;
@@ -196,7 +208,7 @@ public:
virtual App::Property* addDynamicProperty(
const char* type, const char* name=nullptr,
const char* group=nullptr, const char* doc=nullptr,
short attr=0, bool ro=false, bool hidden=false);
short attr=0, bool readonly=false, bool hidden=false);
DynamicProperty::PropData getDynamicPropertyData(const Property* prop) const {
return dynamicProps.getDynamicPropertyData(prop);
@@ -220,6 +232,7 @@ public:
virtual void Save (Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual void beforeSave() const;
virtual void editProperty(const char * /*propName*/) {}
@@ -236,6 +249,11 @@ public:
protected:
/** get called by the container when a property has changed
*
* This function is called before onChanged()
*/
virtual void onEarlyChange(const Property* /*prop*/){}
/// get called by the container when a property has changed
virtual void onChanged(const Property* /*prop*/){}
/// get called before the value is changed
@@ -256,9 +274,12 @@ private:
protected:
DynamicProperty dynamicProps;
private:
private:
std::string _propertyPrefix;
static PropertyData propertyData;
static PropertyData propertyData;
mutable std::unique_ptr<PropertyContainerP> _pimpl;
};
/// Property define
+70 -57
View File
@@ -12,126 +12,139 @@
DisableNotify="true">
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
<UserDocu>This is a Persistence class</UserDocu>
<UserDocu>App.PropertyContainer class.</UserDocu>
</Documentation>
<Methode Name="getPropertyByName">
<Documentation>
<UserDocu>
getPropertyByName(name,checkOwner=0)
Return the value of a named property. Note that the returned property may not
always belong to this container (e.g. from a linked object).
* name: name of the property
* checkOwner: 0: just return the property
1: raise exception if not found or the property
does not belong to this container
2: return a tuple(owner,property_value)
</UserDocu>
<UserDocu>getPropertyByName(name, checkOwner=0) -> object or Tuple\n
Returns the value of a named property. Note that the returned property may not
always belong to this container (e.g. from a linked object).\n
name : str\n Name of the property.
checkOwner : int\n 0: just return the property.
1: raise exception if not found or the property does not belong to this container.
2: return a tuple (owner, propertyValue).</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPropertyTouchList">
<Documentation>
<UserDocu>Return a list of index of touched values for list type properties.</UserDocu>
<UserDocu>getPropertyTouchList(name) -> tuple\n
Returns a list of index of touched values for list type properties.\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getTypeOfProperty">
<Documentation>
<UserDocu>Return the type of a named property. This can be (Hidden,ReadOnly,Output) or any combination. </UserDocu>
<UserDocu>getTypeOfProperty(name) -> list\n
Returns the type of a named property. This can be a list conformed by elements in
(Hidden, NoRecompute, NoPersist, Output, ReadOnly, Transient).\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getTypeIdOfProperty">
<Documentation>
<UserDocu>Returns the C++ class name of a named property.</UserDocu>
<UserDocu>getTypeIdOfProperty(name) -> str\n
Returns the C++ class name of a named property.\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="setEditorMode">
<Documentation>
<UserDocu>Set the behaviour of the property in the property editor.
0 - default behaviour
1 - item is ready-only
2 - item is hidden
</UserDocu>
<UserDocu>setEditorMode(name, type) -> None\n
Set the behaviour of the property in the property editor.\n
name : str\n Property name.
type : int, sequence of str\n Property type.
0: default behaviour. 1: item is ready-only. 2: item is hidden. 3: item is hidden and read-only.
If sequence, the available items are 'ReadOnly' and 'Hidden'.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getEditorMode">
<Documentation>
<UserDocu>Get the behaviour of the property in the property editor.
It returns a list of strings with the current mode. If the list is empty there are no special restrictions.
If the list contains 'ReadOnly' then the item appears in the property editor but is disabled.
If the list contains 'Hidden' then the item even doesn't appear in the property editor.
</UserDocu>
<UserDocu>getEditorMode(name) -> list\n
Get the behaviour of the property in the property editor.
It returns a list of strings with the current mode. If the list is empty there are no
special restrictions.
If the list contains 'ReadOnly' then the item appears in the property editor but is
disabled.
If the list contains 'Hidden' then the item even doesn't appear in the property editor.\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getGroupOfProperty">
<Documentation>
<UserDocu>Return the name of the group which the property belongs to in this class. The properties sorted in different named groups for convenience.</UserDocu>
<UserDocu>getGroupOfProperty(name) -> str\n
Returns the name of the group which the property belongs to in this class.
The properties are sorted in different named groups for convenience.\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="setGroupOfProperty">
<Documentation>
<UserDocu>Set the name of the group of a dynamic property.</UserDocu>
<UserDocu>setGroupOfProperty(name, group) -> None\n
Set the name of the group of a dynamic property.\n
name : str\n Property name.
group : str\n Group name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="setPropertyStatus">
<Documentation>
<UserDocu>
setPropertyStatus(name,val): Set property status
name(String): property name
val(String|Int|[String|Int...]): text or integer value, or list/tuple of
values. Call getPropertyStatus() to get a list of supported text value.
If the text start with '-' or the integer value is negative, then the
status is cleared.
</UserDocu>
<UserDocu>setPropertyStatus(name, val) -> None\n
Set property status.\n
name : str\n Property name.
val : int, str, sequence of str or int\n Call getPropertyStatus() to get a list of supported text value.
If the text start with '-' or the integer value is negative, then the status is cleared.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPropertyStatus">
<Documentation>
<UserDocu>
getPropertyStatus(name=''): Get property status.
name(String): property name. If name is empty, return a list of supported
text names of the status.
</UserDocu>
<UserDocu>getPropertyStatus(name='') -> list\n
Get property status.\n
name : str\n Property name. If empty, returns a list of supported text names of the status.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getDocumentationOfProperty">
<Documentation>
<UserDocu>Return the documentation string of the property of this class.</UserDocu>
<UserDocu>getDocumentationOfProperty(name) -> str\n
Returns the documentation string of the property of this class.\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="setDocumentationOfProperty">
<Documentation>
<UserDocu>Set the documentation string of a dynamic property of this class.</UserDocu>
<UserDocu>setDocumentationOfProperty(name, docstring) -> None\n
Set the documentation string of a dynamic property of this class.\n
name : str\n Property name.
docstring : str\n Documentation string.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getEnumerationsOfProperty">
<Documentation>
<UserDocu>Return all enumeration strings of the property of this class or None if not a PropertyEnumeration.</UserDocu>
<UserDocu>getEnumerationsOfProperty(name) -> list or None\n
Return all enumeration strings of the property of this class or None if not a
PropertyEnumeration.\n
name : str\n Property name.</UserDocu>
</Documentation>
</Methode>
<Methode Name="dumpPropertyContent" Keyword="true" Const="true">
<Documentation>
<UserDocu>Dumps the content of the property, both the XML representation as well as the additional datafiles
required, into a byte representation. It will be returned as byte array.
dumpPropertyContent(propertyname) -- returns a byte array with full content
dumpPropertyContent(propertyname, [Compression=1-9]) -- Sets the data compression from 0 (no) to 9 (max)
</UserDocu>
<UserDocu>dumpPropertyContent(Property, Compression=3) -> bytearray\n
Dumps the content of the property, both the XML representation and the additional
data files required, into a byte representation.\n
Property : str\n Property Name.
Compression : int\n Set the data compression level in the range [0, 9]. Set to 0 for no compression.</UserDocu>
</Documentation>
</Methode>
<Methode Name="restorePropertyContent">
<Documentation>
<UserDocu>Restore the content of given property from a byte representation as stored by \"dumpContent\".
It could be restored from any python object implementing the buffer protocol.
restorePropertyContent(propertyname, buffer) -- restores from the given byte array
</UserDocu>
<UserDocu>restorePropertyContent(name, obj) -> None\n
Restore the content of the object from a byte representation as stored by `dumpPropertyContent`.
It could be restored from any Python object implementing the buffer protocol.\n
name : str\n Property name.
obj : buffer\n Object with buffer protocol support.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="PropertiesList" ReadOnly="true">
<Documentation>
<UserDocu>A list of all property names</UserDocu>
<UserDocu>A list of all property names.</UserDocu>
</Documentation>
<Parameter Name="PropertiesList" Type="List"/>
</Attribute>
+75 -53
View File
@@ -54,16 +54,24 @@ PyObject* PropertyContainerPy::getPropertyByName(PyObject *args)
int checkOwner=0;
if (!PyArg_ParseTuple(args, "s|i", &pstr, &checkOwner))
return nullptr;
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (prop) {
if(!checkOwner || (checkOwner==1 && prop->getContainer()==getPropertyContainerPtr()))
return prop->getPyObject();
Py::TupleN res(Py::asObject(prop->getContainer()->getPyObject()),
Py::asObject(prop->getPyObject()));
return Py::new_reference_to(res);
if (checkOwner < 0 || checkOwner > 2) {
PyErr_SetString(PyExc_ValueError, "'checkOwner' expected in the range [0, 2]");
return nullptr;
}
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return nullptr;
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return nullptr;
}
if (!checkOwner || (checkOwner==1 && prop->getContainer()==getPropertyContainerPtr()))
return prop->getPyObject();
Py::TupleN res(Py::asObject(prop->getContainer()->getPyObject()), Py::asObject(prop->getPyObject()));
return Py::new_reference_to(res);
}
PyObject* PropertyContainerPy::getPropertyTouchList(PyObject *args)
@@ -71,6 +79,7 @@ PyObject* PropertyContainerPy::getPropertyTouchList(PyObject *args)
char *pstr;
if (!PyArg_ParseTuple(args, "s", &pstr))
return nullptr;
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (prop && prop->isDerivedFrom(PropertyLists::getClassTypeId())) {
const auto &touched = static_cast<PropertyLists*>(prop)->getTouchList();
@@ -80,11 +89,14 @@ PyObject* PropertyContainerPy::getPropertyTouchList(PyObject *args)
ret.setItem(i++,Py::Long(idx));
return Py::new_reference_to(ret);
}
else if(!prop)
else if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
else
return nullptr;
}
else {
PyErr_Format(PyExc_AttributeError, "Property '%s' is not of list type", pstr);
return nullptr;
return nullptr;
}
}
PyObject* PropertyContainerPy::getTypeOfProperty(PyObject *args)
@@ -168,7 +180,7 @@ PyObject* PropertyContainerPy::setEditorMode(PyObject *args)
status.reset(Property::ReadOnly);
status.reset(Property::Hidden);
for (Py::Sequence::iterator it = seq.begin();it!=seq.end();++it) {
std::string str = (std::string)Py::String(*it);
std::string str = static_cast<std::string>(Py::String(*it));
if (str == "ReadOnly")
status.set(Property::ReadOnly);
else if (str == "Hidden")
@@ -210,28 +222,30 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args)
PyObject *pyValue;
if (!PyArg_ParseTuple(args, "sO", &name, &pyValue))
return nullptr;
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name);
return nullptr;
}
auto linkProp = Base::freecad_dynamic_cast<App::PropertyLinkBase>(prop);
auto linkProp = Base::freecad_dynamic_cast<App::PropertyLinkBase>(prop);
std::bitset<32> status(prop->getStatus());
size_t count = 1;
bool isSeq = false;
if(PyList_Check(pyValue) || PyTuple_Check(pyValue)) {
if (PyList_Check(pyValue) || PyTuple_Check(pyValue)) {
isSeq = true;
count = PySequence_Size(pyValue);
}
for(size_t i=0;i<count;++i) {
for(size_t i=0; i<count; ++i) {
Py::Object item;
if(isSeq)
if (isSeq)
item = Py::Object(PySequence_GetItem(pyValue,i));
else
item = Py::Object(pyValue);
bool value = true;
if(item.isString()) {
if (item.isString()) {
const auto &statusMap = getStatusMap();
auto v = (std::string)Py::String(item);
if(v.size()>1 && v[0] == '-') {
@@ -248,7 +262,8 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args)
return nullptr;
}
status.set(it->second,value);
}else if(item.isNumeric()) {
}
else if (item.isNumeric()) {
int v = Py::Int(item);
if(v<0) {
value = false;
@@ -257,7 +272,8 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args)
if(v==0 || v>31)
PyErr_Format(PyExc_ValueError, "Status value out of range '%d'", v);
status.set(v,value);
} else {
}
else {
PyErr_SetString(PyExc_TypeError, "Expects status type to be Int or String");
return nullptr;
}
@@ -275,31 +291,34 @@ PyObject* PropertyContainerPy::getPropertyStatus(PyObject *args)
Py::List ret;
const auto &statusMap = getStatusMap();
if(!name[0]) {
if (!name[0]) {
for(auto &v : statusMap)
ret.append(Py::String(v.first.c_str()));
}else{
}
else {
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
if (prop) {
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name);
return nullptr;
}
auto linkProp = Base::freecad_dynamic_cast<App::PropertyLinkBase>(prop);
if(linkProp && linkProp->testFlag(App::PropertyLinkBase::LinkAllowPartial))
ret.append(Py::String("AllowPartial"));
auto linkProp = Base::freecad_dynamic_cast<App::PropertyLinkBase>(prop);
if (linkProp && linkProp->testFlag(App::PropertyLinkBase::LinkAllowPartial))
ret.append(Py::String("AllowPartial"));
std::bitset<32> bits(prop->getStatus());
for(size_t i=1;i<bits.size();++i) {
if(!bits[i]) continue;
bool found = false;
for(auto &v : statusMap) {
if(v.second == (int)i) {
ret.append(Py::String(v.first.c_str()));
found = true;
break;
}
std::bitset<32> bits(prop->getStatus());
for(size_t i=1; i<bits.size(); ++i) {
if(!bits[i]) continue;
bool found = false;
for(auto &v : statusMap) {
if(v.second == static_cast<int>(i)) {
ret.append(Py::String(v.first.c_str()));
found = true;
break;
}
if(!found)
ret.append(Py::Int((long)i));
}
if (!found)
ret.append(Py::Int(static_cast<long>(i)));
}
}
return Py::new_reference_to(ret);
@@ -312,6 +331,11 @@ PyObject* PropertyContainerPy::getEditorMode(PyObject *args)
return nullptr;
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name);
return nullptr;
}
Py::List ret;
if (prop) {
short Type = prop->getType();
@@ -357,7 +381,8 @@ PyObject* PropertyContainerPy::setGroupOfProperty(PyObject *args)
}
prop->getContainer()->changeDynamicProperty(prop,group,nullptr);
Py_Return;
} PY_CATCH
}
PY_CATCH
}
@@ -373,9 +398,9 @@ PyObject* PropertyContainerPy::getDocumentationOfProperty(PyObject *args)
return nullptr;
}
const char* Group = getPropertyContainerPtr()->getPropertyDocumentation(prop);
if (Group)
return Py::new_reference_to(Py::String(Group));
const char* docstr = getPropertyContainerPtr()->getPropertyDocumentation(prop);
if (docstr)
return Py::new_reference_to(Py::String(docstr));
else
return Py::new_reference_to(Py::String(""));
}
@@ -395,7 +420,8 @@ PyObject* PropertyContainerPy::setDocumentationOfProperty(PyObject *args)
}
prop->getContainer()->changeDynamicProperty(prop,nullptr,doc);
Py_Return;
} PY_CATCH
}
PY_CATCH
}
PyObject* PropertyContainerPy::getEnumerationsOfProperty(PyObject *args)
@@ -411,13 +437,10 @@ PyObject* PropertyContainerPy::getEnumerationsOfProperty(PyObject *args)
}
PropertyEnumeration *enumProp = dynamic_cast<PropertyEnumeration*>(prop);
if (!enumProp) {
Py_INCREF(Py_None);
return Py_None;
}
if (!enumProp)
Py_Return;
std::vector<std::string> enumerations = enumProp->getEnumVector();
Py::List ret;
for (std::vector<std::string>::const_iterator it = enumerations.begin(); it != enumerations.end(); ++it) {
ret.append(Py::String(*it));
@@ -432,7 +455,7 @@ Py::List PropertyContainerPy::getPropertiesList(void) const
getPropertyContainerPtr()->getPropertyMap(Map);
for (std::map<std::string,Property*>::const_iterator It=Map.begin();It!=Map.end();++It)
for (std::map<std::string,Property*>::const_iterator It=Map.begin(); It!=Map.end(); ++It)
ret.append(Py::String(It->first));
return ret;
@@ -442,12 +465,11 @@ Py::List PropertyContainerPy::getPropertiesList(void) const
PyObject* PropertyContainerPy::dumpPropertyContent(PyObject *args, PyObject *kwds)
{
int compression = 3;
char* property;
static char* kwds_def[] = {"Property", "Compression",nullptr};
const char* property;
static char* kwds_def[] = {"Property", "Compression", nullptr};
PyErr_Clear();
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwds_def, &property, &compression)) {
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwds_def, &property, &compression))
return nullptr;
}
Property* prop = getPropertyContainerPtr()->getPropertyByName(property);
if (!prop) {
+3 -3
View File
@@ -23,8 +23,8 @@
#ifndef EXPRESSIONENGINE_H
#define EXPRESSIONENGINE_H
#include <functional>
#include <boost/unordered/unordered_map.hpp>
#include <boost/function.hpp>
#include <boost_signals2.hpp>
#include <boost_graph_adjacency_list.hpp>
#include <boost/graph/topological_sort.hpp>
@@ -77,7 +77,7 @@ public:
virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent,
App::DocumentObject *oldObj, App::DocumentObject *newObj) const override;
typedef boost::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)> ValidatorFunc;
typedef std::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)> ValidatorFunc;
/**
* @brief The ExpressionInfo struct encapsulates an expression.
@@ -179,7 +179,7 @@ private:
typedef boost::adjacency_list< boost::listS, boost::vecS, boost::directedS > DiGraph;
typedef std::pair<int, int> Edge;
// Note: use std::map instead of unordered_map to keep the binding order stable
#ifdef FC_OS_MACOSX
#if defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
typedef std::map<App::ObjectIdentifier, ExpressionInfo> ExpressionMap;
#else
typedef std::map<const App::ObjectIdentifier, ExpressionInfo> ExpressionMap;
+9 -18
View File
@@ -354,19 +354,17 @@ void PropertyFileIncluded::Save (Base::Writer &writer) const
_cValue = fi.filePath();
}
if (writer.isForceXML()) {
if (writer.isForceXML()>3) {
if (!_cValue.empty()) {
Base::FileInfo file(_cValue.c_str());
writer.Stream() << writer.ind() << "<FileIncluded data=\""
<< file.fileName() << "\">" << std::endl;
<< encodeAttribute(file.fileName()) << "\">\n";
// write the file in the XML stream
writer.incInd();
writer.insertBinFile(_cValue.c_str());
writer.decInd();
writer.Stream() << writer.ind() <<"</FileIncluded>" << endl;
writer.Stream() << writer.ind() <<"</FileIncluded>\n";
}
else {
writer.Stream() << writer.ind() << "<FileIncluded data=\"\"/>" << std::endl;
writer.Stream() << writer.ind() << "<FileIncluded data=\"\"/>\n";
}
}
else {
@@ -406,7 +404,7 @@ void PropertyFileIncluded::Restore(Base::XMLReader &reader)
// is in the document transient path
aboutToSetValue();
_cValue = getDocTransientPath() + "/" + file;
reader.readBinFile(_cValue.c_str());
reader.readCharacters(_cValue.c_str(),true);
reader.readEndElement("FileIncluded");
_BaseFileName = file;
// set read-only after restoring the file
@@ -427,12 +425,7 @@ void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const
throw Base::FileSystemError(str.str());
}
// copy plain data
unsigned char c;
std::ostream& to = writer.Stream();
while (from.get((char&)c)) {
to.put((char)c);
}
writer.Stream() << from.rdbuf();
}
void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader)
@@ -443,7 +436,7 @@ void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader)
// same file of another object (e.g. for copy&paste of objects inside the same document).
return;
}
Base::ofstream to(fi, std::ios::out | std::ios::binary);
Base::ofstream to(fi, std::ios::out | std::ios::binary | std::ios::trunc);
if (!to) {
std::stringstream str;
str << "PropertyFileIncluded::RestoreDocFile(): "
@@ -453,10 +446,8 @@ void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader)
// copy plain data
aboutToSetValue();
unsigned char c;
while (reader.get((char&)c)) {
to.put((char)c);
}
reader >> to.rdbuf();
to.close();
// set read-only after restoring the file
+59 -3
View File
@@ -23,19 +23,30 @@
#include "PreCompiled.h"
#include <Base/MatrixPy.h>
#include <Base/PlacementPy.h>
#include <Base/Reader.h>
#ifndef _PreComp_
# include <assert.h>
#endif
#include <boost/algorithm/string/predicate.hpp>
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Exception.h>
#include <Base/MatrixPy.h>
#include <Base/Reader.h>
#include <Base/PlacementPy.h>
#include <Base/Quantity.h>
#include <Base/QuantityPy.h>
#include <Base/Rotation.h>
#include <Base/RotationPy.h>
#include <Base/Stream.h>
#include <Base/Tools.h>
#include <Base/Writer.h>
#include <Base/VectorPy.h>
#include <Base/Writer.h>
#include "Document.h"
#include "DocumentObject.h"
#include "PropertyGeo.h"
#include "Placement.h"
#include "ObjectIdentifier.h"
@@ -1136,3 +1147,48 @@ PropertyComplexGeoData::~PropertyComplexGeoData()
{
}
std::string PropertyComplexGeoData::getElementMapVersion(bool) const {
auto data = getComplexData();
if(!data)
return std::string();
auto owner = Base::freecad_dynamic_cast<DocumentObject>(getContainer());
std::ostringstream ss;
if(owner && owner->getDocument()
&& owner->getDocument()->getStringHasher()==data->Hasher)
ss << "1.";
else
ss << "0.";
ss << data->getElementMapVersion();
return ss.str();
}
bool PropertyComplexGeoData::checkElementMapVersion(const char * ver) const
{
auto data = getComplexData();
if(!data)
return false;
auto owner = Base::freecad_dynamic_cast<DocumentObject>(getContainer());
std::ostringstream ss;
const char *prefix;
if(owner && owner->getDocument()
&& owner->getDocument()->getStringHasher() == data->Hasher)
prefix = "1.";
else
prefix = "0.";
if (!boost::starts_with(ver, prefix))
return true;
return data->checkElementMapVersion(ver+2);
}
void PropertyComplexGeoData::afterRestore()
{
auto data = getComplexData();
if (data && data->isRestoreFailed()) {
data->resetRestoreFailure();
auto owner = Base::freecad_dynamic_cast<DocumentObject>(getContainer());
if (owner && owner->getDocument() && !owner->getDocument()->testStatus(App::Document::PartialDoc))
owner->getDocument()->addRecomputeObject(owner);
}
PropertyGeometry::afterRestore();
}
+16
View File
@@ -508,6 +508,10 @@ public:
/** @name Modification */
//@{
/// Set the placement of the geometry
virtual void setTransform(const Base::Matrix4D& rclTrf) = 0;
/// Get the placement of the geometry
virtual Base::Matrix4D getTransform() const = 0;
/// Applies a transformation on the real geometric data type
virtual void transformGeometry(const Base::Matrix4D &rclMat) = 0;
/// Retrieve bounding box information
@@ -537,6 +541,18 @@ public:
virtual const Data::ComplexGeoData* getComplexData() const = 0;
virtual Base::BoundBox3d getBoundingBox() const = 0;
//@}
/** Return the element map version
*
* @param persisted: if true, return the restored element map version. Or
* else, return the current element map version
*/
virtual std::string getElementMapVersion(bool restored=false) const;
/// Return true to signal element map version change
virtual bool checkElementMapVersion(const char * ver) const;
virtual void afterRestore();
};
} // namespace App
+353 -117
View File
@@ -26,22 +26,28 @@
#include <QDir>
#include <QFileInfo>
#include <boost/algorithm/string/predicate.hpp>
#include <boost_bind_bind.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/stream.hpp>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Tools.h>
#include "PropertyLinks.h"
#include "Application.h"
#include "Document.h"
#include "DocumentObject.h"
#include "DocumentObjectPy.h"
#include "DocumentObserver.h"
#include "GeoFeature.h"
#include "ObjectIdentifier.h"
FC_LOG_LEVEL_INIT("PropertyLinks",true,true)
FC_LOG_LEVEL_INIT("App",true,true)
using namespace App;
using namespace Base;
@@ -56,6 +62,9 @@ namespace bp = boost::placeholders;
TYPESYSTEM_SOURCE_ABSTRACT(App::PropertyLinkBase , App::Property)
static std::unordered_map<std::string, std::set<PropertyLinkBase*> > _LabelMap;
static std::unordered_map<App::DocumentObject *, std::unordered_set<PropertyLinkBase*> > _ElementRefMap;
PropertyLinkBase::PropertyLinkBase()
{}
@@ -68,6 +77,11 @@ void PropertyLinkBase::setAllowExternal(bool allow) {
setFlag(LinkAllowExternal,allow);
}
void PropertyLinkBase::setReturnNewElement(bool enable)
{
setFlag(LinkNewElement, enable);
}
void PropertyLinkBase::hasSetValue() {
auto owner = dynamic_cast<DocumentObject*>(getContainer());
if(owner)
@@ -99,6 +113,15 @@ bool PropertyLinkBase::isSame(const Property &other) const
}
void PropertyLinkBase::unregisterElementReference() {
for(auto obj : _ElementRefs) {
auto it = _ElementRefMap.find(obj);
if(it != _ElementRefMap.end()) {
it->second.erase(this);
if(it->second.empty())
_ElementRefMap.erase(it);
}
}
_ElementRefs.clear();
}
void PropertyLinkBase::unregisterLabelReferences()
@@ -203,39 +226,76 @@ static std::string propertyName(const Property *prop) {
return prop->getFullName();
}
std::vector<App::SubObjectT>
PropertyLinkBase::linkedElementsT(bool all) const
{
std::vector<App::DocumentObject*> objs;
std::vector<std::string> subs;
getLinks(objs,all,&subs,true);
std::vector<App::SubObjectT> res;
res.reserve(objs.size());
assert(objs.size() == subs.size());
for (unsigned i=0; i<objs.size(); ++i)
res.emplace_back(objs[i], subs[i].c_str());
return res;
}
const std::unordered_set<PropertyLinkBase*>&
PropertyLinkBase::getElementReferences(DocumentObject *feature)
{
static std::unordered_set<PropertyLinkBase*> none;
auto it = _ElementRefMap.find(feature);
if(it == _ElementRefMap.end())
return none;
return it->second;
}
void PropertyLinkBase::updateElementReferences(DocumentObject *feature, bool reverse) {
(void)feature;
(void)reverse;
if(!feature || !feature->getNameInDocument())
return;
auto it = _ElementRefMap.find(feature);
if(it == _ElementRefMap.end())
return;
std::vector<PropertyLinkBase*> props;
props.reserve(it->second.size());
props.insert(props.end(),it->second.begin(),it->second.end());
for(auto prop : props) {
if(prop->getContainer()) {
try {
prop->updateElementReference(feature,reverse,true);
}catch(Base::Exception &e) {
e.ReportException();
FC_ERR("Failed to update element reference of " << propertyName(prop));
}catch(std::exception &e) {
FC_ERR("Failed to update element reference of " << propertyName(prop)
<< ": " << e.what());
}
}
}
}
void PropertyLinkBase::_registerElementReference(App::DocumentObject *obj, std::string &sub, ShadowSub &shadow)
{
(void)obj;
(void)sub;
(void)shadow;
if(!obj || !obj->getNameInDocument() || sub.empty())
return;
if(shadow.first.empty()) {
_updateElementReference(0,obj,sub,shadow,false);
return;
}
GeoFeature *geo = 0;
const char *element = 0;
std::pair<std::string, std::string> elementName;
GeoFeature::resolveElement(obj,sub.c_str(), elementName,true,
GeoFeature::ElementNameType::Export,0,&element,&geo);
if(!geo || !element || !element[0])
return;
if(_ElementRefs.insert(geo).second)
_ElementRefMap[geo].insert(this);
}
class StringGuard {
public:
StringGuard(char *c)
:c(c)
{
v1 = c[0];
v2 = c[1];
c[0] = '.';
c[1] = 0;
}
~StringGuard()
{
c[0] = v1;
c[1] = v2;
}
char *c;
char v1;
char v2;
};
void PropertyLinkBase::restoreLabelReference(const DocumentObject *obj,
std::string &subname, ShadowSub *shadow)
{
@@ -277,12 +337,139 @@ bool PropertyLinkBase::_updateElementReference(DocumentObject *feature,
App::DocumentObject *obj, std::string &sub, ShadowSub &shadow,
bool reverse, bool notify)
{
(void)feature;
(void)obj;
(void)reverse;
(void)notify;
shadow.second = sub;
return false;
if(!obj || !obj->getNameInDocument()) return false;
ShadowSub elementName;
const char *subname;
if(shadow.first.size())
subname = shadow.first.c_str();
else if(shadow.second.size())
subname = shadow.second.c_str();
else
subname = sub.c_str();
GeoFeature *geo = 0;
const char *element=0;
auto ret = GeoFeature::resolveElement(obj,subname, elementName,true,
GeoFeature::ElementNameType::Export,feature,&element,&geo);
if(!ret || !geo || !element || !element[0]) {
if(elementName.second.size())
shadow.second.swap(elementName.second);
return false;
}
if(_ElementRefs.insert(geo).second)
_ElementRefMap[geo].insert(this);
if (!reverse) {
if (elementName.first.empty()) {
shadow.second.swap(elementName.second);
return false;
}
if(shadow==elementName)
return false;
}
bool missing = GeoFeature::hasMissingElement(elementName.second.c_str());
if (feature == geo && (missing || reverse)) {
// If the referenced element is missing, or we are generating element
// map for the first time, or we are re-generating the element map due
// to version change, i.e. 'reverse', try search by geometry first
const char *oldElement = Data::ComplexGeoData::findElementName(shadow.second.c_str());
if(!Data::ComplexGeoData::hasMissingElement(oldElement)) {
const auto &names = geo->searchElementCache(oldElement);
if(names.size()) {
missing = false;
std::string newsub(subname, strlen(subname) - strlen(element));
newsub += names.front();
GeoFeature::resolveElement(obj, newsub.c_str(), elementName,true,
GeoFeature::ElementNameType::Export,feature);
const auto &oldSub = shadow.first.size()?shadow.first:shadow.second;
const auto &newSub = elementName.first.size()?elementName.first:elementName.second;
if (oldSub != newSub) {
FC_WARN(propertyName(this)
<< " auto change element reference " << ret->getFullName() << " "
<< oldSub << " -> " << newSub);
}
}
// Note: the following code proves to be too risky. There is no way
// (so far) to ensure the recompute do not change the geometry. If
// the geometry does remain the same, the above geometry search
// should be able to find the new reference any way!
#if 0
else if (missing && reverse && shadow.first.size()) {
// reverse means we are trying to either generate the element
// name for the first time, or upgrade to a new map version. In
// case of upgrading, we still consult the original mapped name
// in first try. Here means the first try failed, and the
// geometry search cannot find any match, so we try the
// non-mapped name as a last resort.
//
// WARNING! We are assuming the recomputation is done with no
// actual property change, and the resulting geometry remains
// the same. If this condition is not met, the result may be
// undesirable. TODO: find a way to ensure this condition.
GeoFeature::resolveElement(obj, shadow.second.c_str(), elementName, true,
GeoFeature::ElementNameType::Export,feature);
if(!elementName.second.empty()) {
missing = Data::ComplexGeoData::hasMissingElement(elementName.second.c_str());
if (!missing) {
FC_WARN(propertyName(this)
<< " element reference changed " << ret->getFullName() << " "
<< shadow.first << " -> " << elementName.first);
}
}
}
#endif
}
}
if(notify)
aboutToSetValue();
if(missing) {
FC_WARN(propertyName(this)
<< " missing element reference " << ret->getFullName() << " "
<< (elementName.first.size()?elementName.first:elementName.second));
shadow.second.swap(elementName.second);
} else {
FC_TRACE(propertyName(this)
<< " element reference shadow update " << ret->getFullName() << " "
<< shadow.first << " -> " << elementName.first);
shadow.swap(elementName);
if(shadow.first.size() && Data::ComplexGeoData::hasMappedElementName(sub.c_str()))
sub = shadow.first;
}
if(reverse) {
if(shadow.first.size() && Data::ComplexGeoData::hasMappedElementName(sub.c_str()))
sub = shadow.first;
else
sub = shadow.second;
return true;
}
if (missing) {
if (sub != shadow.first)
sub = shadow.second;
return true;
}
auto pos2 = shadow.first.rfind('.');
if(pos2 == std::string::npos)
return true;
++pos2;
auto pos = sub.rfind('.');
if(pos == std::string::npos)
pos = 0;
else
++pos;
if(pos==pos2) {
if(sub.compare(pos,sub.size()-pos,&shadow.first[pos2])!=0) {
FC_LOG("element reference update " << sub << " -> " << shadow.first);
sub.replace(pos,sub.size()-pos,&shadow.first[pos2]);
}
} else if(sub!=shadow.second) {
FC_LOG("element reference update " << sub << " -> " << shadow.second);
sub = shadow.second;
}
return true;
}
std::pair<DocumentObject*, std::string>
@@ -291,6 +478,8 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject
{
std::pair<DocumentObject*, std::string> res;
res.first = 0;
if (!obj)
return res;
if(oldObj == obj) {
if(owner == parent) {
@@ -310,6 +499,11 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject
return res;
}
return res;
} else if (newObj == obj) {
// This means the new object is already sub-object of this parent
// (consider a case of swapping the tool and base object of the Cut
// feature). We'll swap the old and new object.
return tryReplaceLink(owner, obj, parent, newObj, oldObj, subname);
}
if(!subname || !subname[0])
return res;
@@ -320,6 +514,8 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject
for(auto pos=sub.find('.');pos!=std::string::npos;pos=sub.find('.',pos)) {
++pos;
char c = sub[pos];
if (c == '.')
continue;
sub[pos] = 0;
auto sobj = obj->getSubObject(sub.c_str());
sub[pos] = c;
@@ -344,6 +540,8 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer *owner, DocumentObject
return res;
}
break;
}else if(sobj == newObj) {
return tryReplaceLink(owner, obj, parent, newObj, oldObj, subname);
}else if(prev == parent)
break;
prev = sobj;
@@ -359,6 +557,8 @@ PropertyLinkBase::tryReplaceLinkSubs(const PropertyContainer *owner,
{
std::pair<DocumentObject*,std::vector<std::string> > res;
res.first = 0;
if (!obj)
return res;
auto r = tryReplaceLink(owner,obj,parent,oldObj,newObj);
if(r.first) {
@@ -918,7 +1118,7 @@ TYPESYSTEM_SOURCE(App::PropertyLinkSubHidden, App::PropertyLinkSub)
PropertyLinkSub::PropertyLinkSub()
: _pcLinkSub(nullptr), _restoreLabel(false)
: _pcLinkSub(nullptr)
{
}
@@ -975,9 +1175,10 @@ void PropertyLinkSub::setValue(App::DocumentObject * lValue,
#endif
_pcLinkSub=lValue;
_cSubList=std::move(subs);
if(shadows.size()==_cSubList.size())
if(shadows.size()==_cSubList.size()) {
_ShadowSubList = std::move(shadows);
else
onContainerRestored(); // re-register element references
} else
updateElementReference(nullptr);
checkLabelReferences(_cSubList);
hasSetValue();
@@ -994,13 +1195,22 @@ const std::vector<std::string>& PropertyLinkSub::getSubValues(void) const
}
static inline const std::string &getSubNameWithStyle(const std::string &subName,
const PropertyLinkBase::ShadowSub &shadow, bool newStyle)
const PropertyLinkBase::ShadowSub &shadow, bool newStyle, std::string &tmp)
{
if(!newStyle) {
if(shadow.second.size())
return shadow.second;
}else if(shadow.first.size())
}else if(shadow.first.size()) {
if (Data::ComplexGeoData::hasMissingElement(shadow.second.c_str())) {
auto pos = shadow.first.rfind('.');
if (pos != std::string::npos) {
tmp = shadow.first.substr(0, pos+1);
tmp += shadow.second;
return tmp;
}
}
return shadow.first;
}
return subName;
}
@@ -1008,20 +1218,24 @@ std::vector<std::string> PropertyLinkSub::getSubValues(bool newStyle) const {
assert(_cSubList.size() == _ShadowSubList.size());
std::vector<std::string> ret;
ret.reserve(_cSubList.size());
std::string tmp;
for(size_t i=0;i<_ShadowSubList.size();++i)
ret.push_back(getSubNameWithStyle(_cSubList[i],_ShadowSubList[i],newStyle));
ret.push_back(getSubNameWithStyle(_cSubList[i],_ShadowSubList[i],newStyle,tmp));
return ret;
}
std::vector<std::string> PropertyLinkSub::getSubValuesStartsWith(const char* starter, bool newStyle) const
{
(void)newStyle;
std::vector<std::string> temp;
for(std::vector<std::string>::const_iterator it=_cSubList.begin();it!=_cSubList.end();++it)
if(strncmp(starter,it->c_str(),strlen(starter))==0)
temp.push_back(*it);
return temp;
assert(_cSubList.size() == _ShadowSubList.size());
std::vector<std::string> ret;
std::string tmp;
for(size_t i=0;i<_ShadowSubList.size();++i) {
const auto &sub = getSubNameWithStyle(_cSubList[i],_ShadowSubList[i],newStyle,tmp);
auto element = Data::ComplexGeoData::findElementName(sub.c_str());
if(element && boost::starts_with(element,starter))
ret.emplace_back(element);
}
return ret;
}
App::DocumentObject * PropertyLinkSub::getValue(Base::Type t) const
@@ -1036,8 +1250,9 @@ PyObject *PropertyLinkSub::getPyObject(void)
if (_pcLinkSub) {
_pcLinkSub->getPyObject();
tup[0] = Py::asObject(_pcLinkSub->getPyObject());
for(unsigned int i = 0;i<_cSubList.size(); i++)
list[i] = Py::String(_cSubList[i]);
int i = 0;
for (auto &sub : getSubValues(testFlag(LinkNewElement)))
list[i++] = Py::String(sub);
tup[1] = list;
return Py::new_reference_to(tup);
}
@@ -1310,12 +1525,9 @@ std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, c
return std::string();
}
#define ATTR_SHADOWED "shadowed"
#define ATTR_SHADOW "shadow"
#define ATTR_MAPPED "mapped"
// We do not have topo naming yet, ignore shadow sub for now
#define IGNORE_SHADOW true
static const char *AttrShadowed = "shadowed";
static const char *AttrShadow = "shadow";
static const char *AttrMapped = "mapped";
void PropertyLinkSub::Save (Base::Writer &writer) const
{
@@ -1328,7 +1540,7 @@ void PropertyLinkSub::Save (Base::Writer &writer) const
internal_name = _pcLinkSub->getExportName();
writer.Stream() << writer.ind() << "<LinkSub value=\""
<< internal_name <<"\" count=\"" << _cSubList.size();
writer.Stream() << "\">" << std::endl;
writer.Stream() << "\">\n";
writer.incInd();
auto owner = dynamic_cast<DocumentObject*>(getContainer());
bool exporting = owner && owner->isExporting();
@@ -1343,18 +1555,18 @@ void PropertyLinkSub::Save (Base::Writer &writer) const
std::string exportName;
writer.Stream() << encodeAttribute(exportSubName(exportName,_pcLinkSub,sub.c_str()));
if(shadow.second.size() && shadow.first == _cSubList[i])
writer.Stream() << "\" " ATTR_MAPPED "=\"1";
writer.Stream() << "\" " << AttrMapped << "=\"1";
} else {
writer.Stream() << encodeAttribute(sub);
if(_cSubList[i].size()) {
if(sub!=_cSubList[i]) {
// Stores the actual value that is shadowed. For new version FC,
// we will restore this shadowed value instead.
writer.Stream() << "\" " ATTR_SHADOWED "=\"" << encodeAttribute(_cSubList[i]);
writer.Stream() << "\" " << AttrShadowed << "=\"" << encodeAttribute(_cSubList[i]);
}else if(shadow.first.size()){
// Here means the user set value is old style element name.
// We shall then store the shadow somewhere else.
writer.Stream() << "\" " ATTR_SHADOW "=\"" << encodeAttribute(shadow.first);
writer.Stream() << "\" " << AttrShadow << "=\"" << encodeAttribute(shadow.first);
}
}
}
@@ -1395,15 +1607,15 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader)
for (int i = 0; i < count; i++) {
reader.readElement("Sub");
shadows[i].second = importSubName(reader,reader.getAttribute("value"),restoreLabel);
if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) {
if(reader.hasAttribute(AttrShadowed)) {
values[i] = shadows[i].first =
importSubName(reader,reader.getAttribute(ATTR_SHADOWED),restoreLabel);
importSubName(reader,reader.getAttribute(AttrShadowed),restoreLabel);
} else {
values[i] = shadows[i].second;
if(reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW)
shadows[i].first = importSubName(reader,reader.getAttribute(ATTR_SHADOW),restoreLabel);
if(reader.hasAttribute(AttrShadow))
shadows[i].first = importSubName(reader,reader.getAttribute(AttrShadow),restoreLabel);
}
if(reader.hasAttribute(ATTR_MAPPED))
if(reader.hasAttribute(AttrMapped))
mapped.push_back(i);
}
setFlag(LinkRestoreLabel,restoreLabel);
@@ -1503,6 +1715,7 @@ Property *PropertyLinkSub::Copy(void) const
PropertyLinkSub *p= new PropertyLinkSub();
p->_pcLinkSub = _pcLinkSub;
p->_cSubList = _cSubList;
p->_ShadowSubList = _ShadowSubList;
return p;
}
@@ -1773,9 +1986,10 @@ void PropertyLinkSubList::setValues(std::vector<DocumentObject*>&& lValue,
aboutToSetValue();
_lValueList = std::move(lValue);
_lSubList = std::move(lSubNames);
if(ShadowSubList.size()==_lSubList.size())
if(ShadowSubList.size()==_lSubList.size()) {
_ShadowSubList = std::move(ShadowSubList);
else
onContainerRestored(); // re-register element references
} else
updateElementReference(nullptr);
checkLabelReferences(_lSubList);
hasSetValue();
@@ -2000,7 +2214,7 @@ std::vector<PropertyLinkSubList::SubSet> PropertyLinkSubList::getSubListValues(b
PyObject *PropertyLinkSubList::getPyObject(void)
{
#if 1
std::vector<SubSet> subLists = getSubListValues();
std::vector<SubSet> subLists = getSubListValues(testFlag(LinkNewElement));
std::size_t count = subLists.size();
#if 0//FIXME: Should switch to tuple
Py::Tuple sequence(count);
@@ -2191,18 +2405,18 @@ void PropertyLinkSubList::Save (Base::Writer &writer) const
std::string exportName;
writer.Stream() << encodeAttribute(exportSubName(exportName,obj,sub.c_str()));
if(shadow.second.size() && _lSubList[i]==shadow.first)
writer.Stream() << "\" " ATTR_MAPPED "=\"1";
writer.Stream() << "\" " << AttrMapped << "=\"1";
} else {
writer.Stream() << encodeAttribute(sub);
if(_lSubList[i].size()) {
if(sub!=_lSubList[i]) {
// Stores the actual value that is shadowed. For new version FC,
// we will restore this shadowed value instead.
writer.Stream() << "\" " ATTR_SHADOWED "=\"" << encodeAttribute(_lSubList[i]);
writer.Stream() << "\" " << AttrShadowed << "=\"" << encodeAttribute(_lSubList[i]);
}else if(shadow.first.size()) {
// Here means the user set value is old style element name.
// We shall then store the shadow somewhere else.
writer.Stream() << "\" " ATTR_SHADOW "=\"" << encodeAttribute(shadow.first);
writer.Stream() << "\" " << AttrShadow << "=\"" << encodeAttribute(shadow.first);
}
}
}
@@ -2243,15 +2457,15 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader)
shadows.emplace_back();
auto &shadow = shadows.back();
shadow.second = importSubName(reader,reader.getAttribute("sub"),restoreLabel);
if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) {
shadow.first = importSubName(reader,reader.getAttribute(ATTR_SHADOWED),restoreLabel);
if(reader.hasAttribute(AttrShadowed)) {
shadow.first = importSubName(reader,reader.getAttribute(AttrShadowed),restoreLabel);
SubNames.push_back(shadow.first);
}else{
SubNames.push_back(shadow.second);
if(reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW)
shadow.first = importSubName(reader,reader.getAttribute(ATTR_SHADOW),restoreLabel);
if(reader.hasAttribute(AttrShadow))
shadow.first = importSubName(reader,reader.getAttribute(AttrShadow),restoreLabel);
}
if(reader.hasAttribute(ATTR_MAPPED))
if(reader.hasAttribute(AttrMapped))
mapped.push_back(i);
} else if (reader.isVerbose())
Base::Console().Warning("Lost link to '%s' while loading, maybe "
@@ -2262,7 +2476,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader &reader)
reader.readEndElement("LinkSubList");
// assignment
setValues(values,SubNames,std::move(shadows));
setValues(values,std::move(SubNames),std::move(shadows));
_mapped.swap(mapped);
}
@@ -2451,6 +2665,7 @@ Property *PropertyLinkSubList::Copy(void) const
PropertyLinkSubList *p = new PropertyLinkSubList();
p->_lValueList = _lValueList;
p->_lSubList = _lSubList;
p->_ShadowSubList = _ShadowSubList;
return p;
}
@@ -2474,8 +2689,9 @@ std::vector<std::string> PropertyLinkSubList::getSubValues(bool newStyle) const
assert(_lSubList.size() == _ShadowSubList.size());
std::vector<std::string> ret;
ret.reserve(_ShadowSubList.size());
std::string tmp;
for(size_t i=0;i<_ShadowSubList.size();++i)
ret.push_back(getSubNameWithStyle(_lSubList[i],_ShadowSubList[i],newStyle));
ret.push_back(getSubNameWithStyle(_lSubList[i],_ShadowSubList[i],newStyle,tmp));
return ret;
}
@@ -2628,7 +2844,7 @@ public:
App::Document *pDoc,PropertyXLink *l, const char *objName)
{
QString path;
l->filePath = getDocPath(filename,pDoc,true,&path);
l->filePath = getDocPath(filename,pDoc,false,&path);
FC_LOG("finding doc " << filename);
@@ -2979,6 +3195,7 @@ PropertyXLink::PropertyXLink(bool _allowPartial, PropertyLinkBase *parent)
setAllowPartial(_allowPartial);
setAllowExternal(true);
setSyncSubObject(true);
// setReturnNewElement(true);
if(parent)
setContainer(parent->getContainer());
}
@@ -3010,18 +3227,27 @@ void PropertyXLink::detach() {
}
}
std::string PropertyXLink::getFullName(bool python) const {
if((getName() && getName()[0]) || python || !parentProp)
return inherited::getFullName(python);
std::ostringstream ss;
ss << parentProp->getFullName() << ":" << this;
return ss.str();
}
void PropertyXLink::aboutToSetValue() {
if(parentProp)
parentProp->aboutToSetChildValue(*this);
else
PropertyLinkBase::aboutToSetValue();
inherited::aboutToSetValue();
}
void PropertyXLink::hasSetValue() {
if(parentProp)
parentProp->hasSetChildValue(*this);
else
PropertyLinkBase::hasSetValue();
inherited::hasSetValue();
}
void PropertyXLink::setSubName(const char *subname)
@@ -3035,13 +3261,14 @@ void PropertyXLink::setSubName(const char *subname)
}
void PropertyXLink::setSubValues(std::vector<std::string> &&subs,
std::vector<ShadowSub> &&shadows)
std::vector<ShadowSub> &&shadows)
{
_SubList = std::move(subs);
_ShadowSubList.clear();
if(shadows.size() == _SubList.size())
if(shadows.size() == _SubList.size()) {
_ShadowSubList = std::move(shadows);
else
onContainerRestored(); // re-register element references
} else
updateElementReference(nullptr);
checkLabelReferences(_SubList);
}
@@ -3330,9 +3557,11 @@ void PropertyXLink::Save (Base::Writer &writer) const {
}else
FC_WARN("PropertyXLink export without saving the document");
}
if(_path.size())
path = _path.c_str();
}
} else if (filePath.size())
_path = DocInfo::getDocPath(filePath.c_str(),owner->getDocument(),true);
if(_path.size())
path = _path.c_str();
writer.Stream() << writer.ind()
<< "<XLink file=\"" << encodeAttribute(path)
<< "\" stamp=\"" << (docInfo&&docInfo->pcDoc?docInfo->pcDoc->LastModifiedDate.getValue():"")
@@ -3353,14 +3582,14 @@ void PropertyXLink::Save (Base::Writer &writer) const {
writer.Stream() << "\" sub=\"" <<
encodeAttribute(exportSubName(exportName,_pcLink,sub.c_str()));
if(shadowSub.second.size() && shadowSub.first==subName)
writer.Stream() << "\" " ATTR_MAPPED "=\"1";
writer.Stream() << "\" " << AttrMapped << "=\"1";
}else{
writer.Stream() << "\" sub=\"" << encodeAttribute(sub);
if(sub.size()) {
if(sub!=subName)
writer.Stream() << "\" " ATTR_SHADOWED "=\"" << encodeAttribute(subName);
writer.Stream() << "\" " << AttrShadowed << "=\"" << encodeAttribute(subName);
else if(shadowSub.first.size())
writer.Stream() << "\" " ATTR_SHADOW "=\"" << encodeAttribute(shadowSub.first);
writer.Stream() << "\" " << AttrShadow << "=\"" << encodeAttribute(shadowSub.first);
}
}
writer.Stream() << "\"/>" << std::endl;
@@ -3378,14 +3607,14 @@ void PropertyXLink::Save (Base::Writer &writer) const {
std::string exportName;
writer.Stream() << encodeAttribute(exportSubName(exportName,_pcLink,sub.c_str()));
if(shadow.second.size() && shadow.first == _SubList[i])
writer.Stream() << "\" " ATTR_MAPPED "=\"1";
writer.Stream() << "\" " << AttrMapped << "=\"1";
} else {
writer.Stream() << encodeAttribute(sub);
if(_SubList[i].size()) {
if(sub!=_SubList[i])
writer.Stream() << "\" " ATTR_SHADOWED "=\"" << encodeAttribute(_SubList[i]);
writer.Stream() << "\" " << AttrShadowed << "=\"" << encodeAttribute(_SubList[i]);
else if(shadow.first.size())
writer.Stream() << "\" " ATTR_SHADOW "=\"" << encodeAttribute(shadow.first);
writer.Stream() << "\" " << AttrShadow << "=\"" << encodeAttribute(shadow.first);
}
}
writer.Stream()<<"\"/>" << endl;
@@ -3432,19 +3661,19 @@ void PropertyXLink::Restore(Base::XMLReader &reader)
std::vector<int> mapped;
bool restoreLabel = false;
if(reader.hasAttribute("sub")) {
if(reader.hasAttribute(ATTR_MAPPED))
if(reader.hasAttribute(AttrMapped))
mapped.push_back(0);
subs.emplace_back();
auto &subname = subs.back();
shadows.emplace_back();
auto &shadow = shadows.back();
shadow.second = importSubName(reader,reader.getAttribute("sub"),restoreLabel);
if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW)
subname = shadow.first = importSubName(reader,reader.getAttribute(ATTR_SHADOWED),restoreLabel);
if(reader.hasAttribute(AttrShadowed))
subname = shadow.first = importSubName(reader,reader.getAttribute(AttrShadowed),restoreLabel);
else {
subname = shadow.second;
if(reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW)
shadow.first = importSubName(reader,reader.getAttribute(ATTR_SHADOW),restoreLabel);
if(reader.hasAttribute(AttrShadow))
shadow.first = importSubName(reader,reader.getAttribute(AttrShadow),restoreLabel);
}
}else if(reader.hasAttribute("count")) {
int count = reader.getAttributeAsInteger("count");
@@ -3453,15 +3682,15 @@ void PropertyXLink::Restore(Base::XMLReader &reader)
for (int i = 0; i < count; i++) {
reader.readElement("Sub");
shadows[i].second = importSubName(reader,reader.getAttribute("value"),restoreLabel);
if(reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW)
subs[i] = shadows[i].first =
importSubName(reader,reader.getAttribute(ATTR_SHADOWED),restoreLabel);
if(reader.hasAttribute(AttrShadowed))
subs[i] = shadows[i].first =
importSubName(reader,reader.getAttribute(AttrShadowed),restoreLabel);
else {
subs[i] = shadows[i].second;
if(reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW)
shadows[i].first = importSubName(reader,reader.getAttribute(ATTR_SHADOW),restoreLabel);
if(reader.hasAttribute(AttrShadow))
shadows[i].first = importSubName(reader,reader.getAttribute(AttrShadow),restoreLabel);
}
if(reader.hasAttribute(ATTR_MAPPED))
if(reader.hasAttribute(AttrMapped))
mapped.push_back(i);
}
reader.readEndElement("XLink");
@@ -3542,8 +3771,10 @@ void PropertyXLink::copyTo(PropertyXLink &other,
}
if(subs)
other._SubList = std::move(*subs);
else
else {
other._SubList = _SubList;
other._ShadowSubList = _ShadowSubList;
}
other._Flags = _Flags;
}
@@ -3662,7 +3893,7 @@ PyObject *PropertyXLink::getPyObject(void)
{
if(!_pcLink)
Py_Return;
const auto &subs = getSubValues(false);
const auto &subs = getSubValues(testFlag(LinkNewElement));
if(subs.empty())
return _pcLink->getPyObject();
Py::Tuple ret(2);
@@ -3726,7 +3957,7 @@ void PropertyXLink::setPyObject(PyObject *value) {
const char *PropertyXLink::getSubName(bool newStyle) const {
if(_SubList.empty() || _ShadowSubList.empty())
return "";
return getSubNameWithStyle(_SubList[0],_ShadowSubList[0],newStyle).c_str();
return getSubNameWithStyle(_SubList[0],_ShadowSubList[0],newStyle,tmpShadow).c_str();
}
void PropertyXLink::getLinks(std::vector<App::DocumentObject *> &objs,
@@ -3757,20 +3988,24 @@ std::vector<std::string> PropertyXLink::getSubValues(bool newStyle) const {
assert(_SubList.size() == _ShadowSubList.size());
std::vector<std::string> ret;
ret.reserve(_SubList.size());
std::string tmp;
for(size_t i=0;i<_ShadowSubList.size();++i)
ret.push_back(getSubNameWithStyle(_SubList[i],_ShadowSubList[i],newStyle));
ret.push_back(getSubNameWithStyle(_SubList[i],_ShadowSubList[i],newStyle,tmp));
return ret;
}
std::vector<std::string> PropertyXLink::getSubValuesStartsWith(const char* starter, bool newStyle) const
{
(void)newStyle;
std::vector<std::string> temp;
for(std::vector<std::string>::const_iterator it=_SubList.begin();it!=_SubList.end();++it)
if(strncmp(starter,it->c_str(),strlen(starter))==0)
temp.push_back(*it);
return temp;
assert(_SubList.size() == _ShadowSubList.size());
std::vector<std::string> ret;
std::string tmp;
for(size_t i=0;i<_ShadowSubList.size();++i) {
const auto &sub = getSubNameWithStyle(_SubList[i],_ShadowSubList[i],newStyle,tmp);
auto element = Data::ComplexGeoData::findElementName(sub.c_str());
if(element && boost::starts_with(element,starter))
ret.emplace_back(element);
}
return ret;
}
void PropertyXLink::setAllowPartial(bool enable) {
@@ -3826,7 +4061,7 @@ PyObject *PropertyXLinkSub::getPyObject(void)
Py_Return;
Py::Tuple ret(2);
ret.setItem(0,Py::Object(_pcLink->getPyObject(),true));
const auto &subs = getSubValues(false);
const auto &subs = getSubValues(testFlag(LinkNewElement));
Py::List list(subs.size());
int i = 0;
PropertyString propString;
@@ -3852,6 +4087,7 @@ PropertyXLinkSubList::PropertyXLinkSubList()
{
_pcScope = LinkScope::Global;
setSyncSubObject(true);
// setReturnNewElement(true);
}
PropertyXLinkSubList::~PropertyXLinkSubList()
@@ -4087,7 +4323,7 @@ PyObject *PropertyXLinkSubList::getPyObject(void)
Py::Tuple tup(2);
tup[0] = Py::asObject(obj->getPyObject());
const auto &subs = link.getSubValues();
const auto &subs = link.getSubValues(testFlag(LinkNewElement));
Py::Tuple items(subs.size());
for (std::size_t j = 0; j < subs.size(); j++) {
items[j] = Py::String(subs[j]);
@@ -4107,7 +4343,7 @@ void PropertyXLinkSubList::setPyObject(PyObject *value)
this->setValue(dummy.getValue(), dummy.getSubValues());
return;
}
catch (Base::Exception&) {}
catch (Base::TypeError&) {}
if (!PyTuple_Check(value) && !PyList_Check(value))
throw Base::TypeError("Invalid type. Accepts (DocumentObject, (subname...)) or sequence of such type.");
+19 -4
View File
@@ -26,8 +26,11 @@
#include <list>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include "Property.h"
namespace Base {
@@ -38,6 +41,8 @@ namespace App
{
class DocumentObject;
class Document;
class GeoFeature;
class SubObjectT;
class DocInfo;
typedef std::shared_ptr<DocInfo> DocInfoPtr;
@@ -254,7 +259,7 @@ public:
/// Helper function to return linked objects using an std::inserter
template<class T>
void getLinkedObjects(T &inserter, bool all=false) const {
void getLinkedObjects(T inserter, bool all=false) const {
std::vector<App::DocumentObject*> ret;
getLinks(ret,all);
std::copy(ret.begin(),ret.end(),inserter);
@@ -262,7 +267,7 @@ public:
/// Helper function to return a map of linked object and its subname references
void getLinkedElements(std::map<App::DocumentObject*, std::vector<std::string> > &elements,
bool newStyle=true, bool all=true) const
bool newStyle=true, bool all=false) const
{
std::vector<App::DocumentObject*> ret;
std::vector<std::string> subs;
@@ -275,12 +280,14 @@ public:
/// Helper function to return a map of linked object and its subname references
std::map<App::DocumentObject*, std::vector<std::string> >
linkedElements(bool newStyle=true, bool all=true) const
linkedElements(bool newStyle=true, bool all=false) const
{
std::map<App::DocumentObject*, std::vector<std::string> > ret;
getLinkedElements(ret,newStyle,all);
return ret;
}
std::vector<App::SubObjectT> linkedElementsT(bool all) const;
//@}
virtual bool isSame(const Property &other) const override;
@@ -346,6 +353,8 @@ public:
/// Update all element references in all link properties of \a feature
static void updateElementReferences(DocumentObject *feature, bool reverse=false);
/// Obtain link properties that contain element references to a given object
static const std::unordered_set<PropertyLinkBase*>& getElementReferences(DocumentObject *);
/** Helper function for update individual element reference
*
@@ -538,6 +547,7 @@ public:
LinkAllowPartial,
LinkRestoreLabel,
LinkSyncSubObject, // used by DlgPropertyLink
LinkNewElement, // return new element name in getPyObject
};
inline bool testFlag(int flag) const {
return _Flags.test((std::size_t)flag);
@@ -545,6 +555,8 @@ public:
virtual void setAllowPartial(bool enable) { (void)enable; }
void setReturnNewElement(bool enable);
protected:
virtual void hasSetValue() override;
@@ -1052,6 +1064,7 @@ class PropertyXLinkSubList;
class AppExport PropertyXLink : public PropertyLinkGlobal
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef PropertyLinkGlobal inherited;
public:
PropertyXLink(bool allowPartial=false, PropertyLinkBase *parent=nullptr);
@@ -1137,6 +1150,7 @@ public:
virtual void setAllowPartial(bool enable) override;
virtual std::string getFullName(bool python=false) const override;
const char *getFilePath() const {
return filePath.c_str();
}
@@ -1169,6 +1183,7 @@ protected:
std::vector<ShadowSub> _ShadowSubList;
std::vector<int> _mapped;
PropertyLinkBase *parentProp;
mutable std::string tmpShadow;
};
@@ -1198,10 +1213,10 @@ class AppExport PropertyXLinkSubList: public PropertyLinkBase
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
typedef typename AtomicPropertyChangeInterface<PropertyXLinkSubList>::AtomicPropertyChange atomic_change;
friend atomic_change;
public:
PropertyXLinkSubList();
virtual ~PropertyXLinkSubList();
+10 -11
View File
@@ -392,9 +392,9 @@ void PropertyEnumeration::setEnumVector(const std::vector<std::string> &values)
hasSetValue();
}
const char ** PropertyEnumeration::getEnums() const
bool PropertyEnumeration::hasEnums() const
{
return _enum.getEnums();
return _enum.hasEnums();
}
bool PropertyEnumeration::isValid() const
@@ -447,7 +447,7 @@ void PropertyEnumeration::Restore(Base::XMLReader &reader)
if (val < 0) {
// If the enum is empty at this stage do not print a warning
if (_enum.getEnums())
if (_enum.hasEnums())
Base::Console().Warning("Enumeration index %d is out of range, ignore it\n", val);
val = getValue();
}
@@ -598,13 +598,13 @@ bool PropertyEnumeration::getPyPathValue(const ObjectIdentifier &path, Py::Objec
if (p == ".Enum" || p == ".All") {
Base::PyGILStateLocker lock;
Py::Tuple res(_enum.maxValue()+1);
const char **enums = _enum.getEnums();
std::vector<std::string> enums = _enum.getEnumVector();
PropertyString tmp;
for(int i=0;i<=_enum.maxValue();++i) {
for(int i=0;i< int(enums.size());++i) {
tmp.setValue(enums[i]);
res.setItem(i,Py::asObject(tmp.getPyObject()));
}
if(p == ".Enum")
if (p == ".Enum")
r = res;
else {
Py::Tuple tuple(2);
@@ -1374,7 +1374,7 @@ PropertyString::~PropertyString()
void PropertyString::setValue(const char* newLabel)
{
if(!newLabel)
if(!newLabel)
return;
if(_cValue == newLabel)
@@ -2065,10 +2065,9 @@ PyObject *PropertyBool::getPyObject()
void PropertyBool::setPyObject(PyObject *value)
{
if (PyBool_Check(value))
setValue(PyObject_IsTrue(value)!=0);
else if(PyLong_Check(value))
setValue(PyLong_AsLong(value)!=0);
if (PyBool_Check(value) || PyLong_Check(value)) {
setValue(PyObject_IsTrue(value) ? true : false);
}
else {
std::string error = std::string("type must be bool, not ");
error += value->ob_type->tp_name;
+1 -1
View File
@@ -206,7 +206,7 @@ public:
/// set enum values as vector of strings
void setEnumVector(const std::vector<std::string> &);
/// get the pointer to the enum list
const char ** getEnums(void) const;
bool hasEnums() const;
/// Returns true if the instance is in a usable state
bool isValid(void) const;
+2 -2
View File
@@ -193,14 +193,14 @@ void PropertyQuantityConstraint::setPyObject(PyObject *value)
quant.setValue(temp);
if (unit.isEmpty()){
PropertyFloat::setValue(quant.getValue());
PropertyFloat::setValue(quant.getValue()); // clazy:exclude=skipped-base-method
return;
}
if (unit != _Unit)
throw Base::UnitsMismatchError("Not matching Unit!");
PropertyFloat::setValue(quant.getValue());
PropertyFloat::setValue(quant.getValue()); // clazy:exclude=skipped-base-method
}
//**************************************************************************
+23 -9
View File
@@ -37,7 +37,7 @@ using namespace App;
const int App::CellAddress::MAX_ROWS = 16384;
const int App::CellAddress::MAX_COLUMNS = 26 * 26 + 26;
Range::Range(const char * range)
Range::Range(const char * range, bool normalize)
{
std::string from;
std::string to;
@@ -62,28 +62,42 @@ Range::Range(const char * range)
row_end = end.row();
col_end = end.col();
if (normalize)
this->normalize();
row_curr = row_begin;
col_curr = col_begin;
}
Range::Range(int _row_begin, int _col_begin, int _row_end, int _col_end)
: row_curr(_row_begin)
, col_curr(_col_begin)
, row_begin(_row_begin)
Range::Range(int _row_begin, int _col_begin, int _row_end, int _col_end, bool normalize)
: row_begin(_row_begin)
, col_begin(_col_begin)
, row_end(_row_end)
, col_end(_col_end)
{
if (normalize)
this->normalize();
row_curr = row_begin;
col_curr = col_begin;
}
Range::Range(const CellAddress &from, const CellAddress &to)
: row_curr(from.row())
, col_curr(from.col())
, row_begin(from.row())
Range::Range(const CellAddress &from, const CellAddress &to, bool normalize)
: row_begin(from.row())
, col_begin(from.col())
, row_end(to.row())
, col_end(to.col())
{
if (normalize)
this->normalize();
row_curr = row_begin;
col_curr = col_begin;
}
void Range::normalize()
{
if (row_begin > row_end)
std::swap(row_begin, row_end);
if (col_begin > col_end)
std::swap(col_begin, col_end);
}
bool Range::next()
+6 -3
View File
@@ -117,14 +117,17 @@ protected:
class AppExport Range {
public:
Range(const char *range);
Range(const char *range, bool normalize=false);
Range(int _row_begin, int _col_begin, int _row_end, int _col_end);
Range(int _row_begin, int _col_begin, int _row_end, int _col_end, bool normalize=false);
Range(const CellAddress & from, const CellAddress & to);
Range(const CellAddress & from, const CellAddress & to, bool normalize=false);
bool next();
/** Make sure the range starts from top left and ends with bottom right corner **/
void normalize();
/** Current row */
inline int row() const { return row_curr; }
+749
View File
@@ -0,0 +1,749 @@
/****************************************************************************
* Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#include "PreCompiled.h"
#include <deque>
#include <QCryptographicHash>
#include <QHash>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/bimap.hpp>
#include <boost/bimap/set_of.hpp>
#include <boost/bimap/unordered_set_of.hpp>
#include <boost/iostreams/stream.hpp>
#include "StringHasher.h"
#include "StringHasherPy.h"
#include "DocumentParams.h"
#include "MappedElement.h"
#include "StringIDPy.h"
FC_LOG_LEVEL_INIT("App",true,true)
namespace bio = boost::iostreams;
using namespace App;
///////////////////////////////////////////////////////////
struct StringIDHasher {
std::size_t operator()(const StringID *sid) const {
if (!sid)
return 0;
return qHash(sid->data(), qHash(sid->postfix()));
}
bool operator()(const StringID *IDa, const StringID *IDb) const {
if (IDa == IDb)
return true;
if (!IDa || !IDb)
return false;
return IDa->data() == IDb->data() && IDa->postfix() == IDb->postfix();
}
};
typedef boost::bimap<
boost::bimaps::unordered_set_of<StringID *,
StringIDHasher,
StringIDHasher>,
boost::bimaps::set_of<long>>
HashMapBase;
class StringHasher::HashMap: public HashMapBase
{
public:
bool SaveAll = false;
int Threshold = 0;
};
///////////////////////////////////////////////////////////
TYPESYSTEM_SOURCE_ABSTRACT(App::StringID, Base::BaseClass)
StringID::~StringID()
{
if (_hasher)
_hasher->_hashes->right.erase(_id);
}
PyObject *StringID::getPyObject() {
return new StringIDPy(this);
}
PyObject *StringID::getPyObjectWithIndex(int index) {
auto res = new StringIDPy(this);
res->_index = index;
return res;
}
std::string StringID::toString(int index) const {
std::ostringstream ss;
ss << '#' << std::hex << value();
if (index)
ss << ':' << index;
return ss.str();
}
StringID::IndexID StringID::fromString(const char *name, bool eof, int size) {
IndexID res;
res.id = 0;
res.index = 0;
if (!name) {
res.id = -1;
return res;
}
if (size < 0)
size = std::strlen(name);
bio::stream<bio::array_source> iss(name, size);
char sep = 0;
char sep2 = 0;
iss >> sep >> std::hex >> res.id >> sep2 >> res.index;
if ((eof && !iss.eof()) || sep != '#' || (sep2 != 0 && sep2 != ':')) {
res.id = -1;
return res;
}
return res;
}
std::string StringID::dataToText(int index) const {
if(isHashed() || isBinary())
return _data.toBase64().constData();
std::string res(_data.constData());
if (index)
res += std::to_string(index);
if (_postfix.size())
res += _postfix.constData();
return res;
}
void StringID::mark() const
{
if (isMarked())
return;
_flags.setFlag(Flag::Marked);
for (auto &sid : _sids)
sid.deref().mark();
}
///////////////////////////////////////////////////////////
TYPESYSTEM_SOURCE(App::StringHasher, Base::Persistence)
StringHasher::StringHasher()
:_hashes(new HashMap)
{}
StringHasher::~StringHasher() {
clear();
}
void StringHasher::setSaveAll(bool enable) {
if (_hashes->SaveAll == enable)
return;
_hashes->SaveAll = enable;
compact();
}
void StringHasher::compact()
{
if (_hashes->SaveAll)
return;
std::deque<StringIDRef> pendings;
for (auto &v : _hashes->right) {
if (!v.second->isPersistent() && v.second->getRefCount() == 1)
pendings.emplace_back(v.second);
}
while (pendings.size()) {
StringIDRef sid = pendings.front();
pendings.pop_front();
if (!_hashes->right.erase(sid.value()))
continue;
sid._sid->_hasher = nullptr;
sid._sid->unref();
for (auto &s : sid._sid->_sids) {
if (s._sid->_hasher == this
&& !s._sid->isPersistent()
&& s._sid->getRefCount() == 2)
pendings.push_back(s);
}
}
}
bool StringHasher::getSaveAll() const {
return _hashes->SaveAll;
}
void StringHasher::setThreshold(int threshold) {
_hashes->Threshold = threshold;
}
int StringHasher::getThreshold() const {
return _hashes->Threshold;
}
long StringHasher::lastID() const {
if(_hashes->right.empty())
return 0;
auto it = _hashes->right.end();
--it;
return it->first;
}
StringIDRef StringHasher::getID(const char *text, int len, bool hashable) {
if (len < 0)
len = strlen(text);
return getID(QByteArray::fromRawData(text, len), hashable ? Option::Hashable : Option::None);
}
StringIDRef StringHasher::getID(const QByteArray &data, Options options)
{
bool binary = options.testFlag(Option::Binary);
bool hashable = options.testFlag(Option::Hashable);
bool nocopy = options.testFlag(Option::NoCopy);
bool hashed = hashable && _hashes->Threshold > 0
&& (int)data.size() > _hashes->Threshold;
StringID dataID;
if (hashed) {
QCryptographicHash hasher(QCryptographicHash::Sha1);
hasher.addData(data);
dataID._data = hasher.result();
}
else
dataID._data = data;
auto it = _hashes->left.find(&dataID);
if (it != _hashes->left.end())
return StringIDRef(it->first);
if (!hashed && !nocopy)
// if not hashed, make a deep copy of the data
dataID._data = QByteArray(data.constData(), data.size());
StringID::Flags flags(StringID::Flag::None);
if (binary)
flags.setFlag(StringID::Flag::Binary);
if (hashed)
flags.setFlag(StringID::Flag::Hashed);
StringIDRef sid(new StringID(lastID() + 1, dataID._data, flags));
return StringIDRef(insert(sid));
}
StringIDRef StringHasher::getID(const Data::MappedName &name,
const QVector<StringIDRef> & sids)
{
StringID anID;
anID._postfix = name.postfixBytes();
Data::IndexedName indexed;
if (!anID._postfix.size())
indexed = Data::IndexedName(name.dataBytes());
if (indexed)
anID._data = QByteArray::fromRawData(indexed.getType(), strlen(indexed.getType()));
else
anID._data = name.dataBytes();
auto it = _hashes->left.find(&anID);
if (it != _hashes->left.end()) {
auto res = StringIDRef(it->first);
if (indexed)
res._index = indexed.getIndex();
return res;
}
if (!indexed && name.isRaw())
anID._data = QByteArray(name.dataBytes().constData(),
name.dataBytes().size());
StringIDRef postfixRef;
if (anID._postfix.size() && anID._postfix.indexOf("#") < 0) {
postfixRef = getID(anID._postfix);
postfixRef.toBytes(anID._postfix);
}
StringIDRef indexRef;
if (indexed)
indexRef = getID(anID._data);
StringIDRef sid(new StringID(lastID() + 1, anID._data));
StringID &id = *sid._sid;
if (anID._postfix.size()) {
id._flags.setFlag(StringID::Flag::Postfixed);
id._postfix = anID._postfix;
}
int count = 0;
for (auto &sid : sids) {
if (sid && sid._sid->_hasher == this)
++count;
}
int extra = (postfixRef ? 1 : 0) + (indexRef ? 1 : 0);
if (count == sids.size() && !postfixRef && !indexRef)
id._sids = sids;
else {
id._sids.reserve(count + extra);
if (postfixRef) {
id._flags.setFlag(StringID::Flag::PostfixEncoded);
id._sids.push_back(postfixRef);
}
if (indexRef) {
id._flags.setFlag(StringID::Flag::Indexed);
id._sids.push_back(indexRef);
}
for (auto &s : sids) {
if (s && s._sid->_hasher == this)
id._sids.push_back(s);
}
}
if (id._sids.size() > 10) {
std::sort(id._sids.begin() + extra, id._sids.end());
id._sids.erase(std::unique(id._sids.begin() + extra, id._sids.end()), id._sids.end());
}
if (id._postfix.size() && !indexed) {
StringID::IndexID res = StringID::fromString(id._data);
if (res.id > 0) {
int offset = id.isPostfixEncoded() ? 1 : 0;
for (int i = offset; i < id._sids.size(); ++i) {
if (id._sids[i].value() == res.id) {
if (i!=offset)
std::swap(id._sids[offset], id._sids[i]);
if (res.index != 0)
id._flags.setFlag(StringID::Flag::PrefixIDIndex);
else
id._flags.setFlag(StringID::Flag::PrefixID);
break;
}
}
}
}
return StringIDRef(insert(sid), indexed.getIndex());
}
StringIDRef StringHasher::getID(long id, int index) const {
if (id<=0)
return StringIDRef();
auto it = _hashes->right.find(id);
if (it == _hashes->right.end())
return StringIDRef();
StringIDRef res(it->second);
res._index = index;
return res;
}
void StringHasher::setPersistenceFileName(const char *filename) const {
if (!filename)
filename = "";
_filename = filename;
}
const std::string &StringHasher::getPersistenceFileName() const {
return _filename;
}
void StringHasher::Save(Base::Writer &writer) const {
size_t count;
if (_hashes->SaveAll)
count = _hashes->size();
else {
count = 0;
for (auto &v : _hashes->right) {
if (v.second->isMarked() || v.second->isPersistent())
++count;
}
}
writer.Stream() << writer.ind()
<< "<StringHasher saveall=\"" << _hashes->SaveAll
<< "\" threshold=\"" << _hashes->Threshold << "\"";
if (!count) {
writer.Stream() << " count=\"0\"></StringHasher>\n";
return;
}
writer.Stream() << " count=\"0\" new=\"1\"/>\n";
writer.Stream() << writer.ind() << "<StringHasher2 ";
if (_filename.size()) {
writer.Stream() << " file=\""
<< writer.addFile(_filename + ".txt", this)
<< "\"/>\n";
return;
}
writer.Stream() << " count=\"" << count << "\">\n";
saveStream(writer.beginCharStream(false) << '\n');
writer.endCharStream() << '\n';
writer.Stream() << writer.ind() << "</StringHasher2>\n";
}
void StringHasher::SaveDocFile(Base::Writer &writer) const {
std::size_t count = _hashes->SaveAll?this->size():this->count();
writer.Stream() << "StringTableStart v1 " << count << '\n';
saveStream(writer.Stream());
}
void StringHasher::saveStream(std::ostream &s) const {
Base::OutputStream str(s,false);
boost::io::ios_flags_saver ifs(s);
s << std::hex;
bool allowRealtive = DocumentParams::getRelativeStringID();
long anchor = 0;
const StringID *last = nullptr;
long lastid = 0;
bool relative = false;
for (auto &v : _hashes->right) {
auto &d = *v.second;
long id = d._id;
if (!_hashes->SaveAll && !d.isMarked() && !d.isPersistent())
continue;
if (!allowRealtive)
s << id;
else {
// We use relative coding to save space. But in order to have some
// minimum protection against corruption, write an absolute value every
// once a while.
relative = (id - anchor) < 1000;
if (relative)
s << '-' << id - lastid;
else {
anchor = id;
s << id;
}
lastid = id;
}
int offset = d.isPostfixEncoded() ? 1 : 0;
StringID::IndexID prefixid;
prefixid.id = 0;
prefixid.index = 0;
if (d.isPrefixID()) {
assert(d._sids.size() > offset);
prefixid.id = d._sids[offset].value();
}
else if (d.isPrefixIDIndex()) {
prefixid = StringID::fromString(d._data);
assert(d._sids.size() > offset && d._sids[offset].value() == prefixid.id);
}
auto flags = d._flags;
flags.setFlag(StringID::Flag::Marked, false);
s << '.' << flags.toUnderlyingType();
int i = 0;
if (!relative) {
for (; i < d._sids.size(); ++i)
s << '.' << d._sids[i].value();
}
else {
if (last) {
for (; i < d._sids.size() && i < last->_sids.size(); ++i) {
long m = last->_sids[i].value();
long n = d._sids[i].value();
if (n < m)
s << ".-" << m-n;
else
s << '.' << n - m;
}
}
for (; i < d._sids.size(); ++i)
s << '.' << id - d._sids[i].value();
}
last = &d;
// Having postfix means it is a geometry element name, which
// guarantees to be a single line without space. So it is safe to
// store in raw stream.
if (d.isPostfixed()) {
if (d.isPrefixIDIndex())
s << ' ' << prefixid.index;
else if (!d.isIndexed() && !d.isPrefixID())
s << ' ' << d._data.constData();
if (!d.isPostfixEncoded())
s << ' ' << d._postfix.constData();
s << '\n';
}
else {
// Reaching here means the string may contain space and newlines
// We rely on OutputStream (i.e. str) to save the string.
s << ' ';
str << d._data.constData();
}
}
}
void StringHasher::RestoreDocFile(Base::Reader &reader) {
std::string marker, ver;
reader >> marker;
std::size_t count;
_hashes->clear();
if (marker == "StringTableStart") {
reader >> ver >> count;
if (ver != "v1")
FC_WARN("Unknown string table format");
restoreStreamNew(reader, count);
return;
}
count = atoi(marker.c_str());
restoreStream(reader, count);
}
void StringHasher::restoreStreamNew(std::istream &s, std::size_t count) {
Base::InputStream str(s, false);
_hashes->clear();
std::string content;
boost::io::ios_flags_saver ifs(s);
s >> std::hex;
std::vector<std::string> tokens;
long lastid = 0;
const StringID *last = nullptr;
std::string tmp;
for (uint32_t i = 0; i < count; ++i) {
if (!(s >> tmp))
FC_THROWM(Base::RuntimeError, "Invalid string table");
tokens.clear();
boost::split(tokens, tmp, boost::is_any_of("."));
if (tokens.size() < 2)
FC_THROWM(Base::RuntimeError, "Invalid string table");
long id;
bool relative = false;
if (tokens[0][0] == '-') {
relative = true;
id = lastid + strtol(tokens[0].c_str() + 1, nullptr, 16);
}
else
id = strtol(tokens[0].c_str(), nullptr, 16);
lastid = id;
unsigned long flag = strtol(tokens[1].c_str(), nullptr, 16);
StringIDRef sid(new StringID(id, QByteArray(), static_cast<StringID::Flag>(flag)));
StringID &d = *sid._sid;
d._sids.reserve(tokens.size() - 2);
int j = 2;
if (relative && last) {
for (; j < (int)tokens.size() && j - 2 < last->_sids.size(); ++j) {
long m = last->_sids[j - 2].value();
long n;
if (tokens[j][0] == '-')
n = -strtol(&tokens[j][1], nullptr, 16);
else
n = strtol(&tokens[j][0], nullptr, 16);
StringIDRef sid = getID(m + n);
if (!sid)
FC_THROWM(Base::RuntimeError, "Invalid string id reference");
d._sids.push_back(sid);
}
}
for (; j < (int)tokens.size(); ++j) {
long n = strtol(&tokens[j][0], nullptr, 16);
StringIDRef sid = getID(relative ? id - n : n);
if (!sid)
FC_THROWM(Base::RuntimeError, "Invalid string id reference");
d._sids.push_back(sid);
}
if (!d.isPostfixed()) {
str >> content;
if (d.isHashed() || d.isBinary())
d._data = QByteArray::fromBase64(content.c_str());
else
d._data = content.c_str();
}
else {
int offset = 0;
if (d.isPostfixEncoded()) {
offset = 1;
if (d._sids.empty())
FC_THROWM(Base::RuntimeError, "Missing string postfix");
d._postfix = d._sids[0]._sid->_data;
}
if (d.isIndexed()) {
if (d._sids.size() <= offset)
FC_THROWM(Base::RuntimeError, "Missing string prefix");
d._data = d._sids[offset]._sid->_data;
}
else if (d.isPrefixID() || d.isPrefixIDIndex()) {
if (d._sids.size() <= offset)
FC_THROWM(Base::RuntimeError, "Missing string prefix id");
int index = 0;
if (d.isPrefixIDIndex()) {
if (!(s >> index))
FC_THROWM(Base::RuntimeError, "Missing string prefix index");
}
d._data = d._sids[offset]._sid->toString(index).c_str();
}
else {
s >> content;
d._data = content.c_str();
}
if (!d.isPostfixEncoded()) {
s >> content;
d._postfix = content.c_str();
}
}
last = insert(sid);
}
}
StringID *StringHasher::insert(const StringIDRef &sid)
{
assert(sid && sid._sid->_hasher == nullptr);
auto &d = *sid._sid;
d._hasher = this;
d.ref();
auto res = _hashes->right.insert(_hashes->right.end(),
HashMap::right_map::value_type(sid.value(), &d));
if (res->second != &d) {
d._hasher = nullptr;
d.unref();
}
return res->second;
}
void StringHasher::restoreStream(std::istream &s, std::size_t count) {
Base::InputStream str(s, false);
_hashes->clear();
std::string content;
for (uint32_t i = 0; i < count; ++i) {
int32_t id;
uint8_t type;
str >> id >> type >> content;
StringIDRef sid = new StringID(id, QByteArray(), static_cast<StringID::Flag>(type));
if (sid.isHashed() || sid.isBinary())
sid._sid->_data = QByteArray::fromBase64(content.c_str());
else
sid._sid->_data = QByteArray(content.c_str());
insert(sid);
}
}
void StringHasher::clear() {
for (auto & v : _hashes->right) {
v.second->_hasher = nullptr;
v.second->unref();
}
_hashes->clear();
}
size_t StringHasher::size() const {
return _hashes->size();
}
size_t StringHasher::count() const {
size_t count = 0;
for (auto &v : _hashes->right)
if (v.second->getRefCount() > 1)
++count;
return count;
}
void StringHasher::Restore(Base::XMLReader &reader) {
clear();
reader.readElement("StringHasher");
_hashes->SaveAll = reader.getAttributeAsInteger("saveall") ? true : false;
_hashes->Threshold = reader.getAttributeAsInteger("threshold");
bool newtag = false;
if (reader.getAttributeAsInteger("new", "0") > 0) {
reader.readElement("StringHasher2");
newtag = true;
}
if (reader.hasAttribute("file")) {
const char *file = reader.getAttribute("file");
if(*file)
reader.addFile(file, this);
return;
}
std::size_t count = reader.getAttributeAsUnsigned("count");
if (newtag) {
restoreStreamNew(reader.beginCharStream(false), count);
reader.readEndElement("StringHasher2");
return;
}
else if (count && reader.FileVersion > 1)
restoreStream(reader.beginCharStream(false), count);
else {
for (std::size_t i = 0; i < count; ++i) {
reader.readElement("Item");
StringIDRef sid;
long id = reader.getAttributeAsInteger("id");
bool hashed = reader.hasAttribute("hash");
if (hashed || reader.hasAttribute("data")) {
const char *value = hashed ? reader.getAttribute("hash") : reader.getAttribute("data");
sid = new StringID(id, QByteArray::fromBase64(value), StringID::Flag::Hashed);
}
else
sid = new StringID(id, QByteArray(reader.getAttribute("text")));
insert(sid);
}
}
reader.readEndElement("StringHasher");
}
unsigned int StringHasher::getMemSize (void) const {
return (_hashes->SaveAll?size():count()) * 10;
}
PyObject *StringHasher::getPyObject() {
return new StringHasherPy(this);
}
std::map<long, StringIDRef> StringHasher::getIDMap() const {
std::map<long,StringIDRef> ret;
for (auto &v : _hashes->right)
ret.emplace_hint(ret.end(), v.first, StringIDRef(v.second));
return ret;
}
void StringHasher::clearMarks() const
{
for (auto &v : _hashes->right)
v.second->_flags.setFlag(StringID::Flag::Marked, false);
}
+680
View File
@@ -0,0 +1,680 @@
/****************************************************************************
* Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#ifndef APP_STRINGID_H
#define APP_STRINGID_H
#include <bitset>
#include <memory>
#include <QByteArray>
#include <QVector>
#include <Base/Bitmask.h>
#include <Base/Handle.h>
#include <Base/Persistence.h>
#include <CXX/Objects.hxx>
namespace Data{
class MappedName;
}
namespace App {
class StringHasher;
class StringID;
class StringIDRef;
typedef Base::Reference<StringHasher> StringHasherRef;
/** Class to store a string
*
* The main purpose of this class is to provide an efficient storage of the
* mapped geometry element name (i.e. the new Topological Naming), but it can
* also be used as a general purpose string table.
*
* The StringID is to be stored in a string table (StringHasher), and be
* referred to by an integer ID. The stored data can be optionally divided into
* two parts, prefix and postfix. This is because a new mapped name is often
* created by adding some common postfix to an existing name, so data sharing
* can be improved using the following techniques:
*
* a) reference count (through QByteArray) the main data part,
*
* b) (recursively) encode prefix and/or postfix as an integer (in the
* format of #<hex>, e.g. #1b) that references another StringID,
*
* c) Check index based name in prefix, e.g. Edge1, Vertex2, and encode
* only the text part as StringID. The index is stored separately in
* reference class StringIDRef to maximize data sharing.
*/
class AppExport StringID: public Base::BaseClass, public Base::Handled {
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
/// Flag of the stored string data
enum class Flag {
/// No flag
None = 0,
/// The stored data is binary
Binary = 1 << 0,
/// The stored data is the sha1 hash of the original content
Hashed = 1 << 1,
/** Postfix is encoded as #<hex>, e.g. #1b, where the hex integer part
* refers to another StringID.
*/
PostfixEncoded = 1 << 2,
/// The data is splited as prefix and postfix
Postfixed = 1 << 3,
/// The prefix data is split as text + index
Indexed = 1 << 4,
/** The prefix data is encoded as #<hex>, e.g. #1b, where the hex
* integer part refers to another StringID.
*/
PrefixID = 1 << 5,
/** The prefix split as text + index, where the text is encoded
* using another StringID.
*/
PrefixIDIndex = 1 << 6,
/// The string ID is persistent regardless of internal mark */
Persistent = 1 << 7,
/// Internal marked used to check if the string ID is used
Marked = 1 << 8,
};
typedef Base::Flags<Flag> Flags;
/** Constructor
* @param id: integer ID of this StringID
* @param data: input data
* @param flags: flags describes the data
*
* User code is not supposed to create StringID directly, but through StringHasher::getID()
*/
StringID(long id, const QByteArray &data, const Flags &flags=Flag::None)
:_id(id),_data(data),_flags(flags)
{}
/// Constructs an empty StringID
StringID()
:_id(0), _flags(Flag::None)
{}
virtual ~StringID();
/// Returns the ID of this StringID
long value() const {return _id;}
/// Returns all related StringIDs that used to encode this StringID
const QVector<StringIDRef> &relatedIDs() const {return _sids;}
/// @name Flag accessors
//@{
bool isBinary() const;
bool isHashed() const;
bool isPostfixed() const;
bool isPostfixEncoded() const;
bool isIndexed() const;
bool isPrefixID() const;
bool isPrefixIDIndex() const;
bool isMarked() const;
bool isPersistent() const;
//@}
/// Checks if this StringID is from the input hasher
bool isFromSameHasher(const StringHasherRef & hasher) const
{
return this->_hasher == hasher;
}
/// Returns the owner hasher
StringHasherRef getHasher() const
{
return StringHasherRef(_hasher);
}
/// Returns the data (prefix)
const QByteArray data() const {return _data;}
/// Returns the postfix
const QByteArray postfix() const {return _postfix;}
virtual PyObject *getPyObject() override;
/// Returns a Python tuple containing both the text and index
PyObject *getPyObjectWithIndex(int index);
/** Convert to string represtation of this StringID
* @param index: optional index
*
* The format is #<id>. And if index is non zero, then #<id>:<index>. Both
* <id> and <index> are in hex format.
*/
std::string toString(int index) const;
/// Light weight structure of holding a string ID and associated index
struct IndexID {
long id;
int index;
explicit operator bool() const {
return id > 0;
}
friend std::ostream & operator << (std::ostream &s, const IndexID & id) {
s << id.id;
if (id.index)
s << ':' << id.index;
return s;
}
};
/** Parse string to get ID and index
* @param name: input string
* @param eof: Whether to check the end of string. If true, then the input
* string must contain only the string representation of this
* StringID
* @param size: input string size, or -1 if the input string is zero terminated.
* @return Return the integer ID and index.
*
* The input string is expected to be in the format of #<id> or with index
* #<id>:<index>, where both id and index are in hex digits.
*/
static IndexID fromString(const char *name, bool eof=true, int size = -1);
/** Parse string to get ID and index
* @param bytes: input data
* @param eof: Whether to check the end of string. If true, then the input
* string must contain only the string representation of this
* StringID
*
* The input string is expected to be in the format of #<id> or with index
* #<id>:<index>, where both id and index are in hex digits.
*/
static IndexID fromString(const QByteArray &bytes, bool eof=true) {
return fromString(bytes.constData(), eof, bytes.size());
}
/** Get the text content of this StringID
* @param index: optional index
* @return Return the text content of this StringID. If the data is binary,
* then output in base64 encoded string.
*/
std::string dataToText(int index) const;
/** Get the content of this StringID as QByteArray
* @param bytes: output bytes
* @param index: opttional index.
*/
void toBytes(QByteArray &bytes, int index) const {
if (_postfix.size())
bytes = _data + _postfix;
else if (index)
bytes = _data + QByteArray::number(index);
else
bytes = _data;
}
/// Mark this StringID as used
void mark() const;
/// Mark the StringID as persistent regardless of usage mark
void setPersistent(bool enable);
bool operator<(const StringID &other) const {
return compare(other) < 0;
}
/** Compare StringID
* @param other: the other StringID for comparison
* @return Returns -1 if less than the other StringID, 1 if greater, or 0 if equal
*/
int compare(const StringID &other) const {
if (_hasher < other._hasher)
return -1;
if (_hasher > other._hasher)
return 1;
if (_id < other._id)
return -1;
if (_id > other._id)
return 1;
return 0;
}
friend class StringHasher;
private:
long _id;
QByteArray _data;
QByteArray _postfix;
StringHasher *_hasher = nullptr;
mutable Flags _flags;
mutable QVector<StringIDRef> _sids;
};
//////////////////////////////////////////////////////////////////////////
/** Counted reference to a StringID instance
*/
class StringIDRef
{
public:
StringIDRef()
:_sid(nullptr), _index(0)
{}
StringIDRef(StringID* p, int index=0)
: _sid(p), _index(index)
{
if (_sid)
_sid->ref();
}
StringIDRef(const StringIDRef & other)
: _sid(other._sid)
, _index(other._index)
{
if (_sid)
_sid->ref();
}
StringIDRef(StringIDRef && other)
: _sid(other._sid)
, _index(other._index)
{
other._sid = nullptr;
}
StringIDRef(const StringIDRef & other, int index)
: _sid(other._sid)
, _index(index)
{
if (_sid)
_sid->ref();
}
~StringIDRef()
{
if (_sid)
_sid->unref();
}
void reset(const StringIDRef & p = StringIDRef()) {
*this = p;
}
void reset(const StringIDRef &p, int index) {
*this = p;
this->_index = index;
}
void swap(StringIDRef &p) {
if(*this != p) {
auto tmp = p;
p = *this;
*this = tmp;
}
}
StringIDRef & operator=(StringID* p) {
if (_sid == p)
return *this;
if (_sid)
_sid->unref();
_sid = p;
if (_sid)
_sid->ref();
this->_index = 0;
return *this;
}
StringIDRef & operator=(const StringIDRef & p) {
if (_sid != p._sid) {
if (_sid)
_sid->unref();
_sid = p._sid;
if (_sid)
_sid->ref();
}
this->_index = p._index;
return *this;
}
StringIDRef & operator=(StringIDRef && p) {
if (_sid != p._sid) {
if (_sid)
_sid->unref();
_sid = p._sid;
p._sid = nullptr;
}
this->_index = p._index;
return *this;
}
bool operator<(const StringIDRef & p) const {
if (!_sid)
return true;
if (!p._sid)
return false;
int res = _sid->compare(*p._sid);
if (res < 0)
return true;
if (res > 0)
return false;
return _index < p._index;
}
bool operator==(const StringIDRef & p) const {
return _sid == p._sid && _index == p._index;
}
bool operator!=(const StringIDRef & p) const {
return _sid != p._sid || _index != p._index;
}
explicit operator bool() const {
return _sid != nullptr;
}
int getRefCount(void) const {
if (_sid)
return _sid->getRefCount();
return 0;
}
std::string toString() const {
if (_sid)
return _sid->toString(_index);
return std::string();
}
std::string dataToText() const {
if (_sid)
return _sid->dataToText(_index);
return std::string();
}
const char * constData() const {
if (_sid) {
assert(_index == 0);
assert(_sid->postfix().isEmpty());
return _sid->data().constData();
}
return "";
}
const StringID & deref() const {
return *_sid;
}
long value() const {
if (_sid)
return _sid->value();
return 0;
}
QVector<StringIDRef> relatedIDs() const {
if (_sid)
return _sid->relatedIDs();
return QVector<StringIDRef>();
}
bool isBinary() const {
if (_sid)
return _sid->isBinary();
return false;
}
bool isHashed() const {
if (_sid)
return _sid->isHashed();
return false;
}
void toBytes(QByteArray &bytes) const {
if (_sid)
_sid->toBytes(bytes, _index);
}
PyObject *getPyObject(void) {
if (_sid)
return _sid->getPyObjectWithIndex(_index);
Py_INCREF(Py_None);
return Py_None;
}
void mark() const {
if (_sid)
_sid->mark();
}
bool isMarked() const {
return _sid && _sid->isMarked();
}
bool isFromSameHasher(const StringHasherRef & hasher) const
{
return _sid && _sid->isFromSameHasher(hasher);
}
StringHasherRef getHasher() const
{
if (_sid)
return _sid->getHasher();
return StringHasherRef();
}
void setPersistent(bool enable)
{
if (_sid)
_sid->setPersistent(enable);
}
friend class StringHasher;
private:
StringID *_sid;
int _index;
};
/// A String table to map string from/to a unique integer
class AppExport StringHasher: public Base::Persistence, public Base::Handled {
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
StringHasher();
virtual ~StringHasher();
virtual unsigned int getMemSize (void) const override;
virtual void Save (Base::Writer &/*writer*/) const override;
virtual void Restore(Base::XMLReader &/*reader*/) override;
virtual void SaveDocFile (Base::Writer &/*writer*/) const override;
virtual void RestoreDocFile (Base::Reader &/*reader*/) override;
void setPersistenceFileName(const char *name) const;
const std::string &getPersistenceFileName() const;
/** Maps an arbitrary string to an integer
*
* @param text: input string.
* @param len: length of the string, or -1 if the string is 0 terminated.
* @param hashable: whether the string is hashable.
* @return Return a shared pointer to the internally stored StringID.
*
* The function maps an arbitrary text string to a unique integer ID, which
* is returned as a shared pointer to reference count the ID so that it is
* possible to prune any unused strings.
*
* If \c hashable is true and the string is longer than the threshold
* setting of this StringHasher, it will be sha1 hashed before storing, and
* the original content of the string is discarded. If else, the string is
* copied and stored inside a StringID instance.
*
* The purpose of function is to provide a short form of a stable string
* identification.
*/
StringIDRef getID(const char *text, int len=-1, bool hashable=false);
/// Option for string string data
enum class Option {
/// No option
None = 0,
/// The input data is binary
Binary = 1 << 0,
/** The input data is hashable. If the data length is longer than the
* threshold setting of the StringHasher, it will be sha1 hashed before
* storing, and the original content of the string is discarded.
*/
Hashable = 1 << 1,
/// Do not copy the data, assuming the data is constant. If this option
//is not set, the data will be copied before storing.
NoCopy = 1 << 2,
};
typedef Base::Flags<Option> Options;
/** Map text or binary data to an integer
*
* @param data: input data.
* @param options: options describing how to store the data. @sa Option.
* @return Return a shared pointer to the internally stored StringID.
*
* The function maps an arbitrary text string to a unique integer ID, which
* is returned as a shared pointer to reference count the ID so that it is
* possible to prune any unused strings.
*
* The purpose of function is to provide a short form of a stable string
* identification.
*/
StringIDRef getID(const QByteArray & data, Options options=Option::Hashable);
/** Map geometry element name to an integer */
StringIDRef getID(const Data::MappedName & name,
const QVector<StringIDRef> & sids);
/** Obtain the reference counted StringID object from numerical id
*
* @param id: string ID
* @param index: optional index of the string ID
* @return Return a shared pointer to the internally stored StringID.
*
* This function exists because the stored string may be one way hashed,
* and the original text is not persistent. The caller use this function to
* retrieve the reference count ID object after restore
*/
StringIDRef getID(long id, int index = 0) const;
/** Obtain the reference counted StringID object from numerical id and index
*
* @param id: string ID with index
* @return Return a shared pointer to the internally stored StringID.
*/
StringIDRef getID(const StringID::IndexID &id) const {
return getID(id.id, id.index);
}
std::map<long,StringIDRef> getIDMap() const;
/// Clear all string hashes
void clear();
/// Size of the hash table
size_t size() const;
/// Return the number of hashes that are used by others
size_t count() const;
virtual PyObject *getPyObject(void) override;
/** Enable/disable saving all string ID
*
* If disabled, then only save string ID that are used.
*/
void setSaveAll(bool enable);
bool getSaveAll() const;
/** Set threshold of string hashing
*
* For hashable string that are longer than the threshold, the string will
* be replaced by its sha1 hash.
*/
void setThreshold(int threshold);
int getThreshold() const;
/** Clear internal marks
*
* The internal marks on internally stored StringID instances are used to
* check if the StringID is used.
*/
void clearMarks() const;
/// Compact string storage
void compact();
class HashMap;
friend class StringID;
protected:
StringID * insert(const StringIDRef & sid);
long lastID() const;
void saveStream(std::ostream &s) const;
void restoreStream(std::istream &s, std::size_t count);
void restoreStreamNew(std::istream &s, std::size_t count);
private:
std::unique_ptr<HashMap> _hashes;
mutable std::string _filename;
};
} //namespace App
ENABLE_BITMASK_OPERATORS(App::StringID::Flag)
ENABLE_BITMASK_OPERATORS(App::StringHasher::Option)
namespace App {
inline bool StringID::isBinary() const {
return _flags.testFlag(Flag::Binary);
}
inline bool StringID::isHashed() const {
return _flags.testFlag(Flag::Hashed);
}
inline bool StringID::isPostfixed() const {
return _flags.testFlag(Flag::Postfixed);
}
inline bool StringID::isPostfixEncoded() const {
return _flags.testFlag(Flag::PostfixEncoded);
}
inline bool StringID::isIndexed() const {
return _flags.testFlag(Flag::Indexed);
}
inline bool StringID::isPrefixID() const {
return _flags.testFlag(Flag::PrefixID);
}
inline bool StringID::isPrefixIDIndex() const {
return _flags.testFlag(Flag::PrefixIDIndex);
}
inline bool StringID::isMarked() const {
return _flags.testFlag(Flag::Marked);
}
inline bool StringID::isPersistent() const {
return _flags.testFlag(Flag::Persistent);
}
inline void StringID::setPersistent(bool enable) {
_flags.setFlag(Flag::Persistent, enable);
}
} //namespace App
#endif
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="BaseClassPy"
Name="StringHasherPy"
Twin="StringHasher"
TwinPointer="StringHasher"
Include="App/StringHasher.h"
FatherInclude="Base/BaseClassPy.h"
Namespace="App"
FatherNamespace="Base"
Constructor="true"
Reference="true">
<Documentation>
<Author Licence="LGPL" Name="Zheng, Lei" EMail="realthunder.dev@gmail.com" />
<DeveloperDocu>This is the StringHasher class</DeveloperDocu>
<UserDocu>This is the StringHasher class</UserDocu>
</Documentation>
<Methode Name="getID">
<Documentation>
<UserDocu>
getID(txt|id, base64=False) -> StringID
If the input is text, return a StringID object that is unique within this hasher. This
StringID object is reference counted. The hasher may only save hash ID's that are used.
If the input is an integer, then the hasher will try to find the StringID object stored
with the same integer value.
base64: indicate if the input 'txt' is base64 encoded binary data
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isSame" Const="true">
<Documentation>
<UserDocu>Check if two hasher are the same</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Count" ReadOnly="true">
<Documentation>
<UserDocu>Return count of used hashes</UserDocu>
</Documentation>
<Parameter Name="Count" Type="Int" />
</Attribute>
<Attribute Name="Size" ReadOnly="true">
<Documentation>
<UserDocu>Return the size of the hashes</UserDocu>
</Documentation>
<Parameter Name="Size" Type="Int"/>
</Attribute>
<Attribute Name="SaveAll">
<Documentation>
<UserDocu>Whether to save all string hashes regardless of its use count</UserDocu>
</Documentation>
<Parameter Name="SaveAll" Type="Boolean"/>
</Attribute>
<Attribute Name="Threshold">
<Documentation>
<UserDocu>Data length exceed this threshold will be hashed before storing</UserDocu>
</Documentation>
<Parameter Name="Threshold" Type="Int"/>
</Attribute>
<Attribute Name="Table" ReadOnly="true">
<Documentation>
<UserDocu>Return the entire string table as Int->String dictionary</UserDocu>
</Documentation>
<Parameter Name="Table" Type="Dict"/>
</Attribute>
</PythonExport>
</GenerateModel>
+150
View File
@@ -0,0 +1,150 @@
/****************************************************************************
* Copyright (c) 2018 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#include "PreCompiled.h"
#include "StringHasher.h"
#include "StringHasherPy.h"
#include "StringHasherPy.cpp"
using namespace App;
// returns a string which represent the object e.g. when printed in python
std::string StringHasherPy::representation(void) const
{
std::ostringstream str;
str << "<StringHasher at " << getStringHasherPtr() << ">";
return str.str();
}
PyObject *StringHasherPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
return new StringHasherPy(new StringHasher);
}
// constructor method
int StringHasherPy::PyInit(PyObject* , PyObject* )
{
return 0;
}
PyObject* StringHasherPy::isSame(PyObject *args)
{
PyObject *other;
if (!PyArg_ParseTuple(args, "O!", &StringHasherPy::Type, &other)){ // convert args: Python->C
return Py::new_reference_to(Py::False());
}
auto otherHasher = static_cast<StringHasherPy*>(other)->getStringHasherPtr();
return Py::new_reference_to(Py::Boolean(getStringHasherPtr() == otherHasher));
}
PyObject* StringHasherPy::getID(PyObject *args)
{
long id = -1;
int index = 0;
PyObject *value = 0;
PyObject *base64 = Py_False;
if (!PyArg_ParseTuple(args, "l|i",&id,&index)) {
PyErr_Clear();
if (!PyArg_ParseTuple(args, "O|O",&value,&base64))
return NULL; // NULL triggers exception
}
if(id>0) {
PY_TRY {
auto sid = getStringHasherPtr()->getID(id, index);
if(!sid) Py_Return;
return sid.getPyObject();
}PY_CATCH;
}
std::string txt;
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(value)) {
txt = PyUnicode_AsUTF8(value);
}
#else
if (PyUnicode_Check(value)) {
PyObject* unicode = PyUnicode_AsLatin1String(value);
txt = PyString_AsString(unicode);
Py_DECREF(unicode);
}
else if (PyString_Check(value)) {
txt = PyString_AsString(value);
}
#endif
else
throw Py::TypeError("expect argument of type string");
PY_TRY {
QByteArray data;
StringIDRef sid;
if(PyObject_IsTrue(base64)) {
data = QByteArray::fromBase64(QByteArray::fromRawData(txt.c_str(),txt.size()));
sid = getStringHasherPtr()->getID(data,true);
}else
sid = getStringHasherPtr()->getID(txt.c_str(),txt.size());
return sid.getPyObject();
}PY_CATCH;
}
Py::Int StringHasherPy::getCount(void) const {
return Py::Int((long)getStringHasherPtr()->count());
}
Py::Int StringHasherPy::getSize(void) const {
return Py::Int((long)getStringHasherPtr()->size());
}
Py::Boolean StringHasherPy::getSaveAll(void) const {
return Py::Boolean(getStringHasherPtr()->getSaveAll());
}
void StringHasherPy::setSaveAll(Py::Boolean value) {
getStringHasherPtr()->setSaveAll(value);
}
Py::Int StringHasherPy::getThreshold(void) const {
return Py::Int((long)getStringHasherPtr()->getThreshold());
}
void StringHasherPy::setThreshold(Py::Int value) {
getStringHasherPtr()->setThreshold(value);
}
Py::Dict StringHasherPy::getTable() const {
Py::Dict dict;
for(auto &v : getStringHasherPtr()->getIDMap())
dict.setItem(Py::Int(v.first),Py::String(v.second.dataToText()));
return dict;
}
PyObject *StringHasherPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int StringHasherPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
+64
View File
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="BaseClassPy"
Name="StringIDPy"
Twin="StringID"
TwinPointer="StringID"
Include="App/StringHasher.h"
FatherInclude="Base/BaseClassPy.h"
Namespace="App"
FatherNamespace="Base"
Reference="true">
<Documentation>
<Author Licence="LGPL" Name="Zheng, Lei" EMail="realthunder.dev@gmail.com" />
<DeveloperDocu>This is the StringID class</DeveloperDocu>
<UserDocu>This is the StringID class</UserDocu>
</Documentation>
<Methode Name="isSame" Const="true">
<Documentation>
<UserDocu>Check if two StringIDs are the same</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Value" ReadOnly="true">
<Documentation>
<UserDocu>Return the integer value of this ID</UserDocu>
</Documentation>
<Parameter Name="Value" Type="Int"/>
</Attribute>
<Attribute Name="Related" ReadOnly="true">
<Documentation>
<UserDocu>Return the related string IDs</UserDocu>
</Documentation>
<Parameter Name="Related" Type="List"/>
</Attribute>
<Attribute Name="Data" ReadOnly="true">
<Documentation>
<UserDocu>Return the data associated with this ID</UserDocu>
</Documentation>
<Parameter Name="Data" Type="String"/>
</Attribute>
<Attribute Name="IsBinary" ReadOnly="true">
<Documentation>
<UserDocu>Check if the data is binary, </UserDocu>
</Documentation>
<Parameter Name="IsBinary" Type="Boolean"/>
</Attribute>
<Attribute Name="IsHashed" ReadOnly="true">
<Documentation>
<UserDocu>Check if the data is hash, if so 'Data' returns a base64 encoded string of the raw hash</UserDocu>
</Documentation>
<Parameter Name="IsHashed" Type="Boolean"/>
</Attribute>
<Attribute Name="Index" ReadOnly="false">
<Documentation>
<UserDocu>Geometry index. Only meaningful for geometry element name</UserDocu>
</Documentation>
<Parameter Name="Index" Type="Int"/>
</Attribute>
<ClassDeclarations>private:
friend class StringID;
int _index = 0;
</ClassDeclarations>
</PythonExport>
</GenerateModel>
+91
View File
@@ -0,0 +1,91 @@
/****************************************************************************
* Copyright (c) 2018 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
****************************************************************************/
#include "PreCompiled.h"
#include "StringHasher.h"
#include "StringIDPy.h"
#include "StringIDPy.cpp"
using namespace App;
// returns a string which represent the object e.g. when printed in python
std::string StringIDPy::representation(void) const
{
return getStringIDPtr()->toString(_index);
}
PyObject* StringIDPy::isSame(PyObject *args)
{
PyObject *other;
if (!PyArg_ParseTuple(args, "O!", &StringIDPy::Type, &other)) { // convert args: Python->C
return Py::new_reference_to(Py::False());
}
auto otherPy = static_cast<StringIDPy*>(other);
return Py::new_reference_to(Py::Boolean(
otherPy->getStringIDPtr() == this->getStringIDPtr()
&& otherPy->_index == this->_index));
}
Py::Int StringIDPy::getValue(void) const {
return Py::Int(getStringIDPtr()->value());
}
Py::List StringIDPy::getRelated(void) const {
Py::List list;
for (auto &id : getStringIDPtr()->relatedIDs())
list.append(Py::Long(id.value()));
return list;
}
Py::String StringIDPy::getData(void) const {
return Py::String(getStringIDPtr()->dataToText(this->_index));
}
Py::Boolean StringIDPy::getIsBinary(void) const {
return Py::Boolean(getStringIDPtr()->isBinary());
}
Py::Boolean StringIDPy::getIsHashed(void) const {
return Py::Boolean(getStringIDPtr()->isHashed());
}
Py::Int StringIDPy::getIndex(void) const {
return Py::Int(this->_index);
}
void StringIDPy::setIndex(Py::Int index) {
this->_index = index;
}
PyObject *StringIDPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int StringIDPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
+1 -1
View File
@@ -69,7 +69,7 @@ int AxisPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear();
PyObject* d;
if (PyArg_ParseTuple(args, "O!O", &(Base::VectorPy::Type), &o,
if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type), &o,
&(Base::VectorPy::Type), &d)) {
// NOTE: The first parameter defines the base (origin) and the second the direction.
*getAxisPtr() = Base::Axis(static_cast<Base::VectorPy*>(o)->value(),
+52 -25
View File
@@ -22,11 +22,17 @@
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
Copyright (C) 2019 Zheng Lei (realthunder.dev@gmail.com)
* Added support of in-line transformation using boost iostream for memory
efficiency
*/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <iostream>
# include <string>
#endif
@@ -39,12 +45,31 @@ static const std::string base64_chars =
"0123456789+/";
static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
const signed char *Base::base64_decode_table() {
static const signed char _table[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -1, -2, -1, -1, // 0-15
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 16-31
-2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, // 32-47
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, // 48-63
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64-79
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, // 80-95
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96-111
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, // 112-127
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 128-143
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 144-159
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 160-175
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 176-191
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 192-207
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 208-223
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 224-239
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // 240-255
};
return _table;
}
std::string Base::base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
std::string ret;
std::size_t Base::base64_encode(char *out, void const* in, std::size_t in_len) {
char *ret = out;
unsigned char const *bytes_to_encode = reinterpret_cast<unsigned char const*>(in);
int i = 0;
int j = 0;
unsigned char char_array_3[3];
@@ -59,7 +84,7 @@ std::string Base::base64_encode(unsigned char const* bytes_to_encode, unsigned i
char_array_4[3] = char_array_3[2] & 0x3f;
for(i = 0; (i <4) ; i++)
ret += base64_chars[char_array_4[i]];
*ret++ = base64_chars[char_array_4[i]];
i = 0;
}
}
@@ -75,37 +100,41 @@ std::string Base::base64_encode(unsigned char const* bytes_to_encode, unsigned i
char_array_4[3] = char_array_3[2] & 0x3f;
for (j = 0; (j < i + 1); j++)
ret += base64_chars[char_array_4[j]];
*ret++ = base64_chars[char_array_4[j]];
while((i++ < 3))
ret += '=';
*ret++ = '=';
}
return ret;
return ret-out;
}
std::string Base::base64_decode(std::string const& encoded_string) {
int in_len = encoded_string.size();
std::pair<std::size_t, std::size_t> Base::base64_decode(
void *_out, char const *in, std::size_t in_len)
{
unsigned char *out = reinterpret_cast<unsigned char*>(_out);
unsigned char *ret = out;
char const *input = in;
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::string ret;
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
char_array_4[i++] = encoded_string[in_]; in_++;
static const signed char *table = base64_decode_table();
while (in_len-- && *in != '=') {
const signed char v = table[(int)(*in++)];
if(v < 0)
break;
char_array_4[i++] = (unsigned char)v;
if (i ==4) {
for (i = 0; i <4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (i = 0; (i < 3); i++)
ret += char_array_3[i];
*ret++ = char_array_3[i];
i = 0;
}
}
@@ -114,15 +143,13 @@ std::string Base::base64_decode(std::string const& encoded_string) {
for (j = i; j <4; j++)
char_array_4[j] = 0;
for (j = 0; j <4; j++)
char_array_4[j] = base64_chars.find(char_array_4[j]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
for (j = 0; (j < i - 1); j++) *ret++ = char_array_3[j];
}
return ret;
return std::make_pair((std::size_t)(ret-out), (std::size_t)(in-input));
}
+366 -5
View File
@@ -23,20 +23,381 @@
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
Copyright (C) 2019 Zheng Lei (realthunder.dev@gmail.com)
* Added support of in-line transformation using boost iostream for memory
efficiency
*/
#ifndef BASE_BASE64_H
#define BASE_BASE64_H
#include <FCGlobal.h>
#include <string>
#include <memory>
#include <vector>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/operations.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/device/file.hpp>
namespace Base
{
std::string BaseExport base64_encode(unsigned char const* , unsigned int len);
std::string BaseExport base64_decode(std::string const& s);
/// Returns the max bytes of a encoded base64 string
inline std::size_t base64_encode_size(std::size_t len) {
return 4 * ((len + 2) / 3);
}
}
/// Returns the max bytes of a decoded base64 binary string
inline std::size_t base64_decode_size(std::size_t len) {
return len / 4 * 3;
}
/** Encode input binary with base64
* @param out: output buffer with minimum size of base64_encode(len)
* appending new data.
* @param in: input binary data
* @param len: input length
* @return The character count written to output.
*/
BaseExport std::size_t base64_encode(char *out, void const *in , std::size_t len);
/** Return the internal base64 decoding table
*
* The table maps from any 8-bit character to the decoded binary bits.
* Valid base64 characters are mapped to the corresponding 6-bit binary
* data. White space (space, tab, vtab, CR and LF) characters are mapped
* to -2. Other invalid characters are mapped to -1.
*/
BaseExport const signed char *base64_decode_table();
/** Decode the input base64 string into binary data
* @param out: output buffer with minimum size of base64_encode(len)
* appending new data.
* @param in: input binary data
* @param len: input length
* @return Return a pair of output size and input read size. Compare the
* read size to input size to check for error.
*/
BaseExport std::pair<std::size_t, std::size_t> base64_decode(
void *out, char const *, std::size_t len);
/** Encode input binary into base64 string
* @param out: output string. Note that the string is not cleared before
* adding new content.
* @param in: input binary data
* @param len: input length
*/
inline void base64_encode(std::string &out, void const* in , std::size_t len) {
std::size_t size = out.size();
out.resize(size + base64_encode_size(len));
len = base64_encode(&out[size],in,len);
out.resize(size+len);
}
/** Encode input binary into base64 string
* @param in: input binary data
* @param len: input length
* @return Return the base64 string.
*/
inline std::string base64_encode(void const* in , std::size_t len) {
std::string out;
base64_encode(out,in,len);
return out;
}
/** Decode base64 string into binary data
* @param out: output binary data. Note that the data is not cleared before
* adding new content.
* @param in: input base64 string
* @param len: input length
* @return Return the processed input length. Compare this with the
* argument \c len to check for error.
*/
template<typename T>
inline std::size_t base64_decode(T &out, char const *in, std::size_t len) {
std::size_t size = out.size();
out.resize(size + base64_decode_size(len));
std::pair<std::size_t,std::size_t> res = base64_decode(&out[size],in,len);
out.resize(size + res.first);
return res.second;
}
/** Decode base64 string into binary data
* @param out: output binary data. Note that the data is not cleared before
* adding new content.
* @param s: input base64 string
* @return Return the processed input length. Compare this with the
* argument \c len to check for error.
*/
template<typename T>
inline std::size_t base64_decode(T &out, std::string const &s) {
return base64_decode(out,s.c_str(),s.size());
}
/** Decode base64 string into binary data
* @param out adding new content.
* @param s: input base64 string
* @return Return the decoded binary data.
*/
inline std::string base64_decode(std::string const& s) {
std::string out;
base64_decode(out,s.c_str(),s.size());
return out;
}
namespace bio = boost::iostreams;
/** A base64 encoder that can be used as a boost iostream filter
*
* @sa See create_base64_encoder() for example usage
*/
struct base64_encoder {
typedef char char_type;
struct category : bio::multichar_output_filter_tag
, bio::closable_tag
, bio::optimally_buffered_tag
{};
/** Constructor
* @param line_size: line size for the output base64 string, 0 to
* disable segmentation.
*/
base64_encoder(std::size_t line_size)
:line_size(line_size)
{
}
std::streamsize optimal_buffer_size() const {
return base64_decode_size(line_size);
}
template<typename Device>
void close(Device &dev)
{
if(pending_size)
base64_encode(buffer,pending,pending_size);
if(buffer.size()) {
bio::write(dev,buffer.c_str(),buffer.size());
if(line_size)
bio::put(dev,'\n');
buffer.clear();
}else if(pos && line_size)
bio::put(dev,'\n');
}
template<typename Device>
std::streamsize write(Device& dev, const char_type* s, std::streamsize n) {
std::streamsize res = n;
if(pending_size) {
while(n && pending_size < 3) {
pending[pending_size++] = *s++;
--n;
}
if(pending_size!=3)
return res;
base64_encode(buffer,pending,3);
}
pending_size = n%3;
n = n/3*3;
base64_encode(buffer,s,n);
s += n;
for(unsigned i=0;i<pending_size;++i)
pending[i] = s[i];
const char *buf = buffer.c_str();
const char *end = buf + buffer.size();
if(line_size && buffer.size()>=line_size-pos) {
bio::write(dev,buf,line_size-pos);
bio::put(dev,'\n');
buf += line_size-pos;
pos = 0;
for(; end-buf>=(int)line_size; buf+=line_size) {
bio::write(dev,buf,line_size);
bio::put(dev,'\n');
}
}
pos += end-buf;
bio::write(dev,buf,end-buf);
buffer.clear();
return n;
}
std::size_t line_size;
std::size_t pos = 0;
std::size_t pending_size = 0;
unsigned char pending[3];
std::string buffer;
};
/** A base64 decoder that can be used as a boost iostream filter
*
* @sa See create_base64_decoder() for example usage
*/
struct base64_decoder {
typedef char char_type;
struct category : bio::multichar_input_filter_tag
, bio::optimally_buffered_tag
{};
/** Constructor
* @param line_size: line size of the encoded base64 string. This is
* used just as a suggestion for better buffering.
* @param silent: whether to throw on invalid non white space character.
*/
base64_decoder(std::size_t line_size, bool silent)
:line_size(line_size), silent(silent)
{
}
std::streamsize optimal_buffer_size() const {
return base64_encode_size(line_size?line_size:1024);
}
template<typename Device>
std::streamsize read(Device& dev, char_type* s, std::streamsize n) {
static const signed char *table = base64_decode_table();
if(!n)
return 0;
std::streamsize count = 0;
for(;;) {
while(pending_out<out_count) {
*s++ = char_array_3[pending_out++];
++count;
if(--n == 0)
return count;
}
if(eof)
return count?count:-1;
for(;;) {
int d = bio::get(dev);
if(d < 0) {
eof = true;
if(pending_in<=1) {
if(pending_in == 1 && !silent)
throw BOOST_IOSTREAMS_FAILURE("Unexpected ending of base64 string");
return count?count:-1;
}
out_count = pending_in-1;
pending_in = 4;
} else {
signed char c = table[d];
if(c < 0) {
if(c==-2 || silent)
continue;
throw BOOST_IOSTREAMS_FAILURE("Invalid character in base64 string");
}
char_array_4[pending_in++] = (char)c;
}
if(pending_in == 4) {
pending_out = pending_in = 0;
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
break;
}
}
}
}
std::size_t line_size;
std::uint8_t pending_in = 0;
char char_array_4[4];
std::uint8_t pending_out = 3;
std::uint8_t out_count = 3;
char char_array_3[3];
bool silent;
bool eof = false;
};
/** Create an output stream that transforms the input binary data to base64 strings
*
* @param out: the downstream output stream that will be fed with base64 string
* @param line_size: line size of the base64 string. Zero to disable segmenting.
*
* @return A unique pointer to an output stream that can transforms the
* input binary data to base64 strings.
*/
inline std::unique_ptr<std::ostream> create_base64_encoder(
std::ostream &out, std::size_t line_size=80)
{
std::unique_ptr<std::ostream> res(new bio::filtering_ostream);
bio::filtering_ostream *f = static_cast<bio::filtering_ostream*>(res.get());
f->push(base64_encoder(line_size));
f->push(out);
return res;
}
/** Create an output stream that stores the input binary data to file as base64 strings
*
* @param filename: the output file path
* @param line_size: line size of the base64 string. Zero to disable segmenting.
*
* @return A unique pointer to an output stream that can transforms the
* input binary data to base64 strings.
*/
inline std::unique_ptr<std::ostream> create_base64_encoder(
const std::string &filepath, std::size_t line_size=80)
{
std::unique_ptr<std::ostream> res(new bio::filtering_ostream);
bio::filtering_ostream *f = static_cast<bio::filtering_ostream*>(res.get());
f->push(base64_encoder(line_size));
f->push(bio::file_sink(filepath));
return res;
}
/** Create an input stream that can transform base64 into binary
*
* @param in: input upstream.
* @param line_size: line size of the encoded base64 string. This is
* used just as a suggestion for better buffering.
* @param silent: whether to throw on invalid non white space character.
*
* @return A unique pointer to an input stream that read from the given
* upstream and transform the read base64 strings into binary data.
*/
inline std::unique_ptr<std::istream> create_base64_decoder(
std::istream &in, std::size_t line_size=80, bool silent=true)
{
std::unique_ptr<std::istream> res(new bio::filtering_istream);
bio::filtering_istream *f = static_cast<bio::filtering_istream*>(res.get());
f->push(base64_decoder(line_size,silent));
f->push(in);
return res;
}
/** Create an input stream that can transform base64 into binary
*
* @param filepath: input file.
* @param ending: optional ending character. If non zero, the filter
* will signal EOF when encounter this character.
* @param putback: if true and the filter read the ending character
* it will put it back into upstream
* @param line_size: line size of the encoded base64 string. This is
* used just as a suggestion for better buffering.
* @param silent: whether to throw on invalid non white space character.
*
* @return A unique pointer to an input stream that read from the given
* file and transform the read base64 strings into binary data.
*/
inline std::unique_ptr<std::istream> create_base64_decoder(
const std::string &filepath, std::size_t line_size=80, bool silent=true)
{
std::unique_ptr<std::istream> res(new bio::filtering_istream);
bio::filtering_istream *f = static_cast<bio::filtering_istream*>(res.get());
f->push(base64_decoder(line_size,silent));
f->push(bio::file_source(filepath));
return res;
}
} // namespace Base
#endif
+7
View File
@@ -109,6 +109,7 @@ template <typename Enum>
class Flags {
static_assert(std::is_enum<Enum>::value, "Flags is only usable on enumeration types.");
Enum i;
typedef typename std::underlying_type<Enum>::type underlying_type;
public:
constexpr inline Flags(Enum f) : i(f) {}
@@ -123,6 +124,12 @@ public:
using u = typename std::underlying_type<Enum>::type;
return static_cast<u>(i) == static_cast<u>(f.i);
}
Enum getValue() const {
return i;
}
underlying_type toUnderlyingType() const {
return static_cast<underlying_type>(i);
}
};
}
+2 -2
View File
@@ -610,7 +610,7 @@ inline bool BoundBox3<_Precision>::IntersectionPoint (const Vector3<_Precision>
rc = IntersectPlaneWithLine(i, rcVct, rcVctDir, cVctRes);
if (!cCmpBound.IsInBox(cVctRes))
rc = false;
if (rc == true) {
if (rc) {
// does intersection point lie in desired direction
// or was found the opposing side?
// -> scalar product of both direction vectors > 0 (angle < 90)
@@ -773,7 +773,7 @@ inline typename BoundBox3<_Precision>::SIDE BoundBox3<_Precision>::GetSideFromRa
Vector3<_Precision>& rcInt) const
{
Vector3<_Precision> cP0, cP1;
if (IntersectWithLine(rclPt, rclDir, cP0, cP1) == false)
if (!IntersectWithLine(rclPt, rclDir, cP0, cP1))
return INVALID;
Vector3<_Precision> cOut;
+120 -72
View File
@@ -14,196 +14,244 @@
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
<DeveloperDocu>This is the BoundBox export class</DeveloperDocu>
<UserDocu>Bound box class
A bounding box is an orthographic cube which is a way to describe outer boundaries.
You get a bounding box from a lot of 3D types. It is often used to check if a 3D
entity lies in the range of another object. Checking for bounding interference first
can save a lot of computing time!
Constructor:
App.BoundBox([Xmin,Ymin,Zmin,Xmax,Ymax,Zmax])
App.BoundBox(Tuple, Tuple)
App.BoundBox(Vector, Vector)
App.BoundBox(BoundBox)
</UserDocu>
<UserDocu>Base.BoundBox class.\n
This class represents a bounding box.
A bounding box is a rectangular cuboid which is a way to describe outer
boundaries and is obtained from a lot of 3D types.
It is often used to check if a 3D entity lies in the range of another object.
Checking for bounding interference first can save a lot of computing time!
An invalid BoundBox is represented by inconsistent values at each direction:
The maximum float value of the system at the minimum coordinates, and the
opposite value at the maximum coordinates.\n
The following constructors are supported:\n
BoundBox()
Empty constructor. Returns an invalid BoundBox.\n
BoundBox(boundBox)
Copy constructor.
boundBox : Base.BoundBox\n
BoundBox(xMin, yMin=0, zMin=0, xMax=0, yMax=0, zMax=0)
Define from the minimum and maximum values at each direction.
xMin : float\n Minimum value at x-coordinate.
yMin : float\n Minimum value at y-coordinate.
zMin : float\n Minimum value at z-coordinate.
xMax : float\n Maximum value at x-coordinate.
yMax : float\n Maximum value at y-coordinate.
zMax : float\n Maximum value at z-coordinate.\n
App.BoundBox(min, max)
Define from two containers representing the minimum and maximum values of the
coordinates in each direction.
min : Base.Vector, tuple\n Minimum values of the coordinates.
max : Base.Vector, tuple\n Maximum values of the coordinates.</UserDocu>
</Documentation>
<Methode Name="setVoid">
<Documentation>
<UserDocu>method setVoid()
Invalidate the bounding box</UserDocu>
<UserDocu>setVoid() -> None\n
Invalidate the bounding box.</UserDocu>
</Documentation>
</Methode>
<Methode Name="isValid">
<Documentation>
<UserDocu>method isValid()
Checks if the bounding box is valid</UserDocu>
<UserDocu>isValid() -> bool\n
Checks if the bounding box is valid.</UserDocu>
</Documentation>
</Methode>
<Methode Name="add">
<Documentation>
<UserDocu>method add(BoundBox)
Add (enlarge) the given BoundBox</UserDocu>
<UserDocu>add(minMax) -> None
add(x, y, z) -> None\n
Increase the maximum values or decrease the minimum values of this BoundBox by
replacing the current values with the given values, so the bounding box can grow
but not shrink.\n
minMax : Base.Vector, tuple\n Values to enlarge at each direction.
x : float\n Value to enlarge at x-direction.
y : float\n Value to enlarge at y-direction.
z : float\n Value to enlarge at z-direction.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPoint">
<Documentation>
<UserDocu>method getPoint(Int)
Get the point of the given index. The index must be in the range of [0,7]
</UserDocu>
<UserDocu>getPoint(index) ->Base.Vector\n
Get the point of the given index.
The index must be in the range of [0, 7].\n
index : int</UserDocu>
</Documentation>
</Methode>
<Methode Name="getEdge">
<Documentation>
<UserDocu>method getEdge(Int)
Get the edge points of the given index. The index must be in the range of [0,11]
</UserDocu>
<UserDocu>getEdge(index) -> tuple of Base.Vector\n
Get the edge points of the given index.
The index must be in the range of [0, 11].\n
index : int</UserDocu>
</Documentation>
</Methode>
<Methode Name="closestPoint">
<Documentation>
<UserDocu>method closestPoint(Vector)
Get the closest point of the bounding box to the given point
</UserDocu>
<UserDocu>closestPoint(point) -> Base.Vector
closestPoint(x, y, z) -> Base.Vector\n
Get the closest point of the bounding box to the given point.\n
point : Base.Vector, tuple\n Coordinates of the given point.
x : float\n X-coordinate of the given point.
y : float\n Y-coordinate of the given point.
z : float\n Z-coordinate of the given point.</UserDocu>
</Documentation>
</Methode>
<Methode Name="intersect">
<Documentation>
<UserDocu>method intersect(BoundBox|Vector Base, Vector Dir)
Checks if the given object intersects with the BoundBox. That can be:
- Another BoundBox
- A line, specified by Base and Dir
</UserDocu>
<UserDocu>intersect(boundBox2) -> bool
intersect(base, dir) -> bool\n
Checks if the given object intersects with this bounding box. That can be
another bounding box or a line specified by base and direction.\n
boundBox2 : Base.BoundBox
base : Base.Vector, tuple
dir : Base.Vector, tuple</UserDocu>
</Documentation>
</Methode>
<Methode Name="intersected">
<Documentation>
<UserDocu>method intersected(BoundBox)
Returns the intersection of this and the given bounding box.
</UserDocu>
<UserDocu>intersected(boundBox2) -> Base.BoundBox\n
Returns the intersection of this and the given bounding box.\n
boundBox2 : Base.BoundBox</UserDocu>
</Documentation>
</Methode>
<Methode Name="united">
<Documentation>
<UserDocu>method united(BoundBox)
Returns the union of this and the given bounding box.
</UserDocu>
<UserDocu>united(boundBox2) -> Base.BoundBox\n
Returns the union of this and the given bounding box.\n
boundBox2 : Base.BoundBox</UserDocu>
</Documentation>
</Methode>
<Methode Name="enlarge">
<Documentation>
<UserDocu>method enlarge(Float)
Enlarge the BoundBox by the given value in each direction.
A negative value shrinks the box.</UserDocu>
<UserDocu>enlarge(variation) -> None\n
Decrease the minimum values and increase the maximum values by the given value.
A negative value shrinks the bounding box.\n
variation : float</UserDocu>
</Documentation>
</Methode>
<Methode Name="getIntersectionPoint">
<Documentation>
<UserDocu>method Vector getIntersectionPoint(Vector Base, Vector Dir, [float epsilon=0.0001])
Calculate the intersection point of a line with the BoundBox
The Base point must lie inside the bounding box, if not an
exception is thrown.
</UserDocu>
<UserDocu>getIntersectionPoint(base, dir, epsilon=0.0001) -> Base.Vector\n
Calculate the intersection point of a line with the bounding box.
The base point must lie inside the bounding box, if not an exception is thrown.\n
base : Base.Vector\n Base point of the line.
dir : Base.Vector\n Direction of the line.
epsilon : float\n Bounding box size tolerance.</UserDocu>
</Documentation>
</Methode>
<Methode Name="move">
<Documentation>
<UserDocu> method move(Vector)
Move the BoundBox by the given vector
</UserDocu>
<UserDocu>move(displacement) -> None
move(x, y, z) -> None\n
Move the bounding box by the given values.\n
displacement : Base.Vector, tuple\n Displacement at each direction.
x : float\n Displacement at x-direction.
y : float\n Displacement at y-direction.
z : float\n Displacement at z-direction.</UserDocu>
</Documentation>
</Methode>
<Methode Name="scale">
<Documentation>
<UserDocu> method scale(x,y,z)
Scale the BoundBox by the given values in x, y and z
</UserDocu>
<UserDocu>scale(factor) -> None
scale(x, y, z) -> None\n
Scale the bounding box by the given values.\n
factor : Base.Vector, tuple\n Factor scale at each direction.
x : float\n Scale at x-direction.
y : float\n Scale at y-direction.
z : float\n Scale at z-direction.</UserDocu>
</Documentation>
</Methode>
<Methode Name="transformed">
<Documentation>
<UserDocu> method transformed(Matrix)
Return a new bounding box with the transformed corner of this bounding box
</UserDocu>
<UserDocu>transformed(matrix) -> Base.BoundBox\n
Returns a new BoundBox containing the transformed rectangular cuboid
represented by this BoundBox.\n
matrix : Base.Matrix\n Transformation matrix.</UserDocu>
</Documentation>
</Methode>
<Methode Name="isCutPlane">
<Documentation>
<UserDocu>method bool isCutPlane(Vector Base, Vector Normal)
Check if the plane specified by Base and Normal intersects (cuts) the BoundBox</UserDocu>
<UserDocu>isCutPlane(base, normal) -> bool\n
Check if the plane specified by base and normal intersects (cuts) this bounding
box.\n
base : Base.Vector
normal : Base.Vector</UserDocu>
</Documentation>
</Methode>
<Methode Name="isInside">
<Documentation>
<UserDocu>
method bool isInside(Vector Base|BoundBox box)
Check if the point or bounding box is inside this bounding box
</UserDocu>
<UserDocu>isInside(object) -> bool
isInside(x, y, z) -> bool\n
Check if a point or a bounding box is inside this bounding box.\n
object : Base.Vector, Base.BoundBox\n Object to check if it is inside this bounding box.
x : float\n X-coordinate of the point to check.
y : float\n Y-coordinate of the point to check.
z : float\n Z-coordinate of the point to check.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Center" ReadOnly="true">
<Documentation>
<UserDocu>Center point of the bounding box</UserDocu>
<UserDocu>Center point of the bounding box.</UserDocu>
</Documentation>
<Parameter Name="Center" Type="Object" />
</Attribute>
<Attribute Name="XMax" ReadOnly="false">
<Documentation>
<UserDocu>The maximum x boundary position</UserDocu>
<UserDocu>The maximum x boundary position.</UserDocu>
</Documentation>
<Parameter Name="XMax" Type="Float" />
</Attribute>
<Attribute Name="YMax" ReadOnly="false">
<Documentation>
<UserDocu>The maximum y boundary position</UserDocu>
<UserDocu>The maximum y boundary position.</UserDocu>
</Documentation>
<Parameter Name="YMax" Type="Float" />
</Attribute>
<Attribute Name="ZMax" ReadOnly="false">
<Documentation>
<UserDocu>The maximum z boundary position</UserDocu>
<UserDocu>The maximum z boundary position.</UserDocu>
</Documentation>
<Parameter Name="ZMax" Type="Float" />
</Attribute>
<Attribute Name="XMin" ReadOnly="false">
<Documentation>
<UserDocu>The minimum x boundary position</UserDocu>
<UserDocu>The minimum x boundary position.</UserDocu>
</Documentation>
<Parameter Name="XMin" Type="Float" />
</Attribute>
<Attribute Name="YMin" ReadOnly="false">
<Documentation>
<UserDocu>The minimum y boundary position</UserDocu>
<UserDocu>The minimum y boundary position.</UserDocu>
</Documentation>
<Parameter Name="YMin" Type="Float" />
</Attribute>
<Attribute Name="ZMin" ReadOnly="false">
<Documentation>
<UserDocu>The minimum z boundary position</UserDocu>
<UserDocu>The minimum z boundary position.</UserDocu>
</Documentation>
<Parameter Name="ZMin" Type="Float" />
</Attribute>
<Attribute Name="XLength" ReadOnly="true">
<Documentation>
<UserDocu>Length of the BoundBox in x direction</UserDocu>
<UserDocu>Length of the bounding box in x direction.</UserDocu>
</Documentation>
<Parameter Name="XLength" Type="Float" />
</Attribute>
<Attribute Name="YLength" ReadOnly="true">
<Documentation>
<UserDocu>Length of the BoundBox in y direction</UserDocu>
<UserDocu>Length of the bounding box in y direction.</UserDocu>
</Documentation>
<Parameter Name="YLength" Type="Float" />
</Attribute>
<Attribute Name="ZLength" ReadOnly="true">
<Documentation>
<UserDocu>Length of the BoundBox in z direction</UserDocu>
<UserDocu>Length of the bounding box in z direction.</UserDocu>
</Documentation>
<Parameter Name="ZLength" Type="Float" />
</Attribute>
<Attribute Name="DiagonalLength" ReadOnly="true">
<Documentation>
<UserDocu>Diagonal length of the BoundBox</UserDocu>
<UserDocu>Diagonal length of the bounding box.</UserDocu>
</Documentation>
<Parameter Name="DiagonalLength" Type="Float" />
</Attribute>
+24 -25
View File
@@ -311,23 +311,22 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject *args)
{
PyObject *object,*object2;
double epsilon=0.0001;
if (PyArg_ParseTuple(args,"O!O!|d:Need base and direction vector",
&(Base::VectorPy::Type), &object,&(Base::VectorPy::Type), &object2, &epsilon)) {
Base::Vector3d point;
bool ok = getBoundBoxPtr()->IntersectionPoint(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()),
point, epsilon);
if (ok) {
return new VectorPy(point);
}
else {
PyErr_SetString(Base::PyExc_FC_GeneralError, "No intersection");
return nullptr;
}
}
else
if (!PyArg_ParseTuple(args,"O!O!|d;Need base and direction vector",
&(Base::VectorPy::Type), &object,&(Base::VectorPy::Type), &object2, &epsilon))
return nullptr;
Base::Vector3d point;
bool ok = getBoundBoxPtr()->IntersectionPoint(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()),
point, epsilon);
if (ok) {
return new VectorPy(point);
}
else {
PyErr_SetString(Base::PyExc_FC_GeneralError, "No intersection");
return nullptr;
}
}
PyObject* BoundBoxPy::move(PyObject *args)
@@ -344,13 +343,13 @@ PyObject* BoundBoxPy::move(PyObject *args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args,"O!:Need vector to move",&PyTuple_Type, &object)) {
if (PyArg_ParseTuple(args,"O!",&PyTuple_Type, &object)) {
vec = getVectorFromTuple<double>(object);
break;
}
PyErr_Clear();
if (PyArg_ParseTuple(args,"O!:Need vector to move",&(Base::VectorPy::Type), &object)) {
if (PyArg_ParseTuple(args,"O!",&(Base::VectorPy::Type), &object)) {
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
break;
}
@@ -382,13 +381,13 @@ PyObject* BoundBoxPy::scale(PyObject *args)
}
PyErr_Clear();
if (PyArg_ParseTuple(args,"O!:Need vector to scale",&PyTuple_Type, &object)) {
if (PyArg_ParseTuple(args,"O!",&PyTuple_Type, &object)) {
vec = getVectorFromTuple<double>(object);
break;
}
PyErr_Clear();
if (PyArg_ParseTuple(args,"O!:Need vector to scale",&(Base::VectorPy::Type), &object)) {
if (PyArg_ParseTuple(args,"O!",&(Base::VectorPy::Type), &object)) {
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
break;
}
@@ -429,14 +428,14 @@ PyObject* BoundBoxPy::isCutPlane(PyObject *args)
return nullptr;
}
if (PyArg_ParseTuple(args,"O!O!:Need base and normal vector of a plane",
if (!PyArg_ParseTuple(args,"O!O!;Need base and normal vector of a plane",
&(Base::VectorPy::Type), &object,&(Base::VectorPy::Type), &object2))
retVal = getBoundBoxPtr()->IsCutPlane(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
else
return nullptr;
retVal = getBoundBoxPtr()->IsCutPlane(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
return Py::new_reference_to(retVal);
}
+4 -4
View File
@@ -116,7 +116,7 @@ void Builder3D::endPoints()
void Builder3D::addSinglePoint(float x, float y, float z,short pointSize, float color_r,float color_g,float color_b)
{
// addSinglePoint() not between startXXX() and endXXX() allowed
assert( bStartEndOpen == false );
assert(!bStartEndOpen);
result << "Separator { ";
result << "Material { ";
@@ -155,7 +155,7 @@ void Builder3D::addSinglePoint(const Base::Vector3f &vec, short pointSize, float
void Builder3D::addText(float pos_x, float pos_y , float pos_z,const char * text, float color_r,float color_g,float color_b)
{
// addSinglePoint() not between startXXX() and endXXX() allowed
assert( bStartEndOpen == false );
assert(!bStartEndOpen);
result << "Separator { "
<< "Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} "
@@ -172,8 +172,8 @@ void Builder3D::addText(const Base::Vector3f &vec,const char * text, float color
void Builder3D::clear ()
{
// Under VC6 string::clear() doesn't exist, under gcc stringstream::str() returns a copy not a reference
#if defined(_MSC_VER) && _MSC_VER >= 1400
// under gcc stringstream::str() returns a copy not a reference
#if defined(_MSC_VER)
result.str().clear();
#endif
result.clear();
+2
View File
@@ -34,6 +34,7 @@
#include <frameobject.h>
#include "ConsoleObserver.h"
#include "Interpreter.h"
using namespace Base;
@@ -263,6 +264,7 @@ std::stringstream &LogLevel::prefix(std::stringstream &str, const char *src, int
}
if (print_tag) str << '<' << tag << "> ";
if (print_src==2) {
PyGILStateLocker lock;
PyFrameObject* frame = PyEval_GetFrame();
if (frame) {
line = PyFrame_GetLineNumber(frame);
+27 -19
View File
@@ -14,68 +14,76 @@
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
<DeveloperDocu>This is the CoordinateSystem export class</DeveloperDocu>
<UserDocu></UserDocu>
<UserDocu>Base.CoordinateSystem class.\n
An orthonormal right-handed coordinate system in 3D space.\n
CoordinateSystem()
Empty constructor.</UserDocu>
</Documentation>
<Methode Name="setAxes">
<Documentation>
<UserDocu>setAxes(Axis or Vector z, Vector x)
Set axis or z direction and x direction</UserDocu>
<UserDocu>setAxes(axis, xDir) -> None\n
Set axis or Z-direction, and X-direction.
The X-direction is determined from the orthonormal compononent of `xDir`
with respect to `axis` direction.\n
axis : Base.Axis, Base.Vector
xDir : Base.Vector</UserDocu>
</Documentation>
</Methode>
<Methode Name="displacement" Const="true">
<Documentation>
<UserDocu>displacement(CoordinateSystem)
Computes the placement from this to the passed coordinate system</UserDocu>
<UserDocu>displacement(coordSystem2) -> Base.Placement\n
Computes the placement from this to the passed coordinate system `coordSystem2`.\n
coordSystem2 : Base.CoordinateSystem</UserDocu>
</Documentation>
</Methode>
<Methode Name="transformTo">
<Documentation>
<UserDocu>transformTo(Vector)
Computes the coordinates of the point in coordinates of this system
</UserDocu>
<UserDocu>transformTo(vector) -> Base.Vector\n
Computes the coordinates of the point in coordinates of this coordinate system.\n
vector : Base.Vector</UserDocu>
</Documentation>
</Methode>
<Methode Name="transform">
<Documentation>
<UserDocu>transform(Rotation or Placement)
Applies the rotation or placement on this coordinate system
</UserDocu>
<UserDocu>transform(trans) -> None\n
Applies a transformation on this coordinate system.\n
trans : Base.Rotation, Base.Placement</UserDocu>
</Documentation>
</Methode>
<Methode Name="setPlacement">
<Documentation>
<UserDocu>setPlacment(Placement)
Set placement to the coordinate system.
</UserDocu>
<UserDocu>setPlacment(placement) -> None\n
Set placement to the coordinate system.\n
placement : Base.Placement</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Axis" ReadOnly="false">
<Documentation>
<UserDocu>Set or get axis</UserDocu>
<UserDocu>Set or get axis.</UserDocu>
</Documentation>
<Parameter Name="Axis" Type="Object" />
</Attribute>
<Attribute Name="XDirection" ReadOnly="false">
<Documentation>
<UserDocu>Set or get x direction</UserDocu>
<UserDocu>Set or get X-direction.</UserDocu>
</Documentation>
<Parameter Name="XDirection" Type="Object" />
</Attribute>
<Attribute Name="YDirection" ReadOnly="false">
<Documentation>
<UserDocu>Set or get y direction</UserDocu>
<UserDocu>Set or get Y-direction.</UserDocu>
</Documentation>
<Parameter Name="YDirection" Type="Object" />
</Attribute>
<Attribute Name="ZDirection" ReadOnly="false">
<Documentation>
<UserDocu>Set or get z direction</UserDocu>
<UserDocu>Set or get Z-direction.</UserDocu>
</Documentation>
<Parameter Name="ZDirection" Type="Object" />
</Attribute>
<Attribute Name="Position" ReadOnly="false">
<Documentation>
<UserDocu>Set or get position</UserDocu>
<UserDocu>Set or get position.</UserDocu>
</Documentation>
<Parameter Name="Position" Type="Object" />
</Attribute>

Some files were not shown because too many files have changed in this diff Show More