2011-12-16 13:32:23 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2011-12-16 13:32:23 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2012-06-08 09:56:42 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-16 13:32:23 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file automove.cpp
|
|
|
|
* @brief Routines for automatic displacement and rotation of modules.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <kicad_device_context.h>
|
|
|
|
|
|
|
|
#include <autorout.h>
|
|
|
|
#include <cell.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2007-08-20 01:20:48 +00:00
|
|
|
FIXE_MODULE,
|
|
|
|
FREE_MODULE,
|
|
|
|
FIXE_ALL_MODULES,
|
|
|
|
FREE_ALL_MODULES
|
|
|
|
} SelectFixeFct;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
static bool sortModulesbySize( MODULE* ref, MODULE* compare );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
wxString ModulesMaskSelection = wxT( "*" );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-23 15:28:45 +00:00
|
|
|
/* Called on events (popup menus) relative to automove and autoplace footprints
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-23 15:28:45 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-08-12 05:57:14 +00:00
|
|
|
case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS:
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE:
|
2011-03-09 14:30:39 +00:00
|
|
|
LockModule( (MODULE*) GetScreen()->GetCurItem(), true );
|
2010-08-12 05:57:14 +00:00
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE:
|
2011-09-07 19:41:04 +00:00
|
|
|
LockModule( (MODULE*) GetScreen()->GetCurItem(), false );
|
2010-08-12 05:57:14 +00:00
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES:
|
2011-09-07 19:41:04 +00:00
|
|
|
LockModule( NULL, false );
|
2010-08-12 05:57:14 +00:00
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES:
|
2011-03-09 14:30:39 +00:00
|
|
|
LockModule( NULL, true );
|
2010-08-12 05:57:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2010-08-12 05:57:14 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallEndMouseCapture( &dc );
|
2010-08-12 05:57:14 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-12 05:57:14 +00:00
|
|
|
default: // Abort a current command (if any)
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2010-08-12 05:57:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Erase ratsnest if needed */
|
|
|
|
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
|
|
|
|
DrawGeneralRatsnest( &dc );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-12 05:57:14 +00:00
|
|
|
GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE:
|
2011-09-07 19:41:04 +00:00
|
|
|
AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(), PLACE_1_MODULE, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_ALL_MODULES:
|
|
|
|
AutoPlaceModule( NULL, PLACE_ALL, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_NEW_MODULES:
|
|
|
|
AutoPlaceModule( NULL, PLACE_OUT_OF_BOARD, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE:
|
|
|
|
AutoPlaceModule( NULL, PLACE_INCREMENTAL, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES:
|
2011-09-07 19:41:04 +00:00
|
|
|
AutoMoveModulesOnPcb( false );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES:
|
2011-03-09 14:30:39 +00:00
|
|
|
AutoMoveModulesOnPcb( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES:
|
|
|
|
Autoroute( &dc, ROUTE_ALL );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_MODULE:
|
|
|
|
Autoroute( &dc, ROUTE_MODULE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_PAD:
|
|
|
|
Autoroute( &dc, ROUTE_PAD );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_NET:
|
|
|
|
Autoroute( &dc, ROUTE_NET );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED:
|
|
|
|
Reset_Noroutable( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-09 14:30:39 +00:00
|
|
|
wxMessageBox( wxT( "AutoPlace command error" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
|
2009-06-11 14:26:17 +00:00
|
|
|
Compile_Ratsnest( &dc, true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-08-11 18:17:12 +00:00
|
|
|
/* Function to move components in a rectangular area format 4 / 3,
|
|
|
|
* starting from the mouse cursor
|
|
|
|
* The components with the FIXED status set are not moved
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-26 17:47:35 +00:00
|
|
|
std::vector <MODULE*> moduleList;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint start, current;
|
|
|
|
int Ymax_size, Xsize_allowed;
|
2009-11-12 15:43:38 +00:00
|
|
|
int pas_grille = (int) GetScreen()->GetGridSize().x;
|
2010-11-26 17:47:35 +00:00
|
|
|
double surface;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-13 20:42:42 +00:00
|
|
|
// Undo: init list
|
|
|
|
PICKED_ITEMS_LIST newList;
|
|
|
|
newList.m_Status = UR_CHANGED;
|
|
|
|
ITEM_PICKER picker( NULL, UR_CHANGED );
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
DisplayError( this, _( "No modules found!" ) );
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Confirmation */
|
2009-11-12 15:43:38 +00:00
|
|
|
if( !IsOK( this, _( "Move modules?" ) ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
EDA_RECT bbbox = GetBoard()->ComputeBoundingBox( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
bool edgesExist = ( bbbox.GetWidth() || bbbox.GetHeight() );
|
|
|
|
|
|
|
|
// no edges exist
|
|
|
|
if( PlaceModulesHorsPcb && !edgesExist )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this,
|
2010-06-19 10:58:50 +00:00
|
|
|
_( "Could not automatically place modules. No board outlines detected." ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
// Build sorted footprints list (sort by decreasing size )
|
|
|
|
MODULE* Module = GetBoard()->m_Modules;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
2010-11-26 17:47:35 +00:00
|
|
|
moduleList.push_back(Module);
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
sort( moduleList.begin(), moduleList.end(), sortModulesbySize );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
/* to move modules outside the board, the cursor is placed below
|
|
|
|
* the current board, to avoid placing components in board area.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( PlaceModulesHorsPcb && edgesExist )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( GetScreen()->GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) )
|
2011-02-16 19:16:38 +00:00
|
|
|
{
|
|
|
|
wxPoint pos = GetScreen()->GetCrossHairPosition();
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
pos.y = bbbox.GetBottom() + 2000;
|
2011-02-16 19:16:38 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
/* calculate the area needed by footprints */
|
2007-08-20 01:20:48 +00:00
|
|
|
surface = 0.0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-26 17:47:35 +00:00
|
|
|
Module = moduleList[ii];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( PlaceModulesHorsPcb && edgesExist )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( bbbox.Contains( Module->m_Pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
surface += Module->m_Surface;
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
start = current = GetScreen()->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
Ymax_size = 0;
|
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-26 17:47:35 +00:00
|
|
|
Module = moduleList[ii];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-09-09 02:27:03 +00:00
|
|
|
if( Module->IsLocked() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( PlaceModulesHorsPcb && edgesExist )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( bbbox.Contains( Module->m_Pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-13 20:42:42 +00:00
|
|
|
// Undo: add copy of old Module to undo
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetItem( Module );
|
|
|
|
picker.SetLink( Module->Clone() );
|
2011-12-13 20:42:42 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( current.x > (Xsize_allowed + start.x) )
|
|
|
|
{
|
|
|
|
current.x = start.x;
|
|
|
|
current.y += Ymax_size + pas_grille;
|
|
|
|
Ymax_size = 0;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( current + Module->m_Pos -
|
2011-09-01 21:39:38 +00:00
|
|
|
Module->m_BoundaryBox.GetPosition() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-03 15:43:15 +00:00
|
|
|
Ymax_size = std::max( Ymax_size, Module->m_BoundaryBox.GetHeight() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
PlaceModule( Module, NULL, true );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-13 20:42:42 +00:00
|
|
|
// Undo: add new Module to undo
|
|
|
|
newList.PushItem( picker );
|
|
|
|
|
2011-09-01 21:39:38 +00:00
|
|
|
current.x += Module->m_BoundaryBox.GetWidth() + pas_grille;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-12-13 20:42:42 +00:00
|
|
|
// Undo: commit
|
|
|
|
if( newList.GetCount() )
|
|
|
|
SaveCopyInUndoList( newList, UR_CHANGED );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
/* Set or reset (true or false) Lock attribute of aModule or all modules if aModule == NULL
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-09 14:30:39 +00:00
|
|
|
void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
if( aModule )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
aModule->SetLocked( aLocked );
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( aModule );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
aModule = GetBoard()->m_Modules;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
for( ; aModule != NULL; aModule = aModule->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( WildCompareString( ModulesMaskSelection, aModule->m_Reference->m_Text ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
aModule->SetLocked( aLocked );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-26 17:47:35 +00:00
|
|
|
static bool sortModulesbySize( MODULE* ref, MODULE* compare )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-26 17:47:35 +00:00
|
|
|
return compare->m_Surface < ref->m_Surface;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|