00001 #ifndef msm_shape_mode_view_h_ 00002 #define msm_shape_mode_view_h_ 00003 00004 //: 00005 // \file 00006 // \brief Generates shapes displaying modes of a shape model. 00007 // \author Tim Cootes 00008 00009 #include <vgl/vgl_box_2d.h> 00010 #include <msm/msm_ref_shape_instance.h> 00011 00012 class vsml_smv_graphics; 00013 00014 //: Generates shapes displaying modes of a shape model. 00015 // Generates a set of shapes by varying one model parameter, 00016 // placing shapes in a row. This is useful for display programs. 00017 // 00018 // Essentially two modes of output can be generated. The shapes 00019 // are either all overlapping (suitable for showing change if 00020 // plotted all together, or for generating a moving if plotted 00021 // sequentially), or are arranged in a row (useful for creating 00022 // a picture for a document). Use set_overlap_shapes(bool) to 00023 // select which mode is required. 00024 class msm_shape_mode_view { 00025 private: 00026 const msm_ref_shape_model* shape_model_; 00027 msm_ref_shape_instance sm_inst_; 00028 00029 vnl_vector<double> b_sd_; 00030 vnl_vector<double> b_; 00031 00032 vcl_vector<msm_points> points_; 00033 00034 //: Number of shapes for each mode 00035 unsigned n_per_mode_; 00036 00037 //: Current mode 00038 unsigned mode_; 00039 00040 //: Range in units of sd 00041 double sd_range_; 00042 00043 //: Scale relative to optimal scale to fit shapes to window 00044 double rel_scale_; 00045 00046 //: When true, overlap all the shapes 00047 bool overlap_shapes_; 00048 00049 vgl_box_2d<int> display_win_; 00050 00051 public: 00052 00053 //: Dflt ctor 00054 msm_shape_mode_view(); 00055 00056 //: Destructor 00057 virtual ~msm_shape_mode_view() {} 00058 00059 //: Define shape model 00060 void set_shape_model(const msm_ref_shape_model&); 00061 00062 //: Current shape model 00063 const msm_ref_shape_model& shape_model() const; 00064 00065 //: When true, overlap all the shapes to highlight changes 00066 bool overlap_shapes() const { return overlap_shapes_; } 00067 00068 //: When true, overlap all the shapes 00069 void set_overlap_shapes(bool b); 00070 00071 //: Current array of sets of points 00072 // These are the shapes to be displayed 00073 const vcl_vector<msm_points>& points() const { return points_; } 00074 00075 //: Compute the shapes so they fit into current window 00076 // \param n_shapes Number of shapes to display 00077 // \param range Range (in sd) to vary shapes by 00078 // \param vary_one If one shape and this is true then use range as parameter, else use 0 00079 void compute_shapes(unsigned n_shapes, double range, bool vary_one); 00080 00081 //: Compute the shapes so they fit into current window 00082 void compute_shapes(); 00083 00084 //: Define current display window size 00085 void set_display_window(const vgl_box_2d<int> & win); 00086 00087 //: Define width of display region for a single shape 00088 // Height estimated from aspect ratio of mean shape 00089 // Width of display window is then a multiple of this, 00090 // depending on the number of shapes along the row. 00091 void set_display_width(double); 00092 00093 //: Current display window 00094 const vgl_box_2d<int> & display_window() const 00095 { return display_win_; } 00096 00097 //: Define current mode to use. 00098 // Mode=1 is first shape mode 00099 void set_mode(unsigned m); 00100 00101 //: Current mode 00102 unsigned mode() const { return mode_; } 00103 00104 //: Define number of shapes per mode 00105 void set_n_per_mode(unsigned n); 00106 00107 //: Current number of shapes per mode 00108 unsigned n_per_mode() const { return n_per_mode_; } 00109 00110 //: Maximum number of shape modes available 00111 unsigned max_modes() const; 00112 00113 //: Set range (in units of SD) 00114 void set_range(double r); 00115 00116 //: Get range (in units of SD) 00117 double range() const { return sd_range_; } 00118 }; 00119 00120 #endif // msm_shape_mode_view_h_ 00121 00122