Exemplo n.º 1
0
PlayField::PlayField(qreal pxX, qreal pxY,
                     qreal pxWidth, qreal pxHeight,
                     int x, int y,
                     QGraphicsItem* parent)
    : QGraphicsRectItem(0, 0, pxWidth, pxHeight, parent),
      state_(WATER),
      x(x), y(y)
{
    setPos(pxX, pxY);
    setPen(QPen(Qt::NoPen));
    updateColor();
}
Exemplo n.º 2
0
/**
 * Constructor.
 */
SeqLineWidget::SeqLineWidget(UMLView * pView, ObjectWidget * pObject)
  : UMLSceneLine( pView -> canvas() )
{
    m_scene = pView;
    m_pObject = pObject;
    setPen( QPen( m_pObject->lineColor(), 0, Qt::DashLine ) );
    setZ( 0 );
    setVisible( true );
    m_DestructionBox.line1 = 0;
    m_nLengthY = 250;
    setupDestructionBox();
}
void FieldPainter::drawBallPosAbs(const AbsCoord &ball, QColor colour)
{
   save();
   QPoint newBall = QPoint(ball.x(), ball.y());
   QPen absPen(colour);
   setPen(absPen);
   setBrush(QBrush(colour));
   drawEllipse(newBall, 40, 40);
   restore();

   drawAbsCovEllipse(ball, absPen);
}
Exemplo n.º 4
0
void QgsComposerItem::setFrameOutlineWidth( double outlineWidth )
{
  QPen itemPen = pen();
  if ( itemPen.widthF() == outlineWidth )
  {
    //no change
    return;
  }
  itemPen.setWidthF( outlineWidth );
  setPen( itemPen );
  emit frameChanged();
}
Exemplo n.º 5
0
ConnectorItem::ConnectorItem(OperatorModel* op, unsigned int id, ConnectorType type, QGraphicsItem* parent)
  : QGraphicsRectItem(parent),
    m_op(op),
    m_id(id),
    m_connectorType(type),
    m_currentArrow(0)
{
    setRect(-SIZE/2, -SIZE/2, SIZE, SIZE);
    setAcceptHoverEvents(true);
    setBrush(Qt::black);
    setPen(Qt::NoPen);
}
Exemplo n.º 6
0
void LinkItem::trackNodes()
{
	setPen(QPen(Qt::white, 1.0));
	//log->print(QString("sourcePoint (x, y) = (%1, %2)").arg(source->getCurrentPoint().x()).arg(source->getCurrentPoint().y()));
	//log->print(QString("destPoint (x, y) = (%1, %2)").arg(dest->getCurrentPoint().x()).arg(dest->getCurrentPoint().y()));

	setLine(QLineF(source->getCurrentPoint(), dest->getCurrentPoint()));

	//setLine(QLineF(source->pos(), dest->pos()));

	//log->print(QString("AirPlaneItem pos : (x, y) = (%1, %2)").arg(fromNode->pos().x()).arg(fromNode->pos().y()));
}
void FieldPainter::drawPlayerNumber (const AbsCoord &pos, int num) {
   save();
   translate(pos.x() - 50, pos.y() - 400);
   scale(1,-1);
   setPen("white");
   setBrush(QColor("white"));
   QFont font;
   font.setPixelSize(200);
   setFont(font);
   drawText(0, 0, QString::number(num));
   restore();
}
void FieldPainter::drawGoalArea(const PostInfo::Type &goalArea){
   
   save ();
   if(goalArea & PostInfo::pAway){
      setPen("white");
      setBrush(QColor("red"));
      translate(3000, 705);
      drawEllipse (QPoint(0, 0), 5, 140);
      translate(3000, -705);
      drawEllipse (QPoint(0, 0), 5, 140);

   } else if (goalArea & PostInfo::pHome){
      setPen("white");
      setBrush(QColor("blue"));
      translate(-3000, 705);
      drawEllipse (QPoint(0, 0), 5, 140);
      translate(-3000, -705);
      drawEllipse (QPoint(0, 0), 5, 140);
   }   
   restore ();
}
Exemplo n.º 9
0
bool GiGraphics::rawEllipse(const GiContext* ctx, float x, float y, float w, float h)
{
    bool usePen = setPen(ctx);
    bool useBrush = setBrush(ctx);
    
    if (m_impl->canvas && !m_impl->stopping
        && !isnan(x) && !isnan(y) && !isnan(w) && !isnan(h)) {
        m_impl->canvas->drawEllipse(x, y, w, h, usePen, useBrush);
        return true;
    }
    return false;
}
Exemplo n.º 10
0
CellRectItem::CellRectItem(int row, int column, CellView view)
    : QGraphicsRectItem({basePoint(row, column), cellQSizeF})
    , row_(row)
    , column_(column)
{
    setZValue(cellBackgroundZValue);
    if (view == CellView::None || view == CellView::Flag ||
        view == CellView::Doubt) {
        setPen(
            {Qt::darkCyan, 1.5, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin});
        setBrush(cellBrush);
    }
    else {
        setPen({Qt::NoPen});
        setBrush({});
    }
    if (view != CellView::None) {
        auto text = getTextItem(view, {row, column});
        text->setParentItem(this);
    }
}
Exemplo n.º 11
0
  GradientButton(GamePanel *parent, const QRect &rect, const QString &text) :
      GameButton(parent, rect, text)
  {
    setBackground(Qt::NoBrush);
    setPen(QPen(QColor(Qt::white), 2));
    setHoverBackground(QColor(0x2076b1));

    setTextColor(Qt::white);
    setTextHoverColor(Qt::white);

    setFont(&gameStock->Font20);
  }
void GraphicsSelectionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
{
	qDebug(__PRETTY_FUNCTION__);

	if (m_readOnly)
	{
		setPen(QPen(Qt::white));
		QGraphicsRectItem::paint(painter, option, w);
		return;
	}

	setPen(QPen(Qt::yellow));
	QGraphicsRectItem::paint(painter, option, w);

	QRectF rect = QGraphicsRectItem::rect();
	int bottom = rect.bottom();
	int right = rect.right();
    painter->drawLine(right - 9, bottom, right, bottom - 9);
    painter->drawLine(right - 6, bottom, right, bottom - 6);
    painter->drawLine(right - 3, bottom, right, bottom - 3);
}
void FieldPainter::drawFeatureAbs (const AbsCoord &pos, const FieldFeatureInfo::Type &type) {
   save();
   translate(pos.x(), pos.y());
   rotate(RAD2DEG(pos.theta()));
   setPen(Qt::NoPen);
   setBrush(QBrush("red"));
   QPen p;
   switch (type) {
      case FieldFeatureInfo::fCorner:
         save();
         rotate(RAD2DEG(M_PI_4));
         drawRect(-25, -25, 300, 50);
         restore();
         save();
         rotate(RAD2DEG(-M_PI_4));
         drawRect(-25, -25, 300, 50);
         restore();
         break;
      case FieldFeatureInfo::fTJunction:
         drawRect(-25, -300, 50, 600);
         drawRect(0, -25, 300, 50);
      case FieldFeatureInfo::fPenaltySpot:
         break;
      case FieldFeatureInfo::fCentreCircle:
         save();
         setPen("red");
         p = pen();
         p.setWidth(50);
         setPen(p);
         setBrush(Qt::NoBrush);
         drawEllipse (QPoint(0, 0), 600, 600);
         restore();
         break;
      case FieldFeatureInfo::fLine:
         break;
      default:
         break;
   }
   restore();
}
Exemplo n.º 14
0
void Board::paintPoint(Point point, int index) {
    QRectF rect = Locator<Grid>()->getGridRect(point);
    qreal margin = Locator<Grid>()->getGridSize() * (1 - common::predefinedSize::CircleSizeOverGridSize);
    auto margins = QMarginsF(margin, margin, margin, margin);
    QRectF rectShrinked = rect.marginsRemoved(margins);
    auto circle = new QGraphicsEllipseItem(rectShrinked);
    auto itemID = common::VisibleItemID::Circle;
    QColor color = common::getColor(itemID, index);
    circle->setZValue(itemID);
    circle->setPen(Qt::NoPen);
    circle->setBrush(QBrush(color));
    itemList->addItem(circle);
}
void Celda::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
    QPair<int,int> posicion(pos.y()/65,pos.x()/65);
    set<QPair<int,int> > movPosibles = juego->getMovimientosPosibles(juego->getTurno());   
    if (movPosibles.find(posicion) != movPosibles.end())
    {
        p = pen();
        QPen newPen(Qt::SolidLine);
        newPen.setWidth(3);
        setPen(newPen);
        entroHover = 1;
    }
}
	void KviCanvasRectangle::setProperty(const QString &property,const QVariant &val)
	{
		if(m_properties[property].isValid())
		{
			m_properties.replace(property,val);
			if((property == "clrForeground") || (property == "uLineWidth"))
			{
				setPen(QPen(m_properties["clrForeground"].asColor(),m_properties["uLineWidth"].toInt()));
			} else {
				hide(); show();
			}
		}
	}
Exemplo n.º 17
0
Pin::Pin(QGraphicsItem* parent) :
    QGraphicsEllipseItem(0, 0, 13, 13, parent),
    mColor(Pin::Color::NONE),
    mEnabled(false)
{
    QLinearGradient lgrad(0, 0, 0, 13);
    lgrad.setColorAt(0.0, QColor(50, 50, 50));
    lgrad.setColorAt(1.0, QColor(220, 220, 220));
    setPen(QPen(QBrush(lgrad), 1));

    setAcceptedMouseButtons(Qt::NoButton);
    setCursor(Qt::ArrowCursor);
}
Exemplo n.º 18
0
void specCanvasItem::setPenStyle(const qint8& s)
{
	//	if (s < 0)
	//	{
	//		setStyle(QwtPlotCurve::NoCurve) ;
	//		return ;
	//	}
	//	else
	//		setStyle(QwtPlotCurve::Lines) ;
	QPen newPen(pen()) ;
	newPen.setStyle((Qt::PenStyle) s) ;
	setPen(newPen) ;
}
Exemplo n.º 19
0
void QgsComposerItem::refreshFrameColor( const bool updateItem, const QgsExpressionContext &context )
{
  //data defined stroke color set?
  bool ok = false;
  QColor frameColor = mDataDefinedProperties.valueAsColor( QgsComposerObject::FrameColor, context, mFrameColor, &ok );
  if ( ok )
  {
    QPen itemPen = pen();
    itemPen.setColor( frameColor );
    setPen( itemPen );
  }
  else
  {
    QPen itemPen = pen();
    itemPen.setColor( mFrameColor );
    setPen( itemPen );
  }
  if ( updateItem )
  {
    update();
  }
}
Exemplo n.º 20
0
void QgsComposerItem::setFrameStrokeWidth( const double strokeWidth )
{
  if ( qgsDoubleNear( mFrameWidth, strokeWidth ) )
  {
    //no change
    return;
  }
  mFrameWidth = strokeWidth;
  QPen itemPen = pen();
  itemPen.setWidthF( mFrameWidth );
  setPen( itemPen );
  emit frameChanged();
}
Exemplo n.º 21
0
MultipleConnectionItem::MultipleConnectionItem(MultipleInputItem* _to, MultipleOutputItem* _from):
	QGraphicsPathItem	(0),
	m_isValid			(true),
	m_from				(_from),
	m_to				(_to)
{
	_to->scene()->addItem(this);
	setPen(QPen(m_isValid ? Qt::black : Qt::red, 8));
	rejigEndPoints();
	setFlags(ItemIsFocusable | ItemIsSelectable);
	setCursor(Qt::ArrowCursor);
	setZValue(-1);
}
Exemplo n.º 22
0
PointPort::PointPort(qreal x, qreal y, Item *parent) : Item(parent), mPointImpl(), mType("NonTyped")
{
	mNeedScalingRect = true;
	mRadius = 2;
	setX1(x - mRadius * 1.6);
	setY1(y - mRadius * 1.6);
	setX2(x + mRadius * 1.6);
	setY2(y + mRadius * 1.6);
	mUnrealRadius = mRadius * 1.6;
	setPen(QPen(Qt::blue));
	setBrush(QBrush(Qt::blue, Qt::SolidPattern));
	mDomElementType = portType;
}
Exemplo n.º 23
0
void UseCaseItem::initializeItemMembers()
{
    if(mItemType == "I_ACTOR")
    {
        mItemRectF = QRectF(0, 0, 50, 75);
        setPen(Qt::NoPen);

        if(mItemName.isEmpty())
            mItemName = "Actor";
    }
    else if(mItemType == "I_USECASE")
    {
        setPen(Qt::NoPen);

        if(mItemName.isEmpty())
            mItemName = "Use case";
    }

    setPolygon(QPolygonF(mItemRectF));
    mTextNameItem = new QGraphicsTextItem(mItemName, this);
    paintItemMembers();
}
Exemplo n.º 24
0
Road::Road(const Model::StreetPtr& street,
           const double* normalization,
           QGraphicsItem* parent)
  : QGraphicsLineItem(parent)
{
  //TODO find better solution for converting etc
  double x[2] = { (street->first->lon.get()  - normalization[0]) * 111322.22222222222, //TODO avoid
                  (street->second->lon.get() - normalization[0]) * 111322.22222222222 }; //TODO avoid
  double y[2] = { (street->first->lat.get()  - normalization[1]) * 111132.94444444445, //TODO avoid
                  (street->second->lat.get() - normalization[1]) * 111132.94444444445 }; //TODO avoid
  setLine(x[0], y[0], x[1], y[1]);
  setPen(QPen(Qt::gray));
}
Exemplo n.º 25
0
void PaintMethods::paintPolygon(const DebugDrawing::Polygon& element, QPainter& painter)
{
  setBrush(element.fillStyle, element.fillColor, painter);
  setPen(element, painter);

  // copy vector2 to QPoints
  const int* points = (const int*)(&element + 1);
  std::vector<QPoint> qpoints;
  for(int n = element.nCount - 1; n >= 0; --n)
    qpoints.push_back(QPoint(points[2 * n], points[2 * n + 1]));

  painter.drawPolygon(qpoints.data(), element.nCount);
}
Exemplo n.º 26
0
bool GiGraphics::rawLines(const GiContext* ctx, const Point2d* pxs, int count)
{
    if (m_impl->canvas && setPen(ctx) && pxs && count > 0) {
        m_impl->canvas->beginPath();
        m_impl->canvas->moveTo(pxs[0].x, pxs[0].y);
        for (int i = 1; i < count && !m_impl->stopping; i++) {
            m_impl->canvas->lineTo(pxs[i].x, pxs[i].y);
        }
        m_impl->canvas->drawPath(true, false);
        return true;
    }
    return false;
}
Exemplo n.º 27
0
QtGrid::QtGrid( QCanvas *canvas, int _grid_type ) : QCanvasPolygonalItem( canvas )
{
    grid_color = QColor( 210, 210, 210 );
    ntsc_color = QColor( 255, 0, 0 );
    subgrid_color = QColor( 235, 235, 235 );
    diagonal_color = QColor( 200, 200, 200 );
    grid_type = _grid_type;
    see_ntsc = false;
    _width = 600;
    _height = 440;
    
    setPen( QPen( grid_color, 1 ) );
}
Exemplo n.º 28
0
QwtPieCurve::QwtPieCurve(Table *t, const QString &name, int startRow,
                         int endRow)
    : DataCurve(t, QString(), name, startRow, endRow), d_pie_ray(50),
      d_first_color(0), d_start_azimuth(270), d_view_angle(33), d_thickness(33),
      d_horizontal_offset(0), d_edge_dist(25), d_counter_clockwise(false),
      d_auto_labeling(true), d_values(false), d_percentages(true),
      d_categories(false), d_fixed_labels_pos(true) {
  setPen(QPen(QColor(Qt::black), 1, Qt::SolidLine));
  setBrush(QBrush(Qt::SolidPattern));
  setStyle(QwtPlotCurve::UserCurve);
  setType(Graph::Pie);
  d_table_rows = QVarLengthArray<int>(0);
}
Exemplo n.º 29
0
ezQtPin::ezQtPin()
{
  auto palette = QApplication::palette();

  QPen pen(palette.light().color(), 3, Qt::SolidLine);
  setPen(pen);
  setBrush(palette.base());

  setFlag(QGraphicsItem::ItemSendsGeometryChanges);
  setFlag(QGraphicsItem::ItemSendsScenePositionChanges);

  m_pLabel = new QGraphicsTextItem(this);
}
FittingCurve::FittingCurve (const FittingCurveCoefficients &fittingCoef,
                            double xMin,
                            double xMax,
                            bool isLogXTheta,
                            bool isLogYRadius,
                            const Transformation &transformation)
{
  const int NUM_POINTS = 1000; // Use so many points that spline interpolation is not needed for smoothness
  const double Z_LINE = 500; // More than the z value for lines since this line takes priority, and user can hide it

  setZValue (Z_LINE);
  setPen (QPen (QColor (Qt::red)));

  QPainterPath path;

  if (transformation.transformIsDefined()) {

    for (int i = 0; i < NUM_POINTS; i++) {

      // Compute (x,y) point in graph coordinates
      double s = (double) i / (double) (NUM_POINTS - 1);
      double x = xMin + s * (xMax - xMin);
      double y = yFromCoefficientsAndX (fittingCoef,
                                        x);

      // The coefficients were computed assuming the x and y values were transformed if they were log scale base 10, so
      // we must compensate here in the same way
      if (isLogXTheta) {
        x = qPow (10.0, x);
      }
      if (isLogYRadius) {
        y = qPow (10.0, y);
      }

      // Convert to screen coordinates
      QPointF posGraph (x, y);
      QPointF posScreen;
      transformation.transformRawGraphToScreen (posGraph,
                                                posScreen);

      // Add point to line
      if (i == 0) {
        path.moveTo (posScreen);
      } else {
        path.lineTo (posScreen);
      }
    }
  }

  setPath (path);
}