MCPcopy Create free account
hub / github.com/creatale/node-dv / gplotCreate

Function gplotCreate

deps/leptonica/src/gplot.c:137–188  ·  view source on GitHub ↗

-----------------------------------------------------------------* * Basic Plotting Functions * *-----------------------------------------------------------------*/ ! * \brief gplotCreate() * * \param[in] rootname root for all output files * \param[in] outformat GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_LATEX * \param[in] title [optional] overa

Source from the content-addressed store, hash-verified

135 * </pre>
136 */
137GPLOT *
138gplotCreate(const char *rootname,
139 l_int32 outformat,
140 const char *title,
141 const char *xlabel,
142 const char *ylabel)
143{
144char *newroot;
145char buf[L_BUFSIZE];
146l_int32 badchar;
147GPLOT *gplot;
148
149 PROCNAME("gplotCreate");
150
151 if (!rootname)
152 return (GPLOT *)ERROR_PTR("rootname not defined", procName, NULL);
153 if (outformat != GPLOT_PNG && outformat != GPLOT_PS &&
154 outformat != GPLOT_EPS && outformat != GPLOT_LATEX)
155 return (GPLOT *)ERROR_PTR("outformat invalid", procName, NULL);
156 stringCheckForChars(rootname, "`;&|><\"?*$()", &badchar);
157 if (badchar) /* danger of command injection */
158 return (GPLOT *)ERROR_PTR("invalid rootname", procName, NULL);
159
160 if ((gplot = (GPLOT *)LEPT_CALLOC(1, sizeof(GPLOT))) == NULL)
161 return (GPLOT *)ERROR_PTR("gplot not made", procName, NULL);
162 gplot->cmddata = sarrayCreate(0);
163 gplot->datanames = sarrayCreate(0);
164 gplot->plotdata = sarrayCreate(0);
165 gplot->plottitles = sarrayCreate(0);
166 gplot->plotstyles = numaCreate(0);
167
168 /* Save title, labels, rootname, outformat, cmdname, outname */
169 newroot = genPathname(rootname, NULL);
170 gplot->rootname = newroot;
171 gplot->outformat = outformat;
172 snprintf(buf, L_BUFSIZE, "%s.cmd", rootname);
173 gplot->cmdname = stringNew(buf);
174 if (outformat == GPLOT_PNG)
175 snprintf(buf, L_BUFSIZE, "%s.png", newroot);
176 else if (outformat == GPLOT_PS)
177 snprintf(buf, L_BUFSIZE, "%s.ps", newroot);
178 else if (outformat == GPLOT_EPS)
179 snprintf(buf, L_BUFSIZE, "%s.eps", newroot);
180 else if (outformat == GPLOT_LATEX)
181 snprintf(buf, L_BUFSIZE, "%s.tex", newroot);
182 gplot->outname = stringNew(buf);
183 if (title) gplot->title = stringNew(title);
184 if (xlabel) gplot->xlabel = stringNew(xlabel);
185 if (ylabel) gplot->ylabel = stringNew(ylabel);
186
187 return gplot;
188}
189
190
191/*!

Callers 15

boxaPlotSidesFunction · 0.85
boxaPlotSizesFunction · 0.85
pixWordMaskByDilationFunction · 0.85
pixItalicWordsFunction · 0.85
pixCompareGrayFunction · 0.85
pixCompareRGBFunction · 0.85
gplotSimpleXY1Function · 0.85
gplotSimpleXY2Function · 0.85
gplotSimpleXYNFunction · 0.85
gplotReadFunction · 0.85

Calls 5

stringCheckForCharsFunction · 0.85
sarrayCreateFunction · 0.85
numaCreateFunction · 0.85
genPathnameFunction · 0.85
stringNewFunction · 0.85

Tested by

no test coverage detected