Initialization for buildes program
Provides intialization resources for buildes.
This is a description of what the following modules do. This information is important to understand the structure and relationship between the various parts of buildes. NOTE: There is a similar overview for all packages.
The buildes module provides the user-visible functions the user uses to achieve the capability provided in the buildes program.
Buildes GUI
Provides a window for working with Buildes.
I used the book ‘Rapid GUI Programming with Python and Qt : the definitive guide to PyQt programming’ by Mark Summerfield from [Prentice Hall] as the definitive reference. Of course the complete project would not be possible without specific customization references provided over the internet by numerous others. I tried to give credit in the specific areas in code wherever I could.
Bases: PyQt4.QtGui.QMainWindow
Provides tools to view and receive information while using buildes
Helper for adding actions to menu or toolbar.
Parameters: |
|
---|
Adds recently used session files to file menu list.
Parameter: | fname (String) – name of file that have been recently opened. |
---|
Populate the provided group type with the appropriate objects.
Parameters: |
|
---|
Populate the tree of levels with named objects.
Parameters: |
|
---|
Populate the tree of spaces with their parts and bounds.
Spaces have sides which are part of them. They also have other components such as furniture and fixtures which they bound. All these should be the children of the specific space in the tree. The parts of the space are added first followed by the bounded objects.
Exit buildesUi
It first determines if user really wants to exit. If this is true it then saves the last opened file as well as the recent list of files. It also saves the state of the application including size and position of the windows before closing.
Return true if path is to an accessible file.
Parameter: | filePath (String) – Absolute path to an existing file |
---|---|
Returns: | Whether filePath exists |
Return type: | Boolean |
Testing testing
Parameter: | string – |
---|
Helper for creating actions to be performed in menus and toolbars.
Parameters: |
|
---|---|
Returns: | Menu action |
Return type: | QtGui.QAction |
Returns formated data about named object.
Parameter: | name (QString) – Name of object |
---|---|
Returns: | Formated string of data |
Return type: | String |
Returns the root path to filename
Parameter: | fileName (String) – Desired file name |
---|---|
Returns: | Combines fileName to expected path under root installation |
Return type: | String |
Returns name and contents of site object.
Returns: | A list of names. |
---|---|
Return type: | List |
Returns the user path to filename
Parameter: | fileName (String) – Desired file name |
---|---|
Returns: | Combines fileName to expected path under user directory |
Return type: | String |
Check and render model in modelview
Checks if it is OK to render model in modelView then proceed or abort accordingly
Initializes actions that can be performed.
This is called by __init__ to setup and connect actions to be provided in the menubar and toolbar. It sets up the actions by calling createAction. This is a helper method just to help minimize the steps or number of lines required in creating these actions. Another helper method called addActions is then used to actually add the actions to each menu or toolbar. Note that the filemenu is different because we want to refresh the file menu frequently to show the list of nine last opened files. We save the filemenu actions in a tuple called fileMenuActions, then we connect the filemenu to the slot updateFileMenu to be performed whenever the user clicks on the menu which emits the aboutToShow signal.
Inserts named file into editor. If clear, it clear editor first
Parameters: |
|
---|
Insert the provided template at cursor position in gui
Parameter: | tplFile (String) – Absolute path and file name of template |
---|
Load a file into the textArea.
There are two parts to this function.
The first part is when a call is made without any file name such as when called from a recently used file action. In such a case we retrieve the sending object which should be a QAction object then we extracts the action’s user data in which we store the file name including path.
In the second part we have a file name which we then try to load.
Parameter: | fname (String) – Possible file to be loaded |
---|
Place levels in proper sequence.
Parameter: | levelList – |
---|---|
Returns: | Sorted list of level names. |
Return type: | List |
Allows the choice to save or ignore changes.
Checks to determine if there are any changes to session. If ‘Yes’ allows user to save, if No, does not allow to save but changes will be lost, if ‘Cancel’, does not allow changes to be saved but changes can be saved later.
‘Cancel’ brings up the dialog again as this function is called twice. Provided fixes for the rest. BUG, I say!!!!!
Returns: | Returns boolean depending on user selection. |
---|---|
Return type: | Boolean |
Reaction to user using the down-arrow button in the query line
Allows the user to forwardly navigate historic items for query line
Reaction to user using the up-arrow button in the query line
Allows the user to backwardly navigate historic items for query line
TODO: Removes trailing spaces from text in the editor
Returns: | |
---|---|
Return type: |
Check and process text in textArea
Checks if it is OK to process text in textArea then proceed or abort accordingly
Show copyright in message window.
This happens on first execution of buildesUi only.
Append msg to the message area
Parameter: | msg – |
---|
Show object information when selected in tree.
Parameters: |
|
---|
Get project summary data and designer name.
Parameter: | name (String) – Site object name. |
---|
Populate the filemenu showing any recently opened files.
Rebuilds the filemenu in order to show the list of nine most recently opened filenames.
Enables and disables actions in response to program state.
Parameter: | arg – |
---|
Buildes module
Manages all objects in a building design created using the Buildes program.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Provides the main boundary class for the Buildes program. This can be considered the application object. It provides access to all components.
Assign color to an object.
Parameters: |
|
---|
Assign material to an object.
Parameters: |
|
---|
Raises a custom exception with message.
Parameter: | msg – |
---|
Combines log message and function name with appropriate delimeter
Parameters: |
|
---|---|
Returns: | Properly combined function name and message |
Return type: | String |
Creates the site object.
When buildes startes, it automatically creates a default site object. It does this because every building must have a site and it saves the designer the trouble of having to create one. This default site however, can be replaced by the user’s customized site if manually created. In such cases, the default version is simply replaced. Default site also comes with a default level. This makes it possible for the user to start placing objects if it is a single story building without attention to site parameters.
Raises a custom exception with message.
Parameter: | msg – |
---|
Provides the ability to count debug log types
Parameter: | msg – |
---|
Returns the begin, middle and end labels for an edge.
If edge is None, the default edge letter for components is returned.
Parameter: | edge (String) – The desired edge letter |
---|---|
Returns: | The three snap labels for edge. |
Return type: | None | [String, String, String] |
Raises a custom exception with message.
Parameter: | msg – |
---|
Adds an objects name in in_process.
Parameters: |
|
---|
Determine if any object of otype is under construction.
For certain objects it is important to monitor their construction process because it is expected that the designer will provide additional parts in successive runs of Buildes. This routine checks to determine if there are other objects of the same type designating that they are still unfinished or under contruction. If there are, it issues a reminder message. If there are none it does not issue any message.
In addition, it adds oname provided to designate that it is now under construction.
Parameters: |
|
---|---|
Returns: | Whether an unfinished object was found. |
Return type: | Boolean |
Deletes an object name from inProcess
Parameters: |
|
---|
Returns object of otype that is unfinished in the design.
Parameter: | otype (String) – Type of object to find that is unfinished. |
---|---|
Returns: | Name of object that is unfinished in the design. |
Return type: | String |
Provides the ability to count info log types
Parameter: | msg – |
---|
Check if arg is a possible edge.
Parameter: | arg (String) – Possible edge designation. |
---|---|
Returns: | Whether arg is a possible edge. |
Return type: | Boolean |
Check if arg is a possible snap.
Note
Snap is implied if none is provided in arg. For such cases the origin is assumed. In such cases this function should not be used to determine for possible snap.
Parameter: | arg (String) – Possible snap designation. |
---|---|
Returns: | Whether object is a possible snap designation. |
Return type: | Boolean |
Provide information to enrich messages.
This adds class, method and line information based on the location from where it is called.
Adapted from: http://www.karoltomala.com/blog/?p=720
Parameter: | msg (String) – Message the user desires to send out. |
---|---|
Returns: | Message appended with information to locate where generated |
Return type: | String |
Finds snap labels corresponding to other edges of a component.
For example in the above figure, if label provided is a1, [l1, r1] is returned. If label provided is l1, [r1, a1] is returned and finally if label r1 is provided, [l1, a1] is returned. NOTE: The ‘l’ or ‘r’ labels are always the first in the list. This can only be used for objects with width or thickness.
Parameter: | label (String) – Label designating the edge in question. |
---|---|
Returns: | The corresponding labels at the edge of a component. |
Return type: | None | [String, String] |
Finds the snap label at other end corresponding to label.
For example in the above figure, if label provided is l3, l1 is returned. This can only be used with space sides.
Parameter: | label (String) – Label designating the end in question. |
---|---|
Returns: | Label at the other end of the end in question. |
Return type: | None | String |
Facilitates the heirachical relationship necessary in buildings.
Parameters: |
|
---|
Remake a data object when main properties were not provided by user.
This is necessary after moving objects using fit_offset and conn_offset.
Parameter: | data (BuildesData) – Data object that needs snaps recalculated |
---|
Returns the extension file name for name.
Parameter: | name – |
---|---|
Returns: | Extension file name for name |
Return type: | String |
Returns the extension file ext for ext.
Parameter: | ext – |
---|---|
Returns: | Extension file ext for ext |
Return type: | String |
Add an object name to the seen_open_sides list.
Parameter: | name (String) – Object name that is or has openSides. |
---|
Designate the current selected color object.
Parameter: | col – |
---|
Set orientation in the object provided.
Parameter: | obj (BuildesData) – Buildes data object |
---|
Change building level.
Parameter: | name (String) – Name of level designated by the user. |
---|---|
Returns: | Whether level change was successful |
Return type: | Boolean |
Designate the current selected material object.
Parameter: | mat – |
---|
Allows the ability to log messages
Sets up loggers to both file (.log) and to stdout. Logs at level of info are sent to the file while those at the level of warn and higher logs are sent to stdout by default.
Set up name for logging project information
Parameter: | path_name – |
---|---|
Returns: | |
Return type: |
Determine whether to skip object oname with parent pname.
Parameters: |
|
---|---|
Returns: | Whether oname is in list of objects in skip_shapes |
Return type: | Boolean |
Adds an object name in skip_shapes.
Parameters: |
|
---|
Allows parents to make any updates to their edges.
Parameter: | obj (BuildesData) – Child object. |
---|
Provides the ability to count warn log types
Parameter: | msg – |
---|
Buildes Data Object
This provides the common object between all buildes data objects.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Provides the common parameters for data objects in buildes.
Get the color for object data.
Returns: | Color name for object data. |
---|---|
Return type: | String |
Get the color for object data.
Returns: | Color name for object data. |
---|---|
Return type: | String |
Get the material name for object.
Returns: | Material name for object data. |
---|---|
Return type: | String |
Retrieves global coordinates for specified or first label.
This is the coordinates at the label after factoring in the global location of the object. Typically all object in Buildes are created around the origin and later moved to the actual location in the design. This routine returns the location after the object has been moved. If the object has not been moved, using this routine is the same as using ‘snap’.
Parameters: |
|
---|---|
Returns: | 2D global coordinates at the specified label. |
Return type: | Error message | Vector |
Check if named component is in the site’s _component_list.
Parameter: | name (String) – Component object’s name. |
---|---|
Returns: | Whether name is the list or not. |
Return type: | Boolean |
Get the material name for object.
Returns: | Material name for object data. |
---|---|
Return type: | String |
Updates coords relative to the point.
When the coordinates that are not at the origin of an object are used to manipulate the object, it is important to reposition all other coordinates so the object can be moved precisely. When manipulating without rotation, the precision move point is subtracted as described below. When a rotation is needed the move point must be added for rotation to be accurate.
To adjust coordinates for line component at ‘A’ so that it can be moved precisely using point at ‘r2’, it must be repositioned at ‘B’ with ‘r2’ at the origin. All other coordinates must then be regenerated relatively.
Parameters: |
|
---|---|
Returns: | Adjusted dictionary of 2D vectors and their labels. |
Return type: | Dict |
Set side on which arc will be created
The letter ‘r’ or ‘l’ can be used but need to store these as ‘right’ or ‘left’ in the object.
Set the color for object data.
Parameter: | col (ColorData) – Color data for object |
---|
Set the material object for data object.
Parameter: | mat (MaterialData) – Material object for object data. |
---|
Retrieves coordinates for specified or first label.
Parameter: | label (String) – Label designating the point for object. |
---|---|
Returns: | 2D coordinates at the specified label. |
Return type: | Error message | Vector |
Return the relative horizontal placement of snap point.
Parameter: | snap – |
---|---|
Returns: | Horizontal position as ‘left’, ‘right’ or ‘none’. |
Return type: | String |
Return the label of the provided snap point.
Parameter: | snap (Vector) – 2D coordinates for snap point |
---|---|
Returns: | label of the provided snap point. |
Return type: | None | String |
Return the relative vertical placement of snap point.
This is different compared to kobldes. In kobldes, if this routine returns “bottom”, it means that the vector is actually highest relative to other coords. The aim in kobldes is to designate the direction of the length of wall. This is confusing so I have changed it here. Now the return means exactly what it says. If “down” is returned, this means that the snap is at the bottom relative to other snaps.
Parameter: | snap – |
---|---|
Returns: | Vertical position as ‘up’, ‘down’ or ‘none’. |
Return type: | String |
Add and/or remove objects in the bound_list
bound_list contains names of all objects that define the boundary of another. For example a space object is bounded by side/wall objects.
Parameters: |
|
---|
Add or replace a coordinate in coords.
Coords are updated when component objects are placed in the design. If new_name is different from old_name, then old_name is replaced by new_name. If new_name is the same as old_name, then old_name is updated by new_name.
Parameters: |
|
---|
Add and/or remove objects in _component_list
_component_list contains names of all objects that are part of an object. For example a table can be part of a space object.
Parameters: |
|
---|
Buildes Manager
Manages the configuration and creation of BuildesData objects.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Coordinates the creation of BuildesData objects.
Update parent edge with edge data.
Parameter: | edge (BuildesData) – Reference to edge object. |
---|
End an object’s active status.
Parameter: | name – |
---|
Establish orientation for object.
Parameter: | data – |
---|
Set all common attributes for all similar objects.
Parameter: | data – |
---|
Make introductory message for data object for diplay in the ui.
Parameter: | data (BuildesData) – Reference to the data object. |
---|
Calculate coordinates for defining the data object.
This is where the snaps are created and stored for manipulating and creating the shape of the data object.
Parameter: | data – |
---|
Make a PythonOCC shape for the data object.
Parameter: | data (BuildesData) – Reference to the data object. |
---|
Prepares parts of the data object for use in creation.
Put here any calculations or other activity that may occur before and after the object has been placed in the design using offset. For example see objects that are remade after being placed using fit_offset or conn_offset.
Parameter: | data (BuildesData) – Object to be prepared. |
---|
Summarized identification message.
Parameter: | obj (BuildesData) – Object for which to create summary message. |
---|---|
Returns: | Formatted text for predetermined cells in the spreadsheet |
Return type: | SpreadSheet |
Summarized outlook message.
Parameter: | obj (BuildesData) – Object for which to create summary message. |
---|---|
Returns: | Formatted text for predetermined cells in the spreadsheet |
Return type: | SpreadSheet |