Ignore:
Timestamp:
08/17/2009 08:42:41 PM (3 years ago)
Author:
guyru
Message:

Render legend in the SimplePiePlot? widget

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/simple_pie_plot.h

    r207 r208  
    3232                 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, 
    3333                 long style = wxNO_BORDER, const wxString& name = wxPanelNameStr); 
    34         void SetData(std::vector<double> d); 
     34        void SetData(std::vector<double> d, std::vector<wxString> labels); 
    3535        void OnPaint(wxPaintEvent& event); 
    3636        void OnResize(wxSizeEvent& event); 
    3737        void OnMouseLeaveWindow(wxMouseEvent& event); 
    3838        void OnMouseMove(wxMouseEvent& event); 
     39        wxSize GetMinSize() const; 
    3940private: 
    4041        /** 
     
    4445        wxColour GetSegmentColor(int i); 
    4546 
     47        /** 
     48         * Calculate the angles in the plot and populate the m_angles array. 
     49         */ 
     50        void CalculateAngles(); 
     51 
     52        /** 
     53         * Calculate the maximum widht and height for a label in the legend. 
     54         */ 
     55        void CalculateLegendDimensions(wxGraphicsContext *dc); 
     56 
     57        /** 
     58         * Calculate the location and radius of the pie plot. 
     59         */ 
     60        void CalculatePiePlotLocation(); 
     61 
     62        void DrawLegend(wxGraphicsContext *dc); 
     63 
    4664        void Highlight(int i); 
    4765        void ClearHighlight(); 
    4866 
    4967        std::vector<double> m_data; 
     68        std::vector<wxString> m_labels; 
    5069        std::vector<double> m_angles; 
    5170        double m_data_total; 
    5271        int m_highlight; 
     72 
     73        /// maximum width for a label in the legend. 
     74        double m_max_legend_width; 
     75        /// maximum height for a label in the legend. 
     76        double m_max_legend_height; 
     77        /// total width of the legend 
     78        double m_legend_width; 
     79        /// the line height of each legend entry including padding 
     80        double m_legend_line_height; 
     81 
     82        static const double m_legend_left_padding = 10; 
     83 
     84        // The center point of the pie plot 
     85        double m_pie_x; 
     86        double m_pie_y; 
     87        double m_radius; 
     88 
    5389}; 
    5490 
Note: See TracChangeset for help on using the changeset viewer.