Loading CHANGELOG.txt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,13 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with email address. email address. 2009-Jan-02 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ++Eeschema: Code cleaning. LibDrawPolyline uses now std::vector<wxPoint> to handle corners. 2008-Dec-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ================================================================================ Loading eeschema/block.cpp +16 −26 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,9 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, BASE_SCREEN* screen, BASE_SCREEN* screen, SCH_ITEM* DrawStruct ); SCH_ITEM* DrawStruct ); static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CollectStructsToDrag( SCH_SCREEN* screen ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, wxPoint& position ); wxPoint& aPosition ); static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, wxDC* DC, bool erase ); bool erase ); Loading Loading @@ -182,9 +182,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) /* clear struct.m_Flags */ /* clear struct.m_Flags */ SCH_ITEM* Struct; SCH_ITEM* Struct; for( Struct = GetScreen()->EEDrawList; for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() ) Struct != NULL; Struct = Struct->Next() ) Struct->m_Flags = 0; Struct->m_Flags = 0; DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL; Loading @@ -203,9 +201,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) block->m_BlockDrawStruct = NULL; block->m_BlockDrawStruct = NULL; } } SetToolID( m_ID_current_state, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } } Loading Loading @@ -1152,10 +1148,7 @@ bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct ) if( !DrawStruct ) if( !DrawStruct ) return FALSE; return FALSE; move_vector.x = screen->m_Curseur.x - move_vector = screen->m_Curseur - screen->BlockLocate.m_BlockLastCursorPosition; screen->BlockLocate.m_BlockLastCursorPosition.x; move_vector.y = screen->m_Curseur.y - screen->BlockLocate.m_BlockLastCursorPosition.y; switch( DrawStruct->Type() ) switch( DrawStruct->Type() ) { { Loading Loading @@ -1709,8 +1702,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) /*********************************************************************************/ /*********************************************************************************/ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, wxPoint& position ) wxPoint& aPosition ) /*********************************************************************************/ /*********************************************************************************/ { { EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry; Loading @@ -1720,19 +1713,19 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, int orient; int orient; LibDrawPin* Pin; LibDrawPin* Pin; if( DrawLibItem ) if( aDrawLibItem ) { { NextItem = NULL; NextItem = NULL; if( ( Entry = if( ( Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FindLibPart( aDrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL ) FIND_ROOT ) ) == NULL ) return NULL; return NULL; DEntry = Entry->m_Drawings; DEntry = Entry->m_Drawings; Multi = DrawLibItem->m_Multi; Multi = aDrawLibItem->m_Multi; convert = DrawLibItem->m_Convert; convert = aDrawLibItem->m_Convert; PartX = DrawLibItem->m_Pos.x; PartX = aDrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y; PartY = aDrawLibItem->m_Pos.y; memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) ); } } else else DEntry = NextItem; DEntry = NextItem; Loading @@ -1753,10 +1746,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, orient = Pin->ReturnPinDrawOrient( TransMat ); orient = Pin->ReturnPinDrawOrient( TransMat ); /* Calcul de la position du point de reference */ /* Calcul de la position du point de reference */ position.x = PartX + (TransMat[0][0] *Pin->m_Pos.x) aPosition = TransformCoordinate( TransMat, Pin->m_Pos); + (TransMat[0][1] *Pin->m_Pos.y); position.y = PartY + (TransMat[1][0] *Pin->m_Pos.x) + (TransMat[1][1] *Pin->m_Pos.y); NextItem = DEntry->Next(); NextItem = DEntry->Next(); return DEntry; return DEntry; } } Loading eeschema/block_libedit.cpp +20 −33 Original line number Original line Diff line number Diff line /****************************************************/ /****************************************************/ /* BLOCK.CPP */ /* block_libedt.cpp */ /* Gestion des Operations sur Blocks et Effacements */ /* Gestion des Operations sur Blocks et Effacements */ /****************************************************/ /****************************************************/ Loading Loading @@ -139,11 +139,11 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2; int ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList; for( ii = 0; ii < imax; ii ++ ) for( ii = 0; ii < imax; ii += 2 ) { { pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1]; pos = ( (LibDrawPolyline*) item )->m_PolyPoints[ii]; NEGATE( pos.y ); if( Rect.Inside( pos ) ) if( Rect.Inside( pos ) ) { { item->m_Selected = IS_SELECTED; item->m_Selected = IS_SELECTED; Loading Loading @@ -537,7 +537,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) if( LibEntry == NULL ) if( LibEntry == NULL ) return; return; offset.y = -offset.y; // Y axis for lib items is Down to Up: reverse y offset value NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value item = LibEntry->m_Drawings; item = LibEntry->m_Drawings; for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() ) { { Loading @@ -547,42 +547,31 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) switch( item->Type() ) switch( item->Type() ) { { case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE: ( (LibDrawPin*) item )->m_Pos.x += offset.x; ( (LibDrawPin*) item )->m_Pos += offset; ( (LibDrawPin*) item )->m_Pos.y += offset.y; break; break; case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE: { { ( (LibDrawArc*) item )->m_Pos.x += offset.x; ( (LibDrawArc*) item )->m_Pos += offset; ( (LibDrawArc*) item )->m_Pos.y += offset.y; ( (LibDrawArc*) item )->m_ArcStart += offset; ( (LibDrawArc*) item )->m_ArcStart.x += offset.x; ( (LibDrawArc*) item )->m_ArcEnd += offset; ( (LibDrawArc*) item )->m_ArcStart.y += offset.y; ( (LibDrawArc*) item )->m_ArcEnd.x += offset.x; ( (LibDrawArc*) item )->m_ArcEnd.y += offset.y; break; break; } } case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE: ( (LibDrawCircle*) item )->m_Pos.x += offset.x; ( (LibDrawCircle*) item )->m_Pos += offset; ( (LibDrawCircle*) item )->m_Pos.y += offset.y; break; break; case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE: ( (LibDrawSquare*) item )->m_Pos.x += offset.x; ( (LibDrawSquare*) item )->m_Pos += offset; ( (LibDrawSquare*) item )->m_Pos.y += offset.y; ( (LibDrawSquare*) item )->m_End += offset; ( (LibDrawSquare*) item )->m_End.x += offset.x; ( (LibDrawSquare*) item )->m_End.y += offset.y; break; break; case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2; unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList; for( ii = 0; ii < imax; ii ++ ) for( ii = 0; ii < imax; ii += 2 ) ( (LibDrawPolyline*) item )->m_PolyPoints[ii] += offset; { ptpoly[ii] += offset.x; ptpoly[ii + 1] += offset.y; } } } break; break; Loading @@ -590,8 +579,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) break; break; case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: ( (LibDrawText*) item )->m_Pos.x += offset.x; ( (LibDrawText*) item )->m_Pos += offset; ( (LibDrawText*) item )->m_Pos.y += offset.y; break; break; default: default: Loading Loading @@ -688,11 +676,10 @@ void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2; unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList; for( ii = 0; ii < imax; ii ++ ) for( ii = 0; ii < imax; ii += 2 ) { { SETMIRROR( ptpoly[ii] ); SETMIRROR( ( (LibDrawPolyline*) item )->m_PolyPoints[ii].x ); } } } } break; break; Loading eeschema/class_libentry.cpp +10 −19 Original line number Original line Diff line number Diff line Loading @@ -118,7 +118,6 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) **/ **/ { { int xmin, xmax, ymin, ymax, x1, y1; int xmin, xmax, ymin, ymax, x1, y1; int* pt, ii; LibEDA_BaseStruct* DrawEntry; LibEDA_BaseStruct* DrawEntry; EDA_Rect BoundaryBox; EDA_Rect BoundaryBox; Loading Loading @@ -232,21 +231,15 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { LibDrawPolyline* polyline = (LibDrawPolyline*) DrawEntry; EDA_Rect rect = ((LibDrawPolyline*) DrawEntry)->GetBoundaryBox( ); pt = polyline->m_PolyList; xmin = MIN( xmin, rect.GetX() ); for( ii = 0; ii < polyline->m_CornersCount; ii++ ) xmax = MAX( xmax, rect.GetX() ); { ymin = MIN( ymin, rect.GetY() ); if( xmin > *pt ) ymax = MAX( ymax, rect.GetY() ); xmin = *pt; xmin = MIN( xmin, rect.GetEnd().x ); if( xmax < *pt ) xmax = MAX( xmax, rect.GetEnd().x ); xmax = *pt; ymin = MIN( ymin, rect.GetEnd().y ); pt++; ymax = MAX( ymax, rect.GetEnd().y ); if( ymin > *pt ) ymin = *pt; if( ymax < *pt ) ymax = *pt; pt++; } } } break; break; Loading @@ -257,9 +250,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) // Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */ // Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */ NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense // Ensure w and H > 0 (wxRect assume it) // Ensure H > 0 (wxRect assume it) if( xmax < xmin ) EXCHG( xmax, xmin ); if( ymax < ymin ) if( ymax < ymin ) EXCHG( ymax, ymin ); EXCHG( ymax, ymin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); Loading eeschema/classes_body_items.cpp +64 −44 Original line number Original line Diff line number Diff line Loading @@ -240,8 +240,8 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int color = ReturnLayerColor( LAYER_DEVICE ); int color = ReturnLayerColor( LAYER_DEVICE ); int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); static int* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings static wxPoint* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings static int Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings static unsigned Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings if( aColor < 0 ) // Used normal color or selected color if( aColor < 0 ) // Used normal color or selected color { { Loading @@ -254,25 +254,19 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, // Set the size of the buffer od coordinates // Set the size of the buffer od coordinates if( Buf_Poly_Drawings == NULL ) if( Buf_Poly_Drawings == NULL ) { { Buf_Poly_Size = m_CornersCount; Buf_Poly_Size = m_PolyPoints.size(); Buf_Poly_Drawings = (int*) MyMalloc( sizeof(int) * 2 * Buf_Poly_Size ); Buf_Poly_Drawings = (wxPoint*) MyMalloc( sizeof(wxPoint) * Buf_Poly_Size ); } } else if( Buf_Poly_Size < m_CornersCount ) else if( Buf_Poly_Size < m_PolyPoints.size() ) { { Buf_Poly_Size = m_CornersCount; Buf_Poly_Size = m_PolyPoints.size(); Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings, Buf_Poly_Drawings = (wxPoint*) realloc( Buf_Poly_Drawings, sizeof(int) * 2 * Buf_Poly_Size ); sizeof(wxPoint) * Buf_Poly_Size ); } } for( int ii = 0, jj = 0; ii < m_CornersCount; ii++, jj += 2 ) for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { { pos1.x = m_PolyList[jj]; Buf_Poly_Drawings[ii] = TransformCoordinate( aTransformMatrix, m_PolyPoints[ii] ) + aOffset; pos1.y = m_PolyList[jj + 1]; pos1 = TransformCoordinate( aTransformMatrix, pos1 ) + aOffset; Buf_Poly_Drawings[jj] = pos1.x; Buf_Poly_Drawings[jj + 1] = pos1.y; } } FILL_T fill = aData ? NO_FILL : m_Fill; FILL_T fill = aData ? NO_FILL : m_Fill; Loading @@ -280,15 +274,15 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, fill = NO_FILL; fill = NO_FILL; if( fill == FILLED_WITH_BG_BODYCOLOR ) if( fill == FILLED_WITH_BG_BODYCOLOR ) GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), (wxPoint*) Buf_Poly_Drawings, 1, linewidth, color, Buf_Poly_Drawings, 1, linewidth, color, ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) else if( fill == FILLED_SHAPE ) GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC,m_PolyPoints.size(), (wxPoint*) Buf_Poly_Drawings, 1, linewidth, color, color ); Buf_Poly_Drawings, 1, linewidth, color, color ); else else GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), (wxPoint*) Buf_Poly_Drawings, 0, linewidth, color, color ); Buf_Poly_Drawings, 0, linewidth, color, color ); } } Loading Loading @@ -520,8 +514,6 @@ LibDrawSegment* LibDrawSegment::GenCopy() LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE ) LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE ) { { m_CornersCount = 0; m_PolyList = NULL; m_Fill = NO_FILL; m_Fill = NO_FILL; m_Width = 0; m_Width = 0; } } Loading @@ -532,16 +524,7 @@ LibDrawPolyline* LibDrawPolyline::GenCopy() /************************************************/ /************************************************/ { { LibDrawPolyline* newitem = new LibDrawPolyline(); LibDrawPolyline* newitem = new LibDrawPolyline(); newitem->m_PolyPoints = m_PolyPoints; // Vector copy int size; newitem->m_CornersCount = m_CornersCount; size = sizeof(int) * 2 * m_CornersCount; if( size ) { newitem->m_PolyList = (int*) MyMalloc( size ); memcpy( newitem->m_PolyList, m_PolyList, size ); } newitem->m_Width = m_Width; newitem->m_Width = m_Width; newitem->m_Unit = m_Unit; newitem->m_Unit = m_Unit; newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert; Loading @@ -555,18 +538,55 @@ LibDrawPolyline* LibDrawPolyline::GenCopy() void LibDrawPolyline::AddPoint( const wxPoint& point ) void LibDrawPolyline::AddPoint( const wxPoint& point ) /***************************************************/ /***************************************************/ /* add a point to the polyline coordinate list, and realloc the memory /* add a point to the polyline coordinate list */ */ { { int allocsize; m_PolyPoints.push_back( point ); } m_CornersCount++; allocsize = 2 * sizeof(int) * m_CornersCount; if( m_PolyList == NULL ) m_PolyList = (int*) MyMalloc( allocsize ); else m_PolyList = (int*) realloc( m_PolyList, allocsize ); m_PolyList[(m_CornersCount * 2) - 2] = point.x; /** Function HitTest m_PolyList[(m_CornersCount * 2) - 1] = -point.y; * @return true if the point aPosRef is near a segment * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to a segment * @param aTransMat = the transform matrix */ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, int aTransMat[2][2] ) { aPosRef = TransformCoordinate( aTransMat, aPosRef); /* Move origin coordinate to segment start point */ wxPoint end; for ( unsigned ii = 0; ii < m_PolyPoints.size() -1; ii++ ) { aPosRef -= m_PolyPoints[0]; end = m_PolyPoints[1] - m_PolyPoints[0]; if( distance( end.x, end.y, aPosRef.x, aPosRef.y, aThreshold ) ) return true; } return false; } /** Function GetBoundaryBox * @return the boundary box for this, in library coordinates */ EDA_Rect LibDrawPolyline::GetBoundaryBox( ) { EDA_Rect BoundaryBox; int xmin, xmax, ymin, ymax; xmin = xmax = m_PolyPoints[0].x; ymin = ymax = m_PolyPoints[0].y; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { xmin = MIN( xmin, m_PolyPoints[0].x ); xmax = MAX( xmax, m_PolyPoints[0].x ); ymin = MIN( ymin, m_PolyPoints[0].y ); ymax = MAX( ymax, m_PolyPoints[0].y ); } BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin ); return BoundaryBox; } } Loading
CHANGELOG.txt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,13 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with email address. email address. 2009-Jan-02 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ++Eeschema: Code cleaning. LibDrawPolyline uses now std::vector<wxPoint> to handle corners. 2008-Dec-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-31 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ================================================================================ Loading
eeschema/block.cpp +16 −26 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,9 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, BASE_SCREEN* screen, BASE_SCREEN* screen, SCH_ITEM* DrawStruct ); SCH_ITEM* DrawStruct ); static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CollectStructsToDrag( SCH_SCREEN* screen ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, wxPoint& position ); wxPoint& aPosition ); static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, wxDC* DC, bool erase ); bool erase ); Loading Loading @@ -182,9 +182,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) /* clear struct.m_Flags */ /* clear struct.m_Flags */ SCH_ITEM* Struct; SCH_ITEM* Struct; for( Struct = GetScreen()->EEDrawList; for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() ) Struct != NULL; Struct = Struct->Next() ) Struct->m_Flags = 0; Struct->m_Flags = 0; DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL; Loading @@ -203,9 +201,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) block->m_BlockDrawStruct = NULL; block->m_BlockDrawStruct = NULL; } } SetToolID( m_ID_current_state, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString ); DrawPanel->m_PanelDefaultCursor, wxEmptyString ); } } Loading Loading @@ -1152,10 +1148,7 @@ bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct ) if( !DrawStruct ) if( !DrawStruct ) return FALSE; return FALSE; move_vector.x = screen->m_Curseur.x - move_vector = screen->m_Curseur - screen->BlockLocate.m_BlockLastCursorPosition; screen->BlockLocate.m_BlockLastCursorPosition.x; move_vector.y = screen->m_Curseur.y - screen->BlockLocate.m_BlockLastCursorPosition.y; switch( DrawStruct->Type() ) switch( DrawStruct->Type() ) { { Loading Loading @@ -1709,8 +1702,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) /*********************************************************************************/ /*********************************************************************************/ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, wxPoint& position ) wxPoint& aPosition ) /*********************************************************************************/ /*********************************************************************************/ { { EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry; Loading @@ -1720,19 +1713,19 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, int orient; int orient; LibDrawPin* Pin; LibDrawPin* Pin; if( DrawLibItem ) if( aDrawLibItem ) { { NextItem = NULL; NextItem = NULL; if( ( Entry = if( ( Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FindLibPart( aDrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL ) FIND_ROOT ) ) == NULL ) return NULL; return NULL; DEntry = Entry->m_Drawings; DEntry = Entry->m_Drawings; Multi = DrawLibItem->m_Multi; Multi = aDrawLibItem->m_Multi; convert = DrawLibItem->m_Convert; convert = aDrawLibItem->m_Convert; PartX = DrawLibItem->m_Pos.x; PartX = aDrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y; PartY = aDrawLibItem->m_Pos.y; memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) ); } } else else DEntry = NextItem; DEntry = NextItem; Loading @@ -1753,10 +1746,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem, orient = Pin->ReturnPinDrawOrient( TransMat ); orient = Pin->ReturnPinDrawOrient( TransMat ); /* Calcul de la position du point de reference */ /* Calcul de la position du point de reference */ position.x = PartX + (TransMat[0][0] *Pin->m_Pos.x) aPosition = TransformCoordinate( TransMat, Pin->m_Pos); + (TransMat[0][1] *Pin->m_Pos.y); position.y = PartY + (TransMat[1][0] *Pin->m_Pos.x) + (TransMat[1][1] *Pin->m_Pos.y); NextItem = DEntry->Next(); NextItem = DEntry->Next(); return DEntry; return DEntry; } } Loading
eeschema/block_libedit.cpp +20 −33 Original line number Original line Diff line number Diff line /****************************************************/ /****************************************************/ /* BLOCK.CPP */ /* block_libedt.cpp */ /* Gestion des Operations sur Blocks et Effacements */ /* Gestion des Operations sur Blocks et Effacements */ /****************************************************/ /****************************************************/ Loading Loading @@ -139,11 +139,11 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2; int ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList; for( ii = 0; ii < imax; ii ++ ) for( ii = 0; ii < imax; ii += 2 ) { { pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1]; pos = ( (LibDrawPolyline*) item )->m_PolyPoints[ii]; NEGATE( pos.y ); if( Rect.Inside( pos ) ) if( Rect.Inside( pos ) ) { { item->m_Selected = IS_SELECTED; item->m_Selected = IS_SELECTED; Loading Loading @@ -537,7 +537,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) if( LibEntry == NULL ) if( LibEntry == NULL ) return; return; offset.y = -offset.y; // Y axis for lib items is Down to Up: reverse y offset value NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value item = LibEntry->m_Drawings; item = LibEntry->m_Drawings; for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() ) { { Loading @@ -547,42 +547,31 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) switch( item->Type() ) switch( item->Type() ) { { case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE: ( (LibDrawPin*) item )->m_Pos.x += offset.x; ( (LibDrawPin*) item )->m_Pos += offset; ( (LibDrawPin*) item )->m_Pos.y += offset.y; break; break; case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE: { { ( (LibDrawArc*) item )->m_Pos.x += offset.x; ( (LibDrawArc*) item )->m_Pos += offset; ( (LibDrawArc*) item )->m_Pos.y += offset.y; ( (LibDrawArc*) item )->m_ArcStart += offset; ( (LibDrawArc*) item )->m_ArcStart.x += offset.x; ( (LibDrawArc*) item )->m_ArcEnd += offset; ( (LibDrawArc*) item )->m_ArcStart.y += offset.y; ( (LibDrawArc*) item )->m_ArcEnd.x += offset.x; ( (LibDrawArc*) item )->m_ArcEnd.y += offset.y; break; break; } } case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE: ( (LibDrawCircle*) item )->m_Pos.x += offset.x; ( (LibDrawCircle*) item )->m_Pos += offset; ( (LibDrawCircle*) item )->m_Pos.y += offset.y; break; break; case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE: ( (LibDrawSquare*) item )->m_Pos.x += offset.x; ( (LibDrawSquare*) item )->m_Pos += offset; ( (LibDrawSquare*) item )->m_Pos.y += offset.y; ( (LibDrawSquare*) item )->m_End += offset; ( (LibDrawSquare*) item )->m_End.x += offset.x; ( (LibDrawSquare*) item )->m_End.y += offset.y; break; break; case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2; unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList; for( ii = 0; ii < imax; ii ++ ) for( ii = 0; ii < imax; ii += 2 ) ( (LibDrawPolyline*) item )->m_PolyPoints[ii] += offset; { ptpoly[ii] += offset.x; ptpoly[ii + 1] += offset.y; } } } break; break; Loading @@ -590,8 +579,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) break; break; case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: ( (LibDrawText*) item )->m_Pos.x += offset.x; ( (LibDrawText*) item )->m_Pos += offset; ( (LibDrawText*) item )->m_Pos.y += offset.y; break; break; default: default: Loading Loading @@ -688,11 +676,10 @@ void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2; unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList; for( ii = 0; ii < imax; ii ++ ) for( ii = 0; ii < imax; ii += 2 ) { { SETMIRROR( ptpoly[ii] ); SETMIRROR( ( (LibDrawPolyline*) item )->m_PolyPoints[ii].x ); } } } } break; break; Loading
eeschema/class_libentry.cpp +10 −19 Original line number Original line Diff line number Diff line Loading @@ -118,7 +118,6 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) **/ **/ { { int xmin, xmax, ymin, ymax, x1, y1; int xmin, xmax, ymin, ymax, x1, y1; int* pt, ii; LibEDA_BaseStruct* DrawEntry; LibEDA_BaseStruct* DrawEntry; EDA_Rect BoundaryBox; EDA_Rect BoundaryBox; Loading Loading @@ -232,21 +231,15 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE: { { LibDrawPolyline* polyline = (LibDrawPolyline*) DrawEntry; EDA_Rect rect = ((LibDrawPolyline*) DrawEntry)->GetBoundaryBox( ); pt = polyline->m_PolyList; xmin = MIN( xmin, rect.GetX() ); for( ii = 0; ii < polyline->m_CornersCount; ii++ ) xmax = MAX( xmax, rect.GetX() ); { ymin = MIN( ymin, rect.GetY() ); if( xmin > *pt ) ymax = MAX( ymax, rect.GetY() ); xmin = *pt; xmin = MIN( xmin, rect.GetEnd().x ); if( xmax < *pt ) xmax = MAX( xmax, rect.GetEnd().x ); xmax = *pt; ymin = MIN( ymin, rect.GetEnd().y ); pt++; ymax = MAX( ymax, rect.GetEnd().y ); if( ymin > *pt ) ymin = *pt; if( ymax < *pt ) ymax = *pt; pt++; } } } break; break; Loading @@ -257,9 +250,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) // Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */ // Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */ NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense // Ensure w and H > 0 (wxRect assume it) // Ensure H > 0 (wxRect assume it) if( xmax < xmin ) EXCHG( xmax, xmin ); if( ymax < ymin ) if( ymax < ymin ) EXCHG( ymax, ymin ); EXCHG( ymax, ymin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); Loading
eeschema/classes_body_items.cpp +64 −44 Original line number Original line Diff line number Diff line Loading @@ -240,8 +240,8 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int color = ReturnLayerColor( LAYER_DEVICE ); int color = ReturnLayerColor( LAYER_DEVICE ); int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); int linewidth = MAX( m_Width, g_DrawMinimunLineWidth ); static int* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings static wxPoint* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings static int Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings static unsigned Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings if( aColor < 0 ) // Used normal color or selected color if( aColor < 0 ) // Used normal color or selected color { { Loading @@ -254,25 +254,19 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, // Set the size of the buffer od coordinates // Set the size of the buffer od coordinates if( Buf_Poly_Drawings == NULL ) if( Buf_Poly_Drawings == NULL ) { { Buf_Poly_Size = m_CornersCount; Buf_Poly_Size = m_PolyPoints.size(); Buf_Poly_Drawings = (int*) MyMalloc( sizeof(int) * 2 * Buf_Poly_Size ); Buf_Poly_Drawings = (wxPoint*) MyMalloc( sizeof(wxPoint) * Buf_Poly_Size ); } } else if( Buf_Poly_Size < m_CornersCount ) else if( Buf_Poly_Size < m_PolyPoints.size() ) { { Buf_Poly_Size = m_CornersCount; Buf_Poly_Size = m_PolyPoints.size(); Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings, Buf_Poly_Drawings = (wxPoint*) realloc( Buf_Poly_Drawings, sizeof(int) * 2 * Buf_Poly_Size ); sizeof(wxPoint) * Buf_Poly_Size ); } } for( int ii = 0, jj = 0; ii < m_CornersCount; ii++, jj += 2 ) for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { { pos1.x = m_PolyList[jj]; Buf_Poly_Drawings[ii] = TransformCoordinate( aTransformMatrix, m_PolyPoints[ii] ) + aOffset; pos1.y = m_PolyList[jj + 1]; pos1 = TransformCoordinate( aTransformMatrix, pos1 ) + aOffset; Buf_Poly_Drawings[jj] = pos1.x; Buf_Poly_Drawings[jj + 1] = pos1.y; } } FILL_T fill = aData ? NO_FILL : m_Fill; FILL_T fill = aData ? NO_FILL : m_Fill; Loading @@ -280,15 +274,15 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, fill = NO_FILL; fill = NO_FILL; if( fill == FILLED_WITH_BG_BODYCOLOR ) if( fill == FILLED_WITH_BG_BODYCOLOR ) GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), (wxPoint*) Buf_Poly_Drawings, 1, linewidth, color, Buf_Poly_Drawings, 1, linewidth, color, ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( fill == FILLED_SHAPE ) else if( fill == FILLED_SHAPE ) GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC,m_PolyPoints.size(), (wxPoint*) Buf_Poly_Drawings, 1, linewidth, color, color ); Buf_Poly_Drawings, 1, linewidth, color, color ); else else GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(), (wxPoint*) Buf_Poly_Drawings, 0, linewidth, color, color ); Buf_Poly_Drawings, 0, linewidth, color, color ); } } Loading Loading @@ -520,8 +514,6 @@ LibDrawSegment* LibDrawSegment::GenCopy() LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE ) LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE ) { { m_CornersCount = 0; m_PolyList = NULL; m_Fill = NO_FILL; m_Fill = NO_FILL; m_Width = 0; m_Width = 0; } } Loading @@ -532,16 +524,7 @@ LibDrawPolyline* LibDrawPolyline::GenCopy() /************************************************/ /************************************************/ { { LibDrawPolyline* newitem = new LibDrawPolyline(); LibDrawPolyline* newitem = new LibDrawPolyline(); newitem->m_PolyPoints = m_PolyPoints; // Vector copy int size; newitem->m_CornersCount = m_CornersCount; size = sizeof(int) * 2 * m_CornersCount; if( size ) { newitem->m_PolyList = (int*) MyMalloc( size ); memcpy( newitem->m_PolyList, m_PolyList, size ); } newitem->m_Width = m_Width; newitem->m_Width = m_Width; newitem->m_Unit = m_Unit; newitem->m_Unit = m_Unit; newitem->m_Convert = m_Convert; newitem->m_Convert = m_Convert; Loading @@ -555,18 +538,55 @@ LibDrawPolyline* LibDrawPolyline::GenCopy() void LibDrawPolyline::AddPoint( const wxPoint& point ) void LibDrawPolyline::AddPoint( const wxPoint& point ) /***************************************************/ /***************************************************/ /* add a point to the polyline coordinate list, and realloc the memory /* add a point to the polyline coordinate list */ */ { { int allocsize; m_PolyPoints.push_back( point ); } m_CornersCount++; allocsize = 2 * sizeof(int) * m_CornersCount; if( m_PolyList == NULL ) m_PolyList = (int*) MyMalloc( allocsize ); else m_PolyList = (int*) realloc( m_PolyList, allocsize ); m_PolyList[(m_CornersCount * 2) - 2] = point.x; /** Function HitTest m_PolyList[(m_CornersCount * 2) - 1] = -point.y; * @return true if the point aPosRef is near a segment * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to a segment * @param aTransMat = the transform matrix */ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, int aTransMat[2][2] ) { aPosRef = TransformCoordinate( aTransMat, aPosRef); /* Move origin coordinate to segment start point */ wxPoint end; for ( unsigned ii = 0; ii < m_PolyPoints.size() -1; ii++ ) { aPosRef -= m_PolyPoints[0]; end = m_PolyPoints[1] - m_PolyPoints[0]; if( distance( end.x, end.y, aPosRef.x, aPosRef.y, aThreshold ) ) return true; } return false; } /** Function GetBoundaryBox * @return the boundary box for this, in library coordinates */ EDA_Rect LibDrawPolyline::GetBoundaryBox( ) { EDA_Rect BoundaryBox; int xmin, xmax, ymin, ymax; xmin = xmax = m_PolyPoints[0].x; ymin = ymax = m_PolyPoints[0].y; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { xmin = MIN( xmin, m_PolyPoints[0].x ); xmax = MAX( xmax, m_PolyPoints[0].x ); ymin = MIN( ymin, m_PolyPoints[0].y ); ymax = MAX( ymax, m_PolyPoints[0].y ); } BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin ); return BoundaryBox; } }