Commit 99043b77 authored by Maciej Suminski's avatar Maciej Suminski

Adapted graphics tools to cooperate with module editor.

parent ba320ac7
......@@ -271,11 +271,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true );
m_toolManager->RegisterTool( new EDIT_TOOL );
m_toolManager->RegisterTool( new DRAWING_TOOL );
m_toolManager->RegisterTool( new POINT_EDITOR );
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 );
// 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();
case ID_PCB_ADD_LINE_BUTT:
case ID_MODEDIT_LINE_TOOL:
return COMMON_ACTIONS::drawLine.MakeEvent();
case ID_PCB_CIRCLE_BUTT:
case ID_MODEDIT_CIRCLE_TOOL:
return COMMON_ACTIONS::drawCircle.MakeEvent();
case ID_PCB_ARC_BUTT:
case ID_MODEDIT_ARC_TOOL:
return COMMON_ACTIONS::drawArc.MakeEvent();
case ID_PCB_ADD_TEXT_BUTT:
......@@ -305,6 +308,7 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
return COMMON_ACTIONS::placeTarget.MakeEvent();
case ID_PCB_PLACE_GRID_COORD_BUTT:
case ID_MODEDIT_PLACE_GRID_COORD:
return COMMON_ACTIONS::gridSetOrigin.MakeEvent();
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_MENU_PCB_SHOW_HIDE_MUWAVE_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();
}
......
......@@ -41,7 +41,7 @@
#include <router/direction.h>
#include <class_board.h>
#include <class_drawsegment.h>
#include <class_edge_mod.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <class_mire.h>
......@@ -73,13 +73,38 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
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 );
DRAWSEGMENT* line = new DRAWSEGMENT;
while( drawSegment( S_SEGMENT, line ) )
{
m_frame->OnModify();
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
line->SetLocalCoord();
line->SetParent( module );
module->GraphicalItems().PushFront( line );
while( drawSegment( S_SEGMENT, line ) )
line = new EDGE_MODULE( module );
}
}
else
{
line = new DRAWSEGMENT;
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
DRAWSEGMENT* line = new DRAWSEGMENT;
while( drawSegment( S_SEGMENT, line ) )
{
m_board->Add( line );
m_frame->OnModify();
m_frame->SaveCopyInUndoList( line, UR_NEW );
line = new DRAWSEGMENT;
}
}
setTransitions();
......@@ -91,13 +116,38 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_PCB_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
if( m_editModules )
{
m_frame->SetToolID( ID_MODEDIT_CIRCLE_TOOL, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
DRAWSEGMENT* circle = new DRAWSEGMENT;
MODULE* module = m_frame->GetBoard()->m_Modules;
EDGE_MODULE* circle = new EDGE_MODULE( module );
while( drawSegment( S_CIRCLE, circle ) )
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
{
circle = new DRAWSEGMENT;
m_frame->SetToolID( ID_PCB_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
DRAWSEGMENT* circle = new DRAWSEGMENT;
while( drawSegment( S_CIRCLE, circle ) )
{
m_board->Add( circle );
m_frame->OnModify();
m_frame->SaveCopyInUndoList( circle, UR_NEW );
circle = new DRAWSEGMENT;
}
}
setTransitions();
......@@ -109,13 +159,38 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_PCB_ARC_BUTT, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
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 );
DRAWSEGMENT* arc = new DRAWSEGMENT;
while( drawArc( arc ) )
{
m_frame->OnModify();
m_frame->SaveCopyInUndoList( module, UR_MODEDIT );
arc->SetLocalCoord();
arc->SetParent( module );
module->GraphicalItems().PushFront( arc );
while( drawArc( arc ) )
arc = new EDGE_MODULE( module );
}
}
else
{
arc = new DRAWSEGMENT;
m_frame->SetToolID( ID_PCB_ARC_BUTT, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
DRAWSEGMENT* arc = new DRAWSEGMENT;
while( drawArc( arc ) )
{
m_board->Add( arc );
m_frame->OnModify();
m_frame->SaveCopyInUndoList( arc, UR_NEW );
arc = new DRAWSEGMENT;
}
}
setTransitions();
......@@ -624,11 +699,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic )
assert( aGraphic->GetWidth() > 0 );
m_view->Add( aGraphic );
m_board->Add( aGraphic );
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_frame->OnModify();
m_frame->SaveCopyInUndoList( aGraphic, UR_NEW );
}
else // User has clicked twice in the same spot
{ // a clear sign that the current drawing is finished
......@@ -785,12 +856,8 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic )
assert( aGraphic->GetWidth() > 0 );
m_view->Add( aGraphic );
m_board->Add( aGraphic );
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_frame->OnModify();
m_frame->SaveCopyInUndoList( aGraphic, UR_NEW );
preview.Remove( aGraphic );
preview.Remove( &helperLine );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment