void PiecesWidget::paintEvent (QPaintEvent *e) { int s = Pieces_.size (); QPainter painter (this); painter.setRenderHints (QPainter::Antialiasing | QPainter::SmoothPixmapTransform); if (!s) { painter.setBackgroundMode (Qt::OpaqueMode); painter.setBackground (Qt::white); painter.end (); return; } QPixmap tempPicture (s, 1); QPainter tempPainter (&tempPicture); tempPainter.setPen (Qt::red); tempPainter.drawLine (0, 0, s, 0); QList<QPair<int, int> > trues = FindTrues (Pieces_); for (int i = 0; i < trues.size (); ++i) { QPair<int, int> pair = trues.at (i); tempPainter.setPen (Qt::darkGreen); tempPainter.drawLine (pair.first, 0, pair.second, 0); } tempPainter.end (); painter.drawPixmap (QRect (0, 0, width (), height ()), tempPicture); painter.end (); e->accept (); }
void ParameterSetCanvas::draw(QPainter & p) { if (! visible()) return; QBrush brsh = p.brush(); QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); QRect r = rect(); FILE * fp = svg(); p.setBackgroundColor(co); if (used_color != UmlTransparent) p.setBrush(co); if (fp != 0) fprintf(fp, "<g>\n" "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n" "</g>\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); p.drawRect(r); p.setBackgroundColor(bckgrnd); p.setBrush(brsh); if (selected()) show_mark(p, r); }
// creates an icon in the apple style of gray emboss QIcon iconFromPNG(QString filename, bool emboss) { QImage pngImage; pngImage.load(filename); // use muted dark gray color QImage gray8 = pngImage.convertToFormat(QImage::Format_Indexed8); gray8.setColor(0, QColor(80,80,80, 170).rgb()); if (GCColor::isFlat()) return QIcon(QPixmap::fromImage(gray8)); QImage white8 = pngImage.convertToFormat(QImage::Format_Indexed8); white8.setColor(0, QColor(255,255,255, 255).rgb()); // now convert to a format we can paint with! QImage white = white8.convertToFormat(QImage::Format_ARGB32_Premultiplied); QImage gray = gray8.convertToFormat(QImage::Format_ARGB32_Premultiplied); QPainter painter; painter.begin(&white); painter.setBackgroundMode(Qt::TransparentMode); if (emboss) painter.drawImage(0,-1, gray); else painter.drawImage(0,0, gray); painter.end(); return QIcon(QPixmap::fromImage(white)); }
void Drawboard::setupBuffer() { QPixmap* newBuffer = new QPixmap(width(), height()); QPainter* newPainter = new QPainter(newBuffer); newPainter->setBackgroundMode(Qt::OpaqueMode); newPainter->setBackground(Qt::white); newPainter->setRenderHint(QPainter::Antialiasing); newPainter->setRenderHint(QPainter::SmoothPixmapTransform); newPainter->eraseRect(newBuffer->rect()); if (buffer != NULL) { int w = std::min(buffer->width(), newBuffer->width()); int h = std::min(buffer->height(), newBuffer->height()); newPainter->drawPixmap(0, 0, *buffer, 0, 0, w, h); } newPainter->setBrush(QColor(255, 0, 0, 128)); newPainter->setPen(QColor(255, 0, 0, 255)); delete painter; delete buffer; buffer = newBuffer; painter = newPainter; update(); }
void QHexEditPrivate::drawLine(QPainter &painter, QFontMetrics &fm, qint64 line, int y) { int xhex = this->_xposhex, xascii = this->_xposascii; qint64 linestart = line * QHexEditPrivate::BYTES_PER_LINE; painter.setBackgroundMode(Qt::TransparentMode); this->drawLineBackground(painter, line, linestart, y); this->drawAddress(painter, fm, line, linestart, y); for(qint64 i = 0; i < QHexEditPrivate::BYTES_PER_LINE; i++) { qint64 pos = linestart + i; if(pos >= this->_hexeditdata->length()) return; /* Reached EOF */ uchar b = this->_reader->at(pos); if(this->_comments->isCommented(pos)) { QFont f = this->font(); f.setBold(true); painter.setFont(f); } else painter.setFont(this->font()); QColor bchex, fchex, bcascii, fcascii; this->colorize(b, pos, bchex, fchex, bcascii, fcascii); this->drawHex(painter, fm, bchex, fchex, b, i, xhex, y); this->drawAscii(painter, fm, bcascii, fcascii, b, xascii, y); } }
void DrawSVG::Write(QString filename) { if(!canvas) return; QSvgGenerator generator; generator.setFileName(filename); generator.setSize(QSize(canvas->width(), canvas->height())); generator.setTitle("MLDemos screenshot"); generator.setDescription("Generated with MLDemos"); QPainter painter; painter.begin(&generator); // we need to paint the different layers: // confidence map // samples + trajectories + reward canvas->PaintStandard(painter, true); if(canvas->bDisplayLearned) { // learned model painter.setBackgroundMode(Qt::TransparentMode); if(classifier) DrawClassificationSamples(canvas, painter, classifier, classifierMulti); if(regressor) drawRegr->DrawModel(canvas, painter, regressor); if(dynamical) drawDyn->DrawModel(canvas, painter, dynamical); if(clusterer) drawClust->DrawModel(canvas, painter, clusterer); if(projector) drawProj->DrawModel(canvas, painter, projector); if(dynamical) { int cnt = 10000; // not too many or it will make unreadable files int steps = 8; VectorsFast(cnt, steps, painter); } if(maximizer) { Maximization(painter); } } if(canvas->bDisplayInfo) { // model info painter.setBackgroundMode(Qt::TransparentMode); if(classifier) drawClass->DrawInfo(canvas, painter, classifier); if(regressor) drawRegr->DrawInfo(canvas, painter, regressor); if(dynamical) drawDyn->DrawInfo(canvas, painter, dynamical); if(clusterer) drawClust->DrawInfo(canvas, painter, clusterer); if(projector) drawProj->DrawInfo(canvas, painter, projector); } painter.end(); }
void QHexEditPrivate::drawParts(QPainter &painter) { int span = this->_charwidth / 2; painter.setBackgroundMode(Qt::TransparentMode); painter.setPen(this->palette().color(QPalette::WindowText)); painter.drawLine(this->_xposhex - span, 0, this->_xposhex - span, this->height()); painter.drawLine(this->_xposascii - span, 0, this->_xposascii - span, this->height()); painter.drawLine(this->_xPosend + span, 0, this->_xPosend + span, this->height()); }
void drawCompositedPopup( QWidget* widget, const QPainterPath& outline, const QColor& lineColor, const QBrush& backgroundBrush, qreal opacity ) { bool compositingWorks = true; #if defined(Q_WS_WIN) //HACK: Windows refuses to perform compositing so we must fake it compositingWorks = false; #elif defined(Q_WS_X11) if ( !QX11Info::isCompositingManagerRunning() ) compositingWorks = false; #endif QPainter p; QImage result; if ( compositingWorks ) { p.begin( widget ); p.setRenderHint( QPainter::Antialiasing ); p.setBackgroundMode( Qt::TransparentMode ); } else { result = QImage( widget->rect().size(), QImage::Format_ARGB32_Premultiplied ); p.begin( &result ); p.setCompositionMode( QPainter::CompositionMode_Source ); p.fillRect( result.rect(), Qt::transparent ); p.setCompositionMode( QPainter::CompositionMode_SourceOver ); } QPen pen( lineColor ); pen.setWidth( 2 ); p.setPen( pen ); p.drawPath( outline ); p.setOpacity( opacity ); p.fillPath( outline, backgroundBrush ); p.end(); if ( !compositingWorks ) { QPainter finalPainter( widget ); finalPainter.setRenderHint( QPainter::Antialiasing ); finalPainter.setBackgroundMode( Qt::TransparentMode ); finalPainter.drawImage( 0, 0, result ); widget->setMask( QPixmap::fromImage( result ).mask() ); } #ifdef QT_MAC_USE_COCOA // Work around bug in Qt/Mac Cocoa where opening subsequent popups // would incorrectly calculate the background due to it not being // invalidated. SourceTreePopupHelper::clearBackground( widget ); #endif }
void TextCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QColor bgcolor = p.background().color(); QPen fgcolor = p.pen(); QBrush backgroundColor = p.background(); if (bg_c == UmlTransparent) p.setBackgroundMode(::Qt::TransparentMode); else { p.setBackgroundMode(::Qt::OpaqueMode); //p.setBackgroundColor(color(bg_c)); backgroundColor.setColor(bg_c); p.setBackground(backgroundColor); } if (fg_c != UmlTransparent) p.setPen(color(fg_c)); QRect r = rect(); p.setFont(the_canvas()->get_font(itsfont)); p.drawText(r.left(), r.top(), r.width(), r.height(), ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap, text); FILE * fp = svg(); if (fp != 0) draw_text(r.left(), r.top(), r.width(), r.height(), ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap, text, p.font(), fp, fg_c, bg_c); p.setFont(the_canvas()->get_font(UmlNormalFont)); backgroundColor.setColor(bgcolor); //p.setBackgroundColor(bgcolor); p.setBackground(backgroundColor); p.setPen(fgcolor); if (selected()) show_mark(p, r); }
void CommandPanel::drawPanel(QPainter& painter, const QRect& clipRect) { QColor textColor = palette().color(QPalette::Text); QColor backgroundColor = palette().color(QPalette::Background); QColor disabledTextColor = blendColor(textColor, backgroundColor); // painter.setRenderHint(QPainter::TextAntialiasing); // painter.setPen(Qt::NoPen); painter.setBrush(backgroundColor); painter.drawRect(clipRect); // painter.setFont(font()); painter.setPen(textColor); painter.setBackgroundMode(Qt::OpaqueMode); painter.setBackground(backgroundColor); // std::list<CommandOption>::const_iterator it = options_.items().begin(), itEnd = options_.items().end(); for(int i=0;it!=itEnd;++it, ++i) { assert(i<(int)rects_.size()); // QRect rect(rects_[i]); QRect textRect(rect); textRect.setBottom(textRect.bottom()-cUnderlineHeight); // if(!rect.intersects(clipRect)) continue; // if(i==pressedIndex_) { painter.setPen(backgroundColor); painter.setBackground(textColor); painter.drawText(textRect, Qt::AlignHCenter, it->text()); } else if(enabled_[i]) { painter.setPen(textColor); // QRect underlineRect(rect.left(), rect.bottom()-cUnderlineHeight, rect.width()-1, cUnderlineHeight); if(i==highlightedIndex_ && showHighlight_) { painter.setBrush(textColor); painter.drawRect(underlineRect); } // painter.drawText(textRect, Qt::AlignCenter, it->text()); } else { painter.setPen(disabledTextColor); painter.drawText(textRect, Qt::AlignCenter, it->text()); } } }
void TEWidget::drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear) { //qDebug("begin TEWidget::drawAttrStr"); if (pm && color_table[attr.b].transparent) { paint.setBackgroundMode( TransparentMode ); if (clear) { // erase(rect); qDebug("org code : erase(rect);"); } } else { if (blinking) { paint.fillRect(rect, color_table[attr.b].color); // draw cursor qDebug("\tdarw cursor"); } else { paint.setBackgroundMode(Qt::OpaqueMode); //paint.setBackgroundColor( color_table[attr.b].color ); qDebug("org code : paint.setBackgroundColor( color_table[attr.b].color );"); } } if (color_table[attr.f].bold) paint.setPen(QColor( 0x8F, 0x00, 0x00 )); else paint.setPen(color_table[attr.f].color); paint.drawText(rect.x(),rect.y()+font_a, str); static int count=0; if (attr.r & RE_UNDERLINE) paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); //qDebug("\t%d str : %s", count++,str.toStdString().c_str() ); //qDebug("end TEWidget::drawAttrStr"); }
void SdLifeLineCanvas::drawShape(QPainter & p) { if (end == 0) // masked by user return; p.setBackgroundMode(::Qt::OpaqueMode); p.setRenderHint(QPainter::Antialiasing, true); p.setPen(::Qt::DashLine); int m = (int)(x() + width() / 2); FILE * fp = svg(); p.drawLine(m, (int) y(), m, end); p.setPen(::Qt::SolidLine); if (end != LIFE_LINE_HEIGHT) { int b = end + (int) width(); p.drawLine((int) x(), end, (int)(x() + width()) - 1, b); p.drawLine((int)(x() + width() - 1), end, (int) x(), b); if (fp != 0) { fprintf(fp, "<g>\n" "\t<line stroke=\"black\" stroke-dasharray=\"18,6\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n" "</g>\n", m, (int) y(), m, end); fprintf(fp, "<g>\n" "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", (int) x(), end, (int)(x() + width()) - 1, b); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n" "</g>\n", (int)(x() + width() - 1), end, (int) x(), b); } } else if (fp != 0) fprintf(fp, "<g>\n" "\t<line stroke=\"black\" stroke-dasharray=\"18,6\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n" "</g>\n", m, (int) y(), m, svg_height()); }
QPixmap WelcomeWidget::fromSvg(QRectF _rect, const QString &file) { PlexyDesk::ImageCache *cache = PlexyDesk::ImageCache::instance(); QImage pixmap(_rect.width(), _rect.height(), QImage::Format_ARGB32_Premultiplied); QPainter painter; painter.begin(&pixmap); painter.setBackgroundMode(Qt::TransparentMode); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(_rect, Qt::transparent); painter.save(); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); cache->drawSvg(&painter, _rect, file); painter.restore(); painter.end(); return QPixmap::fromImage(pixmap); }
void DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity ) { p.setBackgroundMode( Qt::TransparentMode ); p.setRenderHint( QPainter::Antialiasing ); p.setOpacity( opacity ); QPen pen( pal.dark().color(), .5 ); p.setPen( pen ); p.setBrush( pal.highlight() ); p.drawRoundedRect( r, 10, 10 ); p.setOpacity( opacity + .2 ); p.setBrush( QBrush() ); p.setPen( pen ); p.drawRoundedRect( r, 10, 10 ); }
void QGraph::DrawGraph(QPainter &painter) { static QColor color; painter.save(); // Paint background // QBrush bg(m_BkColor); // painter.setBackground(bg); // Draw Border if(m_bBorder) color = m_BorderColor; else color = m_BkColor; QPen BorderPen(color); BorderPen.setStyle(GetStyle(m_BorderStyle)); BorderPen.setWidth(m_BorderWidth); painter.setPen(BorderPen); painter.fillRect(m_rCltRect, m_BkColor); painter.drawRect(m_rCltRect); Init(); painter.setClipRect(m_rCltRect); painter.setBackgroundMode(Qt::TransparentMode); if(m_bXMinGrid) DrawXMinGrid(painter); if(m_bYMinGrid) DrawYMinGrid(painter); if(m_bXMajGrid) DrawXMajGrid(painter); if(m_bYMajGrid) DrawYMajGrid(painter); DrawAxes(painter); DrawXTicks(painter); DrawYTicks(painter); for (int nc=0; nc < m_oaCurves.size(); nc++) DrawCurve(nc,painter); DrawTitles(painter); painter.setClipping(false); painter.restore(); }
void DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& /* pal */, QRect& r, qreal opacity ) { p.setBackgroundMode( Qt::TransparentMode ); p.setRenderHint( QPainter::Antialiasing ); p.setOpacity( opacity ); QColor c( 30, 30, 30 ); QPen pen( c.darker(), .5 ); p.setPen( pen ); p.setBrush( c ); p.drawRoundedRect( r, 10, 10 ); p.setOpacity( opacity + .2 ); p.setBrush( QBrush() ); p.setPen( pen ); p.drawRoundedRect( r, 10, 10 ); }
void SubjectCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QRect r = rect(); QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); FILE * fp = svg(); if (fp != 0) fputs("<g>\n", fp); p.setBackgroundColor(co); p.setFont(the_canvas()->get_font(UmlNormalBoldFont)); if (used_color != UmlTransparent) p.fillRect(r, co); if (fp != 0) fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); p.drawRect(r); r.setTop(r.top() + (int) (2*the_canvas()->zoom())); p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name); if (fp != 0) { draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name, p.font(), fp); fputs("</g>\n", fp); } p.setBackgroundColor(bckgrnd); if (selected()) show_mark(p, rect()); }
void IconCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QRect r = rect(); p.setBackgroundMode(::Qt::OpaqueMode); p.drawPixmap(r.topLeft(), *(browser_node->pixmap(0))); if (selected()) show_mark(p, r); FILE * fp = svg(); if (fp != 0) { fprintf(fp, "<g transform=\"translate(%d,%d)\">\n", r.left(), r.top()); ((BrowserDiagram *) browser_node)->draw_svg(); fputs("</g>\n", fp); } }
// -------------------------------------------------------------------------------------------------------------------------------------- void CCachedGraphicsItem::updateCache() { if(isActive()) { QPixmap *pixmap = new QPixmap(size().toSize()); pixmap->fill(QColor(0,0,0,0)); QPainter *painter = new QPainter(pixmap); painter->setBackgroundMode(Qt::TransparentMode); painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing, true); painter->setPen(m_stdPen); painter->setBrush(m_stdBrush); painter->setFont(m_stdFont); paintToCache(painter); delete painter; QPixmap *tmp = m_pixmap; m_pixmap = pixmap; delete tmp; //update(boundingRect()); } }
void InterruptibleActivityRegionCanvas::draw(QPainter & p) { if (! visible()) return; QRect r = rect(); QBrush brsh = p.brush(); QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); p.setBackgroundColor(co); if (used_color != UmlTransparent) p.setBrush(co); p.setPen(::Qt::DotLine); p.drawRoundRect(r, 8, 8); FILE * fp = svg(); if (fp != 0) fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-dasharray=\"4,4\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n", svg_color(used_color), r.left(), r.top(), r.width() - 1, r.height() - 1); p.setPen(::Qt::SolidLine); p.setBackgroundColor(bckgrnd); p.setBrush(brsh); if (selected()) show_mark(p, r); }
void PiecesWidget::paintEvent (QPaintEvent *e) { int s = Pieces_.size (); QPainter painter (this); painter.setRenderHints (QPainter::Antialiasing | QPainter::SmoothPixmapTransform); if (!s) { painter.setBackgroundMode (Qt::OpaqueMode); painter.setBackground (Qt::white); painter.end (); return; } const QPalette& palette = QApplication::palette (); const QColor& backgroundColor = palette.color (QPalette::Base); const QColor& downloadedPieceColor = palette.color (QPalette::Highlight); QPixmap tempPicture (s, 1); QPainter tempPainter (&tempPicture); tempPainter.setPen (backgroundColor); tempPainter.drawLine (0, 0, s, 0); QList<QPair<int, int> > trues = FindTrues (Pieces_); for (int i = 0; i < trues.size (); ++i) { QPair<int, int> pair = trues.at (i); tempPainter.setPen (downloadedPieceColor); tempPainter.drawLine (pair.first, 0, pair.second, 0); } tempPainter.end (); painter.drawPixmap (QRect (0, 0, width (), height ()), tempPicture); painter.end (); e->accept (); }
void FragmentSeparatorCanvas::drawShape(QPainter & p) { p.setBackgroundMode(::Qt::TransparentMode); p.setRenderHint(QPainter::Antialiasing, true); p.setPen(::Qt::DashLine); int m = (int) (fragment->y() + fragment->height() * vpos); p.drawLine((int) fragment->x(), m, (int) fragment->x() + fragment->width() - 1, m); p.setPen(::Qt::SolidLine); FILE * fp = svg(); if (fp != 0) fprintf(fp, "<g>\n\t<line stroke=\"black\" stroke-dasharray=\"20,4\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n</g>\n", (int) fragment->x(), m, (int) fragment->x() + fragment->width() - 1, m); if (selected()) show_mark(p, rect()); }
QImage Utils::applyHomography(MatrixXd H, QImage inputImage, QList<Dot*> region) { MatrixXd x(3,1); MatrixXd y(3,1); vector<double> x_values; vector<double> y_values; int height_output = 454; int width_output = 604; // Calculate output image corners x << region.at(0)->x(), region.at(0)->y(), 1; y = H*x; x_values.push_back(y(0,0)/y(2,0)); y_values.push_back(y(1,0)/y(2,0)); x << region.at(1)->x(), region.at(1)->y(), 1; y = H*x; x_values.push_back(y(0,0)/y(2,0)); y_values.push_back(y(1,0)/y(2,0)); x << region.at(2)->x(), region.at(2)->y(), 1; y = H*x; x_values.push_back(y(0,0)/y(2,0)); y_values.push_back(y(1,0)/y(2,0)); x << region.at(3)->x(), region.at(3)->y(), 1; y = H*x; x_values.push_back(y(0,0)/y(2,0)); y_values.push_back(y(1,0)/y(2,0)); double max_x = (*max_element(x_values.begin(), x_values.end())); double min_x = (*min_element(x_values.begin(), x_values.end())); double max_y = (*max_element(y_values.begin(), y_values.end())); double min_y = (*min_element(y_values.begin(), y_values.end())); height_output = width_output / ((max_x-min_x)/(max_y-min_y)); QImage outputImage(width_output, height_output, QImage::Format_ARGB32); QPainter painter; painter.begin(&outputImage); painter.setRenderHint(QPainter::Antialiasing); painter.setBackgroundMode(Qt::TransparentMode); QPen pen; H = H.inverse().eval(); double step = (max_x - min_x) / width_output; for (int i=0; i < height_output; i++) { for (int j=0; j<width_output; j++) { x << min_x+j*step, min_y+i*step, 1; y = H*x; y << y(0,0)/y(2,0), y(1,0)/y(2,0), 1; if (y(0,0) >= 0 && y(0,0) <= inputImage.width() - 1 && y(1,0) >= 0 && y(1,0) <= inputImage.height() - 1) { // Point lies inside the input Image // Do interpolation QColor c = interpolate(inputImage, y); //QRgb clrCurrent( inputImage.pixel( y(0,0), y(1,0) ) ); pen.setColor(c); pen.setWidth(1); pen.setCapStyle(Qt::RoundCap); painter.setPen(pen); painter.drawPoint(j, i); } else { // Point lies outside the input Image QColor clrCurrent(0,0,0); pen.setColor(clrCurrent); pen.setWidth(1); pen.setCapStyle(Qt::RoundCap); painter.setPen(pen); painter.drawPoint(j, i); } } } painter.end(); return outputImage; }
void UcUseCaseCanvas::draw(QPainter & p) { if (! visible()) return; QRect r = rect(); UseCaseData * data = (UseCaseData *) browser_node->get_data(); p.setRenderHint(QPainter::Antialiasing, true); used_color = (itscolor == UmlDefaultColor) ? the_canvas()->browser_diagram()->get_color(UmlUseCase) : itscolor; QColor col = color(used_color); QBrush brsh = p.brush(); bool realizationp = !strcmp(data->get_short_stereotype(), "realization"); FILE * fp = svg(); int rx = width()/2 - 1; int ry = height()/2 - 1; if (fp != 0) fputs("<g>\n", fp); if (used_color != UmlTransparent) { const int shadow = the_canvas()->shadow() - 1; if (shadow != -1) { r.setRight(r.right() - shadow); r.setBottom(r.bottom() - shadow); p.setPen(::Qt::NoPen); p.setBrush(::Qt::darkGray); p.drawEllipse(r.left() + shadow, r.top() + shadow, r.width(), r.height()); if (fp != 0) { rx = width()/2 - 1; ry = height()/2 - 1; fprintf(fp, "\t<ellipse fill=\"#%06x\" stroke=\"none\"" " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n", QColor(::Qt::darkGray).rgb()&0xffffff, r.left() + shadow + rx, r.top() + shadow + ry, rx, ry); } } if (fp != 0) fprintf(fp, "\t<ellipse fill=\"%s\" stroke=\"black\"%s stroke-width=\"1\" stroke-opacity=\"1\"" " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n", svg_color(used_color), (realizationp) ? " stroke-dasharray=\"4,4\"" : "", r.left() + rx, r.top() + ry, rx, ry); } else if (fp != 0) fprintf(fp, "\t<ellipse fill=\"none\" stroke=\"black\"%s stroke-width=\"1\" stroke-opacity=\"1\"" " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n", (realizationp) ? " stroke-dasharray=\"4,4\"" : "", r.left() + rx, r.top() + ry, rx, ry); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); p.setBrush(col); if (realizationp) p.setPen(::Qt::DotLine); else p.setPen(::Qt::SolidLine); p.drawEllipse(r.left(), r.top(), r.width(), r.height()); if (realizationp) p.setPen(::Qt::SolidLine); QString ep = data->get_extension_points(); if (!ep.isEmpty()) { QFontMetrics fbm(the_canvas()->get_font(UmlNormalBoldFont)); const int two = (int) (2 * the_canvas()->zoom()); int he = fbm.height() + two; int py = (int) y() + height()/4; int dx = width() / 15; int px = (int) x() + dx; p.drawLine(px, py, r.right() - dx, py); if (fp != 0) fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", px, py, r.right() - dx, py); int h = (height() * 3) / 4 - two; int w = width() - dx - dx; QColor bckgrnd = p.backgroundColor(); py += two; p.setBackgroundColor(col); p.setFont(the_canvas()->get_font(UmlNormalBoldFont)); p.drawText(px, py, w, h, ::Qt::AlignHCenter + ::Qt::AlignTop, "Extension Points"); if (fp != 0) draw_text(px, py, w, h, ::Qt::AlignHCenter + ::Qt::AlignTop, "Extension Points", p.font(), fp); h -= he; if (h > he) { // at least one line may be written py += he; p.setFont(the_canvas()->get_font(UmlNormalFont)); p.drawText(px, py, w, h, ::Qt::AlignCenter, ep); p.setBackgroundColor(bckgrnd); if (fp != 0) draw_text(px, py, w, h, ::Qt::AlignCenter, ep, p.font(), fp); } } if (fp != 0) fputs("</g>\n", fp); p.setBrush(brsh); if (selected()) show_mark(p, rect()); }
void FragmentCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QFontMetrics fm(the_canvas()->get_font(UmlNormalFont)); int w = fm.width((name.isEmpty()) ? QString("X") : name); int h = fm.height() / 2; QRect r = rect(); QRect rname = r; rname.setWidth(w + h); rname.setHeight(fm.height() + h); int h1 = (fm.height() + h)/2; int x1 = rname.right() + h1; int y1 = rname.bottom() - h1; QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); FILE * fp = svg(); if (fp != 0) fputs("<g>\n", fp); p.setBackgroundColor(co); p.setFont(the_canvas()->get_font(UmlNormalFont)); if (used_color != UmlTransparent) p.fillRect(r, co); else if (!name.isEmpty()) { Q3PointArray a(6); QBrush brsh = p.brush(); a.setPoint(0, rname.left(), rname.top()); a.setPoint(1, x1, rname.top()); a.setPoint(2, x1, y1); a.setPoint(3, rname.right(), rname.bottom()); a.setPoint(4, rname.left(), rname.bottom()); a.setPoint(5, rname.left(), rname.top()); p.setBrush(UmlWhiteColor); p.drawPolygon(a, TRUE, 0, 5); p.setBrush(brsh); if (fp != 0) draw_poly(fp, a, UmlWhite); } if (fp != 0) fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); p.drawRect(r); if (refer != 0) { QString s = refer->get_name() + form; QRect r2(r.left(), r.top() + 2*fm.height(), r.width(), fm.height()); p.drawText(r2, ::Qt::AlignCenter, s); if (fp != 0) draw_text(r2, ::Qt::AlignCenter, s, p.font(), fp); } if (!name.isEmpty()) p.drawText(rname, ::Qt::AlignCenter, name); if (fp != 0) draw_text(rname, ::Qt::AlignCenter, name, p.font(), fp); p.drawLine(rname.left(), rname.bottom(), rname.right(), rname.bottom()); p.drawLine(rname.right(), rname.bottom(), x1, y1); p.drawLine(x1, y1, x1, rname.top()); if (fp != 0) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", rname.left(), rname.bottom(), rname.right(), rname.bottom()); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", rname.right(), rname.bottom(), x1, y1); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", x1, y1, x1, rname.top()); fputs("</g>\n", fp); } p.setBackgroundColor(bckgrnd); if (selected()) show_mark(p, r); }
////////////////////////////////////////////////////////////////////////////// // draw ////////////////////////////////////////////////////////////////////////////// void CrossTab::Draw(QPainter & paint) { paint.save(); // Calculate the number of rows and columns that we can display int lastColumn(0); int lastRow(0); CalculateDisplayedRowsAndColumns(lastColumn, lastRow, m_rect); paint.drawRect(m_rect); QRect sampleRect(0,0,0,0); // Name itemRectangle QRect saveRect(0,0,0,0); int idRow=m_rowIndexStored; int idCol=m_columnIndexStored; // Start at the correct place CrossTabRowIndex::iterator rowIt(m_rowIndex.begin()); CrossTabColumnIndex::iterator columnIt(m_columnIndex.begin()); for (idRow = 0, rowIt = m_rowIndex.begin() ; ((idRow <= lastRow) && (rowIt != m_rowIndex.end())); ++idRow, ++rowIt) { // Should this row cell be displayed // Skip header column if not wanted if ( ((0 == idRow) && (0 != m_rowIndexStored) && !m_columnHeaderEachPage) || //Skip already displayed rows ((0 < idRow) && (idRow < m_rowIndexStored)) || //Skip rows that are not part of the already drawn table part (m_tableWrapDisplayAllColumnsFirst && (0 < idRow) && (idRow > m_rowIndexStoredLast) && (0 != m_columnIndexStored)) ) { continue; } for (idCol = 0, columnIt = m_columnIndex.begin() ; ((idCol <= lastColumn) && (columnIt != m_columnIndex.end())); ++idCol, ++columnIt) { // Should this column cell be displayed // Skip header row if not wanted if (((0 == idCol) && (0 != m_columnIndexStored) && !m_rowHeaderEachPage) || // Skip already displayed columns ((0 < idCol) && (idCol < m_columnIndexStored))) { continue; } // Get width of this column QString dataTekst (columnIt.key()); sampleRect.setWidth (columnIt.value().m_columnMaxWidth + m_cellLeftMargin + m_cellRightMargin); sampleRect.setHeight (rowIt.value().m_rowMaxHeight + m_cellTopMargin + m_cellBottomMargin); // Save rectangle saveRect = sampleRect; paint.setBackgroundMode(Qt::OpaqueMode); // Draw headers row if (idRow == 0) { paint.setBrush(QBrush(QColor(0, 0, 255, 127), Qt::SolidPattern)); } // Header column else if ((idRow != 0) && (idCol == 0)) { // Odd rows if ((idRow%2) != 0 ) { paint.setBrush(QBrush(QColor(0, 0, 255, 200), Qt::SolidPattern)); } // Even rows else { paint.setBrush(QBrush(QColor(90, 210, 255, 150), Qt::SolidPattern)); } } // Values else if ((idRow != 0) && (idCol != 0)) { // Odd rows if ((idRow%2) != 0 ) { paint.setBrush(QBrush(QColor(0, 0, 0, 0), Qt::SolidPattern)); } // Even rows else { paint.setBrush(QBrush(QColor(90, 210, 255, 127), Qt::SolidPattern)); } } // Draw rectangle paint.drawRect(sampleRect); paint.setBackgroundMode(Qt::TransparentMode); paint.setPen(Qt::SolidLine); // Skip margins: Adjust rectangle for data insertion sampleRect.setX(sampleRect.x() + m_cellLeftMargin); sampleRect.setY(sampleRect.y() + m_cellTopMargin); sampleRect.setWidth (columnIt.value().m_columnMaxWidth); sampleRect.setHeight (rowIt.value().m_rowMaxHeight); // get Font QFontMetrics fm(GetFont()); QRect dataRect; // Header if ((idRow == 0) && (idCol == 0)) { // Do nothing } // Headerrow else if ((idRow == 0) && (idCol != 0)) { dataRect = fm.boundingRect(sampleRect, m_hAlignMap["column"] | m_vAlignMap["column"], columnIt.key()); paint.drawText(dataRect, m_hAlignMap["column"] | m_vAlignMap["column"], columnIt.key()); } // Headercol else if ((idCol == 0) && (idRow != 0)) { dataRect = fm.boundingRect(sampleRect, m_hAlignMap["row"] | m_vAlignMap["row"], rowIt.key()); paint.drawText(dataRect, m_hAlignMap["row"] | m_vAlignMap["row"], rowIt.key()); } // Value else { dataRect = fm.boundingRect(sampleRect, m_hAlignMap["value"] | m_vAlignMap["value"], GetValue(columnIt.key(), rowIt.key())); paint.drawText(dataRect, m_hAlignMap["value"] | m_vAlignMap["value"], GetValue(columnIt.key(), rowIt.key())); } // Restore rectangle sampleRect = saveRect; sampleRect.setX(sampleRect.x() + sampleRect.width()); } // end for // Reset basic column id idCol = m_columnIndexStored; // Adjust item display rectangle sampleRect.setY(sampleRect.y()+sampleRect.height()); sampleRect.setX(0); } // Store indexes for iterative purpose m_rowIndexStored = lastRow + 1; m_columnIndexStored = lastColumn + 1; // Now that we are done return the paint device back to the state // it was when we started to mess with it paint.restore(); }
void QDial::repaintScreen( const QRect *cr ) { QPainter p; p.begin( this ); bool resetClipping = FALSE; // calculate clip-region for erasing background if ( cr ) { p.setClipRect( *cr ); } else if ( !d->onlyOutside && d->eraseAreaValid ) { QRegion reg = d->eraseArea; double a; reg = reg.subtract( calcArrow( a ) ); p.setClipRegion( reg ); resetClipping = TRUE; } QRect br( calcDial() ); p.setPen( NoPen ); // if ( style() == MotifStyle ) // p.setBrush( colorGroup().brush( QColorGroup::Mid ) ); // else { QBrush b; if ( colorGroup().brush( QColorGroup::Light ).pixmap() ) b = QBrush( colorGroup().brush( QColorGroup::Light ) ); else b = QBrush( colorGroup().light(), Dense4Pattern ); p.setBrush( b ); p.setBackgroundMode( OpaqueMode ); // } QRect te = br; te.setWidth(te.width()+2); te.setHeight(te.height()+2); // erase background of dial if ( !d->onlyOutside ) { p.drawEllipse( te ); } // erase remaining space around the dial QRegion remaining( 0, 0, width(), height() ); remaining = remaining.subtract( QRegion( te, QRegion::Ellipse ) ); if ( p.hasClipping() ) remaining = remaining.intersect( p.clipRegion() ); erase(remaining); if ( resetClipping ) { if ( cr ) p.setClipRect( *cr ); else p.setClipRect( QRect( 0, 0, width(), height() ) ); } // draw notches if ( d->showNotches ) { calcLines(); p.setPen( colorGroup().foreground() ); p.drawLineSegments( d->lines ); } // calculate and paint arrow p.setPen( QPen( colorGroup().dark() ) ); p.drawArc( te, 60 * 16, 180 * 16 ); p.setPen( QPen( colorGroup().light() ) ); p.drawArc( te, 240 * 16, 180 * 16 ); double a; QPointArray arrow( calcArrow( a ) ); QRect ea( arrow.boundingRect() ); d->eraseArea = ea; d->eraseAreaValid = TRUE; p.setPen( NoPen ); p.setBrush( colorGroup().brush( QColorGroup::Button ) ); if ( !d->onlyOutside ) p.drawPolygon( arrow ); a = angle( QPoint( width() / 2, height() / 2 ), arrow[ 0 ] ); p.setBrush( Qt::NoBrush ); // that's still a hack... if ( a <= 0 || a > 200 ) { p.setPen( colorGroup().light() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); } else if ( a > 0 && a < 45 ) { p.setPen( colorGroup().light() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); } else if ( a >= 45 && a < 135 ) { p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); p.setPen( colorGroup().light() ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); } else if ( a >= 135 && a < 200 ) { p.setPen( colorGroup().dark() ); p.drawLine( arrow[ 2 ], arrow[ 0 ] ); p.setPen( colorGroup().light() ); p.drawLine( arrow[ 0 ], arrow[ 1 ] ); p.drawLine( arrow[ 1 ], arrow[ 2 ] ); } // draw focus rect around the dial if ( hasFocus() ) { p.setClipping( FALSE ); br.setWidth( br.width() + 2 ); br.setHeight( br.height() + 2 ); if ( d->showNotches ) { int r = QMIN( width(), height() ) / 2; br.moveBy( -r / 6, - r / 6 ); br.setWidth( br.width() + r / 3 ); br.setHeight( br.height() + r / 3 ); } // strange, but else we get redraw errors on Windows p.end(); p.begin( this ); p.save(); p.setPen( QPen( colorGroup().background() ) ); p.setBrush( NoBrush ); p.drawRect( br ); p.restore(); style().drawPrimitive( QStyle::PE_FocusRect, &p, br, colorGroup()); } p.end(); }
/*! */ void PlayerPainter::drawText( QPainter & painter, const PlayerPainter::Param & param ) const { const Options & opt = Options::instance(); char main_buf[64]; std::memset( main_buf, 0, 64 ); if ( opt.showPlayerNumber() ) { char buf[8]; snprintf( buf, 8, "%d", param.player_.unum_ ); std::strcat( main_buf, buf ); } if ( param.player_.hasStamina() && opt.showStamina() ) { char buf[16]; snprintf( buf, 16, "%4.0f", param.player_.stamina_ ); if ( main_buf[0] != '\0' ) std::strcat( main_buf, "," ); std::strcat( main_buf, buf ); } if ( param.player_.hasStaminaCapacity() && opt.showStaminaCapacity() ) { char buf[16]; snprintf( buf, 16, "%.0f", param.player_.stamina_capacity_ ); if ( main_buf[0] != '\0' ) { if ( opt.showStamina() ) { std::strcat( main_buf, "/" ); } else { std::strcat( main_buf, "," ); } } std::strcat( main_buf, buf ); } if ( opt.showPlayerType() ) { char buf[8]; snprintf( buf, 8, "t%d", param.player_.type_ ); if ( main_buf[0] != '\0' ) std::strcat( main_buf, "," ); strcat( main_buf, buf ); } painter.setFont( M_player_font ); const int text_radius = std::min( 40, param.draw_radius_ ); int card_offset = 0; if ( opt.showCard() && ( param.player_.hasRedCard() || param.player_.hasYellowCard() ) ) { QFontMetrics fm = painter.fontMetrics(); int x_size = std::max( 4, fm.ascent() - 2 ); int y_size = std::max( 4, fm.ascent() ); card_offset = x_size + 2; if ( opt.antiAliasing() ) { painter.setRenderHint( QPainter::Antialiasing, false ); } painter.setPen( Qt::black ); painter.setBrush( param.player_.hasRedCard() ? Qt::red : Qt::yellow ); painter.drawRect( param.x_ + text_radius, param.y_ - y_size, x_size, y_size ); if ( opt.antiAliasing() ) { painter.setRenderHint( QPainter::Antialiasing, true ); } } if ( main_buf[0] != '\0' ) { //painter.setPen( param.player_.side() == rcss::rcg::LEFT // ? M_left_team_pen // : M_right_team_pen ); if ( text_radius < param.draw_radius_ ) { painter.setPen( M_player_number_inner_pen ); } else { painter.setPen( M_player_number_pen ); } painter.setBrush( Qt::NoBrush ); painter.drawText( param.x_ + text_radius + card_offset, param.y_, QString::fromAscii( main_buf ) ); painter.setBackgroundMode( Qt::TransparentMode ); } }
void ActivityPartitionCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QRect r = rect(); FILE * fp = svg(); QColor bckgrnd = p.backgroundColor(); QColor co = color(used_color); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); p.setBackgroundColor(co); if (used_color != UmlTransparent) p.fillRect(r, co); p.setFont(the_canvas()->get_font(UmlNormalFont)); QFontMetrics fm(p.font()); int h = 3*fm.height(); if (fp != 0) { fprintf(fp, "<g>\n\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); } p.drawRect(r); if (horiz) { if (! str.isEmpty()) { p.save(); p.rotate(-90); p.drawText(-r.y(), r.x(), -r.height(), h, ::Qt::AlignCenter, str); p.restore(); if (fp != 0) { int index = str.find('\n'); if (index == -1) draw_rotate_text(r.x() + h/2, r.y() + r.height()/2, 270, str, p.font(), fp); else { int vc = r.y() + r.height()/2; draw_rotate_text(r.x() + h/4, vc, 270, str.left(index), p.font(), fp); draw_rotate_text(r.x() + (h*3)/4, vc, 270, str.mid(index + 1), p.font(), fp); } } } r.setLeft(r.left() + h); p.drawLine(r.topLeft(), r.bottomLeft()); if (fp) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.left(), r.top(), r.left(), r.bottom()); fputs("</g>\n", fp); } } else { if (! str.isEmpty()) { p.drawText(r.x(), r.y(), r.width(), h, ::Qt::AlignCenter, str); if (fp != 0) draw_text(r.x(), r.y(), r.width(), h, ::Qt::AlignCenter, str, p.font(), fp); } r.setTop(r.top() + h); p.drawLine(r.topLeft(), r.topRight()); if (fp) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.left(), r.top(), r.right(), r.top()); fputs("</g>\n", fp); } } p.setBackgroundColor(bckgrnd); if (selected()) show_mark(p, rect()); }
void SdDurationCanvas::draw(QPainter & p) { const QRect r = rect(); p.setRenderHint(QPainter::Antialiasing, true); UmlColor used_color = (itscolor != UmlDefaultColor) ? itscolor : browser_node->get_color(UmlActivityDuration); QColor co = color(used_color); int w = width() - 1; int x = r.left(); int y = r.top(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); p.fillRect(r, co); if (coregion) { p.drawLine(x, y + w, x, y); //p.lineTo(x + w, y); p.drawLine(x, y, x + w, y); //p.lineTo(x + w, y + w); p.drawLine(x + w, y, x + w, y + w); int b = r.bottom(); p.drawLine(x, b - w, x, b); //p.lineTo(x + w, b); p.drawLine(x, b, x + w, b); //p.lineTo(x + w, b - w); p.drawLine(x+w, b, x + w, b - w); } else p.drawRect(r); FILE * fp = svg(); if (fp != 0) { if (coregion) { fprintf(fp, "<g>\n" "\t<rect fill=\"%s\" stroke=\"none\" " " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n" "\t<path fill = \"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" " "d=\"M %d %d v %d h %d v %d M %d %d v %d h %d v %d\" />\n" "</g>\n", svg_color(used_color), x, y, w, r.height() - 1, x, y + w, -w, w, w, x, r.bottom() - w, w, w, -w); } else fprintf(fp, "<g>\n" "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n" "</g>\n", svg_color(used_color), x, y, w, r.height() - 1); } if (selected()) show_mark(p, r); }