Add "Limit graphic lines to 45 deg" to line drawing tool context menu
Fixes https://gitlab.com/kicad/code/kicad/issues/7181
This commit is contained in:
parent
6272b48481
commit
5aaedd86ed
|
@ -675,6 +675,8 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( PCB_ACTIONS::zoneFill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::zoneUnfill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) );
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::toggleLine45degMode, CHECK( cond.Line45degMode() ) );
|
||||
|
||||
|
||||
#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
|
||||
|
||||
|
|
|
@ -455,6 +455,10 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
|
|||
zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
|
||||
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
|
||||
|
||||
std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
|
||||
lineMenu->Add( PCB_ACTIONS::toggleLine45degMode, ACTION_MENU::CHECK );
|
||||
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
|
||||
|
||||
m_drawToolBar->KiRealize();
|
||||
}
|
||||
|
||||
|
|
|
@ -1236,6 +1236,14 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::ToggleLine45degMode( const TOOL_EVENT& toolEvent )
|
||||
{
|
||||
m_frame->Settings().m_Use45DegreeGraphicSegments = !m_frame->Settings().m_Use45DegreeGraphicSegments;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update an PCB_SHAPE from the current state of a TWO_POINT_GEOMETRY_MANAGER
|
||||
*/
|
||||
|
@ -2430,4 +2438,5 @@ void DRAWING_TOOL::setTransitions()
|
|||
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::ToggleLine45degMode, PCB_ACTIONS::toggleLine45degMode.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -159,6 +159,11 @@ public:
|
|||
*/
|
||||
int SetAnchor( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Toggle the 45 degree angle constraint for graphic lines.
|
||||
*/
|
||||
int ToggleLine45degMode( const TOOL_EVENT& aEvent );
|
||||
|
||||
///< Set up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "pcb_actions.h"
|
||||
#include "tool/tool_event.h"
|
||||
#include <pcbnew_id.h>
|
||||
#include <bitmaps.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
@ -211,6 +212,10 @@ TOOL_ACTION PCB_ACTIONS::closeOutline( "pcbnew.InteractiveDrawing.closeOutline",
|
|||
_( "Close Outline" ), _( "Close the in progress outline" ),
|
||||
checked_ok_xpm );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::toggleLine45degMode( "pcbnew.InteractiveDrawing.line45degMode",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Limit Lines to 45 deg" ), _( "Limit graphic lines to H, V and 45 degrees" ),
|
||||
nullptr, AF_NONE );
|
||||
|
||||
// DRC
|
||||
//
|
||||
|
|
|
@ -165,6 +165,9 @@ public:
|
|||
static TOOL_ACTION deleteLastPoint;
|
||||
static TOOL_ACTION closeOutline;
|
||||
|
||||
/// Toggle 45 degree line drawing mode
|
||||
static TOOL_ACTION toggleLine45degMode;
|
||||
|
||||
/// Increase width of currently drawn line
|
||||
static TOOL_ACTION incWidth;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "pcbnew_settings.h"
|
||||
#include <board.h>
|
||||
#include <pcb_base_frame.h>
|
||||
#include <tool/selection.h>
|
||||
|
@ -122,6 +123,16 @@ SELECTION_CONDITION PCB_EDITOR_CONDITIONS::ZoneDisplayMode( ZONE_DISPLAY_MODE aM
|
|||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::Line45degMode()
|
||||
{
|
||||
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
||||
|
||||
wxASSERT( drwFrame );
|
||||
|
||||
return std::bind( &PCB_EDITOR_CONDITIONS::line45degModeFunc, _1, drwFrame );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDITOR_CONDITIONS::hasItemsFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
||||
{
|
||||
BOARD* board = aFrame->GetBoard();
|
||||
|
@ -171,3 +182,8 @@ bool PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc( const SELECTION& aSelection, PC
|
|||
{
|
||||
return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
|
||||
}
|
||||
|
||||
bool PCB_EDITOR_CONDITIONS::line45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
||||
{
|
||||
return aFrame->Settings().m_Use45DegreeGraphicSegments;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
SELECTION_CONDITION ViaFillDisplay();
|
||||
|
||||
/**
|
||||
* Create a functor that tests if the frame fills vias
|
||||
* Create a functor that tests if the frame fills tracks
|
||||
*
|
||||
* @return Functor returning true if tracks are filled
|
||||
*/
|
||||
|
@ -101,6 +101,13 @@ public:
|
|||
*/
|
||||
SELECTION_CONDITION ZoneDisplayMode( ZONE_DISPLAY_MODE aMode );
|
||||
|
||||
/**
|
||||
* Create a functor that tests whether only 45 degree graphic lines should be drawn
|
||||
*
|
||||
* @return Functor returning true if only 45 degree graphic lines should be drawn
|
||||
*/
|
||||
SELECTION_CONDITION Line45degMode();
|
||||
|
||||
protected:
|
||||
///< Helper function used by HasItems()
|
||||
static bool hasItemsFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
|
||||
|
@ -126,6 +133,9 @@ protected:
|
|||
///< Helper function used by ZoneDisplayMode()
|
||||
static bool zoneDisplayModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame,
|
||||
ZONE_DISPLAY_MODE aMode );
|
||||
|
||||
///< Helper function used by Line45degMode()
|
||||
static bool line45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame );
|
||||
};
|
||||
|
||||
#endif /* PCB_EDITOR_CONDITIONS_H_ */
|
||||
|
|
Loading…
Reference in New Issue