diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index ab345dcd52..cbe78feb2c 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -24,6 +24,34 @@ #include "bitmaps.h" +// ----------------- +// helper function (from wxWidgets, opengl/cube.cpp sample +// ----------------- +void CheckGLError() +{ + GLenum errLast = GL_NO_ERROR; + + for ( ;; ) + { + GLenum err = glGetError(); + if ( err == GL_NO_ERROR ) + return; + + // normally the error is reset by the call to glGetError() but if + // glGetError() itself returns an error, we risk looping forever here + // so check that we get a different error than the last time + if ( err == errLast ) + { + wxLogError(wxT("OpenGL error state couldn't be reset.")); + return; + } + + errLast = err; + + wxLogError(wxT("OpenGL error %d"), err); + } +} + /* * Pcb3D_GLCanvas implementation */ @@ -519,7 +547,7 @@ void Pcb3D_GLCanvas::InitGL() { // Ratio width / height of the window display double ratio_HV = (double) size.x / size.y; - + // Initialize Projection Matrix for Perspective View gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 10 ); } @@ -538,6 +566,8 @@ void Pcb3D_GLCanvas::InitGL() // Setup light souces: SetLights(); + + CheckGLError(); } @@ -603,7 +633,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) GLint x; GLint y; } viewport; - + // Build image from the 3D buffer wxWindowUpdateLocker noUpdates( this ); glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport ); diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 13fd130157..b6df68fdac 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -20,6 +20,8 @@ #error Please set wxUSE_GLCANVAS to 1 in setup.h. #endif +extern void CheckGLError(); + static void Draw3D_FilledCircle( double posx, double posy, double rayon, double hole_rayon, double zpos ); static void Draw3D_FilledSegment( double startx, double starty, @@ -348,9 +350,8 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() glEndList(); /* Test for errors */ - GLenum err = glGetError(); - if( err != GL_NO_ERROR ) - DisplayError( this, wxT( "Error in GL commands" ) ); + CheckGLError(); + return m_gllist; } @@ -786,8 +787,6 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) delta_cx, delta_cy, xc, yc; int angle, delta_angle; - int coord[4][2]; - double fcoord[8][2], f_hole_coord[8][2]; double scale; double zpos; wxPoint shape_pos; @@ -917,33 +916,18 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) break; case PAD_RECT: - case PAD_TRAPEZOID: { - int ddx, ddy; - ddx = m_DeltaSize.x >> 1; - ddy = m_DeltaSize.y >> 1; - - coord[0][0] = -dx - ddy; - coord[0][1] = +dy + ddx; - - coord[1][0] = -dx + ddy; - coord[1][1] = -dy - ddx; - - coord[2][0] = +dx - ddy; - coord[2][1] = -dy + ddx; - - coord[3][0] = +dx + ddy; - coord[3][1] = +dy - ddx; - + wxPoint coord[5]; + wxRealPoint fcoord[8], f_hole_coord[8]; + BuildPadPolygon( coord, wxSize(0,0), angle ); for( ii = 0; ii < 4; ii++ ) { - RotatePoint( &coord[ii][0], &coord[ii][1], angle ); - coord[ii][0] += ux0; - coord[ii][1] += uy0; + coord[ii].x += ux0; + coord[ii].y += uy0; ll = ii * 2; - fcoord[ll][0] = coord[ii][0] *scale; - fcoord[ll][1] = coord[ii][1] *scale; + fcoord[ll].x = coord[ii].x *scale; + fcoord[ll].y = coord[ii].y *scale; } for( ii = 0; ii < 7; ii += 2 ) @@ -951,18 +935,17 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) ll = ii + 2; if( ll > 7 ) ll -= 8; - fcoord[ii + 1][0] = (fcoord[ii][0] + fcoord[ll][0]) / 2; - fcoord[ii + 1][1] = (fcoord[ii][1] + fcoord[ll][1]) / 2; + fcoord[ii + 1].x = (fcoord[ii].x + fcoord[ll].x) / 2; + fcoord[ii + 1].y = (fcoord[ii].y + fcoord[ll].y) / 2; } for( ii = 0; ii < 8; ii++ ) { - f_hole_coord[ii][0] = -hole * 0.707; - f_hole_coord[ii][1] = hole * 0.707; - RotatePoint( &f_hole_coord[ii][0], &f_hole_coord[ii][1], - angle - (ii * 450) ); - f_hole_coord[ii][0] += drillx; - f_hole_coord[ii][1] += drilly; + f_hole_coord[ii].x = -hole * 0.707; + f_hole_coord[ii].y = hole * 0.707; + RotatePoint( &f_hole_coord[ii].x, &f_hole_coord[ii].y, angle - (ii * 450) ); + f_hole_coord[ii].x += drillx; + f_hole_coord[ii].y += drilly; } for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ ) @@ -991,12 +974,12 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) glBegin( GL_QUAD_STRIP ); for( ii = 0; ii < 8; ii++ ) { - glVertex3f( f_hole_coord[ii][0], -f_hole_coord[ii][1], zpos ); - glVertex3f( fcoord[ii][0], -fcoord[ii][1], zpos ); + glVertex3f( f_hole_coord[ii].x, -f_hole_coord[ii].y, zpos ); + glVertex3f( fcoord[ii].x, -fcoord[ii].y, zpos ); } - glVertex3f( f_hole_coord[0][0], -f_hole_coord[0][1], zpos ); - glVertex3f( fcoord[0][0], -fcoord[0][1], zpos ); + glVertex3f( f_hole_coord[0].x, -f_hole_coord[0].y, zpos ); + glVertex3f( fcoord[0].x, -fcoord[0].y, zpos ); glEnd(); } } diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp index 3e744e3d80..f2dcdbffa9 100644 --- a/3d-viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_toolbar.cpp @@ -87,11 +87,11 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar() _( "Move up ^" ) ); m_HToolBar->AddTool( ID_MOVE3D_DOWN, wxEmptyString, wxBitmap( down_xpm ), - _( "Move down" ) ); - + _( "Move down v" ) ); + m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_ORTHO, wxEmptyString, wxBitmap( ortho_xpm ), - _( "Enable/Disable ortographic projection" ), + _( "Enable/Disable orthographic projection" ), wxITEM_CHECK ); m_HToolBar->Realize(); diff --git a/AUTHORS.txt b/AUTHORS.txt index 6a33c2dc5c..00f56b44d5 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -1,17 +1,13 @@ -* Copyright (C) 1992-2009 Jean-Pierre Charras -* Copyright (C) 1992-2009 Kicad Developers Team +* Copyright (C) 1992-2010 Jean-Pierre Charras +* Copyright (C) 1992-2010 Kicad Developers Team * under GNU General Public License (see copyright.txt) -== Main Author +== Main Authors Jean-Pierre Charras -IUT1 GEII2 -Universite Joseph Fourier (U.J.F.) -Saint Martin d'Hères (38402) -Laboratiore GIPSA-Lab -Saint Martin d'Hères +Dick Hollenbeck +Wayne Stambaugh == Contributors -Dick Hollenbeck Hauptmech Jerry Jacobs Jonas Diemer @@ -21,7 +17,6 @@ Marco Serantoni (OSX maintener) Rok Markovic Tim Hanson Vesa Solonen -Wayne Stambaugh See also CHANGELOG.txt for contributors. diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9307fcd490..952aa093a6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,7 +4,21 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. -2010-oct-15, UPDATE Jean-Pierre Charras +2010-nov-3 UPDATE Wayne Stambaugh +================================================================================ +++common + * Initial ground work for using Boost container for storing draw items + instead of internal linked list. +++EESchema + * Move tests for dangling end code back into schematic objects. + * Add clear draw object state helper to SCH_SCREEN object. + * Add support for schematic objects to keep temporary list of connection + objects for dangling end and other connection related tests. + * Rearrange schematic label object code. + * Remove duplicate error message boxes when loading schematic items. + + +2010-oct-28, UPDATE Jean-Pierre Charras ================================================================================ PolyLine.cpp: remove unused method CPolyLine::TestPointInsideContour() which was a duplicate of diff --git a/bitmaps/CMakeLists.txt b/bitmaps/CMakeLists.txt index e842f91dfd..af21302ab3 100644 --- a/bitmaps/CMakeLists.txt +++ b/bitmaps/CMakeLists.txt @@ -161,6 +161,7 @@ set(BITMAP_SRCS icon_pcbnew.xpm icon_txt.xpm import3d.xpm + import_cmp_from_lib.xpm import_hierarchical_label.xpm Import_Module.xpm import.xpm diff --git a/bitmaps/import_cmp_from_lib.xpm b/bitmaps/import_cmp_from_lib.xpm new file mode 100644 index 0000000000..98ef533e0c --- /dev/null +++ b/bitmaps/import_cmp_from_lib.xpm @@ -0,0 +1,38 @@ +/* XPM */ +const char *import_cmp_from_lib_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 16 1", +"O c #76787C", +"$ c #979A9C", +"= c #404440", +"; c #ACB1B5", +"# c #04BA04", +"+ c #CACCCC", +"o c #F5F6F7", +". c #2E3031", +" c None", +"* c #124912", +"@ c #049304", +"& c #505355", +"X c #0C290C", +"% c #046404", +"- c #DADBDB", +": c #83888C", +/* pixels */ +" .X ", +" ooO ", +" +o++. ", +" @#X$++.$ ", +" %#@X$+X.& ", +" *##@%%%%=&.=.. ", +" OX######%Oooo-.", +" $&*@@##%Ooo-; ", +" :;+:&%@&ooo+: ", +" O;+$*=-oo-;X ", +" =:$+.oooo+O ", +" &O-+oooo; ", +" X&++--o+: ", +" .=O$$$ ", +" .XX ", +" " +}; diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 56f3fb3fc1..c71ea854f3 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -20,6 +20,7 @@ set(COMMON_SRCS block_commande.cpp build_version.cpp class_colors_design_settings.cpp + class_layerchoicebox.cpp class_marker_base.cpp class_plotter.cpp class_undoredo_container.cpp diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 2cd5f6b42c..8e85ca74f7 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -542,6 +542,22 @@ PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( ) } +void BASE_SCREEN::AddItem( EDA_BaseStruct* aItem ) +{ + wxCHECK_RET( aItem != NULL, wxT( "Attempt to add NULL item pointer to " ) + GetClass() + + wxT( "item list" ) ); + m_items.push_back( aItem ); +} + + +void BASE_SCREEN::InsertItem( EDA_ITEMS::iterator aIter, EDA_BaseStruct* aItem ) +{ + wxCHECK_RET( aItem != NULL, wxT( "Attempt to insert NULL item pointer to " ) + GetClass() + + wxT( "item list" ) ); + m_items.insert( aIter, aItem ); +} + + #if defined(DEBUG) /** * Function Show diff --git a/common/basicframe.cpp b/common/basicframe.cpp index d35dd65f8e..417abbcea6 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -259,7 +259,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) } else { - msg.Printf( _( "Help file %s not found" ), GetChars( wxGetApp().m_HelpFileName ) ); + msg.Printf( _( "Help file %s not found." ), GetChars( wxGetApp().m_HelpFileName ) ); DisplayError( this, msg ); } diff --git a/common/class_layerchoicebox.cpp b/common/class_layerchoicebox.cpp new file mode 100644 index 0000000000..8679dfc8ad --- /dev/null +++ b/common/class_layerchoicebox.cpp @@ -0,0 +1,181 @@ +#include "common.h" +#include "pcbnew.h" +#include "wxPcbStruct.h" +#include "class_board_design_settings.h" +#include "colors_selection.h" + +#include "bitmaps.h" +#include "pcbnew_id.h" + +#include "hotkeys.h" +#include "help_common_strings.h" + +#include +#include +#include +#include + +#include "class_layerchoicebox.h" + +/* class to display a layer list. + * + */ + +WinEDALayerChoiceBox::WinEDALayerChoiceBox( WinEDA_Toolbar* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + int n, const wxString choices[] ) : + wxBitmapComboBox( parent, id, wxEmptyString, pos, size, + n, choices, wxCB_READONLY ) +{ + m_layerorder = true; + m_layerhotkeys = true; + m_hotkeys = NULL; + + if( choices != NULL ) + ResyncBitmapOnly(); +} + + +WinEDALayerChoiceBox::WinEDALayerChoiceBox( WinEDA_Toolbar* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices ) : + wxBitmapComboBox( parent, id, wxEmptyString, pos, size, + choices, wxCB_READONLY ) +{ + m_layerorder = true; + m_layerhotkeys = true; + m_hotkeys = NULL; + + if( !choices.IsEmpty() ) + ResyncBitmapOnly(); +} + + +bool WinEDALayerChoiceBox::SetLayersOrdered( bool value ) +{ + m_layerorder = value; + return m_layerorder; +} + + +bool WinEDALayerChoiceBox::SetLayersHotkeys( bool value ) +{ + m_layerhotkeys = value; + return m_layerhotkeys; +} + + +// Get Current Item # +int WinEDALayerChoiceBox::GetChoice() +{ + return GetSelection(); +} + + +// Get Current Layer +int WinEDALayerChoiceBox::GetLayerSelection() +{ + return (long) GetClientData( GetSelection() ); +} + + +// Set Layer # +int WinEDALayerChoiceBox::SetLayerSelection( int layer ) +{ + int elements = GetCount(); + + for( int i = 0; i < elements; i++ ) + { + if( GetClientData( i ) == (void*) layer ) + { + if( GetSelection() != i ) // Element (i) is not selected + { + SetSelection( i ); + return i; + } + else + return i; //If element already selected; do nothing + } + } + + // Not Found + SetSelection( -1 ); + return -1; +} + + +// Reload the Layers +void WinEDALayerChoiceBox::Resync() +{ + WinEDA_BasePcbFrame* pcbFrame = (WinEDA_BasePcbFrame*) GetParent()->GetParent(); + BOARD* board = pcbFrame->GetBoard(); + + wxASSERT( board != NULL ); + + Clear(); + + static DECLARE_LAYERS_ORDER_LIST( layertranscode ); + static DECLARE_LAYERS_HOTKEY( layerhk ); + + for( int i = 0; i < LAYER_COUNT; i++ ) + { + wxBitmap layerbmp( 14, 14 ); + wxMemoryDC bmpDC; + wxBrush brush; + wxString layername; + int layerid = i; + + if( m_layerorder ) + layerid = layertranscode[i]; + + if( !board->IsLayerEnabled( layerid ) ) + continue; + + // Prepare Bitmap + bmpDC.SelectObject( layerbmp ); + brush.SetColour( MakeColour( board->GetLayerColor( layerid ) ) ); + brush.SetStyle( wxSOLID ); + + bmpDC.SetBrush( brush ); + bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() ); + bmpDC.SetBrush( *wxTRANSPARENT_BRUSH ); + bmpDC.SetPen( *wxBLACK_PEN ); + bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() ); + + layername = board->GetLayerName( layerid ); + + if( m_layerhotkeys && m_hotkeys != NULL ) + layername = AddHotkeyName( layername, m_hotkeys, layerhk[layerid], false ); + + Append( layername, layerbmp, (void*) layerid ); + } +} + +void WinEDALayerChoiceBox::ResyncBitmapOnly() +{ + WinEDA_BasePcbFrame* pcbFrame = (WinEDA_BasePcbFrame*) GetParent()->GetParent(); + BOARD* board = pcbFrame->GetBoard(); + + int elements = GetCount(); + for( int i = 0; i < elements; i++ ) + { + wxBitmap layerbmp( 14, 14 ); + wxMemoryDC bmpDC; + wxBrush brush; + wxString layername; + int layerid = i; + + // Prepare Bitmap + bmpDC.SelectObject( layerbmp ); + brush.SetColour( MakeColour( board->GetLayerColor( layerid ) ) ); + brush.SetStyle( wxSOLID ); + + bmpDC.SetBrush( brush ); + bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() ); + bmpDC.SetBrush( *wxTRANSPARENT_BRUSH ); + bmpDC.SetPen( *wxBLACK_PEN ); + bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() ); + + SetItemBitmap(i, layerbmp); + } +} diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 62f6cc15b4..f424f0e3f0 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -633,37 +633,43 @@ void WinEDA_DrawFrame::UpdateStatusBar() } /* The following sadly is an if eeschema/if pcbnew */ - wxString formatter; + wxString absformatter; + wxString locformatter; switch( g_UserUnit ) { case INCHES: if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) { - formatter = wxT( "X %.3f Y %.3f" ); + absformatter = wxT( "X %.3f Y %.3f" ); + locformatter = wxT( "dx %.3f dy %.3f" ); } else { - formatter = wxT( "X %.4f Y %.4f" ); + absformatter = wxT( "X %.4f Y %.4f" ); + locformatter = wxT( "dx %.4f dy %.4f" ); } break; case MILLIMETRES: if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) { - formatter = wxT( "X %.2f Y %.2f" ); + absformatter = wxT( "X %.2f Y %.2f" ); + locformatter = wxT( "dx %.2f dy %.2f" ); } else { - formatter = wxT( "X %.3f Y %.3f" ); + absformatter = wxT( "X %.3f Y %.3f" ); + locformatter = wxT( "dx %.3f dy %.3f" ); } break; case UNSCALED_UNITS: - formatter = wxT( "X %f Y %f" ); + absformatter = wxT( "X %f Y %f" ); + locformatter = wxT( "dx %f dy %f" ); break; } - Line.Printf( formatter, dXpos, dYpos ); + Line.Printf( absformatter, dXpos, dYpos ); SetStatusText( Line, 2 ); /* Display relative coordinates: */ @@ -678,7 +684,7 @@ void WinEDA_DrawFrame::UpdateStatusBar() } /* We already decided the formatter above */ - Line.Printf( formatter, dXpos, dYpos ); + Line.Printf( locformatter, dXpos, dYpos ); SetStatusText( Line, 3 ); } diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index 92d9c58730..ba4e6a3bac 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -224,18 +224,18 @@ bool DSNLEXER::IsSymbol( int aTok ) } -void DSNLEXER::ThrowIOError( wxString aText, int charOffset ) throw (IOError) +void DSNLEXER::ThrowIOError( wxString aText, int charOffset ) throw( IO_ERROR ) { // append to aText, do not overwrite aText << wxT(" ") << _("in") << wxT(" \"") << CurSource() << wxT("\" ") << _("on line") << wxT(" ") << reader->LineNumber() << wxT(" ") << _("at offset") << wxT(" ") << charOffset; - throw IOError( aText ); + throw IO_ERROR( aText ); } -void DSNLEXER::Expecting( int aTok ) throw( IOError ) +void DSNLEXER::Expecting( int aTok ) throw( IO_ERROR ) { wxString errText( _("Expecting") ); errText << wxT(" ") << GetTokenString( aTok ); @@ -243,7 +243,7 @@ void DSNLEXER::Expecting( int aTok ) throw( IOError ) } -void DSNLEXER::Expecting( const wxString& text ) throw( IOError ) +void DSNLEXER::Expecting( const wxString& text ) throw( IO_ERROR ) { wxString errText( _("Expecting") ); errText << wxT(" '") << text << wxT("'"); @@ -251,7 +251,7 @@ void DSNLEXER::Expecting( const wxString& text ) throw( IOError ) } -void DSNLEXER::Unexpected( int aTok ) throw( IOError ) +void DSNLEXER::Unexpected( int aTok ) throw( IO_ERROR ) { wxString errText( _("Unexpected") ); errText << wxT(" ") << GetTokenString( aTok ); @@ -259,7 +259,7 @@ void DSNLEXER::Unexpected( int aTok ) throw( IOError ) } -void DSNLEXER::Unexpected( const wxString& text ) throw( IOError ) +void DSNLEXER::Unexpected( const wxString& text ) throw( IO_ERROR ) { wxString errText( _("Unexpected") ); errText << wxT(" '") << text << wxT("'"); @@ -267,7 +267,7 @@ void DSNLEXER::Unexpected( const wxString& text ) throw( IOError ) } -void DSNLEXER::NeedLEFT() throw( IOError ) +void DSNLEXER::NeedLEFT() throw( IO_ERROR ) { int tok = NextTok(); if( tok != DSN_LEFT ) @@ -275,7 +275,7 @@ void DSNLEXER::NeedLEFT() throw( IOError ) } -void DSNLEXER::NeedRIGHT() throw( IOError ) +void DSNLEXER::NeedRIGHT() throw( IO_ERROR ) { int tok = NextTok(); if( tok != DSN_RIGHT ) @@ -283,7 +283,7 @@ void DSNLEXER::NeedRIGHT() throw( IOError ) } -int DSNLEXER::NeedSYMBOL() throw( IOError ) +int DSNLEXER::NeedSYMBOL() throw( IO_ERROR ) { int tok = NextTok(); if( !IsSymbol( tok ) ) @@ -292,7 +292,7 @@ int DSNLEXER::NeedSYMBOL() throw( IOError ) } -int DSNLEXER::NeedSYMBOLorNUMBER() throw( IOError ) +int DSNLEXER::NeedSYMBOLorNUMBER() throw( IO_ERROR ) { int tok = NextTok(); if( !IsSymbol( tok ) && tok!=DSN_NUMBER ) @@ -312,7 +312,7 @@ static inline bool isSpace( int cc ) } -int DSNLEXER::NextTok() throw (IOError) +int DSNLEXER::NextTok() throw( IO_ERROR ) { char* cur = next; char* head = cur; @@ -1380,7 +1380,7 @@ class DSNTEST : public wxApp DSNLEXER* lexer; int nestLevel; - void recursion() throw( IOError ); + void recursion() throw( IO_ERROR ); void indent() { @@ -1485,7 +1485,7 @@ bool DSNTEST::OnInit() } printf("\n"); } - catch( IOError ioe ) + catch( IO_ERROR ioe ) { fprintf( stderr, "%s\n", CONV_TO_UTF8( ioe.errorText ) ); } @@ -1494,7 +1494,7 @@ bool DSNTEST::OnInit() } -void DSNTEST::recursion() throw(IOError) +void DSNTEST::recursion() throw( IO_ERROR ) { int tok; const char* space = ""; diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 25034b3465..c6fd0034b6 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -626,6 +626,18 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory) } m_EDA_Config->Read( wxT( "BgColor" ), &g_DrawBgColor ); + + /* Load per-user search paths from settings file */ + + wxString upath; + int i = 1; + while( 1 ) + { + upath = m_EDA_CommonConfig->Read( wxString::Format( wxT( "LibraryPath%d" ), i ), wxT( "" ) ); + if( upath.IsSameAs( wxT( "" ) ) ) break; + m_libSearchPaths.Add( upath ); + i ++; + } } diff --git a/common/richio.cpp b/common/richio.cpp index 1de93a9eff..c918f13c6c 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -90,7 +90,7 @@ FILE_LINE_READER::FILE_LINE_READER( FILE* aFile, const wxString& aFileName, unsi } -unsigned FILE_LINE_READER::ReadLine() throw (IOError) +unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR ) { length = 0; line[0] = 0; @@ -101,7 +101,7 @@ unsigned FILE_LINE_READER::ReadLine() throw (IOError) length += strlen( line + length ); if( length == maxLineLength ) - throw IOError( _("Line length exceeded") ); + throw IO_ERROR( _("Line length exceeded") ); // a normal line breaks here, once through while loop if( length+1 < capacity || line[length-1] == '\n' ) @@ -117,7 +117,7 @@ unsigned FILE_LINE_READER::ReadLine() throw (IOError) } -unsigned STRING_LINE_READER::ReadLine() throw (IOError) +unsigned STRING_LINE_READER::ReadLine() throw( IO_ERROR ) { size_t nlOffset = lines.find( '\n', ndx ); @@ -129,7 +129,7 @@ unsigned STRING_LINE_READER::ReadLine() throw (IOError) if( length ) { if( length >= maxLineLength ) - throw IOError( _("Line length exceeded") ); + throw IO_ERROR( _("Line length exceeded") ); if( length+1 > capacity ) // +1 for terminating nul expandCapacity( length+1 ); @@ -186,7 +186,7 @@ const char* OUTPUTFORMATTER::GetQuoteChar( const char* wrapee, const char* quote } -int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap ) throw( IOError ) +int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap ) throw( IO_ERROR ) { int ret = vsnprintf( &buffer[0], buffer.size(), fmt, ap ); if( ret >= (int) buffer.size() ) @@ -202,7 +202,7 @@ int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap ) throw( IOError ) } -int OUTPUTFORMATTER::sprint( const char* fmt, ... ) throw( IOError ) +int OUTPUTFORMATTER::sprint( const char* fmt, ... ) throw( IO_ERROR ) { va_list args; @@ -214,7 +214,7 @@ int OUTPUTFORMATTER::sprint( const char* fmt, ... ) throw( IOError ) } -int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError ) +int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IO_ERROR ) { #define NESTWIDTH 2 ///< how many spaces per nestLevel @@ -243,7 +243,7 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError } -const char* OUTPUTFORMATTER::Quoted( std::string* aWrapee ) throw( IOError ) +const char* OUTPUTFORMATTER::Quoted( std::string* aWrapee ) throw( IO_ERROR ) { // derived class's notion of what a quote character is char quote = *GetQuoteChar( "(" ); @@ -268,7 +268,7 @@ const char* OUTPUTFORMATTER::Quoted( std::string* aWrapee ) throw( IOError ) // a decision was made to make all S-expression strings be on a single // line. You can embedd \n (human readable) in the text but not // '\n' which is 0x0a. - throw IOError( _( "S-expression string has newline" ) ); + throw IO_ERROR( _( "S-expression string has newline" ) ); } } @@ -285,7 +285,7 @@ const char* OUTPUTFORMATTER::Quoted( std::string* aWrapee ) throw( IOError ) //--------------------------------------------------------- -void STRING_FORMATTER::write( const char* aOutBuf, int aCount ) throw( IOError ) +void STRING_FORMATTER::write( const char* aOutBuf, int aCount ) throw( IO_ERROR ) { mystring.append( aOutBuf, aCount ); } @@ -314,7 +314,7 @@ const char* STREAM_OUTPUTFORMATTER::GetQuoteChar( const char* wrapee ) } -void STREAM_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount ) throw( IOError ) +void STREAM_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount ) throw( IO_ERROR ) { int lastWrite; @@ -326,7 +326,7 @@ void STREAM_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount ) throw( IOE if( !os.IsOk() ) { - throw IOError( _( "OUTPUTSTREAM_OUTPUTFORMATTER write error" ) ); + throw IO_ERROR( _( "OUTPUTSTREAM_OUTPUTFORMATTER write error" ) ); } } } diff --git a/common/selcolor.cpp b/common/selcolor.cpp index 8be6bd0e41..13238e2da7 100644 --- a/common/selcolor.cpp +++ b/common/selcolor.cpp @@ -74,13 +74,27 @@ WinEDA_SelColorFrame::WinEDA_SelColorFrame( wxWindow* parent, GetSizer()->SetSizeHints( this ); // Ensure the whole frame is visible, whenever the asked position. + // Moreover with a work station having dual monitors, the asked position can be relative to a monitor + // and this frame can be displayed on the other monitor, with an "out of screen" position. // Give also a small margin. - wxPoint endCornerPosition = GetPosition(); int margin = 10; + wxPoint windowPosition = GetPosition(); + if( framepos != wxDefaultPosition ) + { + if( windowPosition.x < margin ) + windowPosition.x = margin; + // Under MACOS, a vertical margin >= 20 is needed by the system menubar + int v_margin = MAX(20, margin); + if( windowPosition.y < v_margin ) + windowPosition.y = v_margin; + if( windowPosition != framepos ) + SetPosition(windowPosition); + } + wxPoint endCornerPosition = GetPosition(); endCornerPosition.x += GetSize().x + margin; endCornerPosition.y += GetSize().y + margin; - wxPoint windowPosition = GetPosition(); + windowPosition = GetPosition(); wxRect freeScreenArea( wxGetClientDisplayRect( ) ); if( freeScreenArea.GetRight() < endCornerPosition.x ) { diff --git a/common/wineda_toolbar.cpp b/common/wineda_toolbar.cpp index a4a6845677..d4e1f258d1 100644 --- a/common/wineda_toolbar.cpp +++ b/common/wineda_toolbar.cpp @@ -13,7 +13,7 @@ WinEDA_Toolbar::WinEDA_Toolbar( id_toolbar type, wxWindow * parent, wxWindowID id, bool horizontal ): wxAuiToolBar( parent, id, wxDefaultPosition, wxDefaultSize, - wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | ( ( horizontal ) ? + wxAUI_TB_DEFAULT_STYLE | ( ( horizontal ) ? wxAUI_TB_HORZ_LAYOUT : wxAUI_TB_VERTICAL ) ) { diff --git a/common/xnode.cpp b/common/xnode.cpp index fbfe407a3b..cf26f0e850 100644 --- a/common/xnode.cpp +++ b/common/xnode.cpp @@ -29,7 +29,7 @@ typedef wxXmlProperty XATTR; -void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) +void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { switch( GetType() ) { @@ -48,7 +48,7 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) } -void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) +void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { std::string utf8; diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 9bfda9872e..707a442fe3 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -14,6 +14,7 @@ #include "protos.h" #include "cvstruct.h" #include "class_DisplayFootprintsFrame.h" +#include "cvpcb_id.h" /* * NOTE: There is something in 3d_viewer.h that causes a compiler error in diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 98f051dd3d..fe2318e89f 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -23,7 +23,7 @@ FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( WinEDA_CvpcbFrame* parent, { m_UseFootprintFullList = true; m_ActiveFootprintList = NULL; - SetActiveFootprintList( TRUE ); + SetActiveFootprintList( true ); } @@ -61,8 +61,8 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint() if( ii >= 0 ) { wxString msg = (*m_ActiveFootprintList)[ii]; - msg.Trim( TRUE ); - msg.Trim( FALSE ); + msg.Trim( true ); + msg.Trim( false ); FootprintName = msg.AfterFirst( wxChar( ' ' ) ); } @@ -121,11 +121,11 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) m_FullFootprintList.Add( msg ); } - SetActiveFootprintList( TRUE ); + SetActiveFootprintList( true ); if( ( GetCount() == 0 ) || ( OldSelection < 0 ) || ( OldSelection >= GetCount() ) ) - SetSelection( 0, TRUE ); + SetSelection( 0, true ); Refresh(); } @@ -137,7 +137,7 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, wxString msg; unsigned jj; int OldSelection = GetSelection(); - bool HasItem = FALSE; + bool HasItem = false; m_FilteredFootprintList.Clear(); @@ -150,17 +150,17 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1, footprint.m_Module.GetData() ); m_FilteredFootprintList.Add( msg ); - HasItem = TRUE; + HasItem = true; } } if( HasItem ) - SetActiveFootprintList( FALSE ); + SetActiveFootprintList( false ); else - SetActiveFootprintList( TRUE ); + SetActiveFootprintList( true ); if( ( GetCount() == 0 ) || ( OldSelection >= GetCount() ) ) - SetSelection( 0, TRUE ); + SetSelection( 0, true ); Refresh(); } @@ -189,49 +189,35 @@ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) { bool new_selection; if( FullList ) - new_selection = TRUE; + new_selection = true; else - new_selection = FALSE; + new_selection = false; if( new_selection != old_selection ) - SetSelection( 0, TRUE ); + SetSelection( 0, true ); } #endif if( FullList ) { - m_UseFootprintFullList = TRUE; + m_UseFootprintFullList = true; m_ActiveFootprintList = &m_FullFootprintList; SetItemCount( m_FullFootprintList.GetCount() ); } else { - m_UseFootprintFullList = FALSE; + m_UseFootprintFullList = false; m_ActiveFootprintList = &m_FilteredFootprintList; SetItemCount( m_FilteredFootprintList.GetCount() ); } if( Redraw ) { - if( !m_UseFootprintFullList - || ( m_UseFootprintFullList != old_selection ) ) + if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) ) { Refresh(); } } - if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) ) - { - GetParent()->SetStatusText( wxEmptyString, 0 ); - GetParent()->SetStatusText( wxEmptyString, 1 ); - } - - wxString msg; - if( FullList ) - msg.Printf( _( "Footprints (All): %d" ), - m_ActiveFootprintList->GetCount() ); - else - msg.Printf( _( "Footprints (filtered): %d" ), - m_ActiveFootprintList->GetCount() ); - GetParent()->SetStatusText( msg, 2 ); + GetParent()->DisplayStatus(); } @@ -253,6 +239,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) wxString FootprintName = GetSelectedFootprint(); Module = GetModuleDescrByName( FootprintName, GetParent()->m_footprints ); + wxASSERT(Module); if( GetParent()->DrawFrame ) { GetParent()->CreateScreenCmp(); /* refresh general */ diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index f9906ad871..1f00830749 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -16,6 +16,7 @@ #include "cvstruct.h" #include "dialog_cvpcb_config.h" #include "class_DisplayFootprintsFrame.h" +#include "cvpcb_id.h" #include "build_version.h" @@ -115,7 +116,6 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, m_KeepCvpcbOpen = false; m_undefinedComponentCnt = 0; - /* Name of the document footprint list * usually located in share/modules/footprints_doc * this is of the responsibility to users to create this file @@ -422,9 +422,7 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event ) m_undefinedComponentCnt = m_components.size(); } - Line.Printf( _( "Components: %d (free: %d)" ), m_components.size(), - m_components.size() ); - SetStatusText( Line, 1 ); + DisplayStatus(); } @@ -557,6 +555,7 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event ) m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_footprints ); + DisplayStatus(); } @@ -585,3 +584,30 @@ void WinEDA_CvpcbFrame::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event ) { event.Check( m_KeepCvpcbOpen ); } + + +/** DisplayStatus() + * Displays info to the status line at bottom of the main frame + */ +void WinEDA_CvpcbFrame::DisplayStatus() +{ + wxString msg; + msg.Printf( _( "Components: %d (free: %d)" ), + m_components.size(), m_undefinedComponentCnt ); + SetStatusText( msg, 0 ); + + SetStatusText( wxEmptyString, 1 ); + + if( m_FootprintList ) + { + if( m_FootprintList->m_UseFootprintFullList ) + msg.Printf( _( "Footprints (All): %d" ), + m_FootprintList->m_ActiveFootprintList->GetCount() ); + else + msg.Printf( _( "Footprints (filtered): %d" ), + m_FootprintList->m_ActiveFootprintList->GetCount() ); + } + else + msg.Empty(); + SetStatusText( msg, 2 ); +} diff --git a/cvpcb/cvpcb_id.h b/cvpcb/cvpcb_id.h new file mode 100644 index 0000000000..c7e0301582 --- /dev/null +++ b/cvpcb/cvpcb_id.h @@ -0,0 +1,34 @@ +/** + * @file cvpcb_id.h + */ +/* + * Command IDs for CvPcb. + * + * Please add IDs that are unique to the component library viewer here and + * not in the global id.h file. This will prevent the entire project from + * being rebuilt when adding new commands to the component library viewer. + */ + +// Generic IDs: +#include "id.h" + +// specific IDs +enum id_cvpcb_frm +{ + ID_CVPCB_QUIT = ID_END_LIST, + ID_CVPCB_READ_INPUT_NETLIST, + ID_CVPCB_SAVEQUITCVPCB, + ID_CVPCB_CREATE_CONFIGWINDOW, + ID_CVPCB_CREATE_SCREENCMP, + ID_CVPCB_GOTO_FIRSTNA, + ID_CVPCB_GOTO_PREVIOUSNA, + ID_CVPCB_DEL_ASSOCIATIONS, + ID_CVPCB_AUTO_ASSOCIE, + ID_CVPCB_COMPONENT_LIST, + ID_CVPCB_FOOTPRINT_LIST, + ID_CVPCB_CREATE_STUFF_FILE, + ID_CVPCB_SHOW3D_FRAME, + ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, + ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, + ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE +}; diff --git a/cvpcb/cvstruct.h b/cvpcb/cvstruct.h index fce18885fd..b38b1ba87d 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/cvstruct.h @@ -16,36 +16,6 @@ class COMPONENTS_LISTBOX; class DISPLAY_FOOTPRINTS_FRAME; -#include "id.h" - - -/** - * Command IDs for the component library viewer. - * - * Please add IDs that are unique to the component library viewer here and - * not in the global id.h file. This will prevent the entire project from - * being rebuilt when adding new commands to the component library viewer. - */ -enum id_cvpcb_frm -{ - ID_CVPCB_QUIT = ID_END_LIST, - ID_CVPCB_READ_INPUT_NETLIST, - ID_CVPCB_SAVEQUITCVPCB, - ID_CVPCB_CREATE_CONFIGWINDOW, - ID_CVPCB_CREATE_SCREENCMP, - ID_CVPCB_GOTO_FIRSTNA, - ID_CVPCB_GOTO_PREVIOUSNA, - ID_CVPCB_DEL_ASSOCIATIONS, - ID_CVPCB_AUTO_ASSOCIE, - ID_CVPCB_COMPONENT_LIST, - ID_CVPCB_FOOTPRINT_LIST, - ID_CVPCB_CREATE_STUFF_FILE, - ID_CVPCB_SHOW3D_FRAME, - ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, - ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, - ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE -}; - /** * The CVPcb application main window. @@ -120,6 +90,10 @@ public: void SaveProjectFile( const wxString& fileName ); virtual void LoadSettings(); virtual void SaveSettings(); + /** DisplayStatus() + * Displays info to the status line at bottom of the main frame + */ + void DisplayStatus(); PARAM_CFG_ARRAY& GetProjectFileParameters( void ); diff --git a/cvpcb/init.cpp b/cvpcb/init.cpp index b07aa561b9..ec5392ab51 100644 --- a/cvpcb/init.cpp +++ b/cvpcb/init.cpp @@ -24,7 +24,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) COMPONENT* Component; bool isUndefined = false; int NumCmp; - wxString Line; + wxString msg; if( m_components.empty() ) return; @@ -45,7 +45,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) Component->m_Module = package; - Line.Printf( CMP_FORMAT, NumCmp + 1, + msg.Printf( CMP_FORMAT, NumCmp + 1, GetChars( Component->m_Reference ), GetChars( Component->m_Value ), GetChars( Component->m_Module ) ); @@ -54,7 +54,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) if( isUndefined ) m_undefinedComponentCnt -= 1; - m_ListCmp->SetString( NumCmp, Line ); + m_ListCmp->SetString( NumCmp, msg ); m_ListCmp->SetSelection( NumCmp, FALSE ); // We activate next component: @@ -62,9 +62,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) NumCmp++; m_ListCmp->SetSelection( NumCmp, TRUE ); - Line.Printf( _( "Components: %d (free: %d)" ), - m_components.size(), m_undefinedComponentCnt ); - SetStatusText( Line, 1 ); + DisplayStatus(); } @@ -112,9 +110,7 @@ bool WinEDA_CvpcbFrame::ReadNetList() if( !m_components.empty() ) m_ListCmp->SetSelection( 0, TRUE ); - msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(), - m_undefinedComponentCnt ); - SetStatusText( msg, 1 ); + DisplayStatus(); /* Update the title of the main window. */ SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index ba5722955f..fb1c6a652a 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -9,6 +9,7 @@ #include "cvpcb.h" #include "protos.h" #include "cvstruct.h" +#include "cvpcb_id.h" /****************************************************************************** @@ -122,7 +123,5 @@ void WinEDA_CvpcbFrame::BuildFOOTPRINTS_LISTBOX() } m_FootprintList->SetFootprintFullList( m_footprints ); - - msg.Printf( _( "Footprints: %d" ), m_FootprintList->GetCount() ); - SetStatusText( msg, 2 ); + DisplayStatus(); } diff --git a/cvpcb/menucfg.cpp b/cvpcb/menucfg.cpp index f1b0b913a3..12335eeaf3 100644 --- a/cvpcb/menucfg.cpp +++ b/cvpcb/menucfg.cpp @@ -10,6 +10,7 @@ #include "cvpcb.h" #include "cvstruct.h" +#include "cvpcb_id.h" #include "bitmaps.h" diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp index 70a7172e66..de32cbb684 100644 --- a/cvpcb/tool_cvpcb.cpp +++ b/cvpcb/tool_cvpcb.cpp @@ -11,6 +11,7 @@ #include "cvpcb.h" #include "protos.h" #include "cvstruct.h" +#include "cvpcb_id.h" void WinEDA_CvpcbFrame::ReCreateHToolbar() diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 2fed57923b..395c6f9e90 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -19,16 +19,11 @@ // Imported functions: -void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, - const wxPoint aMoveVector ); -void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, - wxPoint& Center ); -void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, - wxPoint& aMirrorPoint ); -void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, - wxPoint& Center ); -void DeleteItemsInList( WinEDA_DrawPanel* panel, - PICKED_ITEMS_LIST& aItemsList ); +void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); +void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center ); +void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint ); +void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center ); +void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ); void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); @@ -38,9 +33,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, wxPoint& aPosition, bool aSearchFirst ); -static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, - wxDC* DC, - bool erase ); +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ); @@ -114,8 +107,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) { wxString msg; err = TRUE; - msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd \ -%d, state %d)" ), + msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd %d, state %d)" ), block->m_Command, block->m_State ); DisplayError( this, msg ); } @@ -136,10 +128,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - SaveCopyInUndoList( block->m_ItemsSelection, - UR_MOVED, - block->m_MoveVector ); - + SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector ); MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector ); block->ClearItemsList(); break; @@ -149,13 +138,10 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - DuplicateItemsInList( - GetScreen(), block->m_ItemsSelection, block->m_MoveVector ); + DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector ); - SaveCopyInUndoList( - block->m_ItemsSelection, - (block->m_Command == - BLOCK_PRESELECT_MOVE) ? UR_CHANGED : UR_NEW ); + SaveCopyInUndoList( block->m_ItemsSelection, + ( block->m_Command == BLOCK_PRESELECT_MOVE ) ? UR_CHANGED : UR_NEW ); block->ClearItemsList(); break; @@ -178,12 +164,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) OnModify(); - /* clear struct.m_Flags */ - SCH_ITEM* Struct; - for( Struct = GetScreen()->EEDrawList; - Struct != NULL; - Struct = Struct->Next() ) - Struct->m_Flags = 0; + // clear struct.m_Flags. + GetScreen()->ClearDrawingState(); DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; @@ -196,13 +178,11 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) if( block->GetCount() ) { - DisplayError( this, - wxT( "HandleBlockPLace() error: some items left in buffer" ) ); + DisplayError( this, wxT( "HandleBlockPLace() error: some items left in buffer" ) ); block->ClearItemsList(); } - SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, - wxEmptyString ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); DrawPanel->Refresh(); } @@ -288,11 +268,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); if( block->GetCount() ) { - wxPoint move_vector = - -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; + wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; SaveStructListForPaste( block->m_ItemsSelection ); - MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, - move_vector ); + MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector ); ii = -1; } block->ClearItemsList(); @@ -317,12 +295,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) if( block->m_Command == BLOCK_ABORT ) { - /* clear struct.m_Flags */ - EDA_BaseStruct* Struct; - for( Struct = GetScreen()->EEDrawList; - Struct != NULL; - Struct = Struct->Next() ) - Struct->m_Flags = 0; + GetScreen()->ClearDrawingState(); } if( ii <= 0 ) @@ -333,9 +306,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; GetScreen()->SetCurItem( NULL ); - SetToolID( m_ID_current_state, - DrawPanel->m_PanelDefaultCursor, - wxEmptyString ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } if( zoom_command ) @@ -415,8 +386,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); if( block->GetCount() ) { - wxPoint move_vector = - -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; + wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; SaveStructListForPaste( block->m_ItemsSelection ); MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector ); } @@ -424,8 +394,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) case BLOCK_ZOOM: /* Window Zoom */ DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); - DrawPanel->SetCursor( - DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); + DrawPanel->SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); Window_Zoom( GetScreen()->m_BlockLocate ); break; @@ -439,9 +408,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) /* Compute the rotation center and put it on grid */ wxPoint rotationPoint = block->Centre(); PutOnGrid( &rotationPoint ); - SaveCopyInUndoList( block->m_ItemsSelection, - UR_ROTATED, - rotationPoint ); + SaveCopyInUndoList( block->m_ItemsSelection, UR_ROTATED, rotationPoint ); RotateListOfItems( block->m_ItemsSelection, rotationPoint ); OnModify(); } @@ -460,9 +427,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) /* Compute the mirror center and put it on grid */ wxPoint mirrorPoint = block->Centre(); PutOnGrid( &mirrorPoint ); - SaveCopyInUndoList( block->m_ItemsSelection, - UR_MIRRORED_X, - mirrorPoint ); + SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_X, mirrorPoint ); Mirror_X_ListOfItems( block->m_ItemsSelection, mirrorPoint ); OnModify(); // block->m_State = STATE_BLOCK_MOVE; @@ -481,9 +446,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) /* Compute the mirror center and put it on grid */ wxPoint mirrorPoint = block->Centre(); PutOnGrid( &mirrorPoint ); - SaveCopyInUndoList( block->m_ItemsSelection, - UR_MIRRORED_Y, - mirrorPoint ); + SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint ); MirrorListOfItems( block->m_ItemsSelection, mirrorPoint ); OnModify(); // block->m_State = STATE_BLOCK_MOVE; @@ -506,9 +469,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; GetScreen()->SetCurItem( NULL ); - SetToolID( m_ID_current_state, - DrawPanel->m_PanelDefaultCursor, - wxEmptyString ); + SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } } @@ -516,8 +477,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) /* Traces the outline of the search block structures * The entire block follows the cursor */ -static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, - bool erase ) +static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) { BLOCK_SELECTOR* block = &panel->GetScreen()->m_BlockLocate;; @@ -555,9 +515,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, */ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ) { - g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous - // saved list, if - // exists + g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous saved list, if exists /* save the new list: */ ITEM_PICKER item; @@ -569,8 +527,7 @@ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { /* Make a copy of the original picked item. */ - SCH_ITEM* DrawStructCopy = DuplicateStruct( - (SCH_ITEM*) aItemsList.GetPickedItem( ii ) ); + SCH_ITEM* DrawStructCopy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) ); DrawStructCopy->SetParent( NULL ); item.m_PickedItem = DrawStructCopy; g_BlockSaveDataList.PushItem( item ); @@ -599,8 +556,7 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ ) { Struct = DuplicateStruct( - (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem( - ii ) ); + (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem( ii ) ); picker.m_PickedItem = Struct; picklist.PushItem( picker ); @@ -621,10 +577,7 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector ); /* clear .m_Flags member for all items */ - for( Struct = GetScreen()->EEDrawList; - Struct != NULL; - Struct = Struct->Next() ) - Struct->m_Flags = 0; + GetScreen()->ClearDrawingState(); OnModify(); @@ -646,11 +599,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) if( pickedlist->GetCount() == 0 ) return; - /* .m_Flags member is used to handle how a wire is exactly selected - * (fully selected, or partially selected by an end point ) - */ - for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() ) - Struct->m_Flags = 0; + screen->ClearDrawingState(); for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) { @@ -724,7 +673,8 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) SCH_SHEET* sheet = (SCH_SHEET*) Struct; // Add all pins sheets of a selected hierarchical sheet to the list - BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() ) { + BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() ) + { AddPickedItem( screen, label.m_Pos ); } } diff --git a/eeschema/class_drawsheet.cpp b/eeschema/class_drawsheet.cpp index 23fd4c61c9..1f0cded178 100644 --- a/eeschema/class_drawsheet.cpp +++ b/eeschema/class_drawsheet.cpp @@ -898,6 +898,70 @@ void SCH_SHEET::renumberLabels() } +void SCH_SHEET::GetEndPoints( std::vector & aItemList ) +{ + // Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet). + // I do not know why. + for( unsigned ii = 0; ii < GetSheetPins().size(); ii++ ) + { + SCH_SHEET_PIN &pinsheet = GetSheetPins()[ii]; + + wxCHECK2_MSG( pinsheet.Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE, continue, + wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) ); + + pinsheet.GetEndPoints( aItemList ); + } +} + + +bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) +{ + bool currentState = IsDangling(); + + BOOST_FOREACH( SCH_SHEET_PIN& pinsheet, GetSheetPins() ) + { + pinsheet.IsDanglingStateChanged( aItemList ); + } + + return currentState != IsDangling(); +} + + +bool SCH_SHEET::IsDangling() const +{ + // If any hierarchical label in the sheet is dangling, then the sheet is dangling. + for( size_t i = 0; i < GetSheetPins().size(); i++ ) + { + if( GetSheetPins()[i].IsDangling() ) + return true; + } + + return false; +} + + +bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + EDA_Rect boundingBox = GetBoundingBox(); + + if( aRect.Intersects( boundingBox ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + for( size_t i = 0; i < GetSheetPins().size(); i++ ) + aPoints.push_back( GetSheetPins()[i].m_Pos ); +} + + #if defined(DEBUG) void SCH_SHEET::Show( int nestLevel, std::ostream& os ) diff --git a/eeschema/class_drawsheet.h b/eeschema/class_drawsheet.h index 6354379229..03ddac4d1b 100644 --- a/eeschema/class_drawsheet.h +++ b/eeschema/class_drawsheet.h @@ -23,7 +23,6 @@ extern SCH_SHEET* g_RootSheet; * the sheet, it corresponds to a hierarchical label. */ -//class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct class SCH_SHEET_PIN : public SCH_HIERLABEL { private: @@ -31,15 +30,15 @@ private: ///< Sheet label numbering begins at 2. ///< 0 is reserved for the sheet name. ///< 1 is reserve for the sheet file name. - int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin - * m_Edge define on which edge the pin is positionned: - * 0: pin on left side - * 1: pin on right side - * 2: pin on top side - * 3: pin on bottom side - * for compatibility reasons, this does not follow same values as text - * orientation. - */ + int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin + * m_Edge define on which edge the pin is positionned: + * 0: pin on left side + * 1: pin on right side + * 2: pin on top side + * 3: pin on bottom side + * for compatibility reasons, this does not follow same values as text + * orientation. + */ public: SCH_SHEET_PIN( SCH_SHEET* parent, @@ -168,8 +167,9 @@ public: * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @return True if this item matches the search criteria. */ - virtual bool Matches( wxFindReplaceData& aSearchData, - void* aAuxData, wxPoint * aFindLocation ); + virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); + + virtual void GetEndPoints( std::vector & aItemList ); }; @@ -251,6 +251,11 @@ public: SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; } + SCH_SHEET_PIN_LIST& GetSheetPins() const + { + return const_cast< SCH_SHEET_PIN_LIST& >( m_labels ); + } + /** * Remove a sheet label from this sheet. * @@ -412,7 +417,9 @@ public: virtual void Move( const wxPoint& aMoveVector ) { m_Pos += aMoveVector; - BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels ) { + + BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels ) + { label.Move( aMoveVector ); } } @@ -437,8 +444,7 @@ public: * * @return True if this item matches the search criteria. */ - virtual bool Matches( wxFindReplaceData& aSearchData, - void* aAuxData, wxPoint * aFindLocation ); + virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); /** * Resize this sheet to aSize and adjust all of the labels accordingly. @@ -457,6 +463,16 @@ public: */ wxPoint GetFileNamePosition (); + virtual void GetEndPoints( std::vector & aItemList ); + + virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ); + + virtual bool IsDangling() const; + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + #if defined(DEBUG) // comment inherited by Doxygen from Base_Struct diff --git a/eeschema/class_hierarchical_PIN_sheet.cpp b/eeschema/class_hierarchical_PIN_sheet.cpp index af88daa653..3a43994b9d 100644 --- a/eeschema/class_hierarchical_PIN_sheet.cpp +++ b/eeschema/class_hierarchical_PIN_sheet.cpp @@ -340,6 +340,46 @@ void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint ) } +/** Virtual Function SCH_SHEET_PIN::CreateGraphicShape + * calculates the graphic shape (a polygon) associated to the text + * @param aCorner_list = a buffer to fill with polygon corners coordinates + * @param aPos = Position of the shape + */ +void SCH_SHEET_PIN::CreateGraphicShape( std::vector & aCorner_list, + const wxPoint& aPos ) +{ + /* This is the same icon shapes as SCH_HIERLABEL + * but the graphic icon is slightly different in 2 cases: + * for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL + * for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL + */ + int tmp = m_Shape; + switch( m_Shape ) + { + case NET_INPUT: + m_Shape = NET_OUTPUT; + break; + + case NET_OUTPUT: + m_Shape = NET_INPUT; + break; + + default: + break; + } + SCH_HIERLABEL::CreateGraphicShape( aCorner_list, aPos ); + m_Shape = tmp; +} + + +void SCH_SHEET_PIN::GetEndPoints( std::vector & aItemList ) +{ + DANGLING_END_ITEM item( SHEET_LABEL_END, this ); + item.m_Pos = m_Pos; + aItemList.push_back( item ); +} + + #if defined(DEBUG) void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) { diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 711269c3b6..c6d0093ae7 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -485,9 +485,8 @@ the current schematic." ), { versionMajor = (int) major; versionMinor = (int) minor; - - wxLogDebug( wxT( "Component library <%s> is version %d.%d." ), - GetChars( GetName() ), versionMajor, versionMinor ); +// wxLogDebug( wxT( "Component library <%s> is version %d.%d." ), +// GetChars( GetName() ), versionMajor, versionMinor ); } } diff --git a/eeschema/class_marker_sch.cpp b/eeschema/class_marker_sch.cpp index c6daaefa6a..4ef1ef7320 100644 --- a/eeschema/class_marker_sch.cpp +++ b/eeschema/class_marker_sch.cpp @@ -180,3 +180,16 @@ void SCH_MARKER::Mirror_Y( int aYaxis_position ) m_Pos.x = -m_Pos.x; m_Pos.x += aYaxis_position; } + + +bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Pos ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} diff --git a/eeschema/class_marker_sch.h b/eeschema/class_marker_sch.h index 0993471985..66a840b604 100644 --- a/eeschema/class_marker_sch.h +++ b/eeschema/class_marker_sch.h @@ -116,6 +116,8 @@ public: */ void DisplayInfo( WinEDA_DrawFrame* aFrame ); + virtual bool IsSelectStateChanged( const wxRect& aRect ); + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); diff --git a/eeschema/class_sch_component.cpp b/eeschema/class_sch_component.cpp index 103c2ce4fe..de22999356 100644 --- a/eeschema/class_sch_component.cpp +++ b/eeschema/class_sch_component.cpp @@ -973,9 +973,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const if( GetField( REFERENCE )->m_Text.IsEmpty() ) strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) ); else - strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), - sizeof( Name1 ) ); + strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), sizeof( Name1 ) ); } + for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) { #if defined(KICAD_GOST) @@ -1284,3 +1284,77 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxP return false; } + + +void SCH_COMPONENT::GetEndPoints( std::vector & aItemList ) +{ + LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); + + if( Entry == NULL ) + return; + + for( LIB_PIN* Pin = Entry->GetNextPin(); Pin != NULL; Pin = Entry->GetNextPin( Pin ) ) + { + wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); + + if( Pin->GetUnit() && m_Multi && ( m_Multi != Pin->GetUnit() ) ) + continue; + + if( Pin->GetConvert() && m_Convert && ( m_Convert != Pin->GetConvert() ) ) + continue; + + DANGLING_END_ITEM item( PIN_END, Pin ); + item.m_Pos = GetPinPhysicalPosition( Pin ); + aItemList.push_back( item ); + } +} + + +wxPoint SCH_COMPONENT::GetPinPhysicalPosition( LIB_PIN* Pin ) +{ + wxCHECK_MSG( Pin != NULL && Pin->Type() == COMPONENT_PIN_DRAW_TYPE, wxPoint( 0, 0 ), + wxT( "Cannot get physical position of pin." ) ); + + return m_Transform.TransformCoordinate( Pin->m_Pos ) + m_Pos; +} + + +bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + EDA_Rect boundingBox = GetBoundingBox(); + + if( aRect.Intersects( boundingBox ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + LIB_PIN* pin; + LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); + + wxCHECK_RET( component != NULL, + wxT( "Cannot add connection points to list. Cannot find component <" ) + + m_ChipName + wxT( "> in any of the loaded libraries." ) ); + + for( pin = component->GetNextPin( pin ); pin != NULL; pin = component->GetNextPin( pin ) ) + { + wxCHECK_RET( pin->Type() == COMPONENT_PIN_DRAW_TYPE, + wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) ); + + // Skip items not used for this part. + if( m_Multi && pin->GetUnit() && ( pin->GetUnit() != m_Multi ) ) + continue; + if( m_Convert && pin->GetConvert() && ( pin->GetConvert() != m_Convert ) ) + continue; + + // Calculate the pin position relative to the component position and orientation. + aPoints.push_back( m_Transform.TransformCoordinate( pin->m_Pos ) + m_Pos ); + } +} diff --git a/eeschema/class_sch_component.h b/eeschema/class_sch_component.h index 6cc5801d73..ca6b1980d3 100644 --- a/eeschema/class_sch_component.h +++ b/eeschema/class_sch_component.h @@ -1,6 +1,6 @@ -/*****************************************************/ +/******************************************************/ /* Definitions for the Component classes for EESchema */ -/*****************************************************/ +/******************************************************/ #ifndef COMPONENT_CLASS_H #define COMPONENT_CLASS_H @@ -85,8 +85,7 @@ private: void Init( const wxPoint& pos = wxPoint( 0, 0 ) ); public: - SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), - SCH_ITEM* aParent = NULL ); + SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL ); /** * Create schematic component from library component object. @@ -122,6 +121,7 @@ public: return wxT( "SCH_COMPONENT" ); } + TRANSFORM& GetTransform() const { return const_cast< TRANSFORM& >( m_Transform ); } /** * Function Save @@ -312,8 +312,7 @@ public: int GetUnitSelection( SCH_SHEET_PATH* aSheet ); // Set the unit selection, for the given sheet path. - void SetUnitSelection( SCH_SHEET_PATH* aSheet, - int aUnitSelection ); + void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection ); /** Function GetPenSize * @return the size of the "pen" that be used to draw or plot this item @@ -355,8 +354,15 @@ public: * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @return True if this component reference or value field matches the search criteria. */ - virtual bool Matches( wxFindReplaceData& aSearchData, - void* aAuxData, wxPoint * aFindLocation ); + virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); + + virtual void GetEndPoints( std::vector & aItemList ); + + wxPoint GetPinPhysicalPosition( LIB_PIN* Pin ); + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; #if defined(DEBUG) diff --git a/eeschema/class_sch_screen.cpp b/eeschema/class_sch_screen.cpp index 5bb6c92f04..4842158f7e 100644 --- a/eeschema/class_sch_screen.cpp +++ b/eeschema/class_sch_screen.cpp @@ -353,6 +353,13 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount } +void SCH_SCREEN::ClearDrawingState() +{ + for( SCH_ITEM* item = EEDrawList; item != NULL; item = item->Next() ) + item->m_Flags = 0; +} + + /******************************************************************/ /* Class SCH_SCREENS to handle the list of screens in a hierarchy */ /******************************************************************/ diff --git a/eeschema/class_schematic_items.cpp b/eeschema/class_schematic_items.cpp index ee04896eca..289fa14647 100644 --- a/eeschema/class_schematic_items.cpp +++ b/eeschema/class_schematic_items.cpp @@ -167,12 +167,45 @@ void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint ) } +void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) +{ + DANGLING_END_ITEM item( ENTRY_END, this ); + item.m_Pos = m_Pos; + + DANGLING_END_ITEM item1( ENTRY_END, this ); + item1.m_Pos = m_End(); + aItemList.push_back( item ); + aItemList.push_back( item1 ); +} + + +bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + // If either end of the bus entry is inside the selection rectangle, the entire + // bus entry is selected. Bus entries have a fixed length and angle. + if( aRect.Contains( m_Pos ) || aRect.Contains( m_End() ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Pos ); + aPoints.push_back( m_End() ); +} + + /**********************/ /* class SCH_JUNCTION */ /**********************/ -SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : - SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE ) +SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE ) { #define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */ m_Pos = pos; @@ -289,6 +322,33 @@ void SCH_JUNCTION::Rotate( wxPoint rotationPoint ) } +void SCH_JUNCTION::GetEndPoints( std::vector & aItemList ) +{ + DANGLING_END_ITEM item( JUNCTION_END, this ); + item.m_Pos = m_Pos; + aItemList.push_back( item ); +} + + +bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Pos ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Pos ); +} + + #if defined(DEBUG) void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) { @@ -306,8 +366,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) /* class SCH_NO_CONNECT */ /************************/ -SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : - SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE ) +SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE ) { #define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */ m_Pos = pos; @@ -430,6 +489,25 @@ void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint ) } +bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Pos ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Pos ); +} + + /******************/ /* Class SCH_LINE */ /******************/ @@ -634,9 +712,7 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) wxCHECK_MSG( aLine != NULL && aLine->Type() == DRAW_SEGMENT_STRUCT_TYPE, false, wxT( "Cannot test line segment for overlap." ) ); - if( this == aLine ) - return false; - if( GetLayer() != aLine->GetLayer() ) + if( this == aLine || GetLayer() != aLine->GetLayer() ) return false; // Search for a common end, and modify coordinates to ensure RefSegm->m_End @@ -646,7 +722,7 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) if( m_End == aLine->m_End ) return true; - EXCHG( m_Start, aLine->m_End ); + EXCHG( m_Start, m_End ); } else if( m_Start == aLine->m_End ) { @@ -658,8 +734,10 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) EXCHG( aLine->m_Start, aLine->m_End ); } else if( m_End != aLine->m_Start ) + { // No common end point, segments cannot be merged. return false; + } /* Test alignment: */ if( m_Start.y == m_End.y ) // Horizontal segment @@ -693,12 +771,86 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) } -/***********************/ -/* Class SCH_POLYLINE */ -/***********************/ +void SCH_LINE::GetEndPoints( std::vector & aItemList ) +{ + if( GetLayer() == LAYER_NOTES ) + return; -SCH_POLYLINE::SCH_POLYLINE( int layer ) : - SCH_ITEM( NULL, DRAW_POLYLINE_STRUCT_TYPE ) + if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) ) + { + DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this ); + item.m_Pos = m_Start; + DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this ); + item1.m_Pos = m_End; + + aItemList.push_back( item ); + aItemList.push_back( item1 ); + } +} + + +bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) +{ + bool previousStartState = m_StartIsDangling; + bool previousEndState = m_EndIsDangling; + + if( GetLayer() == LAYER_WIRE ) + { + BOOST_FOREACH( DANGLING_END_ITEM item, aItemList ) + { + if( item.m_Item == this ) + continue; + + if( m_Start == item.m_Pos ) + m_StartIsDangling = false; + + if( m_End == item.m_Pos ) + m_EndIsDangling = false; + + if( (m_StartIsDangling == false) && (m_EndIsDangling == false) ) + break; + } + } + else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES ) + { + // Lines on the notes layer and the bus layer cannot be tested for dangling ends. + previousStartState = previousEndState = m_StartIsDangling = m_EndIsDangling = false; + } + + return ( previousStartState != m_StartIsDangling ) || ( previousEndState != m_EndIsDangling ); +} + + +bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Start ) ) + m_Flags |= STARTPOINT | SELECTED; + else + m_Flags &= ~( STARTPOINT | SELECTED ); + + if( aRect.Contains( m_End ) ) + m_Flags |= ENDPOINT | SELECTED; + else + m_Flags &= ~( ENDPOINT | SELECTED ); + + return previousState != IsSelected(); +} + + +void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Start ); + aPoints.push_back( m_End ); +} + + +/**********************/ +/* Class SCH_POLYLINE */ +/**********************/ + +SCH_POLYLINE::SCH_POLYLINE( int layer ) : SCH_ITEM( NULL, DRAW_POLYLINE_STRUCT_TYPE ) { m_Width = 0; diff --git a/eeschema/class_schematic_items.h b/eeschema/class_schematic_items.h index 4d71dc3301..62d4be162e 100644 --- a/eeschema/class_schematic_items.h +++ b/eeschema/class_schematic_items.h @@ -108,6 +108,16 @@ public: */ bool MergeOverlap( SCH_LINE* aLine ); + virtual void GetEndPoints( std::vector & aItemList ); + + virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ); + + virtual bool IsDangling() const { return m_StartIsDangling || m_EndIsDangling; } + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); @@ -185,6 +195,10 @@ public: virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_X( int aXaxis_position ); virtual void Rotate( wxPoint rotationPoint ); + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; }; @@ -259,6 +273,12 @@ public: virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_X( int aXaxis_position ); virtual void Rotate( wxPoint rotationPoint ); + + virtual void GetEndPoints( std::vector & aItemList ); + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; }; class SCH_POLYLINE : public SCH_ITEM @@ -405,6 +425,12 @@ public: virtual void Mirror_X( int aXaxis_position ); virtual void Rotate( wxPoint rotationPoint ); + virtual void GetEndPoints( std::vector & aItemList ); + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index 90f599d9ed..a95060a900 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -65,29 +65,21 @@ static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; static int* TemplateShape[5][4] = { - { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, - TemplateIN_BOTTOM }, - { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, - TemplateOUT_BOTTOM }, - { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, - TemplateBIDI_BOTTOM }, - { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, - Template3STATE_BOTTOM }, - { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, - TemplateUNSPC_BOTTOM } + { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, + { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, + { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, + { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, + { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM } }; -/**************************************************************************/ -SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, - KICAD_T aType ) : +SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : SCH_ITEM( NULL, aType ), EDA_TextStruct( text ) { -/**************************************************************************/ m_Layer = LAYER_NOTES; m_Pos = pos; m_Shape = 0; - m_IsDangling = FALSE; + m_IsDangling = false; m_MultilineAllowed = true; m_SchematicOrientation = 0; } @@ -103,10 +95,8 @@ bool SCH_TEXT::HitTest( const wxPoint& aPosRef ) } -/*********************************************/ SCH_TEXT* SCH_TEXT::GenCopy() { -/*********************************************/ SCH_TEXT* newitem; switch( Type() ) @@ -190,23 +180,11 @@ bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint *aFindLocation = BoundaryBox.Centre(); return true; } - + return false; } -/** function GetSchematicTextOffset (virtual) - * @return the offset between the SCH_TEXT position and the text itself - * position - * This offset depend on orientation, and the type of text - * (room to draw an associated graphic symbol, or put the text above a wire) - */ -wxPoint SCH_LABEL::GetSchematicTextOffset() -{ - return SCH_TEXT::GetSchematicTextOffset(); -} - - /** virtual function Mirror_Y * mirror item relative to an Y axis * @param aYaxis_position = the y axis position @@ -330,95 +308,512 @@ void SCH_TEXT::Rotate( wxPoint rotationPoint ) } +/** function SetTextOrientAndJustifyParmeters (virtual) + * Set m_SchematicOrientation, and initialize + * m_orient,m_HJustified and m_VJustified, according to the value of + * m_SchematicOrientation + * must be called after changing m_SchematicOrientation + * @param aSchematicOrientation = + * 0 = normal (horizontal, left justified). + * 1 = up (vertical) + * 2 = (horizontal, right justified). This can be seen as the mirrored + * position of 0 + * 3 = bottom . This can be seen as the mirrored position of up + */ +void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation ) +{ + m_SchematicOrientation = aSchematicOrientation; + + switch( m_SchematicOrientation ) + { + default: + case 0: /* Horiz Normal Orientation (left justified) */ + m_Orient = TEXT_ORIENT_HORIZ; + m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + + case 1: /* Vert Orientation UP */ + m_Orient = TEXT_ORIENT_VERT; + m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + + case 2: /* Horiz Orientation - Right justified */ + m_Orient = TEXT_ORIENT_HORIZ; + m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + + case 3: /* Vert Orientation BOTTOM */ + m_Orient = TEXT_ORIENT_VERT; + m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + } +} + + +void SCH_TEXT::SwapData( SCH_TEXT* copyitem ) +{ + EXCHG( m_Text, copyitem->m_Text ); + EXCHG( m_Pos, copyitem->m_Pos ); + EXCHG( m_Size, copyitem->m_Size ); + EXCHG( m_Width, copyitem->m_Width ); + EXCHG( m_Shape, copyitem->m_Shape ); + EXCHG( m_Orient, copyitem->m_Orient ); + + EXCHG( m_Layer, copyitem->m_Layer ); + EXCHG( m_HJustify, copyitem->m_HJustify ); + EXCHG( m_VJustify, copyitem->m_VJustify ); + EXCHG( m_IsDangling, copyitem->m_IsDangling ); + EXCHG( m_SchematicOrientation, copyitem->m_SchematicOrientation ); +} + + +void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) +{ + /* save old text in undo list */ + if( g_ItemToUndoCopy && ( (m_Flags & IS_NEW) == 0 ) ) + { + /* restore old values and save new ones */ + SwapData( (SCH_TEXT*) g_ItemToUndoCopy ); + + /* save in undo list */ + frame->SaveCopyInUndoList( this, UR_CHANGED ); + + /* restore new values */ + SwapData( (SCH_TEXT*) g_ItemToUndoCopy ); + + SAFE_DELETE( g_ItemToUndoCopy ); + } + + SCH_ITEM::Place( frame, DC ); +} + + +/** Function GetPenSize + * @return the size of the "pen" that be used to draw or plot this item + */ +int SCH_TEXT::GetPenSize() +{ + int pensize = m_Width; + + if( pensize == 0 ) // Use default values for pen size + { + if( m_Bold ) + pensize = GetPenSizeForBold( m_Size.x ); + else + pensize = g_DrawDefaultLineThickness; + } + + // Clip pen size for small texts: + pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); + return pensize; +} + + +/* Text type Comment (text on layer "NOTE") have 4 directions, and the Text + * origin is the first letter + */ +void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, + int DrawMode, int Color ) +{ + EDA_Colors color; + int linewidth = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + + linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + + if( Color >= 0 ) + color = (EDA_Colors) Color; + else + color = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); + + wxPoint text_offset = aOffset + GetSchematicTextOffset(); + + EXCHG( linewidth, m_Width ); // Set the minimum width + EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); + EXCHG( linewidth, m_Width ); // set initial value + if( m_IsDangling ) + DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); + + // Enable these line to draw the bounding box (debug tests purposes only) +#if 0 + { + EDA_Rect BoundaryBox; + BoundaryBox = GetBoundingBox(); + int x1 = BoundaryBox.GetX(); + int y1 = BoundaryBox.GetY(); + int x2 = BoundaryBox.GetRight(); + int y2 = BoundaryBox.GetBottom(); + GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); + } +#endif +} + + +/** + * Function Save + * writes the data structures for this object out to a FILE in "*.brd" format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ +bool SCH_TEXT::Save( FILE* aFile ) const +{ + bool success = true; + const char* shape = "~"; + + if( m_Italic ) + shape = "Italic"; + + wxString text = m_Text; + + for( ; ; ) + { + int i = text.find( '\n' ); + if( i == wxNOT_FOUND ) + break; + + text.erase( i, 1 ); + text.insert( i, wxT( "\\n" ) ); + } + + if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n", + m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, + shape, m_Width, CONV_TO_UTF8( text ) ) == EOF ) + { + success = false; + } + + return success; +} + + +void SCH_TEXT::GetEndPoints( std::vector & aItemList ) +{ + // Normal text labels cannot be tested for dangling ends. + if( Type() == TYPE_SCH_TEXT ) + return; + + DANGLING_END_ITEM item( LABEL_END, this ); + item.m_Pos = m_Pos; + aItemList.push_back( item ); +} + + +bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) +{ + // Normal text labels cannot be tested for dangling ends. + if( Type() == TYPE_SCH_TEXT ) + return false; + + bool previousState = m_IsDangling; + + for( unsigned ii = 0; ii < aItemList.size(); ii++ ) + { + DANGLING_END_ITEM& item = aItemList[ii]; + + if( item.m_Item == this ) + continue; + + switch( item.m_Type ) + { + case PIN_END: + case LABEL_END: + case SHEET_LABEL_END: + if( m_Pos == item.m_Pos ) + m_IsDangling = false; + break; + + case WIRE_START_END: + case BUS_START_END: + { + // These schematic items have created 2 DANGLING_END_ITEM one per end. But being + // a paranoid programmer, I'll check just in case. + ii++; + + wxCHECK_MSG( ii < aItemList.size(), previousState != m_IsDangling, + wxT( "Dangling end type list overflow. Bad programmer!" ) ); + + DANGLING_END_ITEM & nextItem = aItemList[ii]; + m_IsDangling = !SegmentIntersect( item.m_Pos, nextItem.m_Pos, m_Pos ); + } + break; + + default: + break; + } + + if( m_IsDangling == false ) + break; + } + + return previousState != m_IsDangling; +} + + +bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Pos ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_TEXT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + // Normal text labels do not have connection points. All others do. + if( Type() == TYPE_SCH_TEXT ) + return; + + aPoints.push_back( m_Pos ); +} + + +EDA_Rect SCH_TEXT::GetBoundingBox() +{ + // We must pass the effective text thickness to GetTextBox + // when calculating the bounding box + int linewidth = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + + linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + EXCHG( linewidth, m_Width ); // Set the real width + EDA_Rect rect = GetTextBox( -1 ); + EXCHG( linewidth, m_Width ); // set initial value + + if( m_Orient ) // Rotate rect + { + wxPoint pos = rect.GetOrigin(); + wxPoint end = rect.GetEnd(); + RotatePoint( &pos, m_Pos, m_Orient ); + RotatePoint( &end, m_Pos, m_Orient ); + rect.SetOrigin( pos ); + rect.SetEnd( end ); + } + + rect.Normalize(); + return rect; +} + + +#if defined(DEBUG) + +void SCH_TEXT::Show( int nestLevel, std::ostream& os ) +{ + // XML output: + wxString s = GetClass(); + + NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() + << " layer=\"" << m_Layer << '"' + << " shape=\"" << m_Shape << '"' + << " dangling=\"" << m_IsDangling << '"' + << '>' + << CONV_TO_UTF8( m_Text ) + << "\n"; +} + + +#endif + + /** function GetSchematicTextOffset (virtual) * @return the offset between the SCH_TEXT position and the text itself * position * This offset depend on orientation, and the type of text * (room to draw an associated graphic symbol, or put the text above a wire) */ -wxPoint SCH_HIERLABEL::GetSchematicTextOffset() +wxPoint SCH_LABEL::GetSchematicTextOffset() { - wxPoint text_offset; + return SCH_TEXT::GetSchematicTextOffset(); +} - int width = MAX( m_Width, g_DrawDefaultLineThickness ); - int ii = m_Size.x + TXTMARGE + width; +/** function SetTextOrientAndJustifyParmeters + * Set m_SchematicOrientation, and initialize + * m_orient,m_HJustified and m_VJustified, according to the value of + * m_SchematicOrientation (for a label) + * must be called after changing m_SchematicOrientation + * @param aSchematicOrientation = + * 0 = normal (horizontal, left justified). + * 1 = up (vertical) + * 2 = (horizontal, right justified). This can be seen as the mirrored + * position of 0 + * 3 = bottom . This can be seen as the mirrored position of up + */ +void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation ) +{ + SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation ); +} + + +SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : + SCH_TEXT( pos, text, TYPE_SCH_LABEL ) +{ + m_Layer = LAYER_LOCLABEL; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; + m_MultilineAllowed = false; +} + + +/** virtual function Mirror_X + * mirror item relative to an X axis + * @param aXaxis_position = the x axis position + */ +void SCH_LABEL::Mirror_X( int aXaxis_position ) +{ + // Text is NOT really mirrored; it is moved to a suitable position + // which is the closest position for a true mirrored text + // The center position is mirrored and the text is moved for half + // horizontal len + int py = m_Pos.y; + + py -= aXaxis_position; + NEGATE( py ); + py += aXaxis_position; + m_Pos.y = py; +} + + +void SCH_LABEL::Rotate( wxPoint rotationPoint ) +{ + RotatePoint( &m_Pos, rotationPoint, 900 ); + SetSchematicTextOrientation( (GetSchematicTextOrientation() + 1) % 4 ); +} + + +/** + * Function Save + * writes the data structures for this object out to a FILE in "*.brd" format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ +bool SCH_LABEL::Save( FILE* aFile ) const +{ + bool success = true; + const char* shape = "~"; + + if( m_Italic ) + shape = "Italic"; + + if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n", + m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, shape, + m_Width, CONV_TO_UTF8( m_Text ) ) == EOF ) + { + success = false; + } + + return success; +} + + +/** Function SCH_LABEL::Draw + * a label is drawn like a text. So just call SCH_TEXT::Draw + */ +void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) +{ + SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color ); +} + + +EDA_Rect SCH_LABEL::GetBoundingBox() +{ + int x, y, dx, dy, length, height; + + x = m_Pos.x; + y = m_Pos.y; + int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; + length = LenSize( m_Text ); + height = m_Size.y + width; + dx = dy = 0; switch( m_SchematicOrientation ) { - case 0: /* Orientation horiz normale */ - text_offset.x = -ii; + case 0: /* Horiz Normal Orientation (left justified) */ + dx = 2 * DANGLING_SYMBOL_SIZE + length; + dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + x -= DANGLING_SYMBOL_SIZE; + y += DANGLING_SYMBOL_SIZE; break; - case 1: /* Orientation vert UP */ - text_offset.y = -ii; + case 1: /* Vert Orientation UP */ + dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + dy = -2 * DANGLING_SYMBOL_SIZE - length; + x += DANGLING_SYMBOL_SIZE; + y += DANGLING_SYMBOL_SIZE; break; - case 2: /* Orientation horiz inverse */ - text_offset.x = ii; + case 2: /* Horiz Orientation - Right justified */ + dx = -2 * DANGLING_SYMBOL_SIZE - length; + dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + x += DANGLING_SYMBOL_SIZE; + y += DANGLING_SYMBOL_SIZE; break; - case 3: /* Orientation vert BOTTOM */ - text_offset.y = ii; + case 3: /* Vert Orientation BOTTOM */ + dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + dy = 2 * DANGLING_SYMBOL_SIZE + length; + x += DANGLING_SYMBOL_SIZE; + y -= DANGLING_SYMBOL_SIZE; break; } - return text_offset; + EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) ); + box.Normalize(); + return box; } -/** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position +SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : + SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL ) +{ + m_Layer = LAYER_GLOBLABEL; + m_Shape = NET_BIDI; + m_IsDangling = TRUE; + m_MultilineAllowed = false; +} + + +/** + * Function Save + * writes the data structures for this object out to a FILE in "*.brd" format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. */ -void SCH_HIERLABEL::Mirror_Y( int aYaxis_position ) +bool SCH_GLOBALLABEL::Save( FILE* aFile ) const { -/* The hierarchical label is NOT really mirrored. - * for an horizontal label, the schematic orientation is changed. - * for a vericalal label, the schematic orientation is not changed. - * and the label is moved to a suitable position + bool success = true; + const char* shape = "~"; + + if( m_Italic ) + shape = "Italic"; + if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", + m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, + SheetLabelType[m_Shape], shape, m_Width, CONV_TO_UTF8( m_Text ) ) == EOF ) + { + success = false; + } + + return success; +} + + +/** Function HitTest + * @return true if the point aPosRef is within item area + * @param aPosRef = a wxPoint to test */ - - switch( GetSchematicTextOrientation() ) - { - case 0: /* horizontal text */ - SetSchematicTextOrientation( 2 ); - break; - - case 2: /* invert horizontal text*/ - SetSchematicTextOrientation( 0 ); - break; - } - - m_Pos.x -= aYaxis_position; - NEGATE( m_Pos.x ); - m_Pos.x += aYaxis_position; -} - - -void SCH_HIERLABEL::Mirror_X( int aXaxis_position ) +bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef ) { - switch( GetSchematicTextOrientation() ) - { - case 1: /* vertical text */ - SetSchematicTextOrientation( 3 ); - break; + EDA_Rect rect = GetBoundingBox(); - case 3: /* invert vertical text*/ - SetSchematicTextOrientation( 1 ); - break; - } - - m_Pos.y -= aXaxis_position; - NEGATE( m_Pos.y ); - m_Pos.y += aXaxis_position; -} - - -void SCH_HIERLABEL::Rotate( wxPoint rotationPoint ) -{ - RotatePoint( &m_Pos, rotationPoint, 900 ); - SetSchematicTextOrientation( (GetSchematicTextOrientation() + 3) % 4 ); + return rect.Inside( aPosRef ); } @@ -531,70 +926,6 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() } -/** function SetTextOrientAndJustifyParmeters (virtual) - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up - */ -void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation ) -{ - m_SchematicOrientation = aSchematicOrientation; - - switch( m_SchematicOrientation ) - { - default: - case 0: /* Horiz Normal Orientation (left justified) */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; - break; - - case 1: /* Vert Orientation UP */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; - break; - - case 2: /* Horiz Orientation - Right justified */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; - break; - - case 3: /* Vert Orientation BOTTOM */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; - break; - } -} - - -/** function SetTextOrientAndJustifyParmeters - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation (for a label) - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up - */ -void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation ) -{ - SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation ); -} - - /** function SetTextOrientAndJustifyParmeters * Set m_SchematicOrientation, and initialize * m_orient,m_HJustified and m_VJustified, according to the value of @@ -641,571 +972,14 @@ void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) } -/** function SetTextOrientAndJustifyParmeters - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up +/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon */ -void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) -{ - m_SchematicOrientation = aSchematicOrientation; - - switch( m_SchematicOrientation ) - { - default: - case 0: /* Horiz Normal Orientation */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; - break; - - case 1: /* Vert Orientation UP */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; - break; - - case 2: /* Horiz Orientation */ - m_Orient = TEXT_ORIENT_HORIZ; - m_HJustify = GR_TEXT_HJUSTIFY_LEFT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; - break; - - case 3: /* Vert Orientation BOTTOM */ - m_Orient = TEXT_ORIENT_VERT; - m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; - m_VJustify = GR_TEXT_VJUSTIFY_CENTER; - break; - } -} - - -/********************************************************/ -void SCH_TEXT::SwapData( SCH_TEXT* copyitem ) -{ -/********************************************************/ - EXCHG( m_Text, copyitem->m_Text ); - EXCHG( m_Pos, copyitem->m_Pos ); - EXCHG( m_Size, copyitem->m_Size ); - EXCHG( m_Width, copyitem->m_Width ); - EXCHG( m_Shape, copyitem->m_Shape ); - EXCHG( m_Orient, copyitem->m_Orient ); - - EXCHG( m_Layer, copyitem->m_Layer ); - EXCHG( m_HJustify, copyitem->m_HJustify ); - EXCHG( m_VJustify, copyitem->m_VJustify ); - EXCHG( m_IsDangling, copyitem->m_IsDangling ); - EXCHG( m_SchematicOrientation, copyitem->m_SchematicOrientation ); -} - - -/***************************************************************/ -void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) -{ -/***************************************************************/ - /* save old text in undo list */ - if( g_ItemToUndoCopy && ( (m_Flags & IS_NEW) == 0 ) ) - { - /* restore old values and save new ones */ - SwapData( (SCH_TEXT*) g_ItemToUndoCopy ); - - /* save in undo list */ - frame->SaveCopyInUndoList( this, UR_CHANGED ); - - /* restore new values */ - SwapData( (SCH_TEXT*) g_ItemToUndoCopy ); - - SAFE_DELETE( g_ItemToUndoCopy ); - } - - SCH_ITEM::Place( frame, DC ); -} - - -/** Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ -int SCH_TEXT::GetPenSize() -{ - int pensize = m_Width; - - if( pensize == 0 ) // Use default values for pen size - { - if( m_Bold ) - pensize = GetPenSizeForBold( m_Size.x ); - else - pensize = g_DrawDefaultLineThickness; - } - - // Clip pen size for small texts: - pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); - return pensize; -} - - -/****************************************************************************/ -void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, - int DrawMode, int Color ) -{ -/****************************************************************************/ - -/* Text type Comment (text on layer "NOTE") have 4 directions, and the Text - * origin is the first letter - */ - EDA_Colors color; - int linewidth = - (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; - - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); - - if( Color >= 0 ) - color = (EDA_Colors) Color; - else - color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - - wxPoint text_offset = aOffset + GetSchematicTextOffset(); - - EXCHG( linewidth, m_Width ); // Set the minimum width - EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, - UNSPECIFIED_COLOR ); - EXCHG( linewidth, m_Width ); // set initial value - if( m_IsDangling ) - DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); - - // Enable these line to draw the bounding box (debug tests purposes only) -#if 0 - { - EDA_Rect BoundaryBox; - BoundaryBox = GetBoundingBox(); - int x1 = BoundaryBox.GetX(); - int y1 = BoundaryBox.GetY(); - int x2 = BoundaryBox.GetRight(); - int y2 = BoundaryBox.GetBottom(); - GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); - } -#endif -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_TEXT::Save( FILE* aFile ) const -{ - bool success = true; - const char* shape = "~"; - - if( m_Italic ) - shape = "Italic"; - - wxString text = m_Text; - - for( ; ; ) - { - int i = text.find( '\n' ); - if( i==wxNOT_FOUND ) - break; - - text.erase( i, 1 ); - text.insert( i, wxT( "\\n" ) ); - } - - if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, - shape, m_Width, CONV_TO_UTF8( text ) ) == EOF ) - { - success = false; - } - - return success; -} - - -#if defined(DEBUG) - -void SCH_TEXT::Show( int nestLevel, std::ostream& os ) -{ - // XML output: - wxString s = GetClass(); - - NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() - << " layer=\"" << m_Layer << '"' - << " shape=\"" << m_Shape << '"' - << " dangling=\"" << m_IsDangling << '"' - << '>' - << CONV_TO_UTF8( m_Text ) - << "\n"; -} - - -#endif - -/****************************************************************************/ -SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : - SCH_TEXT( pos, text, TYPE_SCH_LABEL ) -{ -/****************************************************************************/ - m_Layer = LAYER_LOCLABEL; - m_Shape = NET_INPUT; - m_IsDangling = TRUE; - m_MultilineAllowed = false; -} - - -/** virtual function Mirror_X - * mirror item relative to an X axis - * @param aXaxis_position = the x axis position - */ -void SCH_LABEL::Mirror_X( int aXaxis_position ) -{ - // Text is NOT really mirrored; it is moved to a suitable position - // which is the closest position for a true mirrored text - // The center position is mirrored and the text is moved for half - // horizontal len - int py = m_Pos.y; - - py -= aXaxis_position; - NEGATE( py ); - py += aXaxis_position; - m_Pos.y = py; -} - - -void SCH_LABEL::Rotate( wxPoint rotationPoint ) -{ - RotatePoint( &m_Pos, rotationPoint, 900 ); - SetSchematicTextOrientation( (GetSchematicTextOrientation() + 1) % 4 ); -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_LABEL::Save( FILE* aFile ) const -{ - bool success = true; - const char* shape = "~"; - - if( m_Italic ) - shape = "Italic"; - - if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, shape, - m_Width, CONV_TO_UTF8( m_Text ) ) == EOF ) - { - success = false; - } - - return success; -} - - -/*****************************************************************************/ -SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : - SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL ) -{ -/*****************************************************************************/ - m_Layer = LAYER_GLOBLABEL; - m_Shape = NET_BIDI; - m_IsDangling = TRUE; - m_MultilineAllowed = false; -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_GLOBALLABEL::Save( FILE* aFile ) const -{ - bool success = true; - const char* shape = "~"; - - if( m_Italic ) - shape = "Italic"; - if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, - SheetLabelType[m_Shape], shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) - { - success = false; - } - - return success; -} - - -/************************************************/ -bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef ) -{ -/************************************************/ - -/** Function HitTest - * @return true if the point aPosRef is within item area - * @param aPosRef = a wxPoint to test - */ - EDA_Rect rect = GetBoundingBox(); - - return rect.Inside( aPosRef ); -} - - -/*****************************************************************************/ -SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) : - SCH_TEXT( pos, text, aType ) -{ -/*****************************************************************************/ - m_Layer = LAYER_HIERLABEL; - m_Shape = NET_INPUT; - m_IsDangling = TRUE; - m_MultilineAllowed = false; -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_HIERLABEL::Save( FILE* aFile ) const -{ - bool success = true; - const char* shape = "~"; - - if( m_Italic ) - shape = "Italic"; - if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", - m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, - SheetLabelType[m_Shape], shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) - { - success = false; - } - - return success; -} - - -/************************************************/ -bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef ) -{ -/************************************************/ - -/** Function HitTest - * @return true if the point aPosRef is within item area - * @param aPosRef = a wxPoint to test - */ - EDA_Rect rect = GetBoundingBox(); - - return rect.Inside( aPosRef ); -} - - -/** Function SCH_LABEL::Draw - * a label is drawn like a text. So just call SCH_TEXT::Draw - */ -void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -{ - SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color ); -} - - -/*****************************************************************************/ -void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, - wxDC* DC, - const wxPoint& offset, - int DrawMode, - int Color ) -{ -/*****************************************************************************/ - -/* Hierarchical Label have a text and a graphic icon. - * Texts type have 4 directions, and the text origin is the graphic icon - */ - static std::vector Poly; - EDA_Colors color; - int linewidth = - ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; - - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); - - if( Color >= 0 ) - color = (EDA_Colors) Color; - else - color = ReturnLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - - EXCHG( linewidth, m_Width ); // Set the minimum width - wxPoint text_offset = offset + GetSchematicTextOffset(); - EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, - UNSPECIFIED_COLOR ); - EXCHG( linewidth, m_Width ); // set initial value - - CreateGraphicShape( Poly, m_Pos + offset ); - GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, - color, color ); - - if( m_IsDangling ) - DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); - - // Enable these line to draw the bounding box (debug tests purposes only) -#if 0 - { - EDA_Rect BoundaryBox; - BoundaryBox = GetBoundingBox(); - int x1 = BoundaryBox.GetX(); - int y1 = BoundaryBox.GetY(); - int x2 = BoundaryBox.GetRight(); - int y2 = BoundaryBox.GetBottom(); - GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); - } -#endif -} - - -/** Function CreateGraphicShape - * calculates the graphic shape (a polygon) associated to the text - * @param aCorner_list = a buffer to fill with polygon corners coordinates - * @param Pos = Postion of the shape - */ -void SCH_HIERLABEL::CreateGraphicShape( std::vector & aCorner_list, - const wxPoint& Pos ) -{ - int* Template = TemplateShape[m_Shape][m_SchematicOrientation]; - int HalfSize = m_Size.x / 2; - - int imax = *Template; Template++; - - aCorner_list.clear(); - for( int ii = 0; ii < imax; ii++ ) - { - wxPoint corner; - corner.x = ( HalfSize * (*Template) ) + Pos.x; - Template++; - - corner.y = ( HalfSize * (*Template) ) + Pos.y; - Template++; - - aCorner_list.push_back( corner ); - } -} - -/** Virtual Function SCH_SHEET_PIN::CreateGraphicShape - * calculates the graphic shape (a polygon) associated to the text - * @param aCorner_list = a buffer to fill with polygon corners coordinates - * @param aPos = Position of the shape - */ -void SCH_SHEET_PIN::CreateGraphicShape( std::vector & aCorner_list, - const wxPoint& aPos ) -{ - /* This is the same icon shapes as SCH_HIERLABEL - * but the graphic icon is slightly different in 2 cases: - * for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL - * for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL - */ - int tmp = m_Shape; - switch( m_Shape ) - { - case NET_INPUT: - m_Shape = NET_OUTPUT; - break; - - case NET_OUTPUT: - m_Shape = NET_INPUT; - break; - - default: - break; - } - SCH_HIERLABEL::CreateGraphicShape( aCorner_list, aPos ); - m_Shape = tmp; -} - -/****************************************/ -EDA_Rect SCH_HIERLABEL::GetBoundingBox() -{ -/****************************************/ - int x, y, dx, dy, length, height; - - x = m_Pos.x; - y = m_Pos.y; - dx = dy = 0; - - int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; - height = m_Size.y + width + 2 * TXTMARGE; - length = LenSize( m_Text ) - + height // add height for triangular shapes - + 2 * DANGLING_SYMBOL_SIZE; - - switch( m_SchematicOrientation ) // respect orientation - { - case 0: /* Horiz Normal Orientation (left - *justified) */ - dx = -length; - dy = height; - x += DANGLING_SYMBOL_SIZE; - y -= height / 2; - break; - - case 1: /* Vert Orientation UP */ - dx = height; - dy = -length; - x -= height / 2; - y += DANGLING_SYMBOL_SIZE; - break; - - case 2: /* Horiz Orientation - Right justified */ - dx = length; - dy = height; - x -= DANGLING_SYMBOL_SIZE; - y -= height / 2; - break; - - case 3: /* Vert Orientation BOTTOM */ - dx = height; - dy = length; - x -= height / 2; - y -= DANGLING_SYMBOL_SIZE; - break; - } - - EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) ); - box.Normalize(); - return box; -} - - -/*****************************************************************************/ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, int DrawMode, int Color ) { -/*****************************************************************************/ - -/* Texts type Global Label have 4 directions, and the Text origin is the - * graphic icon - */ static std::vector Poly; EDA_Colors color; wxPoint text_offset = aOffset + GetSchematicTextOffset(); @@ -1221,13 +995,11 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); EXCHG( linewidth, m_Width ); // Set the minimum width - EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, - UNSPECIFIED_COLOR ); + EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Width ); // set initial value CreateGraphicShape( Poly, m_Pos + aOffset ); - GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, - color, color ); + GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); if( m_IsDangling ) DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); @@ -1336,10 +1108,8 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aCorner_list, } -/******************************************/ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() { -/******************************************/ int x, y, dx, dy, length, height; x = m_Pos.x; @@ -1389,46 +1159,216 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() } -/***********************************/ -EDA_Rect SCH_LABEL::GetBoundingBox() -/***********************************/ +SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) : + SCH_TEXT( pos, text, aType ) { - int x, y, dx, dy, length, height; + m_Layer = LAYER_HIERLABEL; + m_Shape = NET_INPUT; + m_IsDangling = TRUE; + m_MultilineAllowed = false; +} - x = m_Pos.x; - y = m_Pos.y; - int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; - length = LenSize( m_Text ); - height = m_Size.y + width; - dx = dy = 0; + +/** + * Function Save + * writes the data structures for this object out to a FILE in "*.brd" format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ +bool SCH_HIERLABEL::Save( FILE* aFile ) const +{ + bool success = true; + const char* shape = "~"; + + if( m_Italic ) + shape = "Italic"; + if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", + m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, + SheetLabelType[m_Shape], shape, m_Width, CONV_TO_UTF8( m_Text ) ) == EOF ) + { + success = false; + } + + return success; +} + + + +/** Function HitTest + * @return true if the point aPosRef is within item area + * @param aPosRef = a wxPoint to test + */ +bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef ) +{ + EDA_Rect rect = GetBoundingBox(); + + return rect.Inside( aPosRef ); +} + + +/** function SetTextOrientAndJustifyParmeters + * Set m_SchematicOrientation, and initialize + * m_orient,m_HJustified and m_VJustified, according to the value of + * m_SchematicOrientation + * must be called after changing m_SchematicOrientation + * @param aSchematicOrientation = + * 0 = normal (horizontal, left justified). + * 1 = up (vertical) + * 2 = (horizontal, right justified). This can be seen as the mirrored + * position of 0 + * 3 = bottom . This can be seen as the mirrored position of up + */ +void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) +{ + m_SchematicOrientation = aSchematicOrientation; switch( m_SchematicOrientation ) { - case 0: /* Horiz Normal Orientation (left justified) */ - dx = 2 * DANGLING_SYMBOL_SIZE + length; - dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; - x -= DANGLING_SYMBOL_SIZE; - y += DANGLING_SYMBOL_SIZE; + default: + case 0: /* Horiz Normal Orientation */ + m_Orient = TEXT_ORIENT_HORIZ; + m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + break; + + case 1: /* Vert Orientation UP */ + m_Orient = TEXT_ORIENT_VERT; + m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + break; + + case 2: /* Horiz Orientation */ + m_Orient = TEXT_ORIENT_HORIZ; + m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + break; + + case 3: /* Vert Orientation BOTTOM */ + m_Orient = TEXT_ORIENT_VERT; + m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + break; + } +} + + +/* Hierarchical Label have a text and a graphic icon. + * Texts type have 4 directions, and the text origin is the graphic icon + */ +void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, + wxDC* DC, + const wxPoint& offset, + int DrawMode, + int Color ) +{ + static std::vector Poly; + EDA_Colors color; + int linewidth = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + + linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); + + if( Color >= 0 ) + color = (EDA_Colors) Color; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( DC, DrawMode ); + + EXCHG( linewidth, m_Width ); // Set the minimum width + wxPoint text_offset = offset + GetSchematicTextOffset(); + EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); + EXCHG( linewidth, m_Width ); // set initial value + + CreateGraphicShape( Poly, m_Pos + offset ); + GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + + if( m_IsDangling ) + DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); + + // Enable these line to draw the bounding box (debug tests purposes only) +#if 0 + { + EDA_Rect BoundaryBox; + BoundaryBox = GetBoundingBox(); + int x1 = BoundaryBox.GetX(); + int y1 = BoundaryBox.GetY(); + int x2 = BoundaryBox.GetRight(); + int y2 = BoundaryBox.GetBottom(); + GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); + } +#endif +} + + +/** Function CreateGraphicShape + * calculates the graphic shape (a polygon) associated to the text + * @param aCorner_list = a buffer to fill with polygon corners coordinates + * @param Pos = Postion of the shape + */ +void SCH_HIERLABEL::CreateGraphicShape( std::vector & aCorner_list, + const wxPoint& Pos ) +{ + int* Template = TemplateShape[m_Shape][m_SchematicOrientation]; + int HalfSize = m_Size.x / 2; + + int imax = *Template; Template++; + + aCorner_list.clear(); + for( int ii = 0; ii < imax; ii++ ) + { + wxPoint corner; + corner.x = ( HalfSize * (*Template) ) + Pos.x; + Template++; + + corner.y = ( HalfSize * (*Template) ) + Pos.y; + Template++; + + aCorner_list.push_back( corner ); + } +} + +EDA_Rect SCH_HIERLABEL::GetBoundingBox() +{ + int x, y, dx, dy, length, height; + + x = m_Pos.x; + y = m_Pos.y; + dx = dy = 0; + + int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; + height = m_Size.y + width + 2 * TXTMARGE; + length = LenSize( m_Text ) + + height // add height for triangular shapes + + 2 * DANGLING_SYMBOL_SIZE; + + switch( m_SchematicOrientation ) // respect orientation + { + case 0: /* Horiz Normal Orientation (left + *justified) */ + dx = -length; + dy = height; + x += DANGLING_SYMBOL_SIZE; + y -= height / 2; break; case 1: /* Vert Orientation UP */ - dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; - dy = -2 * DANGLING_SYMBOL_SIZE - length; - x += DANGLING_SYMBOL_SIZE; + dx = height; + dy = -length; + x -= height / 2; y += DANGLING_SYMBOL_SIZE; break; case 2: /* Horiz Orientation - Right justified */ - dx = -2 * DANGLING_SYMBOL_SIZE - length; - dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; - x += DANGLING_SYMBOL_SIZE; - y += DANGLING_SYMBOL_SIZE; + dx = length; + dy = height; + x -= DANGLING_SYMBOL_SIZE; + y -= height / 2; break; case 3: /* Vert Orientation BOTTOM */ - dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; - dy = 2 * DANGLING_SYMBOL_SIZE + length; - x += DANGLING_SYMBOL_SIZE; + dx = height; + dy = length; + x -= height / 2; y -= DANGLING_SYMBOL_SIZE; break; } @@ -1439,30 +1379,93 @@ EDA_Rect SCH_LABEL::GetBoundingBox() } -/***********************************/ -EDA_Rect SCH_TEXT::GetBoundingBox() -/***********************************/ +/** function GetSchematicTextOffset (virtual) + * @return the offset between the SCH_TEXT position and the text itself + * position + * This offset depend on orientation, and the type of text + * (room to draw an associated graphic symbol, or put the text above a wire) + */ +wxPoint SCH_HIERLABEL::GetSchematicTextOffset() { - // We must pass the effective text thickness to GetTextBox - // when calculating the bounding box - int linewidth = - (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; + wxPoint text_offset; - linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); - EXCHG( linewidth, m_Width ); // Set the real width - EDA_Rect rect = GetTextBox( -1 ); - EXCHG( linewidth, m_Width ); // set initial value + int width = MAX( m_Width, g_DrawDefaultLineThickness ); - if( m_Orient ) // Rotate rect + int ii = m_Size.x + TXTMARGE + width; + + switch( m_SchematicOrientation ) { - wxPoint pos = rect.GetOrigin(); - wxPoint end = rect.GetEnd(); - RotatePoint( &pos, m_Pos, m_Orient ); - RotatePoint( &end, m_Pos, m_Orient ); - rect.SetOrigin( pos ); - rect.SetEnd( end ); + case 0: /* Orientation horiz normale */ + text_offset.x = -ii; + break; + + case 1: /* Orientation vert UP */ + text_offset.y = -ii; + break; + + case 2: /* Orientation horiz inverse */ + text_offset.x = ii; + break; + + case 3: /* Orientation vert BOTTOM */ + text_offset.y = ii; + break; } - rect.Normalize(); - return rect; + return text_offset; +} + + +/** virtual function Mirror_Y + * mirror item relative to an Y axis + * @param aYaxis_position = the y axis position + */ +void SCH_HIERLABEL::Mirror_Y( int aYaxis_position ) +{ +/* The hierarchical label is NOT really mirrored. + * for an horizontal label, the schematic orientation is changed. + * for a vericalal label, the schematic orientation is not changed. + * and the label is moved to a suitable position + */ + + switch( GetSchematicTextOrientation() ) + { + case 0: /* horizontal text */ + SetSchematicTextOrientation( 2 ); + break; + + case 2: /* invert horizontal text*/ + SetSchematicTextOrientation( 0 ); + break; + } + + m_Pos.x -= aYaxis_position; + NEGATE( m_Pos.x ); + m_Pos.x += aYaxis_position; +} + + +void SCH_HIERLABEL::Mirror_X( int aXaxis_position ) +{ + switch( GetSchematicTextOrientation() ) + { + case 1: /* vertical text */ + SetSchematicTextOrientation( 3 ); + break; + + case 3: /* invert vertical text*/ + SetSchematicTextOrientation( 1 ); + break; + } + + m_Pos.y -= aXaxis_position; + NEGATE( m_Pos.y ); + m_Pos.y += aXaxis_position; +} + + +void SCH_HIERLABEL::Rotate( wxPoint rotationPoint ) +{ + RotatePoint( &m_Pos, rotationPoint, 900 ); + SetSchematicTextOrientation( (GetSchematicTextOrientation() + 3) % 4 ); } diff --git a/eeschema/class_text-label.h b/eeschema/class_text-label.h index 7e4c455826..141f02a711 100644 --- a/eeschema/class_text-label.h +++ b/eeschema/class_text-label.h @@ -167,8 +167,17 @@ public: * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @return True if this schematic text item matches the search criteria. */ - virtual bool Matches( wxFindReplaceData& aSearchData, - void* aAuxData, wxPoint * aFindLocation ); + virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); + + virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ); + + virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ); + + virtual bool IsDangling() const { return m_IsDangling; } + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); diff --git a/eeschema/dangling_ends.cpp b/eeschema/dangling_ends.cpp index 5a3e151178..163c35150a 100644 --- a/eeschema/dangling_ends.cpp +++ b/eeschema/dangling_ends.cpp @@ -4,55 +4,14 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "program.h" #include "general.h" -#include "netlist.h" #include "protos.h" -#include "class_library.h" +#include "class_libentry.h" #include "lib_pin.h" -enum End_Type { - UNKNOWN = 0, - WIRE_START_END, - WIRE_END_END, - BUS_START_END, - BUS_END_END, - JUNCTION_END, - PIN_END, - LABEL_END, - ENTRY_END, - SHEET_LABEL_END -}; - -// A helper class to store a list of items that can be connected to something: -class DANGLING_END_ITEM -{ -public: - const void* m_Item; // a pointer to the parent - wxPoint m_Pos; // the position of the connecting point - int m_Type; // type of parent - - DANGLING_END_ITEM( int type, const void* aItem ) - { - m_Item = aItem; - m_Type = type; - } -}; - -static void TestWireForDangling( std::vector & aItemList, - SCH_LINE* DrawRef, - WinEDA_SchematicFrame* frame, - wxDC* aDC ); -void TestLabelForDangling( std::vector & aItemList, - SCH_TEXT* aLabel, - WinEDA_SchematicFrame* aFrame, - wxDC* aDC ); -void RebuildEndPointsList( std::vector & aItemList, SCH_ITEM* aDrawList ); - - /* Returns true if the point P is on the segment S. */ bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint ) { @@ -64,60 +23,27 @@ bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint ) return false; /* Cross product non-zero, vectors not parallel */ if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) < - ( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) ) + ( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) ) return false; /* Point not on segment */ return true; } -void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) +void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* aDrawList, wxDC* aDC ) { - // this list is static to avoid many useles memory allocation. - std::vector itemList; + SCH_ITEM* item; + std::vector< DANGLING_END_ITEM > endPoints; - RebuildEndPointsList( itemList, DrawList ); + for( item = aDrawList; item != NULL; item = item->Next() ) + item->GetEndPoints( endPoints ); - for( SCH_ITEM* item = DrawList; item; item = item->Next() ) + for( item = aDrawList; item; item = item->Next() ) { - switch( item->Type() ) + if( item->IsDanglingStateChanged( endPoints ) && aDC != NULL ) { - case TYPE_SCH_GLOBALLABEL: - case TYPE_SCH_HIERLABEL: - case TYPE_SCH_LABEL: - TestLabelForDangling( itemList, (SCH_LABEL*) item, this, DC ); - break; - - case DRAW_SHEET_STRUCT_TYPE: - { - SCH_SHEET* sheet = (SCH_SHEET*) item; - // Read the hierarchical pins list and teast for dangling pins: - BOOST_FOREACH( SCH_SHEET_PIN & pinsheet, sheet->GetSheetPins() ) - { - TestLabelForDangling( itemList, &pinsheet, this, DC ); - } - } - break; - - case DRAW_SEGMENT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ( (SCH_LINE*) item ) - if( STRUCT->GetLayer() == LAYER_WIRE ) - { - TestWireForDangling( itemList, STRUCT, this, DC ); - break; - } - if( STRUCT->GetLayer() == LAYER_NOTES ) - break; - if( STRUCT->GetLayer() == LAYER_BUS ) - { - STRUCT->m_StartIsDangling = STRUCT->m_EndIsDangling = false; - break; - } - break; - - default: - break; + RedrawOneStruct( DrawPanel, aDC, item, g_XorMode ); + RedrawOneStruct( DrawPanel, aDC, item, GR_DEFAULT_DRAWMODE ); } } } @@ -129,8 +55,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) * @param DrawList = List of SCH_ITEMs to check. * @return a LIB_PIN pointer to the located pin or NULL if no pin was found. */ -LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, - const wxPoint& pos ) +LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, const wxPoint& pos ) { SCH_COMPONENT* DrawLibItem; LIB_PIN* Pin; @@ -153,234 +78,3 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, return Pin; return NULL; } - - -void TestWireForDangling( std::vector & aItemList, - SCH_LINE* DrawRef, - WinEDA_SchematicFrame* frame, - wxDC* DC ) -{ - bool Sdangstate = true, Edangstate = true; - - BOOST_FOREACH( DANGLING_END_ITEM terminal_item, aItemList ) - { - if( terminal_item.m_Item == DrawRef ) - continue; - - if( DrawRef->m_Start == terminal_item.m_Pos ) - Sdangstate = false; - - if( DrawRef->m_End == terminal_item.m_Pos ) - Edangstate = false; - - if( (Sdangstate == false) && (Edangstate == false) ) - break; - } - - if( (Sdangstate != DrawRef->m_StartIsDangling) - || (Edangstate != DrawRef->m_EndIsDangling) ) - { - if( DC ) - RedrawOneStruct( frame->DrawPanel, DC, DrawRef, g_XorMode ); - DrawRef->m_StartIsDangling = Sdangstate; - DrawRef->m_EndIsDangling = Edangstate; - if( DC ) - RedrawOneStruct( frame->DrawPanel, DC, DrawRef, - GR_DEFAULT_DRAWMODE ); - } -} - - -void TestLabelForDangling( std::vector & aItemList, - SCH_TEXT* aLabel, - WinEDA_SchematicFrame* aFrame, - wxDC* aDC ) -{ - bool dangstate = true; - - for( unsigned ii = 0; ii < aItemList.size(); ii++ ) - { - DANGLING_END_ITEM & terminal_item = aItemList[ii]; - - if( terminal_item.m_Item == aLabel ) - continue; - - switch( terminal_item.m_Type ) - { - case PIN_END: - case LABEL_END: - case SHEET_LABEL_END: - if( aLabel->m_Pos == terminal_item.m_Pos ) - dangstate = false; - break; - - case WIRE_START_END: - case BUS_START_END: - { - // these schematic items have created 2 DANGLING_END_ITEM - // one per end. - ii++; - DANGLING_END_ITEM & next_terminal = aItemList[ii]; - dangstate = !SegmentIntersect( terminal_item.m_Pos, - next_terminal.m_Pos, - aLabel->m_Pos ); - } - break; - - case UNKNOWN: - case JUNCTION_END: - case ENTRY_END: - case WIRE_END_END: - case BUS_END_END: - break; - } - - if( dangstate == false ) - break; - } - - if( dangstate != aLabel->m_IsDangling ) - { - if( aDC ) - RedrawOneStruct( aFrame->DrawPanel, aDC, aLabel, g_XorMode ); - aLabel->m_IsDangling = dangstate; - if( aDC ) - RedrawOneStruct( aFrame->DrawPanel, aDC, aLabel, GR_DEFAULT_DRAWMODE ); - } -} - - -/* Returns the physical position of the pin relative to the component - * orientation. */ -wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem ) -{ - wxPoint PinPos = Pin->m_Pos; - - if( DrawLibItem == NULL ) - NEGATE( PinPos.y ); - - else - PinPos = DrawLibItem->m_Transform.TransformCoordinate( Pin->m_Pos ) + DrawLibItem->m_Pos; - - return PinPos; -} - - -void RebuildEndPointsList( std::vector & aItemList, SCH_ITEM* aDrawList ) -{ - SCH_ITEM* schItem; - - aItemList.clear(); - - for( schItem = aDrawList; schItem != NULL; schItem = schItem->Next() ) - { - switch( schItem->Type() ) - { - case TYPE_SCH_LABEL: - case TYPE_SCH_GLOBALLABEL: - case TYPE_SCH_HIERLABEL: - { - #undef STRUCT - #define STRUCT ( (SCH_LABEL*) schItem ) - DANGLING_END_ITEM item( LABEL_END, schItem ); - item.m_Pos = STRUCT->m_Pos; - aItemList.push_back( item ); - } - break; - - case DRAW_SEGMENT_STRUCT_TYPE: - #undef STRUCT - #define STRUCT ( (SCH_LINE*) schItem ) - if( STRUCT->GetLayer() == LAYER_NOTES ) - break; - if( ( STRUCT->GetLayer() == LAYER_BUS ) - || (STRUCT->GetLayer() == LAYER_WIRE ) ) - { - DANGLING_END_ITEM item( (STRUCT->GetLayer() == LAYER_BUS) ? - BUS_START_END : WIRE_START_END, schItem ); - item.m_Pos = STRUCT->m_Start; - DANGLING_END_ITEM item1( (STRUCT->GetLayer() == LAYER_BUS) ? - BUS_END_END : WIRE_END_END, schItem ); - item1.m_Pos = STRUCT->m_End; - - aItemList.push_back( item ); - aItemList.push_back( item1 ); - } - break; - - case DRAW_JUNCTION_STRUCT_TYPE: - { - #undef STRUCT - #define STRUCT ( (SCH_JUNCTION*) schItem ) - DANGLING_END_ITEM item( JUNCTION_END, schItem ); - item.m_Pos = STRUCT->m_Pos; - aItemList.push_back( item ); - } - break; - - case DRAW_BUSENTRY_STRUCT_TYPE: - { - #undef STRUCT - #define STRUCT ( (SCH_BUS_ENTRY*) schItem ) - DANGLING_END_ITEM item( ENTRY_END, schItem ); - item.m_Pos = STRUCT->m_Pos; - - DANGLING_END_ITEM item1( ENTRY_END, schItem ); - item1.m_Pos = STRUCT->m_End(); - aItemList.push_back( item ); - aItemList.push_back( item1 ); - } - break; - - case TYPE_SCH_COMPONENT: - { - #undef STRUCT - #define STRUCT ( (SCH_COMPONENT*) schItem ) - LIB_COMPONENT* Entry; - Entry = CMP_LIBRARY::FindLibraryComponent( STRUCT->m_ChipName ); - if( Entry == NULL ) - break; - - for( LIB_PIN* Pin = Entry->GetNextPin(); Pin != NULL; - Pin = Entry->GetNextPin( Pin ) ) - { - wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); - - if( Pin->GetUnit() && STRUCT->m_Multi && ( STRUCT->m_Multi != Pin->GetUnit() ) ) - continue; - - if( Pin->GetConvert() && STRUCT->m_Convert - && ( STRUCT->m_Convert != Pin->GetConvert() ) ) - continue; - - DANGLING_END_ITEM item( PIN_END, Pin ); - item.m_Pos = ReturnPinPhysicalPosition( Pin, STRUCT ); - aItemList.push_back( item ); - } - - break; - } - - case DRAW_SHEET_STRUCT_TYPE: - { - SCH_SHEET* sheet = (SCH_SHEET*) schItem; - - // Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet). - // I do not know why. - for( unsigned ii = 0; ii < sheet->GetSheetPins().size(); ii++ ) - { - SCH_SHEET_PIN &pinsheet = sheet->GetSheetPins()[ii]; - wxASSERT( pinsheet.Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ); - - DANGLING_END_ITEM item( SHEET_LABEL_END, &pinsheet ); - item.m_Pos = pinsheet.m_Pos; - aItemList.push_back( item ); - } - } - break; - - default: - ; - } - } -} diff --git a/eeschema/dialog_edit_component_in_lib_base.cpp b/eeschema/dialog_edit_component_in_lib_base.cpp index 5877403740..5afd6dcb25 100644 --- a/eeschema/dialog_edit_component_in_lib_base.cpp +++ b/eeschema/dialog_edit_component_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -25,28 +25,24 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_OptionsBoxSizer = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("General :") ), wxVERTICAL ); m_AsConvertButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("As Convert"), wxDefaultPosition, wxDefaultSize, 0 ); - m_AsConvertButt->SetToolTip( _("Check this option for components that have a De Morgan representation.\nThis is usual for gates.") ); m_OptionsBoxSizer->Add( m_AsConvertButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_ShowPinNumButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Show Pin Num"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowPinNumButt->SetValue(true); - + m_ShowPinNumButt->SetValue(true); m_ShowPinNumButt->SetToolTip( _("Show or hide pin numbers") ); m_OptionsBoxSizer->Add( m_ShowPinNumButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_ShowPinNameButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Show Pin Name"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowPinNameButt->SetValue(true); - + m_ShowPinNameButt->SetValue(true); m_ShowPinNameButt->SetToolTip( _("Show or hide pin names") ); m_OptionsBoxSizer->Add( m_ShowPinNameButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_PinsNameInsideButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Pin Name Inside"), wxDefaultPosition, wxDefaultSize, 0 ); - m_PinsNameInsideButt->SetValue(true); - + m_PinsNameInsideButt->SetValue(true); m_PinsNameInsideButt->SetToolTip( _("Check this option to have pin names inside the body and pin number outside.\nIf not checked pins names and pins numbers are outside.") ); m_OptionsBoxSizer->Add( m_PinsNameInsideButt, 0, wxALL, 5 ); @@ -93,13 +89,11 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx bSizerBasicPanel->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); m_OptionPower = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Power Symbol"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptionPower->SetToolTip( _("Check this option for power symbols.\nPower symbols have specific properties for Eeschema:\n- Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol\n- Reference is updated automatically when a netlist is created (no need to run Annotate)") ); bSizerBasicPanel->Add( m_OptionPower, 0, wxALL, 5 ); m_OptionPartsLocked = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptionPartsLocked->SetToolTip( _("Check this option if Eeschema cannot change parts selections inside a given package\nThis happens when parts are different in this package.\nWhen this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count") ); bSizerBasicPanel->Add( m_OptionPartsLocked, 0, wxALL, 5 ); @@ -123,7 +117,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_staticTextKeywords = new wxStaticText( m_PanelDoc, wxID_ANY, _("Keywords:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextKeywords->Wrap( -1 ); - m_staticTextKeywords->SetToolTip( _("Enter key words that can be used to select this composant.\nKey words cannot have spaces and are separated by a space.") ); + m_staticTextKeywords->SetToolTip( _("Enter key words that can be used to select this component.\nKey words cannot have spaces and are separated by a space.") ); m_PanelDocBoxSizer->Add( m_staticTextKeywords, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -266,4 +260,5 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE() m_ButtonDeleteAllFootprintFilter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DeleteAllFootprintFilter ), NULL, this ); m_sdbSizer2Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnCancelClick ), NULL, this ); m_sdbSizer2OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnOkClick ), NULL, this ); + } diff --git a/eeschema/dialog_edit_component_in_lib_base.fbp b/eeschema/dialog_edit_component_in_lib_base.fbp index 8e8bf16b4b..3292427993 100644 --- a/eeschema/dialog_edit_component_in_lib_base.fbp +++ b/eeschema/dialog_edit_component_in_lib_base.fbp @@ -1,10 +1,12 @@ - + C++ 1 + source_name + 0 UTF-8 connect dialog_edit_component_in_lib_base @@ -16,13 +18,16 @@ . 1 + 1 0 0 + 1 1 + impl_virtual @@ -37,6 +42,10 @@ Lib Component Properties + + wxFILTER_NONE + wxDefaultValidator + @@ -83,6 +92,7 @@ + 1 1 @@ -97,6 +107,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -132,6 +146,7 @@ + 1 1 @@ -145,6 +160,10 @@ + + wxFILTER_NONE + wxDefaultValidator + wxSUNKEN_BORDER|wxTAB_TRAVERSAL @@ -196,6 +215,7 @@ 0 + 1 1 @@ -211,6 +231,10 @@ Check this option for components that have a De Morgan representation. This is usual for gates. + + wxFILTER_NONE + wxDefaultValidator + @@ -248,6 +272,7 @@ 1 + 1 1 @@ -263,6 +288,10 @@ Show or hide pin numbers + + wxFILTER_NONE + wxDefaultValidator + @@ -300,6 +329,7 @@ 1 + 1 1 @@ -315,6 +345,10 @@ Show or hide pin names + + wxFILTER_NONE + wxDefaultValidator + @@ -352,6 +386,7 @@ 1 + 1 1 @@ -367,6 +402,10 @@ Check this option to have pin names inside the body and pin number outside. If not checked pins names and pins numbers are outside. + + wxFILTER_NONE + wxDefaultValidator + @@ -405,6 +444,7 @@ + 1 1 @@ -419,6 +459,10 @@ wxLI_HORIZONTAL + + wxFILTER_NONE + wxDefaultValidator + @@ -472,6 +516,7 @@ + 1 1 @@ -487,6 +532,10 @@ This is the number of parts in this component package. A 74LS00 gate has 4 parts per packages. + + wxFILTER_NONE + wxDefaultValidator + @@ -523,6 +572,7 @@ + 1 1 @@ -540,6 +590,10 @@ wxSP_ARROW_KEYS + + wxFILTER_NONE + wxDefaultValidator + @@ -589,6 +643,7 @@ + 1 1 @@ -604,6 +659,10 @@ Margin (in 0.001 inches) between a pin name position and the component body. A value from 10 to 40 is usually good. + + wxFILTER_NONE + wxDefaultValidator + @@ -640,6 +699,7 @@ + 1 1 @@ -657,6 +717,10 @@ wxSP_ARROW_KEYS + + wxFILTER_NONE + wxDefaultValidator + @@ -699,6 +763,7 @@ + 1 1 @@ -713,6 +778,10 @@ wxLI_HORIZONTAL + + wxFILTER_NONE + wxDefaultValidator + @@ -749,6 +818,7 @@ 0 + 1 1 @@ -764,6 +834,10 @@ Check this option for power symbols. Power symbols have specific properties for Eeschema: - Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol - Reference is updated automatically when a netlist is created (no need to run Annotate) + + wxFILTER_NONE + wxDefaultValidator + @@ -801,6 +875,7 @@ 0 + 1 1 @@ -816,6 +891,10 @@ Check this option if Eeschema cannot change parts selections inside a given package This happens when parts are different in this package. When this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count + + wxFILTER_NONE + wxDefaultValidator + @@ -855,6 +934,7 @@ + 1 1 @@ -868,6 +948,10 @@ + + wxFILTER_NONE + wxDefaultValidator + wxSUNKEN_BORDER|wxTAB_TRAVERSAL @@ -906,6 +990,7 @@ + 1 1 @@ -921,6 +1006,10 @@ A short description that is displayed in Eeschema. Can be a very good help when selecting components in libraries components lists. + + wxFILTER_NONE + wxDefaultValidator + @@ -957,6 +1046,7 @@ + 1 1 @@ -972,6 +1062,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1012,6 +1106,7 @@ + 1 1 @@ -1026,7 +1121,11 @@ - Enter key words that can be used to select this composant. Key words cannot have spaces and are separated by a space. + Enter key words that can be used to select this component. Key words cannot have spaces and are separated by a space. + + wxFILTER_NONE + wxDefaultValidator + @@ -1063,6 +1162,7 @@ + 1 1 @@ -1078,6 +1178,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1118,6 +1222,7 @@ + 1 1 @@ -1133,6 +1238,10 @@ Enter the documentation file (a .pdf document) associated to the component. + + wxFILTER_NONE + wxDefaultValidator + @@ -1169,6 +1278,7 @@ + 1 1 @@ -1184,6 +1294,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1233,6 +1347,7 @@ + 1 0 1 @@ -1249,6 +1364,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1285,6 +1404,7 @@ + 1 0 1 @@ -1301,6 +1421,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1342,6 +1466,7 @@ + 1 1 @@ -1355,6 +1480,10 @@ + + wxFILTER_NONE + wxDefaultValidator + wxSUNKEN_BORDER|wxTAB_TRAVERSAL @@ -1402,6 +1531,7 @@ + 1 1 @@ -1417,6 +1547,10 @@ An alias is a component that uses the body of its root component. It has its own documentation and keywords. A fast way to extend a library with similar components + + wxFILTER_NONE + wxDefaultValidator + @@ -1454,6 +1588,7 @@ + 1 1 @@ -1468,6 +1603,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1516,6 +1655,7 @@ + 1 0 1 @@ -1532,6 +1672,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1568,6 +1712,7 @@ + 1 0 1 @@ -1584,6 +1729,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1620,6 +1769,7 @@ + 1 0 1 @@ -1636,6 +1786,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1677,6 +1831,7 @@ + 1 1 @@ -1690,6 +1845,10 @@ + + wxFILTER_NONE + wxDefaultValidator + wxSUNKEN_BORDER|wxTAB_TRAVERSAL @@ -1737,6 +1896,7 @@ + 1 1 @@ -1752,6 +1912,10 @@ A list of footprints names that can be used for this component. Footprints names can used jockers. (like sm* to allow all footprints names starting by sm). + + wxFILTER_NONE + wxDefaultValidator + @@ -1789,6 +1953,7 @@ + 1 1 @@ -1803,6 +1968,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1851,6 +2020,7 @@ + 1 0 1 @@ -1867,6 +2037,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1903,6 +2077,7 @@ + 1 0 1 @@ -1919,6 +2094,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1955,6 +2134,7 @@ + 1 0 1 @@ -1971,6 +2151,10 @@ + + wxFILTER_NONE + wxDefaultValidator + diff --git a/eeschema/dialog_edit_component_in_lib_base.h b/eeschema/dialog_edit_component_in_lib_base.h index 9759f364c8..1fff34a480 100644 --- a/eeschema/dialog_edit_component_in_lib_base.h +++ b/eeschema/dialog_edit_component_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -91,19 +91,20 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog wxButton* m_sdbSizer2Cancel; // Virtual event handlers, overide them in your derived class - virtual void CopyDocToAlias( wxCommandEvent& event ){ event.Skip(); } - virtual void BrowseAndSelectDocFile( wxCommandEvent& event ){ event.Skip(); } - virtual void AddAliasOfPart( wxCommandEvent& event ){ event.Skip(); } - virtual void DeleteAliasOfPart( wxCommandEvent& event ){ event.Skip(); } - virtual void DeleteAllAliasOfPart( wxCommandEvent& event ){ event.Skip(); } - virtual void AddFootprintFilter( wxCommandEvent& event ){ event.Skip(); } - virtual void DeleteOneFootprintFilter( wxCommandEvent& event ){ event.Skip(); } - virtual void DeleteAllFootprintFilter( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } + virtual void CopyDocToAlias( wxCommandEvent& event ) { event.Skip(); } + virtual void BrowseAndSelectDocFile( wxCommandEvent& event ) { event.Skip(); } + virtual void AddAliasOfPart( wxCommandEvent& event ) { event.Skip(); } + virtual void DeleteAliasOfPart( wxCommandEvent& event ) { event.Skip(); } + virtual void DeleteAllAliasOfPart( wxCommandEvent& event ) { event.Skip(); } + virtual void AddFootprintFilter( wxCommandEvent& event ) { event.Skip(); } + virtual void DeleteOneFootprintFilter( wxCommandEvent& event ) { event.Skip(); } + virtual void DeleteAllFootprintFilter( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: + DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Lib Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 546,384 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(); diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index 75870ea57e..3c0f9c367a 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -80,7 +80,7 @@ void WinEDA_SchematicFrame::LoadLibraries( void ) { wxString prompt; - prompt.Printf( _( "Component library <%s> failed to load.\n\nError: %s" ), + prompt.Printf( _( "Component library <%s> failed to load.\nError: %s" ), GetChars( fn.GetFullPath() ), GetChars( errMsg ) ); DisplayError( this, prompt ); @@ -104,8 +104,8 @@ void WinEDA_SchematicFrame::LoadLibraries( void ) CMP_LIBRARY::SetSortOrder( sortOrder ); CMP_LIBRARY::GetLibraryList().sort(); -#ifdef __WXDEBUG__ - wxLogDebug( wxT( "LoadLibraries () requested component library sort order:" ) ); +#if 0 // #ifdef __WXDEBUG__ + wxLogDebug( wxT( "LoadLibraries() requested component library sort order:" ) ); for( size_t i = 0; i < sortOrder.GetCount(); i++ ) wxLogDebug( wxT( " " ) + sortOrder[i] ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 3c81dce24c..e24eb74843 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -613,7 +613,7 @@ void WinEDA_SchematicFrame::LoadSettings() { m_TemplateFieldNames.Parse( &lexer ); } - catch( IOError e ) + catch( IO_ERROR e ) { // @todo show error msg D(printf("templatefieldnames parsing error: '%s'\n", diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 47a862f799..ae5fed0842 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -269,7 +269,7 @@ bool WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsN { wxString prompt; - prompt.Printf( _( "Component library <%s> failed to load.\n\n Error: %s" ), + prompt.Printf( _( "Component library <%s> failed to load.\nError: %s" ), GetChars( fn.GetFullPath() ), GetChars( errMsg ) ); DisplayError( this, prompt ); diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 316a5e1e24..b557a5202b 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -32,7 +32,7 @@ * s_LibEdit_Hotkey_List list or s_Common_Hotkey_List if the same command is * added both in eeschema and libedit) * Add the new code in the switch in OnHotKey() function. - * when the variable ItemInEdit is true, an item is currently edited. + * when the variable itemInEdit is true, an item is currently edited. * This can be useful if the new function cannot be executed while an item is * currently being edited * ( For example, one cannot start a new wire when a component is moving.) @@ -100,6 +100,7 @@ static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_SHIFT + GR_KB_CTRL + // Schematic editor static Ki_HotkeyInfo HkAddLabel( wxT( "add Label" ), HK_ADD_LABEL, 'L' ); +static Ki_HotkeyInfo HkAddJunction( wxT( "add Junction" ), HK_ADD_JUNCTION, 'J' ); static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' ); static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' ); @@ -180,6 +181,7 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = &HkEditComponentFootprint, &HkBeginWire, &HkAddLabel, + &HkAddJunction, &HkAddNoConn, NULL }; @@ -244,9 +246,13 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, cmd.SetEventObject( this ); - bool ItemInEdit = GetScreen()->GetCurItem()&& GetScreen()->GetCurItem()->m_Flags; - bool RefreshToolBar = FALSE; SCH_SCREEN* screen = GetScreen(); + // itemInEdit == false means no item currently edited. We can ask for editing a new item + bool itemInEdit = screen->GetCurItem() && screen->GetCurItem()->m_Flags; + // notBusy == true means no item currently edited and no other command in progress + // We can change active tool and ask for editing a new item + bool notBusy = (!itemInEdit) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK); + bool RefreshToolBar = FALSE; if( hotkey == 0 ) return; @@ -306,7 +312,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_UNDO: case HK_REDO: - if( !ItemInEdit ) + if( notBusy ) { wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent ); wxPostEvent( this, event ); @@ -318,7 +324,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_DELETE: - if( !ItemInEdit && screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) + if( notBusy) { RefreshToolBar = LocateAndDeleteItem( this, DC ); OnModify(); @@ -328,12 +334,12 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_REPEAT_LAST: - if( !ItemInEdit && g_ItemToRepeat && ( g_ItemToRepeat->m_Flags == 0 ) ) + if( notBusy && g_ItemToRepeat && ( g_ItemToRepeat->m_Flags == 0 ) ) RepeatDrawItem( DC ); break; case HK_FIND_ITEM: - if( !ItemInEdit ) + if( notBusy ) { wxCommandEvent evt; evt.SetId( ID_FIND_ITEMS ); @@ -342,7 +348,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_FIND_NEXT_ITEM: - if( !ItemInEdit ) + if( notBusy ) { wxFindDialogEvent event( wxEVT_COMMAND_FIND, GetId() ); event.SetEventObject( this ); @@ -353,7 +359,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_FIND_NEXT_DRC_MARKER: - if( !ItemInEdit ) + if( notBusy ) { wxFindDialogEvent event( EVT_COMMAND_FIND_DRC_MARKER, GetId() ); event.SetEventObject( this ); @@ -364,7 +370,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_ADD_NEW_COMPONENT: // Add component - if( !ItemInEdit ) + if( !itemInEdit ) { // switch to m_ID_current_state = ID_COMPONENT_BUTT; if( m_ID_current_state != ID_COMPONENT_BUTT ) @@ -374,7 +380,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_ADD_LABEL: - if( !ItemInEdit ) + if( notBusy ) { // switch to m_ID_current_state = ID_LABEL_BUTT; if( m_ID_current_state != ID_LABEL_BUTT ) @@ -383,11 +389,19 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, } break; - case HK_BEGIN_WIRE: + case HK_ADD_JUNCTION: + if( notBusy ) + { + // switch to m_ID_current_state = ID_JUNCTION_BUTT; + if( m_ID_current_state != ID_JUNCTION_BUTT ) + SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add Junction" ) ); + OnLeftClick( DC, MousePos ); + } + break; - /* An item is selected. If edited and not a wire, a new command is not - * possible */ - if( !ItemInEdit && screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) + case HK_BEGIN_WIRE: + // An item is selected. If not a wire, a new command is not possible + if( notBusy ) { if( DrawStruct && DrawStruct->m_Flags ) { @@ -409,7 +423,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_ADD_NOCONN_FLAG: // Add a no connected flag - if( !ItemInEdit ) + if( notBusy ) { if( m_ID_current_state != ID_NOCONN_BUTT ) SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add \"NoNonnect\" Flags" ) ); @@ -532,7 +546,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_DRAG: // Start drag case HK_MOVE_COMPONENT_OR_ITEM: // Start move component or other schematic item case HK_COPY_COMPONENT_OR_LABEL: // Duplicate component or text/label - if( ItemInEdit ) + if( itemInEdit ) break; if( DrawStruct == NULL ) @@ -627,7 +641,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_EDIT: - if( ItemInEdit ) + if( itemInEdit ) break; if( DrawStruct == NULL ) { @@ -671,7 +685,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_EDIT_COMPONENT_VALUE: - if( ItemInEdit ) + if( itemInEdit ) break; if( DrawStruct == NULL ) DrawStruct = LocateSmallestComponent( GetScreen() ); @@ -682,7 +696,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_EDIT_COMPONENT_FOOTPRINT: - if( ItemInEdit ) + if( itemInEdit ) break; if( DrawStruct == NULL ) DrawStruct = LocateSmallestComponent( GetScreen() ); @@ -711,7 +725,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt cmd.SetEventObject( this ); wxPoint MousePos = GetScreen()->m_MousePosition; - bool ItemInEdit = GetScreen()->GetCurItem()&& GetScreen()->GetCurItem()->m_Flags; + bool itemInEdit = GetScreen()->GetCurItem()&& GetScreen()->GetCurItem()->m_Flags; if( hotkey == 0 ) return; @@ -767,7 +781,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt break; case HK_UNDO: - if( !ItemInEdit ) + if( !itemInEdit ) { toolCmd.SetId( wxID_UNDO ); GetEventHandler()->ProcessEvent( toolCmd ); @@ -775,7 +789,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt break; case HK_REDO: - if( !ItemInEdit ) + if( !itemInEdit ) { toolCmd.SetId( wxID_REDO ); GetEventHandler()->ProcessEvent( toolCmd ); diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h index f8cb96c476..acd59b48c8 100644 --- a/eeschema/hotkeys.h +++ b/eeschema/hotkeys.h @@ -32,6 +32,7 @@ enum hotkey_id_commnand { HK_ADD_NEW_COMPONENT, HK_BEGIN_WIRE, HK_ADD_LABEL, + HK_ADD_JUNCTION, HK_ADD_NOCONN_FLAG }; diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 1785c2f4ff..1eec680fb7 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -16,11 +16,11 @@ /* in read_from_file_schematic_items_description.cpp */ SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicFileVersion ); -int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); +int ReadSheetDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); -bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); +bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); -int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); +int ReadPartDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); static void LoadLayers( LINE_READER* aLine ); @@ -29,8 +29,7 @@ static void LoadLayers( LINE_READER* aLine ); * Routine to load an EESchema file. * Returns true if file has been loaded (at least partially.) */ -bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, - const wxString& FullFileName ) +bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName ) { char Name1[256], Name2[256]; @@ -122,13 +121,13 @@ again." ); { case '$': // identification block if( line[1] == 'C' ) - Failed = ReadPartDescr( this, &reader, MsgDiag, screen ); + Failed = ReadPartDescr( &reader, MsgDiag, screen ); else if( line[1] == 'S' ) - Failed = ReadSheetDescr( this, &reader, MsgDiag, screen ); + Failed = ReadSheetDescr( &reader, MsgDiag, screen ); else if( line[1] == 'D' ) - Failed = ReadSchemaDescr( this, &reader, MsgDiag, screen ); + Failed = ReadSchemaDescr( &reader, MsgDiag, screen ); else if( line[1] == 'T' ) // text part { @@ -148,7 +147,7 @@ again." ); break; case 'L': // Its a library item. - Failed = ReadPartDescr( this, &reader, MsgDiag, screen ); + Failed = ReadPartDescr( &reader, MsgDiag, screen ); break; case 'W': // Its a Segment (WIRE or BUS) item. diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index ed7ec136be..a499cb7156 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -305,13 +305,14 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* Global label */ item = new wxMenuItem( placeMenu, ID_GLABEL_BUTT, _( "Global label" ), - _( "Place a global label. Warning: all global labels with the same name are connected in whole hierarchy" ), - wxITEM_NORMAL ); + HELP_PLACE_GLOBALLABEL, wxITEM_NORMAL ); item->SetBitmap( add_glabel_xpm ); placeMenu->Append( item ); /* Junction */ - item = new wxMenuItem( placeMenu, ID_JUNCTION_BUTT, _( "Junction" ), + text = AddHotkeyName( _( "Junction" ), s_Schematic_Hokeys_Descr, + HK_ADD_JUNCTION, false ); // add comment, not a shortcut + item = new wxMenuItem( placeMenu, ID_JUNCTION_BUTT, text, HELP_PLACE_JUNCTION, wxITEM_NORMAL ); item->SetBitmap( add_junction_xpm ); placeMenu->Append( item ); diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 7a86bf48a7..7547a56aff 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -1055,7 +1055,7 @@ bool EXPORT_HELP::WriteGENERICNetList( WinEDA_SchematicFrame* frame, const wxStr STREAM_OUTPUTFORMATTER outputFormatter( os ); xroot->Format( &outputFormatter, 0 ); } - catch( IOError ioe ) + catch( IO_ERROR ioe ) { delete xroot; goto L_error; diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index a5bc380a6c..8bd6e4c824 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -369,14 +369,19 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) if( aLabelItemBuffer.size() == 0 ) return NULL; - int priority_order[4] = - { NET_LABEL, NET_HIERLABEL, NET_PINLABEL, NET_GLOBLABEL }; + // Define a priority (from low to high) to sort labels: + // NET_PINLABEL and NET_GLOBLABEL are global labels + // and priority >= PRIO_MAX-1 is for global connections + // ( i.e. for labels that are not prefixed by a sheetpath) + #define PRIO_MAX 4 + int priority_order[PRIO_MAX+1] = + { NET_ITEM_UNSPECIFIED, NET_LABEL, NET_HIERLABEL, NET_PINLABEL, NET_GLOBLABEL }; NETLIST_OBJECT*item = aLabelItemBuffer[0]; - // Calculate item priority + // Calculate item priority (initial priority) int item_priority = 0; - for( unsigned ii = 0; ii < 4; ii++ ) + for( unsigned ii = 0; ii <= PRIO_MAX; ii++ ) { if ( item->m_Type == priority_order[ii] ) { @@ -388,14 +393,9 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ ) { NETLIST_OBJECT* candidate = aLabelItemBuffer[ii]; - if( candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() ) - { - item = candidate; - continue; - } // Calculate candidate priority int candidate_priority = 0; - for( unsigned ii = 0; ii < 4; ii++ ) + for( unsigned ii = 0; ii <= PRIO_MAX; ii++ ) { if ( candidate->m_Type == priority_order[ii] ) { @@ -404,13 +404,43 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) } } if( candidate_priority > item_priority ) + { item = candidate; + item_priority = candidate_priority; + } else if( candidate_priority == item_priority ) { - if( candidate->m_Label.Cmp( item->m_Label ) < 0 ) - item = candidate; + // for global labels, we select the best candidate by alphabetic order + // because they have no sheetpath as prefix name + // for other labels, we select them before by sheet deep order + // because the actual name is /sheetpath/label + // and for a given path length, by alphabetic order + + if( item_priority >= PRIO_MAX-1 ) // global label or pin label + { // selection by alphabetic order: + if( candidate->m_Label.Cmp( item->m_Label ) < 0 ) + item = candidate; + } + else // not global: names are prefixed by their sheetpath + { + // use name defined in highter hierarchical sheet + // (i.e. shorter path because paths are ///... + // and timestamp = 8 letters. + if( candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() ) + { + item = candidate; + } + else if( candidate->m_SheetList.Path().Length() == item->m_SheetList.Path().Length() ) + { + // For labels on sheets having an equivalent deep in hierarchy, use + // alphabetic label name order: + if( candidate->m_Label.Cmp( item->m_Label ) < 0 ) + item = candidate; + } + } } } + return item; } @@ -994,25 +1024,24 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, int IsBus, int start ) /* - * Search if a junction is connected to segments and include the Netcode - * objects connect to the junction. + * Search if a junction is connected to segments and propagate the junction Netcode + * to objects connected by the junction. * The junction must have a valid Netcode - * The list of objects is SUPPOSED class by NumSheet ??? Croissants, - * And research is done from the start element, 1st element - * Leaf schema - * (There can be no physical connection between elements of different sheets) + * 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* Jonction, - int IsBus, int start ) +static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, + int aIsBus, int aIdxStart ) { - for( unsigned i = start; i < g_NetObjectslist.size(); i++ ) + for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ ) { NETLIST_OBJECT* Segment = g_NetObjectslist[i]; - if( Segment->m_SheetList != Jonction->m_SheetList ) + // if different sheets, no physical connection between elements is possible. + if( Segment->m_SheetList != aJonction->m_SheetList ) continue; - if( IsBus == 0 ) + if( aIsBus == 0 ) { if( Segment->m_Type != NET_SEGMENT ) continue; @@ -1023,24 +1052,24 @@ static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, continue; } - if( SegmentIntersect( Segment->m_Start, Segment->m_End, Jonction->m_Start ) ) + if( SegmentIntersect( Segment->m_Start, Segment->m_End, aJonction->m_Start ) ) { /* Propagation Netcode has all the objects of the same Netcode. */ - if( IsBus == 0 ) + if( aIsBus == 0 ) { if( Segment->GetNet() ) PropageNetCode( Segment->GetNet(), - Jonction->GetNet(), IsBus ); + aJonction->GetNet(), aIsBus ); else - Segment->SetNet( Jonction->GetNet() ); + Segment->SetNet( aJonction->GetNet() ); } else { if( Segment->m_BusNetCode ) PropageNetCode( Segment->m_BusNetCode, - Jonction->m_BusNetCode, IsBus ); + aJonction->m_BusNetCode, aIsBus ); else - Segment->m_BusNetCode = Jonction->m_BusNetCode; + Segment->m_BusNetCode = aJonction->m_BusNetCode; } } } @@ -1072,10 +1101,11 @@ void LabelConnect( NETLIST_OBJECT* LabelRef ) continue; } - //regular labels are sheet-local; - //NET_HIERLABEL are used to connect sheets. - //NET_LABEL is sheet-local (***) - //NET_GLOBLABEL is global. + // regular labels are sheet-local; + // NET_HIERLABEL are used to connect sheets. + // NET_LABEL is sheet-local (***) + // 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 diff --git a/eeschema/read_from_file_schematic_items_descriptions.cpp b/eeschema/read_from_file_schematic_items_descriptions.cpp index 2e1be73c87..121c658616 100644 --- a/eeschema/read_from_file_schematic_items_descriptions.cpp +++ b/eeschema/read_from_file_schematic_items_descriptions.cpp @@ -175,7 +175,7 @@ SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicF /* Function used by LoadEEFile(). * Get the lines for a description of a piece of hierarchy. */ -int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) +int ReadSheetDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) { int ii, fieldNdx, size; char Name1[256], Char1[256], Char2[256]; @@ -286,7 +286,6 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS aLine->LineNumber() ); aMsgDiag << CONV_FROM_UTF8( line ); - DisplayError( frame, aMsgDiag ); } if( size == 0 ) size = DEFAULT_SIZE_TEXT; @@ -316,7 +315,6 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS aMsgDiag.Printf( wxT( "EESchema file sheet label error at line %d, ignoring.\n" ), aLine->LineNumber() ); aMsgDiag << CONV_FROM_UTF8( line ); - DisplayError( frame, aMsgDiag ); continue; } @@ -391,7 +389,7 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS /* Read the schematic header. */ -bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) +bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) { char Text[256], buf[1024]; int ii; @@ -427,7 +425,6 @@ bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, B line %d, \aAbort reading file.\n" ), aLine->LineNumber() ); aMsgDiag << CONV_FROM_UTF8( line ); - DisplayError( frame, aMsgDiag ); } Window->m_CurrentSheetDesc = wsheet; @@ -509,7 +506,7 @@ line %d, \aAbort reading file.\n" ), * Get the lines for a description of a schematic component. */ -int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) +int ReadPartDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) { int ii; char Name1[256], Name2[256], @@ -754,7 +751,6 @@ int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE aMsgDiag.Printf( wxT( "Component Field error line %d, aborted" ), aLine->LineNumber() ); - DisplayError( frame, aMsgDiag ); continue; } diff --git a/eeschema/template_fieldnames.cpp b/eeschema/template_fieldnames.cpp index 674ba94013..51f00740c0 100644 --- a/eeschema/template_fieldnames.cpp +++ b/eeschema/template_fieldnames.cpp @@ -31,7 +31,7 @@ wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx ) } } -void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOError ) +void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ) { // user may want spaces in his field name, ug, so quote them for the parser. out->Print( nestLevel, "(field (name \"%s\")", CONV_TO_UTF8(m_Name) ); @@ -46,7 +46,7 @@ void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const thr } -void TEMPLATE_FIELDNAME::Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IOError ) +void TEMPLATE_FIELDNAME::Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IO_ERROR ) { TFIELD_T tok; @@ -87,7 +87,7 @@ void TEMPLATE_FIELDNAME::Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IOError ) } -void TEMPLATES::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOError ) +void TEMPLATES::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ) { // We'll keep this general, and include the \n, even though the only known // use at this time will not want the newlines or the indentation. @@ -97,7 +97,7 @@ void TEMPLATES::Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOErr out->Print( 0, ")\n" ); } -void TEMPLATES::Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IOError ) +void TEMPLATES::Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IO_ERROR ) { TFIELD_T tok; diff --git a/eeschema/template_fieldnames.h b/eeschema/template_fieldnames.h index ff3b3af3b8..5d12f489ea 100644 --- a/eeschema/template_fieldnames.h +++ b/eeschema/template_fieldnames.h @@ -66,7 +66,7 @@ struct TEMPLATE_FIELDNAME * Function Format * serializes this object out as text into the given OUTPUTFORMATTER. */ - void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOError ); + void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ); /** * Function Parse @@ -81,7 +81,7 @@ struct TEMPLATE_FIELDNAME * * @param aSpec is the input token stream of keywords and symbols. */ - void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec ) throw( IOError ); + void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec ) throw( IO_ERROR ); /** * Function GetDefaultFieldName @@ -106,13 +106,13 @@ public: * Function Format * serializes this object out as text into the given OUTPUTFORMATTER. */ - void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOError ); + void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ); /** * Function Parse * fills this object from information in the input stream handled by TEMPLATE_FIELDNAMES_LEXER */ - void Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IOError ); + void Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IO_ERROR ); /** diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 18c95dffde..1d056d1273 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -113,11 +113,11 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, wxBitmap( new_component_xpm ), - _( "New component" ) ); + _( "Create a new component" ) ); m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString, - wxBitmap( add_component_xpm ), - _( "Select component to edit" ) ); + wxBitmap( import_cmp_from_lib_xpm ), + _( "Load component to edit from the current lib" ) ); m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString, wxBitmap( save_part_in_mem_xpm ), diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index 919e67f0dc..99b4625838 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -110,6 +110,5 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) wxSafeYield(); } - SetToolbars(); UpdateStatusBar(); } diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index 09c6f288dd..d70ee5bb77 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -217,6 +217,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ReFillLayerWidget(); // this is near end because contents establish size + SetToolbars(); m_auimgr.Update(); } @@ -239,6 +240,10 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) int WinEDA_GerberFrame::BestZoom() { + // gives a minimal value to zoom, if no item in list + if( GetBoard()->m_Drawings == NULL ) + return(16 * GetScreen()->m_ZoomScalar) ; + double x, y; EDA_Rect bbox; @@ -248,13 +253,14 @@ int WinEDA_GerberFrame::BestZoom() GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; bbox.Merge( gerb_item->GetBoundingBox() ); } - + bbox.Inflate( GetScreen()->GetGridSize().x * 2, GetScreen()->GetGridSize().y * 2); wxSize size = DrawPanel->GetClientSize(); - x = ( bbox.GetWidth() + GetScreen()->GetGridSize().x ) / (double) size.x; - y = ( bbox.GetHeight() + GetScreen()->GetGridSize().y ) / (double) size.y; + x = bbox.GetWidth() / (double) size.x; + y = bbox.GetHeight() / (double) size.y; GetScreen()->m_Curseur = bbox.Centre(); - return wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ); + int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ) ; + return best_zoom; } /**************************************/ @@ -508,7 +514,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo() gerber->DisplayImageInfo( ); // Display Image Name and Layer Name (from the current gerber data): - text.Printf( _("Image name: \"%s\" Layer name \"%s\""), + text.Printf( _("Image name: \"%s\" Layer name: \"%s\""), GetChars(gerber->m_ImageName), GetChars(gerber->GetLayerParams( ).m_LayerName) ); SetStatusText( text, 0 ); diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index e0f2b807d8..9c33fd60d7 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -47,6 +47,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) SetBaseScreen( ActiveScreen = ScreenPcb ); GetScreen()->Init(); setActiveLayer(LAYER_N_BACK); + syncLayerBox(); return TRUE; } @@ -56,7 +57,7 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) int layer = getActiveLayer(); wxString msg; - msg.Printf( _( "Delete layer %d?" ), layer + 1 ); + msg.Printf( _( "Clear layer %d?" ), layer + 1 ); if( query && !IsOK( this, msg ) ) return; @@ -81,4 +82,5 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) ScreenPcb->SetModify(); ScreenPcb->SetRefreshReq(); + syncLayerBox(); } diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index dcb5718cdf..77653519c2 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -97,8 +97,8 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) tools_xpm ); miscellaneous_menu->AppendSeparator(); ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_GLOBAL_DELETE, - _( "&Delete Layer" ), - _( "Delete current layer" ), general_deletions_xpm ); + _( "&Clear Layer" ), + _( "Clear current layer" ), general_deletions_xpm ); // Menu Help: wxMenu* helpMenu = new wxMenu; diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index ff9de75fe8..526cb99f66 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -17,9 +17,8 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, const wxString& D_Code_FullFileName ) { - int G_commande = 0, - D_commande = 0; /* command number for G or D commands - * (like G04 or D02) */ + int G_commande = 0; // command number for G commands like G04 + int D_commande = 0; // command number for D commands like D02 char line[GERBER_BUFZ]; @@ -57,7 +56,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, SetLocaleTo_C_standard(); - while( TRUE ) + while( true ) { if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL ) { @@ -94,7 +93,6 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, gerber->m_CommandState = CMD_IDLE; while( *text ) text++; - break; case 'G': /* Line type Gxx : command */ diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index cd42fe8a4d..6c442daeb8 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -455,7 +455,9 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_commande ) break; case GC_COMMENT: - text = NULL; + // Skip comment + while ( *text && (*text != '*') ) + text++; break; case GC_LINEAR_INTERPOL_10X: diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 78a13de1c8..0369948cbd 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -13,7 +13,7 @@ #include "gerbview_id.h" #include "hotkeys.h" #include "class_GERBER.h" - +#include "class_layerchoicebox.h" void WinEDA_GerberFrame::ReCreateHToolbar( void ) { @@ -89,7 +89,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) choices.Add( msg ); } - m_SelLayerBox = new WinEDAChoiceBox( m_HToolBar, + m_SelLayerBox = new WinEDALayerChoiceBox( m_HToolBar, ID_TOOLBARH_GERBVIEW_SELECT_LAYER, wxDefaultPosition, wxSize( 150, -1 ), choices ); @@ -224,17 +224,6 @@ void WinEDA_GerberFrame::SetToolbars() if( m_HToolBar == NULL ) return; - if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) - { - m_HToolBar->EnableTool( wxID_CUT, true ); - m_HToolBar->EnableTool( wxID_COPY, true ); - } - else - { - m_HToolBar->EnableTool( wxID_CUT, false ); - m_HToolBar->EnableTool( wxID_COPY, false ); - } - if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != screen->m_Active_Layer) ) { m_SelLayerBox->SetSelection( screen->m_Active_Layer ); diff --git a/gerbview/wxGerberFrame.h b/gerbview/wxGerberFrame.h index 9ce3f136cc..d51f149d51 100644 --- a/gerbview/wxGerberFrame.h +++ b/gerbview/wxGerberFrame.h @@ -8,7 +8,7 @@ #include "id.h" #include "class_gerbview_layer_widget.h" - +#include "class_layerchoicebox.h" /** * Command IDs for the gerber file viewer. @@ -44,7 +44,7 @@ protected: GERBER_LAYER_WIDGET* m_LayersManager; public: - WinEDAChoiceBox* m_SelLayerBox; + WinEDALayerChoiceBox* m_SelLayerBox; WinEDAChoiceBox* m_SelLayerTool; wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about // gerber data (format..) diff --git a/include/base_struct.h b/include/base_struct.h index a0febffc53..94b79b2952 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -348,6 +348,7 @@ public: inline bool IsModified() const { return m_Flags & IS_CHANGED; } inline bool IsMoving() const { return m_Flags & IS_MOVED; } inline bool IsDragging() const { return m_Flags & IS_DRAGGED; } + inline bool IsSelected() const { return m_Flags & SELECTED; } int GetState( int type ) const { diff --git a/include/bitmaps.h b/include/bitmaps.h index b233488391..2e51d5c12c 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -152,6 +152,7 @@ extern const char* icon_gerbview_xpm[]; extern const char* icon_modedit_xpm[]; extern const char* icon_txt_xpm[]; extern const char* icon_w3d_xpm[]; +extern const char* import_cmp_from_lib_xpm[]; extern const char* import_hierarchical_label_xpm[]; extern const char* import_module_xpm[]; extern const char* import_xpm[]; diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 7d322af960..654c13b7da 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -14,12 +14,23 @@ #include "block_commande.h" #include "common.h" +#include + // Forward declarations: class SCH_ITEM; class Ki_PageDescr; +/** + * Define list of drawing items for screens. + * + * The Boost containter was choosen over the statand C++ contain because you can detach + * the pointer from a list with the release method. + */ +typedef boost::ptr_vector< EDA_BaseStruct > EDA_ITEMS; + + /* Simple class for handling grid arrays. */ class GRID_TYPE { @@ -56,17 +67,16 @@ WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray ); /*******************************************************************/ class BASE_SCREEN : public EDA_BaseStruct { + EDA_ITEMS m_items; ///< The drawing items associated with this screen. + public: - wxPoint m_DrawOrg; /* offsets for drawing the circuit on the - * screen */ - wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user - * units. */ - wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user - * units. */ + wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */ + wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ + wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ wxPoint m_MousePositionInPixels; - wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) - * in user units. - * (coordinates from last reset position)*/ + wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) + * in user units. + * (coordinates from last reset position)*/ // Scrollbars management: int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */ int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */ @@ -280,8 +290,7 @@ public: /** * Function SetZoomList * sets the list of zoom factors. - * @param aZoomList An array of zoom factors in ascending order, zero - * terminated + * @param aZoomList An array of zoom factors in ascending order, zero terminated */ void SetZoomList( const wxArrayInt& zoomlist ); @@ -300,8 +309,7 @@ public: bool SetFirstZoom(); bool SetLastZoom(); - //-------------------------------------------------------------- + //-------------------------------------------------------------- /** * Return the command ID of the currently selected grid. @@ -359,6 +367,13 @@ public: return wxT( "BASE_SCREEN" ); } + /** + * Helpers for accessing the draw item list. + */ + EDA_ITEMS::iterator Begin() { return m_items.begin(); } + EDA_ITEMS::iterator End() { return m_items.end(); } + virtual void AddItem( EDA_BaseStruct* aItem ); + virtual void InsertItem( EDA_ITEMS::iterator aIter, EDA_BaseStruct* aItem ); #if defined(DEBUG) diff --git a/include/class_layerchoicebox.h b/include/class_layerchoicebox.h new file mode 100644 index 0000000000..535cfe5ee4 --- /dev/null +++ b/include/class_layerchoicebox.h @@ -0,0 +1,65 @@ +#ifndef CLASS_LAYERCHOICEBOX_H +#define CLASS_LAYERCHOICEBOX_H 1 + +#include "hotkeys_basic.h" +#include + +/* class to display a layer list. + * + */ + +class WinEDALayerChoiceBox : public wxBitmapComboBox +{ +private: + bool m_layerhotkeys; + bool m_layerorder; +public: + WinEDALayerChoiceBox( WinEDA_Toolbar* parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL ); + + WinEDALayerChoiceBox( WinEDA_Toolbar* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices ); + + // Get Current Item # + int GetChoice(); + + // Get Current Layer + int GetLayerSelection(); + + // Set Layer # + int SetLayerSelection(int layer); + + // Reload the Layers + void Resync(); + void ResyncBitmapOnly(); + + bool SetLayersOrdered(bool value); + bool SetLayersHotkeys(bool value); + // Hotkey Info + struct Ki_HotkeyInfoSectionDescriptor* m_hotkeys; +}; + +#define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \ + { \ + HK_SWITCH_LAYER_TO_COPPER, \ + HK_SWITCH_LAYER_TO_INNER1, \ + HK_SWITCH_LAYER_TO_INNER2, \ + HK_SWITCH_LAYER_TO_INNER3, \ + HK_SWITCH_LAYER_TO_INNER4, \ + HK_SWITCH_LAYER_TO_INNER5, \ + HK_SWITCH_LAYER_TO_INNER6, \ + HK_SWITCH_LAYER_TO_INNER7, \ + HK_SWITCH_LAYER_TO_INNER8, \ + HK_SWITCH_LAYER_TO_INNER9, \ + HK_SWITCH_LAYER_TO_INNER10, \ + HK_SWITCH_LAYER_TO_INNER11, \ + HK_SWITCH_LAYER_TO_INNER12, \ + HK_SWITCH_LAYER_TO_INNER13, \ + HK_SWITCH_LAYER_TO_INNER14, \ + HK_SWITCH_LAYER_TO_COMPONENT \ + }; + +#endif //CLASS_LAYERCHOICEBOX_H diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index a4a7e900e3..24e45d1b68 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -6,7 +6,7 @@ #define CLASS_SCREEN_H #include "macros.h" -#include "base_struct.h" +#include "sch_item_struct.h" #include "class_base_screen.h" @@ -17,8 +17,9 @@ class SCH_SCREEN : public BASE_SCREEN { public: - int m_RefCount; /*how many sheets reference this screen? - * delete when it goes to zero. */ + int m_RefCount; ///< Number of sheets referencing this screen. + ///< Delete when it goes to zero. + SCH_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE ); ~SCH_SCREEN(); @@ -80,7 +81,7 @@ public: * items are removed from the beginning of the list. * So this function can be called to remove old commands */ - virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ); + virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ); /** * Function Save @@ -90,6 +91,17 @@ public: * @return bool - true if success writing else false. */ bool Save( FILE* aFile ) const; + + /** + * Clear the state flags of all the items in the screen. + */ + void ClearDrawingState(); + + virtual void AddItem( SCH_ITEM* aItem ) { BASE_SCREEN::AddItem( (EDA_BaseStruct*) aItem ); } + virtual void InsertItem( EDA_ITEMS::iterator aIter, SCH_ITEM* aItem ) + { + BASE_SCREEN::InsertItem( aIter, (EDA_BaseStruct*) aItem ); + } }; diff --git a/include/dsnlexer.h b/include/dsnlexer.h index 6b41b42cdc..3a39d20113 100644 --- a/include/dsnlexer.h +++ b/include/dsnlexer.h @@ -102,7 +102,7 @@ class DSNLEXER void init(); - int readLine() throw (IOError) + int readLine() throw( IO_ERROR ) { unsigned len = reader->ReadLine(); @@ -213,29 +213,29 @@ public: * this lower level function returning an int (so the enum does not collide * with another usage). * @return int - the type of token found next. - * @throw IOError - only if the LINE_READER throws it. + * @throw IO_ERROR - only if the LINE_READER throws it. */ - int NextTok() throw (IOError); + int NextTok() throw( IO_ERROR ); /** * Function NeedSYMBOL * calls NextTok() and then verifies that the token read in * satisfies bool IsSymbol(). - * If not, an IOError is thrown. + * If not, an IO_ERROR is thrown. * @return int - the actual token read in. - * @throw IOError, if the next token does not satisfy IsSymbol() + * @throw IO_ERROR, if the next token does not satisfy IsSymbol() */ - int NeedSYMBOL() throw( IOError ); + int NeedSYMBOL() throw( IO_ERROR ); /** * Function NeedSYMBOLorNUMBER * calls NextTok() and then verifies that the token read in * satisfies bool IsSymbol() or tok==DSN_NUMBER. - * If not, an IOError is thrown. + * If not, an IO_ERROR is thrown. * @return int - the actual token read in. - * @throw IOError, if the next token does not satisfy the above test + * @throw IO_ERROR, if the next token does not satisfy the above test */ - int NeedSYMBOLorNUMBER() throw( IOError ); + int NeedSYMBOLorNUMBER() throw( IO_ERROR ); /** * Function CurTok @@ -311,58 +311,58 @@ public: * encapsulates the formatting of an error message which contains the exact * location within the input file of something the caller is rejecting. */ - void ThrowIOError( wxString aText, int charOffset ) throw (IOError); + void ThrowIOError( wxString aText, int charOffset ) throw( IO_ERROR ); /** * Function Expecting - * throws an IOError exception with an input file specific error message. + * throws an IO_ERROR exception with an input file specific error message. * @param aTok is the token/keyword type which was expected at the current input location. - * @throw IOError with the location within the input file of the problem. + * @throw IO_ERROR with the location within the input file of the problem. */ - void Expecting( int aTok ) throw( IOError ); + void Expecting( int aTok ) throw( IO_ERROR ); /** * Function Expecting - * throws an IOError exception with an input file specific error message. + * throws an IO_ERROR exception with an input file specific error message. * @param aErrorMsg is the token/keyword type which was expected at the * current input location. - * @throw IOError with the location within the input file of the problem. + * @throw IO_ERROR with the location within the input file of the problem. */ - void Expecting( const wxString& aErrorMsg ) throw( IOError ); + void Expecting( const wxString& aErrorMsg ) throw( IO_ERROR ); /** * Function Unexpected - * throws an IOError exception with an input file specific error message. + * throws an IO_ERROR exception with an input file specific error message. * @param aTok is the token/keyword type which was not expected at the * current input location. - * @throw IOError with the location within the input file of the problem. + * @throw IO_ERROR with the location within the input file of the problem. */ - void Unexpected( int aTok ) throw( IOError ); + void Unexpected( int aTok ) throw( IO_ERROR ); /** * Function Unexpected - * throws an IOError exception with an input file specific error message. + * throws an IO_ERROR exception with an input file specific error message. * @param aErrorMsg is the token/keyword type which was not expected at the * current input location. - * @throw IOError with the location within the input file of the problem. + * @throw IO_ERROR with the location within the input file of the problem. */ - void Unexpected( const wxString& aErrorMsg ) throw( IOError ); + void Unexpected( const wxString& aErrorMsg ) throw( IO_ERROR ); /** * Function NeedLEFT * calls NextTok() and then verifies that the token read in is a DSN_LEFT. - * If it is not, an IOError is thrown. - * @throw IOError, if the next token is not a DSN_LEFT + * If it is not, an IO_ERROR is thrown. + * @throw IO_ERROR, if the next token is not a DSN_LEFT */ - void NeedLEFT() throw( IOError ); + void NeedLEFT() throw( IO_ERROR ); /** * Function NeedRIGHT * calls NextTok() and then verifies that the token read in is a DSN_RIGHT. - * If it is not, an IOError is thrown. - * @throw IOError, if the next token is not a DSN_RIGHT + * If it is not, an IO_ERROR is thrown. + * @throw IO_ERROR, if the next token is not a DSN_RIGHT */ - void NeedRIGHT() throw( IOError ); + void NeedRIGHT() throw( IO_ERROR ); /** * Function GetTokenText diff --git a/include/richio.h b/include/richio.h index 0c4bd8d95c..a4d04770af 100644 --- a/include/richio.h +++ b/include/richio.h @@ -42,20 +42,20 @@ /** - * Struct IOError + * Struct IO_ERROR * is a class used to hold an error message and may be used to throw exceptions * containing meaningful error messages. */ -struct IOError +struct IO_ERROR { wxString errorText; - IOError( const wxChar* aMsg ) : + IO_ERROR( const wxChar* aMsg ) : errorText( aMsg ) { } - IOError( const wxString& aMsg ) : + IO_ERROR( const wxString& aMsg ) : errorText( aMsg ) { } @@ -104,9 +104,9 @@ public: * counter. If the line is larger than aMaxLineLength passed to the * constructor, then an exception is thrown. The line is nul terminated. * @return unsigned - The number of bytes read, 0 at end of file. - * @throw IOError when a line is too long. + * @throw IO_ERROR when a line is too long. */ - virtual unsigned ReadLine() throw( IOError ) = 0; + virtual unsigned ReadLine() throw( IO_ERROR ) = 0; /** * Function GetSource @@ -181,7 +181,7 @@ public: fclose( fp ); } - unsigned ReadLine() throw( IOError ); // see LINE_READER::ReadLine() description + unsigned ReadLine() throw( IO_ERROR ); // see LINE_READER::ReadLine() description /** * Function Rewind @@ -228,31 +228,32 @@ public: source = aSource; } - unsigned ReadLine() throw(IOError); // see LINE_READER::ReadLine() description + unsigned ReadLine() throw( IO_ERROR ); // see LINE_READER::ReadLine() description }; /** * Class OUTPUTFORMATTER - * is an important interface (abstract) class used to output UTF8 text in a convenient - * way. The primary interface is "printf() - like" but with support for indentation - * control. The destination of the 8 bit wide text is up to the implementer. + * is an important interface (abstract) class used to output UTF8 text in + * a convenient way. The primary interface is "printf() - like" but + * with support for indentation control. The destination of the 8 bit + * wide text is up to the implementer. *

- * The implementer only has to implement the write() function, but can also optionaly - * re-implement GetQuoteChar(). + * The implementer only has to implement the write() function, but can + * also optionally re-implement GetQuoteChar(). *

- * If you want to output a wxString, then use CONV_TO_UTF8() on it before passing - * it as an argument to Print(). + * If you want to output a wxString, then use CONV_TO_UTF8() on it + * before passing it as an argument to Print(). *

- * Since this is an abstract interface, only classes derived from this one - * may actually be used. + * Since this is an abstract interface, only classes derived from + * this one may actually be used. */ class OUTPUTFORMATTER { std::vector buffer; - int sprint( const char* fmt, ... ) throw( IOError ); - int vprint( const char* fmt, va_list ap ) throw( IOError ); + int sprint( const char* fmt, ... ) throw( IO_ERROR ); + int vprint( const char* fmt, va_list ap ) throw( IO_ERROR ); protected: @@ -283,9 +284,9 @@ protected: * * @param aOutBuf is the start of a byte buffer to write. * @param aCount tells how many bytes to write. - * @throw IOError, if there is a problem outputting, such as a full disk. + * @throw IO_ERROR, if there is a problem outputting, such as a full disk. */ - virtual void write( const char* aOutBuf, int aCount ) throw( IOError ) = 0; + virtual void write( const char* aOutBuf, int aCount ) throw( IO_ERROR ) = 0; #if defined(__GNUG__) // The GNU C++ compiler defines this @@ -307,14 +308,14 @@ public: * Function Print * formats and writes text to the output stream. * - * @param nestLevel The multiple of spaces to preceed the output with. + * @param nestLevel The multiple of spaces to precede the output with. * @param fmt A printf() style format string. * @param ... a variable list of parameters that will get blended into * the output under control of the format string. * @return int - the number of characters output. - * @throw IOError, if there is a problem outputting, such as a full disk. + * @throw IO_ERROR, if there is a problem outputting, such as a full disk. */ - int PRINTF_FUNC Print( int nestLevel, const char* fmt, ... ) throw( IOError ); + int PRINTF_FUNC Print( int nestLevel, const char* fmt, ... ) throw( IO_ERROR ); /** * Function GetQuoteChar @@ -350,11 +351,11 @@ public: * * @return const char* - useful for passing to printf() style functions that * must output utf8 streams. - * @throw IOError, if aWrapee has any \r or \n bytes in it which is + * @throw IO_ERROR, if aWrapee has any \r or \n bytes in it which is * illegal according to the DSNLEXER who does not ever want them * within a string. */ - virtual const char* Quoted( std::string* aWrapee ) throw( IOError ); + virtual const char* Quoted( std::string* aWrapee ) throw( IO_ERROR ); //---------------------------------------------- }; @@ -402,7 +403,7 @@ public: //----------------------------------------------------- protected: - void write( const char* aOutBuf, int aCount ) throw( IOError ); + void write( const char* aOutBuf, int aCount ) throw( IO_ERROR ); //---------------------------------------------------- }; @@ -434,7 +435,7 @@ public: const char* GetQuoteChar( const char* wrapee ); protected: - void write( const char* aOutBuf, int aCount ) throw( IOError ); + void write( const char* aOutBuf, int aCount ) throw( IO_ERROR ); //---------------------------------------------------- }; diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index ce5a933d2a..6eadb588d9 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -5,11 +5,46 @@ #ifndef SCH_ITEM_STRUCT_H #define SCH_ITEM_STRUCT_H +#include +#include +using namespace std; + + +class SCH_ITEM; class WinEDA_SchematicFrame; class wxFindReplaceData; +enum DANGLING_END_T { + UNKNOWN = 0, + WIRE_START_END, + WIRE_END_END, + BUS_START_END, + BUS_END_END, + JUNCTION_END, + PIN_END, + LABEL_END, + ENTRY_END, + SHEET_LABEL_END +}; + +// A helper class to store a list of items that can be connected to something: +class DANGLING_END_ITEM +{ +public: + const void* m_Item; // a pointer to the parent + wxPoint m_Pos; // the position of the connecting point + DANGLING_END_T m_Type; // type of parent + + DANGLING_END_ITEM( DANGLING_END_T type, const void* aItem ) + { + m_Item = aItem; + m_Type = type; + } +}; + + /** * Class SCH_ITEM * is a base class for any item which can be embedded within the SCHEMATIC @@ -21,7 +56,7 @@ class SCH_ITEM : public EDA_BaseStruct { protected: int m_Layer; - + EDA_ITEMS m_connections; ///< List of items connected to this item. public: SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ); @@ -72,15 +107,15 @@ public: * move item to a new position. * @param aMoveVector = the deplacement vector */ - virtual void Move(const wxPoint& aMoveVector) = 0; + virtual void Move( const wxPoint& aMoveVector ) = 0; /** virtual function Mirror_Y * mirror item relative to an Y axis * @param aYaxis_position = the y axis position */ - virtual void Mirror_Y(int aYaxis_position) = 0; - virtual void Mirror_X(int aXaxis_position) = 0; - virtual void Rotate(wxPoint rotationPoint) = 0; + virtual void Mirror_Y( int aYaxis_position ) = 0; + virtual void Mirror_X( int aXaxis_position ) = 0; + virtual void Rotate( wxPoint rotationPoint ) = 0; /** @@ -109,8 +144,7 @@ public: * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @return True if this schematic text item matches the search criteria. */ - virtual bool Matches( wxFindReplaceData& aSearchData, - void * aAuxData, wxPoint * aFindLocation ) + virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) { return false; } /** @@ -121,6 +155,62 @@ public: * @return True if this item matches the search criteria. */ bool Matches( const wxString& aText, wxFindReplaceData& aSearchData ); + + /** + * Add schematic item end points to \a aItemList if the item has endpoints. + * + * The default version doesn't do anything since many of the schematic object cannot + * be tested for dangling ends. If you add a new schematic item that can have a + * dangling end ( no connect ), override this method to provide the correct end + * points. + * + * @param aItemList - List of DANGLING_END_ITEMS to add to. + */ + virtual void GetEndPoints( vector< DANGLING_END_ITEM >& aItemList ) {} + + /** + * Test the schematic item to \a aItemList to check if it's dangling state has changed. + * + * Note that the return value only true when the state of the test has changed. Use + * the IsDangling() method to get the current dangling state of the item. Some of + * the schematic objects cannot be tested for a dangling state, the default method + * always returns false. Only override the method if the item can be tested for a + * dangling state. + * + * @param aItemList - List of items to test item against. + * @return True if the dangling state has changed from it's current setting. + */ + virtual bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList ) { return false; } + + virtual bool IsDangling() const { return false; } + + /** + * Check if the selection state of an item inside \a aRect has changed. + * + * The is used by the block selection code to verify if an item is selected or not. + * True is be return anytime the select state changes. If you need to know the + * the current selection state, use the IsSelected() method. + * + * @param aRect - Rectange to test against. + */ + virtual bool IsSelectStateChanged( const wxRect& aRect ) { return false; } + + /** + * Get a list of connection points for this item. + * + * Not all schematic items have connection points so the default method does nothing. + * + * @param aPoints - List of connection points to add to. + */ + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const { } + + /** + * Clear all of the connection items from the list. + * + * The vector release method is used to prevent the item pointers from being deleted. + * Do not use the vector erase method on the connection list. + */ + void ClearConnections() { m_connections.release(); } }; #endif /* SCH_ITEM_STRUCT_H */ diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 355f77826a..182de55447 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -9,6 +9,7 @@ #include "wxstruct.h" #include "base_struct.h" #include "param_config.h" +#include "class_layerchoicebox.h" #ifndef PCB_INTERNAL_UNIT #define PCB_INTERNAL_UNIT 10000 @@ -114,7 +115,7 @@ protected: public: - WinEDAChoiceBox* m_SelLayerBox; // a combo box to display and + WinEDALayerChoiceBox* m_SelLayerBox; // a combo box to display and // select active layer WinEDAChoiceBox* m_SelTrackWidthBox; // a combo box to display and // select current track width @@ -308,7 +309,7 @@ public: void ReCreateMicrowaveVToolbar(); void ReCreateOptToolbar(); void ReCreateMenuBar(); - WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent ); + WinEDALayerChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent ); /** Virtual Function OnModify() * Must be called after a board change diff --git a/include/xnode.h b/include/xnode.h index daab8bdc9c..4ec00e1178 100644 --- a/include/xnode.h +++ b/include/xnode.h @@ -52,9 +52,9 @@ public: * writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression. * @param out The formatter to write to. * @param nestLevel A multiple of the number of spaces to preceed the output with. - * @throw IOError if a system error writing the output, such as a full disk. + * @throw IO_ERROR if a system error writing the output, such as a full disk. */ - virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ); + virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); /** * Function FormatContents @@ -62,9 +62,9 @@ public: * This is the same as Format() except that the outer wrapper is not included. * @param out The formatter to write to. * @param nestLevel A multiple of the number of spaces to preceed the output with. - * @throw IOError if a system error writing the output, such as a full disk. + * @throw IO_ERROR if a system error writing the output, such as a full disk. */ - virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ); + virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); // The following functions did not appear in the base class until recently. // Overload them even if they are present in base class, just to make sure diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt index 7a9f237190..42fdf5c745 100644 --- a/kicad/CMakeLists.txt +++ b/kicad/CMakeLists.txt @@ -44,7 +44,7 @@ add_executable(kicad WIN32 MACOSX_BUNDLE if(APPLE) set_target_properties(kicad PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) - target_link_libraries(kicad common bitmaps ${wxWidgets_LIBRARIES}) + target_link_libraries(kicad common bitmaps kbool polygon ${wxWidgets_LIBRARIES}) else(APPLE) target_link_libraries(kicad common bitmaps kbool polygon ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES}) endif(APPLE) diff --git a/new/design.h b/new/design.h index 31c9953273..b166ebe71a 100644 --- a/new/design.h +++ b/new/design.h @@ -418,7 +418,7 @@ protected: ///< derived classes must implement * part is done, then LIB::ReloadPart() must be called on this same part * and all parts that inherit it must be reparsed. */ - virtual void WritePart( const STRING& aPartName, const STRING& aSExpression ) throw ( IO_ERROR ) = 0; + virtual void WritePart( const STRING& aPartName, const STRING& aSExpression ) throw( IO_ERROR ) = 0; protected: @@ -444,7 +444,7 @@ public: * will find it and load it into its containing LIB, even if that means * having to load a new LIB as given in the library table. */ - static PART* GetPart( const LPID& aLogicalPartID ) throw ( IO_ERROR ); + static PART* GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR ); /** * Function GetLib @@ -572,9 +572,9 @@ public: * There can be some self referential issues that mean all the parts in the PARTS_LIST * have to reparsed. */ - virtual void WritePart( PART* aPart ) throw ( IO_ERROR ) = 0; + virtual void WritePart( PART* aPart ) throw( IO_ERROR ) = 0; - virtual void SetPartBody( PART* aPart, const STRING& aSExpression ) throw ( IO_ERROR ); + virtual void SetPartBody( PART* aPart, const STRING& aSExpression ) throw( IO_ERROR ); /** * Function GetRevisions diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 13c233c1c8..b00e21ba1d 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -861,8 +861,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_TOOLBARH_PCB_SELECT_LAYER: - itmp = m_SelLayerBox->GetChoice(); - setActiveLayer( (size_t) m_SelLayerBox->wxItemContainer::GetClientData( itmp ) ); + setActiveLayer( (size_t) m_SelLayerBox->GetLayerSelection()); if( DisplayOpt.ContrastModeDisplay ) DrawPanel->Refresh( true ); break; diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index dc1cc892c2..5b53b6095b 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -449,13 +449,13 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_BaseStruct* aIte break; case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress - if( m_ID_current_state != ID_TRACK_BUTT ) - return; if( !itemCurrentlyEdited ) // no track in progress: switch layer only { Other_Layer_Route( NULL, aDC ); break; } + if( m_ID_current_state != ID_TRACK_BUTT ) + return; if( GetCurItem()->Type() != TYPE_TRACK ) return; if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index 27706c59ad..2ec96cc348 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -44,7 +44,6 @@ #define BUTT_SIZE_Y 18 #define BUTT_VOID 4 - /* XPM */ static const char * clear_xpm[] = { "10 14 1 1", @@ -152,9 +151,13 @@ wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, int aColor, in // then create a wxBitmapButton from it. wxBitmap bitmap = makeBitmap( aColor ); +#ifndef __WXMAC__ wxBitmapButton* ret = new wxBitmapButton( aParent, aID, bitmap, wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y), wxBORDER_RAISED ); - +#else + wxBitmapButton* ret = new wxBitmapButton( aParent, aID, bitmap, + wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y)); +#endif // save the color value in the name, no where else to put it. ret->SetName( makeColorTxt( aColor ) ); return ret; diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 82f6f68fd7..b8670f287a 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -32,26 +32,24 @@ void WinEDA_PcbFrame::ReCreateMenuBar() menuBar = new wxMenuBar(); - /** - * File Menu - */ + /** Create File Menu */ wxMenu* filesMenu = new wxMenu; - /* New */ + // New item = new wxMenuItem( filesMenu, ID_NEW_BOARD, _( "&New" ), _( "Clear current board and initialize a new one" ) ); item->SetBitmap( new_xpm ); filesMenu->Append( item ); - /* Open */ + // Open item = new wxMenuItem( filesMenu, ID_LOAD_FILE, _( "&Open\tCtrl+O" ), _( "Delete current board and load new board" ) ); item->SetBitmap( open_xpm ); filesMenu->Append( item ); - /* Load Recent submenu */ + // Load Recent submenu wxMenu* openRecentMenu = new wxMenu(); wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, @@ -60,54 +58,50 @@ void WinEDA_PcbFrame::ReCreateMenuBar() open_project_xpm ); - /* PCBNew Board */ + // PCBNew Board item = new wxMenuItem( filesMenu, ID_APPEND_FILE, _( "&Append Board" ), _( "Append another PCBNew board to the current loaded board" ) ); item->SetBitmap( import_xpm ); filesMenu->Append( item ); - /* Separator */ + // Separator filesMenu->AppendSeparator(); - /* Save */ + // Save item = new wxMenuItem( filesMenu, ID_SAVE_BOARD, _( "&Save\tCtrl+S" ), _( "Save current board" ) ); item->SetBitmap( save_xpm ); filesMenu->Append( item ); - /* Save As */ + // Save As item = new wxMenuItem( filesMenu, ID_SAVE_BOARD_AS, _( "Save as..." ), _( "Save the current board as.." ) ); item->SetBitmap( save_as_xpm ); filesMenu->Append( item ); - - /* Separator */ filesMenu->AppendSeparator(); - /* Revert */ + // Revert item = new wxMenuItem( filesMenu, ID_MENU_READ_LAST_SAVED_VERSION_BOARD, _( "&Revert" ), _( "Clear board and get previous saved version of board" ) ); item->SetBitmap( jigsaw_xpm ); filesMenu->Append( item ); - /* Rescue */ + // Rescue item = new wxMenuItem( filesMenu, ID_MENU_RECOVER_BOARD, _( "&Rescue" ), _( "Clear old board and get last rescue file" ) ); item->SetBitmap( hammer_xpm ); filesMenu->Append( item ); - - /* Separator */ filesMenu->AppendSeparator(); /* Fabrication Outputs submenu */ wxMenu* fabricationOutputsMenu = new wxMenu; item = new wxMenuItem( fabricationOutputsMenu, ID_PCB_GEN_POS_MODULES_FILE, - _( "&Modules Position" ), + _( "&Modules Position File" ), _( "Generate modules position file for pick and place" ) ); item->SetBitmap( post_compo_xpm ); fabricationOutputsMenu->Append( item ); @@ -118,14 +112,14 @@ void WinEDA_PcbFrame::ReCreateMenuBar() item->SetBitmap( post_drill_xpm ); fabricationOutputsMenu->Append( item ); - /* Component File */ + // Component File item = new wxMenuItem( fabricationOutputsMenu, ID_PCB_GEN_CMP_FILE, _( "&Component File" ), - _( "(Re)create components file for CvPcb" ) ); + _( "(Re)create components file (*.cmp) for CvPcb" ) ); item->SetBitmap( save_cmpstuff_xpm ); fabricationOutputsMenu->Append( item ); - /* BOM File */ + // BOM File item = new wxMenuItem( fabricationOutputsMenu, ID_PCB_GEN_BOM_FILE_FROM_BOARD, _( "&BOM File" ), _( "Create a bill of materials from schematic" ) ); @@ -141,51 +135,41 @@ void WinEDA_PcbFrame::ReCreateMenuBar() /* Import submenu */ wxMenu* submenuImport = new wxMenu(); - /* Specctra Session */ + // Specctra Session item = new wxMenuItem( submenuImport, ID_GEN_IMPORT_SPECCTRA_SESSION, _( "&Specctra Session" ), _( "Import a routed \"Specctra Session\" (*.ses) file" ) ); item->SetBitmap( import_xpm ); // @todo need better bitmap submenuImport->Append( item ); - /** - * would be implemented in WinEDA_PcbFrame::ImportSpecctraDesign() in - * specctra_import.cpp - * item = new wxMenuItem(submenuImport, ID_GEN_IMPORT_SPECCTRA_DESIGN, - * _("&Specctra Design"), _("Import a \"Specctra Design\" (*.dsn) file") ); - * item->SetBitmap(export_xpm); // @todo need better bitmap - * submenuImport->Append(item); - */ - ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, submenuImport, ID_GEN_IMPORT_FILE, _( "Import" ), _( "Import files" ), import_xpm ); - /* Export submenu */ wxMenu* submenuexport = new wxMenu(); - /* Specctra DSN */ + // Specctra DSN item = new wxMenuItem( submenuexport, ID_GEN_EXPORT_SPECCTRA, _( "&Specctra DSN" ), _( "Export the current board to a \"Specctra DSN\" file" ) ); item->SetBitmap( export_xpm ); submenuexport->Append( item ); - /* GenCAD */ + // GenCAD item = new wxMenuItem( submenuexport, ID_GEN_EXPORT_FILE_GENCADFORMAT, _( "&GenCAD" ), _( "Export GenCAD format" ) ); item->SetBitmap( export_xpm ); submenuexport->Append( item ); - /* Module Report */ + // Module Report item = new wxMenuItem( submenuexport, ID_GEN_EXPORT_FILE_MODULE_REPORT, _( "&Module Report" ), _( "Create a report of all modules on the current board" ) ); item->SetBitmap( tools_xpm ); submenuexport->Append( item ); - /* VRML */ + // VRML item = new wxMenuItem( submenuexport, ID_GEN_EXPORT_FILE_VRML, _( "&VRML" ), _( "Export a VRML board representation" ) ); @@ -196,43 +180,40 @@ void WinEDA_PcbFrame::ReCreateMenuBar() ID_GEN_EXPORT_FILE, _( "&Export" ), _( "Export board" ), export_xpm ); - /* Separator */ filesMenu->AppendSeparator(); - /* Print */ + // Print item = new wxMenuItem( filesMenu, wxID_PRINT, _( "&Print\tCtrl+P" ), _( "Print board" ) ); item->SetBitmap( print_button ); filesMenu->Append( item ); - /* Print SVG */ + // Create SVG file item = new wxMenuItem( filesMenu, ID_GEN_PLOT_SVG, _( "Print S&VG" ), _( "Plot board in Scalable Vector Graphics format" ) ); item->SetBitmap( print_button ); filesMenu->Append( item ); - /* Plot */ + // Plot item = new wxMenuItem( filesMenu, ID_GEN_PLOT, _( "&Plot" ), _( "Plot board in HPGL, PostScript or Gerber RS-274X format)" ) ); item->SetBitmap( plot_xpm ); filesMenu->Append( item ); - - /* Archive Footprints Submenu */ - filesMenu->AppendSeparator(); + filesMenu->AppendSeparator(); wxMenu* submenuarchive = new wxMenu(); - /* Add New Footprints */ + // Archive New Footprints item = new wxMenuItem( submenuarchive, ID_MENU_ARCHIVE_NEW_MODULES, - _( "Add New Footprints" ), + _( "Archive New Footprints" ), _( "Archive new footprints only in a library (keep other footprints in this lib)" ) ); item->SetBitmap( library_update_xpm ); submenuarchive->Append( item ); - /* Create FootPrint Archive */ + // Create FootPrint Archive item = new wxMenuItem( submenuarchive, ID_MENU_ARCHIVE_ALL_MODULES, _( "Create Footprint Archive" ), _( "Archive all footprints in a library (old library will be deleted)" ) ); @@ -255,62 +236,54 @@ void WinEDA_PcbFrame::ReCreateMenuBar() #endif /* !defined( __WXMAC__ ) */ - - - /** - * Edit menu - */ + /** Create Edit menu **/ wxMenu* editMenu = new wxMenu; - /* Undo */ + // Undo text = AddHotkeyName( _( "Undo" ), s_Pcbnew_Editor_Hokeys_Descr, HK_UNDO ); item = new wxMenuItem( editMenu, wxID_UNDO, text, HELP_UNDO, wxITEM_NORMAL ); item->SetBitmap( undo_xpm ); editMenu->Append( item ); - /* Redo */ + // Redo text = AddHotkeyName( _( "Redo" ), s_Pcbnew_Editor_Hokeys_Descr, HK_REDO ); item = new wxMenuItem( editMenu, wxID_REDO, text, HELP_REDO, wxITEM_NORMAL ); item->SetBitmap( redo_xpm ); editMenu->Append( item ); - /* Delete */ + // Delete item = new wxMenuItem( editMenu, ID_PCB_DELETE_ITEM_BUTT, _( "Delete" ), _( "Delete items" ) ); item->SetBitmap( delete_body_xpm ); editMenu->Append( item ); - - /* Separator */ editMenu->AppendSeparator(); - /* Find */ + // Find text = AddHotkeyName( _( "&Find" ), s_Pcbnew_Editor_Hokeys_Descr, HK_FIND_ITEM ); item = new wxMenuItem( editMenu, ID_FIND_ITEMS, text, HELP_FIND ); item->SetBitmap( find_xpm ); editMenu->Append( item ); - - /* Separator */ editMenu->AppendSeparator(); - /* Global Deletions */ + // Global Deletions item = new wxMenuItem( editMenu, ID_PCB_GLOBAL_DELETE, _( "Global &Deletions" ), _( "Delete tracks, modules, texts... on board" ) ); item->SetBitmap( general_deletions_xpm ); editMenu->Append( item ); - /* Cleanup Tracks and Vias */ + // Cleanup Tracks and Vias item = new wxMenuItem( editMenu, ID_MENU_PCB_CLEAN, _( "&Cleanup Tracks and Vias" ), _( "Clean stubs, vias, delete break points, or connect dangling tracks to pads and vias" ) ); item->SetBitmap( delete_body_xpm ); editMenu->Append( item ); - /* Swap Layers */ + // Swap Layers item = new wxMenuItem( editMenu, ID_MENU_PCB_SWAP_LAYERS, _( "&Swap Layers" ), _( "Swap tracks on copper layers or drawings on other layers" ) ); @@ -318,9 +291,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() editMenu->Append( item ); - /** - * View menu - */ + /** Create View menu **/ wxMenu* viewMenu = new wxMenu; /* Important Note for ZOOM IN and ZOOM OUT commands from menubar: @@ -334,7 +305,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() * in other words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators * for Zoom in and Zoom out sub menus */ - /* Zoom In */ + // Zoom In text = AddHotkeyName( _( "Zoom In" ), s_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_IN, false ); item = new wxMenuItem( viewMenu, ID_ZOOM_IN, text, @@ -342,7 +313,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() item->SetBitmap( zoom_in_xpm ); viewMenu->Append( item ); - /* Zoom Out */ + // Zoom Out text = AddHotkeyName( _( "Zoom Out" ), s_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_OUT, false ); item = new wxMenuItem( viewMenu, ID_ZOOM_OUT, text, @@ -351,7 +322,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() item->SetBitmap( zoom_out_xpm ); viewMenu->Append( item ); - /* Fit on Screen */ + // Fit on Screen text = AddHotkeyName( _( "Fit on Screen" ), s_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_AUTO ); @@ -362,7 +333,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() viewMenu->AppendSeparator(); - /* Redraw */ + // Redraw text = AddHotkeyName( _( "Redraw" ), s_Pcbnew_Editor_Hokeys_Descr, HK_ZOOM_REDRAW ); @@ -371,18 +342,16 @@ void WinEDA_PcbFrame::ReCreateMenuBar() wxITEM_NORMAL ); item->SetBitmap( zoom_redraw_xpm ); viewMenu->Append( item ); - - /* Separator */ viewMenu->AppendSeparator(); - /* 3D Display */ + // 3D Display item = new wxMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME, _( "3D Display" ), _( "Show board in 3D viewer" ) ); item->SetBitmap( show_3d_xpm ); viewMenu->Append( item ); - /* List Nets */ + // List Nets item = new wxMenuItem( viewMenu, ID_MENU_LIST_NETS, _( "&List Nets" ), _( "View a list of nets with names and id's" ) ); @@ -391,163 +360,150 @@ void WinEDA_PcbFrame::ReCreateMenuBar() - /** - * Place Menu - */ + /** Create Place Menu **/ wxMenu* placeMenu = new wxMenu; - /* Module */ + // Module text = AddHotkeyName( _( "Module" ), s_Pcbnew_Editor_Hokeys_Descr, - HK_ADD_MODULE ); + HK_ADD_MODULE, false ); item = new wxMenuItem( placeMenu, ID_COMPONENT_BUTT, text, - _( "Place a module" ), wxITEM_NORMAL ); + _( "Add modules" ), wxITEM_NORMAL ); item->SetBitmap( module_xpm ); placeMenu->Append( item ); - /* Track */ + // Track text = AddHotkeyName( _( "Track" ), s_Pcbnew_Editor_Hokeys_Descr, - HK_ADD_NEW_TRACK ); + HK_ADD_NEW_TRACK, false ); item = new wxMenuItem( placeMenu, ID_TRACK_BUTT, text, - _( "Place a track" ), wxITEM_NORMAL ); + _( "Add tracks and vias" ), wxITEM_NORMAL ); item->SetBitmap( add_tracks_xpm ); placeMenu->Append( item ); - /* Zone */ + // Zone item = new wxMenuItem( placeMenu, ID_PCB_ZONES_BUTT, _( "Zone" ), - _( "Place a filled zone" )); + _( "Add filled zones" )); item->SetBitmap( add_zone_xpm ); placeMenu->Append( item ); - /* Text */ + // Text item = new wxMenuItem( placeMenu, ID_PCB_ADD_TEXT_BUTT, _( "Text" ), - _( "Place text" ) ); + _( "Add text on copper layers or graphic text" ) ); item->SetBitmap( add_text_xpm ); placeMenu->Append( item ); - /* Graphics submenu */ - wxMenu *graphicsSubMenu = new wxMenu; - - /* Graphic Arc */ - item = new wxMenuItem( graphicsSubMenu, ID_PCB_ARC_BUTT, + // Graphic Arc + item = new wxMenuItem( placeMenu, ID_PCB_ARC_BUTT, _( "Arc" ), - _( "Place a graphic arc" ) ); + _( "Add graphic arc" ) ); item->SetBitmap( add_arc_xpm ); - graphicsSubMenu->Append( item ); - - /* Graphic Circle */ - item = new wxMenuItem( graphicsSubMenu, ID_PCB_CIRCLE_BUTT, - _( "Circle" ), - _( "Place a graphic circle" )); - item->SetBitmap( add_circle_xpm ); - graphicsSubMenu->Append( item ); - - /* Dimension */ - item = new wxMenuItem( graphicsSubMenu, ID_PCB_DIMENSION_BUTT, - _( "Dimension" ), - _( "Place a dimension" ) ); - item->SetBitmap( add_dimension_xpm ); - graphicsSubMenu->Append( item ); - - /* Line or Polygon */ - item = new wxMenuItem( graphicsSubMenu, ID_PCB_ADD_LINE_BUTT, - _( "Line or Polygon" ), - _( "Place a graphic line or polygon" )); - item->SetBitmap( add_dashed_line_xpm ); - graphicsSubMenu->Append( item ); - - /* Append graphics submenu to placeMenu */ - placeMenu->AppendSubMenu(graphicsSubMenu, _( "Graphics" )); - - /* Separator */ - placeMenu->AppendSeparator(); - - /* Layer alignment target */ - item = new wxMenuItem( placeMenu, ID_PCB_MIRE_BUTT, - _( "Layer alignment target" ), - _( "Place a layer alignment target" )); - item->SetBitmap( add_mires_xpm ); placeMenu->Append( item ); - /* Drill & Place Offset */ + // Graphic Circle + item = new wxMenuItem( placeMenu, ID_PCB_CIRCLE_BUTT, + _( "Circle" ), + _( "Add graphic circle" )); + item->SetBitmap( add_circle_xpm ); + placeMenu->Append( item ); + + // Line or Polygon + item = new wxMenuItem( placeMenu, ID_PCB_ADD_LINE_BUTT, + _( "Line or Polygon" ), + _( "Add graphic line or polygon" )); + item->SetBitmap( add_dashed_line_xpm ); + placeMenu->Append( item ); + placeMenu->AppendSeparator(); + + // Dimension + item = new wxMenuItem( placeMenu, ID_PCB_DIMENSION_BUTT, + _( "Dimension" ), + _( "Add dimension" ) ); + item->SetBitmap( add_dimension_xpm ); + placeMenu->Append( item ); + + // Layer alignment target + item = new wxMenuItem( placeMenu, ID_PCB_MIRE_BUTT, + _( "Layer alignment target" ), + _( "Add layer alignment target" )); + item->SetBitmap( add_mires_xpm ); + placeMenu->Append( item ); + placeMenu->AppendSeparator(); + + // Drill & Place Offset item = new wxMenuItem( placeMenu, ID_PCB_PLACE_OFFSET_COORD_BUTT, _( "Drill and Place Offset" ), - _( "Place the offset adjust for drill and place files" )); + _( "Place the origin point for drill and place files" )); item->SetBitmap( pcb_offset_xpm ); placeMenu->Append( item ); - /* Grid Origin */ + // Grid Origin item = new wxMenuItem( placeMenu, ID_PCB_PLACE_GRID_COORD_BUTT, _( "Grid Origin" ), - _( "Place origin point for the grid" )); + _( "Set the origin point for the grid" )); item->SetBitmap( grid_select_axis_xpm ); placeMenu->Append( item ); - /** - * Preferences and configuration - */ + /** Create Preferences and configuration menu **/ wxMenu* configmenu = new wxMenu; - /* Library */ + // Library item = new wxMenuItem( configmenu, ID_CONFIG_REQ, _( "&Library" ), _( "Setting libraries, directories and others..." ) ); item->SetBitmap( library_xpm ); configmenu->Append( item ); - /* Colors and Visibility are handled by the layers manager toolbar - * that can be shown or hidden - */ + // Colors and Visibility are also handled by the layers manager toolbar item = new wxMenuItem( configmenu, ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, _( "Hide &Layers Manager" ), HELP_SHOW_HIDE_LAYERMANAGER ); item->SetBitmap( layers_manager_xpm ); configmenu->Append( item ); - /* General */ + // General item = new wxMenuItem( configmenu, ID_OPTIONS_SETUP, _( "&General" ), _( "Select general options for PCBnew" ) ); item->SetBitmap( preference_xpm ); configmenu->Append( item ); - /* Display */ + //Display item = new wxMenuItem( configmenu, ID_PCB_DISPLAY_OPTIONS_SETUP, _( "&Display" ), _( "Select how items (pads, tracks texts ... ) are displayed" ) ); item->SetBitmap( display_options_xpm ); configmenu->Append( item ); - /* Dimensions submenu */ + /* Create Dimensions submenu */ wxMenu* dimensionsMenu = new wxMenu; - /* Grid */ + // Grid item = new wxMenuItem( dimensionsMenu, ID_PCB_USER_GRID_SETUP, _( "Grid" ), _( "Adjust user grid dimensions" ) ); item->SetBitmap( grid_xpm ); dimensionsMenu->Append( item ); - /* Text and Drawings */ + // Text and Drawings item = new wxMenuItem( dimensionsMenu, ID_PCB_DRAWINGS_WIDTHS_SETUP, _( "Texts and Drawings" ), _( "Adjust dimensions for texts and drawings" ) ); item->SetBitmap( options_text_xpm ); dimensionsMenu->Append( item ); - /* Pads */ + // Pads item = new wxMenuItem( dimensionsMenu, ID_PCB_PAD_SETUP, _( "Pads" ), _( "Adjust default pad characteristics" ) ); item->SetBitmap( pad_xpm ); dimensionsMenu->Append( item ); - /* Pads Mask Clearance */ + // Pads Mask Clearance item = new wxMenuItem( dimensionsMenu, ID_PCB_MASK_CLEARANCE, _( "Pads Mask Clearance" ), _( "Adjust the global clearance between pads and the solder resist mask" ) ); @@ -555,7 +511,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() dimensionsMenu->Append( item ); - /* Save dimension preferences */ + // Save dimension preferences dimensionsMenu->AppendSeparator(); item = new wxMenuItem( dimensionsMenu, ID_CONFIG_SAVE, _( "&Save" ), @@ -569,23 +525,21 @@ void WinEDA_PcbFrame::ReCreateMenuBar() _( "Global dimensions preferences" ), add_dimension_xpm ); - /* Language submenu */ + // Language submenu wxGetApp().AddMenuLanguageList( configmenu ); - /* Hotkey submenu */ + // Hotkey submenu AddHotkeyConfigMenu( configmenu ); - - /* Separator */ configmenu->AppendSeparator(); - /* Save Preferences */ + // Save Preferences item = new wxMenuItem( configmenu, ID_CONFIG_SAVE, _( "&Save Preferences" ), _( "Save application preferences" ) ); item->SetBitmap( save_setup_xpm ); configmenu->Append( item ); - /* Read Preferences */ + // Read Preferences item = new wxMenuItem( configmenu, ID_CONFIG_READ, _( "&Read Preferences" ), _( "Read application preferences" ) ); @@ -624,7 +578,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() /* Contents */ item = new wxMenuItem( helpMenu, ID_GENERAL_HELP, _( "&Contents" ), - _( "Open the PCBnew manual" ) ); + _( "Open the on line PCBnew documentation" ) ); item->SetBitmap( online_help_xpm ); helpMenu->Append( item ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index e200d788b2..79e4bfc678 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -341,7 +341,10 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, // wxAuiPaneInfo items to manage them. vert.TopDockable( false ).BottomDockable( false ); horiz.LeftDockable( false ).RightDockable( false ); - horiz.ToolbarPane().Gripper( false ); + + // Create a template from the horiz wxAuiPaneInfo, specific to horizontal toolbars: + wxAuiPaneInfo horiz_tb( horiz ); + horiz_tb.ToolbarPane().Gripper( false ); // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template. // LAYER_WIDGET is floatable, but initially docked at far right @@ -356,13 +359,13 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, if( m_HToolBar ) { m_auimgr.AddPane( m_HToolBar, - wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) ); + wxAuiPaneInfo( horiz_tb ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) ); } if( m_AuxiliaryToolBar ) { m_auimgr.AddPane( m_AuxiliaryToolBar, - wxAuiPaneInfo( horiz ).Name( wxT( "m_AuxiliaryToolBar" ) ).Top().Row( 1 ) ); + wxAuiPaneInfo( horiz_tb ).Name( wxT( "m_AuxiliaryToolBar" ) ).Top().Row( 1 ) ); } if( m_AuxVToolBar ) @@ -379,7 +382,8 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, { m_auimgr.AddPane( m_OptionsToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() - .ToolbarPane().Gripper( false )); + .ToolbarPane().Gripper( false ) ); + m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR, m_show_layer_manager_tools ); m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp index df70774ac9..f041e32677 100644 --- a/pcbnew/specctra.cpp +++ b/pcbnew/specctra.cpp @@ -533,7 +533,7 @@ int SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const } -void SPECCTRA_DB::ThrowIOError( const wxChar* fmt, ... ) throw( IOError ) +void SPECCTRA_DB::ThrowIOError( const wxChar* fmt, ... ) throw( IO_ERROR ) { wxString errText; va_list args; @@ -542,18 +542,18 @@ void SPECCTRA_DB::ThrowIOError( const wxChar* fmt, ... ) throw( IOError ) errText.PrintfV( fmt, args ); va_end( args ); - throw IOError( errText ); + throw IO_ERROR( errText ); } -void SPECCTRA_DB::expecting( const char* text ) throw( IOError ) +void SPECCTRA_DB::expecting( const char* text ) throw( IO_ERROR ) { wxString errText = CONV_FROM_UTF8( text ); lexer->Expecting( errText ); } -void SPECCTRA_DB::unexpected( const char* text ) throw( IOError ) +void SPECCTRA_DB::unexpected( const char* text ) throw( IO_ERROR ) { wxString errText = CONV_FROM_UTF8( text ); lexer->Unexpected( errText ); @@ -566,7 +566,7 @@ DSN_T SPECCTRA_DB::nextTok() return ret; } -void SPECCTRA_DB::readCOMPnPIN( std::string* component_id, std::string* pin_id ) throw( IOError ) +void SPECCTRA_DB::readCOMPnPIN( std::string* component_id, std::string* pin_id ) throw( IO_ERROR ) { DSN_T tok; @@ -609,7 +609,7 @@ void SPECCTRA_DB::readCOMPnPIN( std::string* component_id, std::string* pin_id ) } -void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IOError ) +void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IO_ERROR ) { DSN_T tok; @@ -675,7 +675,7 @@ void SPECCTRA_DB::readTIME( time_t* time_stamp ) throw( IOError ) } -void SPECCTRA_DB::LoadPCB( const wxString& filename ) throw( IOError ) +void SPECCTRA_DB::LoadPCB( const wxString& filename ) throw( IO_ERROR ) { FILE* fp = wxFopen( filename, wxT("r") ); @@ -704,7 +704,7 @@ void SPECCTRA_DB::LoadPCB( const wxString& filename ) throw( IOError ) } -void SPECCTRA_DB::LoadSESSION( const wxString& filename ) throw( IOError ) +void SPECCTRA_DB::LoadSESSION( const wxString& filename ) throw( IO_ERROR ) { FILE* fp = wxFopen( filename, wxT("r") ); @@ -733,7 +733,7 @@ void SPECCTRA_DB::LoadSESSION( const wxString& filename ) throw( IOError ) } -void SPECCTRA_DB::doPCB( PCB* growth ) throw( IOError ) +void SPECCTRA_DB::doPCB( PCB* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -838,7 +838,7 @@ void SPECCTRA_DB::doPCB( PCB* growth ) throw( IOError ) } -void SPECCTRA_DB::doPARSER( PARSER* growth ) throw( IOError ) +void SPECCTRA_DB::doPARSER( PARSER* growth ) throw( IO_ERROR ) { DSN_T tok; std::string const1; @@ -977,7 +977,7 @@ void SPECCTRA_DB::doPARSER( PARSER* growth ) throw( IOError ) } -void SPECCTRA_DB::doRESOLUTION( UNIT_RES* growth ) throw(IOError) +void SPECCTRA_DB::doRESOLUTION( UNIT_RES* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1004,7 +1004,7 @@ void SPECCTRA_DB::doRESOLUTION( UNIT_RES* growth ) throw(IOError) } -void SPECCTRA_DB::doUNIT( UNIT_RES* growth ) throw(IOError) +void SPECCTRA_DB::doUNIT( UNIT_RES* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1025,7 +1025,7 @@ void SPECCTRA_DB::doUNIT( UNIT_RES* growth ) throw(IOError) } -void SPECCTRA_DB::doLAYER_PAIR( LAYER_PAIR* growth ) throw( IOError ) +void SPECCTRA_DB::doLAYER_PAIR( LAYER_PAIR* growth ) throw( IO_ERROR ) { needSYMBOL(); growth->layer_id0 = lexer->CurText(); @@ -1041,7 +1041,7 @@ void SPECCTRA_DB::doLAYER_PAIR( LAYER_PAIR* growth ) throw( IOError ) } -void SPECCTRA_DB::doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IOError ) +void SPECCTRA_DB::doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -1060,7 +1060,7 @@ void SPECCTRA_DB::doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IOEr } -void SPECCTRA_DB::doSTRUCTURE( STRUCTURE* growth ) throw(IOError) +void SPECCTRA_DB::doSTRUCTURE( STRUCTURE* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -1194,7 +1194,7 @@ L_place: } -void SPECCTRA_DB::doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IOError ) +void SPECCTRA_DB::doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IO_ERROR ) { /* ::= @@ -1237,7 +1237,7 @@ void SPECCTRA_DB::doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IOError ) } -void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError ) +void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1326,7 +1326,7 @@ void SPECCTRA_DB::doKEEPOUT( KEEPOUT* growth ) throw( IOError ) } -void SPECCTRA_DB::doWINDOW( WINDOW* growth ) throw( IOError ) +void SPECCTRA_DB::doWINDOW( WINDOW* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1378,7 +1378,7 @@ void SPECCTRA_DB::doWINDOW( WINDOW* growth ) throw( IOError ) } -void SPECCTRA_DB::doBOUNDARY( BOUNDARY* growth ) throw( IOError ) +void SPECCTRA_DB::doBOUNDARY( BOUNDARY* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1425,7 +1425,7 @@ void SPECCTRA_DB::doBOUNDARY( BOUNDARY* growth ) throw( IOError ) } -void SPECCTRA_DB::doPATH( PATH* growth ) throw( IOError ) +void SPECCTRA_DB::doPATH( PATH* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1473,7 +1473,7 @@ void SPECCTRA_DB::doPATH( PATH* growth ) throw( IOError ) } -void SPECCTRA_DB::doRECTANGLE( RECTANGLE* growth ) throw( IOError ) +void SPECCTRA_DB::doRECTANGLE( RECTANGLE* growth ) throw( IO_ERROR ) { needSYMBOL(); growth->layer_id = lexer->CurText(); @@ -1498,7 +1498,7 @@ void SPECCTRA_DB::doRECTANGLE( RECTANGLE* growth ) throw( IOError ) } -void SPECCTRA_DB::doCIRCLE( CIRCLE* growth ) throw( IOError ) +void SPECCTRA_DB::doCIRCLE( CIRCLE* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -1526,7 +1526,7 @@ void SPECCTRA_DB::doCIRCLE( CIRCLE* growth ) throw( IOError ) } -void SPECCTRA_DB::doQARC( QARC* growth ) throw( IOError ) +void SPECCTRA_DB::doQARC( QARC* growth ) throw( IO_ERROR ) { needSYMBOL(); growth->layer_id = lexer->CurText(); @@ -1550,7 +1550,7 @@ void SPECCTRA_DB::doQARC( QARC* growth ) throw( IOError ) } -void SPECCTRA_DB::doSTRINGPROP( STRINGPROP* growth ) throw( IOError ) +void SPECCTRA_DB::doSTRINGPROP( STRINGPROP* growth ) throw( IO_ERROR ) { needSYMBOL(); growth->value = lexer->CurText(); @@ -1558,7 +1558,7 @@ void SPECCTRA_DB::doSTRINGPROP( STRINGPROP* growth ) throw( IOError ) } -void SPECCTRA_DB::doTOKPROP( TOKPROP* growth ) throw( IOError ) +void SPECCTRA_DB::doTOKPROP( TOKPROP* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1571,7 +1571,7 @@ void SPECCTRA_DB::doTOKPROP( TOKPROP* growth ) throw( IOError ) } -void SPECCTRA_DB::doVIA( VIA* growth ) throw( IOError ) +void SPECCTRA_DB::doVIA( VIA* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -1600,7 +1600,7 @@ void SPECCTRA_DB::doVIA( VIA* growth ) throw( IOError ) } -void SPECCTRA_DB::doCONTROL( CONTROL* growth ) throw( IOError ) +void SPECCTRA_DB::doCONTROL( CONTROL* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -1647,7 +1647,7 @@ void SPECCTRA_DB::doCONTROL( CONTROL* growth ) throw( IOError ) } -void SPECCTRA_DB::doPROPERTIES( PROPERTIES* growth ) throw( IOError ) +void SPECCTRA_DB::doPROPERTIES( PROPERTIES* growth ) throw( IO_ERROR ) { DSN_T tok; PROPERTY property; // construct it once here, append multiple times. @@ -1670,7 +1670,7 @@ void SPECCTRA_DB::doPROPERTIES( PROPERTIES* growth ) throw( IOError ) } -void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) +void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1792,7 +1792,7 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) } -void SPECCTRA_DB::doRULE( RULE* growth ) throw( IOError ) +void SPECCTRA_DB::doRULE( RULE* growth ) throw( IO_ERROR ) { std::string builder; int bracketNesting = 1; // we already saw the opening T_LEFT @@ -1838,7 +1838,7 @@ void SPECCTRA_DB::doRULE( RULE* growth ) throw( IOError ) #if 0 -void SPECCTRA_DB::doPLACE_RULE( PLACE_RULE* growth, bool expect_object_type ) throw( IOError ) +void SPECCTRA_DB::doPLACE_RULE( PLACE_RULE* growth, bool expect_object_type ) throw( IO_ERROR ) { /* (place_rule [ ] {[ | @@ -1924,7 +1924,7 @@ void SPECCTRA_DB::doPLACE_RULE( PLACE_RULE* growth, bool expect_object_type ) th #endif -void SPECCTRA_DB::doREGION( REGION* growth ) throw( IOError ) +void SPECCTRA_DB::doREGION( REGION* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -1993,7 +1993,7 @@ void SPECCTRA_DB::doREGION( REGION* growth ) throw( IOError ) } -void SPECCTRA_DB::doCLASS_CLASS( CLASS_CLASS* growth ) throw( IOError ) +void SPECCTRA_DB::doCLASS_CLASS( CLASS_CLASS* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2038,7 +2038,7 @@ void SPECCTRA_DB::doCLASS_CLASS( CLASS_CLASS* growth ) throw( IOError ) } -void SPECCTRA_DB::doCLASSES( CLASSES* growth ) throw( IOError ) +void SPECCTRA_DB::doCLASSES( CLASSES* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2061,7 +2061,7 @@ void SPECCTRA_DB::doCLASSES( CLASSES* growth ) throw( IOError ) } -void SPECCTRA_DB::doGRID( GRID* growth ) throw( IOError ) +void SPECCTRA_DB::doGRID( GRID* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2126,7 +2126,7 @@ void SPECCTRA_DB::doGRID( GRID* growth ) throw( IOError ) } -void SPECCTRA_DB::doLAYER_RULE( LAYER_RULE* growth ) throw( IOError ) +void SPECCTRA_DB::doLAYER_RULE( LAYER_RULE* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -2151,7 +2151,7 @@ void SPECCTRA_DB::doLAYER_RULE( LAYER_RULE* growth ) throw( IOError ) } -void SPECCTRA_DB::doPLACE( PLACE* growth ) throw( IOError ) +void SPECCTRA_DB::doPLACE( PLACE* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2266,7 +2266,7 @@ void SPECCTRA_DB::doPLACE( PLACE* growth ) throw( IOError ) } -void SPECCTRA_DB::doCOMPONENT( COMPONENT* growth ) throw( IOError ) +void SPECCTRA_DB::doCOMPONENT( COMPONENT* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2296,7 +2296,7 @@ void SPECCTRA_DB::doCOMPONENT( COMPONENT* growth ) throw( IOError ) } -void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IOError ) +void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -2355,7 +2355,7 @@ void SPECCTRA_DB::doPLACEMENT( PLACEMENT* growth ) throw( IOError ) } -void SPECCTRA_DB::doPADSTACK( PADSTACK* growth ) throw( IOError ) +void SPECCTRA_DB::doPADSTACK( PADSTACK* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2455,7 +2455,7 @@ void SPECCTRA_DB::doPADSTACK( PADSTACK* growth ) throw( IOError ) } -void SPECCTRA_DB::doSHAPE( SHAPE* growth ) throw( IOError ) +void SPECCTRA_DB::doSHAPE( SHAPE* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -2538,7 +2538,7 @@ L_done_that: } -void SPECCTRA_DB::doIMAGE( IMAGE* growth ) throw( IOError ) +void SPECCTRA_DB::doIMAGE( IMAGE* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2634,7 +2634,7 @@ void SPECCTRA_DB::doIMAGE( IMAGE* growth ) throw( IOError ) } -void SPECCTRA_DB::doPIN( PIN* growth ) throw( IOError ) +void SPECCTRA_DB::doPIN( PIN* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); @@ -2681,7 +2681,7 @@ void SPECCTRA_DB::doPIN( PIN* growth ) throw( IOError ) } -void SPECCTRA_DB::doLIBRARY( LIBRARY* growth ) throw( IOError ) +void SPECCTRA_DB::doLIBRARY( LIBRARY* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -2735,7 +2735,7 @@ void SPECCTRA_DB::doLIBRARY( LIBRARY* growth ) throw( IOError ) } -void SPECCTRA_DB::doNET( NET* growth ) throw( IOError ) +void SPECCTRA_DB::doNET( NET* growth ) throw( IO_ERROR ) { DSN_T tok = nextTok(); PIN_REFS* pin_refs; @@ -2875,7 +2875,7 @@ L_pins: } -void SPECCTRA_DB::doTOPOLOGY( TOPOLOGY* growth ) throw( IOError ) +void SPECCTRA_DB::doTOPOLOGY( TOPOLOGY* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -2913,7 +2913,7 @@ void SPECCTRA_DB::doTOPOLOGY( TOPOLOGY* growth ) throw( IOError ) } -void SPECCTRA_DB::doCLASS( CLASS* growth ) throw( IOError ) +void SPECCTRA_DB::doCLASS( CLASS* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3023,7 +3023,7 @@ void SPECCTRA_DB::doCLASS( CLASS* growth ) throw( IOError ) } -void SPECCTRA_DB::doNETWORK( NETWORK* growth ) throw( IOError ) +void SPECCTRA_DB::doNETWORK( NETWORK* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3068,7 +3068,7 @@ void SPECCTRA_DB::doNETWORK( NETWORK* growth ) throw( IOError ) } -void SPECCTRA_DB::doCOMP_ORDER( COMP_ORDER* growth ) throw( IOError ) +void SPECCTRA_DB::doCOMP_ORDER( COMP_ORDER* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3086,7 +3086,7 @@ void SPECCTRA_DB::doCOMP_ORDER( COMP_ORDER* growth ) throw( IOError ) } -void SPECCTRA_DB::doFROMTO( FROMTO* growth ) throw( IOError ) +void SPECCTRA_DB::doFROMTO( FROMTO* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3172,7 +3172,7 @@ void SPECCTRA_DB::doFROMTO( FROMTO* growth ) throw( IOError ) } -void SPECCTRA_DB::doWIRE( WIRE* growth ) throw( IOError ) +void SPECCTRA_DB::doWIRE( WIRE* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3295,7 +3295,7 @@ void SPECCTRA_DB::doWIRE( WIRE* growth ) throw( IOError ) } -void SPECCTRA_DB::doWIRE_VIA( WIRE_VIA* growth ) throw( IOError ) +void SPECCTRA_DB::doWIRE_VIA( WIRE_VIA* growth ) throw( IO_ERROR ) { DSN_T tok; POINT point; @@ -3399,7 +3399,7 @@ void SPECCTRA_DB::doWIRE_VIA( WIRE_VIA* growth ) throw( IOError ) } -void SPECCTRA_DB::doWIRING( WIRING* growth ) throw( IOError ) +void SPECCTRA_DB::doWIRING( WIRING* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3455,7 +3455,7 @@ void SPECCTRA_DB::doWIRING( WIRING* growth ) throw( IOError ) } -void SPECCTRA_DB::doANCESTOR( ANCESTOR* growth ) throw( IOError ) +void SPECCTRA_DB::doANCESTOR( ANCESTOR* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3493,7 +3493,7 @@ void SPECCTRA_DB::doANCESTOR( ANCESTOR* growth ) throw( IOError ) } -void SPECCTRA_DB::doHISTORY( HISTORY* growth ) throw( IOError ) +void SPECCTRA_DB::doHISTORY( HISTORY* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3549,7 +3549,7 @@ void SPECCTRA_DB::doHISTORY( HISTORY* growth ) throw( IOError ) } -void SPECCTRA_DB::doSESSION( SESSION* growth ) throw( IOError ) +void SPECCTRA_DB::doSESSION( SESSION* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3626,7 +3626,7 @@ void SPECCTRA_DB::doSESSION( SESSION* growth ) throw( IOError ) } -void SPECCTRA_DB::doWAS_IS( WAS_IS* growth ) throw( IOError ) +void SPECCTRA_DB::doWAS_IS( WAS_IS* growth ) throw( IO_ERROR ) { DSN_T tok; PIN_PAIR empty( growth ); @@ -3667,7 +3667,7 @@ void SPECCTRA_DB::doWAS_IS( WAS_IS* growth ) throw( IOError ) } -void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IOError ) +void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3743,7 +3743,7 @@ void SPECCTRA_DB::doROUTE( ROUTE* growth ) throw( IOError ) } -void SPECCTRA_DB::doNET_OUT( NET_OUT* growth ) throw( IOError ) +void SPECCTRA_DB::doNET_OUT( NET_OUT* growth ) throw( IO_ERROR ) { DSN_T tok; @@ -3811,7 +3811,7 @@ void SPECCTRA_DB::doNET_OUT( NET_OUT* growth ) throw( IOError ) } -void SPECCTRA_DB::doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IOError ) +void SPECCTRA_DB::doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IO_ERROR ) { DSN_T tok; PIN_REF empty(growth); @@ -3847,7 +3847,7 @@ void SPECCTRA_DB::doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IOError ) } -void SPECCTRA_DB::ExportPCB( wxString filename, bool aNameChange ) throw( IOError ) +void SPECCTRA_DB::ExportPCB( wxString filename, bool aNameChange ) throw( IO_ERROR ) { if( pcb ) { @@ -3938,7 +3938,7 @@ UNIT_RES* ELEM::GetUnits() const } -void ELEM::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) +void ELEM::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s\n", Name() ); @@ -3948,7 +3948,7 @@ void ELEM::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) } -void ELEM_HOLDER::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) +void ELEM_HOLDER::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( int i=0; iPrint( nestLevel, "(string_quote %c)\n", string_quote ); out->Print( nestLevel, "(space_in_quoted_tokens %s)\n", space_in_quoted_tokens ? "on" : "off" ); @@ -4097,7 +4097,7 @@ void PARSER::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOErro } -void PLACE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) +void PLACE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { bool useMultiLine; diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h index b78246ac65..fa5a4470e9 100644 --- a/pcbnew/specctra.h +++ b/pcbnew/specctra.h @@ -554,9 +554,9 @@ struct POINT * SPECCTRA DSN format. * @param out The formatter to write to. * @param nestLevel A multiple of the number of spaces to preceed the output with. - * @throw IOError if a system error writing the output, such as a full disk. + * @throw IO_ERROR if a system error writing the output, such as a full disk. */ - void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ) { out->Print( nestLevel, " %.6g %.6g", x, y ); } @@ -576,9 +576,9 @@ struct PROPERTY * SPECCTRA DSN format. * @param out The formatter to write to. * @param nestLevel A multiple of the number of spaces to preceed the output with. - * @throw IOError if a system error writing the output, such as a full disk. + * @throw IO_ERROR if a system error writing the output, such as a full disk. */ - void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR ) { const char* quoteName = out->GetQuoteChar( name.c_str() ); const char* quoteValue = out->GetQuoteChar( value.c_str() ); @@ -654,9 +654,9 @@ public: * SPECCTRA DSN format. * @param out The formatter to write to. * @param nestLevel A multiple of the number of spaces to preceed the output with. - * @throw IOError if a system error writing the output, such as a full disk. + * @throw IO_ERROR if a system error writing the output, such as a full disk. */ - virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ); + virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); /** @@ -666,9 +666,9 @@ public: * wrapper is not included. * @param out The formatter to write to. * @param nestLevel A multiple of the number of spaces to preceed the output with. - * @throw IOError if a system error writing the output, such as a full disk. + * @throw IO_ERROR if a system error writing the output, such as a full disk. */ - virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { // overridden in ELEM_HOLDER } @@ -700,7 +700,7 @@ public: { } - virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ); + virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); //-----< list operations >-------------------------------------------- @@ -796,7 +796,7 @@ public: PARSER( ELEM* aParent ); - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ); + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); }; @@ -831,7 +831,7 @@ public: DSN_T GetEngUnits() const { return units; } int GetValue() const { return value; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( type == T_unit ) out->Print( nestLevel, "(%s %s)\n", Name(), @@ -874,7 +874,7 @@ public: point1.FixNegativeZero(); } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* newline = nestLevel ? "\n" : ""; @@ -907,7 +907,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s", Name() ); @@ -953,7 +953,7 @@ public: delete rule; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s", Name() ); @@ -1012,7 +1012,7 @@ public: aperture_width = aWidth; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* newline = nestLevel ? "\n" : ""; @@ -1071,7 +1071,7 @@ public: delete rectangle; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s\n", Name() ); @@ -1104,7 +1104,7 @@ public: diameter = 0.0; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* newline = nestLevel ? "\n" : ""; @@ -1151,7 +1151,7 @@ public: aperture_width = 0.0; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* newline = nestLevel ? "\n" : ""; @@ -1233,7 +1233,7 @@ public: } } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s ", Name() ); @@ -1316,7 +1316,7 @@ public: windows.push_back( aWindow ); } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* newline = "\n"; @@ -1393,7 +1393,7 @@ public: padstacks.push_back( aViaName ); } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const int RIGHTMARGIN = 80; int perLine = out->Print( nestLevel, "(%s", Name() ); @@ -1447,7 +1447,7 @@ public: { } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( STRINGS::iterator i=class_ids.begin(); i!=class_ids.end(); ++i ) { @@ -1485,7 +1485,7 @@ public: delete classes; } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( classes ) classes->Format( out, nestLevel ); @@ -1515,7 +1515,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s\n", Name() ); @@ -1570,7 +1570,7 @@ public: delete rules; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( name.c_str() ); @@ -1644,7 +1644,7 @@ public: layer_weight = 0.0; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote0 = out->GetQuoteChar( layer_id0.c_str() ); const char* quote1 = out->GetQuoteChar( layer_id1.c_str() ); @@ -1671,7 +1671,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s\n", Name() ); @@ -1717,7 +1717,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( value ) ); @@ -1743,7 +1743,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( value.c_str() ); @@ -1786,7 +1786,7 @@ public: delete rules; } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( region_id.size() ) { @@ -1834,7 +1834,7 @@ public: image_type= T_NONE; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s %s %.6g", Name(), @@ -1878,7 +1878,7 @@ public: delete rules; } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( LAYERS::iterator i=layers.begin(); i!=layers.end(); ++i ) i->Format( out, nestLevel ); @@ -1962,7 +1962,7 @@ public: place_boundary->SetParent( this ); } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( unit ) unit->Format( out, nestLevel ); @@ -2094,7 +2094,7 @@ public: rotation = aRotation; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ); + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); }; typedef boost::ptr_vector PLACES; @@ -2131,7 +2131,7 @@ public: */ // static int Compare( IMAGE* lhs, IMAGE* rhs ); - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( image_id.c_str() ); out->Print( nestLevel, "(%s %s%s%s\n", Name(), @@ -2142,7 +2142,7 @@ public: out->Print( nestLevel, ")\n" ); } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( PLACES::iterator i=places.begin(); i!=places.end(); ++i ) i->Format( out, nestLevel ); @@ -2195,7 +2195,7 @@ public: return added; } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( unit ) unit->Format( out, nestLevel ); @@ -2261,7 +2261,7 @@ public: connect = aConnect; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s ", Name() ); @@ -2320,7 +2320,7 @@ public: vertex.FixNegativeZero(); } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( padstack_id.c_str() ); if( isRotated ) @@ -2405,7 +2405,7 @@ public: return image_id; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { std::string imageId = GetImageId(); @@ -2420,7 +2420,7 @@ public: } // this is here for makeHash() - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( side != T_both ) out->Print( 0, " (side %s)", GetTokenText( side ) ); @@ -2520,7 +2520,7 @@ public: padstack_id = aPadstackId; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( padstack_id.c_str() ); @@ -2534,7 +2534,7 @@ public: // this factored out for use by Compare() - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( unit ) unit->Format( out, nestLevel ); @@ -2763,7 +2763,7 @@ public: return NULL; } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( unit ) unit->Format( out, nestLevel ); @@ -2808,7 +2808,7 @@ struct PIN_REF : public ELEM * is like Format() but is not virual and returns the number of characters * that were output. */ - int FormatIt( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + int FormatIt( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { // only print the newline if there is a nest level, and make // the quotes unconditional on this one. @@ -2852,7 +2852,7 @@ public: delete rules; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { // no quoting on these two, the lexer preserved the quotes on input out->Print( nestLevel, "(%s %s %s ", @@ -2910,7 +2910,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s", Name() ); @@ -2993,7 +2993,7 @@ public: return -1; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( net_id.c_str() ); const char* space = " "; @@ -3070,7 +3070,7 @@ public: { } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( FROMTOS::iterator i=fromtos.begin(); i!=fromtos.end(); ++i ) i->Format( out, nestLevel ); @@ -3117,7 +3117,7 @@ public: } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( class_id.c_str() ); @@ -3186,7 +3186,7 @@ public: { } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( NETS::iterator i=nets.begin(); i!=nets.end(); ++i ) i->Format( out, nestLevel ); @@ -3267,7 +3267,7 @@ public: } } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { out->Print( nestLevel, "(%s ", Name() ); @@ -3351,7 +3351,7 @@ public: return padstack_id; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( padstack_id.c_str() ); @@ -3477,7 +3477,7 @@ public: delete unit; } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( unit ) unit->Format( out, nestLevel ); @@ -3540,7 +3540,7 @@ public: delete wiring; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( pcbname.c_str() ); @@ -3603,7 +3603,7 @@ public: time_stamp = time(NULL); } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { char temp[80]; struct tm* tmp; @@ -3647,7 +3647,7 @@ public: time_stamp = time(NULL); } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( ANCESTORS::iterator i=ancestors.begin(); i!=ancestors.end(); ++i ) i->Format( out, nestLevel ); @@ -3690,7 +3690,7 @@ public: { } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { bool singleLine = pin_refs.size() <= 1; out->Print( nestLevel, "(%s", Name() ); @@ -3749,7 +3749,7 @@ public: delete rules; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( net_id.c_str() ); @@ -3816,7 +3816,7 @@ public: return ELEM::GetUnits(); } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { if( resolution ) resolution->Format( out, nestLevel ); @@ -3879,7 +3879,7 @@ public: { } - void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { for( PIN_PAIRS::iterator i=pin_pairs.begin(); i!=pin_pairs.end(); ++i ) { @@ -3936,7 +3936,7 @@ public: delete route; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) + void Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ) { const char* quote = out->GetQuoteChar( session_id.c_str() ); out->Print( nestLevel, "(%s %s%s%s\n", Name(), @@ -4048,10 +4048,10 @@ class SPECCTRA_DB /** * Function needLEFT * calls nextTok() and then verifies that the token read in is a T_LEFT. - * If it is not, an IOError is thrown. - * @throw IOError, if the next token is not a T_LEFT + * If it is not, an IO_ERROR is thrown. + * @throw IO_ERROR, if the next token is not a T_LEFT */ - void needLEFT() throw( IOError ) + void needLEFT() throw( IO_ERROR ) { lexer->NeedLEFT(); } @@ -4059,10 +4059,10 @@ class SPECCTRA_DB /** * Function needRIGHT * calls nextTok() and then verifies that the token read in is a T_RIGHT. - * If it is not, an IOError is thrown. - * @throw IOError, if the next token is not a T_RIGHT + * If it is not, an IO_ERROR is thrown. + * @throw IO_ERROR, if the next token is not a T_RIGHT */ - void needRIGHT() throw( IOError ) + void needRIGHT() throw( IO_ERROR ) { lexer->NeedRIGHT(); } @@ -4071,11 +4071,11 @@ class SPECCTRA_DB * Function needSYMBOL * calls nextTok() and then verifies that the token read in * satisfies bool isSymbol(). - * If not, an IOError is thrown. + * If not, an IO_ERROR is thrown. * @return DSN_T - the actual token read in. - * @throw IOError, if the next token does not satisfy isSymbol() + * @throw IO_ERROR, if the next token does not satisfy isSymbol() */ - DSN_T needSYMBOL() throw( IOError ) + DSN_T needSYMBOL() throw( IO_ERROR ) { return (DSN_T) lexer->NeedSYMBOL(); } @@ -4084,11 +4084,11 @@ class SPECCTRA_DB * Function needSYMBOLorNUMBER * calls nextTok() and then verifies that the token read in * satisfies bool isSymbol() or tok==T_NUMBER. - * If not, an IOError is thrown. + * If not, an IO_ERROR is thrown. * @return DSN_T - the actual token read in. - * @throw IOError, if the next token does not satisfy the above test + * @throw IO_ERROR, if the next token does not satisfy the above test */ - DSN_T needSYMBOLorNUMBER() throw( IOError ) + DSN_T needSYMBOLorNUMBER() throw( IO_ERROR ) { return (DSN_T) lexer->NeedSYMBOLorNUMBER(); } @@ -4106,10 +4106,10 @@ class SPECCTRA_DB * * @param component_id Where to put the text preceeding the '-' hyphen. * @param pin_d Where to put the text which trails the '-'. - * @throw IOError, if the next token or two do no make up a pin_reference, + * @throw IO_ERROR, if the next token or two do no make up a pin_reference, * or there is an error reading from the input stream. */ - void readCOMPnPIN( std::string* component_id, std::string* pid_id ) throw( IOError ); + void readCOMPnPIN( std::string* component_id, std::string* pid_id ) throw( IO_ERROR ); /** @@ -4123,80 +4123,80 @@ class SPECCTRA_DB * time stamp. * * @param time_stamp Where to put the parsed time value. - * @throw IOError, if the next token or 8 do no make up a time stamp, + * @throw IO_ERROR, if the next token or 8 do no make up a time stamp, * or there is an error reading from the input stream. */ - void readTIME( time_t* time_stamp ) throw( IOError ); + void readTIME( time_t* time_stamp ) throw( IO_ERROR ); /** * Function expecting - * throws an IOError exception with an input file specific error message. + * throws an IO_ERROR exception with an input file specific error message. * @param int is the token type which was expected at the current input location. - * @throw IOError with the location within the input file of the problem. + * @throw IO_ERROR with the location within the input file of the problem. */ - void expecting( DSN_T aTok ) throw( IOError ) + void expecting( DSN_T aTok ) throw( IO_ERROR ) { lexer->Expecting( aTok ); } - void unexpected( DSN_T aTok ) throw( IOError ) + void unexpected( DSN_T aTok ) throw( IO_ERROR ) { lexer->Unexpected( aTok ); } - void expecting( const char* text ) throw( IOError ); - void unexpected( const char* text ) throw( IOError ); + void expecting( const char* text ) throw( IO_ERROR ); + void unexpected( const char* text ) throw( IO_ERROR ); - void doPCB( PCB* growth ) throw(IOError); - void doPARSER( PARSER* growth ) throw(IOError); - void doRESOLUTION( UNIT_RES* growth ) throw(IOError); - void doUNIT( UNIT_RES* growth ) throw( IOError ); - void doSTRUCTURE( STRUCTURE* growth ) throw( IOError ); - void doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IOError ); - void doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IOError ); - void doLAYER_PAIR( LAYER_PAIR* growth ) throw( IOError ); - void doBOUNDARY( BOUNDARY* growth ) throw( IOError ); - void doRECTANGLE( RECTANGLE* growth ) throw( IOError ); - void doPATH( PATH* growth ) throw( IOError ); - void doSTRINGPROP( STRINGPROP* growth ) throw( IOError ); - void doTOKPROP( TOKPROP* growth ) throw( IOError ); - void doVIA( VIA* growth ) throw( IOError ); - void doCONTROL( CONTROL* growth ) throw( IOError ); - void doLAYER( LAYER* growth ) throw( IOError ); - void doRULE( RULE* growth ) throw( IOError ); - void doKEEPOUT( KEEPOUT* growth ) throw( IOError ); - void doCIRCLE( CIRCLE* growth ) throw( IOError ); - void doQARC( QARC* growth ) throw( IOError ); - void doWINDOW( WINDOW* growth ) throw( IOError ); - void doREGION( REGION* growth ) throw( IOError ); - void doCLASS_CLASS( CLASS_CLASS* growth ) throw( IOError ); - void doLAYER_RULE( LAYER_RULE* growth ) throw( IOError ); - void doCLASSES( CLASSES* growth ) throw( IOError ); - void doGRID( GRID* growth ) throw( IOError ); - void doPLACE( PLACE* growth ) throw( IOError ); - void doCOMPONENT( COMPONENT* growth ) throw( IOError ); - void doPLACEMENT( PLACEMENT* growth ) throw( IOError ); - void doPROPERTIES( PROPERTIES* growth ) throw( IOError ); - void doPADSTACK( PADSTACK* growth ) throw( IOError ); - void doSHAPE( SHAPE* growth ) throw( IOError ); - void doIMAGE( IMAGE* growth ) throw( IOError ); - void doLIBRARY( LIBRARY* growth ) throw( IOError ); - void doPIN( PIN* growth ) throw( IOError ); - void doNET( NET* growth ) throw( IOError ); - void doNETWORK( NETWORK* growth ) throw( IOError ); - void doCLASS( CLASS* growth ) throw( IOError ); - void doTOPOLOGY( TOPOLOGY* growth ) throw( IOError ); - void doFROMTO( FROMTO* growth ) throw( IOError ); - void doCOMP_ORDER( COMP_ORDER* growth ) throw( IOError ); - void doWIRE( WIRE* growth ) throw( IOError ); - void doWIRE_VIA( WIRE_VIA* growth ) throw( IOError ); - void doWIRING( WIRING* growth ) throw( IOError ); - void doSESSION( SESSION* growth ) throw( IOError ); - void doANCESTOR( ANCESTOR* growth ) throw( IOError ); - void doHISTORY( HISTORY* growth ) throw( IOError ); - void doROUTE( ROUTE* growth ) throw( IOError ); - void doWAS_IS( WAS_IS* growth ) throw( IOError ); - void doNET_OUT( NET_OUT* growth ) throw( IOError ); - void doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IOError ); + void doPCB( PCB* growth ) throw( IO_ERROR ); + void doPARSER( PARSER* growth ) throw( IO_ERROR ); + void doRESOLUTION( UNIT_RES* growth ) throw( IO_ERROR ); + void doUNIT( UNIT_RES* growth ) throw( IO_ERROR ); + void doSTRUCTURE( STRUCTURE* growth ) throw( IO_ERROR ); + void doSTRUCTURE_OUT( STRUCTURE_OUT* growth ) throw( IO_ERROR ); + void doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth ) throw( IO_ERROR ); + void doLAYER_PAIR( LAYER_PAIR* growth ) throw( IO_ERROR ); + void doBOUNDARY( BOUNDARY* growth ) throw( IO_ERROR ); + void doRECTANGLE( RECTANGLE* growth ) throw( IO_ERROR ); + void doPATH( PATH* growth ) throw( IO_ERROR ); + void doSTRINGPROP( STRINGPROP* growth ) throw( IO_ERROR ); + void doTOKPROP( TOKPROP* growth ) throw( IO_ERROR ); + void doVIA( VIA* growth ) throw( IO_ERROR ); + void doCONTROL( CONTROL* growth ) throw( IO_ERROR ); + void doLAYER( LAYER* growth ) throw( IO_ERROR ); + void doRULE( RULE* growth ) throw( IO_ERROR ); + void doKEEPOUT( KEEPOUT* growth ) throw( IO_ERROR ); + void doCIRCLE( CIRCLE* growth ) throw( IO_ERROR ); + void doQARC( QARC* growth ) throw( IO_ERROR ); + void doWINDOW( WINDOW* growth ) throw( IO_ERROR ); + void doREGION( REGION* growth ) throw( IO_ERROR ); + void doCLASS_CLASS( CLASS_CLASS* growth ) throw( IO_ERROR ); + void doLAYER_RULE( LAYER_RULE* growth ) throw( IO_ERROR ); + void doCLASSES( CLASSES* growth ) throw( IO_ERROR ); + void doGRID( GRID* growth ) throw( IO_ERROR ); + void doPLACE( PLACE* growth ) throw( IO_ERROR ); + void doCOMPONENT( COMPONENT* growth ) throw( IO_ERROR ); + void doPLACEMENT( PLACEMENT* growth ) throw( IO_ERROR ); + void doPROPERTIES( PROPERTIES* growth ) throw( IO_ERROR ); + void doPADSTACK( PADSTACK* growth ) throw( IO_ERROR ); + void doSHAPE( SHAPE* growth ) throw( IO_ERROR ); + void doIMAGE( IMAGE* growth ) throw( IO_ERROR ); + void doLIBRARY( LIBRARY* growth ) throw( IO_ERROR ); + void doPIN( PIN* growth ) throw( IO_ERROR ); + void doNET( NET* growth ) throw( IO_ERROR ); + void doNETWORK( NETWORK* growth ) throw( IO_ERROR ); + void doCLASS( CLASS* growth ) throw( IO_ERROR ); + void doTOPOLOGY( TOPOLOGY* growth ) throw( IO_ERROR ); + void doFROMTO( FROMTO* growth ) throw( IO_ERROR ); + void doCOMP_ORDER( COMP_ORDER* growth ) throw( IO_ERROR ); + void doWIRE( WIRE* growth ) throw( IO_ERROR ); + void doWIRE_VIA( WIRE_VIA* growth ) throw( IO_ERROR ); + void doWIRING( WIRING* growth ) throw( IO_ERROR ); + void doSESSION( SESSION* growth ) throw( IO_ERROR ); + void doANCESTOR( ANCESTOR* growth ) throw( IO_ERROR ); + void doHISTORY( HISTORY* growth ) throw( IO_ERROR ); + void doROUTE( ROUTE* growth ) throw( IO_ERROR ); + void doWAS_IS( WAS_IS* growth ) throw( IO_ERROR ); + void doNET_OUT( NET_OUT* growth ) throw( IO_ERROR ); + void doSUPPLY_PIN( SUPPLY_PIN* growth ) throw( IO_ERROR ); //------------------------------------------------------------ @@ -4206,7 +4206,7 @@ class SPECCTRA_DB * @param aBoard The BOARD to get information from in order to make the BOUNDARY. * @param aBoundary The empty BOUNDARY to fill in. */ - void fillBOUNDARY( BOARD* aBoard, BOUNDARY* aBoundary ) throw( IOError ); + void fillBOUNDARY( BOARD* aBoard, BOUNDARY* aBoundary ) throw( IO_ERROR ); /** @@ -4280,7 +4280,7 @@ class SPECCTRA_DB * Function makeTRACK * creates a TRACK form the PATH and BOARD info. */ - TRACK* makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IOError ); + TRACK* makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IO_ERROR ); /** @@ -4288,7 +4288,7 @@ class SPECCTRA_DB * instantiates a Kicad SEGVIA on the heap and initializes it with internal * values consistent with the given PADSTACK, POINT, and netcode. */ - SEGVIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IOError ); + SEGVIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IO_ERROR ); //--------------------------------------------------------- @@ -4357,9 +4357,9 @@ public: * missing only the silkscreen stuff). * * @param filename The name of the dsn file to load. - * @throw IOError if there is a lexer or parser error. + * @throw IO_ERROR if there is a lexer or parser error. */ - void LoadPCB( const wxString& filename ) throw( IOError ); + void LoadPCB( const wxString& filename ) throw( IO_ERROR ); /** @@ -4370,12 +4370,12 @@ public: * tracks, vias, and component locations. * * @param filename The name of the dsn file to load. - * @throw IOError if there is a lexer or parser error. + * @throw IO_ERROR if there is a lexer or parser error. */ - void LoadSESSION( const wxString& filename ) throw( IOError ); + void LoadSESSION( const wxString& filename ) throw( IO_ERROR ); - void ThrowIOError( const wxChar* fmt, ... ) throw( IOError ); + void ThrowIOError( const wxChar* fmt, ... ) throw( IO_ERROR ); /** @@ -4385,9 +4385,9 @@ public: * @param aFilename The file to save to. * @param aNameChange If true, causes the pcb's name to change to "aFilename" * and also to to be changed in the output file. - * @throw IOError, if an i/o error occurs saving the file. + * @throw IO_ERROR, if an i/o error occurs saving the file. */ - void ExportPCB( wxString aFilename, bool aNameChange=false ) throw( IOError ); + void ExportPCB( wxString aFilename, bool aNameChange=false ) throw( IO_ERROR ); /** @@ -4401,7 +4401,7 @@ public: * * @param aBoard The BOARD to convert to a PCB. */ - void FromBOARD( BOARD* aBoard ) throw( IOError ); + void FromBOARD( BOARD* aBoard ) throw( IO_ERROR ); /** * Function FromSESSION @@ -4411,7 +4411,7 @@ public: * * @param aBoard The BOARD to merge the SESSION information into. */ - void FromSESSION( BOARD* aBoard ) throw( IOError ); + void FromSESSION( BOARD* aBoard ) throw( IO_ERROR ); /** * Function ExportSESSION diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 6d2edfebe4..3ee8c92b02 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -112,7 +112,7 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event ) // if an exception is thrown by FromBOARD or ExportPCB(), then // ~SPECCTRA_DB() will close the file. } - catch( IOError ioe ) + catch( IO_ERROR ioe ) { ok = false; @@ -719,7 +719,7 @@ PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia ) } -void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IOError ) +void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ERROR ) { TYPE_COLLECTOR items; @@ -905,7 +905,7 @@ typedef std::set STRINGSET; typedef std::pair STRINGSET_PAIR; -void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError ) +void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR ) { TYPE_COLLECTOR items; diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index a5e84a9c61..be4fab2d79 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -96,7 +96,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event ) db.LoadSESSION( fullFileName ); db.FromSESSION( GetBoard() ); } - catch( IOError ioe ) + catch( IO_ERROR ioe ) { SetLocaleTo_Default( ); // revert to the current locale @@ -193,7 +193,7 @@ static wxPoint mapPt( const POINT& aPoint, UNIT_RES* aResolution ) } -TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IOError ) +TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IO_ERROR ) { int layerNdx = findLayerName( aPath->layer_id ); @@ -216,7 +216,7 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro } -SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IOError ) +SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode ) throw( IO_ERROR ) { SEGVIA* via = 0; SHAPE* shape; @@ -351,7 +351,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet // no UI code in this function, throw exception to report problems to the // UI handler: void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event ) -void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) +void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR ) { sessionBoard = aBoard; // not owned here diff --git a/pcbnew/specctra_test.cpp b/pcbnew/specctra_test.cpp index 21fa18b072..15d73af0c4 100644 --- a/pcbnew/specctra_test.cpp +++ b/pcbnew/specctra_test.cpp @@ -63,7 +63,7 @@ int main( int argc, char** argv ) // db.LoadPCB( filename ); db.LoadSESSION( filename ); } - catch( IOError ioe ) + catch( IO_ERROR ioe ) { fprintf( stderr, "%s\n", CONV_TO_UTF8(ioe.errorText) ); failed = true; diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 69cd7e3bfd..f4d3e3a58b 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -27,6 +27,7 @@ #include "hotkeys.h" #include "help_common_strings.h" +#include "class_layerchoicebox.h" #define SEL_LAYER_HELP _( \ "Show active layer selections\nand select layer pair for route and place via" ) @@ -267,7 +268,12 @@ void WinEDA_PcbFrame::ReCreateHToolbar() m_HToolBar->AddSeparator(); + if(m_SelLayerBox == NULL) + m_SelLayerBox = new WinEDALayerChoiceBox( m_HToolBar, ID_TOOLBARH_PCB_SELECT_LAYER); + ReCreateLayerBox( m_HToolBar ); + m_HToolBar->AddControl( m_SelLayerBox ); + PrepareLayerIndicator(); // Initialize the bitmap with current // active layer colors for the next tool m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString, @@ -434,7 +440,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar() m_VToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, wxBitmap( add_zone_xpm ), - _( "Add zones" ), wxITEM_CHECK ); + _( "Add filled zones" ), wxITEM_CHECK ); m_VToolBar->AddSeparator(); m_VToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, @@ -451,7 +457,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar() m_VToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, wxBitmap( add_text_xpm ), - _( "Add text" ), wxITEM_CHECK ); + _( "Add text on copper layers or graphic text" ), wxITEM_CHECK ); m_VToolBar->AddSeparator(); m_VToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, @@ -470,7 +476,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar() m_VToolBar->AddSeparator(); m_VToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString, wxBitmap( pcb_offset_xpm ), - _( "Offset adjust for drill and place files" ), + _( "Place the origin point for drill and place files" ), wxITEM_CHECK ); m_VToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString, @@ -677,7 +683,6 @@ an existing track use its width\notherwise, use current width setting" ), m_TrackAndViasSizesList_Changed = true; m_AuxiliaryToolBar->AddSeparator(); - ReCreateLayerBox( NULL ); } @@ -685,97 +690,18 @@ void WinEDA_PcbFrame::syncLayerBox() { wxASSERT( m_SelLayerBox ); - // Enable the display on the correct layer - // To avoid reentrancy ( Bug wxGTK Linux version? ), the selection is - // made only if it needs changing ( corrected on wxGTK 2.6.0 ) - int count = m_SelLayerBox->GetCount(); - int choice = m_SelLayerBox->GetChoice(); int layer = getActiveLayer(); - - for( int listNdx=0; listNdxwxItemContainer::GetClientData( listNdx ); - - if( clientData == layer ) - { - if( listNdx != choice ) - m_SelLayerBox->SetSelection( listNdx ); - break; - } - } + m_SelLayerBox->SetLayerSelection(layer); } -WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) +WinEDALayerChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) { if( m_SelLayerBox == NULL ) - { - if( parent == NULL ) - return NULL; - - m_SelLayerBox = new WinEDAChoiceBox( parent, - ID_TOOLBARH_PCB_SELECT_LAYER, - wxPoint( -1, -1 ), -#if defined (__UNIX__) - - // Width enough for the longest - // string: "Component (Page Down)" - // Maybe that string is too long? - wxSize( 230, -1 ) -#else - wxSize( LISTBOX_WIDTH + 30, -1 ) -#endif - ); - - parent->AddControl( m_SelLayerBox ); - } - int layer_mask = GetBoard()->GetEnabledLayers(); - unsigned length = 0; - - m_SelLayerBox->Clear(); - - static DECLARE_LAYERS_ORDER_LIST(layerOrder_for_display); - - for( int idx=0, listNdx=0; idx <= EDGE_N; idx++ ) - { - int layer = layerOrder_for_display[idx]; - // List to append hotkeys in layer box selection - static const int HK_SwitchLayer[EDGE_N + 1] = { - HK_SWITCH_LAYER_TO_COPPER, - HK_SWITCH_LAYER_TO_INNER1, - HK_SWITCH_LAYER_TO_INNER2, - HK_SWITCH_LAYER_TO_INNER3, - HK_SWITCH_LAYER_TO_INNER4, - HK_SWITCH_LAYER_TO_INNER5, - HK_SWITCH_LAYER_TO_INNER6, - HK_SWITCH_LAYER_TO_INNER7, - HK_SWITCH_LAYER_TO_INNER8, - HK_SWITCH_LAYER_TO_INNER9, - HK_SWITCH_LAYER_TO_INNER10, - HK_SWITCH_LAYER_TO_INNER11, - HK_SWITCH_LAYER_TO_INNER12, - HK_SWITCH_LAYER_TO_INNER13, - HK_SWITCH_LAYER_TO_INNER14, - HK_SWITCH_LAYER_TO_COMPONENT - }; - - if( g_TabOneLayerMask[layer] & layer_mask ) - { - wxString msg = GetBoard()->GetLayerName( layer ); - msg << wxT(" "); - msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, - HK_SwitchLayer[layer], false ); - - m_SelLayerBox->Append( msg ); - - //D(printf("appending layername=%s, ndx=%d, layer=%d\n", CONV_TO_UTF8(msg), listNdx, layer );) - - m_SelLayerBox->wxItemContainer::SetClientData( listNdx, (void*) layer ); - length = MAX( length, msg.Len() ); - listNdx++; - } - } + return NULL; + m_SelLayerBox->m_hotkeys = s_Board_Editor_Hokeys_Descr; + m_SelLayerBox->Resync(); m_SelLayerBox->SetToolTip( _( "+/- to switch" ) ); syncLayerBox(); diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index 6f1bdfed36..e0cd18a502 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -184,7 +184,9 @@ void WinEDA_PcbFrame::SetToolbars() state = GetScreen()->GetRedoCommandCount() > 0; m_HToolBar->EnableTool( wxID_REDO, state ); - m_HToolBar->Refresh(); + syncLayerBox(); + PrepareLayerIndicator(); + m_HToolBar->Refresh(true); if( m_OptionsToolBar ) { @@ -276,9 +278,5 @@ void WinEDA_PcbFrame::SetToolbars() if( m_AuxiliaryToolBar ) AuxiliaryToolBar_Update_UI(); - - syncLayerBox(); - - PrepareLayerIndicator(); DisplayUnitsMsg(); } diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 35549bb968..e73c7b89bd 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -55,9 +55,12 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) } #ifdef USE_WX_OVERLAY - DrawPanel->m_overlay.Reset(); - wxDCOverlay overlaydc( DrawPanel->m_overlay, DC ); - overlaydc.Clear(); + if(IsShown()) + { + DrawPanel->m_overlay.Reset(); + wxDCOverlay overlaydc( DrawPanel->m_overlay, DC ); + overlaydc.Clear(); + } #endif screen->ClrRefreshReq(); @@ -91,9 +94,12 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) DrawGeneralRatsnest( DC ); #ifdef USE_WX_OVERLAY - DrawPanel->m_overlay.Reset(); - wxDCOverlay overlaydc( DrawPanel->m_overlay, DC ); - overlaydc.Clear(); + if(IsShown()) + { + DrawPanel->m_overlay.Reset(); + wxDCOverlay overlaydc( DrawPanel->m_overlay, DC ); + overlaydc.Clear(); + } #endif GetScreen()->ClrRefreshReq();