Exemple #1
0
SCnFieldItem* SCnEditorScene::parentField(SCnFieldItem *field)
{
    SCnFieldItem *parentField = 0;
    QGraphicsItem *parentItem = field->parentItem();
    if (parentItem && field->isSCnFieldType(parentItem->type()))
    {
        parentField = static_cast<SCnFieldItem *>(parentItem);
    }
    return parentField;
}
Exemple #2
0
 void visit(QList<QGraphicsItem *> *items)
 {
     for (int i = 0; i < items->size(); ++i) {
         QGraphicsItem *item = items->at(i);
         if (!item->d_func()->itemDiscovered && item->isVisible()) {
             item->d_func()->itemDiscovered = 1;
             foundItems->prepend(item);
         }
     }
 }
Exemple #3
0
void SchemaEditor::slotSelectAll()
{
  QList<QGraphicsItem*> all = _schemaGui->items();
  QGraphicsItem* el;
  GearGui* ggui;
  _schemaGui->setSelectionChangeBypass(true);
  foreach(el,all)
  {
    el->setSelected(true);
  }
Exemple #4
0
void Grabber::EnableGrabber(QGraphicsItem *grabber, int device)
{
    if (grabber==NULL) throw new invalid_argument("Error EnableGrabber NullPointerException.");
    if ((device<0) || (device>255)) throw new invalid_argument("Error device must included between 0 and 255 .");
    QGraphicsItem * item = gItem;
    gItem = grabber;
    ItemDevices = device;
    if (item!=NULL) item->update(item->boundingRect());// refresh schermata.
    gItem->update(gItem->boundingRect());
}
// 使用方块组中的每一个小方块来进行判断
bool BoxGroup::isColliding()
{
    QList<QGraphicsItem *> itemList = childItems();
    QGraphicsItem *item;
    foreach (item, itemList) {
        if(item->collidingItems().count() > 1)
            return true;
    }
    return false;
}
Exemple #6
0
void QGVScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    QGraphicsItem *item = itemAt(mouseEvent->scenePos(), QTransform());
    if(item)
    {
        if(item->type() == QGVNode::Type)
            emit nodeMouseRelease (qgraphicsitem_cast<QGVNode*>(item));
    }
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
Exemple #7
0
void Checker::setVisibleSide (SideSegments &sideSegments,
                              bool visible)
{
  for (int i = 0; i < sideSegments.count(); i++) {
    QGraphicsItem *item = sideSegments [i];
    if (item != 0) {
      item->setVisible (visible);
    }
  }
}
Exemple #8
0
void ScenePainter::drawCircle(double x, double y, int r) {
  QRectF rect;
  if (indexMode()) {
    float minFloat = std::numeric_limits<float>::min();
    rect = QRectF(0, 0, minFloat, minFloat);
  } else rect = QRectF(-r, -r, 2*r, 2*r);
  QGraphicsItem *item = STORE_INDEX(_scene->addEllipse(rect, pen(), brush()));
  item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
  item->setPos(transform().map(QPointF(x, y)));
}
void WLD_ModeSelect::mousePress(QGraphicsSceneMouseEvent *mouseEvent)
{
    if(!scene) return;
    WldScene *s = dynamic_cast<WldScene *>(scene);

    if(s->EditingMode == WldScene::MODE_PasteFromClip)
    {
        if( mouseEvent->buttons() & Qt::RightButton )
        {
            MainWinConnect::pMainWin->on_actionSelect_triggered();
            dontCallEvent = true;
            s->IsMoved = true;
            return;
        }
        s->PasteFromBuffer = true;
        dontCallEvent = true;
        s->IsMoved = true;
        return;
    }

    if((s->disableMoveItems) && (mouseEvent->buttons() & Qt::LeftButton)
        && (Qt::ControlModifier != QApplication::keyboardModifiers()))
    { return; }

    if( mouseEvent->buttons() & Qt::MiddleButton )
    {
        if(GlobalSettings::MidMouse_allowSwitchToPlace)
        {
            if(s->selectedItems().size()==1)
            {
                QGraphicsItem * it = s->selectedItems().first();
                QString itp = it->data(0).toString();
                long itd = it->data(1).toInt();
                if(itp=="TILE")
                {MainWinConnect::pMainWin->SwitchPlacingItem(ItemTypes::WLD_Tile, itd); return;}
                else if(itp=="SCENERY")
                {MainWinConnect::pMainWin->SwitchPlacingItem(ItemTypes::WLD_Scenery, itd); return;}
                else if(itp=="PATH")
                {MainWinConnect::pMainWin->SwitchPlacingItem(ItemTypes::WLD_Path, itd); return;}
                else if(itp=="LEVEL")
                {MainWinConnect::pMainWin->SwitchPlacingItem(ItemTypes::WLD_Level, itd); return;}
                else if(itp=="MUSICBOX")
                {MainWinConnect::pMainWin->SwitchPlacingItem(ItemTypes::WLD_MusicBox, itd); return;}
            }
        }
        if(GlobalSettings::MidMouse_allowDuplicate)
        {
            if(!s->selectedItems().isEmpty())
            {
                s->WldBuffer = s->copy();
                s->PasteFromBuffer=true;
            }
        }
    }
}
Exemple #10
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();
}
double SystemRenderer::drawDirections(const System &system,
                                      const LayoutInfo &layout, double height)
{
    double maxHeight = 0;

    for (const Direction &direction : system.getDirections())
    {
        double localHeight = 0;
        const double x = layout.getPositionX(direction.getPosition());

        for (const DirectionSymbol &symbol : direction.getSymbols())
        {
            QGraphicsItem *item = nullptr;
            switch (symbol.getSymbolType())
            {
                case DirectionSymbol::Coda:
                    item = new SimpleTextItem(QChar(MusicFont::Coda),
                                              myMusicNotationFont);
                    break;
                case DirectionSymbol::DoubleCoda:
                    item = new SimpleTextItem(QString(2, MusicFont::Coda),
                                              myMusicNotationFont);
                    break;
                case DirectionSymbol::Segno:
                    item = new SimpleTextItem(QChar(MusicFont::Segno),
                                              myMusicNotationFont);
                    break;
                case DirectionSymbol::SegnoSegno:
                    item = new SimpleTextItem(QString(2, MusicFont::Segno),
                                              myMusicNotationFont);
                    break;
                default:
                    // Display plain text.
                    QFont font = myPlainTextFont;
                    font.setItalic(true);
                    item = new SimpleTextItem(
                        theDirectionText[symbol.getSymbolType()], font);
                    break;
            }

            centerHorizontally(*item, x, x + layout.getPositionSpacing());
            centerSymbolVertically(*item, height + localHeight);
            // Compensate a bit for the alignment of the music notation font.
            if (symbol.getSymbolType() <= DirectionSymbol::SegnoSegno)
                item->setY(item->y() + 4);

            item->setParentItem(myParentSystem);
            localHeight += LayoutInfo::SYSTEM_SYMBOL_SPACING;
        }

        maxHeight = std::max(maxHeight, localHeight);
    }

    return maxHeight;
}
void CellScene::mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent) {
	QGraphicsItem * item = itemAt(mouseEvent->scenePos());
	QGraphicsEllipseItem * item1;
	if (mouseEvent->button() == Qt::LeftButton)
		if (item)
			if (item->data(0) == "cellpoint" && item->data(1) == "") {
//				qDebug() << "marked";
				item1 = (QGraphicsEllipseItem*) item;
				item1->setPen(QPen(color, 3));
				item->setData(1, "marked");
				item->setData(2,struct_num);
				updatePointsNumbers();
				item->setData(4,0);

//				qDebug() <<item->data(2);
			}
	if (mouseEvent->button() == Qt::RightButton)
		if (item)
			if (item->data(1) == "marked") {
				item1 = (QGraphicsEllipseItem*) item;
				item1->setPen(QPen(Qt::blue, 2));
				item->setData(1, "");
				item->setData(2, "");
				item->setData(3,"");
				item->setData(4,"");
//				qDebug() <<item->data(2);
//				qDebug() << "unmarked";
			}
}
void GraphicsClientItem::focusInEvent(QFocusEvent *)
{
    QGraphicsItem *topSibling = 0;
    if (parentItem()) {
        topSibling = parentItem()->childItems().first();
    } else {
        topSibling = scene()->items().first()->topLevelItem();
    }
    Q_ASSERT(topSibling->parentItem() == parentItem());
    setZValue(topSibling->zValue() + 1);
}
Exemple #14
0
QVariant SCgObject::itemChange(GraphicsItemChange change, const QVariant &value)
{
    // item selection changed
    if (change == QGraphicsItem::ItemSelectedHasChanged)
    {
        if (isSelected())
        {
            mColor = scg_cfg_get_value_color(scg_key_element_color_selected);//QColor(255, 128, 64);
            //setCursor(QCursor(Qt::SizeAllCursor));
        }
        else
        {
            mColor = scg_cfg_get_value_color(scg_key_element_color_normal);//QColor(0, 0, 0);
            //setCursor(QCursor(Qt::ArrowCursor));
        }
    }

    // move to correct position automaticly
    if (change == QGraphicsItem::ItemParentChange && scene())
    {
        // we need to set this flag to prevent processing ItemPositionHasChanged,
        // because item position at this moment not actual
        mParentChanging = true;
        QGraphicsItem* newParent = value.value<QGraphicsItem*>();
        if(newParent)
            setPos(newParent->mapFromScene(scenePos()));
        else
            setPos(scenePos());
    }

    if (change == QGraphicsItem::ItemParentHasChanged)
    {
        // now item position has valid value
        mParentChanging = false;
        updateConnected();
    }

    // Change stacking order
    if (scene() && change == QGraphicsItem::ItemSelectedHasChanged
                && isSelected() && scene()->selectedItems().size() == 1)
    {
        QGraphicsItem* top = this;
        QList<QGraphicsItem*> lst = scene()->items();
        foreach(QGraphicsItem* it, lst)
        {
            if(it != this &&
               it->type() == type() &&
               it->parentItem() == parentItem())
            {
                it->stackBefore(top);
                top = it;
            }
        }
    }
QRectF CSharedPainterScene::itemBoundingRect( boost::shared_ptr<CPaintItem> item )
{
	if( ! item )
		return QRectF();

	if( ! item->drawingObject() )
		return QRectF();

	QGraphicsItem* i = reinterpret_cast<QGraphicsItem *>(item->drawingObject());
	return i->boundingRect();
}
Exemple #16
0
PianoKey* PianoScene::getKeyForPos( const QPointF& p ) const
{
    QGraphicsItem *itm = itemAt(p);
    while (itm != NULL && itm->parentItem() != NULL)
        itm = itm->parentItem();
    if (itm != NULL) {
        PianoKey* key = dynamic_cast<PianoKey*>(itm);
        return key;
    }
    return NULL;
}
void SCgCommandDeleteContour::undo()
{
    SCgBaseCommand::undo();

    QList<QGraphicsItem*>::iterator it;
    for (it = mChilds.begin(); it != mChilds.end(); ++it)
    {
        QGraphicsItem *item = *it;
        item->setParentItem(mContour);
    }
}
  void PeriodicTableScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
  {
    if (event->button() != Qt::LeftButton)
      return;

    QGraphicsItem *item = QGraphicsScene::itemAt(event->scenePos());
    if (item->data(0).toInt() > 0 && item->data(0).toInt() < 119)
      emit(elementChanged(item->data(0).toInt()));

    QGraphicsScene::mousePressEvent(event);
  }
void DigitizeStateSelect::unsetCursorForPoints()
{
  QList<QGraphicsItem*> items = context().mainWindow().scene().items();
  QList<QGraphicsItem*>::iterator itr;
  for (itr = items.begin (); itr != items.end (); itr++) {

    QGraphicsItem *item = *itr;
    if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE) == GRAPHICS_ITEM_TYPE_POINT) {
      item->unsetCursor ();
    }
  }
}
bool MInverseMouseArea::isClickedOnSoftwareInputPanel(QGraphicsSceneMouseEvent *event) const
{
    QGraphicsItem * item = scene()->itemAt(event->scenePos());
    while(item != NULL) {
        QDeclarativeItem * declItem = dynamic_cast<QDeclarativeItem *>(item);
        if(declItem != NULL && declItem->objectName() == "softwareInputPanel")
            return true;

        item = item->parentItem();
    }
    return false;
}
Exemple #21
0
void D2ModelScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
	mRobot->checkSelection();
	for (SensorItem *sensor : mRobot->sensors().values()) {
		if (sensor) {
			sensor->checkSelection();
		}
	}

	emit mouseReleased();

	// After dragging item may be null. We mustn`t select it in that case.
	QGraphicsItem *itemToSelect = nullptr;
	switch (mDrawingAction){
	case wall: {
		reshapeWall(mouseEvent);
		itemToSelect = mCurrentWall;
		mCurrentWall = nullptr;
		break;
	}
	case line: {
		reshapeLine(mouseEvent);
		itemToSelect = mCurrentLine;
		mCurrentLine = nullptr;
		break;
	}
	case stylus: {
		reshapeStylus(mouseEvent);
		itemToSelect = mCurrentStylus;
		mCurrentStylus = nullptr;
		break;
	}
	case ellipse: {
		reshapeEllipse(mouseEvent);
		itemToSelect = mCurrentEllipse;
		mCurrentEllipse = nullptr;
		break;
	}
	default:
		forReleaseResize(mouseEvent, mRobot->realBoundingRect());
		break;
	}

	if (itemToSelect) {
		itemToSelect->setSelected(true);
	}

	setMoveFlag(mouseEvent);

	setSceneRect(sceneRect().united(mRobot->sceneBoundingRect()));
	update();
	AbstractScene::mouseReleaseEvent(mouseEvent);
}
Exemple #22
0
SEXP qt_qupdate_QGraphicsItem(SEXP rself) {
  QGraphicsItem *item = unwrapQGraphicsItem(rself, QGraphicsItem);
  // HACK: purge the cache before updating. QGraphicsScene does not
  // seem to update the cache properly when there are multiple
  // views. This is not very efficient, but usually one is not
  // caching items that are frequently updated.
  QGraphicsItem::CacheMode mode = item->cacheMode();
  item->setCacheMode(QGraphicsItem::NoCache);
  item->setCacheMode(mode);
  item->update();
  return rself;
}
void MyQGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    int x = mouseEvent->scenePos().x();
    int y = mouseEvent->scenePos().y();

    if(tourPortee != 0)
    {
        this->removeItem(tourPortee);
        tourPortee = 0;
        emit this->tourSelectionnee(0,0,0);
    }

    QGraphicsItem * I = itemAt(x,y);

    if(mouseEvent->button() == Qt::RightButton)
    {
        /*this->removeItem(I);
        I = this->itemAt(x,y);
        this->removeItem(I);*/
        this->removeItem(getPrecedent());
        this->removeItem(getPrecedent2());
        this->tourDemandee = "";
    }

    if(tourDemandee != "")
    {
        this->removeItem(getPrecedent());
        this->removeItem(getPrecedent2());
        I = this->itemAt(x,y);

        if(tourDemandee == "EAU" && I->data(0).toString() == "HERBE")
        {
            emit this->ajouterTour(x,y,"EAU");
        }
        else if(tourDemandee == "PIERRE" && I->data(0).toString() == "HERBE")
        {
            emit this->ajouterTour(x,y,"PIERRE");
        }
        else if(tourDemandee == "PEINTURE" && I->data(0).toString() == "HERBE")
        {
            emit this->ajouterTour(x,y,"PEINTURE");
        }
        else if(tourDemandee == "PETANQUE" && I->data(0).toString() == "HERBE")
        {
            emit this->ajouterTour(x,y,"PETANQUE");
        }
        else if(tourDemandee == "MUSICIEN" && I->data(0).toString() == "HERBE")
        {
            emit this->ajouterTour(x,y,"MUSICIEN");
        }
     }
    if(I->data(0).toString() == "EAU" || I->data(0).toString() == "PIERRE" || I->data(0).toString() == "PEINTURE" || I->data(0).toString() == "PETANQUE" || I->data(0).toString() == "MUSICIEN")
    {
        emit this->tourSelectionnee(x,y,I);
    }
    precedent = 0;
    precedent2 = 0;
}
Exemple #24
0
void GraphicsScene::resetPositionHasChangedFlags()
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::resetPositionHasChangedFlags";

  QList<QGraphicsItem*> itms = items ();
  QList<QGraphicsItem*>::const_iterator itr;
  for (itr = itms.begin (); itr != itms.end (); itr++) {

    QGraphicsItem *item = *itr;
    item->setData (DATA_KEY_POSITION_HAS_CHANGED, false);
  }
}
Exemple #25
0
QGraphicsItem* MainRSTView::clickOnPoint(QPointF p)
{
    QPointF realPos = mapToScene(p.toPoint());
    QGraphicsItem *it;
    if ((it = itemAt(p.toPoint())) == bkgItem_)
        return 0;
    QRectF bd = it->sceneBoundingRect();
    double e = bd.width() / bd.height();
    if (std::abs(e - 1) > 0.1)
        return 0;
    return it;
}
Exemple #26
0
void SCgSelectSubGraph::doSelection(SCgScene *scene)
{
    Q_ASSERT(scene != 0);

    QList<QGraphicsItem*> items = scene->selectedItems();
    QGraphicsItem *item = 0;
    foreach(item, items)
    {
        if (SCgObject::isSCgObjectType(item->type()))
            select(static_cast<SCgObject*>(item));
    }
}
Exemple #27
0
void Widget::spawncirc(QPoint coord){
    int A = rand()%100+30;
    double d = A*scale;

    QRectF Itemrect(coord.x(),coord.y(),d/scale,d/scale);
    QGraphicsItem* item = scene->addEllipse(Itemrect);
    item->setTransformOriginPoint(d/scale/2,d/scale/2);
    QGraphicsRectItem* temp = new QGraphicsRectItem(coord.x()*scale,coord.y()*scale,d,d);
    temp->setTransformOriginPoint(d/2,d/2);
    circle* circ = new circle(temp,coord.x()*scale+d/2,coord.y()*scale+d/2, item,d/2);
    next = next->addToList(NULL, NULL, circ);
}
Exemple #28
0
SEXP qt_qupdate_QGraphicsScene(SEXP rself) {
  QGraphicsScene *scene = unwrapQObject(rself, QGraphicsScene);
  QList<QGraphicsItem *> items = scene->items();
  for (int i = 0; i < items.size(); i++) {
    QGraphicsItem *item = items[i];
    QGraphicsItem::CacheMode mode = item->cacheMode();
    item->setCacheMode(QGraphicsItem::NoCache);
    item->setCacheMode(mode);
  }
  scene->update();
  return rself;
}
 void visit(QList<QGraphicsItem *> *items)
 {
     for (int i = 0; i < items->size(); ++i) {
         QGraphicsItem *item = items->at(i);
         if (onlyTopLevelItems && item->d_ptr->parent)
             item = item->topLevelItem();
         if (!item->d_func()->itemDiscovered && item->d_ptr->visible) {
             item->d_func()->itemDiscovered = 1;
             foundItems->prepend(item);
         }
     }
 }
void UBAbstractDrawRuler::create(QGraphicsItem& item)
{
	item.setFlag(QGraphicsItem::ItemIsMovable, true);
    item.setFlag(QGraphicsItem::ItemIsSelectable, true);
    item.setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    item.setAcceptsHoverEvents(true);

    mCloseSvgItem = new QGraphicsSvgItem(":/images/closeTool.svg", &item);
    mCloseSvgItem->setVisible(false);
    mCloseSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
}