Mercurial > hg > octave-nkf
comparison src/graphics.cc @ 12910:e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
* graphics.cc: new static boolean variables updating_xlabel_position,
updating_ylabel_position, updating_zlabel_position, updating_title_position.
author | Konstantinos Poulios <logari81@gmail.com> |
---|---|
date | Wed, 03 Aug 2011 16:28:21 +0200 |
parents | 6c1d0f03c331 |
children | 22bc9ec80c2c |
comparison
equal
deleted
inserted
replaced
12909:abb33ad310e6 | 12910:e77284b6dac6 |
---|---|
4328 update_ylabel_position (); | 4328 update_ylabel_position (); |
4329 update_zlabel_position (); | 4329 update_zlabel_position (); |
4330 update_title_position (); | 4330 update_title_position (); |
4331 } | 4331 } |
4332 | 4332 |
4333 static bool updating_xlabel_position = false; | |
4334 | |
4333 void | 4335 void |
4334 axes::properties::update_xlabel_position (void) | 4336 axes::properties::update_xlabel_position (void) |
4335 { | 4337 { |
4338 if (updating_xlabel_position) | |
4339 return; | |
4340 | |
4336 text::properties& xlabel_props = reinterpret_cast<text::properties&> | 4341 text::properties& xlabel_props = reinterpret_cast<text::properties&> |
4337 (gh_manager::get_object (get_xlabel ()).get_properties ()); | 4342 (gh_manager::get_object (get_xlabel ()).get_properties ()); |
4338 | 4343 |
4339 bool is_empty = xlabel_props.get_string ().empty (); | 4344 bool is_empty = xlabel_props.get_string ().empty (); |
4340 | 4345 |
4341 xlabel_props.set_autopos_tag ("none"); | 4346 unwind_protect frame; |
4347 frame.protect_var (updating_xlabel_position); | |
4348 updating_xlabel_position = true; | |
4342 | 4349 |
4343 if (! is_empty) | 4350 if (! is_empty) |
4344 { | 4351 { |
4345 if (xlabel_props.horizontalalignmentmode_is ("auto")) | 4352 if (xlabel_props.horizontalalignmentmode_is ("auto")) |
4346 { | 4353 { |
4410 { | 4417 { |
4411 xlabel_props.set_rotation (angle); | 4418 xlabel_props.set_rotation (angle); |
4412 xlabel_props.set_rotationmode ("auto"); | 4419 xlabel_props.set_rotationmode ("auto"); |
4413 } | 4420 } |
4414 } | 4421 } |
4415 | 4422 } |
4416 xlabel_props.set_autopos_tag ("xlabel"); | 4423 |
4417 } | 4424 static bool updating_ylabel_position = false; |
4418 | 4425 |
4419 void | 4426 void |
4420 axes::properties::update_ylabel_position (void) | 4427 axes::properties::update_ylabel_position (void) |
4421 { | 4428 { |
4429 if (updating_ylabel_position) | |
4430 return; | |
4431 | |
4422 text::properties& ylabel_props = reinterpret_cast<text::properties&> | 4432 text::properties& ylabel_props = reinterpret_cast<text::properties&> |
4423 (gh_manager::get_object (get_ylabel ()).get_properties ()); | 4433 (gh_manager::get_object (get_ylabel ()).get_properties ()); |
4424 | 4434 |
4425 bool is_empty = ylabel_props.get_string ().empty (); | 4435 bool is_empty = ylabel_props.get_string ().empty (); |
4426 | 4436 |
4427 ylabel_props.set_autopos_tag ("none"); | 4437 unwind_protect frame; |
4438 frame.protect_var (updating_ylabel_position); | |
4439 updating_ylabel_position = true; | |
4428 | 4440 |
4429 if (! is_empty) | 4441 if (! is_empty) |
4430 { | 4442 { |
4431 if (ylabel_props.horizontalalignmentmode_is ("auto")) | 4443 if (ylabel_props.horizontalalignmentmode_is ("auto")) |
4432 { | 4444 { |
4496 { | 4508 { |
4497 ylabel_props.set_rotation (angle); | 4509 ylabel_props.set_rotation (angle); |
4498 ylabel_props.set_rotationmode ("auto"); | 4510 ylabel_props.set_rotationmode ("auto"); |
4499 } | 4511 } |
4500 } | 4512 } |
4501 | 4513 } |
4502 ylabel_props.set_autopos_tag ("ylabel"); | 4514 |
4503 } | 4515 static bool updating_zlabel_position = false; |
4504 | 4516 |
4505 void | 4517 void |
4506 axes::properties::update_zlabel_position (void) | 4518 axes::properties::update_zlabel_position (void) |
4507 { | 4519 { |
4520 if (updating_zlabel_position) | |
4521 return; | |
4522 | |
4508 text::properties& zlabel_props = reinterpret_cast<text::properties&> | 4523 text::properties& zlabel_props = reinterpret_cast<text::properties&> |
4509 (gh_manager::get_object (get_zlabel ()).get_properties ()); | 4524 (gh_manager::get_object (get_zlabel ()).get_properties ()); |
4510 | 4525 |
4511 bool camAuto = cameraupvectormode_is ("auto"); | 4526 bool camAuto = cameraupvectormode_is ("auto"); |
4512 bool is_empty = zlabel_props.get_string ().empty (); | 4527 bool is_empty = zlabel_props.get_string ().empty (); |
4513 | 4528 |
4514 zlabel_props.set_autopos_tag ("none"); | 4529 unwind_protect frame; |
4530 frame.protect_var (updating_zlabel_position); | |
4531 updating_zlabel_position = true; | |
4515 | 4532 |
4516 if (! is_empty) | 4533 if (! is_empty) |
4517 { | 4534 { |
4518 if (zlabel_props.horizontalalignmentmode_is ("auto")) | 4535 if (zlabel_props.horizontalalignmentmode_is ("auto")) |
4519 { | 4536 { |
4604 { | 4621 { |
4605 zlabel_props.set_rotation (angle); | 4622 zlabel_props.set_rotation (angle); |
4606 zlabel_props.set_rotationmode ("auto"); | 4623 zlabel_props.set_rotationmode ("auto"); |
4607 } | 4624 } |
4608 } | 4625 } |
4609 | 4626 } |
4610 zlabel_props.set_autopos_tag ("zlabel"); | 4627 |
4611 } | 4628 static bool updating_title_position = false; |
4612 | 4629 |
4613 void | 4630 void |
4614 axes::properties::update_title_position (void) | 4631 axes::properties::update_title_position (void) |
4615 { | 4632 { |
4633 if (updating_title_position) | |
4634 return; | |
4635 | |
4616 text::properties& title_props = reinterpret_cast<text::properties&> | 4636 text::properties& title_props = reinterpret_cast<text::properties&> |
4617 (gh_manager::get_object (get_title ()).get_properties ()); | 4637 (gh_manager::get_object (get_title ()).get_properties ()); |
4618 | 4638 |
4619 title_props.set_autopos_tag ("none"); | 4639 unwind_protect frame; |
4640 frame.protect_var (updating_title_position); | |
4641 updating_title_position = true; | |
4620 | 4642 |
4621 if (title_props.positionmode_is ("auto")) | 4643 if (title_props.positionmode_is ("auto")) |
4622 { | 4644 { |
4623 graphics_xform xform = get_transform (); | 4645 graphics_xform xform = get_transform (); |
4624 | 4646 |
4628 (x_zlim(0)+x_zlim(1))/2, true); | 4650 (x_zlim(0)+x_zlim(1))/2, true); |
4629 | 4651 |
4630 title_props.set_position (p.extract_n(0, 3).transpose ()); | 4652 title_props.set_position (p.extract_n(0, 3).transpose ()); |
4631 title_props.set_positionmode ("auto"); | 4653 title_props.set_positionmode ("auto"); |
4632 } | 4654 } |
4633 | |
4634 title_props.set_autopos_tag ("title"); | |
4635 } | 4655 } |
4636 | 4656 |
4637 void | 4657 void |
4638 axes::properties::update_autopos (const std::string& elem_type) | 4658 axes::properties::update_autopos (const std::string& elem_type) |
4639 { | 4659 { |