Pcbnew: fix graphic item undo/redo bug. (--fixes lp:1252264)
* Use std::swap for PCB_LINE_T items in SwapData(). * Use std::swap for PCB_MODULE_EDGE_T items in SwapData(). * Add assignment operator to EDGE_MODULE object. * Move code from copy method to assignment operator. * Minor coding policy fixes.
This commit is contained in:
parent
83a002ff91
commit
abe9801d3d
|
@ -38,6 +38,7 @@
|
|||
#include <class_module.h>
|
||||
#include <class_dimension.h>
|
||||
#include <class_zone.h>
|
||||
#include <class_edge_mod.h>
|
||||
|
||||
|
||||
/* Functions to undo and redo edit commands.
|
||||
|
@ -213,18 +214,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
|||
break;
|
||||
|
||||
case PCB_LINE_T:
|
||||
#if 0
|
||||
EXCHG( ( (DRAWSEGMENT*) aItem )->m_Start, ( (DRAWSEGMENT*) aImage )->m_Start );
|
||||
EXCHG( ( (DRAWSEGMENT*) aItem )->m_End, ( (DRAWSEGMENT*) aImage )->m_End );
|
||||
EXCHG( ( (DRAWSEGMENT*) aItem )->m_Width, ( (DRAWSEGMENT*) aImage )->m_Width );
|
||||
EXCHG( ( (DRAWSEGMENT*) aItem )->m_Shape, ( (DRAWSEGMENT*) aImage )->m_Shape );
|
||||
#else
|
||||
{
|
||||
DRAWSEGMENT tmp = *(DRAWSEGMENT*) aImage;
|
||||
*aImage = *aItem;
|
||||
*aItem = tmp;
|
||||
}
|
||||
#endif
|
||||
std::swap( *((DRAWSEGMENT*)aItem), *((DRAWSEGMENT*)aImage) );
|
||||
break;
|
||||
|
||||
case PCB_TRACE_T:
|
||||
|
|
|
@ -66,17 +66,27 @@ EDGE_MODULE::~EDGE_MODULE()
|
|||
}
|
||||
|
||||
|
||||
const EDGE_MODULE& EDGE_MODULE::operator = ( const EDGE_MODULE& rhs )
|
||||
{
|
||||
if( &rhs == this )
|
||||
return *this;
|
||||
|
||||
DRAWSEGMENT::operator=( rhs );
|
||||
|
||||
m_Start0 = rhs.m_Start0;
|
||||
m_End0 = rhs.m_End0;
|
||||
|
||||
m_PolyPoints = rhs.m_PolyPoints; // std::vector copy
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void EDGE_MODULE::Copy( EDGE_MODULE* source )
|
||||
{
|
||||
if( source == NULL )
|
||||
return;
|
||||
|
||||
DRAWSEGMENT::Copy( source );
|
||||
|
||||
m_Start0 = source->m_Start0;
|
||||
m_End0 = source->m_End0;
|
||||
|
||||
m_PolyPoints = source->m_PolyPoints; // std::vector copy
|
||||
*this = *source;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#define CLASS_EDGE_MOD_H_
|
||||
|
||||
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
#include <class_drawsegment.h>
|
||||
|
||||
|
||||
|
@ -52,6 +54,9 @@ public:
|
|||
EDGE_MODULE* Next() const { return (EDGE_MODULE*) Pnext; }
|
||||
EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; }
|
||||
|
||||
/// skip the linked list stuff, and parent
|
||||
const EDGE_MODULE& operator = ( const EDGE_MODULE& rhs );
|
||||
|
||||
void Copy( EDGE_MODULE* source ); // copy structure
|
||||
|
||||
void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/**
|
||||
* @file dialog_graphic_item_properties.cpp
|
||||
*/
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2010 Jean-Pierre Charras <jp.charras@wanadoo.fr>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -24,6 +22,10 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file dialog_graphic_item_properties.cpp
|
||||
*/
|
||||
|
||||
/* Edit parameters values of graphic items type DRAWSEGMENTS:
|
||||
* Lines
|
||||
* Circles
|
||||
|
@ -48,6 +50,7 @@
|
|||
#include <dialog_graphic_item_properties_base.h>
|
||||
#include <class_pcb_layer_box_selector.h>
|
||||
|
||||
|
||||
class DIALOG_GRAPHIC_ITEM_PROPERTIES: public DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE
|
||||
{
|
||||
private:
|
||||
|
@ -82,9 +85,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_EDIT_FRAME*
|
|||
}
|
||||
|
||||
|
||||
/*******************************************************************************************/
|
||||
void PCB_EDIT_FRAME::InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem, wxDC* aDC )
|
||||
/*******************************************************************************************/
|
||||
{
|
||||
if ( aItem == NULL )
|
||||
{
|
||||
|
@ -99,12 +100,8 @@ void PCB_EDIT_FRAME::InstallGraphicItemPropertiesDialog(DRAWSEGMENT * aItem, wxD
|
|||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( )
|
||||
/**************************************************************************/
|
||||
/* Initialize messages and values in text control,
|
||||
* according to the item parameters values
|
||||
*/
|
||||
{
|
||||
m_StandardButtonsSizerOK->SetDefault();
|
||||
|
||||
|
@ -124,6 +121,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( )
|
|||
{
|
||||
if( texts_unit[ii] == NULL )
|
||||
break;
|
||||
|
||||
texts_unit[ii]->SetLabel( GetAbbreviatedUnitsLabel() );
|
||||
}
|
||||
|
||||
|
@ -148,8 +146,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( )
|
|||
m_EndPointXLabel->SetLabel( _( "Start Point X" ) );
|
||||
m_EndPointYLabel->SetLabel( _( "Start Point Y" ) );
|
||||
|
||||
// Here the angle is a double, but the UI is still working
|
||||
// with integers
|
||||
// Here the angle is a double, but the UI is still working with integers.
|
||||
msg << int( m_Item->GetAngle() );
|
||||
m_Angle_Ctrl->SetValue( msg );
|
||||
break;
|
||||
|
@ -195,9 +192,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( )
|
|||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& event )
|
||||
/*******************************************************************/
|
||||
{
|
||||
int thickness;
|
||||
|
||||
|
@ -209,11 +204,8 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& event )
|
|||
PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness );
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
|
||||
/*******************************************************************/
|
||||
/* Copy values in text control to the item parameters
|
||||
*/
|
||||
{
|
||||
m_parent->SaveCopyInUndoList( m_Item, UR_CHANGED );
|
||||
|
||||
|
|
Loading…
Reference in New Issue