Commit 14352646 authored by stambaughw's avatar stambaughw

First pass at DSN token file generator and other minor changes.

* Add CMake script to generate DSN token header and source file from
  token list file.
* Add preliminary component library DSN token list and lexer file to
  test script and prepare for new component library file lexer.
* EESchema: right click on ERC check mark displays error in message panel.
* Remove PCBNew header file dependency from common DSN lexer source.
* Minor code clean ups.
parent 58b5da01
#
# This program source code file is part of KICAD, a free EDA CAD application.
#
# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
# Copyright (C) 2010 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
#
#
# This script converts a plain text file with a line feed separated list
# of token names into the appropriate source and header files required by
# the DSN lexer. See files "<base_source_path>/common/dsnlexer.cpp" and
# "<base_source_path>/include/dsnlexer.h" for more information about how
# the DSN lexer works. The token list file format requires a single token
# per line. Tokens can only contain lower case letters, numbers, and
# underscores. The first letter of each token must be a lower case letter.
# Tokens must be unique. If any of the above criteria are not met, the
# source and header files will not be generated and a build error will
# occur.
#
# Valid tokens: a a1 foo_1 foo_bar2
# Invalid tokens: 1 A _foo bar_ foO
#
# Usage:
#
# add_custom_command(
# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_base.h
# COMMAND ${CMAKE_COMMAND}
# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/token_list_file
# -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
# )
#
# Input parameters:
#
# inputFile - The name of the token list file.
# outputPath - Optional output path to save the generated files. If not defined,
# the output path is the same path as the token list file path.
#
set( tokens "" )
set( lineCount 0 )
set( dsnErrorMsg "DSN token file generator failure:" )
if( NOT EXISTS ${inputFile} )
message( FATAL_ERROR "${dsnErrorMsg} file ${inputFile} cannot be found." )
endif( NOT EXISTS ${inputFile} )
if( NOT EXISTS ${outputPath} )
get_filename_component( outputPath "${inputFile}" PATH )
endif( NOT EXISTS ${outputPath} )
# Separate the file name without extension from the full file path.
get_filename_component( result "${inputFile}" NAME_WE )
message( STATUS "Extracted file name ${result} from path ${inputFile}" )
# Create include and source file name from the list file name.
set( includeFileName "${outputPath}/${result}_base.h" )
set( sourceFileName "${outputPath}/${result}_base.cpp" )
# Create tag for generating header file.
string( TOUPPER "${result}" fileNameTag )
set( headerTag "_${fileNameTag}_H_" )
set( includeFileHeader
"
/*
* Do not modify this file it was automatically generated by the TokenList2DsnLexer CMake
* script.
*/
#ifndef ${headerTag}
#define ${headerTag}
#include \"dsnlexer.h\"
namespace DSN {
enum DSN_T {
// these first few are negative special ones for syntax, and are
// inherited from DSNLEXER.
T_NONE = DSN_NONE,
T_COMMENT = DSN_COMMENT,
T_STRING_QUOTE = DSN_STRING_QUOTE,
T_QUOTE_DEF = DSN_QUOTE_DEF,
T_DASH = DSN_DASH,
T_SYMBOL = DSN_SYMBOL,
T_NUMBER = DSN_NUMBER,
T_RIGHT = DSN_RIGHT, // right bracket, ')'
T_LEFT = DSN_LEFT, // left bracket, '('
T_STRING = DSN_STRING, // a quoted string, stripped of the quotes
T_EOF = DSN_EOF, // special case for end of file
"
)
set( sourceFileHeader
"
/*
* Do not modify this file it was automatically generated by the TokenList2DsnLexer CMake
* script.
*
* Include this file in your lexer class to provide the keywords for you DSN lexer.
*/
#include \"fctsys.h\"
#include \"macros.h\"
#include \"${result}_base.h\"
namespace DSN {
#define TOKDEF(x) { #x, T_##x }
const KEYWORD ${result}_keywords[] = {
"
)
file( STRINGS ${inputFile} tmpTokens NO_HEX_CONVERSION )
foreach( tmpToken ${tmpTokens} )
math( EXPR lineCount "${lineCount} + 1" )
string( STRIP tmpToken "${tmpToken}" )
# Ignore empty lines.
if( tmpToken )
# Make sure token is valid.
string( REGEX MATCH "[a-z][_0-9a-z]*[0-9a-z]$" validToken "${tmpToken}" )
if( validToken STREQUAL tmpToken )
list( APPEND tokens "${validToken}" )
else( validToken STREQUAL tmpToken )
message( FATAL_ERROR
"Invalid token string \"${tmpToken}\" at line ${lineCount} in file "
"<${inputFile}>." )
endif( validToken STREQUAL tmpToken )
endif( tmpToken )
endforeach( tmpToken ${tmpTokens} )
list( SORT tokens )
# Check for duplicates.
list( LENGTH tokens tokensBefore )
list( REMOVE_DUPLICATES tokens )
list( LENGTH tokens tokensAfter )
if( NOT ( tokensBefore EQUAL tokensAfter ) )
message( FATAL_ERROR "Duplicate tokens found in file <${inputFile}>." )
endif( NOT ( tokensBefore EQUAL tokensAfter ) )
file( WRITE "${includeFileName}" "${includeFileHeader}" )
file( WRITE "${sourceFileName}" "${sourceFileHeader}" )
set( lineCount 1 )
foreach( token ${tokens} )
if( lineCount EQUAL 1 )
file( APPEND "${includeFileName}" " T_${token} = 0" )
else( lineCount EQUAL 1 )
file( APPEND "${includeFileName}" " T_${token}" )
endif( lineCount EQUAL 1 )
file(APPEND "${sourceFileName}" " TOKDEF( ${token} )" )
if( lineCount EQUAL tokensAfter )
file( APPEND "${includeFileName}" "\n" )
file( APPEND "${sourceFileName}" "\n" )
else( lineCount EQUAL tokensAfter )
file( APPEND "${includeFileName}" ",\n" )
file( APPEND "${sourceFileName}" ",\n" )
endif( lineCount EQUAL tokensAfter )
math( EXPR lineCount "${lineCount} + 1" )
endforeach( token ${tokens} )
file( APPEND "${includeFileName}"
"};
} // End namespace DSN
#endif // End ${headerTag}
"
)
file( APPEND "${sourceFileName}"
"};
const unsigned ${result}_keyword_count = DIM( ${result}_keywords );
} // End namespace DSN
"
)
...@@ -235,10 +235,8 @@ void WinEDA_DrawFrame::AddMenuZoomAndGrid( wxMenu* MasterMenu ) ...@@ -235,10 +235,8 @@ void WinEDA_DrawFrame::AddMenuZoomAndGrid( wxMenu* MasterMenu )
for( unsigned i = 0; i < screen->m_GridList.GetCount(); i++ ) for( unsigned i = 0; i < screen->m_GridList.GetCount(); i++ )
{ {
tmp = screen->m_GridList[i]; tmp = screen->m_GridList[i];
double gridValueInch = To_User_Unit( 0, tmp.m_Size.x, double gridValueInch = To_User_Unit( 0, tmp.m_Size.x, m_InternalUnits );
m_InternalUnits ); double gridValue_mm = To_User_Unit( 1, tmp.m_Size.x, m_InternalUnits );
double gridValue_mm = To_User_Unit( 1, tmp.m_Size.x,
m_InternalUnits );
if( tmp.m_Id == ID_POPUP_GRID_USER ) if( tmp.m_Id == ID_POPUP_GRID_USER )
{ {
......
...@@ -32,6 +32,7 @@ set(EESCHEMA_SRCS ...@@ -32,6 +32,7 @@ set(EESCHEMA_SRCS
class_text-label.cpp class_text-label.cpp
classes_body_items.cpp classes_body_items.cpp
cleanup.cpp cleanup.cpp
cmp_library_lexer.cpp
controle.cpp controle.cpp
cross-probing.cpp cross-probing.cpp
dangling_ends.cpp dangling_ends.cpp
...@@ -153,13 +154,33 @@ if(APPLE) ...@@ -153,13 +154,33 @@ if(APPLE)
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.eeschema) set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.eeschema)
endif(APPLE) endif(APPLE)
add_executable(eeschema WIN32 MACOSX_BUNDLE ${EESCHEMA_SRCS} ${EESCHEMA_EXTRA_SRCS} ${EESCHEMA_RESOURCES}) # Generate DSN lexer header and source files for the component library file
# format.
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_base.h
COMMAND ${CMAKE_COMMAND}
-DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_base.h(.cpp)
from ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst"
)
set_source_files_properties( cmp_library_lexer.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_base.h
)
add_executable(eeschema WIN32 MACOSX_BUNDLE ${EESCHEMA_SRCS} ${EESCHEMA_EXTRA_SRCS}
${EESCHEMA_RESOURCES})
if(APPLE) if(APPLE)
set_target_properties(eeschema PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(eeschema PROPERTIES MACOSX_BUNDLE_INFO_PLIST
${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE) endif(APPLE)
target_link_libraries(eeschema common bitmaps kbool polygon ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES}) target_link_libraries(eeschema common bitmaps kbool polygon ${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES})
install(TARGETS eeschema install(TARGETS eeschema
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
......
...@@ -135,3 +135,15 @@ EDA_Rect SCH_MARKER::GetBoundingBox() ...@@ -135,3 +135,15 @@ EDA_Rect SCH_MARKER::GetBoundingBox()
return GetBoundingBoxMarker(); return GetBoundingBoxMarker();
} }
void SCH_MARKER::DisplayInfo( WinEDA_DrawFrame* aFrame )
{
if( aFrame == NULL )
return;
wxString msg;
aFrame->ClearMsgPanel();
aFrame->AppendMsgPanel( _( "Electronics rule check error" ),
GetReporter().GetErrorText(), DARKRED );
}
...@@ -100,13 +100,20 @@ public: ...@@ -100,13 +100,20 @@ public:
} }
/** /**
* Compare DRC marker main and auxilary text against search string. * Compare DRC marker main and auxiliary text against search string.
* *
* @param aSearchData - Criteria to search against. * @param aSearchData - Criteria to search against.
* @return True if the DRC main or auxiliary text matches the search criteria. * @return True if the DRC main or auxiliary text matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData ); virtual bool Matches( wxFindReplaceData& aSearchData );
/**
* Show the marker electronics rule check error on the message panel.
*
* @param aFrame - Top window that owns the message panel.
*/
void DisplayInfo( WinEDA_DrawFrame* aFrame );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
......
header
version
name
author
comment
license
url
copyright
symbol
component
field
tags
docs
drawing
arc
start
end
rectangle
position
width
height
polyline
circle
center
radius
text
orientation
pin
number
length
electical_type
style
fill_style
/*
* Do not delete this file. It will eventually become the new component
* library file DSN lexer which will replace the current library and library
* document file formats.
*/
#include "cmp_library_base.cpp"
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
* *
* For some items, characteristics are displayed on the screen. * For some items, characteristics are displayed on the screen.
*/ */
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin )
bool IncludePin )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
wxString msg; wxString msg;
...@@ -115,10 +114,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( ...@@ -115,10 +114,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay(
* *
* For some items, characteristics are displayed on the screen. * For some items, characteristics are displayed on the screen.
*/ */
SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint& refpoint,
const wxPoint& refpoint, bool IncludePin )
bool
IncludePin )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
LIB_PIN* Pin; LIB_PIN* Pin;
...@@ -129,9 +126,10 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( ...@@ -129,9 +126,10 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay(
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM );
if( DrawStruct ) if( DrawStruct )
{ {
ClearMsgPanel(); DrawStruct->DisplayInfo( this );
return DrawStruct; return DrawStruct;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM );
if( DrawStruct ) if( DrawStruct )
{ {
......
...@@ -80,8 +80,7 @@ void WinEDA_SchematicFrame::LoadLibraries( void ) ...@@ -80,8 +80,7 @@ void WinEDA_SchematicFrame::LoadLibraries( void )
{ {
wxString prompt; wxString prompt;
prompt.Printf( _( "Component library <%s> failed to load.\n\n\ prompt.Printf( _( "Component library <%s> failed to load.\n\n\Error: %s" ),
Error: %s" ),
GetChars( fn.GetFullPath() ), GetChars( fn.GetFullPath() ),
GetChars( errMsg ) ); GetChars( errMsg ) );
DisplayError( this, prompt ); DisplayError( this, prompt );
......
...@@ -99,7 +99,8 @@ IMPLEMENT_APP( WinEDA_App ) ...@@ -99,7 +99,8 @@ IMPLEMENT_APP( WinEDA_App )
/* MacOSX: Needed for file association /* MacOSX: Needed for file association
* http://wiki.wxwidgets.org/WxMac-specific_topics * http://wiki.wxwidgets.org/WxMac-specific_topics
*/ */
void WinEDA_App::MacOpenFile(const wxString &fileName) { void WinEDA_App::MacOpenFile( const wxString &fileName )
{
wxFileName filename = fileName; wxFileName filename = fileName;
WinEDA_SchematicFrame * frame = ((WinEDA_SchematicFrame*) GetTopWindow()); WinEDA_SchematicFrame * frame = ((WinEDA_SchematicFrame*) GetTopWindow());
...@@ -168,9 +169,12 @@ bool WinEDA_App::OnInit() ...@@ -168,9 +169,12 @@ bool WinEDA_App::OnInit()
/* Load file specified in the command line. */ /* Load file specified in the command line. */
if( filename.IsOk() ) if( filename.IsOk() )
{ {
wxLogDebug( wxT( "Loading schematic file " ) + filename.GetFullPath() );
if( filename.GetExt() != SchematicFileExtension ) if( filename.GetExt() != SchematicFileExtension )
filename.SetExt( SchematicFileExtension ); filename.SetExt( SchematicFileExtension );
wxSetWorkingDirectory( filename.GetPath() ); wxSetWorkingDirectory( filename.GetPath() );
if( frame->DrawPanel if( frame->DrawPanel
&& frame->LoadOneEEProject( filename.GetFullPath(), false ) <= 0 ) && frame->LoadOneEEProject( filename.GetFullPath(), false ) <= 0 )
frame->DrawPanel->Refresh( true ); frame->DrawPanel->Refresh( true );
......
...@@ -50,8 +50,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) ...@@ -50,8 +50,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
* Schematic root file and its subhierarchies, the configuration and the libs * Schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded) * which are not already loaded)
*/ */
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew )
bool IsNew )
{ {
SCH_SCREEN* screen; SCH_SCREEN* screen;
wxString FullFileName, msg; wxString FullFileName, msg;
...@@ -59,8 +58,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -59,8 +58,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
EDA_ScreenList ScreenList; EDA_ScreenList ScreenList;
for( screen = ScreenList.GetFirst(); screen != NULL; for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
screen = ScreenList.GetNext() )
{ {
if( screen->IsModify() ) if( screen->IsModify() )
break; break;
...@@ -157,9 +155,11 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -157,9 +155,11 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
* and after (due to code change): <root_name>-cache.lib * and after (due to code change): <root_name>-cache.lib
* so if the <name>-cache.lib is not found, the old way will be tried * so if the <name>-cache.lib is not found, the old way will be tried
*/ */
bool use_oldcachename = false;
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->m_AssociatedScreen->m_FileName;
bool use_oldcachename = false;
wxString cachename = fn.GetName() + wxT("-cache"); wxString cachename = fn.GetName() + wxT("-cache");
fn.SetName( cachename ); fn.SetName( cachename );
fn.SetExt( CompLibFileExtension ); fn.SetExt( CompLibFileExtension );
if( ! fn.FileExists() ) if( ! fn.FileExists() )
...@@ -197,8 +197,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -197,8 +197,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
{ {
wxString prompt; wxString prompt;
prompt.Printf( _( "Component library <%s> failed to load.\n\n\ prompt.Printf( _( "Component library <%s> failed to load.\n\n\Error: %s" ),
Error: %s" ),
GetChars( fn.GetFullPath() ), GetChars( fn.GetFullPath() ),
GetChars( errMsg ) ); GetChars( errMsg ) );
DisplayError( this, prompt ); DisplayError( this, prompt );
......
...@@ -24,21 +24,16 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ); ...@@ -24,21 +24,16 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel ); static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel );
static void ListeObjetConnection( SCH_SHEET_PATH* sheetlist, static void ListeObjetConnection( SCH_SHEET_PATH* sheetlist,
NETLIST_OBJECT_LIST& aNetItemBuffer ); NETLIST_OBJECT_LIST& aNetItemBuffer );
static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer, static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer, NETLIST_OBJECT& ObjNet );
NETLIST_OBJECT& ObjNet ); static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start );
static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, int IsBus, int start );
int start );
static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, int IsBus,
int start );
static void LabelConnect( NETLIST_OBJECT* Label ); static void LabelConnect( NETLIST_OBJECT* Label );
static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer ); static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer );
static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer ); static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer );
// Sort functions used here: // Sort functions used here:
static bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, static bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
const NETLIST_OBJECT* Objet2 ); static bool SortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
static bool SortItemsBySheet( const NETLIST_OBJECT* Objet1,
const NETLIST_OBJECT* Objet2 );
static int FirstNumWireBus, LastNumWireBus, RootBusNameLength; static int FirstNumWireBus, LastNumWireBus, RootBusNameLength;
static int LastNetCode, LastBusNetCode; static int LastNetCode, LastBusNetCode;
...@@ -86,7 +81,7 @@ void WinEDA_SchematicFrame::BuildNetListBase() ...@@ -86,7 +81,7 @@ void WinEDA_SchematicFrame::BuildNetListBase()
NetNumber = 1; NetNumber = 1;
activity = _( "List" ); activity = _( "Building net list:" );
SetStatusText( activity ); SetStatusText( activity );
FreeNetObjectsList( g_NetObjectslist ); FreeNetObjectsList( g_NetObjectslist );
...@@ -103,16 +98,14 @@ void WinEDA_SchematicFrame::BuildNetListBase() ...@@ -103,16 +98,14 @@ void WinEDA_SchematicFrame::BuildNetListBase()
if( g_NetObjectslist.size() == 0 ) if( g_NetObjectslist.size() == 0 )
return; // no objects return; // no objects
activity.Empty(); activity << wxT( " " ) << _( "net count =" ) << wxT( " " ) << g_NetObjectslist.size();
activity << wxT( " " ) << _( "NbItems" ) << wxT( " " ) <<
g_NetObjectslist.size();
SetStatusText( activity ); SetStatusText( activity );
/* Sort objects by Sheet */ /* Sort objects by Sheet */
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsBySheet ); sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsBySheet );
activity << wxT( "; " ) << _( "Conn" ); activity << wxT( ", " ) << _( "connections" ) << wxT( "..." );
SetStatusText( activity ); SetStatusText( activity );
sheet = &(g_NetObjectslist[0]->m_SheetList); sheet = &(g_NetObjectslist[0]->m_SheetList);
...@@ -214,13 +207,13 @@ void WinEDA_SchematicFrame::BuildNetListBase() ...@@ -214,13 +207,13 @@ void WinEDA_SchematicFrame::BuildNetListBase()
#endif #endif
activity << wxT( " " ) << _( "Done" ); activity << _( "done" );
SetStatusText( activity ); SetStatusText( activity );
/* Updating the Bus Labels Netcode connected by Bus */ /* Updating the Bus Labels Netcode connected by Bus */
ConnectBusLabels( g_NetObjectslist ); ConnectBusLabels( g_NetObjectslist );
activity << wxT( "; " ) << _( "Labels" ); activity << wxT( ", " ) << _( "bus labels" ) << wxT( "..." );;
SetStatusText( activity ); SetStatusText( activity );
/* Group objects by label. */ /* Group objects by label. */
...@@ -259,11 +252,11 @@ void WinEDA_SchematicFrame::BuildNetListBase() ...@@ -259,11 +252,11 @@ void WinEDA_SchematicFrame::BuildNetListBase()
dumpNetTable(); dumpNetTable();
#endif #endif
activity << wxT( " " ) << _( "Done" ); activity << _( "done" );
SetStatusText( activity ); SetStatusText( activity );
/* Connection hierarchy. */ /* Connection hierarchy. */
activity << wxT( "; " ) << _( "Hierar." ); activity << wxT( ", " ) << _( "hierarchy..." );
SetStatusText( activity ); SetStatusText( activity );
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
{ {
...@@ -280,7 +273,7 @@ void WinEDA_SchematicFrame::BuildNetListBase() ...@@ -280,7 +273,7 @@ void WinEDA_SchematicFrame::BuildNetListBase()
dumpNetTable(); dumpNetTable();
#endif #endif
activity << wxT( " " ) << _( "Done" ); activity << _( "done" );
SetStatusText( activity ); SetStatusText( activity );
/* Compress numbers of Netcode having consecutive values. */ /* Compress numbers of Netcode having consecutive values. */
......
...@@ -68,7 +68,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -68,7 +68,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
else else
{ {
DrawStruct = SchematicGeneralLocateAndDisplay(true); DrawStruct = SchematicGeneralLocateAndDisplay( true );
} }
} }
......
...@@ -22,17 +22,14 @@ ...@@ -22,17 +22,14 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#define EraseItem( item ) item->Draw( Panel, DC, wxPoint( 0,\ #define EraseItem( item ) item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, \
0 ), -1, g_XorMode, NULL,\
DefaultTransformMatrix ) DefaultTransformMatrix )
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ComputeArc( LIB_ARC* DrawItem, wxPoint ArcCentre ); static void ComputeArc( LIB_ARC* DrawItem, wxPoint ArcCentre );
static void ComputeArcRadiusAngles( LIB_ARC* arc ); static void ComputeArcRadiusAngles( LIB_ARC* arc );
static wxPoint ComputeCircumCenter( wxPoint A, wxPoint B, wxPoint C ); static wxPoint ComputeCircumCenter( wxPoint A, wxPoint B, wxPoint C );
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
wxDC* DC,
bool erase );
static wxPoint InitPosition, StartCursor, ItemPreviousPos; static wxPoint InitPosition, StartCursor, ItemPreviousPos;
...@@ -309,8 +306,7 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry, ...@@ -309,8 +306,7 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
break; break;
default: default:
DisplayError( this, wxT( "WinEDA_LibeditFrame::CreateGraphicItem() \ DisplayError( this, wxT( "WinEDA_LibeditFrame::CreateGraphicItem() error" ) );
error" ) );
return NULL; return NULL;
} }
...@@ -380,9 +376,7 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC ) ...@@ -380,9 +376,7 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
/* /*
* Redraw the graphic shape while moving * Redraw the graphic shape while moving
*/ */
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
wxDC* DC,
bool erase )
{ {
LIB_DRAW_ITEM* item; LIB_DRAW_ITEM* item;
...@@ -398,8 +392,7 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, ...@@ -398,8 +392,7 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
if( erase ) if( erase )
{ {
pos = ItemPreviousPos - StartCursor; pos = ItemPreviousPos - StartCursor;
item->Draw( panel, DC, pos, -1, g_XorMode, NULL, item->Draw( panel, DC, pos, -1, g_XorMode, NULL, DefaultTransformMatrix );
DefaultTransformMatrix );
} }
/* Redraw moved shape */ /* Redraw moved shape */
...@@ -451,7 +444,7 @@ void WinEDA_LibeditFrame::StartModifyDrawSymbol( wxDC* DC ) ...@@ -451,7 +444,7 @@ void WinEDA_LibeditFrame::StartModifyDrawSymbol( wxDC* DC )
wxPoint endPoint = ( (LIB_ARC*) m_drawItem )->m_ArcEnd; wxPoint endPoint = ( (LIB_ARC*) m_drawItem )->m_ArcEnd;
wxPoint centerPoint = ( (LIB_ARC*) m_drawItem )->m_Pos; wxPoint centerPoint = ( (LIB_ARC*) m_drawItem )->m_Pos;
wxPoint middlePoint = wxPoint( (startPoint.x + endPoint.x) / 2, wxPoint middlePoint = wxPoint( (startPoint.x + endPoint.x) / 2,
(startPoint.y + endPoint.y) / 2 ); (startPoint.y + endPoint.y) / 2 );
wxPoint centerVector = centerPoint - middlePoint; wxPoint centerVector = centerPoint - middlePoint;
wxPoint startEndVector = TwoPointVector( startPoint, endPoint ); wxPoint startEndVector = TwoPointVector( startPoint, endPoint );
arcState.distanceCenter = EuclideanNorm( centerVector ); arcState.distanceCenter = EuclideanNorm( centerVector );
...@@ -551,7 +544,8 @@ void WinEDA_LibeditFrame::StartModifyDrawSymbol( wxDC* DC ) ...@@ -551,7 +544,8 @@ void WinEDA_LibeditFrame::StartModifyDrawSymbol( wxDC* DC )
+ (cursor - startPoint).y * (cursor - startPoint).y; + (cursor - startPoint).y * (cursor - startPoint).y;
// Find the right index of the point to be dragged // Find the right index of the point to be dragged
BOOST_FOREACH( wxPoint point, ( ( (LIB_POLYLINE*) m_drawItem )->m_PolyPoints ) ) { BOOST_FOREACH( wxPoint point, ( ( (LIB_POLYLINE*) m_drawItem )->m_PolyPoints ) )
{
int distancePoint = (cursor - point).x * (cursor - point).x + int distancePoint = (cursor - point).x * (cursor - point).x +
(cursor - point).y * (cursor - point).y; (cursor - point).y * (cursor - point).y;
...@@ -652,7 +646,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -652,7 +646,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
arcState.endPoint = ( (LIB_ARC*) item )->m_ArcEnd; arcState.endPoint = ( (LIB_ARC*) item )->m_ArcEnd;
wxPoint middlePoint = wxPoint( (arcState.startPoint.x + arcState.endPoint.x) / 2, wxPoint middlePoint = wxPoint( (arcState.startPoint.x + arcState.endPoint.x) / 2,
(arcState.startPoint.y + arcState.endPoint.y) / 2 ); (arcState.startPoint.y + arcState.endPoint.y) / 2 );
// If the distance is too small, use the old center point // If the distance is too small, use the old center point
...@@ -662,7 +656,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -662,7 +656,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
> MINIMUM_SELECTION_DISTANCE ) > MINIMUM_SELECTION_DISTANCE )
{ {
newCenterPoint = ComputeCircumCenter( arcState.startPoint, newCenterPoint = ComputeCircumCenter( arcState.startPoint,
currentCursorPosition, arcState.endPoint ); currentCursorPosition,
arcState.endPoint );
} }
else else
{ {
...@@ -670,14 +665,18 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -670,14 +665,18 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
// Determine if the arc angle is larger than 180 degrees -> this happens if both // Determine if the arc angle is larger than 180 degrees -> this happens if both
// points (cursor position, center point) lie on the same side of the vector start-end // points (cursor position, center point) lie on the same side of the vector
int crossA = CrossProduct( TwoPointVector( arcState.startPoint, arcState.endPoint ), // start-end
TwoPointVector( arcState.endPoint, int crossA = CrossProduct( TwoPointVector( arcState.startPoint,
currentCursorPosition ) ); arcState.endPoint ),
int crossB = CrossProduct( TwoPointVector( arcState.startPoint, arcState.endPoint ), TwoPointVector( arcState.endPoint,
TwoPointVector( arcState.endPoint, newCenterPoint ) ); currentCursorPosition ) );
int crossB = CrossProduct( TwoPointVector( arcState.startPoint,
bool isLarger180degrees = (crossA < 0 && crossB < 0) || (crossA >=0 && crossB >=0); arcState.endPoint ),
TwoPointVector( arcState.endPoint, newCenterPoint ) );
bool isLarger180degrees = ( crossA < 0 && crossB < 0 ) ||
( crossA >= 0 && crossB >= 0 );
if( isLarger180degrees ) if( isLarger180degrees )
newCenterPoint = ( (LIB_ARC*) item )->m_Pos; newCenterPoint = ( (LIB_ARC*) item )->m_Pos;
...@@ -687,7 +686,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -687,7 +686,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
// Compute the new center point when the start/end points are modified // Compute the new center point when the start/end points are modified
wxPoint middlePoint = wxPoint( (arcState.startPoint.x + arcState.endPoint.x) / 2, wxPoint middlePoint = wxPoint( (arcState.startPoint.x + arcState.endPoint.x) / 2,
(arcState.startPoint.y + arcState.endPoint.y) / 2 ); (arcState.startPoint.y + arcState.endPoint.y) / 2 );
wxPoint startEndVector = TwoPointVector( arcState.startPoint, arcState.endPoint ); wxPoint startEndVector = TwoPointVector( arcState.startPoint, arcState.endPoint );
wxPoint perpendicularVector = wxPoint( -startEndVector.y, startEndVector.x ); wxPoint perpendicularVector = wxPoint( -startEndVector.y, startEndVector.x );
...@@ -699,11 +698,11 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -699,11 +698,11 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
lengthPerpendicularVector = 1e-1; lengthPerpendicularVector = 1e-1;
perpendicularVector.x = (int) ( (double) perpendicularVector.x * perpendicularVector.x = (int) ( (double) perpendicularVector.x *
arcState.distanceCenter / arcState.distanceCenter /
lengthPerpendicularVector ) * arcState.direction; lengthPerpendicularVector ) * arcState.direction;
perpendicularVector.y = (int) ( (double) perpendicularVector.y * perpendicularVector.y = (int) ( (double) perpendicularVector.y *
arcState.distanceCenter / arcState.distanceCenter /
lengthPerpendicularVector ) * arcState.direction; lengthPerpendicularVector ) * arcState.direction;
newCenterPoint = middlePoint + perpendicularVector; newCenterPoint = middlePoint + perpendicularVector;
...@@ -804,14 +803,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -804,14 +803,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( arcState.stateDrawArc == 1 ) if( arcState.stateDrawArc == 1 )
{ {
int Color = ReturnLayerColor( LAYER_DEVICE ); int Color = ReturnLayerColor( LAYER_DEVICE );
GRLine( &panel->m_ClipBox, GRLine( &panel->m_ClipBox, DC, arcState.startPoint.x, -arcState.startPoint.y,
DC, arcState.endPoint.x, -arcState.endPoint.y, 0, Color );
arcState.startPoint.x,
-arcState.startPoint.y,
arcState.endPoint.x,
-arcState.endPoint.y,
0,
Color );
} }
else else
{ {
...@@ -973,8 +966,8 @@ static void ComputeArcRadiusAngles( LIB_ARC* arc ) ...@@ -973,8 +966,8 @@ static void ComputeArcRadiusAngles( LIB_ARC* arc )
/* /*
* Routine for adjusting the parameters of the arc currently being drawn. * Routine for adjusting the parameters of the arc currently being drawn.
* Calculates the center, radius, angles for the arc current * Calculates the center, radius, angles for the arc current
* Passes through the points arcState.startPoint.x, arcState.endPoint.x Y and Y with the nearest center * Passes through the points arcState.startPoint.x, arcState.endPoint.x Y and Y with the
* of the mouse position. * nearest center of the mouse position.
* Note: The center is obviously not on the grid * Note: The center is obviously not on the grid
*/ */
static void ComputeArc( LIB_ARC* DrawItem, wxPoint ArcCentre ) static void ComputeArc( LIB_ARC* DrawItem, wxPoint ArcCentre )
...@@ -1100,8 +1093,7 @@ static wxPoint ComputeCircumCenter( wxPoint A, wxPoint B, wxPoint C ) ...@@ -1100,8 +1093,7 @@ static wxPoint ComputeCircumCenter( wxPoint A, wxPoint B, wxPoint C )
*/ */
void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
{ {
if( m_drawItem == NULL if( m_drawItem == NULL || m_drawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
|| m_drawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
return; return;
LIB_POLYLINE* Poly = (LIB_POLYLINE*) m_drawItem; LIB_POLYLINE* Poly = (LIB_POLYLINE*) m_drawItem;
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <string> #include <string>
#include "fctsys.h" #include "fctsys.h"
#include "pcbnew.h"
#include "richio.h" #include "richio.h"
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "dsnlexer.h" #include "dsnlexer.h"
#include "pcbnew.h"
class TYPE_COLLECTOR; // outside the DSN namespace class TYPE_COLLECTOR; // outside the DSN namespace
......
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