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)
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()
# 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 <vector>
......@@ -8,8 +9,6 @@
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "wxstruct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "netlist.h"
......
/****************************************************/
/* BLOCK.CPP */
/****************************************************/
/**
* @file eeschema/block.cpp
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -8,7 +8,6 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h"
#include "class_library.h"
......
/****************************************************/
/* block_libedit.cpp */
/****************************************************/
/**
* @file block_libedit.cpp
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "block_commande.h"
#include "general.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 "gr_basic.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "lib_draw_item.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 "gr_basic.h"
#include "class_drawpanel.h"
#include "eeschema_id.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/**********************************************************/
/* libclass.cpp */
/**********************************************************/
/**
* @file class_library.cpp
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -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 )
{
if( aComponent == NULL )
......@@ -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* aNewComponent )
{
......@@ -569,10 +550,12 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum )
{
text = strtok( Line, " \t\r\n" );
data = strtok( NULL, " \t\r\n" );
if( stricmp( text, "TimeStamp" ) == 0 )
timeStamp = atol( data );
if( stricmp( text, "$ENDHEADER" ) == 0 )
return TRUE;
return true;
}
return FALSE;
......
/*********************************************/
/* Headers for component library definition */
/*********************************************/
/**
* @file class_library.h
* @brief Definition for component library class.
*/
#ifndef 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 "macros.h"
......@@ -9,9 +9,9 @@
#include "general.h"
#include "sch_component.h"
#include "class_netlist_object.h"
#if defined(DEBUG)
#include <iostream>
const char* ShowType( NetObjetType aType )
{
......@@ -25,7 +25,7 @@ const char* ShowType( NetObjetType aType )
case NET_BUS:
ret = "bus"; break;
case NET_JONCTION:
case NET_JUNCTION:
ret = "junction"; break;
case NET_LABEL:
......@@ -89,10 +89,12 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
switch( m_Type )
{
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 )
m_Comp->Show( 1, out );
break;
default:
......@@ -110,7 +112,6 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
out << "</netItem>\n";
}
#endif
......@@ -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 */
/* calculations) */
/***********************************************************************/
/**
* @file class_netlist_object.h
* @brief Definition of the NETLIST_OBJECT class.
*/
#ifndef _CLASS_NETLIST_OBJECT_H_
#define _CLASS_NETLIST_OBJECT_H_
#include "sch_sheet_path.h"
#include "lib_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum )
......@@ -16,7 +17,7 @@ enum NetObjetType {
NET_ITEM_UNSPECIFIED, // only for not yet initialized instances
NET_SEGMENT, // connection by wire
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
NET_LABEL, // this is a local label
NET_GLOBLABEL, // this is a global label that connect all
......@@ -60,7 +61,7 @@ class NETLIST_OBJECT
public:
NetObjetType m_Type; /* Type of item (see NetObjetType
* 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)
*/
SCH_ITEM* m_Link; /* For SCH_SHEET_PIN:
......@@ -101,8 +102,8 @@ public:
#if defined(DEBUG)
void Show( std::ostream& out, int ndx );
#endif
NETLIST_OBJECT();
NETLIST_OBJECT( NETLIST_OBJECT& aSource ); // Copy constructor
......@@ -114,15 +115,27 @@ public:
/**
* Function GetPinNum
* 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()
{
// hide the ugliness in here, but do it inline.
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
typedef std::vector <NETLIST_OBJECT*> NETLIST_OBJECT_LIST;
......
/*
* component_references_lister.cpp: creates a flat list of components.
* Needed for annotation and BOM.
* @file component_references_lister.cpp
* @brief Code for creating a flat list of components needed for annotation and BOM.
*/
/*
......@@ -36,7 +36,6 @@
#include "kicad_string.h"
#include "wxEeschemaStruct.h"
#include "netlist.h"
#include "class_sch_screen.h"
#include "sch_component.h"
......
/*********************/
/* dangling_ends.cpp */
/*********************/
/**
* @file dangling_ends.cpp
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "sch_item_struct.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h"
#include "protos.h"
......
......@@ -25,7 +25,7 @@
* BufName mask (with * and?)
*
* Returns
* TRUE if the selected component
* true if the selected component
* FALSE canceled order
* Place the name of the component has loaded, select from a list in
* 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
* modify it under the terms of the GNU General Public License
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_erc.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 02/07/2000
// License: GPL
/////////////////////////////////////////////////////////////////////////////
/*
* 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 dialog_erc.cpp
* @brief Electrical Rules Check dialog implementation.
*/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "kicad_string.h"
......@@ -31,10 +52,12 @@ bool DIALOG_ERC::m_writeErcFile = false;
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
DIALOG_ERC::ChangeErrorLevel )
END_EVENT_TABLE() DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
END_EVENT_TABLE()
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC_BASE( parent )
{
m_Parent = parent;
......@@ -49,7 +72,7 @@ void DIALOG_ERC::Init()
{
SetFocus();
m_Initialized = FALSE;
m_Initialized = false;
for( int ii = 0; ii < PIN_NMAX; ii++ )
for( int jj = 0; jj < PIN_NMAX; jj++ )
......@@ -57,14 +80,18 @@ void DIALOG_ERC::Init()
m_WriteResultOpt->SetValue( m_writeErcFile );
SCH_SCREENS screens;
int markers = screens.GetMarkerCount();
int warnings = screens.GetMarkerCount( WAR );
wxString num;
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc );
num.Printf( wxT( "%d" ), markers );
m_TotalErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc );
num.Printf( wxT( "%d" ), markers - warnings );
m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
num.Printf( wxT( "%d" ), warnings );
m_LastWarningCount->SetLabel( num );
DisplayERC_MarkersList();
......@@ -78,10 +105,10 @@ void DIALOG_ERC::Init()
/* 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
*/
void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{
SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
......@@ -113,6 +140,7 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
wxSafeYield(); // m_MarkersList must be redraw
wxArrayString messageList;
TestErc( &messageList );
for( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
m_MessagesList->AppendText( messageList[ii] );
}
......@@ -139,20 +167,21 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
SCH_SHEET_LIST SheetList;
NotFound = TRUE;
NotFound = true;
/* Search for the selected marker */
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
{
SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList();
while( item && NotFound )
{
if( item == marker )
{
NotFound = FALSE;
NotFound = false;
break;
}
item = item->Next();
}
......@@ -190,14 +219,14 @@ void DIALOG_ERC::ReBuildMatrixPanel()
// Try to know the size of bitmap button used in drc matrix
wxBitmapButton * dummy = new wxBitmapButton( m_PanelERCOptions, wxID_ANY,
KiBitmap( ercerr_xpm ) );
KiBitmap( ercerr_xpm ) );
wxSize bitmap_size = dummy->GetSize();
delete dummy;
if( !DiagErcTableInit )
{
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
DiagErcTableInit = TRUE;
DiagErcTableInit = true;
}
// Get the current text size: this is a dummy text.
......@@ -222,14 +251,14 @@ void DIALOG_ERC::ReBuildMatrixPanel()
pos.y += text_height;
if( m_Initialized == FALSE )
if( m_Initialized == false )
{
// Print row labels
for( ii = 0; ii < PIN_NMAX; ii++ )
{
int y = pos.y + (ii * bitmap_size.y);
text = new wxStaticText( m_PanelERCOptions, -1, CommentERC_H[ii],
wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) );
wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) );
int x = text->GetRect().GetRight();
pos.x = MAX( pos.x, x );
......@@ -238,16 +267,20 @@ void DIALOG_ERC::ReBuildMatrixPanel()
pos.x += 5;
}
else
{
pos = m_ButtonList[0][0]->GetPosition();
}
for( ii = 0; ii < PIN_NMAX; ii++ )
{
int y = pos.y + (ii * bitmap_size.y);
for( jj = 0; jj <= ii; jj++ )
{
// Add column labels (only once)
int diag = DiagErc[ii][jj];
int x = pos.x + (jj * bitmap_size.x);
if( (ii == jj) && !m_Initialized )
{
wxPoint txtpos;
......@@ -258,9 +291,9 @@ void DIALOG_ERC::ReBuildMatrixPanel()
CommentERC_V[ii],
txtpos );
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x,
text->GetRect().GetRight() );
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, text->GetRect().GetRight() );
}
event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );
delete m_ButtonList[ii][jj];
......@@ -269,25 +302,25 @@ void DIALOG_ERC::ReBuildMatrixPanel()
{
case OK:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id,
KiBitmap( erc_green_xpm ),
wxPoint( x, y ) );
event_id,
KiBitmap( erc_green_xpm ),
wxPoint( x, y ) );
break;
case WAR:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id,
KiBitmap( ercwarn_xpm ),
wxPoint( x, y ) );
event_id,
KiBitmap( ercwarn_xpm ),
wxPoint( x, y ) );
break;
case ERR:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id,
KiBitmap( ercerr_xpm ),
wxPoint( x, y ) );
event_id,
KiBitmap( ercerr_xpm ),
wxPoint( x, y ) );
break;
}
......@@ -301,7 +334,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
BoxMatrixMinSize.y += BoxMatrixPosition.y;
m_PanelMatrixSizer->SetMinSize( BoxMatrixMinSize );
}
m_Initialized = TRUE;
m_Initialized = true;
}
......@@ -315,17 +349,17 @@ void DIALOG_ERC::DisplayERC_MarkersList()
m_MarkersList->ClearList();
for( SCH_SHEET_PATH* Sheet = SheetList.GetFirst();
Sheet != NULL;
Sheet = SheetList.GetNext() )
for( SCH_SHEET_PATH* Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() )
{
SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != SCH_MARKER_T )
continue;
SCH_MARKER* Marker = (SCH_MARKER*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC )
continue;
......@@ -397,16 +431,16 @@ void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
{
wxFileName fn;
unsigned NetItemRef;
unsigned OldItem;
unsigned StartNet;
unsigned net;
unsigned lastNet;
unsigned nextNet;
int NetNbItems, MinConn;
if( !DiagErcTableInit )
{
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
DiagErcTableInit = TRUE;
DiagErcTableInit = true;
}
m_writeErcFile = m_WriteResultOpt->GetValue();
......@@ -423,70 +457,61 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
msg += wxT( "\n" );
aMessagesList->Add( msg );
}
return;
}
/* Erase all DRC markers */
SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
SCH_SCREENS screens;
g_EESchemaVar.NbErrorErc = 0;
g_EESchemaVar.NbWarningErc = 0;
// Erase all previous DRC markers.
screens.DeleteAllMarkers( MARK_ERC );
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL;
Screen = ScreenList.GetNext() )
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
{
bool ModifyWires;
ModifyWires = Screen->SchematicCleanUp( NULL );
/* if wire list has changed, delete Undo Redo list to avoid
* pointers on deleted data problems */
if( ModifyWires )
Screen->ClearUndoRedoList();
/* Ff wire list has changed, delete Undo Redo list to avoid pointers on deleted
* data problems.
*/
if( screen->SchematicCleanUp( NULL ) )
screen->ClearUndoRedoList();
}
/* Test duplicate sheet names
* inside a given sheet, one cannot have sheets with duplicate names (file
* names can be duplicated).
/* Test duplicate sheet names inside a given sheet, one cannot have sheets with
* duplicate names (file names can be duplicated).
*/
int errcnt = TestDuplicateSheetNames( true );
g_EESchemaVar.NbErrorErc += errcnt;
TestDuplicateSheetNames( true );
m_Parent->BuildNetListBase();
/* Reset the flag m_FlagOfConnection, that will be used next, in
* calculations */
/* Reset the flag m_FlagOfConnection, that will be used next, in calculations */
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
StartNet = OldItem = 0;
nextNet = lastNet = 0;
NetNbItems = 0;
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;
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_SEGMENT:
case NET_BUS:
case NET_JONCTION:
case NET_JUNCTION:
case NET_LABEL:
case NET_BUSLABELMEMBER:
case NET_PINLABEL:
case NET_GLOBLABEL:
case NET_GLOBBUSLABELMEMBER:
// These items do not create erc problems
break;
case NET_HIERLABEL:
......@@ -497,37 +522,41 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierarchical label
// Each hierarchical label must match a pin sheet
TestLabel( m_Parent->DrawPanel, NetItemRef, StartNet );
TestLabel( net, nextNet );
break;
case NET_NOCONNECT:
// ERC problems when a noconnect symbol is connected to more than
// one pin.
// ERC problems when a noconnect symbol is connected to more than one pin.
MinConn = NET_NC;
if( NetNbItems != 0 )
Diagnose( m_Parent->DrawPanel, g_NetObjectslist[NetItemRef], NULL, MinConn, UNC );
Diagnose( g_NetObjectslist[net], NULL, MinConn, UNC );
break;
case NET_PIN:
// Look for ERC problems between pins:
TestOthersItems( m_Parent->DrawPanel, NetItemRef, StartNet, &NetNbItems, &MinConn );
TestOthersItems( net, nextNet, &NetNbItems, &MinConn );
break;
}
OldItem = NetItemRef;
lastNet = net;
}
// Displays global results:
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 );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc );
num.Printf( wxT( "%d" ), markers - warnings );
m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
num.Printf( wxT( "%d" ), warnings );
m_LastWarningCount->SetLabel( num );
// Display diags:
......@@ -550,7 +579,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
if( WriteDiagnosticERC( dlg.GetPath() ) )
{
Close( TRUE );
Close( true );
ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) );
}
}
......
/********************************/
/* Schematic component edition */
/********************************/
/**
* @file edit_component_in_schematic.cpp
* @brief Schematic component editing code.
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.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 "gr_basic.h"
......@@ -8,7 +9,6 @@
#include "drawtxt.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "kicad_device_context.h"
......
/*****************************************************************************
* Program to draw EE diagrams. *
* This module redraw/draw all structs. *
*****************************************************************************/
/**
* @file eeredraw.cpp
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "class_drawpanel.h"
#include "appl_wxstruct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
......@@ -9,7 +9,6 @@
#include "gestfich.h"
#include "eda_dde.h"
#include "id.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -22,7 +21,7 @@
// 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) */
wxSize g_RepeatStep;
int g_RepeatDeltaLabel;
......@@ -30,8 +29,6 @@ int g_RepeatDeltaLabel;
bool g_HVLines = true; // Bool: force H or V
// directions (Wires, Bus ..)
struct EESchemaVariables g_EESchemaVar;
int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT;
HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
......
/*****************/
/** eeconfig.h **/
/*****************/
/**
* @file eeschema_config.h
*/
#include "param_config.h"
......@@ -11,6 +11,6 @@
extern int g_PenMinWidth;
/* 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
* 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 "class_drawpanel.h"
#include "kicad_string.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -60,34 +85,34 @@
// Messages for matrix rows:
const wxChar* CommentERC_H[] =
{
wxT( "Input Pin...." ),
wxT( "Output Pin..." ),
wxT( "BiDi Pin....." ),
wxT( "3 State Pin.." ),
wxT( "Passive Pin.." ),
wxT( "Unspec Pin..." ),
wxT( "Power IN Pin." ),
wxT( "PowerOUT Pin." ),
wxT( "Open Coll...." ),
wxT( "Open Emit...." ),
wxT( "No Conn......" ),
_( "Input Pin.........." ),
_( "Output Pin........." ),
_( "Bidirectional Pin.." ),
_( "Tri-State Pin......" ),
_( "Passive Pin........" ),
_( "Unspecified Pin...." ),
_( "Power Input Pin...." ),
_( "Power Output Pin..." ),
_( "Open Collector....." ),
_( "Open Emitter......." ),
_( "No Connection......" ),
NULL
};
// Messages for matrix columns
const wxChar* CommentERC_V[] =
{
wxT( "Input Pin" ),
wxT( "Output Pin" ),
wxT( "BiDi Pin" ),
wxT( "3 State Pin" ),
wxT( "Passive Pin" ),
wxT( "Unspec Pin" ),
wxT( "Power IN Pin" ),
wxT( "PowerOUT Pin" ),
wxT( "Open Coll" ),
wxT( "Open Emit" ),
wxT( "No Conn" ),
_( "Input Pin" ),
_( "Output Pin" ),
_( "Bidirectional Pin" ),
_( "Tri-State Pin" ),
_( "Passive Pin" ),
_( "Unspecified Pin" ),
_( "Power Input Pin" ),
_( "Power Output Pin" ),
_( "Open Collector" ),
_( "Open Emitter" ),
_( "No Connection" ),
NULL
};
......@@ -97,10 +122,11 @@ const wxChar* CommentERC_V[] =
* at start up: must be loaded by DefaultDiagErc
*/
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
* note also, to avoid inconsistancy:
* DefaultDiagErc[i][j] = DefaultDiagErc[j][i]
......@@ -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
* Initial state of a net is NOC (Net with No Connection)
* Can be updated to NPI (Pin Isolated), NET_NC (Net with a no connect symbol),
* NOD (Not Driven) or DRV (DRIven)
*
* 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 NOD have no source signal
/**
* Look up table which gives the minimal drive for a pair of connected pins on
* a net.
* <p>
* 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
* (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
* NOD have no valid source signal.
*/
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 )
{
SCH_SCREEN* screen;
SCH_ITEM* item;
SCH_ITEM* test_item;
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();
Screen != NULL;
Screen = ScreenList.GetNext() )
for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
{
for( SCH_ITEM* ref_item = Screen->GetDrawItems();
ref_item != NULL;
ref_item = ref_item->Next() )
for( item = screen->GetDrawItems(); item != NULL; item = item->Next() )
{
// search for a sheet;
if( ref_item->Type() != SCH_SHEET_T )
if( item->Type() != SCH_SHEET_T )
continue;
for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL;
item_to_test = item_to_test->Next() )
for( test_item = item->Next(); test_item != NULL; test_item = test_item->Next() )
{
if( item_to_test->Type() != SCH_SHEET_T )
if( test_item->Type() != SCH_SHEET_T )
continue;
// We have found a second sheet: compare names
if( ( (SCH_SHEET*) ref_item )->m_SheetName.CmpNoCase(
( ( SCH_SHEET* ) item_to_test )-> m_SheetName )
== 0 )
if( ( (SCH_SHEET*) item )->m_SheetName.CmpNoCase(
( ( SCH_SHEET* ) test_item )-> m_SheetName ) == 0 )
{
if( aCreateMarker )
{
/* Create a new marker type ERC error*/
SCH_MARKER* Marker = new SCH_MARKER();
Marker->m_TimeStamp = GetTimeStamp();
Marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
( (SCH_SHEET*) item_to_test )->m_Pos,
_( "Duplicate Sheet name" ),
( (SCH_SHEET*) item_to_test )->m_Pos );
Marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( ERR );
Marker->SetNext( Screen->GetDrawItems() );
Screen->SetDrawItems( Marker );
SCH_MARKER* marker = new SCH_MARKER();
marker->m_TimeStamp = GetTimeStamp();
marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
( (SCH_SHEET*) test_item )->m_Pos,
_( "Duplicate sheet name" ),
( (SCH_SHEET*) test_item )->m_Pos );
marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( ERR );
marker->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( marker );
}
err_count++;
......@@ -211,16 +225,10 @@ int TestDuplicateSheetNames( bool aCreateMarker )
}
/* Creates an ERC marker to show the ERC problem about aNetItemRef
* 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,
void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
int aMinConn, int aDiag )
{
SCH_MARKER* Marker = NULL;
SCH_MARKER* marker = NULL;
SCH_SCREEN* screen;
int ii, jj;
......@@ -228,16 +236,14 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
return;
/* Create new marker for ERC error. */
Marker = new SCH_MARKER();
Marker->m_TimeStamp = GetTimeStamp();
marker = new SCH_MARKER();
marker->m_TimeStamp = GetTimeStamp();
Marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( WAR );
marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( WAR );
screen = aNetItemRef->m_SheetList.LastScreen();
Marker->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( Marker );
g_EESchemaVar.NbErrorErc++;
g_EESchemaVar.NbWarningErc++;
marker->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( marker );
wxString msg;
......@@ -246,17 +252,17 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
if( (aNetItemRef->m_Type == NET_HIERLABEL)
|| (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 ) );
}
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 ) );
}
Marker->SetData( ERCE_HIERACHICAL_LABEL,
marker->SetData( ERCE_HIERACHICAL_LABEL,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
......@@ -279,10 +285,9 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
{
if( aMinConn == NOC ) /* Only 1 element in the net. */
{
msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ),
GetChars( cmp_ref ), GetChars( string_pinnum ),
MsgPinElectricType[ii] );
Marker->SetData( ERCE_PIN_NOT_CONNECTED,
msg.Printf( _( "Pin %s (%s) of component %s is unconnected." ),
GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ) );
marker->SetData( ERCE_PIN_NOT_CONNECTED,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
......@@ -294,10 +299,11 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
GetChars( cmp_ref ), GetChars( string_pinnum ),
MsgPinElectricType[ii], aNetItemRef->GetNet() );
Marker->SetData( ERCE_PIN_NOT_DRIVEN,
msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ),
GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ),
aNetItemRef->GetNet() );
marker->SetData( ERCE_PIN_NOT_DRIVEN,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
......@@ -306,8 +312,8 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
if( aDiag == UNC )
{
msg.Printf( _( "More than 1 Pin connected to UnConnect symbol" ) );
Marker->SetData( ERCE_NOCONNECT_CONNECTED,
msg.Printf( _( "More than 1 pin connected to an UnConnect symbol." ) );
marker->SetData( ERCE_NOCONNECT_CONNECTED,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
......@@ -319,10 +325,10 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
{
jj = aNetItemTst->m_ElectricalType;
int errortype = ERCE_PIN_TO_PIN_WARNING;
if( aDiag == ERR )
{
Marker->SetErrorLevel( ERR );
g_EESchemaVar.NbWarningErc--;
marker->SetErrorLevel( ERR );
errortype = ERCE_PIN_TO_PIN_ERROR;
}
......@@ -330,29 +336,22 @@ void Diagnose( EDA_DRAW_PANEL* aPanel,
memcpy( ascii_buf, &aNetItemTst->m_PinNum, 4 );
alt_string_pinnum = FROM_UTF8( ascii_buf );
alt_cmp = wxT( "?" );
if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef(
&aNetItemTst->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ),
GetChars( cmp_ref ), GetChars( string_pinnum ), MsgPinElectricType[ii] );
Marker->SetData( errortype,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ),
GetChars( alt_cmp ), GetChars( alt_string_pinnum ), MsgPinElectricType[jj],
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetList );
msg.Printf( _( "Pin %s (%s) of component %s is connected to " ),
GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ) );
marker->SetData( errortype, aNetItemRef->m_Start, msg, aNetItemRef->m_Start );
msg.Printf( _( "pin %s (%s) of component %s (net %d)." ),
GetChars( alt_string_pinnum ), MsgPinElectricType[jj], GetChars( alt_cmp ),
aNetItemRef->GetNet() );
Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
}
}
/* Routine testing electrical conflicts between NetItemRef and other items
* of the same net
*/
void TestOthersItems( EDA_DRAW_PANEL* panel,
unsigned NetItemRef,
unsigned netstart,
void TestOthersItems( unsigned NetItemRef, unsigned netstart,
int* NetNbItems, int* MinConnexion )
{
unsigned NetItemTst;
......@@ -364,6 +363,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
NetItemTst = netstart;
local_minconn = NOC;
if( ref_elect_type == PIN_NC )
local_minconn = NPI;
......@@ -373,8 +373,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
if( NetItemRef == NetItemTst )
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
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
......@@ -384,56 +383,53 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
{
/* Not connected or not driven pin. */
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
* package, and duplicated 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
* TODO test also if instances connected are connected to
* the same net
*/
for( unsigned duppin = 0;
duppin < g_NetObjectslist.size();
duppin++ )
for( unsigned duplicate = 0; duplicate < g_NetObjectslist.size(); duplicate++ )
{
if( g_NetObjectslist[duppin]->m_Type != NET_PIN )
if( g_NetObjectslist[duplicate]->m_Type != NET_PIN )
continue;
if( duppin == NetItemRef )
if( duplicate == NetItemRef )
continue;
if( g_NetObjectslist[NetItemRef]->m_PinNum !=
g_NetObjectslist[duppin]->m_PinNum )
g_NetObjectslist[duplicate]->m_PinNum )
continue;
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]->
m_SheetList ) !=
( (SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link )
->GetRef( &g_NetObjectslist[duppin]->m_SheetList ) )
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]-> m_SheetList ) !=
( (SCH_COMPONENT*) g_NetObjectslist[duplicate]->m_Link )
->GetRef( &g_NetObjectslist[duplicate]->m_SheetList ) )
continue;
// Same component and same pin. Do dot create error for
// this pin
// if the other pin is connected (i.e. if duppin net
// has an other item)
if( (duppin > 0)
&& ( g_NetObjectslist[duppin]->GetNet() ==
g_NetObjectslist[duppin - 1]->GetNet() ) )
// Same component and same pin. Do dot create error for this pin
// if the other pin is connected (i.e. if duplicate net has an other
// item)
if( (duplicate > 0)
&& ( g_NetObjectslist[duplicate]->GetNet() ==
g_NetObjectslist[duplicate - 1]->GetNet() ) )
seterr = false;
if( (duppin < g_NetObjectslist.size() - 1)
&& ( g_NetObjectslist[duppin]->GetNet() ==
g_NetObjectslist[duppin + 1]->GetNet() ) )
if( (duplicate < g_NetObjectslist.size() - 1)
&& ( g_NetObjectslist[duplicate]->GetNet() ==
g_NetObjectslist[duplicate + 1]->GetNet() ) )
seterr = false;
}
}
if( seterr )
Diagnose( panel,
g_NetObjectslist[NetItemRef],
NULL,
local_minconn,
WAR );
Diagnose( g_NetObjectslist[NetItemRef], NULL, local_minconn, WAR );
*MinConnexion = DRV; // inhibiting other messages of this
// type for the net.
}
......@@ -445,7 +441,7 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
case NET_ITEM_UNSPECIFIED:
case NET_SEGMENT:
case NET_BUS:
case NET_JONCTION:
case NET_JUNCTION:
case NET_LABEL:
case NET_HIERLABEL:
case NET_BUSLABELMEMBER:
......@@ -469,15 +465,16 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
break;
*NetNbItems += 1;
if( erc == OK )
{
erc = DiagErc[ref_elect_type][jj];
if( erc != OK )
{
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
{
Diagnose( panel,
g_NetObjectslist[NetItemRef],
Diagnose( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst],
0,
erc );
......@@ -486,95 +483,68 @@ void TestOthersItems( EDA_DRAW_PANEL* panel,
}
}
}
break;
}
}
}
/* Create the Diagnostic file (<xxx>.erc file)
*/
bool WriteDiagnosticERC( const wxString& FullFileName )
bool WriteDiagnosticERC( const wxString& aFullFileName )
{
SCH_ITEM* DrawStruct;
SCH_MARKER* Marker;
char Line[1024];
static FILE* OutErc;
SCH_SHEET_PATH* Sheet;
SCH_ITEM* item;
SCH_MARKER* marker;
static FILE* file;
SCH_SHEET_PATH* sheet;
wxString msg;
int count = 0;
if( ( OutErc = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL )
if( ( file = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
return FALSE;
DateAndTime( Line );
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 / (Root) \n" ) );
}
else
{
wxString str = Sheet->PathHumanReadable();
msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( str ) );
}
msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( sheet->PathHumanReadable() ) );
fprintf( OutErc, "%s", TO_UTF8( msg ) );
fprintf( file, "%s", TO_UTF8( msg ) );
DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
for( item = sheet->LastDrawList(); item != NULL; item = item->Next() )
{
if( DrawStruct->Type() != SCH_MARKER_T )
if( item->Type() != SCH_MARKER_T )
continue;
Marker = (SCH_MARKER*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC )
continue;
msg = Marker->GetReporter().ShowReport();
fprintf( OutErc, "%s", TO_UTF8( msg ) );
}
}
msg.Printf( _( "\n >> Errors ERC: %d\n" ), g_EESchemaVar.NbErrorErc );
fprintf( OutErc, "%s", TO_UTF8( msg ) );
fclose( OutErc );
return TRUE;
}
marker = (SCH_MARKER*) item;
if( marker->GetMarkerType() != MARK_ERC )
continue;
static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b )
{
int at = a->m_Type;
int bt = b->m_Type;
if( marker->GetMarkerType() == ERR )
count++;
if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
&& ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
{
if( a->m_SheetList == b->m_SheetListInclude )
{
return true; //connected!
msg = marker->GetReporter().ShowReport();
fprintf( file, "%s", TO_UTF8( msg ) );
}
}
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
* sub sheet Glabel
*/
void TestLabel( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned StartNet )
void TestLabel( unsigned NetItemRef, unsigned StartNet )
{
unsigned NetItemTst;
int erc = 1;
NetItemTst = StartNet;
/* Review the list of labels connected to NetItemRef. */
......@@ -584,25 +554,24 @@ void TestLabel( EDA_DRAW_PANEL* panel, unsigned NetItemRef, unsigned StartNet )
continue;
/* Is always in the same net? */
if( ( NetItemTst == g_NetObjectslist.size() )
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
g_NetObjectslist[NetItemTst]->GetNet() ) )
if( ( NetItemTst == g_NetObjectslist.size() )
|| ( g_NetObjectslist[NetItemRef]->GetNet() != g_NetObjectslist[NetItemTst]->GetNet() ) )
{
/* End Netcode found. */
if( erc )
{
/* Glabel or SheetLabel orphaned. */
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, -1, WAR );
Diagnose( g_NetObjectslist[NetItemRef], NULL, -1, WAR );
}
return;
}
if( IsLabelsConnected( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst] ) )
if( g_NetObjectslist[NetItemRef]->IsLabelConnected( g_NetObjectslist[NetItemTst] ) )
erc = 0;
//same thing, different order.
if( IsLabelsConnected( g_NetObjectslist[NetItemTst],
g_NetObjectslist[NetItemRef] ) )
if( g_NetObjectslist[NetItemTst]->IsLabelConnected( g_NetObjectslist[NetItemRef] ) )
erc = 0;
}
}
/*
* 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 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* 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
* modify it under the terms of the GNU General Public License
......@@ -22,6 +23,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file erc.h
*/
#ifndef _ERC_H
#define _ERC_H
......@@ -58,16 +63,44 @@ enum errortype
#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 );
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 );
......
/*
* events_called_functions.cpp
* some events functions
* @file events_called_functions.cpp
*/
#include "fctsys.h"
......@@ -8,7 +7,6 @@
#include "class_drawpanel.h"
#include "general.h"
#include "kicad_device_context.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "protos.h"
......
......@@ -185,8 +185,6 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
SetStatusText( wxEmptyString );
ClearMsgPanel();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
screen->ClrModify();
if( aIsNew )
......
......@@ -14,7 +14,6 @@
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/***************/
/* GENERAL.H */
/***************/
/**
* @file general.h
*/
#ifndef _GENERAL_H_
#define _GENERAL_H_
......@@ -115,14 +115,6 @@ extern int g_RepeatDeltaLabel;
// Management options.
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 int g_DefaultTextLabelSize;
......@@ -170,7 +162,7 @@ extern int g_InvisibleItemColor;
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
*/
......
/*************************************************/
/* Module to handle Get & Place Library Part */
/*************************************************/
/**
* @file getpart.cpp
* @brief Cod to handle get & place library component.
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "gr_basic.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "kicad_device_context.h"
......
/******************/
/* hierarch.cpp */
/******************/
/**
* @file hierarch.cpp
*/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -61,7 +60,7 @@ HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) :
m_Parent = parent;
// 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_sel_xpm ) );
......@@ -122,7 +121,7 @@ HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* parent, wxDC* DC, cons
m_nbsheets = 1;
cellule = m_Tree->AddRoot( _( "Root" ), 0, 1 );
m_Tree->SetItemBold( cellule, TRUE );
m_Tree->SetItemBold( cellule, true );
SCH_SHEET_PATH list;
list.Push( g_RootSheet );
m_Tree->SetItemData( cellule, new TreeItemData( list ) );
......
......@@ -22,11 +22,6 @@
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 )
{
wxString errMsg;
......@@ -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 )
{
wxFileName fn;
......
/*****************************************************/
/* libarch.cpp */
/* Module for generation of component archive files. */
/*****************************************************/
/**
* @file libarch.cpp
* @brief Module for generation of component archive files.
*/
#include "fctsys.h"
#include "confirm.h"
#include "class_sch_screen.h"
......
......@@ -96,7 +96,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
SaveCopyInUndoList( m_component );
PlaceAncre();
PlaceAnchor();
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
break;
......
......@@ -17,10 +17,6 @@
#include "class_library.h"
/**
* Function OnPlotCurrentComponent
* plot in SVG or PNG format the curren component
*/
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
{
LIB_COMPONENT* cmp = GetComponent();
......@@ -47,7 +43,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
......@@ -67,7 +63,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
......@@ -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 )
{
wxSize image_size = DrawPanel->GetClientSize();
......@@ -121,16 +110,8 @@ void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_j
image.Destroy();
}
/**
* Function PrintPage (virtual)
* 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)
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData)
{
if( ! m_component )
return;
......
......@@ -9,7 +9,6 @@
#include "confirm.h"
#include "eda_doc.h"
#include "gr_basic.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/************************/
/* class LIB_EDIT_FRAME */
/************************/
/**
* @file libeditframe.h
* @brief Definition of class LIB_EDIT_FRAME
*/
#ifndef __LIBEDITFRM_H__
#define __LIBEDITFRM_H__
......@@ -42,7 +42,7 @@ public:
~LIB_EDIT_FRAME();
void ReCreateMenuBar();
void ReCreateMenuBar();
/**
* Function EnsureActiveLibExists
......@@ -55,19 +55,37 @@ public:
* Function SetLanguage
* is called on a language menu selection
*/
void SetLanguage( wxCommandEvent& event );
void SetLanguage( wxCommandEvent& event );
void InstallConfigFrame( wxCommandEvent& event );
void InstallDimensionsDialog( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event );
void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
void OnSelectTool( wxCommandEvent& aEvent );
void OnImportPart( wxCommandEvent& event );
void OnExportPart( wxCommandEvent& event );
void OnSelectAlias( wxCommandEvent& event );
void OnSelectPart( wxCommandEvent& event );
void InstallConfigFrame( wxCommandEvent& event );
void InstallDimensionsDialog( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event );
/**
* Function OnPlotCurrentComponent
* plot the current component in SVG or PNG format.
*/
void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
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 );
/**
* 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 OnSelectAlias( wxCommandEvent& event );
void OnSelectPart( wxCommandEvent& event );
/**
* Function DeleteOnePart
......@@ -92,9 +110,9 @@ public:
*/
void CreateNewLibraryPart( wxCommandEvent& event );
void OnCreateNewPartFromExisting( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event );
void OnCreateNewPartFromExisting( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event );
/**
* Function LoadOneLibraryPart
......@@ -106,27 +124,27 @@ public:
*/
void LoadOneLibraryPart( wxCommandEvent& event );
void OnViewEntryDoc( wxCommandEvent& event );
void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event );
void OnEditPin( wxCommandEvent& event );
void OnViewEntryDoc( wxCommandEvent& event );
void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event );
void OnEditPin( wxCommandEvent& event );
void OnSelectItem( wxCommandEvent& aEvent );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
void OnUpdateUndo( wxUpdateUIEvent& event );
void OnUpdateRedo( wxUpdateUIEvent& event );
void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event );
void OnUpdateViewDoc( wxUpdateUIEvent& event );
void OnUpdatePinByPin( wxUpdateUIEvent& event );
void OnUpdatePartNumber( wxUpdateUIEvent& event );
void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
void OnUpdateSelectAlias( wxUpdateUIEvent& event );
void UpdateAliasSelectList();
void UpdatePartSelectList();
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
void OnUpdateUndo( wxUpdateUIEvent& event );
void OnUpdateRedo( wxUpdateUIEvent& event );
void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event );
void OnUpdateViewDoc( wxUpdateUIEvent& event );
void OnUpdatePinByPin( wxUpdateUIEvent& event );
void OnUpdatePartNumber( wxUpdateUIEvent& event );
void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
void OnUpdateSelectAlias( wxUpdateUIEvent& event );
void UpdateAliasSelectList();
void UpdatePartSelectList();
/**
* Function DisplayLibInfos
......@@ -135,15 +153,15 @@ public:
*/
void DisplayLibInfos();
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void OnCloseWindow( wxCloseEvent& Event );
void ReCreateHToolbar();
void ReCreateVToolbar();
void CreateOptionToolbar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
double BestZoom(); // Returns the best zoom
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void OnCloseWindow( wxCloseEvent& Event );
void ReCreateHToolbar();
void ReCreateVToolbar();
void CreateOptionToolbar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
double BestZoom(); // Returns the best zoom
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
......@@ -200,18 +218,18 @@ public:
wxString& GetAliasName( void ) { return m_aliasName; }
int GetUnit( void ) { return m_unit; }
int GetUnit( void ) { return m_unit; }
void SetUnit( int unit )
void SetUnit( int unit )
{
wxASSERT( unit >= 1 );
m_unit = unit;
}
int GetConvert( void ) { return m_convert; }
int GetConvert( void ) { return m_convert; }
void SetConvert( int convert )
void SetConvert( int convert )
{
wxASSERT( convert >= 0 );
m_convert = convert;
......@@ -230,11 +248,11 @@ public:
void SetDrawItem( LIB_ITEM* drawItem );
bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
FILL_T GetFillStyle( void ) { return m_drawFillStyle; }
FILL_T GetFillStyle( void ) { return m_drawFillStyle; }
/**
* Function TempCopyComponent
......@@ -272,7 +290,7 @@ private:
* The library list can be changed by the schematic editor after reloading a new schematic
* and the current m_library can point a non existent lib.
*/
virtual void OnActivate( wxActivateEvent& event );
virtual void OnActivate( wxActivateEvent& event );
// General:
......@@ -343,32 +361,56 @@ private:
// General editing
public:
void SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int flag_type_command = 0 );
void SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int flag_type_command = 0 );
private:
void GetComponentFromUndoList( wxCommandEvent& event );
void GetComponentFromRedoList( wxCommandEvent& event );
void GetComponentFromUndoList( wxCommandEvent& event );
void GetComponentFromRedoList( wxCommandEvent& event );
// Editing pins
void CreatePin( wxDC* DC );
void StartMovePin( wxDC* DC );
void CreatePin( 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
LIB_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC );
void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
void EndDrawGraphicItem( wxDC* DC );
void LoadOneSymbol();
void SaveOneSymbol();
void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem );
void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC );
void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
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();
/**
* 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 EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem );
LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition,
const KICAD_T aFilterList[] = LIB_COLLECTOR::AllItems );
void EditField( wxDC* DC, LIB_FIELD* Field );
void EditField( wxDC* DC, LIB_FIELD* Field );
public:
/**
......@@ -382,12 +424,12 @@ public:
bool LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );
/* Block commands: */
virtual int ReturnBlockCommand( int aKey );
virtual void HandleBlockPlace( wxDC* DC );
virtual bool HandleBlockEnd( wxDC* DC );
virtual int ReturnBlockCommand( int aKey );
virtual void HandleBlockPlace( wxDC* DC );
virtual bool HandleBlockEnd( wxDC* DC );
void PlacePin( wxDC* DC );
void GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id );
void PlacePin( wxDC* DC );
void GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id );
// Automatic placement of pins
void RepeatPinItem( wxDC* DC, LIB_PIN* Pin );
......@@ -398,7 +440,7 @@ protected:
wxString m_LastLibExportPath;
/** Convert of the item currently being drawn. */
bool m_drawSpecificConvert;
bool m_drawSpecificConvert;
/**
* Specify which component parts the current draw item applies to.
......@@ -406,25 +448,25 @@ protected:
* If true, the item being drawn or edited applies only to the selected
* part. Otherwise it applies to all parts in the component.
*/
bool m_drawSpecificUnit;
bool m_drawSpecificUnit;
/** The current draw or edit graphic item fill style. */
static FILL_T m_drawFillStyle;
static FILL_T m_drawFillStyle;
/** Default line width for drawing or editing graphic items. */
static int m_drawLineWidth;
static int m_drawLineWidth;
/** The current active library. NULL if no active library is selected. */
static CMP_LIBRARY* m_library;
static CMP_LIBRARY* m_library;
/** The current component being edited. NULL if no component is selected. */
static LIB_COMPONENT* m_component;
static LIB_ITEM* m_lastDrawItem;
static LIB_ITEM* m_drawItem;
static wxString m_aliasName;
static LIB_ITEM* m_lastDrawItem;
static LIB_ITEM* m_drawItem;
static wxString m_aliasName;
// The unit number to edit and show
static int m_unit;
static int m_unit;
// Show the normal shape ( m_convert <= 1 ) or the converted shape
// ( m_convert > 1 )
......@@ -435,13 +477,13 @@ protected:
// Graphic items for converted shape
// But under some circumstances (New component created)
// these tools must left enable
static bool m_showDeMorgan;
static bool m_showDeMorgan;
/// The current text size setting.
static int m_textSize;
static int m_textSize;
/// Current text orientation setting.
static int m_textOrientation;
static int m_textOrientation;
static wxSize m_clientSize;
......@@ -449,14 +491,14 @@ protected:
/**
* Function CreatePNGorJPEGFile
* Create an image (screenshot) of the current component.
* Output file format is png or jpeg
* creates an image (screenshot) of the current component in PNG or JPEG format.
* @param aFileName = the full filename
* @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
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
......
......@@ -7,7 +7,6 @@
#include "confirm.h"
#include "kicad_string.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "richio.h"
#include "general.h"
......@@ -318,7 +317,7 @@ line %d, \aAbort reading file.\n" ),
for( ; ; )
{
if( !aLine->ReadLine() )
return TRUE;
return true;
line = aLine->Line();
......
......@@ -23,19 +23,16 @@
* 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 "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "appl_wxstruct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -47,7 +44,7 @@
#include "sch_component.h"
#include "sch_text.h"
#include "sch_sheet.h"
#include "template_fieldnames.h"
#include <wx/tokenzr.h>
......
/*****************/
/* netlist.cpp */
/*****************/
/**
* @file eeschema/netlist.cpp
*/
#include "fctsys.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -51,6 +50,7 @@ static int LastNetCode, LastBusNetCode;
#if defined(DEBUG)
void dumpNetTable()
{
for( unsigned idx = 0; idx < g_NetObjectslist.size(); ++idx )
......@@ -59,7 +59,6 @@ void dumpNetTable()
}
}
#endif
......@@ -123,6 +122,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
for( unsigned ii = 0, istart = 0; ii < g_NetObjectslist.size(); ii++ )
{
NETLIST_OBJECT* net_item = g_NetObjectslist[ii];
if( net_item->m_SheetList != *sheet ) // Sheet change
{
sheet = &(net_item->m_SheetList);
......@@ -149,16 +149,18 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->SetNet( LastNetCode );
LastNetCode++;
}
PointToPointConnect( net_item, 0, istart );
break;
case NET_JONCTION:
case NET_JUNCTION:
/* Control of the junction outside BUS. */
if( net_item->GetNet() == 0 )
{
net_item->SetNet( LastNetCode );
LastNetCode++;
}
SegmentToPointConnect( net_item, 0, istart );
/* Control of the junction, on BUS. */
......@@ -167,6 +169,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->m_BusNetCode = LastBusNetCode;
LastBusNetCode++;
}
SegmentToPointConnect( net_item, ISBUS, istart );
break;
......@@ -179,6 +182,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->SetNet( LastNetCode );
LastNetCode++;
}
SegmentToPointConnect( net_item, 0, istart );
break;
......@@ -193,6 +197,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->m_BusNetCode = LastBusNetCode;
LastBusNetCode++;
}
PointToPointConnect( net_item, ISBUS, istart );
break;
......@@ -205,6 +210,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
net_item->m_BusNetCode = LastBusNetCode;
LastBusNetCode++;
}
SegmentToPointConnect( net_item, ISBUS, istart );
break;
}
......@@ -215,7 +221,6 @@ void SCH_EDIT_FRAME::BuildNetListBase()
dumpNetTable();
#endif
activity << _( "done" );
SetStatusText( activity );
......@@ -233,7 +238,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
case NET_PIN:
case NET_SHEETLABEL:
case NET_SEGMENT:
case NET_JONCTION:
case NET_JUNCTION:
case NET_BUS:
case NET_NOCONNECT:
break;
......@@ -267,6 +272,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
/* Connection hierarchy. */
activity << wxT( ", " ) << _( "hierarchy..." );
SetStatusText( activity );
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
{
if( g_NetObjectslist[ii]->m_Type == NET_SHEETLABEL
......@@ -287,6 +293,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
/* Compress numbers of Netcode having consecutive values. */
LastNetCode = NetCode = 0;
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
{
if( g_NetObjectslist[ii]->GetNet() != LastNetCode )
......@@ -294,6 +301,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
NetCode++;
LastNetCode = g_NetObjectslist[ii]->GetNet();
}
g_NetObjectslist[ii]->SetNet( NetCode );
}
......@@ -324,6 +332,7 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
NETLIST_OBJECT_LIST candidates;
int netcode = 0; // current netcode for tested items
unsigned idxstart = 0; // index of the first item of this net
for( unsigned ii = 0; ii <= aNetItemBuffer.size(); ii++ )
{
NETLIST_OBJECT* item;
......@@ -332,20 +341,25 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
netcode = -2;
else
item = aNetItemBuffer[ii];
if( netcode != item->GetNet() ) // End of net found
{
if( candidates.size() ) // One or more labels exists, find the best
{
NETLIST_OBJECT* bestlabel = FindBestNetName( candidates );
for (unsigned jj = idxstart; jj < ii; jj++ )
aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel;
}
if( netcode == -2 )
break;
netcode = item->GetNet();
candidates.clear();
idxstart = ii;
}
switch( item->m_Type )
{
case NET_HIERLABEL:
......@@ -384,8 +398,12 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
// and priority >= NET_PRIO_MAX-1 is for global connections
// ( i.e. for labels that are not prefixed by a sheetpath)
#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];
......@@ -403,8 +421,10 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
{
NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
// Calculate candidate priority
int candidate_priority = 0;
for( unsigned ii = 0; ii <= NET_PRIO_MAX; ii++ )
{
if ( candidate->m_Type == priority_order[ii] )
......@@ -511,6 +531,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
SCH_SHEET_PATH list;
DrawList = sheetlist->LastScreen()->GetDrawItems();
for( ; DrawList; DrawList = DrawList->Next() )
{
switch( DrawList->Type() )
......@@ -518,8 +539,8 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
case SCH_LINE_T:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) DrawList )
if( (STRUCT->GetLayer() != LAYER_BUS)
&& (STRUCT->GetLayer() != LAYER_WIRE) )
if( (STRUCT->GetLayer() != LAYER_BUS) && (STRUCT->GetLayer() != LAYER_WIRE) )
break;
new_item = new NETLIST_OBJECT();
......@@ -537,6 +558,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
{
new_item->m_Type = NET_SEGMENT;
}
aNetItemBuffer.push_back( new_item );
break;
......@@ -548,7 +570,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_SheetList = *sheetlist;
new_item->m_SheetListInclude = *sheetlist;
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;
aNetItemBuffer.push_back( new_item );
......@@ -581,6 +603,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
if( STRUCT->GetLayer() == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->GetLayer() == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL;
......@@ -588,6 +611,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item );
/* If a bus connects to label */
if( ii )
ConvertBusToMembers( aNetItemBuffer, *new_item );
......@@ -610,6 +634,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
// (look at the case statement above).
if( STRUCT->GetLayer() == LAYER_GLOBLABEL )
new_item->m_Type = NET_GLOBLABEL;
if( STRUCT->GetLayer() == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL;
......@@ -628,6 +653,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->GetLibName() );
if( Entry == NULL )
break;
......@@ -717,8 +743,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
default:
{
wxString msg;
msg.Printf( wxT( "Netlist: unexpected struct type %d" ),
DrawList->Type() );
msg.Printf( wxT( "Netlist: unexpected struct type %d" ), DrawList->Type() );
wxMessageBox( msg );
break;
}
......@@ -739,9 +764,10 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
{
NETLIST_OBJECT* Label = aNetItemBuffer[ii];
if( (Label->m_Type == NET_SHEETBUSLABELMEMBER)
|| (Label->m_Type == NET_BUSLABELMEMBER)
|| (Label->m_Type == NET_HIERBUSLABELMEMBER) )
if( (Label->m_Type == NET_SHEETBUSLABELMEMBER)
|| (Label->m_Type == NET_BUSLABELMEMBER)
|| (Label->m_Type == NET_HIERBUSLABELMEMBER) )
{
if( Label->GetNet() == 0 )
{
......@@ -765,8 +791,7 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
if( LabelInTst->GetNet() == 0 )
LabelInTst->SetNet( Label->GetNet() );
else
PropageNetCode( LabelInTst->GetNet(),
Label->GetNet(), 0 );
PropageNetCode( LabelInTst->GetNet(), Label->GetNet(), 0 );
}
}
}
......@@ -796,6 +821,7 @@ int IsBusLabel( const wxString& LabelDrawList )
FirstNumWireBus = LastNumWireBus = 9;
RootBusNameLength = Num;
Num++;
while( LabelDrawList[Num] != '.' && Num < LabelDrawList.Len() )
{
BufLine.Append( LabelDrawList[Num] );
......@@ -809,6 +835,7 @@ int IsBusLabel( const wxString& LabelDrawList )
Num++;
BufLine.Empty();
while( LabelDrawList[Num] != ']' && Num < LabelDrawList.Len() )
{
BufLine.Append( LabelDrawList[Num] );
......@@ -902,6 +929,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
{
NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
if( Objet->GetNet() == OldNetCode )
{
Objet->SetNet( NewNetCode );
......@@ -913,6 +941,7 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus )
for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
{
NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
if( Objet->m_BusNetCode == OldNetCode )
{
Objet->m_BusNetCode = NewNetCode;
......@@ -948,9 +977,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
if( IsBus == 0 ) /* Objects other than BUS and BUSLABELS. */
{
netCode = Ref->GetNet();
for( unsigned i = start; i < g_NetObjectslist.size(); i++ )
{
NETLIST_OBJECT* item = g_NetObjectslist[i];
if( item->m_SheetList != Ref->m_SheetList ) //used to be > (why?)
continue;
......@@ -963,7 +994,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
case NET_GLOBLABEL:
case NET_SHEETLABEL:
case NET_PINLABEL:
case NET_JONCTION:
case NET_JUNCTION:
case NET_NOCONNECT:
if( Ref->m_Start == item->m_Start
|| Ref->m_Start == item->m_End
......@@ -990,9 +1021,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
else /* Object type BUS, BUSLABELS, and junctions. */
{
netCode = Ref->m_BusNetCode;
for( unsigned i = start; i<g_NetObjectslist.size(); i++ )
{
NETLIST_OBJECT* item = g_NetObjectslist[i];
if( item->m_SheetList != Ref->m_SheetList )
continue;
......@@ -1014,11 +1047,11 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
case NET_SHEETBUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_JONCTION:
if( Ref->m_Start == item->m_Start
|| Ref->m_Start == item->m_End
|| Ref->m_End == item->m_Start
|| Ref->m_End == item->m_End )
case NET_JUNCTION:
if( Ref->m_Start == item->m_Start
|| Ref->m_Start == item->m_End
|| Ref->m_End == item->m_Start
|| Ref->m_End == item->m_End )
{
if( item->m_BusNetCode == 0 )
item->m_BusNetCode = netCode;
......@@ -1039,8 +1072,7 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start )
* The list of objects is expected sorted by sheets.
* Search is done from index aIdxStart to the last element of g_NetObjectslist
*/
static void SegmentToPointConnect( NETLIST_OBJECT* aJonction,
int aIsBus, int aIdxStart )
static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, int aIsBus, int aIdxStart )
{
for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ )
{
......@@ -1067,16 +1099,14 @@ static void SegmentToPointConnect( NETLIST_OBJECT* aJonction,
if( aIsBus == 0 )
{
if( Segment->GetNet() )
PropageNetCode( Segment->GetNet(),
aJonction->GetNet(), aIsBus );
PropageNetCode( Segment->GetNet(), aJonction->GetNet(), aIsBus );
else
Segment->SetNet( aJonction->GetNet() );
}
else
{
if( Segment->m_BusNetCode )
PropageNetCode( Segment->m_BusNetCode,
aJonction->m_BusNetCode, aIsBus );
PropageNetCode( Segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
else
Segment->m_BusNetCode = aJonction->m_BusNetCode;
}
......@@ -1097,12 +1127,14 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
{
if( g_NetObjectslist[i]->GetNet() == LabelRef->GetNet() )
continue;
if( g_NetObjectslist[i]->m_SheetList != LabelRef->m_SheetList )
{
if( (g_NetObjectslist[i]->m_Type != NET_PINLABEL
&& g_NetObjectslist[i]->m_Type != NET_GLOBLABEL
&& g_NetObjectslist[i]->m_Type != NET_GLOBBUSLABELMEMBER) )
continue;
if( (g_NetObjectslist[i]->m_Type == NET_GLOBLABEL
|| g_NetObjectslist[i]->m_Type == NET_GLOBBUSLABELMEMBER)
&& g_NetObjectslist[i]->m_Type != LabelRef->m_Type )
......@@ -1116,13 +1148,14 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
// NET_GLOBLABEL is global.
// NET_PINLABEL is a kind of global label (generated by a power pin invisible)
NetObjetType ntype = g_NetObjectslist[i]->m_Type;
if( ntype == NET_LABEL
|| ntype == NET_GLOBLABEL
|| ntype == NET_HIERLABEL
|| ntype == NET_BUSLABELMEMBER
|| ntype == NET_GLOBBUSLABELMEMBER
|| ntype == NET_HIERBUSLABELMEMBER
|| ntype == NET_PINLABEL )
|| ntype == NET_GLOBLABEL
|| ntype == NET_HIERLABEL
|| ntype == NET_BUSLABELMEMBER
|| ntype == NET_GLOBBUSLABELMEMBER
|| ntype == NET_HIERBUSLABELMEMBER
|| ntype == NET_PINLABEL )
{
if( g_NetObjectslist[i]->m_Label.CmpNoCase( LabelRef->m_Label ) != 0 )
continue;
......@@ -1227,17 +1260,19 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
case NET_SHEETBUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_JONCTION:
case NET_JUNCTION:
break;
case NET_PIN:
if( NetItemRef->m_Type == NET_PIN )
StateFlag = PAD_CONNECT;
break;
case NET_NOCONNECT:
if( StateFlag != PAD_CONNECT )
StateFlag = NOCONNECT_SYMBOL_PRESENT;
break;
}
}
......
......@@ -18,7 +18,6 @@
#include "confirm.h"
#include "gestfich.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h"
#include "netlist.h"
......
/*******************/
/* onleftclick.cpp */
/*******************/
/**
* @file eeschema/onleftclick.cpp
*/
#include "fctsys.h"
#include "eeschema_id.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/********************/
/* onrightclick.cpp */
/********************/
/**
* @file eeschema/onrightclick.cpp
*/
#include "fctsys.h"
#include "eeschema_id.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/***************************************************
* operations_on_item_lists.cpp
* functions used in block commands, or undo/redo,
* to move, mirror, delete, copy ... lists of schematic items
/**
* @file operations_on_items_lists.cpp
* @brief Functions used in block commands, or undo/redo, to move, mirror, delete, copy ...
* lists of schematic items.
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "class_drawpanel.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.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 "appl_wxstruct.h"
......@@ -20,7 +21,6 @@
#include "sch_component.h"
#include "sch_sheet.h"
#include "sch_sheet_path.h"
#include "template_fieldnames.h"
#include "dialogs/dialog_schematic_find.h"
......@@ -274,7 +274,7 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset
if( Entry == NULL )
{
/* Create a dummy component if the actual component can not be found. */
dummy = TRUE;
dummy = true;
if( DummyCmp == NULL )
CreateDummyCmp();
......@@ -779,7 +779,7 @@ void SCH_COMPONENT::SetOrientation( int aOrientation )
temp.x1 = 1;
temp.y2 = -1;
temp.y1 = temp.x2 = 0;
transform = TRUE;
transform = true;
break;
case CMP_ORIENT_90:
......@@ -1082,7 +1082,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
newfmt = 1;
if( !aLine.ReadLine() )
return TRUE;
return true;
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 0 and 1 are very important: reference and value
......@@ -17,7 +18,6 @@
#include "drawtxt.h"
#include "macros.h"
#include "trigo.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
......@@ -26,9 +26,9 @@
#include "class_library.h"
#include "sch_component.h"
#include "sch_field.h"
#include "template_fieldnames.h"
#include "kicad_string.h"
SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
SCH_ITEM( aParent, SCH_FIELD_T ),
EDA_TEXT()
......
......@@ -18,7 +18,7 @@
class SCH_LINE : public SCH_ITEM
{
bool m_StartIsDangling;
bool m_EndIsDangling; // TRUE if not connected (wires, tracks...)
bool m_EndIsDangling; // true if not connected (wires, tracks...)
public:
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 "gr_basic.h"
......@@ -6,7 +35,6 @@
#include "appl_wxstruct.h"
#include "class_drawpanel.h"
#include "sch_item_struct.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
......@@ -21,7 +49,6 @@
#include "sch_no_connect.h"
#include "sch_sheet.h"
#include "sch_component.h"
#include "sch_collectors.h"
#include "sch_text.h"
#include <boost/foreach.hpp>
......@@ -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
// Purpose: member functions for SCH_SHEET
// header = sch_sheet.h
// Author: jean-pierre Charras
// Modified by: Wayne Stambaugh
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright:
// License: License GNU
/////////////////////////////////////////////////////////////////////////////
/*
* 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 sch_sheet.cpp
* @brief Implementation of SCH_SHEET class.
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -17,7 +35,6 @@
#include "drawtxt.h"
#include "trigo.h"
#include "richio.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "plot_common.h"
......
/////////////////////////////////////////////////////////////////////////////
// Name: sch_sheet_pin.cpp
// Purpose: member functions SCH_SHEET_PIN
// header = sch_sheet.h
// Author: jean-pierre Charras
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright: License GNU
// License:
/////////////////////////////////////////////////////////////////////////////
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006 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 sch_sheet_pin.cpp
* @brief Implementation of the SCH_SHEET_PIN class.
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -17,7 +35,6 @@
#include "plot_common.h"
#include "trigo.h"
#include "richio.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -48,7 +65,7 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
else
SetEdge( 0 );
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_IsDangling = true;
m_Number = 2;
}
......
/*********************************************/
/* Code for handling schematic sheet labels. */
/*********************************************/
/**
* @file sch_text.cpp
* @brief Code for handling schematic sheet labels.
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -729,7 +730,7 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
{
m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_IsDangling = true;
m_MultilineAllowed = false;
}
......@@ -937,7 +938,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
{
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
m_IsDangling = TRUE;
m_IsDangling = true;
m_MultilineAllowed = false;
}
......@@ -1369,7 +1370,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T
{
m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_IsDangling = true;
m_MultilineAllowed = false;
}
......
/*****************/
/* schedit.cpp */
/*****************/
/**
* @file schedit.cpp
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -9,7 +9,6 @@
#include "confirm.h"
#include "eda_doc.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "kicad_device_context.h"
#include "general.h"
......
......@@ -5,7 +5,6 @@
#include "fctsys.h"
#include "class_drawpanel.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/******************/
/* schframe.cpp */
/******************/
/**
* @file schframe.cpp
*/
#ifdef __GNUG__
#pragma implementation
......@@ -19,7 +19,6 @@
#include "lib_pin.h"
#include "class_library.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "sch_component.h"
#include "dialog_helpers.h"
......@@ -157,8 +156,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
EDA_DRAW_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style )
{
m_FrameName = wxT( "SchematicFrame" );
m_Draw_Axis = FALSE; // TRUE to show axis
m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references
m_Draw_Axis = FALSE; // true to show axis
m_Draw_Sheet_Ref = true; // true to show sheet references
m_CurrentSheet = new SCH_SHEET_PATH();
m_Multiflag = 0;
m_TextFieldSize = DEFAULT_SIZE_TEXT;
......@@ -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 );
if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE;
DrawPanel->m_Block_Enable = true;
ReCreateMenuBar();
ReCreateHToolbar();
......@@ -597,7 +596,7 @@ void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& event )
wxASSERT_MSG( m_findReplaceData != NULL,
wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
this->DrawPanel->m_IgnoreMouseEvents = TRUE;
this->DrawPanel->m_IgnoreMouseEvents = true;
if( m_dlgFindReplace )
{
......
......@@ -14,7 +14,6 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.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 "gr_basic.h"
#include "macros.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......
/*************************************************/
/* Functions to Load from file and save to file */
/* the graphic shapes used to draw a component */
/* When using the import/export symbol options */
/* files are the *.sym files */
/*************************************************/
/**
* @file symbedit.cpp
* @brief Functions to load from and save to file component libraries and symbols.
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -23,14 +21,7 @@
#include <wx/ffile.h>
/*
* 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 )
void LIB_EDIT_FRAME::LoadOneSymbol()
{
LIB_COMPONENT* Component;
wxString msg, err;
......@@ -40,7 +31,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void )
if( m_component == NULL || ( m_drawItem && m_drawItem->m_Flags ) )
return;
DrawPanel->m_IgnoreMouseEvents = TRUE;
DrawPanel->m_IgnoreMouseEvents = true;
wxString default_path = wxGetApp().ReturnLastVisitedLibraryPath();
......@@ -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()
{
wxString msg;
......@@ -218,12 +201,7 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
}
/*
* Place anchor reference coordinators for current component
*
* All coordinates of the object are offset to the cursor position.
*/
void LIB_EDIT_FRAME::PlaceAncre()
void LIB_EDIT_FRAME::PlaceAnchor()
{
if( m_component == NULL )
return;
......
/******************/
/* tool_sch.cpp */
/******************/
/**
* @file tool_sch.cpp
*/
#include "fctsys.h"
#include "class_drawpanel.h"
......@@ -21,7 +21,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
return;
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
m_HToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString, KiBitmap( new_xpm ),
......
/***********************/
/* viewlib_frame.cpp */
/***********************/
/**
* @file viewlib_frame.cpp
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "eeschema_id.h"
#include "class_drawpanel.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
......@@ -134,7 +133,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
wxT( "LibWindow" ) );
m_LibListWindow->SetOrientation( wxLAYOUT_VERTICAL );
m_LibListWindow->SetAlignment( wxLAYOUT_LEFT );
m_LibListWindow->SetSashVisible( wxSASH_RIGHT, TRUE );
m_LibListWindow->SetSashVisible( wxSASH_RIGHT, true );
m_LibListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_LibList = new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST,
wxPoint( 0, 0 ), wxDefaultSize,
......@@ -158,7 +157,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
wxT( "CmpWindow" ) );
m_CmpListWindow->SetOrientation( wxLAYOUT_VERTICAL );
m_CmpListWindow->SetSashVisible( wxSASH_RIGHT, TRUE );
m_CmpListWindow->SetSashVisible( wxSASH_RIGHT, true );
m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST,
wxPoint( 0, 0 ), wxDefaultSize,
......@@ -489,7 +488,7 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
else
m_exportToEeschemaCmpName.Empty();
Close( TRUE );
Close( true );
}
......
......@@ -56,7 +56,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
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_convert = 1;
DrawPanel->Refresh();
......@@ -64,7 +64,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
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;
DrawPanel->Refresh();
break;
......
......@@ -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.
class SCH_SCREENS
......@@ -490,6 +491,16 @@ public:
*/
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:
void AddScreenToList( SCH_SCREEN* aScreen );
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