Exemple #1
0
void counter::paint(QPainter &p, bool drawScore, int score, bool drawTimer, const QColor &c1, const QColor &c2, const QColor &c3, QSvgRenderer *renderer)
{
	p.save();
	p.translate(45, 15);
	p.setPen(QPen(Qt::black, 3));
	p.setBrush(QColor(40, 40, 40));
	if (drawTimer)
	{
		p.fillRect(-44, -13, 98, 48, p.brush());
		p.drawRoundRect(-45, -15, 100, 50, 15, 15);
	}
	else
	{
		p.fillRect(-44, -13, 70, 48, p.brush());
		p.drawRoundRect(-45, -15, 73, 50, 15, 15);
	}
	
	if (drawTimer)
	{
		p.fillRect(35, -6, 11, 9, c1);
		p.fillRect(35, 6, 11, 9, c2);
		p.fillRect(35, 18, 11, 9, c3);
	}
	
	if (drawScore)
	{
		p.translate(-5, -5);
		number n(score);
		n.paint(p, 2, renderer);
	}
	
	p.restore();
}
Exemple #2
0
void CanvasRoundRect::drawShape(QPainter &p)
{
    if ( qt_screen->deviceWidth() < 200 )
	p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
    else
	p.drawRoundRect( (int)x(), (int)y(), 23, 36);
}
void WTextSourceViewerLine::drawFoldingLineHidden(QPainter &p,const QPointF &pt)
{
  float demi_char_space=char_space/2.0f;
  QPointF pos(0,pt.y()-demi_char_space);
  QRectF  text_pos(pos,QSizeF(char_space,char_space));

  QPointF p3(pt.x(),pt.y());
  QPointF p1c(char_space,pt.y());
  QBrush b=p.brush();
  p.setBrush(Qt::black);
  QRectF endPoint3(p3.x()-2,p3.y()-2,4,4);

  p.drawEllipse(endPoint3);
  p.setBrush(b);
  p.drawLine(p1c,p3);
  float pos_size=char_space;
  QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
  p.drawRoundRect(rectangle);
  float _x1=pos.x()+3.0f;
  float _y=pos.y()+pos_size/2.0f;
  float _x2=pos.x()+pos_size-3.0f;
  float _x=pos.x()+pos_size/2;
  float _y1=pos.y()+3;
  float _y2=pos.y()+pos_size-3;
  p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
  p.drawLine(QPointF(_x,_y1),QPointF(_x,_y2));
}
Exemple #4
0
void Kanagram::drawText(QPainter &p, const QString &text, const QPoint &center, bool withMargin, int xMargin, int yMargin, QRect *rect, bool highlight, int fontSize)
{
	QRect r;
	QFont font = m_blackboardFont;
	font.setPointSize(fontSize);
	font.setBold(true);
	p.setFont(font);
	
	r = p.boundingRect(QRect(), Qt::AlignAuto, text);
	r = QRect(0, 0, r.width() + xMargin, r.height() + yMargin);
	r.moveBy(center.x() - r.width() / 2, center.y() - r.height() / 2);

	if (withMargin)
	{
		p.fillRect(r, m_fillColor);
		p.setPen(QPen(black, 3));
		p.drawRoundRect(r.left(), r.top(), r.width(), r.height(), 15, 15);
	}
	
	if (!highlight) p.setPen(m_chalkColor);
	else p.setPen(m_chalkHighlightColor);
	p.drawText(r, Qt::AlignCenter, text);
	
	if(rect) *rect = r;
}
Exemple #5
0
void PicItem::drawShape( QPainter & p )
{
	int _x = int(x());
	int _y = int(y());
	
	p.setBrush( QColor( 0xef, 0xff, 0xef ) );
	p.setFont( font() );
	
	p.drawRoundRect( _x, _y, width(), height(), 2000/width(), 2000/height() );
	
	p.drawText( _x+TopPadding-2, _y, width()-TopPadding+2, TopPadding, Qt::AlignVCenter, i18n("PIC Settings") );
	
	if ( !m_bExpanded )
		return;
	
	// Draw rectangle to cut off pins
	p.setBrush( QColor( 239, 255, 255 ) );
	QRect r( _x+SidePadding, _y+TopPadding, InnerWidth, m_innerHeight );
	p.drawRect(r);
	
	// Draw dimple thingy at end of pic
	p.drawArc( r.x()+(r.width()-ArcWidth)/2, r.y()+1-ArcWidth/2, ArcWidth, ArcWidth, 180*16, 180*16 );
	
	// Draw vertical text centered in PIC
	p.translate( r.width()/2 + r.x(), r.height()/2 + r.y() );
	p.rotate(90);
	QRect textRect( r.width()/-2, r.height()/-2, r.width(), r.height() );
	p.drawText( textRect, Qt::AlignCenter, microSettings->microInfo()->id() );
	
	p.rotate(-90);
	p.translate( r.width()/-2 - r.x(), r.height()/-2 - r.y() );
}
Exemple #6
0
void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore,
        ColourDesired back)
{
    Q_ASSERT(painter);

    painter->setPen(convertQColor(fore));
    painter->setBrush(convertQColor(back));
    painter->drawRoundRect(
            QRectF(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
}
Exemple #7
0
void Canvas::drawForeground(QPainter &p, const QRect & clip) {
	QCanvas::drawForeground(p, clip);

	if (!m_pMessageTimeout->isActive())
		return;

	// Following code stolen and adapted from amarok/src/playlist.cpp :)

	// Find out width of smallest view
	QSize minSize;

	const ViewList viewList = p_itemDocument->viewList();

	ViewList::const_iterator end = viewList.end();
	View *firstView = 0;
	for (ViewList::const_iterator it = viewList.begin(); it != end; ++it) {
		if (!*it) continue;

		if (!firstView) {
			firstView = *it;
			minSize = (*it)->size();
		} else	minSize = minSize.boundedTo((*it)->size());
	}

	if (!firstView) return;

	QSimpleRichText *t = new QSimpleRichText(m_message, QApplication::font());

	const int w = t->width();
	const int h = t->height();
	const int x = rect().left() + 15;
	const int y = rect().top() + 15;
	const int b = 10; // text padding

	if (w + 2 * b >= minSize.width() || h + 2 * b >= minSize.height()) {
		delete t;
		return;
	}

	p.setBrush(firstView->colorGroup().background());

	p.drawRoundRect(x, y,
			w + 2 * b,
			h + 2 * b,
			(8 * 200) / (w + 2 * b),
			(8 * 200) / (h + 2 * b));

	t->draw(&p, x + b, y + b, QRect(), firstView->colorGroup());
	delete t;
}
//!
//! Constructor of the ParameterTypeIcon class.
//!
//! \param color The color for the parameter type icon.
//!
ParameterTypeIcon::ParameterTypeIcon ( const QColor &color )
{
    m_color = color;

    const QRect pinRect (0, 4, 15, 8);
    const QColor penColor (109, 109, 109);
    QPixmap normalPixmap (16, 16);
    QPainter painter;
    if (painter.begin(&normalPixmap)) {
        // get the background color from the application style's standard palette
        QColor backgroundColor = QApplication::style()->standardPalette().color(QPalette::Base);
        // fill the pixmap with the background color
        painter.fillRect(normalPixmap.rect(), QBrush(backgroundColor));
        // draw the pin rect into the pixmap
        painter.setPen(QPen(penColor));
        painter.setBrush(QBrush(m_color));
        painter.drawRoundRect(pinRect);
        // end painting the pixmap
        if (painter.end()) {
            // create a bitmap for masking the pixmap
            QBitmap maskBitmap (normalPixmap.size());
            if (painter.begin(&maskBitmap)) {
                // fill the bitmap with white (meaning transparent)
                painter.fillRect(maskBitmap.rect(), QBrush(QColor(Qt::white)));
                // draw the pin rect as black (meaning opaque)
                painter.setPen(QPen(QColor(Qt::black)));
                painter.setBrush(QBrush(QColor(Qt::black)));
                painter.drawRoundRect(pinRect);
                // end painting the bitmap and set it as mask for the pixmap
                if (painter.end())
                    normalPixmap.setMask(maskBitmap);
            }
        }
    }
    // add the pixmap to the icon
    addPixmap(normalPixmap);
}
Exemple #9
0
void FlowContainer::drawShape( QPainter &p )
{
	if (b_deleted)
		return;

	if ( !m_sizeRect.isValid() )
		return;
	
	const int _x = (int)x()+offsetX();
	const int _y = (int)y()+offsetY();
	
	int col = 0xef + level()*0x6;
	if ( col > 0xff ) col = 0xff;
	p.setBrush( QColor( col, 0xff, col ) );
	if( b_expanded )
	{
		p.setPen(Qt::DotLine);
		p.drawRoundRect( _x, _y, width(), topStrip, 1500/width(), 1500/topStrip );
		p.drawRoundRect( _x, _y+height()-botStrip, width(), botStrip, 1500/width(), 1500/botStrip );
	}
	else
	{
		p.setPen(QPen((isSelected()?m_selectedCol:Qt::black),1,Qt::SolidLine));
		p.drawRoundRect( _x, _y, width(), topStrip, 1500/width(), 1500/topStrip );
	}
	
	p.setPen( Qt::black );
	p.setFont( font() );
	p.drawText( QRect( 22 + _x+8, _y, width()-8, topStrip ), Qt::AlignLeft | Qt::AlignVCenter,  m_caption );
	
	if( b_expanded )
	{
		p.setPen(Qt::SolidLine);
		p.setBrush( Qt::NoBrush );
		p.drawRoundRect( _x, _y, width(), height(), 1500/width(), 1500/height() );
	}
}
Exemple #10
0
void RegionWidget::paint(QPainter & p, int offsetX, int offsetY)
{
    setPenFromSettings(p);
    const int w = width();
    const int h = height();
    QPen pen = p.pen();
    {
        setPenFromSettings(p);
        pen.setColor ( Qt::red );
        pen.setStyle ( Qt::DashLine );
        p.setPen( pen );
        p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);

    }
    if(m_selected)
        drawSelected(&p, offsetX, offsetY);
}
void RenderArea::dibujarNodo(Nodo n,QPainter &P)
{
    QColor color(Qt::blue);


    QFontMetrics m(QFont("prueba",11,2,true));

    int x = m.boundingRect(n.etiqueta).width();
    int y = m.boundingRect(n.etiqueta).height();

    P.setPen(Qt::black);

    if(n.pintado)
     P.setBrush(color);
    else
     P.setBrush(Qt::white);


    P.drawRoundRect(n.x,n.y,x,y);
    P.drawText(n.x+15,n.y+15,n.etiqueta);
}
void WTextSourceViewerLine::drawFoldingLineVisible(QPainter &p,const QPointF &p1,const QPointF &p2)
{
  QPolygonF area;
  float demi_char_space=char_space/2.0f;
  QPointF pos(0.0f,(p1.y()+p2.y())/2.0f-demi_char_space);
  QRectF  text_pos(pos,QSizeF(char_space,char_space));

  QPointF p3(demi_char_space,p2.y());
  QRectF endPoint2(p2.x()-2,p2.y()-2,4,4);
  QBrush b=p.brush();
  p.setBrush(Qt::black);
  if (p1!=p2)
  {
    QPointF p0(demi_char_space,p1.y());
    QPointF p1b(demi_char_space,pos.y());
    QPointF p2b(demi_char_space,pos.y()+char_space);
    QRectF endPoint1(p1.x()-2,p1.y()-2,4,4);
    area << p0 << p1 ;
    area << p0 << p1b ;
    area << p2b << p3 ;
    area << p3 << p2 ;
    p.drawEllipse(endPoint1);
  }
  else
  {
    QPointF p1c(char_space,p2.y());
    area << p1c << p2 ;
  }

  p.drawEllipse(endPoint2);
  p.setBrush(b);
  p.drawLines(area);
  float pos_size=char_space;
  QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
  p.drawRoundRect(rectangle);
  float _x1=pos.x()+3.0f;
  float _y=pos.y()+pos_size/2.0f;
  float _x2=pos.x()+pos_size-3.0f;
  p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
}
Exemple #13
0
void GearGui_ListBox::drawShape(QPainter &painter)
{    
  //make the title bar show the value
  std::ostringstream sstream;
  std::string str = ((Gear_ListBox*)_gear)->getLabel();
  sstream << str;//((Gear_ListBox*)_gear)->getLabel();
  setTitle(sstream.str());

  GearGui::drawShape(painter);    

  int sliderStartX, sliderStartY, sizeX, sizeY;
  getDrawableArea(&sliderStartX, &sliderStartY, &sizeX , &sizeY);

  //convert sliderpos to screen value    
  int hi = _gear->settings().get(Gear_ListBox::SETTING_NELEMS)->valueInt()-1;
  float screenRatio;
  if (hi == 0)
    screenRatio = 0.5f;
  else
    screenRatio = ((Gear_ListBox*)_gear)->getValue() / (float)hi;
  int sliderPos = (int) ((float)(screenRatio * (float)(sizeX-SLIDER_THICKNESS)));

  //box                      
  painter.setPen(Qt::black);
  painter.setBrush(SLIDER_BOX_COLOR);
  painter.drawRect(sliderStartX, sliderStartY, sizeX, sizeY);
  painter.drawRect(sliderStartX, sliderStartY + SLIDER_LINE_OFFSETY, sizeX, 1);

  //3d
  painter.setPen(Qt::white);
  painter.drawRect(sliderStartX, sliderStartY + sizeY - 1, sizeX, 1);
  painter.drawRect(sliderStartX + sizeX - 1, sliderStartY, 1, sizeY);

  //slider
  painter.setPen(Qt::black);
  painter.setBrush(SLIDER_COLOR);
  painter.drawRoundRect(sliderStartX + sliderPos, sliderStartY, SLIDER_THICKNESS, sizeY, 85);

}
Exemple #14
0
void Kanagram::drawTextNew(QPainter &p, const QString &text, int textAlign, int xMargin, int yMargin, const QRect &rect, bool highlight, int fontSize)
{
	QRect r = innerRect(rect, xMargin, yMargin);
	QFont font = m_blackboardFont;
	font.setPointSize(fontSize);
	font.setBold(true);
	p.setFont(font);
	
	const bool withMargin = false;
	if (withMargin)
	{
		p.fillRect(r, m_fillColor);
		p.setPen(QPen(black, 3));
		p.drawRoundRect(r.left(), r.top(), r.width(), r.height(), 15, 15);
	}
	
	if (highlight)
		p.setPen(m_chalkHighlightColor);
	else
		p.setPen(m_chalkColor);
	p.drawText(r, textAlign, text);
}
Exemple #15
0
void Board::resizeEvent(QResizeEvent* event)
{
	m_piece_size = qMin(event->size().width() / 10, event->size().height() / 20);
	int w = m_piece_size * 10 + 1;
	int h = m_piece_size * 20 + 1;
	m_background = QRect((width() - w) / 2, (height() - h) / 2, w, h);

	QPainter painter;

	for (int i = 0; i < 7; ++i) {
		QPixmap pixmap(m_piece_size + 1, m_piece_size + 1);
		pixmap.fill(QColor(0, 0, 0, 0));

		painter.begin(&pixmap);
		painter.setRenderHint(QPainter::Antialiasing, true);
		painter.setBrush(colors[i]);
		painter.setPen(QPen(colors[i].lighter(), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
		painter.drawRoundRect(1, 1, m_piece_size - 1, m_piece_size - 1);
		painter.end();

		m_images[i] = pixmap;
	}
}
Exemple #16
0
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);
}
Exemple #17
0
void PreconditionWidget::paint(QPainter & p, int /*offsetX*/, int offsetY)
{
    int w = width();
    int h = height();

    int x = m_pOw->getX() + m_pOw->getWidth() / 2;
    x -= w/2;
    setX(x);
    int y = offsetY;

    //test if y isn't above the object
    if (y <= m_pOw->getY() + m_pOw->getHeight() ) {
        y = m_pOw->getY() + m_pOw->getHeight() + 15;
    }
    if (y + h >= m_pOw->getEndLineY()) {
        y = m_pOw->getEndLineY() - h;
    }
    setY(y);
    setPenFromSettings(p);
    if ( UMLWidget::useFillColor() ) {
        p.setBrush( UMLWidget::fillColor() );
    }
    {
        const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
        const int fontHeight  = fm.lineSpacing();
        const QString precondition_value = "{ " + name() + " }";
        //int middleX = w / 2;
        int textStartY = (h / 2) - (fontHeight / 2);
        p.drawRoundRect(x, y, w, h, (h * 60) / w, 60);
        p.setPen(textColor());
        p.setFont( UMLWidget::font() );
        p.drawText(x + PRECONDITION_MARGIN, y + textStartY,
                   w - PRECONDITION_MARGIN * 2, fontHeight, Qt::AlignCenter, precondition_value);
    }
    if(m_selected)
        drawSelected(&p, x, y);
}
Exemple #18
0
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize,
        ColourDesired fill, int alphaFill, ColourDesired outline,
        int alphaOutline, int)
{
    Q_ASSERT(painter);

    QColor outline_colour = convertQColor(outline, alphaOutline);
    QColor fill_colour = convertQColor(fill, alphaFill);

    // There was a report of Qt seeming to ignore the alpha value of the pen so
    // so we disable the pen if the outline and fill colours are the same.
    if (outline_colour == fill_colour)
        painter->setPen(Qt::NoPen);
    else
        painter->setPen(outline_colour);

    painter->setBrush(fill_colour);

    const int radius = (cornerSize ? 25 : 0);

    painter->drawRoundRect(
            QRectF(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top),
            radius, radius);
}
Exemple #19
0
void FlowPart::drawShape(QPainter &p) {
	initPainter(p);

	const double _x = int(x() + offsetX());
	const double _y = int(y() + offsetY());
	const double w = width();
	double h = height();

	switch (m_flowSymbol) {

	case FlowPart::ps_other:
		CNItem::drawShape(p);
		break;

	case FlowPart::ps_io: {
		h--;
		double roundSize = 8;
		double slantIndent = 5;

// 		CNItem::drawShape(p);
		double inner = std::atan(h / slantIndent);
		double outer = M_PI - inner;

		int inner16 = int(16 * inner * DPR);
		int outer16 = int(16 * outer * DPR);

		p.save();
		p.setPen(Qt::NoPen);
		p.drawPolygon(areaPoints());
		p.restore();

		p.drawLine(int(_x + slantIndent + roundSize / 2),
		           int(_y),
		           int(_x + w - roundSize / 2),
		           int(_y));

		p.drawLine(int(_x + w - slantIndent - roundSize / 2),
		           int(_y + h),
		           int(_x + roundSize / 2),
		           int(_y + h));

		p.drawLine(int(_x + w + (std::sin(outer) - 1) * roundSize / 2),
		           int(_y + (1 - std::cos(outer)) * roundSize / 2),
		           int(_x + w - slantIndent + (std::sin(inner) - 1) * roundSize / 2),
		           int(_y + h + (std::cos(inner) - 1) * roundSize / 2));

		p.drawLine(int(_x + (1 - std::sin(outer)) * roundSize / 2),
		           int(_y + h + (std::cos(outer) - 1) * roundSize / 2),
		           int(_x + slantIndent + (1 - std::sin(inner)) * roundSize / 2),
		           int(_y + (1 - std::cos(inner)) * roundSize / 2));

		p.drawArc(int(_x + slantIndent),
		          int(_y),
		          int(roundSize),
		          int(roundSize),
		          90 * 16,
		          inner16);

		p.drawArc(int(_x + w - roundSize),
		          int(_y),
		          int(roundSize),
		          int(roundSize),
		          270 * 16 + inner16,
		          outer16);

		p.drawArc(int(_x - slantIndent + w - roundSize),
		          int(_y + h - roundSize),
		          int(roundSize),
		          int(roundSize),
		          270*16,
		          inner16);

		p.drawArc(int(_x),
		          int(_y + h - roundSize),
		          int(roundSize),
		          int(roundSize),
		          90*16 + inner16,
		          outer16);
		break;
	}

	case FlowPart::ps_decision:
		// TODO Make the shape nice and pretty with rounded corners
		CNItem::drawShape(p);
		break;

	case FlowPart::ps_call:
		p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), int(1000. / w), int(1000. / h));
		p.drawLine(int(_x + 8), int(_y), int(_x + 8), int(_y + h));
		p.drawLine(int(_x + w - 8), int(_y), int(_x + w - 8), int(_y + h));
		break;

	case FlowPart::ps_process:
		p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), int(1000. / w), int(1000. / h));
		break;

	case FlowPart::ps_round:
		p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), 30, 100);
		break;
	}

	p.setPen(Qt::black);

	p.setFont(font());
	p.drawText(boundingRect(), (Qt::WordBreak | Qt::AlignHCenter | Qt::AlignVCenter), m_caption);
}
Exemple #20
0
void ActivityActionCanvas::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);
  
  const ActivityActionData * data =
    (ActivityActionData *) browser_node->get_data();
  const int shadow = the_canvas()->shadow();
  int margin;
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);  
  
  switch (data->get_action_kind()) {
  case UmlAcceptEventAction:
    if (((AcceptEventAction *) data->get_action())->timeevent) {
      // don't draw shadow
      margin = (int) (21 * the_canvas()->zoom());
      
      int t = (r.y() + r.bottom() - margin)/2;
      
      p.setPen(::Qt::SolidLine);
      p.setBackgroundMode(::Qt::TransparentMode);
      p.drawLine(r.right() - margin, t, r.right() - 1, t);
      p.lineTo(r.right() - margin - 1, t + margin);
      p.lineTo(r.right() - 1, t + margin);
      p.lineTo(r.right() - margin - 1, t);

      if (fp != 0) {
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin, t, r.right() - 1, t);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t, r.right() - margin - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin - 1, t + margin, r.right() - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t + margin, r.right() - margin - 1, t);
      }

      r.setWidth(r.width() - margin - 1);
      margin = (int) (3 * the_canvas()->zoom());
    }
    else {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right(), r.y());
      a.setPoint(2, r.right(), r.bottom());
      a.setPoint(3, r.x(), r.bottom());
      a.setPoint(4, r.x() + margin, (r.y() + r.bottom())/2);
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);

	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(3, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + margin + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setLeft(r.left() + margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  case UmlSendSignalAction:
  case UmlBroadcastSignalAction:
    {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right() - margin, r.y());
      a.setPoint(2, r.right(), (r.y() + r.bottom())/2);
      a.setPoint(3, r.right() - margin, r.bottom());
      a.setPoint(4, r.x(), r.bottom());
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() - margin + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(3, r.right() - margin + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
      
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setWidth(r.width() - margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  default:      
    margin = (int) (9 * the_canvas()->zoom());
      
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
      p.setPen(::Qt::NoPen);
      p.setBrush(::Qt::darkGray);
      p.drawRoundRect(r.left() + shadow, r.top() + shadow, r.width(), r.height());
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
		::Qt::darkGray.rgb()&0xffffff,
		r.left() + shadow, r.top() + shadow, r.width() - 1, r.height() - 1);

      p.setPen(::Qt::SolidLine);
    }
    
    p.setBrush(co);
    p.drawRoundRect(r);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" 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);
    
    if (data->get_action_kind() == UmlCallBehaviorAction) {
      BrowserNode * behavior =
	((CallBehaviorAction *) data->get_action())->behavior;
      
      if ((behavior != 0) && (behavior->get_type() == UmlActivity)) {
	int l = (int) (6 * the_canvas()->zoom());
	int lx = r.right() - margin - l;
	int ty = r.bottom() - margin - l;
	int mx = lx + l;
	int my = ty + l;
	int rx = mx + l;
	int by = my + l;
	
	p.drawLine(lx, my, rx, my);
	p.drawLine(mx, ty, mx, by);
	p.drawLine(lx, my, lx, by);
	p.drawLine(rx, my, rx, by);

	if (fp != 0) {
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, rx, my);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  mx, ty, mx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, lx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  rx, my, rx, by);
	}
      }
    }
    break;
  }
  
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  p.drawText(r.x() + margin,
	     r.y() + margin,
	     r.width() - margin - margin,
	     r.height() - margin - margin,
	     align, s);
  
  if (fp != 0) {
    fputs("</g>\n", fp);
    draw_text(r.x() + margin,
	      r.y() + margin,
	      r.width() - margin - margin,
	      r.height() - margin - margin,
	      align, s, p.font(), fp);
  }
  
  p.setBackgroundColor(bckgrnd);
  p.setBrush(brsh);
  
  if (selected())
    show_mark(p, rect());
}
Exemple #21
0
void MainWindow::on_chooseCube_editingFinished()
{
    ui->divideButton->clicked();
    ui->picLabelRoi->clear();
    int num_cube = ui->chooseCube->value();
    if(num_cube > 0 && num_cube <= cubeRow * cubeCol)
    {
        //find cube in pic
        int num_row = (num_cube - 1) / cubeCol;//start at 0
        int num_col = (num_cube - 1) % cubeCol; // start at 0
        //qDebug() << "row,col:" << num_row << num_col;
        chooseCubeColor = image_resize(cv::Rect(num_col*3,num_row*3,3,3));//cube what we choose

//        //painting roi
//        float multiple = (float)imgScaled.width() / (float)image_resize.size().width;
//        QPicture picture0;
//        QPainter painter0;
//        QPen pen_roi;
//        pen_roi.setColor(Qt::red);
//        pen_roi.setWidth(2);
//        painter0.begin(&picture0);
//        painter0.setPen(pen_roi);
//        //painting red Roi
//        painter0.drawRect(QRectF(num_col*3*multiple,num_row*3*multiple,3*multiple,3*multiple));
//        //qDebug() << QRectF(num_col*3*multiple,num_row*3*multiple,3*multiple,3*multiple);
//        painter0.end();
//        picture0.save("draw_roi.pic");
//        ui->picLabelRoi->setPicture(picture0);


        //painting cube
        QPicture picture;
        QPainter painter;
        QPen pen_cube;
        pen_cube.setColor(Qt::black);
        pen_cube.setWidth(2);
        painter.begin(&picture);
        painter.setPen(pen_cube);
        QBrush brush(Qt::SolidPattern);

        //painting choose cube
        int block_size = 40;
        for(int i = 0; i < 9; i++)
        {
            //qDebug() << "RGB:" << chooseCubeColor.at<Vec3b>(i/3,i%3).val[0]<<chooseCubeColor.at<Vec3b>(i/3,i%3).val[1]<<chooseCubeColor.at<Vec3b>(i/3,i%3).val[2];
            brush.setColor(QColor(chooseCubeColor.at<Vec3b>(i/3,i%3).val[0],chooseCubeColor.at<Vec3b>(i/3,i%3).val[1],chooseCubeColor.at<Vec3b>(i/3,i%3).val[2]));//RGB 3 channels
            painter.setBrush(brush);
            painter.drawRoundRect(QRect(block_size*i%(block_size*3),block_size*(i/3),block_size,block_size));
        }
        painter.end();
        picture.save("draw_cube.pic");
        ui->showCubeChoose->setPicture(picture);

        //store colors of cube
        for(int i = 0; i < 9; i++)
        {
            QColor qcolor = QColor(chooseCubeColor.at<Vec3b>(i/3,i%3).val[0],chooseCubeColor.at<Vec3b>(i/3,i%3).val[1],chooseCubeColor.at<Vec3b>(i/3,i%3).val[2]);//RGB 3 channels
            int color_num;
            if(qcolor == colorTable_cube[0])
                color_num = 0;
            else if(qcolor == colorTable_cube[1])
                color_num = 1;
            else if(qcolor == colorTable_cube[2])
                color_num = 2;
            else if(qcolor == colorTable_cube[3])
                color_num = 3;
            else if(qcolor == colorTable_cube[4])
                color_num = 4;
            else if(qcolor == colorTable_cube[5])
                color_num = 5;
            else
                color_num = -1;
            col[i] = RubikColor(color_num);
            //qDebug() << "color:" << color_num;
        }
        dlg.setRubikColor(col);
    }
    else
    {
        int ret = QMessageBox::warning(this, "Warning", "Please choose the cube you want to make!", QMessageBox::Abort);
        if (ret == QMessageBox::Abort)
            qDebug() << "WARNING!!";
    }

}
Exemple #22
0
void StateWidget::draw(QPainter & p, int offsetX, int offsetY) {
    UMLWidget::setPen(p);
    const int w = width();
    const int h = height();
    switch (m_StateType)
    {
    case Normal :
        if(UMLWidget::getUseFillColour())
            p.setBrush(UMLWidget::getFillColour());
        {
            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
            const int fontHeight  = fm.lineSpacing();
            int textStartY = (h / 2) - (fontHeight / 2);
            const int count = m_Activities.count();
            if( count == 0 ) {
                p.drawRoundRect(offsetX, offsetY, w, h, (h*40)/w, (w*40)/h);
                p.setPen(Qt::black);
                QFont font = UMLWidget::getFont();
                font.setBold( false );
                p.setFont( font );
                p.drawText(offsetX + STATE_MARGIN, offsetY + textStartY,
                           w - STATE_MARGIN * 2, fontHeight,
                           Qt::AlignCenter, getName());
                UMLWidget::setPen(p);
            } else {
                p.drawRoundRect(offsetX, offsetY, w, h, (h*40)/w, (w*40)/h);
                textStartY = offsetY + STATE_MARGIN;
                p.setPen(Qt::black);
                QFont font = UMLWidget::getFont();
                font.setBold( true );
                p.setFont( font );
                p.drawText(offsetX + STATE_MARGIN, textStartY, w - STATE_MARGIN * 2,
                           fontHeight, Qt::AlignCenter, getName());
                font.setBold( false );
                p.setFont( font );
                UMLWidget::setPen(p);
                int linePosY = textStartY + fontHeight;

                QStringList::Iterator end(m_Activities.end());
                for( QStringList::Iterator it(m_Activities.begin()); it != end; ++it ) {
                    textStartY += fontHeight;
                    p.drawLine( offsetX, linePosY, offsetX + w - 1, linePosY );
                    p.setPen(Qt::black);
                    p.drawText(offsetX + STATE_MARGIN, textStartY, w - STATE_MARGIN * 2 - 1,
                               fontHeight, Qt::AlignCenter, *it);
                    UMLWidget::setPen(p);
                    linePosY += fontHeight;
                }//end for
            }//end else
        }
        break;
    case Initial :
        p.setBrush( WidgetBase::getLineColor() );
        p.drawEllipse( offsetX, offsetY, w, h );
        break;
    case End :
        p.setBrush( WidgetBase::getLineColor() );
        p.drawEllipse( offsetX, offsetY, w, h );
        p.setBrush( Qt::white );
        p.drawEllipse( offsetX + 1, offsetY + 1, w - 2, h - 2 );
        p.setBrush( WidgetBase::getLineColor() );
        p.drawEllipse( offsetX + 3, offsetY + 3, w - 6, h - 6 );
        break;
    default:
        kWarning() << "Unknown state type:" << m_StateType << endl;
        break;
    }
    if(m_bSelected)
        drawSelected(&p, offsetX, offsetY);
}