Commit cdd9e8ca authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: code cleanup

parent 6963001a
......@@ -5,7 +5,6 @@
#include "colors_selection.h"
#include "bitmaps.h"
#include "pcbnew_id.h"
#include "hotkeys.h"
#include "help_common_strings.h"
......
......@@ -16,7 +16,6 @@
#include "gerbview.h"
#include "wxGerberFrame.h"
#include "wxPcbStruct.h"
#include "pcbplot.h"
#include "class_board_design_settings.h"
......
......@@ -1100,7 +1100,7 @@ public:
* Function OnOrientFootprints
* install the dialog box for the common Orient Footprints
*/
void OnOrientFootprints( void );
void OnOrientFootprints( wxCommandEvent& event );
/**
* Function ReOrientModules
......@@ -1108,8 +1108,9 @@ public:
* @param ModuleMask = mask (wildcard allowed) selection
* @param Orient = new orientation
* @param include_fixe = true to orient locked footprints
* @return true if some footprints modified, false if no change
*/
void ReOrientModules( const wxString& ModuleMask, int Orient,
bool ReOrientModules( const wxString& ModuleMask, int Orient,
bool include_fixe );
void FixeModule( MODULE* Module, bool Fixe );
void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
......
......@@ -31,8 +31,8 @@ set(PCBNEW_DIALOGS
dialog_design_rules_base.cpp
dialogs/dialog_display_options.cpp
dialogs/dialog_display_options_base.cpp
dialog_drc_base.cpp
dialog_drc.cpp
dialogs/dialog_drc_base.cpp
dialogs/dialog_drc.cpp
dialogs/dialog_edit_module_for_BoardEditor.cpp
dialogs/dialog_edit_module_for_BoardEditor_base.cpp
dialogs/dialog_edit_module_for_Modedit_base.cpp
......@@ -45,20 +45,20 @@ set(PCBNEW_DIALOGS
dialog_freeroute_exchange_base.cpp
dialogs/dialog_gendrill.cpp
dialogs/dialog_gendrill_base.cpp
dialog_general_options.cpp
dialog_general_options_BoardEditor_base.cpp
dialog_global_edit_tracks_and_vias.cpp
dialog_global_edit_tracks_and_vias_base.cpp
dialog_global_pads_edition_base.cpp
dialogs/dialog_general_options.cpp
dialogs/dialog_general_options_BoardEditor_base.cpp
dialogs/dialog_global_edit_tracks_and_vias.cpp
dialogs/dialog_global_edit_tracks_and_vias_base.cpp
dialogs/dialog_global_pads_edition_base.cpp
dialogs/dialog_graphic_items_options.cpp
dialogs/dialog_graphic_items_options_base.cpp
dialogs/dialog_graphic_item_properties.cpp
dialogs/dialog_graphic_item_properties_base.cpp
dialog_layers_setup.cpp
dialog_layers_setup_base.cpp
dialog_netlist.cpp
dialog_netlist_fbp.cpp
dialog_pcb_text_properties.cpp
dialogs/dialog_netlist.cpp
dialogs/dialog_netlist_fbp.cpp
dialogs/dialog_pcb_text_properties.cpp
dialogs/dialog_non_copper_zones_properties_base.cpp
dialogs/dialog_pad_properties.cpp
dialogs/dialog_pad_properties_base.cpp
......@@ -69,7 +69,8 @@ set(PCBNEW_DIALOGS
dialogs/dialog_print_for_modedit_base.cpp
dialogs/dialog_print_using_printer.cpp
dialogs/dialog_print_using_printer_base.cpp
dialog_orient_footprints.cpp
dialogs/dialog_orient_footprints.cpp
dialogs/dialog_orient_footprints_base.cpp
dialogs/dialog_mask_clearance.cpp
dialogs/dialog_mask_clearance_base.cpp
dialogs/dialog_SVG_print.cpp
......
......@@ -2,13 +2,6 @@
/* ar-proto.h */
/**************/
MODULE ** GenListeModules( BOARD * Pcb, int * NbModules );
/****************/
/* GRAPHPCB.CPP */
/****************/
/* Initialize a value type, the cells included in the board surface of the
* pad edge by pt_pad, with the margin reserved for isolation. */
void Place_1_Pad_Board( BOARD * Pcb, D_PAD * pt_pad, int type, int marge,
......@@ -44,8 +37,6 @@ void TraceFilledRectangle( BOARD * Pcb, int ux0, int uy0, int ux1, int uy1,
void TraceArc( int ux0,int uy0, int ux1, int uy1, int ArcAngle, int lg,
int layer, int color, int op_logique);
/* SOLVE.CPP */
/* QUEUE.CPP */
void FreeQueue();
void InitQueue();
......@@ -53,7 +44,6 @@ void GetQueue( int *, int *, int *, int *, int * );
int SetQueue( int, int, int, int, int, int, int );
void ReSetQueue( int, int, int, int, int, int, int );
/* WORK.CPP */
void InitWork();
void ReInitWork();
......
......@@ -8,7 +8,6 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "autorout.h"
#include "protos.h"
......
......@@ -2,6 +2,8 @@
/* Routines for automatic displacement and rotation of modules. */
/****************************************************************/
#include <algorithm>
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
......@@ -25,7 +27,7 @@ typedef enum {
} SelectFixeFct;
static int tri_modules( MODULE** pt_ref, MODULE** pt_compare );
static bool sortModulesbySize( MODULE* ref, MODULE* compare );
wxString ModulesMaskSelection = wxT( "*" );
......@@ -132,10 +134,6 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
AutoMoveModulesOnPcb( TRUE );
break;
case ID_POPUP_PCB_REORIENT_ALL_MODULES:
OnOrientFootprints();
break;
case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES:
Autoroute( &dc, ROUTE_ALL );
break;
......@@ -172,13 +170,12 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
*/
void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
{
MODULE** pt_Dmod, ** BaseListeModules;
MODULE* Module;
std::vector <MODULE*> moduleList;
wxPoint start, current;
int Ymax_size, Xsize_allowed;
int pas_grille = (int) GetScreen()->GetGridSize().x;
bool EdgeExists;
float surface;
bool edgesExists;
double surface;
if( GetBoard()->m_Modules == NULL )
{
......@@ -190,28 +187,29 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( !IsOK( this, _( "Move modules?" ) ) )
return;
EdgeExists = SetBoardBoundaryBoxFromEdgesOnly();
edgesExists = SetBoardBoundaryBoxFromEdgesOnly();
if( PlaceModulesHorsPcb && !EdgeExists )
if( PlaceModulesHorsPcb && !edgesExists )
{
DisplayError( this,
_( "Could not automatically place modules. No board outlines detected." ) );
return;
}
Module = GetBoard()->m_Modules;
// Build sorted footprints list (sort by decreasing size )
MODULE* Module = GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
moduleList.push_back(Module);
}
sort( moduleList.begin(), moduleList.end(), sortModulesbySize );
BaseListeModules = GenListeModules( GetBoard(), NULL );
/* If allocation of modules not PCBs, the cursor is placed below
* PCB, to avoid placing components in PCB area.
/* to move modules outside the board, the cursor is placed below
* the current board, to avoid placing components in board area.
*/
if( PlaceModulesHorsPcb && EdgeExists )
if( PlaceModulesHorsPcb && edgesExists )
{
if( GetScreen()->m_Curseur.y <
(GetBoard()->m_BoundaryBox.GetBottom() + 2000) )
......@@ -219,12 +217,12 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
2000;
}
/* calculating the area occupied by the circuits */
/* calculate the area needed by footprints */
surface = 0.0;
for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
{
Module = *pt_Dmod;
if( PlaceModulesHorsPcb && EdgeExists )
Module = moduleList[ii];
if( PlaceModulesHorsPcb && edgesExists )
{
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
continue;
......@@ -237,13 +235,13 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
start = current = GetScreen()->m_Curseur;
Ymax_size = 0;
for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
{
Module = *pt_Dmod;
Module = moduleList[ii];
if( Module->IsLocked() )
continue;
if( PlaceModulesHorsPcb && EdgeExists )
if( PlaceModulesHorsPcb && edgesExists )
{
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
continue;
......@@ -269,7 +267,6 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
current.x += Module->m_RealBoundaryBox.GetWidth() + pas_grille;
}
MyFree( BaseListeModules );
DrawPanel->Refresh();
}
......@@ -302,58 +299,8 @@ void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe )
}
/* Create memory allocation by the ordered list of structures D_MODULES
* Describing the module to move
* The end of the list is indicated by NULL
* Also returns the number of modules per NbModules *
* Deallocates memory after use
*/
MODULE** GenListeModules( BOARD* Pcb, int* NbModules )
static bool sortModulesbySize( MODULE* ref, MODULE* compare )
{
MODULE* Module;
MODULE** ListeMod, ** PtList;
int NbMod;
/* Reserve memory for descriptions of modules that are to be moved. */
Module = Pcb->m_Modules;
NbMod = 0;
for( ; Module != NULL; Module = Module->Next() )
NbMod++;
ListeMod = (MODULE**) MyZMalloc( (NbMod + 1) * sizeof(MODULE*) );
if( ListeMod == NULL )
{
if( NbModules != NULL )
*NbModules = 0;
return NULL;
}
PtList = ListeMod;
Module = Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{
*PtList = Module; PtList++;
Module->SetRectangleExinscrit();
}
/* Sort by surface area module largest to smallest */
qsort( ListeMod, NbMod, sizeof(MODULE * *),
( int ( * )( const void*, const void* ) )tri_modules );
if( NbModules != NULL )
*NbModules = NbMod;
return ListeMod;
return compare->m_Surface < ref->m_Surface;
}
static int tri_modules( MODULE** pt_ref, MODULE** pt_compare )
{
float ff;
ff = (*pt_ref)->m_Surface - (*pt_compare)->m_Surface;
if( ff < 0 )
return 1;
if( ff > 0 )
return -1;
return 0;
}
This diff is collapsed.
......@@ -12,7 +12,6 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "autorout.h"
#include "pcbplot.h"
#include "trigo.h"
......
......@@ -14,7 +14,6 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "module_editor_frame.h"
#include "autorout.h"
#include "pcbplot.h"
#include "trigo.h"
......
......@@ -17,7 +17,6 @@
#include "class_board_design_settings.h"
#include "colors_selection.h"
#include "autorout.h"
#include "drag.h"
#include "3d_struct.h"
......
......@@ -7,7 +7,6 @@
#include "common.h"
#include "class_drawpanel.h"
#include "pcbnew.h"
#include "autorout.h"
// Constructor and destructor
......
#include "wx/msw/wx.rc"
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_orient_footprints.cpp
// Purpose:
// Author: j-p Charras
// Modified by:
// Created: 11/07/2008 13:32:12
// RCS-ID:
// Copyright: j-p Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 11/07/2008 13:32:12
////@begin includes
////@end includes
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "kicad_string.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "dialog_orient_footprints.h"
////@begin XPM images
////@end XPM images
int s_NewOrientation = 0;
/*!
* dialog_orient_footprints type definition
*/
IMPLEMENT_DYNAMIC_CLASS( dialog_orient_footprints, wxDialog )
/*!
* dialog_orient_footprints event table definition
*/
BEGIN_EVENT_TABLE( dialog_orient_footprints, wxDialog )
////@begin dialog_orient_footprints event table entries
EVT_CLOSE( dialog_orient_footprints::OnCloseWindow )
EVT_BUTTON( wxID_OK, dialog_orient_footprints::OnOkClick )
EVT_BUTTON( wxID_CANCEL, dialog_orient_footprints::OnCancelClick )
////@end dialog_orient_footprints event table entries
END_EVENT_TABLE()
/*!
* dialog_orient_footprints constructors
*/
dialog_orient_footprints::dialog_orient_footprints()
{
Init();
}
dialog_orient_footprints::dialog_orient_footprints( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
m_Parent = parent;
Init();
Create(parent, id, caption, pos, size, style);
}
/*!
* dialog_orient_footprints creator
*/
bool dialog_orient_footprints::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin dialog_orient_footprints creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end dialog_orient_footprints creation
return true;
}
/*!
* dialog_orient_footprints destructor
*/
dialog_orient_footprints::~dialog_orient_footprints()
{
////@begin dialog_orient_footprints destruction
////@end dialog_orient_footprints destruction
}
/*!
* Member initialisation
*/
void dialog_orient_footprints::Init()
{
////@begin dialog_orient_footprints member initialisation
m_OrientationCtrl = NULL;
m_FilterPattern = NULL;
m_ApplyToLocked = NULL;
m_CloseButton = NULL;
////@end dialog_orient_footprints member initialisation
}
/*!
* Control creation for dialog_orient_footprints
*/
void dialog_orient_footprints::CreateControls()
{
////@begin dialog_orient_footprints content construction
// Generated by DialogBlocks, 11/07/2008 16:49:18 (unregistered)
dialog_orient_footprints* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer3, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add(itemStaticText4, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
m_OrientationCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRLROT_VALUE, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
if (dialog_orient_footprints::ShowToolTips())
m_OrientationCtrl->SetToolTip(_("New orientation (0.1 degree resolution)"));
itemBoxSizer3->Add(m_OrientationCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filter:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add(itemStaticText6, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
m_FilterPattern = new wxTextCtrl( itemDialog1, ID_TEXTCTRL_FOOTPRINTS_FILTER, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
if (dialog_orient_footprints::ShowToolTips())
m_FilterPattern->SetToolTip(_("Filter to select footprints by reference"));
itemBoxSizer3->Add(m_FilterPattern, 1, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
itemBoxSizer3->Add(5, 5, 0, wxGROW|wxALL, 5);
m_ApplyToLocked = new wxCheckBox( itemDialog1, ID_CHECKBOX_APPLY_TO_LOCKED, _("Include Locked Footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_ApplyToLocked->SetValue(false);
if (dialog_orient_footprints::ShowToolTips())
m_ApplyToLocked->SetToolTip(_("Force locked footprints to be modified"));
itemBoxSizer3->Add(m_ApplyToLocked, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_CloseButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_CloseButton->SetDefault();
itemBoxSizer10->Add(m_CloseButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
////@end dialog_orient_footprints content construction
wxString txt;
txt.Printf(wxT("%g"), (double) s_NewOrientation/10);
m_OrientationCtrl->SetValue(txt);
m_CloseButton->SetFocus( );
}
/*!
* Should we show tooltips?
*/
bool dialog_orient_footprints::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap dialog_orient_footprints::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin dialog_orient_footprints bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end dialog_orient_footprints bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon dialog_orient_footprints::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin dialog_orient_footprints icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end dialog_orient_footprints icon retrieval
}
/***********************************************/
void WinEDA_PcbFrame::OnOrientFootprints( void )
/***********************************************/
/**
* Function OnOrientFootprints
* install the dialog box for the comman Orient Footprints
*/
{
dialog_orient_footprints dialogbox(this);
dialogbox.ShowModal();
dialogbox.Destroy();
}
/*******************************************************************/
void WinEDA_PcbFrame::ReOrientModules( const wxString& ModuleMask,
int Orient, bool include_fixe )
/*******************************************************************/
/**
* Function ReOrientModules
* Set the orientation of footprints
* @param ModuleMask = mask (wildcard allowed) selection
* @param Orient = new orientation
* @param include_fixe = true to orient locked footprints
*/
{
wxString line;
bool redraw = false;
line.Printf( _( "Ok to set footprints orientation to %g degrees ?" ), (double)Orient / 10 );
if( !IsOK( this, line ) )
return;
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{
if( module->IsLocked() && !include_fixe )
continue;
if( WildCompareString( ModuleMask, module->m_Reference->m_Text, FALSE ) )
{
OnModify();
redraw = true;
Rotate_Module( NULL, module, Orient, FALSE );
}
}
if ( redraw )
DrawPanel->Refresh();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void dialog_orient_footprints::OnOkClick( wxCommandEvent& event )
{
double d_orient;
wxString text = m_OrientationCtrl->GetValue();
if ( ! text.ToDouble(&d_orient) )
{
DisplayError(this, _("Bad value for footprints orientation"));
return;
}
s_NewOrientation = wxRound(d_orient * 10);
if ( s_NewOrientation > 3600 )
s_NewOrientation = 3600;
if ( s_NewOrientation < -3600 )
s_NewOrientation = -3600;
text = m_FilterPattern->GetValue();
m_Parent->ReOrientModules( text, s_NewOrientation, m_ApplyToLocked->IsChecked() );
Close();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void dialog_orient_footprints::OnCancelClick( wxCommandEvent& event )
{
Close();
}
/*!
* wxEVT_CLOSE_WINDOW event handler for ID_DIALOG_ORIENT_FOOTPRINTS
*/
void dialog_orient_footprints::OnCloseWindow( wxCloseEvent& event )
{
EndModal(1);
}
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_orient_footprints.h
// Purpose:
// Author:
// Modified by:
// Created: 11/07/2008 13:32:12
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 11/07/2008 13:32:12
#ifndef _DIALOG_ORIENT_FOOTPRINTS_H_
#define _DIALOG_ORIENT_FOOTPRINTS_H_
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG_ORIENT_FOOTPRINTS 10000
#define ID_TEXTCTRLROT_VALUE 10003
#define ID_TEXTCTRL_FOOTPRINTS_FILTER 10001
#define ID_CHECKBOX_APPLY_TO_LOCKED 10002
#define SYMBOL_DIALOG_ORIENT_FOOTPRINTS_STYLE wxDEFAULT_DIALOG_STYLE
#define SYMBOL_DIALOG_ORIENT_FOOTPRINTS_TITLE _("Footprints Orientation")
#define SYMBOL_DIALOG_ORIENT_FOOTPRINTS_IDNAME ID_DIALOG_ORIENT_FOOTPRINTS
#define SYMBOL_DIALOG_ORIENT_FOOTPRINTS_SIZE wxSize(400, 300)
#define SYMBOL_DIALOG_ORIENT_FOOTPRINTS_POSITION wxDefaultPosition
////@end control identifiers
/*!
* dialog_orient_footprints class declaration
*/
class dialog_orient_footprints: public wxDialog
{
DECLARE_DYNAMIC_CLASS( dialog_orient_footprints )
DECLARE_EVENT_TABLE()
public:
/// Constructors
dialog_orient_footprints();
dialog_orient_footprints( WinEDA_PcbFrame* parent,
wxWindowID id = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_IDNAME,
const wxString& caption = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_TITLE,
const wxPoint& pos = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_POSITION,
const wxSize& size = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_SIZE,
long style = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_IDNAME, const wxString& caption = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_TITLE, const wxPoint& pos = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_POSITION, const wxSize& size = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_SIZE, long style = SYMBOL_DIALOG_ORIENT_FOOTPRINTS_STYLE );
/// Destructor
~dialog_orient_footprints();
/// Initialises member variables
void Init();
/// Creates the controls and sizers
void CreateControls();
////@begin dialog_orient_footprints event handler declarations
/// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG_ORIENT_FOOTPRINTS
void OnCloseWindow( wxCloseEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
////@end dialog_orient_footprints event handler declarations
////@begin dialog_orient_footprints member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end dialog_orient_footprints member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
////@begin dialog_orient_footprints member variables
wxTextCtrl* m_OrientationCtrl;
wxTextCtrl* m_FilterPattern;
wxCheckBox* m_ApplyToLocked;
wxButton* m_CloseButton;
////@end dialog_orient_footprints member variables
WinEDA_PcbFrame * m_Parent;
};
#endif
// _DIALOG_ORIENT_FOOTPRINTS_H_
This diff is collapsed.
......@@ -14,7 +14,6 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "trigo.h"
#include "autorout.h"
#include "zones.h"
#include "dialog_copper_zones.h"
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* @file DIALOG_ORIENT_FOOTPRINTS.cpp
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 Jean_Pierre Charras <jp.charras@ujf-grenoble.fr>
* Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "kicad_string.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "macros.h"
#include "dialog_orient_footprints_base.h"
/* DIALOG_ORIENT_FOOTPRINTS class declaration
*/
class DIALOG_ORIENT_FOOTPRINTS: public DIALOG_ORIENT_FOOTPRINTS_BASE
{
private:
WinEDA_PcbFrame * m_Parent;
static int newOrientation;
public:
DIALOG_ORIENT_FOOTPRINTS( WinEDA_PcbFrame* parent );
~DIALOG_ORIENT_FOOTPRINTS() {}
bool ApplyToLockedModules()
{
return m_ApplyToLocked->IsChecked();
}
int GetOrientation()
{
return newOrientation;
}
wxString GetFilter()
{
return m_FilterPattern->GetValue();
}
private:
void init();
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
};
int DIALOG_ORIENT_FOOTPRINTS::newOrientation = 0;
DIALOG_ORIENT_FOOTPRINTS::DIALOG_ORIENT_FOOTPRINTS( WinEDA_PcbFrame* parent )
: DIALOG_ORIENT_FOOTPRINTS_BASE( parent )
{
m_Parent = parent;
wxString txt;
txt.Printf(wxT("%g"), (double) newOrientation/10);
m_OrientationCtrl->SetValue(txt);
SetFocus( );
GetSizer()->SetSizeHints(this);
Centre();
}
/****************************************************************/
void WinEDA_PcbFrame::OnOrientFootprints( wxCommandEvent& event )
/****************************************************************/
/**
* Function OnOrientFootprints
* install the dialog box for the comman Orient Footprints
*/
{
DIALOG_ORIENT_FOOTPRINTS dlg(this);
if( dlg.ShowModal() != wxID_OK )
return;
wxString text = dlg.GetFilter();
if( ReOrientModules( text, dlg.GetOrientation(), dlg.ApplyToLockedModules() ) )
{
DrawPanel->Refresh();
Compile_Ratsnest( NULL, true );
}
}
/*******************************************************************/
bool WinEDA_PcbFrame::ReOrientModules( const wxString& ModuleMask,
int Orient, bool include_fixe )
/*******************************************************************/
/**
* Function ReOrientModules
* Set the orientation of footprints
* @param ModuleMask = mask (wildcard allowed) selection
* @param Orient = new orientation
* @param include_fixe = true to orient locked footprints
* @return true if some footprints modified, false if no change
*/
{
wxString line;
bool modified = false;
line.Printf( _( "Ok to set footprints orientation to %.1f degrees ?" ), (double)Orient / 10 );
if( !IsOK( this, line ) )
return false;
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{
if( module->IsLocked() && !include_fixe )
continue;
if( WildCompareString( ModuleMask, module->m_Reference->m_Text, FALSE ) )
{
modified = true;
Rotate_Module( NULL, module, Orient, FALSE );
}
}
if ( modified )
OnModify();
return modified;
}
void DIALOG_ORIENT_FOOTPRINTS::OnOkClick( wxCommandEvent& event )
{
double d_orient;
wxString text = m_OrientationCtrl->GetValue();
if ( ! text.ToDouble(&d_orient) )
{
DisplayError(this, _("Bad value for footprints orientation"));
return;
}
newOrientation = wxRound(d_orient * 10);
NORMALIZE_ANGLE_180( newOrientation );
EndModal( wxID_OK );
}
void DIALOG_ORIENT_FOOTPRINTS::OnCancelClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_orient_footprints_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_ORIENT_FOOTPRINTS_BASE::DIALOG_ORIENT_FOOTPRINTS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bSizerLeft->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_OrientationCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_OrientationCtrl->SetToolTip( _("New orientation (0.1 degree resolution)") );
bSizerLeft->Add( m_OrientationCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Filter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizerLeft->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_FilterPattern = new wxTextCtrl( this, wxID_ANY, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
m_FilterPattern->SetToolTip( _("Filter to select footprints by reference") );
bSizerLeft->Add( m_FilterPattern, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerLeft->Add( 0, 0, 0, wxTOP|wxBOTTOM, 5 );
m_ApplyToLocked = new wxCheckBox( this, wxID_ANY, _("Include Locked Footprints"), wxDefaultPosition, wxDefaultSize, 0 );
m_ApplyToLocked->SetToolTip( _("Force locked footprints to be modified") );
bSizerLeft->Add( m_ApplyToLocked, 0, wxALL, 5 );
bSizerMain->Add( bSizerLeft, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonOK->SetDefault();
bSizerRight->Add( m_buttonOK, 0, wxALL, 5 );
m_buttonClose = new wxButton( this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonClose, 0, wxALL, 5 );
bSizerMain->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ORIENT_FOOTPRINTS_BASE::OnOkClick ), NULL, this );
m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ORIENT_FOOTPRINTS_BASE::OnCancelClick ), NULL, this );
}
DIALOG_ORIENT_FOOTPRINTS_BASE::~DIALOG_ORIENT_FOOTPRINTS_BASE()
{
// Disconnect Events
m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ORIENT_FOOTPRINTS_BASE::OnOkClick ), NULL, this );
m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ORIENT_FOOTPRINTS_BASE::OnCancelClick ), NULL, this );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_orient_footprints_base__
#define __dialog_orient_footprints_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_ORIENT_FOOTPRINTS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_ORIENT_FOOTPRINTS_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticText1;
wxTextCtrl* m_OrientationCtrl;
wxStaticText* m_staticText2;
wxTextCtrl* m_FilterPattern;
wxCheckBox* m_ApplyToLocked;
wxButton* m_buttonOK;
wxButton* m_buttonClose;
// Virtual event handlers, overide them in your derived class
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_ORIENT_FOOTPRINTS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprints Orientation"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 403,160 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_ORIENT_FOOTPRINTS_BASE();
};
#endif //__dialog_orient_footprints_base__
......@@ -14,7 +14,6 @@
#include "wxPcbStruct.h"
#include "module_editor_frame.h"
#include "class_board_design_settings.h"
#include "autorout.h"
#include "protos.h"
#include "dialog_drc.h"
......
......@@ -13,7 +13,6 @@
#include "class_board_design_settings.h"
#ifdef PCBNEW
#include "autorout.h"
#include "zones.h"
#endif
......
......@@ -233,6 +233,9 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
ID_POPUP_PCB_AUTOPLACE_END_RANGE,
WinEDA_PcbFrame::AutoPlace )
EVT_MENU( ID_POPUP_PCB_REORIENT_ALL_MODULES,
WinEDA_PcbFrame::OnOrientFootprints )
EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE,
WinEDA_PcbFrame::Process_Special_Functions )
......@@ -253,11 +256,11 @@ END_EVENT_TABLE()
///////****************************///////////:
WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* parent,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style ) :
WinEDA_BasePcbFrame( father, PCB_FRAME, title, pos, size, style )
WinEDA_BasePcbFrame( parent, PCB_FRAME, title, pos, size, style )
{
m_FrameName = wxT( "PcbFrame" );
m_Draw_Sheet_Ref = true; // true to display sheet references
......
......@@ -187,9 +187,6 @@ enum pcbnew_ids
ID_POPUP_PCB_AUTOMOVE_ALL_MODULES,
ID_POPUP_PCB_AUTOMOVE_NEW_MODULES,
ID_POPUP_PCB_AUTOPLACE_COMMANDS,
ID_POPUP_PCB_REORIENT_ALL_MODULES,
ID_POPUP_PCB_AUTOPLACE_ALL_MODULES,
ID_POPUP_PCB_AUTOPLACE_NEW_MODULES,
ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE,
......@@ -204,6 +201,8 @@ enum pcbnew_ids
ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS,
ID_POPUP_PCB_AUTOPLACE_END_RANGE,
ID_POPUP_PCB_REORIENT_ALL_MODULES,
ID_MENU_RECOVER_BOARD,
ID_MENU_READ_LAST_SAVED_VERSION_BOARD,
ID_MENU_ARCHIVE_MODULES,
......
......@@ -9,7 +9,6 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "autorout.h"
#include "class_board_design_settings.h"
#include "colors_selection.h"
......
......@@ -38,7 +38,6 @@
#include "pcbstruct.h" // HISTORY_NUMBER
#include "confirm.h" // DisplayError()
#include "gestfich.h" // EDA_FileSelector()
#include "autorout.h" // NET_CODES_OK
#include "class_board_design_settings.h"
#include "trigo.h" // RotatePoint()
......
......@@ -10,10 +10,7 @@
#include "common.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "autorout.h"
#include "zones.h"
#include "cell.h"
#include "trigo.h"
#include "protos.h"
......@@ -214,144 +211,3 @@ int ZONE_CONTAINER::Fill_Zone_Areas_With_Segments( )
}
/********************************************/
int Propagation( WinEDA_PcbFrame* frame )
/********************************************/
/**
* Function Propagation
* Used now only in autoplace calculations
* Uses the routing matrix to fill the cells within the zone
* Search and mark cells within the zone, and agree with DRC options.
* Requirements:
* Start from an initial point, to fill zone
* The zone must have no "copper island"
* Algorithm:
* If the current cell has a neightbour flagged as "cell in the zone", it
* become a cell in the zone
* The first point in the zone is the starting point
* 4 searches within the matrix are made:
* 1 - Left to right and top to bottom
* 2 - Right to left and top to bottom
* 3 - bottom to top and Right to left
* 4 - bottom to top and Left to right
* Given the current cell, for each search, we consider the 2 neightbour cells
* the previous cell on the same line and the previous cell on the same column.
*
* This funtion can request some iterations
* 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 row, col, nn;
long current_cell, old_cell_H;
int long* pt_cell_V;
int nbpoints = 0;
#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)
wxString msg;
Affiche_1_Parametre( frame, 57, wxT( "Detect" ), msg, CYAN );
Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "1" ), CYAN );
// Alloc memory to handle 1 line or 1 colunmn on the routing matrix
nn = MAX( Nrows, Ncols ) * sizeof(*pt_cell_V);
pt_cell_V = (long*) MyMalloc( nn );
/* 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) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
}
pt_cell_V[col] = old_cell_H = current_cell;
}
}
/* search 2 : from right to left and top to bottom */
Affiche_1_Parametre( frame, -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) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
}
pt_cell_V[col] = old_cell_H = current_cell;
}
}
/* search 3 : from bottom to top and right to left balayage */
Affiche_1_Parametre( frame, -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) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
}
pt_cell_V[row] = old_cell_H = current_cell;
}
}
/* search 4 : from bottom to top and left to right */
Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "4" ), CYAN );
memset( pt_cell_V, 0, nn );
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) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
}
pt_cell_V[row] = old_cell_H = current_cell;
}
}
MyFree( pt_cell_V );
return nbpoints;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment