From 4da0bfc20b4e87eea8b508a92eb7b5967bbee53a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 2 Sep 2011 21:43:56 +0200 Subject: [PATCH 1/9] Eeschema: bitmap editor dialog: some enhancements --- common/class_bitmap_base.cpp | 4 +- common/dialogs/dialog_image_editor.cpp | 85 +++++- common/dialogs/dialog_image_editor.fbp | 272 +++++++++++++++++++- common/dialogs/dialog_image_editor.h | 8 +- common/dialogs/dialog_image_editor_base.cpp | 22 +- common/dialogs/dialog_image_editor_base.h | 8 +- include/class_bitmap_base.h | 20 ++ 7 files changed, 405 insertions(+), 14 deletions(-) diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp index ed85fa252a..c645b40705 100644 --- a/common/class_bitmap_base.cpp +++ b/common/class_bitmap_base.cpp @@ -236,7 +236,7 @@ void BITMAP_BASE::Mirror( bool aVertically ) if( m_image ) { *m_image = m_image->Mirror( not aVertically ); - *m_bitmap = wxBitmap( *m_image ); + RebuildBitmap(); } } @@ -246,7 +246,7 @@ void BITMAP_BASE::Rotate( bool aRotateCCW ) if( m_image ) { *m_image = m_image->Rotate90( aRotateCCW ); - *m_bitmap = wxBitmap( *m_image ); + RebuildBitmap(); } } diff --git a/common/dialogs/dialog_image_editor.cpp b/common/dialogs/dialog_image_editor.cpp index 78738fa97e..48b81ec3f2 100644 --- a/common/dialogs/dialog_image_editor.cpp +++ b/common/dialogs/dialog_image_editor.cpp @@ -40,6 +40,8 @@ DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem : DIALOG_IMAGE_EDITOR_BASE( aParent ) { m_workingImage = new BITMAP_BASE( * aItem ); + m_lastImage = NULL; + m_buttonUndoLast->Enable( false ); wxString msg; msg.Printf( wxT("%f"), m_workingImage->m_Scale ); m_textCtrlScale->SetValue( msg );; @@ -53,28 +55,106 @@ DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem SetFocus(); } +void DIALOG_IMAGE_EDITOR::OnUndoLastChange( wxCommandEvent& event ) +{ + BITMAP_BASE * tmp = m_workingImage; + m_workingImage = m_lastImage; + delete tmp; + m_buttonUndoLast->Enable( false ); + m_lastImage = NULL; + m_panelDraw->Refresh(); +} + void DIALOG_IMAGE_EDITOR::OnMirrorX_click( wxCommandEvent& event ) { - + delete m_lastImage; + m_lastImage = new BITMAP_BASE( * m_workingImage ); + m_buttonUndoLast->Enable( true ); + m_buttonUndoLast->Enable( true ); m_workingImage->Mirror( true ); m_panelDraw->Refresh(); } void DIALOG_IMAGE_EDITOR::OnMirrorY_click( wxCommandEvent& event ) { + delete m_lastImage; + m_lastImage = new BITMAP_BASE( * m_workingImage ); + m_buttonUndoLast->Enable( true ); m_workingImage->Mirror( false ); m_panelDraw->Refresh(); } void DIALOG_IMAGE_EDITOR::OnRotateClick( wxCommandEvent& event ) { + delete m_lastImage; + m_lastImage = new BITMAP_BASE( * m_workingImage ); + m_buttonUndoLast->Enable( true ); m_workingImage->Rotate( false ); m_panelDraw->Refresh(); } +void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event ) +{ + delete m_lastImage; + m_lastImage = new BITMAP_BASE( * m_workingImage ); + m_buttonUndoLast->Enable( true ); + wxImage& image = *m_workingImage->GetImageData(); + image = image.ConvertToGreyscale(); + m_workingImage->RebuildBitmap(); + m_panelDraw->Refresh(); +} + +void DIALOG_IMAGE_EDITOR::OnHalfSize( wxCommandEvent& event ) +{ + delete m_lastImage; + m_lastImage = new BITMAP_BASE( * m_workingImage ); + m_buttonUndoLast->Enable( true ); + wxSize psize = m_workingImage->GetSizePixels(); + wxImage& image = *m_workingImage->GetImageData(); + + image = image.Scale(psize.x/2, psize.y/2, wxIMAGE_QUALITY_HIGH); + m_workingImage->RebuildBitmap(); + m_panelDraw->Refresh(); +} + +/* Test params values correctness + * Currently scale value must give an actual image + * > MIN_SIZE pixels and < MAX_SIZE pixels + */ +bool DIALOG_IMAGE_EDITOR::CheckValues() +{ + #define MIN_SIZE 16 + #define MAX_SIZE 6000 + double tmp; + wxString msg = m_textCtrlScale->GetValue(); + // Test number correctness + if( ! msg.ToDouble( &tmp ) ) + { + wxMessageBox( _("Incorrect scale number" ) ); + return false; + } + + // Test value correctness + wxSize psize = m_workingImage->GetSizePixels(); + if ( (psize.x * tmp) < MIN_SIZE || (psize.y * tmp) < MIN_SIZE ) + { + wxMessageBox( _("Scale is too small for this image" ) ); + return false; + } + if ( (psize.x * tmp) > MAX_SIZE || (psize.y * tmp) > MAX_SIZE ) + { + wxMessageBox( _("Scale is too large for this image" ) ); + return false; + } + + return true; +} + void DIALOG_IMAGE_EDITOR::OnOK_Button( wxCommandEvent& aEvent ) { - EndModal( wxID_OK ); + if( CheckValues() ) + EndModal( wxID_OK ); + return; } void DIALOG_IMAGE_EDITOR::OnCancel_Button( wxCommandEvent& aEvent ) @@ -97,7 +177,6 @@ void DIALOG_IMAGE_EDITOR::TransfertToImage(BITMAP_BASE* aItem ) { wxString msg = m_textCtrlScale->GetValue(); msg.ToDouble( &m_workingImage->m_Scale ); - m_textCtrlScale->SetValue( msg ); aItem->ImportData( m_workingImage ); } diff --git a/common/dialogs/dialog_image_editor.fbp b/common/dialogs/dialog_image_editor.fbp index 7be9af1293..27ec5a178e 100644 --- a/common/dialogs/dialog_image_editor.fbp +++ b/common/dialogs/dialog_image_editor.fbp @@ -69,7 +69,7 @@ Resizable 1 - 340,256 + 340,299 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Image Editor @@ -236,7 +236,7 @@ none 5 - wxEXPAND|wxALL + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -324,7 +324,7 @@ 5 - wxEXPAND|wxALL + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -412,7 +412,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxALL 0 1 @@ -498,6 +498,270 @@ + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Grey + + + 0 + + + 0 + + 1 + m_buttonGrey + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnGreyScaleConvert + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Half Size + + + 0 + + + 0 + + 1 + m_buttonHalfSize + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnHalfSize + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Undo Last + + + 0 + + + 0 + + 1 + m_buttonUndoLast + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnUndoLastChange + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxTOP|wxRIGHT|wxLEFT diff --git a/common/dialogs/dialog_image_editor.h b/common/dialogs/dialog_image_editor.h index 64592cca5e..874622f357 100644 --- a/common/dialogs/dialog_image_editor.h +++ b/common/dialogs/dialog_image_editor.h @@ -35,7 +35,9 @@ class DIALOG_IMAGE_EDITOR : public DIALOG_IMAGE_EDITOR_BASE { private: - BITMAP_BASE* m_workingImage; + BITMAP_BASE* m_workingImage; // The copy of BITMAP_BASE to be edited + BITMAP_BASE* m_lastImage; // the saved BITMAP_BASE before a new change. + // Used to undo the last change public: DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem ); @@ -51,12 +53,16 @@ public: void TransfertToImage( BITMAP_BASE* aItem ); private: + void OnUndoLastChange( wxCommandEvent& event ); + void OnGreyScaleConvert( wxCommandEvent& event ); + void OnHalfSize( wxCommandEvent& event ); void OnMirrorX_click( wxCommandEvent& event ); void OnMirrorY_click( wxCommandEvent& event ); void OnRotateClick( wxCommandEvent& event ); void OnOK_Button( wxCommandEvent& aEvent ); void OnCancel_Button( wxCommandEvent& aEvent ); void OnRedrawPanel( wxPaintEvent& event ); + bool CheckValues(); }; diff --git a/common/dialogs/dialog_image_editor_base.cpp b/common/dialogs/dialog_image_editor_base.cpp index 7b05b29e44..613343fe4b 100644 --- a/common/dialogs/dialog_image_editor_base.cpp +++ b/common/dialogs/dialog_image_editor_base.cpp @@ -31,13 +31,23 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID bSizerRight = new wxBoxSizer( wxVERTICAL ); m_buttonMirrorX = new wxButton( this, wxID_ANY, _("Mirror X"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerRight->Add( m_buttonMirrorX, 0, wxEXPAND|wxALL, 5 ); + bSizerRight->Add( m_buttonMirrorX, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_buttonMirrorY = new wxButton( this, wxID_ANY, _("Mirror Y"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerRight->Add( m_buttonMirrorY, 0, wxEXPAND|wxALL, 5 ); + bSizerRight->Add( m_buttonMirrorY, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_buttonRotate = new wxButton( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerRight->Add( m_buttonRotate, 0, wxALL|wxEXPAND, 5 ); + bSizerRight->Add( m_buttonRotate, 0, wxEXPAND|wxALL, 5 ); + + m_buttonGrey = new wxButton( this, wxID_ANY, _("Grey"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_buttonGrey, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_buttonHalfSize = new wxButton( this, wxID_ANY, _("Half Size"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonHalfSize->SetDefault(); + bSizerRight->Add( m_buttonHalfSize, 0, wxALL|wxEXPAND, 5 ); + + m_buttonUndoLast = new wxButton( this, wxID_ANY, _("Undo Last"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_buttonUndoLast, 0, wxALL|wxEXPAND, 5 ); m_staticTextScale = new wxStaticText( this, wxID_ANY, _("Image Scale:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextScale->Wrap( -1 ); @@ -70,6 +80,9 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID m_buttonMirrorX->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorX_click ), NULL, this ); m_buttonMirrorY->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorY_click ), NULL, this ); m_buttonRotate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRotateClick ), NULL, this ); + m_buttonGrey->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnGreyScaleConvert ), NULL, this ); + m_buttonHalfSize->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnHalfSize ), NULL, this ); + m_buttonUndoLast->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnUndoLastChange ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnCancel_Button ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnOK_Button ), NULL, this ); } @@ -81,6 +94,9 @@ DIALOG_IMAGE_EDITOR_BASE::~DIALOG_IMAGE_EDITOR_BASE() m_buttonMirrorX->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorX_click ), NULL, this ); m_buttonMirrorY->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorY_click ), NULL, this ); m_buttonRotate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRotateClick ), NULL, this ); + m_buttonGrey->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnGreyScaleConvert ), NULL, this ); + m_buttonHalfSize->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnHalfSize ), NULL, this ); + m_buttonUndoLast->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnUndoLastChange ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnCancel_Button ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnOK_Button ), NULL, this ); diff --git a/common/dialogs/dialog_image_editor_base.h b/common/dialogs/dialog_image_editor_base.h index b4e2784a2b..e7f888ee33 100644 --- a/common/dialogs/dialog_image_editor_base.h +++ b/common/dialogs/dialog_image_editor_base.h @@ -38,6 +38,9 @@ class DIALOG_IMAGE_EDITOR_BASE : public wxDialog wxButton* m_buttonMirrorX; wxButton* m_buttonMirrorY; wxButton* m_buttonRotate; + wxButton* m_buttonGrey; + wxButton* m_buttonHalfSize; + wxButton* m_buttonUndoLast; wxStaticText* m_staticTextScale; wxTextCtrl* m_textCtrlScale; wxStdDialogButtonSizer* m_sdbSizer1; @@ -49,13 +52,16 @@ class DIALOG_IMAGE_EDITOR_BASE : public wxDialog virtual void OnMirrorX_click( wxCommandEvent& event ) { event.Skip(); } virtual void OnMirrorY_click( wxCommandEvent& event ) { event.Skip(); } virtual void OnRotateClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnGreyScaleConvert( wxCommandEvent& event ) { event.Skip(); } + virtual void OnHalfSize( wxCommandEvent& event ) { event.Skip(); } + virtual void OnUndoLastChange( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancel_Button( wxCommandEvent& event ) { event.Skip(); } virtual void OnOK_Button( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Image Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,256 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Image Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,299 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_IMAGE_EDITOR_BASE(); }; diff --git a/include/class_bitmap_base.h b/include/class_bitmap_base.h index 6d75a100cc..8a53674154 100644 --- a/include/class_bitmap_base.h +++ b/include/class_bitmap_base.h @@ -72,6 +72,14 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) ); */ double GetPixelScaleFactor() { return m_pixelScaleFactor; } void SetPixelScaleFactor( double aSF ) { m_pixelScaleFactor = aSF; } + wxImage* GetImageData() { return m_image; } + + /* + * Function RebuildBitmap + * Rebuild the internal bitmap used to draw/plot image + * must be called after a m_image change + */ + void RebuildBitmap() { *m_bitmap = wxBitmap( *m_image ); } /** * Function ImportData @@ -102,6 +110,18 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) ); */ wxSize GetSize() const; + /** + * Function GetSizePixels + * @returns the size in pixels of the image + */ + wxSize GetSizePixels() const + { + if( m_image ) + return wxSize( m_image->GetWidth(), m_image->GetHeight() ); + else + return wxSize(0,0); + } + /** * Function GetBoundingBox * returns the orthogonal, bounding box of this object for display From 9b97938a8a8ba81efa104f539c6976256f2b48e3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 4 Sep 2011 20:35:14 +0200 Subject: [PATCH 2/9] Code cleaning: rename DIALOG_LOAD_ERROR (a stupid name) class to the more understandable HTML_MESSAGE_BOX. rename corresponding files are move them in a better place. --- common/CMakeLists.txt | 2 +- ...log_load_error.cpp => html_messagebox.cpp} | 28 +++++++++++++------ cvpcb/cvframe.cpp | 4 +-- eeschema/eelibs_read_libraryfiles.cpp | 4 +-- gerbview/excellon_read_drill_file.cpp | 4 +-- gerbview/readgerb.cpp | 4 +-- ...{dialog_load_error.h => html_messagebox.h} | 23 ++++++++++----- 7 files changed, 44 insertions(+), 25 deletions(-) rename common/{dialogs/dialog_load_error.cpp => html_messagebox.cpp} (63%) rename include/{dialog_load_error.h => html_messagebox.h} (57%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b45f27b667..36ffb30597 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -17,7 +17,6 @@ set( COMMON_ABOUT_DLG_SRCS dialogs/dialog_get_component_base.cpp dialogs/dialog_hotkeys_editor.cpp dialogs/dialog_hotkeys_editor_base.cpp - dialogs/dialog_load_error.cpp dialogs/dialog_page_settings_base.cpp ) @@ -58,6 +57,7 @@ set(COMMON_SRCS gr_basic.cpp hotkeys_basic.cpp hotkey_grid_table.cpp + html_messagebox.cpp msgpanel.cpp netlist_keywords.cpp newstroke_font.cpp diff --git a/common/dialogs/dialog_load_error.cpp b/common/html_messagebox.cpp similarity index 63% rename from common/dialogs/dialog_load_error.cpp rename to common/html_messagebox.cpp index f833431770..cf41c0c35c 100644 --- a/common/dialogs/dialog_load_error.cpp +++ b/common/html_messagebox.cpp @@ -1,22 +1,22 @@ #include "fctsys.h" -#include "dialog_load_error.h" +#include "html_messagebox.h" #include "macros.h" -DIALOG_LOAD_ERROR::DIALOG_LOAD_ERROR( wxWindow* parent ) -: -DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, _("Load Error!"),wxDefaultPosition, wxSize( 450,250 ) ) +HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* parent, const wxString & aTitle, + wxPoint aPos, wxSize aSize) + : DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, aTitle, aPos, aSize ) { SetFocus(); ListClear(); } -void DIALOG_LOAD_ERROR::OnCloseButtonClick( wxCommandEvent& event ) +void HTML_MESSAGE_BOX::OnCloseButtonClick( wxCommandEvent& event ) { EndModal(0); } -void DIALOG_LOAD_ERROR::ListClear(void) +void HTML_MESSAGE_BOX::ListClear(void) { m_htmlWindow->SetPage(wxEmptyString); } @@ -26,7 +26,7 @@ void DIALOG_LOAD_ERROR::ListClear(void) * Add a list of items. * @param aList = a string containing items. Items are separated by '\n' */ -void DIALOG_LOAD_ERROR::ListSet(const wxString &aList) +void HTML_MESSAGE_BOX::ListSet(const wxString &aList) { wxArrayString* wxStringSplit( wxString txt, wxChar splitter ); @@ -48,7 +48,7 @@ void DIALOG_LOAD_ERROR::ListSet(const wxString &aList) * Add a list of items. * @param aList = a wxArrayString containing items */ -void DIALOG_LOAD_ERROR::ListSet(const wxArrayString &aList) +void HTML_MESSAGE_BOX::ListSet(const wxArrayString &aList) { wxString msg = wxT("
    "); for ( unsigned ii = 0; ii < aList.GetCount(); ii ++ ) @@ -65,10 +65,20 @@ void DIALOG_LOAD_ERROR::ListSet(const wxArrayString &aList) * Add a message (in bold) to message list. * @param message = the message */ -void DIALOG_LOAD_ERROR::MessageSet(const wxString &message) +void HTML_MESSAGE_BOX::MessageSet(const wxString &message) { wxString message_value; message_value.Printf(wxT("%s
    "), GetChars( message ) ); m_htmlWindow->AppendToPage( message_value ); } +/** + * Function AddHTML_Text + * Add a text to message list. + * @param message = the text to add + */ +void HTML_MESSAGE_BOX::AddHTML_Text(const wxString &message) +{ + m_htmlWindow->AppendToPage( message ); +} + diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 9960a0c749..64885bcc22 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -17,7 +17,7 @@ #include "dialog_cvpcb_config.h" #include "class_DisplayFootprintsFrame.h" #include "cvpcb_id.h" -#include "dialog_load_error.h" +#include "html_messagebox.h" #include "build_version.h" @@ -578,7 +578,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() /* Display error messages, if any */ if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() ) { - DIALOG_LOAD_ERROR dialog( NULL ); + HTML_MESSAGE_BOX dialog( this, _("Load Error") ); if( !m_footprints.m_filesNotFound.IsEmpty() ) { diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index c02572e1a6..9f468fe106 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -11,7 +11,7 @@ #include "general.h" #include "class_library.h" -#include "dialog_load_error.h" +#include "html_messagebox.h" /** @@ -94,7 +94,7 @@ void SCH_EDIT_FRAME::LoadLibraries( void ) /* Print the libraries not found */ if( !libraries_not_found.IsEmpty() ) { - DIALOG_LOAD_ERROR dialog( this ); + HTML_MESSAGE_BOX dialog( this, _("Files not found") ); dialog.MessageSet( _( "The following libraries could not be found:" ) ); dialog.ListSet( libraries_not_found ); libraries_not_found.empty(); diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 54ded90428..c316b405bf 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -70,7 +70,7 @@ #include -#include "dialog_load_error.h" +#include "html_messagebox.h" extern int ReadInt( char*& text, bool aSkipSeparator = true ); extern double ReadDouble( char*& text, bool aSkipSeparator = true ); @@ -180,7 +180,7 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) // Display errors list if( m_Messages.size() > 0 ) { - DIALOG_LOAD_ERROR dlg( this ); + HTML_MESSAGE_BOX dlg( this, _("Files not found") ); dlg.ListSet( m_Messages ); dlg.ShowModal(); } diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index b479437c4d..6e41d33d28 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -10,7 +10,7 @@ #include "gerbview.h" #include "class_GERBER.h" -#include "dialog_load_error.h" +#include "html_messagebox.h" /* Read a gerber file, RS274D or RS274X format. */ @@ -156,7 +156,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, // Display errors list if( m_Messages.size() > 0 ) { - DIALOG_LOAD_ERROR dlg( this ); + HTML_MESSAGE_BOX dlg( this, _("Errors") ); dlg.ListSet(m_Messages); dlg.ShowModal(); } diff --git a/include/dialog_load_error.h b/include/html_messagebox.h similarity index 57% rename from include/dialog_load_error.h rename to include/html_messagebox.h index 965660d378..5d89965e37 100644 --- a/include/dialog_load_error.h +++ b/include/html_messagebox.h @@ -1,5 +1,5 @@ -#ifndef __dialog_load_error_h_ -#define __dialog_load_error_h_ +#ifndef _html_messagebox_ +#define _html_messagebox_ /** @file @@ -8,16 +8,18 @@ Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder. #include "../common/dialogs/dialog_display_info_HTML_base.h" -/** Implementing DIALOG_LOAD_ERROR */ -class DIALOG_LOAD_ERROR : public DIALOG_DISPLAY_HTML_TEXT_BASE +/** Implementing HTML_MESSAGE_BOX */ +class HTML_MESSAGE_BOX : public DIALOG_DISPLAY_HTML_TEXT_BASE { protected: - // Handlers for DIALOG_LOAD_ERROR_BASE events. + // Handlers for HTML_MESSAGE_BOX_BASE events. void OnCloseButtonClick( wxCommandEvent& event ); public: /** Constructor */ - DIALOG_LOAD_ERROR( wxWindow* parent ); + HTML_MESSAGE_BOX( wxWindow* parent, const wxString & aTitle, + wxPoint aPos = wxDefaultPosition, + wxSize aSize = wxSize( 450,250 ) ); /** * Function ListSet @@ -39,6 +41,13 @@ public: * @param message = the message */ void MessageSet(const wxString &message); + + /** + * Function AddHTML_Text + * Add a html text (without any change) to message list. + * @param message = the text to add + */ + void AddHTML_Text(const wxString &message); }; -#endif // __dialog_load_error_h_ +#endif // _html_messagebox_ From 4467b911b02248f9d40b2cbf52aff218ee706017 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 6 Sep 2011 09:02:18 +0200 Subject: [PATCH 3/9] Commit patch make by Fabrizio, with a minor change to avoid duplicate HTML dialog. --- HOW_TO_CONTRIBUTE.txt | 44 ++++++++++++++++++++++++++++++++++ common/confirm.cpp | 16 ++++++++++++- common/hotkeys_basic.cpp | 10 ++++---- eeschema/help_common_strings.h | 1 + eeschema/hotkeys.cpp | 22 ++++++++--------- eeschema/menubar.cpp | 42 +++++++++++++++++--------------- eeschema/tool_sch.cpp | 2 +- gerbview/hotkeys.cpp | 4 ++-- include/confirm.h | 5 ++++ pcbnew/hotkeys.cpp | 4 ++-- 10 files changed, 110 insertions(+), 40 deletions(-) create mode 100644 HOW_TO_CONTRIBUTE.txt diff --git a/HOW_TO_CONTRIBUTE.txt b/HOW_TO_CONTRIBUTE.txt new file mode 100644 index 0000000000..8d7477eb51 --- /dev/null +++ b/HOW_TO_CONTRIBUTE.txt @@ -0,0 +1,44 @@ +Contribute to KiCad (under Linux) +-------------------- + +1) make sure you have all the dependencies of KiCad: + sudo apt-get install debhelper dpatch libx11-dev + sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev mesa-common-dev + sudo apt-get install libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot + sudo apt-get install cmake bzr + +2) initialize Bazaar: + bzr whoami "John Doe " + +3) get LATEST KiCad source tree and name it, for instance, "kicad_john": + cd ~/ + bzr branch lp:kicad kicad_john + +4) create a copy of this folder and zip it away (just in case). + +5) Modify/add source code. + cd kicad_john + gedit ....... + +6) Compile: + cd kicad_john + mkdir build; cd build + cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug + make -j 4 # this is for a 4 core machine + +7) Repeat step 5 and 6 until satisfied. + +8) Delete the "build" folder and create a patch: + cd kicad_john + rm -R ./build + bzr add . + bzr status + bzr diff > gui_better_zoom.patch + +9) Send the patch file "gui_better_zoom.patch" to the KiCad developers mailing list. + in the subject of the e-mail include the keyword "[PATCH]". + in the body of the e-mail clearly explain what you have done. + + +for more info see INSTALL.txt. + diff --git a/common/confirm.cpp b/common/confirm.cpp index 4aa766c92f..24240e7d00 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -5,7 +5,9 @@ #include "fctsys.h" #include "common.h" - +#include "wx/wx.h" +#include "wx/html/htmlwin.h" +#include "html_messagebox.h" /* Display an error or warning message. * TODO: @@ -45,6 +47,18 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& text, } + /* Display a simple message window in html format. + */ +void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title, + const wxString& text, const wxSize& size ) +{ + HTML_MESSAGE_BOX *dlg = new HTML_MESSAGE_BOX(parent,title, wxDefaultPosition, size ); + dlg->AddHTML_Text( text ); + dlg->ShowModal(); + dlg->Destroy(); +} + + bool IsOK( wxWindow* parent, const wxString& text ) { int ii; diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index dde2a5378f..927afbf21e 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -339,8 +339,9 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, wxString keyname; Ki_HotkeyInfo** List; - wxString msg = _( "Current hotkey list:\n\n" ); + wxString msg = _( "" ); + msg += _( "

    Hotkeys List

    "); for( ; aDescList->m_HK_InfoList != NULL; aDescList++ ) { List = aDescList->m_HK_InfoList; @@ -348,13 +349,14 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, for( ; *List != NULL; List++ ) { Ki_HotkeyInfo* hk_decr = *List; - msg += _( "key " ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); - msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" ); + msg += wxT( ""); + msg += wxT("" ); } } - DisplayInfoMessage( aFrame, msg ); + msg += wxT("
    " ) + hk_decr->m_InfoMsg + wxT("  ") + keyname + wxT( "
    "); + DisplayHtmlInfoMessage( aFrame, _("Hotkeys List"), msg, wxSize(340, 750)); } diff --git a/eeschema/help_common_strings.h b/eeschema/help_common_strings.h index b0dff7f1a8..d6c03ea4e4 100644 --- a/eeschema/help_common_strings.h +++ b/eeschema/help_common_strings.h @@ -57,3 +57,4 @@ #define HELP_ADD_BODYCIRCLE _( "Add circles to the component body" ) #define HELP_ADD_BODYARC _( "Add arcs to the component body" ) #define HELP_ADD_BODYPOLYGON _( "Add lines and polygons to the component body" ) +#define HELP_PLACE_GRAPHICIMAGES _("Add a bitmap image") diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 867ef33fe4..6f3712b230 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -87,8 +87,8 @@ static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' ); #endif -static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' ); -static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), +static Ki_HotkeyInfo HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' ); +static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); /* Undo */ @@ -104,11 +104,11 @@ 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 HkAddHierarchicalLabel( wxT( "add Hierarchical Label" ), HK_ADD_HLABEL, 'H' ); -static Ki_HotkeyInfo HkAddGlobalLabel( wxT( "add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + '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 HkBeginBus( wxT( "begin Bus" ), HK_BEGIN_BUS, 'B' ); +static Ki_HotkeyInfo HkAddHierarchicalLabel( wxT( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H' ); +static Ki_HotkeyInfo HkAddGlobalLabel( wxT( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'L' ); +static Ki_HotkeyInfo HkAddJunction( wxT( "Add Junction" ), HK_ADD_JUNCTION, 'J' ); +static Ki_HotkeyInfo HkBeginWire( wxT( "Draw Wire" ), HK_BEGIN_WIRE, 'W' ); +static Ki_HotkeyInfo HkBeginBus( wxT( "Draw Bus" ), HK_BEGIN_BUS, 'B' ); static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' ); static Ki_HotkeyInfo HkAddPower( wxT( "Add Power" ), HK_ADD_NEW_POWER, 'P' ); static Ki_HotkeyInfo HkAddNoConn( wxT( "Add NoConnected Flag" ), HK_ADD_NOCONN_FLAG, 'Q' ); @@ -139,20 +139,20 @@ static Ki_HotkeyInfo HkCopyComponentOrText( wxT( "Copy Component or Label" ), static Ki_HotkeyInfo HkDrag( wxT( "Drag Schematic Item" ), HK_DRAG, 'G', ID_POPUP_SCH_DRAG_CMP_REQUEST ); -static Ki_HotkeyInfo HkMove2Drag( wxT( "Switch move block to drag block" ), +static Ki_HotkeyInfo HkMove2Drag( wxT( "Move Block -> Drag Block" ), HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' ); static Ki_HotkeyInfo HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT ); static Ki_HotkeyInfo HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE ); static Ki_HotkeyInfo HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL ); static Ki_HotkeyInfo HkFindNextItem( wxT( "Find Next Item" ), HK_FIND_NEXT_ITEM, WXK_F5 ); -static Ki_HotkeyInfo HkFindNextDrcMarker( wxT( "Find next DRC marker" ), HK_FIND_NEXT_DRC_MARKER, +static Ki_HotkeyInfo HkFindNextDrcMarker( wxT( "Find Next DRC Marker" ), HK_FIND_NEXT_DRC_MARKER, WXK_F5 + GR_KB_SHIFT ); // Special keys for library editor: static Ki_HotkeyInfo HkCreatePin( wxT( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' ); static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); -static Ki_HotkeyInfo HkMoveLibItem( wxT( "Move Lib Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' ); +static Ki_HotkeyInfo HkMoveLibItem( wxT( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' ); // List of common hotkey descriptors @@ -977,7 +977,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; case HK_LIBEDIT_CREATE_PIN: - SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add pin" ) ); + SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add Pin" ) ); OnLeftClick( aDC, aPosition ); break; diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index fef72125f9..8e24d9df5a 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -51,7 +51,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() AddMenuItem( fileMenu, ID_LOAD_PROJECT, _( "&Open\tCtrl+O" ), - _( "Open an existing schematic project" ), + _( "Open Existing Schematic Project" ), open_document_xpm ); // Open Recent submenu @@ -67,7 +67,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); AddMenuItem( fileMenu, openRecentMenu, wxID_ANY, _( "Open &Recent" ), - _( "Open a recent opened schematic project" ), + _( "Open Recent Opened Schematic Project" ), open_project_xpm ); // Separator @@ -196,7 +196,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() AddMenuItem( editMenu, ID_BACKANNO_ITEMS, _( "&Backannotate" ), - _( "Back annotate the footprint fields" ), + _( "Back Annotate Footprint Fields" ), import_footprint_names_xpm ); // Menu View: @@ -258,7 +258,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() add_component_xpm ); // Power port - text = AddHotkeyName( _( "Power port" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Power Port" ), s_Schematic_Hokeys_Descr, HK_ADD_NEW_POWER, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_PLACE_POWER_BUTT, text, HELP_PLACE_POWERPORT, @@ -279,21 +279,21 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() add_bus_xpm ); // Wire to Bus entry - text = AddHotkeyName( _( "Wire to bus entry" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Wire to Bus Entry" ), s_Schematic_Hokeys_Descr, HK_ADD_WIRE_ENTRY, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_WIRETOBUS_ENTRY_BUTT, text, HELP_PLACE_WIRE2BUS_ENTRY, add_line2bus_xpm ); // Bus to Bus entry - text = AddHotkeyName( _( "Bus to bus entry" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Bus to Bus Entry" ), s_Schematic_Hokeys_Descr, HK_ADD_BUS_ENTRY, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_BUSTOBUS_ENTRY_BUTT, text, HELP_PLACE_BUS2BUS_ENTRY, add_bus2bus_xpm ); - // No connect flag - text = AddHotkeyName( _( "No connect flag" ), s_Schematic_Hokeys_Descr, + // No Connect Flag + text = AddHotkeyName( _( "No Connect Flag" ), s_Schematic_Hokeys_Descr, HK_ADD_NOCONN_FLAG, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_NOCONN_BUTT, text, HELP_PLACE_NC_FLAG, noconn_xpm ); @@ -305,7 +305,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() add_line_label_xpm ); // Global label - text = AddHotkeyName( _( "Global label" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Global Label" ), s_Schematic_Hokeys_Descr, HK_ADD_GLABEL, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_GLABEL_BUTT, text, HELP_PLACE_GLOBALLABEL, @@ -322,9 +322,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() placeMenu->AppendSeparator(); // Hierarchical label - text = AddHotkeyName( _( "Hierarchical label" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ADD_HLABEL, false ); // add comment, not a shortcut - text = AddHotkeyName( _( "Hierarchical label" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ADD_HLABEL, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_HIERLABEL_BUTT, text, HELP_PLACE_HIER_LABEL, @@ -332,7 +332,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Hierarchical sheet - text = AddHotkeyName( _( "Hierarchical sheet" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Hierarchical Sheet" ), s_Schematic_Hokeys_Descr, HK_ADD_HIER_SHEET, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_SHEET_SYMBOL_BUTT, text, HELP_PLACE_SHEET, @@ -348,7 +348,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Add hierarchical Pin to Sheet AddMenuItem( placeMenu, ID_SHEET_PIN_BUTT, - _( "Add Hierarchical Pin to Sheet" ), + _( "Hierarchical Pin to Sheet" ), HELP_PLACE_SHEETPIN, add_hierar_pin_xpm ); @@ -356,19 +356,23 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() placeMenu->AppendSeparator(); // Graphic line or polygon - text = AddHotkeyName( _( "Graphic polyline" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Graphic Polyline" ), s_Schematic_Hokeys_Descr, HK_ADD_GRAPHIC_POLYLINE, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_LINE_COMMENT_BUTT, text, HELP_PLACE_GRAPHICLINES, add_dashed_line_xpm ); // Graphic text - text = AddHotkeyName( _( "Graphic text" ), s_Schematic_Hokeys_Descr, + text = AddHotkeyName( _( "Graphic Text" ), s_Schematic_Hokeys_Descr, HK_ADD_GRAPHIC_TEXT, false ); // add comment, not a shortcut AddMenuItem( placeMenu, ID_TEXT_COMMENT_BUTT, text, HELP_PLACE_GRAPHICTEXTS, add_text_xpm ); + // Graphic image + AddMenuItem( placeMenu, ID_ADD_IMAGE_BUTT, _("Image"), + HELP_PLACE_GRAPHICIMAGES, + image_xpm ); // Menu Preferences: wxMenu* preferencesMenu = new wxMenu; @@ -412,14 +416,14 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Save preferences AddMenuItem( preferencesMenu, ID_CONFIG_SAVE, - _( "&Save preferences" ), + _( "&Save Preferences" ), _( "Save application preferences" ), save_setup_xpm ); // Read preferences AddMenuItem( preferencesMenu, ID_CONFIG_READ, - _( "&Read preferences" ), + _( "&Read Preferences" ), _( "Read application preferences" ), read_setup_xpm ); @@ -478,14 +482,14 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() //Run CVPcb AddMenuItem( toolsMenu, ID_TO_CVPCB, - _( "A&ssign component footprints" ), + _( "A&ssign Component Footprints" ), _( "Run CVPcb" ), cvpcb_xpm ); // Run PCBNew AddMenuItem( toolsMenu, ID_TO_PCB, - _( "&Layout printed circuit board" ), + _( "&Layout Printed Circuit Board" ), _( "Run PCBNew" ), pcbnew_xpm ); diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index e210e259d7..d464794592 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -218,7 +218,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar() HELP_PLACE_GRAPHICTEXTS, wxITEM_CHECK ); m_VToolBar->AddTool( ID_ADD_IMAGE_BUTT, wxEmptyString, wxBitmap( image_xpm ), - _("Add a bitmap image"), wxITEM_CHECK ); + HELP_PLACE_GRAPHICIMAGES, wxITEM_CHECK ); m_VToolBar->AddTool( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_body_xpm ), HELP_DELETE_ITEMS, wxITEM_CHECK ); diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index b3d4f74928..52d3728efe 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -30,13 +30,13 @@ /* local variables */ /* Hotkey list: */ -static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' ); +static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); -static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' ); +static Ki_HotkeyInfo HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' ); static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' ); static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ), diff --git a/include/confirm.h b/include/confirm.h index 942d45e012..843ba2f439 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -16,4 +16,9 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& msg, bool IsOK( wxWindow* parent, const wxString& msg ); +void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title, + const wxString& msg, + const wxSize& size=wxDefaultSize ); + + #endif /* __INCLUDE__CONFIRM_H__ */ diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 42778de3ab..1bb5635854 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -82,7 +82,7 @@ static Ki_HotkeyInfo HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ), static Ki_HotkeyInfo HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), HK_LOCK_UNLOCK_FOOTPRINT, 'L' ); static Ki_HotkeyInfo HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE ); -static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), +static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); /* Fit on Screen */ @@ -115,7 +115,7 @@ static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' ); #endif -static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' ); +static Ki_HotkeyInfo HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' ); /* Undo */ From ebc7259a91a4889b09efc88fdcb19db75145b839 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 6 Sep 2011 10:09:40 -0400 Subject: [PATCH 4/9] Rename WinEDA_App class to EDA_APP and remove redundant includes. --- bitmap2component/bitmap2cmp_gui.cpp | 32 +++- common/eda_doc.cpp | 4 +- common/edaappl.cpp | 46 ++--- common/gestfich.cpp | 8 +- common/projet_config.cpp | 117 ++++++------ cvpcb/class_components_listbox.cpp | 1 - cvpcb/class_footprints_listbox.cpp | 1 - cvpcb/cvpcb.cpp | 10 +- cvpcb/genequiv.cpp | 1 - cvpcb/listboxes.cpp | 1 - cvpcb/loadcmp.cpp | 1 - cvpcb/readschematicnetlist.cpp | 1 - cvpcb/savecmp.cpp | 1 - eeschema/annotate.cpp | 1 - eeschema/backanno.cpp | 1 - eeschema/block.cpp | 1 - eeschema/block_libedit.cpp | 1 - eeschema/build_BOM.cpp | 1 - eeschema/bus-wire-junction.cpp | 1 - eeschema/busentry.cpp | 1 - eeschema/class_libentry.cpp | 1 - eeschema/class_library.cpp | 1 - eeschema/class_netlist_object.cpp | 1 - eeschema/component_references_lister.cpp | 2 - eeschema/cross-probing.cpp | 1 - eeschema/database.cpp | 1 - eeschema/dialogs/annotate_dialog.cpp | 2 - eeschema/dialogs/dialog_SVG_print.cpp | 1 - eeschema/dialogs/dialog_build_BOM.cpp | 1 - eeschema/dialogs/dialog_color_config.cpp | 1 - .../dialog_edit_component_in_schematic.cpp | 1 - eeschema/dialogs/dialog_edit_label.cpp | 1 - .../dialog_edit_libentry_fields_in_lib.cpp | 1 - eeschema/dialogs/dialog_eeschema_config.cpp | 1 - eeschema/dialogs/dialog_erc.cpp | 2 - .../dialogs/dialog_libedit_dimensions.cpp | 1 - .../dialogs/dialog_plot_schematic_DXF.cpp | 1 - .../dialogs/dialog_plot_schematic_HPGL.cpp | 1 - eeschema/dialogs/dialog_plot_schematic_PS.cpp | 1 - .../dialogs/dialog_print_using_printer.cpp | 1 - eeschema/edit_bitmap.cpp | 1 - eeschema/edit_component_in_schematic.cpp | 1 - eeschema/edit_label.cpp | 1 - eeschema/eeredraw.cpp | 1 - eeschema/eeschema.cpp | 10 +- eeschema/eeschema_config.cpp | 1 - eeschema/erc.cpp | 2 - eeschema/events_called_functions_for_edit.cpp | 1 - eeschema/files-io.cpp | 1 - eeschema/find.cpp | 1 - eeschema/getpart.cpp | 1 - eeschema/hierarch.cpp | 2 - eeschema/hotkeys.cpp | 1 - eeschema/lib_arc.cpp | 1 - eeschema/lib_bezier.cpp | 1 - eeschema/lib_circle.cpp | 1 - eeschema/lib_export.cpp | 1 - eeschema/lib_field.cpp | 1 - eeschema/lib_pin.cpp | 1 - eeschema/lib_polyline.cpp | 2 +- eeschema/lib_rectangle.cpp | 1 - eeschema/lib_text.cpp | 1 - eeschema/libarch.cpp | 1 - eeschema/libedit.cpp | 1 - eeschema/libedit_onleftclick.cpp | 1 - eeschema/libedit_plot_component.cpp | 1 - eeschema/libedit_undo_redo.cpp | 1 - eeschema/libfield.cpp | 2 - eeschema/netform.cpp | 1 - eeschema/netlist.cpp | 1 - eeschema/netlist_control.cpp | 1 - eeschema/onleftclick.cpp | 1 - eeschema/operations_on_items_lists.cpp | 1 - eeschema/pinedit.cpp | 1 - eeschema/sch_bitmap.cpp | 1 - eeschema/sch_component.cpp | 1 - eeschema/sch_field.cpp | 1 - eeschema/sch_marker.cpp | 1 - eeschema/sch_screen.cpp | 1 - eeschema/sch_sheet.cpp | 1 - eeschema/sch_sheet_path.cpp | 1 - eeschema/sch_sheet_pin.cpp | 1 - eeschema/sch_text.cpp | 1 - eeschema/schedit.cpp | 1 - eeschema/schematic_undo_redo.cpp | 1 - eeschema/schframe.cpp | 2 - eeschema/selpart.cpp | 1 - eeschema/sheet.cpp | 1 - eeschema/sheetlab.cpp | 1 - eeschema/symbedit.cpp | 1 - eeschema/tool_lib.cpp | 2 - eeschema/tool_sch.cpp | 4 - eeschema/tool_viewlib.cpp | 3 - eeschema/viewlib_frame.cpp | 2 - eeschema/viewlibs.cpp | 2 - gerbview/class_DCodeSelectionbox.cpp | 1 - gerbview/gerbview.cpp | 16 +- gerbview/gerbview_frame.cpp | 10 +- include/appl_wxstruct.h | 170 ++++++++++-------- kicad/class_treeproject_item.cpp | 1 - kicad/class_treeprojectfiles.cpp | 2 - kicad/commandframe.cpp | 2 - kicad/files-io.cpp | 2 - kicad/kicad.cpp | 18 +- kicad/mainframe.cpp | 2 - kicad/preferences.cpp | 2 - kicad/prjconfig.cpp | 1 - kicad/tree_project_frame.cpp | 2 - pcb_calculator/pcb_calculator.cpp | 7 +- pcbnew/attribut.cpp | 1 - pcbnew/automove.cpp | 1 - pcbnew/autoplac.cpp | 1 - pcbnew/autorout.cpp | 1 - pcbnew/basepcbframe.cpp | 2 - pcbnew/block.cpp | 1 - pcbnew/block_module_editor.cpp | 1 - ...board_items_to_polygon_shape_transform.cpp | 1 - pcbnew/board_undo_redo.cpp | 1 - pcbnew/build_BOM_from_board.cpp | 1 - pcbnew/class_dimension.cpp | 1 - pcbnew/class_drawsegment.cpp | 1 - pcbnew/class_edge_mod.cpp | 1 - pcbnew/class_module.cpp | 1 - pcbnew/class_module_transform_functions.cpp | 1 - pcbnew/class_pcb_layer_widget.cpp | 2 - pcbnew/class_pcb_text.cpp | 1 - pcbnew/class_text_mod.cpp | 1 - pcbnew/class_zone.cpp | 1 - pcbnew/clean.cpp | 1 - pcbnew/cross-probing.cpp | 1 - pcbnew/debug_kbool_key_file_fct.cpp | 1 - pcbnew/deltrack.cpp | 1 - pcbnew/dialogs/dialog_copper_zones.cpp | 1 - pcbnew/dialogs/dialog_design_rules.cpp | 1 - pcbnew/dialogs/dialog_display_options.cpp | 1 - pcbnew/dialogs/dialog_drc.cpp | 2 - .../dialog_edit_module_for_BoardEditor.cpp | 2 - .../dialog_edit_module_for_Modedit.cpp | 2 - pcbnew/dialogs/dialog_freeroute_exchange.cpp | 1 - pcbnew/dialogs/dialog_general_options.cpp | 1 - pcbnew/dialogs/dialog_global_deletion.cpp | 1 - .../dialog_global_edit_tracks_and_vias.cpp | 1 - .../dialog_graphic_item_properties.cpp | 1 - .../dialogs/dialog_graphic_items_options.cpp | 1 - pcbnew/dialogs/dialog_layers_setup.cpp | 1 - pcbnew/dialogs/dialog_mask_clearance.cpp | 1 - pcbnew/dialogs/dialog_netlist.cpp | 1 - pcbnew/dialogs/dialog_pcb_text_properties.cpp | 1 - .../dialog_pcbnew_config_libs_and_paths.cpp | 2 +- pcbnew/dialogs/dialog_print_for_modedit.cpp | 1 - pcbnew/dialogs/dialog_print_using_printer.cpp | 1 - pcbnew/dimension.cpp | 1 - pcbnew/drc.cpp | 1 - pcbnew/drc_clearance_test_functions.cpp | 1 - pcbnew/drc_marker_functions.cpp | 2 - pcbnew/edgemod.cpp | 1 - pcbnew/edit_pcb_text.cpp | 1 - pcbnew/edit_track_width.cpp | 1 - pcbnew/editedge.cpp | 1 - pcbnew/editmod.cpp | 1 - pcbnew/editrack-part2.cpp | 1 - pcbnew/editrack.cpp | 1 - pcbnew/event_handlers_tracks_vias_sizes.cpp | 1 - pcbnew/export_gencad.cpp | 1 - pcbnew/export_vrml.cpp | 1 - pcbnew/files.cpp | 1 - pcbnew/find.cpp | 1 - pcbnew/gen_modules_placefile.cpp | 1 - pcbnew/gendrill.cpp | 1 - pcbnew/hotkeys.cpp | 2 - pcbnew/hotkeys_board_editor.cpp | 1 - pcbnew/hotkeys_module_editor.cpp | 1 - pcbnew/initpcb.cpp | 1 - pcbnew/ioascii.cpp | 1 - pcbnew/librairi.cpp | 1 - pcbnew/loadcmp.cpp | 1 - pcbnew/magnetic_tracks_functions.cpp | 1 - pcbnew/mirepcb.cpp | 1 - pcbnew/modedit_undo_redo.cpp | 1 - pcbnew/modeditoptions.cpp | 1 - pcbnew/moduleframe.cpp | 2 - pcbnew/modules.cpp | 1 - pcbnew/move_or_drag_track.cpp | 1 - pcbnew/muonde.cpp | 1 - pcbnew/muwave_command.cpp | 1 - pcbnew/netlist.cpp | 1 - pcbnew/onleftclick.cpp | 1 - pcbnew/pcbframe.cpp | 2 - pcbnew/pcbnew.cpp | 11 +- pcbnew/pcbnew_config.cpp | 1 - pcbnew/pcbplot.cpp | 1 - pcbnew/print_board_functions.cpp | 1 - pcbnew/solve.cpp | 1 - pcbnew/specctra_import.cpp | 1 - pcbnew/swap_layers.cpp | 1 - pcbnew/tool_modedit.cpp | 2 - pcbnew/tool_onrightclick.cpp | 1 - pcbnew/tool_pcb.cpp | 2 - pcbnew/toolbars_update_user_interface.cpp | 2 - pcbnew/tr_modif.cpp | 1 - pcbnew/tracepcb.cpp | 1 - pcbnew/xchgmod.cpp | 1 - pcbnew/zone_filling_algorithm.cpp | 1 - pcbnew/zones_by_polygon.cpp | 1 - pcbnew/zones_by_polygon_fill_functions.cpp | 1 - ...nvert_brd_items_to_polygons_with_Boost.cpp | 1 - ...nvert_brd_items_to_polygons_with_Kbool.cpp | 1 - ...ones_convert_to_polygons_aux_functions.cpp | 1 - pcbnew/zones_functions_for_undo_redo.cpp | 1 - pcbnew/zones_non_copper_type_functions.cpp | 1 - 210 files changed, 247 insertions(+), 444 deletions(-) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 62d58f6fff..21daf44a12 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -24,7 +24,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" @@ -39,7 +38,6 @@ #include "bitmap2component.xpm" -#include "bitmaps.h" #include "colors_selection.h" #include "build_version.h" @@ -89,6 +87,7 @@ private: void ExportFile( FILE* aOutfile, int aFormat ); }; + BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) { m_Config = new wxConfig(); @@ -116,6 +115,7 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) Centre(); } + BM2CMP_FRAME::~BM2CMP_FRAME() { if( ( m_Config == NULL ) || IsIconized() ) @@ -133,7 +133,7 @@ BM2CMP_FRAME::~BM2CMP_FRAME() delete m_Config; - /* This needed for OSX: avoids furter OnDraw processing after this + /* This needed for OSX: avoids further OnDraw processing after this * destructor and before the native window is destroyed */ this->Freeze( ); @@ -156,7 +156,7 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event ) m_InitialPicturePanel->PrepareDC( pict_dc ); m_GreyscalePicturePanel->PrepareDC( greyscale_dc ); m_BNPicturePanel->PrepareDC( nb_dc ); - + // OSX crashes with empty bitmaps (on initial refreshes) if(m_Pict_Bitmap.IsOk() && m_Greyscale_Bitmap.IsOk() && m_BN_Bitmap.IsOk()) { @@ -166,12 +166,14 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event ) } } + /* Called to load a bitmap file */ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) { wxFileName fn(m_BitmapFileName); wxString path = fn.GetPath(); + if( path.IsEmpty() || !wxDirExists(path) ) path = wxGetCwd(); @@ -182,7 +184,9 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) if( diag != wxID_OK ) return; + wxString fullFilename = FileDlg.GetPath(); + if( ! LoadFile( fullFilename ) ) return; @@ -192,6 +196,7 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) Refresh(); } + bool BM2CMP_FRAME::LoadFile( wxString& aFullFileName ) { m_BitmapFileName = aFullFileName; @@ -232,6 +237,7 @@ bool BM2CMP_FRAME::LoadFile( wxString& aFullFileName ) return true; } + void BM2CMP_FRAME::Binarize( double aThreshold ) { unsigned int pixin; @@ -244,10 +250,12 @@ void BM2CMP_FRAME::Binarize( double aThreshold ) for( int x = 1; x < w; x++ ) { pixin = m_Greyscale_Image.GetGreen( x, y ); + if( pixin < threshold ) pixout = 0; else pixout = 255; + m_NB_Image.SetRGB( x, y, pixout, pixout, pixout ); } @@ -289,8 +297,10 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) { wxFileName fn(m_ConvertedFileName); wxString path = fn.GetPath(); + if( path.IsEmpty() || !wxDirExists(path) ) path = ::wxGetCwd(); + wxString msg = _( "Schematic lib file (*.lib)|*.lib" ); wxFileDialog FileDlg( this, _( "Create a lib file for Eeschema" ), path, wxEmptyString, msg, @@ -299,10 +309,12 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) if( diag != wxID_OK ) return; + m_ConvertedFileName = FileDlg.GetPath(); FILE* outfile; outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); + if( outfile == NULL ) { wxString msg; @@ -320,8 +332,10 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) { wxFileName fn(m_ConvertedFileName); wxString path = fn.GetPath(); + if( path.IsEmpty() || !wxDirExists(path) ) path = ::wxGetCwd(); + wxString msg = _( "Footprint file (*.mod)|*.mod" ); wxFileDialog FileDlg( this, _( "Create a footprint file for PcbNew" ), path, wxEmptyString, @@ -331,10 +345,13 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) if( diag != wxID_OK ) return; + m_ConvertedFileName = FileDlg.GetPath(); + FILE* outfile; outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); + if( outfile == NULL ) { wxString msg; @@ -353,6 +370,7 @@ void BM2CMP_FRAME::ExportFile( FILE* aOutfile, int aFormat ) int h = m_NB_Image.GetHeight(); int w = m_NB_Image.GetWidth(); potrace_bitmap_t* potrace_bitmap = bm_new( w, h ); + if( !potrace_bitmap ) { wxString msg; @@ -377,18 +395,18 @@ void BM2CMP_FRAME::ExportFile( FILE* aOutfile, int aFormat ) // BM_TO_CMP_APP -void WinEDA_App::MacOpenFile(const wxString &fileName) +void EDA_APP::MacOpenFile(const wxString &fileName) { } -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) ///----------------------------------------------------------------------------- // BM_TO_CMP_APP // main program //----------------------------------------------------------------------------- -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { wxInitAllImageHandlers(); diff --git a/common/eda_doc.cpp b/common/eda_doc.cpp index 6d30e651e2..037d7d6421 100644 --- a/common/eda_doc.cpp +++ b/common/eda_doc.cpp @@ -16,7 +16,7 @@ /* Read from Common config the Pdf browser choice */ -void WinEDA_App::ReadPdfBrowserInfos() +void EDA_APP::ReadPdfBrowserInfos() { wxASSERT( m_EDA_CommonConfig != NULL ); @@ -32,7 +32,7 @@ void WinEDA_App::ReadPdfBrowserInfos() /* Write into Common config the Pdf browser choice */ -void WinEDA_App::WritePdfBrowserInfos() +void EDA_APP::WritePdfBrowserInfos() { wxASSERT( m_EDA_CommonConfig != NULL ); diff --git a/common/edaappl.cpp b/common/edaappl.cpp index f423eda434..e2c1fd784c 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -237,7 +237,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = }; -WinEDA_App::WinEDA_App() +EDA_APP::EDA_APP() { m_Checker = NULL; m_HtmlCtrl = NULL; @@ -251,7 +251,7 @@ WinEDA_App::WinEDA_App() } -WinEDA_App::~WinEDA_App() +EDA_APP::~EDA_APP() { SaveSettings(); @@ -271,7 +271,7 @@ WinEDA_App::~WinEDA_App() } -void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId ) +void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) { wxString EnvLang; @@ -349,7 +349,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId ) } -void WinEDA_App::InitOnLineHelp() +void EDA_APP::InitOnLineHelp() { wxString fullfilename = FindKicadHelpPath(); @@ -376,7 +376,7 @@ void WinEDA_App::InitOnLineHelp() } -bool WinEDA_App::SetBinDir() +bool EDA_APP::SetBinDir() { /* Apple MacOSx */ #ifdef __APPLE__ @@ -460,7 +460,7 @@ bool WinEDA_App::SetBinDir() } -void WinEDA_App::SetDefaultSearchPaths( void ) +void EDA_APP::SetDefaultSearchPaths( void ) { size_t i; wxString path = m_BinDir; @@ -554,7 +554,7 @@ void WinEDA_App::SetDefaultSearchPaths( void ) /* Add schematic library file path to search path list. * we must add /library and /library/doc */ - if( m_Id == APP_TYPE_EESCHEMA ) + if( m_Id == APP_EESCHEMA_T ) { fn.AppendDir( wxT( "library" ) ); @@ -576,7 +576,7 @@ void WinEDA_App::SetDefaultSearchPaths( void ) } /* Add PCB library file path to search path list. */ - if( ( m_Id == APP_TYPE_PCBNEW ) || ( m_Id == APP_TYPE_CVPCB ) ) + if( ( m_Id == APP_PCBNEW_T ) || ( m_Id == APP_CVPCB_T ) ) { fn.AppendDir( wxT( "modules" ) ); @@ -611,7 +611,7 @@ void WinEDA_App::SetDefaultSearchPaths( void ) } -void WinEDA_App::GetSettings( bool aReopenLastUsedDirectory ) +void EDA_APP::GetSettings( bool aReopenLastUsedDirectory ) { wxASSERT( m_EDA_Config != NULL && m_EDA_CommonConfig != NULL ); @@ -669,7 +669,7 @@ void WinEDA_App::GetSettings( bool aReopenLastUsedDirectory ) } -void WinEDA_App::SaveSettings() +void EDA_APP::SaveSettings() { wxASSERT( m_EDA_Config != NULL ); m_EDA_Config->Write( wxT( "ShowPageLimits" ), g_ShowPageLimits ); @@ -681,7 +681,7 @@ void WinEDA_App::SaveSettings() } -bool WinEDA_App::SetLanguage( bool first_time ) +bool EDA_APP::SetLanguage( bool first_time ) { bool retv = true; @@ -757,7 +757,7 @@ bool WinEDA_App::SetLanguage( bool first_time ) } -void WinEDA_App::SetLanguageIdentifier( int menu_id ) +void EDA_APP::SetLanguageIdentifier( int menu_id ) { wxLogDebug( wxT( "Select language ID %d from %d possible languages." ), menu_id, LANGUAGE_DESCR_COUNT ); @@ -773,7 +773,7 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id ) } -void WinEDA_App::SetLanguagePath( void ) +void EDA_APP::SetLanguagePath( void ) { size_t i; @@ -811,7 +811,7 @@ void WinEDA_App::SetLanguagePath( void ) } -void WinEDA_App::AddMenuLanguageList( wxMenu* MasterMenu ) +void EDA_APP::AddMenuLanguageList( wxMenu* MasterMenu ) { wxMenu* menu = NULL; wxMenuItem* item; @@ -858,7 +858,7 @@ void WinEDA_App::AddMenuLanguageList( wxMenu* MasterMenu ) } -wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename, +wxString EDA_APP::FindFileInSearchPaths( const wxString& filename, const wxArrayString* subdirs ) { size_t i, j; @@ -885,7 +885,7 @@ wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename, } -wxString WinEDA_App::GetHelpFile( void ) +wxString EDA_APP::GetHelpFile( void ) { wxString fn; wxArrayString subdirs, altsubdirs; @@ -963,7 +963,7 @@ wxString WinEDA_App::GetHelpFile( void ) } -wxString WinEDA_App::GetLibraryFile( const wxString& filename ) +wxString EDA_APP::GetLibraryFile( const wxString& filename ) { wxArrayString subdirs; @@ -978,7 +978,7 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename ) } -wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString& aSubPathToSearch ) +wxString EDA_APP::ReturnLastVisitedLibraryPath( const wxString& aSubPathToSearch ) { if( !m_LastVisitedLibPath.IsEmpty() ) return m_LastVisitedLibPath; @@ -1021,13 +1021,13 @@ wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString& aSubPathToSea } -void WinEDA_App::SaveLastVisitedLibraryPath( const wxString& aPath ) +void EDA_APP::SaveLastVisitedLibraryPath( const wxString& aPath ) { m_LastVisitedLibPath = aPath; } -wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename ) +wxString EDA_APP::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename ) { /* If the library path is already in the library search paths * list, just add the library name to the list. Otherwise, add @@ -1065,7 +1065,7 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF } -wxString WinEDA_App::FindLibraryPath( const wxString& aFileName ) +wxString EDA_APP::FindLibraryPath( const wxString& aFileName ) { if( wxFileName::FileExists( aFileName ) ) return aFileName; @@ -1074,7 +1074,7 @@ wxString WinEDA_App::FindLibraryPath( const wxString& aFileName ) } -void WinEDA_App::RemoveLibraryPath( const wxString& aPaths ) +void EDA_APP::RemoveLibraryPath( const wxString& aPaths ) { wxStringTokenizer Token( aPaths, wxT( ";\n\r" ) ); @@ -1090,7 +1090,7 @@ void WinEDA_App::RemoveLibraryPath( const wxString& aPaths ) } -void WinEDA_App::InsertLibraryPath( const wxString& aPaths, size_t aIndex ) +void EDA_APP::InsertLibraryPath( const wxString& aPaths, size_t aIndex ) { wxStringTokenizer Token( aPaths, wxT( ";\n\r" ) ); diff --git a/common/gestfich.cpp b/common/gestfich.cpp index e66f162f41..fd84120fed 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -520,20 +520,20 @@ wxString ReturnKicadDatasPath() if( PathFound ) { data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); + if( data_path.Last() != '/' ) data_path += UNIX_STRING_DIR_SEP; } else + { data_path.Empty(); + } return data_path; } -/* - * Return the preferred editor name - */ -wxString& WinEDA_App::GetEditorName() +wxString& EDA_APP::GetEditorName() { wxString editorname = m_EditorName; diff --git a/common/projet_config.cpp b/common/projet_config.cpp index 37a044435b..4545b4abae 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -22,19 +22,9 @@ #define FORCE_LOCAL_CONFIG true -/** - * Creates or recreates the kicad project file. (filename.pro) - * Initialize: - * G_Prj_Config - * G_Prj_Config_LocalFilename - * G_Prj_Default_Config_FullFilename - * Return: - * True if local config - * False if default config - */ -bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, - const wxString& GroupName, - bool ForceUseLocalConfig ) +bool EDA_APP::ReCreatePrjConfig( const wxString& fileName, + const wxString& GroupName, + bool ForceUseLocalConfig ) { wxFileName fn = fileName; wxString defaultFileName; @@ -89,7 +79,9 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); if( version > 0 ) + { return true; + } else { delete m_ProjectConfig; // Version incorrect @@ -118,15 +110,9 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, } -/** - * Function WriteProjectConfig - * Save the current "projet" parameters - * saved parameters are parameters that have the .m_Setup member set to false - * saving file is the .pro file project - */ -void WinEDA_App::WriteProjectConfig( const wxString& fileName, - const wxString& GroupName, - PARAM_CFG_BASE** List ) +void EDA_APP::WriteProjectConfig( const wxString& fileName, + const wxString& GroupName, + PARAM_CFG_BASE** List ) { PARAM_CFG_BASE* pt_cfg; wxString msg; @@ -155,6 +141,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, for( ; List != NULL && *List != NULL; List++ ) { pt_cfg = *List; + if( pt_cfg->m_Group ) m_ProjectConfig->SetPath( pt_cfg->m_Group ); else @@ -169,7 +156,9 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, m_ProjectConfig->DeleteGroup( pt_cfg->m_Ident ); } else + { pt_cfg->SaveParam( m_ProjectConfig ); + } } m_ProjectConfig->SetPath( UNIX_STRING_DIR_SEP ); @@ -178,9 +167,9 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, } -void WinEDA_App::WriteProjectConfig( const wxString& fileName, - const wxString& GroupName, - PARAM_CFG_ARRAY& params ) +void EDA_APP::WriteProjectConfig( const wxString& fileName, + const wxString& GroupName, + PARAM_CFG_ARRAY& params ) { ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG ); @@ -216,7 +205,9 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, m_ProjectConfig->DeleteGroup( param.m_Ident ); } else + { param.SaveParam( m_ProjectConfig ); + } } m_ProjectConfig->SetPath( UNIX_STRING_DIR_SEP ); @@ -231,7 +222,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, * saved parameters are parameters that have the .m_Setup member set to true * @param aList = array of PARAM_CFG_BASE pointers */ -void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList ) +void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_BASE** aList ) { PARAM_CFG_BASE* pt_cfg; @@ -250,12 +241,14 @@ void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList ) m_EDA_Config->DeleteGroup( pt_cfg->m_Ident ); } else + { pt_cfg->SaveParam( m_EDA_Config ); + } } } -void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ) +void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ) { if( m_EDA_Config == NULL ) return; @@ -276,24 +269,10 @@ void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ) } -/** - * Function ReadProjectConfig - * Read the current "projet" parameters - * Parameters are parameters that have the .m_Setup member set to false - * read file is the .pro file project - * - * if Load_Only_if_New == true, this file is read only if it differs from - * the current config (different dates ) - * - * @return true if read. - * Also set: - * wxGetApp().m_CurrentOptionFileDateAndTime - * wxGetApp().m_CurrentOptionFile - */ -bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_BASE** List, - bool Load_Only_if_New ) +bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, + const wxString& GroupName, + PARAM_CFG_BASE** List, + bool Load_Only_if_New ) { PARAM_CFG_BASE* pt_cfg; wxString timestamp; @@ -302,6 +281,7 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); timestamp = m_ProjectConfig->Read( wxT( "update" ) ); + if( Load_Only_if_New && ( !timestamp.IsEmpty() ) && (timestamp == m_CurrentOptionFileDateAndTime) ) { @@ -311,12 +291,13 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, m_CurrentOptionFileDateAndTime = timestamp; if( !g_Prj_Default_Config_FullFilename.IsEmpty() ) + { m_CurrentOptionFile = g_Prj_Default_Config_FullFilename; + } else { if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() ) - m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + - g_Prj_Config_LocalFilename; + m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename; else m_CurrentOptionFile = g_Prj_Config_LocalFilename; } @@ -324,6 +305,7 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, for( ; List != NULL && *List != NULL; List++ ) { pt_cfg = *List; + if( pt_cfg->m_Group ) m_ProjectConfig->SetPath( pt_cfg->m_Group ); else @@ -342,10 +324,10 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, } -bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_ARRAY& params, - bool Load_Only_if_New ) +bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, + const wxString& GroupName, + PARAM_CFG_ARRAY& params, + bool Load_Only_if_New ) { wxString timestamp; @@ -353,6 +335,7 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); timestamp = m_ProjectConfig->Read( wxT( "update" ) ); + if( Load_Only_if_New && ( !timestamp.IsEmpty() ) && (timestamp == m_CurrentOptionFileDateAndTime) ) { @@ -362,12 +345,13 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, m_CurrentOptionFileDateAndTime = timestamp; if( !g_Prj_Default_Config_FullFilename.IsEmpty() ) + { m_CurrentOptionFile = g_Prj_Default_Config_FullFilename; + } else { if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() ) - m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + - g_Prj_Config_LocalFilename; + m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename; else m_CurrentOptionFile = g_Prj_Config_LocalFilename; } @@ -392,19 +376,14 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, } -/** - * Function ReadCurrentSetupValues - * Raed the current setup values previously saved, from m_EDA_Config - * saved parameters are parameters that have the .m_Setup member set to true - * @param aList = array of PARAM_CFG_BASE pointers - */ -void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList ) +void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_BASE** aList ) { PARAM_CFG_BASE* pt_cfg; for( ; *aList != NULL; aList++ ) { pt_cfg = *aList; + if( pt_cfg->m_Setup == false ) continue; @@ -413,7 +392,7 @@ void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList ) } -void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ) +void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ) { BOOST_FOREACH( PARAM_CFG_BASE& param, List ) { @@ -468,6 +447,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + int itmp = aConfig->Read( m_Ident, m_Default ); if( (itmp < m_Min) || (itmp > m_Max) ) @@ -485,6 +465,7 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + aConfig->Write( m_Ident, *m_Pt_param ); } @@ -536,6 +517,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + aConfig->Write( m_Ident, *m_Pt_param ); } @@ -577,18 +559,23 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + double ftmp = 0; wxString msg; msg = aConfig->Read( m_Ident, wxT( "" ) ); if( msg.IsEmpty() ) + { ftmp = m_Default; + } else { msg.ToDouble( &ftmp ); + if( (ftmp < m_Min) || (ftmp > m_Max) ) ftmp = m_Default; } + *m_Pt_param = ftmp; } @@ -601,6 +588,7 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + aConfig->Write( m_Ident, *m_Pt_param ); } @@ -635,6 +623,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + int itmp = aConfig->Read( m_Ident, (int) m_Default ); *m_Pt_param = itmp ? true : false; @@ -649,6 +638,7 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + aConfig->Write( m_Ident, *m_Pt_param ); } @@ -694,6 +684,7 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + aConfig->Write( m_Ident, *m_Pt_param ); } @@ -735,6 +726,7 @@ void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + wxString prm = *m_Pt_param; // filenames are stored using Unix notation prm.Replace(wxT("\\"), wxT("/") ); @@ -759,10 +751,12 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) { if( m_Pt_param == NULL || aConfig == NULL ) return; + int indexlib = 1; // We start indexlib to 1 because first // lib name is LibName1 wxString libname, id_lib; wxArrayString* libname_list = m_Pt_param; + while( 1 ) { id_lib = m_Ident; @@ -795,6 +789,7 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) unsigned indexlib = 0; wxString configkey; wxString libname; + for( ; indexlib < libname_list->GetCount(); indexlib++ ) { configkey = m_Ident; diff --git a/cvpcb/class_components_listbox.cpp b/cvpcb/class_components_listbox.cpp index b5bfd940f6..be44ee8020 100644 --- a/cvpcb/class_components_listbox.cpp +++ b/cvpcb/class_components_listbox.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "cvpcb.h" #include "cvpcb_mainframe.h" diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 003ac83081..6b1d10e24b 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "cvpcb.h" #include "cvpcb_mainframe.h" diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 6221d850bc..435db2a6ea 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -5,13 +5,11 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "cvpcb.h" #include "zones.h" -#include "bitmaps.h" #include "cvpcb_mainframe.h" #include "colors_selection.h" #include "cvpcb_id.h" @@ -39,7 +37,7 @@ const wxString titleLibLoadError( _( "Library Load Error" ) ); * MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ -void WinEDA_App::MacOpenFile(const wxString &fileName) +void EDA_APP::MacOpenFile(const wxString &fileName) { wxFileName filename = fileName; wxString oldPath; @@ -62,20 +60,20 @@ void WinEDA_App::MacOpenFile(const wxString &fileName) } // Create a new application object -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) /************************************/ /* Called to initialize the program */ /************************************/ -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { wxFileName filename; wxString message; CVPCB_MAINFRAME* frame = NULL; - InitEDA_Appl( wxT( "CvPcb" ), APP_TYPE_CVPCB ); + InitEDA_Appl( wxT( "CvPcb" ), APP_CVPCB_T ); if( m_Checker && m_Checker->IsAnotherRunning() ) { diff --git a/cvpcb/genequiv.cpp b/cvpcb/genequiv.cpp index f4f6d7866b..e07cffee12 100644 --- a/cvpcb/genequiv.cpp +++ b/cvpcb/genequiv.cpp @@ -6,7 +6,6 @@ #include "wxstruct.h" #include "confirm.h" #include "gestfich.h" -#include "macros.h" #include "cvpcb.h" #include "cvpcb_mainframe.h" diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index 5769011574..0535b93808 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "cvpcb.h" #include "cvpcb_mainframe.h" diff --git a/cvpcb/loadcmp.cpp b/cvpcb/loadcmp.cpp index 0f8a7857dd..b9a1dd2a80 100644 --- a/cvpcb/loadcmp.cpp +++ b/cvpcb/loadcmp.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/cvpcb/readschematicnetlist.cpp b/cvpcb/readschematicnetlist.cpp index a37ee38993..ef152d451a 100644 --- a/cvpcb/readschematicnetlist.cpp +++ b/cvpcb/readschematicnetlist.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "macros.h" diff --git a/cvpcb/savecmp.cpp b/cvpcb/savecmp.cpp index 3bf6f1646e..29ae2219cb 100644 --- a/cvpcb/savecmp.cpp +++ b/cvpcb/savecmp.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index eec3a46122..b28b523443 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -6,7 +6,6 @@ #include #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "wxstruct.h" diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index d71c649e6b..3c78e3523b 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -4,7 +4,6 @@ ****************************************************************/ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/eeschema/block.cpp b/eeschema/block.cpp index b23e99729c..84763e9e36 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 9c41c4df33..3d7cc0ef5e 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "block_commande.h" diff --git a/eeschema/build_BOM.cpp b/eeschema/build_BOM.cpp index cb572b7ae1..564fdc2395 100644 --- a/eeschema/build_BOM.cpp +++ b/eeschema/build_BOM.cpp @@ -8,7 +8,6 @@ #include #include "fctsys.h" -#include "common.h" #include "class_sch_screen.h" #include "kicad_string.h" diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 7a3a34aa6f..487e90f492 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index 77afe18e9f..1aea9cdac1 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "eeschema_id.h" #include "confirm.h" diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 8ccc067972..ba64a6aaf7 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -3,7 +3,6 @@ /*************************/ #include "fctsys.h" -#include "common.h" #include "macros.h" #include "kicad_string.h" #include "class_drawpanel.h" diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index c1854ac6ff..d1531bcecb 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "kicad_string.h" #include "confirm.h" diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index 5e17d223d1..2f58ed5245 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" -#include "common.h" #include "macros.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 0cb35c9307..c18d40df55 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -33,10 +33,8 @@ #include #include "fctsys.h" -#include "common.h" #include "kicad_string.h" #include "wxEeschemaStruct.h" -#include "wxstruct.h" #include "netlist.h" #include "class_sch_screen.h" #include "sch_component.h" diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index d4db4ac71e..b2573c0215 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "macros.h" #include "eda_dde.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/database.cpp b/eeschema/database.cpp index 1d4e42cc3c..387bc8a62b 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "confirm.h" #include "eda_doc.h" diff --git a/eeschema/dialogs/annotate_dialog.cpp b/eeschema/dialogs/annotate_dialog.cpp index ce915e69d6..2e4a6e1bd2 100644 --- a/eeschema/dialogs/annotate_dialog.cpp +++ b/eeschema/dialogs/annotate_dialog.cpp @@ -33,8 +33,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "bitmaps.h" -#include "common.h" #include "wxEeschemaStruct.h" #include "class_drawpanel.h" diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index 6bf3090bc5..73ca5d7c62 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -8,7 +8,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" diff --git a/eeschema/dialogs/dialog_build_BOM.cpp b/eeschema/dialogs/dialog_build_BOM.cpp index cd3db4811f..6b23f356d6 100644 --- a/eeschema/dialogs/dialog_build_BOM.cpp +++ b/eeschema/dialogs/dialog_build_BOM.cpp @@ -8,7 +8,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "kicad_string.h" diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index 8838bd48c8..9117d94584 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "wxstruct.h" #include "class_drawpanel.h" diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index f0dc86ff95..9820abb536 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "class_sch_screen.h" diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 0a932292af..a845245ba5 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -10,7 +10,6 @@ #include "wx/valgen.h" #include "wxEeschemaStruct.h" -#include "common.h" #include "class_drawpanel.h" #include "general.h" #include "drawtxt.h" diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 06dc190733..ad3fa3eca7 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -6,7 +6,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "class_drawpanel.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/dialogs/dialog_eeschema_config.cpp b/eeschema/dialogs/dialog_eeschema_config.cpp index 81390892b2..56ee35447e 100644 --- a/eeschema/dialogs/dialog_eeschema_config.cpp +++ b/eeschema/dialogs/dialog_eeschema_config.cpp @@ -9,7 +9,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 0d93b0caa4..524e8b3876 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -7,11 +7,9 @@ // License: GPL ///////////////////////////////////////////////////////////////////////////// #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "kicad_string.h" #include "gestfich.h" -#include "bitmaps.h" #include "appl_wxstruct.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/dialogs/dialog_libedit_dimensions.cpp b/eeschema/dialogs/dialog_libedit_dimensions.cpp index 5020a70f5a..4ceddb06bb 100644 --- a/eeschema/dialogs/dialog_libedit_dimensions.cpp +++ b/eeschema/dialogs/dialog_libedit_dimensions.cpp @@ -3,7 +3,6 @@ * Handles the dialog so set current texts and pins sizes in LibEdit */ #include "fctsys.h" -#include "common.h" #include "wxEeschemaStruct.h" #include "general.h" diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp index d15b5c68d4..e611f46d5f 100644 --- a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp @@ -27,7 +27,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "plot_common.h" #include "confirm.h" diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index da8fbe662e..c9cb6edc4e 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -27,7 +27,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "confirm.h" #include "plot_common.h" #include "worksheet.h" diff --git a/eeschema/dialogs/dialog_plot_schematic_PS.cpp b/eeschema/dialogs/dialog_plot_schematic_PS.cpp index c0c94515d5..89e480644e 100644 --- a/eeschema/dialogs/dialog_plot_schematic_PS.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_PS.cpp @@ -27,7 +27,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "confirm.h" #include "worksheet.h" #include "plot_common.h" diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 7bb79ba898..630899caa7 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "class_sch_screen.h" diff --git a/eeschema/edit_bitmap.cpp b/eeschema/edit_bitmap.cpp index 3088d8a0fe..2c122e9a0d 100644 --- a/eeschema/edit_bitmap.cpp +++ b/eeschema/edit_bitmap.cpp @@ -31,7 +31,6 @@ #include "macros.h" #include "class_drawpanel.h" #include "trigo.h" -#include "common.h" #include "richio.h" #include "plot_common.h" diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index c3e8f5c7dd..d2024e00e2 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "class_sch_screen.h" diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 1de5405814..1d1738b675 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "base_struct.h" #include "drawtxt.h" #include "class_drawpanel.h" diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 044bf28642..058a62f330 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "appl_wxstruct.h" #include "class_sch_screen.h" diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index feb274793b..ce147bf6f4 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -4,11 +4,9 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" -#include "bitmaps.h" #include "eda_dde.h" #include "id.h" #include "class_sch_screen.h" @@ -80,12 +78,12 @@ TRANSFORM DefaultTransform = TRANSFORM( 1, 0, 0, -1 ); // static object for many reasons) and also declares the accessor function // wxGetApp() which will return the reference of the right type (i.e. MyApp and // not wxApp) -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) /* MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ -void WinEDA_App::MacOpenFile( const wxString &fileName ) +void EDA_APP::MacOpenFile( const wxString &fileName ) { wxFileName filename = fileName; SCH_EDIT_FRAME* frame = ((SCH_EDIT_FRAME*) GetTopWindow()); @@ -100,12 +98,12 @@ void WinEDA_App::MacOpenFile( const wxString &fileName ) } -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { wxFileName filename; SCH_EDIT_FRAME* frame = NULL; - InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA ); + InitEDA_Appl( wxT( "EESchema" ), APP_EESCHEMA_T ); if( m_Checker && m_Checker->IsAnotherRunning() ) { diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 19256ed39c..6dc90c70fd 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 77cff1dd32..9d004665db 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -3,10 +3,8 @@ /**************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "kicad_string.h" -#include "bitmaps.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/events_called_functions_for_edit.cpp b/eeschema/events_called_functions_for_edit.cpp index bb220e1393..ba9ce21cd5 100644 --- a/eeschema/events_called_functions_for_edit.cpp +++ b/eeschema/events_called_functions_for_edit.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "general.h" #include "kicad_device_context.h" diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 4c4145b07f..35cb1cb2e7 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -3,7 +3,6 @@ /****************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 11edc02c94..b0d7828076 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -9,7 +9,6 @@ */ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index bf7ccd9748..07e9be0855 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "class_sch_screen.h" diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 1e3cade248..7dfb384c7d 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -3,10 +3,8 @@ /******************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" -#include "bitmaps.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 6f3712b230..29c7f0a509 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -3,7 +3,6 @@ /***************/ #include "fctsys.h" -#include "common.h" #include "eeschema_id.h" #include "hotkeys.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 685f369a66..a906b7a3e9 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 4f27a9c368..6f35b59f75 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index e15f84493a..aaafa164e9 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index 9eab8faae7..de2848fe90 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -9,7 +9,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 8c5faf867a..ee330bdf38 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "base_struct.h" #include "drawtxt.h" diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 987338ff78..be52de47a3 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -11,7 +11,6 @@ #include "drawtxt.h" #include "plot_common.h" #include "wxEeschemaStruct.h" -#include "bitmaps.h" #include "general.h" #include "protos.h" diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 0dcb99db1f..fde94b08b9 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -4,7 +4,7 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" + #include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 79a63d96d4..a6d5b43489 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index af0722bc8a..c21ff6e3b2 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -9,7 +9,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 0120f1bd4e..6622d8a9db 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -3,7 +3,6 @@ /* Module for generation of component archive files. */ /*****************************************************/ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "class_sch_screen.h" #include "wxstruct.h" diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 30b967588c..59dd71cea0 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index 28364ab3dc..ea343eb5d2 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "eeschema_id.h" diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp index 2a1354c6a6..356f1f7453 100644 --- a/eeschema/libedit_plot_component.cpp +++ b/eeschema/libedit_plot_component.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index dfb7af9d9c..b59907ff12 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "class_drawpanel.h" -#include "common.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index 26c640192b..d9a9878a6b 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -4,13 +4,11 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "class_sch_screen.h" #include "general.h" -//#include "protos.h" #include "sch_component.h" #include "libeditframe.h" #include "class_library.h" diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 14169bad8a..9743f8fa2f 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -31,7 +31,6 @@ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 3ce4e348da..09e7a8e6e7 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -3,7 +3,6 @@ /*****************/ #include "fctsys.h" -#include "common.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index bd220b1fbd..d685eb74aa 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -14,7 +14,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 62570f584a..10ace3dcc5 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -3,7 +3,6 @@ /*******************/ #include "fctsys.h" -#include "common.h" #include "eeschema_id.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index 55e0688071..41c0765451 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -6,7 +6,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 0f3772e55b..8595088a06 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -3,7 +3,6 @@ /***************************/ #include "fctsys.h" -#include "common.h" #include "gr_basic.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 233bfd4921..a671308bf6 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -31,7 +31,6 @@ #include "macros.h" #include "class_drawpanel.h" #include "trigo.h" -#include "common.h" #include "richio.h" #include "plot_common.h" diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index ac0171b637..e11eae846d 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -6,7 +6,6 @@ #include "appl_wxstruct.h" #include "class_drawpanel.h" #include "gr_basic.h" -#include "common.h" #include "trigo.h" #include "kicad_string.h" #include "richio.h" diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 8f4b918347..b7cac00754 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -11,7 +11,6 @@ */ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "base_struct.h" #include "gr_basic.h" diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index 3c0f5cab6f..8f5683dd0e 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "wxstruct.h" #include "class_drawpanel.h" -#include "common.h" #include "trigo.h" #include "general.h" diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 205de2ab21..6034fc04e0 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1,7 +1,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "kicad_string.h" #include "eeschema_id.h" #include "appl_wxstruct.h" diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index b1cc78179f..908c53b76d 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -12,7 +12,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "drawtxt.h" diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 5b445d23f2..946e61e889 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -9,7 +9,6 @@ #include "fctsys.h" -#include "common.h" #include "general.h" #include "dlist.h" #include "class_sch_screen.h" diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index e7105588df..c425ee0e56 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -12,7 +12,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "drawtxt.h" #include "plot_common.h" diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index ee040316c8..82d3f1663d 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "trigo.h" #include "eeschema_id.h" diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index ddc6704463..d942c3991c 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 676779a807..d2b7fda7ae 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -3,7 +3,6 @@ /************************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 6ddfed1d8b..a61ef8f094 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -8,11 +8,9 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "gr_basic.h" #include "class_drawpanel.h" #include "gestfich.h" -#include "bitmaps.h" #include "general.h" #include "protos.h" diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index 2928ce5686..4c9741848c 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "confirm.h" #include "wxstruct.h" diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index e8b2bca465..9af2668559 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -11,7 +11,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 0877b9edff..cc76b41d7e 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index e39a04318d..0d28644ccc 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "macros.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index d808ca9fe1..3bea465d57 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -3,9 +3,7 @@ /******************/ #include "fctsys.h" -#include "common.h" #include "hotkeys.h" -#include "bitmaps.h" #include "eeschema_id.h" #include "general.h" diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index d464794592..3cce9fdc01 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -3,14 +3,10 @@ /******************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" -//#include "confirm.h" -#include "bitmaps.h" #include "wxEeschemaStruct.h" #include "general.h" -//#include "protos.h" #include "hotkeys.h" #include "eeschema_id.h" diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index 18ce2055cf..5e66926dd8 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -3,11 +3,8 @@ /****************************************************************/ #include "fctsys.h" -#include "common.h" -#include "bitmaps.h" #include "macros.h" #include "eeschema_id.h" -#include "wxstruct.h" #include "general.h" #include "protos.h" diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 360334d3d8..6c5abd615e 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -4,10 +4,8 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "eeschema_id.h" #include "class_drawpanel.h" -#include "bitmaps.h" #include "class_sch_screen.h" #include "wxEeschemaStruct.h" diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index cd68336aa8..5399d2a822 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -4,12 +4,10 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" -#include "wxstruct.h" #include "class_sch_screen.h" #include "general.h" diff --git a/gerbview/class_DCodeSelectionbox.cpp b/gerbview/class_DCodeSelectionbox.cpp index c538f93cf4..116e3de921 100644 --- a/gerbview/class_DCodeSelectionbox.cpp +++ b/gerbview/class_DCodeSelectionbox.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "gerbview.h" diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index 151a35ac96..98be784d14 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -3,7 +3,6 @@ /************************************************/ #include "fctsys.h" -#include "common.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" #include "confirm.h" @@ -12,7 +11,6 @@ #include "gerbview.h" #include "gerbview_id.h" #include "pcbplot.h" -#include "bitmaps.h" #include "zones.h" #include "class_board_design_settings.h" #include "colors_selection.h" @@ -42,12 +40,12 @@ Ki_PageDescr* g_GerberPageSizeList[] = }; -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) /* MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ -void WinEDA_App::MacOpenFile(const wxString &fileName) +void EDA_APP::MacOpenFile(const wxString &fileName) { wxFileName filename = fileName; GERBVIEW_FRAME * frame = ((GERBVIEW_FRAME*)GetTopWindow()); @@ -59,18 +57,19 @@ void WinEDA_App::MacOpenFile(const wxString &fileName) } -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { wxFileName fn; GERBVIEW_FRAME* frame = NULL; - InitEDA_Appl( wxT( "GerbView" ), APP_TYPE_GERBVIEW ); + InitEDA_Appl( wxT( "GerbView" ), APP_GERBVIEW_T ); if( m_Checker && m_Checker->IsAnotherRunning() ) { if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) ) return false; } + ScreenPcb = new PCB_SCREEN(); ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; @@ -85,9 +84,7 @@ bool WinEDA_App::OnInit() * display the real hotkeys in menus or tool tips */ ReadHotkeyConfig( wxT("GerberFrame"), s_Gerbview_Hokeys_Descr ); - frame = new GERBVIEW_FRAME( NULL, wxT( "GerbView" ), - wxPoint( 0, 0 ), - wxSize( 600, 400 ) ); + frame = new GERBVIEW_FRAME( NULL, wxT( "GerbView" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); /* Gerbview mainframe title */ frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); @@ -116,6 +113,7 @@ bool WinEDA_App::OnInit() // Load all files specified on the command line. int jj = 0; + for( int ii = 1; ii < argc && ii <= LAYER_COUNT; ++ii ) { fn = wxFileName( argv[ii] ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index eca5ab8684..b9fc48de6e 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -5,13 +5,11 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "gerbview.h" #include "class_gerber_draw_item.h" #include "pcbplot.h" -#include "bitmaps.h" #include "gerbview_id.h" #include "hotkeys.h" #include "class_GERBER.h" @@ -31,10 +29,10 @@ const wxString GerbviewShowDCodes( wxT( "ShowDCodesOpt" ) ); GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style ) : + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style ) : PCB_BASE_FRAME( father, GERBER_FRAME, title, pos, size, style ) { m_FrameName = wxT( "GerberFrame" ); diff --git a/include/appl_wxstruct.h b/include/appl_wxstruct.h index 620e7d233f..8f8ebdd0c8 100644 --- a/include/appl_wxstruct.h +++ b/include/appl_wxstruct.h @@ -1,7 +1,7 @@ -/******************************************/ -/* appl_wxstruct.h */ -/* Base application class implementation. */ -/******************************************/ +/** + * @file appl_wxstruct.h + * @brief Base class implementation for all Kicad applications. + */ #ifndef APPL_WXSTRUCT_H #define APPL_WXSTRUCT_H @@ -13,13 +13,13 @@ #include "param_config.h" -enum id_app_type { - APP_TYPE_UNKOWN, - APP_TYPE_EESCHEMA, - APP_TYPE_PCBNEW, - APP_TYPE_CVPCB, - APP_TYPE_GERBVIEW, - APP_TYPE_KICAD +enum EDA_APP_T { + APP_UNKNOWN_T, + APP_EESCHEMA_T, + APP_PCBNEW_T, + APP_CVPCB_T, + APP_GERBVIEW_T, + APP_KICAD_T }; class wxConfigBase; @@ -28,18 +28,15 @@ class wxSingleInstanceChecker; class wxHtmlHelpController; -/**********************************************/ -/* Class representing the entire Application */ -/**********************************************/ - -class WinEDA_App : public wxApp +/** + * Class EDA_APP + * is the base class representing all of Kicad applications. + */ +class EDA_APP : public wxApp { public: - id_app_type m_Id; /* Used mainly to handle - * default paths libs - * m_Id = APP_TYPE_EESCHEMA, - * APP_TYPE_PCBNEW ... - */ + EDA_APP_T m_Id; /* Used mainly to handle default paths libs + * m_Id = APP_EESCHEMA_T, APP_PCBNEW_T ... */ wxString m_Project; wxSingleInstanceChecker* m_Checker; @@ -56,8 +53,7 @@ public: wxString m_BinDir; /* Kicad executable path.*/ wxString m_KicadEnv; /* environment variable KICAD */ - bool m_Env_Defined; // TRUE if environment KICAD is - // defined. + bool m_Env_Defined; // TRUE if environment KICAD is defined. wxLocale* m_Locale; // The current locale. int m_LanguageId; // The current language setting. @@ -74,29 +70,29 @@ protected: wxFileName m_projectFileName; wxString m_LastVisitedLibPath; -public: WinEDA_App(); - ~WinEDA_App(); +public: EDA_APP(); + ~EDA_APP(); /** * Function OnInit * this is the first executed function (like main() ) * @return true if the application can be started. */ - bool OnInit(); + bool OnInit(); /** * Function SetBinDir - * finds the path to the executable and store it in WinEDA_App::m_BinDir + * finds the path to the executable and store it in EDA_APP::m_BinDir * * @return TODO */ - bool SetBinDir(); + bool SetBinDir(); /** * Function SetDefaultSearchPaths * sets search paths for libraries, modules, internationalization files, etc. */ - void SetDefaultSearchPaths( void ); + void SetDefaultSearchPaths( void ); /** * Function MacOpenFile @@ -116,8 +112,7 @@ public: WinEDA_App(); * @param aId = flag : LIBRARY_TYPE_EESCHEMA or LIBRARY_TYPE_PCBNEW * used to choose what default library path must be used */ - void InitEDA_Appl( const wxString& aName, - id_app_type aId = APP_TYPE_UNKOWN ); + void InitEDA_Appl( const wxString& aName, EDA_APP_T aId = APP_UNKNOWN_T ); /** * Function SetLanguage @@ -129,7 +124,7 @@ public: WinEDA_App(); * called, false otherwise * @return true if the language can be set (i.e. if the locale is available) */ - bool SetLanguage( bool first_time = false ); + bool SetLanguage( bool first_time = false ); /** * Function AddMenuLanguageList @@ -138,7 +133,7 @@ public: WinEDA_App(); * @param MasterMenu The main menu. The sub menu list will be accessible from the menu * item with id ID_LANGUAGE_CHOICE */ - void AddMenuLanguageList( wxMenu* MasterMenu ); + void AddMenuLanguageList( wxMenu* MasterMenu ); /** * Function SetLanguageIdentifier @@ -148,15 +143,15 @@ public: WinEDA_App(); * @param menu_id The kicad menuitem id (returned by Menu Event, when * clicking on a menu item) */ - void SetLanguageIdentifier( int menu_id ); + void SetLanguageIdentifier( int menu_id ); - void SetLanguagePath( void ); + void SetLanguagePath( void ); /** * Function InitOnLineHelp * initializes Kicad's online help. */ - void InitOnLineHelp(); + void InitOnLineHelp(); /** * Function GetSettings @@ -164,20 +159,26 @@ public: WinEDA_App(); * @param aReopenLastUsedDirectory True to switch to last opened directory, false * to use current CWD */ - void GetSettings( bool aReopenLastUsedDirectory ); + void GetSettings( bool aReopenLastUsedDirectory ); /** * Function SaveSettings * saves the application settings. */ - void SaveSettings(); + void SaveSettings(); - void WriteProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_BASE** List ); - void WriteProjectConfig( const wxString& fileName, - const wxString& GroupName, - PARAM_CFG_ARRAY& params ); + /** + * Function WriteProjectConfig + * Save the current "projet" parameters + * saved parameters are parameters that have the .m_Setup member set to false + * saving file is the .pro file project + */ + void WriteProjectConfig( const wxString& local_config_filename, + const wxString& GroupName, + PARAM_CFG_BASE** List ); + void WriteProjectConfig( const wxString& fileName, + const wxString& GroupName, + PARAM_CFG_ARRAY& params ); /** * Function SaveCurrentSetupValues @@ -186,8 +187,8 @@ public: WinEDA_App(); * true * @param aList = array of PARAM_CFG_BASE pointers */ - void SaveCurrentSetupValues( PARAM_CFG_BASE** aList ); - void SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ); + void SaveCurrentSetupValues( PARAM_CFG_BASE** aList ); + void SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ); /** * Function ReadCurrentSetupValues @@ -196,30 +197,55 @@ public: WinEDA_App(); * true * @param aList = array of PARAM_CFG_BASE pointers */ - void ReadCurrentSetupValues( PARAM_CFG_BASE** aList ); - void ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ); + void ReadCurrentSetupValues( PARAM_CFG_BASE** aList ); + void ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ); - bool ReadProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_BASE** List, - bool Load_Only_if_New ); - bool ReadProjectConfig( const wxString& local_config_filename, - const wxString& GroupName, - PARAM_CFG_ARRAY& List, - bool Load_Only_if_New ); - bool ReCreatePrjConfig( const wxString& local_config_filename, - const wxString& GroupName, - bool ForceUseLocalConfig ); + /** + * Function ReadProjectConfig + * Read the current "projet" parameters + * Parameters are parameters that have the .m_Setup member set to false + * read file is the .pro file project + * + * if Load_Only_if_New == true, this file is read only if it differs from + * the current config (different dates ) + * + * @return true if read. + * Also set: + * wxGetApp().m_CurrentOptionFileDateAndTime + * wxGetApp().m_CurrentOptionFile + */ + bool ReadProjectConfig( const wxString& local_config_filename, + const wxString& GroupName, + PARAM_CFG_BASE** List, + bool Load_Only_if_New ); + bool ReadProjectConfig( const wxString& local_config_filename, + const wxString& GroupName, + PARAM_CFG_ARRAY& List, + bool Load_Only_if_New ); - void ReadPdfBrowserInfos(); - void WritePdfBrowserInfos(); + /** + * Creates or recreates the kicad project file. (filename.pro) + * Initialize: + * G_Prj_Config + * G_Prj_Config_LocalFilename + * G_Prj_Default_Config_FullFilename + * Return: + * True if local config + * False if default config + */ + bool ReCreatePrjConfig( const wxString& local_config_filename, + const wxString& GroupName, + bool ForceUseLocalConfig ); + + void ReadPdfBrowserInfos(); + void WritePdfBrowserInfos(); /** * Function FindFileInSearchPaths * looks in search paths for \a filename. */ - wxString FindFileInSearchPaths( const wxString& filename, - const wxArrayString* subdirs = NULL ); + wxString FindFileInSearchPaths( const wxString& filename, + const wxArrayString* subdirs = NULL ); /** * Function GetHelpFile @@ -238,9 +264,13 @@ public: WinEDA_App(); * help/en *

    */ - wxString GetHelpFile( void ); + wxString GetHelpFile( void ); - wxString GetLibraryFile( const wxString& filename ); + wxString GetLibraryFile( const wxString& filename ); + + /** + * Return the preferred editor name. + */ wxString& GetEditorName(); const wxString& GetTitle() { return m_Title; } @@ -273,7 +303,7 @@ public: WinEDA_App(); */ wxString ReturnLastVisitedLibraryPath( const wxString& aSubPathToSearch = wxEmptyString ); - void SaveLastVisitedLibraryPath( const wxString& aPath ); + void SaveLastVisitedLibraryPath( const wxString& aPath ); /** * Function ReturnFilenameWithRelativePathInLibPath @@ -289,7 +319,7 @@ public: WinEDA_App(); * @param aPaths = path or path list to remove. paths must be separated by * ";" */ - void RemoveLibraryPath( const wxString& aPaths ); + void RemoveLibraryPath( const wxString& aPaths ); /** * Function InsertLibraryPath @@ -297,14 +327,14 @@ public: WinEDA_App(); * @param aPaths = path or path list to add. paths must be separated by ";" * @param aIndex = insertion point */ - void InsertLibraryPath( const wxString& aPaths, size_t aIndex ); + void InsertLibraryPath( const wxString& aPaths, size_t aIndex ); }; /* - * Use wxGetApp() to access WinEDA_App. It is not necessary to keep copies + * Use wxGetApp() to access EDA_APP. It is not necessary to keep copies * of the application pointer all over the place or worse yet in a global * variable. */ -DECLARE_APP( WinEDA_App ) +DECLARE_APP( EDA_APP ) #endif /* APPL_WXSTRUCT_H */ diff --git a/kicad/class_treeproject_item.cpp b/kicad/class_treeproject_item.cpp index ee00428e0c..29100b70f7 100644 --- a/kicad/class_treeproject_item.cpp +++ b/kicad/class_treeproject_item.cpp @@ -6,7 +6,6 @@ */ #include "fctsys.h" -#include "common.h" #include "gestfich.h" #include "kicad.h" diff --git a/kicad/class_treeprojectfiles.cpp b/kicad/class_treeprojectfiles.cpp index 1500dcf5a8..2431ea4798 100644 --- a/kicad/class_treeprojectfiles.cpp +++ b/kicad/class_treeprojectfiles.cpp @@ -4,8 +4,6 @@ */ #include "fctsys.h" -#include "common.h" -#include "bitmaps.h" #include "kicad.h" #include "tree_project_frame.h" diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index 050054655e..525d43b169 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -3,8 +3,6 @@ /*****************************************************/ #include "fctsys.h" -#include "common.h" -#include "bitmaps.h" #include "macros.h" #include "kicad.h" diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 9155c40683..8b158e8672 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -14,8 +14,6 @@ #include #include -#include "common.h" -#include "bitmaps.h" #include "confirm.h" #include "gestfich.h" #include "macros.h" diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 60690d6af2..13ef1dab59 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -5,9 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" -#include "bitmaps.h" -#include "colors.h" #ifdef USE_SPLASH_IMAGE #define SPLASH_IMAGE logo_kicad.png @@ -17,7 +14,6 @@ #include "kicad.h" #include "tree_project_frame.h" -#include "macros.h" #include "build_version.h" @@ -34,12 +30,12 @@ void ShowLogo( char* FonteFileName ); /************************************/ // Create a new application object -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) /* MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ -void WinEDA_App::MacOpenFile( const wxString &fileName ) +void EDA_APP::MacOpenFile( const wxString &fileName ) { KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) GetTopWindow(); wxFileName fn = fileName; @@ -62,7 +58,7 @@ void WinEDA_App::MacOpenFile( const wxString &fileName ) } wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() + - wxT( " " ) + frame->m_ProjectFileName.GetFullPath(); + wxT( " " ) + frame->m_ProjectFileName.GetFullPath(); if( !fn.IsDirWritable() ) title += _( " [Read Only]" ); @@ -77,11 +73,11 @@ void WinEDA_App::MacOpenFile( const wxString &fileName ) } -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { KICAD_MANAGER_FRAME* frame; - InitEDA_Appl( wxT( "KiCad" ), APP_TYPE_KICAD ); + InitEDA_Appl( wxT( "KiCad" ), APP_KICAD_T ); // read current setup and reopen last directory if no filename to open in command line bool reopenLastUsedDirectory = argc == 1; @@ -120,7 +116,7 @@ bool WinEDA_App::OnInit() } wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() + - wxT( " " ) + frame->m_ProjectFileName.GetFullPath(); + wxT( " " ) + frame->m_ProjectFileName.GetFullPath(); if( !namelessProject.IsDirWritable() ) title += _( " [Read Only]" ); @@ -136,7 +132,7 @@ bool WinEDA_App::OnInit() #ifdef USE_SPLASH_IMAGE wxBitmap bmp; wxString binDir = GetTraits()->GetStandardPaths().GetExecutablePath() + - wxFileName::GetPathSeparator(); + wxFileName::GetPathSeparator(); if( bmp.LoadFile( binDir + _T( "logokicad.png" ), wxBITMAP_TYPE_PNG ) ) { diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 89820cfd26..7f762fe255 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -8,10 +8,8 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" -#include "bitmaps.h" #include "macros.h" #include "kicad.h" diff --git a/kicad/preferences.cpp b/kicad/preferences.cpp index 56c6d84cf4..fd09182ec7 100644 --- a/kicad/preferences.cpp +++ b/kicad/preferences.cpp @@ -8,10 +8,8 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" -#include "bitmaps.h" #include "kicad.h" diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index a4d281356f..68a5d14c26 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "prjconfig.h" diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index 41397a9bad..07b394f1d0 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -5,11 +5,9 @@ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "appl_wxstruct.h" -#include "bitmaps.h" #include "kicad.h" #include "tree_project_frame.h" diff --git a/pcb_calculator/pcb_calculator.cpp b/pcb_calculator/pcb_calculator.cpp index ad6db87cd6..3595d5fac6 100644 --- a/pcb_calculator/pcb_calculator.cpp +++ b/pcb_calculator/pcb_calculator.cpp @@ -24,7 +24,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" @@ -40,18 +39,18 @@ // PCB_CALCULATOR_APP -void WinEDA_App::MacOpenFile(const wxString &fileName) +void EDA_APP::MacOpenFile(const wxString &fileName) { } -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) ///----------------------------------------------------------------------------- // PCB_CALCULATOR_APP // main program //----------------------------------------------------------------------------- -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { InitEDA_Appl( wxT( "PCBcalc" ) ); diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index 5ec824e015..5afd30c459 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -3,7 +3,6 @@ /******************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index 407839b52f..cda447d3ad 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -5,7 +5,6 @@ #include #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 8a65421826..05e306362d 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -3,7 +3,6 @@ /*******************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 598b05cb63..48a2fafbc4 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -3,7 +3,6 @@ /***************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 00914b5b98..cb517f4260 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -8,14 +8,12 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "confirm.h" #include "appl_wxstruct.h" #include "dialog_helpers.h" #include "kicad_device_context.h" #include "pcbnew.h" -#include "bitmaps.h" #include "pcbnew_id.h" #include "class_board_design_settings.h" diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 0102ae247a..361ba69e9a 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "block_commande.h" diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index a4f4efce02..76712c0575 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -6,7 +6,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "block_commande.h" diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index eaacba97fb..83d57a3946 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -8,7 +8,6 @@ #include #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index 74235fa451..5604cf9ef4 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -3,7 +3,6 @@ /*************************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/build_BOM_from_board.cpp b/pcbnew/build_BOM_from_board.cpp index de46aa7ab8..f5210f78b9 100644 --- a/pcbnew/build_BOM_from_board.cpp +++ b/pcbnew/build_BOM_from_board.cpp @@ -2,7 +2,6 @@ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 627747af53..4d48346f73 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "pcbnew.h" #include "trigo.h" #include "wxstruct.h" diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 91b0c3e421..8d98652228 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -6,7 +6,6 @@ #include "wxstruct.h" #include "gr_basic.h" #include "bezier_curves.h" -#include "common.h" #include "class_drawpanel.h" #include "kicad_string.h" #include "colors_selection.h" diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 127a28e237..aeed51852b 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" #include "wxstruct.h" -#include "common.h" #include "trigo.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index c574ab070a..0b227f9654 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" #include "wxstruct.h" -#include "common.h" #include "plot_common.h" #include "class_drawpanel.h" #include "trigo.h" diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp index b2f99ff2b8..29adafeaa9 100644 --- a/pcbnew/class_module_transform_functions.cpp +++ b/pcbnew/class_module_transform_functions.cpp @@ -6,7 +6,6 @@ #include "fctsys.h" #include "wxstruct.h" -#include "common.h" #include "trigo.h" #include "pcbcommon.h" diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 6d8b92cb96..bab4595b4a 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -30,14 +30,12 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "pcbstruct.h" // enum PCB_VISIBLE #include "collectors.h" -#include "bitmaps.h" #include "pcbnew_id.h" #include "layer_widget.h" #include "class_pcb_layer_widget.h" diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index e35c83e884..d658ecf160 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -6,7 +6,6 @@ #include "wxstruct.h" #include "gr_basic.h" #include "base_struct.h" -#include "common.h" #include "drawtxt.h" #include "kicad_string.h" diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index be3678d64d..e6da8b0584 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" #include "wxstruct.h" -#include "common.h" #include "pcbnew.h" #include "trigo.h" #include "class_drawpanel.h" diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 69e137de99..c78b168308 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "wxstruct.h" #include "gr_basic.h" -#include "common.h" #include "trigo.h" #include "class_drawpanel.h" #include "kicad_string.h" diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index 6e98fc9e5c..8cee96172d 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index be0634edec..9f1b91516c 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -13,7 +13,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "eda_dde.h" diff --git a/pcbnew/debug_kbool_key_file_fct.cpp b/pcbnew/debug_kbool_key_file_fct.cpp index 81bb9eb48c..84cb1d8171 100644 --- a/pcbnew/debug_kbool_key_file_fct.cpp +++ b/pcbnew/debug_kbool_key_file_fct.cpp @@ -3,7 +3,6 @@ #include #include "fctsys.h" -#include "common.h" #include "kicad_string.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 2bbe6ba1a0..ae3dc70700 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -4,7 +4,6 @@ /******************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index c57de649a9..736c5af076 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -10,7 +10,6 @@ #include #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "PolyLine.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index 68417a891e..214a555a52 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -31,7 +31,6 @@ /* functions relatives to the design rules editor */ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index a957710384..70a3379ca4 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -6,7 +6,6 @@ Prefernces/display */ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 1b1c08878f..dfe0749871 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -7,9 +7,7 @@ #include "fctsys.h" -#include "wxstruct.h" #include "dialog_drc.h" -#include "common.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 6353565729..9502bffc3d 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -3,11 +3,9 @@ ******************************************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" -#include "bitmaps.h" #include "appl_wxstruct.h" #include "gestfich.h" #include "3d_struct.h" diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 9443ae2682..5d214ff2f9 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -3,11 +3,9 @@ /*******************************************************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" -#include "bitmaps.h" #include "appl_wxstruct.h" #include "gestfich.h" #include "3d_struct.h" diff --git a/pcbnew/dialogs/dialog_freeroute_exchange.cpp b/pcbnew/dialogs/dialog_freeroute_exchange.cpp index 272aea38ec..f0b2463974 100644 --- a/pcbnew/dialogs/dialog_freeroute_exchange.cpp +++ b/pcbnew/dialogs/dialog_freeroute_exchange.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 5b41508008..8a1428e328 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -8,7 +8,6 @@ * Preferences/display */ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index 05a91e3669..14613e83cd 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index fda08ee743..6e93e027b3 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -7,7 +7,6 @@ ///////////////////////////////////////////////////////////////////////////// #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 6cd2b9c577..4117eb6e1f 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -12,7 +12,6 @@ */ #include "fctsys.h" #include "macros.h" -#include "common.h" #include "confirm.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_graphic_items_options.cpp b/pcbnew/dialogs/dialog_graphic_items_options.cpp index 4cc15e6a22..537c76858d 100644 --- a/pcbnew/dialogs/dialog_graphic_items_options.cpp +++ b/pcbnew/dialogs/dialog_graphic_items_options.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" diff --git a/pcbnew/dialogs/dialog_layers_setup.cpp b/pcbnew/dialogs/dialog_layers_setup.cpp index 4335d8fd6c..829973014e 100644 --- a/pcbnew/dialogs/dialog_layers_setup.cpp +++ b/pcbnew/dialogs/dialog_layers_setup.cpp @@ -25,7 +25,6 @@ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/dialogs/dialog_mask_clearance.cpp b/pcbnew/dialogs/dialog_mask_clearance.cpp index 22db1ae505..beb4294850 100644 --- a/pcbnew/dialogs/dialog_mask_clearance.cpp +++ b/pcbnew/dialogs/dialog_mask_clearance.cpp @@ -8,7 +8,6 @@ ///////////////////////////////////////////////////////////////////////////// #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index 0ed10dc067..9c20c7cd7e 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -6,7 +6,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index 9101b55456..9af78bce1d 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -29,7 +29,6 @@ #include "dialog_pcb_text_properties.h" #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp index 89dfd76942..b910a7cf88 100644 --- a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp +++ b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp @@ -11,10 +11,10 @@ #include "fctsys.h" #include #include "appl_wxstruct.h" -#include "common.h" #include "confirm.h" #include "gestfich.h" #include "pcbnew.h" + #include "wxPcbStruct.h" #include "dialog_pcbnew_config_libs_and_paths.h" diff --git a/pcbnew/dialogs/dialog_print_for_modedit.cpp b/pcbnew/dialogs/dialog_print_for_modedit.cpp index a90df151ef..19c8ccc099 100644 --- a/pcbnew/dialogs/dialog_print_for_modedit.cpp +++ b/pcbnew/dialogs/dialog_print_for_modedit.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp index 74b032e397..5c1425da98 100644 --- a/pcbnew/dialogs/dialog_print_using_printer.cpp +++ b/pcbnew/dialogs/dialog_print_using_printer.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index e4dd3b19c1..e845ea70b7 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -3,7 +3,6 @@ /*****************************************/ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index a3b5f6e07f..bb257c0fbb 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -29,7 +29,6 @@ /****************************/ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index aeaea856b1..28b527f3d7 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -32,7 +32,6 @@ /****************************/ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" diff --git a/pcbnew/drc_marker_functions.cpp b/pcbnew/drc_marker_functions.cpp index 1ebe84dafc..0006691135 100644 --- a/pcbnew/drc_marker_functions.cpp +++ b/pcbnew/drc_marker_functions.cpp @@ -33,9 +33,7 @@ #include "fctsys.h" #include "common.h" -//#include "class_drawpanel.h" #include "pcbnew.h" -//#include "wxPcbStruct.h" #include "class_board_design_settings.h" #include "drc_stuff.h" diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index 8f08dfdea2..ab81379c9a 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -10,7 +10,6 @@ #include "fctsys.h" #include "trigo.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index 27928c1793..c944637272 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index f211a867be..1d1f648b7d 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -4,7 +4,6 @@ ***************************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 8dec74f493..0cf6382ac4 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -3,7 +3,6 @@ /***********************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index a19573c413..386a3a81d3 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -4,7 +4,6 @@ /************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 625a09cecf..f3c815a208 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -3,7 +3,6 @@ /*******************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 721543a74f..293b0d1162 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -3,7 +3,6 @@ /****************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/event_handlers_tracks_vias_sizes.cpp b/pcbnew/event_handlers_tracks_vias_sizes.cpp index 74e143f028..5db5df31cd 100644 --- a/pcbnew/event_handlers_tracks_vias_sizes.cpp +++ b/pcbnew/event_handlers_tracks_vias_sizes.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" -//#include "appl_wxstruct.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew_id.h" diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 297cc9116e..1430db6174 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -3,7 +3,6 @@ /************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index f583f697fa..630f5dec9c 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -1,5 +1,4 @@ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 08ea86ed87..ab785718c2 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -3,7 +3,6 @@ /***************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index 4b9b81c971..51813cce0a 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 6c831b8fd9..901e8aea7f 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -7,7 +7,6 @@ * 2 - create a module report (pos and module descr) (ascii file) */ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index 6acd986b49..2b6af674f9 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -39,7 +39,6 @@ #include -#include "common.h" #include "plot_common.h" #include "trigo.h" #include "confirm.h" diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 1bb5635854..d5401e15ee 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -3,10 +3,8 @@ /***************/ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" -//#include "pcbnew_id.h" #include "hotkeys.h" diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index f10311b29a..3ef11de870 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -3,7 +3,6 @@ /***************/ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "pcbnew_id.h" diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp index 198b7348b4..5e2221ff2e 100644 --- a/pcbnew/hotkeys_module_editor.cpp +++ b/pcbnew/hotkeys_module_editor.cpp @@ -3,7 +3,6 @@ /*****************************/ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 86094501c0..888b2e174f 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 5f029b77e3..31d47e82a5 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -4,7 +4,6 @@ /****************************************************/ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 525684c233..58330bafd3 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 9fcc31dfbf..f6f0066fcd 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -3,7 +3,6 @@ /**********************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index 69261e0974..8008c3a237 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -9,7 +9,6 @@ */ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 2c6cd61b3d..309f1de316 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -3,7 +3,6 @@ /********************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index 2383e51f32..b4bf6ffc70 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "class_drawpanel.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp index e53e80fbdf..ad69c413c4 100644 --- a/pcbnew/modeditoptions.cpp +++ b/pcbnew/modeditoptions.cpp @@ -3,7 +3,6 @@ /***********************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index cbb29585c3..f61582a2f1 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -4,13 +4,11 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" -#include "bitmaps.h" #include "protos.h" #include "pcbnew_id.h" #include "hotkeys.h" diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index f824d35d68..bf962b7781 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 9a3eceb40a..c0b52665d9 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -4,7 +4,6 @@ /****************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 0e5bb7edd4..cc1f8cad80 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -3,7 +3,6 @@ /*******************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "trigo.h" diff --git a/pcbnew/muwave_command.cpp b/pcbnew/muwave_command.cpp index 3d5e0e4492..a85220ca98 100644 --- a/pcbnew/muwave_command.cpp +++ b/pcbnew/muwave_command.cpp @@ -3,7 +3,6 @@ /*****************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index c50f33dc39..698cf40fb2 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -30,7 +30,6 @@ #include "algorithm" #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index d788d0897c..7449ebfeef 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -5,7 +5,6 @@ /**************************************************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 45aef0c5ef..4c09d787e2 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -30,14 +30,12 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "pcbstruct.h" // enum PCB_VISIBLE #include "collectors.h" -#include "bitmaps.h" #include "build_version.h" #include "protos.h" #include "pcbnew_id.h" diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index dc3c57b93b..c7ee016622 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -9,7 +9,6 @@ #include #include -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "plot_common.h" @@ -70,12 +69,12 @@ const wxString g_FootprintLibFileWildcard( wxT( "Kicad footprint library file (* */ wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" ); -IMPLEMENT_APP( WinEDA_App ) +IMPLEMENT_APP( EDA_APP ) /* MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ -void WinEDA_App::MacOpenFile( const wxString& fileName ) +void EDA_APP::MacOpenFile( const wxString& fileName ) { wxFileName filename = fileName; PCB_EDIT_FRAME* frame = ( (PCB_EDIT_FRAME*) GetTopWindow() ); @@ -87,12 +86,12 @@ void WinEDA_App::MacOpenFile( const wxString& fileName ) } -bool WinEDA_App::OnInit() +bool EDA_APP::OnInit() { wxFileName fn; PCB_EDIT_FRAME* frame = NULL; - InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW ); + InitEDA_Appl( wxT( "PCBnew" ), APP_PCBNEW_T ); if( m_Checker && m_Checker->IsAnotherRunning() ) { @@ -149,7 +148,9 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); * So we load settings only */ if( fn.FileExists() ) + { frame->LoadOnePcbFile( fn.GetFullPath() ); + } else { // File does not exists: prepare an empty board wxSetWorkingDirectory( fn.GetPath() ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 15e15da301..35000da4fd 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 7040e859c1..298ff56dc7 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "plot_common.h" #include "confirm.h" #include "gestfich.h" diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index a94739028c..6aa10bdbf5 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index c0f1c083c9..f5e3800a63 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -3,7 +3,6 @@ /*************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index a45f70312d..c7ae2acea8 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -33,7 +33,6 @@ #include "specctra.h" -#include "common.h" // IsOK() & EDA_FileSelector() #include "class_drawpanel.h" // DrawPanel #include "confirm.h" // DisplayError() #include "gestfich.h" // EDA_FileSelector() diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index e4e4e2cca9..324278490a 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -7,7 +7,6 @@ */ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 73e4fc9243..90fae97228 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -4,12 +4,10 @@ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "module_editor_frame.h" #include "dialog_helpers.h" -#include "bitmaps.h" #include "pcbnew_id.h" #include "hotkeys.h" diff --git a/pcbnew/tool_onrightclick.cpp b/pcbnew/tool_onrightclick.cpp index d91ece54ca..024fe266eb 100644 --- a/pcbnew/tool_onrightclick.cpp +++ b/pcbnew/tool_onrightclick.cpp @@ -3,7 +3,6 @@ /*************************/ #include "fctsys.h" -#include "common.h" #include "confirm.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 55a66d85bd..fbd1375a91 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -5,13 +5,11 @@ #include "fctsys.h" #include "wx/wupdlock.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" #include "colors_selection.h" #include "dialog_helpers.h" -#include "bitmaps.h" #include "pcbnew_id.h" #ifdef __UNIX__ diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index ea75869218..6b0ddd79d4 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -8,11 +8,9 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" -#include "bitmaps.h" #include "pcbnew_id.h" #include "drc_stuff.h" #include "3d_viewer.h" diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index 7413421d45..62227c5aba 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -4,7 +4,6 @@ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index c927a110a0..2abb3d1fdf 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -10,7 +10,6 @@ #include "fctsys.h" #include "gr_basic.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 00f987a61f..9e9eb6b2f6 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -3,7 +3,6 @@ /*******************************/ #include "fctsys.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" diff --git a/pcbnew/zone_filling_algorithm.cpp b/pcbnew/zone_filling_algorithm.cpp index 0861e475a4..b534f6d2fa 100644 --- a/pcbnew/zone_filling_algorithm.cpp +++ b/pcbnew/zone_filling_algorithm.cpp @@ -7,7 +7,6 @@ #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "zones.h" diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index bc976944e1..17bef9087b 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -5,7 +5,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "pcbnew.h" diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index b3f02ffbdc..8e42e28bbb 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -28,7 +28,6 @@ #include #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index 3e4d4817a6..8fbbdc3bf8 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -26,7 +26,6 @@ #include "fctsys.h" #include "polygons_defs.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp index 901844ba29..33e4104a71 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp @@ -23,7 +23,6 @@ #include #include "fctsys.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" diff --git a/pcbnew/zones_convert_to_polygons_aux_functions.cpp b/pcbnew/zones_convert_to_polygons_aux_functions.cpp index 011db3bbb8..a8ebc00d3d 100644 --- a/pcbnew/zones_convert_to_polygons_aux_functions.cpp +++ b/pcbnew/zones_convert_to_polygons_aux_functions.cpp @@ -9,7 +9,6 @@ #include "fctsys.h" #include "polygons_defs.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" diff --git a/pcbnew/zones_functions_for_undo_redo.cpp b/pcbnew/zones_functions_for_undo_redo.cpp index 0b822d15d0..e331c2fe0f 100644 --- a/pcbnew/zones_functions_for_undo_redo.cpp +++ b/pcbnew/zones_functions_for_undo_redo.cpp @@ -45,7 +45,6 @@ #include "fctsys.h" #include "appl_wxstruct.h" -#include "common.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "wxPcbStruct.h" diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp index 2d3fd3d73f..6c6470447c 100644 --- a/pcbnew/zones_non_copper_type_functions.cpp +++ b/pcbnew/zones_non_copper_type_functions.cpp @@ -3,7 +3,6 @@ #include "appl_wxstruct.h" #include "gr_basic.h" #include "confirm.h" -#include "common.h" #include "pcbnew.h" #include "wxPcbStruct.h" From 750f84c19a62a9a7e3b66cc7381bff7e7c6178ba Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 6 Sep 2011 15:42:46 -0400 Subject: [PATCH 5/9] Coding style policy fixes and dead code removal. --- 3d-viewer/3d_aux.cpp | 2 +- 3d-viewer/3d_struct.h | 2 +- common/base_screen.cpp | 2 +- common/common.cpp | 18 +- common/displlst.cpp | 52 +++--- common/wxwineda.cpp | 174 ++++++------------ eeschema/database.cpp | 6 +- .../dialog_edit_component_in_schematic.cpp | 9 +- .../dialog_edit_libentry_fields_in_lib.cpp | 8 +- eeschema/eeschema_config.cpp | 2 +- eeschema/netlist_control.cpp | 54 ++++-- eeschema/netlist_control.h | 4 +- eeschema/selpart.cpp | 2 +- include/class_base_screen.h | 2 +- include/common.h | 22 +-- include/dialog_helpers.h | 132 +++++-------- include/gestfich.h | 4 +- include/wxBasePcbFrame.h | 2 +- pcbnew/basepcbframe.cpp | 2 +- pcbnew/dialogs/dialog_general_options.cpp | 5 +- pcbnew/dimension.cpp | 84 ++++----- pcbnew/librairi.cpp | 2 +- pcbnew/loadcmp.cpp | 6 +- pcbnew/mirepcb.cpp | 20 +- pcbnew/muonde.cpp | 17 +- pcbnew/netlist.cpp | 3 +- pcbnew/set_grid.cpp | 2 +- 27 files changed, 284 insertions(+), 354 deletions(-) diff --git a/3d-viewer/3d_aux.cpp b/3d-viewer/3d_aux.cpp index ada44e7879..4e7af2f5ac 100644 --- a/3d-viewer/3d_aux.cpp +++ b/3d-viewer/3d_aux.cpp @@ -175,7 +175,7 @@ Info_3D_Visu::~Info_3D_Visu() * units */ WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, wxBoxSizer* BoxSizer, - UserUnitType units, int internal_unit ) + EDA_UNITS_T units, int internal_unit ) { wxString text; wxStaticText* msgtitle; diff --git a/3d-viewer/3d_struct.h b/3d-viewer/3d_struct.h index 8bff84ba67..d841fa0a30 100644 --- a/3d-viewer/3d_struct.h +++ b/3d-viewer/3d_struct.h @@ -123,7 +123,7 @@ private: public: WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, - wxBoxSizer* BoxSizer, UserUnitType units, int internal_unit ); + wxBoxSizer* BoxSizer, EDA_UNITS_T units, int internal_unit ); ~WinEDA_VertexCtrl(); diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 58f6a2dd71..b9d61ce2a4 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -334,7 +334,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id ) } -void BASE_SCREEN::AddGrid( const wxRealPoint& size, UserUnitType aUnit, int id ) +void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ) { double x, y; wxRealPoint new_size; diff --git a/common/common.cpp b/common/common.cpp index fd9b59d77d..91bfb8ed0c 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -78,7 +78,7 @@ wxString g_Prj_Default_Config_FullFilename; wxString g_Prj_Config_LocalFilename; /* Current user unit of measure */ -UserUnitType g_UserUnit; +EDA_UNITS_T g_UserUnit; /* Draw color for moving objects: */ int g_GhostColor; @@ -221,7 +221,7 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size, } -wxString ReturnUnitSymbol( UserUnitType aUnit, const wxString& formatString ) +wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString ) { wxString tmp; wxString label; @@ -249,7 +249,7 @@ wxString ReturnUnitSymbol( UserUnitType aUnit, const wxString& formatString ) } -wxString GetUnitsLabel( UserUnitType aUnit ) +wxString GetUnitsLabel( EDA_UNITS_T aUnit ) { wxString label; @@ -272,7 +272,7 @@ wxString GetUnitsLabel( UserUnitType aUnit ) } -wxString GetAbbreviatedUnitsLabel( UserUnitType aUnit ) +wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit ) { wxString label; @@ -298,7 +298,7 @@ wxString GetAbbreviatedUnitsLabel( UserUnitType aUnit ) * Add string " (mm):" or " ("):" to the static text Stext. * Used in dialog boxes for entering values depending on selected units */ -void AddUnitSymbol( wxStaticText& Stext, UserUnitType aUnit ) +void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit ) { wxString msg = Stext.GetLabel(); @@ -346,7 +346,7 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) * @return a wxString what contains value and optionally the symbol unit * (like 2.000 mm) */ -wxString ReturnStringFromValue( UserUnitType aUnit, int aValue, int aInternal_Unit, +wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Unit, bool aAdd_unit_symbol ) { wxString StringValue; @@ -384,7 +384,7 @@ wxString ReturnStringFromValue( UserUnitType aUnit, int aValue, int aInternal_Un * Value = text * Internal_Unit = units per inch for computed value */ -int ReturnValueFromString( UserUnitType aUnit, const wxString& TextValue, +int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit ) { int Value; @@ -479,7 +479,7 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter ) * @param val : double : the given value * @param internal_unit_value = internal units per inch */ -double To_User_Unit( UserUnitType aUnit, double val, int internal_unit_value ) +double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) { switch( aUnit ) { @@ -498,7 +498,7 @@ double To_User_Unit( UserUnitType aUnit, double val, int internal_unit_value ) /* * Return in internal units the value "val" given in inch or mm */ -int From_User_Unit( UserUnitType aUnit, double val, int internal_unit_value ) +int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) { double value; diff --git a/common/displlst.cpp b/common/displlst.cpp index e7821014b0..8d433da7ec 100644 --- a/common/displlst.cpp +++ b/common/displlst.cpp @@ -16,14 +16,14 @@ enum listbox { }; -BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog ) - EVT_BUTTON( wxID_OK, WinEDAListBox::OnOkClick ) - EVT_BUTTON( wxID_CANCEL, WinEDAListBox::OnCancelClick ) - EVT_LISTBOX( ID_LISTBOX_LIST, WinEDAListBox::ClickOnList ) - EVT_LISTBOX_DCLICK( ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList ) - EVT_CHAR( WinEDAListBox::OnKeyEvent ) - EVT_CHAR_HOOK( WinEDAListBox::OnKeyEvent ) - EVT_CLOSE( WinEDAListBox::OnClose ) +BEGIN_EVENT_TABLE( EDA_LIST_DIALOG, wxDialog ) + EVT_BUTTON( wxID_OK, EDA_LIST_DIALOG::OnOkClick ) + EVT_BUTTON( wxID_CANCEL, EDA_LIST_DIALOG::OnCancelClick ) + EVT_LISTBOX( ID_LISTBOX_LIST, EDA_LIST_DIALOG::ClickOnList ) + EVT_LISTBOX_DCLICK( ID_LISTBOX_LIST, EDA_LIST_DIALOG::D_ClickOnList ) + EVT_CHAR( EDA_LIST_DIALOG::OnKeyEvent ) + EVT_CHAR_HOOK( EDA_LIST_DIALOG::OnKeyEvent ) + EVT_CLOSE( EDA_LIST_DIALOG::OnClose ) END_EVENT_TABLE() @@ -37,9 +37,9 @@ END_EVENT_TABLE() * @param aCallBackFunction callback function to display comments * @param aPos = position of the dialog. */ -WinEDAListBox::WinEDAListBox( EDA_DRAW_FRAME* aParent, const wxString& aTitle, - const wxArrayString& aItemList, const wxString& aRefText, - void(* aCallBackFunction)(wxString& Text), wxPoint aPos ) : +EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, + const wxArrayString& aItemList, const wxString& aRefText, + void(* aCallBackFunction)(wxString& Text), wxPoint aPos ) : wxDialog( aParent, wxID_ANY, aTitle, aPos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER ) { @@ -61,8 +61,8 @@ WinEDAListBox::WinEDAListBox( EDA_DRAW_FRAME* aParent, const wxString& aTitle, if( m_callBackFct ) { m_messages = new wxTextCtrl( this, -1, wxEmptyString, - wxDefaultPosition, wxSize( -1, 60 ), - wxTE_READONLY | wxTE_MULTILINE ); + wxDefaultPosition, wxSize( -1, 60 ), + wxTE_READONLY | wxTE_MULTILINE ); GeneralBoxSizer->Add( m_messages, 0, wxGROW | wxALL, 5 ); } @@ -78,12 +78,12 @@ WinEDAListBox::WinEDAListBox( EDA_DRAW_FRAME* aParent, const wxString& aTitle, } -WinEDAListBox::~WinEDAListBox() +EDA_LIST_DIALOG::~EDA_LIST_DIALOG() { } -void WinEDAListBox::MoveMouseToOrigin() +void EDA_LIST_DIALOG::MoveMouseToOrigin() { int x, y, w, h; wxSize list_size = m_listBox->GetSize(); @@ -96,32 +96,32 @@ void WinEDAListBox::MoveMouseToOrigin() } -wxString WinEDAListBox::GetTextSelection() +wxString EDA_LIST_DIALOG::GetTextSelection() { wxString text = m_listBox->GetStringSelection(); return text; } -void WinEDAListBox::Append( const wxString& item ) +void EDA_LIST_DIALOG::Append( const wxString& item ) { m_listBox->Append( item ); } -void WinEDAListBox::InsertItems( const wxArrayString& itemlist, int position ) +void EDA_LIST_DIALOG::InsertItems( const wxArrayString& itemlist, int position ) { m_listBox->InsertItems( itemlist, position ); } -void WinEDAListBox::OnCancelClick( wxCommandEvent& event ) +void EDA_LIST_DIALOG::OnCancelClick( wxCommandEvent& event ) { EndModal( wxID_CANCEL ); } -void WinEDAListBox::ClickOnList( wxCommandEvent& event ) +void EDA_LIST_DIALOG::ClickOnList( wxCommandEvent& event ) { wxString text; @@ -135,19 +135,19 @@ void WinEDAListBox::ClickOnList( wxCommandEvent& event ) } -void WinEDAListBox::D_ClickOnList( wxCommandEvent& event ) +void EDA_LIST_DIALOG::D_ClickOnList( wxCommandEvent& event ) { EndModal( wxID_OK ); } -void WinEDAListBox::OnOkClick( wxCommandEvent& event ) +void EDA_LIST_DIALOG::OnOkClick( wxCommandEvent& event ) { EndModal( wxID_OK ); } -void WinEDAListBox::OnClose( wxCloseEvent& event ) +void EDA_LIST_DIALOG::OnClose( wxCloseEvent& event ) { EndModal( wxID_CANCEL ); } @@ -161,7 +161,7 @@ static int SortItems( const wxString** ptr1, const wxString** ptr2 ) } -void WinEDAListBox:: SortList() +void EDA_LIST_DIALOG:: SortList() { int ii, NbItems = m_listBox->GetCount(); const wxString** BufList; @@ -170,6 +170,7 @@ void WinEDAListBox:: SortList() return; BufList = (const wxString**) MyZMalloc( 100 * NbItems * sizeof(wxString*) ); + for( ii = 0; ii < NbItems; ii++ ) { BufList[ii] = new wxString( m_listBox->GetString( ii ) ); @@ -179,6 +180,7 @@ void WinEDAListBox:: SortList() ( int( * ) ( const void*, const void* ) )SortItems ); m_listBox->Clear(); + for( ii = 0; ii < NbItems; ii++ ) { m_listBox->Append( *BufList[ii] ); @@ -189,7 +191,7 @@ void WinEDAListBox:: SortList() } -void WinEDAListBox::OnKeyEvent( wxKeyEvent& event ) +void EDA_LIST_DIALOG::OnKeyEvent( wxKeyEvent& event ) { event.Skip(); } diff --git a/common/wxwineda.cpp b/common/wxwineda.cpp index 3a43e6349e..71720bfeb1 100644 --- a/common/wxwineda.cpp +++ b/common/wxwineda.cpp @@ -1,94 +1,23 @@ - /***************/ -/* wxwineda.cpp */ -/****************/ +/** + * @file wxwineda.cpp + */ #include "fctsys.h" -#include "common.h" #include "wxstruct.h" #include "dialog_helpers.h" -/* - * Text entry dialog to enter one or more lines of text. - */ -WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, - const wxString& Title, - const wxString& TextToEdit, - wxBoxSizer* BoxSizer, - const wxSize& Size, bool Multiline ) -{ - m_Modify = FALSE; - if( ! TextToEdit.IsEmpty() ) - m_NewText = TextToEdit; - - m_Title = new wxStaticText( parent, -1, Title ); - - BoxSizer->Add( m_Title, 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); - - long style = 0; - - if (Multiline) - style = wxTE_MULTILINE; - - m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, - Size,style ); - - m_FrameText->SetInsertionPoint( 1 ); - BoxSizer->Add( m_FrameText, - 0, - wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); -} - - -wxString WinEDA_EnterText::GetValue() -{ - m_Modify = m_FrameText->IsModified(); - m_NewText = m_FrameText->GetValue(); - return m_NewText; -} - - -void WinEDA_EnterText::GetValue( char* buffer, int lenmax ) -{ - m_Modify = m_FrameText->IsModified(); - if( buffer ) - { - m_NewText = m_FrameText->GetValue(); - int ii, ll = m_NewText.Len(); - for( ii = 0; ii < ll && ii < (lenmax - 1); ii++ ) - ; - - buffer[ii] = m_NewText.GetChar( ii ); - buffer[lenmax - 1] = 0; - } -} - - -void WinEDA_EnterText::SetValue( const wxString& new_text ) -{ - m_FrameText->SetValue( new_text ); -} - - -void WinEDA_EnterText::Enable( bool enbl ) -{ - m_Title->Enable( enbl ); - m_FrameText->Enable( enbl ); -} - /*******************************************************/ /* Class to edit a graphic + text size in INCHES or MM */ /*******************************************************/ -WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent, - const wxString& Title, - const wxString& TextToEdit, - int textsize, - UserUnitType user_unit, - wxBoxSizer* BoxSizer, - int framelen, - int internal_unit ) +EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, + const wxString& Title, + const wxString& TextToEdit, + int textsize, + EDA_UNITS_T user_unit, + wxBoxSizer* BoxSizer, + int framelen, + int internal_unit ) { m_UserUnit = user_unit; m_Internal_Unit = internal_unit; @@ -121,7 +50,7 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent, } -WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl() +EDA_GRAPHIC_TEXT_CTRL::~EDA_GRAPHIC_TEXT_CTRL() { /* no, these are deleted by the BoxSizer delete m_FrameText; @@ -130,8 +59,8 @@ WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl() } -wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, UserUnitType aUnit, - int textSize ) +wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit, + int textSize ) { wxString value; @@ -143,40 +72,40 @@ wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, UserUnitType aUni textSize = 3000; value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ), - To_User_Unit( aUnit, textSize, internalUnit ) ); + To_User_Unit( aUnit, textSize, internalUnit ) ); return value; } -void WinEDA_GraphicTextCtrl::SetTitle( const wxString& title ) +void EDA_GRAPHIC_TEXT_CTRL::SetTitle( const wxString& title ) { m_Title->SetLabel( title ); } -void WinEDA_GraphicTextCtrl::SetValue( const wxString& value ) +void EDA_GRAPHIC_TEXT_CTRL::SetValue( const wxString& value ) { m_FrameText->SetValue( value ); } -void WinEDA_GraphicTextCtrl::SetValue( int textSize ) +void EDA_GRAPHIC_TEXT_CTRL::SetValue( int textSize ) { wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textSize ); m_FrameSize->SetValue( value ); } -wxString WinEDA_GraphicTextCtrl::GetText() +wxString EDA_GRAPHIC_TEXT_CTRL::GetText() { wxString text = m_FrameText->GetValue(); return text; } -int WinEDA_GraphicTextCtrl::ParseSize( const wxString& sizeText, - int internalUnit, UserUnitType aUnit ) +int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, + int internalUnit, EDA_UNITS_T aUnit ) { int textsize; @@ -193,13 +122,13 @@ int WinEDA_GraphicTextCtrl::ParseSize( const wxString& sizeText, } -int WinEDA_GraphicTextCtrl::GetTextSize() +int EDA_GRAPHIC_TEXT_CTRL::GetTextSize() { return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_UserUnit ); } -void WinEDA_GraphicTextCtrl::Enable( bool state ) +void EDA_GRAPHIC_TEXT_CTRL::Enable( bool state ) { m_FrameText->Enable( state ); } @@ -208,21 +137,23 @@ void WinEDA_GraphicTextCtrl::Enable( bool state ) /********************************************************/ /* Class to display and edit a coordinated INCHES or MM */ /********************************************************/ -WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent, - const wxString& title, - const wxPoint& pos_to_edit, - UserUnitType user_unit, - wxBoxSizer* BoxSizer, - int internal_unit ) +EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, + const wxString& title, + const wxPoint& pos_to_edit, + EDA_UNITS_T user_unit, + wxBoxSizer* BoxSizer, + int internal_unit ) { wxString text; m_UserUnit = user_unit; m_Internal_Unit = internal_unit; + if( title.IsEmpty() ) text = _( "Pos " ); else text = title; + text += _( "X" ) + ReturnUnitSymbol( m_UserUnit ); m_TextX = new wxStaticText( parent, -1, text ); @@ -239,6 +170,7 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent, else text = title; text += _( "Y" ) + ReturnUnitSymbol( m_UserUnit ); + m_TextY = new wxStaticText( parent, -1, text ); BoxSizer->Add( m_TextY, 0, @@ -252,7 +184,7 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent, } -WinEDA_PositionCtrl::~WinEDA_PositionCtrl() +EDA_POSITION_CTRL::~EDA_POSITION_CTRL() { delete m_TextX; delete m_TextY; @@ -263,7 +195,7 @@ WinEDA_PositionCtrl::~WinEDA_PositionCtrl() /* Returns (in internal units) to coordinate between (in user units) */ -wxPoint WinEDA_PositionCtrl::GetValue() +wxPoint EDA_POSITION_CTRL::GetValue() { wxPoint coord; @@ -274,14 +206,14 @@ wxPoint WinEDA_PositionCtrl::GetValue() } -void WinEDA_PositionCtrl::Enable( bool x_win_on, bool y_win_on ) +void EDA_POSITION_CTRL::Enable( bool x_win_on, bool y_win_on ) { m_FramePosX->Enable( x_win_on ); m_FramePosY->Enable( y_win_on ); } -void WinEDA_PositionCtrl::SetValue( int x_value, int y_value ) +void EDA_POSITION_CTRL::SetValue( int x_value, int y_value ) { wxString msg; @@ -299,22 +231,22 @@ void WinEDA_PositionCtrl::SetValue( int x_value, int y_value ) /*******************/ -/* WinEDA_SizeCtrl */ +/* EDA_SIZE_CTRL */ /*******************/ -WinEDA_SizeCtrl::WinEDA_SizeCtrl( wxWindow* parent, const wxString& title, - const wxSize& size_to_edit, - UserUnitType aUnit, wxBoxSizer* BoxSizer, - int internal_unit ) : - WinEDA_PositionCtrl( parent, title, - wxPoint( size_to_edit.x, size_to_edit.y ), - aUnit, BoxSizer, internal_unit ) +EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, + const wxSize& size_to_edit, + EDA_UNITS_T aUnit, wxBoxSizer* aBoxSizer, + int internal_unit ) : + EDA_POSITION_CTRL( parent, title, + wxPoint( size_to_edit.x, size_to_edit.y ), + aUnit, aBoxSizer, internal_unit ) { } -wxSize WinEDA_SizeCtrl::GetValue() +wxSize EDA_SIZE_CTRL::GetValue() { - wxPoint pos = WinEDA_PositionCtrl::GetValue(); + wxPoint pos = EDA_POSITION_CTRL::GetValue(); wxSize size; size.x = pos.x; @@ -326,9 +258,9 @@ wxSize WinEDA_SizeCtrl::GetValue() /**************************************************************/ /* Class to display and edit a dimension INCHES, MM, or other */ /**************************************************************/ -WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, - int value, UserUnitType user_unit, wxBoxSizer* BoxSizer, - int internal_unit ) +EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, + int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, + int internal_unit ) { wxString label = title; @@ -353,14 +285,14 @@ WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, } -WinEDA_ValueCtrl::~WinEDA_ValueCtrl() +EDA_VALUE_CTRL::~EDA_VALUE_CTRL() { delete m_ValueCtrl; delete m_Text; } -int WinEDA_ValueCtrl::GetValue() +int EDA_VALUE_CTRL::GetValue() { int coord; wxString txtvalue = m_ValueCtrl->GetValue(); @@ -370,7 +302,7 @@ int WinEDA_ValueCtrl::GetValue() } -void WinEDA_ValueCtrl::SetValue( int new_value ) +void EDA_VALUE_CTRL::SetValue( int new_value ) { wxString buffer; @@ -381,7 +313,7 @@ void WinEDA_ValueCtrl::SetValue( int new_value ) } -void WinEDA_ValueCtrl::Enable( bool enbl ) +void EDA_VALUE_CTRL::Enable( bool enbl ) { m_ValueCtrl->Enable( enbl ); m_Text->Enable( enbl ); diff --git a/eeschema/database.cpp b/eeschema/database.cpp index 387bc8a62b..6cbbbd9766 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -49,9 +49,11 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa if( nameList.IsEmpty() ) { msg = _( "No components found matching " ); + if( !BufName.IsEmpty() ) { msg += _( "name search criteria <" ) + BufName + wxT( "> " ); + if( !Keys.IsEmpty() ) msg += _( "and " ); } @@ -66,8 +68,8 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa // Show candidate list: wxString cmpname; - WinEDAListBox dlg( frame, _( "Select Component" ), - nameList, cmpname, DisplayCmpDoc ); + EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), nameList, cmpname, DisplayCmpDoc ); + if( dlg.ShowModal() != wxID_OK ) return wxEmptyString; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 9820abb536..5b4be242c2 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -632,9 +632,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() else fieldValueTextCtrl->Enable( true ); - textSizeTextCtrl->SetValue( - WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT, - g_UserUnit, field.m_Size.x ) ); + textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT, + g_UserUnit, field.m_Size.x ) ); wxPoint coord = field.m_Pos; wxPoint zero = -m_Cmp->m_Pos; // relative zero @@ -713,8 +712,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() setRowItem( fieldNdx, field ); // update fieldListCtrl - field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize( - textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UserUnit ); + field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), + EESCHEMA_INTERNAL_UNIT, g_UserUnit ); field.m_Size.y = field.m_Size.x; int style = m_StyleRadioBox->GetSelection(); diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index ad3fa3eca7..579ae16f9f 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -657,8 +657,8 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() fieldValueTextCtrl->SetValue( field.m_Text ); - textSizeTextCtrl->SetValue( - WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT, g_UserUnit, field.m_Size.x ) ); + textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT, + g_UserUnit, field.m_Size.x ) ); wxPoint coord = field.m_Pos; wxPoint zero; @@ -744,8 +744,8 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() setRowItem( fieldNdx, field ); // update fieldListCtrl - field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize( - textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UserUnit ); + field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), + EESCHEMA_INTERNAL_UNIT, g_UserUnit ); field.m_Size.y = field.m_Size.x; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 6dc90c70fd..c907267d4e 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -210,7 +210,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event ) if( dlg.ShowModal() == wxID_CANCEL ) return; - g_UserUnit = (UserUnitType)dlg.GetUnitsSelection(); + g_UserUnit = (EDA_UNITS_T)dlg.GetUnitsSelection(); GetScreen()->SetGrid( grid_list[ (size_t) dlg.GetGridSelection() ].m_Size ); diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index d685eb74aa..55897e0bd3 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -254,16 +254,23 @@ void NETLIST_DIALOG::InstallPageSpice() wxDefaultPosition, wxDefaultSize, 2, netlist_opt, 1, wxRA_SPECIFY_COLS ); + if( !g_OptNetListUseNames ) m_UseNetNamesInNetlist->SetSelection( 1 ); page->m_LeftBoxSizer->Add( m_UseNetNamesInNetlist, 0, wxGROW | wxALL, 5 ); - page->m_CommandStringCtrl = new WinEDA_EnterText( page, - _( "Simulator command:" ), - m_Parent->GetSimulatorCommand(), - page->m_LowBoxSizer, - wxDefaultSize ); + page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + + page->m_CommandStringCtrl = new wxTextCtrl( page, -1, m_Parent->GetSimulatorCommand(), + wxDefaultPosition, wxDefaultSize ); + + page->m_CommandStringCtrl->SetInsertionPoint( 1 ); + page->m_LowBoxSizer->Add( page->m_CommandStringCtrl, + 0, + wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); // Add buttons Button = new wxButton( page, ID_CREATE_NETLIST, _( "Netlist" ) ); @@ -301,6 +308,7 @@ void NETLIST_DIALOG::InstallCustomPages() /* Install the panel "Add Plugin" after * the last initialized panel */ + previoustitle = title; if( title.IsEmpty() ) CurrPage = @@ -324,17 +332,32 @@ void NETLIST_DIALOG::InstallCustomPages() msg = CUSTOM_NETLIST_COMMAND; msg << ii + 1; wxString Command = wxGetApp().m_EDA_Config->Read( msg ); - CurrPage->m_CommandStringCtrl = - new WinEDA_EnterText( CurrPage, - _( "Netlist command:" ), Command, - CurrPage->m_LowBoxSizer, - wxDefaultSize ); - CurrPage->m_TitleStringCtrl = - new WinEDA_EnterText( CurrPage, - _( "Title:" ), title, - CurrPage->m_LowBoxSizer, - wxDefaultSize ); + CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage, + -1, _( "Netlist command:" ) ), 0, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + + CurrPage->m_CommandStringCtrl = new wxTextCtrl( CurrPage, -1, Command, + wxDefaultPosition, wxDefaultSize ); + + CurrPage->m_CommandStringCtrl->SetInsertionPoint( 1 ); + CurrPage->m_LowBoxSizer->Add( CurrPage->m_CommandStringCtrl, + 0, + wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); + + CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage, + -1, _( "Title:" ) ), 0, + wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + + CurrPage->m_TitleStringCtrl = new wxTextCtrl( CurrPage, -1, title, + wxDefaultPosition, wxDefaultSize ); + + CurrPage->m_TitleStringCtrl->SetInsertionPoint( 1 ); + CurrPage->m_LowBoxSizer->Add( CurrPage->m_TitleStringCtrl, + 0, + wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); } } @@ -384,6 +407,7 @@ void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event ) /* Get a title for this page */ wxString title = CurrPage->m_TitleStringCtrl->GetValue(); + if( title.IsEmpty() ) DisplayInfoMessage( this, _( "Do not forget to choose a title for this netlist control page" ) ); diff --git a/eeschema/netlist_control.h b/eeschema/netlist_control.h index e8b587b031..d3b4f17ee3 100644 --- a/eeschema/netlist_control.h +++ b/eeschema/netlist_control.h @@ -48,8 +48,8 @@ public: int m_IdNetType; wxCheckBox* m_IsCurrentFormat; wxCheckBox* m_AddSubPrefix; - WinEDA_EnterText* m_CommandStringCtrl; - WinEDA_EnterText* m_TitleStringCtrl; + wxTextCtrl* m_CommandStringCtrl; + wxTextCtrl* m_TitleStringCtrl; wxButton* m_ButtonCancel; wxBoxSizer* m_LeftBoxSizer; wxBoxSizer* m_RightBoxSizer; diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index 4c9741848c..8464285be3 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -64,7 +64,7 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame, Library->GetEntryNames( nameList ); - WinEDAListBox dlg( frame, _( "Select Component" ), nameList, OldName, DisplayCmpDoc ); + EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), nameList, OldName, DisplayCmpDoc ); if( dlg.ShowModal() != wxID_OK ) return 0; diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 944cfd3db7..fae15c4eba 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -327,7 +327,7 @@ public: void SetGridList( GRIDS& sizelist ); void AddGrid( const GRID_TYPE& grid ); void AddGrid( const wxRealPoint& size, int id ); - void AddGrid( const wxRealPoint& size, UserUnitType aUnit, int id ); + void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ); /** * Function GetGridCount(). diff --git a/include/common.h b/include/common.h index b3aab67431..9c66cf3d7c 100644 --- a/include/common.h +++ b/include/common.h @@ -13,7 +13,6 @@ class wxAboutDialogInfo; class BASE_SCREEN; class EDA_DRAW_FRAME; -class WinEDAListBox; class EDA_DRAW_PANEL; /* Flag for special keys */ @@ -81,7 +80,8 @@ enum pseudokeys { #define ON 1 #define OFF 0 -enum UserUnitType { + +enum EDA_UNITS_T { INCHES = 0, MILLIMETRES = 1, UNSCALED_UNITS = 2 @@ -163,7 +163,7 @@ extern wxString g_Prj_Default_Config_FullFilename; // Name of local configuration file. (.pro) extern wxString g_Prj_Config_LocalFilename; -extern UserUnitType g_UserUnit; ///< display units +extern EDA_UNITS_T g_UserUnit; ///< display units /* Draw color for moving objects: */ extern int g_GhostColor; @@ -285,7 +285,7 @@ wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils * the format string must contain the %s format specifier. * @return The formatted units symbol. */ -wxString ReturnUnitSymbol( UserUnitType aUnits = g_UserUnit, +wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit, const wxString& aFormatString = _( " (%s):" ) ); /** @@ -297,10 +297,10 @@ wxString ReturnUnitSymbol( UserUnitType aUnits = g_UserUnit, * @param aUnits - The units text to return. * @return The human readable units string. */ -wxString GetUnitsLabel( UserUnitType aUnits ); -wxString GetAbbreviatedUnitsLabel( UserUnitType aUnit = g_UserUnit ); +wxString GetUnitsLabel( EDA_UNITS_T aUnits ); +wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit ); -int ReturnValueFromString( UserUnitType aUnit, const wxString& TextValue, +int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit ); /** @@ -314,12 +314,12 @@ int ReturnValueFromString( UserUnitType aUnit, const wxString& TextV * @return a wxString what contains value and optionally the symbol unit (like * 2.000 mm) */ -wxString ReturnStringFromValue( UserUnitType aUnit, +wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Unit, bool aAdd_unit_symbol = false ); -void AddUnitSymbol( wxStaticText& Stext, UserUnitType aUnit = g_UserUnit ); +void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit ); /* Add string " (mm):" or " ("):" to the static text Stext. * Used in dialog boxes for entering values depending on selected units */ @@ -343,11 +343,11 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter ); * @param val : double : the given value * @param internal_unit_value = internal units per inch */ -double To_User_Unit( UserUnitType aUnit, +double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); -int From_User_Unit( UserUnitType aUnit, +int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); wxString GenDate(); diff --git a/include/dialog_helpers.h b/include/dialog_helpers.h index a9892aca71..8120e775df 100644 --- a/include/dialog_helpers.h +++ b/include/dialog_helpers.h @@ -1,20 +1,20 @@ -// file dialog_helpers.h +/** + * @file dialog_helpers.h + * @brief Helper dialog and control classes. + * @note Due to use of wxFormBuilder to create dialogs many of them should be removed. + */ #ifndef _DIALOG_HELPERS_H_ #define _DIALOG_HELPERS_H_ -/* some small helper classes used in dialogs - * Due to use of wxFormBuilder to create dialogs - * Many of them should be removed - */ /** - * class WinEDAListBox + * class EDA_LIST_DIALOG * * Used to display a list of elements for selection, and an help of info line * about the selected item. */ -class WinEDAListBox : public wxDialog +class EDA_LIST_DIALOG : public wxDialog { private: wxListBox* m_listBox; @@ -24,18 +24,18 @@ private: public: /** * Constructor: - * @param aParent = apointeur to the parent window - * @param aTitle = the title shown on top. - * @param aItemList = a wxArrayStrin: the list of elements. - * @param aRefText = an item name if an item must be preselected. + * @param aParent Pointer to the parent window. + * @param aTitle The title shown on top. + * @param aItemList A wxArrayString of the list of elements. + * @param aRefText An item name if an item must be preselected. * @param aCallBackFunction callback function to display comments - * @param aPos = position of the dialog. + * @param aPos The position of the dialog. */ - WinEDAListBox( EDA_DRAW_FRAME* aParent, const wxString& aTitle, - const wxArrayString& aItemList, const wxString& aRefText, - void(* aCallBackFunction)(wxString& Text) = NULL, - wxPoint aPos = wxDefaultPosition ); - ~WinEDAListBox(); + EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, + const wxArrayString& aItemList, const wxString& aRefText, + void(* aCallBackFunction)(wxString& Text) = NULL, + wxPoint aPos = wxDefaultPosition ); + ~EDA_LIST_DIALOG(); void SortList(); void Append( const wxString& aItemStr ); @@ -55,50 +55,14 @@ private: }; -/************************************************/ -/* Class to enter a line, is some dialog frames */ -/************************************************/ -class WinEDA_EnterText +/** + * Class EDA_GRAPHIC_TEXT_CTRL + * is a custom text edit control to edit/enter Kicad dimensions ( INCHES or MM ) + */ +class EDA_GRAPHIC_TEXT_CTRL { public: - bool m_Modify; - -private: - wxString m_NewText; - wxTextCtrl* m_FrameText; - wxStaticText* m_Title; - -public: - WinEDA_EnterText( wxWindow* parent, const wxString& Title, - const wxString& TextToEdit, wxBoxSizer* BoxSizer, - const wxSize& Size, bool Multiline = false ); - - ~WinEDA_EnterText() - { - } - - - wxString GetValue(); - void GetValue( char* buffer, int lenmax ); - void SetValue( const wxString& new_text ); - void Enable( bool enbl ); - - void SetFocus() { m_FrameText->SetFocus(); } - void SetInsertionPoint( int n ) { m_FrameText->SetInsertionPoint( n ); } - void SetSelection( int n, int m ) - { - m_FrameText->SetSelection( n, m ); - } -}; - - -/************************************************************************/ -/* Class to edit/enter a graphic text and its dimension ( INCHES or MM )*/ -/************************************************************************/ -class WinEDA_GraphicTextCtrl -{ -public: - UserUnitType m_UserUnit; + EDA_UNITS_T m_UserUnit; int m_Internal_Unit; wxTextCtrl* m_FrameText; @@ -107,12 +71,12 @@ private: wxStaticText* m_Title; public: - WinEDA_GraphicTextCtrl( wxWindow* parent, const wxString& Title, - const wxString& TextToEdit, int textsize, - UserUnitType user_unit, wxBoxSizer* BoxSizer, int framelen = 200, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title, + const wxString& TextToEdit, int textsize, + EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); - ~WinEDA_GraphicTextCtrl(); + ~EDA_GRAPHIC_TEXT_CTRL(); wxString GetText(); int GetTextSize(); @@ -127,10 +91,10 @@ public: * Function FormatSize * formats a string containing the size in the desired units. */ - static wxString FormatSize( int internalUnit, UserUnitType user_unit, int textSize ); + static wxString FormatSize( int internalUnit, EDA_UNITS_T user_unit, int textSize ); static int ParseSize( const wxString& sizeText, int internalUnit, - UserUnitType user_unit ); + EDA_UNITS_T user_unit ); }; @@ -138,10 +102,10 @@ public: /* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */ /* dialog boxes, */ /**************************************************************************/ -class WinEDA_PositionCtrl +class EDA_POSITION_CTRL { public: - UserUnitType m_UserUnit; + EDA_UNITS_T m_UserUnit; int m_Internal_Unit; wxPoint m_Pos_To_Edit; @@ -151,12 +115,12 @@ private: wxStaticText* m_TextX, * m_TextY; public: - WinEDA_PositionCtrl( wxWindow* parent, const wxString& title, + EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit, - UserUnitType user_unit, wxBoxSizer* BoxSizer, + EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int internal_unit = EESCHEMA_INTERNAL_UNIT ); - ~WinEDA_PositionCtrl(); + ~EDA_POSITION_CTRL(); void Enable( bool x_win_on, bool y_win_on ); void SetValue( int x_value, int y_value ); @@ -168,15 +132,15 @@ public: * Class to edit/enter a size (pair of values for X and Y size) * ( INCHES or MM ) in dialog boxes ***************************************************************/ -class WinEDA_SizeCtrl : public WinEDA_PositionCtrl +class EDA_SIZE_CTRL : public EDA_POSITION_CTRL { public: - WinEDA_SizeCtrl( wxWindow* parent, const wxString& title, - const wxSize& size_to_edit, - UserUnitType user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, + const wxSize& size_to_edit, + EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); - ~WinEDA_SizeCtrl() { } + ~EDA_SIZE_CTRL() { } wxSize GetValue(); }; @@ -184,10 +148,10 @@ public: /****************************************************************/ /* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */ /****************************************************************/ -class WinEDA_ValueCtrl +class EDA_VALUE_CTRL { public: - UserUnitType m_UserUnit; + EDA_UNITS_T m_UserUnit; int m_Value; wxTextCtrl* m_ValueCtrl; private: @@ -195,11 +159,11 @@ private: wxStaticText* m_Text; public: - WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, int value, - UserUnitType user_unit, wxBoxSizer* BoxSizer, - int internal_unit = EESCHEMA_INTERNAL_UNIT ); + EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value, + EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, + int internal_unit = EESCHEMA_INTERNAL_UNIT ); - ~WinEDA_ValueCtrl(); + ~EDA_VALUE_CTRL(); int GetValue(); void SetValue( int new_value ); @@ -212,4 +176,4 @@ public: }; -#endif +#endif // _DIALOG_HELPERS_H_ diff --git a/include/gestfich.h b/include/gestfich.h index 63177b5f91..fcff27b3b4 100644 --- a/include/gestfich.h +++ b/include/gestfich.h @@ -13,7 +13,7 @@ /* Forward class declarations. */ -class WinEDAListBox; +class EDA_LIST_DIALOG; /** @@ -54,7 +54,7 @@ wxString MakeReducedFileName( const wxString& fullfilename, const wxString& default_path, const wxString& default_ext ); -WinEDAListBox* GetFileNames( char* Directory, char* Mask ); +EDA_LIST_DIALOG* GetFileNames( char* Directory, char* Mask ); int ExecuteFile( wxWindow* frame, const wxString& ExecFile, diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index d9b4295278..23ff91b2ca 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -57,7 +57,7 @@ public: int m_DisplayModText; // How to display module texts (line/ filled / sketch) bool m_DisplayPcbTrackFill; /* FALSE : tracks are show in sketch mode, * TRUE = filled */ - UserUnitType m_UserGridUnit; + EDA_UNITS_T m_UserGridUnit; wxRealPoint m_UserGridSize; EDA_3D_FRAME* m_Draw3DFrame; diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index cb517f4260..ecb9503118 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -476,7 +476,7 @@ void PCB_BASE_FRAME::LoadSettings() long itmp; cfg->Read( m_FrameName + UserGridUnitsEntry, &itmp, ( long )INCHES ); - m_UserGridUnit = (UserUnitType) itmp; + m_UserGridUnit = (EDA_UNITS_T) itmp; cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true ); cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true ); cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true ); diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 8a1428e328..5c8c8efe78 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -69,12 +69,13 @@ void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event ) void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) { - UserUnitType ii; + EDA_UNITS_T ii; DisplayOpt.DisplayPolarCood = ( m_PolarDisplay->GetSelection() == 0 ) ? false : true; ii = g_UserUnit; g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES; + if( ii != g_UserUnit ) m_Parent->ReCreateAuxiliaryToolbar(); @@ -84,11 +85,13 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) /* Updating the combobox to display the active layer. */ g_MaxLinksShowed = m_MaxShowLinks->GetValue(); Drc_On = m_DrcOn->GetValue(); + if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() ) { m_Parent->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() ); m_Parent->DrawPanel->Refresh( ); } + g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue(); diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index e845ea70b7..d4663e676a 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -1,6 +1,7 @@ -/*****************************************/ -/* Edition du pcb: Gestion des dimensions */ -/*****************************************/ +/** + * @file dimension.cpp + * @brief Dialog and code for editing a deminsion object. + */ #include "fctsys.h" #include "confirm.h" @@ -11,7 +12,7 @@ #include "drawtxt.h" #include "dialog_helpers.h" -/* Loca functions */ +/* Local functions */ static void Exit_EditDimension( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void Montre_Position_New_Dimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); @@ -33,22 +34,22 @@ static int status_dimension; /* Used in cimension creation: */ -/************************************/ +/*********************************/ /* class DIMENSION_EDITOR_DIALOG */ -/************************************/ +/*********************************/ class DIMENSION_EDITOR_DIALOG : public wxDialog { private: - PCB_EDIT_FRAME* m_Parent; - wxDC* m_DC; - DIMENSION* CurrentDimension; - WinEDA_EnterText* m_Name; - WinEDA_SizeCtrl* m_TxtSizeCtrl; - WinEDA_ValueCtrl* m_TxtWidthCtrl; - wxRadioBox* m_Mirror; - wxComboBox* m_SelLayerBox; + PCB_EDIT_FRAME* m_Parent; + wxDC* m_DC; + DIMENSION* CurrentDimension; + wxTextCtrl* m_Name; + EDA_SIZE_CTRL* m_TxtSizeCtrl; + EDA_VALUE_CTRL* m_TxtWidthCtrl; + wxRadioBox* m_Mirror; + wxComboBox* m_SelLayerBox; public: @@ -103,22 +104,33 @@ DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* parent, m_Mirror = new wxRadioBox( this, -1, _( "Display" ), wxDefaultPosition, wxSize( -1, -1 ), 2, display_msg, 1, wxRA_SPECIFY_COLS ); + if( Dimension->m_Text->m_Mirror ) m_Mirror->SetSelection( 1 ); + RightBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 ); - m_Name = new WinEDA_EnterText( this, wxT( "Text:" ), - Dimension->m_Text->m_Text, - LeftBoxSizer, wxSize( 200, -1 ) ); + LeftBoxSizer->Add( new wxStaticText( this, -1, _( "Text:" ) ), + 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); - m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ), - Dimension->m_Text->m_Size, + m_Name = new wxTextCtrl( this, -1, Dimension->m_Text->m_Text, + wxDefaultPosition, wxSize( 200, -1 ) ); + + m_Name->SetInsertionPoint( 1 ); + + LeftBoxSizer->Add( m_Name, + 0, + wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); + + m_TxtSizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), + Dimension->m_Text->m_Size, + g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits ); + + m_TxtWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ), + Dimension->m_Width, g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits ); - m_TxtWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ), - Dimension->m_Width, - g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits ); - wxStaticText* text = new wxStaticText( this, -1, _( "Layer:" ) ); LeftBoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_SelLayerBox = new wxComboBox( this, wxID_ANY, wxEmptyString, @@ -138,24 +150,21 @@ DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( PCB_EDIT_FRAME* parent, } -/**********************************************************************/ void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& event ) -/**********************************************************************/ { EndModal( -1 ); } -/***********************************************************************************/ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event ) -/***********************************************************************************/ { - if( m_DC ) // Effacement ancien texte + if( m_DC ) // Delete old text. { CurrentDimension->Draw( m_Parent->DrawPanel, m_DC, GR_XOR ); } m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED); + if( m_Name->GetValue() != wxEmptyString ) { CurrentDimension->SetText( m_Name->GetValue() ); @@ -165,12 +174,14 @@ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event ) int width = m_TxtWidthCtrl->GetValue(); int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text->m_Size ); + if( width > maxthickness ) { DisplayError( NULL, _( "The text thickness is too large for the text size. It will be clamped") ); width = maxthickness; } + CurrentDimension->m_Text->m_Thickness = CurrentDimension->m_Width = width ; CurrentDimension->m_Text->m_Mirror = ( m_Mirror->GetSelection() == 1 ) ? true : false; @@ -179,9 +190,8 @@ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event ) CurrentDimension->AdjustDimensionDetails( true ); - if( m_DC ) // Affichage nouveau texte + if( m_DC ) // Display new text { - /* Redessin du Texte */ CurrentDimension->Draw( m_Parent->DrawPanel, m_DC, GR_OR ); } @@ -190,9 +200,7 @@ void DIMENSION_EDITOR_DIALOG::OnOkClick( wxCommandEvent& event ) } -/**************************************************************/ static void Exit_EditDimension( EDA_DRAW_PANEL* Panel, wxDC* DC ) -/**************************************************************/ { DIMENSION* Dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem(); @@ -214,9 +222,7 @@ static void Exit_EditDimension( EDA_DRAW_PANEL* Panel, wxDC* DC ) } -/*************************************************************************/ DIMENSION* PCB_EDIT_FRAME::Begin_Dimension( DIMENSION* Dimension, wxDC* DC ) -/*************************************************************************/ { wxPoint pos; @@ -254,10 +260,12 @@ DIMENSION* PCB_EDIT_FRAME::Begin_Dimension( DIMENSION* Dimension, wxDC* DC ) Dimension->m_Text->m_Size = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize; int width = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth; int maxthickness = Clamp_Text_PenSize(width, Dimension->m_Text->m_Size ); + if( width > maxthickness ) { width = maxthickness; } + Dimension->m_Text->m_Thickness = Dimension->m_Width = width ; Dimension->AdjustDimensionDetails( ); @@ -324,8 +332,7 @@ static void Montre_Position_New_Dimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, deltax = Dimension->TraitD_ox - Dimension->TraitG_ox; deltay = Dimension->TraitD_oy - Dimension->TraitG_oy; - /* Calcul de la direction de deplacement - * ( perpendiculaire a l'axe de la cote ) */ + /* Calculating the direction of travel perpendicular to the selected axis. */ angle = atan2( (double)deltay, (double)deltax ) + (M_PI / 2); deltax = pos.x - Dimension->TraitD_ox; @@ -345,9 +352,7 @@ static void Montre_Position_New_Dimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, } -/***************************************************************/ void PCB_EDIT_FRAME::Install_Edit_Dimension( DIMENSION* Dimension, wxDC* DC ) -/***************************************************************/ { if( Dimension == NULL ) return; @@ -358,9 +363,7 @@ void PCB_EDIT_FRAME::Install_Edit_Dimension( DIMENSION* Dimension, wxDC* DC ) } -/*******************************************************************/ void PCB_EDIT_FRAME::Delete_Dimension( DIMENSION* Dimension, wxDC* DC ) -/*******************************************************************/ { if( Dimension == NULL ) return; @@ -372,4 +375,3 @@ void PCB_EDIT_FRAME::Delete_Dimension( DIMENSION* Dimension, wxDC* DC ) Dimension->UnLink(); OnModify(); } - diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 58330bafd3..39b7fdadd9 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -694,7 +694,7 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() if( g_LibName_List.GetCount() == 0 ) return; - WinEDAListBox dlg( this, _( "Select Active Library:" ), g_LibName_List, m_CurrentLib ); + EDA_LIST_DIALOG dlg( this, _( "Select Active Library:" ), g_LibName_List, m_CurrentLib ); if( dlg.ShowModal() != wxID_OK ) return; diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index f6f0066fcd..6499b4a00a 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -357,8 +357,8 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, if( footprint_names_list.GetCount() ) { msg.Printf( _( "Modules [%d items]" ), footprint_names_list.GetCount() ); - WinEDAListBox dlg( aWindow, msg, footprint_names_list, OldName, - DisplayCmpDoc, GetComponentDialogPosition() ); + EDA_LIST_DIALOG dlg( aWindow, msg, footprint_names_list, OldName, + DisplayCmpDoc, GetComponentDialogPosition() ); if( dlg.ShowModal() == wxID_OK ) CmpName = dlg.GetTextSelection(); @@ -411,7 +411,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb ) msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() ); - WinEDAListBox dlg( this, msg, listnames, wxEmptyString ); + EDA_LIST_DIALOG dlg( this, msg, listnames, wxEmptyString ); dlg.SortList(); if( dlg.ShowModal() == wxID_OK ) diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 309f1de316..ce329b4edb 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -39,8 +39,8 @@ private: PCB_EDIT_FRAME* m_Parent; wxDC* m_DC; MIREPCB* m_MirePcb; - WinEDA_ValueCtrl* m_MireWidthCtrl; - WinEDA_ValueCtrl* m_MireSizeCtrl; + EDA_VALUE_CTRL* m_MireWidthCtrl; + EDA_VALUE_CTRL* m_MireSizeCtrl; wxRadioBox* m_MireShape; public: @@ -99,16 +99,16 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); // Size: - m_MireSizeCtrl = new WinEDA_ValueCtrl( this, _( "Size" ), - m_MirePcb->m_Size, - g_UserUnit, LeftBoxSizer, - m_Parent->m_InternalUnits ); + m_MireSizeCtrl = new EDA_VALUE_CTRL( this, _( "Size" ), + m_MirePcb->m_Size, + g_UserUnit, LeftBoxSizer, + m_Parent->m_InternalUnits ); // Width: - m_MireWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ), - m_MirePcb->m_Width, - g_UserUnit, LeftBoxSizer, - m_Parent->m_InternalUnits ); + m_MireWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ), + m_MirePcb->m_Width, + g_UserUnit, LeftBoxSizer, + m_Parent->m_InternalUnits ); // Shape wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) }; diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index cc1f8cad80..d374dcaf80 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -724,7 +724,7 @@ class WinEDA_SetParamShapeFrame : public wxDialog private: PCB_EDIT_FRAME* m_Parent; wxRadioBox* m_ShapeOptionCtrl; - WinEDA_SizeCtrl* m_SizeCtrl; + EDA_SIZE_CTRL* m_SizeCtrl; public: WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, const wxPoint& pos ); ~WinEDA_SetParamShapeFrame() { }; @@ -740,12 +740,12 @@ private: BEGIN_EVENT_TABLE( WinEDA_SetParamShapeFrame, wxDialog ) -EVT_BUTTON( wxID_OK, WinEDA_SetParamShapeFrame::OnOkClick ) -EVT_BUTTON( wxID_CANCEL, WinEDA_SetParamShapeFrame::OnCancelClick ) -EVT_BUTTON( ID_READ_SHAPE_FILE, - WinEDA_SetParamShapeFrame::ReadDataShapeDescr ) + EVT_BUTTON( wxID_OK, WinEDA_SetParamShapeFrame::OnOkClick ) + EVT_BUTTON( wxID_CANCEL, WinEDA_SetParamShapeFrame::OnCancelClick ) + EVT_BUTTON( ID_READ_SHAPE_FILE, WinEDA_SetParamShapeFrame::ReadDataShapeDescr ) END_EVENT_TABLE() + WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, const wxPoint& framepos ) : wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ), @@ -755,6 +755,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, if( PolyEdges ) free( PolyEdges ); + PolyEdges = NULL; PolyEdgesCount = 0; @@ -787,9 +788,9 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, wxRA_SPECIFY_COLS ); LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 ); - m_SizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ), ShapeSize, - g_UserUnit, LeftBoxSizer, - PCB_INTERNAL_UNIT ); + m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, + g_UserUnit, LeftBoxSizer, + PCB_INTERNAL_UNIT ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 698cf40fb2..deb5d44b74 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -729,13 +729,14 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName( void ) for( ; Module != NULL; Module = (MODULE*) Module->Next() ) listnames.Add( Module->m_Reference->m_Text ); - WinEDAListBox dlg( this, _( "Components" ), listnames, wxEmptyString ); + EDA_LIST_DIALOG dlg( this, _( "Components" ), listnames, wxEmptyString ); if( dlg.ShowModal() != wxID_OK ) return NULL; wxString ref = dlg.GetTextSelection(); Module = (MODULE*) GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { if( Module->m_Reference->m_Text == ref ) diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index 0334f0df55..4fe478e890 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -48,7 +48,7 @@ void PCB_BASE_FRAME::InstallGridFrame( const wxPoint& pos ) return; m_UserGridSize = dlg.GetGridSize(); - m_UserGridUnit = (UserUnitType) dlg.GetGridUnits(); + m_UserGridUnit = (EDA_UNITS_T) dlg.GetGridUnits(); GetScreen()->m_GridOrigin = dlg.GetGridOrigin(); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); From 9f98995a46717c6b9d57bb5d1b4692e281dd1c5d Mon Sep 17 00:00:00 2001 From: Andrey Fedorushkov Date: Wed, 7 Sep 2011 13:27:02 +0400 Subject: [PATCH 6/9] pcbnew: * Add hotkey "P" - place item * Add record and play macros for sequence hotkey. Macros set to numeric key 0..9. + - start record macros ... | + - end record macros - play macros * Add menu save/read macros to/from xml-file * Add configure rotate angle for rotate module: 45 or 90 deg. * fix segfault when move/drag segment if disconnected to pad --- CHANGELOG.txt | 16 + common/common.cpp | 2 + common/hotkeys_basic.cpp | 9 +- common/pcbcommon.cpp | 1 + include/common.h | 2 + include/id.h | 4 + include/pcbcommon.h | 1 + include/wxPcbStruct.h | 22 + pcbnew/dialogs/dialog_general_options.cpp | 13 + ...ialog_general_options_BoardEditor_base.cpp | 21 +- ...ialog_general_options_BoardEditor_base.fbp | 2476 +++++++++-------- .../dialog_general_options_BoardEditor_base.h | 10 +- pcbnew/edit.cpp | 4 +- pcbnew/hotkeys.cpp | 53 + pcbnew/hotkeys.h | 23 +- pcbnew/hotkeys_board_editor.cpp | 249 +- pcbnew/menubar_pcbframe.cpp | 21 + pcbnew/move_or_drag_track.cpp | 9 + pcbnew/pcbframe.cpp | 10 + pcbnew/pcbnew_config.cpp | 133 + 20 files changed, 1927 insertions(+), 1152 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 54c163b4ea..93d8aa65e7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,22 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. + +2011-Sept-07, UPDATE Andrey Fedorushkov +================================================================================ +Pcbnew: + Add hotkey "P" - place item + Add Roman Bashkov patch for record/play sequence hotkey macros + Add record and play macros for sequence hotkey. + Macros set to numeric key 0..9: + + - start record macros + ... | + + - end record macros + - play macros + Add menu save/read macros to/from xml-file + Add configure rotate angle for rotate module: 45 or 90 deg. + Fix segfault when move/drag segment if disconnected to pad + 2011-Sept-01, UPDATE Jean-Pierre Charras ================================================================================ Add Fabrizio Tappero in contribuotors list. diff --git a/common/common.cpp b/common/common.cpp index 91bfb8ed0c..fb48935876 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -59,6 +59,7 @@ const wxString NetlistFileExtension( wxT( "net" ) ); const wxString GerberFileExtension( wxT( "pho" ) ); const wxString PcbFileExtension( wxT( "brd" ) ); const wxString PdfFileExtension( wxT( "pdf" ) ); +const wxString MacrosFileExtension( wxT( "mcr" ) ); /* Proper wxFileDialog wild card definitions. */ const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) ); @@ -67,6 +68,7 @@ const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString PcbFileWildcard( _( "Kicad printed circuit board files (*.brd)|*.brd" ) ); const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) ); +const wxString MacrosFileWildcard( _( "Kicad recorded macros (*.mcr)|*.mcr" ) ); const wxString AllFilesWildcard( _( "All files (*)|*" ) ); diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 927afbf21e..d2a5364e57 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -349,9 +349,12 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, for( ; *List != NULL; List++ ) { Ki_HotkeyInfo* hk_decr = *List; - keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); - msg += wxT( "" ) + hk_decr->m_InfoMsg + wxT(""); - msg += wxT("  ") + keyname + wxT( "" ); + if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) + { + keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); + msg += wxT( "" ) + hk_decr->m_InfoMsg + wxT(""); + msg += wxT("  ") + keyname + wxT( "" ); + } } } diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index f4df6dd2be..b1237d6054 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -83,6 +83,7 @@ const wxString ModuleFileWildcard( _( "Kicad footprint library files (*.mod)|*.m int g_CurrentVersionPCB = 1; +int g_RotationAngle; int g_TimeOut; // Timer for automatic saving int g_SaveTime; // Time for next saving diff --git a/include/common.h b/include/common.h index 9c66cf3d7c..46e011a98b 100644 --- a/include/common.h +++ b/include/common.h @@ -146,6 +146,7 @@ extern const wxString NetlistFileExtension; extern const wxString GerberFileExtension; extern const wxString PcbFileExtension; extern const wxString PdfFileExtension; +extern const wxString MacrosFileExtension; extern const wxString ProjectFileWildcard; extern const wxString SchematicFileWildcard; @@ -154,6 +155,7 @@ extern const wxString NetlistFileWildcard; extern const wxString GerberFileWildcard; extern const wxString PcbFileWildcard; extern const wxString PdfFileWildcard; +extern const wxString MacrosFileWildcard; extern const wxString AllFilesWildcard; diff --git a/include/id.h b/include/id.h index 52e2b040fb..d089838cc9 100644 --- a/include/id.h +++ b/include/id.h @@ -42,6 +42,10 @@ enum main_id ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, ID_PREFERENCES_HOTKEY_END, + ID_PREFRENCES_MACROS, + ID_PREFRENCES_MACROS_SAVE, + ID_PREFRENCES_MACROS_READ, + ID_GEN_PLOT, ID_GEN_PLOT_PS, ID_GEN_PLOT_HPGL, diff --git a/include/pcbcommon.h b/include/pcbcommon.h index dc484ae558..890ede0adf 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -35,6 +35,7 @@ extern wxString g_ViaType_Name[4]; extern int g_CurrentVersionPCB; +extern int g_RotationAngle; extern int g_TimeOut; // Timer for automatic saving extern int g_SaveTime; // Time for next saving diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index edf1db001f..560fd8c547 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -10,6 +10,7 @@ #include "base_struct.h" #include "param_config.h" #include "class_layer_box_selector.h" +#include "class_macros_record.h" #include "richio.h" #ifndef PCB_INTERNAL_UNIT @@ -53,6 +54,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME void updateTraceWidthSelectBox(); void updateViaSizeSelectBox(); + int m_RecordingMacros; + MACROS_RECORDED m_Macros[10]; + protected: PCB_LAYER_WIDGET* m_Layers; @@ -165,6 +169,22 @@ public: void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ); void OnUpdateSelectAutoTrackWidth( wxUpdateUIEvent& aEvent ); + /** + * Function RecordMacros + * record sequence hotkeys and cursor position to macros. + */ + void RecordMacros(wxDC* aDC, int aNumber); + + /** + * Function CallMacros + * play hotkeys and cursor position from recorded macros. + */ + void CallMacros(wxDC* aDC, const wxPoint& aPosition, int aNumber); + + void SaveMacros(); + + void ReadMacros(); + /** * Function PrintPage , virtual * used to print a page @@ -308,6 +328,8 @@ public: */ bool OnHotkeyDeleteItem( wxDC* aDC ); + bool OnHotkeyPlaceItem( wxDC* aDC ); + bool OnHotkeyEditItem( int aIdCommand ); /** diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 5c8c8efe78..3ede8c6b7d 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -41,6 +41,16 @@ void Dialog_GeneralOptions::init() m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 ); m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 ); + + switch( g_RotationAngle ) + { + case 450: + m_RotationAngle->SetSelection( 0 ); + break; + default: + m_RotationAngle->SetSelection( 1 ); + } + wxString timevalue; timevalue << g_TimeOut / 60; m_SaveTime->SetValue( timevalue ); @@ -82,6 +92,9 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) m_Parent->m_CursorShape = m_CursorShape->GetSelection(); g_TimeOut = 60 * m_SaveTime->GetValue(); + + g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() ); + /* Updating the combobox to display the active layer. */ g_MaxLinksShowed = m_MaxShowLinks->GetValue(); Drc_On = m_DrcOn->GetValue(); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp index 6557d6f2b6..3f98b085b0 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 6 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -66,6 +66,16 @@ DialogGeneralOptionsBoardEditor_base::DialogGeneralOptionsBoardEditor_base( wxWi bMiddleLeftSizer->Add( m_SaveTime, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_staticTextRotationAngle = new wxStaticText( this, wxID_ANY, _("Rotation Angle"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextRotationAngle->Wrap( -1 ); + bMiddleLeftSizer->Add( m_staticTextRotationAngle, 0, wxALL, 5 ); + + wxString m_RotationAngleChoices[] = { _("45"), _("90") }; + int m_RotationAngleNChoices = sizeof( m_RotationAngleChoices ) / sizeof( wxString ); + m_RotationAngle = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RotationAngleNChoices, m_RotationAngleChoices, 0 ); + m_RotationAngle->SetSelection( 0 ); + bMiddleLeftSizer->Add( m_RotationAngle, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bMainSizer->Add( bMiddleLeftSizer, 1, wxEXPAND, 5 ); wxStaticBoxSizer* bMiddleRightBoxSizer; @@ -73,49 +83,41 @@ DialogGeneralOptionsBoardEditor_base::DialogGeneralOptionsBoardEditor_base( wxWi m_DrcOn = new wxCheckBox( this, wxID_DRC_ONOFF, _("Drc ON"), wxDefaultPosition, wxDefaultSize, 0 ); m_DrcOn->SetValue(true); - m_DrcOn->SetToolTip( _("Enable/disable the DRC control.\nWhen DRC is disable, all connections are allowed.") ); bMiddleRightBoxSizer->Add( m_DrcOn, 0, wxALL|wxEXPAND, 5 ); m_ShowGlobalRatsnest = new wxCheckBox( this, wxID_GENERAL_RATSNEST, _("Show Ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowGlobalRatsnest->SetToolTip( _("Show (or not) the full rastnest.") ); bMiddleRightBoxSizer->Add( m_ShowGlobalRatsnest, 0, wxALL, 5 ); m_ShowModuleRatsnest = new wxCheckBox( this, wxID_RATSNEST_MODULE, _("Show Mod Ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowModuleRatsnest->SetToolTip( _("Shows (or not) the local ratsnest relative to a footprint, when moving it.\nThis ratsnest is useful to place a footprint.") ); bMiddleRightBoxSizer->Add( m_ShowModuleRatsnest, 0, wxALL, 5 ); m_TrackAutodel = new wxCheckBox( this, wxID_TRACK_AUTODEL, _("Tracks Auto Del"), wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackAutodel->SetToolTip( _("Enable/disable the automatic track deletion when recreating a track.") ); bMiddleRightBoxSizer->Add( m_TrackAutodel, 0, wxALL, 5 ); m_Track_45_Only_Ctrl = new wxCheckBox( this, wxID_TRACKS45, _("Track only 45 degrees"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Track_45_Only_Ctrl->SetToolTip( _("If enabled, force tracks directions to H, V or 45 degrees, when creating a track.") ); bMiddleRightBoxSizer->Add( m_Track_45_Only_Ctrl, 0, wxALL, 5 ); m_Segments_45_Only_Ctrl = new wxCheckBox( this, wxID_SEGMENTS45, _("Segments 45 Only"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Segments_45_Only_Ctrl->SetToolTip( _("If enabled, force segments directions to H, V or 45 degrees, when creating a segment on technical layers.") ); bMiddleRightBoxSizer->Add( m_Segments_45_Only_Ctrl, 0, wxALL, 5 ); m_AutoPANOpt = new wxCheckBox( this, wxID_AUTOPAN, _("Auto PAN"), wxDefaultPosition, wxDefaultSize, 0 ); - m_AutoPANOpt->SetToolTip( _("Allows auto pan when creating a track, or moving an item.") ); bMiddleRightBoxSizer->Add( m_AutoPANOpt, 0, wxALL, 5 ); m_Track_DoubleSegm_Ctrl = new wxCheckBox( this, wxID_ANY, _("Double Segm Track"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Track_DoubleSegm_Ctrl->SetToolTip( _("If enabled, uses two track segments, with 45 degrees angle between them when creating a new track ") ); bMiddleRightBoxSizer->Add( m_Track_DoubleSegm_Ctrl, 0, wxALL, 5 ); @@ -163,4 +165,5 @@ DialogGeneralOptionsBoardEditor_base::~DialogGeneralOptionsBoardEditor_base() // Disconnect Events m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGeneralOptionsBoardEditor_base::OnOkClick ), NULL, this ); m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGeneralOptionsBoardEditor_base::OnCancelClick ), NULL, this ); + } diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp index 074fdb0faa..691d141b9b 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp @@ -1,1130 +1,1346 @@ - - - - - - C++ - 1 - UTF-8 - connect - dialog_general_options_BoardEditor_base - 1000 - none - 1 - DialogGeneralOptionsBoardEditor_base - - . - - 1 - 1 - 0 - - - - - 1 - - - - 0 - wxID_ANY - - - DialogGeneralOptionsBoardEditor_base - - 585,280 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - General settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxHORIZONTAL - none - - 5 - wxEXPAND - 1 - - - bLeftSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - - "No Display" "Display" - - 1 - - - 0 - wxID_POLAR_CTRL - Display Polar Coord - 1 - - - m_PolarDisplay - protected - - 1 - - wxRA_SPECIFY_COLS - - Activates the display of relative coordinates from relative origin (set by the space key) to the cursor, in polar coordinates (angle and distance) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Inches" "Millimeters" - - 1 - - - 0 - wxID_UNITS - Units - 1 - - - m_UnitsSelection - protected - - 1 - - wxRA_SPECIFY_COLS - - Selection of units used to display dimensions and positions of items - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Small cross" "Full screen cursor" - - 1 - - - 0 - wxID_CURSOR_SHAPE - Cursor - 1 - - - m_CursorShape - protected - - 0 - - wxRA_SPECIFY_COLS - - Main cursor shape selection (small cross or large cursor) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bMiddleLeftSizer - wxVERTICAL - none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - - 1 - - - 0 - wxID_ANY - Max Links: - - - m_staticTextmaxlinks - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - 1 - 5 - - 1 - - m_MaxShowLinks - protected - - - wxSP_ARROW_KEYS - - Adjust the number of ratsnets shown from cursor to closest pads - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - Auto Save (minutes): - - - m_staticTextautosave - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - 0 - 60 - - 0 - - m_SaveTime - protected - - - wxSP_ARROW_KEYS - - Delay after the first change to create a backup file of the board on disk. - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - - 1 - - wxID_ANY - Options: - - bMiddleRightBoxSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - 1 - - 1 - - - 0 - wxID_DRC_ONOFF - Drc ON - - - m_DrcOn - protected - - - - - Enable/disable the DRC control. When DRC is disable, all connections are allowed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_GENERAL_RATSNEST - Show Ratsnest - - - m_ShowGlobalRatsnest - protected - - - - - Show (or not) the full rastnest. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_RATSNEST_MODULE - Show Mod Ratsnest - - - m_ShowModuleRatsnest - protected - - - - - Shows (or not) the local ratsnest relative to a footprint, when moving it. This ratsnest is useful to place a footprint. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_TRACK_AUTODEL - Tracks Auto Del - - - m_TrackAutodel - protected - - - - - Enable/disable the automatic track deletion when recreating a track. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_TRACKS45 - Track only 45 degrees - - - m_Track_45_Only_Ctrl - protected - - - - - If enabled, force tracks directions to H, V or 45 degrees, when creating a track. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_SEGMENTS45 - Segments 45 Only - - - m_Segments_45_Only_Ctrl - protected - - - - - If enabled, force segments directions to H, V or 45 degrees, when creating a segment on technical layers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_AUTOPAN - Auto PAN - - - m_AutoPANOpt - protected - - - - - Allows auto pan when creating a track, or moving an item. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Double Segm Track - - - m_Track_DoubleSegm_Ctrl - protected - - - - - If enabled, uses two track segments, with 45 degrees angle between them when creating a new track - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bRightSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - - "Never" "When creating tracks" "Always" - - 1 - - - 0 - wxID_ANY - Magnetic Pads - 1 - - - m_MagneticPadOptCtrl - protected - - 0 - - wxRA_SPECIFY_COLS - - control the capture of the pcb cursor when the mouse cursor enters a pad area - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Never" "When creating tracks" "Always" - - 1 - - - 0 - wxID_MAGNETIC_TRACKS - Magnetic Tracks - 1 - - - m_MagneticTrackOptCtrl - protected - - 0 - - wxRA_SPECIFY_COLS - - Control the capture of the pcb cursor when the mouse cursor enters a track - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - - - 1 - 1 - - - 0 - wxID_OK - OK - - - m_buttonOK - protected - - - - - - - - - OnOkClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL|wxALL - 0 - - - - 0 - 1 - - - 0 - wxID_CANCEL - Cancel - - - m_buttonCANCEL - protected - - - - - - - - - OnCancelClick - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_general_options_BoardEditor_base + 1000 + none + 1 + DialogGeneralOptionsBoardEditor_base + + . + + 1 + 1 + 1 + 0 + + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DialogGeneralOptionsBoardEditor_base + + 585,280 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + General settings + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bLeftSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "No Display" "Display" + + 1 + 1 + + + 0 + wxID_POLAR_CTRL + Display Polar Coord + 1 + + + m_PolarDisplay + protected + + 1 + + wxRA_SPECIFY_COLS + + Activates the display of relative coordinates from relative origin (set by the space key) to the cursor, in polar coordinates (angle and distance) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Inches" "Millimeters" + + 1 + 1 + + + 0 + wxID_UNITS + Units + 1 + + + m_UnitsSelection + protected + + 1 + + wxRA_SPECIFY_COLS + + Selection of units used to display dimensions and positions of items + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Small cross" "Full screen cursor" + + 1 + 1 + + + 0 + wxID_CURSOR_SHAPE + Cursor + 1 + + + m_CursorShape + protected + + 0 + + wxRA_SPECIFY_COLS + + Main cursor shape selection (small cross or large cursor) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bMiddleLeftSizer + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Max Links: + + + m_staticTextmaxlinks + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + 1 + 5 + + 1 + + m_MaxShowLinks + protected + + + wxSP_ARROW_KEYS + + Adjust the number of ratsnets shown from cursor to closest pads + + wxFILTER_NONE + wxDefaultValidator + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Auto Save (minutes): + + + m_staticTextautosave + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + 0 + 60 + + 0 + + m_SaveTime + protected + + + wxSP_ARROW_KEYS + + Delay after the first change to create a backup file of the board on disk. + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Rotation Angle + + + m_staticTextRotationAngle + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 0 + + + "45" "90" + + 1 + 1 + + + 0 + wxID_ANY + + + m_RotationAngle + protected + + 0 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 1 + + wxID_ANY + Options: + + bMiddleRightBoxSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + 1 + + 1 + 1 + + + 0 + wxID_DRC_ONOFF + Drc ON + + + m_DrcOn + protected + + + + + Enable/disable the DRC control. When DRC is disable, all connections are allowed. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_GENERAL_RATSNEST + Show Ratsnest + + + m_ShowGlobalRatsnest + protected + + + + + Show (or not) the full rastnest. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_RATSNEST_MODULE + Show Mod Ratsnest + + + m_ShowModuleRatsnest + protected + + + + + Shows (or not) the local ratsnest relative to a footprint, when moving it. This ratsnest is useful to place a footprint. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_TRACK_AUTODEL + Tracks Auto Del + + + m_TrackAutodel + protected + + + + + Enable/disable the automatic track deletion when recreating a track. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_TRACKS45 + Track only 45 degrees + + + m_Track_45_Only_Ctrl + protected + + + + + If enabled, force tracks directions to H, V or 45 degrees, when creating a track. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_SEGMENTS45 + Segments 45 Only + + + m_Segments_45_Only_Ctrl + protected + + + + + If enabled, force segments directions to H, V or 45 degrees, when creating a segment on technical layers. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_AUTOPAN + Auto PAN + + + m_AutoPANOpt + protected + + + + + Allows auto pan when creating a track, or moving an item. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + Double Segm Track + + + m_Track_DoubleSegm_Ctrl + protected + + + + + If enabled, uses two track segments, with 45 degrees angle between them when creating a new track + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bRightSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "Never" "When creating tracks" "Always" + + 1 + 1 + + + 0 + wxID_ANY + Magnetic Pads + 1 + + + m_MagneticPadOptCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + control the capture of the pcb cursor when the mouse cursor enters a pad area + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Never" "When creating tracks" "Always" + + 1 + 1 + + + 0 + wxID_MAGNETIC_TRACKS + Magnetic Tracks + 1 + + + m_MagneticTrackOptCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + Control the capture of the pcb cursor when the mouse cursor enters a track + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 1 + 1 + 1 + + + 0 + wxID_OK + OK + + + m_buttonOK + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_CANCEL + Cancel + + + m_buttonCANCEL + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h index f1988c92cf..63318b28c0 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 6 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,8 @@ class DialogGeneralOptionsBoardEditor_base : public wxDialog wxSpinCtrl* m_MaxShowLinks; wxStaticText* m_staticTextautosave; wxSpinCtrl* m_SaveTime; + wxStaticText* m_staticTextRotationAngle; + wxChoice* m_RotationAngle; wxCheckBox* m_DrcOn; wxCheckBox* m_ShowGlobalRatsnest; wxCheckBox* m_ShowModuleRatsnest; @@ -70,11 +73,12 @@ class DialogGeneralOptionsBoardEditor_base : public wxDialog wxButton* m_buttonCANCEL; // Virtual event handlers, overide them in your derived class - virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } public: + DialogGeneralOptionsBoardEditor_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("General settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 585,280 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DialogGeneralOptionsBoardEditor_base(); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 257b25d108..54637cc52b 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -658,7 +658,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos); - Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true ); + Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true ); break; case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: @@ -685,7 +685,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos); - Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true ); + Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true ); break; case ID_POPUP_PCB_CHANGE_SIDE_MODULE: diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index d5401e15ee..9886725ee2 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -65,6 +65,8 @@ static Ki_HotkeyInfo HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' ); static Ki_HotkeyInfo HkDragTrackKeepSlope( wxT( "Drag track keep slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' ); +static Ki_HotkeyInfo HkPlaceItem( wxT( "Place Item" ), + HK_PLACE_ITEM, 'P' ); static Ki_HotkeyInfo HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL ); static Ki_HotkeyInfo HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END ); @@ -136,6 +138,46 @@ static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ), HK_SWITCH_TRACK_DISPLAY_MODE, 'K' ); static Ki_HotkeyInfo HkAddModule( wxT( "Add Module" ), HK_ADD_MODULE, 'O' ); +/* Record and play macros */ +static Ki_HotkeyInfo HkRecordMacros0( wxT( "Record Macros 0" ), HK_RECORD_MACROS_0, GR_KB_CTRL+'0' ); + +static Ki_HotkeyInfo HkCallMacros0( wxT( "Call Macross 0" ), HK_CALL_MACROS_0, '0' ); + +static Ki_HotkeyInfo HkRecordMacros1( wxT( "Record Macros 1" ), HK_RECORD_MACROS_1, GR_KB_CTRL+'1' ); + +static Ki_HotkeyInfo HkCallMacros1( wxT( "Call Macross 1" ), HK_CALL_MACROS_1, '1' ); + +static Ki_HotkeyInfo HkRecordMacros2( wxT( "Record Macros 2" ), HK_RECORD_MACROS_2, GR_KB_CTRL+'2' ); + +static Ki_HotkeyInfo HkCallMacros2( wxT( "Call Macross 2" ), HK_CALL_MACROS_2, '2' ); + +static Ki_HotkeyInfo HkRecordMacros3( wxT( "Record Macros 3" ), HK_RECORD_MACROS_3, GR_KB_CTRL+'3' ); + +static Ki_HotkeyInfo HkCallMacros3( wxT( "Call Macross 3" ), HK_CALL_MACROS_3, '3' ); + +static Ki_HotkeyInfo HkRecordMacros4( wxT( "Record Macros 4" ), HK_RECORD_MACROS_4, GR_KB_CTRL+'4' ); + +static Ki_HotkeyInfo HkCallMacros4( wxT( "Call Macross 4" ), HK_CALL_MACROS_4, '4' ); + +static Ki_HotkeyInfo HkRecordMacros5( wxT( "Record Macros 5" ), HK_RECORD_MACROS_5, GR_KB_CTRL+'5' ); + +static Ki_HotkeyInfo HkCallMacros5( wxT( "Call Macross 5" ), HK_CALL_MACROS_5, '5' ); + +static Ki_HotkeyInfo HkRecordMacros6( wxT( "Record Macros 6" ), HK_RECORD_MACROS_6, GR_KB_CTRL+'6' ); + +static Ki_HotkeyInfo HkCallMacros6( wxT( "Call Macross 6" ), HK_CALL_MACROS_6, '6' ); + +static Ki_HotkeyInfo HkRecordMacros7( wxT( "Record Macros 7" ), HK_RECORD_MACROS_7, GR_KB_CTRL+'7' ); + +static Ki_HotkeyInfo HkCallMacros7( wxT( "Call Macross 7" ), HK_CALL_MACROS_7, '7' ); + +static Ki_HotkeyInfo HkRecordMacros8( wxT( "Record Macros 8" ), HK_RECORD_MACROS_8, GR_KB_CTRL+'8' ); + +static Ki_HotkeyInfo HkCallMacros8( wxT( "Call Macross 8" ), HK_CALL_MACROS_8, '8' ); + +static Ki_HotkeyInfo HkRecordMacros9( wxT( "Record Macros 9" ), HK_RECORD_MACROS_9, GR_KB_CTRL+'9' ); + +static Ki_HotkeyInfo HkCallMacros9( wxT( "Call Macross 9" ), HK_CALL_MACROS_9, '9' ); // List of common hotkey descriptors Ki_HotkeyInfo* common_Hotkey_List[] = @@ -155,6 +197,7 @@ Ki_HotkeyInfo* board_edit_Hotkey_List[] = &HkAddNewTrack, &HkAddVia, &HkAddMicroVia, &HkSwitchTrackPosture, &HkDragTrackKeepSlope, + &HkPlaceItem, &HkEndTrack, &HkMoveItem, &HkFlipFootprint, &HkRotateItem, &HkDragFootprint, &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, @@ -163,6 +206,16 @@ Ki_HotkeyInfo* board_edit_Hotkey_List[] = &HkSwitch2InnerLayer2, &HkSwitch2InnerLayer3, &HkSwitch2InnerLayer4, &HkSwitch2InnerLayer5, &HkSwitch2InnerLayer6, &HkSwitch2ComponentLayer, &HkSwitch2NextCopperLayer, &HkSwitch2PreviousCopperLayer,&HkAddModule, + &HkRecordMacros0, &HkCallMacros0, + &HkRecordMacros1, &HkCallMacros1, + &HkRecordMacros2, &HkCallMacros2, + &HkRecordMacros3, &HkCallMacros3, + &HkRecordMacros4, &HkCallMacros4, + &HkRecordMacros5, &HkCallMacros5, + &HkRecordMacros6, &HkCallMacros6, + &HkRecordMacros7, &HkCallMacros7, + &HkRecordMacros8, &HkCallMacros8, + &HkRecordMacros9, &HkCallMacros9, NULL }; diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index ce22cabbdb..1c3178e04c 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -30,6 +30,7 @@ enum hotkey_id_commnand { HK_SWITCH_TRACK_DISPLAY_MODE, HK_FIND_ITEM, HK_EDIT_ITEM, + HK_PLACE_ITEM, HK_SWITCH_LAYER_TO_COPPER, HK_SWITCH_LAYER_TO_COMPONENT, HK_SWITCH_LAYER_TO_NEXT, @@ -49,7 +50,27 @@ enum hotkey_id_commnand { HK_SWITCH_LAYER_TO_INNER13, HK_SWITCH_LAYER_TO_INNER14, HK_ADD_MODULE, - HK_SLIDE_TRACK + HK_SLIDE_TRACK, + HK_RECORD_MACROS_0, + HK_CALL_MACROS_0, + HK_RECORD_MACROS_1, + HK_CALL_MACROS_1, + HK_RECORD_MACROS_2, + HK_CALL_MACROS_2, + HK_RECORD_MACROS_3, + HK_CALL_MACROS_3, + HK_RECORD_MACROS_4, + HK_CALL_MACROS_4, + HK_RECORD_MACROS_5, + HK_CALL_MACROS_5, + HK_RECORD_MACROS_6, + HK_CALL_MACROS_6, + HK_RECORD_MACROS_7, + HK_CALL_MACROS_7, + HK_RECORD_MACROS_8, + HK_CALL_MACROS_8, + HK_RECORD_MACROS_9, + HK_CALL_MACROS_9 }; // Full list of hotkey descriptors for borad editor and footprint editor diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 3ef11de870..95edfb757c 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -18,6 +18,79 @@ */ +/** + * Function RecordMacros. + * Record sequence hotkeys and cursor position to macros. + * @param aDC = current device context + * @param aNumber The current number macros. + */ +void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber) +{ + assert(aNumber >= 0); + assert(aNumber < 10); + wxString msg, tmp; + + if( m_RecordingMacros < 0 ) + { + m_RecordingMacros = aNumber; + m_Macros[aNumber].m_StartPosition = GetScreen()->GetCrossHairPosition(false); + m_Macros[aNumber].m_Record.clear(); + + msg.Printf( wxT("%s %d"), _( "Recording macros" ), aNumber); + SetStatusText(msg); + } + else + { + m_RecordingMacros = -1; + + msg.Printf( wxT("%s %d %s"), _( "Macros" ), aNumber, _( "recorded" )); + SetStatusText(msg); + } +} + + +/** + * Function CallMacros + * play hotkeys and cursor position from recorded macros. + * @param aDC = current device context + * @param aPosition The current cursor position in logical (drawing) units. + * @param aNumber The current number macros. +*/ +void PCB_EDIT_FRAME::CallMacros(wxDC* aDC, const wxPoint& aPosition, int aNumber) +{ + PCB_SCREEN* screen = GetScreen(); + wxPoint tPosition; + + wxString msg; + + msg.Printf( wxT("%s %d"), _( "Call macros"), aNumber); + SetStatusText( msg ); + + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + + tPosition = screen->GetNearestGridPosition( aPosition ); + + DrawPanel->CrossHairOff( aDC ); + screen->SetMousePosition( tPosition ); + GeneralControl( aDC, tPosition ); + + for( std::list::iterator i = m_Macros[aNumber].m_Record.begin(); i != m_Macros[aNumber].m_Record.end(); i++ ) + { + wxPoint tmpPos = tPosition + i->m_Position; + + screen->SetMousePosition( tmpPos ); + + GeneralControl( aDC, tmpPos, i->m_HotkeyCode ); + } + + cmd.SetId( ID_ZOOM_REDRAW ); + GetEventHandler()->ProcessEvent( cmd ); + + DrawPanel->CrossHairOn( aDC ); +} + + /** * Function OnHotKey. * ** Commands are case insensitive ** @@ -53,6 +126,25 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( HK_Descr == NULL ) return; + if( (m_RecordingMacros != -1) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_1) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_1) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_2) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_2) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_3) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_3) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_4) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_4) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_5) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_5) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_6) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_6) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_7) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_7) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_8) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_8) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_9) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_9) && + (HK_Descr->m_Idcommand != HK_RECORD_MACROS_0) && (HK_Descr->m_Idcommand != HK_CALL_MACROS_0) ) + { + MACROS_RECORD macros_record; + macros_record.m_HotkeyCode = aHotkeyCode; + macros_record.m_Idcommand = HK_Descr->m_Idcommand; + macros_record.m_Position = screen->GetNearestGridPosition( aPosition ) - m_Macros[m_RecordingMacros].m_StartPosition; + m_Macros[m_RecordingMacros].m_Record.push_back(macros_record); + } + // Create a wxCommandEvent that will be posted in some hot keys functions wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); @@ -66,6 +158,86 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit return; break; + case HK_RECORD_MACROS_0: + RecordMacros(aDC, 0); + break; + + case HK_RECORD_MACROS_1: + RecordMacros(aDC, 1); + break; + + case HK_RECORD_MACROS_2: + RecordMacros(aDC, 2); + break; + + case HK_RECORD_MACROS_3: + RecordMacros(aDC, 3); + break; + + case HK_RECORD_MACROS_4: + RecordMacros(aDC, 4); + break; + + case HK_RECORD_MACROS_5: + RecordMacros(aDC, 5); + break; + + case HK_RECORD_MACROS_6: + RecordMacros(aDC, 6); + break; + + case HK_RECORD_MACROS_7: + RecordMacros(aDC, 7); + break; + + case HK_RECORD_MACROS_8: + RecordMacros(aDC, 8); + break; + + case HK_RECORD_MACROS_9: + RecordMacros(aDC, 9); + break; + + case HK_CALL_MACROS_0: + CallMacros(aDC, aPosition, 0); + break; + + case HK_CALL_MACROS_1: + CallMacros(aDC, aPosition, 1); + break; + + case HK_CALL_MACROS_2: + CallMacros(aDC, aPosition, 2); + break; + + case HK_CALL_MACROS_3: + CallMacros(aDC, aPosition, 3); + break; + + case HK_CALL_MACROS_4: + CallMacros(aDC, aPosition, 4); + break; + + case HK_CALL_MACROS_5: + CallMacros(aDC, aPosition, 5); + break; + + case HK_CALL_MACROS_6: + CallMacros(aDC, aPosition, 6); + break; + + case HK_CALL_MACROS_7: + CallMacros(aDC, aPosition, 7); + break; + + case HK_CALL_MACROS_8: + CallMacros(aDC, aPosition, 8); + break; + + case HK_CALL_MACROS_9: + CallMacros(aDC, aPosition, 9); + break; + case HK_SWITCH_LAYER_TO_PREVIOUS: ll = getActiveLayer(); if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) ) @@ -282,6 +454,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit OnHotkeyMoveItem( HK_DRAG_TRACK_KEEP_SLOPE ); break; + case HK_PLACE_ITEM: + OnHotkeyPlaceItem( aDC ); + break; + case HK_ADD_NEW_TRACK: // Start new track if( getActiveLayer() > LAYER_N_FRONT ) break; @@ -361,7 +537,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); } } @@ -521,7 +697,7 @@ bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand ) wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); return true; } @@ -621,13 +797,78 @@ bool PCB_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand ) wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); return true; } return false; } +/** + * Function OnHotkeyPlaceItem + * Place the item (footprint, track, text .. ) found under the mouse cursor + * An item can be placed only if there is this item currently edited + * Only a footprint, a pad or a track can be placed + * @param aDC = current device context + * @return true if an item was placedd + */ +bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC ) +{ + BOARD_ITEM* item = GetCurItem(); + bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED; + bool itemCurrentlyEdited = item && item->m_Flags; + + DrawPanel->m_AutoPAN_Request = false; + + if( itemCurrentlyEdited ) + { + DrawPanel->m_IgnoreMouseEvents = true; + DrawPanel->CrossHairOff( aDC ); + + switch( item->Type() ) + { + case TYPE_TRACK: + case TYPE_VIA: + if( item->m_Flags & IS_DRAGGED ) + PlaceDraggedOrMovedTrackSegment( (TRACK*) item, aDC ); + break; + + case TYPE_TEXTE: + Place_Texte_Pcb( (TEXTE_PCB*) item, aDC ); + break; + + case TYPE_TEXTE_MODULE: + PlaceTexteModule( (TEXTE_MODULE*) item, aDC ); + break; + + case TYPE_PAD: + PlacePad( (D_PAD*) item, aDC ); + break; + + case TYPE_MODULE: + Place_Module( (MODULE*) item, aDC ); + break; + + case TYPE_MIRE: + Place_Mire( (MIREPCB*) item, aDC ); + break; + + case TYPE_DRAWSEGMENT: + if( no_tool ) // when no tools: existing item moving. + Place_DrawItem( (DRAWSEGMENT*) item, aDC ); + break; + + default: + break; + } + + DrawPanel->m_IgnoreMouseEvents = false; + DrawPanel->CrossHairOn( aDC ); + + return true; + } + return false; +} /** * Function OnHotkeyRotateItem @@ -682,7 +923,7 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand ) wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); evt.SetEventObject( this ); evt.SetId( evt_type ); - wxPostEvent( this, evt ); + GetEventHandler()->ProcessEvent( evt ); return true; } diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index bca4ff3d23..be5ff97e91 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -558,6 +558,27 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // Hotkey submenu AddHotkeyConfigMenu( configmenu ); + + + // Macros submenu + wxMenu* macrosMenu = new wxMenu; + + item = new wxMenuItem( macrosMenu, ID_PREFRENCES_MACROS_SAVE, + _( "Save macros" ), + _( "Save macros to file" ) ); + macrosMenu->Append( item ); + + item = new wxMenuItem( macrosMenu, ID_PREFRENCES_MACROS_READ, + _( "Read macros" ), + _( "Read macros from file" ) ); + macrosMenu->Append( item ); + + // Append macros menu to config menu + AddMenuItem( configmenu, macrosMenu, + -1, _( "Macros" ), + _( "Macros save/read operations" ), + add_dimension_xpm ); + configmenu->AppendSeparator(); // Save Preferences diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index c0b52665d9..78bb511fef 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -1004,7 +1004,16 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) * tested by test_1_net_connexion() ) */ int masque_layer = g_TabOneLayerMask[Track->GetLayer()]; Track->start = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_Start, masque_layer ); + if( Track->start ) + Track->SetState( BEGIN_ONPAD, ON ); + else + Track->SetState( BEGIN_ONPAD, OFF ); + Track->end = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_End, masque_layer ); + if( Track->end ) + Track->SetState( END_ONPAD, ON ); + else + Track->SetState( END_ONPAD, OFF ); } EraseDragList(); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 4c09d787e2..55898a35a4 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -116,6 +116,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_PCB_PAD_SETUP, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_READ, PCB_EDIT_FRAME::Process_Config ) + EVT_MENU( ID_PREFRENCES_MACROS_SAVE, PCB_EDIT_FRAME::Process_Config ) + EVT_MENU( ID_PREFRENCES_MACROS_READ, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_PCB_DISPLAY_OPTIONS_SETUP, PCB_EDIT_FRAME::InstallDisplayOptionsDialog ) EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::Process_Special_Functions ) @@ -274,6 +276,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_show_layer_manager_tools = true; m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; + m_RecordingMacros = -1; + for ( int i = 0; i < 10; i++ ) + m_Macros[i].m_Record.clear(); + SetBoard( new BOARD( NULL, this ) ); // Create the PCB_LAYER_WIDGET *after* SetBoard(): @@ -409,6 +415,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, PCB_EDIT_FRAME::~PCB_EDIT_FRAME() { + m_RecordingMacros = -1; + for( int i = 0; i < 10; i++ ) + m_Macros[i].m_Record.clear(); + delete m_drc; } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 35000da4fd..9b5aad62ee 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -2,6 +2,8 @@ /** pcbnew_config.cpp : configuration **/ /****************************************/ +#include + #include "fctsys.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" @@ -114,6 +116,15 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; + /* Macros IDs*/ + case ID_PREFRENCES_MACROS_SAVE: + SaveMacros(); + break; + + case ID_PREFRENCES_MACROS_READ: + ReadMacros(); + break; + default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } @@ -383,6 +394,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() WHITE ) ); // Miscellaneous: + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle, + 900, 450, 900 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TimeOut" ), &g_TimeOut, 600, 0, 60000 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed, @@ -395,3 +408,123 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() true ) ); return m_configSettings; } + + +/** + */ +void PCB_EDIT_FRAME::SaveMacros() +{ + wxFileName fn; + wxXmlDocument xml; + wxXmlNode *rootNode = new wxXmlNode::wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "macrosrootnode" ), wxEmptyString, NULL); + wxXmlNode *macrosNode, *hkNode; + wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp; + wxString str, hkStr, xStr, yStr; + + fn = GetScreen()->GetFileName(); + fn.SetExt( MacrosFileExtension ); + + wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(), + MacrosFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + xml.SetRoot( rootNode ); + + for( int number = 9; number >= 0; number--) + { + str.Printf( wxT( "%d" ), number); + macrosProp = new wxXmlProperty::wxXmlProperty( wxT("number"), str); + + macrosNode = new wxXmlNode::wxXmlNode(rootNode, wxXML_ELEMENT_NODE, wxT( "macros" ), wxEmptyString, macrosProp); + + for( std::list::reverse_iterator i = m_Macros[number].m_Record.rbegin(); i != m_Macros[number].m_Record.rend(); i++ ) + { + hkStr.Printf( wxT( "%d" ), i->m_HotkeyCode); + xStr.Printf( wxT( "%d" ), i->m_Position.x); + yStr.Printf( wxT( "%d" ), i->m_Position.y); + + yProp = new wxXmlProperty( wxT( "y" ), yStr); + xProp = new wxXmlProperty( wxT( "x" ), xStr, yProp); + hkProp = new wxXmlProperty( wxT( "hkcode" ), hkStr, xProp); + + hkNode = new wxXmlNode(macrosNode, wxXML_ELEMENT_NODE, wxT( "hotkey" ), wxEmptyString, hkProp); + } + } + + xml.SetFileEncoding(wxT("UTF-8")); + xml.Save(dlg.GetFilename()); +} + + +/** + */ +void PCB_EDIT_FRAME::ReadMacros() +{ + wxString str; + wxFileName fn; + + fn = GetScreen()->GetFileName(); + fn.SetExt( MacrosFileExtension ); + + wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(), + fn.GetFullName(), MacrosFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + if( !wxFileExists( dlg.GetPath() ) ) + { + wxString msg; + msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); + DisplayError( this, msg ); + return; + } + + wxXmlDocument xml; + + xml.SetFileEncoding(wxT("UTF-8")); + if( !xml.Load( dlg.GetFilename() ) ) + return; + + wxXmlNode *macrosNode = xml.GetRoot()->GetChildren(); + + while( macrosNode ) + { + int number = -1; + + if( macrosNode->GetName() == wxT( "macros" ) ) + { + number = wxAtoi( macrosNode->GetPropVal( wxT( "number" ), wxT( "-1" ) ) ); + + if( number >= 0 && number < 10 ) + { + m_Macros[number].m_Record.clear(); + + wxXmlNode *hotkeyNode = macrosNode->GetChildren(); + while( hotkeyNode ) + { + if( hotkeyNode->GetName() == wxT( "hotkey" ) ) + { + int x = wxAtoi( hotkeyNode->GetPropVal( wxT( "x" ), wxT( "0" ) ) ); + int y = wxAtoi( hotkeyNode->GetPropVal( wxT( "y" ), wxT( "0" ) ) ); + int hk = wxAtoi( hotkeyNode->GetPropVal( wxT( "hkcode" ), wxT( "0" ) ) ); + + MACROS_RECORD macros_record; + macros_record.m_HotkeyCode = hk; + macros_record.m_Position.x = x; + macros_record.m_Position.y = y; + m_Macros[number].m_Record.push_back(macros_record); + } + + hotkeyNode = hotkeyNode->GetNext(); + } + } + } + + macrosNode = macrosNode->GetNext(); + } + +} From 0648addabfd7e2cae381a9e229dea264f7c05350 Mon Sep 17 00:00:00 2001 From: Andrey Fedorushkov Date: Wed, 7 Sep 2011 14:38:11 +0400 Subject: [PATCH 7/9] add forgotten file to bzr3107, add GOST to KICAD_BULD_VERSION if defined KICAD_GOST --- common/build_version.cpp | 6 +++++- include/class_macros_record.h | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 include/class_macros_record.h diff --git a/common/build_version.cpp b/common/build_version.cpp index d2996e6041..1e0ac76c58 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -6,7 +6,11 @@ #endif #ifndef KICAD_BUILD_VERSION -#define KICAD_BUILD_VERSION "(2011-aug-04)" +#if defined KICAD_GOST +# define KICAD_BUILD_VERSION "(2011-aug-04 GOST)" +#else +# define KICAD_BUILD_VERSION "(2011-aug-04)" +#endif #endif diff --git a/include/class_macros_record.h b/include/class_macros_record.h new file mode 100644 index 0000000000..51fcc6d871 --- /dev/null +++ b/include/class_macros_record.h @@ -0,0 +1,26 @@ +/****************************************/ +/* Macros: used to record and play */ +/* sequence hotkeys and their positions */ +/****************************************/ + +#ifndef _CLASS_MACROS_RECORD_H +#define _CLASS_MACROS_RECORD_H + +#include + +class MACROS_RECORD +{ +public: + int m_HotkeyCode; + int m_Idcommand; + wxPoint m_Position; +}; + +class MACROS_RECORDED +{ +public: + wxPoint m_StartPosition; + std::list m_Record; +}; + +#endif // _CLASS_MACROS_RECORD_H From c7dee039670cb40ac9d54f74d4761de25914aa15 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 7 Sep 2011 20:41:35 +0200 Subject: [PATCH 8/9] Remove minizip from kicad sources. Useless because now (and since a long time) wxWidgets supports full zip file read/write, and minizip build creates problems under Windows, due to zlib not always installed. --- CMakeLists.txt | 5 - .../{FindZLIB.cmake => FindZLIB.cmake.unused} | 0 kicad/CMakeLists.txt | 4 - kicad/files-io.cpp | 81 +- kicad/minizip/CMakeLists.txt | 43 - kicad/minizip/crypt.h | 132 -- kicad/minizip/ioapi.c | 177 --- kicad/minizip/ioapi.h | 75 -- kicad/minizip/iowin32.c | 270 ---- kicad/minizip/iowin32.h | 21 - kicad/minizip/minizip.c | 400 ------ kicad/minizip/zip.c | 1170 ----------------- kicad/minizip/zip.h | 235 ---- 13 files changed, 52 insertions(+), 2561 deletions(-) rename CMakeModules/{FindZLIB.cmake => FindZLIB.cmake.unused} (100%) delete mode 100644 kicad/minizip/CMakeLists.txt delete mode 100644 kicad/minizip/crypt.h delete mode 100644 kicad/minizip/ioapi.c delete mode 100644 kicad/minizip/ioapi.h delete mode 100644 kicad/minizip/iowin32.c delete mode 100644 kicad/minizip/iowin32.h delete mode 100644 kicad/minizip/minizip.c delete mode 100644 kicad/minizip/zip.c delete mode 100644 kicad/minizip/zip.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 063850dca9..b8746408d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,6 @@ endif(WIN32) # Path to local CMake modules. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) -# Command line option to enable or disable building minizip. Minizip -# building is enabled by default. Use -DKICAD_MINIZIP=OFF to disable -# building minizip. -option(KICAD_MINIZIP "enable/disable building minizip (default ON)" ON) - # Russian GOST patch option(wxUSE_UNICODE "enable/disable building unicode (default OFF)") option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)") diff --git a/CMakeModules/FindZLIB.cmake b/CMakeModules/FindZLIB.cmake.unused similarity index 100% rename from CMakeModules/FindZLIB.cmake rename to CMakeModules/FindZLIB.cmake.unused diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt index 42fdf5c745..00c7abff28 100644 --- a/kicad/CMakeLists.txt +++ b/kicad/CMakeLists.txt @@ -52,7 +52,3 @@ endif(APPLE) install(TARGETS kicad DESTINATION ${KICAD_BIN} COMPONENT binary) - -if(KICAD_MINIZIP) - add_subdirectory(minizip) -endif(KICAD_MINIZIP) diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 8b158e8672..61c221df64 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -9,6 +9,7 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include +#include #include #include #include @@ -107,6 +108,15 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) { + /* List of file extensions to save. */ + static const wxChar* extentionList[] = { + wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), wxT( "*.brd" ), + wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ), + wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ), + NULL + }; + + wxString msg; size_t i; wxFileName fileName = m_ProjectFileName; wxString oldPath = wxGetCwd(); @@ -123,17 +133,6 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) wxFileName zip = dlg.GetPath(); - /* List of file extensions to save. */ - static const wxChar* extList[] = { - wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), wxT( "*.brd" ), - wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ), - wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.dcm" ), - NULL - }; - - wxString cmd = wxT( "-o " ); // run minizip with option -o (overwrite) - cmd += QuoteFullPath(zip); - wxString currdirname = wxT( "." ); currdirname += zip.GetPathSeparator(); wxDir dir( currdirname ); @@ -141,37 +140,61 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) if( !dir.IsOpened() ) return; - wxString f; + // Prepare the zip file + wxString zipfilename = zip.GetFullPath(); - for( i = 0; extList[i] != 0; i++ ) + wxFFileOutputStream ostream(zipfilename); + wxZipOutputStream zipstream( ostream ); + + // Build list of filenames to put in zip archive + wxString currFilename; + int zipBytesCnt = 0; // Size of the zip file + for( i = 0; extentionList[i] != 0; i++ ) { - bool cont = dir.GetFirst( &f, extList[i] ); + bool cont = dir.GetFirst( &currFilename, extentionList[i] ); while( cont ) { - wxFileName fn( f ); - wxString filename = QuoteFullPath(fn); - cmd += wxT( " " ) + filename; - PrintMsg( _( "Archive file " ) + filename + wxT( "\n" ) ); - cont = dir.GetNext( &f ); + wxFileSystem fsfile; + PrintMsg( _( "Archive file " ) + currFilename ); + // Read input file and put it in zip file: + wxFSFile * infile = fsfile.OpenFile(currFilename); + if( infile ) + { + zipstream.PutNextEntry( currFilename, infile->GetModificationTime() ); + infile->GetStream()->Read( zipstream ); + zipstream.CloseEntry(); + int zippedsize = zipstream.GetSize() - zipBytesCnt; + zipBytesCnt = zipstream.GetSize(); + PrintMsg( wxT(" ") ); + msg.Printf( _( "(%d bytes, compressed %d bytes)\n"), + infile->GetStream()->GetSize(), zippedsize ); + PrintMsg( msg ); + delete infile; + } + else + { + PrintMsg( _(" >>Error\n") ); + } + + cont = dir.GetNext( &currFilename ); } } -#ifdef __WINDOWS__ -#define ZIPPER wxT( "minizip.exe" ) -#else -#define ZIPPER wxT( "minizip" ) -#endif - if( ExecuteFile( this, ZIPPER, cmd ) >= 0 ) + zipBytesCnt = ostream.GetSize(); + if( zipstream.Close() ) { - wxString msg; - wxString filename = QuoteFullPath(zip); - msg.Printf( _("\nZip archive <%s> created" ), GetChars( filename ) ); + msg.Printf( _("\nZip archive <%s> created (%d bytes)" ), + GetChars( zipfilename ), zipBytesCnt ); PrintMsg( msg ); PrintMsg( wxT( "\n** end **\n" ) ); } else - PrintMsg( wxT( "Minizip command error, abort\n" ) ); + { + msg.Printf( wxT( "Unable to create archive <%s>, abort\n" ), + GetChars( zipfilename ) ); + PrintMsg( msg ); + } wxSetWorkingDirectory( oldPath ); } diff --git a/kicad/minizip/CMakeLists.txt b/kicad/minizip/CMakeLists.txt deleted file mode 100644 index 601c468123..0000000000 --- a/kicad/minizip/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -find_package(ZLIB QUIET) -if(ZLIB_FOUND) - message(STATUS "Check for installed zlib -- found") -else(ZLIB_FOUND) - message(STATUS "Check for installed zlib -- not found") - message(STATUS "Use wxWidgets zlib") - - # zlib is not installed, and in this case wxWidgets creates its own zlib library - # include files are in ${wxWidgets_ROOT_DIR}/src/zlib - # and the corresponding library is libwxzlib-.a (like libwxzlib-2.8.a) - # and we try to use it - # Unfortunately, we have no way to know exactly the path of zlib.h because this file - # is in wxWidgets sources, not in wxWidgets include path. - find_path(ZLIB_INCLUDE_DIR - zlib.h - PATHS ${wxWidgets_ROOT_DIR}/../src/zlib/ ${wxWidgets_ROOT_DIR}/src/zlib/ - DOC "location of zlib include files" - ) - - find_file( - ZLIB_LIBRARIES NAMES ${wxWidgets_LIB_DIR}/libwxzlib-2.8.a - ZLIB_LIBRARIES NAMES ${wxWidgets_LIB_DIR}/libwxzlib-2.9.a libwxzlib.a - PATHS ${wxWidgets_ROOT_DIR}/lib/ - PATH_SUFFIXES gcc_lib gcc_dll - DOC "location of wxzlib library file" - ) -endif(ZLIB_FOUND) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${ZLIB_INCLUDE_DIR}) - -set(MINIZIP_SRCS - ioapi.c - minizip.c - zip.c) - -add_executable(minizip ${MINIZIP_SRCS}) - -target_link_libraries(minizip ${ZLIB_LIBRARIES}) - -install(TARGETS minizip - DESTINATION ${KICAD_BIN} - COMPONENT binary) diff --git a/kicad/minizip/crypt.h b/kicad/minizip/crypt.h deleted file mode 100644 index 9c7a89cbe8..0000000000 --- a/kicad/minizip/crypt.h +++ /dev/null @@ -1,132 +0,0 @@ -/* crypt.h -- base code for crypt/uncrypt ZIPfile - - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - This code is a modified version of crypting code in Infozip distribution - - The encryption/decryption parts of this source code (as opposed to the - non-echoing password parts) were originally written in Europe. The - whole source package can be freely distributed, including from the USA. - (Prior to January 2000, re-export from the US was a violation of US law.) - - This encryption code is a direct transcription of the algorithm from - Roger Schlafly, described by Phil Katz in the file appnote.txt. This - file (appnote.txt) is distributed with the PKZIP program (even in the - version without encryption capabilities). - - If you don't need crypting in your application, just define symbols - NOCRYPT and NOUNCRYPT. - - This code support the "Traditional PKWARE Encryption". - - The new AES encryption added on Zip format by Winzip (see the page - http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong - Encryption is not supported. -*/ - -#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) - -/*********************************************************************** - * Return the next byte in the pseudo-random sequence - */ -static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) -{ - unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an - * unpredictable manner on 16-bit systems; not a problem - * with any known compiler so far, though */ - - temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; - return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); -} - -/*********************************************************************** - * Update the encryption keys with the next byte of plain text - */ -static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) -{ - (*(pkeys+0)) = CRC32((*(pkeys+0)), c); - (*(pkeys+1)) += (*(pkeys+0)) & 0xff; - (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; - { - register int keyshift = (int)((*(pkeys+1)) >> 24); - (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); - } - return c; -} - - -/*********************************************************************** - * Initialize the encryption keys and the random header according to - * the given password. - */ -static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) -{ - *(pkeys+0) = 305419896L; - *(pkeys+1) = 591751049L; - *(pkeys+2) = 878082192L; - while (*passwd != '\0') { - update_keys(pkeys,pcrc_32_tab,(int)*passwd); - passwd++; - } -} - -#define zdecode(pkeys,pcrc_32_tab,c) \ - (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) - -#define zencode(pkeys,pcrc_32_tab,c,t) \ - (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) - -#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED - -#define RAND_HEAD_LEN 12 - /* "last resort" source for second part of crypt seed pattern */ -# ifndef ZCR_SEED2 -# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ -# endif - -static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) - const char *passwd; /* password string */ - unsigned char *buf; /* where to write header */ - int bufSize; - unsigned long* pkeys; - const unsigned long* pcrc_32_tab; - unsigned long crcForCrypting; -{ - int n; /* index in random header */ - int t; /* temporary */ - int c; /* random byte */ - unsigned char header[RAND_HEAD_LEN-2]; /* random header */ - static unsigned calls = 0; /* ensure different random header each time */ - - if (bufSize> 7) & 0xff; - header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); - } - /* Encrypt random header (last two bytes is high word of crc) */ - init_keys(passwd, pkeys, pcrc_32_tab); - for (n = 0; n < RAND_HEAD_LEN-2; n++) - { - buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); - } - buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); - buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); - return n; -} - -#endif diff --git a/kicad/minizip/ioapi.c b/kicad/minizip/ioapi.c deleted file mode 100644 index 80443b761f..0000000000 --- a/kicad/minizip/ioapi.c +++ /dev/null @@ -1,177 +0,0 @@ -/* ioapi.c -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant -*/ - -#include -#include -#include - -#include "zlib.h" -#include "ioapi.h" - - - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -voidpf ZCALLBACK fopen_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); - -uLong ZCALLBACK fread_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); - -uLong ZCALLBACK fwrite_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); - -long ZCALLBACK ftell_file_func OF(( - voidpf opaque, - voidpf stream)); - -long ZCALLBACK fseek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); - -int ZCALLBACK fclose_file_func OF(( - voidpf opaque, - voidpf stream)); - -int ZCALLBACK ferror_file_func OF(( - voidpf opaque, - voidpf stream)); - - -voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) - voidpf opaque; - const char* filename; - int mode; -{ - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen(filename, mode_fopen); - return file; -} - - -uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - void* buf; - uLong size; -{ - uLong ret; - ret = fread(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - - -uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - const void* buf; - uLong size; -{ - uLong ret; - ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - -long ZCALLBACK ftell_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - long ret; - ret = ftell((FILE *)stream); - return ret; -} - -long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) - voidpf opaque; - voidpf stream; - uLong offset; - int origin; -{ - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - fseek((FILE *)stream, offset, fseek_origin); - return ret; -} - -int ZCALLBACK fclose_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - int ret; - ret = fclose((FILE *)stream); - return ret; -} - -int ZCALLBACK ferror_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - int ret; - ret = ferror((FILE *)stream); - return ret; -} - -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; -{ - pzlib_filefunc_def->zopen_file = fopen_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell_file = ftell_file_func; - pzlib_filefunc_def->zseek_file = fseek_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; -} diff --git a/kicad/minizip/ioapi.h b/kicad/minizip/ioapi.h deleted file mode 100644 index 6bc2a2cc87..0000000000 --- a/kicad/minizip/ioapi.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ioapi.h -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant -*/ - -#ifndef _ZLIBIOAPI_H -#define _ZLIBIOAPI_H - - -#define ZLIB_FILEFUNC_SEEK_CUR (1) -#define ZLIB_FILEFUNC_SEEK_END (2) -#define ZLIB_FILEFUNC_SEEK_SET (0) - -#define ZLIB_FILEFUNC_MODE_READ (1) -#define ZLIB_FILEFUNC_MODE_WRITE (2) -#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) - -#define ZLIB_FILEFUNC_MODE_EXISTING (4) -#define ZLIB_FILEFUNC_MODE_CREATE (8) - - -#ifndef ZCALLBACK - -#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) -#define ZCALLBACK CALLBACK -#else -#define ZCALLBACK -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); - -typedef struct zlib_filefunc_def_s -{ - open_file_func zopen_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell_file_func ztell_file; - seek_file_func zseek_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc_def; - - - -void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); - -#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) -#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) -#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) -#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) -#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) -#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/kicad/minizip/iowin32.c b/kicad/minizip/iowin32.c deleted file mode 100644 index 02b27cb761..0000000000 --- a/kicad/minizip/iowin32.c +++ /dev/null @@ -1,270 +0,0 @@ -/* iowin32.c -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - This IO API version uses the Win32 API (for Microsoft Windows) - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant -*/ - -#include - -#include "zlib.h" -#include "ioapi.h" -#include "iowin32.h" - -#ifndef INVALID_HANDLE_VALUE -#define INVALID_HANDLE_VALUE (0xFFFFFFFF) -#endif - -#ifndef INVALID_SET_FILE_POINTER -#define INVALID_SET_FILE_POINTER ((DWORD)-1) -#endif - -voidpf ZCALLBACK win32_open_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); - -uLong ZCALLBACK win32_read_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); - -uLong ZCALLBACK win32_write_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); - -long ZCALLBACK win32_tell_file_func OF(( - voidpf opaque, - voidpf stream)); - -long ZCALLBACK win32_seek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); - -int ZCALLBACK win32_close_file_func OF(( - voidpf opaque, - voidpf stream)); - -int ZCALLBACK win32_error_file_func OF(( - voidpf opaque, - voidpf stream)); - -typedef struct -{ - HANDLE hf; - int error; -} WIN32FILE_IOWIN; - -voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) - voidpf opaque; - const char* filename; - int mode; -{ - const char* mode_fopen = NULL; - DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; - HANDLE hFile = 0; - voidpf ret=NULL; - - dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; - - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - { - dwDesiredAccess = GENERIC_READ; - dwCreationDisposition = OPEN_EXISTING; - dwShareMode = FILE_SHARE_READ; - } - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - { - dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; - dwCreationDisposition = OPEN_EXISTING; - } - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - { - dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; - dwCreationDisposition = CREATE_ALWAYS; - } - - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, - dwCreationDisposition, dwFlagsAndAttributes, NULL); - - if (hFile == INVALID_HANDLE_VALUE) - hFile = NULL; - - if (hFile != NULL) - { - WIN32FILE_IOWIN w32fiow; - w32fiow.hf = hFile; - w32fiow.error = 0; - ret = malloc(sizeof(WIN32FILE_IOWIN)); - if (ret==NULL) - CloseHandle(hFile); - else *((WIN32FILE_IOWIN*)ret) = w32fiow; - } - return ret; -} - - -uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - void* buf; - uLong size; -{ - uLong ret=0; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - if (hFile != NULL) - if (!ReadFile(hFile, buf, size, &ret, NULL)) - { - DWORD dwErr = GetLastError(); - if (dwErr == ERROR_HANDLE_EOF) - dwErr = 0; - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - } - - return ret; -} - - -uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - const void* buf; - uLong size; -{ - uLong ret=0; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - - if (hFile !=NULL) - if (!WriteFile(hFile, buf, size, &ret, NULL)) - { - DWORD dwErr = GetLastError(); - if (dwErr == ERROR_HANDLE_EOF) - dwErr = 0; - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - } - - return ret; -} - -long ZCALLBACK win32_tell_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - long ret=-1; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - if (hFile != NULL) - { - DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); - if (dwSet == INVALID_SET_FILE_POINTER) - { - DWORD dwErr = GetLastError(); - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - ret = -1; - } - else - ret=(long)dwSet; - } - return ret; -} - -long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) - voidpf opaque; - voidpf stream; - uLong offset; - int origin; -{ - DWORD dwMoveMethod=0xFFFFFFFF; - HANDLE hFile = NULL; - - long ret=-1; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - dwMoveMethod = FILE_CURRENT; - break; - case ZLIB_FILEFUNC_SEEK_END : - dwMoveMethod = FILE_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - dwMoveMethod = FILE_BEGIN; - break; - default: return -1; - } - - if (hFile != NULL) - { - DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); - if (dwSet == INVALID_SET_FILE_POINTER) - { - DWORD dwErr = GetLastError(); - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - ret = -1; - } - else - ret=0; - } - return ret; -} - -int ZCALLBACK win32_close_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - int ret=-1; - - if (stream!=NULL) - { - HANDLE hFile; - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - if (hFile != NULL) - { - CloseHandle(hFile); - ret=0; - } - free(stream); - } - return ret; -} - -int ZCALLBACK win32_error_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - int ret=-1; - if (stream!=NULL) - { - ret = ((WIN32FILE_IOWIN*)stream) -> error; - } - return ret; -} - -void fill_win32_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; -{ - pzlib_filefunc_def->zopen_file = win32_open_file_func; - pzlib_filefunc_def->zread_file = win32_read_file_func; - pzlib_filefunc_def->zwrite_file = win32_write_file_func; - pzlib_filefunc_def->ztell_file = win32_tell_file_func; - pzlib_filefunc_def->zseek_file = win32_seek_file_func; - pzlib_filefunc_def->zclose_file = win32_close_file_func; - pzlib_filefunc_def->zerror_file = win32_error_file_func; - pzlib_filefunc_def->opaque=NULL; -} diff --git a/kicad/minizip/iowin32.h b/kicad/minizip/iowin32.h deleted file mode 100644 index c0ebd50738..0000000000 --- a/kicad/minizip/iowin32.h +++ /dev/null @@ -1,21 +0,0 @@ -/* iowin32.h -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - This IO API version uses the Win32 API (for Microsoft Windows) - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant -*/ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); - -#ifdef __cplusplus -} -#endif diff --git a/kicad/minizip/minizip.c b/kicad/minizip/minizip.c deleted file mode 100644 index 917569d96c..0000000000 --- a/kicad/minizip/minizip.c +++ /dev/null @@ -1,400 +0,0 @@ -/* MiniZip 1.00, demo of zLib + Zip package written by Gilles Vollant - * Modifie le 2 juin 2004 JPC - */ -#include -#include -#include -#include -#include -#include - -#ifndef WIN32 -# include -# include -# include -# include -#else -# include -# include -#endif - -#include "zip.h" - -#ifdef WIN32 - -//#define USEWIN32IOAPI -#include "iowin32.h" -#endif - - -#define WRITEBUFFERSIZE (16384) -#define MAXFILENAME (1024) - -int g_Verbose = 1; - - -/*****************************/ -uLong filetime( - const char* filename, /* name of file to get info on */ - tm_zip* tmzip, /* return value: access, modific. and creation times */ - uLong* dt ) /* dostime */ -/*****************************/ -#ifdef WIN32 -{ - int ret = 0; - - { - FILETIME ftLocal; - HANDLE hFind; - WIN32_FIND_DATA ff32; - - hFind = FindFirstFile( filename, &ff32 ); - if( hFind != INVALID_HANDLE_VALUE ) - { - FileTimeToLocalFileTime( &(ff32.ftLastWriteTime), &ftLocal ); - FileTimeToDosDateTime( &ftLocal, ( (LPWORD) dt ) + 1, ( (LPWORD) dt ) + 0 ); - FindClose( hFind ); - ret = 1; - } - } - return ret; -} - - -#else -#ifdef unix -{ - int ret = 0; - struct stat s; /* results of stat() */ - struct tm* filedate; - time_t tm_t = 0; - - if( strcmp( filename, "-" )!=0 ) - { - char name[MAXFILENAME + 10]; - int len = strlen( filename ); - - strncpy( name, filename, MAXFILENAME ); - /* strncpy doesnt append the trailing NULL, of the string is too long. */ - name[ MAXFILENAME ] = '\0'; - - if( name[len - 1] == '/' ) - name[len - 1] = '\0'; - /* not all systems allow stat'ing a file with / appended */ - if( stat( name, &s )==0 ) - { - tm_t = s.st_mtime; - ret = 1; - } - } - filedate = localtime( &tm_t ); - - tmzip->tm_sec = filedate->tm_sec; - tmzip->tm_min = filedate->tm_min; - tmzip->tm_hour = filedate->tm_hour; - tmzip->tm_mday = filedate->tm_mday; - tmzip->tm_mon = filedate->tm_mon; - tmzip->tm_year = filedate->tm_year; - - return ret; -} -#else -{ - return 0; -} -#endif -#endif - - -/*******************************************/ -int check_exist_file( const char* filename ) -{ -/*******************************************/ - FILE* ftestexist; - int ret = 1; - - ftestexist = fopen( filename, "rb" ); - if( ftestexist == NULL ) - ret = 0; - else - fclose( ftestexist ); - return ret; -} - - -/* calculate the CRC32 of a file, - * because to encrypt a file, we need known the CRC32 of the file before */ -int getFileCrc( const char* filenameinzip, - void* buf, - unsigned long size_buf, - unsigned long* result_crc ) -{ - unsigned long calculate_crc = 0; - int err = ZIP_OK; - FILE* fin = fopen( filenameinzip, "rb" ); - unsigned long size_read = 0; - unsigned long total_read = 0; - - if( fin==NULL ) - { - err = ZIP_ERRNO; - } - - if( err == ZIP_OK ) - do - { - err = ZIP_OK; - size_read = (int) fread( buf, 1, size_buf, fin ); - if( size_read < size_buf ) - if( feof( fin )==0 ) - { - printf( "error in reading %s\n", filenameinzip ); - err = ZIP_ERRNO; - } - - if( size_read>0 ) - calculate_crc = crc32( calculate_crc, buf, size_read ); - total_read += size_read; - } while( (err == ZIP_OK) && (size_read>0) ); - - if( fin ) - fclose( fin ); - - *result_crc = calculate_crc; - if( g_Verbose ) - printf( "file %s crc %lx\n", filenameinzip, calculate_crc ); - return err; -} - - -/********************************/ -int main( int argc, char* argv[] ) -{ -/********************************/ - int i; - int opt_overwrite = 0; - int opt_compress_level = Z_DEFAULT_COMPRESSION; - int zipfilenamearg = 0; - char filename_try[MAXFILENAME + 16]; - int zipok; - int err = 0; - int size_buf = 0; - void* buf = NULL; - const char* password = NULL; - - if( argc <= 1 ) - { - printf( "Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ - " -o Overwrite existing file.zip\n" \ - " -a Append to existing file.zip\n" \ - " -0 Store only, -1 Compress faster, -9 Compress better [5]\n\n" ); - return 0; - } - - for( i = 1; i < argc; i++ ) - { - if( (*argv[i])=='-' ) /* Find options */ - { - const char* p = argv[i] + 1; - - while( (*p)!='\0' ) - { - char c = *(p++); - if( (c=='o') || (c=='O') ) - opt_overwrite = 1; - else if( (c=='a') || (c=='A') ) - opt_overwrite = 2; - else if( (c>='0') && (c<='9') ) - opt_compress_level = c - '0'; - - else if( ( (c=='p') || (c=='P') ) && (i + 1='a') && (rep<='z') ) - rep -= 0x20; - } while( (rep!='Y') && (rep!='N') && (rep!='A') ); - - if( rep=='N' ) - zipok = 0; - if( rep=='A' ) - opt_overwrite = 2; - } - } - - if( zipok==1 ) - { - zipFile zf; - int errclose; -#ifdef USEWIN32IOAPI - zlib_filefunc_def ffunc; - fill_win32_filefunc( &ffunc ); - zf = zipOpen2( filename_try, (opt_overwrite==2) ? 2 : 0, NULL, &ffunc ); -#else - zf = zipOpen( filename_try, (opt_overwrite==2) ? 2 : 0 ); -#endif - - if( zf == NULL ) - { - printf( "error opening %s\n", filename_try ); - err = ZIP_ERRNO; - } - else - if( g_Verbose ) - printf( "creating %s\n", filename_try ); - - for( i = zipfilenamearg + 1; (i0 ) - { - err = zipWriteInFileInZip( zf, buf, size_read ); - if( err<0 ) - { - printf( "error in writing %s in the zipfile\n", - filenameinzip ); - } - } - } while( (err == ZIP_OK) && (size_read>0) ); - - if( fin ) - fclose( fin ); - - if( err<0 ) - err = ZIP_ERRNO; - else - { - err = zipCloseFileInZip( zf ); - if( err!=ZIP_OK ) - printf( "error in closing %s in the zipfile\n", - filenameinzip ); - } - } - } - - errclose = zipClose( zf, NULL ); - if( errclose != ZIP_OK ) - printf( "error in closing %s\n", filename_try ); - } - - free( buf ); - return 0; -} diff --git a/kicad/minizip/zip.c b/kicad/minizip/zip.c deleted file mode 100644 index 399709fbb8..0000000000 --- a/kicad/minizip/zip.c +++ /dev/null @@ -1,1170 +0,0 @@ -/* zip.c -- IO on .zip files using zlib - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - Read zip.h for more info -*/ - - -#include -#include -#include -#include -#include "zlib.h" -#include "zip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -#ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ -#endif - -#ifndef Z_BUFSIZE -#define Z_BUFSIZE (16384) -#endif - -#ifndef Z_MAXFILENAMEINZIP -#define Z_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -/* -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) -*/ - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifndef DEF_MEM_LEVEL -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -#endif -const char zip_copyright[] = - " zip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; - - -#define SIZEDATA_INDATABLOCK (4096-(4*4)) - -#define LOCALHEADERMAGIC (0x04034b50) -#define CENTRALHEADERMAGIC (0x02014b50) -#define ENDHEADERMAGIC (0x06054b50) - -#define FLAG_LOCALHEADER_OFFSET (0x06) -#define CRC_LOCALHEADER_OFFSET (0x0e) - -#define SIZECENTRALHEADER (0x2e) /* 46 */ - -typedef struct linkedlist_datablock_internal_s -{ - struct linkedlist_datablock_internal_s* next_datablock; - uLong avail_in_this_block; - uLong filled_in_this_block; - uLong unused; /* for future use and alignement */ - unsigned char data[SIZEDATA_INDATABLOCK]; -} linkedlist_datablock_internal; - -typedef struct linkedlist_data_s -{ - linkedlist_datablock_internal* first_block; - linkedlist_datablock_internal* last_block; -} linkedlist_data; - - -typedef struct -{ - z_stream stream; /* zLib stream structure for inflate */ - int stream_initialised; /* 1 is stream is initialised */ - uInt pos_in_buffered_data; /* last written byte in buffered_data */ - - uLong pos_local_header; /* offset of the local header of the file - currenty writing */ - char* central_header; /* central header data for the current file */ - uLong size_centralheader; /* size of the central header for cur file */ - uLong flag; /* flag of the file currently writing */ - - int method; /* compression method of file currenty wr.*/ - int raw; /* 1 for directly writing raw data */ - Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ - uLong dosDate; - uLong crc32; - int encrypt; -#ifndef NOCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const unsigned long* pcrc_32_tab; - int crypt_header_size; -#endif -} curfile_info; - -typedef struct -{ - zlib_filefunc_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - linkedlist_data central_dir;/* datablock with central dir in construction*/ - int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile_info ci; /* info on the file curretly writing */ - - uLong begin_pos; /* position of the beginning of the zipfile */ - uLong add_position_when_writting_offset; - uLong number_entry; -} zip_internal; - - - -#ifndef NOCRYPT -#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED -#include "crypt.h" -#endif - -local linkedlist_datablock_internal* allocate_new_datablock() -{ - linkedlist_datablock_internal* ldi; - ldi = (linkedlist_datablock_internal*) - ALLOC(sizeof(linkedlist_datablock_internal)); - if (ldi!=NULL) - { - ldi->next_datablock = NULL ; - ldi->filled_in_this_block = 0 ; - ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; - } - return ldi; -} - -local void free_datablock(ldi) - linkedlist_datablock_internal* ldi; -{ - while (ldi!=NULL) - { - linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); - ldi = ldinext; - } -} - -local void init_linkedlist(ll) - linkedlist_data* ll; -{ - ll->first_block = ll->last_block = NULL; -} - -// local void free_linkedlist(ll) -// linkedlist_data* ll; -// { -// free_datablock(ll->first_block); -// ll->first_block = ll->last_block = NULL; -// } - - -local int add_data_in_datablock(ll,buf,len) - linkedlist_data* ll; - const void* buf; - uLong len; -{ - linkedlist_datablock_internal* ldi; - const unsigned char* from_copy; - - if (ll==NULL) - return ZIP_INTERNALERROR; - - if (ll->last_block == NULL) - { - ll->first_block = ll->last_block = allocate_new_datablock(); - if (ll->first_block == NULL) - return ZIP_INTERNALERROR; - } - - ldi = ll->last_block; - from_copy = (unsigned char*)buf; - - while (len>0) - { - uInt copy_this; - uInt i; - unsigned char* to_copy; - - if (ldi->avail_in_this_block==0) - { - ldi->next_datablock = allocate_new_datablock(); - if (ldi->next_datablock == NULL) - return ZIP_INTERNALERROR; - ldi = ldi->next_datablock ; - ll->last_block = ldi; - } - - if (ldi->avail_in_this_block < len) - copy_this = (uInt)ldi->avail_in_this_block; - else - copy_this = (uInt)len; - - to_copy = &(ldi->data[ldi->filled_in_this_block]); - - for (i=0;ifilled_in_this_block += copy_this; - ldi->avail_in_this_block -= copy_this; - from_copy += copy_this ; - len -= copy_this; - } - return ZIP_OK; -} - - - -/****************************************************************************/ - -#ifndef NO_ADDFILEINEXISTINGZIP -/* =========================================================================== - Inputs a long in LSB order to the given file - nbByte == 1, 2 or 4 (byte, short or long) -*/ - -local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, uLong x, int nbByte)); -local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong x; - int nbByte; -{ - unsigned char buf[4]; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) - return ZIP_ERRNO; - else - return ZIP_OK; -} - -local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); -local void ziplocal_putValue_inmemory (dest, x, nbByte) - void* dest; - uLong x; - int nbByte; -{ - unsigned char* buf=(unsigned char*)dest; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } -} -/****************************************************************************/ - - -local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) - const tm_zip* ptm; - uLong dosDate; -{ - uLong year = (uLong)ptm->tm_year; - if (year>1980) - year-=1980; - else if (year>80) - year-=80; - return - (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | - ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); -} - - -/****************************************************************************/ - -local int ziplocal_getByte OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); - -local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - int *pi; -{ - unsigned char c; - int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) - { - *pi = (int)c; - return ZIP_OK; - } - else - { - if (ZERROR(*pzlib_filefunc_def,filestream)) - return ZIP_ERRNO; - else - return ZIP_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int ziplocal_getShort OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int ziplocal_getLong OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<16; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - return err; -} - -#ifndef BUFREADCOMMENT -#define BUFREADCOMMENT (0x400) -#endif -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local uLong ziplocal_SearchCentralDir OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream)); - -local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; -{ - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} -#endif /* !NO_ADDFILEINEXISTINGZIP*/ - -/************************************************************/ -extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) - const char *pathname; - int append; - zipcharpc* globalcomment; - zlib_filefunc_def* pzlib_filefunc_def; -{ - zip_internal ziinit; - zip_internal* zi; - int err=ZIP_OK; - - - if (pzlib_filefunc_def==NULL) - fill_fopen_filefunc(&ziinit.z_filefunc); - else - ziinit.z_filefunc = *pzlib_filefunc_def; - - ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) - (ziinit.z_filefunc.opaque, - pathname, - (append == APPEND_STATUS_CREATE) ? - (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : - (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); - - if (ziinit.filestream == NULL) - return NULL; - ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - ziinit.add_position_when_writting_offset = 0; - init_linkedlist(&(ziinit.central_dir)); - - - zi = (zip_internal*)ALLOC(sizeof(zip_internal)); - if (zi==NULL) - { - ZCLOSE(ziinit.z_filefunc,ziinit.filestream); - return NULL; - } - - /* now we add file in a zipfile */ -# ifndef NO_ADDFILEINEXISTINGZIP - if (append == APPEND_STATUS_ADDINZIP) - { - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory */ - uLong central_pos,uL; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry; - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - uLong size_comment; - - central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); - if (central_pos==0) - err=ZIP_ERRNO; - - if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; - - /* the signature, already checked */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of this disk */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of the disk with the start of the central directory */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((number_entry_CD!=number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=ZIP_BADZIPFILE; - - /* size of the central directory */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* zipfile comment length */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((central_pos0) && (err==ZIP_OK)) - { - uLong read_this = SIZEDATA_INDATABLOCK; - if (read_this > size_central_dir_to_read) - read_this = size_central_dir_to_read; - if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) - err=ZIP_ERRNO; - - if (err==ZIP_OK) - err = add_data_in_datablock(&ziinit.central_dir,buf_read, - (uLong)read_this); - size_central_dir_to_read-=read_this; - } - TRYFREE(buf_read); - } - ziinit.begin_pos = byte_before_the_zipfile; - ziinit.number_entry = number_entry_CD; - - if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, - offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; - } -# endif /* !NO_ADDFILEINEXISTINGZIP*/ - - if (err != ZIP_OK) - { - TRYFREE(zi); - return NULL; - } - else - { - *zi = ziinit; - return (zipFile)zi; - } -} - -extern zipFile ZEXPORT zipOpen (pathname, append) - const char *pathname; - int append; -{ - return zipOpen2(pathname,append,NULL,NULL); -} - -extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; - int raw; - int windowBits; - int memLevel; - int strategy; - const char* password; - uLong crcForCrypting; -{ - zip_internal* zi; - uInt size_filename; - uInt size_comment; - uInt i; - int err = ZIP_OK; - -# ifdef NOCRYPT - if (password != NULL) - return ZIP_PARAMERROR; -# endif - - if (file == NULL) - return ZIP_PARAMERROR; - if ((method!=0) && (method!=Z_DEFLATED)) - return ZIP_PARAMERROR; - - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - if (err != ZIP_OK) - return err; - } - - - if (filename==NULL) - filename="-"; - - if (comment==NULL) - size_comment = 0; - else - size_comment = strlen(comment); - - size_filename = strlen(filename); - - if (zipfi == NULL) - zi->ci.dosDate = 0; - else - { - if (zipfi->dosDate != 0) - zi->ci.dosDate = zipfi->dosDate; - else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); - } - - zi->ci.flag = 0; - if ((level==8) || (level==9)) - zi->ci.flag |= 2; - if ((level==2)) - zi->ci.flag |= 4; - if ((level==1)) - zi->ci.flag |= 6; - if (password != NULL) - zi->ci.flag |= 1; - - zi->ci.crc32 = 0; - zi->ci.method = method; - zi->ci.encrypt = 0; - zi->ci.stream_initialised = 0; - zi->ci.pos_in_buffered_data = 0; - zi->ci.raw = raw; - zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + - size_extrafield_global + size_comment; - zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); - - ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); - /* version info */ - ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); - ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); - ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); - ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); - ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); - ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); - ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); - ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); - else - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); - else - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); - - ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); - - for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = - *(((const char*)extrafield_global)+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ - size_extrafield_global+i) = *(comment+i); - if (zi->ci.central_header == NULL) - return ZIP_INTERNALERROR; - - /* write the local header */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); - - if ((err==ZIP_OK) && (size_filename>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) - err = ZIP_ERRNO; - - if ((err==ZIP_OK) && (size_extrafield_local>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) - !=size_extrafield_local) - err = ZIP_ERRNO; - - zi->ci.stream.avail_in = (uInt)0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - zi->ci.stream.total_in = 0; - zi->ci.stream.total_out = 0; - - if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; - zi->ci.stream.opaque = (voidpf)0; - - if (windowBits>0) - windowBits = -windowBits; - - err = deflateInit2(&zi->ci.stream, level, - Z_DEFLATED, windowBits, memLevel, strategy); - - if (err==Z_OK) - zi->ci.stream_initialised = 1; - } -# ifndef NOCRYPT - zi->ci.crypt_header_size = 0; - if ((err==Z_OK) && (password != NULL)) - { - unsigned char bufHead[RAND_HEAD_LEN]; - unsigned int sizeHead; - zi->ci.encrypt = 1; - zi->ci.pcrc_32_tab = get_crc_table(); - /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ - - sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); - zi->ci.crypt_header_size = sizeHead; - - if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) - err = ZIP_ERRNO; - } -# endif - - if (err==Z_OK) - zi->in_opened_file_inzip = 1; - return err; -} - -extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; - int raw; -{ - return zipOpenNewFileInZip3 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0); -} - -extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; -{ - return zipOpenNewFileInZip2 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0); -} - -local int zipFlushWriteBuffer(zi) - zip_internal* zi; -{ - int err=ZIP_OK; - - if (zi->ci.encrypt != 0) - { -#ifndef NOCRYPT - uInt i; - int t; - for (i=0;ici.pos_in_buffered_data;i++) - zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, - zi->ci.buffered_data[i],t); -#endif - } - if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) - !=zi->ci.pos_in_buffered_data) - err = ZIP_ERRNO; - zi->ci.pos_in_buffered_data = 0; - return err; -} - -extern int ZEXPORT zipWriteInFileInZip (file, buf, len) - zipFile file; - const void* buf; - unsigned len; -{ - zip_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - - zi->ci.stream.next_in = (void*)buf; - zi->ci.stream.avail_in = len; - zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); - - while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) - { - if (zi->ci.stream.avail_out == 0) - { - if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - - - if(err != ZIP_OK) - break; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - uLong uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_NO_FLUSH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - - } - else - { - uInt copy_this,i; - if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) - copy_this = zi->ci.stream.avail_in; - else - copy_this = zi->ci.stream.avail_out; - for (i=0;ici.stream.next_out)+i) = - *(((const char*)zi->ci.stream.next_in)+i); - { - zi->ci.stream.avail_in -= copy_this; - zi->ci.stream.avail_out-= copy_this; - zi->ci.stream.next_in+= copy_this; - zi->ci.stream.next_out+= copy_this; - zi->ci.stream.total_in+= copy_this; - zi->ci.stream.total_out+= copy_this; - zi->ci.pos_in_buffered_data += copy_this; - } - } - } - - return err; -} - -extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) - zipFile file; - uLong uncompressed_size; - uLong crc32; -{ - zip_internal* zi; - uLong compressed_size; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - zi->ci.stream.avail_in = 0; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - while (err==ZIP_OK) - { - uLong uTotalOutBefore; - if (zi->ci.stream.avail_out == 0) - { - if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_FINISH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - } - - if (err==Z_STREAM_END) - err=ZIP_OK; /* this is normal */ - - if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) - if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) - err = ZIP_ERRNO; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - err=deflateEnd(&zi->ci.stream); - zi->ci.stream_initialised = 0; - } - - if (!zi->ci.raw) - { - crc32 = (uLong)zi->ci.crc32; - uncompressed_size = (uLong)zi->ci.stream.total_in; - } - compressed_size = (uLong)zi->ci.stream.total_out; -# ifndef NOCRYPT - compressed_size += zi->ci.crypt_header_size; -# endif - - ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20, - compressed_size,4); /*compr size*/ - if (zi->ci.stream.data_type == Z_ASCII) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); - ziplocal_putValue_inmemory(zi->ci.central_header+24, - uncompressed_size,4); /*uncompr size*/ - - if (err==ZIP_OK) - err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, - (uLong)zi->ci.size_centralheader); - free(zi->ci.central_header); - - if (err==ZIP_OK) - { - long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); - if (ZSEEK(zi->z_filefunc,zi->filestream, - zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ - - if (err==ZIP_OK) /* compressed size, unknown */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); - - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); - - if (ZSEEK(zi->z_filefunc,zi->filestream, - cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - } - - zi->number_entry ++; - zi->in_opened_file_inzip = 0; - - return err; -} - -extern int ZEXPORT zipCloseFileInZip (file) - zipFile file; -{ - return zipCloseFileInZipRaw (file,0,0); -} - -extern int ZEXPORT zipClose (file, global_comment) - zipFile file; - const char* global_comment; -{ - zip_internal* zi; - int err = 0; - uLong size_centraldir = 0; - uLong centraldir_pos_inzip ; - uInt size_global_comment; - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - } - - if (global_comment==NULL) - size_global_comment = 0; - else - size_global_comment = strlen(global_comment); - - - centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); - if (err==ZIP_OK) - { - linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; - while (ldi!=NULL) - { - if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream, - ldi->data,ldi->filled_in_this_block) - !=ldi->filled_in_this_block ) - err = ZIP_ERRNO; - - size_centraldir += ldi->filled_in_this_block; - ldi = ldi->next_datablock; - } - } - free_datablock(zi->central_dir.first_block); - - if (err==ZIP_OK) /* Magic End */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); - - if (err==ZIP_OK) /* number of this disk */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); - - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); - - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* total number of entries in the central dir */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* size of the central directory */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the - starting disk number */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, - (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); - - if (err==ZIP_OK) /* zipfile comment length */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); - - if ((err==ZIP_OK) && (size_global_comment>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream, - global_comment,size_global_comment) != size_global_comment) - err = ZIP_ERRNO; - - if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) - if (err == ZIP_OK) - err = ZIP_ERRNO; - - TRYFREE(zi); - - return err; -} diff --git a/kicad/minizip/zip.h b/kicad/minizip/zip.h deleted file mode 100644 index c37ea21872..0000000000 --- a/kicad/minizip/zip.h +++ /dev/null @@ -1,235 +0,0 @@ -/* zip.h -- IO for compress .zip files using zlib - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - This unzip package allow creates .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - For uncompress .zip file, look at unzip.h - - - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.html for evolution - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - -*/ - -/* for more info about .ZIP format, see - http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip - http://www.info-zip.org/pub/infozip/doc/ - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _zip_H -#define _zip_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#ifndef _ZLIBIOAPI_H -#include "ioapi.h" -#endif - -#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zipFile__; -typedef zipFile__ *zipFile; -#else -typedef voidp zipFile; -#endif - -#define ZIP_OK (0) -#define ZIP_EOF (0) -#define ZIP_ERRNO (Z_ERRNO) -#define ZIP_PARAMERROR (-102) -#define ZIP_BADZIPFILE (-103) -#define ZIP_INTERNALERROR (-104) - -#ifndef DEF_MEM_LEVEL -# if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -# else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -# endif -#endif -/* default memLevel */ - -/* tm_zip contain date/time info */ -typedef struct tm_zip_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_zip; - -typedef struct -{ - tm_zip tmz_date; /* date in understandable format */ - uLong dosDate; /* if dos_date == 0, tmu_date is used */ -/* uLong flag; */ /* general purpose bit flag 2 bytes */ - - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ -} zip_fileinfo; - -typedef const char* zipcharpc; - - -#define APPEND_STATUS_CREATE (0) -#define APPEND_STATUS_CREATEAFTER (1) -#define APPEND_STATUS_ADDINZIP (2) - -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -/* - Create a zipfile. - pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on - an Unix computer "zlib/zlib113.zip". - if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip - will be created at the end of the file. - (useful if the file contain a self extractor code) - if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will - add files in existing zip (be sure you don't add file that doesn't exist) - If the zipfile cannot be opened, the return value is NULL. - Else, the return value is a zipFile Handle, usable with other function - of this zip package. -*/ - -/* Note : there is no delete function into a zipfile. - If you want delete file into a zipfile, you must open a zipfile, and create another - Of couse, you can use RAW reading and writing to copy the file you did not want delte -*/ - -extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc_def* pzlib_filefunc_def)); - -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); -/* - Open a file in the ZIP for writing. - filename : the filename in zip (if NULL, '-' without quote will be used - *zipfi contain supplemental information - if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header - if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header - if comment != NULL, comment contain the comment string - method contain the compression method (0 for store, Z_DEFLATED for deflate) - level contain the level of compression (can be Z_DEFAULT_COMPRESSION) -*/ - - -extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw)); - -/* - Same than zipOpenNewFileInZip, except if raw=1, we write raw file - */ - -extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCtypting)); - -/* - Same than zipOpenNewFileInZip2, except - windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 - password : crypting password (NULL for no crypting) - crcForCtypting : crc of file to compress (needed for crypting) - */ - - -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const void* buf, - unsigned len)); -/* - Write data in the zipfile -*/ - -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); -/* - Close the current file in the zipfile -*/ - - -extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, - uLong uncompressed_size, - uLong crc32)); -/* - Close the current file in the zipfile, for fiel opened with - parameter raw=1 in zipOpenNewFileInZip2 - uncompressed_size and crc32 are value for the uncompressed size -*/ - -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); -/* - Close the zipfile -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _zip_H */ From 0c44335795fd8880d644e9091b165f3abd25db5e Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 7 Sep 2011 15:41:04 -0400 Subject: [PATCH 9/9] Lots and lots of PCBNew code cleaning and fix build bug introduced in r3108. * Changed to "xnode.h" in pcbnew_config.cpp to fix bug when building against wxWidgets 2.9 and above. * Convert broken wxXmlNode code to use XNODE. * Overloaded XNODE constructor for creating child nodes. * Translate French naming conventions. * Translate French comments. * Remove tabs from several source files. * Coding style policy and Doxygen comment fixes. --- 3d-viewer/3d_draw.cpp | 126 +++++--- cvpcb/setvisu.cpp | 12 +- gerbview/draw_gerber_screen.cpp | 12 +- include/base_struct.h | 9 +- include/wxPcbStruct.h | 17 +- include/xnode.h | 6 + pcbnew/attribut.cpp | 5 +- pcbnew/automove.cpp | 40 ++- pcbnew/autoplac.cpp | 182 ++++++++---- pcbnew/basepcbframe.cpp | 2 +- pcbnew/block.cpp | 67 ++--- pcbnew/block_module_editor.cpp | 9 +- pcbnew/board.cpp | 28 +- ...board_items_to_polygon_shape_transform.cpp | 165 ++++++----- pcbnew/board_undo_redo.cpp | 69 ++--- pcbnew/class_board.cpp | 99 ++++--- pcbnew/class_board.h | 13 +- pcbnew/class_dimension.cpp | 24 +- pcbnew/class_drawsegment.cpp | 55 ++-- pcbnew/class_edge_mod.cpp | 62 ++-- pcbnew/class_mire.cpp | 80 +++--- pcbnew/class_mire.h | 14 +- pcbnew/class_module.cpp | 51 +++- pcbnew/class_module.h | 4 +- pcbnew/class_module_transform_functions.cpp | 73 ++--- pcbnew/class_pad.cpp | 105 ++++--- pcbnew/class_pad.h | 2 +- pcbnew/class_pad_draw_functions.cpp | 69 +++-- pcbnew/class_track.cpp | 184 ++++++------ pcbnew/class_zone.cpp | 118 ++++++-- pcbnew/class_zone.h | 2 +- pcbnew/clean.cpp | 177 +++++++----- pcbnew/collectors.cpp | 24 +- pcbnew/connect.cpp | 271 ++++++++++-------- pcbnew/deltrack.cpp | 27 +- .../dialog_edit_module_for_BoardEditor.cpp | 2 +- .../dialog_edit_module_for_Modedit.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 18 +- pcbnew/drag.h | 12 +- pcbnew/dragsegm.cpp | 41 ++- pcbnew/drc.cpp | 31 +- pcbnew/drc_clearance_test_functions.cpp | 108 ++++--- pcbnew/edgemod.cpp | 33 ++- pcbnew/edit.cpp | 10 +- pcbnew/edit_pcb_text.cpp | 7 +- pcbnew/edit_track_width.cpp | 38 ++- pcbnew/editedge.cpp | 29 +- pcbnew/editmod.cpp | 16 +- pcbnew/editrack-part2.cpp | 71 +++-- pcbnew/editrack.cpp | 109 ++++--- pcbnew/edtxtmod.cpp | 49 +++- pcbnew/export_gencad.cpp | 120 ++++---- pcbnew/export_vrml.cpp | 115 ++++---- pcbnew/find.cpp | 21 +- pcbnew/gen_drill_report_files.cpp | 44 +-- pcbnew/gen_modules_placefile.cpp | 36 ++- pcbnew/globaleditpad.cpp | 19 +- pcbnew/gpcb_exchange.cpp | 59 ++-- pcbnew/graphpcb.cpp | 28 +- pcbnew/hotkeys_board_editor.cpp | 10 +- pcbnew/initpcb.cpp | 12 +- pcbnew/ioascii.cpp | 111 ++++--- pcbnew/locate.cpp | 35 +-- pcbnew/magnetic_tracks_functions.cpp | 5 +- pcbnew/mirepcb.cpp | 154 +++++----- pcbnew/modedit.cpp | 4 +- pcbnew/modedit_onclick.cpp | 6 +- pcbnew/modules.cpp | 45 +-- pcbnew/move-drag_pads.cpp | 28 +- pcbnew/move_or_drag_track.cpp | 98 ++++--- pcbnew/muonde.cpp | 108 ++++--- pcbnew/onleftclick.cpp | 38 ++- pcbnew/onrightclick.cpp | 4 +- pcbnew/pcbnew_config.cpp | 65 +++-- pcbnew/pcbplot.h | 4 +- pcbnew/plot_rtn.cpp | 193 +++++++------ pcbnew/plothpgl.cpp | 15 +- pcbnew/plotps.cpp | 9 +- pcbnew/print_board_functions.cpp | 67 +++-- pcbnew/protos.h | 50 ++-- pcbnew/ratsnest.cpp | 134 +++++---- pcbnew/solve.cpp | 148 +++++----- pcbnew/specctra_export.cpp | 6 +- pcbnew/specctra_import.cpp | 2 +- pcbnew/swap_layers.cpp | 33 ++- pcbnew/tr_modif.cpp | 47 +-- pcbnew/tracepcb.cpp | 13 +- pcbnew/track.cpp | 163 ++++++----- pcbnew/trpiste.cpp | 11 +- pcbnew/zones_by_polygon.cpp | 157 +++++----- pcbnew/zones_by_polygon_fill_functions.cpp | 19 +- ...nvert_brd_items_to_polygons_with_Boost.cpp | 82 ++++-- ...nvert_brd_items_to_polygons_with_Kbool.cpp | 80 ++++-- pcbnew/zones_non_copper_type_functions.cpp | 24 +- pcbnew/zones_test_and_combine_areas.cpp | 2 +- 95 files changed, 3018 insertions(+), 2185 deletions(-) diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index fe5488c67e..df70f24b43 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -92,7 +92,9 @@ void Pcb3D_GLCanvas::Redraw( bool finish ) glRotatef( g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0 ); if( m_gllist ) + { glCallList( m_gllist ); + } else { CreateDrawGL_List(); @@ -146,9 +148,8 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() for( ii = 0; ii < 32; ii++ ) { if( ii < g_Parm_3D_Visu.m_Layers ) - g_Parm_3D_Visu.m_LayerZcoord[ii] = - g_Parm_3D_Visu.m_Epoxy_Width - * ii / (g_Parm_3D_Visu.m_Layers - 1); + g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width + * ii / (g_Parm_3D_Visu.m_Layers - 1); else g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width; } @@ -277,16 +278,20 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() for( ii = 0; ii < pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* zone = pcb->GetArea( ii ); + if( zone->m_FilledPolysList.size() == 0 ) continue; + if( zone->m_ZoneMinThickness <= 1 ) continue; + int imax = zone->m_FilledPolysList.size() - 1; CPolyPt* firstcorner = &zone->m_FilledPolysList[0]; CPolyPt* begincorner = firstcorner; SEGZONE dummysegment( pcb ); dummysegment.SetLayer( zone->GetLayer() ); dummysegment.m_Width = zone->m_ZoneMinThickness; + for( int ic = 1; ic <= imax; ic++ ) { CPolyPt* endcorner = &zone->m_FilledPolysList[ic]; @@ -312,13 +317,16 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() Draw3D_Track( &dummysegment ); } + ic++; + if( ic < imax - 1 ) - begincorner = firstcorner = - &zone->m_FilledPolysList[ic]; + begincorner = firstcorner = &zone->m_FilledPolysList[ic]; } else + { begincorner = endcorner; + } } } } @@ -345,6 +353,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() /* draw footprints */ MODULE* Module = pcb->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { Module->Draw3D( this ); @@ -373,6 +382,7 @@ void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track ) if( layer == LAST_COPPER_LAYER ) layer = g_Parm_3D_Visu.m_Layers - 1; + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; SetGLColor( color ); @@ -404,6 +414,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) if( layer == LAST_COPPER_LAYER ) layer = g_Parm_3D_Visu.m_Layers - 1; + zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; g_Parm_3D_Visu.m_ActZpos = zpos; @@ -471,16 +482,16 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; if( layer < g_Parm_3D_Visu.m_Layers - 1 ) { - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == - false ) + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; + color = g_ColorsSettings.GetLayerColor( layer ); } else { - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( LAYER_N_FRONT ) == - false ) + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( LAYER_N_FRONT ) == false ) continue; + color = g_ColorsSettings.GetLayerColor( LAYER_N_FRONT ); } @@ -488,11 +499,14 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) // SetGLColor( LIGHTGRAY ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); + if( layer == LAYER_N_BACK ) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; + Draw3D_FilledCircle( x, -y, r, hole, zpos ); + if( layer >= top_layer ) break; } @@ -500,10 +514,8 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via ) // Drawing hole: color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->m_Shape ); SetGLColor( color ); - height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer]; - Draw3D_FilledCylinder( x, -y, hole, height, - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer] ); + height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer]; + Draw3D_FilledCylinder( x, -y, hole, height, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer] ); } @@ -553,6 +565,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment ) { glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) ); zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + if( Get3DLayerEnable( layer ) ) { switch( segment->m_Shape ) @@ -591,8 +604,7 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf ) double endx = xf * g_Parm_3D_Visu.m_BoardScale; double endy = yf * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledSegment( startx, -starty, endx, -endy, - s_Text3DWidth, s_Text3DZPos ); + Draw3D_FilledSegment( startx, -starty, endx, -endy, s_Text3DWidth, s_Text3DZPos ); } @@ -605,14 +617,15 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) int color = g_ColorsSettings.GetLayerColor( layer ); - SetGLColor( color ); s_Text3DZPos = g_Parm_3D_Visu.m_LayerZcoord[layer]; s_Text3DWidth = text->m_Thickness * g_Parm_3D_Visu.m_BoardScale; glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) ); wxSize size = text->m_Size; + if( text->m_Mirror ) NEGATE( size.x ); + if( text->m_MultilineAllowed ) { wxPoint pos = text->m_Pos; @@ -622,6 +635,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) offset.y = text->GetInterline(); RotatePoint( &offset, text->m_Orient ); + for( unsigned i = 0; iCount(); i++ ) { wxString txt = list->Item( i ); @@ -636,12 +650,14 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) delete (list); } else + { DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_Colors) color, text->m_Text, text->m_Orient, size, text->m_HJustify, text->m_VJustify, text->m_Thickness, text->m_Italic, true, Draw3dTextSegm ); + } } @@ -652,6 +668,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) /* Draw pads */ glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis + for( ; pad != NULL; pad = pad->Next() ) { pad->Draw3D( glcanvas ); @@ -679,6 +696,7 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) glRotatef( 180.0, 0.0, 1.0, 0.0 ); glRotatef( 180.0, 0.0, 0.0, 1.0 ); } + DataScale3D = g_Parm_3D_Visu.m_BoardScale * UNITS3D_TO_UNITSPCB; for( ; Struct3D != NULL; Struct3D = Struct3D->Next() ) @@ -789,7 +807,7 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) default: s.Printf( wxT( "Error: Shape nr %d not implemented!\n" ), m_Shape ); D( printf( "%s", TO_UTF8( s ) ); ) - break; + break; } } } @@ -837,7 +855,7 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) default: s.Printf( wxT( "Error: Shape nr %d not implemented!\n" ), m_Shape ); D( printf( "%s", TO_UTF8( s ) ); ) - break; + break; } } } @@ -889,8 +907,8 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis nlmax = g_Parm_3D_Visu.m_Layers - 1; - Oncu = (m_Masque_Layer & LAYER_BACK) ? TRUE : FALSE; - Oncmp = (m_Masque_Layer & LAYER_FRONT) ? TRUE : FALSE; + Oncu = (m_layerMask & LAYER_BACK) ? TRUE : FALSE; + Oncmp = (m_layerMask & LAYER_FRONT) ? TRUE : FALSE; Both = Oncu && Oncmp; switch( m_PadShape & 0x7F ) @@ -899,29 +917,35 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) x = xc * scale; y = yc * scale; r = (double) dx * scale; + for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ ) { if( layer && (layer == nlmax) ) layer = LAYER_N_FRONT; + if( (layer == LAYER_N_FRONT) && !Oncmp ) continue; + if( (layer == LAYER_N_BACK) && !Oncu ) continue; - if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) - && !Both ) + + if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both ) continue; + color = g_ColorsSettings.GetLayerColor( layer ); - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == - false ) + + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; SetGLColor( color ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + if( layer == LAYER_N_BACK ) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; + Draw3D_FilledCircle( x, -y, r, hole, zpos ); } @@ -940,42 +964,48 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) delta_cy = dy - dx; w = m_Size.x * scale; } + RotatePoint( &delta_cx, &delta_cy, angle ); + { double ox, oy, fx, fy; ox = (double) ( ux0 + delta_cx ) * scale; oy = (double) ( uy0 + delta_cy ) * scale; fx = (double) ( ux0 - delta_cx ) * scale; fy = (double) ( uy0 - delta_cy ) * scale; - for( layer = FIRST_COPPER_LAYER; - layer <= LAST_COPPER_LAYER; - layer++ ) + + for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ ) { if( layer && (layer == nlmax) ) layer = LAYER_N_FRONT; + if( (layer == LAYER_N_FRONT) && !Oncmp ) continue; + if( (layer == LAYER_N_BACK) && !Oncu ) continue; - if( (layer > FIRST_COPPER_LAYER) - && (layer < LAST_COPPER_LAYER) && !Both ) + + if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both ) continue; + color = g_ColorsSettings.GetLayerColor( layer ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == - false ) + + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; SetGLColor( color ); zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + if( layer == LAYER_N_BACK ) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledSegmentWithHole( ox, -oy, fx, -fy, w, drillx, - -drilly, hole, zpos ); + + Draw3D_FilledSegmentWithHole( ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos ); } } + break; case PAD_RECT: @@ -984,6 +1014,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) wxPoint coord[5]; wxRealPoint fcoord[8], f_hole_coord[8]; BuildPadPolygon( coord, wxSize(0,0), angle ); + for( ii = 0; ii < 4; ii++ ) { coord[ii].x += ux0; @@ -996,8 +1027,10 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) for( ii = 0; ii < 7; ii += 2 ) { ll = ii + 2; + if( ll > 7 ) ll -= 8; + fcoord[ii + 1].x = (fcoord[ii].x + fcoord[ll].x) / 2; fcoord[ii + 1].y = (fcoord[ii].y + fcoord[ll].y) / 2; } @@ -1015,26 +1048,32 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas ) { if( layer && (layer == nlmax) ) layer = LAYER_N_FRONT; + if( (layer == LAYER_N_FRONT) && !Oncmp ) continue; + if( (layer == LAYER_N_BACK) && !Oncu ) continue; - if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) - && !Both ) + + if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both ) continue; + color = g_ColorsSettings.GetLayerColor( layer ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == - false ) + + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) continue; SetGLColor( color ); zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + if( layer == LAYER_N_BACK ) zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale; else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; + glBegin( GL_QUAD_STRIP ); + for( ii = 0; ii < 8; ii++ ) { glVertex3f( f_hole_coord[ii].x, -f_hole_coord[ii].y, zpos ); @@ -1073,6 +1112,7 @@ static void Draw3D_FilledCircle( double posx, double posy, double x, y; glBegin( GL_QUAD_STRIP ); + for( ii = 0; ii <= slice; ii++ ) { x = hole; @@ -1151,6 +1191,7 @@ static void Draw3D_FilledSegment( double startx, double starty, double endx, x += dx; RotatePoint( &x, &y, -angle ); glVertex3f( startx + x, starty + y, zpos ); + if( ii == 0 ) { firstx = startx + x; @@ -1217,6 +1258,7 @@ static void Draw3D_FilledSegmentWithHole( double startx, double starty, RotatePoint( &xin, &yin, -angle ); glVertex3f( startx + xin, starty + yin, zpos ); glVertex3f( startx + x, starty + y, zpos ); + if( ii == 0 ) { firstx = startx + x; @@ -1263,8 +1305,10 @@ static void Draw3D_ArcSegment( double startx, double starty, double centrex, // Calculate the number of segments to approximate this arc int imax = (int) ( (double) arc_angle * slice / 3600.0 ); + if( imax < 0 ) imax = -imax; + if( imax == 0 ) imax = 1; @@ -1273,6 +1317,7 @@ static void Draw3D_ArcSegment( double startx, double starty, double centrex, double delta_angle = (double) arc_angle / imax; glBegin( GL_QUAD_STRIP ); + for( ii = 0; ii <= imax; ii++ ) { double angle = (double) ii * delta_angle; @@ -1301,6 +1346,7 @@ static void Draw3D_CircleSegment( double startx, double starty, double endx, hole = rayon - width; glBegin( GL_QUAD_STRIP ); + for( ii = 0; ii <= slice; ii++ ) { x = hole; y = 0.0; @@ -1339,6 +1385,7 @@ void Pcb3D_GLCanvas::Draw3D_Polygon( std::vector& aCornersList, double // Draw solid polygon gluTessBeginPolygon( tess, NULL ); gluTessBeginContour( tess ); + for( unsigned ii = 0; ii < aCornersList.size(); ii++ ) { v_data[0] = aCornersList[ii].x * g_Parm_3D_Visu.m_BoardScale; @@ -1361,12 +1408,16 @@ static int Get3DLayerEnable( int act_layer ) bool enablelayer; enablelayer = TRUE; + if( act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings ) enablelayer = FALSE; + if( act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments ) enablelayer = FALSE; + if( act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1 ) enablelayer = FALSE; + if( act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2 ) enablelayer = FALSE; @@ -1379,6 +1430,7 @@ static GLfloat Get3DLayerSide( int act_layer ) GLfloat nZ; nZ = 1.0; + if( ( act_layer <= LAST_COPPER_LAYER - 1 ) || ( act_layer == ADHESIVE_N_BACK ) || ( act_layer == SOLDERPASTE_N_BACK ) diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index b365e15b13..d3e305b4fb 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -136,12 +136,12 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin * but they must exist because they appear in some classes. * Do nothing in CvPcb. */ -TRACK* Marque_Une_Piste( BOARD* aPcb, - TRACK* aStartSegm, - int* aSegmCount, - int* aTrackLen, - int* aLenDie, - bool aReorder ) +TRACK* MarkTrace( BOARD* aPcb, + TRACK* aStartSegm, + int* aSegmCount, + int* aTrackLen, + int* aLenDie, + bool aReorder ) { return NULL; } diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index 386e33cbd5..f267bc047e 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -420,12 +420,12 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int ) * but they must exist because they appear in some classes, and here, no nothing. */ -TRACK* Marque_Une_Piste( BOARD* aPcb, - TRACK* aStartSegm, - int* aSegmCount, - int* aTrackLen, - int* aLenDie, - bool aReorder ) +TRACK* MarkTrace( BOARD* aPcb, + TRACK* aStartSegm, + int* aSegmCount, + int* aTrackLen, + int* aLenDie, + bool aReorder ) { return NULL; } diff --git a/include/base_struct.h b/include/base_struct.h index 0c184b1b10..2766636d49 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -1,6 +1,7 @@ -/*********************************************************************/ -/* base_struct.h : Basic classes for most kicad item descriptions */ -/*********************************************************************/ +/** + * @file base_struct.h + * @brief Basic classes for most kicad items. + */ #ifndef BASE_STRUCT_H #define BASE_STRUCT_H @@ -41,7 +42,7 @@ enum KICAD_T { // copper layer) TYPE_MARKER_PCB, // a marker used to show something TYPE_DIMENSION, // a dimension (graphic item) - TYPE_MIRE, // a target (graphic item) + PCB_TARGET_T, // a target (graphic item) TYPE_ZONE_EDGE_CORNER, // in zone outline: a point to define an outline TYPE_ZONE_CONTAINER, // a zone area TYPE_BOARD_ITEM_LIST, // a list of board items diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 560fd8c547..aa31cc9c82 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -28,7 +28,7 @@ class SEGZONE; class SEGVIA; class D_PAD; class TEXTE_MODULE; -class MIREPCB; +class PCB_TARGET; class DIMENSION; class EDGE_MODULE; class DRC; @@ -830,8 +830,8 @@ public: * the case where DRC would not allow a via. */ bool Other_Layer_Route( TRACK* track, wxDC* DC ); - void Affiche_PadsNoConnect( wxDC* DC ); - void Affiche_Status_Net( wxDC* DC ); + void HighlightUnconnectedPads( wxDC* DC ); + void DisplayNetStatus( wxDC* DC ); TRACK* Delete_Segment( wxDC* DC, TRACK* Track ); void Delete_Track( wxDC* DC, TRACK* Track ); void Delete_net( wxDC* DC, TRACK* Track ); @@ -910,7 +910,6 @@ public: void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ); void SwitchLayer( wxDC* DC, int layer ); bool Add_45_degrees_Segment( wxDC* DC ); - bool Genere_Pad_Connexion( wxDC* DC, int layer ); /** * Function EraseRedundantTrack @@ -1085,11 +1084,11 @@ public: void Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ); // Target handling - MIREPCB* Create_Mire( wxDC* DC ); - void Delete_Mire( MIREPCB* MirePcb, wxDC* DC ); - void StartMove_Mire( MIREPCB* MirePcb, wxDC* DC ); - void Place_Mire( MIREPCB* MirePcb, wxDC* DC ); - void InstallMireOptionsFrame( MIREPCB* MirePcb, wxDC* DC ); + PCB_TARGET* CreateTarget( wxDC* DC ); + void DeleteTarget( PCB_TARGET* aTarget, wxDC* DC ); + void BeginMoveTarget( PCB_TARGET* aTarget, wxDC* DC ); + void PlaceTarget( PCB_TARGET* aTarget, wxDC* DC ); + void ShowTargetOptionsDialog( PCB_TARGET* aTarget, wxDC* DC ); // Graphic segments type DRAWSEGMENT handling: DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, wxDC* DC ); diff --git a/include/xnode.h b/include/xnode.h index de5b5988bd..7fd3413e40 100644 --- a/include/xnode.h +++ b/include/xnode.h @@ -53,6 +53,12 @@ public: { } + XNODE( XNODE* aParent, wxXmlNodeType aType, const wxString& aName, + const wxString& aContent = wxEmptyString, wxXmlProperty* aProperties = NULL ) : + wxXmlNode( aParent, aType, aName, aContent, aProperties ) + { + } + /** * Function Format * writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression. diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index 5afd30c459..309d092a6e 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -39,8 +39,8 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) return; DrawPanel->CrossHairOff( DC ); // Erase cursor shape - Track = Marque_Une_Piste( GetBoard(), track, &nb_segm, NULL, NULL, true ); - Trace_Une_Piste( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL ); + Track = MarkTrace( GetBoard(), track, &nb_segm, NULL, NULL, true ); + DrawTraces( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL ); for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- ) { @@ -74,6 +74,7 @@ void PCB_EDIT_FRAME::Attribut_net( wxDC* DC, int net_code, bool Flag_On ) } DrawPanel->CrossHairOff( DC ); // Erase cursor shape + while( Track ) /* Flag change */ { if( (net_code >= 0 ) && (net_code != Track->GetNet()) ) diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index cda447d3ad..fb1a0b6295 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -46,24 +46,32 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) { case ID_TOOLBARH_PCB_MODE_MODULE: on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_MODE_MODULE ); + if( on_state ) { - m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, FALSE ); + m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, false ); m_HTOOL_current_state = ID_TOOLBARH_PCB_MODE_MODULE; } else + { m_HTOOL_current_state = 0; + } + return; case ID_TOOLBARH_PCB_MODE_TRACKS: on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_MODE_TRACKS ); + if( on_state ) { - m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, FALSE ); + m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, false ); m_HTOOL_current_state = ID_TOOLBARH_PCB_MODE_TRACKS; } else + { m_HTOOL_current_state = 0; + } + return; @@ -75,11 +83,11 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) return; case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE: - LockModule( (MODULE*) GetScreen()->GetCurItem(), FALSE ); + LockModule( (MODULE*) GetScreen()->GetCurItem(), false ); return; case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES: - LockModule( NULL, FALSE ); + LockModule( NULL, false ); return; case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES: @@ -91,6 +99,7 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) { DrawPanel->m_endMouseCaptureCallback( DrawPanel, &dc ); } + break; default: // Abort a current command (if any) @@ -101,13 +110,13 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) /* Erase ratsnest if needed */ if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) DrawGeneralRatsnest( &dc ); + GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; switch( id ) { case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE: - AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(), - PLACE_1_MODULE, &dc ); + AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(), PLACE_1_MODULE, &dc ); break; case ID_POPUP_PCB_AUTOPLACE_ALL_MODULES: @@ -123,7 +132,7 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) break; case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES: - AutoMoveModulesOnPcb( FALSE ); + AutoMoveModulesOnPcb( false ); break; case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES: @@ -194,11 +203,13 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) // Build sorted footprints list (sort by decreasing size ) MODULE* Module = GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); moduleList.push_back(Module); } + sort( moduleList.begin(), moduleList.end(), sortModulesbySize ); /* to move modules outside the board, the cursor is placed below @@ -216,14 +227,17 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) /* calculate the area needed by footprints */ surface = 0.0; + for( unsigned ii = 0; ii < moduleList.size(); ii++ ) { Module = moduleList[ii]; + if( PlaceModulesHorsPcb && edgesExists ) { if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) continue; } + surface += Module->m_Surface; } @@ -235,6 +249,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) for( unsigned ii = 0; ii < moduleList.size(); ii++ ) { Module = moduleList[ii]; + if( Module->IsLocked() ) continue; @@ -253,6 +268,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) GetScreen()->SetCrossHairPosition( current + Module->m_Pos - Module->m_BoundaryBox.GetPosition() ); + Ymax_size = MAX( Ymax_size, Module->m_BoundaryBox.GetHeight() ); Place_Module( Module, NULL, true ); @@ -264,8 +280,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) } -/* Set or reset (true or FALSE) Lock attribute of aModule - * or all modules if aModule == NULL +/* Set or reset (true or false) Lock attribute of aModule or all modules if aModule == NULL */ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) { @@ -279,10 +294,10 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) else { aModule = GetBoard()->m_Modules; + for( ; aModule != NULL; aModule = aModule->Next() ) { - if( WildCompareString( ModulesMaskSelection, - aModule->m_Reference->m_Text ) ) + if( WildCompareString( ModulesMaskSelection, aModule->m_Reference->m_Text ) ) { aModule->SetLocked( aLocked ); OnModify(); @@ -296,4 +311,3 @@ static bool sortModulesbySize( MODULE* ref, MODULE* compare ) { return compare->m_Surface < ref->m_Surface; } - diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 05e306362d..e01dbfdb42 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -56,7 +56,7 @@ static void TracePenaliteRectangle( BOARD* Pcb, int uy1, int marge, int Penalite, - int masque_layer ); + int aLayerMask ); static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ); @@ -86,8 +86,10 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) { case PLACE_1_MODULE: ThisModule = Module; + if( ThisModule == NULL ) return; + ThisModule->m_ModuleStatus &= ~(MODULE_is_PLACED | MODULE_to_PLACE); break; @@ -97,11 +99,13 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) case PLACE_ALL: if( !IsOK( this, _( "Footprints NOT LOCKED will be moved" ) ) ) return; + break; case PLACE_INCREMENTAL: if( !IsOK( this, _( "Footprints NOT PLACED will be moved" ) ) ) return; + break; } @@ -118,9 +122,10 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) /* Compute module parmeters used in auto place */ Module = GetBoard()->m_Modules; NbTotalModules = 0; + for( ; Module != NULL; Module = Module->Next() ) { - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); NbTotalModules ++; } @@ -128,6 +133,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) return; Module = GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { Module->m_ModuleStatus &= ~MODULE_to_PLACE; @@ -141,16 +147,21 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) case PLACE_OUT_OF_BOARD: Module->m_ModuleStatus &= ~MODULE_is_PLACED; + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; + if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) Module->m_ModuleStatus |= MODULE_to_PLACE; + break; case PLACE_ALL: Module->m_ModuleStatus &= ~MODULE_is_PLACED; + if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; + Module->m_ModuleStatus |= MODULE_to_PLACE; break; @@ -159,8 +170,10 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) { Module->m_ModuleStatus &= ~MODULE_is_PLACED; break; } + if( !(Module->m_ModuleStatus & MODULE_is_PLACED) ) Module->m_ModuleStatus |= MODULE_to_PLACE; + break; } @@ -181,6 +194,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) if( NbModules ) Pas = 100.0 / (float) NbModules; + while( ( Module = PickModule( this, DC ) ) != NULL ) { float BestScore; @@ -192,6 +206,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) error = RecherchePlacementModule( Module, DC ); BestScore = MinCout; PosOK = CurrPosition; + if( error == ESC ) goto end_of_tst; @@ -202,9 +217,10 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) { int Angle_Rot_Module = 1800; Rotate_Module( DC, Module, Angle_Rot_Module, false ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); error = RecherchePlacementModule( Module, DC ); MinCout *= OrientPenality[ii]; + if( BestScore > MinCout ) /* This orientation is best. */ { PosOK = CurrPosition; @@ -215,18 +231,21 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) Angle_Rot_Module = -1800; Rotate_Module( DC, Module, Angle_Rot_Module, false ); } + if( error == ESC ) goto end_of_tst; } /* Determine if the best orientation of a module is 90. */ ii = Module->m_CntRot90 & 0x0F; + if( ii != 0 ) { int Angle_Rot_Module = 900; Rotate_Module( DC, Module, Angle_Rot_Module, false ); error = RecherchePlacementModule( Module, DC ); MinCout *= OrientPenality[ii]; + if( BestScore > MinCout ) /* This orientation is best. */ { PosOK = CurrPosition; @@ -237,18 +256,21 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) Angle_Rot_Module = -900; Rotate_Module( DC, Module, Angle_Rot_Module, false ); } + if( error == ESC ) goto end_of_tst; } /* Determine if the best orientation of a module is 270. */ ii = (Module->m_CntRot90 >> 4 ) & 0x0F; + if( ii != 0 ) { int Angle_Rot_Module = 2700; Rotate_Module( DC, Module, Angle_Rot_Module, false ); error = RecherchePlacementModule( Module, DC ); MinCout *= OrientPenality[ii]; + if( BestScore > MinCout ) /* This orientation is best. */ { PosOK = CurrPosition; @@ -259,6 +281,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) Angle_Rot_Module = -2700; Rotate_Module( DC, Module, Angle_Rot_Module, false ); } + if( error == ESC ) goto end_of_tst; } @@ -274,7 +297,7 @@ end_of_tst: Place_Module( Module, DC ); GetScreen()->SetCrossHairPosition( CurrPosition ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); GenModuleOnBoard( Module ); Module->m_ModuleStatus |= MODULE_is_PLACED; @@ -289,15 +312,15 @@ end_of_tst: Route_Layer_BOTTOM = lay_tmp_BOTTOM; Module = GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); } GetBoard()->m_Status_Pcb = 0; Compile_Ratsnest( DC, true ); DrawPanel->ReDraw( DC, true ); - DrawPanel->m_AbortEnable = false; } @@ -309,14 +332,14 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) MATRIX_CELL top_state, bottom_state; GRSetDrawMode( DC, GR_COPY ); + for( ii = 0; ii < Board.m_Nrows; ii++ ) { oy = GetBoard()->m_BoundaryBox.m_Pos.y + ( ii * Board.m_GridRouting ); for( jj = 0; jj < Board.m_Ncols; jj++ ) { - ox = GetBoard()->m_BoundaryBox.m_Pos.x + - (jj * Board.m_GridRouting); + ox = GetBoard()->m_BoundaryBox.m_Pos.x + (jj * Board.m_GridRouting); color = BLACK; top_state = GetCell( ii, jj, TOP ); @@ -328,12 +351,10 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) /* obstacles */ if( ( top_state & CELL_is_EDGE ) || ( bottom_state & CELL_is_EDGE ) ) color = WHITE; - else if( top_state & ( HOLE | CELL_is_MODULE ) ) color = LIGHTRED; else if( bottom_state & (HOLE | CELL_is_MODULE) ) color = LIGHTGREEN; - else /* Display the filling and keep out regions. */ { if( GetDist( ii, jj, TOP ) || GetDist( ii, jj, BOTTOM ) ) @@ -419,8 +440,10 @@ int PCB_EDIT_FRAME::GenPlaceBoard() MsgPanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN ); Route_Layer_BOTTOM = LAYER_N_FRONT; + if( Nb_Sides == TWO_SIDES ) Route_Layer_BOTTOM = LAYER_N_BACK; + Route_Layer_TOP = LAYER_N_FRONT; /* Place the edge layer segments */ @@ -430,6 +453,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() TmpSegm.SetLayer( -1 ); TmpSegm.SetNet( -1 ); TmpSegm.m_Width = Board.m_GridRouting / 2; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { DRAWSEGMENT* DrawSegm; @@ -438,6 +462,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() { case TYPE_DRAWSEGMENT: DrawSegm = (DRAWSEGMENT*) PtStruct; + if( DrawSegm->GetLayer() != EDGE_N ) break; @@ -485,7 +510,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) { int ox, oy, fx, fy, Penalite; int marge = Board.m_GridRouting / 2; - int masque_layer; + int layerMask; D_PAD* Pad; ox = Module->m_BoundaryBox.m_Pos.x - marge; @@ -495,31 +520,37 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) if( ox < GetBoard()->m_BoundaryBox.m_Pos.x ) ox = GetBoard()->m_BoundaryBox.m_Pos.x; + if( ox > GetBoard()->m_BoundaryBox.GetRight() ) ox = GetBoard()->m_BoundaryBox.GetRight(); if( fx < GetBoard()->m_BoundaryBox.m_Pos.x ) fx = GetBoard()->m_BoundaryBox.m_Pos.x; + if( fx > GetBoard()->m_BoundaryBox.GetRight() ) fx = GetBoard()->m_BoundaryBox.GetRight(); if( oy < GetBoard()->m_BoundaryBox.m_Pos.y ) oy = GetBoard()->m_BoundaryBox.m_Pos.y; + if( oy > GetBoard()->m_BoundaryBox.GetBottom() ) oy = GetBoard()->m_BoundaryBox.GetBottom(); if( fy < GetBoard()->m_BoundaryBox.m_Pos.y ) fy = GetBoard()->m_BoundaryBox.m_Pos.y; + if( fy > GetBoard()->m_BoundaryBox.GetBottom() ) fy = GetBoard()->m_BoundaryBox.GetBottom(); - masque_layer = 0; - if( Module->GetLayer() == LAYER_N_FRONT ) - masque_layer = LAYER_FRONT; - if( Module->GetLayer() == LAYER_N_BACK ) - masque_layer = LAYER_BACK; + layerMask = 0; - TraceFilledRectangle( GetBoard(), ox, oy, fx, fy, masque_layer, + if( Module->GetLayer() == LAYER_N_FRONT ) + layerMask = LAYER_FRONT; + + if( Module->GetLayer() == LAYER_N_BACK ) + layerMask = LAYER_BACK; + + TraceFilledRectangle( GetBoard(), ox, oy, fx, fy, layerMask, CELL_is_MODULE, WRITE_OR_CELL ); int trackWidth = GetBoard()->m_NetClasses.GetDefault()->GetTrackWidth(); @@ -530,15 +561,13 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() ) { - Place_1_Pad_Board( GetBoard(), Pad, CELL_is_MODULE, marge, - WRITE_OR_CELL ); + Place_1_Pad_Board( GetBoard(), Pad, CELL_is_MODULE, marge, WRITE_OR_CELL ); } /* Trace clearance. */ - marge = (Board.m_GridRouting * Module->m_PadNum ) / GAIN; + marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN; Penalite = PENALITE; - TracePenaliteRectangle( GetBoard(), ox, oy, fx, fy, marge, Penalite, - masque_layer ); + TracePenaliteRectangle( GetBoard(), ox, oy, fx, fy, marge, Penalite, layerMask ); } @@ -588,23 +617,25 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC ) * appearing on the other side. */ TstOtherSide = false; + if( Nb_Sides == TWO_SIDES ) { - D_PAD* Pad; int masque_otherlayer; - masque_otherlayer = LAYER_BACK; + D_PAD* Pad; + int otherLayerMask = LAYER_BACK; + if( Module->GetLayer() == LAYER_N_BACK ) - masque_otherlayer = LAYER_FRONT; + otherLayerMask = LAYER_FRONT; for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() ) { - if( ( Pad->m_Masque_Layer & masque_otherlayer ) == 0 ) + if( ( Pad->m_layerMask & otherLayerMask ) == 0 ) continue; + TstOtherSide = true; break; } } - DrawModuleOutlines( DrawPanel, DC, Module ); mincout = -1.0; @@ -614,6 +645,7 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC ) CurrPosition.x += Board.m_GridRouting ) { wxYield(); + if( DrawPanel->m_AbortRequest ) { if( IsOK( this, _( "Ok to abort?" ) ) ) @@ -640,8 +672,10 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC ) { /* Erase traces. */ DrawModuleOutlines( DrawPanel, DC, Module ); + if( DisplayChevelu ) Compute_Ratsnest_PlaceModule( DC ); + DisplayChevelu = 0; Module->m_BoundaryBox.m_Pos.x = ox + CurrPosition.x; Module->m_BoundaryBox.m_Pos.y = oy + CurrPosition.y; @@ -649,6 +683,7 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC ) g_Offset_Module.y = cy - CurrPosition.y; DrawModuleOutlines( DrawPanel, DC, Module ); Penalite = TstModuleOnBoard( GetBoard(), Module, TstOtherSide ); + if( Penalite >= 0 ) /* c a d if the module can be placed. */ { error = 0; @@ -669,13 +704,16 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC ) SetStatusText( msg ); } } + if( DisplayChevelu ) Compute_Ratsnest_PlaceModule( DC ); + DisplayChevelu = 0; } } DrawModuleOutlines( DrawPanel, DC, Module ); /* erasing the last traces */ + if( DisplayChevelu ) Compute_Ratsnest_PlaceModule( DC ); @@ -711,18 +749,24 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side ) row_max = uy1 / Board.m_GridRouting; col_max = ux1 / Board.m_GridRouting; row_min = uy0 / Board.m_GridRouting; + if( uy0 > row_min * Board.m_GridRouting ) row_min++; + col_min = ux0 / Board.m_GridRouting; + if( ux0 > col_min * Board.m_GridRouting ) col_min++; if( row_min < 0 ) row_min = 0; + if( row_max >= ( Nrows - 1 ) ) row_max = Nrows - 1; + if( col_min < 0 ) col_min = 0; + if( col_max >= ( Ncols - 1 ) ) col_max = Ncols - 1; @@ -731,8 +775,10 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side ) for( col = col_min; col <= col_max; col++ ) { data = GetCell( row, col, side ); + if( ( data & CELL_is_ZONE ) == 0 ) return OUT_OF_BOARD; + if( data & CELL_is_MODULE ) return OCCUPED_By_MODULE; } @@ -761,22 +807,29 @@ unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, row_max = uy1 / Board.m_GridRouting; col_max = ux1 / Board.m_GridRouting; row_min = uy0 / Board.m_GridRouting; + if( uy0 > row_min * Board.m_GridRouting ) row_min++; + col_min = ux0 / Board.m_GridRouting; + if( ux0 > col_min * Board.m_GridRouting ) col_min++; if( row_min < 0 ) row_min = 0; + if( row_max >= ( Nrows - 1 ) ) row_max = Nrows - 1; + if( col_min < 0 ) col_min = 0; + if( col_max >= ( Ncols - 1 ) ) col_max = Ncols - 1; Penalite = 0; + for( row = row_min; row <= row_max; row++ ) { for( col = col_min; col <= col_max; col++ ) @@ -799,6 +852,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide ) int error, Penalite, marge, side, otherside; side = TOP; otherside = BOTTOM; + if( Module->GetLayer() == LAYER_N_BACK ) { side = BOTTOM; otherside = TOP; @@ -810,12 +864,14 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide ) fy = Module->m_BoundaryBox.GetBottom(); error = TstRectangle( Pcb, ox, oy, fx, fy, side ); + if( error < 0 ) return error; if( TstOtherSide ) { error = TstRectangle( Pcb, ox, oy, fx, fy, otherside ); + if( error < 0 ) return error; } @@ -843,15 +899,18 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) if( ( GetBoard()->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 ) return -1; + cout = 0; int color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); if( AutoPlaceShowAll ) GRSetDrawMode( DC, GR_XOR ); + for( unsigned ii = 0; ii < GetBoard()->m_LocalRatsnest.size(); ii++ ) { RATSNEST_ITEM* pt_local_chevelu = &GetBoard()->m_LocalRatsnest[ii]; + if( !( pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM ) ) { ox = pt_local_chevelu->m_PadStart->GetPosition().x - @@ -863,8 +922,7 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) if( AutoPlaceShowAll ) { - GRLine( &DrawPanel->m_ClipBox, DC, ox, oy, fx, fy, - 0, color ); + GRLine( &DrawPanel->m_ClipBox, DC, ox, oy, fx, fy, 0, color ); } /* Cost of the ratsnest. */ @@ -901,7 +959,7 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) * Cell outside this rectangle, but inside the rectangle * x0,y0 -marge to x1,y1 + marge sont incrementede by a decreasing value * (Penalite ... 0). The decreasing value de pends on the distance to the first rectangle - * Therefore the cost is hight in rect x0,y0 a x1,y1, and decrease outside this rectangle + * Therefore the cost is high in rect x0,y0 a x1,y1, and decrease outside this rectangle */ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, @@ -910,7 +968,7 @@ static void TracePenaliteRectangle( BOARD* Pcb, int uy1, int marge, int Penalite, - int masque_layer ) + int aLayerMask ) { int row, col; int row_min, row_max, col_min, col_max, pmarge; @@ -918,10 +976,10 @@ static void TracePenaliteRectangle( BOARD* Pcb, DIST_CELL data, LocalPenalite; int lgain, cgain; - if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + if( aLayerMask & g_TabOneLayerMask[Route_Layer_BOTTOM] ) trace = 1; /* Trace on bottom layer. */ - if( ( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides ) + if( ( aLayerMask & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides ) trace |= 2; /* Trace on top layer. */ if( trace == 0 ) @@ -942,24 +1000,31 @@ static void TracePenaliteRectangle( BOARD* Pcb, row_max = uy1 / Board.m_GridRouting; col_max = ux1 / Board.m_GridRouting; row_min = uy0 / Board.m_GridRouting; + if( uy0 > row_min * Board.m_GridRouting ) row_min++; + col_min = ux0 / Board.m_GridRouting; + if( ux0 > col_min * Board.m_GridRouting ) col_min++; if( row_min < 0 ) row_min = 0; + if( row_max >= (Nrows - 1) ) row_max = Nrows - 1; + if( col_min < 0 ) col_min = 0; + if( col_max >= (Ncols - 1) ) col_max = Ncols - 1; for( row = row_min; row <= row_max; row++ ) { lgain = 256; + if( row < pmarge ) lgain = ( 256 * row ) / pmarge; else if( row > row_max - pmarge ) @@ -969,19 +1034,23 @@ static void TracePenaliteRectangle( BOARD* Pcb, { cgain = 256; LocalPenalite = Penalite; + if( col < pmarge ) cgain = ( 256 * col ) / pmarge; else if( col > col_max - pmarge ) cgain = ( 256 * ( col_max - col ) ) / pmarge; cgain = ( cgain * lgain ) / 256; + if( cgain != 256 ) LocalPenalite = ( LocalPenalite * cgain ) / 256; + if( trace & 1 ) { data = GetDist( row, col, BOTTOM ) + LocalPenalite; SetDist( row, col, BOTTOM, data ); } + if( trace & 2 ) { data = GetDist( row, col, TOP ); @@ -1025,27 +1094,29 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) // Build sorted footprints list (sort by decreasing size ) Module = pcbframe->GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); moduleList.push_back(Module); } + sort( moduleList.begin(), moduleList.end(), Tri_PlaceModules ); for( unsigned ii = 0; ii < moduleList.size(); ii++ ) { Module = moduleList[ii]; Module->flag = 0; + if( !( Module->m_ModuleStatus & MODULE_to_PLACE ) ) continue; + pcbframe->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK; Module->DisplayInfo( pcbframe ); pcbframe->build_ratsnest_module( Module ); /* Calculate external ratsnet. */ - for( unsigned ii = 0; - ii < pcbframe->GetBoard()->m_LocalRatsnest.size(); - ii++ ) + for( unsigned ii = 0; ii < pcbframe->GetBoard()->m_LocalRatsnest.size(); ii++ ) { if( ( pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status & LOCAL_RATSNEST_ITEM ) == 0 ) @@ -1060,14 +1131,19 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) /* Search for "best" module. */ MODULE* bestModule = NULL; MODULE* altModule = NULL; + for( unsigned ii = 0; ii < moduleList.size(); ii++ ) { Module = moduleList[ii]; + if( !( Module->m_ModuleStatus & MODULE_to_PLACE ) ) continue; + altModule = Module; + if( Module->flag == 0 ) continue; + bestModule = Module; break; } @@ -1079,10 +1155,6 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) } -/********************************************/ -int Propagation( PCB_EDIT_FRAME* frame ) -/********************************************/ - /** * Function Propagation * Used now only in autoplace calculations @@ -1107,6 +1179,7 @@ int Propagation( PCB_EDIT_FRAME* frame ) * Iterations are made until no cell is added to the zone. * @return: added cells count (i.e. which the attribute CELL_is_ZONE is set) */ +int Propagation( PCB_EDIT_FRAME* frame ) { int row, col, nn; long current_cell, old_cell_H; @@ -1125,22 +1198,25 @@ int Propagation( PCB_EDIT_FRAME* frame ) /* search 1 : from left to right and top to bottom */ memset( pt_cell_V, 0, nn ); + for( row = 0; row < Nrows; row++ ) { old_cell_H = 0; + for( col = 0; col < Ncols; col++ ) { current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; + if( current_cell == 0 ) /* a free cell is found */ { - if( (old_cell_H & CELL_is_ZONE) - || (pt_cell_V[col] & CELL_is_ZONE) ) + if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) ) { OrCell( row, col, BOTTOM, CELL_is_ZONE ); current_cell = CELL_is_ZONE; nbpoints++; } } + pt_cell_V[col] = old_cell_H = current_cell; } } @@ -1148,22 +1224,24 @@ int Propagation( PCB_EDIT_FRAME* frame ) /* search 2 : from right to left and top to bottom */ frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "2" ), CYAN ); memset( pt_cell_V, 0, nn ); + for( row = 0; row < Nrows; row++ ) { old_cell_H = 0; for( col = Ncols - 1; col >= 0; col-- ) { current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; + if( current_cell == 0 ) /* a free cell is found */ { - if( (old_cell_H & CELL_is_ZONE) - || (pt_cell_V[col] & CELL_is_ZONE) ) + if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) ) { OrCell( row, col, BOTTOM, CELL_is_ZONE ); current_cell = CELL_is_ZONE; nbpoints++; } } + pt_cell_V[col] = old_cell_H = current_cell; } } @@ -1171,22 +1249,25 @@ int Propagation( PCB_EDIT_FRAME* frame ) /* search 3 : from bottom to top and right to left balayage */ frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "3" ), CYAN ); memset( pt_cell_V, 0, nn ); + for( col = Ncols - 1; col >= 0; col-- ) { old_cell_H = 0; + for( row = Nrows - 1; row >= 0; row-- ) { current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; + if( current_cell == 0 ) /* a free cell is found */ { - if( (old_cell_H & CELL_is_ZONE) - || (pt_cell_V[row] & CELL_is_ZONE) ) + if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) ) { OrCell( row, col, BOTTOM, CELL_is_ZONE ); current_cell = CELL_is_ZONE; nbpoints++; } } + pt_cell_V[row] = old_cell_H = current_cell; } } @@ -1198,19 +1279,21 @@ int Propagation( PCB_EDIT_FRAME* frame ) for( col = 0; col < Ncols; col++ ) { old_cell_H = 0; + for( row = Nrows - 1; row >= 0; row-- ) { current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; + if( current_cell == 0 ) /* a free cell is found */ { - if( (old_cell_H & CELL_is_ZONE) - || (pt_cell_V[row] & CELL_is_ZONE) ) + if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) ) { OrCell( row, col, BOTTOM, CELL_is_ZONE ); current_cell = CELL_is_ZONE; nbpoints++; } } + pt_cell_V[row] = old_cell_H = current_cell; } } @@ -1219,4 +1302,3 @@ int Propagation( PCB_EDIT_FRAME* frame ) return nbpoints; } - diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index ecb9503118..07a9fe4185 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -69,7 +69,7 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, m_DisplayModEdge = FILLED; // How to display module drawings (line/ filled / sketch) m_DisplayModText = FILLED; // How to display module texts (line/ filled / sketch) - m_DisplayPcbTrackFill = true; /* FALSE = sketch , true = filled */ + m_DisplayPcbTrackFill = true; /* false = sketch , true = filled */ m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL) m_ModuleEditFrame = NULL; // Frame for footprint edition diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 361ba69e9a..68db54fda7 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -378,7 +378,7 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) */ void PCB_EDIT_FRAME::Block_SelectItems() { - int masque_layer; + int layerMask; GetScreen()->m_BlockLocate.Normalize(); @@ -388,8 +388,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() // Add modules if( blockIncludeModules ) { - for( MODULE* module = m_Pcb->m_Modules; module != NULL; - module = module->Next() ) + for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() ) { int layer = module->GetLayer(); @@ -409,8 +408,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() // Add tracks and vias if( blockIncludeTracks ) { - for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL; - pt_segm = pt_segm->Next() ) + for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) ) { @@ -425,16 +423,15 @@ void PCB_EDIT_FRAME::Block_SelectItems() } // Add graphic items - masque_layer = EDGE_LAYER; + layerMask = EDGE_LAYER; if( blockIncludeItemsOnTechLayers ) - masque_layer = ALL_LAYERS; + layerMask = ALL_LAYERS; if( !blockIncludeBoardOutlineLayer ) - masque_layer &= ~EDGE_LAYER; + layerMask &= ~EDGE_LAYER; - for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; - PtStruct = PtStruct->Next() ) + for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && ! blockIncludeItemsOnInvisibleLayers) continue; @@ -442,7 +439,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() switch( PtStruct->Type() ) { case TYPE_DRAWSEGMENT: - if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[PtStruct->GetLayer()] & layerMask) == 0 ) break; if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) @@ -459,21 +456,23 @@ void PCB_EDIT_FRAME::Block_SelectItems() select_me = true; // This item is in bloc: select it break; - case TYPE_MIRE: - if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer ) == 0 ) + case PCB_TARGET_T: + if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & layerMask ) == 0 ) break; if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) break; + select_me = true; // This item is in bloc: select it break; case TYPE_DIMENSION: - if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer ) == 0 ) + if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & layerMask ) == 0 ) break; if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) break; + select_me = true; // This item is in bloc: select it break; @@ -517,9 +516,11 @@ static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent(); g_Offset_Module = -aOffset; + for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ ) { BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii ); + switch( item->Type() ) { case TYPE_MODULE: @@ -531,7 +532,7 @@ static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset case TYPE_TEXTE: case TYPE_TRACK: case TYPE_VIA: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DIMENSION: // Currently markers are not affected by block commands case TYPE_MARKER_PCB: item->Draw( aPanel, aDC, GR_XOR, aOffset ); @@ -600,6 +601,7 @@ void PCB_EDIT_FRAME::Block_Delete() { BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii ); itemsList->SetPickedItemStatus( UR_DELETED, ii ); + switch( item->Type() ) { case TYPE_MODULE: @@ -620,7 +622,7 @@ void PCB_EDIT_FRAME::Block_Delete() case TYPE_TRACK: // a track segment (segment on a copper layer) case TYPE_VIA: // a via (like atrack segment on a copper layer) case TYPE_DIMENSION: // a dimension (graphic item) - case TYPE_MIRE: // a target (graphic item) + case PCB_TARGET_T: // a target (graphic item) item->UnLink(); break; @@ -671,6 +673,7 @@ void PCB_EDIT_FRAME::Block_Rotate() wxASSERT( item ); itemsList->SetPickedItemStatus( UR_ROTATED, ii ); item->Rotate( centre, rotAngle ); + switch( item->Type() ) { case TYPE_MODULE: @@ -687,7 +690,7 @@ void PCB_EDIT_FRAME::Block_Rotate() case TYPE_ZONE_CONTAINER: case TYPE_DRAWSEGMENT: case TYPE_TEXTE: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DIMENSION: break; @@ -736,6 +739,7 @@ void PCB_EDIT_FRAME::Block_Flip() wxASSERT( item ); itemsList->SetPickedItemStatus( UR_FLIPPED, ii ); item->Flip( center ); + switch( item->Type() ) { case TYPE_MODULE: @@ -752,7 +756,7 @@ void PCB_EDIT_FRAME::Block_Flip() case TYPE_ZONE_CONTAINER: case TYPE_DRAWSEGMENT: case TYPE_TEXTE: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DIMENSION: break; @@ -812,7 +816,7 @@ void PCB_EDIT_FRAME::Block_Move() case TYPE_ZONE_CONTAINER: case TYPE_DRAWSEGMENT: case TYPE_TEXTE: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DIMENSION: break; @@ -890,8 +894,7 @@ void PCB_EDIT_FRAME::Block_Duplicate() case TYPE_ZONE_CONTAINER: { - ZONE_CONTAINER* new_zone = - new ZONE_CONTAINER( (BOARD*) item->GetParent() ); + ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*) item->GetParent() ); new_zone->Copy( (ZONE_CONTAINER*) item ); new_zone->m_TimeStamp = GetTimeStamp(); newitem = new_zone; @@ -917,12 +920,12 @@ void PCB_EDIT_FRAME::Block_Duplicate() } break; - case TYPE_MIRE: + case PCB_TARGET_T: { - MIREPCB* new_mire = new MIREPCB( m_Pcb ); - new_mire->Copy( (MIREPCB*) item ); - m_Pcb->Add( new_mire ); - newitem = new_mire; + PCB_TARGET* target = new PCB_TARGET( m_Pcb ); + target->Copy( (PCB_TARGET*) item ); + m_Pcb->Add( target ); + newitem = target; } break; @@ -941,12 +944,12 @@ void PCB_EDIT_FRAME::Block_Duplicate() } if( newitem ) - { - newitem->Move( MoveVector ); - picker.m_PickedItem = newitem; - picker.m_PickedItemType = newitem->Type(); - newList.PushItem( picker ); - } + { + newitem->Move( MoveVector ); + picker.m_PickedItem = newitem; + picker.m_PickedItemType = newitem->Type(); + newList.PushItem( picker ); + } } if( newList.GetCount() ) diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 76712c0575..6e18cace3b 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -114,13 +114,13 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) if( DrawPanel->IsMouseCaptured() ) { - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines; - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; - DrawPanel->Refresh( TRUE ); + DrawPanel->Refresh( true ); } break; @@ -215,7 +215,7 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) GetScreen()->m_BlockLocate.ClearItemsList(); SaveCopyInUndoList( currentModule, UR_MODEDIT ); MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.m_MoveVector ); - DrawPanel->Refresh( TRUE ); + DrawPanel->Refresh( true ); break; case BLOCK_COPY: /* Copy */ @@ -366,6 +366,7 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) { if( pad->m_Selected == 0 ) continue; + pad->m_Selected = 0; D_PAD* NewPad = new D_PAD( module ); NewPad->Copy( pad ); diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index ba5c8af53c..c7864f5722 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -81,16 +81,19 @@ int MATRIX_ROUTING_HEAD::InitBoard() /* allocate Board & initialize everything to empty */ m_BoardSide[kk] = (MATRIX_CELL*) MyZMalloc( ii * sizeof(MATRIX_CELL) ); + if( m_BoardSide[kk] == NULL ) return -1; /***** allocate Distances *****/ m_DistSide[kk] = (DIST_CELL*) MyZMalloc( ii * sizeof(DIST_CELL) ); + if( m_DistSide[kk] == NULL ) return -1; /***** allocate Dir (chars) *****/ m_DirSide[kk] = (char*) MyZMalloc( ii ); + if( m_DirSide[kk] == NULL ) return -1; } @@ -146,7 +149,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) { int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy; int marge, via_marge; - int masque_layer; + int layerMask; // use the default NETCLASS? NETCLASS* nc = aPcb->m_NetClasses.GetDefault(); @@ -167,12 +170,14 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) { Place_1_Pad_Board( aPcb, pad, HOLE, marge, WRITE_CELL ); } + Place_1_Pad_Board( aPcb, pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); } // Place outlines of modules on matrix routing, if they are on a copper layer // or on the edge layer TRACK tmpSegm( NULL ); // A dummy track used to create segments. + for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() ) @@ -184,6 +189,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) EDGE_MODULE* edge = (EDGE_MODULE*) item; tmpSegm.SetLayer( edge->GetLayer() ); + if( tmpSegm.GetLayer() == EDGE_N ) tmpSegm.SetLayer( -1 ); @@ -195,8 +201,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) tmpSegm.SetNet( -1 ); TraceSegmentPcb( aPcb, &tmpSegm, HOLE, marge, WRITE_CELL ); - TraceSegmentPcb( aPcb, &tmpSegm, VIA_IMPOSSIBLE, via_marge, - WRITE_OR_CELL ); + TraceSegmentPcb( aPcb, &tmpSegm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); } break; @@ -218,6 +223,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) int type_cell = HOLE; DrawSegm = (DRAWSEGMENT*) item; tmpSegm.SetLayer( DrawSegm->GetLayer() ); + if( DrawSegm->GetLayer() == EDGE_N ) { tmpSegm.SetLayer( -1 ); @@ -258,16 +264,16 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) ux0 -= dx; uy0 -= dy; - masque_layer = g_TabOneLayerMask[PtText->GetLayer()]; + layerMask = g_TabOneLayerMask[PtText->GetLayer()]; TraceFilledRectangle( aPcb, ux0 - marge, uy0 - marge, ux1 + marge, uy1 + marge, (int) (PtText->m_Orient), - masque_layer, HOLE, WRITE_CELL ); + layerMask, HOLE, WRITE_CELL ); TraceFilledRectangle( aPcb, ux0 - via_marge, uy0 - via_marge, ux1 + via_marge, uy1 + via_marge, (int) (PtText->m_Orient), - masque_layer, VIA_IMPOSSIBLE, WRITE_OR_CELL ); + layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL ); } break; @@ -299,6 +305,7 @@ int Build_Work( BOARD* Pcb ) InitWork(); /* clear work list */ Ntotal = 0; + for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ ) { pt_rats = &Pcb->m_FullRatsnest[ii]; @@ -308,10 +315,13 @@ int Build_Work( BOARD* Pcb ) */ if( (pt_rats->m_Status & CH_ACTIF) == 0 ) continue; + if( pt_rats->m_Status & CH_UNROUTABLE ) continue; + if( (pt_rats->m_Status & CH_ROUTE_REQ) == 0 ) continue; + pt_pad = pt_rats->m_PadStart; current_net_code = pt_pad->GetNet(); @@ -319,6 +329,7 @@ int Build_Work( BOARD* Pcb ) r1 = ( pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y + demi_pas ) / Board.m_GridRouting; + if( r1 < 0 || r1 >= Nrows ) { msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1, @@ -326,8 +337,10 @@ int Build_Work( BOARD* Pcb ) wxMessageBox( msg ); return 0; } + c1 = ( pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x + demi_pas ) / Board.m_GridRouting; + if( c1 < 0 || c1 >= Ncols ) { msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1, @@ -340,6 +353,7 @@ int Build_Work( BOARD* Pcb ) r2 = ( pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y + demi_pas ) / Board.m_GridRouting; + if( r2 < 0 || r2 >= Nrows ) { msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2, @@ -347,8 +361,10 @@ int Build_Work( BOARD* Pcb ) wxMessageBox( msg ); return 0; } + c2 = ( pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x + demi_pas ) / Board.m_GridRouting; + if( c2 < 0 || c2 >= Ncols ) { msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2, diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 83d57a3946..9da9797922 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -46,9 +46,10 @@ void TransformArcToPolygon( std::vector & aCornerBuffer, int aCircleToSegmentsCount, int aWidth ) { wxPoint arc_start, arc_end; - int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree + int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree arc_end = arc_start = aStart; + if( aArcAngle != 3600 ) { RotatePoint( &arc_end, aCentre, -aArcAngle ); @@ -63,12 +64,13 @@ void TransformArcToPolygon( std::vector & aCornerBuffer, // Compute the ends of segments and creates poly wxPoint curr_end = arc_start; wxPoint curr_start = arc_start; + for( int ii = delta; ii < aArcAngle; ii += delta ) { curr_end = arc_start; RotatePoint( &curr_end, aCentre, -ii ); - TransformRoundedEndsSegmentToPolygon( aCornerBuffer, - curr_start, curr_end, aCircleToSegmentsCount, aWidth ); + TransformRoundedEndsSegmentToPolygon( aCornerBuffer, curr_start, curr_end, + aCircleToSegmentsCount, aWidth ); curr_start = curr_end; } @@ -90,11 +92,10 @@ void TransformArcToPolygon( std::vector & aCornerBuffer, * clearance when the circle is approximated by segment bigger or equal * to the real clearance value (usually near from 1.0) */ -void TEXTE_PCB::TransformShapeWithClearanceToPolygon( - std::vector & aCornerBuffer, - int aClearanceValue, - int aCircleToSegmentsCount, - double aCorrectionFactor ) +void TEXTE_PCB::TransformShapeWithClearanceToPolygon( std::vector & aCornerBuffer, + int aClearanceValue, + int aCircleToSegmentsCount, + double aCorrectionFactor ) { if( GetLength() == 0 ) return; @@ -115,9 +116,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygon( for( int ii = 0; ii < 4; ii++ ) { // Rotate polygon - RotatePoint( &corners[ii].x, &corners[ii].y, - m_Pos.x, m_Pos.y, - m_Orient ); + RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient ); aCornerBuffer.push_back( corners[ii] ); } @@ -137,32 +136,31 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygon( * clearance when the circle is approxiamted by segment bigger or equal * to the real clearance value (usually near from 1.0) */ -void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( - std::vector & aCornerBuffer, - int aClearanceValue, - int aCircleToSegmentsCount, - double aCorrectionFactor ) +void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( std::vector & aCornerBuffer, + int aClearanceValue, + int aCircleToSegmentsCount, + double aCorrectionFactor ) { switch( m_Shape ) { case S_CIRCLE: TransformArcToPolygon( aCornerBuffer, m_Start, // Circle centre - m_End, 3600, - aCircleToSegmentsCount, - m_Width + (2 * aClearanceValue) ); + m_End, 3600, + aCircleToSegmentsCount, + m_Width + (2 * aClearanceValue) ); break; case S_ARC: TransformArcToPolygon( aCornerBuffer, m_Start, - m_End, m_Angle, - aCircleToSegmentsCount, - m_Width + (2 * aClearanceValue) ); + m_End, m_Angle, + aCircleToSegmentsCount, + m_Width + (2 * aClearanceValue) ); break; default: - TransformRoundedEndsSegmentToPolygon( - aCornerBuffer, m_Start, m_End, - aCircleToSegmentsCount, m_Width + (2 * aClearanceValue) ); + TransformRoundedEndsSegmentToPolygon( aCornerBuffer, m_Start, m_End, + aCircleToSegmentsCount, + m_Width + (2 * aClearanceValue) ); break; } } @@ -188,17 +186,17 @@ void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor wxPoint corner_position; int ii, angle; int dx = (m_Width / 2) + aClearanceValue; - int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree + int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree switch( Type() ) { case TYPE_VIA: dx = (int) ( dx * aCorrectionFactor ); + for( ii = 0; ii < aCircleToSegmentsCount; ii++ ) { corner_position = wxPoint( dx, 0 ); - RotatePoint( &corner_position.x, &corner_position.y, - (1800 / aCircleToSegmentsCount) ); + RotatePoint( &corner_position.x, &corner_position.y, (1800 / aCircleToSegmentsCount) ); angle = ii * delta; RotatePoint( &corner_position.x, &corner_position.y, angle ); corner_position.x += m_Start.x; @@ -211,11 +209,10 @@ void TRACK:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor break; default: - TransformRoundedEndsSegmentToPolygon( - aCornerBuffer, - m_Start, m_End, - aCircleToSegmentsCount, - m_Width + ( 2 * aClearanceValue) ); + TransformRoundedEndsSegmentToPolygon( aCornerBuffer, + m_Start, m_End, + aCircleToSegmentsCount, + m_Width + ( 2 * aClearanceValue) ); break; } } @@ -228,7 +225,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, int aCircleToSegmentsCount, int aWidth ) { - int rayon = aWidth / 2; + int radius = aWidth / 2; wxPoint endp = aEnd - aStart; // end point coordinate for the same segment starting at (0,0) wxPoint startp = aStart; wxPoint corner; @@ -241,20 +238,21 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, endp = aStart - aEnd; startp = aEnd; } + int delta_angle = ArcTangente( endp.y, endp.x ); // delta_angle is in 0.1 degrees seg_len = (int) sqrt( ( (double) endp.y * endp.y ) + ( (double) endp.x * endp.x ) ); int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree // Compute the outlines of the segment, and creates a polygon - corner = wxPoint( 0, rayon ); + corner = wxPoint( 0, radius ); RotatePoint( &corner, -delta_angle ); corner += startp; polypoint.x = corner.x; polypoint.y = corner.y; aCornerBuffer.push_back( polypoint ); - corner = wxPoint( seg_len, rayon ); + corner = wxPoint( seg_len, radius ); RotatePoint( &corner, -delta_angle ); corner += startp; polypoint.x = corner.x; @@ -264,7 +262,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, // add right rounded end: for( int ii = delta; ii < 1800; ii += delta ) { - corner = wxPoint( 0, rayon ); + corner = wxPoint( 0, radius ); RotatePoint( &corner, ii ); corner.x += seg_len; RotatePoint( &corner, -delta_angle ); @@ -274,14 +272,14 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, aCornerBuffer.push_back( polypoint ); } - corner = wxPoint( seg_len, -rayon ); + corner = wxPoint( seg_len, -radius ); RotatePoint( &corner, -delta_angle ); corner += startp; polypoint.x = corner.x; polypoint.y = corner.y; aCornerBuffer.push_back( polypoint ); - corner = wxPoint( 0, -rayon ); + corner = wxPoint( 0, -radius ); RotatePoint( &corner, -delta_angle ); corner += startp; polypoint.x = corner.x; @@ -291,7 +289,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, // add left rounded end: for( int ii = delta; ii < 1800; ii += delta ) { - corner = wxPoint( 0, -rayon ); + corner = wxPoint( 0, -radius ); RotatePoint( &corner, ii ); RotatePoint( &corner, -delta_angle ); corner += startp; @@ -326,17 +324,18 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor int dx = (m_Size.x / 2) + aClearanceValue; int dy = (m_Size.y / 2) + aClearanceValue; - int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree - wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset, - * the pad position is NOT the shape position */ - wxSize psize = m_Size; /* pad size unsed in RECT and TRAPEZOIDAL pads - * trapezoidal pads are considered as rect pad shape having they boudary box size - */ + int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree + wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset, + * the pad position is NOT the shape position */ + wxSize psize = m_Size; /* pad size unsed in RECT and TRAPEZOIDAL pads + * trapezoidal pads are considered as rect + * pad shape having they boudary box size */ switch( m_PadShape ) { case PAD_CIRCLE: dx = (int) ( dx * aCorrectionFactor ); + for( ii = 0; ii < aCircleToSegmentsCount; ii++ ) { corner_position = wxPoint( dx, 0 ); @@ -360,7 +359,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor dy = (int) ( dy * aCorrectionFactor ); int angle_pg; // Polygon angle wxPoint shape_offset = wxPoint( 0, dy - dx ); - RotatePoint( &shape_offset, angle ); // Rotating shape offset vector with component + + RotatePoint( &shape_offset, angle ); // Rotating shape offset vector with component for( ii = 0; ii < aCircleToSegmentsCount / 2 + 1; ii++ ) // Half circle end cap... { @@ -434,10 +434,13 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor psize.y += ABS( m_DeltaSize.x ); // fall through - case PAD_RECT: // Easy implementation for rectangular cutouts with rounded corners // Easy implementation for rectangular cutouts with rounded corners + case PAD_RECT: + // Easy implementation for rectangular cutouts with rounded corners angle = m_Orient; - int rounding_radius = (int) ( aClearanceValue * aCorrectionFactor ); // Corner rounding radius - int angle_pg; // Polygon increment angle + + // Corner rounding radius + int rounding_radius = (int) ( aClearanceValue * aCorrectionFactor ); + int angle_pg; // Polygon increment angle for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) { @@ -449,11 +452,11 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation - corner_position -= psize / 2; // Rounding vector + Pad corner offset + corner_position -= psize / 2; // Rounding vector + Pad corner offset RotatePoint( &corner_position, angle ); // Rotate according to module orientation - corner_position += PadShapePos; // Shift origin to position + corner_position += PadShapePos; // Shift origin to position CPolyPt polypoint( corner_position.x, corner_position.y ); aCornerBuffer.push_back( polypoint ); } @@ -471,9 +474,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor aCornerBuffer.push_back( polypoint ); } - for( int i = 0; - i < aCircleToSegmentsCount / 4 + 1; - i++ ) + for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) { corner_position = wxPoint( 0, rounding_radius ); RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) ); @@ -533,7 +534,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor * And * nothing else between holes * And - * angles less than 90 deg between 2 consecutive lines in hole outline (sometime occurs without this condition) + * angles less than 90 deg between 2 consecutive lines in hole outline (sometime occurs without + * this condition) * And * a hole above the identical holes * @@ -547,8 +549,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor * * Note 2: * Trapezoidal pads are not considered here because they are very special case - * and are used in microwave applications and they *DO NOT* have a thermal relief that change the shape - * by creating stubs and destroy their properties. + * and are used in microwave applications and they *DO NOT* have a thermal relief that + * change the shape by creating stubs and destroy their properties. */ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, D_PAD& aPad, @@ -579,6 +581,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, * with a thickness of aMinThicknessValue will increase real thickness by aMinThicknessValue */ aCopperThickness -= aMinThicknessValue; + if( aCopperThickness < 0 ) aCopperThickness = 0; @@ -611,17 +614,20 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // Crosspoint of thermal spoke sides, the first point of polygon buffer corners_buffer.push_back( wxPoint( copper_thickness.x / 2, copper_thickness.y / 2 ) ); - // Add an intermediate point on spoke sides, to allow a > 90 deg angle between side and first seg of arc approx + // Add an intermediate point on spoke sides, to allow a > 90 deg angle between side + // and first seg of arc approx corner.x = copper_thickness.x / 2; int y = outer_radius - (aThermalGap / 4); corner.y = (int) sqrt( ( ( (double) y * y ) - (double) corner.x * corner.x ) ); + if( aThermalRot != 0 ) corners_buffer.push_back( corner ); // calculate the starting point of the outter arc corner.x = copper_thickness.x / 2; - double dtmp = - sqrt( ( (double) outer_radius * outer_radius ) - ( (double) corner.x * corner.x ) ); + + double dtmp = sqrt( ( (double) outer_radius * outer_radius ) - + ( (double) corner.x * corner.x ) ); corner.y = (int) dtmp; RotatePoint( &corner, 90 ); @@ -638,7 +644,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, corners_buffer.push_back( corner_end ); - /* add an intermediate point, to avoid angles < 90 deg between last arc approx line and radius line + /* add an intermediate point, to avoid angles < 90 deg between last arc approx line + * and radius line */ corner.x = corners_buffer[1].y; corner.y = corners_buffer[1].x; @@ -649,10 +656,12 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // bad filled polygon on some cases, when pads are on a same vertical line // this seems a bug in kbool polygon (exists in 2.0 kbool version) // aThermalRot = 450 (45.0 degrees orientation) seems work fine. - // aThermalRot = 0 with thermal shapes without angle < 90 deg has problems in rare circumstances + // aThermalRot = 0 with thermal shapes without angle < 90 deg has problems in rare + // circumstances. // Note: with the 2 step build ( thermal shapes added after areas are built), 0 seems work int angle_pad = aPad.m_Orient; // Pad orientation int th_angle = aThermalRot; + for( unsigned ihole = 0; ihole < 4; ihole++ ) { for( unsigned ii = 0; ii < corners_buffer.size(); ii++ ) @@ -682,12 +691,14 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // We want to calculate an oval shape with dx > dy. // if this is not the case, exchange dx and dy, and rotate the shape 90 deg. int supp_angle = 0; + if( dx < dy ) { EXCHG( dx, dy ); supp_angle = 900; EXCHG( copper_thickness.x, copper_thickness.y ); } + int deltasize = dx - dy; // = distance between shape position and the 2 demi-circle ends centre // here we have dx > dy // Radius of outer arcs of the shape: @@ -703,9 +714,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, if( copper_thickness.x > deltasize ) // If copper thickness is more than shape offset, we need to calculate arc intercept point. { corner.x = copper_thickness.x / 2; - corner.y = - (int) sqrt( ( (double) outer_radius * outer_radius ) - - ( (double) ( corner.x - delta ) * ( corner.x - deltasize ) ) ); + corner.y = (int) sqrt( ( (double) outer_radius * outer_radius ) - + ( (double) ( corner.x - delta ) * ( corner.x - deltasize ) ) ); corner.x -= deltasize; /* creates an intermediate point, to have a > 90 deg angle @@ -724,7 +734,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, corner.x = ( deltasize - copper_thickness.x ) / 2; } - // Add an intermediate point on spoke sides, to allow a > 90 deg angle between side and first seg of arc approx + // Add an intermediate point on spoke sides, to allow a > 90 deg angle between side + // and first seg of arc approx wxPoint last_corner; last_corner.y = copper_thickness.y / 2; int px = outer_radius - (aThermalGap / 4); @@ -745,13 +756,14 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, RotatePoint( &corner, delta ); } - //corners_buffer.push_back(corner + shape_offset); // TODO: about one mil geometry error forms somewhere. + //corners_buffer.push_back(corner + shape_offset); // TODO: about one mil geometry error forms somewhere. corners_buffer.push_back( corner_end + shape_offset ); corners_buffer.push_back( last_corner + shape_offset ); // Enabling the line above shows intersection point. /* Create 2 holes, rotated by pad rotation. */ int angle = aPad.m_Orient + supp_angle; + for( int irect = 0; irect < 2; irect++ ) { for( unsigned ic = 0; ic < corners_buffer.size(); ic++ ) @@ -764,6 +776,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, aCornerBuffer.back().end_contour = true; angle += 1800; // this is calculate hole 3 + if( angle >= 3600 ) angle -= 3600; } @@ -778,6 +791,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // Now add corner 4 and 2 (2 is the corner 4 rotated by 180 deg angle = aPad.m_Orient + supp_angle; + for( int irect = 0; irect < 2; irect++ ) { for( unsigned ic = 0; ic < corners_buffer.size(); ic++ ) @@ -790,6 +804,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, aCornerBuffer.back().end_contour = true; angle += 1800; + if( angle >= 3600 ) angle -= 3600; } @@ -818,15 +833,17 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // | | // 1 -------4 - // Modified rectangles with one corner rounded. TODO: merging with oval thermals and possibly round too. + // Modified rectangles with one corner rounded. TODO: merging with oval thermals + // and possibly round too. std::vector corners_buffer; // Polygon buffer as vector int dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y - // The first point of polygon buffer is left lower corner, second the crosspoint of thermal spoke sides, - // the third is upper right corner and the rest are rounding vertices going anticlockwise. Note the inveted Y-axis in CG. + // The first point of polygon buffer is left lower corner, second the crosspoint of + // thermal spoke sides, the third is upper right corner and the rest are rounding + // vertices going anticlockwise. Note the inveted Y-axis in CG. corners_buffer.push_back( wxPoint( -dx, -(aThermalGap / 4 + copper_thickness.y / 2) ) ); // Adds small miters to zone corners_buffer.push_back( wxPoint( -(dx - aThermalGap / 4), -copper_thickness.y / 2 ) ); // fill and spoke corner corners_buffer.push_back( wxPoint( -copper_thickness.x / 2, -copper_thickness.y / 2 ) ); @@ -852,13 +869,14 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, for( unsigned ic = 0; ic < corners_buffer.size(); ic++ ) { wxPoint cpos = corners_buffer[ic]; - RotatePoint( &cpos, angle ); // Rotate according to module orientation - cpos += PadShapePos; // Shift origin to position + RotatePoint( &cpos, angle ); // Rotate according to module orientation + cpos += PadShapePos; // Shift origin to position aCornerBuffer.push_back( CPolyPt( cpos.x, cpos.y ) ); } aCornerBuffer.back().end_contour = true; angle += 1800; // this is calculate hole 3 + if( angle >= 3600 ) angle -= 3600; } @@ -884,6 +902,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, aCornerBuffer.back().end_contour = true; angle += 1800; + if( angle >= 3600 ) angle -= 3600; } diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index 5604cf9ef4..995ae73135 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -16,7 +16,8 @@ * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER), * that store the list of schematic items that are concerned by the command to undo or redo * and is created for each command to undo (handle also a command to redo). - * each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or modified), + * each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or + * modified), * and has a pointer to a copy of this item, when this item has been modified * (the old values of parameters are therefore saved) * @@ -49,9 +50,11 @@ * => the copy of item(s) is moved in Undo list * * - add item(s) command - * => The list of item(s) is used to create a deleted list in undo list(same as a delete command) + * => The list of item(s) is used to create a deleted list in undo list(same as a delete + * command) * - * Some block operations that change items can be undoed without memorise items, just the coordiantes of the transform: + * Some block operations that change items can be undoed without memorise items, just the + * coordiantes of the transform: * move list of items (undo/redo is made by moving with the opposite move vector) * mirror (Y) and flip list of items (undo/redo is made by mirror or flip items) * so they are handled specifically. @@ -106,10 +109,6 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem ) } -/**************************************************************/ -void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) -/***************************************************************/ - /** * Function SwapData * Used in undo / redo command: @@ -119,6 +118,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) * @param aItem = the item * @param aImage = a copy of the item */ +void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) { if( aItem == NULL || aImage == NULL ) { @@ -173,16 +173,22 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) EXCHG( track->m_Width, image->m_Width ); EXCHG( track->m_Shape, image->m_Shape ); int atmp = track->GetDrillValue(); + if( track->IsDrillDefault() ) atmp = -1; + int itmp = image->GetDrillValue(); + if( image->IsDrillDefault() ) itmp = -1; + EXCHG(itmp, atmp ); + if( atmp > 0 ) track->SetDrillValue( atmp ); else track->SetDrillDefault(); + if( itmp > 0 ) image->SetDrillValue( itmp ); else @@ -203,11 +209,11 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) EXCHG( ( (TEXTE_PCB*) aItem )->m_VJustify, ( (TEXTE_PCB*) aImage )->m_VJustify ); break; - case TYPE_MIRE: - EXCHG( ( (MIREPCB*) aItem )->m_Pos, ( (MIREPCB*) aImage )->m_Pos ); - EXCHG( ( (MIREPCB*) aItem )->m_Width, ( (MIREPCB*) aImage )->m_Width ); - EXCHG( ( (MIREPCB*) aItem )->m_Size, ( (MIREPCB*) aImage )->m_Size ); - EXCHG( ( (MIREPCB*) aItem )->m_Shape, ( (MIREPCB*) aImage )->m_Shape ); + case PCB_TARGET_T: + EXCHG( ( (PCB_TARGET*) aItem )->m_Pos, ( (PCB_TARGET*) aImage )->m_Pos ); + EXCHG( ( (PCB_TARGET*) aItem )->m_Width, ( (PCB_TARGET*) aImage )->m_Width ); + EXCHG( ( (PCB_TARGET*) aItem )->m_Size, ( (PCB_TARGET*) aImage )->m_Size ); + EXCHG( ( (PCB_TARGET*) aItem )->m_Shape, ( (PCB_TARGET*) aImage )->m_Shape ); break; case TYPE_DIMENSION: @@ -217,8 +223,10 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) ( (DIMENSION*) aImage )->SetText( txt ); EXCHG( ( (DIMENSION*) aItem )->m_Width, ( (DIMENSION*) aImage )->m_Width ); EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Size, ( (DIMENSION*) aImage )->m_Text->m_Size ); - EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Thickness, ( (DIMENSION*) aImage )->m_Text->m_Thickness ); - EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Mirror, ( (DIMENSION*) aImage )->m_Text->m_Mirror ); + EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Thickness, + ( (DIMENSION*) aImage )->m_Text->m_Thickness ); + EXCHG( ( (DIMENSION*) aItem )->m_Text->m_Mirror, + ( (DIMENSION*) aImage )->m_Text->m_Mirror ); } break; @@ -230,13 +238,10 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) } -/************************************************************/ -BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem ) -/************************************************************/ - /* Routine to create a new copy of given struct. * The new object is not put in list (not linked) */ +BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem ) { if( aItem == NULL ) { @@ -295,11 +300,11 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem ) } break; - case TYPE_MIRE: + case PCB_TARGET_T: { - MIREPCB* new_mire = new MIREPCB( aItem->GetParent() ); - new_mire->Copy( (MIREPCB*) aItem ); - return new_mire; + PCB_TARGET* target = new PCB_TARGET( aItem->GetParent() ); + target->Copy( (PCB_TARGET*) aItem ); + return target; } break; @@ -413,6 +418,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, { BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii ); UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii ); + if( command == UR_UNSPECIFIED ) { command = aTypeCommand; @@ -461,7 +467,9 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); } else // Should not occur + { delete commandToUndo; + } } @@ -555,9 +563,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed default: { wxString msg; - msg.Printf( wxT( - "PutDataInPreviousState() error (unknown code %X)" ), - aList->GetPickedItemStatus( ii ) ); + msg.Printf( wxT( "PutDataInPreviousState() error (unknown code %X)" ), + aList->GetPickedItemStatus( ii ) ); wxMessageBox( msg ); } break; @@ -573,10 +580,6 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed } -/**********************************************************/ -void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event ) -/**********************************************************/ - /** * Function GetBoardFromUndoList * Undo the last edition: @@ -584,6 +587,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event ) * - Get an old version of the board state from Undo list * @return none */ +void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event ) { if( GetScreen()->GetUndoCommandCount() <= 0 ) return; @@ -630,10 +634,6 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event ) } -/***********************************************************************************/ -void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ) -/**********************************************************************************/ - /** * Function ClearUndoORRedoList * free the undo or redo list from List element @@ -645,11 +645,13 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount * items (commands stored in list) are removed from the beginning of the list. * So this function can be called to remove old commands */ +void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ) { if( aItemCount == 0 ) return; unsigned icnt = aList.m_CommandsList.size(); + if( aItemCount > 0 ) icnt = aItemCount; @@ -657,6 +659,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount { if( aList.m_CommandsList.size() == 0 ) break; + PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0]; aList.m_CommandsList.erase( aList.m_CommandsList.begin() ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 85624fba8d..efe493b69b 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -39,8 +39,7 @@ BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) : // progress m_NetInfo = new NETINFO_LIST( this ); // handle nets info list (name, // design constraints .. - m_NetInfo->BuildListOfNets(); // prepare pads and nets lists - // containers. + m_NetInfo->BuildListOfNets(); // prepare pads and nets lists containers. for( int layer = 0; layer < NB_COPPER_LAYERS; ++layer ) { @@ -54,8 +53,7 @@ BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) : // Should user eventually load a board from a disk file, then these // defaults // will get overwritten during load. - m_NetClasses.GetDefault()->SetDescription( - _( "This is the default net class." ) ); + m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) ); m_ViaSizeSelector = 0; m_TrackWidthSelector = 0; @@ -88,6 +86,7 @@ BOARD::~BOARD() delete m_NetInfo; } + /* * Function PushHightLight * save current hight light info for later use @@ -97,6 +96,7 @@ void BOARD::PushHightLight() m_hightLightPrevious = m_hightLight; } + /* * Function PopHightLight * retrieve a previously saved hight light info @@ -107,6 +107,7 @@ void BOARD::PopHightLight() m_hightLightPrevious.Clear(); } + /** * Function SetCurrentNetClass * Must be called after a netclass selection (or after a netclass parameter @@ -134,6 +135,7 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName ) lists_sizes_modified = true; m_ViasDimensionsList.push_back( viadim ); } + if( m_TrackWidthList.size() == 0 ) { lists_sizes_modified = true; @@ -145,14 +147,17 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName ) */ if( m_ViasDimensionsList[0].m_Diameter != netClass->GetViaDiameter() ) lists_sizes_modified = true; + m_ViasDimensionsList[0].m_Diameter = netClass->GetViaDiameter(); if( m_TrackWidthList[0] != netClass->GetTrackWidth() ) lists_sizes_modified = true; + m_TrackWidthList[0] = netClass->GetTrackWidth(); if( m_ViaSizeSelector >= m_ViasDimensionsList.size() ) m_ViaSizeSelector = m_ViasDimensionsList.size(); + if( m_TrackWidthSelector >= m_TrackWidthList.size() ) m_TrackWidthSelector = m_TrackWidthList.size(); @@ -169,9 +174,7 @@ int BOARD::GetBiggestClearanceValue() int clearance = m_NetClasses.GetDefault()->GetClearance(); //Read list of Net Classes - for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); - nc != m_NetClasses.end(); - nc++ ) + for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ ) { NETCLASS* netclass = nc->second; clearance = MAX( clearance, netclass->GetClearance() ); @@ -291,8 +294,7 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName ) { for( int i = 0; i < NB_COPPER_LAYERS; i++ ) { - if( i != aLayerIndex && IsLayerEnabled( i ) - && NameTemp == m_Layer[i].m_Name ) + if( i != aLayerIndex && IsLayerEnabled( i ) && NameTemp == m_Layer[i].m_Name ) return false; } @@ -314,6 +316,7 @@ LAYER_T BOARD::GetLayerType( int aLayerIndex ) const // in the layer sequence. if( IsLayerEnabled( aLayerIndex ) ) return m_Layer[aLayerIndex].m_Type; + return LT_SIGNAL; } @@ -330,6 +333,7 @@ bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType ) m_Layer[aLayerIndex].m_Type = aLayerType; return true; } + return false; } @@ -430,6 +434,7 @@ void BOARD::SetVisibleElements( int aMask ) void BOARD::SetVisibleAlls( ) { SetVisibleLayers( FULL_LAYERS ); + /* Call SetElementVisibility for each item, * to ensure specific calculations that can be needed by some items */ @@ -461,14 +466,15 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled ) // so the hide/show option is a per item selection if( IsElementVisible(RATSNEST_VISIBLE) ) { - for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ ) - m_FullRatsnest[ii].m_Status |= CH_VISIBLE; + for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ ) + m_FullRatsnest[ii].m_Status |= CH_VISIBLE; } else { for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ ) m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE; } + break; @@ -541,6 +547,7 @@ int BOARD::GetLayerColor( int aLayer ) return GetColorsSettings()->GetLayerColor( aLayer ); } + /** * Function IsModuleLayerVisible * expects either of the two layers on which a module can reside, and returns @@ -552,10 +559,8 @@ bool BOARD::IsModuleLayerVisible( int layer ) { if( layer==LAYER_N_FRONT ) return IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) ); - else if( layer==LAYER_N_BACK ) return IsElementVisible( PCB_VISIBLE(MOD_BK_VISIBLE) ); - else return true; } @@ -612,6 +617,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) m_Modules.PushBack( (MODULE*) aBoardItem ); else m_Modules.PushFront( (MODULE*) aBoardItem ); + aBoardItem->SetParent( this ); // Because the list of pads has changed, reset the status @@ -624,11 +630,12 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) case TYPE_DRAWSEGMENT: case TYPE_TEXTE: case TYPE_EDGE_MODULE: - case TYPE_MIRE: + case PCB_TARGET_T: if( aControl & ADD_APPEND ) m_Drawings.PushBack( aBoardItem ); else m_Drawings.PushFront( aBoardItem ); + aBoardItem->SetParent( this ); break; @@ -636,9 +643,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) default: { wxString msg; - msg.Printf( - wxT( "BOARD::Add() needs work: BOARD_ITEM type (%d) not handled" ), - aBoardItem->Type() ); + msg.Printf( wxT( "BOARD::Add() needs work: BOARD_ITEM type (%d) not handled" ), + aBoardItem->Type() ); wxFAIL_MSG( msg ); } break; @@ -697,7 +703,7 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) case TYPE_DRAWSEGMENT: case TYPE_TEXTE: case TYPE_EDGE_MODULE: - case TYPE_MIRE: + case PCB_TARGET_T: m_Drawings.Remove( aBoardItem ); break; @@ -774,6 +780,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) area = item->GetBoundingBox(); else area.Merge( item->GetBoundingBox() ); + hasItems = true; } @@ -786,6 +793,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) area = module->GetBoundingBox(); else area.Merge( module->GetBoundingBox() ); + hasItems = true; } @@ -796,6 +804,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) area = track->GetBoundingBox(); else area.Merge( track->GetBoundingBox() ); + hasItems = true; } @@ -806,6 +815,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) area = track->GetBoundingBox(); else area.Merge( track->GetBoundingBox() ); + hasItems = true; } @@ -818,6 +828,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) area = aZone->GetBoundingBox(); else area.Merge( aZone->GetBoundingBox() ); + area.Merge( aZone->GetBoundingBox() ); hasItems = true; } @@ -836,7 +847,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) area.SetOrigin( -m_PcbFrame->GetScreen()->ReturnPageSize().x / 2, -m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 ); area.SetEnd( m_PcbFrame->GetScreen()->ReturnPageSize().x / 2, - m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 ); + m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 ); } } @@ -858,6 +869,7 @@ void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame ) int viasCount = 0; int trackSegmentsCount = 0; + for( BOARD_ITEM* item = m_Track; item; item = item->Next() ) { if( item->Type() == TYPE_VIA ) @@ -914,6 +926,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, while( !done ) { stype = *p; + switch( stype ) { case TYPE_PCB: @@ -960,7 +973,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, case TYPE_DRAWSEGMENT: case TYPE_TEXTE: case TYPE_DIMENSION: - case TYPE_MIRE: + case PCB_TARGET_T: result = IterateForward( m_Drawings, inspector, testData, p ); // skip over any types handled in the above call. @@ -971,7 +984,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, case TYPE_DRAWSEGMENT: case TYPE_TEXTE: case TYPE_DIMENSION: - case TYPE_MIRE: + case PCB_TARGET_T: continue; default: @@ -1041,6 +1054,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, for( unsigned i = 0; iVisit( inspector, testData, p ); + if( result == SEARCH_QUIT ) break; } @@ -1053,9 +1067,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, // TYPE_ZONE_CONTAINER are in the m_ZoneDescriptorList std::vector for( unsigned i = 0; i< m_ZoneDescriptorList.size(); ++i ) { - result = m_ZoneDescriptorList[i]->Visit( inspector, - testData, - p ); + result = m_ZoneDescriptorList[i]->Visit( inspector, testData, p ); + if( result == SEARCH_QUIT ) break; } @@ -1108,7 +1121,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, * D_PAD* pad = (D_PAD*) item; * if( pad->HitTest( refPos ) ) * { - * if( layer_mask & pad->m_Masque_Layer ) + * if( layer_mask & pad->m_layerMask ) * { * found = item; * return SEARCH_QUIT; @@ -1211,6 +1224,7 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const for( int ii = 1; ii < ncount; ii++ ) { NETINFO_ITEM* item = m_NetInfo->GetNetItem( ii ); + if( item && item->GetNetname() == aNetname ) { return item; @@ -1225,6 +1239,7 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const // NETINFO_LIST::Build_Pads_Full_List() int imax = ncount - 1; int index = imax; + while( ncount > 0 ) { int ii = ncount; @@ -1234,26 +1249,34 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const ncount++; NETINFO_ITEM* item = m_NetInfo->GetNetItem( index ); + if( item == NULL ) return NULL; + int icmp = item->GetNetname().Cmp( aNetname ); if( icmp == 0 ) // found ! { return item; } + if( icmp < 0 ) // must search after item { index += ncount; + if( index > imax ) index = imax; + continue; } + if( icmp > 0 ) // must search before item { index -= ncount; + if( index < 1 ) index = 1; + continue; } } @@ -1281,6 +1304,7 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const found = module; return SEARCH_QUIT; } + return SEARCH_CONTINUE; } } inspector; @@ -1310,8 +1334,7 @@ static bool s_SortByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b ) * (i.e. leave the sort by net names) * @return int - net names count. */ -int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, - bool aSortbyPadsCount ) +int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount ) { if( m_NetInfo->GetCount() == 0 ) return 0; @@ -1362,18 +1385,18 @@ bool BOARD::Save( FILE* aFile ) const { case TYPE_TEXTE: case TYPE_DRAWSEGMENT: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DIMENSION: if( !item->Save( aFile ) ) goto out; + break; default: // future: throw exception here #if defined(DEBUG) - printf( "BOARD::Save() ignoring m_Drawings type %d\n", - item->Type() ); + printf( "BOARD::Save() ignoring m_Drawings type %d\n", item->Type() ); #endif break; } @@ -1391,6 +1414,7 @@ bool BOARD::Save( FILE* aFile ) const // save the zones fprintf( aFile, "$ZONE\n" ); + for( item = m_Zone; item; item = item->Next() ) if( !item->Save( aFile ) ) goto out; @@ -1427,6 +1451,7 @@ void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode for( int ii = 0; ii < GetAreaCount(); ii++ ) { ZONE_CONTAINER* edge_zone = GetArea( ii ); + if( (aLayer < 0) || ( aLayer == edge_zone->GetLayer() ) ) edge_zone->Draw( panel, aDC, aDrawMode ); } @@ -1445,6 +1470,7 @@ void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, for( int ii = 0; ii < GetAreaCount(); ii++ ) { ZONE_CONTAINER* edge_zone = GetArea( ii ); + if( (aLayer < 0) || ( aLayer == edge_zone->GetLayer() ) ) edge_zone->DrawFilledArea( panel, aDC, aDrawMode ); } @@ -1469,6 +1495,7 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, { if( aEndLayer < 0 ) aEndLayer = aStartLayer; + if( aEndLayer < aStartLayer ) EXCHG( aEndLayer, aStartLayer ); @@ -1476,11 +1503,14 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, { ZONE_CONTAINER* area = m_ZoneDescriptorList[ia]; int layer = area->GetLayer(); + if( (layer < aStartLayer) || (layer > aEndLayer) ) continue; + if( area->GetState( BUSY ) ) // In locate functions we must skip // tagged items with BUSY flag set. continue; + if( area->HitTestFilledArea( aRefPos ) ) return area; } @@ -1514,10 +1544,10 @@ int BOARD::SetAreasNetCodesFromNetNames( void ) continue; } - if( GetArea( ii )->GetNet() != 0 ) // i.e. if this zone is - // connected to a net + if( GetArea( ii )->GetNet() != 0 ) // i.e. if this zone is connected to a net { const NETINFO_ITEM* net = FindNet( GetArea( ii )->m_Netname ); + if( net ) { GetArea( ii )->SetNet( net->GetNet() ); @@ -1555,6 +1585,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) // specialization of the output: NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Modules; + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); @@ -1562,6 +1593,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Drawings; + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); @@ -1569,6 +1601,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Track; + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); @@ -1576,6 +1609,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Zone; + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); @@ -1590,6 +1624,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) */ p = (BOARD_ITEM*) m_Son; + for( ; p; p = p->Next() ) { p->Show( nestLevel + 1, os ); diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 854796669c..6bcbf40485 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -842,6 +842,7 @@ public: { if( (unsigned) index < m_ZoneDescriptorList.size() ) return m_ZoneDescriptorList[index]; + return NULL; } @@ -879,8 +880,8 @@ public: /** * Function AddArea * Add an empty copper area to board areas list - * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful in undo commands) - * can be NULL + * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful + * in undo commands) can be NULL * @param aNetcode = the necode of the copper area (0 = no net) * @param aLayer = the layer of area * @param aStartPointPosition = position of the first point of the polygon outline of this area @@ -924,8 +925,8 @@ public: * Function ClipAreaPolygon * Process an area that has been modified, by clipping its polygon against itself. * This may change the number and order of copper areas in the net. - * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful in undo commands) - * can be NULL + * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful + * in undo commands) can be NULL * @param aCurrArea = the zone to process * @param bMessageBoxInt == true, shows message when clipping occurs. * @param bMessageBoxArc == true, shows message when clipping can't be done due to arcs. @@ -940,7 +941,7 @@ public: ZONE_CONTAINER* aCurrArea, bool bMessageBoxArc, bool bMessageBoxInt, - bool bRetainArcs = TRUE ); + bool bRetainArcs = true ); /** * Process an area that has been modified, by clipping its polygon against @@ -949,7 +950,7 @@ public: * @param aModifiedZonesList = a PICKED_ITEMS_LIST * where to store deleted or added areas * (useful in undo commands. Can be NULL * @param modified_area = area to test - * @param bMessageBoxInt : if TRUE, shows message boxes when clipping occurs. + * @param bMessageBoxInt : if true, shows message boxes when clipping occurs. * @param bMessageBoxArc if true, shows message when clipping can't be done due to arcs. * @return : * -1 if arcs intersect other sides, so polygon can't be clipped diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 4d48346f73..b37ef8eb51 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -108,8 +108,9 @@ bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader ) while( aReader->ReadLine() ) { Line = aReader->Line(); + if( strnicmp( Line, "$EndDIMENSION", 4 ) == 0 ) - return TRUE; + return true; if( Line[0] == 'V' ) { @@ -125,6 +126,7 @@ bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader ) if( layer < FIRST_NO_COPPER_LAYER ) layer = FIRST_NO_COPPER_LAYER; + if( layer > LAST_NO_COPPER_LAYER ) layer = LAST_NO_COPPER_LAYER; @@ -221,7 +223,7 @@ bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader ) } } - return FALSE; + return false; } @@ -275,8 +277,10 @@ void DIMENSION::Rotate(const wxPoint& aRotCentre, int aAngle) RotatePoint( &m_Text->m_Pos, aRotCentre, aAngle ); m_Text->m_Orient += aAngle; + if( m_Text->m_Orient >= 3600 ) m_Text->m_Orient -= 3600; + if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient <2700 ) ) m_Text->m_Orient -= 1800; @@ -323,8 +327,10 @@ void DIMENSION::Mirror(const wxPoint& axis_pos) INVERT( m_Pos.y ); INVERT( m_Text->m_Pos.y ); INVERT_ANGLE( m_Text->m_Orient ); + if( m_Text->m_Orient >= 3600 ) m_Text->m_Orient -= 3600; + if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient < 2700 ) ) m_Text->m_Orient -= 1800; @@ -456,10 +462,13 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) if( TraitG_ox > Barre_ox ) hx = -hx; + if( TraitG_ox == Barre_ox ) hx = 0; + if( TraitG_oy > Barre_oy ) hy = -hy; + if( TraitG_oy == Barre_oy ) hy = 0; @@ -503,16 +512,17 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) TraitD_fy = Barre_fy + hy; /* Calculate the better text position and orientation: */ - m_Pos.x = m_Text->m_Pos.x - = (Barre_fx + TraitG_fx) / 2; - m_Pos.y = m_Text->m_Pos.y - = (Barre_fy + TraitG_fy) / 2; + m_Pos.x = m_Text->m_Pos.x = (Barre_fx + TraitG_fx) / 2; + m_Pos.y = m_Text->m_Pos.y = (Barre_fy + TraitG_fy) / 2; m_Text->m_Orient = -(int) (angle * 1800 / M_PI); + if( m_Text->m_Orient < 0 ) m_Text->m_Orient += 3600; + if( m_Text->m_Orient >= 3600 ) m_Text->m_Orient -= 3600; + if( (m_Text->m_Orient > 900) && (m_Text->m_Orient <2700) ) m_Text->m_Orient -= 1800; @@ -537,6 +547,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxP m_Text->Draw( panel, DC, mode_color, offset ); BOARD * brd = GetBoard( ); + if( brd->IsLayerVisible( m_Layer ) == false ) return; @@ -734,6 +745,7 @@ bool DIMENSION::HitTest( EDA_RECT& refArea ) { if( refArea.Contains( m_Pos ) ) return true; + return false; } diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 8d98652228..661d9a675f 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -109,7 +109,7 @@ bool DRAWSEGMENT::ReadDrawSegmentDescr( LINE_READER* aReader ) Line = aReader->Line(); if( strnicmp( Line, "$End", 4 ) == 0 ) - return TRUE; /* End of description */ + return true; /* End of description */ if( Line[0] == 'P' ) { @@ -175,7 +175,7 @@ bool DRAWSEGMENT::ReadDrawSegmentDescr( LINE_READER* aReader ) } } - return FALSE; + return false; } @@ -227,9 +227,9 @@ MODULE* DRAWSEGMENT::GetParentModule() const void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset ) { int ux0, uy0, dx, dy; - int l_piste; + int l_trace; int color, mode; - int rayon; + int radius; BOARD * brd = GetBoard( ); @@ -239,7 +239,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx color = brd->GetLayerColor( GetLayer() ); GRSetDrawMode( DC, draw_mode ); - l_piste = m_Width >> 1; /* half trace width */ + l_trace = m_Width >> 1; /* half trace width */ // Line start point or Circle and Arc center ux0 = m_Start.x + aOffset.x; @@ -250,34 +250,37 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx dy = m_End.y + aOffset.y; mode = DisplayOpt.DisplayDrawItems; + if( m_Flags & FORCE_SKETCH ) mode = SKETCH; - if( l_piste < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) ) + if( l_trace < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) ) mode = FILAIRE; switch( m_Shape ) { case S_CIRCLE: - rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + radius = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + if( mode == FILAIRE ) { - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius, color ); } else if( mode == SKETCH ) { - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, color ); - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius - l_trace, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius + l_trace, color ); } else { - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, m_Width, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius, m_Width, color ); } + break; case S_ARC: int StAngle, EndAngle; - rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + radius = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); StAngle = (int) ArcTangente( dy - uy0, dx - ux0 ); EndAngle = StAngle + m_Angle; @@ -295,19 +298,19 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx if( mode == FILAIRE ) GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon, color ); + radius, color ); else if( mode == SKETCH ) { GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon - l_piste, color ); + radius - l_trace, color ); GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon + l_piste, color ); + radius + l_trace, color ); } else { GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon, m_Width, color ); + radius, m_Width, color ); } break; case S_CURVE: @@ -329,15 +332,17 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx else { GRFillCSegm( &panel->m_ClipBox, DC, - m_BezierPoints[i].x, m_BezierPoints[i].y, - m_BezierPoints[i-1].x, m_BezierPoints[i-1].y, + m_BezierPoints[i].x, m_BezierPoints[i].y, + m_BezierPoints[i-1].x, m_BezierPoints[i-1].y, m_Width, color ); } } break; default: if( mode == FILAIRE ) + { GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color ); + } else if( mode == SKETCH ) { GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, @@ -348,6 +353,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, m_Width, color ); } + break; } } @@ -388,6 +394,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame ) default: frame->AppendMsgPanel( shape, _( "Segment" ), RED ); } + wxString start; start << GetStart(); @@ -396,8 +403,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( start, end, DARKGREEN ); - frame->AppendMsgPanel( _( "Layer" ), - board->GetLayerName( m_Layer ), DARKBROWN ); + frame->AppendMsgPanel( _( "Layer" ), board->GetLayerName( m_Layer ), DARKBROWN ); valeur_param( (unsigned) m_Width, msg ); frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN ); @@ -444,6 +450,7 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const if( ii == 0 ) p_end = pt; + bbox.m_Pos.x = MIN( bbox.m_Pos.x, pt.x ); bbox.m_Pos.y = MIN( bbox.m_Pos.y, pt.y ); p_end.x = MAX( p_end.x, pt.x ); @@ -471,10 +478,10 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aRefPos ) case S_CIRCLE: case S_ARC: { - int rayon = GetRadius(); + int radius = GetRadius(); int dist = (int) hypot( (double) relPos.x, (double) relPos.y ); - if( abs( rayon - dist ) <= ( m_Width / 2 ) ) + if( abs( radius - dist ) <= ( m_Width / 2 ) ) { if( m_Shape == S_CIRCLE ) return true; @@ -498,8 +505,7 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aRefPos ) case S_CURVE: for( unsigned int i= 1; i < m_BezierPoints.size(); i++) { - if( TestSegmentHit( aRefPos,m_BezierPoints[i-1], - m_BezierPoints[i-1], m_Width / 2 ) ) + if( TestSegmentHit( aRefPos,m_BezierPoints[i-1], m_BezierPoints[i-1], m_Width / 2 ) ) return true; } break; @@ -527,6 +533,7 @@ bool DRAWSEGMENT::HitTest( EDA_RECT& refArea ) // Text if area intersects the circle: EDA_RECT area = refArea; area.Inflate( radius ); + if( area.Contains( m_Start ) ) return true; } diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index aeed51852b..9da227c3d1 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -77,7 +77,7 @@ void EDGE_MODULE::SetDrawCoord() */ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& offset ) { - int ux0, uy0, dx, dy, rayon, StAngle, EndAngle; + int ux0, uy0, dx, dy, radius, StAngle, EndAngle; int color, type_trace; int typeaff; PCB_BASE_FRAME* frame; @@ -105,9 +105,11 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx GRSetDrawMode( DC, draw_mode ); typeaff = frame->m_DisplayModEdge; + if( m_Layer <= LAST_COPPER_LAYER ) { typeaff = frame->m_DisplayPcbTrackFill; + if( !typeaff ) typeaff = SKETCH; } @@ -125,53 +127,53 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx else // SKETCH Mode GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, m_Width, color ); + break; case S_CIRCLE: - rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + radius = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + if( typeaff == FILAIRE ) { - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius, color ); } else { if( typeaff == FILLED ) { - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, - m_Width, color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius, m_Width, color ); } else // SKETCH Mode { - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, - rayon + (m_Width / 2), color ); - GRCircle( &panel->m_ClipBox, DC, ux0, uy0, - rayon - (m_Width / 2), color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius + (m_Width / 2), color ); + GRCircle( &panel->m_ClipBox, DC, ux0, uy0, radius - (m_Width / 2), color ); } } + break; case S_ARC: - rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); + radius = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) ); StAngle = (int) ArcTangente( dy - uy0, dx - ux0 ); EndAngle = StAngle + m_Angle; + if( StAngle > EndAngle ) EXCHG( StAngle, EndAngle ); + if( typeaff == FILAIRE ) { - GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon, color ); + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, radius, color ); } else if( typeaff == FILLED ) { - GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, - m_Width, color ); + GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, radius, m_Width, color ); } else // SKETCH Mode { GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon + (m_Width / 2), color ); + radius + (m_Width / 2), color ); GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, - rayon - (m_Width / 2), color ); + radius - (m_Width / 2), color ); } break; @@ -190,8 +192,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx pt += module->m_Pos - offset; } - GRPoly( &panel->m_ClipBox, DC, points.size(), &points[0], - TRUE, m_Width, color, color ); + GRPoly( &panel->m_ClipBox, DC, points.size(), &points[0], true, m_Width, color, color ); break; } } @@ -208,34 +209,27 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) return; BOARD* board = (BOARD*) module->GetParent(); + if( !board ) return; frame->ClearMsgPanel(); frame->AppendMsgPanel( _( "Graphic Item" ), wxEmptyString, DARKCYAN ); - - frame->AppendMsgPanel( _( "Module" ), module->m_Reference->m_Text, - DARKCYAN ); + frame->AppendMsgPanel( _( "Module" ), module->m_Reference->m_Text, DARKCYAN ); frame->AppendMsgPanel( _( "Value" ), module->m_Value->m_Text, BLUE ); msg.Printf( wxT( "%8.8lX" ), module->m_TimeStamp ); frame->AppendMsgPanel( _( "TimeStamp" ), msg, BROWN ); - - frame->AppendMsgPanel( _( "Mod Layer" ), - board->GetLayerName( module->GetLayer() ), RED ); - - frame->AppendMsgPanel( _( "Seg Layer" ), - board->GetLayerName( GetLayer() ), RED ); + frame->AppendMsgPanel( _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ), RED ); + frame->AppendMsgPanel( _( "Seg Layer" ), board->GetLayerName( GetLayer() ), RED ); valeur_param( m_Width, msg ); frame->AppendMsgPanel( _( "Width" ), msg, BLUE ); } -/*******************************************/ bool EDGE_MODULE::Save( FILE* aFile ) const -/*******************************************/ { int ret = -1; @@ -271,8 +265,7 @@ bool EDGE_MODULE::Save( FILE* aFile ) const m_Width, m_Layer ); for( unsigned i = 0; iReadLine() ) { Buf = aReader->Line(); + if( strncmp( Buf, "Dl", 2 ) != 0 ) { error = 1; @@ -398,15 +393,18 @@ int EDGE_MODULE::ReadDescr( LINE_READER* aReader ) // Check for a reasonable width: if( m_Width <= 1 ) m_Width = 1; + if( m_Width > MAX_WIDTH ) m_Width = MAX_WIDTH; // Check for a reasonable layer: // m_Layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints // can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed. - // @todo: changes use of EDGE_MODULE these footprints and allows only m_Layer >= FIRST_NON_COPPER_LAYER + // @todo: changes use of EDGE_MODULE these footprints and allows only + // m_Layer >= FIRST_NON_COPPER_LAYER if( (m_Layer < 0) || (m_Layer > LAST_NON_COPPER_LAYER) ) m_Layer = SILKSCREEN_N_FRONT; + return error; } diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index dccc74522f..62ff5e38e6 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -16,20 +16,20 @@ #include "richio.h" -MIREPCB::MIREPCB( BOARD_ITEM* aParent ) : - BOARD_ITEM( aParent, TYPE_MIRE ) +PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) : + BOARD_ITEM( aParent, PCB_TARGET_T ) { m_Shape = 0; m_Size = 5000; } -MIREPCB::~MIREPCB() +PCB_TARGET::~PCB_TARGET() { } -void MIREPCB::Copy( MIREPCB* source ) +void PCB_TARGET::Copy( PCB_TARGET* source ) { m_Layer = source->m_Layer; m_Width = source->m_Width; @@ -42,37 +42,41 @@ void MIREPCB::Copy( MIREPCB* source ) /* Read the description from the PCB file. */ -bool MIREPCB::ReadMirePcbDescr( LINE_READER* aReader ) +bool PCB_TARGET::ReadMirePcbDescr( LINE_READER* aReader ) { char* Line; while( aReader->ReadLine() ) { Line = aReader->Line(); + if( strnicmp( Line, "$End", 4 ) == 0 ) - return TRUE; + return true; + if( Line[0] == 'P' ) { sscanf( Line + 2, " %X %d %d %d %d %d %lX", &m_Shape, &m_Layer, &m_Pos.x, &m_Pos.y, &m_Size, &m_Width, &m_TimeStamp ); + if( m_Layer < FIRST_NO_COPPER_LAYER ) m_Layer = FIRST_NO_COPPER_LAYER; + if( m_Layer > LAST_NO_COPPER_LAYER ) m_Layer = LAST_NO_COPPER_LAYER; } } - return FALSE; + return false; } -bool MIREPCB::Save( FILE* aFile ) const +bool PCB_TARGET::Save( FILE* aFile ) const { bool rc = false; - if( fprintf( aFile, "$MIREPCB\n" ) != sizeof("$MIREPCB\n")-1 ) + if( fprintf( aFile, "$PCB_TARGET\n" ) != sizeof("$PCB_TARGET\n")-1 ) goto out; fprintf( aFile, "Po %X %d %d %d %d %d %8.8lX\n", @@ -80,7 +84,7 @@ bool MIREPCB::Save( FILE* aFile ) const m_Pos.x, m_Pos.y, m_Size, m_Width, m_TimeStamp ); - if( fprintf( aFile, "$EndMIREPCB\n" ) != sizeof("$EndMIREPCB\n")-1 ) + if( fprintf( aFile, "$EndPCB_TARGET\n" ) != sizeof("$EndPCB_TARGET\n")-1 ) goto out; rc = true; @@ -92,13 +96,13 @@ out: -/* Draw MIREPCB object: 2 segments + 1 circle +/* Draw PCB_TARGET object: 2 segments + 1 circle * The circle radius is half the radius of the target * 2 lines have length the diameter of the target */ -void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoint& offset ) +void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoint& offset ) { - int rayon, ox, oy, gcolor, width; + int radius, ox, oy, gcolor, width; int dx1, dx2, dy1, dy2; int typeaff; @@ -106,10 +110,11 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi oy = m_Pos.y + offset.y; BOARD * brd = GetBoard( ); + if( brd->IsLayerVisible( m_Layer ) == false ) return; - gcolor = brd->GetLayerColor(m_Layer); + gcolor = brd->GetLayerColor( m_Layer ); GRSetDrawMode( DC, mode_color ); typeaff = DisplayOpt.DisplayDrawItems; @@ -118,7 +123,7 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi if( DC->LogicalToDeviceXRel( width ) < 2 ) typeaff = FILAIRE; - rayon = m_Size / 4; + radius = m_Size / 4; switch( typeaff ) { @@ -126,25 +131,25 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi width = 0; case FILLED: - GRCircle( &panel->m_ClipBox, DC, ox, oy, rayon, width, gcolor ); + GRCircle( &panel->m_ClipBox, DC, ox, oy, radius, width, gcolor ); break; case SKETCH: - GRCircle( &panel->m_ClipBox, DC, ox, oy, rayon + (width / 2), gcolor ); - GRCircle( &panel->m_ClipBox, DC, ox, oy, rayon - (width / 2), gcolor ); + GRCircle( &panel->m_ClipBox, DC, ox, oy, radius + (width / 2), gcolor ); + GRCircle( &panel->m_ClipBox, DC, ox, oy, radius - (width / 2), gcolor ); break; } - rayon = m_Size / 2; - dx1 = rayon; + radius = m_Size / 2; + dx1 = radius; dy1 = 0; dx2 = 0; - dy2 = rayon; + dy2 = radius; if( m_Shape ) /* Form X */ { - dx1 = dy1 = ( rayon * 7 ) / 5; + dx1 = dy1 = ( radius * 7 ) / 5; dx2 = dx1; dy2 = -dy1; } @@ -153,19 +158,13 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi { case FILAIRE: case FILLED: - GRLine( &panel->m_ClipBox, DC, ox - dx1, oy - dy1, - ox + dx1, oy + dy1, width, gcolor ); - GRLine( &panel->m_ClipBox, DC, ox - dx2, oy - dy2, - ox + dx2, oy + dy2, width, gcolor ); + GRLine( &panel->m_ClipBox, DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor ); + GRLine( &panel->m_ClipBox, DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor ); break; case SKETCH: - GRCSegm( &panel->m_ClipBox, DC, ox - dx1, oy - dy1, - ox + dx1, oy + dy1, - width, gcolor ); - GRCSegm( &panel->m_ClipBox, DC, ox - dx2, oy - dy2, - ox + dx2, oy + dy2, - width, gcolor ); + GRCSegm( &panel->m_ClipBox, DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor ); + GRCSegm( &panel->m_ClipBox, DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor ); break; } } @@ -177,12 +176,12 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi * @param refPos A wxPoint to test * @return bool - true if a hit, else false */ -bool MIREPCB::HitTest( const wxPoint& refPos ) +bool PCB_TARGET::HitTest( const wxPoint& refPos ) { int dX = refPos.x - m_Pos.x; int dY = refPos.y - m_Pos.y; - int rayon = m_Size / 2; - return abs( dX ) <= rayon && abs( dY ) <= rayon; + int radius = m_Size / 2; + return abs( dX ) <= radius && abs( dY ) <= radius; } @@ -192,10 +191,11 @@ bool MIREPCB::HitTest( const wxPoint& refPos ) * @param refArea : the given EDA_RECT * @return bool - true if a hit, else false */ -bool MIREPCB::HitTest( EDA_RECT& refArea ) +bool PCB_TARGET::HitTest( EDA_RECT& refArea ) { if( refArea.Contains( m_Pos ) ) return true; + return false; } @@ -206,7 +206,7 @@ bool MIREPCB::HitTest( EDA_RECT& refArea ) * @param aRotCentre - the rotation point. * @param aAngle - the rotation angle in 0.1 degree. */ -void MIREPCB::Rotate(const wxPoint& aRotCentre, int aAngle) +void PCB_TARGET::Rotate(const wxPoint& aRotCentre, int aAngle) { RotatePoint( &m_Pos, aRotCentre, aAngle ); } @@ -217,14 +217,14 @@ void MIREPCB::Rotate(const wxPoint& aRotCentre, int aAngle) * Flip this object, i.e. change the board side for this object * @param aCentre - the rotation point. */ -void MIREPCB::Flip(const wxPoint& aCentre ) +void PCB_TARGET::Flip(const wxPoint& aCentre ) { m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); SetLayer( ChangeSideNumLayer( GetLayer() ) ); } -EDA_RECT MIREPCB::GetBoundingBox() const +EDA_RECT PCB_TARGET::GetBoundingBox() const { EDA_RECT bBox; bBox.SetX( m_Pos.x - m_Size/2 ); @@ -236,7 +236,7 @@ EDA_RECT MIREPCB::GetBoundingBox() const } -wxString MIREPCB::GetSelectMenuText() const +wxString PCB_TARGET::GetSelectMenuText() const { wxString text; wxString msg; diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index aafb78e73e..390eb07399 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -1,5 +1,5 @@ /****************************************************/ -/* MIREPCB class definition. (targets for photos) */ +/* PCB_TARGET class definition. (targets for photos) */ /****************************************************/ #ifndef MIRE_H @@ -9,7 +9,7 @@ #include "richio.h" -class MIREPCB : public BOARD_ITEM +class PCB_TARGET : public BOARD_ITEM { public: int m_Width; @@ -18,11 +18,11 @@ public: int m_Size; public: - MIREPCB( BOARD_ITEM* aParent ); - ~MIREPCB(); + PCB_TARGET( BOARD_ITEM* aParent ); + ~PCB_TARGET(); - MIREPCB* Next() const { return (MIREPCB*) Pnext; } - MIREPCB* Back() const { return (MIREPCB*) Pnext; } + PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; } + PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; } wxPoint& GetPosition() { @@ -65,7 +65,7 @@ public: bool ReadMirePcbDescr( LINE_READER* aReader ); - void Copy( MIREPCB* source ); + void Copy( PCB_TARGET* source ); void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset ); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 0b227f9654..0aecfdf49c 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -113,16 +113,17 @@ void MODULE::Copy( MODULE* aModule ) /* Copy auxiliary data: Pads */ m_Pads.DeleteAll(); + for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() ) { D_PAD* newpad = new D_PAD( this ); newpad->Copy( pad ); - m_Pads.PushBack( newpad ); } /* Copy auxiliary data: Drawings */ m_Drawings.DeleteAll(); + for( BOARD_ITEM* item = aModule->m_Drawings; item; item = item->Next() ) { switch( item->Type() ) @@ -152,15 +153,18 @@ void MODULE::Copy( MODULE* aModule ) // Ensure there is one (or more) item in m_3D_Drawings m_3D_Drawings.PushBack( new S3D_MASTER( this ) ); // push a void item + for( S3D_MASTER* item = aModule->m_3D_Drawings; item; item = item->Next() ) { if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes. continue; + S3D_MASTER* t3d = m_3D_Drawings; + if( t3d && t3d->m_Shape3DName.IsEmpty() ) // The first entry can - // exist, but is empty : - // use it. + { // exist, but is empty : use it. t3d->Copy( item ); + } else { t3d = new S3D_MASTER( this ); @@ -297,12 +301,16 @@ bool MODULE::Save( FILE* aFile ) const fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp ); fprintf( aFile, "AR %s\n", TO_UTF8( m_Path ) ); fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 ); + if( m_LocalSolderMaskMargin != 0 ) fprintf( aFile, ".SolderMask %d\n", m_LocalSolderMaskMargin ); + if( m_LocalSolderPasteMargin != 0 ) fprintf( aFile, ".SolderPaste %d\n", m_LocalSolderPasteMargin ); + if( m_LocalSolderPasteMarginRatio != 0 ) fprintf( aFile, ".SolderPasteRatio %g\n", m_LocalSolderPasteMarginRatio ); + if( m_LocalClearance != 0 ) fprintf( aFile, ".LocalClearance %d\n", m_LocalClearance ); @@ -310,10 +318,13 @@ bool MODULE::Save( FILE* aFile ) const if( m_Attributs != MOD_DEFAULT ) { fprintf( aFile, "At " ); + if( m_Attributs & MOD_CMS ) fprintf( aFile, "SMD " ); + if( m_Attributs & MOD_VIRTUAL ) fprintf( aFile, "VIRTUAL " ); + fprintf( aFile, "\n" ); } @@ -334,6 +345,7 @@ bool MODULE::Save( FILE* aFile ) const case TYPE_EDGE_MODULE: if( !item->Save( aFile ) ) goto out; + break; default: @@ -422,11 +434,13 @@ int MODULE::Read_3D_Descr( LINE_READER* aReader ) while( aReader->ReadLine() ) { Line = aReader->Line(); + switch( Line[0] ) { case '$': if( Line[1] == 'E' ) return 0; + return 1; case 'N': // Shape File Name @@ -484,6 +498,7 @@ int MODULE::ReadDescr( LINE_READER* aReader ) { if( Line[1] == 'E' ) break; + if( Line[1] == 'P' ) { D_PAD* pad = new D_PAD( this ); @@ -495,6 +510,7 @@ int MODULE::ReadDescr( LINE_READER* aReader ) m_Pads.PushBack( pad ); continue; } + if( Line[1] == 'S' ) Read_3D_Descr( aReader ); } @@ -517,10 +533,13 @@ int MODULE::ReadDescr( LINE_READER* aReader ) &m_LastEdit_Time, &m_TimeStamp, BufCar1 ); m_ModuleStatus = 0; + if( BufCar1[0] == 'F' ) SetLocked( true ); + if( BufCar1[1] == 'P' ) m_ModuleStatus |= MODULE_is_PLACED; + break; case 'L': /* Li = read the library name of the footprint */ @@ -539,15 +558,20 @@ int MODULE::ReadDescr( LINE_READER* aReader ) sscanf( PtLine, " %X %X", &itmp1, &itmp2 ); m_CntRot180 = itmp2 & 0x0F; + if( m_CntRot180 > 10 ) m_CntRot180 = 10; m_CntRot90 = itmp1 & 0x0F; + if( m_CntRot90 > 10 ) m_CntRot90 = 0; + itmp1 = (itmp1 >> 4) & 0x0F; + if( itmp1 > 10 ) itmp1 = 0; + m_CntRot90 |= itmp1 << 4; break; @@ -557,21 +581,25 @@ int MODULE::ReadDescr( LINE_READER* aReader ) /* At = (At)tributes of module */ if( strstr( PtLine, "SMD" ) ) m_Attributs |= MOD_CMS; + if( strstr( PtLine, "VIRTUAL" ) ) m_Attributs |= MOD_VIRTUAL; } + if( Line[1] == 'R' ) { // alternate reference, e.g. /478C2408/478AD1B6 sscanf( PtLine, " %s", BufLine ); m_Path = FROM_UTF8( BufLine ); } + break; case 'T': /* Read a footprint text description (ref, value, or * drawing */ TEXTE_MODULE * textm; sscanf( Line + 1, "%d", &itmp1 ); + if( itmp1 == TEXT_is_REFERENCE ) textm = m_Reference; else if( itmp1 == TEXT_is_VALUE ) @@ -609,6 +637,7 @@ int MODULE::ReadDescr( LINE_READER* aReader ) m_LocalSolderPasteMarginRatio = atof( Line + 18 ); else if( strnicmp( Line, ".LocalClearance ", 16 ) == 0 ) m_LocalClearance = atoi( Line + 16 ); + break; default: @@ -617,12 +646,12 @@ int MODULE::ReadDescr( LINE_READER* aReader ) } /* Recalculate the bounding box */ - Set_Rectangle_Encadrement(); + CalculateBoundingBox(); return 0; } -void MODULE::Set_Rectangle_Encadrement() +void MODULE::CalculateBoundingBox() { m_BoundaryBox = GetFootPrintRect(); m_Surface = ABS( (double) m_BoundaryBox.GetWidth() * m_BoundaryBox.GetHeight() ); @@ -673,14 +702,14 @@ void MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) { int nbpad; char bufcar[512], Line[512]; - bool flag = FALSE; + bool flag = false; wxString msg; BOARD* board = GetBoard(); frame->EraseMsgBox(); if( frame->m_Ident != PCB_FRAME ) - flag = TRUE; + flag = true; frame->AppendMsgPanel( m_Reference->m_Text, m_Value->m_Text, DARKCYAN ); @@ -783,9 +812,6 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const #else if( buf == aPadName ) #endif - - - return pad; } @@ -824,10 +850,12 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, case TYPE_TEXTE_MODULE: result = inspector->Inspect( m_Reference, testData ); + if( result == SEARCH_QUIT ) break; result = inspector->Inspect( m_Value, testData ); + if( result == SEARCH_QUIT ) break; @@ -908,6 +936,7 @@ void MODULE::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Pads; + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); @@ -915,12 +944,14 @@ void MODULE::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Drawings; + for( ; p; p = p->Next() ) p->Show( nestLevel + 2, os ); NestedSpace( nestLevel + 1, os ) << "\n"; p = m_Son; + for( ; p; p = p->Next() ) { p->Show( nestLevel + 1, os ); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 7baa8cbc46..cb36aa9d8a 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -114,10 +114,10 @@ public: */ /** - * Function Set_Rectangle_Encadrement + * Function CalculateBoundingBox * calculates the bounding box in board coordinates. */ - void Set_Rectangle_Encadrement(); + void CalculateBoundingBox(); /** * Function GetFootPrintRect() diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp index 29adafeaa9..b9a30e21f8 100644 --- a/pcbnew/class_module_transform_functions.cpp +++ b/pcbnew/class_module_transform_functions.cpp @@ -73,48 +73,54 @@ int ChangeSideNumLayer( int oldlayer ) /* Calculate the mask layer when flipping a footprint * BACK and FRONT copper layers , mask, paste, solder layers are swapped */ -int ChangeSideMaskLayer( int masque ) +int ChangeSideMaskLayer( int aMask ) { - int newmasque; + int newMask; - newmasque = masque & ~(LAYER_BACK | LAYER_FRONT | + newMask = aMask & ~(LAYER_BACK | LAYER_FRONT | SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT | ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT | SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT | ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT); - if( masque & LAYER_BACK ) - newmasque |= LAYER_FRONT; - if( masque & LAYER_FRONT ) - newmasque |= LAYER_BACK; + if( aMask & LAYER_BACK ) + newMask |= LAYER_FRONT; - if( masque & SILKSCREEN_LAYER_BACK ) - newmasque |= SILKSCREEN_LAYER_FRONT; - if( masque & SILKSCREEN_LAYER_FRONT ) - newmasque |= SILKSCREEN_LAYER_BACK; + if( aMask & LAYER_FRONT ) + newMask |= LAYER_BACK; - if( masque & ADHESIVE_LAYER_BACK ) - newmasque |= ADHESIVE_LAYER_FRONT; - if( masque & ADHESIVE_LAYER_FRONT ) - newmasque |= ADHESIVE_LAYER_BACK; + if( aMask & SILKSCREEN_LAYER_BACK ) + newMask |= SILKSCREEN_LAYER_FRONT; - if( masque & SOLDERMASK_LAYER_BACK ) - newmasque |= SOLDERMASK_LAYER_FRONT; - if( masque & SOLDERMASK_LAYER_FRONT ) - newmasque |= SOLDERMASK_LAYER_BACK; + if( aMask & SILKSCREEN_LAYER_FRONT ) + newMask |= SILKSCREEN_LAYER_BACK; - if( masque & SOLDERPASTE_LAYER_BACK ) - newmasque |= SOLDERPASTE_LAYER_FRONT; - if( masque & SOLDERPASTE_LAYER_FRONT ) - newmasque |= SOLDERPASTE_LAYER_BACK; + if( aMask & ADHESIVE_LAYER_BACK ) + newMask |= ADHESIVE_LAYER_FRONT; - if( masque & ADHESIVE_LAYER_BACK ) - newmasque |= ADHESIVE_LAYER_FRONT; - if( masque & ADHESIVE_LAYER_FRONT ) - newmasque |= ADHESIVE_LAYER_BACK; + if( aMask & ADHESIVE_LAYER_FRONT ) + newMask |= ADHESIVE_LAYER_BACK; - return newmasque; + if( aMask & SOLDERMASK_LAYER_BACK ) + newMask |= SOLDERMASK_LAYER_FRONT; + + if( aMask & SOLDERMASK_LAYER_FRONT ) + newMask |= SOLDERMASK_LAYER_BACK; + + if( aMask & SOLDERPASTE_LAYER_BACK ) + newMask |= SOLDERPASTE_LAYER_FRONT; + + if( aMask & SOLDERPASTE_LAYER_FRONT ) + newMask |= SOLDERPASTE_LAYER_BACK; + + if( aMask & ADHESIVE_LAYER_BACK ) + newMask |= ADHESIVE_LAYER_FRONT; + + if( aMask & ADHESIVE_LAYER_FRONT ) + newMask |= ADHESIVE_LAYER_BACK; + + return newMask; } @@ -160,7 +166,7 @@ void MODULE::Flip(const wxPoint& aCentre ) // Move module to its final position: wxPoint finalPos = m_Pos; finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position - SetPosition(finalPos); + SetPosition(finalPos); /* Flip layer */ SetLayer( ChangeSideNumLayer( GetLayer() ) ); @@ -171,6 +177,7 @@ void MODULE::Flip(const wxPoint& aCentre ) /* Mirror inversion layers pads. */ pt_pad = m_Pads; + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { pt_pad->m_Pos.y -= m_Pos.y; @@ -182,7 +189,7 @@ void MODULE::Flip(const wxPoint& aCentre ) NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient ); /* flip pads layers*/ - pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer ); + pt_pad->m_layerMask = ChangeSideMaskLayer( pt_pad->m_layerMask ); } /* Mirror reference. */ @@ -285,7 +292,7 @@ void MODULE::Flip(const wxPoint& aCentre ) } } - Set_Rectangle_Encadrement(); + CalculateBoundingBox(); } void MODULE::SetPosition( const wxPoint& newpos ) @@ -327,7 +334,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) } } - Set_Rectangle_Encadrement(); + CalculateBoundingBox(); } @@ -373,5 +380,5 @@ void MODULE::SetOrientation( int newangle ) } } - Set_Rectangle_Encadrement(); + CalculateBoundingBox(); } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 9e07b0f842..b5e28c3082 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -45,9 +45,8 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPE_PAD ) m_LocalSolderMaskMargin = 0; m_LocalSolderPasteMargin = 0; m_LocalSolderPasteMarginRatio = 0.0; - m_Masque_Layer = PAD_STANDARD_DEFAULT_LAYERS; // set layers mask to - // default for a standard - // pad + m_layerMask = PAD_STANDARD_DEFAULT_LAYERS; // set layers mask to + // default for a standard pad SetSubRatsnest( 0 ); // used in ratsnest // calculations @@ -160,10 +159,12 @@ void D_PAD::ReturnStringPadName( wxString& text ) const int ii; text.Empty(); + for( ii = 0; ii < 4; ii++ ) { if( m_Padname[ii] == 0 ) break; + text.Append( m_Padname[ii] ); } } @@ -175,8 +176,10 @@ void D_PAD::SetPadName( const wxString& name ) int ii, len; len = name.Length(); + if( len > 4 ) len = 4; + for( ii = 0; ii < len; ii++ ) m_Padname[ii] = name.GetChar( ii ); @@ -202,7 +205,7 @@ void D_PAD::Copy( D_PAD* source ) return; m_Pos = source->m_Pos; - m_Masque_Layer = source->m_Masque_Layer; + m_layerMask = source->m_layerMask; m_NumPadName = source->m_NumPadName; SetNet( source->GetNet() ); @@ -280,6 +283,7 @@ int D_PAD::GetSolderMaskMargin() { int margin = m_LocalSolderMaskMargin; MODULE * module = (MODULE*) GetParent(); + if( module ) { if( margin == 0 ) @@ -287,6 +291,7 @@ int D_PAD::GetSolderMaskMargin() if( module->m_LocalSolderMaskMargin ) margin = module->m_LocalSolderMaskMargin; } + if( margin == 0 ) { BOARD * brd = GetBoard(); @@ -298,9 +303,11 @@ int D_PAD::GetSolderMaskMargin() if( margin < 0 ) { int minsize = -MIN( m_Size.x, m_Size.y ) / 2; + if( margin < minsize ) minsize = minsize; } + return margin; } @@ -326,11 +333,13 @@ wxSize D_PAD::GetSolderPasteMargin() margin = module->m_LocalSolderPasteMargin; BOARD * brd = GetBoard(); + if( margin == 0 ) margin = brd->GetBoardDesignSettings()->m_SolderPasteMargin; if( mratio == 0.0 ) mratio = module->m_LocalSolderPasteMarginRatio; + if( mratio == 0.0 ) { mratio = brd->GetBoardDesignSettings()->m_SolderPasteMarginRatio; @@ -373,6 +382,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) while( aReader->ReadLine() ) { Line = aReader->Line(); + if( Line[0] == '$' ) return 0; @@ -385,6 +395,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) case 'S': // = Sh /* Read pad name */ nn = 0; + while( (*PtLine != '"') && *PtLine ) PtLine++; @@ -392,6 +403,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) PtLine++; memset( m_Padname, 0, sizeof(m_Padname) ); + while( (*PtLine != '"') && *PtLine ) { if( nn < (int) sizeof(m_Padname) ) @@ -450,21 +462,24 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) m_DrillShape = PAD_OVAL; } } + break; case 'A': nn = sscanf( PtLine, "%s %s %X", BufLine, BufCar, - &m_Masque_Layer ); + &m_layerMask ); - /* BufCar is not used now */ - /* update attributes */ + /* BufCar is not used now update attributes */ m_Attribut = PAD_STANDARD; if( strncmp( BufLine, "SMD", 3 ) == 0 ) m_Attribut = PAD_SMD; + if( strncmp( BufLine, "CONN", 4 ) == 0 ) m_Attribut = PAD_CONN; + if( strncmp( BufLine, "HOLE", 4 ) == 0 ) m_Attribut = PAD_HOLE_NOT_PLATED; + break; case 'N': /* Read Netname */ @@ -545,10 +560,12 @@ bool D_PAD::Save( FILE* aFile ) const m_DeltaSize.x, m_DeltaSize.y, m_Orient ); fprintf( aFile, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); + if( m_DrillShape == PAD_OVAL ) { fprintf( aFile, " %c %d %d", 'O', m_Drill.x, m_Drill.y ); } + fprintf( aFile, "\n" ); switch( m_Attribut ) @@ -571,7 +588,7 @@ bool D_PAD::Save( FILE* aFile ) const break; } - fprintf( aFile, "At %s N %8.8X\n", texttype, m_Masque_Layer ); + fprintf( aFile, "At %s N %8.8X\n", texttype, m_layerMask ); fprintf( aFile, "Ne %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() ); @@ -608,6 +625,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->EraseMsgBox(); module = (MODULE*) m_Parent; + if( module ) { wxString msg = module->GetReference(); @@ -621,8 +639,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) /* For test and debug only: display m_physical_connexion and * m_logical_connexion */ #if 1 // Used only to debug connectivity calculations - Line.Printf( wxT( "%d-%d-%d " ), GetSubRatsnest(), - GetSubNet(), m_ZoneSubnet ); + Line.Printf( wxT( "%d-%d-%d " ), GetSubRatsnest(), GetSubNet(), m_ZoneSubnet ); frame->AppendMsgPanel( wxT( "L-P-Z" ), Line, DARKGREEN ); #endif @@ -630,9 +647,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) wxString layerInfo; - if( (m_Masque_Layer & ALL_CU_LAYERS) == 0 ) // pad is not on any copper layers + if( (m_layerMask & ALL_CU_LAYERS) == 0 ) // pad is not on any copper layers { - switch( m_Masque_Layer & ~ALL_CU_LAYERS ) + switch( m_layerMask & ~ALL_CU_LAYERS ) { case ADHESIVE_LAYER_BACK: layerInfo = board->GetLayerName( ADHESIVE_N_BACK ); @@ -697,33 +714,34 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) static const wxChar* andInternal = _( " & int" ); - if( (m_Masque_Layer & (LAYER_BACK | LAYER_FRONT)) == LAYER_BACK ) + if( (m_layerMask & (LAYER_BACK | LAYER_FRONT)) == LAYER_BACK ) { layerInfo = board->GetLayerName( LAYER_N_BACK ); - if( m_Masque_Layer & INTERIOR_COPPER ) + if( m_layerMask & INTERIOR_COPPER ) layerInfo += andInternal; } - else if( (m_Masque_Layer & (LAYER_BACK | LAYER_FRONT)) == (LAYER_BACK | LAYER_FRONT) ) + else if( (m_layerMask & (LAYER_BACK | LAYER_FRONT)) == (LAYER_BACK | LAYER_FRONT) ) { layerInfo = board->GetLayerName( LAYER_N_BACK ) + wxT(", ") + board->GetLayerName( LAYER_N_FRONT ); - if( m_Masque_Layer & INTERIOR_COPPER ) + if( m_layerMask & INTERIOR_COPPER ) layerInfo += andInternal; } - else if( (m_Masque_Layer & (LAYER_BACK | LAYER_FRONT)) == LAYER_FRONT ) + else if( (m_layerMask & (LAYER_BACK | LAYER_FRONT)) == LAYER_FRONT ) { layerInfo = board->GetLayerName( LAYER_N_FRONT ); - if( m_Masque_Layer & INTERIOR_COPPER ) + if( m_layerMask & INTERIOR_COPPER ) layerInfo += andInternal; } - - else // necessarily true: if( m_Masque_Layer & INTERIOR_COPPER ) + else // necessarily true: if( m_layerMask & INTERIOR_COPPER ) + { layerInfo = _( "internal" ); + } } frame->AppendMsgPanel( _( "Layer" ), layerInfo, DARKGREEN ); @@ -737,6 +755,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "V Size" ), Line, RED ); valeur_param( (unsigned) m_Drill.x, Line ); + if( m_DrillShape == PAD_CIRCLE ) { frame->AppendMsgPanel( _( "Drill" ), Line, RED ); @@ -751,6 +770,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) } int module_orient = module ? module->m_Orient : 0; + if( module_orient ) Line.Printf( wxT( "%3.1f(+%3.1f)" ), (float) ( m_Orient - module_orient ) / 10, @@ -777,7 +797,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) // see class_pad.h bool D_PAD::IsOnLayer( int aLayer ) const { - return (1 << aLayer) & m_Masque_Layer; + return (1 << aLayer) & m_layerMask; } @@ -807,8 +827,10 @@ bool D_PAD::HitTest( const wxPoint& refPos ) { case PAD_CIRCLE: dist = hypot( delta.x, delta.y ); + if( wxRound( dist ) <= dx ) return true; + break; case PAD_TRAPEZOID: @@ -821,8 +843,10 @@ bool D_PAD::HitTest( const wxPoint& refPos ) default: RotatePoint( &delta, -m_Orient ); + if( (abs( delta.x ) <= dx ) && (abs( delta.y ) <= dy) ) return true; + break; } @@ -836,23 +860,29 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) if( (diff = padref->m_PadShape - padcmp->m_PadShape) ) return diff; + if( (diff = padref->m_Size.x - padcmp->m_Size.x) ) return diff; + if( (diff = padref->m_Size.y - padcmp->m_Size.y) ) return diff; + if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) ) return diff; + if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) ) return diff; + if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) ) return diff; + if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) return diff; // @todo check if export_gencad still works: // specctra_export needs this, but maybe export_gencad does not. added on // Jan 24 2008 by Dick. - if( ( diff = padref->m_Masque_Layer - padcmp->m_Masque_Layer ) ) + if( ( diff = padref->m_layerMask - padcmp->m_layerMask ) ) return diff; return 0; @@ -864,19 +894,19 @@ wxString D_PAD::ShowPadShape() const switch( m_PadShape ) { case PAD_CIRCLE: - return _("Circle"); + return _( "Circle" ); case PAD_OVAL: - return _("Oval"); + return _( "Oval" ); case PAD_RECT: - return _("Rect"); + return _( "Rect" ); case PAD_TRAPEZOID: - return _("Trap"); + return _( "Trap" ); default: - return wxT("??Unknown??"); + return wxT( "??Unknown??" ); } } @@ -886,19 +916,19 @@ wxString D_PAD::ShowPadAttr() const switch( m_Attribut & 0x0F ) { case PAD_STANDARD: - return _("Std"); + return _( "Std" ); case PAD_SMD: - return _("Smd"); + return _( "Smd" ); case PAD_CONN: - return _("Conn"); + return _( "Conn" ); case PAD_HOLE_NOT_PLATED: - return _("Not Plated"); + return _( "Not Plated" ); default: - return wxT("??Unkown??"); + return wxT( "??Unkown??" ); } } @@ -910,11 +940,11 @@ wxString D_PAD::GetSelectMenuText() const text << _( "Pad" ) << wxT( " \"" ) << ReturnStringPadName() << wxT( "\" (" ); - if ( (m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS ) + if ( (m_layerMask & ALL_CU_LAYERS) == ALL_CU_LAYERS ) text << _("all copper layers"); - else if( (m_Masque_Layer & LAYER_BACK ) == LAYER_BACK ) + else if( (m_layerMask & LAYER_BACK ) == LAYER_BACK ) text << board->GetLayerName(LAYER_N_BACK); - else if( (m_Masque_Layer & LAYER_FRONT) == LAYER_FRONT ) + else if( (m_layerMask & LAYER_FRONT) == LAYER_FRONT ) text << board->GetLayerName(LAYER_N_FRONT); else text << _( "???" ); @@ -935,12 +965,11 @@ wxString D_PAD::GetSelectMenuText() const */ void D_PAD::Show( int nestLevel, std::ostream& os ) { - char padname[5] = - { m_Padname[0], m_Padname[1], m_Padname[2], m_Padname[3], 0 }; + char padname[5] = { m_Padname[0], m_Padname[1], m_Padname[2], m_Padname[3], 0 }; char layerMask[16]; - sprintf( layerMask, "0x%08X", m_Masque_Layer ); + sprintf( layerMask, "0x%08X", m_layerMask ); // for now, make it look like XML: NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 4cf26e06c1..ef5d56d157 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -73,7 +73,7 @@ public: */ }; - int m_Masque_Layer; // Bitwise layer :1= copper layer, 15= cmp, + int m_layerMask; // Bitwise layer :1= copper layer, 15= cmp, // 2..14 = internal layers // 16 .. 31 = technical layers diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index bd1eaf1d70..88ed7541de 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -97,29 +97,30 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi /* If pad are only on front side (no layer on back side) * and if hide front side pads is enabled, do not draw */ - if( !frontVisible && ( (m_Masque_Layer & BACK_SIDE_LAYERS) == 0 ) ) + if( !frontVisible && ( (m_layerMask & BACK_SIDE_LAYERS) == 0 ) ) return; /* If pad are only on back side (no layer on front side) * and if hide back side pads is enabled, do not draw */ - if( !backVisible && ( (m_Masque_Layer & FRONT_SIDE_LAYERS) == 0 ) ) + if( !backVisible && ( (m_layerMask & FRONT_SIDE_LAYERS) == 0 ) ) return; PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent(); PCB_SCREEN* screen = frame->GetScreen(); + if( frame->m_DisplayPadFill == FILLED ) drawInfo.m_ShowPadFilled = true; else drawInfo.m_ShowPadFilled = false; - if( m_Masque_Layer & LAYER_FRONT ) + if( m_layerMask & LAYER_FRONT ) { color = brd->GetVisibleElementColor( PAD_FR_VISIBLE ); } - if( m_Masque_Layer & LAYER_BACK ) + if( m_layerMask & LAYER_BACK ) { color |= brd->GetVisibleElementColor( PAD_BK_VISIBLE ); } @@ -128,7 +129,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi { // If the pad in on only one tech layer, use the layer color // else use DARKGRAY - int mask_non_copper_layers = m_Masque_Layer & ~ALL_CU_LAYERS; + int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS; #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR mask_non_copper_layers &= brd->GetVisibleLayers(); #endif @@ -208,8 +209,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi } // if PAD_SMD pad and high contrast mode - if( ( m_Attribut == PAD_SMD || m_Attribut == PAD_CONN ) - && DisplayOpt.ContrastModeDisplay ) + if( ( m_Attribut == PAD_SMD || m_Attribut == PAD_CONN ) && DisplayOpt.ContrastModeDisplay ) { // when routing tracks if( frame && frame->GetToolId() == ID_TRACK_BUTT ) @@ -220,10 +220,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi // if routing between copper and component layers, // or the current layer is one of said 2 external copper layers, // then highlight only the current layer. - if( ( ( 1 << routeTop ) | ( 1 << routeBot ) ) - == ( LAYER_BACK | LAYER_FRONT ) - || ( ( 1 << screen->m_Active_Layer ) - & ( LAYER_BACK | LAYER_FRONT ) ) ) + if( ( ( 1 << routeTop ) | ( 1 << routeBot ) ) == ( LAYER_BACK | LAYER_FRONT ) + || ( ( 1 << screen->m_Active_Layer ) & ( LAYER_BACK | LAYER_FRONT ) ) ) { if( !IsOnLayer( screen->m_Active_Layer ) ) { @@ -319,8 +317,9 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi color = ColorRefs[color & MASKCOLOR].m_LightColor; bool DisplayIsol = DisplayOpt.DisplayPadIsol; - if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 ) - DisplayIsol = FALSE; + + if( ( m_layerMask & ALL_CU_LAYERS ) == 0 ) + DisplayIsol = false; if( m_Attribut == PAD_HOLE_NOT_PLATED ) drawInfo.m_ShowNotPlatedHole = true; @@ -339,12 +338,12 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi * needed (never needed in Cvpcb nor in Gerbview) */ drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0; + /* Draw the pad number */ if( frame && !frame->m_DisplayPadNum ) drawInfo.m_Display_padnum = false; - if( ( DisplayOpt.DisplayNetNamesMode == 0 ) - || ( DisplayOpt.DisplayNetNamesMode == 2 ) ) + if( ( DisplayOpt.DisplayNetNamesMode == 0 ) || ( DisplayOpt.DisplayNetNamesMode == 2 ) ) drawInfo.m_Display_netname = false; // Display net names is restricted to pads that are on the active layer @@ -378,6 +377,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) wxSize halfsize = m_Size; halfsize.x >>= 1; halfsize.y >>= 1; + switch( GetShape() ) { case PAD_CIRCLE: @@ -398,6 +398,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) 0, aDrawInfo.m_Color ); } + break; case PAD_OVAL: @@ -406,6 +407,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) seg_width = BuildSegmentFromOvalShape(segStart, segEnd, angle); segStart += shape_pos; segEnd += shape_pos; + if( aDrawInfo.m_ShowPadFilled ) { GRFillCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, @@ -430,6 +432,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) case PAD_RECT: case PAD_TRAPEZOID: BuildPadPolygon( coord, aDrawInfo.m_Mask_margin, angle ); + for( int ii = 0; ii < 4; ii++ ) coord[ii] += shape_pos; @@ -458,11 +461,14 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) int hole = m_Drill.x >> 1; bool drawhole = hole > 0; + if( !aDrawInfo.m_ShowPadFilled && !aDrawInfo. m_ShowNotPlatedHole ) drawhole = false; + if( drawhole ) { bool blackpenstate = false; + if( aDrawInfo.m_IsPrinting ) { blackpenstate = GetGRForceBlackPenState(); @@ -476,6 +482,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) GRSetDrawMode( aDC, GR_XOR ); int hole_color = aDrawInfo.m_HoleColor; + if( aDrawInfo. m_ShowNotPlatedHole ) // Draw a specific hole color hole_color = aDrawInfo.m_NPHoleColor; @@ -503,6 +510,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) delta_cy = halfsize.y - halfsize.x; seg_width = m_Drill.x; } + RotatePoint( &delta_cx, &delta_cy, angle ); GRFillCSegm( aClipBox, aDC, holepos.x + delta_cx, holepos.y + delta_cy, @@ -526,11 +534,11 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) int dx0 = MIN( halfsize.x, halfsize.y ); int nc_color = BLUE; - if( m_Masque_Layer & LAYER_FRONT ) /* Draw \ */ + if( m_layerMask & LAYER_FRONT ) /* Draw \ */ GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0, holepos.x + dx0, holepos.y + dx0, 0, nc_color ); - if( m_Masque_Layer & LAYER_BACK ) /* Draw / */ + if( m_layerMask & LAYER_BACK ) /* Draw / */ GRLine( aClipBox, aDC, holepos.x + dx0, holepos.y - dx0, holepos.x - dx0, holepos.y + dx0, 0, nc_color ); } @@ -544,11 +552,15 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) wxSize AreaSize; // size of text area, normalized to // AreaSize.y < AreaSize.x int shortname_len = m_ShortNetname.Len(); + if( !aDrawInfo.m_Display_netname ) shortname_len = 0; + if( GetShape() == PAD_CIRCLE ) angle = 0; + AreaSize = m_Size; + if( m_Size.y > m_Size.x ) { angle += 900; @@ -556,12 +568,10 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) AreaSize.y = m_Size.x; } - if( shortname_len > 0 ) // if there is a netname, provides room - // to display this netname + if( shortname_len > 0 ) // if there is a netname, provides room to display this netname { - AreaSize.y /= 2; // Text used only the upper area of the - // pad. The lower area displays the net - // name + AreaSize.y /= 2; // Text used only the upper area of the + // pad. The lower area displays the net name tpos.y -= AreaSize.y / 2; } @@ -581,6 +591,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) wxString buffer; int tsize; + if( aDrawInfo.m_Display_padnum ) { ReturnStringPadName( buffer ); @@ -610,8 +621,10 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small. { tpos = tpos0; + if( aDrawInfo.m_Display_padnum ) tpos.y += AreaSize.y / 2; + RotatePoint( &tpos, shape_pos, angle ); // tsize reserve room for marges and segments thickness @@ -622,6 +635,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) } } + /** * Function BuildSegmentFromOvalShape * Has meaning only for OVAL (and ROUND) pads. @@ -632,6 +646,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, int aRotation) const { int width; + if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment { int delta = ( m_Size.x - m_Size.y ) / 2; @@ -660,6 +675,7 @@ int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, int a return width; } + /** * Function BuildPadPolygon * Has meaning only for polygonal pads (trapeziod and rectangular) @@ -690,6 +706,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat // Only possible for inflate negative values. if( halfsize.x < 0 ) halfsize.x = 0; + if( halfsize.y < 0 ) halfsize.y = 0; } @@ -702,10 +719,13 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat // be sure delta values are not to large if( (delta.x < 0) && (delta.x <= -halfsize.y) ) delta.x = -halfsize.y + 1; + if( (delta.x > 0) && (delta.x >= halfsize.y) ) delta.x = halfsize.y - 1; + if( (delta.y < 0) && (delta.y <= -halfsize.x) ) delta.y = -halfsize.x + 1; + if( (delta.y > 0) && (delta.y >= halfsize.x) ) delta.y = halfsize.x - 1; } @@ -730,6 +750,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat { double angle; wxSize corr; + if( delta.y ) // lower and upper segment is horizontal { // Calculate angle of left (or right) segment with vertical axis @@ -766,6 +787,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat { delta = aInflateValue; // this pad is rectangular (delta null). } + aCoord[0].x += -delta.x - corr.x; // lower left aCoord[0].y += delta.y + corr.y; @@ -786,10 +808,13 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat if( aCoord[0].x > 0 ) // lower left x coordinate must be <= 0 aCoord[0].x = aCoord[3].x = 0; + if( aCoord[1].x > 0 ) // upper left x coordinate must be <= 0 aCoord[1].x = aCoord[2].x = 0; + if( aCoord[0].y < 0 ) // lower left y coordinate must be >= 0 aCoord[0].y = aCoord[1].y = 0; + if( aCoord[3].y < 0 ) // lower right y coordinate must be >= 0 aCoord[3].y = aCoord[2].y = 0; } diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 4260f7237b..95410d1dae 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -30,10 +30,8 @@ static bool ShowClearance( const TRACK* aTrack ) } -/**********************************************************/ TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) : BOARD_CONNECTED_ITEM( aParent, idtype ) -/**********************************************************/ { m_Width = 0; m_Shape = S_SEGMENT; @@ -174,6 +172,7 @@ TRACK* TRACK::Copy() const return NULL; // should never happen } + /** * Function GetClearance (virtual) * returns the clearance in internal units. If \a aItem is not NULL then the @@ -192,6 +191,7 @@ int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const return BOARD_CONNECTED_ITEM::GetClearance( aItem ); } + /** * Function GetDrillValue * calculate the drill value for vias (m_Drill if > 0, or default drill value for the Netclass @@ -215,11 +215,8 @@ int TRACK::GetDrillValue() const } -/***********************/ -bool TRACK::IsNull() -/***********************/ - // return true if segment length = 0 +bool TRACK::IsNull() { if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) ) return true; @@ -228,10 +225,6 @@ bool TRACK::IsNull() } -/*************************************************************/ -int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) -/*************************************************************/ - /* Return: * STARTPOINT if point if near (dist = min_dist) star point * ENDPOINT if point if near (dist = min_dist) end point @@ -239,6 +232,7 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) * 0 if no * if min_dist < 0: min_dist = track_width/2 */ +int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) { int result = 0; @@ -256,12 +250,14 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) else { double dist = hypot( (double)dx, (double) dy ); + if( min_dist >= (int) dist ) result |= STARTPOINT; } dx = m_End.x - point.x; dy = m_End.y - point.y; + if( min_dist == 0 ) { if( (dx == 0) && (dy == 0 ) ) @@ -270,6 +266,7 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) else { double dist = hypot( (double) dx, (double) dy ); + if( min_dist >= (int) dist ) result |= ENDPOINT; } @@ -356,11 +353,15 @@ void TRACK::Flip( const wxPoint& aCentre ) { m_Start.y = aCentre.y - (m_Start.y - aCentre.y); m_End.y = aCentre.y - (m_End.y - aCentre.y); + if( Type() == TYPE_VIA ) { + // Huh? Wouldn't it be better to us Type() != VIA and get rid of these brackets? } else + { SetLayer( ChangeSideNumLayer( GetLayer() ) ); + } } @@ -386,9 +387,7 @@ SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData, } -/***********************************************/ bool SEGVIA::IsOnLayer( int layer_number ) const -/***********************************************/ { int bottom_layer, top_layer; @@ -401,12 +400,10 @@ bool SEGVIA::IsOnLayer( int layer_number ) const } -/***********************************/ -int TRACK::ReturnMaskLayer() -/***********************************/ /* Return the mask layer for this. * for a via, there is more than one layer used */ +int TRACK::ReturnMaskLayer() { if( Type() == TYPE_VIA ) { @@ -423,6 +420,7 @@ int TRACK::ReturnMaskLayer() ( (SEGVIA*) this )->ReturnLayerPair( &top_layer, &bottom_layer ); int layermask = 0; + while( bottom_layer <= top_layer ) { layermask |= g_TabOneLayerMask[bottom_layer++]; @@ -431,14 +429,12 @@ int TRACK::ReturnMaskLayer() return layermask; } else + { return g_TabOneLayerMask[m_Layer]; + } } -/*********************************************************/ -void SEGVIA::SetLayerPair( int top_layer, int bottom_layer ) -/*********************************************************/ - /** Set the .m_Layer member param: * For a via m_Layer contains the 2 layers : * top layer and bottom layer used by the via. @@ -447,6 +443,7 @@ void SEGVIA::SetLayerPair( int top_layer, int bottom_layer ) * @param top_layer = first layer connected by the via * @param bottom_layer = last layer connected by the via */ +void SEGVIA::SetLayerPair( int top_layer, int bottom_layer ) { if( Shape() == VIA_THROUGH ) { @@ -461,10 +458,6 @@ void SEGVIA::SetLayerPair( int top_layer, int bottom_layer ) } -/*********************************************************************/ -void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const -/*********************************************************************/ - /** * Function ReturnLayerPair * Return the 2 layers used by the via (the via actually uses @@ -472,6 +465,7 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const * @param top_layer = pointer to the first layer (can be null) * @param bottom_layer = pointer to the last layer (can be null) */ +void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const { int b_layer = LAYER_N_BACK; int t_layer = LAYER_N_FRONT; @@ -480,6 +474,7 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const { b_layer = (m_Layer >> 4) & 15; t_layer = m_Layer & 15; + if( b_layer > t_layer ) EXCHG( b_layer, t_layer ); } @@ -511,13 +506,10 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb ) } -/*******************************************/ -TRACK* TRACK::GetStartNetCode( int NetCode ) -/*******************************************/ - /* Search (within the track linked list) the first segment matching the netcode * ( the linked list is always sorted by net codes ) */ +TRACK* TRACK::GetStartNetCode( int NetCode ) { TRACK* Track = this; int ii = 0; @@ -546,13 +538,10 @@ TRACK* TRACK::GetStartNetCode( int NetCode ) } -/*****************************************/ -TRACK* TRACK::GetEndNetCode( int NetCode ) -/*****************************************/ - /* Search (within the track linked list) the last segment matching the netcode * ( the linked list is always sorted by net codes ) */ +TRACK* TRACK::GetEndNetCode( int NetCode ) { TRACK* NextS, * Track = this; int ii = 0; @@ -566,6 +555,7 @@ TRACK* TRACK::GetEndNetCode( int NetCode ) while( Track != NULL ) { NextS = (TRACK*) Track->Pnext; + if( Track->GetNet() == NetCode ) ii++; @@ -603,13 +593,11 @@ bool TRACK::Save( FILE* aFile ) const } -/*********************************************************************/ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset ) -/*********************************************************************/ { - int l_piste; + int l_trace; int color; - int rayon; + int radius; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; if( Type() == TYPE_ZONE && DisplayOpt.DisplayZonesMode != 0 ) @@ -618,8 +606,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& BOARD * brd = GetBoard( ); color = brd->GetLayerColor(m_Layer); - if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != - HIGHLIGHT_FLAG ) + if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) return; if( DisplayOpt.ContrastModeDisplay ) @@ -647,44 +634,43 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& GRSetDrawMode( DC, draw_mode ); - l_piste = m_Width >> 1; + l_trace = m_Width >> 1; if( m_Shape == S_CIRCLE ) { - rayon = (int) hypot( (double) ( m_End.x - m_Start.x ), - (double) ( m_End.y - m_Start.y ) ); + radius = (int) hypot( (double) ( m_End.x - m_Start.x ), + (double) ( m_End.y - m_Start.y ) ); - if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN ) + if( DC->LogicalToDeviceXRel( l_trace ) < L_MIN_DESSIN ) { GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, rayon, color ); + m_Start.y + aOffset.y, radius, color ); } else { - if( DC->LogicalToDeviceXRel( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */ + if( DC->LogicalToDeviceXRel( l_trace ) <= 1 ) /* Sketch mode if l_trace/zoom <= 1 */ { GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, rayon, color ); + m_Start.y + aOffset.y, radius, color ); } else if( ( !DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) ) { GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, rayon - l_piste, color ); + m_Start.y + aOffset.y, radius - l_trace, color ); GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, rayon + l_piste, color ); + m_Start.y + aOffset.y, radius + l_trace, color ); } else { GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, rayon, - m_Width, color ); + m_Start.y + aOffset.y, radius, m_Width, color ); } } return; } - if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN ) + if( DC->LogicalToDeviceXRel( l_trace ) < L_MIN_DESSIN ) { GRLine( &panel->m_ClipBox, DC, m_Start + aOffset, m_End + aOffset, 0, color ); return; @@ -724,12 +710,10 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& return; #define THRESHOLD 10 - if( (m_End.x - m_Start.x) != 0 - && (m_End.y - m_Start.y) != 0 ) + if( (m_End.x - m_Start.x) != 0 && (m_End.y - m_Start.y) != 0 ) return; - int len = ABS( (m_End.x - m_Start.x) - + (m_End.y - m_Start.y) ); + int len = ABS( (m_End.x - m_Start.x) + (m_End.y - m_Start.y) ); if( len < THRESHOLD * m_Width ) return; @@ -739,11 +723,14 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& if( GetNet() == 0 ) return; + NETINFO_ITEM* net = ( (BOARD*) GetParent() )->FindNet( GetNet() ); + if( net == NULL ) return; int textlen = net->GetShortNetname().Len(); + if( textlen > 0 ) { // calculate a good size for the text @@ -754,6 +741,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& // Calculate angle: if the track segment is vertical, angle = 90 degrees int angle = 0; + if( (m_End.x - m_Start.x) == 0 ) // Vertical segment angle = 900; // angle is in 0.1 degree @@ -772,12 +760,10 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& } -/*******************************************************************************************/ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset ) -/*******************************************************************************************/ { int color; - int rayon; + int radius; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int fillvia = 0; @@ -819,17 +805,17 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint SetAlpha( &color, 150 ); - rayon = m_Width >> 1; - // for small via size on screen (rayon < 4 pixels) draw a simplified shape + radius = m_Width >> 1; + // for small via size on screen (radius < 4 pixels) draw a simplified shape - int radius_in_pixels = DC->LogicalToDeviceXRel( rayon ); + int radius_in_pixels = DC->LogicalToDeviceXRel( radius ); bool fast_draw = false; // Vias are drawn as a filled circle or a double circle. The hole will be drawn later - int drill_rayon = GetDrillValue() / 2; + int drill_radius = GetDrillValue() / 2; - int inner_rayon = rayon - DC->DeviceToLogicalXRel( 2 ); + int inner_radius = radius - DC->DeviceToLogicalXRel( 2 ); if( radius_in_pixels < 3 ) { @@ -838,25 +824,27 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint } if( fillvia ) - GRFilledCircle( &panel->m_ClipBox, DC, m_Start + aOffset, rayon, color ); - + { + GRFilledCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius, color ); + } else { - GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset,rayon, 0, color ); + GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset,radius, 0, color ); if ( fast_draw ) return; - GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, inner_rayon, 0, color ); + GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, inner_radius, 0, color ); } // Draw the via hole if the display option allows it if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) { if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) // Display all drill holes requested - || ( (drill_rayon > 0 ) && !IsDrillDefault() ) ) // Or Display non default holes requested + || ( (drill_radius > 0 ) && !IsDrillDefault() ) ) // Or Display non default holes requested { if( fillvia ) { bool blackpenstate = false; + if( screen->m_IsPrinting ) { blackpenstate = GetGRForceBlackPenState(); @@ -864,31 +852,32 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint color = g_DrawBgColor; } else + { color = BLACK; // or DARKGRAY; + } if( draw_mode != GR_XOR ) GRSetDrawMode( DC, GR_COPY ); else GRSetDrawMode( DC, GR_XOR ); - if( DC->LogicalToDeviceXRel( drill_rayon ) > 1 ) // Draw hole if large enough. + if( DC->LogicalToDeviceXRel( drill_radius ) > 1 ) // Draw hole if large enough. GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, drill_rayon, 0, color, color ); + m_Start.y + aOffset.y, drill_radius, 0, color, color ); if( screen->m_IsPrinting ) GRForceBlackPen( blackpenstate ); } else { - if( drill_rayon < inner_rayon ) // We can show the via hole - GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, drill_rayon, 0, color ); + if( drill_radius < inner_radius ) // We can show the via hole + GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, drill_radius, 0, color ); } } } if( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS ) - GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, - rayon + GetClearance(), 0, color ); + GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color ); // for Micro Vias, draw a partial cross : // X on component layer, or + on copper layer @@ -899,13 +888,13 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint if( IsOnLayer( LAYER_N_BACK ) ) { - ax = rayon; ay = 0; - bx = drill_rayon; by = 0; + ax = radius; ay = 0; + bx = drill_radius; by = 0; } else { - ax = ay = (rayon * 707) / 1000; - bx = by = (drill_rayon * 707) / 1000; + ax = ay = (radius * 707) / 1000; + bx = by = (drill_radius * 707) / 1000; } /* lines | or \ */ @@ -934,7 +923,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint // (so we can see superimposed buried vias ): if( Shape() == VIA_BLIND_BURIED ) { - int ax = 0, ay = rayon, bx = 0, by = drill_rayon; + int ax = 0, ay = radius, bx = 0, by = drill_radius; int layer_top, layer_bottom; ( (SEGVIA*) this )->ReturnLayerPair( &layer_top, &layer_bottom ); @@ -948,7 +937,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint m_Start.y + aOffset.y - by, 0, color ); /* lines for the bottom layer */ - ax = 0; ay = rayon; bx = 0; by = drill_rayon; + ax = 0; ay = radius; bx = 0; by = drill_radius; RotatePoint( &ax, &ay, layer_bottom * 3600 / brd->GetCopperLayerCount( ) ); RotatePoint( &bx, &by, layer_bottom * 3600 / brd->GetCopperLayerCount( ) ); GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x - ax, @@ -960,13 +949,17 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint // Display the short netname: if( GetNet() == 0 ) return; + if( DisplayOpt.DisplayNetNamesMode == 0 || DisplayOpt.DisplayNetNamesMode == 1 ) return; + NETINFO_ITEM* net = ( (BOARD*) GetParent() )->FindNet( GetNet() ); + if( net == NULL ) return; int len = net->GetShortNetname().Len(); + if( len > 0 ) { // calculate a good size for the text @@ -998,9 +991,10 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame ) { int trackLen = 0; int lenDie = 0; - Marque_Une_Piste( board, this, NULL, &trackLen, &lenDie, false ); + MarkTrace( board, this, NULL, &trackLen, &lenDie, false ); msg = frame->CoordinateToString( trackLen ); frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN ); + if( lenDie != 0 ) { msg = frame->CoordinateToString( trackLen + lenDie ); @@ -1092,6 +1086,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) /* Display the State member */ msg = wxT( ". . " ); + if( GetState( TRACK_LOCKED ) ) msg[0] = 'F'; @@ -1107,11 +1102,12 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) int top_layer, bottom_layer; Via->ReturnLayerPair( &top_layer, &bottom_layer ); - msg = board->GetLayerName( top_layer ) + wxT( "/" ) - + board->GetLayerName( bottom_layer ); + msg = board->GetLayerName( top_layer ) + wxT( "/" ) + board->GetLayerName( bottom_layer ); } else + { msg = board->GetLayerName( m_Layer ); + } frame->AppendMsgPanel( _( "Layer" ), msg, BROWN ); @@ -1172,8 +1168,7 @@ bool TRACK::HitTest( const wxPoint& refPos ) if( Type() == TYPE_VIA ) { - return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <= - (double) radius * radius; + return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <= (double) radius * radius; } else { @@ -1196,8 +1191,10 @@ bool TRACK::HitTest( EDA_RECT& refArea ) { if( refArea.Contains( m_Start ) ) return true; + if( refArea.Contains( m_End ) ) return true; + return false; } @@ -1305,11 +1302,11 @@ void SEGVIA::Show( int nestLevel, std::ostream& os ) if( board ) os << " layers=\"" << board->GetLayerName( topLayer ).Trim().mb_str() << "," << board->GetLayerName( botLayer ).Trim().mb_str() << '"'; - os << - " width=\"" << m_Width << '"' << - " drill=\"" << GetDrillValue() << '"' << - " netcode=\"" << GetNet() << "\">" << - ""; + + os << " width=\"" << m_Width << '"' + << " drill=\"" << GetDrillValue() << '"' + << " netcode=\"" << GetNet() << "\">" + << ""; os << "\n"; } @@ -1321,26 +1318,37 @@ wxString TRACK::ShowState( int stateBits ) if( stateBits & IS_LINKED ) ret << wxT( " | IS_LINKED" ); + if( stateBits & TRACK_AR ) ret << wxT( " | TRACK_AR" ); + if( stateBits & TRACK_LOCKED ) ret << wxT( " | TRACK_LOCKED" ); + if( stateBits & IN_EDIT ) ret << wxT( " | IN_EDIT" ); + if( stateBits & IS_DRAGGED ) ret << wxT( " | IS_DRAGGED" ); + if( stateBits & DO_NOT_DRAW ) ret << wxT( " | DO_NOT_DRAW" ); + if( stateBits & IS_DELETED ) ret << wxT( " | IS_DELETED" ); + if( stateBits & BUSY ) ret << wxT( " | BUSY" ); + if( stateBits & END_ONPAD ) ret << wxT( " | END_ONPAD" ); + if( stateBits & BEGIN_ONPAD ) ret << wxT( " | BEGIN_ONPAD" ); + if( stateBits & FLAG0 ) ret << wxT( " | FLAG0" ); + if( stateBits & FLAG1 ) ret << wxT( " | FLAG1" ); diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index c78b168308..f58dd38b7b 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -77,41 +77,42 @@ wxPoint& ZONE_CONTAINER::GetPosition() } else pos = wxPoint( 0, 0 ); + return pos; } -/*******************************************/ -void ZONE_CONTAINER::SetNet( int anet_code ) -{ -/*******************************************/ /** * Set the netcode and the netname * if netcode >= 0, set the netname * if netcode < 0: keep old netname (used to set an necode error flag) */ +void ZONE_CONTAINER::SetNet( int anet_code ) +{ m_NetCode = anet_code; if( anet_code < 0 ) return; BOARD* board = GetBoard(); + if( board ) { NETINFO_ITEM* net = board->FindNet( anet_code ); + if( net ) m_Netname = net->GetNetname(); else m_Netname.Empty(); } else + { m_Netname.Empty(); + } } -/********************************************/ bool ZONE_CONTAINER::Save( FILE* aFile ) const -/********************************************/ { unsigned item_pos; int ret; @@ -123,13 +124,15 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const // Save the outline main info ret = fprintf( aFile, "ZInfo %8.8lX %d %s\n", - m_TimeStamp, m_NetCode, - EscapedUTF8( m_Netname ).c_str() ); + m_TimeStamp, m_NetCode, + EscapedUTF8( m_Netname ).c_str() ); + if( ret < 3 ) return false; // Save the outline layer info ret = fprintf( aFile, "ZLayer %d\n", m_Layer ); + if( ret < 1 ) return false; @@ -151,6 +154,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const } ret = fprintf( aFile, "ZAux %d %c\n", corners_count, outline_hatch ); + if( ret < 2 ) return false; @@ -172,10 +176,12 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const } ret = fprintf( aFile, "ZClearance %d %c\n", m_ZoneClearance, padoption ); + if( ret < 2 ) return false; ret = fprintf( aFile, "ZMinThickness %d\n", m_ZoneMinThickness ); + if( ret < 1 ) return false; @@ -186,12 +192,14 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const m_IsFilled ? 'S' : 'F', m_ThermalReliefGapValue, m_ThermalReliefCopperBridgeValue ); + if( ret < 3 ) return false; ret = fprintf( aFile, "ZSmoothing %d %d\n", cornerSmoothingType, cornerRadius ); + if( ret < 2 ) return false; @@ -201,6 +209,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const ret = fprintf( aFile, "ZCorner %d %d %d\n", m_Poly->corner[item_pos].x, m_Poly->corner[item_pos].y, m_Poly->corner[item_pos].end_contour ); + if( ret < 3 ) return false; } @@ -209,6 +218,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const if( m_FilledPolysList.size() ) { fprintf( aFile, "$POLYSCORNERS\n" ); + for( unsigned ii = 0; ii < m_FilledPolysList.size(); ii++ ) { const CPolyPt* corner = &m_FilledPolysList[ii]; @@ -218,6 +228,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const corner->y, corner->end_contour, corner->utility ); + if( ret < 4 ) return false; } @@ -229,27 +240,28 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const if( m_FillSegmList.size() ) { fprintf( aFile, "$FILLSEGMENTS\n" ); + for( unsigned ii = 0; ii < m_FillSegmList.size(); ii++ ) { ret = fprintf( aFile, "%d %d %d %d\n", m_FillSegmList[ii].m_Start.x, m_FillSegmList[ii].m_Start.y, m_FillSegmList[ii].m_End.x, m_FillSegmList[ii].m_End.y ); + if( ret < 4 ) return false; } fprintf( aFile, "$endFILLSEGMENTS\n" ); } + fprintf( aFile, "$endCZONE_OUTLINE\n" ); return true; } -/**********************************************************/ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) { -/**********************************************************/ char* Line, * text; char netname_buffer[1024]; int ret; @@ -257,9 +269,11 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) bool error = false, has_corner = false; netname_buffer[0] = 0; + while( aReader->ReadLine() ) { Line = aReader->Line(); + if( strnicmp( Line, "ZCorner", 7 ) == 0 ) // new corner found { int x; @@ -268,8 +282,11 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) text = Line + 7; ret = sscanf( text, "%d %d %d", &x, &y, &flag ); + if( ret < 3 ) + { error = true; + } else { if( !has_corner ) @@ -278,6 +295,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) AppendCorner( wxPoint( x, y ) ); has_corner = true; + if( flag ) m_Poly->Close(); } @@ -289,8 +307,11 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) text = Line + 5; ret = sscanf( text, "%X %d %s", &ts, &netcode, netname_buffer ); + if( ret < 3 ) + { error = true; + } else { m_TimeStamp = ts; @@ -305,6 +326,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) text = Line + 6; ret = sscanf( text, "%d", &x ); + if( ret < 1 ) error = true; else @@ -317,8 +339,11 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) text = Line + 4; ret = sscanf( text, "%d %c", &x, hopt ); + if( ret < 2 ) + { error = true; + } else { switch( hopt[0] ) @@ -379,14 +404,17 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) m_IsFilled = (fillstate == 'S') ? true : false; } - else if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearance and pad options info found + else if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearance and pad options info found { int clearance = 200; char padoption; text = Line + 10; ret = sscanf( text, "%d %1c", &clearance, &padoption ); + if( ret < 2 ) + { error = true; + } else { m_ZoneClearance = clearance; @@ -415,6 +443,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) int thickness; text = Line + 13; ret = sscanf( text, "%d", &thickness ); + if( ret < 1 ) error = true; else @@ -425,8 +454,10 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) while( aReader->ReadLine() ) { Line = aReader->Line(); + if( strnicmp( Line, "$endPOLYSCORNERS", 4 ) == 0 ) break; + CPolyPt corner; int end_contour, utility; utility = 0; @@ -438,6 +469,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) &utility ); if( ret < 4 ) return false; + corner.end_contour = end_contour ? true : false; corner.utility = utility; m_FilledPolysList.push_back( corner ); @@ -449,8 +481,10 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) while( aReader->ReadLine() ) { Line = aReader->Line(); + if( strnicmp( Line, "$endFILLSEGMENTS", 4 ) == 0 ) break; + ret = sscanf( Line, "%d %d %d %d", &segm.m_Start.x, @@ -459,6 +493,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) &segm.m_End.y ); if( ret < 4 ) return false; + m_FillSegmList.push_back( segm ); } } @@ -492,8 +527,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const BOARD* brd = GetBoard(); int color = brd->GetLayerColor( m_Layer ); - if( brd->IsLayerVisible( m_Layer ) == false - && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) + if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) return; GRSetDrawMode( DC, aDrawMode ); @@ -514,6 +548,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const else color |= HIGHLIGHT_FLAG; } + if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -528,7 +563,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const { seg_start = GetCornerPosition( ic ) + offset; - if( m_Poly->corner[ic].end_contour == FALSE && ic < GetNumCorners() - 1 ) + if( m_Poly->corner[ic].end_contour == false && ic < GetNumCorners() - 1 ) { seg_end = GetCornerPosition( ic + 1 ) + offset; } @@ -537,6 +572,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const seg_end = GetCornerPosition( i_start_contour ) + offset; i_start_contour = ic + 1; } + lines.push_back( seg_start ); lines.push_back( seg_end ); } @@ -561,11 +597,6 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const } -/************************************************************************************/ -void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, - wxDC* DC, int aDrawMode, const wxPoint& offset ) -{ -/************************************************************************************/ /** * Function DrawDrawFilledArea * Draws the filled areas for this zone (polygon list .m_FilledPolysList) @@ -574,6 +605,9 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, * @param offset = Draw offset (usually wxPoint(0,0)) * @param aDrawMode = GR_OR, GR_XOR, GR_COPY .. */ +void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, + wxDC* DC, int aDrawMode, const wxPoint& offset ) +{ static vector CornersTypeBuffer; static vector CornersBuffer; @@ -615,6 +649,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, else color |= HIGHLIGHT_FLAG; } + if( color & HIGHLIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -625,6 +660,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, // Draw all filled areas int imax = m_FilledPolysList.size() - 1; + for( int ic = 0; ic <= imax; ic++ ) { CPolyPt* corner = &m_FilledPolysList[ic]; @@ -649,6 +685,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, if( (m_ZoneMinThickness > 1) || outline_mode ) { int ilim = CornersBuffer.size() - 1; + for( int is = 0, ie = ilim; is <= ilim; ie = is, is++ ) { int x0 = CornersBuffer[is].x; @@ -675,6 +712,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, GRPoly( &panel->m_ClipBox, DC, CornersBuffer.size(), &CornersBuffer[0], true, 0, color, color ); } + CornersTypeBuffer.clear(); CornersBuffer.clear(); } @@ -725,10 +763,6 @@ EDA_RECT ZONE_CONTAINER::GetBoundingBox() const } -/**********************************************************************************************/ -void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode ) -{ -/***********************************************************************************************/ /** * Function DrawWhileCreateOutline * Draws the zone outline when ir is created. @@ -739,12 +773,15 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in * @param DC = current Device Context * @param draw_mode = draw mode: OR, XOR .. */ +void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode ) +{ int current_gr_mode = draw_mode; bool is_close_segment = false; wxPoint seg_start, seg_end; if( DC == NULL ) return; + int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); int color = brd->GetLayerColor( m_Layer ) & MASKCOLOR; @@ -758,20 +795,22 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in } } - // draw the lines wxPoint start_contour_pos = GetCornerPosition( 0 ); int icmax = GetNumCorners() - 1; + for( int ic = 0; ic <= icmax; ic++ ) { int xi = GetCornerPosition( ic ).x; int yi = GetCornerPosition( ic ).y; int xf, yf; - if( m_Poly->corner[ic].end_contour == FALSE && ic < icmax ) + + if( m_Poly->corner[ic].end_contour == false && ic < icmax ) { is_close_segment = false; xf = GetCornerPosition( ic + 1 ).x; yf = GetCornerPosition( ic + 1 ).y; + if( (m_Poly->corner[ic + 1].end_contour) || (ic == icmax - 1) ) current_gr_mode = GR_XOR; else @@ -788,7 +827,9 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in if( ic < icmax ) start_contour_pos = GetCornerPosition( ic + 1 ); } + GRSetDrawMode( DC, current_gr_mode ); + if( is_close_segment ) GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, WHITE ); else @@ -808,6 +849,7 @@ bool ZONE_CONTAINER::HitTest( const wxPoint& refPos ) { if( HitTestForCorner( refPos ) ) return true; + if( HitTestForEdge( refPos ) ) return true; @@ -830,6 +872,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) #define CORNER_MIN_DIST 100 // distance (in internal units) to detect a corner in a zone outline int min_dist = CORNER_MIN_DIST + 1; + if( GetBoard() && GetBoard()->m_PcbFrame ) { // Use grid size because it is known @@ -839,12 +882,14 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) wxPoint delta; unsigned lim = m_Poly->corner.size(); + for( unsigned item_pos = 0; item_pos < lim; item_pos++ ) { delta.x = refPos.x - m_Poly->corner[item_pos].x; delta.y = refPos.y - m_Poly->corner[item_pos].y; // Calculate a distance: int dist = MAX( abs( delta.x ), abs( delta.y ) ); + if( dist < min_dist ) // this corner is a candidate: { m_CornerSelection = item_pos; @@ -874,6 +919,7 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) #define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline int min_dist = EDGE_MIN_DIST+1; + if( GetBoard() && GetBoard()->m_PcbFrame ) { // Use grid size because it is known @@ -882,6 +928,7 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) } unsigned first_corner_pos = 0; + for( unsigned item_pos = 0; item_pos < lim; item_pos++ ) { unsigned end_segm = item_pos + 1; @@ -899,11 +946,12 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) /* test the dist between segment and ref point */ int dist = (int) GetPointToLineSegmentDistance( refPos.x, - refPos.y, - m_Poly->corner[item_pos].x, - m_Poly->corner[item_pos].y, - m_Poly->corner[end_segm].x, - m_Poly->corner[end_segm].y ); + refPos.y, + m_Poly->corner[item_pos].x, + m_Poly->corner[item_pos].y, + m_Poly->corner[end_segm].x, + m_Poly->corner[end_segm].y ); + if( dist < min_dist ) { m_CornerSelection = item_pos; @@ -929,10 +977,13 @@ bool ZONE_CONTAINER::HitTest( EDA_RECT& refArea ) if( rect.left < refArea.GetX() ) is_out_of_box = true; + if( rect.top < refArea.GetY() ) is_out_of_box = true; + if( rect.right > refArea.GetRight() ) is_out_of_box = true; + if( rect.bottom > refArea.GetBottom() ) is_out_of_box = true; @@ -1011,6 +1062,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame ) msg = _( "Zone Outline" ); int ncont = m_Poly->GetContour( m_CornerSelection ); + if( ncont ) msg << wxT( " " ) << _( "(Cutout)" ); @@ -1037,7 +1089,9 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "NetName" ), msg, RED ); } else + { frame->AppendMsgPanel( _( "Non Copper Zone" ), wxEmptyString, RED ); + } /* Display net code : (useful in test or debug) */ msg.Printf( wxT( "%d" ), GetNet() ); @@ -1053,6 +1107,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame ) msg.Printf( _( "Segments" ), m_FillMode ); else msg = _( "Polygons" ); + frame->AppendMsgPanel( _( "Fill mode" ), msg, BROWN ); // Useful for statistics : @@ -1119,7 +1174,10 @@ void ZONE_CONTAINER::MoveEdge( const wxPoint& offset ) ii = m_Poly->GetContourStart( icont ); } else + { ii++; + } + SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); m_Poly->Hatch(); diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 01b258cfe0..ed8d296bfd 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -281,7 +281,7 @@ public: * @param verbose = true to show error messages * @return error level (0 = no error) */ - int Fill_Zone( PCB_EDIT_FRAME* frame, wxDC* DC, bool verbose = TRUE ); + int Fill_Zone( PCB_EDIT_FRAME* frame, wxDC* DC, bool verbose = true ); /** * Function Fill_Zone_Areas_With_Segments diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index 8cee96172d..0c8ae7fcde 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -31,17 +31,17 @@ static void ConnectDanglingEndToVia( BOARD* pcb ); #endif -/*****************************************/ -void PCB_EDIT_FRAME::Clean_Pcb( wxDC* DC ) -/*****************************************/ /* Install the track operation dialog frame */ +void PCB_EDIT_FRAME::Clean_Pcb( wxDC* DC ) { DIALOG_CLEANING_OPTIONS::connectToPads = false; DIALOG_CLEANING_OPTIONS dlg( this ); + if( dlg.ShowModal() == wxID_OK ) Clean_Pcb_Items( this, DC, dlg.cleanVias, dlg.mergeSegments, - dlg.deleteUnconnectedSegm, dlg.connectToPads ); + dlg.deleteUnconnectedSegm, dlg.connectToPads ); + DrawPanel->Refresh( true ); } @@ -115,6 +115,7 @@ void Clean_Pcb_Items( PCB_EDIT_FRAME* frame, wxDC* DC, frame->OnModify(); } + void clean_vias( BOARD * aPcb ) { TRACK* track; @@ -127,9 +128,11 @@ void clean_vias( BOARD * aPcb ) // Search and delete others vias at same location TRACK* alt_track = track->Next(); + for( ; alt_track != NULL; alt_track = next_track ) { next_track = alt_track->Next(); + if( alt_track->m_Shape != VIA_THROUGH ) continue; @@ -146,11 +149,13 @@ void clean_vias( BOARD * aPcb ) for( track = aPcb->m_Track; track != NULL; track = next_track ) { next_track = track->Next(); + if( track->m_Shape != VIA_THROUGH ) continue; D_PAD* pad = Fast_Locate_Pad_Connecte( aPcb, track->m_Start, ALL_CU_LAYERS ); - if( pad && (pad->m_Masque_Layer & EXTERNAL_LAYERS) == EXTERNAL_LAYERS ) // redundant Via + + if( pad && (pad->m_layerMask & EXTERNAL_LAYERS) == EXTERNAL_LAYERS ) // redundant Via { /* delete via */ track->UnLink(); @@ -160,15 +165,12 @@ void clean_vias( BOARD * aPcb ) } -/*****************************************************************************/ -static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) -/*****************************************************************************/ - /* * Delete dangling tracks * Vias: * If a via is only connected to a dangling track, it also will be removed */ +static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) { TRACK* segment; TRACK* other; @@ -181,7 +183,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) if( frame->GetBoard()->m_Track == NULL ) return; - frame->DrawPanel->m_AbortRequest = FALSE; + frame->DrawPanel->m_AbortRequest = false; // correct via m_End defects for( segment = frame->GetBoard()->m_Track; segment; segment = next ) @@ -192,6 +194,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) { if( segment->m_Start != segment->m_End ) segment->m_End = segment->m_Start; + continue; } } @@ -199,6 +202,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) // removal of unconnected tracks segment = startNetcode = frame->GetBoard()->m_Track; oldnetcode = segment->GetNet(); + for( int ii = 0; segment ; segment = next, ii++ ) { next = segment->Next(); @@ -222,6 +226,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) D_PAD* pad; pad = Fast_Locate_Pad_Connecte( frame->GetBoard(), segment->m_Start, masklayer ); + if( pad != NULL ) { segment->start = pad; @@ -229,6 +234,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) } pad = Fast_Locate_Pad_Connecte( frame->GetBoard(), segment->m_End, masklayer ); + if( pad != NULL ) { segment->end = pad; @@ -239,27 +245,30 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) // For via tests, an enhancement could to test if connected to 2 items on different layers. // Currently a via must be connected to 2 items, taht can be on the same layer int top_layer, bottom_layer; + if( (type_end & START_ON_PAD ) == 0 ) { - other = Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track, NULL, START ); + other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, START ); if( other == NULL ) // Test a connection to zones { if( segment->Type() != TYPE_VIA ) { - zone = frame->GetBoard()->HitTestForAnyFilledArea(segment->m_Start, segment->GetLayer() ); + zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_Start, + segment->GetLayer() ); } - else { ((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer ); - zone = frame->GetBoard()->HitTestForAnyFilledArea(segment->m_Start, top_layer, bottom_layer ); + zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_Start, + top_layer, bottom_layer ); } } if( (other == NULL) && (zone == NULL) ) + { flag_erase |= 1; - + } else // segment, via or zone connected to this end { segment->start = other; @@ -272,12 +281,14 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) segment->SetState( BUSY, ON ); SEGVIA* via = (SEGVIA*) other; - other = Locate_Piste_Connectee( via, frame->GetBoard()->m_Track, - NULL, START ); + other = GetConnectedTrace( via, frame->GetBoard()->m_Track, NULL, START ); + if( other == NULL ) { via->ReturnLayerPair( &top_layer, &bottom_layer ); - zone = frame->GetBoard()->HitTestForAnyFilledArea(via->m_Start, bottom_layer, top_layer ); + zone = frame->GetBoard()->HitTestForAnyFilledArea( via->m_Start, + bottom_layer, + top_layer ); } if( (other == NULL) && (zone == NULL) ) @@ -291,23 +302,25 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) // if not connected to a pad, test if segment's END is connected to another track if( (type_end & END_ON_PAD ) == 0 ) { - other = Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track, - NULL, END ); + other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, END ); + if( other == NULL ) // Test a connection to zones { if( segment->Type() != TYPE_VIA ) - zone = frame->GetBoard()->HitTestForAnyFilledArea(segment->m_End, segment->GetLayer() ); - + zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_End, + segment->GetLayer() ); else { ((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer ); - zone = frame->GetBoard()->HitTestForAnyFilledArea(segment->m_End,top_layer, bottom_layer ); + zone = frame->GetBoard()->HitTestForAnyFilledArea( segment->m_End, + top_layer, bottom_layer ); } } if ( (other == NULL) && (zone == NULL) ) + { flag_erase |= 0x10; - + } else // segment, via or zone connected to this end { segment->end = other; @@ -321,12 +334,14 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) segment->SetState( BUSY, ON ); SEGVIA* via = (SEGVIA*) other; - other = Locate_Piste_Connectee( via, frame->GetBoard()->m_Track, - NULL, END ); + other = GetConnectedTrace( via, frame->GetBoard()->m_Track, NULL, END ); + if( other == NULL ) { via->ReturnLayerPair( &top_layer, &bottom_layer ); - zone = frame->GetBoard()->HitTestForAnyFilledArea(via->m_End, bottom_layer, top_layer ); + zone = frame->GetBoard()->HitTestForAnyFilledArea( via->m_End, + bottom_layer, + top_layer ); } if( (other == NULL) && (zone == NULL) ) @@ -346,7 +361,9 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) startNetcode = next; } else + { next = startNetcode; + } // remove segment from screen and board segment->Draw( frame->DrawPanel, DC, GR_XOR ); @@ -359,10 +376,8 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) } -/************************************************************/ -static void clean_segments( PCB_EDIT_FRAME* frame ) -/************************************************************/ /* Delete null lenght segments, and intermediate points .. */ +static void clean_segments( PCB_EDIT_FRAME* frame ) { TRACK* segment, * nextsegment; TRACK* other; @@ -370,12 +385,13 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) int flag, no_inc; wxString msg; - frame->DrawPanel->m_AbortRequest = FALSE; + frame->DrawPanel->m_AbortRequest = false; // Delete null segments for( segment = frame->GetBoard()->m_Track; segment; segment = nextsegment ) { nextsegment = segment->Next(); + if( !segment->IsNull() ) continue; @@ -423,6 +439,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) /* delete intermediate points */ ii = 0; + for( segment = frame->GetBoard()->m_Track; segment; segment = nextsegment ) { TRACK* segStart; @@ -430,6 +447,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) TRACK* segDelete; nextsegment = segment->Next(); + if( frame->DrawPanel->m_AbortRequest ) return; @@ -441,8 +459,8 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) // search for a possible point that connects on the START point of the segment for( segStart = segment->Next(); ; ) { - segStart = Locate_Piste_Connectee( segment, segStart, - NULL, START ); + segStart = GetConnectedTrace( segment, segStart, NULL, START ); + if( segStart ) { // the two segments must have the same width @@ -455,8 +473,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) /* We must have only one segment connected */ segStart->SetState( BUSY, ON ); - other = Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track, - NULL, START ); + other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, START ); segStart->SetState( BUSY, OFF ); if( other == NULL ) @@ -467,9 +484,10 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) break; } - if( flag ) /* We have the starting point of the segment is connecte to an other segment */ + if( flag ) // We have the starting point of the segment is connecte to an other segment { segDelete = AlignSegment( frame->GetBoard(), segment, segStart, START ); + if( segDelete ) { no_inc = 1; @@ -480,7 +498,8 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) /* search for a possible point that connects on the END point of the segment: */ for( segEnd = segment->Next(); ; ) { - segEnd = Locate_Piste_Connectee( segment, segEnd, NULL, END ); + segEnd = GetConnectedTrace( segment, segEnd, NULL, END ); + if( segEnd ) { if( segment->m_Width != segEnd->m_Width ) @@ -491,8 +510,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) /* We must have only one segment connected */ segEnd->SetState( BUSY, ON ); - other = Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track, - NULL, END ); + other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, END ); segEnd->SetState( BUSY, OFF ); if( other == NULL ) @@ -501,12 +519,15 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) break; } else + { break; + } } - if( flag & 2 ) /* We have the ending point of the segment is connecte to an other segment */ + if( flag & 2 ) // We have the ending point of the segment is connecte to an other segment { segDelete = AlignSegment( frame->GetBoard(), segment, segEnd, END ); + if( segDelete ) { no_inc = 1; @@ -522,9 +543,6 @@ static void clean_segments( PCB_EDIT_FRAME* frame ) } -/****************************************************************************/ -static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extremite ) -/****************************************************************************/ /* Function used by clean_segments. * Test alignement of pt_segm and pt_ref (which must have acommon end). * and see if the common point is not on a pad (i.e. if this common point can be removed). @@ -536,6 +554,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre * and return pt_segm (which can be deleted). * else return NULL */ +static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extremite ) { int flag = 0; @@ -570,6 +589,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre if( (refdy * segmdx != refdx * segmdy) && (refdy * segmdx != -refdx * segmdy) ) return NULL; + flag = 4; } @@ -602,7 +622,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre { /* We do not have a pad */ if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_End, - g_TabOneLayerMask[pt_ref->GetLayer()] ) ) + g_TabOneLayerMask[pt_ref->GetLayer()] ) ) return NULL; /* change the common point coordinate of pt_segm tu use the other point @@ -618,6 +638,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre return pt_segm; } } + return NULL; } @@ -644,6 +665,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) // find the netcode for segment using anything connected to the "start" of "segment" net_code_s = -1; + if( segment->start && segment->start->Type()==TYPE_PAD ) { // get the netcode of the pad to propagate. @@ -651,8 +673,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) } else { - other = Locate_Piste_Connectee( segment, GetBoard()->m_Track, - NULL, START ); + other = GetConnectedTrace( segment, GetBoard()->m_Track, NULL, START ); if( other ) net_code_s = other->GetNet(); } @@ -662,14 +683,15 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) // find the netcode for segment using anything connected to the "end" of "segment" net_code_e = -1; + if( segment->end && segment->end->Type()==TYPE_PAD ) { net_code_e = ((D_PAD*)(segment->end))->GetNet(); } else { - other = Locate_Piste_Connectee( segment, GetBoard()->m_Track, - NULL, END ); + other = GetConnectedTrace( segment, GetBoard()->m_Track, NULL, END ); + if( other ) net_code_e = other->GetNet(); } @@ -706,9 +728,6 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) #if 0 -/***************************************************************/ -static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) -/***************************************************************/ /** * Function Gen_Raccord_Track @@ -717,26 +736,30 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) * segment first being operated on. This is done so that the subsequent tests * of connection, which do not test segment overlaps, will see this continuity. */ +static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) { TRACK* segment; TRACK* other; int nn = 0; - int masquelayer; + int layerMask; int ii, percent, oldpercent; wxString msg; frame->Affiche_Message( wxT( "Gen Raccords sur Pistes:" ) ); + if( frame->GetBoard()->GetNumSegmTrack() == 0 ) return; - frame->DrawPanel->m_AbortRequest = FALSE; + frame->DrawPanel->m_AbortRequest = false; oldpercent = -1; ii = 0; + for( segment = frame->GetBoard()->m_Track; segment; segment = segment->Next() ) { // display activity ii++; percent = (100 * ii) / frame->GetBoard()->m_Track.GetCount(); + if( percent != oldpercent ) { frame->DisplayActivity( percent, wxT( "Tracks: " ) ); @@ -752,14 +775,15 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) if( frame->DrawPanel->m_AbortRequest ) return; - masquelayer = segment->ReturnMaskLayer(); + layerMask = segment->ReturnMaskLayer(); // look at the "start" of the "segment" for( other = frame->GetBoard()->m_Track; other; other = other->Next() ) { TRACK* newTrack; - other = Locate_Pistes( other, segment->m_Start, masquelayer ); + other = GetTrace( other, segment->m_Start, layerMask ); + if( other == NULL ) break; @@ -796,7 +820,7 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) other->m_End = segment->m_Start; newTrack->m_Start = segment->m_Start; - Trace_Une_Piste( frame->DrawPanel, DC, other, 2, GR_OR ); + DrawTraces( frame->DrawPanel, DC, other, 2, GR_OR ); // skip forward one, skipping the newTrack other = newTrack; @@ -807,7 +831,8 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) { TRACK* newTrack; - other = Locate_Pistes( other, segment->m_End, masquelayer ); + other = GetTrace( other, segment->m_End, layerMask ); + if( other == NULL ) break; @@ -842,7 +867,7 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) other->m_End = segment->m_End; newTrack->m_Start = segment->m_End; - Trace_Une_Piste( frame->DrawPanel, DC, other, 2, GR_OR ); + DrawTraces( frame->DrawPanel, DC, other, 2, GR_OR ); // skip forward one, skipping the newTrack other = newTrack; @@ -882,9 +907,10 @@ static void ConnectDanglingEndToVia( BOARD* pcb ) if( !via->IsOnLayer( other->GetLayer() ) ) continue; - // if the other track's m_End does not match the via position, and the track's m_Start is - // within the bounds of the via, and the other track has no start - if( other->m_End!=via->GetPosition() && via->HitTest( other->m_Start ) && !other->start ) + // if the other track's m_End does not match the via position, and the track's + // m_Start is within the bounds of the via, and the other track has no start + if( other->m_End != via->GetPosition() && via->HitTest( other->m_Start ) + && !other->start ) { TRACK* newTrack = other->Copy(); @@ -905,9 +931,10 @@ static void ConnectDanglingEndToVia( BOARD* pcb ) via->end = other; } - // if the other track's m_Start does not match the via position, and the track's m_End is - // within the bounds of the via, and the other track has no end - else if( other->m_Start!=via->GetPosition() && via->HitTest( other->m_End ) && !other->end ) + // if the other track's m_Start does not match the via position, and the track's + // m_End is within the bounds of the via, and the other track has no end + else if( other->m_Start != via->GetPosition() && via->HitTest( other->m_End ) + && !other->end ) { TRACK* newTrack = other->Copy(); @@ -932,22 +959,19 @@ static void ConnectDanglingEndToVia( BOARD* pcb ) } -/***************************************************************/ -void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) -/**************************************************************/ - /** * Function ConnectDanglingEndToPad * possibly adds a segment to the end of any and all tracks if their end is not exactly * connected into the center of the pad. This allows faster control of * connections. */ +void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) { TRACK* segment; - int nb_new_piste = 0; + int nb_new_trace = 0; wxString msg; - frame->DrawPanel->m_AbortRequest = FALSE; + frame->DrawPanel->m_AbortRequest = false; for( segment = frame->GetBoard()->m_Track; segment; segment = segment->Next() ) { @@ -957,24 +981,23 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) return; pad = Locate_Pad_Connecte( frame->GetBoard(), segment, START ); + if( pad ) { // test if the track is not precisely starting on the found pad if( segment->m_Start != pad->m_Pos ) { - if( Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track, - NULL, START ) == NULL ) + if( GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, START ) == NULL ) { TRACK* newTrack = segment->Copy(); frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); newTrack->m_End = pad->m_Pos; - newTrack->start = segment; newTrack->end = pad; - nb_new_piste++; + nb_new_trace++; newTrack->Draw( frame->DrawPanel, DC, GR_OR ); } @@ -982,13 +1005,13 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) } pad = Locate_Pad_Connecte( frame->GetBoard(), segment, END ); + if( pad ) { // test if the track is not precisely ending on the found pad if( segment->m_End != pad->m_Pos ) { - if( Locate_Piste_Connectee( segment, frame->GetBoard()->m_Track, - NULL, END ) == NULL ) + if( GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, END ) == NULL ) { TRACK* newTrack = segment->Copy(); @@ -998,7 +1021,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) newTrack->start = pad; newTrack->end = segment; - nb_new_piste++; + nb_new_trace++; } } } diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 27cfa37a1c..f46b244e7a 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -36,15 +36,15 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { // there are some restrictions on the order of items in the general case. // all items in m_Drawings for instance should be contiguous. // *** all items in a same list (shown here) must be contiguous **** - TYPE_MARKER_PCB, // in m_markers + TYPE_MARKER_PCB, // in m_markers TYPE_TEXTE, // in m_Drawings TYPE_DRAWSEGMENT, // in m_Drawings - TYPE_DIMENSION, // in m_Drawings - TYPE_MIRE, // in m_Drawings + TYPE_DIMENSION, // in m_Drawings + PCB_TARGET_T, // in m_Drawings TYPE_VIA, // in m_Tracks TYPE_TRACK, // in m_Tracks TYPE_PAD, // in modules - TYPE_TEXTE_MODULE, // in modules + TYPE_TEXTE_MODULE, // in modules TYPE_MODULE, // in m_Modules TYPE_ZONE, // in m_Zones TYPE_ZONE_CONTAINER, // in m_ZoneDescriptorList @@ -70,7 +70,7 @@ const KICAD_T GENERAL_COLLECTOR::AllButZones[] = { TYPE_TEXTE, TYPE_DRAWSEGMENT, TYPE_DIMENSION, - TYPE_MIRE, + PCB_TARGET_T, TYPE_VIA, TYPE_TRACK, TYPE_PAD, @@ -153,6 +153,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa case TYPE_PAD: { MODULE* m = (MODULE*) item->GetParent(); + if( m->GetReference() == wxT( "Y2" ) ) { breakhere++; @@ -187,6 +188,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa case TYPE_TEXTE_MODULE: { TEXTE_MODULE* tm = (TEXTE_MODULE*) item; + if( tm->m_Text == wxT( "10uH" ) ) { breakhere++; @@ -197,6 +199,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa case TYPE_MODULE: { MODULE* m = (MODULE*) item; + if( m->GetReference() == wxT( "C98" ) ) { breakhere++; @@ -217,10 +220,12 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa case TYPE_PAD: // there are pad specific visibility controls. // Criterias to select a pad is: - // for smd pads: the module parent must be seen, and pads on the corresponding board side must be seen + // for smd pads: the module parent must be seen, and pads on the corresponding + // board side must be seen // if pad is a thru hole, then it can be visible when its parent module is not. // for through pads: pads on Front or Back board sides must be seen pad = (D_PAD*) item; + if( (pad->m_Attribut != PAD_SMD) && (pad->m_Attribut != PAD_CONN) ) // a hole is present, so multiple layers { @@ -229,7 +234,10 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa pad_through = true; } else // smd, so use pads test after module test + { module = (MODULE*) item->GetParent(); + } + break; case TYPE_VIA: @@ -253,7 +261,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa case TYPE_DIMENSION: break; - case TYPE_MIRE: + case PCB_TARGET_T: break; case TYPE_TEXTE_MODULE: @@ -298,10 +306,12 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa { if( m_Guide->IgnorePads() ) goto exit; + if( ! pad_through ) { if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(LAYER_N_FRONT ) ) goto exit; + if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(LAYER_N_BACK ) ) goto exit; } diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index acc681bf07..fe261aaed3 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -23,16 +23,12 @@ static void RebuildTrackChain( BOARD* pcb ); /*..*/ -/**************************************************************************************************/ -static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_val, int new_val ) -/**************************************************************************************************/ - /** * Function Merge_Two_SubNets * Used by Propagate_SubNet() - * Change a subnet value to a new value, for tracks ans pads which are connected to corresponding track - * for pads and tracks, this is the .m_Subnet member that is tested and modified - * these members are block numbers (or cluster numbers) for a given net + * Change a subnet value to a new value, for tracks ans pads which are connected to + * corresponding track for pads and tracks, this is the .m_Subnet member that is tested + * and modified these members are block numbers (or cluster numbers) for a given net * The result is merging 2 blocks (or subnets) * @return modification count * @param old_val = subnet value to modify @@ -41,6 +37,7 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_ * @param pt_end_conn = last track segment to test * If pt_end_conn = NULL: search is made from pt_start_conn to end of linked list */ +static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_val, int new_val ) { TRACK* pt_conn; int nb_change = 0; @@ -53,12 +50,14 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_ EXCHG( old_val, new_val ); pt_conn = pt_start_conn; + for( ; pt_conn != NULL; pt_conn = pt_conn->Next() ) { if( pt_conn->GetSubNet() != old_val ) { if( pt_conn == pt_end_conn ) break; + continue; } @@ -68,6 +67,7 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_ if( pt_conn->start && ( pt_conn->start->Type() == TYPE_PAD) ) { pt_pad = (D_PAD*) (pt_conn->start); + if( pt_pad->GetSubNet() == old_val ) pt_pad->SetSubNet( pt_conn->GetSubNet() ); } @@ -75,9 +75,11 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_ if( pt_conn->end && (pt_conn->end->Type() == TYPE_PAD) ) { pt_pad = (D_PAD*) (pt_conn->end); + if( pt_pad->GetSubNet() == old_val ) pt_pad->SetSubNet( pt_conn->GetSubNet() ); } + if( pt_conn == pt_end_conn ) break; } @@ -86,39 +88,42 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_ } -/******************************************************************/ -static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) -/******************************************************************/ /** * Function Propagate_SubNet - * Test a list of track segment, to create or propagate a sub netcode to pads and segments connected together - * the track list must be sorted by nets, and all segments from pt_start_conn to pt_end_conn have the same net - * When 2 items are connected (a track to a pad, or a track to an other track) they are grouped in a cluster. + * Test a list of track segments, to create or propagate a sub netcode to pads and + * segments connected together the track list must be sorted by nets, and all segments + * from pt_start_conn to pt_end_conn have the same net when 2 items are connected (a + * track to a pad, or a track to an other track) they are grouped in a cluster. * for pads, this is the .m_physical_connexion member which is a cluster identifier * for tracks, this is the .m_Subnet member which is a cluster identifier * For a given net, if all tracks are created, there is only one cluster. - * but if not all tracks are created, there are more than one cluster, and some ratsnets will be shown. + * but if not all tracks are created, there are more than one cluster, and some ratsnets + * will be shown. * @param pt_start_conn = first track to test * @param pt_end_conn = last segment to test */ +static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) { TRACK* pt_conn; int sub_netcode; D_PAD* pt_pad; - TRACK* pt_autre_piste; + TRACK* pt_other_trace; BOARD_ITEM* PtStruct; /* Clear variables used in computations */ pt_conn = pt_start_conn; + for( ; pt_conn != NULL; pt_conn = pt_conn->Next() ) { pt_conn->SetSubNet( 0 ); PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) ( (D_PAD*) PtStruct )->SetSubNet( 0 ); PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) ( (D_PAD*) PtStruct )->SetSubNet( 0 ); @@ -131,6 +136,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) /* Start of calculation */ pt_conn = pt_start_conn; + for( ; pt_conn != NULL; pt_conn = pt_conn->Next() ) { /* First: handling connections to pads */ @@ -140,19 +146,20 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) { pt_pad = (D_PAD*) PtStruct; - if( pt_conn->GetSubNet() ) /* the track segment is already a cluster member */ + + if( pt_conn->GetSubNet() ) /* the track segment is already a cluster member */ { - if( pt_pad->GetSubNet() > 0 ) /* The pad is already a cluster member, so we can merge the 2 clusters */ + if( pt_pad->GetSubNet() > 0 ) /* The pad is already a cluster member, so we can merge the 2 clusters */ { Merge_Two_SubNets( pt_start_conn, pt_end_conn, - pt_pad->GetSubNet(), pt_conn->GetSubNet() ); + pt_pad->GetSubNet(), pt_conn->GetSubNet() ); } else /* The pad is not yet attached to a cluster , so we can add this pad to the cluster */ pt_pad->SetSubNet( pt_conn->GetSubNet() ); } - else /* the track segment is not attached to a cluster */ + else /* the track segment is not attached to a cluster */ { - if( pt_pad->GetSubNet() > 0 ) /* it is connected to a pad in a cluster, merge this track */ + if( pt_pad->GetSubNet() > 0 ) /* it is connected to a pad in a cluster, merge this track */ { pt_conn->SetSubNet( pt_pad->GetSubNet() ); } @@ -166,19 +173,23 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) } PtStruct = pt_conn->end; + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) /* The segment end on a pad */ { pt_pad = (D_PAD*) PtStruct; + if( pt_conn->GetSubNet() ) { if( pt_pad->GetSubNet() > 0 ) { Merge_Two_SubNets( pt_start_conn, pt_end_conn, - pt_pad->GetSubNet(), pt_conn->GetSubNet() ); + pt_pad->GetSubNet(), pt_conn->GetSubNet() ); } else + { pt_pad->SetSubNet( pt_conn->GetSubNet() ); + } } else { @@ -198,85 +209,88 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ) /* Test connections between segments */ PtStruct = pt_conn->start; + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { /* The segment starts on an other track */ - pt_autre_piste = (TRACK*) PtStruct; + pt_other_trace = (TRACK*) PtStruct; if( pt_conn->GetSubNet() ) /* the track segment is already a cluster member */ { - if( pt_autre_piste->GetSubNet() ) /* The other track is already a cluster member, so we can merge the 2 clusters */ + if( pt_other_trace->GetSubNet() ) /* The other track is already a cluster member, so we can merge the 2 clusters */ { Merge_Two_SubNets( pt_start_conn, pt_end_conn, - pt_autre_piste->GetSubNet(), pt_conn->GetSubNet() ); + pt_other_trace->GetSubNet(), pt_conn->GetSubNet() ); } else /* The other track is not yet attached to a cluster , so we can add this other track to the cluster */ { - pt_autre_piste->SetSubNet( pt_conn->GetSubNet() ); + pt_other_trace->SetSubNet( pt_conn->GetSubNet() ); } } else /* the track segment is not yet attached to a cluster */ { - if( pt_autre_piste->GetSubNet() ) /* The other track is already a cluster member, so we can add the segment to the cluster */ + if( pt_other_trace->GetSubNet() ) /* The other track is already a cluster member, so we can add the segment to the cluster */ { - pt_conn->SetSubNet( pt_autre_piste->GetSubNet() ); + pt_conn->SetSubNet( pt_other_trace->GetSubNet() ); } else /* it is connected to an other segment not in a cluster, so we must create a new cluster (only with the 2 track segments) */ { sub_netcode++; pt_conn->SetSubNet( sub_netcode ); - pt_autre_piste->SetSubNet( pt_conn->GetSubNet() ); + pt_other_trace->SetSubNet( pt_conn->GetSubNet() ); } } } PtStruct = pt_conn->end; // Do the same calculations for the segment end point + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { - pt_autre_piste = (TRACK*) PtStruct; + pt_other_trace = (TRACK*) PtStruct; if( pt_conn->GetSubNet() ) /* the track segment is already a cluster member */ { - if( pt_autre_piste->GetSubNet() ) + if( pt_other_trace->GetSubNet() ) { Merge_Two_SubNets( pt_start_conn, pt_end_conn, - pt_autre_piste->GetSubNet(), pt_conn->GetSubNet() ); + pt_other_trace->GetSubNet(), pt_conn->GetSubNet() ); } else - pt_autre_piste->SetSubNet( pt_conn->GetSubNet() ); + { + pt_other_trace->SetSubNet( pt_conn->GetSubNet() ); + } } else /* the track segment is not yet attached to a cluster */ { - if( pt_autre_piste->GetSubNet() ) + if( pt_other_trace->GetSubNet() ) { - pt_conn->SetSubNet( pt_autre_piste->GetSubNet() ); + pt_conn->SetSubNet( pt_other_trace->GetSubNet() ); } else { sub_netcode++; pt_conn->SetSubNet( sub_netcode ); - pt_autre_piste->SetSubNet( pt_conn->GetSubNet() ); + pt_other_trace->SetSubNet( pt_conn->GetSubNet() ); } } } + if( pt_conn == pt_end_conn ) break; } } -/***************************************************/ -void PCB_BASE_FRAME::test_connexions( wxDC* DC ) -/***************************************************/ - /** * Function testing the connections relative to all nets - * This function update the status of the ratsnest ( flag CH_ACTIF = 0 if a connection is found, = 1 else) - * track segments are assumed to be sorted by net codes. - * This is the case because when a new track is added, it is inserted in the linked list according to its net code. - * and when nets are changed (when a new netlist is read) tracks are sorted before using this function + * This function update the status of the ratsnest ( flag CH_ACTIF = 0 if a connection + * is found, = 1 else) track segments are assumed to be sorted by net codes. + * This is the case because when a new track is added, it is inserted in the linked list + * according to its net code. and when nets are changed (when a new netlist is read) + * tracks are sorted before using this function * @param DC = current Device Context */ +void PCB_BASE_FRAME::test_connexions( wxDC* DC ) { // Clear the cluster identifier for all pads for( unsigned i = 0; i< m_Pcb->GetPadsCount(); ++i ) @@ -290,7 +304,7 @@ void PCB_BASE_FRAME::test_connexions( wxDC* DC ) m_Pcb->Test_Connections_To_Copper_Areas(); // Test existing connections net by net - for( TRACK* track = m_Pcb->m_Track; track; ) + for( TRACK* track = m_Pcb->m_Track; track; ) { // this is the current net because pt_start_conn is the first segment of the net int current_net_code = track->GetNet(); @@ -309,16 +323,13 @@ void PCB_BASE_FRAME::test_connexions( wxDC* DC ) } -/*************************************************************************/ -void PCB_BASE_FRAME::test_1_net_connexion( wxDC* DC, int net_code ) -/*************************************************************************/ - /** * Function testing the connections relative to a given net * track segments are assumed to be sorted by net codes * @param DC = current Device Context * @param net_code = net code to test */ +void PCB_BASE_FRAME::test_1_net_connexion( wxDC* DC, int net_code ) { wxString msg; @@ -326,7 +337,7 @@ void PCB_BASE_FRAME::test_1_net_connexion( wxDC* DC, int net_code ) return; if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) - Compile_Ratsnest( DC, TRUE ); + Compile_Ratsnest( DC, true ); for( unsigned i = 0; iGetPadsCount(); ++i ) { @@ -355,11 +366,12 @@ void PCB_BASE_FRAME::test_1_net_connexion( wxDC* DC, int net_code ) if( pt_start_conn ) pt_end_conn = pt_start_conn->GetEndNetCode( net_code ); - if( pt_start_conn && pt_end_conn ) // c.a.d. s'il y a des segments + if( pt_start_conn && pt_end_conn ) // c.a.d. if there are segments { Build_Pads_Info_Connections_By_Tracks( pt_start_conn, pt_end_conn ); } } + Merge_SubNets_Connected_By_CopperAreas( m_Pcb, net_code ); /* Test the rastnest for this net */ @@ -375,10 +387,6 @@ void PCB_BASE_FRAME::test_1_net_connexion( wxDC* DC, int net_code ) } -/*******************************************************************************************/ -static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* pt_end_conn ) -/*******************************************************************************************/ - /** Used after a track change (delete a track ou add a track) * Compute connections (initialize the .start and .end members) for a single net. * tracks must be sorted by net, as usual @@ -388,6 +396,7 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* * If a track is deleted, the other pointers to pads do not change. * When a track is added, its pointers to pads are already initialized */ +static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* pt_end_conn ) { TRACK* Track; @@ -413,6 +422,7 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* { TRACK* pt_segm; int layermask = Track->ReturnMaskLayer(); + for( pt_segm = pt_start_conn; pt_segm != NULL; pt_segm = pt_segm->Next() ) { int curlayermask = pt_segm->ReturnMaskLayer(); @@ -428,6 +438,7 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* { pt_segm->end = Track; } + if( pt_segm == pt_end_conn ) break; } @@ -435,12 +446,12 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* if( Track->start == NULL ) // end track not already connected, search a connection { - Track->start = Locate_Piste_Connectee( Track, Track, pt_end_conn, START ); + Track->start = GetConnectedTrace( Track, Track, pt_end_conn, START ); } if( Track->end == NULL ) // end track not already connected, search a connection { - Track->end = Locate_Piste_Connectee( Track, Track, pt_end_conn, END ); + Track->end = GetConnectedTrace( Track, Track, pt_end_conn, END ); } if( Track == pt_end_conn ) @@ -460,18 +471,19 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* * A track is seen as connected if the px, py position is same as the pad position. * * @param aPcb = the board. - * @param pt_liste = Pointers to pads buffer - * This buffer is a list like the list created by build_liste_pad, but sorted by increasing X pad coordinate + * @param pt_liste = Pointers to pads buffer. This buffer is a list like the list + * created by build_liste_pad, but sorted by increasing X pad coordinate * @param posref = reference coordinate - * @param masque_layer = Layers (bit to bit) to consider - * @return : pointer on the connected pad - * This function uses a fast search in this sorted pad list and it is faster than Fast_Locate_Pad_connecte(), + * @param aLayerMask = Layers (bit to bit) to consider + * @return : pointer on the connected pad. This function uses a fast search in this sorted + * pad list and it is faster than Fast_Locate_Pad_connecte(), * But this sorted pad list must be built before calling this function. * - * (Note: The usual pad list (created by build_liste_pad) m_Pcb->m_Pads is sorted by increasing netcodes ) + * (Note: The usual pad list (created by build_liste_pad) m_Pcb->m_Pads is sorted by + * increasing netcodes ) */ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, - const wxPoint& posref, int masque_layer ) + const wxPoint& posref, int aLayerMask ) { D_PAD* pad; int ii; @@ -481,6 +493,7 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, LISTE_PAD* lim = pt_liste + nb_pad - 1; ptr_pad = pt_liste; + while( nb_pad ) { pad = *ptr_pad; @@ -493,15 +506,20 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, if( pad->m_Pos.x < posref.x ) /* Must search after this item */ { ptr_pad += nb_pad; + if( ptr_pad > lim ) ptr_pad = lim; + continue; } + if( pad->m_Pos.x > posref.x ) /* Must search before this item */ { ptr_pad -= nb_pad; + if( ptr_pad < pt_liste ) ptr_pad = pt_liste; + continue; } @@ -511,6 +529,7 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, while( ptr_pad >= pt_liste ) { pad = *ptr_pad; + if( pad->m_Pos.x == posref.x ) ptr_pad--; else @@ -525,6 +544,7 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, return NULL; /* outside suitable block */ pad = *ptr_pad; + if( pad->m_Pos.x != posref.x ) return NULL; /* outside suitable block */ @@ -532,7 +552,7 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, continue; /* A Pad if found here: but it must mach the layer */ - if( pad->m_Masque_Layer & masque_layer ) // Matches layer => a connected pad is found ! + if( pad->m_layerMask & aLayerMask ) // Matches layer => a connected pad is found ! return pad; } } @@ -555,48 +575,47 @@ static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp ) } -/*****************************************************************************/ void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector* aVector ) -/*****************************************************************************/ { - aVector->insert( aVector->end(), aBoard->m_NetInfo->m_PadsFullList.begin(), aBoard->m_NetInfo->m_PadsFullList.end() ); + aVector->insert( aVector->end(), aBoard->m_NetInfo->m_PadsFullList.begin(), + aBoard->m_NetInfo->m_PadsFullList.end() ); qsort( &(*aVector)[0], aBoard->GetPadsCount(), sizeof( D_PAD*), SortPadsByXCoord ); } -/********************************************************************/ -void PCB_BASE_FRAME::RecalculateAllTracksNetcode() -/********************************************************************/ - /* search connections between tracks and pads, and propagate pad net codes to the track segments * This is a 2 pass computation. * First: - * We search a connection between a track segment and a pad: if found : this segment netcode is set to the pad netcode + * We search a connection between a track segment and a pad: if found : this segment netcode + * is set to the pad netcode */ +void PCB_BASE_FRAME::RecalculateAllTracksNetcode() { - TRACK* pt_piste; + TRACK* pt_trace; TRACK* pt_next; char new_passe_request = 1; std::vector sortedPads; BOARD_ITEM* PtStruct; - int masque_layer; + int layerMask; wxString msg; // Build the net info list GetBoard()->m_NetInfo->BuildListOfNets(); - if( m_Pcb->GetPadsCount() == 0 ) // If no pad, reset pointers and netcode, and do nothing else + if( m_Pcb->GetPadsCount() == 0 ) // If no pad, reset pointers and netcode, and do nothing else { - pt_piste = m_Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) + pt_trace = m_Pcb->m_Track; + + for( ; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - pt_piste->start = NULL; - pt_piste->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); - pt_piste->SetNet( 0 ); - pt_piste->end = NULL; + pt_trace->start = NULL; + pt_trace->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + pt_trace->SetNet( 0 ); + pt_trace->end = NULL; } + return; } @@ -606,43 +625,45 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() CreateSortedPadListByXCoord( m_Pcb, &sortedPads ); /* Reset variables and flags used in computation */ - pt_piste = m_Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) + pt_trace = m_Pcb->m_Track; + + for( ; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - pt_piste->SetState( BUSY | IN_EDIT | BEGIN_ONPAD | END_ONPAD, OFF ); - pt_piste->SetZoneSubNet( 0 ); - pt_piste->SetNet( 0 ); // net code = 0 means not connected + pt_trace->SetState( BUSY | IN_EDIT | BEGIN_ONPAD | END_ONPAD, OFF ); + pt_trace->SetZoneSubNet( 0 ); + pt_trace->SetNet( 0 ); // net code = 0 means not connected } /* First pass: search connection between a track segment and a pad. * if found, set the track net code to the pad netcode */ - pt_piste = m_Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) + pt_trace = m_Pcb->m_Track; + + for( ; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - masque_layer = g_TabOneLayerMask[pt_piste->GetLayer()]; + layerMask = g_TabOneLayerMask[pt_trace->GetLayer()]; /* Search for a pad on the segment starting point */ - pt_piste->start = SuperFast_Locate_Pad_Connecte( m_Pcb, + pt_trace->start = SuperFast_Locate_Pad_Connecte( m_Pcb, &sortedPads[0], - pt_piste->m_Start, - masque_layer ); - if( pt_piste->start != NULL ) + pt_trace->m_Start, + layerMask ); + if( pt_trace->start != NULL ) { - pt_piste->SetState( BEGIN_ONPAD, ON ); - pt_piste->SetNet( ( (D_PAD*) (pt_piste->start) )->GetNet() ); + pt_trace->SetState( BEGIN_ONPAD, ON ); + pt_trace->SetNet( ( (D_PAD*) (pt_trace->start) )->GetNet() ); } /* Search for a pad on the segment ending point */ - pt_piste->end = SuperFast_Locate_Pad_Connecte( m_Pcb, + pt_trace->end = SuperFast_Locate_Pad_Connecte( m_Pcb, &sortedPads[0], - pt_piste->m_End, - masque_layer ); + pt_trace->m_End, + layerMask ); - if( pt_piste->end != NULL ) + if( pt_trace->end != NULL ) { - pt_piste->SetState( END_ONPAD, ON ); - pt_piste->SetNet( ( (D_PAD*) (pt_piste->end) )->GetNet() ); + pt_trace->SetState( END_ONPAD, ON ); + pt_trace->SetNet( ( (D_PAD*) (pt_trace->end) )->GetNet() ); } } @@ -657,16 +678,16 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() * when a track has a net code and the other has a null net code, the null net code is changed */ - for( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next() ) + for( pt_trace = m_Pcb->m_Track; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - if( pt_piste->start == NULL ) + if( pt_trace->start == NULL ) { - pt_piste->start = Locate_Piste_Connectee( pt_piste, m_Pcb->m_Track, NULL, START ); + pt_trace->start = GetConnectedTrace( pt_trace, m_Pcb->m_Track, NULL, START ); } - if( pt_piste->end == NULL ) + if( pt_trace->end == NULL ) { - pt_piste->end = Locate_Piste_Connectee( pt_piste, m_Pcb->m_Track, NULL, END ); + pt_trace->end = GetConnectedTrace( pt_trace, m_Pcb->m_Track, NULL, END ); } } @@ -676,7 +697,7 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() while( new_passe_request ) { - bool reset_flag = FALSE; + bool reset_flag = false; new_passe_request = 0; /* look for vias which could be connect many tracks */ @@ -690,77 +711,83 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() // Lock for a connection to a track with a known netcode pt_next = m_Pcb->m_Track; - while( ( pt_next = Locate_Piste_Connectee( via, pt_next, NULL, START ) ) != NULL ) + + while( ( pt_next = GetConnectedTrace( via, pt_next, NULL, START ) ) != NULL ) { if( pt_next->GetNet() ) { via->SetNet( pt_next->GetNet() ); break; } + pt_next->SetState( BUSY, ON ); - reset_flag = TRUE; + reset_flag = true; } } if( reset_flag ) - for( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next() ) + for( pt_trace = m_Pcb->m_Track; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - pt_piste->SetState( BUSY, OFF ); + pt_trace->SetState( BUSY, OFF ); } - /* set the netcode of connected tracks: if at track is connected to a pad, its net code is already set. + /* set the netcode of connected tracks: if at track is connected to a pad, its net + * code is already set. * if the current track is connected to an other track: * if a track has a net code, it is used for the other track. * Thus there is a propagation of the netcode from a track to an other. * if none of the 2 track has a net code we do nothing * the iteration is stopped when no new change occurs */ - for( pt_piste = m_Pcb->m_Track; pt_piste != NULL; pt_piste = pt_piste->Next() ) + for( pt_trace = m_Pcb->m_Track; pt_trace != NULL; pt_trace = pt_trace->Next() ) { /* look for the connection to the current segment starting point */ - PtStruct = (BOARD_ITEM*) pt_piste->start; + PtStruct = (BOARD_ITEM*) pt_trace->start; + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { // Begin on an other track segment pt_next = (TRACK*) PtStruct; - if( pt_piste->GetNet() ) + + if( pt_trace->GetNet() ) { if( pt_next->GetNet() == 0 ) // the current track has a netcode, we use it for the other track { new_passe_request = 1; // A change is made: a new iteration is requested. - pt_next->SetNet( pt_piste->GetNet() ); + pt_next->SetNet( pt_trace->GetNet() ); } } else { if( pt_next->GetNet() != 0 ) // the other track has a netcode, we use it for the current track { - pt_piste->SetNet( pt_next->GetNet() ); + pt_trace->SetNet( pt_next->GetNet() ); new_passe_request = 1; } } } /* look for the connection to the current segment ending point */ - PtStruct = pt_piste->end; - if( PtStruct &&(PtStruct->Type() != TYPE_PAD) ) + PtStruct = pt_trace->end; + + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { pt_next = (TRACK*) PtStruct; // End on an other track: propagate netcode if possible - if( pt_piste->GetNet() ) + if( pt_trace->GetNet() ) { if( pt_next->GetNet() == 0 ) { new_passe_request = 1; - pt_next->SetNet( pt_piste->GetNet() ); + pt_next->SetNet( pt_trace->GetNet() ); } } else { if( pt_next->GetNet() != 0 ) { - pt_piste->SetNet( pt_next->GetNet() ); + pt_trace->SetNet( pt_next->GetNet() ); new_passe_request = 1; } } diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index ae3dc70700..344db56e5b 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -33,7 +33,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) D( g_CurrentTrackList.VerifyListIntegrity(); ) // Delete the current trace - ShowNewTrackWhenMovingCursor( DrawPanel, DC, wxDefaultPosition, FALSE ); + ShowNewTrackWhenMovingCursor( DrawPanel, DC, wxDefaultPosition, false ); // delete the most recently entered delete g_CurrentTrackList.PopBack(); @@ -51,13 +51,11 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) } } - while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() == - TYPE_VIA ) + while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() == TYPE_VIA ) { delete g_CurrentTrackList.PopBack(); - if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() != - TYPE_VIA ) + if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() != TYPE_VIA ) previous_layer = g_CurrentTrackSegment->GetLayer(); } @@ -66,8 +64,8 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) setActiveLayer( previous_layer ); UpdateStatusBar(); - if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, - // or 0 + + if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 { if( g_CurrentTrackList.GetCount() == 1 && g_CurrentTrackSegment->Type() != TYPE_VIA ) @@ -89,7 +87,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) else { if( DrawPanel->IsMouseCaptured() ) - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); return g_CurrentTrackSegment; } @@ -178,8 +176,9 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) if( pt_segm == NULL ) return; - TRACK* trackList = Marque_Une_Piste( GetBoard(), pt_segm, - &segments_to_delete_count, NULL, NULL, true ); + TRACK* trackList = MarkTrace( GetBoard(), pt_segm, &segments_to_delete_count, + NULL, NULL, true ); + if( segments_to_delete_count == 0 ) return; @@ -190,6 +189,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) int ii = 0; TRACK* tracksegment = trackList; TRACK* next_track; + for( ; ii < segments_to_delete_count; ii++, tracksegment = next_track ) { next_track = tracksegment->Next(); @@ -198,9 +198,9 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) //D( printf( "%s: track %p status=\"%s\"\n", __func__, tracksegment, // TO_UTF8( TRACK::ShowState( tracksegment->GetState( -1 ) ) ) // ); ) - D( std::cout<<__func__<<": track "< g_DragSegmentList; /* Functions */ -void Dessine_Segments_Dragges( EDA_DRAW_PANEL* panel, wxDC* DC ); +void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC ); void Build_Drag_Liste( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module ); void Build_1_Pad_SegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, D_PAD* PtPad ); void Collect_TrackSegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, - wxPoint& point, int MasqueLayer, int net_code ); + wxPoint& point, int LayerMask, int net_code ); /** diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 37d74bd830..7d9fc00cb0 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -26,10 +26,8 @@ DRAG_SEGM::DRAG_SEGM( TRACK* segm ) } -/*******************************************************************/ -void Dessine_Segments_Dragges( EDA_DRAW_PANEL* panel, wxDC* DC ) -/*******************************************************************/ /* Redraw the list of segments starting in g_DragSegmentList, while moving a footprint */ +void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC ) { D_PAD* pt_pad; TRACK* Track; @@ -45,6 +43,7 @@ void Dessine_Segments_Dragges( EDA_DRAW_PANEL* panel, wxDC* DC ) Track->Draw( panel, DC, GR_XOR ); // erase from screen at old position #endif pt_pad = g_DragSegmentList[ii].m_Pad_Start; + if( pt_pad ) { pos = pt_pad->m_Pos - g_Offset_Module; @@ -52,6 +51,7 @@ void Dessine_Segments_Dragges( EDA_DRAW_PANEL* panel, wxDC* DC ) } pt_pad = g_DragSegmentList[ii].m_Pad_End; + if( pt_pad ) { pos = pt_pad->m_Pos - g_Offset_Module; @@ -63,18 +63,17 @@ void Dessine_Segments_Dragges( EDA_DRAW_PANEL* panel, wxDC* DC ) } -/*************************************************************************/ -void Build_Drag_Liste( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module ) -/*************************************************************************/ /** Build the list of track segments connected to pads of a given module * by populate the std::vector g_DragSegmentList * For each selected track segment set the EDIT flag * and redraw them in EDIT mode (sketch mode) */ +void Build_Drag_Liste( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module ) { D_PAD* pt_pad; pt_pad = Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() ) { Build_1_Pad_SegmentsToDrag( panel, DC, pt_pad ); @@ -84,32 +83,31 @@ void Build_Drag_Liste( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module ) } -/**********************************************************************************/ -void Build_1_Pad_SegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, D_PAD* PtPad ) -/**********************************************************************************/ /** Build the list of track segments connected to a given pad * by populate the std::vector g_DragSegmentList * For each selected track segment set the EDIT flag * and redraw them in EDIT mode (sketch mode) * Net codes must be OK. */ +void Build_1_Pad_SegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, D_PAD* PtPad ) { TRACK* Track; int net_code = PtPad->GetNet(); - int MasqueLayer; + int LayerMask; wxPoint pos; BOARD* pcb = ( (PCB_BASE_FRAME*)( panel->GetParent() ) )->GetBoard(); Track = pcb->m_Track->GetStartNetCode( net_code ); pos = PtPad->m_Pos; - MasqueLayer = PtPad->m_Masque_Layer; + LayerMask = PtPad->m_layerMask; + for( ; Track; Track = Track->Next() ) { if( Track->GetNet() != net_code ) break; - if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) + if( ( LayerMask & Track->ReturnMaskLayer() ) == 0 ) continue; if( pos == Track->m_Start ) @@ -127,12 +125,10 @@ void Build_1_Pad_SegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, D_PAD* PtPad ) } -/******************************************************************/ -void AddSegmentToDragList( EDA_DRAW_PANEL* panel, wxDC* DC, int flag, TRACK* Track ) -/******************************************************************/ /* Add the segment"Track" to the drag list, and erase it from screen * flag = STARTPOINT (if the point to drag is the start point of Track) or ENDPOINT */ +void AddSegmentToDragList( EDA_DRAW_PANEL* panel, wxDC* DC, int flag, TRACK* Track ) { DRAG_SEGM wrapper( Track ); @@ -156,15 +152,12 @@ void AddSegmentToDragList( EDA_DRAW_PANEL* panel, wxDC* DC, int flag, TRACK* Tra } -/**********************************************************************************/ -void Collect_TrackSegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, - wxPoint& aRefPos, int MasqueLayer, int net_code ) -/**********************************************************************************/ - /* Build the list of tracks connected to the ref point * Net codes must be OK. * @param aRefPos = reference point of connection */ +void Collect_TrackSegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, + wxPoint& aRefPos, int LayerMask, int net_code ) { BOARD* pcb = ( (PCB_BASE_FRAME*)( panel->GetParent() ) )->GetBoard(); @@ -175,7 +168,7 @@ void Collect_TrackSegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, if( track->GetNet() != net_code ) // Bad net, not connected break; - if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 ) + if( ( LayerMask & track->ReturnMaskLayer() ) == 0 ) continue; // Cannot be connected, not on the same layer if( track->m_Flags & IS_DRAGGED ) @@ -194,12 +187,12 @@ void Collect_TrackSegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, if( flag ) { AddSegmentToDragList( panel, DC, flag, track ); + // If a connected via is found at location aRefPos, // collect also tracks connected by this via. if( track->Type() == TYPE_VIA ) - Collect_TrackSegmentsToDrag( panel, DC, aRefPos, - track->ReturnMaskLayer(), - net_code ); + Collect_TrackSegmentsToDrag( panel, DC, aRefPos, track->ReturnMaskLayer(), + net_code ); } } } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index bb257c0fbb..4923c48668 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -228,6 +228,7 @@ void DRC::RunTests( wxTextCtrl* aMessages ) aMessages->AppendText( _( "Fill zones...\n" ) ); wxSafeYield(); } + m_mainWindow->Fill_All_Zones( false ); // test zone clearances to other zones, pads, tracks, and vias @@ -263,9 +264,7 @@ void DRC::RunTests( wxTextCtrl* aMessages ) } -/***************************************************************/ void DRC::ListUnconnectedPads() -/***************************************************************/ { testUnconnected(); @@ -408,9 +407,7 @@ bool DRC::testNetClasses() } -/***********************/ void DRC::testPad2Pad() -/***********************/ { std::vector sortedPads; @@ -466,7 +463,7 @@ void DRC::testUnconnected() if( (m_pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) { wxClientDC dc( m_mainWindow->DrawPanel ); - m_mainWindow->Compile_Ratsnest( &dc, TRUE ); + m_mainWindow->Compile_Ratsnest( &dc, true ); } if( m_pcb->GetRatsnestsCount() == 0 ) @@ -475,6 +472,7 @@ void DRC::testUnconnected() for( unsigned ii = 0; ii < m_pcb->GetRatsnestsCount(); ++ii ) { RATSNEST_ITEM* rat = &m_pcb->m_FullRatsnest[ii]; + if( (rat->m_Status & CH_ACTIF) == 0 ) continue; @@ -491,9 +489,7 @@ void DRC::testUnconnected() } -/**********************************************/ void DRC::testZones( bool adoTestFillSegments ) -/**********************************************/ { // Test copper areas for valide netcodes // if a netcode is < 0 the netname was not found when reading a netlist @@ -502,8 +498,10 @@ void DRC::testZones( bool adoTestFillSegments ) for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* Area_To_Test = m_pcb->GetArea( ii ); + if( !Area_To_Test->IsOnCopperLayer() ) continue; + if( Area_To_Test->GetNet() < 0 ) { m_currentMarker = fillMarker( Area_To_Test, @@ -536,6 +534,7 @@ void DRC::testZones( bool adoTestFillSegments ) // Pads already tested: disable pad test bool rc = doTrackDrc( zoneSeg, m_pcb->m_Track, false ); + if( !rc ) { wxASSERT( m_currentMarker ); @@ -546,12 +545,9 @@ void DRC::testZones( bool adoTestFillSegments ) } -/*****************************************************************************/ -bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, - int x_limit ) -/*****************************************************************************/ +bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, int x_limit ) { - int layerMask = aRefPad->m_Masque_Layer & ALL_CU_LAYERS; + int layerMask = aRefPad->m_layerMask & ALL_CU_LAYERS; /* used to test DRC pad to holes: this dummy pad has the size and shape of the hole * to test pad to pad hole DRC, using the pad to pad DRC test function. @@ -561,7 +557,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, */ MODULE dummymodule( m_pcb ); // Creates a dummy parent D_PAD dummypad( &dummymodule ); - dummypad.m_Masque_Layer |= ALL_CU_LAYERS; // Ensure the hole is on all copper layers + dummypad.m_layerMask |= ALL_CU_LAYERS; // Ensure the hole is on all copper layers dummypad.m_LocalClearance = 1; /* Use the minimal local clerance value for the dummy pad * the clearance of the active pad will be used * as minimum distance to a hole @@ -571,6 +567,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, for( LISTE_PAD* pad_list = aStart; pad_listm_Masque_Layer & layerMask ) == 0 ) + if( (pad->m_layerMask & layerMask ) == 0 ) { // if holes are in the same location and have the same size and shape, // this can be accepted @@ -592,6 +589,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, { if( aRefPad->m_DrillShape == PAD_CIRCLE ) continue; + if( pad->m_Orient == aRefPad->m_Orient ) // for oval holes: must also have the same orientation continue; } @@ -606,6 +604,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, dummypad.m_PadShape = (pad->m_DrillShape == PAD_OVAL) ? PAD_OVAL : PAD_CIRCLE; dummypad.m_Orient = pad->m_Orient; dummypad.ComputeShapeMaxRadius(); // compute the radius of the circle containing this pad + if( !checkClearancePadToPad( aRefPad, &dummypad ) ) { // here we have a drc error on pad! @@ -630,6 +629,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, return false; } } + continue; } @@ -654,8 +654,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, if( !checkClearancePadToPad( aRefPad, pad ) ) { // here we have a drc error! - m_currentMarker = fillMarker( aRefPad, pad, - DRCE_PAD_NEAR_PAD1, m_currentMarker ); + m_currentMarker = fillMarker( aRefPad, pad, DRCE_PAD_NEAR_PAD1, m_currentMarker ); return false; } } diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index 28b527f3d7..aabb6cad7a 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -52,10 +52,12 @@ bool trapezoid2trapezoidDRC( wxPoint aTref[4], wxPoint aTcompare[4], int aDist ) */ if( TestPointInsidePolygon( aTref, 4, aTcompare[0] ) ) return false; + if( TestPointInsidePolygon( aTcompare, 4, aTref[0] ) ) return false; int ii, jj, kk, ll; + for( ii = 0, jj = 3; ii<4; jj = ii, ii++ ) // for all edges in aTref { for( kk = 0, ll = 3; kk < 4; ll = kk, kk++ ) // for all edges in aTcompare @@ -91,6 +93,7 @@ bool trapezoid2segmentDRC( wxPoint aTref[4], wxPoint aSegStart, wxPoint aSegEnd, return false; int ii, jj; + for( ii = 0, jj = 3; ii < 4; jj = ii, ii++ ) // for all edges in aTref { double d; @@ -128,6 +131,7 @@ bool trapezoid2pointDRC( wxPoint aTref[4], wxPoint aPcompare, int aDist ) // Test distance between aPcompare and polygon edges: int ii, jj; double dist = (double) aDist; + for( ii = 0, jj = 3; ii < 4; jj = ii, ii++ ) // for all edges in polygon { if( TestLineHit( aTref[ii].x, aTref[ii].y, @@ -140,9 +144,7 @@ bool trapezoid2pointDRC( wxPoint aTref[4], wxPoint aPcompare, int aDist ) return true; } -/***********************************************************************/ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) -/***********************************************************************/ { TRACK* track; wxPoint delta; // lenght on X and Y axis of segments @@ -205,15 +207,18 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) bool err = true; ( (SEGVIA*) aRefSeg )->ReturnLayerPair( &layer1, &layer2 ); - if( layer1> layer2 ) + + if( layer1 > layer2 ) EXCHG( layer1, layer2 ); // test: if( layer1 == LAYER_N_BACK && layer2 == LAYER_N_2 ) err = false; + if( layer1 == (m_pcb->GetBoardDesignSettings()->GetCopperLayerCount() - 2 ) && layer2 == LAYER_N_FRONT ) err = false; + if( err ) { m_currentMarker = fillMarker( aRefSeg, NULL, @@ -260,7 +265,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) */ MODULE dummymodule( m_pcb ); // Creates a dummy parent D_PAD dummypad( &dummymodule ); - dummypad.m_Masque_Layer = ALL_CU_LAYERS; // Ensure the hole is on all layers + dummypad.m_layerMask = ALL_CU_LAYERS; // Ensure the hole is on all layers // Compute the min distance to pads if( testPads ) @@ -273,10 +278,11 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) * But if a drill hole exists (a pad on a single layer can have a hole!) * we must test the hole */ - if( (pad->m_Masque_Layer & layerMask ) == 0 ) + if( (pad->m_layerMask & layerMask ) == 0 ) { - /* We must test the pad hole. In order to use the function checkClearanceSegmToPad(), - * a pseudo pad is used, with a shape and a size like the hole + /* We must test the pad hole. In order to use the function + * checkClearanceSegmToPad(),a pseudo pad is used, with a shape and a + * size like the hole */ if( pad->m_Drill.x == 0 ) continue; @@ -289,12 +295,13 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) m_padToTestPos = dummypad.GetPosition() - origin; if( !checkClearanceSegmToPad( &dummypad, aRefSeg->m_Width, - netclass->GetClearance() ) ) + netclass->GetClearance() ) ) { m_currentMarker = fillMarker( aRefSeg, pad, DRCE_TRACK_NEAR_THROUGH_HOLE, m_currentMarker ); return false; } + continue; } @@ -378,6 +385,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) return false; } } + continue; } @@ -396,8 +404,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) if( checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) ) continue; - m_currentMarker = fillMarker( aRefSeg, track, - DRCE_TRACK_NEAR_VIA, m_currentMarker ); + m_currentMarker = fillMarker( aRefSeg, track, DRCE_TRACK_NEAR_VIA, m_currentMarker ); return false; } @@ -423,6 +430,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) DRCE_TRACK_ENDS1, m_currentMarker ); return false; } + if( !checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) ) { m_currentMarker = fillMarker( aRefSeg, track, @@ -430,6 +438,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) return false; } } + if( segEndPoint.x > (-w_dist) && segEndPoint.x < (m_segmLength + w_dist) ) { /* Fine test : we consider the rounded shape of the ends */ @@ -439,6 +448,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) DRCE_TRACK_ENDS3, m_currentMarker ); return false; } + if( !checkMarginToCircle( segEndPoint, w_dist, m_segmLength ) ) { m_currentMarker = fillMarker( aRefSeg, track, @@ -462,6 +472,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) // Test if segments are crossing if( segStartPoint.y > segEndPoint.y ) EXCHG( segStartPoint.y, segEndPoint.y ); + if( (segStartPoint.y < 0) && (segEndPoint.y > 0) ) { m_currentMarker = fillMarker( aRefSeg, track, @@ -531,12 +542,14 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) RotatePoint( &relStartPos, angle ); RotatePoint( &relEndPos, angle ); + if( !checkMarginToCircle( relStartPos, w_dist, delta.x ) ) { m_currentMarker = fillMarker( aRefSeg, track, DRCE_ENDS_PROBLEM4, m_currentMarker ); return false; } + if( !checkMarginToCircle( relEndPos, w_dist, delta.x ) ) { m_currentMarker = fillMarker( aRefSeg, track, @@ -583,6 +596,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) */ bool swap_pads; swap_pads = false; + if( (aRefPad->m_PadShape != PAD_CIRCLE) && (aPad->m_PadShape == PAD_CIRCLE) ) swap_pads = true; else if( (aRefPad->m_PadShape != PAD_OVAL) && (aPad->m_PadShape == PAD_OVAL) ) @@ -602,6 +616,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) * aPad is also a PAD_RECT or a PAD_TRAPEZOID */ bool diag = true; + switch( aRefPad->m_PadShape ) { case PAD_CIRCLE: @@ -623,6 +638,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) // pad_angle = pad orient relative to the aRefPad orient pad_angle = aRefPad->m_Orient + aPad->m_Orient; NORMALIZE_ANGLE_POS( pad_angle ); + if( aPad->m_PadShape == PAD_RECT ) { wxSize size = aPad->m_Size; @@ -657,9 +673,11 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) wxPoint polycompare[4]; // Shape of aPad aRefPad->BuildPadPolygon( polyref, wxSize( 0, 0 ), aRefPad->m_Orient ); aPad->BuildPadPolygon( polycompare, wxSize( 0, 0 ), aPad->m_Orient ); + // Move aPad shape to relativePadPos for( int ii = 0; ii < 4; ii++ ) polycompare[ii] += relativePadPos; + // And now test polygons: if( !trapezoid2trapezoidDRC( polyref, polycompare, dist_min ) ) diag = false; @@ -694,6 +712,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) */ int segm_width; m_segmAngle = aRefPad->m_Orient; // Segment orient. + if( aRefPad->m_Size.y < aRefPad->m_Size.x ) // Build an horizontal equiv segment { segm_width = aRefPad->m_Size.y; @@ -776,6 +795,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi seuil = segmHalfWidth + aMinDist; padHalfsize.x = aPad->m_Size.x >> 1; padHalfsize.y = aPad->m_Size.y >> 1; + if( aPad->m_PadShape == PAD_TRAPEZOID ) // The size is bigger, due to m_DeltaSize extra size { padHalfsize.x += ABS(aPad->m_DeltaSize.y) / 2; // Remember: m_DeltaSize.y is the m_Size.x change @@ -830,9 +850,11 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi { EXCHG( padHalfsize.x, padHalfsize.y ); orient += 900; + if( orient >= 3600 ) orient -= 3600; } + deltay = padHalfsize.y - padHalfsize.x; // here: padHalfsize.x = radius, delta = dist centre cercles a centre pad @@ -842,6 +864,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi m_ycliplo = m_padToTestPos.y - segmHalfWidth - deltay; m_xcliphi = m_padToTestPos.x + seuil + padHalfsize.x; m_ycliphi = m_padToTestPos.y + segmHalfWidth + deltay; + if( !checkLine( startPoint, endPoint ) ) { return false; @@ -856,6 +879,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi // Calculate the actual position of the circle in the new X,Y axis: RotatePoint( &startPoint, m_segmAngle ); + if( !checkMarginToCircle( startPoint, padHalfsize.x + seuil, m_segmLength ) ) { return false; @@ -871,6 +895,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi { return false; } + break; case PAD_RECT: /* 2 rectangle + 4 1/4 cercles a tester */ @@ -898,6 +923,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi startPoint.y = m_padToTestPos.y - padHalfsize.y; RotatePoint( &startPoint, m_padToTestPos, orient ); RotatePoint( &startPoint, m_segmAngle ); + if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) ) return false; @@ -906,6 +932,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi startPoint.y = m_padToTestPos.y - padHalfsize.y; RotatePoint( &startPoint, m_padToTestPos, orient ); RotatePoint( &startPoint, m_segmAngle ); + if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) ) return false; @@ -914,6 +941,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi startPoint.y = m_padToTestPos.y + padHalfsize.y; RotatePoint( &startPoint, m_padToTestPos, orient ); RotatePoint( &startPoint, m_segmAngle ); + if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) ) return false; @@ -922,6 +950,7 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi startPoint.y = m_padToTestPos.y + padHalfsize.y; RotatePoint( &startPoint, m_padToTestPos, orient ); RotatePoint( &startPoint, m_segmAngle ); + if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) ) return false; @@ -1006,50 +1035,55 @@ bool DRC::checkLine( wxPoint aSegStart, wxPoint aSegEnd ) { WHEN_OUTSIDE; } + if( aSegStart.y < aSegEnd.y ) { if( (aSegEnd.y < m_ycliplo) || (aSegStart.y > m_ycliphi) ) { WHEN_OUTSIDE; } + if( aSegStart.y < m_ycliplo ) { - temp = - USCALE( (aSegEnd.x - aSegStart.x), (m_ycliplo - aSegStart.y), - (aSegEnd.y - aSegStart.y) ); + temp = USCALE( (aSegEnd.x - aSegStart.x), (m_ycliplo - aSegStart.y), + (aSegEnd.y - aSegStart.y) ); + if( (aSegStart.x += temp) > m_xcliphi ) { WHEN_OUTSIDE; } + aSegStart.y = m_ycliplo; WHEN_INSIDE; } + if( aSegEnd.y > m_ycliphi ) { - temp = - USCALE( (aSegEnd.x - aSegStart.x), (aSegEnd.y - m_ycliphi), - (aSegEnd.y - aSegStart.y) ); + temp = USCALE( (aSegEnd.x - aSegStart.x), (aSegEnd.y - m_ycliphi), + (aSegEnd.y - aSegStart.y) ); + if( (aSegEnd.x -= temp) < m_xcliplo ) { WHEN_OUTSIDE; } + aSegEnd.y = m_ycliphi; WHEN_INSIDE; } + if( aSegStart.x < m_xcliplo ) { - temp = - USCALE( (aSegEnd.y - aSegStart.y), (m_xcliplo - aSegStart.x), - (aSegEnd.x - aSegStart.x) ); + temp = USCALE( (aSegEnd.y - aSegStart.y), (m_xcliplo - aSegStart.x), + (aSegEnd.x - aSegStart.x) ); aSegStart.y += temp; aSegStart.x = m_xcliplo; WHEN_INSIDE; } + if( aSegEnd.x > m_xcliphi ) { - temp = - USCALE( (aSegEnd.y - aSegStart.y), (aSegEnd.x - m_xcliphi), - (aSegEnd.x - aSegStart.x) ); + temp = USCALE( (aSegEnd.y - aSegStart.y), (aSegEnd.x - m_xcliphi), + (aSegEnd.x - aSegStart.x) ); aSegEnd.y -= temp; aSegEnd.x = m_xcliphi; WHEN_INSIDE; @@ -1061,44 +1095,48 @@ bool DRC::checkLine( wxPoint aSegStart, wxPoint aSegEnd ) { WHEN_OUTSIDE; } + if( aSegStart.y > m_ycliphi ) { - temp = - USCALE( (aSegEnd.x - aSegStart.x), (aSegStart.y - m_ycliphi), - (aSegStart.y - aSegEnd.y) ); + temp = USCALE( (aSegEnd.x - aSegStart.x), (aSegStart.y - m_ycliphi), + (aSegStart.y - aSegEnd.y) ); + if( (aSegStart.x += temp) > m_xcliphi ) { WHEN_OUTSIDE; } + aSegStart.y = m_ycliphi; WHEN_INSIDE; } + if( aSegEnd.y < m_ycliplo ) { - temp = - USCALE( (aSegEnd.x - aSegStart.x), (m_ycliplo - aSegEnd.y), - (aSegStart.y - aSegEnd.y) ); + temp = USCALE( (aSegEnd.x - aSegStart.x), (m_ycliplo - aSegEnd.y), + (aSegStart.y - aSegEnd.y) ); + if( (aSegEnd.x -= temp) < m_xcliplo ) { WHEN_OUTSIDE; } + aSegEnd.y = m_ycliplo; WHEN_INSIDE; } + if( aSegStart.x < m_xcliplo ) { - temp = - USCALE( (aSegStart.y - aSegEnd.y), (m_xcliplo - aSegStart.x), - (aSegEnd.x - aSegStart.x) ); + temp = USCALE( (aSegStart.y - aSegEnd.y), (m_xcliplo - aSegStart.x), + (aSegEnd.x - aSegStart.x) ); aSegStart.y -= temp; aSegStart.x = m_xcliplo; WHEN_INSIDE; } + if( aSegEnd.x > m_xcliphi ) { - temp = - USCALE( (aSegStart.y - aSegEnd.y), (aSegEnd.x - m_xcliphi), - (aSegEnd.x - aSegStart.x) ); + temp = USCALE( (aSegStart.y - aSegEnd.y), (aSegEnd.x - m_xcliphi), + (aSegEnd.x - aSegStart.x) ); aSegEnd.y += temp; aSegEnd.x = m_xcliphi; WHEN_INSIDE; @@ -1113,5 +1151,7 @@ bool DRC::checkLine( wxPoint aSegStart, wxPoint aSegEnd ) return false; } else + { return true; + } } diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index ab81379c9a..c6e8fc87e5 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -40,7 +40,7 @@ void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) CursorInitialPosition = GetScreen()->GetCrossHairPosition(); DrawPanel->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline ); SetCurItem( Edge ); - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } @@ -48,6 +48,7 @@ void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* Edge ) { if( Edge == NULL ) return; + Edge->m_Start -= MoveVector; Edge->m_End -= MoveVector; @@ -59,7 +60,7 @@ void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* Edge ) SetCurItem( NULL ); OnModify(); MODULE* Module = (MODULE*) Edge->GetParent(); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); DrawPanel->Refresh( ); } @@ -87,7 +88,7 @@ static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, Edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); } @@ -105,7 +106,7 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& MODULE* Module = (MODULE*) Edge->GetParent(); - // if( erase ) + // if( erase ) { Edge->Draw( aPanel, aDC, GR_XOR ); } @@ -118,7 +119,7 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& Edge->Draw( aPanel, aDC, GR_XOR ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); } @@ -131,18 +132,22 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge ) if( aEdge == NULL ) { aEdge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings; + for( ; aEdge != NULL; aEdge = aEdge->Next() ) { if( aEdge->Type() != TYPE_EDGE_MODULE ) continue; + aEdge->m_Width = g_ModuleSegmentWidth; } } else + { aEdge->m_Width = g_ModuleSegmentWidth; + } OnModify(); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Module->m_LastEdit_Time = time( NULL ); } @@ -155,9 +160,9 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* Edge ) if( Edge != NULL ) new_layer = Edge->GetLayer(); - /* Ask for the new layer */ new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER ); + if( new_layer < 0 ) return; @@ -190,7 +195,7 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* Edge ) } OnModify(); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Module->m_LastEdit_Time = time( NULL ); } @@ -214,7 +219,7 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) { MODULE* Module = GetBoard()->m_Modules; aEdge->m_Width = g_ModuleSegmentWidth; - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); OnModify(); } } @@ -236,7 +241,7 @@ void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* Edge ) /* Delete segment. */ Edge->DeleteStructure(); Module->m_LastEdit_Time = time( NULL ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); OnModify(); } @@ -256,7 +261,7 @@ static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC ) MODULE* Module = (MODULE*) Edge->GetParent(); Edge->Draw( Panel, DC, GR_XOR, MoveVector ); Edge->DeleteStructure(); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); } else // On aborting, move existing outline to its initial position. { @@ -319,7 +324,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge, RotatePoint( &Edge->m_Start0, -module->m_Orient ); Edge->m_End0 = Edge->m_Start0; - module->Set_Rectangle_Encadrement(); + module->CalculateBoundingBox(); DrawPanel->SetMouseCapture( ShowNewEdgeModule, Abort_Move_ModuleOutline ); } /* Segment creation in progress. @@ -356,7 +361,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge, Edge->m_End0 = Edge->m_Start0; - module->Set_Rectangle_Encadrement(); + module->CalculateBoundingBox(); module->m_LastEdit_Time = time( NULL ); OnModify(); } @@ -384,7 +389,7 @@ void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* Edge ) Edge->DeleteStructure(); } - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Module->m_LastEdit_Time = time( NULL ); OnModify(); DrawPanel->SetMouseCapture( NULL, NULL ); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 54637cc52b..d4080c55e8 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -881,18 +881,18 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_MOVE_MIRE_REQUEST: - StartMove_Mire( (MIREPCB*) GetCurItem(), &dc ); + BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc ); DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_EDIT_MIRE: - InstallMireOptionsFrame( (MIREPCB*) GetCurItem(), &dc ); + ShowTargetOptionsDialog( (PCB_TARGET*) GetCurItem(), &dc ); DrawPanel->MoveCursorToCrossHair(); break; case ID_POPUP_PCB_DELETE_MIRE: DrawPanel->MoveCursorToCrossHair(); - Delete_Mire( (MIREPCB*) GetCurItem(), &dc ); + DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc ); SetCurItem( NULL ); break; @@ -1096,8 +1096,8 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) Delete_Dimension( (DIMENSION*) Item, DC ); break; - case TYPE_MIRE: - Delete_Mire( (MIREPCB*) Item, DC ); + case PCB_TARGET_T: + DeleteTarget( (PCB_TARGET*) Item, DC ); break; case TYPE_DRAWSEGMENT: diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index c944637272..281705ec45 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -111,7 +111,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC ) DrawPanel->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text ); SetCurItem( TextePcb ); - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); } @@ -160,6 +160,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::Create_Texte_Pcb( wxDC* DC ) TextePcb->m_Flags = IS_NEW; TextePcb->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); TextePcb->m_Mirror = false; + if( TextePcb->GetLayer() == LAYER_N_BACK ) TextePcb->m_Mirror = true; @@ -168,13 +169,16 @@ TEXTE_PCB* PCB_EDIT_FRAME::Create_Texte_Pcb( wxDC* DC ) TextePcb->m_Thickness = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth; InstallTextPCBOptionsFrame( TextePcb, DC ); + if( TextePcb->m_Text.IsEmpty() ) { TextePcb->DeleteStructure(); TextePcb = NULL; } else + { StartMoveTextePcb( TextePcb, DC ); + } return TextePcb; } @@ -197,6 +201,7 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) /* Redraw text in new position. */ TextePcb->Draw( DrawPanel, DC, drawmode ); TextePcb->DisplayInfo( this ); + if( TextePcb->m_Flags == 0 ) // i.e. not edited, or moved SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->m_Pos ); else // set flag edit, to show it was a complex command diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index 1d1f648b7d..225bf4ba15 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -41,17 +41,22 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, new_width = net->GetTrackWidth(); else new_width = GetBoard()->GetCurrentTrackWidth(); + if( aTrackItem->Type() == TYPE_VIA ) { if( !aTrackItem->IsDrillDefault() ) initial_drill = aTrackItem->GetDrillValue(); + if( net ) + { new_width = net->GetViaSize(); + } else { new_width = GetBoard()->GetCurrentViaSize(); new_drill = GetBoard()->GetCurrentViaDrill(); } + if( aTrackItem->m_Shape == VIA_MICROVIA ) { if( net ) @@ -59,29 +64,36 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, else new_width = net->GetMicroViaSize(); } - } aTrackItem->m_Width = new_width; + if( initial_width < new_width ) /* make a DRC test because the new size is bigger than the old size */ { int diagdrc = OK_DRC; + if( Drc_On ) diagdrc = m_drc->Drc( aTrackItem, GetBoard()->m_Track ); + if( diagdrc == OK_DRC ) change_ok = true; } else if( initial_width > new_width ) + { change_ok = true; + } // if new width == initial_width: do nothing, // unless a via has its drill value changed else if( (aTrackItem->Type() == TYPE_VIA) && (initial_drill != new_drill) ) + { change_ok = true; + } if( change_ok ) { OnModify(); + if( aItemsListPicker ) { aTrackItem->m_Width = initial_width; @@ -89,18 +101,21 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, picker.m_Link = aTrackItem->Copy(); aItemsListPicker->PushItem( picker ); aTrackItem->m_Width = new_width; + if( aTrackItem->Type() == TYPE_VIA ) { // Set new drill value. Note: currently microvias have only a default drill value if( new_drill > 0 ) aTrackItem->SetDrillValue(new_drill); else - aTrackItem->SetDrillDefault( ); + aTrackItem->SetDrillDefault(); } } } else + { aTrackItem->m_Width = initial_width; + } return change_ok; } @@ -125,11 +140,12 @@ void PCB_EDIT_FRAME::Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem ) { TRACK* oldsegm = (TRACK*) itemsListPicker.GetPickedItemLink( 0 ); wxASSERT( oldsegm ); - DrawPanel->CrossHairOff( aDC ); // Erase cursor shape + DrawPanel->CrossHairOff( aDC ); // Erase cursor shape oldsegm->Draw( DrawPanel, aDC, GR_XOR ); // Erase old track shape aTrackItem->Draw( DrawPanel, aDC, GR_OR ); // Display new track shape - DrawPanel->CrossHairOn( aDC ); // Display cursor shape + DrawPanel->CrossHairOn( aDC ); // Display cursor shape } + SaveCopyInUndoList( itemsListPicker, UR_CHANGED ); } @@ -137,7 +153,8 @@ void PCB_EDIT_FRAME::Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem ) /** * Function Edit_Track_Width * Modify a full track width (using DRC control). - * a full track is the set of track segments between 2 ends: pads or a point that has more than 2 segments ends connected + * a full track is the set of track segments between 2 ends: pads or a point that has + * more than 2 segments ends connected * @param aDC = the curred device context (can be NULL) * @param aTrackSegment = a segment or via on the track to change */ @@ -149,13 +166,15 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) if( aTrackSegment == NULL ) return; - pt_track = Marque_Une_Piste( GetBoard(), aTrackSegment, &nb_segm, NULL, NULL, true ); + pt_track = MarkTrace( GetBoard(), aTrackSegment, &nb_segm, NULL, NULL, true ); PICKED_ITEMS_LIST itemsListPicker; bool change = false; + for( int ii = 0; ii < nb_segm; ii++, pt_track = pt_track->Next() ) { pt_track->SetState( BUSY, OFF ); + if( SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) ) change = true; } @@ -190,9 +209,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) * @param aNetcode : the netcode of the net to edit * @param aUseNetclassValue : bool. True to use netclass values, false to use current values */ -/***********************************************************/ bool PCB_EDIT_FRAME::Change_Net_Tracks_And_Vias_Sizes( int aNetcode, bool aUseNetclassValue ) -/***********************************************************/ { TRACK* pt_segm; @@ -202,10 +219,12 @@ bool PCB_EDIT_FRAME::Change_Net_Tracks_And_Vias_Sizes( int aNetcode, bool aUseNe /* Examine segments */ PICKED_ITEMS_LIST itemsListPicker; bool change = false; + for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( aNetcode != pt_segm->GetNet() ) /* not in net */ continue; + /* we have found a item member of the net */ if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, aUseNetclassValue ) ) change = true; @@ -220,15 +239,14 @@ bool PCB_EDIT_FRAME::Change_Net_Tracks_And_Vias_Sizes( int aNetcode, bool aUseNe } -/*************************************************************************/ bool PCB_EDIT_FRAME::Reset_All_Tracks_And_Vias_To_Netclass_Values( bool aTrack, bool aVia ) -/*************************************************************************/ { TRACK* pt_segm; /* read and edit tracks and vias if required */ PICKED_ITEMS_LIST itemsListPicker; bool change = false; + for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() ) { if( (pt_segm->Type() == TYPE_VIA ) && aVia ) diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 0cf6382ac4..8478c3fb08 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -14,8 +14,7 @@ static void Abort_EditEdge( EDA_DRAW_PANEL* Panel, wxDC* DC ); -static void Montre_Position_NewSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aPosition, bool aErase ); +static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); @@ -29,6 +28,7 @@ void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) { if( drawitem == NULL ) return; + drawitem->Draw( DrawPanel, DC, GR_XOR ); drawitem->m_Flags |= IS_MOVED; s_InitialPosition = s_LastPosition = GetScreen()->GetCrossHairPosition(); @@ -94,8 +94,10 @@ void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) Segment->Draw( DrawPanel, DC, GR_XOR ); PtStruct = Segment->Back(); Segment ->DeleteStructure(); + if( PtStruct && (PtStruct->Type() == TYPE_DRAWSEGMENT ) ) Segment = (DRAWSEGMENT*) PtStruct; + DisplayOpt.DisplayDrawItems = track_fill_copy; SetCurItem( NULL ); } @@ -120,6 +122,7 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( int aLayer ) } wxString msg = _( "Delete Layer " ) + GetBoard()->GetLayerName( aLayer ); + if( !IsOK( this, msg ) ) return; @@ -136,13 +139,14 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( int aLayer ) case TYPE_DRAWSEGMENT: case TYPE_TEXTE: case TYPE_DIMENSION: - case TYPE_MIRE: + case PCB_TARGET_T: if( item->GetLayer() == aLayer ) { item->UnLink(); picker.m_PickedItem = item; pickList.PushItem( picker ); } + break; default: @@ -218,10 +222,10 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, Segment->m_Shape = shape; Segment->m_Angle = 900; Segment->m_Start = Segment->m_End = GetScreen()->GetCrossHairPosition(); - DrawPanel->SetMouseCapture( Montre_Position_NewSegment, Abort_EditEdge ); + DrawPanel->SetMouseCapture( DrawSegment, Abort_EditEdge ); } else /* The ending point ccordinate Segment->m_End was updated by he function - * Montre_Position_NewSegment() called on a move mouse event + * DrawSegment() called on a move mouse event * during the segment creation */ { @@ -248,7 +252,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, Segment->m_Type = DrawItem->m_Type; Segment->m_Angle = DrawItem->m_Angle; Segment->m_Start = Segment->m_End = DrawItem->m_End; - Montre_Position_NewSegment( DrawPanel, DC, wxDefaultPosition, false ); + DrawSegment( DrawPanel, DC, wxDefaultPosition, false ); } else { @@ -266,12 +270,14 @@ void PCB_EDIT_FRAME::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) { if( Segment == NULL ) return; + Segment->Draw( DrawPanel, DC, GR_OR ); /* Delete if segment length is zero. */ if( Segment->m_Start == Segment->m_End ) + { Segment ->DeleteStructure(); - + } else { Segment->m_Flags = 0; @@ -287,8 +293,7 @@ void PCB_EDIT_FRAME::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) /* Redraw segment during cursor movement */ -static void Montre_Position_NewSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aPosition, bool aErase ) +static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); int t_fill = DisplayOpt.DisplayDrawItems; @@ -303,9 +308,9 @@ static void Montre_Position_NewSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, if( Segments_45_Only && ( Segment->m_Shape == S_SEGMENT ) ) { - Calcule_Coord_Extremite_45( aPanel->GetScreen()->GetCrossHairPosition(), - Segment->m_Start.x, Segment->m_Start.y, - &Segment->m_End.x, &Segment->m_End.y ); + CalculateSegmentEndPoint( aPanel->GetScreen()->GetCrossHairPosition(), + Segment->m_Start.x, Segment->m_Start.y, + &Segment->m_End.x, &Segment->m_End.y ); } else /* here the angle is arbitrary */ { diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 386a3a81d3..5142b9a276 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -1,6 +1,6 @@ /************************************************/ -/* Module editor: Dialog box for editing module */ -/* properties and characteristics */ +/* Module editor: Dialog box for editing module */ +/* properties and characteristics */ /************************************************/ #include "fctsys.h" @@ -23,8 +23,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ) if( Module == NULL ) return; - DIALOG_MODULE_BOARD_EDITOR* dialog = - new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC ); + DIALOG_MODULE_BOARD_EDITOR* dialog = new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC ); int retvalue = dialog->ShowModal(); /* retvalue = * -1 if abort, @@ -47,8 +46,8 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ) m_ModuleEditFrame->Load_Module_From_BOARD( Module ); SetCurItem( NULL ); - m_ModuleEditFrame->Show( TRUE ); - m_ModuleEditFrame->Iconize( FALSE ); + m_ModuleEditFrame->Show( true ); + m_ModuleEditFrame->Iconize( false ); } } @@ -107,7 +106,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod ) } } - pt_mod->Set_Rectangle_Encadrement(); + pt_mod->CalculateBoundingBox(); } @@ -125,16 +124,19 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item ) case TYPE_TEXTE_MODULE: { TEXTE_MODULE* text = (TEXTE_MODULE*) Item; + if( text->m_Type == TEXT_is_REFERENCE ) { DisplayError( this, _( "Text is REFERENCE!" ) ); break; } + if( text->m_Type == TEXT_is_VALUE ) { DisplayError( this, _( "Text is VALUE!" ) ); break; } + DeleteTextModule( text ); } break; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index f3c815a208..77cf7eb03d 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -1,6 +1,6 @@ -/*******************************/ +/************************/ /* Edit tracks */ -/*******************************/ +/************************/ #include "fctsys.h" #include "class_drawpanel.h" @@ -33,12 +33,14 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) l1 = Route_Layer_TOP; l2 = Route_Layer_BOTTOM; - pt_track = Marque_Une_Piste( GetBoard(), pt_segm, &nb_segm, NULL, NULL, true ); + pt_track = MarkTrace( GetBoard(), pt_segm, &nb_segm, NULL, NULL, true ); + if ( DC ) - Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR ); + DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_XOR ); /* Clear the BUSY flag and backup member. Param layer original. */ ii = nb_segm; pt_segm = pt_track; + for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Next() ) { pt_segm->SetState( BUSY, OFF ); @@ -46,6 +48,7 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) } ii = 0; pt_segm = pt_track; + for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() ) { if( pt_segm->Type() == TYPE_VIA ) @@ -69,15 +72,19 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) } if( DC ) - Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR ); - DisplayError( this, _( "Drc error, canceled" ), 10 ); + DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_OR ); + + DisplayError( this, _( "Drc error, canceled" ) ); return; } } - Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL ); + DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL ); + /* Control of segment end point, is it on a pad? */ - ii = 0; pt_segm = pt_track; + ii = 0; + pt_segm = pt_track; + for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ ) { pt_segm->start = Locate_Pad_Connecte( GetBoard(), pt_segm, START ); @@ -96,8 +103,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) if( aTrack == NULL ) { - if( getActiveLayer() != - ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) + if( getActiveLayer() != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) setActiveLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ); else setActiveLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM ); @@ -107,14 +113,12 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) } /* Avoid more than one via on the current location: */ - if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End, - g_CurrentTrackSegment->GetLayer() ) ) + if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) return false; for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() ) { - if( segm->Type()==TYPE_VIA - && g_CurrentTrackSegment->m_End==segm->m_Start ) + if( segm->Type() == TYPE_VIA && g_CurrentTrackSegment->m_End == segm->m_Start ) return false; } @@ -128,8 +132,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) // Handle 2 segments. if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() ) { - if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), - GetBoard()->m_Track ) ) + if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), GetBoard()->m_Track ) ) return false; } } @@ -140,7 +143,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) itmp = g_CurrentTrackList.GetCount(); Begin_Route( g_CurrentTrackSegment, DC ); - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); /* create the via */ SEGVIA* via = new SEGVIA( GetBoard() ); @@ -149,6 +152,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) via->m_Width = GetBoard()->GetCurrentViaSize(); via->SetNet( GetBoard()->GetHightLightNetCode() ); via->m_Start = via->m_End = g_CurrentTrackSegment->m_End; + // Usual via is from copper to component. // layer pair is LAYER_N_BACK and LAYER_N_FRONT. via->SetLayerPair( LAYER_N_BACK, LAYER_N_FRONT ); @@ -156,6 +160,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) int first_layer = getActiveLayer(); int last_layer; + // prepare switch to new active layer: if( first_layer != GetScreen()->m_Route_Layer_TOP ) last_layer = GetScreen()->m_Route_Layer_TOP; @@ -180,6 +185,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) last_layer = LAYER_N_BACK; else if ( first_layer == last_inner_layer ) last_layer = LAYER_N_FRONT; + // else error: will be removed later via->SetLayerPair( first_layer, last_layer ); { @@ -198,7 +204,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) /* DRC fault: the Via cannot be placed here ... */ delete via; - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); // delete the track(s) added in Begin_Route() while( g_CurrentTrackList.GetCount() > itmp ) @@ -252,7 +258,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() ); } - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); via->DisplayInfo( this ); UpdateStatusBar(); @@ -265,13 +271,13 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) * The status of the net on top of the screen segment advanced by mouse. * PCB status or bottom of screen if no segment peak. */ -void PCB_EDIT_FRAME::Affiche_Status_Net( wxDC* DC ) +void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC ) { TRACK* pt_segm; - int masquelayer = (1 << getActiveLayer()); + int layerMask = (1 << getActiveLayer()); wxPoint pos = GetScreen()->RefPos( true ); - pt_segm = Locate_Pistes( GetBoard(), GetBoard()->m_Track, pos, masquelayer ); + pt_segm = GetTrace( GetBoard(), GetBoard()->m_Track, pos, layerMask ); if( pt_segm == NULL ) GetBoard()->DisplayInfo( this ); @@ -294,7 +300,7 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) return; if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 ) - Compile_Ratsnest( DC, TRUE ); + Compile_Ratsnest( DC, true ); if( item ) { @@ -307,14 +313,18 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) if( pt_pad ) /* Displaying the ratsnest of the corresponding net. */ { pt_pad->DisplayInfo( this ); + for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) { RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii]; + if( net->GetNet() == pt_pad->GetNet() ) { if( ( net->m_Status & CH_VISIBLE ) != 0 ) continue; + net->m_Status |= CH_VISIBLE; + if( ( net->m_Status & CH_ACTIF ) == 0 ) continue; @@ -326,8 +336,7 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) { if( item->Type() == TYPE_TEXTE_MODULE ) { - if( item->GetParent() - && ( item->GetParent()->Type() == TYPE_MODULE ) ) + if( item->GetParent() && ( item->GetParent()->Type() == TYPE_MODULE ) ) Module = (MODULE*) item->GetParent(); } else if( item->Type() == TYPE_MODULE ) @@ -339,19 +348,20 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) { Module->DisplayInfo( this ); pt_pad = Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() ) { - for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); - ii++ ) + for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) { RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii]; - if( ( net->m_PadStart == pt_pad ) - || ( net->m_PadEnd == pt_pad ) ) + + if( ( net->m_PadStart == pt_pad ) || ( net->m_PadEnd == pt_pad ) ) { if( net->m_Status & CH_VISIBLE ) continue; net->m_Status |= CH_VISIBLE; + if( (net->m_Status & CH_ACTIF) == 0 ) continue; @@ -378,11 +388,12 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) /* High light the unconnected pads */ -void PCB_EDIT_FRAME::Affiche_PadsNoConnect( wxDC* DC ) +void PCB_EDIT_FRAME::HighlightUnconnectedPads( wxDC* DC ) { for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) { RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii]; + if( (net->m_Status & CH_ACTIF) == 0 ) continue; diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 293b0d1162..fbcf43afea 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -26,8 +26,7 @@ static void EnsureEndTrackOnPad( D_PAD* Pad ); static PICKED_ITEMS_LIST s_ItemsListPicker; -/* Routine to cancel the route if a track is being drawn, or exit the - * application EDITRACK. +/* Routine to cancel the route if a track is being drawn, or exit the application EDITRACK. */ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC ) { @@ -39,10 +38,12 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC ) { /* Erase the current drawing */ ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false ); + if( pcb->IsHightLightNetON() ) frame->High_Light( DC ); pcb->PopHightLight(); + if( pcb->IsHightLightNetON() ) pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); @@ -80,8 +81,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) { D_PAD* pt_pad = NULL; TRACK* TrackOnStartPoint = NULL; - int masquelayer = - g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; + int layerMask = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; BOARD_ITEM* LockPoint; wxPoint pos = GetScreen()->GetCrossHairPosition(); @@ -90,9 +90,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) DrawPanel->SetMouseCapture( ShowNewTrackWhenMovingCursor, Abort_Create_Track ); // Prepare the undo command info - s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be - // necessary, - // but... + s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but... GetBoard()->PushHightLight(); @@ -106,7 +104,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) GetBoard()->SetHightLightNet(0); // Search for a starting point of the new track, a track or pad - LockPoint = LocateLockPoint( GetBoard(), pos, masquelayer ); + LockPoint = LocateLockPoint( GetBoard(), pos, layerMask ); if( LockPoint ) // An item (pad or track) is found { @@ -122,9 +120,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) { TrackOnStartPoint = (TRACK*) LockPoint; GetBoard()->SetHightLightNet( TrackOnStartPoint->GetNet() ); - CreateLockPoint( GetBoard(), pos, - TrackOnStartPoint, - &s_ItemsListPicker ); + CreateLockPoint( GetBoard(), pos, TrackOnStartPoint, &s_ItemsListPicker ); } } else // no starting point, but a filled zone area can exist. This is @@ -158,6 +154,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) if( TrackOnStartPoint && TrackOnStartPoint->Type() == TYPE_TRACK ) g_CurrentTrackSegment->m_Width = TrackOnStartPoint->m_Width; } + g_CurrentTrackSegment->m_Start = pos; g_CurrentTrackSegment->m_End = pos; @@ -167,7 +164,9 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) g_CurrentTrackSegment->SetState( BEGIN_ONPAD, ON ); } else + { g_CurrentTrackSegment->start = TrackOnStartPoint; + } if( g_TwoSegmentTrackBuild ) { @@ -190,8 +189,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) if( Drc_On ) { - if( BAD_DRC == - m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) + if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) { return g_CurrentTrackSegment; } @@ -202,16 +200,13 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) /* Tst for a D.R.C. error: */ if( Drc_On ) { - if( BAD_DRC == - m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) + if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) return NULL; // We must handle 2 segments if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() ) { - if( BAD_DRC == - m_drc->Drc( g_CurrentTrackSegment->Back(), - GetBoard()->m_Track ) ) + if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), GetBoard()->m_Track ) ) return NULL; } } @@ -221,6 +216,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) * if a 2 segments track build. */ bool CanCreateNewSegment = true; + if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) CanCreateNewSegment = false; @@ -251,13 +247,14 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); - oneBeforeLatest->end = Locate_Pad_Connecte( - GetBoard(), oneBeforeLatest, END ); + oneBeforeLatest->end = Locate_Pad_Connecte( GetBoard(), oneBeforeLatest, END ); + if( oneBeforeLatest->end ) { oneBeforeLatest->SetState( END_ONPAD, ON ); newTrack->SetState( BEGIN_ONPAD, ON ); } + newTrack->start = oneBeforeLatest->end; D( g_CurrentTrackList.VerifyListIntegrity(); ); @@ -265,6 +262,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) newTrack->m_Start = newTrack->m_End; newTrack->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); + if( !GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) { newTrack->m_Width = GetBoard()->GetCurrentTrackWidth(); @@ -310,6 +308,7 @@ bool PCB_EDIT_FRAME::Add_45_degrees_Segment( wxDC* DC ) } int segm_step_45 = wxRound( GetScreen()->GetGridSize().x / 2 ); + if( segm_step_45 < ( curTrack->m_Width * 2 ) ) segm_step_45 = curTrack->m_Width * 2; @@ -415,17 +414,15 @@ bool PCB_EDIT_FRAME::Add_45_degrees_Segment( wxDC* DC ) */ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) { - int masquelayer = - g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; + int layerMask = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; if( aTrack == NULL ) return false; - if( Drc_On && BAD_DRC== - m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) + if( Drc_On && BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) return false; - /* Sauvegarde des coord du point terminal de la piste */ + /* Saving the coordinate of end point of the trace */ wxPoint pos = g_CurrentTrackSegment->m_End; D( g_CurrentTrackList.VerifyListIntegrity(); ); @@ -454,7 +451,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) * This helps to reduce the computing time */ /* Attaching the end of the track. */ - BOARD_ITEM* LockPoint = LocateLockPoint( GetBoard(), pos, masquelayer ); + BOARD_ITEM* LockPoint = LocateLockPoint( GetBoard(), pos, layerMask ); if( LockPoint ) /* End of trace is on a pad. */ { @@ -490,8 +487,8 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) // Put entire new current segment list in BOARD, and prepare undo // command TRACK* track; - TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( - GetBoard() ); + TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() ); + while( ( track = g_CurrentTrackList.PopFront() ) != NULL ) { ITEM_PICKER picker( track, UR_NEW ); @@ -501,9 +498,10 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) trace_ratsnest_pad( DC ); - Trace_Une_Piste( DrawPanel, DC, firstTrack, newCount, GR_OR ); + DrawTraces( DrawPanel, DC, firstTrack, newCount, GR_OR ); int i = 0; + for( track = firstTrack; track && iNext() ) { track->m_Flags = 0; @@ -515,6 +513,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) { EraseRedundantTrack( DC, firstTrack, newCount, &s_ItemsListPicker ); } + SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more // owner of picked items @@ -524,9 +523,9 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) GetBoard()->DisplayInfo( this ); } - wxASSERT( g_FirstTrackSegment==NULL ); - wxASSERT( g_CurrentTrackSegment==NULL ); - wxASSERT( g_CurrentTrackList.GetCount()==0 ); + wxASSERT( g_FirstTrackSegment == NULL ); + wxASSERT( g_CurrentTrackSegment == NULL ); + wxASSERT( g_CurrentTrackList.GetCount() == 0 ); if( GetBoard()->IsHightLightNetON() ) High_Light( DC ); @@ -632,10 +631,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel ) if( !det ) return; - dist = - (track->m_Width + - 1) / 2 + (other->m_Width + 1) / 2 + track->GetClearance( - other ) + 2; + dist = (track->m_Width + 1) / 2 + (other->m_Width + 1) / 2 + track->GetClearance( other ) + 2; /* * DRC wants >, so +1. @@ -653,6 +649,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel ) n.x = -vec.y; n.y = vec.x; } + f = dist / hypot( double(n.x), double(n.y) ); n.x = wxRound( f * n.x ); n.y = wxRound( f * n.y ); @@ -688,7 +685,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo /* Erase old track */ if( aErase ) { - Trace_Une_Piste( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); + DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); frame->trace_ratsnest_pad( aDC ); @@ -744,7 +741,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo /* Calculate of the end of the path for the permitted directions: * horizontal, vertical or 45 degrees. */ - Calcule_Coord_Extremite_45( screen->GetCrossHairPosition(), + CalculateSegmentEndPoint( screen->GetCrossHairPosition(), g_CurrentTrackSegment->m_Start.x, g_CurrentTrackSegment->m_Start.y, &g_CurrentTrackSegment->m_End.x, @@ -758,7 +755,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo /* Redraw the new track */ D( g_CurrentTrackList.VerifyListIntegrity(); ); - Trace_Une_Piste( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); + DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) { @@ -776,6 +773,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo * interesting segment. */ TRACK* isegm = g_CurrentTrackSegment; + if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() ) isegm = g_CurrentTrackSegment->Back(); @@ -787,12 +785,14 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo double trackLen = 0.0; double lenDie = 0.0; wxString msg; + // If the starting point is on a pad, add current track length+ lenght die if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) ) { D_PAD * pad = (D_PAD *) g_FirstTrackSegment->start; lenDie = (double) pad->m_LengthDie; - } + } + // calculate track len on board: for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() ) trackLen += track->GetLength(); @@ -823,7 +823,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo /* Determine the coordinate to advanced the the current segment * in 0, 90, or 45 degrees, depending on position of origin and \a aPosition. */ -void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy ) +void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy ) { int deltax, deltay, angle; @@ -865,6 +865,7 @@ void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* /* Recalculate the signs fo deltax and deltaY. */ if( ( aPosition.x - ox ) < 0 ) deltax = -deltax; + if( ( aPosition.y - oy ) < 0 ) deltay = -deltay; @@ -891,12 +892,14 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) if( SegmentCount <= 0 ) return; + if( track == NULL ) return; TRACK* newTrack = track; track = track->Back(); SegmentCount--; + if( track ) { iDx = end.x - track->m_Start.x; @@ -907,6 +910,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) } TRACK* lastTrack = track ? track->Back() : NULL; + if( lastTrack ) { if(( (lastTrack->m_End.x == lastTrack->m_Start.x) @@ -915,10 +919,13 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) { iAngle = 45; } - } else { - if (g_Alternate_Track_Posture) { - iAngle = 45; - } + } + else + { + if( g_Alternate_Track_Posture ) + { + iAngle = 45; + } } if( iAngle == 0 ) @@ -942,6 +949,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) track->m_End.x = end.x + iDy; else track->m_End.x = end.x - iDy; + track->m_End.y = track->m_Start.y; break; @@ -952,6 +960,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) /* Recalculate the signs fo deltax and deltaY. */ if( ( end.x - track->m_Start.x ) < 0 ) iDx = -iDx; + if( ( end.y - track->m_Start.y ) < 0 ) iDy = -iDy; @@ -976,6 +985,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) newTrack->m_Start = track->m_End; } + newTrack->m_End = end; } @@ -993,10 +1003,12 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST& aTrackList ) TRACK* oldtrack; BOARD_ITEM* LockPoint = track->start; + while( track != NULL ) { oldtrack = track; track = track->Next(); + if( !oldtrack->IsNull() ) { continue; @@ -1015,6 +1027,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST& aTrackList ) // we must set the pointers on connected items and the connection status oldtrack = track = firsttrack; firsttrack->start = NULL; + while( track != NULL ) { oldtrack = track; @@ -1028,24 +1041,29 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST& aTrackList ) } firsttrack->start = LockPoint; + if( LockPoint && LockPoint->Type()==TYPE_PAD ) firsttrack->SetState( BEGIN_ONPAD, ON ); track = firsttrack; + while( track != NULL ) { TRACK* next_track = track->Next(); LockPoint = Locate_Pad_Connecte( pcb, track, END ); + if( LockPoint ) { track->end = LockPoint; track->SetState( END_ONPAD, ON ); + if( next_track ) { next_track->start = LockPoint; next_track->SetState( BEGIN_ONPAD, ON ); } } + track = next_track; } } @@ -1065,6 +1083,7 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) } TRACK* lasttrack = g_CurrentTrackSegment; + if( !g_CurrentTrackSegment->IsNull() ) { /* Must create a new segment, from track end to pad center */ diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 8093f4a5ca..1c4af156f9 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -45,8 +45,7 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC ) Text->m_Text = wxT( "text" ); g_ModuleTextWidth = Clamp_Text_PenSize( g_ModuleTextWidth, - MIN( g_ModuleTextSize.x, - g_ModuleTextSize.y ), true ); + MIN( g_ModuleTextSize.x, g_ModuleTextSize.y ), true ); Text->m_Size = g_ModuleTextSize; Text->m_Thickness = g_ModuleTextWidth; Text->m_Pos = GetScreen()->GetCrossHairPosition(); @@ -56,6 +55,7 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC ) DrawPanel->MoveCursorToCrossHair(); Text->m_Flags = 0; + if( DC ) Text->Draw( DrawPanel, DC, GR_OR ); @@ -74,8 +74,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) MODULE* module = (MODULE*) Text->GetParent(); - if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // prepare undo - // command + if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // prepare undo command { if( this->m_Ident == PCB_FRAME ) SaveCopyInUndoList( module, UR_CHANGED ); @@ -85,6 +84,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) Text->Draw( DrawPanel, DC, GR_XOR, MoveVector ); Text->m_Orient += 900; + while( Text->m_Orient >= 1800 ) Text->m_Orient -= 1800; @@ -93,6 +93,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) if( module ) module->m_LastEdit_Time = time( NULL ); + OnModify(); } @@ -185,7 +186,7 @@ void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) SetCurItem( Text ); DrawPanel->SetMouseCapture( Show_MoveTexte_Module, AbortMoveTextModule ); - DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, TRUE ); + DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); } @@ -200,14 +201,17 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) /* Update the coordinates for anchor. */ MODULE* Module = (MODULE*) Text->GetParent(); + if( Module ) { // Prepare undo command (a rotation can be made while moving) EXCHG( Text->m_Orient, TextInitialOrientation ); + if( m_Ident == PCB_FRAME ) SaveCopyInUndoList( Module, UR_CHANGED ); else SaveCopyInUndoList( Module, UR_MODEDIT ); + EXCHG( Text->m_Orient, TextInitialOrientation ); // Set the new position for text. @@ -224,7 +228,9 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() ); } else + { Text->m_Pos = GetScreen()->GetCrossHairPosition(); + } } // leave it at (0,0) so we can use it Rotate when not moving. @@ -276,12 +282,14 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) pcbText = (TEXTE_PCB*) aItem; text = (EDA_TEXT*) pcbText; break; + case TYPE_TEXTE_MODULE: newSize = g_ModuleTextSize; newThickness = g_ModuleTextWidth; moduleText = (TEXTE_MODULE*) aItem; text = (EDA_TEXT*) moduleText; break; + default: // Exit if aItem is not a text field return; @@ -289,8 +297,7 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) } // Exit if there's nothing to do - if( text->GetSize() == newSize - && text->GetThickness() == newThickness ) + if( text->GetSize() == newSize && text->GetThickness() == newThickness ) return; // Push item to undo list @@ -299,9 +306,11 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) case TYPE_TEXTE: SaveCopyInUndoList( pcbText, UR_CHANGED ); break; + case TYPE_TEXTE_MODULE: SaveCopyInUndoList( moduleText->GetParent(), UR_CHANGED ); break; + default: break; } @@ -333,28 +342,33 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) while( module ) { itemWrapper.m_PickedItem = module; + switch( aType ) { case TEXT_is_REFERENCE: item = module->m_Reference; - if( item->GetSize() != g_ModuleTextSize - || item->GetThickness() != g_ModuleTextWidth ) + + if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_ModuleTextWidth ) undoItemList.PushItem( itemWrapper ); + break; + case TEXT_is_VALUE: item = module->m_Value; - if( item->GetSize() != g_ModuleTextSize - || item->GetThickness() != g_ModuleTextWidth ) + + if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_ModuleTextWidth ) undoItemList.PushItem( itemWrapper ); + break; + case TEXT_is_DIVERS: // Go through all other module text fields - for( boardItem = module->m_Drawings; boardItem; - boardItem = boardItem->Next() ) + for( boardItem = module->m_Drawings; boardItem; boardItem = boardItem->Next() ) { if( boardItem->Type() == TYPE_TEXTE_MODULE ) { item = (TEXTE_MODULE*) boardItem; + if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_ModuleTextWidth ) { @@ -363,7 +377,9 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) } } } + break; + default: break; } @@ -380,19 +396,21 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) for( ii = 0; ii < undoItemList.GetCount(); ii++ ) { module = (MODULE*) undoItemList.GetPickedItem( ii ); + switch( aType ) { case TEXT_is_REFERENCE: module->m_Reference->SetThickness( g_ModuleTextWidth ); module->m_Reference->SetSize( g_ModuleTextSize ); break; + case TEXT_is_VALUE: module->m_Value->SetThickness( g_ModuleTextWidth ); module->m_Value->SetSize( g_ModuleTextSize ); break; + case TEXT_is_DIVERS: - for( boardItem = module->m_Drawings; boardItem; - boardItem = boardItem->Next() ) + for( boardItem = module->m_Drawings; boardItem; boardItem = boardItem->Next() ) { if( boardItem->Type() == TYPE_TEXTE_MODULE ) { @@ -401,6 +419,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) item->SetSize( g_ModuleTextSize ); } } + break; } } diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 1430db6174..db2b9b276d 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -92,7 +92,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& event ) offsetX = m_Auxiliary_Axis_Position.x; offsetY = m_Auxiliary_Axis_Position.y; - Compile_Ratsnest( NULL, TRUE ); + Compile_Ratsnest( NULL, true ); /* Temporary modification of footprints that are flipped (i.e. on bottom * layer) to convert them to non flipped footprints. @@ -101,9 +101,11 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& event ) * these changes will be undone later */ MODULE* module; + for( module = GetBoard()->m_Modules; module != NULL; module = module->Next() ) { module->flag = 0; + if( module->GetLayer() == LAYER_N_BACK ) { module->Flip( module->m_Pos ); @@ -198,12 +200,12 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) pads.insert( pads.end(), pcb->m_NetInfo->m_PadsFullList.begin(), pcb->m_NetInfo->m_PadsFullList.end() ); - qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ), - Pad_list_Sort_by_Shapes ); + qsort( &pads[0], pcb->GetPadsCount(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes ); } D_PAD* old_pad = NULL; int pad_name_number = 0; + for( unsigned i = 0; i= 0 ) // Horizontal oval { - int rayon = dy; + int radius = dy; fprintf( file, "LINE %d %d %d %d\n", - -dr + pad->m_Offset.x, -pad->m_Offset.y - rayon, - dr + pad->m_Offset.x, -pad->m_Offset.y - rayon ); + -dr + pad->m_Offset.x, -pad->m_Offset.y - radius, + dr + pad->m_Offset.x, -pad->m_Offset.y - radius ); fprintf( file, "ARC %d %d %d %d %d %d\n", - dr + pad->m_Offset.x, -pad->m_Offset.y - rayon, - dr + pad->m_Offset.x, -pad->m_Offset.y + rayon, + dr + pad->m_Offset.x, -pad->m_Offset.y - radius, + dr + pad->m_Offset.x, -pad->m_Offset.y + radius, dr + pad->m_Offset.x, -pad->m_Offset.y ); fprintf( file, "LINE %d %d %d %d\n", - dr + pad->m_Offset.x, -pad->m_Offset.y + rayon, - -dr + pad->m_Offset.x, -pad->m_Offset.y + rayon ); + dr + pad->m_Offset.x, -pad->m_Offset.y + radius, + -dr + pad->m_Offset.x, -pad->m_Offset.y + radius ); fprintf( file, "ARC %d %d %d %d %d %d\n", - -dr + pad->m_Offset.x, -pad->m_Offset.y + rayon, - -dr + pad->m_Offset.x, -pad->m_Offset.y - rayon, + -dr + pad->m_Offset.x, -pad->m_Offset.y + radius, + -dr + pad->m_Offset.x, -pad->m_Offset.y - radius, -dr + pad->m_Offset.x, -pad->m_Offset.y ); } else // Vertical oval { dr = -dr; - int rayon = dx; + int radius = dx; fprintf( file, "LINE %d %d %d %d\n", - -rayon + pad->m_Offset.x, -pad->m_Offset.y - dr, - -rayon + pad->m_Offset.x, -pad->m_Offset.y + dr ); + -radius + pad->m_Offset.x, -pad->m_Offset.y - dr, + -radius + pad->m_Offset.x, -pad->m_Offset.y + dr ); fprintf( file, "ARC %d %d %d %d %d %d\n", - -rayon + pad->m_Offset.x, -pad->m_Offset.y + dr, - rayon + pad->m_Offset.x, -pad->m_Offset.y + dr, + -radius + pad->m_Offset.x, -pad->m_Offset.y + dr, + radius + pad->m_Offset.x, -pad->m_Offset.y + dr, pad->m_Offset.x, -pad->m_Offset.y + dr ); fprintf( file, "LINE %d %d %d %d\n", - rayon + pad->m_Offset.x, -pad->m_Offset.y + dr, - rayon + pad->m_Offset.x, -pad->m_Offset.y - dr ); + radius + pad->m_Offset.x, -pad->m_Offset.y + dr, + radius + pad->m_Offset.x, -pad->m_Offset.y - dr ); fprintf( file, "ARC %d %d %d %d %d %d\n", - rayon + pad->m_Offset.x, -pad->m_Offset.y - dr, - -rayon + pad->m_Offset.x, -pad->m_Offset.y - dr, + radius + pad->m_Offset.x, -pad->m_Offset.y - dr, + -radius + pad->m_Offset.x, -pad->m_Offset.y - dr, pad->m_Offset.x, -pad->m_Offset.y - dr ); } break; @@ -349,17 +351,19 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) for( module = pcb->m_Modules; module != NULL; module = module->Next() ) { FootprintWriteShape( file, module ); + for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { layer = "ALL"; - if( ( pad->m_Masque_Layer & ALL_CU_LAYERS ) == LAYER_BACK ) + + if( ( pad->m_layerMask & ALL_CU_LAYERS ) == LAYER_BACK ) { if( module->GetLayer() == LAYER_N_FRONT ) layer = "BOTTOM"; else layer = "TOP"; } - else if( ( pad->m_Masque_Layer & ALL_CU_LAYERS ) == LAYER_FRONT ) + else if( ( pad->m_layerMask & ALL_CU_LAYERS ) == LAYER_FRONT ) { if( module->GetLayer() == LAYER_N_FRONT ) layer = "TOP"; @@ -368,6 +372,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) } pad->ReturnStringPadName( pinname ); + if( pinname.IsEmpty() ) pinname = wxT( "noname" ); @@ -377,8 +382,10 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) TO_UTF8( pinname ), pad->GetSubRatsnest(), pad->m_Pos0.x, -pad->m_Pos0.y, layer, orient / 10, mirror ); + if( orient % 10 ) fprintf( file, " .%d", orient % 10 ); + fprintf( file, "\n" ); } } @@ -406,6 +413,7 @@ void CreateComponentsSection( FILE* file, BOARD* pcb ) for( ; module != NULL; module = module->Next() ) { int orient = module->m_Orient; + if( module->flag ) { mirror = "MIRRORX"; // Mirrored relative to X axis @@ -420,24 +428,22 @@ void CreateComponentsSection( FILE* file, BOARD* pcb ) flip = "0"; } - fprintf( file, "COMPONENT %s\n", - TO_UTF8( module->m_Reference->m_Text ) ); - fprintf( file, "DEVICE %s\n", - TO_UTF8( module->m_Reference->m_Text ) ); - fprintf( file, "PLACE %d %d\n", mapXto( module->m_Pos.x ), - mapYto( module->m_Pos.y ) ); + fprintf( file, "COMPONENT %s\n", TO_UTF8( module->m_Reference->m_Text ) ); + fprintf( file, "DEVICE %s\n", TO_UTF8( module->m_Reference->m_Text ) ); + fprintf( file, "PLACE %d %d\n", mapXto( module->m_Pos.x ), mapYto( module->m_Pos.y ) ); fprintf( file, "LAYER %s\n", (module->flag) ? "BOTTOM" : "TOP" ); - fprintf( file, "ROTATION %d", orient / 10 ); + if( orient % 10 ) fprintf( file, ".%d", orient % 10 ); + fputs( "\n", file ); - fprintf( file, "SHAPE %s %s %s\n", - TO_UTF8( module->m_Reference->m_Text ), mirror, flip ); + fprintf( file, "SHAPE %s %s %s\n", TO_UTF8( module->m_Reference->m_Text ), mirror, flip ); /* creates texts (ref and value) */ PtTexte = module->m_Reference; + for( ii = 0; ii < 2; ii++ ) { int orient = PtTexte->m_Orient; @@ -489,8 +495,8 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) for( unsigned ii = 0; ii < pcb->m_NetInfo->GetCount(); ii++ ) { net = pcb->m_NetInfo->GetNetItem( ii ); - if( net->GetNetname() == wxEmptyString ) // dummy netlist (no - // connection) + + if( net->GetNetname() == wxEmptyString ) // dummy netlist (no connection) { wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++; net->SetNetname( msg ); @@ -509,6 +515,7 @@ void CreateSignalsSection( FILE* file, BOARD* pcb ) for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { wxString padname; + if( pad->GetNet() != net->GetNet() ) continue; @@ -536,13 +543,11 @@ bool CreateHeaderInfoData( FILE* file, PCB_EDIT_FRAME* frame ) fputs( "$HEADER\n", file ); fputs( "GENCAD 1.4\n", file ); - msg = wxT( "USER " ) + wxGetApp().GetAppName() + wxT( " " ) + - GetBuildVersion(); + msg = wxT( "USER " ) + wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); fputs( TO_UTF8( msg ), file ); fputs( "\n", file ); msg = wxT( "DRAWING " ) + screen->GetFileName(); fputs( TO_UTF8( msg ), file ); fputs( "\n", file ); - msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) + - screen->m_Date; + msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) + screen->m_Date; fputs( TO_UTF8( msg ), file ); fputs( "\n", file ); msg.Printf( wxT( "UNITS USER %d" ), PCB_INTERNAL_UNIT ); fputs( TO_UTF8( msg ), file ); fputs( "\n", file ); @@ -553,7 +558,7 @@ bool CreateHeaderInfoData( FILE* file, PCB_EDIT_FRAME* frame ) fputs( "INTERTRACK 0\n", file ); fputs( "$ENDHEADER\n\n", file ); - return TRUE; + return true; } @@ -568,10 +573,13 @@ static int Track_list_Sort_by_Netcode( const void* refptr, const void* objptr ) ref = *( (TRACK**) refptr ); cmp = *( (TRACK**) objptr ); + if( ( diff = ref->GetNet() - cmp->GetNet() ) ) return diff; + if( ( diff = ref->m_Width - cmp->m_Width ) ) return diff; + if( ( diff = ref->GetLayer() - cmp->GetLayer() ) ) return diff; @@ -625,6 +633,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) fputs( "$ROUTES\n", file ); old_netcode = -1; old_width = -1; old_layer = -1; + for( ii = 0; ii < nbitems; ii++ ) { track = tracklist[ii]; @@ -633,10 +642,12 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) old_netcode = track->GetNet(); NETINFO_ITEM* net = pcb->FindNet( track->GetNet() ); wxString netname; + if( net && (net->GetNetname() != wxEmptyString) ) netname = net->GetNetname(); else netname = wxT( "_noname_" ); + fprintf( file, "ROUTE %s\n", TO_UTF8( netname ) ); } @@ -652,8 +663,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) { old_layer = track->GetLayer(); fprintf( file, "LAYER %s\n", - TO_UTF8( GenCAD_Layer_Name[track->GetLayer() & - 0x1F] ) ); + TO_UTF8( GenCAD_Layer_Name[track->GetLayer() & 0x1F] ) ); } fprintf( file, "LINE %d %d %d %d\n", @@ -688,21 +698,21 @@ void CreateDevicesSection( FILE* file, BOARD* pcb ) for( module = pcb->m_Modules; module != NULL; module = module->Next() ) { - fprintf( file, "DEVICE %s\n", - TO_UTF8( module->m_Reference->m_Text ) ); + fprintf( file, "DEVICE %s\n", TO_UTF8( module->m_Reference->m_Text ) ); fprintf( file, "PART %s\n", TO_UTF8( module->m_LibRef ) ); fprintf( file, "TYPE %s\n", "UNKNOWN" ); + for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { fprintf( file, "PINDESCR %.4s", pad->m_Padname ); + if( pad->GetNetname() == wxEmptyString ) fputs( " NoConn\n", file ); else fprintf( file, " %.4s\n", pad->m_Padname ); } - fprintf( file, "ATTRIBUTE %s\n", - TO_UTF8( module->m_Value->m_Text ) ); + fprintf( file, "ATTRIBUTE %s\n", TO_UTF8( module->m_Value->m_Text ) ); } fputs( "$ENDDEVICES\n\n", file ); @@ -760,6 +770,7 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb ) std::vector trackinfo; unsigned ii; + for( track = pcb->m_Track; track != NULL; track = track->Next() ) { if( last_width != track->m_Width ) // Find a thickness already used. @@ -796,6 +807,7 @@ void CreateTracksInfoData( FILE* file, BOARD* pcb ) // Write data fputs( "$TRACKS\n", file ); + for( ii = 0; ii < trackinfo.size(); ii++ ) { fprintf( file, "TRACK TRACK%d %d\n", trackinfo[ii], trackinfo[ii] ); @@ -824,22 +836,25 @@ void FootprintWriteShape( FILE* file, MODULE* module ) /* creates header: */ fprintf( file, "SHAPE %s\n", TO_UTF8( module->m_Reference->m_Text ) ); - fprintf( file, "INSERT %s\n", - (module->m_Attributs & MOD_CMS) ? "SMD" : "TH" ); + fprintf( file, "INSERT %s\n", (module->m_Attributs & MOD_CMS) ? "SMD" : "TH" ); /* creates Attributes */ if( module->m_Attributs != MOD_DEFAULT ) { fprintf( file, "ATTRIBUTE" ); + if( module->m_Attributs & MOD_CMS ) fprintf( file, " PAD_SMD" ); + if( module->m_Attributs & MOD_VIRTUAL ) fprintf( file, " VIRTUAL" ); + fprintf( file, "\n" ); } /* creates Drawing */ item = module->m_Drawings; + for( ; item != NULL; item = item->Next() ) { switch( item->Type() ) @@ -860,12 +875,10 @@ void FootprintWriteShape( FILE* file, MODULE* module ) case S_CIRCLE: { - int rayon = (int) hypot( - (double) ( edge->m_End0.x - edge->m_Start0.x ), - (double) ( edge->m_End0.y - edge->m_Start0.y ) ); + int radius = (int) hypot( (double) ( edge->m_End0.x - edge->m_Start0.x ), + (double) ( edge->m_End0.y - edge->m_Start0.y ) ); fprintf( file, "CIRCLE %d %d %d\n", - edge->m_Start0.x, y_axis_sign * edge->m_Start0.y, - rayon ); + edge->m_Start0.x, y_axis_sign * edge->m_Start0.y, radius ); break; } @@ -876,7 +889,8 @@ void FootprintWriteShape( FILE* file, MODULE* module ) // edge->m_Start0 is the arc center relative to the shape position // edge->m_End0 is the arc start point relative to the shape position arcStart = edge->m_End0; - // calculate arcEnd arc end point relative to the shape position, in pcbnew coordinates + // calculate arcEnd arc end point relative to the shape position, in pcbnew + // coordinates arcEnd = arcStart; RotatePoint( &arcEnd, edge->m_Start0, -edge->m_Angle ); // due to difference between pcbnew and gencad, swap arc start and arc end diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index 630f5dec9c..8ed490377b 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -168,8 +168,7 @@ static void bag_flat_triangle( int layer, /*{{{*/ { double z = layer_z[layer]; - layer_triangles[layer].push_back( Triangle( x1, y1, z, - x2, y2, z, x3, y3, z ) ); + layer_triangles[layer].push_back( Triangle( x1, y1, z, x2, y2, z, x3, y3, z ) ); } @@ -178,12 +177,10 @@ void FlatFan::bag( int layer, bool close ) /*{{{*/ unsigned i; for( i = 0; i < pts.size() - 1; i++ ) - bag_flat_triangle( layer, c.x, c.y, pts[i].x, pts[i].y, - pts[i + 1].x, pts[i + 1].y ); + bag_flat_triangle( layer, c.x, c.y, pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y ); if( close ) - bag_flat_triangle( layer, c.x, c.y, pts[i].x, pts[i].y, - pts[0].x, pts[0].y ); + bag_flat_triangle( layer, c.x, c.y, pts[i].x, pts[i].y, pts[0].x, pts[0].y ); } @@ -222,14 +219,12 @@ static void bag_vquad( TriangleBag& triangles, /*{{{*/ double x1, double y1, double x2, double y2, double z1, double z2 ) { - triangles.push_back( Triangle( - x1, y1, z1, - x2, y2, z1, - x2, y2, z2 ) ); - triangles.push_back( Triangle( - x1, y1, z1, - x2, y2, z2, - x1, y1, z2 ) ); + triangles.push_back( Triangle( x1, y1, z1, + x2, y2, z1, + x2, y2, z2 ) ); + triangles.push_back( Triangle( x1, y1, z1, + x2, y2, z2, + x1, y1, z2 ) ); } @@ -345,8 +340,7 @@ static void write_triangle_bag( FILE* output_file, int color_index, /*{{{*/ i != triangles.end(); i++ ) { - fprintf( output_file, "%d %d %d -1\n", - j, j + 1, j + 2 ); + fprintf( output_file, "%d %d %d -1\n", j, j + 1, j + 2 ); j += 3; } } @@ -408,6 +402,7 @@ static void export_vrml_line( int layer, double startx, double starty, /*{{{*/ /* Output the 'bone' as a triangle fan, this is the fan centre */ fan.c.x = (startx + endx) / 2; fan.c.y = (starty + endy) / 2; + /* The 'end' side cap */ for( alpha = angle - PI2; alpha < angle + PI2; alpha += PI2 / divisions ) fan.add( endx + r * cos( alpha ), endy + r * sin( alpha ) ); @@ -428,16 +423,16 @@ static void export_vrml_line( int layer, double startx, double starty, /*{{{*/ static void export_vrml_circle( int layer, double startx, double starty, /*{{{*/ double endx, double endy, double width, int divisions ) { - double hole, rayon; + double hole, radius; FlatRing ring; - rayon = hypot( startx - endx, starty - endy ) + ( width / 2); - hole = rayon - width; + radius = hypot( startx - endx, starty - endy ) + ( width / 2); + hole = radius - width; for( double alpha = 0; alpha < M_PI * 2; alpha += M_PI * 2 / divisions ) { ring.add_inner( startx + hole * cos( alpha ), starty + hole * sin( alpha ) ); - ring.add_outer( startx + rayon * cos( alpha ), starty + rayon * sin( alpha ) ); + ring.add_outer( startx + radius * cos( alpha ), starty + radius * sin( alpha ) ); } ring.bag( layer ); @@ -454,6 +449,7 @@ static void export_vrml_slot( TriangleBag& triangles, /*{{{*/ loop.z_top = layer_z[top_layer]; loop.z_bottom = layer_z[bottom_layer]; double angle = orient / 1800.0 * M_PI; + if( dy > dx ) { EXCHG( dx, dy ); @@ -466,14 +462,17 @@ static void export_vrml_slot( TriangleBag& triangles, /*{{{*/ /* The first side cap */ capx = xc + cos( angle ) * dx / 2; capy = yc + sin( angle ) * dx / 2; + for( alpha = angle - PI2; alpha < angle + PI2; alpha += PI2 / divisions ) loop.add( capx + r * cos( alpha ), capy + r * sin( alpha ) ); alpha = angle + PI2; loop.add( capx + r * cos( alpha ), capy + r * sin( alpha ) ); + /* The other side cap */ capx = xc - cos( angle ) * dx / 2; capy = yc - sin( angle ) * dx / 2; + for( alpha = angle + PI2; alpha < angle + 3 * PI2; alpha += PI2 / divisions ) loop.add( capx + r * cos( alpha ), capy + r * sin( alpha ) ); @@ -491,6 +490,7 @@ static void export_vrml_hole( TriangleBag& triangles, /*{{{*/ loop.z_top = layer_z[top_layer]; loop.z_bottom = layer_z[bottom_layer]; + for( double alpha = 0; alpha < M_PI * 2; alpha += M_PI * 2 / divisions ) loop.add( xc + cos( alpha ) * hole, yc + sin( alpha ) * hole ); @@ -507,10 +507,11 @@ static void export_vrml_varc( TriangleBag& triangles, /*{{{*/ loop.z_top = layer_z[top_layer]; loop.z_bottom = layer_z[bottom_layer]; double angle = atan2( endx - startx, endy - starty ); - double rayon = hypot( startx - endx, starty - endy ); + double radius = hypot( startx - endx, starty - endy ); + for( double alpha = angle; alpha < angle + PI2; alpha += PI2 / divisions ) { - loop.add( startx + cos( alpha ) * rayon, starty + sin( alpha ) * rayon ); + loop.add( startx + cos( alpha ) * radius, starty + sin( alpha ) * radius ); } loop.bag( triangles ); @@ -527,6 +528,7 @@ static void export_vrml_oval_pad( int layer, /*{{{*/ fan.c.x = xc; fan.c.y = yc; double angle = orient / 1800.0 * M_PI; + if( dy > dx ) { EXCHG( dx, dy ); @@ -536,9 +538,11 @@ static void export_vrml_oval_pad( int layer, /*{{{*/ /* The exchange above means that cutter radius is alvays dy/2 */ double r = dy / 2; double alpha; + /* The first side cap */ capx = xc + cos( angle ) * dx / 2; capy = yc + sin( angle ) * dx / 2; + for( alpha = angle - PI2; alpha < angle + PI2; alpha += PI2 / divisions ) fan.add( capx + r * cos( alpha ), capy + r * sin( alpha ) ); @@ -547,6 +551,7 @@ static void export_vrml_oval_pad( int layer, /*{{{*/ /* The other side cap */ capx = xc - cos( angle ) * dx / 2; capy = yc - sin( angle ) * dx / 2; + for( alpha = angle + PI2; alpha < angle + 3 * PI2; alpha += PI2 / divisions ) fan.add( capx + r * cos( alpha ), capy + r * sin( alpha ) ); @@ -560,16 +565,16 @@ static void export_vrml_arc( int layer, double startx, double starty, /*{{{*/ double endx, double endy, double width, int divisions ) { FlatRing ring; - double hole, rayon; + double hole, radius; double angle = atan2( endx - startx, endy - starty ); - rayon = hypot( startx - endx, starty - endy ) + ( width / 2); - hole = rayon - width; + radius = hypot( startx - endx, starty - endy ) + ( width / 2); + hole = radius - width; for( double alpha = angle; alpha < angle + PI2; alpha += PI2 / divisions ) { ring.add_inner( startx + cos( alpha ) * hole, starty + sin( alpha ) * hole ); - ring.add_outer( startx + cos( alpha ) * rayon, starty + sin( alpha ) * rayon ); + ring.add_outer( startx + cos( alpha ) * radius, starty + sin( alpha ) * radius ); } ring.bag( layer, false ); @@ -650,9 +655,11 @@ static void export_vrml_pcbtext( TEXTE_PCB* text ) /* Coupling by globals! Ewwww... */ s_text_layer = text->GetLayer(); s_text_width = text->m_Thickness; + wxSize size = text->m_Size; if( text->m_Mirror ) NEGATE( size.x ); + if( text->m_MultilineAllowed ) { wxPoint pos = text->m_Pos; @@ -720,6 +727,7 @@ static void export_round_padstack( BOARD* pcb, double x, double y, double r, /*{ /* The last layer is always the component one, unless it's single face */ if( (layer > FIRST_COPPER_LAYER) && (layer == copper_layers - 1) ) layer = LAST_COPPER_LAYER; + if( layer <= top_layer ) export_vrml_circle( layer, x, y, x + r / 2, y, r, divisions ); } @@ -890,7 +898,7 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ } /* The pad proper, on the selected layers */ - unsigned long layer_mask = pad->m_Masque_Layer; + unsigned long layer_mask = pad->m_layerMask; int copper_layers = pcb->GetCopperLayerCount( ); /* The (maybe offseted) pad position */ wxPoint pad_pos = pad->ReturnShapePos(); @@ -901,6 +909,7 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ double pad_dy = pad_delta.y / 2; double pad_w = pad->m_Size.x / 2; double pad_h = pad->m_Size.y / 2; + for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ ) { /* The last layer is always the component one, unless it's single face */ @@ -973,6 +982,7 @@ static void build_quat( double x, double y, double z, double a, double q[4] ) static void from_quat( double q[4], double rot[4] ) { rot[3] = acos( q[3] ) * 2; + for( int i = 0; i < 3; i++ ) { rot[i] = q[i] / sin( rot[3] / 2 ); @@ -995,8 +1005,8 @@ static void compose_quat( double q1[4], double q2[4], double qr[4] ) static void export_vrml_module( BOARD* aPcb, MODULE* aModule, - FILE* aOutputFile, double aScalingFactor, - bool aExport3DFiles, const wxString & a3D_Subdir ) + FILE* aOutputFile, double aScalingFactor, + bool aExport3DFiles, const wxString & a3D_Subdir ) { /* Reference and value */ export_vrml_text_module( aModule->m_Reference ); @@ -1021,17 +1031,16 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, } /* Export pads */ - for( D_PAD* pad = aModule->m_Pads; - pad != 0; - pad = pad->Next() ) + for( D_PAD* pad = aModule->m_Pads; pad != 0; pad = pad->Next() ) export_vrml_pad( aPcb, pad ); bool isFlipped = aModule->GetLayer() == LAYER_N_BACK; + /* Export the object VRML model(s) */ - for( S3D_MASTER* vrmlm = aModule->m_3D_Drawings; - vrmlm != 0; vrmlm = vrmlm->Next() ) + for( S3D_MASTER* vrmlm = aModule->m_3D_Drawings; vrmlm != 0; vrmlm = vrmlm->Next() ) { wxString fname = vrmlm->m_Shape3DName; + if( fname.IsEmpty() ) continue; @@ -1039,16 +1048,19 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, { wxFileName fn = fname; fname = wxGetApp().FindLibraryPath( fn ); + if( fname.IsEmpty() ) // keep "short" name if full filemane not found fname = vrmlm->m_Shape3DName; } fname.Replace(wxT("\\"), wxT("/" ) ); wxString source_fname = fname; + if( aExport3DFiles ) // Change illegal characters in short filename { ChangeIllegalCharacters( fname, true ); fname = a3D_Subdir + wxT("/") + fname; + if( !wxFileExists( fname ) ) wxCopyFile( source_fname, fname ); } @@ -1061,6 +1073,7 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, double rotx = - vrmlm->m_MatRotation.x; double roty = - vrmlm->m_MatRotation.y; double rotz = - vrmlm->m_MatRotation.z; + if ( isFlipped ) { rotx += 180.0; @@ -1085,13 +1098,14 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, /* A null rotation would fail the acos! */ if( rot[3] != 0.0 ) { - fprintf( aOutputFile, " rotation %g %g %g %g\n", - rot[0], rot[1], rot[2], rot[3] ); + fprintf( aOutputFile, " rotation %g %g %g %g\n", rot[0], rot[1], rot[2], rot[3] ); } + fprintf( aOutputFile, " scale %g %g %g\n", vrmlm->m_MatScale.x * aScalingFactor, vrmlm->m_MatScale.y * aScalingFactor, vrmlm->m_MatScale.z * aScalingFactor ); + /* adjust 3D shape offset position (offset is given inch) */ #define UNITS_3D_TO_PCB_UNITS PCB_INTERNAL_UNIT int offsetx = wxRound( vrmlm->m_MatPosition.x * UNITS_3D_TO_PCB_UNITS ); @@ -1110,16 +1124,14 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, - (double)(offsety + aModule->m_Pos.y), // Y axis is reversed in pcbnew offsetz + layer_z[aModule->GetLayer()] ); fprintf( aOutputFile, - " children [\n Inline {\n url \"%s\"\n } ]\n", - TO_UTF8( fname ) ); + " children [\n Inline {\n url \"%s\"\n } ]\n", + TO_UTF8( fname ) ); fprintf( aOutputFile, " }\n" ); - } } -static void write_and_empty_triangle_bag( FILE* output_file, - TriangleBag& triangles, int color ) +static void write_and_empty_triangle_bag( FILE* output_file, TriangleBag& triangles, int color ) { if( !triangles.empty() ) { @@ -1158,8 +1170,10 @@ wxBusyCursor dummy; wxString fullFilename = dlg.FilePicker()->GetPath(); subDirFor3Dshapes = dlg.GetSubdir(); + if( ! wxDirExists( subDirFor3Dshapes ) ) wxMkdir( subDirFor3Dshapes ); + if( ! ExportVRML_File( fullFilename, scale, export3DFiles, subDirFor3Dshapes ) ) { wxString msg = _( "Unable to create " ) + fullFilename; @@ -1215,12 +1229,13 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName, /* scaling factor to convert internal units (decimils) to inches */ double board_scaling_factor = 0.0001; + /* auxiliary scale to export to a different scale. */ double general_scaling_factor = board_scaling_factor * aScale; - fprintf(output_file, "Transform {\n"); - fprintf(output_file, " scale %g %g %g\n", - general_scaling_factor, general_scaling_factor, general_scaling_factor ); + fprintf( output_file, "Transform {\n" ); + fprintf( output_file, " scale %g %g %g\n", + general_scaling_factor, general_scaling_factor, general_scaling_factor ); /* Define the translation to have the board centre to the 2D axis origin * more easy for rotations... @@ -1228,9 +1243,9 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName, pcb->ComputeBoundingBox(); double dx = board_scaling_factor * pcb->m_BoundaryBox.Centre().x * aScale; double dy = board_scaling_factor * pcb->m_BoundaryBox.Centre().y * aScale; - fprintf(output_file, " translation %g %g 0.0\n", -dx, dy ); + fprintf( output_file, " translation %g %g 0.0\n", -dx, dy ); - fprintf(output_file, " children [\n" ); + fprintf( output_file, " children [\n" ); /* scaling factor to convert 3D models to board units (decimils) * Usually we use Wings3D to create thems. @@ -1238,7 +1253,8 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName, * So the scaling factor from 0.1 inch to board units * is 0.1 / board_scaling_factor */ - double wrml_3D_models_scaling_factor = 0.1 / board_scaling_factor; + + double wrml_3D_models_scaling_factor = 0.1 / board_scaling_factor; /* Preliminary computation: the z value for each layer */ compute_layer_Zs( pcb ); @@ -1253,9 +1269,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName, */ /* Export footprints */ - for( MODULE* module = pcb->m_Modules; - module != 0; - module = module->Next() ) + for( MODULE* module = pcb->m_Modules; module != 0; module = module->Next() ) export_vrml_module( pcb, module, output_file, wrml_3D_models_scaling_factor, aExport3DFiles, a3D_Subdir ); @@ -1291,6 +1305,7 @@ static void ChangeIllegalCharacters( wxString & aFileName, bool aDirSepIsIllegal { if( aDirSepIsIllegal ) aFileName.Replace(wxT("/"), wxT("_" ) ); + aFileName.Replace(wxT(" "), wxT("_" ) ); aFileName.Replace(wxT(":"), wxT("_" ) ); } diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index 51813cce0a..cc7ced1a55 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -36,7 +36,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) PCB_SCREEN* screen = (PCB_SCREEN*) ( m_Parent->GetScreen() ); wxPoint locate_pos; wxString msg; - bool FindMarker = FALSE; + bool FindMarker = false; BOARD_ITEM* foundItem = 0; switch( event.GetId() ) @@ -51,7 +51,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) // fall thru case ID_FIND_NEXT_MARKER: - FindMarker = TRUE; + FindMarker = true; break; } @@ -63,6 +63,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) if( FindMarker ) { MARKER_PCB* marker = m_Parent->GetBoard()->GetMARKER( s_MarkerCount++ ); + if( marker ) { foundItem = marker; @@ -72,14 +73,13 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) else { int StartCount = 0; - for( MODULE* module = m_Parent->GetBoard()->m_Modules; - module; - module = module->Next() ) + + for( MODULE* module = m_Parent->GetBoard()->m_Modules; module; module = module->Next() ) { - if( WildCompareString( s_OldStringFound, - module->GetReference().GetData(), FALSE ) ) + if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), false ) ) { StartCount++; + if( StartCount > s_ItemCount ) { foundItem = module; @@ -88,10 +88,11 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) break; } } - if( WildCompareString( s_OldStringFound, - module->m_Value->m_Text.GetData(), FALSE ) ) + + if( WildCompareString( s_OldStringFound, module->m_Value->m_Text.GetData(), false ) ) { StartCount++; + if( StartCount > s_ItemCount ) { foundItem = module; @@ -201,10 +202,12 @@ bool WinEDA_PcbFindFrame::Create( wxWindow* parent, wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); + if( GetSizer() ) { GetSizer()->SetSizeHints( this ); } + Centre(); ////@end WinEDA_PcbFindFrame creation diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index f558fe1d1f..4a7dab80aa 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -119,15 +119,12 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, /* Draw items on edge layer */ - for( PtStruct = aPcb->m_Drawings; - PtStruct != NULL; - PtStruct = PtStruct->Next() ) + for( PtStruct = aPcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { switch( PtStruct->Type() ) { case TYPE_DRAWSEGMENT: - PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, EDGE_LAYER, - FILLED ); + PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, EDGE_LAYER, FILLED ); break; case TYPE_TEXTE: @@ -138,8 +135,8 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, PlotDimension( plotter, (DIMENSION*) PtStruct, EDGE_LAYER, FILLED ); break; - case TYPE_MIRE: - PlotMirePcb( plotter, (MIREPCB*) PtStruct, EDGE_LAYER, FILLED ); + case PCB_TARGET_T: + PlotPcbTarget( plotter, (PCB_TARGET*) PtStruct, EDGE_LAYER, FILLED ); break; case TYPE_MARKER_PCB: // do not draw @@ -181,6 +178,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, for( unsigned ii = 0; ii < aToolListBuffer.size(); ii++ ) { int plot_diam; + if( aToolListBuffer[ii].m_TotalCount == 0 ) continue; @@ -203,6 +201,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, sprintf( line, "%2.2fmm / %2.3f\" ", double (aToolListBuffer[ii].m_Diameter) * 0.00254, double (aToolListBuffer[ii].m_Diameter) * 0.0001 ); + msg = FROM_UTF8( line ); // Now list how many holes and ovals are associated with each drill. @@ -212,16 +211,15 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, else if( aToolListBuffer[ii].m_TotalCount == 1 ) // && ( aToolListBuffer[ii]m_OvalCount == 1 ) sprintf( line, "(1 slot)" ); else if( aToolListBuffer[ii].m_OvalCount == 0 ) - sprintf( line, "(%d holes)", - aToolListBuffer[ii].m_TotalCount ); + sprintf( line, "(%d holes)", aToolListBuffer[ii].m_TotalCount ); else if( aToolListBuffer[ii].m_OvalCount == 1 ) - sprintf( line, "(%d holes + 1 slot)", - aToolListBuffer[ii].m_TotalCount - 1 ); + sprintf( line, "(%d holes + 1 slot)", aToolListBuffer[ii].m_TotalCount - 1 ); else // if ( aToolListBuffer[ii]m_OvalCount > 1 ) sprintf( line, "(%d holes + %d slots)", aToolListBuffer[ii].m_TotalCount - aToolListBuffer[ii].m_OvalCount, aToolListBuffer[ii].m_OvalCount ); + msg += FROM_UTF8( line ); plotter->text( wxPoint( plotX, y ), BLACK, msg, @@ -258,8 +256,7 @@ void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* aPlotter, if( aToolListBuffer.size() > 13 ) { DisplayInfoMessage( NULL, - _( - " Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values" ), + _( " Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values" ), 10 ); } @@ -271,13 +268,14 @@ void Gen_Drill_PcbMap( BOARD* aPcb, PLOTTER* aPlotter, /* Always plot the drill symbol (for slots identifies the needed * cutter!) */ aPlotter->marker( pos, aHoleListBuffer[ii].m_Hole_Diameter, - aHoleListBuffer[ii].m_Tool_Reference - 1 ); + aHoleListBuffer[ii].m_Tool_Reference - 1 ); + if( aHoleListBuffer[ii].m_Hole_Shape != 0 ) { wxSize oblong_size; oblong_size = aHoleListBuffer[ii].m_Hole_Size; aPlotter->flash_pad_oval( pos, oblong_size, - aHoleListBuffer[ii].m_Hole_Orient, FILAIRE ); + aHoleListBuffer[ii].m_Hole_Orient, FILAIRE ); } } } @@ -345,8 +343,8 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, } sprintf( line, "Drill report for holes from layer %s to layer %s\n", - TO_UTF8( aPcb->GetLayerName( layer1 ) ), - TO_UTF8( aPcb->GetLayerName( layer2 ) ) ); + TO_UTF8( aPcb->GetLayerName( layer1 ) ), + TO_UTF8( aPcb->GetLayerName( layer2 ) ) ); } fputs( line, aFile ); @@ -366,6 +364,7 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, ii + 1, double (aToolListBuffer[ii].m_Diameter) * 0.00254, double (aToolListBuffer[ii].m_Diameter) * 0.0001 ); + fputs( line, aFile ); // Now list how many holes and ovals are associated with each drill. @@ -375,15 +374,14 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, else if( aToolListBuffer[ii].m_TotalCount == 1 ) sprintf( line, "(1 hole) (with 1 oblong)\n" ); else if( aToolListBuffer[ii].m_OvalCount == 0 ) - sprintf( line, "(%d holes)\n", - aToolListBuffer[ii].m_TotalCount ); + sprintf( line, "(%d holes)\n", aToolListBuffer[ii].m_TotalCount ); else if( aToolListBuffer[ii].m_OvalCount == 1 ) - sprintf( line, "(%d holes) (with 1 oblong)\n", - aToolListBuffer[ii].m_TotalCount ); + sprintf( line, "(%d holes) (with 1 oblong)\n", aToolListBuffer[ii].m_TotalCount ); else // if ( buffer[ii]m_OvalCount > 1 ) sprintf( line, "(%d holes) (with %d oblongs)\n", aToolListBuffer[ii].m_TotalCount, aToolListBuffer[ii].m_OvalCount ); + fputs( line, aFile ); TotalHoleCount += aToolListBuffer[ii].m_TotalCount; @@ -393,6 +391,7 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, sprintf( line, "\ntotal Not Plated holes count %d\n\n\n", TotalHoleCount ); else sprintf( line, "\ntotal plated holes count %d\n\n\n", TotalHoleCount ); + fputs( line, aFile ); if( gen_NPTH_holes ) @@ -408,7 +407,9 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, } if( gen_through_holes ) + { layer2 = layer1 + 1; + } else { if( layer2 >= LAYER_N_FRONT ) // no more layer pair to consider @@ -416,6 +417,7 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb, gen_NPTH_holes = true; continue; } + layer1++; layer2++; // use next layer pair if( layer2 == aPcb->GetCopperLayerCount() - 1 ) diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 901e8aea7f..1cdbdde36a 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -189,6 +189,7 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event ) Liste = (LIST_MOD*) MyZMalloc( moduleCount * sizeof(LIST_MOD) ); module = GetBoard()->m_Modules; + for( int ii = 0; module; module = module->Next() ) { if( module->m_Attributs & MOD_VIRTUAL ) @@ -206,8 +207,7 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event ) qsort( Liste, moduleCount, sizeof(LIST_MOD), ListeModCmp ); // Write file header - sprintf( line, "### Module positions - created on %s ###\n", - DateAndTime( Buff ) ); + sprintf( line, "### Module positions - created on %s ###\n", DateAndTime( Buff ) ); fputs( line, fpFront ); if( doBoardBack ) @@ -238,6 +238,7 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event ) sprintf( line, "# Ref Val PosX PosY Rot Side\n" ); fputs( line, fpFront ); + if( doBoardBack ) fputs( line, fpBack ); @@ -246,8 +247,7 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event ) wxPoint module_pos; wxString ref = Liste[ii].m_Reference; wxString val = Liste[ii].m_Value; - sprintf( line, "%-8.8s %-16.16s ", TO_UTF8( ref ), - TO_UTF8( val ) ); + sprintf( line, "%-8.8s %-16.16s ", TO_UTF8( ref ), TO_UTF8( val ) ); module_pos = Liste[ii].m_Module->m_Pos; module_pos.x -= File_Place_Offset.x; @@ -351,7 +351,7 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) // Switch the locale to standard C (needed to print floating point // numbers like 1.3) - SetLocaleTo_C_standard( ); + SetLocaleTo_C_standard(); /* Generate header file comments.) */ sprintf( line, "## Module report - date %s\n", DateAndTime( Buff ) ); @@ -381,6 +381,7 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) fputs( "$EndBOARD\n\n", rptfile ); Module = (MODULE*) GetBoard()->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() ); @@ -394,12 +395,16 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) fputs( line, rptfile ); msg = wxT( "attribut" ); + if( Module->m_Attributs & MOD_VIRTUAL ) msg += wxT( " virtual" ); + if( Module->m_Attributs & MOD_CMS ) msg += wxT( " smd" ); + if( ( Module->m_Attributs & (MOD_VIRTUAL | MOD_CMS) ) == 0 ) msg += wxT( " none" ); + msg += wxT( "\n" ); fputs( TO_UTF8( msg ), rptfile ); @@ -413,12 +418,14 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) fputs( line, rptfile ); sprintf( line, "orientation %.2f\n", (double) Module->m_Orient / 10 ); + if( Module->GetLayer() == LAYER_N_FRONT ) strcat( line, "layer component\n" ); else if( Module->GetLayer() == LAYER_N_BACK ) strcat( line, "layer copper\n" ); else strcat( line, "layer other\n" ); + fputs( line, rptfile ); Module->Write_3D_Descr( rptfile ); @@ -445,16 +452,18 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) sprintf( line, "orientation %.2f\n", double(pad->m_Orient - Module->m_Orient) / 10 ); fputs( line, rptfile ); - const char* shape_name[6] = - { "??? ", "Circ", "Rect", "Oval", "trap", "spec" }; + const char* shape_name[6] = { "??? ", "Circ", "Rect", "Oval", "trap", "spec" }; sprintf( line, "Shape %s\n", shape_name[pad->m_PadShape] ); fputs( line, rptfile ); int layer = 0; - if( pad->m_Masque_Layer & LAYER_BACK ) + + if( pad->m_layerMask & LAYER_BACK ) layer = 1; - if( pad->m_Masque_Layer & LAYER_FRONT ) + + if( pad->m_layerMask & LAYER_FRONT ) layer |= 2; + const char* layer_name[4] = { "??? ", "copper", "component", "all" }; sprintf( line, "Layer %s\n", layer_name[layer] ); fputs( line, rptfile ); @@ -475,6 +484,7 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) if( ( (DRAWSEGMENT*) PtStruct )->GetLayer() != EDGE_N ) continue; + WriteDrawSegmentPcb( (DRAWSEGMENT*) PtStruct, rptfile ); } @@ -499,7 +509,7 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) { double conv_unit, ux0, uy0, dx, dy; - double rayon, width; + double radius, width; char line[1024]; conv_unit = 0.0001; /* units = INCHES */ @@ -515,10 +525,10 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) switch( PtDrawSegment->m_Shape ) { case S_CIRCLE: - rayon = hypot( dx - ux0, dy - uy0 ); + radius = hypot( dx - ux0, dy - uy0 ); fprintf( rptfile, "$CIRCLE \n" ); fprintf( rptfile, "centre %.6lf %.6lf\n", ux0, uy0 ); - fprintf( rptfile, "radius %.6lf\n", rayon ); + fprintf( rptfile, "radius %.6lf\n", radius ); fprintf( rptfile, "width %.6lf\n", width ); fprintf( rptfile, "$EndCIRCLE \n" ); break; @@ -526,7 +536,7 @@ void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) case S_ARC: { int endx = PtDrawSegment->m_End.x, endy = PtDrawSegment->m_End.y; - rayon = hypot( dx - ux0, dy - uy0 ); + radius = hypot( dx - ux0, dy - uy0 ); RotatePoint( &endx, &endy, PtDrawSegment->m_Start.x, diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 8d8f7e56bd..f11305b46d 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -121,8 +121,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( Module == NULL ) { - DisplayError( this, - wxT( "Global_Import_Pad_Settings() Error: NULL module" ) ); + DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) ); return; } @@ -135,6 +134,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( diag == -1 ) return; + if( diag == 1 ) edit_Same_Modules = true; @@ -155,6 +155,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) bool saveMe = false; D_PAD* pt_pad = (D_PAD*) Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { /* Filters changes prohibited. */ @@ -167,7 +168,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) continue; if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter - && ( pt_pad->m_Masque_Layer != aPad->m_Masque_Layer ) ) + && ( pt_pad->m_layerMask != aPad->m_layerMask ) ) continue; saveMe = true; @@ -185,6 +186,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) /* Update the current module and same others modules if requested. */ Module = (MODULE*) m_Pcb->m_Modules; + for( ; Module != NULL; Module = Module->Next() ) { if( !edit_Same_Modules && (Module != Module_Ref) ) @@ -202,6 +204,7 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) } D_PAD* pt_pad = (D_PAD*) Module->m_Pads; + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { /* Filters changes prohibited. */ @@ -215,18 +218,17 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter ) { - if( pt_pad->m_Masque_Layer != aPad->m_Masque_Layer ) + if( pt_pad->m_layerMask != aPad->m_layerMask ) continue; else - m_Pcb->m_Status_Pcb &= - ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK); + m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK); } /* Change characteristics.: */ pt_pad->m_Attribut = aPad->m_Attribut; pt_pad->m_PadShape = aPad->m_PadShape; - pt_pad->m_Masque_Layer = aPad->m_Masque_Layer; + pt_pad->m_layerMask = aPad->m_layerMask; pt_pad->m_Size = aPad->m_Size; pt_pad->m_DeltaSize = aPad->m_DeltaSize; @@ -269,7 +271,8 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) pt_pad->ComputeShapeMaxRadius(); } - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); + if( aDraw ) DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() ); } diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 2e72ab331e..17b3bb23fd 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -17,10 +17,6 @@ static void Extract_Parameters( wxArrayString& param_list, char* text ); static bool TestFlags( const wxString& flg_string, long flg_mask, const wxChar* flg_name ); -/**************************************************************/ -bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) -/**************************************************************/ - /** * Function Read_GPCB_Descr * Read a footprint description in GPCB (Newlib) format @@ -148,6 +144,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) * For pads, set to prevent a solderpaste stencil opening for the pad. Primarily * used for pads used as fiducials. */ +bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { #define TEXT_DEFAULT_SIZE 400 #define OLD_GPCB_UNIT_CONV 10 @@ -187,12 +184,13 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) // Test symbol after "Element": if [ units = 0.01 mils, and if ( units = 1 mil iprmcnt++; + if( params[iprmcnt] == wxT( "(" ) ) conv_unit = OLD_GPCB_UNIT_CONV; /* Analyse first line : * Element [element_flags, description, pcb-name, value, mark_x, mark_y, text_x, text_y, - * text_direction, text_scale, text_flags] + * text_direction, text_scale, text_flags] */ // Read flags (unused) @@ -212,6 +210,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) // Read other infos iprmcnt++; + for( int ii = 0; ii < 6; ii++ ) { if( iprmcnt < icnt_max ) @@ -220,7 +219,10 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) ibuf[ii] = 0; } else + { params[iprmcnt].ToLong( &ibuf[ii] ); + } + iprmcnt++; } @@ -267,6 +269,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) for( unsigned ii = 0; ii < 5; ii++ ) { long dim; + if( ii < (params.GetCount() - 2) ) { if( params[ii + 2].ToLong( &dim ) ) @@ -301,7 +304,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) ibuf[ii] = 0; } - int rayon = (ibuf[2] + ibuf[3]) / 4; // for and arc: ibuf[3] = ibuf[4]. pcbnew does not know ellipses + int radius = (ibuf[2] + ibuf[3]) / 4; // for and arc: ibuf[3] = ibuf[4]. pcbnew does not know ellipses wxPoint centre; centre.x = wxRound( ibuf[0] * conv_unit ); centre.y = wxRound( ibuf[1] * conv_unit ); @@ -309,9 +312,9 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) int start_angle = ibuf[4] * 10; // Pcbnew uses 0.1 degrees as units start_angle -= 1800; // Use normal X axis as reference DrawSegm->m_Angle = ibuf[5] * 10; // Angle value is clockwise in gpcb and pcbnew - DrawSegm->m_End0.x = wxRound( rayon * conv_unit ); + DrawSegm->m_End0.x = wxRound( radius * conv_unit ); DrawSegm->m_End0.y = 0; - RotatePoint( &DrawSegm->m_End0, -start_angle ); // Calculate start point coordinate of arc + RotatePoint( &DrawSegm->m_End0, -start_angle );// Calculate start point coordinate of arc DrawSegm->m_End0 += centre; DrawSegm->m_Width = wxRound( ibuf[6] * conv_unit ); @@ -323,23 +326,27 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { // format: Pad [x1 y1 x2 y2 thickness clearance mask "name" "pad_number" flags] Pad = new D_PAD( this ); Pad->m_PadShape = PAD_RECT; - Pad->m_Masque_Layer = LAYER_FRONT | SOLDERMASK_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT; + Pad->m_layerMask = LAYER_FRONT | SOLDERMASK_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT; // Set shape from flags iflgidx = params.GetCount() - 2; + if( TestFlags( params[iflgidx], 0x0080, wxT( "onsolder" ) ) ) - Pad->m_Masque_Layer = LAYER_BACK | SOLDERMASK_LAYER_BACK | SOLDERPASTE_LAYER_BACK; + Pad->m_layerMask = LAYER_BACK | SOLDERMASK_LAYER_BACK | SOLDERPASTE_LAYER_BACK; for( unsigned ii = 0; ii < 5; ii++ ) { if( ii < params.GetCount() - 2 ) { long dim; + if( params[ii + 2].ToLong( &dim ) ) ibuf[ii] = wxRound( dim * conv_unit ); } else + { ibuf[ii] = 0; + } } // Read name: @@ -356,6 +363,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) Pad->m_Size.y = ibuf[4] + abs( ibuf[1] - ibuf[3] ); Pad->m_Pos.x += m_Pos.x; Pad->m_Pos.y += m_Pos.y; + if( !TestFlags( params[iflgidx], 0x0100, wxT( "square" ) ) ) { if( Pad->m_Size.x == Pad->m_Size.y ) @@ -372,7 +380,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { // format: Pin[x y Thickness Clearance Mask DrillHole Name Number Flags] Pad = new D_PAD( this ); Pad->m_PadShape = PAD_ROUND; - Pad->m_Masque_Layer = ALL_CU_LAYERS | + Pad->m_layerMask = ALL_CU_LAYERS | SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT | SOLDERMASK_LAYER_BACK; @@ -390,7 +398,9 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) ibuf[ii] = wxRound( dim * conv_unit ); } else + { ibuf[ii] = 0; + } } // Read name: @@ -401,12 +411,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { strncpy( Pad->m_Padname, TO_UTF8( params[9] ), 4 ); } + Pad->m_Pos.x = ibuf[0]; Pad->m_Pos.y = ibuf[1]; Pad->m_Drill.x = Pad->m_Drill.y = ibuf[5]; Pad->m_Size.x = Pad->m_Size.y = ibuf[3] + Pad->m_Drill.x; Pad->m_Pos.x += m_Pos.x; Pad->m_Pos.y += m_Pos.y; + if( (Pad->m_PadShape == PAD_ROUND) && (Pad->m_Size.x != Pad->m_Size.y) ) Pad->m_PadShape = PAD_OVAL; @@ -417,6 +429,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( m_Value->m_Text.IsEmpty() ) m_Value->m_Text = wxT( "Val**" ); + if( m_Reference->m_Text.IsEmpty() ) { wxFileName filename( CmpFullFileName ); @@ -424,15 +437,11 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) } /* Recalculate the bounding box */ - Set_Rectangle_Encadrement(); + CalculateBoundingBox(); return success; } -/***********************************************************************/ -static void Extract_Parameters( wxArrayString& param_list, char* text ) -/***********************************************************************/ - /* Read a text line and extract params and tokens. * special chars are: * [ ] ( ) Begin and end of parameter list and units indicator @@ -443,8 +452,9 @@ static void Extract_Parameters( wxArrayString& param_list, char* text ) * other are parameters (number or delimited string) * last parameter is ) or ] */ +static void Extract_Parameters( wxArrayString& param_list, char* text ) { - char key; + char key; wxString tmp; while( *text != 0 ) @@ -484,6 +494,7 @@ static void Extract_Parameters( wxArrayString& param_list, char* text ) { key = *text; text++; + if( key == '"' ) { param_list.Add( tmp ); @@ -491,7 +502,9 @@ static void Extract_Parameters( wxArrayString& param_list, char* text ) break; } else + { tmp.Append( key ); + } } break; @@ -504,10 +517,6 @@ static void Extract_Parameters( wxArrayString& param_list, char* text ) } -/***********************************************************************************/ -bool TestFlags( const wxString& flg_string, long flg_mask, const wxChar* flg_name ) -/***********************************************************************************/ - /** * Function TestFlags * Test flag flg_mask or flg_name. @@ -518,19 +527,23 @@ bool TestFlags( const wxString& flg_string, long flg_mask, const wxChar* flg_nam * @param flg_name = flag name to find in list * @return true if found */ +bool TestFlags( const wxString& flg_string, long flg_mask, const wxChar* flg_name ) { wxString strnumber; - if( flg_string.StartsWith( wxT( "0x" ), - &strnumber ) || flg_string.StartsWith( wxT( "0X" ), &strnumber ) ) + if( flg_string.StartsWith( wxT( "0x" ), &strnumber ) + || flg_string.StartsWith( wxT( "0X" ), &strnumber ) ) { long lflags; + if( strnumber.ToLong( &lflags, 16 ) ) if( lflags & flg_mask ) return true; } else if( flg_string.Contains( flg_name ) ) + { return true; + } return false; } diff --git a/pcbnew/graphpcb.cpp b/pcbnew/graphpcb.cpp index a57bde3a6c..c81c8ad8da 100644 --- a/pcbnew/graphpcb.cpp +++ b/pcbnew/graphpcb.cpp @@ -41,7 +41,7 @@ static void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int radius, - int masque_layer, + int aLayerMask, int color, int op_logique ); static void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, @@ -102,7 +102,7 @@ void Place_1_Pad_Board( BOARD* Pcb, if( pt_pad->m_PadShape == PAD_CIRCLE ) { TraceFilledCercle( Pcb, shape_pos.x, shape_pos.y, dx, - pt_pad->m_Masque_Layer, color, op_logique ); + pt_pad->m_layerMask, color, op_logique ); return; } @@ -126,14 +126,14 @@ void Place_1_Pad_Board( BOARD* Pcb, TraceFilledRectangle( Pcb, shape_pos.x - dx, shape_pos.y - dy, shape_pos.x + dx, shape_pos.y + dy, - pt_pad->m_Masque_Layer, color, op_logique ); + pt_pad->m_layerMask, color, op_logique ); } else { TraceFilledRectangle( Pcb, shape_pos.x - dx, shape_pos.y - dy, shape_pos.x + dx, shape_pos.y + dy, (int) pt_pad->m_Orient, - pt_pad->m_Masque_Layer, color, op_logique ); + pt_pad->m_layerMask, color, op_logique ); } } @@ -142,7 +142,7 @@ void Place_1_Pad_Board( BOARD* Pcb, * circle center cx, cy. * Parameters: * radius: a value add to the radius or half the score pad - * masque_layer: layer occupied + * aLayerMask: layer occupied * color: mask write in cells * op_logique: type of writing in the cell (WRITE, OR) */ @@ -150,7 +150,7 @@ void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int radius, - int masque_layer, + int aLayerMask, int color, int op_logique ) { @@ -169,10 +169,10 @@ void TraceFilledCercle( BOARD* Pcb, /* Single routing layer on bitmap and BOTTOM * Route_Layer_B = Route_Layer_A */ - if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + if( aLayerMask & g_TabOneLayerMask[Route_Layer_BOTTOM] ) trace = 1; /* Trace on BOTTOM */ - if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) + if( aLayerMask & g_TabOneLayerMask[Route_Layer_TOP] ) if( Nb_Sides ) trace |= 2; /* Trace on TOP */ @@ -528,7 +528,7 @@ void TraceLignePcb( int x0, * Contact PCBs. */ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, - int masque_layer, int color, int op_logique ) + int aLayerMask, int color, int op_logique ) { int row, col; int row_min, row_max, col_min, col_max; @@ -536,10 +536,10 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, void (* WriteCell)( int, int, int, MATRIX_CELL ); - if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + if( aLayerMask & g_TabOneLayerMask[Route_Layer_BOTTOM] ) trace = 1; /* Trace on BOTTOM */ - if( ( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides ) + if( ( aLayerMask & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides ) trace |= 2; /* Trace on TOP */ if( trace == 0 ) @@ -615,7 +615,7 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, * contact PCBs. */ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, - int angle, int masque_layer, int color, + int angle, int aLayerMask, int color, int op_logique ) { int row, col; @@ -627,10 +627,10 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, void (* WriteCell)( int, int, int, MATRIX_CELL ); - if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] ) + if( aLayerMask & g_TabOneLayerMask[Route_Layer_BOTTOM] ) trace = 1; /* Trace on BOTTOM */ - if( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) + if( aLayerMask & g_TabOneLayerMask[Route_Layer_TOP] ) if( Nb_Sides ) trace |= 2; /* Trace on TOP */ diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 95edfb757c..0e1cb56875 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -663,7 +663,7 @@ bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand ) evt_type = ID_POPUP_PCB_EDIT_MODULE; break; - case TYPE_MIRE: + case PCB_TARGET_T: if( aIdCommand == HK_EDIT_ITEM ) evt_type = ID_POPUP_PCB_EDIT_MIRE; break; @@ -757,8 +757,10 @@ bool PCB_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand ) // the parent. if( aIdCommand == HK_MOVE_ITEM ) evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; + if( aIdCommand == HK_DRAG_ITEM ) evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST; + break; case TYPE_TEXTE: @@ -766,7 +768,7 @@ bool PCB_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand ) evt_type = ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST; break; - case TYPE_MIRE: + case PCB_TARGET_T: if( aIdCommand == HK_MOVE_ITEM ) evt_type = ID_POPUP_PCB_MOVE_MIRE_REQUEST; break; @@ -849,8 +851,8 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC ) Place_Module( (MODULE*) item, aDC ); break; - case TYPE_MIRE: - Place_Mire( (MIREPCB*) item, aDC ); + case PCB_TARGET_T: + PlaceTarget( (PCB_TARGET*) item, aDC ); break; case TYPE_DRAWSEGMENT: diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 888b2e174f..bd8a724920 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -22,7 +22,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) { if( GetBoard() == NULL ) - return FALSE; + return false; if( aQuery ) { @@ -30,8 +30,8 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) || GetBoard()->m_Track || GetBoard()->m_Zone ) { if( !IsOK( this, - _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) ) - return FALSE; + _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) ) + return false; } } @@ -74,15 +74,15 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) { if( GetBoard() == NULL ) - return FALSE; + return false; if( aQuery && GetScreen()->IsModify() ) { if( GetBoard()->m_Modules ) { if( !IsOK( this, - _( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) ) - return FALSE; + _( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) ) + return false; } } diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 31d47e82a5..be508a6d6d 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -149,8 +149,7 @@ int PCB_BASE_FRAME::ReadListeSegmentDescr( LINE_READER* aReader, case TYPE_ZONE: // this is now deprecated, but exits in old boards newTrack = new SEGZONE( GetBoard() ); - GetBoard()->m_Zone.Insert( (SEGZONE*) newTrack, - (SEGZONE*) insertBeforeMe ); + GetBoard()->m_Zone.Insert( (SEGZONE*) newTrack, (SEGZONE*) insertBeforeMe ); break; } @@ -174,8 +173,7 @@ int PCB_BASE_FRAME::ReadListeSegmentDescr( LINE_READER* aReader, if( makeType == TYPE_VIA ) // Ensure layers are OK when possible: { if( newTrack->Shape() == VIA_THROUGH ) - ( (SEGVIA*) newTrack )->SetLayerPair( LAYER_N_FRONT, - LAYER_N_BACK ); + ( (SEGVIA*) newTrack )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK ); } newTrack->SetNet( net_code ); @@ -195,6 +193,7 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader ) { Line = aReader->Line(); data = strtok( Line, " =\n\r" ); + if( strnicmp( data, "$EndGENERAL", 10 ) == 0 ) break; @@ -218,10 +217,12 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader ) // Setup layer count int layer_count = 0; + for( ii = 0; ii < NB_COPPER_LAYERS; ii++ ) { if( Masque_Layer & 1 ) layer_count++; + Masque_Layer >>= 1; } @@ -229,6 +230,7 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader ) continue; } + if( stricmp( data, "BoardThickness" ) == 0 ) { data = strtok( NULL, " =\n\r" ); @@ -257,11 +259,9 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader ) data = strtok( NULL, " =\n\r" ); GetBoard()->m_BoundaryBox.SetY( atoi( data ) ); data = strtok( NULL, " =\n\r" ); - GetBoard()->m_BoundaryBox.SetWidth( - atoi( data ) - GetBoard()->m_BoundaryBox.GetX() ); + GetBoard()->m_BoundaryBox.SetWidth( atoi( data ) - GetBoard()->m_BoundaryBox.GetX() ); data = strtok( NULL, " =\n\r" ); - GetBoard()->m_BoundaryBox.SetHeight( - atoi( data ) - GetBoard()->m_BoundaryBox.GetY() ); + GetBoard()->m_BoundaryBox.SetHeight( atoi( data ) - GetBoard()->m_BoundaryBox.GetY() ); continue; } @@ -367,8 +367,10 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) int gx = 0, gy = 0; gx = atoi( data ); data = strtok( NULL, " =\n\r" ); + if( data ) gy = atoi( data ); + m_Auxiliary_Axis_Position.x = gx; m_Auxiliary_Axis_Position.y = gy; continue; @@ -398,12 +400,14 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) GetBoard()->SetLayerName( layer, layerName ); data = strtok( NULL, " \n\r" ); + if( data ) { LAYER_T type = LAYER::ParseType( data ); GetBoard()->SetLayerType( layer, type ); } } + continue; } @@ -477,11 +481,13 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) VIA_DIMENSION via_dim; via_dim.m_Diameter = tmp; data = strtok( NULL, " \n\r" ); + if( data ) { tmp = atoi( data ); via_dim.m_Drill = tmp > 0 ? tmp : 0; } + GetBoard()->m_ViasDimensionsList.push_back( via_dim ); continue; } @@ -567,16 +573,19 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; continue; } + if( stricmp( Line, "Pad2MaskClearance" ) == 0 ) { GetBoard()->GetBoardDesignSettings()->m_SolderMaskMargin = atoi( data ); continue; } + if( stricmp( Line, "Pad2PasteClearance" ) == 0 ) { GetBoard()->GetBoardDesignSettings()->m_SolderPasteMargin = atoi( data ); continue; } + if( stricmp( Line, "Pad2PasteClearanceRatio" ) == 0 ) { GetBoard()->GetBoardDesignSettings()->m_SolderPasteMarginRatio = atof( data ); @@ -606,30 +615,23 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) * Sort lists by by increasing value and remove duplicates * (the first value is not tested, because it is the netclass value */ - sort( GetBoard()->m_ViasDimensionsList.begin() + 1, - GetBoard()->m_ViasDimensionsList.end() ); - sort( GetBoard()->m_TrackWidthList.begin() + 1, - GetBoard()->m_TrackWidthList.end() ); - for( unsigned ii = 1; - ii < GetBoard()->m_ViasDimensionsList.size() - 1; - ii++ ) + sort( GetBoard()->m_ViasDimensionsList.begin() + 1, GetBoard()->m_ViasDimensionsList.end() ); + sort( GetBoard()->m_TrackWidthList.begin() + 1, GetBoard()->m_TrackWidthList.end() ); + + for( unsigned ii = 1; ii < GetBoard()->m_ViasDimensionsList.size() - 1; ii++ ) { - if( GetBoard()->m_ViasDimensionsList[ii] - == GetBoard()->m_ViasDimensionsList[ii + 1] ) + if( GetBoard()->m_ViasDimensionsList[ii] == GetBoard()->m_ViasDimensionsList[ii + 1] ) { - GetBoard()->m_ViasDimensionsList.erase( - GetBoard()->m_ViasDimensionsList.begin() + ii ); + GetBoard()->m_ViasDimensionsList.erase( GetBoard()->m_ViasDimensionsList.begin() + ii ); ii--; } } for( unsigned ii = 1; ii < GetBoard()->m_TrackWidthList.size() - 1; ii++ ) { - if( GetBoard()->m_TrackWidthList[ii] - == GetBoard()->m_TrackWidthList[ii + 1] ) + if( GetBoard()->m_TrackWidthList[ii] == GetBoard()->m_TrackWidthList[ii + 1] ) { - GetBoard()->m_TrackWidthList.erase( - GetBoard()->m_TrackWidthList.begin() + ii ); + GetBoard()->m_TrackWidthList.erase( GetBoard()->m_TrackWidthList.begin() + ii ); ii--; } } @@ -650,8 +652,7 @@ static int WriteSetup( FILE* aFile, PCB_BASE_FRAME* aFrame, BOARD* aBoard ) fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() ); - unsigned layerMask = - g_TabAllCopperLayerMask[aBoard->GetCopperLayerCount() - 1]; + unsigned layerMask = g_TabAllCopperLayerMask[aBoard->GetCopperLayerCount() - 1]; for( int layer = 0; layerMask; ++layer, layerMask >>= 1 ) { @@ -663,27 +664,22 @@ static int WriteSetup( FILE* aFile, PCB_BASE_FRAME* aFrame, BOARD* aBoard ) } } - // Save current default track width, for compatibility with older - // pcbnew version; + // Save current default track width, for compatibility with older pcbnew version; fprintf( aFile, "TrackWidth %d\n", aBoard->GetCurrentTrackWidth() ); - // Save custom tracks width list (the first is not saved here: this is the - // netclass value + // Save custom tracks width list (the first is not saved here: this is the netclass value for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ ) fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] ); fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() ); - fprintf( aFile, - "ZoneClearence %d\n", - g_Zone_Default_Setting.m_ZoneClearance ); + fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); fprintf( aFile, "TrackMinWidth %d\n", aBoard->GetBoardDesignSettings()->m_TrackMinWidth ); fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_DrawSegmentWidth ); fprintf( aFile, "EdgeSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_EdgeSegmentWidth ); - // Save current default via size, for compatibility with older pcbnew - // version; + // Save current default via size, for compatibility with older pcbnew version; fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() ); fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() ); fprintf( aFile, "ViaMinSize %d\n", aBoard->GetBoardDesignSettings()->m_ViasMinSize ); @@ -718,18 +714,17 @@ static int WriteSetup( FILE* aFile, PCB_BASE_FRAME* aFrame, BOARD* aBoard ) fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth ); - fprintf( aFile, - "PadSize %d %d\n", - g_Pad_Master.m_Size.x, - g_Pad_Master.m_Size.y ); + fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); fprintf( aFile, "Pad2MaskClearance %d\n", aBoard->GetBoardDesignSettings()->m_SolderMaskMargin ); + if( aBoard->GetBoardDesignSettings()->m_SolderPasteMargin != 0 ) fprintf( aFile, "Pad2PasteClearance %d\n", aBoard->GetBoardDesignSettings()->m_SolderPasteMargin ); + if( aBoard->GetBoardDesignSettings()->m_SolderPasteMarginRatio != 0 ) fprintf( aFile, "Pad2PasteClearanceRatio %g\n", @@ -756,7 +751,6 @@ static int WriteSetup( FILE* aFile, PCB_BASE_FRAME* aFrame, BOARD* aBoard ) record.Replace( wxT("\n"), wxT(""), true ); record.Replace( wxT(" "), wxT(" "), true); fprintf( aFile, "PcbPlotParams %s\n", TO_UTF8( record ) ); - fprintf( aFile, "$EndSETUP\n\n" ); return 1; } @@ -799,20 +793,18 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File ) NbModules++; PtStruct = GetBoard()->m_Drawings; NbDrawItem = 0; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) NbDrawItem++; fprintf( File, "Ndraw %d\n", NbDrawItem ); fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() ); fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() ); - fprintf( File, "BoardThickness %d\n", - GetBoard()->GetBoardDesignSettings()->m_BoardThickness ); - + fprintf( File, "BoardThickness %d\n", GetBoard()->GetBoardDesignSettings()->m_BoardThickness ); fprintf( File, "Nmodule %d\n", NbModules ); fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() ); - fprintf( File, "$EndGENERAL\n\n" ); - return TRUE; + return true; } @@ -839,7 +831,7 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File ) fprintf( File, "Comment4 %s\n", EscapedUTF8( screen->m_Commentaire4 ).c_str() ); fprintf( File, "$EndSHEETDESCR\n\n" ); - return TRUE; + return true; } @@ -850,8 +842,9 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader ) while( aReader->ReadLine() ) { Line = aReader->Line(); + if( strnicmp( Line, "$End", 4 ) == 0 ) - return TRUE; + return true; if( strnicmp( Line, "Sheet", 4 ) == 0 ) { @@ -859,20 +852,26 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader ) text = strtok( NULL, " \t\n\r" ); Ki_PageDescr* sheet = g_SheetSizeList[0]; int ii; + for( ii = 0; sheet != NULL; ii++, sheet = g_SheetSizeList[ii] ) { if( stricmp( TO_UTF8( sheet->m_Name ), text ) == 0 ) { screen->m_CurrentSheetDesc = sheet; + if( sheet == &g_Sheet_user ) { text = strtok( NULL, " \t\n\r" ); + if( text ) sheet->m_Size.x = atoi( text ); + text = strtok( NULL, " \t\n\r" ); + if( text ) sheet->m_Size.y = atoi( text ); } + break; } } @@ -937,7 +936,7 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader ) } } - return FALSE; + return false; } @@ -1008,8 +1007,7 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) { #ifdef PCBNEW TRACK* insertBeforeMe = Append ? NULL : board->m_Track.GetFirst(); - ReadListeSegmentDescr( aReader, insertBeforeMe, TYPE_TRACK, - NbTrack ); + ReadListeSegmentDescr( aReader, insertBeforeMe, TYPE_TRACK, NbTrack ); #endif continue; } @@ -1054,9 +1052,9 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) continue; } - if( TESTLINE( "MIREPCB" ) ) + if( TESTLINE( "PCB_TARGET" ) ) { - MIREPCB* Mire = new MIREPCB( board ); + PCB_TARGET* Mire = new PCB_TARGET( board ); board->Add( Mire, ADD_APPEND ); Mire->ReadMirePcbDescr( aReader ); continue; @@ -1067,8 +1065,7 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) #ifdef PCBNEW SEGZONE* insertBeforeMe = Append ? NULL : board->m_Zone.GetFirst(); - ReadListeSegmentDescr( aReader, insertBeforeMe, TYPE_ZONE, - NbZone ); + ReadListeSegmentDescr( aReader, insertBeforeMe, TYPE_ZONE, NbZone ); #endif continue; } @@ -1093,12 +1090,15 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) } else { - while( aReader->ReadLine() ) { + while( aReader->ReadLine() ) + { Line = aReader->Line(); + if( TESTLINE( "EndSETUP" ) ) break; } } + continue; } @@ -1144,8 +1144,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile ) /* Writing file header. */ fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, DateAndTime( line ) ); - fprintf( aFile, "# Created by Pcbnew%s\n\n", - TO_UTF8( GetBuildVersion() ) ); + fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) ); GetBoard()->SynchronizeNetsAndNetClasses(); diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index 0359c19f1c..a7cb4bb2c5 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -76,32 +76,32 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer ) /* Locate the pad CONNECTED to a track - * input: ptr_piste: pointer to the segment of track + * input: ptr_trace: pointer to the segment of track * Extr = flag = START -> beginning of the test segment * END -> end of the segment to be tested * Returns: * A pointer to the description of the pad if found. * NULL pointer if pad NOT FOUND */ -D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr ) +D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_trace, int extr ) { D_PAD* ptr_pad = NULL; wxPoint ref_pos; - int masque_layer = g_TabOneLayerMask[ptr_piste->GetLayer()]; + int aLayerMask = g_TabOneLayerMask[ptr_trace->GetLayer()]; if( extr == START ) { - ref_pos = ptr_piste->m_Start; + ref_pos = ptr_trace->m_Start; } else { - ref_pos = ptr_piste->m_End; + ref_pos = ptr_trace->m_End; } for( MODULE* module = Pcb->m_Modules; module; module = module->Next() ) { - ptr_pad = Locate_Pads( module, ref_pos, masque_layer ); + ptr_pad = Locate_Pads( module, ref_pos, aLayerMask ); if( ptr_pad != NULL ) break; @@ -140,12 +140,12 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, int aLayerMask ) * Returns: * A pointer to the pad if found or NULL */ -D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) +D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int aLayerMask ) { for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() ) { /* ... and on the correct layer. */ - if( ( pt_pad->m_Masque_Layer & masque_layer ) == 0 ) + if( ( pt_pad->m_layerMask & aLayerMask ) == 0 ) continue; if( pt_pad->HitTest( ref_pos ) ) @@ -274,7 +274,8 @@ int dist; } -/** Search for the track (or via) segment which is connected to the track +/** + * Search for the track (or via) segment which is connected to the track * segment PtRefSegm * if extr == START, the starting track segment PtRefSegm is used to locate * a connected segment @@ -294,7 +295,7 @@ int dist; * @param pt_lim = upper limit for search (can be NULL) * @param extr = START or END = end of ref track segment to use in tests */ -TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, TRACK* pt_lim, int extr ) +TRACK* GetConnectedTrace( TRACK* PtRefSegm, TRACK* pt_base, TRACK* pt_lim, int extr ) { const int NEIGHTBOUR_COUNT_MAX = 50; @@ -389,6 +390,7 @@ suite1: continue; } + if( PtSegmN == PtRefSegm ) { if( PtSegmN == pt_lim ) @@ -410,6 +412,7 @@ suite1: if( Reflayer & PtSegmN->ReturnMaskLayer() ) return PtSegmN; } + if( PtSegmN == pt_lim ) break; } @@ -425,7 +428,7 @@ suite1: * * The search begins to address start_adresse */ -TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer ) +TRACK* GetTrace( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int LayerMask ) { for( TRACK* track = start_adresse; track; track = track->Next() ) { @@ -449,7 +452,7 @@ TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, } else { - if( (g_TabOneLayerMask[layer] & MasqueLayer) == 0 ) + if( (g_TabOneLayerMask[layer] & LayerMask) == 0 ) continue; /* Segments on different layers. */ if( track->HitTest( ref_pos ) ) @@ -486,7 +489,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ) /* Find the pad center px, py, - * The layer INDICATED BY masque_layer (bitwise) + * The layer INDICATED BY aLayerMask (bitwise) * (Runway end) * The list of pads must already exist. * @@ -495,7 +498,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ) * Pointer to the structure corresponding descr_pad if pad found * (Good position and good layer). */ -D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_layer ) +D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int aLayerMask ) { for( unsigned i=0; iGetPadsCount(); ++i ) { @@ -505,7 +508,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_ continue; /* Pad found, it must be on the correct layer */ - if( pad->m_Masque_Layer & masque_layer ) + if( pad->m_layerMask & aLayerMask ) return pad; } @@ -520,7 +523,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_ * The segments of track marks with the flag are not IS_DELETED or taken * into account */ -TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int MaskLayer ) +TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int MaskLayer ) { TRACK* PtSegm; diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index 8008c3a237..dcbe7cf126 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -46,6 +46,7 @@ static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 ) b0 -= a0; denom = (double) b1.y * a1.x - (double) b1.x * a1.y; + if( !denom ) { return false; // parallel @@ -74,7 +75,7 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ) wxPoint vec = track->m_End - track->m_Start; double t = double( on_grid.x - track->m_Start.x ) * vec.x + - double( on_grid.y - track->m_Start.y ) * vec.y; + double( on_grid.y - track->m_Start.y ) * vec.y; t /= (double) vec.x * vec.x + (double) vec.y * vec.y; t = min( max( t, 0.0 ), 1.0 ); @@ -192,7 +193,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr { int layer_mask = g_TabOneLayerMask[layer]; - TRACK* track = Locate_Pistes( m_Pcb, m_Pcb->m_Track, pos, layer_mask ); + TRACK* track = GetTrace( m_Pcb, m_Pcb->m_Track, pos, layer_mask ); if( !track || track->Type() != TYPE_TRACK ) { diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index ce329b4edb..03ecc0ff2c 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -22,7 +22,7 @@ static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, /* Local variables : */ static int MireDefaultSize = 5000; -static MIREPCB s_TargetCopy( NULL ); /* Used to store "old" values of the +static PCB_TARGET s_TargetCopy( NULL ); /* Used to store "old" values of the * current item parameters before * edition (used in undo/redo or * cancel operations) @@ -38,13 +38,13 @@ private: PCB_EDIT_FRAME* m_Parent; wxDC* m_DC; - MIREPCB* m_MirePcb; + PCB_TARGET* m_Target; EDA_VALUE_CTRL* m_MireWidthCtrl; EDA_VALUE_CTRL* m_MireSizeCtrl; wxRadioBox* m_MireShape; public: - TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent, MIREPCB* Mire, wxDC* DC ); + TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent, PCB_TARGET* Mire, wxDC* DC ); ~TARGET_PROPERTIES_DIALOG_EDITOR() { } private: @@ -60,19 +60,18 @@ BEGIN_EVENT_TABLE( TARGET_PROPERTIES_DIALOG_EDITOR, wxDialog ) END_EVENT_TABLE() -void PCB_EDIT_FRAME::InstallMireOptionsFrame( MIREPCB* MirePcb, wxDC* DC ) +void PCB_EDIT_FRAME::ShowTargetOptionsDialog( PCB_TARGET* aTarget, wxDC* DC ) { TARGET_PROPERTIES_DIALOG_EDITOR* frame = - new TARGET_PROPERTIES_DIALOG_EDITOR( this, MirePcb, DC ); + new TARGET_PROPERTIES_DIALOG_EDITOR( this, aTarget, DC ); frame->ShowModal(); frame->Destroy(); } -TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( - PCB_EDIT_FRAME* parent, - MIREPCB* Mire, wxDC* DC ) : +TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME* parent, + PCB_TARGET* aTarget, wxDC* DC ) : wxDialog( parent, wxID_ANY, wxString( _( "Target Properties" ) ) ) { wxString number; @@ -82,7 +81,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( m_DC = DC; Centre(); - m_MirePcb = Mire; + m_Target = aTarget; wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( MainBoxSizer ); @@ -100,13 +99,13 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( // Size: m_MireSizeCtrl = new EDA_VALUE_CTRL( this, _( "Size" ), - m_MirePcb->m_Size, + m_Target->m_Size, g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits ); // Width: m_MireWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ), - m_MirePcb->m_Width, + m_Target->m_Width, g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits ); @@ -116,7 +115,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( _( "Target Shape:" ), wxDefaultPosition, wxSize( -1, -1 ), 2, shape_list, 1 ); - m_MireShape->SetSelection( m_MirePcb->m_Shape ? 1 : 0 ); + m_MireShape->SetSelection( m_Target->m_Shape ? 1 : 0 ); LeftBoxSizer->Add( m_MireShape, 0, wxGROW | wxALL, 5 ); GetSizer()->Fit( this ); @@ -134,143 +133,140 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event ) */ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event ) { - m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, GR_XOR ); + m_Target->Draw( m_Parent->DrawPanel, m_DC, GR_XOR ); - // Save old item in undo list, if is is not currently edited (will be later - // if so) - if( m_MirePcb->m_Flags == 0 ) - m_Parent->SaveCopyInUndoList( m_MirePcb, UR_CHANGED ); + // Save old item in undo list, if is is not currently edited (will be later if so) + if( m_Target->m_Flags == 0 ) + m_Parent->SaveCopyInUndoList( m_Target, UR_CHANGED ); - if( m_MirePcb->m_Flags != 0 ) // other edition in progress (MOVE, - // NEW ..) - m_MirePcb->m_Flags |= IN_EDIT; // set flag in edit to force - // undo/redo/abort proper operation + if( m_Target->m_Flags != 0 ) // other edition in progress (MOVE, NEW ..) + m_Target->m_Flags |= IN_EDIT; // set flag in edit to force + // undo/redo/abort proper operation - m_MirePcb->m_Width = m_MireWidthCtrl->GetValue(); - MireDefaultSize = m_MirePcb->m_Size = m_MireSizeCtrl->GetValue(); - m_MirePcb->m_Shape = m_MireShape->GetSelection() ? 1 : 0; + m_Target->m_Width = m_MireWidthCtrl->GetValue(); + MireDefaultSize = m_Target->m_Size = m_MireSizeCtrl->GetValue(); + m_Target->m_Shape = m_MireShape->GetSelection() ? 1 : 0; - m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, - ( m_MirePcb->m_Flags & IS_MOVED ) ? GR_XOR : GR_OR ); + m_Target->Draw( m_Parent->DrawPanel, m_DC, ( m_Target->m_Flags & IS_MOVED ) ? GR_XOR : GR_OR ); m_Parent->OnModify(); EndModal( 1 ); } -void PCB_EDIT_FRAME::Delete_Mire( MIREPCB* MirePcb, wxDC* DC ) +void PCB_EDIT_FRAME::DeleteTarget( PCB_TARGET* aTarget, wxDC* DC ) { - if( MirePcb == NULL ) + if( aTarget == NULL ) return; - MirePcb->Draw( DrawPanel, DC, GR_XOR ); - SaveCopyInUndoList( MirePcb, UR_DELETED ); - MirePcb->UnLink(); + aTarget->Draw( DrawPanel, DC, GR_XOR ); + SaveCopyInUndoList( aTarget, UR_DELETED ); + aTarget->UnLink(); } static void AbortMoveAndEditTarget( EDA_DRAW_PANEL* Panel, wxDC* DC ) { BASE_SCREEN* screen = Panel->GetScreen(); - MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem(); + PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem(); ( (PCB_EDIT_FRAME*) Panel->GetParent() )->SetCurItem( NULL ); Panel->SetMouseCapture( NULL, NULL ); - if( MirePcb == NULL ) + if( target == NULL ) return; - MirePcb->Draw( Panel, DC, GR_XOR ); + target->Draw( Panel, DC, GR_XOR ); - if( MirePcb->IsNew() ) // If it is new, delete it + if( target->IsNew() ) // If it is new, delete it { - MirePcb->Draw( Panel, DC, GR_XOR ); - MirePcb->DeleteStructure(); - MirePcb = NULL; + target->Draw( Panel, DC, GR_XOR ); + target->DeleteStructure(); + target = NULL; } else /* it is an existing item: retrieve initial values of parameters */ { - if( ( MirePcb->m_Flags & (IN_EDIT | IS_MOVED) ) ) + if( ( target->m_Flags & (IN_EDIT | IS_MOVED) ) ) { - MirePcb->m_Pos = s_TargetCopy.m_Pos; - MirePcb->m_Width = s_TargetCopy.m_Width; - MirePcb->m_Size = s_TargetCopy.m_Size; - MirePcb->m_Shape = s_TargetCopy.m_Shape; + target->m_Pos = s_TargetCopy.m_Pos; + target->m_Width = s_TargetCopy.m_Width; + target->m_Size = s_TargetCopy.m_Size; + target->m_Shape = s_TargetCopy.m_Shape; } - MirePcb->m_Flags = 0; - MirePcb->Draw( Panel, DC, GR_OR ); + target->m_Flags = 0; + target->Draw( Panel, DC, GR_OR ); } } /* Draw Symbol PCB type MIRE. */ -MIREPCB* PCB_EDIT_FRAME::Create_Mire( wxDC* DC ) +PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC ) { - MIREPCB* MirePcb = new MIREPCB( GetBoard() ); + PCB_TARGET* target = new PCB_TARGET( GetBoard() ); - MirePcb->m_Flags = IS_NEW; + target->m_Flags = IS_NEW; - GetBoard()->Add( MirePcb ); + GetBoard()->Add( target ); - MirePcb->SetLayer( EDGE_N ); - MirePcb->m_Width = GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth; - MirePcb->m_Size = MireDefaultSize; - MirePcb->m_Pos = DrawPanel->GetScreen()->GetCrossHairPosition(); + target->SetLayer( EDGE_N ); + target->m_Width = GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth; + target->m_Size = MireDefaultSize; + target->m_Pos = DrawPanel->GetScreen()->GetCrossHairPosition(); - Place_Mire( MirePcb, DC ); + PlaceTarget( target, DC ); - return MirePcb; + return target; } /* Routine to initialize the displacement of a focal */ -void PCB_EDIT_FRAME::StartMove_Mire( MIREPCB* MirePcb, wxDC* DC ) +void PCB_EDIT_FRAME::BeginMoveTarget( PCB_TARGET* aTarget, wxDC* DC ) { - if( MirePcb == NULL ) + if( aTarget == NULL ) return; - s_TargetCopy = *MirePcb; - MirePcb->m_Flags |= IS_MOVED; + s_TargetCopy = *aTarget; + aTarget->m_Flags |= IS_MOVED; DrawPanel->SetMouseCapture( ShowTargetShapeWhileMovingMouse, AbortMoveAndEditTarget ); - SetCurItem( MirePcb ); + SetCurItem( aTarget ); } -void PCB_EDIT_FRAME::Place_Mire( MIREPCB* MirePcb, wxDC* DC ) +void PCB_EDIT_FRAME::PlaceTarget( PCB_TARGET* aTarget, wxDC* DC ) { - if( MirePcb == NULL ) + if( aTarget == NULL ) return; - MirePcb->Draw( DrawPanel, DC, GR_OR ); + aTarget->Draw( DrawPanel, DC, GR_OR ); DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); OnModify(); - if( MirePcb->IsNew() ) + if( aTarget->IsNew() ) { - SaveCopyInUndoList( MirePcb, UR_NEW ); - MirePcb->m_Flags = 0; + SaveCopyInUndoList( aTarget, UR_NEW ); + aTarget->m_Flags = 0; return; } - if( MirePcb->m_Flags == IS_MOVED ) + if( aTarget->m_Flags == IS_MOVED ) { - SaveCopyInUndoList( MirePcb, UR_MOVED, MirePcb->m_Pos - s_TargetCopy.m_Pos ); - MirePcb->m_Flags = 0; + SaveCopyInUndoList( aTarget, UR_MOVED, aTarget->m_Pos - s_TargetCopy.m_Pos ); + aTarget->m_Flags = 0; return; } - if( (MirePcb->m_Flags & IN_EDIT) ) + if( (aTarget->m_Flags & IN_EDIT) ) { - SwapData( MirePcb, &s_TargetCopy ); - SaveCopyInUndoList( MirePcb, UR_CHANGED ); - SwapData( MirePcb, &s_TargetCopy ); + SwapData( aTarget, &s_TargetCopy ); + SaveCopyInUndoList( aTarget, UR_CHANGED ); + SwapData( aTarget, &s_TargetCopy ); } - MirePcb->m_Flags = 0; + aTarget->m_Flags = 0; } @@ -279,15 +275,15 @@ static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { BASE_SCREEN* screen = aPanel->GetScreen(); - MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem(); + PCB_TARGET* target = (PCB_TARGET*) screen->GetCurItem(); - if( MirePcb == NULL ) + if( target == NULL ) return; if( aErase ) - MirePcb->Draw( aPanel, aDC, GR_XOR ); + target->Draw( aPanel, aDC, GR_XOR ); - MirePcb->m_Pos = screen->GetCrossHairPosition(); + target->m_Pos = screen->GetCrossHairPosition(); - MirePcb->Draw( aPanel, aDC, GR_XOR ); + target->Draw( aPanel, aDC, GR_XOR ); } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index e752e3e603..c6dc186c1a 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -795,8 +795,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) textmod = (TEXTE_MODULE*) PtStruct; NEGATE( textmod->m_Pos.y ); NEGATE( textmod->m_Pos0.y ); + if( textmod->m_Orient ) textmod->m_Orient = 3600 - textmod->m_Orient; + break; default: @@ -812,7 +814,7 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) break; } - module->Set_Rectangle_Encadrement(); + module->CalculateBoundingBox(); OnModify(); } diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 5deaaf7382..a47997bcd6 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -184,7 +184,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen { BOARD_ITEM* item = GetCurItem(); wxString msg; - bool append_set_width = FALSE; + bool append_set_width = false; bool blockActive = GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE; // Simple location of elements where possible. @@ -338,7 +338,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen _( "Edit Layer (All)" ), select_layer_pair_xpm ); msg = AddHotkeyName( _("Delete edge" ), g_Module_Editor_Hokeys_Descr, HK_DELETE ); AddMenuItem( PopMenu, ID_POPUP_PCB_DELETE_EDGE, msg, delete_xpm ); - append_set_width = TRUE; + append_set_width = true; } break; @@ -349,7 +349,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen case TYPE_ZONE: case TYPE_MARKER_PCB: case TYPE_DIMENSION: - case TYPE_MIRE: + case PCB_TARGET_T: break; case TYPE_SCREEN: diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index bf962b7781..369ef2a9ea 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -35,22 +35,27 @@ MODULE* PCB_BASE_FRAME::GetModuleByName() MODULE* module = NULL; wxTextEntryDialog dlg( this, _( "Name:" ), _( "Search footprint" ), moduleName ); + if( dlg.ShowModal() != wxID_OK ) return NULL; //Aborted by user moduleName = dlg.GetValue(); moduleName.Trim( true ); moduleName.Trim( false ); + if( !moduleName.IsEmpty() ) { module = GetBoard()->m_Modules; + while( module ) { if( module->m_Reference->m_Text.CmpNoCase( moduleName ) == 0 ) break; + module = module->Next(); } } + return module; } @@ -83,6 +88,7 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC ) { Build_Drag_Liste( DrawPanel, DC, module ); ITEM_PICKER itemWrapper( NULL, UR_CHANGED ); + for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { TRACK* segm = g_DragSegmentList[ii].m_Segm; @@ -94,7 +100,7 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC ) } GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; - DrawPanel->SetMouseCapture( Montre_Position_Empreinte, Abort_MoveOrCopyModule ); + DrawPanel->SetMouseCapture( MoveFootprint, Abort_MoveOrCopyModule ); DrawPanel->m_AutoPAN_Request = true; // Erase the module. @@ -229,8 +235,7 @@ MODULE* PCB_BASE_FRAME::Copie_Module( MODULE* module ) /* Redraw the footprint when moving the mouse. */ -void Montre_Position_Empreinte( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) +void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { MODULE* module = (MODULE*) aPanel->GetScreen()->GetCurItem(); @@ -247,7 +252,7 @@ void Montre_Position_Empreinte( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint g_Offset_Module = module->m_Pos - aPanel->GetScreen()->GetCrossHairPosition(); DrawModuleOutlines( aPanel, aDC, module ); - Dessine_Segments_Dragges( aPanel, aDC ); + DrawSegmentWhileMovingFootprint( aPanel, aDC ); } @@ -274,6 +279,7 @@ bool PCB_EDIT_FRAME::Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeD msg.Printf( _( "Delete Module %s (value %s) ?" ), GetChars( aModule->m_Reference->m_Text ), GetChars( aModule->m_Value->m_Text ) ); + if( !IsOK( this, msg ) ) { return false; @@ -311,16 +317,16 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC ) { if( Module == NULL ) return; - if( ( Module->GetLayer() != LAYER_N_FRONT ) - && ( Module->GetLayer() != LAYER_N_BACK ) ) + + if( ( Module->GetLayer() != LAYER_N_FRONT ) && ( Module->GetLayer() != LAYER_N_BACK ) ) return; OnModify(); - if( !( Module->m_Flags & IS_MOVED ) ) /* This is a simple flip, no other - *edition in progress */ + if( !( Module->m_Flags & IS_MOVED ) ) /* This is a simple flip, no other edition in progress */ { GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK ); + if( DC ) { int tmp = Module->m_Flags; @@ -342,7 +348,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC ) if( DC ) { DrawModuleOutlines( DrawPanel, DC, Module ); - Dessine_Segments_Dragges( DrawPanel, DC ); + DrawSegmentWhileMovingFootprint( DrawPanel, DC ); } } @@ -356,6 +362,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC ) if( DC ) { Module->Draw( DrawPanel, DC, GR_OR ); + if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) Compile_Ratsnest( DC, true ); } @@ -365,8 +372,9 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC ) if( DC ) { DrawModuleOutlines( DrawPanel, DC, Module ); - Dessine_Segments_Dragges( DrawPanel, DC ); + DrawSegmentWhileMovingFootprint( DrawPanel, DC ); } + GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK; } } @@ -397,22 +405,19 @@ void PCB_BASE_FRAME::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreate ITEM_PICKER picker( module, UR_CHANGED ); picker.m_Link = s_ModuleInitialCopy; s_PickedList.PushItem( picker ); - s_ModuleInitialCopy = NULL; // the picker is now owner of - // s_ModuleInitialCopy. + s_ModuleInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy. } if( s_PickedList.GetCount() ) { SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED ); - // Clear list, but DO NOT delete items, - // because they are owned by the saved undo list and they therefore in - // use + // Clear list, but DO NOT delete items, because they are owned by the saved undo + // list and they therefore in use s_PickedList.ClearItemsList(); } - if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) - && DC ) + if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) && DC ) trace_ratsnest_module( DC ); newpos = GetScreen()->GetCrossHairPosition(); @@ -487,7 +492,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, int angle, bool in if( DC ) { DrawModuleOutlines( DrawPanel, DC, module ); - Dessine_Segments_Dragges( DrawPanel, DC ); + DrawSegmentWhileMovingFootprint( DrawPanel, DC ); } } @@ -506,6 +511,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, int angle, bool in { // not beiing moved: redraw the module and update ratsnest module->Draw( DrawPanel, DC, GR_OR ); + if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) Compile_Ratsnest( DC, true ); } @@ -513,7 +519,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, int angle, bool in { // Beiing moved: just redraw it DrawModuleOutlines( DrawPanel, DC, module ); - Dessine_Segments_Dragges( DrawPanel, DC ); + DrawSegmentWhileMovingFootprint( DrawPanel, DC ); } if( module->m_Flags == 0 ) // module not in edit: redraw full screen @@ -540,6 +546,7 @@ void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module ) DisplayOpt.DisplayPadFill = true; pt_pad = module->m_Pads; + for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { pt_pad->Draw( panel, DC, GR_XOR, g_Offset_Module ); diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index aa09248af5..3930fc2c10 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -51,7 +51,7 @@ static void Abort_Move_Pad( EDA_DRAW_PANEL* Panel, wxDC* DC ) EraseDragList(); s_CurrentSelectedPad = NULL; - g_Drag_Pistes_On = FALSE; + g_Drag_Pistes_On = false; } @@ -109,7 +109,7 @@ void PCB_BASE_FRAME::Export_Pad_Settings( D_PAD* pt_pad ) g_Pad_Master.m_PadShape = pt_pad->m_PadShape; g_Pad_Master.m_Attribut = pt_pad->m_Attribut; - g_Pad_Master.m_Masque_Layer = pt_pad->m_Masque_Layer; + g_Pad_Master.m_layerMask = pt_pad->m_layerMask; g_Pad_Master.m_Orient = pt_pad->m_Orient - ( (MODULE*) pt_pad->GetParent() )->m_Orient; g_Pad_Master.m_Size = pt_pad->m_Size; @@ -137,7 +137,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) } aPad->m_PadShape = g_Pad_Master.m_PadShape; - aPad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer; + aPad->m_layerMask = g_Pad_Master.m_layerMask; aPad->m_Attribut = g_Pad_Master.m_Attribut; aPad->m_Orient = g_Pad_Master.m_Orient + ( (MODULE*) aPad->GetParent() )->m_Orient; @@ -206,8 +206,7 @@ void PCB_BASE_FRAME::AddPad( MODULE* Module, bool draw ) long num = 0; int ponder = 1; - while( lastPadName.Len() && lastPadName.Last() >= '0' - && lastPadName.Last() <= '9' ) + while( lastPadName.Len() && lastPadName.Last() >= '0' && lastPadName.Last() <= '9' ) { num += ( lastPadName.Last() - '0' ) * ponder; lastPadName.RemoveLast(); @@ -219,8 +218,9 @@ void PCB_BASE_FRAME::AddPad( MODULE* Module, bool draw ) Pad->SetPadName( lastPadName ); g_Pad_Master.SetPadName(lastPadName); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Pad->DisplayInfo( this ); + if( draw ) DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() ); } @@ -248,8 +248,9 @@ void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery ) { wxString msg; msg.Printf( _( "Delete Pad (module %s %s) " ), - GetChars( Module->m_Reference->m_Text ), - GetChars( Module->m_Value->m_Text ) ); + GetChars( Module->m_Reference->m_Text ), + GetChars( Module->m_Value->m_Text ) ); + if( !IsOK( this, msg ) ) return; } @@ -257,7 +258,7 @@ void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery ) m_Pcb->m_Status_Pcb = 0; aPad->DeleteStructure(); DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); OnModify(); } @@ -310,6 +311,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) // Set the old state if( g_DragSegmentList[ii].m_Pad_Start ) Track->m_Start = Pad_OldPos; + if( g_DragSegmentList[ii].m_Pad_End ) Track->m_End = Pad_OldPos; @@ -342,6 +344,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) // Set the new state if( g_DragSegmentList[ii].m_Pad_Start ) Track->m_Start = Pad->m_Pos; + if( g_DragSegmentList[ii].m_Pad_End ) Track->m_End = Pad->m_Pos; @@ -351,8 +354,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) Track->Draw( DrawPanel, DC, GR_OR ); } - /* Compute local coordinates (i.e refer to Module position and for Module - * orient = 0) */ + /* Compute local coordinates (i.e refer to Module position and for Module orient = 0) */ dX = Pad->m_Pos.x - Pad_OldPos.x; dY = Pad->m_Pos.y - Pad_OldPos.y; RotatePoint( &dX, &dY, -Module->m_Orient ); @@ -365,7 +367,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) if( DC ) Pad->Draw( DrawPanel, DC, GR_OR ); - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Module->m_LastEdit_Time = time( NULL ); EraseDragList(); @@ -400,7 +402,7 @@ void PCB_BASE_FRAME::RotatePad( D_PAD* Pad, wxDC* DC ) EXCHG( Pad->m_DeltaSize.x, Pad->m_DeltaSize.y ); Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Pad->DisplayInfo( this ); if( DC ) diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 78bb511fef..2a0d077869 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -83,6 +83,7 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) TRACK* Track = NewTrack; int dx = s_LastPos.x - PosInit.x; int dy = s_LastPos.y - PosInit.y; + for( ii = 0; ii < NbPtNewTrack; ii++, Track = Track->Next() ) { if( Track == NULL ) @@ -97,7 +98,7 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) Track->m_Flags = 0; } - Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR ); + DrawTraces( Panel, DC, NewTrack, NbPtNewTrack, GR_OR ); } NewTrack = NULL; @@ -147,7 +148,7 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo if( aErase ) { if( NewTrack ) - Trace_Une_Piste( aPanel, aDC, NewTrack, NbPtNewTrack, draw_mode ); + DrawTraces( aPanel, aDC, NewTrack, NbPtNewTrack, draw_mode ); } /* set the new track coordinates */ @@ -169,7 +170,7 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo } /* Redraw the current moved track segments */ - Trace_Une_Piste( aPanel, aDC, NewTrack, NbPtNewTrack, draw_mode ); + DrawTraces( aPanel, aDC, NewTrack, NbPtNewTrack, draw_mode ); for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { @@ -422,13 +423,13 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC xi1 = tx1; yi1 = ty1; } + if( tSegmentToEnd == NULL ) { xi2 = tx2; yi2 = ty2; } - if( update ) { s_LastPos = Pos; @@ -492,22 +493,23 @@ bool InitialiseDragParameters() Track = g_DragSegmentList[ii].m_Segm; if( Track == NULL ) return false; + ii--; + if( ii >= 0) { if( s_EndSegmentPresent ) { - tSegmentToEnd = g_DragSegmentList[ii].m_Segm; // Get the segment - // connected to the end - // point + tSegmentToEnd = g_DragSegmentList[ii].m_Segm; // Get the segment connected to + // the end point ii--; } + if( s_StartSegmentPresent ) { if( ii >= 0 ) - tSegmentToStart = g_DragSegmentList[ii].m_Segm; // Get the segment - // connected to the - // start point + tSegmentToStart = g_DragSegmentList[ii].m_Segm; // Get the segment connected to + // the start point } } @@ -549,6 +551,7 @@ bool InitialiseDragParameters() ty2 = (double) Track->m_End.y; RotatePoint( &tx2, &ty2, tx1, ty1, 900 ); } + if( tx1 != tx2 ) { s_StartSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 ); @@ -558,6 +561,7 @@ bool InitialiseDragParameters() { s_StartPointVertical = true; //signal first segment vertical } + if( ty1 == ty2 ) { s_StartPointHorizontal = true; @@ -602,6 +606,7 @@ bool InitialiseDragParameters() { s_EndPointVertical = true; //signal second segment vertical } + if( ty1 == ty2 ) { s_EndPointHorizontal = true; @@ -621,6 +626,7 @@ bool InitialiseDragParameters() { s_MovingSegmentVertical = true; //signal vertical line } + if( ty1 == ty2 ) { s_MovingSegmentHorizontal = true; @@ -634,11 +640,10 @@ bool InitialiseDragParameters() } else { - if( !s_EndPointVertical - && ( s_MovingSegmentSlope == s_EndSegmentSlope ) ) + if( !s_EndPointVertical && ( s_MovingSegmentSlope == s_EndSegmentSlope ) ) return false; - if( !s_StartPointVertical - && ( s_MovingSegmentSlope == s_StartSegmentSlope ) ) + + if( !s_StartPointVertical && ( s_MovingSegmentSlope == s_StartSegmentSlope ) ) return false; } @@ -664,17 +669,20 @@ void PCB_EDIT_FRAME::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int com if( GetBoard()->IsHightLightNetON() ) High_Light( DC ); + PosInit = GetScreen()->GetCrossHairPosition(); if( track->Type() == TYPE_VIA ) // For a via: always drag it { track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT; + if( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT ) { Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start, track->ReturnMaskLayer(), track->GetNet() ); } + NewTrack = track; NbPtNewTrack = 1; PosInit = track->m_Start; @@ -719,6 +727,7 @@ void PCB_EDIT_FRAME::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int com ITEM_PICKER picker( track, UR_CHANGED ); picker.m_Link = track->Copy(); s_ItemsListPicker.PushItem( picker ); + for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; @@ -774,13 +783,12 @@ void SortTrackEndPoints( TRACK* track ) * 2 collinear segments can be merged only in no other segment or via is * connected to the common point * and if they have the same width. See cleanup.cpp for merge functions, - * and consider Marque_Une_Piste() to locate segments that can be merged + * and consider MarkTrace() to locate segments that can be merged */ bool PCB_EDIT_FRAME::MergeCollinearTracks( TRACK* track, wxDC* DC, int end ) { - testtrack = (TRACK*) Locate_Piste_Connectee( track, - GetBoard()->m_Track, NULL, - end ); + testtrack = (TRACK*) GetConnectedTrace( track, GetBoard()->m_Track, NULL, end ); + if( testtrack ) { SortTrackEndPoints( track ); @@ -790,14 +798,12 @@ bool PCB_EDIT_FRAME::MergeCollinearTracks( TRACK* track, wxDC* DC, int end ) int tdx = testtrack->m_End.x - testtrack->m_Start.x; int tdy = testtrack->m_End.y - testtrack->m_Start.y; - if( ( dy * tdx == dx * tdy && dy != 0 && dx != 0 && tdy != 0 && tdx != - 0 ) /* angle, same slope */ + if( ( dy * tdx == dx * tdy && dy != 0 && dx != 0 && tdy != 0 && tdx != 0 ) /* angle, same slope */ || ( dy == 0 && tdy == 0 && dx * tdx ) /*horizontal */ || ( dx == 0 && tdx == 0 && dy * tdy ) /*vertical */ ) { - if( track->m_Start == testtrack->m_Start || track->m_End == - testtrack->m_Start ) + if( track->m_Start == testtrack->m_Start || track->m_End == testtrack->m_Start ) { if( ( dx * tdx && testtrack->m_End.x > track->m_End.x ) ||( dy * tdy && testtrack->m_End.y > track->m_End.y ) ) @@ -808,11 +814,11 @@ bool PCB_EDIT_FRAME::MergeCollinearTracks( TRACK* track, wxDC* DC, int end ) return true; } } - if( track->m_Start == testtrack->m_End || track->m_End == - testtrack->m_End ) + + if( track->m_Start == testtrack->m_End || track->m_End == testtrack->m_End ) { if( ( dx * tdx && testtrack->m_Start.x < track->m_Start.x ) - ||( dy * tdy && testtrack->m_Start.y < track->m_Start.y ) ) + || ( dy * tdy && testtrack->m_Start.y < track->m_Start.y ) ) { track->m_Start = testtrack->m_Start; @@ -846,6 +852,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC while( MergeCollinearTracks( track, DC, START ) ) { }; + while( MergeCollinearTracks( track, DC, END ) ) { }; @@ -854,32 +861,32 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC s_StartSegmentPresent = s_EndSegmentPresent = true; if( ( track->start == NULL ) || ( track->start->Type() == TYPE_TRACK ) ) - TrackToStartPoint = Locate_Piste_Connectee( track, - GetBoard()->m_Track, NULL, - START ); + TrackToStartPoint = GetConnectedTrace( track, GetBoard()->m_Track, NULL, START ); // Test if more than one segment is connected to this point if( TrackToStartPoint ) { TrackToStartPoint->SetState( BUSY, ON ); + if( ( TrackToStartPoint->Type() == TYPE_VIA ) - || Locate_Piste_Connectee( track, GetBoard()->m_Track, NULL, START ) ) + || GetConnectedTrace( track, GetBoard()->m_Track, NULL, START ) ) error = true; + TrackToStartPoint->SetState( BUSY, OFF ); } if( ( track->end == NULL ) || ( track->end->Type() == TYPE_TRACK ) ) - TrackToEndPoint = Locate_Piste_Connectee( track, - GetBoard()->m_Track, NULL, - END ); + TrackToEndPoint = GetConnectedTrace( track, GetBoard()->m_Track, NULL, END ); // Test if more than one segment is connected to this point if( TrackToEndPoint ) { TrackToEndPoint->SetState( BUSY, ON ); + if( (TrackToEndPoint->Type() == TYPE_VIA) - || Locate_Piste_Connectee( track, GetBoard()->m_Track, NULL, END ) ) + || GetConnectedTrace( track, GetBoard()->m_Track, NULL, END ) ) error = true; + TrackToEndPoint->SetState( BUSY, OFF ); } @@ -898,6 +905,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC /* Change high light net: the new one will be highlighted */ GetBoard()->PushHightLight(); + if( GetBoard()->IsHightLightNetON() ) High_Light( DC ); @@ -910,8 +918,10 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC if( TrackToStartPoint ) { int flag = STARTPOINT; + if( track->m_Start != TrackToStartPoint->m_Start ) flag = ENDPOINT; + AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint ); track->m_Flags |= STARTPOINT; } @@ -919,8 +929,10 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC if( TrackToEndPoint ) { int flag = STARTPOINT; + if( track->m_End != TrackToEndPoint->m_Start ) flag = ENDPOINT; + AddSegmentToDragList( DrawPanel, DC, flag, TrackToEndPoint ); track->m_Flags |= ENDPOINT; } @@ -938,6 +950,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC // Prepare the Undo command ITEM_PICKER picker( NULL, UR_CHANGED ); + for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; @@ -973,12 +986,15 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) if( Drc_On ) { errdrc = m_drc->Drc( Track, GetBoard()->m_Track ); + if( errdrc == BAD_DRC ) return false; + /* Redraw the dragged segments */ for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { errdrc = m_drc->Drc( g_DragSegmentList[ii].m_Segm, GetBoard()->m_Track ); + if( errdrc == BAD_DRC ) return false; } @@ -1002,14 +1018,15 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) /* Test the connections modified by the move * (only pad connection must be tested, track connection will be * tested by test_1_net_connexion() ) */ - int masque_layer = g_TabOneLayerMask[Track->GetLayer()]; - Track->start = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_Start, masque_layer ); + int layerMask = g_TabOneLayerMask[Track->GetLayer()]; + Track->start = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_Start, layerMask ); + if( Track->start ) Track->SetState( BEGIN_ONPAD, ON ); else Track->SetState( BEGIN_ONPAD, OFF ); - Track->end = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_End, masque_layer ); + Track->end = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_End, layerMask ); if( Track->end ) Track->SetState( END_ONPAD, ON ); else @@ -1019,8 +1036,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) EraseDragList(); SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); - s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner - // of picked items + s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items if( GetBoard()->IsHightLightNetON() ) High_Light( DC ); @@ -1061,10 +1077,10 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask ) } /* No pad has been located so check for a segment of the trace. */ - TRACK* ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask ); + TRACK* ptsegm = GetTrace( Pcb->m_Track, NULL, pos, LayerMask ); if( ptsegm == NULL ) - ptsegm = Locate_Pistes( Pcb, Pcb->m_Track, pos, LayerMask ); + ptsegm = GetTrace( Pcb, Pcb->m_Track, pos, LayerMask ); return ptsegm; } @@ -1133,6 +1149,7 @@ TRACK* CreateLockPoint( BOARD* aPcb, newPoint.y += aSegm->m_Start.y; TRACK* newTrack = aSegm->Copy(); + if( aItemsListPicker ) { ITEM_PICKER picker( newTrack, UR_NEW ); @@ -1169,6 +1186,7 @@ TRACK* CreateLockPoint( BOARD* aPcb, newTrack->SetState( BEGIN_ONPAD, OFF ); D_PAD * pad = Locate_Pad_Connecte( aPcb, newTrack, START ); + if ( pad ) { newTrack->start = pad; diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index d374dcaf80..f3690cfc7f 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -199,6 +199,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) /* Enter the desired length. */ msg = ReturnStringFromValue( g_UserUnit, Mself.lng, GetScreen()->GetInternalUnits() ); wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg ); + if( dlg.ShowModal() != wxID_OK ) return NULL; // cancelled by user @@ -216,8 +217,8 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) Mself.m_Width = GetBoard()->GetCurrentTrackWidth(); std::vector buffer; - ll = BuildCornersList_S_Shape( buffer, Mself.m_Start, Mself.m_End, - Mself.lng, Mself.m_Width ); + ll = BuildCornersList_S_Shape( buffer, Mself.m_Start, Mself.m_End, Mself.lng, Mself.m_Width ); + if( !ll ) { DisplayError( this, _( "Requested length too large" ) ); @@ -228,6 +229,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) /* Generate module. */ MODULE* Module; Module = Create_1_Module( wxEmptyString ); + if( Module == NULL ) return NULL; @@ -261,7 +263,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) PtPad->m_Pos = Mself.m_End; PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos; PtPad->m_Size.x = PtPad->m_Size.y = Mself.m_Width; - PtPad->m_Masque_Layer = g_TabOneLayerMask[Module->GetLayer()]; + PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()]; PtPad->m_Attribut = PAD_SMD; PtPad->m_PadShape = PAD_CIRCLE; PtPad->ComputeShapeMaxRadius(); @@ -279,17 +281,16 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) /* Modify text positions. */ Module->DisplayInfo( this ); Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = - ( Mself.m_Start.x + Mself.m_End.x ) / 2; + ( Mself.m_Start.x + Mself.m_End.x ) / 2; Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = - ( Mself.m_Start.y + Mself.m_End.y ) / 2; + ( Mself.m_Start.y + Mself.m_End.y ) / 2; Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y; Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y; Module->m_Reference->m_Pos0 = Module->m_Reference->m_Pos - Module->m_Pos; Module->m_Value->m_Pos0 = Module->m_Value->m_Pos - Module->m_Pos; - - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); Module->Draw( DrawPanel, DC, GR_OR ); return Module; @@ -394,7 +395,7 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, wxPoint pt = aEndPoint - aStartPoint; int angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); int min_len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); - int segm_len = 0; // lenght of segments + int segm_len = 0; // length of segments int full_len; // full len of shape (sum of lenght of all segments + arcs) @@ -415,25 +416,29 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, int segm_count; // number of full len segments // the half size segments (first and last segment) are not counted here int stubs_len = 0; // lenght of first or last segment (half size of others segments) + for( segm_count = 0; ; segm_count++ ) { stubs_len = ( size.y - ( radius * 2 * (segm_count + 2 ) ) ) / 2; + if( stubs_len < size.y / 10 ) // Reduce radius. { stubs_len = size.y / 10; radius = ( size.y - (2 * stubs_len) ) / ( 2 * (segm_count + 2) ); + if( radius < aWidth ) // Radius too small. { // Unable to create line: Requested length value is too large for room return 0; } } + segm_len = size.x - ( radius * 2 ); - full_len = 2 * stubs_len; // Length of coil connections. - full_len += segm_len * segm_count; // Length of full length segments. + full_len = 2 * stubs_len; // Length of coil connections. + full_len += segm_len * segm_count; // Length of full length segments. full_len += wxRound( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius ); // Ard arcs len - full_len += segm_len - (2 * radius); // Length of first and last segments - // (half size segments len = segm_len/2 - radius). + full_len += segm_len - (2 * radius); // Length of first and last segments + // (half size segments len = segm_len/2 - radius). if( full_len >= aLength ) break; @@ -457,6 +462,7 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, pt = aBuffer.back(); int half_size_seg_len = segm_len / 2 - radius; + if( half_size_seg_len ) { pt.x -= half_size_seg_len; @@ -467,6 +473,7 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, int ii; int sign = 1; segm_count += 1; // increase segm_count to create the last half_size segment + for( ii = 0; ii < segm_count; ii++ ) { int arc_angle; @@ -475,6 +482,7 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, sign = -1; else sign = 1; + arc_angle = 1800 * sign; centre = pt; centre.y += radius; @@ -498,10 +506,10 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, // Rotate point angle += 900; + for( unsigned jj = 0; jj < aBuffer.size(); jj++ ) { - RotatePoint( &aBuffer[jj].x, &aBuffer[jj].y, - aStartPoint.x, aStartPoint.y, angle ); + RotatePoint( &aBuffer[jj].x, &aBuffer[jj].y, aStartPoint.x, aStartPoint.y, angle ); } // push last point (end point) @@ -522,6 +530,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c wxString Line; Module = Create_1_Module( name ); + if( Module == NULL ) return NULL; @@ -546,11 +555,11 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c Module->m_Pads.PushFront( pad ); - pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); - pad->m_Pos = Module->m_Pos; - pad->m_PadShape = PAD_RECT; - pad->m_Attribut = PAD_SMD; - pad->m_Masque_Layer = LAYER_FRONT; + pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + pad->m_Pos = Module->m_Pos; + pad->m_PadShape = PAD_RECT; + pad->m_Attribut = PAD_SMD; + pad->m_layerMask = LAYER_FRONT; Line.Printf( wxT( "%d" ), pad_num ); pad->SetPadName( Line ); pad_num++; @@ -566,7 +575,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c * PAD_SMD, rectangular, H size = V size = current track width. * the "gap" is isolation created between this 2 pads */ -MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) +MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) { int oX; D_PAD* pad; @@ -603,8 +612,9 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) } wxString value = ReturnStringFromValue( g_UserUnit, gap_size, - GetScreen()->GetInternalUnits() ); + GetScreen()->GetInternalUnits() ); wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value ); + if( dlg.ShowModal() != wxID_OK ) { DrawPanel->MoveCursorToCrossHair(); @@ -615,24 +625,30 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) gap_size = ReturnValueFromString( g_UserUnit, value, GetScreen()->GetInternalUnits() ); bool abort = false; + if( shape_type == 2 ) { double fcoeff = 10.0, fval; msg.Printf( wxT( "%3.1f" ), angle / fcoeff ); - wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), _( - "Create microwave module" ), msg ); + wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), + _( "Create microwave module" ), msg ); + if( angledlg.ShowModal() != wxID_OK ) { DrawPanel->MoveCursorToCrossHair(); return NULL; // cancelled by user } + msg = angledlg.GetValue(); + if( !msg.ToDouble( &fval ) ) { DisplayError( this, _( "Incorrect number, abort" ) ); - abort = TRUE; + abort = true; } + angle = ABS( wxRound( fval * fcoeff ) ); + if( angle > 1800 ) angle = 1800; } @@ -681,6 +697,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) polyPoints.push_back( wxPoint( 0, 0 ) ); int theta = -angle / 2; + for( int ii = 1; ii angle / 2 ) theta = angle / 2; } @@ -703,7 +721,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) break; } - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); GetBoard()->m_Status_Pcb = 0; OnModify(); return Module; @@ -748,8 +766,7 @@ END_EVENT_TABLE() WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, const wxPoint& framepos ) : - wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ), - DIALOG_STYLE ) + wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ), DIALOG_STYLE ) { m_Parent = parent; @@ -772,9 +789,8 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = - new wxButton( this, ID_READ_SHAPE_FILE, - _( "Read Shape Description File..." ) ); + Button = new wxButton( this, ID_READ_SHAPE_FILE, + _( "Read Shape Description File..." ) ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); wxString shapelist[3] = @@ -782,6 +798,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" ) }; + m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ), wxDefaultPosition, wxDefaultSize, 3, shapelist, 1, @@ -801,6 +818,7 @@ void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& event ) { if( PolyEdges ) free( PolyEdges ); + PolyEdges = NULL; PolyEdgesCount = 0; EndModal( -1 ); @@ -849,7 +867,7 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event ) mask, this, wxFD_OPEN, - TRUE ); + true ); if( FullFileName.IsEmpty() ) return; @@ -869,6 +887,7 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event ) ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double) ); SetLocaleTo_C_standard(); + while( reader.ReadLine() ) { Line = reader.Line(); @@ -879,11 +898,14 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event ) { if( strnicmp( param2, "inch", 4 ) == 0 ) unitconv = 10000; + if( strnicmp( param2, "mm", 2 ) == 0 ) unitconv = 10000 / 25.4; } + if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 ) break; + if( strnicmp( param1, "$COORD", 6 ) == 0 ) { while( reader.ReadLine() ) @@ -891,17 +913,19 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event ) Line = reader.Line(); param1 = strtok( Line, " \t\n\r" ); param2 = strtok( NULL, " \t\n\r" ); + if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 ) break; + if( bufsize <= PolyEdgesCount ) { int index = ptbuf - PolyEdges; bufsize *= 2; - ptbuf = PolyEdges = (double*) realloc( - PolyEdges, bufsize * 2 * - sizeof(double) ); + ptbuf = PolyEdges = (double*) realloc( PolyEdges, bufsize * 2 * + sizeof(double) ); ptbuf += index; } + *ptbuf = atof( param1 ); ptbuf++; *ptbuf = atof( param2 ); @@ -909,10 +933,12 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event ) PolyEdgesCount++; } } + if( strnicmp( Line, "XScale", 6 ) == 0 ) { ShapeScaleX = atof( param2 ); } + if( strnicmp( Line, "YScale", 6 ) == 0 ) { ShapeScaleY = atof( param2 ); @@ -924,6 +950,7 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event ) free( PolyEdges ); PolyEdges = NULL; } + SetLocaleTo_Default(); // revert to the current locale ShapeScaleX *= unitconv; @@ -942,8 +969,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() EDGE_MODULE* edge; int ii, npoints; - WinEDA_SetParamShapeFrame* frame = new WinEDA_SetParamShapeFrame( - this, wxPoint( -1, -1 ) ); + WinEDA_SetParamShapeFrame* frame = new WinEDA_SetParamShapeFrame( this, wxPoint( -1, -1 ) ); int ok = frame->ShowModal(); @@ -955,6 +981,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() { if( PolyEdges ) free( PolyEdges ); + PolyEdges = NULL; PolyEdgesCount = 0; return NULL; @@ -971,6 +998,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() DisplayError( this, _( "Shape has a null size!" ) ); return NULL; } + if( PolyEdgesCount == 0 ) { DisplayError( this, _( "Shape has no points!" ) ); @@ -1005,6 +1033,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() double* dptr = PolyEdges; wxPoint first_coordinate, last_coordinate; + for( ii = 0; ii < npoints; ii++ ) // Copy points { last_coordinate.x = wxRound( *dptr++ *ShapeScaleX ) + pad1->m_Pos0.x; @@ -1049,7 +1078,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() PolyEdgesCount = 0; PolyEdges = NULL; - Module->Set_Rectangle_Encadrement(); + Module->CalculateBoundingBox(); GetBoard()->m_Status_Pcb = 0; OnModify(); return Module; @@ -1071,16 +1100,20 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) /* Test if module is a gap type (name begins with GAP, and has 2 pads). */ msg = Module->m_Reference->m_Text.Left( 3 ); + if( msg != wxT( "GAP" ) ) return; pad = Module->m_Pads; + if( pad == NULL ) { DisplayError( this, _( "No pad for this module" ) ); return; } + next_pad = (D_PAD*) pad->Next(); + if( next_pad == NULL ) { DisplayError( this, _( "Only one pad for this module" ) ); @@ -1095,6 +1128,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) /* Entrer the desired length of the gap. */ msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() ); wxTextEntryDialog dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg ); + if( dlg.ShowModal() != wxID_OK ) return; // cancelled by user diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 7449ebfeef..c9136ac373 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -72,8 +72,8 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) exit = true; break; - case TYPE_MIRE: - Place_Mire( (MIREPCB*) DrawStruct, aDC ); + case PCB_TARGET_T: + PlaceTarget( (PCB_TARGET*) DrawStruct, aDC ); exit = true; break; @@ -171,15 +171,18 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_PCB_MIRE_BUTT: if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) { - SetCurItem( Create_Mire( aDC ) ); + SetCurItem( CreateTarget( aDC ) ); DrawPanel->MoveCursorToCrossHair(); } - else if( DrawStruct->Type() == TYPE_MIRE ) + else if( DrawStruct->Type() == PCB_TARGET_T ) { - Place_Mire( (MIREPCB*) DrawStruct, aDC ); + PlaceTarget( (PCB_TARGET*) DrawStruct, aDC ); } else - DisplayError( this, wxT( "Internal err: Struct not TYPE_MIRE" ) ); + { + DisplayError( this, wxT( "Internal err: Struct not PCB_TARGET_T" ) ); + } + break; case ID_PCB_CIRCLE_BUTT: @@ -286,7 +289,10 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) GetScreen()->SetCurItem( DrawStruct ); } else + { DisplayError( this, wxT( "PCB_EDIT_FRAME::OnLeftClick() zone internal error" ) ); + } + break; case ID_PCB_ADD_TEXT_BUTT: @@ -302,7 +308,10 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) DrawPanel->m_AutoPAN_Request = false; } else + { DisplayError( this, wxT( "Internal err: Struct not TYPE_TEXTE" ) ); + } + break; case ID_PCB_MODULE_BUTT: @@ -311,6 +320,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) DrawPanel->MoveCursorToCrossHair(); DrawStruct = Load_Module_From_Library( wxEmptyString, aDC ); SetCurItem( DrawStruct ); + if( DrawStruct ) StartMove_Module( (MODULE*) DrawStruct, aDC ); } @@ -320,7 +330,10 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) DrawPanel->m_AutoPAN_Request = false; } else + { DisplayError( this, wxT( "Internal err: Struct not TYPE_MODULE" ) ); + } + break; case ID_PCB_DIMENSION_BUTT: @@ -344,20 +357,25 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) DrawPanel->m_AutoPAN_Request = true; } else + { DisplayError( this, wxT( "PCB_EDIT_FRAME::OnLeftClick() error item is not a DIMENSION" ) ); + } + break; case ID_PCB_DELETE_ITEM_BUTT: if( !DrawStruct || (DrawStruct->m_Flags == 0) ) { DrawStruct = PcbGeneralLocateAndDisplay(); + if( DrawStruct && (DrawStruct->m_Flags == 0) ) { RemoveStruct( DrawStruct, aDC ); SetCurItem( DrawStruct = NULL ); } } + break; case ID_PCB_PLACE_OFFSET_COORD_BUTT: @@ -416,12 +434,13 @@ void PCB_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) { Edit_TrackSegm_Width( aDC, (TRACK*) DrawStruct ); } + break; case TYPE_TEXTE: case TYPE_PAD: case TYPE_MODULE: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DIMENSION: case TYPE_TEXTE_MODULE: OnEditItemRequest( aDC, DrawStruct ); @@ -450,6 +469,7 @@ void PCB_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) if( End_Route( (TRACK*) DrawStruct, aDC ) ) DrawPanel->m_AutoPAN_Request = false; } + break; case ID_PCB_ZONES_BUTT: @@ -506,8 +526,8 @@ void PCB_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) InstallModuleOptionsFrame( (MODULE*) aItem, aDC ); break; - case TYPE_MIRE: - InstallMireOptionsFrame( (MIREPCB*) aItem, aDC ); + case PCB_TARGET_T: + ShowTargetOptionsDialog( (PCB_TARGET*) aItem, aDC ); break; case TYPE_DIMENSION: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 8afb9d9356..ebe3119704 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -23,7 +23,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) { wxString msg; int flags = 0; - bool locate_track = FALSE; + bool locate_track = false; bool blockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE); wxClientDC dc( DrawPanel ); @@ -223,7 +223,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) break; - case TYPE_MIRE: + case PCB_TARGET_T: if( !flags ) { msg = AddHotkeyName( _( "Move Target" ), g_Board_Editor_Hokeys_Descr, diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 9b5aad62ee..70ffc1f324 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -2,13 +2,13 @@ /** pcbnew_config.cpp : configuration **/ /****************************************/ -#include - #include "fctsys.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "xnode.h" + #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" @@ -405,7 +405,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ), &g_TwoSegmentTrackBuild, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" ), &Segments_45_Only, - true ) ); + true ) ); return m_configSettings; } @@ -416,8 +416,8 @@ void PCB_EDIT_FRAME::SaveMacros() { wxFileName fn; wxXmlDocument xml; - wxXmlNode *rootNode = new wxXmlNode::wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "macrosrootnode" ), wxEmptyString, NULL); - wxXmlNode *macrosNode, *hkNode; + XNODE *rootNode = new XNODE( wxXML_ELEMENT_NODE, wxT( "macrosrootnode" ), wxEmptyString ); + XNODE *macrosNode, *hkNode; wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp; wxString str, hkStr, xStr, yStr; @@ -432,29 +432,33 @@ void PCB_EDIT_FRAME::SaveMacros() xml.SetRoot( rootNode ); - for( int number = 9; number >= 0; number--) + for( int number = 9; number >= 0; number-- ) { - str.Printf( wxT( "%d" ), number); - macrosProp = new wxXmlProperty::wxXmlProperty( wxT("number"), str); + str.Printf( wxT( "%d" ), number ); + macrosProp = new wxXmlProperty( wxT( "number" ), str ); - macrosNode = new wxXmlNode::wxXmlNode(rootNode, wxXML_ELEMENT_NODE, wxT( "macros" ), wxEmptyString, macrosProp); + macrosNode = new XNODE( rootNode, wxXML_ELEMENT_NODE, wxT( "macros" ), wxEmptyString, + macrosProp ); - for( std::list::reverse_iterator i = m_Macros[number].m_Record.rbegin(); i != m_Macros[number].m_Record.rend(); i++ ) + for( std::list::reverse_iterator i = m_Macros[number].m_Record.rbegin(); + i != m_Macros[number].m_Record.rend(); + i++ ) { - hkStr.Printf( wxT( "%d" ), i->m_HotkeyCode); - xStr.Printf( wxT( "%d" ), i->m_Position.x); - yStr.Printf( wxT( "%d" ), i->m_Position.y); + hkStr.Printf( wxT( "%d" ), i->m_HotkeyCode ); + xStr.Printf( wxT( "%d" ), i->m_Position.x ); + yStr.Printf( wxT( "%d" ), i->m_Position.y ); - yProp = new wxXmlProperty( wxT( "y" ), yStr); - xProp = new wxXmlProperty( wxT( "x" ), xStr, yProp); - hkProp = new wxXmlProperty( wxT( "hkcode" ), hkStr, xProp); + yProp = new wxXmlProperty( wxT( "y" ), yStr ); + xProp = new wxXmlProperty( wxT( "x" ), xStr, yProp ); + hkProp = new wxXmlProperty( wxT( "hkcode" ), hkStr, xProp ); - hkNode = new wxXmlNode(macrosNode, wxXML_ELEMENT_NODE, wxT( "hotkey" ), wxEmptyString, hkProp); + hkNode = new XNODE( macrosNode, wxXML_ELEMENT_NODE, wxT( "hotkey" ), + wxEmptyString, hkProp ); } } - xml.SetFileEncoding(wxT("UTF-8")); - xml.Save(dlg.GetFilename()); + xml.SetFileEncoding( wxT("UTF-8") ); + xml.Save( dlg.GetFilename() ); } @@ -485,11 +489,12 @@ void PCB_EDIT_FRAME::ReadMacros() wxXmlDocument xml; - xml.SetFileEncoding(wxT("UTF-8")); + xml.SetFileEncoding( wxT( "UTF-8" ) ); + if( !xml.Load( dlg.GetFilename() ) ) return; - wxXmlNode *macrosNode = xml.GetRoot()->GetChildren(); + XNODE *macrosNode = (XNODE*) xml.GetRoot()->GetChildren(); while( macrosNode ) { @@ -497,34 +502,34 @@ void PCB_EDIT_FRAME::ReadMacros() if( macrosNode->GetName() == wxT( "macros" ) ) { - number = wxAtoi( macrosNode->GetPropVal( wxT( "number" ), wxT( "-1" ) ) ); + number = wxAtoi( macrosNode->GetAttribute( wxT( "number" ), wxT( "-1" ) ) ); if( number >= 0 && number < 10 ) { m_Macros[number].m_Record.clear(); - wxXmlNode *hotkeyNode = macrosNode->GetChildren(); + XNODE *hotkeyNode = (XNODE*) macrosNode->GetChildren(); + while( hotkeyNode ) { if( hotkeyNode->GetName() == wxT( "hotkey" ) ) { - int x = wxAtoi( hotkeyNode->GetPropVal( wxT( "x" ), wxT( "0" ) ) ); - int y = wxAtoi( hotkeyNode->GetPropVal( wxT( "y" ), wxT( "0" ) ) ); - int hk = wxAtoi( hotkeyNode->GetPropVal( wxT( "hkcode" ), wxT( "0" ) ) ); + int x = wxAtoi( hotkeyNode->GetAttribute( wxT( "x" ), wxT( "0" ) ) ); + int y = wxAtoi( hotkeyNode->GetAttribute( wxT( "y" ), wxT( "0" ) ) ); + int hk = wxAtoi( hotkeyNode->GetAttribute( wxT( "hkcode" ), wxT( "0" ) ) ); MACROS_RECORD macros_record; macros_record.m_HotkeyCode = hk; macros_record.m_Position.x = x; macros_record.m_Position.y = y; - m_Macros[number].m_Record.push_back(macros_record); + m_Macros[number].m_Record.push_back( macros_record ); } - hotkeyNode = hotkeyNode->GetNext(); + hotkeyNode = (XNODE*) hotkeyNode->GetNext(); } } } - macrosNode = macrosNode->GetNext(); + macrosNode = (XNODE*) macrosNode->GetNext(); } - } diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 0ef3985ea2..68b2fa3d07 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -38,8 +38,8 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* PtSegm, int masque_layer, void PlotDimension( PLOTTER* plotter, DIMENSION* Dimension, int masque_layer, GRTraceMode trace_mode ); -void PlotMirePcb( PLOTTER* plotter, MIREPCB* PtMire, int masque_layer, - GRTraceMode trace_mode ); +void PlotPcbTarget( PLOTTER* plotter, PCB_TARGET* PtMire, int masque_layer, + GRTraceMode trace_mode ); void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, GRTraceMode trace_mode ); diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index ad4bc1c486..54fe7ede52 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -14,7 +14,7 @@ #include "class_board_design_settings.h" -static void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, +static void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int aLayerMask, GRTraceMode trace_mode ); static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, GRTraceMode trace_mode ); @@ -23,7 +23,7 @@ static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, /* Creates the plot for silkscreen layers */ void PCB_BASE_FRAME::Plot_Serigraphie( PLOTTER* plotter, - int masque_layer, + int aLayerMask, GRTraceMode trace_mode ) { bool trace_val, trace_ref; @@ -37,19 +37,19 @@ void PCB_BASE_FRAME::Plot_Serigraphie( PLOTTER* plotter, switch( PtStruct->Type() ) { case TYPE_DRAWSEGMENT: - PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, masque_layer, trace_mode ); + PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, aLayerMask, trace_mode ); break; case TYPE_TEXTE: - PlotTextePcb( plotter, (TEXTE_PCB*) PtStruct, masque_layer, trace_mode ); + PlotTextePcb( plotter, (TEXTE_PCB*) PtStruct, aLayerMask, trace_mode ); break; case TYPE_DIMENSION: - PlotDimension( plotter, (DIMENSION*) PtStruct, masque_layer, trace_mode ); + PlotDimension( plotter, (DIMENSION*) PtStruct, aLayerMask, trace_mode ); break; - case TYPE_MIRE: - PlotMirePcb( plotter, (MIREPCB*) PtStruct, masque_layer, trace_mode ); + case PCB_TARGET_T: + PlotPcbTarget( plotter, (PCB_TARGET*) PtStruct, aLayerMask, trace_mode ); break; case TYPE_MARKER_PCB: @@ -62,13 +62,15 @@ void PCB_BASE_FRAME::Plot_Serigraphie( PLOTTER* plotter, } /* Plot footprint outlines : */ - Plot_Edges_Modules( plotter, m_Pcb, masque_layer, trace_mode ); + Plot_Edges_Modules( plotter, m_Pcb, aLayerMask, trace_mode ); /* Plot pads (creates pads outlines, for pads on silkscreen layers) */ - int layersmask_plotpads = masque_layer; + int layersmask_plotpads = aLayerMask; // Calculate the mask layers of allowed layers for pads + if( !g_PcbPlotOptions.m_PlotPadsOnSilkLayer ) // Do not plot pads on silk screen layers layersmask_plotpads &= ~(SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT ); + if( layersmask_plotpads ) { for( MODULE* Module = m_Pcb->m_Modules; Module; Module = Module->Next() ) @@ -76,7 +78,7 @@ void PCB_BASE_FRAME::Plot_Serigraphie( PLOTTER* plotter, for( D_PAD * pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) { /* See if the pad is on this layer */ - if( (pad->m_Masque_Layer & layersmask_plotpads) == 0 ) + if( (pad->m_layerMask & layersmask_plotpads) == 0 ) continue; wxPoint shape_pos = pad->ReturnShapePos(); @@ -129,11 +131,11 @@ module\n %s's \"reference\" text." ), return; } - if( ( ( 1 << textLayer ) & masque_layer ) == 0 ) - trace_ref = FALSE; + if( ( ( 1 << textLayer ) & aLayerMask ) == 0 ) + trace_ref = false; if( text->m_NoShow && !g_PcbPlotOptions.m_PlotInvisibleTexts ) - trace_ref = FALSE; + trace_ref = false; text = Module->m_Value; textLayer = text->GetLayer(); @@ -149,11 +151,11 @@ module\n %s's \"value\" text." ), return; } - if( ( (1 << textLayer) & masque_layer ) == 0 ) - trace_val = FALSE; + if( ( (1 << textLayer) & aLayerMask ) == 0 ) + trace_val = false; if( text->m_NoShow && !g_PcbPlotOptions.m_PlotInvisibleTexts ) - trace_val = FALSE; + trace_val = false; /* Plot text fields, if allowed */ if( trace_ref ) @@ -171,11 +173,12 @@ module\n %s's \"value\" text." ), if( !g_PcbPlotOptions.m_PlotTextOther ) continue; - if( (pt_texte->m_NoShow) - && !g_PcbPlotOptions.m_PlotInvisibleTexts ) + + if( (pt_texte->m_NoShow) && !g_PcbPlotOptions.m_PlotInvisibleTexts ) continue; textLayer = pt_texte->GetLayer(); + if( textLayer >= 32 ) { wxString errMsg; @@ -188,7 +191,7 @@ for module\n %s's \"module text\" text of %s." ), return; } - if( !( ( 1 << textLayer ) & masque_layer ) ) + if( !( ( 1 << textLayer ) & aLayerMask ) ) continue; PlotTextModule( plotter, pt_texte, trace_mode ); @@ -199,8 +202,10 @@ for module\n %s's \"module text\" text of %s." ), for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii ); - if( ( ( 1 << edge_zone->GetLayer() ) & masque_layer ) == 0 ) + + if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 ) continue; + PlotFilledAreas( plotter, edge_zone, trace_mode ); } @@ -208,16 +213,15 @@ for module\n %s's \"module text\" text of %s." ), // compatibility): for( SEGZONE* seg = m_Pcb->m_Zone; seg != NULL; seg = seg->Next() ) { - if( ( ( 1 << seg->GetLayer() ) & masque_layer ) == 0 ) + if( ( ( 1 << seg->GetLayer() ) & aLayerMask ) == 0 ) continue; - plotter->thick_segment( seg->m_Start, seg->m_End, seg->m_Width, - trace_mode ); + + plotter->thick_segment( seg->m_Start, seg->m_End, seg->m_Width, trace_mode ); } } -static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, - GRTraceMode trace_mode ) +static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, GRTraceMode trace_mode ) { wxSize size; wxPoint pos; @@ -230,6 +234,7 @@ static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, orient = pt_texte->GetDrawRotation(); thickness = pt_texte->m_Thickness; + if( trace_mode == FILAIRE ) thickness = -1; @@ -250,12 +255,12 @@ static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, } -void PlotDimension( PLOTTER* plotter, DIMENSION* Dimension, int masque_layer, +void PlotDimension( PLOTTER* plotter, DIMENSION* Dimension, int aLayerMask, GRTraceMode trace_mode ) { DRAWSEGMENT* DrawTmp; - if( (g_TabOneLayerMask[Dimension->GetLayer()] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[Dimension->GetLayer()] & aLayerMask) == 0 ) return; DrawTmp = new DRAWSEGMENT( NULL ); @@ -263,61 +268,60 @@ void PlotDimension( PLOTTER* plotter, DIMENSION* Dimension, int masque_layer, DrawTmp->m_Width = (trace_mode==FILAIRE) ? -1 : Dimension->m_Width; DrawTmp->SetLayer( Dimension->GetLayer() ); - PlotTextePcb( plotter, Dimension->m_Text, masque_layer, trace_mode ); + PlotTextePcb( plotter, Dimension->m_Text, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->Barre_ox; DrawTmp->m_Start.y = Dimension->Barre_oy; DrawTmp->m_End.x = Dimension->Barre_fx; DrawTmp->m_End.y = Dimension->Barre_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->TraitG_ox; DrawTmp->m_Start.y = Dimension->TraitG_oy; DrawTmp->m_End.x = Dimension->TraitG_fx; DrawTmp->m_End.y = Dimension->TraitG_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->TraitD_ox; DrawTmp->m_Start.y = Dimension->TraitD_oy; DrawTmp->m_End.x = Dimension->TraitD_fx; DrawTmp->m_End.y = Dimension->TraitD_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->FlecheD1_ox; DrawTmp->m_Start.y = Dimension->FlecheD1_oy; DrawTmp->m_End.x = Dimension->FlecheD1_fx; DrawTmp->m_End.y = Dimension->FlecheD1_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->FlecheD2_ox; DrawTmp->m_Start.y = Dimension->FlecheD2_oy; DrawTmp->m_End.x = Dimension->FlecheD2_fx; DrawTmp->m_End.y = Dimension->FlecheD2_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->FlecheG1_ox; DrawTmp->m_Start.y = Dimension->FlecheG1_oy; DrawTmp->m_End.x = Dimension->FlecheG1_fx; DrawTmp->m_End.y = Dimension->FlecheG1_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Dimension->FlecheG2_ox; DrawTmp->m_Start.y = Dimension->FlecheG2_oy; DrawTmp->m_End.x = Dimension->FlecheG2_fx; DrawTmp->m_End.y = Dimension->FlecheG2_fy; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); delete DrawTmp; } -void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer, - GRTraceMode trace_mode ) +void PlotPcbTarget( PLOTTER* plotter, PCB_TARGET* Mire, int aLayerMask, GRTraceMode trace_mode ) { DRAWSEGMENT* DrawTmp; int dx1, dx2, dy1, dy2, radius; - if( (g_TabOneLayerMask[Mire->GetLayer()] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[Mire->GetLayer()] & aLayerMask) == 0 ) return; DrawTmp = new DRAWSEGMENT( NULL ); @@ -329,7 +333,7 @@ void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer, DrawTmp->m_End.x = DrawTmp->m_Start.x + ( Mire->m_Size / 4 ); DrawTmp->m_End.y = DrawTmp->m_Start.y; DrawTmp->m_Shape = S_CIRCLE; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Shape = S_SEGMENT; @@ -350,20 +354,20 @@ void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer, DrawTmp->m_Start.y = Mire->m_Pos.y - dy1; DrawTmp->m_End.x = Mire->m_Pos.x + dx1; DrawTmp->m_End.y = Mire->m_Pos.y + dy1; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); DrawTmp->m_Start.x = Mire->m_Pos.x - dx2; DrawTmp->m_Start.y = Mire->m_Pos.y - dy2; DrawTmp->m_End.x = Mire->m_Pos.x + dx2; DrawTmp->m_End.y = Mire->m_Pos.y + dy2; - PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); + PlotDrawSegment( plotter, DrawTmp, aLayerMask, trace_mode ); delete DrawTmp; } /* Plot footprints graphic items (outlines) */ -void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, +void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int aLayerMask, GRTraceMode trace_mode ) { for( MODULE* module = pcb->m_Modules; module; module = module->Next() ) @@ -375,7 +379,7 @@ void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, if( edge->Type() != TYPE_EDGE_MODULE ) continue; - if( ( g_TabOneLayerMask[edge->GetLayer()] & masque_layer ) == 0 ) + if( ( g_TabOneLayerMask[edge->GetLayer()] & aLayerMask ) == 0 ) continue; Plot_1_EdgeModule( plotter, edge, trace_mode ); @@ -431,6 +435,7 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, case S_POLYGON: { std::vector polyPoints = PtEdge->GetPolyPoints(); + if( polyPoints.size() <= 1 ) // Malformed polygon break; @@ -462,7 +467,7 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, /* Plot a PCB Text, i;e. a text found on a copper or technical layer */ -void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, +void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int aLayerMask, GRTraceMode trace_mode ) { int orient, thickness; @@ -471,7 +476,8 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, if( pt_texte->m_Text.IsEmpty() ) return; - if( ( g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer ) == 0 ) + + if( ( g_TabOneLayerMask[pt_texte->GetLayer()] & aLayerMask ) == 0 ) return; size = pt_texte->m_Size; @@ -496,6 +502,7 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, offset.y = pt_texte->GetInterline(); RotatePoint( &offset, orient ); + for( unsigned i = 0; i < list->Count(); i++ ) { wxString txt = list->Item( i ); @@ -510,20 +517,22 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, delete (list); } else + { plotter->text( pos, BLACK, pt_texte->m_Text, orient, size, pt_texte->m_HJustify, pt_texte->m_VJustify, thickness, pt_texte->m_Italic, allow_bold ); + } } /* Plot areas (given by .m_FilledPolysList member) in a zone */ -void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, - GRTraceMode trace_mode ) +void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, GRTraceMode trace_mode ) { unsigned imax = aZone->m_FilledPolysList.size(); + if( imax == 0 ) // Nothing to draw return; @@ -541,6 +550,7 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, { CPolyPt* corner = &aZone->m_FilledPolysList[ic]; cornerList.push_back( wxPoint( corner->x, corner->y) ); + if( corner->end_contour ) // Plot the current filled area outline { // First, close the outline @@ -554,14 +564,12 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, { // Plot the current filled area polygon if( aZone->m_FillMode == 0 ) // We are using solid polygons - // (if != 0: using segments ) + { // (if != 0: using segments ) plotter->PlotPoly( cornerList, FILLED_SHAPE ); + } else // We are using areas filled by - // segments: plot them ) - { - for( unsigned iseg = 0; - iseg < aZone->m_FillSegmList.size(); - iseg++ ) + { // segments: plot them ) + for( unsigned iseg = 0; iseg < aZone->m_FillSegmList.size(); iseg++ ) { wxPoint start = aZone->m_FillSegmList[iseg].m_Start; wxPoint end = aZone->m_FillSegmList[iseg].m_End; @@ -581,28 +589,30 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, if( aZone->m_ZoneMinThickness > 0 ) { for( unsigned jj = 1; jjthick_segment(cornerList[jj -1], cornerList[jj], - ( trace_mode == FILAIRE ) ? -1 : aZone->m_ZoneMinThickness, - trace_mode ); + plotter->thick_segment( cornerList[jj -1], cornerList[jj], + ( trace_mode == FILAIRE ) ? -1 : aZone->m_ZoneMinThickness, + trace_mode ); } + plotter->set_current_line_width( -1 ); } + cornerList.clear(); } } } -/* Plot items type DRAWSEGMENT on layers allowed by masque_layer +/* Plot items type DRAWSEGMENT on layers allowed by aLayerMask */ -void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer, +void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int aLayerMask, GRTraceMode trace_mode ) { wxPoint start, end; int thickness; int radius = 0, StAngle = 0, EndAngle = 0; - if( (g_TabOneLayerMask[pt_segm->GetLayer()] & masque_layer) == 0 ) + if( (g_TabOneLayerMask[pt_segm->GetLayer()] & aLayerMask) == 0 ) return; if( trace_mode == FILAIRE ) @@ -614,27 +624,21 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer, end = pt_segm->m_End; plotter->set_current_line_width( thickness ); + switch( pt_segm->m_Shape ) { case S_CIRCLE: - radius = - (int) hypot( (double) ( end.x - start.x ), - (double) ( end.y - start.y ) ); + radius = (int) hypot( (double) ( end.x - start.x ), + (double) ( end.y - start.y ) ); plotter->thick_circle( start, radius * 2, thickness, trace_mode ); break; case S_ARC: - radius = - (int) hypot( (double) ( end.x - start.x ), - (double) ( end.y - start.y ) ); + radius = (int) hypot( (double) ( end.x - start.x ), + (double) ( end.y - start.y ) ); StAngle = ArcTangente( end.y - start.y, end.x - start.x ); EndAngle = StAngle + pt_segm->m_Angle; - plotter->thick_arc( start, - -EndAngle, - -StAngle, - radius, - thickness, - trace_mode ); + plotter->thick_arc( start, -EndAngle, -StAngle, radius, thickness, trace_mode ); break; case S_CURVE: @@ -684,8 +688,7 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* plotter, int Layer, GRTraceMode trace_ Plot_Standard_Layer( plotter, layer_mask, true, trace_mode, g_PcbPlotOptions.m_SkipNPTH_Pads ); - // Adding drill marks, if required and if the plotter is able to plot - // them: + // Adding drill marks, if required and if the plotter is able to plot them: if( g_PcbPlotOptions.m_DrillShapeOpt != PCB_PLOT_PARAMS::NO_DRILL_SHAPE ) { if( plotter->GetPlotterType() == PLOT_FORMAT_POST ) @@ -693,6 +696,7 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* plotter, int Layer, GRTraceMode trace_ g_PcbPlotOptions.m_DrillShapeOpt == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE ); } + break; case SOLDERMASK_N_BACK: @@ -728,6 +732,7 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* plotter, int Layer, GRTraceMode trace_ g_PcbPlotOptions.m_PlotViaOnMaskLayer, trace_mode ); } + break; } } @@ -752,10 +757,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, switch( item->Type() ) { case TYPE_DRAWSEGMENT: - PlotDrawSegment( aPlotter, - (DRAWSEGMENT*) item, - aLayerMask, - aPlotMode ); + PlotDrawSegment( aPlotter, (DRAWSEGMENT*) item, aLayerMask, aPlotMode ); break; case TYPE_TEXTE: @@ -766,8 +768,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, PlotDimension( aPlotter, (DIMENSION*) item, aLayerMask, aPlotMode ); break; - case TYPE_MIRE: - PlotMirePcb( aPlotter, (MIREPCB*) item, aLayerMask, aPlotMode ); + case PCB_TARGET_T: + PlotPcbTarget( aPlotter, (PCB_TARGET*) item, aLayerMask, aPlotMode ); break; case TYPE_MARKER_PCB: @@ -788,9 +790,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, { case TYPE_EDGE_MODULE: if( aLayerMask & g_TabOneLayerMask[ item->GetLayer() ] ) - Plot_1_EdgeModule( aPlotter, - (EDGE_MODULE*) item, - aPlotMode ); + Plot_1_EdgeModule( aPlotter, (EDGE_MODULE*) item, aPlotMode ); + break; default: @@ -805,12 +806,14 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() ) { wxPoint shape_pos; - if( (pad->m_Masque_Layer & aLayerMask) == 0 ) + + if( (pad->m_layerMask & aLayerMask) == 0 ) continue; shape_pos = pad->ReturnShapePos(); pos = shape_pos; wxSize margin; + switch( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT | SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT ) ) @@ -843,6 +846,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, (pad->m_Size == pad->m_Drill) && (pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) break; + aPlotter->flash_pad_circle( pos, size.x, aPlotMode ); break; @@ -851,6 +855,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, (pad->m_Size == pad->m_Drill) && (pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) break; + aPlotter->flash_pad_oval( pos, size, pad->m_Orient, aPlotMode ); break; @@ -884,10 +889,13 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, // is SOLDERMASK_LAYER_BACK or SOLDERMASK_LAYER_FRONT,vias are drawn, // if they are on an external copper layer int via_mask_layer = Via->ReturnMaskLayer(); + if( via_mask_layer & LAYER_BACK ) via_mask_layer |= SOLDERMASK_LAYER_BACK; + if( via_mask_layer & LAYER_FRONT ) via_mask_layer |= SOLDERMASK_LAYER_FRONT; + if( ( via_mask_layer & aLayerMask ) == 0 ) continue; @@ -897,6 +905,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, // clearance for vias if( ( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) ) ) via_margin = GetBoard()->GetBoardDesignSettings()->m_SolderMaskMargin; + pos = Via->m_Start; size.x = size.y = Via->m_Width + 2 * via_margin; @@ -945,8 +954,10 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii ); + if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 ) continue; + PlotFilledAreas( aPlotter, edge_zone, aPlotMode ); } } @@ -982,7 +993,9 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, { if( pts->Type() != TYPE_VIA ) continue; + pos = pts->m_Start; + if( g_PcbPlotOptions.m_DrillShapeOpt == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE ) diam.x = diam.y = SMALL_DRILL; else @@ -991,26 +1004,20 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, aPlotter->flash_pad_circle( pos, diam.x, aTraceMode ); } - for( Module = m_Pcb->m_Modules; - Module != NULL; - Module = Module->Next() ) + for( Module = m_Pcb->m_Modules; Module != NULL; Module = Module->Next() ) { - for( PtPad = Module->m_Pads; - PtPad != NULL; - PtPad = PtPad->Next() ) + for( PtPad = Module->m_Pads; PtPad != NULL; PtPad = PtPad->Next() ) { if( PtPad->m_Drill.x == 0 ) continue; // Output hole shapes: pos = PtPad->m_Pos; + if( PtPad->m_DrillShape == PAD_OVAL ) { diam = PtPad->m_Drill; - aPlotter->flash_pad_oval( pos, - diam, - PtPad->m_Orient, - aTraceMode ); + aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode ); } else { diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index eaa7f3d899..73851b32ed 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -18,29 +18,34 @@ bool PCB_BASE_FRAME::Genere_HPGL( const wxString& FullFileName, int Layer, GRTra wxSize SheetSize; wxSize BoardSize; wxPoint BoardCenter; - bool Center = FALSE; + bool Center = false; Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc; double scale; wxPoint offset; FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) ); + if( output_file == NULL ) { return false; } + // Compute pen_dim (from g_m_HPGLPenDiam in mils) in pcb units, // with plot scale (if Scale is 2, pen diameter is always g_m_HPGLPenDiam // so apparent pen diam is real pen diam / Scale - int pen_diam = wxRound( (g_PcbPlotOptions.m_HPGLPenDiam * U_PCB) / g_PcbPlotOptions.m_PlotScale ); + int pen_diam = wxRound( (g_PcbPlotOptions.m_HPGLPenDiam * U_PCB) / + g_PcbPlotOptions.m_PlotScale ); // compute pen_overlay (from g_m_HPGLPenOvr in mils) // with plot scale if( g_PcbPlotOptions.m_HPGLPenOvr < 0 ) g_PcbPlotOptions.m_HPGLPenOvr = 0; + if( g_PcbPlotOptions.m_HPGLPenOvr >= g_PcbPlotOptions.m_HPGLPenDiam ) g_PcbPlotOptions.m_HPGLPenOvr = g_PcbPlotOptions.m_HPGLPenDiam - 1; - int pen_overlay = wxRound( - g_PcbPlotOptions.m_HPGLPenOvr * 10.0 / g_PcbPlotOptions.m_PlotScale ); + + int pen_overlay = wxRound( g_PcbPlotOptions.m_HPGLPenOvr * 10.0 / + g_PcbPlotOptions.m_PlotScale ); SetLocaleTo_C_standard(); @@ -68,7 +73,9 @@ bool PCB_BASE_FRAME::Genere_HPGL( const wxString& FullFileName, int Layer, GRTra scale = MIN( Xscale, Yscale ); } else + { scale = g_PcbPlotOptions.m_PlotScale; + } // Calculate the page size offset. if( Center ) diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index 5068eb45b6..c35d0e4db1 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -23,13 +23,14 @@ bool PCB_BASE_FRAME::Genere_PS( const wxString& FullFileName, int Layer, wxSize PaperSize; wxSize BoardSize; wxPoint BoardCenter; - bool Center = FALSE; + bool Center = false; Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc; double scale, paperscale; Ki_PageDescr* SheetPS; wxPoint offset; FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) ); + if( output_file == NULL ) { return false; @@ -80,10 +81,8 @@ bool PCB_BASE_FRAME::Genere_PS( const wxString& FullFileName, int Layer, if( Center ) { - offset.x = wxRound( (double) BoardCenter.x - - ( (double) PaperSize.x / 2.0 ) / scale ); - offset.y = wxRound( (double) BoardCenter.y - - ( (double) PaperSize.y / 2.0 ) / scale ); + offset.x = wxRound( (double) BoardCenter.x - ( (double) PaperSize.x / 2.0 ) / scale ); + offset.y = wxRound( (double) BoardCenter.y - ( (double) PaperSize.y / 2.0 ) / scale ); } else { diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 6aa10bdbf5..2a49d83f29 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -113,17 +113,19 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, { MODULE* Module; int drawmode = GR_COPY; - DISPLAY_OPTIONS save_opt; - TRACK* pt_piste; - BOARD* Pcb = GetBoard(); - int defaultPenSize = 50; - bool onePagePerLayer = false; + DISPLAY_OPTIONS save_opt; + TRACK* pt_trace; + BOARD* Pcb = GetBoard(); + int defaultPenSize = 50; + bool onePagePerLayer = false; PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null + if( printParameters && printParameters->m_OptionPrintPage == 0 ) onePagePerLayer = true; PRINT_PARAMETERS::DrillShapeOptT drillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; + if( printParameters ) { drillShapeOpt = printParameters->m_DrillShapeOpt; @@ -140,14 +142,15 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, if( (aPrintMaskLayer & ALL_CU_LAYERS) == 0 ) { if( onePagePerLayer ) - { // We can print mask layers (solder mask and solder paste) with the actual pad sizes - // To do that, we must set ContrastModeDisplay to true and set the GetScreen()->m_Active_Layer - // to the current printed layer + { // We can print mask layers (solder mask and solder paste) with the actual + // pad sizes. To do that, we must set ContrastModeDisplay to true and set + //the GetScreen()->m_Active_Layer to the current printed layer DisplayOpt.ContrastModeDisplay = true; DisplayOpt.DisplayPadFill = true; // Calculate the active layer number to print from its mask layer: GetScreen()->m_Active_Layer = 0; + for(int kk = 0; kk < 32; kk ++ ) { if( ((1 << kk) & aPrintMaskLayer) != 0 ) @@ -203,7 +206,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, case TYPE_DRAWSEGMENT: case TYPE_DIMENSION: case TYPE_TEXTE: - case TYPE_MIRE: + case PCB_TARGET_T: if( ( ( 1 << item->GetLayer() ) & aPrintMaskLayer ) == 0 ) break; @@ -217,38 +220,38 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, } /* Print tracks */ - pt_piste = Pcb->m_Track; + pt_trace = Pcb->m_Track; - for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) + for( ; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 ) + if( ( aPrintMaskLayer & pt_trace->ReturnMaskLayer() ) == 0 ) continue; - if( pt_piste->Type() == TYPE_VIA ) /* VIA encountered. */ + if( pt_trace->Type() == TYPE_VIA ) /* VIA encountered. */ { - int rayon = pt_piste->m_Width >> 1; - int color = g_ColorsSettings.GetItemColor(VIAS_VISIBLE+pt_piste->m_Shape); + int radius = pt_trace->m_Width >> 1; + int color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + pt_trace->m_Shape ); GRSetDrawMode( aDC, drawmode ); GRFilledCircle( &DrawPanel->m_ClipBox, aDC, - pt_piste->m_Start.x, - pt_piste->m_Start.y, - rayon, + pt_trace->m_Start.x, + pt_trace->m_Start.y, + radius, 0, color, color ); } else { - pt_piste->Draw( DrawPanel, aDC, drawmode ); + pt_trace->Draw( DrawPanel, aDC, drawmode ); } } - pt_piste = Pcb->m_Zone; + pt_trace = Pcb->m_Zone; - for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) + for( ; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 ) + if( ( aPrintMaskLayer & pt_trace->ReturnMaskLayer() ) == 0 ) continue; - pt_piste->Draw( DrawPanel, aDC, drawmode ); + pt_trace->Draw( DrawPanel, aDC, drawmode ); } /* Draw filled areas (i.e. zones) */ @@ -279,28 +282,28 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, * vias */ if( drillShapeOpt != PRINT_PARAMETERS::NO_DRILL_SHAPE ) { - pt_piste = Pcb->m_Track; + pt_trace = Pcb->m_Track; int color = g_DrawBgColor; bool blackpenstate = GetGRForceBlackPenState(); GRForceBlackPen( false ); GRSetDrawMode( aDC, GR_COPY ); - for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) + for( ; pt_trace != NULL; pt_trace = pt_trace->Next() ) { - if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 ) + if( ( aPrintMaskLayer & pt_trace->ReturnMaskLayer() ) == 0 ) continue; - if( pt_piste->Type() == TYPE_VIA ) /* VIA encountered. */ + if( pt_trace->Type() == TYPE_VIA ) /* VIA encountered. */ { int diameter; if( drillShapeOpt == PRINT_PARAMETERS::SMALL_DRILL_SHAPE ) - diameter = min( SMALL_DRILL, pt_piste->GetDrillValue() ); + diameter = min( SMALL_DRILL, pt_trace->GetDrillValue() ); else - diameter = pt_piste->GetDrillValue(); + diameter = pt_trace->GetDrillValue(); GRFilledCircle( &DrawPanel->m_ClipBox, aDC, - pt_piste->m_Start.x, pt_piste->m_Start.y, + pt_trace->m_Start.x, pt_trace->m_Start.y, diameter/2, 0, color, color ); } @@ -337,7 +340,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { - if( (pt_pad->m_Masque_Layer & aMasklayer ) == 0 ) + if( (pt_pad->m_layerMask & aMasklayer ) == 0 ) continue; // Manage hole according to the print drill option @@ -394,8 +397,10 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, case TYPE_EDGE_MODULE: { EDGE_MODULE* edge = (EDGE_MODULE*) PtStruct; + if( ( g_TabOneLayerMask[edge->GetLayer()] & aMasklayer ) == 0 ) break; + edge->Draw( aPanel, aDC, aDraw_mode ); break; } diff --git a/pcbnew/protos.h b/pcbnew/protos.h index 25cd00f64b..6e50cefda1 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -55,11 +55,11 @@ void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector* aVector ); * The starting point of a track following MUST exist: may be * Then put a 0 before calling a routine if the track is the last draw */ -void Trace_Une_Piste( EDA_DRAW_PANEL* panel, - wxDC* DC, - TRACK* pt_start_piste, - int nbsegment, - int mode_color ); +void DrawTraces( EDA_DRAW_PANEL* panel, + wxDC* DC, + TRACK* aStartTrace, + int nbsegment, + int mode_color ); /****************/ @@ -67,7 +67,7 @@ void Trace_Une_Piste( EDA_DRAW_PANEL* panel, /****************/ /* Find a pad by it's name om the module. */ -TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 ); +TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 ); /** * Function Locate_Via_Area @@ -89,8 +89,7 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, in * by masquelayer. * Search is done to address start_adr has end_adr (not included) */ -TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, - const wxPoint& ref_pos, int masquelayer ); +TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int masquelayer ); /* Search for segment connected to the segment edge by * Ptr_piste: @@ -99,7 +98,7 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, * The search is done only on the ends of segments * The search is limited to the area [... pt_base] pt_lim. */ -TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, TRACK* pt_lim, int extr ); +TRACK* GetConnectedTrace( TRACK* aTrace, TRACK* pt_base, TRACK* pt_lim, int extr ); /* * 1 - Locate segment of track leading from the mouse. @@ -110,7 +109,7 @@ TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, TRACK* pt_lim, * * The search begins to address start_adresse */ -TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int layer ); +TRACK* GetTrace( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int layer ); /* Locate pad connected to the beginning or end of a segment * Input: pointer to the segment, and flag = START or END @@ -158,7 +157,7 @@ D_PAD* Locate_Pads( MODULE* Module, int typeloc ); /* Locate a trace segment at the current cursor position. * The search begins to address start_adresse. */ -TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc ); +TRACK* GetTrace( TRACK* start_adresse, int typeloc ); DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ); @@ -187,8 +186,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ); /*************/ int ChangeSideNumLayer( int oldlayer ); void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module ); -void Montre_Position_Empreinte( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ); +void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); /****************/ @@ -203,7 +201,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo /* Determine coordinate for a segment direction of 0, 90 or 45 degrees, * depending on it's position from the origin (ox, oy) and \a aPosiition.. */ -void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy ); +void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy ); /*****************/ @@ -211,7 +209,7 @@ void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* /*****************/ /** - * Function Marque_Une_Piste + * Function MarkTrace * marks a chain of track segments, connected to aTrackList. * Each segment is marked by setting the BUSY bit into m_Flags. Electrical * continuity is detected by walking each segment, and finally the segments @@ -234,12 +232,12 @@ void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* * track length in this case, flags are reset * @return TRACK* the first in the chain of interesting segments. */ -TRACK* Marque_Une_Piste( BOARD* aPcb, - TRACK* aStartSegm, - int* aSegmCount, - int* aTrackLen, - int* aLengthDie, - bool aReorder ); +TRACK* MarkTrace( BOARD* aPcb, + TRACK* aStartSegm, + int* aSegmCount, + int* aTrackLen, + int* aLengthDie, + bool aReorder ); /* Calculate end coordinate of a trace. * Returns 1 if OK, 0 if trace looped back on itself. @@ -247,7 +245,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, * And EndTrack-> fx, fy if OK * The segments are drawn consecutively. */ -int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** EndTrack ); +int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** EndTrack ); /***************/ @@ -279,10 +277,10 @@ BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask ); * Returns the exact value of aRefPoint and a pointer to the via, * But does not create extra point */ -TRACK* CreateLockPoint( BOARD* aPcb, - wxPoint& aRefPoint, - TRACK* aSegm, - PICKED_ITEMS_LIST* aItemsListPicker ); +TRACK* CreateLockPoint( BOARD* aPcb, + wxPoint& aRefPoint, + TRACK* aSegm, + PICKED_ITEMS_LIST* aItemsListPicker ); /****************/ diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index d616f72bdc..3fc111f053 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -116,7 +116,7 @@ void PCB_BASE_FRAME::Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus ) { wxString msg; - DisplayRastnestInProgress = TRUE; + DisplayRastnestInProgress = true; GetBoard()->m_Status_Pcb = 0; /* we want a full ratsnest computation, * from the scratch */ @@ -203,7 +203,8 @@ static int sort_by_length( const void* o1, const void* o2 ) * @param aPadIdxMax = ending index (within the pad list) for search * @return blocks not connected count */ -static int gen_rats_block_to_block( +static int gen_rats_block_to_block +( std::vector& aRatsnestBuffer, std::vector& aPadBuffer, unsigned aPadIdxStart, @@ -271,8 +272,10 @@ static int gen_rats_block_to_block( } if( padBlock1Idx < 0 ) + { DisplayError( NULL, wxT( "gen_rats_block_to_block() internal error" ) ); + } else { /* Create the new ratsnest */ @@ -285,6 +288,7 @@ static int gen_rats_block_to_block( aRatsnestBuffer.push_back( net ); } } + return current_num_block; } @@ -355,11 +359,9 @@ static int gen_rats_pad_to_pad( vector& aRatsnestBuffer, /* Update the block number * if the 2 pads are not already created : a new block is created */ - if( (pad->GetSubRatsnest() == 0) - && (ref_pad->GetSubRatsnest() == 0) ) + if( (pad->GetSubRatsnest() == 0) && (ref_pad->GetSubRatsnest() == 0) ) { - current_num_block++; // Creates a new block number (or - // subratsnest) + current_num_block++; // Creates a new block number (or subratsnest) pad->SetSubRatsnest( current_num_block ); ref_pad->SetSubRatsnest( current_num_block ); } @@ -437,7 +439,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest( wxDC* DC ) return; /* No useful connections. */ /* Ratsnest computation */ - DisplayRastnestInProgress = TRUE; + DisplayRastnestInProgress = true; unsigned current_net_code = 1; // First net code is analyzed. // (net_code = 0 -> no connect) @@ -446,19 +448,23 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest( wxDC* DC ) for( ; current_net_code < m_Pcb->m_NetInfo->GetCount(); current_net_code++ ) { NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code ); + if( net == NULL ) //Should not occur { DisplayError( this, wxT( "Build_Board_Ratsnest() error: net not found" ) ); return; } + net->m_RatsnestStartIdx = m_Pcb->GetRatsnestsCount(); // Search for the last subratsnest already in use int num_block = 0; + for( unsigned ii = 0; ii < net->m_ListPad.size(); ii++ ) { pad = net->m_ListPad[ii]; + if( num_block < pad->GetSubRatsnest() ) num_block = pad->GetSubRatsnest(); } @@ -486,6 +492,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest( wxDC* DC ) /* sort by length */ net = m_Pcb->FindNet( current_net_code ); + if( ( net->m_RatsnestEndIdx - net->m_RatsnestStartIdx ) > 1 ) { RATSNEST_ITEM* rats = &m_Pcb->m_FullRatsnest[0]; @@ -522,14 +529,19 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode ) { if( ( m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 ) return; + if( ( m_Pcb->m_Status_Pcb & DO_NOT_SHOW_GENERAL_RASTNEST ) ) return; + if( aDC == NULL ) return; + int state = CH_VISIBLE | CH_ACTIF; + for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) { RATSNEST_ITEM& item = m_Pcb->m_FullRatsnest[ii]; + if( ( item.m_Status & state ) != state ) continue; @@ -565,13 +577,12 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, /* Search a link from a block to an other block */ min_rats = NULL; - for( unsigned ii = net->m_RatsnestStartIdx; - ii < net->m_RatsnestEndIdx; - ii++ ) + + for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ ) { rats = &aRatsnestBuffer[ii]; - if( rats->m_PadStart->GetSubRatsnest() == - rats->m_PadEnd->GetSubRatsnest() ) // Same block + + if( rats->m_PadStart->GetSubRatsnest() == rats->m_PadEnd->GetSubRatsnest() ) // Same block continue; if( min_rats == NULL ) @@ -631,35 +642,33 @@ static int tst_rats_pad_to_pad( int current_num_block, RATSNEST_ITEM* end_rat_list ) { D_PAD* pad_start, * pad_end; - RATSNEST_ITEM* chevelu; + RATSNEST_ITEM* item; - for( chevelu = start_rat_list; chevelu < end_rat_list; chevelu++ ) + for( item = start_rat_list; item < end_rat_list; item++ ) { - pad_start = chevelu->m_PadStart; - pad_end = chevelu->m_PadEnd; + pad_start = item->m_PadStart; + pad_end = item->m_PadEnd; - /* Update the block if the 2 pads are not connected : a new block is - * created + /* Update the block if the 2 pads are not connected : a new block is created */ - if( (pad_start->GetSubRatsnest() == 0) - && (pad_end->GetSubRatsnest() == 0) ) + if( (pad_start->GetSubRatsnest() == 0) && (pad_end->GetSubRatsnest() == 0) ) { current_num_block++; pad_start->SetSubRatsnest( current_num_block ); pad_end->SetSubRatsnest( current_num_block ); - chevelu->m_Status |= CH_ACTIF; + item->m_Status |= CH_ACTIF; } - /* If a pad is already connected : the other is merged in the current - * block */ + + /* If a pad is already connected : the other is merged in the current block */ else if( pad_start->GetSubRatsnest() == 0 ) { pad_start->SetSubRatsnest( pad_end->GetSubRatsnest() ); - chevelu->m_Status |= CH_ACTIF; + item->m_Status |= CH_ACTIF; } else if( pad_end->GetSubRatsnest() == 0 ) { pad_end->SetSubRatsnest( pad_start->GetSubRatsnest() ); - chevelu->m_Status |= CH_ACTIF; + item->m_Status |= CH_ACTIF; } } @@ -680,14 +689,14 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode ) if( m_Pcb->GetPadsCount() == 0 ) return; + if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) Build_Board_Ratsnest( DC ); - for( int net_code = 1; - net_code < (int) m_Pcb->m_NetInfo->GetCount(); - net_code++ ) + for( int net_code = 1; net_code < (int) m_Pcb->m_NetInfo->GetCount(); net_code++ ) { net = m_Pcb->FindNet( net_code ); + if( net == NULL ) //Should not occur { DisplayError( this, wxT( "Tst_Ratsnest() error: net not found" ) ); @@ -698,6 +707,7 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode ) continue; int num_block = 0; + for( unsigned ip = 0; ip < net->m_ListPad.size(); ip++ ) { pad = net->m_ListPad[ip]; @@ -706,9 +716,7 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode ) num_block = MAX( num_block, subnet ); } - for( unsigned ii = net->m_RatsnestStartIdx; - ii < net->m_RatsnestEndIdx; - ii++ ) + for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ ) { m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_ACTIF; } @@ -727,6 +735,7 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode ) } m_Pcb->m_NbNoconnect = 0; + for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) { if( m_Pcb->m_FullRatsnest[ii].m_Status & CH_ACTIF ) @@ -743,7 +752,7 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode ) */ int PCB_BASE_FRAME::Test_1_Net_Ratsnest( wxDC* aDC, int aNetcode ) { - DisplayRastnestInProgress = FALSE; + DisplayRastnestInProgress = false; DrawGeneralRatsnest( aDC, aNetcode ); Tst_Ratsnest( aDC, aNetcode ); DrawGeneralRatsnest( aDC, aNetcode ); @@ -811,27 +820,27 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) } pads_module_count = s_localPadBuffer.size(); + if( pads_module_count == 0 ) return; /* no connection! */ - qsort( &s_localPadBuffer[0], - pads_module_count, - sizeof(D_PAD*), - sortByNetcode ); + qsort( &s_localPadBuffer[0], pads_module_count, sizeof( D_PAD* ), sortByNetcode ); /* Build the list of pads linked to the current footprint pads */ - DisplayRastnestInProgress = FALSE; + DisplayRastnestInProgress = false; current_net_code = 0; + for( unsigned ii = 0; ii < pads_module_count; ii++ ) { pad_ref = s_localPadBuffer[ii]; + if( pad_ref->GetNet() == current_net_code ) continue; - // A new net was found, load all pads of others modules members of this - // net: + // A new net was found, load all pads of others modules members of this net: NETINFO_ITEM* net = m_Pcb->FindNet( pad_ref->GetNet() ); + if( net == NULL ) //Should not occur { DisplayError( this, @@ -842,6 +851,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) for( unsigned jj = 0; jj < net->m_ListPad.size(); jj++ ) { pad_externe = net->m_ListPad[jj]; + if( pad_externe->GetParent() == aModule ) continue; @@ -854,8 +864,8 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) /* Sort the pad list by net_code */ baseListePad = &s_localPadBuffer[0]; - qsort( baseListePad + pads_module_count, - s_localPadBuffer.size() - pads_module_count, + + qsort( baseListePad + pads_module_count, s_localPadBuffer.size() - pads_module_count, sizeof(D_PAD*), sortByNetcode ); /* Compute the internal rats nest: @@ -869,6 +879,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) { /* Search the end of pad list relative to the current net */ unsigned jj = ii + 1; + for( ; jj <= pads_module_count; jj++ ) { if( jj >= pads_module_count ) @@ -880,20 +891,17 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) /* End of list found: */ /* a - first step of lee algorithm : build the pad to pad link list */ - int icnt = gen_rats_pad_to_pad( m_Pcb->m_LocalRatsnest, - s_localPadBuffer, - ii, jj, 0 ); + int icnt = gen_rats_pad_to_pad( m_Pcb->m_LocalRatsnest, s_localPadBuffer, ii, jj, 0 ); /* b - second step of lee algorithm : build the block to block link *list (Iteration) */ while( icnt > 1 ) { - icnt = gen_rats_block_to_block( m_Pcb->m_LocalRatsnest, - s_localPadBuffer, - ii, jj ); + icnt = gen_rats_block_to_block( m_Pcb->m_LocalRatsnest, s_localPadBuffer, ii, jj ); } ii = jj; + if( ii < s_localPadBuffer.size() ) current_net_code = s_localPadBuffer[ii]->GetNet(); } @@ -926,14 +934,15 @@ CalculateExternalRatsnest: local_rats.m_Status = 0; bool addRats = false; if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() ) - m_Pcb->m_LocalRatsnest.erase( - m_Pcb->m_LocalRatsnest.begin() + internalRatsCount, - m_Pcb->m_LocalRatsnest.end() ); + m_Pcb->m_LocalRatsnest.erase( m_Pcb->m_LocalRatsnest.begin() + internalRatsCount, + m_Pcb->m_LocalRatsnest.end() ); current_net_code = s_localPadBuffer[0]->GetNet(); + for( unsigned ii = 0; ii < pads_module_count; ii++ ) { pad_ref = s_localPadBuffer[ii]; + if( pad_ref->GetNet() != current_net_code ) { /* if needed, creates a new ratsnest for the old net */ @@ -941,6 +950,7 @@ CalculateExternalRatsnest: { m_Pcb->m_LocalRatsnest.push_back( local_rats ); } + addRats = false; current_net_code = pad_ref->GetNet(); local_rats.m_Lenght = 0x7FFFFFFF; @@ -949,9 +959,7 @@ CalculateExternalRatsnest: pad_pos = pad_ref->m_Pos - g_Offset_Module; // Search the nearest external pad of this current pad - for( unsigned jj = pads_module_count; - jj < s_localPadBuffer.size(); - jj++ ) + for( unsigned jj = pads_module_count; jj < s_localPadBuffer.size(); jj++ ) { pad_externe = s_localPadBuffer[jj]; @@ -959,9 +967,7 @@ CalculateExternalRatsnest: if( pad_externe->GetNet() < pad_ref->GetNet() ) continue; - if( pad_externe->GetNet() > pad_ref->GetNet() ) // remember pads - // are sorted by - // net code + if( pad_externe->GetNet() > pad_ref->GetNet() ) // pads are sorted by net code break; distance = abs( pad_externe->m_Pos.x - pad_pos.x ) + @@ -993,13 +999,16 @@ void PCB_BASE_FRAME::trace_ratsnest_module( wxDC* DC ) { if( DC == NULL ) return; + if( ( m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 ) return; int tmpcolor = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); + for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ ) { RATSNEST_ITEM* rats = &m_Pcb->m_LocalRatsnest[ii]; + if( rats->m_Status & LOCAL_RATSNEST_ITEM ) { g_ColorsSettings.SetItemColor(RATSNEST_VISIBLE, YELLOW); @@ -1073,9 +1082,11 @@ void PCB_BASE_FRAME::build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, } s_CursorPos = refpos; + if( init ) { s_RatsnestMouseToPads.clear(); + if( ref == NULL ) return; @@ -1107,8 +1118,7 @@ void PCB_BASE_FRAME::build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, if( net == NULL ) // Should not occur { - DisplayError( this, - wxT( "build_ratsnest_pad() error: net not found" ) ); + DisplayError( this, wxT( "build_ratsnest_pad() error: net not found" ) ); return; } @@ -1117,6 +1127,7 @@ void PCB_BASE_FRAME::build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, for( unsigned ii = 0; ii < net->m_ListPad.size(); ii++ ) { D_PAD* pad = net->m_ListPad[ii]; + if( pad == pad_ref ) continue; @@ -1126,8 +1137,7 @@ void PCB_BASE_FRAME::build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, } /* end if Init */ if( s_RatsnestMouseToPads.size() > 1 ) - sort( s_RatsnestMouseToPads.begin(), - s_RatsnestMouseToPads.end(), sort_by_localnetlength ); + sort( s_RatsnestMouseToPads.begin(), s_RatsnestMouseToPads.end(), sort_by_localnetlength ); } @@ -1144,12 +1154,12 @@ void PCB_BASE_FRAME::trace_ratsnest_pad( wxDC* DC ) GRSetDrawMode( DC, GR_XOR ); + for( int ii = 0; ii < (int) s_RatsnestMouseToPads.size(); ii++ ) { if( ii >= g_MaxLinksShowed ) break; - GRLine( &DrawPanel->m_ClipBox, DC, s_CursorPos, - s_RatsnestMouseToPads[ii], 0, YELLOW ); + GRLine( &DrawPanel->m_ClipBox, DC, s_CursorPos, s_RatsnestMouseToPads[ii], 0, YELLOW ); } } diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index f5e3800a63..86a20a2eec 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -23,6 +23,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, int row_target, int col_target, RATSNEST_ITEM* pt_chevelu ); + static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, int, @@ -31,13 +32,15 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, int, int, int net_code ); + static void OrCell_Trace( BOARD* pcb, int col, int row, int side, int orient, int current_net_code ); -static void Place_Piste_en_Buffer( PCB_EDIT_FRAME* pcbframe, wxDC* DC ); + +static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC ); static int segm_oX, segm_oY; @@ -260,7 +263,9 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides ) break; } else + { DrawPanel->m_AbortRequest = 0; + } } EraseMsgBox(); @@ -375,15 +380,12 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, int newdist, olddir, _self; int current_net_code; int marge; - int pad_masque_layer_s; /* Mask layers belonging to the - *starting pad. */ - int pad_masque_layer_e; /* Mask layers belonging to the ending - *pad. */ - int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP]; - int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM]; - int masque_layers; /* Mask two layers for routing. */ - int tab_mask[2]; /* Enables the calculation of the mask - * layer being + int padLayerMaskStart; /* Mask layers belonging to the starting pad. */ + int padLayerMaskEnd; /* Mask layers belonging to the ending pad. */ + int topLayerMask = g_TabOneLayerMask[Route_Layer_TOP]; + int bottomLayerMask = g_TabOneLayerMask[Route_Layer_BOTTOM]; + int routeLayerMask; /* Mask two layers for routing. */ + int tab_mask[2]; /* Enables the calculation of the mask layer being * tested. (side = TOP or BOTTOM) */ int start_mask_layer = 0; wxString msg; @@ -393,8 +395,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, result = NOSUCCESS; - marge = s_Clearance + - ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 ); + marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 ); /* clear direction flags */ i = Nrows * Ncols * sizeof(DIR_CELL); @@ -404,23 +405,24 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, lastopen = lastclos = lastmove = 0; /* Set tab_masque[side] for final test of routing. */ - tab_mask[TOP] = masque_layer_TOP; - tab_mask[BOTTOM] = masque_layer_BOTTOM; + tab_mask[TOP] = topLayerMask; + tab_mask[BOTTOM] = bottomLayerMask; /* Set active layers mask. */ - masque_layers = masque_layer_TOP | masque_layer_BOTTOM; + routeLayerMask = topLayerMask | bottomLayerMask; pt_cur_ch = pt_chevelu; current_net_code = pt_chevelu->GetNet(); - pad_masque_layer_s = pt_cur_ch->m_PadStart->m_Masque_Layer; - pad_masque_layer_e = pt_cur_ch->m_PadEnd->m_Masque_Layer; + padLayerMaskStart = pt_cur_ch->m_PadStart->m_layerMask; + padLayerMaskEnd = pt_cur_ch->m_PadEnd->m_layerMask; /* First Test if routing possible ie if the pads are accessible * on the routing layers. */ - if( ( masque_layers & pad_masque_layer_s ) == 0 ) + if( ( routeLayerMask & padLayerMaskStart ) == 0 ) goto end_of_route; - if( ( masque_layers & pad_masque_layer_e ) == 0 ) + + if( ( routeLayerMask & padLayerMaskEnd ) == 0 ) goto end_of_route; /* Then test if routing possible ie if the pads are accessible @@ -438,6 +440,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, if( ( ( pt_cur_ch->m_PadStart->m_Orient / 900 ) & 1 ) != 0 ) EXCHG( dx, dy ); + if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) ) goto end_of_route; @@ -449,6 +452,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, dy = pt_cur_ch->m_PadEnd->m_Size.y / 2; px = pt_cur_ch->m_PadEnd->GetPosition().x; py = pt_cur_ch->m_PadEnd->GetPosition().y; + if( ( (pt_cur_ch->m_PadEnd->m_Orient / 900) & 1 ) != 0 ) EXCHG( dx, dy ); @@ -458,7 +462,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, /* Test the trivial case: direct connection overlay pads. */ if( ( row_source == row_target ) && ( col_source == col_target ) - && ( pad_masque_layer_e & pad_masque_layer_s & + && ( padLayerMaskEnd & padLayerMaskStart & g_TabAllCopperLayerMask[pcbframe->GetBoard()->GetCopperLayerCount() - 1] ) ) { result = TRIVIAL_SUCCESS; @@ -477,13 +481,15 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, * bits precedent) */ i = pcbframe->GetBoard()->GetPadsCount(); + for( unsigned ii = 0; ii < pcbframe->GetBoard()->GetPadsCount(); ii++ ) { + D_PAD* ptr = pcbframe->GetBoard()->m_NetInfo->GetPad( ii ); + if( ( pt_cur_ch->m_PadStart != ptr ) && ( pt_cur_ch->m_PadEnd != ptr ) ) { - Place_1_Pad_Board( pcbframe->GetBoard(), ptr, ~CURRENT_PAD, - marge, WRITE_AND_CELL ); + Place_1_Pad_Board( pcbframe->GetBoard(), ptr, ~CURRENT_PAD, marge, WRITE_AND_CELL ); } } @@ -495,16 +501,18 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, { if( abs( row_target - row_source ) > abs( col_target - col_source ) ) { - if( pad_masque_layer_s & masque_layer_TOP ) + if( padLayerMaskStart & topLayerMask ) { start_mask_layer = 2; + if( SetQueue( row_source, col_source, TOP, 0, apx_dist, row_target, col_target ) == 0 ) { return ERR_MEMORY; } } - if( pad_masque_layer_s & masque_layer_BOTTOM ) + + if( padLayerMaskStart & bottomLayerMask ) { start_mask_layer |= 1; @@ -517,16 +525,18 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, } else { - if( pad_masque_layer_s & masque_layer_BOTTOM ) + if( padLayerMaskStart & bottomLayerMask ) { start_mask_layer = 1; + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, row_target, col_target ) == 0 ) { return ERR_MEMORY; } } - if( pad_masque_layer_s & masque_layer_TOP ) + + if( padLayerMaskStart & topLayerMask ) { start_mask_layer |= 2; @@ -538,12 +548,11 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, } } } - else if( pad_masque_layer_s & masque_layer_BOTTOM ) + else if( padLayerMaskStart & bottomLayerMask ) { start_mask_layer = 1; - if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, - row_target, col_target ) == 0 ) + if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist, row_target, col_target ) == 0 ) { return ERR_MEMORY; } @@ -551,13 +560,16 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, /* search until success or we exhaust all possibilities */ GetQueue( &r, &c, &side, &d, &apx_dist ); + for( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) ) { curcell = GetCell( r, c, side ); + if( curcell & CURRENT_PAD ) curcell &= ~HOLE; + if( (r == row_target) && (c == col_target) /* success if layer OK */ - && ( tab_mask[side] & pad_masque_layer_e) ) + && ( tab_mask[side] & padLayerMaskEnd) ) { /* Remove link. */ GRSetDrawMode( DC, GR_XOR ); @@ -576,6 +588,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, { result = SUCCESS; /* Success : Route OK */ } + break; /* Routing complete. */ } @@ -600,9 +613,11 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, } _self = 0; + if( curcell & HOLE ) { _self = 5; + /* set 'present' bits */ for( i = 0; i < 8; i++ ) { @@ -622,7 +637,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, if( _self == 5 && selfok2[i].present ) continue; + newcell = GetCell( nr, nc, side ); + if( newcell & CURRENT_PAD ) newcell &= ~HOLE; @@ -634,23 +651,29 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, } /* check for traces */ else if( newcell & HOLE & ~(newmask[i]) ) + { continue; + } /* check blocking on corner neighbors */ if( delta[i][0] && delta[i][1] ) { /* check first buddy */ buddy = GetCell( r + blocking[i].r1, c + blocking[i].c1, side ); + if( buddy & CURRENT_PAD ) buddy &= ~HOLE; + if( buddy & HOLE ) continue; // if (buddy & (blocking[i].b1)) continue; /* check second buddy */ buddy = GetCell( r + blocking[i].r2, c + blocking[i].c2, side ); + if( buddy & CURRENT_PAD ) buddy &= ~HOLE; + if( buddy & HOLE ) continue; @@ -668,6 +691,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, { SetDir( nr, nc, side, ndir[i] ); SetDist( nr, nc, side, newdist ); + if( SetQueue( nr, nc, side, newdist, GetApxDist( nr, nc, row_target, col_target ), row_target, col_target ) == 0 ) @@ -689,13 +713,17 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, if( two_sides ) { olddir = GetDir( r, c, side ); + if( olddir == FROM_OTHERSIDE ) continue; /* useless move, so don't bother */ + if( curcell ) /* can't drill via if anything here */ continue; + /* check for holes or traces on other side */ if( ( newcell = GetCell( r, c, 1 - side ) ) != 0 ) continue; + /* check for nearby holes or traces on both sides */ for( skip = 0, i = 0; i < 8; i++ ) { @@ -729,8 +757,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, { SetDir( r, c, 1 - side, FROM_OTHERSIDE ); SetDist( r, c, 1 - side, newdist ); - if( SetQueue( r, c, 1 - side, newdist, apx_dist, row_target, - col_target ) == 0 ) + + if( SetQueue( r, c, 1 - side, newdist, apx_dist, row_target, col_target ) == 0 ) { return ERR_MEMORY; } @@ -899,7 +927,8 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, wxASSERT( g_CurrentTrackList.GetCount() == 0 ); - do { + do + { /* find where we came from to get here */ r2 = r1; c2 = c1; s2 = s1; x = GetDir( r1, c1, s1 ); @@ -947,8 +976,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, break; default: - DisplayError( pcbframe, - wxT( "Retrace: internal error: no way back" ) ); + DisplayError( pcbframe, wxT( "Retrace: internal error: no way back" ) ); return 0; } @@ -1001,8 +1029,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, return 0; } - OrCell_Trace( - pcbframe->GetBoard(), r1, c1, s1, p_dir, current_net_code ); + OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, p_dir, current_net_code ); } else { @@ -1017,11 +1044,10 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, || x == FROM_OTHERSIDE ) && ( ( b = bit[y - 1][x - 1] ) != 0 ) ) { - OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, b, - current_net_code ); + OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, b, current_net_code ); + if( b & HOLE ) - OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, HOLE, - current_net_code ); + OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, HOLE, current_net_code ); } else { @@ -1074,9 +1100,9 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, return 0; } - OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, p_dir, - current_net_code ); + OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, p_dir, current_net_code ); } + /* move to next cell */ r0 = r1; c0 = c1; @@ -1086,7 +1112,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC, s1 = s2; } while( !( ( r2 == row_source ) && ( c2 == col_source ) ) ); - Place_Piste_en_Buffer( pcbframe, DC ); + AddNewTrace( pcbframe, DC ); return 1; } @@ -1129,6 +1155,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackSegment->SetLayer( Route_Layer_BOTTOM ); + if( side == TOP ) g_CurrentTrackSegment->SetLayer( Route_Layer_TOP ); @@ -1145,26 +1172,20 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, g_CurrentTrackSegment->m_Start.y = segm_fY; /* Placement on the center of the pad if outside grid. */ - dx1 = g_CurrentTrackSegment->m_End.x - - g_CurrentTrackSegment->m_Start.x; - dy1 = g_CurrentTrackSegment->m_End.y - - g_CurrentTrackSegment->m_Start.y; + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; - dx0 = pt_cur_ch->m_PadEnd->GetPosition().x - - g_CurrentTrackSegment->m_Start.x; - dy0 = pt_cur_ch->m_PadEnd->GetPosition().y - - g_CurrentTrackSegment->m_Start.y; + dx0 = pt_cur_ch->m_PadEnd->GetPosition().x - g_CurrentTrackSegment->m_Start.x; + dy0 = pt_cur_ch->m_PadEnd->GetPosition().y - g_CurrentTrackSegment->m_Start.y; /* If aligned, change the origin point. */ if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) { - g_CurrentTrackSegment->m_Start = - pt_cur_ch->m_PadEnd->GetPosition(); + g_CurrentTrackSegment->m_Start = pt_cur_ch->m_PadEnd->GetPosition(); } else // Creation of a supplemental segment { - g_CurrentTrackSegment->m_Start = - pt_cur_ch->m_PadEnd->GetPosition(); + g_CurrentTrackSegment->m_Start = pt_cur_ch->m_PadEnd->GetPosition(); newTrack = g_CurrentTrackSegment->Copy(); newTrack->m_Start = g_CurrentTrackSegment->m_End; @@ -1176,22 +1197,21 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, { if( g_CurrentTrackSegment->Back() ) { - g_CurrentTrackSegment->m_Start = - g_CurrentTrackSegment->Back()->m_End; + g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->Back()->m_End; } } + g_CurrentTrackSegment->m_Width = pcb->GetCurrentTrackWidth(); if( g_CurrentTrackSegment->m_Start != g_CurrentTrackSegment->m_End ) { /* Reduce aligned segments by one. */ TRACK* oldTrack = g_CurrentTrackSegment->Back(); + if( oldTrack && oldTrack->Type() != TYPE_VIA ) { - dx1 = g_CurrentTrackSegment->m_End.x - - g_CurrentTrackSegment->m_Start.x; - dy1 = g_CurrentTrackSegment->m_End.y - - g_CurrentTrackSegment->m_Start.y; + dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; + dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; dx0 = oldTrack->m_End.x - oldTrack->m_Start.x; dy0 = oldTrack->m_End.y - oldTrack->m_Start.y; @@ -1213,7 +1233,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, * connected * Center on pads even if they are off grid. */ -static void Place_Piste_en_Buffer( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) +static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) { if( g_FirstTrackSegment == NULL ) return; @@ -1282,7 +1302,7 @@ static void Place_Piste_en_Buffer( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) pcbframe->GetBoard()->m_Track.Insert( track, insertBeforeMe ); } - Trace_Une_Piste( panel, DC, firstTrack, newCount, GR_OR ); + DrawTraces( panel, DC, firstTrack, newCount, GR_OR ); pcbframe->test_1_net_connexion( DC, netcode ); diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 2eb0c4856c..54f2a0a80f 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -81,7 +81,7 @@ void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event ) mask, this, wxFD_SAVE, - FALSE + false ); if( fullFileName == wxEmptyString ) return; @@ -245,7 +245,7 @@ static bool isRoundKeepout( D_PAD* aPad ) if( aPad->m_Drill.x >= aPad->m_Size.x ) return true; - if( (aPad->m_Masque_Layer & ALL_CU_LAYERS) == 0 ) + if( (aPad->m_layerMask & ALL_CU_LAYERS) == 0 ) return true; } @@ -283,7 +283,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) uniqifier = '['; - bool onAllCopperLayers = ( (aPad->m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS ); + bool onAllCopperLayers = ( (aPad->m_layerMask & ALL_CU_LAYERS) == ALL_CU_LAYERS ); if( onAllCopperLayers ) uniqifier += 'A'; // A for all layers diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index c7ae2acea8..ebe7380d51 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -80,7 +80,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) mask, this, wxFD_OPEN, - FALSE + false ); if( fullFileName == wxEmptyString ) diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index 324278490a..36b8643ff4 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -209,17 +209,21 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) : for( int jj = 1; jj < NB_LAYERS; jj++ ) { text->SetLabel( board->GetLayerName( jj ) ); + if( goodSize.x < text->GetSize().x ) goodSize.x = text->GetSize().x; } text->SetLabel( _( "No Change" ) ); + if( goodSize.x < text->GetSize().x ) goodSize.x = text->GetSize().x; } else + { text = new wxStaticText( this, item_ID, _( "No Change" ), wxDefaultPosition, wxDefaultSize, 0 ); + } text->SetMinSize( goodSize ); FlexColumnBoxSizer->Add( text, 1, @@ -241,8 +245,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) : // Provide a line to separate the controls which have been provided so far // from the OK and Cancel buttons (which will be provided after this line) - Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, - wxLI_HORIZONTAL ); + Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); OuterBoxSizer->Add( Line, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); // Provide a StdDialogButtonSizer to accommodate the OK and Cancel buttons; @@ -251,8 +254,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) : StdDialogButtonSizer = new wxStdDialogButtonSizer; OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 ); - Button = new wxButton( this, wxID_OK, _( "&OK" ), wxDefaultPosition, - wxDefaultSize, 0 ); + Button = new wxButton( this, wxID_OK, _( "&OK" ), wxDefaultPosition, wxDefaultSize, 0 ); Button->SetDefault(); StdDialogButtonSizer->AddButton( Button ); @@ -281,8 +283,10 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event ) ii = event.GetId() - ID_BUTTON_0; jj = New_Layer[ii]; + if( (jj < 0) || (jj > NB_LAYERS) ) jj = LAYER_NO_CHANGE; // (Defaults to "No Change".) + jj = m_Parent->SelectLayer( jj, -1, -1, true ); if( (jj < 0) || (jj > NB_LAYERS) ) @@ -303,6 +307,7 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event ) if( jj != New_Layer[ii] ) { New_Layer[ii] = jj; + if( jj >= LAYER_NO_CHANGE ) { layer_list[ii]->SetLabel( _( "No Change" ) ); @@ -356,27 +361,34 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event ) /* Change traces. */ pt_segm = GetBoard()->m_Track; + for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) { OnModify(); + if( pt_segm->Type() == TYPE_VIA ) { SEGVIA* Via = (SEGVIA*) pt_segm; + if( Via->Shape() == VIA_THROUGH ) continue; + int top_layer, bottom_layer; + Via->ReturnLayerPair( &top_layer, &bottom_layer ); - if( New_Layer[bottom_layer] >= 0 && New_Layer[bottom_layer] < - LAYER_NO_CHANGE ) + + if( New_Layer[bottom_layer] >= 0 && New_Layer[bottom_layer] < LAYER_NO_CHANGE ) bottom_layer = New_Layer[bottom_layer]; - if( New_Layer[top_layer] >= 0 - && New_Layer[top_layer] < LAYER_NO_CHANGE ) + + if( New_Layer[top_layer] >= 0 && New_Layer[top_layer] < LAYER_NO_CHANGE ) top_layer = New_Layer[top_layer]; + Via->SetLayerPair( top_layer, bottom_layer ); } else { jj = pt_segm->GetLayer(); + if( New_Layer[jj] >= 0 && New_Layer[jj] < LAYER_NO_CHANGE ) pt_segm->SetLayer( New_Layer[jj] ); } @@ -387,12 +399,14 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event ) { OnModify(); jj = pt_segm->GetLayer(); + if( New_Layer[jj] >= 0 && New_Layer[jj] < LAYER_NO_CHANGE ) pt_segm->SetLayer( New_Layer[jj] ); } /* Change other segments. */ PtStruct = GetBoard()->m_Drawings; + for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { if( PtStruct->Type() == TYPE_DRAWSEGMENT ) @@ -400,10 +414,11 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event ) OnModify(); pt_drawsegm = (DRAWSEGMENT*) PtStruct; jj = pt_drawsegm->GetLayer(); + if( New_Layer[jj] >= 0 && New_Layer[jj] < LAYER_NO_CHANGE ) pt_drawsegm->SetLayer( New_Layer[jj] ); } } - DrawPanel->Refresh( TRUE ); + DrawPanel->Refresh( true ); } diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index 62227c5aba..a2e06772b8 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -11,7 +11,7 @@ static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff ); extern int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, - TRACK** StartTrack, TRACK** EndTrack ); + TRACK** StartTrack, TRACK** EndTrack ); /** @@ -54,8 +54,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, if( aNewTrack->Type() == TYPE_VIA && ( aNewTrackSegmentsCount > 1 ) ) aNewTrack = aNewTrack->Next(); - aNewTrack = Marque_Une_Piste( GetBoard(), aNewTrack, - &aNewTrackSegmentsCount, NULL, NULL, true ); + aNewTrack = MarkTrace( GetBoard(), aNewTrack, &aNewTrackSegmentsCount, NULL, NULL, true ); wxASSERT( aNewTrack ); #if 0 && defined(DEBUG) @@ -63,11 +62,11 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, * the track */ EndNewTrack = aNewTrack; + for( ii = 1; ii < aNewTrackSegmentsCount; ii++ ) { wxASSERT( EndNewTrack->GetState( -1 ) != 0 ); - D( printf( "track %p is newly part of net %d\n", EndNewTrack, - netcode ); ) + D( printf( "track %p is newly part of net %d\n", EndNewTrack, netcode ); ) EndNewTrack = EndNewTrack->Next(); } @@ -79,8 +78,8 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, #endif - TRACK* bufStart = m_Pcb->m_Track->GetStartNetCode( netcode ); // Beginning of tracks of the net - TRACK* bufEnd = bufStart->GetEndNetCode( netcode ); // Enf of tracks of the net + TRACK* bufStart = m_Pcb->m_Track->GetStartNetCode( netcode ); // Beginning of tracks of the net + TRACK* bufEnd = bufStart->GetEndNetCode( netcode ); // Enf of tracks of the net /* Flags for cleaning the net. */ for( pt_del = bufStart; pt_del; pt_del = pt_del->Next() ) @@ -88,12 +87,12 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, //D( printf( "track %p turning off BUSY | IN_EDIT | IS_LINKED\n", pt_del ); ) D( std::cout<<"track "<SetState( BUSY | IN_EDIT | IS_LINKED, OFF ); + if( pt_del == bufEnd ) // Last segment reached break; } - if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount, - &StartTrack, &EndTrack ) == 0 ) + if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount, &StartTrack, &EndTrack ) == 0 ) return 0; if( ( StartTrack == NULL ) || ( EndTrack == NULL ) ) @@ -112,6 +111,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, /* There may be a via or a pad on the end points. */ pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, start, startmasklayer ); + if( pt_segm ) startmasklayer |= pt_segm->ReturnMaskLayer(); @@ -119,17 +119,18 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, { /* Start on pad. */ D_PAD* pt_pad = (D_PAD*)(StartTrack->start); - startmasklayer |= pt_pad->m_Masque_Layer; + startmasklayer |= pt_pad->m_layerMask; } pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, end, endmasklayer ); + if( pt_segm ) endmasklayer |= pt_segm->ReturnMaskLayer(); if( EndTrack->end && ( EndTrack->end->Type() == TYPE_PAD ) ) { D_PAD* pt_pad = (D_PAD*)(EndTrack->end); - endmasklayer |= pt_pad->m_Masque_Layer; + endmasklayer |= pt_pad->m_layerMask; } /* Mark as deleted a new track (which is not involved in the search for @@ -140,7 +141,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, /* A segment must be connected to the starting point, otherwise * it is unnecessary to analyze the other point */ - pt_segm = Fast_Locate_Piste( bufStart, bufEnd, start, startmasklayer ); + pt_segm = GetTrace( bufStart, bufEnd, start, startmasklayer ); if( pt_segm == NULL ) /* Not connected to the track starting point. */ { @@ -155,7 +156,8 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, */ for( pt_del = bufStart, nbconnect = 0; ; ) { - pt_segm = Fast_Locate_Piste( pt_del, bufEnd, end, endmasklayer ); + pt_segm = GetTrace( pt_del, bufEnd, end, endmasklayer ); + if( pt_segm == NULL ) break; @@ -167,6 +169,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, nbconnect++; } } + if( pt_del == bufEnd ) break; @@ -179,6 +182,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, for( pt_del = bufStart; pt_del; pt_del = pt_del->Next() ) { pt_del->SetState( BUSY | IS_DELETED | IN_EDIT | IS_LINKED, OFF ); + if( pt_del == bufEnd ) // Last segment reached break; } @@ -199,6 +203,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, { if( pt_del->GetState( IS_LINKED ) ) break; + if( pt_del == bufEnd ) // Last segment reached break; } @@ -206,13 +211,14 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, nbconnect--; pt_del->SetState( IS_LINKED, OFF ); - pt_del = Marque_Une_Piste( GetBoard(), pt_del, &nb_segm, NULL, NULL, true ); + pt_del = MarkTrace( GetBoard(), pt_del, &nb_segm, NULL, NULL, true ); /* Test if the marked track is redundant, i.e. if one of marked segments * is connected to the starting point of the new track. */ ii = 0; pt_segm = pt_del; + for( ; pt_segm && (ii < nb_segm); pt_segm = pt_segm->Next(), ii++ ) { if( pt_segm->GetState( BUSY ) == 0 ) @@ -222,12 +228,13 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, { /* Marked track can be erased. */ TRACK* NextS; - Trace_Une_Piste( DrawPanel, aDC, pt_del, nb_segm, - GR_XOR | GR_SURBRILL ); + + DrawTraces( DrawPanel, aDC, pt_del, nb_segm, GR_XOR | GR_SURBRILL ); for( jj = 0; jj < nb_segm; jj++, pt_del = NextS ) { NextS = pt_del->Next(); + if( aItemsListPicker ) { pt_del->UnLink(); @@ -237,19 +244,22 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, aItemsListPicker->PushItem( picker ); } else + { pt_del->DeleteStructure(); + } } /* Clean up flags. */ - for( pt_del = m_Pcb->m_Track; pt_del != NULL; - pt_del = pt_del->Next() ) + for( pt_del = m_Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() ) { if( pt_del->GetState( IN_EDIT ) ) { pt_del->SetState( IN_EDIT, OFF ); + if( aDC ) pt_del->Draw( DrawPanel, aDC, GR_OR ); } + pt_del->SetState( IN_EDIT | IS_LINKED, OFF ); } @@ -266,6 +276,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, for( pt_del = m_Pcb->m_Track; pt_del; pt_del = pt_del->Next() ) { pt_del->SetState( BUSY | IS_DELETED | IN_EDIT | IS_LINKED, OFF ); + if( pt_del == bufEnd ) // Last segment reached break; } diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 2abb3d1fdf..a505ee6692 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -26,10 +26,10 @@ extern int g_DrawDefaultLineThickness; // Default line thickness, used to draw F /* Trace the pads of a module in sketch mode. * Used to display pads when when the module visibility is set to not visible * and we want to see pad through. - * The pads must appear on the layers selected in MasqueLayer + * The pads must appear on the layers selected in LayerMask */ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module, - int ox, int oy, int MasqueLayer, int draw_mode ); + int ox, int oy, int LayerMask, int draw_mode ); void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) @@ -141,7 +141,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, int aDrawMode, const wxPoint { case TYPE_DIMENSION: case TYPE_TEXTE: - case TYPE_MIRE: + case PCB_TARGET_T: case TYPE_DRAWSEGMENT: item->Draw( aPanel, DC, aDrawMode ); break; @@ -177,6 +177,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, int aDrawMode, const wxPoint { if( module->GetLayer() == LAYER_N_FRONT ) display = false; + layerMask &= ~LAYER_FRONT; } @@ -250,10 +251,10 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* DC, int aNetCode ) /* Trace the pads of a module in sketch mode. * Used to display pads when when the module visibility is set to not visible * and we want to see pad through. - * The pads must appear on the layers selected in MasqueLayer + * The pads must appear on the layers selected in LayerMask */ void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module, - int ox, int oy, int MasqueLayer, int draw_mode ) + int ox, int oy, int LayerMask, int draw_mode ) { int tmp; PCB_BASE_FRAME* frame; @@ -266,7 +267,7 @@ void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module, /* Draw pads. */ for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) { - if( (pad->m_Masque_Layer & MasqueLayer) == 0 ) + if( (pad->m_layerMask & LayerMask) == 0 ) continue; pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) ); diff --git a/pcbnew/track.cpp b/pcbnew/track.cpp index 2e210ee8ff..b6e3f51d95 100644 --- a/pcbnew/track.cpp +++ b/pcbnew/track.cpp @@ -22,18 +22,18 @@ typedef std::vector TRACK_PTRS; // buffer of item candidates when /* Local functions */ -static void Marque_Chaine_segments( BOARD* Pcb, - wxPoint ref_pos, - int masklayer, - TRACK_PTRS* aList ); +static void ChainMarkedSegments( BOARD* Pcb, + wxPoint ref_pos, + int masklayer, + TRACK_PTRS* aList ); -TRACK* Marque_Une_Piste( BOARD* aPcb, - TRACK* aStartSegm, - int* aSegmCount, - int* aTrackLen, - int* aLengthDie, - bool aReorder ) +TRACK* MarkTrace( BOARD* aPcb, + TRACK* aStartSegm, + int* aSegmCount, + int* aTrackLen, + int* aLengthDie, + bool aReorder ) { int NbSegmBusy; @@ -55,7 +55,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, /* Set flags of the initial track segment */ aStartSegm->SetState( BUSY, ON ); - int masque_layer = aStartSegm->ReturnMaskLayer(); + int layerMask = aStartSegm->ReturnMaskLayer(); trackList.push_back( aStartSegm ); @@ -69,50 +69,42 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, if( aStartSegm->Type() == TYPE_VIA ) { TRACK* Segm1, * Segm2 = NULL, * Segm3 = NULL; - Segm1 = Fast_Locate_Piste( aPcb->m_Track, NULL, - aStartSegm->m_Start, masque_layer ); + Segm1 = GetTrace( aPcb->m_Track, NULL, aStartSegm->m_Start, layerMask ); + if( Segm1 ) { - Segm2 = Fast_Locate_Piste( Segm1->Next(), NULL, - aStartSegm->m_Start, masque_layer ); + Segm2 = GetTrace( Segm1->Next(), NULL, aStartSegm->m_Start, layerMask ); } + if( Segm2 ) { - Segm3 = Fast_Locate_Piste( Segm2->Next(), NULL, - aStartSegm->m_Start, masque_layer ); + Segm3 = GetTrace( Segm2->Next(), NULL, aStartSegm->m_Start, layerMask ); } - if( Segm3 ) // More than 2 segments are connected to this via. the - // "track" is only this via + + if( Segm3 ) // More than 2 segments are connected to this via. the track" is only this via { if( aSegmCount ) *aSegmCount = 1; + return aStartSegm; } - if( Segm1 ) // search for others segments connected to the initial - // segment start point + + if( Segm1 ) // search for others segments connected to the initial segment start point { - masque_layer = Segm1->ReturnMaskLayer(); - Marque_Chaine_segments( aPcb, aStartSegm->m_Start, masque_layer, - &trackList ); + layerMask = Segm1->ReturnMaskLayer(); + ChainMarkedSegments( aPcb, aStartSegm->m_Start, layerMask, &trackList ); } - if( Segm2 ) // search for others segments connected to the initial - // segment end point + + if( Segm2 ) // search for others segments connected to the initial segment end point { - masque_layer = Segm2->ReturnMaskLayer(); - Marque_Chaine_segments( aPcb, aStartSegm->m_Start, masque_layer, - &trackList ); + layerMask = Segm2->ReturnMaskLayer(); + ChainMarkedSegments( aPcb, aStartSegm->m_Start, layerMask, &trackList ); } } else // mark the chain using both ends of the initial segment { - Marque_Chaine_segments( aPcb, - aStartSegm->m_Start, - masque_layer, - &trackList ); - Marque_Chaine_segments( aPcb, - aStartSegm->m_End, - masque_layer, - &trackList ); + ChainMarkedSegments( aPcb, aStartSegm->m_Start, layerMask, &trackList ); + ChainMarkedSegments( aPcb, aStartSegm->m_End, layerMask, &trackList ); } // Now examine selected vias and flag them if they are on the track @@ -131,17 +123,13 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, if( via == aStartSegm ) continue; - via->SetState( BUSY, ON ); // Try to flag it. the flag will be cleared - // later if needed + via->SetState( BUSY, ON ); // Try to flag it. the flag will be cleared later if needed - masque_layer = via->ReturnMaskLayer(); + layerMask = via->ReturnMaskLayer(); - TRACK* track = Fast_Locate_Piste( aPcb->m_Track, - NULL, - via->m_Start, - masque_layer ); + TRACK* track = GetTrace( aPcb->m_Track, NULL, via->m_Start, layerMask ); - // Fast_Locate_Piste does not consider tracks flagged BUSY. + // GetTrace does not consider tracks flagged BUSY. // So if no connected track found, this via is on the current track // only: keep it if( track == NULL ) @@ -161,9 +149,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, */ int layer = track->GetLayer(); - while( ( track = Fast_Locate_Piste( track->Next(), NULL, - via->m_Start, - masque_layer ) ) != NULL ) + while( ( track = GetTrace( track->Next(), NULL, via->m_Start, layerMask ) ) != NULL ) { if( layer != track->GetLayer() ) { @@ -183,9 +169,8 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, */ NbSegmBusy = 0; TRACK* firstTrack; - for( firstTrack = aPcb->m_Track; - firstTrack; - firstTrack = firstTrack->Next() ) + + for( firstTrack = aPcb->m_Track; firstTrack; firstTrack = firstTrack->Next() ) { // Search for the first flagged BUSY segments if( firstTrack->GetState( BUSY ) ) @@ -200,6 +185,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, double full_len = 0; double lenDie = 0; + if( aReorder ) { DLIST* list = (DLIST*)firstTrack->GetList(); @@ -210,16 +196,20 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, * of the flagged list */ TRACK* next; + for( TRACK* track = firstTrack->Next(); track; track = next ) { next = track->Next(); + if( track->GetState( BUSY ) ) // move it! { NbSegmBusy++; track->UnLink(); list->Insert( track, firstTrack->Next() ); + if( aTrackLen ) full_len += track->GetLength(); + if( aLengthDie ) // Add now length die. { // In fact only 2 pads (maximum) will be taken in account: @@ -229,6 +219,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, D_PAD * pad = (D_PAD *) track->start; lenDie += (double) pad->m_LengthDie; } + if( track->GetState( END_ONPAD ) ) { D_PAD * pad = (D_PAD *) track->end; @@ -241,6 +232,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, else if( aTrackLen ) { NbSegmBusy = 0; + for( TRACK* track = firstTrack; track; track = track->Next() ) { if( track->GetState( BUSY ) ) @@ -248,6 +240,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, NbSegmBusy++; track->SetState( BUSY, OFF ); full_len += track->GetLength(); + // Add now length die. // In fact only 2 pads (maximum) will be taken in account: // that are on each end of the track, if any @@ -256,6 +249,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, D_PAD * pad = (D_PAD *) track->start; lenDie += (double) pad->m_LengthDie; } + if( track->GetState( END_ONPAD ) ) { D_PAD * pad = (D_PAD *) track->end; @@ -267,8 +261,10 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, if( aTrackLen ) *aTrackLen = wxRound( full_len ); + if( aLengthDie ) *aLengthDie = wxRound( lenDie ); + if( aSegmCount ) *aSegmCount = NbSegmBusy; @@ -277,7 +273,7 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, /** - * Function used by Marque_Une_Piste + * Function used by MarkTrace * - Set the BUSY flag of connected segments, the first search point is * ref_pos on layers allowed in masque_layer * - Put segments fount in aList @@ -289,10 +285,10 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, * starting point is on a via) * @param aList = the track list to fill with points of segments flagged */ -static void Marque_Chaine_segments( BOARD* aPcb, - wxPoint aRef_pos, - int aLayerMask, - TRACK_PTRS* aList ) +static void ChainMarkedSegments( BOARD* aPcb, + wxPoint aRef_pos, + int aLayerMask, + TRACK_PTRS* aList ) { TRACK* pt_segm, // The current segment being analyzed. * pt_via, // The via identified, eventually destroy @@ -332,6 +328,7 @@ static void Marque_Chaine_segments( BOARD* aPcb, * and we do not know if this via is on the track or finish the track */ pt_via = Fast_Locate_Via( aPcb->m_Track, NULL, aRef_pos, aLayerMask ); + if( pt_via ) { aLayerMask = pt_via->ReturnMaskLayer(); @@ -346,11 +343,10 @@ static void Marque_Chaine_segments( BOARD* aPcb, */ pt_segm = aPcb->m_Track; SegmentCandidate = NULL; NbSegm = 0; - while( ( pt_segm = Fast_Locate_Piste( pt_segm, NULL, - aRef_pos, aLayerMask ) ) != NULL ) + + while( ( pt_segm = GetTrace( pt_segm, NULL, aRef_pos, aLayerMask ) ) != NULL ) { - if( pt_segm->GetState( BUSY ) ) // already found and selected: skip - // it + if( pt_segm->GetState( BUSY ) ) // already found and selected: skip it { pt_segm = pt_segm->Next(); continue; @@ -363,21 +359,19 @@ static void Marque_Chaine_segments( BOARD* aPcb, } NbSegm++; - if( NbSegm == 1 ) /* First time we found a connected item: pt_segm - * is candidate */ + + if( NbSegm == 1 ) /* First time we found a connected item: pt_segm is candidate */ { SegmentCandidate = pt_segm; pt_segm = pt_segm->Next(); } - else /* More than 1 segment connected -> this location is an end of - * the track */ + else /* More than 1 segment connected -> this location is an end of the track */ { return; } } - if( SegmentCandidate ) // A candidate is found: flag it an push it - // in list + if( SegmentCandidate ) // A candidate is found: flag it an push it in list { /* Initialize parameters to search items connected to this * candidate: @@ -401,7 +395,9 @@ static void Marque_Chaine_segments( BOARD* aPcb, SegmentCandidate->SetState( BUSY, ON ); } else + { return; + } } } @@ -416,11 +412,10 @@ static void Marque_Chaine_segments( BOARD* aPcb, * (*EndTrack)->m_End coordinate is the end of the track * Segments connected must be consecutive in list */ -int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, - TRACK** StartTrack, TRACK** EndTrack ) +int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** EndTrack ) { TRACK* Track, * via, * segm, * TrackListEnd; - int NbEnds, masque_layer, ii, ok = 0; + int NbEnds, layerMask, ii, ok = 0; if( NbSegm <= 1 ) { @@ -431,6 +426,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, /* Calculation of the limit analysis. */ *StartTrack = *EndTrack = NULL; TrackListEnd = Track = RefTrack; ii = 0; + for( ; ( Track != NULL ) && ( ii < NbSegm ); ii++, Track = Track->Next() ) { TrackListEnd = Track; @@ -439,24 +435,25 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, /* Calculate the extremes. */ NbEnds = 0; Track = RefTrack; ii = 0; + for( ; ( Track != NULL ) && ( ii < NbSegm ); ii++, Track = Track->Next() ) { if( Track->Type() == TYPE_VIA ) continue; - masque_layer = Track->ReturnMaskLayer(); - via = Fast_Locate_Via( RefTrack, TrackListEnd, - Track->m_Start, masque_layer ); + layerMask = Track->ReturnMaskLayer(); + via = Fast_Locate_Via( RefTrack, TrackListEnd, Track->m_Start, layerMask ); + if( via ) { - masque_layer |= via->ReturnMaskLayer(); + layerMask |= via->ReturnMaskLayer(); via->SetState( BUSY, ON ); } Track->SetState( BUSY, ON ); - segm = Fast_Locate_Piste( RefTrack, TrackListEnd, - Track->m_Start, masque_layer ); + segm = GetTrace( RefTrack, TrackListEnd, Track->m_Start, layerMask ); Track->SetState( BUSY, OFF ); + if( via ) via->SetState( BUSY, OFF ); @@ -480,6 +477,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, if( BeginPad ) Track->SetState( END_ONPAD, ON ); + if( EndPad ) Track->SetState( BEGIN_ONPAD, ON ); @@ -490,21 +488,22 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, } } - masque_layer = Track->ReturnMaskLayer(); - via = Fast_Locate_Via( RefTrack, TrackListEnd, - Track->m_End, masque_layer ); + layerMask = Track->ReturnMaskLayer(); + via = Fast_Locate_Via( RefTrack, TrackListEnd, Track->m_End, layerMask ); + if( via ) { - masque_layer |= via->ReturnMaskLayer(); + layerMask |= via->ReturnMaskLayer(); via->SetState( BUSY, ON ); } Track->SetState( BUSY, ON ); - segm = Fast_Locate_Piste( RefTrack, TrackListEnd, - Track->m_End, masque_layer ); + segm = GetTrace( RefTrack, TrackListEnd, Track->m_End, layerMask ); Track->SetState( BUSY, OFF ); + if( via ) via->SetState( BUSY, OFF ); + if( segm == NULL ) { switch( NbEnds ) @@ -522,6 +521,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, if( BeginPad ) Track->SetState( END_ONPAD, ON ); + if( EndPad ) Track->SetState( BEGIN_ONPAD, ON ); @@ -539,4 +539,3 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, return ok; } - diff --git a/pcbnew/trpiste.cpp b/pcbnew/trpiste.cpp index d616641b82..fcb2b4c2e1 100644 --- a/pcbnew/trpiste.cpp +++ b/pcbnew/trpiste.cpp @@ -12,22 +12,21 @@ #include "protos.h" -/* Trace consecutive segments in memory. +/** + * Draw a list of trace segmants. * * Parameters: - * Pt_start_piste = first segment in the list + * Pt_start_trace = first segment in the list * Nbsegment = number of segments traced * Draw_mode = mode (GR_XOR, GR_OR ..) * CAUTION: * The starting point of a track following MUST exist: may be * then put a 0 before calling a routine if the track is the last drawn. */ -void Trace_Une_Piste( EDA_DRAW_PANEL* panel, wxDC* DC, TRACK* aTrackList, - int nbsegment, int draw_mode ) +void DrawTraces( EDA_DRAW_PANEL* panel, wxDC* DC, TRACK* aTrackList, int nbsegment, int draw_mode ) { // preserve the start of the list for debugging. - for( TRACK* track = aTrackList; nbsegment > 0 && track; - nbsegment--, track = track->Next() ) + for( TRACK* track = aTrackList; nbsegment > 0 && track; nbsegment--, track = track->Next() ) { track->Draw( panel, DC, draw_mode ); } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 17bef9087b..36cd92e7a7 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -40,9 +40,6 @@ static PICKED_ITEMS_LIST _AuxiliaryList; // a picked list to store z #include "dialog_copper_zones.h" -/**********************************************************************************/ -void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container ) -/**********************************************************************************/ /** * Function Add_Similar_Zone @@ -51,6 +48,7 @@ void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container * @param DC = current Device Context * @param zone_container = parent zone outline */ +void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container ) { if ( zone_container == NULL ) return; @@ -67,19 +65,17 @@ void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container } -/**********************************************************************************/ -void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container ) -/**********************************************************************************/ - /** * Function Add_Zone_Cutout * Add a cutout zone to a given zone outline * @param DC = current Device Context * @param zone_container = parent zone outline */ +void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container ) { if ( zone_container == NULL ) return; + s_AddCutoutToCurrentZone = true; s_CurrentZone = zone_container; @@ -93,15 +89,12 @@ void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container ) } -/*******************************************************/ -int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC ) -/*******************************************************/ - /** Used **only** while creating a new zone outline * Remove and delete the current outline segment in progress * @return 0 if no corner in list, or corner number * if no corner in list, close the outline creation */ +int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC ) { ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour; @@ -127,18 +120,16 @@ int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC ) zone->RemoveAllContours(); zone->m_Flags = 0; } + return zone->GetNumCorners(); } -/*************************************************************************/ -static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC ) -/*************************************************************************/ - /** * Function Abort_Zone_Create_Outline * cancels the Begin_Zone command if at least one EDGE_ZONE was created. */ +static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC ) { PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent(); ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour; @@ -157,16 +148,13 @@ static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC ) } -/*******************************************************************************************************/ -void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container, - int corner_id, bool IsNewCorner ) -/*******************************************************************************************************/ - /** * Function Start_Move_Zone_Corner * Initialise parametres to move an existing corner of a zone. * if IsNewCorner is true, the Abort_Zone_Move_Corner_Or_Outlines will remove this corner, if called */ +void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container, + int corner_id, bool IsNewCorner ) { if( zone_container->IsOnCopperLayer() ) /* Show the Net */ { @@ -177,6 +165,7 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); GetBoard()->SetHightLightNet( zone_container->GetNet() ); + if( DC ) High_Light( DC ); } @@ -193,7 +182,9 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont _AuxiliaryList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems(); - SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), zone_container->GetLayer() ); + SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), + zone_container->GetLayer() ); + if ( IsNewCorner ) zone_container->m_Poly->InsertCorner(corner_id-1, cx, cy ); @@ -207,40 +198,34 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont } -/**************************************************************************************/ -void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC, - ZONE_CONTAINER* zone_container, - int corner_id ) -/**************************************************************************************/ - /** * Function Start_Move_Zone_Drag_Outline_Edge * Prepares a drag edge for an existing zone outline, */ +void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC, + ZONE_CONTAINER* zone_container, + int corner_id ) { zone_container->m_Flags = IS_DRAGGED; zone_container->m_CornerSelection = corner_id; DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, - Abort_Zone_Move_Corner_Or_Outlines ); + Abort_Zone_Move_Corner_Or_Outlines ); s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; s_PickedList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems(); - SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), - zone_container->GetLayer() ); + SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), + zone_container->GetLayer() ); } -/*******************************************************************************************************/ -void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ) -/*******************************************************************************************************/ - /** * Function Start_Move_Zone_Outlines * Initialise parametres to move an existing zone outlines. */ +void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ) { /* Show the Net */ if( zone_container->IsOnCopperLayer() ) /* Show the Net */ @@ -257,11 +242,12 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_co s_PickedList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems(); - SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), zone_container->GetLayer() ); + SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), + zone_container->GetLayer() ); zone_container->m_Flags = IS_MOVED; DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, - Abort_Zone_Move_Corner_Or_Outlines ); + Abort_Zone_Move_Corner_Or_Outlines ); s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); s_CornerIsNew = false; s_AddCutoutToCurrentZone = false; @@ -269,16 +255,13 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_co } -/*************************************************************************************************/ -void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ) -/*************************************************************************************************/ - /** * Function End_Move_Zone_Corner_Or_Outlines * Terminates a move corner in a zone outline, or a move zone outlines * @param DC = current Device Context (can be NULL) * @param zone_container: the given zone */ +void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ) { zone_container->m_Flags = 0; DrawPanel->SetMouseCapture( NULL, NULL ); @@ -299,6 +282,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists + if( ii < 0 ) zone_container = NULL; // was removed by combining zones @@ -307,6 +291,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true ); + if( error_count ) { DisplayError( this, _( "Area: DRC outline error" ) ); @@ -314,10 +299,6 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* } -/*************************************************************************************/ -void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container ) -/*************************************************************************************/ - /** * Function Remove_Zone_Corner * Remove the currently selected corner in a zone outline @@ -326,17 +307,20 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe * @param zone_container = the zone that contains the selected corner * the member .m_CornerSelection is used as selected corner */ +void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container ) { OnModify(); if( zone_container->m_Poly->GetNumCorners() <= 3 ) { DrawPanel->RefreshDrawingRect( zone_container->GetBoundingBox() ); + if( DC ) { // Remove the full zone because this is no more an area zone_container->UnFill(); zone_container->DrawFilledArea( DrawPanel, DC, GR_XOR ); } + GetBoard()->Delete( zone_container ); return; } @@ -351,11 +335,13 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe _AuxiliaryList.ClearListAndDeleteItems(); s_PickedList. ClearListAndDeleteItems(); - SaveCopyOfZones(s_PickedList, GetBoard(), zone_container->GetNet(), zone_container->GetLayer() ); + SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), + zone_container->GetLayer() ); zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection ); // modify zones outlines according to the new zone_container shape GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_Verbose ); + if( DC ) { GetBoard()->RedrawAreasOutlines( DrawPanel, DC, GR_OR, layer ); @@ -367,9 +353,12 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists + if( ii < 0 ) - zone_container = NULL; // zone_container does not exist anymaore, after combining zones + zone_container = NULL; // zone_container does not exist anymaore, after combining zones + int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true ); + if( error_count ) { DisplayError( this, _( "Area: DRC outline error" ) ); @@ -377,14 +366,11 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe } -/**************************************************************************/ -void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC ) -/**************************************************************************/ - /** * Function Abort_Zone_Move_Corner_Or_Outlines * cancels the Begin_Zone state if at least one EDGE_ZONE has been created. */ +void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC ) { PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent(); ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem(); @@ -456,16 +442,14 @@ void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* s_CursorLastPosition = pos; } else + { zone->m_Poly->MoveCorner( zone->m_CornerSelection, pos.x, pos.y ); + } zone->Draw( aPanel, aDC, GR_XOR ); } -/*************************************************/ -int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) -/*************************************************/ - /** * Function Begin_Zone * either initializes the first segment of a new zone, or adds an @@ -475,9 +459,11 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) * created from a similar zone (s_CurrentZone is used): parameters are copied from s_CurrentZone * created as a cutout (an hole) inside s_CurrentZone */ +int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) { // verify if s_CurrentZone exists (could be deleted since last selection) : int ii; + for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ ) { if( s_CurrentZone == GetBoard()->GetArea( ii ) ) @@ -495,7 +481,8 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) GetBoard()->m_CurrentZoneContour = new ZONE_CONTAINER( GetBoard() ); ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour; - if( zone->GetNumCorners() == 0 ) /* Start a new contour: init zone params (net, layer ...) */ + + if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...) { if( s_CurrentZone == NULL ) // A new outline is created, from scratch { @@ -504,7 +491,8 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) zone->SetLayer( getActiveLayer() ); // Prompt user for parameters: - DrawPanel->m_IgnoreMouseEvents = TRUE; + DrawPanel->m_IgnoreMouseEvents = true; + if( zone->IsOnCopperLayer() ) { // Put a zone on a copper layer if ( GetBoard()->GetHightLightNetCode() > 0 ) @@ -516,9 +504,9 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) } wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, - &g_Zone_Default_Setting.m_ThermalReliefGapValue ); + &g_Zone_Default_Setting.m_ThermalReliefGapValue ); wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, - &g_Zone_Default_Setting.m_ThermalReliefCopperBridgeValue ); + &g_Zone_Default_Setting.m_ThermalReliefCopperBridgeValue ); g_Zone_Default_Setting.m_CurrentZone_Layer = zone->GetLayer(); DIALOG_COPPER_ZONE* frame = new DIALOG_COPPER_ZONE( this, &g_Zone_Default_Setting ); @@ -530,8 +518,9 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) diag = InstallDialogNonCopperZonesEditor( zone ); g_Zone_Default_Setting.m_NetcodeSelection = 0; // No net for non copper zones } + DrawPanel->MoveCursorToCrossHair(); - DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->m_IgnoreMouseEvents = false; if( diag == ZONE_ABORT ) return 0; @@ -539,8 +528,8 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) // Switch active layer to the selectec zonz layer setActiveLayer( g_Zone_Default_Setting.m_CurrentZone_Layer ); } - else // Start a new contour: init zone params (net and layer) from an existing zone (add cutout or similar zone) - { + else // Start a new contour: init zone params (net and layer) from an existing + { // zone (add cutout or similar zone) g_Zone_Default_Setting.m_CurrentZone_Layer = s_CurrentZone->GetLayer(); setActiveLayer( s_CurrentZone->GetLayer() ); g_Zone_Default_Setting.ImportSetting( * s_CurrentZone); @@ -551,6 +540,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) { if( s_CurrentZone ) g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet(); + if( GetBoard()->IsHightLightNetON() ) { High_Light( DC ); // Remove old hightlight selection @@ -559,6 +549,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) GetBoard()->SetHightLightNet( g_Zone_Default_Setting.m_NetcodeSelection ); High_Light( DC ); } + if( !s_AddCutoutToCurrentZone ) s_CurrentZone = NULL; // the zone is used only once ("add similar zone" command) } @@ -574,6 +565,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) GetScreen()->GetCrossHairPosition().y, zone->GetHatchStyle() ); zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); + if( Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() ) { zone->m_Flags = 0; @@ -584,25 +576,21 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) // PCB_EDIT_FRAME::SetCurItem() calls DisplayInfo(). GetScreen()->SetCurItem( NULL ); DisplayError( this, - _( "DRC error: this start point is inside or too close an other area" ) ); + _( "DRC error: this start point is inside or too close an other area" ) ); return 0; } SetCurItem( zone ); - DrawPanel->SetMouseCapture( Show_New_Edge_While_Move_Mouse, - Abort_Zone_Create_Outline ); + DrawPanel->SetMouseCapture( Show_New_Edge_While_Move_Mouse, Abort_Zone_Create_Outline ); } - // edge in progress: - else + else // edge in progress: { ii = zone->GetNumCorners() - 1; /* edge in progress : the current corner coordinate was set by Show_New_Edge_While_Move_Mouse */ if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) ) { - if( !Drc_On || !zone->IsOnCopperLayer() - || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) - ) + if( !Drc_On || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) ) { // Ok, we can add a new corner zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); SetCurItem( zone ); // calls DisplayInfo(). @@ -614,10 +602,6 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) } -/*********************************************/ -bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) -/*********************************************/ - /** * Function End_Zone * Terminates a zone outline creation @@ -626,6 +610,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) * @return true if Ok, false if DRC error * if ok, put it in the main list GetBoard()->m_ZoneDescriptorList (a vector) */ +bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) { ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour; @@ -645,10 +630,11 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) { if( Drc_On && m_drc->Drc( zone, icorner - 1 ) == BAD_DRC ) // we can't validate last edge return false; + if( Drc_On && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge { DisplayError( this, - _( "DRC error: closing this area creates a drc error with an other area" ) ); + _( "DRC error: closing this area creates a drc error with an other area" ) ); DrawPanel->MoveCursorToCrossHair(); return false; } @@ -705,10 +691,12 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) GetBoard()->RedrawFilledAreas( DrawPanel, DC, GR_OR, layer ); int ii = GetBoard()->GetAreaIndex( zone ); // test if zone_container exists + if( ii < 0 ) zone = NULL; // was removed by combining zones int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone, true ); + if( error_count ) { DisplayError( this, _( "Area: DRC outline error" ) ); @@ -750,7 +738,7 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, { // calculate the new position as allowed wxPoint StartPoint = zone->GetCornerPosition( icorner - 1 ); - Calcule_Coord_Extremite_45( c_pos, StartPoint.x, StartPoint.y, &c_pos.x, &c_pos.y ); + CalculateSegmentEndPoint( c_pos, StartPoint.x, StartPoint.y, &c_pos.x, &c_pos.y ); } zone->SetCornerPosition( icorner, c_pos ); @@ -759,17 +747,14 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, } -/***********************************************************************************/ -void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container ) -/***********************************************************************************/ - /** * Function Edit_Zone_Params * Edit params (layer, clearance, ...) for a zone outline */ +void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container ) { int diag; - DrawPanel->m_IgnoreMouseEvents = TRUE; + DrawPanel->m_IgnoreMouseEvents = true; /* Save initial zones configuration, for undo/redo, before adding new zone * note the net name and the layer can be changed, so we must save all zones @@ -786,10 +771,12 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container frame->Destroy(); } else // edit a zone on a non copper layer (technical layer) + { diag = InstallDialogNonCopperZonesEditor( zone_container ); + } DrawPanel->MoveCursorToCrossHair(); - DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->m_IgnoreMouseEvents = false; if( diag == ZONE_ABORT ) { @@ -797,6 +784,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container s_PickedList.ClearListAndDeleteItems(); return; } + if( diag == ZONE_EXPORT_VALUES ) { UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() ); @@ -814,6 +802,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container g_Zone_Default_Setting.ExportSetting( *zone_container); NETINFO_ITEM* net = GetBoard()->FindNet( g_Zone_Default_Setting.m_NetcodeSelection ); + if( net ) // net == NULL should not occur zone_container->m_Netname = net->GetNetname(); @@ -831,10 +820,6 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container } -/************************************************************************************/ -void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container ) -/************************************************************************************/ - /** * Function Delete_Zone_Contour * Remove the zone which include the segment aZone, or the zone which have the given time stamp. @@ -845,6 +830,7 @@ void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_contain * if the outline is the main outline, all the zone_container is removed (deleted) * otherwise, the hole is deleted */ +void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container ) { int ncont = zone_container->m_Poly->GetContour( zone_container->m_CornerSelection ); @@ -871,4 +857,3 @@ void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_contain OnModify(); } - diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 8e42e28bbb..64c0116d5c 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -37,7 +37,8 @@ /** * Function Delete_OldZone_Fill (obsolete) * Used for compatibility with old boards - * Remove the zone filling which include the segment aZone, or the zone which have the given time stamp. + * Remove the zone filling which include the segment aZone, or the zone which have the + * given time stamp. * A zone is a group of segments which have the same TimeStamp * @param aZone = zone segment within the zone to delete. Can be NULL * @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL @@ -53,12 +54,14 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp ) TimeStamp = aZone->m_TimeStamp; // Save reference time stamp (aZone will be deleted) SEGZONE* next; + for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = next ) { next = zone->Next(); + if( zone->m_TimeStamp == TimeStamp ) { - modify = TRUE; + modify = true; /* remove item from linked list and free memory */ zone->DeleteStructure(); } @@ -116,7 +119,6 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* zone_container, bool verbose ) } -int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) /** * Function Fill_All_Zones * Fill all zones on the board @@ -124,6 +126,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) * @param verbose = true to show error messages * @return error level (0 = no error) */ +int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) { int errorLevel = 0; int areaCount = GetBoard()->GetAreaCount(); @@ -133,8 +136,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) // Create a message with a long net name, and build a wxProgressDialog // with a correct size to show this long net name - msg.Printf( FORMAT_STRING, - 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) ); + msg.Printf( FORMAT_STRING, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) ); wxProgressDialog progressDialog( _( "Fill All Zones" ), msg, areaCount+2, this, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT ); @@ -145,11 +147,11 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) GetBoard()->m_Zone.DeleteAll(); int ii; + for( ii = 0; ii < areaCount; ii++ ) { ZONE_CONTAINER* zoneContainer = GetBoard()->GetArea( ii ); - msg.Printf( FORMAT_STRING, - ii+1, areaCount, GetChars( zoneContainer->GetNetName() ) ); + msg.Printf( FORMAT_STRING, ii+1, areaCount, GetChars( zoneContainer->GetNetName() ) ); if( !progressDialog.Update( ii+1, msg ) ) break; @@ -159,6 +161,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) if( errorLevel && !verbose ) break; } + progressDialog.Update( ii+2, _( "Updating ratsnest..." ) ); test_connexions( NULL ); @@ -168,5 +171,3 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) return errorLevel; } - - diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index 8fbbdc3bf8..f639aeda3f 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -9,9 +9,11 @@ * calculated from these items shapes and the clearance area * * Important note: - * Because filled areas must have a minimum thickness to match with Design rule, they are draw in 2 step: + * Because filled areas must have a minimum thickness to match with Design rule, they are + * draw in 2 step: * 1 - filled polygons are drawn - * 2 - polygon outlines are drawn with a "minimum thickness width" ( or with a minimum thickness pen ) + * 2 - polygon outlines are drawn with a "minimum thickness width" ( or with a minimum + * thickness pen ) * So outlines of filled polygons are calculated with the constraint they match with clearance, * taking in account outlines have thickness * This ensures: @@ -38,8 +40,10 @@ extern void BuildUnconnectedThermalStubsPolygonList( std::vector& aCorn BOARD* aPcb, ZONE_CONTAINER* aZone, double aArcCorrection, int aRoundPadThermalRotation); + extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb, ZONE_CONTAINER* aZone_container ); + extern void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, D_PAD& aPad, int aThermalGap, @@ -55,6 +59,7 @@ static void AddPolygonCornersToKPolygonList( std::vector & aCornersBuff static int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone, KPolygonSet& aKPolyList ); + static int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone, KPolygonSet& aKPolyList ); @@ -86,9 +91,10 @@ double s_Correction; /* mult coeff used to enlarge rounded and oval pads (an * 1 - Creates the main outline (zone outline) using a correction to shrink the resulting area * with m_ZoneMinThickness/2 value. * The result is areas with a margin of m_ZoneMinThickness/2 - * When drawing outline with segments having a thickness of m_ZoneMinThickness, the outlines will - * match exactly the initial outlines - * 3 - Add all non filled areas (pads, tracks) in group B with a clearance of m_Clearance + m_ZoneMinThickness/2 + * When drawing outline with segments having a thickness of m_ZoneMinThickness, the + * outlines will match exactly the initial outlines + * 3 - Add all non filled areas (pads, tracks) in group B with a clearance of m_Clearance + + * m_ZoneMinThickness/2 * in a buffer * - If Thermal shapes are wanted, add non filled area, in order to create these thermal shapes * 4 - calculates the polygon A - B @@ -96,9 +102,9 @@ double s_Correction; /* mult coeff used to enlarge rounded and oval pads (an * This zone contains pads with the same net. * 6 - Remove insulated copper islands * 7 - If Thermal shapes are wanted, remove unconnected stubs in thermal shapes: - * creates a buffer of polygons corresponding to stubs to remove - * sub them to the filled areas. - * Remove new insulated copper islands + * creates a buffer of polygons corresponding to stubs to remove + * sub them to the filled areas. + * Remove new insulated copper islands */ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { @@ -134,8 +140,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) * the main polygon is stored in polyset_zone_solid_areas */ - CopyPolygonsFromFilledPolysListTotKPolygonList( this, - polyset_zone_solid_areas ); + CopyPolygonsFromFilledPolysListTotKPolygonList( this, polyset_zone_solid_areas ); polyset_zone_solid_areas -= margin; if( polyset_zone_solid_areas.size() == 0 ) @@ -189,17 +194,21 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { for( D_PAD* pad = module->m_Pads; pad != NULL; pad = nextpad ) { - nextpad = pad->Next(); // pad pointer can be modified by next code, so calculate the next pad here + nextpad = pad->Next(); // pad pointer can be modified by next code, so + // calculate the next pad here + if( !pad->IsOnLayer( GetLayer() ) ) { /* Test for pads that are on top or bottom only and have a hole. - * There are curious pads but they can be used for some components that are inside the - * board (in fact inside the hole. Some photo diodes and Leds are like this) + * There are curious pads but they can be used for some components that are + * inside the board (in fact inside the hole. Some photo diodes and Leds are + * like this) */ if( (pad->m_Drill.x == 0) && (pad->m_Drill.y == 0) ) continue; - // Use a dummy pad to calculate a hole shape that have the same dimension as the pad hole + // Use a dummy pad to calculate a hole shape that have the same dimension as + // the pad hole dummypad.m_Size = pad->m_Drill; dummypad.m_Orient = pad->m_Orient; dummypad.m_PadShape = pad->m_DrillShape; @@ -211,6 +220,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { item_clearance = pad->GetClearance() + margin; item_boundingbox = pad->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { int clearance = MAX( zone_clearance, item_clearance ); @@ -219,10 +229,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) s_CircleToSegmentsCount, s_Correction ); } + continue; } int gap = zone_clearance; + if( (m_PadOption == PAD_NOT_IN_ZONE) || (GetNet() == 0) || pad->m_PadShape == PAD_TRAPEZOID ) @@ -230,6 +242,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) // and i think it is good that shapes are not changed by thermal pads or others { item_boundingbox = pad->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { pad->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract, @@ -248,11 +261,13 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { if( !track->IsOnLayer( GetLayer() ) ) continue; + if( track->GetNet() == GetNet() && (GetNet() != 0) ) continue; item_clearance = track->GetClearance() + margin; item_boundingbox = track->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { int clearance = MAX( zone_clearance, item_clearance ); @@ -273,9 +288,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { if( !item->IsOnLayer( GetLayer() ) ) continue; + if( item->Type() != TYPE_EDGE_MODULE ) continue; + item_boundingbox = item->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { ( (EDGE_MODULE*) item )->TransformShapeWithClearanceToPolygon( @@ -301,7 +319,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) s_Correction ); break; - case TYPE_TEXTE: ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract, @@ -329,6 +346,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) continue; item_boundingbox = pad->GetBoundingBox(); item_boundingbox.Inflate( m_ThermalReliefGapValue, m_ThermalReliefGapValue ); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { CreateThermalReliefPadPolygon( cornerBufferPolysToSubstract, @@ -348,8 +366,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) if( cornerBufferPolysToSubstract.size() > 0 ) { KPolygonSet polyset_holes; - AddPolygonCornersToKPolygonList( cornerBufferPolysToSubstract, - polyset_holes ); + AddPolygonCornersToKPolygonList( cornerBufferPolysToSubstract, polyset_holes ); // Remove holes from initial area.: polyset_zone_solid_areas -= polyset_holes; } @@ -362,12 +379,13 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) if( GetNet() > 0 ) Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb ); -// Now we remove all unused thermal stubs. + // Now we remove all unused thermal stubs. if( m_PadOption == THERMAL_PAD ) { cornerBufferPolysToSubstract.clear(); // Test thermal stubs connections and add polygons to remove unconnected stubs. - BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, s_Correction, s_thermalRot ); + BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, + s_Correction, s_thermalRot ); /* remove copper areas */ if( cornerBufferPolysToSubstract.size() ) @@ -379,6 +397,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) /* put these areas in m_FilledPolysList */ m_FilledPolysList.clear(); CopyPolygonsFromKPolygonListToFilledPolysList( this, polyset_zone_solid_areas ); + if( GetNet() > 0 ) Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb ); } @@ -387,15 +406,15 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) cornerBufferPolysToSubstract.clear(); } -void AddPolygonCornersToKPolygonList( std::vector & - aCornersBuffer, - KPolygonSet& aKPolyList ) +void AddPolygonCornersToKPolygonList( std::vector & aCornersBuffer, + KPolygonSet& aKPolyList ) { unsigned ii; std::vector cornerslist; int polycount = 0; + for( unsigned ii = 0; ii < aCornersBuffer.size(); ii++ ) { if( aCornersBuffer[ii].end_contour ) @@ -408,10 +427,11 @@ void AddPolygonCornersToKPolygonList( std::vector & { KPolygon poly; cornerslist.clear(); + for( ii = icnt; ii < aCornersBuffer.size(); ii++ ) { - cornerslist.push_back( KPolyPoint( aCornersBuffer[ii].x, - aCornersBuffer[ii].y ) ); + cornerslist.push_back( KPolyPoint( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) ); + if( aCornersBuffer[ii].end_contour ) break; } @@ -423,9 +443,8 @@ void AddPolygonCornersToKPolygonList( std::vector & } -int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* - aZone, KPolygonSet& - aKPolyList ) +int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone, + KPolygonSet& aKPolyList ) { int count = 0; @@ -433,6 +452,7 @@ int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* { KPolygon& poly = aKPolyList[ii]; CPolyPt corner( 0, 0, false ); + for( unsigned jj = 0; jj < poly.size(); jj++ ) { KPolyPoint point = *(poly.begin() + jj); @@ -456,9 +476,8 @@ int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* } -int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* - aZone, KPolygonSet& - aKPolyList ) +int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone, + KPolygonSet& aKPolyList ) { unsigned corners_count = aZone->m_FilledPolysList.size(); int count = 0; @@ -469,12 +488,14 @@ int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* for( unsigned ii = 0; ii < corners_count; ii++ ) { CPolyPt* corner = &aZone->m_FilledPolysList[ic]; + if( corner->end_contour ) polycount++; } aKPolyList.reserve( polycount ); std::vector cornerslist; + while( ic < corners_count ) { cornerslist.clear(); @@ -485,6 +506,7 @@ int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* CPolyPt* corner = &aZone->m_FilledPolysList[ic]; cornerslist.push_back( KPolyPoint( corner->x, corner->y ) ); count++; + if( corner->end_contour ) { ic++; diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp index 33e4104a71..35bf1c98b5 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Kbool.cpp @@ -9,9 +9,11 @@ * calculated from these items shapes and the clearance area * * Important note: - * Because filled areas must have a minimum thickness to match with Design rule, they are draw in 2 step: + * Because filled areas must have a minimum thickness to match with Design rule, they are + * draw in 2 step: * 1 - filled polygons are drawn - * 2 - polygon outlines are drawn with a "minimum thickness width" ( or with a minimum thickness pen ) + * 2 - polygon outlines are drawn with a "minimum thickness width" ( or with a minimum + * thickness pen ) * So outlines of filled polygons are calculated with the constraint they match with clearance, * taking in account outlines have thickness * This ensures: @@ -31,7 +33,8 @@ #include "PolyLine.h" -// Kbool 1.9 and before had sometimes problemes when calculating thermal shapes as polygons (this is the best solution) +// Kbool 1.9 and before had sometimes problemes when calculating thermal shapes as polygons +// (this is the best solution) // Kbool 2.0 has solved some problems, but not all // Kbool 2.1 has solved some others problems, but not all @@ -47,8 +50,10 @@ extern void BuildUnconnectedThermalStubsPolygonList( std::vector& aCorn BOARD* aPcb, ZONE_CONTAINER* aZone, double aArcCorrection, int aRoundPadThermalRotation); + extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb, ZONE_CONTAINER* aZone_container ); + extern void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, D_PAD& aPad, int aThermalGap, @@ -90,23 +95,27 @@ double s_Correction; /* mult coeff used to enlarge rounded and oval pads (an * BuildFilledPolysListData() call this function just after creating the * filled copper area polygon (without clearence areas * to do that this function: - * 1 - creates a Bool_Engine,with option: holes are linked to outer contours by double overlapping segments - * this means the created polygons have no holes (hole are linked to outer outline by double overlapped segments - * and are therefore compatible with draw functions (DC draw polygons and Gerber or PS outputs) + * 1 - creates a Bool_Engine,with option: holes are linked to outer contours by double + * overlapping segments this means the created polygons have no holes (hole are linked + * to outer outline by double overlapped segments and are therefore compatible with + * draw functions (DC draw polygons and Gerber or PS outputs) * 2 - Add the main outline (zone outline) in group A * 3 - Creates a correction using BOOL_CORRECTION operation to shrink the resulting area * with m_ZoneMinThickness/2 value. * The result is areas with a margin of m_ZoneMinThickness/2 - * When drawing outline with segments having a thickness of m_ZoneMinThickness, the outlines will + * When drawing outline with segments having a thickness of m_ZoneMinThickness, the + * outlines will * match exactly the initial outlines * 4 - recreates the same Bool_Engine, with no correction * 5 - Add the main modified outline (zone outline) in group A - * 6 - Add all non filled areas (pads, tracks) in group B with a clearance of m_Clearance + m_ZoneMinThickness/2 + * 6 - Add all non filled areas (pads, tracks) in group B with a clearance of m_Clearance + + * m_ZoneMinThickness/2 * 7 - calculates the polygon A - B * 8 - put resulting list of polygons (filled areas) in m_FilledPolysList * This zone contains pads with the same net. * 9 - Remove insulated copper islands - * 10 - If Thermal shapes are wanted, remove copper around pads in zone, in order to create thes thermal shapes + * 10 - If Thermal shapes are wanted, remove copper around pads in zone, in order to create + * thes thermal shapes * a - Creates a bool engine and add the last copper areas in group A * b - Add thermal shapes (non copper ares in group B * c - Calculates the polygon A - B @@ -223,11 +232,13 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) MODULE dummymodule( aPcb ); // Creates a dummy parent D_PAD dummypad( &dummymodule ); D_PAD* nextpad; + for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { for( D_PAD* pad = module->m_Pads; pad != NULL; pad = nextpad ) { nextpad = pad->Next(); // pad pointer can be modified by next code, so calculate the next pad here + if( !pad->IsOnLayer( GetLayer() ) ) { /* Test fo pads that are on top or bottom only and have a hole. @@ -249,6 +260,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { item_clearance = pad->GetClearance() + margin; item_boundingbox = pad->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { int clearance = MAX( zone_clearance, item_clearance ); @@ -261,13 +273,15 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) } int gap = zone_clearance; + if( (m_PadOption == PAD_NOT_IN_ZONE) - || (GetNet() == 0) || pad->m_PadShape == PAD_TRAPEZOID ) + || (GetNet() == 0) || pad->m_PadShape == PAD_TRAPEZOID ) // PAD_TRAPEZOID shapes are not in zones because they are used in microwave apps // and i think it is good that shapes are not changed by thermal pads or others { item_boundingbox = pad->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { pad->TransformShapeWithClearanceToPolygon( cornerBufferPolysToSubstract, @@ -286,11 +300,13 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { if( !track->IsOnLayer( GetLayer() ) ) continue; + if( track->GetNet() == GetNet() && (GetNet() != 0) ) continue; item_clearance = track->GetClearance() + margin; item_boundingbox = track->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { int clearance = MAX( zone_clearance, item_clearance ); @@ -311,9 +327,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { if( !item->IsOnLayer( GetLayer() ) ) continue; + if( item->Type() != TYPE_EDGE_MODULE ) continue; + item_boundingbox = item->GetBoundingBox(); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { ( (EDGE_MODULE*) item )->TransformShapeWithClearanceToPolygon( @@ -355,17 +374,18 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) // cornerBufferPolysToSubstract contains polygons to substract, // prepare booleng to do that: - AddPolygonCornersToBoolengine( cornerBufferPolysToSubstract, - booleng, GROUP_B ); + AddPolygonCornersToBoolengine( cornerBufferPolysToSubstract, booleng, GROUP_B ); #ifdef CREATE_KBOOL_KEY_FILES_FIRST_PASS for( unsigned icnt = 0; icnt < cornerBuffer.size(); ) { StartKeyFilePolygon( 1 ); + for( ii = icnt; ii < cornerBuffer.size(); ii++ ) { AddKeyFilePointXY( cornerBufferPolysToSubstract[ii].x, cornerBufferPolysToSubstract[ii].y ); + if( cornerBufferPolysToSubstract[ii].end_contour ) break; } @@ -392,9 +412,10 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) m_FilledPolysList.clear(); CopyPolygonsFromBoolengineToFilledPolysList( booleng ); } + delete booleng; -// Remove insulated islands: + // Remove insulated islands: if( GetNet() > 0 ) Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb ); @@ -402,8 +423,9 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) if( m_PadOption != THERMAL_PAD || aPcb->m_Modules == NULL ) return; -// Remove thermal symbols + // Remove thermal symbols cornerBufferPolysToSubstract.clear(); + if( m_PadOption == THERMAL_PAD ) { booleng = new Bool_Engine(); @@ -424,8 +446,10 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) if( pad->GetNet() != GetNet() ) continue; + item_boundingbox = pad->GetBoundingBox(); item_boundingbox.Inflate( m_ThermalReliefGapValue ); + if( item_boundingbox.Intersects( zone_boundingbox ) ) { CreateThermalReliefPadPolygon( cornerBufferPolysToSubstract, @@ -447,8 +471,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) // cornerBufferPolysToSubstract contains polygons to substract, // prepare booleng to do that: - AddPolygonCornersToBoolengine( cornerBufferPolysToSubstract, - booleng, GROUP_B ); + AddPolygonCornersToBoolengine( cornerBufferPolysToSubstract, booleng, GROUP_B ); /* remove thermal areas (non copper areas) */ booleng->Do_Operation( BOOL_A_SUB_B ); @@ -456,19 +479,23 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) m_FilledPolysList.clear(); CopyPolygonsFromBoolengineToFilledPolysList( booleng ); } + delete booleng; // Remove insulated islands: if( GetNet() > 0 ) Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb ); + #ifdef CREATE_KBOOL_KEY_FILES for( unsigned icnt = 0; icnt < cornerBufferPolysToSubstract.size(); ) { StartKeyFilePolygon( 1 ); + for( ii = icnt; ii < cornerBufferPolysToSubstract.size(); ii++ ) { AddKeyFilePointXY( cornerBufferPolysToSubstract[ii].x, cornerBufferPolysToSubstract[ii].y ); + if( cornerBufferPolysToSubstract[ii].end_contour ) break; } @@ -477,6 +504,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) icnt = ii + 1; } } + CloseKeyFileEntity(); CloseKeyFile(); #endif @@ -490,7 +518,9 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) booleng = new Bool_Engine(); ArmBoolEng( booleng, true ); cornerBufferPolysToSubstract.clear(); - BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, s_Correction, s_thermalRot ); + BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, + s_Correction, s_thermalRot ); + /* remove copper areas */ if( cornerBufferPolysToSubstract.size() ) { @@ -531,9 +561,11 @@ void AddPolygonCornersToBoolengine( std::vector & aCornersBuffer, for( unsigned icnt = 0; icnt < aCornersBuffer.size(); ) { aBoolengine->StartPolygonAdd( aGroup ); + for( ii = icnt; ii < aCornersBuffer.size(); ii++ ) { aBoolengine->AddPoint( aCornersBuffer[ii].x, aCornersBuffer[ii].y ); + if( aCornersBuffer[ii].end_contour ) break; } @@ -544,11 +576,6 @@ void AddPolygonCornersToBoolengine( std::vector & aCornersBuffer, } -/***********************************************************************************************************/ -int ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToBoolengine( Bool_Engine* aBoolengine, - GroupType aGroup ) -/************************************************************************************************************/ - /** * Function CopyPolygonsFromFilledPolysListToBoolengine * Copy (Add) polygons found in m_FilledPolysList to kbool BoolEngine @@ -557,6 +584,8 @@ int ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToBoolengine( Bool_Engine* aB * @param aGroup = group in kbool engine (GROUP_A or GROUP_B only) * @return the corner count */ +int ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToBoolengine( Bool_Engine* aBoolengine, + GroupType aGroup ) { unsigned corners_count = m_FilledPolysList.size(); int count = 0; @@ -571,6 +600,7 @@ int ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToBoolengine( Bool_Engine* aB CPolyPt* corner = &m_FilledPolysList[ic]; aBoolengine->AddPoint( corner->x, corner->y ); count++; + if( corner->end_contour ) { ic++; @@ -586,22 +616,20 @@ int ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToBoolengine( Bool_Engine* aB } -/*****************************************************************************************/ -int ZONE_CONTAINER::CopyPolygonsFromBoolengineToFilledPolysList( Bool_Engine* aBoolengine ) -/*****************************************************************************************/ - /** * Function CopyPolygonsFromBoolengineToFilledPolysList * Copy (Add) polygons created by kbool (after Do_Operation) to m_FilledPolysList * @param aBoolengine = kbool engine * @return the corner count */ +int ZONE_CONTAINER::CopyPolygonsFromBoolengineToFilledPolysList( Bool_Engine* aBoolengine ) { int count = 0; while( aBoolengine->StartPolygonGet() ) { CPolyPt corner( 0, 0, false ); + while( aBoolengine->PolygonHasMorePoints() ) { corner.x = (int) aBoolengine->GetPolygonXPoint(); diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp index 6c6470447c..b247cf29d8 100644 --- a/pcbnew/zones_non_copper_type_functions.cpp +++ b/pcbnew/zones_non_copper_type_functions.cpp @@ -38,12 +38,10 @@ public: }; -/*******************************************************************************************/ DialogNonCopperZonesEditor::DialogNonCopperZonesEditor( PCB_EDIT_FRAME* parent, ZONE_CONTAINER* zone_container, ZONE_SETTING* zone_setting ) : DialogNonCopperZonesPropertiesBase( parent ) -/*******************************************************************************************/ { m_Parent = parent; m_Zone_Container = zone_container; @@ -54,9 +52,7 @@ DialogNonCopperZonesEditor::DialogNonCopperZonesEditor( PCB_EDIT_FRAME* parent, } -/********************************************************/ DialogNonCopperZonesEditor::~DialogNonCopperZonesEditor() -/********************************************************/ { } @@ -70,9 +66,7 @@ bool PCB_EDIT_FRAME::InstallDialogNonCopperZonesEditor( ZONE_CONTAINER* aZone ) } -/********************************************************************/ void DialogNonCopperZonesEditor::Init() -/********************************************************************/ { SetFocus(); SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click @@ -81,8 +75,8 @@ void DialogNonCopperZonesEditor::Init() AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit ); wxString msg = ReturnStringFromValue( g_UserUnit, - m_Zone_Setting->m_ZoneMinThickness, - m_Parent->m_InternalUnits ); + m_Zone_Setting->m_ZoneMinThickness, + m_Parent->m_InternalUnits ); m_ZoneMinThicknessCtrl->SetValue( msg ); if( g_Zone_45_Only ) @@ -126,18 +120,16 @@ void DialogNonCopperZonesEditor::Init() } -/******************************************************************/ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event ) -/******************************************************************/ { wxString txtvalue = m_ZoneMinThicknessCtrl->GetValue(); m_Zone_Setting->m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->m_InternalUnits ); + if( m_Zone_Setting->m_ZoneMinThickness < 10 ) { DisplayError( this, - _( - "Error :\nyou must choose a copper min thickness value bigger than 0.001 inch (or 0.0254 mm)" ) ); + _( "Error :\nyou must choose a copper min thickness value bigger than 0.001 inch (or 0.0254 mm)" ) ); return; } @@ -165,25 +157,25 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event ) } if( m_OrientEdgesOpt->GetSelection() == 0 ) - g_Zone_45_Only = FALSE; + g_Zone_45_Only = false; else - g_Zone_45_Only = TRUE; + g_Zone_45_Only = true; /* Get the layer selection for this zone */ int ii = m_LayerSelectionCtrl->GetSelection(); + if( ii < 0 ) { DisplayError( this, _( "Error : you must choose a layer" ) ); return; } + g_Zone_Default_Setting.m_CurrentZone_Layer = ii + FIRST_NO_COPPER_LAYER; EndModal( ZONE_OK ); } -/**********************************************************************/ void DialogNonCopperZonesEditor::OnCancelClick( wxCommandEvent& event ) -/**********************************************************************/ { EndModal( ZONE_ABORT ); } diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index 235a4edb24..76fc9fff03 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -1019,7 +1019,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex ) wxPoint end; // Search the end point of the edge starting at aCornerIndex - if( aArea->m_Poly->corner[aCornerIndex].end_contour == FALSE + if( aArea->m_Poly->corner[aCornerIndex].end_contour == false && aCornerIndex < (aArea->GetNumCorners() - 1) ) { end = aArea->GetCornerPosition( aCornerIndex + 1 );