26 #if defined (HAVE_CONFIG_H)
32 #if defined (HAVE_WINDOWS_H)
33 # define WIN32_LEAN_AND_MEAN
49 #if defined (HAVE_OPENGL)
62 #define LIGHT_MODE GL_FRONT_AND_BACK
92 #if ! defined (CALLBACK)
104 : m_glfcns (glfcns), id (),
w (), h (), tw (), th (), tx (), ty (),
105 valid (false), count (1)
109 int w_arg,
int h_arg,
int tw_arg,
int th_arg)
110 : m_glfcns (glfcns), id (id_arg),
w (w_arg), h (h_arg),
111 tw (tw_arg), th (th_arg), tx (double(
w)/tw), ty (double(h)/th),
112 valid (true), count (1)
118 m_glfcns.glDeleteTextures (1, &
id);
122 {
if (valid) m_glfcns.glBindTexture (mode,
id); }
125 {
if (valid) m_glfcns.glTexCoord2d (q*tx,
r*ty); }
153 if (--rep->
count == 0)
161 if (--rep->
count == 0)
174 void bind (
int mode = GL_TEXTURE_2D)
const
175 { rep->
bind (mode); }
181 {
return rep->
valid; }
192 if (dv.
ndims () == 3 && dv(2) == 3)
197 h = dv(0),
w = dv(1);
202 glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_size);
203 static bool warned =
false;
204 if (h > max_size ||
w > max_size)
208 warning (
"opengl_texture::create: the opengl library in use "
209 "doesn't support images with either dimension larger "
210 "than %d. Not rendering.", max_size);
232 for (
int i = 0; i < h; i++)
234 for (
int j = 0, idx = i*tw*3; j <
w; j++, idx += 3)
236 a[idx] = xdata(i,j,0);
237 a[idx+1] = xdata(i,j,1);
238 a[idx+2] = xdata(i,j,2);
242 glfcns.
glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0, GL_RGB,
252 for (
int i = 0; i < h; i++)
254 for (
int j = 0, idx = i*tw*3; j <
w; j++, idx += 3)
256 a[idx] = xdata(i,j,0);
257 a[idx+1] = xdata(i,j,1);
258 a[idx+2] = xdata(i,j,2);
262 glfcns.
glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0, GL_RGB,
271 for (
int i = 0; i < h; i++)
273 for (
int j = 0, idx = i*tw*3; j <
w; j++, idx += 3)
275 a[idx] = xdata(i,j,0);
276 a[idx+1] = xdata(i,j,1);
277 a[idx+2] = xdata(i,j,2);
282 GL_RGB, GL_UNSIGNED_SHORT, a);
290 for (
int i = 0; i < h; i++)
292 for (
int j = 0, idx = i*tw*3; j <
w; j++, idx += 3)
294 a[idx] = xdata(i,j,0);
295 a[idx+1] = xdata(i,j,1);
296 a[idx+2] = xdata(i,j,2);
301 GL_RGB, GL_UNSIGNED_BYTE, a);
306 warning (
"opengl_texture::create: invalid image data type, expected double, single, uint8, or uint16");
311 glfcns.
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
312 glfcns.
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
315 warning (
"opengl_texture::create: OpenGL error while generating texture data");
321 warning (
"opengl_texture::create: invalid texture data size");
330 #if defined (HAVE_FRAMEWORK_OPENGL) && defined (HAVE_GLUTESSCALLBACK_THREEDOTS)
331 typedef GLvoid (
CALLBACK *fcn) (...);
347 {
if (glu_tess) gluDeleteTess (glu_tess); }
351 gluTessProperty (glu_tess, GLU_TESS_BOUNDARY_ONLY,
352 (filled ? GL_FALSE : GL_TRUE));
354 gluTessBeginPolygon (glu_tess,
this);
358 { gluTessEndPolygon (glu_tess); }
361 { gluTessBeginContour (glu_tess); }
364 { gluTessEndContour (glu_tess); }
367 { gluTessVertex (glu_tess,
loc, data); }
372 virtual void end (
void) { }
376 virtual void combine (GLdouble [3] ,
void * [4] ,
377 GLfloat [4] ,
void ** ) { }
382 {
::error (
"OpenGL tessellation error (%d)", err); }
386 glu_tess = gluNewTess ();
388 gluTessCallback (glu_tess, GLU_TESS_BEGIN_DATA,
389 reinterpret_cast<fcn
> (tess_begin));
390 gluTessCallback (glu_tess, GLU_TESS_END_DATA,
391 reinterpret_cast<fcn
> (tess_end));
392 gluTessCallback (glu_tess, GLU_TESS_VERTEX_DATA,
393 reinterpret_cast<fcn
> (tess_vertex));
394 gluTessCallback (glu_tess, GLU_TESS_COMBINE_DATA,
395 reinterpret_cast<fcn
> (tess_combine));
396 gluTessCallback (glu_tess, GLU_TESS_EDGE_FLAG_DATA,
397 reinterpret_cast<fcn
> (tess_edge_flag));
398 gluTessCallback (glu_tess, GLU_TESS_ERROR_DATA,
399 reinterpret_cast<fcn
> (tess_error));
452 : coords (), color (), vertex_normal (), face_normal (), alpha (),
453 ambient (), diffuse (), specular (), specular_exp (),
454 specular_color_refl (), count (1) { }
457 const Matrix& fn,
double a,
float as,
float ds,
float ss,
459 : coords (c), color (col), vertex_normal (vn), face_normal (fn),
460 alpha (a), ambient (as), diffuse (ds), specular (ss),
461 specular_exp (se), specular_color_refl (scr), count (1) { }
482 const Matrix& fn,
double a,
float as,
float ds,
float ss,
492 if (--rep->
count == 0)
500 if (--rep->
count == 0)
520 color_mode (cmode), light_mode (lmode), face_lighting (fl), index (idx),
521 first (true), tmp_vdata ()
538 renderer->set_polygon_offset (
true, index);
549 renderer->set_polygon_offset (
false);
563 if (color_mode ==
INTERP || (color_mode ==
FLAT && ! is_filled ()))
567 if (col.
numel () == 3)
573 float buf[4] = { 0.0f, 0.0f, 0.0f, 1.0f };;
576 for (
int k = 0; k < 3; k++)
582 for (
int k = 0; k < 3; k++)
583 buf[k] = (v->
diffuse * col(k));
586 for (
int k = 0; k < 3; k++)
587 buf[k] = (v->
ambient * col(k));
593 if (light_mode ==
FLAT && first)
595 else if (light_mode ==
GOURAUD)
603 void combine (GLdouble xyz[3],
void *data[4], GLfloat
w[4],
void **out_data)
610 for (
int i = 0; i < 4; i++)
614 if (vmax == 4 && ! v[i])
628 if (v[0]->color.numel ())
631 for (
int ic = 0; ic < 3; ic++)
632 for (
int iv = 0; iv < vmax; iv++)
633 cc(ic) += (
w[iv] * v[iv]->
color (ic));
636 if (v[0]->vertex_normal.numel () > 0)
638 for (
int in = 0; in < 3; in++)
639 for (
int iv = 0; iv < vmax; iv++)
643 if (v[0]->face_normal.numel () > 0)
645 for (
int in = 0; in < 3; in++)
646 for (
int iv = 0; iv < vmax; iv++)
650 for (
int iv = 0; iv < vmax; iv++)
651 aa += (
w[iv] * v[iv]->alpha);
653 vertex_data new_v (vv, cc, vnn, fnn, aa, v[0]->ambient, v[0]->diffuse,
654 v[0]->specular, v[0]->specular_exp,
655 v[0]->specular_color_refl);
656 tmp_vdata.push_back (new_v);
689 : m_glfcns (glfcns),
xmin (),
xmax (), ymin (), ymax (), zmin (), zmax (),
690 m_devpixratio (1.0),
xform (), toolkit (), xZ1 (), xZ2 (), marker_id (),
691 filled_marker_id (), camera_pos (), camera_dir (), view_vector (),
692 interpreter (
"none"), txt_renderer (), m_current_light (0),
693 m_max_lights (0), selecting (false), m_printing (false)
699 #if defined (HAVE_OPENGL)
704 static bool ok = (
sizeof (int) <=
sizeof (GLsizei));
707 error (
"the size of GLsizei is smaller than the size of int");
727 if (go.
isa (
"figure"))
729 else if (go.
isa (
"axes"))
731 else if (go.
isa (
"line"))
733 else if (go.
isa (
"surface"))
735 else if (go.
isa (
"patch"))
737 else if (go.
isa (
"light"))
739 else if (go.
isa (
"hggroup"))
741 else if (go.
isa (
"text"))
743 else if (go.
isa (
"image"))
745 else if (go.
isa (
"uimenu") || go.
isa (
"uicontrol")
746 || go.
isa (
"uicontextmenu") || go.
isa (
"uitoolbar")
747 || go.
isa (
"uipushtool") || go.
isa (
"uitoggletool")
748 || go.
isa (
"uitable"))
750 else if (go.
isa (
"uipanel"))
755 else if (go.
isa (
"uibuttongroup"))
762 warning (
"opengl_renderer: cannot render object of type '%s'",
766 #if defined (HAVE_OPENGL)
770 warning (
"opengl_renderer: Error '%s' (%d) occurred drawing '%s' object",
782 init_gl_context (props.is_graphicssmoothing (), props.get_color_rgb ());
784 #if defined (HAVE_OPENGL)
786 props.set___gl_extensions__ (
get_string (GL_EXTENSIONS));
787 props.set___gl_renderer__ (
get_string (GL_RENDERER));
788 props.set___gl_vendor__ (
get_string (GL_VENDOR));
789 props.set___gl_version__ (
get_string (GL_VERSION));
809 props.get_backgroundcolor_rgb ());
827 props.get_backgroundcolor_rgb ());
837 #if defined (HAVE_OPENGL)
851 bool has_multisample =
false;
854 GLint iMultiSample, iNumSamples;
857 if (iMultiSample == GL_TRUE && iNumSamples > 0)
858 has_multisample =
true;
861 if (! has_multisample)
888 warning (
"opengl_renderer: Error '%s' (%d) occurred in init_gl_context",
889 gluErrorString (gl_error), gl_error);
893 octave_unused_parameter (enhanced);
894 octave_unused_parameter (c);
906 const std::string& gridstyle,
907 const Matrix& gridcolor,
const double gridalpha,
908 const Matrix& ticks,
double lim1,
double lim2,
909 double p1,
double p1N,
double p2,
double p2N,
912 #if defined (HAVE_OPENGL)
917 for (
int i = 0; i < ticks.
numel (); i++)
919 double val = ticks(i);
920 if (lim1 <= val && val <= lim2)
953 double black[3] = {0, 0, 0};
958 octave_unused_parameter (linewidth);
959 octave_unused_parameter (gridstyle);
960 octave_unused_parameter (gridcolor);
961 octave_unused_parameter (gridalpha);
962 octave_unused_parameter (ticks);
963 octave_unused_parameter (lim1);
964 octave_unused_parameter (lim2);
965 octave_unused_parameter (p1);
966 octave_unused_parameter (p1N);
967 octave_unused_parameter (p2);
968 octave_unused_parameter (p2N);
969 octave_unused_parameter (xyz);
970 octave_unused_parameter (is_3D);
982 double lim1,
double lim2,
983 double p1,
double p1N,
984 double p2,
double p2N,
985 double dx,
double dy,
double dz,
986 int xyz,
bool mirror)
988 #if defined (HAVE_OPENGL)
992 for (
int i = 0; i < ticks.
numel (); i++)
994 double val = ticks(i);
996 if (lim1 <= val && val <= lim2)
1035 octave_unused_parameter (ticks);
1036 octave_unused_parameter (lim1);
1037 octave_unused_parameter (lim2);
1038 octave_unused_parameter (p1);
1039 octave_unused_parameter (p1N);
1040 octave_unused_parameter (p2);
1041 octave_unused_parameter (p2N);
1042 octave_unused_parameter (dx);
1043 octave_unused_parameter (dy);
1044 octave_unused_parameter (dz);
1045 octave_unused_parameter (xyz);
1046 octave_unused_parameter (mirror);
1059 double lim1,
double lim2,
1060 double p1,
double p2,
1061 int xyz,
int ha,
int va,
1062 int& wmax,
int& hmax)
1064 #if defined (HAVE_OPENGL)
1066 int nticks = ticks.
numel ();
1067 int nlabels = ticklabels.
numel ();
1072 for (
int i = 0; i < nticks; i++)
1074 double val = ticks(i);
1076 if (lim1 <= val && val <= lim2)
1080 std::string label (ticklabels(i % nlabels));
1081 label.erase (0, label.find_first_not_of (
' '));
1082 label = label.substr (0, label.find_last_not_of (
' ')+1);
1099 wmax =
std::max (wmax,
static_cast<int> (b(2)));
1100 hmax =
std::max (hmax,
static_cast<int> (b(3)));
1106 octave_unused_parameter (ticks);
1107 octave_unused_parameter (ticklabels);
1108 octave_unused_parameter (lim1);
1109 octave_unused_parameter (lim2);
1110 octave_unused_parameter (p1);
1111 octave_unused_parameter (p2);
1112 octave_unused_parameter (xyz);
1113 octave_unused_parameter (ha);
1114 octave_unused_parameter (va);
1115 octave_unused_parameter (wmax);
1116 octave_unused_parameter (hmax);
1129 #if defined (HAVE_OPENGL)
1139 octave_unused_parameter (x1);
1140 octave_unused_parameter (x2);
1141 octave_unused_parameter (y1);
1142 octave_unused_parameter (y2);
1154 int x1,
int y1,
int x2,
int y2,
1155 const Matrix& overlaycolor,
1156 double overlayalpha,
1157 const Matrix& bordercolor,
1158 double borderalpha,
double borderwidth)
1160 #if defined (HAVE_OPENGL)
1197 octave_unused_parameter (width);
1198 octave_unused_parameter (height);
1199 octave_unused_parameter (x1);
1200 octave_unused_parameter (x2);
1201 octave_unused_parameter (y1);
1202 octave_unused_parameter (y2);
1203 octave_unused_parameter (overlaycolor);
1204 octave_unused_parameter (overlayalpha);
1205 octave_unused_parameter (bordercolor);
1206 octave_unused_parameter (borderalpha);
1207 octave_unused_parameter (borderwidth);
1220 #if defined (HAVE_OPENGL)
1239 return pix.
permute (perm).index (idx);
1246 octave_unused_parameter (width);
1247 octave_unused_parameter (height);
1257 #if defined (HAVE_OPENGL)
1274 #if defined (HAVE_OPENGL)
1280 xZ1 =
std::max (-1e6, x_zlim(0)-(x_zlim(1)-x_zlim(0))*100.0);
1281 xZ2 =
std::min (1e6, x_zlim(1)+(x_zlim(1)-x_zlim(0))*100.0);
1306 octave_unused_parameter (props);
1319 #if defined (HAVE_OPENGL)
1321 Matrix axe_color = props.get_color_rgb ();
1322 if (axe_color.
isempty () || ! props.is_visible ())
1366 octave_unused_parameter (props);
1379 #if defined (HAVE_OPENGL)
1381 if (! props.is_visible ())
1387 bool isXOrigin = props.xaxislocation_is (
"origin")
1388 && ! props.yscale_is (
"log");
1389 bool isYOrigin = props.yaxislocation_is (
"origin")
1390 && ! props.xscale_is (
"log");
1391 bool boxFull = (props.get_boxstyle () ==
"full");
1392 double linewidth = props.get_linewidth ();
1406 bool plotyy = (props.
has_property (
"__plotyy_axes__"));
1416 std::swap (zpTick, zpTickN);
1419 Matrix color = props.get_xcolor_rgb ();
1425 if (! isXOrigin || props.is_box() || ! is2D)
1431 if (props.is_box ())
1449 color = props.get_ycolor_rgb ();
1454 if (! isYOrigin || props.is_box() || ! is2D)
1460 if (props.is_box () && ! plotyy)
1479 color = props.get_zcolor_rgb ();
1481 if (! color.
isempty () && ! is2D)
1496 if (props.is_box ())
1526 octave_unused_parameter (props);
1539 #if defined (HAVE_OPENGL)
1547 && (props.is_visible ()
1548 || (
selecting && props.pickableparts_is (
"all"))))
1557 double fy = props.
get_fy ();
1558 double fz = props.
get_fz ();
1575 bool do_xminortick = props.is_xminortick () && ! xticks.
isempty ();
1576 string_vector xticklabels = props.get_xticklabel ().string_vector_value ();
1579 bool tick_along_z = nearhoriz ||
math::isinf (fy);
1580 double linewidth = props.get_linewidth ();
1581 std::string gridstyle = props.get_gridlinestyle ();
1582 std::string minorgridstyle = props.get_minorgridlinestyle ();
1583 Matrix gridcolor = props.get_gridcolor_rgb ();
1584 Matrix minorgridcolor = props.get_minorgridcolor_rgb ();
1585 double gridalpha = props.get_gridalpha ();
1586 double minorgridalpha = props.get_minorgridalpha ();
1587 bool do_xgrid = (props.is_xgrid () && (gridstyle !=
"none"));
1588 bool do_xminorgrid = (props.is_xminorgrid ()
1589 && (minorgridstyle !=
"none")
1591 bool is_origin = props.xaxislocation_is (
"origin") && props.
get_is2D ()
1592 && ! props.yscale_is (
"log");
1593 bool is_origin_low = is_origin && (y_min + y_max) < 0;
1594 bool mirror = props.is_box () && xstate !=
AXE_ANY_DIR;
1599 if (props.gridcolormode_is (
"auto"))
1600 if (props.xcolormode_is (
"manual") && ! props.xcolor_is (
"none"))
1601 gridcolor = props.get_xcolor_rgb ();
1603 if (props.minorgridcolormode_is (
"auto"))
1604 if (props.xcolormode_is (
"manual") && ! props.xcolor_is (
"none"))
1605 minorgridcolor = props.get_xcolor_rgb ();
1610 if (minorgridcolor.
isempty ())
1611 do_xminorgrid =
false;
1614 if (do_xminorgrid && ! do_xgrid)
1616 gridstyle = minorgridstyle;
1617 gridcolor = minorgridcolor;
1618 gridalpha = minorgridalpha;
1625 minorgridstyle, minorgridcolor, minorgridalpha,
1626 xmticks, x_min, x_max,
1627 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1633 gridstyle, gridcolor, gridalpha,
1634 xticks, x_min, x_max,
1635 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1639 if (props.xcolor_is (
"none"))
1645 double y_axis_pos = 0.;
1661 is_origin ? y_axis_pos : ypTick, ypTick,
1662 zpTick, zpTickN, 0., 0.,
1663 (is_origin_low ? -1. : 1.) *
1665 0, ! is_origin && mirror);
1668 is_origin ? y_axis_pos : ypTick, ypTickN,
1670 (is_origin_low ? -1. : 1.) *
1672 0., 0, ! is_origin && mirror);
1678 is_origin ? y_axis_pos : ypTick, ypTick,
1679 zpTick, zpTickN, 0., 0.,
1680 (is_origin_low ? -1. : 1.) *
1682 0, ! is_origin && mirror);
1685 is_origin ? y_axis_pos : ypTick, ypTickN,
1687 (is_origin_low ? -1. : 1.) *
1689 0., 0, ! is_origin && mirror);
1692 if (xticklabels.
numel () > 0)
1696 : (xyzSym || is_origin_low ? 0 : 2));
1699 : (x2Dtop || is_origin_low ? 0 : 2));
1703 is_origin ? y_axis_pos : ypTick,
1705 (is_origin_low ? -1. : 1.) *
1707 0, halign, valign, wmax, hmax);
1710 (is_origin ? y_axis_pos : ypTick) +
1711 (is_origin_low ? -1. : 1.) *
1713 zpTick, 0, halign, valign, wmax, hmax);
1716 gh_mgr.
get_object (props.get_xlabel ()).
set (
"visible",
"on");
1719 gh_mgr.
get_object (props.get_xlabel ()).
set (
"visible",
"off");
1723 octave_unused_parameter (props);
1736 #if defined (HAVE_OPENGL)
1744 && (props.is_visible ()
1745 || (
selecting && props.pickableparts_is (
"all"))))
1754 double fx = props.
get_fx ();
1755 double fz = props.
get_fz ();
1772 bool do_yminortick = props.is_yminortick () && ! yticks.
isempty ();
1773 string_vector yticklabels = props.get_yticklabel ().string_vector_value ();
1776 bool tick_along_z = nearhoriz ||
math::isinf (fx);
1777 double linewidth = props.get_linewidth ();
1778 std::string gridstyle = props.get_gridlinestyle ();
1779 std::string minorgridstyle = props.get_minorgridlinestyle ();
1780 Matrix gridcolor = props.get_gridcolor_rgb ();
1781 Matrix minorgridcolor = props.get_minorgridcolor_rgb ();
1782 double gridalpha = props.get_gridalpha ();
1783 double minorgridalpha = props.get_minorgridalpha ();
1784 bool do_ygrid = (props.is_ygrid () && (gridstyle !=
"none"));
1785 bool do_yminorgrid = (props.is_yminorgrid ()
1786 && (minorgridstyle !=
"none")
1788 bool is_origin = props.yaxislocation_is (
"origin") && props.
get_is2D ()
1789 && ! props.xscale_is (
"log");
1790 bool is_origin_low = is_origin && (x_min + x_max) < 0;
1791 bool mirror = props.is_box () && ystate !=
AXE_ANY_DIR
1797 if (props.gridcolormode_is (
"auto"))
1798 if (props.ycolormode_is (
"manual") && ! props.ycolor_is (
"none"))
1799 gridcolor = props.get_ycolor_rgb ();
1801 if (props.minorgridcolormode_is (
"auto"))
1802 if (props.ycolormode_is (
"manual") && ! props.ycolor_is (
"none"))
1803 minorgridcolor = props.get_ycolor_rgb ();
1808 if (minorgridcolor.
isempty ())
1809 do_yminorgrid =
false;
1812 if (do_yminorgrid && ! do_ygrid)
1814 gridstyle = minorgridstyle;
1815 gridcolor = minorgridcolor;
1816 gridalpha = minorgridalpha;
1823 minorgridstyle, minorgridcolor, minorgridalpha,
1824 ymticks, y_min, y_max,
1825 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1831 gridstyle, gridcolor, gridalpha,
1832 yticks, y_min, y_max,
1833 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1837 if (props.ycolor_is (
"none"))
1843 double x_axis_pos = 0.;
1859 is_origin ? x_axis_pos : xpTick, xpTick,
1860 zpTick, zpTickN, 0., 0.,
1861 (is_origin_low ? -1. : 1.) *
1863 1, ! is_origin && mirror);
1866 is_origin ? x_axis_pos : xpTick, xpTickN,
1868 (is_origin_low ? -1. : 1.) *
1870 0., 0., 1, ! is_origin && mirror);
1876 is_origin ? x_axis_pos : xpTick, xpTick,
1877 zpTick, zpTickN, 0., 0.,
1878 (is_origin_low ? -1. : 1.) *
1880 1, ! is_origin && mirror);
1883 is_origin ? x_axis_pos : xpTick, xpTickN,
1885 (is_origin_low ? -1. : 1.) *
1887 0., 0., 1, ! is_origin && mirror);
1890 if (yticklabels.
numel () > 0)
1894 : (! xyzSym || y2Dright || is_origin_low ? 0 : 2));
1897 : (is_origin_low ? 0 : 2));
1901 is_origin ? x_axis_pos : xpTick,
1903 (is_origin_low ? -1. : 1.) *
1905 1, halign, valign, wmax, hmax);
1908 (is_origin ? x_axis_pos : xpTick) +
1909 (is_origin_low ? -1. : 1.) *
1911 zpTick, 1, halign, valign, wmax, hmax);
1914 gh_mgr.
get_object (props.get_ylabel ()).
set (
"visible",
"on");
1917 gh_mgr.
get_object (props.get_ylabel ()).
set (
"visible",
"off");
1921 octave_unused_parameter (props);
1940 && (props.is_visible ()
1941 || (
selecting && props.pickableparts_is (
"all"))))
1947 double fx = props.
get_fx ();
1948 double fy = props.
get_fy ();
1959 bool do_zminortick = props.is_zminortick () && ! zticks.
isempty ();
1960 string_vector zticklabels = props.get_zticklabel ().string_vector_value ();
1963 double linewidth = props.get_linewidth ();
1964 std::string gridstyle = props.get_gridlinestyle ();
1965 std::string minorgridstyle = props.get_minorgridlinestyle ();
1966 Matrix gridcolor = props.get_gridcolor_rgb ();
1967 Matrix minorgridcolor = props.get_minorgridcolor_rgb ();
1968 double gridalpha = props.get_gridalpha ();
1969 double minorgridalpha = props.get_minorgridalpha ();
1970 bool do_zgrid = (props.is_zgrid () && (gridstyle !=
"none"));
1971 bool do_zminorgrid = (props.is_zminorgrid ()
1972 && (minorgridstyle !=
"none")
1974 bool mirror = props.is_box () && zstate !=
AXE_ANY_DIR;
1979 if (props.gridcolormode_is (
"auto"))
1980 if (props.zcolormode_is (
"manual") && ! props.zcolor_is (
"none"))
1981 gridcolor = props.get_zcolor_rgb ();
1983 if (props.minorgridcolormode_is (
"auto"))
1984 if (props.zcolormode_is (
"manual") && ! props.zcolor_is (
"none"))
1985 minorgridcolor = props.get_zcolor_rgb ();
1990 if (minorgridcolor.
isempty ())
1991 do_zminorgrid =
false;
1994 if (do_zminorgrid && ! do_zgrid)
1996 gridstyle = minorgridstyle;
1997 gridcolor = minorgridcolor;
1998 gridalpha = minorgridalpha;
2005 minorgridstyle, minorgridcolor, minorgridalpha,
2006 zmticks, z_min, z_max,
2007 xPlane, xPlaneN, yPlane, yPlaneN, 2,
true);
2012 gridstyle, gridcolor, gridalpha,
2013 zticks, z_min, z_max,
2014 xPlane, xPlaneN, yPlane, yPlaneN, 2,
true);
2017 if (props.zcolor_is (
"none"))
2042 yPlaneN, yPlane, 0.,
2071 yPlaneN, yPlane, 0.,
2082 if (zticklabels.
numel () > 0)
2085 int valign = (zstate ==
AXE_VERT_DIR ? 1 : (zSign ? 3 : 2));
2091 xPlaneN +
math::signum (xPlaneN-xPlane)*fx*ztickoffset,
2092 yPlane, 2, halign, valign, wmax, hmax);
2096 2, halign, valign, wmax, hmax);
2102 yPlaneN +
math::signum (yPlaneN-yPlane)*fy*ztickoffset,
2103 2, halign, valign, wmax, hmax);
2107 yPlaneN, 2, halign, valign, wmax, hmax);
2111 gh_mgr.
get_object (props.get_zlabel ()).
set (
"visible",
"on");
2114 gh_mgr.
get_object (props.get_zlabel ()).
set (
"visible",
"off");
2120 #if defined (HAVE_OPENGL)
2122 GLboolean antialias;
2126 if (antialias == GL_TRUE)
2138 if (antialias == GL_TRUE)
2142 octave_unused_parameter (props);
2154 std::list<graphics_object>& obj_list)
2156 #if defined (HAVE_OPENGL)
2169 || (
selecting && p.pickableparts_is (
"all")))
2180 else if (go.
isa (
"hggroup")
2181 && ! (
selecting && p.pickableparts_is (
"none")))
2183 else if (! (
selecting && p.pickableparts_is (
"none")))
2184 obj_list.push_back (go);
2189 octave_unused_parameter (props);
2190 octave_unused_parameter (obj_list);
2203 #if defined (HAVE_OPENGL)
2205 std::list<graphics_object> obj_list;
2206 std::list<graphics_object>::iterator it;
2222 "light: Maximum number of lights (%d) in these axes is "
2234 view_vector = props.get_cameraposition ().matrix_value ();
2236 float cb[4] = { 1.0, 1.0, 1.0, 1.0 };
2237 ColumnVector ambient_color = props.get_ambientlightcolor_rgb ();
2238 for (
int i = 0; i < 3; i++)
2239 cb[i] = ambient_color(i);
2244 it = obj_list.begin ();
2245 while (it != obj_list.end ())
2256 it = obj_list.erase (it);
2266 for (it = obj_list.begin (); it != obj_list.end (); it++)
2281 octave_unused_parameter (props);
2294 #if defined (HAVE_OPENGL)
2297 if (! props.is_visible () && props.get_tag () ==
"legend")
2302 if (
selecting && props.pickableparts_is (
"none"))
2314 if (x_max > floatmax || y_max > floatmax || z_max > floatmax
2315 || x_min < -floatmax || y_min < -floatmax || z_min < -floatmax)
2317 warning (
"opengl_renderer: data values greater than float capacity. (1) Scale data, or (2) Use gnuplot");
2333 if (! is2D || props.layer_is (
"bottom"))
2336 if (props.get_tag () !=
"legend" || props.get_box () !=
"off")
2340 set_clipbox (x_min, x_max, y_min, y_max, z_min, z_max);
2344 if (is2D && props.layer_is (
"top"))
2347 if (props.get_tag () !=
"legend" || props.get_box () !=
"off")
2353 octave_unused_parameter (props);
2366 #if defined (HAVE_OPENGL)
2368 bool draw_all =
selecting && props.pickableparts_is (
"all");
2374 bool has_z = (z.
numel () > 0);
2378 uint8_t clip_mask = (props.is_clipping () ? 0x7F : 0x40);
2379 uint8_t clip_ok = 0x40;
2381 std::vector<uint8_t> clip (
n);
2384 for (
int i = 0; i <
n; i++)
2385 clip[i] = (
clip_code (
x(i), y(i), z(i)) & clip_mask);
2390 for (
int i = 0; i <
n; i++)
2391 clip[i] = (
clip_code (
x(i), y(i), z_mid) & clip_mask);
2394 if (! props.linestyle_is (
"none") && ! props.color_is (
"none"))
2397 set_linestyle (props.get_linestyle (),
false, props.get_linewidth ());
2406 for (
int i = 1; i <
n; i++)
2408 if ((clip[i-1] & clip[i]) == clip_ok)
2432 for (
int i = 1; i <
n; i++)
2434 if ((clip[i-1] & clip[i]) == clip_ok)
2461 if (! props.marker_is (
"none")
2462 && ! (props.markeredgecolor_is (
"none")
2463 && props.markerfacecolor_is (
"none")))
2469 else if (props.markeredgecolor_is (
"auto"))
2470 lc = props.get_color_rgb ();
2471 else if (! props.markeredgecolor_is (
"none"))
2472 lc = props.get_markeredgecolor_rgb ();
2476 if (props.markerfacecolor_is (
"auto"))
2477 fc = props.get_color_rgb ();
2478 else if (! props.markerfacecolor_is (
"none"))
2479 fc = props.get_markerfacecolor_rgb ();
2481 init_marker (props.get_marker (), props.get_markersize (),
2482 props.get_linewidth ());
2484 for (
int i = 0; i <
n; i++)
2486 if (clip[i] == clip_ok)
2499 octave_unused_parameter (props);
2512 #if defined (HAVE_OPENGL)
2514 bool draw_all =
selecting && props.pickableparts_is (
"all");
2524 const NDArray vn = props.get_vertexnormals ().array_value ();
2526 bool has_vertex_normals = (vn_dims(0) == zr && vn_dims(1) == zc
2527 && vn_dims(2) == 3);
2528 const NDArray fn = props.get_facenormals ().array_value ();
2530 bool has_face_normals = (fn_dims(0) == zr - 1 && fn_dims(1) == zc - 1
2531 && fn_dims(2) == 3);
2536 int fc_mode = (props.facecolor_is_rgb () ? 0 :
2537 (props.facecolor_is (
"flat") ? 1 :
2538 (props.facecolor_is (
"interp") ? 2 :
2539 (props.facecolor_is (
"texturemap") ? 3 : -1))));
2540 int fl_mode = (props.facelighting_is (
"none") ? 0 :
2541 (props.facelighting_is (
"flat") ?
2542 (has_face_normals ? 1 : 0) :
2543 (has_vertex_normals ? 2 : 0)));
2544 int fa_mode = (props.facealpha_is_double () ? 0 :
2545 (props.facealpha_is (
"flat") ? 1 : 2));
2546 int ec_mode = (props.edgecolor_is_rgb () ? 0 :
2547 (props.edgecolor_is (
"flat") ? 1 :
2548 (props.edgecolor_is (
"interp") ? 2 : -1)));
2549 int el_mode = (props.edgelighting_is (
"none") ? 0 :
2550 (props.edgelighting_is (
"flat") ?
2551 (has_face_normals ? 1 : 0) :
2552 (has_vertex_normals ? 2 : 0)));
2553 int ea_mode = (props.edgealpha_is_double () ? 0 :
2554 (props.edgealpha_is (
"flat") ? 1 : 2));
2555 int bfl_mode = (props.backfacelighting_is (
"lit") ? 0 :
2556 (props.backfacelighting_is (
"reverselit") ? 1 : 2));
2560 : props.get_facecolor_rgb ());
2561 Matrix ecolor = props.get_edgecolor_rgb ();
2564 float as = props.get_ambientstrength ();
2565 float ds = props.get_diffusestrength ();
2566 float ss = props.get_specularstrength ();
2567 float se = props.get_specularexponent () * 5;
2568 float scr = props.get_specularcolorreflectance ();
2569 float cb[4] = { 0.0, 0.0, 0.0, 1.0 };
2574 bool x_mat = (
x.rows () == z.
rows ());
2577 i1 = i2 = j1 = j2 = 0;
2579 if ((fc_mode > 0 && fc_mode < 3) || ec_mode > 0)
2584 for (
int i = 0; i < zr; i++)
2589 for (
int j = 0; j < zc; j++)
2598 if (fa_mode > 0 || ea_mode > 0)
2604 if (fl_mode > 0 || el_mode > 0)
2612 if (draw_all || ! props.facecolor_is (
"none"))
2616 fa = props.get_facealpha_double ();
2623 for (
int i = 0; i < 3; i++)
2624 cb[i] = as * fcolor(i);
2627 for (
int i = 0; i < 3; i++)
2628 cb[i] = ds * fcolor(i);
2631 for (
int i = 0; i < 3; i++)
2632 cb[i] = ss * (scr + (1-scr) * fcolor(i));
2637 if ((fl_mode > 0) && do_lighting)
2640 ? GL_SMOOTH : GL_FLAT);
2645 for (
int i = 1; i < zc; i++)
2653 for (
int j = 1; j < zr; j++)
2656 if (clip(j-1, i-1) || clip(j, i-1)
2657 || clip(j-1, i) || clip(j, i))
2660 if (fc_mode ==
FLAT)
2666 else if (fc_mode ==
INTERP)
2685 double (j-1) / (zr-1));
2686 else if (fc_mode > 0)
2689 for (
int k = 0; k < 3; k++)
2690 cb[k] = c(j-1, i-1, k);
2695 for (
int k = 0; k < 3; k++)
2699 for (
int k = 0; k < 3; k++)
2700 cb[k] = ds * c(j-1, i-1, k);
2703 for (
int k = 0; k < 3; k++)
2704 cb[k] = ss * (scr + (1-scr) * c(j-1, i-1, k));
2716 tex.
tex_coord (
double (i) / (zc-1),
double (j-1) / (zr-1));
2717 else if (fc_mode ==
INTERP)
2719 for (
int k = 0; k < 3; k++)
2720 cb[k] = c(j-1, i, k);
2725 for (
int k = 0; k < 3; k++)
2729 for (
int k = 0; k < 3; k++)
2730 cb[k] = ds * c(j-1, i, k);
2733 for (
int k = 0; k < 3; k++)
2734 cb[k] = ss * (scr + (1-scr) * c(j-1, i, k));
2746 tex.
tex_coord (
double (i) / (zc-1),
double (j) / (zr-1));
2747 else if (fc_mode ==
INTERP)
2749 for (
int k = 0; k < 3; k++)
2755 for (
int k = 0; k < 3; k++)
2759 for (
int k = 0; k < 3; k++)
2760 cb[k] = ds * c(j, i, k);
2763 for (
int k = 0; k < 3; k++)
2764 cb[k] = ss * (scr + (1-scr) * c(j, i, k));
2775 tex.
tex_coord (
double (i-1) / (zc-1),
double (j) / (zr-1));
2776 else if (fc_mode ==
INTERP)
2778 for (
int k = 0; k < 3; k++)
2779 cb[k] = c(j, i-1, k);
2784 for (
int k = 0; k < 3; k++)
2788 for (
int k = 0; k < 3; k++)
2789 cb[k] = ds * c(j, i-1, k);
2792 for (
int k = 0; k < 3; k++)
2793 cb[k] = ss * (scr + (1-scr) * c(j, i-1, k));
2810 if ((fl_mode > 0) && do_lighting)
2819 if (! props.edgecolor_is (
"none") && ! props.linestyle_is (
"none"))
2821 if (props.get_edgealpha_double () == 1)
2829 for (
int i = 0; i < 3; i++)
2830 cb[i] = as * ecolor(i);
2833 for (
int i = 0; i < 3; i++)
2834 cb[i] = ds * ecolor(i);
2837 for (
int i = 0; i < 3; i++)
2838 cb[i] = ss * (scr + (1-scr) * ecolor(i));
2843 if ((el_mode > 0) && do_lighting)
2846 ? GL_SMOOTH : GL_FLAT);
2849 props.get_linewidth ());
2856 if (props.meshstyle_is (
"both") || props.meshstyle_is (
"column"))
2858 for (
int i = 0; i < zc; i++)
2866 for (
int j = 1; j < zr; j++)
2868 if (clip(j-1,i) || clip(j,i))
2871 if (ec_mode ==
FLAT)
2877 else if (ec_mode ==
INTERP)
2895 for (
int k = 0; k < 3; k++)
2896 cb[k] = c(j-1, i, k);
2901 for (
int k = 0; k < 3; k++)
2905 for (
int k = 0; k < 3; k++)
2906 cb[k] = ds * c(j-1, i, k);
2909 for (
int k = 0; k < 3; k++)
2910 cb[k] = ss * (scr + (1-scr) * c(j-1, i, k));
2927 for (
int k = 0; k < 3; k++)
2933 for (
int k = 0; k < 3; k++)
2937 for (
int k = 0; k < 3; k++)
2938 cb[k] = ds * c(j, i, k);
2941 for (
int k = 0; k < 3; k++)
2942 cb[k] = ss * (scr + (1-scr) * c(j, i, k));
2958 if (props.meshstyle_is (
"both") || props.meshstyle_is (
"row"))
2960 for (
int j = 0; j < zr; j++)
2968 for (
int i = 1; i < zc; i++)
2970 if (clip(j,i-1) || clip(j,i))
2973 if (ec_mode ==
FLAT)
2979 else if (ec_mode ==
INTERP)
2997 for (
int k = 0; k < 3; k++)
2998 cb[k] = c(j, i-1, k);
3003 for (
int k = 0; k < 3; k++)
3007 for (
int k = 0; k < 3; k++)
3008 cb[k] = ds * c(j, i-1, k);
3011 for (
int k = 0; k < 3; k++)
3012 cb[k] = ss * (scr + (1-scr) * c(j, i-1, k));
3029 for (
int k = 0; k < 3; k++)
3035 for (
int k = 0; k < 3; k++)
3039 for (
int k = 0; k < 3; k++)
3040 cb[k] = ds * c(j, i, k);
3043 for (
int k = 0; k < 3; k++)
3044 cb[k] = ss * (scr + (1-scr) * c(j, i, k));
3061 if ((el_mode > 0) && do_lighting)
3070 if (! props.marker_is (
"none")
3071 && ! (props.markeredgecolor_is (
"none")
3072 && props.markerfacecolor_is (
"none")))
3078 bool do_edge = draw_all || ! props.markeredgecolor_is (
"none");
3079 bool do_face = draw_all || ! props.markerfacecolor_is (
"none");
3082 props.get_markeredgecolor_rgb ());
3084 props.get_markerfacecolor_rgb ());
3087 if (mecolor.
isempty () && props.markeredgecolor_is (
"auto"))
3089 mecolor = props.get_edgecolor_rgb ();
3090 do_edge = ! props.edgecolor_is (
"none");
3093 if (mfcolor.
isempty () && props.markerfacecolor_is (
"auto"))
3095 mfcolor = props.get_facecolor_rgb ();
3096 do_face = ! props.facecolor_is (
"none");
3102 init_marker (props.get_marker (), props.get_markersize (),
3103 props.get_linewidth ());
3105 uint8_t clip_mask = (props.is_clipping () ? 0x7F : 0x40);
3106 uint8_t clip_ok = 0x40;
3108 for (
int i = 0; i < zc; i++)
3113 for (
int j = 0; j < zr; j++)
3118 if ((
clip_code (
x(j1,i), y(j,i1), z(j,i)) & clip_mask)
3122 if ((do_edge && mecolor.
isempty ())
3123 || (do_face && mfcolor.
isempty ()))
3128 for (
int k = 0; k < 3; k++)
3146 octave_unused_parameter (props);
3161 #if defined (HAVE_OPENGL)
3167 warning (
"opengl_renderer: %s. Not rendering.", msg.c_str ());
3171 bool draw_all =
selecting && props.pickableparts_is (
"all");
3172 const Matrix f = props.get_faces ().matrix_value ();
3180 int fcmax =
f.columns ();
3182 bool has_z = (v.
columns () > 2);
3183 bool has_facecolor =
false;
3184 bool has_facealpha =
false;
3186 int fc_mode = ((props.facecolor_is (
"none")
3187 || props.facecolor_is_rgb () || draw_all) ? 0 :
3188 (props.facecolor_is (
"flat") ? 1 : 2));
3189 int fl_mode = (props.facelighting_is (
"none") ? 0 :
3190 (props.facelighting_is (
"flat") ? 1 : 2));
3191 int fa_mode = (props.facealpha_is_double () ? 0 :
3192 (props.facealpha_is (
"flat") ? 1 : 2));
3193 int ec_mode = ((props.edgecolor_is (
"none")
3194 || props.edgecolor_is_rgb ()) ? 0 :
3195 (props.edgecolor_is (
"flat") ? 1 : 2));
3196 int el_mode = (props.edgelighting_is (
"none") ? 0 :
3197 (props.edgelighting_is (
"flat") ? 1 : 2));
3198 int ea_mode = (props.edgealpha_is_double () ? 0 :
3199 (props.edgealpha_is (
"flat") ? 1 : 2));
3200 int bfl_mode = (props.backfacelighting_is (
"lit") ? 0 :
3201 (props.backfacelighting_is (
"reverselit") ? 1 : 2));
3204 Matrix fcolor = props.get_facecolor_rgb ();
3205 Matrix ecolor = props.get_edgecolor_rgb ();
3207 float as = props.get_ambientstrength ();
3208 float ds = props.get_diffusestrength ();
3209 float ss = props.get_specularstrength ();
3210 float se = props.get_specularexponent () * 5;
3211 float scr = props.get_specularcolorreflectance ();
3213 const Matrix vn = props.get_vertexnormals ().matrix_value ();
3214 bool has_vertex_normals = (vn.
rows () == nv);
3215 const Matrix fn = props.get_facenormals ().matrix_value ();
3216 bool has_face_normals = (fn.
rows () == nf);
3221 for (
int i = 0; i < nv; i++)
3224 for (
int i = 0; i < nv; i++)
3230 for (
int i = 0; i < nf; i++)
3235 for (
int j = 0; j < fcmax && !
math::isnan (
f(i,j)); j++, count++)
3236 fclip = (fclip || clip(
int (
f(i,j) - 1)));
3242 if (draw_all || fc_mode > 0 || ec_mode > 0)
3253 if (draw_all || fc_mode > 0)
3259 if (draw_all || ec_mode > 0)
3268 has_facecolor = ((c.
numel () > 0) && (c.
rows () ==
f.rows ()));
3271 if (fa_mode > 0 || ea_mode > 0)
3275 has_facealpha = ((a.
numel () > 0) && (a.
rows () ==
f.rows ()));
3279 fa = props.get_facealpha_double ();
3282 std::vector<vertex_data> vdata (
f.numel ());
3284 for (
int i = 0; i < nf; i++)
3285 for (
int j = 0; j < count_f(i); j++)
3287 int idx = int (
f(i,j) - 1);
3295 vv(0) = v(idx,0); vv(1) = v(idx,1);
3298 if (((fl_mode ==
FLAT) || (el_mode ==
FLAT)) && has_face_normals)
3305 ? ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0);
3306 fnn(0) = dir * fn(i,0);
3307 fnn(1) = dir * fn(i,1);
3308 fnn(2) = dir * fn(i,2);
3310 if ((fl_mode ==
GOURAUD || el_mode ==
GOURAUD) && has_vertex_normals)
3317 ? ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0);
3318 vnn(0) = dir * vn(idx,0);
3319 vnn(1) = dir * vn(idx,1);
3320 vnn(2) = dir * vn(idx,2);
3326 cc(0) = c(i,0), cc(1) = c(i,1), cc(2) = c(i,2);
3328 cc(0) = c(idx,0), cc(1) = c(idx,1), cc(2) = c(idx,2);
3332 else if (a.
numel () > 0)
3340 vdata[i+j*fr] =
vertex_data (vv, cc, vnn, fnn, aa, as, ds, ss, se, scr);
3343 if (fl_mode > 0 || el_mode > 0)
3346 if (draw_all || ! props.facecolor_is (
"none"))
3356 float cb[4] = { 0.0f, 0.0f, 0.0f, 1.0f };;
3358 for (
int i = 0; i < 3; i++)
3359 cb[i] = as * fcolor(i);
3362 for (
int i = 0; i < 3; i++)
3363 cb[i] = ds * fcolor(i);
3366 for (
int i = 0; i < 3; i++)
3367 cb[i] = ss * (scr + (1-scr) * fcolor(i));
3372 if ((fl_mode > 0) && do_lighting)
3381 std::vector<octave_idx_type>::const_iterator it;
3384 for (
int i = 0; i < nf; i++)
3389 bool is_non_planar =
false;
3393 is_non_planar =
true;
3414 i_end = count_f(i) - 1;
3422 for (
int j = i_end; j > i_start; j--)
3425 = vdata[i+j*fr].get_rep ();
3434 if (fc_mode ==
FLAT)
3439 if (col.
numel () == 3)
3444 float cb[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
3446 for (
int k = 0; k < 3; k++)
3447 cb[k] = (vv->
ambient * col(k));
3450 for (
int k = 0; k < 3; k++)
3451 cb[k] = (vv->
diffuse * col(k));
3454 for (
int k = 0; k < 3; k++)
3469 }
while (i_start > 0);
3472 if ((fl_mode > 0) && do_lighting)
3482 || (! props.edgecolor_is (
"none") && ! props.linestyle_is (
"none")))
3485 if (props.get_edgealpha_double () == 1)
3493 float cb[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
3497 for (
int i = 0; i < 3; i++)
3498 cb[i] = (as * ecolor(i));
3503 if ((el_mode > 0) && do_lighting)
3506 double linewidth = props.get_linewidth ();
3519 for (
int i = 0; i < nf; i++)
3521 bool is_non_planar =
false;
3524 is_non_planar =
true;
3525 if (clip_f(i) || is_non_planar)
3532 ? GL_SMOOTH : GL_FLAT);
3535 for (
int j = count_f(i)-1; j >= 0; j--)
3537 if (! clip(
int (
f(i,j) - 1)))
3540 = vdata[i+j*fr].get_rep ();
3551 if (col.
numel () == 3)
3564 int j = count_f(i)-1;
3565 if (flag && ! clip(
int (
f(i,j) - 1)))
3568 = vdata[i+j*fr].get_rep ();
3574 if (col.
numel () == 3)
3588 for (
int j = count_f(i)-1; j >= 0; j--)
3591 = vdata[i+j*fr].get_rep ();
3603 if ((el_mode > 0) && do_lighting)
3612 if (! props.marker_is (
"none")
3613 && ! (props.markeredgecolor_is (
"none")
3614 && props.markerfacecolor_is (
"none")))
3616 bool do_edge = draw_all || ! props.markeredgecolor_is (
"none");
3617 bool do_face = draw_all || ! props.markerfacecolor_is (
"none");
3620 props.get_markeredgecolor_rgb ());
3622 props.get_markerfacecolor_rgb ());
3624 bool has_markerfacecolor = draw_all ||
false;
3626 if ((mecolor.
isempty () && ! props.markeredgecolor_is (
"none"))
3627 || (mfcolor.
isempty () && ! props.markerfacecolor_is (
"none")))
3631 if (mc.
rows () == 1)
3634 if (mfcolor.
isempty () && ! props.markerfacecolor_is (
"none"))
3637 if (mecolor.
isempty () && ! props.markeredgecolor_is (
"none"))
3644 has_markerfacecolor = ((c.
numel () > 0)
3645 && (c.
rows () ==
f.rows ()));
3649 init_marker (props.get_marker (), props.get_markersize (),
3650 props.get_linewidth ());
3652 uint8_t clip_mask = (props.is_clipping () ? 0x7F : 0x40);
3653 uint8_t clip_ok = 0x40;
3655 for (
int i = 0; i < nf; i++)
3656 for (
int j = 0; j < count_f(i); j++)
3658 int idx = int (
f(i,j) - 1);
3660 if ((
clip_code (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0))
3661 & clip_mask) != clip_ok)
3668 if (has_markerfacecolor)
3669 cc(0) = c(i,0), cc(1) = c(i,1), cc(2) = c(i,2);
3671 cc(0) = c(idx,0), cc(1) = c(idx,1), cc(2) = c(idx,2);
3679 draw_marker (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0), lc, fc);
3687 octave_unused_parameter (props);
3700 #if defined (HAVE_OPENGL)
3706 float pos[4] = { 0, 0, 0, 0 };
3707 Matrix lpos = props.get_position ().matrix_value ();
3708 for (
int i = 0; i < 3; i++)
3710 if (props.style_is (
"local"))
3715 float col[4] = { 1, 1, 1, 1 };
3716 Matrix lcolor = props.get_color ().matrix_value ();
3717 for (
int i = 0; i < 3; i++)
3724 octave_unused_parameter (props);
3743 #if defined (HAVE_OPENGL)
3745 if (props.get_string ().isempty () || props.color_is (
"none"))
3751 if (! props.is_clipping ()
3752 || (
clip_code (pos(0), pos(1), pos.
numel () > 2 ? pos(2) : 0.0) == 0x40))
3761 const Matrix bbox = props.get_extent_matrix ();
3770 props.get_pixels ().data ());
3777 octave_unused_parameter (props);
3791 #if defined (HAVE_OPENGL)
3793 Matrix bgcol = props.get_backgroundcolor_rgb ();
3794 Matrix ecol = props.get_edgecolor_rgb ();
3799 Matrix pos = props.get_data_position ();
3819 double rotation = props.get_rotation ();
3821 if (do_rotate && rotation != 0.0 && rotation != 90.0
3822 && rotation != 180.0 && rotation != 270.0)
3826 const Matrix bbox = props.get_extent_matrix ();
3855 set_linestyle (props.get_linestyle (),
false, props.get_linewidth ());
3876 octave_unused_parameter (props);
3877 octave_unused_parameter (do_rotate);
3890 #if defined (HAVE_OPENGL)
3896 double x0, x1, y0, y1;
3898 Matrix x = props.get_xdata ().matrix_value ();
3901 dx = (
x(1) -
x(0)) / (
w - 1);
3906 Matrix y = props.get_ydata ().matrix_value ();
3909 dy = (y(1) - y(0)) / (h - 1);
3915 if (dv.
ndims () == 3 && dv(2) == 3)
3943 warning (
"opengl_renderer: invalid image size (expected MxNx3 or MxN)");
3947 octave_unused_parameter (props);
3963 for (
int i =
len-1; i >= 0; i--)
3968 draw (obj, toplevel);
3975 #if defined (HAVE_OPENGL)
3981 octave_unused_parameter (
w);
3982 octave_unused_parameter (h);
3997 #if defined (HAVE_OPENGL)
3998 #if defined (HAVE_FRAMEWORK_OPENGL)
4006 for (
int i = 0; i < 4; i++)
4024 #if defined (HAVE_OPENGL)
4033 octave_unused_parameter (c);
4046 bool do_anti_alias = props.
get (
"fontsmoothing").
string_value () ==
"on";
4058 #if defined (HAVE_OPENGL)
4074 octave_unused_parameter (on);
4075 octave_unused_parameter (offset);
4088 #if defined (HAVE_OPENGL)
4094 octave_unused_parameter (
w);
4108 #if defined (HAVE_OPENGL)
4114 uint16_t pattern = 0xFFFF;
4146 if (solid && ! use_stipple)
4153 octave_unused_parameter (s);
4154 octave_unused_parameter (use_stipple);
4155 octave_unused_parameter (linewidth);
4167 double z1,
double z2)
4169 #if defined (HAVE_OPENGL)
4171 double dx = (x2-x1);
4172 double dy = (y2-y1);
4173 double dz = (z2-z1);
4175 x1 -= 0.001*dx; x2 += 0.001*dx;
4176 y1 -= 0.001*dy; y2 += 0.001*dy;
4177 z1 -= 0.001*dz; z2 += 0.001*dz;
4181 p(0) = -1; p(3) = x2;
4183 p(0) = 1; p(3) = -x1;
4185 p(0) = 0; p(1) = -1; p(3) = y2;
4187 p(1) = 1; p(3) = -y1;
4189 p(1) = 0; p(2) = -1; p(3) = z2;
4191 p(2) = 1; p(3) = -z1;
4200 octave_unused_parameter (x1);
4201 octave_unused_parameter (x2);
4202 octave_unused_parameter (y1);
4203 octave_unused_parameter (y2);
4204 octave_unused_parameter (z1);
4205 octave_unused_parameter (z2);
4218 #if defined (HAVE_OPENGL)
4222 if (enable != has_clipping)
4225 for (
int i = 0; i < 6; i++)
4228 for (
int i = 0; i < 6; i++)
4234 octave_unused_parameter (enable);
4247 #if defined (HAVE_OPENGL)
4265 octave_unused_parameter (
m);
4266 octave_unused_parameter (size);
4267 octave_unused_parameter (width);
4280 #if defined (HAVE_OPENGL)
4305 #if defined (HAVE_OPENGL)
4317 if (lc.
numel () > 0)
4336 octave_unused_parameter (
x);
4337 octave_unused_parameter (y);
4338 octave_unused_parameter (z);
4339 octave_unused_parameter (lc);
4340 octave_unused_parameter (fc);
4353 #if defined (HAVE_OPENGL)
4376 #if defined (HAVE_OPENGL)
4382 std::ostringstream buf;
4386 return std::string (buf.str ());
4390 octave_unused_parameter (
id);
4396 return std::string ();
4404 #if defined (HAVE_OPENGL)
4406 double x =
n(j,i,0);
4407 double y =
n(j,i,1);
4408 double z =
n(j,i,2);
4410 double d = sqrt (
x*
x + y*y + z*z);
4416 ? ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0);
4422 octave_unused_parameter (bfl_mode);
4423 octave_unused_parameter (
n);
4424 octave_unused_parameter (j);
4425 octave_unused_parameter (i);
4442 static const double pix_per_pts =
4457 #if defined (HAVE_OPENGL)
4461 if (filled && (c ==
'+' || c ==
'x' || c ==
'*' || c ==
'.'))
4470 const double sqrt2d4 = 0.35355339059327;
4471 double tt = sz*sqrt2d4;
4510 if (sz > 0 && sz < 3)
4513 int div =
static_cast<int> (M_PI * sz / 12);
4517 double ang_step = M_PI / div;
4520 for (
double ang = 0; ang < 2*M_PI; ang += ang_step)
4535 int div =
static_cast<int> (M_PI * sz / 4);
4539 double ang_step = M_PI / div;
4542 for (
double ang = 0; ang < 2*M_PI; ang += ang_step)
4586 dr = 1.0 - sin (M_PI/10)/sin (3*M_PI/10)*1.02;
4589 for (
int i = 0; i < 2*5; i++)
4591 ang = (-0.5 + double (i+1) / 5) * M_PI;
4592 r = 1.0 - (dr * fmod (
double (i+1), 2.0));
4601 dr = 1.0 - 0.5/sin (M_PI/3)*1.02;
4604 for (
int i = 0; i < 2*6; i++)
4606 ang = (0.5 + double (i+1) / 6.0) * M_PI;
4607 r = 1.0 - (dr * fmod (
double (i+1), 2.0));
4614 warning (
"opengl_renderer: unsupported marker '%s'",
marker.c_str ());
4624 octave_unused_parameter (
marker);
4625 octave_unused_parameter (size);
4626 octave_unused_parameter (filled);
4640 int halign,
int valign,
double rotation)
4648 std::list<text_renderer::string>& lst,
4650 int halign,
int valign,
double rotation)
4658 double x,
double y,
double z,
4659 int halign,
int valign,
double rotation)
4661 #if defined (HAVE_OPENGL)
4680 GL_RGBA, GL_UNSIGNED_BYTE, pixels.
data ());
4691 octave_unused_parameter (txt);
4692 octave_unused_parameter (
x);
4693 octave_unused_parameter (y);
4694 octave_unused_parameter (z);
4695 octave_unused_parameter (halign);
4696 octave_unused_parameter (valign);
4697 octave_unused_parameter (rotation);
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
octave_idx_type columns(void) const
octave_idx_type numel(void) const
Number of elements in the array.
const T * data(void) const
Size of the specified dimension.
octave_idx_type rows(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
const T * fortran_vec(void) const
Size of the specified dimension.
bool isempty(void) const
Size of the specified dimension.
MArray< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
double get_yticklen(void) const
double get_ypTickN(void) const
bool get_y2Dright(void) const
double get_yPlaneN(void) const
double get_zPlane(void) const
graphics_xform get_transform(void) const
bool get_zSign(void) const
double get_yPlane(void) const
unsigned int get_num_lights(void) const
double get_xPlaneN(void) const
double get_ypTick(void) const
bool get_layer2Dtop(void) const
double get_y_min(void) const
double get_xpTickN(void) const
bool get_is2D(bool include_kids=false) const
int get_xstate(void) const
double get_xpTick(void) const
double get_zpTickN(void) const
double get_fz(void) const
double get_zpTick(void) const
Matrix get_opengl_matrix_2(void) const
Matrix get_opengl_matrix_1(void) const
double get_zticklen(void) const
double get_xtickoffset(void) const
double get_z_min(void) const
double get_fy(void) const
bool get_xyzSym(void) const
double get_x_max(void) const
bool get_nearhoriz(void) const
double get_y_max(void) const
double get_z_max(void) const
double get_x_min(void) const
bool get_x2Dtop(void) const
double get_fx(void) const
double get_ztickoffset(void) const
int get_zstate(void) const
int get_ystate(void) const
double get_zPlaneN(void) const
double get_ytickoffset(void) const
bool get_xySym(void) const
double get_xticklen(void) const
Matrix get_transform_zlim(void) const
double get_xPlane(void) const
Matrix get_children(void) const
virtual octave::graphics_toolkit get_toolkit(void) const
Matrix get_all_children(void) const
virtual bool has_property(const caseless_str &) const
virtual octave_value get(const caseless_str &pname) const
virtual std::string graphics_object_name(void) const
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
graphics_object get_object(double val) const
octave_value get(bool all=false) const
void set(const caseless_str &name, const octave_value &val)
graphics_object get_ancestor(const std::string &type) const
bool isa(const std::string &go_name) const
base_properties & get_properties(void)
bool valid_object(void) const
static const idx_vector colon
static idx_vector make_range(octave_idx_type start, octave_idx_type step, octave_idx_type len)
octave_value get_color_data(void) const
virtual void glBindTexture(GLenum target, GLuint texture)
virtual void glPolygonMode(GLenum face, GLenum mode)
virtual void glMultMatrixd(const GLdouble *m)
virtual void glBegin(GLenum mode)
virtual void glDisable(GLenum cap)
virtual void glNormal3dv(const GLdouble *v)
virtual void glGenTextures(GLsizei n, GLuint *textures)
virtual void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
virtual void glPolygonOffset(GLfloat factor, GLfloat units)
virtual void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)
virtual void glVertex2d(GLdouble x, GLdouble y)
virtual void glDepthFunc(GLenum func)
virtual void glPixelStorei(GLenum pname, GLint param)
virtual void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
virtual void glColor3dv(const GLdouble *v)
virtual void glLineStipple(GLint factor, GLushort pattern)
virtual void glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
virtual void glShadeModel(GLenum mode)
virtual void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
virtual void glAlphaFunc(GLenum func, GLclampf ref)
virtual void glBlendFunc(GLenum sfactor, GLenum dfactor)
virtual void glGetIntegerv(GLenum pname, GLint *data)
virtual void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
virtual const GLubyte * glGetString(GLenum name)
virtual GLboolean glIsEnabled(GLenum cap)
virtual void glClipPlane(GLenum plane, const GLdouble *equation)
virtual void glColor3f(GLfloat red, GLfloat green, GLfloat blue)
virtual void glEdgeFlag(GLboolean flag)
virtual void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
virtual void glPopMatrix(void)
virtual void glScaled(GLdouble x, GLdouble y, GLdouble z)
virtual void glGetBooleanv(GLenum pname, GLboolean *data)
virtual void glLineWidth(GLfloat width)
virtual void glEnable(GLenum cap)
virtual void glPushAttrib(GLbitfield mask)
virtual void glVertex3d(GLdouble x, GLdouble y, GLdouble z)
virtual void glDeleteLists(GLuint list, GLsizei range)
virtual void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
virtual void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
virtual void glCallList(GLuint list)
virtual GLuint glGenLists(GLsizei range)
virtual void glEndList(void)
virtual void glLoadIdentity(void)
virtual void glNewList(GLuint list, GLenum mode)
virtual void glTranslated(GLdouble x, GLdouble y, GLdouble z)
virtual void glFinish(void)
virtual void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
virtual void glRasterPos3d(GLdouble x, GLdouble y, GLdouble z)
virtual void glPopAttrib(void)
virtual GLenum glGetError(void)
virtual void glHint(GLenum target, GLenum mode)
virtual void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
virtual void glMaterialf(GLenum face, GLenum pname, GLfloat param)
virtual void glMatrixMode(GLenum mode)
virtual void glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)
virtual void glColor3fv(const GLfloat *v)
virtual void glColor4fv(const GLfloat *v)
virtual void glPushMatrix(void)
virtual void glTexParameteri(GLenum target, GLenum pname, GLint param)
virtual void glClear(GLbitfield mask)
virtual void glVertex3dv(const GLdouble *v)
virtual void glLightfv(GLenum light, GLenum pname, const GLfloat *params)
patch_tessellator(const patch_tessellator &)=delete
opengl_renderer * renderer
void combine(GLdouble xyz[3], void *data[4], GLfloat w[4], void **out_data)
std::list< vertex_data > tmp_vdata
patch_tessellator(opengl_renderer *r, int cmode, int lmode, bool fl, float idx=0.0)
unsigned int filled_marker_id
virtual void text_to_strlist(const std::string &txt, std::list< text_renderer::string > &lst, Matrix &bbox, int halign=0, int valign=0, double rotation=0.0)
virtual void end_marker(void)
virtual void draw_hggroup(const hggroup::properties &props)
virtual void draw_surface(const surface::properties &props)
virtual void draw_text_background(const text::properties &props, bool do_rotate=false)
virtual void set_interpreter(const caseless_str &interp)
virtual void render_tickmarks(const Matrix &ticks, double lim1, double lim2, double p1, double p1N, double p2, double p2N, double dx, double dy, double dz, int xyz, bool doubleside)
void draw_axes_grids(const axes::properties &props)
virtual void set_clipbox(double x1, double x2, double y1, double y2, double z1, double z2)
bool is_nan_or_inf(double x, double y, double z) const
virtual void draw_text(const text::properties &props)
opengl_functions & m_glfcns
void draw_axes_boxes(const axes::properties &props)
virtual void draw_line(const line::properties &props)
virtual Matrix render_text(const std::string &txt, double x, double y, double z, int halign, int valign, double rotation=0.0)
unsigned int m_max_lights
void draw_all_lights(const base_properties &props, std::list< graphics_object > &obj_list)
void draw_axes_children(const axes::properties &props)
virtual void set_linewidth(float w)
virtual void set_linejoin(const std::string &)
virtual void draw_uibuttongroup(const uibuttongroup::properties &props, const graphics_object &go)
virtual void draw_axes(const axes::properties &props)
virtual void draw(const graphics_object &go, bool toplevel=true)
unsigned int m_current_light
void draw_axes_z_grid(const axes::properties &props)
void draw_axes_planes(const axes::properties &props)
virtual void init_gl_context(bool enhanced, const Matrix &backgroundColor)
virtual uint8NDArray get_pixels(int width, int height)
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 draw_patch(const patch::properties &props)
void init_maxlights(void)
virtual graphics_xform get_transform(void) const
virtual void set_linestyle(const std::string &s, bool stipple=false, double linewidth=0.5)
virtual void set_font(const base_properties &props)
void draw_axes_y_grid(const axes::properties &props)
virtual void draw_image(const image::properties &props)
virtual void text_to_pixels(const std::string &txt, uint8NDArray &pixels, Matrix &bbox, int halign=0, int valign=0, double rotation=0.0)
uint8_t clip_code(double x, double y, double z) const
virtual void render_ticktexts(const Matrix &ticks, const string_vector &ticklabels, double lim1, double lim2, double p1, double p2, int xyz, int ha, int va, int &wmax, int &hmax)
virtual void draw_marker(double x, double y, double z, const Matrix &lc, const Matrix &fc)
unsigned int make_marker_list(const std::string &m, double size, bool filled) const
std::string get_string(unsigned int id) const
text_renderer txt_renderer
virtual void set_viewport(int w, int h)
void set_normal(int bfl_mode, const NDArray &n, int j, int i)
opengl_renderer(opengl_functions &glfcns)
virtual void set_linecap(const std::string &)
virtual void set_clipping(bool on)
virtual void set_color(const Matrix &c)
virtual void setup_opengl_transformation(const axes::properties &props)
void draw_axes_x_grid(const axes::properties &props)
double points_to_pixels(const double val) const
virtual void draw_uipanel(const uipanel::properties &props, const graphics_object &go)
virtual void draw_light(const light::properties &props)
virtual void finish(void)
virtual void draw_figure(const figure::properties &props)
virtual void render_grid(const double linewidth, const std::string &gridstyle, const Matrix &gridcolor, const double gridalpha, const Matrix &ticks, double lim1, double lim2, double p1, double p1N, double p2, double p2N, int xyz, bool is_3D)
virtual Matrix get_viewport_scaled(void) const
virtual void draw_zoom_box(int width, int height, int x1, int y1, int x2, int y2, const Matrix &overlaycolor, double overlayalpha, const Matrix &bordercolor, double borderalpha, double borderwidth)
virtual void draw_zoom_rect(int x1, int y1, int x2, int y2)
virtual ~opengl_tessellator(void)
static void tess_vertex(void *v, void *t)
virtual void vertex(void *)
void end_polygon(void) const
static void tess_combine(GLdouble c[3], void *v[4], GLfloat w[4], void **out, void *t)
static void tess_end(void *t)
virtual void edge_flag(GLboolean)
static void tess_edge_flag(GLboolean flag, void *t)
void begin_polygon(bool filled=true)
virtual void combine(GLdouble[3], void *[4], GLfloat[4], void **)
static void tess_begin(GLenum type, void *t)
static void tess_error(GLenum err, void *t)
virtual void error(GLenum err)
void add_vertex(double *loc, void *data) const
void begin_contour(void) const
opengl_tessellator(const opengl_tessellator &)=delete
virtual void begin(GLenum)
bool is_filled(void) const
void end_contour(void) const
opengl_functions & m_glfcns
texture_rep(opengl_functions &glfcns, GLuint id_arg, int w_arg, int h_arg, int tw_arg, int th_arg)
void tex_coord(double q, double r) const
void bind(int mode) const
texture_rep(opengl_functions &glfcns)
refcount< octave_idx_type > count
opengl_texture(opengl_functions &glfcns)
bool is_valid(void) const
opengl_texture(texture_rep *_rep)
opengl_texture(const opengl_texture &tx)
static opengl_texture create(opengl_functions &glfcns, const octave_value &data)
void tex_coord(double q, double r) const
void bind(int mode=GL_TEXTURE_2D) const
void set_anti_aliasing(bool val)
void text_to_strlist(const std::string &txt, std::list< string > &lst, Matrix &box, int halign, int valign, double rotation=0.0, const caseless_str &interpreter="tex")
void text_to_pixels(const std::string &txt, uint8NDArray &pxls, Matrix &bbox, int halign, int valign, double rotation=0.0, const caseless_str &interpreter="tex", bool handle_rotation=true)
void set_color(const Matrix &c)
void set_font(const std::string &name, const std::string &weight, const std::string &angle, double size)
vertex_data_rep(const Matrix &c, const Matrix &col, const Matrix &vn, const Matrix &fn, double a, float as, float ds, float ss, float se, float scr)
refcount< octave_idx_type > count
float specular_color_refl
vertex_data(vertex_data_rep *new_rep)
vertex_data(const Matrix &c, const Matrix &col, const Matrix &vn, const Matrix &fn, double a, float as, float ds, float ss, float se, float scr)
vertex_data(const vertex_data &v)
vertex_data_rep * nil_rep(void) const
vertex_data_rep * get_rep(void) const
uint16NDArray uint16_array_value(void) const
bool is_uint16_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
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
bool has_bad_data(std::string &msg) const
octave_value get_color_data(void) const
std::vector< std::vector< octave_idx_type > > coplanar_last_idx
bool get_do_lighting(void) const
octave_idx_type numel(void) const
octave_value get_color_data(void) const
bool get_do_lighting(void) const
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
#define panic_impossible()
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
void xform(ColumnVector &v, const Matrix &m)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
std::complex< double > w(std::complex< double > z, double relerr=0)
static int next_power_of_2(int n)
gh_manager & __get_gh_manager__(const std::string &who)
static double f(double k, double l_nu, double c_pm)
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)
octave_value::octave_value(const Array< char > &chm, char type) return retval