// create the constrained lines foreach(QVariant item, lines) { QObject* line = item.value<QObject*>(); int start = line->property("startPoint").value<QObject*>()->property("identifier").toInt(); int end = line->property("endPoint").value<QObject*>()->property("identifier").toInt(); #ifdef CARPENTER_DEBUG qDebug() << "SketchSolver: line [" << start << "," << end << "]"; #endif bool vertical = line->property("verticallyConstrained").toBool(); bool horizontal = line->property("horizontallyConstrained").toBool(); bool distanceFixed = line->property("distanceFixed").toBool(); int identifier = line->property("identifier").toInt(); QSharedPointer<ConstrainedLine> cLine1(new ConstrainedLine(this->points[start], this->points[end], identifier)); QSharedPointer<ConstrainedLine> cLine2(new ConstrainedLine(this->points[end], this->points[start], identifier)); if(distanceFixed) { double desiredDistance = line->property("desiredDistance").toDouble(); cLine1->setDesiredDistance(desiredDistance); cLine2->setDesiredDistance(desiredDistance); this->constraints << cLine1; } if(horizontal) { cLine1->horizontallyConstrained(); cLine2->horizontallyConstrained(); horizontalAndVerticalConstraints++; } if(vertical) { cLine1->verticallyConstrained(); cLine2->verticallyConstrained(); horizontalAndVerticalConstraints++; } this->lines << cLine1 << cLine2; }
void MythSqueezeDisplay::PaintSqueezeDisplay(DisplayBuffer *buf) { DEBUGF("Colors" << m_displayBackgroundColor << m_textcolorGeneral ); int playedCount = 0; int totalCount = 1; // this way we never get a divide by zero error QString timeText = ""; QPainter p( displayImage ); QBrush b( m_displayBackgroundColor ); m_textcolorGeneral.setAlpha( m_Brightness ); textcolorLine1.setAlpha( m_Brightness - line1Alpha ); QBrush c( m_textcolorGeneral ); QBrush e( c ); // non-filling brush e.setStyle( Qt::NoBrush ); p.setBackground( b ); p.setBrush( c ); p.setPen( m_textcolorGeneral ); p.setFont( large ); p.eraseRect( displayImage->rect() ); DEBUGF("LINE 0: " << line0Bounds << " LINE 1:" << line1Bounds); // draw Line 0 NOTE: Only transitions left or right, but NOT up and down if( buf->line0.length() > 0 ) { p.setFont( small ); if( isTransition && ( transitionDirection == transLEFT || transitionDirection == transRIGHT)) { p.drawText(line0Bounds.left()+xOffsetOld, line0Bounds.bottom(), transBuffer.line0); p.drawText(line0Bounds.left()+xOffsetNew, line0Bounds.bottom(), buf->line0); } else p.drawText(line0Bounds.x(), line0Bounds.bottom(), buf->line0); } // draw Line 1 if( buf->line1.length() > 0 ) { if( buf->line0.left( 8 ) == "Volume (" ) { // it's the volume, so emulate a progress bar qreal volume = buf->line0.mid( 8, buf->line0.indexOf( ')' ) - 8 ).toInt(); volFillRect.setWidth( (qreal)volRect.width() * ( volume / (qreal)100 ) ); p.setBrush( e ); // non-filling brush so we end up with an outline of a rounded rectangle p.drawRoundedRect( volRect, radius, radius ); p.setBrush( c ); if( volume > 1 ) // if it's too small, we get a funny line at the start of the progress bar p.drawRoundedRect( volFillRect, radius, radius ); } else { QBrush cLine1( textcolorLine1 ); p.setBrush( cLine1 ); p.setPen( textcolorLine1 ); p.setFont( large ); p.setClipRegion( line1Clipping ); if( isTransition ) { p.drawText( line1Bounds.x() + xOffsetOld, line1Bounds.bottom() + yOffsetOld, transBuffer.line1); p.drawText( line1Bounds.x() + xOffsetNew, line1Bounds.bottom() + yOffsetNew, buf->line1 ); } else { // p.drawText( line1Bounds.x(), line1Bounds.bottom(), buf->line1 ); p.drawText( line1Bounds.x() - ScrollOffset, line1Bounds.bottom(), buf->line1 ); if( scrollState != NOSCROLL ) p.drawText(pointLine1_2.x() - ScrollOffset, line1Bounds.bottom(), buf->line1 ); } p.setClipRegion( fullDisplayClipping ); p.setBrush( c ); p.setPen( m_textcolorGeneral ); } } // deal with "overlay0" (the right-hand portion of the display) this can be time (e.g., "-3:08") or number of items (e.g., "(2 of 7)") if( buf->overlay0.length() > 0 ) { if( Slimp3Display( buf->overlay0 ) ) { QRegExp rx( "\\W(\\w+)\\W"); // QRegExp rx( "\037(\\w+)\037" ); QStringList el; int pos = 0; while ((pos = rx.indexIn(buf->overlay0, pos)) != -1) { el << rx.cap(1); pos += rx.matchedLength(); } rx.indexIn( buf->overlay0 ); QStringList::iterator it = el.begin(); while( it != el.end() ) { QString s = *it; if( s.left( 12 ) == "leftprogress" ) { // first element int inc = s.at( 12 ).digitValue(); playedCount += inc; totalCount += 4; } else if( s.left( 14 ) == "middleprogress" ) { // standard element int inc = s.at( 14 ).digitValue(); playedCount += inc; totalCount += 4; } else if( s.left( 10 ) == "solidblock" ) { // full block playedCount += 4; totalCount += 4; } else if( s.left( 13 ) == "rightprogress" ) { // end element int inc = s.at( 13 ).digitValue(); playedCount += inc; totalCount += 4; } ++it; } QChar *data = buf->overlay0.data(); for( int i = ( buf->overlay0.length() - 8 ); i < buf->overlay0.length(); i++ ) { if( *( data + i ) == ' ' ) { timeText = buf->overlay0.mid( i + 1 ); } } } else if( buf->overlay0.contains( QChar( 8 ) ) ) { QChar elapsed = QChar(8); QChar remaining = QChar(5); QChar *data = buf->overlay0.data(); for( int i = 0; i < buf->overlay0.length(); i++, data++ ) { if( *data == elapsed ) { playedCount++; totalCount++; } else if( *data == remaining ) totalCount++; else if( *data == ' ' ) { timeText = buf->overlay0.mid( i + 1 ); } } } else { timeText = buf->overlay0; } p.setFont( small ); QFontMetrics fm = p.fontMetrics(); // p.setClipping(false); p.setClipRegion(line0Clipping ); if( isTransition ) { p.drawText( ( line0Bounds.right() + xOffsetNew ) - fm.width(timeText), line0Bounds.bottom(), timeText ); } else { p.drawText( line0Bounds.right() - fm.width(timeText), line0Bounds.bottom(), timeText ); } if( totalCount > 1 ) { // make sure we received data on a progress bar, otherwise, don't draw progRect.setLeft( ( qreal )( line0Bounds.x() + fm.width( buf->line0.toUpper() ) + xOffsetOld ) ); progRect.setRight( ( qreal )( line0Bounds.right() + xOffsetOld - ( qreal )( 3 * fm.width( timeText ) / 2 ) ) ); progFillRect.setLeft( progRect.left() ); progFillRect.setWidth( ( playedCount * progRect.width() ) / totalCount ); p.setBrush( e ); // non-filling brush so we end up with an outline of a rounded rectangle p.drawRoundedRect( progRect, radius, radius ); p.setBrush( c ); if( playedCount > 1 ) // if it's too small, we get a funny line at the start of the progress bar p.drawRoundedRect( progFillRect, radius, radius ); } } // deal with "overlay1" (the right-hand portion of the display) // if( buf->overlay1.length() > 0 ) { // DEBUGF( "Don't know what to do with overlay1 yet" ); // } // if we've received a "center" display, it means we're powered down, so draw them if( buf->center0.length() > 0 ) { p.setFont( medium ); QFontMetrics fm = p.fontMetrics(); QPoint start = QPoint( center0Bounds.x() + (center0Bounds.width()/2) - (fm.width( buf->center0 )/2 ), center0Bounds.bottom() ); p.drawText( start, buf->center0 ); } if( buf->center1.length() > 0 ) { p.setFont( medium ); QFontMetrics fm = p.fontMetrics(); QPoint start = QPoint( center1Bounds.x() + (center1Bounds.width()/2)- ( fm.width( buf->center1 )/2 ), center1Bounds.bottom() ); p.drawText( start, buf->center1 ); } // displayLabel.setPixmap(QPixmap::fromImage( *displayImage) ); QPixmap pix = QPixmap::fromImage(*displayImage); m_squeezeDisplay->UpdateFrame(&pix); }