Commit d4fb921b authored by Wayne Stambaugh's avatar Wayne Stambaugh

Eeschema ERC improvements and other minor fixes.

* Move the hierarchical label connected test into the NETLIST_OBJECT class.
* ERC pin type strings can now be translated.
* Remove unused EDA_DRAW_PANEL attribute from all ERC test functions.
* Add get marker count method to SCH_SCREENS object.
* Redundant header removal.
* Lots of coding style policy fixes.
parent 5602177d
...@@ -13,7 +13,7 @@ endif(WIN32) ...@@ -13,7 +13,7 @@ endif(WIN32)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
# #
# KiCad build options go here. # KiCad build options should be added below.
# #
# If you add a new build option, please add it's state to the CopyVersionInfoToClipboard() # If you add a new build option, please add it's state to the CopyVersionInfoToClipboard()
# function in common/basicframe.cpp so that build option settings can be includeed in bug # function in common/basicframe.cpp so that build option settings can be includeed in bug
......
/**************************************/ /**
/* annotate.cpp: component annotation */ * @file annotate.cpp
/**************************************/ * @brief Component annotation.
*/
#include <algorithm> // to use sort vector #include <algorithm> // to use sort vector
#include <vector> #include <vector>
...@@ -8,8 +9,6 @@ ...@@ -8,8 +9,6 @@
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "wxstruct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "netlist.h" #include "netlist.h"
......
/****************************************************/ /**
/* BLOCK.CPP */ * @file eeschema/block.cpp
/****************************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h" #include "general.h"
#include "class_library.h" #include "class_library.h"
......
/****************************************************/ /**
/* block_libedit.cpp */ * @file block_libedit.cpp
/****************************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "block_commande.h"
#include "general.h" #include "general.h"
#include "class_library.h" #include "class_library.h"
......
/***************************************************************/ /**
/* Code for handling creation of buses, wires, and junctions. */ * @file bus-wire-junction.cpp
/***************************************************************/ * @brief Code for editing buses, wires, and junctions.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "lib_draw_item.h" #include "lib_draw_item.h"
#include "lib_pin.h" #include "lib_pin.h"
......
/*****************************************************/ /**
/* Code to handle manipulation on bus entry objects. */ * @file busentry.cpp
/*****************************************************/ * @brief Code to handle manipulation of bus entry objects.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/**********************************************************/ /**
/* libclass.cpp */ * @file class_library.cpp
/**********************************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -232,18 +232,6 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) ...@@ -232,18 +232,6 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias )
} }
/**
* Add \a aComponent entry to library.
* Note a component can have an alias list,
* so these alias will be added in library.
* Conflicts can happen if aliases are already existing.
* User is asked to choose what alias is removed (existing, or new)
* a special case is the library cache:
* user is not asked, and old aliases removed.
* this is not perfect, but sufficient to create a library cache project
* @param aComponent - Component to add.
* @return Added component if successful.
*/
LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
{ {
if( aComponent == NULL ) if( aComponent == NULL )
...@@ -323,13 +311,6 @@ LIB_ALIAS* CMP_LIBRARY::RemoveEntry( LIB_ALIAS* aEntry ) ...@@ -323,13 +311,6 @@ LIB_ALIAS* CMP_LIBRARY::RemoveEntry( LIB_ALIAS* aEntry )
} }
/**
* Replace an existing component entry in the library.
*
* @param aOldComponent - The component to replace.
* @param aNewComponent - The new component.
* the new component and the old component are expected having the same name.
*/
LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent,
LIB_COMPONENT* aNewComponent ) LIB_COMPONENT* aNewComponent )
{ {
...@@ -569,10 +550,12 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum ) ...@@ -569,10 +550,12 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum )
{ {
text = strtok( Line, " \t\r\n" ); text = strtok( Line, " \t\r\n" );
data = strtok( NULL, " \t\r\n" ); data = strtok( NULL, " \t\r\n" );
if( stricmp( text, "TimeStamp" ) == 0 ) if( stricmp( text, "TimeStamp" ) == 0 )
timeStamp = atol( data ); timeStamp = atol( data );
if( stricmp( text, "$ENDHEADER" ) == 0 ) if( stricmp( text, "$ENDHEADER" ) == 0 )
return TRUE; return true;
} }
return FALSE; return FALSE;
......
/*********************************************/ /**
/* Headers for component library definition */ * @file class_library.h
/*********************************************/ * @brief Definition for component library class.
*/
#ifndef CLASS_LIBRARY_H #ifndef CLASS_LIBRARY_H
#define CLASS_LIBRARY_H #define CLASS_LIBRARY_H
......
/*************************************************************************************/ /**
/* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations) */ * @file class_netlist_object.cpp
/*************************************************************************************/ * @brief Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations)
*/
#include "fctsys.h" #include "fctsys.h"
#include "macros.h" #include "macros.h"
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "general.h" #include "general.h"
#include "sch_component.h" #include "sch_component.h"
#include "class_netlist_object.h"
#if defined(DEBUG) #if defined(DEBUG)
#include <iostream> #include <iostream>
const char* ShowType( NetObjetType aType ) const char* ShowType( NetObjetType aType )
{ {
...@@ -25,7 +25,7 @@ const char* ShowType( NetObjetType aType ) ...@@ -25,7 +25,7 @@ const char* ShowType( NetObjetType aType )
case NET_BUS: case NET_BUS:
ret = "bus"; break; ret = "bus"; break;
case NET_JONCTION: case NET_JUNCTION:
ret = "junction"; break; ret = "junction"; break;
case NET_LABEL: case NET_LABEL:
...@@ -89,10 +89,12 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) ...@@ -89,10 +89,12 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
switch( m_Type ) switch( m_Type )
{ {
case NET_PIN: case NET_PIN:
out << " <refOfComp>" << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str() << "</refOfComp>\n"; out << " <refOfComp>" << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str()
<< "</refOfComp>\n";
if( m_Comp ) if( m_Comp )
m_Comp->Show( 1, out ); m_Comp->Show( 1, out );
break; break;
default: default:
...@@ -110,7 +112,6 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) ...@@ -110,7 +112,6 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
out << "</netItem>\n"; out << "</netItem>\n";
} }
#endif #endif
...@@ -153,3 +154,23 @@ NETLIST_OBJECT::~NETLIST_OBJECT() ...@@ -153,3 +154,23 @@ NETLIST_OBJECT::~NETLIST_OBJECT()
{ {
} }
bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
{
if( aNetItem == this ) // Don't compare the same net list object.
return false;
int at = m_Type;
int bt = aNetItem->m_Type;
if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
&& ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
{
if( m_SheetList == aNetItem->m_SheetListInclude )
{
return true; //connected!
}
}
return false; //these two are unconnected
}
/***********************************************************************/ /**
/* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc */ * @file class_netlist_object.h
/* calculations) */ * @brief Definition of the NETLIST_OBJECT class.
/***********************************************************************/ */
#ifndef _CLASS_NETLIST_OBJECT_H_ #ifndef _CLASS_NETLIST_OBJECT_H_
#define _CLASS_NETLIST_OBJECT_H_ #define _CLASS_NETLIST_OBJECT_H_
#include "sch_sheet_path.h" #include "sch_sheet_path.h"
#include "lib_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum ) #include "lib_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum )
...@@ -16,7 +17,7 @@ enum NetObjetType { ...@@ -16,7 +17,7 @@ enum NetObjetType {
NET_ITEM_UNSPECIFIED, // only for not yet initialized instances NET_ITEM_UNSPECIFIED, // only for not yet initialized instances
NET_SEGMENT, // connection by wire NET_SEGMENT, // connection by wire
NET_BUS, // connection by bus NET_BUS, // connection by bus
NET_JONCTION, // connection by junction: can connect to NET_JUNCTION, // connection by junction: can connect to
// or more crossing wires // or more crossing wires
NET_LABEL, // this is a local label NET_LABEL, // this is a local label
NET_GLOBLABEL, // this is a global label that connect all NET_GLOBLABEL, // this is a global label that connect all
...@@ -60,7 +61,7 @@ class NETLIST_OBJECT ...@@ -60,7 +61,7 @@ class NETLIST_OBJECT
public: public:
NetObjetType m_Type; /* Type of item (see NetObjetType NetObjetType m_Type; /* Type of item (see NetObjetType
* enum) */ * enum) */
EDA_ITEM * m_Comp; /* Pointer on the library item that EDA_ITEM* m_Comp; /* Pointer on the library item that
* created this net object (the parent) * created this net object (the parent)
*/ */
SCH_ITEM* m_Link; /* For SCH_SHEET_PIN: SCH_ITEM* m_Link; /* For SCH_SHEET_PIN:
...@@ -101,8 +102,8 @@ public: ...@@ -101,8 +102,8 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( std::ostream& out, int ndx ); void Show( std::ostream& out, int ndx );
#endif #endif
NETLIST_OBJECT(); NETLIST_OBJECT();
NETLIST_OBJECT( NETLIST_OBJECT& aSource ); // Copy constructor NETLIST_OBJECT( NETLIST_OBJECT& aSource ); // Copy constructor
...@@ -114,15 +115,27 @@ public: ...@@ -114,15 +115,27 @@ public:
/** /**
* Function GetPinNum * Function GetPinNum
* returns a pin number in wxString form. Pin numbers are not always * returns a pin number in wxString form. Pin numbers are not always
* numbers. "A23" would be a valid pin number. * numbers. \"A23\" would be a valid pin number.
*/ */
wxString GetPinNumText() wxString GetPinNumText()
{ {
// hide the ugliness in here, but do it inline. // hide the ugliness in here, but do it inline.
return LIB_PIN::ReturnPinStringNum( m_PinNum ); return LIB_PIN::ReturnPinStringNum( m_PinNum );
} }
/**
* Function IsLabelConnected
* tests if the net list object is a hierarchical label or sheet label and is
* connected to an associated hierarchical label or sheet label of \a aNetItem.
*
* @param aNetItem A pointer to a NETLIST_OBJECT to test against.
* @return A bool value of true if there is a connection with \a aNetItem or false
* if no connection to \a aNetItem.
*/
bool IsLabelConnected( NETLIST_OBJECT* aNetItem );
}; };
// Buffer to build the list of items used in netlist and erc calculations // Buffer to build the list of items used in netlist and erc calculations
typedef std::vector <NETLIST_OBJECT*> NETLIST_OBJECT_LIST; typedef std::vector <NETLIST_OBJECT*> NETLIST_OBJECT_LIST;
......
/* /*
* component_references_lister.cpp: creates a flat list of components. * @file component_references_lister.cpp
* Needed for annotation and BOM. * @brief Code for creating a flat list of components needed for annotation and BOM.
*/ */
/* /*
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "netlist.h" #include "netlist.h"
#include "class_sch_screen.h"
#include "sch_component.h" #include "sch_component.h"
......
/*********************/ /**
/* dangling_ends.cpp */ * @file dangling_ends.cpp
/*********************/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "sch_item_struct.h" #include "sch_item_struct.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* BufName mask (with * and?) * BufName mask (with * and?)
* *
* Returns * Returns
* TRUE if the selected component * true if the selected component
* FALSE canceled order * FALSE canceled order
* Place the name of the component has loaded, select from a list in * Place the name of the component has loaded, select from a list in
* BufName * BufName
......
/* /*
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2009 Kicad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2009 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
///////////////////////////////////////////////////////////////////////////// /*
* This program source code file is part of KiCad, a free EDA CAD application.
// Name: dialog_erc.cpp *
// Purpose: * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
// Author: jean-pierre Charras * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
// Modified by: * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
// Created: 02/07/2000 *
// License: GPL * 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
*/
/**
* @file dialog_erc.cpp
* @brief Electrical Rules Check dialog implementation.
*/
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "kicad_string.h" #include "kicad_string.h"
...@@ -31,10 +52,12 @@ bool DIALOG_ERC::m_writeErcFile = false; ...@@ -31,10 +52,12 @@ bool DIALOG_ERC::m_writeErcFile = false;
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE ) BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1, EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
wxEVT_COMMAND_BUTTON_CLICKED, wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
DIALOG_ERC::ChangeErrorLevel ) END_EVENT_TABLE()
END_EVENT_TABLE() DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC_BASE( parent ) DIALOG_ERC_BASE( parent )
{ {
m_Parent = parent; m_Parent = parent;
...@@ -49,7 +72,7 @@ void DIALOG_ERC::Init() ...@@ -49,7 +72,7 @@ void DIALOG_ERC::Init()
{ {
SetFocus(); SetFocus();
m_Initialized = FALSE; m_Initialized = false;
for( int ii = 0; ii < PIN_NMAX; ii++ ) for( int ii = 0; ii < PIN_NMAX; ii++ )
for( int jj = 0; jj < PIN_NMAX; jj++ ) for( int jj = 0; jj < PIN_NMAX; jj++ )
...@@ -57,14 +80,18 @@ void DIALOG_ERC::Init() ...@@ -57,14 +80,18 @@ void DIALOG_ERC::Init()
m_WriteResultOpt->SetValue( m_writeErcFile ); m_WriteResultOpt->SetValue( m_writeErcFile );
SCH_SCREENS screens;
int markers = screens.GetMarkerCount();
int warnings = screens.GetMarkerCount( WAR );
wxString num; wxString num;
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); num.Printf( wxT( "%d" ), markers );
m_TotalErrCount->SetLabel( num ); m_TotalErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc ); num.Printf( wxT( "%d" ), markers - warnings );
m_LastErrCount->SetLabel( num ); m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc ); num.Printf( wxT( "%d" ), warnings );
m_LastWarningCount->SetLabel( num ); m_LastWarningCount->SetLabel( num );
DisplayERC_MarkersList(); DisplayERC_MarkersList();
...@@ -78,10 +105,10 @@ void DIALOG_ERC::Init() ...@@ -78,10 +105,10 @@ void DIALOG_ERC::Init()
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS */ /* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS */
void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{
/* Delete the old ERC markers, over the whole hierarchy /* Delete the old ERC markers, over the whole hierarchy
*/ */
void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{
SCH_SCREENS ScreenList; SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC ); ScreenList.DeleteAllMarkers( MARK_ERC );
...@@ -113,6 +140,7 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event ) ...@@ -113,6 +140,7 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
wxSafeYield(); // m_MarkersList must be redraw wxSafeYield(); // m_MarkersList must be redraw
wxArrayString messageList; wxArrayString messageList;
TestErc( &messageList ); TestErc( &messageList );
for( unsigned ii = 0; ii < messageList.GetCount(); ii++ ) for( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
m_MessagesList->AppendText( messageList[ii] ); m_MessagesList->AppendText( messageList[ii] );
} }
...@@ -139,20 +167,21 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) ...@@ -139,20 +167,21 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
NotFound = TRUE; NotFound = true;
/* Search for the selected marker */ /* Search for the selected marker */
for( sheet = SheetList.GetFirst(); for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList(); SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList();
while( item && NotFound ) while( item && NotFound )
{ {
if( item == marker ) if( item == marker )
{ {
NotFound = FALSE; NotFound = false;
break; break;
} }
item = item->Next(); item = item->Next();
} }
...@@ -197,7 +226,7 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -197,7 +226,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
if( !DiagErcTableInit ) if( !DiagErcTableInit )
{ {
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) ); memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
DiagErcTableInit = TRUE; DiagErcTableInit = true;
} }
// Get the current text size: this is a dummy text. // Get the current text size: this is a dummy text.
...@@ -222,7 +251,7 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -222,7 +251,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
pos.y += text_height; pos.y += text_height;
if( m_Initialized == FALSE ) if( m_Initialized == false )
{ {
// Print row labels // Print row labels
for( ii = 0; ii < PIN_NMAX; ii++ ) for( ii = 0; ii < PIN_NMAX; ii++ )
...@@ -238,16 +267,20 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -238,16 +267,20 @@ void DIALOG_ERC::ReBuildMatrixPanel()
pos.x += 5; pos.x += 5;
} }
else else
{
pos = m_ButtonList[0][0]->GetPosition(); pos = m_ButtonList[0][0]->GetPosition();
}
for( ii = 0; ii < PIN_NMAX; ii++ ) for( ii = 0; ii < PIN_NMAX; ii++ )
{ {
int y = pos.y + (ii * bitmap_size.y); int y = pos.y + (ii * bitmap_size.y);
for( jj = 0; jj <= ii; jj++ ) for( jj = 0; jj <= ii; jj++ )
{ {
// Add column labels (only once) // Add column labels (only once)
int diag = DiagErc[ii][jj]; int diag = DiagErc[ii][jj];
int x = pos.x + (jj * bitmap_size.x); int x = pos.x + (jj * bitmap_size.x);
if( (ii == jj) && !m_Initialized ) if( (ii == jj) && !m_Initialized )
{ {
wxPoint txtpos; wxPoint txtpos;
...@@ -258,9 +291,9 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -258,9 +291,9 @@ void DIALOG_ERC::ReBuildMatrixPanel()
CommentERC_V[ii], CommentERC_V[ii],
txtpos ); txtpos );
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, text->GetRect().GetRight() );
text->GetRect().GetRight() );
} }
event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX ); event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );
delete m_ButtonList[ii][jj]; delete m_ButtonList[ii][jj];
...@@ -301,7 +334,8 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -301,7 +334,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
BoxMatrixMinSize.y += BoxMatrixPosition.y; BoxMatrixMinSize.y += BoxMatrixPosition.y;
m_PanelMatrixSizer->SetMinSize( BoxMatrixMinSize ); m_PanelMatrixSizer->SetMinSize( BoxMatrixMinSize );
} }
m_Initialized = TRUE;
m_Initialized = true;
} }
...@@ -315,17 +349,17 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -315,17 +349,17 @@ void DIALOG_ERC::DisplayERC_MarkersList()
m_MarkersList->ClearList(); m_MarkersList->ClearList();
for( SCH_SHEET_PATH* Sheet = SheetList.GetFirst(); for( SCH_SHEET_PATH* Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() )
Sheet != NULL;
Sheet = SheetList.GetNext() )
{ {
SCH_ITEM* DrawStruct = Sheet->LastDrawList(); SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != SCH_MARKER_T ) if( DrawStruct->Type() != SCH_MARKER_T )
continue; continue;
SCH_MARKER* Marker = (SCH_MARKER*) DrawStruct; SCH_MARKER* Marker = (SCH_MARKER*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC ) if( Marker->GetMarkerType() != MARK_ERC )
continue; continue;
...@@ -397,16 +431,16 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event ) ...@@ -397,16 +431,16 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
{ {
wxFileName fn; wxFileName fn;
unsigned NetItemRef; unsigned net;
unsigned OldItem; unsigned lastNet;
unsigned StartNet; unsigned nextNet;
int NetNbItems, MinConn; int NetNbItems, MinConn;
if( !DiagErcTableInit ) if( !DiagErcTableInit )
{ {
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) ); memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
DiagErcTableInit = TRUE; DiagErcTableInit = true;
} }
m_writeErcFile = m_WriteResultOpt->GetValue(); m_writeErcFile = m_WriteResultOpt->GetValue();
...@@ -423,70 +457,61 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -423,70 +457,61 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
msg += wxT( "\n" ); msg += wxT( "\n" );
aMessagesList->Add( msg ); aMessagesList->Add( msg );
} }
return; return;
} }
/* Erase all DRC markers */ SCH_SCREENS screens;
SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
g_EESchemaVar.NbErrorErc = 0; // Erase all previous DRC markers.
g_EESchemaVar.NbWarningErc = 0; screens.DeleteAllMarkers( MARK_ERC );
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
Screen != NULL;
Screen = ScreenList.GetNext() )
{ {
bool ModifyWires; /* Ff wire list has changed, delete Undo Redo list to avoid pointers on deleted
ModifyWires = Screen->SchematicCleanUp( NULL ); * data problems.
*/
/* if wire list has changed, delete Undo Redo list to avoid if( screen->SchematicCleanUp( NULL ) )
* pointers on deleted data problems */ screen->ClearUndoRedoList();
if( ModifyWires )
Screen->ClearUndoRedoList();
} }
/* Test duplicate sheet names /* Test duplicate sheet names inside a given sheet, one cannot have sheets with
* inside a given sheet, one cannot have sheets with duplicate names (file * duplicate names (file names can be duplicated).
* names can be duplicated).
*/ */
int errcnt = TestDuplicateSheetNames( true ); TestDuplicateSheetNames( true );
g_EESchemaVar.NbErrorErc += errcnt;
m_Parent->BuildNetListBase(); m_Parent->BuildNetListBase();
/* Reset the flag m_FlagOfConnection, that will be used next, in /* Reset the flag m_FlagOfConnection, that will be used next, in calculations */
* calculations */
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED; g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
StartNet = OldItem = 0; nextNet = lastNet = 0;
NetNbItems = 0; NetNbItems = 0;
MinConn = NOC; MinConn = NOC;
for( NetItemRef = 0; NetItemRef < g_NetObjectslist.size(); NetItemRef++ ) for( net = 0; net < g_NetObjectslist.size(); net++ )
{ {
if( g_NetObjectslist[OldItem]->GetNet() != g_NetObjectslist[NetItemRef]->GetNet() ) // New net found: if( g_NetObjectslist[lastNet]->GetNet() != g_NetObjectslist[net]->GetNet() )
{ {
// New net found:
MinConn = NOC; MinConn = NOC;
NetNbItems = 0; NetNbItems = 0;
StartNet = NetItemRef; nextNet = net;
} }
switch( g_NetObjectslist[NetItemRef]->m_Type ) switch( g_NetObjectslist[net]->m_Type )
{ {
// These items do not create erc problems
case NET_ITEM_UNSPECIFIED: case NET_ITEM_UNSPECIFIED:
case NET_SEGMENT: case NET_SEGMENT:
case NET_BUS: case NET_BUS:
case NET_JONCTION: case NET_JUNCTION:
case NET_LABEL: case NET_LABEL:
case NET_BUSLABELMEMBER: case NET_BUSLABELMEMBER:
case NET_PINLABEL: case NET_PINLABEL:
case NET_GLOBLABEL: case NET_GLOBLABEL:
case NET_GLOBBUSLABELMEMBER: case NET_GLOBBUSLABELMEMBER:
// These items do not create erc problems
break; break;
case NET_HIERLABEL: case NET_HIERLABEL:
...@@ -497,37 +522,41 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -497,37 +522,41 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// ERC problems when pin sheets do not match hierarchical labels. // ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierarchical label // Each pin sheet must match a hierarchical label
// Each hierarchical label must match a pin sheet // Each hierarchical label must match a pin sheet
TestLabel( m_Parent->DrawPanel, NetItemRef, StartNet ); TestLabel( net, nextNet );
break; break;
case NET_NOCONNECT: case NET_NOCONNECT:
// ERC problems when a noconnect symbol is connected to more than // ERC problems when a noconnect symbol is connected to more than one pin.
// one pin.
MinConn = NET_NC; MinConn = NET_NC;
if( NetNbItems != 0 ) if( NetNbItems != 0 )
Diagnose( m_Parent->DrawPanel, g_NetObjectslist[NetItemRef], NULL, MinConn, UNC ); Diagnose( g_NetObjectslist[net], NULL, MinConn, UNC );
break; break;
case NET_PIN: case NET_PIN:
// Look for ERC problems between pins: // Look for ERC problems between pins:
TestOthersItems( m_Parent->DrawPanel, NetItemRef, StartNet, &NetNbItems, &MinConn ); TestOthersItems( net, nextNet, &NetNbItems, &MinConn );
break; break;
} }
OldItem = NetItemRef; lastNet = net;
} }
// Displays global results: // Displays global results:
wxString num; wxString num;
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); int markers = screens.GetMarkerCount();
int warnings = screens.GetMarkerCount( WAR );
num.Printf( wxT( "%d" ), markers );
m_TotalErrCount->SetLabel( num ); m_TotalErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc ); num.Printf( wxT( "%d" ), markers - warnings );
m_LastErrCount->SetLabel( num ); m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc ); num.Printf( wxT( "%d" ), warnings );
m_LastWarningCount->SetLabel( num ); m_LastWarningCount->SetLabel( num );
// Display diags: // Display diags:
...@@ -550,7 +579,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -550,7 +579,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
if( WriteDiagnosticERC( dlg.GetPath() ) ) if( WriteDiagnosticERC( dlg.GetPath() ) )
{ {
Close( TRUE ); Close( true );
ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) ); ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) );
} }
} }
......
/********************************/ /**
/* Schematic component edition */ * @file edit_component_in_schematic.cpp
/********************************/ * @brief Schematic component editing code.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/*********************************************************************/ /**
/* edit_label.cpp: label, global label and text creation or edition */ * @file edit_label.cpp
/*********************************************************************/ * @brief Label, global label and text creation and editing.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -8,7 +9,6 @@ ...@@ -8,7 +9,6 @@
#include "drawtxt.h" #include "drawtxt.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
......
/***************************************************************************** /**
* Program to draw EE diagrams. * * @file eeredraw.cpp
* This module redraw/draw all structs. * */
*****************************************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "gestfich.h" #include "gestfich.h"
#include "eda_dde.h" #include "eda_dde.h"
#include "id.h" #include "id.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -22,7 +21,7 @@ ...@@ -22,7 +21,7 @@
// Global variables // Global variables
bool g_OptNetListUseNames; /* TRUE to use names rather than net bool g_OptNetListUseNames; /* true to use names rather than net
* The numbers (PSPICE netlist only) */ * The numbers (PSPICE netlist only) */
wxSize g_RepeatStep; wxSize g_RepeatStep;
int g_RepeatDeltaLabel; int g_RepeatDeltaLabel;
...@@ -30,8 +29,6 @@ int g_RepeatDeltaLabel; ...@@ -30,8 +29,6 @@ int g_RepeatDeltaLabel;
bool g_HVLines = true; // Bool: force H or V bool g_HVLines = true; // Bool: force H or V
// directions (Wires, Bus ..) // directions (Wires, Bus ..)
struct EESchemaVariables g_EESchemaVar;
int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT; int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT;
HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
......
/*****************/ /**
/** eeconfig.h **/ * @file eeschema_config.h
/*****************/ */
#include "param_config.h" #include "param_config.h"
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
extern int g_PenMinWidth; extern int g_PenMinWidth;
/* saving parameters option : */ /* saving parameters option : */
#define INSETUP TRUE /* used when the parameter is saved in general config #define INSETUP true /* used when the parameter is saved in general config
* if not used, the parameter is saved in the local * if not used, the parameter is saved in the local
* config (project config) */ * config (project config) */
/**************************************/ /*
/* erc.cpp - Electrical Rules Check */ * 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.
*
* 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
*/
/**
* @file erc.cpp
* @brief Electrical Rules Check implementation.
*/
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -60,34 +85,34 @@ ...@@ -60,34 +85,34 @@
// Messages for matrix rows: // Messages for matrix rows:
const wxChar* CommentERC_H[] = const wxChar* CommentERC_H[] =
{ {
wxT( "Input Pin...." ), _( "Input Pin.........." ),
wxT( "Output Pin..." ), _( "Output Pin........." ),
wxT( "BiDi Pin....." ), _( "Bidirectional Pin.." ),
wxT( "3 State Pin.." ), _( "Tri-State Pin......" ),
wxT( "Passive Pin.." ), _( "Passive Pin........" ),
wxT( "Unspec Pin..." ), _( "Unspecified Pin...." ),
wxT( "Power IN Pin." ), _( "Power Input Pin...." ),
wxT( "PowerOUT Pin." ), _( "Power Output Pin..." ),
wxT( "Open Coll...." ), _( "Open Collector....." ),
wxT( "Open Emit...." ), _( "Open Emitter......." ),
wxT( "No Conn......" ), _( "No Connection......" ),
NULL NULL
}; };
// Messages for matrix columns // Messages for matrix columns
const wxChar* CommentERC_V[] = const wxChar* CommentERC_V[] =
{ {
wxT( "Input Pin" ), _( "Input Pin" ),
wxT( "Output Pin" ), _( "Output Pin" ),
wxT( "BiDi Pin" ), _( "Bidirectional Pin" ),
wxT( "3 State Pin" ), _( "Tri-State Pin" ),
wxT( "Passive Pin" ), _( "Passive Pin" ),
wxT( "Unspec Pin" ), _( "Unspecified Pin" ),
wxT( "Power IN Pin" ), _( "Power Input Pin" ),
wxT( "PowerOUT Pin" ), _( "Power Output Pin" ),
wxT( "Open Coll" ), _( "Open Collector" ),
wxT( "Open Emit" ), _( "Open Emitter" ),
wxT( "No Conn" ), _( "No Connection" ),
NULL NULL
}; };
...@@ -97,10 +122,11 @@ const wxChar* CommentERC_V[] = ...@@ -97,10 +122,11 @@ const wxChar* CommentERC_V[] =
* at start up: must be loaded by DefaultDiagErc * at start up: must be loaded by DefaultDiagErc
*/ */
int DiagErc[PIN_NMAX][PIN_NMAX]; int DiagErc[PIN_NMAX][PIN_NMAX];
bool DiagErcTableInit; // go to TRUE after DiagErc init bool DiagErcTableInit; // go to true after DiagErc init
/* Default Look up table which gives the diag for a pair of connected pins /**
* Same as DiagErc, but cannot be modified * Default Look up table which gives the ERC error level for a pair of connected pins
* Same as DiagErc, but cannot be modified.
* Used to init or reset DiagErc * Used to init or reset DiagErc
* note also, to avoid inconsistancy: * note also, to avoid inconsistancy:
* DefaultDiagErc[i][j] = DefaultDiagErc[j][i] * DefaultDiagErc[i][j] = DefaultDiagErc[j][i]
...@@ -122,16 +148,15 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] = ...@@ -122,16 +148,15 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
}; };
/* Look up table which gives the minimal drive for a pair of connected pins on /**
* a net * Look up table which gives the minimal drive for a pair of connected pins on
* Initial state of a net is NOC (Net with No Connection) * a net.
* Can be updated to NPI (Pin Isolated), NET_NC (Net with a no connect symbol), * <p>
* NOD (Not Driven) or DRV (DRIven) * The initial state of a net is NOC (Net with No Connection). It can be updated to
* * NPI (Pin Isolated), NET_NC (Net with a no connect symbol), NOD (Not Driven) or DRV
* Can be updated to NET_NC with no error only if there is only one pin in net * (DRIven). It can be updated to NET_NC with no error only if there is only one pin
* * in net. Nets are OK when their final state is NET_NC or DRV. Nets with the state
* Nets are OK when their final state is NET_NC or DRV * NOD have no valid source signal.
* Nets with the state NOD have no source signal
*/ */
static int MinimalReq[PIN_NMAX][PIN_NMAX] = static int MinimalReq[PIN_NMAX][PIN_NMAX] =
{ {
...@@ -150,55 +175,44 @@ static int MinimalReq[PIN_NMAX][PIN_NMAX] = ...@@ -150,55 +175,44 @@ static int MinimalReq[PIN_NMAX][PIN_NMAX] =
}; };
/**
* Function TestDuplicateSheetNames( )
* inside a given sheet, one cannot have sheets with duplicate names (file
* names can be duplicated).
* @return the error count
* @param aCreateMarker: true = create error markers in schematic,
* false = calculate error count only
*/
int TestDuplicateSheetNames( bool aCreateMarker ) int TestDuplicateSheetNames( bool aCreateMarker )
{ {
SCH_SCREEN* screen;
SCH_ITEM* item;
SCH_ITEM* test_item;
int err_count = 0; int err_count = 0;
SCH_SCREENS ScreenList; // Created the list of screen SCH_SCREENS screenList; // Created the list of screen
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
Screen != NULL;
Screen = ScreenList.GetNext() )
{ {
for( SCH_ITEM* ref_item = Screen->GetDrawItems(); for( item = screen->GetDrawItems(); item != NULL; item = item->Next() )
ref_item != NULL;
ref_item = ref_item->Next() )
{ {
// search for a sheet; // search for a sheet;
if( ref_item->Type() != SCH_SHEET_T ) if( item->Type() != SCH_SHEET_T )
continue; continue;
for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL; for( test_item = item->Next(); test_item != NULL; test_item = test_item->Next() )
item_to_test = item_to_test->Next() )
{ {
if( item_to_test->Type() != SCH_SHEET_T ) if( test_item->Type() != SCH_SHEET_T )
continue; continue;
// We have found a second sheet: compare names // We have found a second sheet: compare names
if( ( (SCH_SHEET*) ref_item )->m_SheetName.CmpNoCase( if( ( (SCH_SHEET*) item )->m_SheetName.CmpNoCase(
( ( SCH_SHEET* ) item_to_test )-> m_SheetName ) ( ( SCH_SHEET* ) test_item )-> m_SheetName ) == 0 )
== 0 )
{ {
if( aCreateMarker ) if( aCreateMarker )
{ {
/* Create a new marker type ERC error*/ /* Create a new marker type ERC error*/
SCH_MARKER* Marker = new SCH_MARKER(); SCH_MARKER* marker = new SCH_MARKER();
Marker->m_TimeStamp = GetTimeStamp(); marker->m_TimeStamp = GetTimeStamp();
Marker->SetData( ERCE_DUPLICATE_SHEET_NAME, marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
( (SCH_SHEET*) item_to_test )->m_Pos, ( (SCH_SHEET*) test_item )->m_Pos,
_( "Duplicate Sheet name" ), _( "Duplicate sheet name" ),
( (SCH_SHEET*) item_to_test )->m_Pos ); ( (SCH_SHEET*) test_item )->m_Pos );
Marker->SetMarkerType( MARK_ERC ); marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( ERR ); marker->SetErrorLevel( ERR );
Marker->SetNext( Screen->GetDrawItems() ); marker->SetNext( screen->GetDrawItems() );
Screen->SetDrawItems( Marker ); screen->SetDrawItems( marker );
} }
err_count++; err_count++;
...@@ -211,16 +225,10 @@ int TestDuplicateSheetNames( bool aCreateMarker ) ...@@ -211,16 +225,10 @@ int TestDuplicateSheetNames( bool aCreateMarker )
} }
/* Creates an ERC marker to show the ERC problem about aNetItemRef void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
* or between aNetItemRef and aNetItemTst
* if MinConn < 0: this is an error on labels
*/
void Diagnose( EDA_DRAW_PANEL* aPanel,
NETLIST_OBJECT* aNetItemRef,
NETLIST_OBJECT* aNetItemTst,
int aMinConn, int aDiag ) int aMinConn, int aDiag )
{ {
SCH_MARKER* Marker = NULL; SCH_MARKER* marker = NULL;
SCH_SCREEN* screen; SCH_SCREEN* screen;
int ii, jj; int ii, jj;
...@@ -228,16 +236,14 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -228,16 +236,14 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
return; return;
/* Create new marker for ERC error. */ /* Create new marker for ERC error. */
Marker = new SCH_MARKER(); marker = new SCH_MARKER();
Marker->m_TimeStamp = GetTimeStamp(); marker->m_TimeStamp = GetTimeStamp();
Marker->SetMarkerType( MARK_ERC ); marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( WAR ); marker->SetErrorLevel( WAR );
screen = aNetItemRef->m_SheetList.LastScreen(); screen = aNetItemRef->m_SheetList.LastScreen();
Marker->SetNext( screen->GetDrawItems() ); marker->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( Marker ); screen->SetDrawItems( marker );
g_EESchemaVar.NbErrorErc++;
g_EESchemaVar.NbWarningErc++;
wxString msg; wxString msg;
...@@ -246,17 +252,17 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -246,17 +252,17 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
if( (aNetItemRef->m_Type == NET_HIERLABEL) if( (aNetItemRef->m_Type == NET_HIERLABEL)
|| (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) ) || (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
{ {
msg.Printf( _( "HLabel %s not connected to SheetLabel" ), msg.Printf( _( "Hierarchical label %s is not connected to a sheet label." ),
GetChars( aNetItemRef->m_Label ) ); GetChars( aNetItemRef->m_Label ) );
} }
else else
{ {
msg.Printf( _( "SheetLabel %s not connected to HLabel" ), msg.Printf( _( "Sheet label %s is not connected to a hierarchical label." ),
GetChars( aNetItemRef->m_Label ) ); GetChars( aNetItemRef->m_Label ) );
} }
Marker->SetData( ERCE_HIERACHICAL_LABEL, marker->SetData( ERCE_HIERACHICAL_LABEL,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
aNetItemRef->m_Start ); aNetItemRef->m_Start );
...@@ -279,10 +285,9 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -279,10 +285,9 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
{ {
if( aMinConn == NOC ) /* Only 1 element in the net. */ if( aMinConn == NOC ) /* Only 1 element in the net. */
{ {
msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ), msg.Printf( _( "Pin %s (%s) of component %s is unconnected." ),
GetChars( cmp_ref ), GetChars( string_pinnum ), GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ) );
MsgPinElectricType[ii] ); marker->SetData( ERCE_PIN_NOT_CONNECTED,
Marker->SetData( ERCE_PIN_NOT_CONNECTED,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
aNetItemRef->m_Start ); aNetItemRef->m_Start );
...@@ -294,10 +299,11 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -294,10 +299,11 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link ) if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList ); &aNetItemRef->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
GetChars( cmp_ref ), GetChars( string_pinnum ), msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ),
MsgPinElectricType[ii], aNetItemRef->GetNet() ); GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ),
Marker->SetData( ERCE_PIN_NOT_DRIVEN, aNetItemRef->GetNet() );
marker->SetData( ERCE_PIN_NOT_DRIVEN,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
aNetItemRef->m_Start ); aNetItemRef->m_Start );
...@@ -306,8 +312,8 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -306,8 +312,8 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
if( aDiag == UNC ) if( aDiag == UNC )
{ {
msg.Printf( _( "More than 1 Pin connected to UnConnect symbol" ) ); msg.Printf( _( "More than 1 pin connected to an UnConnect symbol." ) );
Marker->SetData( ERCE_NOCONNECT_CONNECTED, marker->SetData( ERCE_NOCONNECT_CONNECTED,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
aNetItemRef->m_Start ); aNetItemRef->m_Start );
...@@ -319,10 +325,10 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -319,10 +325,10 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
{ {
jj = aNetItemTst->m_ElectricalType; jj = aNetItemTst->m_ElectricalType;
int errortype = ERCE_PIN_TO_PIN_WARNING; int errortype = ERCE_PIN_TO_PIN_WARNING;
if( aDiag == ERR ) if( aDiag == ERR )
{ {
Marker->SetErrorLevel( ERR ); marker->SetErrorLevel( ERR );
g_EESchemaVar.NbWarningErc--;
errortype = ERCE_PIN_TO_PIN_ERROR; errortype = ERCE_PIN_TO_PIN_ERROR;
} }
...@@ -330,29 +336,22 @@ void Diagnose( EDA_DRAW_PANEL* aPanel, ...@@ -330,29 +336,22 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
memcpy( ascii_buf, &aNetItemTst->m_PinNum, 4 ); memcpy( ascii_buf, &aNetItemTst->m_PinNum, 4 );
alt_string_pinnum = FROM_UTF8( ascii_buf ); alt_string_pinnum = FROM_UTF8( ascii_buf );
alt_cmp = wxT( "?" ); alt_cmp = wxT( "?" );
if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link ) if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetList );
&aNetItemTst->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ), msg.Printf( _( "Pin %s (%s) of component %s is connected to " ),
GetChars( cmp_ref ), GetChars( string_pinnum ), MsgPinElectricType[ii] ); GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ) );
Marker->SetData( errortype, marker->SetData( errortype, aNetItemRef->m_Start, msg, aNetItemRef->m_Start );
aNetItemRef->m_Start, msg.Printf( _( "pin %s (%s) of component %s (net %d)." ),
msg, GetChars( alt_string_pinnum ), MsgPinElectricType[jj], GetChars( alt_cmp ),
aNetItemRef->m_Start );
msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ),
GetChars( alt_cmp ), GetChars( alt_string_pinnum ), MsgPinElectricType[jj],
aNetItemRef->GetNet() ); aNetItemRef->GetNet() );
Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start ); marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
} }
} }
/* Routine testing electrical conflicts between NetItemRef and other items void TestOthersItems( unsigned NetItemRef, unsigned netstart,
* of the same net
*/
void TestOthersItems( EDA_DRAW_PANEL* panel,
unsigned NetItemRef,
unsigned netstart,
int* NetNbItems, int* MinConnexion ) int* NetNbItems, int* MinConnexion )
{ {
unsigned NetItemTst; unsigned NetItemTst;
...@@ -364,6 +363,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel, ...@@ -364,6 +363,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
NetItemTst = netstart; NetItemTst = netstart;
local_minconn = NOC; local_minconn = NOC;
if( ref_elect_type == PIN_NC ) if( ref_elect_type == PIN_NC )
local_minconn = NPI; local_minconn = NPI;
...@@ -373,8 +373,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel, ...@@ -373,8 +373,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
if( NetItemRef == NetItemTst ) if( NetItemRef == NetItemTst )
continue; continue;
/* We examine only a given net. We stop the search if the net changes // We examine only a given net. We stop the search if the net changes
**/
if( ( NetItemTst >= g_NetObjectslist.size() ) // End of list if( ( NetItemTst >= g_NetObjectslist.size() ) // End of list
|| ( g_NetObjectslist[NetItemRef]->GetNet() != || ( g_NetObjectslist[NetItemRef]->GetNet() !=
g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
...@@ -384,56 +383,53 @@ void TestOthersItems( EDA_DRAW_PANEL* panel, ...@@ -384,56 +383,53 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
{ {
/* Not connected or not driven pin. */ /* Not connected or not driven pin. */
bool seterr = true; bool seterr = true;
if( local_minconn == NOC
&& g_NetObjectslist[NetItemRef]->m_Type == NET_PIN ) if( local_minconn == NOC && g_NetObjectslist[NetItemRef]->m_Type == NET_PIN )
{ {
/* This pin is not connected: for multiple part per /* This pin is not connected: for multiple part per
* package, and duplicated pin, * package, and duplicated pin,
* search for an other instance of this pin * search for an other instance of this pin
* this will be flagged only is all instances of this pin * this will be flagged only if all instances of this pin
* are not connected * are not connected
* TODO test also if instances connected are connected to * TODO test also if instances connected are connected to
* the same net * the same net
*/ */
for( unsigned duppin = 0; for( unsigned duplicate = 0; duplicate < g_NetObjectslist.size(); duplicate++ )
duppin < g_NetObjectslist.size();
duppin++ )
{ {
if( g_NetObjectslist[duppin]->m_Type != NET_PIN ) if( g_NetObjectslist[duplicate]->m_Type != NET_PIN )
continue; continue;
if( duppin == NetItemRef )
if( duplicate == NetItemRef )
continue; continue;
if( g_NetObjectslist[NetItemRef]->m_PinNum != if( g_NetObjectslist[NetItemRef]->m_PinNum !=
g_NetObjectslist[duppin]->m_PinNum ) g_NetObjectslist[duplicate]->m_PinNum )
continue; continue;
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]-> if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]-> m_Link )->GetRef( &g_NetObjectslist[NetItemRef]-> m_SheetList ) !=
m_SheetList ) != ( (SCH_COMPONENT*) g_NetObjectslist[duplicate]->m_Link )
( (SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link ) ->GetRef( &g_NetObjectslist[duplicate]->m_SheetList ) )
->GetRef( &g_NetObjectslist[duppin]->m_SheetList ) )
continue; continue;
// Same component and same pin. Do dot create error for // Same component and same pin. Do dot create error for this pin
// this pin // if the other pin is connected (i.e. if duplicate net has an other
// if the other pin is connected (i.e. if duppin net // item)
// has an other item) if( (duplicate > 0)
if( (duppin > 0) && ( g_NetObjectslist[duplicate]->GetNet() ==
&& ( g_NetObjectslist[duppin]->GetNet() == g_NetObjectslist[duplicate - 1]->GetNet() ) )
g_NetObjectslist[duppin - 1]->GetNet() ) )
seterr = false; seterr = false;
if( (duppin < g_NetObjectslist.size() - 1)
&& ( g_NetObjectslist[duppin]->GetNet() == if( (duplicate < g_NetObjectslist.size() - 1)
g_NetObjectslist[duppin + 1]->GetNet() ) ) && ( g_NetObjectslist[duplicate]->GetNet() ==
g_NetObjectslist[duplicate + 1]->GetNet() ) )
seterr = false; seterr = false;
} }
} }
if( seterr ) if( seterr )
Diagnose( panel, Diagnose( g_NetObjectslist[NetItemRef], NULL, local_minconn, WAR );
g_NetObjectslist[NetItemRef],
NULL,
local_minconn,
WAR );
*MinConnexion = DRV; // inhibiting other messages of this *MinConnexion = DRV; // inhibiting other messages of this
// type for the net. // type for the net.
} }
...@@ -445,7 +441,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel, ...@@ -445,7 +441,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
case NET_ITEM_UNSPECIFIED: case NET_ITEM_UNSPECIFIED:
case NET_SEGMENT: case NET_SEGMENT:
case NET_BUS: case NET_BUS:
case NET_JONCTION: case NET_JUNCTION:
case NET_LABEL: case NET_LABEL:
case NET_HIERLABEL: case NET_HIERLABEL:
case NET_BUSLABELMEMBER: case NET_BUSLABELMEMBER:
...@@ -469,15 +465,16 @@ void TestOthersItems( EDA_DRAW_PANEL* panel, ...@@ -469,15 +465,16 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
break; break;
*NetNbItems += 1; *NetNbItems += 1;
if( erc == OK ) if( erc == OK )
{ {
erc = DiagErc[ref_elect_type][jj]; erc = DiagErc[ref_elect_type][jj];
if( erc != OK ) if( erc != OK )
{ {
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 ) if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
{ {
Diagnose( panel, Diagnose( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst], g_NetObjectslist[NetItemTst],
0, 0,
erc ); erc );
...@@ -486,95 +483,68 @@ void TestOthersItems( EDA_DRAW_PANEL* panel, ...@@ -486,95 +483,68 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
} }
} }
} }
break; break;
} }
} }
} }
/* Create the Diagnostic file (<xxx>.erc file) bool WriteDiagnosticERC( const wxString& aFullFileName )
*/
bool WriteDiagnosticERC( const wxString& FullFileName )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* item;
SCH_MARKER* Marker; SCH_MARKER* marker;
char Line[1024]; static FILE* file;
static FILE* OutErc; SCH_SHEET_PATH* sheet;
SCH_SHEET_PATH* Sheet;
wxString msg; wxString msg;
int count = 0;
if( ( OutErc = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL ) if( ( file = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
return FALSE; return FALSE;
DateAndTime( Line );
msg = _( "ERC report" ); msg = _( "ERC report" );
fprintf( OutErc, "%s (%s)\n", TO_UTF8( msg ), Line ); fprintf( file, "%s (%s)\n", TO_UTF8( msg ), TO_UTF8( DateAndTime() ) );
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST sheetList;
for( Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() ) for( sheet = sheetList.GetFirst(); sheet != NULL; sheet = sheetList.GetNext() )
{ {
if( Sheet->Last() == g_RootSheet ) msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( sheet->PathHumanReadable() ) );
{
msg.Printf( _( "\n***** Sheet / (Root) \n" ) );
}
else
{
wxString str = Sheet->PathHumanReadable();
msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( str ) );
}
fprintf( OutErc, "%s", TO_UTF8( msg ) ); fprintf( file, "%s", TO_UTF8( msg ) );
DrawStruct = Sheet->LastDrawList(); for( item = sheet->LastDrawList(); item != NULL; item = item->Next() )
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != SCH_MARKER_T ) if( item->Type() != SCH_MARKER_T )
continue;
Marker = (SCH_MARKER*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC )
continue; continue;
msg = Marker->GetReporter().ShowReport();
fprintf( OutErc, "%s", TO_UTF8( msg ) );
}
}
msg.Printf( _( "\n >> Errors ERC: %d\n" ), g_EESchemaVar.NbErrorErc ); marker = (SCH_MARKER*) item;
fprintf( OutErc, "%s", TO_UTF8( msg ) );
fclose( OutErc );
return TRUE;
}
if( marker->GetMarkerType() != MARK_ERC )
continue;
static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b ) if( marker->GetMarkerType() == ERR )
{ count++;
int at = a->m_Type;
int bt = b->m_Type;
if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER ) msg = marker->GetReporter().ShowReport();
&& ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) ) fprintf( file, "%s", TO_UTF8( msg ) );
{
if( a->m_SheetList == b->m_SheetListInclude )
{
return true; //connected!
} }
} }
return false; //these two are unconnected
msg.Printf( _( "\n >> Errors ERC: %d\n" ), count );
fprintf( file, "%s", TO_UTF8( msg ) );
fclose( file );
return true;
} }
/* Routine to perform erc on a sheetLabel that is connected to a corresponding void TestLabel( unsigned NetItemRef, unsigned StartNet )
* sub sheet Glabel
*/
void TestLabel( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned StartNet )
{ {
unsigned NetItemTst; unsigned NetItemTst;
int erc = 1; int erc = 1;
NetItemTst = StartNet; NetItemTst = StartNet;
/* Review the list of labels connected to NetItemRef. */ /* Review the list of labels connected to NetItemRef. */
...@@ -585,24 +555,23 @@ void TestLabel( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned StartNet ) ...@@ -585,24 +555,23 @@ void TestLabel( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned StartNet )
/* Is always in the same net? */ /* Is always in the same net? */
if( ( NetItemTst == g_NetObjectslist.size() ) if( ( NetItemTst == g_NetObjectslist.size() )
|| ( g_NetObjectslist[NetItemRef]->GetNet() != || ( g_NetObjectslist[NetItemRef]->GetNet() != g_NetObjectslist[NetItemTst]->GetNet() ) )
g_NetObjectslist[NetItemTst]->GetNet() ) )
{ {
/* End Netcode found. */ /* End Netcode found. */
if( erc ) if( erc )
{ {
/* Glabel or SheetLabel orphaned. */ /* Glabel or SheetLabel orphaned. */
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, -1, WAR ); Diagnose( g_NetObjectslist[NetItemRef], NULL, -1, WAR );
} }
return; return;
} }
if( IsLabelsConnected( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst] ) ) if( g_NetObjectslist[NetItemRef]->IsLabelConnected( g_NetObjectslist[NetItemTst] ) )
erc = 0; erc = 0;
//same thing, different order. //same thing, different order.
if( IsLabelsConnected( g_NetObjectslist[NetItemTst], if( g_NetObjectslist[NetItemTst]->IsLabelConnected( g_NetObjectslist[NetItemRef] ) )
g_NetObjectslist[NetItemRef] ) )
erc = 0; erc = 0;
} }
} }
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jea-Pierre.Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2009-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -22,6 +23,10 @@ ...@@ -22,6 +23,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file erc.h
*/
#ifndef _ERC_H #ifndef _ERC_H
#define _ERC_H #define _ERC_H
...@@ -58,16 +63,44 @@ enum errortype ...@@ -58,16 +63,44 @@ enum errortype
#define NOC 0 // initial state of a net: no connection #define NOC 0 // initial state of a net: no connection
extern bool WriteDiagnosticERC( const wxString& FullFileName ); /**
* Function WriteDiagnosticERC
* save the ERC errors to \a aFullFileName.
*
* @param aFullFileName A wxString object containing the file name and path.
*/
extern bool WriteDiagnosticERC( const wxString& aFullFileName );
extern void Diagnose( EDA_DRAW_PANEL* panel, NETLIST_OBJECT* NetItemRef, /**
NETLIST_OBJECT* NetItemTst, int MinConnexion, int Diag ); * Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef
* or between aNetItemRef and aNetItemTst.
* if MinConn < 0: this is an error on labels
*/
extern void Diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst,
int MinConnexion, int Diag );
extern void TestOthersItems( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned NetStart, /**
* Perform ERC testing for electrical conflicts between \a NetItemRef and other items
* on the same net.
*/
extern void TestOthersItems( unsigned NetItemRef, unsigned NetStart,
int* NetNbItems, int* MinConnexion ); int* NetNbItems, int* MinConnexion );
extern void TestLabel( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned StartNet ); /**
* Function TestLabel
* performs an ERC on a sheet labels to verify that it is connected to a corresponding
* sub sheet global label.
*/
extern void TestLabel( unsigned NetItemRef, unsigned StartNet );
/**
* Function TestDuplicateSheetNames( )
* inside a given sheet, one cannot have sheets with duplicate names (file
* names can be duplicated).
* @return the error count
* @param aCreateMarker: true = create error markers in schematic,
* false = calculate error count only
*/
extern int TestDuplicateSheetNames( bool aCreateMarker ); extern int TestDuplicateSheetNames( bool aCreateMarker );
......
/* /*
* events_called_functions.cpp * @file events_called_functions.cpp
* some events functions
*/ */
#include "fctsys.h" #include "fctsys.h"
...@@ -8,7 +7,6 @@ ...@@ -8,7 +7,6 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "general.h" #include "general.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "protos.h" #include "protos.h"
......
...@@ -185,8 +185,6 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew ) ...@@ -185,8 +185,6 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
SetStatusText( wxEmptyString ); SetStatusText( wxEmptyString );
ClearMsgPanel(); ClearMsgPanel();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
screen->ClrModify(); screen->ClrModify();
if( aIsNew ) if( aIsNew )
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/***************/ /**
/* GENERAL.H */ * @file general.h
/***************/ */
#ifndef _GENERAL_H_ #ifndef _GENERAL_H_
#define _GENERAL_H_ #define _GENERAL_H_
...@@ -115,14 +115,6 @@ extern int g_RepeatDeltaLabel; ...@@ -115,14 +115,6 @@ extern int g_RepeatDeltaLabel;
// Management options. // Management options.
extern bool g_HVLines; extern bool g_HVLines;
// Management variables, option ... to be stored. Reset to 0 during a
// project reload.
struct EESchemaVariables
{
int NbErrorErc;
int NbWarningErc;
};
extern struct EESchemaVariables g_EESchemaVar; extern struct EESchemaVariables g_EESchemaVar;
extern int g_DefaultTextLabelSize; extern int g_DefaultTextLabelSize;
...@@ -170,7 +162,7 @@ extern int g_InvisibleItemColor; ...@@ -170,7 +162,7 @@ extern int g_InvisibleItemColor;
extern NETLIST_OBJECT_LIST g_NetObjectslist; extern NETLIST_OBJECT_LIST g_NetObjectslist;
extern bool g_OptNetListUseNames; /* TRUE to use names rather than extern bool g_OptNetListUseNames; /* true to use names rather than
* net numbers. SPICE netlist only * net numbers. SPICE netlist only
*/ */
......
/*************************************************/ /**
/* Module to handle Get & Place Library Part */ * @file getpart.cpp
/*************************************************/ * @brief Cod to handle get & place library component.
*/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
......
/******************/ /**
/* hierarch.cpp */ * @file hierarch.cpp
/******************/ */
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -61,7 +60,7 @@ HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) : ...@@ -61,7 +60,7 @@ HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) :
m_Parent = parent; m_Parent = parent;
// Make an image list containing small icons // Make an image list containing small icons
imageList = new wxImageList( 16, 15, TRUE, 2 ); imageList = new wxImageList( 16, 15, true, 2 );
imageList->Add( KiBitmap( tree_nosel_xpm ) ); imageList->Add( KiBitmap( tree_nosel_xpm ) );
imageList->Add( KiBitmap( tree_sel_xpm ) ); imageList->Add( KiBitmap( tree_sel_xpm ) );
...@@ -122,7 +121,7 @@ HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* parent, wxDC* DC, cons ...@@ -122,7 +121,7 @@ HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* parent, wxDC* DC, cons
m_nbsheets = 1; m_nbsheets = 1;
cellule = m_Tree->AddRoot( _( "Root" ), 0, 1 ); cellule = m_Tree->AddRoot( _( "Root" ), 0, 1 );
m_Tree->SetItemBold( cellule, TRUE ); m_Tree->SetItemBold( cellule, true );
SCH_SHEET_PATH list; SCH_SHEET_PATH list;
list.Push( g_RootSheet ); list.Push( g_RootSheet );
m_Tree->SetItemData( cellule, new TreeItemData( list ) ); m_Tree->SetItemData( cellule, new TreeItemData( list ) );
......
...@@ -22,11 +22,6 @@ ...@@ -22,11 +22,6 @@
extern int ExportPartId; extern int ExportPartId;
/* Routine to read one part.
* The format is that of libraries, but it loads only 1 component.
* Or 1 component if there are several.
* If the first component is an alias, it will load the corresponding root.
*/
void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
{ {
wxString errMsg; wxString errMsg;
...@@ -74,18 +69,6 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) ...@@ -74,18 +69,6 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
} }
/* Routine to create a new library and backup the current component in this
* library or export the component of the current library.
* createLib == TRUE if we are creating a new library.
* If not: export the library component.
* Basically these 2 options do the same thing, but for user's convenience
* > When creating a new lib, the user is prompted to add the new lib to
* current eeschema config library list
* > When exporting there is no message (it is expected the user does not want to add the
* new created lib
*
* The file format is created in all cases the same.
*/
void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
......
/*****************************************************/ /**
/* libarch.cpp */ * @file libarch.cpp
/* Module for generation of component archive files. */ * @brief Module for generation of component archive files.
/*****************************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
......
...@@ -96,7 +96,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -96,7 +96,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_ANCHOR_ITEM_BUTT: case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
PlaceAncre(); PlaceAnchor();
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break; break;
......
...@@ -17,10 +17,6 @@ ...@@ -17,10 +17,6 @@
#include "class_library.h" #include "class_library.h"
/**
* Function OnPlotCurrentComponent
* plot in SVG or PNG format the curren component
*/
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
{ {
LIB_COMPONENT* cmp = GetComponent(); LIB_COMPONENT* cmp = GetComponent();
...@@ -47,7 +43,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) ...@@ -47,7 +43,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(), FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this, fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE ); wxFD_SAVE, true );
if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() )
return; return;
...@@ -67,7 +63,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) ...@@ -67,7 +63,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
fn.SetExt( file_ext ); fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(), FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this, fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE ); wxFD_SAVE, true );
if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() )
return; return;
...@@ -90,13 +86,6 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) ...@@ -90,13 +86,6 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
} }
/**
* Function CreatePNGorJPEGFile
* Create an image (screenshot) of the current component.
* Output file format is png or jpeg
* @param aFileName = the full filename
* @param aFmt_jpeg = true to use JPEG file format, false to use PNG file format
*/
void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ) void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg )
{ {
wxSize image_size = DrawPanel->GetClientSize(); wxSize image_size = DrawPanel->GetClientSize();
...@@ -121,16 +110,8 @@ void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_j ...@@ -121,16 +110,8 @@ void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_j
image.Destroy(); image.Destroy();
} }
/**
* Function PrintPage (virtual) void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData)
* used to print a page.
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not used here)
*/
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask,
bool aPrintMirrorMode, void* aData)
{ {
if( ! m_component ) if( ! m_component )
return; return;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "confirm.h" #include "confirm.h"
#include "eda_doc.h" #include "eda_doc.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/**
/************************/ * @file libeditframe.h
/* class LIB_EDIT_FRAME */ * @brief Definition of class LIB_EDIT_FRAME
/************************/ */
#ifndef __LIBEDITFRM_H__ #ifndef __LIBEDITFRM_H__
#define __LIBEDITFRM_H__ #define __LIBEDITFRM_H__
...@@ -61,10 +61,28 @@ public: ...@@ -61,10 +61,28 @@ public:
void InstallDimensionsDialog( wxCommandEvent& event ); void InstallDimensionsDialog( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent ); void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
/**
* Function OnPlotCurrentComponent
* plot the current component in SVG or PNG format.
*/
void OnPlotCurrentComponent( wxCommandEvent& event ); void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnSelectTool( wxCommandEvent& aEvent ); void OnSelectTool( wxCommandEvent& aEvent );
/**
* Routine to read one part.
* The format is that of libraries, but it loads only 1 component.
* Or 1 component if there are several.
* If the first component is an alias, it will load the corresponding root.
*/
void OnImportPart( wxCommandEvent& event ); void OnImportPart( wxCommandEvent& event );
/**
* Function OnExportPart
* creates a new library and backup the current component in this library or export
* the component of the current library.
*/
void OnExportPart( wxCommandEvent& event ); void OnExportPart( wxCommandEvent& event );
void OnSelectAlias( wxCommandEvent& event ); void OnSelectAlias( wxCommandEvent& event );
void OnSelectPart( wxCommandEvent& event ); void OnSelectPart( wxCommandEvent& event );
...@@ -353,8 +371,14 @@ private: ...@@ -353,8 +371,14 @@ private:
void CreatePin( wxDC* DC ); void CreatePin( wxDC* DC );
void StartMovePin( wxDC* DC ); void StartMovePin( wxDC* DC );
// Editing anchor /**
void PlaceAncre(); * Function PlaceAnchor
* places an anchor reference coordinate for the current component.
* <p>
* All object coordinates are offset to the current cursor position.
* </p>
*/
void PlaceAnchor();
// Editing graphic items // Editing graphic items
LIB_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ); LIB_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
...@@ -362,8 +386,26 @@ private: ...@@ -362,8 +386,26 @@ private:
void StartMoveDrawSymbol( wxDC* DC ); void StartMoveDrawSymbol( wxDC* DC );
void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc. void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
void EndDrawGraphicItem( wxDC* DC ); void EndDrawGraphicItem( wxDC* DC );
/**
* Function LoadOneSymbol
* read a component symbol file (*.sym ) and add graphic items to the current component.
* <p>
* A symbol file *.sym has the same format as a library, and contains only
* one symbol.
* </p>
*/
void LoadOneSymbol(); void LoadOneSymbol();
/**
* Function SaveOneSymbol
* saves the current component to a symbol file.
* <p>
* The symbol file format is similar to the standard component library file format, but
* there is only one symbol. Invisible pins are not saved.
*/
void SaveOneSymbol(); void SaveOneSymbol();
void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ); void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ); void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem );
LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition, LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition,
...@@ -449,14 +491,14 @@ protected: ...@@ -449,14 +491,14 @@ protected:
/** /**
* Function CreatePNGorJPEGFile * Function CreatePNGorJPEGFile
* Create an image (screenshot) of the current component. * creates an image (screenshot) of the current component in PNG or JPEG format.
* Output file format is png or jpeg
* @param aFileName = the full filename * @param aFileName = the full filename
* @param aFmt_jpeg = true to use JPEG ffile format, false to use PNG file format * @param aFmt_jpeg = true to use JPEG ffile format, false to use PNG file format
*/ */
void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ); void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg );
/** Virtual function PrintPage /**
* Virtual function PrintPage
* used to print a page * used to print a page
* @param aDC = wxDC given by the calling print function * @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here * @param aPrintMask = not used here
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "richio.h" #include "richio.h"
#include "general.h" #include "general.h"
...@@ -318,7 +317,7 @@ line %d, \aAbort reading file.\n" ), ...@@ -318,7 +317,7 @@ line %d, \aAbort reading file.\n" ),
for( ; ; ) for( ; ; )
{ {
if( !aLine->ReadLine() ) if( !aLine->ReadLine() )
return TRUE; return true;
line = aLine->Line(); line = aLine->Line();
......
...@@ -23,19 +23,16 @@ ...@@ -23,19 +23,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/*****************************/ /**
/* Net list generation code. */ * @file netform.cpp
/*****************************/ * @brief Net list generation code.
*/
#include "fctsys.h" #include "fctsys.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -47,7 +44,7 @@ ...@@ -47,7 +44,7 @@
#include "sch_component.h" #include "sch_component.h"
#include "sch_text.h" #include "sch_text.h"
#include "sch_sheet.h" #include "sch_sheet.h"
#include "template_fieldnames.h"
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
......
/*****************/ /**
/* netlist.cpp */ * @file eeschema/netlist.cpp
/*****************/ */
#include "fctsys.h" #include "fctsys.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -51,6 +50,7 @@ static int LastNetCode, LastBusNetCode; ...@@ -51,6 +50,7 @@ static int LastNetCode, LastBusNetCode;
#if defined(DEBUG) #if defined(DEBUG)
void dumpNetTable() void dumpNetTable()
{ {
for( unsigned idx = 0; idx < g_NetObjectslist.size(); ++idx ) for( unsigned idx = 0; idx < g_NetObjectslist.size(); ++idx )
...@@ -59,7 +59,6 @@ void dumpNetTable() ...@@ -59,7 +59,6 @@ void dumpNetTable()
} }
} }
#endif #endif
...@@ -123,6 +122,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -123,6 +122,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
for( unsigned ii = 0, istart = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0, istart = 0; ii < g_NetObjectslist.size(); ii++ )
{ {
NETLIST_OBJECT* net_item = g_NetObjectslist[ii]; NETLIST_OBJECT* net_item = g_NetObjectslist[ii];
if( net_item->m_SheetList != *sheet ) // Sheet change if( net_item->m_SheetList != *sheet ) // Sheet change
{ {
sheet = &(net_item->m_SheetList); sheet = &(net_item->m_SheetList);
...@@ -149,16 +149,18 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -149,16 +149,18 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->SetNet( LastNetCode ); net_item->SetNet( LastNetCode );
LastNetCode++; LastNetCode++;
} }
PointToPointConnect( net_item, 0, istart ); PointToPointConnect( net_item, 0, istart );
break; break;
case NET_JONCTION: case NET_JUNCTION:
/* Control of the junction outside BUS. */ /* Control of the junction outside BUS. */
if( net_item->GetNet() == 0 ) if( net_item->GetNet() == 0 )
{ {
net_item->SetNet( LastNetCode ); net_item->SetNet( LastNetCode );
LastNetCode++; LastNetCode++;
} }
SegmentToPointConnect( net_item, 0, istart ); SegmentToPointConnect( net_item, 0, istart );
/* Control of the junction, on BUS. */ /* Control of the junction, on BUS. */
...@@ -167,6 +169,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -167,6 +169,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->m_BusNetCode = LastBusNetCode; net_item->m_BusNetCode = LastBusNetCode;
LastBusNetCode++; LastBusNetCode++;
} }
SegmentToPointConnect( net_item, ISBUS, istart ); SegmentToPointConnect( net_item, ISBUS, istart );
break; break;
...@@ -179,6 +182,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -179,6 +182,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->SetNet( LastNetCode ); net_item->SetNet( LastNetCode );
LastNetCode++; LastNetCode++;
} }
SegmentToPointConnect( net_item, 0, istart ); SegmentToPointConnect( net_item, 0, istart );
break; break;
...@@ -193,6 +197,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -193,6 +197,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->m_BusNetCode = LastBusNetCode; net_item->m_BusNetCode = LastBusNetCode;
LastBusNetCode++; LastBusNetCode++;
} }
PointToPointConnect( net_item, ISBUS, istart ); PointToPointConnect( net_item, ISBUS, istart );
break; break;
...@@ -205,6 +210,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -205,6 +210,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->m_BusNetCode = LastBusNetCode; net_item->m_BusNetCode = LastBusNetCode;
LastBusNetCode++; LastBusNetCode++;
} }
SegmentToPointConnect( net_item, ISBUS, istart ); SegmentToPointConnect( net_item, ISBUS, istart );
break; break;
} }
...@@ -215,7 +221,6 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -215,7 +221,6 @@ void SCH_EDIT_FRAME::BuildNetListBase()
dumpNetTable(); dumpNetTable();
#endif #endif
activity << _( "done" ); activity << _( "done" );
SetStatusText( activity ); SetStatusText( activity );
...@@ -233,7 +238,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -233,7 +238,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
case NET_PIN: case NET_PIN:
case NET_SHEETLABEL: case NET_SHEETLABEL:
case NET_SEGMENT: case NET_SEGMENT:
case NET_JONCTION: case NET_JUNCTION:
case NET_BUS: case NET_BUS:
case NET_NOCONNECT: case NET_NOCONNECT:
break; break;
...@@ -267,6 +272,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -267,6 +272,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
/* Connection hierarchy. */ /* Connection hierarchy. */
activity << wxT( ", " ) << _( "hierarchy..." ); activity << wxT( ", " ) << _( "hierarchy..." );
SetStatusText( activity ); SetStatusText( activity );
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
{ {
if( g_NetObjectslist[ii]->m_Type == NET_SHEETLABEL if( g_NetObjectslist[ii]->m_Type == NET_SHEETLABEL
...@@ -287,6 +293,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -287,6 +293,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
/* Compress numbers of Netcode having consecutive values. */ /* Compress numbers of Netcode having consecutive values. */
LastNetCode = NetCode = 0; LastNetCode = NetCode = 0;
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
{ {
if( g_NetObjectslist[ii]->GetNet() != LastNetCode ) if( g_NetObjectslist[ii]->GetNet() != LastNetCode )
...@@ -294,6 +301,7 @@ void SCH_EDIT_FRAME::BuildNetListBase() ...@@ -294,6 +301,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
NetCode++; NetCode++;
LastNetCode = g_NetObjectslist[ii]->GetNet(); LastNetCode = g_NetObjectslist[ii]->GetNet();
} }
g_NetObjectslist[ii]->SetNet( NetCode ); g_NetObjectslist[ii]->SetNet( NetCode );
} }
...@@ -324,6 +332,7 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer ) ...@@ -324,6 +332,7 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
NETLIST_OBJECT_LIST candidates; NETLIST_OBJECT_LIST candidates;
int netcode = 0; // current netcode for tested items int netcode = 0; // current netcode for tested items
unsigned idxstart = 0; // index of the first item of this net unsigned idxstart = 0; // index of the first item of this net
for( unsigned ii = 0; ii <= aNetItemBuffer.size(); ii++ ) for( unsigned ii = 0; ii <= aNetItemBuffer.size(); ii++ )
{ {
NETLIST_OBJECT* item; NETLIST_OBJECT* item;
...@@ -332,20 +341,25 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer ) ...@@ -332,20 +341,25 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
netcode = -2; netcode = -2;
else else
item = aNetItemBuffer[ii]; item = aNetItemBuffer[ii];
if( netcode != item->GetNet() ) // End of net found if( netcode != item->GetNet() ) // End of net found
{ {
if( candidates.size() ) // One or more labels exists, find the best if( candidates.size() ) // One or more labels exists, find the best
{ {
NETLIST_OBJECT* bestlabel = FindBestNetName( candidates ); NETLIST_OBJECT* bestlabel = FindBestNetName( candidates );
for (unsigned jj = idxstart; jj < ii; jj++ ) for (unsigned jj = idxstart; jj < ii; jj++ )
aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel; aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel;
} }
if( netcode == -2 ) if( netcode == -2 )
break; break;
netcode = item->GetNet(); netcode = item->GetNet();
candidates.clear(); candidates.clear();
idxstart = ii; idxstart = ii;
} }
switch( item->m_Type ) switch( item->m_Type )
{ {
case NET_HIERLABEL: case NET_HIERLABEL:
...@@ -384,8 +398,12 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -384,8 +398,12 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
// and priority >= NET_PRIO_MAX-1 is for global connections // and priority >= NET_PRIO_MAX-1 is for global connections
// ( i.e. for labels that are not prefixed by a sheetpath) // ( i.e. for labels that are not prefixed by a sheetpath)
#define NET_PRIO_MAX 4 #define NET_PRIO_MAX 4
int priority_order[NET_PRIO_MAX+1] =
{ NET_ITEM_UNSPECIFIED, NET_LABEL, NET_HIERLABEL, NET_PINLABEL, NET_GLOBLABEL }; int priority_order[NET_PRIO_MAX+1] = {
NET_ITEM_UNSPECIFIED,
NET_LABEL, NET_HIERLABEL,
NET_PINLABEL,
NET_GLOBLABEL };
NETLIST_OBJECT*item = aLabelItemBuffer[0]; NETLIST_OBJECT*item = aLabelItemBuffer[0];
...@@ -403,8 +421,10 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -403,8 +421,10 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ ) for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
{ {
NETLIST_OBJECT* candidate = aLabelItemBuffer[ii]; NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
// Calculate candidate priority // Calculate candidate priority
int candidate_priority = 0; int candidate_priority = 0;
for( unsigned ii = 0; ii <= NET_PRIO_MAX; ii++ ) for( unsigned ii = 0; ii <= NET_PRIO_MAX; ii++ )
{ {
if ( candidate->m_Type == priority_order[ii] ) if ( candidate->m_Type == priority_order[ii] )
...@@ -511,6 +531,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -511,6 +531,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
SCH_SHEET_PATH list; SCH_SHEET_PATH list;
DrawList = sheetlist->LastScreen()->GetDrawItems(); DrawList = sheetlist->LastScreen()->GetDrawItems();
for( ; DrawList; DrawList = DrawList->Next() ) for( ; DrawList; DrawList = DrawList->Next() )
{ {
switch( DrawList->Type() ) switch( DrawList->Type() )
...@@ -518,8 +539,8 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -518,8 +539,8 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
case SCH_LINE_T: case SCH_LINE_T:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_LINE*) DrawList ) #define STRUCT ( (SCH_LINE*) DrawList )
if( (STRUCT->GetLayer() != LAYER_BUS)
&& (STRUCT->GetLayer() != LAYER_WIRE) ) if( (STRUCT->GetLayer() != LAYER_BUS) && (STRUCT->GetLayer() != LAYER_WIRE) )
break; break;
new_item = new NETLIST_OBJECT(); new_item = new NETLIST_OBJECT();
...@@ -537,6 +558,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -537,6 +558,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
{ {
new_item->m_Type = NET_SEGMENT; new_item->m_Type = NET_SEGMENT;
} }
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
break; break;
...@@ -548,7 +570,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -548,7 +570,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_SheetList = *sheetlist; new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist; new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = STRUCT; new_item->m_Comp = STRUCT;
new_item->m_Type = NET_JONCTION; new_item->m_Type = NET_JUNCTION;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos; new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
...@@ -581,6 +603,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -581,6 +603,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
if( STRUCT->GetLayer() == LAYER_GLOBLABEL ) if( STRUCT->GetLayer() == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL; new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->GetLayer() == LAYER_HIERLABEL ) if( STRUCT->GetLayer() == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL; new_item->m_Type = NET_HIERLABEL;
...@@ -588,6 +611,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -588,6 +611,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_Start = new_item->m_End = STRUCT->m_Pos; new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
/* If a bus connects to label */ /* If a bus connects to label */
if( ii ) if( ii )
ConvertBusToMembers( aNetItemBuffer, *new_item ); ConvertBusToMembers( aNetItemBuffer, *new_item );
...@@ -610,6 +634,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -610,6 +634,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
// (look at the case statement above). // (look at the case statement above).
if( STRUCT->GetLayer() == LAYER_GLOBLABEL ) if( STRUCT->GetLayer() == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL; new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->GetLayer() == LAYER_HIERLABEL ) if( STRUCT->GetLayer() == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL; new_item->m_Type = NET_HIERLABEL;
...@@ -628,6 +653,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -628,6 +653,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
DrawLibItem = (SCH_COMPONENT*) DrawList; DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->GetLibName() ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->GetLibName() );
if( Entry == NULL ) if( Entry == NULL )
break; break;
...@@ -717,8 +743,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -717,8 +743,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
default: default:
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "Netlist: unexpected struct type %d" ), msg.Printf( wxT( "Netlist: unexpected struct type %d" ), DrawList->Type() );
DrawList->Type() );
wxMessageBox( msg ); wxMessageBox( msg );
break; break;
} }
...@@ -739,6 +764,7 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer ) ...@@ -739,6 +764,7 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ ) for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
{ {
NETLIST_OBJECT* Label = aNetItemBuffer[ii]; NETLIST_OBJECT* Label = aNetItemBuffer[ii];
if( (Label->m_Type == NET_SHEETBUSLABELMEMBER) if( (Label->m_Type == NET_SHEETBUSLABELMEMBER)
|| (Label->m_Type == NET_BUSLABELMEMBER) || (Label->m_Type == NET_BUSLABELMEMBER)
|| (Label->m_Type == NET_HIERBUSLABELMEMBER) ) || (Label->m_Type == NET_HIERBUSLABELMEMBER) )
...@@ -765,8 +791,7 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer ) ...@@ -765,8 +791,7 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
if( LabelInTst->GetNet() == 0 ) if( LabelInTst->GetNet() == 0 )
LabelInTst->SetNet( Label->GetNet() ); LabelInTst->SetNet( Label->GetNet() );
else else
PropageNetCode( LabelInTst->GetNet(), PropageNetCode( LabelInTst->GetNet(), Label->GetNet(), 0 );
Label->GetNet(), 0 );
} }
} }
} }
...@@ -796,6 +821,7 @@ int IsBusLabel( const wxString& LabelDrawList ) ...@@ -796,6 +821,7 @@ int IsBusLabel( const wxString& LabelDrawList )
FirstNumWireBus = LastNumWireBus = 9; FirstNumWireBus = LastNumWireBus = 9;
RootBusNameLength = Num; RootBusNameLength = Num;
Num++; Num++;
while( LabelDrawList[Num] != '.' && Num < LabelDrawList.Len() ) while( LabelDrawList[Num] != '.' && Num < LabelDrawList.Len() )
{ {
BufLine.Append( LabelDrawList[Num] ); BufLine.Append( LabelDrawList[Num] );
...@@ -809,6 +835,7 @@ int IsBusLabel( const wxString& LabelDrawList ) ...@@ -809,6 +835,7 @@ int IsBusLabel( const wxString& LabelDrawList )
Num++; Num++;
BufLine.Empty(); BufLine.Empty();
while( LabelDrawList[Num] != ']' && Num < LabelDrawList.Len() ) while( LabelDrawList[Num] != ']' && Num < LabelDrawList.Len() )
{ {
BufLine.Append( LabelDrawList[Num] ); BufLine.Append( LabelDrawList[Num] );
...@@ -902,6 +929,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ) ...@@ -902,6 +929,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ ) for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
{ {
NETLIST_OBJECT* Objet = g_NetObjectslist[jj]; NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
if( Objet->GetNet() == OldNetCode ) if( Objet->GetNet() == OldNetCode )
{ {
Objet->SetNet( NewNetCode ); Objet->SetNet( NewNetCode );
...@@ -913,6 +941,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ) ...@@ -913,6 +941,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ ) for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
{ {
NETLIST_OBJECT* Objet = g_NetObjectslist[jj]; NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
if( Objet->m_BusNetCode == OldNetCode ) if( Objet->m_BusNetCode == OldNetCode )
{ {
Objet->m_BusNetCode = NewNetCode; Objet->m_BusNetCode = NewNetCode;
...@@ -948,9 +977,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) ...@@ -948,9 +977,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
if( IsBus == 0 ) /* Objects other than BUS and BUSLABELS. */ if( IsBus == 0 ) /* Objects other than BUS and BUSLABELS. */
{ {
netCode = Ref->GetNet(); netCode = Ref->GetNet();
for( unsigned i = start; i < g_NetObjectslist.size(); i++ ) for( unsigned i = start; i < g_NetObjectslist.size(); i++ )
{ {
NETLIST_OBJECT* item = g_NetObjectslist[i]; NETLIST_OBJECT* item = g_NetObjectslist[i];
if( item->m_SheetList != Ref->m_SheetList ) //used to be > (why?) if( item->m_SheetList != Ref->m_SheetList ) //used to be > (why?)
continue; continue;
...@@ -963,7 +994,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) ...@@ -963,7 +994,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
case NET_GLOBLABEL: case NET_GLOBLABEL:
case NET_SHEETLABEL: case NET_SHEETLABEL:
case NET_PINLABEL: case NET_PINLABEL:
case NET_JONCTION: case NET_JUNCTION:
case NET_NOCONNECT: case NET_NOCONNECT:
if( Ref->m_Start == item->m_Start if( Ref->m_Start == item->m_Start
|| Ref->m_Start == item->m_End || Ref->m_Start == item->m_End
...@@ -990,9 +1021,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) ...@@ -990,9 +1021,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
else /* Object type BUS, BUSLABELS, and junctions. */ else /* Object type BUS, BUSLABELS, and junctions. */
{ {
netCode = Ref->m_BusNetCode; netCode = Ref->m_BusNetCode;
for( unsigned i = start; i<g_NetObjectslist.size(); i++ ) for( unsigned i = start; i<g_NetObjectslist.size(); i++ )
{ {
NETLIST_OBJECT* item = g_NetObjectslist[i]; NETLIST_OBJECT* item = g_NetObjectslist[i];
if( item->m_SheetList != Ref->m_SheetList ) if( item->m_SheetList != Ref->m_SheetList )
continue; continue;
...@@ -1014,7 +1047,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) ...@@ -1014,7 +1047,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
case NET_SHEETBUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER: case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER: case NET_GLOBBUSLABELMEMBER:
case NET_JONCTION: case NET_JUNCTION:
if( Ref->m_Start == item->m_Start if( Ref->m_Start == item->m_Start
|| Ref->m_Start == item->m_End || Ref->m_Start == item->m_End
|| Ref->m_End == item->m_Start || Ref->m_End == item->m_Start
...@@ -1039,8 +1072,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) ...@@ -1039,8 +1072,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
* The list of objects is expected sorted by sheets. * The list of objects is expected sorted by sheets.
* Search is done from index aIdxStart to the last element of g_NetObjectslist * Search is done from index aIdxStart to the last element of g_NetObjectslist
*/ */
static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, int aIsBus, int aIdxStart )
int aIsBus, int aIdxStart )
{ {
for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ ) for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ )
{ {
...@@ -1067,16 +1099,14 @@ static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, ...@@ -1067,16 +1099,14 @@ static void SegmentToPointConnect( NETLIST_OBJECT* aJonction,
if( aIsBus == 0 ) if( aIsBus == 0 )
{ {
if( Segment->GetNet() ) if( Segment->GetNet() )
PropageNetCode( Segment->GetNet(), PropageNetCode( Segment->GetNet(), aJonction->GetNet(), aIsBus );
aJonction->GetNet(), aIsBus );
else else
Segment->SetNet( aJonction->GetNet() ); Segment->SetNet( aJonction->GetNet() );
} }
else else
{ {
if( Segment->m_BusNetCode ) if( Segment->m_BusNetCode )
PropageNetCode( Segment->m_BusNetCode, PropageNetCode( Segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
aJonction->m_BusNetCode, aIsBus );
else else
Segment->m_BusNetCode = aJonction->m_BusNetCode; Segment->m_BusNetCode = aJonction->m_BusNetCode;
} }
...@@ -1097,12 +1127,14 @@ void LabelConnect( NETLIST_OBJECT* LabelRef ) ...@@ -1097,12 +1127,14 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
{ {
if( g_NetObjectslist[i]->GetNet() == LabelRef->GetNet() ) if( g_NetObjectslist[i]->GetNet() == LabelRef->GetNet() )
continue; continue;
if( g_NetObjectslist[i]->m_SheetList != LabelRef->m_SheetList ) if( g_NetObjectslist[i]->m_SheetList != LabelRef->m_SheetList )
{ {
if( (g_NetObjectslist[i]->m_Type != NET_PINLABEL if( (g_NetObjectslist[i]->m_Type != NET_PINLABEL
&& g_NetObjectslist[i]->m_Type != NET_GLOBLABEL && g_NetObjectslist[i]->m_Type != NET_GLOBLABEL
&& g_NetObjectslist[i]->m_Type != NET_GLOBBUSLABELMEMBER) ) && g_NetObjectslist[i]->m_Type != NET_GLOBBUSLABELMEMBER) )
continue; continue;
if( (g_NetObjectslist[i]->m_Type == NET_GLOBLABEL if( (g_NetObjectslist[i]->m_Type == NET_GLOBLABEL
|| g_NetObjectslist[i]->m_Type == NET_GLOBBUSLABELMEMBER) || g_NetObjectslist[i]->m_Type == NET_GLOBBUSLABELMEMBER)
&& g_NetObjectslist[i]->m_Type != LabelRef->m_Type ) && g_NetObjectslist[i]->m_Type != LabelRef->m_Type )
...@@ -1116,6 +1148,7 @@ void LabelConnect( NETLIST_OBJECT* LabelRef ) ...@@ -1116,6 +1148,7 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
// NET_GLOBLABEL is global. // NET_GLOBLABEL is global.
// NET_PINLABEL is a kind of global label (generated by a power pin invisible) // NET_PINLABEL is a kind of global label (generated by a power pin invisible)
NetObjetType ntype = g_NetObjectslist[i]->m_Type; NetObjetType ntype = g_NetObjectslist[i]->m_Type;
if( ntype == NET_LABEL if( ntype == NET_LABEL
|| ntype == NET_GLOBLABEL || ntype == NET_GLOBLABEL
|| ntype == NET_HIERLABEL || ntype == NET_HIERLABEL
...@@ -1227,17 +1260,19 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer ) ...@@ -1227,17 +1260,19 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
case NET_SHEETBUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER: case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER: case NET_GLOBBUSLABELMEMBER:
case NET_JONCTION: case NET_JUNCTION:
break; break;
case NET_PIN: case NET_PIN:
if( NetItemRef->m_Type == NET_PIN ) if( NetItemRef->m_Type == NET_PIN )
StateFlag = PAD_CONNECT; StateFlag = PAD_CONNECT;
break; break;
case NET_NOCONNECT: case NET_NOCONNECT:
if( StateFlag != PAD_CONNECT ) if( StateFlag != PAD_CONNECT )
StateFlag = NOCONNECT_SYMBOL_PRESENT; StateFlag = NOCONNECT_SYMBOL_PRESENT;
break; break;
} }
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
......
/*******************/ /**
/* onleftclick.cpp */ * @file eeschema/onleftclick.cpp
/*******************/ */
#include "fctsys.h" #include "fctsys.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/********************/ /**
/* onrightclick.cpp */ * @file eeschema/onrightclick.cpp
/********************/ */
#include "fctsys.h" #include "fctsys.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/*************************************************** /**
* operations_on_item_lists.cpp * @file operations_on_items_lists.cpp
* functions used in block commands, or undo/redo, * @brief Functions used in block commands, or undo/redo, to move, mirror, delete, copy ...
* to move, mirror, delete, copy ... lists of schematic items * lists of schematic items.
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/*******************************************************/ /**
/* sch_component.cpp : handle the class SCH_COMPONENT */ * @file sch_component.cpp
/*******************************************************/ * @brief Implementation of the class SCH_COMPONENT.
*/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -20,7 +21,6 @@ ...@@ -20,7 +21,6 @@
#include "sch_component.h" #include "sch_component.h"
#include "sch_sheet.h" #include "sch_sheet.h"
#include "sch_sheet_path.h" #include "sch_sheet_path.h"
#include "template_fieldnames.h"
#include "dialogs/dialog_schematic_find.h" #include "dialogs/dialog_schematic_find.h"
...@@ -274,7 +274,7 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ...@@ -274,7 +274,7 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset
if( Entry == NULL ) if( Entry == NULL )
{ {
/* Create a dummy component if the actual component can not be found. */ /* Create a dummy component if the actual component can not be found. */
dummy = TRUE; dummy = true;
if( DummyCmp == NULL ) if( DummyCmp == NULL )
CreateDummyCmp(); CreateDummyCmp();
...@@ -779,7 +779,7 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) ...@@ -779,7 +779,7 @@ void SCH_COMPONENT::SetOrientation( int aOrientation )
temp.x1 = 1; temp.x1 = 1;
temp.y2 = -1; temp.y2 = -1;
temp.y1 = temp.x2 = 0; temp.y1 = temp.x2 = 0;
transform = TRUE; transform = true;
break; break;
case CMP_ORIENT_90: case CMP_ORIENT_90:
...@@ -1082,7 +1082,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -1082,7 +1082,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
newfmt = 1; newfmt = 1;
if( !aLine.ReadLine() ) if( !aLine.ReadLine() )
return TRUE; return true;
line = aLine.Line(); line = aLine.Line();
} }
......
/***********************************************/ /**
/* sch_field.cpp : handle the class SCH_FIELD */ * @file sch_field.cpp
/***********************************************/ * @brief Implementation of the SCH_FIELD class.
*/
/* Fields are texts attached to a component, having a special meaning /* Fields are texts attached to a component, having a special meaning
* Fields 0 and 1 are very important: reference and value * Fields 0 and 1 are very important: reference and value
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
#include "drawtxt.h" #include "drawtxt.h"
#include "macros.h" #include "macros.h"
#include "trigo.h" #include "trigo.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h" #include "plot_common.h"
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#include "class_library.h" #include "class_library.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_field.h" #include "sch_field.h"
#include "template_fieldnames.h"
#include "kicad_string.h" #include "kicad_string.h"
SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) : SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
SCH_ITEM( aParent, SCH_FIELD_T ), SCH_ITEM( aParent, SCH_FIELD_T ),
EDA_TEXT() EDA_TEXT()
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
class SCH_LINE : public SCH_ITEM class SCH_LINE : public SCH_ITEM
{ {
bool m_StartIsDangling; bool m_StartIsDangling;
bool m_EndIsDangling; // TRUE if not connected (wires, tracks...) bool m_EndIsDangling; // true if not connected (wires, tracks...)
public: public:
int m_Width; // 0 = line, > 0 = tracks, bus ... int m_Width; // 0 = line, > 0 = tracks, bus ...
......
/*
* 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) 2010 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 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
* 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
*/
/**
* @file sch_screen.cpp
* @brief Implementation of SCH_SCREEN and SCH_SCREENS classes.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -6,7 +35,6 @@ ...@@ -6,7 +35,6 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "sch_item_struct.h" #include "sch_item_struct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h" #include "plot_common.h"
...@@ -21,7 +49,6 @@ ...@@ -21,7 +49,6 @@
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_sheet.h" #include "sch_sheet.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_collectors.h"
#include "sch_text.h" #include "sch_text.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -1480,3 +1507,33 @@ void SCH_SCREENS::DeleteAllMarkers( int aMarkerType ) ...@@ -1480,3 +1507,33 @@ void SCH_SCREENS::DeleteAllMarkers( int aMarkerType )
} }
} }
} }
int SCH_SCREENS::GetMarkerCount( int aMarkerType )
{
SCH_ITEM* item;
SCH_ITEM* nextItem;
SCH_MARKER* marker;
SCH_SCREEN* screen;
int count = 0;
for( screen = GetFirst(); screen != NULL; screen = GetNext() )
{
for( item = screen->GetDrawItems(); item != NULL; item = nextItem )
{
nextItem = item->Next();
if( item->Type() != SCH_MARKER_T )
continue;
marker = (SCH_MARKER*) item;
if( (aMarkerType != -1) && (marker->GetMarkerType() != aMarkerType) )
continue;
count++;
}
}
return count;
}
///////////////////////////////////////////////////////////////////////////// /*
// Name: sch_sheet.cpp * This program source code file is part of KiCad, a free EDA CAD application.
// Purpose: member functions for SCH_SHEET *
// header = sch_sheet.h * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
// Author: jean-pierre Charras * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
// Modified by: Wayne Stambaugh * Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
// Created: 08/02/2006 18:37:02 *
// RCS-ID: * This program is free software; you can redistribute it and/or
// Copyright: * modify it under the terms of the GNU General Public License
// License: License GNU * 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
*/
/**
* @file sch_sheet.cpp
* @brief Implementation of SCH_SHEET class.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -17,7 +35,6 @@ ...@@ -17,7 +35,6 @@
#include "drawtxt.h" #include "drawtxt.h"
#include "trigo.h" #include "trigo.h"
#include "richio.h" #include "richio.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "plot_common.h" #include "plot_common.h"
......
///////////////////////////////////////////////////////////////////////////// /*
// Name: sch_sheet_pin.cpp * This program source code file is part of KiCad, a free EDA CAD application.
// Purpose: member functions SCH_SHEET_PIN *
// header = sch_sheet.h * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
// Author: jean-pierre Charras * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
// Modified by: * Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
// Created: 08/02/2006 18:37:02 *
// RCS-ID: * This program is free software; you can redistribute it and/or
// Copyright: License GNU * modify it under the terms of the GNU General Public License
// 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
*/
/**
* @file sch_sheet_pin.cpp
* @brief Implementation of the SCH_SHEET_PIN class.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -17,7 +35,6 @@ ...@@ -17,7 +35,6 @@
#include "plot_common.h" #include "plot_common.h"
#include "trigo.h" #include "trigo.h"
#include "richio.h" #include "richio.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -48,7 +65,7 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr ...@@ -48,7 +65,7 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
else else
SetEdge( 0 ); SetEdge( 0 );
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = true;
m_Number = 2; m_Number = 2;
} }
......
/*********************************************/ /**
/* Code for handling schematic sheet labels. */ * @file sch_text.cpp
/*********************************************/ * @brief Code for handling schematic sheet labels.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -729,7 +730,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : ...@@ -729,7 +730,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
{ {
m_Layer = LAYER_LOCLABEL; m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = true;
m_MultilineAllowed = false; m_MultilineAllowed = false;
} }
...@@ -937,7 +938,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : ...@@ -937,7 +938,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
{ {
m_Layer = LAYER_GLOBLABEL; m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI; m_Shape = NET_BIDI;
m_IsDangling = TRUE; m_IsDangling = true;
m_MultilineAllowed = false; m_MultilineAllowed = false;
} }
...@@ -1369,7 +1370,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T ...@@ -1369,7 +1370,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T
{ {
m_Layer = LAYER_HIERLABEL; m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = true;
m_MultilineAllowed = false; m_MultilineAllowed = false;
} }
......
/*****************/ /**
/* schedit.cpp */ * @file schedit.cpp
/*****************/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "confirm.h" #include "confirm.h"
#include "eda_doc.h" #include "eda_doc.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
#include "general.h" #include "general.h"
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/******************/ /**
/* schframe.cpp */ * @file schframe.cpp
/******************/ */
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "lib_pin.h" #include "lib_pin.h"
#include "class_library.h" #include "class_library.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "sch_component.h" #include "sch_component.h"
#include "dialog_helpers.h" #include "dialog_helpers.h"
...@@ -157,8 +156,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, ...@@ -157,8 +156,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
EDA_DRAW_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style ) EDA_DRAW_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style )
{ {
m_FrameName = wxT( "SchematicFrame" ); m_FrameName = wxT( "SchematicFrame" );
m_Draw_Axis = FALSE; // TRUE to show axis m_Draw_Axis = FALSE; // true to show axis
m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references m_Draw_Sheet_Ref = true; // true to show sheet references
m_CurrentSheet = new SCH_SHEET_PATH(); m_CurrentSheet = new SCH_SHEET_PATH();
m_Multiflag = 0; m_Multiflag = 0;
m_TextFieldSize = DEFAULT_SIZE_TEXT; m_TextFieldSize = DEFAULT_SIZE_TEXT;
...@@ -196,7 +195,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, ...@@ -196,7 +195,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE; DrawPanel->m_Block_Enable = true;
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -597,7 +596,7 @@ void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& event ) ...@@ -597,7 +596,7 @@ void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& event )
wxASSERT_MSG( m_findReplaceData != NULL, wxASSERT_MSG( m_findReplaceData != NULL,
wxT( "Forgot to create find/replace data. Bad Programmer!" ) ); wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
this->DrawPanel->m_IgnoreMouseEvents = TRUE; this->DrawPanel->m_IgnoreMouseEvents = true;
if( m_dlgFindReplace ) if( m_dlgFindReplace )
{ {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h" #include "general.h"
#include "sch_sheet.h" #include "sch_sheet.h"
......
/**********************************************************/ /**
/* sheetlab.cpp create and edit the SCH_SHEET_PIN items */ * @file sheetlab.cpp
/**********************************************************/ * @brief Create and edit the SCH_SHEET_PIN items.
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "macros.h" #include "macros.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
......
/*************************************************/ /**
/* Functions to Load from file and save to file */ * @file symbedit.cpp
/* the graphic shapes used to draw a component */ * @brief Functions to load from and save to file component libraries and symbols.
/* When using the import/export symbol options */ */
/* files are the *.sym files */
/*************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -23,14 +21,7 @@ ...@@ -23,14 +21,7 @@
#include <wx/ffile.h> #include <wx/ffile.h>
/* void LIB_EDIT_FRAME::LoadOneSymbol()
* Read a component shape file (symbol file *.sym ) and add data (graphic
* items) to the current component.
*
* A symbol file *.sym has the same format as a library, and contains only
* one symbol
*/
void LIB_EDIT_FRAME::LoadOneSymbol( void )
{ {
LIB_COMPONENT* Component; LIB_COMPONENT* Component;
wxString msg, err; wxString msg, err;
...@@ -40,7 +31,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void ) ...@@ -40,7 +31,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void )
if( m_component == NULL || ( m_drawItem && m_drawItem->m_Flags ) ) if( m_component == NULL || ( m_drawItem && m_drawItem->m_Flags ) )
return; return;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = true;
wxString default_path = wxGetApp().ReturnLastVisitedLibraryPath(); wxString default_path = wxGetApp().ReturnLastVisitedLibraryPath();
...@@ -113,14 +104,6 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void ) ...@@ -113,14 +104,6 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void )
} }
/*
* Save the current symbol to a file.
*
* The symbol file format is like the standard libraries, but there is only
* one symbol.
*
* Invisible pins are not saved
*/
void LIB_EDIT_FRAME::SaveOneSymbol() void LIB_EDIT_FRAME::SaveOneSymbol()
{ {
wxString msg; wxString msg;
...@@ -218,12 +201,7 @@ void LIB_EDIT_FRAME::SaveOneSymbol() ...@@ -218,12 +201,7 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
} }
/* void LIB_EDIT_FRAME::PlaceAnchor()
* Place anchor reference coordinators for current component
*
* All coordinates of the object are offset to the cursor position.
*/
void LIB_EDIT_FRAME::PlaceAncre()
{ {
if( m_component == NULL ) if( m_component == NULL )
return; return;
......
/******************/ /**
/* tool_sch.cpp */ * @file tool_sch.cpp
/******************/ */
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -21,7 +21,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar() ...@@ -21,7 +21,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
return; return;
wxString msg; wxString msg;
m_HToolBar = new EDA_TOOLBAR( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new EDA_TOOLBAR( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, KiBitmap( new_xpm ), m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, KiBitmap( new_xpm ),
......
/***********************/ /**
/* viewlib_frame.cpp */ * @file viewlib_frame.cpp
/***********************/ */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
...@@ -134,7 +133,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph ...@@ -134,7 +133,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
wxT( "LibWindow" ) ); wxT( "LibWindow" ) );
m_LibListWindow->SetOrientation( wxLAYOUT_VERTICAL ); m_LibListWindow->SetOrientation( wxLAYOUT_VERTICAL );
m_LibListWindow->SetAlignment( wxLAYOUT_LEFT ); m_LibListWindow->SetAlignment( wxLAYOUT_LEFT );
m_LibListWindow->SetSashVisible( wxSASH_RIGHT, TRUE ); m_LibListWindow->SetSashVisible( wxSASH_RIGHT, true );
m_LibListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); m_LibListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_LibList = new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST, m_LibList = new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST,
wxPoint( 0, 0 ), wxDefaultSize, wxPoint( 0, 0 ), wxDefaultSize,
...@@ -158,7 +157,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph ...@@ -158,7 +157,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
wxT( "CmpWindow" ) ); wxT( "CmpWindow" ) );
m_CmpListWindow->SetOrientation( wxLAYOUT_VERTICAL ); m_CmpListWindow->SetOrientation( wxLAYOUT_VERTICAL );
m_CmpListWindow->SetSashVisible( wxSASH_RIGHT, TRUE ); m_CmpListWindow->SetSashVisible( wxSASH_RIGHT, true );
m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE ); m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST, m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST,
wxPoint( 0, 0 ), wxDefaultSize, wxPoint( 0, 0 ), wxDefaultSize,
...@@ -489,7 +488,7 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event ) ...@@ -489,7 +488,7 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
else else
m_exportToEeschemaCmpName.Empty(); m_exportToEeschemaCmpName.Empty();
Close( TRUE ); Close( true );
} }
......
...@@ -56,7 +56,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -56,7 +56,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT: case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, TRUE ); m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, true );
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, FALSE ); m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, FALSE );
m_convert = 1; m_convert = 1;
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -64,7 +64,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -64,7 +64,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT: case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, FALSE ); m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, FALSE );
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, TRUE ); m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, true );
m_convert = 2; m_convert = 2;
DrawPanel->Refresh(); DrawPanel->Refresh();
break; break;
......
...@@ -434,9 +434,10 @@ public: ...@@ -434,9 +434,10 @@ public:
}; };
/********************************************************/ /**
/* Class to handle the list of *screens* in a hierarchy */ * Class SCH_SCREENS
/********************************************************/ * is a class to handle the list of *screens* in a hierarchy.
*/
// screens are unique, and correspond to .sch files. // screens are unique, and correspond to .sch files.
class SCH_SCREENS class SCH_SCREENS
...@@ -490,6 +491,16 @@ public: ...@@ -490,6 +491,16 @@ public:
*/ */
void DeleteAllMarkers( int aMarkerType ); void DeleteAllMarkers( int aMarkerType );
/**
* Function GetMarkerCount
* returns the number of ERC markers of \a aMarkerType from all of the screens in the list.
*
* @param aMarkerType Indicates the type of marker to count. A value less then zero
* indicates all markers are counted.
* @return int count of the markers found.
*/
int GetMarkerCount( int aMarkerType = -1 );
private: private:
void AddScreenToList( SCH_SCREEN* aScreen ); void AddScreenToList( SCH_SCREEN* aScreen );
void BuildScreenList( EDA_ITEM* aItem ); void BuildScreenList( EDA_ITEM* aItem );
......
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