26 #if defined (HAVE_CONFIG_H)
34 #if defined (HAVE_GL2PS_H) && defined (HAVE_OPENGL)
74 gl2ps_renderer :
public opengl_renderer
78 gl2ps_renderer (opengl_functions& glfcns, FILE *_fp,
79 const std::string& _term)
80 : opengl_renderer (glfcns), fp (_fp), term (_term),
81 fontsize (), fontname (), buffer_overflow (false)
84 ~gl2ps_renderer (
void) =
default;
97 Matrix render_text (
const std::string& txt,
98 double x,
double y,
double z,
99 int halign,
int valign,
double rotation = 0.0);
114 if (go.
isa (
"axes") || go.
isa (
"hggroup"))
124 else if (go.
isa (
"patch") || go.
isa (
"surface"))
139 m_glfcns.glGetIntegerv (GL_VIEWPORT, vp);
140 gl2psBeginViewport (vp);
145 gl2psGetOptions (&opts);
146 if (has_alpha (props.get___myhandle__ ()))
148 opts &= ~GL2PS_OCCLUSION_CULL;
152 gl2psEnable (GL2PS_BLEND);
156 opts |= GL2PS_OCCLUSION_CULL;
157 gl2psDisable (GL2PS_BLEND);
160 gl2psSetOptions (opts);
168 GLint
state = gl2psEndViewport ();
169 if (
state == GL2PS_NO_FEEDBACK && props.is_visible ())
170 warning (
"gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print");
171 else if (
state == GL2PS_ERROR)
172 error (
"gl2ps_renderer::draw_axes: gl2psEndPage returned GL2PS_ERROR");
174 buffer_overflow |= (
state == GL2PS_OVERFLOW);
178 gl2psGetOptions (&opts);
179 opts &= ~GL2PS_DRAW_BACKGROUND;
180 gl2psSetOptions (opts);
186 void draw_pixels (
int w,
int h,
const float *data);
187 void draw_pixels (
int w,
int h,
const uint8_t *data);
188 void draw_pixels (
int w,
int h,
const uint16_t *data);
190 void init_marker (
const std::string&
m,
double size,
float width)
196 if (
m ==
"o" ||
m ==
"v" ||
m ==
"^" ||
m ==
">" ||
m ==
"<" ||
m ==
"h"
197 ||
m ==
"hexagram" ||
m ==
"p" ||
m ==
"pentagram")
199 set_linejoin (
"round");
200 set_linecap (
"round");
204 set_linejoin (
"miter");
205 set_linecap (
"square");
209 void set_linestyle (
const std::string& s,
bool use_stipple =
false,
210 double linewidth = 0.5)
214 if (s ==
"-" && ! use_stipple)
215 gl2psDisable (GL2PS_LINE_STIPPLE);
217 gl2psEnable (GL2PS_LINE_STIPPLE);
220 void set_linecap (
const std::string& s)
224 #if defined (HAVE_GL2PSLINEJOIN)
226 gl2psLineCap (GL2PS_LINE_CAP_BUTT);
227 else if (s ==
"square")
228 gl2psLineCap (GL2PS_LINE_CAP_SQUARE);
229 else if (s ==
"round")
230 gl2psLineCap (GL2PS_LINE_CAP_ROUND);
234 void set_linejoin (
const std::string& s)
238 #if defined (HAVE_GL2PSLINEJOIN)
240 gl2psLineJoin (GL2PS_LINE_JOIN_ROUND);
241 else if (s ==
"miter")
242 gl2psLineJoin (GL2PS_LINE_JOIN_MITER);
243 else if (s ==
"chamfer")
244 gl2psLineJoin (GL2PS_LINE_JOIN_BEVEL);
248 void set_polygon_offset (
bool on,
float offset = 0.0f)
253 gl2psEnable (GL2PS_POLYGON_OFFSET_FILL);
257 gl2psDisable (GL2PS_POLYGON_OFFSET_FILL);
262 void set_linewidth (
float w)
271 void fix_strlist_position (
double x,
double y,
double z,
273 std::list<text_renderer::string>& lst);
276 std::string strlist_to_svg (
double x,
double y,
double z,
Matrix box,
278 std::list<text_renderer::string>& lst);
281 std::string strlist_to_ps (
double x,
double y,
double z,
Matrix box,
283 std::list<text_renderer::string>& lst);
285 int alignment_to_mode (
int ha,
int va)
const;
290 std::string fontname;
291 bool buffer_overflow;
306 if (go.
isa (
"figure") || go.
isa (
"uipanel"))
316 else if (go.
isa (
"axes"))
329 static bool in_draw =
false;
330 static std::string old_print_cmd;
331 static GLint buffsize;
335 unwind_protect frame;
337 frame.protect_var (in_draw);
341 GLint gl2ps_term = GL2PS_PS;
342 if (term.find (
"eps") != std::string::npos)
343 gl2ps_term = GL2PS_EPS;
344 else if (term.find (
"pdf") != std::string::npos)
345 gl2ps_term = GL2PS_PDF;
346 else if (term.find (
"ps") != std::string::npos)
347 gl2ps_term = GL2PS_PS;
348 else if (term.find (
"svg") != std::string::npos)
349 gl2ps_term = GL2PS_SVG;
350 else if (term.find (
"pgf") != std::string::npos)
351 gl2ps_term = GL2PS_PGF;
352 else if (term.find (
"tex") != std::string::npos)
353 gl2ps_term = GL2PS_TEX;
355 warning (
"gl2ps_renderer::draw: Unknown terminal %s, using 'ps'",
358 GLint gl2ps_text = 0;
359 if (term.find (
"notxt") != std::string::npos)
360 gl2ps_text = GL2PS_NO_TEXT;
363 GLint gl2ps_sort = GL2PS_BSP_SORT;
367 if (has_2D_axes (go.
get (
"__myhandle__")))
368 gl2ps_sort = GL2PS_NO_SORT;
374 error (
"gl2ps_renderer::draw: couldn't open temporary file for printing");
376 frame.add_fcn (safe_fclose, tmpf);
379 if (term.find (
"tex") == std::string::npos)
380 buffsize = 2*1024*1024;
384 buffer_overflow =
true;
386 while (buffer_overflow)
388 buffer_overflow =
false;
400 std::string include_graph;
402 size_t found_redirect = old_print_cmd.find (
'>');
404 if (found_redirect != std::string::npos)
405 include_graph = old_print_cmd.substr (found_redirect + 1);
407 include_graph = old_print_cmd;
409 size_t n_begin = include_graph.find_first_not_of (
" \"'");
411 if (n_begin != std::string::npos)
413 size_t n_end = include_graph.find_last_not_of (
" \"'");
414 include_graph = include_graph.substr (n_begin,
415 n_end - n_begin + 1);
418 include_graph =
"foobar-inc";
424 Matrix c = fprop.get_color_rgb ();
425 m_glfcns.glClearColor (c(0), c(1), c(2), 1);
428 set_device_pixel_ratio (fprop.get___device_pixel_ratio__ ());
431 GLint ret = gl2psBeginPage (
"gl2ps_renderer figure",
"Octave",
432 nullptr, gl2ps_term, gl2ps_sort,
435 | GL2PS_DRAW_BACKGROUND
436 | GL2PS_NO_PS3_SHADING
437 | GL2PS_USE_CURRENT_VIEWPORT),
438 GL_RGBA, 0,
nullptr, 0, 0, 0,
439 buffsize, tmpf, include_graph.c_str ());
440 if (ret == GL2PS_ERROR)
442 old_print_cmd.clear ();
443 error (
"gl2ps_renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
449 warning (
"gl2ps_renderer::draw: retrying with buffer size: %.1E B\n",
double (2*buffsize));
451 if (! buffer_overflow)
452 old_print_cmd = print_cmd;
463 size_t nread, nwrite;
468 const char* fcn =
"/SRX { gsave FCT moveto rotate xshow grestore } BD\n";
469 bool header_found = ! (term.find (
"eps") != std::string::npos
470 || term.find (
"svg") != std::string::npos);
472 while (! feof (tmpf) && nread)
474 if (! header_found && std::fgets (str, 8192, tmpf))
477 nread = std::fread (str, 1, 8192, tmpf);
481 if (! header_found &&
std::strncmp (str,
"/SBCR", 5) == 0)
484 nwrite = std::fwrite (fcn, 1,
strlen (fcn), fp);
485 if (nwrite !=
strlen (fcn))
489 error (
"gl2ps_renderer::draw: internal pipe error");
492 else if (! header_found
493 && term.find (
"svg") != std::string::npos)
499 std::string srchstr (str);
500 size_t pos = srchstr.find (
"px");
501 if (pos != std::string::npos)
504 srchstr[pos+1] =
't';
506 pos = srchstr.find (
"px", pos);
507 srchstr[pos+1] =
't';
508 std::strcpy (str, srchstr.c_str ());
512 nwrite = std::fwrite (str, 1, nread, fp);
517 error (
"gl2ps_renderer::draw: internal pipe error");
527 gl2ps_renderer::alignment_to_mode (
int ha,
int va)
const
529 int gl2psa = GL2PS_TEXT_BL;
533 if (va == 0 || va == 3)
534 gl2psa=GL2PS_TEXT_BL;
536 gl2psa=GL2PS_TEXT_TL;
538 gl2psa=GL2PS_TEXT_CL;
542 if (va == 0 || va == 3)
543 gl2psa=GL2PS_TEXT_BR;
545 gl2psa=GL2PS_TEXT_TR;
547 gl2psa=GL2PS_TEXT_CR;
551 if (va == 0 || va == 3)
563 gl2ps_renderer::fix_strlist_position (
double x,
double y,
double z,
565 std::list<text_renderer::string>& lst)
567 for (
auto& txtobj : lst)
570 ColumnVector coord_pix = get_transform ().transform (
x, y, z,
false);
573 double rot = rotation * 4.0 *
atan (1.0) / 180;
574 coord_pix(0) += (txtobj.get_x () +
box(0))*cos (rot)
575 - (txtobj.get_y () +
box(1))*sin (rot);
576 coord_pix(1) -= (txtobj.get_y () +
box(1))*cos (rot)
577 + (txtobj.get_x () +
box(0))*sin (rot);
580 m_glfcns.glGetIntegerv (GL_VIEWPORT, vp);
582 txtobj.set_x (coord_pix(0));
583 txtobj.set_y (vp[3] - coord_pix(1));
584 txtobj.set_z (coord_pix(2));
589 code_to_symbol (uint32_t code)
593 uint32_t idx = code - 945;
596 std::string characters (
"abgdezhqiklmnxoprVstufcyw");
604 std::string characters (
"ABGDEZHQIKLMNXOPRVSTUFCYW");
607 else if (code == 978)
609 else if (code == 215)
611 else if (code == 177)
613 else if (code == 8501)
615 else if (code == 8465)
617 else if (code == 8242)
619 else if (code == 8736)
621 else if (code == 172)
623 else if (code == 9829)
625 else if (code == 8472)
627 else if (code == 8706)
629 else if (code == 8704)
631 else if (code == 9827)
633 else if (code == 9824)
635 else if (code == 8476)
637 else if (code == 8734)
639 else if (code == 8730)
641 else if (code == 8707)
643 else if (code == 9830)
645 else if (code == 8747)
647 else if (code == 8727)
649 else if (code == 8744)
651 else if (code == 8855)
653 else if (code == 8901)
655 else if (code == 8728)
657 else if (code == 8745)
659 else if (code == 8743)
661 else if (code == 8856)
663 else if (code == 8729)
665 else if (code == 8746)
667 else if (code == 8853)
669 else if (code == 8804)
671 else if (code == 8712)
673 else if (code == 8839)
675 else if (code == 8801)
677 else if (code == 8773)
679 else if (code == 8834)
681 else if (code == 8805)
683 else if (code == 8715)
685 else if (code == 8764)
687 else if (code == 8733)
689 else if (code == 8838)
691 else if (code == 8835)
693 else if (code == 8739)
695 else if (code == 8776)
697 else if (code == 8869)
699 else if (code == 8656)
701 else if (code == 8592)
703 else if (code == 8658)
705 else if (code == 8594)
707 else if (code == 8596)
709 else if (code == 8593)
711 else if (code == 8595)
713 else if (code == 8970)
715 else if (code == 8971)
717 else if (code == 10216)
719 else if (code == 10217)
721 else if (code == 8968)
723 else if (code == 8969)
725 else if (code == 8800)
727 else if (code == 8230)
729 else if (code == 176)
731 else if (code == 8709)
733 else if (code == 169)
737 warning (
"print: unhandled symbol %d", code);
743 select_font (
caseless_str fn,
bool isbold,
bool isitalic)
746 std::string fontname;
747 if (fn ==
"times" || fn ==
"times-roman")
749 if (isitalic && isbold)
750 fontname =
"Times-BoldItalic";
752 fontname =
"Times-Italic";
754 fontname =
"Times-Bold";
756 fontname =
"Times-Roman";
758 else if (fn ==
"courier")
760 if (isitalic && isbold)
761 fontname =
"Courier-BoldOblique";
763 fontname =
"Courier-Oblique";
765 fontname =
"Courier-Bold";
767 fontname =
"Courier";
769 else if (fn ==
"symbol")
771 else if (fn ==
"zapfdingbats")
772 fontname =
"ZapfDingbats";
775 if (isitalic && isbold)
776 fontname =
"Helvetica-BoldOblique";
778 fontname =
"Helvetica-Oblique";
780 fontname =
"Helvetica-Bold";
782 fontname =
"Helvetica";
788 escape_character (
const std::string chr, std::string& str)
790 std::size_t idx = str.find (chr);
791 while (idx != std::string::npos)
793 str.insert (idx, 1,
'\\');
794 idx = str.find (chr, idx + 2);
799 gl2ps_renderer::strlist_to_svg (
double x,
double y,
double z,
801 std::list<text_renderer::string>& lst)
807 ColumnVector coord_pix = get_transform ().transform (
x, y, z,
false);
809 std::ostringstream os;
810 os <<
"<text xml:space=\"preserve\" ";
814 <<
"translate(" << coord_pix(0) +
box(0) <<
"," << coord_pix(1) -
box(1)
815 <<
") rotate(" << -rotation <<
"," << -
box(0) <<
"," <<
box(1)
819 auto p = lst.begin ();
820 std::string
name = p->get_family ();
821 std::string weight = p->get_weight ();
822 std::string angle = p->get_angle ();
823 double size = p->get_size ();
825 os <<
"font-family=\"" <<
name <<
"\" "
826 <<
"font-weight=\"" << weight <<
"\" "
827 <<
"font-style=\"" << angle <<
"\" "
828 <<
"font-size=\"" << size <<
"\">";
832 for (p = lst.begin (); p != lst.end (); p++)
836 if (
name.compare (p->get_family ()))
837 os <<
"font-family=\"" << p->get_family () <<
"\" ";
839 if (weight.compare (p->get_weight ()))
840 os <<
"font-weight=\"" << p->get_weight () <<
"\" ";
842 if (angle.compare (p->get_angle ()))
843 os <<
"font-style=\"" << p->get_angle () <<
"\" ";
845 if (size != p->get_size ())
846 os <<
"font-size=\"" << p->get_size () <<
"\" ";
848 os <<
"y=\"" << - p->get_y () <<
"\" ";
850 Matrix col = p->get_color ();
851 os <<
"fill=\"rgb(" << col(0)*255 <<
","
852 << col(1)*255 <<
"," << col(2)*255 <<
")\" ";
856 std::vector<double> xdata = p->get_xdata ();
857 for (
auto q = xdata.begin (); q != xdata.end (); q++)
865 os <<
"&#" << p->get_code () <<
";";
868 const std::string str = p->get_string ();
869 for (
auto q = str.begin (); q != str.end (); q++)
871 std::stringstream chr;
873 if (chr.str () ==
"\"")
875 else if (chr.str () ==
"'")
877 else if (chr.str () ==
"&")
879 else if (chr.str () ==
"<")
881 else if (chr.str () ==
">")
895 gl2ps_renderer::strlist_to_ps (
double x,
double y,
double z,
897 std::list<text_renderer::string>& lst)
900 fix_strlist_position (
x, y, z,
box, rotation, lst);
901 Matrix prev_color (1, 3, -1);
903 std::ostringstream ss;
906 static bool warned =
false;
908 for (
const auto& txtobj : lst)
911 if (txtobj.get_color () != prev_color)
913 prev_color = txtobj.get_color ();
914 for (
int i = 0; i < 3; i++)
915 ss << prev_color(i) <<
" ";
922 if (txtobj.get_code ())
925 str = code_to_symbol (txtobj.get_code ());
929 fontname = select_font (txtobj.get_name (),
930 txtobj.get_weight () ==
"bold",
931 txtobj.get_angle () ==
"italic");
934 const std::string tmpstr = txtobj.get_string ();
936 =
reinterpret_cast<const uint8_t *
> (tmpstr.c_str ());
938 for (
size_t i = 0; i < tmpstr.size ();)
949 "print: only ASCII characters are "
950 "supported for EPS and derived "
962 "print: only ASCII characters are "
963 "supported for EPS and derived "
969 str += tmpstr.at (i);
975 escape_character (
"\\", str);
976 escape_character (
"(", str);
977 escape_character (
")", str);
979 ss <<
"(" << str <<
") [";
981 std::vector<double> xdata = txtobj.get_xdata ();
982 for (
size_t i = 1; i < xdata.size (); i++)
983 ss << xdata[i] - xdata[i-1] <<
" ";
985 ss <<
"10] " << rotation <<
" " << txtobj.get_x ()
986 <<
" " << txtobj.get_y () <<
" " << txtobj.get_size ()
987 <<
" /" << fontname <<
" SRX\n";
996 gl2ps_renderer::render_text (
const std::string& txt,
997 double x,
double y,
double z,
998 int ha,
int va,
double rotation)
1000 std::string saved_font = fontname;
1003 return Matrix (1, 4, 0.0);
1006 std::string str = txt;
1007 std::list<text_renderer::string> lst;
1009 text_to_strlist (str, lst, bbox, ha, va, rotation);
1010 m_glfcns.glRasterPos3d (
x, y, z);
1013 if (term.find (
"svg") != std::string::npos)
1015 std::string elt = strlist_to_svg (
x, y, z, bbox, rotation, lst);
1017 gl2psSpecial (GL2PS_SVG, elt.c_str ());
1019 else if (term.find (
"eps") != std::string::npos)
1021 std::string elt = strlist_to_ps (
x, y, z, bbox, rotation, lst);
1023 gl2psSpecial (GL2PS_EPS, elt.c_str ());
1027 gl2psTextOpt (str.c_str (), fontname.c_str (), fontsize,
1028 alignment_to_mode (ha, va), rotation);
1030 fontname = saved_font;
1052 fontname = select_font (fn, isbold, isitalic);
1063 Matrix x = props.get_xdata ().matrix_value ();
1064 Matrix y = props.get_ydata ().matrix_value ();
1074 std::swap (
x(0),
x(1));
1077 else if (
w > 1 &&
x(1) ==
x(0))
1078 x(1) =
x(1) + (
w-1);
1083 std::swap (y(0), y(1));
1086 else if (h > 1 && y(1) == y(0))
1087 y(1) = y(1) + (h-1);
1096 warning (
"opengl_renderer: image X,Y data too large to draw");
1101 float pix_dx, pix_dy;
1103 float nor_dx, nor_dy;
1107 pix_dx = (p1(0) - p0(0)) / (
w-1);
1108 nor_dx = (
x(1) -
x(0)) / (
w-1);
1113 pix_dx = p1w(0) - p0(0);
1119 pix_dy = (p1(1) - p0(1)) / (h-1);
1120 nor_dy = (y(1) - y(0)) / (h-1);
1125 pix_dy = p1h(1) - p0(1);
1132 int j0, j1, jj, i0, i1, ii;
1136 float im_xmin =
x(0) - nor_dx/2;
1137 float im_xmax =
x(1) + nor_dx/2;
1138 float im_ymin = y(0) - nor_dy/2;
1139 float im_ymax = y(1) + nor_dy/2;
1142 bool do_clip = props.is_clipping ();
1143 Matrix vp = get_viewport_scaled ();
1146 =
xform.untransform (std::numeric_limits <float>::epsilon (),
1147 std::numeric_limits <float>::epsilon ());
1150 if (vp_lim_min(0) > vp_lim_max(0))
1151 std::swap (vp_lim_min(0), vp_lim_max(0));
1153 if (vp_lim_min(1) > vp_lim_max(1))
1154 std::swap (vp_lim_min(1), vp_lim_max(1));
1157 = do_clip ? (vp_lim_min(0) >
xmin ? vp_lim_min(0) :
xmin) : vp_lim_min(0);
1160 = do_clip ? (vp_lim_min(1) > ymin ? vp_lim_min(1) : ymin) : vp_lim_min(1);
1163 = do_clip ? (vp_lim_max(0) <
xmax ? vp_lim_max(0) :
xmax) : vp_lim_max(0);
1166 = do_clip ? (vp_lim_max(1) < ymax ? vp_lim_max(1) : ymax) : vp_lim_max(1);
1168 if (im_xmin < clip_xmin)
1169 j0 += (clip_xmin - im_xmin)/nor_dx + 1;
1171 if (im_xmax > clip_xmax)
1172 j1 -= (im_xmax - clip_xmax)/nor_dx;
1174 if (im_ymin < clip_ymin)
1175 i0 += (clip_ymin - im_ymin)/nor_dy + 1;
1177 if (im_ymax > clip_ymax)
1178 i1 -= (im_ymax - clip_ymax)/nor_dy;
1180 if (i0 >= i1 || j0 >= j1)
1184 m_glfcns.glGetFloatv (GL_ZOOM_X, &zoom_x);
1186 m_glfcns.glGetFloatv (GL_ZOOM_Y, &zoom_y);
1188 m_glfcns.glPixelZoom (m_devpixratio * pix_dx, - m_devpixratio * pix_dy);
1189 m_glfcns.glRasterPos3d (im_xmin + nor_dx*j0, im_ymin + nor_dy*i0, 0);
1192 if (dv.ndims () == 3 && dv(2) == 3)
1200 for (
int i = i0; i < i1; i++)
1202 for (
int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
1214 a[idx] = xcdata(ii,jj,0);
1215 a[idx+1] = xcdata(ii,jj,1);
1216 a[idx+2] = xcdata(ii,jj,2);
1220 draw_pixels (j1-j0, i1-i0, a);
1229 for (
int i = i0; i < i1; i++)
1231 for (
int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
1243 a[idx] = xcdata(ii,jj,0);
1244 a[idx+1] = xcdata(ii,jj,1);
1245 a[idx+2] = xcdata(ii,jj,2);
1249 draw_pixels (j1-j0, i1-i0, a);
1258 for (
int i = i0; i < i1; i++)
1260 for (
int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
1272 a[idx] = xcdata(ii,jj,0);
1273 a[idx+1] = xcdata(ii,jj,1);
1274 a[idx+2] = xcdata(ii,jj,2);
1278 draw_pixels (j1-j0, i1-i0, a);
1287 for (
int i = i0; i < i1; i++)
1289 for (
int j = j0, idx = (i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
1301 a[idx] = xcdata(ii,jj,0);
1302 a[idx+1] = xcdata(ii,jj,1);
1303 a[idx+2] = xcdata(ii,jj,2);
1307 draw_pixels (j1-j0, i1-i0, a);
1311 warning (
"opengl_renderer: invalid image data type (expected double, single, uint8, or uint16)");
1313 m_glfcns.glPixelZoom (zoom_x, zoom_y);
1319 gl2ps_renderer::draw_pixels (
int w,
int h,
const float *data)
1324 for (
int i = 0; i < 3*h*
w; i++)
1325 tmp_data[i] = (data[i] < 0.0f ? 0.0f : (data[i] > 1.0f ? 1.0f : data[i]));
1327 gl2psDrawPixels (
w, h, 0, 0, GL_RGB, GL_FLOAT, tmp_data);
1331 gl2ps_renderer::draw_pixels (
int w,
int h,
const uint8_t *data)
1339 for (
int i = 0; i < 3*
w*h; i++)
1340 tmp_data[i] = data[i] / maxval;
1342 draw_pixels (
w, h, tmp_data);
1346 gl2ps_renderer::draw_pixels (
int w,
int h,
const uint16_t *data)
1354 for (
int i = 0; i < 3*
w*h; i++)
1355 tmp_data[i] = data[i] / maxval;
1357 draw_pixels (
w, h, tmp_data);
1363 if (props.get_string ().isempty ())
1366 draw_text_background (props,
true);
1372 set_color (props.get_color_rgb ());
1374 std::string saved_font = fontname;
1380 if (props.horizontalalignment_is (
"center"))
1382 else if (props.horizontalalignment_is (
"right"))
1385 if (props.verticalalignment_is (
"top"))
1387 else if (props.verticalalignment_is (
"baseline"))
1389 else if (props.verticalalignment_is (
"middle"))
1395 const Matrix pos = get_transform ().scale (props.get_data_position ());
1396 std::string str = props.get_string ().string_vector_value ().join (
"\n");
1398 render_text (str, pos(0), pos(1), pos.
numel () > 2 ? pos(2) : 0.0,
1399 halign, valign, props.get_rotation ());
1412 const std::string&
stream,
const std::string& term)
1414 #if defined (HAVE_GL2PS_H) && defined (HAVE_OPENGL)
1419 bool have_cmd =
stream.length () > 1 &&
stream[0] ==
'|';
1429 std::string cmd =
stream.substr (1);
1431 fp =
popen (cmd.c_str (),
"w");
1434 error (R
"(print: failed to open pipe "%s")", stream.c_str ());
1436 frame.add_fcn (safe_pclose, fp);
1445 error (R
"(gl2ps_print: failed to create file "%s")", stream.c_str ());
1447 frame.add_fcn (safe_fclose, fp);
1450 gl2ps_renderer rend (glfcns, fp, term);
1453 rend.set_viewport (pos(2), pos(3));
1461 octave_unused_parameter (glfcns);
1462 octave_unused_parameter (fig);
1463 octave_unused_parameter (
stream);
1464 octave_unused_parameter (term);
charNDArray max(char d, const charNDArray &m)
octave_idx_type numel(void) const
Number of elements in the array.
bool isempty(void) const
Size of the specified dimension.
bool get_is2D(bool include_kids=false) const
virtual bool has_property(const caseless_str &) const
virtual octave_value get(const caseless_str &pname) const
Vector representing the dimensions (size) of an Array.
graphics_object get_object(double val) const
octave_value get(bool all=false) const
bool isa(const std::string &go_name) const
base_properties & get_properties(void)
bool valid_object(void) const
octave_value get_color_data(void) const
void add_fcn(void(*fcn)(Params...), Args &&... args)
virtual void set_linejoin(const std::string &)
virtual void draw_axes(const axes::properties &props)
virtual void draw(const graphics_object &go, bool toplevel=true)
virtual void set_polygon_offset(bool on, float offset=0.0f)
virtual void init_marker(const std::string &m, double size, float width)
virtual void set_linestyle(const std::string &s, bool stipple=false, double linewidth=0.5)
virtual void set_font(const base_properties &props)
uint16NDArray uint16_array_value(void) const
bool is_uint16_type(void) const
bool is_scalar_type(void) const
bool is_double_type(void) const
uint8NDArray uint8_array_value(void) const
std::string string_value(bool force=false) const
NDArray array_value(bool frc_str_conv=false) const
octave_value xtolower(void) const
bool is_single_type(void) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
bool is_uint8_type(void) const
Matrix matrix_value(bool frc_str_conv=false) const
double double_value(bool frc_str_conv=false) const
dim_vector dims(void) const
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
void xform(ColumnVector &v, const Matrix &m)
ColumnVector transform(const Matrix &m, double x, double y, double z)
F77_RET_T const F77_DBLE * x
std::complex< double > w(std::complex< double > z, double relerr=0)
Complex atan(const Complex &x)
bool strncmp(const T &str_a, const T &str_b, const typename T::size_type n)
True if the first N characters are the same.
std::FILE * fopen(const std::string &filename, const std::string &mode)
gh_manager & __get_gh_manager__(const std::string &who)
static uint32_t state[624]
void respond_to_pending_signals(void)
void gl2ps_print(opengl_functions &glfcns, const graphics_object &fig, const std::string &stream, const std::string &term)
static double f(double k, double l_nu, double c_pm)
FILE * popen(const char *command, const char *mode)
octave_int< T > xmin(const octave_int< T > &x, const octave_int< T > &y)
octave_int< T > xmax(const octave_int< T > &x, const octave_int< T > &y)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
T::size_type strlen(const typename T::value_type *str)
void draw(QDomElement &parent_elt, pdfpainter &painter)
static octave_value box(JNIEnv *jni_env, void *jobj, void *jcls_arg=nullptr)
octave_value::octave_value(const Array< char > &chm, char type) return retval
FILE * octave_tmpfile_wrapper(void)
int octave_ftruncate_wrapper(int fd, off_t sz)
int octave_u8_strmblen_wrapper(const uint8_t *src)