2019-04-21 23:45:34 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2021-02-24 13:48:02 +00:00
|
|
|
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-04-21 23:45:34 +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
|
|
|
|
*/
|
|
|
|
|
2020-09-02 00:37:28 +00:00
|
|
|
#include <kiway.h>
|
2019-07-15 23:44:01 +00:00
|
|
|
#include <tool/picker_tool.h>
|
2019-04-23 13:06:37 +00:00
|
|
|
#include <tools/sch_edit_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_selection_tool.h>
|
2019-06-16 13:42:40 +00:00
|
|
|
#include <tools/sch_line_wire_bus_tool.h>
|
2019-05-04 13:02:05 +00:00
|
|
|
#include <tools/sch_move_tool.h>
|
2020-07-08 14:15:24 +00:00
|
|
|
#include <widgets/infobar.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <ee_actions.h>
|
2019-04-21 23:45:34 +00:00
|
|
|
#include <bitmaps.h>
|
2019-04-23 17:40:29 +00:00
|
|
|
#include <confirm.h>
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2020-07-08 14:15:24 +00:00
|
|
|
#include <reporter.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2019-05-10 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2019-04-23 17:40:29 +00:00
|
|
|
#include <sch_sheet.h>
|
2021-04-06 21:15:49 +00:00
|
|
|
#include <sch_sheet_pin.h>
|
2019-04-23 17:40:29 +00:00
|
|
|
#include <sch_text.h>
|
|
|
|
#include <sch_bitmap.h>
|
2019-04-23 13:06:37 +00:00
|
|
|
#include <sch_view.h>
|
2019-04-27 14:32:40 +00:00
|
|
|
#include <sch_line.h>
|
2019-04-29 17:50:46 +00:00
|
|
|
#include <sch_bus_entry.h>
|
2020-06-24 17:35:33 +00:00
|
|
|
#include <sch_junction.h>
|
2019-04-23 13:06:37 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
|
|
|
#include <drawing_sheet/ds_proxy_undo_item.h>
|
2019-04-27 23:50:35 +00:00
|
|
|
#include <eeschema_id.h>
|
2019-04-28 16:36:31 +00:00
|
|
|
#include <status_popup.h>
|
2019-04-30 13:54:32 +00:00
|
|
|
#include <wx/gdicmn.h>
|
2020-08-13 17:51:26 +00:00
|
|
|
#include <dialogs/dialog_change_symbols.h>
|
2019-06-19 10:31:21 +00:00
|
|
|
#include <dialogs/dialog_image_editor.h>
|
2021-07-12 10:58:14 +00:00
|
|
|
#include <dialogs/dialog_line_wire_bus_properties.h>
|
2020-10-17 23:25:39 +00:00
|
|
|
#include <dialogs/dialog_symbol_properties.h>
|
2020-10-29 22:46:33 +00:00
|
|
|
#include <dialogs/dialog_sheet_pin_properties.h>
|
2021-08-06 19:54:26 +00:00
|
|
|
#include <dialogs/dialog_field_properties.h>
|
2020-06-24 17:35:33 +00:00
|
|
|
#include <dialogs/dialog_junction_props.h>
|
2019-05-07 18:49:53 +00:00
|
|
|
#include "sch_drawing_tools.h"
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_editor_settings.h>
|
2021-08-06 19:54:26 +00:00
|
|
|
#include <dialogs/dialog_text_and_label_properties.h>
|
2021-01-12 23:55:46 +00:00
|
|
|
#include <core/kicad_algo.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
//#include <wx/filedlg.h>
|
|
|
|
#include <wx/textdlg.h>
|
|
|
|
|
2019-06-03 13:49:17 +00:00
|
|
|
|
2021-02-13 01:15:45 +00:00
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
class SYMBOL_UNIT_MENU : public ACTION_MENU
|
2019-05-02 20:03:03 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-06-15 00:29:42 +00:00
|
|
|
SYMBOL_UNIT_MENU() :
|
|
|
|
ACTION_MENU( true )
|
2019-05-02 20:03:03 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
SetIcon( BITMAPS::component_select_unit );
|
2019-05-02 20:03:03 +00:00
|
|
|
SetTitle( _( "Symbol Unit" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2019-05-14 11:14:00 +00:00
|
|
|
ACTION_MENU* create() const override
|
2019-05-02 20:03:03 +00:00
|
|
|
{
|
|
|
|
return new SYMBOL_UNIT_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void update() override
|
|
|
|
{
|
2019-05-10 17:19:48 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>();
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = selTool->GetSelection();
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
|
2019-05-02 20:03:03 +00:00
|
|
|
|
2019-06-19 20:04:34 +00:00
|
|
|
Clear();
|
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
if( !symbol )
|
2019-05-02 20:03:03 +00:00
|
|
|
{
|
|
|
|
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
|
|
|
|
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
int unit = symbol->GetUnit();
|
2019-05-02 20:03:03 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
if( !symbol->GetLibSymbolRef() || symbol->GetLibSymbolRef()->GetUnitCount() < 2 )
|
2019-05-02 20:03:03 +00:00
|
|
|
{
|
|
|
|
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
|
|
|
|
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
for( int ii = 0; ii < symbol->GetLibSymbolRef()->GetUnitCount(); ii++ )
|
2019-05-02 20:03:03 +00:00
|
|
|
{
|
|
|
|
wxString num_unit;
|
2021-06-10 18:51:46 +00:00
|
|
|
num_unit.Printf( _( "Unit %s" ), LIB_SYMBOL::SubReference( ii + 1, false ) );
|
2019-05-02 20:03:03 +00:00
|
|
|
|
|
|
|
wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
|
|
|
|
wxITEM_CHECK );
|
|
|
|
if( unit == ii + 1 )
|
|
|
|
item->Check(true);
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
// The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
|
2019-05-02 20:03:03 +00:00
|
|
|
// See eeschema_id to modify this value.
|
2021-06-10 14:10:55 +00:00
|
|
|
if( ii >= (ID_POPUP_SCH_SELECT_UNIT_SYM_MAX - ID_POPUP_SCH_SELECT_UNIT1) )
|
2019-05-02 20:03:03 +00:00
|
|
|
break; // We have used all IDs for these submenus
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-04-23 13:06:37 +00:00
|
|
|
SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
|
2019-04-23 13:06:37 +00:00
|
|
|
{
|
2020-01-11 00:11:31 +00:00
|
|
|
m_pickerItem = nullptr;
|
2019-04-26 18:37:47 +00:00
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
|
|
|
|
|
2019-05-17 16:45:27 +00:00
|
|
|
using E_C = EE_CONDITIONS;
|
|
|
|
|
2019-04-23 13:06:37 +00:00
|
|
|
bool SCH_EDIT_TOOL::Init()
|
|
|
|
{
|
2019-05-12 11:49:58 +00:00
|
|
|
EE_TOOL_BASE::Init();
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
SCH_DRAWING_TOOLS* drawingTools = m_toolMgr->GetTool<SCH_DRAWING_TOOLS>();
|
2019-05-12 11:49:58 +00:00
|
|
|
SCH_MOVE_TOOL* moveTool = m_toolMgr->GetTool<SCH_MOVE_TOOL>();
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-08-20 23:05:21 +00:00
|
|
|
auto hasElements =
|
|
|
|
[ this ] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return !m_frame->GetScreen()->Items().empty();
|
|
|
|
};
|
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
auto sheetTool =
|
|
|
|
[ this ] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return ( m_frame->IsCurrentTool( EE_ACTIONS::drawSheet ) );
|
|
|
|
};
|
2019-05-03 22:48:24 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
auto anyTextTool =
|
|
|
|
[ this ] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return ( m_frame->IsCurrentTool( EE_ACTIONS::placeLabel )
|
|
|
|
|| m_frame->IsCurrentTool( EE_ACTIONS::placeGlobalLabel )
|
|
|
|
|| m_frame->IsCurrentTool( EE_ACTIONS::placeHierLabel )
|
|
|
|
|| m_frame->IsCurrentTool( EE_ACTIONS::placeSchematicText ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto duplicateCondition =
|
|
|
|
[] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
|
|
|
return false;
|
2019-05-03 22:48:24 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
return true;
|
|
|
|
};
|
2019-05-02 10:59:36 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
auto orientCondition =
|
|
|
|
[] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
if( aSel.Empty() )
|
|
|
|
return false;
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
|
|
|
return false;
|
2019-04-29 17:50:46 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
if( aSel.GetSize() > 1 )
|
|
|
|
return true;
|
2019-05-01 23:35:05 +00:00
|
|
|
|
2021-07-29 19:23:11 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
|
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_MARKER_T:
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
case SCH_PIN_T:
|
|
|
|
return false;
|
2020-11-24 23:40:17 +00:00
|
|
|
case SCH_LINE_T:
|
|
|
|
return item->GetLayer() != LAYER_WIRE && item->GetLayer() != LAYER_BUS;
|
2020-04-20 23:24:29 +00:00
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2019-04-29 17:50:46 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
auto propertiesCondition =
|
2021-04-11 13:18:08 +00:00
|
|
|
[&]( const SELECTION& aSel )
|
2020-04-20 23:24:29 +00:00
|
|
|
{
|
|
|
|
if( aSel.GetSize() == 0 )
|
2021-04-11 13:18:08 +00:00
|
|
|
{
|
|
|
|
if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) )
|
|
|
|
{
|
|
|
|
DS_PROXY_VIEW_ITEM* ds = m_frame->GetCanvas()->GetView()->GetDrawingSheet();
|
|
|
|
VECTOR2D cursor = getViewControls()->GetCursorPosition( false );
|
|
|
|
|
|
|
|
if( ds && ds->HitTestDrawingSheetItems( getView(), (wxPoint) cursor ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-29 17:50:46 +00:00
|
|
|
|
2020-11-25 00:08:09 +00:00
|
|
|
SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
|
2020-06-19 11:48:00 +00:00
|
|
|
const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
|
|
|
|
|
2020-11-25 00:08:09 +00:00
|
|
|
if( !firstItem || !eeSelection )
|
|
|
|
return false;
|
2020-06-24 17:35:33 +00:00
|
|
|
|
2020-05-12 18:48:36 +00:00
|
|
|
switch( firstItem->Type() )
|
2020-04-20 23:24:29 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
case SCH_SYMBOL_T:
|
2020-04-20 23:24:29 +00:00
|
|
|
case SCH_SHEET_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_FIELD_T:
|
|
|
|
case SCH_BITMAP_T:
|
|
|
|
return aSel.GetSize() == 1;
|
|
|
|
|
|
|
|
case SCH_LINE_T:
|
2020-06-19 11:48:00 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
2020-11-22 22:21:41 +00:00
|
|
|
return eeSelection->AllItemsHaveLineStroke();
|
2020-04-20 23:24:29 +00:00
|
|
|
|
2020-06-24 17:35:33 +00:00
|
|
|
case SCH_JUNCTION_T:
|
2020-11-22 22:21:41 +00:00
|
|
|
return eeSelection->AreAllItemsIdentical();
|
2020-06-24 17:35:33 +00:00
|
|
|
|
2020-04-20 23:24:29 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2019-04-29 20:38:05 +00:00
|
|
|
|
2021-07-29 19:23:11 +00:00
|
|
|
auto autoplaceCondition =
|
|
|
|
[] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
for( const EDA_ITEM* item : aSel )
|
|
|
|
{
|
|
|
|
if( item->IsType( EE_COLLECTOR::FieldOwners ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2019-05-20 18:05:27 +00:00
|
|
|
static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
|
2019-05-17 16:45:27 +00:00
|
|
|
auto toLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-20 18:05:27 +00:00
|
|
|
static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
|
|
|
|
auto toHLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-20 18:05:27 +00:00
|
|
|
static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
|
|
|
|
auto toGLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-20 18:05:27 +00:00
|
|
|
static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
|
|
|
|
auto toTextlCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes );
|
2019-05-01 21:50:11 +00:00
|
|
|
|
2019-05-20 18:05:27 +00:00
|
|
|
static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
|
2019-05-17 16:45:27 +00:00
|
|
|
auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
|
2019-05-01 21:50:11 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
|
2021-02-19 14:51:18 +00:00
|
|
|
|
2019-05-02 10:59:36 +00:00
|
|
|
//
|
2019-05-04 13:02:05 +00:00
|
|
|
// Add edit actions to the move tool menu
|
2019-04-28 23:34:43 +00:00
|
|
|
//
|
2019-05-04 13:02:05 +00:00
|
|
|
if( moveTool )
|
|
|
|
{
|
|
|
|
CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
|
|
|
|
|
2019-06-15 16:40:14 +00:00
|
|
|
moveMenu.AddSeparator();
|
2019-05-10 17:19:48 +00:00
|
|
|
moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
|
|
|
|
moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
|
2021-02-16 20:45:25 +00:00
|
|
|
moveMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition );
|
|
|
|
moveMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition );
|
2019-05-10 17:19:48 +00:00
|
|
|
|
|
|
|
moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
|
2021-02-21 23:45:32 +00:00
|
|
|
moveMenu.AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol );
|
|
|
|
moveMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol );
|
|
|
|
moveMenu.AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol );
|
2019-06-01 19:48:01 +00:00
|
|
|
moveMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
|
|
|
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
|
|
|
|
symUnitMenu->SetTool( this );
|
|
|
|
m_menu.AddSubMenu( symUnitMenu );
|
2019-05-17 16:45:27 +00:00
|
|
|
moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2019-06-15 16:40:14 +00:00
|
|
|
moveMenu.AddSeparator();
|
2019-05-17 16:45:27 +00:00
|
|
|
moveMenu.AddItem( ACTIONS::cut, E_C::IdleSelection );
|
|
|
|
moveMenu.AddItem( ACTIONS::copy, E_C::IdleSelection );
|
2021-01-17 18:19:02 +00:00
|
|
|
moveMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty );
|
2019-05-27 10:40:52 +00:00
|
|
|
moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
|
2020-08-20 23:05:21 +00:00
|
|
|
|
|
|
|
moveMenu.AddSeparator();
|
|
|
|
moveMenu.AddItem( ACTIONS::selectAll, hasElements );
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-02 10:59:36 +00:00
|
|
|
//
|
2019-04-28 23:34:43 +00:00
|
|
|
// Add editing actions to the drawing tool menu
|
|
|
|
//
|
2019-05-08 18:56:03 +00:00
|
|
|
CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-17 15:44:58 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
|
2021-02-16 20:45:25 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
|
2019-05-17 15:44:58 +00:00
|
|
|
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
|
2021-02-21 23:45:32 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
|
2021-07-29 19:23:11 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 );
|
2019-06-01 19:48:01 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol, 200 );
|
2019-05-02 20:03:03 +00:00
|
|
|
|
|
|
|
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
|
2019-05-08 18:56:03 +00:00
|
|
|
symUnitMenu2->SetTool( drawingTools );
|
|
|
|
drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
|
2019-05-17 16:45:27 +00:00
|
|
|
drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
|
2019-05-02 20:03:03 +00:00
|
|
|
|
2021-02-21 23:45:32 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::editWithLibEdit, E_C::SingleSymbolOrPower && E_C::Idle, 200 );
|
2019-05-06 20:37:54 +00:00
|
|
|
|
2019-05-17 16:45:27 +00:00
|
|
|
drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
|
|
|
|
drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && E_C::Idle, 250 );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-02 10:59:36 +00:00
|
|
|
//
|
2019-04-28 23:34:43 +00:00
|
|
|
// Add editing actions to the selection tool menu
|
|
|
|
//
|
|
|
|
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
|
2021-02-16 20:45:25 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
|
2019-05-02 10:59:36 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
|
2019-05-17 16:45:27 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::editReference, E_C::SingleSymbol, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
|
2021-07-29 19:23:11 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, autoplaceCondition, 200 );
|
2019-06-01 19:48:01 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleSymbol, 200 );
|
2019-05-02 20:03:03 +00:00
|
|
|
|
|
|
|
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
|
|
|
|
symUnitMenu3->SetTool( m_selectionTool );
|
|
|
|
m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
|
2019-05-17 16:45:27 +00:00
|
|
|
selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
|
2019-05-02 20:03:03 +00:00
|
|
|
|
2021-02-21 23:45:32 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::editWithLibEdit, E_C::SingleSymbolOrPower && E_C::Idle, 200 );
|
2021-02-17 00:14:23 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::changeSymbol, E_C::SingleSymbolOrPower, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::updateSymbol, E_C::SingleSymbolOrPower, 200 );
|
2019-05-06 20:37:54 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
|
|
|
|
selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
|
2019-05-17 15:16:13 +00:00
|
|
|
selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 250 );
|
2019-04-29 10:41:27 +00:00
|
|
|
|
2019-06-15 16:40:14 +00:00
|
|
|
selToolMenu.AddSeparator( 300 );
|
2019-05-17 16:45:27 +00:00
|
|
|
selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
|
|
|
|
selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
|
|
|
|
selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
|
2019-09-02 18:23:46 +00:00
|
|
|
selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
|
2021-01-17 18:19:02 +00:00
|
|
|
selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 300 );
|
2019-05-27 10:40:52 +00:00
|
|
|
selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2020-08-20 23:05:21 +00:00
|
|
|
selToolMenu.AddSeparator( 400 );
|
|
|
|
selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
|
|
|
|
|
|
|
|
|
2019-04-23 13:06:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-17 21:11:41 +00:00
|
|
|
const KICAD_T rotatableItems[] = {
|
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIER_LABEL_T,
|
|
|
|
SCH_FIELD_T,
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL_T,
|
2019-06-17 21:11:41 +00:00
|
|
|
SCH_SHEET_PIN_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
SCH_BITMAP_T,
|
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
|
|
|
SCH_LINE_T,
|
|
|
|
SCH_JUNCTION_T,
|
2020-03-28 11:50:37 +00:00
|
|
|
SCH_NO_CONNECT_T,
|
2019-06-17 21:11:41 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-04-23 17:40:29 +00:00
|
|
|
int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
|
2019-06-17 21:11:41 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( rotatableItems );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() == 0 )
|
|
|
|
return 0;
|
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
SCH_ITEM* head = nullptr;
|
|
|
|
int principalItemCount = 0; // User-selected items (as opposed to connected wires)
|
2019-04-23 17:40:29 +00:00
|
|
|
wxPoint rotPoint;
|
2020-12-23 01:17:18 +00:00
|
|
|
bool moving = false;
|
2019-04-23 17:40:29 +00:00
|
|
|
bool connections = false;
|
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
|
|
|
|
|
|
|
|
if( item->HasFlag( TEMP_SELECTED ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
principalItemCount++;
|
|
|
|
|
|
|
|
if( !head )
|
|
|
|
head = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( head && head->IsMoving() )
|
|
|
|
moving = true;
|
|
|
|
|
|
|
|
if( principalItemCount == 1 )
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
rotPoint = head->GetPosition();
|
|
|
|
|
2019-04-23 17:40:29 +00:00
|
|
|
if( !moving )
|
2020-12-23 01:17:18 +00:00
|
|
|
saveCopyInUndoList( head, UNDO_REDO::CHANGED );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
switch( head->Type() )
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
case SCH_SYMBOL_T:
|
2020-01-08 19:07:55 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( head );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
if( clockwise )
|
2021-06-10 14:10:55 +00:00
|
|
|
symbol->SetOrientation( SYM_ROTATE_CLOCKWISE );
|
2020-01-08 19:07:55 +00:00
|
|
|
else
|
2021-06-10 14:10:55 +00:00
|
|
|
symbol->SetOrientation( SYM_ROTATE_COUNTERCLOCKWISE );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
if( m_frame->eeconfig()->m_AutoplaceFields.enable )
|
2021-03-19 20:27:30 +00:00
|
|
|
symbol->AutoAutoplaceFields( m_frame->GetScreen() );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( head );
|
2020-11-18 21:40:04 +00:00
|
|
|
textItem->Rotate90( clockwise );
|
2020-01-08 19:07:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
{
|
|
|
|
// Rotate pin within parent sheet
|
2020-12-23 01:17:18 +00:00
|
|
|
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( head );
|
2020-01-08 19:07:55 +00:00
|
|
|
SCH_SHEET* sheet = pin->GetParent();
|
2020-11-18 21:40:04 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
|
2019-05-17 16:45:27 +00:00
|
|
|
pin->Rotate( sheet->GetBoundingBox().GetCenter() );
|
2020-11-18 23:34:03 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-11-24 23:40:17 +00:00
|
|
|
case SCH_LINE_T:
|
2020-01-08 19:07:55 +00:00
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
|
2020-12-23 01:17:18 +00:00
|
|
|
head->Rotate( rotPoint );
|
2020-11-18 21:40:04 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
break;
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case SCH_FIELD_T:
|
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
SCH_FIELD* field = static_cast<SCH_FIELD*>( head );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
|
|
|
|
field->SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
else
|
|
|
|
field->SetTextAngle( TEXT_ANGLE_HORIZ );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
// Now that we're moving a field, they're no longer autoplaced.
|
2020-12-23 01:17:18 +00:00
|
|
|
static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced();
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
case SCH_BITMAP_T:
|
|
|
|
for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
|
2020-12-23 01:17:18 +00:00
|
|
|
head->Rotate( rotPoint );
|
2020-11-18 21:40:04 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
// The bitmap is cached in Opengl: clear the cache to redraw
|
|
|
|
getView()->RecacheAllItems();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( head );
|
|
|
|
rotPoint = m_frame->GetNearestGridPosition( sheet->GetRotationCenter() );
|
2019-09-02 21:34:50 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
// Rotate the sheet on itself. Sheets do not have an anchor point.
|
2020-03-06 20:02:58 +00:00
|
|
|
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
|
2019-09-02 21:34:50 +00:00
|
|
|
sheet->Rotate( rotPoint );
|
2020-12-23 01:17:18 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
default:
|
|
|
|
break;
|
2019-04-23 17:40:29 +00:00
|
|
|
}
|
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
connections = head->IsConnectable();
|
|
|
|
m_frame->UpdateItem( head );
|
2019-04-23 17:40:29 +00:00
|
|
|
}
|
2020-12-23 01:17:18 +00:00
|
|
|
else
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
2019-07-08 23:14:10 +00:00
|
|
|
rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
|
2020-12-23 01:17:18 +00:00
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
// We've already rotated the user selected item if there was only one. We're just
|
|
|
|
// here to rotate the ends of wires that were attached to it.
|
|
|
|
if( principalItemCount == 1 && !item->HasFlag( TEMP_SELECTED ) )
|
|
|
|
continue;
|
2019-04-23 17:40:29 +00:00
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
if( !moving )
|
|
|
|
saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
|
|
|
|
|
|
|
|
for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_LINE_T )
|
2019-05-03 22:46:44 +00:00
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
SCH_LINE* line = (SCH_LINE*) item;
|
2019-05-17 16:45:27 +00:00
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
if( item->HasFlag( STARTPOINT ) )
|
|
|
|
line->RotateStart( rotPoint );
|
2019-05-17 16:45:27 +00:00
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
if( item->HasFlag( ENDPOINT ) )
|
|
|
|
line->RotateEnd( rotPoint );
|
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_SHEET_PIN_T )
|
|
|
|
{
|
|
|
|
if( item->GetParent()->IsSelected() )
|
2019-05-17 16:45:27 +00:00
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
// parent will rotate us
|
2019-05-17 16:45:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-23 01:17:18 +00:00
|
|
|
// rotate within parent
|
|
|
|
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
|
|
|
|
SCH_SHEET* sheet = pin->GetParent();
|
|
|
|
|
|
|
|
pin->Rotate( sheet->GetBoundingBox().GetCenter() );
|
2019-05-17 16:45:27 +00:00
|
|
|
}
|
2019-05-03 22:46:44 +00:00
|
|
|
}
|
2021-02-04 00:04:54 +00:00
|
|
|
else if( item->Type() == SCH_FIELD_T )
|
|
|
|
{
|
|
|
|
if( item->GetParent()->IsSelected() )
|
|
|
|
{
|
|
|
|
// parent will rotate us
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-13 19:02:32 +00:00
|
|
|
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
|
|
|
|
|
|
|
field->Rotate( rotPoint );
|
|
|
|
|
|
|
|
if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
|
|
|
|
field->SetTextAngle( TEXT_ANGLE_VERT );
|
|
|
|
else
|
|
|
|
field->SetTextAngle( TEXT_ANGLE_HORIZ );
|
|
|
|
|
|
|
|
// Now that we're moving a field, they're no longer autoplaced.
|
|
|
|
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
|
2021-02-04 00:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-23 01:17:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
item->Rotate( rotPoint );
|
|
|
|
}
|
2019-04-23 17:40:29 +00:00
|
|
|
}
|
2020-12-23 01:17:18 +00:00
|
|
|
|
|
|
|
connections |= item->IsConnectable();
|
|
|
|
m_frame->UpdateItem( item );
|
2019-04-23 17:40:29 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
2020-12-23 01:17:18 +00:00
|
|
|
if( moving )
|
2019-05-20 10:22:36 +00:00
|
|
|
{
|
2019-07-04 20:56:21 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
2019-05-20 10:22:36 +00:00
|
|
|
}
|
|
|
|
else
|
2019-04-23 17:40:29 +00:00
|
|
|
{
|
2019-04-26 16:34:04 +00:00
|
|
|
if( selection.IsHover() )
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
if( connections )
|
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-17 21:11:41 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( rotatableItems );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() == 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
wxPoint mirrorPoint;
|
2021-02-16 20:45:25 +00:00
|
|
|
bool vertical = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
|
2019-05-01 21:50:11 +00:00
|
|
|
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
|
2019-04-26 16:34:04 +00:00
|
|
|
bool connections = false;
|
|
|
|
bool moving = item->IsMoving();
|
|
|
|
|
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
|
|
|
if( !moving )
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( item, UNDO_REDO::CHANGED );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
case SCH_SYMBOL_T:
|
2019-04-26 16:34:04 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
2021-06-10 14:10:55 +00:00
|
|
|
symbol->SetOrientation( SYM_MIRROR_X );
|
2019-04-26 16:34:04 +00:00
|
|
|
else
|
2021-06-10 14:10:55 +00:00
|
|
|
symbol->SetOrientation( SYM_MIRROR_Y );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
if( m_frame->eeconfig()->m_AutoplaceFields.enable )
|
2021-03-19 20:27:30 +00:00
|
|
|
symbol->AutoAutoplaceFields( m_frame->GetScreen() );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
{
|
|
|
|
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
|
2021-02-16 20:45:25 +00:00
|
|
|
textItem->MirrorSpinStyle( !vertical );
|
2019-04-26 16:34:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-05-17 16:45:27 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
{
|
|
|
|
// mirror within parent sheet
|
|
|
|
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
|
|
|
|
SCH_SHEET* sheet = pin->GetParent();
|
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
|
|
|
pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
|
2019-05-17 16:45:27 +00:00
|
|
|
else
|
2021-02-16 20:45:25 +00:00
|
|
|
pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
|
2019-05-17 16:45:27 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-04-26 16:34:04 +00:00
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
|
|
|
item->MirrorVertically( item->GetPosition().y );
|
2019-04-26 16:34:04 +00:00
|
|
|
else
|
2021-02-16 20:45:25 +00:00
|
|
|
item->MirrorHorizontally( item->GetPosition().x );
|
2019-04-26 16:34:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_FIELD_T:
|
|
|
|
{
|
|
|
|
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
2019-04-26 16:34:04 +00:00
|
|
|
field->SetVertJustify( (EDA_TEXT_VJUSTIFY_T)-field->GetVertJustify() );
|
|
|
|
else
|
|
|
|
field->SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-field->GetHorizJustify() );
|
|
|
|
|
|
|
|
// Now that we're re-justifying a field, they're no longer autoplaced.
|
2020-03-06 20:02:58 +00:00
|
|
|
static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCH_BITMAP_T:
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
|
|
|
item->MirrorVertically( item->GetPosition().y );
|
2019-04-26 16:34:04 +00:00
|
|
|
else
|
2021-02-16 20:45:25 +00:00
|
|
|
item->MirrorHorizontally( item->GetPosition().x );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
// The bitmap is cached in Opengl: clear the cache to redraw
|
|
|
|
getView()->RecacheAllItems();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
// Mirror the sheet on itself. Sheets do not have a anchor point.
|
2021-02-15 19:58:12 +00:00
|
|
|
mirrorPoint = m_frame->GetNearestHalfGridPosition( item->GetBoundingBox().Centre() );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
|
|
|
item->MirrorVertically( mirrorPoint.y );
|
2019-04-26 16:34:04 +00:00
|
|
|
else
|
2021-02-16 20:45:25 +00:00
|
|
|
item->MirrorHorizontally( mirrorPoint.x );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
connections = item->IsConnectable();
|
2020-08-10 11:40:58 +00:00
|
|
|
m_frame->UpdateItem( item );
|
2019-04-26 16:34:04 +00:00
|
|
|
}
|
|
|
|
else if( selection.GetSize() > 1 )
|
|
|
|
{
|
2021-02-15 19:58:12 +00:00
|
|
|
mirrorPoint = m_frame->GetNearestHalfGridPosition( (wxPoint)selection.GetCenter() );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
|
|
|
|
{
|
|
|
|
item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
|
|
|
|
|
|
|
|
if( !moving )
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
2019-05-17 16:45:27 +00:00
|
|
|
if( item->Type() == SCH_SHEET_PIN_T )
|
|
|
|
{
|
|
|
|
if( item->GetParent()->IsSelected() )
|
|
|
|
{
|
|
|
|
// parent will mirror us
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// mirror within parent sheet
|
|
|
|
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
|
|
|
|
SCH_SHEET* sheet = pin->GetParent();
|
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
|
|
|
pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
|
2019-05-17 16:45:27 +00:00
|
|
|
else
|
2021-02-16 20:45:25 +00:00
|
|
|
pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
|
2019-05-17 16:45:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-26 16:34:04 +00:00
|
|
|
else
|
2019-05-17 16:45:27 +00:00
|
|
|
{
|
2021-02-16 20:45:25 +00:00
|
|
|
if( vertical )
|
|
|
|
item->MirrorVertically( mirrorPoint.y );
|
2019-05-17 16:45:27 +00:00
|
|
|
else
|
2021-02-16 20:45:25 +00:00
|
|
|
item->MirrorHorizontally( mirrorPoint.x );
|
2019-05-17 16:45:27 +00:00
|
|
|
}
|
2019-04-26 16:34:04 +00:00
|
|
|
|
|
|
|
connections |= item->IsConnectable();
|
2020-08-10 11:40:58 +00:00
|
|
|
m_frame->UpdateItem( item );
|
2019-04-26 16:34:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
|
2020-12-02 00:18:44 +00:00
|
|
|
// Update R-Tree for modified items
|
|
|
|
for( EDA_ITEM* selected : selection )
|
|
|
|
updateItem( selected, true );
|
|
|
|
|
2019-05-20 10:22:36 +00:00
|
|
|
if( item->IsMoving() )
|
|
|
|
{
|
2019-07-04 20:56:21 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
2019-05-20 10:22:36 +00:00
|
|
|
}
|
|
|
|
else
|
2019-04-26 16:34:04 +00:00
|
|
|
{
|
|
|
|
if( selection.IsHover() )
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
2019-04-26 16:34:04 +00:00
|
|
|
|
2019-04-23 17:40:29 +00:00
|
|
|
if( connections )
|
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-26 22:23:12 +00:00
|
|
|
int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
|
|
|
|
|
|
|
|
if( !sourceItem )
|
|
|
|
return 0;
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
2019-04-26 22:23:12 +00:00
|
|
|
|
2020-02-20 12:11:04 +00:00
|
|
|
SCH_ITEM* newItem = sourceItem->Duplicate();
|
2019-04-26 22:23:12 +00:00
|
|
|
bool performDrag = false;
|
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
// If cloning a symbol then put into 'move' mode.
|
2021-06-10 14:10:55 +00:00
|
|
|
if( newItem->Type() == SCH_SYMBOL_T )
|
2019-04-26 22:23:12 +00:00
|
|
|
{
|
2019-05-04 13:02:05 +00:00
|
|
|
wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
|
|
|
|
newItem->Move( cursorPos - newItem->GetPosition() );
|
2019-04-26 22:23:12 +00:00
|
|
|
performDrag = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
if( m_isSymbolEditor )
|
2020-04-12 23:09:17 +00:00
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
|
|
|
|
if( dynamic_cast<SCH_TEXT*>( newItem ) )
|
|
|
|
{
|
|
|
|
SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
|
|
|
|
text->IncrementLabel( cfg->m_Repeat.label_delta );
|
|
|
|
}
|
|
|
|
|
|
|
|
newItem->Move( wxPoint( Mils2iu( cfg->m_Repeat.x_step ),
|
|
|
|
Mils2iu( cfg->m_Repeat.y_step ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
|
|
|
|
|
|
|
if( dynamic_cast<SCH_TEXT*>( newItem ) )
|
|
|
|
{
|
|
|
|
SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
|
2020-12-04 12:48:32 +00:00
|
|
|
|
|
|
|
// If incrementing tries to go below zero, tell user why the value is repeated
|
|
|
|
|
|
|
|
if( !text->IncrementLabel( cfg->m_Drawing.repeat_label_increment ) )
|
2020-12-04 13:45:14 +00:00
|
|
|
m_frame->ShowInfoBarWarning( _( "Label value cannot go below zero" ), true );
|
2020-04-12 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ),
|
|
|
|
Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ) );
|
|
|
|
}
|
2019-04-26 22:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
newItem->SetFlags( IS_NEW );
|
2020-07-13 11:21:40 +00:00
|
|
|
m_frame->AddToScreen( newItem, m_frame->GetScreen() );
|
2020-08-26 18:04:32 +00:00
|
|
|
m_frame->SaveCopyInUndoList( m_frame->GetScreen(), newItem, UNDO_REDO::NEWITEM, false );
|
2019-04-26 22:23:12 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
// Symbols need to be handled by the move tool. The move tool will handle schematic
|
2021-02-10 17:58:28 +00:00
|
|
|
// cleanup routines
|
2019-04-26 22:23:12 +00:00
|
|
|
if( performDrag )
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::move, true );
|
2019-04-26 22:23:12 +00:00
|
|
|
|
|
|
|
newItem->ClearFlags();
|
|
|
|
|
2021-02-10 17:58:28 +00:00
|
|
|
if( !performDrag && newItem->IsConnectable() )
|
2019-06-19 03:10:21 +00:00
|
|
|
{
|
2021-03-09 21:24:03 +00:00
|
|
|
EE_SELECTION new_sel;
|
2021-02-05 18:16:45 +00:00
|
|
|
new_sel.Add( newItem );
|
2019-06-19 03:10:21 +00:00
|
|
|
|
2021-02-05 18:16:45 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &new_sel );
|
2021-03-09 21:24:03 +00:00
|
|
|
|
|
|
|
m_frame->RecalculateConnections( LOCAL_CLEANUP );
|
2019-04-26 22:23:12 +00:00
|
|
|
m_frame->TestDanglingEnds();
|
2019-06-19 03:10:21 +00:00
|
|
|
}
|
2019-04-26 22:23:12 +00:00
|
|
|
|
2021-03-09 21:24:03 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
// Save newItem at the new position.
|
2019-05-10 16:48:46 +00:00
|
|
|
m_frame->SaveCopyForRepeatItem( newItem );
|
2019-04-26 22:23:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-17 21:11:41 +00:00
|
|
|
static KICAD_T deletableItems[] =
|
|
|
|
{
|
|
|
|
SCH_MARKER_T,
|
|
|
|
SCH_JUNCTION_T,
|
|
|
|
SCH_LINE_T,
|
|
|
|
SCH_BUS_BUS_ENTRY_T,
|
|
|
|
SCH_BUS_WIRE_ENTRY_T,
|
|
|
|
SCH_TEXT_T,
|
|
|
|
SCH_LABEL_T,
|
|
|
|
SCH_GLOBAL_LABEL_T,
|
|
|
|
SCH_HIER_LABEL_T,
|
|
|
|
SCH_NO_CONNECT_T,
|
|
|
|
SCH_SHEET_T,
|
|
|
|
SCH_SHEET_PIN_T,
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL_T,
|
2019-07-05 08:25:23 +00:00
|
|
|
SCH_BITMAP_T,
|
2019-06-17 21:11:41 +00:00
|
|
|
EOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
2019-04-23 13:06:37 +00:00
|
|
|
{
|
2019-06-19 18:30:11 +00:00
|
|
|
SCH_SCREEN* screen = m_frame->GetScreen();
|
|
|
|
auto items = m_selectionTool->RequestSelection( deletableItems ).GetItems();
|
|
|
|
bool appendToUndo = false;
|
|
|
|
std::vector<wxPoint> pts;
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
if( items.empty() )
|
2019-04-23 13:06:37 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
// Don't leave a freed pointer in the selection
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-04 13:02:05 +00:00
|
|
|
for( EDA_ITEM* item : items )
|
2019-06-19 18:30:11 +00:00
|
|
|
item->ClearFlags( STRUCT_DELETED );
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-06-19 18:30:11 +00:00
|
|
|
for( EDA_ITEM* item : items )
|
|
|
|
{
|
2019-08-27 10:03:49 +00:00
|
|
|
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
|
|
|
|
|
2019-10-18 04:29:26 +00:00
|
|
|
if( !sch_item )
|
|
|
|
continue;
|
|
|
|
|
2020-09-08 13:27:13 +00:00
|
|
|
if( sch_item->IsConnectable() )
|
|
|
|
{
|
|
|
|
std::vector<wxPoint> tmp_pts = sch_item->GetConnectionPoints();
|
|
|
|
pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
|
|
|
|
}
|
|
|
|
|
2019-08-27 10:03:49 +00:00
|
|
|
if( sch_item->Type() == SCH_JUNCTION_T )
|
2019-05-04 13:02:05 +00:00
|
|
|
{
|
2019-08-27 10:03:49 +00:00
|
|
|
sch_item->SetFlags( STRUCT_DELETED );
|
2019-06-19 18:30:11 +00:00
|
|
|
// clean up junctions at the end
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2021-01-12 23:55:46 +00:00
|
|
|
else if( sch_item->Type() == SCH_SHEET_PIN_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
|
|
|
|
SCH_SHEET* sheet = pin->GetParent();
|
|
|
|
|
|
|
|
if( !alg::contains( items, sheet ) )
|
|
|
|
{
|
|
|
|
pin->SetFlags( STRUCT_DELETED );
|
|
|
|
saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
|
|
|
|
appendToUndo = true;
|
|
|
|
|
|
|
|
updateItem( pin, false );
|
|
|
|
|
|
|
|
sheet->RemovePin( pin );
|
|
|
|
}
|
|
|
|
}
|
2019-05-04 13:02:05 +00:00
|
|
|
else
|
|
|
|
{
|
2019-08-27 10:03:49 +00:00
|
|
|
sch_item->SetFlags( STRUCT_DELETED );
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
|
2019-05-04 13:02:05 +00:00
|
|
|
appendToUndo = true;
|
|
|
|
|
2020-10-30 15:15:20 +00:00
|
|
|
updateItem( sch_item, false );
|
2019-05-04 13:02:05 +00:00
|
|
|
|
2021-01-12 23:55:46 +00:00
|
|
|
m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() );
|
2019-10-24 17:07:01 +00:00
|
|
|
|
|
|
|
if( sch_item->Type() == SCH_SHEET_T )
|
|
|
|
m_frame->UpdateHierarchyNavigator();
|
2019-05-04 13:02:05 +00:00
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
}
|
|
|
|
|
2019-06-19 18:30:11 +00:00
|
|
|
for( auto point : pts )
|
|
|
|
{
|
|
|
|
SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
|
2019-08-27 10:03:49 +00:00
|
|
|
|
|
|
|
if( !junction )
|
|
|
|
continue;
|
|
|
|
|
2019-08-27 12:12:34 +00:00
|
|
|
if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsJunctionNeeded( point ) )
|
2019-06-19 18:30:11 +00:00
|
|
|
m_frame->DeleteJunction( junction, appendToUndo );
|
|
|
|
}
|
|
|
|
|
2019-04-27 14:59:38 +00:00
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
2019-04-23 13:06:37 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-17 21:11:41 +00:00
|
|
|
#define HITTEST_THRESHOLD_PIXELS 5
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
2019-04-28 16:36:31 +00:00
|
|
|
{
|
2019-07-15 23:44:01 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
2019-06-17 21:11:41 +00:00
|
|
|
m_pickerItem = nullptr;
|
|
|
|
|
2019-07-19 20:47:33 +00:00
|
|
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
|
|
|
Activate();
|
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
picker->SetCursor( KICURSOR::REMOVE );
|
2021-01-31 14:50:19 +00:00
|
|
|
picker->SetSnapping( false );
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetClickHandler(
|
2020-11-22 22:21:41 +00:00
|
|
|
[this]( const VECTOR2D& aPosition ) -> bool
|
2019-06-25 13:01:22 +00:00
|
|
|
{
|
2020-11-22 22:21:41 +00:00
|
|
|
if( m_pickerItem )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
2020-11-22 22:21:41 +00:00
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
|
|
|
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
|
|
|
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
|
|
|
m_pickerItem = nullptr;
|
|
|
|
}
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
return true;
|
|
|
|
} );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetMotionHandler(
|
2020-11-22 22:21:41 +00:00
|
|
|
[this]( const VECTOR2D& aPos )
|
|
|
|
{
|
|
|
|
EE_COLLECTOR collector;
|
|
|
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
|
|
collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
|
2019-05-05 10:33:34 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
2019-06-28 19:11:26 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
2019-06-28 19:11:26 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
if( m_pickerItem != item )
|
|
|
|
{
|
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
m_pickerItem = item;
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->BrightenItem( m_pickerItem );
|
|
|
|
}
|
|
|
|
} );
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetFinalizeHandler(
|
2020-11-22 22:21:41 +00:00
|
|
|
[this]( const int& aFinalState )
|
|
|
|
{
|
|
|
|
if( m_pickerItem )
|
|
|
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
2020-10-11 17:12:13 +00:00
|
|
|
|
2020-11-22 22:21:41 +00:00
|
|
|
// Wake the selection tool after exiting to ensure the cursor gets updated
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
|
|
|
} );
|
2019-06-17 21:11:41 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
2019-07-15 12:15:58 +00:00
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
2021-03-19 20:27:30 +00:00
|
|
|
// Save old symbol in undo list if not already in edit, or moving.
|
2019-06-19 10:31:21 +00:00
|
|
|
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( aField, UNDO_REDO::CHANGED );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
2021-07-19 13:43:34 +00:00
|
|
|
KICAD_T parentType = aField->GetParent() ? aField->GetParent()->Type() : SCHEMATIC_T;
|
|
|
|
wxString caption;
|
|
|
|
|
|
|
|
// Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
|
|
|
|
if( parentType == SCH_SYMBOL_T && aField->GetId() < MANDATORY_FIELDS )
|
|
|
|
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
|
|
|
else if( parentType == SCH_SHEET_T && aField->GetId() < SHEET_MANDATORY_FIELDS )
|
|
|
|
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
|
|
|
else
|
|
|
|
caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
2021-08-06 19:54:26 +00:00
|
|
|
DIALOG_SCH_FIELD_PROPERTIES dlg( m_frame, caption, aField );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
2019-07-20 23:31:16 +00:00
|
|
|
// The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
|
2019-07-28 05:33:34 +00:00
|
|
|
if( dlg.ShowQuasiModal() != wxID_OK )
|
2019-06-19 10:31:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
2021-07-19 13:43:34 +00:00
|
|
|
if( m_frame->eeconfig()->m_AutoplaceFields.enable || parentType == SCH_SHEET_T )
|
2020-03-06 20:02:58 +00:00
|
|
|
static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
2020-08-10 11:40:58 +00:00
|
|
|
m_frame->UpdateItem( aField );
|
2019-06-19 10:31:21 +00:00
|
|
|
m_frame->OnModify();
|
2020-08-13 21:30:30 +00:00
|
|
|
|
|
|
|
// This must go after OnModify() so that the connectivity graph will have been updated.
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
2019-06-19 10:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-27 23:50:35 +00:00
|
|
|
int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
static KICAD_T Nothing[] = { EOT };
|
2021-06-10 14:10:55 +00:00
|
|
|
static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_SYMBOL_T, EOT };
|
|
|
|
static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_SYMBOL_T, EOT };
|
|
|
|
static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_SYMBOL_T, EOT };
|
2019-04-27 23:50:35 +00:00
|
|
|
|
|
|
|
KICAD_T* filter = Nothing;
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
|
2019-04-27 23:50:35 +00:00
|
|
|
filter = CmpOrReference;
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
|
2019-04-27 23:50:35 +00:00
|
|
|
filter = CmpOrValue;
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
|
2019-04-27 23:50:35 +00:00
|
|
|
filter = CmpOrFootprint;
|
|
|
|
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2021-01-08 20:42:23 +00:00
|
|
|
if( selection.Size() != 1 )
|
2019-04-27 23:50:35 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-05-01 21:50:11 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) selection.Front();
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
if( item->Type() == SCH_SYMBOL_T )
|
2019-04-27 23:50:35 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) item;
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
|
2021-03-19 20:27:30 +00:00
|
|
|
editFieldText( symbol->GetField( REFERENCE_FIELD ) );
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
|
2021-03-19 20:27:30 +00:00
|
|
|
editFieldText( symbol->GetField( VALUE_FIELD ) );
|
2019-05-10 17:19:48 +00:00
|
|
|
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
|
2021-03-19 20:27:30 +00:00
|
|
|
editFieldText( symbol->GetField( FOOTPRINT_FIELD ) );
|
2019-04-27 23:50:35 +00:00
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_FIELD_T )
|
|
|
|
{
|
2020-03-06 20:02:58 +00:00
|
|
|
editFieldText( (SCH_FIELD*) item );
|
2019-04-27 23:50:35 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 18:00:55 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-04-27 23:50:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-28 23:34:43 +00:00
|
|
|
int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
|
2019-04-27 23:50:35 +00:00
|
|
|
{
|
2020-11-17 16:02:47 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::FieldOwners );
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2019-04-28 23:34:43 +00:00
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
|
|
|
|
2021-07-29 15:51:12 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
SCH_ITEM* sch_item = static_cast<SCH_ITEM*>( item );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2021-07-29 15:51:12 +00:00
|
|
|
if( !sch_item->IsNew() )
|
|
|
|
saveCopyInUndoList( sch_item, UNDO_REDO::CHANGED );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2021-07-29 15:51:12 +00:00
|
|
|
sch_item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
|
|
|
|
updateItem( sch_item, true );
|
|
|
|
}
|
2019-04-28 23:34:43 +00:00
|
|
|
|
|
|
|
m_frame->OnModify();
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2020-05-06 18:00:55 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-04-28 23:34:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-13 17:51:26 +00:00
|
|
|
int SCH_EDIT_TOOL::ChangeSymbols( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* selectedSymbol = nullptr;
|
2021-06-14 18:00:08 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
2020-08-13 17:51:26 +00:00
|
|
|
|
|
|
|
if( !selection.Empty() )
|
2021-06-10 14:10:55 +00:00
|
|
|
selectedSymbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
|
2020-08-13 17:51:26 +00:00
|
|
|
|
|
|
|
DIALOG_CHANGE_SYMBOLS::MODE mode = DIALOG_CHANGE_SYMBOLS::MODE::UPDATE;
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &EE_ACTIONS::changeSymbol )
|
|
|
|
|| aEvent.IsAction( &EE_ACTIONS::changeSymbols ) )
|
2020-11-17 16:02:47 +00:00
|
|
|
{
|
2020-08-13 17:51:26 +00:00
|
|
|
mode = DIALOG_CHANGE_SYMBOLS::MODE::CHANGE;
|
2020-11-17 16:02:47 +00:00
|
|
|
}
|
2020-08-13 17:51:26 +00:00
|
|
|
|
|
|
|
DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode );
|
|
|
|
|
2020-12-17 23:51:24 +00:00
|
|
|
dlg.ShowQuasiModal();
|
2020-08-13 17:51:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-01 21:50:11 +00:00
|
|
|
int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-06-14 18:00:08 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
|
2019-05-01 21:50:11 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
|
2019-05-01 21:50:11 +00:00
|
|
|
|
2019-06-01 19:48:01 +00:00
|
|
|
if( aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard )
|
2021-03-19 20:27:30 +00:00
|
|
|
&& symbol->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
|
2020-11-17 16:02:47 +00:00
|
|
|
{
|
2019-06-01 19:48:01 +00:00
|
|
|
return 0;
|
2020-11-17 16:02:47 +00:00
|
|
|
}
|
2019-06-01 19:48:01 +00:00
|
|
|
|
|
|
|
if( aEvent.IsAction( &EE_ACTIONS::showDeMorganAlternate )
|
2021-03-19 20:27:30 +00:00
|
|
|
&& symbol->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
2020-11-17 16:02:47 +00:00
|
|
|
{
|
2019-06-01 19:48:01 +00:00
|
|
|
return 0;
|
2020-11-17 16:02:47 +00:00
|
|
|
}
|
2019-06-01 19:48:01 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
if( !symbol->IsNew() )
|
|
|
|
saveCopyInUndoList( symbol, UNDO_REDO::CHANGED );
|
2019-05-01 21:50:11 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
m_frame->ConvertPart( symbol );
|
2019-05-01 21:50:11 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
if( symbol->IsNew() )
|
2019-07-04 20:56:21 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
2019-06-01 19:48:01 +00:00
|
|
|
|
2020-05-06 18:00:55 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-05-01 21:50:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-28 23:34:43 +00:00
|
|
|
int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems );
|
2019-04-28 23:34:43 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
2020-04-20 23:24:29 +00:00
|
|
|
{
|
2021-02-22 16:37:43 +00:00
|
|
|
if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) )
|
2020-05-02 23:06:43 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_PROXY_VIEW_ITEM* ds = m_frame->GetCanvas()->GetView()->GetDrawingSheet();
|
|
|
|
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
|
2020-05-02 23:06:43 +00:00
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
if( ds && ds->HitTestDrawingSheetItems( getView(), (wxPoint) cursorPos ) )
|
2020-05-02 23:06:43 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pageSettings );
|
|
|
|
}
|
|
|
|
|
2019-04-28 23:34:43 +00:00
|
|
|
return 0;
|
2020-04-20 23:24:29 +00:00
|
|
|
}
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2019-05-01 21:50:11 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) selection.Front();
|
2019-04-28 23:34:43 +00:00
|
|
|
|
2020-05-13 10:52:44 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LINE_T:
|
2020-06-19 11:48:00 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
if( !selection.AllItemsHaveLineStroke() )
|
2020-05-13 10:52:44 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-06-24 17:35:33 +00:00
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
if( !selection.AreAllItemsIdentical() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-05-13 10:52:44 +00:00
|
|
|
default:
|
|
|
|
if( selection.Size() > 1 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-04-27 23:50:35 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
case SCH_SYMBOL_T:
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) item;
|
2021-03-19 20:27:30 +00:00
|
|
|
DIALOG_SYMBOL_PROPERTIES symbolPropsDialog( m_frame, symbol );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
|
|
|
// This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
|
|
|
|
// frame. Therefore this dialog as a modal frame parent, MUST be run under
|
|
|
|
// quasimodal mode for the quasimodal frame support to work. So don't use
|
|
|
|
// the QUASIMODAL macros here.
|
2020-09-02 00:37:28 +00:00
|
|
|
int retval = symbolPropsDialog.ShowQuasiModal();
|
|
|
|
|
|
|
|
if( retval == SYMBOL_PROPS_EDIT_OK )
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
2020-04-12 23:09:17 +00:00
|
|
|
if( m_frame->eeconfig()->m_AutoplaceFields.enable )
|
2021-03-19 20:27:30 +00:00
|
|
|
symbol->AutoAutoplaceFields( m_frame->GetScreen() );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
2020-09-02 00:37:28 +00:00
|
|
|
else if( retval == SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
auto editor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR,
|
|
|
|
true );
|
2020-09-02 00:37:28 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
editor->LoadSymbolFromSchematic( symbol );
|
2020-09-02 00:37:28 +00:00
|
|
|
|
|
|
|
editor->Show( true );
|
|
|
|
editor->Raise();
|
|
|
|
}
|
|
|
|
else if( retval == SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
auto editor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR,
|
|
|
|
true );
|
2020-09-02 00:37:28 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
editor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
|
2020-09-02 00:37:28 +00:00
|
|
|
|
|
|
|
editor->Show( true );
|
|
|
|
editor->Raise();
|
|
|
|
}
|
|
|
|
else if( retval == SYMBOL_PROPS_WANT_UPDATE_SYMBOL )
|
|
|
|
{
|
2021-03-19 20:27:30 +00:00
|
|
|
DIALOG_CHANGE_SYMBOLS dlg( m_frame, symbol, DIALOG_CHANGE_SYMBOLS::MODE::UPDATE );
|
2020-12-17 23:51:24 +00:00
|
|
|
dlg.ShowQuasiModal();
|
2020-09-02 00:37:28 +00:00
|
|
|
}
|
|
|
|
else if( retval == SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL )
|
|
|
|
{
|
2021-03-19 20:27:30 +00:00
|
|
|
DIALOG_CHANGE_SYMBOLS dlg( m_frame, symbol, DIALOG_CHANGE_SYMBOLS::MODE::CHANGE );
|
2020-12-17 23:51:24 +00:00
|
|
|
dlg.ShowQuasiModal();
|
2020-09-02 00:37:28 +00:00
|
|
|
}
|
2019-06-19 10:31:21 +00:00
|
|
|
}
|
2019-04-27 23:50:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
{
|
2020-03-12 13:56:44 +00:00
|
|
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
|
|
|
bool doClearAnnotation;
|
|
|
|
bool doRefresh = false;
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2020-10-05 12:24:21 +00:00
|
|
|
// Keep track of existing sheet paths. EditSheet() can modify this list.
|
|
|
|
// Note that we use the validity checking/repairing version here just to make sure
|
|
|
|
// we've got a valid hierarchy to begin with.
|
|
|
|
SCH_SHEET_LIST initial_sheetpathList( &m_frame->Schematic().Root(), true );
|
|
|
|
|
|
|
|
doRefresh = m_frame->EditSheetProperties( sheet, &m_frame->GetCurrentSheet(),
|
|
|
|
&doClearAnnotation );
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2020-05-13 10:52:44 +00:00
|
|
|
// If the sheet file is changed and new sheet contents are loaded then we have to
|
|
|
|
// clear the annotations on the new content (as it may have been set from some other
|
|
|
|
// sheet path reference)
|
|
|
|
if( doClearAnnotation )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS screensList( &m_frame->Schematic().Root() );
|
2019-04-27 23:50:35 +00:00
|
|
|
// We clear annotation of new sheet paths here:
|
|
|
|
screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
|
2020-05-13 10:52:44 +00:00
|
|
|
// Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
|
2021-03-19 20:27:30 +00:00
|
|
|
// path, but symbols managed by its sheet path must have their annotation cleared
|
|
|
|
// because they are new:
|
2020-05-13 02:00:37 +00:00
|
|
|
sheet->GetScreen()->ClearAnnotation( &m_frame->GetCurrentSheet() );
|
2019-04-27 23:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( doRefresh )
|
2019-05-08 18:56:03 +00:00
|
|
|
{
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
2019-04-27 23:50:35 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2019-10-24 17:07:01 +00:00
|
|
|
m_frame->UpdateHierarchyNavigator();
|
2019-05-08 18:56:03 +00:00
|
|
|
}
|
2019-04-27 23:50:35 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCH_SHEET_PIN_T:
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
2020-10-29 22:46:33 +00:00
|
|
|
SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
|
|
|
|
DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, pin );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
2020-10-29 22:46:33 +00:00
|
|
|
// QuasiModal required for help dialog
|
|
|
|
if( dlg.ShowQuasiModal() == wxID_OK )
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
|
|
|
}
|
2019-04-27 23:50:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
2020-05-23 15:50:08 +00:00
|
|
|
{
|
2021-08-06 19:54:26 +00:00
|
|
|
DIALOG_TEXT_AND_LABEL_PROPERTIES dlg( m_frame, (SCH_TEXT*) item );
|
2020-05-23 15:50:08 +00:00
|
|
|
|
2020-10-20 19:54:28 +00:00
|
|
|
// Must be quasi modal for syntax help
|
|
|
|
if( dlg.ShowQuasiModal() == wxID_OK )
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
2020-05-23 15:50:08 +00:00
|
|
|
}
|
2019-04-27 23:50:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_FIELD_T:
|
2020-03-06 20:02:58 +00:00
|
|
|
editFieldText( (SCH_FIELD*) item );
|
2019-04-27 23:50:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_BITMAP_T:
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
|
|
|
SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
|
|
|
|
DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2019-04-27 23:50:35 +00:00
|
|
|
{
|
2019-06-19 10:31:21 +00:00
|
|
|
// save old image in undo list if not already in edit
|
|
|
|
if( bitmap->GetEditFlags() == 0 )
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( bitmap, UNDO_REDO::CHANGED );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
|
|
|
dlg.TransferToImage( bitmap->GetImage() );
|
|
|
|
|
2019-04-27 23:50:35 +00:00
|
|
|
// The bitmap is cached in Opengl: clear the cache in case it has become invalid
|
|
|
|
getView()->RecacheAllItems();
|
2019-06-19 10:31:21 +00:00
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
2019-04-27 23:50:35 +00:00
|
|
|
}
|
2019-06-19 10:31:21 +00:00
|
|
|
}
|
2019-04-27 23:50:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_LINE_T:
|
2020-06-19 11:48:00 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
2019-06-19 10:31:21 +00:00
|
|
|
{
|
2020-06-19 11:48:00 +00:00
|
|
|
std::deque<SCH_ITEM*> strokeItems;
|
2019-12-31 04:05:51 +00:00
|
|
|
|
2020-05-09 21:19:34 +00:00
|
|
|
for( auto selItem : selection.Items() )
|
2019-12-31 04:05:51 +00:00
|
|
|
{
|
2020-06-19 11:48:00 +00:00
|
|
|
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( selItem );
|
2020-01-03 19:30:29 +00:00
|
|
|
|
2020-06-19 11:48:00 +00:00
|
|
|
if( schItem && schItem->HasLineStroke() )
|
|
|
|
strokeItems.push_back( schItem );
|
2020-05-13 10:52:44 +00:00
|
|
|
else
|
|
|
|
return 0;
|
2019-12-31 04:05:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-12 10:58:14 +00:00
|
|
|
DIALOG_LINE_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems );
|
2019-06-19 10:31:21 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 04:05:51 +00:00
|
|
|
break;
|
2019-04-27 23:50:35 +00:00
|
|
|
|
|
|
|
case SCH_JUNCTION_T:
|
2020-06-24 17:35:33 +00:00
|
|
|
{
|
|
|
|
std::deque<SCH_JUNCTION*> junctions;
|
|
|
|
|
|
|
|
for( auto selItem : selection.Items() )
|
|
|
|
{
|
|
|
|
SCH_JUNCTION* junction = dynamic_cast<SCH_JUNCTION*>( selItem );
|
|
|
|
|
|
|
|
wxCHECK( junction, 0 );
|
|
|
|
|
|
|
|
junctions.push_back( junction );
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
|
|
|
}
|
2020-06-27 18:01:00 +00:00
|
|
|
break;
|
2020-06-24 17:35:33 +00:00
|
|
|
|
|
|
|
case SCH_MARKER_T: // These items have no properties to edit
|
2019-04-27 23:50:35 +00:00
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // Unexpected item
|
|
|
|
wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
|
|
|
|
}
|
|
|
|
|
2020-10-30 15:15:20 +00:00
|
|
|
updateItem( item, true );
|
2019-04-27 23:50:35 +00:00
|
|
|
|
2019-05-20 07:38:00 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-04-27 23:50:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-29 17:50:46 +00:00
|
|
|
int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-17 22:02:30 +00:00
|
|
|
KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
|
2019-06-08 21:48:22 +00:00
|
|
|
KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
|
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
|
2019-04-29 17:50:46 +00:00
|
|
|
|
2019-05-09 15:10:53 +00:00
|
|
|
for( unsigned int i = 0; i < selection.GetSize(); ++i )
|
2019-04-29 17:50:46 +00:00
|
|
|
{
|
|
|
|
SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
|
|
|
|
|
2020-05-27 11:13:57 +00:00
|
|
|
if( text && text->Type() != convertTo )
|
|
|
|
{
|
|
|
|
bool selected = text->IsSelected();
|
|
|
|
SCH_TEXT* newtext = nullptr;
|
|
|
|
const wxPoint& position = text->GetPosition();
|
|
|
|
LABEL_SPIN_STYLE orientation = text->GetLabelSpinStyle();
|
|
|
|
wxString txt = UnescapeString( text->GetText() );
|
|
|
|
|
|
|
|
// There can be characters in a SCH_TEXT object that can break labels so we have to
|
|
|
|
// fix them here.
|
|
|
|
if( text->Type() == SCH_TEXT_T )
|
|
|
|
{
|
|
|
|
txt.Replace( "\n", "_" );
|
|
|
|
txt.Replace( "\r", "_" );
|
|
|
|
txt.Replace( "\t", "_" );
|
|
|
|
txt.Replace( " ", "_" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// label strings are "escaped" i.e. a '/' is replaced by "{slash}"
|
|
|
|
if( convertTo != SCH_TEXT_T )
|
|
|
|
txt = EscapeString( txt, CTX_NETNAME );
|
|
|
|
|
|
|
|
switch( convertTo )
|
|
|
|
{
|
|
|
|
case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
|
|
|
|
case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
|
|
|
|
case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
|
|
|
|
case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the old text item settings to the new one. Justifications are not copied
|
|
|
|
// because they are not used in labels. Justifications will be set to default value
|
|
|
|
// in the new text item type.
|
|
|
|
//
|
|
|
|
newtext->SetFlags( text->GetEditFlags() );
|
|
|
|
newtext->SetShape( text->GetShape() );
|
|
|
|
newtext->SetLabelSpinStyle( orientation );
|
|
|
|
newtext->SetTextSize( text->GetTextSize() );
|
|
|
|
newtext->SetTextThickness( text->GetTextThickness() );
|
|
|
|
newtext->SetItalic( text->IsItalic() );
|
|
|
|
newtext->SetBold( text->IsBold() );
|
|
|
|
newtext->SetIsDangling( text->IsDangling() );
|
|
|
|
|
|
|
|
if( selected )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::removeItemFromSel, true, text );
|
|
|
|
|
|
|
|
if( !text->IsNew() )
|
|
|
|
{
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( text, UNDO_REDO::DELETED );
|
|
|
|
saveCopyInUndoList( newtext, UNDO_REDO::NEWITEM, true );
|
2020-05-27 11:13:57 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
m_frame->RemoveFromScreen( text, m_frame->GetScreen() );
|
|
|
|
m_frame->AddToScreen( newtext, m_frame->GetScreen() );
|
2021-01-25 10:34:35 +00:00
|
|
|
|
|
|
|
if( convertTo == SCH_GLOBAL_LABEL_T )
|
|
|
|
static_cast<SCH_GLOBALLABEL*>( newtext )->UpdateIntersheetRefProps();
|
2020-05-27 11:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( selected )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
|
|
|
|
|
|
|
|
// Otherwise, pointer is owned by the undo stack
|
|
|
|
if( text->IsNew() )
|
|
|
|
delete text;
|
|
|
|
|
|
|
|
if( convertTo == SCH_TEXT_T )
|
|
|
|
{
|
|
|
|
if( newtext->IsDangling() )
|
|
|
|
{
|
|
|
|
newtext->SetIsDangling( false );
|
|
|
|
getView()->Update( newtext, KIGFX::REPAINT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->OnModify();
|
|
|
|
}
|
2019-04-29 17:50:46 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 18:00:55 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-04-29 17:50:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-30 13:54:32 +00:00
|
|
|
int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-05-09 19:17:01 +00:00
|
|
|
wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
2021-02-13 01:15:45 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::WiresOnly );
|
|
|
|
|
|
|
|
std::vector<SCH_LINE*> lines;
|
2019-04-30 13:54:32 +00:00
|
|
|
|
2021-07-29 15:51:12 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2019-04-30 13:54:32 +00:00
|
|
|
{
|
2021-02-16 18:09:56 +00:00
|
|
|
if( SCH_LINE* line = dyn_cast<SCH_LINE*>( item ) )
|
|
|
|
{
|
|
|
|
if( !line->IsEndPoint( cursorPos ) )
|
2021-07-29 15:51:12 +00:00
|
|
|
lines.push_back( line );
|
2021-02-16 18:09:56 +00:00
|
|
|
}
|
2021-02-13 01:15:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_selectionTool->ClearSelection();
|
2021-02-16 18:09:56 +00:00
|
|
|
m_frame->StartNewUndo();
|
2021-02-13 01:15:45 +00:00
|
|
|
|
2021-02-16 18:09:56 +00:00
|
|
|
for( SCH_LINE* line : lines )
|
|
|
|
m_frame->BreakSegment( line, cursorPos );
|
2021-02-13 01:15:45 +00:00
|
|
|
|
2021-02-16 18:09:56 +00:00
|
|
|
if( !lines.empty() )
|
|
|
|
{
|
2019-10-17 14:21:20 +00:00
|
|
|
if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) )
|
2020-07-13 11:21:40 +00:00
|
|
|
m_frame->AddJunction( m_frame->GetScreen(), cursorPos, true, false );
|
2019-10-17 14:21:20 +00:00
|
|
|
|
2019-04-30 13:54:32 +00:00
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->OnModify();
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
2021-02-13 01:15:45 +00:00
|
|
|
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::drag );
|
2019-04-30 13:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-01 22:14:21 +00:00
|
|
|
int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
2019-05-01 22:14:21 +00:00
|
|
|
|
|
|
|
if( !sheet )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( !sheet->HasUndefinedPins() )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
|
|
|
|
return 0;
|
|
|
|
|
2020-08-26 18:04:32 +00:00
|
|
|
saveCopyInUndoList( sheet, UNDO_REDO::CHANGED );
|
2019-05-01 22:14:21 +00:00
|
|
|
|
|
|
|
sheet->CleanupSheet();
|
|
|
|
|
2020-10-30 15:15:20 +00:00
|
|
|
updateItem( sheet, true );
|
2019-05-01 22:14:21 +00:00
|
|
|
m_frame->OnModify();
|
|
|
|
|
2020-05-06 18:00:55 +00:00
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-05-01 22:14:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
int SCH_EDIT_TOOL::EditPageNumber( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
|
|
|
|
|
|
|
if( selection.GetSize() > 1 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
|
|
|
|
|
|
|
SCH_SHEET_PATH instance = m_frame->GetCurrentSheet();
|
|
|
|
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
|
|
|
|
if( sheet )
|
|
|
|
{
|
|
|
|
// When changing the page number of a selected sheet, the current screen owns the sheet.
|
|
|
|
screen = m_frame->GetScreen();
|
|
|
|
|
|
|
|
instance.push_back( sheet );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH prevInstance = instance;
|
|
|
|
|
|
|
|
// When change the page number in the screen, the previous screen owns the sheet.
|
|
|
|
if( prevInstance.size() )
|
|
|
|
{
|
|
|
|
prevInstance.pop_back();
|
|
|
|
screen = prevInstance.LastScreen();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The root sheet and root screen are effectively the same thing.
|
|
|
|
screen = m_frame->GetScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
sheet = m_frame->GetCurrentSheet().Last();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString msg;
|
2020-11-29 00:10:17 +00:00
|
|
|
wxString sheetPath = instance.PathHumanReadable( false );
|
2020-10-18 20:30:37 +00:00
|
|
|
wxString pageNumber = instance.GetPageNumber();
|
|
|
|
|
|
|
|
msg.Printf( _( "Enter page number for sheet path%s" ),
|
|
|
|
( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
|
|
|
|
|
2021-02-19 14:51:18 +00:00
|
|
|
wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
|
2020-10-18 20:30:37 +00:00
|
|
|
|
|
|
|
dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.GetPageNumber() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
m_frame->SaveCopyInUndoList( screen, sheet, UNDO_REDO::CHANGED, false );
|
|
|
|
|
|
|
|
instance.SetPageNumber( dlg.GetValue() );
|
|
|
|
|
|
|
|
if( instance == m_frame->GetCurrentSheet() )
|
|
|
|
{
|
|
|
|
m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
|
|
|
|
m_frame->OnPageSettingsChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-23 13:06:37 +00:00
|
|
|
void SCH_EDIT_TOOL::setTransitions()
|
|
|
|
{
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::RepeatDrawItem, EE_ACTIONS::repeatDrawItem.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::Rotate, EE_ACTIONS::rotateCW.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::Rotate, EE_ACTIONS::rotateCCW.MakeEvent() );
|
2021-02-16 20:45:25 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorV.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorH.MakeEvent() );
|
2019-07-31 12:48:00 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
|
2019-07-31 12:10:13 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::DeleteItemCursor, ACTIONS::deleteTool.MakeEvent() );
|
2019-05-10 17:19:48 +00:00
|
|
|
|
|
|
|
Go( &SCH_EDIT_TOOL::Properties, EE_ACTIONS::properties.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editReference.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editValue.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editFootprint.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::AutoplaceFields, EE_ACTIONS::autoplaceFields.MakeEvent() );
|
2020-08-13 17:51:26 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::changeSymbols.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::updateSymbols.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::changeSymbol.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::updateSymbol.MakeEvent() );
|
2019-06-01 19:48:01 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::toggleDeMorgan.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() );
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::ChangeTextType, EE_ACTIONS::toLabel.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ChangeTextType, EE_ACTIONS::toHLabel.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ChangeTextType, EE_ACTIONS::toGLabel.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::ChangeTextType, EE_ACTIONS::toText.MakeEvent() );
|
|
|
|
|
|
|
|
Go( &SCH_EDIT_TOOL::BreakWire, EE_ACTIONS::breakWire.MakeEvent() );
|
|
|
|
Go( &SCH_EDIT_TOOL::BreakWire, EE_ACTIONS::breakBus.MakeEvent() );
|
|
|
|
|
|
|
|
Go( &SCH_EDIT_TOOL::CleanupSheetPins, EE_ACTIONS::cleanupSheetPins.MakeEvent() );
|
2019-06-30 22:06:34 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::GlobalEdit, EE_ACTIONS::editTextAndGraphics.MakeEvent() );
|
2020-10-18 20:30:37 +00:00
|
|
|
Go( &SCH_EDIT_TOOL::EditPageNumber, EE_ACTIONS::editPageNumber.MakeEvent() );
|
2019-04-23 13:06:37 +00:00
|
|
|
}
|