Loading gerbview/block.cpp +3 −20 Original line number Original line Diff line number Diff line Loading @@ -45,9 +45,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, wxDC* DC, bool erase ); bool erase ); static bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ); /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * the key (ALT, SHIFT ALT ..) * the key (ALT, SHIFT ALT ..) */ */ Loading Loading @@ -292,7 +289,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) { { nextitem = item->Next(); nextitem = item->Next(); GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) ) gerb_item->DeleteStructure(); gerb_item->DeleteStructure(); } } Loading Loading @@ -324,7 +321,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) for( ; item; item = item->Next() ) for( ; item; item = item->Next() ) { { GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) ) gerb_item->Move( delta ); gerb_item->Move( delta ); } } Loading Loading @@ -355,7 +352,7 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) for( ; item; item = item->Next() ) for( ; item; item = item->Next() ) { { GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) ) { { /* this item must be duplicated */ /* this item must be duplicated */ BOARD_ITEM* new_item = gerb_item->Copy(); BOARD_ITEM* new_item = gerb_item->Copy(); Loading @@ -367,17 +364,3 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) DrawPanel->Refresh(); DrawPanel->Refresh(); } } /* Test if the structure PtStruct is inside the block * Returns true or false */ bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ) { if( aBlocklocate.Inside( aItem->m_Start ) ) return true; if( aBlocklocate.Inside( aItem->m_End ) ) return true; return false; } gerbview/class_GERBER.cpp +7 −6 Original line number Original line Diff line number Diff line Loading @@ -130,15 +130,16 @@ void GERBER::ResetDefaultValues() m_MirrorA = false; // true: miror / axe A (default = X) m_MirrorA = false; // true: miror / axe A (default = X) m_MirrorB = false; // true: miror / axe B (default = Y) m_MirrorB = false; // true: miror / axe B (default = Y) m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y m_ImageOffset.x = m_ImageOffset.y = 0; // Coord Offset, from IO command m_Offset.x = m_Offset.y = 0; // Coord Offset, from OF command m_Rotation = 0; // Allowed 0, 90, 180, 270 m_Has_DCode = false; // true = DCodes in file m_Has_DCode = false; // true = DCodes in file // false = no DCode-> // false = no DCode-> // search for separate DCode file // search for separate DCode file m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4 m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4 m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4 m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4 m_LayerScale.x = m_LayerScale.y = 1.0; // scale (A and B) this layer m_LayerScale.x = m_LayerScale.y = 1.0; // scale (A and B) this layer m_Rotation = 0; // Allowed 0, 90, 180, 270 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_360Arc_enbl = false; // 360 deg circular m_360Arc_enbl = false; // 360 deg circular // interpolation disable // interpolation disable Loading gerbview/class_GERBER.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,8 @@ public: wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 wxRealPoint m_LayerScale; // scale (X and Y) of layer. wxRealPoint m_LayerScale; // scale (X and Y) of layer. int m_Rotation; int m_Rotation; // Image rotation (0, 90, 180, 270 // Note these values are stored in 0.1 degrees int m_Iterpolation; // Linear, 90 arc, Circ. int m_Iterpolation; // Linear, 90 arc, Circ. bool m_ImageNegative; // true = Negative image bool m_ImageNegative; // true = Negative image int m_Current_Tool; // Current Tool (Dcode) number selected int m_Current_Tool; // Current Tool (Dcode) number selected Loading gerbview/class_aperture_macro.cpp +34 −25 Original line number Original line Diff line number Diff line Loading @@ -147,6 +147,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, * type is not stored in parameters list, so the first parameter is exposure * type is not stored in parameters list, so the first parameter is exposure */ */ curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric ); curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric ); curPos = aParent->GetABPosition( curPos ); int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2; int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2; if( !aFilledShape ) if( !aFilledShape ) GRCircle( aClipBox, aDC, curPos, radius, 0, aColor ); GRCircle( aClipBox, aDC, curPos, radius, 0, aColor ); Loading @@ -170,12 +171,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( rotation ) if( rotation ) { { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); RotatePoint( &polybuffer[ii], -rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading @@ -196,12 +200,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( rotation ) if( rotation ) { { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); RotatePoint( &polybuffer[ii], -rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading @@ -222,12 +229,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( rotation ) if( rotation ) { { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); RotatePoint( &polybuffer[ii], -rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading Loading @@ -255,11 +265,14 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, subshape_poly = polybuffer; subshape_poly = polybuffer; int sub_rotation = rotation + 900 * ii; int sub_rotation = rotation + 900 * ii; for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) RotatePoint( &subshape_poly[jj], sub_rotation ); RotatePoint( &subshape_poly[jj], -sub_rotation ); // Move to current position: // Move to current position: for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) { subshape_poly[jj] += curPos; subshape_poly[jj] += curPos; subshape_poly[jj] = aParent->GetABPosition( subshape_poly[jj] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, subshape_poly.size(), &subshape_poly[0], true, aAltColor, subshape_poly.size(), &subshape_poly[0], true, aAltColor, Loading @@ -283,6 +296,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, int gap = scale( params[4].GetValue( tool ), gerberMetric ); int gap = scale( params[4].GetValue( tool ), gerberMetric ); int numCircles = wxRound( params[5].GetValue( tool ) ); int numCircles = wxRound( params[5].GetValue( tool ) ); // Draw circles: wxPoint center = aParent->GetABPosition( curPos ); // adjust outerDiam by this on each nested circle // adjust outerDiam by this on each nested circle int diamAdjust = (gap + penThickness); //*2; //Should we use * 2 ? int diamAdjust = (gap + penThickness); //*2; //Should we use * 2 ? for( int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust ) for( int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust ) Loading @@ -292,12 +307,12 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( !aFilledShape ) if( !aFilledShape ) { { // draw the border of the pen's path using two circles, each as narrow as possible // draw the border of the pen's path using two circles, each as narrow as possible GRCircle( aClipBox, aDC, curPos, outerDiam / 2, 0, aColor ); GRCircle( aClipBox, aDC, center, outerDiam / 2, 0, aColor ); GRCircle( aClipBox, aDC, curPos, outerDiam / 2 - penThickness, 0, aColor ); GRCircle( aClipBox, aDC, center, outerDiam / 2 - penThickness, 0, aColor ); } } else // Filled mode else // Filled mode { { GRCircle( aClipBox, aDC, curPos, GRCircle( aClipBox, aDC, center, (outerDiam - penThickness) / 2, penThickness, aColor ); (outerDiam - penThickness) / 2, penThickness, aColor ); } } } } Loading @@ -305,17 +320,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, // Draw the cross: // Draw the cross: ConvertShapeToPolygon( aParent, polybuffer, gerberMetric ); ConvertShapeToPolygon( aParent, polybuffer, gerberMetric ); // shape rotation: rotation = wxRound( params[8].GetValue( tool ) * 10.0 ); rotation = wxRound( params[8].GetValue( tool ) * 10.0 ); if( rotation ) { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); { } // shape rotation: RotatePoint( &polybuffer[ii], -rotation ); // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading Loading @@ -344,13 +357,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, // shape rotation: // shape rotation: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { { NEGATE(polybuffer[ii].y); RotatePoint( &polybuffer[ii], -rotation ); RotatePoint( &polybuffer[ii], rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading @@ -372,9 +387,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { { NEGATE(polybuffer[ii].y); RotatePoint( &polybuffer[ii], -rotation ); RotatePoint( &polybuffer[ii], rotation ); polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading Loading @@ -441,7 +456,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, { { RotatePoint( &aBuffer[ii], -angle ); RotatePoint( &aBuffer[ii], -angle ); aBuffer[ii] += start; aBuffer[ii] += start; NEGATE( aBuffer[ii].y ); } } } } break; break; Loading Loading @@ -471,7 +485,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, tool ), aUnitsMetric ); tool ), aUnitsMetric ); // Build poly: // Build poly: NEGATE( lowerLeft.y ); aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); lowerLeft.y += size.y; // Upper left lowerLeft.y += size.y; // Upper left aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); Loading @@ -479,10 +492,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); lowerLeft.y -= size.y; // lower right lowerLeft.y -= size.y; // lower right aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); // Negate y coordinates: for( unsigned ii = 0; ii < aBuffer.size(); ii++ ) NEGATE( aBuffer[ii].y ); } } break; break; Loading gerbview/class_gerber_draw_item.cpp +89 −26 Original line number Original line Diff line number Diff line Loading @@ -112,11 +112,13 @@ GERBER_DRAW_ITEM* GERBER_DRAW_ITEM::Copy() const * offsets, axis selection, scale, rotation * offsets, axis selection, scale, rotation * @param aXYPosition = position in Y,X gerber axis * @param aXYPosition = position in Y,X gerber axis * @return const wxPoint& - The position in A,B axis. * @return const wxPoint& - The position in A,B axis. * Because draw axis is top to bottom, the final y coordinates is negated */ */ wxPoint GERBER_DRAW_ITEM::GetABPosition( wxPoint& aXYPosition ) wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) { { /* Note: RS274Xrevd_e is obscure about the order of transforms: /* Note: RS274Xrevd_e is obscure about the order of transforms: * For instance: Rotation must be made after or before mirroring ? * For instance: Rotation must be made after or before mirroring ? * Note: if something is changed here, GetYXPosition must reflect changes */ */ wxPoint abPos = aXYPosition; wxPoint abPos = aXYPosition; Loading @@ -126,14 +128,41 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( wxPoint& aXYPosition ) abPos.x = wxRound( abPos.x * m_drawScale.x ); abPos.x = wxRound( abPos.x * m_drawScale.x ); abPos.y = wxRound( abPos.y * m_drawScale.y ); abPos.y = wxRound( abPos.y * m_drawScale.y ); if( m_imageParams->m_Rotation ) if( m_imageParams->m_Rotation ) RotatePoint( &abPos, m_imageParams->m_Rotation ); RotatePoint( &abPos, -m_imageParams->m_Rotation ); if( m_mirrorA ) if( m_mirrorA ) NEGATE( abPos.x ); NEGATE( abPos.x ); if( m_mirrorB ) // abPos.y must be negated, because draw axis is top to bottom if( !m_mirrorB ) NEGATE( abPos.y ); NEGATE( abPos.y ); return abPos; return abPos; } } /** * Function GetXYPosition * returns the image position of aPosition for this object. * Image position is the value of aPosition, modified by image parameters: * offsets, axis selection, scale, rotation * @param aABPosition = position in A,B plotter axis * @return const wxPoint - The given position in X,Y axis. */ wxPoint GERBER_DRAW_ITEM::GetXYPosition(const wxPoint& aABPosition ) { // do the inverse tranform made by GetABPosition wxPoint xyPos = aABPosition; if( m_mirrorA ) NEGATE( xyPos.x ); if( !m_mirrorB ) NEGATE( xyPos.y ); if( m_imageParams->m_Rotation ) RotatePoint( &xyPos, m_imageParams->m_Rotation ); xyPos.x = wxRound( xyPos.x / m_drawScale.x ); xyPos.y = wxRound( xyPos.y / m_drawScale.y ); xyPos -= m_layerOffset + m_imageParams->m_ImageOffset; if( m_swapAxis ) EXCHG( xyPos.x, xyPos.y ); return xyPos; } /** function SetLayerParameters /** function SetLayerParameters * Initialize draw parameters from Image and Layer parameters * Initialize draw parameters from Image and Layer parameters Loading Loading @@ -216,6 +245,9 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox() EDA_Rect bbox( m_Start, wxSize( 1, 1 ) ); EDA_Rect bbox( m_Start, wxSize( 1, 1 ) ); bbox.Inflate( m_Size.x / 2, m_Size.y / 2 ); bbox.Inflate( m_Size.x / 2, m_Size.y / 2 ); bbox.SetOrigin(GetXYPosition( bbox.GetOrigin() ) ); bbox.SetEnd(GetXYPosition( bbox.GetEnd() ) ); return bbox; return bbox; } } Loading @@ -223,15 +255,16 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox() /** /** * Function Move * Function Move * move this object. * move this object. * @param const wxPoint& aMoveVector - the move vector for this object. * @param const wxPoint& aMoveVector - the move vector for this object, in AB plotter axis. */ */ void GERBER_DRAW_ITEM::Move( const wxPoint& aMoveVector ) void GERBER_DRAW_ITEM::Move( const wxPoint& aMoveVector ) { { m_Start += aMoveVector; wxPoint xymove = GetXYPosition( aMoveVector ); m_End += aMoveVector; m_Start += xymove; m_ArcCentre += aMoveVector; m_End += xymove; m_ArcCentre += xymove; for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ ) for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ ) m_PolyCorners[ii] += aMoveVector; m_PolyCorners[ii] += xymove; } } Loading Loading @@ -376,20 +409,17 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_Rect* aClipBox, std::vector<wxPoint> points; std::vector<wxPoint> points; points = m_PolyCorners; points = m_PolyCorners; if( aOffset != wxPoint( 0, 0 ) ) { for( unsigned ii = 0; ii < points.size(); ii++ ) for( unsigned ii = 0; ii < points.size(); ii++ ) { { points[ii] += aOffset; points[ii] += aOffset; points[ii] = GetABPosition( points[ii] ); points[ii] = GetABPosition( points[ii] ); } } } GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilledShape, aColor, aColor ); GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilledShape, aColor, aColor ); } } /** Function DisplayInfoBase /** Function DisplayInfo * has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. * about this object into the frame's message panel. * Display info about the track segment only, and does not calculate the full track length * Display info about the track segment only, and does not calculate the full track length Loading @@ -398,28 +428,59 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_Rect* aClipBox, void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) { { wxString msg; wxString msg; BOARD* board = ( (WinEDA_BasePcbFrame*) frame )->GetBoard(); frame->ClearMsgPanel(); frame->ClearMsgPanel(); msg = ShowGBRShape(); msg = ShowGBRShape(); frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN ); /* Display layer */ // Display D_Code value: msg = board->GetLayerName( m_Layer ); msg.Printf( wxT("%d"), m_DCode); frame->AppendMsgPanel( _( "Layer" ), msg, BROWN ); frame->AppendMsgPanel( _( "D Code" ), msg, RED ); // Display Image name if(m_imageParams) { msg = m_imageParams->m_ImageName; frame->AppendMsgPanel( _( "Image name" ), msg, BROWN ); } // Display graphic layer number msg.Printf( wxT("%d"), GetLayer()+1); frame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN ); // This next info can be see as debug info, so it can be disabled #if 1 // Display offset wxPoint tmp = m_layerOffset + m_imageParams->m_ImageOffset; msg.Printf( wxT("X=%f Y=%f"), (double)tmp.x/10000, (double)tmp.y/10000); frame->AppendMsgPanel( _( "Offset" ), msg, DARKRED ); // Display rotation msg.Printf( wxT("%d"), m_imageParams->m_Rotation/10); frame->AppendMsgPanel( _( "Image rotation" ), msg, DARKRED ); // Display mirroring msg.Printf( wxT("X%d Y%d"), m_mirrorA, m_mirrorB); frame->AppendMsgPanel( _( "Mirror" ), msg, DARKRED ); // Display AB axis swap msg = m_swapAxis ? wxT("A=Y B=X") : wxT("A=X B=Y"); frame->AppendMsgPanel( _( "AB axis" ), msg, DARKRED ); #endif } } /** /** * Function HitTest * Function HitTest * tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object. * @param ref_pos A wxPoint to test * @param aRefPos A wxPoint to test in AB axis * @return bool - true if a hit, else false * @return bool - true if a hit, else false */ */ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& ref_pos ) bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) { { // TODO: a better analyse od the shape (perhaps create a D_CODE::HitTest for flashed items) wxPoint ref_pos = GetXYPosition( aRefPos ); // TODO: a better analyse of the shape (perhaps create a D_CODE::HitTest for flashed items) int radius = MIN( m_Size.x, m_Size.y ) >> 1; int radius = MIN( m_Size.x, m_Size.y ) >> 1; // delta is a vector from m_Start to m_End (an origin of m_Start) // delta is a vector from m_Start to m_End (an origin of m_Start) Loading Loading @@ -447,14 +508,16 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& ref_pos ) * Function HitTest (overlayed) * Function HitTest (overlayed) * tests if the given EDA_Rect intersect this object. * tests if the given EDA_Rect intersect this object. * For now, an ending point must be inside this rect. * For now, an ending point must be inside this rect. * @param refArea : the given EDA_Rect * @param refArea : the given EDA_Rect in AB plotter axis * @return bool - true if a hit, else false * @return bool - true if a hit, else false */ */ bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& refArea ) bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& refArea ) { { if( refArea.Inside( m_Start ) ) wxPoint pos = GetABPosition( m_Start ); if( refArea.Inside( pos ) ) return true; return true; if( refArea.Inside( m_End ) ) pos = GetABPosition( m_End ); if( refArea.Inside( pos ) ) return true; return true; return false; return false; } } Loading Loading
gerbview/block.cpp +3 −20 Original line number Original line Diff line number Diff line Loading @@ -45,9 +45,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, wxDC* DC, bool erase ); bool erase ); static bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ); /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * the key (ALT, SHIFT ALT ..) * the key (ALT, SHIFT ALT ..) */ */ Loading Loading @@ -292,7 +289,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) { { nextitem = item->Next(); nextitem = item->Next(); GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) ) gerb_item->DeleteStructure(); gerb_item->DeleteStructure(); } } Loading Loading @@ -324,7 +321,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) for( ; item; item = item->Next() ) for( ; item; item = item->Next() ) { { GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) ) gerb_item->Move( delta ); gerb_item->Move( delta ); } } Loading Loading @@ -355,7 +352,7 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) for( ; item; item = item->Next() ) for( ; item; item = item->Next() ) { { GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item; if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) ) if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) ) { { /* this item must be duplicated */ /* this item must be duplicated */ BOARD_ITEM* new_item = gerb_item->Copy(); BOARD_ITEM* new_item = gerb_item->Copy(); Loading @@ -367,17 +364,3 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC ) DrawPanel->Refresh(); DrawPanel->Refresh(); } } /* Test if the structure PtStruct is inside the block * Returns true or false */ bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem ) { if( aBlocklocate.Inside( aItem->m_Start ) ) return true; if( aBlocklocate.Inside( aItem->m_End ) ) return true; return false; }
gerbview/class_GERBER.cpp +7 −6 Original line number Original line Diff line number Diff line Loading @@ -130,15 +130,16 @@ void GERBER::ResetDefaultValues() m_MirrorA = false; // true: miror / axe A (default = X) m_MirrorA = false; // true: miror / axe A (default = X) m_MirrorB = false; // true: miror / axe B (default = Y) m_MirrorB = false; // true: miror / axe B (default = Y) m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y m_ImageOffset.x = m_ImageOffset.y = 0; // Coord Offset, from IO command m_Offset.x = m_Offset.y = 0; // Coord Offset, from OF command m_Rotation = 0; // Allowed 0, 90, 180, 270 m_Has_DCode = false; // true = DCodes in file m_Has_DCode = false; // true = DCodes in file // false = no DCode-> // false = no DCode-> // search for separate DCode file // search for separate DCode file m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4 m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4 m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4 m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4 m_LayerScale.x = m_LayerScale.y = 1.0; // scale (A and B) this layer m_LayerScale.x = m_LayerScale.y = 1.0; // scale (A and B) this layer m_Rotation = 0; // Allowed 0, 90, 180, 270 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ. m_360Arc_enbl = false; // 360 deg circular m_360Arc_enbl = false; // 360 deg circular // interpolation disable // interpolation disable Loading
gerbview/class_GERBER.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,8 @@ public: wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 wxRealPoint m_LayerScale; // scale (X and Y) of layer. wxRealPoint m_LayerScale; // scale (X and Y) of layer. int m_Rotation; int m_Rotation; // Image rotation (0, 90, 180, 270 // Note these values are stored in 0.1 degrees int m_Iterpolation; // Linear, 90 arc, Circ. int m_Iterpolation; // Linear, 90 arc, Circ. bool m_ImageNegative; // true = Negative image bool m_ImageNegative; // true = Negative image int m_Current_Tool; // Current Tool (Dcode) number selected int m_Current_Tool; // Current Tool (Dcode) number selected Loading
gerbview/class_aperture_macro.cpp +34 −25 Original line number Original line Diff line number Diff line Loading @@ -147,6 +147,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, * type is not stored in parameters list, so the first parameter is exposure * type is not stored in parameters list, so the first parameter is exposure */ */ curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric ); curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric ); curPos = aParent->GetABPosition( curPos ); int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2; int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2; if( !aFilledShape ) if( !aFilledShape ) GRCircle( aClipBox, aDC, curPos, radius, 0, aColor ); GRCircle( aClipBox, aDC, curPos, radius, 0, aColor ); Loading @@ -170,12 +171,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( rotation ) if( rotation ) { { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); RotatePoint( &polybuffer[ii], -rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading @@ -196,12 +200,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( rotation ) if( rotation ) { { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); RotatePoint( &polybuffer[ii], -rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading @@ -222,12 +229,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( rotation ) if( rotation ) { { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); RotatePoint( &polybuffer[ii], -rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading Loading @@ -255,11 +265,14 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, subshape_poly = polybuffer; subshape_poly = polybuffer; int sub_rotation = rotation + 900 * ii; int sub_rotation = rotation + 900 * ii; for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) RotatePoint( &subshape_poly[jj], sub_rotation ); RotatePoint( &subshape_poly[jj], -sub_rotation ); // Move to current position: // Move to current position: for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) for( unsigned jj = 0; jj < subshape_poly.size(); jj++ ) { subshape_poly[jj] += curPos; subshape_poly[jj] += curPos; subshape_poly[jj] = aParent->GetABPosition( subshape_poly[jj] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, subshape_poly.size(), &subshape_poly[0], true, aAltColor, subshape_poly.size(), &subshape_poly[0], true, aAltColor, Loading @@ -283,6 +296,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, int gap = scale( params[4].GetValue( tool ), gerberMetric ); int gap = scale( params[4].GetValue( tool ), gerberMetric ); int numCircles = wxRound( params[5].GetValue( tool ) ); int numCircles = wxRound( params[5].GetValue( tool ) ); // Draw circles: wxPoint center = aParent->GetABPosition( curPos ); // adjust outerDiam by this on each nested circle // adjust outerDiam by this on each nested circle int diamAdjust = (gap + penThickness); //*2; //Should we use * 2 ? int diamAdjust = (gap + penThickness); //*2; //Should we use * 2 ? for( int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust ) for( int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust ) Loading @@ -292,12 +307,12 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, if( !aFilledShape ) if( !aFilledShape ) { { // draw the border of the pen's path using two circles, each as narrow as possible // draw the border of the pen's path using two circles, each as narrow as possible GRCircle( aClipBox, aDC, curPos, outerDiam / 2, 0, aColor ); GRCircle( aClipBox, aDC, center, outerDiam / 2, 0, aColor ); GRCircle( aClipBox, aDC, curPos, outerDiam / 2 - penThickness, 0, aColor ); GRCircle( aClipBox, aDC, center, outerDiam / 2 - penThickness, 0, aColor ); } } else // Filled mode else // Filled mode { { GRCircle( aClipBox, aDC, curPos, GRCircle( aClipBox, aDC, center, (outerDiam - penThickness) / 2, penThickness, aColor ); (outerDiam - penThickness) / 2, penThickness, aColor ); } } } } Loading @@ -305,17 +320,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, // Draw the cross: // Draw the cross: ConvertShapeToPolygon( aParent, polybuffer, gerberMetric ); ConvertShapeToPolygon( aParent, polybuffer, gerberMetric ); // shape rotation: rotation = wxRound( params[8].GetValue( tool ) * 10.0 ); rotation = wxRound( params[8].GetValue( tool ) * 10.0 ); if( rotation ) { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) RotatePoint( &polybuffer[ii], rotation ); { } // shape rotation: RotatePoint( &polybuffer[ii], -rotation ); // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading Loading @@ -344,13 +357,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, // shape rotation: // shape rotation: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { { NEGATE(polybuffer[ii].y); RotatePoint( &polybuffer[ii], -rotation ); RotatePoint( &polybuffer[ii], rotation ); } } // Move to current position: // Move to current position: for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading @@ -372,9 +387,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { { NEGATE(polybuffer[ii].y); RotatePoint( &polybuffer[ii], -rotation ); RotatePoint( &polybuffer[ii], rotation ); polybuffer[ii] += curPos; polybuffer[ii] += curPos; polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] ); } } GRClosedPoly( aClipBox, aDC, GRClosedPoly( aClipBox, aDC, polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor ); Loading Loading @@ -441,7 +456,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, { { RotatePoint( &aBuffer[ii], -angle ); RotatePoint( &aBuffer[ii], -angle ); aBuffer[ii] += start; aBuffer[ii] += start; NEGATE( aBuffer[ii].y ); } } } } break; break; Loading Loading @@ -471,7 +485,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, tool ), aUnitsMetric ); tool ), aUnitsMetric ); // Build poly: // Build poly: NEGATE( lowerLeft.y ); aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); lowerLeft.y += size.y; // Upper left lowerLeft.y += size.y; // Upper left aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); Loading @@ -479,10 +492,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); lowerLeft.y -= size.y; // lower right lowerLeft.y -= size.y; // lower right aBuffer.push_back( lowerLeft ); aBuffer.push_back( lowerLeft ); // Negate y coordinates: for( unsigned ii = 0; ii < aBuffer.size(); ii++ ) NEGATE( aBuffer[ii].y ); } } break; break; Loading
gerbview/class_gerber_draw_item.cpp +89 −26 Original line number Original line Diff line number Diff line Loading @@ -112,11 +112,13 @@ GERBER_DRAW_ITEM* GERBER_DRAW_ITEM::Copy() const * offsets, axis selection, scale, rotation * offsets, axis selection, scale, rotation * @param aXYPosition = position in Y,X gerber axis * @param aXYPosition = position in Y,X gerber axis * @return const wxPoint& - The position in A,B axis. * @return const wxPoint& - The position in A,B axis. * Because draw axis is top to bottom, the final y coordinates is negated */ */ wxPoint GERBER_DRAW_ITEM::GetABPosition( wxPoint& aXYPosition ) wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) { { /* Note: RS274Xrevd_e is obscure about the order of transforms: /* Note: RS274Xrevd_e is obscure about the order of transforms: * For instance: Rotation must be made after or before mirroring ? * For instance: Rotation must be made after or before mirroring ? * Note: if something is changed here, GetYXPosition must reflect changes */ */ wxPoint abPos = aXYPosition; wxPoint abPos = aXYPosition; Loading @@ -126,14 +128,41 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( wxPoint& aXYPosition ) abPos.x = wxRound( abPos.x * m_drawScale.x ); abPos.x = wxRound( abPos.x * m_drawScale.x ); abPos.y = wxRound( abPos.y * m_drawScale.y ); abPos.y = wxRound( abPos.y * m_drawScale.y ); if( m_imageParams->m_Rotation ) if( m_imageParams->m_Rotation ) RotatePoint( &abPos, m_imageParams->m_Rotation ); RotatePoint( &abPos, -m_imageParams->m_Rotation ); if( m_mirrorA ) if( m_mirrorA ) NEGATE( abPos.x ); NEGATE( abPos.x ); if( m_mirrorB ) // abPos.y must be negated, because draw axis is top to bottom if( !m_mirrorB ) NEGATE( abPos.y ); NEGATE( abPos.y ); return abPos; return abPos; } } /** * Function GetXYPosition * returns the image position of aPosition for this object. * Image position is the value of aPosition, modified by image parameters: * offsets, axis selection, scale, rotation * @param aABPosition = position in A,B plotter axis * @return const wxPoint - The given position in X,Y axis. */ wxPoint GERBER_DRAW_ITEM::GetXYPosition(const wxPoint& aABPosition ) { // do the inverse tranform made by GetABPosition wxPoint xyPos = aABPosition; if( m_mirrorA ) NEGATE( xyPos.x ); if( !m_mirrorB ) NEGATE( xyPos.y ); if( m_imageParams->m_Rotation ) RotatePoint( &xyPos, m_imageParams->m_Rotation ); xyPos.x = wxRound( xyPos.x / m_drawScale.x ); xyPos.y = wxRound( xyPos.y / m_drawScale.y ); xyPos -= m_layerOffset + m_imageParams->m_ImageOffset; if( m_swapAxis ) EXCHG( xyPos.x, xyPos.y ); return xyPos; } /** function SetLayerParameters /** function SetLayerParameters * Initialize draw parameters from Image and Layer parameters * Initialize draw parameters from Image and Layer parameters Loading Loading @@ -216,6 +245,9 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox() EDA_Rect bbox( m_Start, wxSize( 1, 1 ) ); EDA_Rect bbox( m_Start, wxSize( 1, 1 ) ); bbox.Inflate( m_Size.x / 2, m_Size.y / 2 ); bbox.Inflate( m_Size.x / 2, m_Size.y / 2 ); bbox.SetOrigin(GetXYPosition( bbox.GetOrigin() ) ); bbox.SetEnd(GetXYPosition( bbox.GetEnd() ) ); return bbox; return bbox; } } Loading @@ -223,15 +255,16 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox() /** /** * Function Move * Function Move * move this object. * move this object. * @param const wxPoint& aMoveVector - the move vector for this object. * @param const wxPoint& aMoveVector - the move vector for this object, in AB plotter axis. */ */ void GERBER_DRAW_ITEM::Move( const wxPoint& aMoveVector ) void GERBER_DRAW_ITEM::Move( const wxPoint& aMoveVector ) { { m_Start += aMoveVector; wxPoint xymove = GetXYPosition( aMoveVector ); m_End += aMoveVector; m_Start += xymove; m_ArcCentre += aMoveVector; m_End += xymove; m_ArcCentre += xymove; for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ ) for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ ) m_PolyCorners[ii] += aMoveVector; m_PolyCorners[ii] += xymove; } } Loading Loading @@ -376,20 +409,17 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_Rect* aClipBox, std::vector<wxPoint> points; std::vector<wxPoint> points; points = m_PolyCorners; points = m_PolyCorners; if( aOffset != wxPoint( 0, 0 ) ) { for( unsigned ii = 0; ii < points.size(); ii++ ) for( unsigned ii = 0; ii < points.size(); ii++ ) { { points[ii] += aOffset; points[ii] += aOffset; points[ii] = GetABPosition( points[ii] ); points[ii] = GetABPosition( points[ii] ); } } } GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilledShape, aColor, aColor ); GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilledShape, aColor, aColor ); } } /** Function DisplayInfoBase /** Function DisplayInfo * has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. * about this object into the frame's message panel. * Display info about the track segment only, and does not calculate the full track length * Display info about the track segment only, and does not calculate the full track length Loading @@ -398,28 +428,59 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_Rect* aClipBox, void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) { { wxString msg; wxString msg; BOARD* board = ( (WinEDA_BasePcbFrame*) frame )->GetBoard(); frame->ClearMsgPanel(); frame->ClearMsgPanel(); msg = ShowGBRShape(); msg = ShowGBRShape(); frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN ); /* Display layer */ // Display D_Code value: msg = board->GetLayerName( m_Layer ); msg.Printf( wxT("%d"), m_DCode); frame->AppendMsgPanel( _( "Layer" ), msg, BROWN ); frame->AppendMsgPanel( _( "D Code" ), msg, RED ); // Display Image name if(m_imageParams) { msg = m_imageParams->m_ImageName; frame->AppendMsgPanel( _( "Image name" ), msg, BROWN ); } // Display graphic layer number msg.Printf( wxT("%d"), GetLayer()+1); frame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN ); // This next info can be see as debug info, so it can be disabled #if 1 // Display offset wxPoint tmp = m_layerOffset + m_imageParams->m_ImageOffset; msg.Printf( wxT("X=%f Y=%f"), (double)tmp.x/10000, (double)tmp.y/10000); frame->AppendMsgPanel( _( "Offset" ), msg, DARKRED ); // Display rotation msg.Printf( wxT("%d"), m_imageParams->m_Rotation/10); frame->AppendMsgPanel( _( "Image rotation" ), msg, DARKRED ); // Display mirroring msg.Printf( wxT("X%d Y%d"), m_mirrorA, m_mirrorB); frame->AppendMsgPanel( _( "Mirror" ), msg, DARKRED ); // Display AB axis swap msg = m_swapAxis ? wxT("A=Y B=X") : wxT("A=X B=Y"); frame->AppendMsgPanel( _( "AB axis" ), msg, DARKRED ); #endif } } /** /** * Function HitTest * Function HitTest * tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object. * @param ref_pos A wxPoint to test * @param aRefPos A wxPoint to test in AB axis * @return bool - true if a hit, else false * @return bool - true if a hit, else false */ */ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& ref_pos ) bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) { { // TODO: a better analyse od the shape (perhaps create a D_CODE::HitTest for flashed items) wxPoint ref_pos = GetXYPosition( aRefPos ); // TODO: a better analyse of the shape (perhaps create a D_CODE::HitTest for flashed items) int radius = MIN( m_Size.x, m_Size.y ) >> 1; int radius = MIN( m_Size.x, m_Size.y ) >> 1; // delta is a vector from m_Start to m_End (an origin of m_Start) // delta is a vector from m_Start to m_End (an origin of m_Start) Loading Loading @@ -447,14 +508,16 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& ref_pos ) * Function HitTest (overlayed) * Function HitTest (overlayed) * tests if the given EDA_Rect intersect this object. * tests if the given EDA_Rect intersect this object. * For now, an ending point must be inside this rect. * For now, an ending point must be inside this rect. * @param refArea : the given EDA_Rect * @param refArea : the given EDA_Rect in AB plotter axis * @return bool - true if a hit, else false * @return bool - true if a hit, else false */ */ bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& refArea ) bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& refArea ) { { if( refArea.Inside( m_Start ) ) wxPoint pos = GetABPosition( m_Start ); if( refArea.Inside( pos ) ) return true; return true; if( refArea.Inside( m_End ) ) pos = GetABPosition( m_End ); if( refArea.Inside( pos ) ) return true; return true; return false; return false; } } Loading