Пример #1
0
FloatRect ChromeClientQt::pageRect()
{
    if (!m_webPage)
        return FloatRect();
    return FloatRect(QRectF(QPointF(0, 0), m_webPage->viewportSize()));
}
Пример #2
0
QRectF StackZone::boundingRect() const
{
    return QRectF(0, 0, 100, zoneHeight);
}
void QgsPointDisplacementRenderer::drawGroup( const DisplacementGroup& group, QgsRenderContext& context )
{
  const QgsFeature& feature = group.begin().value().first;
  bool selected = mSelectedFeatures.contains( feature.id() ); // maybe we should highlight individual features instead of the whole group?



  //get list of labels and symbols
  QStringList labelAttributeList;
  QList<QgsMarkerSymbolV2*> symbolList;

  QgsMultiPointV2* groupMultiPoint = new QgsMultiPointV2();
  for ( DisplacementGroup::const_iterator attIt = group.constBegin(); attIt != group.constEnd(); ++attIt )
  {
    labelAttributeList << ( mDrawLabels ? getLabel( attIt.value().first ) : QString() );
    symbolList << dynamic_cast<QgsMarkerSymbolV2*>( attIt.value().second );
    groupMultiPoint->addGeometry( attIt.value().first.constGeometry()->geometry()->clone() );
  }

  //calculate centroid of all points, this will be center of group
  QgsGeometry groupGeom( groupMultiPoint );
  QgsGeometry* centroid = groupGeom.centroid();
  QPointF pt;
  _getPoint( pt, context, QgsConstWkbPtr( centroid->asWkb(), centroid->wkbSize() ) );
  delete centroid;

  //calculate max diagonal size from all symbols in group
  double diagonal = 0;
  Q_FOREACH ( QgsMarkerSymbolV2* symbol, symbolList )
  {
    if ( symbol )
    {
      diagonal = qMax( diagonal, QgsSymbolLayerV2Utils::convertToPainterUnits( context,
                       M_SQRT2 * symbol->size(),
                       symbol->outputUnit(), symbol->mapUnitScale() ) );
    }
  }

  QgsSymbolV2RenderContext symbolContext( context, QgsSymbolV2::MM, 1.0, selected );

  QList<QPointF> symbolPositions;
  QList<QPointF> labelPositions;
  double circleRadius = -1.0;
  calculateSymbolAndLabelPositions( symbolContext, pt, symbolList.size(), diagonal, symbolPositions, labelPositions, circleRadius );

  //draw Circle
  if ( circleRadius > 0 )
    drawCircle( circleRadius, symbolContext, pt, symbolList.size() );

  //draw mid point
  if ( labelAttributeList.size() > 1 )
  {
    if ( mCenterSymbol )
    {
      mCenterSymbol->renderPoint( pt, &feature, context, -1, selected );
    }
    else
    {
      context.painter()->drawRect( QRectF( pt.x() - symbolContext.outputLineWidth( 1 ), pt.y() - symbolContext.outputLineWidth( 1 ), symbolContext.outputLineWidth( 2 ), symbolContext.outputLineWidth( 2 ) ) );
    }
  }

  //draw symbols on the circle
  drawSymbols( feature, context, symbolList, symbolPositions, selected );
  //and also the labels
  drawLabels( pt, symbolContext, labelPositions, labelAttributeList );
}
QRectF ChatWidget::boundingRect() const{
    return QRectF(-1, 0, 24 * 3 + 2, 24);
}
Пример #5
0
void Webcam::paintEvent(QPaintEvent *event)
{
	QRectF rect = QRectF(QPoint(), size());
	QPainter painter(this);
	painter.drawPixmap(rect, pixmap, rect);
}
Пример #6
0
bool CDiagramTextNode::stopGrowing(const QPointF &p)
{
	setGeometry( QRectF(p, QSizeF(80, 24)) );
	return true;
}
Пример #7
0
void CDiagramItem::setPos(qreal x, qreal y)
{
	setGeometry( QRectF(QPointF(x,y), size()) );
}
Пример #8
0
void GraphViewer::onSceneMousePress(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (_vertices.isEmpty())
        _initialText->setVisible(false);

    if (_scene.items(QRectF(
                mouseEvent->scenePos().x() - VERTEX_SIZE*0.5,
                mouseEvent->scenePos().y() - VERTEX_SIZE*0.5,
                VERTEX_SIZE,
                VERTEX_SIZE)
                ).isEmpty())
    {
        // Create new vertex
        QGraphicsEllipseItem * vertex = _scene.addEllipse(
                    QRectF(-VERTEX_SIZE*0.5, -VERTEX_SIZE*0.5, VERTEX_SIZE, VERTEX_SIZE),
                    QPen(Qt::black, 0),
                    QBrush(Qt::white)
                    );
        vertex->setTransform(
                    QTransform::fromTranslate(mouseEvent->scenePos().x(), mouseEvent->scenePos().y())
                    );
        vertex->setZValue(VERTEX_CIRCLE_Z);
        _vertices << vertex;
        int id = _vertices.size()-1;
        vertex->setData(KEY_VERTEX_ID, id);
        QGraphicsSimpleTextItem * vertexId = _scene.addSimpleText(QString("%1").arg(id+1));
        vertexId->setParentItem(vertex);
        vertexId->setTransform(
                    QTransform::fromScale(0.005, 0.005)
                    * QTransform::fromTranslate(-VERTEX_SIZE*( (id < 9) ? 0.18 : 0.28 ), -VERTEX_SIZE*0.35)
                    );
        vertexId->setZValue(VERTEX_TEXT_Z);

    }
    else
    {
        // Propose to draw new edge
        QGraphicsItem * item = _scene.itemAt(mouseEvent->scenePos(), QTransform());
        if (qgraphicsitem_cast<QGraphicsEllipseItem*>(item)
                || qgraphicsitem_cast<QGraphicsSimpleTextItem*>(item))
        {
            QGraphicsEllipseItem* vertex = qgraphicsitem_cast<QGraphicsEllipseItem*>(item->parentItem());
            if (!vertex)
                vertex = qgraphicsitem_cast<QGraphicsEllipseItem*>(item);

            if (vertex)
            {
                _isDrawingEdge=true;
                _drawingEdge = _scene.addLine(0.0,
                                              0.0,
                                              mouseEvent->scenePos().x()-vertex->scenePos().x(),
                                              mouseEvent->scenePos().y()-vertex->scenePos().y(),
                                              QPen(Qt::black, 0));
                _drawingEdge->setTransform(QTransform::fromTranslate(vertex->scenePos().x(), vertex->scenePos().y()));
                _drawingEdge->setZValue(VERTEX_CIRCLE_Z);
                _drawingEdge->setData(KEY_EDGE_VERTEX1, vertex->data(KEY_VERTEX_ID));
            }

        }
    }
}
QRectF Warning::boundingRect() const
{
    return QRectF(QPointF(100,200),QSize(400,200));
}
Пример #10
0
TextRenderable::TextRenderable(const TextSymbol* symbol, const TextObject* text_object, const MapColor* color, double anchor_x, double anchor_y, bool framing_line)
 : Renderable(color)
{
	const QFont& font(symbol->getQFont());
	const QFontMetricsF& metrics(symbol->getFontMetrics());
	this->anchor_x = anchor_x;
	this->anchor_y = anchor_y;
	this->rotation = text_object->getRotation();
	scale_factor = symbol->getFontSize() / TextSymbol::internal_point_size;
	this->framing_line = framing_line;
	framing_line_width = framing_line ? (2 * 0.001 * symbol->getFramingLineHalfWidth() / scale_factor) : 0;
	
	path.setFillRule(Qt::WindingFill);	// Otherwise, when text and an underline intersect, holes appear
	
	int num_lines = text_object->getNumLines();
	for (int i=0; i < num_lines; i++)
	{
		const TextObjectLineInfo* line_info = text_object->getLineInfo(i);
		
		double line_y = line_info->line_y;
		
		double underline_x0 = 0.0;
		double underline_y0 = line_info->line_y + metrics.underlinePos();
		double underline_y1 = underline_y0 + metrics.lineWidth();
		
		int num_parts = line_info->part_infos.size();
		for (int j=0; j < num_parts; j++)
		{
			const TextObjectPartInfo& part(line_info->part_infos.at(j));
			if (font.underline())
			{
				if (j > 0)
				{
					// draw underline for gap between parts as rectangle
					// TODO: watch out for inconsistency between text and gap underline
					path.moveTo(underline_x0, underline_y0);
					path.lineTo(part.part_x,  underline_y0);
					path.lineTo(part.part_x,  underline_y1);
					path.lineTo(underline_x0, underline_y1);
					path.closeSubpath();
				}
				underline_x0 = part.part_x;
			}
			path.addText(part.part_x, line_y, font, part.part_text);
		}
	}
	
	extent = path.controlPointRect();
	extent = QRectF(scale_factor * (extent.left() - 0.5f * framing_line_width),
					scale_factor * (extent.top() - 0.5f * framing_line_width),
					scale_factor * (extent.width() + framing_line_width),
					scale_factor * (extent.height() + framing_line_width));
	if (rotation != 0)
	{
		float rcos = cos(-rotation);
		float rsin = sin(-rotation);
		
		std::vector<QPointF> extent_corners;
		extent_corners.push_back(extent.topLeft());
		extent_corners.push_back(extent.topRight());
		extent_corners.push_back(extent.bottomRight());
		extent_corners.push_back(extent.bottomLeft());
		
		for (int i = 0; i < 4; ++i)
		{
			auto x = extent_corners[i].x() * rcos - extent_corners[i].y() * rsin;
			auto y = extent_corners[i].y() * rcos + extent_corners[i].x() * rsin;
			
			if (i == 0)
				extent = QRectF(x, y, 0, 0);
			else
				rectInclude(extent, QPointF(x, y));
		}
	}
	extent = QRectF(extent.left() + anchor_x, extent.top() + anchor_y, extent.width(), extent.height());
	
	Q_ASSERT(extent.right() < 999999);	// assert if bogus values are returned
}
Пример #11
0
LineRenderable::LineRenderable(const LineSymbol* symbol, const VirtualPath& virtual_path, bool closed)
 : Renderable(symbol->getColor())
 , line_width(0.001f * symbol->getLineWidth())
{
	Q_ASSERT(virtual_path.size() >= 2);
	
	float half_line_width = (color_priority < 0) ? 0.0f : 0.5f * line_width;
	
	switch (symbol->getCapStyle())
	{
		case LineSymbol::FlatCap:		cap_style = Qt::FlatCap;	break;
		case LineSymbol::RoundCap:		cap_style = Qt::RoundCap;	break;
		case LineSymbol::SquareCap:		cap_style = Qt::SquareCap;	break;
		case LineSymbol::PointedCap:	cap_style = Qt::FlatCap;	break;
	}
	switch (symbol->getJoinStyle())
	{
		case LineSymbol::BevelJoin:		join_style = Qt::BevelJoin;	break;
		case LineSymbol::MiterJoin:		join_style = Qt::MiterJoin;	break;
		case LineSymbol::RoundJoin:		join_style = Qt::RoundJoin;	break;
	}
	
	auto& flags  = virtual_path.coords.flags;
	auto& coords = virtual_path.coords;
	
	bool has_curve = false;
	bool hole = false;
	bool gap = false;
	QPainterPath first_subpath;
	
	auto i = virtual_path.first_index;
	path.moveTo(coords[i]);
	extent = QRectF(coords[i].x(), coords[i].y(), 0.0001f, 0.0001f);
	extentIncludeCap(i, half_line_width, false, symbol, virtual_path);
	
	for (++i; i <= virtual_path.last_index; ++i)
	{
		if (gap)
		{
			if (flags[i].isHolePoint())
			{
				gap = false;
				hole = true;
			}
			else if (flags[i].isGapPoint())
			{
				gap = false;
				if (first_subpath.isEmpty() && closed)
				{
					first_subpath = path;
					path = QPainterPath();
				}
				path.moveTo(coords[i]);
				extentIncludeCap(i, half_line_width, false, symbol, virtual_path);
			}
			continue;
		}
		
		if (hole)
		{
			Q_ASSERT(!flags[i].isHolePoint() && "Two hole points in a row!");
			if (first_subpath.isEmpty() && closed)
			{
				first_subpath = path;
				path = QPainterPath();
			}
			path.moveTo(coords[i]);
			extentIncludeCap(i, half_line_width, false, symbol, virtual_path);
			hole = false;
			continue;
		}
		
		if (flags[i-1].isCurveStart())
		{
			Q_ASSERT(i < virtual_path.last_index-1);
			has_curve = true;
			path.cubicTo(coords[i], coords[i+1], coords[i+2]);
			i += 2;
		}
		else
			path.lineTo(coords[i]);
		
		if (flags[i].isHolePoint())
			hole = true;
		else if (flags[i].isGapPoint())
			gap = true;
		
		if ((i < virtual_path.last_index && !hole && !gap) || (i == virtual_path.last_index && closed))
			extentIncludeJoin(i, half_line_width, symbol, virtual_path);
		else
			extentIncludeCap(i, half_line_width, true, symbol, virtual_path);
	}
	
	if (closed)
	{
		if (first_subpath.isEmpty())
			path.closeSubpath();
		else
			path.connectPath(first_subpath);
	}
	
	// If we do not have the path coords, but there was a curve, calculate path coords.
	if (has_curve)
	{
		//  This happens for point symbols with curved lines in them.
		const auto& path_coords = virtual_path.path_coords;
		Q_ASSERT(path_coords.front().param == 0.0);
		Q_ASSERT(path_coords.back().param == 0.0);
		for (auto i = path_coords.size()-1; i > 0; --i)
		{
			if (path_coords[i].param != 0.0)
			{
				const auto& pos = path_coords[i].pos;
				auto to_coord   = pos - path_coords[i-1].pos;
				auto to_next    = path_coords[i+1].pos - pos;
				to_coord.normalize();
				to_next.normalize();
				auto right = (to_coord + to_next).perpRight();
				right.setLength(half_line_width);
				
				rectInclude(extent, pos + right);
				rectInclude(extent, pos - right);
			}
		}
	}
	Q_ASSERT(extent.right() < 999999);	// assert if bogus values are returned
}
Пример #12
0
void Mesa::paintEvent ( QPaintEvent * event ) {

        QPainter painter;
        painter.begin ( this ); // paint in picture
	painter.setPen(QColor(0, 0, 0, 255));
	QFont sansFont("Helvetica [Cronyx]", 8);
	QFont normal("Helvetica [Cronyx]", 10);
	painter.setFont(normal);
	
    BtCompany * emp = ( BtCompany * ) mainCompany();
    
    
    if (g_selectedTables.contains(m_nombreMesa) && (!g_selectMode)) {    
      painter.fillRect(0,0,m_XScale,m_YScale, QColor(255,255,0));
    } // end if
    
    /// Miramos que no haya ningun ticket abierto con el nombre usado
    BtTicket *ticket = NULL;
    for ( int i = 0; i < emp->listaTickets() ->size(); ++i ) {
        ticket = emp->listaTickets() ->at ( i );
        if ( m_nombreMesa == ticket->dbValue ( "nomticket" )) {
	  
	    if (ticket->dbValue("idalbaran") != "") {
	       painter.setBrush(Qt::cyan);
		painter.drawRect(QRectF (0, 0, m_XScale, 30));
		painter.setBrush(Qt::NoBrush);

	    } // end if
	  
	  
	    int min = ticket->elapsed() / 60000;
	    int sec = (ticket->elapsed() % 60000) / 1000;
	    QString tiempo;
	    tiempo.sprintf( "%02i:%02i",  min, sec );

	    
	    painter.setFont(sansFont);
	    painter.drawText(0,20, tiempo);
	    painter.setFont(normal);
            painter.setPen(QColor(255, 0, 0, 127));
        }// end if
    }// end for
    painter.drawText(0, 10, m_nombreMesa);

    if (m_escalando == 0)  {
	    QSvgRenderer arender(QString(m_filename), this);
    //        arender.render(&painter, QRectF (0, 15, g_escala, g_escala));
	    arender.render(&painter, QRectF (0, 15, m_XScale, m_YScale));
    }

    if (g_mesaAct == this) {
        if (!g_bloqueo) {
            painter.setPen(QColor(0, 0, 0, 127));
            painter.setPen(Qt::DashDotLine);
            painter.drawRect(0,0,m_XScale,m_YScale);

            painter.setPen(QColor(0, 0, 0, 127));
            painter.setPen(Qt::DashDotLine);
            painter.setBrush(Qt::green);
            painter.drawRect(0,0,5,5);
            painter.drawRect(0,m_YScale -5, 5, 5);
            painter.drawRect(m_XScale -5,0, 5, 5);
            painter.drawRect(m_XScale -5,m_YScale -5, 5, 5);

            painter.drawRect(m_XScale / 2 -3,m_YScale -5, 5, 5);
            painter.drawRect(m_XScale / 2 -3, 0, 5, 5);
            painter.drawRect(0,m_YScale / 2 -3, 5, 5);
            painter.drawRect(m_XScale - 5,m_YScale / 2 -3, 5, 5);

        
      } else {
            painter.setPen(Qt::DashDotLine);
	    painter.drawRect(0,0,m_XScale,m_YScale);
      }// end if
    } //end if


        painter.end();

}
Пример #13
0
QRectF CellView::boundingRect() const
{
    return QRectF(0, 0, width_, height_);
}
Пример #14
0
void ORPrintRender::renderPage(ORODocument * pDocument, int pageNb, QPainter *painter, qreal xDpi, qreal yDpi, QSize margins, int printResolution)
{
  OROPage * p = pDocument->page(pageNb);

  if(((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0)) ||
     ((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0)))
  {
    // Do some simple processing used by both Background and Watermark
    const int resolution = 100;
    bool doBgWm = false;
    int printMarginWidth  = margins.width()  < 0 ? 0 : margins.width();
    int printMarginHeight = margins.height() < 0 ? 0 : margins.height();

    QString pageSize = pDocument->pageOptions().getPageSize();
    int pageWidth = 0;
    int pageHeight = 0;
    if(pageSize == "Custom") {
      // if this is custom sized sheet of paper we will just use those values
      pageWidth = (int)(pDocument->pageOptions().getCustomWidth() * resolution);
      pageHeight = (int)(pDocument->pageOptions().getCustomHeight() * resolution);
    } else {
      // lookup the correct size information for the specified size paper
      PageSizeInfo pi = PageSizeInfo::getByName(pageSize);
      if(!pi.isNull())
      {
        pageWidth = (int)((pi.width() / 100.0) * resolution);
        pageHeight = (int)((pi.height() / 100.0) * resolution);
      }
    }
    if(!pDocument->pageOptions().isPortrait()) {
      int tmp = pageWidth;
      pageWidth = pageHeight;
      pageHeight = tmp;
    }
    if(pageWidth < 1 || pageHeight < 1) {
      // whoops we couldn't find it.... we will use the values from the painter
      // and add in the margins of the printer to get what should be the correct
      // size of the sheet of paper we are printing to.
      pageWidth = (int)(((painter->viewport().width() + printMarginWidth + printMarginWidth) / xDpi) * resolution);
      pageHeight = (int)(((painter->viewport().height() + printMarginHeight + printMarginHeight) / yDpi) * resolution);
    }

    QImage image = QImage(pageWidth, pageHeight, QImage::Format_RGB32);
    QPainter gPainter;
    if(gPainter.begin(&image))
      gPainter.fillRect(gPainter.viewport(), QColor(Qt::white));

    // Render Background
    if((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0))
    {
      doBgWm = true;
      QPointF ps = p->backgroundPosition();
      QSizeF sz = p->backgroundSize();
      QRectF rc = QRectF(ps.x() * resolution, ps.y() * resolution, sz.width() * resolution, sz.height() * resolution);
      renderBackground(image, p->backgroundImage(), rc.toRect(),
        p->backgroundScale(), p->backgroundScaleMode(),
        p->backgroundAlign(), p->backgroundOpacity());
    }

    // Render Watermark
    if((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0))
    {
      doBgWm = true;
      renderWatermark(image, p->watermarkText(), p->watermarkFont(), p->watermarkOpacity(),
                      pDocument->pageOptions().getMarginLeft()   * resolution,
                      pDocument->pageOptions().getMarginRight()  * resolution,
                      pDocument->pageOptions().getMarginTop()    * resolution,
                      pDocument->pageOptions().getMarginBottom() * resolution);
    }

    if(doBgWm)
    {
      QRectF target(0, 0, pageWidth, pageHeight);
      painter->save();
      painter->scale(xDpi / resolution, yDpi / resolution);
      QRectF source(0, 0, image.width(), image.height());
      painter->drawImage(target, image, source);
      painter->restore();
    }
  }

  // Render Page Objects
  for(int i = 0; i < p->primitives(); i++)
  {
    OROPrimitive * prim = p->primitive(i);

    QPen pen(prim->pen());
    painter->save();
    painter->setPen(pen);
    painter->setBrush(prim->brush());

    QPointF ps = prim->position();
    if(prim->rotationAxis().isNull())
    {
      painter->translate(ps.x() * xDpi, ps.y() * yDpi);
      painter->rotate(prim->rotation()); // rotation around the origin of the primitive (not the center)
    }
    else
    { // rotation around the defined axis
      qreal xRot = prim->rotationAxis().x();
      qreal yRot = prim->rotationAxis().y();
      painter->translate(xRot * xDpi, yRot * yDpi);
      painter->rotate(prim->rotation());
      painter->translate((ps.x() - xRot) * xDpi, (ps.y() - yRot) * yDpi);
    }

    if(prim->type() == OROTextBox::TextBox)
    {
      OROTextBox * tb = (OROTextBox*)prim;

      QSizeF sz = tb->size();
      QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi);

      prim->drawRect(rc, painter, printResolution);

      painter->setFont(tb->font());
      QString text = tb->text();
      QString url;

      if(tb->text().startsWith("<http"))
      {
          int endOfUrl = tb->text().indexOf('>');
          if(endOfUrl > 0)
          {
              url = tb->text().mid(1, endOfUrl-1);
              text = tb->text().mid(endOfUrl+1);
              if(text.isEmpty()) text = url;
          }
      }

      bool toPdf = painter->paintEngine()->type() == QPaintEngine::Pdf;
      if(toPdf && !url.isEmpty())
      {
          QTextDocument doc;
          QTextCursor cursor(&doc);
          QTextCharFormat format;
          format.setFont(tb->font());
          format.setFontPointSize(tb->font().pointSizeF()*printResolution/100.0);
          format.setAnchor(true);
          format.setAnchorHref(url);
          cursor.insertText(text, format);
          doc.drawContents(painter);
      }
      else
      {
          painter->drawText(rc, tb->flags(), text);
      }

    }
    else if(prim->type() == OROBarcode::Barcode)
    {
      OROBarcode * bc = (OROBarcode*)prim;

      QSizeF sz = bc->size();
      QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi);


      if(painter->paintEngine()->type() == QPaintEngine::User)
      {
        // label paint engine: the barcode parameters are encoded in a text item
        QString encodedData = ReportPrinter::barcodePrefix() + QString("%1;%2;%3;%4").arg(bc->format()).arg(sz.height()).arg(bc->narrowBarWidth()).arg(bc->data());
        painter->drawText(rc, 0, encodedData);
      }
      else
      {
        if(bc->format() == "3of9")
          render3of9(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "3of9+")
          renderExtended3of9(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "128")
          renderCode128(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "i2of5")
          renderI2of5(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "ean13")
          renderCodeEAN13(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "ean8")
          renderCodeEAN8(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "upc-a")
          renderCodeUPCA(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format() == "upc-e")
          renderCodeUPCE(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format().contains("datamatrix"))
          renderCodeDatamatrix(painter, rc, bc->data(), bc);
        else if(bc->format().contains("PDF417"))
          renderPDF417(painter, xDpi, rc, bc->data(), bc);
        else if(bc->format().contains("QR"))
          renderQR(painter, xDpi, rc, bc->data(), bc);
        else
        {
          painter->drawText(rc, 0, "ERR: [" + bc->format() + "]" + bc->data());
        }
      }
    }
    else if(prim->type() == OROLine::Line)
    {
        OROLine * ln = (OROLine*)prim;
		QPointF s = ln->startPoint();
		QPointF e = ln->endPoint();
        pen.setWidthF((pen.widthF() / 100.0) * printResolution);
		painter->setPen(pen);
		painter->drawLine(QLineF(0, 0, (e.x()-s.x()) * xDpi, (e.y()-s.y()) * yDpi));
    }
    else if(prim->type() == OROImage::Image)
    {
      OROImage * im = (OROImage*)prim;
      QSizeF sz = im->size();
      QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi);

      prim->drawRect(rc, painter, printResolution);

      QImage img = im->image();
      if(im->scaled())
        img = img.scaled(rc.size().toSize(), (Qt::AspectRatioMode)im->aspectRatioMode(), (Qt::TransformationMode)im->transformationMode());
      else
        img = img.scaled(QSize(img.width()*(int)xDpi/150, img.height()*(int)yDpi/150), Qt::KeepAspectRatio);

      QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size()));
      painter->drawImage(rc.topLeft(), img, sr);
    }
    else if(prim->type() == ORORect::Rect)
    {
      QSizeF sz = ((OROTextBox*)prim)->size();
      QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi);
      prim->drawRect(rc, painter, printResolution);
    }
    else
    {
      qDebug("unrecognized primitive type");
    }

    painter->restore();

  }
}
Пример #15
0
static inline QRectF qwtBoundingRect( const QwtIntervalSample &sample )
{
    return QRectF( sample.interval.minValue(), sample.value,
        sample.interval.maxValue() - sample.interval.minValue(), 0.0 );
}
Пример #16
0
QRectF GameItem::boundingRect() const
{
    return QRectF(pos(), m_selPix->size());
}
void SaveAsImageDialog::accept() {
    const QString fileName = ui->name->text();
    if (fileName.isEmpty())
        return;

    if (QFile::exists(fileName)) {
        const QMessageBox::StandardButton button =
                QMessageBox::warning(this,
                                     tr("Save as Image"),
                                     tr("%1 already exists.\n"
                                        "Do you want to replace it?")
                                     .arg(QFileInfo(fileName).fileName()),
                                     QMessageBox::Yes | QMessageBox::No,
                                     QMessageBox::No);

        if (button != QMessageBox::Yes)
            return;
    }

    const bool visibleLayersOnly = ui->visibleLayers->isChecked();
    const bool useCurrentScale = ui->currentZoomLevel->isChecked();
    const bool drawTileGrid = ui->showGrid->isChecked();

    MapRenderer *renderer = mMapEditor->renderer();

    //remember the current render flags
    const Aurora::RenderFlags renderFlags = renderer->flags();

    renderer->setFlag(ShowTileObjectOutlines, false);

    QSize mapSize = renderer->mapSize();
    if (useCurrentScale)
        mapSize *= mCurrentScale;

    QImage image(mapSize, QImage::Format_ARGB32);
    image.fill(Qt::transparent);
    QPainter painter(&image);

    if (useCurrentScale && mCurrentScale != qreal(1)) {
        painter.setRenderHints(QPainter::SmoothPixmapTransform |
                               QPainter::HighQualityAntialiasing);
        painter.setTransform(QTransform::fromScale(mCurrentScale,
                                                   mCurrentScale));
    }

    foreach (const Layer *layer, mMapEditor->map()->layers()) {
        if (visibleLayersOnly && !layer->isVisible())
            continue;

        painter.setOpacity(layer->opacity());

        const Tilelayer *tilelayer = dynamic_cast<const Tilelayer*>(layer);

        if (tilelayer) {
            renderer->drawTilelayer(&painter, tilelayer);
        }
    }

    if (drawTileGrid) {
        renderer->drawGrid(&painter, QRectF(QPointF(), renderer->mapSize()));
    }

    //restore the previous render flags
    renderer->setFlags(renderFlags);

    image.save(fileName);
    mPath = QFileInfo(fileName).path();

    //store settings for next time
    QSettings *s = Preferences::instance()->settings();
    s->setValue(QLatin1String(VISIBLE_ONLY_KEY), visibleLayersOnly);
    s->setValue(QLatin1String(CURRENT_SCALE_KEY), useCurrentScale);
    s->setValue(QLatin1String(DRAW_GRID_KEY), drawTileGrid);

    QDialog::accept();
}
Пример #18
0
void SliderThumb::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    // Halo

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(_haloColor);
    painter.setBrush(brush);
    painter.setPen(Qt::NoPen);

    painter.setRenderHint(QPainter::Antialiasing);

    QPointF disp = Qt::Horizontal == slider->orientation()
        ? QPointF(SLIDER_MARGIN + slider->thumbOffset(), slider->height()/2)
        : QPointF(slider->width()/2, SLIDER_MARGIN + slider->thumbOffset());

    QRectF halo((slider->pos() - QPointF(_haloSize, _haloSize)/2) + disp,
                QSizeF(_haloSize, _haloSize));

    painter.drawEllipse(halo);

    // Knob

    brush.setColor(slider->value() > slider->minimum()
       ? (slider->isEnabled()
          ? _fillColor : Style::instance().themeColor("disabled"))
       : _minFillColor);
    painter.setBrush(brush);

    if (_borderWidth > 0) {
        QPen pen;
        pen.setColor(Style::instance().themeColor("accent3"));
        pen.setWidthF(_borderWidth);
        painter.setPen(pen);
    } else {
        painter.setPen(Qt::NoPen);
    }

    QRectF geometry = Qt::Horizontal == slider->orientation()
        ? QRectF(slider->thumbOffset(), slider->height()/2 - SLIDER_MARGIN,
                 SLIDER_MARGIN*2, SLIDER_MARGIN*2).translated(slider->pos())
        : QRectF(slider->width()/2 - SLIDER_MARGIN, slider->thumbOffset(),
                 SLIDER_MARGIN*2, SLIDER_MARGIN*2).translated(slider->pos());

    QRectF thumb(0, 0, _diameter, _diameter);

    thumb.moveCenter(geometry.center());

    painter.drawEllipse(thumb);

#ifdef DEBUG_LAYOUT
    QPen pen;
    pen.setColor(Qt::red);
    pen.setWidth(2);
    painter.setPen(pen);
    painter.setBrush(Qt::NoBrush);

    painter.drawRect(geometry);

    painter.drawRect(rect().adjusted(0, 0, -2, -2));
#endif

    QWidget::paintEvent(event);
}
Пример #19
0
void CDiagramItem::setPos(const QPointF &p)
{
	setGeometry( QRectF(p, size()) );
}
Пример #20
0
void tSidebarControlVolts::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    Assert(painter != 0 && option != 0);
    tSidebarControl::paint(painter, option, widget);

    tMercuryStyle* style = GetMercuryStyle();
    if( style == 0 || m_FontValue.isNull() || m_FontText.isNull() )
    {
        return;
    }

    QRect contentRect(option->rect);
    contentRect.adjust(5, 1, -5, -2);

    painter->setPen(style->GetColor(tMercuryStyle::eColorRoleIndicatorText));

    QSize iconSize(contentRect.width() / 3, contentRect.height() / 3);
    QSize textSize = GetTextSize(contentRect.size());

    const int topLine = contentRect.top() + contentRect.height() / 4;
    const int bottomLine = contentRect.bottom() - contentRect.height() / 4;
    const int centerX = contentRect.center().x();

    QSize iconImageSize(WidgetUtil::FitSize(m_BatteryIcon->defaultSize(), QSize(iconSize.width() * 2 / 3, iconSize.height())));
    m_BatteryIcon->render(painter,
        QRectF(centerX - iconSize.width() / 6 - iconImageSize.width() / 2, topLine - iconImageSize.height() / 2,
        iconImageSize.width(), iconImageSize.height())
        );
    painter->setFont(m_FontText->GetFont());
    painter->drawText(centerX + iconSize.width() / 6, topLine - iconSize.height() / 2, iconSize.width() / 3, iconSize.height(),
        Qt::AlignCenter, m_Unit);

    painter->setFont(m_FontValue->GetFont());
    if( m_Count == 4 )
    {
        painter->drawText(contentRect.left() + contentRect.width() / 6 - textSize.width() / 2, topLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value1);
        painter->drawText(contentRect.left() + contentRect.width() / 3 - textSize.width() / 2, bottomLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value2);
        painter->drawText(contentRect.right() - contentRect.width() / 3 - textSize.width() / 2, bottomLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value3);
        painter->drawText(contentRect.right() - contentRect.width() / 6 - textSize.width() / 2, topLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value4);
    }
    else if( m_Count == 3 )
    {
        painter->drawText(contentRect.left() + contentRect.width() / 6 - textSize.width() / 2, topLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value1);
        painter->drawText(centerX - textSize.width() / 2, bottomLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value2);
        painter->drawText(contentRect.right() - contentRect.width() / 6 - textSize.width() / 2, topLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value3);
    }
    else if( m_Count == 2 )
    {
        painter->drawText(contentRect.left() + contentRect.width() / 4 - textSize.width() / 2, bottomLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value1);
        painter->drawText(contentRect.right() - contentRect.width() / 4 - textSize.width() / 2, bottomLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value2);
    }
    else if( m_Count == 1 )
    {
        painter->drawText(centerX - textSize.width() / 2, bottomLine - textSize.height() / 2,
            textSize.width(), textSize.height(), Qt::AlignCenter, m_Value1);
    }
}
Пример #21
0
QRectF CDiagramItem::contentsRect() const
{
	return QRectF(-width() / 2.0, -height() / 2.0, width(), height());
}
Пример #22
0
QRectF ItemCircleAnimation::boundingRect() const
{
    return QRectF(0, 0, 300, 320);
}
QRectF MyPixmapItem::boundingRect() const{
    return QRectF(QPointF(0, 0), QSizeF(sizex, sizey));
}
Пример #24
0
void ItemCircleAnimation::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    QPointF newPosition = event->scenePos();
    this->setPosUsingSheepDog(this->pos() + newPosition - this->mouseMoveLastPosition, QRectF(-260, -280, 1350, 1160));
    this->mouseMoveLastPosition = newPosition;
}
Пример #25
0
QRectF TrhythmPane::boundingRect() const {
  return QRectF(0.0, 0.0, WIDTH * 2, 24.0);
}
Пример #26
0
static inline QRectF qwtBoundingRect( const QwtPoint3D &sample )
{
    return QRectF( sample.x(), sample.y(), 0.0, 0.0 );
}
Пример #27
0
void ChoiceView::paintEvent(QPaintEvent *event) {
    QFontMetrics metrics(font());
    QPainter painter(this);

    int y = arrowHeight + 2;
    const int baseline = metrics.leading() + metrics.ascent() + 1;
    const int w = width(), h = height() - (y * 2);
    const int yInc = h / 10;
    const int labelWidth = w - yInc - 10;
    const int hotkeyCenter = w - (yInc / 2);

    // Top arrow
    const int center = w / 2;
    painter.eraseRect(0, 0, w, y);
    if (_offset > 0) {
        painter.drawLine(center, 0, center - arrowHeight, arrowHeight);
        painter.drawLine(center, 0, center + arrowHeight, arrowHeight);
        painter.drawLine(center - arrowHeight, arrowHeight, center + arrowHeight, arrowHeight);
    }

    // Bottom arrow
    painter.eraseRect(0, height() - y, w, y);
    if (_offset + 10 < _choices.size()) {
        painter.drawLine(center, height() - 1, center - arrowHeight, height() - arrowHeight - 1);
        painter.drawLine(center, height() - 1, center + arrowHeight, height() - arrowHeight - 1);
        painter.drawLine(center - arrowHeight, height() - arrowHeight - 1,
                         center + arrowHeight, height() - arrowHeight - 1);
    }

    QLinearGradient fade(QPointF(0,0), QPointF(labelWidth, 0));
    fade.setColorAt(0, Qt::black);
    fade.setColorAt(0.95, Qt::black);
    fade.setColorAt(1.0, QColor(0xAA, 0xAA, 0xAA));

    QTextOption noWrap;
    noWrap.setWrapMode(QTextOption::NoWrap);

    // Choice area
    for (int row = 0; row < NUM_CHOICES; row++) {
        const int item = row + _offset;
        painter.eraseRect(0, y, w, yInc);
        if (item < _choices.size()) {
            const Choice &c = _choices[item];
            if (metrics.width(c.title()) > labelWidth) {
                painter.setPen(QPen(QBrush(fade), 1));
            } else {
                painter.setPen(QPen(Qt::black));
            }

            painter.drawText(QRectF(0, y, labelWidth, yInc), c.title(), noWrap);

            painter.save();
            if (row > 0) {
                painter.setPen(QColor(0xAA, 0xAA, 0xAA));
                painter.drawLine(50, y - 10, w - 50, y - 10);
            }

            painter.setPen(QColor(0x55, 0x55, 0x55));
            painter.drawRoundedRect(labelWidth + 10, y + metrics.leading(), yInc - 1, metrics.height(), 4, 4);
            painter.drawText(hotkeyCenter - (metrics.width(_hotkeys[row]) / 2), y + baseline,
                             QString(1, _hotkeys[row]));

            painter.restore();
        }
        y += yInc;
    }
}
Пример #28
0
static inline QRectF qwtBoundingRect( const QwtPointPolar &sample )
{
    return QRectF( sample.azimuth(), sample.radius(), 0.0, 0.0 );
}
Пример #29
0
void TableObjectView::configureDescriptor(ConstraintType constr_type)
{
	ObjectType obj_type=BASE_OBJECT;
	Column *column=dynamic_cast<Column *>(this->getSourceObject());
	float factor=font_config[ParsersAttributes::GLOBAL].font().pointSizeF()/DEFAULT_FONT_SIZE;
	bool ellipse_desc=false;

	//Based upon the source object type the descriptor is allocated
	if(this->getSourceObject())
		obj_type=this->getSourceObject()->getObjectType();

	/* Elliptical descriptor is used to columns (with or without not-null constraint),
		for other object types, polygonal descriptor is usded */
	ellipse_desc=((column && constr_type==BaseType::null) ||
								(obj_type!=OBJ_INDEX && obj_type!=OBJ_RULE &&
																									obj_type!=OBJ_TRIGGER && obj_type!=OBJ_COLUMN));

	if(descriptor && ((ellipse_desc && !dynamic_cast<QGraphicsEllipseItem *>(descriptor)) ||
										(!ellipse_desc && dynamic_cast<QGraphicsEllipseItem *>(descriptor))))
	{
		this->removeFromGroup(descriptor);
		delete(descriptor);
		descriptor=nullptr;
	}

	if(!descriptor)
	{
		if(ellipse_desc)
			descriptor=new QGraphicsEllipseItem;
		else
			descriptor=new QGraphicsPolygonItem;

		this->addToGroup(descriptor);
	}

	if(column)
	{
		QString attrib;
		QPolygonF pol;

		if(constr_type==BaseType::null)
		{
			QGraphicsEllipseItem *desc=dynamic_cast<QGraphicsEllipseItem *>(descriptor);

			desc->setRect(QRectF(QPointF(0,0),
													 QSizeF(9.0f * factor, 9.0f * factor)));

			if(column->isNotNull())
				attrib=ParsersAttributes::NN_COLUMN;
			else
				attrib=ParsersAttributes::COLUMN;

			desc->setBrush(this->getFillStyle(attrib));
			desc->setPen(this->getBorderStyle(attrib));
		}
		else
		{
			QGraphicsPolygonItem *desc=dynamic_cast<QGraphicsPolygonItem *>(descriptor);

			if(constr_type==ConstraintType::primary_key)
			{
				attrib=ParsersAttributes::PK_COLUMN;
				pol.append(QPointF(2,0)); pol.append(QPointF(0,2)); pol.append(QPointF(0,7));
				pol.append(QPointF(2,9)); pol.append(QPointF(3,8)); pol.append(QPointF(3,6));
				pol.append(QPointF(4,6)); pol.append(QPointF(5,7)); pol.append(QPointF(6,6));
				pol.append(QPointF(7,5)); pol.append(QPointF(9,7)); pol.append(QPointF(9,3));
				pol.append(QPointF(3,3)); pol.append(QPointF(3,1));
			}
			else if(constr_type==ConstraintType::foreign_key)
			{
				attrib=ParsersAttributes::FK_COLUMN;
				pol.append(QPointF(0,3)); pol.append(QPointF(0,6)); pol.append(QPointF(4,6));
				pol.append(QPointF(4,9)); pol.append(QPointF(5,9)); pol.append(QPointF(9,5));
				pol.append(QPointF(9,4)); pol.append(QPointF(5,0)); pol.append(QPointF(4,0));
				pol.append(QPointF(4,3));
			}
			else if(constr_type==ConstraintType::unique)
			{
				attrib=ParsersAttributes::UQ_COLUMN;
				pol.append(QPointF(4,0)); pol.append(QPointF(0,4)); pol.append(QPointF(0,5));
				pol.append(QPointF(4,9)); pol.append(QPointF(5,9)); pol.append(QPointF(9,5));
				pol.append(QPointF(9,4)); pol.append(QPointF(5,0));
			}

			if(factor!=1.0f)
				this->resizePolygon(pol,
														pol.boundingRect().width() * factor,
														pol.boundingRect().height()  * factor);

			desc->setPolygon(pol);
			desc->setBrush(this->getFillStyle(attrib));
			desc->setPen(this->getBorderStyle(attrib));
		}
	}
	else if(obj_type==OBJ_INDEX ||
					obj_type==OBJ_RULE ||
					obj_type==OBJ_TRIGGER)
	{
		TableObject *tab_obj=dynamic_cast<TableObject *>(this->getSourceObject());
		QGraphicsPolygonItem *desc=dynamic_cast<QGraphicsPolygonItem *>(descriptor);
		QPolygonF pol;

		pol.append(QPointF(5,0)); pol.append(QPointF(0,5)); pol.append(QPointF(4,9));
		pol.append(QPointF(9,9)); pol.append(QPointF(9,4));

		if(factor!=1.0f)
			this->resizePolygon(pol,
													pol.boundingRect().width() * factor ,
													pol.boundingRect().height() * factor);

		desc->setPolygon(pol);
		desc->setBrush(this->getFillStyle(tab_obj->getSchemaName()));
		desc->setPen(this->getBorderStyle(tab_obj->getSchemaName()));
	}
	else
	{
		QGraphicsEllipseItem *desc=dynamic_cast<QGraphicsEllipseItem *>(descriptor);

		desc->setRect(QRectF(QPointF(0,0),
												 QSizeF(9.0f * factor, 9.0f * factor)));
		desc->setBrush(this->getFillStyle(ParsersAttributes::REFERENCE));
		desc->setPen(this->getBorderStyle(ParsersAttributes::REFERENCE));
	}
}
Пример #30
0
QRectF TextButton::boundingRect() const
{
    return QRectF(0, 0, this->logicalSize.width(), this->logicalSize.height());
};