Mercurial > hg > octave-nkf
comparison src/graphics.h.in @ 7836:4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 21 Feb 2008 13:45:04 +0100 |
parents | ca8b97bb952c |
children | 1357bcae6e29 |
comparison
equal
deleted
inserted
replaced
7835:ca8b97bb952c | 7836:4fb2db9c87dd |
---|---|
715 // --------------------------------------------------------------------- | 715 // --------------------------------------------------------------------- |
716 | 716 |
717 class array_property : public base_property | 717 class array_property : public base_property |
718 { | 718 { |
719 public: | 719 public: |
720 array_property (void) | |
721 : base_property ("", graphics_handle ()), data (Matrix ()) | |
722 { | |
723 get_data_limits (); | |
724 } | |
725 | |
720 array_property (const std::string& nm, const graphics_handle& h, | 726 array_property (const std::string& nm, const graphics_handle& h, |
721 const octave_value& m) | 727 const octave_value& m) |
722 : base_property (nm, h), data (m) { } | 728 : base_property (nm, h), data (m) |
729 { | |
730 get_data_limits (); | |
731 } | |
723 | 732 |
724 octave_value get (void) const { return data; } | 733 octave_value get (void) const { return data; } |
725 | 734 |
726 void set (const octave_value& v) | 735 void set (const octave_value& v) |
727 { | 736 { |
728 if (validate (v)) | 737 if (validate (v)) |
729 data = v; | 738 { |
739 data = v; | |
740 | |
741 get_data_limits (); | |
742 } | |
730 else | 743 else |
731 error ("invalid value for array property \"%s\"", | 744 error ("invalid value for array property \"%s\"", |
732 get_name ().c_str ()); | 745 get_name ().c_str ()); |
733 } | 746 } |
734 | 747 |
736 { type_constraints.push_back (type); } | 749 { type_constraints.push_back (type); } |
737 | 750 |
738 void add_constraint (const dim_vector& dims) | 751 void add_constraint (const dim_vector& dims) |
739 { size_constraints.push_back (dims); } | 752 { size_constraints.push_back (dims); } |
740 | 753 |
754 double min_val (void) const { return xmin; } | |
755 double max_val (void) const { return xmax; } | |
756 double min_pos (void) const { return xminp; } | |
757 | |
741 array_property& operator = (const octave_value& val) | 758 array_property& operator = (const octave_value& val) |
742 { | 759 { |
743 set (val); | 760 set (val); |
744 return *this; | 761 return *this; |
745 } | 762 } |
746 | 763 |
747 private: | 764 private: |
748 OCTINTERP_API bool validate (const octave_value& v); | 765 OCTINTERP_API bool validate (const octave_value& v); |
749 | 766 |
767 OCTINTERP_API void get_data_limits (void); | |
768 | |
750 protected: | 769 protected: |
751 octave_value data; | 770 octave_value data; |
771 double xmin; | |
772 double xmax; | |
773 double xminp; | |
752 std::list<std::string> type_constraints; | 774 std::list<std::string> type_constraints; |
753 std::list<dim_vector> size_constraints; | 775 std::list<dim_vector> size_constraints; |
754 }; | 776 }; |
755 | 777 |
756 class row_vector_property : public array_property | 778 class row_vector_property : public array_property |
1655 { | 1677 { |
1656 error ("get: invalid property \"xudata\""); | 1678 error ("get: invalid property \"xudata\""); |
1657 return data_property (); | 1679 return data_property (); |
1658 } | 1680 } |
1659 | 1681 |
1660 virtual data_property get_cdata_property (void) const | 1682 virtual array_property get_cdata_property (void) const |
1661 { | 1683 { |
1662 error ("get: invalid property \"cdata\""); | 1684 error ("get: invalid property \"cdata\""); |
1663 return data_property (); | 1685 return array_property (); |
1664 } | 1686 } |
1665 | 1687 |
1666 protected: | 1688 protected: |
1667 // properties common to all objects | 1689 // properties common to all objects |
1668 bool_property beingdeleted; | 1690 bool_property beingdeleted; |
2030 { | 2052 { |
2031 const base_properties& props = get_properties (); | 2053 const base_properties& props = get_properties (); |
2032 return props.get_xudata_property (); | 2054 return props.get_xudata_property (); |
2033 } | 2055 } |
2034 | 2056 |
2035 data_property get_cdata_property (void) const | 2057 array_property get_cdata_property (void) const |
2036 { | 2058 { |
2037 const base_properties& props = get_properties (); | 2059 const base_properties& props = get_properties (); |
2038 return props.get_cdata_property (); | 2060 return props.get_cdata_property (); |
2039 } | 2061 } |
2040 | 2062 |
2855 // properties declarations. | 2877 // properties declarations. |
2856 | 2878 |
2857 BEGIN_PROPERTIES(image) | 2879 BEGIN_PROPERTIES(image) |
2858 data_property xdata l , Matrix () | 2880 data_property xdata l , Matrix () |
2859 data_property ydata l , Matrix () | 2881 data_property ydata l , Matrix () |
2860 data_property cdata l , Matrix () | 2882 array_property cdata l , Matrix () |
2861 radio_property cdatamapping a , "{scaled}|direct" | 2883 radio_property cdatamapping a , "{scaled}|direct" |
2862 END_PROPERTIES | 2884 END_PROPERTIES |
2863 | 2885 |
2864 protected: | 2886 protected: |
2865 void init (void) | 2887 void init (void) |
2866 { | 2888 { |
2889 cdata.add_constraint ("double"); | |
2890 cdata.add_constraint ("uint8"); | |
2891 cdata.add_constraint (dim_vector (-1, -1)); | |
2892 cdata.add_constraint (dim_vector (-1, -1, 3)); | |
2867 } | 2893 } |
2868 }; | 2894 }; |
2869 | 2895 |
2870 private: | 2896 private: |
2871 properties xproperties; | 2897 properties xproperties; |
2901 | 2927 |
2902 BEGIN_PROPERTIES(patch) | 2928 BEGIN_PROPERTIES(patch) |
2903 data_property xdata l , Matrix () | 2929 data_property xdata l , Matrix () |
2904 data_property ydata l , Matrix () | 2930 data_property ydata l , Matrix () |
2905 data_property zdata l , Matrix () | 2931 data_property zdata l , Matrix () |
2906 data_property cdata l , Matrix () | 2932 array_property cdata l , Matrix () |
2907 radio_property cdatamapping , "{scaled}|direct" | 2933 radio_property cdatamapping , "{scaled}|direct" |
2908 array_property faces , Matrix () | 2934 array_property faces , Matrix () |
2909 data_property facevertexalphadata , Matrix () | 2935 data_property facevertexalphadata , Matrix () |
2910 data_property facevertexcdata , Matrix () | 2936 array_property facevertexcdata , Matrix () |
2911 array_property vertices , Matrix () | 2937 array_property vertices , Matrix () |
2912 array_property vertexnormals , Matrix () | 2938 array_property vertexnormals , Matrix () |
2913 radio_property normalmode , "{auto}|manual" | 2939 radio_property normalmode , "{auto}|manual" |
2914 color_property facecolor , "{flat}|none|interp" | 2940 color_property facecolor , "{flat}|none|interp" |
2915 double_property facealpha , 1.0 | 2941 double_property facealpha , 1.0 |
2937 protected: | 2963 protected: |
2938 void init (void) | 2964 void init (void) |
2939 { | 2965 { |
2940 vertices.add_constraint (dim_vector (-1, 2)); | 2966 vertices.add_constraint (dim_vector (-1, 2)); |
2941 vertices.add_constraint (dim_vector (-1, 3)); | 2967 vertices.add_constraint (dim_vector (-1, 3)); |
2968 cdata.add_constraint (dim_vector (-1, -1)); | |
2969 cdata.add_constraint (dim_vector (-1, -1, 3)); | |
2970 facevertexcdata.add_constraint (dim_vector (-1, 1)); | |
2971 facevertexcdata.add_constraint (dim_vector (-1, 3)); | |
2942 } | 2972 } |
2943 }; | 2973 }; |
2944 | 2974 |
2945 private: | 2975 private: |
2946 properties xproperties; | 2976 properties xproperties; |
2976 | 3006 |
2977 BEGIN_PROPERTIES(surface) | 3007 BEGIN_PROPERTIES(surface) |
2978 data_property xdata lu , Matrix () | 3008 data_property xdata lu , Matrix () |
2979 data_property ydata lu , Matrix () | 3009 data_property ydata lu , Matrix () |
2980 data_property zdata lu , Matrix () | 3010 data_property zdata lu , Matrix () |
2981 // FIXME: cdata can be of type "double" or "uint8" | 3011 array_property cdata l , Matrix () |
2982 data_property cdata l , Matrix () | |
2983 radio_property cdatamapping a , "{scaled}|direct" | 3012 radio_property cdatamapping a , "{scaled}|direct" |
2984 color_property facecolor , "{flat}|none|interp|texturemap" | 3013 color_property facecolor , "{flat}|none|interp|texturemap" |
2985 // FIXME: should be a double-radio property | 3014 // FIXME: should be a double-radio property |
2986 double_property facealpha , 1.0 | 3015 double_property facealpha , 1.0 |
2987 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) | 3016 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
3016 { | 3045 { |
3017 alphadata.add_constraint ("double"); | 3046 alphadata.add_constraint ("double"); |
3018 alphadata.add_constraint ("uint8"); | 3047 alphadata.add_constraint ("uint8"); |
3019 alphadata.add_constraint (dim_vector (-1, -1)); | 3048 alphadata.add_constraint (dim_vector (-1, -1)); |
3020 vertexnormals.add_constraint (dim_vector (-1, -1, 3)); | 3049 vertexnormals.add_constraint (dim_vector (-1, -1, 3)); |
3021 // FIXME: uncomment this when cdata has the right type | 3050 cdata.add_constraint ("double"); |
3022 //cdata.add_constraint ("double"); | 3051 cdata.add_constraint ("uint8"); |
3023 //cdata.add_constraint ("double"); | 3052 cdata.add_constraint (dim_vector (-1, -1)); |
3024 //cdata.add_constraint (dim_vector (-1, -1)); | 3053 cdata.add_constraint (dim_vector (-1, -1, 3)); |
3025 //cdata.add_constraint (dim_vector (-1, -1, 3)); | |
3026 } | 3054 } |
3027 | 3055 |
3028 private: | 3056 private: |
3029 void update_normals (void); | 3057 void update_normals (void); |
3030 | 3058 |