Keep circles controlled by radius

Circles are defined by center and a point on their edge.  This requires
the user to do extra math to figure out the size of the circle.  The
patch allows the user to edit and draw circles using radial coordinates.
This commit is contained in:
Seth Hillbrand 2018-04-27 09:09:05 -07:00
parent 3a8a718e43
commit 0c2f9b1827
3 changed files with 34 additions and 9 deletions

View File

@ -156,8 +156,10 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
SetTitle( _( "Circle Properties" ) );
m_StartPointXLabel->SetLabel( _( "Center X:" ) );
m_StartPointYLabel->SetLabel( _( "Center Y:" ) );
m_EndPointXLabel->SetLabel( _( "Point X:" ) );
m_EndPointYLabel->SetLabel( _( "Point Y:" ) );
m_EndPointXLabel->SetLabel( _( "Radius:" ) );
m_EndPointYLabel->Show( false );
m_EndPointYUnit->Show( false );
m_EndY_Ctrl->Show( false );
break;
case S_ARC:
@ -187,9 +189,15 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
PutValueInLocalUnits( *m_Center_StartYCtrl, m_item->GetStart().y );
PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_item->GetEnd().x );
PutValueInLocalUnits( *m_EndY_Ctrl, m_item->GetEnd().y );
if( m_item->GetShape() == S_CIRCLE )
{
PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_item->GetRadius() );
}
else
{
PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_item->GetEnd().x );
PutValueInLocalUnits( *m_EndY_Ctrl, m_item->GetEnd().y );
}
PutValueInLocalUnits( *m_ThicknessCtrl, m_item->GetWidth() );
@ -253,11 +261,19 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
msg = m_Center_StartYCtrl->GetValue();
m_item->SetStartY( ValueFromString( g_UserUnit, msg ) );
msg = m_EndX_Radius_Ctrl->GetValue();
m_item->SetEndX( ValueFromString( g_UserUnit, msg ) );
if( m_item->GetShape() == S_CIRCLE )
{
msg = m_EndX_Radius_Ctrl->GetValue();
m_item->SetEnd( m_item->GetStart() + wxPoint( ValueFromString( g_UserUnit, msg ), 0 ) );
}
else
{
msg = m_EndX_Radius_Ctrl->GetValue();
m_item->SetEndX( ValueFromString( g_UserUnit, msg ) );
msg = m_EndY_Ctrl->GetValue();
m_item->SetEndY( ValueFromString( g_UserUnit, msg ) );
msg = m_EndY_Ctrl->GetValue();
m_item->SetEndY( ValueFromString( g_UserUnit, msg ) );
}
msg = m_ThicknessCtrl->GetValue();
m_item->SetWidth( ValueFromString( g_UserUnit, msg ) );

View File

@ -1071,6 +1071,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
// 45 degree lines
if( direction45 && aShape == S_SEGMENT )
make45DegLine( aGraphic, &line45 );
else if( aShape == S_CIRCLE )
aGraphic->SetEnd( aGraphic->GetStart() + wxPoint(
EuclideanNorm( wxPoint( cursorPos - aGraphic->GetStart() ) ), 0 ) );
else
aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );

View File

@ -164,6 +164,12 @@ public:
case S_CIRCLE:
points->AddPoint( segment->GetCenter() );
points->AddPoint( segment->GetEnd() );
// Set constraints
// Circle end is on the horizontal axis with the center
points->Point( CIRC_END ).SetConstraint(
new EC_HORIZONTAL( points->Point( CIRC_END ),
points->Point( CIRC_CENTER ) ) );
break;
case S_POLYGON: