Mercurial > hg > octave-lyh
comparison src/graphics.cc @ 7526:52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2008 04:12:19 -0500 |
parents | f2000f1971ab |
children | d219e712c20e |
comparison
equal
deleted
inserted
replaced
7525:3feb6e9643cd | 7526:52d58b0463ed |
---|---|
1861 { | 1861 { |
1862 double xd = (xdir_is ("normal") ? 1 : -1); | 1862 double xd = (xdir_is ("normal") ? 1 : -1); |
1863 double yd = (ydir_is ("normal") ? 1 : -1); | 1863 double yd = (ydir_is ("normal") ? 1 : -1); |
1864 double zd = (zdir_is ("normal") ? 1 : -1); | 1864 double zd = (zdir_is ("normal") ? 1 : -1); |
1865 | 1865 |
1866 Matrix xlim = sx.scale (get_xlim ().matrix_value ()); | 1866 Matrix xlimits = sx.scale (get_xlim ().matrix_value ()); |
1867 Matrix ylim = sy.scale (get_ylim ().matrix_value ()); | 1867 Matrix ylimits = sy.scale (get_ylim ().matrix_value ()); |
1868 Matrix zlim = sz.scale (get_zlim ().matrix_value ()); | 1868 Matrix zlimits = sz.scale (get_zlim ().matrix_value ()); |
1869 | 1869 |
1870 double xo = xlim(xd > 0 ? 0 : 1); | 1870 double xo = xlimits(xd > 0 ? 0 : 1); |
1871 double yo = ylim(yd > 0 ? 0 : 1); | 1871 double yo = ylimits(yd > 0 ? 0 : 1); |
1872 double zo = zlim(zd > 0 ? 0 : 1); | 1872 double zo = zlimits(zd > 0 ? 0 : 1); |
1873 | 1873 |
1874 Matrix pb = get_plotboxaspectratio ().matrix_value (); | 1874 Matrix pb = get_plotboxaspectratio ().matrix_value (); |
1875 | 1875 |
1876 bool autocam = (camerapositionmode_is ("auto") | 1876 bool autocam = (camerapositionmode_is ("auto") |
1877 && cameratargetmode_is ("auto") | 1877 && cameratargetmode_is ("auto") |
1884 ColumnVector c_center (xform_vector ()); | 1884 ColumnVector c_center (xform_vector ()); |
1885 ColumnVector c_upv (xform_vector ()); | 1885 ColumnVector c_upv (xform_vector ()); |
1886 | 1886 |
1887 if (cameratargetmode_is ("auto")) | 1887 if (cameratargetmode_is ("auto")) |
1888 { | 1888 { |
1889 c_center(0) = (xlim(0)+xlim(1))/2; | 1889 c_center(0) = (xlimits(0)+xlimits(1))/2; |
1890 c_center(1) = (ylim(0)+ylim(1))/2; | 1890 c_center(1) = (ylimits(0)+ylimits(1))/2; |
1891 c_center(2) = (zlim(0)+zlim(1))/2; | 1891 c_center(2) = (zlimits(0)+zlimits(1))/2; |
1892 | 1892 |
1893 cameratarget = xform2cam (c_center); | 1893 cameratarget = xform2cam (c_center); |
1894 } | 1894 } |
1895 else | 1895 else |
1896 c_center = cam2xform (get_cameratarget ().matrix_value ()); | 1896 c_center = cam2xform (get_cameratarget ().matrix_value ()); |
1897 | 1897 |
1898 if (camerapositionmode_is ("auto")) | 1898 if (camerapositionmode_is ("auto")) |
1899 { | 1899 { |
1900 Matrix view = get_view ().matrix_value (); | 1900 Matrix tview = get_view ().matrix_value (); |
1901 double az = view(0), el = view(1); | 1901 double az = tview(0), el = tview(1); |
1902 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); | 1902 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
1903 | 1903 |
1904 if (el == 90 || el == -90) | 1904 if (el == 90 || el == -90) |
1905 c_eye(2) = d*signum(el); | 1905 c_eye(2) = d*signum(el); |
1906 else | 1906 else |
1909 el *= M_PI/180.0; | 1909 el *= M_PI/180.0; |
1910 c_eye(0) = d*cos(el)*sin(az); | 1910 c_eye(0) = d*cos(el)*sin(az); |
1911 c_eye(1) = -d*cos(el)*cos(az); | 1911 c_eye(1) = -d*cos(el)*cos(az); |
1912 c_eye(2) = d*sin(el); | 1912 c_eye(2) = d*sin(el); |
1913 } | 1913 } |
1914 c_eye(0) = c_eye(0)*(xlim(1)-xlim(0))/(xd*pb(0))+c_center(0); | 1914 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0); |
1915 c_eye(1) = c_eye(1)*(ylim(1)-ylim(0))/(yd*pb(1))+c_center(1); | 1915 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1); |
1916 c_eye(2) = c_eye(2)*(zlim(1)-zlim(0))/(zd*pb(2))+c_center(2); | 1916 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
1917 | 1917 |
1918 cameraposition = xform2cam (c_eye); | 1918 cameraposition = xform2cam (c_eye); |
1919 } | 1919 } |
1920 else | 1920 else |
1921 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | 1921 c_eye = cam2xform (get_cameraposition ().matrix_value ()); |
1922 | 1922 |
1923 if (cameraupvectormode_is ("auto")) | 1923 if (cameraupvectormode_is ("auto")) |
1924 { | 1924 { |
1925 Matrix view = get_view ().matrix_value (); | 1925 Matrix tview = get_view ().matrix_value (); |
1926 double az = view(0), el = view(1); | 1926 double az = tview(0), el = tview(1); |
1927 | 1927 |
1928 if (el == 90 || el == -90) | 1928 if (el == 90 || el == -90) |
1929 { | 1929 { |
1930 c_upv(0) = -sin(az*M_PI/180.0)*(xlim(1)-xlim(0))/pb(0); | 1930 c_upv(0) = -sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0); |
1931 c_upv(1) = cos(az*M_PI/180.0)*(ylim(1)-ylim(0))/pb(1); | 1931 c_upv(1) = cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1); |
1932 } | 1932 } |
1933 else | 1933 else |
1934 c_upv(2) = 1; | 1934 c_upv(2) = 1; |
1935 | 1935 |
1936 cameraupvector = xform2cam (c_upv); | 1936 cameraupvector = xform2cam (c_upv); |
1947 x_render = xform_matrix (); | 1947 x_render = xform_matrix (); |
1948 x_render_inv = xform_matrix (); | 1948 x_render_inv = xform_matrix (); |
1949 | 1949 |
1950 scale (x_pre, pb(0), pb(1), pb(2)); | 1950 scale (x_pre, pb(0), pb(1), pb(2)); |
1951 translate (x_pre, -0.5, -0.5, -0.5); | 1951 translate (x_pre, -0.5, -0.5, -0.5); |
1952 scale (x_pre, xd/(xlim(1)-xlim(0)), yd/(ylim(1)-ylim(0)), | 1952 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
1953 zd/(zlim(1)-zlim(0))); | 1953 zd/(zlimits(1)-zlimits(0))); |
1954 translate (x_pre, -xo, -yo, -zo); | 1954 translate (x_pre, -xo, -yo, -zo); |
1955 | 1955 |
1956 xform (c_eye, x_pre); | 1956 xform (c_eye, x_pre); |
1957 xform (c_center, x_pre); | 1957 xform (c_center, x_pre); |
1958 scale (c_upv, pb(0)/(xlim(1)-xlim(0)), pb(1)/(ylim(1)-ylim(0)), | 1958 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)), |
1959 pb(2)/(zlim(1)-zlim(0))); | 1959 pb(2)/(zlimits(1)-zlimits(0))); |
1960 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); | 1960 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
1961 | 1961 |
1962 ColumnVector F (c_center), f (F), UP (c_upv); | 1962 ColumnVector F (c_center), f (F), UP (c_upv); |
1963 normalize (f); | 1963 normalize (f); |
1964 normalize (UP); | 1964 normalize (UP); |
2048 x_zlim.resize (1, 2); | 2048 x_zlim.resize (1, 2); |
2049 x_zlim(0) = cmin(2); | 2049 x_zlim(0) = cmin(2); |
2050 x_zlim(1) = cmax(2); | 2050 x_zlim(1) = cmax(2); |
2051 | 2051 |
2052 x_render = x_normrender; | 2052 x_render = x_normrender; |
2053 scale (x_render, xd/(xlim(1)-xlim(0)), yd/(ylim(1)-ylim(0)), | 2053 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
2054 zd/(zlim(1)-zlim(0))); | 2054 zd/(zlimits(1)-zlimits(0))); |
2055 translate (x_render, -xo, -yo, -zo); | 2055 translate (x_render, -xo, -yo, -zo); |
2056 | 2056 |
2057 x_viewtransform = x_view; | 2057 x_viewtransform = x_view; |
2058 x_projectiontransform = x_projection; | 2058 x_projectiontransform = x_projection; |
2059 x_viewporttransform = x_viewport; | 2059 x_viewporttransform = x_viewport; |
2064 | 2064 |
2065 // Note: these matrices are a slight modified version of the regular | 2065 // Note: these matrices are a slight modified version of the regular |
2066 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | 2066 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light |
2067 // => x_gl_mat2) | 2067 // => x_gl_mat2) |
2068 x_gl_mat1 = x_view; | 2068 x_gl_mat1 = x_view; |
2069 scale (x_gl_mat1, xd/(xlim(1)-xlim(0)), yd/(ylim(1)-ylim(0)), | 2069 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
2070 zd/(zlim(1)-zlim(0))); | 2070 zd/(zlimits(1)-zlimits(0))); |
2071 translate (x_gl_mat1, -xo, -yo, -zo); | 2071 translate (x_gl_mat1, -xo, -yo, -zo); |
2072 x_gl_mat2 = x_viewport * x_projection; | 2072 x_gl_mat2 = x_viewport * x_projection; |
2073 } | 2073 } |
2074 | 2074 |
2075 void | 2075 void |
2076 axes::properties::update_aspectratios (void) | 2076 axes::properties::update_aspectratios (void) |
2077 { | 2077 { |
2078 Matrix xlim = get_xlim ().matrix_value (); | 2078 Matrix xlimits = get_xlim ().matrix_value (); |
2079 Matrix ylim = get_ylim ().matrix_value (); | 2079 Matrix ylimits = get_ylim ().matrix_value (); |
2080 Matrix zlim = get_zlim ().matrix_value (); | 2080 Matrix zlimits = get_zlim ().matrix_value (); |
2081 | 2081 |
2082 double dx = (xlim(1)-xlim(0)); | 2082 double dx = (xlimits(1)-xlimits(0)); |
2083 double dy = (ylim(1)-ylim(0)); | 2083 double dy = (ylimits(1)-ylimits(0)); |
2084 double dz = (zlim(1)-zlim(0)); | 2084 double dz = (zlimits(1)-zlimits(0)); |
2085 | 2085 |
2086 if (dataaspectratiomode_is ("auto")) | 2086 if (dataaspectratiomode_is ("auto")) |
2087 { | 2087 { |
2088 double dmin = xmin (xmin (dx, dy), dz); | 2088 double dmin = xmin (xmin (dx, dy), dz); |
2089 Matrix da (1, 3, 0.0); | 2089 Matrix da (1, 3, 0.0); |