Commit 78853feb authored by Maciej Suminski's avatar Maciej Suminski

Zone fill/unfill actions in context menu (GAL).

parent 898e4e26
...@@ -759,7 +759,8 @@ void PNS_ROUTER::CommitRouting( PNS_NODE* aNode ) ...@@ -759,7 +759,8 @@ void PNS_ROUTER::CommitRouting( PNS_NODE* aNode )
via_board->SetWidth( via->Diameter() ); via_board->SetWidth( via->Diameter() );
via_board->SetDrill( via->Drill() ); via_board->SetDrill( via->Drill() );
via_board->SetNetCode( via->Net() ); via_board->SetNetCode( via->Net() );
via_board->SetLayerPair( m_settings.GetLayerTop(), m_settings.GetLayerBottom() ); via_board->SetLayerPair( ToLAYER_ID( m_settings.GetLayerTop() ),
ToLAYER_ID( m_settings.GetLayerBottom() ) );
newBI = via_board; newBI = via_board;
break; break;
} }
......
...@@ -212,8 +212,8 @@ public: ...@@ -212,8 +212,8 @@ public:
Add( ACT_PlaceThroughVia ); Add( ACT_PlaceThroughVia );
Add( ACT_SwitchPosture ); Add( ACT_SwitchPosture );
AppendSeparator ( ); AppendSeparator();
CONTEXT_TRACK_WIDTH_MENU* trackMenu = new CONTEXT_TRACK_WIDTH_MENU; CONTEXT_TRACK_WIDTH_MENU* trackMenu = new CONTEXT_TRACK_WIDTH_MENU;
trackMenu->SetBoard( aBoard ); trackMenu->SetBoard( aBoard );
AppendSubMenu( trackMenu, wxT( "Select Track Width" ) ); AppendSubMenu( trackMenu, wxT( "Select Track Width" ) );
...@@ -567,7 +567,7 @@ void ROUTER_TOOL::performRouting() ...@@ -567,7 +567,7 @@ void ROUTER_TOOL::performRouting()
break; break;
// Synchronize the indicated layer // Synchronize the indicated layer
frame->SetActiveLayer( m_router->GetCurrentLayer() ); frame->SetActiveLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) );
m_router->Move( m_endSnapPoint, m_endItem ); m_router->Move( m_endSnapPoint, m_endItem );
} }
......
...@@ -109,6 +109,7 @@ TOOL_ACTION COMMON_ACTIONS::setAnchor( "pcbnew.InteractiveDrawing.setAnchor", ...@@ -109,6 +109,7 @@ TOOL_ACTION COMMON_ACTIONS::setAnchor( "pcbnew.InteractiveDrawing.setAnchor",
"Place the footprint anchor", "Place the footprint anchor", "Place the footprint anchor", "Place the footprint anchor",
AF_ACTIVATE ); AF_ACTIVATE );
// View Controls // View Controls
TOOL_ACTION COMMON_ACTIONS::zoomIn( "pcbnew.Control.zoomIn", TOOL_ACTION COMMON_ACTIONS::zoomIn( "pcbnew.Control.zoomIn",
AS_GLOBAL, WXK_F1, AS_GLOBAL, WXK_F1,
...@@ -271,6 +272,20 @@ TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaS ...@@ -271,6 +272,20 @@ TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaS
"", "", AF_NOTIFY ); "", "", AF_NOTIFY );
// Zone actions
TOOL_ACTION COMMON_ACTIONS::zoneFill( "pcbnew.EditorControl.zoneFill",
AS_GLOBAL, 0,
"Fill", "Fill zone(s)" );
TOOL_ACTION COMMON_ACTIONS::zoneFillAll( "pcbnew.EditorControl.zoneFillAll",
AS_GLOBAL, 0,
"Fill all", "Fill all zones" );
TOOL_ACTION COMMON_ACTIONS::zoneUnfill( "pcbnew.EditorControl.zoneUnfill",
AS_GLOBAL, 0,
"Unfill", "Unfill zone(s)" );
// Module editor tools // Module editor tools
TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad", TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
AS_GLOBAL, 0, AS_GLOBAL, 0,
......
...@@ -62,7 +62,6 @@ public: ...@@ -62,7 +62,6 @@ public:
/// Deleting a BOARD_ITEM /// Deleting a BOARD_ITEM
static TOOL_ACTION remove; static TOOL_ACTION remove;
// Drawing Tool // Drawing Tool
/// Activation of the drawing tool (line) /// Activation of the drawing tool (line)
static TOOL_ACTION drawLine; static TOOL_ACTION drawLine;
...@@ -177,6 +176,10 @@ public: ...@@ -177,6 +176,10 @@ public:
static TOOL_ACTION trackViaSizeChanged; // notification static TOOL_ACTION trackViaSizeChanged; // notification
// Zone actions
static TOOL_ACTION zoneFill;
static TOOL_ACTION zoneFillAll;
static TOOL_ACTION zoneUnfill;
// Module editor tools // Module editor tools
/// Activation of the drawing tool (placing a PAD) /// Activation of the drawing tool (placing a PAD)
...@@ -197,7 +200,6 @@ public: ...@@ -197,7 +200,6 @@ public:
/// Display module texts as outlines /// Display module texts as outlines
static TOOL_ACTION moduleTextOutlines; static TOOL_ACTION moduleTextOutlines;
// Miscellaneous // Miscellaneous
static TOOL_ACTION resetCoords; static TOOL_ACTION resetCoords;
static TOOL_ACTION switchCursor; static TOOL_ACTION switchCursor;
......
...@@ -25,10 +25,26 @@ ...@@ -25,10 +25,26 @@
#include "pcb_editor_control.h" #include "pcb_editor_control.h"
#include "common_actions.h" #include "common_actions.h"
#include "selection_tool.h"
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <class_board.h> #include <class_board.h>
#include <class_zone.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
class ZONE_CONTEXT_MENU : public CONTEXT_MENU
{
public:
ZONE_CONTEXT_MENU()
{
Add( COMMON_ACTIONS::zoneFill );
Add( COMMON_ACTIONS::zoneFillAll );
Add( COMMON_ACTIONS::zoneUnfill );
}
};
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() : PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.EditorControl" ) TOOL_INTERACTIVE( "pcbnew.EditorControl" )
{ {
...@@ -43,6 +59,14 @@ void PCB_EDITOR_CONTROL::Reset( RESET_REASON aReason ) ...@@ -43,6 +59,14 @@ void PCB_EDITOR_CONTROL::Reset( RESET_REASON aReason )
bool PCB_EDITOR_CONTROL::Init() bool PCB_EDITOR_CONTROL::Init()
{ {
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
if( selTool )
{
selTool->AddSubMenu( new ZONE_CONTEXT_MENU, wxT( "Zones" ),
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
}
setTransitions(); setTransitions();
return true; return true;
...@@ -134,6 +158,67 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent ) ...@@ -134,6 +158,67 @@ int PCB_EDITOR_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent )
} }
// Zone actions
int PCB_EDITOR_CONTROL::ZoneFill( TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
for( int i = 0; i < selection.Size(); ++i )
{
assert( selection.Item<BOARD_ITEM>( i )->Type() == PCB_ZONE_AREA_T );
ZONE_CONTAINER* zone = selection.Item<ZONE_CONTAINER>( i );
m_frame->Fill_Zone( zone );
zone->SetIsFilled( true );
zone->ViewUpdate();
}
setTransitions();
return 0;
}
int PCB_EDITOR_CONTROL::ZoneFillAll( TOOL_EVENT& aEvent )
{
BOARD* board = getModel<BOARD>();
for( int i = 0; i < board->GetAreaCount(); ++i )
{
ZONE_CONTAINER* zone = board->GetArea( i );
m_frame->Fill_Zone( zone );
zone->SetIsFilled( true );
zone->ViewUpdate();
}
setTransitions();
return 0;
}
int PCB_EDITOR_CONTROL::ZoneUnfill( TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
for( int i = 0; i < selection.Size(); ++i )
{
assert( selection.Item<BOARD_ITEM>( i )->Type() == PCB_ZONE_AREA_T );
ZONE_CONTAINER* zone = selection.Item<ZONE_CONTAINER>( i );
zone->SetIsFilled( false );
zone->ClearFilledPolysList();
zone->ViewUpdate();
}
setTransitions();
return 0;
}
void PCB_EDITOR_CONTROL::setTransitions() void PCB_EDITOR_CONTROL::setTransitions()
{ {
// Track & via size control // Track & via size control
...@@ -141,4 +226,9 @@ void PCB_EDITOR_CONTROL::setTransitions() ...@@ -141,4 +226,9 @@ void PCB_EDITOR_CONTROL::setTransitions()
Go( &PCB_EDITOR_CONTROL::TrackWidthDec, COMMON_ACTIONS::trackWidthDec.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::TrackWidthDec, COMMON_ACTIONS::trackWidthDec.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ViaSizeInc, COMMON_ACTIONS::viaSizeInc.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::ViaSizeInc, COMMON_ACTIONS::viaSizeInc.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ViaSizeDec, COMMON_ACTIONS::viaSizeDec.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::ViaSizeDec, COMMON_ACTIONS::viaSizeDec.MakeEvent() );
// Zone actions
Go( &PCB_EDITOR_CONTROL::ZoneFill, COMMON_ACTIONS::zoneFill.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ZoneFillAll, COMMON_ACTIONS::zoneFillAll.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ZoneUnfill, COMMON_ACTIONS::zoneUnfill.MakeEvent() );
} }
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
/** /**
* Class PCBNEW_CONTROL * Class PCB_EDITOR_CONTROL
* *
* Handles hot keys that are not accepted by any other tool. * Handles actions specific to the board editor in pcbnew.
*/ */
class PCB_EDITOR_CONTROL : public TOOL_INTERACTIVE class PCB_EDITOR_CONTROL : public TOOL_INTERACTIVE
{ {
...@@ -51,6 +51,11 @@ public: ...@@ -51,6 +51,11 @@ public:
int ViaSizeInc( TOOL_EVENT& aEvent ); int ViaSizeInc( TOOL_EVENT& aEvent );
int ViaSizeDec( TOOL_EVENT& aEvent ); int ViaSizeDec( TOOL_EVENT& aEvent );
// Zone actions
int ZoneFill( TOOL_EVENT& aEvent );
int ZoneFillAll( TOOL_EVENT& aEvent );
int ZoneUnfill( TOOL_EVENT& aEvent );
private: private:
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions(); void setTransitions();
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <view/view_controls.h> #include <view/view_controls.h>
#include <pcb_painter.h> #include <pcb_painter.h>
PCBNEW_CONTROL::PCBNEW_CONTROL() : PCBNEW_CONTROL::PCBNEW_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.Control" ) TOOL_INTERACTIVE( "pcbnew.Control" )
{ {
......
...@@ -32,7 +32,7 @@ class PCB_BASE_FRAME; ...@@ -32,7 +32,7 @@ class PCB_BASE_FRAME;
/** /**
* Class PCBNEW_CONTROL * Class PCBNEW_CONTROL
* *
* Handles hot keys that are not accepted by any other tool. * Handles actions that are shared between different frames in pcbnew.
*/ */
class PCBNEW_CONTROL : public TOOL_INTERACTIVE class PCBNEW_CONTROL : public TOOL_INTERACTIVE
...@@ -75,12 +75,6 @@ public: ...@@ -75,12 +75,6 @@ public:
int GridPrev( TOOL_EVENT& aEvent ); int GridPrev( TOOL_EVENT& aEvent );
int GridSetOrigin( TOOL_EVENT& aEvent ); int GridSetOrigin( TOOL_EVENT& aEvent );
// Track & via size control
int TrackWidthInc( TOOL_EVENT& aEvent );
int TrackWidthDec( TOOL_EVENT& aEvent );
int ViaSizeInc( TOOL_EVENT& aEvent );
int ViaSizeDec( TOOL_EVENT& aEvent );
// Miscellaneous // Miscellaneous
int ResetCoords( TOOL_EVENT& aEvent ); int ResetCoords( TOOL_EVENT& aEvent );
int SwitchCursor( TOOL_EVENT& aEvent ); int SwitchCursor( TOOL_EVENT& aEvent );
......
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