2007-08-20 01:20:48 +00:00
|
|
|
|
/*********************************************/
|
|
|
|
|
/* Routines de gestion des mires de centrage */
|
|
|
|
|
/*********************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Exit_EditMire( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
|
static void Montre_Position_Mire( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
/* Variables locales : */
|
|
|
|
|
static wxPoint OldPos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static int MireDefaultSize = 5000;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
enum id_mire_properties {
|
|
|
|
|
ID_ACCEPT_MIRE_PROPERTIES = 1900,
|
|
|
|
|
ID_CANCEL_MIRE_PROPERTIES,
|
|
|
|
|
ID_SIZE_MIRE,
|
|
|
|
|
ID_LISTBOX_SHAPE_MIRE
|
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
|
|
|
|
|
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Constructor and destructor
|
|
|
|
|
WinEDA_MirePropertiesFrame( WinEDA_PcbFrame* parent,
|
|
|
|
|
MIREPCB* Mire, wxDC* DC, const wxPoint& pos );
|
2007-09-01 12:00:30 +00:00
|
|
|
|
~WinEDA_MirePropertiesFrame()
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void MirePropertiesAccept( wxCommandEvent& event );
|
|
|
|
|
void OnQuit( 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 )
|
|
|
|
|
EVT_BUTTON( ID_ACCEPT_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::MirePropertiesAccept )
|
|
|
|
|
EVT_BUTTON( ID_CANCEL_MIRE_PROPERTIES, WinEDA_MirePropertiesFrame::OnQuit )
|
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
|
|
|
|
/***************************************************************/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
WinEDA_MirePropertiesFrame* frame = new WinEDA_MirePropertiesFrame( this,
|
|
|
|
|
MirePcb, DC, pos );
|
|
|
|
|
|
|
|
|
|
frame->ShowModal(); frame->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame( WinEDA_PcbFrame* parent,
|
|
|
|
|
MIREPCB* Mire, wxDC* DC,
|
|
|
|
|
const wxPoint& framepos ) :
|
|
|
|
|
wxDialog( parent, -1, _( "Mire properties" ), framepos, wxSize( 270, 210 ),
|
|
|
|
|
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;
|
|
|
|
|
SetFont( *g_DialogFont );
|
|
|
|
|
m_DC = DC;
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
|
/* Creation des boutons de commande */
|
|
|
|
|
Button = new wxButton( this, ID_ACCEPT_MIRE_PROPERTIES, _( "Ok" ) );
|
|
|
|
|
Button->SetForegroundColour( *wxRED );
|
|
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
|
|
Button = new wxButton( this, ID_CANCEL_MIRE_PROPERTIES, _( "Cancel" ) );
|
|
|
|
|
Button->SetForegroundColour( *wxBLUE );
|
|
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
|
|
// Size:
|
|
|
|
|
m_MireSizeCtrl = new WinEDA_ValueCtrl( this, _( "Size" ),
|
|
|
|
|
m_MirePcb->m_Size,
|
|
|
|
|
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
|
|
// Width:
|
|
|
|
|
m_MireWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ),
|
|
|
|
|
m_MirePcb->m_Width,
|
|
|
|
|
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
|
|
// Shape
|
|
|
|
|
wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) };
|
|
|
|
|
m_MireShape = new wxRadioBox( this, ID_LISTBOX_SHAPE_MIRE,
|
|
|
|
|
_( "Mire Shape:" ),
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_MirePropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************************/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Close( true ); // true is to force the frame to close
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_MirePropertiesFrame::MirePropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Met a jour les differents parametres pour le composant en cours d'<27>dition
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR );
|
2007-05-06 16:03:28 +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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_MirePcb->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
Close( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MirePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
|
|
|
|
DeleteStructure( MirePcb );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Exit_EditMire( 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;
|
|
|
|
|
|
|
|
|
|
if( MirePcb )
|
|
|
|
|
{
|
|
|
|
|
/* Effacement de la mire */
|
|
|
|
|
MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
|
|
|
|
|
|
|
|
|
|
if( MirePcb->m_Flags & IS_NEW )
|
|
|
|
|
{
|
|
|
|
|
MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
|
|
|
|
|
DeleteStructure( MirePcb );
|
|
|
|
|
MirePcb = NULL;
|
|
|
|
|
}
|
|
|
|
|
else /* Ancienne mire en deplacement: Remise en ancienne position */
|
|
|
|
|
{
|
|
|
|
|
MirePcb->m_Pos = OldPos;
|
|
|
|
|
MirePcb->m_Flags = 0;
|
|
|
|
|
MirePcb->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR );
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine de creation d'un Draw Symbole Pcb type MIRE
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MIREPCB* MirePcb = new MIREPCB( m_Pcb );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MirePcb->Pnext = m_Pcb->m_Drawings;
|
|
|
|
|
MirePcb->Pback = m_Pcb;
|
|
|
|
|
if( m_Pcb->m_Drawings )
|
|
|
|
|
m_Pcb->m_Drawings->Pback = MirePcb;
|
|
|
|
|
m_Pcb->m_Drawings = MirePcb;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
MirePcb->SetLayer( EDGE_N );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MirePcb->m_Width = g_DesignSettings.m_EdgeSegmentWidth;
|
|
|
|
|
MirePcb->m_Size = MireDefaultSize;
|
|
|
|
|
MirePcb->m_Pos = 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-08-20 01:20:48 +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
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine d'initialisation du deplacement d'une mire
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( MirePcb == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
OldPos = MirePcb->m_Pos;
|
|
|
|
|
MirePcb->m_Flags |= IS_MOVED;
|
|
|
|
|
DrawPanel->ManageCurseur = Montre_Position_Mire;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_EditMire;
|
|
|
|
|
GetScreen()->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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MirePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MirePcb->m_Flags = 0;
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Montre_Position_Mire( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************************************/
|
|
|
|
|
/* redessin du contour de la piste lors des deplacements de la souris */
|
|
|
|
|
{
|
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
|
|
|
|
/* efface ancienne position */
|
|
|
|
|
if( erase )
|
|
|
|
|
MirePcb->Draw( panel, DC, wxPoint( 0, 0 ), 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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
// Reaffichage
|
|
|
|
|
MirePcb->Draw( panel, DC, wxPoint( 0, 0 ), GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|