Curve

The Curve class represents the graphical connection between elements in a reaction, typically used to draw the edges that link species to a reaction center and to each other. A Curve holds one or more Curve Segments, which define its actual path (straight lines or Bezier curves), and an optional Arrowhead that indicates the direction or type of connection.

Each Reaction can have multiple Curves — for example, to draw edges from reactants to the reaction center and then to products.

After loading a model and retrieving a Reaction or Species, you can:

  • Retrieve all Curves associated with a Reaction using get_curves_list().

  • Retrieve all Curves connected to a Species using get_curves_list().

Example:

import sbmlnetwork as sn

net = sn.load("my_model.xml")

# Get species and reaction ids
species_id = net.get_species_ids()[0]
reaction_id = net.get_reaction_ids()[0]

# All Curves for a Reaction
for curve in net.get_reaction(reaction_id).get_curves_list():
   print(len(curve.get_segments()))

# All Curves in a Reaction that connect to a specific Species
for curve in net.get_reaction(reaction_id).get_curves_list(species_id):
   print(len(curve.get_segments()))

# All Curves connected to a Species
for curve in net.get_species(species_id).get_curves_list():
   print(len(curve.get_segments()))

# All Curves connected to a Species, filtered by Reaction
for curve in net.get_species(species_id).get_curves_list(reaction_id):
   print(len(curve.get_segments()))

A Curve contains all the details needed to draw its path and arrowhead. The diagram below shows how a Curve contains multiple Curve Segments and may include an optional Arrowhead.

digraph curve_hierarchy {
  rankdir=TB;
  node [shape=record, style=rounded, fontname=Helvetica];

  Curve [
    label=< <font color="#3366cc">Curve</font> >,
    URL="curve.html",
    tooltip="Base Curve class"
  ];

  CurveSegments [
    label=<
      <table border="0" cellborder="0" cellpadding="5">
        <tr><td><font color="#3366cc">Curve Segments</font></td></tr>
      </table>
    >,
    shape=record,
    style=rounded,
    URL="curve_segment.html",
    tooltip="Line or Bezier segments"
  ];

  Arrowhead [
    label=<
      <table border="0" cellborder="0" cellpadding="5">
        <tr><td><font color="#3366cc">Arrowhead</font></td></tr>
      </table>
    >,
    shape=record,
    style=rounded,
    URL="arrow_head.html",
    tooltip="Optional arrowhead"
  ];

  Curve -> CurveSegments;
  Curve -> Arrowhead;
}

Core Methods

Identification

get_reaction()

Return the parent Reaction object for this Curve.

Return type:

Reaction

get_species()

Return the Species this Curve connects to, or None.

Return type:

Species or None

get_role()

Return the role of the species reference (e.g., “substrate”, “product”, “modifier”).

Return type:

str

Path Geometry

get_start()

Return the absolute (x, y) coordinates of the Curve’s first segment start point.

Return type:

tuple[float, float]

set_start(start)

Move the first segment start (and its first control point) to the given (x, y).

Parameters:

start – New start coordinates.

get_end()

Return the absolute (x, y) coordinates of the Curve’s last segment end point.

Return type:

tuple[float, float]

set_end(end)

Move the last segment end (and its second control point) to the given (x, y).

Parameters:

end – New end coordinates.

get_start_slope()

Compute and return the angle (in radians) of the tangent at the start of the Curve.

Return type:

float

get_end_slope()

Compute and return the angle (in radians) of the tangent at the end of the Curve.

Return type:

float

Segments Management

add_segment(start, end, control_point_1=None, control_point_2=None)

Append a cubic Bézier segment to the Curve with specified endpoints and optional control points.

Parameters:
  • start – Segment start (x, y).

  • end – Segment end (x, y).

  • control_point_1 – First control point (x, y) (defaults to start).

  • control_point_2 – Second control point (x, y) (defaults to end).

remove_segment(segment)

Remove a segment by index or CurveSegment object.

Parameters:

segment – Integer index or CurveSegment instance.

get_segment(curve_segment_index=0)

Return the segment at the given index.

Parameters:

curve_segment_index – Zero-based index.

Return type:

CurveSegment or None

get_segments_list()

Return a list of all CurveSegment objects for this Curve.

Return type:

CurveSegmentList

get_segments()

Alias for get_segments_list().

property segments

Shorthand for get_segments_list().

Movement

move_by(delta)

Translate the entire Curve path by the given offset.

Parameters:

delta(dx, dy) in diagram units.

move_start_to(position)

Move the start of the Curve to an absolute position, adjusting control points.

Parameters:

position – New start (x, y).

move_start_by(delta)

Move the start of the Curve by the given offset.

Parameters:

delta(dx, dy).

move_end_to(position, adjust_end_point_for_uni_uni_reaction=False)

Move the end of the Curve to an absolute position; for simple uni–uni reactions, optionally adjust both curves symmetrically.

Parameters:
  • position – New end (x, y).

  • adjust_end_point_for_uni_uni_reactionTrue to auto-adjust paired curve.

move_end_by(delta, adjust_end_point_for_uni_uni_reaction=False)

Move the end of the Curve by the given offset; see move_end_to().

Parameters:
  • delta(dx, dy).

  • adjust_end_point_for_uni_uni_reaction – See move_end_to().

Styling

get_color()

Return the curve line colour as a hex string or RGB tuple.

Return type:

str or tuple[int, int, int]

set_color(color)

Set the curve line colour.

Parameters:

color – Hex string (e.g. “#rrggbb”) or RGB tuple (r, g, b).

get_thickness()

Return the line width of the Curve.

Return type:

float

set_thickness(thickness)

Set the line width of the Curve.

Parameters:

thickness – Line width in diagram units.

Arrowhead

get_arrow_head()

Return the attached ArrowHead object, or None.

Return type:

ArrowHead or None

get_arrow_head_relative_position()

Return the arrowhead position relative to the Curve.

Return type:

tuple[float, float]

set_arrow_head_relative_position(relative_position)

Move the arrowhead to the given relative (dx, dy).

Parameters:

relative_position – Offset from Curve path.

get_arrow_head_size()

Return the width and height of the arrowhead.

Return type:

tuple[float, float]

set_arrow_head_size(size)

Set the arrowhead dimensions.

Parameters:

size(width, height) in diagram units.

get_arrow_head_shapes()

Return the shape type(s) of the arrowhead.

Return type:

str

set_arrow_head_shapes(shape)

Set the arrowhead shape (e.g., “triangle”, “diamond”).

Parameters:

shape – Shape name.

get_arrow_head_border_color()

Return the arrowhead border colour.

Return type:

str or tuple[int, int, int]

set_arrow_head_border_color(border_color)

Set the arrowhead border colour.

Parameters:

border_color – Hex string or RGB tuple.

get_arrow_head_border_thickness()

Return the arrowhead border width.

Return type:

float

set_arrow_head_border_thickness(thickness)

Set the arrowhead border width.

Parameters:

thickness – Line width in diagram units.

get_arrow_head_fill_color()

Return the arrowhead fill colour.

Return type:

str or tuple[int, int, int]

set_arrow_head_fill_color(fill_color)

Set the arrowhead fill colour.

Parameters:

fill_color – Hex string, RGB tuple, or list.

Visibility

show()

Make this Curve visible in the diagram.

hide()

Make this Curve invisible in the diagram.

is_hidden()

Return whether this Curve is currently hidden.

Return type:

bool

Information

property info

Human-readable summary of glyph state for debugging.

Return type:

str

get_info()

Generate the info string.

Example workflow

Below is a script demonstrating how to discover, inspect, and modify Curves:

import sbmlnetwork as sn

 # Load the SBML model
 net = sn.load("my_model.xml")

 # Select a reaction and its first curve
 rxn = net.get_reactions_list()[0]
 curve = rxn.get_curves_list()[0]

 # Inspect basic properties
 print("Role      :", curve.role)
 print("Color     :", curve.get_color())
 print("Thickness :", curve.thickness)
 print("Start     :", curve.start, "Slope:", curve.start_slope)

 # Change styling
 curve.set_color("#cc6633")
 curve.set_thickness(3.0)

 # Add a new Bézier segment
 curve.add_segment((50, 50), (100, 100), (60, 60), (90, 90))

 # Move the curve
 curve.move_by((10, -20))

 # Toggle visibility
 curve.hide()
 curve.show()

 # Debug summary
 print(curve.info)