altium: improve orientation of net label

It is interesting, because altium allows text which is upside-down. Of course, KiCad does
not allow this sensless thing.
This commit is contained in:
Thomas Pointhuber 2020-10-14 21:38:12 +02:00 committed by Jon Evans
parent ad93396d35
commit 1400e5cdb9
3 changed files with 35 additions and 29 deletions

View File

@ -106,7 +106,7 @@ ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProperties )
int pinconglomerate = ALTIUM_PARSER::PropertiesReadInt( aProperties, "PINCONGLOMERATE", 0 );
orientation = static_cast<ASCH_PIN_ORIENTATION>( pinconglomerate & 0x03 );
orientation = static_cast<ASCH_RECORD_ORIENTATION>( pinconglomerate & 0x03 );
showPinName = ( pinconglomerate & 0x08 ) != 0;
showDesignator = ( pinconglomerate & 0x10 ) != 0;
@ -128,19 +128,19 @@ ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProperties )
switch( orientation )
{
case ASCH_PIN_ORIENTATION::RIGHTWARDS:
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
kicadX += p;
kicadXfrac += pfrac;
break;
case ASCH_PIN_ORIENTATION::UPWARDS:
case ASCH_RECORD_ORIENTATION::UPWARDS:
kicadY += p;
kicadYfrac += pfrac;
break;
case ASCH_PIN_ORIENTATION::LEFTWARDS:
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
kicadX -= p;
kicadXfrac -= pfrac;
break;
case ASCH_PIN_ORIENTATION::DOWNWARDS:
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
kicadY -= p;
kicadYfrac -= pfrac;
break;
@ -331,10 +331,14 @@ ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProperties
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NET_LABEL );
text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" );
orientation = ALTIUM_PARSER::PropertiesReadInt( aProperties, "ORIENTATION", 0 );
location = wxPoint( PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.X" ),
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
int orientationRaw = ALTIUM_PARSER::PropertiesReadInt( aProperties, "ORIENTATION", 0 );
orientation = orientationRaw >= 0 && orientationRaw <= 3 ?
static_cast<ASCH_RECORD_ORIENTATION>( orientationRaw ) :
ASCH_RECORD_ORIENTATION::RIGHTWARDS;
}

View File

@ -82,6 +82,15 @@ enum class ALTIUM_SCH_RECORD
};
enum class ASCH_RECORD_ORIENTATION
{
RIGHTWARDS = 0,
UPWARDS = 1,
LEFTWARDS = 2,
DOWNWARDS = 3
};
struct ASCH_COMPONENT
{
int currentpartid;
@ -158,15 +167,6 @@ enum class ASCH_PIN_ELECTRICAL
};
enum class ASCH_PIN_ORIENTATION
{
RIGHTWARDS = 0,
UPWARDS = 1,
LEFTWARDS = 2,
DOWNWARDS = 3
};
struct ASCH_PIN
{
int ownerindex;
@ -183,7 +183,7 @@ struct ASCH_PIN
ASCH_PIN_SYMBOL_INNEREDGE symbolInnerEdge;
ASCH_PIN_ELECTRICAL electrical;
ASCH_PIN_ORIENTATION orientation;
ASCH_RECORD_ORIENTATION orientation;
wxPoint location;
int pinlength;
@ -335,9 +335,11 @@ struct ASCH_NO_ERC
struct ASCH_NET_LABEL
{
wxString text;
int orientation;
wxPoint location;
ASCH_RECORD_ORIENTATION orientation;
explicit ASCH_NET_LABEL( const std::map<wxString, wxString>& aProperties );
};

View File

@ -493,19 +493,19 @@ void SCH_ALTIUM_PLUGIN::ParsePin( const std::map<wxString, wxString>& aPropertie
wxPoint pinLocation = elem.location; // the location given is not the connection point!
switch( elem.orientation )
{
case ASCH_PIN_ORIENTATION::RIGHTWARDS:
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
pin->SetOrientation( DrawPinOrient::PIN_LEFT );
pinLocation.x += elem.pinlength;
break;
case ASCH_PIN_ORIENTATION::UPWARDS:
case ASCH_RECORD_ORIENTATION::UPWARDS:
pin->SetOrientation( DrawPinOrient::PIN_DOWN );
pinLocation.y -= elem.pinlength;
break;
case ASCH_PIN_ORIENTATION::LEFTWARDS:
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
pin->SetOrientation( DrawPinOrient::PIN_RIGHT );
pinLocation.x -= elem.pinlength;
break;
case ASCH_PIN_ORIENTATION::DOWNWARDS:
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
pin->SetOrientation( DrawPinOrient::PIN_UP );
pinLocation.y += elem.pinlength;
break;
@ -1074,16 +1074,16 @@ void SCH_ALTIUM_PLUGIN::ParseNetLabel( const std::map<wxString, wxString>& aProp
switch( elem.orientation )
{
case 0:
label->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT );
break;
case 1:
label->SetLabelSpinStyle( LABEL_SPIN_STYLE::UP );
break;
case 2:
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
label->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT );
break;
case 3:
case ASCH_RECORD_ORIENTATION::UPWARDS:
label->SetLabelSpinStyle( LABEL_SPIN_STYLE::UP );
break;
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
label->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT );
break;
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
label->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM );
break;
default: