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
*/
- 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 << "" << GetClass().Lower().mb_str() << ">\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