# HG changeset patch # User John W. Eaton # Date 1232592185 18000 # Node ID 5cc594679cdce4482a97baecf6168b4a64599780 # Parent 07c93dae3fdbe013b39ae8777a426571f5e9b45e get display characteristics from system diff -r 07c93dae3fdb -r 5cc594679cdc ChangeLog --- a/ChangeLog Wed Jan 21 15:35:17 2009 -0500 +++ b/ChangeLog Wed Jan 21 21:43:05 2009 -0500 @@ -1,5 +1,9 @@ 2009-01-21 John W. Eaton + * Makeconf.in: Substitute X11_INCFLAGS and X11_LIBS. + * configure.in: Use AC_PATH_X to check for X11 header files and + libraries. + * THANKS, Announce: Remove obsolete files. * octMakefile.in (DISTFILES): Remove THANKS from the list. diff -r 07c93dae3fdb -r 5cc594679cdc Makeconf.in --- a/Makeconf.in Wed Jan 21 15:35:17 2009 -0500 +++ b/Makeconf.in Wed Jan 21 21:43:05 2009 -0500 @@ -148,6 +148,9 @@ endif INCFLAGS = $(TMP_IF_1) $(TMP_IF_2) +X11_INCFLAGS = @X11_INCFLAGS@ +X11_LIBS = @X11_LIBS@ + MAGICK_CONFIG = @MAGICK_CONFIG@ MAGICK_INCFLAGS = $(shell $(MAGICK_CONFIG) --cppflags) MAGICK_LIBS = $(shell $(MAGICK_CONFIG) --ldflags --libs) diff -r 07c93dae3fdb -r 5cc594679cdc configure.in --- a/configure.in Wed Jan 21 15:35:17 2009 -0500 +++ b/configure.in Wed Jan 21 21:43:05 2009 -0500 @@ -259,6 +259,17 @@ AC_SUBST(DEPEND_FLAGS) AC_SUBST(DEPEND_EXTRA_SED_PATTERN) +AC_PATH_X +if test "$have_x"; then + AC_DEFINE(HAVE_X_WINDOWS, 1, [Define if you have X11]) + + X11_INCFLAGS="$x_includes" + AC_SUBST(X11_INCFLAGS) + + AC_CHECK_LIB(X11, XrmInitialize, [X11_LIBS=-lX11], [X11_LIBS=]) + AC_SUBST(X11_LIBS) +fi + ### On Intel systems with gcc, we may need to compile with -mieee-fp ### and -ffloat-store to get full support for IEEE floating point. ### @@ -2066,11 +2077,13 @@ CURL libraries: $CURL_LIBS REGEX libraries: $REGEX_LIBS QHULL libraries: $QHULL_LIBS + OPENGL libraries: $OPENGL_LIBS + FLTK backend libs: $GRAPHICS_LIBS + X11 include flags: $X11_INCFLAGS + X11 libraries: $X11_LIBS LIBS: $LIBS Default pager: $DEFAULT_PAGER gnuplot: $GNUPLOT - OPENGL libraries: $OPENGL_LIBS - FLTK backend libs: $GRAPHICS_LIBS Magick config: $MAGICK_CONFIG Do internal array bounds checking: $BOUNDS_CHECKING diff -r 07c93dae3fdb -r 5cc594679cdc src/ChangeLog --- a/src/ChangeLog Wed Jan 21 15:35:17 2009 -0500 +++ b/src/ChangeLog Wed Jan 21 21:43:05 2009 -0500 @@ -1,5 +1,16 @@ 2009-01-21 John W. Eaton + * Makefile.in (display.o): Add X11_INCFLAGS to CPPFLAGS. + (octave$(EXEEXT)): Link with X11_LIBS. + + * display.h, display.cc: New files. + * graphics.cc (default_screendepth, default_screensize, + default_screenpixelsperinch): New functions. + * graphics.h.in (class root_figure::properties): New property, + screendepth. Use default_screensize to initialize screensize + property. Use default_screenpixelsperinch to initialize + screenpixelsperinch property. + * graphics.cc (properties::init): Set default xlabel, ylabel, zlabel, and title properties that differ from default text properties. diff -r 07c93dae3fdb -r 5cc594679cdc src/Makefile.in --- a/src/Makefile.in Wed Jan 21 15:35:17 2009 -0500 +++ b/src/Makefile.in Wed Jan 21 21:43:05 2009 -0500 @@ -121,7 +121,7 @@ INCLUDES := Cell.h base-list.h builtins.h c-file-ptr-stream.h \ comment-list.h debug.h defun-dld.h defun-int.h defun.h \ - dirfns.h dynamic-ld.h error.h file-io.h gl-render.h \ + dirfns.h display.h dynamic-ld.h error.h file-io.h gl-render.h \ gripes.h help.h input.h lex.h load-path.h load-save.h ls-hdf5.h \ ls-mat-ascii.h ls-mat4.h ls-mat5.h ls-oct-ascii.h \ ls-oct-binary.h ls-utils.h mex.h mexproto.h oct-errno.h \ @@ -216,7 +216,7 @@ DIST_SRC := Cell.cc bitfcns.cc c-file-ptr-stream.cc comment-list.cc \ cutils.c data.cc debug.cc defaults.cc defun.cc dirfns.cc \ - dynamic-ld.cc error.cc file-io.cc gl-render.cc graphics.cc \ + display.cc dynamic-ld.cc error.cc file-io.cc gl-render.cc graphics.cc \ gripes.cc help.cc input.cc lex.l load-path.cc load-save.cc \ ls-hdf5.cc ls-mat-ascii.cc ls-mat4.cc ls-mat5.cc ls-oct-ascii.cc \ ls-oct-binary.cc ls-utils.cc main.c mappers.cc matherr.c \ @@ -373,7 +373,7 @@ $(LEXLIB) $(UMFPACK_LIBS) $(AMD_LIBS) $(CAMD_LIBS) $(COLAMD_LIBS) \ $(CHOLMOD_LIBS) $(CCOLAMD_LIBS) $(CXSPARSE_LIBS) $(BLAS_LIBS) \ $(FFTW_LIBS) $(QRUPDATE_LIBS) $(ARPACK_LIBS) $(OPENGL_LIBS) \ - $(LIBS) $(FLIBS) + $(X11_LIBS) $(LIBS) $(FLIBS) stmp-pic: pic @if [ -f stmp-pic ]; then \ @@ -644,6 +644,8 @@ || (rm -f $@-t; exit 1) @mv $@-t $@ +display.o: CPPFLAGS += $(X11_FLAGS) + __magick_read__.d: CPPFLAGS += $(MAGICK_INCFLAGS) __magick_read__.df: CPPFLAGS += $(MAGICK_INCFLAGS) __magick_read__.o pic/__magick_read__.o: CPPFLAGS += $(MAGICK_INCFLAGS) diff -r 07c93dae3fdb -r 5cc594679cdc src/graphics.cc --- a/src/graphics.cc Wed Jan 21 15:35:17 2009 -0500 +++ b/src/graphics.cc Wed Jan 21 21:43:05 2009 -0500 @@ -40,6 +40,7 @@ #include "cmd-edit.h" #include "defun.h" +#include "display.h" #include "error.h" #include "graphics.h" #include "input.h" @@ -98,6 +99,29 @@ return cmap; } +static double +default_screendepth (void) +{ + return display_info::depth (); +} + +static Matrix +default_screensize (void) +{ + Matrix retval (1, 4, 1.0); + + retval(2) = display_info::width (); + retval(3) = display_info::height (); + + return retval; +} + +static double +default_screenpixelsperinch (void) +{ + return (display_info::x_dpi () + display_info::y_dpi ()) / 2; +} + static Matrix default_colororder (void) { @@ -2013,6 +2037,44 @@ } void +root_figure::properties::update_units (void) +{ + caseless_str xunits = get_units (); + + Matrix ss = default_screensize (); + + double dpi = get_screenpixelsperinch (); + + if (xunits.compare ("inches")) + { + ss(0) = 0; + ss(1) = 0; + ss(2) /= dpi; + ss(3) /= dpi; + } + else if (xunits.compare ("centimeters")) + { + ss(0) = 0; + ss(1) = 0; + ss(2) *= 2.54 / dpi; + ss(3) *= 2.54 / dpi; + } + else if (xunits.compare ("normalized")) + { + ss = Matrix (1, 4, 1.0); + } + else if (xunits.compare ("points")) + { + ss(0) = 0; + ss(1) = 0; + ss(2) *= 72 / dpi; + ss(3) *= 72 / dpi; + } + + set_screensize (ss); +} + +void root_figure::properties::remove_child (const graphics_handle& gh) { gh_manager::pop_figure (gh); diff -r 07c93dae3fdb -r 5cc594679cdc src/graphics.h.in --- a/src/graphics.h.in Wed Jan 21 15:35:17 2009 -0500 +++ b/src/graphics.h.in Wed Jan 21 21:43:05 2009 -0500 @@ -2159,8 +2159,10 @@ BEGIN_PROPERTIES (root_figure, root) handle_property currentfigure S , graphics_handle () handle_property callbackobject Sr , graphics_handle () - array_property screensize , Matrix (1, 4, 0) - double_property screenpixelsperinch , 72 + double_property screendepth r , default_screendepth () + array_property screensize r , default_screensize () + double_property screenpixelsperinch r , default_screenpixelsperinch () + radio_property units U , "inches|centimeters|normalized|points|{pixels}" bool_property showhiddenhandles , "off" END_PROPERTIES