2012-01-04 22:08:46 +00:00
|
|
|
/*
|
2011-10-19 20:32:21 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-01-17 14:25:47 +00:00
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2019-05-28 21:07:46 +00:00
|
|
|
* Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-01-17 14:25:47 +00:00
|
|
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-19 20:32:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file schedit.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiway.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <eda_doc.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <hotkeys_basic.h>
|
|
|
|
|
|
|
|
#include <general.h>
|
|
|
|
#include <eeschema_id.h>
|
2017-11-13 17:38:51 +00:00
|
|
|
#include <list_operations.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_library.h>
|
|
|
|
#include <sch_bus_entry.h>
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_junction.h>
|
|
|
|
#include <sch_line.h>
|
|
|
|
#include <sch_sheet.h>
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_view.h>
|
2019-04-02 11:39:09 +00:00
|
|
|
#include <simulation_cursors.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
pos = wxGetMousePosition();
|
|
|
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
|
|
// If needed, stop the current command and deselect current tool
|
|
|
|
switch( id )
|
|
|
|
{
|
2011-03-11 14:44:08 +00:00
|
|
|
case wxID_CUT:
|
|
|
|
case wxID_COPY:
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
|
2012-10-23 16:37:19 +00:00
|
|
|
case ID_POPUP_SCH_BEGIN_WIRE:
|
|
|
|
case ID_POPUP_SCH_BEGIN_BUS:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_END_LINE:
|
|
|
|
case ID_POPUP_SCH_SET_SHAPE_TEXT:
|
|
|
|
case ID_POPUP_SCH_CLEANUP_SHEET:
|
|
|
|
case ID_POPUP_SCH_END_SHEET:
|
|
|
|
case ID_POPUP_SCH_RESIZE_SHEET:
|
2015-07-24 10:23:34 +00:00
|
|
|
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_SCH_INIT_CMP:
|
|
|
|
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
case ID_POPUP_DRAG_BLOCK:
|
2017-07-04 08:08:33 +00:00
|
|
|
case ID_POPUP_DUPLICATE_BLOCK:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_SCH_DELETE_NODE:
|
|
|
|
case ID_POPUP_SCH_DELETE_CONNECTION:
|
|
|
|
case ID_POPUP_SCH_ENTER_SHEET:
|
|
|
|
case ID_POPUP_SCH_LEAVE_SHEET:
|
|
|
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
|
|
|
case ID_POPUP_SCH_ADD_LABEL:
|
2009-07-08 15:42:45 +00:00
|
|
|
case ID_POPUP_SCH_GETINFO_MARKER:
|
2009-11-04 20:46:53 +00:00
|
|
|
/* At this point: Do nothing. these commands do not need to stop the
|
|
|
|
* current command (mainly a block command) or reset the current state
|
|
|
|
* They will be executed later, in next switch structure.
|
2008-03-10 11:42:41 +00:00
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_SCH_DELETE_CMP:
|
2009-11-04 20:46:53 +00:00
|
|
|
case ID_POPUP_SCH_DELETE:
|
2009-12-20 19:48:58 +00:00
|
|
|
// Stop the current command (if any) but keep the current tool
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
default:
|
|
|
|
// Stop the current command and deselect the current tool
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-16 19:32:57 +00:00
|
|
|
item = screen->GetCurItem(); // Can be modified by previous calls.
|
2011-01-30 22:22:38 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case ID_HIERARCHY:
|
2015-07-11 07:37:52 +00:00
|
|
|
InstallHierarchyFrame( pos );
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2017-07-03 11:46:59 +00:00
|
|
|
case wxID_CUT: // save and delete block
|
2017-12-23 19:44:16 +00:00
|
|
|
case ID_POPUP_CUT_BLOCK:
|
2017-07-03 11:46:59 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2017-07-03 11:46:59 +00:00
|
|
|
screen->m_BlockLocate.SetCommand( BLOCK_CUT );
|
2013-10-15 16:18:30 +00:00
|
|
|
screen->m_BlockLocate.SetMessageBlock( this );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2009-01-06 20:09:32 +00:00
|
|
|
SetSheetNumberAndCount();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2017-07-03 11:46:59 +00:00
|
|
|
case wxID_COPY: // really this is a Save block for paste
|
2017-12-23 19:44:16 +00:00
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2017-07-04 08:08:33 +00:00
|
|
|
screen->m_BlockLocate.SetCommand( BLOCK_COPY );
|
2017-07-03 11:46:59 +00:00
|
|
|
screen->m_BlockLocate.SetMessageBlock( this );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2017-07-03 11:46:59 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case wxID_PASTE:
|
2018-10-30 10:48:23 +00:00
|
|
|
case ID_POPUP_PASTE_BLOCK:
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockBegin( nullptr, BLOCK_PASTE, GetCrossHairPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-08-03 12:18:26 +00:00
|
|
|
SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-08-03 12:18:26 +00:00
|
|
|
SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-03-11 14:44:08 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2018-08-27 13:28:21 +00:00
|
|
|
SetToolID( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString );
|
2011-03-11 14:44:08 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-27 17:51:22 +00:00
|
|
|
{
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2011-10-27 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_END_LINE:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-11-16 20:39:59 +00:00
|
|
|
EndSegment();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-10-23 16:37:19 +00:00
|
|
|
case ID_POPUP_SCH_BEGIN_WIRE:
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-08-03 12:18:26 +00:00
|
|
|
OnLeftClick( nullptr, GetCrossHairPosition() );
|
2012-10-23 16:37:19 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-10-23 16:37:19 +00:00
|
|
|
case ID_POPUP_SCH_BEGIN_BUS:
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-08-03 12:18:26 +00:00
|
|
|
OnLeftClick( nullptr, GetCrossHairPosition() );
|
2012-10-23 16:37:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_SET_SHAPE_TEXT:
|
2008-02-21 12:21:01 +00:00
|
|
|
// Not used
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_NODE:
|
|
|
|
case ID_POPUP_SCH_DELETE_CONNECTION:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-04-15 12:40:56 +00:00
|
|
|
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION );
|
2017-11-27 19:27:24 +00:00
|
|
|
SchematicCleanUp( true );
|
2008-04-17 16:25:29 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2016-02-19 15:41:32 +00:00
|
|
|
|
2018-10-16 13:11:33 +00:00
|
|
|
TestDanglingEnds();
|
2016-05-20 08:09:08 +00:00
|
|
|
m_canvas->Refresh();
|
2016-02-19 15:41:32 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_BREAK_WIRE:
|
2018-10-16 13:11:33 +00:00
|
|
|
SaveWireImage();
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
BreakSegments( GetCrossHairPosition() );
|
|
|
|
|
|
|
|
TestDanglingEnds();
|
|
|
|
m_canvas->Refresh();
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_CMP:
|
|
|
|
case ID_POPUP_SCH_DELETE:
|
2010-09-05 17:01:48 +00:00
|
|
|
if( item == NULL )
|
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
DeleteItem( item );
|
2017-11-27 19:27:24 +00:00
|
|
|
SchematicCleanUp( true );
|
2010-09-05 17:01:48 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2018-10-16 13:11:33 +00:00
|
|
|
TestDanglingEnds();
|
2010-09-05 17:01:48 +00:00
|
|
|
SetSheetNumberAndCount();
|
2018-10-18 09:50:43 +00:00
|
|
|
GetCanvas()->Refresh();
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2011-03-25 19:16:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_END_SHEET:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-09-10 10:58:50 +00:00
|
|
|
addCurrentItemToScreen();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_RESIZE_SHEET:
|
2018-08-03 12:18:26 +00:00
|
|
|
ReSizeSheet( (SCH_SHEET*) item, nullptr );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2015-07-24 10:23:34 +00:00
|
|
|
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item != NULL && item->Type() == SCH_SHEET_T )
|
2018-09-09 21:06:38 +00:00
|
|
|
screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item ) );
|
2009-05-16 05:38:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_CLEANUP_SHEET:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item != NULL && item->Type() == SCH_SHEET_T )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
if( !sheet->HasUndefinedPins() )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2018-09-09 21:06:38 +00:00
|
|
|
DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) );
|
2010-06-24 18:31:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
|
2010-06-24 18:31:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
|
|
|
|
SaveCopyInUndoList( sheet, UR_CHANGED );
|
|
|
|
sheet->CleanupSheet();
|
2018-10-18 09:50:43 +00:00
|
|
|
SyncView();
|
|
|
|
GetCanvas()->Refresh();
|
2010-06-24 18:31:43 +00:00
|
|
|
OnModify();
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_INIT_CMP:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
2011-03-29 15:21:35 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-09-09 21:06:38 +00:00
|
|
|
ConvertPart( (SCH_COMPONENT*) item );
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTER_SHEET:
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
if( item && (item->Type() == SCH_SHEET_T) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
m_CurrentSheet->push_back( (SCH_SHEET*) item );
|
2011-02-05 02:21:11 +00:00
|
|
|
DisplayCurrentSheet();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_LEAVE_SHEET:
|
2015-06-12 21:31:44 +00:00
|
|
|
if( m_CurrentSheet->Last() != g_RootSheet )
|
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
m_CurrentSheet->pop_back();
|
2015-06-12 21:31:44 +00:00
|
|
|
DisplayCurrentSheet();
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockPlace( nullptr );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2013-10-15 16:18:30 +00:00
|
|
|
screen->m_BlockLocate.SetCommand( BLOCK_ZOOM );
|
|
|
|
screen->m_BlockLocate.SetMessageBlock( this );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2015-08-09 15:04:49 +00:00
|
|
|
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
|
|
|
break;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2013-10-15 16:18:30 +00:00
|
|
|
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
|
|
|
|
screen->m_BlockLocate.SetMessageBlock( this );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2009-01-06 20:09:32 +00:00
|
|
|
SetSheetNumberAndCount();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2017-07-04 08:08:33 +00:00
|
|
|
case ID_POPUP_DUPLICATE_BLOCK:
|
2015-08-09 15:04:49 +00:00
|
|
|
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
|
|
|
break;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-07-04 08:08:33 +00:00
|
|
|
screen->m_BlockLocate.SetCommand( BLOCK_DUPLICATE );
|
2013-10-15 16:18:30 +00:00
|
|
|
screen->m_BlockLocate.SetMessageBlock( this );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DRAG_BLOCK:
|
2015-08-09 15:04:49 +00:00
|
|
|
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
|
|
|
break;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2013-10-15 16:18:30 +00:00
|
|
|
screen->m_BlockLocate.SetCommand( BLOCK_DRAG );
|
|
|
|
screen->m_BlockLocate.SetMessageBlock( this );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2017-11-16 20:39:59 +00:00
|
|
|
screen->SetCurItem( AddJunction( GetCrossHairPosition() ) );
|
2016-02-19 15:41:32 +00:00
|
|
|
|
2018-10-16 13:11:33 +00:00
|
|
|
TestDanglingEnds();
|
|
|
|
m_canvas->Refresh();
|
2016-02-19 15:41:32 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ADD_LABEL:
|
|
|
|
case ID_POPUP_SCH_ADD_GLABEL:
|
2018-09-09 21:06:38 +00:00
|
|
|
screen->SetCurItem( CreateNewText( id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL
|
|
|
|
: LAYER_GLOBLABEL ) );
|
2011-03-25 19:16:05 +00:00
|
|
|
item = screen->GetCurItem();
|
|
|
|
|
|
|
|
if( item )
|
2018-09-10 10:58:50 +00:00
|
|
|
addCurrentItemToScreen();
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
case ID_POPUP_SCH_GETINFO_MARKER:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_MARKER_T )
|
|
|
|
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default: // Log error:
|
2018-09-09 21:06:38 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// End switch ( id ) (Command execution)
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-04-19 12:08:12 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2012-10-08 19:34:04 +00:00
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
2011-04-19 12:08:12 +00:00
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
|
|
|
{
|
|
|
|
// trying to move an item when there is a block at the same time is not acceptable
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
if( item == NULL )
|
2011-10-21 13:59:15 +00:00
|
|
|
{
|
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
|
if( aEvent.GetInt() == 0 )
|
|
|
|
return;
|
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
2011-10-21 13:59:15 +00:00
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
2011-10-21 13:59:15 +00:00
|
|
|
|
|
|
|
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems,
|
|
|
|
aEvent.GetInt() );
|
|
|
|
|
|
|
|
// Exit if no item found at the current location or the item is already being edited.
|
|
|
|
if( (item == NULL) || (item->GetFlags() != 0) )
|
|
|
|
return;
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2018-11-04 00:25:45 +00:00
|
|
|
GetCanvas()->GetViewControls()->WarpCursor( GetCrossHairPosition(), true );
|
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-19 20:32:21 +00:00
|
|
|
case SCH_LINE_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
2013-04-01 10:35:20 +00:00
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
case SCH_TEXT_T:
|
2011-10-19 20:32:21 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2011-10-21 13:59:15 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
2011-10-22 12:31:44 +00:00
|
|
|
case SCH_FIELD_T:
|
2015-02-28 16:56:09 +00:00
|
|
|
case SCH_SHEET_T:
|
2018-09-08 11:12:41 +00:00
|
|
|
case SCH_BITMAP_T:
|
2018-09-09 21:06:38 +00:00
|
|
|
PrepareMoveItem( item );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-19 20:32:21 +00:00
|
|
|
case SCH_MARKER_T:
|
2015-02-28 16:56:09 +00:00
|
|
|
// Moving a marker has no sense
|
2015-03-11 16:04:20 +00:00
|
|
|
break;
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
default:
|
|
|
|
// Unknown items cannot be moved
|
2018-09-09 21:06:38 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( "Cannot move item type %d", item->Type() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-19 12:08:12 +00:00
|
|
|
|
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2011-02-05 19:22:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
|
|
|
if( screen->IsBlockActive() )
|
|
|
|
{
|
2018-09-09 21:06:38 +00:00
|
|
|
GetCanvas()->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() );
|
2011-02-05 19:22:58 +00:00
|
|
|
screen->ClearBlockCommand();
|
|
|
|
|
|
|
|
// Stop the current command (if any) but keep the current tool
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2011-02-05 19:22:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
|
|
|
|
m_canvas->EndMouseCapture();
|
2018-09-09 21:06:38 +00:00
|
|
|
else // Deselect current tool
|
2018-08-27 13:28:21 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
|
2011-03-05 10:35:18 +00:00
|
|
|
}
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
GetCanvas()->GetView()->ClearHiddenFlags();
|
|
|
|
GetCanvas()->GetView()->ClearPreview();
|
|
|
|
GetCanvas()->GetView()->ShowPreview( false );
|
2011-02-05 19:22:58 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|
|
|
{
|
2012-03-19 07:48:29 +00:00
|
|
|
int id = aEvent.GetId();
|
2017-06-10 07:06:25 +00:00
|
|
|
int lastToolID = GetToolId();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
// Stop the current command and deselect the current tool.
|
2018-08-27 13:28:21 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2016-11-16 10:07:02 +00:00
|
|
|
case ID_HIGHLIGHT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
|
2016-11-16 10:07:02 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_ZOOM_SELECTION:
|
2016-06-08 11:19:53 +00:00
|
|
|
case ID_ZOOM_SELECTION:
|
2017-06-10 07:06:25 +00:00
|
|
|
// This tool is located on the main toolbar: switch it on or off on click
|
|
|
|
if( lastToolID != ID_ZOOM_SELECTION )
|
|
|
|
SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
|
|
|
|
else
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2016-06-08 11:19:53 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_NOCONN_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_NOCONN_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_WIRE_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_WIRE_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_BUS_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_BUS_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_LINE_COMMENT_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_LINE_COMMENT_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_JUNCTION_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_JUNCTION_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_LABEL_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_LABEL_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_GLABEL_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_GLABEL_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_HIERLABEL_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_HIERLABEL_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_TEXT_COMMENT_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_TEXT_COMMENT_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_ADD_IMAGE_BUTT:
|
2011-08-31 14:59:20 +00:00
|
|
|
case ID_ADD_IMAGE_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
|
2011-08-31 14:59:20 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_WIRETOBUS_ENTRY_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_WIRETOBUS_ENTRY_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_BUSTOBUS_ENTRY_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_BUSTOBUS_ENTRY_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_SHEET_SYMBOL_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_SHEET_SYMBOL_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_SHEET_PIN_BUTT:
|
2011-03-30 19:26:05 +00:00
|
|
|
case ID_SHEET_PIN_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_IMPORT_HLABEL_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_IMPORT_HLABEL_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_PLACE_COMPONENT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_SCH_PLACE_COMPONENT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_PLACE_POWER_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_PLACE_POWER_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-01 18:58:27 +00:00
|
|
|
case ID_MENU_DELETE_ITEM_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
2018-04-01 18:58:27 +00:00
|
|
|
SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
2016-08-11 12:42:13 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2016-08-11 12:41:45 +00:00
|
|
|
case ID_SIM_PROBE:
|
2016-08-11 12:41:12 +00:00
|
|
|
SetToolID( id, -1, _( "Add a simulator probe" ) );
|
2019-04-02 11:39:09 +00:00
|
|
|
//GAL TODO: m_canvas->SetCurrentCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::PROBE ) );
|
2016-08-11 12:41:11 +00:00
|
|
|
break;
|
|
|
|
|
2016-08-11 12:41:45 +00:00
|
|
|
case ID_SIM_TUNE:
|
|
|
|
SetToolID( id, -1, _( "Select a value to be tuned" ) );
|
2019-04-02 11:39:09 +00:00
|
|
|
//GAL TODO: m_canvas->SetCurrentCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::TUNE ) );
|
2016-08-11 12:41:45 +00:00
|
|
|
break;
|
2016-08-11 12:42:13 +00:00
|
|
|
#endif /* KICAD_SPICE */
|
2016-08-11 12:41:45 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
default:
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2011-10-24 13:56:35 +00:00
|
|
|
|
|
|
|
// Simulate left click event if we got here from a hot key.
|
2011-10-26 20:46:04 +00:00
|
|
|
if( aEvent.GetClientObject() != NULL )
|
2011-10-24 13:56:35 +00:00
|
|
|
{
|
2011-10-26 20:46:04 +00:00
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
2011-10-24 13:56:35 +00:00
|
|
|
|
2018-09-09 21:06:38 +00:00
|
|
|
OnLeftClick( nullptr, data->GetPosition() );
|
2011-10-24 13:56:35 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2018-04-14 15:44:17 +00:00
|
|
|
if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
|
2018-04-13 20:41:36 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2011-04-15 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
|
|
|
|
{
|
2012-08-24 11:14:10 +00:00
|
|
|
PICKED_ITEMS_LIST pickList;
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint pos = GetCrossHairPosition();
|
2011-04-15 12:40:56 +00:00
|
|
|
|
|
|
|
if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
|
|
|
|
{
|
2017-10-12 23:41:25 +00:00
|
|
|
DeleteItemsInList( pickList );
|
2017-11-27 19:27:24 +00:00
|
|
|
SchematicCleanUp( true );
|
2011-04-15 12:40:56 +00:00
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-09 21:06:38 +00:00
|
|
|
bool SCH_EDIT_FRAME::DeleteItemAtCrossHair()
|
2011-04-15 12:40:56 +00:00
|
|
|
{
|
2012-08-24 11:14:10 +00:00
|
|
|
SCH_ITEM* item;
|
2011-04-15 12:40:56 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
item = LocateItem( GetCrossHairPosition(), SCH_COLLECTOR::ParentItems );
|
2011-04-15 12:40:56 +00:00
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
bool itemHasConnections = item->IsConnectable();
|
|
|
|
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
SetRepeatItem( NULL );
|
|
|
|
DeleteItem( item );
|
|
|
|
|
2018-09-09 21:06:38 +00:00
|
|
|
if( itemHasConnections )
|
2018-10-16 13:11:33 +00:00
|
|
|
TestDanglingEnds();
|
2011-04-15 12:40:56 +00:00
|
|
|
|
2018-09-10 10:58:50 +00:00
|
|
|
GetCanvas()->Refresh();
|
2011-04-15 12:40:56 +00:00
|
|
|
OnModify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-10-22 12:31:44 +00:00
|
|
|
|
2018-09-09 21:06:38 +00:00
|
|
|
// This function is a callback function, called by the mouse cursor moving event
|
2015-02-28 16:56:09 +00:00
|
|
|
static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase )
|
2011-10-22 12:31:44 +00:00
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
2012-08-24 11:14:10 +00:00
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
2018-08-03 12:18:26 +00:00
|
|
|
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
2018-10-23 16:16:23 +00:00
|
|
|
auto view = panel->GetView();
|
2011-10-22 12:31:44 +00:00
|
|
|
|
|
|
|
wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
|
|
|
|
cpos -= item->GetStoredPos();
|
|
|
|
|
|
|
|
item->SetPosition( cpos );
|
2011-10-22 12:31:44 +00:00
|
|
|
|
2018-10-23 16:16:23 +00:00
|
|
|
view->Hide( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
view->ClearPreview();
|
2018-10-23 16:16:23 +00:00
|
|
|
view->AddToPreview( item->Clone() );
|
2018-10-21 08:56:44 +00:00
|
|
|
|
|
|
|
// Needed when moving a bitmap image to avoid ugly rendering and artifacts,
|
|
|
|
// because a bitmap is drawn only as non cached
|
|
|
|
if( item->Type() == SCH_BITMAP_T )
|
|
|
|
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
2011-10-22 12:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-21 08:56:44 +00:00
|
|
|
/**
|
|
|
|
* Callback function called when aborting a move item with mouse cursor command.
|
|
|
|
*/
|
2011-10-22 12:31:44 +00:00
|
|
|
static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
|
|
|
{
|
2012-08-24 11:14:10 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
|
2018-08-03 12:18:26 +00:00
|
|
|
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
|
|
|
auto view = panel->GetView();
|
2011-10-22 12:31:44 +00:00
|
|
|
|
|
|
|
parent->SetRepeatItem( NULL );
|
|
|
|
screen->SetCurItem( NULL );
|
2018-08-03 12:18:26 +00:00
|
|
|
view->ClearPreview();
|
|
|
|
view->ClearHiddenFlags();
|
2011-10-22 12:31:44 +00:00
|
|
|
|
|
|
|
if( item == NULL ) /* no current item */
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( item->IsNew() )
|
|
|
|
{
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCH_ITEM* oldItem = parent->GetUndoItem();
|
|
|
|
|
|
|
|
SCH_ITEM* currentItem;
|
|
|
|
|
|
|
|
// Items that are children of other objects are undone by swapping the contents
|
|
|
|
// of the parent items.
|
|
|
|
if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
|
|
|
|
currentItem = (SCH_ITEM*) item->GetParent();
|
|
|
|
else
|
|
|
|
currentItem = item;
|
|
|
|
|
|
|
|
wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
|
|
|
|
wxT( "Cannot restore undefined or bad last schematic item." ) );
|
|
|
|
|
|
|
|
// Never delete existing item, because it can be referenced by an undo/redo command
|
|
|
|
// Just restore its data
|
2018-12-21 20:31:51 +00:00
|
|
|
|
2018-12-27 18:41:14 +00:00
|
|
|
view->Remove( currentItem );
|
2011-10-22 12:31:44 +00:00
|
|
|
currentItem->SwapData( oldItem );
|
|
|
|
item->ClearFlags();
|
2018-12-27 18:41:14 +00:00
|
|
|
view->Add( currentItem );
|
2018-12-21 20:31:51 +00:00
|
|
|
view->Hide( item, false );
|
2011-10-22 12:31:44 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 20:57:13 +00:00
|
|
|
screen->TestDanglingEnds();
|
2011-10-22 12:31:44 +00:00
|
|
|
aPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-09 21:06:38 +00:00
|
|
|
void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem )
|
2011-10-22 12:31:44 +00:00
|
|
|
{
|
|
|
|
wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
|
|
|
|
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2011-10-22 12:31:44 +00:00
|
|
|
|
2018-09-14 22:53:38 +00:00
|
|
|
if( !aItem->IsNew() )
|
2011-10-22 12:31:44 +00:00
|
|
|
{
|
|
|
|
if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
|
|
|
|
SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
|
|
|
|
else
|
|
|
|
SetUndoItem( aItem );
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:22:29 +00:00
|
|
|
std::vector<DANGLING_END_ITEM> emptySet;
|
|
|
|
aItem->UpdateDanglingState( emptySet );
|
|
|
|
|
2018-10-23 16:16:23 +00:00
|
|
|
aItem->SetFlags( IS_MOVED );
|
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
// Now that we're moving a field, they're no longer autoplaced.
|
2016-01-09 23:36:09 +00:00
|
|
|
SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
|
2015-12-13 16:56:47 +00:00
|
|
|
parent->ClearFieldsAutoplaced();
|
|
|
|
}
|
|
|
|
|
2018-10-24 15:08:21 +00:00
|
|
|
// These are owned by their parent, and so their parent must erase them
|
|
|
|
if( aItem->Type() == SCH_SHEET_PIN_T || aItem->Type() == SCH_FIELD_T )
|
|
|
|
RefreshItem( aItem );
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
// For some items, moving the cursor to anchor is not good
|
|
|
|
// (for instance large hierarchical sheets od componants can have
|
|
|
|
// the anchor position outside the canvas)
|
|
|
|
// these items return IsMovableFromAnchorPoint() == false
|
2018-09-09 09:57:36 +00:00
|
|
|
// For these items, do not warp the cursor
|
2015-02-28 16:56:09 +00:00
|
|
|
if( aItem->IsMovableFromAnchorPoint() )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( aItem->GetPosition() );
|
2015-02-28 16:56:09 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
aItem->SetStoredPos( wxPoint( 0,0 ) );
|
|
|
|
}
|
|
|
|
else
|
2016-03-30 18:19:32 +00:00
|
|
|
{
|
|
|
|
// Round the point under the cursor to a multiple of the grid
|
|
|
|
wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
|
|
|
|
wxPoint gridsize = GetScreen()->GetGridSize();
|
|
|
|
cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
|
|
|
|
cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
|
|
|
|
|
|
|
|
aItem->SetStoredPos( cursorpos );
|
|
|
|
}
|
2011-10-22 12:31:44 +00:00
|
|
|
|
|
|
|
OnModify();
|
2015-07-24 10:23:34 +00:00
|
|
|
|
2011-10-22 12:31:44 +00:00
|
|
|
GetScreen()->SetCurItem( aItem );
|
2015-07-24 10:23:34 +00:00
|
|
|
m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );
|
2018-09-09 21:06:38 +00:00
|
|
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
2015-02-28 16:56:09 +00:00
|
|
|
|
|
|
|
m_canvas->Refresh();
|
2011-10-22 12:31:44 +00:00
|
|
|
}
|
2011-10-26 20:46:04 +00:00
|
|
|
|
2017-09-18 09:25:32 +00:00
|
|
|
|
2017-07-24 19:58:55 +00:00
|
|
|
void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
|
|
|
|
{
|
2017-09-18 09:25:32 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
2017-07-24 19:58:55 +00:00
|
|
|
|
2017-09-18 09:25:32 +00:00
|
|
|
if( item != NULL )
|
|
|
|
{
|
2017-07-24 19:58:55 +00:00
|
|
|
item = LocateAndShowItem( item->GetPosition() );
|
2017-09-18 09:25:32 +00:00
|
|
|
SendMessageToPCBNEW( item, NULL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-24 19:58:55 +00:00
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
|
if( aEvent.GetInt() == 0 )
|
|
|
|
return;
|
2017-09-18 09:25:32 +00:00
|
|
|
|
2017-07-24 19:58:55 +00:00
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
|
|
|
|
|
|
|
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
|
|
|
|
|
|
|
item = LocateAndShowItem( data->GetPosition() );
|
2017-09-18 09:25:32 +00:00
|
|
|
SendMessageToPCBNEW( item, NULL );
|
|
|
|
}
|
2017-07-24 19:58:55 +00:00
|
|
|
}
|
2011-10-26 20:46:04 +00:00
|
|
|
|
2017-09-18 09:25:32 +00:00
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
|
|
|
{
|
2018-09-06 14:26:00 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
|
|
|
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
2011-10-26 20:46:04 +00:00
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
// Allows block rotate operation on hot key.
|
2018-09-06 14:26:00 +00:00
|
|
|
if( block.GetState() != STATE_NO_BLOCK )
|
2011-10-26 20:46:04 +00:00
|
|
|
{
|
2018-09-05 22:55:11 +00:00
|
|
|
// Compute the rotation center and put it on grid:
|
2018-10-30 10:48:23 +00:00
|
|
|
wxPoint rotationPoint = GetNearestGridPosition( block.Centre() );
|
2018-09-05 22:55:11 +00:00
|
|
|
|
2019-01-16 23:46:47 +00:00
|
|
|
if( block.GetCommand() != BLOCK_DUPLICATE && block.GetCommand() != BLOCK_PASTE )
|
2018-09-06 21:42:51 +00:00
|
|
|
{
|
|
|
|
SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
|
|
|
|
block.SetAppendUndo();
|
|
|
|
}
|
|
|
|
|
2018-09-06 14:26:00 +00:00
|
|
|
RotateListOfItems( block.GetItems(), rotationPoint );
|
|
|
|
|
2018-09-05 22:55:11 +00:00
|
|
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
2019-01-17 14:25:47 +00:00
|
|
|
m_canvas->Refresh();
|
2012-12-29 12:55:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-10-26 20:46:04 +00:00
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
if( item == NULL )
|
|
|
|
{
|
2011-10-28 20:30:50 +00:00
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
|
if( aEvent.GetInt() == 0 )
|
|
|
|
return;
|
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
|
|
|
|
|
|
|
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
|
|
|
|
|
|
|
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::RotatableItems,
|
|
|
|
aEvent.GetInt() );
|
|
|
|
|
|
|
|
// Exit if no item found at the current location or the item is already being edited.
|
|
|
|
if( (item == NULL) || (item->GetFlags() != 0) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_COMPONENT_T:
|
2015-12-13 16:56:47 +00:00
|
|
|
{
|
2016-01-09 23:36:09 +00:00
|
|
|
SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
|
|
|
|
OrientComponent( CMP_ROTATE_CLOCKWISE );
|
|
|
|
else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
|
|
|
|
OrientComponent( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
else
|
|
|
|
wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
if( m_autoplaceFields )
|
|
|
|
component->AutoAutoplaceFields( GetScreen() );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2011-10-26 20:46:04 +00:00
|
|
|
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2016-03-23 12:16:27 +00:00
|
|
|
ChangeTextOrient( (SCH_TEXT*) item );
|
2011-10-26 20:46:04 +00:00
|
|
|
break;
|
|
|
|
|
2019-01-28 05:55:12 +00:00
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
SaveCopyInUndoList( item, UR_CHANGED );
|
|
|
|
item->Rotate( m_canvas->GetParent()->GetCrossHairPosition() );
|
|
|
|
break;
|
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
case SCH_FIELD_T:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2016-03-23 12:16:27 +00:00
|
|
|
RotateField( (SCH_FIELD*) item );
|
2015-12-13 16:56:47 +00:00
|
|
|
if( item->GetParent()->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
// Now that we're moving a field, they're no longer autoplaced.
|
2016-01-09 23:36:09 +00:00
|
|
|
SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
|
2015-12-13 16:56:47 +00:00
|
|
|
parent->ClearFieldsAutoplaced();
|
|
|
|
}
|
2011-10-26 20:46:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_BITMAP_T:
|
|
|
|
RotateImage( (SCH_BITMAP*) item );
|
2018-09-08 11:12:41 +00:00
|
|
|
// The bitmap is cached in Opengl: clear the cache, because
|
|
|
|
// the cache data is invalid
|
2019-02-12 15:40:20 +00:00
|
|
|
GetCanvas()->GetView()->RecacheAllItems();
|
2011-10-26 20:46:04 +00:00
|
|
|
break;
|
|
|
|
|
2015-04-26 16:32:16 +00:00
|
|
|
case SCH_SHEET_T:
|
|
|
|
if( !item->IsNew() ) // rotate a sheet during its creation has no sense
|
|
|
|
{
|
|
|
|
bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
// these items are not rotated, because rotation does not change them.
|
|
|
|
break;
|
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
default:
|
2015-04-26 16:32:16 +00:00
|
|
|
// Other items (wires...) cannot be rotated, at least during creation
|
|
|
|
if( item->IsNew() )
|
|
|
|
break;
|
|
|
|
|
2011-10-27 13:34:28 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
|
|
|
|
GetChars( item->GetClass() ) ) );
|
|
|
|
}
|
|
|
|
|
2018-09-09 19:34:09 +00:00
|
|
|
RefreshItem( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-10-24 20:59:22 +00:00
|
|
|
if( item->IsMoving() )
|
|
|
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
|
|
|
|
2011-10-27 13:34:28 +00:00
|
|
|
if( item->GetFlags() == 0 )
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
{
|
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
|
if( aEvent.GetInt() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
|
|
|
|
|
|
|
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
|
|
|
|
2012-12-08 17:24:49 +00:00
|
|
|
// Set the locat filter, according to the edit command
|
|
|
|
const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
|
|
|
|
const KICAD_T* filterListAux = NULL;
|
2013-10-15 16:18:30 +00:00
|
|
|
|
2012-12-08 17:24:49 +00:00
|
|
|
switch( aEvent.GetId() )
|
|
|
|
{
|
|
|
|
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
|
|
|
filterList = SCH_COLLECTOR::CmpFieldReferenceOnly;
|
|
|
|
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCH_EDIT_COMPONENT_VALUE:
|
|
|
|
filterList = SCH_COLLECTOR::CmpFieldValueOnly;
|
|
|
|
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCH_EDIT_COMPONENT_FOOTPRINT:
|
|
|
|
filterList = SCH_COLLECTOR::CmpFieldFootprintOnly;
|
|
|
|
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
|
|
|
break;
|
|
|
|
|
2018-09-24 14:31:35 +00:00
|
|
|
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
|
|
|
filterList = SCH_COLLECTOR::CmpFieldDatasheetOnly;
|
|
|
|
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
|
|
|
|
2012-12-08 17:24:49 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-10-15 16:18:30 +00:00
|
|
|
|
|
|
|
item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
|
2012-12-08 17:24:49 +00:00
|
|
|
|
|
|
|
// If no item found, and if an auxiliary filter exists, try to use it
|
|
|
|
if( !item && filterListAux )
|
2013-10-15 16:18:30 +00:00
|
|
|
item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
|
2011-10-27 13:34:28 +00:00
|
|
|
|
|
|
|
// Exit if no item found at the current location or the item is already being edited.
|
|
|
|
if( (item == NULL) || (item->GetFlags() != 0) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_COMPONENT_T:
|
|
|
|
{
|
|
|
|
switch( aEvent.GetId() )
|
|
|
|
{
|
|
|
|
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
2012-06-03 11:16:08 +00:00
|
|
|
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
|
2011-10-27 13:34:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCH_EDIT_COMPONENT_VALUE:
|
2012-06-03 11:16:08 +00:00
|
|
|
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
|
2011-10-27 13:34:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCH_EDIT_COMPONENT_FOOTPRINT:
|
2012-06-03 11:16:08 +00:00
|
|
|
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
|
2011-10-27 13:34:28 +00:00
|
|
|
break;
|
|
|
|
|
2018-09-24 14:31:35 +00:00
|
|
|
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
|
|
|
{
|
|
|
|
wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
|
|
|
|
|
|
|
|
if( !text.IsEmpty() )
|
|
|
|
GetAssociatedDocument( this, text );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-10-27 13:34:28 +00:00
|
|
|
case ID_SCH_EDIT_ITEM:
|
|
|
|
EditComponent( (SCH_COMPONENT*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
|
|
|
|
aEvent.GetId() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
2018-09-03 10:11:39 +00:00
|
|
|
{
|
|
|
|
bool doClearAnnotation;
|
|
|
|
bool doRefresh = false;
|
|
|
|
// Keep trace of existing sheet paths. EditSheet() can modify this list
|
|
|
|
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
|
|
|
|
|
|
|
|
doRefresh = EditSheet( (SCH_SHEET*) item, m_CurrentSheet, &doClearAnnotation );
|
|
|
|
|
|
|
|
if( doClearAnnotation ) // happens when the current sheet load a existing file
|
|
|
|
{ // we must clear "new" components annotation
|
|
|
|
SCH_SCREENS screensList( g_RootSheet );
|
|
|
|
// We clear annotation of new sheet paths here:
|
|
|
|
screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
|
|
|
|
// Clear annotation of m_CurrentSheet itself, because its sheetpath
|
|
|
|
// is not a new path, but components managed by its sheet path must have
|
|
|
|
// their annotation cleared, becuase they are new:
|
2019-05-28 21:07:46 +00:00
|
|
|
((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( m_CurrentSheet );
|
2018-09-03 10:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( doRefresh )
|
2015-06-28 16:45:05 +00:00
|
|
|
m_canvas->Refresh();
|
2018-09-03 10:11:39 +00:00
|
|
|
}
|
2011-10-26 20:46:04 +00:00
|
|
|
break;
|
2011-10-27 13:34:28 +00:00
|
|
|
|
|
|
|
case SCH_SHEET_PIN_T:
|
2015-06-27 09:12:32 +00:00
|
|
|
EditSheetPin( (SCH_SHEET_PIN*) item, true );
|
2011-10-27 13:34:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
EditSchematicText( (SCH_TEXT*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_FIELD_T:
|
2012-06-03 11:16:08 +00:00
|
|
|
EditComponentFieldText( (SCH_FIELD*) item );
|
2011-10-27 13:34:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_BITMAP_T:
|
2019-02-12 15:40:20 +00:00
|
|
|
|
2018-09-08 11:12:41 +00:00
|
|
|
// The bitmap is cached in Opengl: clear the cache, because
|
|
|
|
// the cache data is perhaps invalid
|
2019-02-12 15:40:20 +00:00
|
|
|
if( EditImage( (SCH_BITMAP*) item ) )
|
|
|
|
GetCanvas()->GetView()->RecacheAllItems();
|
|
|
|
|
2011-10-27 13:34:28 +00:00
|
|
|
break;
|
|
|
|
|
2015-04-30 11:08:35 +00:00
|
|
|
case SCH_LINE_T: // These items have no param to edit
|
2017-10-31 16:33:37 +00:00
|
|
|
EditLine( (SCH_LINE*) item, true );
|
|
|
|
break;
|
2015-04-30 11:08:35 +00:00
|
|
|
case SCH_MARKER_T:
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // Unexpected item
|
2011-10-27 13:34:28 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
|
|
|
|
GetChars( item->GetClass() ) ) );
|
2011-10-26 20:46:04 +00:00
|
|
|
}
|
|
|
|
|
2018-09-09 19:34:09 +00:00
|
|
|
RefreshItem( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
if( item->GetFlags() == 0 )
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
}
|
2011-10-27 17:51:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
|
|
|
|
2014-07-29 16:38:27 +00:00
|
|
|
// The easiest way to handle a menu or a hot key drag command
|
|
|
|
// is to simulate a block drag command
|
|
|
|
//
|
|
|
|
// When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
|
|
|
|
// an some items use a BLOCK_DRAG drag type (mainly a junction)
|
|
|
|
// a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
|
|
|
|
// and BLOCK_DRAG_ITEM drag only the selected item
|
|
|
|
BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
|
2011-10-27 17:51:22 +00:00
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
{
|
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
|
if( aEvent.GetInt() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
|
|
|
|
|
|
|
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
|
|
|
|
|
|
|
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::DraggableItems,
|
|
|
|
aEvent.GetInt() );
|
|
|
|
|
|
|
|
// Exit if no item found at the current location or the item is already being edited.
|
|
|
|
if( (item == NULL) || (item->GetFlags() != 0) )
|
|
|
|
return;
|
2014-07-29 16:38:27 +00:00
|
|
|
|
|
|
|
// When a junction or a node is found, a BLOCK_DRAG is better
|
|
|
|
if( m_collectedItems.IsCorner() || m_collectedItems.IsNode( false )
|
|
|
|
|| m_collectedItems.IsDraggableJunction() )
|
2018-09-09 19:34:09 +00:00
|
|
|
{
|
2014-07-29 16:38:27 +00:00
|
|
|
dragType = BLOCK_DRAG;
|
2018-09-09 19:34:09 +00:00
|
|
|
}
|
2011-10-27 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2014-07-31 02:56:25 +00:00
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_LINE_T:
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_COMPONENT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
case SCH_SHEET_T:
|
2018-10-31 13:53:55 +00:00
|
|
|
case SCH_TEXT_T:
|
2014-07-31 02:56:25 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-10-27 17:51:22 +00:00
|
|
|
|
2014-07-31 02:56:25 +00:00
|
|
|
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
|
|
|
|
{
|
2018-08-03 12:18:26 +00:00
|
|
|
if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
|
2014-07-31 02:56:25 +00:00
|
|
|
break;
|
2011-10-27 17:51:22 +00:00
|
|
|
|
2014-07-31 02:56:25 +00:00
|
|
|
// Give a non null size to the search block:
|
|
|
|
screen->m_BlockLocate.Inflate( 1 );
|
2018-09-07 21:49:12 +00:00
|
|
|
screen->m_BlockLocate.SetLastCursorPosition( GetCrossHairPosition() );
|
2018-08-03 12:18:26 +00:00
|
|
|
HandleBlockEnd( nullptr );
|
2014-07-31 02:56:25 +00:00
|
|
|
}
|
2011-10-27 17:51:22 +00:00
|
|
|
|
2014-07-31 02:56:25 +00:00
|
|
|
break;
|
2011-10-27 17:51:22 +00:00
|
|
|
|
2014-07-31 02:56:25 +00:00
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
|
|
|
|
GetChars( item->GetClass() ) ) );
|
2011-10-27 17:51:22 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-28 20:30:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|
|
|
{
|
2018-09-06 14:26:00 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
|
|
|
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
// Allows block rotate operation on hot key.
|
2018-09-06 14:26:00 +00:00
|
|
|
if( block.GetState() != STATE_NO_BLOCK )
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
2012-12-29 12:55:36 +00:00
|
|
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
2013-10-15 16:18:30 +00:00
|
|
|
{
|
2018-09-06 14:26:00 +00:00
|
|
|
// Compute the mirror center and put it on grid.
|
2018-09-06 21:42:51 +00:00
|
|
|
wxPoint mirrorPt = block.Centre();
|
|
|
|
mirrorPt = GetNearestGridPosition( mirrorPt );
|
|
|
|
SetCrossHairPosition( mirrorPt );
|
2018-09-06 14:26:00 +00:00
|
|
|
|
2019-01-16 23:46:47 +00:00
|
|
|
if( block.GetCommand() != BLOCK_DUPLICATE && block.GetCommand() != BLOCK_PASTE )
|
2018-09-06 21:42:51 +00:00
|
|
|
{
|
|
|
|
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPt );
|
|
|
|
block.SetAppendUndo();
|
|
|
|
}
|
|
|
|
|
|
|
|
MirrorX( block.GetItems(), mirrorPt );
|
2018-09-06 14:26:00 +00:00
|
|
|
|
|
|
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
2019-01-17 14:25:47 +00:00
|
|
|
m_canvas->Refresh();
|
2018-09-06 14:26:00 +00:00
|
|
|
return;
|
2013-10-15 16:18:30 +00:00
|
|
|
}
|
2012-12-29 12:55:36 +00:00
|
|
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
2013-10-15 16:18:30 +00:00
|
|
|
{
|
2018-09-06 14:26:00 +00:00
|
|
|
// Compute the mirror center and put it on grid.
|
2018-09-06 21:42:51 +00:00
|
|
|
wxPoint mirrorPt = block.Centre();
|
|
|
|
mirrorPt = GetNearestGridPosition( mirrorPt );
|
|
|
|
SetCrossHairPosition( mirrorPt );
|
2018-09-06 14:26:00 +00:00
|
|
|
|
2019-01-16 23:46:47 +00:00
|
|
|
if( block.GetCommand() != BLOCK_DUPLICATE && block.GetCommand() != BLOCK_PASTE )
|
2018-09-06 21:42:51 +00:00
|
|
|
{
|
|
|
|
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPt );
|
|
|
|
block.SetAppendUndo();
|
|
|
|
}
|
|
|
|
|
|
|
|
MirrorY( block.GetItems(), mirrorPt );
|
2018-09-06 14:26:00 +00:00
|
|
|
|
|
|
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
2019-01-17 14:25:47 +00:00
|
|
|
m_canvas->Refresh();
|
2018-09-06 14:26:00 +00:00
|
|
|
return;
|
2013-10-15 16:18:30 +00:00
|
|
|
}
|
2012-12-29 12:55:36 +00:00
|
|
|
else
|
2013-10-15 16:18:30 +00:00
|
|
|
{
|
2012-12-29 12:55:36 +00:00
|
|
|
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
|
2013-10-15 16:18:30 +00:00
|
|
|
}
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2012-12-29 12:55:36 +00:00
|
|
|
if( item == NULL )
|
|
|
|
{
|
2011-10-28 20:30:50 +00:00
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
|
if( aEvent.GetInt() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
|
|
|
|
|
|
|
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
|
|
|
|
|
|
|
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::OrientableItems,
|
|
|
|
aEvent.GetInt() );
|
|
|
|
|
|
|
|
// Exit if no item found at the current location or the item is already being edited.
|
|
|
|
if( (item == NULL) || (item->GetFlags() != 0) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_COMPONENT_T:
|
2015-12-13 16:56:47 +00:00
|
|
|
{
|
2016-01-09 23:36:09 +00:00
|
|
|
SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
|
2015-12-13 16:56:47 +00:00
|
|
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
|
|
|
OrientComponent( CMP_MIRROR_X );
|
|
|
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
|
|
|
OrientComponent( CMP_MIRROR_Y );
|
|
|
|
else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
|
|
|
|
OrientComponent( CMP_NORMAL );
|
|
|
|
else
|
|
|
|
wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
|
|
|
|
|
|
|
|
if( m_autoplaceFields )
|
|
|
|
component->AutoAutoplaceFields( GetScreen() );
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-10-28 20:30:50 +00:00
|
|
|
|
|
|
|
case SCH_BITMAP_T:
|
|
|
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
|
|
|
MirrorImage( (SCH_BITMAP*) item, true );
|
|
|
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
|
|
|
MirrorImage( (SCH_BITMAP*) item, false );
|
|
|
|
|
2018-09-08 11:12:41 +00:00
|
|
|
// The bitmap is cached in Opengl: clear the cache, because
|
|
|
|
// the cache data is invalid
|
2019-02-12 15:40:20 +00:00
|
|
|
GetCanvas()->GetView()->RecacheAllItems();
|
2011-10-28 20:30:50 +00:00
|
|
|
break;
|
|
|
|
|
2015-04-26 16:32:16 +00:00
|
|
|
case SCH_SHEET_T:
|
|
|
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
|
|
|
MirrorSheet( (SCH_SHEET*) item, true );
|
|
|
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
|
|
|
MirrorSheet( (SCH_SHEET*) item, false );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2019-01-28 05:55:12 +00:00
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
SaveCopyInUndoList( item, UR_CHANGED );
|
|
|
|
|
|
|
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
|
|
|
item->MirrorX( m_canvas->GetParent()->GetCrossHairPosition().y );
|
|
|
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
|
|
|
item->MirrorY( m_canvas->GetParent()->GetCrossHairPosition().x );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2011-10-28 20:30:50 +00:00
|
|
|
default:
|
2015-09-15 13:51:47 +00:00
|
|
|
// This object cannot be oriented.
|
|
|
|
;
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-09 19:34:09 +00:00
|
|
|
RefreshItem( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-10-24 20:59:22 +00:00
|
|
|
if( item->IsMoving() )
|
|
|
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
|
|
|
|
2011-10-28 20:30:50 +00:00
|
|
|
if( item->GetFlags() == 0 )
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
}
|