Commit b0923f78 authored by Pascal Baerten's avatar Pascal Baerten Committed by jean-pierre charras

added eeschema rotate block patch from Pascal Baerten. Uncrustify files. fixed some issues.

Some minor issues (sheet and pin sheet rotate from menu) must be added
parents 4e3e2108 352dcb38
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
// Imported functions: // Imported functions:
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector ); const wxPoint aMoveVector );
void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList,
wxPoint& Center );
void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList,
wxPoint& aMirrorPoint );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList,
wxPoint& Center ); wxPoint& Center );
void DeleteItemsInList( WinEDA_DrawPanel* panel, void DeleteItemsInList( WinEDA_DrawPanel* panel,
...@@ -111,7 +115,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -111,7 +115,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
wxString msg; wxString msg;
err = TRUE; err = TRUE;
msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd \ msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd \
%d, state %d)" ), %d, state %d)" ),
block->m_Command, block->m_State ); block->m_Command, block->m_State );
DisplayError( this, msg ); DisplayError( this, msg );
} }
...@@ -124,6 +128,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -124,6 +128,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
err = TRUE; err = TRUE;
break; break;
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
...@@ -163,16 +170,13 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -163,16 +170,13 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_ZOOM: // Handled by HandleBlockEnd() case BLOCK_ZOOM: // Handled by HandleBlockEnd()
case BLOCK_DELETE: case BLOCK_DELETE:
case BLOCK_SAVE: case BLOCK_SAVE:
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_FLIP: case BLOCK_FLIP:
case BLOCK_ABORT: case BLOCK_ABORT:
case BLOCK_SELECT_ITEMS_ONLY: case BLOCK_SELECT_ITEMS_ONLY:
break; break;
} }
OnModify( ); OnModify();
/* clear struct.m_Flags */ /* clear struct.m_Flags */
SCH_ITEM* Struct; SCH_ITEM* Struct;
...@@ -193,7 +197,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -193,7 +197,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( block->GetCount() ) if( block->GetCount() )
{ {
DisplayError( this, DisplayError( this,
wxT( "HandleBlockPLace() error: some items left in buffer" ) ); wxT( "HandleBlockPLace() error: some items left in buffer" ) );
block->ClearItemsList(); block->ClearItemsList();
} }
...@@ -240,6 +244,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -240,6 +244,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() ); BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() ); PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
...@@ -269,7 +276,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -269,7 +276,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{ {
ii = -1; ii = -1;
DeleteItemsInList( DrawPanel, block->m_ItemsSelection ); DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
OnModify( ); OnModify();
} }
block->ClearItemsList(); block->ClearItemsList();
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
...@@ -298,10 +305,6 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -298,10 +305,6 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_FLIP: /* pcbnew only! */ case BLOCK_FLIP: /* pcbnew only! */
break; break;
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
zoom_command = TRUE; zoom_command = TRUE;
...@@ -396,7 +399,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -396,7 +399,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
{ {
ii = -1; ii = -1;
DeleteItemsInList( DrawPanel, block->m_ItemsSelection ); DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
OnModify( ); OnModify();
} }
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -425,15 +428,53 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -425,15 +428,53 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_ROTATE: case BLOCK_ROTATE:
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
ii = 1;
/* Compute the rotation center and put it on grid */
wxPoint rotationPoint = block->Centre();
PutOnGrid( &rotationPoint );
SaveCopyInUndoList( block->m_ItemsSelection,
UR_ROTATED,
rotationPoint );
RotateListOfItems( block->m_ItemsSelection, rotationPoint );
OnModify();
}
TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh();
block->m_State = STATE_BLOCK_MOVE;
block->m_Command = BLOCK_MOVE; //allows multiple rotate
break; break;
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
ii = 1;
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
PutOnGrid( &mirrorPoint );
SaveCopyInUndoList( block->m_ItemsSelection,
UR_MIRRORED_X,
mirrorPoint );
Mirror_X_ListOfItems( block->m_ItemsSelection, mirrorPoint );
OnModify();
block->m_State = STATE_BLOCK_MOVE;
block->m_Command = BLOCK_MOVE; //allows multiple mirrors
}
TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh();
break;
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() ) if( block->GetCount() )
{ {
ii = -1; ii = 1;
/* Compute the mirror center and put it on grid */ /* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre(); wxPoint mirrorPoint = block->Centre();
PutOnGrid( &mirrorPoint ); PutOnGrid( &mirrorPoint );
...@@ -441,7 +482,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -441,7 +482,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
UR_MIRRORED_Y, UR_MIRRORED_Y,
mirrorPoint ); mirrorPoint );
MirrorListOfItems( block->m_ItemsSelection, mirrorPoint ); MirrorListOfItems( block->m_ItemsSelection, mirrorPoint );
OnModify( ); OnModify();
block->m_State = STATE_BLOCK_MOVE;
block->m_Command = BLOCK_MOVE; //allows multiple mirrors
} }
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -515,6 +558,7 @@ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ) ...@@ -515,6 +558,7 @@ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
/* save the new list: */ /* save the new list: */
ITEM_PICKER item; ITEM_PICKER item;
// In list the wrapper is owner of the shematic item, we can use the UR_DELETED // In list the wrapper is owner of the shematic item, we can use the UR_DELETED
// status for the picker because pickers with this status are owner of the picked item // status for the picker because pickers with this status are owner of the picked item
// (or TODO ?: create a new status like UR_DUPLICATE) // (or TODO ?: create a new status like UR_DUPLICATE)
...@@ -523,7 +567,7 @@ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ) ...@@ -523,7 +567,7 @@ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
{ {
/* Make a copy of the original picked item. */ /* Make a copy of the original picked item. */
SCH_ITEM* DrawStructCopy = DuplicateStruct( SCH_ITEM* DrawStructCopy = DuplicateStruct(
(SCH_ITEM*) aItemsList.GetPickedItem( ii ) ); (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
DrawStructCopy->SetParent( NULL ); DrawStructCopy->SetParent( NULL );
item.m_PickedItem = DrawStructCopy; item.m_PickedItem = DrawStructCopy;
g_BlockSaveDataList.PushItem( item ); g_BlockSaveDataList.PushItem( item );
...@@ -552,7 +596,7 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -552,7 +596,7 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ ) for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ )
{ {
Struct = DuplicateStruct( Struct = DuplicateStruct(
(SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem( (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem(
ii ) ); ii ) );
picker.m_PickedItem = Struct; picker.m_PickedItem = Struct;
picklist.PushItem( picker ); picklist.PushItem( picker );
...@@ -579,7 +623,7 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -579,7 +623,7 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
Struct = Struct->Next() ) Struct = Struct->Next() )
Struct->m_Flags = 0; Struct->m_Flags = 0;
OnModify( ); OnModify();
return; return;
} }
...@@ -591,10 +635,10 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -591,10 +635,10 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
*/ */
static void CollectStructsToDrag( SCH_SCREEN* screen ) static void CollectStructsToDrag( SCH_SCREEN* screen )
{ {
SCH_ITEM* Struct; SCH_ITEM* Struct;
SCH_LINE* SegmStruct; SCH_LINE* SegmStruct;
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection; PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
if( pickedlist->GetCount() == 0 ) if( pickedlist->GetCount() == 0 )
return; return;
...@@ -618,7 +662,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -618,7 +662,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Remove the displacement of segment and undo the selection. */ /* Remove the displacement of segment and undo the selection. */
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{ {
Struct = (SCH_ITEM*) (SCH_ITEM*) pickedlist->GetPickedItem( ii ); Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE ) if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{ {
SegmStruct = (SCH_LINE*) Struct; SegmStruct = (SCH_LINE*) Struct;
...@@ -639,18 +683,18 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -639,18 +683,18 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{ {
Struct = (SCH_ITEM*) (SCH_ITEM*) pickedlist->GetPickedItem( ii ); Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( ( Struct->Type() == TYPE_SCH_LABEL ) if( ( Struct->Type() == TYPE_SCH_LABEL )
|| ( Struct->Type() == TYPE_SCH_GLOBALLABEL ) || ( Struct->Type() == TYPE_SCH_GLOBALLABEL )
|| ( Struct->Type() == TYPE_SCH_HIERLABEL ) ) || ( Struct->Type() == TYPE_SCH_HIERLABEL ) )
{ {
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_TEXT*) Struct ) #define STRUCT ( (SCH_TEXT*) Struct )
if( !screen->m_BlockLocate.Inside( STRUCT->m_Pos ) ) if( !screen->m_BlockLocate.Inside( STRUCT->m_Pos ) )
{ {
AddPickedItem( screen, STRUCT->m_Pos ); AddPickedItem( screen, STRUCT->m_Pos );
}
} }
}
if( Struct->Type() == TYPE_SCH_COMPONENT ) if( Struct->Type() == TYPE_SCH_COMPONENT )
{ {
...@@ -677,8 +721,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -677,8 +721,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
SCH_SHEET* sheet = (SCH_SHEET*) Struct; SCH_SHEET* sheet = (SCH_SHEET*) Struct;
// Add all pins sheets of a selected hierarchical sheet to the list // Add all pins sheets of a selected hierarchical sheet to the list
BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() ) BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() ) {
{
AddPickedItem( screen, label.m_Pos ); AddPickedItem( screen, label.m_Pos );
} }
} }
...@@ -701,7 +744,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -701,7 +744,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
*/ */
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{ {
SCH_ITEM* Struct; SCH_ITEM* Struct;
/* Review the list of already selected elements. */ /* Review the list of already selected elements. */
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection; PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
...@@ -871,8 +914,8 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -871,8 +914,8 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
Pin = Entry->GetNextPin(); Pin = Entry->GetNextPin();
Multi = aDrawLibItem->m_Multi; Multi = aDrawLibItem->m_Multi;
convert = aDrawLibItem->m_Convert; convert = aDrawLibItem->m_Convert;
CmpPosition = aDrawLibItem->m_Pos; CmpPosition = aDrawLibItem->m_Pos;
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "confirm.h" #include "confirm.h"
#include "trigo.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
...@@ -204,6 +205,16 @@ bool SCH_SHEET::HasLabel( const wxString& aName ) ...@@ -204,6 +205,16 @@ bool SCH_SHEET::HasLabel( const wxString& aName )
return false; return false;
} }
bool SCH_SHEET::IsVerticalOrientation()
{
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels )
{
if( label.GetEdge()>1 )
return true;
}
return false;
}
bool SCH_SHEET::HasUndefinedLabels() bool SCH_SHEET::HasUndefinedLabels()
{ {
...@@ -316,18 +327,7 @@ SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition ) ...@@ -316,18 +327,7 @@ SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition )
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{ {
size = ( label.GetLength() + 1 ) * label.m_Size.x; if (label.HitTest(aPosition)) return &label;
if( label.m_Edge )
size = -size;
minx = label.m_Pos.x;
maxx = label.m_Pos.x + size;
if( maxx < minx )
EXCHG( maxx, minx );
dy = label.m_Size.x / 2;
if( ( ABS( aPosition.y - label.m_Pos.y ) <= dy )
&& ( aPosition.x <= maxx ) && ( aPosition.x >= minx ) )
return &label;
} }
return NULL; return NULL;
...@@ -358,6 +358,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -358,6 +358,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
int txtcolor; int txtcolor;
wxString Text; wxString Text;
int color; int color;
int name_orientation;
wxPoint pos_sheetname,pos_filename;
wxPoint pos = m_Pos + aOffset; wxPoint pos = m_Pos + aOffset;
int LineWidth = g_DrawDefaultLineThickness; int LineWidth = g_DrawDefaultLineThickness;
...@@ -369,7 +371,18 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -369,7 +371,18 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y, GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y,
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color );
if (IsVerticalOrientation())
{
pos_sheetname=wxPoint( pos.x-8, pos.y+m_Size.y );
pos_filename=wxPoint( pos.x+m_Size.x+4, pos.y+m_Size.y );
name_orientation=TEXT_ORIENT_VERT;
}
else
{
pos_sheetname=wxPoint( pos.x, pos.y - 8 );
pos_filename=wxPoint( pos.x, pos.y + m_Size.y + 4 );
name_orientation=TEXT_ORIENT_HORIZ;
}
/* Draw text : SheetName */ /* Draw text : SheetName */
if( aColor > 0 ) if( aColor > 0 )
txtcolor = aColor; txtcolor = aColor;
...@@ -377,8 +390,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -377,8 +390,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
Text = wxT( "Sheet: " ) + m_SheetName; Text = wxT( "Sheet: " ) + m_SheetName;
DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y - 8 ), DrawGraphicText( aPanel, aDC, pos_sheetname,
(EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ, (EDA_Colors) txtcolor, Text, name_orientation,
wxSize( m_SheetNameSize, m_SheetNameSize ), wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth,
false, false, false ); false, false, false );
...@@ -389,8 +402,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -389,8 +402,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_FileName; Text = wxT( "File: " ) + m_FileName;
DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y + m_Size.y + 4 ), DrawGraphicText( aPanel, aDC, pos_filename,
(EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ, (EDA_Colors) txtcolor, Text, name_orientation,
wxSize( m_FileNameSize, m_FileNameSize ), wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth,
false, false, false ); false, false, false );
...@@ -741,6 +754,34 @@ void SCH_SHEET::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -741,6 +754,34 @@ void SCH_SHEET::DisplayInfo( WinEDA_DrawFrame* frame )
} }
void SCH_SHEET::Rotate(wxPoint rotationPoint)
{
RotatePoint(&m_Pos,rotationPoint,900);
RotatePoint(&m_Size.x,&m_Size.y,900);
if (m_Size.x<0) {
m_Pos.x+=m_Size.x;
NEGATE(m_Size.x);
}
if (m_Size.y<0) {
m_Pos.y+=m_Size.y;
NEGATE(m_Size.y);
}
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
{
sheetPin.Rotate( rotationPoint );
}
}
void SCH_SHEET::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
m_Pos.y -= m_Size.y;
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
{
sheetPin.Mirror_X( aXaxis_position );
}
}
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
...@@ -770,8 +811,7 @@ void SCH_SHEET::Resize( const wxSize& aSize ) ...@@ -770,8 +811,7 @@ void SCH_SHEET::Resize( const wxSize& aSize )
/* Move the sheet labels according to the new sheet size. */ /* Move the sheet labels according to the new sheet size. */
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{ {
if( label.m_Edge ) label.ConstraintOnEdge(label.m_Pos);
label.m_Pos.x = m_Pos.x + m_Size.x;
} }
} }
...@@ -817,3 +857,4 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os ) ...@@ -817,3 +857,4 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os )
} }
#endif #endif
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base_struct.h" #include "base_struct.h"
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include "class_text-label.h"
extern SCH_SHEET* g_RootSheet; extern SCH_SHEET* g_RootSheet;
...@@ -22,17 +22,29 @@ extern SCH_SHEET* g_RootSheet; ...@@ -22,17 +22,29 @@ extern SCH_SHEET* g_RootSheet;
* connected to a wire, bus, or label. In the schematic page represented by * connected to a wire, bus, or label. In the schematic page represented by
* the sheet, it corresponds to a hierarchical label. * the sheet, it corresponds to a hierarchical label.
*/ */
class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct
//class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct
class SCH_SHEET_PIN : public SCH_HIERLABEL
{ {
private: private:
int m_Number; ///< Label number use for saving sheet label to file. int m_Number; ///< Label number use for saving sheet label to file.
///< Sheet label numbering begins at 2. ///< Sheet label numbering begins at 2.
///< 0 is reserved for the sheet name. ///< 0 is reserved for the sheet name.
///< 1 is reserve for the sheet file name. ///< 1 is reserve for the sheet file name.
int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin
* m_Edge define on which edge the pin is positionned:
* 0: pin on left side
* 1: pin on right side
* 2: pin on top side
* 3: pin on bottom side
* for compatibility reasons, this does not follow same values as text
* orientation.
*/
public: public:
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE non connected //int m_Shape;
//bool m_IsDangling; // TRUE non connected
public: public:
SCH_SHEET_PIN( SCH_SHEET* parent, SCH_SHEET_PIN( SCH_SHEET* parent,
...@@ -46,15 +58,18 @@ public: ...@@ -46,15 +58,18 @@ public:
return wxT( "SCH_SHEET_PIN" ); return wxT( "SCH_SHEET_PIN" );
} }
bool operator==( const SCH_SHEET_PIN* aPin ) const;
bool operator ==( const SCH_SHEET_PIN* aPin ) const;
SCH_SHEET_PIN* GenCopy(); SCH_SHEET_PIN* GenCopy();
SCH_SHEET_PIN* Next() SCH_SHEET_PIN* Next()
{ {
return ( SCH_SHEET_PIN*) Pnext; return (SCH_SHEET_PIN*) Pnext;
} }
void SwapData( SCH_SHEET_PIN* copyitem );
/** /**
* Get the sheet label number. * Get the sheet label number.
* *
...@@ -67,7 +82,10 @@ public: ...@@ -67,7 +82,10 @@ public:
* *
* @param aNumber - New sheet number label. * @param aNumber - New sheet number label.
*/ */
void SetNumber( int aNumber ); void SetNumber( int aNumber );
void SetEdge( int aEdge );
int GetEdge();
void ConstraintOnEdge( wxPoint Pos );
/** /**
* Get the parent sheet object of this sheet pin. * Get the parent sheet object of this sheet pin.
...@@ -77,20 +95,11 @@ public: ...@@ -77,20 +95,11 @@ public:
*/ */
SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_Parent; } SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_Parent; }
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Draw( WinEDA_DrawPanel* panel, /*the functions Draw, CreateGraphicShape and Plot are no removed as
wxDC* DC, * as this shape is already handled as HIERLABEL ...
const wxPoint& offset, */
int draw_mode,
int Color = -1 );
/**
* Plot this sheet pin object to aPlotter.
*
* @param aPlotter - The plotter object to plot to.
*/
void Plot( PLOTTER* aPlotter );
/** /**
* Function Save * Function Save
...@@ -118,8 +127,6 @@ public: ...@@ -118,8 +127,6 @@ public:
* @param aCorner_list = list to fill with polygon corners coordinates * @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape * @param Pos = Position of the shape
*/ */
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos );
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
...@@ -137,13 +144,11 @@ public: ...@@ -137,13 +144,11 @@ public:
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y( int aYaxis_position )
{ virtual void Mirror_Y( int aYaxis_position );
m_Edge = m_Edge ? 0 : 1; virtual void Rotate( wxPoint rotationPoint );
m_Pos.x -= aYaxis_position; virtual void Mirror_X( int aXaxis_position );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
/** /**
* Compare schematic sheet entry (pin?) name against search string. * Compare schematic sheet entry (pin?) name against search string.
...@@ -155,7 +160,7 @@ public: ...@@ -155,7 +160,7 @@ public:
}; };
typedef boost::ptr_vector< SCH_SHEET_PIN > SCH_SHEET_PIN_LIST; typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PIN_LIST;
/* class SCH_SHEET /* class SCH_SHEET
...@@ -209,11 +214,16 @@ public: ...@@ -209,11 +214,16 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
SCH_SHEET* GenCopy(); SCH_SHEET* GenCopy();
void DisplayInfo( WinEDA_DrawFrame* frame ); void DisplayInfo( WinEDA_DrawFrame* frame );
/* there is no member for orientation in sch_sheet, to preserve file
* format, we detect orientation based on pin edges
*/
bool IsVerticalOrientation();
/** /**
* Add aLabel to this sheet. * Add aLabel to this sheet.
...@@ -224,7 +234,7 @@ public: ...@@ -224,7 +234,7 @@ public:
* *
* @param aLabel - The label to add to the sheet. * @param aLabel - The label to add to the sheet.
*/ */
void AddLabel( SCH_SHEET_PIN* aLabel ); void AddLabel( SCH_SHEET_PIN* aLabel );
SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; } SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; }
...@@ -233,7 +243,7 @@ public: ...@@ -233,7 +243,7 @@ public:
* *
* @param aSheetLabel - The sheet label to remove from the list. * @param aSheetLabel - The sheet label to remove from the list.
*/ */
void RemoveLabel( SCH_SHEET_PIN* aSheetLabel ); void RemoveLabel( SCH_SHEET_PIN* aSheetLabel );
/** /**
* Delete sheet label which do not have a corresponding hierarchical label. * Delete sheet label which do not have a corresponding hierarchical label.
...@@ -241,7 +251,7 @@ public: ...@@ -241,7 +251,7 @@ public:
* Note: Make sure you save a copy of the sheet in the undo list before calling * Note: Make sure you save a copy of the sheet in the undo list before calling
* CleanupSheet() otherwise any unrefernced sheet labels will be lost. * CleanupSheet() otherwise any unrefernced sheet labels will be lost.
*/ */
void CleanupSheet(); void CleanupSheet();
/** /**
* Return the label found at aPosition in this sheet. * Return the label found at aPosition in this sheet.
...@@ -259,7 +269,7 @@ public: ...@@ -259,7 +269,7 @@ public:
* *
* @return - True if label found, otherwise false. * @return - True if label found, otherwise false.
*/ */
bool HasLabel( const wxString& aName ); bool HasLabel( const wxString& aName );
bool HasLabels() { return !m_labels.empty(); } bool HasLabels() { return !m_labels.empty(); }
...@@ -268,12 +278,12 @@ public: ...@@ -268,12 +278,12 @@ public:
* *
* @return True if there are any undefined labels. * @return True if there are any undefined labels.
*/ */
bool HasUndefinedLabels(); bool HasUndefinedLabels();
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize(); virtual int GetPenSize();
/** Function Draw /** Function Draw
* Draw the hierarchical sheet shape * Draw the hierarchical sheet shape
...@@ -284,11 +294,11 @@ public: ...@@ -284,11 +294,11 @@ public:
* @param aColor = color used to draw sheet. Usually -1 to use the normal * @param aColor = color used to draw sheet. Usually -1 to use the normal
* color for sheet items * color for sheet items
*/ */
void Draw( WinEDA_DrawPanel* aPanel, void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC, wxDC* aDC,
const wxPoint& aOffset, const wxPoint& aOffset,
int aDrawMode, int aDrawMode,
int aColor = -1 ); int aColor = -1 );
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
...@@ -389,8 +399,7 @@ public: ...@@ -389,8 +399,7 @@ public:
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels ) {
{
label.Move( aMoveVector ); label.Move( aMoveVector );
} }
} }
...@@ -401,6 +410,8 @@ public: ...@@ -401,6 +410,8 @@ public:
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
/** /**
* Compare schematic sheet file and sheet name against search string. * Compare schematic sheet file and sheet name against search string.
...@@ -416,7 +427,7 @@ public: ...@@ -416,7 +427,7 @@ public:
* *
* @param aSize - The new size for this sheet. * @param aSize - The new size for this sheet.
*/ */
void Resize( const wxSize& aSize ); void Resize( const wxSize& aSize );
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -17,20 +17,33 @@ ...@@ -17,20 +17,33 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "plot_common.h" #include "plot_common.h"
#include "trigo.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
/* m_Edge define on which edge the pin is positionned:
*
* 0: pin on left side
* 1: pin on right side
* 2: pin on top side
* 3: pin on bottom side
* for compatibility reasons, this does not follow same values as text
* ortientation.
*/
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) : SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ), EDA_TextStruct( text ) SCH_HIERLABEL( pos, text, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{ {
SetParent( parent );
wxASSERT( parent ); wxASSERT( parent );
wxASSERT( Pnext == NULL );
m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL;
m_Pos = pos; m_Pos = pos;
m_Edge = 0; if( parent->IsVerticalOrientation() )
SetEdge( 2 );
else
SetEdge( 0 );
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = TRUE;
m_Number = 2; m_Number = 2;
...@@ -41,15 +54,27 @@ SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy() ...@@ -41,15 +54,27 @@ SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy()
{ {
SCH_SHEET_PIN* newitem = new SCH_SHEET_PIN( (SCH_SHEET*) m_Parent, m_Pos, m_Text ); SCH_SHEET_PIN* newitem = new SCH_SHEET_PIN( (SCH_SHEET*) m_Parent, m_Pos, m_Text );
newitem->m_Edge = m_Edge; newitem->SetEdge( GetEdge() );
newitem->m_Shape = m_Shape; newitem->m_Shape = m_Shape;
newitem->m_Number = m_Number; newitem->SetNumber( GetNumber() );
return newitem; return newitem;
} }
bool SCH_SHEET_PIN::operator==(const SCH_SHEET_PIN* aPin ) const void SCH_SHEET_PIN::SwapData( SCH_SHEET_PIN* copyitem )
{
SCH_TEXT::SwapData( (SCH_TEXT*) copyitem );
int tmp;
tmp = copyitem->GetNumber();
copyitem->SetNumber( GetNumber() );
SetNumber( tmp );
tmp = copyitem->GetEdge();
copyitem->SetEdge( GetEdge() );
SetEdge( tmp );
}
bool SCH_SHEET_PIN::operator==( const SCH_SHEET_PIN* aPin ) const
{ {
return aPin == this; return aPin == this;
} }
...@@ -72,153 +97,88 @@ void SCH_SHEET_PIN::SetNumber( int aNumber ) ...@@ -72,153 +97,88 @@ void SCH_SHEET_PIN::SetNumber( int aNumber )
} }
/*****************************************************************************/ void SCH_SHEET_PIN::SetEdge( int aEdge )
/* Routine to create hierarchical labels */
/*****************************************************************************/
void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int DrawMode,
int Color )
{ {
GRTextHorizJustifyType side; SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
EDA_Colors txtcolor;
int posx, tposx, posy;
static std::vector <wxPoint> Poly; /* use -1 to adjust text orientation without changing edge*/
if( aEdge > -1 )
int LineWidth = GetPenSize(); m_Edge = aEdge;
switch( m_Edge )
{
case 0: /* pin on left side*/
m_Pos.x = Sheet->m_Pos.x;
SetSchematicTextOrientation( 2 ); /* Orientation horiz inverse */
break;
if( Color >= 0 ) case 1: /* pin on right side*/
txtcolor = (EDA_Colors) Color; m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
else SetSchematicTextOrientation( 0 ); /* Orientation horiz normal */
txtcolor = ReturnLayerColor( m_Layer ); break;
GRSetDrawMode( DC, DrawMode );
posx = m_Pos.x + offset.x; case 2: /* pin on top side*/
posy = m_Pos.y + offset.y; m_Pos.y = Sheet->m_Pos.y;
wxSize size = m_Size; SetSchematicTextOrientation( 3 ); /* Orientation vert BOTTOM */
break;
if( !m_Text.IsEmpty() ) case 3: /* pin on bottom side*/
{ m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
if( m_Edge ) SetSchematicTextOrientation( 1 ); /* Orientation vert UP */
{ break;
tposx = posx - size.x;
side = GR_TEXT_HJUSTIFY_RIGHT;
}
else
{
tposx = posx + size.x + (size.x / 8);
side = GR_TEXT_HJUSTIFY_LEFT;
}
DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor,
m_Text, TEXT_ORIENT_HORIZ, size, side,
GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, false );
} }
/* Draw the graphic symbol */
CreateGraphicShape( Poly, m_Pos + offset );
int FillShape = false;
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0],
FillShape, LineWidth, txtcolor, txtcolor );
} }
void SCH_SHEET_PIN::Plot( PLOTTER* aPlotter ) int SCH_SHEET_PIN::GetEdge()
{ {
wxASSERT( aPlotter != NULL ); return m_Edge;
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
int posx, tposx, posy, size;
static std::vector <wxPoint> Poly;
txtcolor = ReturnLayerColor( GetLayer() );
posx = m_Pos.x;
posy = m_Pos.y;
size = m_Size.x;
GRTextHorizJustifyType side;
if( m_Edge )
{
tposx = posx - size;
side = GR_TEXT_HJUSTIFY_RIGHT;
}
else
{
tposx = posx + size + (size / 8);
side = GR_TEXT_HJUSTIFY_LEFT;
}
int thickness = GetPenSize();
aPlotter->set_current_line_width( thickness );
aPlotter->text( wxPoint( tposx, posy ), txtcolor, m_Text, TEXT_ORIENT_HORIZ,
wxSize( size, size ), side, GR_TEXT_VJUSTIFY_CENTER, thickness,
m_Italic, m_Bold );
/* Draw the associated graphic symbol */
CreateGraphicShape( Poly, m_Pos );
aPlotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
} }
/** function CreateGraphicShape /* ConstraintOnEdge is used to ajust label position to egde based
* Calculates the graphic shape (a polygon) associated to the text * on proximity to vertical / horizontal edge.
* @param aCorner_list = list to fill with polygon corners coordinates * used by sheetlab and resize
* @param Pos = Position of the shape
*/ */
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos )
const wxPoint& Pos )
{ {
wxSize size = m_Size; SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
aCorner_list.clear();
if( m_Edge )
{
size.x = -size.x;
size.y = -size.y;
}
int size2 = size.x / 2; if( Sheet == NULL )
return;
aCorner_list.push_back( Pos ); if( m_Edge<2 ) /*horizontal sheetpin*/
switch( m_Shape )
{ {
case 0: /* input |> */ if( Pos.x > ( Sheet->m_Pos.x + ( Sheet->m_Size.x / 2 ) ) )
aCorner_list.push_back( wxPoint( Pos.x, Pos.y - size2 ) ); {
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y - size2 ) ); SetEdge( 1 );
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y ) ); }
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y + size2 ) ); else
aCorner_list.push_back( wxPoint( Pos.x, Pos.y + size2 ) ); {
aCorner_list.push_back( Pos ); SetEdge( 0 );
break; }
case 1: /* output <| */
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y - size2 ) );
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y - size2 ) );
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y + size2 ) );
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y + size2 ) );
aCorner_list.push_back( Pos );
break;
case 2: /* bidi <> */ m_Pos.y = Pos.y;
case 3: /* TriSt <> */ if( m_Pos.y < Sheet->m_Pos.y )
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y - size2 ) ); m_Pos.y = Sheet->m_Pos.y;
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y ) ); if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y + size2 ) ); m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
aCorner_list.push_back( Pos ); }
break; else /* vertical sheetpin*/
{
if( Pos.y > ( Sheet->m_Pos.y + ( Sheet->m_Size.y / 2 ) ) )
{
SetEdge( 3 ); //bottom
}
else
{
SetEdge( 2 ); //top
}
default: /* unsp []*/ m_Pos.x = Pos.x;
aCorner_list.push_back( wxPoint( Pos.x, Pos.y - size2 ) ); if( m_Pos.x < Sheet->m_Pos.x )
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y - size2 ) ); m_Pos.x = Sheet->m_Pos.x;
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y + size2 ) ); if( m_Pos.x > (Sheet->m_Pos.x + Sheet->m_Size.x) )
aCorner_list.push_back( wxPoint( Pos.x, Pos.y + size2 ) ); m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
aCorner_list.push_back( Pos );
break;
} }
} }
...@@ -235,8 +195,24 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const ...@@ -235,8 +195,24 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const
if( m_Text.IsEmpty() ) if( m_Text.IsEmpty() )
return true; return true;
if( m_Edge ) switch( m_Edge )
{
case 0: //pin on left side
side = 'L';
break;
case 1: //pin on right side
side = 'R'; side = 'R';
break;
case 2: //pin on top side
side = 'T';
break;
case 3: //pin on bottom side
side = 'B';
break;
}
switch( m_Shape ) switch( m_Shape )
{ {
...@@ -273,6 +249,66 @@ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData ) ...@@ -273,6 +249,66 @@ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData )
} }
void SCH_SHEET_PIN::Mirror_X( int aXaxis_position )
{
int p = m_Pos.y - aXaxis_position;
m_Pos.y = aXaxis_position - p;
switch( m_Edge )
{
case 2:
SetEdge( 3 );
break;
case 3:
SetEdge( 2 );
break;
}
}
void SCH_SHEET_PIN::Mirror_Y( int aYaxis_position )
{
int p = m_Pos.x - aYaxis_position;
m_Pos.x = aYaxis_position - p;
switch( m_Edge )
{
case 0:
SetEdge( 1 );
break;
case 1:
SetEdge( 0 );
break;
}
}
void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
switch( m_Edge )
{
case 0: //pin on left side
SetEdge( 3 );
break;
case 1: //pin on right side
SetEdge( 2 );
break;
case 2: //pin on top side
SetEdge( 0 );
break;
case 3: //pin on bottom side
SetEdge( 1 );
break;
}
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os )
{ {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "trigo.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "erc.h" #include "erc.h"
...@@ -51,7 +52,7 @@ SCH_MARKER::~SCH_MARKER() ...@@ -51,7 +52,7 @@ SCH_MARKER::~SCH_MARKER()
SCH_MARKER* SCH_MARKER::GenCopy() SCH_MARKER* SCH_MARKER::GenCopy()
{ {
SCH_MARKER* newitem = new SCH_MARKER( GetPos(), SCH_MARKER* newitem = new SCH_MARKER( GetPos(),
GetReporter().GetMainText() ); GetReporter().GetMainText() );
newitem->SetMarkerType( GetMarkerType() ); newitem->SetMarkerType( GetMarkerType() );
newitem->SetErrorLevel( GetErrorLevel() ); newitem->SetErrorLevel( GetErrorLevel() );
...@@ -147,3 +148,25 @@ void SCH_MARKER::DisplayInfo( WinEDA_DrawFrame* aFrame ) ...@@ -147,3 +148,25 @@ void SCH_MARKER::DisplayInfo( WinEDA_DrawFrame* aFrame )
aFrame->AppendMsgPanel( _( "Electronics rule check error" ), aFrame->AppendMsgPanel( _( "Electronics rule check error" ),
GetReporter().GetErrorText(), DARKRED ); GetReporter().GetErrorText(), DARKRED );
} }
void SCH_MARKER::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}
void SCH_MARKER::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
m_Pos.y = -m_Pos.y;
m_Pos.y += aXaxis_position;
}
void SCH_MARKER::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
m_Pos.x = -m_Pos.x;
m_Pos.x += aYaxis_position;
}
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
#include "class_marker_base.h" #include "class_marker_base.h"
/* Marker are mainly used to show an ERC error /* Marker are mainly used to show an ERC error
*/ */
enum TypeMarker { /* Markers type */ enum TypeMarker {
/* Markers type */
MARK_UNSPEC, MARK_UNSPEC,
MARK_ERC, MARK_ERC,
MARK_PCB, MARK_PCB,
...@@ -24,10 +25,10 @@ enum TypeMarker { /* Markers type */ ...@@ -24,10 +25,10 @@ enum TypeMarker { /* Markers type */
extern const wxChar* NameMarqueurType[]; extern const wxChar* NameMarqueurType[];
class SCH_MARKER : public SCH_ITEM , public MARKER_BASE class SCH_MARKER : public SCH_ITEM, public MARKER_BASE
{ {
public: public:
SCH_MARKER( ); SCH_MARKER();
SCH_MARKER( const wxPoint& aPos, const wxString& aText ); SCH_MARKER( const wxPoint& aPos, const wxString& aText );
~SCH_MARKER(); ~SCH_MARKER();
virtual wxString GetClass() const virtual wxString GetClass() const
...@@ -36,11 +37,11 @@ public: ...@@ -36,11 +37,11 @@ public:
} }
SCH_MARKER* GenCopy(); SCH_MARKER* GenCopy();
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aDraw_mode, const wxPoint& aOffset, int aDraw_mode,
int aColor = -1 ); int aColor = -1 );
/** /**
...@@ -50,14 +51,14 @@ public: ...@@ -50,14 +51,14 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
* for a marker, has no meaning, but it is necessary to satisfy the * for a marker, has no meaning, but it is necessary to satisfy the
* SCH_ITEM class requirements * SCH_ITEM class requirements
*/ */
virtual int GetPenSize( ) { return 0; }; virtual int GetPenSize() { return 0; };
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
...@@ -68,6 +69,7 @@ public: ...@@ -68,6 +69,7 @@ public:
return HitTestMarker( aPosRef ); return HitTestMarker( aPosRef );
} }
/** /**
* Function GetBoundingBox * Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes. * returns the orthogonal, bounding box of this object for display purposes.
...@@ -79,25 +81,24 @@ public: ...@@ -79,25 +81,24 @@ public:
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_Y( int aYaxis_position );
{ virtual void Rotate( wxPoint rotationPoint );
m_Pos.x -= aYaxis_position; virtual void Mirror_X( int aXaxis_position );
m_Pos.x = - m_Pos.x;
m_Pos.x += aYaxis_position;
}
/** /**
* Compare DRC marker main and auxiliary text against search string. * Compare DRC marker main and auxiliary text against search string.
...@@ -112,10 +113,11 @@ public: ...@@ -112,10 +113,11 @@ public:
* *
* @param aFrame - Top window that owns the message panel. * @param aFrame - Top window that owns the message panel.
*/ */
void DisplayInfo( WinEDA_DrawFrame* aFrame ); void DisplayInfo( WinEDA_DrawFrame* aFrame );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "macros.h" #include "macros.h"
#include "trigo.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
...@@ -115,10 +116,10 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -115,10 +116,10 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
* justifications are complicated to calculate * justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text ) * so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered * and use GetBoundaryBox to know the text coordinate considered as centered
*/ */
EDA_Rect BoundaryBox = GetBoundaryBox(); EDA_Rect BoundaryBox = GetBoundaryBox();
GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER;
textpos = BoundaryBox.Centre(); textpos = BoundaryBox.Centre();
if( m_FieldId == REFERENCE ) if( m_FieldId == REFERENCE )
...@@ -151,15 +152,18 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -151,15 +152,18 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/* Enable this to draw the bounding box around the text field to validate /* Enable this to draw the bounding box around the text field to validate
* the bounding box calculations. * the bounding box calculations.
*/ */
#if 0 #if 0
// Draw boundary box: // Draw boundary box:
int x1 = BoundaryBox.GetX(); int x1 = BoundaryBox.GetX();
int y1 = BoundaryBox.GetY(); int y1 = BoundaryBox.GetY();
int x2 = BoundaryBox.GetRight(); int x2 = BoundaryBox.GetRight();
int y2 = BoundaryBox.GetBottom(); int y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN ); GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
// Draw the text anchor point // Draw the text anchor point
/* Calculate the text position, according to the component /* Calculate the text position, according to the component
* orientation/mirror */ * orientation/mirror */
textpos = m_Pos - parentComponent->m_Pos; textpos = m_Pos - parentComponent->m_Pos;
...@@ -169,7 +173,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -169,7 +173,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
y1 = textpos.y; y1 = textpos.y;
int len = 10; int len = 10;
GRLine( &panel->m_ClipBox, DC, x1 - len, y1, x1 + len, y1, 0, BLUE ); GRLine( &panel->m_ClipBox, DC, x1 - len, y1, x1 + len, y1, 0, BLUE );
GRLine( &panel->m_ClipBox, DC, x1, y1 - len, x1, y1 +len, 0, BLUE ); GRLine( &panel->m_ClipBox, DC, x1, y1 - len, x1, y1 + len, 0, BLUE );
#endif #endif
} }
...@@ -224,20 +228,20 @@ void SCH_FIELD::SwapData( SCH_FIELD* copyitem ) ...@@ -224,20 +228,20 @@ void SCH_FIELD::SwapData( SCH_FIELD* copyitem )
*/ */
EDA_Rect SCH_FIELD::GetBoundaryBox() const EDA_Rect SCH_FIELD::GetBoundaryBox() const
{ {
EDA_Rect BoundaryBox; EDA_Rect BoundaryBox;
int hjustify, vjustify; int hjustify, vjustify;
int orient; int orient;
wxSize size; wxSize size;
wxPoint pos1, pos2; wxPoint pos1, pos2;
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
orient = m_Orient; orient = m_Orient;
wxPoint pos = parentComponent->m_Pos; wxPoint pos = parentComponent->m_Pos;
pos1 = m_Pos - pos; pos1 = m_Pos - pos;
size.x = LenSize( m_Text ); size.x = LenSize( m_Text );
size.y = m_Size.y; size.y = m_Size.y;
hjustify = m_HJustify; hjustify = m_HJustify;
vjustify = m_VJustify; vjustify = m_VJustify;
...@@ -396,18 +400,18 @@ void SCH_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -396,18 +400,18 @@ void SCH_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
m_Flags = 0; m_Flags = 0;
frame->GetScreen()->SetCurItem( NULL ); frame->GetScreen()->SetCurItem( NULL );
frame->OnModify( ); frame->OnModify();
frame->SetCurrentField( NULL ); frame->SetCurrentField( NULL );
} }
bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void * aAuxData ) bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
{ {
if( aAuxData && m_FieldId == REFERENCE ) if( aAuxData && m_FieldId == REFERENCE )
{ {
SCH_COMPONENT* pSch = (SCH_COMPONENT*) m_Parent; SCH_COMPONENT* pSch = (SCH_COMPONENT*) m_Parent;
SCH_SHEET_PATH* sheet = (SCH_SHEET_PATH*) aAuxData; SCH_SHEET_PATH* sheet = (SCH_SHEET_PATH*) aAuxData;
wxString fulltext = pSch->GetRef( sheet ); wxString fulltext = pSch->GetRef( sheet );
if( m_AddExtraText ) if( m_AddExtraText )
{ {
/* For more than one part per package, we must add the part selection /* For more than one part per package, we must add the part selection
...@@ -420,3 +424,9 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void * aAuxData ) ...@@ -420,3 +424,9 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
return SCH_ITEM::Matches( m_Text, aSearchData ); return SCH_ITEM::Matches( m_Text, aSearchData );
} }
void SCH_FIELD::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
* (for REFERENCE: add part selection text */ * (for REFERENCE: add part selection text */
public: public:
SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
wxString aName = wxEmptyString ); wxString aName = wxEmptyString );
~SCH_FIELD(); ~SCH_FIELD();
...@@ -47,6 +47,7 @@ public: ...@@ -47,6 +47,7 @@ public:
return wxT( "SCH_FIELD" ); return wxT( "SCH_FIELD" );
} }
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
EDA_Rect GetBoundaryBox() const; EDA_Rect GetBoundaryBox() const;
...@@ -58,22 +59,24 @@ public: ...@@ -58,22 +59,24 @@ public:
bool IsVoid() bool IsVoid()
{ {
size_t len = m_Text.Len(); size_t len = m_Text.Len();
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) ); return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
} }
void SwapData( SCH_FIELD* copyitem );
void SwapData( SCH_FIELD* copyitem );
/** Function ImportValues /** Function ImportValues
* copy parameters from a source. * copy parameters from a source.
* Pointers and specific values (position) are not copied * Pointers and specific values (position) are not copied
* @param aSource = the LIB_FIELD to read * @param aSource = the LIB_FIELD to read
*/ */
void ImportValues( const LIB_FIELD& aSource ); void ImportValues( const LIB_FIELD& aSource );
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
int GetPenSize( ); int GetPenSize();
/** Function IsVisible /** Function IsVisible
* @return true is this field is visible, false if flagged invisible * @return true is this field is visible, false if flagged invisible
...@@ -83,14 +86,15 @@ public: ...@@ -83,14 +86,15 @@ public:
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false; return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
} }
/** /**
* Function Draw * Function Draw
*/ */
void Draw( WinEDA_DrawPanel* panel, void Draw( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
const wxPoint& offset, const wxPoint& offset,
int draw_mode, int draw_mode,
int Color = -1 ); int Color = -1 );
/** /**
* Function Save * Function Save
...@@ -102,20 +106,33 @@ public: ...@@ -102,20 +106,33 @@ public:
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
} }
virtual void Rotate( wxPoint rotationPoint );
virtual void Mirror_X( int aXaxis_position )
{
/* Do Nothing: fields are never mirrored alone.
* they are moved when the parent component is mirrored
* this function is only needed by the virtual pure function of the
* master class */
}
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_Y( int aYaxis_position )
{ {
/* Do Nothing: fields are never mirrored alone. /* Do Nothing: fields are never mirrored alone.
* they are moved when the parent component is mirrored * they are moved when the parent component is mirrored
...@@ -123,6 +140,7 @@ public: ...@@ -123,6 +140,7 @@ public:
* master class */ * master class */
} }
/** /**
* Compare schematic field text against search string. * Compare schematic field text against search string.
* *
...@@ -133,7 +151,7 @@ public: ...@@ -133,7 +151,7 @@ public:
* this is only one of all references (one per sheet path) * this is only one of all references (one per sheet path)
* @return True if this field text matches the search criteria. * @return True if this field text matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData ); virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData );
}; };
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "trigo.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
...@@ -37,12 +38,12 @@ void CreateDummyCmp() ...@@ -37,12 +38,12 @@ void CreateDummyCmp()
{ {
DummyCmp = new LIB_COMPONENT( wxEmptyString ); DummyCmp = new LIB_COMPONENT( wxEmptyString );
LIB_RECTANGLE* Square = new LIB_RECTANGLE(DummyCmp); LIB_RECTANGLE* Square = new LIB_RECTANGLE( DummyCmp );
Square->m_Pos = wxPoint( -200, 200 ); Square->m_Pos = wxPoint( -200, 200 );
Square->m_End = wxPoint( 200, -200 ); Square->m_End = wxPoint( 200, -200 );
LIB_TEXT* Text = new LIB_TEXT(DummyCmp); LIB_TEXT* Text = new LIB_TEXT( DummyCmp );
Text->m_Size.x = Text->m_Size.y = 150; Text->m_Size.x = Text->m_Size.y = 150;
Text->m_Text = wxT( "??" ); Text->m_Text = wxT( "??" );
...@@ -134,7 +135,7 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : ...@@ -134,7 +135,7 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
m_Son = NULL; m_Son = NULL;
// Re-parent the fields, which before this had aTemplate as parent // Re-parent the fields, which before this had aTemplate as parent
for( int i=0; i<GetFieldCount(); ++i ) for( int i = 0; i<GetFieldCount(); ++i )
{ {
GetField( i )->SetParent( this ); GetField( i )->SetParent( this );
} }
...@@ -143,8 +144,8 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : ...@@ -143,8 +144,8 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
void SCH_COMPONENT::Init( const wxPoint& pos ) void SCH_COMPONENT::Init( const wxPoint& pos )
{ {
m_Pos = pos; m_Pos = pos;
m_Multi = 0; // In multi unit chip - which unit to draw. m_Multi = 0; // In multi unit chip - which unit to draw.
m_Convert = 0; // De Morgan Handling m_Convert = 0; // De Morgan Handling
// The rotation/mirror transformation matrix. pos normal // The rotation/mirror transformation matrix. pos normal
...@@ -182,8 +183,8 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -182,8 +183,8 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
bool DrawPinText ) bool DrawPinText )
{ {
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
int ii; int ii;
bool dummy = FALSE; bool dummy = FALSE;
Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
...@@ -329,7 +330,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet ) ...@@ -329,7 +330,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet )
h_ref = tokenizer.GetNextToken(); h_ref = tokenizer.GetNextToken();
/* printf( "GetRef hpath: %s\n", /* printf( "GetRef hpath: %s\n",
CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */ * CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */
return h_ref; return h_ref;
} }
} }
...@@ -382,8 +383,8 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ) ...@@ -382,8 +383,8 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
SCH_FIELD* rf = GetField( REFERENCE ); SCH_FIELD* rf = GetField( REFERENCE );
if( rf->m_Text.IsEmpty() if( rf->m_Text.IsEmpty()
|| ( abs( rf->m_Pos.x - m_Pos.x ) + || ( abs( rf->m_Pos.x - m_Pos.x ) +
abs( rf->m_Pos.y - m_Pos.y ) > 10000 ) ) abs( rf->m_Pos.y - m_Pos.y ) > 10000 ) )
{ {
// move it to a reasonable position // move it to a reasonable position
rf->m_Pos = m_Pos; rf->m_Pos = m_Pos;
...@@ -395,32 +396,36 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ) ...@@ -395,32 +396,36 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
// Reinit the m_PrefixString member if needed // Reinit the m_PrefixString member if needed
wxString prefix = ref; wxString prefix = ref;
while( prefix.Last() == '?' or isdigit(prefix.Last()) ) while( prefix.Last() == '?' or isdigit( prefix.Last() ) )
prefix.RemoveLast(); prefix.RemoveLast();
if( m_PrefixString != prefix ) if( m_PrefixString != prefix )
m_PrefixString = prefix; m_PrefixString = prefix;
} }
/** function SetTimeStamp /** function SetTimeStamp
* Change the old time stamp to the new time stamp. * Change the old time stamp to the new time stamp.
* the time stamp is also modified in paths * the time stamp is also modified in paths
* @param aNewTimeStamp = new time stamp * @param aNewTimeStamp = new time stamp
*/ */
void SCH_COMPONENT::SetTimeStamp( long aNewTimeStamp) void SCH_COMPONENT::SetTimeStamp( long aNewTimeStamp )
{ {
wxString string_timestamp, string_oldtimestamp; wxString string_timestamp, string_oldtimestamp;
string_timestamp.Printf(wxT("%8.8X"), aNewTimeStamp);
string_oldtimestamp.Printf(wxT("%8.8X"), m_TimeStamp); string_timestamp.Printf( wxT( "%8.8X" ), aNewTimeStamp );
string_oldtimestamp.Printf( wxT( "%8.8X" ), m_TimeStamp );
m_TimeStamp = aNewTimeStamp; m_TimeStamp = aNewTimeStamp;
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ ) for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
{ {
m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(), m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(),
string_timestamp.GetData() ); string_timestamp.GetData() );
} }
} }
/***********************************************************/ /***********************************************************/
//returns the unit selection, for the given sheet path. //returns the unit selection, for the given sheet path.
/***********************************************************/ /***********************************************************/
int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet ) int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
...@@ -452,6 +457,7 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet ) ...@@ -452,6 +457,7 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
/****************************************************************************/ /****************************************************************************/
//Set the unit selection, for the given sheet path. //Set the unit selection, for the given sheet path.
/****************************************************************************/ /****************************************************************************/
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet,
...@@ -508,6 +514,7 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const ...@@ -508,6 +514,7 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField ) SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField )
{ {
int newNdx = m_Fields.size(); int newNdx = m_Fields.size();
m_Fields.push_back( aField ); m_Fields.push_back( aField );
return &m_Fields[newNdx]; return &m_Fields[newNdx];
} }
...@@ -515,11 +522,12 @@ SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField ) ...@@ -515,11 +522,12 @@ SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField )
SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName ) SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
{ {
for( unsigned i=0; i<m_Fields.size(); ++i ) for( unsigned i = 0; i<m_Fields.size(); ++i )
{ {
if( aFieldName == m_Fields[i].m_Name ) if( aFieldName == m_Fields[i].m_Name )
return &m_Fields[i]; return &m_Fields[i];
} }
return NULL; return NULL;
} }
...@@ -536,6 +544,7 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) ...@@ -536,6 +544,7 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
return Entry->GetPin( number, m_Multi, m_Convert ); return Entry->GetPin( number, m_Multi, m_Convert );
} }
/** /**
* Function GetBoundaryBox * Function GetBoundaryBox
* returns the orthogonal, bounding box of this object for display purposes. * returns the orthogonal, bounding box of this object for display purposes.
...@@ -546,8 +555,8 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) ...@@ -546,8 +555,8 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
{ {
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
EDA_Rect BoundaryBox; EDA_Rect BoundaryBox;
int x0, xm, y0, ym; int x0, xm, y0, ym;
/* Get the basic Boundary box */ /* Get the basic Boundary box */
if( Entry ) if( Entry )
...@@ -569,10 +578,10 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const ...@@ -569,10 +578,10 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
} }
/* Compute the real Boundary box (rotated, mirrored ...)*/ /* Compute the real Boundary box (rotated, mirrored ...)*/
int x1 = m_Transform[0][0] * x0 + m_Transform[0][1] * y0; int x1 = m_Transform[0][0] *x0 + m_Transform[0][1] *y0;
int y1 = m_Transform[1][0] * x0 + m_Transform[1][1] * y0; int y1 = m_Transform[1][0] *x0 + m_Transform[1][1] *y0;
int x2 = m_Transform[0][0] * xm + m_Transform[0][1] * ym; int x2 = m_Transform[0][0] *xm + m_Transform[0][1] *ym;
int y2 = m_Transform[1][0] * xm + m_Transform[1][1] * ym; int y2 = m_Transform[1][0] *xm + m_Transform[1][1] *ym;
// H and W must be > 0: // H and W must be > 0:
if( x2 < x1 ) if( x2 < x1 )
...@@ -610,14 +619,15 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem ) ...@@ -610,14 +619,15 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
// (after swap(), m_Parent member does not point to the right parent): // (after swap(), m_Parent member does not point to the right parent):
for( int ii = 0; ii < copyitem->GetFieldCount(); ++ii ) for( int ii = 0; ii < copyitem->GetFieldCount(); ++ii )
{ {
copyitem->GetField(ii)->SetParent( copyitem ); copyitem->GetField( ii )->SetParent( copyitem );
} }
for( int ii = 0; ii < GetFieldCount(); ++ii ) for( int ii = 0; ii < GetFieldCount(); ++ii )
{ {
GetField(ii)->SetParent( this ); GetField( ii )->SetParent( this );
} }
EXCHG( m_PathsAndReferences, copyitem->m_PathsAndReferences); EXCHG( m_PathsAndReferences, copyitem->m_PathsAndReferences );
} }
...@@ -625,8 +635,8 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -625,8 +635,8 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{ {
/* save old text in undo list */ /* save old text in undo list */
if( g_ItemToUndoCopy if( g_ItemToUndoCopy
&& ( g_ItemToUndoCopy->Type() == Type() ) && ( g_ItemToUndoCopy->Type() == Type() )
&& ( ( m_Flags & IS_NEW ) == 0 ) ) && ( ( m_Flags & IS_NEW ) == 0 ) )
{ {
/* restore old values and save new ones */ /* restore old values and save new ones */
SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy ); SwapData( (SCH_COMPONENT*) g_ItemToUndoCopy );
...@@ -709,6 +719,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet ) ...@@ -709,6 +719,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet )
/******************************************************************/ /******************************************************************/
/* Compute the new matrix transform for a schematic component /* Compute the new matrix transform for a schematic component
* in order to have the requested transform (type_rotate = rot, mirror..) * in order to have the requested transform (type_rotate = rot, mirror..)
* which is applied to the initial transform. * which is applied to the initial transform.
...@@ -732,28 +743,28 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) ...@@ -732,28 +743,28 @@ void SCH_COMPONENT::SetOrientation( int aOrientation )
TempMat[0][0] = TempMat[1][1] = 0; TempMat[0][0] = TempMat[1][1] = 0;
TempMat[0][1] = 1; TempMat[0][1] = 1;
TempMat[1][0] = -1; TempMat[1][0] = -1;
Transform = TRUE; Transform = TRUE;
break; break;
case CMP_ROTATE_COUNTERCLOCKWISE: /* Rotate - */ case CMP_ROTATE_COUNTERCLOCKWISE: /* Rotate - */
TempMat[0][0] = TempMat[1][1] = 0; TempMat[0][0] = TempMat[1][1] = 0;
TempMat[0][1] = -1; TempMat[0][1] = -1;
TempMat[1][0] = 1; TempMat[1][0] = 1;
Transform = TRUE; Transform = TRUE;
break; break;
case CMP_MIRROR_Y: /* MirrorY */ case CMP_MIRROR_Y: /* MirrorY */
TempMat[0][0] = -1; TempMat[0][0] = -1;
TempMat[1][1] = 1; TempMat[1][1] = 1;
TempMat[0][1] = TempMat[1][0] = 0; TempMat[0][1] = TempMat[1][0] = 0;
Transform = TRUE; Transform = TRUE;
break; break;
case CMP_MIRROR_X: /* MirrorX */ case CMP_MIRROR_X: /* MirrorX */
TempMat[0][0] = 1; TempMat[0][0] = 1;
TempMat[1][1] = -1; TempMat[1][1] = -1;
TempMat[0][1] = TempMat[1][0] = 0; TempMat[0][1] = TempMat[1][0] = 0;
Transform = TRUE; Transform = TRUE;
break; break;
case CMP_ORIENT_90: case CMP_ORIENT_90:
...@@ -832,17 +843,17 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) ...@@ -832,17 +843,17 @@ void SCH_COMPONENT::SetOrientation( int aOrientation )
*/ */
int NewMatrix[2][2]; int NewMatrix[2][2];
NewMatrix[0][0] = m_Transform[0][0] * TempMat[0][0] + NewMatrix[0][0] = m_Transform[0][0] *TempMat[0][0] +
m_Transform[1][0] * TempMat[0][1]; m_Transform[1][0] *TempMat[0][1];
NewMatrix[0][1] = m_Transform[0][1] * TempMat[0][0] + NewMatrix[0][1] = m_Transform[0][1] *TempMat[0][0] +
m_Transform[1][1] * TempMat[0][1]; m_Transform[1][1] *TempMat[0][1];
NewMatrix[1][0] = m_Transform[0][0] * TempMat[1][0] + NewMatrix[1][0] = m_Transform[0][0] *TempMat[1][0] +
m_Transform[1][0] * TempMat[1][1]; m_Transform[1][0] *TempMat[1][1];
NewMatrix[1][1] = m_Transform[0][1] * TempMat[1][0] + NewMatrix[1][1] = m_Transform[0][1] *TempMat[1][0] +
m_Transform[1][1] * TempMat[1][1]; m_Transform[1][1] *TempMat[1][1];
m_Transform[0][0] = NewMatrix[0][0]; m_Transform[0][0] = NewMatrix[0][0];
m_Transform[0][1] = NewMatrix[0][1]; m_Transform[0][1] = NewMatrix[0][1];
...@@ -867,19 +878,20 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) ...@@ -867,19 +878,20 @@ void SCH_COMPONENT::SetOrientation( int aOrientation )
*/ */
int SCH_COMPONENT::GetOrientation() int SCH_COMPONENT::GetOrientation()
{ {
int type_rotate = CMP_ORIENT_0; int type_rotate = CMP_ORIENT_0;
int ComponentMatOrient[2][2]; int ComponentMatOrient[2][2];
int ii; int ii;
#define ROTATE_VALUES_COUNT 12 #define ROTATE_VALUES_COUNT 12
// list of all possibilities, but only the first 8 are actually used // list of all possibilities, but only the first 8 are actually used
int rotate_value[ROTATE_VALUES_COUNT] = int rotate_value[ROTATE_VALUES_COUNT] =
{ {
CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180,
CMP_MIRROR_X + CMP_ORIENT_0, CMP_MIRROR_X + CMP_ORIENT_90, CMP_ORIENT_270,
CMP_MIRROR_X + CMP_ORIENT_0, CMP_MIRROR_X + CMP_ORIENT_90,
CMP_MIRROR_X + CMP_ORIENT_180, CMP_MIRROR_X + CMP_ORIENT_270, CMP_MIRROR_X + CMP_ORIENT_180, CMP_MIRROR_X + CMP_ORIENT_270,
CMP_MIRROR_Y + CMP_ORIENT_0, CMP_MIRROR_Y + CMP_ORIENT_90, CMP_MIRROR_Y + CMP_ORIENT_0, CMP_MIRROR_Y + CMP_ORIENT_90,
CMP_MIRROR_Y + CMP_ORIENT_180, CMP_MIRROR_Y + CMP_ORIENT_270 CMP_MIRROR_Y + CMP_ORIENT_180, CMP_MIRROR_Y + CMP_ORIENT_270
}; };
...@@ -891,12 +903,12 @@ int SCH_COMPONENT::GetOrientation() ...@@ -891,12 +903,12 @@ int SCH_COMPONENT::GetOrientation()
type_rotate = rotate_value[ii]; type_rotate = rotate_value[ii];
SetOrientation( type_rotate ); SetOrientation( type_rotate );
if( memcmp( ComponentMatOrient, m_Transform, if( memcmp( ComponentMatOrient, m_Transform,
sizeof(ComponentMatOrient) ) == 0 ) sizeof(ComponentMatOrient) ) == 0 )
return type_rotate; return type_rotate;
} }
// Error: orientation not found in list (should not happen) // Error: orientation not found in list (should not happen)
wxMessageBox(wxT("Component orientation matrix internal error") ); wxMessageBox( wxT( "Component orientation matrix internal error" ) );
memcpy( m_Transform, ComponentMatOrient, sizeof( ComponentMatOrient ) ); memcpy( m_Transform, ComponentMatOrient, sizeof( ComponentMatOrient ) );
return CMP_NORMAL; return CMP_NORMAL;
} }
...@@ -911,13 +923,13 @@ wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord ) ...@@ -911,13 +923,13 @@ wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord )
{ {
wxPoint screenpos; wxPoint screenpos;
screenpos.x = m_Transform[0][0] * coord.x + m_Transform[0][1] * coord.y; screenpos.x = m_Transform[0][0] *coord.x + m_Transform[0][1] *coord.y;
screenpos.y = m_Transform[1][0] * coord.x + m_Transform[1][1] * coord.y; screenpos.y = m_Transform[1][0] *coord.x + m_Transform[1][1] *coord.y;
return screenpos; return screenpos;
} }
#if defined (DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
...@@ -932,7 +944,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) ...@@ -932,7 +944,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " ref=\"" << CONV_TO_UTF8( ReturnFieldName( 0 ) ) << " ref=\"" << CONV_TO_UTF8( ReturnFieldName( 0 ) )
<< '"' << " chipName=\"" << '"' << " chipName=\""
<< CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos << CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos
<< " layer=\"" << m_Layer << " layer=\"" << m_Layer
<< '"' << ">\n"; << '"' << ">\n";
...@@ -945,7 +957,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) ...@@ -945,7 +957,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
{ {
NestedSpace( nestLevel + 1, os ) << "<field" << " name=\"" NestedSpace( nestLevel + 1, os ) << "<field" << " name=\""
<< CONV_TO_UTF8( ReturnFieldName( i ) ) << CONV_TO_UTF8( ReturnFieldName( i ) )
<< '"' << " value=\"" << '"' << " value=\""
<< CONV_TO_UTF8( value ) << "\"/>\n"; << CONV_TO_UTF8( value ) << "\"/>\n";
} }
} }
...@@ -954,6 +966,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) ...@@ -954,6 +966,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
<< ">\n"; << ">\n";
} }
#endif #endif
...@@ -979,15 +992,16 @@ bool SCH_COMPONENT::Save( FILE* f ) const ...@@ -979,15 +992,16 @@ bool SCH_COMPONENT::Save( FILE* f ) const
strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) ); strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) );
else else
strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ),
sizeof( Name1 ) ); sizeof( Name1 ) );
} }
for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) for( ii = 0; ii < (int) strlen( Name1 ); ii++ )
{ {
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
if( Name1[ii] == ' ' ) if( Name1[ii] == ' ' )
#else #else
if( Name1[ii] <= ' ' ) if( Name1[ii] <= ' ' )
#endif #endif
Name1[ii] = '~'; Name1[ii] = '~';
} }
...@@ -996,16 +1010,19 @@ bool SCH_COMPONENT::Save( FILE* f ) const ...@@ -996,16 +1010,19 @@ bool SCH_COMPONENT::Save( FILE* f ) const
strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof( Name2 ) ); strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof( Name2 ) );
for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) for( ii = 0; ii < (int) strlen( Name2 ); ii++ )
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
if( Name2[ii] == ' ' ) if( Name2[ii] == ' ' )
#else #else
if( Name2[ii] <= ' ' ) if( Name2[ii] <= ' ' )
#endif #endif
Name2[ii] = '~'; Name2[ii] = '~';
} }
else else
strncpy( Name2, NULL_STRING, sizeof( Name2 ) ); strncpy( Name2, NULL_STRING, sizeof( Name2 ) );
if ( fprintf( f, "$Comp\n" ) == EOF ) if( fprintf( f, "$Comp\n" ) == EOF )
return false; return false;
if( fprintf( f, "L %s %s\n", Name2, Name1 ) == EOF ) if( fprintf( f, "L %s %s\n", Name2, Name1 ) == EOF )
...@@ -1040,15 +1057,15 @@ bool SCH_COMPONENT::Save( FILE* f ) const ...@@ -1040,15 +1057,15 @@ bool SCH_COMPONENT::Save( FILE* f ) const
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], reference_fields = wxStringTokenize( m_PathsAndReferences[ii],
delimiters ); delimiters );
if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n", if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
CONV_TO_UTF8( reference_fields[0] ), CONV_TO_UTF8( reference_fields[0] ),
CONV_TO_UTF8( reference_fields[1] ), CONV_TO_UTF8( reference_fields[1] ),
CONV_TO_UTF8( reference_fields[2] ) ) == EOF ) CONV_TO_UTF8( reference_fields[2] ) ) == EOF )
return false; return false;
} }
} }
// update the ugly field index, which I would like to see go away someday soon. // update the ugly field index, which I would like to see go away someday soon.
for( unsigned i=0; i<m_Fields.size(); ++i ) for( unsigned i = 0; i<m_Fields.size(); ++i )
{ {
SCH_FIELD* fld = GetField( i ); SCH_FIELD* fld = GetField( i );
fld->m_FieldId = i; // we don't need field Ids, please be gone. fld->m_FieldId = i; // we don't need field Ids, please be gone.
...@@ -1056,7 +1073,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const ...@@ -1056,7 +1073,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
// Fixed fields: // Fixed fields:
// Save fixed fields which are non blank. // Save fixed fields which are non blank.
for( unsigned i=0; i<MANDATORY_FIELDS; ++i ) for( unsigned i = 0; i<MANDATORY_FIELDS; ++i )
{ {
SCH_FIELD* fld = GetField( i ); SCH_FIELD* fld = GetField( i );
if( !fld->m_Text.IsEmpty() ) if( !fld->m_Text.IsEmpty() )
...@@ -1071,7 +1088,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const ...@@ -1071,7 +1088,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
// only in the dialog editors. No policy should be enforced here, simply // only in the dialog editors. No policy should be enforced here, simply
// save all the user defined fields, they are present because a dialog editor // save all the user defined fields, they are present because a dialog editor
// thought they should be. If you disagree, go fix the dialog editors. // thought they should be. If you disagree, go fix the dialog editors.
for( unsigned i=MANDATORY_FIELDS; i<m_Fields.size(); ++i ) for( unsigned i = MANDATORY_FIELDS; i<m_Fields.size(); ++i )
{ {
SCH_FIELD* fld = GetField( i ); SCH_FIELD* fld = GetField( i );
if( !fld->Save( f ) ) if( !fld->Save( f ) )
...@@ -1111,7 +1128,7 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox() ...@@ -1111,7 +1128,7 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox()
// Include BoundingBoxes of fields // Include BoundingBoxes of fields
for( int ii = 0; ii < GetFieldCount(); ii++ ) for( int ii = 0; ii < GetFieldCount(); ii++ )
{ {
if( ! GetField( ii )->IsVisible() ) if( !GetField( ii )->IsVisible() )
continue; continue;
bbox.Merge( GetField( ii )->GetBoundaryBox() ); bbox.Merge( GetField( ii )->GetBoundaryBox() );
} }
...@@ -1138,7 +1155,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1138,7 +1155,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
frame->ClearMsgPanel(); frame->ClearMsgPanel();
frame->AppendMsgPanel( _( "Reference" ), frame->AppendMsgPanel( _( "Reference" ),
GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), GetRef( ( (WinEDA_SchematicFrame*) frame )->GetSheet() ),
DARKCYAN ); DARKCYAN );
if( root_component->isPower() ) if( root_component->isPower() )
...@@ -1149,7 +1166,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1149,7 +1166,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
// Display component reference in library and library // Display component reference in library and library
frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN ); frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN );
if( Entry->isAlias( ) ) if( Entry->isAlias() )
frame->AppendMsgPanel( _( "Alias of" ), root_component->GetName(), BROWN ); frame->AppendMsgPanel( _( "Alias of" ), root_component->GetName(), BROWN );
frame->AppendMsgPanel( _( "Library" ), Entry->GetLibraryName(), BROWN ); frame->AppendMsgPanel( _( "Library" ), Entry->GetLibraryName(), BROWN );
...@@ -1158,13 +1175,15 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1158,13 +1175,15 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN ); frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN );
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
void SCH_COMPONENT::Mirror_Y(int aYaxis_position) void SCH_COMPONENT::Mirror_Y( int aYaxis_position )
{ {
int dx = m_Pos.x; int dx = m_Pos.x;
SetOrientation( CMP_MIRROR_Y ); SetOrientation( CMP_MIRROR_Y );
m_Pos.x -= aYaxis_position; m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x ); NEGATE( m_Pos.x );
...@@ -1180,15 +1199,58 @@ void SCH_COMPONENT::Mirror_Y(int aYaxis_position) ...@@ -1180,15 +1199,58 @@ void SCH_COMPONENT::Mirror_Y(int aYaxis_position)
} }
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData ) /** virtual function Mirror_X
* mirror item relative to an X axis
* @param aXaxis_position = the x axis position
*/
void SCH_COMPONENT::Mirror_X( int aXaxis_position )
{
int dy = m_Pos.y;
SetOrientation( CMP_MIRROR_X );
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
dy -= m_Pos.y; // dy,0 is the move vector for this transform
for( int ii = 0; ii < GetFieldCount(); ii++ )
{
/* move the fields to the new position because the component itself
* has moved */
GetField( ii )->m_Pos.y -= dy;
}
}
void SCH_COMPONENT::Rotate( wxPoint rotationPoint )
{
wxPoint prev = m_Pos;
RotatePoint( &m_Pos, rotationPoint, 900 );
//SetOrientation( CMP_ROTATE_COUNTERCLOCKWISE );
SetOrientation( CMP_ROTATE_CLOCKWISE );
for( int ii = 0; ii < GetFieldCount(); ii++ )
{
/* move the fields to the new position because the component itself
* has moved */
GetField( ii )->m_Pos.x -= prev.x - m_Pos.x;
GetField( ii )->m_Pos.y -= prev.y - m_Pos.y;
}
}
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
{ {
// Search reference. // Search reference.
// reference is a special field because a part identifier is added // reference is a special field because a part identifier is added
// in multi parts per package // in multi parts per package
// the .m_AddExtraText of the field msut be set to add this identifier: // the .m_AddExtraText of the field msut be set to add this identifier:
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry && Entry->GetPartCount() > 1 ) if( Entry && Entry->GetPartCount() > 1 )
GetField( REFERENCE )->m_AddExtraText = true; GetField( REFERENCE )->m_AddExtraText = true;
else else
GetField( REFERENCE )->m_AddExtraText = false; GetField( REFERENCE )->m_AddExtraText = false;
...@@ -1201,7 +1263,7 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData ) ...@@ -1201,7 +1263,7 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS ) ) if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS ) )
return false; return false;
for( size_t i = VALUE+1; i < m_Fields.size(); i++ ) for( size_t i = VALUE + 1; i < m_Fields.size(); i++ )
{ {
if( GetField( i )->Matches( aSearchData, aAuxData ) ) if( GetField( i )->Matches( aSearchData, aAuxData ) )
return true; return true;
......
...@@ -18,13 +18,14 @@ class SCH_SHEET_PATH; ...@@ -18,13 +18,14 @@ class SCH_SHEET_PATH;
*/ */
struct Error struct Error
{ {
wxString errorText; wxString errorText;
Error( const wxChar* aMsg ) : Error( const wxChar* aMsg ) :
errorText( aMsg ) errorText( aMsg )
{ {
} }
Error( const wxString& aMsg ) : Error( const wxString& aMsg ) :
errorText( aMsg ) errorText( aMsg )
{ {
...@@ -32,7 +33,7 @@ struct Error ...@@ -32,7 +33,7 @@ struct Error
}; };
/// A container for several SCH_FIELD items /// A container for several SCH_FIELD items
typedef std::vector<SCH_FIELD> SCH_FIELDS; typedef std::vector<SCH_FIELD> SCH_FIELDS;
/** /**
...@@ -44,14 +45,14 @@ class SCH_COMPONENT : public SCH_ITEM ...@@ -44,14 +45,14 @@ class SCH_COMPONENT : public SCH_ITEM
friend class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC; friend class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC;
public: public:
int m_Multi; // In multi unit chip - which unit to draw. int m_Multi; // In multi unit chip - which unit to draw.
wxPoint m_Pos; wxPoint m_Pos;
wxString m_ChipName; /* Key to look for in the library, wxString m_ChipName; /* Key to look for in the library,
* i.e. "74LS00". */ * i.e. "74LS00". */
wxString m_PrefixString; /* C, R, U, Q etc - the first character wxString m_PrefixString; /* C, R, U, Q etc - the first character
* which typically indicates what the * which typically indicates what the
* component is. Determined, upon * component is. Determined, upon
* placement, from the library component. * placement, from the library component.
...@@ -59,14 +60,14 @@ public: ...@@ -59,14 +60,14 @@ public:
* first non-digits in the reference * first non-digits in the reference
* fields. */ * fields. */
int m_Convert; /* Handle multiple shape (for instance int m_Convert; /* Handle multiple shape (for instance
* De Morgan conversion) */ * De Morgan conversion) */
int m_Transform[2][2]; /* The rotation/mirror transformation int m_Transform[2][2]; /* The rotation/mirror transformation
* matrix. */ * matrix. */
private: private:
SCH_FIELDS m_Fields; ///< variable length list of fields SCH_FIELDS m_Fields; ///< variable length list of fields
/* Hierarchical references. /* Hierarchical references.
...@@ -78,7 +79,7 @@ private: ...@@ -78,7 +79,7 @@ private:
* multi = part selection in multi parts per package (0 or 1 for one part * multi = part selection in multi parts per package (0 or 1 for one part
* per package) * per package)
*/ */
wxArrayString m_PathsAndReferences; wxArrayString m_PathsAndReferences;
void Init( const wxPoint& pos = wxPoint( 0, 0 ) ); void Init( const wxPoint& pos = wxPoint( 0, 0 ) );
...@@ -128,7 +129,7 @@ public: ...@@ -128,7 +129,7 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** /**
...@@ -147,12 +148,13 @@ public: ...@@ -147,12 +148,13 @@ public:
* set to NULL. * set to NULL.
* @return SCH_COMPONENT* - a copy of me. * @return SCH_COMPONENT* - a copy of me.
*/ */
SCH_COMPONENT* GenCopy() SCH_COMPONENT* GenCopy()
{ {
return new SCH_COMPONENT( *this ); return new SCH_COMPONENT( *this );
} }
void SetOrientation( int aOrientation );
void SetOrientation( int aOrientation );
/** function GetOrientation() /** function GetOrientation()
* Used to display component orientation (in dialog editor or info) * Used to display component orientation (in dialog editor or info)
...@@ -167,24 +169,24 @@ public: ...@@ -167,24 +169,24 @@ public:
* ( a CMP_MIRROR_Y is find as a CMP_MIRROR_X + orientation 180, because * ( a CMP_MIRROR_Y is find as a CMP_MIRROR_X + orientation 180, because
* they are equivalent) * they are equivalent)
*/ */
int GetOrientation(); int GetOrientation();
wxPoint GetScreenCoord( const wxPoint& coord ); wxPoint GetScreenCoord( const wxPoint& coord );
void DisplayInfo( WinEDA_DrawFrame* frame ); void DisplayInfo( WinEDA_DrawFrame* frame );
/** /**
* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1) * Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
* @param aSheet: SCH_SHEET_PATH value: if NULL remove all annotations, * @param aSheet: SCH_SHEET_PATH value: if NULL remove all annotations,
* else remove annotation relative to this sheetpath * else remove annotation relative to this sheetpath
*/ */
void ClearAnnotation( SCH_SHEET_PATH* aSheet ); void ClearAnnotation( SCH_SHEET_PATH* aSheet );
/** function SetTimeStamp /** function SetTimeStamp
* Change the old time stamp to the new time stamp. * Change the old time stamp to the new time stamp.
* the time stamp is also modified in paths * the time stamp is also modified in paths
* @param aNewTimeStamp = new time stamp * @param aNewTimeStamp = new time stamp
*/ */
void SetTimeStamp( long aNewTimeStamp); void SetTimeStamp( long aNewTimeStamp );
/** /**
* Function GetBoundaryBox * Function GetBoundaryBox
...@@ -193,7 +195,7 @@ public: ...@@ -193,7 +195,7 @@ public:
* this include only fields defined in library * this include only fields defined in library
* use GetBoundingBox() to include fields in schematic * use GetBoundingBox() to include fields in schematic
*/ */
EDA_Rect GetBoundaryBox() const; EDA_Rect GetBoundaryBox() const;
/** /**
* Function GetBoundingBox * Function GetBoundingBox
...@@ -202,7 +204,7 @@ public: ...@@ -202,7 +204,7 @@ public:
* object, and the units should be in the pcb or schematic coordinate system. * object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts. * It is OK to overestimate the size by a few counts.
*/ */
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
//-----<Fields>----------------------------------------------------------- //-----<Fields>-----------------------------------------------------------
...@@ -212,7 +214,7 @@ public: ...@@ -212,7 +214,7 @@ public:
* @reeturn wxString - the field name or wxEmptyString if invalid field * @reeturn wxString - the field name or wxEmptyString if invalid field
* index. * index.
*/ */
wxString ReturnFieldName( int aFieldNdx ) const; wxString ReturnFieldName( int aFieldNdx ) const;
/** /**
* Function GetField * Function GetField
...@@ -242,6 +244,7 @@ public: ...@@ -242,6 +244,7 @@ public:
m_Fields = aFields; // vector copying, length is changed possibly m_Fields = aFields; // vector copying, length is changed possibly
} }
//-----</Fields>---------------------------------------------------------- //-----</Fields>----------------------------------------------------------
/** /**
...@@ -267,28 +270,29 @@ public: ...@@ -267,28 +270,29 @@ public:
Draw( panel, DC, offset, draw_mode, Color, true ); Draw( panel, DC, offset, draw_mode, Color, true );
} }
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color,
bool DrawPinText );
void SwapData( SCH_COMPONENT* copyitem ); void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color,
bool DrawPinText );
void SwapData( SCH_COMPONENT* copyitem );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
// returns a unique ID, in the form of a path. // returns a unique ID, in the form of a path.
wxString GetPath( SCH_SHEET_PATH* sheet ); wxString GetPath( SCH_SHEET_PATH* sheet );
/** /**
* Function GetRef * Function GetRef
* returns the reference, for the given sheet path. * returns the reference, for the given sheet path.
*/ */
const wxString GetRef( SCH_SHEET_PATH* sheet ); const wxString GetRef( SCH_SHEET_PATH* sheet );
// Set the reference, for the given sheet path. // Set the reference, for the given sheet path.
void SetRef( SCH_SHEET_PATH* sheet, const wxString& ref ); void SetRef( SCH_SHEET_PATH* sheet, const wxString& ref );
/** /**
* Function AddHierarchicalReference * Function AddHierarchicalReference
...@@ -299,25 +303,26 @@ public: ...@@ -299,25 +303,26 @@ public:
* @param aMulti = part selection, used in multi part per package (0 or 1 * @param aMulti = part selection, used in multi part per package (0 or 1
* for non multi) * for non multi)
*/ */
void AddHierarchicalReference( const wxString& aPath, void AddHierarchicalReference( const wxString& aPath,
const wxString& aRef, const wxString& aRef,
int aMulti ); int aMulti );
// returns the unit selection, for the given sheet path. // returns the unit selection, for the given sheet path.
int GetUnitSelection( SCH_SHEET_PATH* aSheet ); int GetUnitSelection( SCH_SHEET_PATH* aSheet );
// Set the unit selection, for the given sheet path. // Set the unit selection, for the given sheet path.
void SetUnitSelection( SCH_SHEET_PATH* aSheet, void SetUnitSelection( SCH_SHEET_PATH* aSheet,
int aUnitSelection ); int aUnitSelection );
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
* for a component, has no meaning, but it is necessary to satisfy the * for a component, has no meaning, but it is necessary to satisfy the
* SCH_ITEM class requirements. * SCH_ITEM class requirements.
*/ */
virtual int GetPenSize( ) { return 0; } virtual int GetPenSize() { return 0; }
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
...@@ -329,11 +334,15 @@ public: ...@@ -329,11 +334,15 @@ public:
GetField( ii )->Move( aMoveVector ); GetField( ii )->Move( aMoveVector );
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
/** /**
* Compare schematic component reference and value fields against search string. * Compare schematic component reference and value fields against search string.
...@@ -344,9 +353,9 @@ public: ...@@ -344,9 +353,9 @@ public:
* This param is used in this case * This param is used in this case
* @return True if this component reference or value field matches the search criteria. * @return True if this component reference or value field matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData ); virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData );
#if defined (DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "trigo.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
...@@ -97,11 +97,12 @@ bool SCH_BUS_ENTRY::Save( FILE* aFile ) const ...@@ -97,11 +97,12 @@ bool SCH_BUS_ENTRY::Save( FILE* aFile ) const
EDA_Rect SCH_BUS_ENTRY::GetBoundingBox() EDA_Rect SCH_BUS_ENTRY::GetBoundingBox()
{ {
EDA_Rect box; EDA_Rect box;
box.SetOrigin(m_Pos);
box.SetEnd(m_End()); box.SetOrigin( m_Pos );
box.SetEnd( m_End() );
box.Normalize(); box.Normalize();
int width = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; int width = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
box.Inflate( width / 2 ); box.Inflate( width / 2 );
return box; return box;
...@@ -141,6 +142,31 @@ void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -141,6 +142,31 @@ void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
} }
void SCH_BUS_ENTRY::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
NEGATE( m_Size.y );
}
void SCH_BUS_ENTRY::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
NEGATE( m_Size.x );
}
void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
RotatePoint( &m_Size.x, &m_Size.y, 900 );
}
/**********************/ /**********************/
/* class SCH_JUNCTION */ /* class SCH_JUNCTION */
/**********************/ /**********************/
...@@ -148,15 +174,14 @@ void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -148,15 +174,14 @@ void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE ) SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE )
{ {
#define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */ #define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */
m_Pos = pos; m_Pos = pos;
m_Layer = LAYER_JUNCTION; m_Layer = LAYER_JUNCTION;
m_Size.x = m_Size.y = DRAWJUNCTION_DIAMETER; m_Size.x = m_Size.y = DRAWJUNCTION_DIAMETER;
#undef DRAWJUNCTION_DIAMETER #undef DRAWJUNCTION_DIAMETER
} }
SCH_JUNCTION* SCH_JUNCTION::GenCopy() SCH_JUNCTION* SCH_JUNCTION::GenCopy()
{ {
SCH_JUNCTION* newitem = new SCH_JUNCTION( m_Pos ); SCH_JUNCTION* newitem = new SCH_JUNCTION( m_Pos );
...@@ -191,6 +216,7 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const ...@@ -191,6 +216,7 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const
EDA_Rect SCH_JUNCTION::GetBoundingBox() EDA_Rect SCH_JUNCTION::GetBoundingBox()
{ {
EDA_Rect rect; EDA_Rect rect;
rect.SetOrigin( m_Pos ); rect.SetOrigin( m_Pos );
rect.Inflate( ( GetPenSize() + m_Size.x ) / 2 ); rect.Inflate( ( GetPenSize() + m_Size.x ) / 2 );
...@@ -207,7 +233,7 @@ bool SCH_JUNCTION::HitTest( const wxPoint& aPosRef ) ...@@ -207,7 +233,7 @@ bool SCH_JUNCTION::HitTest( const wxPoint& aPosRef )
wxPoint dist = aPosRef - m_Pos; wxPoint dist = aPosRef - m_Pos;
return sqrt( ( (double) ( dist.x * dist.x ) ) + return sqrt( ( (double) ( dist.x * dist.x ) ) +
( (double) ( dist.y * dist.y ) ) ) < ( m_Size.x / 2 ); ( (double) ( dist.y * dist.y ) ) ) < ( m_Size.x / 2 );
} }
...@@ -236,11 +262,33 @@ void SCH_JUNCTION::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -236,11 +262,33 @@ void SCH_JUNCTION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x, GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x,
m_Pos.y + offset.y, (m_Size.x/2), 0, color, m_Pos.y + offset.y, (m_Size.x / 2), 0, color,
color ); color );
} }
void SCH_JUNCTION::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
}
void SCH_JUNCTION::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
void SCH_JUNCTION::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
{ {
...@@ -263,7 +311,7 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : ...@@ -263,7 +311,7 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE ) SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE )
{ {
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */ #define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
m_Pos = pos; m_Pos = pos;
m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE; m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE;
#undef DRAWNOCONNECT_SIZE #undef DRAWNOCONNECT_SIZE
} }
...@@ -282,8 +330,9 @@ SCH_NO_CONNECT* SCH_NO_CONNECT::GenCopy() ...@@ -282,8 +330,9 @@ SCH_NO_CONNECT* SCH_NO_CONNECT::GenCopy()
EDA_Rect SCH_NO_CONNECT::GetBoundingBox() EDA_Rect SCH_NO_CONNECT::GetBoundingBox()
{ {
int delta = ( GetPenSize() + m_Size.x ) / 2; int delta = ( GetPenSize() + m_Size.x ) / 2;
EDA_Rect box; EDA_Rect box;
box.SetOrigin( m_Pos ); box.SetOrigin( m_Pos );
box.Inflate( delta ); box.Inflate( delta );
...@@ -340,9 +389,9 @@ int SCH_NO_CONNECT::GetPenSize() ...@@ -340,9 +389,9 @@ int SCH_NO_CONNECT::GetPenSize()
void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color ) const wxPoint& offset, int DrawMode, int Color )
{ {
int pX, pY, color; int pX, pY, color;
int delta = m_Size.x / 2; int delta = m_Size.x / 2;
int width = g_DrawDefaultLineThickness; int width = g_DrawDefaultLineThickness;
pX = m_Pos.x + offset.x; pX = m_Pos.x + offset.x;
pY = m_Pos.y + offset.y; pY = m_Pos.y + offset.y;
...@@ -360,6 +409,28 @@ void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -360,6 +409,28 @@ void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
} }
void SCH_NO_CONNECT::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
}
void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}
/******************/ /******************/
/* Class SCH_LINE */ /* Class SCH_LINE */
/******************/ /******************/
...@@ -431,6 +502,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os ) ...@@ -431,6 +502,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os )
<< GetClass().Lower().mb_str() << ">\n"; << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -446,7 +518,7 @@ EDA_Rect SCH_LINE::GetBoundingBox() ...@@ -446,7 +518,7 @@ EDA_Rect SCH_LINE::GetBoundingBox()
// return a rectangle which is [pos,dim) in nature. therefore the +1 // return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_Rect ret( wxPoint( xmin, ymin ), EDA_Rect ret( wxPoint( xmin, ymin ),
wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
return ret; return ret;
} }
...@@ -530,6 +602,35 @@ void SCH_LINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, ...@@ -530,6 +602,35 @@ void SCH_LINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
} }
void SCH_LINE::Mirror_X( int aXaxis_position )
{
m_Start.y -= aXaxis_position;
NEGATE( m_Start.y );
m_Start.y += aXaxis_position;
m_End.y -= aXaxis_position;
NEGATE( m_End.y );
m_End.y += aXaxis_position;
}
void SCH_LINE::Mirror_Y( int aYaxis_position )
{
m_Start.x -= aYaxis_position;
NEGATE( m_Start.x );
m_Start.x += aYaxis_position;
m_End.x -= aYaxis_position;
NEGATE( m_End.x );
m_End.x += aYaxis_position;
}
void SCH_LINE::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Start, rotationPoint, 900 );
RotatePoint( &m_End, rotationPoint, 900 );
}
/***********************/ /***********************/
/* Class SCH_POLYLINE */ /* Class SCH_POLYLINE */
/***********************/ /***********************/
...@@ -586,7 +687,7 @@ bool SCH_POLYLINE::Save( FILE* aFile ) const ...@@ -586,7 +687,7 @@ bool SCH_POLYLINE::Save( FILE* aFile ) const
if( GetLayer() == LAYER_BUS ) if( GetLayer() == LAYER_BUS )
layer = "Bus"; layer = "Bus";
if( fprintf( aFile, "Poly %s %s %d\n", if( fprintf( aFile, "Poly %s %s %d\n",
width, layer, GetCornerCount() ) == EOF ) width, layer, GetCornerCount() ) == EOF )
{ {
return false; return false;
} }
...@@ -648,3 +749,34 @@ void SCH_POLYLINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -648,3 +749,34 @@ void SCH_POLYLINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
m_PolyPoints[i].y + offset.y, width, color ); m_PolyPoints[i].y + offset.y, width, color );
} }
} }
void SCH_POLYLINE::Mirror_X( int aXaxis_position )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
m_PolyPoints[ii].y -= aXaxis_position;
NEGATE( m_PolyPoints[ii].y );
m_PolyPoints[ii].y = aXaxis_position;
}
}
void SCH_POLYLINE::Mirror_Y( int aYaxis_position )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
m_PolyPoints[ii].x -= aYaxis_position;
NEGATE( m_PolyPoints[ii].x );
m_PolyPoints[ii].x = aYaxis_position;
}
}
void SCH_POLYLINE::Rotate( wxPoint rotationPoint )
{
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
RotatePoint( &m_PolyPoints[ii], rotationPoint, 900 );
}
}
...@@ -71,14 +71,15 @@ public: ...@@ -71,14 +71,15 @@ public:
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
if( (m_Flags & STARTPOINT) == 0 ) if( (m_Flags & STARTPOINT) == 0 )
m_Start += aMoveVector; m_Start += aMoveVector;
...@@ -86,22 +87,18 @@ public: ...@@ -86,22 +87,18 @@ public:
m_End += aMoveVector; m_End += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_X( int aXaxis_position );
{ virtual void Mirror_Y( int aYaxis_position );
m_Start.x -= aYaxis_position; virtual void Rotate( wxPoint rotationPoint );
NEGATE( m_Start.x );
m_Start.x += aYaxis_position;
m_End.x -= aYaxis_position;
NEGATE( m_End.x );
m_End.x += aYaxis_position;
}
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
...@@ -110,7 +107,7 @@ class SCH_NO_CONNECT : public SCH_ITEM ...@@ -110,7 +107,7 @@ class SCH_NO_CONNECT : public SCH_ITEM
{ {
public: public:
wxPoint m_Pos; /* XY coordinates of NoConnect. */ wxPoint m_Pos; /* XY coordinates of NoConnect. */
wxSize m_Size; // size of this symbol wxSize m_Size; // size of this symbol
public: public:
SCH_NO_CONNECT( const wxPoint& pos ); SCH_NO_CONNECT( const wxPoint& pos );
...@@ -126,11 +123,11 @@ public: ...@@ -126,11 +123,11 @@ public:
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
/** /**
* Function Save * Function Save
...@@ -139,13 +136,13 @@ public: ...@@ -139,13 +136,13 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
/** /**
* Function GetBoundingBox * Function GetBoundingBox
...@@ -155,28 +152,27 @@ public: ...@@ -155,28 +152,27 @@ public:
* schematic coordinate system. It is OK to overestimate the size * schematic coordinate system. It is OK to overestimate the size
* by a few counts. * by a few counts.
*/ */
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_Y( int aYaxis_position );
{ virtual void Mirror_X( int aXaxis_position );
m_Pos.x -= aYaxis_position; virtual void Rotate( wxPoint rotationPoint );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
}; };
...@@ -230,29 +226,27 @@ public: ...@@ -230,29 +226,27 @@ public:
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_Y( int aYaxis_position );
{ virtual void Mirror_X( int aXaxis_position );
m_Pos.x -= aYaxis_position; virtual void Rotate( wxPoint rotationPoint );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
NEGATE( m_Size.x );
}
}; };
class SCH_POLYLINE : public SCH_ITEM class SCH_POLYLINE : public SCH_ITEM
...@@ -271,10 +265,10 @@ public: ...@@ -271,10 +265,10 @@ public:
} }
SCH_POLYLINE* GenCopy(); SCH_POLYLINE* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
/** /**
* Function Save * Function Save
...@@ -283,7 +277,7 @@ public: ...@@ -283,7 +277,7 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function AddPoint /** Function AddPoint
* add a corner to m_PolyPoints * add a corner to m_PolyPoints
...@@ -293,6 +287,7 @@ public: ...@@ -293,6 +287,7 @@ public:
m_PolyPoints.push_back( point ); m_PolyPoints.push_back( point );
} }
/** Function GetCornerCount /** Function GetCornerCount
* @return the number of corners * @return the number of corners
*/ */
...@@ -302,31 +297,28 @@ public: ...@@ -302,31 +297,28 @@ public:
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
m_PolyPoints[ii] += aMoveVector; m_PolyPoints[ii] += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_Y( int aYaxis_position );
{ virtual void Mirror_X( int aXaxis_position );
for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) virtual void Rotate( wxPoint rotationPoint );
{
m_PolyPoints[ii].x -= aYaxis_position;
NEGATE( m_PolyPoints[ii].x );
m_PolyPoints[ii].x = aYaxis_position;
}
}
}; };
...@@ -334,7 +326,7 @@ class SCH_JUNCTION : public SCH_ITEM ...@@ -334,7 +326,7 @@ class SCH_JUNCTION : public SCH_ITEM
{ {
public: public:
wxPoint m_Pos; /* XY coordinates of connection. */ wxPoint m_Pos; /* XY coordinates of connection. */
wxSize m_Size; wxSize m_Size;
public: public:
SCH_JUNCTION( const wxPoint& pos ); SCH_JUNCTION( const wxPoint& pos );
...@@ -350,7 +342,7 @@ public: ...@@ -350,7 +342,7 @@ public:
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
/** /**
* Function GetBoundingBox * Function GetBoundingBox
...@@ -360,17 +352,18 @@ public: ...@@ -360,17 +352,18 @@ public:
* schematic coordinate system. It is OK to overestimate the size * schematic coordinate system. It is OK to overestimate the size
* by a few counts. * by a few counts.
*/ */
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
SCH_JUNCTION* GenCopy(); SCH_JUNCTION* GenCopy();
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode, int Color = -1 ); const wxPoint& offset, int draw_mode, int Color = -1 );
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.sch" * writes the data structures for this object out to a FILE in "*.sch"
...@@ -381,28 +374,28 @@ public: ...@@ -381,28 +374,28 @@ public:
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * move item to a new position.
* @param aMoveVector = the displacement vector * @param aMoveVector = the displacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) virtual void Mirror_Y( int aYaxis_position );
{ virtual void Mirror_X( int aXaxis_position );
m_Pos.x -= aYaxis_position; virtual void Rotate( wxPoint rotationPoint );
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
......
...@@ -218,10 +218,18 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position ) ...@@ -218,10 +218,18 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position )
dx = LenSize( m_Text ) / 2; dx = LenSize( m_Text ) / 2;
break; break;
case 1: /* Vert Orientation UP */
dx = -m_Size.x / 2;
break;
case 2: /* invert horizontal text*/ case 2: /* invert horizontal text*/
dx = -LenSize( m_Text ) / 2; dx = -LenSize( m_Text ) / 2;
break; break;
case 3: /* Vert Orientation BOTTOM */
dx = m_Size.x / 2;
break;
default: default:
dx = 0; dx = 0;
break; break;
...@@ -236,6 +244,84 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position ) ...@@ -236,6 +244,84 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position )
} }
/** virtual function Mirror_X
* mirror item relative to an X axis
* @param aXaxis_position = the x axis position
*/
void SCH_TEXT::Mirror_X( int aXaxis_position )
{
// Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half
// horizontal len
int py = m_Pos.y;
int dy;
switch( GetSchematicTextOrientation() )
{
case 0: /* horizontal text */
dy = -m_Size.y / 2;
break;
case 1: /* Vert Orientation UP */
dy = -LenSize( m_Text ) / 2;
break;
case 2: /* invert horizontal text*/
dy = m_Size.y / 2; // how to calculate text height?
break;
case 3: /* Vert Orientation BOTTOM */
dy = LenSize( m_Text ) / 2;
break;
default:
dy = 0;
break;
}
py += dy;
py -= aXaxis_position;
NEGATE( py );
py += aXaxis_position;
py -= dy;
m_Pos.y = py;
}
void SCH_TEXT::Rotate( wxPoint rotationPoint )
{
int dy;
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 1) % 4 );
switch( GetSchematicTextOrientation() )
{
case 0: /* horizontal text */
dy = m_Size.y;
break;
case 1: /* Vert Orientation UP */
dy = 0;
break;
case 2: /* invert horizontal text*/
dy = m_Size.y;
break;
case 3: /* Vert Orientation BOTTOM */
dy = 0;
break;
default:
dy = 0;
break;
}
m_Pos.y += dy;
}
/** function GetSchematicTextOffset (virtual) /** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself * @return the offset between the SCH_TEXT position and the text itself
* position * position
...@@ -302,6 +388,32 @@ void SCH_HIERLABEL::Mirror_Y( int aYaxis_position ) ...@@ -302,6 +388,32 @@ void SCH_HIERLABEL::Mirror_Y( int aYaxis_position )
} }
void SCH_HIERLABEL::Mirror_X( int aXaxis_position )
{
switch( GetSchematicTextOrientation() )
{
case 1: /* vertical text */
SetSchematicTextOrientation( 3 );
break;
case 3: /* invert vertical text*/
SetSchematicTextOrientation( 1 );
break;
}
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
}
void SCH_HIERLABEL::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 3) % 4 );
}
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
...@@ -330,6 +442,32 @@ void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position ) ...@@ -330,6 +442,32 @@ void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position )
} }
void SCH_GLOBALLABEL::Mirror_X( int aXaxis_position )
{
switch( GetSchematicTextOrientation() )
{
case 1: /* vertical text */
SetSchematicTextOrientation( 3 );
break;
case 3: /* invert vertical text*/
SetSchematicTextOrientation( 1 );
break;
}
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
}
void SCH_GLOBALLABEL::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 3) % 4 );
}
/** function GetSchematicTextOffset (virtual) /** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself * @return the offset between the SCH_TEXT position and the text itself
* position * position
...@@ -717,6 +855,32 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : ...@@ -717,6 +855,32 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
} }
/** virtual function Mirror_X
* mirror item relative to an X axis
* @param aXaxis_position = the x axis position
*/
void SCH_LABEL::Mirror_X( int aXaxis_position )
{
// Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half
// horizontal len
int py = m_Pos.y;
py -= aXaxis_position;
NEGATE( py );
py += aXaxis_position;
m_Pos.y = py;
}
void SCH_LABEL::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 1) % 4 );
}
/** /**
* 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.
...@@ -795,8 +959,8 @@ bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef ) ...@@ -795,8 +959,8 @@ bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
/*****************************************************************************/ /*****************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) : SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL ) SCH_TEXT( pos, text, aType )
{ {
/*****************************************************************************/ /*****************************************************************************/
m_Layer = LAYER_HIERLABEL; m_Layer = LAYER_HIERLABEL;
......
...@@ -49,7 +49,6 @@ protected: ...@@ -49,7 +49,6 @@ protected:
* Saving file * Saving file
*/ */
public: public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString, const wxString& text = wxEmptyString,
...@@ -143,7 +142,10 @@ public: ...@@ -143,7 +142,10 @@ public:
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Rotate( wxPoint rotationPoint );
virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
/** /**
* Compare schematic text entry against search string. * Compare schematic text entry against search string.
...@@ -152,7 +154,7 @@ public: ...@@ -152,7 +154,7 @@ public:
* @param aAuxData - a pointer on auxiliary data, if needed. Can be null * @param aAuxData - a pointer on auxiliary data, if needed. Can be null
* @return True if this schematic text item matches the search criteria. * @return True if this schematic text item matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData ); virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
...@@ -201,6 +203,8 @@ public: ...@@ -201,6 +203,8 @@ public:
* wire) * wire)
*/ */
virtual wxPoint GetSchematicTextOffset(); virtual wxPoint GetSchematicTextOffset();
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
/** /**
* Function GetBoundingBox * Function GetBoundingBox
...@@ -209,7 +213,7 @@ public: ...@@ -209,7 +213,7 @@ public:
* object, and the units should be in the pcb or schematic coordinate system. * object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts. * It is OK to overestimate the size by a few counts.
*/ */
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/** /**
* Function Save * Function Save
...@@ -300,6 +304,8 @@ public: ...@@ -300,6 +304,8 @@ public:
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
}; };
...@@ -307,7 +313,7 @@ class SCH_HIERLABEL : public SCH_TEXT ...@@ -307,7 +313,7 @@ class SCH_HIERLABEL : public SCH_TEXT
{ {
public: public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ), SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString ); const wxString& text = wxEmptyString, KICAD_T aType = TYPE_SCH_HIERLABEL );
~SCH_HIERLABEL() { } ~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
...@@ -381,6 +387,8 @@ public: ...@@ -381,6 +387,8 @@ public:
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
}; };
#endif /* CLASS_TEXT_LABEL_H */ #endif /* CLASS_TEXT_LABEL_H */
...@@ -57,15 +57,15 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ); ...@@ -57,15 +57,15 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList );
/* Returns true if the point P is on the segment S. */ /* Returns true if the point P is on the segment S. */
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint ) bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint )
{ {
wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2 wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
// Use long long here to avoid overflow in calculations // Use long long here to avoid overflow in calculations
if( (long long)vectSeg.x * vectPoint.y - (long long)vectSeg.y * vectPoint.x ) if( (long long) vectSeg.x * vectPoint.y - (long long) vectSeg.y * vectPoint.x )
return false; /* Cross product non-zero, vectors not parallel */ return false; /* Cross product non-zero, vectors not parallel */
if( ((long long)vectSeg.x * vectPoint.x + (long long)vectSeg.y * vectPoint.y) < if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) <
((long long)vectPoint.x * vectPoint.x + (long long)vectPoint.y * vectPoint.y) ) ( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) )
return false; /* Point not on segment */ return false; /* Point not on segment */
return true; return true;
...@@ -100,6 +100,14 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) ...@@ -100,6 +100,14 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
TestLabelForDangling( (SCH_LABEL*) item, this, DC ); TestLabelForDangling( (SCH_LABEL*) item, this, DC );
break; break;
case DRAW_SHEET_STRUCT_TYPE:
// Read the hierarchical pins list and teast for dangling pins:
BOOST_FOREACH( SCH_SHEET_PIN & sheetPin, ( (SCH_SHEET*) item )->GetSheetPins() ) {
TestLabelForDangling( &sheetPin, this, DC );
}
break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_LINE*) item ) #define STRUCT ( (SCH_LINE*) item )
...@@ -118,7 +126,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) ...@@ -118,7 +126,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
break; break;
default: default:
; break;
} }
} }
} }
......
...@@ -435,7 +435,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -435,7 +435,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_ROTATE: // Component or other schematic item rotation case HK_ROTATE: // Component or other schematic item rotation
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK)//allows bloc operation on hotkey
{
HandleBlockEndByPopUp(BLOCK_ROTATE, DC );
break;
}
if( DrawStruct == NULL ) if( DrawStruct == NULL )
{ {
// Find the schematic object to rotate under the cursor // Find the schematic object to rotate under the cursor
...@@ -465,6 +469,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -465,6 +469,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case DRAW_SHEET_STRUCT_TYPE: //TODO allow sheet rotate on hotkey
//wxPostEvent( this, eventRotateSheet );
break;
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
wxPostEvent( this, eventRotateComponent ); wxPostEvent( this, eventRotateComponent );
break; break;
...@@ -487,6 +494,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -487,6 +494,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component) case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK)
{
HandleBlockEndByPopUp(BLOCK_MIRROR_Y, DC );
break;
}
if( DrawStruct == NULL ) if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() ); DrawStruct = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() );
if( DrawStruct ) if( DrawStruct )
...@@ -501,6 +513,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -501,6 +513,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_MIRROR_X_COMPONENT: // Mirror X (Component) case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK) //allows bloc operation on hotkey
{
HandleBlockEndByPopUp(BLOCK_MIRROR_X, DC );
break;
}
if( DrawStruct == NULL ) if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() ); DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct ) if( DrawStruct )
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
using namespace std; using namespace std;
static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ); static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame );
static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, WinEDA_SchematicFrame* frame ); static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, WinEDA_SchematicFrame* frame );
static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, WinEDA_SchematicFrame* frame ); static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, WinEDA_SchematicFrame* frame );
...@@ -209,7 +208,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMe ...@@ -209,7 +208,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMe
default: default:
wxString msg; wxString msg;
msg.Printf( wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d" ), msg.Printf( wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d" ),
DrawStruct->Type() ); DrawStruct->Type() );
DisplayError( this, msg ); DisplayError( this, msg );
break; break;
} }
...@@ -223,7 +222,8 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field ) ...@@ -223,7 +222,8 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
{ {
wxString msg; wxString msg;
if( !Field->m_Flags ){ if( !Field->m_Flags )
{
msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
...@@ -444,7 +444,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) ...@@ -444,7 +444,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
{ {
wxString msg; wxString msg;
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
if( !Text->m_Flags ) if( !Text->m_Flags )
{ {
...@@ -482,7 +482,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -482,7 +482,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, WinEDA_SchematicFrame* frame ) void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, WinEDA_SchematicFrame* frame )
{ {
bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE;
wxString msg; wxString msg;
if( !is_new ) if( !is_new )
...@@ -506,8 +506,8 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, WinEDA_Schema ...@@ -506,8 +506,8 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, WinEDA_Schema
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, WinEDA_SchematicFrame* frame ) void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, WinEDA_SchematicFrame* frame )
{ {
bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur; wxPoint pos = frame->GetScreen()->m_Curseur;
wxString msg; wxString msg;
if( is_new ) if( is_new )
...@@ -630,6 +630,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ) ...@@ -630,6 +630,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
{ {
wxString msg; wxString msg;
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
...@@ -650,6 +651,9 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) ...@@ -650,6 +651,9 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK, msg, move_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK, msg, move_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), delete_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), mirror_H_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), mirror_H_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ), mirror_V_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ), rotate_pos_xpm );
#if 0 #if 0
#ifdef __WINDOWS__ #ifdef __WINDOWS__
ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD, ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
......
/*************************************************** /***************************************************
* operations_on_item_lists.cpp * operations_on_item_lists.cpp
* functions used in block commands, on lists of schematic items: * functions used in block commands, or undo/redo,
* move, mirror, delete and copy * to move, mirror, delete, copy ... lists of schematic items
****************************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -14,9 +14,17 @@ ...@@ -14,9 +14,17 @@
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Rotate( rotationPoint ); // Place it in its new position.
item->m_Flags = 0;
}
}
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
void DeleteItemsInList( WinEDA_DrawPanel* panel, void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList ); PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
...@@ -34,6 +42,17 @@ void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint ) ...@@ -34,6 +42,17 @@ void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint )
} }
void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Mirror_X( aMirrorPoint.y ); // Place it in its new position.
item->m_Flags = 0;
}
}
/** Function MoveItemsInList /** Function MoveItemsInList
* Move a list of items to a given move vector * Move a list of items to a given move vector
* @param aItemsList = list of picked items * @param aItemsList = list of picked items
...@@ -68,8 +87,9 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ) ...@@ -68,8 +87,9 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ) if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{ {
/* this item is depending on a sheet, and is not in global list */ /* this item is depending on a sheet, and is not in global list */
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected \ wxMessageBox( wxT(
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) ); "DeleteItemsInList() err: unexpected \
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) );
} }
else else
{ {
...@@ -102,7 +122,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -102,7 +122,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
/* This structure is attached to a node, and is not accessible by /* This structure is attached to a node, and is not accessible by
* the global list directly. */ * the global list directly. */
frame->SaveCopyInUndoList( frame->SaveCopyInUndoList(
(SCH_ITEM*) ( (SCH_SHEET_PIN*) DrawStruct )-> GetParent(), (SCH_ITEM*)( (SCH_SHEET_PIN*) DrawStruct )->GetParent(),
UR_CHANGED ); UR_CHANGED );
frame->DeleteSheetLabel( DC ? true : false, frame->DeleteSheetLabel( DC ? true : false,
(SCH_SHEET_PIN*) DrawStruct ); (SCH_SHEET_PIN*) DrawStruct );
...@@ -199,7 +219,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone ) ...@@ -199,7 +219,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) ); wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) );
return NULL; return NULL;
} }
switch( aDrawStruct->Type() ) switch( aDrawStruct->Type() )
{ {
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
...@@ -248,9 +268,10 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone ) ...@@ -248,9 +268,10 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy(); NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy();
if ( aClone ) if( aClone )
{ {
((SCH_SHEET*)NewDrawStruct)->m_SheetName = ((SCH_SHEET*)aDrawStruct)->m_SheetName; ( (SCH_SHEET*) NewDrawStruct )->m_SheetName =
( (SCH_SHEET*) aDrawStruct )->m_SheetName;
} }
break; break;
...@@ -264,7 +285,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone ) ...@@ -264,7 +285,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
break; break;
} }
if ( aClone ) if( aClone )
NewDrawStruct->m_TimeStamp = aDrawStruct->m_TimeStamp; NewDrawStruct->m_TimeStamp = aDrawStruct->m_TimeStamp;
NewDrawStruct->m_Image = aDrawStruct; NewDrawStruct->m_Image = aDrawStruct;
......
...@@ -106,10 +106,10 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, ...@@ -106,10 +106,10 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
*/ */
EDA_Rect BoundaryBox = field->GetBoundaryBox(); EDA_Rect BoundaryBox = field->GetBoundaryBox();
GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre(); wxPoint textpos = BoundaryBox.Centre();
int thickness = field->GetPenSize(); int thickness = field->GetPenSize();
if( !IsMulti || (FieldNumber != REFERENCE) ) if( !IsMulti || (FieldNumber != REFERENCE) )
{ {
...@@ -242,6 +242,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText ) ...@@ -242,6 +242,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
switch( aSchText->Type() ) switch( aSchText->Type() )
{ {
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
...@@ -293,7 +294,8 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText ) ...@@ -293,7 +294,8 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
aSchText->m_Pos ); aSchText->m_Pos );
plotter->poly( Poly.size(), &Poly[0].x, NO_FILL ); plotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
} }
if( aSchText->Type() == TYPE_SCH_HIERLABEL ) if( ( aSchText->Type() == TYPE_SCH_HIERLABEL )
|| ( aSchText->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE) )
{ {
( (SCH_HIERLABEL*) aSchText )->CreateGraphicShape( Poly, ( (SCH_HIERLABEL*) aSchText )->CreateGraphicShape( Poly,
aSchText->m_Pos ); aSchText->m_Pos );
...@@ -307,6 +309,8 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct ) ...@@ -307,6 +309,8 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
EDA_Colors txtcolor = UNSPECIFIED_COLOR; EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size; wxSize size;
wxString Text; wxString Text;
int name_orientation;
wxPoint pos_sheetname, pos_filename;
wxPoint pos; wxPoint pos;
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) ); plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
...@@ -326,18 +330,32 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct ) ...@@ -326,18 +330,32 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->line_to( pos ); plotter->line_to( pos );
plotter->finish_to( Struct->m_Pos ); plotter->finish_to( Struct->m_Pos );
if( Struct->IsVerticalOrientation() )
{
pos_sheetname = wxPoint( Struct->m_Pos.x - 8, Struct->m_Pos.y + Struct->m_Size.y );
pos_filename = wxPoint( Struct->m_Pos.x + Struct->m_Size.x + 4,
Struct->m_Pos.y + Struct->m_Size.y );
name_orientation = TEXT_ORIENT_VERT;
}
else
{
pos_sheetname = wxPoint( Struct->m_Pos.x, Struct->m_Pos.y - 4 );
pos_filename = wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 );
name_orientation = TEXT_ORIENT_HORIZ;
}
/* Draw texts: SheetName */ /* Draw texts: SheetName */
Text = Struct->m_SheetName; Text = Struct->m_SheetName;
size = wxSize( Struct->m_SheetNameSize, Struct->m_SheetNameSize ); size = wxSize( Struct->m_SheetNameSize, Struct->m_SheetNameSize );
pos = Struct->m_Pos; pos.y -= 4;
//pos = Struct->m_Pos; pos.y -= 4;
thickness = g_DrawDefaultLineThickness; thickness = g_DrawDefaultLineThickness;
thickness = Clamp_Text_PenSize( thickness, size, false ); thickness = Clamp_Text_PenSize( thickness, size, false );
plotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) ); plotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
bool italic = false; bool italic = false;
plotter->text( pos, txtcolor, plotter->text( pos_sheetname, txtcolor,
Text, TEXT_ORIENT_HORIZ, size, Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false ); thickness, italic, false );
...@@ -349,17 +367,17 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct ) ...@@ -349,17 +367,17 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) ); plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
plotter->text( wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ), plotter->text( pos_filename, txtcolor,
txtcolor, Text, TEXT_ORIENT_HORIZ, size, Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false ); thickness, italic, false );
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) ); plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
/* Draw texts : SheetLabel */ /* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN& pin_sheet, Struct->GetSheetPins() ) BOOST_FOREACH( SCH_SHEET_PIN & pin_sheet, Struct->GetSheetPins() ) {
{ //pin_sheet.Plot( plotter );
pin_sheet.Plot( plotter ); PlotTextStruct( plotter, &pin_sheet );
} }
} }
......
...@@ -323,7 +323,7 @@ error line %d, aborted\n" ), ...@@ -323,7 +323,7 @@ error line %d, aborted\n" ),
if( size == 0 ) if( size == 0 )
size = DEFAULT_SIZE_TEXT; size = DEFAULT_SIZE_TEXT;
SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size;
SheetLabelStruct->m_Pos.x=x; //to readjust x of first label if vertical
switch( Char1[0] ) switch( Char1[0] )
{ {
case 'I': case 'I':
...@@ -347,9 +347,22 @@ error line %d, aborted\n" ), ...@@ -347,9 +347,22 @@ error line %d, aborted\n" ),
break; break;
} }
if( Char2[0] == 'R' ) switch( Char2[0] )
SheetLabelStruct->m_Edge = 1; {
case 'R' : /* pin on right side */
SheetLabelStruct->SetEdge(1);
break;
case 'T' : /* pin on top side */
SheetLabelStruct->SetEdge(2);
break;
case 'B' : /* pin on bottom side */
SheetLabelStruct->SetEdge(3);
break;
case 'L' : /* pin on left side */
default :
SheetLabelStruct->SetEdge(0);
break;
}
SheetStruct->AddLabel( SheetLabelStruct ); SheetStruct->AddLabel( SheetLabelStruct );
} }
} }
......
...@@ -124,7 +124,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -124,7 +124,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
m_PanelDefaultCursor ) ); m_PanelDefaultCursor ) );
// Stop the current command (if any) but keep the current tool // Stop the current command (if any) but keep the current tool
DrawPanel->UnManageCursor( ); DrawPanel->UnManageCursor();
/* Should not be executed, except bug. */ /* Should not be executed, except bug. */
if( screen->m_BlockLocate.m_Command != BLOCK_IDLE ) if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
...@@ -137,11 +137,13 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -137,11 +137,13 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_CMP: case ID_POPUP_SCH_DELETE_CMP:
case ID_POPUP_SCH_DELETE: case ID_POPUP_SCH_DELETE:
// Stop the current command (if any) but keep the current tool // Stop the current command (if any) but keep the current tool
DrawPanel->UnManageCursor( ); DrawPanel->UnManageCursor();
break; break;
default: default:
// Stop the current command and deselect the current tool // Stop the current command and deselect the current tool
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor =
wxCURSOR_ARROW; wxCURSOR_ARROW;
...@@ -327,7 +329,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -327,7 +329,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( oldWiresList, UR_WIRE_IMAGE ); SaveCopyInUndoList( oldWiresList, UR_WIRE_IMAGE );
TestDanglingEnds( screen->EEDrawList, &dc ); TestDanglingEnds( screen->EEDrawList, &dc );
} }
break; break;
case ID_POPUP_SCH_DELETE_CMP: case ID_POPUP_SCH_DELETE_CMP:
if( screen->GetCurItem() == NULL ) if( screen->GetCurItem() == NULL )
...@@ -339,19 +341,19 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -339,19 +341,19 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
screen->SetCurItem( LocateSmallestComponent( screen ) ); screen->SetCurItem( LocateSmallestComponent( screen ) );
case ID_POPUP_SCH_DELETE: case ID_POPUP_SCH_DELETE:
{ {
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
if( item == NULL ) if( item == NULL )
break; break;
DeleteStruct( DrawPanel, &dc, item ); DeleteStruct( DrawPanel, &dc, item );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
TestDanglingEnds( screen->EEDrawList, &dc ); TestDanglingEnds( screen->EEDrawList, &dc );
SetSheetNumberAndCount(); SetSheetNumberAndCount();
OnModify(); OnModify();
} }
break; break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT: case ID_SCHEMATIC_DELETE_ITEM_BUTT:
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) ); SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
...@@ -374,19 +376,19 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -374,19 +376,19 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_IMPORT_GLABEL:
if ( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE ) if( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*)screen->GetCurItem(), &dc ) ); GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ) );
break; break;
case ID_POPUP_SCH_CLEANUP_SHEET: case ID_POPUP_SCH_CLEANUP_SHEET:
if ( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE ) if( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
{ {
SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem(); SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem();
if( !sheet->HasUndefinedLabels() ) if( !sheet->HasUndefinedLabels() )
{ {
DisplayInfoMessage( this, DisplayInfoMessage( this,
_( "There are no undefined labels in this sheet to clean up." ) ); _( "There are no undefined labels in this sheet to clean up." ) );
return; return;
} }
...@@ -407,23 +409,25 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -407,23 +409,25 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_MOVE_PINSHEET: case ID_POPUP_SCH_MOVE_PINSHEET:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
StartMove_PinSheet( (SCH_SHEET_PIN*)screen->GetCurItem(), &dc ); StartMove_PinSheet( (SCH_SHEET_PIN*) screen->GetCurItem(), &dc );
break; break;
case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_CMP_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST: case ID_POPUP_SCH_MOVE_CMP_REQUEST:
// Ensure the struct is a component (could be a struct of a // Ensure the struct is a component (could be a struct of a
// component, like Field, text..) or a hierachical sheet // component, like Field, text..) or a hierachical sheet
// or a label // or a label
if( (screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT) if( (screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT)
&& (screen->GetCurItem()->Type() != TYPE_SCH_LABEL) && (screen->GetCurItem()->Type() != TYPE_SCH_LABEL)
&& (screen->GetCurItem()->Type() != TYPE_SCH_GLOBALLABEL) && (screen->GetCurItem()->Type() != TYPE_SCH_GLOBALLABEL)
&& (screen->GetCurItem()->Type() != TYPE_SCH_HIERLABEL) && (screen->GetCurItem()->Type() != TYPE_SCH_HIERLABEL)
&& (screen->GetCurItem()->Type() != DRAW_SHEET_STRUCT_TYPE) ) && (screen->GetCurItem()->Type() != DRAW_SHEET_STRUCT_TYPE) )
screen->SetCurItem( LocateSmallestComponent( screen ) ); screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL ) if( screen->GetCurItem() == NULL )
break; break;
// fall through
// fall through
case ID_POPUP_SCH_MOVE_ITEM_REQUEST: case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST ) if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST )
...@@ -435,8 +439,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -435,8 +439,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( !HandleBlockBegin( &dc, BLOCK_DRAG, if( !HandleBlockBegin( &dc, BLOCK_DRAG,
screen->m_Curseur ) ) screen->m_Curseur ) )
break; break;
// Give a non null size to the search block: // Give a non null size to the search block:
screen->m_BlockLocate.Inflate(1); screen->m_BlockLocate.Inflate( 1 );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
} }
} }
...@@ -446,6 +451,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -446,6 +451,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_WIRE_REQUEST: case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// The easiest way to handle a drag component is to simulate a // The easiest way to handle a drag component is to simulate a
// block drag command // block drag command
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
...@@ -453,6 +459,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -453,6 +459,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( !HandleBlockBegin( &dc, BLOCK_DRAG, if( !HandleBlockBegin( &dc, BLOCK_DRAG,
screen->m_Curseur ) ) screen->m_Curseur ) )
break; break;
// Ensure the block selection contains the segment, or one end of // Ensure the block selection contains the segment, or one end of
// the segment. The initial rect is only one point (w = h = 0) // the segment. The initial rect is only one point (w = h = 0)
// The rect must contains one or 2 ends. // The rect must contains one or 2 ends.
...@@ -461,18 +468,18 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -461,18 +468,18 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
// whole segment. This works fine only for H and V segments and // whole segment. This works fine only for H and V segments and
// only if they do not cross a component // only if they do not cross a component
// TODO: a better way to drag only wires // TODO: a better way to drag only wires
SCH_LINE* segm = (SCH_LINE*)screen->GetCurItem(); SCH_LINE* segm = (SCH_LINE*) screen->GetCurItem();
if( !screen->m_BlockLocate.Inside(segm->m_Start) && if( !screen->m_BlockLocate.Inside( segm->m_Start )
!screen->m_BlockLocate.Inside(segm->m_End) ) && !screen->m_BlockLocate.Inside( segm->m_End ) )
{ {
screen->m_BlockLocate.SetOrigin(segm->m_Start); screen->m_BlockLocate.SetOrigin( segm->m_Start );
screen->m_BlockLocate.SetEnd(segm->m_End); screen->m_BlockLocate.SetEnd( segm->m_End );
} }
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
} }
break; break;
case ID_POPUP_SCH_EDIT_CMP: case ID_POPUP_SCH_EDIT_CMP:
// Ensure the struct is a component (could be a struct of a // Ensure the struct is a component (could be a struct of a
// component, like Field, text..) // component, like Field, text..)
...@@ -521,10 +528,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -521,10 +528,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( screen->GetCurItem()->m_Flags == 0 ) if( screen->GetCurItem()->m_Flags == 0 )
SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(), SaveCopyInUndoList( (SCH_ITEM*) screen->GetCurItem(),
UR_CHANGED ); UR_CHANGED );
CmpRotationMiroir( (SCH_COMPONENT*) screen->GetCurItem(), CmpRotationMiroir( (SCH_COMPONENT*) screen->GetCurItem(),
&dc, option ); &dc, option );
break; break;
} }
...@@ -618,7 +625,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -618,7 +625,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
SelPartUnit( (SCH_COMPONENT*) screen->GetCurItem(), SelPartUnit( (SCH_COMPONENT*) screen->GetCurItem(),
id + 1 - ID_POPUP_SCH_SELECT_UNIT1, &dc ); id + 1 - ID_POPUP_SCH_SELECT_UNIT1, &dc );
break; break;
case ID_POPUP_SCH_DISPLAYDOC_CMP: case ID_POPUP_SCH_DISPLAYDOC_CMP:
...@@ -637,7 +644,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -637,7 +644,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString ) if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString )
{ {
GetAssociatedDocument( this, LibEntry->GetDocFileName(), GetAssociatedDocument( this, LibEntry->GetDocFileName(),
&wxGetApp().GetLibraryPathList() ); &wxGetApp().GetLibraryPathList() );
} }
} }
break; break;
...@@ -650,7 +657,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -650,7 +657,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
InstallNextScreen( (SCH_SHEET*) DrawStruct ); InstallNextScreen( (SCH_SHEET*) DrawStruct );
} }
} }
break; break;
case ID_POPUP_SCH_LEAVE_SHEET: case ID_POPUP_SCH_LEAVE_SHEET:
InstallPreviousSheet(); InstallPreviousSheet();
...@@ -686,6 +693,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -686,6 +693,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_MIRROR_X_BLOCK: case ID_POPUP_MIRROR_X_BLOCK:
DrawPanel->MouseToCursorSchema();
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
break;
case ID_POPUP_MIRROR_Y_BLOCK: case ID_POPUP_MIRROR_Y_BLOCK:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc ); HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
...@@ -717,7 +728,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -717,7 +728,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
LAYER_LOCLABEL : LAYER_GLOBLABEL ) ); LAYER_LOCLABEL : LAYER_GLOBLABEL ) );
if( screen->GetCurItem() ) if( screen->GetCurItem() )
{ {
((SCH_ITEM*)screen->GetCurItem())->Place( this, &dc ); ( (SCH_ITEM*) screen->GetCurItem() )->Place( this, &dc );
TestDanglingEnds( screen->EEDrawList, &dc ); TestDanglingEnds( screen->EEDrawList, &dc );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
} }
...@@ -726,12 +737,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -726,12 +737,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_GETINFO_MARKER: case ID_POPUP_SCH_GETINFO_MARKER:
if( screen->GetCurItem() if( screen->GetCurItem()
&& screen->GetCurItem()->Type() == TYPE_SCH_MARKER ) && screen->GetCurItem()->Type() == TYPE_SCH_MARKER )
((SCH_MARKER*)screen->GetCurItem())->DisplayMarkerInfo( this ); ( (SCH_MARKER*) screen->GetCurItem() )->DisplayMarkerInfo( this );
break; break;
default: // Log error: default: // Log error:
DisplayError( this, DisplayError( this,
wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) ); wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) );
break; break;
} }
...@@ -743,7 +754,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -743,7 +754,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
} }
void WinEDA_SchematicFrame::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC ) void WinEDA_SchematicFrame::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC )
{ {
if( DrawStruct == NULL ) if( DrawStruct == NULL )
return; return;
......
...@@ -157,8 +157,7 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) ...@@ -157,8 +157,7 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
#undef DEST #undef DEST
#define SOURCE ( (SCH_SHEET_PIN*) aItem ) #define SOURCE ( (SCH_SHEET_PIN*) aItem )
#define DEST ( (SCH_SHEET_PIN*) aImage ) #define DEST ( (SCH_SHEET_PIN*) aImage )
EXCHG( SOURCE->m_Edge, DEST->m_Edge ); DEST->SwapData( SOURCE );
EXCHG( SOURCE->m_Shape, DEST->m_Shape );
break; break;
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
...@@ -174,13 +173,12 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) ...@@ -174,13 +173,12 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
// not directly used in schematic: // not directly used in schematic:
default: default:
wxMessageBox(wxT( "SwapData() error: unexpected type" ) ); wxMessageBox( wxT( "SwapData() error: unexpected type" ) );
break; break;
} }
} }
/** function SaveCopyInUndoList /** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list. * Create a copy of the current schematic item, and put it in the undo list.
* *
...@@ -225,7 +223,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem, ...@@ -225,7 +223,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
if( aItem ) if( aItem )
{ {
itemWrapper.m_PickedItemType = aItem->Type(); itemWrapper.m_PickedItemType = aItem->Type();
itemWrapper.m_PickerFlags = aItem->m_Flags; itemWrapper.m_PickerFlags = aItem->m_Flags;
} }
switch( aCommandType ) switch( aCommandType )
...@@ -233,7 +231,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem, ...@@ -233,7 +231,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
case UR_CHANGED: /* Create a copy of item */ case UR_CHANGED: /* Create a copy of item */
CopyOfItem = DuplicateStruct( aItem, true ); CopyOfItem = DuplicateStruct( aItem, true );
itemWrapper.m_Link = CopyOfItem; itemWrapper.m_Link = CopyOfItem;
if ( CopyOfItem ) if( CopyOfItem )
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
...@@ -273,10 +271,12 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem, ...@@ -273,10 +271,12 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
*/ */
void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint ) const wxPoint& aTransformPoint )
{ {
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
// Copy picker list: // Copy picker list:
commandToUndo->CopyList( aItemsList ); commandToUndo->CopyList( aItemsList );
...@@ -286,27 +286,30 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -286,27 +286,30 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii );
wxASSERT( item ); wxASSERT( item );
UndoRedoOpType command = commandToUndo->GetPickedItemStatus( ii ); UndoRedoOpType command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED ) if( command == UR_UNSPECIFIED )
{ {
command = aTypeCommand; command = aTypeCommand;
commandToUndo->SetPickedItemStatus(command, ii ); commandToUndo->SetPickedItemStatus( command, ii );
} }
switch( command ) switch( command )
{ {
case UR_CHANGED: /* Create a copy of item */ case UR_CHANGED: /* Create a copy of item */
/* If needed, create a copy of item, and put in undo list /* If needed, create a copy of item, and put in undo list
* in the picker, as link * in the picker, as link
* If this link is not null, the copy is already done * If this link is not null, the copy is already done
*/ */
if( commandToUndo->GetPickedItemLink(ii) == NULL ) if( commandToUndo->GetPickedItemLink( ii ) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii ); commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii );
wxASSERT( commandToUndo->GetPickedItemLink(ii) ); wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
break; break;
case UR_MOVED: case UR_MOVED:
case UR_MIRRORED_Y: case UR_MIRRORED_Y:
case UR_MIRRORED_X:
case UR_ROTATED:
case UR_NEW: case UR_NEW:
case UR_DELETED: case UR_DELETED:
break; break;
...@@ -343,7 +346,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -343,7 +346,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
* @param aRedoCommand = a bool: true for redo, false for undo * @param aRedoCommand = a bool: true for redo, false for undo
*/ */
void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
bool aRedoCommand ) bool aRedoCommand )
{ {
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* alt_item; SCH_ITEM* alt_item;
...@@ -351,13 +354,13 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, ...@@ -351,13 +354,13 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
// Undo in the reverse order of list creation: (this can allow stacked // Undo in the reverse order of list creation: (this can allow stacked
// changes like the same item can be changes and deleted in the same // changes like the same item can be changes and deleted in the same
// complex command // complex command
for( int ii = aList->GetCount()-1; ii >= 0 ; ii-- ) for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{ {
ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii ); ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii );
item = (SCH_ITEM*) itemWrapper.m_PickedItem; item = (SCH_ITEM*) itemWrapper.m_PickedItem;
if ( item ) if( item )
item->m_Flags = 0; item->m_Flags = 0;
SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link; SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link;
switch( itemWrapper.m_UndoRedoStatus ) switch( itemWrapper.m_UndoRedoStatus )
{ {
case UR_CHANGED: /* Exchange old and new data for each item */ case UR_CHANGED: /* Exchange old and new data for each item */
...@@ -376,9 +379,9 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, ...@@ -376,9 +379,9 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
break; break;
case UR_MOVED: case UR_MOVED:
item->m_Flags = aList->GetPickerFlags(ii); item->m_Flags = aList->GetPickerFlags( ii );
item->Move( aRedoCommand ? item->Move( aRedoCommand ?
aList->m_TransformPoint : - aList->m_TransformPoint ); aList->m_TransformPoint : -aList->m_TransformPoint );
item->m_Flags = 0; item->m_Flags = 0;
break; break;
...@@ -387,7 +390,23 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, ...@@ -387,7 +390,23 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
wxPoint mirrorPoint = aList->m_TransformPoint; wxPoint mirrorPoint = aList->m_TransformPoint;
item->Mirror_Y( mirrorPoint.x ); item->Mirror_Y( mirrorPoint.x );
} }
break; break;
case UR_MIRRORED_X:
{
wxPoint mirrorPoint = aList->m_TransformPoint;
item->Mirror_X( mirrorPoint.y );
}
break;
case UR_ROTATED:
{
wxPoint RotationPoint = aList->m_TransformPoint;
item->Rotate( RotationPoint );
item->Rotate( RotationPoint );
item->Rotate( RotationPoint );
}
break;
case UR_WIRE_IMAGE: case UR_WIRE_IMAGE:
/* Exchange the current wires and the old wires */ /* Exchange the current wires and the old wires */
...@@ -423,7 +442,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, ...@@ -423,7 +442,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
* - Get the previous version of the schematic from undo list * - Get the previous version of the schematic from undo list
* @return none * @return none
*/ */
void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) void WinEDA_SchematicFrame::GetSchematicFromUndoList( wxCommandEvent& event )
{ {
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
...@@ -439,13 +458,13 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) ...@@ -439,13 +458,13 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
// m_drawItem = NULL; // m_drawItem = NULL;
OnModify( ); OnModify();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
ReCreateHToolbar(); ReCreateHToolbar();
SetToolbars(); SetToolbars();
TestDanglingEnds( GetScreen()->EEDrawList, NULL ); TestDanglingEnds( GetScreen()->EEDrawList, NULL );
DrawPanel->Refresh( ); DrawPanel->Refresh();
} }
...@@ -455,7 +474,7 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) ...@@ -455,7 +474,7 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
* - Get the previous version from Redo list * - Get the previous version from Redo list
* @return none * @return none
*/ */
void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event) void WinEDA_SchematicFrame::GetSchematicFromRedoList( wxCommandEvent& event )
{ {
if( GetScreen()->GetRedoCommandCount() == 0 ) if( GetScreen()->GetRedoCommandCount() == 0 )
return; return;
...@@ -472,13 +491,13 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event) ...@@ -472,13 +491,13 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event)
GetScreen()->PushCommandToUndoList( List ); GetScreen()->PushCommandToUndoList( List );
// m_drawItem = NULL; // m_drawItem = NULL;
OnModify( ); OnModify();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
ReCreateHToolbar(); ReCreateHToolbar();
SetToolbars(); SetToolbars();
TestDanglingEnds( GetScreen()->EEDrawList, NULL ); TestDanglingEnds( GetScreen()->EEDrawList, NULL );
DrawPanel->Refresh( ); DrawPanel->Refresh();
} }
......
...@@ -20,7 +20,7 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); ...@@ -20,7 +20,7 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static int s_CurrentTypeLabel = NET_INPUT; static int s_CurrentTypeLabel = NET_INPUT;
static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT ); static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
static wxPoint s_InitialPosition; // remember the initial value of the pin label when moving it static wxPoint s_InitialPosition; // remember the initial value of the pin label when moving it
static int s_InitialEdge;
/****************************************/ /****************************************/
/* class WinEDA_PinSheetPropertiesFrame */ /* class WinEDA_PinSheetPropertiesFrame */
...@@ -38,8 +38,8 @@ private: ...@@ -38,8 +38,8 @@ private:
WinEDA_GraphicTextCtrl* m_TextWin; WinEDA_GraphicTextCtrl* m_TextWin;
public: WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent, public: WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent,
SCH_SHEET_PIN* curr_pinsheet, SCH_SHEET_PIN* curr_pinsheet,
const wxPoint& framepos = wxPoint( -1, -1 ) ); const wxPoint& framepos = wxPoint( -1, -1 ) );
~WinEDA_PinSheetPropertiesFrame() { }; ~WinEDA_PinSheetPropertiesFrame() { };
private: private:
...@@ -50,8 +50,8 @@ private: ...@@ -50,8 +50,8 @@ private:
}; };
BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_PinSheetPropertiesFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_PinSheetPropertiesFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_PinSheetPropertiesFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_PinSheetPropertiesFrame::OnCancelClick )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -126,6 +126,7 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) ...@@ -126,6 +126,7 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
/* Called when aborting a move pinsheet label /* Called when aborting a move pinsheet label
* delete a new pin sheet label, or restire its old position * delete a new pin sheet label, or restire its old position
*/ */
...@@ -145,13 +146,9 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -145,13 +146,9 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode ); RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode );
SheetLabel->m_Pos = s_InitialPosition; SheetLabel->m_Pos = s_InitialPosition;
// Restore edge position:
SCH_SHEET* sheet = (SCH_SHEET*) SheetLabel->GetParent();
if( s_InitialPosition.x > ( sheet->m_Pos.x + (sheet->m_Size.x / 2) ) )
SheetLabel->m_Edge = 1;
else
SheetLabel->m_Edge = 0;
// Restore edge position:
SheetLabel->SetEdge( s_InitialEdge );
RedrawOneStruct( Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
SheetLabel->m_Flags = 0; SheetLabel->m_Flags = 0;
} }
...@@ -165,6 +162,7 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -165,6 +162,7 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
wxASSERT( Sheet != NULL && Sheet->Type() == DRAW_SHEET_STRUCT_TYPE ); wxASSERT( Sheet != NULL && Sheet->Type() == DRAW_SHEET_STRUCT_TYPE );
SAFE_DELETE( g_ItemToUndoCopy ); SAFE_DELETE( g_ItemToUndoCopy );
...@@ -180,27 +178,12 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -180,27 +178,12 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{ {
wxPoint tmp = m_Pos; wxPoint tmp = m_Pos;
m_Pos = s_InitialPosition; m_Pos = s_InitialPosition;
m_Edge = 0; SetEdge( s_InitialEdge );
if( m_Pos.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
m_Edge = 1;
frame->SaveCopyInUndoList( Sheet, UR_CHANGED ); frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
m_Pos = tmp; m_Pos = tmp;
} }
m_Pos.x = Sheet->m_Pos.x; ConstraintOnEdge( frame->GetScreen()->m_Curseur );
m_Edge = 0;
if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + ( Sheet->m_Size.x / 2 ) ) )
{
m_Edge = 1;
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
m_Pos.y = frame->GetScreen()->m_Curseur.y;
if( m_Pos.y < Sheet->m_Pos.y )
m_Pos.y = Sheet->m_Pos.y;
if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
frame->DrawPanel->ManageCurseur = NULL; frame->DrawPanel->ManageCurseur = NULL;
...@@ -214,7 +197,8 @@ void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel, ...@@ -214,7 +197,8 @@ void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel,
NetSheetTextSize = SheetLabel->m_Size; NetSheetTextSize = SheetLabel->m_Size;
s_CurrentTypeLabel = SheetLabel->m_Shape; s_CurrentTypeLabel = SheetLabel->m_Shape;
SheetLabel->m_Flags |= IS_MOVED; SheetLabel->m_Flags |= IS_MOVED;
s_InitialPosition = SheetLabel->m_Pos; s_InitialPosition = SheetLabel->m_Pos;
s_InitialEdge = SheetLabel->GetEdge();
DrawPanel->ManageCurseur = Move_PinSheet; DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet; DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
...@@ -229,27 +213,10 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -229,27 +213,10 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( SheetLabel == NULL ) if( SheetLabel == NULL )
return; return;
SCH_SHEET* Sheet = (SCH_SHEET*) SheetLabel->GetParent();
if( Sheet == NULL )
return;
if( erase ) if( erase )
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode ); RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
SheetLabel->m_Edge = 0; SheetLabel->ConstraintOnEdge( panel->GetScreen()->m_Curseur );
SheetLabel->m_Pos.x = Sheet->m_Pos.x;
if( panel->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
{
SheetLabel->m_Edge = 1;
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
SheetLabel->m_Pos.y = panel->GetScreen()->m_Curseur.y;
if( SheetLabel->m_Pos.y < Sheet->m_Pos.y )
SheetLabel->m_Pos.y = Sheet->m_Pos.y;
if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode ); RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
} }
...@@ -269,7 +236,7 @@ int WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel, wxDC* DC ) ...@@ -269,7 +236,7 @@ int WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel, wxDC* DC )
int diag = frame->ShowModal(); int diag = frame->ShowModal();
frame->Destroy(); frame->Destroy();
if ( DC ) if( DC )
RedrawOneStruct( DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
return diag; return diag;
...@@ -302,7 +269,7 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet, wxDC* D ...@@ -302,7 +269,7 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet, wxDC* D
DrawPanel->ForceCloseManageCurseur = ExitPinSheet; DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
OnModify( ); OnModify();
return NewSheetLabel; return NewSheetLabel;
} }
...@@ -342,7 +309,7 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet, wxDC* D ...@@ -342,7 +309,7 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet, wxDC* D
return NULL; return NULL;
} }
OnModify( ); OnModify();
SAFE_DELETE( g_ItemToUndoCopy ); SAFE_DELETE( g_ItemToUndoCopy );
SaveCopyInUndoList( Sheet, UR_CHANGED ); SaveCopyInUndoList( Sheet, UR_CHANGED );
......
...@@ -79,6 +79,9 @@ public: ...@@ -79,6 +79,9 @@ public:
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) = 0; virtual void Mirror_Y(int aYaxis_position) = 0;
virtual void Mirror_X(int aXaxis_position) = 0;
virtual void Rotate(wxPoint rotationPoint) = 0;
/** /**
* Function Save * Function Save
......
...@@ -97,7 +97,7 @@ wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap ...@@ -97,7 +97,7 @@ wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap
{ {
wxPoint buttPos = m_ButtonLastPosition; wxPoint buttPos = m_ButtonLastPosition;
wxSize buttSize; wxSize buttSize;
int btn_margin = 8; int btn_margin = 10;
buttSize.x = aBitmap.GetWidth() + btn_margin; buttSize.x = aBitmap.GetWidth() + btn_margin;
buttSize.y = aBitmap.GetHeight() + btn_margin; buttSize.y = aBitmap.GetHeight() + btn_margin;
buttPos.y -= buttSize.y; buttPos.y -= buttSize.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