2009-04-06 10:56:17 +00:00
|
|
|
/************************/
|
|
|
|
/* sch_item_struct.cpp */
|
|
|
|
/************************/
|
2009-04-05 21:07:24 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "base_struct.h"
|
|
|
|
#include "sch_item_struct.h"
|
|
|
|
#include "class_sch_screen.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "wxEeschemaStruct.h"
|
|
|
|
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
#include "../eeschema/dialogs/dialog_schematic_find.h"
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 )
|
|
|
|
{
|
|
|
|
return *aItem1 < *aItem2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 21:07:24 +00:00
|
|
|
/* Constructor and destructor for SCH_ITEM */
|
|
|
|
/* They are not inline because this creates problems with gcc at linking time
|
|
|
|
* in debug mode
|
2011-06-17 13:24:22 +00:00
|
|
|
*/
|
2009-04-05 21:07:24 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
|
|
|
|
EDA_ITEM( aParent, aType )
|
2009-04-05 21:07:24 +00:00
|
|
|
{
|
|
|
|
m_Layer = 0;
|
|
|
|
}
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) :
|
|
|
|
EDA_ITEM( aItem )
|
|
|
|
{
|
|
|
|
m_Layer = aItem.m_Layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 21:07:24 +00:00
|
|
|
SCH_ITEM::~SCH_ITEM()
|
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
// Do not let the connections container go out of scope with any objects or they
|
2011-09-30 18:15:37 +00:00
|
|
|
// will be deleted by the container will cause the Eeschema to crash. These objects
|
2010-11-10 15:30:12 +00:00
|
|
|
// are owned by the sheet object container.
|
|
|
|
if( !m_connections.empty() )
|
2011-03-25 19:16:05 +00:00
|
|
|
m_connections.clear();
|
2009-04-05 21:07:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2009-04-05 21:07:24 +00:00
|
|
|
/**
|
2010-12-08 20:12:46 +00:00
|
|
|
* place the struct in m_drawList.
|
2009-04-05 21:07:24 +00:00
|
|
|
* if it is a new item, it it also put in undo list
|
2011-03-25 19:16:05 +00:00
|
|
|
* for an "old" item, saving it in undo list must be done before editing,
|
2009-04-05 21:07:24 +00:00
|
|
|
* and not here!
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
|
2009-04-05 21:07:24 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
SCH_SCREEN* screen = aFrame->GetScreen();
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( IsNew() )
|
2009-04-05 21:07:24 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
if( !screen->CheckIfOnDrawList( this ) ) // don't want a loop!
|
2009-04-05 21:07:24 +00:00
|
|
|
screen->AddToDrawList( this );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
aFrame->SetRepeatItem( this );
|
|
|
|
aFrame->SaveCopyInUndoList( this, UR_NEW );
|
2009-04-05 21:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Flags = 0;
|
2011-02-03 19:27:28 +00:00
|
|
|
screen->SetModify();
|
|
|
|
screen->SetCurItem( NULL );
|
2011-02-11 20:48:13 +00:00
|
|
|
aFrame->DrawPanel->SetMouseCapture( NULL, NULL );
|
2009-04-05 21:07:24 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aDC )
|
2009-04-05 21:07:24 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
EDA_CROSS_HAIR_MANAGER( aFrame->DrawPanel, aDC ); // Erase schematic cursor
|
2011-02-03 19:27:28 +00:00
|
|
|
Draw( aFrame->DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
2009-04-05 21:07:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SCH_ITEM::Matches( const wxString& aText, wxFindReplaceData& aSearchData )
|
|
|
|
{
|
|
|
|
wxString text = aText;
|
|
|
|
wxString searchText = aSearchData.GetFindString();
|
|
|
|
|
|
|
|
if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
|
|
|
|
return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
|
|
|
|
|
|
|
|
if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
|
|
|
|
{
|
|
|
|
if( aSearchData.GetFlags() & wxFR_MATCHCASE )
|
|
|
|
return text.Matches( searchText );
|
|
|
|
|
|
|
|
return text.MakeUpper().Matches( searchText.MakeUpper() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aSearchData.GetFlags() & wxFR_MATCHCASE )
|
|
|
|
return aText.Find( searchText ) != wxNOT_FOUND;
|
|
|
|
|
|
|
|
return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
|
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const
|
|
|
|
{
|
|
|
|
if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT )
|
|
|
|
return false;
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
return doIsConnected( aPosition );
|
2010-12-13 15:59:00 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
void SCH_ITEM::SwapData( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxT( "SwapData() method not implemented for class " ) + GetClass() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( false, this->Type() < aItem.Type(),
|
|
|
|
wxT( "Less than operator not defined for " ) + GetClass() );
|
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_ITEM::doPlot( PLOTTER* aPlotter )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxT( "doPlot() method not implemented for class " ) + GetClass() );
|
|
|
|
}
|