void SkeletonCanvasView::contentsMousePressEvent( QMouseEvent *e ) { // a list of all items underneath the mouse when it was pressed QCanvasItemList list = canvas()->collisions(e->pos()); // the RTTI of a QCanvasSprite is 1... if ( !list.isEmpty() && list.first()->rtti() == 1 ) { // ...which means we can safely cast to a Bone pointer. Bone *sphere = (Bone*)list.first(); // hit() will return false it we hit the transparent corners // of the planet image. if ( sphere->hit( e->pos() ) ) { Moving = sphere; canvas()->setAdvancePeriod( -1 ); // stops the animation when dragging MovingStart = e->pos(); Moving->setZ( 2 ); // raises the current item above other items when dragging. // (This in not really necessary here, since we have just one item.) Timer->start( 10, false ); // start the timer } } }
QCanvasItem * UmlCanvas::collision(const QPoint & p, int except) const { QCanvasItemList l = collisions(p); QCanvasItemList::ConstIterator it; QCanvasItemList::ConstIterator end = l.end(); ArrowCanvas * arrow = 0; for (it = l.begin(); it != end; ++it) if (((*it)->visible()) && // at least not deleted !isa_alien(*it) && !isa_col_msg_dirs(*it)) { int k = (*it)->rtti(); if (k != except) { switch (k) { case RTTI_ARROW: if (arrow == 0) arrow = (ArrowCanvas *) *it; break; case RTTI_LABEL: return (arrow == 0) ? *it : arrow; default: // isa DiagramCanvas return ((arrow == 0) || (small_element(((DiagramCanvas *) *it)->rect()) && ((DiagramCanvas *) *it)->attached_to(arrow))) ? *it : arrow; } } } return arrow; }
void Canvas::redraw() { QCanvasItemList l = m_canvas->allItems(); for(QCanvasItemList::iterator i = l.begin(), e = l.end(); i != e; ++i) { delete *i; } unsigned count = 0; for (unsigned x = 10; x < 4*1600; x += 20) for (unsigned y = 10; y < 600; y += 20) { QCanvasRectangle* r = new QCanvasRectangle(x, y, 10, 10, m_canvas); r->setPen(m_pen); r->setBrush(m_brushes[m_current_brush]); r->show(); ++count; QCanvasText* t = new QCanvasText("D", m_canvas); t->move(x, y); t->show(); ++count; } (new QCanvasText(QString::number(count), m_canvas))->show(); m_canvas->setAllChanged(); }
void ItemDocument::select(const QCanvasItemList &list) { const QCanvasItemList::const_iterator end = list.end(); for (QCanvasItemList::const_iterator it = list.begin(); it != end; ++it) selectList()->addQCanvasItem(*it); selectList()->setSelected(true); }
void k9MenuEditor::clear() { QCanvasItemList list = canvas()->allItems(); QCanvasItemList::Iterator it = list.begin(); for (; it != list.end(); ++it) { if ( *it ) delete *it; } }
void KviCanvasView::contentsMouseMoveEvent(QMouseEvent *e) { // QPoint p = inverseWorldMatrix().map(e->pos()); QPoint p = e->pos(); if(e->state() & Qt::LeftButton) { if((m_dragMode != None) && (m_pSelectedItem)) { if(m_pSelectedItem->isEnabled())m_pSelectedItem->setEnabled(false); switch(KVI_CANVAS_RTTI_CONTROL_TYPE(m_pSelectedItem)) { case KVI_CANVAS_RTTI_CONTROL_TYPE_RECTANGLE: dragRectangle((KviCanvasRectangleItem *)m_pSelectedItem,p); break; case KVI_CANVAS_RTTI_CONTROL_TYPE_LINE: dragLine((KviCanvasLine *)m_pSelectedItem,p); break; case KVI_CANVAS_RTTI_CONTROL_TYPE_POLYGON: dragPolygon((KviCanvasPolygon *)m_pSelectedItem,p); break; } } } else { // Without buttons if(m_state == Idle) { QCanvasItemList l = canvas()->collisions(p); QCanvasItemList::Iterator it = l.begin(); if(it != l.end()) { // Got an item QCanvasItem * hit = (QCanvasItem *)*it; // Now find the point on that we have clicked it if(hit == m_pSelectedItem) { switch(KVI_CANVAS_RTTI_CONTROL_TYPE(m_pSelectedItem)) { case KVI_CANVAS_RTTI_CONTROL_TYPE_RECTANGLE: beginDragRectangle((KviCanvasRectangleItem *)m_pSelectedItem,p); break; case KVI_CANVAS_RTTI_CONTROL_TYPE_LINE: beginDragLine((KviCanvasLine *)m_pSelectedItem,p); break; case KVI_CANVAS_RTTI_CONTROL_TYPE_POLYGON: beginDragPolygon((KviCanvasPolygon *)m_pSelectedItem,p); break; } } else if(m_dragMode != None)setCursor(arrowCursor); } else { if(m_dragMode != None)setCursor(arrowCursor); } } } }
void ItemDocument::setSVGExport(bool svgExport) { // Find any items and tell them not to draw buttons or sliders QCanvasItemList items = m_canvas->allItems(); const QCanvasItemList::iterator end = items.end(); for (QCanvasItemList::Iterator it = items.begin(); it != end; ++it) { if (CNItem * cnItem = dynamic_cast<CNItem*>(*it)) cnItem->setDrawWidgets(!svgExport); } }
void KviCanvasView::contentsMousePressEvent(QMouseEvent *e) { if(e->button() & Qt::LeftButton) { // QPoint p = inverseWorldMatrix().map(e->pos()); QPoint p = e->pos(); switch(m_state) { case SelectOrigin: clearSelection(); setCursor(arrowCursor); m_state = Idle; insertObjectAt(p,m_objectToInsert); canvas()->update(); break; case Idle: { QCanvasItemList l = canvas()->collisions(p); QCanvasItemList::Iterator it = l.begin(); if(it != l.end()) { // Got an item QCanvasItem * hit = *it; if(hit != m_pSelectedItem) { // Was not selected yet setItemSelected(hit); canvas()->update(); } // Now find the point on that we have clicked it switch(KVI_CANVAS_RTTI_CONTROL_TYPE(hit)) { case KVI_CANVAS_RTTI_CONTROL_TYPE_RECTANGLE: beginDragRectangle(((KviCanvasRectangleItem *)hit),p); break; case KVI_CANVAS_RTTI_CONTROL_TYPE_LINE: beginDragLine(((KviCanvasLine *)hit),p); break; case KVI_CANVAS_RTTI_CONTROL_TYPE_POLYGON: beginDragPolygon(((KviCanvasPolygon *)hit),p,e->state() & Qt::ShiftButton,e->state() & Qt::ControlButton); break; } } else { // No item clearSelection(); canvas()->update(); } } break; } } }
void CanvasView::contentsMousePressEvent( QMouseEvent *e ) { QCanvasItemList list = canvas()->collisions( e->pos() ); for ( QCanvasItemList::iterator it = list.begin(); it != list.end(); ++it ) if ( (*it)->rtti() == CanvasText::CANVAS_TEXT ) { m_movingItem = *it; m_pos = e->pos(); return; } m_movingItem = 0; }
void KTreemapView::deleteAllItems( QCanvas * canvas ) { if ( ! canvas ) return; QCanvasItemList all = canvas->allItems(); for ( QCanvasItemList::Iterator it = all.begin(); it != all.end(); ++it ) delete *it; }
int LinePath::onLinePath( const QPoint &position ) { QCanvasItemList list = getCanvas() -> collisions( position ); int index = -1; QCanvasItemList::iterator end(list.end()); for(QCanvasItemList::iterator item_it(list.begin()); item_it != end; ++item_it ) { if( ( index = m_LineList.findRef( (QCanvasLine*)*item_it ) ) != -1 ) break; }//end for return index; }
void SpielFeldView::showGame() { QCanvasItemList list = canvas()->allItems(); QCanvasItemList::Iterator it = list.begin(); for(; it != list.end(); ++it) { (*it)->show(); } _canvas->setAllChanged(); _canvas->update(); }
void ossimQtVceCanvasWidget::selectItems(QCanvasItemList& selectionList) { if(selectionList.size()) { for(int idx = 0; idx < (int)selectionList.size(); ++idx) { theSelectedItems.push_back(selectionList[idx]); selectionList[idx]->setSelected(true); emit itemSelected(selectionList[idx]); } } }
void ScheduleDialog::clearCanvas() { QCanvasItemList::iterator it; QCanvasItemList canvasItems = canvas->allItems(); for (it = canvasItems.begin(); it != canvasItems.end(); ++it) { delete *it; } canvasItems = labelCanvas->allItems(); for (it = canvasItems.begin(); it != canvasItems.end(); ++it) { delete *it; } }
void SpielFeldView::timerDone() { QCanvasItemList list = canvas()->allItems(); QCanvasItemList::Iterator it = list.begin(); for(; it != list.end(); ++it) { if((*it)->rtti() == RTTI_FLAMME) { (*it)->hide(); _canvas->update(); delete (*it); } } }
void CNavigationDiagramView::contentsMousePressEvent(QMouseEvent * e){ QWMatrix matrix = inverseWorldMatrix(); int xPos = matrix.m11() * e->pos().x() + matrix.m12() * e->pos().y(); int yPos = matrix.m21() * e->pos().x() + matrix.m22() * e->pos().y(); QPoint p(xPos, yPos); QCanvasItemList items = canvas()->collisions(p); if (items.empty()){ setActiveItem(0); }else{ setActiveItem(*items.begin()); } m_qLastPos = e->pos(); }
void SpielFeldView::removeItem(int atx, int aty) { // cout << "removeItem(" << atx << "," << aty << ");" << endl; QCanvasItemList list = canvas()->allItems(); QCanvasItemList::Iterator it = list.begin(); for(; it != list.end(); ++it) { if( ((*it)->x() == atx*FIELD_WIDTH) && ((*it)->y() == aty*FIELD_WIDTH) && ((*it)->rtti() != RTTI_FIGUR) && ((*it)->rtti() != RTTI_FLAMME)) { delete (*it); } } }
void ReportSection::buildXML(QDomDocument & doc, QDomElement & section) { //qDebug("ReportSection::buildXML()"); float f = (float)canvas->height() / dpiY * 100.0; f = ((f - (int)f) > .5 ? (int)f : (int)f + 1); QDomElement height = doc.createElement("height"); height.appendChild(doc.createTextNode(QString::number((int)f))); section.appendChild(height); // now get a list of all the QCanvasItems on this canvas and output them. QCanvasItemList list = canvas->allItems(); for(QCanvasItemList::iterator it = list.begin(); it != list.end(); it++ ) { ReportEntity::buildXML((*it),doc,section); } }
void DiagramView::contentsMousePressEvent(QMouseEvent *event) { if (event->button() == LeftButton && pendingItem) { pendingItem->move(event->pos().x(), event->pos().y()); showNewItem(pendingItem); pendingItem = 0; unsetCursor(); } else { QCanvasItemList items = canvas()->collisions(event->pos()); if (items.empty()) setActiveItem(0); else setActiveItem(*items.begin()); } lastPos = event->pos(); }
KTreemapTile * KTreemapView::tileAt( QPoint pos ) { KTreemapTile * tile = 0; QCanvasItemList coll = canvas()->collisions( pos ); QCanvasItemList::Iterator it = coll.begin(); while ( it != coll.end() && tile == 0 ) { tile = dynamic_cast<KTreemapTile *> (*it); ++it; } return tile; }
bool UmlCanvas::already_drawn(BrowserNode * bn) { QCanvasItemList all = allItems(); QCanvasItemList::Iterator cit; UmlCode k = bn->get_type(); for (cit = all.begin(); cit != all.end(); ++cit) { if ((*cit)->visible()) { DiagramItem * di = QCanvasItemToDiagramItem(*cit); if ((di != 0) && (di->type() == k) && (di->get_bn() == bn)) return TRUE; } } return FALSE; }
void Floater::moveBy(double dx, double dy) { if (!isEnabled()) return; QCanvasItemList l = collisions(false); for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { CanvasItem *item = dynamic_cast<CanvasItem *>(*it); if (!noUpdateZ && item && item->canBeMovedByOthers()) item->updateZ(this); if ((*it)->z() >= z()) { if (item && item->canBeMovedByOthers() && collidesWith(*it)) { if ((*it)->rtti() == Rtti_Ball) { //((Ball *)(*it))->setState(Rolling); (*it)->moveBy(dx, dy); if (game && game->hasFocus() && !game->isEditing() && game->curBall() == (Ball *)(*it)) game->ballMoved(); } else if ((*it)->rtti() != Rtti_Putter) (*it)->moveBy(dx, dy); } } } point->dontMove(); point->move(x() + width(), y() + height()); // this call must come after we have tested for collisions, otherwise we skip them when saving! // that's a bad thing QCanvasRectangle::moveBy(dx, dy); // because we don't do Bridge::moveBy(); topWall->move(x(), y()); botWall->move(x(), y() - 1); leftWall->move(x(), y()); rightWall->move(x(), y()); if (game && game->isEditing()) game->updateHighlighter(); }
/** * Handles mouse clicks over the graph view. * @param pEvent Includes information on the mouse press event */ void GraphWidget::contentsMousePressEvent(QMouseEvent* pEvent) { QPoint ptRealPos; QCanvasItemList il; QCanvasItemList::Iterator itr; QString sFunc; GraphNode* pNode; GraphEdge* pEdge; pNode = NULL; pEdge = NULL; // Handle right-clicks only if (pEvent->button() != Qt::RightButton) { QCanvasView::contentsMousePressEvent(pEvent); return; } // Take the zoom factor into consideration ptRealPos = pEvent->pos(); ptRealPos /= m_dZoom; // Check if an item was clicked il = canvas()->collisions(ptRealPos); for (itr = il.begin(); itr != il.end(); ++itr) { if (dynamic_cast<GraphNode*>(*itr) != NULL) pNode = dynamic_cast<GraphNode*>(*itr); else if (dynamic_cast<GraphEdge*>(*itr) != NULL) pEdge = dynamic_cast<GraphEdge*>(*itr); } // Handle clicks over different types of items if (pNode != NULL) { // Show a context menu for nodes showNodeMenu(pNode, pEvent->globalPos()); } else if (pEdge != NULL) { // Show a context menu for edges showEdgeMenu(pEdge, pEvent->globalPos()); } else { // Take the default action QCanvasView::contentsMousePressEvent(pEvent); } }
QRect ItemDocument::canvasBoundingRect() const { QRect bound; // Don't include items used for dragging Item *dragItem = 0; const ViewList::const_iterator viewsEnd = m_viewList.end(); for (ViewList::const_iterator it = m_viewList.begin(); it != viewsEnd; ++it) { dragItem = (static_cast<ItemView*>((View*) * it))->dragItem(); if (dragItem) break; } const QCanvasItemList allItems = canvas()->allItems(); const QCanvasItemList::const_iterator end = allItems.end(); for (QCanvasItemList::const_iterator it = allItems.begin(); it != end; ++it) { if (!(*it)->isVisible()) continue; if (dragItem) { if (*it == dragItem) continue; if (Node *n = dynamic_cast<Node*>(*it)) { if (n->parentItem() == dragItem) continue; } if (GuiPart *gp = dynamic_cast<GuiPart*>(*it)) { if (gp->parent() == dragItem) continue; } } bound |= (*it)->boundingRect(); } if (!bound.isNull()) { bound.setLeft(bound.left() - 16); bound.setTop(bound.top() - 16); bound.setRight(bound.right() + 16); bound.setBottom(bound.bottom() + 16); } return bound; }
void KLBoard::contentsMouseReleaseEvent(QMouseEvent *e) { if ( e->button()!=LeftButton || blocked ) return; QCanvasItemList list = canvas()->collisions(e->pos()); if ( list.count()==0 ) return; QCanvasSprite *spr = static_cast<QCanvasSprite *>(list.first()); Coord c = findSprite(spr); field.fill(0); addRemoved = findGroup(field, c); if ( addRemoved>=2 ) { if ( state!=Normal ) { state = Normal; emit firstBlockClicked(); } blocked = true; _beforeRemove(true); } }
void ActivityPartitionCanvas::turn(int cx100, int cy100) { horiz ^= TRUE; setSize(height(), width()); if (cx100 == -1000) { // first turn partition cx100 = center_x_scale100; cy100 = center_y_scale100; } else { int dx = center_x_scale100 - cx100; int dy = center_y_scale100 - cy100; if (horiz) { center_x_scale100 = cx100 + dy; center_y_scale100 = cy100 - dx; } else { center_x_scale100 = cx100 - dy; center_y_scale100 = cy100 + dx; } } recenter(); DiagramCanvas::resize(width(), height()); QCanvasItemList all = the_canvas()->allItems(); QCanvasItemList::Iterator cit; for (cit = all.begin(); cit != all.end(); ++cit) { if ((*cit)->visible()) { ActivityPartitionCanvas * p = dynamic_cast<ActivityPartitionCanvas *>(*cit); if ((p != 0) && (p->get_bn()->parent() == browser_node) && (p->horiz != horiz)) { p->turn(cx100, cy100); } } } }
void TransitionCanvas::drop(BrowserNode * bn, UmlCanvas * canvas) { TransitionData * def = (TransitionData *) bn->get_data(); BrowserNode * from = def->get_start_node(); BrowserNode * to = def->get_end_node(); DiagramItem * difrom = 0; DiagramItem * dito = 0; QCanvasItemList all = canvas->allItems(); QCanvasItemList::Iterator cit; // the two extremities are drawn ? for (cit = all.begin(); cit != all.end(); ++cit) { if ((*cit)->visible()) { DiagramItem * di = QCanvasItemToDiagramItem(*cit); if (di != 0) { if (di->get_bn() == from) { difrom = di; if (dito != 0) break; } if (di->get_bn() == to) { dito = di; if (difrom != 0) break; } } } } if ((difrom != 0) && (dito != 0)){ if (difrom->has_relation(UmlTransition, def)) msg_information("Bouml", "transition already drawn"); else { TransitionCanvas * tr = new TransitionCanvas(canvas, difrom, dito, from, 0, -1.0, -1.0, def); tr->show(); tr->package_modified(); } } }
ActivityPartitionCanvas::ActivityPartitionCanvas(BrowserNode * bn, UmlCanvas * canvas, int x, int y) : ActivityContainerCanvas(0, canvas, x, y, ACTIVITY_PARTITION_CANVAS_MIN_SIZE, ACTIVITY_PARTITION_CANVAS_MIN_SIZE, 0) { browser_node = bn; itscolor = UmlDefaultColor; BrowserNode * parent = (BrowserNode *) browser_node->parent(); if (parent->get_type() == UmlActivityPartition) { QCanvasItemList all = the_canvas()->allItems(); QCanvasItemList::Iterator cit; for (cit = all.begin(); cit != all.end(); ++cit) { if ((*cit)->visible()) { DiagramItem * di = QCanvasItemToDiagramItem(*cit); if ((di != 0) && (di->get_bn() == parent)) { horiz = ((ActivityPartitionCanvas *) di)->horiz; break; } } } if (cit == all.end()) horiz = FALSE; } else horiz = FALSE; check_size(); check_stereotypeproperties(); ActivityPartitionData * data = (ActivityPartitionData *) browser_node->get_data(); connect(data, SIGNAL(changed()), this, SLOT(modified())); connect(data, SIGNAL(deleted()), this, SLOT(deleted())); connect(DrawingSettings::instance(), SIGNAL(changed()), this, SLOT(modified())); }
void TextCanvas::send(ToolCom * com, QCanvasItemList & all) { QCanvasItemList::Iterator cit; for (cit = all.begin(); cit != all.end(); ++cit) { DiagramItem *di = QCanvasItemToDiagramItem(*cit); if ((di != 0) && (*cit)->visible() && (di->type() == UmlText)) { TextCanvas * tx = (TextCanvas *) di; QCString s = fromUnicode(tx->text); com->write_bool(TRUE); // one more com->write_string((const char *) s); com->write(tx->rect()); } } com->write_bool(FALSE); // done }
KTreemapTile * KTreemapView::findTile( KFileInfo * node ) { if ( ! node ) return 0; QCanvasItemList itemList = canvas()->allItems(); QCanvasItemList::Iterator it = itemList.begin(); while ( it != itemList.end() ) { KTreemapTile * tile = dynamic_cast<KTreemapTile *> (*it); if ( tile && tile->orig() == node ) return tile; ++it; } return 0; }