void GModelComponent::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
  QPen pen = m_pen;
  QBrush brush = m_brush;
  QPainterPath m_path = QPainterPath();

  QRectF bRect = m_textItem->boundingRect();
  bRect.setCoords(0, 0, bRect.width() + 2 * m_margin, bRect.height() + 2 * m_margin);
  m_path.addRoundedRect(bRect, m_cornerRadius, m_cornerRadius, Qt::SizeMode::AbsoluteSize);

  if (option->state & QStyle::State_Selected)
  {
    pen = s_selectedPen;
    brush = s_selectedBrush;
  }
  else if (m_isTrigger)
  {
    pen = s_triggerPen;
    brush = s_triggerBrush;
  }

  painter->setPen(pen);
  painter->setBrush(brush);
  painter->drawPath(m_path);

  if (option->state & QStyle::State_Selected)
  {
    GDefaultSelectionGraphic::paint(bRect, painter);
  }
}
Esempio n. 2
0
void ImageScene::mouseMoveEvent(QGraphicsSceneMouseEvent* in_mEvent) {
	if (m_pPixmap == NULL) {
		return;
	}
	qreal x = in_mEvent->scenePos().x(), y = in_mEvent->scenePos().y();
	if ( 	x < m_pPixmap->offset().x() ) {
		x = m_pPixmap->offset().x();
	} else if ( x - m_pPixmap->offset().x() >= m_pPixmap->pixmap().rect().width() ) {
		x = m_pPixmap->pixmap().rect().width() + m_pPixmap->offset().x() - 1;
	}
	if ( y < m_pPixmap->offset().y() ) {
		y = m_pPixmap->offset().y();
	} else if ( y - m_pPixmap->offset().y() >= m_pPixmap->pixmap().rect().height() ) {
		y = m_pPixmap->pixmap().rect().height() + m_pPixmap->offset().y() - 1;
	}
	if (m_pSelection != NULL) {
		QRectF rect;
		rect.setCoords ( m_SelectionPosition.x(),
				 m_SelectionPosition.y(),
				 x,y );
		m_pSelection->setRect ( rect.normalized());
	} else {
		m_pSelection = QGraphicsScene::addRect (x,y,0,0, m_SelectionPen, m_SelectionBrush);
		m_pSelection->setParentItem (m_pPixmap);
		m_SelectionPosition = m_pSelection->rect().topLeft();
	}

	if  ( 	m_pSelection->rect().width() < 1 ||
		m_pSelection->rect().height() < 1 )
	{
		m_pSelection->setVisible(false);
	} else {
		m_pSelection->setVisible(true);
	}
}
Esempio n. 3
0
QRectF
SeriesData::boundingRect() const
{
    QRectF rect;
    rect.setCoords( range_x_.first, range_y_.first, range_x_.second, range_y_.second );
    return rect;
}
Esempio n. 4
0
void BSplineVisDialog::on_copyPointsButton_clicked() {
    m_Algo = ((MainWindow*) parent())->GetImageParticlesAlgorithm();

    // select the current slice of the first image as reference image
    ImageContainer::Pointer img = m_Algo->GetImage(0);
    m_RefImage = img->GetSlice();

    // reset grid and checkerboard
    CreateGridAndCheckerboards(m_RefImage);

    // clear current landmarks
    m_VectorList.clear();

    const OptimizerParametersType& particles = m_Algo->GetCurrentParams();
    const int nPoints = m_Algo->GetNumberOfPoints();
    const int nParams = m_Algo->GetNumberOfParams();

    // copy landmarks from the first and second
    for (int i = 0; i < nPoints; i++) {
        QRectF rect;
        rect.setCoords(particles[SDim*i], particles[SDim*i+1], particles[nParams+SDim*i], particles[nParams+SDim*i+1]);
        m_VectorList.push_back(rect);
    }
    
    updateScene();
}
Esempio n. 5
0
void BSplineVisDialog::on_addPairButton_clicked() {
    QRectF rect;
    rect.setCoords(10, 10, 20, 20);
    m_VectorList.push_back(rect);

    updateScene();
}
Esempio n. 6
0
void DockScatterPlot::enlarge(QRectF& r,double dRatio)
{
    double dX=r.width();
    double dY=r.height();
    QPointF c=r.center();
    r.setCoords( c.x()-dX*dRatio/2., c.y()-dY*dRatio/2., c.x()+dX*dRatio/2., c.y()+dY*dRatio/2.);
}
Esempio n. 7
0
		virtual void zoom (QRectF const & rect)
		{
			QRectF newRect;
			QRectF const & baseRect = zoomBase();
			newRect.setCoords(rect.left(), baseRect.top(), rect.right(), baseRect.bottom());
			QwtPlotZoomer::zoom(newRect);
		}
QRectF PositionableJPanel::getBounds(QRectF r)
{
 if(r.isNull())
  return QRectF(getX(), getY(), /*getWidth()*/_itemGroup->boundingRect().width(), /*getHeight()*/_itemGroup->boundingRect().height());
    //return QRectF(getX(), getY(), _itemGroup->boundingRect().width(), _itemGroup->boundingRect().height());

 r.setCoords(getX(), getY(), getWidth(), getHeight());
 return r;
}
Esempio n. 9
0
/*! Find a minimal rectangle that encapsulates the polygon. The
    rectangle is returned in the QRectF object.
 */
QRectF Polygon2D::GetSurroundingRectangle() const
{
	QRectF rc;

   if(m_vecV.size()) {
		Point2D pt1, pt2;
		GetSurroundingRectangle(pt1, pt2);
		rc.setCoords(
			pt1.GetX(), pt2.GetY(),	// left, top 
			pt2.GetX(), pt1.GetY()  // right, bottom.
		);
   }

	return rc.normalized();
}
Esempio n. 10
0
void CustomMessageBox::paintEvent(QPaintEvent *)
{
    QPainter painter(this);

    QRectF imgRect;
    QRectF deviceRect;
    QImage img;
    if(_type == Trick)
    {
        imgRect.setCoords(0, 0, 646, 266);
        deviceRect.setCoords(0, 0, 646, 266);
        img.load(":/image/Background_Astuce.png");
    }
    else
    {
        imgRect.setCoords(0, 0, 434, 179);
        deviceRect.setCoords(0, 0, 434, 179);
        img.load(":/image/Message_box.png");
    }

    painter.drawImage(deviceRect, img, imgRect);

    painter.end();
}
Esempio n. 11
0
void OsmAndMapView::calculateTileRectangle(QRect& pixRect, float cx, float cy, float ctilex, float ctiley, QRectF& tileRect) const{

    float x1 = calcDiffTileX(pixRect.left() - cx, pixRect.top() - cy);
    float x2 = calcDiffTileX(pixRect.left() - cx, pixRect.bottom() - cy);
    float x3 = calcDiffTileX(pixRect.right() - cx, pixRect.top() - cy);
    float x4 = calcDiffTileX(pixRect.right() - cx, pixRect.bottom() - cy);
    float y1 = calcDiffTileY(pixRect.left() - cx, pixRect.top() - cy);
    float y2 = calcDiffTileY(pixRect.left() - cx, pixRect.bottom() - cy);
    float y3 = calcDiffTileY(pixRect.right() - cx, pixRect.top() - cy);
    float y4 = calcDiffTileY(pixRect.right() - cx, pixRect.bottom() - cy);
    float l = qMin(qMin(x1, x2), qMin(x3, x4)) + ctilex;
    float r = qMax(qMax(x1, x2), qMax(x3, x4)) + ctilex;
    float t = qMin(qMin(y1, y2), qMin(y3, y4)) + ctiley;
    float b = qMax(qMax(y1, y2), qMax(y3, y4)) + ctiley;
    tileRect.setCoords(l, t, r, b);
}
    void setCornerRects( const QPainterPath &path )
    {
        QPointF pos( 0.0, 0.0 );

        for ( int i = 0; i < path.elementCount(); i++ )
        {
            QPainterPath::Element el = path.elementAt(i); 
            switch( el.type )
            {
                case QPainterPath::MoveToElement:
                case QPainterPath::LineToElement:
                {
                    pos.setX( el.x );
                    pos.setY( el.y );
                    break;
                }
                case QPainterPath::CurveToElement:
                {
                    QRectF r( pos, QPointF( el.x, el.y ) );
                    clipRects += r.normalized();

                    pos.setX( el.x );
                    pos.setY( el.y );

                    break;
                }
                case QPainterPath::CurveToDataElement:
                {
                    if ( clipRects.size() > 0 )
                    {
                        QRectF r = clipRects.last();
                        r.setCoords( 
                            qMin( r.left(), el.x ),
                            qMin( r.top(), el.y ),
                            qMax( r.right(), el.x ),
                            qMax( r.bottom(), el.y )
                        );
                        clipRects.last() = r.normalized();
                    }
                    break;
                }
            }
        }
    }
Esempio n. 13
0
void KGVisualItemGroup::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{

    QPointF const mousePos = mapToScene(event->pos());
    QRectF rect;
    rect.setCoords(mousePos.x()-35, mousePos.y(), mousePos.x()+35, mousePos.y()+1);

    QList<KGVisualItem *> kgitems = filterByType<KGVisualItem*>(
                scene()->items(rect, Qt::IntersectsItemBoundingRect));
    if (!kgitems.isEmpty())
    {
        QList<KGVisualItem*> items;
        int insertIndex = 0;
        QPointF itemPos;
        bool visible = false;
        for (int i = 0; i < m_visualItemList.count(); i++)
        {
            if (kgitems.contains(m_visualItemList.at(i)))
            {
                items.append(m_visualItemList.at(i));
                insertIndex = i;
            }
        }

        if (items.size() == 2)
        {
            itemPos = items.first()->geometry().topRight();
            visible = true;
        } else if (items.size() == 1)
        {
            if (items.first()->geometry().left() > mousePos.x())
            {
                itemPos = items.first()->geometry().topLeft() - QPointF(p_visualInsertItem->size().width(),0);
                visible = true;
            }
        }
        p_visualInsertItem->setPos(itemPos);
        p_visualInsertItem->setVisible(visible);
        p_visualInsertItem->setInsertIndex(insertIndex);
    }
}
Esempio n. 14
0
void plotLinesToPainter(QPainter& painter,
			const Numpy1DObj& x1, const Numpy1DObj& y1,
			const Numpy1DObj& x2, const Numpy1DObj& y2,
			const QRectF* clip, bool autoexpand)
{
  const int maxsize = min(x1.dim, x2.dim, y1.dim, y2.dim);

  // if autoexpand, expand rectangle by line width
  QRectF clipcopy;
  if ( clip != 0 && autoexpand )
    {
      const qreal lw = painter.pen().widthF();
      qreal x1, y1, x2, y2;
      clip->getCoords(&x1, &y1, &x2, &y2);
      clipcopy.setCoords(x1, y1, x2, y2);
      clipcopy.adjust(-lw, -lw, lw, lw);
    }

  if( maxsize != 0 )
    {
      QVector<QLineF> lines;
      for(int i = 0; i < maxsize; ++i)
	{
	  QPointF pt1(x1(i), y1(i));
	  QPointF pt2(x2(i), y2(i));
	  if( clip != 0 )
	    {
	      if( clipLine(clipcopy, pt1, pt2) )
		lines << QLineF(pt1, pt2);
	    }
	  else
	    lines << QLineF(pt1, pt2);
	}

      painter.drawLines(lines);
    }
}
Esempio n. 15
0
QRectF QPScrollingCurve::coordinateBounds() const
{
    QRectF bounds;
    bounds.setCoords(0, yMax(), numPoints(), yMin());
    return bounds;
}