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
This commit is contained in:
Pascal Baerten 2010-09-05 19:07:46 +02:00 committed by jean-pierre charras
commit b0923f7892
25 changed files with 1294 additions and 661 deletions

View File

@ -21,6 +21,10 @@
// Imported functions:
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList,
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,
wxPoint& Center );
void DeleteItemsInList( WinEDA_DrawPanel* panel,
@ -124,6 +128,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
err = TRUE;
break;
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
if( DrawPanel->ManageCurseur )
@ -163,9 +170,6 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_ZOOM: // Handled by HandleBlockEnd()
case BLOCK_DELETE:
case BLOCK_SAVE:
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_FLIP:
case BLOCK_ABORT:
case BLOCK_SELECT_ITEMS_ONLY:
@ -240,6 +244,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
@ -298,10 +305,6 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_FLIP: /* pcbnew only! */
break;
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = TRUE;
@ -425,15 +428,53 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
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;
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:
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
ii = -1;
ii = 1;
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
PutOnGrid( &mirrorPoint );
@ -442,6 +483,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
mirrorPoint );
MirrorListOfItems( 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();
@ -515,6 +558,7 @@ void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
/* save the new list: */
ITEM_PICKER item;
// 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
// (or TODO ?: create a new status like UR_DUPLICATE)
@ -677,8 +721,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
SCH_SHEET* sheet = (SCH_SHEET*) Struct;
// 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 );
}
}

View File

@ -16,6 +16,7 @@
#include "class_drawpanel.h"
#include "drawtxt.h"
#include "confirm.h"
#include "trigo.h"
#include "program.h"
#include "general.h"
@ -204,6 +205,16 @@ bool SCH_SHEET::HasLabel( const wxString& aName )
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()
{
@ -316,18 +327,7 @@ SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition )
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{
size = ( label.GetLength() + 1 ) * label.m_Size.x;
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;
if (label.HitTest(aPosition)) return &label;
}
return NULL;
@ -358,6 +358,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
int txtcolor;
wxString Text;
int color;
int name_orientation;
wxPoint pos_sheetname,pos_filename;
wxPoint pos = m_Pos + aOffset;
int LineWidth = g_DrawDefaultLineThickness;
@ -369,7 +371,18 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y,
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 */
if( aColor > 0 )
txtcolor = aColor;
@ -377,8 +390,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
Text = wxT( "Sheet: " ) + m_SheetName;
DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y - 8 ),
(EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ,
DrawGraphicText( aPanel, aDC, pos_sheetname,
(EDA_Colors) txtcolor, Text, name_orientation,
wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth,
false, false, false );
@ -389,8 +402,8 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_FileName;
DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y + m_Size.y + 4 ),
(EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ,
DrawGraphicText( aPanel, aDC, pos_filename,
(EDA_Colors) txtcolor, Text, name_orientation,
wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth,
false, false, false );
@ -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
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
@ -770,8 +811,7 @@ void SCH_SHEET::Resize( const wxSize& aSize )
/* Move the sheet labels according to the new sheet size. */
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{
if( label.m_Edge )
label.m_Pos.x = m_Pos.x + m_Size.x;
label.ConstraintOnEdge(label.m_Pos);
}
}
@ -817,3 +857,4 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os )
}
#endif

View File

@ -8,7 +8,7 @@
#include "base_struct.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>
#include "class_text-label.h"
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
* 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:
int m_Number; ///< Label number use for saving sheet label to file.
///< Sheet label numbering begins at 2.
///< 0 is reserved for the sheet 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:
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE non connected
//int m_Shape;
//bool m_IsDangling; // TRUE non connected
public:
SCH_SHEET_PIN( SCH_SHEET* parent,
@ -46,6 +58,7 @@ public:
return wxT( "SCH_SHEET_PIN" );
}
bool operator ==( const SCH_SHEET_PIN* aPin ) const;
SCH_SHEET_PIN* GenCopy();
@ -55,6 +68,8 @@ public:
return (SCH_SHEET_PIN*) Pnext;
}
void SwapData( SCH_SHEET_PIN* copyitem );
/**
* Get the sheet label number.
*
@ -68,6 +83,9 @@ public:
* @param aNumber - New sheet number label.
*/
void SetNumber( int aNumber );
void SetEdge( int aEdge );
int GetEdge();
void ConstraintOnEdge( wxPoint Pos );
/**
* Get the parent sheet object of this sheet pin.
@ -79,18 +97,9 @@ public:
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
/**
* Plot this sheet pin object to aPlotter.
*
* @param aPlotter - The plotter object to plot to.
/*the functions Draw, CreateGraphicShape and Plot are no removed as
* as this shape is already handled as HIERLABEL ...
*/
void Plot( PLOTTER* aPlotter );
/**
* Function Save
@ -118,8 +127,6 @@ public:
* @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos );
// Geometric transforms (used in block operations):
@ -137,13 +144,11 @@ public:
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y( int aYaxis_position )
{
m_Edge = m_Edge ? 0 : 1;
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
virtual void Mirror_Y( int aYaxis_position );
virtual void Rotate( wxPoint rotationPoint );
virtual void Mirror_X( int aXaxis_position );
/**
* Compare schematic sheet entry (pin?) name against search string.
@ -215,6 +220,11 @@ public:
SCH_SHEET* GenCopy();
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.
*
@ -389,8 +399,7 @@ public:
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{
BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels ) {
label.Move( aMoveVector );
}
}
@ -401,6 +410,8 @@ public:
* @param aYaxis_position = the y axis 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.

View File

@ -17,20 +17,33 @@
#include "class_drawpanel.h"
#include "drawtxt.h"
#include "plot_common.h"
#include "trigo.h"
#include "program.h"
#include "general.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_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( Pnext == NULL );
m_Layer = LAYER_SHEETLABEL;
m_Pos = pos;
m_Edge = 0;
if( parent->IsVerticalOrientation() )
SetEdge( 2 );
else
SetEdge( 0 );
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_Number = 2;
@ -41,14 +54,26 @@ SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy()
{
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_Number = m_Number;
newitem->SetNumber( GetNumber() );
return newitem;
}
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;
@ -72,153 +97,88 @@ void SCH_SHEET_PIN::SetNumber( int aNumber )
}
/*****************************************************************************/
/* Routine to create hierarchical labels */
/*****************************************************************************/
void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int DrawMode,
int Color )
void SCH_SHEET_PIN::SetEdge( int aEdge )
{
GRTextHorizJustifyType side;
EDA_Colors txtcolor;
int posx, tposx, posy;
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
static std::vector <wxPoint> Poly;
int LineWidth = GetPenSize();
if( Color >= 0 )
txtcolor = (EDA_Colors) Color;
else
txtcolor = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
posx = m_Pos.x + offset.x;
posy = m_Pos.y + offset.y;
wxSize size = m_Size;
if( !m_Text.IsEmpty() )
/* use -1 to adjust text orientation without changing edge*/
if( aEdge > -1 )
m_Edge = aEdge;
switch( m_Edge )
{
if( m_Edge )
{
tposx = posx - size.x;
side = GR_TEXT_HJUSTIFY_RIGHT;
case 0: /* pin on left side*/
m_Pos.x = Sheet->m_Pos.x;
SetSchematicTextOrientation( 2 ); /* Orientation horiz inverse */
break;
case 1: /* pin on right side*/
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
SetSchematicTextOrientation( 0 ); /* Orientation horiz normal */
break;
case 2: /* pin on top side*/
m_Pos.y = Sheet->m_Pos.y;
SetSchematicTextOrientation( 3 ); /* Orientation vert BOTTOM */
break;
case 3: /* pin on bottom side*/
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
SetSchematicTextOrientation( 1 ); /* Orientation vert UP */
break;
}
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 );
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 );
return m_Edge;
}
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape
/* ConstraintOnEdge is used to ajust label position to egde based
* on proximity to vertical / horizontal edge.
* used by sheetlab and resize
*/
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos )
{
wxSize size = m_Size;
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
aCorner_list.clear();
if( m_Edge )
if( Sheet == NULL )
return;
if( m_Edge<2 ) /*horizontal sheetpin*/
{
size.x = -size.x;
size.y = -size.y;
if( Pos.x > ( Sheet->m_Pos.x + ( Sheet->m_Size.x / 2 ) ) )
{
SetEdge( 1 );
}
else
{
SetEdge( 0 );
}
int size2 = size.x / 2;
aCorner_list.push_back( Pos );
switch( m_Shape )
m_Pos.y = Pos.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;
}
else /* vertical sheetpin*/
{
case 0: /* input |> */
aCorner_list.push_back( wxPoint( Pos.x, Pos.y - size2 ) );
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y - size2 ) );
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y ) );
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y + size2 ) );
aCorner_list.push_back( wxPoint( Pos.x, Pos.y + size2 ) );
aCorner_list.push_back( Pos );
break;
if( Pos.y > ( Sheet->m_Pos.y + ( Sheet->m_Size.y / 2 ) ) )
{
SetEdge( 3 ); //bottom
}
else
{
SetEdge( 2 ); //top
}
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 <> */
case 3: /* TriSt <> */
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y - size2 ) );
aCorner_list.push_back( wxPoint( Pos.x + size.x, Pos.y ) );
aCorner_list.push_back( wxPoint( Pos.x + size2, Pos.y + size2 ) );
aCorner_list.push_back( Pos );
break;
default: /* unsp []*/
aCorner_list.push_back( wxPoint( Pos.x, 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, Pos.y + size2 ) );
aCorner_list.push_back( Pos );
break;
m_Pos.x = Pos.x;
if( m_Pos.x < Sheet->m_Pos.x )
m_Pos.x = Sheet->m_Pos.x;
if( m_Pos.x > (Sheet->m_Pos.x + Sheet->m_Size.x) )
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
}
@ -235,8 +195,24 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const
if( m_Text.IsEmpty() )
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';
break;
case 2: //pin on top side
side = 'T';
break;
case 3: //pin on bottom side
side = 'B';
break;
}
switch( m_Shape )
{
@ -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)
void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os )
{

View File

@ -8,6 +8,7 @@
#include "common.h"
#include "program.h"
#include "general.h"
#include "trigo.h"
#include "class_marker_sch.h"
#include "erc.h"
@ -147,3 +148,25 @@ void SCH_MARKER::DisplayInfo( WinEDA_DrawFrame* aFrame )
aFrame->AppendMsgPanel( _( "Electronics rule check error" ),
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;
}

View File

@ -11,7 +11,8 @@
/* Marker are mainly used to show an ERC error
*/
enum TypeMarker { /* Markers type */
enum TypeMarker {
/* Markers type */
MARK_UNSPEC,
MARK_ERC,
MARK_PCB,
@ -68,6 +69,7 @@ public:
return HitTestMarker( aPosRef );
}
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
@ -79,6 +81,7 @@ public:
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -88,16 +91,14 @@ public:
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position)
{
m_Pos.x -= aYaxis_position;
m_Pos.x = - m_Pos.x;
m_Pos.x += aYaxis_position;
}
virtual void Mirror_Y( int aYaxis_position );
virtual void Rotate( wxPoint rotationPoint );
virtual void Mirror_X( int aXaxis_position );
/**
* Compare DRC marker main and auxiliary text against search string.
@ -116,6 +117,7 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};

View File

@ -17,6 +17,7 @@
#include "gr_basic.h"
#include "drawtxt.h"
#include "macros.h"
#include "trigo.h"
#include "program.h"
#include "general.h"
@ -153,13 +154,16 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
* the bounding box calculations.
*/
#if 0
// Draw boundary box:
int x1 = BoundaryBox.GetX();
int y1 = BoundaryBox.GetY();
int x2 = BoundaryBox.GetRight();
int y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
// Draw the text anchor point
/* Calculate the text position, according to the component
* orientation/mirror */
textpos = m_Pos - parentComponent->m_Pos;
@ -420,3 +424,9 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
return SCH_ITEM::Matches( m_Text, aSearchData );
}
void SCH_FIELD::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
}

View File

@ -47,6 +47,7 @@ public:
return wxT( "SCH_FIELD" );
}
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
EDA_Rect GetBoundaryBox() const;
@ -58,9 +59,11 @@ public:
bool IsVoid()
{
size_t len = m_Text.Len();
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
}
void SwapData( SCH_FIELD* copyitem );
/** Function ImportValues
@ -83,6 +86,7 @@ public:
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
}
/**
* Function Draw
*/
@ -102,6 +106,7 @@ public:
bool Save( FILE* aFile ) const;
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -111,6 +116,18 @@ public:
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
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
@ -123,6 +140,7 @@ public:
* master class */
}
/**
* Compare schematic field text against search string.
*

View File

@ -7,6 +7,7 @@
#include "class_drawpanel.h"
#include "gr_basic.h"
#include "common.h"
#include "trigo.h"
#include "program.h"
#include "general.h"
@ -329,7 +330,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet )
h_ref = tokenizer.GetNextToken();
/* printf( "GetRef hpath: %s\n",
CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */
* CONV_TO_UTF8( m_PathsAndReferences[ii] ) ); */
return h_ref;
}
}
@ -397,10 +398,12 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
wxString prefix = ref;
while( prefix.Last() == '?' or isdigit( prefix.Last() ) )
prefix.RemoveLast();
if( m_PrefixString != prefix )
m_PrefixString = prefix;
}
/** function SetTimeStamp
* Change the old time stamp to the new time stamp.
* the time stamp is also modified in paths
@ -409,6 +412,7 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
void SCH_COMPONENT::SetTimeStamp( long aNewTimeStamp )
{
wxString string_timestamp, string_oldtimestamp;
string_timestamp.Printf( wxT( "%8.8X" ), aNewTimeStamp );
string_oldtimestamp.Printf( wxT( "%8.8X" ), m_TimeStamp );
m_TimeStamp = aNewTimeStamp;
@ -421,6 +425,7 @@ void SCH_COMPONENT::SetTimeStamp( long aNewTimeStamp)
/***********************************************************/
//returns the unit selection, for the given sheet path.
/***********************************************************/
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.
/****************************************************************************/
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet,
@ -508,6 +514,7 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField )
{
int newNdx = m_Fields.size();
m_Fields.push_back( aField );
return &m_Fields[newNdx];
}
@ -520,6 +527,7 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
if( aFieldName == m_Fields[i].m_Name )
return &m_Fields[i];
}
return NULL;
}
@ -536,6 +544,7 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
return Entry->GetPin( number, m_Multi, m_Convert );
}
/**
* Function GetBoundaryBox
* returns the orthogonal, bounding box of this object for display purposes.
@ -612,6 +621,7 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
{
copyitem->GetField( ii )->SetParent( copyitem );
}
for( int ii = 0; ii < GetFieldCount(); ++ii )
{
GetField( ii )->SetParent( this );
@ -709,6 +719,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet )
/******************************************************************/
/* Compute the new matrix transform for a schematic component
* in order to have the requested transform (type_rotate = rot, mirror..)
* which is applied to the initial transform.
@ -876,7 +887,8 @@ int SCH_COMPONENT::GetOrientation()
// list of all possibilities, but only the first 8 are actually used
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_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_Y + CMP_ORIENT_0, CMP_MIRROR_Y + CMP_ORIENT_90,
@ -954,6 +966,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
<< ">\n";
}
#endif
@ -988,6 +1001,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
#else
if( Name1[ii] <= ' ' )
#endif
Name1[ii] = '~';
}
@ -996,10 +1010,13 @@ bool SCH_COMPONENT::Save( FILE* f ) const
strncpy( Name2, CONV_TO_UTF8( m_ChipName ), sizeof( Name2 ) );
for( ii = 0; ii < (int) strlen( Name2 ); ii++ )
#if defined(KICAD_GOST)
if( Name2[ii] == ' ' )
#else
if( Name2[ii] <= ' ' )
#endif
Name2[ii] = '~';
}
else
@ -1158,6 +1175,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN );
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
@ -1165,6 +1183,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
void SCH_COMPONENT::Mirror_Y( int aYaxis_position )
{
int dx = m_Pos.x;
SetOrientation( CMP_MIRROR_Y );
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
@ -1180,6 +1199,48 @@ void SCH_COMPONENT::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_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.
@ -1187,6 +1248,7 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
// in multi parts per package
// the .m_AddExtraText of the field msut be set to add this identifier:
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry && Entry->GetPartCount() > 1 )
GetField( REFERENCE )->m_AddExtraText = true;
else

View File

@ -25,6 +25,7 @@ struct Error
{
}
Error( const wxString& aMsg ) :
errorText( aMsg )
{
@ -152,6 +153,7 @@ public:
return new SCH_COMPONENT( *this );
}
void SetOrientation( int aOrientation );
/** function GetOrientation()
@ -242,6 +244,7 @@ public:
m_Fields = aFields; // vector copying, length is changed possibly
}
//-----</Fields>----------------------------------------------------------
/**
@ -267,6 +270,7 @@ public:
Draw( panel, DC, offset, draw_mode, Color, true );
}
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
@ -318,6 +322,7 @@ public:
virtual int GetPenSize() { return 0; }
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -329,11 +334,15 @@ public:
GetField( ii )->Move( aMoveVector );
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis 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.

View File

@ -5,7 +5,7 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "class_drawpanel.h"
#include "trigo.h"
#include "common.h"
#include "program.h"
#include "general.h"
@ -97,6 +97,7 @@ bool SCH_BUS_ENTRY::Save( FILE* aFile ) const
EDA_Rect SCH_BUS_ENTRY::GetBoundingBox()
{
EDA_Rect box;
box.SetOrigin( m_Pos );
box.SetEnd( m_End() );
@ -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 */
/**********************/
@ -156,7 +182,6 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
}
SCH_JUNCTION* SCH_JUNCTION::GenCopy()
{
SCH_JUNCTION* newitem = new SCH_JUNCTION( m_Pos );
@ -191,6 +216,7 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const
EDA_Rect SCH_JUNCTION::GetBoundingBox()
{
EDA_Rect rect;
rect.SetOrigin( m_Pos );
rect.Inflate( ( GetPenSize() + m_Size.x ) / 2 );
@ -241,6 +267,28 @@ void SCH_JUNCTION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
}
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)
void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
{
@ -284,6 +332,7 @@ EDA_Rect SCH_NO_CONNECT::GetBoundingBox()
{
int delta = ( GetPenSize() + m_Size.x ) / 2;
EDA_Rect box;
box.SetOrigin( m_Pos );
box.Inflate( delta );
@ -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 */
/******************/
@ -431,6 +502,7 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os )
<< GetClass().Lower().mb_str() << ">\n";
}
#endif
@ -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 */
/***********************/
@ -648,3 +749,34 @@ void SCH_POLYLINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
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 );
}
}

View File

@ -74,6 +74,7 @@ public:
virtual int GetPenSize();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -86,22 +87,18 @@ public:
m_End += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void 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;
}
virtual void Mirror_X( int aXaxis_position );
virtual void Mirror_Y( int aYaxis_position );
virtual void Rotate( wxPoint rotationPoint );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};
@ -158,6 +155,7 @@ public:
EDA_Rect GetBoundingBox();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -167,16 +165,14 @@ public:
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position)
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
};
@ -233,6 +229,7 @@ public:
virtual int GetPenSize();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -242,17 +239,14 @@ public:
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position)
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
NEGATE( m_Size.x );
}
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
};
class SCH_POLYLINE : public SCH_ITEM
@ -293,6 +287,7 @@ public:
m_PolyPoints.push_back( point );
}
/** Function GetCornerCount
* @return the number of corners
*/
@ -305,6 +300,7 @@ public:
virtual int GetPenSize();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -314,19 +310,15 @@ public:
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
m_PolyPoints[ii] += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void 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;
}
}
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
};
@ -371,6 +363,7 @@ public:
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode, int Color = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
@ -381,6 +374,7 @@ public:
bool Save( FILE* aFile ) const;
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the displacement vector
@ -390,19 +384,18 @@ public:
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position)
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};

View File

@ -218,10 +218,18 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position )
dx = LenSize( m_Text ) / 2;
break;
case 1: /* Vert Orientation UP */
dx = -m_Size.x / 2;
break;
case 2: /* invert horizontal text*/
dx = -LenSize( m_Text ) / 2;
break;
case 3: /* Vert Orientation BOTTOM */
dx = m_Size.x / 2;
break;
default:
dx = 0;
break;
@ -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)
* @return the offset between the SCH_TEXT position and the text itself
* 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
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis 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)
* @return the offset between the SCH_TEXT position and the text itself
* position
@ -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
* 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 )
/*****************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
SCH_TEXT( pos, text, aType )
{
/*****************************************************************************/
m_Layer = LAYER_HIERLABEL;

View File

@ -49,7 +49,6 @@ protected:
* Saving file
*/
public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString,
@ -143,7 +142,10 @@ public:
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Rotate( wxPoint rotationPoint );
virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position );
/**
* Compare schematic text entry against search string.
@ -201,6 +203,8 @@ public:
* wire)
*/
virtual wxPoint GetSchematicTextOffset();
virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint );
/**
* Function GetBoundingBox
@ -300,6 +304,8 @@ public:
* @param aYaxis_position = the y axis 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
{
public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
const wxString& text = wxEmptyString, KICAD_T aType = TYPE_SCH_HIERLABEL );
~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
@ -381,6 +387,8 @@ public:
* @param aYaxis_position = the y axis 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 */

View File

@ -100,6 +100,14 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
TestLabelForDangling( (SCH_LABEL*) item, this, DC );
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:
#undef STRUCT
#define STRUCT ( (SCH_LINE*) item )
@ -118,7 +126,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
break;
default:
;
break;
}
}
}

View File

@ -435,7 +435,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break;
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 )
{
// Find the schematic object to rotate under the cursor
@ -465,6 +469,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
switch( DrawStruct->Type() )
{
case DRAW_SHEET_STRUCT_TYPE: //TODO allow sheet rotate on hotkey
//wxPostEvent( this, eventRotateSheet );
break;
case TYPE_SCH_COMPONENT:
wxPostEvent( this, eventRotateComponent );
break;
@ -487,6 +494,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break;
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 )
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() );
if( DrawStruct )
@ -501,6 +513,11 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break;
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 )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )

View File

@ -19,7 +19,6 @@
using namespace std;
static void AddMenusForBlock( wxMenu* PopMenu, 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 );
@ -223,7 +222,8 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
{
wxString msg;
if( !Field->m_Flags ){
if( !Field->m_Flags )
{
msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
@ -630,6 +630,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
{
wxString msg;
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm );
PopMenu->AppendSeparator();
@ -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_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_X_BLOCK, _( "Mirror Block --" ), mirror_V_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ), rotate_pos_xpm );
#if 0
#ifdef __WINDOWS__
ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD,

View File

@ -1,8 +1,8 @@
/***************************************************
* operations_on_item_lists.cpp
* functions used in block commands, on lists of schematic items:
* move, mirror, delete and copy
****************************************************/
* functions used in block commands, or undo/redo,
* to move, mirror, delete, copy ... lists of schematic items
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
@ -14,9 +14,17 @@
#include "class_marker_sch.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,
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 )
}
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
* Move a list of items to a given move vector
* @param aItemsList = list of picked items
@ -68,7 +87,8 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
/* this item is depending on a sheet, and is not in global list */
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected \
wxMessageBox( wxT(
"DeleteItemsInList() err: unexpected \
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) );
}
else
@ -250,7 +270,8 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone )
NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy();
if( aClone )
{
((SCH_SHEET*)NewDrawStruct)->m_SheetName = ((SCH_SHEET*)aDrawStruct)->m_SheetName;
( (SCH_SHEET*) NewDrawStruct )->m_SheetName =
( (SCH_SHEET*) aDrawStruct )->m_SheetName;
}
break;

View File

@ -242,6 +242,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
switch( aSchText->Type() )
{
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL:
@ -293,7 +294,8 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
aSchText->m_Pos );
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,
aSchText->m_Pos );
@ -307,6 +309,8 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size;
wxString Text;
int name_orientation;
wxPoint pos_sheetname, pos_filename;
wxPoint pos;
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
@ -326,18 +330,32 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->line_to( 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 */
Text = Struct->m_SheetName;
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 = Clamp_Text_PenSize( thickness, size, false );
plotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
bool italic = false;
plotter->text( pos, txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
plotter->text( pos_sheetname, txtcolor,
Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false );
@ -349,17 +367,17 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
plotter->text( wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ),
txtcolor, Text, TEXT_ORIENT_HORIZ, size,
plotter->text( pos_filename, txtcolor,
Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false );
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
/* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN& pin_sheet, Struct->GetSheetPins() )
{
pin_sheet.Plot( plotter );
BOOST_FOREACH( SCH_SHEET_PIN & pin_sheet, Struct->GetSheetPins() ) {
//pin_sheet.Plot( plotter );
PlotTextStruct( plotter, &pin_sheet );
}
}

View File

@ -323,7 +323,7 @@ error line %d, aborted\n" ),
if( size == 0 )
size = DEFAULT_SIZE_TEXT;
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] )
{
case 'I':
@ -347,9 +347,22 @@ error line %d, aborted\n" ),
break;
}
if( Char2[0] == 'R' )
SheetLabelStruct->m_Edge = 1;
switch( Char2[0] )
{
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 );
}
}

View File

@ -137,11 +137,13 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_CMP:
case ID_POPUP_SCH_DELETE:
// Stop the current command (if any) but keep the current tool
DrawPanel->UnManageCursor();
break;
default:
// Stop the current command and deselect the current tool
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor =
wxCURSOR_ARROW;
@ -412,6 +414,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST:
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..) or a hierachical sheet
// or a label
@ -423,6 +426,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
break;
// fall through
case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
DrawPanel->MouseToCursorSchema();
@ -435,6 +439,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( !HandleBlockBegin( &dc, BLOCK_DRAG,
screen->m_Curseur ) )
break;
// Give a non null size to the search block:
screen->m_BlockLocate.Inflate( 1 );
HandleBlockEnd( &dc );
@ -446,6 +451,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
DrawPanel->MouseToCursorSchema();
// The easiest way to handle a drag component is to simulate a
// block drag command
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
@ -453,6 +459,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( !HandleBlockBegin( &dc, BLOCK_DRAG,
screen->m_Curseur ) )
break;
// Ensure the block selection contains the segment, or one end of
// the segment. The initial rect is only one point (w = h = 0)
// The rect must contains one or 2 ends.
@ -462,8 +469,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
// only if they do not cross a component
// TODO: a better way to drag only wires
SCH_LINE* segm = (SCH_LINE*) screen->GetCurItem();
if( !screen->m_BlockLocate.Inside(segm->m_Start) &&
!screen->m_BlockLocate.Inside(segm->m_End) )
if( !screen->m_BlockLocate.Inside( segm->m_Start )
&& !screen->m_BlockLocate.Inside( segm->m_End ) )
{
screen->m_BlockLocate.SetOrigin( segm->m_Start );
screen->m_BlockLocate.SetEnd( segm->m_End );
@ -686,6 +693,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_MIRROR_X_BLOCK:
DrawPanel->MouseToCursorSchema();
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
break;
case ID_POPUP_MIRROR_Y_BLOCK:
DrawPanel->MouseToCursorSchema();
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );

View File

@ -157,8 +157,7 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
#undef DEST
#define SOURCE ( (SCH_SHEET_PIN*) aItem )
#define DEST ( (SCH_SHEET_PIN*) aImage )
EXCHG( SOURCE->m_Edge, DEST->m_Edge );
EXCHG( SOURCE->m_Shape, DEST->m_Shape );
DEST->SwapData( SOURCE );
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
@ -180,7 +179,6 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
}
/** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list.
*
@ -276,7 +274,9 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
const wxPoint& aTransformPoint )
{
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
// Copy picker list:
commandToUndo->CopyList( aItemsList );
@ -296,6 +296,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
switch( command )
{
case UR_CHANGED: /* Create a copy of item */
/* If needed, create a copy of item, and put in undo list
* in the picker, as link
* If this link is not null, the copy is already done
@ -307,6 +308,8 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
case UR_MOVED:
case UR_MIRRORED_Y:
case UR_MIRRORED_X:
case UR_ROTATED:
case UR_NEW:
case UR_DELETED:
break;
@ -389,6 +392,22 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
}
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:
/* Exchange the current wires and the old wires */
alt_item = GetScreen()->ExtractWires( false );

View File

@ -20,7 +20,7 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static int s_CurrentTypeLabel = NET_INPUT;
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 int s_InitialEdge;
/****************************************/
/* class WinEDA_PinSheetPropertiesFrame */
@ -126,6 +126,7 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
EndModal( wxID_OK );
}
/* Called when aborting a move pinsheet label
* delete a new pin sheet label, or restire its old position
*/
@ -145,13 +146,9 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
{
RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode );
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 );
SheetLabel->m_Flags = 0;
}
@ -165,6 +162,7 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
wxASSERT( Sheet != NULL && Sheet->Type() == DRAW_SHEET_STRUCT_TYPE );
SAFE_DELETE( g_ItemToUndoCopy );
@ -180,27 +178,12 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{
wxPoint tmp = m_Pos;
m_Pos = s_InitialPosition;
m_Edge = 0;
if( m_Pos.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
m_Edge = 1;
SetEdge( s_InitialEdge );
frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
m_Pos = tmp;
}
m_Pos.x = Sheet->m_Pos.x;
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;
ConstraintOnEdge( frame->GetScreen()->m_Curseur );
RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
frame->DrawPanel->ManageCurseur = NULL;
@ -215,6 +198,7 @@ void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel,
s_CurrentTypeLabel = SheetLabel->m_Shape;
SheetLabel->m_Flags |= IS_MOVED;
s_InitialPosition = SheetLabel->m_Pos;
s_InitialEdge = SheetLabel->GetEdge();
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
@ -229,27 +213,10 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( SheetLabel == NULL )
return;
SCH_SHEET* Sheet = (SCH_SHEET*) SheetLabel->GetParent();
if( Sheet == NULL )
return;
if( erase )
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
SheetLabel->m_Edge = 0;
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;
SheetLabel->ConstraintOnEdge( panel->GetScreen()->m_Curseur );
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
}

View File

@ -79,6 +79,9 @@ public:
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position) = 0;
virtual void Mirror_X(int aXaxis_position) = 0;
virtual void Rotate(wxPoint rotationPoint) = 0;
/**
* Function Save

View File

@ -97,7 +97,7 @@ wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap
{
wxPoint buttPos = m_ButtonLastPosition;
wxSize buttSize;
int btn_margin = 8;
int btn_margin = 10;
buttSize.x = aBitmap.GetWidth() + btn_margin;
buttSize.y = aBitmap.GetHeight() + btn_margin;
buttPos.y -= buttSize.y;