Commit 2a7ac9d3 authored by charras's avatar charras

fixed a recent bug in pcbnew print and plot dialogs: fine scale adjust displayed as 0.0

Rework on undo/redo and block functions: more efficient code to undo/redo block move and mirror operations
parent 618df99c
......@@ -424,7 +424,7 @@ WinEDA_DFloatValueCtrl::WinEDA_DFloatValueCtrl( wxWindow* parent,
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
buffer.Printf( wxT( "%lf" ), m_Value );
buffer.Printf( wxT( "%f" ), m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, buffer );
BoxSizer->Add( m_ValueCtrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
......@@ -453,7 +453,7 @@ void WinEDA_DFloatValueCtrl::SetValue( double new_value )
m_Value = new_value;
buffer.Printf( wxT( "%lf" ), m_Value );
buffer.Printf( wxT( "%f" ), m_Value );
m_ValueCtrl->SetValue( buffer );
}
......
......@@ -26,12 +26,12 @@ set(EESCHEMA_SRCS
class_netlist_object.cpp
class_pin.cpp
class_sch_cmp_field.cpp
class_sch_component.cpp
class_schematic_items.cpp
class_sch_screen.cpp
class_text-label.cpp
classes_body_items.cpp
cleanup.cpp
component_class.cpp
controle.cpp
cross-probing.cpp
dangling_ends.cpp
......@@ -73,7 +73,6 @@ set(EESCHEMA_SRCS
erc.cpp
files-io.cpp
find.cpp
geometric_transforms.cpp
getpart.cpp
hierarch.cpp
hotkeys.cpp
......@@ -94,6 +93,7 @@ set(EESCHEMA_SRCS
netlist.cpp
onleftclick.cpp
onrightclick.cpp
operations_on_items_lists.cpp
pinedit.cpp
# pinedit-dialog.cpp
plot.cpp
......
This diff is collapsed.
......@@ -705,6 +705,27 @@ void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame )
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void DrawSheetStruct::Mirror_Y(int aYaxis_position)
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
m_Pos.x -= m_Size.x;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label != NULL )
{
label->Mirror_Y( aYaxis_position );
label = label->Next();
}
}
#if defined(DEBUG)
void DrawSheetStruct::Show( int nestLevel, std::ostream& os )
{
......
......@@ -70,6 +70,28 @@ public:
* @param Pos = Position of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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_Edge = m_Edge ? 0 : 1;
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
};
......@@ -224,6 +246,28 @@ public:
//to remove a sheet, just delete it
//-- the destructor should take care of everything else.
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Pos += aMoveVector;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label != NULL )
{
label->Move( aMoveVector );
label = label->Next();
}
}
/** 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);
#if defined (DEBUG)
// comment inherited by Doxygen from Base_Struct
......
......@@ -77,6 +77,27 @@ public:
virtual EDA_Rect GetBoundingBox();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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;
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
......
......@@ -78,6 +78,28 @@ public:
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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)
{
/* 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
*/
}
};
......
/***********************************************************************/
/* component_class.cpp : handle the class SCH_COMPONENT */
/***********************************************************************/
/**************************************************************/
/* class_sch_component.cpp : handle the class SCH_COMPONENT */
/**************************************************************/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
......@@ -14,14 +13,8 @@
#include "protos.h"
#include <wx/arrimpl.cpp>
#include <wx/tokenzr.h>
#include "component_class.h"
WX_DEFINE_OBJARRAY( ArrayOfSheetLists );
/* Local variables */
static EDA_LibComponentStruct* DummyCmp;
......@@ -148,6 +141,7 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
}
/*******************************************************************/
SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
SCH_ITEM( aParent, TYPE_SCH_COMPONENT )
......@@ -797,7 +791,7 @@ void SCH_COMPONENT::SetRotationMiroir( int type_rotate )
default:
Transform = FALSE;
DisplayError( NULL, wxT( "SetRotateMiroir() error: ill value" ) );
wxMessageBox( wxT( "SetRotateMiroir() error: ill value" ) );
break;
}
......@@ -873,7 +867,7 @@ int SCH_COMPONENT::GetRotationMiroir()
}
// Error: orientation not found in list (should not happen)
DisplayError(NULL, wxT("Component orientation matrix internal error") );
wxMessageBox(wxT("Component orientation matrix internal error") );
memcpy( m_Transform, ComponentMatOrient, sizeof( ComponentMatOrient ) );
return CMP_NORMAL;
}
......@@ -1093,3 +1087,23 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
DARKCYAN );
}
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_COMPONENT::Mirror_Y(int aYaxis_position)
{
int dx = m_Pos.x;
SetRotationMiroir( CMP_MIROIR_Y );
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
dx -= m_Pos.x; // dx,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.x -= dx;
}
}
......@@ -285,7 +285,25 @@ public:
*/
virtual int GetPenSize( ) { return 0; }
#if defined (DEBUG)
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
m_Pos += aMoveVector;
for( int ii = 0; ii < GetFieldCount(); ii++ )
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);
#if defined (DEBUG)
/**
* Function Show
......
......@@ -69,6 +69,33 @@ public:
*/
virtual int GetPenSize( );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
if( (m_Flags & STARTPOINT) == 0 )
m_Start += aMoveVector;
if( (m_Flags & ENDPOINT) == 0 )
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;
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
......@@ -116,6 +143,26 @@ public:
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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;
}
};
......@@ -162,6 +209,27 @@ public:
*/
virtual int GetPenSize( );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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 );
}
};
class DrawPolylineStruct : public SCH_ITEM /* Polyligne (serie de segments) */
......@@ -213,6 +281,29 @@ public:
*/
virtual int GetPenSize( );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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;
}
}
};
......@@ -257,6 +348,27 @@ public:
*/
bool Save( FILE* aFile ) const;
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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;
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
......
......@@ -186,6 +186,31 @@ wxPoint SCH_LABEL::GetSchematicTextOffset()
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_TEXT::Mirror_Y(int aYaxis_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 px = m_Pos.x;
int dx;
if( m_Orient == 0 ) /* horizontal text */
dx = LenSize( m_Text ) / 2;
else if( m_Orient == 2 ) /* invert horizontal text*/
dx = -LenSize( m_Text ) / 2;
else
dx = 0;
px += dx;
px -= aYaxis_position;
NEGATE(px);
px += aYaxis_position;
px -= dx;
m_Pos.x = px;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* This offset depend on orientation, and the type of text
......@@ -221,6 +246,41 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset()
return text_offset;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_HIERLABEL::Mirror_Y(int aYaxis_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
if( m_Orient == 0 ) /* horizontal text */
m_Orient = 2;
else if( m_Orient == 2 ) /* invert horizontal text*/
m_Orient = 0;
m_Pos.x -= aYaxis_position;
NEGATE(m_Pos.x);
m_Pos.x += aYaxis_position;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_GLOBALLABEL::Mirror_Y(int aYaxis_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
if( m_Orient == 0 ) /* horizontal text */
m_Orient = 2;
else if( m_Orient == 2 ) /* invert horizontal text*/
m_Orient = 0;
m_Pos.x -= aYaxis_position;
NEGATE(m_Pos.x);
m_Pos.x += aYaxis_position;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
......
......@@ -102,6 +102,21 @@ public:
*/
int GetPenSize( );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
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);
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
......@@ -209,6 +224,12 @@ public:
* @param Pos = Position of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
/** 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);
};
......@@ -268,6 +289,11 @@ public:
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
/** 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);
};
#endif /* CLASS_TEXT_LABEL_H */
......@@ -9,7 +9,6 @@
#include "drawtxt.h"
#include "program.h"
#include "libcmp.h"
#include "component_class.h"
#include "general.h"
#include "trigo.h"
#include "protos.h"
......
This diff is collapsed.
......@@ -258,9 +258,8 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
DrawStructsInGhost( panel, DC, Component, wxPoint(0,0) );
}
move_vector.x = screen->m_Curseur.x - Component->m_Pos.x;
move_vector.y = screen->m_Curseur.y - Component->m_Pos.y;
MoveOneStruct( Component, move_vector );
move_vector = screen->m_Curseur - Component->m_Pos;
Component->Move( move_vector );
DrawStructsInGhost( panel, DC, Component, wxPoint(0,0) );
}
......@@ -327,15 +326,9 @@ static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC )
}
else if( Component ) /* Deplacement ancien composant en cours */
{
wxPoint move_vector;
move_vector.x = OldPos.x - Component->m_Pos.x;
move_vector.y = OldPos.y - Component->m_Pos.y;
MoveOneStruct( Component, move_vector );
wxPoint move_vector = OldPos - Component->m_Pos;
Component->Move( move_vector );
memcpy( Component->m_Transform, OldTransMat, sizeof(OldTransMat) );
Component->m_Flags = 0;
}
......
/***************************************************
* operations_on_item_lists.cpp
* functions used in block commands, on lists of schematic items:
* move, mirror, delete anc copy
****************************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h"
/* Exported Functions */
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, const wxPoint aMoveVector );
/*****************************************************************************
* Routine to Mirror objects. *
*****************************************************************************/
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
item->Mirror_Y( aMirrorPoint.x ); // Place it in its new position.
item->m_Flags = 0;
}
}
/** Function MoveItemsInList
* Move a list of items to a givent move vector
* @param aItemsList = list of picked items
* @param aMoveVector = the move vector value
*/
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector )
{
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
item->Move( aMoveVector );
}
}
/** function DeleteItemsInList
* delete schematic items in aItemsList
* deleted items are put in undo list
*/
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
{
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->m_Parent;
PICKED_ITEMS_LIST itemsList;
ITEM_PICKER itemWrapper;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
itemWrapper.m_Item = item;
itemWrapper.m_UndoRedoStatus = UR_DELETED;
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 DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) );
#if 0
Hierarchical_PIN_Sheet_Struct* pinlabel = (Hierarchical_PIN_Sheet_Struct*) item;
frame->DeleteSheetLabel( false, pinlabel->m_Parent );
itemWrapper.m_Item = pinlabel->m_Parent;
itemWrapper.m_UndoRedoStatus = UR_CHANGED;
itemsList.PushItem( itemWrapper );
#endif
}
else
{
screen->RemoveFromDrawList( item );
/* Unlink the structure */
item->SetNext( 0 );
item->SetBack( 0 );
itemsList.PushItem( itemWrapper );
}
}
frame->SaveCopyInUndoList( itemsList, UR_DELETED );
}
/*********************************************************************************/
void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
/*********************************************************************************/
/* Routine to delete an object from global drawing object list.
* Object is put in Undo list
*/
{
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->m_Parent;
if( !DrawStruct )
return;
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
/* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct
*) DrawStruct )->GetParent(),
UR_CHANGED );
frame->DeleteSheetLabel( DC ? true : false,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct );
return;
}
else /* structure classique */
{
screen->RemoveFromDrawList( DrawStruct );
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
/* Unlink the structure */
DrawStruct->SetNext( 0 );
DrawStruct->SetBack( 0 ); // Only one struct -> no link
frame->SaveCopyInUndoList( DrawStruct, UR_DELETED );
}
}
/*****************************************************************************/
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector )
/*****************************************************************************/
/* Routine to copy a new entity of an object for each object in list and reposition it.
* Return the new created object list in aItemsList
*/
{
SCH_ITEM* newitem;
if( aItemsList.GetCount() == 0 )
return;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetItemData( ii ) );
aItemsList.SetItem( newitem, ii );
aItemsList.SetItemStatus( UR_NEW, ii );
{
switch( newitem->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
default:
break;
case DRAW_SHEET_STRUCT_TYPE:
{
DrawSheetStruct* sheet = (DrawSheetStruct*) newitem;
sheet->m_TimeStamp = GetTimeStamp();
sheet->SetSon( NULL );
break;
}
case TYPE_SCH_COMPONENT:
( (SCH_COMPONENT*) newitem )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL );
break;
}
SetaParent( newitem, screen );
newitem->SetNext( screen->EEDrawList );
screen->EEDrawList = newitem;
}
}
MoveItemsInList( aItemsList, aMoveVector );
}
/************************************************************/
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
/************************************************************/
/* Routine to create a new copy of given struct.
* The new object is not put in draw list (not linked)
*/
{
SCH_ITEM* NewDrawStruct = NULL;
if( DrawStruct == NULL )
{
wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) );
return NULL;
}
switch( DrawStruct->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
NewDrawStruct = ( (DrawPolylineStruct*) DrawStruct )->GenCopy();
break;
case DRAW_SEGMENT_STRUCT_TYPE:
NewDrawStruct = ( (EDA_DrawLineStruct*) DrawStruct )->GenCopy();
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
NewDrawStruct = ( (DrawBusEntryStruct*) DrawStruct )->GenCopy();
break;
case DRAW_JUNCTION_STRUCT_TYPE:
NewDrawStruct = ( (DrawJunctionStruct*) DrawStruct )->GenCopy();
break;
case DRAW_MARKER_STRUCT_TYPE:
NewDrawStruct = ( (MARKER_SCH*) DrawStruct )->GenCopy();
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
NewDrawStruct = ( (DrawNoConnectStruct*) DrawStruct )->GenCopy();
break;
case TYPE_SCH_TEXT:
NewDrawStruct = ( (SCH_TEXT*) DrawStruct )->GenCopy();
break;
case TYPE_SCH_LABEL:
NewDrawStruct = ( (SCH_LABEL*) DrawStruct )->GenCopy();
break;
case TYPE_SCH_HIERLABEL:
NewDrawStruct = ( (SCH_HIERLABEL*) DrawStruct )->GenCopy();
break;
case TYPE_SCH_GLOBALLABEL:
NewDrawStruct = ( (SCH_GLOBALLABEL*) DrawStruct )->GenCopy();
break;
case TYPE_SCH_COMPONENT:
NewDrawStruct = ( (SCH_COMPONENT*) DrawStruct )->GenCopy();
break;
case DRAW_SHEET_STRUCT_TYPE:
NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy();
break;
default:
{
wxString msg;
msg << wxT( "DuplicateStruct error: unexpected StructType " ) <<
DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass();
wxMessageBox( msg );
}
break;
}
NewDrawStruct->m_Image = DrawStruct;
return NewDrawStruct;
}
......@@ -10,7 +10,7 @@
#include "base_struct.h"
#include "sch_item_struct.h"
#include "component_class.h"
#include "class_sch_component.h"
#include "class_sch_screen.h"
#include "class_drawsheet.h"
#include "class_drawsheetpath.h"
......
......@@ -93,9 +93,6 @@ char * StrPurge(char * text);
/* BLOCK.CPP */
/************/
SCH_ITEM * DuplicateStruct(SCH_ITEM *DrawStruct);
void MoveOneStruct(SCH_ITEM *DrawStructs, const wxPoint & move_vector);
/* Given a structure move it by move_vector. */
void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *DrawStruct);
/*************/
......
......@@ -13,9 +13,6 @@
#include "class_marker_sch.h"
// Imported functions
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& aMirrorPoint );
/* Functions to undo and redo edit commands.
* commmands to undo are stored in CurrentScreen->m_UndoList
* commmands to redo are stored in CurrentScreen->m_RedoList
......@@ -344,6 +341,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
{
SCH_ITEM* item;
SCH_ITEM* alt_item;
bool as_moved = false;
for( unsigned ii = 0; ii < aList->GetCount(); ii++ )
{
......@@ -371,17 +369,14 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
break;
case UR_MOVED:
{
wxPoint moveVector = - aList->m_TransformPoint;
MoveOneStruct( item, moveVector );
aList->m_TransformPoint = moveVector;
}
item->Move( - aList->m_TransformPoint );
as_moved = true;
break;
case UR_MIRRORED_Y:
{
wxPoint mirrorPoint = aList->m_TransformPoint;
MirrorOneStruct( item, mirrorPoint );
item->Mirror_Y( mirrorPoint.x );
}
break;
......@@ -411,6 +406,10 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
break;
}
}
// Undo for move transform needs to change the general move vector:
if ( as_moved )
aList->m_TransformPoint = - aList->m_TransformPoint;
}
......
......@@ -485,9 +485,8 @@ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
else /* Move Sheet */
{
move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x;
move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y;
MoveOneStruct( Sheet, move_vector );
move_vector = screen->m_Curseur - Sheet->m_Pos;
Sheet->Move( move_vector );
}
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
......
......@@ -62,9 +62,22 @@ public:
int Color = -1 ) = 0;
/* fonction de placement */
/* Place function */
virtual void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
*/
virtual void Move(const wxPoint& aMoveVector) = 0;
/** 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) = 0;
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
......
......@@ -238,9 +238,9 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
// Create scale adjust option
msg.Printf( wxT( "%lf" ), m_XScaleAdjust );
msg.Printf( wxT( "%f" ), m_XScaleAdjust );
m_FineAdjustXscaleOpt->SetValue( msg );
msg.Printf( wxT( "%lf" ), m_YScaleAdjust );
msg.Printf( wxT( "%f" ), m_YScaleAdjust );
m_FineAdjustYscaleOpt->SetValue( msg );
if( GetSizer() )
......
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