Commit 41c80dd9 authored by charras's avatar charras

pcbnew: work on undo/redo in progress

parent f9be70f2
...@@ -64,9 +64,10 @@ set(PCB_COMMON_SRCS ...@@ -64,9 +64,10 @@ set(PCB_COMMON_SRCS
../pcbnew/class_netclass.cpp ../pcbnew/class_netclass.cpp
../pcbnew/class_netinfo_item.cpp ../pcbnew/class_netinfo_item.cpp
../pcbnew/class_netinfolist.cpp ../pcbnew/class_netinfolist.cpp
../pcbnew/class_marker.cpp ../pcbnew/class_marker_pcb.cpp
../pcbnew/class_mire.cpp ../pcbnew/class_mire.cpp
../pcbnew/class_module.cpp ../pcbnew/class_module.cpp
../pcbnew/class_module_transform_functions.cpp
../pcbnew/class_pad.cpp ../pcbnew/class_pad.cpp
../pcbnew/class_pad_draw_functions.cpp ../pcbnew/class_pad_draw_functions.cpp
../pcbnew/class_pcb_text.cpp ../pcbnew/class_pcb_text.cpp
......
...@@ -113,11 +113,11 @@ EDA_BaseStruct* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) ...@@ -113,11 +113,11 @@ EDA_BaseStruct* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
} }
/** function GetLink /** function GetPickedItemLink
* @return link of the picked item, or null if does not exist * @return link of the picked item, or null if does not exist
* @param aIdx = index of the picked item in the picked list * @param aIdx = index of the picked item in the picked list
*/ */
EDA_BaseStruct* PICKED_ITEMS_LIST::GetLink( unsigned int aIdx ) EDA_BaseStruct* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].m_Link; return m_ItemsList[aIdx].m_Link;
...@@ -157,13 +157,13 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_BaseStruct* aItem, unsigned aIdx ) ...@@ -157,13 +157,13 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_BaseStruct* aItem, unsigned aIdx )
} }
/** function SetLink /** function SetPickedItemLink
* Set the link associated to a given picked item * Set the link associated to a given picked item
* @param aLink = the link to the item associated to the picked item * @param aLink = the link to the item associated to the picked item
* @param aIdx = index of the picker in the picked list * @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist * @return true if the picker exists, or false if does not exist
*/ */
bool PICKED_ITEMS_LIST::SetLink( EDA_BaseStruct* aLink, unsigned aIdx ) bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_BaseStruct* aLink, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {
......
...@@ -812,7 +812,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -812,7 +812,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
#undef STRUCT #undef STRUCT
#define STRUCT ( (MARKER_SCH*) Struct ) #define STRUCT ( (MARKER_SCH*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
......
...@@ -32,14 +32,14 @@ const wxChar* NameMarqueurType[] = ...@@ -32,14 +32,14 @@ const wxChar* NameMarqueurType[] =
/**************************/ /**************************/
MARKER_SCH::MARKER_SCH() : MARKER_SCH::MARKER_SCH() :
SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ), SCH_ITEM( NULL, TYPE_MARKER_SCH ),
MARKER_BASE() MARKER_BASE()
{ {
} }
MARKER_SCH::MARKER_SCH( const wxPoint& pos, const wxString& text ) : MARKER_SCH::MARKER_SCH( const wxPoint& pos, const wxString& text ) :
SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ), SCH_ITEM( NULL, TYPE_MARKER_SCH ),
MARKER_BASE( 0, pos, text, pos ) MARKER_BASE( 0, pos, text, pos )
{ {
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
/* classes to handle markers used in schematic ... */ /* classes to handle markers used in schematic ... */
/***************************************************/ /***************************************************/
#ifndef _CLASS_MARKER_SCH_H_ #ifndef _TYPE_MARKER_SCH_H_
#define _CLASS_MARKER_SCH_H_ #define _TYPE_MARKER_SCH_H_
#include "sch_item_struct.h" #include "sch_item_struct.h"
#include "class_marker_base.h" #include "class_marker_base.h"
...@@ -103,4 +103,4 @@ public: ...@@ -103,4 +103,4 @@ public:
#endif #endif
}; };
#endif /* _CLASS_MARKER_SCH_H_ */ #endif /* _TYPE_MARKER_SCH_H_ */
...@@ -26,7 +26,7 @@ void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) ...@@ -26,7 +26,7 @@ void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
Struct->SetParent( Screen ); Struct->SetParent( Screen );
break; break;
......
...@@ -115,7 +115,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen ) ...@@ -115,7 +115,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
......
...@@ -474,7 +474,7 @@ void DeleteAllMarkers( int type ) ...@@ -474,7 +474,7 @@ void DeleteAllMarkers( int type )
for( DrawStruct = screen->EEDrawList; DrawStruct != NULL; DrawStruct = NextStruct ) for( DrawStruct = screen->EEDrawList; DrawStruct != NULL; DrawStruct = NextStruct )
{ {
NextStruct = DrawStruct->Next(); NextStruct = DrawStruct->Next();
if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE ) if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue; continue;
/* Marqueur trouve */ /* Marqueur trouve */
......
...@@ -303,7 +303,7 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -303,7 +303,7 @@ void DIALOG_ERC::DisplayERC_MarkersList()
SCH_ITEM* DrawStruct = Sheet->LastDrawList(); SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE ) if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue; continue;
/* Marqueur trouve */ /* Marqueur trouve */
......
...@@ -279,7 +279,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem ...@@ -279,7 +279,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
} }
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
break; break;
default: default:
......
...@@ -668,7 +668,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) ...@@ -668,7 +668,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
DrawStruct = Sheet->LastDrawList(); DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE ) if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue; continue;
Marker = (MARKER_SCH*) DrawStruct; Marker = (MARKER_SCH*) DrawStruct;
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "protos.h" #include "protos.h"
#include "id.h" #include "id.h"
/* Fonctions locales */
/****************************************************************/ /****************************************************************/
void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
......
...@@ -291,7 +291,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType ) ...@@ -291,7 +291,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType )
DrawList = (SCH_ITEM*) sheet->LastDrawList(); DrawList = (SCH_ITEM*) sheet->LastDrawList();
while( DrawList && NotFound ) while( DrawList && NotFound )
{ {
if( DrawList->Type() == DRAW_MARKER_STRUCT_TYPE ) if( DrawList->Type() == TYPE_MARKER_SCH )
{ {
Marker = (MARKER_SCH*) DrawList; Marker = (MARKER_SCH*) DrawList;
NotFound = FALSE; NotFound = FALSE;
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
/******************************************************/ /******************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
...@@ -16,6 +14,7 @@ ...@@ -16,6 +14,7 @@
#include "protos.h" #include "protos.h"
/* Routines Locales */ /* Routines Locales */
static bool DrawStructInBox(int x1, int y1, int x2, int y2, SCH_ITEM *DrawStruct);
static SCH_ITEM* LastSnappedStruct = NULL; static SCH_ITEM* LastSnappedStruct = NULL;
static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
int StartX2, int StartY2, int EndX2, int EndY2 ); int StartX2, int StartY2, int EndX2, int EndY2 );
...@@ -262,7 +261,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -262,7 +261,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
} }
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
{ {
#undef STRUCT #undef STRUCT
#define STRUCT ( (MARKER_SCH*) DrawList ) #define STRUCT ( (MARKER_SCH*) DrawList )
...@@ -358,7 +357,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -358,7 +357,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
wxString msg; wxString msg;
msg.Printf( wxT( "SnapPoint2() error: unexpected struct type %d (" ), DrawList->Type() ); msg.Printf( wxT( "SnapPoint2() error: unexpected struct type %d (" ), DrawList->Type() );
msg << DrawList->GetClass() << wxT( ")" ); msg << DrawList->GetClass() << wxT( ")" );
DisplayError( NULL, msg ); wxMessageBox( msg );
break; break;
} }
} }
...@@ -433,7 +432,7 @@ bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct ) ...@@ -433,7 +432,7 @@ bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct )
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
#undef STRUCT #undef STRUCT
#define STRUCT ( (MARKER_SCH*) DrawStruct ) #define STRUCT ( (MARKER_SCH*) DrawStruct )
if( (STRUCT->m_Pos.x >= x1) && (STRUCT->m_Pos.x <= x2) if( (STRUCT->m_Pos.x >= x1) && (STRUCT->m_Pos.x <= x2)
...@@ -540,7 +539,7 @@ bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct ) ...@@ -540,7 +539,7 @@ bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct )
wxT( "DrawStructInBox() Err: unexpected StructType %d (" ), wxT( "DrawStructInBox() Err: unexpected StructType %d (" ),
DrawStruct->Type() ); DrawStruct->Type() );
msg << DrawStruct->GetClass() << wxT( ")" ); msg << DrawStruct->GetClass() << wxT( ")" );
DisplayError( NULL, msg ); wxMessageBox( msg );
break; break;
} }
...@@ -634,7 +633,7 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen, ...@@ -634,7 +633,7 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
if( LibEntry->Type != ROOT ) if( LibEntry->Type != ROOT )
{ {
DisplayError( NULL, wxT( "Error in LocateDrawItem: Entry is ALIAS" ) ); wxMessageBox( wxT( "Error in LocateDrawItem: Entry is ALIAS" ) );
return NULL; return NULL;
} }
...@@ -729,7 +728,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number, ...@@ -729,7 +728,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
if( Entry->Type != ROOT ) if( Entry->Type != ROOT )
{ {
DisplayError( NULL, wxT( "LocatePinByNumber() error: Entry is ALIAS" ) ); wxMessageBox( wxT( "LocatePinByNumber() error: Entry is ALIAS" ) );
return NULL; return NULL;
} }
...@@ -776,7 +775,7 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, ...@@ -776,7 +775,7 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
if( Entry->Type != ROOT ) if( Entry->Type != ROOT )
{ {
DisplayError( NULL, wxT( "LocatePin() error: Entry is ALIAS" ) ); wxMessageBox( wxT( "LocatePin() error: Entry is ALIAS" ) );
return NULL; return NULL;
} }
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
/***********************************/ /***********************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
...@@ -535,7 +533,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -535,7 +533,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
break; break;
...@@ -569,15 +567,12 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -569,15 +567,12 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
break; break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DisplayError( NULL, wxT( "Netlist: Type DRAW_SHEETLABEL inattendu" ) );
break;
default: default:
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "Netlist: unexpected type struct %d" ), msg.Printf( wxT( "Netlist: unexpected struct type %d" ),
DrawList->Type() ); DrawList->Type() );
DisplayError( NULL, msg ); wxMessageBox( msg );
break; break;
} }
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/******************************************************/ /******************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "id.h" #include "id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -370,7 +369,7 @@ void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -370,7 +369,7 @@ void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
((MARKER_SCH*)DrawStruct)->DisplayMarkerInfo( this); ((MARKER_SCH*)DrawStruct)->DisplayMarkerInfo( this);
break; break;
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
/* droit de la souris */ /* droit de la souris */
/******************************************************************/ /******************************************************************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "id.h" #include "id.h"
...@@ -140,7 +136,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -140,7 +136,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
_( "Delete Bus Entry" ), delete_bus_xpm ); _( "Delete Bus Entry" ), delete_bus_xpm );
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
AddMenusForMarkers( PopMenu, (MARKER_SCH*) DrawStruct, this ); AddMenusForMarkers( PopMenu, (MARKER_SCH*) DrawStruct, this );
break; break;
......
...@@ -169,7 +169,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, co ...@@ -169,7 +169,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, co
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
default: default:
break; break;
...@@ -232,7 +232,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) ...@@ -232,7 +232,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
NewDrawStruct = ( (DrawJunctionStruct*) DrawStruct )->GenCopy(); NewDrawStruct = ( (DrawJunctionStruct*) DrawStruct )->GenCopy();
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
NewDrawStruct = ( (MARKER_SCH*) DrawStruct )->GenCopy(); NewDrawStruct = ( (MARKER_SCH*) DrawStruct )->GenCopy();
break; break;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/***************************************************/ /***************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "plot_common.h" #include "plot_common.h"
#include "worksheet.h" #include "worksheet.h"
...@@ -756,7 +755,7 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist ) ...@@ -756,7 +755,7 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
......
...@@ -98,8 +98,6 @@ void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *DrawStruct); ...@@ -98,8 +98,6 @@ void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *DrawStruct);
/*************/ /*************/
/* LOCATE.CPP */ /* LOCATE.CPP */
/*************/ /*************/
bool DrawStructInBox(int x1, int y1, int x2, int y2,
SCH_ITEM *DrawStruct);
LibDrawPin* LocatePinByNumber( const wxString & ePin_Number, LibDrawPin* LocatePinByNumber( const wxString & ePin_Number,
SCH_COMPONENT* eComponent ); SCH_COMPONENT* eComponent );
......
...@@ -714,7 +714,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -714,7 +714,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_SCH_GETINFO_MARKER: case ID_POPUP_SCH_GETINFO_MARKER:
if( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_MARKER_STRUCT_TYPE ) if( screen->GetCurItem() && screen->GetCurItem()->Type() == TYPE_MARKER_SCH )
((MARKER_SCH*)screen->GetCurItem())->DisplayMarkerInfo( this ); ((MARKER_SCH*)screen->GetCurItem())->DisplayMarkerInfo( this );
break; break;
...@@ -775,7 +775,7 @@ void WinEDA_SchematicFrame::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC ) ...@@ -775,7 +775,7 @@ void WinEDA_SchematicFrame::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC )
StartMoveCmpField( (SCH_CMP_FIELD*) DrawStruct, DC ); StartMoveCmpField( (SCH_CMP_FIELD*) DrawStruct, DC );
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
default: default:
wxString msg; wxString msg;
......
...@@ -144,7 +144,7 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) ...@@ -144,7 +144,7 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
DEST->SwapData( SOURCE ); DEST->SwapData( SOURCE );
break; break;
case DRAW_MARKER_STRUCT_TYPE: case TYPE_MARKER_SCH:
#undef SOURCE #undef SOURCE
#undef DEST #undef DEST
#define SOURCE ( (MARKER_SCH*) aItem ) #define SOURCE ( (MARKER_SCH*) aItem )
...@@ -322,17 +322,16 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -322,17 +322,16 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
} }
/***************************************************************************/ /** Function PutDataInPreviousState()
void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) * Used in undo or redo command.
/***************************************************************************/
/* Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorised by List * Put data pointed by List in the previous state, i.e. the state memorised by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
*/ */
void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
{ {
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* alt_item; SCH_ITEM* alt_item;
bool as_moved = false;
for( unsigned ii = 0; ii < aList->GetCount(); ii++ ) for( unsigned ii = 0; ii < aList->GetCount(); ii++ )
{ {
...@@ -360,8 +359,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -360,8 +359,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
break; break;
case UR_MOVED: case UR_MOVED:
item->Move( - aList->m_TransformPoint ); item->Move( aRedoCommand ? aList->m_TransformPoint : - aList->m_TransformPoint );
as_moved = true;
break; break;
case UR_MIRRORED_Y: case UR_MIRRORED_Y:
...@@ -397,10 +395,6 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -397,10 +395,6 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
break; break;
} }
} }
// Undo for move transform needs to change the general move vector:
if ( as_moved )
aList->m_TransformPoint = - aList->m_TransformPoint;
} }
...@@ -411,8 +405,8 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) ...@@ -411,8 +405,8 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
/** Function GetSchematicFromUndoList /** Function GetSchematicFromUndoList
* Undo the last edition: * Undo the last edition:
* - Save the current schematic in Redo list * - Save the current schematic in Redo list
* - Get an old version of the schematic * - Get the previous version of the schematic from Unodo list
* @return false if nothing done, else true * @return none
*/ */
{ {
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
...@@ -422,7 +416,7 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) ...@@ -422,7 +416,7 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
/* Undo the command */ /* Undo the command */
PutDataInPreviousState( List ); PutDataInPreviousState( List, false );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -438,10 +432,11 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) ...@@ -438,10 +432,11 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event) void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event)
/**********************************************************/ /**********************************************************/
/* Redo the last edition: /** Function GetSchematicFromRedoList
* Redo the last edition:
* - Save the current schematic in undo list * - Save the current schematic in undo list
* - Get the old version * - Get the previous version from Redo list
* @return false if nothing done, else true * @return none
*/ */
{ {
if( GetScreen()->GetRedoCommandCount() == 0 ) if( GetScreen()->GetRedoCommandCount() == 0 )
...@@ -453,7 +448,7 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event) ...@@ -453,7 +448,7 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event)
GetScreen()->PushCommandToUndoList( List ); GetScreen()->PushCommandToUndoList( List );
/* Redo the command: */ /* Redo the command: */
PutDataInPreviousState( List ); PutDataInPreviousState( List, true );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
......
...@@ -70,7 +70,7 @@ if(APPLE) ...@@ -70,7 +70,7 @@ if(APPLE)
set_target_properties(gerbview PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(gerbview PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE) endif(APPLE)
target_link_libraries(gerbview 3d-viewer common pcbcommon polygon bitmaps kbool ${wxWidgets_LIBRARIES}) target_link_libraries(gerbview common pcbcommon 3d-viewer polygon bitmaps kbool ${wxWidgets_LIBRARIES})
install(TARGETS gerbview install(TARGETS gerbview
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
......
...@@ -24,27 +24,24 @@ enum KICAD_T { ...@@ -24,27 +24,24 @@ enum KICAD_T {
TYPE_NOT_INIT = 0, TYPE_NOT_INIT = 0,
TYPE_PCB, TYPE_PCB,
TYPE_SCREEN, // not really an item, used to identify a screen
// Items in pcb // Items in pcb
TYPE_MODULE, TYPE_MODULE, // a footprint
TYPE_PAD, TYPE_PAD, // a pad in a footprint
TYPE_DRAWSEGMENT, TYPE_DRAWSEGMENT, // a segment not on copper layers
TYPE_TEXTE, TYPE_TEXTE, // a text on a layer
TYPE_TEXTE_MODULE, TYPE_TEXTE_MODULE, // a text in a footprint
TYPE_EDGE_MODULE, TYPE_EDGE_MODULE, // a footprint edge
TYPE_TRACK, TYPE_TRACK, // a track segment (segment on a copper layer)
TYPE_CLR, TYPE_VIA, // a via (like atrack segment on a copper layer)
TYPE_ZONE, TYPE_ZONE, // a segment used to fill a zome area (segment on a copper layer)
TYPE_VIA, TYPE_MARKER_PCB, // a marker used to show something
TYPE_MARKER, TYPE_COTATION, // a dimension (graphic item)
TYPE_COTATION, TYPE_MIRE, // a target (graphic item)
TYPE_MIRE, TYPE_ZONE_EDGE_CORNER, // in zone outline: a point to define an outline
TYPE_SCREEN, TYPE_ZONE_CONTAINER, // a zone area
TYPE_BLOCK, TYPE_BOARD_ITEM_LIST, // a list of board items
TYPE_ZONE_UNUSED,
TYPE_ZONE_EDGE_CORNER,
TYPE_ZONE_CONTAINER,
TYPE_BOARD_ITEM_LIST,
// Draw Items in schematic // Draw Items in schematic
DRAW_POLYLINE_STRUCT_TYPE, DRAW_POLYLINE_STRUCT_TYPE,
...@@ -58,7 +55,7 @@ enum KICAD_T { ...@@ -58,7 +55,7 @@ enum KICAD_T {
DRAW_BUSENTRY_STRUCT_TYPE, DRAW_BUSENTRY_STRUCT_TYPE,
DRAW_SHEET_STRUCT_TYPE, DRAW_SHEET_STRUCT_TYPE,
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE,
DRAW_MARKER_STRUCT_TYPE, TYPE_MARKER_SCH,
DRAW_NOCONNECT_STRUCT_TYPE, DRAW_NOCONNECT_STRUCT_TYPE,
DRAW_PART_TEXT_STRUCT_TYPE, DRAW_PART_TEXT_STRUCT_TYPE,
...@@ -78,6 +75,9 @@ enum KICAD_T { ...@@ -78,6 +75,9 @@ enum KICAD_T {
COMPONENT_FIELD_DRAW_TYPE, COMPONENT_FIELD_DRAW_TYPE,
COMPONENT_BEZIER_DRAW_TYPE, COMPONENT_BEZIER_DRAW_TYPE,
// Special id used to store clearance values (this is not a good idea: TODO: change it)
TYPE_CLEARANCE,
// End value // End value
MAX_STRUCT_TYPE_ID MAX_STRUCT_TYPE_ID
}; };
......
...@@ -176,6 +176,36 @@ public: ...@@ -176,6 +176,36 @@ public:
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
virtual bool Save( FILE* aFile ) const = 0; virtual bool Save( FILE* aFile ) const = 0;
// Some geometric transforms, that must be rewrittem for derived classes
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
wxMessageBox(wxT("virtual BOARD_ITEM::Move used, should not occur"), GetClass());
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle)
{
wxMessageBox(wxT("virtual BOARD_ITEM::Rotate used, should not occur"), GetClass());
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre )
{
wxMessageBox(wxT("virtual BOARD_ITEM::Flip used, should not occur"), GetClass());
}
}; };
......
...@@ -135,11 +135,11 @@ public: ...@@ -135,11 +135,11 @@ public:
*/ */
EDA_BaseStruct* GetPickedItem( unsigned int aIdx ); EDA_BaseStruct* GetPickedItem( unsigned int aIdx );
/** function GetLink /** function GetPickedItemLink
* @return link of the picked item, or null if does not exist * @return link of the picked item, or null if does not exist
* @param aIdx = index of the picked item in the picked list * @param aIdx = index of the picked item in the picked list
*/ */
EDA_BaseStruct* GetLink( unsigned int aIdx ); EDA_BaseStruct* GetPickedItemLink( unsigned int aIdx );
/** function GetPickedItemStatus /** function GetPickedItemStatus
* @return the type of undo/redo opertaion associated to the picked item, * @return the type of undo/redo opertaion associated to the picked item,
...@@ -163,13 +163,13 @@ public: ...@@ -163,13 +163,13 @@ public:
*/ */
bool SetPickedItem( EDA_BaseStruct* aItem, UndoRedoOpType aStatus, unsigned aIdx ); bool SetPickedItem( EDA_BaseStruct* aItem, UndoRedoOpType aStatus, unsigned aIdx );
/** function SetLink /** function SetPickedItemLink
* Set the link associated to a given picked item * Set the link associated to a given picked item
* @param aLink = the link to the item associated to the picked item * @param aLink = the link to the item associated to the picked item
* @param aIdx = index of the picker in the picked list * @param aIdx = index of the picker in the picked list
* @return true if the pixker exists, or false if does not exist * @return true if the pixker exists, or false if does not exist
*/ */
bool SetLink( EDA_BaseStruct* aLink, unsigned aIdx ); bool SetPickedItemLink( EDA_BaseStruct* aLink, unsigned aIdx );
/** function SetPickedItemStatus /** function SetPickedItemStatus
* Set the the type of undo/redo operation for a given picked item * Set the the type of undo/redo operation for a given picked item
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
/* Forward declaration */ /* Forward declaration */
class NETINFO_ITEM; class NETINFO_ITEM;
class MARKER; class MARKER_PCB;
class RATSNEST_ITEM; class RATSNEST_ITEM;
...@@ -223,7 +223,7 @@ enum DisplayViaMode { ...@@ -223,7 +223,7 @@ enum DisplayViaMode {
#include "class_cotation.h" #include "class_cotation.h"
#include "class_mire.h" #include "class_mire.h"
#include "class_track.h" #include "class_track.h"
#include "class_marker.h" #include "class_marker_pcb.h"
#include "class_zone.h" #include "class_zone.h"
/* Values for DISPLAY_OPTIONS.ShowTrackClearanceMode parameter option /* Values for DISPLAY_OPTIONS.ShowTrackClearanceMode parameter option
......
...@@ -391,8 +391,26 @@ public: ...@@ -391,8 +391,26 @@ public:
const wxPoint& aTransformPoint = wxPoint(0,0) ); const wxPoint& aTransformPoint = wxPoint(0,0) );
private: private:
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList ); /** Function PutDataInPreviousState()
* Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorised by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
*/
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand );
/** Function GetSchematicFromRedoList
* Redo the last edition:
* - Save the current schematic in Undo list
* - Get an old version of the schematic from Redo list
* @return none
*/
void GetSchematicFromRedoList(wxCommandEvent& event); void GetSchematicFromRedoList(wxCommandEvent& event);
/** Function GetSchematicFromUndoList
* Undo the last edition:
* - Save the current schematic in Redo list
* - Get an old version of the schematic from Undo list
* @return none
*/
void GetSchematicFromUndoList(wxCommandEvent& event); void GetSchematicFromUndoList(wxCommandEvent& event);
......
...@@ -72,7 +72,7 @@ private: ...@@ -72,7 +72,7 @@ private:
void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu ); void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu );
void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ); void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu );
void createPopUpBlockMenu( wxMenu* menu ); void createPopUpBlockMenu( wxMenu* menu );
void createPopUpMenuForMarkers( MARKER* aMarker, wxMenu* aPopMenu ); void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
public: public:
WinEDA_PcbFrame( wxWindow* father, const wxString& title, WinEDA_PcbFrame( wxWindow* father, const wxString& title,
...@@ -156,8 +156,26 @@ public: ...@@ -156,8 +156,26 @@ public:
void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand, void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint = wxPoint(0,0) ); const wxPoint& aTransformPoint = wxPoint(0,0) );
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList ); /** Function PutDataInPreviousState()
* Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorised by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
*/
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand );
/** Function GetBoardFromRedoList
* Redo the last edition:
* - Save the current board in Undo list
* - Get an old version of the board from Redo list
* @return none
*/
void GetBoardFromRedoList(wxCommandEvent& event); void GetBoardFromRedoList(wxCommandEvent& event);
/** Function GetBoardFromUndoList
* Undo the last edition:
* - Save the current board in Redo list
* - Get an old version of the board from Undo list
* @return none
*/
void GetBoardFromUndoList(wxCommandEvent& event); void GetBoardFromUndoList(wxCommandEvent& event);
/* Gestion generale des operations sur block */ /* Gestion generale des operations sur block */
...@@ -166,41 +184,55 @@ public: ...@@ -166,41 +184,55 @@ public:
int HandleBlockEnd( wxDC* DC ); int HandleBlockEnd( wxDC* DC );
/* Block operations: */ /* Block operations: */
/**
* Function Block_SelectItems
* Uses GetScreen()->m_BlockLocate
* select items within the selected block.
* selected items are put in the pick list
* @param none
*/
void Block_SelectItems( );
/** /**
* Function Block_Delete * Function Block_Delete
* deletes all tracks and segments within the selected block. * deletes all items within the selected block.
* Defined separately in pcbnew and gerbview * @param none
*
* @param DC A device context to draw on.
*/ */
void Block_Delete( wxDC* DC ); void Block_Delete( );
void Block_Rotate( wxDC* DC ); /**
void Block_Invert( wxDC* DC ); * Function Block_Rotate
* Rotate all items within the selected block.
* The rotation centre is the centre of the block
* @param none
*/
void Block_Rotate( );
/**
* Function Block_Flip
* Flip items within the selected block.
* The flip centre is the centre of the block
* @param none
*/
void Block_Flip( );
/** /**
* Function Block_Move * Function Block_Move
* moves all tracks and segments within the selected block. * move all items within the selected block.
* New location is determined by the current offset from the selected block's original location. * New location is determined by the current offset from the selected block's original location.
* Defined separately in pcbnew and gerbview * @param none
*
* @param DC A device context to draw on.
*/ */
void Block_Move( wxDC* DC ); void Block_Move( );
/** /**
* Function Block_Mirror_X * Function Block_Mirror_X
* mirrors all tracks and segments within the currently selected block in the X axis. * mirrors all items within the currently selected block in the X axis.
* * @param none
* @param DC A device context to draw on.
*/ */
void Block_Mirror_X( wxDC* DC ); void Block_Mirror_X( );
/** /**
* Function Block_Duplicate * Function Block_Duplicate
* copies-and-moves all tracks and segments within the selected block. * Duplicate all items within the selected block.
* New location is determined by the current offset from the selected block's original location. * New location is determined by the current offset from the selected block's original location.
* Defined separately in pcbnew and gerbview * @param none
*
* @param DC A device context to draw on.
*/ */
void Block_Duplicate( wxDC* DC ); void Block_Duplicate( );
void SetToolbars(); void SetToolbars();
......
...@@ -123,28 +123,38 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent, ...@@ -123,28 +123,38 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
// Selection des options : // Selection des options :
m_Include_Modules = new wxCheckBox( this, -1, _( "Include Modules" ), wxDefaultPosition, wxDefaultSize, 0 ); m_Include_Modules = new wxCheckBox( this, -1, _(
"Include Modules" ), wxDefaultPosition, wxDefaultSize,
0 );
m_Include_Modules->SetValue( Block_Include_Modules ); m_Include_Modules->SetValue( Block_Include_Modules );
fgSizer1->Add( m_Include_Modules, 0, wxALL, 5 ); fgSizer1->Add( m_Include_Modules, 0, wxALL, 5 );
m_Include_Tracks = new wxCheckBox( this, -1, _( "Include tracks" ), wxDefaultPosition, wxDefaultSize, 0 ); m_Include_Tracks = new wxCheckBox( this, -1, _(
"Include tracks" ), wxDefaultPosition, wxDefaultSize, 0 );
m_Include_Tracks->SetValue( Block_Include_Tracks ); m_Include_Tracks->SetValue( Block_Include_Tracks );
fgSizer1->Add( m_Include_Tracks, 0, wxALL, 5 ); fgSizer1->Add( m_Include_Tracks, 0, wxALL, 5 );
m_Include_Zones = new wxCheckBox( this, -1, _( "Include zones" ), wxDefaultPosition, wxDefaultSize, 0 ); m_Include_Zones = new wxCheckBox( this, -1, _(
"Include zones" ), wxDefaultPosition, wxDefaultSize, 0 );
m_Include_Zones->SetValue( Block_Include_Zones ); m_Include_Zones->SetValue( Block_Include_Zones );
fgSizer1->Add( m_Include_Zones, 0, wxALL, 5 ); fgSizer1->Add( m_Include_Zones, 0, wxALL, 5 );
m_Include_PcbTextes = new wxCheckBox( this, -1, m_Include_PcbTextes = new wxCheckBox( this, -1,
_( "Include Text on copper layers" ), wxDefaultPosition, wxDefaultSize, 0 ); _(
"Include Text on copper layers" ), wxDefaultPosition,
wxDefaultSize, 0 );
m_Include_PcbTextes->SetValue( Block_Include_PcbTextes ); m_Include_PcbTextes->SetValue( Block_Include_PcbTextes );
fgSizer1->Add( m_Include_PcbTextes, 0, wxALL, 5 ); fgSizer1->Add( m_Include_PcbTextes, 0, wxALL, 5 );
m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include drawings" ), wxDefaultPosition, wxDefaultSize, 0 ); m_Include_Draw_Items = new wxCheckBox( this, -1, _(
"Include drawings" ), wxDefaultPosition,
wxDefaultSize, 0 );
m_Include_Draw_Items->SetValue( Block_Include_Draw_Items ); m_Include_Draw_Items->SetValue( Block_Include_Draw_Items );
fgSizer1->Add( m_Include_Draw_Items, 0, wxALL, 5 ); fgSizer1->Add( m_Include_Draw_Items, 0, wxALL, 5 );
m_Include_Edges_Items = new wxCheckBox( this, -1, _( "Include board outline layer" ), wxDefaultPosition, wxDefaultSize, 0 ); m_Include_Edges_Items = new wxCheckBox( this, -1, _(
"Include board outline layer" ), wxDefaultPosition,
wxDefaultSize, 0 );
m_Include_Edges_Items->SetValue( Block_Include_Edges_Items ); m_Include_Edges_Items->SetValue( Block_Include_Edges_Items );
fgSizer1->Add( m_Include_Edges_Items, 0, wxALL, 5 ); fgSizer1->Add( m_Include_Edges_Items, 0, wxALL, 5 );
...@@ -155,7 +165,8 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent, ...@@ -155,7 +165,8 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
/* Creation des boutons de commande */ /* Creation des boutons de commande */
m_button2 = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); m_button2 = new wxButton( this, wxID_CANCEL, _(
"Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_button2, 0, wxALL, 5 ); fgSizer2->Add( m_button2, 0, wxALL, 5 );
m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 ); m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 );
m_button1->SetDefault(); m_button1->SetDefault();
...@@ -261,14 +272,14 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -261,14 +272,14 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Move( DC ); Block_Move();
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Duplicate( DC ); Block_Duplicate();
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
...@@ -334,7 +345,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -334,7 +345,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
Block_Delete( DC ); Block_Delete();
break; break;
case BLOCK_ROTATE: /* Rotation */ case BLOCK_ROTATE: /* Rotation */
...@@ -343,7 +354,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -343,7 +354,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
Block_Rotate( DC ); Block_Rotate();
break; break;
case BLOCK_INVERT: /* Flip */ case BLOCK_INVERT: /* Flip */
...@@ -352,7 +363,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -352,7 +363,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
Block_Invert( DC ); Block_Flip();
break; break;
case BLOCK_SAVE: /* Save (not used, for future enhancements)*/ case BLOCK_SAVE: /* Save (not used, for future enhancements)*/
...@@ -361,7 +372,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -361,7 +372,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
{ {
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
// SaveStruct(GetScreen()->m_BlockLocate.m_BlockDrawStruct); // TODO (if useful) Save_Block( );
} }
break; break;
...@@ -395,78 +406,36 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -395,78 +406,36 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
} }
/**************************************************************************/ /* Block operations: */
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/**************************************************************************/
/* Retrace le contour du block de repositionnement des structures a dplacer
*/
{
int Color;
BASE_SCREEN* screen = panel->GetScreen();
Color = YELLOW;
/* Effacement ancien cadre */
if( erase )
{
screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0), g_XorMode, Color );
if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{
screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector, g_XorMode, Color );
}
}
if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP )
{
screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->m_BlockLocate.GetRight();
screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->m_BlockLocate.GetBottom();
}
screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0), g_XorMode, Color );
if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{
screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector, g_XorMode, Color );
}
}
/************************************************/ /**
void WinEDA_PcbFrame::Block_Delete( wxDC* DC ) * Function Block_SelectItems
/************************************************/ * Uses GetScreen()->m_BlockLocate
/* * select items within the selected block.
* routine d'effacement du block deja selectionne * selected items are put in the pick list
* @param none
*/ */
void WinEDA_PcbFrame::Block_SelectItems()
{ {
BOARD_ITEM* PtStruct, * NextS; BOARD_ITEM* PtStruct;
int masque_layer; int masque_layer;
if( !InstallBlockCmdFrame( this, _( "Delete Block" ) ) )
return;
GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
SetCurItem( NULL );
PICKED_ITEMS_LIST itemsList; PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
ITEM_PICKER picker(NULL,UR_DELETED); ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
/* Effacement des modules */ /* Effacement des modules */
if( Block_Include_Modules ) if( Block_Include_Modules )
{ {
MODULE* module; ;
module = m_Pcb->m_Modules; for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() )
for( ; module != NULL; module = (MODULE*) NextS )
{ {
NextS = module->Next();
if( module->HitTest( GetScreen()->m_BlockLocate ) ) if( module->HitTest( GetScreen()->m_BlockLocate ) )
{ {
module->m_Flags = 0;
module->UnLink();
m_Pcb->m_Status_Pcb = 0;
picker.m_PickedItem = module; picker.m_PickedItem = module;
picker.m_PickedItemType = module->Type(); picker.m_PickedItemType = module->Type();
itemsList.PushItem(picker); itemsList->PushItem( picker );
} }
} }
} }
...@@ -474,23 +443,19 @@ void WinEDA_PcbFrame::Block_Delete( wxDC* DC ) ...@@ -474,23 +443,19 @@ void WinEDA_PcbFrame::Block_Delete( wxDC* DC )
/* Remove tracks and vias */ /* Remove tracks and vias */
if( Block_Include_Tracks ) if( Block_Include_Tracks )
{ {
TRACK* pt_segm; for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() )
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS )
{ {
NextS = pt_segm->Next();
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) ) if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
{ {
/* This track is in bloc: remove it */ /* This track is in bloc: select it */
pt_segm->UnLink();
picker.m_PickedItem = pt_segm; picker.m_PickedItem = pt_segm;
picker.m_PickedItemType = pt_segm->Type(); picker.m_PickedItemType = pt_segm->Type();
itemsList.PushItem(picker); itemsList->PushItem( picker );
} }
} }
} }
/* Remove graphic items */ /* Select graphic items */
masque_layer = EDGE_LAYER; masque_layer = EDGE_LAYER;
if( Block_Include_Draw_Items ) if( Block_Include_Draw_Items )
masque_layer = ALL_LAYERS; masque_layer = ALL_LAYERS;
...@@ -498,786 +463,518 @@ void WinEDA_PcbFrame::Block_Delete( wxDC* DC ) ...@@ -498,786 +463,518 @@ void WinEDA_PcbFrame::Block_Delete( wxDC* DC )
if( !Block_Include_Edges_Items ) if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER; masque_layer &= ~EDGE_LAYER;
PtStruct = m_Pcb->m_Drawings; for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
for( ; PtStruct != NULL; PtStruct = NextS )
{ {
NextS = PtStruct->Next(); bool select_me = false;
bool remove_me = false;
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
remove_me = true; // This item is in bloc: remove it select_me = true; // This item is in bloc: select it
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
remove_me = true; // This item is in bloc: remove it select_me = true; // This item is in bloc: select it
break; break;
case TYPE_MIRE: case TYPE_MIRE:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
remove_me = true; // This item is in bloc: remove it select_me = true; // This item is in bloc: select it
break; break;
case TYPE_COTATION: case TYPE_COTATION:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
remove_me = true; // This item is in bloc: remove it select_me = true; // This item is in bloc: select it
break; break;
default: default:
break; break;
} }
if ( remove_me ) if( select_me )
{ {
PtStruct->UnLink();
picker.m_PickedItem = PtStruct; picker.m_PickedItem = PtStruct;
picker.m_PickedItemType = PtStruct->Type(); picker.m_PickedItemType = PtStruct->Type();
itemsList.PushItem(picker); itemsList->PushItem( picker );
} }
} }
/* Effacement des Zones */ /* Effacement des Zones */
if( Block_Include_Zones ) if( Block_Include_Zones )
{ {
SEGZONE* pt_segm, *NextSegZ; for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = pt_segm->Next() )
Affiche_Message( _( "Delete zones" ) );
for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextSegZ )
{ {
NextSegZ = pt_segm->Next();
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) ) if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
{ {
pt_segm->UnLink();
picker.m_PickedItem = PtStruct; picker.m_PickedItem = PtStruct;
picker.m_PickedItemType = PtStruct->Type(); picker.m_PickedItemType = PtStruct->Type();
itemsList.PushItem(picker); itemsList->PushItem( picker );
} }
} }
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) ) if( m_Pcb->GetArea( ii )->HitTest( GetScreen()->m_BlockLocate ) )
{ {
BOARD_ITEM* zone_c = m_Pcb->Remove(m_Pcb->GetArea(ii)); BOARD_ITEM* zone_c = m_Pcb->GetArea( ii );
ii--; // because the current data was removed, ii points actually the next data
picker.m_PickedItem = zone_c; picker.m_PickedItem = zone_c;
picker.m_PickedItemType = zone_c->Type(); picker.m_PickedItemType = zone_c->Type();
itemsList.PushItem(picker); itemsList->PushItem( picker );
} }
} }
} }
if ( itemsList.GetCount() )
SaveCopyInUndoList( itemsList, UR_DELETED );
DrawPanel->Refresh( TRUE );
Compile_Ratsnest( DC, TRUE );
} }
/****************************************************/ /**************************************************************************/
void WinEDA_PcbFrame::Block_Rotate( wxDC* DC ) static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/****************************************************/ /**************************************************************************/
/** /* Retrace le contour du block de repositionnement des structures a dplacer
* Function Block_Rotate
* Rotate 90 deg the selected block
* The rotation centre is the centre of the block
*/ */
{ {
MODULE* module; int Color;
EDA_BaseStruct* PtStruct; BASE_SCREEN* screen = panel->GetScreen();
int masque_layer;
wxPoint oldpos;
wxPoint centre; /* rotation centre for the rotation transform */
if( !InstallBlockCmdFrame( this, _( "Rotate Block" ) ) )
return;
oldpos = GetScreen()->m_Curseur;
GetScreen()->m_BlockLocate.Normalize();
centre = GetScreen()->m_BlockLocate.Centre(); // This is the rotation centre
GetScreen()->SetModify(); Color = YELLOW;
/* Rotation des modules */ /* Effacement ancien cadre */
if( Block_Include_Modules ) if( erase )
{ {
bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
int Angle_Rot_Module = 900; if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
module = m_Pcb->m_Modules;
for( ; module != NULL; module = module->Next() )
{ {
if( ! module->HitTest( GetScreen()->m_BlockLocate ) ) screen->m_BlockLocate.Draw( panel,
continue; DC,
m_Pcb->m_Status_Pcb = 0; screen->m_BlockLocate.m_MoveVector,
module->m_Flags = 0; g_XorMode,
/* Move the footprint before rotate it */ Color );
RotatePoint( &module->m_Pos, centre, 900 );
GetScreen()->m_Curseur = module->m_Pos;
Place_Module( module, NULL );
/* Rotate the footprint */
Rotate_Module( DC, module, Angle_Rot_Module, TRUE );
} }
/* regeneration des valeurs originelles */
GetScreen()->m_Curseur = oldpos;
g_Show_Ratsnest = Show_Ratsnest_tmp;
} }
/* Move and rotate the track segments */ if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP )
if( Block_Include_Tracks )
{
TRACK* track;
track = m_Pcb->m_Track;
while( track )
{ {
if( track->HitTest( GetScreen()->m_BlockLocate ) ) screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x -
{ /* la piste est ici bonne a etre deplacee */ screen->m_BlockLocate.GetRight();
m_Pcb->m_Status_Pcb = 0; screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y -
RotatePoint( &track->m_Start, centre, 900 ); screen->m_BlockLocate.GetBottom();
RotatePoint( &track->m_End, centre, 900 );
}
track = track->Next();
}
} }
/* Move and rotate the zone fill segments, and outlines */ screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
if( Block_Include_Zones ) if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{
TRACK* track;
Affiche_Message( _( "Zone rotation" ) );
track = (TRACK*) m_Pcb->m_Zone;
while( track )
{
if( track->HitTest( GetScreen()->m_BlockLocate ) )
{
RotatePoint( &track->m_Start, centre, 900 );
RotatePoint( &track->m_End, centre, 900 );
}
track = track->Next();
}
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
m_Pcb->GetArea(ii)->Rotate(centre, 900); screen->m_BlockLocate.Draw( panel,
} DC,
} screen->m_BlockLocate.m_MoveVector,
g_XorMode,
Color );
} }
}
masque_layer = EDGE_LAYER;
if( Block_Include_Draw_Items )
masque_layer = ALL_LAYERS;
if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER;
/* Move and rotate the graphic items */ /************************************************/
PtStruct = m_Pcb->m_Drawings; void WinEDA_PcbFrame::Block_Delete()
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) /************************************************/
/*
* routine d'effacement du block deja selectionne
*/
{
if( !InstallBlockCmdFrame( this, _( "Delete Block" ) ) )
return;
Block_SelectItems();
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
return;
GetScreen()->SetModify();
SetCurItem( NULL );
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
itemsList->m_Status = UR_DELETED;
/* unlink items and clear flags */
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{ {
switch( PtStruct->Type() ) BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
itemsList->SetPickedItemStatus( UR_DELETED, ii );
switch( item->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_MODULE:
#undef STRUCT {
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) MODULE* module = (MODULE*) item;
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) module->m_Flags = 0;
break; module->UnLink();
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) m_Pcb->m_Status_Pcb = 0;
break; }
RotatePoint( &STRUCT->m_Start, centre, 900 );
RotatePoint( &STRUCT->m_End, centre, 900 );
break;
case TYPE_TEXTE:
#undef STRUCT
#define STRUCT ( (TEXTE_PCB*) PtStruct )
if( !Block_Include_PcbTextes )
break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
RotatePoint( &STRUCT->m_Pos, centre, 900 );
STRUCT->m_Orient += 900;
if( STRUCT->m_Orient >= 3600 )
STRUCT->m_Orient -= 3600;
break; break;
case TYPE_MIRE: case TYPE_ZONE_CONTAINER: // a zone area
#undef STRUCT m_Pcb->Remove( item );
#define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre modifie */
RotatePoint( &STRUCT->m_Pos, centre, 900 );
break; break;
case TYPE_COTATION: case TYPE_DRAWSEGMENT: // a segment not on copper layers
#undef STRUCT case TYPE_TEXTE: // a text on a layer
#define STRUCT ( (COTATION*) PtStruct ) case TYPE_TRACK: // a track segment (segment on a copper layer)
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) case TYPE_VIA: // a via (like atrack segment on a copper layer)
break; case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) case TYPE_MARKER_PCB: // a marker used to show something
break; case TYPE_COTATION: // a dimension (graphic item)
STRUCT->Rotate(centre, 900); case TYPE_MIRE: // a target (graphic item)
item->UnLink();
break; break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Delete( ) error: unexpected type" ) );
break; break;
} }
} }
SaveCopyInUndoList( *itemsList, UR_DELETED );
Compile_Ratsnest( NULL, TRUE );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
Compile_Ratsnest( DC, TRUE );
} }
/*****************************************************/ /**
void WinEDA_PcbFrame::Block_Invert( wxDC* DC ) * Function Block_Rotate
/*****************************************************/ * Rotate all items within the selected block.
* The rotation centre is the centre of the block
/* * @param none
* routine d'inversion miroir deg du block deja selectionne
* les elements sont inverse / axe horizontal,
* l'axe d'inversion est la mediane horizontale du block
*/ */
void WinEDA_PcbFrame::Block_Rotate()
{ {
#define INVERT( pos ) (pos) = centerY - ( (pos) - centerY ) wxPoint oldpos;
#define INVERT_ANGLE( phi ) (phi) = -(phi) wxPoint centre; // rotation centre for the rotation transform
MODULE* module; int rotAngle = 900; // rottaion angle in 0.1 deg.
EDA_BaseStruct* PtStruct;
int masque_layer;
wxPoint memo;
int Ny, centerY;/* position de l'axe d'inversion de l'ensemble des elements */
if( !InstallBlockCmdFrame( this, _( "Block mirroring" ) ) ) if( !InstallBlockCmdFrame( this, _( "Rotate Block" ) ) )
return; return;
memo = GetScreen()->m_Curseur; Block_SelectItems();
GetScreen()->m_BlockLocate.Normalize(); if( GetScreen()->m_BlockLocate.GetCount() == 0 )
return;
/* calcul du centre d'inversion */ oldpos = GetScreen()->m_Curseur;
centerY = GetScreen()->m_BlockLocate.Centre().y; centre = GetScreen()->m_BlockLocate.Centre(); // This is the rotation centre
GetScreen()->SetModify(); GetScreen()->SetModify();
/* Inversion des modules */ PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
if( Block_Include_Modules ) itemsList->m_Status = UR_ROTATED;
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{ {
bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
module = m_Pcb->m_Modules; wxASSERT(item);
for( ; module != NULL; module = module->Next() ) itemsList->SetPickedItemStatus( UR_ROTATED, ii );
item->Rotate(centre, rotAngle);
switch( item->Type() )
{ {
if( ! module->HitTest( GetScreen()->m_BlockLocate ) ) case TYPE_MODULE:
continue; ((MODULE*) item)->m_Flags = 0;
/* le module est ici bon a etre efface */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0; break;
/* calcul de la nouvelle position du Module */ /* Move and rotate the track segments */
Ny = module->m_Pos.y; case TYPE_TRACK: // a track segment (segment on a copper layer)
INVERT( Ny ); case TYPE_VIA: // a via (like atrack segment on a copper layer)
GetScreen()->m_Curseur.x = module->m_Pos.x; m_Pcb->m_Status_Pcb = 0;
GetScreen()->m_Curseur.y = Ny; break;
Place_Module( module, NULL );
/* inversion du module */ case TYPE_ZONE: // a segment used to fill a zone area (segment on a copper layer)
m_Pcb->Change_Side_Module( module, DC ); case TYPE_ZONE_CONTAINER:
case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
case TYPE_MIRE:
case TYPE_COTATION:
break;
/* regeneration des valeurs originelles */
GetScreen()->m_Curseur = memo;
}
g_Show_Ratsnest = Show_Ratsnest_tmp; default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Rotate( ) error: unexpected type" ) );
break;
}
} }
/* Deplacement des Segments de piste */ SaveCopyInUndoList( *itemsList, UR_ROTATED, centre );
if( Block_Include_Tracks )
{
TRACK* track;
track = m_Pcb->m_Track; Compile_Ratsnest( NULL, TRUE );
while( track ) DrawPanel->Refresh( TRUE );
{ }
if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */
m_Pcb->m_Status_Pcb = 0;
INVERT( track->m_Start.y );
INVERT( track->m_End.y );
if( track->Type() != TYPE_VIA )
{
track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) );
}
}
track = track->Next();
}
}
/* Deplacement des Segments de Zone */
if( Block_Include_Zones )
{
TRACK* track;
track = (TRACK*) m_Pcb->m_Zone; /**
while( track ) * Function Block_Flip
{ * Flip items within the selected block.
if( track->HitTest( GetScreen()->m_BlockLocate ) ) * The flip centre is the centre of the block
{ /* la piste est ici bonne a etre deplacee */ * @param none
INVERT( track->m_Start.y ); */
INVERT( track->m_End.y ); void WinEDA_PcbFrame::Block_Flip()
track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); {
} #define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
track = track->Next(); wxPoint memo;
} wxPoint center; /* position de l'axe d'inversion de l'ensemble des elements */
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{
m_Pcb->GetArea(ii)->Mirror( wxPoint(0, centerY) );
m_Pcb->GetArea(ii)->SetLayer( ChangeSideNumLayer( m_Pcb->GetArea(ii)->GetLayer() ) );
}
}
}
masque_layer = EDGE_LAYER; Block_SelectItems();
if( Block_Include_Draw_Items ) if( GetScreen()->m_BlockLocate.GetCount() == 0 )
masque_layer = ALL_LAYERS; return;
if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER;
PtStruct = m_Pcb->m_Drawings; GetScreen()->SetModify();
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
switch( PtStruct->Type() ) itemsList->m_Status = UR_FLIPPED;
memo = GetScreen()->m_Curseur;
/* calcul du centre d'inversion */
center = GetScreen()->m_BlockLocate.Centre();
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{ {
case TYPE_DRAWSEGMENT: BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
#undef STRUCT wxASSERT(item);
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) item->Flip(center);
break; switch( item->Type() )
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre selectionne */
if( STRUCT->m_Shape == S_ARC )
{ {
INVERT_ANGLE( STRUCT->m_Angle ); case TYPE_MODULE:
} ((MODULE*) item)->m_Flags = 0;
INVERT( STRUCT->m_Start.y ); m_Pcb->m_Status_Pcb = 0;
INVERT( STRUCT->m_End.y );
STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) );
break; break;
case TYPE_TEXTE: /* Move and rotate the track segments */
#undef STRUCT case TYPE_TRACK: // a track segment (segment on a copper layer)
#define STRUCT ( (TEXTE_PCB*) PtStruct ) case TYPE_VIA: // a via (like atrack segment on a copper layer)
if( !Block_Include_PcbTextes ) m_Pcb->m_Status_Pcb = 0;
break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* le texte est ici bon a etre selectionne*/
INVERT( STRUCT->m_Pos.y );
INVERT_ANGLE( STRUCT->m_Orient );
if( (STRUCT->GetLayer() == COPPER_LAYER_N) || (STRUCT->GetLayer() == CMP_N) )
{
STRUCT->m_Mirror = not STRUCT->m_Mirror; /* inverse miroir */
}
STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) );
break; break;
case TYPE_ZONE: // a segment used to fill a zone area (segment on a copper layer)
case TYPE_ZONE_CONTAINER:
case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
case TYPE_MIRE: case TYPE_MIRE:
#undef STRUCT
#define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre modifie */
INVERT( STRUCT->m_Pos.y );
STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) );
break;
case TYPE_COTATION: case TYPE_COTATION:
#undef STRUCT
#define STRUCT ( (COTATION*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre modifie */
STRUCT->Mirror( wxPoint(0, centerY) );
STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) );
break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Flip( ) error: unexpected type" ) );
break; break;
} }
} }
SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
Compile_Ratsnest( NULL, TRUE );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
Compile_Ratsnest( DC, TRUE );
} }
/************************************************/ /**
void WinEDA_PcbFrame::Block_Move( wxDC* DC ) * Function Block_Move
/************************************************/ * moves all tracks and segments within the selected block.
* New location is determined by the current offset from the selected block's original location.
/* * @param none
* Function to move items withing the selected block
*/ */
void WinEDA_PcbFrame::Block_Move()
{ {
int masque_layer;
wxPoint oldpos;
wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
oldpos = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = NULL;
if( !InstallBlockCmdFrame( this, _( "Move Block" ) ) ) if( !InstallBlockCmdFrame( this, _( "Move Block" ) ) )
return; return;
GetScreen()->m_Curseur = oldpos; Block_SelectItems();
DrawPanel->MouseToCursorSchema(); if( GetScreen()->m_BlockLocate.GetCount() == 0 )
GetScreen()->SetModify(); return;
GetScreen()->m_BlockLocate.Normalize();
/* Deplacement des modules */
if( Block_Include_Modules )
{
bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false;
oldpos = GetScreen()->m_Curseur;
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) GetScreen()->SetModify();
{
if( ! module->HitTest( GetScreen()->m_BlockLocate ) )
continue;
/* le module est ici bon a etre deplace */ wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0;
GetScreen()->m_Curseur = module->m_Pos + MoveVector;
Place_Module( module, NULL );
}
GetScreen()->m_Curseur = oldpos; PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
g_Show_Ratsnest = Show_Ratsnest_tmp; itemsList->m_Status = UR_MOVED;
}
/* Deplacement des Segments de piste */ for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
if( Block_Include_Tracks )
{
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{ {
if( track->HitTest( GetScreen()->m_BlockLocate ) ) BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
{ /* la piste est ici bonne a etre deplacee */ itemsList->SetPickedItemStatus( UR_MOVED, ii );
m_Pcb->m_Status_Pcb = 0; item->Move( MoveVector );
track->m_Start += MoveVector;
track->m_End += MoveVector;
}
}
}
/* Deplacement des Segments de Zone */
if( Block_Include_Zones )
{
for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
{
if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */
track->m_Start += MoveVector;
track->m_End += MoveVector;
}
}
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{
m_Pcb->GetArea(ii)->Move( MoveVector );
}
}
}
masque_layer = EDGE_LAYER;
if( Block_Include_Draw_Items )
masque_layer = ALL_LAYERS;
if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER;
for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() )
{
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_MODULE:
#undef STRUCT m_Pcb->m_Status_Pcb = 0;
#define STRUCT ( (DRAWSEGMENT*) item ) ((MODULE*) item)->m_Flags = 0;
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre efface */
STRUCT->m_Start += MoveVector;
STRUCT->m_End += MoveVector;
break; break;
case TYPE_TEXTE: /* Move track segments */
#undef STRUCT case TYPE_TRACK: // a track segment (segment on a copper layer)
#define STRUCT ( (TEXTE_PCB*) item ) case TYPE_VIA: // a via (like a track segment on a copper layer)
if( !Block_Include_PcbTextes ) m_Pcb->m_Status_Pcb = 0;
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* le texte est ici bon a etre deplace */
/* Redessin du Texte */
STRUCT->m_Pos += MoveVector;
break; break;
case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
case TYPE_ZONE_CONTAINER:
case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
case TYPE_MIRE: case TYPE_MIRE:
#undef STRUCT
#define STRUCT ( (MIREPCB*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre efface */
STRUCT->m_Pos += MoveVector;
break;
case TYPE_COTATION: case TYPE_COTATION:
#undef STRUCT
#define STRUCT ( (COTATION*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre efface */
( (COTATION*) item )->Move( wxPoint(MoveVector) );
break; break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Move( ) error: unexpected type" ) );
break; break;
} }
} }
SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
Compile_Ratsnest( NULL, TRUE );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
Compile_Ratsnest( DC, TRUE );
} }
/**************************************************/ /**
void WinEDA_PcbFrame::Block_Duplicate( wxDC* DC ) * Function Block_Duplicate
/**************************************************/ * Duplicate all items within the selected block.
* New location is determined by the current offset from the selected block's original location.
/* * @param none
* routine de duplication des elements du block deja selectionne
*/ */
void WinEDA_PcbFrame::Block_Duplicate()
{ {
int masque_layer;
wxPoint oldpos;
wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector; wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
oldpos = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = NULL;
if( !InstallBlockCmdFrame( this, _( "Copy Block" ) ) ) if( !InstallBlockCmdFrame( this, _( "Copy Block" ) ) )
return; return;
GetScreen()->m_Curseur = oldpos; Block_SelectItems();
DrawPanel->MouseToCursorSchema(); if( GetScreen()->m_BlockLocate.GetCount() == 0 )
return;
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize();
/* Module copy */ PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
if( Block_Include_Modules )
{ PICKED_ITEMS_LIST newList;
bool Show_Ratsnest_tmp = g_Show_Ratsnest; newList.m_Status = UR_NEW;
g_Show_Ratsnest = false;
oldpos = GetScreen()->m_Curseur; ITEM_PICKER picker(NULL, UR_NEW);
BOARD_ITEM * newitem;
for( MODULE* module= m_Pcb->m_Modules; module; module = module->Next() ) for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
newitem = NULL;
switch( item->Type() )
{
case TYPE_MODULE:
{ {
MODULE* module = (MODULE*) item;
MODULE* new_module; MODULE* new_module;
if( ! module->HitTest( GetScreen()->m_BlockLocate ) )
continue;
/* le module est ici bon a etre deplace */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0; module->m_Flags = 0;
new_module = new MODULE( m_Pcb ); newitem = new_module = new MODULE( m_Pcb );
new_module->Copy( module ); new_module->Copy( module );
new_module->m_TimeStamp = GetTimeStamp(); new_module->m_TimeStamp = GetTimeStamp();
m_Pcb->m_Modules.PushFront( new_module ); m_Pcb->m_Modules.PushFront( new_module );
GetScreen()->m_Curseur = module->m_Pos + MoveVector;
Place_Module( new_module, NULL );
}
GetScreen()->m_Curseur = oldpos;
g_Show_Ratsnest = Show_Ratsnest_tmp;
} }
break;
/* Deplacement des Segments de piste */ case TYPE_TRACK:
if( Block_Include_Tracks ) case TYPE_VIA:
{
TRACK* track, * next_track, * new_track;
track = m_Pcb->m_Track;
while( track )
{
next_track = track->Next();
if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ {
/* la piste est ici bonne a etre deplacee */ TRACK* track = (TRACK*) item;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
TRACK* new_track = track->Copy();
new_track = track->Copy(); newitem = new_track;
m_Pcb->m_Track.PushFront( new_track ); m_Pcb->m_Track.PushFront( new_track );
new_track->m_Start += MoveVector;
new_track->m_End += MoveVector;
}
track = next_track;
}
} }
break;
/* Duplicate Zones */ case TYPE_ZONE: // a segment used to fill a zome area (segment on a copper layer)
if( Block_Include_Zones )
{
for( SEGZONE* segzone = m_Pcb->m_Zone; segzone; segzone = segzone->Next() )
{
if( segzone->HitTest( GetScreen()->m_BlockLocate ) )
{ {
SEGZONE* new_segzone = (SEGZONE*) segzone->Copy(); SEGZONE* track = (SEGZONE*) item;
SEGZONE* new_track = (SEGZONE*) track->Copy();
m_Pcb->m_Zone.PushFront( new_segzone ); newitem = new_track;
m_Pcb->m_Track.PushFront( new_track );
new_segzone->m_Start += MoveVector;
new_segzone->m_End += MoveVector;
}
} }
break;
unsigned imax = m_Pcb->GetAreaCount(); case TYPE_ZONE_CONTAINER:
for ( unsigned ii = 0; ii < imax; ii++ )
{
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
ZONE_CONTAINER * new_zone = new ZONE_CONTAINER(m_Pcb); ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*) item->GetParent() );
new_zone->Copy( m_Pcb->GetArea(ii) ); new_zone->Copy( (ZONE_CONTAINER*) item );
new_zone->m_TimeStamp = GetTimeStamp(); new_zone->m_TimeStamp = GetTimeStamp();
new_zone->Move( MoveVector ); newitem = new_zone;
m_Pcb->Add(new_zone); m_Pcb->Add( new_zone );
} }
} break;
}
masque_layer = EDGE_LAYER;
if( Block_Include_Draw_Items )
masque_layer = ALL_LAYERS;
if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER;
for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
{ {
#undef STRUCT
#define STRUCT ( (DRAWSEGMENT*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre copie */
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb ); DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb );
new_drawsegment->Copy( STRUCT ); new_drawsegment->Copy( (DRAWSEGMENT*) item );
m_Pcb->Add( new_drawsegment ); m_Pcb->Add( new_drawsegment );
newitem = new_drawsegment;
new_drawsegment->m_Start += MoveVector;
new_drawsegment->m_End += MoveVector;
} }
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
{ {
#undef STRUCT
#define STRUCT ( (TEXTE_PCB*) item )
if( !Block_Include_PcbTextes )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* le texte est ici bon a etre deplace */
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb ); TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb );
new_pcbtext->Copy( STRUCT ); new_pcbtext->Copy( (TEXTE_PCB*) item );
m_Pcb->Add( new_pcbtext ); m_Pcb->Add( new_pcbtext );
newitem = new_pcbtext;
/* Redessin du Texte */
new_pcbtext->m_Pos += MoveVector;
} }
break; break;
case TYPE_MIRE: case TYPE_MIRE:
{ {
#undef STRUCT
#define STRUCT ( (MIREPCB*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre efface */
MIREPCB* new_mire = new MIREPCB( m_Pcb ); MIREPCB* new_mire = new MIREPCB( m_Pcb );
new_mire->Copy( STRUCT ); new_mire->Copy( (MIREPCB*) item );
m_Pcb->Add( new_mire ); m_Pcb->Add( new_mire );
newitem = new_mire;
new_mire->m_Pos += MoveVector;
} }
break; break;
case TYPE_COTATION: case TYPE_COTATION:
{ {
#undef STRUCT
#define STRUCT ( (COTATION*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break;
/* l'element est ici bon a etre copie */
COTATION* new_cotation = new COTATION( m_Pcb ); COTATION* new_cotation = new COTATION( m_Pcb );
new_cotation->Copy( STRUCT ); new_cotation->Copy( (COTATION*) item );
m_Pcb->Add( new_cotation ); m_Pcb->Add( new_cotation );
newitem = new_cotation;
new_cotation->Move( MoveVector );
} }
break; break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Duplicate( ) error: unexpected type" ) );
break; break;
} }
if ( newitem )
{
newitem->Move( MoveVector );
picker.m_PickedItem = newitem;
picker.m_PickedItemType = newitem->Type();
newList.PushItem(picker);
}
} }
DrawPanel->Refresh( TRUE ); if( newList.GetCount() )
Compile_Ratsnest( DC, TRUE ); SaveCopyInUndoList( newList, UR_NEW );
Compile_Ratsnest( NULL, TRUE );
DrawPanel->Refresh( TRUE );
} }
...@@ -70,37 +70,39 @@ ...@@ -70,37 +70,39 @@
* @param aBoard = board to test * @param aBoard = board to test
* @param aItem = item to find * @param aItem = item to find
*/ */
static bool TestForExistingItem( BOARD * aPcb, BOARD_ITEM * aItem ) static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
{ {
BOARD_ITEM *item; BOARD_ITEM* item;
// search in tracks: // search in tracks:
for( item = aPcb->m_Track; item != NULL; item = item->Next() ) for( item = aPcb->m_Track; item != NULL; item = item->Next() )
if (item == aItem ) if( item == aItem )
return true; return true;
// search in modules: // search in modules:
for( item = aPcb->m_Modules; item != NULL; item = item->Next() ) for( item = aPcb->m_Modules; item != NULL; item = item->Next() )
if (item == aItem ) if( item == aItem )
return true; return true;
// Search in drawings // Search in drawings
for( item = aPcb->m_Drawings; item != NULL; item = item->Next() ) for( item = aPcb->m_Drawings; item != NULL; item = item->Next() )
if (item == aItem ) if( item == aItem )
return true; return true;
// Search in zones outlines // Search in zones outlines
for ( int ii = 0; ii < aPcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
if( aPcb->GetArea(ii) == aItem ) if( aPcb->GetArea( ii ) == aItem )
return true; return true;
// search in zones segm: // search in zones segm:
for( item = aPcb->m_Zone; item != NULL; item = item->Next() ) for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
if (item == aItem ) if( item == aItem )
return true; return true;
return false; return false;
} }
/**************************************************************/ /**************************************************************/
void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
/***************************************************************/ /***************************************************************/
...@@ -133,8 +135,6 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem ) ...@@ -133,8 +135,6 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem )
* The new object is not put in list (not linked) * The new object is not put in list (not linked)
*/ */
{ {
BOARD_ITEM* newItem = NULL;
if( aItem == NULL ) if( aItem == NULL )
{ {
wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) ); wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) );
...@@ -143,17 +143,82 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem ) ...@@ -143,17 +143,82 @@ BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem )
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case TYPE_MODULE:
{
MODULE* new_module;
new_module = new MODULE( (BOARD*)aItem->GetParent() );
new_module->Copy( (MODULE*) aItem );
return new_module;
}
case TYPE_TRACK:
{
TRACK* new_track = ( (TRACK*) aItem )->Copy();
return new_track;
}
case TYPE_VIA:
{
SEGVIA* new_via = (SEGVIA*)( (SEGVIA*) aItem )->Copy();
return new_via;
}
case TYPE_ZONE:
{
SEGZONE* new_segzone = (SEGZONE*)( (SEGZONE*) aItem )->Copy();
return new_segzone;
}
case TYPE_ZONE_CONTAINER:
{
ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*)aItem->GetParent() );
new_zone->Copy( (ZONE_CONTAINER*)aItem );
return new_zone;
}
case TYPE_DRAWSEGMENT:
{
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( aItem->GetParent() );
new_drawsegment->Copy( (DRAWSEGMENT*)aItem );
return new_drawsegment;
}
break;
case TYPE_TEXTE:
{
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( aItem->GetParent() );
new_pcbtext->Copy( (TEXTE_PCB*)aItem );
return new_pcbtext;
}
break;
case TYPE_MIRE:
{
MIREPCB* new_mire = new MIREPCB( aItem->GetParent() );
new_mire->Copy( (MIREPCB*)aItem );
return new_mire;
}
break;
case TYPE_COTATION:
{
COTATION* new_cotation = new COTATION( aItem->GetParent() );
new_cotation->Copy( (COTATION*) aItem );
return new_cotation;
}
break;
default: default:
{ {
wxString msg; wxString msg;
msg << wxT( "DuplicateStruct error: unexpected StructType " ) << msg << wxT( "DuplicateStruct error: unexpected StructType " ) <<
aItem->Type() << wxT( " " ) << aItem->GetClass(); aItem->Type() << wxT( " " ) << aItem->GetClass();
// wxMessageBox( msg ); wxMessageBox( msg );
} }
break; break;
} }
return newItem; return NULL;
} }
...@@ -170,17 +235,14 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, ...@@ -170,17 +235,14 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
* UR_CHANGED * UR_CHANGED
* UR_NEW * UR_NEW
* UR_DELETED * UR_DELETED
* UR_MOVED
* UR_FLIPPED
* UR_ROTATED
* *
* If it is a delete command, items are put on list with the .Flags member set to UR_DELETED. * If it is a delete command, items are put on list with the .Flags member set to UR_DELETED.
* When it will be really deleted, the EEDrawList and the subhierarchy will be deleted. * When it will be really deleted, the EEDrawList and the subhierarchy will be deleted.
* If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted. * If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted.
* *
* Note:
* Edit wires and busses is a bit complex.
* because when a new wire is added, modifications in wire list
* (wire concatenation) there are modified items, deleted items and new items
* so flag_type_command is UR_WIRE_IMAGE: the struct ItemToCopy is a list of wires
* saved in Undo List (for Undo or Redo commands, saved wires will be exchanged with current wire list
*/ */
{ {
BOARD_ITEM* CopyOfItem; BOARD_ITEM* CopyOfItem;
...@@ -194,7 +256,7 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, ...@@ -194,7 +256,7 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
switch( aCommandType ) switch( aCommandType )
{ {
case UR_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( aItemToCopy ); CopyOfItem = NULL;//DuplicateStruct( aItemToCopy );
itemWrapper.m_PickedItem = CopyOfItem; itemWrapper.m_PickedItem = CopyOfItem;
itemWrapper.m_Link = aItemToCopy; itemWrapper.m_Link = aItemToCopy;
if( CopyOfItem ) if( CopyOfItem )
...@@ -202,7 +264,9 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, ...@@ -202,7 +264,9 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
break; break;
case UR_NEW: case UR_NEW:
case UR_WIRE_IMAGE: case UR_MOVED:
case UR_FLIPPED:
case UR_ROTATED:
case UR_DELETED: case UR_DELETED:
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
...@@ -246,34 +310,31 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -246,34 +310,31 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
BOARD_ITEM* ItemToCopy = (BOARD_ITEM*) aItemsList.GetPickedItem( ii ); BOARD_ITEM* item = (BOARD_ITEM*) aItemsList.GetPickedItem( ii );
UndoRedoOpType command = aItemsList.GetPickedItemStatus( ii ); UndoRedoOpType command = aItemsList.GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED ) if( command == UR_UNSPECIFIED )
{ {
command = aTypeCommand; command = aTypeCommand;
} }
wxASSERT( ItemToCopy ); wxASSERT( item );
itemWrapper.m_PickedItem = ItemToCopy; itemWrapper.m_PickedItem = item;
itemWrapper.m_PickedItemType = ItemToCopy->Type(); itemWrapper.m_PickedItemType = item->Type();
itemWrapper.m_UndoRedoStatus = command; itemWrapper.m_UndoRedoStatus = command;
switch( command ) switch( command )
{ {
case UR_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( ItemToCopy ); CopyOfItem = DuplicateStruct( item );
itemWrapper.m_PickedItem = CopyOfItem; itemWrapper.m_PickedItem = CopyOfItem;
itemWrapper.m_Link = ItemToCopy; itemWrapper.m_Link = item;
if( CopyOfItem ) if( CopyOfItem )
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
case UR_MOVED: case UR_MOVED:
case UR_MIRRORED_Y: case UR_ROTATED:
case UR_FLIPPED:
case UR_NEW: case UR_NEW:
commandToUndo->PushItem( itemWrapper );
break;
case UR_DELETED: case UR_DELETED:
ItemToCopy->m_Flags = UR_DELETED;
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
...@@ -300,27 +361,24 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -300,27 +361,24 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
} }
/***************************************************************************/ /** Function PutDataInPreviousState()
void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) * Used in undo or redo command.
/***************************************************************************/
/* Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorised by List * Put data pointed by List in the previous state, i.e. the state memorised by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
*/ */
void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
{ {
BOARD_ITEM* item; BOARD_ITEM* item;
bool as_moved = false;
bool not_found = false; bool not_found = false;
for( unsigned ii = 0; ii < aList->GetCount(); ii++ ) for( unsigned ii = 0; ii < aList->GetCount(); ii++ )
{ {
ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii ); item = (BOARD_ITEM*) aList->GetPickedItem(ii);
item = (BOARD_ITEM*) itemWrapper.m_PickedItem;
wxASSERT( item ); wxASSERT( item );
BOARD_ITEM* image = (BOARD_ITEM*) itemWrapper.m_Link; if( aList->GetPickedItemStatus(ii) != UR_DELETED )
if( itemWrapper.m_UndoRedoStatus != UR_DELETED )
{ {
if( ! TestForExistingItem( GetBoard(), item ) ) if( !TestForExistingItem( GetBoard(), item ) )
{ {
// Remove this non existant item // Remove this non existant item
aList->RemovePickedItem( ii ); aList->RemovePickedItem( ii );
...@@ -330,10 +388,13 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -330,10 +388,13 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
continue; continue;
} }
} }
switch( itemWrapper.m_UndoRedoStatus ) switch( aList->GetPickedItemStatus(ii) )
{ {
case UR_CHANGED: /* Exchange old and new data for each item */ case UR_CHANGED: /* Exchange old and new data for each item */
{
BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink(ii);
SwapData( item, image ); SwapData( item, image );
}
break; break;
case UR_NEW: /* new items are deleted */ case UR_NEW: /* new items are deleted */
...@@ -349,14 +410,15 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -349,14 +410,15 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
break; break;
case UR_MOVED: case UR_MOVED:
item->Move( aRedoCommand ? aList->m_TransformPoint : - aList->m_TransformPoint );
// item->Move( - aList->m_TransformPoint );
as_moved = true;
break; break;
case UR_MIRRORED_Y: case UR_ROTATED:
item->Rotate( aList->m_TransformPoint, aRedoCommand ? 900 : -900 );
break;
// item->Mirror_Y( aList->m_TransformPoint.x ); case UR_FLIPPED:
item->Flip( aList->m_TransformPoint );
break; break;
default: default:
...@@ -364,7 +426,7 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -364,7 +426,7 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
wxString msg; wxString msg;
msg.Printf( wxT( msg.Printf( wxT(
"PutDataInPreviousState() error (unknown code %X)" ), "PutDataInPreviousState() error (unknown code %X)" ),
itemWrapper.m_UndoRedoStatus ); aList->GetPickedItemStatus(ii) );
wxMessageBox( msg ); wxMessageBox( msg );
} }
break; break;
...@@ -372,11 +434,7 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -372,11 +434,7 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
} }
if( not_found ) if( not_found )
wxMessageBox(wxT("Incomplete undo/redo command: item not found" ) ); wxMessageBox( wxT( "Incomplete undo/redo command: item not found" ) );
// Undo for move transform needs to change the general move vector:
if( as_moved )
aList->m_TransformPoint = -aList->m_TransformPoint;
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
} }
...@@ -385,12 +443,11 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -385,12 +443,11 @@ void WinEDA_PcbFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
/**********************************************************/ /**********************************************************/
void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event ) void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event )
/**********************************************************/ /**********************************************************/
/** Function GetBoardFromUndoList
/** Function GetSchematicFromUndoList
* Undo the last edition: * Undo the last edition:
* - Save the current schematic in Redo list * - Save the current board in Redo list
* - Get an old version of the schematic * - Get an old version of the board from Undo list
* @return false if nothing done, else true * @return none
*/ */
{ {
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
...@@ -400,7 +457,7 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -400,7 +457,7 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event )
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
/* Undo the command */ /* Undo the command */
PutDataInPreviousState( List ); PutDataInPreviousState( List, false );
GetScreen()->SetModify(); GetScreen()->SetModify();
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -410,15 +467,13 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -410,15 +467,13 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event )
} }
/**********************************************************/ /** Function GetBoardFromRedoList
void WinEDA_PcbFrame::GetBoardFromRedoList( wxCommandEvent& event ) * Redo the last edition:
/**********************************************************/ * - Save the current board in Undo list
* - Get an old version of the board from Redo list
/* Redo the last edition: * @return none
* - Save the current schematic in undo list
* - Get the old version
* @return false if nothing done, else true
*/ */
void WinEDA_PcbFrame::GetBoardFromRedoList( wxCommandEvent& event )
{ {
if( GetScreen()->GetRedoCommandCount() == 0 ) if( GetScreen()->GetRedoCommandCount() == 0 )
return; return;
...@@ -429,7 +484,7 @@ void WinEDA_PcbFrame::GetBoardFromRedoList( wxCommandEvent& event ) ...@@ -429,7 +484,7 @@ void WinEDA_PcbFrame::GetBoardFromRedoList( wxCommandEvent& event )
GetScreen()->PushCommandToUndoList( List ); GetScreen()->PushCommandToUndoList( List );
/* Redo the command: */ /* Redo the command: */
PutDataInPreviousState( List ); PutDataInPreviousState( List, true );
GetScreen()->SetModify(); GetScreen()->SetModify();
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -460,6 +515,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -460,6 +515,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
unsigned icnt = aList.m_CommandsList.size(); unsigned icnt = aList.m_CommandsList.size();
if( aItemCount > 0 ) if( aItemCount > 0 )
icnt = aItemCount; icnt = aItemCount;
bool displ_error = true;
for( unsigned ii = 0; ii < icnt; ii++ ) for( unsigned ii = 0; ii < icnt; ii++ )
{ {
if( aList.m_CommandsList.size() == 0 ) if( aList.m_CommandsList.size() == 0 )
...@@ -476,7 +532,13 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -476,7 +532,13 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
break; break;
switch( wrapper.m_UndoRedoStatus ) switch( wrapper.m_UndoRedoStatus )
{ {
case UR_UNSPECIFIED:
if( displ_error )
wxMessageBox(wxT("ClearUndoORRedoList() error: unspecified item type"));
displ_error = false;
break;
case UR_MOVED: case UR_MOVED:
case UR_FLIPPED:
case UR_MIRRORED_X: case UR_MIRRORED_X:
case UR_MIRRORED_Y: case UR_MIRRORED_Y:
case UR_ROTATED: case UR_ROTATED:
......
...@@ -203,9 +203,9 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) ...@@ -203,9 +203,9 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
// this one uses a vector // this one uses a vector
case TYPE_MARKER: case TYPE_MARKER_PCB:
aBoardItem->SetParent( this ); aBoardItem->SetParent( this );
m_markers.push_back( (MARKER*) aBoardItem ); m_markers.push_back( (MARKER_PCB*) aBoardItem );
break; break;
// this one uses a vector // this one uses a vector
...@@ -267,12 +267,12 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) ...@@ -267,12 +267,12 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
case TYPE_MARKER: case TYPE_MARKER_PCB:
// find the item in the vector, then remove it // find the item in the vector, then remove it
for( unsigned i = 0; i<m_markers.size(); ++i ) for( unsigned i = 0; i<m_markers.size(); ++i )
{ {
if( m_markers[i] == (MARKER*) aBoardItem ) if( m_markers[i] == (MARKER_PCB*) aBoardItem )
{ {
m_markers.erase( m_markers.begin() + i ); m_markers.erase( m_markers.begin() + i );
break; break;
...@@ -326,7 +326,7 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) ...@@ -326,7 +326,7 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
void BOARD::DeleteMARKERs() void BOARD::DeleteMARKERs()
{ {
// the vector does not know how to delete the MARKER, it holds pointers // the vector does not know how to delete the MARKER_PCB, it holds pointers
for( unsigned i = 0; i<m_markers.size(); ++i ) for( unsigned i = 0; i<m_markers.size(); ++i )
delete m_markers[i]; delete m_markers[i];
...@@ -691,9 +691,9 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -691,9 +691,9 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
break; break;
#endif #endif
case TYPE_MARKER: case TYPE_MARKER_PCB:
// MARKERS are in the m_markers std::vector // MARKER_PCBS are in the m_markers std::vector
for( unsigned i = 0; i<m_markers.size(); ++i ) for( unsigned i = 0; i<m_markers.size(); ++i )
{ {
result = m_markers[i]->Visit( inspector, testData, p ); result = m_markers[i]->Visit( inspector, testData, p );
...@@ -722,9 +722,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ...@@ -722,9 +722,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
++p; ++p;
break; break;
case TYPE_ZONE_UNUSED: // Unused type
break;
default: // catch EOT or ANY OTHER type here and return. default: // catch EOT or ANY OTHER type here and return.
done = true; done = true;
break; break;
...@@ -975,7 +972,7 @@ bool BOARD::Save( FILE* aFile ) const ...@@ -975,7 +972,7 @@ bool BOARD::Save( FILE* aFile ) const
} }
} }
// do not save MARKERs, they can be regenerated easily // do not save MARKER_PCBs, they can be regenerated easily
// save the tracks & vias // save the tracks & vias
fprintf( aFile, "$TRACK\n" ); fprintf( aFile, "$TRACK\n" );
......
...@@ -70,8 +70,8 @@ class BOARD : public BOARD_ITEM ...@@ -70,8 +70,8 @@ class BOARD : public BOARD_ITEM
friend class WinEDA_PcbFrame; friend class WinEDA_PcbFrame;
private: private:
typedef std::vector<MARKER*> MARKERS; // @todo: switch to boost:ptr_vector, and change ~BOARD() typedef std::vector<MARKER_PCB*> MARKERS; // @todo: switch to boost:ptr_vector, and change ~BOARD()
MARKERS m_markers; ///< MARKERs for clearance problems, owned by pointer MARKERS m_markers; ///< MARKER_PCBs for clearance problems, owned by pointer
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD() typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD()
ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer
...@@ -162,10 +162,10 @@ public: ...@@ -162,10 +162,10 @@ public:
/** /**
* Function GetMARKER * Function GetMARKER
* returns the MARKER at a given index. * returns the MARKER at a given index.
* @param index The array type index into a collection of MARKERS. * @param index The array type index into a collection of MARKER_PCBS.
* @return MARKER* - a pointer to the MARKER or NULL if index out of range. * @return MARKER_PCB* - a pointer to the MARKER_PCB or NULL if index out of range.
*/ */
MARKER* GetMARKER( int index ) const MARKER_PCB* GetMARKER( int index ) const
{ {
if( (unsigned) index < m_markers.size() ) if( (unsigned) index < m_markers.size() )
return m_markers[index]; return m_markers[index];
...@@ -175,7 +175,7 @@ public: ...@@ -175,7 +175,7 @@ public:
/** /**
* Function GetMARKERCount * Function GetMARKERCount
* @return int - The number of MARKERS. * @return int - The number of MARKER_PCBS.
*/ */
int GetMARKERCount() const int GetMARKERCount() const
{ {
......
...@@ -212,9 +212,9 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const ...@@ -212,9 +212,9 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
} }
break; break;
case TYPE_MARKER: case TYPE_MARKER_PCB:
text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->GetPos().x text << _( "Marker" ) << wxT( " @(" ) << ((MARKER_PCB*)item)->GetPos().x
<< wxT(",") << ((MARKER*)item)->GetPos().y << wxT(")"); << wxT(",") << ((MARKER_PCB*)item)->GetPos().y << wxT(")");
break; break;
case TYPE_COTATION: case TYPE_COTATION:
...@@ -228,10 +228,6 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const ...@@ -228,10 +228,6 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
; ;
break; break;
case TYPE_ZONE_UNUSED:
text << wxT( "Unused" );
break;
default: default:
text << item->GetClass() << wxT( " Unexpected item type: BUG!!" ); text << item->GetClass() << wxT( " Unexpected item type: BUG!!" );
break; break;
...@@ -291,7 +287,7 @@ const char** BOARD_ITEM::MenuIcon() const ...@@ -291,7 +287,7 @@ const char** BOARD_ITEM::MenuIcon() const
xpm = pad_sketch_xpm; xpm = pad_sketch_xpm;
break; break;
case TYPE_MARKER: case TYPE_MARKER_PCB:
xpm = pad_xpm; // @todo: create and use marker xpm xpm = pad_xpm; // @todo: create and use marker xpm
break; break;
...@@ -303,10 +299,6 @@ const char** BOARD_ITEM::MenuIcon() const ...@@ -303,10 +299,6 @@ const char** BOARD_ITEM::MenuIcon() const
xpm = add_mires_xpm; xpm = add_mires_xpm;
break; break;
case TYPE_ZONE_UNUSED:
xpm = 0; // unused
break;
default: default:
xpm = 0; xpm = 0;
break; break;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "wxstruct.h" #include "wxstruct.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "protos.h"
COTATION::COTATION( BOARD_ITEM* aParent ) : COTATION::COTATION( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, TYPE_COTATION ) BOARD_ITEM( aParent, TYPE_COTATION )
...@@ -235,36 +235,46 @@ void COTATION::Rotate(const wxPoint& centre, int angle) ...@@ -235,36 +235,46 @@ void COTATION::Rotate(const wxPoint& centre, int angle)
/******************************************************/ /******************************************************/
/** /**
* Function Rotate * Function Rotate
* @param offset : Rotation point * @param centre : Rotation point
* @param angle : Rotation angle in 0.1 degrees * @param angle : Rotation angle in 0.1 degrees
*/ */
{ {
RotatePoint( &m_Pos, centre, 900 ); RotatePoint( &m_Pos, centre, angle );
RotatePoint( &m_Text->m_Pos, centre, 900 ); RotatePoint( &m_Text->m_Pos, centre, angle );
m_Text->m_Orient += 900; m_Text->m_Orient += angle;
if( m_Text->m_Orient >= 3600 ) if( m_Text->m_Orient >= 3600 )
m_Text->m_Orient -= 3600; m_Text->m_Orient -= 3600;
if( (m_Text->m_Orient > 900) if( (m_Text->m_Orient > 900)
&& (m_Text->m_Orient <2700) ) && (m_Text->m_Orient <2700) )
m_Text->m_Orient -= 1800; m_Text->m_Orient -= 1800;
RotatePoint( &Barre_ox, &Barre_oy, centre.x, centre.y, 900 ); RotatePoint( &Barre_ox, &Barre_oy, centre.x, centre.y, angle );
RotatePoint( &Barre_fx, &Barre_fy, centre.x, centre.y, 900 ); RotatePoint( &Barre_fx, &Barre_fy, centre.x, centre.y, angle );
RotatePoint( &TraitG_ox, &TraitG_oy, centre.x, centre.y, 900 ); RotatePoint( &TraitG_ox, &TraitG_oy, centre.x, centre.y, angle );
RotatePoint( &TraitG_fx, &TraitG_fy, centre.x, centre.y, 900 ); RotatePoint( &TraitG_fx, &TraitG_fy, centre.x, centre.y, angle );
RotatePoint( &TraitD_ox, &TraitD_oy, centre.x, centre.y, 900 ); RotatePoint( &TraitD_ox, &TraitD_oy, centre.x, centre.y, angle );
RotatePoint( &TraitD_fx, &TraitD_fy, centre.x, centre.y, 900 ); RotatePoint( &TraitD_fx, &TraitD_fy, centre.x, centre.y, angle );
RotatePoint( &FlecheG1_ox, &FlecheG1_oy, centre.x, centre.y, 900 ); RotatePoint( &FlecheG1_ox, &FlecheG1_oy, centre.x, centre.y, angle );
RotatePoint( &FlecheG1_fx, &FlecheG1_fy, centre.x, centre.y, 900 ); RotatePoint( &FlecheG1_fx, &FlecheG1_fy, centre.x, centre.y, angle );
RotatePoint( &FlecheG2_ox, &FlecheG2_oy, centre.x, centre.y, 900 ); RotatePoint( &FlecheG2_ox, &FlecheG2_oy, centre.x, centre.y, angle );
RotatePoint( &FlecheG2_fx, &FlecheG2_fy, centre.x, centre.y, 900 ); RotatePoint( &FlecheG2_fx, &FlecheG2_fy, centre.x, centre.y, angle );
RotatePoint( &FlecheD1_ox, &FlecheD1_oy, centre.x, centre.y, 900 ); RotatePoint( &FlecheD1_ox, &FlecheD1_oy, centre.x, centre.y, angle );
RotatePoint( &FlecheD1_fx, &FlecheD1_fy, centre.x, centre.y, 900 ); RotatePoint( &FlecheD1_fx, &FlecheD1_fy, centre.x, centre.y, angle );
RotatePoint( &FlecheD2_ox, &FlecheD2_oy, centre.x, centre.y, 900 ); RotatePoint( &FlecheD2_ox, &FlecheD2_oy, centre.x, centre.y, angle );
RotatePoint( &FlecheD2_fx, &FlecheD2_fy, centre.x, centre.y, 900 ); RotatePoint( &FlecheD2_fx, &FlecheD2_fy, centre.x, centre.y, angle );
} }
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void COTATION::Flip(const wxPoint& aCentre )
{
Mirror( aCentre );
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
/**********************************************/ /**********************************************/
void COTATION::Mirror(const wxPoint& axis_pos) void COTATION::Mirror(const wxPoint& axis_pos)
......
...@@ -64,10 +64,18 @@ public: ...@@ -64,10 +64,18 @@ public:
/** /**
* Function Rotate * Function Rotate
* @param offset : Rotation point * Rotate this object.
* @param angle : Rotation angle in 0.1 degrees * @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/ */
void Rotate(const wxPoint& centre, int angle); virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/** /**
* Function Mirror * Function Mirror
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "pcbnew.h" #include "pcbnew.h"
#include "trigo.h" #include "trigo.h"
#include "protos.h"
/* DRAWSEGMENT: constructor */ /* DRAWSEGMENT: constructor */
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) : DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) :
...@@ -44,6 +45,34 @@ void DRAWSEGMENT::Copy( DRAWSEGMENT* source ) ...@@ -44,6 +45,34 @@ void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
m_BezierC2 = source->m_BezierC1; m_BezierC2 = source->m_BezierC1;
} }
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void DRAWSEGMENT::Rotate(const wxPoint& aRotCentre, int aAngle)
{
RotatePoint( &m_Start, aRotCentre, aAngle );
RotatePoint( &m_End, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void DRAWSEGMENT::Flip(const wxPoint& aCentre )
{
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
m_End.y = aCentre.y - (m_End.y - aCentre.y);
if( m_Shape == S_ARC )
{
NEGATE( m_Angle );
}
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
bool DRAWSEGMENT::Save( FILE* aFile ) const bool DRAWSEGMENT::Save( FILE* aFile ) const
{ {
......
...@@ -116,6 +116,31 @@ public: ...@@ -116,6 +116,31 @@ public:
return hypot( delta.x, delta.y ); return hypot( delta.x, delta.y );
} }
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Start += aMoveVector;
m_End += aMoveVector;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
......
...@@ -8,18 +8,19 @@ ...@@ -8,18 +8,19 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "trigo.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "class_marker.h" #include "class_marker_pcb.h"
#define SCALING_FACTOR 30 // Adjust the actual size of markers, when using default shape #define SCALING_FACTOR 30 // Adjust the actual size of markers, when using default shape
/*******************/ /*******************/
/* Classe MARKER */ /* Classe MARKER_PCB */
/*******************/ /*******************/
MARKER::MARKER( BOARD_ITEM* aParent ) : MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, TYPE_MARKER ), BOARD_ITEM( aParent, TYPE_MARKER_PCB ),
MARKER_BASE( ) MARKER_BASE( )
{ {
m_Color = WHITE; m_Color = WHITE;
...@@ -27,10 +28,10 @@ MARKER::MARKER( BOARD_ITEM* aParent ) : ...@@ -27,10 +28,10 @@ MARKER::MARKER( BOARD_ITEM* aParent ) :
} }
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos, const wxString& aText, const wxPoint& aPos,
const wxString& bText, const wxPoint& bPos ) : const wxString& bText, const wxPoint& bPos ) :
BOARD_ITEM( NULL, TYPE_MARKER ), // parent set during BOARD::Add() BOARD_ITEM( NULL, TYPE_MARKER_PCB ), // parent set during BOARD::Add()
MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ) MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos )
{ {
...@@ -38,9 +39,9 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -38,9 +39,9 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
m_ScalingFactor = SCALING_FACTOR; m_ScalingFactor = SCALING_FACTOR;
} }
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos ) : const wxString& aText, const wxPoint& aPos ) :
BOARD_ITEM( NULL, TYPE_MARKER ), // parent set during BOARD::Add() BOARD_ITEM( NULL, TYPE_MARKER_PCB ), // parent set during BOARD::Add()
MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos ) MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos )
{ {
m_Color = WHITE; m_Color = WHITE;
...@@ -48,21 +49,13 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -48,21 +49,13 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
} }
/* Effacement memoire de la structure */ /* destructor */
MARKER::~MARKER() MARKER_PCB::~MARKER_PCB()
{ {
} }
/* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement
*/
void MARKER::UnLink()
{
wxFAIL_MSG( wxT("MARKER::UnLink is deprecated") );
}
void MARKER_PCB::DisplayInfo( WinEDA_DrawFrame* frame )
void MARKER::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
int text_pos; int text_pos;
...@@ -91,3 +84,26 @@ void MARKER::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -91,3 +84,26 @@ void MARKER::DisplayInfo( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, text_pos, txtA, txtB, DARKBROWN ); Affiche_1_Parametre( frame, text_pos, txtA, txtB, DARKBROWN );
} }
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void MARKER_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* this function has not reeally sense for a marker.
* It moves just the marker to keep its position on board, when the board is flipped
* @param const wxPoint& aCentre - the rotation point.
*/
void MARKER_PCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
}
...@@ -2,47 +2,69 @@ ...@@ -2,47 +2,69 @@
/* Markers: used to show a drc problem */ /* Markers: used to show a drc problem */
/***************************************/ /***************************************/
#ifndef CLASS_MARKER_H #ifndef CLASS_MARKER_PCB_H
#define CLASS_MARKER_H #define CLASS_MARKER_PCB_H
#include "base_struct.h" #include "base_struct.h"
#include "drc_stuff.h" #include "drc_stuff.h"
class MARKER : public BOARD_ITEM, public MARKER_BASE class MARKER_PCB : public BOARD_ITEM, public MARKER_BASE
{ {
public: public:
MARKER( BOARD_ITEM* aParent ); MARKER_PCB( BOARD_ITEM* aParent );
/** /**
* Constructor * Constructor
* @param aErrorCode The categorizing identifier for an error * @param aErrorCode The categorizing identifier for an error
* @param aMarkerPos The position of the MARKER on the BOARD * @param aMarkerPos The position of the MARKER_PCB on the BOARD
* @param aText Text describing the first of two objects * @param aText Text describing the first of two objects
* @param aPos The position of the first of two objects * @param aPos The position of the first of two objects
* @param bText Text describing the second of the two conflicting objects * @param bText Text describing the second of the two conflicting objects
* @param bPos The position of the second of two objects * @param bPos The position of the second of two objects
*/ */
MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos, const wxString& aText, const wxPoint& aPos,
const wxString& bText, const wxPoint& bPos ); const wxString& bText, const wxPoint& bPos );
/** /**
* Constructor * Constructor
* @param aErrorCode The categorizing identifier for an error * @param aErrorCode The categorizing identifier for an error
* @param aMarkerPos The position of the MARKER on the BOARD * @param aMarkerPos The position of the MARKER_PCB on the BOARD
* @param aText Text describing the object * @param aText Text describing the object
* @param aPos The position of the object * @param aPos The position of the object
*/ */
MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos ); const wxString& aText, const wxPoint& aPos );
~MARKER(); ~MARKER_PCB();
void UnLink(); // Deprecated /**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Pos += aMoveVector;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/** Function Draw /** Function Draw
*/ */
...@@ -53,7 +75,7 @@ public: ...@@ -53,7 +75,7 @@ public:
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this MARKER. * returns the position of this MARKER_PCB.
*/ */
wxPoint& GetPosition() wxPoint& GetPosition()
{ {
...@@ -93,4 +115,4 @@ public: ...@@ -93,4 +115,4 @@ public:
}; };
#endif // CLASS_MARKER_H #endif // CLASS_MARKER_PCB_H
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "trigo.h"
#include "protos.h"
MIREPCB::MIREPCB( BOARD_ITEM* aParent ) : MIREPCB::MIREPCB( BOARD_ITEM* aParent ) :
...@@ -201,3 +203,25 @@ bool MIREPCB::HitTest( EDA_Rect& refArea ) ...@@ -201,3 +203,25 @@ bool MIREPCB::HitTest( EDA_Rect& refArea )
return false; return false;
} }
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void MIREPCB::Rotate(const wxPoint& aRotCentre, int aAngle)
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void MIREPCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
...@@ -28,6 +28,31 @@ public: ...@@ -28,6 +28,31 @@ public:
} }
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Pos += aMoveVector;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
......
...@@ -21,32 +21,6 @@ ...@@ -21,32 +21,6 @@
#include "3d_struct.h" #include "3d_struct.h"
#include "protos.h" #include "protos.h"
/*********************************************************************************/
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode )
/*********************************************************************************/
/* trace de l'ancre (croix verticale)
* (doit etre fait apres les pads,
* car le trace du trou efface tout donc peut etre l'ancre */
{
int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
GRSetDrawMode( DC, draw_mode );
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
{
GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y,
0, g_AnchorColor );
GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size,
m_Pos.x - offset.x, m_Pos.y - offset.y + anchor_size,
0, g_AnchorColor );
}
}
/*************************************************/ /*************************************************/
/* Class MODULE : description d'un composant pcb */ /* Class MODULE : description d'un composant pcb */
...@@ -81,6 +55,32 @@ MODULE::~MODULE() ...@@ -81,6 +55,32 @@ MODULE::~MODULE()
} }
/*********************************************************************************/
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode )
/*********************************************************************************/
/* trace de l'ancre (croix verticale)
* (doit etre fait apres les pads,
* car le trace du trou efface tout donc peut etre l'ancre */
{
int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
GRSetDrawMode( DC, draw_mode );
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
{
GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y,
0, g_AnchorColor );
GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size,
m_Pos.x - offset.x, m_Pos.y - offset.y + anchor_size,
0, g_AnchorColor );
}
}
/*********************************/ /*********************************/
void MODULE::Copy( MODULE* aModule ) void MODULE::Copy( MODULE* aModule )
/*********************************/ /*********************************/
...@@ -131,7 +131,7 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -131,7 +131,7 @@ void MODULE::Copy( MODULE* aModule )
break; break;
default: default:
DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) ); wxMessageBox( wxT( "Internal Err: CopyModule: type indefini" ) );
break; break;
} }
} }
...@@ -594,118 +594,6 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -594,118 +594,6 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
} }
/*************************************************/
void MODULE::SetPosition( const wxPoint& newpos )
/*************************************************/
// replace le module en position newpos
{
int deltaX = newpos.x - m_Pos.x;
int deltaY = newpos.y - m_Pos.y;
/* deplacement de l'ancre */
m_Pos.x += deltaX;
m_Pos.y += deltaY;
/* deplacement de la reference */
m_Reference->m_Pos.x += deltaX;
m_Reference->m_Pos.y += deltaY;
/* deplacement de la Valeur */
m_Value->m_Pos.x += deltaX;
m_Value->m_Pos.y += deltaY;
/* deplacement des pastilles */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->m_Pos.x += deltaX;
pad->m_Pos.y += deltaY;
}
/* deplacement des dessins de l'empreinte : */
EDA_BaseStruct* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
switch( PtStruct->Type() )
{
case TYPE_EDGE_MODULE:
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord();
break;
}
case TYPE_TEXTE_MODULE:
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.x += deltaX;
pt_texte->m_Pos.y += deltaY;
break;
}
default:
DisplayError( NULL, wxT( "Type Draw Indefini" ) ); break;
}
}
Set_Rectangle_Encadrement();
}
/*********************************************/
void MODULE::SetOrientation( int newangle )
/*********************************************/
/* Tourne de newangle (en 0.1 degres) le module
*/
{
int px, py;
newangle -= m_Orient; // = delta de rotation
m_Orient += newangle;
NORMALIZE_ANGLE_POS( m_Orient );
/* deplacement et rotation des pastilles */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
px = pad->m_Pos0.x;
py = pad->m_Pos0.y;
pad->m_Orient += newangle; /* change m_Orientation */
NORMALIZE_ANGLE_POS( pad->m_Orient );
RotatePoint( &px, &py, (int) m_Orient );
pad->m_Pos.x = m_Pos.x + px;
pad->m_Pos.y = m_Pos.y + py;
}
/* mise a jour de la reference et de la valeur*/
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
/* deplacement des contours et textes de l'empreinte : */
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == TYPE_EDGE_MODULE )
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord();
}
if( item->Type() == TYPE_TEXTE_MODULE )
{
/* deplacement des inscriptions : */
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->SetDrawCoord();
}
}
/* Recalcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
}
/************************************************/ /************************************************/
void MODULE::Set_Rectangle_Encadrement() void MODULE::Set_Rectangle_Encadrement()
/************************************************/ /************************************************/
......
...@@ -123,7 +123,27 @@ public: ...@@ -123,7 +123,27 @@ public:
// Moves // Moves
void SetPosition( const wxPoint& newpos ); void SetPosition( const wxPoint& newpos );
void SetOrientation( int newangle ); void SetOrientation( int newangle );
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector);
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/** /**
* Function IsLocked * Function IsLocked
......
/****************************************************
* class_module_transform_functions.cpp :
* functions of class MODULE to handle some geometric changes:
* move, rot ...
****************************************************/
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "trigo.h"
#include "pcbcommon.h"
#include "pcbnew.h"
#include "protos.h"
/*************************************/
int ChangeSideNumLayer( int oldlayer )
/*************************************/
/* Routine de recalcul du numero de couche lors des
* echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
*/
{
int newlayer;
switch( oldlayer )
{
case COPPER_LAYER_N:
newlayer = CMP_N; break;
case CMP_N:
newlayer = COPPER_LAYER_N; break;
case SILKSCREEN_N_CU:
newlayer = SILKSCREEN_N_CMP; break;
case SILKSCREEN_N_CMP:
newlayer = SILKSCREEN_N_CU; break;
case ADHESIVE_N_CU:
newlayer = ADHESIVE_N_CMP; break;
case ADHESIVE_N_CMP:
newlayer = ADHESIVE_N_CU; break;
case SOLDERMASK_N_CU:
newlayer = SOLDERMASK_N_CMP; break;
case SOLDERMASK_N_CMP:
newlayer = SOLDERMASK_N_CU; break;
case SOLDERPASTE_N_CU:
newlayer = SOLDERPASTE_N_CMP; break;
case SOLDERPASTE_N_CMP:
newlayer = SOLDERPASTE_N_CU; break;
default:
newlayer = oldlayer;
}
return newlayer;
}
/*********************************************/
static int ChangeSideMaskLayer( int masque )
/*********************************************/
/* Routine de recalcul du masque-layer lors des
* echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
*/
{
int newmasque;
newmasque = masque & ~(CUIVRE_LAYER | CMP_LAYER |
SILKSCREEN_LAYER_CU | SILKSCREEN_LAYER_CMP |
ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP |
SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP |
SOLDERPASTE_LAYER_CU | SOLDERPASTE_LAYER_CMP |
ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP);
if( masque & CUIVRE_LAYER )
newmasque |= CMP_LAYER;
if( masque & CMP_LAYER )
newmasque |= CUIVRE_LAYER;
if( masque & SILKSCREEN_LAYER_CU )
newmasque |= SILKSCREEN_LAYER_CMP;
if( masque & SILKSCREEN_LAYER_CMP )
newmasque |= SILKSCREEN_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP )
newmasque |= ADHESIVE_LAYER_CU;
if( masque & SOLDERMASK_LAYER_CU )
newmasque |= SOLDERMASK_LAYER_CMP;
if( masque & SOLDERMASK_LAYER_CMP )
newmasque |= SOLDERMASK_LAYER_CU;
if( masque & SOLDERPASTE_LAYER_CU )
newmasque |= SOLDERPASTE_LAYER_CMP;
if( masque & SOLDERPASTE_LAYER_CMP )
newmasque |= SOLDERPASTE_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP )
newmasque |= ADHESIVE_LAYER_CU;
return newmasque;
}
/**
* Function Move (virtual)
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
void MODULE::Move(const wxPoint& aMoveVector)
{
wxPoint newpos = m_Pos + aMoveVector;
SetPosition( newpos );
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void MODULE::Rotate(const wxPoint& aRotCentre, int aAngle)
{
wxPoint newpos = m_Pos;
RotatePoint( &newpos, aRotCentre, aAngle );
SetPosition( newpos );
SetOrientation( m_Orient + aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void MODULE::Flip(const wxPoint& aCentre )
{
D_PAD* pt_pad;
TEXTE_MODULE* pt_texte;
EDGE_MODULE* pt_edgmod;
EDA_BaseStruct* PtStruct;
// Move module to its final position:
wxPoint finalPos = m_Pos;
finalPos.y = aCentre.y - (finalPos.y - aCentre.y); /// Mirror the Y position
SetPosition(finalPos);
/* Flip layer */
SetLayer( ChangeSideNumLayer( GetLayer() ) );
/* Inversion miroir de l'orientation */
NEGATE( m_Orient );
NORMALIZE_ANGLE_POS( m_Orient );
/* Inversion miroir + layers des pastilles */
pt_pad = m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
pt_pad->m_Pos.y -= m_Pos.y;
pt_pad->m_Pos.y = -pt_pad->m_Pos.y;
pt_pad->m_Pos.y += m_Pos.y;
NEGATE(pt_pad->m_Pos0.y);
NEGATE(pt_pad->m_Offset.y);
NEGATE(pt_pad->m_DeltaSize.y);
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* flip pads layers*/
pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer );
}
/* Inversion miroir de la Reference et mise en miroir : */
pt_texte = m_Reference;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += m_Pos.y;
NEGATE(pt_texte->m_Pos0.y);
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) );
if( GetLayer() == COPPER_LAYER_N )
pt_texte->SetLayer( SILKSCREEN_N_CU );
if( GetLayer() == CMP_N )
pt_texte->SetLayer( SILKSCREEN_N_CMP );
if( (GetLayer() == SILKSCREEN_N_CU)
|| (GetLayer() == ADHESIVE_N_CU) || (GetLayer() == COPPER_LAYER_N) )
pt_texte->m_Mirror = true;
/* Inversion miroir de la Valeur et mise en miroir : */
pt_texte = m_Value;
pt_texte->m_Pos.y -= m_Pos.y;
NEGATE(pt_texte->m_Pos.y);
pt_texte->m_Pos.y += m_Pos.y;
NEGATE(pt_texte->m_Pos0.y);
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) );
if( GetLayer() == COPPER_LAYER_N )
pt_texte->SetLayer( SILKSCREEN_N_CU );
if( GetLayer() == CMP_N )
pt_texte->SetLayer( SILKSCREEN_N_CMP );
if( (GetLayer() == SILKSCREEN_N_CU)
|| (GetLayer() == ADHESIVE_N_CU) || (GetLayer() == COPPER_LAYER_N) )
pt_texte->m_Mirror = true;
/* Inversion miroir des dessins de l'empreinte : */
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
switch( PtStruct->Type() )
{
case TYPE_EDGE_MODULE:
pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->m_Start.y -= m_Pos.y;
pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y;
pt_edgmod->m_Start.y += m_Pos.y;
pt_edgmod->m_End.y -= m_Pos.y;
pt_edgmod->m_End.y = -pt_edgmod->m_End.y;
pt_edgmod->m_End.y += m_Pos.y;
/* inversion des coords locales */
NEGATE(pt_edgmod->m_Start0.y);
NEGATE(pt_edgmod->m_End0.y);
if( pt_edgmod->m_Shape == S_ARC )
{
NEGATE(pt_edgmod->m_Angle);
}
pt_edgmod->SetLayer( ChangeSideNumLayer( pt_edgmod->GetLayer() ) );
break;
case TYPE_TEXTE_MODULE:
/* Inversion miroir de la position et mise en miroir : */
pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += m_Pos.y;
NEGATE(pt_texte->m_Pos0.y);
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) );
if( GetLayer() == COPPER_LAYER_N )
pt_texte->SetLayer( SILKSCREEN_N_CU );
if( GetLayer() == CMP_N )
pt_texte->SetLayer( SILKSCREEN_N_CMP );
if( GetLayer() == SILKSCREEN_N_CU
|| GetLayer() == ADHESIVE_N_CU
|| GetLayer() == COPPER_LAYER_N )
{
pt_texte->m_Mirror = true;
}
break;
default:
wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) );
break;
}
}
/* calcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
}
/*************************************************/
void MODULE::SetPosition( const wxPoint& newpos )
/*************************************************/
// replace le module en position newpos
{
int deltaX = newpos.x - m_Pos.x;
int deltaY = newpos.y - m_Pos.y;
/* deplacement de l'ancre */
m_Pos.x += deltaX;
m_Pos.y += deltaY;
/* deplacement de la reference */
m_Reference->m_Pos.x += deltaX;
m_Reference->m_Pos.y += deltaY;
/* deplacement de la Valeur */
m_Value->m_Pos.x += deltaX;
m_Value->m_Pos.y += deltaY;
/* deplacement des pastilles */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->m_Pos.x += deltaX;
pad->m_Pos.y += deltaY;
}
/* deplacement des dessins de l'empreinte : */
EDA_BaseStruct* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
switch( PtStruct->Type() )
{
case TYPE_EDGE_MODULE:
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord();
break;
}
case TYPE_TEXTE_MODULE:
{
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.x += deltaX;
pt_texte->m_Pos.y += deltaY;
break;
}
default:
wxMessageBox( wxT( "Type Draw Indefini" ) ); break;
}
}
Set_Rectangle_Encadrement();
}
/*********************************************/
void MODULE::SetOrientation( int newangle )
/*********************************************/
/* Tourne de newangle (en 0.1 degres) le module
*/
{
int px, py;
newangle -= m_Orient; // = delta de rotation
m_Orient += newangle;
NORMALIZE_ANGLE_POS( m_Orient );
/* deplacement et rotation des pastilles */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
px = pad->m_Pos0.x;
py = pad->m_Pos0.y;
pad->m_Orient += newangle; /* change m_Orientation */
NORMALIZE_ANGLE_POS( pad->m_Orient );
RotatePoint( &px, &py, (int) m_Orient );
pad->m_Pos.x = m_Pos.x + px;
pad->m_Pos.y = m_Pos.y + py;
}
/* mise a jour de la reference et de la valeur*/
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
/* deplacement des contours et textes de l'empreinte : */
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == TYPE_EDGE_MODULE )
{
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) item;
pt_edgmod->SetDrawCoord();
}
if( item->Type() == TYPE_TEXTE_MODULE )
{
/* deplacement des inscriptions : */
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->SetDrawCoord();
}
}
/* Recalcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
}
...@@ -203,6 +203,15 @@ public: ...@@ -203,6 +203,15 @@ public:
*/ */
static int Compare( const D_PAD* padref, const D_PAD* padcmp ); static int Compare( const D_PAD* padref, const D_PAD* padcmp );
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Pos += aMoveVector;
}
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "trigo.h"
#include "protos.h"
/*******************/ /*******************/
...@@ -258,6 +260,39 @@ void TEXTE_PCB::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -258,6 +260,39 @@ void TEXTE_PCB::DisplayInfo( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, 70, _( "V Size" ), msg, RED ); Affiche_1_Parametre( frame, 70, _( "V Size" ), msg, RED );
} }
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void TEXTE_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
m_Orient += aAngle;
while( m_Orient >= 3600 )
m_Orient -= 3600;
while( m_Orient < -3600 )
m_Orient += 3600;
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void TEXTE_PCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
NEGATE( m_Orient );
if( (GetLayer() == COPPER_LAYER_N) || (GetLayer() == CMP_N) )
{
m_Mirror = not m_Mirror; /* inverse miroir */
}
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -24,6 +24,31 @@ public: ...@@ -24,6 +24,31 @@ public:
return m_Pos; // within EDA_TextStruct return m_Pos; // within EDA_TextStruct
} }
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Pos += aMoveVector;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/* duplicate structure */ /* duplicate structure */
void Copy( TEXTE_PCB* source ); void Copy( TEXTE_PCB* source );
......
...@@ -272,6 +272,34 @@ EDA_Rect TRACK::GetBoundingBox() ...@@ -272,6 +272,34 @@ EDA_Rect TRACK::GetBoundingBox()
return ret; return ret;
} }
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void TRACK::Rotate(const wxPoint& aRotCentre, int aAngle)
{
RotatePoint( &m_Start, aRotCentre, aAngle );
RotatePoint( &m_End, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void TRACK::Flip(const wxPoint& aCentre )
{
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
m_End.y = aCentre.y - (m_End.y - aCentre.y);
if( Type() == TYPE_VIA )
{
}
else
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
// see class_track.h // see class_track.h
// SEGVIA and SEGZONE inherit this version // SEGVIA and SEGZONE inherit this version
......
...@@ -60,6 +60,32 @@ public: ...@@ -60,6 +60,32 @@ public:
TRACK* Back() const { return (TRACK*) Pback; } TRACK* Back() const { return (TRACK*) Pback; }
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Start += aMoveVector;
m_End += aMoveVector;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
virtual void Rotate(const wxPoint& aRotCentre, int aAngle);
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "pcbnew.h" #include "pcbnew.h"
#include "zones.h" #include "zones.h"
#include "protos.h"
/************************/ /************************/
/* class ZONE_CONTAINER */ /* class ZONE_CONTAINER */
...@@ -1010,6 +1012,17 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, int angle ) ...@@ -1010,6 +1012,17 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, int angle )
m_Poly->Hatch(); m_Poly->Hatch();
} }
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* (like Mirror() but changes layer)
* @param const wxPoint& aCentre - the rotation point.
*/
void ZONE_CONTAINER::Flip(const wxPoint& aCentre )
{
Mirror( aCentre );
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
/** /**
* Function Mirror * Function Mirror
......
...@@ -285,6 +285,14 @@ public: ...@@ -285,6 +285,14 @@ public:
*/ */
void Rotate( const wxPoint& centre, int angle ); void Rotate( const wxPoint& centre, int angle );
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* (like Mirror() but changes layer)
* @param const wxPoint& aCentre - the rotation point.
*/
virtual void Flip(const wxPoint& aCentre );
/** /**
* Function Mirror * Function Mirror
* Mirror the outlines , relative to a given horizontal axis * Mirror the outlines , relative to a given horizontal axis
......
...@@ -36,7 +36,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { ...@@ -36,7 +36,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
// there are some restrictions on the order of items in the general case. // there are some restrictions on the order of items in the general case.
// all items in m_Drawings for instance should be contiguous. // all items in m_Drawings for instance should be contiguous.
// *** all items in a same list (shown here) must be contiguous **** // *** all items in a same list (shown here) must be contiguous ****
TYPE_MARKER, // in m_markers TYPE_MARKER_PCB, // in m_markers
TYPE_TEXTE, // in m_Drawings TYPE_TEXTE, // in m_Drawings
TYPE_DRAWSEGMENT, // in m_Drawings TYPE_DRAWSEGMENT, // in m_Drawings
TYPE_COTATION, // in m_Drawings TYPE_COTATION, // in m_Drawings
...@@ -66,7 +66,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { ...@@ -66,7 +66,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
const KICAD_T GENERAL_COLLECTOR::AllButZones[] = { const KICAD_T GENERAL_COLLECTOR::AllButZones[] = {
TYPE_MARKER, TYPE_MARKER_PCB,
TYPE_TEXTE, TYPE_TEXTE,
TYPE_DRAWSEGMENT, TYPE_DRAWSEGMENT,
TYPE_COTATION, TYPE_COTATION,
......
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
const DRC_ITEM* GetItem( int aIndex ) const DRC_ITEM* GetItem( int aIndex )
{ {
const MARKER* marker = m_board->GetMARKER( aIndex ); const MARKER_PCB* marker = m_board->GetMARKER( aIndex );
if( marker ) if( marker )
return &marker->GetReporter(); return &marker->GetReporter();
return NULL; return NULL;
...@@ -144,7 +144,7 @@ public: ...@@ -144,7 +144,7 @@ public:
void DeleteItem( int aIndex ) void DeleteItem( int aIndex )
{ {
MARKER* marker = m_board->GetMARKER( aIndex ); MARKER_PCB* marker = m_board->GetMARKER( aIndex );
if( marker ) if( marker )
m_board->Delete( marker ); m_board->Delete( marker );
} }
......
...@@ -119,7 +119,7 @@ void DIALOG_TRACKS_OPTIONS::OnButtonOkClick( wxCommandEvent& event ) ...@@ -119,7 +119,7 @@ void DIALOG_TRACKS_OPTIONS::OnButtonOkClick( wxCommandEvent& event )
m_Parent->AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA ); m_Parent->AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA );
m_Parent->AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK ); m_Parent->AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK );
m_Parent->AddHistory( g_DesignSettings.m_TrackClearence, TYPE_CLR ); m_Parent->AddHistory( g_DesignSettings.m_TrackClearence, TYPE_CLEARANCE );
EndModal( 1 ); EndModal( 1 );
} }
...@@ -171,7 +171,7 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type ) ...@@ -171,7 +171,7 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type )
} }
break; break;
case TYPE_CLR: case TYPE_CLEARANCE:
for( ii = 0; ii < HISTORY_NUMBER; ii++ ) for( ii = 0; ii < HISTORY_NUMBER; ii++ )
{ {
if( g_DesignSettings.m_TrackClearenceHistory[ii] == value ) if( g_DesignSettings.m_TrackClearenceHistory[ii] == value )
......
...@@ -409,7 +409,7 @@ void DRC::testZones( bool adoTestFillSegments ) ...@@ -409,7 +409,7 @@ void DRC::testZones( bool adoTestFillSegments )
} }
MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKER* fillMe ) MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKER_PCB* fillMe )
{ {
wxString textA = aTrack->MenuText( m_pcb ); wxString textA = aTrack->MenuText( m_pcb );
wxString textB; wxString textB;
...@@ -464,11 +464,11 @@ MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKE ...@@ -464,11 +464,11 @@ MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKE
else else
{ {
if( aItem ) if( aItem )
fillMe = new MARKER( aErrorCode, position, fillMe = new MARKER_PCB( aErrorCode, position,
textA, aTrack->GetPosition(), textA, aTrack->GetPosition(),
textB, posB ); textB, posB );
else else
fillMe = new MARKER( aErrorCode, position, fillMe = new MARKER_PCB( aErrorCode, position,
textA, aTrack->GetPosition() ); textA, aTrack->GetPosition() );
} }
...@@ -476,7 +476,7 @@ MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKE ...@@ -476,7 +476,7 @@ MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKE
} }
MARKER* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER* fillMe ) MARKER_PCB* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER_PCB* fillMe )
{ {
wxString textA = aPad->MenuText( m_pcb ); wxString textA = aPad->MenuText( m_pcb );
wxString textB = bPad->MenuText( m_pcb ); wxString textB = bPad->MenuText( m_pcb );
...@@ -487,13 +487,13 @@ MARKER* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER* fillM ...@@ -487,13 +487,13 @@ MARKER* DRC::fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER* fillM
if( fillMe ) if( fillMe )
fillMe->SetData( aErrorCode, posA, textA, posA, textB, posB ); fillMe->SetData( aErrorCode, posA, textA, posA, textB, posB );
else else
fillMe = new MARKER( aErrorCode, posA, textA, posA, textB, posB ); fillMe = new MARKER_PCB( aErrorCode, posA, textA, posA, textB, posB );
return fillMe; return fillMe;
} }
MARKER* DRC::fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER* fillMe ) MARKER_PCB* DRC::fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER_PCB* fillMe )
{ {
wxString textA = aArea->MenuText( m_pcb ); wxString textA = aArea->MenuText( m_pcb );
...@@ -502,16 +502,16 @@ MARKER* DRC::fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER* fillMe ) ...@@ -502,16 +502,16 @@ MARKER* DRC::fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER* fillMe )
if( fillMe ) if( fillMe )
fillMe->SetData( aErrorCode, posA, textA, posA ); fillMe->SetData( aErrorCode, posA, textA, posA );
else else
fillMe = new MARKER( aErrorCode, posA, textA, posA ); fillMe = new MARKER_PCB( aErrorCode, posA, textA, posA );
return fillMe; return fillMe;
} }
MARKER* DRC::fillMarker( const ZONE_CONTAINER* aArea, MARKER_PCB* DRC::fillMarker( const ZONE_CONTAINER* aArea,
const wxPoint& aPos, const wxPoint& aPos,
int aErrorCode, int aErrorCode,
MARKER* fillMe ) MARKER_PCB* fillMe )
{ {
wxString textA = aArea->MenuText( m_pcb ); wxString textA = aArea->MenuText( m_pcb );
...@@ -520,7 +520,7 @@ MARKER* DRC::fillMarker( const ZONE_CONTAINER* aArea, ...@@ -520,7 +520,7 @@ MARKER* DRC::fillMarker( const ZONE_CONTAINER* aArea,
if( fillMe ) if( fillMe )
fillMe->SetData( aErrorCode, posA, textA, posA ); fillMe->SetData( aErrorCode, posA, textA, posA );
else else
fillMe = new MARKER( aErrorCode, posA, textA, posA ); fillMe = new MARKER_PCB( aErrorCode, posA, textA, posA );
return fillMe; return fillMe;
} }
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
class WinEDA_DrawPanel; class WinEDA_DrawPanel;
class MARKER; class MARKER_PCB;
class DIALOG_DRC_CONTROL; class DIALOG_DRC_CONTROL;
...@@ -144,7 +144,7 @@ private: ...@@ -144,7 +144,7 @@ private:
// int m_errorCount; // int m_errorCount;
MARKER* m_currentMarker; MARKER_PCB* m_currentMarker;
bool m_aboartDRC; bool m_aboartDRC;
bool m_drcInProgress; bool m_drcInProgress;
...@@ -188,14 +188,14 @@ private: ...@@ -188,14 +188,14 @@ private:
* or TRACK. * or TRACK.
* @param aErrorCode A categorizing identifier for the particular type * @param aErrorCode A categorizing identifier for the particular type
* of error that is being reported. * of error that is being reported.
* @param fillMe A MARKER* which is to be filled in, or NULL if one is to * @param fillMe A MARKER_PCB* which is to be filled in, or NULL if one is to
* first be allocated, then filled. * first be allocated, then filled.
*/ */
MARKER* fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKER* fillMe ); MARKER_PCB* fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKER_PCB* fillMe );
MARKER* fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER* fillMe ); MARKER_PCB* fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER_PCB* fillMe );
MARKER* fillMarker( ZONE_CONTAINER * aArea, int aErrorCode, MARKER* fillMe ); MARKER_PCB* fillMarker( ZONE_CONTAINER * aArea, int aErrorCode, MARKER_PCB* fillMe );
/** /**
* Function fillMarker * Function fillMarker
...@@ -206,10 +206,10 @@ private: ...@@ -206,10 +206,10 @@ private:
* @param aEdge edge zone to test * @param aEdge edge zone to test
* @param aPos position of error * @param aPos position of error
* @param aErrorCode Type of error * @param aErrorCode Type of error
* @param fillMe A MARKER* which is to be filled in, or NULL if one is to * @param fillMe A MARKER_PCB* which is to be filled in, or NULL if one is to
* first be allocated, then filled. * first be allocated, then filled.
*/ */
MARKER* fillMarker( const ZONE_CONTAINER * aArea, const wxPoint & aPos, int aErrorCode, MARKER* fillMe ); MARKER_PCB* fillMarker( const ZONE_CONTAINER * aArea, const wxPoint & aPos, int aErrorCode, MARKER_PCB* fillMe );
//-----<categorical group tests>----------------------------------------- //-----<categorical group tests>-----------------------------------------
......
...@@ -958,8 +958,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -958,8 +958,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_GETINFO_MARKER: case ID_POPUP_PCB_GETINFO_MARKER:
if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER ) if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER_PCB )
( (MARKER*) GetCurItem() )->DisplayMarkerInfo( this ); ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
...@@ -1261,10 +1261,10 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) ...@@ -1261,10 +1261,10 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
} }
break; break;
case TYPE_MARKER: case TYPE_MARKER_PCB:
if( Item == GetCurItem() ) if( Item == GetCurItem() )
SetCurItem( NULL ); SetCurItem( NULL );
( (MARKER*) Item )->Draw( DrawPanel, DC, GR_XOR ); ( (MARKER_PCB*) Item )->Draw( DrawPanel, DC, GR_XOR );
// delete the marker, and free memory. Don't use undo stack. // delete the marker, and free memory. Don't use undo stack.
GetBoard()->Delete( Item ); GetBoard()->Delete( Item );
......
...@@ -72,7 +72,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) ...@@ -72,7 +72,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
if( FindMarker ) if( FindMarker )
{ {
MARKER* marker = m_Parent->GetBoard()->GetMARKER( s_MarkerCount++ ); MARKER_PCB* marker = m_Parent->GetBoard()->GetMARKER( s_MarkerCount++ );
if( marker ) if( marker )
{ {
foundItem = marker; foundItem = marker;
......
...@@ -145,7 +145,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -145,7 +145,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
PlotMirePcb(plotter, (MIREPCB*) PtStruct, EDGE_LAYER, FILLED ); PlotMirePcb(plotter, (MIREPCB*) PtStruct, EDGE_LAYER, FILLED );
break; break;
case TYPE_MARKER: // do not draw case TYPE_MARKER_PCB: // do not draw
break; break;
default: default:
......
...@@ -370,7 +370,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -370,7 +370,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "TrackClearenceHistory" ) == 0 ) if( stricmp( Line, "TrackClearenceHistory" ) == 0 )
{ {
int tmp = atoi( data ); int tmp = atoi( data );
AddHistory( tmp, TYPE_CLR ); AddHistory( tmp, TYPE_CLEARANCE );
continue; continue;
} }
......
...@@ -322,7 +322,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, ...@@ -322,7 +322,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
case TYPE_VIA: case TYPE_VIA:
case TYPE_TRACK: case TYPE_TRACK:
case TYPE_ZONE: case TYPE_ZONE:
case TYPE_MARKER: case TYPE_MARKER_PCB:
case TYPE_COTATION: case TYPE_COTATION:
case TYPE_MIRE: case TYPE_MIRE:
break; break;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
/* fonctions externes */ /* fonctions externes */
/* Fonctions locales */ /* Fonctions locales */
static int ChangeSideMaskLayer( int masque );
static void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC );
/* Variables locales : */ /* Variables locales : */
...@@ -349,10 +348,6 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -349,10 +348,6 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC )
* @param DC Current Device Context. if NULL, no redraw * @param DC Current Device Context. if NULL, no redraw
*/ */
{ {
D_PAD* pt_pad;
TEXTE_MODULE* pt_texte;
EDGE_MODULE* pt_edgmod;
EDA_BaseStruct* PtStruct;
if( Module == NULL ) if( Module == NULL )
return; return;
...@@ -390,131 +385,8 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -390,131 +385,8 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC )
} }
} }
/* mise a jour du Flag de l'empreinte et des couches des contours et textes */ /* Flip the module */
Module->SetLayer( ChangeSideNumLayer( Module->GetLayer() ) ); Module->Flip( Module->m_Pos );
/* Inversion miroir de l'orientation */
Module->m_Orient = -Module->m_Orient;
NORMALIZE_ANGLE_POS( Module->m_Orient );
/* Inversion miroir + layers des pastilles */
pt_pad = Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
pt_pad->m_Pos.y -= Module->m_Pos.y;
pt_pad->m_Pos.y = -pt_pad->m_Pos.y;
pt_pad->m_Pos.y += Module->m_Pos.y;
pt_pad->m_Pos0.y = -pt_pad->m_Pos0.y;
pt_pad->m_Offset.y = -pt_pad->m_Offset.y;
pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* change cote pour pastilles surfaciques */
pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer );
}
/* Inversion miroir de la Reference et mise en miroir : */
pt_texte = Module->m_Reference;
pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = -pt_texte->m_Pos0.y;
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( Module->GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) );
if( Module->GetLayer() == COPPER_LAYER_N )
pt_texte->SetLayer( SILKSCREEN_N_CU );
if( Module->GetLayer() == CMP_N )
pt_texte->SetLayer( SILKSCREEN_N_CMP );
if( (Module->GetLayer() == SILKSCREEN_N_CU)
|| (Module->GetLayer() == ADHESIVE_N_CU) || (Module->GetLayer() == COPPER_LAYER_N) )
pt_texte->m_Mirror = true;
/* Inversion miroir de la Valeur et mise en miroir : */
pt_texte = Module->m_Value;
pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = -pt_texte->m_Pos0.y;
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( Module->GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) );
if( Module->GetLayer() == COPPER_LAYER_N )
pt_texte->SetLayer( SILKSCREEN_N_CU );
if( Module->GetLayer() == CMP_N )
pt_texte->SetLayer( SILKSCREEN_N_CMP );
if( (Module->GetLayer() == SILKSCREEN_N_CU)
|| (Module->GetLayer() == ADHESIVE_N_CU) || (Module->GetLayer() == COPPER_LAYER_N) )
pt_texte->m_Mirror = true;
/* Inversion miroir des dessins de l'empreinte : */
PtStruct = Module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
switch( PtStruct->Type() )
{
case TYPE_EDGE_MODULE:
pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->m_Start.y -= Module->m_Pos.y;
pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y;
pt_edgmod->m_Start.y += Module->m_Pos.y;
pt_edgmod->m_End.y -= Module->m_Pos.y;
pt_edgmod->m_End.y = -pt_edgmod->m_End.y;
pt_edgmod->m_End.y += Module->m_Pos.y;
/* inversion des coords locales */
pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y;
pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y;
if( pt_edgmod->m_Shape == S_ARC )
{
pt_edgmod->m_Angle = -pt_edgmod->m_Angle;
}
pt_edgmod->SetLayer( ChangeSideNumLayer( pt_edgmod->GetLayer() ) );
break;
case TYPE_TEXTE_MODULE:
/* Inversion miroir de la position et mise en miroir : */
pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = - pt_texte->m_Pos0.y;
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( Module->GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) );
if( Module->GetLayer() == COPPER_LAYER_N )
pt_texte->SetLayer( SILKSCREEN_N_CU );
if( Module->GetLayer() == CMP_N )
pt_texte->SetLayer( SILKSCREEN_N_CMP );
if( Module->GetLayer() == SILKSCREEN_N_CU
|| Module->GetLayer() == ADHESIVE_N_CU
|| Module->GetLayer() == COPPER_LAYER_N )
{
pt_texte->m_Mirror = true;
}
break;
default:
DisplayError( m_PcbFrame, wxT( "Unknown Draw Type" ) ); break;
}
}
/* calcul du rectangle d'encadrement */
Module->Set_Rectangle_Encadrement();
if( m_PcbFrame ) if( m_PcbFrame )
Module->DisplayInfo( m_PcbFrame ); Module->DisplayInfo( m_PcbFrame );
...@@ -541,109 +413,6 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -541,109 +413,6 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC )
} }
/*********************************************/
static int ChangeSideMaskLayer( int masque )
/*********************************************/
/* Routine de recalcul du masque-layer lors des
* echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
*/
{
int newmasque;
newmasque = masque & ~(CUIVRE_LAYER | CMP_LAYER |
SILKSCREEN_LAYER_CU | SILKSCREEN_LAYER_CMP |
ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP |
SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP |
SOLDERPASTE_LAYER_CU | SOLDERPASTE_LAYER_CMP |
ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP);
if( masque & CUIVRE_LAYER )
newmasque |= CMP_LAYER;
if( masque & CMP_LAYER )
newmasque |= CUIVRE_LAYER;
if( masque & SILKSCREEN_LAYER_CU )
newmasque |= SILKSCREEN_LAYER_CMP;
if( masque & SILKSCREEN_LAYER_CMP )
newmasque |= SILKSCREEN_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP )
newmasque |= ADHESIVE_LAYER_CU;
if( masque & SOLDERMASK_LAYER_CU )
newmasque |= SOLDERMASK_LAYER_CMP;
if( masque & SOLDERMASK_LAYER_CMP )
newmasque |= SOLDERMASK_LAYER_CU;
if( masque & SOLDERPASTE_LAYER_CU )
newmasque |= SOLDERPASTE_LAYER_CMP;
if( masque & SOLDERPASTE_LAYER_CMP )
newmasque |= SOLDERPASTE_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP )
newmasque |= ADHESIVE_LAYER_CU;
return newmasque;
}
/*************************************/
int ChangeSideNumLayer( int oldlayer )
/*************************************/
/* Routine de recalcul du numero de couche lors des
* echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
*/
{
int newlayer;
switch( oldlayer )
{
case COPPER_LAYER_N:
newlayer = CMP_N; break;
case CMP_N:
newlayer = COPPER_LAYER_N; break;
case SILKSCREEN_N_CU:
newlayer = SILKSCREEN_N_CMP; break;
case SILKSCREEN_N_CMP:
newlayer = SILKSCREEN_N_CU; break;
case ADHESIVE_N_CU:
newlayer = ADHESIVE_N_CMP; break;
case ADHESIVE_N_CMP:
newlayer = ADHESIVE_N_CU; break;
case SOLDERMASK_N_CU:
newlayer = SOLDERMASK_N_CMP; break;
case SOLDERMASK_N_CMP:
newlayer = SOLDERMASK_N_CU; break;
case SOLDERPASTE_N_CU:
newlayer = SOLDERPASTE_N_CMP; break;
case SOLDERPASTE_N_CMP:
newlayer = SOLDERPASTE_N_CU; break;
default:
newlayer = oldlayer;
}
return newlayer;
}
/*****************************************************************/ /*****************************************************************/
void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest ) void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest )
/*****************************************************************/ /*****************************************************************/
......
...@@ -275,8 +275,8 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -275,8 +275,8 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
createPopupMenuForTracks( (TRACK*) item, aPopMenu ); createPopupMenuForTracks( (TRACK*) item, aPopMenu );
break; break;
case TYPE_MARKER: case TYPE_MARKER_PCB:
createPopUpMenuForMarkers( (MARKER*) item, aPopMenu ); createPopUpMenuForMarkers( (MARKER_PCB*) item, aPopMenu );
break; break;
case TYPE_COTATION: case TYPE_COTATION:
...@@ -879,7 +879,7 @@ void WinEDA_PcbFrame::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) ...@@ -879,7 +879,7 @@ void WinEDA_PcbFrame::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
} }
/**********************************************************************/ /**********************************************************************/
void WinEDA_PcbFrame::createPopUpMenuForMarkers( MARKER* aMarker, wxMenu* aPopMenu ) void WinEDA_PcbFrame::createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu )
/**********************************************************************/ /**********************************************************************/
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ), delete_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ), delete_xpm );
......
...@@ -57,7 +57,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( Plotter* plotter, ...@@ -57,7 +57,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( Plotter* plotter,
PlotMirePcb( plotter, (MIREPCB*) PtStruct, masque_layer, trace_mode ); PlotMirePcb( plotter, (MIREPCB*) PtStruct, masque_layer, trace_mode );
break; break;
case TYPE_MARKER: case TYPE_MARKER_PCB:
break; break;
default: default:
...@@ -740,7 +740,7 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( Plotter* plotter, ...@@ -740,7 +740,7 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( Plotter* plotter,
PlotMirePcb( plotter, (MIREPCB*) item, masque_layer, trace_mode ); PlotMirePcb( plotter, (MIREPCB*) item, masque_layer, trace_mode );
break; break;
case TYPE_MARKER: case TYPE_MARKER_PCB:
break; break;
default: default:
......
...@@ -76,7 +76,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa ...@@ -76,7 +76,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa
item->Draw( this, aDC, drawmode ); item->Draw( this, aDC, drawmode );
break; break;
case TYPE_MARKER: /* Trace des marqueurs */ case TYPE_MARKER_PCB: /* Trace des marqueurs */
default: default:
break; break;
} }
......
...@@ -482,7 +482,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -482,7 +482,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
// erase the ratsnest displayed on screen if needed // erase the ratsnest displayed on screen if needed
for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ )
{ {
if( !g_Show_Ratsnest ) // Clear VISIBLE flag if( !g_Show_Ratsnest && DC ) // Clear VISIBLE flag
m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE; m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
if( DC ) if( DC )
......
...@@ -847,7 +847,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E ...@@ -847,7 +847,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
{ {
wxString msg1 = Area_Ref->MenuText( this ); wxString msg1 = Area_Ref->MenuText( this );
wxString msg2 = Area_To_Test->MenuText( this ); wxString msg2 = Area_To_Test->MenuText( this );
MARKER* marker = new MARKER( COPPERAREA_INSIDE_COPPERAREA, wxPoint( x, y ), MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA, wxPoint( x, y ),
msg1, wxPoint( x, y ), msg1, wxPoint( x, y ),
msg2, wxPoint( x, y ) ); msg2, wxPoint( x, y ) );
Add( marker ); Add( marker );
...@@ -868,7 +868,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E ...@@ -868,7 +868,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
{ {
wxString msg1 = Area_To_Test->MenuText( this ); wxString msg1 = Area_To_Test->MenuText( this );
wxString msg2 = Area_Ref->MenuText( this ); wxString msg2 = Area_Ref->MenuText( this );
MARKER* marker = new MARKER( COPPERAREA_INSIDE_COPPERAREA, wxPoint( x, y ), MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA, wxPoint( x, y ),
msg1, wxPoint( x, y ), msg1, wxPoint( x, y ),
msg2, wxPoint( x, y ) ); msg2, wxPoint( x, y ) );
Add( marker ); Add( marker );
...@@ -935,7 +935,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E ...@@ -935,7 +935,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
{ {
wxString msg1 = Area_Ref->MenuText( this ); wxString msg1 = Area_Ref->MenuText( this );
wxString msg2 = Area_To_Test->MenuText( this ); wxString msg2 = Area_To_Test->MenuText( this );
MARKER* marker = new MARKER( COPPERAREA_CLOSE_TO_COPPERAREA, MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_CLOSE_TO_COPPERAREA,
wxPoint( x, y ), wxPoint( x, y ),
msg1, wxPoint( x, y ), msg1, wxPoint( x, y ),
msg2, wxPoint( x, y ) ); msg2, wxPoint( x, y ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment