drawing_tools.view.annotations.aircraft package#

Submodules#

drawing_tools.view.annotations.aircraft.orientation_indicators module#

Aircraft orientation indicators – the arrow saying where the aircraft’s front is.

An orientation indicator is what a view carries so a reader can position the depicted part on the aircraft: an arrow drawn together with a bilingual caption, the French line above the English one (“AVANT APPAREIL” / “FRONT AIRCRAFT”). Both halves are needed – the caption carries the meaning, the arrow is what makes it a positioning element rather than a plain note.

CATIA exports one as a CompositeEntity whose geometries draw the arrow strokes and whose entities hold a single bare TypeNote carrying the caption, one text primitive per language.

CAPTION_LINE_HEIGHT is the vertical spacing between the overlay caption lines, in drawing units. plot_data draws text at a fixed screen size while line_height is in drawing units, so a value calibrated on rendered sheets is what keeps a three-line caption from collapsing onto itself.

Detection lives in drawing_tools.view.annotations.aircraft.view_orientation_detector.

Related ticket: DERY-3759 (aircraft positioning rule, structural elements helping positioning).

class drawing_tools.view.annotations.aircraft.orientation_indicators.OrientationIndicator(source_entity: Entity, arrow_edges: list[Edge], caption_symbol: TextSearchable, text_by_language: dict[str, str])#

Bases: object

Wrapper for the arrow and the bilingual caption that say where the aircraft’s front is.

The caption is what carries the meaning – it is read per language, so a check can state what the view says in French and in English – and the arrow is what makes the caption a positioning element rather than a plain note.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>#
__init__(source_entity: Entity, arrow_edges: list[Edge], caption_symbol: TextSearchable, text_by_language: dict[str, str]) None#

Initialize an indicator from the entity it was detected on.

Parameters:
  • source_entity – The entity holding the arrow strokes and the caption – a CompositeEntity for the only export shape known so far, hence the loose type: a future detection branch may build indicators from something else.

  • arrow_edges – The graphic edges of that entity, as exported: the arrow strokes. The reference drawings duplicate some of them (10 edges for 8 distinct strokes), which the overlay redraw tolerates.

  • caption_symbol – The nested text entity carrying the bilingual caption.

  • text_by_language – Language name (as named by its LanguageConfig) mapped to the caption line that matched that language, e.g. {"french": "AVANT APPAREIL", "english": "FRONT AIRCRAFT"}.

__repr__() str#

Return a concise representation with the caption and the languages it was read in.

property text_content: str#

The whole caption as exported, every language line joined.

property languages: list[str]#

Names of the languages the caption was recognized in, alphabetically.

text_for_language(language_name: str) str | None#

Return the caption line recognized for one language, None when that language matched none.

Parameters:

language_name – The name of a LanguageConfig (“french”, “english”…).

Returns:

The matching caption line, or None.

property overlay_lines: list[str]#

what the element is, then what it says per language.

The caption drawn on the sheet and tooltip both read these lines, so the two can never diverge.

Type:

The overlay caption lines

property tooltip: str#

overlay_lines joined, as shown on hover.

Type:

The overlay tooltip

overlay_primitives(color: Color | None = None) list#

Build the diagnostic overlay of this indicator, every part in the same color.

Draws a rectangle around the whole element carrying tooltip, the arrow strokes redrawn in the overlay color – so the arrow reads at a glance among the view geometry – and the overlay_lines caption, so what the element says is readable without hovering.

Parameters:

color – Overlay color. Defaults to blue; callers rendering several indicators pass one color per indicator from a palette.

Returns:

List of plot_data primitives, empty when the element has no bounding rectangle.

arrow_overlay_primitives(color: Color | None = None) list#

Redraw the arrow strokes in the overlay color.

Parameters:

color – Overlay color (defaults to blue).

Returns:

List of plot_data primitives, empty when the element draws no edge.

drawing_tools.view.annotations.aircraft.view_orientation_detector module#

View-level detection of aircraft orientation indicators.

Recognizes the arrow a view carries to say where the aircraft’s front is: a bilingual caption matched against the patterns of the language configurations, drawn together with an arrow. Because the caption is read per language, the detected element states what the view says in French and in English. The detected element is OrientationIndicator.

COMPOSITE_OPTIONS selects the candidates: the first-level CompositeEntity annotations of the view, which is what CATIA exports one indicator as. Nesting is not searched, the reference drawings never nesting one in another annotation.

Related ticket: DERY-3759 (aircraft positioning rule, structural elements helping positioning).

class drawing_tools.view.annotations.aircraft.view_orientation_detector.OrientationDetectionConfig(min_arrow_edge_count: int = 2)#

Bases: object

Configuration for aircraft orientation indicator detection.

Parameters:

min_arrow_edge_count – Minimum number of graphic edges the entity must draw for its caption to count as an orientation indicator rather than a plain note. Two is the lowest an arrow head can be drawn with. Measured on the reference drawings: every one of the 16 captions is drawn with 10 edges (8 distinct strokes – a chevron head, a two-line shaft, two connectors and a tail feather), so this bound rejects none of them; what it rejects is a caption with no arrow at all, which the rule does not accept as a positioning element.

min_arrow_edge_count: int = 2#
__init__(min_arrow_edge_count: int = 2) None#
class drawing_tools.view.annotations.aircraft.view_orientation_detector.ViewOrientationDetector(view: View, language_configs: list[LanguageConfig] | None = None, config: OrientationDetectionConfig | None = None)#

Bases: object

Detect the aircraft orientation indicators of a view.

Every CompositeEntity of the view whose nested caption matches the orientation patterns of at least one language configuration, and which draws an arrow, becomes an indicator. The caption lines that matched are kept per language, so a check can report what the view says in French and in English.

Usage:

detector = ViewOrientationDetector(view)
indicators = detector.indicators   # cached_property
__init__(view: View, language_configs: list[LanguageConfig] | None = None, config: OrientationDetectionConfig | None = None) None#

Initialize the detector with a view.

Parameters:
  • view – A dessia_drawing View object to analyze.

  • language_configs – The language configurations whose aircraft_orientation_patterns the caption is matched against, and whose name keys the detected texts. Defaults to the French and English defaults, so a view with no language configuration still detects rather than failing – unlike the view title, this detection reads one fixed caption per language, not a parsed title.

  • config – Detection parameters. Uses defaults if not provided.

property indicators: list[OrientationIndicator]#

All detected aircraft orientation indicators (computed once on first access).

detect_all() list[OrientationIndicator]#

Detect this view’s aircraft orientation indicators.

Returns:

List of detected OrientationIndicator instances.

drawing_tools.view.annotations.aircraft.reference_lines module#

Aircraft reference lines – the coordinate grid an assembly is positioned against.

An aircraft reference line is one of the dash-dot lines an assembly drawing carries to state where the part sits in the aircraft frame. Each line is drawn along a drawing axis and carries a label naming the aircraft axis and the value it stands for: X 6815, Y-670, Z 1565.8.

Two conventions hold on every drawing of the corpus and are what the detection keys on:

  • the label reads along its own line, so a horizontal line carries a horizontal label and a vertical line carries a label rotated by 90 degrees;

  • the label sits against its line, within about one font size of it.

DEFAULT_REFERENCE_LABEL_PATTERN is the label grammar: an uppercase axis letter, then a signed number, matched case-sensitively on purpose. Uppercase is what separates a reference label (X 6815) from a quantity (x10); the axis letter is uppercase on every drawing of the corpus. Surrounding whitespace is absorbed by the pattern itself, so the raw text of a drawing can be matched without being stripped first. Its two capture groups are the axis letter and the value.

Related tickets: DERY-3760 (the coordinate grid itself) and DERY-3761 (the text bound to each dash-dot line).

class drawing_tools.view.annotations.aircraft.reference_lines.ReferenceLineDetectionConfig(dash_dot_curve_type: str = 'DOTTED_DASHED', orientation_tolerance: float = 0.09, max_label_gap_in_font_sizes: float = 1.0, max_label_overhang_in_font_sizes: float = 1.0, default_font_size: float = 5.0, label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$'))#

Bases: object

Configuration for aircraft reference line detection.

Every distance is expressed in font sizes of the label being tested, so the detection behaves the same on an A4 detail and on an A0 assembly.

Parameters:
  • dash_dot_curve_typecurve_type an entity must declare to be a reference line candidate.

  • orientation_tolerance – Aperture, as a sine, within which a direction counts as horizontal or vertical. Applied to the lines and to the labels alike; anything further off from both axes is oblique and takes no part. Defaults to the aperture of the helper it is passed to, so the two never disagree.

  • max_label_gap_in_font_sizes – Maximum distance between a label and its line, measured perpendicular to the line.

  • max_label_overhang_in_font_sizes – How far past a line’s end a label may sit and still be considered to run along it.

  • default_font_size – Font size assumed when a label declares none.

  • label_pattern – Compiled regex a label must match, capturing the axis letter and the value.

dash_dot_curve_type: str = 'DOTTED_DASHED'#
orientation_tolerance: float = 0.09#
max_label_gap_in_font_sizes: float = 1.0#
max_label_overhang_in_font_sizes: float = 1.0#
default_font_size: float = 5.0#
label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$')#
__init__(dash_dot_curve_type: str = 'DOTTED_DASHED', orientation_tolerance: float = 0.09, max_label_gap_in_font_sizes: float = 1.0, max_label_overhang_in_font_sizes: float = 1.0, default_font_size: float = 5.0, label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$')) None#
drawing_tools.view.annotations.aircraft.reference_lines.parse_reference_label(text_content: str, pattern: Pattern | None = None) tuple[str, float] | None#

Read the aircraft axis and the value out of a reference label.

Parameters:
  • text_content – Raw label content, e.g. "Y -130" or "Z+2400".

  • pattern – Compiled pattern capturing the axis letter and the value. Defaults to DEFAULT_REFERENCE_LABEL_PATTERN.

Returns:

The axis letter and the value, or None when the text is not a reference label.

class drawing_tools.view.annotations.aircraft.reference_lines.ReferenceLine(axis: str, value: float, orientation: Literal['horizontal', 'vertical'], source_entity: Entity, label_entity: Entity, name: str = '')#

Bases: DessiaObject

A dash-dot line positioning the drawn assembly in the aircraft frame.

Pairs the drawn line with the label that gives it its meaning: without the label a dash-dot line is just an axis, so the label is what makes the element.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>#
__init__(axis: str, value: float, orientation: Literal['horizontal', 'vertical'], source_entity: Entity, label_entity: Entity, name: str = '')#

Initialize an ReferenceLine.

Parameters:
  • axis – Aircraft axis the line stands for, "X", "Y" or "Z".

  • value – Value along that axis, as read from the label.

  • orientation – Orientation of the line on the sheet, HORIZONTAL or VERTICAL.

  • source_entity – The dash-dot entity drawn on the sheet.

  • label_entity – The text entity naming the axis and the value.

  • name – Optional display name.

__repr__() str#

Return a concise representation with the axis, the value and the orientation.

property bounding_rectangle: BoundingRectangle | None#

The rectangle covering both the drawn line and its label.

overlay_primitives(color: str | None = None) list[PlotDataObject]#

Build the diagnostic overlay primitives (rectangle plus label lines).

Parameters:

color – Override color (defaults to blue).

Returns:

Overlay primitives, empty when the element has no bounding rectangle.

plot_data_primitives(color: str | None = None) list[PlotDataObject]#

Get the plot_data primitives for a standalone visualization of this reference line.

Parameters:

color – Override color for the overlay (defaults to blue).

Returns:

The source entities’ own primitives followed by the overlay.

plot_data(color: str | None = None) None#

Visualize this reference line standalone.

Parameters:

color – Override color for the overlay (defaults to blue).

drawing_tools.view.annotations.aircraft.view_reference_line_detector module#

Detection of aircraft reference lines in a view (DERY-3760, DERY-3761).

A reference line is a dash-dot line that a reference label claims. The label does the claiming: its box, inflated by the configured tolerances, is the zone within which a line drawn along the same orientation is its line. See reference_lines for what the element is and which drawing conventions the tolerances come from.

class drawing_tools.view.annotations.aircraft.view_reference_line_detector.ViewReferenceLineDetector(view: View, config: ReferenceLineDetectionConfig | None = None)#

Bases: object

Detect the aircraft reference lines of a view.

Usage:

detector = ViewReferenceLineDetector(view)
reference_lines = detector.reference_lines
__init__(view: View, config: ReferenceLineDetectionConfig | None = None) None#

Initialize the detector with a view.

Parameters:
  • view – A dessia_drawing View to analyze.

  • config – Detection parameters. Uses defaults if not provided.

property reference_lines: list[ReferenceLine]#

All detected aircraft reference lines (computed once on first access).

detect_all() list[ReferenceLine]#

Detect every aircraft reference line of the view.

Returns:

One ReferenceLine per dash-dot line claimed by a label.

Module contents#

What a drawing carries to position the drawn assembly in the aircraft.

Home of the elements serving the aircraft positioning rule (structural elements helping positioning): the reference lines of the coordinate grid, each a dash-dot line claimed by a label naming an aircraft axis and a value, and the orientation indicators, each an arrow drawn with a bilingual caption naming the aircraft’s front.

Grouped by subject rather than by drawn primitive, unlike symbol/electrical: these elements share the question they answer, not the shape they take on the sheet.

class drawing_tools.view.annotations.aircraft.OrientationDetectionConfig(min_arrow_edge_count: int = 2)#

Bases: object

Configuration for aircraft orientation indicator detection.

Parameters:

min_arrow_edge_count – Minimum number of graphic edges the entity must draw for its caption to count as an orientation indicator rather than a plain note. Two is the lowest an arrow head can be drawn with. Measured on the reference drawings: every one of the 16 captions is drawn with 10 edges (8 distinct strokes – a chevron head, a two-line shaft, two connectors and a tail feather), so this bound rejects none of them; what it rejects is a caption with no arrow at all, which the rule does not accept as a positioning element.

min_arrow_edge_count: int = 2#
__init__(min_arrow_edge_count: int = 2) None#
class drawing_tools.view.annotations.aircraft.OrientationIndicator(source_entity: Entity, arrow_edges: list[Edge], caption_symbol: TextSearchable, text_by_language: dict[str, str])#

Bases: object

Wrapper for the arrow and the bilingual caption that say where the aircraft’s front is.

The caption is what carries the meaning – it is read per language, so a check can state what the view says in French and in English – and the arrow is what makes the caption a positioning element rather than a plain note.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>#
__init__(source_entity: Entity, arrow_edges: list[Edge], caption_symbol: TextSearchable, text_by_language: dict[str, str]) None#

Initialize an indicator from the entity it was detected on.

Parameters:
  • source_entity – The entity holding the arrow strokes and the caption – a CompositeEntity for the only export shape known so far, hence the loose type: a future detection branch may build indicators from something else.

  • arrow_edges – The graphic edges of that entity, as exported: the arrow strokes. The reference drawings duplicate some of them (10 edges for 8 distinct strokes), which the overlay redraw tolerates.

  • caption_symbol – The nested text entity carrying the bilingual caption.

  • text_by_language – Language name (as named by its LanguageConfig) mapped to the caption line that matched that language, e.g. {"french": "AVANT APPAREIL", "english": "FRONT AIRCRAFT"}.

__repr__() str#

Return a concise representation with the caption and the languages it was read in.

property text_content: str#

The whole caption as exported, every language line joined.

property languages: list[str]#

Names of the languages the caption was recognized in, alphabetically.

text_for_language(language_name: str) str | None#

Return the caption line recognized for one language, None when that language matched none.

Parameters:

language_name – The name of a LanguageConfig (“french”, “english”…).

Returns:

The matching caption line, or None.

property overlay_lines: list[str]#

what the element is, then what it says per language.

The caption drawn on the sheet and tooltip both read these lines, so the two can never diverge.

Type:

The overlay caption lines

property tooltip: str#

overlay_lines joined, as shown on hover.

Type:

The overlay tooltip

overlay_primitives(color: Color | None = None) list#

Build the diagnostic overlay of this indicator, every part in the same color.

Draws a rectangle around the whole element carrying tooltip, the arrow strokes redrawn in the overlay color – so the arrow reads at a glance among the view geometry – and the overlay_lines caption, so what the element says is readable without hovering.

Parameters:

color – Overlay color. Defaults to blue; callers rendering several indicators pass one color per indicator from a palette.

Returns:

List of plot_data primitives, empty when the element has no bounding rectangle.

arrow_overlay_primitives(color: Color | None = None) list#

Redraw the arrow strokes in the overlay color.

Parameters:

color – Overlay color (defaults to blue).

Returns:

List of plot_data primitives, empty when the element draws no edge.

class drawing_tools.view.annotations.aircraft.ReferenceLine(axis: str, value: float, orientation: Literal['horizontal', 'vertical'], source_entity: Entity, label_entity: Entity, name: str = '')#

Bases: DessiaObject

A dash-dot line positioning the drawn assembly in the aircraft frame.

Pairs the drawn line with the label that gives it its meaning: without the label a dash-dot line is just an axis, so the label is what makes the element.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>#
__init__(axis: str, value: float, orientation: Literal['horizontal', 'vertical'], source_entity: Entity, label_entity: Entity, name: str = '')#

Initialize an ReferenceLine.

Parameters:
  • axis – Aircraft axis the line stands for, "X", "Y" or "Z".

  • value – Value along that axis, as read from the label.

  • orientation – Orientation of the line on the sheet, HORIZONTAL or VERTICAL.

  • source_entity – The dash-dot entity drawn on the sheet.

  • label_entity – The text entity naming the axis and the value.

  • name – Optional display name.

__repr__() str#

Return a concise representation with the axis, the value and the orientation.

property bounding_rectangle: BoundingRectangle | None#

The rectangle covering both the drawn line and its label.

overlay_primitives(color: str | None = None) list[PlotDataObject]#

Build the diagnostic overlay primitives (rectangle plus label lines).

Parameters:

color – Override color (defaults to blue).

Returns:

Overlay primitives, empty when the element has no bounding rectangle.

plot_data_primitives(color: str | None = None) list[PlotDataObject]#

Get the plot_data primitives for a standalone visualization of this reference line.

Parameters:

color – Override color for the overlay (defaults to blue).

Returns:

The source entities’ own primitives followed by the overlay.

plot_data(color: str | None = None) None#

Visualize this reference line standalone.

Parameters:

color – Override color for the overlay (defaults to blue).

class drawing_tools.view.annotations.aircraft.ReferenceLineDetectionConfig(dash_dot_curve_type: str = 'DOTTED_DASHED', orientation_tolerance: float = 0.09, max_label_gap_in_font_sizes: float = 1.0, max_label_overhang_in_font_sizes: float = 1.0, default_font_size: float = 5.0, label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$'))#

Bases: object

Configuration for aircraft reference line detection.

Every distance is expressed in font sizes of the label being tested, so the detection behaves the same on an A4 detail and on an A0 assembly.

Parameters:
  • dash_dot_curve_typecurve_type an entity must declare to be a reference line candidate.

  • orientation_tolerance – Aperture, as a sine, within which a direction counts as horizontal or vertical. Applied to the lines and to the labels alike; anything further off from both axes is oblique and takes no part. Defaults to the aperture of the helper it is passed to, so the two never disagree.

  • max_label_gap_in_font_sizes – Maximum distance between a label and its line, measured perpendicular to the line.

  • max_label_overhang_in_font_sizes – How far past a line’s end a label may sit and still be considered to run along it.

  • default_font_size – Font size assumed when a label declares none.

  • label_pattern – Compiled regex a label must match, capturing the axis letter and the value.

dash_dot_curve_type: str = 'DOTTED_DASHED'#
orientation_tolerance: float = 0.09#
max_label_gap_in_font_sizes: float = 1.0#
max_label_overhang_in_font_sizes: float = 1.0#
default_font_size: float = 5.0#
label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$')#
__init__(dash_dot_curve_type: str = 'DOTTED_DASHED', orientation_tolerance: float = 0.09, max_label_gap_in_font_sizes: float = 1.0, max_label_overhang_in_font_sizes: float = 1.0, default_font_size: float = 5.0, label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$')) None#
class drawing_tools.view.annotations.aircraft.ViewOrientationDetector(view: View, language_configs: list[LanguageConfig] | None = None, config: OrientationDetectionConfig | None = None)#

Bases: object

Detect the aircraft orientation indicators of a view.

Every CompositeEntity of the view whose nested caption matches the orientation patterns of at least one language configuration, and which draws an arrow, becomes an indicator. The caption lines that matched are kept per language, so a check can report what the view says in French and in English.

Usage:

detector = ViewOrientationDetector(view)
indicators = detector.indicators   # cached_property
__init__(view: View, language_configs: list[LanguageConfig] | None = None, config: OrientationDetectionConfig | None = None) None#

Initialize the detector with a view.

Parameters:
  • view – A dessia_drawing View object to analyze.

  • language_configs – The language configurations whose aircraft_orientation_patterns the caption is matched against, and whose name keys the detected texts. Defaults to the French and English defaults, so a view with no language configuration still detects rather than failing – unlike the view title, this detection reads one fixed caption per language, not a parsed title.

  • config – Detection parameters. Uses defaults if not provided.

property indicators: list[OrientationIndicator]#

All detected aircraft orientation indicators (computed once on first access).

detect_all() list[OrientationIndicator]#

Detect this view’s aircraft orientation indicators.

Returns:

List of detected OrientationIndicator instances.

class drawing_tools.view.annotations.aircraft.ViewReferenceLineDetector(view: View, config: ReferenceLineDetectionConfig | None = None)#

Bases: object

Detect the aircraft reference lines of a view.

Usage:

detector = ViewReferenceLineDetector(view)
reference_lines = detector.reference_lines
__init__(view: View, config: ReferenceLineDetectionConfig | None = None) None#

Initialize the detector with a view.

Parameters:
  • view – A dessia_drawing View to analyze.

  • config – Detection parameters. Uses defaults if not provided.

property reference_lines: list[ReferenceLine]#

All detected aircraft reference lines (computed once on first access).

detect_all() list[ReferenceLine]#

Detect every aircraft reference line of the view.

Returns:

One ReferenceLine per dash-dot line claimed by a label.