Adapted graphics tools to cooperate with module editor.
This commit is contained in:
parent
ba320ac7c3
commit
99043b777d
|
@ -271,11 +271,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
||||||
|
|
||||||
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
||||||
m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true );
|
|
||||||
m_toolManager->RegisterTool( new EDIT_TOOL );
|
m_toolManager->RegisterTool( new EDIT_TOOL );
|
||||||
m_toolManager->RegisterTool( new DRAWING_TOOL );
|
m_toolManager->RegisterTool( new DRAWING_TOOL );
|
||||||
m_toolManager->RegisterTool( new POINT_EDITOR );
|
m_toolManager->RegisterTool( new POINT_EDITOR );
|
||||||
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||||
|
m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true );
|
||||||
|
m_toolManager->GetTool<DRAWING_TOOL>()->EditModules( true );
|
||||||
m_toolManager->ResetTools( TOOL_BASE::RUN );
|
m_toolManager->ResetTools( TOOL_BASE::RUN );
|
||||||
|
|
||||||
// Run the selection tool, it is supposed to be always active
|
// Run the selection tool, it is supposed to be always active
|
||||||
|
|
|
@ -286,12 +286,15 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
|
||||||
return COMMON_ACTIONS::drawKeepout.MakeEvent();
|
return COMMON_ACTIONS::drawKeepout.MakeEvent();
|
||||||
|
|
||||||
case ID_PCB_ADD_LINE_BUTT:
|
case ID_PCB_ADD_LINE_BUTT:
|
||||||
|
case ID_MODEDIT_LINE_TOOL:
|
||||||
return COMMON_ACTIONS::drawLine.MakeEvent();
|
return COMMON_ACTIONS::drawLine.MakeEvent();
|
||||||
|
|
||||||
case ID_PCB_CIRCLE_BUTT:
|
case ID_PCB_CIRCLE_BUTT:
|
||||||
|
case ID_MODEDIT_CIRCLE_TOOL:
|
||||||
return COMMON_ACTIONS::drawCircle.MakeEvent();
|
return COMMON_ACTIONS::drawCircle.MakeEvent();
|
||||||
|
|
||||||
case ID_PCB_ARC_BUTT:
|
case ID_PCB_ARC_BUTT:
|
||||||
|
case ID_MODEDIT_ARC_TOOL:
|
||||||
return COMMON_ACTIONS::drawArc.MakeEvent();
|
return COMMON_ACTIONS::drawArc.MakeEvent();
|
||||||
|
|
||||||
case ID_PCB_ADD_TEXT_BUTT:
|
case ID_PCB_ADD_TEXT_BUTT:
|
||||||
|
@ -305,6 +308,7 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
|
||||||
return COMMON_ACTIONS::placeTarget.MakeEvent();
|
return COMMON_ACTIONS::placeTarget.MakeEvent();
|
||||||
|
|
||||||
case ID_PCB_PLACE_GRID_COORD_BUTT:
|
case ID_PCB_PLACE_GRID_COORD_BUTT:
|
||||||
|
case ID_MODEDIT_PLACE_GRID_COORD:
|
||||||
return COMMON_ACTIONS::gridSetOrigin.MakeEvent();
|
return COMMON_ACTIONS::gridSetOrigin.MakeEvent();
|
||||||
|
|
||||||
case ID_ZOOM_IN: // toolbar button "Zoom In"
|
case ID_ZOOM_IN: // toolbar button "Zoom In"
|
||||||
|
@ -325,6 +329,9 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
|
||||||
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE:
|
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE:
|
||||||
case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR:
|
case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR:
|
||||||
case ID_MICROWAVE_V_TOOLBAR:
|
case ID_MICROWAVE_V_TOOLBAR:
|
||||||
|
case ID_MODEDIT_PAD_TOOL:
|
||||||
|
case ID_MODEDIT_DELETE_TOOL:
|
||||||
|
case ID_MODEDIT_ANCHOR_TOOL:
|
||||||
return COMMON_ACTIONS::toBeDone.MakeEvent();
|
return COMMON_ACTIONS::toBeDone.MakeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <router/direction.h>
|
#include <router/direction.h>
|
||||||
|
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_drawsegment.h>
|
#include <class_edge_mod.h>
|
||||||
#include <class_pcb_text.h>
|
#include <class_pcb_text.h>
|
||||||
#include <class_dimension.h>
|
#include <class_dimension.h>
|
||||||
#include <class_mire.h>
|
#include <class_mire.h>
|
||||||
|
@ -72,6 +72,26 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
|
||||||
|
|
||||||
|
|
||||||
int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
|
int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
if( m_editModules )
|
||||||
|
{
|
||||||
|
m_frame->SetToolID( ID_MODEDIT_LINE_TOOL, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||||
|
|
||||||
|
MODULE* module = m_frame->GetBoard()->m_Modules;
|
||||||
|
EDGE_MODULE* line = new EDGE_MODULE( module );
|
||||||
|
|
||||||
|
while( drawSegment( S_SEGMENT, line ) )
|
||||||
|
{
|
||||||
|
m_frame->OnModify();
|
||||||
|
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
|
||||||
|
line->SetLocalCoord();
|
||||||
|
line->SetParent( module );
|
||||||
|
module->GraphicalItems().PushFront( line );
|
||||||
|
|
||||||
|
line = new EDGE_MODULE( module );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||||
|
|
||||||
|
@ -79,8 +99,13 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( drawSegment( S_SEGMENT, line ) )
|
while( drawSegment( S_SEGMENT, line ) )
|
||||||
{
|
{
|
||||||
|
m_board->Add( line );
|
||||||
|
m_frame->OnModify();
|
||||||
|
m_frame->SaveCopyInUndoList( line, UR_NEW );
|
||||||
|
|
||||||
line = new DRAWSEGMENT;
|
line = new DRAWSEGMENT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||||
|
@ -90,6 +115,26 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
|
|
||||||
int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
|
int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
if( m_editModules )
|
||||||
|
{
|
||||||
|
m_frame->SetToolID( ID_MODEDIT_CIRCLE_TOOL, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||||
|
|
||||||
|
MODULE* module = m_frame->GetBoard()->m_Modules;
|
||||||
|
EDGE_MODULE* circle = new EDGE_MODULE( module );
|
||||||
|
|
||||||
|
while( drawSegment( S_CIRCLE, circle ) )
|
||||||
|
{
|
||||||
|
m_frame->OnModify();
|
||||||
|
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
|
||||||
|
circle->SetLocalCoord();
|
||||||
|
circle->SetParent( module );
|
||||||
|
module->GraphicalItems().PushFront( circle );
|
||||||
|
|
||||||
|
circle = new EDGE_MODULE( module );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_PCB_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
m_frame->SetToolID( ID_PCB_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||||
|
|
||||||
|
@ -97,8 +142,13 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( drawSegment( S_CIRCLE, circle ) )
|
while( drawSegment( S_CIRCLE, circle ) )
|
||||||
{
|
{
|
||||||
|
m_board->Add( circle );
|
||||||
|
m_frame->OnModify();
|
||||||
|
m_frame->SaveCopyInUndoList( circle, UR_NEW );
|
||||||
|
|
||||||
circle = new DRAWSEGMENT;
|
circle = new DRAWSEGMENT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||||
|
@ -108,6 +158,26 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
|
|
||||||
int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
|
int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
if( m_editModules )
|
||||||
|
{
|
||||||
|
m_frame->SetToolID( ID_MODEDIT_ARC_TOOL, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||||
|
|
||||||
|
MODULE* module = m_frame->GetBoard()->m_Modules;
|
||||||
|
EDGE_MODULE* arc = new EDGE_MODULE( module );
|
||||||
|
|
||||||
|
while( drawArc( arc ) )
|
||||||
|
{
|
||||||
|
m_frame->OnModify();
|
||||||
|
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
|
||||||
|
arc->SetLocalCoord();
|
||||||
|
arc->SetParent( module );
|
||||||
|
module->GraphicalItems().PushFront( arc );
|
||||||
|
|
||||||
|
arc = new EDGE_MODULE( module );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_PCB_ARC_BUTT, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
m_frame->SetToolID( ID_PCB_ARC_BUTT, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||||
|
|
||||||
|
@ -115,8 +185,13 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( drawArc( arc ) )
|
while( drawArc( arc ) )
|
||||||
{
|
{
|
||||||
|
m_board->Add( arc );
|
||||||
|
m_frame->OnModify();
|
||||||
|
m_frame->SaveCopyInUndoList( arc, UR_NEW );
|
||||||
|
|
||||||
arc = new DRAWSEGMENT;
|
arc = new DRAWSEGMENT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||||
|
@ -624,11 +699,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic )
|
||||||
assert( aGraphic->GetWidth() > 0 );
|
assert( aGraphic->GetWidth() > 0 );
|
||||||
|
|
||||||
m_view->Add( aGraphic );
|
m_view->Add( aGraphic );
|
||||||
m_board->Add( aGraphic );
|
|
||||||
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||||
|
|
||||||
m_frame->OnModify();
|
|
||||||
m_frame->SaveCopyInUndoList( aGraphic, UR_NEW );
|
|
||||||
}
|
}
|
||||||
else // User has clicked twice in the same spot
|
else // User has clicked twice in the same spot
|
||||||
{ // a clear sign that the current drawing is finished
|
{ // a clear sign that the current drawing is finished
|
||||||
|
@ -785,12 +856,8 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic )
|
||||||
assert( aGraphic->GetWidth() > 0 );
|
assert( aGraphic->GetWidth() > 0 );
|
||||||
|
|
||||||
m_view->Add( aGraphic );
|
m_view->Add( aGraphic );
|
||||||
m_board->Add( aGraphic );
|
|
||||||
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||||
|
|
||||||
m_frame->OnModify();
|
|
||||||
m_frame->SaveCopyInUndoList( aGraphic, UR_NEW );
|
|
||||||
|
|
||||||
preview.Remove( aGraphic );
|
preview.Remove( aGraphic );
|
||||||
preview.Remove( &helperLine );
|
preview.Remove( &helperLine );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue