void drvJAVA2::show_rectangle(const float llx, const float lly, const float urx, const float ury) { if (numberOfElements > limitNumberOfElements) continue_page(); outf << " // Path # " << currentNr() << endl; outf << " currentPage.add(new PSPathObject(new Color("; outf << currentR() << "f, " << currentG() << "f, " << currentB() << "f), "; outf << currentLineWidth() << "f"; if ((currentLineJoin() != 0) || (currentShowType() != 0)) { outf << ", " << currentLineJoin(); switch (currentShowType()) { case drvbase::stroke: outf << ", 0"; break; case drvbase::fill: outf << ", 1"; break; case drvbase::eofill: outf << ", 2"; break; default: errf << "\t\tFatal: unexpected case for currentShowType() in drvjava2" << endl; // cannot happen abort(); } } if (currentLineType() != solid) { outf << "," << endl; show_dashPattern(outf, dashPattern()); } outf << ", new Rectangle2D.Float(" << (llx + x_offset) << "f, " << (currentDeviceHeight - ury + y_offset) << "f"; outf << ", " << (urx - llx) << "f, " << (ury - lly) << "f)));" << endl; numberOfElements++; }
/*! Sets the dash offset (the starting point on the dash pattern) for this pen to the \a offset specified. The offset is measured in terms of the units used to specify the dash pattern. \table \row \o \inlineimage qpen-dashpattern.png \o For example, a pattern where each stroke is four units long, followed by a gap of two units, will begin with the stroke when drawn as a line. However, if the dash offset is set to 4.0, any line drawn will begin with the gap. Values of the offset up to 4.0 will cause part of the stroke to be drawn first, and values of the offset between 4.0 and 6.0 will cause the line to begin with part of the gap. \endtable \note This implicitly converts the style of the pen to Qt::CustomDashLine. */ void QPen::setDashOffset(qreal offset) { if (qFuzzyCompare(offset, static_cast<QPenData *>(d)->dashOffset)) return; detach(); QPenData *dd = static_cast<QPenData *>(d); dd->dashOffset = offset; if (d->style != Qt::CustomDashLine) { dd->dashPattern = dashPattern(); d->style = Qt::CustomDashLine; } }
void drvPDF::show_path() { // add_to_page(); // is done in drvbase !! endtext(); // close text if open const char *setrgbcolor = 0; const char *drawingop = 0; switch (currentShowType()) { case drvbase::stroke: // it's a stroke drawingop = "S"; setrgbcolor = "RG"; break; case drvbase::fill: drawingop = "f"; setrgbcolor = "rg"; break; case drvbase::eofill: drawingop = "f*"; setrgbcolor = "rg"; break; default: // cannot happen errf << "unexpected ShowType " << (int) currentShowType() << endl; exit(1); break; } // buffer.precision(3); // buffer.setf(ios::fixed); // buffer.width(0); // to force minimal width // buffer.unsetf(ios::showpoint); if (Verbose()) { buffer << "% path " << currentNr() << endl; } buffer << RND3(currentR()) << " " << RND3(currentG()) << " " << RND3(currentB()) << " " << setrgbcolor << endl; buffer << currentLineWidth() << " w" << endl; buffer << currentLineCap() << " J" << endl; buffer << currentLineJoin() << " j" << endl; buffer << dashPattern() << " d" << endl; print_coords(); buffer << drawingop << endl; }
void drvSAMPL::show_path() { outf << "Path # " << currentNr(); if (isPolygon()) outf << " (polygon): " << endl; else outf << " (polyline): " << endl; outf << "\tcurrentShowType: "; switch (currentShowType()) { case drvbase::stroke: outf << "stroked"; break; case drvbase::fill: outf << "filled"; break; case drvbase::eofill: outf << "eofilled"; break; default: // cannot happen outf << "unexpected ShowType " << (int) currentShowType(); break; } outf << endl; outf << "\tcurrentLineWidth: " << currentLineWidth() << endl; outf << "\tcurrentR: " << currentR() << endl; outf << "\tcurrentG: " << currentG() << endl; outf << "\tcurrentB: " << currentB() << endl; outf << "\tedgeR: " << edgeR() << endl; outf << "\tedgeG: " << edgeG() << endl; outf << "\tedgeB: " << edgeB() << endl; outf << "\tfillR: " << fillR() << endl; outf << "\tfillG: " << fillG() << endl; outf << "\tfillB: " << fillB() << endl; outf << "\tcurrentLineCap: " << currentLineCap() << endl; outf << "\tdashPattern: " << dashPattern() << endl; outf << "\tPath Elements 0 to " << numberOfElementsInPath() - 1 << endl; print_coords(); }
// set libplot's cap style, join style, line style void drvplot::set_line_style() { // set cap style and join style (void)plotter->capmod(currentLineCap() == 0 ? "butt" : currentLineCap() == 1 ? "round" : currentLineCap() == 2 ? "projecting" : "butt"); (void)plotter->joinmod(currentLineJoin() == 0 ? "miter" : currentLineJoin() == 1 ? "round" : currentLineJoin() == 2 ? "bevel" : "miter"); // set old-fashioned line style const char *linestyle; switch (currentLineType()) { case solid: default: linestyle = "solid"; break; case dashed: linestyle = "longdashed"; break; case dashdot: linestyle = "dotdashed"; break; case dotted: linestyle = "dotted"; break; case dashdotdot: linestyle = "dotdotdashed"; break; } (void)plotter->linemod(linestyle); // set dashing pattern, which most types of Plotter understand DashPattern dash_pattern(dashPattern()); double *numbers = new double[dash_pattern.nrOfEntries]; for (int i = 0; i < dash_pattern.nrOfEntries; i++) numbers[i] = (double) dash_pattern.numbers[i]; (void)plotter->flinedash(dash_pattern.nrOfEntries, numbers, (double) dash_pattern.offset); delete[]numbers; }
void drvJAVA2::show_path() { outf << " // Path # " << currentNr() << endl; outf << " currentPath = new PSPathObject(new Color("; outf << currentR() << "f, " << currentG() << "f, " << currentB() << "f), "; outf << currentLineWidth() << "f"; if ((currentLineCap() != 0) || (currentLineJoin() != 0) || (currentShowType() != 0) || (currentLineType() != solid)) { outf << ", " << currentLineCap() << ", " << currentLineJoin() << ", " << currentMiterLimit() << "f, "; switch (currentShowType()) { case drvbase::stroke: outf << "0"; break; case drvbase::fill: outf << "1"; break; case drvbase::eofill: outf << "2"; break; default: errf << "\t\tFatal: unexpected case for currentShowType() in drvjava2" << endl; // cannot happen abort(); } if (currentLineType() != solid) { outf << "," << endl; show_dashPattern(outf, dashPattern()); } } if (isPolygon()) { outf << ", true"; } outf << ");" << endl; numberOfElements++; print_coords(); outf << " currentPage.add(currentPath);" << endl; numberOfElements++; }
void drvCAIRO::show_path() { DashPattern dp(dashPattern()); outf << endl; outf << " /*" << endl; outf << " * Path # " << currentNr() ; if (isPolygon()) outf << " (polygon):" << endl; else outf << " (polyline):" << endl; outf << " */" << endl; outf << endl; outf << " cairo_save (cr);" << endl; outf << " cairo_set_line_width (cr, " << currentLineWidth() << ");" << endl; // CAIRO_LINE_CAP_BUTT - start(stop) the line exactly at the start(end) point // CAIRO_LINE_CAP_ROUND - use a round ending, the center of the circle is the end point // CAIRO_LINE_CAP_SQUARE - use squared ending, the center of the square is the end point outf << " cairo_set_line_cap (cr, "; switch( currentLineCap() ) { case 0: outf << "CAIRO_LINE_CAP_BUTT);" << endl; break; case 1: outf << "CAIRO_LINE_CAP_ROUND);" << endl; break; case 2: outf << "CAIRO_LINE_CAP_SQUARE);" << endl; break; default: errf << "Unexpected currentLineCap() in cairo driver: " << currentLineCap() << endl; outf << "CAIRO_LINE_CAP_ROUND);" << endl; break; } // cairo_set_dash (cairo_t *cr, const double *dashes, int num_dashes, double offset); // dashes : // an array specifying alternate lengths of on and off stroke portions // // num_dashes : // the length of the dashes array // // offset : // an offset into the dash pattern at which the stroke should start // // dashPattern: has nrOfEntries, float *numbers, float offset if (dp.nrOfEntries > 0) { outf << " {" << endl; outf << " double pat[" << dp.nrOfEntries << "] = {" << endl; for (int i = 0; i < dp.nrOfEntries; i++) { outf << " " << dp.numbers[i] << ", " << endl; } outf << " };" << endl; outf << endl; outf << " cairo_set_dash (cr, pat, " << dp.nrOfEntries << ", " << dp.offset << ");" << endl; outf << " }" << endl; } else { outf << " cairo_set_dash (cr, NULL, 0, 0.0);" << endl; } // cairo_move_to (cr, 0.25, 0.25); // cairo_line_to (cr, 0.5, 0.375); outf << " /* Path Elements 0 to " << numberOfElementsInPath() - 1 << " */" << endl; print_coords(); switch (currentShowType()) { case drvbase::stroke: outf << " cairo_set_source_rgb (cr, " << edgeR() << "," << edgeG() << "," << edgeB() << ");" << endl; outf << " cairo_stroke (cr);" << endl; break; case drvbase::eofill: outf << " cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);" << endl; evenoddmode = true; case drvbase::fill: outf << " cairo_set_source_rgb (cr, " << fillR() << "," << fillG() << "," << fillB() << ");" << endl; outf << " cairo_fill_preserve (cr);" << endl; if (evenoddmode) { outf << " cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);" << endl; evenoddmode = false; } outf << " cairo_set_source_rgb (cr, " << edgeR() << "," << edgeG() << "," << edgeB() << ");" << endl; outf << " cairo_stroke (cr);" << endl; break; default: // cannot happen outf << " // unexpected ShowType " << (int) currentShowType(); break; } outf << " cairo_restore (cr);" << endl; }