Mercurial > octave-nkf
comparison src/graphics.cc @ 12381:c87c97f16862 release-3-4-x
Untabify and improve indentation
author | Konstantinos Poulios <logari81@googlemail.com> |
---|---|
date | Sun, 06 Feb 2011 02:50:57 +0100 |
parents | e8f17ad29f95 |
children | 5367bd36b9f8 |
comparison
equal
deleted
inserted
replaced
12380:e8f17ad29f95 | 12381:c87c97f16862 |
---|---|
3936 if (dir(0) == 0) | 3936 if (dir(0) == 0) |
3937 xstate = AXE_VERT_DIR; | 3937 xstate = AXE_VERT_DIR; |
3938 else if (dir(1) == 0) | 3938 else if (dir(1) == 0) |
3939 xstate = AXE_HORZ_DIR; | 3939 xstate = AXE_HORZ_DIR; |
3940 } | 3940 } |
3941 | |
3941 if (dir(2) == 0) | 3942 if (dir(2) == 0) |
3942 if (dir(1) == 0) | 3943 { |
3943 xPlane = (dir(0) > 0 ? x_max : x_min); | 3944 if (dir(1) == 0) |
3944 else | 3945 xPlane = (dir(0) > 0 ? x_max : x_min); |
3945 xPlane = (dir(1) < 0 ? x_max : x_min); | 3946 else |
3947 xPlane = (dir(1) < 0 ? x_max : x_min); | |
3948 } | |
3946 else | 3949 else |
3947 xPlane = (dir(2) < 0 ? x_min : x_max); | 3950 xPlane = (dir(2) < 0 ? x_min : x_max); |
3951 | |
3948 xPlaneN = (xPlane == x_min ? x_max : x_min); | 3952 xPlaneN = (xPlane == x_min ? x_max : x_min); |
3949 fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); | 3953 fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
3950 | 3954 |
3951 p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false); | 3955 p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false); |
3952 p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false); | 3956 p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false); |
3960 if (dir(0) == 0) | 3964 if (dir(0) == 0) |
3961 ystate = AXE_VERT_DIR; | 3965 ystate = AXE_VERT_DIR; |
3962 else if (dir(1) == 0) | 3966 else if (dir(1) == 0) |
3963 ystate = AXE_HORZ_DIR; | 3967 ystate = AXE_HORZ_DIR; |
3964 } | 3968 } |
3969 | |
3965 if (dir(2) == 0) | 3970 if (dir(2) == 0) |
3966 if (dir(1) == 0) | 3971 { |
3967 yPlane = (dir(0) > 0 ? y_max : y_min); | 3972 if (dir(1) == 0) |
3968 else | 3973 yPlane = (dir(0) > 0 ? y_max : y_min); |
3969 yPlane = (dir(1) < 0 ? y_max : y_min); | 3974 else |
3975 yPlane = (dir(1) < 0 ? y_max : y_min); | |
3976 } | |
3970 else | 3977 else |
3971 yPlane = (dir(2) < 0 ? y_min : y_max); | 3978 yPlane = (dir(2) < 0 ? y_min : y_max); |
3979 | |
3972 yPlaneN = (yPlane == y_min ? y_max : y_min); | 3980 yPlaneN = (yPlane == y_min ? y_max : y_min); |
3973 fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); | 3981 fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
3974 | 3982 |
3975 p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); | 3983 p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); |
3976 p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); | 3984 p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); |
3978 dir(1) = xround (p2(1)-p1(1)); | 3986 dir(1) = xround (p2(1)-p1(1)); |
3979 dir(2) = (p2(2)-p1(2)); | 3987 dir(2) = (p2(2)-p1(2)); |
3980 if (dir(0) == 0 && dir(1) == 0) | 3988 if (dir(0) == 0 && dir(1) == 0) |
3981 zstate = AXE_DEPTH_DIR; | 3989 zstate = AXE_DEPTH_DIR; |
3982 else if (dir(2) == 0) | 3990 else if (dir(2) == 0) |
3983 { | 3991 { |
3984 if (dir(0) == 0) | 3992 if (dir(0) == 0) |
3985 zstate = AXE_VERT_DIR; | 3993 zstate = AXE_VERT_DIR; |
3986 else if (dir(1) == 0) | 3994 else if (dir(1) == 0) |
3987 zstate = AXE_HORZ_DIR; | 3995 zstate = AXE_HORZ_DIR; |
3988 } | 3996 } |
3997 | |
3989 if (dir(2) == 0) | 3998 if (dir(2) == 0) |
3990 if (dir(1) == 0) | 3999 { |
3991 zPlane = (dir(0) > 0 ? z_min : z_max); | 4000 if (dir(1) == 0) |
3992 else | 4001 zPlane = (dir(0) > 0 ? z_min : z_max); |
3993 zPlane = (dir(1) < 0 ? z_min : z_max); | 4002 else |
4003 zPlane = (dir(1) < 0 ? z_min : z_max); | |
4004 } | |
3994 else | 4005 else |
3995 zPlane = (dir(2) < 0 ? z_min : z_max); | 4006 zPlane = (dir(2) < 0 ? z_min : z_max); |
4007 | |
3996 zPlaneN = (zPlane == z_min ? z_max : z_min); | 4008 zPlaneN = (zPlane == z_min ? z_max : z_min); |
3997 fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); | 4009 fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
3998 | 4010 |
3999 unwind_protect frame; | 4011 unwind_protect frame; |
4000 frame.protect_var (updating_axes_layout); | 4012 frame.protect_var (updating_axes_layout); |
4167 | 4179 |
4168 text::properties& ylabel_props = reinterpret_cast<text::properties&> | 4180 text::properties& ylabel_props = reinterpret_cast<text::properties&> |
4169 (gh_manager::get_object (get_ylabel ()).get_properties ()); | 4181 (gh_manager::get_object (get_ylabel ()).get_properties ()); |
4170 | 4182 |
4171 if (ylabel_props.horizontalalignmentmode_is ("auto")) | 4183 if (ylabel_props.horizontalalignmentmode_is ("auto")) |
4172 { | 4184 { |
4173 ylabel_props.set_horizontalalignment | 4185 ylabel_props.set_horizontalalignment |
4174 (ystate > AXE_DEPTH_DIR | 4186 (ystate > AXE_DEPTH_DIR |
4175 ? "center" : (!xyzSym ? "left" : "right")); | 4187 ? "center" : (!xyzSym ? "left" : "right")); |
4176 | 4188 |
4177 ylabel_props.set_horizontalalignmentmode ("auto"); | 4189 ylabel_props.set_horizontalalignmentmode ("auto"); |
4178 } | 4190 } |
4179 | 4191 |
4180 if (ylabel_props.verticalalignmentmode_is ("auto")) | 4192 if (ylabel_props.verticalalignmentmode_is ("auto")) |
4181 { | 4193 { |
4182 ylabel_props.set_verticalalignment | 4194 ylabel_props.set_verticalalignment |
4183 (ystate == AXE_VERT_DIR && !y2Dright ? "bottom" : "top"); | 4195 (ystate == AXE_VERT_DIR && !y2Dright ? "bottom" : "top"); |
4184 | 4196 |
4185 ylabel_props.set_verticalalignmentmode ("auto"); | 4197 ylabel_props.set_verticalalignmentmode ("auto"); |
4186 } | 4198 } |
4187 | 4199 |
4188 if (ylabel_props.positionmode_is ("auto") | 4200 if (ylabel_props.positionmode_is ("auto") |
4189 || ylabel_props.rotationmode_is ("auto")) | 4201 || ylabel_props.rotationmode_is ("auto")) |
4190 { | 4202 { |
4191 Matrix ext (1, 2, 0.0); | 4203 Matrix ext (1, 2, 0.0); |
4192 ext = get_ticklabel_extents (get_ytick ().matrix_value (), | 4204 ext = get_ticklabel_extents (get_ytick ().matrix_value (), |
4193 get_yticklabel ().all_strings (), | 4205 get_yticklabel ().all_strings (), |
4194 get_ylim ().matrix_value ()); | 4206 get_ylim ().matrix_value ()); |
4195 | 4207 |
4196 double wmax = ext(0), hmax = ext(1), angle = 0; | 4208 double wmax = ext(0), hmax = ext(1), angle = 0; |
4197 ColumnVector p = | 4209 ColumnVector p = |
4198 graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick); | 4210 graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick); |
4199 | 4211 |
4200 bool tick_along_z = nearhoriz || xisinf (fx); | 4212 bool tick_along_z = nearhoriz || xisinf (fx); |
4201 if (tick_along_z) | 4213 if (tick_along_z) |
4202 p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset); | 4214 p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset); |
4203 else | 4215 else |
4204 p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset); | 4216 p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset); |
4205 | 4217 |
4206 p = xform.transform (p(0), p(1), p(2), false); | 4218 p = xform.transform (p(0), p(1), p(2), false); |
4207 | 4219 |
4208 switch (ystate) | 4220 switch (ystate) |
4209 { | 4221 { |
4210 case AXE_ANY_DIR: | 4222 case AXE_ANY_DIR: |
4211 p(0) += (!xyzSym ? wmax : -wmax); | 4223 p(0) += (!xyzSym ? wmax : -wmax); |
4212 p(1) += hmax; | 4224 p(1) += hmax; |
4213 break; | 4225 break; |
4214 | 4226 |
4215 case AXE_VERT_DIR: | 4227 case AXE_VERT_DIR: |
4216 p(0) += (y2Dright ? wmax : -wmax); | 4228 p(0) += (y2Dright ? wmax : -wmax); |
4217 angle = 90; | 4229 angle = 90; |
4218 break; | 4230 break; |
4219 | 4231 |
4220 case AXE_HORZ_DIR: | 4232 case AXE_HORZ_DIR: |
4221 p(1) += hmax; | 4233 p(1) += hmax; |
4222 break; | 4234 break; |
4223 } | 4235 } |
4224 | 4236 |
4225 if (ylabel_props.positionmode_is ("auto")) | 4237 if (ylabel_props.positionmode_is ("auto")) |
4226 { | 4238 { |
4227 p = xform.untransform (p(0), p(1), p(2), true); | 4239 p = xform.untransform (p(0), p(1), p(2), true); |
4228 ylabel_props.set_position (p.extract_n (0, 3).transpose ()); | 4240 ylabel_props.set_position (p.extract_n (0, 3).transpose ()); |
4229 ylabel_props.set_positionmode ("auto"); | 4241 ylabel_props.set_positionmode ("auto"); |
4230 } | 4242 } |
4231 | 4243 |
4232 if (ylabel_props.rotationmode_is ("auto")) | 4244 if (ylabel_props.rotationmode_is ("auto")) |
4233 { | 4245 { |
4234 ylabel_props.set_rotation (angle); | 4246 ylabel_props.set_rotation (angle); |
4235 ylabel_props.set_rotationmode ("auto"); | 4247 ylabel_props.set_rotationmode ("auto"); |
4236 } | 4248 } |
4237 } | 4249 } |
4238 } | 4250 } |
4239 | 4251 |
4240 void | 4252 void |
4241 axes::properties::update_zlabel_position (void) | 4253 axes::properties::update_zlabel_position (void) |
4242 { | 4254 { |
4246 (gh_manager::get_object (get_zlabel ()).get_properties ()); | 4258 (gh_manager::get_object (get_zlabel ()).get_properties ()); |
4247 | 4259 |
4248 bool camAuto = cameraupvectormode_is ("auto"); | 4260 bool camAuto = cameraupvectormode_is ("auto"); |
4249 | 4261 |
4250 if (zlabel_props.horizontalalignmentmode_is ("auto")) | 4262 if (zlabel_props.horizontalalignmentmode_is ("auto")) |
4251 { | 4263 { |
4252 zlabel_props.set_horizontalalignment | 4264 zlabel_props.set_horizontalalignment |
4253 ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right"); | 4265 ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right"); |
4254 | 4266 |
4255 zlabel_props.set_horizontalalignmentmode ("auto"); | 4267 zlabel_props.set_horizontalalignmentmode ("auto"); |
4256 } | 4268 } |
4257 | 4269 |
4258 if (zlabel_props.verticalalignmentmode_is ("auto")) | 4270 if (zlabel_props.verticalalignmentmode_is ("auto")) |
4259 { | 4271 { |
4260 zlabel_props.set_verticalalignment | 4272 zlabel_props.set_verticalalignment |
4261 (zstate == AXE_VERT_DIR | 4273 (zstate == AXE_VERT_DIR |
4262 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top")); | 4274 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top")); |
4263 | 4275 |
4264 zlabel_props.set_verticalalignmentmode ("auto"); | 4276 zlabel_props.set_verticalalignmentmode ("auto"); |
4265 } | 4277 } |
4266 | 4278 |
4267 if (zlabel_props.positionmode_is ("auto") | 4279 if (zlabel_props.positionmode_is ("auto") |
4268 || zlabel_props.rotationmode_is ("auto")) | 4280 || zlabel_props.rotationmode_is ("auto")) |
4269 { | 4281 { |
4270 Matrix ext (1, 2, 0.0); | 4282 Matrix ext (1, 2, 0.0); |
4271 ext = get_ticklabel_extents (get_ztick ().matrix_value (), | 4283 ext = get_ticklabel_extents (get_ztick ().matrix_value (), |
4272 get_zticklabel ().all_strings (), | 4284 get_zticklabel ().all_strings (), |
4273 get_zlim ().matrix_value ()); | 4285 get_zlim ().matrix_value ()); |
4274 | 4286 |
4275 double wmax = ext(0), hmax = ext(1), angle = 0; | 4287 double wmax = ext(0), hmax = ext(1), angle = 0; |
4276 ColumnVector p; | 4288 ColumnVector p; |
4277 | 4289 |
4278 if (xySym) | 4290 if (xySym) |
4279 { | 4291 { |
4280 p = graphics_xform::xform_vector (xPlaneN, yPlane, | 4292 p = graphics_xform::xform_vector (xPlaneN, yPlane, |
4281 (zpTickN+zpTick)/2); | 4293 (zpTickN+zpTick)/2); |
4282 if (xisinf (fy)) | 4294 if (xisinf (fy)) |
4283 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); | 4295 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); |
4284 else | 4296 else |
4285 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); | 4297 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); |
4286 } | 4298 } |
4287 else | 4299 else |
4288 { | 4300 { |
4289 p = graphics_xform::xform_vector (xPlane, yPlaneN, | 4301 p = graphics_xform::xform_vector (xPlane, yPlaneN, |
4290 (zpTickN+zpTick)/2); | 4302 (zpTickN+zpTick)/2); |
4291 if (xisinf (fx)) | 4303 if (xisinf (fx)) |
4292 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); | 4304 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); |
4293 else | 4305 else |
4294 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); | 4306 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); |
4295 } | 4307 } |
4296 | 4308 |
4297 p = xform.transform (p(0), p(1), p(2), false); | 4309 p = xform.transform (p(0), p(1), p(2), false); |
4298 | 4310 |
4299 switch (zstate) | 4311 switch (zstate) |
4300 { | 4312 { |
4301 case AXE_ANY_DIR: | 4313 case AXE_ANY_DIR: |
4302 if (camAuto) | 4314 if (camAuto) |
4303 { | 4315 { |
4304 p(0) -= wmax; | 4316 p(0) -= wmax; |
4305 angle = 90; | 4317 angle = 90; |
4306 } | 4318 } |
4307 | 4319 |
4308 // FIXME -- what's the correct offset? | 4320 // FIXME -- what's the correct offset? |
4309 // | 4321 // |
4310 // p[0] += (!xySym ? wmax : -wmax); | 4322 // p[0] += (!xySym ? wmax : -wmax); |
4311 // p[1] += (zSign ? hmax : -hmax); | 4323 // p[1] += (zSign ? hmax : -hmax); |
4312 | 4324 |
4313 break; | 4325 break; |
4314 | 4326 |
4315 case AXE_VERT_DIR: | 4327 case AXE_VERT_DIR: |
4316 p(0) -= wmax; | 4328 p(0) -= wmax; |
4317 angle = 90; | 4329 angle = 90; |
4318 break; | 4330 break; |
4319 | 4331 |
4320 case AXE_HORZ_DIR: | 4332 case AXE_HORZ_DIR: |
4321 p(1) += hmax; | 4333 p(1) += hmax; |
4322 break; | 4334 break; |
4323 } | 4335 } |
4324 | 4336 |
4325 if (zlabel_props.positionmode_is ("auto")) | 4337 if (zlabel_props.positionmode_is ("auto")) |
4326 { | 4338 { |
4327 p = xform.untransform (p(0), p(1), p(2), true); | 4339 p = xform.untransform (p(0), p(1), p(2), true); |
4328 zlabel_props.set_position (p.extract_n (0, 3).transpose ()); | 4340 zlabel_props.set_position (p.extract_n (0, 3).transpose ()); |
4329 zlabel_props.set_positionmode ("auto"); | 4341 zlabel_props.set_positionmode ("auto"); |
4330 } | 4342 } |
4331 | 4343 |
4332 if (zlabel_props.rotationmode_is ("auto")) | 4344 if (zlabel_props.rotationmode_is ("auto")) |
4333 { | 4345 { |
4334 zlabel_props.set_rotation (angle); | 4346 zlabel_props.set_rotation (angle); |
4335 zlabel_props.set_rotationmode ("auto"); | 4347 zlabel_props.set_rotationmode ("auto"); |
4336 } | 4348 } |
4337 } | 4349 } |
4338 } | 4350 } |
4339 | 4351 |
4340 void | 4352 void |
4341 axes::properties::update_title_position (void) | 4353 axes::properties::update_title_position (void) |
4342 { | 4354 { |
4345 text::properties& title_props = reinterpret_cast<text::properties&> | 4357 text::properties& title_props = reinterpret_cast<text::properties&> |
4346 (gh_manager::get_object (get_title ()).get_properties ()); | 4358 (gh_manager::get_object (get_title ()).get_properties ()); |
4347 | 4359 |
4348 if (title_props.positionmode_is ("auto")) | 4360 if (title_props.positionmode_is ("auto")) |
4349 { | 4361 { |
4350 // FIXME: bbox should be stored in axes::properties | 4362 // FIXME: bbox should be stored in axes::properties |
4351 ColumnVector bbox(4); | 4363 ColumnVector bbox(4); |
4352 bbox(0) = octave_Inf; | 4364 bbox(0) = octave_Inf; |
4353 bbox(1) = octave_Inf; | 4365 bbox(1) = octave_Inf; |
4354 bbox(2) = -octave_Inf; | 4366 bbox(2) = -octave_Inf; |
4355 bbox(3) = -octave_Inf; | 4367 bbox(3) = -octave_Inf; |
4356 for (int i = 0; i <= 1; i++) | 4368 for (int i = 0; i <= 1; i++) |
4357 for (int j = 0; j <= 1; j++) | 4369 for (int j = 0; j <= 1; j++) |
4358 for (int k = 0; k <= 1; k++) | 4370 for (int k = 0; k <= 1; k++) |
4359 { | 4371 { |
4360 ColumnVector p = xform.transform (i ? xPlaneN : xPlane, | 4372 ColumnVector p = xform.transform (i ? xPlaneN : xPlane, |
4361 j ? yPlaneN : yPlane, | 4373 j ? yPlaneN : yPlane, |
4362 k ? zPlaneN : zPlane, false); | 4374 k ? zPlaneN : zPlane, false); |
4363 bbox(0) = std::min (bbox(0), p(0)); | 4375 bbox(0) = std::min (bbox(0), p(0)); |
4364 bbox(1) = std::min (bbox(1), p(1)); | 4376 bbox(1) = std::min (bbox(1), p(1)); |
4365 bbox(2) = std::max (bbox(2), p(0)); | 4377 bbox(2) = std::max (bbox(2), p(0)); |
4366 bbox(3) = std::max (bbox(3), p(1)); | 4378 bbox(3) = std::max (bbox(3), p(1)); |
4367 } | 4379 } |
4368 | 4380 |
4369 bbox(2) = bbox(2)-bbox(0); | 4381 bbox(2) = bbox(2)-bbox(0); |
4370 bbox(3) = bbox(3)-bbox(1); | 4382 bbox(3) = bbox(3)-bbox(1); |
4371 | 4383 |
4372 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10), | 4384 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10), |
4373 (x_zlim(0)+x_zlim(1))/2, true); | 4385 (x_zlim(0)+x_zlim(1))/2, true); |
4374 | 4386 |
4375 title_props.set_position (p.extract_n(0, 3).transpose ()); | 4387 title_props.set_position (p.extract_n(0, 3).transpose ()); |