56 changed files with 95 additions and 7306 deletions
-
13common/legacy_gal/eda_draw_frame.cpp
-
12common/legacy_wx/eda_draw_frame.cpp
-
277common/legacy_wx/eda_draw_panel.cpp
-
68cvpcb/display_footprints_frame.cpp
-
1cvpcb/display_footprints_frame.h
-
150eeschema/ee_hotkeys.cpp
-
30eeschema/libedit/lib_edit_frame.cpp
-
4eeschema/libedit/lib_edit_frame.h
-
64eeschema/sch_draw_panel.cpp
-
1eeschema/sch_draw_panel.h
-
2eeschema/sch_edit_frame.h
-
33eeschema/viewlib_frame.cpp
-
12eeschema/viewlib_frame.h
-
2gerbview/CMakeLists.txt
-
58gerbview/controle.cpp
-
4gerbview/gerber_collectors.cpp
-
15gerbview/gerbview_frame.h
-
65gerbview/hotkeys.cpp
-
61gerbview/onleftclick.cpp
-
22include/draw_frame.h
-
49include/legacy_wx/class_drawpanel.h
-
32include/pcb_base_frame.h
-
82pagelayout_editor/hotkeys.cpp
-
12pagelayout_editor/pl_editor_frame.h
-
13pcbnew/CMakeLists.txt
-
126pcbnew/attribut.cpp
-
314pcbnew/controle.cpp
-
30pcbnew/drag.h
-
105pcbnew/dragsegm.cpp
-
408pcbnew/edgemod.cpp
-
278pcbnew/edit.cpp
-
284pcbnew/edit_pcb_text.cpp
-
296pcbnew/editedge.cpp
-
232pcbnew/editrack.cpp
-
334pcbnew/edtxtmod.cpp
-
35pcbnew/footprint_edit_frame.cpp
-
82pcbnew/footprint_edit_frame.h
-
275pcbnew/footprint_editor_onclick.cpp
-
201pcbnew/footprint_editor_utils.cpp
-
32pcbnew/footprint_viewer_frame.cpp
-
12pcbnew/footprint_viewer_frame.h
-
36pcbnew/footprint_wizard_frame.cpp
-
12pcbnew/footprint_wizard_frame.h
-
112pcbnew/highlight.cpp
-
104pcbnew/hotkeys.cpp
-
3pcbnew/hotkeys.h
-
512pcbnew/hotkeys_board_editor.cpp
-
127pcbnew/hotkeys_footprint_editor.cpp
-
199pcbnew/microwave.cpp
-
114pcbnew/move-drag_pads.cpp
-
126pcbnew/move_or_drag_track.cpp
-
578pcbnew/onleftclick.cpp
-
209pcbnew/pcb_edit_frame.h
-
272pcbnew/pcb_footprint_edit_utils.cpp
-
25pcbnew/pcbnew_id.h
-
846pcbnew/zones_by_polygon.cpp
@ -1,58 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 1992-2017 <Jean-Pierre Charras> |
|||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file gerbview/controle.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <gerbview_frame.h>
|
|||
|
|||
|
|||
bool GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) |
|||
{ |
|||
// Filter out the 'fake' mouse motion after a keyboard movement
|
|||
if( !aHotKey && m_movingCursorWithKeyboard ) |
|||
{ |
|||
m_movingCursorWithKeyboard = false; |
|||
return false; |
|||
} |
|||
|
|||
wxPoint pos = aPosition; |
|||
wxPoint oldpos = GetCrossHairPosition(); |
|||
bool eventHandled = GeneralControlKeyMovement( aHotKey, &pos, true ); |
|||
|
|||
SetCrossHairPosition( pos ); |
|||
RefreshCrossHair( oldpos, aPosition, aDC ); |
|||
|
|||
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition ) ) |
|||
{ |
|||
eventHandled = true; |
|||
} |
|||
|
|||
UpdateStatusBar(); |
|||
|
|||
return eventHandled; |
|||
} |
@ -1,61 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2014 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 <gerbview.h>
|
|||
#include <gerbview_frame.h>
|
|||
#include <gerber_file_image.h>
|
|||
#include <gerber_file_image_list.h>
|
|||
#include <dialog_helpers.h>
|
|||
#include <gerbview_id.h>
|
|||
|
|||
/* Process the command triggered by the left button of the mouse
|
|||
* currently: just display info in the message panel. |
|||
*/ |
|||
void GERBVIEW_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) |
|||
{ |
|||
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); |
|||
|
|||
GERBER_DRAW_ITEM* DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE ); |
|||
|
|||
GetScreen()->SetCurItem( DrawStruct ); |
|||
|
|||
if( DrawStruct == NULL ) |
|||
{ |
|||
GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() ); |
|||
|
|||
if( gerber ) |
|||
gerber->DisplayImageInfo( this ); |
|||
} |
|||
} |
|||
|
|||
|
|||
/* Called on a double click of left mouse button.
|
|||
*/ |
|||
void GERBVIEW_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) |
|||
{ |
|||
// Currently: no nothing
|
|||
} |
@ -1,126 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> |
|||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file attribut.cpp |
|||
* @brief Track attribute flags editing. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <gr_basic.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <msgpanel.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <protos.h>
|
|||
|
|||
#include <class_track.h>
|
|||
#include <class_board.h>
|
|||
|
|||
|
|||
/* Attribute change for 1 track segment.
|
|||
* Attributes are |
|||
* TRACK_LOCKED protection against global delete |
|||
* TRACK_AR AutoRouted segment |
|||
*/ |
|||
void PCB_EDIT_FRAME::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On ) |
|||
{ |
|||
if( track == NULL ) |
|||
return; |
|||
|
|||
OnModify(); |
|||
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
|||
track->SetState( TRACK_LOCKED, Flag_On ); |
|||
track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT ); |
|||
m_canvas->CrossHairOn( DC ); // Display cursor shape
|
|||
|
|||
MSG_PANEL_ITEMS items; |
|||
track->GetMsgPanelInfo( m_UserUnits, items ); |
|||
SetMsgPanel( items ); |
|||
} |
|||
|
|||
|
|||
/* Attribute change for an entire track */ |
|||
void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) |
|||
{ |
|||
TRACK* Track; |
|||
int nb_segm; |
|||
|
|||
if( track == NULL ) |
|||
return; |
|||
|
|||
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
|||
Track = GetBoard()->MarkTrace( GetBoard()->m_Track, track, &nb_segm, NULL, NULL, true ); |
|||
DrawTraces( m_canvas, DC, Track, nb_segm, GR_OR | GR_HIGHLIGHT ); |
|||
|
|||
for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- ) |
|||
{ |
|||
Track->SetState( TRACK_LOCKED, Flag_On ); |
|||
Track->SetState( BUSY, false ); |
|||
Track = Track->Next(); |
|||
} |
|||
|
|||
m_canvas->CrossHairOn( DC ); // Display cursor shape
|
|||
|
|||
OnModify(); |
|||
} |
|||
|
|||
|
|||
/* Modify the flag TRACK_LOCKED according to Flag_On value,
|
|||
* for all the segments related to net_code. |
|||
* if net_code < 0 all the segments are modified. |
|||
*/ |
|||
void PCB_EDIT_FRAME::Attribut_net( wxDC* DC, int net_code, bool Flag_On ) |
|||
{ |
|||
TRACK* Track = GetBoard()->m_Track; |
|||
|
|||
/* search the first segment for the selected net_code */ |
|||
if( net_code >= 0 ) |
|||
{ |
|||
for( ; Track != NULL; Track = Track->Next() ) |
|||
{ |
|||
if( net_code == Track->GetNetCode() ) |
|||
break; |
|||
} |
|||
} |
|||
|
|||
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
|||
|
|||
while( Track ) /* Flag change */ |
|||
{ |
|||
if( ( net_code >= 0 ) && ( net_code != Track->GetNetCode() ) ) |
|||
break; |
|||
|
|||
OnModify(); |
|||
Track->SetState( TRACK_LOCKED, Flag_On ); |
|||
Track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT ); |
|||
Track = Track->Next(); |
|||
} |
|||
|
|||
m_canvas->CrossHairOn( DC ); // Display cursor shape
|
|||
OnModify(); |
|||
} |
@ -1,314 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* 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> |
|||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file pcbnew/controle.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <pcbnew_id.h>
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_zone.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <protos.h>
|
|||
#include <collectors.h>
|
|||
#include <menus_helpers.h>
|
|||
|
|||
//external functions used here:
|
|||
extern bool Magnetize( PCB_BASE_EDIT_FRAME* frame, int aCurrentTool, |
|||
wxSize aGridSize, wxPoint on_grid, wxPoint* curpos ); |
|||
|
|||
|
|||
/**
|
|||
* Function AllAreModulesAndReturnSmallestIfSo |
|||
* tests that all items in the collection are MODULEs and if so, returns the |
|||
* smallest MODULE. |
|||
* @return BOARD_ITEM* - The smallest or NULL. |
|||
*/ |
|||
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector ) |
|||
{ |
|||
#if 0 // Dick: this is not consistent with name of this function, and does not
|
|||
// work correctly using 'M' (move hotkey) when another module's (2nd module) reference
|
|||
// is under a module (first module) and you want to move the reference.
|
|||
// Another way to fix this would be to
|
|||
// treat module text as copper layer content, and put the module text into
|
|||
// the primary list. I like the coded behavior best. If it breaks something
|
|||
// perhaps you need a different test before calling this function, which should
|
|||
// do what its name says it does.
|
|||
int count = aCollector->GetPrimaryCount(); // try to use preferred layer
|
|||
if( 0 == count ) count = aCollector->GetCount(); |
|||
#else
|
|||
int count = aCollector->GetCount(); |
|||
#endif
|
|||
|
|||
for( int i = 0; i<count; ++i ) |
|||
{ |
|||
if( (*aCollector)[i]->Type() != PCB_MODULE_T ) |
|||
return NULL; |
|||
} |
|||
|
|||
// all are modules, now find smallest MODULE
|
|||
|
|||
int minDim = 0x7FFFFFFF; |
|||
int minNdx = 0; |
|||
|
|||
for( int i = 0; i<count; ++i ) |
|||
{ |
|||
MODULE* module = (MODULE*) (*aCollector)[i]; |
|||
|
|||
int lx = module->GetBoundingBox().GetWidth(); |
|||
int ly = module->GetBoundingBox().GetHeight(); |
|||
|
|||
int lmin = std::min( lx, ly ); |
|||
|
|||
if( lmin < minDim ) |
|||
{ |
|||
minDim = lmin; |
|||
minNdx = i; |
|||
} |
|||
} |
|||
|
|||
return (*aCollector)[minNdx]; |
|||
} |
|||
|
|||
|
|||
// JEY TODO: RETIRE THIS
|
|||
BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) |
|||
{ |
|||
BOARD_ITEM* item; |
|||
|
|||
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide(); |
|||
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( GetDisplayOptions() ); |
|||
|
|||
// Assign to scanList the proper item types desired based on tool type
|
|||
// or hotkey that is in play.
|
|||
|
|||
const KICAD_T* scanList = NULL; |
|||
|
|||
if( aHotKeyCode ) |
|||
{ |
|||
// @todo: add switch here and add calls to PcbGeneralLocateAndDisplay( int aHotKeyCode )
|
|||
// when searching is needed from a hotkey handler
|
|||
} |
|||
else if( GetToolId() == ID_NO_TOOL_SELECTED ) |
|||
{ |
|||
scanList = (displ_opts->m_DisplayZonesMode == 0) ? |
|||
GENERAL_COLLECTOR::AllBoardItems : |
|||
GENERAL_COLLECTOR::AllButZones; |
|||
} |
|||
else |
|||
{ |
|||
switch( GetToolId() ) |
|||
{ |
|||
case ID_LOCAL_RATSNEST_BUTT: |
|||
scanList = GENERAL_COLLECTOR::PadsOrModules; |
|||
break; |
|||
|
|||
case ID_TRACK_BUTT: |
|||
scanList = GENERAL_COLLECTOR::Tracks; |
|||
break; |
|||
|
|||
case ID_PCB_MODULE_BUTT: |
|||
scanList = GENERAL_COLLECTOR::Modules; |
|||
break; |
|||
|
|||
case ID_PCB_ZONES_BUTT: |
|||
case ID_PCB_KEEPOUT_BUTT: |
|||
scanList = GENERAL_COLLECTOR::Zones; |
|||
break; |
|||
|
|||
default: |
|||
scanList = displ_opts->m_DisplayZonesMode == 0 ? |
|||
GENERAL_COLLECTOR::AllBoardItems : |
|||
GENERAL_COLLECTOR::AllButZones; |
|||
} |
|||
} |
|||
|
|||
m_Collector->Collect( m_Pcb, scanList, RefPos( true ), guide ); |
|||
|
|||
#if 0
|
|||
// debugging: print out the collected items, showing their priority order too.
|
|||
for( int i = 0; i<m_Collector->GetCount(); ++i ) |
|||
(*m_Collector)[i]->Show( 0, std::cout ); |
|||
#endif
|
|||
|
|||
// Trigger the selection of the current edge for zones
|
|||
for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) |
|||
{ |
|||
item = (*m_Collector)[ii]; |
|||
|
|||
if( item->Type() == PCB_ZONE_AREA_T ) |
|||
{ |
|||
// We need to do the selection now because the menu text depends on it
|
|||
ZONE_CONTAINER *zone = static_cast<ZONE_CONTAINER*>( item ); |
|||
int accuracy = KiROUND( 5 * guide.OnePixelInIU() ); |
|||
zone->SetSelectedCorner( RefPos( true ), accuracy ); |
|||
} |
|||
} |
|||
|
|||
if( m_Collector->GetCount() <= 1 ) |
|||
{ |
|||
item = (*m_Collector)[0]; |
|||
SetCurItem( item ); |
|||
} |
|||
|
|||
// If the count is 2, and first item is a pad or module text, and the 2nd item is its
|
|||
// parent module:
|
|||
else if( m_Collector->GetCount() == 2 |
|||
&& ( (*m_Collector)[0]->Type() == PCB_PAD_T || (*m_Collector)[0]->Type() == |
|||
PCB_MODULE_TEXT_T ) |
|||
&& (*m_Collector)[1]->Type() == PCB_MODULE_T && (*m_Collector)[0]->GetParent()== |
|||
(*m_Collector)[1] ) |
|||
{ |
|||
item = (*m_Collector)[0]; |
|||
SetCurItem( item ); |
|||
} |
|||
// if all are modules, find the smallest one among the primary choices
|
|||
else if( ( item = AllAreModulesAndReturnSmallestIfSo( m_Collector ) ) != NULL ) |
|||
{ |
|||
SetCurItem( item ); |
|||
} |
|||
|
|||
else // we can't figure out which item user wants, do popup menu so user can choose
|
|||
{ |
|||
wxMenu itemMenu; |
|||
|
|||
// Give a title to the selection menu. This is also a cancel menu item
|
|||
AddMenuItem( &itemMenu, wxID_NONE, _( "Clarify Selection" ), |
|||
KiBitmap( info_xpm ) ); |
|||
itemMenu.AppendSeparator(); |
|||
|
|||
int limit = std::min( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() ); |
|||
|
|||
for( int i = 0; i<limit; ++i ) |
|||
{ |
|||
wxString text; |
|||
item = (*m_Collector)[i]; |
|||
|
|||
text = item->GetSelectMenuText( m_UserUnits ); |
|||
|
|||
BITMAP_DEF xpm = item->GetMenuImage(); |
|||
|
|||
AddMenuItem( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + i, text, KiBitmap( xpm ) ); |
|||
} |
|||
|
|||
/* @todo: rather than assignment to true, these should be increment and decrement
|
|||
* operators throughout _everywhere_. |
|||
* That way we can handle nesting. |
|||
* But I tried that and found there cases where the assignment to true (converted to |
|||
* a m_IgnoreMouseEvents++ ) |
|||
* was not balanced with the -- (now m_IgnoreMouseEvents=false), so I had to revert. |
|||
* Somebody should track down these and make them balanced. |
|||
* m_canvas->SetIgnoreMouseEvents( true ); |
|||
*/ |
|||
|
|||
// this menu's handler is void PCB_BASE_FRAME::ProcessItemSelection()
|
|||
// and it calls SetCurItem() which in turn calls DisplayInfo() on the item.
|
|||
m_canvas->SetAbortRequest( true ); // changed in false if an item is selected
|
|||
PopupMenu( &itemMenu ); |
|||
|
|||
m_canvas->MoveCursorToCrossHair(); |
|||
|
|||
// The function ProcessItemSelection() has set the current item, return it.
|
|||
if( m_canvas->GetAbortRequest() ) // Nothing selected
|
|||
item = NULL; |
|||
else |
|||
item = GetCurItem(); |
|||
} |
|||
|
|||
return item; |
|||
} |
|||
|
|||
|
|||
bool PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) |
|||
{ |
|||
// Filter out the 'fake' mouse motion after a keyboard movement
|
|||
if( !aHotKey && m_movingCursorWithKeyboard ) |
|||
{ |
|||
m_movingCursorWithKeyboard = false; |
|||
return false; |
|||
} |
|||
|
|||
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
|
|||
// for next cursor position
|
|||
// ( shift or ctrl key down are PAN command with mouse wheel)
|
|||
bool snapToGrid = true; |
|||
|
|||
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) |
|||
snapToGrid = false; |
|||
|
|||
wxPoint oldpos = GetCrossHairPosition(); |
|||
wxPoint pos = aPosition; |
|||
bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); |
|||
|
|||
// Put cursor in new position, according to the zoom keys (if any).
|
|||
SetCrossHairPosition( pos, snapToGrid ); |
|||
|
|||
/* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the
|
|||
* cursor is left off grid this is better to reach items to delete off grid, |
|||
*/ |
|||
if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT ) |
|||
snapToGrid = false; |
|||
|
|||
wxPoint curs_pos = pos; |
|||
|
|||
wxRealPoint gridSize = GetScreen()->GetGridSize(); |
|||
wxSize igridsize; |
|||
igridsize.x = KiROUND( gridSize.x ); |
|||
igridsize.y = KiROUND( gridSize.y ); |
|||
|
|||
if( Magnetize( this, GetToolId(), igridsize, curs_pos, &pos ) ) |
|||
{ |
|||
SetCrossHairPosition( pos, false ); |
|||
} |
|||
else |
|||
{ |
|||
// If there's no intrusion and DRC is active, we pass the cursor
|
|||
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
|
|||
if( !Settings().m_legacyDrcOn || !g_CurrentTrackSegment || |
|||
(BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() || |
|||
!LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, |
|||
GetScreen()->m_Active_Layer, RefPos( true ) ) ) |
|||
{ |
|||
SetCrossHairPosition( curs_pos, snapToGrid ); |
|||
} |
|||
} |
|||
|
|||
RefreshCrossHair( oldpos, aPosition, aDC ); |
|||
|
|||
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition ) ) |
|||
{ |
|||
keyHandled = true; |
|||
} |
|||
|
|||
UpdateStatusBar(); // Display new cursor coordinates
|
|||
|
|||
return keyHandled; |
|||
} |
@ -1,408 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net> |
|||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file edgemod.cpp: |
|||
* @brief Functions to edit graphic items used to draw footprint edges. |
|||
* |
|||
* @todo - Arc functions not compete but menus are ready to use. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <trigo.h>
|
|||
#include <gr_basic.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <base_units.h>
|
|||
#include <dialog_text_entry.h>
|
|||
|
|||
#include <footprint_edit_frame.h>
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_edge_mod.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
|
|||
|
|||
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool erase ); |
|||
static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC ); |
|||
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, |
|||
const wxPoint& aPosition, bool aErase ); |
|||
|
|||
static double ArcValue = 900; |
|||
static wxPoint MoveVector; // Move vector for move edge
|
|||
static wxPoint CursorInitialPosition; // Mouse cursor initial position for move command
|
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* aEdge, wxDC* DC ) |
|||
{ |
|||
if( aEdge == NULL ) |
|||
return; |
|||
|
|||
aEdge->Draw( m_canvas, DC, GR_XOR ); |
|||
aEdge->SetFlags( IS_MOVED ); |
|||
MoveVector.x = MoveVector.y = 0; |
|||
CursorInitialPosition = GetCrossHairPosition(); |
|||
m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline ); |
|||
SetCurItem( aEdge ); |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* aEdge ) |
|||
{ |
|||
if( aEdge == NULL ) |
|||
return; |
|||
|
|||
aEdge->Move( -MoveVector ); |
|||
|
|||
aEdge->ClearFlags(); |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
SetCurItem( NULL ); |
|||
OnModify(); |
|||
|
|||
MODULE* module = (MODULE*) aEdge->GetParent(); |
|||
module->CalculateBoundingBox(); |
|||
|
|||
m_canvas->Refresh( ); |
|||
} |
|||
|
|||
|
|||
/* Redraw the current moved graphic item when mouse is moving
|
|||
* Use this function to show an existing outline, in move command |
|||
*/ |
|||
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, |
|||
const wxPoint& aPosition, bool aErase ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem(); |
|||
|
|||
if( edge == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = (MODULE*) edge->GetParent(); |
|||
|
|||
if( aErase ) |
|||
{ |
|||
edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); |
|||
} |
|||
|
|||
MoveVector = -(aPanel->GetParent()->GetCrossHairPosition() - CursorInitialPosition); |
|||
|
|||
edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); |
|||
|
|||
module->CalculateBoundingBox(); |
|||
} |
|||
|
|||
|
|||
/* Redraw the current graphic item during its creation
|
|||
* Use this function to show a new outline, in begin command |
|||
*/ |
|||
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem(); |
|||
|
|||
if( edge == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = (MODULE*) edge->GetParent(); |
|||
|
|||
// if( erase )
|
|||
{ |
|||
edge->Draw( aPanel, aDC, GR_XOR ); |
|||
} |
|||
|
|||
edge->SetEnd( aPanel->GetParent()->GetCrossHairPosition() ); |
|||
|
|||
// Update relative coordinate.
|
|||
edge->SetEnd0( edge->GetEnd() - module->GetPosition() ); |
|||
|
|||
wxPoint pt( edge->GetEnd0() ); |
|||
|
|||
RotatePoint( &pt, -module->GetOrientation() ); |
|||
|
|||
edge->SetEnd0( pt ); |
|||
|
|||
edge->Draw( aPanel, aDC, GR_XOR ); |
|||
|
|||
module->CalculateBoundingBox(); |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge ) |
|||
{ |
|||
MODULE* module = GetBoard()->m_Modules; |
|||
|
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
|
|||
if( aEdge == NULL ) |
|||
{ |
|||
for( BOARD_ITEM *item = module->GraphicalItemsList(); item; item = item->Next() ) |
|||
{ |
|||
aEdge = dyn_cast<EDGE_MODULE*>( item ); |
|||
|
|||
if( aEdge ) |
|||
aEdge->SetWidth( GetDesignSettings().GetLineThickness( aEdge->GetLayer() ) ); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
aEdge->SetWidth( GetDesignSettings().GetLineThickness( aEdge->GetLayer() ) ); |
|||
} |
|||
|
|||
OnModify(); |
|||
module->CalculateBoundingBox(); |
|||
module->SetLastEditTime(); |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge ) |
|||
{ |
|||
// note: if aEdge == NULL, all outline segments will be modified
|
|||
|
|||
MODULE* module = GetBoard()->m_Modules; |
|||
PCB_LAYER_ID layer = F_SilkS; |
|||
bool modified = false; |
|||
|
|||
if( aEdge ) |
|||
layer = aEdge->GetLayer(); |
|||
|
|||
// Ask for the new layer
|
|||
PCB_LAYER_ID new_layer = SelectLayer( layer, Edge_Cuts ); |
|||
|
|||
if( layer < 0 ) |
|||
return; |
|||
|
|||
if( IsCopperLayer( new_layer ) ) |
|||
{ |
|||
// an edge is put on a copper layer, and it is very dangerous.
|
|||
// A confirmation is requested
|
|||
if( !IsOK( this, |
|||
_( "The graphic item will be on a copper layer.\n" |
|||
"This is very dangerous. Are you sure?" ) ) ) |
|||
return; |
|||
} |
|||
|
|||
if( !aEdge ) |
|||
{ |
|||
for( BOARD_ITEM *item = module->GraphicalItemsList() ; item != NULL; |
|||
item = item->Next() ) |
|||
{ |
|||
aEdge = dyn_cast<EDGE_MODULE*>( item ); |
|||
|
|||
if( aEdge && (aEdge->GetLayer() != new_layer) ) |
|||
{ |
|||
if( ! modified ) // save only once
|
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
aEdge->SetLayer( new_layer ); |
|||
modified = true; |
|||
} |
|||
} |
|||
} |
|||
else if( aEdge->GetLayer() != new_layer ) |
|||
{ |
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
aEdge->SetLayer( new_layer ); |
|||
modified = true; |
|||
} |
|||
|
|||
if( modified ) |
|||
{ |
|||
module->CalculateBoundingBox(); |
|||
module->SetLastEditTime(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* aEdge ) |
|||
{ |
|||
if( aEdge == NULL ) |
|||
return; |
|||
|
|||
if( aEdge->Type() != PCB_MODULE_EDGE_T ) |
|||
{ |
|||
wxLogDebug( wxT( "StructType error: PCB_MODULE_EDGE_T expected" ) ); |
|||
return; |
|||
} |
|||
|
|||
MODULE* module = (MODULE*) aEdge->GetParent(); |
|||
|
|||
// Delete segment.
|
|||
aEdge->DeleteStructure(); |
|||
module->SetLastEditTime(); |
|||
module->CalculateBoundingBox(); |
|||
OnModify(); |
|||
} |
|||
|
|||
|
|||
/* abort function in moving outline.
|
|||
*/ |
|||
static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC ) |
|||
{ |
|||
EDGE_MODULE* edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem(); |
|||
|
|||
Panel->SetMouseCapture( NULL, NULL ); |
|||
|
|||
if( edge && ( edge->Type() == PCB_MODULE_EDGE_T ) ) |
|||
{ |
|||
if( edge->IsNew() ) // On aborting, delete new outline.
|
|||
{ |
|||
MODULE* module = (MODULE*) edge->GetParent(); |
|||
edge->Draw( Panel, DC, GR_XOR, MoveVector ); |
|||
edge->DeleteStructure(); |
|||
module->CalculateBoundingBox(); |
|||
} |
|||
else // On aborting, move existing outline to its initial position.
|
|||
{ |
|||
edge->Draw( Panel, DC, GR_XOR, MoveVector ); |
|||
edge->ClearFlags(); |
|||
edge->Draw( Panel, DC, GR_OR ); |
|||
} |
|||
} |
|||
|
|||
Panel->GetScreen()->SetCurItem( NULL ); |
|||
} |
|||
|
|||
|
|||
EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge, |
|||
wxDC* DC, |
|||
STROKE_T type_edge ) |
|||
{ |
|||
MODULE* module = GetBoard()->m_Modules; |
|||
|
|||
if( module == NULL ) |
|||
return NULL; |
|||
|
|||
if( aEdge == NULL ) // Start a new edge item
|
|||
{ |
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
|
|||
aEdge = new EDGE_MODULE( module ); |
|||
MoveVector.x = MoveVector.y = 0; |
|||
|
|||
// Add the new item to the Drawings list head
|
|||
module->GraphicalItemsList().PushFront( aEdge ); |
|||
|
|||
// Update characteristics of the segment or arc.
|
|||
aEdge->SetFlags( IS_NEW ); |
|||
aEdge->SetAngle( 0 ); |
|||
aEdge->SetShape( type_edge ); |
|||
|
|||
if( aEdge->GetShape() == S_ARC ) |
|||
aEdge->SetAngle( ArcValue ); |
|||
|
|||
aEdge->SetWidth( GetDesignSettings().GetLineThickness( GetActiveLayer() ) ); |
|||
aEdge->SetLayer( GetActiveLayer() ); |
|||
|
|||
// Initialize the starting point of the new segment or arc
|
|||
aEdge->SetStart( GetCrossHairPosition() ); |
|||
|
|||
// Initialize the ending point of the new segment or arc
|
|||
aEdge->SetEnd( aEdge->GetStart() ); |
|||
|
|||
// Initialize the relative coordinates
|
|||
aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() ); |
|||
|
|||
RotatePoint( &aEdge->m_Start0, -module->GetOrientation() ); |
|||
|
|||
aEdge->m_End0 = aEdge->m_Start0; |
|||
module->CalculateBoundingBox(); |
|||
m_canvas->SetMouseCapture( ShowNewEdgeModule, Abort_Move_ModuleOutline ); |
|||
} |
|||
/* Segment creation in progress.
|
|||
* The ending coordinate is updated by the function |
|||
* ShowNewEdgeModule() called on move mouse event |
|||
* during the segment creation |
|||
*/ |
|||
else |
|||
{ |
|||
if( type_edge == S_SEGMENT ) |
|||
{ |
|||
if( aEdge->m_Start0 != aEdge->m_End0 ) |
|||
{ |
|||
aEdge->Draw( m_canvas, DC, GR_OR ); |
|||
|
|||
EDGE_MODULE* newedge = new EDGE_MODULE( *aEdge ); |
|||
|
|||
// insert _after_ aEdge, which is the same as inserting before aEdge->Next()
|
|||
module->GraphicalItemsList().Insert( newedge, aEdge->Next() ); |
|||
aEdge->ClearFlags(); |
|||
|
|||
aEdge = newedge; // point now new item
|
|||
|
|||
aEdge->SetFlags( IS_NEW ); |
|||
aEdge->SetWidth( GetDesignSettings().GetLineThickness( aEdge->GetLayer() ) ); |
|||
aEdge->SetStart( GetCrossHairPosition() ); |
|||
aEdge->SetEnd( aEdge->GetStart() ); |
|||
|
|||
// Update relative coordinate.
|
|||
aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() ); |
|||
|
|||
wxPoint pt( aEdge->GetStart0() ); |
|||
|
|||
RotatePoint( &pt, -module->GetOrientation() ); |
|||
|
|||
aEdge->SetStart0( pt ); |
|||
|
|||
aEdge->SetEnd0( aEdge->GetStart0() ); |
|||
|
|||
module->CalculateBoundingBox(); |
|||
module->SetLastEditTime(); |
|||
OnModify(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
wxLogDebug( wxT( "Begin_Edge() error" ) ); |
|||
} |
|||
} |
|||
|
|||
return aEdge; |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* aEdge ) |
|||
{ |
|||
MODULE* module = GetBoard()->m_Modules; |
|||
|
|||
if( aEdge ) |
|||
{ |
|||
aEdge->ClearFlags(); |
|||
|
|||
// If last segment length is 0: remove it
|
|||
if( aEdge->GetStart() == aEdge->GetEnd() ) |
|||
aEdge->DeleteStructure(); |
|||
} |
|||
|
|||
module->CalculateBoundingBox(); |
|||
module->SetLastEditTime(); |
|||
OnModify(); |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
} |
@ -1,284 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file edit_pcb_text.cpp |
|||
* @brief Editing of text on copper and technical layers (TEXTE_PCB class) |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <pcbnew.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <macros.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_pcb_text.h>
|
|||
#include <class_board_item.h>
|
|||
|
|||
|
|||
static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ); |
|||
static void Abort_Edit_Pcb_Text( EDA_DRAW_PANEL* Panel, wxDC* DC ); |
|||
|
|||
|
|||
static TEXTE_PCB s_TextCopy( (BOARD_ITEM*) NULL ); // copy of the edited text used to
|
|||
// undo/redo/abort a complex edit command
|
|||
|
|||
|
|||
/*
|
|||
* Abort current text edit progress. |
|||
* If a text is selected, its initial coord are regenerated |
|||
*/ |
|||
void Abort_Edit_Pcb_Text( EDA_DRAW_PANEL* Panel, wxDC* DC ) |
|||
{ |
|||
TEXTE_PCB* TextePcb = (TEXTE_PCB*) Panel->GetScreen()->GetCurItem(); |
|||
( (PCB_EDIT_FRAME*) Panel->GetParent() )->SetCurItem( NULL ); |
|||
|
|||
Panel->SetMouseCapture( NULL, NULL ); |
|||
|
|||
if( TextePcb == NULL ) // Should not occur
|
|||
return; |
|||
|
|||
#ifndef USE_WX_OVERLAY
|
|||
TextePcb->Draw( Panel, DC, GR_XOR ); |
|||
#endif
|
|||
|
|||
if( TextePcb->IsNew() ) // If new: remove it
|
|||
{ |
|||
TextePcb->DeleteStructure(); |
|||
return; |
|||
} |
|||
|
|||
|
|||
TextePcb->SwapData( &s_TextCopy ); |
|||
TextePcb->ClearFlags(); |
|||
#ifndef USE_WX_OVERLAY
|
|||
TextePcb->Draw( Panel, DC, GR_OR ); |
|||
#else
|
|||
Panel->Refresh(); |
|||
#endif
|
|||
} |
|||
|
|||
|
|||
/*
|
|||
* Place the current text being moving |
|||
*/ |
|||
void PCB_EDIT_FRAME::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) |
|||
{ |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
SetCurItem( NULL ); |
|||
|
|||
if( TextePcb == NULL ) |
|||
return; |
|||
|
|||
TextePcb->Draw( m_canvas, DC, GR_OR ); |
|||
OnModify(); |
|||
|
|||
if( TextePcb->IsNew() ) // If new: prepare undo command
|
|||
{ |
|||
SaveCopyInUndoList( TextePcb, UR_NEW ); |
|||
TextePcb->ClearFlags(); |
|||
return; |
|||
} |
|||
|
|||
if( TextePcb->IsMoving() ) // If moved only
|
|||
{ |
|||
SaveCopyInUndoList( TextePcb, UR_MOVED, |
|||
TextePcb->GetTextPos() - s_TextCopy.GetTextPos() ); |
|||
} |
|||
else |
|||
{ |
|||
// Restore initial params
|
|||
TextePcb->SwapData( &s_TextCopy ); |
|||
// Prepare undo command
|
|||
SaveCopyInUndoList( TextePcb, UR_CHANGED ); |
|||
// Restore current params
|
|||
TextePcb->SwapData( &s_TextCopy ); |
|||
} |
|||
|
|||
TextePcb->ClearFlags(); |
|||
#ifdef USE_WX_OVERLAY
|
|||
m_canvas->Refresh(); |
|||
#endif
|
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aErase ) |
|||
{ |
|||
if( aTextePcb == NULL ) |
|||
return; |
|||
|
|||
// if it is an existing item: prepare a copy to undo/abort command
|
|||
if( !aTextePcb->IsNew() ) |
|||
s_TextCopy = *aTextePcb; |
|||
|
|||
aTextePcb->SetFlags( IS_MOVED ); |
|||
SetMsgPanel( aTextePcb ); |
|||
|
|||
#ifdef USE_WX_OVERLAY
|
|||
m_canvas->Refresh(); |
|||
#endif
|
|||
|
|||
SetCrossHairPosition( aTextePcb->GetTextPos() ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
|
|||
m_canvas->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text ); |
|||
SetCurItem( aTextePcb ); |
|||
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, aErase ); |
|||
} |
|||
|
|||
|
|||
// Move PCB text following the cursor.
|
|||
static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ) |
|||
{ |
|||
TEXTE_PCB* TextePcb = (TEXTE_PCB*) aPanel->GetScreen()->GetCurItem(); |
|||
|
|||
if( TextePcb == NULL ) |
|||
return; |
|||
|
|||
if( aErase ) |
|||
TextePcb->Draw( aPanel, aDC, GR_XOR ); |
|||
|
|||
TextePcb->SetTextPos( aPanel->GetParent()->GetCrossHairPosition() ); |
|||
|
|||
TextePcb->Draw( aPanel, aDC, GR_XOR ); |
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) |
|||
{ |
|||
if( TextePcb == NULL ) |
|||
return; |
|||
|
|||
TextePcb->Draw( m_canvas, DC, GR_XOR ); |
|||
|
|||
SaveCopyInUndoList( TextePcb, UR_DELETED ); |
|||
TextePcb->UnLink(); |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
SetCurItem( NULL ); |
|||
} |
|||
|
|||
|
|||
TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText ) |
|||
{ |
|||
TEXTE_PCB* textePcb = new TEXTE_PCB( GetBoard() ); |
|||
|
|||
if( aText ) |
|||
{ |
|||
*textePcb = *aText; |
|||
GetBoard()->Add( textePcb ); |
|||
textePcb->SetFlags( IS_NEW ); |
|||
if( aDC ) |
|||
StartMoveTextePcb( textePcb, aDC, false ); // Don't erase aText when copying
|
|||
} |
|||
else |
|||
{ |
|||
GetBoard()->Add( textePcb ); |
|||
textePcb->SetFlags( IS_NEW ); |
|||
|
|||
PCB_LAYER_ID layer = GetActiveLayer(); |
|||
|
|||
textePcb->SetLayer( layer ); |
|||
|
|||
// Set the mirrored option for layers on the BACK side of the board
|
|||
if( layer == B_Cu || layer == B_SilkS || |
|||
layer == B_Paste || layer == B_Mask || |
|||
layer == B_Adhes |
|||
) |
|||
textePcb->SetMirrored( true ); |
|||
|
|||
textePcb->SetTextSize( GetBoard()->GetDesignSettings().GetTextSize( layer ) ); |
|||
textePcb->SetTextPos( GetCrossHairPosition() ); |
|||
textePcb->SetThickness( GetBoard()->GetDesignSettings().GetTextThickness( layer ) ); |
|||
textePcb->SetItalic( GetBoard()->GetDesignSettings().GetTextItalic( layer ) ); |
|||
|
|||
InstallTextOptionsFrame( textePcb, aDC ); |
|||
|
|||
if( textePcb->GetText().IsEmpty() ) |
|||
{ |
|||
textePcb->DeleteStructure(); |
|||
textePcb = NULL; |
|||
} |
|||
else if( aDC ) |
|||
{ |
|||
StartMoveTextePcb( textePcb, aDC ); |
|||
} |
|||
} |
|||
|
|||
return textePcb; |
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) |
|||
{ |
|||
if( TextePcb == NULL ) |
|||
return; |
|||
|
|||
// Erase previous text:
|
|||
TextePcb->Draw( m_canvas, DC, GR_XOR ); |
|||
|
|||
TextePcb->SetTextAngle( TextePcb->GetTextAngle() + 900 ); |
|||
|
|||
// Redraw text in new position:
|
|||
TextePcb->Draw( m_canvas, DC, GR_XOR ); |
|||
SetMsgPanel( TextePcb ); |
|||
|
|||
if( TextePcb->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
|||
SaveCopyInUndoList( TextePcb, UR_ROTATED, TextePcb->GetTextPos() ); |
|||
else // set flag edit, to show it was a complex command
|
|||
TextePcb->SetFlags( IN_EDIT ); |
|||
|
|||
OnModify(); |
|||
#ifdef USE_WX_OVERLAY
|
|||
m_canvas->Refresh(); |
|||
#endif
|
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC ) |
|||
{ |
|||
if( aTextePcb == NULL ) |
|||
return; |
|||
|
|||
aTextePcb->Draw( m_canvas, aDC, GR_XOR ); |
|||
|
|||
aTextePcb->Flip( aTextePcb->GetTextPos() ); |
|||
|
|||
aTextePcb->Draw( m_canvas, aDC, GR_XOR ); |
|||
SetMsgPanel( aTextePcb ); |
|||
|
|||
if( aTextePcb->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
|||
SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetTextPos() ); |
|||
else // set edit flag, for the current command
|
|||
aTextePcb->SetFlags( IN_EDIT ); |
|||
|
|||
OnModify(); |
|||
#ifdef USE_WX_OVERLAY
|
|||
m_canvas->Refresh(); |
|||
#endif
|
|||
} |
@ -1,296 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file editedge.cpp |
|||
* @brief Edit segments and edges of PCB. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <gr_basic.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <protos.h>
|
|||
#include <macros.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_drawsegment.h>
|
|||
|
|||
|
|||
static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC ); |
|||
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); |
|||
static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ); |
|||
|
|||
|
|||
static wxPoint s_InitialPosition; // Initial cursor position.
|
|||
static wxPoint s_LastPosition; // Current cursor position.
|
|||
|
|||
|
|||
// Start move of a graphic element type DRAWSEGMENT
|
|||
void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) |
|||
{ |
|||
if( drawitem == NULL ) |
|||
return; |
|||
|
|||
drawitem->Draw( m_canvas, DC, GR_XOR ); |
|||
drawitem->SetFlags( IS_MOVED ); |
|||
s_InitialPosition = s_LastPosition = GetCrossHairPosition(); |
|||
SetMsgPanel( drawitem ); |
|||
m_canvas->SetMouseCapture( Move_Segment, Abort_EditEdge ); |
|||
SetCurItem( drawitem ); |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
} |
|||
|
|||
|
|||
/*
|
|||
* Place graphic element of type DRAWSEGMENT. |
|||
*/ |
|||
void PCB_EDIT_FRAME::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) |
|||
{ |
|||
if( drawitem == NULL ) |
|||
return; |
|||
|
|||
drawitem->ClearFlags(); |
|||
SaveCopyInUndoList(drawitem, UR_MOVED, s_LastPosition - s_InitialPosition); |
|||
drawitem->Draw( m_canvas, DC, GR_OR ); |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
SetCurItem( NULL ); |
|||
OnModify(); |
|||
} |
|||
|
|||
/*
|
|||
* Redraw segment during cursor movement. |
|||
*/ |
|||
static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ) |
|||
{ |
|||
DRAWSEGMENT* segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); |
|||
|
|||
if( segment == NULL ) |
|||
return; |
|||
|
|||
if( aErase ) |
|||
segment->Draw( aPanel, aDC, GR_XOR ); |
|||
|
|||
wxPoint delta; |
|||
delta = aPanel->GetParent()->GetCrossHairPosition() - s_LastPosition; |
|||
|
|||
segment->Move( delta ); |
|||
|
|||
s_LastPosition = aPanel->GetParent()->GetCrossHairPosition(); |
|||
|
|||
segment->Draw( aPanel, aDC, GR_XOR ); |
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) |
|||
{ |
|||
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); |
|||
bool tmp = displ_opts->m_DisplayDrawItemsFill; |
|||
|
|||
if( Segment == NULL ) |
|||
return; |
|||
|
|||
if( Segment->IsNew() ) // Trace in progress.
|
|||
{ |
|||
// Delete current segment.
|
|||
displ_opts->m_DisplayDrawItemsFill = SKETCH; |
|||
Segment->Draw( m_canvas, DC, GR_XOR ); |
|||
Segment->DeleteStructure(); |
|||
displ_opts->m_DisplayDrawItemsFill = tmp; |
|||
SetCurItem( NULL ); |
|||
} |
|||
else if( Segment->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
|||
{ |
|||
Segment->Draw( m_canvas, DC, GR_XOR ); |
|||
Segment->ClearFlags(); |
|||
SaveCopyInUndoList(Segment, UR_DELETED); |
|||
Segment->UnLink(); |
|||
SetCurItem( NULL ); |
|||
OnModify(); |
|||
} |
|||
} |
|||
|
|||
|
|||
static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC ) |
|||
{ |
|||
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); |
|||
|
|||
if( Segment == NULL ) |
|||
{ |
|||
aPanel->SetMouseCapture( NULL, NULL ); |
|||
return; |
|||
} |
|||
|
|||
if( Segment->IsNew() ) |
|||
{ |
|||
aPanel->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
Segment ->DeleteStructure(); |
|||
Segment = NULL; |
|||
} |
|||
else |
|||
{ |
|||
wxPoint pos = aPanel->GetParent()->GetCrossHairPosition(); |
|||
aPanel->GetParent()->SetCrossHairPosition( s_InitialPosition ); |
|||
aPanel->CallMouseCapture( DC, wxDefaultPosition, true ); |
|||
aPanel->GetParent()->SetCrossHairPosition( pos ); |
|||
Segment->ClearFlags(); |
|||
Segment->Draw( aPanel, DC, GR_OR ); |
|||
} |
|||
|
|||
#ifdef USE_WX_OVERLAY
|
|||
aPanel->Refresh(); |
|||
#endif
|
|||
|
|||
aPanel->SetMouseCapture( NULL, NULL ); |
|||
( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL ); |
|||
} |
|||
|
|||
|
|||
/* Initialize the drawing of a segment of type other than trace.
|
|||
*/ |
|||
DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC ) |
|||
{ |
|||
int lineWidth; |
|||
DRAWSEGMENT* DrawItem; |
|||
|
|||
lineWidth = GetDesignSettings().GetLineThickness( GetActiveLayer() ); |
|||
|
|||
if( Segment == NULL ) // Create new segment.
|
|||
{ |
|||
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) ); |
|||
Segment->SetFlags( IS_NEW ); |
|||
Segment->SetLayer( GetActiveLayer() ); |
|||
Segment->SetWidth( lineWidth ); |
|||
Segment->SetShape( shape ); |
|||
Segment->SetAngle( 900 ); |
|||
Segment->SetStart( GetCrossHairPosition() ); |
|||
Segment->SetEnd( GetCrossHairPosition() ); |
|||
m_canvas->SetMouseCapture( DrawSegment, Abort_EditEdge ); |
|||
} |
|||
else |
|||
{ |
|||
// The ending point coordinate Segment->m_End was updated by the function
|
|||
// DrawSegment() called on a move mouse event during the segment creation
|
|||
if( Segment->GetStart() != Segment->GetEnd() ) |
|||
{ |
|||
if( Segment->GetShape() == S_SEGMENT ) |
|||
{ |
|||
SaveCopyInUndoList( Segment, UR_NEW ); |
|||
GetBoard()->Add( Segment ); |
|||
|
|||
OnModify(); |
|||
Segment->ClearFlags(); |
|||
|
|||
Segment->Draw( m_canvas, DC, GR_OR ); |
|||
|
|||
DrawItem = Segment; |
|||
|
|||
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) ); |
|||
|
|||
Segment->SetFlags( IS_NEW ); |
|||
Segment->SetLayer( DrawItem->GetLayer() ); |
|||
Segment->SetWidth( lineWidth ); |
|||
Segment->SetShape( DrawItem->GetShape() ); |
|||
Segment->SetType( DrawItem->GetType() ); |
|||
Segment->SetAngle( DrawItem->GetAngle() ); |
|||
Segment->SetStart( DrawItem->GetEnd() ); |
|||
Segment->SetEnd( DrawItem->GetEnd() ); |
|||
DrawSegment( m_canvas, DC, wxDefaultPosition, false ); |
|||
} |
|||
else |
|||
{ |
|||
End_Edge( Segment, DC ); |
|||
Segment = NULL; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return Segment; |
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) |
|||
{ |
|||
if( Segment == NULL ) |
|||
return; |
|||
|
|||
Segment->Draw( m_canvas, DC, GR_OR ); |
|||
|
|||
// Delete if segment length is zero.
|
|||
if( Segment->GetStart() == Segment->GetEnd() ) |
|||
{ |
|||
Segment->DeleteStructure(); |
|||
} |
|||
else |
|||
{ |
|||
Segment->ClearFlags(); |
|||
GetBoard()->Add( Segment ); |
|||
OnModify(); |
|||
SaveCopyInUndoList( Segment, UR_NEW ); |
|||
} |
|||
|
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
SetCurItem( NULL ); |
|||
} |
|||
|
|||
|
|||
/* Redraw segment during cursor movement
|
|||
*/ |
|||
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) |
|||
{ |
|||
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); |
|||
auto frame = (PCB_EDIT_FRAME*) ( aPanel->GetParent() ); |
|||
if( Segment == NULL ) |
|||
return; |
|||
|
|||
auto displ_opts = (PCB_DISPLAY_OPTIONS*) ( aPanel->GetDisplayOptions() ); |
|||
bool tmp = displ_opts->m_DisplayDrawItemsFill; |
|||
|
|||
displ_opts->m_DisplayDrawItemsFill = SKETCH; |
|||
|
|||
if( aErase ) |
|||
Segment->Draw( aPanel, aDC, GR_XOR ); |
|||
|
|||
if( frame->Settings().m_use45DegreeGraphicSegments && Segment->GetShape() == S_SEGMENT ) |
|||
{ |
|||
wxPoint pt; |
|||
|
|||
pt = CalculateSegmentEndPoint( aPanel->GetParent()->GetCrossHairPosition(), |
|||
Segment->GetStart() ); |
|||
Segment->SetEnd( pt ); |
|||
} |
|||
else // here the angle is arbitrary
|
|||
{ |
|||
Segment->SetEnd( aPanel->GetParent()->GetCrossHairPosition() ); |
|||
} |
|||
|
|||
Segment->Draw( aPanel, aDC, GR_XOR ); |
|||
displ_opts->m_DisplayDrawItemsFill = tmp; |
|||
} |
@ -1,334 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file edtxtmod.cpp |
|||
* @brief Edit texts in footprints. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <common.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <draw_graphic_text.h>
|
|||
#include <trigo.h>
|
|||
#include <pcb_base_frame.h>
|
|||
#include <macros.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <footprint_edit_frame.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_text_mod.h>
|
|||
#include <class_pcb_text.h>
|
|||
|
|||
|
|||
static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ); |
|||
static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC ); |
|||
|
|||
|
|||
wxPoint MoveVector; // Move vector for move edge, exported
|
|||
// to dialog_edit mod_text.cpp
|
|||
static wxPoint TextInitialPosition; // Mouse cursor initial position for
|
|||
// undo/abort move command
|
|||
static double TextInitialOrientation; // module text initial orientation for
|
|||
// undo/abort move+rot command+rot
|
|||
|
|||
|
|||
/* Add a new graphical text to the active module (footprint)
|
|||
* Note there always are 2 mandatory texts: reference and value. |
|||
* New texts have the member TEXTE_MODULE.GetType() set to TEXT_is_DIVERS |
|||
*/ |
|||
TEXTE_MODULE* FOOTPRINT_EDIT_FRAME::CreateTextModule( MODULE* aModule, wxDC* aDC ) |
|||
{ |
|||
TEXTE_MODULE* text = new TEXTE_MODULE( aModule ); |
|||
|
|||
text->SetFlags( IS_NEW ); |
|||
|
|||
if( LSET::AllTechMask().test( GetActiveLayer() ) ) // i.e. a possible layer for a text
|
|||
text->SetLayer( GetActiveLayer() ); |
|||
|
|||
InstallTextOptionsFrame( text, NULL ); |
|||
|
|||
if( text->GetText().IsEmpty() ) |
|||
{ |
|||
delete text; |
|||
return NULL; |
|||
} |
|||
|
|||
// Add the new text object to the beginning of the footprint draw list.
|
|||
if( aModule ) |
|||
aModule->GraphicalItemsList().PushFront( text ); |
|||
|
|||
text->ClearFlags(); |
|||
|
|||
if( aDC ) |
|||
text->Draw( m_canvas, aDC, GR_OR ); |
|||
|
|||
SetMsgPanel( text ); |
|||
|
|||
return text; |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) |
|||
{ |
|||
if( Text == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = (MODULE*) Text->GetParent(); |
|||
|
|||
if( module && module->GetEditFlags() == 0 && Text->GetEditFlags() == 0 ) // prepare undo command
|
|||
{ |
|||
if( IsType( FRAME_PCB ) ) |
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
} |
|||
|
|||
// we expect MoveVector to be (0,0) if there is no move in progress
|
|||
Text->Draw( m_canvas, DC, GR_XOR, MoveVector ); |
|||
|
|||
Text->SetTextAngle( Text->GetTextAngle() + 900 ); |
|||
|
|||
Text->Draw( m_canvas, DC, GR_XOR, MoveVector ); |
|||
SetMsgPanel( Text ); |
|||
|
|||
if( module ) |
|||
module->SetLastEditTime(); |
|||
|
|||
OnModify(); |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::DeleteTextModule( TEXTE_MODULE* aText ) |
|||
{ |
|||
MODULE* module; |
|||
|
|||
if( aText == NULL ) |
|||
return; |
|||
|
|||
module = static_cast<MODULE*>( aText->GetParent() ); |
|||
|
|||
if( aText->GetType() == TEXTE_MODULE::TEXT_is_DIVERS ) |
|||
{ |
|||
if( module && module->GetEditFlags() == 0 && aText->GetEditFlags() == 0 ) |
|||
{ |
|||
if( IsType( FRAME_PCB ) ) |
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
} |
|||
|
|||
m_canvas->RefreshDrawingRect( aText->GetBoundingBox() ); |
|||
aText->DeleteStructure(); |
|||
OnModify(); |
|||
|
|||
if( module ) |
|||
module->SetLastEditTime(); |
|||
} |
|||
} |
|||
|
|||
|
|||
/**
|
|||
* Abort text move in progress. |
|||
* |
|||
* If a text is selected, its initial coordinates are regenerated. |
|||
*/ |
|||
static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) |
|||
{ |
|||
BASE_SCREEN* screen = Panel->GetScreen(); |
|||
TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() ); |
|||
MODULE* Module; |
|||
|
|||
Panel->SetMouseCapture( NULL, NULL ); |
|||
|
|||
if( Text == NULL ) |
|||
return; |
|||
|
|||
Module = static_cast<MODULE*>( Text->GetParent() ); |
|||
|
|||
Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector ); |
|||
Text->Draw( Panel, DC, GR_XOR, MoveVector ); |
|||
|
|||
// If the text was moved (the move does not change internal data)
|
|||
// it could be rotated while moving. So set old value for orientation
|
|||
if( Text->IsMoving() ) |
|||
Text->SetTextAngle( TextInitialOrientation ); |
|||
|
|||
// Redraw the text
|
|||
Panel->RefreshDrawingRect( Text->GetBoundingBox() ); |
|||
|
|||
// leave it at (0,0) so we can use it Rotate when not moving.
|
|||
MoveVector.x = MoveVector.y = 0; |
|||
|
|||
Text->ClearFlags(); |
|||
Module->ClearFlags(); |
|||
|
|||
screen->SetCurItem( NULL ); |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) |
|||
{ |
|||
if( Text == NULL ) |
|||
return; |
|||
|
|||
MODULE *Module = static_cast<MODULE*>( Text->GetParent() ); |
|||
|
|||
Text->SetFlags( IS_MOVED ); |
|||
Module->SetFlags( IN_EDIT ); |
|||
|
|||
MoveVector.x = MoveVector.y = 0; |
|||
|
|||
TextInitialPosition = Text->GetTextPos(); |
|||
TextInitialOrientation = Text->GetTextAngle(); |
|||
|
|||
// Center cursor on initial position of text
|
|||
SetCrossHairPosition( TextInitialPosition ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
|
|||
SetMsgPanel( Text ); |
|||
SetCurItem( Text ); |
|||
m_canvas->SetMouseCapture( Show_MoveTexte_Module, AbortMoveTextModule ); |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true ); |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) |
|||
{ |
|||
if( Text != NULL ) |
|||
{ |
|||
m_canvas->RefreshDrawingRect( Text->GetBoundingBox() ); |
|||
Text->DrawUmbilical( m_canvas, DC, GR_XOR, -MoveVector ); |
|||
|
|||
// Update the coordinates for anchor.
|
|||
MODULE* Module = static_cast<MODULE*>( Text->GetParent() ); |
|||
|
|||
if( Module ) |
|||
{ |
|||
// Prepare undo command (a rotation can be made while moving)
|
|||
double tmp = Text->GetTextAngle(); |
|||
Text->SetTextAngle( TextInitialOrientation ); |
|||
|
|||
if( IsType( FRAME_PCB ) ) |
|||
SaveCopyInUndoList( Module, UR_CHANGED ); |
|||
else |
|||
SaveCopyInUndoList( Module, UR_CHANGED ); |
|||
|
|||
Text->SetTextAngle( tmp ); |
|||
|
|||
// Set the new position for text.
|
|||
Text->SetTextPos( GetCrossHairPosition() ); |
|||
wxPoint textRelPos = Text->GetTextPos() - Module->GetPosition(); |
|||
RotatePoint( &textRelPos, -Module->GetOrientation() ); |
|||
Text->SetPos0( textRelPos ); |
|||
Text->ClearFlags(); |
|||
Module->ClearFlags(); |
|||
Module->SetLastEditTime(); |
|||
OnModify(); |
|||
|
|||
// Redraw text.
|
|||
m_canvas->RefreshDrawingRect( Text->GetBoundingBox() ); |
|||
} |
|||
else |
|||
{ |
|||
Text->SetTextPos( GetCrossHairPosition() ); |
|||
} |
|||
} |
|||
|
|||
// leave it at (0,0) so we can use it Rotate when not moving.
|
|||
MoveVector.x = MoveVector.y = 0; |
|||
|
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
} |
|||
|
|||
|
|||
static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() ); |
|||
|
|||
if( Text == NULL ) |
|||
return; |
|||
|
|||
// Erase umbilical and text if necessary
|
|||
if( aErase ) |
|||
{ |
|||
Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector ); |
|||
Text->Draw( aPanel, aDC, GR_XOR, MoveVector ); |
|||
} |
|||
|
|||
MoveVector = TextInitialPosition - aPanel->GetParent()->GetCrossHairPosition(); |
|||
|
|||
// Draw umbilical if text moved
|
|||
if( MoveVector.x || MoveVector.y ) |
|||
Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector ); |
|||
|
|||
// Redraw text
|
|||
Text->Draw( aPanel, aDC, GR_XOR, MoveVector ); |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) |
|||
{ |
|||
wxSize newSize = GetDesignSettings().GetTextSize( aItem->GetLayer() ); |
|||
int newThickness = GetDesignSettings().GetTextThickness( aItem->GetLayer() ); |
|||
bool newItalic = GetDesignSettings().GetTextItalic( aItem->GetLayer() ); |
|||
|
|||
if( aItem->Type() == PCB_TEXT_T ) |
|||
{ |
|||
TEXTE_PCB* text = static_cast<TEXTE_PCB*>( aItem ); |
|||
|
|||
// Exit if there's nothing to do
|
|||
if( text->GetTextSize() == newSize && text->GetThickness() == newThickness ) |
|||
return; |
|||
|
|||
SaveCopyInUndoList( text, UR_CHANGED ); |
|||
text->SetTextSize( newSize ); |
|||
text->SetThickness( newThickness ); |
|||
text->SetItalic( newItalic ); |
|||
} |
|||
|
|||
else if( aItem->Type() == PCB_MODULE_TEXT_T ) |
|||
{ |
|||
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( aItem ); |
|||
|
|||
// Exit if there's nothing to do
|
|||
if( text->GetTextSize() == newSize && text->GetThickness() == newThickness ) |
|||
return; |
|||
|
|||
SaveCopyInUndoList( text->GetParent(), UR_CHANGED ); |
|||
text->SetTextSize( newSize ); |
|||
text->SetThickness( newThickness ); |
|||
text->SetItalic( newItalic ); |
|||
} |
|||
else |
|||
return; |
|||
|
|||
if( aDC ) |
|||
m_canvas->Refresh(); |
|||
|
|||
OnModify(); |
|||
} |
@ -1,275 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file footprint_editor_onclick.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <gr_basic.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_edge_mod.h>
|
|||
#include <origin_viewitem.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <pcbnew_id.h>
|
|||
#include <tools/pcbnew_control.h>
|
|||
#include <hotkeys.h>
|
|||
#include <footprint_edit_frame.h>
|
|||
#include <dialog_edit_footprint_for_fp_editor.h>
|
|||
#include <menus_helpers.h>
|
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) |
|||
{ |
|||
BOARD_ITEM* item = GetCurItem(); |
|||
|
|||
m_canvas->CrossHairOff( DC ); |
|||
|
|||
if( GetToolId() == ID_NO_TOOL_SELECTED ) |
|||
{ |
|||
if( item && item->GetEditFlags() ) // Move item command in progress
|
|||
{ |
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_TEXT_T: |
|||
PlaceTexteModule( static_cast<TEXTE_MODULE*>( item ), DC ); |
|||
break; |
|||
|
|||
case PCB_MODULE_EDGE_T: |
|||
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED ); |
|||
Place_EdgeMod( static_cast<EDGE_MODULE*>( item ) ); |
|||
break; |
|||
|
|||
case PCB_PAD_T: |
|||
PlacePad( static_cast<D_PAD*>( item ), DC ); |
|||
break; |
|||
|
|||
default: |
|||
wxLogDebug( wxT( "WinEDA_ModEditFrame::OnLeftClick err:Struct %d, m_Flag %X" ), |
|||
item->Type(), item->GetEditFlags() ); |
|||
item->ClearFlags(); |
|||
} |
|||
} |
|||
|
|||
else |
|||
{ |
|||
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT ) |
|||
&& !wxGetKeyState( WXK_CONTROL ) ) |
|||
item = ModeditLocateAndDisplay(); |
|||
|
|||
SetCurItem( item ); |
|||
} |
|||
} |
|||
|
|||
item = GetCurItem(); |
|||
bool no_item_edited = item == NULL || item->GetEditFlags() == 0; |
|||
|
|||
switch( GetToolId() ) |
|||
{ |
|||
case ID_NO_TOOL_SELECTED: |
|||
break; |
|||
|
|||
case ID_MODEDIT_CIRCLE_TOOL: |
|||
case ID_MODEDIT_ARC_TOOL: |
|||
case ID_MODEDIT_LINE_TOOL: |
|||
if( no_item_edited ) |
|||
{ |
|||
STROKE_T shape = S_SEGMENT; |
|||
|
|||
if( GetToolId() == ID_MODEDIT_CIRCLE_TOOL ) |
|||
shape = S_CIRCLE; |
|||
|
|||
if( GetToolId() == ID_MODEDIT_ARC_TOOL ) |
|||
shape = S_ARC; |
|||
|
|||
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) ); |
|||
} |
|||
else if( item->IsNew() ) |
|||
{ |
|||
if( ( (EDGE_MODULE*) item )->GetShape() == S_CIRCLE ) |
|||
{ |
|||
End_Edge_Module( (EDGE_MODULE*) item ); |
|||
SetCurItem( NULL ); |
|||
m_canvas->Refresh(); |
|||
} |
|||
else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC ) |
|||
{ |
|||
End_Edge_Module( (EDGE_MODULE*) item ); |
|||
SetCurItem( NULL ); |
|||
m_canvas->Refresh(); |
|||
} |
|||
else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT ) |
|||
{ |
|||
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) item, DC, S_SEGMENT ) ); |
|||
} |
|||
else |
|||
wxLogDebug( wxT( "ProcessCommand error: unknown shape" ) ); |
|||
} |
|||
break; |
|||
|
|||
case ID_MODEDIT_DELETE_TOOL: |
|||
if( ! no_item_edited ) // Item in edit, cannot delete it
|
|||
break; |
|||
|
|||
item = ModeditLocateAndDisplay(); |
|||
|
|||
if( item && item->Type() != PCB_MODULE_T ) // Cannot delete the module itself
|
|||
{ |
|||
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED ); |
|||
RemoveStruct( item ); |
|||
SetCurItem( NULL ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_MODEDIT_ANCHOR_TOOL: |
|||
{ |
|||
MODULE* module = GetBoard()->m_Modules; |
|||
|
|||
if( module == NULL || module->GetEditFlags() != 0 ) |
|||
break; |
|||
|
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
|
|||
// set the new relative internal local coordinates of footprint items
|
|||
wxPoint moveVector = module->GetPosition() - GetCrossHairPosition(); |
|||
module->MoveAnchorPosition( moveVector ); |
|||
|
|||
// Usually, we do not need to change twice the anchor position,
|
|||
// so deselect the active tool
|
|||
SetNoToolSelected(); |
|||
SetCurItem( NULL ); |
|||
m_canvas->Refresh(); |
|||
} |
|||
break; |
|||
|
|||
case ID_MODEDIT_PLACE_GRID_COORD: |
|||
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetBoard()->GetGridOrigin(), UR_TRANSIENT ), |
|||
GetCrossHairPosition() ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case ID_MODEDIT_TEXT_TOOL: |
|||
if( GetBoard()->m_Modules == NULL ) |
|||
break; |
|||
|
|||
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED ); |
|||
CreateTextModule( GetBoard()->m_Modules, DC ); |
|||
break; |
|||
|
|||
case ID_MODEDIT_PAD_TOOL: |
|||
if( GetBoard()->m_Modules ) |
|||
{ |
|||
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED ); |
|||
AddPad( GetBoard()->m_Modules, true ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_MODEDIT_MEASUREMENT_TOOL: |
|||
DisplayError( this, _( "Measurement Tool not available in Legacy Toolset" ) ); |
|||
SetNoToolSelected(); |
|||
break; |
|||
|
|||
default: |
|||
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::ProcessCommand error" ) ); |
|||
SetNoToolSelected(); |
|||
} |
|||
|
|||
m_canvas->CrossHairOn( DC ); |
|||
} |
|||
|
|||
|
|||
/*
|
|||
* Called on a mouse left button double click |
|||
*/ |
|||
void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) |
|||
{ |
|||
BOARD_ITEM* item = GetCurItem(); |
|||
|
|||
switch( GetToolId() ) |
|||
{ |
|||
case ID_NO_TOOL_SELECTED: |
|||
if( item == NULL || item->GetEditFlags() == 0 ) |
|||
item = ModeditLocateAndDisplay(); |
|||
|
|||
if( item == NULL || item->GetEditFlags() != 0 ) |
|||
break; |
|||
|
|||
// Item found
|
|||
SetCurItem( item ); |
|||
OnEditItemRequest( DC, item ); |
|||
break; // end case 0
|
|||
|
|||
case ID_PCB_ADD_LINE_BUTT: |
|||
{ |
|||
if( item && item->IsNew() ) |
|||
{ |
|||
End_Edge_Module( (EDGE_MODULE*) item ); |
|||
SetCurItem( NULL ); |
|||
m_canvas->Refresh(); |
|||
} |
|||
|
|||
break; |
|||
} |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) |
|||
{ |
|||
switch( aItem->Type() ) |
|||
{ |
|||
case PCB_PAD_T: |
|||
InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
break; |
|||
|
|||
case PCB_MODULE_T: |
|||
editFootprintProperties( (MODULE*) aItem ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case PCB_MODULE_TEXT_T: |
|||
InstallTextOptionsFrame( aItem, aDC ); |
|||
break; |
|||
|
|||
case PCB_MODULE_EDGE_T : |
|||
InstallGraphicItemPropertiesDialog( aItem ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
@ -1,112 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file highlight.cpp |
|||
* @brief Highlight nets. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <kicad_device_context.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_track.h>
|
|||
#include <class_zone.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <collectors.h>
|
|||
|
|||
|
|||
int PCB_EDIT_FRAME::SelectHighLight( wxDC* DC ) |
|||
{ |
|||
int netcode = -1; |
|||
|
|||
if( GetBoard()->IsHighLightNetON() ) |
|||
HighLight( DC ); |
|||
|
|||
// use this scheme because a pad is a higher priority than a track in the
|
|||
// search, and finding a pad, instead of a track on a pad,
|
|||
// allows us to fire a message to Eeschema.
|
|||
|
|||
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide(); |
|||
|
|||
// optionally, modify the "guide" here as needed using its member functions
|
|||
|
|||
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsOrTracks, |
|||
RefPos( true ), guide ); |
|||
|
|||
if( m_Collector->GetCount() == 0 ) |
|||
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::Zones, |
|||
RefPos( true ), guide ); |
|||
|
|||
BOARD_ITEM* item = (*m_Collector)[0]; |
|||
|
|||
if( item ) |
|||
{ |
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_PAD_T: |
|||
netcode = ( (D_PAD*) item )->GetNetCode(); |
|||
SendMessageToEESCHEMA( item ); |
|||
break; |
|||
|
|||
case PCB_TRACE_T: |
|||
case PCB_VIA_T: |
|||
// since these classes are all derived from TRACK, use a common
|
|||
// GetNet() function:
|
|||
netcode = ( (TRACK*) item )->GetNetCode(); |
|||
break; |
|||
|
|||
case PCB_ZONE_AREA_T: |
|||
netcode = ( (ZONE_CONTAINER*) item )->GetNetCode(); |
|||
break; |
|||
|
|||
default: |
|||
; // until somebody changes GENERAL_COLLECTOR::PadsOrTracks,
|
|||
// this should not happen.
|
|||
} |
|||
} |
|||
|
|||
if( netcode >= 0 ) |
|||
{ |
|||
GetBoard()->SetHighLightNet( netcode ); |
|||
HighLight( DC ); |
|||
} |
|||
|
|||
return netcode; // HitTest() failed.
|
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::HighLight( wxDC* DC ) |
|||
{ |
|||
if( GetBoard()->IsHighLightNetON() ) |
|||
GetBoard()->HighLightOFF(); |
|||
else |
|||
GetBoard()->HighLightON(); |
|||
|
|||
GetBoard()->DrawHighLight( m_canvas, DC, GetBoard()->GetHighLightNetCode() ); |
|||
} |
@ -1,512 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras@wanadoo.fr |
|||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file hotkeys_board_editor.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_track.h>
|
|||
#include <class_pcb_text.h>
|
|||
#include <class_pcb_target.h>
|
|||
#include <class_drawsegment.h>
|
|||
#include <origin_viewitem.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <pcbnew_id.h>
|
|||
#include <hotkeys.h>
|
|||
#include <class_zone.h>
|
|||
#include <tool/tool_manager.h>
|
|||
#include <tools/pcbnew_control.h>
|
|||
#include <tools/selection_tool.h>
|
|||
#include <tool/actions.h>
|
|||
|
|||
/* How to add a new hotkey:
|
|||
* see hotkeys.cpp |
|||
*/ |
|||
|
|||
|
|||
EDA_HOTKEY* PCB_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const |
|||
{ |
|||
EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); |
|||
|
|||
if( HK_Descr == NULL ) |
|||
HK_Descr = GetDescriptorFromCommand( aCommand, board_edit_Hotkey_List ); |
|||
|
|||
return HK_Descr; |
|||
} |
|||
|
|||
|
|||
bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, |
|||
EDA_ITEM* aItem ) |
|||
{ |
|||
if( aHotkeyCode == 0 ) |
|||
return false; |
|||
|
|||
SELECTION& selection = GetToolManager()->GetTool<SELECTION_TOOL>()->GetSelection(); |
|||
bool itemCurrentlyEdited = selection.Front() && selection.Front()->GetEditFlags(); |
|||
MODULE* module = NULL; |
|||
int evt_type = 0; //Used to post a wxCommandEvent on demand
|
|||
PCB_SCREEN* screen = GetScreen(); |
|||
auto displ_opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); |
|||
|
|||
/* Convert lower to upper case
|
|||
* (the usual toupper function has problem with non ascii codes like function keys |
|||
*/ |
|||
if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') ) |
|||
aHotkeyCode += 'A' - 'a'; |
|||
|
|||
EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, common_Hotkey_List ); |
|||
|
|||
if( HK_Descr == NULL ) |
|||
HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, board_edit_Hotkey_List ); |
|||
|
|||
if( HK_Descr == NULL ) |
|||
return false; |
|||
|
|||
int hk_id = HK_Descr->m_Idcommand; |
|||
|
|||
// Create a wxCommandEvent that will be posted in some hot keys functions
|
|||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); |
|||
cmd.SetEventObject( this ); |
|||
|
|||
LAYER_NUM ll; |
|||
|
|||
switch( hk_id ) |
|||
{ |
|||
default: |
|||
case HK_NOT_FOUND: |
|||
return false; |
|||
|
|||
case HK_LEFT_CLICK: |
|||
OnLeftClick( aDC, aPosition ); |
|||
break; |
|||
|
|||
case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
|
|||
OnLeftClick( aDC, aPosition ); |
|||
OnLeftDClick( aDC, aPosition ); |
|||
break; |
|||
|
|||
case HK_SWITCH_TRACK_WIDTH_TO_NEXT: |
|||
if( GetCanvas()->IsMouseCaptured() ) |
|||
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); |
|||
|
|||
if( GetDesignSettings().GetTrackWidthIndex() < GetDesignSettings().m_TrackWidthList.size() - 1 ) |
|||
GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() + 1 ); |
|||
else |
|||
GetDesignSettings().SetTrackWidthIndex( 0 ); |
|||
|
|||
if( GetCanvas()->IsMouseCaptured() ) |
|||
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); |
|||
|
|||
break; |
|||
|
|||
case HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS: |
|||
if( GetCanvas()->IsMouseCaptured() ) |
|||
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); |
|||
|
|||
if( GetDesignSettings().GetTrackWidthIndex() <= 0 ) |
|||
GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().m_TrackWidthList.size() -1 ); |
|||
else |
|||
GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() - 1 ); |
|||
|
|||
if( GetCanvas()->IsMouseCaptured() ) |
|||
GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); |
|||
|
|||
break; |
|||
|
|||
case HK_SWITCH_GRID_TO_FASTGRID1: |
|||
SetFastGrid1(); |
|||
break; |
|||
|
|||
case HK_SWITCH_GRID_TO_FASTGRID2: |
|||
SetFastGrid2(); |
|||
break; |
|||
|
|||
case HK_SWITCH_GRID_TO_NEXT: |
|||
evt_type = ID_POPUP_GRID_NEXT; |
|||
break; |
|||
|
|||
case HK_SWITCH_GRID_TO_PREVIOUS: |
|||
evt_type = ID_POPUP_GRID_PREV; |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_PREVIOUS: |
|||
ll = GetActiveLayer(); |
|||
|
|||
if( !IsCopperLayer( ll ) ) |
|||
break; |
|||
|
|||
if( ll == F_Cu ) |
|||
ll = B_Cu; |
|||
else if( ll == B_Cu ) |
|||
ll = ToLAYER_ID( GetBoard()->GetCopperLayerCount() - 2 ); |
|||
else |
|||
ll = ll - 1; |
|||
|
|||
SwitchLayer( aDC, ToLAYER_ID( ll ) ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_NEXT: |
|||
ll = GetActiveLayer(); |
|||
|
|||
if( !IsCopperLayer( ll ) ) |
|||
break; |
|||
|
|||
if( ll == B_Cu ) |
|||
ll = F_Cu; |
|||
else if( ++ll >= GetBoard()->GetCopperLayerCount() - 1 ) |
|||
ll = B_Cu; |
|||
|
|||
SwitchLayer( aDC, ToLAYER_ID( ll ) ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_COMPONENT: |
|||
SwitchLayer( aDC, F_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_COPPER: |
|||
SwitchLayer( aDC, B_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_INNER1: |
|||
SwitchLayer( aDC, In1_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_INNER2: |
|||
SwitchLayer( aDC, In2_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_INNER3: |
|||
SwitchLayer( aDC, In3_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_INNER4: |
|||
SwitchLayer( aDC, In4_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_INNER5: |
|||
SwitchLayer( aDC, In5_Cu ); |
|||
break; |
|||
|
|||
case HK_SWITCH_LAYER_TO_INNER6: |
|||
SwitchLayer( aDC, In6_Cu ); |
|||
break; |
|||
|
|||
case HK_HELP: // Display Current hotkey list
|
|||
DisplayHotkeyList( this, g_Board_Editor_Hotkeys_Descr ); |
|||
break; |
|||
|
|||
case HK_PREFERENCES: |
|||
evt_type = wxID_PREFERENCES; |
|||
break; |
|||
|
|||
case HK_ADD_MODULE: |
|||
evt_type = ID_PCB_MODULE_BUTT; |
|||
break; |
|||
|
|||
case HK_RESET_LOCAL_COORD: // Set the relative coord
|
|||
GetScreen()->m_O_Curseur = GetCrossHairPosition(); |
|||
break; |
|||
|
|||
case HK_SET_GRID_ORIGIN: |
|||
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ), |
|||
GetCrossHairPosition() ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case HK_RESET_GRID_ORIGIN: |
|||
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ), |
|||
wxPoint( 0, 0 ) ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case HK_SWITCH_TRACK_DISPLAY_MODE: |
|||
displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_DisplayPcbTrackFill; |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case HK_BACK_SPACE: |
|||
m_toolManager->RunAction( ACTIONS::doDelete ); |
|||
break; |
|||
|
|||
case HK_GET_AND_MOVE_FOOTPRINT: |
|||
if( !itemCurrentlyEdited ) |
|||
evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST; |
|||
|
|||
break; |
|||
|
|||
case HK_OPEN: |
|||
if( !itemCurrentlyEdited ) |
|||
evt_type = ID_LOAD_FILE ; |
|||
|
|||
break; |
|||
|
|||
case HK_SAVE: |
|||
if( !itemCurrentlyEdited ) |
|||
evt_type = ID_SAVE_BOARD; |
|||
|
|||
break; |
|||
|
|||
case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
|
|||
if( GetToolId() != ID_TRACK_BUTT ) |
|||
return true; |
|||
|
|||
if( !itemCurrentlyEdited ) // no track in progress: nothing to do
|
|||
break; |
|||
|
|||
if( GetCurItem()->Type() != PCB_TRACE_T ) // Should not occur
|
|||
return true; |
|||
|
|||
if( !GetCurItem()->IsNew() ) |
|||
return true; |
|||
|
|||
// place micro via and switch layer
|
|||
if( IsMicroViaAcceptable() ) |
|||
evt_type = ID_POPUP_PCB_PLACE_MICROVIA; |
|||
|
|||
break; |
|||
|
|||
case HK_ADD_BLIND_BURIED_VIA: |
|||
case HK_ADD_THROUGH_VIA: // Switch to alternate layer and Place a via if a track is in progress
|
|||
if( GetBoard()->GetDesignSettings().m_BlindBuriedViaAllowed && |
|||
hk_id == HK_ADD_BLIND_BURIED_VIA ) |
|||
GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_BLIND_BURIED; |
|||
else |
|||
GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_THROUGH; |
|||
|
|||
if( !itemCurrentlyEdited ) // no track in progress: switch layer only
|
|||
{ |
|||
Other_Layer_Route( NULL, aDC ); |
|||
if( displ_opts->m_ContrastModeDisplay ) |
|||
m_canvas->Refresh(); |
|||
break; |
|||
} |
|||
|
|||
if( GetToolId() != ID_TRACK_BUTT ) |
|||
return true; |
|||
|
|||
if( GetCurItem()->Type() != PCB_TRACE_T ) |
|||
return true; |
|||
|
|||
if( !GetCurItem()->IsNew() ) |
|||
return true; |
|||
|
|||
evt_type = hk_id == HK_ADD_BLIND_BURIED_VIA ? |
|||
ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA : ID_POPUP_PCB_PLACE_THROUGH_VIA; |
|||
break; |
|||
|
|||
case HK_SEL_LAYER_AND_ADD_THROUGH_VIA: |
|||
case HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA: |
|||
if( GetCurItem() == NULL || !GetCurItem()->IsNew() || |
|||
GetCurItem()->Type() != PCB_TRACE_T ) |
|||
break; |
|||
|
|||
evt_type = hk_id == HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA ? |
|||
ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA : |
|||
ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA; |
|||
break; |
|||
|
|||
case HK_SWITCH_TRACK_POSTURE: |
|||
/* change the position of initial segment when creating new tracks
|
|||
* switch from _/ to -\ . |
|||
*/ |
|||
evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ; |
|||
break; |
|||
|
|||
case HK_ADD_NEW_TRACK: // Start new track, if possible
|
|||
OnHotkeyBeginRoute( aDC ); |
|||
break; |
|||
|
|||
case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
|
|||
// get any module, locked or not locked and toggle its locked status
|
|||
if( !itemCurrentlyEdited ) |
|||
{ |
|||
wxPoint pos = RefPos( true ); |
|||
module = GetBoard()->GetFootprint( pos, screen->m_Active_Layer, true ); |
|||
} |
|||
else if( GetCurItem()->Type() == PCB_MODULE_T ) |
|||
{ |
|||
module = (MODULE*) GetCurItem(); |
|||
} |
|||
|
|||
if( module ) |
|||
{ |
|||
SetCurItem( module ); |
|||
module->SetLocked( !module->IsLocked() ); |
|||
OnModify(); |
|||
SetMsgPanel( module ); |
|||
} |
|||
break; |
|||
|
|||
case HK_MOVE_ITEM_EXACT: |
|||
case HK_DUPLICATE: |
|||
case HK_DUPLICATE_ITEM_AND_INCREMENT: |
|||
case HK_CREATE_ARRAY: |
|||
OnHotkeyDuplicateOrArrayItem( HK_Descr->m_Idcommand ); |
|||
break; |
|||
|
|||
case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas
|
|||
displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay; |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case HK_CANVAS_CAIRO: |
|||
evt_type = ID_MENU_CANVAS_CAIRO; |
|||
break; |
|||
|
|||
case HK_CANVAS_OPENGL: |
|||
evt_type = ID_MENU_CANVAS_OPENGL; |
|||
break; |
|||
|
|||
case HK_ZONE_FILL_OR_REFILL: |
|||
evt_type = ID_POPUP_PCB_FILL_ALL_ZONES; |
|||
break; |
|||
|
|||
case HK_ZONE_REMOVE_FILLED: |
|||
evt_type = ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES; |
|||
break; |
|||
} |
|||
|
|||
if( evt_type != 0 ) |
|||
{ |
|||
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); |
|||
evt.SetEventObject( this ); |
|||
evt.SetId( evt_type ); |
|||
GetEventHandler()->ProcessEvent( evt ); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC ) |
|||
{ |
|||
if( !IsCopperLayer( GetActiveLayer() ) ) |
|||
return NULL; |
|||
|
|||
bool itemCurrentlyEdited = GetCurItem() && GetCurItem()->GetEditFlags(); |
|||
|
|||
// Ensure the track tool is active
|
|||
if( GetToolId() != ID_TRACK_BUTT && !itemCurrentlyEdited ) |
|||
{ |
|||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); |
|||
cmd.SetEventObject( this ); |
|||
cmd.SetId( ID_TRACK_BUTT ); |
|||
GetEventHandler()->ProcessEvent( cmd ); |
|||
} |
|||
|
|||
if( GetToolId() != ID_TRACK_BUTT ) |
|||
return NULL; |
|||
|
|||
TRACK* track = NULL; |
|||
|
|||
if( !itemCurrentlyEdited ) // no track in progress:
|
|||
{ |
|||
track = Begin_Route( NULL, aDC ); |
|||
SetCurItem( track ); |
|||
|
|||
if( track ) |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
else if( GetCurItem()->IsNew() ) |
|||
{ |
|||
track = Begin_Route( (TRACK*) GetCurItem(), aDC ); |
|||
|
|||
// SetCurItem() must not write to the msg panel
|
|||
// because a track info is displayed while moving the mouse cursor
|
|||
if( track ) // A new segment was created
|
|||
SetCurItem( track, false ); |
|||
|
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
|
|||
return track; |
|||
} |
|||
|
|||
|
|||
bool PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem( int aIdCommand ) |
|||
{ |
|||
BOARD_ITEM* item = GetCurItem(); |
|||
bool itemCurrentlyEdited = item && item->GetEditFlags(); |
|||
|
|||
if( itemCurrentlyEdited ) |
|||
return false; |
|||
|
|||
item = PcbGeneralLocateAndDisplay(); |
|||
|
|||
if( item == NULL ) |
|||
return false; |
|||
|
|||
SetCurItem( item ); |
|||
|
|||
int evt_type = 0; // Used to post a wxCommandEvent on demand
|
|||
|
|||
bool canDuplicate = true; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
// Only handle items we know we can handle
|
|||
case PCB_PAD_T: |
|||
canDuplicate = false; |
|||
// no break
|
|||
case PCB_MODULE_T: |
|||
case PCB_LINE_T: |
|||
case PCB_TEXT_T: |
|||
case PCB_TRACE_T: |
|||
case PCB_ZONE_AREA_T: |
|||
case PCB_TARGET_T: |
|||
case PCB_DIMENSION_T: |
|||
switch( aIdCommand ) |
|||
{ |
|||
case HK_CREATE_ARRAY: |
|||
if( canDuplicate ) |
|||
evt_type = ID_POPUP_PCB_CREATE_ARRAY; |
|||
break; |
|||
|
|||
case HK_MOVE_ITEM_EXACT: |
|||
evt_type = ID_POPUP_PCB_MOVE_EXACT; |
|||
break; |
|||
|
|||
default: |
|||
// We don't handle other commands here
|
|||
break; |
|||
} |
|||
break; |
|||
|
|||
default: |
|||
evt_type = 0; |
|||
break; |
|||
} |
|||
|
|||
return PostCommandMenuEvent( evt_type ); |
|||
} |
@ -1,127 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2010-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file hotkeys_module_editor.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <pcbnew.h>
|
|||
#include <footprint_edit_frame.h>
|
|||
#include <pcbnew_id.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <board_design_settings.h>
|
|||
#include <origin_viewitem.h>
|
|||
#include <tools/pcbnew_control.h>
|
|||
|
|||
#include <hotkeys.h>
|
|||
|
|||
/* How to add a new hotkey:
|
|||
* See hotkeys.cpp |
|||
*/ |
|||
|
|||
EDA_HOTKEY* FOOTPRINT_EDIT_FRAME::GetHotKeyDescription( int aCommand ) const |
|||
{ |
|||
EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List ); |
|||
|
|||
if( HK_Descr == NULL ) |
|||
HK_Descr = GetDescriptorFromCommand( aCommand, module_edit_Hotkey_List ); |
|||
|
|||
return HK_Descr; |
|||
} |
|||
|
|||
|
|||
bool FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, |
|||
EDA_ITEM* aItem ) |
|||
{ |
|||
if( aHotKey == 0 ) |
|||
return false; |
|||
|
|||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); |
|||
cmd.SetEventObject( this ); |
|||
|
|||
/* Convert lower to upper case (the usual toupper function has problem with non ascii
|
|||
* codes like function keys */ |
|||
if( (aHotKey >= 'a') && (aHotKey <= 'z') ) |
|||
aHotKey += 'A' - 'a'; |
|||
|
|||
EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List ); |
|||
|
|||
if( HK_Descr == NULL ) |
|||
HK_Descr = GetDescriptorFromHotkey( aHotKey, module_edit_Hotkey_List ); |
|||
|
|||
if( HK_Descr == NULL ) |
|||
return false; |
|||
|
|||
switch( HK_Descr->m_Idcommand ) |
|||
{ |
|||
default: |
|||
case HK_NOT_FOUND: |
|||
return false; |
|||
|
|||
case HK_HELP: // Display Current hotkey list
|
|||
DisplayHotkeyList( this, g_Module_Editor_Hotkeys_Descr ); |
|||
break; |
|||
|
|||
case HK_PREFERENCES: |
|||
cmd.SetId( wxID_PREFERENCES ); |
|||
GetEventHandler()->ProcessEvent( cmd ); |
|||
break; |
|||
|
|||
case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin
|
|||
GetScreen()->m_O_Curseur = GetCrossHairPosition(); |
|||
break; |
|||
|
|||
case HK_LEFT_CLICK: |
|||
OnLeftClick( aDC, aPosition ); |
|||
break; |
|||
|
|||
case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
|
|||
OnLeftClick( aDC, aPosition ); |
|||
OnLeftDClick( aDC, aPosition ); |
|||
break; |
|||
|
|||
case HK_SET_GRID_ORIGIN: |
|||
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ), |
|||
GetCrossHairPosition() ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case HK_RESET_GRID_ORIGIN: |
|||
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetGridOrigin(), UR_TRANSIENT ), |
|||
wxPoint( 0, 0 ) ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case HK_CREATE_ARRAY: |
|||
PostCommandMenuEvent( ID_POPUP_PCB_CREATE_ARRAY ); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
@ -1,114 +0,0 @@ |
|||
|
|||
|
|||
/**
|
|||
* @file move-drag_pads.cpp |
|||
* @brief Edit footprint pads. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <common.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <trigo.h>
|
|||
#include <pcb_base_frame.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <drag.h>
|
|||
|
|||
|
|||
static wxPoint Pad_OldPos; |
|||
|
|||
|
|||
// Routine to place a moved pad.
|
|||
void PCB_BASE_FRAME::PlacePad( D_PAD* aPad, wxDC* DC ) |
|||
{ |
|||
int dX, dY; |
|||
TRACK* track; |
|||
|
|||
if( aPad == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
ITEM_PICKER picker( NULL, UR_CHANGED ); |
|||
PICKED_ITEMS_LIST pickList; |
|||
|
|||
// Save dragged track segments in undo list
|
|||
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) |
|||
{ |
|||
track = g_DragSegmentList[ii].m_Track; |
|||
|
|||
// Set the old state
|
|||
if( g_DragSegmentList[ii].m_Pad_Start ) |
|||
track->SetStart( Pad_OldPos ); |
|||
|
|||
if( g_DragSegmentList[ii].m_Pad_End ) |
|||
track->SetEnd( Pad_OldPos ); |
|||
|
|||
picker.SetItem( track ); |
|||
pickList.PushItem( picker ); |
|||
} |
|||
|
|||
// Save old module and old items values
|
|||
aPad->ClearFlags(); |
|||
wxPoint pad_curr_position = aPad->GetPosition(); |
|||
|
|||
aPad->SetPosition( Pad_OldPos ); |
|||
|
|||
if( g_DragSegmentList.size() == 0 ) |
|||
SaveCopyInUndoList( module, UR_CHANGED ); |
|||
else |
|||
{ |
|||
picker.SetItem( module ); |
|||
pickList.PushItem( picker ); |
|||
SaveCopyInUndoList( pickList, UR_CHANGED ); |
|||
} |
|||
|
|||
aPad->SetPosition( pad_curr_position ); |
|||
aPad->Draw( m_canvas, DC, GR_XOR ); |
|||
|
|||
// Redraw dragged track segments
|
|||
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) |
|||
{ |
|||
track = g_DragSegmentList[ii].m_Track; |
|||
|
|||
// Set the new state
|
|||
if( g_DragSegmentList[ii].m_Pad_Start ) |
|||
track->SetStart( aPad->GetPosition() ); |
|||
|
|||
if( g_DragSegmentList[ii].m_Pad_End ) |
|||
track->SetEnd( aPad->GetPosition() ); |
|||
|
|||
if( DC ) |
|||
track->Draw( m_canvas, DC, GR_XOR ); |
|||
|
|||
track->SetState( IN_EDIT, false ); |
|||
track->ClearFlags(); |
|||
|
|||
if( DC ) |
|||
track->Draw( m_canvas, DC, GR_OR ); |
|||
} |
|||
|
|||
// Compute local coordinates (i.e refer to module position and for module orient = 0)
|
|||
dX = aPad->GetPosition().x - Pad_OldPos.x; |
|||
dY = aPad->GetPosition().y - Pad_OldPos.y; |
|||
|
|||
RotatePoint( &dX, &dY, -module->GetOrientation() ); |
|||
|
|||
aPad->SetX0( dX + aPad->GetPos0().x ); |
|||
aPad->SetY0( dY + aPad->GetPos0().y ); |
|||
|
|||
if( DC ) |
|||
aPad->Draw( m_canvas, DC, GR_OR ); |
|||
|
|||
module->CalculateBoundingBox(); |
|||
module->SetLastEditTime(); |
|||
|
|||
EraseDragList(); |
|||
|
|||
OnModify(); |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
} |
@ -1,126 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* 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> |
|||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file move_or_drag_track.cpp |
|||
* @brief Track editing routines to move and drag track segments or node. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <trigo.h>
|
|||
#include <macros.h>
|
|||
#include <gr_basic.h>
|
|||
|
|||
#include <class_board.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <drc.h>
|
|||
#include <drag.h>
|
|||
#include <pcbnew_id.h>
|
|||
|
|||
|
|||
static PICKED_ITEMS_LIST s_ItemsListPicker; |
|||
|
|||
|
|||
// Place a dragged (or moved) track segment or via
|
|||
bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) |
|||
{ |
|||
int errdrc; |
|||
|
|||
if( Track == NULL ) |
|||
return false; |
|||
|
|||
int current_net_code = Track->GetNetCode(); |
|||
|
|||
// DRC control:
|
|||
if( Settings().m_legacyDrcOn ) |
|||
{ |
|||
errdrc = m_drc->DrcOnCreatingTrack( Track, GetBoard()->m_Track ); |
|||
|
|||
if( errdrc == BAD_DRC ) |
|||
return false; |
|||
|
|||
// Test the dragged segments
|
|||
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) |
|||
{ |
|||
errdrc = m_drc->DrcOnCreatingTrack( g_DragSegmentList[ii].m_Track, GetBoard()->m_Track ); |
|||
|
|||
if( errdrc == BAD_DRC ) |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
// DRC Ok: place track segments
|
|||
Track->ClearFlags(); |
|||
Track->SetState( IN_EDIT, false ); |
|||
|
|||
// Draw dragged tracks
|
|||
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) |
|||
{ |
|||
Track = g_DragSegmentList[ii].m_Track; |
|||
Track->SetState( IN_EDIT, false ); |
|||
Track->ClearFlags(); |
|||
|
|||
/* Test the connections modified by the move
|
|||
* (only pad connection must be tested, track connection will be |
|||
* tested by TestNetConnection() ) */ |
|||
LSET layerMask( Track->GetLayer() ); |
|||
|
|||
Track->start = GetBoard()->GetPadFast( Track->GetStart(), layerMask ); |
|||
|
|||
if( Track->start ) |
|||
Track->SetState( BEGIN_ONPAD, true ); |
|||
else |
|||
Track->SetState( BEGIN_ONPAD, false ); |
|||
|
|||
Track->end = GetBoard()->GetPadFast( Track->GetEnd(), layerMask ); |
|||
|
|||
if( Track->end ) |
|||
Track->SetState( END_ONPAD, true ); |
|||
else |
|||
Track->SetState( END_ONPAD, false ); |
|||
} |
|||
|
|||
EraseDragList(); |
|||
|
|||
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); |
|||
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
|||
|
|||
GetBoard()->PopHighLight(); |
|||
|
|||
OnModify(); |
|||
m_canvas->SetMouseCapture( NULL, NULL ); |
|||
|
|||
if( current_net_code > 0 ) |
|||
TestNetConnection( DC, current_net_code ); |
|||
|
|||
m_canvas->Refresh(); |
|||
|
|||
return true; |
|||
} |
@ -1,578 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2007 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr |
|||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> |
|||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file pcbnew/onleftclick.cpp |
|||
* @brief Functions called when the left button is clicked or double clicked. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <msgpanel.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_drawsegment.h>
|
|||
#include <class_dimension.h>
|
|||
#include <class_zone.h>
|
|||
#include <class_pcb_text.h>
|
|||
#include <class_text_mod.h>
|
|||
#include <class_module.h>
|
|||
#include <class_pcb_target.h>
|
|||
#include <origin_viewitem.h>
|
|||
#include <project.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <pcbnew_id.h>
|
|||
#include <menus_helpers.h>
|
|||
#include <tools/pcb_editor_control.h>
|
|||
#include <tools/pcbnew_control.h>
|
|||
|
|||
|
|||
/* Handle the left button mouse click, when a tool is active
|
|||
*/ |
|||
void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) |
|||
{ |
|||
BOARD_ITEM* curr_item = GetCurItem(); |
|||
bool exit = false; |
|||
bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED; |
|||
|
|||
if( no_tool || ( curr_item && curr_item->GetEditFlags() ) ) |
|||
{ |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
|
|||
if( curr_item && curr_item->GetEditFlags() ) // Command in progress
|
|||
{ |
|||
m_canvas->SetIgnoreMouseEvents( true ); |
|||
m_canvas->CrossHairOff( aDC ); |
|||
|
|||
switch( curr_item->Type() ) |
|||
{ |
|||
case PCB_ZONE_AREA_T: |
|||
if( curr_item->IsNew() ) |
|||
{ |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
Begin_Zone( aDC ); |
|||
} |
|||
else |
|||
{ |
|||
End_Move_Zone_Corner_Or_Outlines( aDC, static_cast<ZONE_CONTAINER*>( curr_item ) ); |
|||
} |
|||
|
|||
exit = true; |
|||
break; |
|||
|
|||
case PCB_TRACE_T: |
|||
case PCB_VIA_T: |
|||
if( curr_item->IsDragging() ) |
|||
{ |
|||
PlaceDraggedOrMovedTrackSegment( static_cast<TRACK*>( curr_item ), aDC ); |
|||
exit = true; |
|||
} |
|||
|
|||
break; |
|||
|
|||
case PCB_TEXT_T: |
|||
Place_Texte_Pcb( static_cast<TEXTE_PCB*>( curr_item ), aDC ); |
|||
exit = true; |
|||
break; |
|||
|
|||
case PCB_MODULE_TEXT_T: |
|||
PlaceTexteModule( static_cast<TEXTE_MODULE*>( curr_item ), aDC ); |
|||
exit = true; |
|||
break; |
|||
|
|||
case PCB_PAD_T: |
|||
PlacePad( static_cast<D_PAD*>( curr_item ), aDC ); |
|||
exit = true; |
|||
break; |
|||
|
|||
case PCB_MODULE_T: |
|||
PlaceModule( static_cast<MODULE*>( curr_item ), aDC ); |
|||
exit = true; |
|||
break; |
|||
|
|||
case PCB_TARGET_T: |
|||
PlaceTarget( static_cast<PCB_TARGET*>( curr_item ), aDC ); |
|||
exit = true; |
|||
break; |
|||
|
|||
case PCB_LINE_T: |
|||
if( no_tool ) // when no tools: existing item moving.
|
|||
{ |
|||
Place_DrawItem( static_cast<DRAWSEGMENT*>( curr_item ), aDC ); |
|||
exit = true; |
|||
} |
|||
|
|||
break; |
|||
|
|||
case PCB_DIMENSION_T: |
|||
if( ! curr_item->IsNew() ) |
|||
{ // We are moving the text of an existing dimension. Place it
|
|||
PlaceDimensionText( static_cast<DIMENSION*>( curr_item ), aDC ); |
|||
exit = true; |
|||
} |
|||
break; |
|||
|
|||
case PCB_MARKER_T: // MARKER_PCB, a marker used to show something
|
|||
curr_item->ClearFlags(); // Not reason to have flags set
|
|||
exit = true; |
|||
break; |
|||
|
|||
default: |
|||
DisplayError( this, |
|||
wxString::Format( |
|||
"PCB_EDIT_FRAME::OnLeftClick() err: curr_item type %d m_Flags != 0 (%X)", |
|||
curr_item->Type(), curr_item->GetEditFlags() ) ); |
|||
exit = true; |
|||
break; |
|||
} |
|||
|
|||
m_canvas->SetIgnoreMouseEvents( false ); |
|||
m_canvas->CrossHairOn( aDC ); |
|||
|
|||
if( exit ) |
|||
return; |
|||
} |
|||
else if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT ) |
|||
&& !wxGetKeyState( WXK_CONTROL ) ) |
|||
{ |
|||
curr_item = PcbGeneralLocateAndDisplay(); |
|||
|
|||
if( curr_item ) |
|||
SendMessageToEESCHEMA( curr_item ); |
|||
} |
|||
} |
|||
|
|||
if( curr_item ) // display netclass info for zones, tracks and pads
|
|||
{ |
|||
switch( curr_item->Type() ) |
|||
{ |
|||
case PCB_ZONE_AREA_T: |
|||
case PCB_TRACE_T: |
|||
case PCB_VIA_T: |
|||
case PCB_PAD_T: |
|||
SetCurrentNetClass( |
|||
((BOARD_CONNECTED_ITEM*)curr_item)->GetNetClassName() ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
switch( GetToolId() ) |
|||
{ |
|||
case ID_MAIN_MENUBAR: |
|||
case ID_NO_TOOL_SELECTED: |
|||
case ID_ZOOM_SELECTION: |
|||
break; |
|||
|
|||
case ID_PCB_HIGHLIGHT_BUTT: |
|||
{ |
|||
int netcode = SelectHighLight( aDC ); |
|||
|
|||
if( netcode < 0 ) |
|||
SetMsgPanel( GetBoard() ); |
|||
else |
|||
{ |
|||
NETINFO_ITEM* net = GetBoard()->FindNet( netcode ); |
|||
|
|||
if( net ) |
|||
{ |
|||
MSG_PANEL_ITEMS items; |
|||
net->GetMsgPanelInfo( m_UserUnits, items ); |
|||
SetMsgPanel( items ); |
|||
} |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case ID_LOCAL_RATSNEST_BUTT: |
|||
curr_item = PcbGeneralLocateAndDisplay(); |
|||
Show_1_Ratsnest( curr_item, aDC ); |
|||
|
|||
if( curr_item ) |
|||
SendMessageToEESCHEMA( curr_item ); |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_TARGET_BUTT: |
|||
if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
SetCurItem( (BOARD_ITEM*) CreateTarget( aDC ) ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
} |
|||
else if( curr_item->Type() == PCB_TARGET_T ) |
|||
{ |
|||
PlaceTarget( (PCB_TARGET*) curr_item, aDC ); |
|||
} |
|||
else |
|||
{ |
|||
wxLogDebug( wxT( "OnLeftClick err: not a PCB_TARGET_T" ) ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_CIRCLE_BUTT: |
|||
case ID_PCB_ARC_BUTT: |
|||
case ID_PCB_ADD_LINE_BUTT: |
|||
{ |
|||
STROKE_T shape = S_SEGMENT; |
|||
|
|||
if( GetToolId() == ID_PCB_CIRCLE_BUTT ) |
|||
shape = S_CIRCLE; |
|||
|
|||
if( GetToolId() == ID_PCB_ARC_BUTT ) |
|||
shape = S_ARC; |
|||
|
|||
if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
curr_item = (BOARD_ITEM*) Begin_DrawSegment( NULL, shape, aDC ); |
|||
SetCurItem( curr_item ); |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
else if( curr_item |
|||
&& (curr_item->Type() == PCB_LINE_T) |
|||
&& curr_item->IsNew() ) |
|||
{ |
|||
curr_item = (BOARD_ITEM*) Begin_DrawSegment( (DRAWSEGMENT*) curr_item, shape, aDC ); |
|||
SetCurItem( curr_item ); |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case ID_TRACK_BUTT: |
|||
if( !IsCopperLayer( GetActiveLayer() ) ) |
|||
{ |
|||
DisplayError( this, _( "Tracks on Copper layers only" ) ); |
|||
break; |
|||
} |
|||
|
|||
if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
curr_item = (BOARD_ITEM*) Begin_Route( NULL, aDC ); |
|||
SetCurItem( curr_item ); |
|||
|
|||
if( curr_item ) |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
else if( curr_item && curr_item->IsNew() ) |
|||
{ |
|||
TRACK* track = Begin_Route( (TRACK*) curr_item, aDC ); |
|||
|
|||
// SetCurItem() must not write to the msg panel
|
|||
// because a track info is displayed while moving the mouse cursor
|
|||
if( track ) // A new segment was created
|
|||
SetCurItem( curr_item = (BOARD_ITEM*) track, false ); |
|||
|
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_ZONES_BUTT: |
|||
case ID_PCB_KEEPOUT_BUTT: |
|||
/* ZONE or KEEPOUT Tool is selected. Determine action for a left click:
|
|||
* this can be start a new zone or select and move an existing zone outline corner |
|||
* if found near the mouse cursor |
|||
*/ |
|||
if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
if( Begin_Zone( aDC ) ) |
|||
{ |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
curr_item = GetBoard()->m_CurrentZoneContour; |
|||
GetScreen()->SetCurItem( curr_item ); |
|||
} |
|||
} |
|||
else if( curr_item && (curr_item->Type() == PCB_ZONE_AREA_T) && curr_item->IsNew() ) |
|||
{ // Add a new corner to the current outline being created:
|
|||
m_canvas->SetAutoPanRequest( true ); |
|||
Begin_Zone( aDC ); |
|||
curr_item = GetBoard()->m_CurrentZoneContour; |
|||
GetScreen()->SetCurItem( curr_item ); |
|||
} |
|||
else |
|||
{ |
|||
wxLogDebug( wxT( "PCB_EDIT_FRAME::OnLeftClick() zone internal error" ) ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_ADD_TEXT_BUTT: |
|||
if( Edge_Cuts == GetActiveLayer() ) |
|||
{ |
|||
DisplayError( this, |
|||
_( "Texts not allowed on Edge Cut layer" ) ); |
|||
break; |
|||
} |
|||
|
|||
if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
SetCurItem( CreateTextePcb( aDC ) ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
else if( curr_item->Type() == PCB_TEXT_T ) |
|||
{ |
|||
Place_Texte_Pcb( (TEXTE_PCB*) curr_item, aDC ); |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
} |
|||
else |
|||
{ |
|||
wxLogDebug( wxT( "OnLeftClick err: not a PCB_TEXT_T" ) ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_DIMENSION_BUTT: |
|||
if( IsCopperLayer( GetActiveLayer() ) || GetActiveLayer() == Edge_Cuts ) |
|||
{ |
|||
DisplayError( this, _( "Dimension not allowed on Copper or Edge Cut layers" ) ); |
|||
break; |
|||
} |
|||
|
|||
if( !curr_item || !curr_item->GetEditFlags() ) |
|||
{ |
|||
curr_item = (BOARD_ITEM*) EditDimension( NULL, aDC ); |
|||
SetCurItem( curr_item ); |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
else if( curr_item && (curr_item->Type() == PCB_DIMENSION_T) && curr_item->IsNew() ) |
|||
{ |
|||
curr_item = (BOARD_ITEM*) EditDimension( (DIMENSION*) curr_item, aDC ); |
|||
SetCurItem( curr_item ); |
|||
m_canvas->SetAutoPanRequest( true ); |
|||
} |
|||
else |
|||
{ |
|||
wxLogDebug( wxT( "PCB_EDIT_FRAME::OnLeftClick() error item is not a DIMENSION" ) ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_DELETE_ITEM_BUTT: |
|||
if( !curr_item || !curr_item->GetEditFlags() ) |
|||
{ |
|||
curr_item = PcbGeneralLocateAndDisplay(); |
|||
|
|||
if( curr_item && curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
RemoveStruct( curr_item, aDC ); |
|||
SetCurItem( curr_item = NULL ); |
|||
} |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_PLACE_OFFSET_COORD_BUTT: |
|||
PCB_EDITOR_CONTROL::SetDrillOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetAuxOrigin(), UR_TRANSIENT ), |
|||
GetCrossHairPosition() ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case ID_PCB_PLACE_GRID_COORD_BUTT: |
|||
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this, |
|||
new KIGFX::ORIGIN_VIEWITEM( GetBoard()->GetGridOrigin(), UR_TRANSIENT ), |
|||
GetCrossHairPosition() ); |
|||
m_canvas->Refresh(); |
|||
break; |
|||
|
|||
case ID_PCB_DRAW_VIA_BUTT: |
|||
DisplayError( this, _( "Via Tool not available in Legacy Toolset" ) ); |
|||
SetNoToolSelected(); |
|||
break; |
|||
|
|||
case ID_PCB_MEASUREMENT_TOOL: |
|||
DisplayError( this, _( "Measurement Tool not available in Legacy Toolset" ) ); |
|||
SetNoToolSelected(); |
|||
break; |
|||
|
|||
default: |
|||
wxLogDebug( wxT( "PCB_EDIT_FRAME::OnLeftClick() id error" ) ); |
|||
SetNoToolSelected(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
|
|||
/* handle the double click on the mouse left button
|
|||
*/ |
|||
void PCB_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) |
|||
{ |
|||
BOARD_ITEM* curr_item = GetCurItem(); |
|||
|
|||
switch( GetToolId() ) |
|||
{ |
|||
case ID_NO_TOOL_SELECTED: |
|||
if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) |
|||
curr_item = PcbGeneralLocateAndDisplay(); |
|||
|
|||
if( curr_item == NULL || curr_item->GetEditFlags() != 0 ) |
|||
break; |
|||
|
|||
SendMessageToEESCHEMA( curr_item ); |
|||
|
|||
// An item is found
|
|||
SetCurItem( curr_item ); |
|||
|
|||
switch( curr_item->Type() ) |
|||
{ |
|||
case PCB_TRACE_T: |
|||
case PCB_VIA_T: |
|||
if( curr_item->IsNew() ) |
|||
{ |
|||
if( End_Route( (TRACK*) curr_item, aDC ) ) |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
} |
|||
else if( curr_item->GetEditFlags() == 0 ) |
|||
{ |
|||
Edit_TrackSegm_Width( aDC, (TRACK*) curr_item ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case PCB_TEXT_T: |
|||
case PCB_PAD_T: |
|||
case PCB_MODULE_T: |
|||
case PCB_TARGET_T: |
|||
case PCB_DIMENSION_T: |
|||
case PCB_MODULE_TEXT_T: |
|||
OnEditItemRequest( aDC, curr_item ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
break; |
|||
|
|||
case PCB_LINE_T: |
|||
OnEditItemRequest( aDC, curr_item ); |
|||
break; |
|||
|
|||
case PCB_ZONE_AREA_T: |
|||
if( curr_item->GetEditFlags() ) |
|||
break; |
|||
|
|||
OnEditItemRequest( aDC, curr_item ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
|
|||
break; // end case 0
|
|||
|
|||
case ID_TRACK_BUTT: |
|||
if( curr_item && curr_item->IsNew() ) |
|||
{ |
|||
if( End_Route( (TRACK*) curr_item, aDC ) ) |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_ZONES_BUTT: |
|||
case ID_PCB_KEEPOUT_BUTT: |
|||
if( End_Zone( aDC ) ) |
|||
{ |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
SetCurItem( NULL ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case ID_PCB_ADD_LINE_BUTT: |
|||
case ID_PCB_ARC_BUTT: |
|||
case ID_PCB_CIRCLE_BUTT: |
|||
if( curr_item == NULL ) |
|||
break; |
|||
|
|||
if( curr_item->Type() != PCB_LINE_T ) |
|||
{ |
|||
DisplayErrorMessage( this, "Item type is incorrect", |
|||
wxString::Format( "Selected item type is %d\n" |
|||
"Expected: %d", curr_item->Type(), PCB_LINE_T ) ); |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
break; |
|||
} |
|||
|
|||
if( curr_item->IsNew() ) |
|||
{ |
|||
End_Edge( (DRAWSEGMENT*) curr_item, aDC ); |
|||
m_canvas->SetAutoPanRequest( false ); |
|||
SetCurItem( NULL ); |
|||
} |
|||
|
|||
break; |
|||
} |
|||
} |
|||
|
|||
|
|||
void PCB_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) |
|||
{ |
|||
switch( aItem->Type() ) |
|||
{ |
|||
case PCB_TRACE_T: |
|||
case PCB_VIA_T: |
|||
Edit_TrackSegm_Width( aDC, static_cast<TRACK*>( aItem ) ); |
|||
break; |
|||
|
|||
case PCB_TEXT_T: |
|||
InstallTextOptionsFrame( aItem, aDC ); |
|||
break; |
|||
|
|||
case PCB_PAD_T: |
|||
InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) ); |
|||
break; |
|||
|
|||
case PCB_MODULE_T: |
|||
InstallFootprintPropertiesDialog( static_cast<MODULE*>( aItem ), aDC ); |
|||
break; |
|||
|
|||
case PCB_TARGET_T: |
|||
ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ), aDC ); |
|||
break; |
|||
|
|||
case PCB_DIMENSION_T: |
|||
ShowDimensionPropertyDialog( static_cast<DIMENSION*>( aItem ), aDC ); |
|||
break; |
|||
|
|||
case PCB_MODULE_TEXT_T: |
|||
InstallTextOptionsFrame( aItem, aDC ); |
|||
break; |
|||
|
|||
case PCB_LINE_T: |
|||
InstallGraphicItemPropertiesDialog( aItem ); |
|||
break; |
|||
|
|||
case PCB_ZONE_AREA_T: |
|||
Edit_Zone_Params( aDC, static_cast<ZONE_CONTAINER*>( aItem ) ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue