Commit Graph

231 Commits

Author SHA1 Message Date
Zheng, Lei
29bc24a5cf PropertyLinks: refactor property link API
* Create new class PropertyLinkBase as the common parent class for all
  type of links. See the class document for details of its API.

* Added new link scope 'Hidden' that is ignored during normal object
  dependency calculation, but still keep tracks of object remove,
  relabel, etc.

* There is a new concept called 'Shadow subname' introduced in this
  patch, which will only be meaningful in future topological naming
  feature. See [here](https://git.io/fjXKR) for more details.

* DocumentObject added a new API adjustRelativeLink() and a helper
  resolveRelativeLink() function.
2019-08-17 14:52:09 +02:00
Zheng, Lei
de4651bc99 App: transaction related API changes
Introduce a new concept of transaction ID. Each transaction must be
unique inside the document. Multiple transactions from different
documents can be grouped together with the same transaction ID.
This makes it possible to undo/redo single operation that contains
changes from multiple documents due to external linking.

Application:

* get/set/closeActiveTransaction() is used to setup potential
  transactions with a given name. The transaction is only created when
  there is actual changes. If objects from multiple documents are
  changed under the same active transaction, they will have the same
  trasnaction ID, and can be undo/redo togtether later.

* signalUndo/signalRedo, new signals triggered once after an undo/redo
  operation. Unlike signalUndo/RedoDocument, these signals will only be
  triggered once even if there may be multiple documents involved during
  undo/redo.

* signal(Before)CloseTransaction, new signals triggered before/after an
  actual transaction is created or aborted.

AutoTransaction:

* Helper class to enable automatic management of transactions. See class
  document for more details. This class will be used by Gui::Command
  in later patches to allow better automation of transactions in
  command.

Document:

* open/commit/abortTransaction() are now redirected to call
  Application::get/set/closeActiveTransaction() instead.

* _openTransaction() is added to do the real creation of transaction.

* _checkTransaction() is modified to create transaction on actual change
  of any property.

* getTransactionID() is used to find out the position of a transaction
  with a given ID. When triggering undo in external document, it may be
  necessary to perform multi-step undo/redo in order to match for the
  transaction ID.

Transaction/TransactionObject:

* Various changes for the new transaction ID concept.

* Support undo/redo add/remove dynamic property
2019-08-17 14:52:09 +02:00
Zheng, Lei
be6ec3fdfc App: Property related API changes
Property:

* Extended property status bitset. Mirror most of PropertyType and
  allow dynamic change property type.

* Cache property name and type to improve performance

* Centralize property status change signalling

* Change aboutToSetValue()/hasSetValue() to virtual

* Add new API getFullName() to obtain full quanlified name of the property

AtomicPropertyChangeInterface:

* Allow calling aboutToSetValue()/hasSetValue() when actually changed

PropertyLists:

* Refactor implementation by an abstract class PropertyListBase and a
  template class PropertyListsT, to allow better code reuse.
  PropertyListT is derived from AtomicPropertyChangeInterface to allow
  more efficient change on individual elements.

* All list type property now accept setting python value as a dictionary
  with index as key to set individual element of a list.

* Add touch list for more efficient handling of value changes. The list
  contains the index of changed value. And empty touch list should be
  treated as the entire list is changed. PropertyContainerPy expose this
  functionality with getPropertyTouchList().

PropertyPersistentObject:

* New property to allow dynamic creation of any FreeCAD object derived
  from Base::Persistence, and use it as a property.

DynamicProperty:

* Use boost multi_index_container for efficient property lookup while
  keeping order.

* Modify to be allowed to use in PropertyContainer directly

PropertyContainer:

* Use boost multi_index_container for efficient property lookup while
  keeping order.

* Allow adding/removing dynamic property on all property container

* Modify Save/Restore() to persist property status, and better handle
  transient property which can now be dynamically enabled/disabled per
  object.

* Add new API getFullName() to obtain full quanlified name of the property.
  Implemented by Document, DocumentObject, and also
  ViewProviderDocumentObject if future patch

DocumentObject and FeaturePython are modified to accommondate the
dynamic property changes.

Removed get/setCustomAttribute() implementation from DocumentObjectPy,
and rely on PropertyContainerPy for the implementation, because of the
additional dynamic property support in property container.

Gui::ViewProviderDocumentObject, which is derived from
PropertyContainer, is also modified accordingly
2019-08-17 14:52:09 +02:00
Zheng, Lei
6731e83bf5 App: add New APIs for future Link function
DocumentObject:

* getSubObject(): the most important API for Link to work with
  hierarchies. The function is a inspired from and replaces the
  getPySubObjects(). It returns a child object following a dot separated
  subname reference, and can optionally return accumulated
  transformation, and/or a python object of the refered
  sub-object/element. The default implementation here is to look for
  link type property, and search for the referenced object. This patch also
  include other specialized implementation of this API, such as
  (GeoFeature)GroupExtension (through extensionGetSubObject()),
  PartDesign::Body, and so on. A link type object is expected to
  call the linked object's getSubObject() for resolving.

* getSubObjectList(): helper function to return a list of object
  referenced in the given subname.

* getSubObjects(): return a list of subname references of all children
  objects. The purpose of this function is similar to
  ViewProvider::claimChildren().  Container type object is expected to
  implement this function.  The reason it returns subname references
  instead of just object is to allow the container to skip hierarchies.
  For example, the Assembly3 container uses this to skip the constraint
  and element group.

* getLinkedObject(), obtain the linked object, and optionally with the
  accumulated transformation. It is expected to return a linked object
  or the object itself if it is not a link. In case there are multiple
  levels of linking involved, this function allows the caller to retrieve
  the linked object recursively.

* hasChildElement(), set/isElementVisible(), controls the children
  visibility for a group type object. Because the child object may be
  claimed by other objects, it is essential to have independent control
  of children visibilities. These APIs are designed to abstract how
  group manages the child visibility. For performance reason, these
  function are meant to control only the immediate child object.

* resolve(), helper function to parse subname reference and resolve the
  final object, and optionally the immediate parent of the final object,
  the final object reference name (for calling `set/isElementVisible()`),
  and the subname reference if there is one.

* touch(), add optional argument 'noRecompute' for better backward
  compatibility with the NoRecompute flag. By default, touch() causes
  recompute unless noRecompute is true

* signalChanged/signalBeforeChange, two new signal for tracking changes
  of a specific object.

* getViewProviderNameOverride(), return a string of the view provider
  type of this object. This allows Python class to override the view
  provider of an object. This feature will be used by ViewProviderLink
  which is designed to work with any object that has LinkBaseExtension.

* canLinkProperties(), will be used by Gui::PropertyView to display
  linked object properties together with the object's own properties.

* redirectSubname(), will be used by Gui::Tree to allow an object to
  redirect selection to some other object when (pre)selected in the tree
  view.

* Visibility, new property serve as the same purpose as view provider
  property of the same name. It is added here so that App namespace
  code can check for visibility without Gui module. This is useful,
  for example, when constructing a compound shape of a container that
  respects the children visibility.

* (has)hasHiddenMarker(), return or check for a special sub-element
  name used as marker for overriding sub-object visibility. Will be
  used by Gui::ViewProvider, it is put here for the same reason as
  adding Visibility property.

* getID(), return object internal identifier. Each object is now
  assigned an integer identifier that is unique within its containing
  document.

Document:

* ShowHidden, new property to tell tree view whether to show hidden
  object items.

* signalTouchedObject, new signal triggered when manually touch an
  object when calling its touch() function

* getObjectByID(), get object by its identifier

* addObject() is modified to allow overriding view provider

* has/getLinksTo(), helper function to obtain links to a given object.

Application:

* checkLinkDepth(), helper function to check recursive depth for link
  traversal. The depth is checked against the total object count of
  all opened documents. The count (_objCount) is internally updated
  whenever object is added or removed.

* has/getLinksTo(), same as Document::has/getLinksTo() but return links
  from all opened documents.

GroupExtension/OriginGroupExtension/DatumFeature/DatumCS/Part::Feature:
implement sepcialized getSubObject/getSubObjects().
2019-08-17 14:52:08 +02:00
Zheng, Lei
8f16147a40 Base: improve exception
For better FC and Python exception mapping.
2019-08-17 14:52:08 +02:00
wmayer
254bae2ebd For divide-by-zero issues write an error message intead of raising an exception 2019-06-20 14:43:16 +02:00
wmayer
6d1785a5eb Fix crash in case encoding of Python paths fails 2019-06-19 17:31:50 +02:00
wmayer
fdcd36f251 fixes #0004000: Ability to suppress console output when running under python 2019-06-13 15:46:49 +02:00
luz.paz
b7b433e461 Misc. typo and whitespace fixes
Found via `codespell`
2019-04-30 10:15:59 -03:00
joha2
0d8f3127ee FreeCAD: Application: removed banner in Cmd RunMode 2019-03-31 11:27:14 +02:00
wmayer
f0a1c43dbf fix -Winconsistent-missing-override 2019-02-28 22:55:46 +01:00
wmayer
2f31efe4c3 PVS: V779 Unreachable code detected. It is possible that an error is present. 2019-02-17 20:12:56 +01:00
Abdullah Tahiri
92b216f7e5 Missing ExceptionProducer init for RestoreError 2018-11-27 13:23:44 -03:00
wmayer
1647eee92c add specialized exception type for bad graphs 2018-11-26 14:15:19 +01:00
wmayer
a41a130704 some additions to pR 1794:
add a special XMLAttributeError class to indicate an error when accessing a missing attribute
in PropertyContainer::Restore make error handling more flexible
2018-11-19 19:07:56 +01:00
wmayer
36271b4052 move from deprecated boost.signals to boost.signals2 library 2018-10-30 19:09:03 +01:00
wmayer
193c253289 add module for Qt translation stuff 2018-10-28 12:58:14 +01:00
wmayer
4310b745ea improve whitespaces 2018-10-24 19:41:21 +02:00
wmayer
d88860a4c1 rework error handling mechanism 2018-10-24 19:38:43 +02:00
wmayer
bf4dd7920e emit signal when starting and finishing to save a document 2018-10-08 14:03:00 +02:00
wmayer
addb742b3c minor fixes 2018-10-08 12:27:03 +02:00
ickby
b08738c15b Expose document property changes to python document observer 2018-10-08 11:01:07 +02:00
ickby
65d6d5cc33 Expose onBeforeChange to python document observer 2018-10-08 10:52:52 +02:00
Stefan Tröger
e338fe6b70 Expose transaction events to document observer 2018-10-08 10:49:39 +02:00
Stefan Tröger
e571a6e07a Add signals for recomputed objects 2018-10-08 10:43:32 +02:00
luz.paz
360e581672 Misc. typo and whitespace fixes
ref: https://forum.freecadweb.org/viewtopic.php?f=3&t=30988#p256964
along with other misc. fixes
2018-09-19 17:26:03 +02:00
wmayer
9e8be1aa23 extend QuantityFormat to set denominator independent of user settings 2018-09-17 12:38:46 +02:00
hokieengr
f8dcd64fa2 Added support for fractional inch user setting. 2018-09-17 10:32:04 +02:00
wmayer
398fc8ce80 issue #0003588: The path to the Addons does not allow special characters 2018-09-13 21:40:30 +02:00
wmayer
8f1ef0d90c get rid of private function _PyImport_FixupBuiltin for FreeCAD and FreeCADGui modules 2018-09-01 19:57:15 +02:00
wmayer
ab7346b216 get rid of private function _PyImport_FixupBuiltin for __FreeCADBase__ module 2018-09-01 16:26:18 +02:00
wmayer
78efe74229 number of used decimals in UnitsApi must already be set when initializing App 2018-08-29 23:35:38 +02:00
wmayer
d3b69b582d improve handling as library if used by another application 2018-08-09 17:01:46 +02:00
wmayer
228b63e1f9 fix possible UNICODE related build failure due to OCCT cmake flags 2018-08-06 12:29:43 +02:00
wmayer
1f2302141d + implement direct and queued mode in console class 2018-07-25 17:25:32 +02:00
luz.paz
69b3b0b7f2 Misc. typos 2018-05-19 12:06:34 -04:00
luz.paz
9167064fc1 Misc. typos
Found via `codespell`
2018-04-25 09:41:33 -03:00
wmayer
911fedbbac behave like standard Python interpreter in console mode if no file name is passed 2018-04-21 16:42:54 +02:00
looooo
74d7adef10 py3: make __FreeCADBase__ importable
https://forum.freecadweb.org/viewtopic.php?f=10&t=12534&start=510#p220765
2018-03-30 11:28:15 +02:00
luz.paz
436444b424 Misc. typos 2018-01-27 19:43:18 +01:00
Unknown
e3eca59173 Misc. typo fixes
Various workbenches
2017-12-23 14:30:30 +01:00
wmayer
6ed21609e4 issue #0002973: Path to FreeCAD.app can't contain unicode 2017-12-02 19:37:05 +01:00
wmayer
0b7ce87340 allow to set console and unit test option without overriding each other
start unit tests in command line mode because the python pivy package is missing
2017-10-10 20:40:09 +02:00
luzpaz
f3bf8fe919 Misc. typos
+ some are doxy others are just comment code.  
+ some minor whitespace and grammatical tweaks. 
+ app/SCL/* typos have also been submitted upstream (https://github.com/stepcode/stepcode/pull/366). So it's ok to merge them in to master.
2017-10-04 17:59:11 +02:00
Stefan Tröger
d5633c37bf Create special scope properties 2017-09-09 16:47:07 +02:00
Eivind Kvedalen
03c39f3a13 Added PropertyPosition and PropertyDirection classes. Basically PropertyVector classes with units. 2017-07-23 22:14:05 +02:00
Markus Hovorka
f9f2d8c31b Add TextDocument with full size editor
A new document object App::TextDocument. It has a property Text which
holds the text of the document as a string. This commit also contains a
full size editor based on QPlainTextEdit. It can only be used by the
TextDocument and has a read only mode invoked for read only documents
(ReadOnly property set to true). The editor is invoked by a double
click on the TextDocument.
2017-07-04 19:36:10 +02:00
wmayer
19d55fa227 fix issues in CoordinateSystem class and expose to Python 2017-06-20 21:22:59 +02:00
wmayer
729cfd8155 py3: fox compiler warnings
issue 0000995
2017-06-04 00:17:57 +02:00
Zheng, Lei
f14ef7058d Console: added tag based log support 2017-05-13 17:46:38 +02:00