Class CairoDrawer#

Inheritance Relationships#

Base Type#

Class Documentation#

class CairoDrawer : public Drawer#

SVG surface drawer for MooViE.

CairoDrawer is a wrapper class for MooViE’s basic drawing abilities which are realized using Cairo.

Authors

beyss, stratmann

Date

05.07.2017

Public Functions

CairoDrawer(const std::string &fpath, int width, int height, std::size_t num_inputs_)#
inline virtual ~CairoDrawer()#
virtual void change_surface(const std::string &fpath, int width, int height, std::size_t num_inputs_)#

Alters the surface of this Drawer in number of inputs, width, height and storage path. All unsafed changes will be stored and all kept resources freed correctly.

Parameters:
  • fpath – a string containing an valid existing or accessible not existing path

  • width – an integer between 0 and MAX_INT

  • height – an integer between 0 and MAX_INT

  • num_inputs – the number of inputs

virtual void draw_output_grid(const OutputGrid &grid)#

Draws a OutputGrid using its radius and angles. For thin or thick lines the properties given by the Configuration instance are used.

Parameters:

grid – the OutputGrid to draw

virtual void draw_input_axis(const InputAxis &axis)#

Draws a InputAxis using its radius and angles. For thin or thick lines the properties given by the Configuration instance are used.

Parameters:

axis – the InputAxis to draw

virtual void draw_io_vector(const IOVector &iov)#

Draws a IOVector using its coordinates.

Parameters:

elem – the IOVector to draw

virtual void finish()#

Save the Drawer’s result to the given file.

Public Static Attributes

static const double RADIAL_TEXT_FACTOR = 0.3#
static const double COORDGRID_ADJUSTMENT = 0.5#
static const double COORDPOINT_ANGLE = 0.005#
static const double END_RADIUS_MAJOR_FACTOR = 0.25#
static const double END_RADIUS_MINOR_FACTOR = 0.125#
static const double RADIUS_TICK_LABEL_FACTOR = 0.75#
static const double IO_LINE_WIDTH = 0.1#
static const double CONNECTOR_ARC_RATIO = 0.6#
static const double CONNECTOR_ARROW_HEIGHT = 3#
static const double CONNECTOR_ARROW_ANGLE = 0.012#
static const double INPUT_RADIUS_DELTA = 2.5#
static const double CONNECTOR_DELTA = 10#
static const double TEXT_DELTA = 0.01#
static const double ANGLE_DELTA_SMALL = 0.001#
static const double ANGLE_DELTA_MEDIUM = 0.01#
static const double ANGLE_DELTA_LARGE#
static const double RADIUS_DELTA = 10#
static const double OUTPUT_EXTREME_RADIUS_DELTA = 2#
static const double OUTPUT_LABEL_LINE_END_DELTA = 3#
static const double OUTPUT_LABEL_FONT_FACTOR = 0.1#

Protected Functions

virtual void set_surface(const std::string &fpath, int width, int height)#

Alters the surface of this Drawer in with, height and storage path.

Parameters:
  • fpath – a string containing an valid or accessible path

  • width – an integer between 0 and MAX_INT

  • height – an integer between 0 and MAX_INT

virtual void draw_histogram(const InputAxis::Histogram &histogram, double radius, const Angle &start, const Angle &end)#

Draws a Histogram from the given radius, between begin and end Angle. For the histogram height, thin or thick lines the properties given by the Configuration instance are used.

Parameters:
  • histogram – the Histogram to draw

  • radius – the start radius of the Histogram

  • start – the starting angle of the Histogram

  • end – the end angle of the Histogram

virtual void draw_link(const Polar &origin1, const Polar &origin2, const Polar &target1, const Polar &target2, const DrawerProperties<> &prop)#

Draws a bold line between the lines origin1-origin2 and target1-target2. This is realized by drawing Bezier curves from origin1 to target1 and from origin2 to target2 and filling the so created surface.

Parameters:
  • origin1 – first origin coordinate

  • origin2 – second origin coordinate

  • target1 – first target coordinate

  • target2 – second target coordinate

  • propDrawerProperties for the link

virtual void draw_connector(const Polar &from, const Polar &to, const DrawerProperties<> &prop)#

Draws a connection between to given polar coordinates. The connection is a bezier curve which is controlled by automatically generated control points.

Parameters:
virtual void draw_segment_axis(double inner_radius, double thickness, const Angle &start, const Angle &end, const DrawerProperties<std::array<Color, 10>> &prop, Direction dir)#

Draws a circle segment which is itself divided in colored segments.

Parameters:
  • inner_radius – inner radius of the split axis

  • thickness – width of the split axis

  • begin – angle of the segments begin

  • end – angle of the segments end

  • prop – color

  • dir – direction of the split axis’ colors

virtual void draw_output_label(const Label &output_label, double radius_label, double radius_output, const Angle &begin, const Angle &end)#

Draws the given Label output_label with the radius radius_label and a descriptive path that connects the output label with the associated output. The path consists of an arc segment and a line.

Parameters:
  • output_label – the output label to draw

  • radius_label – the radius of the output label

  • radius_output – the radius of the associated output

  • begin – the angle at which the output ends

  • end – the angle at which the arc ends

virtual void draw_arrow(const Polar &start, const DrawerProperties<> &prop)#

Draws a arrow head from a given start pointing.

Parameters:
  • start – the start of the arrow head

  • propDrawerProperties for the arrow head

virtual void draw_ring_segment(double radius, double thickness, const Angle &begin, const Angle &end, const DrawerProperties<> &prop, Direction dir)#

Draws a filled ring segment around the center of its coordinate system between the two given Angles and with the given radius.

Parameters:
  • radius – the radius

  • thickness – the thinkness of the edge segment

  • begin – the begin Angle

  • end – the end Angle

  • prop – the CairoDrawer properties

  • dir – the direction

virtual void draw_connector_segment(double begin_radius, double begin_angle, double end_radius, double end_angle, const DrawerProperties<> &prop)#

Draws a Bezier curve from Polar(start_radius, start_angle) to Polar(end_radius, end_angle) which approximately behaves like Archimedean spiral. If the smaller difference angle between start_angle and end_angle is bigger than PI, the spiral will be approximated by two Bezier curves.

Parameters:
  • start_radius – the radius of the starting point

  • start_angle – the angle of the starting point

  • end_radius – the radius of the end point

  • end_angle – the angle of the end point

  • prop – the DrawerProperties for the segment

virtual void draw_line(const Polar &from, const Polar &to, const DrawerProperties<> &prop)#

Draws a line from a given starting vertice to a given end vertice.

Parameters:
  • from – the starting coordinates

  • to – the end coordinates

  • prop – the DrawerProperties to use

virtual void draw_arc(double inner_radius, const Angle &start, const Angle &end, Direction dir)#

Draws a simple edge segment around the center of its coordinate system between the two given Angles and with the given radius.

Parameters:
  • inner_radius – the inner radius

  • start – the start Angle

  • end – the end Angle

  • dir – the direction

virtual void draw_coord_point(const Polar &coord, const Angle &width, double height, const DrawerProperties<> &prop)#

Draws a coordinate point with given height and with.

Parameters:
  • coord – the polar coordinate to draw

  • width – the width

  • height – the height

  • prop – the DrawerProperties

virtual void draw_text_parallel(const Label &label, const Polar &start, const TextAlignment &alignment = TextAlignment::CENTERED)#

Draws the given label with the same angle like the given coordinate.

Parameters:
  • label – the label to draw

  • start – the coordinate to adjust to

virtual void draw_text_orthogonal(const Label &label, const Polar &start, const TextAlignment &alignment = TextAlignment::CENTERED)#

Draws the given label orthogonal to the angle of the given coordinate’s angle.

Parameters:
  • label – the label to draw

  • start – the coordinate to adjust to

void set_font_face(const Label &label)#

set font style

Sets the font face according to the TextProperties of the given Label.

Parameters:

label – the Label whose properties to set

Cairo::TextExtents get_text_extents(const Label &label) const#
inline Angle get_cairo_angle(const Angle &angle)#

Cairo uses an non-standard way to define angles. The angle of 0 is on the positive X axis, but the angle of pi/2 or 90° is on the negative Y axis (the common model uses the positive Y axis).

Parameters:

angle

Returns:

the cairo angle