Tue, 11/05/2024 - 12:20
Forums:
Hello everyone, i've got few questions about implementing application. Using Qt and OpenCASCADE. I've found out there is class TDocStd_Application , should i use it to control every process in my app or i should use inherited classes(if yes, which one)? Because i checked source code of FreeCAD , they don't use this class.
If i am going to use this class, should i separated implement wrapper class Command, to got opportunity to manipulate history of model modification? Or *_Application classes could provide this functionality?
Tue, 11/05/2024 - 16:15
This would greatly depend on Data Model demands of your application. OCCT comes with:
BinTools
andBRepTools
implementing persistence forTopoDS_Shape
(without any extra data), e.g. for saving shapes in files.TopoDS_Shape
persistence with arbitrary attributes and other data. It also defines low-level Undo/Redo mechanisms.XCAF
defines document structure based on OCAF for Data Exchange - e.g. shapes with colors, materials, validation properties, PMI, metadata. Mostly fllfills capacities of STEP standard, but includes some other features. It is possible extending XCAF document at application level, but this customization should be done carefully.TObj
defines object-oriented tools on top ofOCAF
for implementing application-specific Data Model with shapes, Undo/Redo, persistence. It provides a more clear and straightforward mechanism than using low-levelOCAF
bricks directly.As such, you need first to understand which information you would like to store in your document, how many application-specific attributes and data it will hold and which operations should support.
E.g., if Data Exchange is your main focus, than XCAF is preferable document format compatible with all XDE interfaces in OCCT (STEP, IGES, OBJ, glTF, VRML) and having it's own persistence (binary XBF or textual XML). But it is not that extensible and might be difficult to modify.
If you have a lot of own data objects or completely different document structure - then it might be better starting with
TObj
(it is quite convenient interface, but you might experience some lack of live examples and tutorials - I've been working with it having a look at existing projects usingTObj
, a great cheat sheet of good practices). Dealing with low-level OCAF might be even more challenging for newcomer (but I have no personal experience on that).Of course, you may end up implementing you own Data Model and rely on
BinTools
andBRepTools
just for file persistence ofTopoDS_Shape
- this is what FreeCAD developers decided to do (with own XML file format), as far as I understand. But in this case you will have to implement Undo/Redo/Transactions mechanism on your own (if your application requires that).Tue, 11/05/2024 - 14:38
As for original question of inheriting
TDocStd_Application
- there is no much reason to do so, you may use this class directly. Previously, subclasses of this class did some extra work to define persistence drivers (as dynamically loaded plugins, with extra files defining mappings), but nowadays file formats could be specified externally, so that subclassing is not that necessary.One exception is
TObj_Application
which defines a couple of extra routines (you will need this class, if you'll work withTObj
. OrXCAFApp_Application
forXCAF
.Tue, 11/05/2024 - 15:03
Thx a lot, for such wide answers.