Respect 45-degree mode when set from zone dialog.
Fixes: lp:1655073 * https://bugs.launchpad.net/kicad/+bug/1655073
This commit is contained in:
parent
4d5e1489fb
commit
cd81254262
|
@ -36,7 +36,7 @@ bool POLYGON_GEOM_MANAGER::AddPoint( const VECTOR2I& aPt )
|
|||
{
|
||||
// if this is the first point, make sure the client is happy
|
||||
// for us to continue
|
||||
if( !IsPolygonInProgress() && !m_client.OnFirstPoint() )
|
||||
if( !IsPolygonInProgress() && !m_client.OnFirstPoint( *this ) )
|
||||
return false;
|
||||
|
||||
if( m_leaderPts.size() > 1 )
|
||||
|
@ -69,9 +69,9 @@ void POLYGON_GEOM_MANAGER::SetLeaderMode( LEADER_MODE aMode )
|
|||
}
|
||||
|
||||
|
||||
void POLYGON_GEOM_MANAGER::SetCursorPosition( const VECTOR2I& aPos )
|
||||
void POLYGON_GEOM_MANAGER::SetCursorPosition( const VECTOR2I& aPos, LEADER_MODE aModifier )
|
||||
{
|
||||
updateLeaderPoints( aPos );
|
||||
updateLeaderPoints( aPos, aModifier );
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,11 +114,11 @@ void POLYGON_GEOM_MANAGER::Reset()
|
|||
}
|
||||
|
||||
|
||||
void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint )
|
||||
void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER_MODE aModifier )
|
||||
{
|
||||
SHAPE_LINE_CHAIN newChain;
|
||||
|
||||
if( m_leaderMode == LEADER_MODE::DEG45 )
|
||||
if( m_leaderMode == LEADER_MODE::DEG45 || aModifier == LEADER_MODE::DEG45 )
|
||||
{
|
||||
// get a restricted 45/H/V line from the last fixed point to the cursor
|
||||
DIRECTION_45 direction( m_lockedPoints.back() - aEndPoint );
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
*
|
||||
* @return false to veto start of new polygon
|
||||
*/
|
||||
virtual bool OnFirstPoint() = 0;
|
||||
virtual bool OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr ) = 0;
|
||||
|
||||
///> Sent when the polygon geometry changes
|
||||
virtual void OnGeometryChange( const POLYGON_GEOM_MANAGER& aMgr ) = 0;
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
/**
|
||||
* Set the current cursor position
|
||||
*/
|
||||
void SetCursorPosition( const VECTOR2I& aPos );
|
||||
void SetCursorPosition( const VECTOR2I& aPos, LEADER_MODE aModifier );
|
||||
|
||||
/**
|
||||
* @return true if the polygon in "in progress", i.e. it has at least
|
||||
|
@ -141,7 +141,8 @@ private:
|
|||
* Update the leader line points based on a new endpoint (probably
|
||||
* a cursor position)
|
||||
*/
|
||||
void updateLeaderPoints( const VECTOR2I& aEndPoint );
|
||||
void updateLeaderPoints( const VECTOR2I& aEndPoint,
|
||||
LEADER_MODE aModifier = LEADER_MODE::DIRECT );
|
||||
|
||||
///> The "user" of the polygon data that is informed when the geometry changes
|
||||
CLIENT& m_client;
|
||||
|
|
|
@ -658,6 +658,8 @@ public:
|
|||
|
||||
const std::vector<SEG>& GetHatchLines() const { return m_HatchLines; }
|
||||
|
||||
bool GetHV45() const { return m_hv45; }
|
||||
void SetHV45( bool aConstrain ) { m_hv45 = aConstrain; }
|
||||
|
||||
#if defined(DEBUG)
|
||||
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
|
@ -739,6 +741,8 @@ private:
|
|||
std::vector<SEG> m_HatchLines; // hatch lines
|
||||
std::vector<int> m_insulatedIslands;
|
||||
|
||||
bool m_hv45; // constrain edges to horizontal, vertical or 45º
|
||||
|
||||
/**
|
||||
* Union to handle conversion between references to wxPoint and to VECTOR2I.
|
||||
*
|
||||
|
|
|
@ -1325,10 +1325,9 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr )
|
|||
else if( polyGeomMgr.IsPolygonInProgress()
|
||||
&& ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
|
||||
{
|
||||
bool draw45 = evt->Modifier( MD_CTRL );
|
||||
polyGeomMgr.SetLeaderMode( draw45 ? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
|
||||
: POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||
polyGeomMgr.SetCursorPosition( cursorPos );
|
||||
polyGeomMgr.SetCursorPosition( cursorPos, evt->Modifier( MD_CTRL )
|
||||
? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
|
||||
: POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||
}
|
||||
} // end while
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
|||
}
|
||||
|
||||
|
||||
bool ZONE_CREATE_HELPER::OnFirstPoint()
|
||||
bool ZONE_CREATE_HELPER::OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr )
|
||||
{
|
||||
// if we don't have a zone, create one
|
||||
// the user's choice here can affect things like the colour
|
||||
|
@ -211,6 +211,10 @@ bool ZONE_CREATE_HELPER::OnFirstPoint()
|
|||
m_previewItem.SetFillColor( color.WithAlpha( 0.2 ) );
|
||||
|
||||
m_parentView.SetVisible( &m_previewItem, true );
|
||||
|
||||
aMgr.SetLeaderMode( m_zone.get()->GetHV45()
|
||||
? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
|
||||
: POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
void OnGeometryChange( const POLYGON_GEOM_MANAGER& aMgr ) override;
|
||||
|
||||
bool OnFirstPoint() override;
|
||||
bool OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr ) override;
|
||||
|
||||
void OnComplete( const POLYGON_GEOM_MANAGER& aMgr ) override;
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE_CONTAINER& aSource )
|
|||
m_keepoutDoNotAllowCopperPour = aSource.GetDoNotAllowCopperPour();
|
||||
m_keepoutDoNotAllowVias = aSource.GetDoNotAllowVias();
|
||||
m_keepoutDoNotAllowTracks = aSource.GetDoNotAllowTracks();
|
||||
m_Zone_45_Only = aSource.GetHV45();
|
||||
|
||||
m_CurrentZone_Layer = aSource.GetLayer();
|
||||
m_Layers = aSource.GetLayerSet();
|
||||
|
@ -111,6 +112,7 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c
|
|||
aTarget.SetDoNotAllowCopperPour( GetDoNotAllowCopperPour() );
|
||||
aTarget.SetDoNotAllowVias( GetDoNotAllowVias() );
|
||||
aTarget.SetDoNotAllowTracks( GetDoNotAllowTracks() );
|
||||
aTarget.SetHV45( m_Zone_45_Only );
|
||||
|
||||
if( aFullExport )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue