Naming conventions and formatting.

This commit is contained in:
Jeff Young 2020-12-18 17:41:56 +00:00
parent 06aa1506ee
commit 189b1742f7
2 changed files with 116 additions and 106 deletions

View File

@ -30,23 +30,23 @@
* annoying if they happened without permission. * annoying if they happened without permission.
* Short description of the process: * Short description of the process:
* *
* 1. Compute the dimensions of the fields' bounding box ::ComputeFBoxSize * 1. Compute the dimensions of the fields' bounding box ::computeFBoxSize
* 2. Determine which side the fields will go on. ::choose_side_for_fields * 2. Determine which side the fields will go on. ::chooseSideForFields
* 1. Sort the four sides in preference order, * 1. Sort the four sides in preference order,
* depending on the component's shape and * depending on the component's shape and
* orientation ::get_preferred_sides * orientation ::getPreferredSides
* 2. If in manual mode, sift out the sides that would * 2. If in manual mode, sift out the sides that would
* cause fields to overlap other items ::get_colliding_sides * cause fields to overlap other items ::getCollidingSides
* 3. If any remaining sides have zero pins there, * 3. If any remaining sides have zero pins there,
* choose the highest zero-pin side according to * choose the highest zero-pin side according to
* preference order. * preference order.
* 4. If all sides have pins, choose the side with the * 4. If all sides have pins, choose the side with the
* fewest pins. * fewest pins.
* 3. Compute the position of the fields' bounding box ::field_box_placement * 3. Compute the position of the fields' bounding box ::fieldBoxPlacement
* 4. In manual mode, shift the box vertically if possible * 4. In manual mode, shift the box vertically if possible
* to fit fields between adjacent wires ::fit_fields_between_wires * to fit fields between adjacent wires ::fitFieldsBetweenWires
* 5. Move all fields to their final positions * 5. Move all fields to their final positions
* 1. Re-justify fields if options allow that ::justify_field * 1. Re-justify fields if options allow that ::justifyField
* 2. Round to a 50-mil grid coordinate if desired * 2. Round to a 50-mil grid coordinate if desired
*/ */
@ -95,15 +95,6 @@ EDA_TEXT_HJUSTIFY_T TO_HJUSTIFY( int x )
class AUTOPLACER class AUTOPLACER
{ {
SCH_SCREEN* m_screen;
SCH_COMPONENT* m_component;
std::vector<SCH_FIELD*> m_fields;
std::vector<SCH_ITEM*> m_colliders;
EDA_RECT m_comp_bbox;
wxSize m_fbox_size;
bool m_allow_rejustify, m_align_to_grid;
bool m_power_symbol;
public: public:
typedef wxPoint SIDE; typedef wxPoint SIDE;
static const SIDE SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT; static const SIDE SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT;
@ -121,11 +112,11 @@ public:
COLLISION collision; COLLISION collision;
}; };
AUTOPLACER( SCH_COMPONENT* aSymbol, SCH_SCREEN* aScreen ) :
AUTOPLACER( SCH_COMPONENT* aComponent, SCH_SCREEN* aScreen ) : m_screen( aScreen ),
m_screen( aScreen ), m_component( aComponent ) m_symbol( aSymbol )
{ {
m_component->GetFields( m_fields, /* aVisibleOnly */ true ); m_symbol->GetFields( m_fields, /* aVisibleOnly */ true );
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxASSERT( cfg ); wxASSERT( cfg );
@ -139,16 +130,15 @@ public:
m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid; m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
} }
m_comp_bbox = m_component->GetBodyBoundingBox(); m_symbol_bbox = m_symbol->GetBodyBoundingBox();
m_fbox_size = ComputeFBoxSize( /* aDynamic */ true ); m_fbox_size = computeFBoxSize( /* aDynamic */ true );
m_power_symbol = ! m_component->IsInNetlist(); m_is_power_symbol = !m_symbol->IsInNetlist();
if( aScreen ) if( aScreen )
get_possible_colliders( m_colliders ); getPossibleCollisions( m_colliders );
} }
/** /**
* Do the actual autoplacement. * Do the actual autoplacement.
* @param aManual - if true, use extra heuristics for smarter placement when manually * @param aManual - if true, use extra heuristics for smarter placement when manually
@ -156,26 +146,26 @@ public:
*/ */
void DoAutoplace( bool aManual ) void DoAutoplace( bool aManual )
{ {
bool force_wire_spacing = false; bool force_wire_spacing = false;
SIDE field_side = choose_side_for_fields( aManual ); SIDE field_side = chooseSideForFields( aManual );
wxPoint fbox_pos = field_box_placement( field_side ); wxPoint fbox_pos = fieldBoxPlacement( field_side );
EDA_RECT field_box( fbox_pos, m_fbox_size ); EDA_RECT field_box( fbox_pos, m_fbox_size );
if( aManual ) if( aManual )
force_wire_spacing = fit_fields_between_wires( &field_box, field_side ); force_wire_spacing = fitFieldsBetweenWires( &field_box, field_side );
// Move the fields // Move the fields
int last_y_coord = field_box.GetTop(); int last_y_coord = field_box.GetTop();
for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx ) for( unsigned field_idx = 0; field_idx < m_fields.size(); ++field_idx )
{ {
SCH_FIELD* field = m_fields[field_idx]; SCH_FIELD* field = m_fields[field_idx];
if( m_allow_rejustify ) if( m_allow_rejustify )
justify_field( field, field_side ); justifyField( field, field_side );
wxPoint pos( wxPoint pos( fieldHorizPlacement( field, field_box ),
field_horiz_placement( field, field_box ), fieldVertPlacement( field, field_box, &last_y_coord, !force_wire_spacing ) );
field_vert_placement( field, field_box, &last_y_coord, !force_wire_spacing ) );
if( m_align_to_grid ) if( m_align_to_grid )
{ {
@ -187,13 +177,12 @@ public:
} }
} }
protected: protected:
/** /**
* Compute and return the size of the fields' bounding box. * Compute and return the size of the fields' bounding box.
* @param aDynamic - if true, use dynamic spacing * @param aDynamic - if true, use dynamic spacing
*/ */
wxSize ComputeFBoxSize( bool aDynamic ) wxSize computeFBoxSize( bool aDynamic )
{ {
int max_field_width = 0; int max_field_width = 0;
int total_height = 0; int total_height = 0;
@ -203,7 +192,7 @@ protected:
int field_width; int field_width;
int field_height; int field_height;
if( m_component->GetTransform().y1 ) if( m_symbol->GetTransform().y1 )
{ {
field->SetTextAngle( TEXT_ANGLE_VERT ); field->SetTextAngle( TEXT_ANGLE_VERT );
} }
@ -218,7 +207,7 @@ protected:
max_field_width = std::max( max_field_width, field_width ); max_field_width = std::max( max_field_width, field_width );
if( aDynamic ) if( aDynamic )
total_height += field_height + get_field_padding(); total_height += field_height + getFieldPadding();
else else
total_height += WIRE_V_SPACING; total_height += WIRE_V_SPACING;
@ -227,13 +216,13 @@ protected:
return wxSize( max_field_width, total_height ); return wxSize( max_field_width, total_height );
} }
/** /**
* Return the side that a pin is on. * Return the side that a pin is on.
*/ */
SIDE get_pin_side( SCH_PIN* aPin ) SIDE getPinSide( SCH_PIN* aPin )
{ {
int pin_orient = aPin->GetLibPin()->PinDrawOrient( m_component->GetTransform() ); int pin_orient = aPin->GetLibPin()->PinDrawOrient( m_symbol->GetTransform() );
switch( pin_orient ) switch( pin_orient )
{ {
case PIN_RIGHT: return SIDE_LEFT; case PIN_RIGHT: return SIDE_LEFT;
@ -246,44 +235,44 @@ protected:
} }
} }
/** /**
* Count the number of pins on a side of the component. * Count the number of pins on a side of the component.
*/ */
unsigned pins_on_side( SIDE aSide ) unsigned pinsOnSide( SIDE aSide )
{ {
unsigned pin_count = 0; unsigned pin_count = 0;
for( SCH_PIN* each_pin : m_component->GetPins() ) for( SCH_PIN* each_pin : m_symbol->GetPins() )
{ {
if( !each_pin->IsVisible() && !m_power_symbol ) if( !each_pin->IsVisible() && !m_is_power_symbol )
continue; continue;
if( get_pin_side( each_pin ) == aSide )
if( getPinSide( each_pin ) == aSide )
++pin_count; ++pin_count;
} }
return pin_count; return pin_count;
} }
/** /**
* Populate a list of all drawing items that *may* collide with the fields. That is, * Populate a list of all drawing items that *may* collide with the fields. That is,
* all drawing items, including other fields, that are not the current component or * all drawing items, including other fields, that are not the current component or
* its own fields. * its own fields.
*/ */
void get_possible_colliders( std::vector<SCH_ITEM*>& aItems ) void getPossibleCollisions( std::vector<SCH_ITEM*>& aItems )
{ {
wxCHECK_RET( m_screen, "get_possible_colliders() with null m_screen" ); wxCHECK_RET( m_screen, "getPossibleCollisions() with null m_screen" );
for( auto item : m_screen->Items().Overlapping( m_component->GetBoundingBox() ) ) for( SCH_ITEM* item : m_screen->Items().Overlapping( m_symbol->GetBoundingBox() ) )
{ {
if( SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( item ) ) if( SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( item ) )
{ {
if( comp == m_component ) if( comp == m_symbol )
continue; continue;
std::vector<SCH_FIELD*> fields; std::vector<SCH_FIELD*> fields;
comp->GetFields( fields, /* aVisibleOnly */ true ); comp->GetFields( fields, /* aVisibleOnly */ true );
for( SCH_FIELD* field : fields ) for( SCH_FIELD* field : fields )
aItems.push_back( field ); aItems.push_back( field );
} }
@ -292,17 +281,18 @@ protected:
} }
} }
/** /**
* Filter a list of possible colliders to include only those that actually collide * Filter a list of possible colliders to include only those that actually collide
* with a given rectangle. Returns the new vector. * with a given rectangle. Returns the new vector.
*/ */
std::vector<SCH_ITEM*> filtered_colliders( const EDA_RECT& aRect ) std::vector<SCH_ITEM*> filterCollisions( const EDA_RECT& aRect )
{ {
std::vector<SCH_ITEM*> filtered; std::vector<SCH_ITEM*> filtered;
for( SCH_ITEM* item : m_colliders ) for( SCH_ITEM* item : m_colliders )
{ {
EDA_RECT item_box; EDA_RECT item_box;
if( SCH_COMPONENT* item_comp = dynamic_cast<SCH_COMPONENT*>( item ) ) if( SCH_COMPONENT* item_comp = dynamic_cast<SCH_COMPONENT*>( item ) )
item_box = item_comp->GetBodyBoundingBox(); item_box = item_comp->GetBodyBoundingBox();
else else
@ -314,32 +304,31 @@ protected:
return filtered; return filtered;
} }
/** /**
* Return a list with the preferred field sides for the component, in * Return a list with the preferred field sides for the component, in
* decreasing order of preference. * decreasing order of preference.
*/ */
std::vector<SIDE_AND_NPINS> get_preferred_sides() std::vector<SIDE_AND_NPINS> getPreferredSides()
{ {
SIDE_AND_NPINS sides_init[] = { SIDE_AND_NPINS sides_init[] = {
{ SIDE_RIGHT, pins_on_side( SIDE_RIGHT ) }, { SIDE_RIGHT, pinsOnSide( SIDE_RIGHT ) },
{ SIDE_TOP, pins_on_side( SIDE_TOP ) }, { SIDE_TOP, pinsOnSide( SIDE_TOP ) },
{ SIDE_LEFT, pins_on_side( SIDE_LEFT ) }, { SIDE_LEFT, pinsOnSide( SIDE_LEFT ) },
{ SIDE_BOTTOM, pins_on_side( SIDE_BOTTOM ) }, { SIDE_BOTTOM, pinsOnSide( SIDE_BOTTOM ) },
}; };
std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) ); std::vector<SIDE_AND_NPINS> sides( sides_init, sides_init + arrayDim( sides_init ) );
int orient = m_component->GetOrientation(); int orient = m_symbol->GetOrientation();
int orient_angle = orient & 0xff; // enum is a bitmask int orient_angle = orient & 0xff; // enum is a bitmask
bool h_mirrored = ( ( orient & CMP_MIRROR_X ) bool h_mirrored = ( ( orient & CMP_MIRROR_X )
&& ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) ); && ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) );
double w = double( m_comp_bbox.GetWidth() ); double w = double( m_symbol_bbox.GetWidth() );
double h = double( m_comp_bbox.GetHeight() ); double h = double( m_symbol_bbox.GetHeight() );
// The preferred-sides heuristics are a bit magical. These were determined mostly // The preferred-sides heuristics are a bit magical. These were determined mostly
// by trial and error. // by trial and error.
if( m_power_symbol ) if( m_is_power_symbol )
{ {
// For power symbols, we generally want the label at the top first. // For power symbols, we generally want the label at the top first.
switch( orient_angle ) switch( orient_angle )
@ -383,35 +372,39 @@ protected:
return sides; return sides;
} }
/** /**
* Return a list of the sides where a field set would collide with another item. * Return a list of the sides where a field set would collide with another item.
*/ */
std::vector<SIDE_AND_COLL> get_colliding_sides() std::vector<SIDE_AND_COLL> getCollidingSides()
{ {
SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM }; SIDE sides_init[] = { SIDE_RIGHT, SIDE_TOP, SIDE_LEFT, SIDE_BOTTOM };
std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) ); std::vector<SIDE> sides( sides_init, sides_init + arrayDim( sides_init ) );
std::vector<SIDE_AND_COLL> colliding; std::vector<SIDE_AND_COLL> colliding;
// Iterate over all sides and find the ones that collide // Iterate over all sides and find the ones that collide
for( SIDE side : sides ) for( SIDE side : sides )
{ {
EDA_RECT box( field_box_placement( side ), m_fbox_size ); EDA_RECT box( fieldBoxPlacement( side ), m_fbox_size );
COLLISION collision = COLLIDE_NONE; COLLISION collision = COLLIDE_NONE;
for( SCH_ITEM* collider : filtered_colliders( box ) )
for( SCH_ITEM* collider : filterCollisions( box ) )
{ {
SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider ); SCH_LINE* line = dynamic_cast<SCH_LINE*>( collider );
if( line && !side.x ) if( line && !side.x )
{ {
wxPoint start = line->GetStartPoint(), end = line->GetEndPoint(); wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
if( start.y == end.y && collision != COLLIDE_OBJECTS ) if( start.y == end.y && collision != COLLIDE_OBJECTS )
collision = COLLIDE_H_WIRES; collision = COLLIDE_H_WIRES;
else else
collision = COLLIDE_OBJECTS; collision = COLLIDE_OBJECTS;
} }
else else
{
collision = COLLIDE_OBJECTS; collision = COLLIDE_OBJECTS;
}
} }
if( collision != COLLIDE_NONE ) if( collision != COLLIDE_NONE )
@ -421,28 +414,33 @@ protected:
return colliding; return colliding;
} }
/** /**
* Choose a side for the fields, filtered on only one side collision type. * Choose a side for the fields, filtered on only one side collision type.
* Removes the sides matching the filter from the list. * Removes the sides matching the filter from the list.
*/ */
SIDE_AND_NPINS choose_side_filtered( std::vector<SIDE_AND_NPINS>& aSides, SIDE_AND_NPINS chooseSideFiltered( std::vector<SIDE_AND_NPINS>& aSides,
const std::vector<SIDE_AND_COLL>& aCollidingSides, COLLISION aCollision, const std::vector<SIDE_AND_COLL>& aCollidingSides,
SIDE_AND_NPINS aLastSelection) COLLISION aCollision,
SIDE_AND_NPINS aLastSelection)
{ {
SIDE_AND_NPINS sel = aLastSelection; SIDE_AND_NPINS sel = aLastSelection;
std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin(); std::vector<SIDE_AND_NPINS>::iterator it = aSides.begin();
while( it != aSides.end() ) while( it != aSides.end() )
{ {
bool collide = false; bool collide = false;
for( SIDE_AND_COLL collision : aCollidingSides ) for( SIDE_AND_COLL collision : aCollidingSides )
{ {
if( collision.side == it->side && collision.collision == aCollision ) if( collision.side == it->side && collision.collision == aCollision )
collide = true; collide = true;
} }
if( !collide ) if( !collide )
{
++it; ++it;
}
else else
{ {
if( it->pins <= sel.pins ) if( it->pins <= sel.pins )
@ -450,30 +448,31 @@ protected:
sel.pins = it->pins; sel.pins = it->pins;
sel.side = it->side; sel.side = it->side;
} }
it = aSides.erase( it ); it = aSides.erase( it );
} }
} }
return sel; return sel;
} }
/** /**
* Look where a component's pins are to pick a side to put the fields on * Look where a component's pins are to pick a side to put the fields on
* @param aAvoidCollisions - if true, pick last the sides where the label will collide * @param aAvoidCollisions - if true, pick last the sides where the label will collide
* with other items. * with other items.
*/ */
SIDE choose_side_for_fields( bool aAvoidCollisions ) SIDE chooseSideForFields( bool aAvoidCollisions )
{ {
std::vector<SIDE_AND_NPINS> sides = get_preferred_sides(); std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
std::reverse( sides.begin(), sides.end() ); std::reverse( sides.begin(), sides.end() );
SIDE_AND_NPINS side = { wxPoint( 1, 0 ), UINT_MAX }; SIDE_AND_NPINS side = { wxPoint( 1, 0 ), UINT_MAX };
if( aAvoidCollisions ) if( aAvoidCollisions )
{ {
std::vector<SIDE_AND_COLL> colliding_sides = get_colliding_sides(); std::vector<SIDE_AND_COLL> colliding_sides = getCollidingSides();
side = choose_side_filtered( sides, colliding_sides, COLLIDE_OBJECTS, side ); side = chooseSideFiltered( sides, colliding_sides, COLLIDE_OBJECTS, side );
side = choose_side_filtered( sides, colliding_sides, COLLIDE_H_WIRES, side ); side = chooseSideFiltered( sides, colliding_sides, COLLIDE_H_WIRES, side );
} }
for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed ) for( SIDE_AND_NPINS& each_side : sides | boost::adaptors::reversed )
@ -493,52 +492,49 @@ protected:
return side.side; return side.side;
} }
/** /**
* Set the justification of a field based on the side it's supposed to be on, taking * Set the justification of a field based on the side it's supposed to be on, taking
* into account whether the field will be displayed with flipped justification due to * into account whether the field will be displayed with flipped justification due to
* mirroring. * mirroring.
*/ */
void justify_field( SCH_FIELD* aField, SIDE aFieldSide ) void justifyField( SCH_FIELD* aField, SIDE aFieldSide )
{ {
// Justification is set twice to allow IsHorizJustifyFlipped() to work correctly. // Justification is set twice to allow IsHorizJustifyFlipped() to work correctly.
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) ); aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x * aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) ); * ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
aField->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); aField->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
} }
/** /**
* Return the position of the field bounding box. * Return the position of the field bounding box.
*/ */
wxPoint field_box_placement( SIDE aFieldSide ) wxPoint fieldBoxPlacement( SIDE aFieldSide )
{ {
wxPoint fbox_center = m_comp_bbox.Centre(); wxPoint fbox_center = m_symbol_bbox.Centre();
int offs_x = ( m_comp_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2 + HPADDING; int offs_x = ( m_symbol_bbox.GetWidth() + m_fbox_size.GetWidth() ) / 2 + HPADDING;
int offs_y = ( m_comp_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2 + VPADDING; int offs_y = ( m_symbol_bbox.GetHeight() + m_fbox_size.GetHeight() ) / 2 + VPADDING;
fbox_center.x += aFieldSide.x * offs_x; fbox_center.x += aFieldSide.x * offs_x;
fbox_center.y += aFieldSide.y * offs_y; fbox_center.y += aFieldSide.y * offs_y;
wxPoint fbox_pos( wxPoint fbox_pos( fbox_center.x - m_fbox_size.GetWidth() / 2,
fbox_center.x - m_fbox_size.GetWidth() / 2, fbox_center.y - m_fbox_size.GetHeight() / 2 );
fbox_center.y - m_fbox_size.GetHeight() / 2 );
return fbox_pos; return fbox_pos;
} }
/** /**
* Shift a field box up or down a bit to make the fields fit between some wires. * Shift a field box up or down a bit to make the fields fit between some wires.
* Returns true if a shift was made. * Returns true if a shift was made.
*/ */
bool fit_fields_between_wires( EDA_RECT* aBox, SIDE aSide ) bool fitFieldsBetweenWires( EDA_RECT* aBox, SIDE aSide )
{ {
if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM ) if( aSide != SIDE_TOP && aSide != SIDE_BOTTOM )
return false; return false;
std::vector<SCH_ITEM*> colliders = filtered_colliders( *aBox ); std::vector<SCH_ITEM*> colliders = filterCollisions( *aBox );
if( colliders.empty() ) if( colliders.empty() )
return false; return false;
@ -548,13 +544,17 @@ protected:
for( SCH_ITEM* item : colliders ) for( SCH_ITEM* item : colliders )
{ {
SCH_LINE* line = dynamic_cast<SCH_LINE*>( item ); SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
if( !line ) if( !line )
return false; return false;
wxPoint start = line->GetStartPoint(), end = line->GetEndPoint(); wxPoint start = line->GetStartPoint(), end = line->GetEndPoint();
if( start.y != end.y ) if( start.y != end.y )
return false; return false;
int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING ); int this_offset = (3 * WIRE_V_SPACING / 2) - ( start.y % WIRE_V_SPACING );
if( offset == 0 ) if( offset == 0 )
offset = this_offset; offset = this_offset;
else if( offset != this_offset ) else if( offset != this_offset )
@ -563,18 +563,18 @@ protected:
// At this point we are recomputing the field box size. Do not // At this point we are recomputing the field box size. Do not
// return false after this point. // return false after this point.
m_fbox_size = ComputeFBoxSize( /* aDynamic */ false ); m_fbox_size = computeFBoxSize( /* aDynamic */ false );
wxPoint pos = aBox->GetPosition(); wxPoint pos = aBox->GetPosition();
// Remove the existing padding to get a bit more space to work with // Remove the existing padding to get a bit more space to work with
if( aSide == SIDE_BOTTOM ) if( aSide == SIDE_BOTTOM )
{ {
pos.y = m_comp_bbox.GetBottom() - get_field_padding(); pos.y = m_symbol_bbox.GetBottom() - getFieldPadding();
} }
else else
{ {
pos.y = m_comp_bbox.GetTop() - m_fbox_size.y + get_field_padding(); pos.y = m_symbol_bbox.GetTop() - m_fbox_size.y + getFieldPadding();
} }
pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM ); pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM );
@ -583,7 +583,6 @@ protected:
return true; return true;
} }
/** /**
* Place a field horizontally, taking into account the field width and justification. * Place a field horizontally, taking into account the field width and justification.
* *
@ -592,7 +591,7 @@ protected:
* *
* @return Correct field horizontal position * @return Correct field horizontal position
*/ */
int field_horiz_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox ) int fieldHorizPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox )
{ {
int field_hjust; int field_hjust;
int field_xcoord; int field_xcoord;
@ -632,8 +631,8 @@ protected:
* *
* @return Correct field vertical position * @return Correct field vertical position
*/ */
int field_vert_placement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum, int fieldVertPlacement( SCH_FIELD *aField, const EDA_RECT &aFieldBox, int *aPosAccum,
bool aDynamic ) bool aDynamic )
{ {
int field_height; int field_height;
int padding; int padding;
@ -642,7 +641,7 @@ protected:
{ {
field_height = aField->GetBoundingBox().GetHeight(); field_height = aField->GetBoundingBox().GetHeight();
padding = get_field_padding(); padding = getFieldPadding();
} }
else else
{ {
@ -660,7 +659,7 @@ protected:
/** /**
* Return the desired padding between fields. * Return the desired padding between fields.
*/ */
int get_field_padding() int getFieldPadding()
{ {
if( m_align_to_grid ) if( m_align_to_grid )
return FIELD_PADDING_ALIGNED; return FIELD_PADDING_ALIGNED;
@ -668,8 +667,19 @@ protected:
return FIELD_PADDING; return FIELD_PADDING;
} }
private:
SCH_SCREEN* m_screen;
SCH_COMPONENT* m_symbol;
std::vector<SCH_FIELD*> m_fields;
std::vector<SCH_ITEM*> m_colliders;
EDA_RECT m_symbol_bbox;
wxSize m_fbox_size;
bool m_allow_rejustify;
bool m_align_to_grid;
bool m_is_power_symbol;
}; };
const AUTOPLACER::SIDE AUTOPLACER::SIDE_TOP( 0, -1 ); const AUTOPLACER::SIDE AUTOPLACER::SIDE_TOP( 0, -1 );
const AUTOPLACER::SIDE AUTOPLACER::SIDE_BOTTOM( 0, 1 ); const AUTOPLACER::SIDE AUTOPLACER::SIDE_BOTTOM( 0, 1 );
const AUTOPLACER::SIDE AUTOPLACER::SIDE_LEFT( -1, 0 ); const AUTOPLACER::SIDE AUTOPLACER::SIDE_LEFT( -1, 0 );

View File

@ -71,7 +71,7 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName )
m_my_part->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp ); m_my_part->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp );
// Plot lib fields, not plotted by m_component->Plot(): // Plot lib fields, not plotted by m_my_part->Plot():
m_my_part->PlotLibFields( plotter, GetUnit(), GetConvert(), plotPos, temp ); m_my_part->PlotLibFields( plotter, GetUnit(), GetConvert(), plotPos, temp );
} }