本文整理汇总了C++中DRAWSEGMENT::GetShape方法的典型用法代码示例。如果您正苦于以下问题:C++ DRAWSEGMENT::GetShape方法的具体用法?C++ DRAWSEGMENT::GetShape怎么用?C++ DRAWSEGMENT::GetShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DRAWSEGMENT
的用法示例。
在下文中一共展示了DRAWSEGMENT::GetShape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSegment
/* Redraw segment during cursor movement
*/
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
{
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
auto frame = (PCB_EDIT_FRAME*) ( aPanel->GetParent() );
if( Segment == NULL )
return;
auto displ_opts = (PCB_DISPLAY_OPTIONS*) ( aPanel->GetDisplayOptions() );
bool tmp = displ_opts->m_DisplayDrawItemsFill;
displ_opts->m_DisplayDrawItemsFill = SKETCH;
if( aErase )
Segment->Draw( aPanel, aDC, GR_XOR );
if( frame->Settings().m_use45DegreeGraphicSegments && Segment->GetShape() == S_SEGMENT )
{
wxPoint pt;
pt = CalculateSegmentEndPoint( aPanel->GetParent()->GetCrossHairPosition(),
Segment->GetStart() );
Segment->SetEnd( pt );
}
else // here the angle is arbitrary
{
Segment->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
}
Segment->Draw( aPanel, aDC, GR_XOR );
displ_opts->m_DisplayDrawItemsFill = tmp;
}
示例2: DrawSegment
/* Redraw segment during cursor movement
*/
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
{
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
int t_fill = DisplayOpt.DisplayDrawItems;
if( Segment == NULL )
return;
DisplayOpt.DisplayDrawItems = SKETCH;
if( aErase )
Segment->Draw( aPanel, aDC, GR_XOR );
if( g_Segments_45_Only && Segment->GetShape() == S_SEGMENT )
{
wxPoint pt;
CalculateSegmentEndPoint( aPanel->GetParent()->GetCrossHairPosition(),
Segment->GetStart().x, Segment->GetStart().y,
&pt.x, &pt.y );
Segment->SetEnd( pt );
}
else // here the angle is arbitrary
{
Segment->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
}
Segment->Draw( aPanel, aDC, GR_XOR );
DisplayOpt.DisplayDrawItems = t_fill;
}
示例3: 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;
}
示例4: OnOkClick
void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
{
if( !itemValuesOK() )
return;
m_parent->SaveCopyInUndoList( m_item, UR_CHANGED );
wxString msg;
if( m_DC )
m_item->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue();
m_item->SetStartX( ValueFromString( g_UserUnit, msg ) );
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 ) );
msg = m_EndY_Ctrl->GetValue();
m_item->SetEndY( ValueFromString( g_UserUnit, msg ) );
msg = m_ThicknessCtrl->GetValue();
m_item->SetWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ValueFromString( g_UserUnit, msg );
m_item->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
if( m_item->GetLayer() == Edge_Cuts )
m_brdSettings.m_EdgeSegmentWidth = thickness;
else
m_brdSettings.m_DrawSegmentWidth = thickness;
if( m_item->GetShape() == S_ARC )
{
double angle;
m_Angle_Ctrl->GetValue().ToDouble( &angle );
NORMALIZE_ANGLE_360( angle );
m_item->SetAngle( angle );
}
m_parent->OnModify();
if( m_DC )
m_item->Draw( m_parent->GetCanvas(), m_DC, GR_OR );
m_parent->SetMsgPanel( m_item );
m_parent->SetDesignSettings( m_brdSettings );
Close( true );
}
示例5: OnOkClick
void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
/*******************************************************************/
/* Copy values in text control to the item parameters
*/
{
m_parent->SaveCopyInUndoList( m_Item, UR_CHANGED );
wxString msg;
if( m_DC )
m_Item->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue();
m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
msg = m_Center_StartYCtrl->GetValue();
m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
msg = m_EndX_Radius_Ctrl->GetValue();
m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
msg = m_EndY_Ctrl->GetValue();
m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
msg = m_ThicknessCtrl->GetValue();
m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
m_Item->SetLayer( m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NO_COPPER_LAYER);
if( m_Item->GetLayer() == EDGE_N )
m_brdSettings.m_EdgeSegmentWidth = thickness;
else
m_brdSettings.m_DrawSegmentWidth = thickness;
if( m_Item->GetShape() == S_ARC )
{
double angle;
m_Angle_Ctrl->GetValue().ToDouble( &angle );
NORMALIZE_ANGLE_360(angle);
m_Item->SetAngle( angle );
}
m_parent->OnModify();
if( m_DC )
m_Item->Draw( m_parent->GetCanvas(), m_DC, GR_OR );
m_Item->DisplayInfo( m_parent );
m_parent->SetDesignSettings( m_brdSettings );
Close( true );
}
示例6: TransferDataFromWindow
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
{
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
m_parent->SaveCopyInUndoList( m_item, UR_CHANGED );
wxString msg;
if( m_DC )
m_item->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue();
m_item->SetStartX( ValueFromString( g_UserUnit, msg ) );
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 ) );
msg = m_EndY_Ctrl->GetValue();
m_item->SetEndY( ValueFromString( g_UserUnit, msg ) );
msg = m_ThicknessCtrl->GetValue();
m_item->SetWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ValueFromString( g_UserUnit, msg );
m_item->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
if( m_item->GetLayer() == Edge_Cuts )
m_brdSettings.m_EdgeSegmentWidth = thickness;
else
m_brdSettings.m_DrawSegmentWidth = thickness;
if( m_item->GetShape() == S_ARC )
{
m_item->SetAngle( m_AngleValue * 10.0 );
}
m_parent->OnModify();
if( m_DC )
m_item->Draw( m_parent->GetCanvas(), m_DC, GR_OR );
m_parent->SetMsgPanel( m_item );
m_parent->SetDesignSettings( m_brdSettings );
return true;
}
示例7: 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;
}
示例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: 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() );
//.........这里部分代码省略.........
示例11: 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
//.........这里部分代码省略.........
示例12: Validate
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate()
{
wxArrayString error_msgs;
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::Validate() )
return false;
// Load the start and end points -- all types use these in the checks.
int startx = ValueFromString( g_UserUnit, m_Center_StartXCtrl->GetValue() );
int starty = ValueFromString( g_UserUnit, m_Center_StartYCtrl->GetValue() );
int endx = ValueFromString( g_UserUnit, m_EndX_Radius_Ctrl->GetValue() );
int endy = ValueFromString( g_UserUnit, m_EndY_Ctrl->GetValue() );
// Type specific checks.
switch( m_item->GetShape() )
{
case S_ARC:
// Check angle of arc.
if( m_AngleValue == 0.0 )
{
error_msgs.Add( _( "The arc angle must be greater than zero." ) );
}
// Fall through.
case S_CIRCLE:
// Check radius.
if( (startx == endx) && (starty == endy) )
{
error_msgs.Add( _( "The radius must be greater than zero." ) );
}
break;
default:
// Check start and end are not the same.
if( (startx == endx) && (starty == endy) )
{
error_msgs.Add( _( "The start and end points cannot be the same." ) );
}
break;
}
// Check the item thickness.
int thickness = ValueFromString( g_UserUnit, m_ThicknessCtrl->GetValue() );
if( thickness <= 0 )
error_msgs.Add( _( "The item thickness must be greater than zero." ) );
// And the default thickness.
thickness = ValueFromString( g_UserUnit, m_DefaultThicknessCtrl->GetValue() );
if( thickness <= 0 )
error_msgs.Add( _( "The default thickness must be greater than zero." ) );
if( error_msgs.GetCount() )
{
HTML_MESSAGE_BOX dlg( this, _( "Error List" ) );
dlg.ListSet( error_msgs );
dlg.ShowModal();
}
return error_msgs.GetCount() == 0;
}
示例13: TransferDataToWindow
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
{
// Set unit symbol
wxStaticText* texts_unit[] =
{
m_StartPointXUnit,
m_StartPointYUnit,
m_EndPointXUnit,
m_EndPointYUnit,
m_ThicknessTextUnit,
m_DefaulThicknessTextUnit,
};
for( size_t ii = 0; ii < DIM( texts_unit ); ii++ )
{
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_AngleText->Show( false );
m_AngleCtrl->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:" ) );
m_AngleValue = m_item->GetAngle() / 10.0;
break;
case S_SEGMENT:
SetTitle( _( "Line Segment Properties" ) );
// Fall through.
default:
m_AngleText->Show( false );
m_AngleCtrl->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 );
}
return DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataToWindow();
}
示例14: PlaceDXF
//.........这里部分代码省略.........
break;
}
}
else if ( evt->IsClick( BUT_RIGHT ) )
{
showContextMenu();
}
else if( evt->IsClick( BUT_LEFT ) )
{
// Place the drawing
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
for( auto item : preview )
{
if( m_editModules )
{
// Modules use different types for the same things,
// so we need to convert imported items to appropriate classes.
BOARD_ITEM* converted = NULL;
switch( item->Type() )
{
case PCB_TEXT_T:
{
TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item );
TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent );
// Assignment operator also copies the item PCB_TEXT_T type,
// so it cannot be added to a module which handles PCB_MODULE_TEXT_T
textMod->SetPosition( text->GetPosition() );
textMod->SetText( text->GetText() );
textMod->SetSize( text->GetSize() );
textMod->SetThickness( text->GetThickness() );
textMod->SetOrientation( text->GetOrientation() );
textMod->SetTextPosition( text->GetTextPosition() );
textMod->SetSize( text->GetSize() );
textMod->SetMirrored( text->IsMirrored() );
textMod->SetAttributes( text->GetAttributes() );
textMod->SetItalic( text->IsItalic() );
textMod->SetBold( text->IsBold() );
textMod->SetHorizJustify( text->GetHorizJustify() );
textMod->SetVertJustify( text->GetVertJustify() );
textMod->SetMultilineAllowed( text->IsMultilineAllowed() );
converted = textMod;
break;
}
case PCB_LINE_T:
{
DRAWSEGMENT* seg = static_cast<DRAWSEGMENT*>( item );
EDGE_MODULE* modSeg = new EDGE_MODULE( (MODULE*) parent );
// Assignment operator also copies the item PCB_LINE_T type,
// so it cannot be added to a module which handles PCB_MODULE_EDGE_T
modSeg->SetWidth( seg->GetWidth() );
modSeg->SetStart( seg->GetStart() );
modSeg->SetEnd( seg->GetEnd() );
modSeg->SetAngle( seg->GetAngle() );
modSeg->SetShape( seg->GetShape() );
modSeg->SetType( seg->GetType() );
modSeg->SetBezControl1( seg->GetBezControl1() );
modSeg->SetBezControl2( seg->GetBezControl2() );
modSeg->SetBezierPoints( seg->GetBezierPoints() );
modSeg->SetPolyPoints( seg->GetPolyPoints() );
converted = modSeg;
break;
}
default:
assert( false );
break;
}
if( converted )
converted->SetLayer( item->GetLayer() );
delete item;
item = converted;
}
if( item )
commit.Add( item );
}
commit.Push( _( "Place a DXF drawing" ) );
break;
}
}
preview.Clear();
m_controls->ShowCursor( false );
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( &preview );
return 0;
}
示例15: 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 );
}
}