void Node::recache() { if (getParent() == nullptr) { cached_transform_ = (getTranslationMat4(position_) * getScalingMat4(scale_)) * orientation_; derivedScale_ = scale_; derivedPosition_ = position_; derivedOrientation_ = orientation_; } else { cached_transform_ = getParent()->getCachedTransformRef() * ((getTranslationMat4(position_) * getScalingMat4(scale_)) * orientation_); derivedPosition_ = cached_transform_ * position_; derivedScale_ = parent_->getDerivedScale().mul(scale_); derivedOrientation_ = parent_->getDerivedOrientation() * orientation_; //FIX? } setNeedsUpdate(false); // Notify listeners if (listener) listener->onRecache(this); }
void OutWidget::resizeEvent(QResizeEvent *e) { emit outputResized(e->size()); // needsUpdate = true; setNeedsUpdate(true); }
void OutWidget::setCursorPos(const QPoint &value) { cursorPos = value; // needsUpdate = true; setNeedsUpdate(true); }
void OutWidget::setQuadList(QList<Quad*> *value) { quadList = value; setNeedsUpdate(true); // needsUpdate = true; }
void BBTCOView::paintEvent( QPaintEvent * ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ? QPixmap( size() ) : m_paintPixmap; QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted(); // state: selected, muted, default, user selected c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : ( m_bbTCO->m_useStyleColor ? painter.background().color() : m_bbTCO->colorObj() ) ); lingrad.setColorAt( 0, c.light( 130 ) ); lingrad.setColorAt( 1, c.light( 70 ) ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } // bar lines const int lineSize = 3; p.setPen( c.darker( 200 ) ); tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() ); if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 ) { for( int x = static_cast<int>( t * pixelsPerTact() ); x < width() - 2; x += static_cast<int>( t * pixelsPerTact() ) ) { p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize ); p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ), x, rect().bottom() - TCO_BORDER_WIDTH ); } } // pattern name p.setRenderHint( QPainter::TextAntialiasing ); if( m_staticTextName.text() != m_bbTCO->name() ) { m_staticTextName.setText( m_bbTCO->name() ); } QFont font; font.setHintingPreference( QFont::PreferFullHinting ); font.setPointSize( 8 ); p.setFont( font ); const int textTop = TCO_BORDER_WIDTH + 1; const int textLeft = TCO_BORDER_WIDTH + 1; p.setPen( textShadowColor() ); p.drawStaticText( textLeft + 1, textTop + 1, m_staticTextName ); p.setPen( textColor() ); p.drawStaticText( textLeft, textTop, m_staticTextName ); // inner border p.setPen( c.lighter( 130 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_bbTCO->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }
void SampleTCOView::paintEvent( QPaintEvent * pe ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ? QPixmap( size() ) : m_paintPixmap; QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); // state: selected, muted, normal c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : painter.background().color() ); lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } p.setPen( !muted ? painter.pen().brush().color() : mutedColor() ); const int spacing = TCO_BORDER_WIDTH + 1; QRect r = QRect( TCO_BORDER_WIDTH, spacing, qMax( static_cast<int>( m_tco->sampleLength() * pixelsPerTact() / DefaultTicksPerTact ), 1 ), rect().bottom() - 2 * spacing ); m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); // disable antialiasing for borders, since its not needed p.setRenderHint( QPainter::Antialiasing, false ); if( r.width() < width() - 1 ) { p.drawLine( r.x(), r.y() + r.height() / 2, rect().right() - TCO_BORDER_WIDTH, r.y() + r.height() / 2 ); } // inner border p.setPen( c.lighter( 160 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_tco->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } // recording sample tracks is not possible at the moment /* if( m_tco->isRecord() ) { p.setFont( pointSize<7>( p.font() ) ); p.setPen( textShadowColor() ); p.drawText( 10, p.fontMetrics().height()+1, "Rec" ); p.setPen( textColor() ); p.drawText( 9, p.fontMetrics().height(), "Rec" ); p.setBrush( QBrush( textColor() ) ); p.drawEllipse( 4, 5, 4, 4 ); }*/ p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }
Node & Node::setOrientation(Quat q) { orientation_ = q; setNeedsUpdate(); return * this; }
void Node::rotate(Vec3 axis, float angle) { orientation_ = orientation_ * Quat(axis, angle); setNeedsUpdate(); }
Node & Node::setScale(Vec3 k) { scale_ = k; setNeedsUpdate(); return * this; }
Node & Node::setPosition(Vec3 v) { position_ = v; setNeedsUpdate(); return * this; }
void Node::move(Vec3 v) { position_ = position_ + v; setNeedsUpdate(); }
void SampleTCOView::paintEvent( QPaintEvent * pe ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); if (m_paintPixmap.isNull() || m_paintPixmap.size() != size()) { m_paintPixmap = QPixmap(size()); } QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted(); // state: selected, muted, normal c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : painter.background().color() ); lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds p.fillRect( rect(), QColor( 0, 0, 0 ) ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } p.setPen( !muted ? painter.pen().brush().color() : mutedColor() ); const int spacing = TCO_BORDER_WIDTH + 1; const float ppt = fixedTCOs() ? ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) / (float) m_tco->length().getTact() : pixelsPerTact(); float nom = Engine::getSong()->getTimeSigModel().getNumerator(); float den = Engine::getSong()->getTimeSigModel().getDenominator(); float ticksPerTact = DefaultTicksPerTact * nom / den; float offset = m_tco->startTimeOffset() / ticksPerTact * pixelsPerTact(); QRect r = QRect( TCO_BORDER_WIDTH + offset, spacing, qMax( static_cast<int>( m_tco->sampleLength() * ppt / ticksPerTact ), 1 ), rect().bottom() - 2 * spacing ); m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); QFileInfo fileInfo(m_tco->m_sampleBuffer->audioFile()); QString filename = fileInfo.fileName(); paintTextLabel(filename, p); // disable antialiasing for borders, since its not needed p.setRenderHint( QPainter::Antialiasing, false ); // inner border p.setPen( c.lighter( 160 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_tco->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } // recording sample tracks is not possible at the moment /* if( m_tco->isRecord() ) { p.setFont( pointSize<7>( p.font() ) ); p.setPen( textShadowColor() ); p.drawText( 10, p.fontMetrics().height()+1, "Rec" ); p.setPen( textColor() ); p.drawText( 9, p.fontMetrics().height(), "Rec" ); p.setBrush( QBrush( textColor() ) ); p.drawEllipse( 4, 5, 4, 4 ); }*/ p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }