[go: nahoru, domu]

Skip to content

Source Files

Patrick Podest edited this page Jul 24, 2019 · 1 revision

On this page an overview of the source files is given as well as a description of its purposes. Here the top directory is considered as being ./bcfplugin

./

The bcfplugin/ directory, here considered as top directory ./, contains all source files executed during the execution of the plugin.

File Description
__init__.py Contains the dependency checks as well as the detection of the mode of operation (inside FreeCAD or not, in GUI mode or not)
programmaticInterface.py Provides the interface to the data model.
util.py Contains miscellaneous functions that are needed in multiple modules. For example the printing functions (debug, printInfo, printErr) are located in this file.
BCFPlugin.FCMacro Will be executed by FreeCAD. It starts the initialization sequence of the plugin

./rdwr

This directory contains the files that contain the classes which comprise the data model. In addition to that it provides the modules reader.py and writer.py, which read and write from and to a BCF file.

File Description
__init__.py Apart from creating a python package of the ./rdwr directory, the ./rdwr/interfaces directory and the top directory are added to the path variable.
markup.py Contains most classes specified inside markup.bcf.
modification.py This file contains just two classes holding for one the eMail address of an author and the date of authoring. Objects of these classes however can be serialized to one of two XML-nodes: <Date>, <Author> or <ModificationDate> or <ModificationAuthor>. In case of serializing the Topic class, objects of these classes can also be serialized to <CreationDate> and <CreationAuthor>.
project.py Contains only the class representing data contained inside project.bcfp, and a list of all topics contained inside the BCF file.
reader.py Responsible for reading in a BCF file and returning an object of Project as a result.
threedvector.py Contains classes representing points, vectors and lines in the three dimensional space.
topic.py Contains all data associated with a topic.
uri.py Holds only a wrapper class for string objects that can be an URI.
viewpoint.py Holds all data contained inside viewpoint.bcfv.
writer.py Probably the mightiest module of this whole plugin. It writes updates to the extracted BCF file in a temporary directory (working directory). It also can save the complete state of the working directory to a new BCF file.

./rdwr/interfaces

Contains interfaces that are implemented by the classes of the data model, which make working with the data model easier.

File Description
__init__.py Does not do anything, except for letting the python import system recognize this directory as package.
hierarchy.py Contains the Hierarchy interface, providing every implementing class with a reference to the object that holds a reference to it.
identifiable.py Contains two classes used for identification of objects. The first Identifiable is implemented by nearly every class, and is the backbone of the programmaticInterface, the second is implemented by classes representing XML-nodes that are assigned a GUID (for example: <Comment>).
state.py Contains the State interface. It supplies every implementing class with a member denoting the current state of the object. The state therefore can assume one of four values: ORIGINAL, ADDED, MODIFIED, DELETED.
xmlname.py Every implementing class can be serialized to an XML element. Thus getEtElement() has to be implemented by every class, which returns an xml.etree.ElementTree.Element object, containing all data of the object.

./frontend

Contains only code for controlling the view of FreeCAD.

File Description
viewController.py Modifies the currently active view of FreeCAD's active document, if running in GUI mode.

./gui

Contains all code concerning the graphical user interface of the plugin.

File Description
plugin_delegate.py This file contains all delegates used for the GUI in the plugin. The most advanced one being CommentDelegate.
plugin_model.py Contains models, retrieving data from the data model (i.e.: object of class Project), which are returned in a standardized way, depending on the current index and role.
plugin_panel.py Contains the code opening the main plugin window as a task panel inside FreeCAD.
plugin_view.py Contains for one all views used in the plugin and also the main window, which is realized as separate class.

./gui/design

This folder contains files, who's contents will be merged into one of the plugin_*.py files. It thus is simply a testing directory.

./gui/comment-list

Here the prototyping of the comment view has taken place. It can be started as separate application if mainwindow.py is executed.

./gui/examples

In this directory only some examples, created in tutorials, are located for reference.

./tests

This directory contains unit tests for several aspects of the application. The following table gives a description of the aspects tested. Every testfile is accompanied by an equally named test folder, which contains test data. The tests are unit tests created with python's unit test framework. To run all tests specified in one file simply run

python *tests.py
File Description
interface_tests.py Contains tests for programmaticInterface.py.
reader-tests.py Contains tests for reader.py. For theses test cases many test xml files are located inside ./tests/reader_tests/
search_test.py Contains tests for the object search algorithm, searching for an object's id (it has to implement Identifiable) inside the object of Project and its members. The algorithm implemented is a depth first algorithm.
writer_tests.py Contains tests for writer.py. The test files are located inside ./tests/writer_tests. Every file with the suffix '_test.bcf` is being written to. The resulting file is checked against the equally named file with the suffix '_check.bcf'.
Clone this wiki locally