本文整理汇总了C++中ZONE_CONTAINER::GetNumCorners方法的典型用法代码示例。如果您正苦于以下问题:C++ ZONE_CONTAINER::GetNumCorners方法的具体用法?C++ ZONE_CONTAINER::GetNumCorners怎么用?C++ ZONE_CONTAINER::GetNumCorners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZONE_CONTAINER
的用法示例。
在下文中一共展示了ZONE_CONTAINER::GetNumCorners方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Delete_LastCreatedCorner
int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC )
{
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
if( !zone )
return 0;
if( !zone->GetNumCorners() )
return 0;
zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
if( zone->GetNumCorners() > 2 )
{
zone->m_Poly->DeleteCorner( zone->GetNumCorners() - 1 );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
else
{
m_canvas->SetMouseCapture( NULL, NULL );
SetCurItem( NULL );
zone->RemoveAllContours();
zone->ClearFlags();
}
return zone->GetNumCorners();
}
示例2: Show_New_Edge_While_Move_Mouse
/* Redraws the zone outlines when moving mouse
*/
static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
wxPoint c_pos = pcbframe->GetScreen()->GetCrossHairPosition();
ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
if( !zone )
return;
int icorner = zone->GetNumCorners() - 1;
if( icorner < 1 )
return; // We must have 2 (or more) corners
if( aErase ) // Undraw edge in old position
{
zone->DrawWhileCreateOutline( aPanel, aDC );
}
// Redraw the current edge in its new position
if( pcbframe->GetZoneSettings().m_Zone_45_Only )
{
// calculate the new position as allowed
wxPoint StartPoint = zone->GetCornerPosition( icorner - 1 );
CalculateSegmentEndPoint( c_pos, StartPoint.x, StartPoint.y, &c_pos.x, &c_pos.y );
}
zone->SetCornerPosition( icorner, c_pos );
zone->DrawWhileCreateOutline( aPanel, aDC );
}
示例3: OnAreaPolygonModified
bool BOARD::OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList,
ZONE_CONTAINER* modified_area )
{
// clip polygon against itself
bool modified = NormalizeAreaPolygon( aModifiedZonesList, modified_area );
// now see if we need to clip against other areas
/*
LAYER_NUM layer = modified_area->GetLayer();
*/
bool bCheckAllAreas = TestAreaIntersections( modified_area );
if( bCheckAllAreas )
{
modified = true;
CombineAllAreasInNet( aModifiedZonesList, modified_area->GetNetCode(), true );
}
/*
FIXME : do we really need this?
if( !IsCopperLayer( layer ) ) // Refill non copper zones on this layer
{
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
if( m_ZoneDescriptorList[ia]->GetLayer() == layer )
m_ZoneDescriptorList[ia]->BuildFilledSolidAreasPolygons( this );
}
*/
// Test for bad areas: all zones must have more than 2 corners:
// Note: should not happen, but just in case.
for( unsigned ii = 0; ii < m_ZoneDescriptorList.size(); )
{
ZONE_CONTAINER* zone = m_ZoneDescriptorList[ii];
if( zone->GetNumCorners() >= 3 )
ii++;
else // Remove zone because it is incorrect:
RemoveArea( aModifiedZonesList, zone );
}
return modified;
}
示例4: removeCornerCondition
bool POINT_EDITOR::removeCornerCondition( const SELECTION& )
{
if( !m_editPoints )
return false;
EDA_ITEM* item = m_editPoints->GetParent();
if( item->Type() != PCB_ZONE_AREA_T )
return false;
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
if( zone->GetNumCorners() <= 3 )
return false;
// Remove corner does not work with lines
if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
return false;
return m_editedPoint != NULL;
}
示例5: End_Zone
bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
{
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
if( !zone )
return true;
// Validate the current outline:
if( zone->GetNumCorners() <= 2 ) // An outline must have 3 corners or more
{
Abort_Zone_Create_Outline( m_canvas, DC );
return true;
}
// Remove the last corner if is is at the same location as the prevoius corner
zone->m_Poly->RemoveNullSegments();
// Validate the current edge:
int icorner = zone->GetNumCorners() - 1;
if( zone->IsOnCopperLayer() )
{
if( Drc_On && m_drc->Drc( zone, icorner - 1 ) == BAD_DRC ) // we can't validate last edge
return false;
if( Drc_On && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge
{
DisplayError( this,
_( "DRC error: closing this area creates a drc error with an other area" ) );
m_canvas->MoveCursorToCrossHair();
return false;
}
}
zone->ClearFlags();
zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
m_canvas->SetMouseCapture( NULL, NULL );
// Undraw old drawings, because they can have important changes
int layer = zone->GetLayer();
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
// Save initial zones configuration, for undo/redo, before adding new zone
s_AuxiliaryList.ClearListAndDeleteItems();
s_PickedList.ClearListAndDeleteItems();
SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNet(), zone->GetLayer() );
// Put new zone in list
if( !s_CurrentZone )
{
zone->m_Poly->CloseLastContour(); // Close the current corner list
GetBoard()->Add( zone );
GetBoard()->m_CurrentZoneContour = NULL;
// Add this zone in picked list, as new item
ITEM_PICKER picker( zone, UR_NEW );
s_PickedList.PushItem( picker );
}
else // Append this outline as a cutout to an existing zone
{
for( int ii = 0; ii < zone->GetNumCorners(); ii++ )
{
s_CurrentZone->AppendCorner( zone->GetCornerPosition( ii ) );
}
s_CurrentZone->m_Poly->CloseLastContour(); // Close the current corner list
zone->RemoveAllContours(); // All corners are copied in s_CurrentZone. Free corner list.
zone = s_CurrentZone;
}
s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL;
GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
// Combine zones if possible :
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, zone );
// Redraw the real edge zone :
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
int ii = GetBoard()->GetAreaIndex( zone ); // test if zone exists
if( ii < 0 )
zone = NULL; // was removed by combining zones
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone, true );
if( error_count )
{
DisplayError( this, _( "Area: DRC outline error" ) );
}
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
//.........这里部分代码省略.........
示例6: Begin_Zone
int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
{
ZONE_SETTINGS zoneInfo = GetZoneSettings();
// verify if s_CurrentZone exists (could be deleted since last selection) :
int ii;
for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{
if( s_CurrentZone == GetBoard()->GetArea( ii ) )
break;
}
if( ii >= GetBoard()->GetAreaCount() ) // Not found: could be deleted since last selection
{
s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL;
}
// If no zone contour in progress, a new zone is being created:
if( !GetBoard()->m_CurrentZoneContour )
{
if( GetToolId() == ID_PCB_KEEPOUT_AREA_BUTT &&
getActiveLayer() >= FIRST_NON_COPPER_LAYER )
{
DisplayError( this,
_( "Error: a keepout area is allowed only on copper layers" ) );
return 0;
}
else
GetBoard()->m_CurrentZoneContour = new ZONE_CONTAINER( GetBoard() );
}
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...)
{
if( !s_CurrentZone ) // A new outline is created, from scratch
{
ZONE_EDIT_T edited;
// Init zone params to reasonable values
zone->SetLayer( getActiveLayer() );
// Prompt user for parameters:
m_canvas->SetIgnoreMouseEvents( true );
if( zone->IsOnCopperLayer() )
{
// Put a zone on a copper layer
if( GetBoard()->GetHighLightNetCode() > 0 )
{
zoneInfo.m_NetcodeSelection = GetBoard()->GetHighLightNetCode();
zone->SetNet( zoneInfo.m_NetcodeSelection );
zone->SetNetNameFromNetCode( );
}
double tmp = ZONE_THERMAL_RELIEF_GAP_MIL;
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, &tmp );
zoneInfo.m_ThermalReliefGap = KiROUND( tmp * IU_PER_MILS);
tmp = ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL;
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&tmp );
zoneInfo.m_ThermalReliefCopperBridge = KiROUND( tmp * IU_PER_MILS );
tmp = ZONE_CLEARANCE_MIL;
wxGetApp().GetSettings()->Read( ZONE_CLEARANCE_WIDTH_STRING_KEY,
&tmp );
zoneInfo.m_ZoneClearance = KiROUND( tmp * IU_PER_MILS );
tmp = ZONE_THICKNESS_MIL;
wxGetApp().GetSettings()->Read( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY,
&tmp );
zoneInfo.m_ZoneMinThickness = KiROUND( tmp * IU_PER_MILS );
zoneInfo.m_CurrentZone_Layer = zone->GetLayer();
if( GetToolId() == ID_PCB_KEEPOUT_AREA_BUTT )
{
zoneInfo.SetIsKeepout( true );
edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
}
else
{
zoneInfo.SetIsKeepout( false );
edited = InvokeCopperZonesEditor( this, &zoneInfo );
}
}
else // Put a zone on a non copper layer (technical layer)
{
zoneInfo.SetIsKeepout( false );
zoneInfo.m_NetcodeSelection = 0; // No net for non copper zones
edited = InvokeNonCopperZonesEditor( this, zone, &zoneInfo );
}
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
if( edited == ZONE_ABORT )
return 0;
//.........这里部分代码省略.........
示例7: 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 );
//.........这里部分代码省略.........