void Print_Formatter(FILE *stream, CONST_FORMAT_PTR format) { Print_Data_Type printer; LOCK_CM_MUTEX; startPrint(stream, &printer); if (format) Print_Formatter1(stream, &printer, format, 0); else printString(stream, &printer, "NULL Format", 0); endPrint(stream, &printer); UNLOCK_CM_MUTEX; }
void Print_Formatted_Data(FILE *stream, CONST_FORMAT_PTR format, const void *dataPtr) { Print_Data_Type printer; LOCK_CM_MUTEX; startPrint(stream, &printer); Print_Structured_Data(stream, &printer, format, (CONST_GENERIC_DATA_PTR)dataPtr, 0, (FORMAT_PTR)NULL, 0); endPrint(stream, &printer); UNLOCK_CM_MUTEX; }
void PuzzlePrinter::print (const ksudoku::Game & game) { const ksudoku::Puzzle * puzzle = game.puzzle(); const SKGraph * graph = puzzle->graph(); if (graph->sizeZ() > 1) { KMessageBox::information (m_parent, i18n("Sorry, cannot print three-dimensional puzzles.")); return; } const int leastCellsToFit = 20; // Avoids huge cells in small puzzles. // Set up a QPrinter and a QPainter and allocate space on the page. bool pageFilled = setupOutputDevices (leastCellsToFit, graph->sizeX()); if (! m_printer) { return; // The user did not select a printer. } // Draw the puzzle grid and its contents. bool hasBlocks = (graph->specificType() != Mathdoku); bool hasCages = ((graph->specificType() == Mathdoku) || (graph->specificType() == KillerSudoku)); bool killerStyle = (graph->specificType() == KillerSudoku); if (hasBlocks) { // Only Mathdoku has no blocks. drawBlocks (puzzle, graph); } if (hasCages) { // Mathdoku and KillerSudoku have cages. drawCages (puzzle, graph, killerStyle); // KillerSudoku has blocks too. } drawValues (game, graph); // Print starting and filled-in values. if (pageFilled) { endPrint(); // Print immediately. } else { KMessageBox::information (m_parent, i18n ("The KSudoku setting for printing several puzzles per page " "is currently selected.\n\n" "Your puzzle will be printed when no more will fit on the " "page or when KSudoku terminates.")); } }
void map (int argc, char *argv[], HWND hWnd, char *dirpath, char *map_filename) { char *datatitle; char *maptitle; char *zname; DATATYPE data_type; double hscale, vscale; double xmin, xmax, ymin, ymax; double *x, *y, *z; double *fit, *resid; int fit_degree; int i, k; int npoint; int zdigits; unsigned long *code; /* get data to plot */ npoint = prepdata (argc, argv, &datatitle, &data_type, &code, &x, &y, &z, &fit_degree, &fit, &resid); /* use select conditions to select points */ k = 0; for (i = 0; i < npoint; i++) { double fitval, residval; if (fit_degree > 0) { fitval = fit[i]; residval = resid[i]; } else { fitval = residval = 0.0; } if (opt_select (code[i], x[i], y[i], z[i], fit_degree, fitval, residval)) { code[k] = code[i]; x[k] = x[i]; y[k] = y[i]; z[k] = z[i]; if (fit_degree) { fit[k] = fit[i]; resid[k] = resid[i]; } ++k; } } npoint = k; if (npoint == 0) error_stop ("no points remain after selections in output.opt",""); /* prepare map title */ opt_zvalue (&zname, &zdigits); if (strlen (datatitle) > 100 || strlen (zname) > 100) error_stop ("data title or observed value name too long", ""); maptitle = (char *) malloc (250); if (maptitle == NULL) error_stop ("cannot allocate vector for map title", ""); switch (data_type) { case CODE: sprintf_s (maptitle, 250, "%s - Station Codes", datatitle); break; case OBS: sprintf_s (maptitle, 250, "%s - %s Values", datatitle, zname); break; case FIT: sprintf_s (maptitle, 250, "%s - Degree %d Fit of %s Values", datatitle, fit_degree, zname); break; case RESID: sprintf_s (maptitle, 250, "%s - Degree %d Fit Residual of %s Values", datatitle, fit_degree, zname); break; } /* determine range of coordinate values */ xmin = ymin = 1.e+30; xmax = ymax = -xmin; for (i = 0; i < npoint; i++) { xmin = x[i] < xmin ? x[i] : xmin; ymin = y[i] < ymin ? y[i] : ymin; xmax = x[i] > xmax ? x[i] : xmax; ymax = y[i] > ymax ? y[i] : ymax; } /* convert coordinates to map scale inches, assuming that the */ /* x and y values are longitude and latitude, respectively */ { double center_latitude = (ymin + ymax) / 2; double cos_cent; double degrees_per_radian = M_PI / 180.; double s, t; long ratio; opt_scale (&ratio); cos_cent = cos (center_latitude * degrees_per_radian); t = 1 - cos_cent * cos_cent * 0.006693422; s = (cos_cent * 2.5026656e+8) / sqrt (t); hscale = ratio / (s * degrees_per_radian); t = (6.305541e+16 - 0.006693422 * s * s); t = t * sqrt (t) / 6.284403e+16; vscale = ratio / (t * degrees_per_radian); for (i = 0; i < npoint; i++) { x[i] = - x[i] / hscale; /* switch sign on longitude for */ /* correct map orientation */ y[i] = y[i] / vscale; } { /* must also switch sign on */ double hold = xmin; /* xmin and xmax */ xmin = - xmax / hscale; xmax = - hold / hscale; } ymin = ymin / vscale; ymax = ymax / vscale; } /* create pdf map file */ startPrint(hWnd, dirpath, map_filename, maptitle); printHeader(maptitle); printStations(data_type, npoint, code, x, y, z, fit, resid, hscale, vscale, xmin, xmax, ymin, ymax, zdigits); endPrint(); return; }