2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************/
|
|
|
|
/* set_grid.cpp - Gestion de la grille utilisateur */
|
|
|
|
/***************************************************/
|
|
|
|
/*
|
|
|
|
Affichage et modifications des parametres de travail de PcbNew
|
|
|
|
Parametres = dimensions de la grille utilisateur
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
#include <wx/spinctrl.h>
|
|
|
|
|
2008-12-05 16:03:05 +00:00
|
|
|
#include "id.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "set_grid.h"
|
|
|
|
|
2009-02-07 20:11:09 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/************************************************************/
|
|
|
|
void WinEDA_BasePcbFrame::InstallGridFrame(const wxPoint & pos)
|
|
|
|
{
|
|
|
|
WinEDA_PcbGridFrame dlg( this, pos );
|
2008-12-05 16:03:05 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
dlg.SetGridSize( m_UserGridSize );
|
|
|
|
dlg.SetGridUnits( m_UserGridUnits );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
m_UserGridSize = dlg.GetGridSize();
|
|
|
|
m_UserGridUnits = dlg.GetGridUnits();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
|
|
|
|
DrawPanel->Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbGridFrame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbGridFrame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbGridFrame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_PcbGridFrame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_PcbGridFrame event table entries
|
|
|
|
////@end WinEDA_PcbGridFrame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbGridFrame constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent,
|
2008-12-05 16:03:05 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxSize& size, long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
Create(parent, id, caption, pos, size, style);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbGridFrame creator
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_PcbGridFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
|
|
|
{
|
|
|
|
////@begin WinEDA_PcbGridFrame member initialisation
|
|
|
|
m_UnitGrid = NULL;
|
|
|
|
m_OptGridSizeX = NULL;
|
|
|
|
m_OptGridSizeY = NULL;
|
|
|
|
////@end WinEDA_PcbGridFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_PcbGridFrame creation
|
2009-05-01 18:06:03 +00:00
|
|
|
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
2007-06-05 12:10:51 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
|
|
|
if (GetSizer())
|
|
|
|
{
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
}
|
|
|
|
////@end WinEDA_PcbGridFrame creation
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_PcbGridFrame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbGridFrame::CreateControls()
|
2008-12-05 16:03:05 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
////@begin WinEDA_PcbGridFrame content construction
|
2009-05-06 17:13:09 +00:00
|
|
|
// Generated by DialogBlocks, 06/05/2009 13:48:21 (unregistered)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
WinEDA_PcbGridFrame* itemDialog1 = this;
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
itemDialog1->SetSizer(itemBoxSizer2);
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);
|
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
wxArrayString m_UnitGridStrings;
|
|
|
|
m_UnitGridStrings.Add(_("Inches"));
|
|
|
|
m_UnitGridStrings.Add(_("mm"));
|
|
|
|
m_UnitGrid = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid Size Units"), wxDefaultPosition, wxDefaultSize, m_UnitGridStrings, 1, wxRA_SPECIFY_COLS );
|
2007-06-05 12:10:51 +00:00
|
|
|
m_UnitGrid->SetSelection(0);
|
|
|
|
itemBoxSizer3->Add(m_UnitGrid, 0, wxGROW|wxALL, 5);
|
|
|
|
|
|
|
|
itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Grid Size X"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer3->Add(itemStaticText6, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
|
|
|
|
|
|
|
|
m_OptGridSizeX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer3->Add(m_OptGridSizeX, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Grid Size Y"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer3->Add(itemStaticText8, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
|
|
|
|
|
|
|
|
m_OptGridSizeY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer3->Add(m_OptGridSizeY, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemBoxSizer2->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemButton11->SetDefault();
|
|
|
|
itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
|
|
|
////@end WinEDA_PcbGridFrame content construction
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_PcbGridFrame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_PcbGridFrame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_PcbGridFrame bitmap retrieval
|
|
|
|
wxUnusedVar(name);
|
|
|
|
return wxNullBitmap;
|
|
|
|
////@end WinEDA_PcbGridFrame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_PcbGridFrame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_PcbGridFrame icon retrieval
|
|
|
|
wxUnusedVar(name);
|
|
|
|
return wxNullIcon;
|
|
|
|
////@end WinEDA_PcbGridFrame icon retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_PcbGridFrame::SetGridSize( const wxRealPoint& grid )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg.Printf( wxT( "%.4f" ), grid.x );
|
|
|
|
m_OptGridSizeX->SetValue( msg );
|
|
|
|
msg.Printf( wxT( "%.4f" ), grid.y );
|
|
|
|
m_OptGridSizeY->SetValue( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxRealPoint WinEDA_PcbGridFrame::GetGridSize()
|
|
|
|
{
|
|
|
|
wxRealPoint grid;
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: Some error checking here would be a good thing. */
|
|
|
|
m_OptGridSizeX->GetValue().ToDouble( &grid.x );
|
|
|
|
m_OptGridSizeY->GetValue().ToDouble( &grid.y );
|
|
|
|
|
|
|
|
return grid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinEDA_PcbGridFrame::SetGridUnits( int units )
|
|
|
|
{
|
|
|
|
if ( units != INCHES )
|
|
|
|
m_UnitGrid->SetSelection( 1 );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
int WinEDA_PcbGridFrame::GetGridUnits()
|
|
|
|
{
|
|
|
|
return m_UnitGrid->GetSelection();
|
|
|
|
}
|