//////////////////////////////////////////////////////////////////////////////// /// CChanceTreeHistoryArtist::paintTable /// /// @description This function paints all the nodes to the screen. /// @pre None /// @post All the nodes are drawn to the screen. /// /// @param painter: This is a pointer to the painter to use. If no value is /// passed, create a painter to use. /// /// @limitations None /// //////////////////////////////////////////////////////////////////////////////// void CChanceTreeHistoryArtist::paintTable( QPainter *painter ) { //Make sure the pointer to the model has been initialized. if (m_model == NULL) return; //Make sure the root node of the tree isn't NULL, then call the //paintModelHelper function to pain the model. if ( m_model->getRootNode() == NULL ) return; //This variable is used for painting to the canvas if no painter was //specified. QPainter localPainter( m_canvas ); //Check if the calling function did not pass a painter and use //the local one in that case. if ( painter == NULL ) painter = &localPainter; //Create the QPainter object to paint the model. painter->setPen( m_style->getPen() ); painter->setBrush( m_style->getBrush() ); painter->setFont( m_style->getFont() ); painter->setRenderHint( QPainter::Antialiasing ); HistoryTable historyTable = m_model->getHistoryTable(); HistoryTable::const_iterator i = historyTable.constBegin(); QRect cellRect( painter->boundingRect( 0,0,0,0,0,"WW-WW" ) ); cellRect.adjust( -4,-4,4,4 ); cellRect.moveTopLeft( m_model->getHistoryPosition() ); while ( i != historyTable.constEnd() ) { painter->drawRect( cellRect ); painter->drawText( cellRect, Qt::AlignCenter, moveName(i->first) ); cellRect.moveTopLeft( cellRect.bottomLeft() ); painter->drawRect( cellRect ); painter->drawText( cellRect, Qt::AlignCenter, QString::number(i->second) ); cellRect.moveBottomLeft( cellRect.topRight() ); ++i; } }
//////////////////////////////////////////////////////////////////////////////// /// CPuzzleSpanArtist::paintModel /// /// @description This function paints all the spans to the screen. /// @pre None /// @post All the spans are drawn to the screen. /// /// @limitations None /// //////////////////////////////////////////////////////////////////////////////// void CPuzzleSpanArtist::paintModel( QPainter *painter ) { if (m_model != NULL) { //This variable is used for painting to the canvas if no painter was //specified. QPainter localPainter( m_canvas ); //Check if the calling function did not pass a painter and use //the local one in that case. if ( painter == NULL ) painter = &localPainter; for (int i = 0; i < m_model->getSpanCount(); i++) { paintSpan( m_model->getSpanAt(i), painter ); } } }
///public: QUuid PixmapJUPOCObject::addPart(QPixmap& srcPixmap,const QRect& srcRect) { if (srcPixmap.isNull()) { return QUuid(); } //proper clipped rect, please QRect csrcRect = (srcRect.isEmpty() ? srcPixmap.rect() : srcRect.intersect(srcPixmap.rect())); QRect targetRect = findSpace(csrcRect.size()); if (targetRect.isEmpty()) { //couldn't find space return QUuid(); } //copy in QPainter localPainter(pm); localPainter.drawPixmap(targetRect,srcPixmap,csrcRect); QUuid nUid = QUuid::createUuid(); m_parts[nUid] = targetRect; return nUid; }
//static PixmapJUPOCRefObject * PixmapJUPOCObject::transfer(PixmapJUPOCObject * p_jupoc,PixmapObject * p_src) { if ((p_jupoc == 0) || (p_src == 0)) { return 0; } QRect targetRect = p_jupoc->findSpace(p_src->size()); if (targetRect.isEmpty()) { //no space... return 0; } //copy in QPainter localPainter(p_jupoc->pm); p_src->paint(&localPainter,QRectF(targetRect)); QUuid nUid = QUuid::createUuid(); p_jupoc->m_parts[nUid] = targetRect; //TODO: dispose properly delete p_src; return new PixmapJUPOCRefObject(*p_jupoc,nUid,targetRect); }