]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/chart.h
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / chart.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #ifndef wx_chart_h
27 #define wx_chart_h
28
29
30 //-----------------------------------------------------------------
31 #ifdef __GNUG__
32     #pragma interface "chart.h"
33 #endif
34
35 #ifdef __BORLANDC__
36         #pragma hdrstop
37 #endif
38
39 //---------------------------------------------------------------------
40 #include "wx/wxprec.h"
41 #ifndef WX_PRECOMP
42         #include "wx/wx.h"
43 #endif
44
45
46 //---------------------------------------------------------------------
47 #define MAX_DATASET   10
48 #define MAX_ITEM      50 
49 #define MARGE              5
50 #define MINOR_STEP    10
51 #define MAJOR_STEP     5
52 #define MAX_PER      200 
53 #define MINOR_PER     25
54 #define MAJOR_PER     50
55         
56 enum 
57 {
58   wxArea              = 0,
59   wxPerimeter         = 1,
60   wxDiameterArea      = 2, 
61   wxDiameterPerimeter = 3,
62   wxMinimumDiameter   = 4,
63   wxMaximumDiameter   = 5,
64   wxAverageDiameter   = 6,
65   wxStenosis          = 7
66 };
67
68
69 //-------------------------------------------------------------------
70 class wxDataSet: public wxObject
71 {
72  protected:
73    wxBrush  *m_dataStyle;
74    wxPen    *m_lineStyle;
75    wxString *m_text;
76    int       m_dataWidth;     // Scaled|Fixed
77    int       m_lineWidth;
78    int       m_pointMark;
79    int       m_displayValues; // def=NONE |IN | OUT 
80    bool      m_display;
81
82  public:
83    wxList *m_rowsList;
84  
85  public :
86    // Constructor & Destructor
87    wxDataSet(wxPen *lStype, wxBrush *dStyle,
88              int dWidth, int lWidth, int dGap, int pMark,
89              int disValues);
90    wxDataSet(wxPen *lStype, wxBrush *dStyle,
91              wxString *lText, bool lDisplay=false);
92    wxDataSet();
93    ~wxDataSet();
94  
95     // Set
96    void SetDataStyle(wxBrush* brush)  { m_dataStyle = brush;}
97    void SetDataWidth(int width)       { m_dataWidth = width;}
98    void SetLineStyle(wxPen* style)    { m_lineStyle = style;}
99    void SetPointMark(int mark)        { m_pointMark = mark; }
100    void SetText(wxString* string)     { m_text = string;    }
101    void Show(bool show)               { m_display=show;     }
102    
103    // Get
104    bool      GetShow()      { return m_display;   }
105    wxBrush*  GetDataStyle() { return m_dataStyle; }
106    int       GetDataWidth() { return m_dataWidth; }
107    wxPen*    GetLineStyle() { return m_lineStyle; }
108    int       GetPointMark() { return m_pointMark; }
109    wxString* GetText()      { return m_text;      }
110    
111 };
112 //---------------------------------------------------------------
113
114
115 class Table
116 {
117   public :
118     double x,y;
119         bool   empty;
120 };
121
122 //----------------------------------------------------------------------
123 class wxChart: public wxWindow
124 {
125 private:
126         
127     int         m_NumDataSet;
128         int         m_NumItem;
129         Table       m_table[MAX_DATASET][MAX_ITEM];
130     wxDataSet  *m_dataSetArray[MAX_DATASET]; 
131  
132     double  m_MinX, m_MaxX;
133     double  m_InfX, m_SupX, m_SupY;
134         
135         double  m_StepSizeX, m_StepSizeY, m_StepSizePer;
136     double  m_MaxValue; 
137     
138         int     m_ValueCol;      
139     bool    m_ShowPer;
140
141         int     m_MaxHauteur, m_MaxLargeur;
142     int     m_CenterX, m_CenterY;
143         int     m_EdgeTop, m_EdgeBottom, m_EdgeLeft, m_EdgeRight;
144     int     m_Top,m_Bottom, m_Left, m_Right;
145             
146     int     m_EdgeTopLegend, m_EdgeBottomLegend, m_EdgeLeftLegend, m_EdgeRightLegend;
147     int     m_TopLegend, m_BottomLegend, m_LeftLegend, m_RightLegend;
148         
149         double  m_MinorIncX, m_MajorIncX;
150     double  m_MinorIncY, m_MajorIncY;
151
152         void    DrawLine(wxDC &dc, int a);
153         void    DrawFond(wxDC& dc);
154     void    DrawAxe(wxDC& dc);
155     void    DrawAxePer(wxDC& dc);
156         void    DrawLegend(wxDC& dc, int nbr);
157         void    DrawGrille(wxDC& dc);
158         void    SetInitEdge();
159     void    SetChartBounds();
160         void    SetChartBoundsLegend();
161         void    SetCadreLegend(int nbr, int* bottom);
162     void    InitDataSet();
163     void    InitData();
164         double  MaxValue();
165         double  MinCol(double inf);
166     double  MaxCol(double sup);
167     void    SetInfX(double sup);
168         void    SetSupX(double sup);
169         void    SetSupY(double sup);
170     void    InitChart();
171     int     GetShow();
172
173 public:
174         // Constructor et Destructor
175         wxChart(wxFrame *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
176                 const wxSize& size = wxDefaultSize, long  style = wxDEFAULT_FRAME_STYLE,
177                 const wxString& name = wxPanelNameStr);
178     ~wxChart();
179         
180         void    OnPaint(wxPaintEvent& event);
181         void    OnLeftClick(wxDC &dc, double x, double y, int keys);
182         void    OnRightClick(wxDC &dc, double x, double y, int keys);
183         
184         void    Draw(wxDC& dc);
185         bool    IsEmpty(int a, int item);
186         double  GetDataX(int a, int item);
187         double  GetDataY(int a, int item);
188     void    SetData(int a, int item, double x, double y);
189     
190     void    SetMinX(double MinX);
191         void    SetMaxX(double MaxX);
192         void    SetMaxWidthHeight(int x,int y); 
193         void    SetCenterChart(int x, int y);
194         void    SetShowPer(bool per);
195         void    SetMaxValue(double max);
196         void    SetStepSizeX(double sizeX);
197     void    SetStepSizeY(double sizeY);
198     void    SetStepSizePer(double sizePer);
199     void    SetNumDataSet(int NumDataSet);
200         void    SetNumItem(int NumItem);
201         void    SetIncAxisX(double minor, double major);
202     void    SetIncAxisY(double minor, double major);
203     void    SetEdgeTop(int top);
204         void    SetEdgeBottom(int bottom);
205         void    SetEdgeLeft(int left);
206         void    SetEdgeRight(int right);
207     void    SetEdgeTopLegend(int top);
208         void    SetEdgeBottomLegend(int bottom);
209         void    SetEdgeLeftLegend(int left);
210         void    SetEdgeRightLegend(int right);
211         void    ShowDataSet(bool show,int dataset);
212         
213         double  GetMinX()          { return m_MinX;       }
214     double  GetMaxX()          { return m_MaxX;       }
215         int     GetMaxValue()      { return m_MaxValue;   }
216         double  GetStepSizeX()     { return m_StepSizeX;  }
217     double  GetStepSizeY()     { return m_StepSizeY;  }
218     double  GetStepSizePer()   { return m_StepSizePer;}
219     int     GetValueCol()      { return m_ValueCol;   }
220     int     GetNumDataSet()    { return m_NumDataSet; }
221         int     GetNumItem()       { return m_NumItem;    }
222         bool    GetShowPer()       { return m_ShowPer;    }
223         int     GetLargeur()       { return m_MaxLargeur; }
224     int     GetHauteur()       { return m_MaxHauteur; }
225         int     GetEdgeTop()       { return m_EdgeTop;    }
226     int     GetEdgeBottom()    { return m_EdgeBottom; }
227     int     GetEdgeLeft()      { return m_EdgeLeft;   }
228     int     GetEdgeRight()     { return m_EdgeRight;  }
229         int     GetEdgeTopLegend()    { return m_EdgeTopLegend;    }
230     int     GetEdgeBottomLegend() { return m_EdgeBottomLegend; }
231     int     GetEdgeLeftLegend()   { return m_EdgeLeftLegend;   }
232     int     GetEdgeRightLegend()  { return m_EdgeRightLegend;  }
233         bool    GetShowDataSet(int dataset);
234   
235    DECLARE_EVENT_TABLE()
236 };
237
238 #endif // wx_chart_h