Loading pcbnew/tools/drawing_tool.cpp +36 −23 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include <id.h> #include <id.h> #include <pcbnew_id.h> #include <pcbnew_id.h> #include <confirm.h> #include <confirm.h> #include <dialog_edit_module_text.h> #include <view/view_group.h> #include <view/view_group.h> #include <view/view_controls.h> #include <view/view_controls.h> Loading Loading @@ -64,7 +65,7 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason ) m_view = getView(); m_view = getView(); m_controls = getViewControls(); m_controls = getViewControls(); m_board = getModel<BOARD>(); m_board = getModel<BOARD>(); m_frame = getEditFrame<PCB_BASE_FRAME>(); m_frame = getEditFrame<PCB_EDIT_FRAME>(); setTransitions(); setTransitions(); } } Loading Loading @@ -126,7 +127,9 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent ) int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) { { TEXTE_MODULE* text = NULL; TEXTE_MODULE* text = new TEXTE_MODULE( NULL ); const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings(); MODULE* module = m_frame->GetBoard()->m_Modules; // Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item KIGFX::VIEW_GROUP preview( m_view ); KIGFX::VIEW_GROUP preview( m_view ); Loading @@ -139,6 +142,7 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) Activate(); Activate(); m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); bool placing = false; // Main loop: keep receiving events // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() ) Loading @@ -147,28 +151,26 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() ) { { if( text ) { // Delete the old text and have another try m_board->Delete( text ); // it was already added by CreateTextPcb() text = NULL; preview.Clear(); preview.Clear(); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate(); m_controls->ShowCursor( true ); m_controls->ShowCursor( true ); } else break; if( evt->IsActivate() ) // now finish unconditionally if( !placing || evt->IsActivate() ) { delete text; break; break; } } else { placing = false; // start from the beginning } } else if( text && evt->Category() == TC_COMMAND ) else if( text && evt->Category() == TC_COMMAND ) { { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { { text->Rotate( text->GetPosition(), 900.0 /*m_frame->GetRotationAngle()*/ ); // FIXME text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) Loading @@ -180,15 +182,21 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) ) { { if( !text ) if( !placing ) { { // Init the new item attributes text->SetSize( dsnSettings.m_ModuleTextSize ); text = m_frame->CreateTextModule( m_frame->GetBoard()->m_Modules, NULL ); text->SetThickness( dsnSettings.m_ModuleTextWidth ); text->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); if( text == NULL ) DialogEditModuleText textDialog( m_frame, text, NULL ); placing = textDialog.ShowModal() && ( text->GetText().Length() > 0 ); if( !placing ) continue; continue; m_controls->ShowCursor( false ); m_controls->ShowCursor( false ); text->SetParent( module ); // it has to set after the settings dialog // otherwise the dialog stores it in undo buffer preview.Add( text ); preview.Add( text ); } } else else Loading @@ -196,18 +204,23 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) assert( text->GetText().Length() > 0 ); assert( text->GetText().Length() > 0 ); assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); text->SetLocalCoord(); text->ClearFlags(); text->ClearFlags(); // Module has to be saved before any modification is made m_frame->SaveCopyInUndoList( m_frame->GetBoard()->m_Modules, UR_MODEDIT ); module->GraphicalItems().PushFront( text ); m_view->Add( text ); m_view->Add( text ); // m_board->Add( text ); // it is already added by CreateTextePcb() text->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); text->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( text, UR_NEW ); preview.Remove( text ); preview.Remove( text ); m_controls->ShowCursor( true ); m_controls->ShowCursor( true ); text = NULL; text = new TEXTE_MODULE( NULL ); placing = false; } } } } Loading Loading @@ -276,7 +289,7 @@ int DRAWING_TOOL::PlaceTextPcb( TOOL_EVENT& aEvent ) { { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { { text->Rotate( text->GetPosition(), /*m_frame->GetRotationAngle()*/ 900.0 ); // FIXME text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) Loading pcbnew/tools/drawing_tool.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,7 @@ namespace KIGFX class VIEW_CONTROLS; class VIEW_CONTROLS; } } class BOARD; class BOARD; class PCB_BASE_FRAME; class PCB_EDIT_FRAME; class DRAWSEGMENT; class DRAWSEGMENT; /** /** Loading Loading @@ -160,7 +160,7 @@ private: KIGFX::VIEW* m_view; KIGFX::VIEW* m_view; KIGFX::VIEW_CONTROLS* m_controls; KIGFX::VIEW_CONTROLS* m_controls; BOARD* m_board; BOARD* m_board; PCB_BASE_FRAME* m_frame; PCB_EDIT_FRAME* m_frame; // How does line width change after one -/+ key press. // How does line width change after one -/+ key press. static const int WIDTH_STEP = 100000; static const int WIDTH_STEP = 100000; Loading Loading
pcbnew/tools/drawing_tool.cpp +36 −23 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include <id.h> #include <id.h> #include <pcbnew_id.h> #include <pcbnew_id.h> #include <confirm.h> #include <confirm.h> #include <dialog_edit_module_text.h> #include <view/view_group.h> #include <view/view_group.h> #include <view/view_controls.h> #include <view/view_controls.h> Loading Loading @@ -64,7 +65,7 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason ) m_view = getView(); m_view = getView(); m_controls = getViewControls(); m_controls = getViewControls(); m_board = getModel<BOARD>(); m_board = getModel<BOARD>(); m_frame = getEditFrame<PCB_BASE_FRAME>(); m_frame = getEditFrame<PCB_EDIT_FRAME>(); setTransitions(); setTransitions(); } } Loading Loading @@ -126,7 +127,9 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent ) int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) { { TEXTE_MODULE* text = NULL; TEXTE_MODULE* text = new TEXTE_MODULE( NULL ); const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings(); MODULE* module = m_frame->GetBoard()->m_Modules; // Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item KIGFX::VIEW_GROUP preview( m_view ); KIGFX::VIEW_GROUP preview( m_view ); Loading @@ -139,6 +142,7 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) Activate(); Activate(); m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); bool placing = false; // Main loop: keep receiving events // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() ) Loading @@ -147,28 +151,26 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() ) { { if( text ) { // Delete the old text and have another try m_board->Delete( text ); // it was already added by CreateTextPcb() text = NULL; preview.Clear(); preview.Clear(); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate(); m_controls->ShowCursor( true ); m_controls->ShowCursor( true ); } else break; if( evt->IsActivate() ) // now finish unconditionally if( !placing || evt->IsActivate() ) { delete text; break; break; } } else { placing = false; // start from the beginning } } else if( text && evt->Category() == TC_COMMAND ) else if( text && evt->Category() == TC_COMMAND ) { { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { { text->Rotate( text->GetPosition(), 900.0 /*m_frame->GetRotationAngle()*/ ); // FIXME text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) Loading @@ -180,15 +182,21 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) ) { { if( !text ) if( !placing ) { { // Init the new item attributes text->SetSize( dsnSettings.m_ModuleTextSize ); text = m_frame->CreateTextModule( m_frame->GetBoard()->m_Modules, NULL ); text->SetThickness( dsnSettings.m_ModuleTextWidth ); text->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); if( text == NULL ) DialogEditModuleText textDialog( m_frame, text, NULL ); placing = textDialog.ShowModal() && ( text->GetText().Length() > 0 ); if( !placing ) continue; continue; m_controls->ShowCursor( false ); m_controls->ShowCursor( false ); text->SetParent( module ); // it has to set after the settings dialog // otherwise the dialog stores it in undo buffer preview.Add( text ); preview.Add( text ); } } else else Loading @@ -196,18 +204,23 @@ int DRAWING_TOOL::PlaceTextModule( TOOL_EVENT& aEvent ) assert( text->GetText().Length() > 0 ); assert( text->GetText().Length() > 0 ); assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); text->SetLocalCoord(); text->ClearFlags(); text->ClearFlags(); // Module has to be saved before any modification is made m_frame->SaveCopyInUndoList( m_frame->GetBoard()->m_Modules, UR_MODEDIT ); module->GraphicalItems().PushFront( text ); m_view->Add( text ); m_view->Add( text ); // m_board->Add( text ); // it is already added by CreateTextePcb() text->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); text->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( text, UR_NEW ); preview.Remove( text ); preview.Remove( text ); m_controls->ShowCursor( true ); m_controls->ShowCursor( true ); text = NULL; text = new TEXTE_MODULE( NULL ); placing = false; } } } } Loading Loading @@ -276,7 +289,7 @@ int DRAWING_TOOL::PlaceTextPcb( TOOL_EVENT& aEvent ) { { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { { text->Rotate( text->GetPosition(), /*m_frame->GetRotationAngle()*/ 900.0 ); // FIXME text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) Loading
pcbnew/tools/drawing_tool.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,7 @@ namespace KIGFX class VIEW_CONTROLS; class VIEW_CONTROLS; } } class BOARD; class BOARD; class PCB_BASE_FRAME; class PCB_EDIT_FRAME; class DRAWSEGMENT; class DRAWSEGMENT; /** /** Loading Loading @@ -160,7 +160,7 @@ private: KIGFX::VIEW* m_view; KIGFX::VIEW* m_view; KIGFX::VIEW_CONTROLS* m_controls; KIGFX::VIEW_CONTROLS* m_controls; BOARD* m_board; BOARD* m_board; PCB_BASE_FRAME* m_frame; PCB_EDIT_FRAME* m_frame; // How does line width change after one -/+ key press. // How does line width change after one -/+ key press. static const int WIDTH_STEP = 100000; static const int WIDTH_STEP = 100000; Loading