Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
treepic_utils.H File Reference

Tree picture generation utilities. More...

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <fstream>
#include <aleph.H>
Include dependency graph for treepic_utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

long double font_width ()
 
long double font_height ()
 
void intersection_ellipse_line (long double lx0, long double ly0, long double lx1, long double ly1, long double a, long double b, long double &dx, long double &dy)
 
void intersection_line_line (long double lx1, long double ly1, long double lx2, long double ly2, long double rx1, long double ry1, long double rx2, long double ry2, long double &x, long double &y)
 
long double distance_between_points (long double x1, long double y1, long double x2, long double y2)
 
void intersection_rectangle_line (long double lx0, long double ly0, long double lx1, long double ly1, long double a, long double b, long double &dx, long double &dy)
 
long double YPIC (long double y)
 
size_t compute_true_len (const std::string &str)
 
void put_string (std::ofstream &output, const long double &x, const long double &y, const std::string &comment, const std::string &str)
 
void put_string_tkiz (std::ofstream &output, const long double &x, const long double &y, const std::string &comment, const std::string &str)
 
void draw_arc (std::ofstream &output, long double src_x, long double src_y, long double tgt_x, long double tgt_y, bool is_dashed, bool with_arrow, bool thick=true)
 
void draw_arc_tikz (std::ofstream &output, long double src_x, long double src_y, long double tgt_x, long double tgt_y, bool is_dashed, bool with_arrow, bool thick=true)
 
long double center_string (const std::string &str, long double window_size)
 
long double string_width (const std::string &str)
 
int compute_section (long double x1, long double y1, long double x2, long double y2)
 
void compute_mid_point_line (const long double &sx, const long double &sy, const long double &tx, const long double &ty, const long double &d, const bool &left, long double &mx, long double &my)
 

Variables

const long double sin_45 = sin(M_PI_4)
 
const long double cos_45 = cos(M_PI_4)
 
const char *const font_wrapper = "\\texttt{"
 
const char * fill_type = "shade"
 
static const long double points_per_inch = 72.27
 
static const long double mm_per_inch = 25.4
 
long double font_width_in_points = 5
 
long double font_width_in_mm
 
long double font_height_in_mm = 2.0
 
long double resolution = 0.05
 
bool flip_y = false
 
bool tiny_keys = false
 Global flag to enable tiny font size for keys/labels.
 
std::string input_file_name
 
std::string output_file_name
 
double v_size
 
bool with_arrow = false
 
long double dash_len = 1/resolution
 
long double arrow_width = arrow_width_in_mm/resolution
 
long double arrow_lenght = arrow_lenght_in_mm/resolution
 
Arrow drawing parameters (in mm)
Warning
These global variables are NOT thread-safe
static long double arrow_width_in_mm = 0.5
 
static long double arrow_lenght_in_mm = 1.5
 

Detailed Description

Tree picture generation utilities.

Warning
This file uses static global variables for drawing parameters and is NOT thread-safe. Do not use these functions concurrently from multiple threads.
Author
Leandro Rabindranath León

Definition in file treepic_utils.H.

Function Documentation

◆ center_string()

long double center_string ( const std::string &  str,
long double  window_size 
)
inline

Definition at line 419 of file treepic_utils.H.

References compute_true_len(), and font_width().

Referenced by generate_tree(), and generate_tree().

◆ compute_mid_point_line()

void compute_mid_point_line ( const long double &  sx,
const long double &  sy,
const long double &  tx,
const long double &  ty,
const long double &  d,
const bool &  left,
long double &  mx,
long double &  my 
)
inline

Definition at line 450 of file treepic_utils.H.

References h.

◆ compute_section()

int compute_section ( long double  x1,
long double  y1,
long double  x2,
long double  y2 
)
inline

Definition at line 432 of file treepic_utils.H.

References y1().

◆ compute_true_len()

size_t compute_true_len ( const std::string &  str)
inline

Definition at line 255 of file treepic_utils.H.

Referenced by center_string(), and string_width().

◆ distance_between_points()

long double distance_between_points ( long double  x1,
long double  y1,
long double  x2,
long double  y2 
)
inline

Definition at line 185 of file treepic_utils.H.

References sqrt(), and y1().

◆ draw_arc()

void draw_arc ( std::ofstream &  output,
long double  src_x,
long double  src_y,
long double  tgt_x,
long double  tgt_y,
bool  is_dashed,
bool  with_arrow,
bool  thick = true 
)
inline

Definition at line 328 of file treepic_utils.H.

References arrow_lenght, arrow_width, atan(), atan2(), cos(), dash_len, l, output, sin(), sqrt(), with_arrow, and YPIC().

Referenced by generate_tree(), and generate_tree().

◆ draw_arc_tikz()

void draw_arc_tikz ( std::ofstream &  output,
long double  src_x,
long double  src_y,
long double  tgt_x,
long double  tgt_y,
bool  is_dashed,
bool  with_arrow,
bool  thick = true 
)
inline

Definition at line 372 of file treepic_utils.H.

References arrow_lenght, arrow_width, atan(), atan2(), cos(), l, output, sin(), sqrt(), with_arrow, and YPIC().

◆ font_height()

long double font_height ( )
inline

◆ font_width()

long double font_width ( )
inline

Definition at line 100 of file treepic_utils.H.

References font_width_in_mm, and resolution.

Referenced by center_string(), and string_width().

◆ intersection_ellipse_line()

void intersection_ellipse_line ( long double  lx0,
long double  ly0,
long double  lx1,
long double  ly1,
long double  a,
long double  b,
long double &  dx,
long double &  dy 
)
inline

Definition at line 124 of file treepic_utils.H.

References sqrt().

Referenced by generate_tree(), and generate_tree().

◆ intersection_line_line()

void intersection_line_line ( long double  lx1,
long double  ly1,
long double  lx2,
long double  ly2,
long double  rx1,
long double  ry1,
long double  rx2,
long double  ry2,
long double &  x,
long double &  y 
)
inline

Definition at line 162 of file treepic_utils.H.

References y.

◆ intersection_rectangle_line()

void intersection_rectangle_line ( long double  lx0,
long double  ly0,
long double  lx1,
long double  ly1,
long double  a,
long double  b,
long double &  dx,
long double &  dy 
)
inline

Definition at line 207 of file treepic_utils.H.

Referenced by generate_tree().

◆ put_string()

void put_string ( std::ofstream &  output,
const long double &  x,
const long double &  y,
const std::string &  comment,
const std::string &  str 
)
inline

Definition at line 281 of file treepic_utils.H.

References flip_y, font_height(), font_wrapper, output, tiny_keys, y, and YPIC().

Referenced by generate_tree(), and generate_tree().

◆ put_string_tkiz()

void put_string_tkiz ( std::ofstream &  output,
const long double &  x,
const long double &  y,
const std::string &  comment,
const std::string &  str 
)
inline

Definition at line 301 of file treepic_utils.H.

References flip_y, font_height(), output, y, and YPIC().

◆ string_width()

long double string_width ( const std::string &  str)
inline

Definition at line 426 of file treepic_utils.H.

References compute_true_len(), and font_width().

Referenced by generate_tree(), and generate_tree().

◆ YPIC()

long double YPIC ( long double  y)
inline

Variable Documentation

◆ arrow_lenght

long double arrow_lenght = arrow_lenght_in_mm/resolution

Definition at line 326 of file treepic_utils.H.

Referenced by draw_arc(), draw_arc_tikz(), main(), and parser_opt().

◆ arrow_lenght_in_mm

long double arrow_lenght_in_mm = 1.5
static

Definition at line 321 of file treepic_utils.H.

◆ arrow_width

long double arrow_width = arrow_width_in_mm/resolution

Definition at line 325 of file treepic_utils.H.

Referenced by draw_arc(), draw_arc_tikz(), main(), and parser_opt().

◆ arrow_width_in_mm

long double arrow_width_in_mm = 0.5
static

Definition at line 320 of file treepic_utils.H.

◆ cos_45

const long double cos_45 = cos(M_PI_4)

Definition at line 58 of file treepic_utils.H.

◆ dash_len

long double dash_len = 1/resolution

Definition at line 324 of file treepic_utils.H.

Referenced by draw_arc(), generate_split_lines(), and generate_tree().

◆ fill_type

const char * fill_type = "shade"

Definition at line 61 of file treepic_utils.H.

Referenced by build_tree(), generate_prologue(), main(), and parser_opt().

◆ flip_y

bool flip_y = false

Definition at line 74 of file treepic_utils.H.

Referenced by main(), parser_opt(), put_string(), put_string_tkiz(), and YPIC().

◆ font_height_in_mm

long double font_height_in_mm = 2.0

Definition at line 70 of file treepic_utils.H.

Referenced by font_height().

◆ font_width_in_mm

long double font_width_in_mm
Initial value:
=
long double font_width_in_points
static const long double points_per_inch
static const long double mm_per_inch

Definition at line 68 of file treepic_utils.H.

Referenced by font_width().

◆ font_width_in_points

long double font_width_in_points = 5

Definition at line 66 of file treepic_utils.H.

◆ font_wrapper

const char *const font_wrapper = "\\texttt{"

Definition at line 60 of file treepic_utils.H.

Referenced by generate_split_lines(), and put_string().

◆ input_file_name

std::string input_file_name
extern

Definition at line 406 of file btreepic.C.

Referenced by file_to_dynarrays(), generate_prologue(), main(), and parser_opt().

◆ mm_per_inch

const long double mm_per_inch = 25.4
static

Definition at line 64 of file treepic_utils.H.

◆ output_file_name

std::string output_file_name
extern

Definition at line 407 of file btreepic.C.

Referenced by generate_prologue(), main(), and parser_opt().

◆ points_per_inch

const long double points_per_inch = 72.27
static

Definition at line 63 of file treepic_utils.H.

◆ resolution

◆ sin_45

const long double sin_45 = sin(M_PI_4)

Definition at line 57 of file treepic_utils.H.

Referenced by generate_tree(), and generate_tree().

◆ tiny_keys

bool tiny_keys = false

Global flag to enable tiny font size for keys/labels.

When set to true, text labels will be rendered using LaTeX's \tiny font size modifier. Useful for dense diagrams with many labels.

Definition at line 76 of file treepic_utils.H.

Referenced by Eepic_Plane::draw_text(), main(), and put_string().

◆ v_size

◆ with_arrow

bool with_arrow = false

Definition at line 323 of file treepic_utils.H.

Referenced by draw_arc(), draw_arc_tikz(), generate_tree(), generate_tree(), main(), and parser_opt().