From 3097b919edee317ffe06c02904c60c23e73dece7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 13 Jul 2010 12:42:32 +0200 Subject: [PATCH] Pcbnew: Added grid origin patch from Lorenzo Marcantonio. Converted set grid dialog from DialogBlocks to wxFormBuilder, and added in this dialog the grid origin parameters settings. --- CHANGELOG.txt | 7 + bitmaps/CMakeLists.txt | 1 + bitmaps/grid_select_axis.xpm | 28 + common/base_screen.cpp | 6 + common/drawframe.cpp | 1 + common/drawpanel.cpp | 33 ++ common/zoom.cpp | 13 +- include/bitmaps.h | 1 + include/class_base_screen.h | 2 + include/class_drawpanel.h | 2 + include/wxstruct.h | 1 + pcbnew/CMakeLists.txt | 1 + pcbnew/dialog_set_grid.fbp | 806 ++++++++++++++++++++++++++++ pcbnew/dialog_set_grid_base.cpp | 113 ++++ pcbnew/dialog_set_grid_base.h | 66 +++ pcbnew/edit.cpp | 4 + pcbnew/modedit.cpp | 4 + pcbnew/modedit_onclick.cpp | 7 + pcbnew/moduleframe.cpp | 3 + pcbnew/onleftclick.cpp | 7 + pcbnew/pcbframe.cpp | 4 + pcbnew/pcbnew_id.h | 1 + pcbnew/set_grid.cpp | 279 +++------- pcbnew/set_grid.h | 108 ---- pcbnew/set_grid.pjd | 923 -------------------------------- pcbnew/set_grid.rc | 1 - pcbnew/tool_modedit.cpp | 5 + pcbnew/tool_onrightclick.cpp | 4 + pcbnew/tool_pcb.cpp | 7 +- 29 files changed, 1201 insertions(+), 1237 deletions(-) create mode 100644 bitmaps/grid_select_axis.xpm create mode 100644 pcbnew/dialog_set_grid.fbp create mode 100644 pcbnew/dialog_set_grid_base.cpp create mode 100644 pcbnew/dialog_set_grid_base.h delete mode 100644 pcbnew/set_grid.h delete mode 100644 pcbnew/set_grid.pjd delete mode 100644 pcbnew/set_grid.rc diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 486e1abcab..4e97935c6c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,13 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. +2010-jul-12, UPDATE Jean-Pierre Charras +================================================================================ +++pcbnew: + Added grid origin patch from Lorenzo Marcantonio. + Converted set grid dialog from DialogBlocks to wxFormBuilder, + and added in this dialog the grid origin parameters settings. + 2010-jun-24 UPDATE Wayne Stambaugh ================================================================================ ++EESchema component library and hierarchical sheet label object improvements. diff --git a/bitmaps/CMakeLists.txt b/bitmaps/CMakeLists.txt index 321d3c85e0..9b3ace8b1b 100644 --- a/bitmaps/CMakeLists.txt +++ b/bitmaps/CMakeLists.txt @@ -142,6 +142,7 @@ set(BITMAP_SRCS Global_Options_Pad.xpm green.xpm grid_select.xpm + grid_select_axis.xpm grid.xpm hammer.xpm help.xpm diff --git a/bitmaps/grid_select_axis.xpm b/bitmaps/grid_select_axis.xpm new file mode 100644 index 0000000000..4faac7f65f --- /dev/null +++ b/bitmaps/grid_select_axis.xpm @@ -0,0 +1,28 @@ +/* PM */ +const char *grid_select_axis_xpm[] = { + +/* columns rows colors const chars-per-pixel */ +"16 16 4 1", +" c None", +"o c #000000", +"+ c #FF0000", +". c #600000", + +/* pixels */ +" + ", +"oo +. oo oo ", +"oo +. oo oo ", +" +. ", +" +. ", +"oo +. oo oo ", +"oo +. oo oo ", +" +. ", +" +. ", +"+++++++++++++++ ", +" ...+...........", +" +. ", +" +. ", +"oo +. oo oo ", +"oo +. oo oo ", +" . " +}; diff --git a/common/base_screen.cpp b/common/base_screen.cpp index a77175b2e5..fbee42a0a4 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -478,6 +478,12 @@ GRID_TYPE BASE_SCREEN::GetGrid() return m_Grid; } +/*********************************/ +const wxPoint& BASE_SCREEN::GetGridOrigin() +/*********************************/ +{ + return m_GridOrigin; +} wxRealPoint BASE_SCREEN::GetGridSize() { diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 604e0ff72a..f0e2f030b1 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -72,6 +72,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet. m_Print_Sheet_Ref = TRUE; // TRUE to print reference sheet. m_Draw_Auxiliary_Axis = FALSE; // TRUE draw auxilary axis. + m_Draw_Grid_Axis = FALSE; // TRUE to draw the grid axis m_CursorShape = 0; m_LastGridSizeId = 0; m_DrawGrid = true; // hide/Show grid. default = show diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index ed7d1cf63b..7dc03c4c68 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -739,6 +739,9 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) if( m_Parent->m_Draw_Auxiliary_Axis ) DrawAuxiliaryAxis( DC, GR_COPY ); + + if( m_Parent->m_Draw_Grid_Axis ) + DrawGridAxis( DC, GR_COPY ); } @@ -916,6 +919,36 @@ void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode ) 0, Color ); } +/********************************************************************/ +void WinEDA_DrawPanel::DrawGridAxis( wxDC* DC, int drawmode ) +/********************************************************************/ +{ + BASE_SCREEN* screen = GetScreen(); + if( !m_Parent->m_Draw_Grid_Axis + || ( screen->m_GridOrigin.x == 0 + && screen->m_GridOrigin.y == 0 ) ) + return; + + int Color = m_Parent->GetGridColor(); + + GRSetDrawMode( DC, drawmode ); + + /* Draw the Y axis */ + GRDashedLine( &m_ClipBox, DC, + screen->m_GridOrigin.x, + -screen->ReturnPageSize().y, + screen->m_GridOrigin.x, + screen->ReturnPageSize().y, + 0, Color ); + + /* Draw the X axis */ + GRDashedLine( &m_ClipBox, DC, + -screen->ReturnPageSize().x, + screen->m_GridOrigin.y, + screen->ReturnPageSize().x, + screen->m_GridOrigin.y, + 0, Color ); +} /** Build and display a Popup menu on a right mouse button click * @return true if a popup menu is shown, or false diff --git a/common/zoom.cpp b/common/zoom.cpp index 3f3a6148b5..fccb26759e 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -52,13 +52,16 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) { wxRealPoint grid_size = GetBaseScreen()->GetGridSize(); - if( !GetBaseScreen()->m_UserGridIsON ) + if( !GetBaseScreen()->m_UserGridIsON ) // XXX UNUSED VARIABLE??? { - int tmp = wxRound( (double) coord->x / grid_size.x ); - coord->x = wxRound( (double) tmp * grid_size.x ); + const wxPoint& grid_origin = GetBaseScreen()->GetGridOrigin(); + double offset = fmod(grid_origin.x, grid_size.x); + int tmp = wxRound( (coord->x - offset) / grid_size.x ); + coord->x = wxRound( tmp * grid_size.x + offset ); - tmp = wxRound( (double) coord->y / grid_size.y ); - coord->y = wxRound( (double) tmp * grid_size.y ); + offset = fmod(grid_origin.y, grid_size.y); + tmp = wxRound( (coord->y - offset) / grid_size.y ); + coord->y = wxRound ( tmp * grid_size.y + offset ); } } diff --git a/include/bitmaps.h b/include/bitmaps.h index b014ac0ca5..3b704edbb8 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -134,6 +134,7 @@ extern const char* glabel2text_xpm[]; extern const char* gl_change_xpm[]; extern const char* global_options_pad_xpm[]; extern const char* green_xpm[]; +extern const char* grid_select_axis_xpm[]; extern const char* grid_select_xpm[]; extern const char* grid_xpm[]; extern const char* hammer_xpm[]; diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 37fd0499f0..2251a22c88 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -130,6 +130,7 @@ private: /* Grid and zoom values. */ public: + wxPoint m_GridOrigin; GridArray m_GridList; bool m_UserGridIsON; @@ -321,6 +322,7 @@ public: */ GRID_TYPE GetGrid(); + const wxPoint &GetGridOrigin(); void SetGrid( const wxRealPoint& size ); void SetGrid( int id ); void SetGridList( GridArray& sizelist ); diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index cfa1d7e681..8f52f229b6 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -107,6 +107,8 @@ public: * @param DC = current Device Context */ void DrawAuxiliaryAxis( wxDC* DC, int drawmode ); + void DrawGridAxis( wxDC* DC, int drawmode ); + void OnEraseBackground( wxEraseEvent& event ); void OnActivate( wxActivateEvent& event ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 9cc298e415..5e6b6b31ec 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -169,6 +169,7 @@ public: // for PCBnew and Gerbview bool m_Draw_Axis; // TRUE to show X and Y axis + bool m_Draw_Grid_Axis; /* TRUE to show grid axis. */ bool m_Draw_Sheet_Ref; // TRUE to show frame references bool m_Print_Sheet_Ref; // TRUE to print frame references diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 58ec67504f..d0bdcac66b 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -85,6 +85,7 @@ set(PCBNEW_SRCS dialog_mask_clearance_base.cpp dialog_SVG_print.cpp dialog_SVG_print_base.cpp + dialog_set_grid_base.cpp dist.cpp dragsegm.cpp drc.cpp diff --git a/pcbnew/dialog_set_grid.fbp b/pcbnew/dialog_set_grid.fbp new file mode 100644 index 0000000000..3b6f373210 --- /dev/null +++ b/pcbnew/dialog_set_grid.fbp @@ -0,0 +1,806 @@ + + + + + + C++ + 1 + UTF-8 + connect + dialog_set_grid_base + 1000 + none + 1 + dialog_set_grid + + . + + 1 + 0 + 0 + + + + + 1 + + + + 0 + wxID_ANY + + + DIALOG_SET_GRID_BASE + + 374,267 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + Grid Origin and User Grid Size + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bUpperSizer + wxHORIZONTAL + none + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + User Grid Size + + sbLeftSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + "Inches" "mm" + + 1 + + + 0 + wxID_ANY + Grid Size Units + 1 + + + m_UnitGrid + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 10 + protected + 10 + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + User Grid Size X + + + m_staticTextSizeX + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_OptGridSizeX + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + User Grid Size Y + + + m_staticTextSizeY + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_OptGridSizeY + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 2 + + wxID_ANY + Grid Origin + + sbRightSizer + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + 3 + wxBOTH + 1 + + 0 + + fgSizerGridOrigin + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 5 + wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT + 0 + + + + 1 + + + 0 + wxID_ANY + Grid origin X: + + + m_staticTextGridPosX + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_GridOriginXCtrl + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + + + 0 + wxID_ANY + Inches + + + m_TextPosXUnits + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT + 0 + + + + 1 + + + 0 + wxID_ANY + Grid origin Y: + + + m_staticTextGridPosY + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_GridOriginYCtrl + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + + + 0 + wxID_ANY + Inches + + + m_TextPosYUnits + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + 0 + 1 + + + 0 + wxID_ANY + Reset Grid Origin + + + m_buttonReset + protected + + + + + + + + + OnResetGridOrgClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT|wxTOP|wxBOTTOM + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + OnCancelClick + + + + OnOkClick + + + + + + + + diff --git a/pcbnew/dialog_set_grid_base.cpp b/pcbnew/dialog_set_grid_base.cpp new file mode 100644 index 0000000000..1065a60feb --- /dev/null +++ b/pcbnew/dialog_set_grid_base.cpp @@ -0,0 +1,113 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_set_grid_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bUpperSizer; + bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticBoxSizer* sbLeftSizer; + sbLeftSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Grid Size") ), wxVERTICAL ); + + wxString m_UnitGridChoices[] = { _("Inches"), _("mm") }; + int m_UnitGridNChoices = sizeof( m_UnitGridChoices ) / sizeof( wxString ); + m_UnitGrid = new wxRadioBox( this, wxID_ANY, _("Grid Size Units"), wxDefaultPosition, wxDefaultSize, m_UnitGridNChoices, m_UnitGridChoices, 1, wxRA_SPECIFY_COLS ); + m_UnitGrid->SetSelection( 0 ); + sbLeftSizer->Add( m_UnitGrid, 0, wxALL|wxEXPAND, 5 ); + + + sbLeftSizer->Add( 10, 10, 0, 0, 5 ); + + m_staticTextSizeX = new wxStaticText( this, wxID_ANY, _("User Grid Size X"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextSizeX->Wrap( -1 ); + sbLeftSizer->Add( m_staticTextSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_OptGridSizeX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + sbLeftSizer->Add( m_OptGridSizeX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("User Grid Size Y"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextSizeY->Wrap( -1 ); + sbLeftSizer->Add( m_staticTextSizeY, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_OptGridSizeY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + sbLeftSizer->Add( m_OptGridSizeY, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + bUpperSizer->Add( sbLeftSizer, 1, wxEXPAND|wxALL, 5 ); + + wxStaticBoxSizer* sbRightSizer; + sbRightSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Grid Origin") ), wxVERTICAL ); + + wxFlexGridSizer* fgSizerGridOrigin; + fgSizerGridOrigin = new wxFlexGridSizer( 2, 3, 0, 0 ); + fgSizerGridOrigin->AddGrowableCol( 1 ); + fgSizerGridOrigin->SetFlexibleDirection( wxBOTH ); + fgSizerGridOrigin->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticTextGridPosX = new wxStaticText( this, wxID_ANY, _("Grid origin X:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextGridPosX->Wrap( -1 ); + fgSizerGridOrigin->Add( m_staticTextGridPosX, 0, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + + m_GridOriginXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerGridOrigin->Add( m_GridOriginXCtrl, 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_TextPosXUnits = new wxStaticText( this, wxID_ANY, _("Inches"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextPosXUnits->Wrap( -1 ); + fgSizerGridOrigin->Add( m_TextPosXUnits, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticTextGridPosY = new wxStaticText( this, wxID_ANY, _("Grid origin Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextGridPosY->Wrap( -1 ); + fgSizerGridOrigin->Add( m_staticTextGridPosY, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + + m_GridOriginYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerGridOrigin->Add( m_GridOriginYCtrl, 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_TextPosYUnits = new wxStaticText( this, wxID_ANY, _("Inches"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextPosYUnits->Wrap( -1 ); + fgSizerGridOrigin->Add( m_TextPosYUnits, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + sbRightSizer->Add( fgSizerGridOrigin, 0, wxALL|wxEXPAND, 5 ); + + m_buttonReset = new wxButton( this, wxID_ANY, _("Reset Grid Origin"), wxDefaultPosition, wxDefaultSize, 0 ); + sbRightSizer->Add( m_buttonReset, 0, wxALL|wxEXPAND, 5 ); + + bUpperSizer->Add( sbRightSizer, 2, wxEXPAND|wxALL, 5 ); + + bSizerMain->Add( bUpperSizer, 1, wxEXPAND, 5 ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + bSizerMain->Add( m_sdbSizer1, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5 ); + + this->SetSizer( bSizerMain ); + this->Layout(); + + // Connect Events + m_buttonReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnResetGridOrgClick ), NULL, this ); + m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnCancelClick ), NULL, this ); + m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnOkClick ), NULL, this ); +} + +DIALOG_SET_GRID_BASE::~DIALOG_SET_GRID_BASE() +{ + // Disconnect Events + m_buttonReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnResetGridOrgClick ), NULL, this ); + m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnCancelClick ), NULL, this ); + m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SET_GRID_BASE::OnOkClick ), NULL, this ); +} diff --git a/pcbnew/dialog_set_grid_base.h b/pcbnew/dialog_set_grid_base.h new file mode 100644 index 0000000000..bb6c46cc1c --- /dev/null +++ b/pcbnew/dialog_set_grid_base.h @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_set_grid_base__ +#define __dialog_set_grid_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_SET_GRID_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_SET_GRID_BASE : public wxDialog +{ + private: + + protected: + wxRadioBox* m_UnitGrid; + + wxStaticText* m_staticTextSizeX; + wxTextCtrl* m_OptGridSizeX; + wxStaticText* m_staticTextSizeY; + wxTextCtrl* m_OptGridSizeY; + wxStaticText* m_staticTextGridPosX; + wxTextCtrl* m_GridOriginXCtrl; + wxStaticText* m_TextPosXUnits; + wxStaticText* m_staticTextGridPosY; + wxTextCtrl* m_GridOriginYCtrl; + wxStaticText* m_TextPosYUnits; + wxButton* m_buttonReset; + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Cancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnResetGridOrgClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } + + + public: + DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Origin and User Grid Size"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 374,267 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_SET_GRID_BASE(); + +}; + +#endif //__dialog_set_grid_base__ diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index ce7719f1a3..9b5970fffd 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -251,6 +251,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) SetToolID( id, wxCURSOR_PENCIL, _( "Adjust Zero" ) ); break; + case ID_PCB_PLACE_GRID_COORD_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Adjust Grid Origin" ) ); + break; + case ID_PCB_ADD_LINE_BUTT: case ID_PCB_ARC_BUTT: case ID_PCB_CIRCLE_BUTT: diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 7f0c517885..47ab2925ca 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -458,6 +458,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) SetToolID( id, wxCURSOR_PENCIL, _( "Place anchor" ) ); break; + case ID_PCB_PLACE_GRID_COORD_BUTT: + SetToolID( id, wxCURSOR_PENCIL, _( "Adjust Grid Origin" ) ); + break; + case ID_NO_SELECT_BUTT: SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); break; diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 61325a4377..a8ac024930 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -149,6 +149,13 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), } break; + case ID_PCB_PLACE_GRID_COORD_BUTT: + DrawPanel->DrawGridAxis( DC, GR_XOR ); + GetScreen()->m_GridOrigin = GetScreen()->m_Curseur; + DrawPanel->DrawGridAxis( DC, GR_COPY ); + GetScreen()->SetModify(); + break; + case ID_PCB_ADD_TEXT_BUTT: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); CreateTextModule( GetBoard()->m_Modules, DC ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 06bf424468..be63c59ff7 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -99,6 +99,8 @@ BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame ) WinEDA_ModuleEditFrame::Process_Special_Functions ) EVT_TOOL( ID_MODEDIT_PLACE_ANCHOR, WinEDA_ModuleEditFrame::Process_Special_Functions ) + EVT_TOOL( ID_PCB_PLACE_GRID_COORD_BUTT, + WinEDA_ModuleEditFrame::Process_Special_Functions ) // Vertical toolbar (right click): EVT_TOOL_RCLICKED( ID_MODEDIT_ADD_PAD, @@ -157,6 +159,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, m_FrameName = wxT( "ModEditFrame" ); m_Draw_Sheet_Ref = false; // true to show the frame references m_Draw_Axis = true; // true to show X and Y axis on screen + m_Draw_Grid_Axis = true; // show the grid origin axis m_HotkeysZoomAndGridList = s_Module_Editor_Hokeys_Descr; // Give an icon diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 4f13b0f700..fed6b4e44f 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -374,6 +374,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) OnModify(); break; + case ID_PCB_PLACE_GRID_COORD_BUTT: + DrawPanel->DrawGridAxis( DC, GR_XOR ); + GetScreen()->m_GridOrigin = GetScreen()->m_Curseur; + DrawPanel->DrawGridAxis( DC, GR_COPY ); + GetScreen()->SetModify(); + break; + default: DrawPanel->SetCursor( wxCURSOR_ARROW ); DisplayError( this, wxT( "WinEDA_PcbFrame::OnLeftClick() id error" ) ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index dce8b3253a..b7e5169f52 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -215,6 +215,8 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame ) EVT_TOOL_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD, WinEDA_PcbFrame::ProcessMuWaveFunctions ) +EVT_TOOL( ID_PCB_PLACE_GRID_COORD_BUTT, + WinEDA_PcbFrame::Process_Special_Functions ) EVT_TOOL_RCLICKED( ID_TRACK_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) EVT_TOOL_RCLICKED( ID_PCB_CIRCLE_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) @@ -222,6 +224,7 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame ) EVT_TOOL_RCLICKED( ID_PCB_ADD_TEXT_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) EVT_TOOL_RCLICKED( ID_PCB_ADD_LINE_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) EVT_TOOL_RCLICKED( ID_PCB_DIMENSION_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) + EVT_TOOL_RCLICKED( ID_PCB_PLACE_GRID_COORD_BUTT, WinEDA_PcbFrame::ToolOnRightClick ) EVT_MENU_RANGE( ID_POPUP_PCB_AUTOPLACE_START_RANGE, ID_POPUP_PCB_AUTOPLACE_END_RANGE, @@ -257,6 +260,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, m_Draw_Sheet_Ref = true; // true to display sheet references m_Draw_Axis = false; // true to display X and Y axis m_Draw_Auxiliary_Axis = true; + m_Draw_Grid_Axis = true; m_SelTrackWidthBox = NULL; m_SelViaSizeBox = NULL; m_SelLayerBox = NULL; diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 215b02bb14..47c5bf3128 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -22,6 +22,7 @@ enum pcbnew_ids ID_PCB_MIRE_BUTT, ID_PCB_SHOW_1_RATSNEST_BUTT, ID_PCB_PLACE_OFFSET_COORD_BUTT, + ID_PCB_PLACE_GRID_COORD_BUTT, ID_PCB_MASK_CLEARANCE, ID_PCB_LAYERS_SETUP, ID_PCB_ADD_LINE_BUTT, diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index 8c0729bb99..8af541aae7 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -8,230 +8,72 @@ #include "pcbnew.h" -#include "protos.h" -#include +//#include "protos.h" #include "pcbnew_id.h" +#include "dialog_set_grid_base.h" -#include "set_grid.h" +class DIALOG_SET_GRID: public DIALOG_SET_GRID_BASE +{ + public: + int m_internalUnits; + + public: + DIALOG_SET_GRID( wxWindow* parent, const wxPoint& pos ); + ~DIALOG_SET_GRID() { } + void SetGridSize( const wxRealPoint& grid ); + wxRealPoint GetGridSize(); + void SetGridUnits( int units ); + int GetGridUnits(); + void SetGridOrigin( const wxPoint& grid ); + wxPoint GetGridOrigin(); + + private: + void OnResetGridOrgClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); +}; void WinEDA_BasePcbFrame::InstallGridFrame( const wxPoint& pos ) { - WinEDA_PcbGridFrame dlg( this, pos ); + DIALOG_SET_GRID dlg( this, pos ); - dlg.SetGridSize( m_UserGridSize ); + dlg.m_internalUnits = m_InternalUnits; dlg.SetGridUnits( m_UserGridUnit ); + dlg.SetGridSize( m_UserGridSize ); + dlg.SetGridOrigin( GetScreen()->m_GridOrigin ); if( dlg.ShowModal() == wxID_CANCEL ) return; m_UserGridSize = dlg.GetGridSize(); m_UserGridUnit = (UserUnitType)dlg.GetGridUnits(); + GetScreen()->m_GridOrigin = dlg.GetGridOrigin( ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); - + // If the user grid is the current option, recall SetGrid() // to force new values put in list as current grid value if( GetScreen()->GetGridId() == ID_POPUP_GRID_USER ) GetScreen()->SetGrid( ID_POPUP_GRID_USER ); + DrawPanel->Refresh(); } -/*! - * 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() +DIALOG_SET_GRID::DIALOG_SET_GRID( wxWindow* parent, const wxPoint& pos ) + : DIALOG_SET_GRID_BASE( parent ) { + m_TextPosXUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); + m_TextPosYUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); + + GetSizer()->SetSizeHints( this ); + Centre( ); } -WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent, - const wxPoint& pos, - wxWindowID id, - const wxString& caption, - const wxSize& size, long style ) -{ - 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 - SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); - 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() -{ -////@begin WinEDA_PcbGridFrame content construction - // Generated by DialogBlocks, 06/05/2009 13:48:21 (unregistered) - - WinEDA_PcbGridFrame* itemDialog1 = this; - - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL ); - - itemDialog1->SetSizer( itemBoxSizer2 ); - - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 ); - - 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 ); - 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 -} - - -void WinEDA_PcbGridFrame::SetGridSize( const wxRealPoint& grid ) +void DIALOG_SET_GRID::SetGridSize( const wxRealPoint& grid ) { wxString msg; @@ -242,7 +84,7 @@ void WinEDA_PcbGridFrame::SetGridSize( const wxRealPoint& grid ) } -wxRealPoint WinEDA_PcbGridFrame::GetGridSize() +wxRealPoint DIALOG_SET_GRID::GetGridSize() { wxRealPoint grid; @@ -255,14 +97,53 @@ wxRealPoint WinEDA_PcbGridFrame::GetGridSize() } -void WinEDA_PcbGridFrame::SetGridUnits( int units ) +void DIALOG_SET_GRID::SetGridUnits( int units ) { if( units != INCHES ) m_UnitGrid->SetSelection( 1 ); } - -int WinEDA_PcbGridFrame::GetGridUnits() +int DIALOG_SET_GRID::GetGridUnits() { return m_UnitGrid->GetSelection(); } + +wxPoint DIALOG_SET_GRID::GetGridOrigin() +{ + wxPoint grid; + + /* TODO: Some error checking here would be a good thing. */ + grid.x = ReturnValueFromTextCtrl( *m_GridOriginXCtrl, m_internalUnits ); + grid.y = ReturnValueFromTextCtrl( *m_GridOriginYCtrl, m_internalUnits ); + + return grid; +} + +void DIALOG_SET_GRID::SetGridOrigin( const wxPoint& grid ) +{ + wxString msg; + PutValueInLocalUnits( *m_GridOriginXCtrl, grid.x, m_internalUnits ); + PutValueInLocalUnits( *m_GridOriginYCtrl, grid.y, m_internalUnits ); +} + + +void DIALOG_SET_GRID::OnResetGridOrgClick(wxCommandEvent& event) +{ + wxString msg(_("0") ); + m_GridOriginXCtrl->SetValue(msg); + m_GridOriginYCtrl->SetValue(msg); +} + +/*****************************************************************/ +void DIALOG_SET_GRID::OnCancelClick( wxCommandEvent& event ) +/*****************************************************************/ +{ + EndModal(wxID_CANCEL); +} + +/*************************************************************************/ +void DIALOG_SET_GRID::OnOkClick(wxCommandEvent& event) +/*************************************************************************/ +{ + EndModal(wxID_OK); +} diff --git a/pcbnew/set_grid.h b/pcbnew/set_grid.h deleted file mode 100644 index 2abbea88f2..0000000000 --- a/pcbnew/set_grid.h +++ /dev/null @@ -1,108 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: set_grid.h -// Purpose: -// Author: jean-pierre Charras -// Modified by: -// Created: 26/02/2006 17:24:12 -// RCS-ID: -// Copyright: License GNU -// Licence: -///////////////////////////////////////////////////////////////////////////// - -// Generated by DialogBlocks (unregistered), 26/02/2006 17:24:12 - -#ifndef _SET_GRID_H_ -#define _SET_GRID_H_ - - -/*! - * Includes - */ - -////@begin includes -////@end includes - -/*! - * Forward declarations - */ - -////@begin forward declarations -////@end forward declarations - -/*! - * Control identifiers - */ - -////@begin control identifiers -#define ID_DIALOG 10000 -#define ID_RADIOBOX 10001 -#define ID_TEXTCTRL 10002 -#define ID_TEXTCTRL1 10003 -#define SYMBOL_WINEDA_PCBGRIDFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER -#define SYMBOL_WINEDA_PCBGRIDFRAME_TITLE _("User Grid Size") -#define SYMBOL_WINEDA_PCBGRIDFRAME_IDNAME ID_DIALOG -#define SYMBOL_WINEDA_PCBGRIDFRAME_SIZE wxSize(400, 300) -#define SYMBOL_WINEDA_PCBGRIDFRAME_POSITION wxDefaultPosition -////@end control identifiers - -/*! - * Compatibility - */ - -#ifndef wxCLOSE_BOX -#define wxCLOSE_BOX 0x1000 -#endif - -/*! - * WinEDA_PcbGridFrame class declaration - */ - -class WinEDA_PcbGridFrame: public wxDialog -{ - DECLARE_DYNAMIC_CLASS( WinEDA_PcbGridFrame ) - DECLARE_EVENT_TABLE() - -public: - /// Constructors - WinEDA_PcbGridFrame( ); - WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent, - const wxPoint& pos = SYMBOL_WINEDA_PCBGRIDFRAME_POSITION, - wxWindowID id = SYMBOL_WINEDA_PCBGRIDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGRIDFRAME_TITLE, const wxSize& size = SYMBOL_WINEDA_PCBGRIDFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGRIDFRAME_STYLE ); - - /// Creation - bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBGRIDFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_PCBGRIDFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_PCBGRIDFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_PCBGRIDFRAME_SIZE, long style = SYMBOL_WINEDA_PCBGRIDFRAME_STYLE ); - - /// Creates the controls and sizers - void CreateControls(); - -////@begin WinEDA_PcbGridFrame event handler declarations - -////@end WinEDA_PcbGridFrame event handler declarations - -////@begin WinEDA_PcbGridFrame member function declarations - - /// Retrieves bitmap resources - wxBitmap GetBitmapResource( const wxString& name ); - - /// Retrieves icon resources - wxIcon GetIconResource( const wxString& name ); -////@end WinEDA_PcbGridFrame member function declarations - - /// Should we show tooltips? - static bool ShowToolTips(); - -////@begin WinEDA_PcbGridFrame member variables - wxRadioBox* m_UnitGrid; - wxTextCtrl* m_OptGridSizeX; - wxTextCtrl* m_OptGridSizeY; -////@end WinEDA_PcbGridFrame member variables - - void SetGridUnits( int units ); - int GetGridUnits(); - - void SetGridSize( const wxRealPoint& grid ); - wxRealPoint GetGridSize(); -}; - -#endif - // _SET_GRID_H_ diff --git a/pcbnew/set_grid.pjd b/pcbnew/set_grid.pjd deleted file mode 100644 index 673b7ca018..0000000000 --- a/pcbnew/set_grid.pjd +++ /dev/null @@ -1,923 +0,0 @@ - - -
- 0 - "" - "" - "" - "" - "" - 0 - 0 - 0 - 1 - 1 - 1 - 1 - 0 - "jean-pierre Charras" - "License GNU" - "" - 0 - 0 - 0 - "<All platforms>" - "<Any>" - "///////////////////////////////////////////////////////////////////////////// -// Name: %HEADER-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SOURCE-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SYMBOLS-FILENAME% -// Purpose: Symbols file -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "%HEADER-FILENAME%" -#endif - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "%HEADER-FILENAME%" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -" - " /// %BODY% -" - " -/*! - * %BODY% - */ - -" - "app_resources.h" - "app_resources.cpp" - "AppResources" - "app.h" - "app.cpp" - "Application" - 0 - "" - "<None>" - "<System>" - "utf-8" - "<System>" - "" - 0 - 0 - 4 - " " - "" - 0 - 0 - 1 - 0 - 1 - 1 - 0 - 1 - 0 - 0 -
- - - "" - "data-document" - "" - "" - 0 - 1 - 0 - 0 - - "Configurations" - "config-data-document" - "" - "" - 0 - 1 - 0 - 0 - "" - 1 - -8519680 - "" - "Debug" - "ANSI" - "Static" - "Modular" - "GUI" - "wxMSW" - "Dynamic" - "Yes" - "No" - "No" - "%WXVERSION%" - "%EXECUTABLE%" - "" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - 0 - 1 - "" - - - - - - - "Projects" - "root-document" - "" - "project" - 1 - 1 - 0 - 1 - - "Windows" - "html-document" - "" - "dialogsfolder" - 1 - 1 - 0 - 1 - - "User Grid Size" - "dialog-document" - "" - "dialog" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbDialogProxy" - 10000 - 0 - "" - 0 - "" - 0 - 0 - "ID_DIALOG" - 10000 - "WinEDA_PcbGridFrame" - "wxDialog" - "wxDialog" - "set_grid.cpp" - "set_grid.h" - "" - "User Grid Size" - 0 - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "Tiled" - 0 - 1 - 0 - 1 - 0 - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - "MAYBE_RESIZE_BORDER" - 0 - 1 - -1 - -1 - 400 - 300 - 0 - "" - - "wxBoxSizer H" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "wbBoxSizerProxy" - "Horizontal" - "" - 0 - 0 - 0 - "<Any platform>" - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Expand" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxRadioBox: ID_RADIOBOX" - "dialog-control-document" - "" - "radiobox" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbRadioBoxProxy" - "ID_RADIOBOX" - 10001 - "" - "wxRadioBox" - "wxRadioBox" - 1 - 0 - "" - "" - "m_UnitGrid" - "Grid Size Units" - 1 - "Inches|mm" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 1 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "Spacer" - "dialog-control-document" - "" - "spacer" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbSpacerProxy" - 5 - 5 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "" - "User Grid Size X" - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL" - 10002 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_OptGridSizeX" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - 0 - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "" - "User Grid Size Y" - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL1" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL1" - 10003 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_OptGridSizeY" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - 0 - - - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxButton: wxID_OK" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbButtonProxy" - "wxID_OK" - 5100 - "" - "wxButton" - "wxButton" - 1 - 0 - "" - "" - "" - "&OK" - 1 - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "wxButton: wxID_CANCEL" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "26/3/2006" - "wbButtonProxy" - "wxID_CANCEL" - 5101 - "" - "wxButton" - "wxButton" - 1 - 0 - "" - "" - "" - "&Cancel" - 0 - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - - - - - "Sources" - "html-document" - "" - "sourcesfolder" - 1 - 1 - 0 - 1 - - "set_grid.rc" - "source-editor-document" - "set_grid.rc" - "source-editor" - 0 - 0 - 1 - 0 - "26/3/2006" - "" - - - - "Images" - "html-document" - "" - "bitmapsfolder" - 1 - 1 - 0 - 1 - - - - -
diff --git a/pcbnew/set_grid.rc b/pcbnew/set_grid.rc deleted file mode 100644 index b86c4e2265..0000000000 --- a/pcbnew/set_grid.rc +++ /dev/null @@ -1 +0,0 @@ -#include "wx/msw/wx.rc" diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index 9086da6e26..b0043a2f85 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -181,6 +181,11 @@ void WinEDA_ModuleEditFrame::ReCreateVToolbar() wxBitmap( delete_body_xpm ), _( "Delete items" ), wxITEM_CHECK ); + m_VToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString, + wxBitmap( grid_select_axis_xpm ), + _( "Set the origin point for the grid" ), + wxITEM_CHECK ); + m_VToolBar->Realize(); SetToolbars(); diff --git a/pcbnew/tool_onrightclick.cpp b/pcbnew/tool_onrightclick.cpp index 2ca7dc9214..88fe48e3c7 100644 --- a/pcbnew/tool_onrightclick.cpp +++ b/pcbnew/tool_onrightclick.cpp @@ -41,6 +41,10 @@ void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event ) OnConfigurePcbOptions( event ); break; + case ID_PCB_PLACE_GRID_COORD_BUTT: + InstallGridFrame( wxDefaultPosition ); + break; + default: break; } diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 9838b2535c..1621547843 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -463,6 +463,11 @@ void WinEDA_PcbFrame::ReCreateVToolbar() _( "Offset adjust for drill and place files" ), wxITEM_CHECK ); + m_VToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString, + wxBitmap( grid_select_axis_xpm ), + _( "Set the origin point for the grid" ), + wxITEM_CHECK ); + m_VToolBar->Realize(); SetToolbars(); } @@ -638,7 +643,7 @@ an existing track use its width\notherwise, use current width setting" ), m_InternalUnits ); if( grid.m_Id != ID_POPUP_GRID_USER ) { - switch( g_UserUnit ) + switch( g_UserUnit ) { case INCHES: msg.Printf( format.GetData(), value * 1000 );