# HG changeset patch # User Konstantinos Poulios # Date 1291849541 -3600 # Branch disable-autopositioning # Node ID 7778f811473f3f4fd0401c04bb1d20f31a2c78ca # Parent e773d57de57252789acfc562302e901059391966 Disable auto-positioning of manually positioned title and axes labels. diff -r e773d57de572 -r 7778f811473f src/ChangeLog --- a/src/ChangeLog Wed Dec 08 07:57:16 2010 -0500 +++ b/src/ChangeLog Thu Dec 09 00:05:41 2010 +0100 @@ -1,3 +1,12 @@ +2012-12-09 Konstantinos Poulios + + * graphics.h.in (class text::properties): New properties positionmode, + rotationmode, horizontalalignmentmode, verticalalignmentmode. + * graphics.cc (axes::properties::init, axes::properties::set_defaults): + Set mode to auto for all initialized positioning properties. + * gl-render.cc (opengl_renderer::draw_axes): Disable auto-positioning + of manually positioned title and axes labels. + 2010-12-08 John W. Eaton * graphics.h.in (base_property::do_set): Don't reverse order of diff -r e773d57de572 -r 7778f811473f src/gl-render.cc --- a/src/gl-render.cc Wed Dec 08 07:57:16 2010 -0500 +++ b/src/gl-render.cc Thu Dec 09 00:05:41 2010 +0100 @@ -1089,38 +1089,55 @@ xlabel_props.set_visible ("on"); - // FIXME: auto-positioning should be disabled if the - // label has been positioned manually if (! xlabel_props.get_string ().empty ()) { - xlabel_props.set_horizontalalignment (xstate > AXE_DEPTH_DIR ? "center" : (xySym ? "left" : "right")); - xlabel_props.set_verticalalignment (xstate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom")); - - double angle = 0; - ColumnVector p = graphics_xform::xform_vector ((x_min+x_max)/2, yPlaneN, zPlane); - - if (tick_along_z) - p(2) += (signum(zPlane-zPlaneN)*fz*xtickoffset); - else - p(1) += (signum(yPlaneN-yPlane)*fy*xtickoffset); - p = xform.transform (p(0), p(1), p(2), false); - switch (xstate) + if (xlabel_props.horizontalalignmentmode_is("auto")) { - case AXE_ANY_DIR: - p(0) += (xySym ? wmax : -wmax); - p(1) += (zd*zv(2) <= 0 ? hmax : -hmax); - break; - case AXE_VERT_DIR: - p(0) -= wmax; - angle = 90; - break; - case AXE_HORZ_DIR: - p(1) += hmax; - break; + xlabel_props.set_horizontalalignment (xstate > AXE_DEPTH_DIR ? "center" : (xySym ? "left" : "right")); + xlabel_props.set_horizontalalignmentmode("auto"); } - p = xform.untransform (p(0), p(1), p(2), true); - xlabel_props.set_position (p.extract_n (0, 3).transpose ()); - xlabel_props.set_rotation (angle); + if (xlabel_props.verticalalignmentmode_is("auto")) + { + xlabel_props.set_verticalalignment (xstate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom")); + xlabel_props.set_verticalalignmentmode("auto"); + } + + if (xlabel_props.positionmode_is("auto") || xlabel_props.rotationmode_is("auto")) + { + double angle = 0; + ColumnVector p = graphics_xform::xform_vector ((x_min+x_max)/2, yPlaneN, zPlane); + + if (tick_along_z) + p(2) += (signum(zPlane-zPlaneN)*fz*xtickoffset); + else + p(1) += (signum(yPlaneN-yPlane)*fy*xtickoffset); + p = xform.transform (p(0), p(1), p(2), false); + switch (xstate) + { + case AXE_ANY_DIR: + p(0) += (xySym ? wmax : -wmax); + p(1) += (zd*zv(2) <= 0 ? hmax : -hmax); + break; + case AXE_VERT_DIR: + p(0) -= wmax; + angle = 90; + break; + case AXE_HORZ_DIR: + p(1) += hmax; + break; + } + if (xlabel_props.positionmode_is("auto")) + { + p = xform.untransform (p(0), p(1), p(2), true); + xlabel_props.set_position (p.extract_n (0, 3).transpose ()); + xlabel_props.set_positionmode ("auto"); + } + if (xlabel_props.rotationmode_is("auto")) + { + xlabel_props.set_rotation (angle); + xlabel_props.set_rotationmode ("auto"); + } + } } } else @@ -1322,38 +1339,55 @@ ylabel_props.set_visible ("on"); - // FIXME: auto-positioning should be disabled if the - // label has been positioned manually if (! ylabel_props.get_string ().empty ()) { - ylabel_props.set_horizontalalignment (ystate > AXE_DEPTH_DIR ? "center" : (!xySym ? "left" : "right")); - ylabel_props.set_verticalalignment (ystate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom")); - - double angle = 0; - ColumnVector p = graphics_xform::xform_vector (xPlaneN, (y_min+y_max)/2, zPlane); - - if (tick_along_z) - p(2) += (signum(zPlane-zPlaneN)*fz*ytickoffset); - else - p(0) += (signum(xPlaneN-xPlane)*fx*ytickoffset); - p = xform.transform (p(0), p(1), p(2), false); - switch (ystate) + if (ylabel_props.horizontalalignmentmode_is("auto")) { - case AXE_ANY_DIR: - p(0) += (!xySym ? wmax : -wmax); - p(1) += (zd*zv(2) <= 0 ? hmax : -hmax); - break; - case AXE_VERT_DIR: - p(0) -= wmax; - angle = 90; - break; - case AXE_HORZ_DIR: - p(1) += hmax; - break; + ylabel_props.set_horizontalalignment (ystate > AXE_DEPTH_DIR ? "center" : (!xySym ? "left" : "right")); + ylabel_props.set_horizontalalignmentmode("auto"); } - p = xform.untransform(p(0), p(1), p(2), true); - ylabel_props.set_position (p.extract_n (0, 3).transpose ()); - ylabel_props.set_rotation (angle); + if (ylabel_props.verticalalignmentmode_is("auto")) + { + ylabel_props.set_verticalalignment (ystate == AXE_VERT_DIR ? "bottom" : (zd*zv(2) <= 0 ? "top" : "bottom")); + ylabel_props.set_verticalalignmentmode("auto"); + } + + if (ylabel_props.positionmode_is("auto") || ylabel_props.rotationmode_is("auto")) + { + double angle = 0; + ColumnVector p = graphics_xform::xform_vector (xPlaneN, (y_min+y_max)/2, zPlane); + + if (tick_along_z) + p(2) += (signum(zPlane-zPlaneN)*fz*ytickoffset); + else + p(0) += (signum(xPlaneN-xPlane)*fx*ytickoffset); + p = xform.transform (p(0), p(1), p(2), false); + switch (ystate) + { + case AXE_ANY_DIR: + p(0) += (!xySym ? wmax : -wmax); + p(1) += (zd*zv(2) <= 0 ? hmax : -hmax); + break; + case AXE_VERT_DIR: + p(0) -= wmax; + angle = 90; + break; + case AXE_HORZ_DIR: + p(1) += hmax; + break; + } + if (ylabel_props.positionmode_is("auto")) + { + p = xform.untransform (p(0), p(1), p(2), true); + ylabel_props.set_position (p.extract_n (0, 3).transpose ()); + ylabel_props.set_positionmode ("auto"); + } + if (ylabel_props.rotationmode_is("auto")) + { + ylabel_props.set_rotation (angle); + ylabel_props.set_rotationmode ("auto"); + } + } } } else @@ -1624,59 +1658,76 @@ zlabel_props.set_visible ("on"); - // FIXME: auto-positioning should be disabled if the - // label has been positioned manually if (! zlabel_props.get_string ().empty ()) { bool camAuto = props.cameraupvectormode_is ("auto"); - zlabel_props.set_horizontalalignment ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right"); - zlabel_props.set_verticalalignment(zstate == AXE_VERT_DIR ? "bottom" : ((zd*zv(2) < 0 || camAuto) ? "bottom" : "top")); - - double angle = 0; - ColumnVector p; - - if (xySym) + if (zlabel_props.horizontalalignmentmode_is("auto")) { - p = graphics_xform::xform_vector (xPlaneN, yPlane, (z_min+z_max)/2); - if (xisinf (fy)) - p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); + zlabel_props.set_horizontalalignment ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right"); + zlabel_props.set_horizontalalignmentmode("auto"); + } + if (zlabel_props.verticalalignmentmode_is("auto")) + { + zlabel_props.set_verticalalignment(zstate == AXE_VERT_DIR ? "bottom" : ((zd*zv(2) < 0 || camAuto) ? "bottom" : "top")); + zlabel_props.set_verticalalignmentmode("auto"); + } + + if (zlabel_props.positionmode_is("auto") || zlabel_props.rotationmode_is("auto")) + { + double angle = 0; + ColumnVector p; + + if (xySym) + { + p = graphics_xform::xform_vector (xPlaneN, yPlane, (z_min+z_max)/2); + if (xisinf (fy)) + p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); + else + p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); + } else - p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); - } - else - { - p = graphics_xform::xform_vector (xPlane, yPlaneN, (z_min+z_max)/2); - if (xisinf (fx)) - p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); - else - p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); - } - p = xform.transform (p(0), p(1), p(2), false); - switch (zstate) - { - case AXE_ANY_DIR: - if (camAuto) - { + { + p = graphics_xform::xform_vector (xPlane, yPlaneN, (z_min+z_max)/2); + if (xisinf (fx)) + p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); + else + p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); + } + p = xform.transform (p(0), p(1), p(2), false); + switch (zstate) + { + case AXE_ANY_DIR: + if (camAuto) + { + p(0) -= wmax; + angle = 90; + } + /* FIXME: what's the correct offset? + p[0] += (!xySym ? wmax : -wmax); + p[1] += (zd*zv[2] <= 0 ? hmax : -hmax); + */ + break; + case AXE_VERT_DIR: p(0) -= wmax; angle = 90; - } - /* FIXME: what's the correct offset? - p[0] += (!xySym ? wmax : -wmax); - p[1] += (zd*zv[2] <= 0 ? hmax : -hmax); - */ - break; - case AXE_VERT_DIR: - p(0) -= wmax; - angle = 90; - break; - case AXE_HORZ_DIR: - p(1) += hmax; - break; + break; + case AXE_HORZ_DIR: + p(1) += hmax; + break; + } + if (zlabel_props.positionmode_is("auto")) + { + p = xform.untransform (p(0), p(1), p(2), true); + zlabel_props.set_position (p.extract_n (0, 3).transpose ()); + zlabel_props.set_positionmode ("auto"); + } + if (zlabel_props.rotationmode_is("auto")) + { + zlabel_props.set_rotation (angle); + zlabel_props.set_rotationmode ("auto"); + } } - p = xform.untransform (p(0), p(1), p(2), true); - zlabel_props.set_position (p.extract_n (0, 3).transpose ()); - zlabel_props.set_rotation (angle); } } else diff -r e773d57de572 -r 7778f811473f src/graphics.cc --- a/src/graphics.cc Wed Dec 08 07:57:16 2010 -0500 +++ b/src/graphics.cc Thu Dec 09 00:05:41 2010 +0100 @@ -3183,15 +3183,24 @@ xset (title.handle_value (), "handlevisibility", "off"); xset (xlabel.handle_value (), "horizontalalignment", "center"); + xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); xset (ylabel.handle_value (), "horizontalalignment", "center"); + xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); xset (zlabel.handle_value (), "horizontalalignment", "right"); + xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); xset (title.handle_value (), "horizontalalignment", "center"); + xset (title.handle_value (), "horizontalalignmentmode", "auto"); xset (xlabel.handle_value (), "verticalalignment", "cap"); + xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); xset (ylabel.handle_value (), "verticalalignment", "bottom"); + xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); xset (title.handle_value (), "verticalalignment", "bottom"); + xset (title.handle_value (), "verticalalignmentmode", "auto"); xset (ylabel.handle_value (), "rotation", 90.0); + xset (ylabel.handle_value (), "rotationmode", "auto"); + xset (zlabel.handle_value (), "visible", "off"); xset (xlabel.handle_value (), "clipping", "off"); @@ -3422,15 +3431,24 @@ xset (title.handle_value (), "handlevisibility", "off"); xset (xlabel.handle_value (), "horizontalalignment", "center"); + xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); xset (ylabel.handle_value (), "horizontalalignment", "center"); + xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); xset (zlabel.handle_value (), "horizontalalignment", "right"); + xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); xset (title.handle_value (), "horizontalalignment", "center"); + xset (title.handle_value (), "horizontalalignmentmode", "auto"); xset (xlabel.handle_value (), "verticalalignment", "cap"); + xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); xset (ylabel.handle_value (), "verticalalignment", "bottom"); + xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); xset (title.handle_value (), "verticalalignment", "bottom"); + xset (title.handle_value (), "verticalalignmentmode", "auto"); xset (ylabel.handle_value (), "rotation", 90.0); + xset (ylabel.handle_value (), "rotationmode", "auto"); + xset (zlabel.handle_value (), "visible", "off"); xset (xlabel.handle_value (), "clipping", "off"); diff -r e773d57de572 -r 7778f811473f src/graphics.h.in --- a/src/graphics.h.in Wed Dec 08 07:57:16 2010 -0500 +++ b/src/graphics.h.in Thu Dec 09 00:05:41 2010 +0100 @@ -3491,9 +3491,9 @@ BEGIN_PROPERTIES (text) string_property string u , "" radio_property units u , "{data}|pixels|normalized|inches|centimeters|points" - array_property position u , Matrix (1, 3, 0.0) - double_property rotation u , 0 - radio_property horizontalalignment , "{left}|center|right" + array_property position mu , Matrix (1, 3, 0.0) + double_property rotation mu , 0 + radio_property horizontalalignment m , "{left}|center|right" color_property color , color_values (0, 0, 0) string_property fontname u , OCTAVE_DEFAULT_FONTNAME double_property fontsize u , 10 @@ -3509,7 +3509,7 @@ radio_property linestyle , "{-}|--|:|-.|none" double_property linewidth , 0.5 double_property margin , 1 - radio_property verticalalignment , "top|cap|{middle}|baseline|bottom" + radio_property verticalalignment m , "top|cap|{middle}|baseline|bottom" array_property extent rG , Matrix (1, 4, 0.0) // hidden properties for limit computation row_vector_property xlim hlr , Matrix () @@ -3518,6 +3518,11 @@ bool_property xliminclude hl , "off" bool_property yliminclude hl , "off" bool_property zliminclude hl , "off" + // hidden properties for auto-positioning + radio_property positionmode h , "{auto}|manual" + radio_property rotationmode h , "{auto}|manual" + radio_property horizontalalignmentmode h , "{auto}|manual" + radio_property verticalalignmentmode h , "{auto}|manual" END_PROPERTIES Matrix get_data_position (void) const;