Beispiel #1
0
int output_raster(int fd)
{
    int i;

    for (i = 0; i < page.rows; i++, at_row++) {
	G_percent(i, page.rows, 2);
	switch (format) {
	case USE_CELL:
	    cell = raster.cell[i];

	    /* insert the NULL values */
	    Rast_insert_c_null_values(cell, null_flags[i], page.cols);
	    Rast_put_c_row(fd, cell);
	    break;
	case USE_DCELL:
	    dcell = raster.dcell[i];

	    /* insert the NULL values */
	    Rast_insert_d_null_values(dcell, null_flags[i], page.cols);
	    Rast_put_d_row(fd, dcell);
	    break;
	}
    }
    G_percent(1, 1, 1);
    
    return configure_plot();
}
Beispiel #2
0
// Start plot
static void popup_plot_shell(PlotWindowInfo *plot)
{
    if (!plot->active && plot->plotter != 0)
    {
	// We have the plot
	plot->plotter->removeHandler(Died, PlotterNotFoundHP, 
				     (void *)plot);

	// Fetch plot settings
	configure_plot(plot);

	// Command and export dialogs are not needed (yet)
	if (plot->command_dialog != 0)
	    XtUnmanageChild(plot->command_dialog);
	if (plot->export_dialog != 0)
	    XtUnmanageChild(plot->export_dialog);

	// Pop down working dialog
	if (plot->working_dialog != 0)
	    XtUnmanageChild(plot->working_dialog);

	// Pop up shell
	XtSetSensitive(plot->shell, True);
	XtPopup(plot->shell, XtGrabNone);
	wait_until_mapped(plot->shell);

	plot->active = true;
    }
}
Beispiel #3
0
static void GetPlotSettingsCB(XtPointer client_data, XtIntervalId *id)
{
    (void) id;			// Use it
    PlotWindowInfo *plot = (PlotWindowInfo *)client_data;

    assert(plot->settings_timer == *id);
    plot->settings_timer = 0;

    // Check for settings file to be created
    string settings;
    slurp_file(plot->settings_file, settings);

    if (settings.contains("set zero"))
    {
	// Settings are complete
	unlink(plot->settings_file.chars());
	plot->settings = settings;

	configure_plot(plot);

	delete plot->settings_delay;
	plot->settings_delay = 0;
    }
    else
    {
	// Try again in 500 ms
	plot->settings_timer = 
	    XtAppAddTimeOut(XtWidgetToApplicationContext(plot->shell), 500, 
			    GetPlotSettingsCB, XtPointer(plot));
    }
}
Beispiel #4
0
int begin_rasterization(int nrows, int f)
{
    int i, size;
    int pages;

    /* otherwise get complaints about window changes */
    G_suppress_warnings(1);

    format = f;

    max_rows = nrows;
    if (max_rows <= 0)
	max_rows = 512;

    G_get_set_window(&region);
    G_get_set_window(&page);

    pages = (region.rows + max_rows - 1) / max_rows;

    if (max_rows > region.rows)
	max_rows = region.rows;

    size = max_rows * region.cols;
    switch (format) {
    case USE_CELL:
	raster.cell =
	    (CELL **) G_calloc(max_rows * sizeof(char), sizeof(CELL *));
	raster.cell[0] = (CELL *) G_calloc(size * sizeof(char), sizeof(CELL));
	for (i = 1; i < max_rows; i++)
	    raster.cell[i] = raster.cell[i - 1] + region.cols;
	dot = cell_dot;
	break;

    case USE_DCELL:
	raster.dcell =
	    (DCELL **) G_calloc(max_rows * sizeof(char), sizeof(DCELL *));
	raster.dcell[0] =
	    (DCELL *) G_calloc(size * sizeof(char), sizeof(DCELL));
	for (i = 1; i < max_rows; i++)
	    raster.dcell[i] = raster.dcell[i - 1] + region.cols;
	dot = dcell_dot;
	break;
    }

    null_flags = (char **)G_calloc(max_rows * sizeof(char), sizeof(char *));
    null_flags[0] = (char *)G_calloc(size * sizeof(char), sizeof(char));
    for (i = 1; i < max_rows; i++)
	null_flags[i] = null_flags[i - 1] + region.cols;

    at_row = 0;
    configure_plot();

    return pages;
}
Beispiel #5
0
int output_raster(int fd)
{
    int i, j;

    for (i = 0; i < page.rows; i++, at_row++) {
	switch (format) {

	case USE_CHAR:
	    for (j = 0; j < page.cols; j++) {
		cell[j] = (CELL) raster.c[i][j];
		if (cell[j] == 0)
		    G_set_null_value(&cell[j], 1, CELL_TYPE);
	    }
	    break;

	case USE_UCHAR:
	    for (j = 0; j < page.cols; j++) {
		cell[j] = (CELL) raster.u[i][j];
		if (cell[j] == 0)
		    G_set_null_value(&cell[j], 1, CELL_TYPE);
	    }
	    break;

	case USE_SHORT:
	    for (j = 0; j < page.cols; j++) {
		cell[j] = (CELL) raster.s[i][j];
		if (cell[j] == 0)
		    G_set_null_value(&cell[j], 1, CELL_TYPE);
	    }
	    break;

	case USE_CELL:
	    cell = raster.cell[i];
	    if (cell == 0)
		G_set_null_value(&cell, 1, CELL_TYPE);
	    break;
	}

	G_percent(i, page.rows, 2);
	if (G_put_raster_row(fd, cell, CELL_TYPE) < 0)
	    return ERROR;
    }
    G_percent(i, page.rows, 2);
    return configure_plot();
}
Beispiel #6
0
int begin_rasterization(int nrows, int f)
{
    int i, size;
    int pages;

    format = f;

    max_rows = nrows;
    if (max_rows <= 0)
	max_rows = 512;

    G_get_set_window(&region);
    G_get_set_window(&page);

    pages = (region.rows + max_rows - 1) / max_rows;

    if (max_rows > region.rows)
	max_rows = region.rows;

    size = max_rows * region.cols;
    switch (format) {
    case USE_CHAR:
	raster.c = (char **)G_calloc(max_rows, sizeof(char *));
	raster.c[0] = (char *)G_calloc(size, sizeof(char));
	for (i = 1; i < max_rows; i++)
	    raster.c[i] = raster.c[i - 1] + region.cols;
	dot = char_dot;
	break;

    case USE_UCHAR:
	raster.u =
	    (unsigned char **)G_calloc(max_rows, sizeof(unsigned char *));
	raster.u[0] = (unsigned char *)G_calloc(size, sizeof(unsigned char));
	for (i = 1; i < max_rows; i++)
	    raster.u[i] = raster.u[i - 1] + region.cols;
	dot = uchar_dot;
	break;

    case USE_SHORT:
	raster.s = (short **)G_calloc(max_rows, sizeof(short *));
	raster.s[0] = (short *)G_calloc(size, sizeof(short));
	for (i = 1; i < max_rows; i++)
	    raster.s[i] = raster.s[i - 1] + region.cols;
	dot = short_dot;
	break;

    case USE_CELL:
	raster.cell = (CELL **) G_calloc(max_rows, sizeof(CELL *));
	raster.cell[0] = (CELL *) G_calloc(size, sizeof(CELL));
	for (i = 1; i < max_rows; i++)
	    raster.cell[i] = raster.cell[i - 1] + region.cols;
	dot = cell_dot;
	break;
    }
    if (format != USE_CELL)
	cell = G_allocate_cell_buf();

    at_row = 0;
    configure_plot();

    return pages;
}