2011-11-10 15:55:05 +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>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
2017-05-25 07:05:35 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-11-10 15:55:05 +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 block_module_editor.cpp
|
|
|
|
* @brief Footprint editor block handling implementation.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <block_commande.h>
|
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <module_editor_frame.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_mire.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_dimension.h>
|
|
|
|
#include <class_edge_mod.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
#include <dialogs/dialog_move_exact.h>
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#define BLOCK_COLOR BROWN
|
|
|
|
|
2012-02-19 19:53:11 +00:00
|
|
|
// Functions defined here, but used also in other files
|
2015-02-12 03:22:24 +00:00
|
|
|
// These 3 functions are used in modedit to rotate, mirror or move the
|
|
|
|
// whole footprint so they are called with force_all = true
|
2012-02-19 19:53:11 +00:00
|
|
|
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
|
|
|
|
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
|
2015-02-12 03:22:24 +00:00
|
|
|
void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
|
|
|
|
const wxPoint& translation, double rotation,
|
|
|
|
bool force_all = false );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-19 19:53:11 +00:00
|
|
|
// Local functions:
|
2011-02-03 19:27:28 +00:00
|
|
|
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2011-03-29 19:33:07 +00:00
|
|
|
static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ClearMarkItems( MODULE* module );
|
2015-03-22 09:42:41 +00:00
|
|
|
static void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement );
|
2007-08-20 01:20:48 +00:00
|
|
|
static void MoveMarkedItems( MODULE* module, wxPoint offset );
|
|
|
|
static void DeleteMarkedItems( MODULE* module );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
int FOOTPRINT_EDIT_FRAME::BlockCommand( EDA_KEY key )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int cmd;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
switch( key )
|
|
|
|
{
|
|
|
|
default:
|
2014-09-24 16:42:56 +00:00
|
|
|
cmd = key & 0xFF;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
case EDA_KEY_C( 0xffffffff ): // -1
|
|
|
|
// Historically, -1 has been used as a key, which can cause bit flag
|
|
|
|
// clashes with unaware code. On debug builds, catch any old code that
|
|
|
|
// might still be doing this. TODO: remove if sure all this old code is gone.
|
|
|
|
wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" );
|
|
|
|
// fall through on release builds
|
|
|
|
|
|
|
|
case GR_KEY_INVALID:
|
2007-08-20 01:20:48 +00:00
|
|
|
cmd = BLOCK_PRESELECT_MOVE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case 0:
|
|
|
|
cmd = BLOCK_MOVE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_ALT:
|
|
|
|
cmd = BLOCK_MIRROR_Y;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_SHIFTCTRL:
|
|
|
|
cmd = BLOCK_DELETE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_SHIFT:
|
|
|
|
cmd = BLOCK_COPY;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_CTRL:
|
|
|
|
cmd = BLOCK_ROTATE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case MOUSE_MIDDLE:
|
|
|
|
cmd = BLOCK_ZOOM;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return cmd;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
int itemsCount = 0;
|
|
|
|
bool nextcmd = false;
|
|
|
|
MODULE* currentModule = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-03-22 09:42:41 +00:00
|
|
|
// Set the SELECTED flag of all preselected items, and clear preselect list
|
|
|
|
ClearMarkItems( currentModule );
|
|
|
|
PICKED_ITEMS_LIST* list = &GetScreen()->m_BlockLocate.GetItems();
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii );
|
|
|
|
item->SetFlags( SELECTED );
|
|
|
|
++itemsCount;
|
|
|
|
}
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
switch( GetScreen()->m_BlockLocate.GetCommand() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
|
|
|
|
break;
|
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
case BLOCK_DRAG: // Drag
|
|
|
|
case BLOCK_DRAG_ITEM: // Drag a given item (not used here)
|
|
|
|
case BLOCK_MOVE: // Move
|
|
|
|
case BLOCK_COPY: // Copy
|
|
|
|
case BLOCK_COPY_AND_INCREMENT: // Specific to duplicate with increment command
|
|
|
|
|
|
|
|
// Find selected items if we didn't already set them manually
|
|
|
|
if( itemsCount == 0 )
|
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( itemsCount )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
nextcmd = true;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
|
|
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
|
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2012-03-26 23:47:08 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
case BLOCK_MOVE_EXACT:
|
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
|
|
|
|
|
|
|
if( itemsCount )
|
|
|
|
{
|
2017-04-22 20:07:29 +00:00
|
|
|
MOVE_PARAMETERS params;
|
|
|
|
params.allowOverride = false;
|
|
|
|
|
|
|
|
DIALOG_MOVE_EXACT dialog( this, params );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
|
|
|
int ret = dialog.ShowModal();
|
|
|
|
|
2015-02-22 14:43:44 +00:00
|
|
|
if( ret == wxID_OK )
|
2015-02-12 03:22:24 +00:00
|
|
|
{
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2017-04-22 20:07:29 +00:00
|
|
|
wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre();
|
|
|
|
|
|
|
|
wxPoint origin;
|
|
|
|
|
|
|
|
switch( params.origin )
|
|
|
|
{
|
|
|
|
case RELATIVE_TO_USER_ORIGIN:
|
|
|
|
origin = GetScreen()->m_O_Curseur;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RELATIVE_TO_GRID_ORIGIN:
|
|
|
|
origin = GetGridOrigin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RELATIVE_TO_DRILL_PLACE_ORIGIN:
|
|
|
|
origin = GetAuxOrigin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RELATIVE_TO_SHEET_ORIGIN:
|
|
|
|
origin = wxPoint( 0, 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RELATIVE_TO_CURRENT_POSITION:
|
|
|
|
// relative movement means that only the translation values should be used:
|
|
|
|
// -> set origin and blockCentre to zero
|
|
|
|
origin = wxPoint( 0, 0 );
|
|
|
|
blockCentre = wxPoint( 0, 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint finalMoveVector = params.translation + origin - blockCentre;
|
|
|
|
|
|
|
|
MoveMarkedItemsExactly( currentModule, blockCentre, finalMoveVector, params.rotation );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
2010-11-13 11:02:24 +00:00
|
|
|
nextcmd = true;
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_DELETE: // Delete
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( itemsCount )
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
DeleteMarkedItems( currentModule );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_SAVE: // Save
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_PASTE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( itemsCount )
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_FLIP: // mirror
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( itemsCount )
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_ZOOM: // Window Zoom
|
2009-07-25 04:53:39 +00:00
|
|
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( !nextcmd )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
ClearMarkItems( currentModule );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
GetScreen()->ClearBlockCommand();
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
|
2012-03-26 23:47:08 +00:00
|
|
|
false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
return nextcmd;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
MODULE* currentModule = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( !m_canvas->IsMouseCaptured() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
|
|
|
|
|
|
|
|
switch( command )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_DRAG: // Drag
|
|
|
|
case BLOCK_MOVE: // Move
|
|
|
|
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2012-03-26 23:47:08 +00:00
|
|
|
MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
case BLOCK_COPY: // Copy
|
2016-06-01 09:28:07 +00:00
|
|
|
case BLOCK_COPY_AND_INCREMENT: // Copy and increment pad names
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2015-03-22 09:42:41 +00:00
|
|
|
CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(),
|
|
|
|
command == BLOCK_COPY_AND_INCREMENT );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_PASTE: // Paste
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_FLIP: // Mirror by popup menu, from block move
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2010-11-13 11:02:24 +00:00
|
|
|
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_CHANGED );
|
2010-11-13 11:02:24 +00:00
|
|
|
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: // Handled by HandleBlockEnd
|
|
|
|
case BLOCK_DELETE:
|
|
|
|
case BLOCK_SAVE:
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK );
|
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
|
|
|
|
m_canvas->Refresh( true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Traces the outline of the search block structures
|
|
|
|
* The entire block follows the cursor
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2015-03-13 16:48:42 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
wxASSERT( moduleEditFrame );
|
|
|
|
MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
|
2011-02-03 19:27:28 +00:00
|
|
|
GRSetDrawMode( aDC, g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( currentModule )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint move_offset = -block->GetMoveVector();
|
2013-03-18 19:36:07 +00:00
|
|
|
BOARD_ITEM* item = currentModule->GraphicalItems();
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
|
|
|
case PCB_MODULE_EDGE_T:
|
2011-02-03 19:27:28 +00:00
|
|
|
item->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
D_PAD* pad = currentModule->Pads();
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !pad->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Repaint new view.
|
|
|
|
block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( currentModule )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
BOARD_ITEM* item = currentModule->GraphicalItems();
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint move_offset = - block->GetMoveVector();
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
|
|
|
case PCB_MODULE_EDGE_T:
|
2011-02-03 19:27:28 +00:00
|
|
|
item->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
D_PAD* pad = currentModule->Pads();
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !pad->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
|
|
|
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Copy marked items, at new position = old position + offset
|
|
|
|
*/
|
2015-03-22 09:42:41 +00:00
|
|
|
void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2014-09-27 16:39:18 +00:00
|
|
|
// Reference and value cannot be copied, they are unique.
|
|
|
|
// Ensure they are not selected
|
|
|
|
module->Reference().ClearFlags();
|
|
|
|
module->Value().ClearFlags();
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !pad->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
pad->ClearFlags( SELECTED );
|
2012-01-14 19:50:32 +00:00
|
|
|
D_PAD* NewPad = new D_PAD( *pad );
|
|
|
|
NewPad->SetParent( module );
|
2011-12-21 13:42:02 +00:00
|
|
|
NewPad->SetFlags( SELECTED );
|
2013-03-18 19:36:07 +00:00
|
|
|
module->Pads().PushFront( NewPad );
|
2015-03-22 09:42:41 +00:00
|
|
|
|
|
|
|
if( aIncrement )
|
2016-06-01 09:28:07 +00:00
|
|
|
NewPad->IncrementPadName( true, true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
BOARD_ITEM* newItem;
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
item->ClearFlags( SELECTED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
newItem = (BOARD_ITEM*)item->Clone();
|
|
|
|
newItem->SetParent( module );
|
|
|
|
newItem->SetFlags( SELECTED );
|
2013-03-18 19:36:07 +00:00
|
|
|
module->GraphicalItems().PushFront( newItem );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MoveMarkedItems( module, offset );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Move marked items, at new position = old position + offset
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void MoveMarkedItems( MODULE* module, wxPoint offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2014-09-27 16:39:18 +00:00
|
|
|
if( module->Reference().IsSelected() )
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Reference().Move( offset );
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
if( module->Value().IsSelected() )
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Value().Move( offset );
|
2014-09-27 16:39:18 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
D_PAD* pad = module->Pads();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !pad->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2009-02-18 07:37:53 +00:00
|
|
|
pad->SetPosition( pad->GetPosition() + offset );
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetPos0( pad->GetPos0() + offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
item = module->GraphicalItems();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2015-07-31 19:04:30 +00:00
|
|
|
static_cast<TEXTE_MODULE*>( item )->Move( offset );
|
2014-09-10 15:18:42 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2013-03-18 19:36:07 +00:00
|
|
|
{
|
|
|
|
EDGE_MODULE* em = (EDGE_MODULE*) item;
|
|
|
|
em->SetStart( em->GetStart() + offset );
|
|
|
|
em->SetEnd( em->GetEnd() + offset );
|
|
|
|
em->SetStart0( em->GetStart0() + offset );
|
|
|
|
em->SetEnd0( em->GetEnd0() + offset );
|
|
|
|
}
|
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
ClearMarkItems( module );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Delete marked items
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void DeleteMarkedItems( MODULE* module )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2015-09-26 06:46:25 +00:00
|
|
|
D_PAD* next_pad;
|
|
|
|
BOARD* board = module->GetBoard();
|
|
|
|
|
2015-09-23 23:02:40 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad; pad = next_pad )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
next_pad = pad->Next();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !pad->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2015-09-23 23:02:40 +00:00
|
|
|
if( board )
|
|
|
|
board->PadDelete( pad );
|
|
|
|
else
|
|
|
|
pad->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 06:46:25 +00:00
|
|
|
BOARD_ITEM* next_item;
|
|
|
|
|
2015-09-23 23:02:40 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = next_item )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
next_item = item->Next();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
item->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
// Ref and value can be flagged, but cannot be deleted
|
|
|
|
ClearMarkItems( module );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
/** Mirror marked items, refer to a Vertical axis at position offset
|
2012-02-19 19:53:11 +00:00
|
|
|
* Note: because this function is used in global transform,
|
|
|
|
* if force_all is true, all items will be mirrored
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2012-02-19 19:53:11 +00:00
|
|
|
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
|
2011-11-29 17:25:30 +00:00
|
|
|
wxPoint tmp;
|
2012-02-19 04:02:19 +00:00
|
|
|
wxSize tmpz;
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2014-09-27 16:39:18 +00:00
|
|
|
if( module->Reference().IsSelected() || force_all )
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Reference().Mirror( offset, false );
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
if( module->Value().IsSelected() || force_all )
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Value().Mirror( offset, false );
|
2014-09-27 16:39:18 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-19 19:53:11 +00:00
|
|
|
// Skip pads not selected, i.e. not inside the block to mirror:
|
|
|
|
if( !pad->IsSelected() && !force_all )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
tmp = pad->GetPosition();
|
|
|
|
SETMIRROR( tmp.x );
|
|
|
|
pad->SetPosition( tmp );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetX0( pad->GetPosition().x );
|
|
|
|
|
|
|
|
tmp = pad->GetOffset();
|
2015-06-26 13:41:56 +00:00
|
|
|
tmp.x = -tmp.x;
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetOffset( tmp );
|
|
|
|
|
|
|
|
tmpz = pad->GetDelta();
|
2015-06-26 13:41:56 +00:00
|
|
|
tmpz.x = -tmpz.x;
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetDelta( tmpz );
|
|
|
|
|
2016-11-02 11:55:19 +00:00
|
|
|
pad->SetOrientation( - pad->GetOrientation() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-19 19:53:11 +00:00
|
|
|
// Skip items not selected, i.e. not inside the block to mirror:
|
|
|
|
if( !item->IsSelected() && !force_all )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2015-07-31 19:04:30 +00:00
|
|
|
((EDGE_MODULE*) item)->Mirror( offset, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2015-07-31 19:04:30 +00:00
|
|
|
static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
default:
|
2009-08-12 10:40:01 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
ClearMarkItems( module );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-19 19:53:11 +00:00
|
|
|
/** Rotate marked items, refer to a rotation point at position offset
|
|
|
|
* Note: because this function is used in global transform,
|
|
|
|
* if force_all is true, all items will be rotated
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2012-02-19 19:53:11 +00:00
|
|
|
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
|
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2014-09-27 16:39:18 +00:00
|
|
|
if( module->Reference().IsSelected() || force_all )
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Reference().Rotate( offset, 900 );
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
if( module->Value().IsSelected() || force_all )
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Value().Rotate( offset, 900 );
|
2014-09-27 16:39:18 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-19 19:53:11 +00:00
|
|
|
if( !pad->IsSelected() && !force_all )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2015-02-27 14:33:13 +00:00
|
|
|
wxPoint pos = pad->GetPos0();
|
2011-11-29 17:25:30 +00:00
|
|
|
ROTATE( pos );
|
2015-02-27 14:33:13 +00:00
|
|
|
pad->SetPos0( pos );
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetOrientation( pad->GetOrientation() + 900 );
|
2015-02-27 14:33:13 +00:00
|
|
|
|
|
|
|
pad->SetDrawCoord();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-09-27 16:39:18 +00:00
|
|
|
if( !item->IsSelected() && !force_all )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2015-07-31 19:04:30 +00:00
|
|
|
((EDGE_MODULE*) item)->Rotate( offset, 900 );
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2015-07-31 19:04:30 +00:00
|
|
|
static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
|
2014-09-10 15:18:42 +00:00
|
|
|
break;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
default:
|
2014-09-10 15:18:42 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
ClearMarkItems( module );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
void ClearMarkItems( MODULE* module )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-09-27 16:39:18 +00:00
|
|
|
module->Reference().ClearFlags();
|
|
|
|
module->Value().ClearFlags();
|
|
|
|
|
|
|
|
EDA_ITEM* item = module->GraphicalItems();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
2011-12-21 13:42:02 +00:00
|
|
|
{
|
|
|
|
item->ClearFlags();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
item = module->Pads();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
2011-12-21 13:42:02 +00:00
|
|
|
{
|
|
|
|
item->ClearFlags();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-02-12 03:22:24 +00:00
|
|
|
void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
|
|
|
|
const wxPoint& translation,
|
|
|
|
double rotation, bool force_all )
|
|
|
|
{
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( module->Reference().IsSelected() || force_all )
|
|
|
|
{
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Reference().Rotate( centre, rotation );
|
|
|
|
module->Reference().Move( translation );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( module->Value().IsSelected() || force_all )
|
|
|
|
{
|
2015-07-31 19:04:30 +00:00
|
|
|
module->Value().Rotate( centre, rotation );
|
|
|
|
module->Value().Move( translation );
|
2015-02-12 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
D_PAD* pad = module->Pads();
|
|
|
|
|
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( !pad->IsSelected() && !force_all )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// rotate about centre point,
|
|
|
|
wxPoint newPos = pad->GetPosition();
|
|
|
|
RotatePoint( &newPos, centre, rotation );
|
|
|
|
|
|
|
|
// shift and update
|
|
|
|
newPos += translation;
|
|
|
|
pad->SetPosition( newPos );
|
|
|
|
pad->SetPos0( newPos );
|
|
|
|
|
|
|
|
// finally apply rotation to the pad itself
|
|
|
|
pad->Rotate( newPos, rotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_ITEM* item = module->GraphicalItems();
|
|
|
|
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( !item->IsSelected() && !force_all )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_TEXT_T:
|
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
|
|
|
|
|
2015-07-31 19:04:30 +00:00
|
|
|
text->Rotate( centre, rotation );
|
|
|
|
text->Move( translation );
|
2015-02-12 03:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PCB_MODULE_EDGE_T:
|
|
|
|
{
|
|
|
|
EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
|
|
|
|
em->Rotate( centre, rotation );
|
|
|
|
em->Move( translation );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ClearMarkItems( module );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Mark items inside rect.
|
2007-08-20 01:20:48 +00:00
|
|
|
* Items are inside rect when an end point is inside rect
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
|
|
|
int ItemsCount = 0;
|
|
|
|
wxPoint pos;
|
|
|
|
D_PAD* pad;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return 0;
|
|
|
|
|
2014-09-27 16:39:18 +00:00
|
|
|
ClearMarkItems( module ); // Just in case ...
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
pos = module->Reference().GetTextPos();
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
if( Rect.Contains( pos ) )
|
|
|
|
{
|
|
|
|
module->Reference().SetFlags( SELECTED );
|
|
|
|
ItemsCount++;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
pos = module->Value().GetTextPos();
|
2014-09-27 16:39:18 +00:00
|
|
|
|
|
|
|
if( Rect.Contains( pos ) )
|
|
|
|
{
|
|
|
|
module->Value().SetFlags( SELECTED );
|
|
|
|
ItemsCount++;
|
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
pad = module->Pads();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
pad->ClearFlags( SELECTED );
|
2007-12-01 03:42:52 +00:00
|
|
|
pos = pad->GetPosition();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
if( Rect.Contains( pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
pad->SetFlags( SELECTED );
|
2007-08-20 01:20:48 +00:00
|
|
|
ItemsCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
item = module->GraphicalItems();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
item->ClearFlags( SELECTED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2011-02-27 19:54:01 +00:00
|
|
|
if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
item->SetFlags( SELECTED );
|
2007-08-20 01:20:48 +00:00
|
|
|
ItemsCount++;
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2017-01-23 20:30:11 +00:00
|
|
|
pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
if( Rect.Contains( pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
item->SetFlags( SELECTED );
|
2007-08-20 01:20:48 +00:00
|
|
|
ItemsCount++;
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ItemsCount;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|