Aliasing in AutomationPatternView and AutomationEditor fixed (#3386)

* Ailiasing in AutomationPatternView; ERROR: Doesn't draw unreferanced tracks

* Draws one polygon instead of 'poly'-polygons

* Changed QPoints to QPointF

* Added int MidiTpT constant

* Added ppTact for reduced computation

* Added spaces in parentheses to be consistent

* Variable name change and spacing

* S P A C E S

* Anti-Aliasing of Automation Editor

* Commented out all referances to unused is_selected

* Changed css to non-gradient graphs

* Added Brackets

* Removed no-pixel line at bottom of graph

* Revert "Added Brackets"

This reverts commit ff801868b7.

* Revert "Revert "Added Brackets""

This reverts commit 4e127a78df.

* Revert "Removed no-pixel line at bottom of graph"

This reverts commit 940c766b61.
This commit is contained in:
TheTravelingSpaceman
2017-03-13 02:14:05 +02:00
committed by Umcaruje
parent 97cd037300
commit 899e386df7
5 changed files with 74 additions and 44 deletions

View File

@@ -18,9 +18,7 @@ AutomationEditor {
qproperty-gridColor: #808080;
qproperty-crossColor: rgb( 255, 51, 51 );
qproperty-graphColor: qlineargradient(spread:reflect,
x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(153, 175, 255, 250), stop:1 rgba(153, 175, 255, 100));
qproperty-graphColor: rgba(153, 175, 255, 250);
qproperty-scaleColor: qlineargradient(spread:reflect,
x1:0, y1:0.5, x2:1, y2:0.5,
stop:0 #333, stop:1 #202020);

View File

@@ -22,8 +22,7 @@ AutomationEditor {
qproperty-beatLineColor: #4a3bba;
qproperty-barLineColor: #8173fe;
qproperty-graphColor: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(69,42,153,180), stop:1 rgba(69,42,153,100));
qproperty-graphColor: rgba(69,42,153,180);
qproperty-scaleColor: #262b30;
}

View File

@@ -125,9 +125,8 @@ protected:
float getLevel( int y );
int xCoordOfTick( int tick );
int yCoordOfLevel( float level );
inline void drawLevelTick( QPainter & p, int tick,
float value, bool is_selected );
float yCoordOfLevel( float level );
inline void drawLevelTick( QPainter & p, int tick, float value);// bool is_selected ); //NEEDS Change in CSS
void removeSelection();
void selectAll();
void getSelectedValues(timeMap & selected_values );

View File

@@ -280,6 +280,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
const float y_scale = max - min;
const float h = ( height() - 2 * TCO_BORDER_WIDTH ) / y_scale;
const float ppTick = ppt / MidiTime::ticksPerTact();
p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH );
p.scale( 1.0f, -h );
@@ -293,14 +294,14 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
lin2grad.setColorAt( 0.5, col );
lin2grad.setColorAt( 0, col.darker( 150 ) );
p.setRenderHints( QPainter::Antialiasing, true );
for( AutomationPattern::timeMap::const_iterator it =
m_pat->getTimeMap().begin();
it != m_pat->getTimeMap().end(); ++it )
{
if( it+1 == m_pat->getTimeMap().end() )
{
const float x1 = x_base + it.key() * ppt /
MidiTime::ticksPerTact();
const float x1 = x_base + it.key() * ppTick;
const float x2 = (float)( width() - TCO_BORDER_WIDTH );
if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break;
if( gradient() )
@@ -315,27 +316,36 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
}
float *values = m_pat->valuesAfter( it.key() );
for( int i = it.key(); i < (it + 1).key(); i++ )
{
float value = values[i - it.key()];
const float x1 = x_base + i * ppt /
MidiTime::ticksPerTact();
const float x2 = x_base + (i + 1) * ppt /
MidiTime::ticksPerTact();
if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break;
if( gradient() )
{
p.fillRect( QRectF( x1, 0.0f, x2 - x1, value ), lin2grad );
}
else
{
p.fillRect( QRectF( x1, 0.0f, x2 - x1, value ), col );
}
QPainterPath path;
QPointF origin = QPointF( x_base + it.key() * ppTick, 0.0f );
path.moveTo( origin );
path.moveTo( QPointF( x_base + it.key() * ppTick,values[0] ) );
float x;
for( int i = it.key() + 1; i < ( it + 1 ).key(); i++ )
{
x = x_base + i * ppTick;
if( x > ( width() - TCO_BORDER_WIDTH ) ) break;
float value = values[ i - it.key() ];
path.lineTo( QPointF( x, value ) );
}
path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, values[ ( it + 1 ).key() - 1 - it.key() ] );
path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, 0.0f );
path.lineTo( origin );
if( gradient() )
{
p.fillPath( path, lin2grad );
}
else
{
p.fillPath( path, col );
}
delete [] values;
}
p.setRenderHints( QPainter::Antialiasing, false );
p.resetMatrix();
// bar lines

View File

@@ -1284,7 +1284,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
if( validPattern() )
{
int len_ticks = 4;
//NEEDS Change in CSS
//int len_ticks = 4;
timeMap & time_map = m_pattern->getTimeMap();
//Don't bother doing/rendering anything if there is no automation points
@@ -1307,8 +1308,9 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
{
break;
}
bool is_selected = false;
//NEEDS Change in CSS
/*bool is_selected = false;
// if we're in move-mode, we may only draw
// values in selected area, that have originally
// been selected and not values that are now in
@@ -1326,15 +1328,34 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
it.key() + len_ticks <= sel_pos_end )
{
is_selected = true;
}
}*/
float *values = m_pattern->valuesAfter( it.key() );
for( int i = 0; i < (it+1).key() - it.key(); i++ )
{
drawLevelTick( p, it.key() + i, values[i],
is_selected );
float nextValue;
if ( m_pattern->valuesAfter( ( it + 1 ).key() ) != NULL )
{
nextValue = *( m_pattern->valuesAfter( ( it + 1 ).key() ) );
}
else
{
nextValue = values[ ( it + 1 ).key() - it.key() -1 ];
}
p.setRenderHints( QPainter::Antialiasing, true );
QPainterPath path;
path.moveTo( QPointF( xCoordOfTick( it.key() ), yCoordOfLevel( 0 ) ) );
for( int i = 0; i < ( it + 1 ).key() - it.key(); i++ )
{ path.lineTo( QPointF( xCoordOfTick( it.key() + i ), yCoordOfLevel( values[i] ) ) );
//NEEDS Change in CSS
//drawLevelTick( p, it.key() + i, values[i], is_selected );
}
path.lineTo( QPointF( xCoordOfTick( ( it + 1 ).key() ), yCoordOfLevel( nextValue ) ) );
path.lineTo( QPointF( xCoordOfTick( ( it + 1 ).key() ), yCoordOfLevel( 0 ) ) );
path.lineTo( QPointF( xCoordOfTick( it.key() ), yCoordOfLevel( 0 ) ) );
p.fillPath( path, graphColor() );
p.setRenderHints( QPainter::Antialiasing, false );
delete [] values;
// Draw circle
@@ -1349,7 +1370,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
// TODO: Find out if the section after the last control
// point is able to be selected and if so set this
// boolean correctly
drawLevelTick( p, i, it.value(), false );
drawLevelTick( p, i, it.value()); ////NEEDS Change in CSS:, false );
}
// Draw circle(the last one)
drawAutomationPoint(p, it);
@@ -1433,27 +1454,25 @@ int AutomationEditor::xCoordOfTick(int tick )
int AutomationEditor::yCoordOfLevel(float level )
float AutomationEditor::yCoordOfLevel(float level )
{
int grid_bottom = height() - SCROLLBAR_SIZE - 1;
if( m_y_auto )
{
return (int)( grid_bottom - ( grid_bottom - TOP_MARGIN )
* ( level - m_minLevel )
/ ( m_maxLevel - m_minLevel ) );
return ( grid_bottom - ( grid_bottom - TOP_MARGIN ) * ( level - m_minLevel ) / ( m_maxLevel - m_minLevel ) );
}
else
{
return (int)( grid_bottom - ( level - m_bottomLevel )
* m_y_delta );
return ( grid_bottom - ( level - m_bottomLevel ) * m_y_delta );
}
}
void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value,
bool is_selected )
//NEEDS Change in CSS
void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value)
// bool is_selected )
{
int grid_bottom = height() - SCROLLBAR_SIZE - 1;
const int x = xCoordOfTick( tick );
@@ -1481,10 +1500,15 @@ void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value,
rect_height = (int)( value * m_y_delta );
}
QBrush currentColor = is_selected
//NEEDS Change in CSS
/*QBrush currentColor = is_selected
? QBrush( QColor( 0x00, 0x40, 0xC0 ) )
: graphColor();
*/
QBrush currentColor = graphColor();
p.fillRect( x, y_start, rect_width, rect_height, currentColor );
}