Exemplo n.º 1
0
void LVL_ModeCircle::mouseMove(QGraphicsSceneMouseEvent *mouseEvent)
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    if(!LvlPlacingItems::layer.isEmpty() && LvlPlacingItems::layer!="Default")
        s->setLabelBoxItem(true, mouseEvent->scenePos(), LvlPlacingItems::layer + ", " +
                     QString::number( mouseEvent->scenePos().toPoint().x() ) + "x" +
                     QString::number( mouseEvent->scenePos().toPoint().y() )
                      );
    else
        s->setLabelBoxItem(false);

    if(s->m_cursorItemImg && s->m_cursorItemImg->isVisible())
    {
        QGraphicsEllipseItem * cur = dynamic_cast<QGraphicsEllipseItem *>(s->m_cursorItemImg);
        QPoint hw = s->applyGrid( mouseEvent->scenePos().toPoint(),
                               LvlPlacingItems::gridSz,
                               LvlPlacingItems::gridOffset);

        QSize hs = QSize( (long)fabs(drawStartPos.x() - hw.x()),  (long)fabs( drawStartPos.y() - hw.y() ) );


        cur->setRect(0,0, hs.width(), hs.height());
        cur->setPos(((hw.x() < drawStartPos.x() )? hw.x() : drawStartPos.x()),
                    ((hw.y() < drawStartPos.y() )? hw.y() : drawStartPos.y()));
    }

}
Exemplo n.º 2
0
/// @brief constructor
///
/// @param parent parent widget
ScrollScene::ScrollScene (QWidget * parent, ResultsTab *resultsTab)
    : QGraphicsScene (parent)
    , resultsTab (resultsTab)
    , testing (false)
    , text1 (new QGraphicsTextItem ("Scroll until the red circle is centered.  Press SPACE to begin."))
    , text2 (new QGraphicsTextItem ("Scroll until the red circle is centered.  Press SPACE to begin."))
{
    // set the text font
    text1->setFont (QFont ("Arial", 18, QFont::Bold));
    text2->setFont (QFont ("Arial", 18, QFont::Bold));
    QRectF r = text1->boundingRect ();
    const size_t NCIRCLES = 100;
    text1->setPos (-r.width () / 2, -4 * RADIUS);
    text2->setPos (-r.width () / 2, NCIRCLES * RADIUS * 2);
    // add it
    addItem (text1);
    addItem (text2);
    // set background of client area
    setBackgroundBrush (Qt::white);
    circles.resize (NCIRCLES);
    for (size_t i = 0; i < circles.size (); ++i)
    {
        QGraphicsEllipseItem *c = new QGraphicsEllipseItem (0);
        c->setRect (-RADIUS, -RADIUS, RADIUS, RADIUS);
        int y = i * RADIUS * 2;
        c->setPos (0, y);
        addItem (c);
        circles[i] = c;
    }
}
QGraphicsItemGroup* SDefaultBrush::renderPath(QPainterPath path){
    QGraphicsItemGroup* pGroup = new QGraphicsItemGroup();

    QPen pen;
    QColor c1 = mColor;
    QColor c2 = mColor;
    int alpha1 = 3*mColor.alpha()/4;
    c1.setAlpha(alpha1);
    int alpha2 = alpha1*mHardness/100;
    c2.setAlpha(alpha2);
    pen.setColor(QColor(Qt::transparent));
    QRadialGradient gradient(500, 500, 500, 500, 500);
    gradient.setColorAt(0, c1);
    gradient.setColorAt(1, c2);
    QBrush brush(gradient);


    for(int i=0; i<path.length(); i+=(mWidth/2)*mSpacing){
        QGraphicsEllipseItem* pEllipse = new QGraphicsEllipseItem();
        pEllipse->setPen(pen);
        pEllipse->setBrush(brush);
        QPointF pt = path.pointAtPercent(path.percentAtLength(i));
        pEllipse->setRect(pt.x()-mWidth/2, pt.y()-mWidth/2, mWidth, mWidth);
        pGroup->addToGroup(pEllipse);
    }

    return pGroup;
}
Exemplo n.º 4
0
TmoodView::TmoodView(QWidget *parent) :
  QGraphicsView(parent)
{
  setScene(new QGraphicsScene(this));
  setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setFrameShape(QFrame::NoFrame);
  setStyleSheet("background-color: transparent");
  
  QPen commonPen(Qt::darkRed, 5, Qt::SolidLine, Qt::RoundCap);
  
  QGraphicsEllipseItem *face = scene()->addEllipse(0, 0, 400, 400, commonPen, QBrush(Qt::yellow));
  face->setZValue(1);
  face->setGraphicsEffect(new QGraphicsDropShadowEffect);
  
  QGraphicsEllipseItem *eye1 = scene()->addEllipse(100, 100, 20, 20, commonPen);
  eye1->setZValue(2);
  
  QGraphicsEllipseItem *eye2 = scene()->addEllipse(280, 100, 20, 20, commonPen);
  eye2->setZValue(2);
  
  QPainterPath path;
  path.moveTo(200, 150);
  path.cubicTo(180, 250, 200, 250, 200, 200);
  QGraphicsPathItem *nose = scene()->addPath(path, commonPen);
  nose->setZValue(2);
  
  
  m_mood = new QGraphicsPathItem();
  scene()->addItem(m_mood);
  m_mood->setPen(commonPen);
  m_mood->setZValue(3);
  setMood(1.0);
}
void ProfileScene::moveVertex() {
    // we have have at least one vertex on the profile plan, if we click on it, we can move it
    if (isProfileSelected){
        Vertex* currentVertex = currentProfile->getProfileVertex();
        // find which vertex we have selected
        while(currentVertex != 0) {
            QGraphicsEllipseItem* ellipse = currentVertex->getEllipse();
            if (ellipse->isUnderMouse()) {

                // cannot move the first vertex
                if (currentVertex->getNeighbor1() == 0) {
                    return;
                }

                isVertexMoving = true;
                currentlyMovingVertex = currentVertex;

                // tell the meshManager to generate new point/triangle
                meshManager->setLongUpdateOnMesh(true);
                return;
            }
            currentVertex = currentVertex->getNeighbor2();
        }
    }
}
Exemplo n.º 6
0
void GalaGV::setPlayerLogItems(const QList<Kampf> &list)
{
    qDebug() << Q_FUNC_INFO <<list.size();
    QString lastCords;
    for(int var = 0; var < list.size(); ++var) {
        const Kampf &k = list.at(var);
        QColor c =Qt::red;
        if(var == list.size()-1){
            c = Qt::darkMagenta;
        }
        QGraphicsEllipseItem *item = makeMarkerItem(k.cords,k.sysid,Log,c,Mark);
        item->setToolTip(k.toString());
        item->show();
        item->setFlags(QGraphicsItem::ItemIsSelectable);
        item->setData(Bericht,k.berichtUrl);
        scene()->addItem(item);
        mData->mPlayerLogPlanis.append(item);
        if(var>0){
            QGraphicsLineItem *lineItem = makeLineItem(k.cords,lastCords,Qt::red);
            scene()->addItem(lineItem);
            mData->mPlayerLogPlanis.append(lineItem);
        }
        lastCords = k.cords;
    }
}
Exemplo n.º 7
0
void QGraphicsGuideView::pathEndEvent(QMouseEvent *event) {
    cout << "Drawing Path (Before Simplification): " << _drawingPath.elementCount() << endl;
//    simplifyPainterPath();
    if (_pathMode == FillMode) {
        QPainter painter(&_userDrawingCanvas);
        painter.setRenderHints(0);
        painter.setBrush(QBrush(Qt::yellow,Qt::SolidPattern));
        painter.setPen(Qt::NoPen);
        painter.drawPath(_drawingPath);
        painter.end();

        this->scene()->removeItem(_drawingPathItem);
        _drawingPathItem = NULL;
        _updateRect = _drawingPath.boundingRect();
        userDrawingToSlice();
        sliceToLabelImage(true);
        updateLabelItem();
        sliceToVolume(true);
    } else {
        simplifyPainterPath();
        cout << "Drawing Path (After Simplification): " << _drawingPath.elementCount() << endl;
        for (int i = 0; i < _drawingPath.elementCount(); i++) {
            QPainterPath::Element e = _drawingPath.elementAt(i);
            QGraphicsEllipseItem* el = new QGraphicsEllipseItem(e.x-2,e.y-2,5,5,_drawingPathItem);
            el->setBrush(QBrush(0xFFFFBBDD, Qt::SolidPattern));
            el->setOpacity(1);
            el->setZValue(2);
        }
    }
}
Exemplo n.º 8
0
void widgetLandmark::NewRegion()
{
    ui->add_button->setChecked(false);
    // show ellipse and text in graphics view
    QPen pen = QPen(Qt::darkGreen,2);
    pen.setCosmetic(true);
    QRectF rect = _gview->GetCurrentSelectRect()->rect();
    QGraphicsEllipseItem* ellipse = _gview->GetScene()->addEllipse(rect,pen);
    ellipse->setTransform(QTransform::fromTranslate(_gview->GetTranslationX(),_gview->GetTranslationY()), true);


    // create region
    jpsRegion* region = new jpsRegion(_dmanager->GetRegionCounter(),"Region"+QString::number(_dmanager->GetRegionCounter()),
                                      rect.center(),std::fabs(rect.width()/2.0),std::fabs(rect.height()/2.0));


    QGraphicsTextItem* text = _gview->GetScene()->addText(region->GetCaption());
    text->setPos(rect.center().x()+_gview->GetTranslationX(),rect.center().y()+_gview->GetTranslationY());
    //text->setScale(gl_scale_f);
    text->setData(0,_gview->GetScaleF());
    text->setTransform(QTransform::fromScale(_gview->GetScaleF(),-_gview->GetScaleF()),true);

    region->SetTextItem(text);
    region->SetEllipse(ellipse);
    _dmanager->NewRegion(region);

    //show Region in listwidget
    ShowRegions();
}
Exemplo n.º 9
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    iScore1(0), iScore2(0)
{
    ui->setupUi(this);

    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setSceneRect(0, 0, ui->boardView->size().width()-30, ui->boardView->size().height()-30);

    QGraphicsRectItem *p1 = new QGraphicsRectItem(0, 0, 20, 80);
    p1->setBrush(QBrush(Qt::blue));
    QGraphicsRectItem *p2 = new QGraphicsRectItem(0, 0, 20, 80);
    p2->setBrush(QBrush(Qt::green));

    QGraphicsEllipseItem *ball = new QGraphicsEllipseItem(0, 0, 15, 15);
    ball->setBrush(QBrush(Qt::magenta));

    ui->boardView->setScene(scene);

    iLoop = new Gameplay(*scene, p1, p2, ball, this);
    QSize m(scene->sceneRect().size().width() + 10, scene->sceneRect().size().height() + 10);
    ui->boardView->setMinimumSize(m);
    ui->boardView->installEventFilter(iLoop);

    QObject::connect(iLoop, SIGNAL(goal(int)),
                     this, SLOT(addScore(int)));


    panel =  new ControlPanel(this);
    connect(panel, SIGNAL(pointsReady(std::vector<glm::vec2>)), iLoop, SLOT(setPoints(std::vector<glm::vec2>)));

    panel->show();
}
static QGraphicsEllipseItem* createPointItem() {
    QGraphicsEllipseItem* item = new QGraphicsEllipseItem(-pointRadius, -pointRadius, 2.0 * pointRadius, 2.0 * pointRadius);
    item->setBrush(pointBrush);
    item->setPen(pointPen);
    item->setZValue(1);
    return item;
}
Exemplo n.º 11
0
void widgetLandmark::SetPosInCMap()
{
    jpsLandmark* landmark = GetCurrentLandmark();

    if (landmark!=nullptr)
    {
        landmark->SetRect(_gview->GetCurrentSelectRect()->rect());
        QString string = "Ellipse: x: "+QString::number(landmark->GetRect().center().x())
                + " y: "+QString::number(landmark->GetRect().center().y())+" rA: "+QString::number(landmark->GetA())
                                         + " rB: "+QString::number(landmark->GetB());
        ui->ellipse_label->setText(string);
        ui->add_button->setChecked(false);

        // show ellipse and text in graphics view
        QPen pen = QPen(Qt::blue,2);
        pen.setCosmetic(true);
        QGraphicsEllipseItem* ellipse = _gview->GetScene()->addEllipse(landmark->GetRect(),pen);
        ellipse->setTransform(QTransform::fromTranslate(_gview->GetTranslationX(),_gview->GetTranslationY()), true);
        QGraphicsTextItem* text = _gview->GetScene()->addText(landmark->GetCaption());
        text->setPos(landmark->GetPos().x()+_gview->GetTranslationX(),landmark->GetPos().y()+_gview->GetTranslationY());
        //text->setScale(gl_scale_f);
        text->setData(0,_gview->GetScaleF());
        text->setTransform(QTransform::fromScale(_gview->GetScaleF(),-_gview->GetScaleF()),true);
        landmark->SetEllipseItem(ellipse);
        landmark->SetTextItem(text);
    }

}
Exemplo n.º 12
0
void SymbolDataEditor::rememberChanges()
{
    if (scene->items().isEmpty())
        return;

    if (itemToChange == Item::InPoint)
    {
        QGraphicsEllipseItem* inPointItem = static_cast<QGraphicsEllipseItem *>(scene->items(Qt::AscendingOrder).at(Item::InPoint));
        inPoint = inPointItem->rect().center();
    }

    if (itemToChange == Item::OutPoint)
    {
        QGraphicsEllipseItem* outPointItem = static_cast<QGraphicsEllipseItem *>(scene->items(Qt::AscendingOrder).at(Item::OutPoint));
        outPoint = outPointItem->rect().center();
    }

    if (itemToChange == Item::LimitsRect)
    {
        QGraphicsRectItem* limitsRectItem = static_cast<QGraphicsRectItem *>(scene->items(Qt::AscendingOrder).at(Item::LimitsRect));
        limits = limitsRectItem->rect();
    }

    correctLimits();
}
Exemplo n.º 13
0
void GraphicsBoard::setHighlights(const QList<Chess::Square>& squares)
{
	clearHighlights();
	if (squares.isEmpty())
		return;

	TargetHighlights* targets = new TargetHighlights(this);

	QRectF rect;
	rect.setSize(QSizeF(m_squareSize / 3, m_squareSize / 3));
	rect.moveCenter(QPointF(0, 0));
	QPen pen(Qt::white, m_squareSize / 20);
	QBrush brush(Qt::black);

	for (const auto& sq : squares)
	{
		QGraphicsEllipseItem* dot = new QGraphicsEllipseItem(rect, targets);

		dot->setCacheMode(DeviceCoordinateCache);
		dot->setPen(pen);
		dot->setBrush(brush);
		dot->setPos(squarePos(sq));
	}

	m_highlightAnim = new QPropertyAnimation(targets, "opacity");
	targets->setParent(m_highlightAnim);

	m_highlightAnim->setStartValue(0.0);
	m_highlightAnim->setEndValue(1.0);
	m_highlightAnim->setDuration(500);
	m_highlightAnim->setEasingCurve(QEasingCurve::InOutQuad);
	m_highlightAnim->start(QAbstractAnimation::KeepWhenStopped);
}
Exemplo n.º 14
0
void GraphicalRobotElement::updateTraceRect() {
	QGraphicsEllipseItem *Position;
	QGraphicsLineItem *UnLine;
	int RobotPositionsSize;
	QRectF rect0;
	QRectF rect1;
	QPen penForTraceLine (Qt::black);
	penForTraceLine.setWidth (1);

	if (currentWIM.has_myposition() ) {
		Position = this->parentScene->addEllipse (QRect(), QPen (Qt::black), QBrush (Qt::magenta) );
		Position->setRect (this->parentScene->rectFromFC ( currentWIM.myposition().x() * 1000,
		                   currentWIM.myposition().y() * 1000, 40, 40) );
		RobotPositions.push_back (Position);
		RobotPositionsSize = RobotPositions.size();

		if (RobotPositionsSize > 1) {
			rect0 = RobotPositions[RobotPositionsSize-1]->rect();
			rect1 = RobotPositions[RobotPositionsSize-2]->rect();
			UnLine = this->parentScene->addLine (QLineF(), penForTraceLine);
			UnLine->setLine (QLineF (rect0.x(), rect0.y(), rect1.x(), rect1.y() ) );
			UnionistLines.push_back (UnLine);
		}
	}
}
Exemplo n.º 15
0
void PSV_CircularIndicatorItem::drawCoverCircle(int zValue)
{
    double coverCircleRadius = m_coverCircleRadiusRatio * m_outerRadius;
    QRectF rect(m_rect.center().x()-coverCircleRadius, m_rect.center().y()-coverCircleRadius, coverCircleRadius*2, coverCircleRadius*2);
    QGraphicsEllipseItem* item = new QGraphicsEllipseItem(rect, this);
    item->setPen(QPen(Qt::NoPen));
    item->setBrush(QBrush(QColor(130, 130, 130)));
    item->setZValue(zValue);
}
Exemplo n.º 16
0
void QGraphicsVolumeView::addWorkingSetItem(QGraphicsItem *sliceItem) {
    const static int markerSize = 9;
    QRectF rect = sliceItem->boundingRect();
    QRectF ellipse = QRectF(rect.width() - markerSize - 3, 3, markerSize, markerSize);
    QGraphicsEllipseItem* rectItem = new QGraphicsEllipseItem(ellipse, sliceItem);
    rectItem->setZValue(1);
    rectItem->setPen(QPen(Qt::green, 3));
    rectItem->setData(AnnotationType, QVariant(WorkingSet));
}
void MainWindow::slotAddEllipseItem() 	//在场景中加入一个椭圆形图元
{
    QGraphicsEllipseItem *item = new QGraphicsEllipseItem(QRectF(0,0,80, 60));
    item->setPen(Qt::NoPen);
    item->setBrush(QColor(qrand()%256,qrand()%256,qrand()%256));
    item->setFlag(QGraphicsItem::ItemIsMovable);

    scene->addItem(item);
    item->setPos((qrand()%int(scene->sceneRect().width()))-200,(qrand()%int(scene->sceneRect().height()))-200);
}
    virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value){
        if(change == ItemPositionHasChanged){
            QGraphicsEllipseItem *item = qgraphicsitem_cast<QGraphicsEllipseItem *>(parentItem());

            qreal diff = qSqrt(x()*x() + y()*y());
            item->setRect(MakeCircleRect(diff - kCropItemControlPointRadius));
        }

        return QGraphicsEllipseItem::itemChange(change, value);
    }
Exemplo n.º 19
0
QGraphicsItem* CGraphicsEllipseItem::createItem()
{
	QGraphicsEllipseItem* pItem = new QGraphicsEllipseItem(m_Parent);

	drawPen(pItem);
	drawBrush(pItem);

	pItem->setRect(GET_VALUE(cx).toInt(), GET_VALUE(cy).toInt(), GET_VALUE(rx).toInt(), GET_VALUE(ry).toInt());
	return pItem;
}
Exemplo n.º 20
0
void IdentityItem::updateItem( const Polka::Identity &identity )
{
  m_identity = identity;

  foreach( QGraphicsItem *child, childItems() ) {
    delete child;
  }

  if ( identity.type() == "group" ) {
    int circleSize = m_itemSize + 14;
    QGraphicsEllipseItem *groupCircle = new QGraphicsEllipseItem( this );
    groupCircle->setRect( -circleSize/2, -circleSize/2,
      circleSize, circleSize );
    QPen pen;
    pen.setBrush( Qt::white );
    pen.setWidth( 4 );
    groupCircle->setPen( pen );
  }

  QPixmap pixmap = m_model->pixmap( identity );

  QGraphicsItem *item = new QGraphicsPixmapItem( pixmap, this );
  item->setPos( -pixmap.width() / 2, -pixmap.height() / 2 );

  QGraphicsTextItem *textItem = new QGraphicsTextItem( identity.name().value() );

  int textWidth = textItem->boundingRect().width();
  int textHeight = textItem->boundingRect().height();

  m_nameItem = new RoundedRectItem( this );
  m_nameItem->setRect( 0, 0, textWidth, textHeight );
  m_nameItem->setBrush( QColor( 255,255,230 ) );
  m_nameItem->setZValue( 10 );

  textItem->setParentItem( m_nameItem );

  m_nameItem->setPos( - textWidth / 2, 30 );

  m_fanMenu = new FanMenu( this );
  m_fanMenu->setZValue( 50 );

  FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Remove") );
  connect( menuItem, SIGNAL( clicked() ), SLOT( emitRemoveIdentity() ) );
  m_checkMenuItem = m_fanMenu->addItem( i18n("Check") );
  connect( m_checkMenuItem, SIGNAL( clicked() ), SLOT( checkItem() ) );
  if ( identity.type() == "group" ) {
    menuItem = m_fanMenu->addItem( i18n("Go to") );
  } else {
    menuItem = m_fanMenu->addItem( i18n("Show") );
  }
  connect( menuItem, SIGNAL( clicked() ), SLOT( emitShowIdentity() ) );
  m_fanMenu->setupItems();

  hidePopups();
}
Exemplo n.º 21
0
void CSharedPainterScene::drawLineStart( const QPointF &pt, const QColor &clr, int width )
{
	double x = pt.x() - (double(width) / 2.f);
	double y = pt.y() - (double(width) / 2.f);
	QRectF rect( x, y, width, width);

	QGraphicsEllipseItem *item = addEllipse( rect, QPen(clr, 1), QBrush(clr) );
	item->setZValue( currentZValue() );

	tempLineItemList_.push_back( item );
}
Exemplo n.º 22
0
void GraphiItemCtrl::OnDrawEvent()
{

	switch(i_CurrentType)
	{
	case ITM_TYPE_LINE:
		{
			QGraphicsLineItem* pLine = o_ItemScene.addLine(o_PointA.x(),o_PointA.y(),
				o_PointB.x(), o_PointB.y(),o_CurrentPen);
			int iKey = GetNextItemKey();
			QLineF oLine = pLine->line();
			map_Lines.insert(iKey,oLine);
			map_LineItems.insert(iKey, pLine);
			pLine->setData(CUSTDATA_KEY,iKey);
			
			emit NotifyLineAdded(iKey,oLine);
			break;
		}
	case ITM_TYPE_RECTANGLE:
		{
			double dWidth = o_PointB.x() - o_PointA.x();
			double dHeight = o_PointB.y() - o_PointA.y();
			QGraphicsRectItem* pRect = o_ItemScene.addRect(o_PointA.x(),o_PointA.y(),
				dWidth ,dHeight,o_CurrentPen);
			int iKey = GetNextItemKey();
			QRectF oRect = pRect->rect();
			map_Rects.insert(iKey, oRect);
			pRect->setData(CUSTDATA_KEY,iKey);
			
			emit NotifyRectAdded(iKey,oRect);
		
			break;
		}
	case ITM_TYPE_ELIPSE:
		{
			double dWidth = o_PointB.x() - o_PointA.x();
			double dHeight = o_PointB.y() - o_PointA.y();
			QGraphicsEllipseItem* pElipse =	o_ItemScene.addEllipse(o_PointA.x(),o_PointA.y(),
				dWidth ,dHeight,o_CurrentPen);
			
			int iKey = GetNextItemKey();
			pElipse->setData(CUSTDATA_KEY, iKey);
			QRectF oRect = pElipse->rect();
			map_Elipses.insert(iKey,oRect);
			
			emit NotifyElipseAdded(iKey,oRect);
			break;
		}
	}



}
void FloorScene::removeVertex()
{
    //remove point if clicked on a point
    FloorVertex* floorplan = mesh->getFloorPlan();
    unsigned int floorPlanSize = mesh->getFloorPlanSize();

    if (floorPlanSize <= 3) {
        return;
    }

    Vertex* currentVertex = floorplan;

    //find if a vertex is under the mouse
    for (unsigned int i(0); i < floorPlanSize; ++i) {
        QGraphicsEllipseItem* ellipse = currentVertex->getEllipse();

        if (ellipse->isUnderMouse()) {
            // first set the floorplan pointer in mesh to be the neighbor of the
            // currently deleted vertex. Because it can be the one pointed in
            // the mesh class used to iterate over the floorplan
            mesh->setFloorPlan((FloorVertex*)currentVertex->getNeighbor2());

            // we find one vertex to remove under the mouse, we remove it
            QGraphicsLineItem* newEdge = currentVertex->removeVertex();
            QGraphicsLineItem* oldEdge1 = currentVertex->getEdge1();
            QGraphicsLineItem* oldEdge2 = currentVertex->getEdge2();
            this->removeItem(ellipse);
            this->removeItem(oldEdge1);
            this->removeItem(oldEdge2);

            //update normals of the two neighbor
            FloorVertex* neighbor1 = (FloorVertex*)currentVertex->getNeighbor1();
            FloorVertex* neighbor2 = (FloorVertex*)currentVertex->getNeighbor2();
            neighbor1->computeNormal();
            neighbor2->computeNormal();

            this->addItem(newEdge);

            delete oldEdge1;
            delete oldEdge2;
            delete ellipse;
            delete currentVertex;

            mesh->decrementFloorPlanSize();

            // tell the mesh to generate new point/triangle
            mesh->setUpdateOnMesh();

            break;
        }
        currentVertex = currentVertex->getNeighbor2();
    }
}
Exemplo n.º 24
0
PacMan::PacMan(int radius, QColor color, int layer , double startX, double startY, double endX, double endY, int startSec, int endSec)
 : radius(radius) , color(color) , layer(layer) , startX(startX) , startY(startY) , endX(endX) , endY(endY) , startSec(startSec) , endSec(endSec)
{
    moveScale = 1;

    QGraphicsEllipseItem * ellipse = new QGraphicsEllipseItem(this);

    ellipse->setRect ( -radius , -radius , radius*2 , radius*2 );
    ellipse->setBrush (QBrush(color));
    liveSec = endSec - startSec;

    setZValue(layer);
}
Exemplo n.º 25
0
SEXP qt_qgraphicsEllipseItem(SEXP x, SEXP y, 
			     SEXP width, SEXP height, 
			     SEXP pars)
{
    double 
	px = asReal(x), py = asReal(y),
	pw = asReal(width), ph = asReal(height);
    QGraphicsEllipseItem *item = 
	new QGraphicsEllipseItem(px - pw/2, py - ph/2, pw, ph, 0);
    item->setBrush(asQBrush(pars));
    item->setPen(asQPen(pars));
    return wrapQGraphicsItem(item);
}
Exemplo n.º 26
0
void StitcherView::drawConstraintFit(geometrically_constrained_system *gc){
  for(int i = 0;i<gc->n_constraints;i++){
    GeometryConstraintType type = gc->constraints[i].type;
    double fit = gc->constraints[i].best_fit;    
    if(type == RadialLineConstraint){
      qreal x1,x2,y1,y2;
      qreal scale = 10000;
      x1 = cos(fit)*scale;

      y1 = sin(fit)*scale;
      x2 = -x1;
      y2 = -y1;
      QGraphicsLineItem * item = new QGraphicsLineItem(x1,y1,x2,y2);
      QPen p = item->pen();
      p.setStyle(Qt::DashLine);
      QVector<qreal> dashes;
      dashes << 25 << 15;
      p.setDashPattern(dashes);
      p.setColor(Qt::white);
      item->setPen(p);
      item->setZValue(10000);
      scene()->addItem(item);
      constraintFit.append(item);
    }else if(type == CircleConstraint){
      double radius = fit;
      QGraphicsEllipseItem * item = new QGraphicsEllipseItem(-radius,-radius,2*radius,2*radius);
      QPen p = item->pen();
      p.setStyle(Qt::DashLine);
      QVector<qreal> dashes;
      dashes << 25 << 15;
      p.setDashPattern(dashes);
      p.setColor(Qt::white);
      item->setPen(p);
      item->setZValue(10000);
      scene()->addItem(item);
      constraintFit.append(item);
    }
    sp_vector ** cp_g = control_point_list_to_global(gc->constraints[i].points,gc->constraints[i].n_points);
    QColor color = QColor::fromHsvF(1.0/3+(double)i/gc->n_constraints,1,1,1);
    for(int j = 0;j<gc->constraints[i].n_points;j++){
      QGraphicsEllipseItem * point = new QGraphicsEllipseItem(-4,-4,8,8);
      point->setZValue(10001);
      point->setPos(sp_vector_get(cp_g[j],0),sp_vector_get(cp_g[j],1));
      point->setPen(QPen(color, 2));
      point->setFlags(point->flags() | QGraphicsItem::ItemIgnoresTransformations);
      scene()->addItem(point);
      constraintFit.append(point);
    }
  }
}
Exemplo n.º 27
0
void HostItem::createJobHalo(const Job &job)
{
    QGraphicsEllipseItem *halo = new QGraphicsEllipseItem(
        centerPosX(), centerPosY(), m_baseWidth, m_baseHeight,
        this, scene());

    halo->setZValue(70 - m_jobHalos.size());
    halo->setPen(QPen(Qt::NoPen));
    halo->show();

    m_jobHalos.insert(job, halo);

    updateHalos();
}
Exemplo n.º 28
0
SEXP
scene_addPoints(SEXP scene, SEXP x, SEXP y, SEXP radius)
{
    QGraphicsScene* s = unwrapQObject(scene, QGraphicsScene);
    int i, n = length(x);
    for (i = 0; i < n; i++) {
	// QGraphicsEllipseItem *item = s->addEllipse(REAL(x)[i], REAL(y)[i], REAL(radius)[0], REAL(radius)[0]);
	QGraphicsEllipseItem *item = s->addEllipse(0.0, 0.0, REAL(radius)[0], REAL(radius)[0]);
	item->setPos(REAL(x)[i], REAL(y)[i]);
	item->setFlags(QGraphicsItem::ItemIsSelectable | 
		       QGraphicsItem::ItemIgnoresTransformations);
    }
    return R_NilValue;
}
Exemplo n.º 29
0
void GraphViewer::onSceneMouseRelease(QGraphicsSceneMouseEvent *mouseEvent)
{

    // need to put the connecting line on the background otherwise it is detected under the mouse
    _drawingEdge->setZValue(EDGE_LINE_Z);

    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)
        {
            double x = _drawingEdge->transform().dx();
            double y = _drawingEdge->transform().dy();
            _drawingEdge->setLine(0.0,0.0, vertex->scenePos().x()-x, vertex->scenePos().y()-y);
            _drawingEdge->setZValue(EDGE_LINE_Z);

            if (_drawingEdge->data(KEY_EDGE_VERTEX1) == vertex->data(KEY_EDGE_VERTEX1))
                _scene.removeItem(_drawingEdge);
            else
            {
                int defaultWeight = 1;
                _drawingEdge->setData(KEY_EDGE_VERTEX2, vertex->data(KEY_VERTEX_ID));
                _drawingEdge->setData(KEY_EDGE_WEIGHT, defaultWeight);
                // draw edge weight
                QGraphicsSimpleTextItem * edgeWeight = _scene.addSimpleText(QString("%1").arg(defaultWeight));
                edgeWeight->setParentItem(_drawingEdge);
                edgeWeight->setBrush(Qt::blue);
                QLineF line = _drawingEdge->line();
                edgeWeight->setTransform(
                            QTransform::fromScale(0.005, 0.005)
                            * QTransform::fromTranslate(line.x2()*0.5, line.y2()*0.5)
                            );
                edgeWeight->setZValue(EDGE_TEXT_Z);
                // add to graph edges
                _edges << _drawingEdge;
            }
        }
    }
    else
    {
        _scene.removeItem(_drawingEdge);
    }
    _isDrawingEdge=false;
    _drawingEdge=0;
}
Exemplo n.º 30
0
void PSV_CircularIndicatorItem::drawCoverBall(int zValue)
{
    qreal ballRadius=m_outerRadius * m_coverBallRadiusRatio;
    QRadialGradient ballGradient(m_rect.center(), ballRadius, m_rect.center());
    ballGradient.setColorAt(0.0, QColor(140, 140, 140));
    ballGradient.setColorAt(0.7, QColor(140, 140, 140));
    ballGradient.setColorAt(1.0, QColor(60, 60, 60));
    //==================
    QRectF rect(m_rect.center().x()-ballRadius, m_rect.center().y()-ballRadius, ballRadius*2, ballRadius*2);
    QGraphicsEllipseItem* item = new QGraphicsEllipseItem(rect, this);
    item->setPen(QPen(Qt::NoPen));
    item->setBrush(ballGradient);
    item->setZValue(zValue);
}