Mercurial > hg > octave-lojdl
changeset 17457:1647020d09ec
Applied GNU coding style
author | Andrej Lojdl <andrej.lojdl@gmail.com> |
---|---|
date | Tue, 17 Sep 2013 20:47:20 +0200 |
parents | 9bc940e63aa2 |
children | 562dafc5270a |
files | libinterp/corefcn/txt-eng-ft.cc libinterp/corefcn/txt-latex.cc libinterp/corefcn/txt-latex.h libinterp/corefcn/txt-render.cc libinterp/corefcn/txt-render.h |
diffstat | 5 files changed, 121 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/txt-eng-ft.cc +++ b/libinterp/corefcn/txt-eng-ft.cc @@ -924,11 +924,11 @@ } Matrix bounding_box = box; - + box = alignment (halign, valign, bounding_box); bounding_box = box; - + box = rotate_bounding_box (rot_mode, bounding_box); }
--- a/libinterp/corefcn/txt-latex.cc +++ b/libinterp/corefcn/txt-latex.cc @@ -53,38 +53,38 @@ int latex_render::check_programs (void) { - int cmd, ready = 1; - std::string check_latex, check_dvips, check_ghostscript; - - check_latex = "latex --version >/dev/null 2>/dev/null"; - check_dvips = "dvips --version >/dev/null 2>/dev/null"; - check_ghostscript = "gs --version >/dev/null 2>/dev/null"; - - cmd = system (check_latex.c_str ()); - - if (cmd != 0) - { + int cmd, ready = 1; + std::string check_latex, check_dvips, check_ghostscript; + + check_latex = "latex --version >/dev/null 2>/dev/null"; + check_dvips = "dvips --version >/dev/null 2>/dev/null"; + check_ghostscript = "gs --version >/dev/null 2>/dev/null"; + + cmd = system (check_latex.c_str ()); + + if (cmd != 0) + { ::error("There's no LaTeX document preparation system installed on this system. Please install it and then try again."); ready = 0; - } - - cmd = system (check_dvips.c_str ()); - - if (cmd != 0) - { + } + + cmd = system (check_dvips.c_str ()); + + if (cmd != 0) + { ::error("There's no dvips converter installed on this system. Please install it and then try again."); ready = 0; - } - - cmd = system (check_ghostscript.c_str ()); - - if (cmd != 0) - { + } + + cmd = system (check_ghostscript.c_str ()); + + if (cmd != 0) + { ::error("There's no GhostScript program for converting installed on this system. Please install it and then try again."); ready = 0; - } - - return ready; + } + + return ready; } void @@ -353,15 +353,15 @@ int halign, int valign, double rotation) { if (check_programs () == 1) - { - adapter (txt); - pixels = render(); - } + { + adapter (txt); + pixels = render(); + } else - { - pixels = uint8NDArray (dim_vector (4, 10, 10), static_cast<uint8_t> (0)); - } - + { + pixels = uint8NDArray (dim_vector (4, 10, 10), static_cast<uint8_t> (0)); + } + int rot_mode = rotation_to_mode (rotation); if(pixels.ndims () < 3) @@ -371,18 +371,18 @@ bbox = Matrix (1, 4, 0.0); bbox (2) = pixels.dim2 (); bbox (3) = pixels.dim3 (); - + Matrix bounding_box = bbox; - + bbox = alignment (halign, valign, bounding_box); - + bounding_box = bbox; - + bbox = rotate_bounding_box (rot_mode, bounding_box); } - - /* Rotating pixels */ - if (pixels.numel () > 0) + + /* Rotating pixels */ + if (pixels.numel () > 0) { uint8NDArray data = pixels; pixels = rotate_data (rot_mode, data);
--- a/libinterp/corefcn/txt-latex.h +++ b/libinterp/corefcn/txt-latex.h @@ -50,7 +50,7 @@ Matrix get_extent (text_element *elt, double rotation = 0.0); Matrix get_extent (const std::string& txt, double rotation = 0.0); - + /* method that cheks if there are all required programs installed */ int check_programs (void);
--- a/libinterp/corefcn/txt-render.cc +++ b/libinterp/corefcn/txt-render.cc @@ -103,93 +103,93 @@ base_text_render::rotate_data (int mode, uint8NDArray data) { switch (mode) + { + case ROTATION_0: + break; + case ROTATION_90: { - case ROTATION_0: - break; - case ROTATION_90: - { - Array<octave_idx_type> perm (dim_vector (3, 1)); - perm(0) = 0; - perm(1) = 2; - perm(2) = 1; - data = data.permute (perm); + Array<octave_idx_type> perm (dim_vector (3, 1)); + perm(0) = 0; + perm(1) = 2; + perm(2) = 1; + data = data.permute (perm); - Array<idx_vector> idx (dim_vector (3, 1)); - idx(0) = idx_vector (':'); - idx(1) = idx_vector (data.dim2 ()-1, -1, -1); - idx(2) = idx_vector (':'); - data = uint8NDArray (data.index (idx)); - } - break; - case ROTATION_180: - { - Array<idx_vector> idx (dim_vector (3, 1)); - idx(0) = idx_vector (':'); - idx(1) = idx_vector (data.dim2 ()-1, -1, -1); - idx(2)= idx_vector (data.dim3 ()-1, -1, -1); - data = uint8NDArray (data.index (idx)); - } - break; - case ROTATION_270: - { - Array<octave_idx_type> perm (dim_vector (3, 1)); - perm(0) = 0; - perm(1) = 2; - perm(2) = 1; - data = data.permute (perm); + Array<idx_vector> idx (dim_vector (3, 1)); + idx(0) = idx_vector (':'); + idx(1) = idx_vector (data.dim2 ()-1, -1, -1); + idx(2) = idx_vector (':'); + data = uint8NDArray (data.index (idx)); + } + break; + case ROTATION_180: + { + Array<idx_vector> idx (dim_vector (3, 1)); + idx(0) = idx_vector (':'); + idx(1) = idx_vector (data.dim2 ()-1, -1, -1); + idx(2)= idx_vector (data.dim3 ()-1, -1, -1); + data = uint8NDArray (data.index (idx)); + } + break; + case ROTATION_270: + { + Array<octave_idx_type> perm (dim_vector (3, 1)); + perm(0) = 0; + perm(1) = 2; + perm(2) = 1; + data = data.permute (perm); - Array<idx_vector> idx (dim_vector (3, 1)); - idx(0) = idx_vector (':'); - idx(1) = idx_vector (':'); - idx(2) = idx_vector (data.dim3 ()-1, -1, -1); - data = uint8NDArray (data.index (idx)); - } - break; + Array<idx_vector> idx (dim_vector (3, 1)); + idx(0) = idx_vector (':'); + idx(1) = idx_vector (':'); + idx(2) = idx_vector (data.dim3 ()-1, -1, -1); + data = uint8NDArray (data.index (idx)); } - return data; + break; + } + return data; } Matrix base_text_render::alignment (int halign, int valign, Matrix bounding_box) { switch (halign) - { - default: bounding_box (0) = 0; break; - case 1: bounding_box (0) = -bounding_box (2) / 2; break; - case 2: bounding_box (0) = -bounding_box (2); break; - } - switch (valign) - { - default: bounding_box (1) = 0; break; - case 1: bounding_box (1) = -bounding_box (3) / 2; break; - case 2: bounding_box (1) = -bounding_box (3); break; - case 3: break; - case 4: bounding_box (1) = -bounding_box (3) - bounding_box (1); break; - } - - return bounding_box; + { + default: bounding_box (0) = 0; break; + case 1: bounding_box (0) = -bounding_box (2) / 2; break; + case 2: bounding_box (0) = -bounding_box (2); break; + } + switch (valign) + { + default: bounding_box (1) = 0; break; + case 1: bounding_box (1) = -bounding_box (3) / 2; break; + case 2: bounding_box (1) = -bounding_box (3); break; + case 3: break; + case 4: bounding_box (1) = -bounding_box (3) - bounding_box (1); break; + } + + return bounding_box; } Matrix base_text_render::rotate_bounding_box (int rotation, Matrix bounding_box) { - switch (rotation) - { - case ROTATION_90: - std::swap (bounding_box (0), bounding_box (1)); - std::swap (bounding_box (2), bounding_box (3)); - bounding_box (0) = -bounding_box (0) - bounding_box (2); - break; - case ROTATION_180: - bounding_box (0) = -bounding_box (0) - bounding_box (2); - bounding_box (1) = -bounding_box (1) - bounding_box (3); - break; - case ROTATION_270: - std::swap (bounding_box (0), bounding_box (1)); - std::swap (bounding_box (2), bounding_box (3)); - bounding_box (1) = -bounding_box (1) - bounding_box(3); - break; - } - - return bounding_box; + switch (rotation) + { + case ROTATION_90: + std::swap (bounding_box (0), bounding_box (1)); + std::swap (bounding_box (2), bounding_box (3)); + bounding_box (0) = -bounding_box (0) - bounding_box (2); + break; + case ROTATION_180: + bounding_box (0) = -bounding_box (0) - bounding_box (2); + bounding_box (1) = -bounding_box (1) - bounding_box (3); + break; + case ROTATION_270: + std::swap (bounding_box (0), bounding_box (1)); + std::swap (bounding_box (2), bounding_box (3)); + bounding_box (1) = -bounding_box (1) - bounding_box(3); + break; + } + + return bounding_box; }
--- a/libinterp/corefcn/txt-render.h +++ b/libinterp/corefcn/txt-render.h @@ -37,13 +37,13 @@ base_text_render { public: - enum { + enum { ROTATION_0 = 0, ROTATION_90 = 1, ROTATION_180 = 2, ROTATION_270 = 3 }; - + public: friend class text_render; @@ -62,7 +62,7 @@ virtual Matrix get_extent (text_element *elt, double rotation = 0.0) = 0; virtual Matrix get_extent (const std::string& txt, double rotation = 0.0) = 0; - + int rotation_to_mode (double rotation) const; uint8NDArray rotate_data (int mode, uint8NDArray data); Matrix alignment (int halign, int valign, Matrix bounding_box);