From ab1df3f1d7859349b736ceeca3bc5d459352258d Mon Sep 17 00:00:00 2001 From: charras Date: Sat, 27 Sep 2008 19:26:29 +0000 Subject: [PATCH] more about non copper zones (see changelog) --- change_log.txt | 5 + cvpcb/setvisu.cpp | 23 ++- gerbview/tracepcb.cpp | 14 +- include/wxPcbStruct.h | 1 - pcbnew/class_board.cpp | 2 + pcbnew/class_board.h | 7 +- pcbnew/class_zone.cpp | 10 +- pcbnew/lay2plot.cpp | 10 ++ pcbnew/plot_rtn.cpp | 61 +++++-- pcbnew/protos.h | 22 --- pcbnew/tracepcb.cpp | 73 +++++---- pcbnew/trpiste.cpp | 20 --- pcbnew/zones_by_polygon.cpp | 9 +- pcbnew/zones_non_copper_type_functions.cpp | 8 +- polygon/PolyLine.cpp | 175 +-------------------- polygon/PolyLine.h | 30 ++-- polygon/freepcbDisplayList.h | 39 ----- 17 files changed, 169 insertions(+), 340 deletions(-) delete mode 100644 polygon/freepcbDisplayList.h diff --git a/change_log.txt b/change_log.txt index e0920ce33e..24ab7d05be 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,11 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2008-Sep-26 UPDATE Jean-Pierre Charras +================================================================================ ++pcbnew: + more about use polygons in zone fill algos on techinals layers: + plot Ok. holes are handled 2008-Sep-26 UPDATE Jean-Pierre Charras ================================================================================ diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index 54034eedca..0c9228c5c8 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -83,21 +83,30 @@ void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) if( !m_Pcb ) return; - MODULE* Module = m_Pcb->m_Modules; - ActiveScreen = (PCB_SCREEN*) GetScreen(); if( EraseBg ) DrawPanel->EraseScreen( DC ); DrawPanel->DrawBackGround( DC ); + m_Pcb->Draw( DrawPanel, DC, GR_COPY, wxPoint(0,0) ); - if( Module ) - { - Module->Draw( DrawPanel, DC, GR_COPY ); + MODULE* Module = m_Pcb->m_Modules; + if ( Module ) Module->Display_Infos( this ); - } - Affiche_Status_Box(); DrawPanel->Trace_Curseur( DC ); } + + +/********************************************************************/ +void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, + int aDrawMode, const wxPoint& offset ) +/********************************************************************/ +/* Redraw the BOARD items but not cursors, axis or grid */ +{ + if( m_Modules ) + { + m_Modules->Draw( aPanel, DC, GR_COPY ); + } +} diff --git a/gerbview/tracepcb.cpp b/gerbview/tracepcb.cpp index 84affb3869..f743aeeabd 100644 --- a/gerbview/tracepcb.cpp +++ b/gerbview/tracepcb.cpp @@ -29,7 +29,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl { DISPLAY_OPTIONS save_opt; int DisplayPolygonsModeImg; - + save_opt = DisplayOpt; if( printmasklayer & ALL_CU_LAYERS ) DisplayOpt.DisplayPadFill = FILLED; @@ -86,11 +86,19 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) DrawPanel->Trace_Curseur( DC ); } +/********************************************************************/ +void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, + int aDrawMode, const wxPoint& offset ) +/********************************************************************/ +/* Redraw the BOARD items but not cursors, axis or grid */ +// @todo: replace WinEDA_GerberFrame::Trace_Gerber() by this function +{ +} /***********************************************************************************/ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer ) /***********************************************************************************/ -/* +/* * Trace l'ensemble des elements du PCB sur l'ecran actif * @param DC = device context to draw * @param draw_mode = draw mode for the device context (GR_COPY, GR_OR, GR_XOR ..) @@ -104,7 +112,7 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay Draw_Track_Buffer( DrawPanel, DC, m_Pcb, draw_mode, printmasklayer ); // Draw filled polygons - #define NBMAX 2000 + #define NBMAX 20000 TRACK* track; int nbpoints = 0; int nbpointsmax = NBMAX; diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 173860d855..278dc08ad7 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -438,7 +438,6 @@ public: void Liste_Equipot( wxCommandEvent& event ); void Swap_Layers( wxCommandEvent& event ); void Install_Test_DRC_Frame( wxDC* DC ); - void Trace_Pcb( wxDC* DC, int mode ); // Handling texts on the board void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 0a0a3b8f9b..69a27281a6 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -1045,6 +1045,8 @@ out: return rc; } + + /***********************************************************************************************/ void BOARD::RedrawAreasOutlines(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMode, int aLayer) /***********************************************************************************************/ diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 8260fe4bdf..34ee029cb4 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -253,11 +253,7 @@ public: void Display_Infos( WinEDA_DrawFrame* frame ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, - int aDrawMode, const wxPoint& offset = ZeroOffset ) - { - // void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) - // goes here. - } + int aDrawMode, const wxPoint& offset = ZeroOffset ); /** @@ -380,6 +376,7 @@ public: * or net change * Must be called after pad netcodes are calculated * @return : error count + * For non copper areas, netcode is set to 0 */ int SetAreasNetCodesFromNetNames(void); diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index c28d8415b2..b7b6294add 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -368,7 +368,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, /** * Function DrawDrawFilledArea - * Draws the filled area for this zone (polygon list .m_FilledPolysList) + * Draws the filled areas for this zone (polygon list .m_FilledPolysList) * @param panel = current Draw Panel * @param DC = current Device Context * @param offset = Draw offset (usually wxPoint(0,0)) @@ -416,7 +416,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, if( color & HIGHT_LIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; - // draw the filled polygon + // We need a buffer to store corners coordinates: if( CornersBuffer == NULL ) { CornersBufferSize = imax * 4; @@ -429,6 +429,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, CornersBuffer = (int*) realloc( CornersBuffer, CornersBufferSize * sizeof(int) ); } + // Draw all filled areas int corners_count = 0; for( unsigned ic = 0, ii = 0; ic < imax; ic++ ) { @@ -437,9 +438,8 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, CornersBuffer[ii++] = corner->y + offset.y; corners_count++; if( corner->end_contour ) - { - GRPoly( &panel->m_ClipBox, DC, corners_count, CornersBuffer, - 1, 0, color, color ); + { // Draw the current filled area + GRPoly( &panel->m_ClipBox, DC, corners_count, CornersBuffer, true, 0, color, color ); corners_count = 0; ii = 0; } diff --git a/pcbnew/lay2plot.cpp b/pcbnew/lay2plot.cpp index b24ca423fb..93b2594435 100644 --- a/pcbnew/lay2plot.cpp +++ b/pcbnew/lay2plot.cpp @@ -125,6 +125,16 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl } GRForceBlackPen( blackpenstate ); + /* Draw areas (i.e. zones) */ + for( int ii = 0; ii < Pcb->GetAreaCount(); ii++ ) + { + ZONE_CONTAINER* zone = Pcb->GetArea(ii); + if( ( printmasklayer & (1 << zone->GetLayer()) ) == 0 ) + continue; + + zone->DrawFilledArea( this, DC, drawmode ); + } + if( Print_Sheet_Ref ) m_Parent->TraceWorkSheet( DC, ActiveScreen, 0 ); diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 328e02f226..1ba03ba601 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -21,6 +21,7 @@ /* Fonctions locales */ static void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer ); static void PlotTextModule( TEXTE_MODULE* pt_texte ); +static void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat); /**********************************************************/ @@ -46,27 +47,18 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, { case TYPEDRAWSEGMENT: PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format_plot, masque_layer ); - - // (Following line has been superceded by new commands elsewhere.) -// EDGE_LAYER | masque_layer ); break; case TYPETEXTE: PlotTextePcb( (TEXTE_PCB*) PtStruct, format_plot, masque_layer ); - -// EDGE_LAYER | masque_layer ); break; case TYPECOTATION: PlotCotation( (COTATION*) PtStruct, format_plot, masque_layer ); - -// EDGE_LAYER | masque_layer ); break; case TYPEMIRE: PlotMirePcb( (MIREPCB*) PtStruct, format_plot, masque_layer ); - -// EDGE_LAYER | masque_layer ); break; case TYPEMARKER: @@ -303,6 +295,15 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, } } + /* Plot filled ares */ + for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) + { + ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii); + if( ( (1 << edge_zone->GetLayer()) & masque_layer ) == 0 ) + continue; + PlotFilledAreas(edge_zone, format_plot); + } + exit: ; } @@ -704,6 +705,48 @@ void Affiche_erreur( int nb_err ) // Affiche_1_Parametre(this, 30,"Err",msg,GREEN) ; } +/*********************************************************/ +void PlotFilledAreas( ZONE_CONTAINER * aZone, int aFormat ) +/*********************************************************/ +/* Plot areas (given by .m_FilledPolysList member) in a zone +*/ +{ + static int* CornersBuffer = NULL; + static unsigned CornersBufferSize = 0; + unsigned imax = aZone->m_FilledPolysList.size(); + + if( imax == 0 ) // Nothing to draw + return; + + // We need a buffer to store corners coordinates: + if( CornersBuffer == NULL ) + { + CornersBufferSize = imax * 4; + CornersBuffer = (int*) MyMalloc( CornersBufferSize * sizeof(int) ); + } + + if( (imax * 4) > CornersBufferSize ) + { + CornersBufferSize = imax * 4; + CornersBuffer = (int*) realloc( CornersBuffer, CornersBufferSize * sizeof(int) ); + } + + // Plot all filled areas + int corners_count = 0; + for( unsigned ic = 0, ii = 0; ic < imax; ic++ ) + { + CPolyPt* corner = &aZone->m_FilledPolysList[ic]; + CornersBuffer[ii++] = corner->x; + CornersBuffer[ii++] = corner->y; + corners_count++; + if( corner->end_contour ) + { // Plot the current filled area + PlotPolygon( aFormat, true, corners_count, CornersBuffer ); + corners_count = 0; + ii = 0; + } + } +} /******************************************************************************/ void PlotDrawSegment( DRAWSEGMENT* pt_segm, int Format, int masque_layer ) diff --git a/pcbnew/protos.h b/pcbnew/protos.h index ec491b1cc5..ba2c408df9 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -41,16 +41,11 @@ void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector* aVector ); bool Read_Config( const wxString& project_name ); bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ); -/***************/ -/* TRACEPCB.CPP */ -/***************/ -void Trace_MirePcb( WinEDA_DrawPanel* panel, wxDC* DC, MIREPCB* MirePcb, int mode_color ); /***************/ /* TRPISTE.CPP */ /***************/ -void Trace_Pistes( WinEDA_DrawPanel* panel, BOARD* Pcb, wxDC* DC, int drawmode ); void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* pt_start_piste, @@ -282,14 +277,6 @@ void ListSetState( EDA_BaseStruct* Start, int Nbitem, int State, int onoff ); /* Met a jour le membre .state d'une chaine de structures */ -/*****************/ -/* EDITEDGE.CPP : */ -/*****************/ -void Trace_1_Edge( WinEDA_DrawPanel* panel, - wxDC* DC, - TRACK* start_edge, - int nbpoint, - int mode_color ); /************/ /* DRC.CPP : */ @@ -409,11 +396,6 @@ void RemoteCommand( const char* cmdline ); bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ); -/***************/ -/* AUTOPLACE.CPP */ -/***************/ -int Calcule_Encadrement_EdgeBoard(); - /***************/ /* AUTOROUT.CPP */ /***************/ @@ -429,10 +411,6 @@ MODULE* ListAndSelectModuleName( COMMAND* Cmd ); * Retourne un pointeur sur le module selectionne * ( ou NULL si pas de selection ) */ -/***************/ -/* LAY2PLOT.CPP */ -/***************/ - /*****************/ /* SET_COLOR.CPP */ /*****************/ diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 203584bac4..a6f0086a06 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -87,7 +87,13 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) TraceWorkSheet( DC, GetScreen(), 0 ); - Trace_Pcb( DC, GR_OR ); + m_Pcb->Draw( DrawPanel, DC, GR_OR ); + if( g_HightLigt_Status ) + DrawHightLight( DC, g_HightLigth_NetCode ); + + DrawGeneralRatsnest( DC ); + + GetScreen()->ClrRefreshReq(); Affiche_Status_Box(); @@ -99,21 +105,13 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) } -/* should make the function below this one: -void BOARD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, - int aDrawMode, const wxPoint& offset = ZeroOffset ); -*/ - - -/****************************************************/ -void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) -/****************************************************/ +/********************************************************************/ +void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, + int aDrawMode, const wxPoint& offset ) +/********************************************************************/ /* Redraw the BOARD items but not cursors, axis or grid */ { - if( !m_Pcb ) - return; - - for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) + for( MODULE* module = m_Modules; module; module = module->Next() ) { bool display = true; int layerMask = ALL_CU_LAYERS; @@ -136,14 +134,14 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) } if( display ) - module->Draw( DrawPanel, DC, mode ); + module->Draw( aPanel, DC, aDrawMode ); else - Trace_Pads_Only( DrawPanel, DC, module, 0, 0, layerMask, mode ); + Trace_Pads_Only( aPanel, DC, module, 0, 0, layerMask, aDrawMode ); } // Draw the graphic items - for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() ) + for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) { if( item->m_Flags & IS_MOVED ) continue; @@ -154,7 +152,7 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) case TYPETEXTE: case TYPEMIRE: case TYPEDRAWSEGMENT: - item->Draw( DrawPanel, DC, mode ); + item->Draw( aPanel, DC, aDrawMode ); break; default: @@ -162,31 +160,40 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) } } - Trace_Pistes( DrawPanel, m_Pcb, DC, mode ); - if( g_HightLigt_Status ) - DrawHightLight( DC, g_HightLigth_NetCode ); - - for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) + /* Draw all tracks and zones. As long as dark colors are used for the tracks, + * Then the OR draw mode should show tracks underneath other tracks. But a white + * track will cover any other color since it has more bits to OR in. + */ + for( TRACK* track = m_Track; track; track = track->Next() ) { - ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii); + track->Draw( aPanel, DC, aDrawMode ); + } + + for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() ) + { + zone->Draw( aPanel, DC, aDrawMode ); + } + + + /* Draw areas (i.e. zones) */ + for( int ii = 0; ii < GetAreaCount(); ii++ ) + { + ZONE_CONTAINER* zone = GetArea(ii); // Areas must be drawn here only if not moved or dragged, // because these areas are drawn by ManageCursor() in a specific manner - if ( (edge_zone->m_Flags & (IN_EDIT | IS_DRAGGED | IS_MOVED)) == 0 ) + if ( (zone->m_Flags & (IN_EDIT | IS_DRAGGED | IS_MOVED)) == 0 ) { - edge_zone->Draw( DrawPanel, DC, mode ); - edge_zone->DrawFilledArea( DrawPanel, DC, mode ); + zone->Draw( aPanel, DC, aDrawMode ); + zone->DrawFilledArea( aPanel, DC, aDrawMode ); } } // draw the BOARD's markers. - for( unsigned i=0; im_markers.size(); ++i ) + for( unsigned i=0; i < m_markers.size(); ++i ) { - m_Pcb->m_markers[i]->Draw( DrawPanel, DC, mode ); + m_markers[i]->Draw( aPanel, DC, aDrawMode ); } - - DrawGeneralRatsnest( DC ); - - GetScreen()->ClrRefreshReq(); } + diff --git a/pcbnew/trpiste.cpp b/pcbnew/trpiste.cpp index 745bafcbc8..0211ba702f 100644 --- a/pcbnew/trpiste.cpp +++ b/pcbnew/trpiste.cpp @@ -13,26 +13,6 @@ /* variables locales : */ -/*********************************************************************************/ -void Trace_Pistes( WinEDA_DrawPanel* panel, BOARD* Pcb, wxDC* DC, int drawmode ) -/********************************************************************************/ - -/* Draw all tracks and zones. As long as dark colors are used for the tracks, - * Then the OR draw mode should show tracks underneath other tracks. But a white - * track will cover any other color since it has more bits to OR in. - */ -{ - for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) - { - track->Draw( panel, DC, drawmode ); - } - - for( SEGZONE* zone = Pcb->m_Zone; zone; zone = zone->Next() ) - { - zone->Draw( panel, DC, drawmode ); - } -} - /************************************************************************/ void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track, diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 2fd03186c7..6378790ee7 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -939,10 +939,11 @@ int WinEDA_PcbFrame::Fill_All_Zones( wxDC* DC, bool verbose ) * Function SetAreasNetCodesFromNetNames * Set the .m_NetCode member of all copper areas, according to the area Net Name * The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons. - * However the Netcode is an arbitrary equyivalence, it must be set after each netlist read + * However the Netcode is an arbitrary equivalence, it must be set after each netlist read * or net change * Must be called after pad netcodes are calculated * @return : error count + * For non copper areas, netcode is set to 0 */ int BOARD::SetAreasNetCodesFromNetNames( void ) { @@ -950,6 +951,12 @@ int BOARD::SetAreasNetCodesFromNetNames( void ) for( int ii = 0; ii < GetAreaCount(); ii++ ) { + if ( ! GetArea( ii )->IsOnCopperLayer() ) + { + GetArea( ii )->SetNet( 0 ); + continue; + } + const EQUIPOT* net = FindNet( GetArea( ii )->m_Netname ); if( net ) { diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp index 5857452e47..de8e5992be 100644 --- a/pcbnew/zones_non_copper_type_functions.cpp +++ b/pcbnew/zones_non_copper_type_functions.cpp @@ -59,7 +59,7 @@ bool InstallDialogNonCopperZonesEditor(WinEDA_PcbFrame* aParent, ZONE_CONTAINER* DialogNonCopperZonesEditor* frame = new DialogNonCopperZonesEditor( aParent, aZone ); bool diag = frame->ShowModal(); frame->Destroy(); - + return diag; } @@ -90,7 +90,7 @@ void DialogNonCopperZonesEditor::InitDialog( wxInitDialogEvent& event ) } for( int layer_number = FIRST_NO_COPPER_LAYER, ii = 0; - layer_number < LAST_NO_COPPER_LAYER - 1; + layer_number <= LAST_NO_COPPER_LAYER; layer_number++, ii++ ) { wxString msg; @@ -109,7 +109,7 @@ void DialogNonCopperZonesEditor::InitDialog( wxInitDialogEvent& event ) m_LayerSelectionCtrl->SetSelection( ii ); } } - + /* the size of m_LayerSelectionCtrl has changed, so we must recall SetSizeHints() */ GetSizer()->SetSizeHints(this); } @@ -205,6 +205,6 @@ int ZONE_CONTAINER::BuildFilledPolysListData( void ) } m_Poly->FreeKboolEngine(); - + return count; } diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index c8867cb2ac..65b2ca66db 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -288,7 +288,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector< // Fill a kbool engine for this contour, // and combine it with previous contours Bool_Engine* booleng = new Bool_Engine(); - ArmBoolEng( booleng ); + ArmBoolEng( booleng, aConvertHoles ); if( m_Kbool_Poly_Engine ) // a previous contour exists. Put it in new engine { @@ -751,15 +751,6 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw ) side_style.push_back( style ); if( corner.size() > 0 && !corner[corner.size() - 1].end_contour ) side_style[corner.size() - 1] = style; - int dl_type; - if( style == CPolyLine::STRAIGHT ) - dl_type = DL_LINE; - else if( style == CPolyLine::ARC_CW ) - dl_type = DL_ARC_CW; - else if( style == CPolyLine::ARC_CCW ) - dl_type = DL_ARC_CCW; - else - wxASSERT( 0 ); if( bDraw ) Draw(); } @@ -1552,170 +1543,6 @@ void CPolyLine::SetEndContour( int ic, bool end_contour ) } -// Create CPolyLine for a pad -// -CPolyLine* CPolyLine::MakePolylineForPad( int type, int x, int y, int w, int l, int r, int angle ) -{ - CPolyLine* poly = new CPolyLine; - int dx = l / 2; - int dy = w / 2; - - if( angle % 180 == 90 ) - { - dx = w / 2; - dy = l / 2; - } - if( type == PAD_ROUND ) - { - poly->Start( 0, x - dx, y, 0 ); - poly->AppendCorner( x, y + dy, ARC_CW, 0 ); - poly->AppendCorner( x + dx, y, ARC_CW, 0 ); - poly->AppendCorner( x, y - dy, ARC_CW, 0 ); - poly->Close( ARC_CW ); - } - return poly; -} - - -// Add cutout for a pad -// Convert arcs to multiple straight lines -// Do NOT draw or undraw -// -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 dx = l / 2; - int dy = w / 2; - - if( angle % 180 == 90 ) - { - dx = w / 2; - dy = l / 2; - } - int x_clearance = max( fill_clearance, hole_clearance + hole_w / 2 - dx ); - int y_clearance = max( fill_clearance, hole_clearance + hole_w / 2 - dy ); - dx += x_clearance; - dy += y_clearance; - if( !bThermal ) - { - // normal clearance - if( type == PAD_ROUND || (type == PAD_NONE && hole_w > 0) ) - { - AppendCorner( x - dx, y, ARC_CW, 0 ); - AppendCorner( x, y + dy, ARC_CW, 0 ); - AppendCorner( x + dx, y, ARC_CW, 0 ); - AppendCorner( x, y - dy, ARC_CW, 0 ); - Close( ARC_CW ); - } - else if( type == PAD_SQUARE || type == PAD_RECT - || type == PAD_RRECT || type == PAD_OVAL ) - { - AppendCorner( x - dx, y - dy, STRAIGHT, 0 ); - AppendCorner( x + dx, y - dy, STRAIGHT, 0 ); - AppendCorner( x + dx, y + dy, STRAIGHT, 0 ); - AppendCorner( x - dx, y + dy, STRAIGHT, 0 ); - Close( STRAIGHT ); - } - } - else - { - // thermal relief - if( type == PAD_ROUND || (type == PAD_NONE && hole_w > 0) ) - { - // draw 4 "wedges" - double r = max( w / 2 + fill_clearance, hole_w / 2 + hole_clearance ); - double start_angle = asin( spoke_w / (2.0 * r) ); - double th1, th2, corner_x, corner_y; - th1 = th2 = corner_x = corner_y = 0; // gcc warning fix - for( int i = 0; i<4; i++ ) - { - if( i == 0 ) - { - corner_x = spoke_w / 2; - corner_y = spoke_w / 2; - th1 = start_angle; - th2 = pi / 2.0 - start_angle; - } - else if( i == 1 ) - { - corner_x = -spoke_w / 2; - corner_y = spoke_w / 2; - th1 = pi / 2.0 + start_angle; - th2 = pi - start_angle; - } - else if( i == 2 ) - { - corner_x = -spoke_w / 2; - corner_y = -spoke_w / 2; - th1 = -pi + start_angle; - th2 = -pi / 2.0 - start_angle; - } - else if( i == 3 ) - { - corner_x = spoke_w / 2; - corner_y = -spoke_w / 2; - th1 = -pi / 2.0 + start_angle; - th2 = -start_angle; - } - AppendCorner( to_int( x + corner_x ), to_int( y + corner_y ), STRAIGHT, 0 ); - AppendCorner( to_int( x + r * cos( th1 ) ), to_int( y + r * sin( - th1 ) ), STRAIGHT, 0 ); - AppendCorner( to_int( x + r * cos( th2 ) ), to_int( y + r * sin( - th2 ) ), ARC_CCW, 0 ); - Close( STRAIGHT ); - } - } - else if( type == PAD_SQUARE || type == PAD_RECT - || type == PAD_RRECT || type == PAD_OVAL ) - { - // draw 4 rectangles - int xL = x - dx; - int xR = x - spoke_w / 2; - int yB = y - dy; - int yT = y - spoke_w / 2; - AppendCorner( xL, yB, STRAIGHT, 0 ); - AppendCorner( xR, yB, STRAIGHT, 0 ); - AppendCorner( xR, yT, STRAIGHT, 0 ); - AppendCorner( xL, yT, STRAIGHT, 0 ); - Close( STRAIGHT ); - xL = x + spoke_w / 2; - xR = x + dx; - AppendCorner( xL, yB, STRAIGHT, 0 ); - AppendCorner( xR, yB, STRAIGHT, 0 ); - AppendCorner( xR, yT, STRAIGHT, 0 ); - AppendCorner( xL, yT, STRAIGHT, 0 ); - Close( STRAIGHT ); - xL = x - dx; - xR = x - spoke_w / 2; - yB = y + spoke_w / 2; - yT = y + dy; - AppendCorner( xL, yB, STRAIGHT, 0 ); - AppendCorner( xR, yB, STRAIGHT, 0 ); - AppendCorner( xR, yT, STRAIGHT, 0 ); - AppendCorner( xL, yT, STRAIGHT, 0 ); - Close( STRAIGHT ); - xL = x + spoke_w / 2; - xR = x + dx; - AppendCorner( xL, yB, STRAIGHT, 0 ); - AppendCorner( xR, yB, STRAIGHT, 0 ); - AppendCorner( xR, yT, STRAIGHT, 0 ); - AppendCorner( xL, yT, STRAIGHT, 0 ); - Close( STRAIGHT ); - } - } - return; -} - void CPolyLine::AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num ) { diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 3666cb9749..dd19c87bc6 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -9,7 +9,7 @@ // separated by setting the end_contour flag of the last corner of // each contour. // -// When used for copper areas, the first contour is the outer edge +// When used for copper (or technical layers) areas, the first contour is the outer edge // of the area, subsequent ones are "holes" in the copper. #ifndef POLYLINE_H @@ -18,9 +18,18 @@ #include #include "kbool/include/booleng.h" -#include "freepcbDisplayList.h" #include "pad_shapes.h" +// inflection modes for DS_LINE and DS_LINE_VERTEX, used in math_for_graphics.cpp +enum +{ + IM_NONE = 0, + IM_90_45, + IM_45_90, + IM_90 +}; + + /** Function ArmBoolEng * Initialise parameters used in kbool @@ -159,19 +168,6 @@ public: void SetSideStyle( int is, int style ); int RestoreArcs( std::vector * arc_array, std::vector * 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 NormalizeAreaOutlines( std::vector * pa = NULL, bool bRetainArcs = FALSE ); @@ -222,7 +218,7 @@ public: * @return number of external contours, or -1 if error */ int NormalizeWithKbool( std::vector * aExtraPolyList, bool bRetainArcs ); - + /** function GetKboolEngine * @return the current used Kbool Engine (after normalization using kbool) */ @@ -231,7 +227,7 @@ public: * delete the current used Kbool Engine (free memory after normalization using kbool) */ void FreeKboolEngine( ) { delete m_Kbool_Poly_Engine; m_Kbool_Poly_Engine = NULL; } - + private: int m_layer; // layer to draw on diff --git a/polygon/freepcbDisplayList.h b/polygon/freepcbDisplayList.h deleted file mode 100644 index 04e7ffdf80..0000000000 --- a/polygon/freepcbDisplayList.h +++ /dev/null @@ -1,39 +0,0 @@ -// DisplayList.h : header file for CDisplayList class -// - -#ifndef FP_DISPLAY_LIST_H -#define FP_DISPLAY_LIST_H - -// graphics element types -enum -{ - DL_NONE = 0, - DL_LINE, // line segment with round end-caps - DL_CIRC, // filled circle - DL_HOLLOW_CIRC, // circle outline - DL_DONUT, // annulus - DL_SQUARE, // filled square - DL_RECT, // filled rectangle - DL_RRECT, // filled rounded rectangle - DL_OVAL, // filled oval - DL_OCTAGON, // filled octagon - DL_HOLE, // hole, shown as circle - DL_HOLLOW_RECT, // rectangle outline - DL_RECT_X, // rectangle outline with X - DL_POINT, // shape to highlight a point - DL_ARC_CW, // arc with clockwise curve - DL_ARC_CCW, // arc with counter-clockwise curve - DL_X // X -}; - -// inflection modes for DS_LINE and DS_LINE_VERTEX -enum -{ - IM_NONE = 0, - IM_90_45, - IM_45_90, - IM_90 -}; - - -#endif // #ifndef FP_DISPLAY_LIST_H