comparison src/graphics.cc @ 10949:848f3a13b7cf

Backed out changeset 6b50fd2d4ca6
author David Bateman <dbateman@free.fr>
date Tue, 07 Sep 2010 21:44:13 +0200
parents 6b50fd2d4ca6
children a8235d26b57a
comparison
equal deleted inserted replaced
10948:6b50fd2d4ca6 10949:848f3a13b7cf
2550 2550
2551 #include "graphics-props.cc" 2551 #include "graphics-props.cc"
2552 2552
2553 // --------------------------------------------------------------------- 2553 // ---------------------------------------------------------------------
2554 2554
2555 octave_value
2556 root_figure::properties::get_monitorpositions (void) const
2557 {
2558 Matrix sz = screensize.get ().matrix_value ().extract_n (0, 2, 1, 2);
2559 return convert_position (monitorpositions.get ().matrix_value (),
2560 "pixels", get_units (), sz);
2561
2562 }
2563
2564 void
2565 root_figure::properties::set_monitorpositions (const octave_value& val)
2566 {
2567 if (! error_state)
2568 {
2569 Matrix sz = screensize.get ().matrix_value ().extract_n (0, 2, 1, 2);
2570 Matrix pos = convert_position (val.matrix_value (), get_units (), "pixels", sz);
2571
2572 if (monitorpositions.set (octave_value (pos), true))
2573 {
2574 mark_modified ();
2575 }
2576 }
2577 }
2578
2579 octave_value
2580 root_figure::properties::get_pointerlocation (void) const
2581 {
2582 Matrix sz = screensize.get ().matrix_value ().extract_n (0, 2, 1, 2);
2583 Matrix pos = pointerpositions.get ().matrix_value ();
2584 pos.resize (1, 4);
2585 return convert_position (pos, "pixels", get_units (), sz).extract_n (0, 0, 1, 2);
2586 }
2587
2588 void
2589 root_figure::properties::set_pointerlocation (const octave_value& val)
2590 {
2591 if (! error_state)
2592 {
2593 Matrix sz = screensize.get ().matrix_value ().extract_n (0, 2, 1, 2);
2594 Matrix pos1 = val.matrix_value ();
2595 pos1.resize (1, 4);
2596 Matrix pos2 = convert_position (pos1, get_units (), "pixels", sz).extract_n (0, 0, 1, 2);
2597
2598 if (pointerlocation.set (octave_value (pos2), true))
2599 {
2600 mark_modified ();
2601 }
2602 }
2603 }
2604
2605 octave_value
2606 root_figure::properties::get_screensize (void) const
2607 {
2608 Matrix sz = screensize.get ().matrix_value ().extract_n (0, 2, 1, 2);
2609 Matrix sz2 (sz);
2610 sz2.resize (1, 4);
2611 return convert_position (sz2, "pixels", get_units (), sz).extract_n (0, 0, 1, 2);
2612 }
2613
2614 void 2555 void
2615 root_figure::properties::set_currentfigure (const octave_value& v) 2556 root_figure::properties::set_currentfigure (const octave_value& v)
2616 { 2557 {
2617 graphics_handle val (v); 2558 graphics_handle val (v);
2618 2559
2807 figure::properties::get_boundingbox (bool) const 2748 figure::properties::get_boundingbox (bool) const
2808 { 2749 {
2809 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2); 2750 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2);
2810 Matrix pos; 2751 Matrix pos;
2811 2752
2812 pos = convert_position (position.get ().matrix_value (), get_units (), 2753 pos = convert_position (get_position ().matrix_value (), get_units (),
2813 "pixels", screen_size); 2754 "pixels", screen_size);
2814 2755
2815 pos(0)--; 2756 pos(0)--;
2816 pos(1)--; 2757 pos(1)--;
2817 pos(1) = screen_size(1) - pos(1) - pos(3); 2758 pos(1) = screen_size(1) - pos(1) - pos(3);
2831 pos = convert_position (pos, "pixels", get_units (), screen_size); 2772 pos = convert_position (pos, "pixels", get_units (), screen_size);
2832 2773
2833 set_position (pos); 2774 set_position (pos);
2834 } 2775 }
2835 2776
2836 octave_value
2837 figure::properties::get_position (void) const
2838 {
2839 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2);
2840 return convert_position (position.get ().matrix_value (),
2841 "pixels", get_units (), screen_size);
2842 }
2843
2844 void 2777 void
2845 figure::properties::set_position (const octave_value& v) 2778 figure::properties::set_position (const octave_value& v)
2846 { 2779 {
2847 if (! error_state) 2780 if (! error_state)
2848 { 2781 {
2849 Matrix old_bb, new_bb; 2782 Matrix old_bb, new_bb;
2850 2783
2851 old_bb = get_boundingbox (); 2784 old_bb = get_boundingbox ();
2852 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2); 2785 position = v;
2853 position = convert_position (v.matrix_value (), get_units (),
2854 "pixels", screen_size);
2855 new_bb = get_boundingbox (); 2786 new_bb = get_boundingbox ();
2856 2787
2857 if (old_bb != new_bb) 2788 if (old_bb != new_bb)
2858 { 2789 {
2859 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3)) 2790 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
2862 update_boundingbox (); 2793 update_boundingbox ();
2863 } 2794 }
2864 } 2795 }
2865 2796
2866 mark_modified (); 2797 mark_modified ();
2867 }
2868 }
2869
2870 octave_value
2871 figure::properties::get_paperposition (void) const
2872 {
2873 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2);
2874 return convert_position (paperposition.get ().matrix_value (),
2875 "inches", get_paperunits (), screen_size);
2876 }
2877
2878 void
2879 figure::properties::set_paperposition (const octave_value& val)
2880 {
2881 if (! error_state)
2882 {
2883 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2);
2884 Matrix pos = convert_position (val.matrix_value (), get_paperunits (),
2885 "inches", screen_size);
2886 if (paperposition.set (octave_value (pos), true))
2887 {
2888 mark_modified ();
2889 }
2890 }
2891 }
2892
2893 octave_value
2894 figure::properties::get_papersize (void) const
2895 {
2896 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2);
2897 Matrix sz = papersize.get ().matrix_value ();
2898 sz. resize (1, 4);
2899 return convert_position (sz, "inches", get_paperunits (), screen_size). extract_n (0, 0, 1, 2);
2900 }
2901
2902 void
2903 figure::properties::set_papersize (const octave_value& val)
2904 {
2905 if (! error_state)
2906 {
2907 Matrix screen_size = xget (0, "screensize").matrix_value ().extract_n (0, 2, 1, 2);
2908 Matrix sz = val.matrix_value ();
2909 sz. resize (1, 4);
2910
2911 Matrix pos = convert_position (sz, get_paperunits (), "inches", screen_size). extract_n (0, 0, 1, 2);
2912 if (papersize.set (octave_value (pos), true))
2913 {
2914 mark_modified ();
2915 }
2916 } 2798 }
2917 } 2799 }
2918 2800
2919 std::string 2801 std::string
2920 figure::properties::get_title (void) const 2802 figure::properties::get_title (void) const
3787 pos(0)--; 3669 pos(0)--;
3788 pos(1)--; 3670 pos(1)--;
3789 pos(1) = parent_bb(3) - pos(1) - pos(3); 3671 pos(1) = parent_bb(3) - pos(1) - pos(3);
3790 3672
3791 return pos; 3673 return pos;
3792 }
3793
3794 octave_value
3795 axes::properties::get_outerposition (void) const
3796 {
3797 graphics_object obj = gh_manager::get_object (get_parent ());
3798 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
3799 return convert_position (outerposition.get ().matrix_value (),
3800 "normalized", get_units (),
3801 parent_bb.extract_n (0, 2, 1, 2));
3802 }
3803
3804 void
3805 axes::properties::set_outerposition (const octave_value& val)
3806 {
3807 if (! error_state)
3808 {
3809 graphics_object obj = gh_manager::get_object (get_parent ());
3810 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
3811 Matrix pos = convert_position (val.matrix_value(), get_units (),
3812 "normalized",
3813 parent_bb.extract_n (0, 2, 1, 2));
3814 if (outerposition.set (octave_value (pos), true))
3815 {
3816 update_outerposition ();
3817 mark_modified ();
3818 }
3819 }
3820 }
3821
3822 octave_value
3823 axes::properties::get_position (void) const
3824 {
3825 graphics_object obj = gh_manager::get_object (get_parent ());
3826 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
3827 return convert_position (position.get ().matrix_value (),
3828 "normalized", get_units (),
3829 parent_bb.extract_n (0, 2, 1, 2));
3830 }
3831
3832 void
3833 axes::properties::set_position (const octave_value& val)
3834 {
3835 if (! error_state)
3836 {
3837 graphics_object obj = gh_manager::get_object (get_parent ());
3838 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
3839 Matrix pos = convert_position (val.matrix_value (), get_units (), "normalized",
3840 parent_bb.extract_n (0, 2, 1, 2));
3841 if (position.set (octave_value (pos), true))
3842 {
3843 update_position ();
3844 mark_modified ();
3845 }
3846 }
3847 } 3674 }
3848 3675
3849 ColumnVector 3676 ColumnVector
3850 graphics_xform::xform_vector (double x, double y, double z) 3677 graphics_xform::xform_vector (double x, double y, double z)
3851 { 3678 {