void GraphEditor::clear() {//erase all the items of the canvas, but not the canvas itself if(!scene())return; QList<QGraphicsItem *> list = gwp->canvas->items(); QList<QGraphicsItem *>::Iterator it = list.begin(); QGraphicsItem * item; for (; it != list.end(); ++it) {item = (QGraphicsItem *)(*it); if(item->scene() == gwp->canvas) scene()->removeItem(*it); } GridDrawn = false; }
void AirGunTurret::removeExtraShells() { QMutableListIterator<QGraphicsItem *> i(*shellList); while (i.hasNext()) { QGraphicsItem* shell = i.next(); if ((shell->scenePos().x() > 800) || (shell->scene() == NULL)) { i.remove(); delete shell; } } }
void GInstructionView::UpdateView() { if(!m_pInstruction) return; // m_pInstruction->UpdateGraphicsItem(); QGraphicsItem* pItemInstruction = &m_pInstruction->m_GraphicsItem; // is the item already displayed in a scene? m_pInsScene = pItemInstruction->scene(); // if so, we display this scene, centered on the item. An item can only be in ONE scene at a time // else we make a scene and display the item. if(!m_pInsScene) { m_pInsScene = new QGraphicsScene(m_pInstruction); m_pInsScene->addItem(pItemInstruction); } setScene(m_pInsScene); pItemInstruction->setZValue(0.0); FitInstructionInView(); }