Commit a0fbe422 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: Rework on netlist generator: code cleaning and enhancement.

Mainly, fix an annoying issue about not named nets:
now, these nets are named from the component references and pin names which are connected.
therefore, unless the net or the footprint references are modified, the net name is not modified between 2 netlist calculations.

Netlist generation code still needs some code enhancement (mainly removing the global g_NetObjectslist variable).
parents f72394cc daeeee56
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -32,8 +32,8 @@
#include <macros.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <sch_component.h>
#include <class_netlist_object.h>
#include <wx/regex.h>
......@@ -175,7 +175,7 @@ NETLIST_OBJECT::NETLIST_OBJECT()
m_Flag = 0; /* flag used in calculations */
m_ElectricalType = 0; /* Has meaning only for Pins and hierarchical pins: electrical
* type */
m_NetCode = 0; /* net code for all items except BUS labels because a BUS
m_netCode = 0; /* net code for all items except BUS labels because a BUS
* label has as many net codes as bus members
*/
m_BusNetCode = 0; /* Used for BUS connections */
......@@ -184,7 +184,7 @@ NETLIST_OBJECT::NETLIST_OBJECT()
*/
m_FlagOfConnection = UNCONNECTED;
m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
m_NetNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
* object used to give a name to the net
*/
}
......@@ -201,6 +201,15 @@ NETLIST_OBJECT::~NETLIST_OBJECT()
{
}
// return true if the object is a label of any type
bool NETLIST_OBJECT::IsLabelType() const
{
return m_Type == NET_LABEL
|| m_Type == NET_GLOBLABEL || m_Type == NET_HIERLABEL
|| m_Type == NET_BUSLABELMEMBER || m_Type == NET_GLOBBUSLABELMEMBER
|| m_Type == NET_HIERBUSLABELMEMBER
|| m_Type == NET_PINLABEL;
}
bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
{
......@@ -299,3 +308,80 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem
aNetListItems.push_back( item );
}
}
/*
* return the net name of the item
*/
wxString NETLIST_OBJECT::GetNetName() const
{
if( m_netNameCandidate == NULL )
return wxEmptyString;
wxString netName;
if( m_netNameCandidate->m_Type == NET_PIN )
return GetShortNetName();
if( !m_netNameCandidate->IsLabelGlobal() )
{
// usual net name, prefix it by the sheet path
netName = m_netNameCandidate->m_SheetList.PathHumanReadable();
}
netName += m_netNameCandidate->m_Label;
return netName;
}
/**
* return the short net name of the item i.e. the net name
* from the "best" label without any prefix.
* 2 different nets can have the same short name
*/
wxString NETLIST_OBJECT::GetShortNetName() const
{
if( m_netNameCandidate == NULL )
return wxEmptyString;
wxString netName;
if( m_netNameCandidate->m_Type == NET_PIN )
{
if( m_Link )
{
netName = wxT("Net-<");
netName << ( (SCH_COMPONENT*) m_Link )->GetRef( &m_SheetList );
netName << wxT("-Pad") << LIB_PIN::ReturnPinStringNum( m_PinNum );
netName << wxT(">");
}
}
else
netName = m_netNameCandidate->m_Label;
return netName;
}
/**
* Set m_netNameCandidate to a connected item which will
* be used to calcule the net name of the item
* Obviously the candidate can be only a label
* when there is no label on the net a pad which will
* used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>
* @param aCandidate = the connected item candidate
*/
void NETLIST_OBJECT::SetNetNameCandidate( NETLIST_OBJECT* aCandidate )
{
switch( aCandidate->m_Type )
{
case NET_HIERLABEL:
case NET_LABEL:
case NET_PINLABEL:
case NET_GLOBLABEL:
case NET_PIN:
m_netNameCandidate = aCandidate;
break;
default:
break;
}
}
This diff is collapsed.
......@@ -37,8 +37,8 @@
#include <wxEeschemaStruct.h>
#include <invoke_sch_dialog.h>
#include <general.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <sch_marker.h>
#include <sch_sheet.h>
#include <lib_pin.h>
......
......@@ -33,8 +33,8 @@
#include <kicad_string.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <lib_pin.h>
#include <protos.h>
#include <erc.h>
......
......@@ -35,12 +35,11 @@
#include <wxEeschemaStruct.h>
#include <appl_wxstruct.h>
#include <general.h>
#include <protos.h>
#include <eeschema_id.h>
#include <class_library.h>
#include <libeditframe.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <wildcards_and_files_ext.h>
......
......@@ -5,26 +5,20 @@
#ifndef _GENERAL_H_
#define _GENERAL_H_
#include <wx/string.h>
#include <wx/gdicmn.h>
#include <colors.h> // for EDA_COLOR_T
#include <block_commande.h>
#include <class_netlist_object.h>
class SCH_SHEET;
class TRANSFORM;
class SCH_SHEET;
#define EESCHEMA_VERSION 2
#define SCHEMATIC_HEAD_STRING "Schematic File Version"
#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers
#define DEFAULT_TEXT_SIZE 50 // Default size for field texts
#define DANGLING_SYMBOL_SIZE 12
#define GR_DEFAULT_DRAWMODE GR_COPY
#define DANGLING_SYMBOL_SIZE 12
// this enum is for color management
typedef enum {
LAYER_WIRE,
......@@ -75,8 +69,6 @@ extern int g_RepeatDeltaLabel;
/* First and main (root) screen */
extern SCH_SHEET* g_RootSheet;
extern NETLIST_OBJECT_LIST g_NetObjectslist;
/**
* Default line thickness used to draw/plot items having a
* default thickness line value (i.e. = 0 ).
......
......@@ -32,6 +32,7 @@
#include <base_struct.h>
#include <transform.h>
#include <gr_basic.h>
#include <boost/ptr_container/ptr_vector.hpp>
......
......@@ -43,6 +43,7 @@
#include <libeditframe.h>
#include <class_library.h>
#include <lib_polyline.h>
#include <lib_pin.h>
#include <kicad_device_context.h>
#include <hotkeys.h>
......
......@@ -35,8 +35,8 @@
#include <appl_wxstruct.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <class_library.h>
#include <lib_pin.h>
#include <sch_component.h>
......@@ -121,7 +121,8 @@ class NETLIST_EXPORT_TOOL
* <li> "/path/netname" for the usual nets
* </ul>
*/
static void sprintPinNetName( wxString* aResult, const wxString& aNetNameFormat, NETLIST_OBJECT* aPin );
static void sprintPinNetName( wxString& aResult, const wxString& aNetNameFormat,
NETLIST_OBJECT* aPin );
/**
* Function findNextComponentAndCreatePinList
......@@ -462,7 +463,7 @@ static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 )
}
void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString* aResult,
void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString& aResult,
const wxString& aNetNameFormat, NETLIST_OBJECT* aPin )
{
int netcode = aPin->GetNet();
......@@ -470,34 +471,14 @@ void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString* aResult,
// Not wxString::Clear(), which would free memory. We want the worst
// case wxString memory to grow to avoid reallocation from within the
// caller's loop.
aResult->Empty();
aResult.Empty();
if( netcode != 0 && aPin->m_FlagOfConnection == PAD_CONNECT )
{
NETLIST_OBJECT* netref = aPin->m_NetNameCandidate;
if( netref )
*aResult = netref->m_Label;
aResult = aPin->GetNetName();
if( !aResult->IsEmpty() )
{
// prefix non global label names with the sheet path, to avoid name collisions
if( netref->m_Type != NET_PINLABEL && netref->m_Type != NET_GLOBLABEL )
{
wxString lnet = *aResult;
*aResult = netref->m_SheetList.PathHumanReadable();
// If sheet path is too long, use the time stamp name instead
if( aResult->Length() > 32 )
*aResult = netref->m_SheetList.Path();
*aResult += lnet;
}
}
else
{
aResult->Printf( aNetNameFormat.GetData(), netcode );
}
if( aResult.IsEmpty() ) // No net name: give a name from net code
aResult.Printf( aNetNameFormat.GetData(), netcode );
}
}
......@@ -880,22 +861,7 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericListOfNets()
if( ( netCode = nitem->GetNet() ) != lastNetCode )
{
sameNetcodeCount = 0; // item count for this net
netName.Empty();
// Find a label for this net, if it exists.
NETLIST_OBJECT* netref = nitem->m_NetNameCandidate;
if( netref )
{
if( netref->m_Type != NET_PINLABEL && netref->m_Type != NET_GLOBLABEL )
{
// usual net name, prefix it by the sheet path
netName = netref->m_SheetList.PathHumanReadable();
}
netName += netref->m_Label;
}
netName = nitem->GetNetName();
lastNetCode = netCode;
}
......@@ -1316,7 +1282,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool aUsePrefix )
if( !pin )
continue;
sprintPinNetName( &netName , wxT( "N-%.6d" ), pin );
sprintPinNetName( netName , wxT( "N-%.6d" ), pin );
if( netName.IsEmpty() )
netName = wxT( "?" );
......@@ -1470,7 +1436,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
if( !pin )
continue;
sprintPinNetName( &netName, wxT( "N-%.6d" ), pin );
sprintPinNetName( netName, wxT( "N-%.6d" ), pin );
if( netName.IsEmpty() )
netName = wxT( "?" );
......@@ -1682,49 +1648,33 @@ bool NETLIST_EXPORT_TOOL::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST&
for( unsigned ii = 0; ii < aObjectsList.size(); ii++ )
{
SCH_COMPONENT* comp;
NETLIST_OBJECT* nitem = aObjectsList[ii];
// New net found, write net id;
if( ( netCode = aObjectsList[ii]->GetNet() ) != lastNetCode )
if( ( netCode = nitem->GetNet() ) != lastNetCode )
{
sameNetcodeCount = 0; // Items count for this net
netName.Empty();
// Find a label (if exists) for this net.
NETLIST_OBJECT* netref;
netref = aObjectsList[ii]->m_NetNameCandidate;
if( netref )
netName = netref->m_Label;
netName = nitem->GetNetName();
netcodeName.Printf( wxT( "Net %d " ), netCode );
netcodeName += wxT( "\"" );
if( !netName.IsEmpty() )
{
if( ( netref->m_Type != NET_PINLABEL )
&& ( netref->m_Type != NET_GLOBLABEL ) )
{
// usual net name, prefix it by the sheet path
netcodeName += netref->m_SheetList.PathHumanReadable();
}
netcodeName += netName;
}
netcodeName += wxT( "\"" );
netcodeName << wxT( "\"" ) << netName << wxT( "\"" );
// Add the netname without prefix, in cases we need only the
// "short" netname
netcodeName += wxT( " \"" ) + netName + wxT( "\"" );
netcodeName += wxT( " \"" ) + nitem->GetShortNetName() + wxT( "\"" );
lastNetCode = netCode;
}
if( aObjectsList[ii]->m_Type != NET_PIN )
if( nitem->m_Type != NET_PIN )
continue;
if( aObjectsList[ii]->m_Flag != 0 ) // Redundant pin, skip it
if( nitem->m_Flag != 0 ) // Redundant pin, skip it
continue;
comp = (SCH_COMPONENT*) aObjectsList[ii]->m_Link;
comp = (SCH_COMPONENT*) nitem->m_Link;
// Get the reference for the net name and the main parent component
ref = comp->GetRef( &aObjectsList[ii]->m_SheetList );
ref = comp->GetRef( &nitem->m_SheetList );
if( ref[0] == wxChar( '#' ) )
continue; // Pseudo component (Like Power symbol)
......@@ -1750,7 +1700,7 @@ bool NETLIST_EXPORT_TOOL::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST&
if( sameNetcodeCount >= 2 )
ret |= fprintf( f, " %s %.4s\n", TO_UTF8( ref ),
(const char*) &aObjectsList[ii]->m_PinNum );
(const char*) &nitem->m_PinNum );
}
return ret >= 0;
......@@ -1841,48 +1791,37 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
int print_ter = 0;
int NetCode, lastNetCode = -1;
SCH_COMPONENT* Cmp;
wxString NetName;
wxString netName;
for( ii = 0; ii < g_NetObjectslist.size(); ii++ )
{
NETLIST_OBJECT* nitem = aObjectsList[ii];
// Get the NetName of the current net :
if( ( NetCode = aObjectsList[ii]->GetNet() ) != lastNetCode )
if( ( NetCode = nitem->GetNet() ) != lastNetCode )
{
NetName.Empty();
NETLIST_OBJECT* netref;
netref = aObjectsList[ii]->m_NetNameCandidate;
if( netref )
NetName = netref->m_Label;
netName = nitem->GetNetName();
netcodeName = wxT( "\"" );
if( !NetName.IsEmpty() )
{
if( ( netref->m_Type != NET_PINLABEL )
&& ( netref->m_Type != NET_GLOBLABEL ) )
{
// usual net name, prefix it by the sheet path
netcodeName +=
netref->m_SheetList.PathHumanReadable();
}
netcodeName += NetName;
}
if( !netName.IsEmpty() )
netcodeName << netName;
else // this net has no name: create a default name $<net number>
netcodeName << wxT( "$" ) << NetCode;
netcodeName += wxT( "\"" );
lastNetCode = NetCode;
print_ter = 0;
}
if( aObjectsList[ii]->m_Type != NET_PIN )
if( nitem->m_Type != NET_PIN )
continue;
if( aObjectsList[ii]->m_Flag != 0 )
if( nitem->m_Flag != 0 )
continue;
Cmp = (SCH_COMPONENT*) aObjectsList[ii]->m_Link;
wxString refstr = Cmp->GetRef( &(aObjectsList[ii]->m_SheetList) );
Cmp = (SCH_COMPONENT*) nitem->m_Link;
wxString refstr = Cmp->GetRef( &nitem->m_SheetList );
if( refstr[0] == '#' )
continue; // Power supply symbols.
......@@ -1892,7 +1831,7 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
{
char buf[5];
wxString str_pinnum;
strncpy( buf, (char*) &aObjectsList[ii]->m_PinNum, 4 );
strncpy( buf, (char*) &nitem->m_PinNum, 4 );
buf[4] = 0;
str_pinnum = FROM_UTF8( buf );
InitNetDescLine.Printf( wxT( "\n%s %s %.4s %s" ),
......@@ -1909,18 +1848,18 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
ret |= fprintf( f, "%s %s %.4s\n",
TO_UTF8( StartNetDesc ),
TO_UTF8( refstr ),
(char*) &aObjectsList[ii]->m_PinNum );
(char*) &nitem->m_PinNum );
print_ter++;
break;
default:
ret |= fprintf( f, " %s %.4s\n",
TO_UTF8( refstr ),
(char*) &aObjectsList[ii]->m_PinNum );
(char*) &nitem->m_PinNum );
break;
}
aObjectsList[ii]->m_Flag = 1;
nitem->m_Flag = 1;
}
return ret >= 0;
......
This diff is collapsed.
......@@ -37,6 +37,7 @@
#include <class_libentry.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <sch_text.h>
/// netlist types
......@@ -483,7 +484,7 @@ private:
/**
* Class BOM_LABEL
* is used to build a BOM by handling the list of labels in schematic because in a
* is used to build a List of Labels by handling the list of labels in schematic because in a
* complex hierarchy, a label is used more than once and has more than one sheet path
* so we must create a flat list of labels.
*/
......@@ -512,7 +513,11 @@ public:
const SCH_SHEET_PATH& GetSheetPath() const { return m_sheetPath; }
wxString GetText() const;
wxString GetText() const
{
const SCH_TEXT* tmp = (SCH_TEXT*) m_label;
return tmp->GetText();
}
};
......
......@@ -34,7 +34,6 @@
#include <wxEeschemaStruct.h>
#include <menus_helpers.h>
#include <general.h>
#include <sch_bus_entry.h>
#include <sch_text.h>
#include <sch_marker.h>
......@@ -43,6 +42,7 @@
#include <sch_no_connect.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_bitmap.h>
......
......@@ -28,7 +28,7 @@
#include <macros.h>
#include <general.h>
#include <sch_sheet_path.h>
#include <transform.h>
#include <sch_collectors.h>
#include <sch_component.h>
......
......@@ -1720,8 +1720,8 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
}
void SCH_COMPONENT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( GetLibName() );
......
......@@ -40,7 +40,7 @@ class SCH_SHEET_PATH;
class LIB_ITEM;
class LIB_PIN;
class LIB_COMPONENT;
class NETLIST_OBJECT_LIST;
/// A container for several SCH_FIELD items
typedef std::vector<SCH_FIELD> SCH_FIELDS;
......@@ -384,8 +384,8 @@ public:
BITMAP_DEF GetMenuImage() const { return add_component_xpm; }
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
bool operator <( const SCH_ITEM& aItem ) const;
......
......@@ -36,6 +36,7 @@
#include <plot_common.h>
#include <sch_junction.h>
#include <class_netlist_object.h>
int SCH_JUNCTION::m_symbolSize = 40; // Default diameter of the junction symbol
......@@ -173,7 +174,7 @@ void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
void SCH_JUNCTION::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
void SCH_JUNCTION::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
NETLIST_OBJECT* item = new NETLIST_OBJECT();
......
......@@ -31,6 +31,7 @@
#include <sch_item_struct.h>
class NETLIST_OBJECT_LIST;
class SCH_JUNCTION : public SCH_ITEM
{
......@@ -86,7 +87,7 @@ public:
BITMAP_DEF GetMenuImage() const { return add_junction_xpm; }
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
wxPoint GetPosition() const { return m_pos; }
......
......@@ -516,8 +516,8 @@ BITMAP_DEF SCH_LINE::GetMenuImage() const
}
void SCH_LINE::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
void SCH_LINE::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
// Net list item not required for graphic lines.
if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
......
......@@ -32,6 +32,7 @@
#include <sch_item_struct.h>
class NETLIST_OBJECT_LIST;
/**
* Class SCH_LINE
......@@ -128,7 +129,7 @@ public:
BITMAP_DEF GetMenuImage() const;
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
bool operator <( const SCH_ITEM& aItem ) const;
......
......@@ -188,8 +188,8 @@ void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
void SCH_NO_CONNECT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
NETLIST_OBJECT* item = new NETLIST_OBJECT();
......
......@@ -32,6 +32,7 @@
#include <sch_item_struct.h>
class NETLIST_OBJECT_LIST;
class SCH_NO_CONNECT : public SCH_ITEM
{
......@@ -86,7 +87,7 @@ public:
BITMAP_DEF GetMenuImage() const { return noconn_xpm; }
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
wxPoint GetPosition() const { return m_pos; }
......
......@@ -40,9 +40,8 @@
#include <wxEeschemaStruct.h>
#include <plot_common.h>
#include <general.h>
#include <protos.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <class_library.h>
#include <sch_junction.h>
#include <sch_bus_entry.h>
......@@ -52,6 +51,7 @@
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_text.h>
#include <lib_pin.h>
#include <boost/foreach.hpp>
......
......@@ -37,7 +37,6 @@
#include <kicad_string.h>
#include <msgpanel.h>
#include <general.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
......@@ -1073,8 +1072,8 @@ wxPoint SCH_SHEET::GetResizePosition() const
}
void SCH_SHEET::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
SCH_SHEET_PATH sheetPath = *aSheetPath;
sheetPath.Push( this );
......
......@@ -42,6 +42,7 @@ class SCH_SHEET_PIN;
class SCH_SHEET_PATH;
class DANGLING_END_ITEM;
class SCH_EDIT_FRAME;
class NETLIST_OBJECT_LIST;
#define MIN_SHEET_WIDTH 500
......@@ -541,8 +542,8 @@ public:
BITMAP_DEF GetMenuImage() const { return add_hierarchical_subsheet_xpm; }
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
......
......@@ -613,8 +613,8 @@ wxString SCH_TEXT::GetSelectMenuText() const
}
void SCH_TEXT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
return;
......
......@@ -37,6 +37,7 @@
class LINE_READER;
class NETLIST_OBJECT_LIST;
/* Type of SCH_HIERLABEL and SCH_GLOBALLABEL
......@@ -196,8 +197,8 @@ public:
virtual BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
virtual void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
virtual wxPoint GetPosition() const { return m_Pos; }
......
......@@ -47,6 +47,7 @@
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
......
......@@ -44,6 +44,7 @@ class SCH_EDIT_FRAME;
class wxFindReplaceData;
class PLOTTER;
class NETLIST_OBJECT;
class NETLIST_OBJECT_LIST;
typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS;
......@@ -342,8 +343,8 @@ public:
* net list objects associated with them.
* </p>
*/
virtual void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath ) { }
virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath ) { }
/**
* Function GetPosition
......
......@@ -643,9 +643,12 @@ public:
* @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer)
* @param aNotAllowedLayersMask = a layer mask for not allowed layers
* (= 0 to show all layers in use)
* @param aDlgPosition = position of dialog ( defualt = centered)
* @return the selected layer id
*/
LAYER_NUM SelectLayer( LAYER_NUM aDefaultLayer, LAYER_MSK aNotAllowedLayersMask = 0 );
LAYER_NUM SelectLayer( LAYER_NUM aDefaultLayer,
LAYER_MSK aNotAllowedLayersMask = 0,
wxPoint aDlgPosition = wxDefaultPosition );
/* Display a list of two copper layers to choose a pair of copper layers
* the layer pair is used to fast switch between copper layers when placing vias
......
......@@ -283,7 +283,7 @@ void DIALOG_COPPER_ZONE::initDialog()
ctrlWidth += 4; // add small margin between text and window borders
m_LayerSelectionCtrl->SetMinSize( wxSize(ctrlWidth, -1));
wxString netNameDoNotShowFilter = wxT( "N-*" );
wxString netNameDoNotShowFilter = wxT( "Net-*" );
if( m_Config )
{
int opt = m_Config->Read( ZONE_NET_SORT_OPTION_KEY, 1l );
......
......@@ -60,18 +60,12 @@
void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
LAYER_NUM itmp;
INSTALL_UNBUFFERED_DC( dc, m_canvas );
MODULE* module;
m_canvas->CrossHairOff( &dc );
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 20;
switch( id ) // Some (not all ) edit commands must be finished or aborted
{
case wxID_CUT:
......@@ -246,7 +240,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_PCB_GLOBAL_DELETE:
InstallPcbGlobalDeleteFrame( pos );
InstallPcbGlobalDeleteFrame( wxDefaultPosition );
break;
case ID_POPUP_PLACE_BLOCK:
......@@ -409,7 +403,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
id == ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA )
{
m_canvas->SetIgnoreMouseEvents( true );
LAYER_NUM layer = SelectLayer( getActiveLayer(), ALL_NO_CU_LAYERS );
wxPoint dlgPosition;
wxGetMousePosition( &dlgPosition.x, &dlgPosition.y );
LAYER_NUM layer = SelectLayer( getActiveLayer(), ALL_NO_CU_LAYERS,
dlgPosition );
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
......
......@@ -87,16 +87,7 @@ class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR,
public:
PCB_ONE_LAYER_SELECTOR( wxWindow* aParent, BOARD * aBrd,
LAYER_NUM aDefaultLayer,
LAYER_MSK aNotAllowedLayersMask )
:PCB_LAYER_SELECTOR( aBrd ), DIALOG_LAYER_SELECTION_BASE( aParent )
{
m_layerSelected = (int) aDefaultLayer;
m_notAllowedLayersMask = aNotAllowedLayersMask;
BuildList();
Layout();
GetSizer()->SetSizeHints(this);
SetFocus();
}
LAYER_MSK aNotAllowedLayersMask );
LAYER_NUM GetLayerSelection() { return m_layerSelected; }
......@@ -108,6 +99,20 @@ private:
void BuildList();
};
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( wxWindow* aParent,
BOARD * aBrd,
LAYER_NUM aDefaultLayer,
LAYER_MSK aNotAllowedLayersMask )
: PCB_LAYER_SELECTOR( aBrd ), DIALOG_LAYER_SELECTION_BASE( aParent )
{
m_layerSelected = (int) aDefaultLayer;
m_notAllowedLayersMask = aNotAllowedLayersMask;
BuildList();
Layout();
GetSizer()->SetSizeHints(this);
SetFocus();
}
// Build the layers list
// Column position by function:
#define SELECT_COLNUM 0
......@@ -221,10 +226,18 @@ void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event )
* @return the selected layer id
*/
LAYER_NUM PCB_BASE_FRAME::SelectLayer( LAYER_NUM aDefaultLayer,
LAYER_MSK aNotAllowedLayersMask )
LAYER_MSK aNotAllowedLayersMask,
wxPoint aDlgPosition )
{
PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(),
aDefaultLayer, aNotAllowedLayersMask );
if( aDlgPosition != wxDefaultPosition )
{
wxSize dlgSize = dlg.GetSize();
aDlgPosition.x -= dlgSize.x/2;
aDlgPosition.y -= dlgSize.y/2;
dlg.SetPosition( aDlgPosition );
}
dlg.ShowModal();
LAYER_NUM layer = dlg.GetLayerSelection();
return layer;
......
......@@ -14,7 +14,6 @@
#include <class_drawsegment.h>
#include <pcbnew.h>
#include <protos.h>
#include <wx/statline.h>
......@@ -31,7 +30,7 @@ enum swap_layer_id {
};
class WinEDA_SwapLayerFrame : public DIALOG_SHIM
class SWAP_LAYERS_DIALOG : public DIALOG_SHIM
{
private:
PCB_BASE_FRAME* m_Parent;
......@@ -46,8 +45,8 @@ private:
public:
WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent );
~WinEDA_SwapLayerFrame() { };
SWAP_LAYERS_DIALOG( PCB_BASE_FRAME* parent );
~SWAP_LAYERS_DIALOG() { };
private:
void Sel_Layer( wxCommandEvent& event );
......@@ -58,16 +57,16 @@ private:
};
BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog )
BEGIN_EVENT_TABLE( SWAP_LAYERS_DIALOG, wxDialog )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_PCB_LAYERS - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
WinEDA_SwapLayerFrame::Sel_Layer )
EVT_BUTTON( wxID_OK, WinEDA_SwapLayerFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_SwapLayerFrame::OnCancelClick )
SWAP_LAYERS_DIALOG::Sel_Layer )
EVT_BUTTON( wxID_OK, SWAP_LAYERS_DIALOG::OnOkClick )
EVT_BUTTON( wxID_CANCEL, SWAP_LAYERS_DIALOG::OnCancelClick )
END_EVENT_TABLE()
WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) :
SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( PCB_BASE_FRAME* parent ) :
DIALOG_SHIM( parent, -1, _( "Swap Layers:" ), wxPoint( -1, -1 ),
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
{
......@@ -269,10 +268,12 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) :
{
GetSizer()->SetSizeHints( this );
}
Center();
}
void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event )
void SWAP_LAYERS_DIALOG::Sel_Layer( wxCommandEvent& event )
{
int ii;
......@@ -283,21 +284,24 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event )
ii = event.GetId() - ID_BUTTON_0;
LAYER_NUM jj = New_Layer[ii];
LAYER_NUM layer = New_Layer[ii];
if( (jj < 0) || (jj > NB_PCB_LAYERS) )
jj = LAYER_NO_CHANGE; // (Defaults to "No Change".)
if( (layer < 0) || (layer > NB_PCB_LAYERS) )
layer = LAYER_NO_CHANGE; // (Defaults to "No Change".)
jj = m_Parent->SelectLayer( jj );
LAYER_MSK notallowed_mask = ii < NB_COPPER_LAYERS ?
ALL_NO_CU_LAYERS : ALL_CU_LAYERS;
layer = m_Parent->SelectLayer( layer == LAYER_NO_CHANGE ? ii : layer,
notallowed_mask );
if( !IsValidLayer( jj ) )
if( !IsValidLayer( layer ) )
return;
if( jj != New_Layer[ii] )
if( layer != New_Layer[ii] )
{
New_Layer[ii] = jj;
New_Layer[ii] = layer;
if( jj >= LAYER_NO_CHANGE || jj == ii )
if( layer >= LAYER_NO_CHANGE || layer == ii )
{
layer_list[ii]->SetLabel( _( "No Change" ) );
......@@ -307,7 +311,7 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event )
}
else
{
layer_list[ii]->SetLabel( m_Parent->GetBoard()->GetLayerName( jj ) );
layer_list[ii]->SetLabel( m_Parent->GetBoard()->GetLayerName( layer ) );
// Change the text color to fuchsia (to highlight
// that this layer *is* being swapped)
......@@ -317,13 +321,13 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event )
}
void WinEDA_SwapLayerFrame::OnCancelClick( wxCommandEvent& event )
void SWAP_LAYERS_DIALOG::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event )
void SWAP_LAYERS_DIALOG::OnOkClick( wxCommandEvent& event )
{
EndModal( 1 );
}
......@@ -340,10 +344,9 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event )
for( ii = FIRST_LAYER; ii < NB_PCB_LAYERS; ii++ )
New_Layer[ii] = LAYER_NO_CHANGE;
WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( this );
SWAP_LAYERS_DIALOG dlg( this );
ii = frame->ShowModal();
frame->Destroy();
ii = dlg.ShowModal();
if( ii != 1 )
return; // (Canceled dialog box returns -1 instead)
......
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