2009-11-18 12:52:19 +00:00
|
|
|
/********************************************/
|
|
|
|
/* Functions to edit targets (class MIRE) */
|
|
|
|
/********************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-08-03 07:55:08 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Routines Locales */
|
2009-08-03 07:55:08 +00:00
|
|
|
static void AbortMoveAndEditTarget( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2009-11-18 12:52:19 +00:00
|
|
|
static void ShowTargetShapeWhileMovingMouse( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-08-03 07:55:08 +00:00
|
|
|
/* Local variables : */
|
2007-08-20 01:20:48 +00:00
|
|
|
static int MireDefaultSize = 5000;
|
2009-11-18 12:52:19 +00:00
|
|
|
static MIREPCB s_TargetCopy( NULL ); /* Used to store "old" values of the
|
|
|
|
* current item parameters before
|
|
|
|
* edition (used in undo/redo or
|
|
|
|
* cancel operations)
|
2009-08-03 07:55:08 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
|
|
|
/* class WinEDA_MirePropertiesFrame */
|
|
|
|
/************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
class WinEDA_MirePropertiesFrame : public wxDialog
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_PcbFrame* m_Parent;
|
|
|
|
wxDC* m_DC;
|
|
|
|
MIREPCB* m_MirePcb;
|
|
|
|
WinEDA_ValueCtrl* m_MireWidthCtrl;
|
|
|
|
WinEDA_ValueCtrl* m_MireSizeCtrl;
|
|
|
|
wxRadioBox* m_MireShape;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
public: WinEDA_MirePropertiesFrame( WinEDA_PcbFrame* parent,
|
|
|
|
MIREPCB* Mire,
|
|
|
|
wxDC* DC,
|
|
|
|
const wxPoint& pos );
|
2007-10-11 04:56:44 +00:00
|
|
|
~WinEDA_MirePropertiesFrame() { }
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
private:
|
2009-08-03 07:55:08 +00:00
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_MirePropertiesFrame, wxDialog )
|
2009-11-18 12:52:19 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_MirePropertiesFrame::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_MirePropertiesFrame::OnCancelClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::InstallMireOptionsFrame( MIREPCB* MirePcb,
|
|
|
|
wxDC* DC, const wxPoint& pos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
WinEDA_MirePropertiesFrame* frame =
|
|
|
|
new WinEDA_MirePropertiesFrame( this, MirePcb, DC, pos );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-10-11 04:56:44 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame(
|
|
|
|
WinEDA_PcbFrame* parent,
|
|
|
|
MIREPCB* Mire, wxDC* DC,
|
|
|
|
const wxPoint& framepos ) :
|
2007-10-10 14:08:26 +00:00
|
|
|
wxDialog( parent, -1, _( "Target Properties" ), framepos, wxSize( 270, 210 ),
|
2007-08-20 01:20:48 +00:00
|
|
|
DIALOG_STYLE )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString number;
|
|
|
|
wxButton* Button;
|
|
|
|
|
|
|
|
m_Parent = parent;
|
2009-08-03 07:55:08 +00:00
|
|
|
m_DC = DC;
|
2007-08-20 01:20:48 +00:00
|
|
|
Centre();
|
|
|
|
|
|
|
|
m_MirePcb = Mire;
|
|
|
|
|
|
|
|
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
SetSizer( MainBoxSizer );
|
|
|
|
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create of the command buttons. */
|
2007-10-11 04:56:44 +00:00
|
|
|
Button = new wxButton( this, wxID_OK, _( "OK" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2007-10-11 04:56:44 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
// Size:
|
|
|
|
m_MireSizeCtrl = new WinEDA_ValueCtrl( this, _( "Size" ),
|
|
|
|
m_MirePcb->m_Size,
|
2009-11-18 12:52:19 +00:00
|
|
|
g_UnitMetric, LeftBoxSizer,
|
|
|
|
m_Parent->m_InternalUnits );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Width:
|
|
|
|
m_MireWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ),
|
|
|
|
m_MirePcb->m_Width,
|
2009-11-18 12:52:19 +00:00
|
|
|
g_UnitMetric, LeftBoxSizer,
|
|
|
|
m_Parent->m_InternalUnits );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Shape
|
|
|
|
wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) };
|
2009-10-28 11:48:47 +00:00
|
|
|
m_MireShape = new wxRadioBox( this, wxID_ANY,
|
2007-10-10 14:08:26 +00:00
|
|
|
_( "Target Shape:" ),
|
2007-08-20 01:20:48 +00:00
|
|
|
wxDefaultPosition, wxSize( -1, -1 ),
|
|
|
|
2, shape_list, 1 );
|
|
|
|
m_MireShape->SetSelection( m_MirePcb->m_Shape ? 1 : 0 );
|
|
|
|
LeftBoxSizer->Add( m_MireShape, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_MirePropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED(
|
|
|
|
event ) )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-11 04:56:44 +00:00
|
|
|
EndModal( -1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Updates the different parameters for the component being edited
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_MirePropertiesFrame::OnOkClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Save old item in undo list, if is is not currently edited (will be later
|
|
|
|
// if so)
|
2009-08-03 07:55:08 +00:00
|
|
|
if( m_MirePcb->m_Flags == 0 )
|
|
|
|
m_Parent->SaveCopyInUndoList( m_MirePcb, UR_CHANGED );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( m_MirePcb->m_Flags != 0 ) // other edition in progress (MOVE,
|
|
|
|
// NEW ..)
|
|
|
|
m_MirePcb->m_Flags |= IN_EDIT; // set flag in edit to force
|
|
|
|
// undo/redo/abort proper operation
|
2009-08-03 07:55:08 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_MirePcb->m_Width = m_MireWidthCtrl->GetValue();
|
|
|
|
MireDefaultSize = m_MirePcb->m_Size = m_MireSizeCtrl->GetValue();
|
|
|
|
m_MirePcb->m_Shape = m_MireShape->GetSelection() ? 1 : 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_MirePcb->Draw( m_Parent->DrawPanel, m_DC,
|
|
|
|
( m_MirePcb->m_Flags & IS_MOVED ) ? GR_XOR : GR_OR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
m_Parent->OnModify();
|
2007-10-11 04:56:44 +00:00
|
|
|
EndModal( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
void WinEDA_PcbFrame::Delete_Mire( MIREPCB* MirePcb, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( MirePcb == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
MirePcb->Draw( DrawPanel, DC, GR_XOR );
|
2009-08-03 07:55:08 +00:00
|
|
|
SaveCopyInUndoList( MirePcb, UR_DELETED );
|
2009-07-29 13:10:36 +00:00
|
|
|
MirePcb->UnLink();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-03 07:55:08 +00:00
|
|
|
static void AbortMoveAndEditTarget( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
BASE_SCREEN* screen = Panel->GetScreen();
|
|
|
|
MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem();
|
|
|
|
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2009-12-21 12:05:36 +00:00
|
|
|
( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL );
|
2009-08-03 07:55:08 +00:00
|
|
|
|
|
|
|
if( MirePcb == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
MirePcb->Draw( Panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-03 07:55:08 +00:00
|
|
|
if( MirePcb->m_Flags & IS_NEW ) // If it is new, delete it
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
MirePcb->Draw( Panel, DC, GR_XOR );
|
2009-08-03 07:55:08 +00:00
|
|
|
MirePcb->DeleteStructure();
|
|
|
|
MirePcb = NULL;
|
|
|
|
}
|
|
|
|
else /* it is an existing item: retrieve initial values of parameters */
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( MirePcb->m_Flags & (IN_EDIT | IS_MOVED) ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
MirePcb->m_Pos = s_TargetCopy.m_Pos;
|
2009-08-03 07:55:08 +00:00
|
|
|
MirePcb->m_Width = s_TargetCopy.m_Width;
|
|
|
|
MirePcb->m_Size = s_TargetCopy.m_Size;
|
|
|
|
MirePcb->m_Shape = s_TargetCopy.m_Shape;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-03 07:55:08 +00:00
|
|
|
MirePcb->m_Flags = 0;
|
|
|
|
MirePcb->Draw( Panel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Draw Symbol PCB type MIRE.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
MIREPCB* MirePcb = new MIREPCB( GetBoard() );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-08-03 07:55:08 +00:00
|
|
|
MirePcb->m_Flags = IS_NEW;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( MirePcb );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
MirePcb->SetLayer( EDGE_N );
|
2010-01-31 20:01:46 +00:00
|
|
|
MirePcb->m_Width = GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth;
|
2007-08-20 01:20:48 +00:00
|
|
|
MirePcb->m_Size = MireDefaultSize;
|
2010-01-23 10:50:05 +00:00
|
|
|
MirePcb->m_Pos = DrawPanel->GetScreen()->m_Curseur;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Place_Mire( MirePcb, DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return MirePcb;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Routine to initialize the displacement of a focal
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_PcbFrame::StartMove_Mire( MIREPCB* MirePcb, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( MirePcb == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
s_TargetCopy = *MirePcb;
|
2007-08-20 01:20:48 +00:00
|
|
|
MirePcb->m_Flags |= IS_MOVED;
|
2009-08-03 07:55:08 +00:00
|
|
|
DrawPanel->ManageCurseur = ShowTargetShapeWhileMovingMouse;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortMoveAndEditTarget;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( MirePcb );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Place_Mire( MIREPCB* MirePcb, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( MirePcb == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
MirePcb->Draw( DrawPanel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-03 07:55:08 +00:00
|
|
|
|
|
|
|
if( (MirePcb->m_Flags & IS_NEW) )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( MirePcb, UR_NEW );
|
|
|
|
MirePcb->m_Flags = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( MirePcb->m_Flags == IS_MOVED )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
SaveCopyInUndoList( MirePcb,
|
|
|
|
UR_MOVED,
|
|
|
|
MirePcb->m_Pos - s_TargetCopy.m_Pos );
|
2009-08-03 07:55:08 +00:00
|
|
|
MirePcb->m_Flags = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (MirePcb->m_Flags & IN_EDIT) )
|
|
|
|
{
|
|
|
|
SwapData( MirePcb, &s_TargetCopy );
|
|
|
|
SaveCopyInUndoList( MirePcb, UR_CHANGED );
|
|
|
|
SwapData( MirePcb, &s_TargetCopy );
|
|
|
|
}
|
|
|
|
MirePcb->m_Flags = 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Redraw the contour of the track while moving the mouse */
|
|
|
|
static void ShowTargetShapeWhileMovingMouse( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
MIREPCB* MirePcb = (MIREPCB*) screen->GetCurItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( MirePcb == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
2008-04-01 05:21:50 +00:00
|
|
|
MirePcb->Draw( panel, DC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
MirePcb->m_Pos = screen->m_Curseur;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
MirePcb->Draw( panel, DC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|