Coverage for /home/pi/Software/model-railway-signalling/model_railway_signals/editor/objects/__init__.py: 100%
78 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-03-22 13:55 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-03-22 13:55 +0000
1#------------------------------------------------------------------------------------
2# These are the Public API functions for the Objects sub-package
3#------------------------------------------------------------------------------------
4#
5# Externalised API functions intended for use by other editor modules:
6# initialise (canvas,x,y,grid) - Initialise the objects package and set defaults
7# update_canvas(x,y,grid) - update the attributes (on load and re-size)
8# signal(item_id:int) - helper function to find the object Id by Item ID
9# point(item_id:int) - helper function to find the object Id by Item ID
10# section(item_id:int) - helper function to find the object Id by Item ID
11# instrument(item_id:int) - helper function to find the object Id by Item ID
12# line(item_id:int) - helper function to find the object Id by Item ID
13# signal_exists(item_id:int) - Common function to see if a given item exists
14# point_exists(item_id:int) - Common function to see if a given item exists
15# section_exists(item_id:int) - Common function to see if a given item exists
16# instrument_exists(item_id:int) - Common function to see if a given item exists
17# line_exists (item_id:int) - Common function to see if a given item exists
18# track_sensor_exists (item_id:int) - Common function to see if a given item exists
19# update_local_sensors(trigger,timeout,mappings) - configure local track sections
20# mqtt_update_sensors(pub_list, sub_list) - configure MQTT publish/subscribe
21# mqtt_update_signals(pub_list, sub_list) - configure MQTT publish/subscribe
22# mqtt_update_sections(pub_list, sub_list) - configure MQTT publish/subscribe
23# mqtt_update_instruments(pub_list, sub_list) - configure MQTT publish/subscribe
24# save_schematic_state(reset_pointer:bool) - save a snapshot of the schematic objects
25# (reset_pointer=True will clear the undo buffer (deleting the undo history)
26# set_all(new_objects) - Creates a new dictionary of objects (following a load)
27# get_all() - returns the current dictionary of objects (for saving to file)
28# undo() / redo() - Undo and re-do functions as you would expect
29# create_object(obj_type, item_type, item_subtype) - create a new object on the canvas
30# delete_objects([object_IDs]) - Delete the selected objects from the canvas
31# rotate_objects([object_IDs]) - Rotate the selected objects on the canvas
32# move_objects([object_IDs]) - Finalises the move of selected objects
33# copy_objects([object_IDs]) - Copy the selected objects to the clipboard
34# paste_objects() - Paste Clipboard objects onto the canvas (returns list of new IDs)
35# update_object(object_ID, new_object) - update the config of an existing object
36# enable_editing() - Call when 'Edit' Mode is selected (from Schematic Module)
37# disable_editing() - Call when 'Run' Mode is selected (from Schematic Module)
38# reset_objects() - resets all points, signals, instruments and sections to default state
39# get_endstop_offsets(x1,y1,x2,y2)- used by the schematics module to get the offsets
40# for line 'end stops' so they can be moved with the line ends during editing
41#
42# Objects intended to be accessed directly by other editor modules:
43# object_type - Enumeration type for the supported objects
44# schematic_objects - For accessing/editing the configuration of an object
45# signal_index - for iterating through all the signal objects
46# point_index - for iterating through all the point objects
47# instrument_index - for iterating through all the instrument objects
48# section_index - for iterating through all the section objects
49#
50# Makes the following external API calls to other editor modules:
51# run_layout.initialise(canvas) - Initialise the module with the canvas reference on startup
52# run_layout.initialise_layout() - Re-initiallise the state of schematic objects following a change
53# run_layout.enable_editing() - To set "edit mode" for processing schematic object callbacks
54# run_layout.disable_editing() - To set "edit mode" for processing schematic object callbacks
55# run_layout.schematic_callback - the callback reference to use when creating library objects
56#
57#------------------------------------------------------------------------------------
59from .objects import set_all
60from .objects import get_all
61from .objects import undo
62from .objects import redo
63from .objects import create_object
64from .objects import delete_objects
65from .objects import rotate_objects
66from .objects import move_objects
67from .objects import copy_objects
68from .objects import paste_objects
69from .objects import update_object
70from .objects import save_schematic_state
71from .objects import enable_editing
72from .objects import disable_editing
73from .objects import reset_objects
74from .objects_common import initialise
75from .objects_common import update_canvas
76from .objects_common import signal
77from .objects_common import point
78from .objects_common import section
79from .objects_common import instrument
80from .objects_common import line
81from .objects_common import track_sensor
83from .objects_common import section_exists ####################
84from .objects_common import line_exists #######################
86from .objects_common import object_type
87from .objects_common import schematic_objects
88from .objects_common import signal_index
89from .objects_common import point_index
90from .objects_common import section_index
91from .objects_common import instrument_index
92from .objects_common import line_index
93from .objects_common import track_sensor_index
95from .objects_lines import get_endstop_offsets
96from .objects_signals import mqtt_update_signals
97from .objects_sections import mqtt_update_sections
98from .objects_instruments import mqtt_update_instruments
99from .objects_gpio import update_local_gpio_sensors
100from .objects_gpio import mqtt_update_gpio_sensors
102# The following code does nothing apart from suppressing
103# the spurious pyflakes warnings for unused imports
105assert set_all
106assert get_all
107assert undo
108assert redo
109assert create_object
110assert delete_objects
111assert rotate_objects
112assert move_objects
113assert copy_objects
114assert paste_objects
115assert update_object
116assert save_schematic_state
117assert enable_editing
118assert disable_editing
119assert reset_objects
120assert initialise
121assert update_canvas
122assert signal
123assert point
124assert section
125assert instrument
126assert line
127assert track_sensor
128assert section_exists #######################
129assert line_exists ##########################
130assert object_type
131assert get_endstop_offsets
132assert update_local_gpio_sensors
133assert mqtt_update_gpio_sensors
134assert mqtt_update_signals
135assert mqtt_update_sections
136assert mqtt_update_instruments
137assert type(schematic_objects)
138assert type(signal_index)
139assert type(point_index)
140assert type(section_index)
141assert type(instrument_index)
142assert type(line_index)
143assert type(track_sensor_index)
145##########################################################################################################################