2011-07-12 06:57:11 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2011-07-12 06:57:11 +00:00
|
|
|
*
|
2016-03-06 21:22:01 +00:00
|
|
|
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
|
2011-07-12 06:57:11 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
/**
|
|
|
|
* @file sch_collectors.cpp
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <macros.h>
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <transform.h>
|
|
|
|
#include <sch_collectors.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_line.h>
|
2013-04-01 10:35:20 +00:00
|
|
|
#include <sch_bus_entry.h>
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::AllItems[] = {
|
|
|
|
SCH_MARKER_T,
|
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_NO_CONNECT_T,
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_LINE_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_FIELD_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
LIB_PIN_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = {
|
|
|
|
SCH_MARKER_T,
|
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_NO_CONNECT_T,
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_LINE_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_FIELD_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::EditableItems[] = {
|
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_FIELD_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2017-10-31 16:33:37 +00:00
|
|
|
SCH_LINE_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
2012-12-08 17:24:49 +00:00
|
|
|
const KICAD_T SCH_COLLECTOR::CmpFieldValueOnly[] = {
|
|
|
|
SCH_FIELD_LOCATE_VALUE_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::CmpFieldReferenceOnly[] = {
|
|
|
|
SCH_FIELD_LOCATE_REFERENCE_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::CmpFieldFootprintOnly[] = {
|
|
|
|
SCH_FIELD_LOCATE_FOOTPRINT_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::MovableItems[] = {
|
|
|
|
SCH_MARKER_T,
|
2011-10-19 20:32:21 +00:00
|
|
|
SCH_JUNCTION_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_NO_CONNECT_T,
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
// SCH_LINE_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_FIELD_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::DraggableItems[] = {
|
|
|
|
SCH_JUNCTION_T,
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_LINE_T,
|
2012-12-21 12:56:17 +00:00
|
|
|
SCH_LABEL_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::RotatableItems[] = {
|
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_FIELD_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_SHEET_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::ParentItems[] = {
|
|
|
|
SCH_MARKER_T,
|
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_NO_CONNECT_T,
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
SCH_LINE_T,
|
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
2011-08-31 14:59:20 +00:00
|
|
|
SCH_BITMAP_T,
|
2011-07-12 06:57:11 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::ComponentsOnly[] = {
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::SheetsOnly[] = {
|
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const KICAD_T SCH_COLLECTOR::SheetsAndSheetLabels[] = {
|
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-10-28 20:30:50 +00:00
|
|
|
const KICAD_T SCH_COLLECTOR::OrientableItems[] = {
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
SCH_BITMAP_T,
|
2015-04-26 16:32:16 +00:00
|
|
|
SCH_SHEET_T,
|
2011-10-28 20:30:50 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-02-11 18:29:22 +00:00
|
|
|
const KICAD_T SCH_COLLECTOR::CopyableItems[] = {
|
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIERARCHICAL_LABEL_T,
|
|
|
|
SCH_COMPONENT_T,
|
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
if( aItem->Type() != LIB_PIN_T && !aItem->HitTest( m_RefPos ) )
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
|
|
|
|
// Pins have special hit testing requirements that are relative to their parent
|
|
|
|
// SCH_COMPONENT item.
|
|
|
|
if( aItem->Type() == LIB_PIN_T )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( aTestData && ( (EDA_ITEM*) aTestData )->Type() == SCH_COMPONENT_T,
|
|
|
|
SEARCH_CONTINUE, wxT( "Cannot inspect invalid data. Bad programmer!" ) );
|
|
|
|
|
|
|
|
// Pin hit testing is relative to the components position and orientation in the
|
|
|
|
// schematic. The hit test position must be converted to library coordinates.
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) aTestData;
|
|
|
|
TRANSFORM transform = component->GetTransform().InverseTransform();
|
2011-10-19 20:32:21 +00:00
|
|
|
wxPoint position = transform.TransformCoordinate( m_RefPos - component->GetPosition() );
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
position.y *= -1; // Y axis polarity in schematic is inverted from library.
|
|
|
|
|
|
|
|
if( !aItem->HitTest( position ) )
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Append( aItem );
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[],
|
|
|
|
const wxPoint& aPosition )
|
|
|
|
{
|
|
|
|
Empty(); // empty the collection just in case
|
|
|
|
|
|
|
|
SetScanTypes( aFilterList );
|
|
|
|
|
|
|
|
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
|
|
|
SetRefPos( aPosition );
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
|
2011-07-12 06:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COLLECTOR::IsCorner() const
|
|
|
|
{
|
|
|
|
if( GetCount() != 2 )
|
|
|
|
return false;
|
|
|
|
|
2015-11-03 19:44:05 +00:00
|
|
|
bool is_busentry0 = (dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[0] ) != NULL);
|
|
|
|
bool is_busentry1 = (dynamic_cast<SCH_BUS_ENTRY_BASE*>( m_List[1] ) != NULL);
|
2013-04-01 10:35:20 +00:00
|
|
|
|
2011-07-12 06:57:11 +00:00
|
|
|
if( (m_List[0]->Type() == SCH_LINE_T) && (m_List[1]->Type() == SCH_LINE_T) )
|
2017-11-27 22:44:41 +00:00
|
|
|
return ( ( SCH_LINE* ) m_List[0])->GetLayer() == ( ( SCH_LINE* ) m_List[1])->GetLayer();
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
if( (m_List[0]->Type() == SCH_LINE_T) && is_busentry1 )
|
2011-07-12 06:57:11 +00:00
|
|
|
return true;
|
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
if( is_busentry0 && (m_List[1]->Type() == SCH_LINE_T) )
|
2011-07-12 06:57:11 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COLLECTOR::IsNode( bool aIncludePins ) const
|
|
|
|
{
|
|
|
|
for( size_t i = 0; i < m_List.size(); i++ )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = (SCH_ITEM*) m_List[ i ];
|
|
|
|
KICAD_T type = item->Type();
|
|
|
|
|
|
|
|
if( type == SCH_JUNCTION_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( type == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
if( item->GetLayer() != LAYER_WIRE )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( type == LIB_PIN_T )
|
|
|
|
{
|
|
|
|
if( !aIncludePins )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Any other item types indicate that this collection is not a node.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COLLECTOR::IsDraggableJunction() const
|
|
|
|
{
|
|
|
|
int wireEndCount = 0;
|
|
|
|
int wireMidPoint = 0;
|
|
|
|
int junctionCount = 0;
|
|
|
|
|
|
|
|
for( size_t i = 0; i < m_List.size(); i++ )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = (SCH_ITEM*) m_List[ i ];
|
|
|
|
KICAD_T type = item->Type();
|
|
|
|
|
|
|
|
if( type == SCH_JUNCTION_T )
|
|
|
|
{
|
|
|
|
junctionCount++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( type == SCH_LINE_T )
|
|
|
|
{
|
|
|
|
if( item->GetLayer() != LAYER_WIRE )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SCH_LINE* line = (SCH_LINE*) item;
|
|
|
|
|
|
|
|
if( line->IsEndPoint( m_RefPos ) )
|
|
|
|
wireEndCount++;
|
|
|
|
else
|
|
|
|
wireMidPoint++;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Any other item types indicate that this collection is not a draggable junction.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (wireEndCount >= 3) || ((wireEndCount >= 1) && (wireMidPoint == 1))
|
|
|
|
|| ((wireMidPoint >= 2) && (junctionCount == 1));
|
|
|
|
}
|
2011-12-01 16:49:28 +00:00
|
|
|
|
|
|
|
|
2013-07-20 17:13:40 +00:00
|
|
|
bool SCH_FIND_COLLECTOR::PassedEnd() const
|
2011-12-13 15:37:33 +00:00
|
|
|
{
|
|
|
|
bool retv = false;
|
|
|
|
|
|
|
|
wxUint32 flags = m_findReplaceData.GetFlags();
|
|
|
|
|
|
|
|
if( GetCount() == 0 )
|
|
|
|
return true;
|
|
|
|
|
2013-10-27 18:21:53 +00:00
|
|
|
if( !(flags & FR_SEARCH_WRAP) || (flags & FR_SEARCH_REPLACE) )
|
2011-12-13 15:37:33 +00:00
|
|
|
{
|
|
|
|
if( flags & wxFR_DOWN )
|
|
|
|
{
|
2013-07-20 17:13:40 +00:00
|
|
|
if( m_foundIndex >= GetCount() )
|
2011-12-13 15:37:33 +00:00
|
|
|
retv = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-20 17:13:40 +00:00
|
|
|
if( m_foundIndex < 0 )
|
2011-12-13 15:37:33 +00:00
|
|
|
retv = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
void SCH_FIND_COLLECTOR::dump()
|
|
|
|
{
|
|
|
|
int tmp = m_foundIndex;
|
|
|
|
|
|
|
|
wxLogTrace( traceFindReplace, wxT( "%d items found to replace %s with %s." ),
|
|
|
|
GetCount(), GetChars( m_findReplaceData.GetFindString() ),
|
|
|
|
GetChars( m_findReplaceData.GetReplaceString() ) );
|
|
|
|
|
|
|
|
for( m_foundIndex = 0; m_foundIndex < GetCount(); m_foundIndex++ )
|
|
|
|
wxLogTrace( traceFindReplace, wxT( " " ) + GetText() );
|
|
|
|
|
|
|
|
m_foundIndex = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_FIND_COLLECTOR::UpdateIndex()
|
|
|
|
{
|
|
|
|
wxUint32 flags = m_findReplaceData.GetFlags();
|
|
|
|
|
|
|
|
if( flags & wxFR_DOWN )
|
|
|
|
{
|
2013-07-20 17:13:40 +00:00
|
|
|
if( m_foundIndex < GetCount() )
|
|
|
|
m_foundIndex += 1;
|
2011-12-13 15:37:33 +00:00
|
|
|
if( (m_foundIndex >= GetCount()) && (flags & FR_SEARCH_WRAP) )
|
|
|
|
m_foundIndex = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-20 17:13:40 +00:00
|
|
|
if( m_foundIndex >= 0 )
|
|
|
|
m_foundIndex -= 1;
|
2011-12-13 15:37:33 +00:00
|
|
|
if( (m_foundIndex < 0) && (flags & FR_SEARCH_WRAP) )
|
|
|
|
m_foundIndex = GetCount() - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
SCH_FIND_COLLECTOR_DATA SCH_FIND_COLLECTOR::GetFindData( int aIndex )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( (unsigned) aIndex < m_data.size(), SCH_FIND_COLLECTOR_DATA(),
|
|
|
|
wxT( "Attempt to get find data outside of list boundary." ) );
|
|
|
|
|
|
|
|
return m_data[ aIndex ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
wxString SCH_FIND_COLLECTOR::GetText()
|
2011-12-01 16:49:28 +00:00
|
|
|
{
|
2011-12-13 15:37:33 +00:00
|
|
|
wxCHECK_MSG( (GetCount() != 0) && IsValidIndex( m_foundIndex ), wxEmptyString,
|
2011-12-01 16:49:28 +00:00
|
|
|
wxT( "Cannot get found item at invalid index." ) );
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
SCH_FIND_COLLECTOR_DATA data = m_data[ m_foundIndex ];
|
|
|
|
EDA_ITEM* foundItem = m_List[ m_foundIndex ];
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2011-12-22 08:07:50 +00:00
|
|
|
wxCHECK_MSG( foundItem != NULL, wxEmptyString, wxT( "Invalid found item pointer." ) );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( data.GetParent() )
|
|
|
|
{
|
2011-12-22 08:07:50 +00:00
|
|
|
msg.Printf( _( "Child item %s of parent item %s found in sheet %s" ),
|
|
|
|
GetChars( foundItem->GetSelectMenuText() ),
|
|
|
|
GetChars( data.GetParent()->GetSelectMenuText() ),
|
|
|
|
GetChars( data.GetSheetPath() ) );
|
2011-12-01 16:49:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-22 08:07:50 +00:00
|
|
|
msg.Printf( _( "Item %s found in sheet %s" ),
|
|
|
|
GetChars( foundItem->GetSelectMenuText() ),
|
|
|
|
GetChars( data.GetSheetPath() ) );
|
2011-12-01 16:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
EDA_ITEM* SCH_FIND_COLLECTOR::GetItem( SCH_FIND_COLLECTOR_DATA& aData )
|
|
|
|
{
|
2013-07-20 17:13:40 +00:00
|
|
|
if( PassedEnd() )
|
2011-12-13 15:37:33 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
aData = m_data[ m_foundIndex ];
|
|
|
|
return m_List[ m_foundIndex ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-27 18:21:53 +00:00
|
|
|
bool SCH_FIND_COLLECTOR::ReplaceItem( SCH_SHEET_PATH* aSheetPath )
|
2011-12-13 15:37:33 +00:00
|
|
|
{
|
2013-07-20 17:13:40 +00:00
|
|
|
if( PassedEnd() )
|
2011-12-13 15:37:33 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
wxCHECK_MSG( IsValidIndex( m_foundIndex ), false,
|
|
|
|
wxT( "Invalid replace list index in SCH_FIND_COLLECTOR." ) );
|
|
|
|
|
|
|
|
EDA_ITEM* item = m_List[ m_foundIndex ];
|
|
|
|
|
2013-10-27 18:21:53 +00:00
|
|
|
bool replaced = item->Replace( m_findReplaceData, aSheetPath );
|
2011-12-13 15:37:33 +00:00
|
|
|
|
|
|
|
if( replaced )
|
2015-04-09 19:37:48 +00:00
|
|
|
SetForceSearch();
|
2011-12-13 15:37:33 +00:00
|
|
|
|
|
|
|
return replaced;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
2011-12-01 16:49:28 +00:00
|
|
|
{
|
|
|
|
wxPoint position;
|
|
|
|
|
|
|
|
if( aItem->Matches( m_findReplaceData, m_sheetPath, &position ) )
|
|
|
|
{
|
|
|
|
if( aItem->Type() == LIB_PIN_T )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( aTestData && ( (EDA_ITEM*) aTestData )->Type() == SCH_COMPONENT_T,
|
|
|
|
SEARCH_CONTINUE, wxT( "Cannot inspect invalid data. Bad programmer!" ) );
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
// Pin positions are relative to their parent component's position and
|
|
|
|
// orientation in the schematic. The pin's position must be converted
|
|
|
|
// schematic coordinates.
|
2011-12-01 16:49:28 +00:00
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) aTestData;
|
|
|
|
TRANSFORM transform = component->GetTransform();
|
|
|
|
position.y = -position.y;
|
|
|
|
position = transform.TransformCoordinate( position ) + component->GetPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
Append( aItem );
|
|
|
|
m_data.push_back( SCH_FIND_COLLECTOR_DATA( position, m_sheetPath->PathHumanReadable(),
|
|
|
|
(SCH_ITEM*) aTestData ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-18 15:38:46 +00:00
|
|
|
void SCH_FIND_COLLECTOR::SetReplaceString( const wxString &aReplaceString )
|
|
|
|
{
|
|
|
|
m_findReplaceData.SetReplaceString( aReplaceString );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
|
|
|
|
SCH_SHEET_PATH* aSheetPath )
|
|
|
|
{
|
2013-07-14 18:08:20 +00:00
|
|
|
if( !IsSearchRequired( aFindReplaceData ) && !m_List.empty() && !m_forceSearch )
|
2011-12-01 16:49:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_findReplaceData = aFindReplaceData;
|
|
|
|
Empty(); // empty the collection just in case
|
|
|
|
m_data.clear();
|
2011-12-13 15:37:33 +00:00
|
|
|
m_foundIndex = 0;
|
2015-04-09 19:37:48 +00:00
|
|
|
SetForceSearch( false );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
|
|
|
if( aSheetPath )
|
|
|
|
{
|
|
|
|
m_sheetPath = aSheetPath;
|
2016-07-12 19:05:54 +00:00
|
|
|
EDA_ITEM::IterateForward( aSheetPath->LastDrawList(), m_inspector, NULL, m_ScanTypes );
|
2011-12-01 16:49:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET_LIST schematic( g_RootSheet );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < schematic.size(); i++ )
|
2011-12-01 16:49:28 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
m_sheetPath = &schematic[i];
|
2016-07-12 19:05:54 +00:00
|
|
|
EDA_ITEM::IterateForward( m_sheetPath->LastDrawList(), m_inspector, NULL, m_ScanTypes );
|
2011-12-01 16:49:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
dump();
|
|
|
|
#endif
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
if( m_List.size() != m_data.size() )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxT( "List size mismatch." ) );
|
|
|
|
m_List.clear();
|
|
|
|
m_data.clear();
|
|
|
|
}
|
|
|
|
}
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT SCH_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
// The Vist() function only visits the testItem if its type was in the
|
|
|
|
// the scanList, so therefore we can collect anything given to us here.
|
|
|
|
Append( aItem );
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TYPE_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[] )
|
|
|
|
{
|
|
|
|
Empty(); // empty the collection
|
|
|
|
|
|
|
|
SetScanTypes( aFilterList );
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|