You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
#include <config.h>
#include <stdio.h>
#include "chart.h"
#include "str.h"
+#include "alloc.h"
+#include "som.h"
+#include "output.h"
const char *data_colour[] = {
-int
-chart_initialise(struct chart *chart)
+struct chart *
+chart_create(void)
{
-
- chart->pl_params = pl_newplparams();
-
- chart->lp = pl_newpl_r ("X",0,stdout,stderr,chart->pl_params);
+ struct chart *chart;
+ struct outp_driver *d;
+
+ d = outp_drivers (NULL);
+ if (d == NULL)
+ return NULL;
+
+ chart = xmalloc (sizeof *chart);
+ d->class->initialise_chart(d, chart);
+ if (!chart->lp)
+ {
+ free (chart);
+ return NULL;
+ }
if (pl_openpl_r (chart->lp) < 0) /* open Plotter */
- return 1;
-
+ return NULL;
+
pl_fspace_r (chart->lp, 0.0, 0.0, 1000.0, 1000.0); /* set coordinate system */
pl_flinewidth_r (chart->lp, 0.25); /* set line thickness */
pl_pencolorname_r (chart->lp, "black");
pl_erase_r (chart->lp); /* erase graphics display */
pl_filltype_r(chart->lp,0);
-
-
pl_savestate_r(chart->lp);
/* Set default chartetry */
chart->font_size = 0;
strcpy(chart->fill_colour,"red");
-
/* Get default font size */
if ( !chart->font_size)
chart->font_size = pl_fontsize_r(chart->lp, -1);
chart->data_left, chart->data_bottom,
chart->data_right, chart->data_top);
- return 0;
-
+ return chart;
}
-
-
/* Draw a tick mark at position
If label is non zero, then print it at the tick mark
*/
{
const int tickSize = 10;
+ assert(chart);
+
pl_savestate_r(chart->lp);
pl_move_r(chart->lp, chart->data_left, chart->data_bottom);
va_list ap;
char buf[100];
+ if ( ! chart )
+ return ;
+
pl_savestate_r(chart->lp);
pl_ffontsize_r(chart->lp,chart->font_size * 1.5);
pl_move_r(chart->lp,chart->data_left, chart->title_bottom);
}
+extern struct som_table_class tab_table_class;
void
-chart_finalise(struct chart *chart)
+chart_submit(struct chart *chart)
{
+ struct som_entity s;
+ struct outp_driver *d;
+
+ if ( ! chart )
+ return ;
+
pl_restorestate_r(chart->lp);
+ s.class = &tab_table_class;
+ s.ext = chart;
+ s.type = SOM_CHART;
+ som_submit (&s);
+
if (pl_closepl_r (chart->lp) < 0) /* close Plotter */
{
fprintf (stderr, "Couldn't close Plotter\n");
}
-
pl_deletepl_r(chart->lp);
pl_deleteplparams(chart->pl_params);
+ d = outp_drivers (NULL);
+ d->class->finalise_chart(d, chart);
+ free(chart);
}
const double tick_interval =
chart_rounded_tick( (max - min) / (double) ticks);
+ assert ( ch );
+
+
ch->x_max = ceil( max / tick_interval ) * tick_interval ;
ch->x_min = floor ( min / tick_interval ) * tick_interval ;
+
ch->abscissa_scale = fabs(ch->data_right - ch->data_left) /
fabs(ch->x_max - ch->x_min);
const double tick_interval =
chart_rounded_tick( (smax - smin) / (double) ticks);
+
+ if ( !ch )
+ return;
+
ch->y_max = ceil ( smax / tick_interval ) * tick_interval ;
ch->y_min = floor ( smin / tick_interval ) * tick_interval ;