Loading CHANGELOG.txt +19 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,24 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. 2010-sept-28, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> ================================================================================ ++gerbview: Important changes: graphic functions rewritten. graphics items are now specific to gerbview (added a GERBER_DRAW_ITEM class) and do not use tracks from pcbnew. The way used to draw them is also new. Apertures are now correctly drawn for round, oval and rectangular shapes (with or without holes) Aperture definition type Polygon is not yet handle. Polygons are correctly drawn. TODO: Draw functions for aperture definition type Polygon. Draw functions for aperture macros. Work in progress. 2010-Aug-9 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ ++CMakeModules: Loading Loading @@ -67,7 +85,7 @@ email address. 2010-jul-27, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> ================================================================================ ++all: Updated boost to version 1.43 Updated boost to version 1.44 Added boost::polygon (experimental) ++pcbnew: Added experimental zone fill calculations with boost::polygon Loading common/gr_basic.cpp +36 −20 Original line number Diff line number Diff line Loading @@ -58,6 +58,10 @@ int g_DrawBgColor = WHITE; void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n ); #endif static void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ); static void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color, int BgColor ); extern BASE_SCREEN* ActiveScreen; Loading Loading @@ -1333,6 +1337,26 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color ) GRSCircle( ClipBox, DC, cx, cy, radius, 0, Color ); } /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ) { r = ZoomValue( r ); width = ZoomValue( width ); GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color ); } /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor ) { aRadius = ZoomValue( aRadius ); aWidth = ZoomValue( aWidth ); GRSCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, aWidth, aColor ); } /* * Draw a filled circle, in object space. Loading @@ -1346,6 +1370,14 @@ void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, Color, BgColor ); } /* * Draw a filled circle, in object space. */ void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor ) { aRadius = ZoomValue( aRadius ); GRSFilledCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, 0, aColor, aColor ); } /* * Draw a filled circle, in drawing space. Loading Loading @@ -1377,22 +1409,6 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, } /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ) { r = ZoomValue( r ); width = ZoomValue( width ); GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color ); } /* * Draw a circle in drawing space. Loading gerbview/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ### set(GERBVIEW_SRCS block.cpp class_GERBER.cpp class_gerber_draw_item.cpp class_gerbview_layer_widget.cpp controle.cpp dcode.cpp Loading @@ -32,7 +34,6 @@ set(GERBVIEW_SRCS gerbview.cpp hotkeys.cpp initpcb.cpp lay2plot.cpp locate.cpp menubar.cpp onrightclick.cpp Loading gerbview/block.cpp +65 −186 Original line number Diff line number Diff line Loading @@ -2,6 +2,30 @@ /* Block operations: displacement, rotation, deletion ... */ /**********************************************************/ /* * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2010 <Jean-Pierre Charras> * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "fctsys.h" #include "gr_basic.h" Loading @@ -11,6 +35,7 @@ #include "confirm.h" #include "gerbview.h" #include "class_gerber_draw_item.h" #include "protos.h" Loading @@ -21,7 +46,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm ); static bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ); /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to Loading Loading @@ -168,21 +193,10 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) Block_Delete( DC ); break; case BLOCK_MIRROR_X: /* Mirror*/ GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); Block_Mirror_X( DC ); break; case BLOCK_MIRROR_X: /* Mirror, unused*/ case BLOCK_ROTATE: /* Unused */ break; case BLOCK_FLIP: /* Flip, unused */ break; case BLOCK_SAVE: /* Save (not used)*/ break; case BLOCK_PASTE: break; Loading Loading @@ -273,28 +287,14 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) GetScreen()->m_BlockLocate.Normalize(); GetScreen()->SetCurItem( NULL ); TRACK* pt_segm, * NextS; for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS ) { NextS = pt_segm->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) ) { /* the track here is good to be cleared */ pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->DeleteStructure(); } } /* Erasing areas. */ for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS ) { NextS = pt_segm->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) ) BOARD_ITEM* item = GetBoard()->m_Drawings; BOARD_ITEM* nextitem; for( ; item; item = nextitem ) { /* The track here is good to be cleared. */ pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->DeleteStructure(); } nextitem = item->Next(); GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) gerb_item->DeleteStructure(); } Refresh(); Loading @@ -320,106 +320,13 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) /* Calculate displacement vectors. */ delta = GetScreen()->m_BlockLocate.m_MoveVector; /* Move the Track segments in block */ TRACK* track = m_Pcb->m_Track; while( track ) /* Move items in block */ BOARD_ITEM* item = GetBoard()->m_Drawings; for( ; item; item = item->Next() ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) { m_Pcb->m_Status_Pcb = 0; track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->m_Start += delta; track->m_End += delta; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center. track->m_Param += delta.x; track->SetSubNet( track->GetSubNet() + delta.y ); track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track } track = track->Next(); } /* Move the Zone segments in block */ SEGZONE* zsegment = m_Pcb->m_Zone; while( zsegment ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) { zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->m_Start += delta; zsegment->m_End += delta; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center zsegment->m_Param += delta.x; zsegment->SetSubNet( zsegment->GetSubNet() + delta.y ); zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone // segment } zsegment = zsegment->Next(); } DrawPanel->Refresh( TRUE ); } /* * Function to mirror items in the current selected block */ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC ) { int xoffset = 0; wxPoint oldpos; oldpos = GetScreen()->m_Curseur; DrawPanel->ManageCurseur = NULL; GetScreen()->m_Curseur = oldpos; DrawPanel->MouseToCursorSchema(); GetScreen()->SetModify(); GetScreen()->m_BlockLocate.Normalize(); /* Calculate offset to mirror track points from block edges */ xoffset = GetScreen()->m_BlockLocate.m_Pos.x + GetScreen()->m_BlockLocate.m_Pos.x + GetScreen()->m_BlockLocate.m_Size.x; /* Move the Track segments in block */ for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) { m_Pcb->m_Status_Pcb = 0; track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->m_Start.x = xoffset - track->m_Start.x; track->m_End.x = xoffset - track->m_End.x; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center track->m_Param = xoffset - track->m_Param; track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track } } /* Move the Zone segments in block */ for( SEGZONE* zsegment = m_Pcb->m_Zone; zsegment; zsegment = zsegment->Next() ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) { zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->m_Start.x = xoffset - zsegment->m_Start.x; zsegment->m_End.x = xoffset - zsegment->m_End.x; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center zsegment->m_Param = xoffset - zsegment->m_Param; zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone // segment } GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) gerb_item->Move( delta ); } DrawPanel->Refresh( TRUE ); Loading @@ -444,62 +351,34 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) delta = GetScreen()->m_BlockLocate.m_MoveVector; /* Copy selected track segments and move the new track its new location */ TRACK* track = m_Pcb->m_Track; while( track ) /* Copy items in block */ BOARD_ITEM* item = GetBoard()->m_Drawings; for( ; item; item = item->Next() ) { TRACK* next_track = track->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) { /* this track segment must be duplicated */ m_Pcb->m_Status_Pcb = 0; TRACK* new_track = track->Copy(); m_Pcb->Add( new_track ); new_track->m_Start += delta; new_track->m_End += delta; new_track->Draw( DrawPanel, DC, GR_OR ); // draw the new created // segment /* this item must be duplicated */ BOARD_ITEM* new_item = gerb_item->Copy(); new_item->Move( delta ); GetBoard()->m_Drawings.PushFront( new_item ); } track = next_track; } /* Copy the Zone segments and move the new segment to its new location */ SEGZONE* zsegment = m_Pcb->m_Zone; while( zsegment ) { SEGZONE* next_zsegment = zsegment->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) { /* this zone segment must be duplicated */ SEGZONE* new_zsegment = (SEGZONE*) zsegment->Copy(); m_Pcb->Add( new_zsegment ); new_zsegment->m_Start += delta; new_zsegment->m_End += delta; new_zsegment->Draw( DrawPanel, DC, GR_OR ); // draw the new created // segment } zsegment = next_zsegment; } DrawPanel->Refresh(); } /* Test if the structure PtStruct is listed in the block selects * Returns whether PtSegm * NULL if not /* Test if the structure PtStruct is inside the block * Returns true or false */ static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm ) bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ) { if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) ) return PtSegm; if( aBlocklocate.Inside( aItem->m_Start ) ) return true; if( blocklocate.Inside( PtSegm->m_End.x, PtSegm->m_End.y ) ) return PtSegm; if( aBlocklocate.Inside( aItem->m_End ) ) return true; return NULL; return false; } gerbview/class_GERBER.cpp 0 → 100644 +190 −0 Original line number Diff line number Diff line /** @file class_GERBER.cpp * a GERBER class handle for a given layer info about used D_CODES and how the layer is drawn */ /* * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2010 <Jean-Pierre Charras> * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "fctsys.h" #include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "macros.h" #include "gerbview.h" /* Format Gerber: NOTES: * Tools and D_CODES * tool number (identification of shapes) * 1 to 999 * * D_CODES: * D01 ... D9 = action codes: * D01 = activating light (lower pen) when di placement * D02 = light extinction (lift pen) when di placement * D03 Flash * D09 = VAPE Flash * D10 ... = Indentification Tool (Opening) * * For tools: * DCode min = D10 * DCode max = 999 */ GERBER::GERBER( int aLayer ) { m_Layer = aLayer; // Layer Number m_Selected_Tool = FIRST_DCODE; ResetDefaultValues(); for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) m_Aperture_List[ii] = 0; m_Pcb = 0; } GERBER::~GERBER() { for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) { delete m_Aperture_List[ii]; // m_Aperture_List[ii] = NULL; } delete m_Pcb; } D_CODE* GERBER::GetDCODE( int aDCODE, bool create ) { unsigned ndx = aDCODE - FIRST_DCODE; if( ndx < (unsigned) DIM( m_Aperture_List ) ) { // lazily create the D_CODE if it does not exist. if( create ) { if( m_Aperture_List[ndx] == NULL ) m_Aperture_List[ndx] = new D_CODE( ndx + FIRST_DCODE ); } return m_Aperture_List[ndx]; } return NULL; } APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup ) { APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup ); if( iter != m_aperture_macros.end() ) { APERTURE_MACRO* pam = (APERTURE_MACRO*) &(*iter); return pam; } return NULL; // not found } void GERBER::ResetDefaultValues() { m_FileName.Empty(); m_Name = wxT( "no name" ); // Layer name m_LayerNegative = FALSE; // TRUE = Negative Layer m_ImageNegative = FALSE; // TRUE = Negative image m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric m_Relative = FALSE; // FALSE = absolute Coord, RUE = // relative Coord m_NoTrailingZeros = FALSE; // True: trailing zeros deleted m_MirorA = FALSE; // True: miror / axe A (X) m_MirorB = FALSE; // True: miror / axe B (Y) m_Has_DCode = FALSE; // TRUE = DCodes in file (FALSE = no // DCode-> // separate DCode file m_Offset.x = m_Offset.y = 0; // Coord Offset m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10; m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10); m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X and Y) this // layer m_Rotation = 0; m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_360Arc_enbl = FALSE; // 360 deg circular // interpolation disable m_Current_Tool = 0; // Current Tool (Dcode) // number selected m_CommandState = 0; // gives tate of the // stacking order analysis m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord // for plot m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified // coord for plot m_IJPos.x = m_IJPos.y = 0; // current centre coord for // plot arcs & circles m_Current_File = NULL; // File to read m_FilesPtr = 0; m_Transform[0][0] = m_Transform[1][1] = 1; m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal m_PolygonFillMode = FALSE; m_PolygonFillModeState = 0; } int GERBER::ReturnUsedDcodeNumber() { int count = 0; for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) { if( m_Aperture_List[ii] ) if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined ) ++count; } return count; } void GERBER::InitToolTable() { for( int count = 0; count < TOOLS_MAX_COUNT; count++ ) { if( m_Aperture_List[count] == NULL ) continue; m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE; m_Aperture_List[count]->Clear_D_CODE_Data(); } } Loading
CHANGELOG.txt +19 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,24 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. 2010-sept-28, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> ================================================================================ ++gerbview: Important changes: graphic functions rewritten. graphics items are now specific to gerbview (added a GERBER_DRAW_ITEM class) and do not use tracks from pcbnew. The way used to draw them is also new. Apertures are now correctly drawn for round, oval and rectangular shapes (with or without holes) Aperture definition type Polygon is not yet handle. Polygons are correctly drawn. TODO: Draw functions for aperture definition type Polygon. Draw functions for aperture macros. Work in progress. 2010-Aug-9 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ ++CMakeModules: Loading Loading @@ -67,7 +85,7 @@ email address. 2010-jul-27, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> ================================================================================ ++all: Updated boost to version 1.43 Updated boost to version 1.44 Added boost::polygon (experimental) ++pcbnew: Added experimental zone fill calculations with boost::polygon Loading
common/gr_basic.cpp +36 −20 Original line number Diff line number Diff line Loading @@ -58,6 +58,10 @@ int g_DrawBgColor = WHITE; void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n ); #endif static void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ); static void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color, int BgColor ); extern BASE_SCREEN* ActiveScreen; Loading Loading @@ -1333,6 +1337,26 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color ) GRSCircle( ClipBox, DC, cx, cy, radius, 0, Color ); } /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ) { r = ZoomValue( r ); width = ZoomValue( width ); GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color ); } /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor ) { aRadius = ZoomValue( aRadius ); aWidth = ZoomValue( aWidth ); GRSCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, aWidth, aColor ); } /* * Draw a filled circle, in object space. Loading @@ -1346,6 +1370,14 @@ void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, Color, BgColor ); } /* * Draw a filled circle, in object space. */ void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor ) { aRadius = ZoomValue( aRadius ); GRSFilledCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, 0, aColor, aColor ); } /* * Draw a filled circle, in drawing space. Loading Loading @@ -1377,22 +1409,6 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, } /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ) { r = ZoomValue( r ); width = ZoomValue( width ); GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color ); } /* * Draw a circle in drawing space. Loading
gerbview/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ### set(GERBVIEW_SRCS block.cpp class_GERBER.cpp class_gerber_draw_item.cpp class_gerbview_layer_widget.cpp controle.cpp dcode.cpp Loading @@ -32,7 +34,6 @@ set(GERBVIEW_SRCS gerbview.cpp hotkeys.cpp initpcb.cpp lay2plot.cpp locate.cpp menubar.cpp onrightclick.cpp Loading
gerbview/block.cpp +65 −186 Original line number Diff line number Diff line Loading @@ -2,6 +2,30 @@ /* Block operations: displacement, rotation, deletion ... */ /**********************************************************/ /* * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2010 <Jean-Pierre Charras> * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "fctsys.h" #include "gr_basic.h" Loading @@ -11,6 +35,7 @@ #include "confirm.h" #include "gerbview.h" #include "class_gerber_draw_item.h" #include "protos.h" Loading @@ -21,7 +46,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm ); static bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ); /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to Loading Loading @@ -168,21 +193,10 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) Block_Delete( DC ); break; case BLOCK_MIRROR_X: /* Mirror*/ GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); Block_Mirror_X( DC ); break; case BLOCK_MIRROR_X: /* Mirror, unused*/ case BLOCK_ROTATE: /* Unused */ break; case BLOCK_FLIP: /* Flip, unused */ break; case BLOCK_SAVE: /* Save (not used)*/ break; case BLOCK_PASTE: break; Loading Loading @@ -273,28 +287,14 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) GetScreen()->m_BlockLocate.Normalize(); GetScreen()->SetCurItem( NULL ); TRACK* pt_segm, * NextS; for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS ) { NextS = pt_segm->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) ) { /* the track here is good to be cleared */ pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->DeleteStructure(); } } /* Erasing areas. */ for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS ) { NextS = pt_segm->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) ) BOARD_ITEM* item = GetBoard()->m_Drawings; BOARD_ITEM* nextitem; for( ; item; item = nextitem ) { /* The track here is good to be cleared. */ pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->DeleteStructure(); } nextitem = item->Next(); GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) gerb_item->DeleteStructure(); } Refresh(); Loading @@ -320,106 +320,13 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) /* Calculate displacement vectors. */ delta = GetScreen()->m_BlockLocate.m_MoveVector; /* Move the Track segments in block */ TRACK* track = m_Pcb->m_Track; while( track ) /* Move items in block */ BOARD_ITEM* item = GetBoard()->m_Drawings; for( ; item; item = item->Next() ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) { m_Pcb->m_Status_Pcb = 0; track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->m_Start += delta; track->m_End += delta; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center. track->m_Param += delta.x; track->SetSubNet( track->GetSubNet() + delta.y ); track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track } track = track->Next(); } /* Move the Zone segments in block */ SEGZONE* zsegment = m_Pcb->m_Zone; while( zsegment ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) { zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->m_Start += delta; zsegment->m_End += delta; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center zsegment->m_Param += delta.x; zsegment->SetSubNet( zsegment->GetSubNet() + delta.y ); zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone // segment } zsegment = zsegment->Next(); } DrawPanel->Refresh( TRUE ); } /* * Function to mirror items in the current selected block */ void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC ) { int xoffset = 0; wxPoint oldpos; oldpos = GetScreen()->m_Curseur; DrawPanel->ManageCurseur = NULL; GetScreen()->m_Curseur = oldpos; DrawPanel->MouseToCursorSchema(); GetScreen()->SetModify(); GetScreen()->m_BlockLocate.Normalize(); /* Calculate offset to mirror track points from block edges */ xoffset = GetScreen()->m_BlockLocate.m_Pos.x + GetScreen()->m_BlockLocate.m_Pos.x + GetScreen()->m_BlockLocate.m_Size.x; /* Move the Track segments in block */ for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) { m_Pcb->m_Status_Pcb = 0; track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->m_Start.x = xoffset - track->m_Start.x; track->m_End.x = xoffset - track->m_End.x; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center track->m_Param = xoffset - track->m_Param; track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track } } /* Move the Zone segments in block */ for( SEGZONE* zsegment = m_Pcb->m_Zone; zsegment; zsegment = zsegment->Next() ) { if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) { zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->m_Start.x = xoffset - zsegment->m_Start.x; zsegment->m_End.x = xoffset - zsegment->m_End.x; // the two parameters are used in gerbview to store center // coordinates for arcs. Move this center zsegment->m_Param = xoffset - zsegment->m_Param; zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone // segment } GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) gerb_item->Move( delta ); } DrawPanel->Refresh( TRUE ); Loading @@ -444,62 +351,34 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) delta = GetScreen()->m_BlockLocate.m_MoveVector; /* Copy selected track segments and move the new track its new location */ TRACK* track = m_Pcb->m_Track; while( track ) /* Copy items in block */ BOARD_ITEM* item = GetBoard()->m_Drawings; for( ; item; item = item->Next() ) { TRACK* next_track = track->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) ) GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) { /* this track segment must be duplicated */ m_Pcb->m_Status_Pcb = 0; TRACK* new_track = track->Copy(); m_Pcb->Add( new_track ); new_track->m_Start += delta; new_track->m_End += delta; new_track->Draw( DrawPanel, DC, GR_OR ); // draw the new created // segment /* this item must be duplicated */ BOARD_ITEM* new_item = gerb_item->Copy(); new_item->Move( delta ); GetBoard()->m_Drawings.PushFront( new_item ); } track = next_track; } /* Copy the Zone segments and move the new segment to its new location */ SEGZONE* zsegment = m_Pcb->m_Zone; while( zsegment ) { SEGZONE* next_zsegment = zsegment->Next(); if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) ) { /* this zone segment must be duplicated */ SEGZONE* new_zsegment = (SEGZONE*) zsegment->Copy(); m_Pcb->Add( new_zsegment ); new_zsegment->m_Start += delta; new_zsegment->m_End += delta; new_zsegment->Draw( DrawPanel, DC, GR_OR ); // draw the new created // segment } zsegment = next_zsegment; } DrawPanel->Refresh(); } /* Test if the structure PtStruct is listed in the block selects * Returns whether PtSegm * NULL if not /* Test if the structure PtStruct is inside the block * Returns true or false */ static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm ) bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ) { if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) ) return PtSegm; if( aBlocklocate.Inside( aItem->m_Start ) ) return true; if( blocklocate.Inside( PtSegm->m_End.x, PtSegm->m_End.y ) ) return PtSegm; if( aBlocklocate.Inside( aItem->m_End ) ) return true; return NULL; return false; }
gerbview/class_GERBER.cpp 0 → 100644 +190 −0 Original line number Diff line number Diff line /** @file class_GERBER.cpp * a GERBER class handle for a given layer info about used D_CODES and how the layer is drawn */ /* * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2010 <Jean-Pierre Charras> * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "fctsys.h" #include "common.h" #include "class_drawpanel.h" #include "confirm.h" #include "macros.h" #include "gerbview.h" /* Format Gerber: NOTES: * Tools and D_CODES * tool number (identification of shapes) * 1 to 999 * * D_CODES: * D01 ... D9 = action codes: * D01 = activating light (lower pen) when di placement * D02 = light extinction (lift pen) when di placement * D03 Flash * D09 = VAPE Flash * D10 ... = Indentification Tool (Opening) * * For tools: * DCode min = D10 * DCode max = 999 */ GERBER::GERBER( int aLayer ) { m_Layer = aLayer; // Layer Number m_Selected_Tool = FIRST_DCODE; ResetDefaultValues(); for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) m_Aperture_List[ii] = 0; m_Pcb = 0; } GERBER::~GERBER() { for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) { delete m_Aperture_List[ii]; // m_Aperture_List[ii] = NULL; } delete m_Pcb; } D_CODE* GERBER::GetDCODE( int aDCODE, bool create ) { unsigned ndx = aDCODE - FIRST_DCODE; if( ndx < (unsigned) DIM( m_Aperture_List ) ) { // lazily create the D_CODE if it does not exist. if( create ) { if( m_Aperture_List[ndx] == NULL ) m_Aperture_List[ndx] = new D_CODE( ndx + FIRST_DCODE ); } return m_Aperture_List[ndx]; } return NULL; } APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup ) { APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup ); if( iter != m_aperture_macros.end() ) { APERTURE_MACRO* pam = (APERTURE_MACRO*) &(*iter); return pam; } return NULL; // not found } void GERBER::ResetDefaultValues() { m_FileName.Empty(); m_Name = wxT( "no name" ); // Layer name m_LayerNegative = FALSE; // TRUE = Negative Layer m_ImageNegative = FALSE; // TRUE = Negative image m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric m_Relative = FALSE; // FALSE = absolute Coord, RUE = // relative Coord m_NoTrailingZeros = FALSE; // True: trailing zeros deleted m_MirorA = FALSE; // True: miror / axe A (X) m_MirorB = FALSE; // True: miror / axe B (Y) m_Has_DCode = FALSE; // TRUE = DCodes in file (FALSE = no // DCode-> // separate DCode file m_Offset.x = m_Offset.y = 0; // Coord Offset m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10; m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10); m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X and Y) this // layer m_Rotation = 0; m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_360Arc_enbl = FALSE; // 360 deg circular // interpolation disable m_Current_Tool = 0; // Current Tool (Dcode) // number selected m_CommandState = 0; // gives tate of the // stacking order analysis m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord // for plot m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified // coord for plot m_IJPos.x = m_IJPos.y = 0; // current centre coord for // plot arcs & circles m_Current_File = NULL; // File to read m_FilesPtr = 0; m_Transform[0][0] = m_Transform[1][1] = 1; m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal m_PolygonFillMode = FALSE; m_PolygonFillModeState = 0; } int GERBER::ReturnUsedDcodeNumber() { int count = 0; for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ ) { if( m_Aperture_List[ii] ) if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined ) ++count; } return count; } void GERBER::InitToolTable() { for( int count = 0; count < TOOLS_MAX_COUNT; count++ ) { if( m_Aperture_List[count] == NULL ) continue; m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE; m_Aperture_List[count]->Clear_D_CODE_Data(); } }