Commit f37812f8 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Refactoring: split in two the SCH_BUS_ENTRY class

parent 0dd413a7
......@@ -43,28 +43,36 @@
static int s_LastShape = '\\';
SCH_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusEntry( wxDC* aDC, int aType )
SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC )
{
SCH_SCREEN* screen = GetScreen();
// Create and place a new bus entry at cursor position
SCH_BUS_ENTRY* busEntry = new SCH_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape,
aType );
SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToList( aDC );
return busEntry;
}
SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry( wxDC* aDC )
{
SCH_SCREEN* screen = GetScreen();
// Create and place a new bus entry at cursor position
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToList( aDC );
return busEntry;
}
/* set the shape of BusEntry (shape = / or \ )
*/
void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_shape )
void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape )
{
if( BusEntry == NULL )
return;
if( BusEntry->Type() != SCH_BUS_ENTRY_T )
{
DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
return;
......
......@@ -147,6 +147,7 @@ again." );
while( reader.ReadLine() )
{
itemLoaded = false;
line = reader.Line();
item = NULL;
......@@ -167,6 +168,8 @@ again." );
itemLoaded = ReadSchemaDescr( &reader, msgDiag, aScreen );
else if( line[1] == 'B' )
item = new SCH_BITMAP();
else if( line[1] == 'E' )
itemLoaded = true; // The EOF marker
break;
case 'L': // Its a library item.
......@@ -178,7 +181,9 @@ again." );
break;
case 'E': // Its a WIRE or BUS item.
item = new SCH_BUS_ENTRY();
/* The bus entry can be represented by two different
* classes, so we need a factory function */
itemLoaded = SCH_BUS_ENTRY_BASE::Load( reader, msgDiag, &item );
break;
case 'C': // It is a connection item.
......@@ -220,6 +225,8 @@ again." );
if( item )
{
// Load it if it wasn't by a factory
if( !itemLoaded )
itemLoaded = item->Load( reader, msgDiag );
if( !itemLoaded )
......
......@@ -70,7 +70,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_TEXT_T:
case SCH_SHEET_PIN_T:
case SCH_SHEET_T:
case SCH_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_JUNCTION_T:
case SCH_COMPONENT_T:
case SCH_FIELD_T:
......@@ -157,11 +158,20 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_WIRETOBUS_ENTRY_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
CreateBusWireEntry( aDC );
m_canvas->SetAutoPanRequest( true );
}
else
{
addCurrentItemToList( aDC );
}
break;
case ID_BUSTOBUS_ENTRY_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
CreateBusEntry( aDC, ( GetToolId() == ID_WIRETOBUS_ENTRY_BUTT ) ?
WIRE_TO_BUS : BUS_TO_BUS );
CreateBusBusEntry( aDC );
m_canvas->SetAutoPanRequest( true );
}
else
......
......@@ -64,7 +64,7 @@ static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component );
static void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field );
static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame );
static void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap );
static void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY * aBusEntry );
static void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE * aBusEntry );
......@@ -219,8 +219,9 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
addJunctionMenuEntries( PopMenu, (SCH_JUNCTION*) item );
break;
case SCH_BUS_ENTRY_T:
AddMenusForBusEntry( PopMenu, (SCH_BUS_ENTRY*) item );
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
AddMenusForBusEntry( PopMenu, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ) );
break;
case SCH_MARKER_T:
......@@ -873,7 +874,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
}
}
void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY * aBusEntry )
void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE* aBusEntry )
{
wxString msg;
if( !aBusEntry->GetFlags() )
......
......@@ -31,7 +31,8 @@ void SetSchItemParent( SCH_ITEM* Struct, SCH_SCREEN* Screen )
case SCH_HIERARCHICAL_LABEL_T:
case SCH_COMPONENT_T:
case SCH_LINE_T:
case SCH_BUS_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_SHEET_T:
case SCH_MARKER_T:
case SCH_NO_CONNECT_T:
......@@ -185,7 +186,8 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
{
case SCH_JUNCTION_T:
case SCH_LINE_T:
case SCH_BUS_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
......
......@@ -42,80 +42,81 @@
#include <sch_bus_entry.h>
SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) :
SCH_ITEM( NULL, SCH_BUS_ENTRY_T )
SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, char shape ) :
SCH_ITEM( NULL, aType )
{
m_pos = pos;
m_size.x = 100;
m_size.y = 100;
m_Layer = LAYER_WIRE;
m_width = 0;
if( id == BUS_TO_BUS )
{
m_Layer = LAYER_BUS;
}
if( shape == '/' )
m_size.y = -100;
}
SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, char shape ) :
SCH_BUS_ENTRY_BASE( SCH_BUS_WIRE_ENTRY_T, pos, shape )
{
m_Layer = LAYER_WIRE;
}
EDA_ITEM* SCH_BUS_ENTRY::Clone() const
SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, char shape ) :
SCH_BUS_ENTRY_BASE( SCH_BUS_BUS_ENTRY_T, pos, shape )
{
return new SCH_BUS_ENTRY( *this );
m_Layer = LAYER_BUS;
}
EDA_ITEM* SCH_BUS_WIRE_ENTRY::Clone() const
{
return new SCH_BUS_WIRE_ENTRY( *this );
}
wxPoint SCH_BUS_ENTRY::m_End() const
EDA_ITEM* SCH_BUS_BUS_ENTRY::Clone() const
{
return new SCH_BUS_BUS_ENTRY( *this );
}
wxPoint SCH_BUS_ENTRY_BASE::m_End() const
{
return wxPoint( m_pos.x + m_size.x, m_pos.y + m_size.y );
}
void SCH_BUS_ENTRY::SwapData( SCH_ITEM* aItem )
void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem )
{
wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_BUS_ENTRY_T),
wxT( "Cannot swap bus entry data with invalid item." ) );
SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
SCH_BUS_ENTRY* item = (SCH_BUS_ENTRY*)aItem;
EXCHG( m_pos, item->m_pos );
EXCHG( m_size, item->m_size );
EXCHG( m_width, item->m_width );
}
bool SCH_BUS_ENTRY::Save( FILE* aFile ) const
bool SCH_BUS_WIRE_ENTRY::Save( FILE* aFile ) const
{
bool success = true;
const char* layer = "Wire";
const char* width = "Line";
if( fprintf( aFile, "Entry Wire Line\n\t%-4d %-4d %-4d %-4d\n",
m_pos.x, m_pos.y, m_End().x, m_End().y ) == EOF )
return false;
return true;
}
if( GetLayer() == LAYER_BUS )
{
layer = "Bus"; width = "Bus";
}
if( fprintf( aFile, "Entry %s %s\n", layer, width ) == EOF )
{
success = false;
}
if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n",
bool SCH_BUS_BUS_ENTRY::Save( FILE* aFile ) const
{
if( fprintf( aFile, "Entry Bus Bus\n\t%-4d %-4d %-4d %-4d\n",
m_pos.x, m_pos.y, m_End().x, m_End().y ) == EOF )
{
success = false;
}
return success;
return false;
return true;
}
bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg,
SCH_ITEM **out )
{
char Name1[256];
char Name2[256];
char* line = (char*) aLine;
*out = NULL;
while( (*line != ' ' ) && *line )
line++;
......@@ -128,13 +129,16 @@ bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
return false;
}
m_Layer = LAYER_WIRE;
SCH_BUS_ENTRY_BASE *this_new;
if( Name1[0] == 'B' )
m_Layer = LAYER_BUS;
this_new = new SCH_BUS_BUS_ENTRY;
else
this_new = new SCH_BUS_WIRE_ENTRY;
*out = this_new;
if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", &m_pos.x, &m_pos.y,
&m_size.x, &m_size.y ) != 4 )
if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ",
&this_new->m_pos.x, &this_new->m_pos.y,
&this_new->m_size.x, &this_new->m_size.y ) != 4 )
{
aErrorMsg.Printf( wxT( "Eeschema file bus entry load error at line %d" ),
aLine.LineNumber() );
......@@ -142,14 +146,14 @@ bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
return false;
}
m_size.x -= m_pos.x;
m_size.y -= m_pos.y;
this_new->m_size.x -= this_new->m_pos.x;
this_new->m_size.y -= this_new->m_pos.y;
return true;
}
EDA_RECT SCH_BUS_ENTRY::GetBoundingBox() const
EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const
{
EDA_RECT box;
......@@ -157,27 +161,25 @@ EDA_RECT SCH_BUS_ENTRY::GetBoundingBox() const
box.SetEnd( m_End() );
box.Normalize();
int width = ( m_width == 0 ) ? GetDefaultLineThickness() : m_width;
box.Inflate( width / 2 );
box.Inflate( GetPenSize() / 2 );
return box;
}
int SCH_BUS_ENTRY::GetPenSize() const
int SCH_BUS_WIRE_ENTRY::GetPenSize() const
{
int pensize = ( m_width == 0 ) ? GetDefaultLineThickness() : m_width;
return GetDefaultLineThickness();
}
if( m_Layer == LAYER_BUS )
{
pensize = ( m_width == 0 ) ? GetDefaultBusThickness() : m_width;
}
return pensize;
int SCH_BUS_BUS_ENTRY::GetPenSize() const
{
return GetDefaultBusThickness();
}
void SCH_BUS_ENTRY::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
{
EDA_COLOR_T color;
......@@ -194,7 +196,7 @@ void SCH_BUS_ENTRY::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOff
}
void SCH_BUS_ENTRY::MirrorX( int aXaxis_position )
void SCH_BUS_ENTRY_BASE::MirrorX( int aXaxis_position )
{
m_pos.y -= aXaxis_position;
NEGATE( m_pos.y );
......@@ -203,7 +205,7 @@ void SCH_BUS_ENTRY::MirrorX( int aXaxis_position )
}
void SCH_BUS_ENTRY::MirrorY( int aYaxis_position )
void SCH_BUS_ENTRY_BASE::MirrorY( int aYaxis_position )
{
m_pos.x -= aYaxis_position;
NEGATE( m_pos.x );
......@@ -212,14 +214,14 @@ void SCH_BUS_ENTRY::MirrorY( int aYaxis_position )
}
void SCH_BUS_ENTRY::Rotate( wxPoint aPosition )
void SCH_BUS_ENTRY_BASE::Rotate( wxPoint aPosition )
{
RotatePoint( &m_pos, aPosition, 900 );
RotatePoint( &m_size.x, &m_size.y, 900 );
}
void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
void SCH_BUS_ENTRY_BASE::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{
DANGLING_END_ITEM item( ENTRY_END, this, m_pos );
aItemList.push_back( item );
......@@ -229,44 +231,47 @@ void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
}
bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect )
bool SCH_BUS_ENTRY_BASE::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
// If either end of the bus entry is inside the selection rectangle, the entire
// bus entry is selected. Bus entries have a fixed length and angle.
if( aRect.Contains( m_pos ) || aRect.Contains( m_End() ) )
m_Flags |= SELECTED;
SetFlags( SELECTED );
else
m_Flags &= ~SELECTED;
ClearFlags( SELECTED );
return previousState != IsSelected();
}
void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const
void SCH_BUS_ENTRY_BASE::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_pos );
aPoints.push_back( m_End() );
}
wxString SCH_BUS_ENTRY::GetSelectMenuText() const
wxString SCH_BUS_WIRE_ENTRY::GetSelectMenuText() const
{
if( m_Layer == LAYER_WIRE )
return wxString( _( "Bus to Wire Entry" ) );
}
wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText() const
{
return wxString( _( "Bus to Bus Entry" ) );
}
bool SCH_BUS_ENTRY::HitTest( const wxPoint& aPosition, int aAccuracy ) const
bool SCH_BUS_ENTRY_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
return TestSegmentHit( aPosition, m_pos, m_End(), aAccuracy );
}
bool SCH_BUS_ENTRY::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT rect = aRect;
......@@ -279,7 +284,7 @@ bool SCH_BUS_ENTRY::HitTest( const EDA_RECT& aRect, bool aContained, int aAccura
}
void SCH_BUS_ENTRY::Plot( PLOTTER* aPlotter )
void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter )
{
aPlotter->SetCurrentLineWidth( GetPenSize() );
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
......@@ -291,7 +296,7 @@ void SCH_BUS_ENTRY::Plot( PLOTTER* aPlotter )
* Set the shape of the bus entry.
* aShape = ascii code '/' or '\'
*/
void SCH_BUS_ENTRY::SetBusEntryShape( int aShape )
void SCH_BUS_ENTRY_BASE::SetBusEntryShape( char aShape )
{
switch( aShape )
{
......@@ -311,12 +316,11 @@ void SCH_BUS_ENTRY::SetBusEntryShape( int aShape )
/* GetBusEntryShape:
* return the shape of the bus entry, as an ascii code '/' or '\'
*/
int SCH_BUS_ENTRY::GetBusEntryShape() const
char SCH_BUS_ENTRY_BASE::GetBusEntryShape() const
{
int shape = '\\';
if( GetSize().y < 0 )
shape = '/';
return shape;
return '/';
else
return '\\';
}
......@@ -33,33 +33,23 @@
#include <sch_item_struct.h>
/* Flags for BUS ENTRY (bus to bus or wire to bus */
#define WIRE_TO_BUS 0
#define BUS_TO_BUS 1
/**
* Class SCH_BUS_ENTRY
* Class SCH_BUS_ENTRY_BASE
*
* Defines a bus or wire entry.
* Base class for a bus or wire entry.
*/
class SCH_BUS_ENTRY : public SCH_ITEM
class SCH_BUS_ENTRY_BASE : public SCH_ITEM
{
protected:
wxPoint m_pos;
int m_width;
wxSize m_size;
public:
SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS );
SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_BUS_ENTRY() { }
wxString GetClass() const
{
return wxT( "SCH_BUS_ENTRY" );
}
~SCH_BUS_ENTRY_BASE() { }
wxPoint m_End() const;
......@@ -67,17 +57,13 @@ public:
* function GetBusEntryShape
* @return the shape of the bus entry, as an ascii code '/' or '\'
*/
int GetBusEntryShape() const;
char GetBusEntryShape() const;
/**
* function SetBusEntryShape
* @param aShape = the shape of the bus entry, as an ascii code '/' or '\'
*/
void SetBusEntryShape( int aShape );
int GetWidth() const { return m_width; }
void SetWidth( int aWidth ) { m_width = aWidth; }
void SetBusEntryShape( char aShape );
wxSize GetSize() const { return m_size; }
......@@ -88,14 +74,10 @@ public:
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
bool Save( FILE* aFile ) const;
bool Load( LINE_READER& aLine, wxString& aErrorMsg );
static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out );
EDA_RECT GetBoundingBox() const;
int GetPenSize() const;
void Move( const wxPoint& aMoveVector )
{
m_pos += aMoveVector;
......@@ -116,8 +98,6 @@ public:
void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
wxString GetSelectMenuText() const;
BITMAP_DEF GetMenuImage() const { return add_entry_xpm; }
wxPoint GetPosition() const { return m_pos; }
......@@ -130,12 +110,61 @@ public:
void Plot( PLOTTER* aPlotter );
EDA_ITEM* Clone() const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
};
/**
* Class SCH_BUS_WIRE_ENTRY
*
* Class for a wire to bus entry.
*/
class SCH_BUS_WIRE_ENTRY : public SCH_BUS_ENTRY_BASE
{
public:
SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
~SCH_BUS_WIRE_ENTRY() { }
wxString GetClass() const
{
return wxT( "SCH_BUS_WIRE_ENTRY" );
}
bool Save( FILE* aFile ) const;
int GetPenSize() const;
wxString GetSelectMenuText() const;
EDA_ITEM* Clone() const;
};
/**
* Class SCH_BUS_WIRE_ENTRY
*
* Class for a bus to bus entry.
*/
class SCH_BUS_BUS_ENTRY : public SCH_BUS_ENTRY_BASE
{
public:
SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
~SCH_BUS_BUS_ENTRY() { }
wxString GetClass() const
{
return wxT( "SCH_BUS_BUS_ENTRY" );
}
bool Save( FILE* aFile ) const;
int GetPenSize() const;
wxString GetSelectMenuText() const;
EDA_ITEM* Clone() const;
};
#endif // _SCH_BUS_ENTRY_H_
......@@ -33,13 +33,15 @@
#include <sch_collectors.h>
#include <sch_component.h>
#include <sch_line.h>
#include <sch_bus_entry.h>
const KICAD_T SCH_COLLECTOR::AllItems[] = {
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,
SCH_BUS_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_LINE_T,
SCH_BITMAP_T,
SCH_TEXT_T,
......@@ -59,7 +61,8 @@ const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = {
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,
SCH_BUS_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_LINE_T,
SCH_BITMAP_T,
SCH_TEXT_T,
......@@ -107,7 +110,8 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = {
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,
SCH_BUS_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_BUS_WIRE_ENTRY_T,
// SCH_LINE_T,
SCH_BITMAP_T,
SCH_TEXT_T,
......@@ -124,7 +128,8 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = {
const KICAD_T SCH_COLLECTOR::DraggableItems[] = {
SCH_JUNCTION_T,
SCH_BUS_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_LINE_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
......@@ -152,7 +157,8 @@ const KICAD_T SCH_COLLECTOR::ParentItems[] = {
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,
SCH_BUS_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_LINE_T,
SCH_TEXT_T,
SCH_LABEL_T,
......@@ -241,13 +247,16 @@ bool SCH_COLLECTOR::IsCorner() const
if( GetCount() != 2 )
return false;
bool is_busentry0 = dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[0] );
bool is_busentry1 = dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[1] );
if( (m_List[0]->Type() == SCH_LINE_T) && (m_List[1]->Type() == SCH_LINE_T) )
return true;
if( (m_List[0]->Type() == SCH_LINE_T) && (m_List[1]->Type() == SCH_BUS_ENTRY_T) )
if( (m_List[0]->Type() == SCH_LINE_T) && is_busentry1 )
return true;
if( (m_List[0]->Type() == SCH_BUS_ENTRY_T) && (m_List[1]->Type() == SCH_LINE_T) )
if( is_busentry0 && (m_List[1]->Type() == SCH_LINE_T) )
return true;
return false;
......
......@@ -394,7 +394,10 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
break;
case LAYER_WIRE:
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_ENTRY_T ) )
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_WIRE_ENTRY_T) )
return true;
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) )
return true;
if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) )
......@@ -958,15 +961,17 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
if( BreakSegment( junction->GetPosition() ) )
brokenSegments = true;
}
else if( item->Type() == SCH_BUS_ENTRY_T )
else
{
SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( item );
if( busEntry )
{
SCH_BUS_ENTRY* busEntry = ( SCH_BUS_ENTRY* ) item;
if( BreakSegment( busEntry->GetPosition() )
|| BreakSegment( busEntry->m_End() ) )
brokenSegments = true;
}
}
}
return brokenSegments;
}
......
......@@ -137,12 +137,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
m_canvas->MoveCursorToCrossHair();
SetBusEntryShape( &dc, (SCH_BUS_ENTRY*) item, '/' );
SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
break;
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
m_canvas->MoveCursorToCrossHair();
SetBusEntryShape( &dc, (SCH_BUS_ENTRY*) item, '\\' );
SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
......@@ -417,7 +417,8 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
case SCH_JUNCTION_T:
case SCH_NO_CONNECT_T:
case SCH_BUS_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
......@@ -939,7 +940,8 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
switch( item->Type() )
{
case SCH_BUS_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_LINE_T:
case SCH_JUNCTION_T:
if( item->GetLayer() == LAYER_BUS )
......
......@@ -82,7 +82,8 @@ enum KICAD_T {
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,
SCH_BUS_ENTRY_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_LINE_T,
SCH_BITMAP_T,
SCH_TEXT_T,
......
......@@ -48,7 +48,9 @@ class CMP_LIBRARY;
class LIB_COMPONENT;
class LIB_DRAW_ITEM;
class EDA_ITEM;
class SCH_BUS_ENTRY;
class SCH_BUS_ENTRY_BASE;
class SCH_BUS_WIRE_ENTRY;
class SCH_BUS_BUS_ENTRY;
class SCH_GLOBALLABEL;
class SCH_TEXT;
class SCH_BITMAP;
......@@ -811,8 +813,9 @@ private:
void UpdateTitle();
// Bus Entry
SCH_BUS_ENTRY* CreateBusEntry( wxDC* DC, int entry_type );
void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_type );
SCH_BUS_WIRE_ENTRY* CreateBusWireEntry( wxDC* DC );
SCH_BUS_BUS_ENTRY* CreateBusBusEntry( wxDC* DC );
void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape );
/**
* Function AddNoConnect
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment