void QGraphicsItemComposite::computeSize(qreal &xmin, qreal &xmax, qreal &ymin, qreal &ymax) const { if (children.empty()) { xmin = xmax = ymin = ymax = 0; return; } xmin = xmax = children.first()->x(); ymin = ymax = children.first()->y(); xmax += children.first()->boundingRect().width(); ymax += children.first()->boundingRect().height(); for (int i = 1; i < children.length(); i++) { QGraphicsItem* child = children.at(i); if (xmin > child->x()) { xmin = child->x(); } if (xmax < child->x() + child->boundingRect().width()) { xmax = child->x() + child->boundingRect().width(); } if (ymin > child->y()) { ymin = child->y(); } if (ymax < child->y() + child->boundingRect().height()) { ymax = child->y() + child->boundingRect().height(); } } }
QImage * FusionCalques::fusionCalques(QList<QGraphicsItem *> list, QImage * im){ //copie image QImage * image = new QImage(*im); //variable QPoint origine; int w; int h; QGraphicsItem * it; QGraphicsPixmapItem * it2; QPixmap map; QImage item; float nivFusion, r, g, b, alpha; //récupération du niveau de transparence Contraste *fenetre = new Contraste; fenetre->show(); fenetre->activateWindow(); fenetre->exec(); if( fenetre->getCanceled() ){ fenetre->close(); return NULL; } else{ nivFusion= fenetre->getValue(); nivFusion= nivFusion/100.0; } //insertion for( int i=0; i<list.size(); i++){ it = list[i]; origine = it->pos().toPoint(); w = it->boundingRect().width(); h = it->boundingRect().height(); if( it->type() == 7 ){ it2 = (QGraphicsPixmapItem *)it; } else{ return NULL; } map = it2->pixmap(); item = map.toImage(); for (int j = origine.y(); j < origine.y()+h-1; ++j) { for (int i = origine.x(); i < origine.x()+w-1; ++i) { r = QColor(item.pixel(i-origine.x(),j-origine.y())).red()*(nivFusion) + (QColor(image->pixel(i,j)).red()*(1-nivFusion)); g = QColor(item.pixel(i-origine.x(),j-origine.y())).green()*(nivFusion) + (QColor(image->pixel(i,j)).green()*(1-nivFusion)); b = QColor(item.pixel(i-origine.x(),j-origine.y())).blue()*(nivFusion) + (QColor(image->pixel(i,j)).blue()*(1-nivFusion)); alpha = QColor(item.pixel(i-origine.x(),j-origine.y())).alpha()*(nivFusion) + (QColor(image->pixel(i,j)).alpha()*(1-nivFusion)); image->setPixel(i,j,qRgba(int(r+0.5),int(g+0.5),int(b+0.5),int(alpha+0.5))); } } } return image; }
void SymbolDataEditor::addDataItems() { QGraphicsItem * symbolItem = scene->items(Qt::AscendingOrder).at(Item::SymbolItem); qreal maxSymbolSide = qMax(symbolItem->boundingRect().width(), symbolItem->boundingRect().height()); pointWidth = maxSymbolSide / 300; scene->addEllipse(inPoint.x() - pointWidth / 2, inPoint.y() - pointWidth / 2, pointWidth, pointWidth, QPen(Qt::darkCyan), QBrush(Qt::cyan)); scene->addEllipse(outPoint.x() - pointWidth / 2, outPoint.y() - pointWidth / 2, pointWidth, pointWidth, QPen(Qt::darkMagenta), QBrush(Qt::magenta)); scene->addRect(limits, QPen(Qt::darkYellow, 0)); }
static void paintLinesToChildren( QGraphicsItem * qgi, QPainter * painter, QPen const & pen ) { typedef QList<QGraphicsItem*> QGIL; QGIL ch( qboard::childItems(qgi) ); if( ch.isEmpty() ) return; QRectF prect( qgi->boundingRect() ); QPointF mid( prect.left() + (prect.width() / 2), prect.top() + (prect.height() / 2) ); painter->save(); for( QGIL::iterator it = ch.begin(); ch.end() != it; ++it ) { QGraphicsItem * x = *it; QRectF xr( x->boundingRect() ); QPointF xmid( xr.center() ); //xmid = x->mapToParent( xmid ); xmid = qgi->mapFromItem( x, xmid ); painter->setPen( pen ); painter->drawLine( QLineF( mid, xmid ) ); } painter->restore(); }
/*! calculates the position of the label, when the position relative to the parent was specified (left, right, etc.) */ void TextLabelPrivate::updatePosition() { //determine the parent item QRectF parentRect; QGraphicsItem* parent = parentItem(); if (parent) { parentRect = parent->boundingRect(); } else { if (!scene()) return; parentRect = scene()->sceneRect(); } if (position.horizontalPosition != TextLabel::hPositionCustom) { if (position.horizontalPosition == TextLabel::hPositionLeft) position.point.setX( parentRect.x() ); else if (position.horizontalPosition == TextLabel::hPositionCenter) position.point.setX( parentRect.x() + parentRect.width()/2 ); else if (position.horizontalPosition == TextLabel::hPositionRight) position.point.setX( parentRect.x() + parentRect.width() ); } if (position.verticalPosition != TextLabel::vPositionCustom) { if (position.verticalPosition == TextLabel::vPositionTop) position.point.setY( parentRect.y() ); else if (position.verticalPosition == TextLabel::vPositionCenter) position.point.setY( parentRect.y() + parentRect.height()/2 ); else if (position.verticalPosition == TextLabel::vPositionBottom) position.point.setY( parentRect.y() + parentRect.height() ); } emit q->positionChanged(position); }
void DataVisualizer::setItemPos(QGraphicsItem * item, QPointF pos) { typedef QList<QGraphicsItem *> QGraphicsItemList; SceneType scene(gvDisplay->scene()); if (!item || !scene) return; // set the desired position item->setPos(pos); // check for collisions with other items QList<QGraphicsItem *> collides = scene->collidingItems(item); if (collides.size() == 0) return; QGraphicsItem * cItem = 0; QGraphicsItemList::const_iterator it = collides.constBegin(); while(it != collides.constEnd()) { cItem = *it; if (cItem && !cItem->parentItem()) break; it++; } if (!cItem || cItem->parentItem()) return; // item has no parent => top-level, bounding rect qreal newYPos = cItem->y() + 0.5*cItem->boundingRect().height() + 0.5*item->boundingRect().height() + itemMargin; QPointF newPos(pos); newPos.setY(newYPos); setItemPos(item, newPos); }
bool AssociationMode::onMousePress(DiagramView* view, QMouseEvent* event) { if (view->scene()) { QPointF p = event->pos(); if (clickedOnItem) { clickedItems[1] = dynamic_cast<Entity*>(view->itemAt(p.toPoint())); if (clickedItems[1] && clickedItems[1] != clickedItems[0]) { clickedOnItem = false; qobject_cast<DiagramScene*>(view->scene())->addDiagramItem(createAssociation(clickedItems[0], clickedItems[1])); view->scene()->removeItem(line); delete line; line = NULL; } } else { clickedItems[0] = dynamic_cast<Entity*>(view->itemAt(p.toPoint())); if (clickedItems[0]) { QGraphicsItem* item = view->itemAt(event->pos()); line = view->scene()->addLine(QLineF(item->pos() + item->boundingRect().center(), view->mapToScene(event->pos())), QPen(Qt::red, 0.0, Qt::DashDotLine)); line->setZValue(-1.0); clickedOnItem = true; } } } return false; }
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()); }
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(); }
GSequenceView::GSequenceView(QWidget *parent) : QAbstractItemView(parent), m_GraphicsView(this) { m_GraphicsView.resize(size()); m_GraphicsView.setBackgroundBrush(Qt::yellow); m_GraphicsView.setAlignment(Qt::AlignLeft); QGraphicsScene* pscccc = new QGraphicsScene(this); m_GraphicsView.setScene(pscccc); QGraphicsItem* pell = pscccc->addEllipse(200, 100, 60, 40); pscccc->addRect(pell->boundingRect()); }
// Converts the value into an percentage: // this enables smooth movement in moveIndex below void TelemetryMonitorWidget::showTelemetry() { txIndex = (txValue-minValue)/(maxValue-minValue) * NODE_NUMELEM; rxIndex = (rxValue-minValue)/(maxValue-minValue) * NODE_NUMELEM; if (connected) this->setToolTip(QString("Tx: %0 bytes/sec\nRx: %1 bytes/sec").arg(txValue).arg(rxValue)); else this->setToolTip(QString("Disconnected")); int i; int nodeMargin = 8; int leftMargin = 60; QGraphicsItem* node; for (i=0; i < txNodes.count(); i++) { node = txNodes.at(i); node->setPos((i*(node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height()/2) - 2); node->setVisible(connected && i < txIndex); node->update(); } for (i=0; i < rxNodes.count(); i++) { node = rxNodes.at(i); node->setPos((i*(node->boundingRect().width() + nodeMargin)) + leftMargin, (node->boundingRect().height()*2) - 2); node->setVisible(connected && i < rxIndex); node->update(); } QRectF rect = graph->boundingRect(); txSpeed->setPos(rect.right() - 110, rect.top()); txSpeed->setPlainText(QString("%0").arg(txValue)); txSpeed->setVisible(connected); rxSpeed->setPos(rect.right() - 110, rect.top() + (rect.height() / 2)); rxSpeed->setPlainText(QString("%0").arg(rxValue)); rxSpeed->setVisible(connected); update(); }
void CSharedPainterScene::removeItem( CPaintItem * item ) { if( ! item ) return; if( ! item->drawingObject() ) return; if( lastAddItem_.get() == item ) clearLastItemBorderRect(); QGraphicsItem* i = reinterpret_cast<QGraphicsItem *>(item->drawingObject()); QGraphicsScene::removeItem( i ); invalidate( i->boundingRect() ); }
void AreaWidget::doubleClickInit(AnimationItem *pItem) { if(!pItem) return; QList <QGraphicsItem *> items = pItem->childItems(); QGraphicsItem *group = NULL; int nCount = items.size(); int i = 0; QString sName = ""; int ikey = 0; m_Tinfo.clear(); QRectF rc; for(i = 0;i < nCount;i++) { group = items.at(i); sName = group->data(GROUP_NAME_KEY).toString(); ikey = group->type(); if(sName == tr("mMain")) //向量图控件 { // rc = group->boundingRect(); // ui->m_width->setValue(rc.width()); //初始化向量图的的宽度 // ui->m_height->setValue(rc.height());//初始化向量图的的高度 // iWidth = rc.width(); // iHeight = rc.height(); } else if(ikey == SAM_DRAW_OBJECT_ELIPSE) //记录每个点的位置 { QPointF pos = group->boundingRect().topLeft()+group->scenePos(); TrackPointInfo TrackPoint; TrackPoint.nXPos = pos.x(); TrackPoint.nYPos = pos.y(); m_Tinfo.append(TrackPoint); } }//end for if(2 != m_Tinfo.size()) { return; } ui->m_XlineEdit->setText(QString::number(m_Tinfo[0].nXPos)); ui->M_YlineEdit->setText(QString::number(m_Tinfo[0].nYPos)); ui->m_WlineEdit->setText(QString::number(qAbs(m_Tinfo[1].nXPos - m_Tinfo[0].nXPos))); ui->m_HlineEdit->setText(QString::number(qAbs(m_Tinfo[1].nYPos - m_Tinfo[0].nYPos))); }
void ScatterWidget::doubleClickInit(AnimationItem *pItem) { if(!pItem) return; QList <QGraphicsItem *> items = pItem->childItems(); QGraphicsItem *group = NULL; int nCount = items.size(); int i = 0; QString sName = ""; int ikey = 0; m_Tinfo.clear(); QRectF rc; for(i = 0;i < nCount;i++) { group = items.at(i); sName = group->data(GROUP_NAME_KEY).toString(); ikey = group->type(); if(sName == tr("mMain")) //向量图控件 { // rc = group->boundingRect(); // ui->m_width->setValue(rc.width()); //初始化向量图的的宽度 // ui->m_height->setValue(rc.height());//初始化向量图的的高度 // iWidth = rc.width(); // iHeight = rc.height(); } else if(ikey == SAM_DRAW_OBJECT_ELIPSE) //记录每个点的位置 { QPointF pos = group->boundingRect().topLeft()+group->scenePos(); TrackPointInfo TrackPoint; TrackPoint.nXPos = pos.x(); TrackPoint.nYPos = pos.y(); m_Tinfo.append(TrackPoint); } }//end for ui->m_TrackspBox->setRange(0,m_Tinfo.size() - 1); for(i = 0;i < m_Tinfo.size();i++) { m_Tinfo[i].nOrbitId = i; } ui->m_TrackspBox->setValue(0); //初始化轨迹点 ui->m_xTracklineEdit->setText(QString::number(m_Tinfo.at(0).nXPos)); //初始化位置0的x坐标 ui->m_yTracklineEdit->setText(QString::number(m_Tinfo.at(0).nYPos));//初始化位置1的y坐标 }
void setPosTopLeft(QGraphicsItem* item, int x, int y) { // position item, @ x,y within the items' parent // coordinate system, treating the origin of the item // and the parent system at the top,left if (!item) return; QRectF pBounds, iBounds = item->boundingRect(); QGraphicsItem* p = item->parentItem(); if (p) { pBounds = p->boundingRect(); } x = x + pBounds.x() - iBounds.x(); y = y + pBounds.y() - iBounds.y(); item->setPos(x, y); }
void RotateTool::mousePressEvent(QGraphicsSceneMouseEvent *event) { QGraphicsItem * item = scene()->itemAt(event->buttonDownScenePos(Qt::LeftButton)); if (!item) return; if (item->type() == Atom::Type) item = item->parentItem(); if (item->type() == Bond::Type) item = item->parentItem(); QPointF rotatePoint = item->boundingRect().center(); QPointF rotatePointAbs = item->mapToScene(rotatePoint); m_rotationCenter = rotatePointAbs; m_rotationItem = item; m_lastRotationVect = event->buttonDownScenePos(Qt::LeftButton) - rotatePointAbs ; //save vector for relative rotation step }
QPoint Utils::getPopupPoint(QGraphicsScene *scene, QWidget *hostedWidget, QToolButton *button, QWidget *widget) { qreal x, y; QRectF sc, r0; QRect menuRect, buttonRect; QPoint p; CDiagram *diagram = NULL; QGraphicsView *v = NULL; QWidget *parent = NULL; CDiagramHostedWidget *hosted = NULL; QGraphicsItem *item = NULL; diagram = dynamic_cast<CDiagram*>(scene); hosted = dynamic_cast<CDiagramHostedWidget*>( hostedWidget ); parent = button->parentWidget(); if (!diagram || !widget || !parent || !hosted) return QPoint(); v = diagram->getMainView(); if (!v) return QPoint(); item = hosted->diagramWidget(); menuRect = widget->geometry(); buttonRect = button->geometry(); p = parent->mapTo(hostedWidget, button->pos()); sc = v->mapToScene(v->viewport()->geometry()).boundingRect(); r0 = item->mapToScene( item->boundingRect() ).boundingRect(); r0 = QRectF(r0.topLeft() + QPointF(p.x(), p.y()), QSizeF(buttonRect.width(), buttonRect.height())); // determine x if (sc.right() - menuRect.width() > r0.left()) x = r0.left(); else x = sc.right() - menuRect.width(); // determine y if (sc.bottom() - menuRect.height() > r0.bottom() ) y = r0.bottom(); else y = sc.bottom() - menuRect.height(); return v->mapToGlobal( v->mapFromScene( QPointF(x, y) ) ); }
void QGraphicsVolumeView::fitToImage(int sliceIdx, int volumeId) { if (_airImages != NULL && _airImages->Count() > 0) { // clear scene rect to recompute bounding box QRectF sceneRect = scene()->sceneRect(); if (_volumeDisplays.size() > 0) { QGraphicsItem* item = _volumeDisplays[0].GetSliceData<QGraphicsItem>(sliceIdx); QRectF viewport = item->boundingRect(); if (item != NULL) { if (sceneRect.width() > sceneRect.height()) { viewport.setHeight(sceneRect.height()); } else { viewport.setWidth(sceneRect.width()); } } fitInView(viewport, Qt::KeepAspectRatio); centerOn(item->pos().x() + viewport.width()/2, item->pos().y() + viewport.height()/2); } } }
void SceneInspector::sceneItemSelectionChanged(const QItemSelection &selection) { QModelIndex index; if (!selection.isEmpty()) index = selection.first().topLeft(); if (index.isValid()) { QGraphicsItem *item = index.data(SceneModel::SceneItemRole).value<QGraphicsItem *>(); QGraphicsObject *obj = item->toGraphicsObject(); if (obj) m_propertyController->setObject(obj); else m_propertyController->setObject(item, QStringLiteral("QGraphicsItem")); emit itemSelected(item->mapRectToScene(item->boundingRect())); } else { m_propertyController->setObject(nullptr); emit sceneChanged(); } }
void CSharedPainterScene::moveItem( boost::shared_ptr<CPaintItem> item, double x, double y ) { if( ! item ) return; if( ! item->drawingObject() ) return; clearLastItemBorderRect(); QGraphicsItem* i = reinterpret_cast<QGraphicsItem *>(item->drawingObject()); // freeze move changes notify i->setFlag( QGraphicsItem::ItemSendsGeometryChanges, false ); i->setPos( x, y ); // thaw move changes notify i->setFlag( QGraphicsItem::ItemSendsGeometryChanges, true ); invalidate( i->boundingRect() ); }
void Menu::moveVertically() { QList<QGraphicsItem *> items = this->items(); int sizeList = items.size(); QGraphicsItem * focusItem = this->focusItem(); QList<QGraphicsItem *>::const_iterator it = items.begin(); QList<QGraphicsItem *>::const_iterator tmpIt = it; int index = items.indexOf(focusItem); ++index; QRectF currentRectF = focusItem->boundingRect(); currentRectF.setHeight(this->getGeometry().height()); currentRectF.setWidth(currentRectF.width()); currentRectF.setX(currentRectF.x()); currentRectF.setY(0); int i = 0; bool haveRect = false; while (i < sizeList && haveRect == false) { index = ((index < sizeList) ? index : (index - sizeList)); tmpIt = it; tmpIt += index; haveRect = currentRectF.intersects((*tmpIt)->boundingRect()); ++index; ++i; } if (haveRect == true) { (*tmpIt)->setFocus(); } else { index = items.indexOf(focusItem) + 1; index = ((index < sizeList) ? index : (index - sizeList)); it += index; (*it)->setFocus(); } }
void ImageView::setGifAnimation(QString fileName) { /* the built-in gif reader gives the first frame, which won't be shown but is used for tracking position and dimensions */ image_ = QImage(fileName); if(image_.isNull()) { if(imageItem_) { imageItem_->hide(); imageItem_->setBrush(QBrush()); } scene_->setSceneRect(0, 0, 0, 0); } else { scene_->clear(); imageItem_ = nullptr; // it's deleted by clear(); if(gifMovie_) { delete gifMovie_; gifMovie_ = nullptr; } QPixmap pix(image_.size()); pix.fill(Qt::transparent); QGraphicsItem *gifItem = new QGraphicsPixmapItem(pix); QLabel *gifLabel = new QLabel(); gifMovie_ = new QMovie(fileName); QGraphicsProxyWidget* gifWidget = new QGraphicsProxyWidget(gifItem); gifLabel->setAttribute(Qt::WA_NoSystemBackground); gifLabel->setMovie(gifMovie_); gifWidget->setWidget(gifLabel); gifMovie_->start(); scene_->addItem(gifItem); scene_->setSceneRect(gifItem->boundingRect()); } if(autoZoomFit_) zoomFit(); queueGenerateCache(); // deletes the cache timer in this case }
dmz::QtCanvasObjectText * dmz::QtPluginCanvasObjectBasic::_create_text_item ( ObjectStruct &os, QGraphicsItem *parent, const Config &Data) { QtCanvasObjectText *item (new QtCanvasObjectText (parent)); ConfigIterator it; Config cd; while (Data.get_next_config (it, cd)) { const String DataName (cd.get_name ().to_lower ()); if (DataName == "text") { String text (config_to_string (cd)); item->set_text (text.get_buffer ()); } else if (DataName == "textcolor") { item->set_text_color (config_to_qcolor (cd)); } else if (DataName == "outlinecolor") { item->set_outline_color (config_to_qcolor (cd)); } else if (DataName == "backgroundcolor") { item->set_background_color (config_to_qcolor (cd)); } else if (DataName == "enablebackground") { item->enable_background (config_to_boolean ("value", cd, true)); } else if (DataName == "alignment") { String alignmentName (config_to_string (cd).to_lower ()); if (alignmentName == "center") { item->set_alignment (Qt::AlignCenter); } else if (alignmentName == "right") { item->set_alignment (Qt::AlignRight); } else { item->set_alignment (Qt::AlignLeft); } } else if (DataName == "max-length") { item->set_max_length (config_to_int32 ("value", cd)); } else if (DataName == "translate") { Vector vec (config_to_vector (cd)); String itemName = config_to_string ("name", cd); if (itemName) { QGraphicsItem *img = os.itemTable.lookup (itemName); if (img) { QRectF rect = img->boundingRect (); Vector rectVec; if (vec.get_x () == 0) { rectVec.set_x (0); } else if (vec.get_x() > 0) { rectVec.set_x (rect.center ().x ()); } else { rectVec.set_x (-rect.center ().x ()); } if (vec.get_y () == 0) { rectVec.set_y (0); } else if (vec.get_y () > 0) { rectVec.set_y (rect.center ().y ()); } else { rectVec.set_y (-rect.center ().y ()); } vec += rectVec; item->setPos (vec.get_x (), vec.get_y ()); } } else { item->translate (vec.get_x (), vec.get_y ()); } } else if (DataName == "scale") { Vector vec (config_to_vector (cd)); if (vec.get_x () && vec.get_y ()) { item->scale (vec.get_x (), vec.get_y ()); } } } return item; }
void SunMenuItemView::reinitializeDisplayedItemPosition() { qint32 maxWidth = width(); qint32 maxHeight; QGraphicsItem* gi = displayedItem()->graphicsItem(); //default gi->resetTransform(); // Calculate maxHeight as smaller chord(only for small sweepLengths) if (sweepLength() <= 90) { qreal biggerChord = 2 * (innerRadius() + maxWidth) * /*qAbs*/(qSin((M_PI / 180) * sweepLength() / 2)); qreal smallerChord = 2 * innerRadius() * /*qAbs*/(qSin((M_PI / 180) * sweepLength() / 2)); maxHeight = (0.2 * smallerChord + 1.4 * biggerChord) / 2; } else maxHeight = displayedItem()->maximumHeight(); //hide item if it too small if (maxWidth < 10 || maxHeight < 5) { gi->hide(); return; } QRectF graphicsItemRect; if (sweepLength() == 360 && innerRadius() == 0) { displayedItem()->setMaximumSize(2 * maxWidth /*diameter*/, maxHeight); graphicsItemRect = gi->boundingRect(); gi->setPos(-graphicsItemRect.width() / 2, -graphicsItemRect.height() / 2); gi->show(); return; } displayedItem()->setMaximumSize(maxWidth - 10, maxHeight); graphicsItemRect = gi->boundingRect(); ///////////////////////////////////////////////////////////////////////////////// //positioning mDisplayedItem (rotation and coordinates). qreal rotationAngle = startAngle() + sweepLength() / 2; // Getting distance and angle (polar coordinates) + some centering adjustments // We assume that (0,0) item's coordinate is it's top left corner //(like QGraphicsSimpleTextItem and QGraphicsProxyWidget). qreal angle, distance; if (rotationAngle >= 270 || rotationAngle <= 90) { distance = innerRadius() + maxWidth / 2 - graphicsItemRect.width() / 2; angle = rotationAngle + (180 / M_PI) * qAtan(graphicsItemRect.height() / (2 * distance)); } else { distance = innerRadius() + maxWidth / 2 + graphicsItemRect.width() / 2; angle = rotationAngle - (180 / M_PI) * qAtan(graphicsItemRect.height() / (2 * distance)); rotationAngle -= 180; } gi->setPos(distance * qCos((M_PI / 180) * angle), -distance * qSin((M_PI / 180) * angle)); gi->setRotation(-rotationAngle); //minus - because this function rotates clockwise. gi->show(); /////////////////////////////////////////////////////////////////////////////////// }
void PSV_TreeItem::paintLine(const QLineF &parentVLine, PSV_TreeItemData *itemData) { if(itemData == NULL) { return; } QPointF point2 = parentVLine.p2(); QList<PSV_TreeItemData*> children = itemData->children(); int leafCount = itemData->leafCount(); int count = children.count(); QPen pen; pen.setColor(QColor(Qt::red)); QPen pen_vLine; pen_vLine.setColor(QColor(Qt::blue)); QPen pen_hLine; QString tempText = itemData->text().trimmed(); QString text; for(int i = 0; i < tempText.length(); ++i) { text.append(tempText.at(i)); if(i != tempText.length() - 1) { text.append("\n"); } } QGraphicsItem* nodeItem = new QGraphicsEllipseItem(QRectF(0,0,1,1),this); nodeItem->setToolTip(tempText); QSizeF size = nodeItem->boundingRect().size(); nodeItem->setPos(point2.x() - size.width() * 0.5,point2.y() - size.height() * 0.5); QRectF rect = QRectF(nodeItem->pos().x(),nodeItem->pos().y(),size.width(),size.height()); // QGraphicsRectItem* rectItem = new QGraphicsRectItem(rect,this); // rectItem->setPen(pen); if(parentVLine.length() > PSV_ZEOR) { QLineF line = parentVLine; line.setP2(QPointF(line.x2(),rect.top())); QGraphicsLineItem* item = new QGraphicsLineItem(line,this); PSV_NOUSED(item); } if(count > 0) { QLineF leftHLine(point2.x() - leafCount * 0.5 * m_dw ,point2.y() ,rect.left() ,point2.y()); QLineF rightHLine(rect.right() ,point2.y() ,point2.x() + leafCount * 0.5 * m_dw ,point2.y()); double curX1 = leftHLine.x1(); for(int i = 0; i < count; ++i) { PSV_TreeItemData* tempItemData = children.at(i); int tempLeafCount = tempItemData->leafCount(); curX1 += tempLeafCount * 0.5 * m_dw; if(i == 0) { leftHLine.setP1(QPointF(curX1,leftHLine.y1())); } if(i == count - 1) { rightHLine.setP2(QPointF(curX1,leftHLine.y2())); } double y1 = point2.y(); double y2 = point2.y() + tempItemData->distance() * m_dhRatio; if(curX1 > rect.left() && curX1 < rect.right()) { y1 = rect.bottom(); } QLineF lineV(curX1,y1,curX1,y2); curX1 += tempLeafCount * 0.5 * m_dw; paintLine(lineV,tempItemData); } if(count > 1) { QGraphicsLineItem* leftHLineItem = new QGraphicsLineItem(leftHLine,this); leftHLineItem->setPen(pen_hLine); QGraphicsLineItem* rightHLineItem = new QGraphicsLineItem(rightHLine,this); rightHLineItem->setPen(pen_hLine); } } }
void QGraphicsSpriteItem::snap() { QVector < QGraphicsSpriteItem* > items = ((QScene*)scene())->items(); QGraphicsItem* hor = 0, * ver = 0; int horDist = 1e9, horType = 0, verDist = 1e9, verType = 0; for (int i = 0; i < items.size(); i++) { if (items[i] == this) continue; if ((x() + snapRadius >= items[i]->x() && x() <= items[i]->x() + items[i]->boundingRect().width() + snapRadius) || (x() + boundingRect().width() + snapRadius >= items[i]->x() && x() + boundingRect().width() <= items[i]->x() + items[i]->boundingRect().width() + snapRadius)) { if (qAbs(y() - items[i]->y()) <= horDist) hor = items[i], horDist = qAbs(y() - items[i]->y()), horType = 0; if (qAbs(y() + boundingRect().height() - items[i]->y()) <= horDist) hor = items[i], horDist = qAbs(y() + boundingRect().height() - items[i]->y()), horType = 1; if (qAbs(y() + boundingRect().height() - items[i]->y() - items[i]->boundingRect().height()) <= horDist) hor = items[i], horDist = qAbs(y() + boundingRect().height() - items[i]->y() - items[i]->boundingRect().height()), horType = 2; if (qAbs(y() - items[i]->y() - items[i]->boundingRect().height()) <= horDist) hor = items[i], horDist = qAbs(y() - items[i]->y() - items[i]->boundingRect().height()), horType = 3; } if ((y() + snapRadius >= items[i]->y() && y() <= items[i]->y() + items[i]->boundingRect().height() + snapRadius) || (y() + boundingRect().height() + snapRadius >= items[i]->y() && y() + boundingRect().height() <= items[i]->y() + items[i]->boundingRect().height() + snapRadius)) { if (qAbs(x() - items[i]->x()) <= verDist) ver = items[i], verDist = qAbs(x() - items[i]->x()), verType = 0; if (qAbs(x() + boundingRect().width() - items[i]->x()) <= verDist) ver = items[i], verDist = qAbs(x() + boundingRect().width() - items[i]->x()), verType = 1; if (qAbs(x() + boundingRect().width() - items[i]->x() - items[i]->boundingRect().width()) <= verDist) ver = items[i], verDist = qAbs(x() + boundingRect().width() - items[i]->x() - items[i]->boundingRect().width()), verType = 2; if (qAbs(x() - items[i]->x() - items[i]->boundingRect().width()) <= verDist) ver = items[i], verDist = qAbs(x() - items[i]->x() - items[i]->boundingRect().width()), verType = 3; } } if (hor && horDist <= snapRadius) { if (horType == 0) setPos(x(), hor->y()); if (horType == 1) setPos(x(), hor->y() - boundingRect().height()); if (horType == 2) setPos(x(), hor->y() + hor->boundingRect().height() - boundingRect().height()); if (horType == 3) setPos(x(), hor->y() + hor->boundingRect().height()); } if (ver && verDist <= snapRadius) { if (verType == 0) setPos(ver->x(), y()); if (verType == 1) setPos(ver->x() - boundingRect().width(), y()); if (verType == 2) setPos(ver->x() + ver->boundingRect().width() - boundingRect().width(), y()); if (verType == 3) setPos(ver->x() + ver->boundingRect().width(), y()); } }
SEXP qt_qboundingRect_QGraphicsItem(SEXP rself) { QGraphicsItem *item = unwrapQGraphicsItem(rself, QGraphicsItem); return asRRectF(item->boundingRect()); }
void CustomGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* _event) { // // Обработку производим только после перемещения мыши // if (m_afterMoving) { // // 1. Перемещение карточки на связь // QList<Shape*> selected = selectedShapes(); CardShape* selectedCard = nullptr; ArrowFlow* selectedFlow = nullptr; if (selected.size() == 2) { if (dynamic_cast<CardShape*>(selected.first())) { selectedCard = dynamic_cast<CardShape*>(selected.first()); selectedFlow = dynamic_cast<ArrowFlow*>(selected.last()); } else { selectedCard = dynamic_cast<CardShape*>(selected.last()); selectedFlow = dynamic_cast<ArrowFlow*>(selected.first()); } // // Если это действительно перемещение карточки на связь // if (selectedCard != nullptr && selectedFlow != nullptr && selectedFlow->startShape() != selectedCard && selectedFlow->endShape() != selectedCard) { // // Изымаем карточку из сцены // takeShape(selectedCard); // // Определяем элементы к которым теперь будет присоединена карточка // CardShape* previousCard = dynamic_cast<CardShape*>(selectedFlow->startShape()); CardShape* nextCard = dynamic_cast<CardShape*>(selectedFlow->endShape()); // // Заменяем старую связь на новые // removeShape(selectedFlow); appendShape(new ArrowFlow(previousCard, selectedCard)); if (hasCards(selectedCard)) { appendShape(new ArrowFlow(lastCard(selectedCard), nextCard)); } else { appendShape(new ArrowFlow(selectedCard, nextCard)); } // // Меняем порядок следования фигур // insertShape(selectedCard, previousCard); // // Если предыдущая карточка вложена в группирующий элемент // QGraphicsItem* previousParentItem = previousCard->parentItem(); QGraphicsItem* nextParentItem = nextCard->parentItem(); bool handled = false; if (previousParentItem != nullptr) { const QRectF selectedCardRect = selectedCard->mapToScene(selectedCard->boundingRect()).boundingRect(); const QRectF parentCardRect = previousParentItem->mapToScene(previousParentItem->boundingRect()).boundingRect(); // // ... и если текущая карточка тоже помещена внутрь группирующего элемента // if (parentCardRect.contains(selectedCardRect)) { // // ... поместим её внутрь // const QPointF lastPos = selectedCard->scenePos(); selectedCard->setParentItem(previousParentItem); selectedCard->setPos(previousParentItem->mapFromScene(lastPos)); handled = true; } } // // Если следующая карточка вложена в группирующий элемент // if (!handled && nextParentItem != nullptr) { const QRectF selectedCardRect = selectedCard->mapToScene(selectedCard->boundingRect()).boundingRect(); const QRectF parentCardRect = nextParentItem->mapToScene(nextParentItem->boundingRect()).boundingRect(); // // ... и если текущая карточка тоже помещена внутрь группирующего элемента // if (parentCardRect.contains(selectedCardRect)) { // // ... поместим её внутрь // const QPointF lastPos = selectedCard->scenePos(); selectedCard->setParentItem(nextParentItem); selectedCard->setPos(nextParentItem->mapFromScene(lastPos)); handled = true; } } // // Если не удалось вложить, то убираем родителя у элемента // if (!handled && selectedCard->parentItem() != nullptr) { const QPointF lastPos = selectedCard->scenePos(); selectedCard->setParentItem(nullptr); selectedCard->setPos(lastPos); } } } // // 2. Обработка вложения и вытаскивания элементов из групп сцен и папок // selected = selectedShapes(); if (selected.size() == 1) { selectedCard = dynamic_cast<CardShape*>(selected.first()); if (selectedCard != nullptr) { // // Определим, есть ли группирующий элемент, помеченный на вложение // CardShape* parentCard = nullptr; for (Shape* shape : shapes()) { if (CardShape* card = dynamic_cast<CardShape*>(shape)) { if (card->isOnInstertionState()) { parentCard = card; break; } } } // // Если это перемещение карточки внутри своего родителя, просто снимем режим выделения // if (parentCard != nullptr && selectedCard->parentItem() == parentCard) { parentCard->setOnInstertionState(false); } // // В противном случае // else { // // Вложение // if (parentCard != nullptr) { // // Изымаем карточку из сцены // takeShape(selectedCard); // // Если у группирующего элемента есть дети, то связываем с последней карточкой // if (hasCards(parentCard)) { // // Определяем элементы к которым теперь будет присоединена карточка // CardShape* previousCard = dynamic_cast<CardShape*>(lastCard(parentCard)); Flow* previousCardFlow = cardFlow(previousCard, CARD_ON_FLOW_START); if (previousCardFlow != nullptr) { CardShape* nextCard = dynamic_cast<CardShape*>(previousCardFlow->endShape()); // // Заменяем старую связь на новые // removeShape(previousCardFlow); if (hasCards(selectedCard)) { appendShape(new ArrowFlow(lastCard(selectedCard), nextCard)); } else { appendShape(new ArrowFlow(selectedCard, nextCard)); } } appendShape(new ArrowFlow(previousCard, selectedCard)); // // Меняем порядок следования фигур // insertShape(selectedCard, previousCard); } // // Если детей нет, то связываем непосредственно с группирующим элементом // else { // // Определяем элементы к которым теперь будет присоединена карточка // CardShape* previousCard = parentCard; Flow* previousCardFlow = cardFlow(previousCard, CARD_ON_FLOW_START); if (previousCardFlow != nullptr) { CardShape* nextCard = dynamic_cast<CardShape*>(previousCardFlow->endShape()); // // Заменяем старую связь на новые // removeShape(previousCardFlow); if (hasCards(selectedCard)) { appendShape(new ArrowFlow(lastCard(selectedCard), nextCard)); } else { appendShape(new ArrowFlow(selectedCard, nextCard)); } } appendShape(new ArrowFlow(previousCard, selectedCard)); // // Меняем порядок следования фигур // insertShape(selectedCard, previousCard); } // // Назначаем нового родителя // const QPointF lastPos = selectedCard->scenePos(); selectedCard->setParentItem(parentCard); selectedCard->setPos(parentCard->mapFromScene(lastPos)); parentCard->setOnInstertionState(false); } // // Вытаскивание - соединяем с последней карточкой в сценарии // else if (selectedCard->parentItem() != nullptr) { // // Изымаем карточку из сцены // takeShape(selectedCard); // // Определяем элемент к которому теперь будет присоединена карточка // CardShape* previousCard = dynamic_cast<CardShape*>(lastCard()); // // Добавляем связь // appendShape(new ArrowFlow(previousCard, selectedCard)); // // Меняем порядок следования фигур // insertShape(selectedCard, previousCard); // // Убираем родителя // const QPointF lastPos = selectedCard->scenePos(); selectedCard->setParentItem(nullptr); selectedCard->setPos(lastPos); } } } } } update(); QGraphicsScene::mouseReleaseEvent(_event); m_afterMoving = false; }
//确定按钮的事件 void QMultiCopy::on_OK_clicked() { // QPLC_Struct *PLC_P=NULL; QList<QGraphicsItem *> selList=pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->selectedItems(); if(selList.size()!=1)//选择多个或者没有 { accept(); return; } else{ DrawItemToScene CopyFun; int nItemWidth=0; int nItemHeight=0; if(ui->Overlap->isChecked()) { nItemWidth=0; nItemHeight=0; } else { nItemWidth=selList.at(0)->boundingRect().width(); nItemHeight=selList.at(0)->boundingRect().height(); } qreal bottom;//基准控件的底边界值 qreal right;//基准控件的右边界值 int nColumn=ui->Column->value();//行数 int nColumn_Interval=ui->Column_Interval->value();//行间隔 int nRow=ui->Row->value();//列数 int nRow_Interval=ui->Row_Interval->value();//列间隔 qreal scence_h=pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->sceneRect().height(); qreal scence_w=pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->sceneRect().width(); QGraphicsItem * pCopyTem = NULL; QGraphicsItem * pTem = NULL; QList<QGraphicsItem *> addItemsList; CopyFun.CopyItem(&pCopyTem,selList.at(0)); if(R_Alignment_Group->checkedId() == 1)//默认情况下,选中的是向右递增 { for(int j=0;j<nRow;j++) { for(int i=0;i<nColumn-1;i++) { if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { right=pCopyTem->sceneBoundingRect().right(); } else { right=pCopyTem->boundingRect().right(); } qreal item_x=right+(i+1)*(nColumn_Interval+nItemWidth);//计算边界值是否越界 if(item_x>scence_w)//若复制的大小越界的话 {//退出循环 break; } CopyFun.CopyItem(&pTem,pCopyTem); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pTem); addItemsList.push_back(pTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pTem->setPos(pTem->sceneBoundingRect().topLeft().x()+(nItemWidth+nColumn_Interval)*(i+1), pTem->sceneBoundingRect().topLeft().y()); } else { pTem->setPos((nItemWidth+nColumn_Interval)*(i+1),0); } pTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); pTem=NULL; } if(j<nRow-1) { qreal item_y; // int hight=pCopyTem->sceneBoundingRect().height(); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { bottom=pCopyTem->sceneBoundingRect().bottom(); item_y=bottom+(nRow_Interval+nItemHeight);//计算边界值是否越界 } else { bottom=pCopyTem->boundingRect().bottom(); item_y=bottom+(nRow_Interval+nItemHeight)*(j+1);//计算边界值是否越界 } if(item_y>scence_h)//若复制的大小越界的话 {//退出循环 break; } CopyFun.CopyItem(&pCopyTem,selList.at(0)); //MuCopyList(*pCopyTem,CopyCount,NormKeyboardstr); //pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->setNewItem_ID(pCopyTem,NouseItem ); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pCopyTem); addItemsList.push_back(pCopyTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pCopyTem->setPos(pCopyTem->sceneBoundingRect().topLeft().x(),(nItemHeight+nRow_Interval)*(j+1)+ pCopyTem->sceneBoundingRect().topLeft().y()); } else { pCopyTem->setPos(0,(nItemHeight+nRow_Interval)*(j+1)); } pCopyTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pCopyTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); //pwnd->AndTreeSubItem(pCopyTem); //pwnd->upDatetreeScreenItem();//更新画面的子项 } } } else if(R_Alignment_Group->checkedId() == 2)//选中的是向下递增 { for(int i=0;i<nColumn;i++) { for(int j=0;j<nRow-1;j++) { if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { bottom=pCopyTem->sceneBoundingRect().bottom(); } else { bottom=pCopyTem->boundingRect().bottom(); } qreal item_y=bottom+(j+1)*(nRow_Interval+nItemHeight);//计算边界值是否越界 // 若复制的大小越界的话 if(item_y>scence_h) break; CopyFun.CopyItem(&pTem,pCopyTem); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pTem); addItemsList.push_back(pTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pTem->setPos(pTem->sceneBoundingRect().topLeft().x(),(nItemHeight+nRow_Interval)*(j+1)+ pTem->sceneBoundingRect().topLeft().y()); } else { pTem->setPos(0,(nItemHeight+nRow_Interval)*(j+1)); } pTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); pTem=NULL; } if(i<nColumn-1) { qreal item_x; if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { right=pCopyTem->sceneBoundingRect().right(); item_x=right+(nColumn_Interval+nItemWidth);//计算边界值是否越界 } else { right=pCopyTem->boundingRect().right(); item_x=right+(i+1)*(nColumn_Interval+nItemWidth);//计算边界值是否越界 } //若复制的大小越界的话 if(item_x>scence_w) break; CopyFun.CopyItem(&pCopyTem,selList.at(0)); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pCopyTem); addItemsList.push_back(pCopyTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pCopyTem->setPos(pCopyTem->sceneBoundingRect().topLeft().x()+(nItemWidth+nColumn_Interval)*(i+1), pCopyTem->sceneBoundingRect().topLeft().y()); } else { pCopyTem->setPos((nItemWidth+nColumn_Interval)*(i+1),0); } pCopyTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pCopyTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); } } } if(ui->if_Increse_Address->isChecked()) { //设置地址增加 QList<QGraphicsItem *> itemList = addItemsList; qDebug() << "multiCopy size ----"<< itemList.size(); setMulitAddrs(itemList,selList.at(0)); } pwnd->undoStack->push(new multiCopyCommand(pwnd->pSceneSheet[pwnd->nActiveSheetIndex],addItemsList,selList[0],true)); } pwnd->PreviewWindow(); accept(); }
void Canvas::mousePressEvent(QMouseEvent *event) { if(event->buttons() & Qt::LeftButton) { if(enableFill) { AbstractShape * tmp = currentShape(); if(tmp->isUnderMouse()) { tmp->setBrush(QBrush(color())); currentScene->update(); } } else { QPointF point = mapToScene(event->pos()); _startX = point.x(); _startY = point.y(); QGraphicsItem * item = currentShape(); QPointF p = event->pos(); QRectF r = item->boundingRect(); QPointF tl = mapFromScene(r.topLeft()); QPointF br = mapFromScene(r.bottomRight()); QPointF tr = mapFromScene(r.topRight()); QPointF bl = mapFromScene(r.bottomLeft()); checkIfProperRect(tl, br, tr, bl); if(belongToFirstCorners(p, tl, br)) { _direction = None; _normalize = NormalizeLeft; } /*else if(belongToSecondCorners(p, tl, br)) { _direction = None; _normalize = NormalizeRight; }*/ else if((p.x() <= tl.x() && p.x() > tl.x() - 3) && p.y() > tl.y() - 3 && p.y() < br.y()) { _direction = Left; _startY = r.topLeft().y(); } else if((p.x() > br.x() - 3 && p.x() <= br.x()) && p.y() > tl.y() - 3 && p.y() < br.y()) { _direction = Right; _startX = r.topLeft().x(); _startY = r.topLeft().y(); _endY = r.bottomRight().y(); } else if((p.y() <= tl.y() && p.y() > tl.y() - 3) && p.x() > tl.x() - 3 && p.x() < br.x()) { _direction = Top; _startX = r.topLeft().x(); } else if((p.y() > br.y() - 3 && p.y() <= br.y()) && p.x() > tl.x() - 3 && p.x() < br.x()) { _direction = Bottom; _startX = r.topLeft().x(); _startY = r.topLeft().y(); _endX = r.bottomRight().x(); } else if(p.x() >= tl.x() && p.x() <= br.x() && p.y() >= tl.y() && p.y() <= br.y()) { _direction = None; isMoved = true; _startX = item->boundingRect().topLeft().x(); _startY = item->boundingRect().topLeft().y(); _endX = item->boundingRect().bottomRight().x(); _endY = item->boundingRect().bottomRight().y(); coordinatesIterationMove = event->pos(); linesEnds.clear(); linesStarts.clear(); linePointIndexes.clear(); for(auto & i : currentScene->lines) { if(i->boundingRect().intersects(currentShape()->boundingRect())) { QPointF tl = i->boundingRect().topLeft(); QPointF br = i->boundingRect().bottomRight(); if(currentShape()->boundingRect().contains(br) && !currentShape()->boundingRect().contains(tl)) { linesEnds.append(br.toPoint()); linesStarts.append(tl.toPoint()); linePointIndexes.append(currentScene->lines.indexOf(i)); } else if(currentShape()->boundingRect().contains(tl) && !currentShape()->boundingRect().contains(br)) { linesEnds.append(tl.toPoint()); linesStarts.append(br.toPoint()); linePointIndexes.append(currentScene->lines.indexOf(i)); } } } } else { _direction = None; currentScene->edge()->hide(); if(point.x() > sceneRect().topLeft().x() && point.y() > sceneRect().topLeft().y() && point.x() < sceneRect().bottomRight().x() && point.y() < sceneRect().bottomRight().y()) { enableResize = false; buttonPressed = true; if(shapeDrawn) { notifyObservers(); } } } } } }