本文整理汇总了C++中DRAWSEGMENT::SetArcStart方法的典型用法代码示例。如果您正苦于以下问题:C++ DRAWSEGMENT::SetArcStart方法的具体用法?C++ DRAWSEGMENT::SetArcStart怎么用?C++ DRAWSEGMENT::SetArcStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DRAWSEGMENT
的用法示例。
在下文中一共展示了DRAWSEGMENT::SetArcStart方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: center
/*
* Import Arc entities.
*/
void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
{
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
segm->SetShape( S_ARC );
// Init arc centre:
wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetCenter( center );
// Init arc start point
double arcStartx = data.radious;
double arcStarty = 0;
double startangle = data.staangle;
double endangle = data.endangle;
RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) );
wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
mapY( arcStarty + data.basePoint.y ) );
segm->SetArcStart( arcStart );
// calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
double angle = -RAD2DECIDEG( endangle - startangle );
if( angle > 0.0 )
angle -= 3600.0;
segm->SetAngle( angle );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness : data.thickness ) );
m_newItemsList.push_back( segm );
}
示例2: center
/*
* Import Arc entities.
*/
void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
{
DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );
segm->SetLayer( m_brdLayer );
segm->SetShape( S_ARC );
// Init arc centre:
wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetCenter( center );
// Init arc start point
double arcStartx = data.radious;
double arcStarty = 0;
double startangle = data.staangle;
double endangle = data.endangle;
RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) );
wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
mapY( arcStarty + data.basePoint.y ) );
segm->SetArcStart( arcStart );
// calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
double angle = -RAD2DECIDEG( endangle - startangle );
if( angle > 0.0 )
angle -= 3600.0;
segm->SetAngle( angle );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
appendToBoard( segm );
}
示例3: updateItem
void POINT_EDITOR::updateItem() const
{
EDA_ITEM* item = m_editPoints->GetParent();
switch( item->Type() )
{
case PCB_LINE_T:
case PCB_MODULE_EDGE_T:
{
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
switch( segment->GetShape() )
{
case S_SEGMENT:
if( isModified( m_editPoints->Point( SEG_START ) ) )
segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
m_editPoints->Point( SEG_START ).GetPosition().y ) );
else if( isModified( m_editPoints->Point( SEG_END ) ) )
segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
m_editPoints->Point( SEG_END ).GetPosition().y ) );
break;
case S_ARC:
{
const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
if( center != segment->GetCenter() )
{
wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
segment->Move( moveVector );
m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
}
else
{
segment->SetArcStart( wxPoint( start.x, start.y ) );
VECTOR2D startLine = start - center;
VECTOR2I endLine = end - center;
double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
// Adjust the new angle to (counter)clockwise setting
bool clockwise = ( segment->GetAngle() > 0 );
if( clockwise && newAngle < 0.0 )
newAngle += 3600.0;
else if( !clockwise && newAngle > 0.0 )
newAngle -= 3600.0;
segment->SetAngle( newAngle );
}
break;
}
case S_CIRCLE:
{
const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
{
wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
segment->Move( moveVector );
}
else
{
segment->SetEnd( wxPoint( end.x, end.y ) );
}
break;
}
default: // suppress warnings
break;
}
// Update relative coordinates for module edges
if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
edge->SetLocalCoord();
break;
}
case PCB_ZONE_AREA_T:
{
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
zone->ClearFilledPolysList();
CPolyLine* outline = zone->Outline();
for( int i = 0; i < outline->GetCornersCount(); ++i )
{
VECTOR2I point = m_editPoints->Point( i ).GetPosition();
outline->SetX( i, point.x );
outline->SetY( i, point.y );
//.........这里部分代码省略.........
示例4: segment_startpoint
void DXF2BRD_CONVERTER::insertArc( const wxRealPoint& aSegStart, const wxRealPoint& aSegEnd,
double aBulge, int aWidth )
{
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
wxPoint segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) );
// ensure aBulge represents an angle from +/- ( 0 .. approx 359.8 deg )
if( aBulge < -2000.0 )
aBulge = -2000.0;
else if( aBulge > 2000.0 )
aBulge = 2000.0;
double ang = 4.0 * atan( aBulge );
// reflect the Y values to put everything in a RHCS
wxRealPoint sp( aSegStart.x, -aSegStart.y );
wxRealPoint ep( aSegEnd.x, -aSegEnd.y );
// angle from end->start
double offAng = atan2( ep.y - sp.y, ep.x - sp.x );
// length of subtended segment = 1/2 distance between the 2 points
double d = 0.5 * sqrt( (sp.x - ep.x) * (sp.x - ep.x) + (sp.y - ep.y) * (sp.y - ep.y) );
// midpoint of the subtended segment
double xm = ( sp.x + ep.x ) * 0.5;
double ym = ( sp.y + ep.y ) * 0.5;
double radius = d / sin( ang * 0.5 );
if( radius < 0.0 )
radius = -radius;
// calculate the height of the triangle with base d and hypotenuse r
double dh2 = radius * radius - d * d;
// this should only ever happen due to rounding errors when r == d
if( dh2 < 0.0 )
dh2 = 0.0;
double h = sqrt( dh2 );
if( ang < 0.0 )
offAng -= M_PI_2;
else
offAng += M_PI_2;
// for angles greater than 180 deg we need to flip the
// direction in which the arc center is found relative
// to the midpoint of the subtended segment.
if( ang < -M_PI )
offAng += M_PI;
else if( ang > M_PI )
offAng -= M_PI;
// center point
double cx = h * cos( offAng ) + xm;
double cy = h * sin( offAng ) + ym;
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
segm->SetShape( S_ARC );
segm->SetCenter( wxPoint( Millimeter2iu( cx ), Millimeter2iu( -cy ) ) );
if( ang < 0.0 )
{
segm->SetArcStart( wxPoint( Millimeter2iu( ep.x ), Millimeter2iu( -ep.y ) ) );
segm->SetAngle( RAD2DECIDEG( ang ) );
}
else
{
segm->SetArcStart( wxPoint( Millimeter2iu( sp.x ), Millimeter2iu( -sp.y ) ) );
segm->SetAngle( RAD2DECIDEG( -ang ) );
}
segm->SetWidth( aWidth );
m_newItemsList.push_back( segm );
return;
}