コード例 #1
0
void WGraphicsPolygonItem::onContextMenu(Ws::ContextMenuFlag flag)
{
	if (flag == Ws::AddVertex)
	{
		int id = high_word(_select_flag);
		WWorldPolygonF p = data()->polygon;
		p.insert(p.begin()+id+1, _cp[id]);
		setPolygon(p, true, true);
	}
	else if (flag == Ws::DeleteVertex)
	{
		int id = high_word(_select_flag);
		WWorldPolygonF p = data()->polygon;
		p.erase(p.begin() + id);
		if (id == 0)
		{
			p.back() = p.front();
		}
		setPolygon(p, true, true);
	}
	else if (flag == Ws::Copy)
	{
		scene()->setClipboard(this);
	}
}
コード例 #2
0
ファイル: port.cpp プロジェクト: kreuzberger/FSM-Editor
Port::Port(int iInNumber,  FSMElementIfc* poInElementParent )
: FSMElementBase( poInElementParent )
, QGraphicsPolygonItem(poInElementParent ? poInElementParent->getGraphicsItem() : 0 )
, moPolygon()
, miNumber( iInNumber )
{
    // create signal slot connections
    if ( poInElementParent )
    {
      // observer change of id of parent element (node)
      connect(
          poInElementParent->getSignalSlotBase(), SIGNAL( sigChangedId( const FSMElementIfc& ))
          , this, SLOT( slotUpdateId( const FSMElementIfc& ) ) );
    }

    setBrush( QBrush( QColor( Qt::black), Qt::NoBrush ) );
    setPen( QPen( QColor( Qt::black), 2 ) );

    moPolygon << QPointF(0, 0) << QPointF(5, 0)
              << QPointF(5, 5)   << QPointF(0, 5)
              << QPointF(0, 0);

    setPolygon( moPolygon);

    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    // recalculate id
    updateId();

    FSMElementManager::getInstance().addElement( this );
}
コード例 #3
0
void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;

	QPolygonF p;
	p.append(QPointF(hAxis->posAtValue(0), vAxis->posAtValue(0)));
	plot_data *entry = dataModel->data().entry;
	for (int i = 0, count = dataModel->rowCount(); i < count; i++, entry++) {
		if (entry->in_deco && entry->stopdepth) {
			p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(qMin(entry->stopdepth, entry->depth))));
		} else {
			p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0)));
		}
	}
	setPolygon(p);
	QLinearGradient pat(0, p.boundingRect().top(), 0, p.boundingRect().bottom());
	// does the user want the ceiling in "surface color" or in red?
	if (prefs.redceiling) {
		pat.setColorAt(0, getColor(CEILING_SHALLOW));
		pat.setColorAt(1, getColor(CEILING_DEEP));
	} else {
		pat.setColorAt(0, getColor(BACKGROUND_TRANS));
		pat.setColorAt(1, getColor(BACKGROUND_TRANS));
	}
	setPen(QPen(QBrush(Qt::NoBrush), 0));
	setBrush(pat);
}
コード例 #4
0
ファイル: mypolygon.cpp プロジェクト: lbaudouin/SewingPattern
void MyPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
    //painter->save();
    Q_UNUSED(option);
    QColor color = color_;
    if(isSelected())
        color.setAlpha(125);
    else
        color.setAlpha(50);
    painter->setPen(Qt::NoPen);
    painter->setBrush(color);

    QPolygonF poly = getPoly();
    setPolygon(poly);

    painter->drawPolygon(poly,Qt::WindingFill);

    painter->setPen(Qt::black);
    //qDebug() << pattern_->getName();
    //QRect rect(0,0,200,50);
    //painter->drawText(rect, Qt::AlignCenter, pattern_->getName());
    painter->drawText(poly.boundingRect(), Qt::AlignCenter, pattern_->getName());
    //painter->drawText(QRect(pattern_->getPolygon().at(0).toPoint(),QSize(200,50)), Qt::AlignCenter, pattern_->getName());
    //painter->restore();
}
コード例 #5
0
ファイル: tileoutline.cpp プロジェクト: Oyinda8/Hive-AI
TileOutline::TileOutline(Qt::GlobalColor color, copair xy, QGraphicsItem *parent):QGraphicsPolygonItem(parent)
{
    QPen pen(color,2);
    setPen(pen);

    if((xy.first+xy.second)%2)
        throw(1);

    //set points for hexagon
    QVector<QPointF> points;
    points << QPointF(-1.0/(qSqrt(3)),-1) << QPointF(1.0/(qSqrt(3)),-1) << QPointF(2.0/(qSqrt(3)),0)
           << QPointF(1.0/(qSqrt(3)),1) << QPointF(-1.0/(qSqrt(3)),1) << QPointF(-2.0/(qSqrt(3)),0);

    //scale hexagon
    for(size_t i = 0,n = points.size();i<n;i++)
    {
        points[i]*=HEX_SCALE;
    }

    setPolygon(QPolygonF(points));

    int xb=xy.first,yb=xy.second;//board coordinates
    float xs,ys; //screen coordinates

    xs = HEX_SCALE*qSqrt(3)*xb+xc;
    ys = HEX_SCALE*(-yb)+yc;

    //qDebug()<<"tile created at "<<xs<<","<<ys;

    setPos(xs,ys);
}
コード例 #6
0
void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	// We don't have enougth data to calculate things, quit.
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;
	int last_index = -1;
	QPolygonF boundingPoly; // This is the "Whole Item", but a pressure can be divided in N Polygons.
	polygons.clear();

	for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
		plot_data *entry = dataModel->data().entry + i;
		int mbar = GET_PRESSURE(entry);

		if (entry->cylinderindex != last_index) {
			polygons.append(QPolygonF()); // this is the polygon that will be actually drawned on screen.
			last_index = entry->cylinderindex;
		}
		if (!mbar) {
			continue;
		}

		QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(mbar));
		boundingPoly.push_back(point);    // The BoundingRect
		polygons.last().push_back(point); // The polygon thta will be plotted.
	}
	setPolygon(boundingPoly);
	qDeleteAll(texts);
	texts.clear();
	int mbar, cyl;
	int seen_cyl[MAX_CYLINDERS] = { false, };
	int last_pressure[MAX_CYLINDERS] = { 0, };
	int last_time[MAX_CYLINDERS] = { 0, };
	struct plot_data *entry;

	cyl = -1;
	for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
		entry = dataModel->data().entry + i;
		mbar = GET_PRESSURE(entry);

		if (!mbar)
			continue;
		if (cyl != entry->cylinderindex) {
			cyl = entry->cylinderindex;
			if (!seen_cyl[cyl]) {
				plotPressureValue(mbar, entry->sec, Qt::AlignRight | Qt::AlignTop);
				plotGasValue(mbar, entry->sec, Qt::AlignRight | Qt::AlignBottom,
					       displayed_dive.cylinder[cyl].gasmix);
				seen_cyl[cyl] = true;
			}
		}
		last_pressure[cyl] = mbar;
		last_time[cyl] = entry->sec;
	}

	for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
		if (last_time[cyl]) {
			plotPressureValue(last_pressure[cyl], last_time[cyl], Qt::AlignLeft | Qt::AlignTop);
		}
	}
}
コード例 #7
0
void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
{
    QGraphicsItem *prevItem = m_currentItem;
    m_currentItem = item;

    if (!m_currentItem)
        return;

    QRect viewRect = m_inspector->declarativeView()->rect();
    viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect();

    QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
    itemRect = item->mapRectToScene(itemRect);

    // if updating the same item as before, resize the rectangle only bigger, not smaller.
    if (prevItem == item && prevItem != 0) {
        m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect);
    } else {
        m_itemPolyRect = itemRect;
    }
    QRectF borderRect = m_itemPolyRect;
    borderRect.adjust(-1, -1, 1, 1);
    m_borderRect->setRect(borderRect);

    const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect());
    setPolygon(regionToPolygon(externalRegion));
}
コード例 #8
0
void DiagramDrawItem::setDimension(QPointF newPos)
{
	prepareGeometryChange();
	myPos2=newPos;
	myPolygon=createPath();
	setPolygon(myPolygon);
}
コード例 #9
0
void DiagramDrawItem::setPos2(QPointF newPos)
{
	prepareGeometryChange();
	myPos2=mapFromScene(newPos);
	myPolygon=createPath();
	setPolygon(myPolygon);
}
コード例 #10
0
void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	// We don't have enougth data to calculate things, quit.
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;
	AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight);
	// Add 2 points to close the polygon.
	QPolygonF poly = polygon();
	if (poly.isEmpty())
		return;
	QPointF p1 = poly.first();
	QPointF p2 = poly.last();

	poly.prepend(QPointF(p1.x(), vAxis->posAtValue(0)));
	poly.append(QPointF(p2.x(), vAxis->posAtValue(0)));
	setPolygon(poly);

	QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
	pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
	pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
	setPen(QPen(QBrush(Qt::NoBrush), 0));
	setBrush(pat);

	gradientFactor->setX(poly.boundingRect().width() / 2 + poly.boundingRect().x());
	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
	if (plannerModel->isPlanner()) {
		struct diveplan &diveplan = plannerModel->getDiveplan();
		gradientFactor->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
	} else {
		gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
	}
}
コード例 #11
0
ファイル: SMDItem.cpp プロジェクト: constrictor/Layoutie
void SMDItem::createItem(QGraphicsItemGroup* inOutItem, bool inIsMainNotGround)
{
    auto main = new QGraphicsPolygonItem;
    QPolygonF poly;
    for (auto point : mComponent->rect().points)
    {
        poly << QPointF(point.x, - point.y);
    }
    poly << poly.first();
    main->setPolygon(poly);

    QColor color = inIsMainNotGround ?
        gSettings().layerColor(mComponent->layer())
        : gSettings().backgroundColor();
    QBrush br(color);
    main->setBrush(br);
    QPen p(color);
    if (!inIsMainNotGround)
    {
        p.setColor(color);
        p.setWidthF(mComponent->groundPlaneDistance() * 2);
        p.setJoinStyle(Qt::MiterJoin);
    }
    main->setPen(p);
    inOutItem->addToGroup(main);
}
コード例 #12
0
void PartialPressureGasItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
	//AbstractProfilePolygonItem::modelDataChanged();
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;

	plot_data *entry = dataModel->data().entry;
	QPolygonF poly;
	alertPoly.clear();
	QSettings s;
	s.beginGroup("TecDetails");
	double threshould = s.value(threshouldKey).toDouble();
	for(int i = 0;  i < dataModel->rowCount(); i++, entry++){
		double value = dataModel->index(i, vDataColumn).data().toDouble();
		int time = dataModel->index(i, hDataColumn).data().toInt();
		QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
		poly.push_back( point );
		if (value >= threshould)
			alertPoly.push_back(point);
	}
	setPolygon(poly);
	/*
	createPPLegend(trUtf8("pN" UTF8_SUBSCRIPT_2),getColor(PN2), legendPos);
	*/
}
コード例 #13
0
ファイル: Hex.cpp プロジェクト: Fader1997/QtGameTutorial
Hex::Hex(QGraphicsItem *parent){
    // draw the polygon

    // points needed to draw hexagon: (1,0), (2,0), (3,1), (2,2), (1,2), (0,1)
    QVector<QPointF> hexPoints;
    hexPoints << QPointF(1,0) << QPointF(2,0) << QPointF(3,1) << QPointF(2,2)
              << QPointF(1,2) << QPointF(0,1);

    // scale the points
    int SCALE_BY = 40;
    for (size_t i = 0, n = hexPoints.size(); i < n; ++i){
        hexPoints[i] = hexPoints[i] * SCALE_BY;
    }

    // create a polygon with the scaled points
    QPolygonF hexagon(hexPoints);

    // draw the poly
    setPolygon(hexagon);

    // initialize
    isPlaced = false;

    // initialize side attacks to 0
    side0Attack = 0;
    side1Attack = 0;
    side2Attack = 0;
    side3Attack = 0;
    side4Attack = 0;
    side5Attack = 0;

    // create QGraphicsTextItems to represent visually each side's attack
    QGraphicsTextItem* text0 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text1 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text2 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text3 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text4 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text5 = new QGraphicsTextItem(QString::number(0),this);

    attackTexts.append(text0);
    attackTexts.append(text1);
    attackTexts.append(text2);
    attackTexts.append(text3);
    attackTexts.append(text4);
    attackTexts.append(text5);

    // set the correct position of the attack texts
    text0->setPos(50,0);
    text1->setPos(20,15);
    text2->setPos(20,40);
    text3->setPos(50,55);
    text4->setPos(80,40);
    text5->setPos(80,15);

    // make all attack texts invisible
    for (size_t i = 0, n = attackTexts.size(); i < n; i++){
        attackTexts[i]->setVisible(false);
    }
}
コード例 #14
0
ファイル: hexagonitem.cpp プロジェクト: pqpqpqpqpq/Graph
/*!
	\brief Create the hexagon by setting a QPolygonF
*/
void HexagonItem::createHexagon()
{
	QPolygonF hexagonPolygon;
	hexagonPolygon << QPointF(-HEXAGON_EDGE_ITEM, 0.0) << QPointF(-HEXAGON_EDGE_ITEM/2, HEXAGON_EDGE_ITEM/2*sqrt(3.0))
					<< QPointF(HEXAGON_EDGE_ITEM/2, HEXAGON_EDGE_ITEM/2*sqrt(3.0)) << QPointF(HEXAGON_EDGE_ITEM, 0.0)
					<< QPointF(HEXAGON_EDGE_ITEM/2, -HEXAGON_EDGE_ITEM/2*sqrt(3.0)) << QPointF(-HEXAGON_EDGE_ITEM/2, -HEXAGON_EDGE_ITEM/2*sqrt(3.0));
	setPolygon(hexagonPolygon);
}
コード例 #15
0
ファイル: hexagonitem.cpp プロジェクト: pqpqpqpqpq/Graph
HexagonItem::HexagonItem(const QPolygonF &polygon, QGraphicsItem *parent)
	: QGraphicsPolygonItem(parent),
	  edgeWidth(1)
{
	setPolygon(polygon);
	createHexagon();
	setZValue(3);
}
コード例 #16
0
ファイル: Terrain.cpp プロジェクト: D-Pointer/imperium-editor
Terrain::Terrain (const QPolygonF & polygon, QGraphicsItem *parent) : QGraphicsPolygonItem(parent)/*, m_polygon(polygon)*/ {
    setPolygon( polygon );
    setType( kWoods );
    setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges );

    foreach ( const QPointF & pos, polygon ) {
        createDot( pos );
    }
コード例 #17
0
void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation)
{
    QPolygonF polygon;
    polygon << QPointF(x, y) << QPoint(x, y + h) << QPoint(x+w, y + h);
    setPolygon(polygon);

    setOrientation(orientation);
}
コード例 #18
0
void AbstractProfilePolygonItem::modelDataRemoved(const QModelIndex &parent, int from, int to)
{
	Q_UNUSED(from);
	Q_UNUSED(parent);
	Q_UNUSED(to);
	setPolygon(QPolygonF());
	qDeleteAll(texts);
	texts.clear();
}
コード例 #19
0
void UBGraphicsTriangle::setOrientation(UBGraphicsTriangleOrientation orientation)
{
    mOrientation = orientation;
    calculatePoints(boundingRect());

    QPolygonF polygon;
    polygon << A1 << B1 << C1;
    setPolygon(polygon);
}
コード例 #20
0
void DiveProfileItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
	if(!shouldCalculateStuff(topLeft, bottomRight))
		return;

	AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight);
	if (polygon().isEmpty())
		return;

	show_reported_ceiling = prefs.profile_dc_ceiling;
	reported_ceiling_in_red = prefs.profile_red_ceiling;

	/* Show any ceiling we may have encountered */
	if (prefs.profile_dc_ceiling && !prefs.profile_red_ceiling) {
		QPolygonF p = polygon();
		plot_data *entry = dataModel->data().entry + dataModel->rowCount()-1;
		for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
			if (!entry->in_deco) {
				/* not in deco implies this is a safety stop, no ceiling */
				p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0)));
			} else if (entry->stopdepth < entry->depth) {
				p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->stopdepth)));
			} else {
				p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth)));
			}
		}
		setPolygon(p);
	}

		// This is the blueish gradient that the Depth Profile should have.
	// It's a simple QLinearGradient with 2 stops, starting from top to bottom.
	QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
	pat.setColorAt(1, getColor(DEPTH_BOTTOM));
	pat.setColorAt(0, getColor(DEPTH_TOP));
	setBrush(QBrush(pat));

	int last = -1;
	for (int i = 0, count  = dataModel->rowCount(); i < count; i++) {

		struct plot_data *entry = dataModel->data().entry+i;
		if (entry->depth < 2000)
			continue;

		if ((entry == entry->max[2]) && entry->depth / 100 != last) {
			plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_DEEP));
			last = entry->depth / 100;
		}

		if ((entry == entry->min[2]) && entry->depth / 100 != last) {
			plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_SHALLOW));
			last = entry->depth / 100;
		}

		if (entry->depth != last)
			last = -1;
	}
}
コード例 #21
0
ファイル: diagramitem.cpp プロジェクト: ninja-king/CS240
//! [0]
DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu,
             QGraphicsItem *parent)
    : QGraphicsPolygonItem(parent)
{
    myDiagramType = diagramType;
    myContextMenu = contextMenu;

    QPainterPath path;
    switch (myDiagramType) {
        case StartEnd:
            path.moveTo(200, 50);
            path.arcTo(150, 0, 50, 50, 0, 90);
            path.arcTo(50, 0, 50, 50, 90, 90);
            path.arcTo(50, 50, 50, 50, 180, 90);
            path.arcTo(150, 50, 50, 50, 270, 90);
            path.lineTo(200, 25);
            myPolygon = path.toFillPolygon();
            break;
        case Conditional:
            myPolygon << QPointF(-100, 0) << QPointF(0, 100)
                      << QPointF(100, 0) << QPointF(0, -100)
                      << QPointF(-100, 0);
            break;
        case Step:
            myPolygon << QPointF(-100, -100) << QPointF(100, -100)
                      << QPointF(100, 100) << QPointF(-100, 100)
                      << QPointF(-100, -100);
            break;
        case Oval:
            path.moveTo(-50,50);
            path.arcTo(0, -50, 100, 100, 270,180);
            path.lineTo(-50,-50);
            path.arcTo(-100, -50, 100, 100, 90, 180);
            myPolygon = path.toFillPolygon();
            break;
        case Hexagon:
            myPolygon << QPointF(-100, 0) << QPointF(-50, 100)
                      << QPointF(50, 100) << QPointF(100, 0)
                      << QPointF(50, -100) << QPointF(-50,-100) << QPointF(-100,0);
            break;
        case Pentagon:
            myPolygon << QPointF(100, 50) << QPointF(100, -100)
                      << QPointF(-100, -100) << QPointF(-100, 50)
                      << QPointF(0,100) << QPointF(100,50);
            break;
        default:
            myPolygon << QPointF(-120, -80) << QPointF(-70, 80)
                      << QPointF(120, 80) << QPointF(70, -80)
                      << QPointF(-120, -80);
            break;
    }
    setPolygon(myPolygon);
    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
コード例 #22
0
void WGraphicsPolygonItem::mouseReleaseEvent(WGraphicsSceneMouseEvent* event)
{
	if (isSelected() && (event->button() == Ws::LeftButton) && _dragging)
	{
		_dragging = false;

		setPolygon(draggedPolygon(data()->polygon, scene()->dragStartPos(), scene()->attachedPoint(event->scenePos()), _select_flag), false, true);
		scene()->update();
	}
}
コード例 #23
0
void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	int last = -300, last_printed_hr = 0, sec = 0;
	struct {
		int sec;
		int hr;
	} hist[3] = {};

	// We don't have enougth data to calculate things, quit.
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;

	qDeleteAll(texts);
	texts.clear();
	// Ignore empty values. a heartrate of 0 would be a bad sign.
	QPolygonF poly;
	for (int i = 0, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++) {
		int hr = dataModel->index(i, vDataColumn).data().toInt();
		if (!hr)
			continue;
		sec = dataModel->index(i, hDataColumn).data().toInt();
		QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(hr));
		poly.append(point);
		if (hr == hist[2].hr)
			// same as last one, no point in looking at printing
			continue;
		hist[0] = hist[1];
		hist[1] = hist[2];
		hist[2].sec = sec;
		hist[2].hr = hr;
		// don't print a HR
		// if it's not a local min / max
		// if it's been less than 5min and less than a 20 beats change OR
		// if it's been less than 2min OR if the change from the
		// last print is less than 10 beats
		// to test min / max requires three points, so we now look at the
		// previous one
		sec = hist[1].sec;
		hr = hist[1].hr;
		if ((hist[0].hr < hr && hr < hist[2].hr) ||
		    (hist[0].hr > hr && hr > hist[2].hr) ||
		    ((sec < last + 300) && (abs(hr - last_printed_hr) < 20)) ||
		    (sec < last + 120) ||
		    (abs(hr - last_printed_hr) < 10))
			continue;
		last = sec;
		createTextItem(sec, hr);
		last_printed_hr = hr;
	}
	setPolygon(poly);

	if (texts.count())
		texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
}
コード例 #24
0
ファイル: diagramitem.cpp プロジェクト: AlexSoehn/qt-base-deb
DiagramItem::DiagramItem(DiagramType diagramType, QGraphicsItem *item)
    : QGraphicsPolygonItem(item)
{
    if (diagramType == Box) {
        boxPolygon << QPointF(0, 0) << QPointF(0, 30) << QPointF(30, 30)
                   << QPointF(30, 0) << QPointF(0, 0);
        setPolygon(boxPolygon);
    } else {
        trianglePolygon << QPointF(15, 0) << QPointF(30, 30) << QPointF(0, 30)
                        << QPointF(15, 0);
        setPolygon(trianglePolygon);
    }

    QColor color(static_cast<int>(qrand()) % 256,
        static_cast<int>(qrand()) % 256, static_cast<int>(qrand()) % 256);
    QBrush brush(color);
    setBrush(brush);
    setFlag(QGraphicsItem::ItemIsSelectable);
    setFlag(QGraphicsItem::ItemIsMovable);
}
コード例 #25
0
ファイル: BusInterfaceItem.cpp プロジェクト: kammoh/kactus2
//-----------------------------------------------------------------------------
// Function: BusInterfaceItem()
//-----------------------------------------------------------------------------
BusInterfaceItem::BusInterfaceItem(LibraryInterface* lh, QSharedPointer<Component> component,
                                   QSharedPointer<BusInterface> busIf,
                                   QGraphicsItem *parent)
    : HWConnectionEndpoint(parent, busIf == 0, QVector2D(1.0f, 0.0f)),
      lh_(lh),
	  nameLabel_("", this),
      busInterface_(),
      component_(component),
      oldColumn_(0),
      oldPos_(),
      oldInterfacePositions_(),
      offPageConnector_(0),
      portsCopied_(false)
{
    setType(ENDPOINT_TYPE_BUS);
    setTypeLocked(busIf != 0 && busIf->getInterfaceMode() != General::INTERFACE_MODE_COUNT);

    busInterface_ = busIf;
    int squareSize = GridSize;

    QPolygonF shape;
    shape << QPointF(-squareSize/2, squareSize / 2)
          << QPointF(-squareSize/2, -squareSize)
          << QPointF(squareSize/2, -squareSize)
          << QPointF(squareSize/2, squareSize / 2)
          << QPointF(0, squareSize);
    setPolygon(shape);
    
	QFont font = nameLabel_.font();
    font.setPointSize(8);
    nameLabel_.setFont(font);
    nameLabel_.setRotation(-rotation());
    nameLabel_.setFlag(ItemStacksBehindParent);
	
	QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
    shadow->setXOffset(0);
    shadow->setYOffset(0);
    shadow->setBlurRadius(5);
	nameLabel_.setGraphicsEffect(shadow);

    setFlag(ItemIsMovable);
    setFlag(ItemIsSelectable);
    setFlag(ItemSendsGeometryChanges);
    setFlag(ItemSendsScenePositionChanges);

    // Create the off-page connector.
    offPageConnector_ = new OffPageConnectorItem(this);
    offPageConnector_->setPos(0.0, -GridSize * 3);
    offPageConnector_->setFlag(ItemStacksBehindParent);
    offPageConnector_->setVisible(false);

    updateInterface();
}
コード例 #26
0
ファイル: mark.cpp プロジェクト: alserkli/q4Go
void MarkTriangle::setSize(double w, double)
{
	if (setting->readBoolEntry("SMALL_MARKS"))
		size = (int)(w*0.45);
	else
		size = (int)(w*0.55);
	
	pa.setPoint(0,(int)(size/2), 0);
	pa.setPoint(1,0, (int)size);
	pa.setPoint(2,(int)size, (int)size);
	setPolygon(pa);
}
コード例 #27
0
void DiagramDrawItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
	// left click
	if ((e -> buttons() & Qt::LeftButton)&&(mySelPoint>-1)) {
		QPointF mouse_point = onGrid(e -> pos());
#ifdef DEBUG
		std::cout << "Corner: " << mySelPoint << std::endl;
		std::cout << "mouse: " << mouse_point.x() << "/" << mouse_point.y() << std::endl;
		std::cout << "pos2: " << myPos2.x() << "/" << myPos2.y() << std::endl;
#endif
		prepareGeometryChange();
		switch (mySelPoint) {
			case 0:
				myPos2=myPos2-mouse_point;
				setPos(mapToScene(mouse_point));
				break;
			case 1:
				setPos(pos().x(),mapToScene(mouse_point).y());
				myPos2.setY(myPos2.y()-mouse_point.y());
				break;
			case 2:
				myPos2.setX(mouse_point.x());
				setPos(pos().x(),mapToScene(mouse_point).y());
				myPos2.setY(myPos2.y()-mouse_point.y());
				break;
			case 3:
				myPos2.setX(mouse_point.x());
				break;
			case 6:
				myPos2.setX(mouse_point.x());
				myPos2.setY(mouse_point.y());
				break;
			case 5:
				myPos2.setY(mouse_point.y());
				break;
			case 4:
				myPos2.setY(mouse_point.y());
				setPos(mapToScene(mouse_point).x(),pos().y());
				myPos2.setX(myPos2.x()-mouse_point.x());
				break;
			case 7:
				setPos(mapToScene(mouse_point).x(),pos().y());
				myPos2.setX(myPos2.x()-mouse_point.x());
				break;
			default:
				break;
		}
		myPolygon=createPath();
		setPolygon(myPolygon);
	}
	else
	DiagramItem::mouseMoveEvent(e);
}
コード例 #28
0
void TriangleSelection::moveBy( double dx, double dy )
{
	foreach (Triangle* t, m_triangles)
		t->moveBy(dx,dy);
	foreach(NodeItem* node, m_nodes)
		node->moveBy(dx,dy);
	QTransform trans = transform();
	translate(dx, dy);
	QPolygonF pa;
	foreach (QPointF p, polygon())
		pa << mapToScene(p);
	setTransform(trans);
	setPolygon(pa);
}
コード例 #29
0
ファイル: thingview.cpp プロジェクト: grefab/flakysworld
ThingView::ThingView(const Thing& thing, QGraphicsItem *parent) :
        QGraphicsPolygonItem(parent)
{
    /* colorize! */
    setAppearanceDependingOnID(thing.id());

    /* we need the body only to connect to it. no reference is stored. */
    connect(&thing, SIGNAL(changedPosition(QTransform)), this, SLOT(bodyChanged(QTransform)));

    /* initially set our location parameters */
    bodyChanged(thing.getWorldMap());

    /* adept our model's shape */
    setPolygon(thing.shape());
}
コード例 #30
0
//! [0]
DiagramDrawItem::DiagramDrawItem(DiagramType diagramType, QMenu *contextMenu,
             QGraphicsItem *parent, QGraphicsScene *scene)
	: DiagramItem(contextMenu,parent,scene)
{
	myPos2=pos();
    myDiagramType = diagramType;
    myContextMenu = contextMenu;

    myPolygon=createPath();
    setPolygon(myPolygon);
    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setAcceptHoverEvents(true);
    myHoverPoint=-1;
    mySelPoint=-1;
    myHandlerWidth=2.0;
}