1 /* @include ajhist ************************************************************ 2 ** 3 ** AJAX GRAPH (ajax histogram) functions 4 ** 5 ** These functions control all aspects of AJAX histogram. 6 ** 7 ** @author Copyright (C) 1998 Peter Rice 8 ** @version $Revision: 1.25 $ 9 ** @modified 1988-11-12 pmr First version 10 ** @modified 1999 ajb ANSIfication 11 ** @modified $Date: 2011/09/27 11:19:27 $ by $Author: rice $ 12 ** @@ 13 ** 14 ** This library is free software; you can redistribute it and/or 15 ** modify it under the terms of the GNU Lesser General Public 16 ** License as published by the Free Software Foundation; either 17 ** version 2.1 of the License, or (at your option) any later version. 18 ** 19 ** This library is distributed in the hope that it will be useful, 20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 ** Lesser General Public License for more details. 23 ** 24 ** You should have received a copy of the GNU Lesser General Public 25 ** License along with this library; if not, write to the Free Software 26 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 27 ** MA 02110-1301, USA. 28 ** 29 ******************************************************************************/ 30 31 #ifndef AJHIST_H 32 #define AJHIST_H 33 34 /* ========================================================================= */ 35 /* ============================= include files ============================= */ 36 /* ========================================================================= */ 37 38 #include "ajdefine.h" 39 #include "ajgraph.h" 40 #include "ajstr.h" 41 #include <stdlib.h> 42 #include <stdio.h> 43 #include <string.h> 44 45 AJ_BEGIN_DECLS 46 47 48 49 50 /* ========================================================================= */ 51 /* =============================== constants =============================== */ 52 /* ========================================================================= */ 53 54 55 56 57 #define HIST_ONTOP 0 58 #define HIST_SIDEBYSIDE 1 59 #define HIST_SEPARATE 2 60 61 #define GRAPH_HIST (AJGRAPH_X_BOTTOM + AJGRAPH_Y_LEFT + AJGRAPH_Y_RIGHT + \ 62 AJGRAPH_Y_INVERT_TICK + AJGRAPH_X_INVERT_TICK + AJGRAPH_Y_TICK + \ 63 AJGRAPH_X_TICK + AJGRAPH_X_LABEL + AJGRAPH_Y_LABEL + AJGRAPH_TITLE ) 64 65 #ifndef WIN32 66 extern ajint aj_hist_mark; 67 #else 68 #ifdef AJAXGDLL_EXPORTS 69 __declspec(dllexport) ajint aj_hist_mark; 70 #else 71 __declspec(dllimport) ajint aj_hist_mark; 72 #endif 73 #endif 74 75 76 77 78 /* ========================================================================= */ 79 /* ============================== public data ============================== */ 80 /* ========================================================================= */ 81 82 83 84 85 /* @data AjPHistdata ********************************************************** 86 ** 87 ** AJAX data structure for histogram graph data 88 ** 89 ** @attr data [float*] y coordinates 90 ** @attr deletedata [AjBool] if true, delete data 91 ** @attr colour [ajint] colour code 92 ** @attr title [AjPStr] graph title 93 ** @attr subtitle [AjPStr] graph subtitle 94 ** @attr xaxis [AjPStr] x axis title 95 ** @attr yaxis [AjPStr] y axis title 96 ** @attr pattern [ajint] pattern code 97 ** @attr Padding [char[4]] Padding to alignment boundary 98 ** @@ 99 ******************************************************************************/ 100 101 typedef struct AjSHistdata { 102 float *data; 103 AjBool deletedata; 104 ajint colour; 105 AjPStr title; 106 AjPStr subtitle; 107 AjPStr xaxis; 108 AjPStr yaxis; 109 ajint pattern; 110 char Padding[4]; 111 } AjOHistdata; 112 #define AjPHistdata AjOHistdata* 113 114 115 116 117 /* @data AjPHist ************************************************************** 118 ** 119 ** AJAX data structure for histogram graph objects 120 ** 121 ** 122 ** @attr numofsets [ajuint] number of current sets 123 ** @attr numofsetsmax [ajuint] maximum number of sets 124 ** @attr numofdatapoints [ajuint] number of data points 125 ** @attr xmin [float] Lowest x value 126 ** @attr xmax [float] Highest x value 127 ** @attr displaytype [ajuint] Display type index 128 ** @attr bins [ajuint] Number of histogram bins 129 ** @attr BaW [AjBool] Black and white rendering if ajTrue 130 ** @attr title [AjPStr] Plot title 131 ** @attr subtitle [AjPStr] Plot subtitle 132 ** @attr xaxis [AjPStr] x axis title 133 ** @attr yaxisleft [AjPStr] y axis title 134 ** @attr yaxisright [AjPStr] second y axis title for right side 135 ** @attr graph [AjPGraph] Graph 136 ** @attr hists [AjPHistdata*] Histogram bin data 137 ** @@ 138 ******************************************************************************/ 139 140 typedef struct AjSHist { 141 ajuint numofsets; 142 ajuint numofsetsmax; 143 ajuint numofdatapoints; 144 float xmin; 145 float xmax; 146 ajuint displaytype; 147 ajuint bins; 148 AjBool BaW; 149 AjPStr title; 150 AjPStr subtitle; 151 AjPStr xaxis; 152 AjPStr yaxisleft; 153 AjPStr yaxisright; 154 AjPGraph graph; 155 AjPHistdata *hists; 156 } AjOHist; 157 #define AjPHist AjOHist* 158 159 160 161 162 /* ========================================================================= */ 163 /* =========================== public functions ============================ */ 164 /* ========================================================================= */ 165 166 167 168 /* 169 ** Prototype definitions 170 */ 171 172 void ajHistogramClose (void); 173 void ajHistDataCopy (AjPHist hist, ajuint indexnum, PLFLT const *data); 174 void ajHistDel (AjPHist* hist); 175 void ajHistDisplay (const AjPHist hist); 176 AjPHist ajHistNew (ajuint numofsets, ajuint numofpoints); 177 AjPHist ajHistNewG (ajuint numofsets, ajuint numofpoints, AjPGraph graph); 178 void ajHistSetMono (AjPHist hist, AjBool set); 179 void ajHistSetmultiColour(AjPHist hist, ajuint indexnum, ajint colour); 180 void ajHistSetmultiTitleS (AjPHist hist, ajuint indexnum, 181 const AjPStr title); 182 void ajHistSetmultiTitleC (AjPHist hist, ajuint indexnum, const char *title); 183 void ajHistSetmultiXlabelS (AjPHist hist, ajuint indexnum, 184 const AjPStr title); 185 void ajHistSetmultiXlabelC (AjPHist hist, ajuint indexnum, 186 const char *title); 187 void ajHistSetmultiYlabelS (AjPHist hist, ajuint indexnum, 188 const AjPStr title); 189 void ajHistSetmultiYlabelC (AjPHist hist, ajuint indexnum, 190 const char *title); 191 void ajHistSetmultiPattern (AjPHist hist, ajuint indexnum, ajint style); 192 void ajHistDataAdd (AjPHist hist, ajuint indexnum, PLFLT *data); 193 void ajHistSetTitleC (AjPHist hist, const char* strng); 194 void ajHistSetXlabelC (AjPHist hist, const char* strng); 195 void ajHistSetYlabelC (AjPHist hist,const char* strng); 196 void ajHistSetRlabelC (AjPHist hist, const char* strng); 197 198 void ajHistogramSetMark(ajint mark); 199 200 /* 201 ** End of prototype definitions 202 */ 203 204 #ifdef AJ_COMPILE_DEPRECATED_BOOK 205 #endif 206 #ifdef AJ_COMPILE_DEPRECATED 207 208 __deprecated void ajHistSetColour(AjPHist hist, ajuint indexnum, 209 ajint colour); 210 __deprecated void ajHistSetPattern (AjPHist hist, ajuint indexnum, 211 ajint style); 212 __deprecated void ajHistSetBlackandWhite (AjPHist hist, AjBool set); 213 __deprecated void ajHistSetXAxisC (AjPHist hist, const char* strng); 214 __deprecated void ajHistSetYAxisLeftC (AjPHist hist,const char* strng); 215 __deprecated void ajHistSetYAxisRightC (AjPHist hist, const char* strng); 216 __deprecated void ajHistCopyData (AjPHist hist, ajuint indexnum, 217 const PLFLT *data); 218 __deprecated void ajHistSetPtrToData (AjPHist hist, 219 ajint indexnum, PLFLT *data); 220 __deprecated void ajHistSetMark(ajint mark); 221 __deprecated void ajHistClose (void); 222 __deprecated void ajHistDelete (AjPHist* hist); 223 __deprecated void ajHistSetMultiTitle (AjPHist hist, ajint indexnum, 224 const AjPStr title); 225 __deprecated void ajHistSetMultiTitleC (AjPHist hist, ajint indexnum, 226 const char *title); 227 __deprecated void ajHistSetMultiXTitle (AjPHist hist, ajint indexnum, 228 const AjPStr title); 229 __deprecated void ajHistSetMultiXTitleC (AjPHist hist, ajint indexnum, 230 const char *title); 231 __deprecated void ajHistSetMultiYTitle (AjPHist hist, ajint indexnum, 232 const AjPStr title); 233 __deprecated void ajHistSetMultiYTitleC (AjPHist hist, ajint indexnum, 234 const char *title); 235 236 #endif 237 238 AJ_END_DECLS 239 240 #endif /* !AJHIST_H */ 241