Fix more bugs from collapsing LIB_* to SCH_*.
The transform can always be used: it will be the identiy transform when in the schematic. Also fixes a bug where textbox borders didn't get plotted, and a couple others where things were still expecting an upside-down coordinate system.
This commit is contained in:
parent
3d56494652
commit
e5a17b96a3
|
@ -142,24 +142,14 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
|
||||||
ptList.clear();
|
ptList.clear();
|
||||||
|
|
||||||
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
|
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
|
||||||
{
|
ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
|
|
||||||
else
|
|
||||||
ptList.push_back( pt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( GetShape() == SHAPE_T::BEZIER )
|
else if( GetShape() == SHAPE_T::BEZIER )
|
||||||
{
|
{
|
||||||
ptList.clear();
|
ptList.clear();
|
||||||
|
|
||||||
for( const VECTOR2I& pt : m_bezierPoints )
|
for( const VECTOR2I& pt : m_bezierPoints )
|
||||||
{
|
ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
|
|
||||||
else
|
|
||||||
ptList.push_back( pt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
COLOR4D color = GetStroke().GetColor();
|
COLOR4D color = GetStroke().GetColor();
|
||||||
|
@ -221,33 +211,19 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
|
||||||
aPlotter->SetCurrentLineWidth( pen_size );
|
aPlotter->SetCurrentLineWidth( pen_size );
|
||||||
aPlotter->SetDash( pen_size, lineStyle );
|
aPlotter->SetDash( pen_size, lineStyle );
|
||||||
|
|
||||||
VECTOR2I start = m_start;
|
VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
|
||||||
VECTOR2I end = m_end;
|
VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
|
||||||
VECTOR2I mid, center;
|
VECTOR2I mid, center;
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
{
|
|
||||||
start = renderSettings->TransformCoordinate( start ) + aOffset;
|
|
||||||
end = renderSettings->TransformCoordinate( end ) + aOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( GetShape() )
|
switch( GetShape() )
|
||||||
{
|
{
|
||||||
case SHAPE_T::ARC:
|
case SHAPE_T::ARC:
|
||||||
mid = GetArcMid();
|
mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset;
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
mid = renderSettings->TransformCoordinate( mid ) + aOffset;
|
|
||||||
|
|
||||||
aPlotter->Arc( start, mid, end, fill, pen_size );
|
aPlotter->Arc( start, mid, end, fill, pen_size );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_T::CIRCLE:
|
case SHAPE_T::CIRCLE:
|
||||||
center = getCenter();
|
center = renderSettings->TransformCoordinate( getCenter() ) + aOffset;
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
center = renderSettings->TransformCoordinate( center ) + aOffset;
|
|
||||||
|
|
||||||
aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
|
aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -308,24 +284,14 @@ void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit
|
||||||
ptList.clear();
|
ptList.clear();
|
||||||
|
|
||||||
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
|
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
|
||||||
{
|
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
|
||||||
else
|
|
||||||
ptList.push_back( pt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( GetShape() == SHAPE_T::BEZIER )
|
else if( GetShape() == SHAPE_T::BEZIER )
|
||||||
{
|
{
|
||||||
ptList.clear();
|
ptList.clear();
|
||||||
|
|
||||||
for( const VECTOR2I& pt : m_bezierPoints )
|
for( const VECTOR2I& pt : m_bezierPoints )
|
||||||
{
|
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
|
||||||
else
|
|
||||||
ptList.push_back( pt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
|
||||||
|
@ -394,31 +360,21 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
|
||||||
ptList.clear();
|
ptList.clear();
|
||||||
|
|
||||||
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
|
for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
|
||||||
{
|
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
|
||||||
else
|
|
||||||
ptList.push_back( pt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( GetShape() == SHAPE_T::BEZIER )
|
else if( GetShape() == SHAPE_T::BEZIER )
|
||||||
{
|
{
|
||||||
ptList.clear();
|
ptList.clear();
|
||||||
|
|
||||||
for( const VECTOR2I& pt : m_bezierPoints )
|
for( const VECTOR2I& pt : m_bezierPoints )
|
||||||
{
|
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
||||||
if( m_layer == LAYER_DEVICE )
|
|
||||||
ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
|
|
||||||
else
|
|
||||||
ptList.push_back( pt );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTOR2I start = GetStart();
|
VECTOR2I start = GetStart();
|
||||||
VECTOR2I end = GetEnd();
|
VECTOR2I end = GetEnd();
|
||||||
VECTOR2I center = ( GetShape() == SHAPE_T::ARC ) ? getCenter() : VECTOR2I( 0, 0 );
|
VECTOR2I center = ( GetShape() == SHAPE_T::ARC ) ? getCenter() : VECTOR2I( 0, 0 );
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE )
|
if( aSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
|
||||||
{
|
{
|
||||||
start = aSettings->TransformCoordinate( start ) + aOffset;
|
start = aSettings->TransformCoordinate( start ) + aOffset;
|
||||||
end = aSettings->TransformCoordinate( end ) + aOffset;
|
end = aSettings->TransformCoordinate( end ) + aOffset;
|
||||||
|
@ -527,16 +483,9 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod
|
||||||
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
||||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||||
{
|
{
|
||||||
if( m_layer == LAYER_DEVICE )
|
VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
|
||||||
{
|
VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
|
||||||
VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
|
GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
|
||||||
VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
|
|
||||||
GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,19 +122,9 @@ void SCH_TEXTBOX::Rotate90( bool aClockwise )
|
||||||
|
|
||||||
VECTOR2I SCH_TEXTBOX::GetDrawPos() const
|
VECTOR2I SCH_TEXTBOX::GetDrawPos() const
|
||||||
{
|
{
|
||||||
BOX2I bbox;
|
BOX2I bbox = BOX2I( m_start, m_end - m_start );
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system
|
bbox.Normalize();
|
||||||
{
|
|
||||||
bbox = BOX2I( VECTOR2I( std::min( m_start.x, m_end.x ), std::min( -m_start.y, -m_end.y ) ),
|
|
||||||
VECTOR2I( abs( m_end.x - m_start.x ), abs( m_end.y - m_start.y ) ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bbox = BOX2I( m_start, m_end - m_start );
|
|
||||||
|
|
||||||
bbox.Normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
|
VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
|
||||||
|
|
||||||
|
@ -324,16 +314,9 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB
|
||||||
STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
|
STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
|
||||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||||
{
|
{
|
||||||
if( m_layer == LAYER_DEVICE )
|
VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
|
||||||
{
|
VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
|
||||||
VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
|
GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
|
||||||
VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
|
|
||||||
GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,28 +336,7 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB
|
||||||
color = color.Mix( bg, 0.5f );
|
color = color.Mix( bg, 0.5f );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE )
|
EDA_TEXT::Print( aSettings, aOffset, color );
|
||||||
{
|
|
||||||
SCH_TEXTBOX temp( *this );
|
|
||||||
|
|
||||||
if( aSettings->m_Transform.y1 )
|
|
||||||
{
|
|
||||||
temp.SetTextAngle( temp.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL
|
|
||||||
: ANGLE_HORIZONTAL );
|
|
||||||
}
|
|
||||||
|
|
||||||
// NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates
|
|
||||||
temp.SetStart( VECTOR2I( pt1.x, -pt1.y ) );
|
|
||||||
temp.SetEnd( VECTOR2I( pt2.x, -pt2.y ) );
|
|
||||||
|
|
||||||
GRPrintText( DC, temp.GetDrawPos(), color, temp.GetShownText( true ), temp.GetTextAngle(),
|
|
||||||
temp.GetTextSize(), temp.GetHorizJustify(), temp.GetVertJustify(), penWidth,
|
|
||||||
temp.IsItalic(), temp.IsBold(), getDrawFont(), GetFontMetrics() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EDA_TEXT::Print( aSettings, aOffset, color );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -472,11 +434,10 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
|
||||||
if( IsPrivate() )
|
if( IsPrivate() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
|
||||||
|
|
||||||
if( aBackground )
|
if( aBackground )
|
||||||
{
|
|
||||||
SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
|
SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
|
||||||
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
|
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
|
||||||
|
@ -525,15 +486,15 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
|
||||||
penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
|
penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
|
||||||
aPlotter->SetCurrentLineWidth( penWidth );
|
aPlotter->SetCurrentLineWidth( penWidth );
|
||||||
|
|
||||||
|
TEXT_ATTRIBUTES attrs;
|
||||||
std::vector<VECTOR2I> positions;
|
std::vector<VECTOR2I> positions;
|
||||||
wxArrayString strings_list;
|
wxArrayString strings_list;
|
||||||
|
|
||||||
wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
|
wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
|
||||||
positions.reserve( strings_list.Count() );
|
positions.reserve( strings_list.Count() );
|
||||||
|
|
||||||
if( m_layer == LAYER_DEVICE )
|
if( renderSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
|
||||||
{
|
{
|
||||||
VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
|
|
||||||
VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
|
|
||||||
SCH_TEXTBOX temp( *this );
|
SCH_TEXTBOX temp( *this );
|
||||||
|
|
||||||
if( renderSettings->m_Transform.y1 )
|
if( renderSettings->m_Transform.y1 )
|
||||||
|
@ -542,17 +503,18 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
|
||||||
: ANGLE_HORIZONTAL );
|
: ANGLE_HORIZONTAL );
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates
|
temp.SetStart( renderSettings->TransformCoordinate( m_start ) + aOffset );
|
||||||
temp.SetStart( VECTOR2I( start.x, -start.y ) );
|
temp.SetEnd( renderSettings->TransformCoordinate( m_end ) + aOffset );
|
||||||
temp.SetEnd( VECTOR2I( end.x, -end.y ) );
|
|
||||||
|
attrs = temp.GetAttributes();
|
||||||
temp.GetLinePositions( positions, (int) strings_list.Count() );
|
temp.GetLinePositions( positions, (int) strings_list.Count() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
attrs = GetAttributes();
|
||||||
GetLinePositions( positions, (int) strings_list.Count() );
|
GetLinePositions( positions, (int) strings_list.Count() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
|
||||||
attrs.m_StrokeWidth = penWidth;
|
attrs.m_StrokeWidth = penWidth;
|
||||||
attrs.m_Multiline = false;
|
attrs.m_Multiline = false;
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
|
||||||
//
|
//
|
||||||
// Careful when pasting. The pasted pin will be at the same location as it
|
// Careful when pasting. The pasted pin will be at the same location as it
|
||||||
// was copied from, leading us to believe it's a synchronized pin. It's not.
|
// was copied from, leading us to believe it's a synchronized pin. It's not.
|
||||||
if( m_frame->SynchronizePins()
|
if( m_frame->SynchronizePins() && !( lib_item->GetEditFlags() & IS_PASTED ) )
|
||||||
&& ( lib_item->GetEditFlags() & IS_PASTED ) == 0 )
|
|
||||||
{
|
{
|
||||||
std::set<SCH_PIN*> sync_pins;
|
std::set<SCH_PIN*> sync_pins;
|
||||||
|
|
||||||
|
@ -188,8 +187,8 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
|
||||||
|
|
||||||
if( lib_item->Type() == SCH_PIN_T )
|
if( lib_item->Type() == SCH_PIN_T )
|
||||||
{
|
{
|
||||||
SCH_PIN* cur_pin = static_cast<SCH_PIN*>( lib_item );
|
SCH_PIN* cur_pin = static_cast<SCH_PIN*>( lib_item );
|
||||||
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
|
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
|
||||||
std::vector<bool> got_unit( symbol->GetUnitCount() + 1 );
|
std::vector<bool> got_unit( symbol->GetUnitCount() + 1 );
|
||||||
|
|
||||||
got_unit[cur_pin->GetUnit()] = true;
|
got_unit[cur_pin->GetUnit()] = true;
|
||||||
|
@ -240,7 +239,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
|
||||||
else if( m_frame->GetMoveWarpsCursor() )
|
else if( m_frame->GetMoveWarpsCursor() )
|
||||||
{
|
{
|
||||||
VECTOR2I itemPos = selection.GetTopLeftItem()->GetPosition();
|
VECTOR2I itemPos = selection.GetTopLeftItem()->GetPosition();
|
||||||
m_anchorPos = VECTOR2I( itemPos.x, -itemPos.y );
|
m_anchorPos = VECTOR2I( itemPos.x, itemPos.y );
|
||||||
|
|
||||||
getViewControls()->WarpMouseCursor( m_anchorPos, true, true );
|
getViewControls()->WarpMouseCursor( m_anchorPos, true, true );
|
||||||
m_cursor = m_anchorPos;
|
m_cursor = m_anchorPos;
|
||||||
|
|
Loading…
Reference in New Issue