本文整理汇总了C++中DRAWSEGMENT::GetEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ DRAWSEGMENT::GetEnd方法的具体用法?C++ DRAWSEGMENT::GetEnd怎么用?C++ DRAWSEGMENT::GetEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DRAWSEGMENT
的用法示例。
在下文中一共展示了DRAWSEGMENT::GetEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Begin_DrawSegment
/* Initialize the drawing of a segment of type other than trace.
*/
DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC )
{
int lineWidth;
DRAWSEGMENT* DrawItem;
lineWidth = GetDesignSettings().GetLineThickness( GetActiveLayer() );
if( Segment == NULL ) // Create new segment.
{
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->SetFlags( IS_NEW );
Segment->SetLayer( GetActiveLayer() );
Segment->SetWidth( lineWidth );
Segment->SetShape( shape );
Segment->SetAngle( 900 );
Segment->SetStart( GetCrossHairPosition() );
Segment->SetEnd( GetCrossHairPosition() );
m_canvas->SetMouseCapture( DrawSegment, Abort_EditEdge );
}
else
{
// The ending point coordinate Segment->m_End was updated by the function
// DrawSegment() called on a move mouse event during the segment creation
if( Segment->GetStart() != Segment->GetEnd() )
{
if( Segment->GetShape() == S_SEGMENT )
{
SaveCopyInUndoList( Segment, UR_NEW );
GetBoard()->Add( Segment );
OnModify();
Segment->ClearFlags();
Segment->Draw( m_canvas, DC, GR_OR );
DrawItem = Segment;
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->SetFlags( IS_NEW );
Segment->SetLayer( DrawItem->GetLayer() );
Segment->SetWidth( lineWidth );
Segment->SetShape( DrawItem->GetShape() );
Segment->SetType( DrawItem->GetType() );
Segment->SetAngle( DrawItem->GetAngle() );
Segment->SetStart( DrawItem->GetEnd() );
Segment->SetEnd( DrawItem->GetEnd() );
DrawSegment( m_canvas, DC, wxDefaultPosition, false );
}
else
{
End_Edge( Segment, DC );
Segment = NULL;
}
}
}
return Segment;
}
示例2: DrawLine
int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
{
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
boost::optional<VECTOR2D> startingPoint;
BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
m_frame->SetToolID( m_editModules ? ID_MODEDIT_LINE_TOOL : ID_PCB_ADD_LINE_BUTT,
wxCURSOR_PENCIL, _( "Add graphic line" ) );
while( drawSegment( S_SEGMENT, line, startingPoint ) )
{
if( line )
{
commit.Add( line );
commit.Push( _( "Draw a line segment" ) );
startingPoint = line->GetEnd();
}
else
{
startingPoint = boost::none;
}
line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
}
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
}
示例3: DrawLine
int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
{
boost::optional<VECTOR2D> startingPoint;
if( m_editModules )
{
m_frame->SetToolID( ID_MODEDIT_LINE_TOOL, wxCURSOR_PENCIL, _( "Add graphic line" ) );
EDGE_MODULE* line = new EDGE_MODULE( m_board->m_Modules );
while( drawSegment( S_SEGMENT, reinterpret_cast<DRAWSEGMENT*&>( line ), startingPoint ) )
{
if( line )
{
m_frame->OnModify();
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_MODEDIT );
line->SetParent( m_board->m_Modules );
line->SetLocalCoord();
m_board->m_Modules->GraphicalItems().PushFront( line );
startingPoint = line->GetEnd();
}
else
{
startingPoint = boost::none;
}
line = new EDGE_MODULE( m_board->m_Modules );
}
}
else // !m_editModules case
{
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
DRAWSEGMENT* line = new DRAWSEGMENT;
while( drawSegment( S_SEGMENT, line, startingPoint ) )
{
if( line )
{
m_board->Add( line );
m_frame->OnModify();
m_frame->SaveCopyInUndoList( line, UR_NEW );
startingPoint = line->GetEnd();
}
else
{
startingPoint = boost::none;
}
line = new DRAWSEGMENT;
}
}
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
}
示例4: CreateBoardSection
/* Creates the section $BOARD.
* We output here only the board perimeter
*/
static void CreateBoardSection( FILE* aFile, BOARD* aPcb )
{
fputs( "$BOARD\n", aFile );
// Extract the board edges
for( EDA_ITEM* drawing = aPcb->m_Drawings; drawing != 0;
drawing = drawing->Next() )
{
if( drawing->Type() == PCB_LINE_T )
{
DRAWSEGMENT* drawseg = static_cast<DRAWSEGMENT*>( drawing );
if( drawseg->GetLayer() == Edge_Cuts )
{
// XXX GenCAD supports arc boundaries but I've seen nothing that reads them
fprintf( aFile, "LINE %g %g %g %g\n",
MapXTo( drawseg->GetStart().x ), MapYTo( drawseg->GetStart().y ),
MapXTo( drawseg->GetEnd().x ), MapYTo( drawseg->GetEnd().y ) );
}
}
}
fputs( "$ENDBOARD\n\n", aFile );
}
示例5: 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 );
}
示例6: findPoint
/**
* Searches for a DRAWSEGMENT matching a given end point or start point in a list, and
* if found, removes it from the TYPE_COLLECTOR and returns it, else returns NULL.
* @param aPoint The starting or ending point to search for.
* @param aList The list to remove from.
* @param aLimit is the distance from \a aPoint that still constitutes a valid find.
* @return DRAWSEGMENT* - The first DRAWSEGMENT that has a start or end point matching
* aPoint, otherwise NULL if none.
*/
static DRAWSEGMENT* findPoint( const wxPoint& aPoint, std::vector< DRAWSEGMENT* >& aList, unsigned aLimit )
{
unsigned min_d = INT_MAX;
int ndx_min = 0;
// find the point closest to aPoint and perhaps exactly matching aPoint.
for( size_t i = 0; i < aList.size(); ++i )
{
DRAWSEGMENT* graphic = aList[i];
unsigned d;
switch( graphic->GetShape() )
{
case S_ARC:
if( aPoint == graphic->GetArcStart() || aPoint == graphic->GetArcEnd() )
{
aList.erase( aList.begin() + i );
return graphic;
}
d = close_ness( aPoint, graphic->GetArcStart() );
if( d < min_d )
{
min_d = d;
ndx_min = i;
}
d = close_ness( aPoint, graphic->GetArcEnd() );
if( d < min_d )
{
min_d = d;
ndx_min = i;
}
break;
default:
if( aPoint == graphic->GetStart() || aPoint == graphic->GetEnd() )
{
aList.erase( aList.begin() + i );
return graphic;
}
d = close_ness( aPoint, graphic->GetStart() );
if( d < min_d )
{
min_d = d;
ndx_min = i;
}
d = close_ness( aPoint, graphic->GetEnd() );
if( d < min_d )
{
min_d = d;
ndx_min = i;
}
}
}
if( min_d <= aLimit )
{
DRAWSEGMENT* graphic = aList[ndx_min];
aList.erase( aList.begin() + ndx_min );
return graphic;
}
return NULL;
}
示例7: initDlg
void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( )
/**************************************************************************/
/* Initialize messages and values in text control,
* according to the item parameters values
*/
{
SetFocus();
m_StandardButtonsSizerOK->SetDefault();
// Set unit symbol
wxStaticText * texts_unit[] =
{
m_StartPointXUnit,
m_StartPointYUnit,
m_EndPointXUnit,
m_EndPointYUnit,
m_ThicknessTextUnit,
m_DefaulThicknessTextUnit,
NULL
};
for( int ii = 0; ; ii++ )
{
if( texts_unit[ii] == NULL )
break;
texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() );
}
wxString msg;
// Change texts according to the segment shape:
switch ( m_Item->GetShape() )
{
case S_CIRCLE:
m_StartPointXLabel->SetLabel(_("Center X"));
m_StartPointYLabel->SetLabel(_("Center Y"));
m_EndPointXLabel->SetLabel(_("Point X"));
m_EndPointYLabel->SetLabel(_("Point Y"));
m_Angle_Text->Show(false);
m_Angle_Ctrl->Show(false);
m_AngleUnit->Show(false);
break;
case S_ARC:
m_StartPointXLabel->SetLabel(_("Center X"));
m_StartPointYLabel->SetLabel(_("Center Y"));
m_EndPointXLabel->SetLabel(_("Start Point X"));
m_EndPointYLabel->SetLabel(_("Start Point Y"));
msg << m_Item->GetAngle();
m_Angle_Ctrl->SetValue(msg);
break;
default:
m_Angle_Text->Show(false);
m_Angle_Ctrl->Show(false);
m_AngleUnit->Show(false);
break;
}
PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->GetStart().x,
m_parent->GetInternalUnits() );
PutValueInLocalUnits( *m_Center_StartYCtrl, m_Item->GetStart().y,
m_parent->GetInternalUnits() );
PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_Item->GetEnd().x,
m_parent->GetInternalUnits() );
PutValueInLocalUnits( *m_EndY_Ctrl, m_Item->GetEnd().y,
m_parent->GetInternalUnits() );
PutValueInLocalUnits( *m_ThicknessCtrl, m_Item->GetWidth(),
m_parent->GetInternalUnits() );
int thickness;
if( m_Item->GetLayer() == EDGE_N )
thickness = m_brdSettings.m_EdgeSegmentWidth;
else
thickness = m_brdSettings.m_DrawSegmentWidth;
PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness,
m_parent->GetInternalUnits() );
for( int layer=FIRST_NO_COPPER_LAYER; layer <= LAST_NO_COPPER_LAYER; ++layer )
{
m_LayerSelectionCtrl->Append( m_parent->GetBoard()->GetLayerName( layer ) );
}
int layer = m_Item->GetLayer();
// Control:
if ( layer < FIRST_NO_COPPER_LAYER )
layer = FIRST_NO_COPPER_LAYER;
if ( layer > LAST_NO_COPPER_LAYER )
layer = LAST_NO_COPPER_LAYER;
m_LayerSelectionCtrl->SetSelection( layer - FIRST_NO_COPPER_LAYER );
}
示例8: idf_export_outline
/**
* Function idf_export_outline
* retrieves line segment information from the edge layer and compiles
* the data into a form which can be output as an IDFv3 compliant
* BOARD_OUTLINE section.
*/
static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
{
double scale = aIDFBoard.GetUserScale();
DRAWSEGMENT* graphic; // KiCad graphical item
IDF_POINT sp, ep; // start and end points from KiCad item
std::list< IDF_SEGMENT* > lines; // IDF intermediate form of KiCad graphical item
IDF_OUTLINE* outline = NULL; // graphical items forming an outline or cutout
// NOTE: IMPLEMENTATION
// If/when component cutouts are allowed, we must implement them separately. Cutouts
// must be added to the board outline section and not to the Other Outline section.
// The module cutouts should be handled via the idf_export_module() routine.
double offX, offY;
aIDFBoard.GetUserOffset( offX, offY );
// Retrieve segments and arcs from the board
for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
{
if( item->Type() != PCB_LINE_T || item->GetLayer() != Edge_Cuts )
continue;
graphic = (DRAWSEGMENT*) item;
switch( graphic->GetShape() )
{
case S_SEGMENT:
{
if( ( graphic->GetStart().x == graphic->GetEnd().x )
&& ( graphic->GetStart().y == graphic->GetEnd().y ) )
break;
sp.x = graphic->GetStart().x * scale + offX;
sp.y = -graphic->GetStart().y * scale + offY;
ep.x = graphic->GetEnd().x * scale + offX;
ep.y = -graphic->GetEnd().y * scale + offY;
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep );
if( seg )
lines.push_back( seg );
}
break;
case S_ARC:
{
if( ( graphic->GetCenter().x == graphic->GetArcStart().x )
&& ( graphic->GetCenter().y == graphic->GetArcStart().y ) )
break;
sp.x = graphic->GetCenter().x * scale + offX;
sp.y = -graphic->GetCenter().y * scale + offY;
ep.x = graphic->GetArcStart().x * scale + offX;
ep.y = -graphic->GetArcStart().y * scale + offY;
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep, -graphic->GetAngle() / 10.0, true );
if( seg )
lines.push_back( seg );
}
break;
case S_CIRCLE:
{
if( graphic->GetRadius() == 0 )
break;
sp.x = graphic->GetCenter().x * scale + offX;
sp.y = -graphic->GetCenter().y * scale + offY;
ep.x = sp.x - graphic->GetRadius() * scale;
ep.y = sp.y;
// Circles must always have an angle of +360 deg. to appease
// quirky MCAD implementations of IDF.
IDF_SEGMENT* seg = new IDF_SEGMENT( sp, ep, 360.0, true );
if( seg )
lines.push_back( seg );
}
break;
default:
break;
}
}
// if there is no outline then use the bounding box
if( lines.empty() )
{
goto UseBoundingBox;
}
// get the board outline and write it out
// note: we do not use a try/catch block here since we intend
// to simply ignore unclosed loops and continue processing
//.........这里部分代码省略.........
示例9: 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 );
}
}
//.........这里部分代码省略.........
示例10: genPlacementRoutingMatrix
int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel )
{
wxString msg;
RoutingMatrix.UnInitRoutingMatrix();
EDA_RECT bbox = aBrd->ComputeBoundingBox( true );
if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
{
DisplayError( NULL, _( "No PCB edge found, unknown board size!" ) );
return 0;
}
RoutingMatrix.ComputeMatrixSize( aBrd, true );
int nbCells = RoutingMatrix.m_Ncols * RoutingMatrix.m_Nrows;
messagePanel->EraseMsgBox();
msg.Printf( wxT( "%d" ), RoutingMatrix.m_Ncols );
messagePanel->SetMessage( 1, _( "Cols" ), msg, GREEN );
msg.Printf( wxT( "%d" ), RoutingMatrix.m_Nrows );
messagePanel->SetMessage( 7, _( "Lines" ), msg, GREEN );
msg.Printf( wxT( "%d" ), nbCells );
messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW );
// Choose the number of board sides.
RoutingMatrix.m_RoutingLayersCount = 2;
RoutingMatrix.InitRoutingMatrix();
// Display memory usage.
msg.Printf( wxT( "%d" ), RoutingMatrix.m_MemSize / 1024 );
messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN );
g_Route_Layer_BOTTOM = LAYER_N_FRONT;
if( RoutingMatrix.m_RoutingLayersCount > 1 )
g_Route_Layer_BOTTOM = LAYER_N_BACK;
g_Route_Layer_TOP = LAYER_N_FRONT;
// Place the edge layer segments
TRACK TmpSegm( NULL );
TmpSegm.SetLayer( UNDEFINED_LAYER );
TmpSegm.SetNet( -1 );
TmpSegm.SetWidth( RoutingMatrix.m_GridRouting / 2 );
EDA_ITEM* PtStruct = aBrd->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
DRAWSEGMENT* DrawSegm;
switch( PtStruct->Type() )
{
case PCB_LINE_T:
DrawSegm = (DRAWSEGMENT*) PtStruct;
if( DrawSegm->GetLayer() != EDGE_N )
break;
TmpSegm.SetStart( DrawSegm->GetStart() );
TmpSegm.SetEnd( DrawSegm->GetEnd() );
TmpSegm.SetShape( DrawSegm->GetShape() );
TmpSegm.m_Param = DrawSegm->GetAngle();
TraceSegmentPcb( &TmpSegm, HOLE | CELL_is_EDGE,
RoutingMatrix.m_GridRouting, WRITE_CELL );
break;
case PCB_TEXT_T:
default:
break;
}
}
// Mark cells of the routing matrix to CELL_is_ZONE
// (i.e. availlable cell to place a module )
// Init a starting point of attachment to the area.
RoutingMatrix.OrCell( RoutingMatrix.m_Nrows / 2, RoutingMatrix.m_Ncols / 2,
BOTTOM, CELL_is_ZONE );
// find and mark all other availlable cells:
for( int ii = 1; ii != 0; )
ii = propagate();
// Initialize top layer. to the same value as the bottom layer
if( RoutingMatrix.m_BoardSide[TOP] )
memcpy( RoutingMatrix.m_BoardSide[TOP], RoutingMatrix.m_BoardSide[BOTTOM],
nbCells * sizeof(MATRIX_CELL) );
return 1;
}
示例11: PlaceCells
/**
* Function PlaceCells
* Initialize the matrix routing by setting obstacles for each occupied cell
* a cell set to HOLE is an obstacle for tracks and vias
* a cell set to VIA_IMPOSSIBLE is an obstacle for vias only.
* a cell set to CELL_is_EDGE is a frontier.
* Tracks and vias having the same net code as net_code are skipped
* (htey do not are obstacles)
*
* For single-sided Routing 1:
* BOTTOM side is used, and Route_Layer_BOTTOM = Route_Layer_TOP
*
* If flag == FORCE_PADS: all pads will be put in matrix as obstacles.
*/
void PlaceCells( BOARD* aPcb, int net_code, int flag )
{
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
int marge, via_marge;
LAYER_MSK layerMask;
// use the default NETCLASS?
NETCLASS* nc = aPcb->m_NetClasses.GetDefault();
int trackWidth = nc->GetTrackWidth();
int clearance = nc->GetClearance();
int viaSize = nc->GetViaDiameter();
marge = clearance + (trackWidth / 2);
via_marge = clearance + (viaSize / 2);
// Place PADS on matrix routing:
for( unsigned i = 0; i < aPcb->GetPadCount(); ++i )
{
D_PAD* pad = aPcb->GetPad( i );
if( net_code != pad->GetNet() || (flag & FORCE_PADS) )
{
::PlacePad( pad, HOLE, marge, WRITE_CELL );
}
::PlacePad( pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
}
// Place outlines of modules on matrix routing, if they are on a copper layer
// or on the edge layer
TRACK tmpSegm( NULL ); // A dummy track used to create segments.
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* edge = (EDGE_MODULE*) item;
tmpSegm.SetLayer( edge->GetLayer() );
if( tmpSegm.GetLayer() == EDGE_N )
tmpSegm.SetLayer( UNDEFINED_LAYER );
tmpSegm.SetStart( edge->GetStart() );
tmpSegm.SetEnd( edge->GetEnd() );
tmpSegm.SetShape( edge->GetShape() );
tmpSegm.SetWidth( edge->GetWidth() );
tmpSegm.m_Param = edge->GetAngle();
tmpSegm.SetNet( -1 );
TraceSegmentPcb( &tmpSegm, HOLE, marge, WRITE_CELL );
TraceSegmentPcb( &tmpSegm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
}
break;
default:
break;
}
}
}
// Place board outlines and texts on copper layers:
for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_LINE_T:
{
DRAWSEGMENT* DrawSegm;
int type_cell = HOLE;
DrawSegm = (DRAWSEGMENT*) item;
tmpSegm.SetLayer( DrawSegm->GetLayer() );
if( DrawSegm->GetLayer() == EDGE_N )
{
tmpSegm.SetLayer( UNDEFINED_LAYER );
type_cell |= CELL_is_EDGE;
}
tmpSegm.SetStart( DrawSegm->GetStart() );
//.........这里部分代码省略.........
示例12: initDlg
void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg()
{
m_StandardButtonsSizerOK->SetDefault();
// Set unit symbol
wxStaticText* texts_unit[] =
{
m_StartPointXUnit,
m_StartPointYUnit,
m_EndPointXUnit,
m_EndPointYUnit,
m_ThicknessTextUnit,
m_DefaulThicknessTextUnit,
NULL
};
for( int ii = 0; ; ii++ )
{
if( texts_unit[ii] == NULL )
break;
texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() );
}
wxString msg;
// Change texts according to the segment shape:
switch( m_item->GetShape() )
{
case S_CIRCLE:
SetTitle( _( "Circle Properties" ) );
m_StartPointXLabel->SetLabel( _( "Center X" ) );
m_StartPointYLabel->SetLabel( _( "Center Y" ) );
m_EndPointXLabel->SetLabel( _( "Point X" ) );
m_EndPointYLabel->SetLabel( _( "Point Y" ) );
m_Angle_Text->Show( false );
m_Angle_Ctrl->Show( false );
m_AngleUnit->Show( false );
break;
case S_ARC:
SetTitle( _( "Arc Properties" ) );
m_StartPointXLabel->SetLabel( _( "Center X" ) );
m_StartPointYLabel->SetLabel( _( "Center Y" ) );
m_EndPointXLabel->SetLabel( _( "Start Point X" ) );
m_EndPointYLabel->SetLabel( _( "Start Point Y" ) );
// Here the angle is a double, but the UI is still working with integers.
msg << int( m_item->GetAngle() );
m_Angle_Ctrl->SetValue( msg );
break;
case S_SEGMENT:
SetTitle( _( "Line Segment Properties" ) );
// Fall through.
default:
m_Angle_Text->Show( false );
m_Angle_Ctrl->Show( false );
m_AngleUnit->Show( false );
break;
}
PutValueInLocalUnits( *m_Center_StartXCtrl, m_item->GetStart().x );
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 );
PutValueInLocalUnits( *m_ThicknessCtrl, m_item->GetWidth() );
int thickness;
if( m_item->GetLayer() == Edge_Cuts )
thickness = m_brdSettings.m_EdgeSegmentWidth;
else
thickness = m_brdSettings.m_DrawSegmentWidth;
PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness );
// Configure the layers list selector
m_LayerSelectionCtrl->SetLayersHotkeys( false );
m_LayerSelectionCtrl->SetLayerSet( LSET::AllCuMask() );
m_LayerSelectionCtrl->SetBoardFrame( m_parent );
m_LayerSelectionCtrl->Resync();
if( m_LayerSelectionCtrl->SetLayerSelection( m_item->GetLayer() ) < 0 )
{
wxMessageBox( _( "This item was on an unknown layer.\n"
"It has been moved to the drawings layer. Please fix it." ) );
m_LayerSelectionCtrl->SetLayerSelection( Dwgs_User );
}
}
示例13: computeAnchors
void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
{
VECTOR2I origin;
switch( aItem->Type() )
{
case PCB_MODULE_T:
{
MODULE* mod = static_cast<MODULE*>( aItem );
addAnchor( mod->GetPosition(), ORIGIN | SNAPPABLE, mod );
for( D_PAD* pad = mod->Pads(); pad; pad = pad->Next() )
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
break;
}
case PCB_PAD_T:
{
D_PAD* pad = static_cast<D_PAD*>( aItem );
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
break;
}
case PCB_MODULE_EDGE_T:
case PCB_LINE_T:
{
DRAWSEGMENT* dseg = static_cast<DRAWSEGMENT*>( aItem );
VECTOR2I start = dseg->GetStart();
VECTOR2I end = dseg->GetEnd();
//LAYER_ID layer = dseg->GetLayer();
switch( dseg->GetShape() )
{
case S_CIRCLE:
{
int r = ( start - end ).EuclideanNorm();
addAnchor( start, ORIGIN | SNAPPABLE, dseg );
addAnchor( start + VECTOR2I( -r, 0 ), OUTLINE | SNAPPABLE, dseg );
addAnchor( start + VECTOR2I( r, 0 ), OUTLINE | SNAPPABLE, dseg );
addAnchor( start + VECTOR2I( 0, -r ), OUTLINE | SNAPPABLE, dseg );
addAnchor( start + VECTOR2I( 0, r ), OUTLINE | SNAPPABLE, dseg );
break;
}
case S_ARC:
{
origin = dseg->GetCenter();
addAnchor( dseg->GetArcStart(), CORNER | SNAPPABLE, dseg );
addAnchor( dseg->GetArcEnd(), CORNER | SNAPPABLE, dseg );
addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
break;
}
case S_SEGMENT:
{
origin.x = start.x + ( start.x - end.x ) / 2;
origin.y = start.y + ( start.y - end.y ) / 2;
addAnchor( start, CORNER | SNAPPABLE, dseg );
addAnchor( end, CORNER | SNAPPABLE, dseg );
addAnchor( origin, ORIGIN, dseg );
break;
}
default:
{
origin = dseg->GetStart();
addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
break;
}
}
break;
}
case PCB_TRACE_T:
{
TRACK* track = static_cast<TRACK*>( aItem );
VECTOR2I start = track->GetStart();
VECTOR2I end = track->GetEnd();
origin.x = start.x + ( start.x - end.x ) / 2;
origin.y = start.y + ( start.y - end.y ) / 2;
addAnchor( start, CORNER | SNAPPABLE, track );
addAnchor( end, CORNER | SNAPPABLE, track );
addAnchor( origin, ORIGIN, track);
break;
}
case PCB_VIA_T:
addAnchor( aItem->GetPosition(), CORNER | SNAPPABLE, aItem );
break;
case PCB_ZONE_AREA_T:
{
const CPolyLine* outline = static_cast<const ZONE_CONTAINER*>( aItem )->Outline();
int cornersCount = outline->GetCornersCount();
SHAPE_LINE_CHAIN lc;
//.........这里部分代码省略.........
示例14: ConvertOutlineToPolygon
/**
* Function ConvertOutlineToPolygon
* build a polygon (with holes) from a DRAWSEGMENT list, which is expected to be
* a outline, therefore a closed main outline with perhaps closed inner outlines.
* These closed inner outlines are considered as holes in the main outline
* @param aSegList the initial list of drawsegments (only lines, circles and arcs).
* @param aPolygons will contain the complex polygon.
* @param aTolerance is the max distance between points that is still accepted as connected (internal units)
* @param aErrorText is a wxString to return error message.
* @param aErrorLocation is the optional position of the error in the outline
*/
bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SET& aPolygons,
wxString* aErrorText, unsigned int aTolerance, wxPoint* aErrorLocation )
{
if( aSegList.size() == 0 )
return true;
wxString msg;
// Make a working copy of aSegList, because the list is modified during calculations
std::vector< DRAWSEGMENT* > segList = aSegList;
DRAWSEGMENT* graphic;
wxPoint prevPt;
// Find edge point with minimum x, this should be in the outer polygon
// which will define the perimeter Edge.Cuts polygon.
wxPoint xmin = wxPoint( INT_MAX, 0 );
int xmini = 0;
for( size_t i = 0; i < segList.size(); i++ )
{
graphic = (DRAWSEGMENT*) segList[i];
switch( graphic->GetShape() )
{
case S_SEGMENT:
{
if( graphic->GetStart().x < xmin.x )
{
xmin = graphic->GetStart();
xmini = i;
}
if( graphic->GetEnd().x < xmin.x )
{
xmin = graphic->GetEnd();
xmini = i;
}
}
break;
case S_ARC:
// Freerouter does not yet understand arcs, so approximate
// an arc with a series of short lines and put those
// line segments into the !same! PATH.
{
wxPoint pstart = graphic->GetArcStart();
wxPoint center = graphic->GetCenter();
double angle = -graphic->GetAngle();
double radius = graphic->GetRadius();
int steps = GetArcToSegmentCount( radius, ARC_LOW_DEF, angle / 10.0 );
wxPoint pt;
for( int step = 1; step<=steps; ++step )
{
double rotation = ( angle * step ) / steps;
pt = pstart;
RotatePoint( &pt, center, rotation );
if( pt.x < xmin.x )
{
xmin = pt;
xmini = i;
}
}
}
break;
case S_CIRCLE:
{
wxPoint pt = graphic->GetCenter();
// pt has minimum x point
pt.x -= graphic->GetRadius();
// when the radius <= 0, this is a mal-formed circle. Skip it
if( graphic->GetRadius() > 0 && pt.x < xmin.x )
{
xmin = pt;
xmini = i;
}
}
break;
case S_CURVE:
{
graphic->RebuildBezierToSegmentsPointsList( graphic->GetWidth() );
//.........这里部分代码省略.........
示例15: drawZone
int DRAWING_TOOL::drawZone( bool aKeepout )
{
ZONE_CONTAINER* zone = NULL;
DRAWSEGMENT line45;
DRAWSEGMENT* helperLine = NULL; // we will need more than one helper line
// if one day it is possible to draw zones in the footprint editor,
// then hereby I'm letting you know that this tool does not handle UR_MODEDIT undo yet
assert( !m_editModules );
// 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();
VECTOR2I origin;
int numPoints = 0;
bool direction45 = false; // 45 degrees only mode
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
bool updatePreview = false; // should preview be updated
VECTOR2I cursorPos = m_controls->GetCursorPosition();
// Enable 45 degrees lines only mode by holding control
if( direction45 != ( evt->Modifier( MD_CTRL ) && numPoints > 0 ) )
{
direction45 = evt->Modifier( MD_CTRL );
if( direction45 )
{
preview.Add( &line45 );
make45DegLine( helperLine, &line45 );
}
else
{
preview.Remove( &line45 );
helperLine->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
}
updatePreview = true;
}
if( evt->IsCancel() || evt->IsActivate() )
{
if( numPoints > 0 ) // cancel the current zone
{
delete zone;
zone = NULL;
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
if( direction45 )
{
preview.Remove( &line45 );
direction45 = false;
}
preview.FreeItems();
updatePreview = true;
numPoints = 0;
}
else // there is no zone currently drawn - just stop the tool
break;
if( evt->IsActivate() ) // now finish unconditionally
break;
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{
// Check if it is double click / closing line (so we have to finish the zone)
if( evt->IsDblClick( BUT_LEFT ) || ( numPoints > 0 && cursorPos == origin ) )
{
if( numPoints > 2 ) // valid zone consists of more than 2 points
{
assert( zone->GetNumCorners() > 2 );
// Finish the zone
if( direction45 )
zone->AppendCorner( cursorPos == origin ? line45.GetStart() : line45.GetEnd() );
zone->Outline()->CloseLastContour();
zone->Outline()->RemoveNullSegments();
m_board->Add( zone );
m_view->Add( zone );
if( !aKeepout )
static_cast<PCB_EDIT_FRAME*>( m_frame )->Fill_Zone( zone );
zone->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_board->GetRatsnest()->Update( zone );
//.........这里部分代码省略.........