Appy units updating more consistently to editing assistants.
Fixes https://gitlab.com/kicad/code/kicad/issues/6283
This commit is contained in:
parent
f6c17001e4
commit
8c782506b9
|
@ -246,7 +246,6 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsActivate() )
|
else if( evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( originSet )
|
if( originSet )
|
||||||
|
@ -263,7 +262,6 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// click or drag starts
|
// click or drag starts
|
||||||
else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
|
else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
|
@ -275,7 +273,6 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
originSet = true;
|
originSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// second click or mouse up after drag ends
|
// second click or mouse up after drag ends
|
||||||
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
|
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
|
@ -284,7 +281,6 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
controls.SetAutoPan( false );
|
controls.SetAutoPan( false );
|
||||||
controls.CaptureCursor( false );
|
controls.CaptureCursor( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// move or drag when origin set updates rules
|
// move or drag when origin set updates rules
|
||||||
else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
|
else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
|
@ -294,9 +290,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
view.SetVisible( &ruler, true );
|
view.SetVisible( &ruler, true );
|
||||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||||
}
|
}
|
||||||
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
||||||
else if( evt->IsAction( &ACTIONS::toggleUnits )
|
|
||||||
|| evt->IsAction( &ACTIONS::updateUnits ) )
|
|
||||||
{
|
{
|
||||||
if( m_frame->GetUserUnits() != units )
|
if( m_frame->GetUserUnits() != units )
|
||||||
{
|
{
|
||||||
|
@ -304,15 +298,16 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
ruler.SwitchUnits( units );
|
ruler.SwitchUnits( units );
|
||||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||||
}
|
}
|
||||||
|
evt->SetPassEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
m_menu.ShowContextMenu( m_frame->GetCurrentSelection() );
|
m_menu.ShowContextMenu( m_frame->GetCurrentSelection() );
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view.SetVisible( &ruler, false );
|
view.SetVisible( &ruler, false );
|
||||||
|
|
|
@ -65,6 +65,8 @@ namespace PREVIEW
|
||||||
return "ARC_ASSISTANT";
|
return "ARC_ASSISTANT";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetUnits( EDA_UNITS aUnits ) { m_units = aUnits; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ARC_GEOM_MANAGER& m_constructMan;
|
const ARC_GEOM_MANAGER& m_constructMan;
|
||||||
EDA_UNITS m_units;
|
EDA_UNITS m_units;
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
return "TWO_POINT_ASSISTANT";
|
return "TWO_POINT_ASSISTANT";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetUnits( EDA_UNITS aUnits ) { m_units = aUnits; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const TWO_POINT_GEOMETRY_MANAGER& m_constructMan;
|
const TWO_POINT_GEOMETRY_MANAGER& m_constructMan;
|
||||||
EDA_UNITS m_units;
|
EDA_UNITS m_units;
|
||||||
|
|
|
@ -1168,7 +1168,8 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), LSET::AllLayersMask() );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(),
|
||||||
|
LSET::AllLayersMask() );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
m_controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
|
@ -1208,10 +1209,10 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an PCB_SHAPE from the current state of an Two POINT Geometry Manager
|
* Update an PCB_SHAPE from the current state of a TWO_POINT_GEOMETRY_MANAGER
|
||||||
*/
|
*/
|
||||||
static void updateSegmentFromConstructionMgr(
|
static void updateSegmentFromGeometryMgr( const KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER& aMgr,
|
||||||
const KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER& aMgr, PCB_SHAPE* aGraphic )
|
PCB_SHAPE* aGraphic )
|
||||||
{
|
{
|
||||||
auto vec = aMgr.GetOrigin();
|
auto vec = aMgr.GetOrigin();
|
||||||
|
|
||||||
|
@ -1238,8 +1239,8 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE*
|
||||||
// drawing assistant overlay
|
// drawing assistant overlay
|
||||||
// TODO: workaround because PCB_SHAPE_TYPE_T is not visible from commons.
|
// TODO: workaround because PCB_SHAPE_TYPE_T is not visible from commons.
|
||||||
KIGFX::PREVIEW::GEOM_SHAPE geomShape( static_cast<KIGFX::PREVIEW::GEOM_SHAPE>( aShape ) );
|
KIGFX::PREVIEW::GEOM_SHAPE geomShape( static_cast<KIGFX::PREVIEW::GEOM_SHAPE>( aShape ) );
|
||||||
KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst(
|
KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst( twoPointManager, m_frame->GetUserUnits(),
|
||||||
twoPointManager, m_frame->GetUserUnits(), geomShape );
|
geomShape );
|
||||||
|
|
||||||
// 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
|
||||||
PCBNEW_SELECTION preview;
|
PCBNEW_SELECTION preview;
|
||||||
|
@ -1383,7 +1384,7 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE*
|
||||||
m_controls->SetAutoPan( true );
|
m_controls->SetAutoPan( true );
|
||||||
m_controls->CaptureCursor( true );
|
m_controls->CaptureCursor( true );
|
||||||
|
|
||||||
updateSegmentFromConstructionMgr( twoPointManager, graphic );
|
updateSegmentFromGeometryMgr( twoPointManager, graphic );
|
||||||
|
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
@ -1440,7 +1441,7 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE*
|
||||||
twoPointManager.SetAngleSnap( false );
|
twoPointManager.SetAngleSnap( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSegmentFromConstructionMgr( twoPointManager, graphic );
|
updateSegmentFromGeometryMgr( twoPointManager, graphic );
|
||||||
m_view->Update( &preview );
|
m_view->Update( &preview );
|
||||||
m_view->Update( &twoPointAsst );
|
m_view->Update( &twoPointAsst );
|
||||||
}
|
}
|
||||||
|
@ -1463,6 +1464,12 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, PCB_SHAPE*
|
||||||
isLocalOriginSet = true;
|
isLocalOriginSet = true;
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
}
|
}
|
||||||
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
||||||
|
{
|
||||||
|
twoPointAsst.SetUnits( frame()->GetUserUnits() );
|
||||||
|
m_view->Update( &twoPointAsst );
|
||||||
|
evt->SetPassEvent();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
|
@ -1666,6 +1673,12 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
|
||||||
{
|
{
|
||||||
arcManager.ToggleClockwise();
|
arcManager.ToggleClockwise();
|
||||||
}
|
}
|
||||||
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
||||||
|
{
|
||||||
|
arcAsst.SetUnits( frame()->GetUserUnits() );
|
||||||
|
m_view->Update( &arcAsst );
|
||||||
|
evt->SetPassEvent();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
|
@ -1889,7 +1902,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
m_controls->SetAutoPan( false );
|
m_controls->SetAutoPan( false );
|
||||||
m_controls->CaptureCursor( false );
|
m_controls->CaptureCursor( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// adding a corner
|
// adding a corner
|
||||||
else if( polyGeomMgr.AddPoint( cursorPos ) )
|
else if( polyGeomMgr.AddPoint( cursorPos ) )
|
||||||
{
|
{
|
||||||
|
@ -1943,6 +1955,14 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
frame()->SetMsgPanel( zoneTool.GetZone() );
|
frame()->SetMsgPanel( zoneTool.GetZone() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
||||||
|
{
|
||||||
|
// If we ever have an assistant here that reports dimensions, we'll want to
|
||||||
|
// update its units here....
|
||||||
|
// zoneAsst.SetUnits( frame()->GetUserUnits() );
|
||||||
|
// m_view->Update( &zoneAsst );
|
||||||
|
evt->SetPassEvent();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
|
|
|
@ -256,7 +256,6 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsActivate() )
|
else if( evt->IsActivate() )
|
||||||
{
|
{
|
||||||
if( originSet )
|
if( originSet )
|
||||||
|
@ -273,7 +272,6 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// click or drag starts
|
// click or drag starts
|
||||||
else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
|
else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
|
@ -285,7 +283,6 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
originSet = true;
|
originSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// second click or mouse up after drag ends
|
// second click or mouse up after drag ends
|
||||||
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
|
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
|
@ -294,7 +291,6 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
controls.SetAutoPan( false );
|
controls.SetAutoPan( false );
|
||||||
controls.CaptureCursor( false );
|
controls.CaptureCursor( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// move or drag when origin set updates rules
|
// move or drag when origin set updates rules
|
||||||
else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
|
else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
|
@ -304,9 +300,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
view.SetVisible( &ruler, true );
|
view.SetVisible( &ruler, true );
|
||||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||||
}
|
}
|
||||||
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
||||||
else if( evt->IsAction( &ACTIONS::toggleUnits )
|
|
||||||
|| evt->IsAction( &ACTIONS::updateUnits ) )
|
|
||||||
{
|
{
|
||||||
if( frame()->GetUserUnits() != units )
|
if( frame()->GetUserUnits() != units )
|
||||||
{
|
{
|
||||||
|
@ -315,15 +309,16 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||||
canvas()->Refresh();
|
canvas()->Refresh();
|
||||||
}
|
}
|
||||||
|
evt->SetPassEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
m_menu.ShowContextMenu();
|
m_menu.ShowContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view.SetVisible( &ruler, false );
|
view.SetVisible( &ruler, false );
|
||||||
|
|
Loading…
Reference in New Issue