Commit 97be0050 authored by CHARRAS's avatar CHARRAS

Added: Delete cutout outline in zone popup menu

parent 549e5f68
......@@ -4,12 +4,21 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-jan-05 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
Added: Delete cutout outline in zone popup menu
the GUI about zones is now working.
Some work is needed ( a zone in a zone of the same net is not merged )
Currently No DRC for outlines
2008-jan-04 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
More about zones:
Outlines can be edited. Outlines are merged if needeed.
Current No DRC for outlines
Currently No DRC for outlines
2008-jan-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
......
......@@ -560,7 +560,7 @@ enum main_id {
ID_POPUP_PCB_PLACE_ZONE_CORNER,
ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
ID_POPUP_ZONE_UNUSED1,
ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
ID_POPUP_ZONE_UNUSED2,
ID_POPUP_ZONE_UNUSED3,
ID_POPUP_ZONE_UNUSED4,
......
/***********************************************************/
/* wxstruct.h: */
/* descriptions des principales classes derivees utilisees */
/* wxPcbStruct.h: */
/* Classes used in pcbnew, cvpcb and gerbview */
/***********************************************************/
#ifndef WXPCB_STRUCT_H
......@@ -14,14 +14,6 @@
#define PCB_INTERNAL_UNIT 10000
#endif
// Option for dialog boxes
// #define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT|wxSTAY_ON_TOP
#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | MAYBE_RESIZE_BORDER
#define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE|wxWANTS_CHARS
#define EDA_DRAW_PANEL wxScrolledWindow
class wxMyDialogModalData;
/* Forward declarations of classes. */
class WinEDA_DrawPanel;
......@@ -29,25 +21,12 @@ class WinEDA_DrawFrame;
#include "base_struct.h"
class WinEDA_App;
class WinEDA_MsgPanel;
class COMMAND;
class WinEDA_MainFrame;
class BASE_SCREEN;
class SCH_SCREEN;
class PCB_SCREEN;
class WinEDA_SchematicFrame; // Schematic main frame
class WinEDA_LibeditFrame; // Component creation and edition main frame
class WinEDA_ViewlibFrame; // Component viewer main frame
class WinEDA_GerberFrame; // GERBER viewer main frame
class WinEDA_Toolbar;
class WinEDA_CvpcbFrame;
class WinEDA_PcbFrame;
class WinEDA_ModuleEditFrame;
class WinEDAChoiceBox;
#define WinEDA_MenuBar wxMenuBar
#define WinEDA_Menu wxMenu
#define WinEDA_MenuItem wxMenuItem
// Used but not defined here:
class BOARD;
......@@ -193,7 +172,9 @@ public:
void InstallModuleOptionsFrame( MODULE* Module,
wxDC* DC, const wxPoint& pos );
MODULE* Copie_Module( MODULE* module );
MODULE* Exchange_Module( wxWindow* winaff, MODULE* old_module, MODULE* new_module );
MODULE* Exchange_Module( wxWindow* winaff,
MODULE* old_module,
MODULE* new_module );
int Save_1_Module( const wxString& LibName, MODULE* Module,
bool Overwrite, bool DisplayDialog );
void Archive_Modules( const wxString& LibName, bool NewModulesOnly );
......@@ -203,7 +184,10 @@ public:
// Modules (footprints)
MODULE* Create_1_Module( wxDC* DC, const wxString& module_name );
void Edit_Module( MODULE* module, wxDC* DC );
void Rotate_Module( wxDC* DC, MODULE* module, int angle, bool incremental );
void Rotate_Module( wxDC* DC,
MODULE* module,
int angle,
bool incremental );
void Change_Side_Module( MODULE* Module, wxDC* DC );
void Place_Module( MODULE* module, wxDC* DC );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule,
......@@ -232,8 +216,10 @@ public:
// loading footprints
MODULE* Get_Librairie_Module( wxWindow* winaff, const wxString& library,
const wxString& ModuleName, bool show_msg_err );
MODULE* Get_Librairie_Module( wxWindow* winaff,
const wxString& library,
const wxString& ModuleName,
bool show_msg_err );
wxString Select_1_Module_From_List(
WinEDA_DrawFrame* active_window, const wxString& Library,
......@@ -252,7 +238,9 @@ public:
void trace_ratsnest_pad( wxDC* DC );
void recalcule_pad_net_code(); /* compute and update the PAD net codes */
void build_liste_pads();
int* build_ratsnest_pad( EDA_BaseStruct* ref, const wxPoint& refpos, bool init );
int* build_ratsnest_pad( EDA_BaseStruct* ref,
const wxPoint& refpos,
bool init );
void Tst_Ratsnest( wxDC* DC, int ref_netcode );
void test_connexions( wxDC* DC );
......@@ -483,16 +471,18 @@ public:
bool Genere_Pad_Connexion( wxDC* DC, int layer );
// zone handling
/** Function Delete_Zone
* Remove the zone which include the segment aZone, or the zone which have the given time stamp.
/** Function Delete_Zone_Fill
* Remove the zone filling which include the segment aZone, or the zone which have the given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param DC = current Device Context (can be NULL)
* @param aZone = zone segment within the zone to delete. Can be NULL
* @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL
*/
void Delete_Zone( wxDC* DC, SEGZONE* Track, long aTimestamp = 0 );
void Delete_Zone_Fill( wxDC* DC, SEGZONE* Track, long aTimestamp = 0 );
EDGE_ZONE* Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone );
/**
* Function Begin_Zone
* initiates a zone edge creation process,
......@@ -517,7 +507,7 @@ public:
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
int Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container, bool verbose = TRUE );
int Fill_Zone( wxDC* DC, ZONE_CONTAINER* zone_container, bool verbose = TRUE );
/** Function Fill_All_Zones()
* Fill all zones on the board
......@@ -536,7 +526,7 @@ public:
* @param DC = current Device Context
* @param zone_container = parent zone outline
*/
void Add_Zone_Cutout( wxDC* DC , ZONE_CONTAINER * zone_container );
void Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container );
/**
* Function Add_Similar_Zone
......@@ -545,13 +535,13 @@ public:
* @param DC = current Device Context
* @param zone_container = parent zone outline
*/
void Add_Similar_Zone( wxDC* DC , ZONE_CONTAINER * zone_container );
void Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container );
/**
* Function Edit_Zone_Params
* Edit params (layer, clearance, ...) for a zone outline
*/
void Edit_Zone_Params( wxDC* DC , ZONE_CONTAINER * zone_container );
void Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container );
/**
* Function Start_Move_Zone_Corner
......@@ -559,19 +549,34 @@ public:
* called from a move corner command (IsNewCorner = false),
* or a create new cornet command (IsNewCorner = true )
*/
void Start_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container, int corner_id, bool IsNewCorner );
void Start_Move_Zone_Corner( wxDC* DC,
ZONE_CONTAINER* zone_container,
int corner_id,
bool IsNewCorner );
/**
* Function End_Move_Zone_Corner
* Terminates a move corner in a zone outline
*/
void End_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container );
void End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container );
/**
* Function End_Move_Zone_Corner
* Remove the currently selected corner in a zone outline
* the .m_CornerSelection is used as corner selection
*/
void Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_container );
void Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container );
/** Function Delete_Zone
* Remove the zone which include the segment aZone, or the zone which have the given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param DC = current Device Context (can be NULL)
* @param zone_container = zone to modify
* the member .m_CornerSelection is used to find the outline to remove.
* if the outline is the main outline, all the zone is removed
* otherwise, the hole is deleted
*/
void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container );
// Target handling
MIREPCB* Create_Mire( wxDC* DC );
......
No preview for this file type
This diff is collapsed.
......@@ -150,6 +150,11 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
case TYPEZONE_CONTAINER:
text = _( "Zone Outline" );
{
ZONE_CONTAINER* area = (ZONE_CONTAINER*) this;
int ncont = area->m_Poly->GetContour(area->m_CornerSelection);
if ( ncont ) text << wxT(" ") << _("(Cutout)");
}
text << wxT( " " );
{
wxString TimeStampText;
......
......@@ -331,6 +331,7 @@ int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
int dist;
unsigned item_pos, lim;
lim = m_Poly->corner.size();
m_CornerSelection = -1;
// Min distance to hit = MIN_DIST_IN_PIXELS pixels :
WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame;
......@@ -340,8 +341,11 @@ int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
{
dist = abs( m_Poly->corner[item_pos].x - refPos.x ) + abs( m_Poly->corner[item_pos].y - refPos.y );
if( dist <= min_dist )
{
m_CornerSelection = item_pos;
return item_pos;
}
}
return -1;
}
......@@ -366,6 +370,7 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
/* Test for an entire segment */
unsigned first_corner_pos = 0, end_segm;
m_CornerSelection = -1;
for ( item_pos = 0; item_pos < lim; item_pos++ )
{
......@@ -389,8 +394,11 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
m_Poly->corner[end_segm].x,
m_Poly->corner[end_segm].y );
if( dist <= min_dist )
{
m_CornerSelection = item_pos;
return item_pos;
}
}
return -1;
}
......@@ -407,6 +415,9 @@ void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
msg = _( "Zone Outline" );
int ncont = m_Poly->GetContour(m_CornerSelection);
if ( ncont ) msg << wxT(" ") << _("(Cutout)");
text_pos = 1;
Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN );
......
......@@ -441,7 +441,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema();
if( GetCurItem() == NULL )
break;
Delete_Zone( &dc, (SEGZONE*) GetCurItem() );
Delete_Zone_Fill( &dc, (SEGZONE*) GetCurItem() );
SetCurItem( NULL );
break;
......@@ -460,15 +460,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
{
case ID_POPUP_PCB_DELETE_ZONE_CUTOUT:
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
Delete_Zone( &dc, NULL, zone_cont->m_TimeStamp );
m_Pcb->Delete( zone_cont );
Delete_Zone_Contour( &dc, (ZONE_CONTAINER*)GetCurItem() );
SetCurItem( NULL );
break;
}
case ID_POPUP_PCB_DELETE_ZONE_CORNER:
Remove_Zone_Corner( &dc, (ZONE_CONTAINER*)GetCurItem() );
......@@ -1010,7 +1006,7 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
break;
case TYPEZONE:
Delete_Zone( DC, (SEGZONE*) Item );
Delete_Zone_Fill( DC, (SEGZONE*) Item );
break;
case TYPEMARKER:
......
......@@ -639,37 +639,42 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
}
else
{
edge_zone->m_CornerSelection = -1;
wxMenu * zones_menu = new wxMenu();
ADD_MENUITEM_WITH_SUBMENU( aPopMenu, zones_menu,
-1, _( "Zones" ), add_zone_xpm );
int index;
if( ( index = edge_zone->HitTestForCorner( GetScreen()->m_Curseur ) ) >= 0 )
{
edge_zone->m_CornerSelection = index;
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_ZONE_CORNER,
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_CORNER,
_( "Move Corner" ), move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE_CORNER,
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CORNER,
_( "Delete Corner" ), delete_xpm );
}
else if( ( index = edge_zone->HitTestForEdge( GetScreen()->m_Curseur ) ) >= 0 )
{
edge_zone->m_CornerSelection = index;
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ADD_ZONE_CORNER,
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER,
_( "Create Corner" ), Add_Corner_xpm );
}
aPopMenu->AppendSeparator();
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
zones_menu->AppendSeparator();
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
_( "Add Similar Zone" ), add_zone_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
_( "Add Cutout Area" ), add_zone_cutout );
aPopMenu->AppendSeparator();
zones_menu->AppendSeparator();
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ZONE,
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_FILL_ZONE,
_( "Fill Zone" ), fill_zone_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
_( "Edit Zone Params" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
if ( index >= 0 && edge_zone->m_Poly->IsCutoutContour( edge_zone->m_CornerSelection ) )
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
_( "Delete Cutout" ), delete_xpm );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
_( "Delete Zone Outline" ), delete_xpm );
}
}
......
......@@ -48,7 +48,7 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
s_TimeStamp = m_TimeStamp;
// Delete the old filling, if any :
frame->Delete_Zone( DC, NULL, m_TimeStamp );
frame->Delete_Zone_Fill( DC, NULL, m_TimeStamp );
// calculate the fixed step of the routing matrix as 5 mils or more
E_scale = g_GridRoutingSize / 50;
......
......@@ -104,11 +104,11 @@ void WinEDA_PcbFrame::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container
/*****************************************************************************/
void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* aZone, long aTimestamp )
void WinEDA_PcbFrame::Delete_Zone_Fill( wxDC* DC, SEGZONE* aZone, long aTimestamp )
/******************************************************************************/
/** Function Delete_Zone
* Remove the zone which include the segment aZone, or the zone which have the given time stamp.
/** Function Delete_Zone_Fill
* Remove the zone fillig which include the segment aZone, or the zone which have the given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param DC = current Device Context (can be NULL)
* @param aZone = zone segment within the zone to delete. Can be NULL
......@@ -257,13 +257,12 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con
*/
{
/* Show the Net */
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
if( g_HightLigt_Status )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if( !g_HightLigt_Status )
g_HightLigth_NetCode = s_NetcodeSelection = zone_container->GetNet();
Hight_Light( DC );
zone_container->m_Flags = IN_EDIT;
......@@ -327,7 +326,7 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai
{
if ( zone_container->m_Poly->GetNumCorners() <= 3 )
{
Delete_Zone( DC, NULL, zone_container->m_TimeStamp );
Delete_Zone_Fill( DC, NULL, zone_container->m_TimeStamp );
m_Pcb->Delete( zone_container );
return;
}
......@@ -466,7 +465,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
s_Zone_Hatching = s_CurrentZone->m_Poly->GetHatchStyle();
}
/* Show the Net */
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
if( g_HightLigt_Status && (g_HightLigth_NetCode != s_NetcodeSelection) )
{
Hight_Light( DC ); // Remove old hightlight selection
}
......@@ -474,7 +473,6 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
if( s_CurrentZone )
s_NetcodeSelection = s_CurrentZone->GetNet();
g_HightLigth_NetCode = s_NetcodeSelection;
if( !g_HightLigt_Status )
Hight_Light( DC );
if( !s_AddCutoutToCurrentZone )
......@@ -742,6 +740,39 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
GetScreen()->SetModify();
}
/************************************************************************************/
void WinEDA_PcbFrame::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container )
/************************************************************************************/
/** Function Delete_Zone_Contour
* Remove the zone which include the segment aZone, or the zone which have the given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param DC = current Device Context (can be NULL)
* @param zone_container = zone to modify
* the member .m_CornerSelection is used to find the outline to remove.
* if the outline is the main outline, all the zone_container is removed (deleted)
* otherwise, the hole is deleted
*/
{
int ncont = zone_container->m_Poly->GetContour(zone_container->m_CornerSelection);
if ( DC )
zone_container->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR);
Delete_Zone_Fill( DC, NULL, zone_container->m_TimeStamp ); // Remove fill segments
if ( ncont == 0 ) // This is the main outline: remove all
m_Pcb->Delete( zone_container );
else
{
zone_container->m_Poly->RemoveContour( ncont );
if ( DC )
zone_container->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
}
GetScreen()->SetModify();
}
/***************************************************************************************/
int WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER* zone_container, bool verbose )
......@@ -770,13 +801,13 @@ int WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER* zone_container, bool v
/* Show the Net */
s_NetcodeSelection = zone_container->GetNet();
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) && DC )
if( g_HightLigt_Status && (g_HightLigth_NetCode != s_NetcodeSelection) && DC )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if( !g_HightLigt_Status && DC )
if( DC )
Hight_Light( DC );
if( g_HightLigth_NetCode > 0 )
......
This diff is collapsed.
......@@ -59,7 +59,7 @@ CPolyLine::~CPolyLine()
// If bRetainArcs == TRUE, try to retain arcs in polys
// Returns number of external contours, or -1 if error
//
int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, BOOL bRetainArcs )
int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs )
{
std::vector<CArc> arc_array;
......@@ -495,7 +495,7 @@ int CPolyLine::RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine
}
// find arcs and replace them
BOOL bFound;
bool bFound;
int arc_start;
int arc_end;
for( unsigned iarc=0; iarc<arc_array->size(); iarc++ )
......@@ -637,7 +637,7 @@ void CPolyLine::Start( int layer, int w, int sel_box, int x, int y,
// add a corner to unclosed polyline
//
void CPolyLine::AppendCorner( int x, int y, int style, BOOL bDraw )
void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
{
Undraw();
CPolyPt poly_pt( x, y );
......@@ -663,7 +663,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, BOOL bDraw )
// close last polyline contour
//
void CPolyLine::Close( int style, BOOL bDraw )
void CPolyLine::Close( int style, bool bDraw )
{
if( GetClosed() )
ASSERT(0);
......@@ -686,13 +686,13 @@ void CPolyLine::MoveCorner( int ic, int x, int y )
// delete corner and adjust arrays
//
void CPolyLine::DeleteCorner( int ic, BOOL bDraw )
void CPolyLine::DeleteCorner( int ic, bool bDraw )
{
Undraw();
int icont = GetContour( ic );
int istart = GetContourStart( icont );
int iend = GetContourEnd( icont );
BOOL bClosed = icont < GetNumContours()-1 || GetClosed();
bool bClosed = icont < GetNumContours()-1 || GetClosed();
if( !bClosed )
{
......@@ -719,7 +719,14 @@ void CPolyLine::DeleteCorner( int ic, BOOL bDraw )
Draw();
}
/******************************************/
void CPolyLine::RemoveContour( int icont )
/******************************************/
/**
* Function RemoveContour
* @param icont = contour number to remove
* remove a contour only if there is more than 1 contour
*/
{
Undraw();
int istart = GetContourStart( icont );
......@@ -733,8 +740,8 @@ void CPolyLine::RemoveContour( int icont )
else if( icont == GetNumContours()-1 )
{
// remove last contour
corner.erase( corner.begin() + icont, corner.end() );
side_style.erase( side_style.begin() + icont, side_style.end() );
corner.erase( corner.begin() + istart, corner.end() );
side_style.erase( side_style.begin() + istart, side_style.end() );
}
else
{
......@@ -749,7 +756,9 @@ void CPolyLine::RemoveContour( int icont )
}
/******************************************/
void CPolyLine::RemoveAllContours( void )
/******************************************/
/**
* function RemoveAllContours
* removes all corners from the lists.
......@@ -1162,11 +1171,6 @@ int CPolyLine::GetW()
return m_Width;
}
int CPolyLine::GetSelBoxSize()
{
return m_sel_box;
}
int CPolyLine::GetNumContours()
{
int ncont = 0;
......@@ -1462,7 +1466,7 @@ void CPolyLine::Hatch()
// test to see if a point is inside polyline
//
BOOL CPolyLine::TestPointInside( int x, int y )
bool CPolyLine::TestPointInside( int x, int y )
{
enum { MAXPTS = 100 };
if( !GetClosed() )
......@@ -1538,7 +1542,7 @@ BOOL CPolyLine::TestPointInside( int x, int y )
// test to see if a point is inside polyline contour
//
BOOL CPolyLine::TestPointInsideContour( int icont, int x, int y )
bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
{
if( icont >= GetNumContours() )
return FALSE;
......@@ -1662,25 +1666,6 @@ int CPolyLine::TestIntersection( CPolyLine * poly )
return 0;
}
// set selection box size
//
void CPolyLine::SetSelBoxSize( int sel_box )
{
// Undraw();
m_sel_box = sel_box;
// Draw();
}
// set pointer to display list, and draw into display list
//
void CPolyLine::SetDisplayList( CDisplayList * dl )
{
if( m_dlist )
Undraw();
m_dlist = dl;
if( m_dlist )
Draw();
}
// copy data from another poly, but don't draw it
//
......@@ -1701,6 +1686,20 @@ void CPolyLine::Copy( CPolyLine * src )
FreeGpcPoly();
}
/*******************************************/
bool CPolyLine::IsCutoutContour( int icont )
/*******************************************/
/*
* return true if the corner icont is inside the outline (i.e it is a hole)
*/
{
int ncont = GetContour( icont );
if ( ncont == 0 ) // the first contour is the main outline, not an hole
return false;
return true;
}
void CPolyLine::MoveOrigin( int x_off, int y_off )
{
Undraw();
......@@ -1719,7 +1718,11 @@ void CPolyLine::MoveOrigin( int x_off, int y_off )
//
void CPolyLine::SetX( int ic, int x ) { corner[ic].x = x; }
void CPolyLine::SetY( int ic, int y ) { corner[ic].y = y; }
void CPolyLine::SetEndContour( int ic, BOOL end_contour ) { corner[ic].end_contour = end_contour; }
void CPolyLine::SetEndContour( int ic, bool end_contour )
{
corner[ic].end_contour = end_contour;
}
// Create CPolyLine for a pad
//
......@@ -1750,7 +1753,7 @@ CPolyLine * CPolyLine::MakePolylineForPad( int type, int x, int y, int w, int l,
//
void CPolyLine::AddContourForPadClearance( int type, int x, int y, int w,
int l, int r, int angle, int fill_clearance,
int hole_w, int hole_clearance, BOOL bThermal, int spoke_w )
int hole_w, int hole_clearance, bool bThermal, int spoke_w )
{
int dx = l/2;
int dy = w/2;
......
......@@ -46,17 +46,17 @@ public:
int style;
int xi, yi, xf, yf;
int n_steps; // number of straight-line segments in gpc_poly
BOOL bFound;
bool bFound;
};
class CPolyPt
{
public:
CPolyPt( int qx=0, int qy=0, BOOL qf=FALSE )
CPolyPt( int qx=0, int qy=0, bool qf=FALSE )
{ x=qx; y=qy; end_contour=qf; utility = 0; };
int x;
int y;
BOOL end_contour;
bool end_contour;
int utility;
};
......@@ -75,11 +75,11 @@ public:
// functions for modifying polyline
void Start( int layer, int w, int sel_box, int x, int y,
int hatch );
void AppendCorner( int x, int y, int style = STRAIGHT, BOOL bDraw=TRUE );
void AppendCorner( int x, int y, int style = STRAIGHT, bool bDraw=TRUE );
void InsertCorner( int ic, int x, int y );
void DeleteCorner( int ic, BOOL bDraw=TRUE );
void DeleteCorner( int ic, bool bDraw=TRUE );
void MoveCorner( int ic, int x, int y );
void Close( int style = STRAIGHT, BOOL bDraw=TRUE );
void Close( int style = STRAIGHT, bool bDraw=TRUE );
void RemoveContour( int icont );
void RemoveAllContours( void );
......@@ -93,7 +93,7 @@ public:
void Undraw();
void Draw( CDisplayList * dl = NULL );
void Hatch();
void MakeVisible( BOOL visible = TRUE );
void MakeVisible( bool visible = TRUE );
void MoveOrigin( int x_off, int y_off );
// misc. functions
......@@ -101,8 +101,9 @@ public:
CRect GetCornerBounds();
CRect GetCornerBounds( int icont );
void Copy( CPolyLine * src );
BOOL TestPointInside( int x, int y );
BOOL TestPointInsideContour( int icont, int x, int y );
bool TestPointInside( int x, int y );
bool TestPointInsideContour( int icont, int x, int y );
bool IsCutoutContour( int icont );
int TestIntersection( CPolyLine * poly );
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
......@@ -124,30 +125,25 @@ public:
void SetUtility( int ic, int utility ){ corner[ic].utility = utility; };
int GetW();
int GetSideStyle( int is );
id GetId();
int GetSelBoxSize();
CDisplayList * GetDisplayList(){ return m_dlist; };
int GetHatchStyle(){ return m_HatchStyle; }
void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); };
void SetX( int ic, int x );
void SetY( int ic, int y );
void SetEndContour( int ic, BOOL end_contour );
void SetEndContour( int ic, bool end_contour );
// void SetLayer( int layer );
void SetW( int w );
void SetSideStyle( int is, int style );
void SetSelBoxSize( int sel_box );
void SetDisplayList( CDisplayList * dl );
// GPC functions
int MakeGpcPoly( int icontour=0, std::vector<CArc> * arc_array=NULL );
int FreeGpcPoly();
gpc_polygon * GetGpcPoly(){ return m_gpc_poly; };
int NormalizeWithGpc( std::vector<CPolyLine*> * pa=NULL, BOOL bRetainArcs=FALSE );
int NormalizeWithGpc( std::vector<CPolyLine*> * pa=NULL, bool bRetainArcs=FALSE );
int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa=NULL );
CPolyLine * MakePolylineForPad( int type, int x, int y, int w, int l, int r, int angle );
void AddContourForPadClearance( int type, int x, int y, int w,
int l, int r, int angle, int fill_clearance,
int hole_w, int hole_clearance, BOOL bThermal=FALSE, int spoke_w=0 );
int hole_w, int hole_clearance, bool bThermal=FALSE, int spoke_w=0 );
void ClipGpcPolygon( gpc_op op, CPolyLine * poly );
// PHP functions
......@@ -174,7 +170,7 @@ public:
private:
gpc_polygon * m_gpc_poly; // polygon in gpc format
polygon * m_php_poly;
BOOL bDrawn;
bool bDrawn;
};
#endif // #ifndef POLYLINE_H
......@@ -31,31 +31,6 @@ enum
PAD_OCTAGON
};
/*
enum
{
// visible layers
LAY_SELECTION = 0,
LAY_BACKGND,
LAY_VISIBLE_GRID,
LAY_HILITE,
LAY_DRC_ERROR,
LAY_BOARD_OUTLINE,
LAY_RAT_LINE,
LAY_SILK_TOP,
LAY_SILK_BOTTOM,
LAY_SM_TOP,
LAY_SM_BOTTOM,
LAY_PAD_THRU,
LAY_TOP_COPPER,
LAY_BOTTOM_COPPER,
// invisible layers
LAY_MASK_TOP = -100,
LAY_MASK_BOTTOM = -101,
LAY_PASTE_TOP = -102,
LAY_PASTE_BOTTOM = -103
};
*/
#define LAY_SELECTION 0
#define LAY_TOP_COPPER 0
......
......@@ -2,25 +2,10 @@
#include "PolyLine.h"
dl_element * CDisplayList::Add( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo,
int radius, int orig_layer )
{
return NULL;
}
dl_element * CDisplayList::AddSelector( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int radius )
{
return NULL;
}
void CDisplayList::Set_visible( dl_element * el, int visible )
{
}
int CDisplayList::StopDragging()
{
return 0;
......@@ -31,10 +16,6 @@ int CDisplayList::CancelHighLight()
return 0;
}
void CDisplayList::Set_id( dl_element * el, id * id )
{
}
id CDisplayList::Remove( dl_element * element )
{
return 0;
......@@ -83,3 +64,4 @@ int CDisplayList::StartDraggingArc( CDC * pDC, int style, int x, int y, int xi,
{
return 0;
}
......@@ -656,10 +656,15 @@ BOOL polygon::isInside( vertex * v )
int winding_number3 = 0;
int winding_number4 = 0;
//** vertex * point_at_infinity = new vertex(-10000000,v->Y()); // Create point at infinity
vertex * point_at_infinity = new vertex(-1000000000,-50000000); // Create point at infinity
/* vertex * point_at_infinity = new vertex(-1000000000,-50000000); // Create point at infinity
vertex * point_at_infinity2 = new vertex(1000000000,+50000000); // Create point at infinity
vertex * point_at_infinity3 = new vertex(500000000,1000000000); // Create point at infinity
vertex * point_at_infinity4 = new vertex(-500000000,1000000000); // Create point at infinity
*/
vertex point_at_infinity(-1000000000,-50000000); // Create point at infinity
vertex point_at_infinity2(1000000000,+50000000); // Create point at infinity
vertex point_at_infinity3(500000000,1000000000); // Create point at infinity
vertex point_at_infinity4(-500000000,1000000000); // Create point at infinity
vertex * q = m_first; // End vertex of a line segment in polygon
do
{
......@@ -667,20 +672,20 @@ BOOL polygon::isInside( vertex * v )
{
int n;
double x[2], y[2], aP[2], aQ[2];
if( ints( point_at_infinity, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
if( ints( &point_at_infinity, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
winding_number += n; // Add number of intersections found
if( ints( point_at_infinity2, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
if( ints( &point_at_infinity2, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
winding_number2 += n; // Add number of intersections found
if( ints( point_at_infinity3, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
if( ints( &point_at_infinity3, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
winding_number3 += n; // Add number of intersections found
if( ints( point_at_infinity4, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
if( ints( &point_at_infinity4, v, q, nxt(q->Next()), &n, x, y, aP, aQ ) )
winding_number4 += n; // Add number of intersections found
}
q = q->Next();
}
while( q->id() != m_first->id() );
delete point_at_infinity;
delete point_at_infinity2;
// delete point_at_infinity;
// delete point_at_infinity2;
if( winding_number%2 != winding_number2%2
|| winding_number3%2 != winding_number4%2
|| winding_number%2 != winding_number3%2 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment