parent
1e054071fc
commit
570f4dd991
|
@ -74,11 +74,11 @@ bool SHAPE_ARC::Collide( const SEG& aSeg, int aClearance ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SHAPE_ARC::ConstructFromCorners( VECTOR2I aP0, VECTOR2I aP1, double aCenterAngle )
|
bool SHAPE_ARC::ConstructFromCorners( const VECTOR2I& aP0, const VECTOR2I& aP1, double aCenterAngle )
|
||||||
{
|
{
|
||||||
VECTOR2D mid = ( VECTOR2D( aP0 ) + VECTOR2D( aP1 ) ) * 0.5;
|
VECTOR2D mid = ( VECTOR2D( aP0 ) + VECTOR2D( aP1 ) ) * 0.5;
|
||||||
VECTOR2D chord = VECTOR2D( aP1 ) - VECTOR2D( aP0 );
|
VECTOR2D chord = VECTOR2D( aP1 ) - VECTOR2D( aP0 );
|
||||||
double c = (aP1 - aP0).EuclideanNorm() / 2;
|
double c = (aP1 - aP0).EuclideanNorm() / 2.0;
|
||||||
VECTOR2D d = chord.Rotate( M_PI / 2.0 ).Resize( c );
|
VECTOR2D d = chord.Rotate( M_PI / 2.0 ).Resize( c );
|
||||||
|
|
||||||
m_pc = mid + d * ( 1.0 / tan( aCenterAngle / 2.0 * M_PI / 180.0 ) );
|
m_pc = mid + d * ( 1.0 / tan( aCenterAngle / 2.0 * M_PI / 180.0 ) );
|
||||||
|
@ -88,7 +88,8 @@ bool SHAPE_ARC::ConstructFromCorners( VECTOR2I aP0, VECTOR2I aP1, double aCenter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHAPE_ARC::ConstructFromCornerAndAngles( VECTOR2I aP0,
|
|
||||||
|
bool SHAPE_ARC::ConstructFromCornerAndAngles( const VECTOR2I& aP0,
|
||||||
double aStartAngle,
|
double aStartAngle,
|
||||||
double aCenterAngle,
|
double aCenterAngle,
|
||||||
double aRadius )
|
double aRadius )
|
||||||
|
@ -148,7 +149,8 @@ double SHAPE_ARC::GetCentralAngle() const
|
||||||
return ea - sa;
|
return ea - sa;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
|
|
||||||
|
SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
|
||||||
{
|
{
|
||||||
SHAPE_LINE_CHAIN rv;
|
SHAPE_LINE_CHAIN rv;
|
||||||
double ca = GetCentralAngle();
|
double ca = GetCentralAngle();
|
||||||
|
@ -158,15 +160,10 @@ const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if( r == 0.0 )
|
if( r == 0.0 )
|
||||||
{
|
return rv;
|
||||||
ca = 0;
|
|
||||||
n = 0;
|
step = 180.0 / M_PI * acos( r * ( 1.0 - aAccuracy ) / r );
|
||||||
}
|
n = (int) ceil( ca / step );
|
||||||
else
|
|
||||||
{
|
|
||||||
step = 180 / M_PI * acos( r * ( 1 - aAccuracy ) / r );
|
|
||||||
n = (int) ceil(ca / step);
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int i = 0; i <= n ; i++ )
|
for( int i = 0; i <= n ; i++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,6 +62,7 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
||||||
ITEM_PICKER redoWrapper = redoCommand->PopItem();
|
ITEM_PICKER redoWrapper = redoCommand->PopItem();
|
||||||
delete redoCommand;
|
delete redoCommand;
|
||||||
LIB_PART* part = (LIB_PART*) redoWrapper.GetItem();
|
LIB_PART* part = (LIB_PART*) redoWrapper.GetItem();
|
||||||
|
wxCHECK( part, /* void */ );
|
||||||
part->SetFlags( part->GetFlags() & ~UR_TRANSIENT );
|
part->SetFlags( part->GetFlags() & ~UR_TRANSIENT );
|
||||||
UNDO_REDO_T undoRedoType = redoWrapper.GetStatus();
|
UNDO_REDO_T undoRedoType = redoWrapper.GetStatus();
|
||||||
|
|
||||||
|
@ -79,9 +80,6 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
||||||
// Just set the current part to the part which come from the redo list
|
// Just set the current part to the part which come from the redo list
|
||||||
m_my_part = part;
|
m_my_part = part;
|
||||||
|
|
||||||
if( !part )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( undoRedoType == UR_LIB_RENAME )
|
if( undoRedoType == UR_LIB_RENAME )
|
||||||
{
|
{
|
||||||
wxString lib = GetCurLib();
|
wxString lib = GetCurLib();
|
||||||
|
@ -115,6 +113,7 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
|
||||||
ITEM_PICKER undoWrapper = undoCommand->PopItem();
|
ITEM_PICKER undoWrapper = undoCommand->PopItem();
|
||||||
delete undoCommand;
|
delete undoCommand;
|
||||||
LIB_PART* part = (LIB_PART*) undoWrapper.GetItem();
|
LIB_PART* part = (LIB_PART*) undoWrapper.GetItem();
|
||||||
|
wxCHECK( part, /* void */ );
|
||||||
part->SetFlags( part->GetFlags() & ~UR_TRANSIENT );
|
part->SetFlags( part->GetFlags() & ~UR_TRANSIENT );
|
||||||
UNDO_REDO_T undoRedoType = undoWrapper.GetStatus();
|
UNDO_REDO_T undoRedoType = undoWrapper.GetStatus();
|
||||||
|
|
||||||
|
@ -126,17 +125,12 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
|
||||||
redoCommand->PushItem( redoWrapper );
|
redoCommand->PushItem( redoWrapper );
|
||||||
GetScreen()->PushCommandToRedoList( redoCommand );
|
GetScreen()->PushCommandToRedoList( redoCommand );
|
||||||
|
|
||||||
printf("RestoreCopy [%p]\n", part);
|
|
||||||
|
|
||||||
// Do not delete the previous part by calling SetCurPart( part ),
|
// Do not delete the previous part by calling SetCurPart( part ),
|
||||||
// which calls delete <previous part>.
|
// which calls delete <previous part>.
|
||||||
// <previous part> is now put in redo list and is owned by this list.
|
// <previous part> is now put in redo list and is owned by this list.
|
||||||
// Just set the current part to the part which come from the undo list
|
// Just set the current part to the part which come from the undo list
|
||||||
m_my_part = part;
|
m_my_part = part;
|
||||||
|
|
||||||
if( !part )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( undoRedoType == UR_LIB_RENAME )
|
if( undoRedoType == UR_LIB_RENAME )
|
||||||
{
|
{
|
||||||
wxString lib = GetCurLib();
|
wxString lib = GetCurLib();
|
||||||
|
|
|
@ -105,15 +105,15 @@ public:
|
||||||
double GetEndAngle() const;
|
double GetEndAngle() const;
|
||||||
|
|
||||||
|
|
||||||
bool ConstructFromCorners( VECTOR2I aP0, VECTOR2I aP1, double aCenterAngle );
|
bool ConstructFromCorners( const VECTOR2I& aP0, const VECTOR2I& aP1, double aCenterAngle );
|
||||||
|
|
||||||
|
|
||||||
bool ConstructFromCornerAndAngles( VECTOR2I aP0,
|
bool ConstructFromCornerAndAngles( const VECTOR2I& aP0,
|
||||||
double aStartAngle,
|
double aStartAngle,
|
||||||
double aCenterAngle,
|
double aCenterAngle,
|
||||||
double aRadius );
|
double aRadius );
|
||||||
|
|
||||||
const SHAPE_LINE_CHAIN ConvertToPolyline( double aAccuracy = 0.02f ) const;
|
SHAPE_LINE_CHAIN ConvertToPolyline( double aAccuracy = 0.02 ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue