本文整理汇总了C++中DRAWSEGMENT::SetStart方法的典型用法代码示例。如果您正苦于以下问题:C++ DRAWSEGMENT::SetStart方法的具体用法?C++ DRAWSEGMENT::SetStart怎么用?C++ DRAWSEGMENT::SetStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DRAWSEGMENT
的用法示例。
在下文中一共展示了DRAWSEGMENT::SetStart方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlotPcbTarget
void BRDITEMS_PLOTTER::PlotPcbTarget( PCB_TARGET* aMire )
{
int dx1, dx2, dy1, dy2, radius;
if( !m_layerMask[aMire->GetLayer()] )
return;
m_plotter->SetColor( getColor( aMire->GetLayer() ) );
DRAWSEGMENT draw;
draw.SetShape( S_CIRCLE );
draw.SetWidth( ( GetMode() == LINE ) ? -1 : aMire->GetWidth() );
draw.SetLayer( aMire->GetLayer() );
draw.SetStart( aMire->GetPosition() );
radius = aMire->GetSize() / 3;
if( aMire->GetShape() ) // shape X
radius = aMire->GetSize() / 2;
// Draw the circle
draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ));
PlotDrawSegment( &draw );
draw.SetShape( S_SEGMENT );
radius = aMire->GetSize() / 2;
dx1 = radius;
dy1 = 0;
dx2 = 0;
dy2 = radius;
if( aMire->GetShape() ) // Shape X
{
dx1 = dy1 = radius;
dx2 = dx1;
dy2 = -dy1;
}
wxPoint mirePos( aMire->GetPosition() );
// Draw the X or + shape:
draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ));
draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ));
PlotDrawSegment( &draw );
draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ));
draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ));
PlotDrawSegment( &draw );
}
示例2: start
void DXF2BRD_CONVERTER::addLine( const DRW_Line& aData )
{
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
wxPoint start( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
segm->SetStart( start );
wxPoint end( mapX( aData.secPoint.x ), mapY( aData.secPoint.y ) );
segm->SetEnd( end );
segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
m_newItemsList.push_back( segm );
}
示例3: DRAWSEGMENT
/*
* Import line entities.
*/
void DXF2BRD_CONVERTER::addLine( const DRW_Line& data )
{
DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );
segm->SetLayer( m_brdLayer );
wxPoint start( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetStart( start );
wxPoint end( mapX( data.secPoint.x ), mapY( data.secPoint.y ) );
segm->SetEnd( end );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
appendToBoard( segm );
}
示例4: segment_endpoint
void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData )
{
// Currently, Pcbnew does not know polylines, for boards.
// So we have to convert a polyline to a set of segments.
// Obviously, the z coordinate is ignored
wxPoint polyline_startpoint;
wxPoint segment_startpoint;
for( unsigned ii = 0; ii < aData.vertlist.size(); ii++ )
{
DRW_Vertex* vertex = aData.vertlist[ii];
if( ii == 0 )
{
segment_startpoint.x = mapX( vertex->basePoint.x );
segment_startpoint.y = mapY( vertex->basePoint.y );
polyline_startpoint = segment_startpoint;
continue;
}
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
new DRAWSEGMENT;
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
segm->SetStart( segment_startpoint );
wxPoint segment_endpoint( mapX( vertex->basePoint.x ), mapY( vertex->basePoint.y ) );
segm->SetEnd( segment_endpoint );
segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness
: aData.thickness ) );
m_newItemsList.push_back( segm );
segment_startpoint = segment_endpoint;
}
// Polyline flags bit 0 indicates closed (1) or open (0) polyline
if( aData.flags & 1 )
{
DRAWSEGMENT* closing_segm = ( m_useModuleItems ) ?
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
new DRAWSEGMENT;
closing_segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
closing_segm->SetStart( segment_startpoint );
closing_segm->SetEnd( polyline_startpoint );
closing_segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness
: aData.thickness ) );
m_newItemsList.push_back( closing_segm );
}
}
示例5: segment_startpoint
void DXF2BRD_CONVERTER::insertLine( const wxRealPoint& aSegStart,
const wxRealPoint& aSegEnd, 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 ) );
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
segm->SetStart( segment_startpoint );
segm->SetEnd( segment_endpoint );
segm->SetWidth( aWidth );
m_newItemsList.push_back( segm );
return;
}
示例6: PlotDimension
void BRDITEMS_PLOTTER::PlotDimension( DIMENSION* aDim )
{
if( !m_layerMask[aDim->GetLayer()] )
return;
DRAWSEGMENT draw;
draw.SetWidth( (GetMode() == LINE) ? -1 : aDim->GetWidth() );
draw.SetLayer( aDim->GetLayer() );
EDA_COLOR_T color = aDim->GetBoard()->GetLayerColor( aDim->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
PlotTextePcb( &aDim->Text() );
draw.SetStart( aDim->m_crossBarO );
draw.SetEnd( aDim->m_crossBarF );
PlotDrawSegment( &draw );
draw.SetStart( aDim->m_featureLineGO);
draw.SetEnd( aDim->m_featureLineGF );
PlotDrawSegment( &draw );
draw.SetStart( aDim->m_featureLineDO );
draw.SetEnd( aDim->m_featureLineDF );
PlotDrawSegment( &draw );
draw.SetStart( aDim->m_crossBarF );
draw.SetEnd( aDim->m_arrowD1F );
PlotDrawSegment( &draw );
draw.SetStart( aDim->m_crossBarF );
draw.SetEnd( aDim->m_arrowD2F );
PlotDrawSegment( &draw );
draw.SetStart( aDim->m_crossBarO );
draw.SetEnd( aDim->m_arrowG1F );
PlotDrawSegment( &draw );
draw.SetStart( aDim->m_crossBarO );
draw.SetEnd( aDim->m_arrowG2F );
PlotDrawSegment( &draw );
}
示例7: Move_Segment
/*
* Redraw segment during cursor movement.
*/
static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
DRAWSEGMENT* segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
if( segment == NULL )
return;
if( aErase )
segment->Draw( aPanel, aDC, GR_XOR );
wxPoint delta;
delta = aPanel->GetParent()->GetCrossHairPosition() - s_LastPosition;
segment->SetStart( segment->GetStart() + delta );
segment->SetEnd( segment->GetEnd() + delta );
s_LastPosition = aPanel->GetParent()->GetCrossHairPosition();
segment->Draw( aPanel, aDC, GR_XOR );
}
示例8: addCorner
void POINT_EDITOR::addCorner( const VECTOR2I& aBreakPoint )
{
EDA_ITEM* item = m_editPoints->GetParent();
const SELECTION& selection = m_selectionTool->GetSelection();
if( item->Type() == PCB_ZONE_AREA_T )
{
getEditFrame<PCB_BASE_FRAME>()->OnModify();
getEditFrame<PCB_BASE_FRAME>()->SaveCopyInUndoList( selection.items, UR_CHANGED );
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
CPolyLine* outline = zone->Outline();
// Handle the last segment, so other segments can be easily handled in a loop
unsigned int nearestIdx = outline->GetCornersCount() - 1, nextNearestIdx = 0;
SEG side( VECTOR2I( outline->GetPos( nearestIdx ) ),
VECTOR2I( outline->GetPos( nextNearestIdx ) ) );
unsigned int nearestDist = side.Distance( aBreakPoint );
for( int i = 0; i < outline->GetCornersCount() - 1; ++i )
{
side = SEG( VECTOR2I( outline->GetPos( i ) ), VECTOR2I( outline->GetPos( i + 1 ) ) );
unsigned int distance = side.Distance( aBreakPoint );
if( distance < nearestDist )
{
nearestDist = distance;
nearestIdx = i;
nextNearestIdx = i + 1;
}
}
// Find the point on the closest segment
VECTOR2I sideOrigin( outline->GetPos( nearestIdx ) );
VECTOR2I sideEnd( outline->GetPos( nextNearestIdx ) );
SEG nearestSide( sideOrigin, sideEnd );
VECTOR2I nearestPoint = nearestSide.NearestPoint( aBreakPoint );
// Do not add points that have the same coordinates as ones that already belong to polygon
// instead, add a point in the middle of the side
if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
nearestPoint = ( sideOrigin + sideEnd ) / 2;
outline->InsertCorner( nearestIdx, nearestPoint.x, nearestPoint.y );
}
else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
{
bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
frame->OnModify();
if( moduleEdge )
frame->SaveCopyInUndoList( getModel<BOARD>()->m_Modules, UR_MODEDIT );
else
frame->SaveCopyInUndoList( selection.items, UR_CHANGED );
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
if( segment->GetShape() == S_SEGMENT )
{
SEG seg( segment->GetStart(), segment->GetEnd() );
VECTOR2I nearestPoint = seg.NearestPoint( aBreakPoint );
// Move the end of the line to the break point..
segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
// and add another one starting from the break point
DRAWSEGMENT* newSegment;
if( moduleEdge )
{
EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
assert( segment->GetParent()->Type() == PCB_MODULE_T );
newSegment = new EDGE_MODULE( *edge );
edge->SetLocalCoord();
}
else
{
newSegment = new DRAWSEGMENT( *segment );
}
newSegment->ClearSelected();
newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
if( moduleEdge )
{
static_cast<EDGE_MODULE*>( newSegment )->SetLocalCoord();
getModel<BOARD>()->m_Modules->Add( newSegment );
}
else
{
getModel<BOARD>()->Add( newSegment );
}
getView()->Add( newSegment );
}
}
//.........这里部分代码省略.........
示例9: 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 );
//.........这里部分代码省略.........
示例10: drawArc
bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
{
bool clockwise = true; // drawing direction of the arc
double startAngle = 0.0f; // angle of the first arc line
VECTOR2I cursorPos = m_controls->GetCursorPosition();
DRAWSEGMENT helperLine;
helperLine.SetShape( S_SEGMENT );
helperLine.SetLayer( Dwgs_User );
helperLine.SetWidth( 1 );
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX::VIEW_GROUP preview( m_view );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
m_controls->SetSnapping( true );
Activate();
enum ARC_STEPS
{
SET_ORIGIN = 0,
SET_END,
SET_ANGLE,
FINISHED
};
int step = SET_ORIGIN;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
cursorPos = m_controls->GetCursorPosition();
if( evt->IsCancel() || evt->IsActivate() )
{
preview.Clear();
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
delete aGraphic;
aGraphic = NULL;
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
switch( step )
{
case SET_ORIGIN:
{
LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer;
if( IsCopperLayer( layer ) )
{
DisplayInfoMessage( NULL, _( "Graphic not allowed on Copper layers" ) );
--step;
}
else
{
// Init the new item attributes
aGraphic->SetShape( S_ARC );
aGraphic->SetAngle( 0.0 );
aGraphic->SetWidth( getSegmentWidth( layer ) );
aGraphic->SetCenter( wxPoint( cursorPos.x, cursorPos.y ) );
aGraphic->SetLayer( layer );
helperLine.SetStart( aGraphic->GetCenter() );
helperLine.SetEnd( aGraphic->GetCenter() );
preview.Add( aGraphic );
preview.Add( &helperLine );
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( true );
}
}
break;
case SET_END:
{
if( wxPoint( cursorPos.x, cursorPos.y ) != aGraphic->GetCenter() )
{
VECTOR2D startLine( aGraphic->GetArcStart() - aGraphic->GetCenter() );
startAngle = startLine.Angle();
aGraphic->SetArcStart( wxPoint( cursorPos.x, cursorPos.y ) );
}
else
--step; // one another chance to draw a proper arc
}
break;
case SET_ANGLE:
{
if( wxPoint( cursorPos.x, cursorPos.y ) != aGraphic->GetArcStart() && aGraphic->GetAngle() != 0 )
{
assert( aGraphic->GetArcStart() != aGraphic->GetArcEnd() );
assert( aGraphic->GetWidth() > 0 );
m_view->Add( aGraphic );
aGraphic->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
//.........这里部分代码省略.........
示例11: drawZone
//.........这里部分代码省略.........
{
preview.Remove( &line45 );
direction45 = false;
}
preview.FreeItems();
updatePreview = true;
}
else
{
if( numPoints == 0 ) // it's the first click
{
// Get the current default settings for zones
ZONE_SETTINGS zoneInfo = m_frame->GetZoneSettings();
zoneInfo.m_CurrentZone_Layer = m_frame->GetScreen()->m_Active_Layer;
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( true );
// Show options dialog
ZONE_EDIT_T dialogResult;
if( aKeepout )
dialogResult = InvokeKeepoutAreaEditor( m_frame, &zoneInfo );
else
{
if( IsCopperLayer( zoneInfo.m_CurrentZone_Layer ) )
dialogResult = InvokeCopperZonesEditor( m_frame, &zoneInfo );
else
dialogResult = InvokeNonCopperZonesEditor( m_frame, NULL, &zoneInfo );
}
if( dialogResult == ZONE_ABORT )
{
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
continue;
}
// Apply the selected settings
zone = new ZONE_CONTAINER( m_board );
zoneInfo.ExportSetting( *zone );
m_frame->GetGalCanvas()->SetTopLayer( zoneInfo.m_CurrentZone_Layer );
// Add the first point
zone->Outline()->Start( zoneInfo.m_CurrentZone_Layer,
cursorPos.x, cursorPos.y,
zone->GetHatchStyle() );
origin = cursorPos;
// Helper line represents the currently drawn line of the zone polygon
helperLine = new DRAWSEGMENT;
helperLine->SetShape( S_SEGMENT );
helperLine->SetWidth( 1 );
helperLine->SetLayer( zoneInfo.m_CurrentZone_Layer );
helperLine->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
helperLine->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
line45 = *helperLine;
preview.Add( helperLine );
}
else
{
zone->AppendCorner( helperLine->GetEnd() );
helperLine = new DRAWSEGMENT( *helperLine );
helperLine->SetStart( helperLine->GetEnd() );
preview.Add( helperLine );
}
++numPoints;
updatePreview = true;
}
}
else if( evt->IsMotion() && numPoints > 0 )
{
// 45 degree lines
if( direction45 )
make45DegLine( helperLine, &line45 );
else
helperLine->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
// Show a preview of the item
updatePreview = true;
}
if( updatePreview )
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
m_controls->ShowCursor( false );
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( &preview );
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
}