kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #05802
[PATCH] Footprint reference/value text size patch
Hi,
I'm reposting this patch since the original has probably gone missing
due to a non-conformant subject line. The original discussion is in
this thread: https://lists.launchpad.net/kicad-developers/msg05243.html.
The patch adds an item into reference and value text item menus for
resetting the text sizes to current default settings in pcbnew.
Similar items are added into the edit menu to reset reference and
value text sizes globally. This patch has been revised according to
the comments posted by Wayne Stambaugh in the thread the the link
above points to.
marco
=== modified file 'include/wxBasePcbFrame.h'
--- include/wxBasePcbFrame.h 2010-08-11 13:15:30 +0000
+++ include/wxBasePcbFrame.h 2010-11-11 19:13:34 +0000
@@ -251,6 +251,20 @@
void StartMoveTexteModule( TEXTE_MODULE* Text,
wxDC* DC );
TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC );
+ /** Function ResetTextModuleSize
+ * resets given field text size and width to current settings in
+ * Preferences->Dimensions->Texts and Drawings.
+ * @param aText = field to be reset
+ * @param aDC = drawing context
+ */
+ void ResetTextModuleSize( TEXTE_MODULE* aText, wxDC* aDC );
+ /** Function ResetTextModuleSizes
+ * resets text size and width of all fields of given field type
+ * to current settings in Preferences->Dimensions->Texts and Drawings.
+ * @param aType = field type (0 for reference, 1 for value)
+ * @param aDC = drawing context
+ */
+ void ResetTextModuleSizes( int aType, wxDC* aDC );
void InstallPadOptionsFrame( D_PAD* pad );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod,
=== modified file 'pcbnew/class_text_mod.cpp'
--- pcbnew/class_text_mod.cpp 2010-02-08 18:15:42 +0000
+++ pcbnew/class_text_mod.cpp 2010-11-11 19:13:34 +0000
@@ -200,11 +200,25 @@
}
-void TEXTE_MODULE:: SetWidth( int new_width )
-{
- m_Width = new_width;
-}
-
+void TEXTE_MODULE::SetWidth( int aNewWidth )
+{
+ m_Width = aNewWidth;
+}
+
+int TEXTE_MODULE::GetWidth()
+{
+ return m_Width;
+}
+
+void TEXTE_MODULE::SetSize( wxSize aNewSize )
+{
+ m_Size = aNewSize;
+}
+
+wxSize TEXTE_MODULE::GetSize()
+{
+ return m_Size;
+}
// Update draw coordinates
void TEXTE_MODULE:: SetDrawCoord()
=== modified file 'pcbnew/class_text_mod.h'
--- pcbnew/class_text_mod.h 2009-11-12 15:43:38 +0000
+++ pcbnew/class_text_mod.h 2010-11-11 19:13:34 +0000
@@ -45,7 +45,26 @@
void Copy( TEXTE_MODULE* source ); // copy structure
/* Gestion du texte */
- void SetWidth( int new_width );
+ /** Function SetWidth
+ * sets text width
+ * @param aNewWidth = new text width
+ */
+ void SetWidth( int aNewWidth );
+ /** Function GetWidth
+ * returns text width
+ * @return int - text width
+ */
+ int GetWidth();
+ /** Function SetSize
+ * sets text size
+ * @param aNewSize = new text size
+ */
+ void SetSize( wxSize aNewSize );
+ /** Function GetSize
+ * returns text size
+ * @return wxSize - text size
+ */
+ wxSize GetSize();
int GetLength(); /* text length */
int GetDrawRotation(); // Return text rotation for drawings and
// plotting
=== modified file 'pcbnew/edit.cpp'
--- pcbnew/edit.cpp 2010-11-03 21:19:46 +0000
+++ pcbnew/edit.cpp 2010-11-11 19:13:34 +0000
@@ -814,6 +814,10 @@
DrawPanel->MouseToCursorSchema();
break;
+ case ID_POPUP_PCB_RESET_TEXTMODULE_SIZE:
+ ResetTextModuleSize( (TEXTE_MODULE*) GetCurItem(), &dc );
+ break;
+
case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
DrawPanel->MouseToCursorSchema();
StartMoveTexteModule( (TEXTE_MODULE*) GetCurItem(), &dc );
@@ -1015,6 +1019,14 @@
Swap_Layers( event );
break;
+ case ID_MENU_PCB_RESET_TEXTMODULE_REFERENCE_SIZES:
+ ResetTextModuleSizes( TEXT_is_REFERENCE, &dc );
+ break;
+
+ case ID_MENU_PCB_RESET_TEXTMODULE_VALUE_SIZES:
+ ResetTextModuleSizes( TEXT_is_VALUE, &dc );
+ break;
+
case ID_PCB_USER_GRID_SETUP:
InstallGridFrame( pos );
break;
=== modified file 'pcbnew/edtxtmod.cpp'
--- pcbnew/edtxtmod.cpp 2010-07-20 18:11:34 +0000
+++ pcbnew/edtxtmod.cpp 2010-11-11 19:13:34 +0000
@@ -251,3 +251,129 @@
/* Redraw the text */
Text->Draw( panel, DC, GR_XOR, MoveVector );
}
+
+void WinEDA_BasePcbFrame::ResetTextModuleSize( TEXTE_MODULE* aText, wxDC* aDC )
+{
+ MODULE* module;
+ TEXTE_MODULE* item;
+ ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
+ itemWrapper.m_PickedItemType = TYPE_MODULE;
+ PICKED_ITEMS_LIST undoItemList;
+ int ii;
+
+ module = (MODULE*) aText->GetParent();
+
+ // Prepare undo list
+ itemWrapper.m_PickedItem = module;
+ // Check if there will be any change
+ if( aText->GetSize() != g_ModuleTextSize ||
+ aText->GetWidth() != g_ModuleTextWidth )
+ undoItemList.PushItem( itemWrapper );
+
+ // Exit if there's nothing to do
+ if( !undoItemList.GetCount() )
+ return;
+
+ SaveCopyInUndoList( undoItemList, UR_CHANGED );
+
+ // Apply changes
+ aText->SetWidth( g_ModuleTextWidth );
+ aText->SetSize( g_ModuleTextSize );
+
+ if( aDC )
+ DrawPanel->Refresh();
+
+ OnModify();
+}
+
+void WinEDA_BasePcbFrame::ResetTextModuleSizes( int aType, wxDC* aDC )
+{
+ MODULE* module;
+ BOARD_ITEM* boardItem;
+ TEXTE_MODULE* item;
+ ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
+ itemWrapper.m_PickedItemType = TYPE_MODULE;
+ PICKED_ITEMS_LIST undoItemList;
+ int ii;
+
+ module = GetBoard()->m_Modules;
+
+ // Prepare undo list
+ while( module )
+ {
+ itemWrapper.m_PickedItem = module;
+ switch( aType )
+ {
+ case TEXT_is_REFERENCE:
+ item = module->m_Reference;
+ if( item->GetSize() != g_ModuleTextSize ||
+ item->GetWidth() != g_ModuleTextWidth )
+ undoItemList.PushItem( itemWrapper );
+ break;
+ case TEXT_is_VALUE:
+ item = module->m_Value;
+ if( item->GetSize() != g_ModuleTextSize ||
+ item->GetWidth() != g_ModuleTextWidth )
+ undoItemList.PushItem( itemWrapper );
+ break;
+ default:
+ // Go through all other module texts
+ for( boardItem = module->m_Drawings; boardItem;
+ boardItem = boardItem->Next() )
+ {
+ if( boardItem->Type() == TYPE_TEXTE_MODULE )
+ {
+ item = (TEXTE_MODULE*) boardItem;
+ if( item->GetSize() != g_ModuleTextSize ||
+ item->GetWidth() != g_ModuleTextWidth )
+ {
+ undoItemList.PushItem( itemWrapper );
+ break;
+ }
+ }
+ }
+ break;
+ }
+ module = module->Next();
+ }
+
+ // Exit if there's nothing to do
+ if( !undoItemList.GetCount() )
+ return;
+
+ SaveCopyInUndoList( undoItemList, UR_CHANGED );
+
+ // Apply changes to modules in the undo list
+ for( ii = 0; ii < undoItemList.GetCount(); ii++ )
+ {
+ module = (MODULE*) undoItemList.GetPickedItem( ii );
+ switch( aType )
+ {
+ case TEXT_is_REFERENCE:
+ module->m_Reference->SetWidth( g_ModuleTextWidth );
+ module->m_Reference->SetSize( g_ModuleTextSize );
+ break;
+ case TEXT_is_VALUE:
+ module->m_Value->SetWidth( g_ModuleTextWidth );
+ module->m_Value->SetSize( g_ModuleTextSize );
+ break;
+ default:
+ for( boardItem = module->m_Drawings; boardItem;
+ boardItem = boardItem->Next() )
+ {
+ if( boardItem->Type() == TYPE_TEXTE_MODULE )
+ {
+ item = (TEXTE_MODULE*) boardItem;
+ item->SetWidth( g_ModuleTextWidth );
+ item->SetSize( g_ModuleTextSize );
+ }
+ }
+ break;
+ }
+ }
+
+ if( aDC )
+ DrawPanel->Refresh();
+
+ OnModify();
+}
=== modified file 'pcbnew/menubar_pcbframe.cpp'
--- pcbnew/menubar_pcbframe.cpp 2010-11-01 13:43:12 +0000
+++ pcbnew/menubar_pcbframe.cpp 2010-11-11 19:13:34 +0000
@@ -290,6 +290,19 @@
item->SetBitmap( swap_layer_xpm );
editMenu->Append( item );
+ // Reset module reference sizes
+ item = new wxMenuItem( editMenu,
+ ID_MENU_PCB_RESET_TEXTMODULE_REFERENCE_SIZES,
+ _( "Reset Module &Reference Sizes" ),
+ _( "Reset text size and width of all module references to current defaults" ) );
+ editMenu->Append( item );
+
+ // Reset module value sizes
+ item = new wxMenuItem( editMenu,
+ ID_MENU_PCB_RESET_TEXTMODULE_VALUE_SIZES,
+ _( "Reset Module &Value Sizes" ),
+ _( "Reset text size and width of all module values to current defaults" ) );
+ editMenu->Append( item );
/** Create View menu **/
wxMenu* viewMenu = new wxMenu;
=== modified file 'pcbnew/onrightclick.cpp'
--- pcbnew/onrightclick.cpp 2010-09-03 14:33:09 +0000
+++ pcbnew/onrightclick.cpp 2010-11-11 19:13:34 +0000
@@ -705,6 +705,8 @@
msg = AddHotkeyName( _( "Edit" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE,
msg, edit_text_xpm );
+ ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_RESET_TEXTMODULE_SIZE,
+ _( "Reset Size" ), edit_text_xpm);
}
if( !flags && FpText->m_Type == TEXT_is_DIVERS ) // Graphic texts can be deleted only if are not currently edited
=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp 2010-11-03 18:55:51 +0000
+++ pcbnew/pcbframe.cpp 2010-11-11 19:13:34 +0000
@@ -147,6 +147,10 @@
EVT_MENU( ID_MENU_PCB_CLEAN, WinEDA_PcbFrame::Process_Special_Functions )
EVT_MENU( ID_MENU_PCB_SWAP_LAYERS,
WinEDA_PcbFrame::Process_Special_Functions )
+ EVT_MENU( ID_MENU_PCB_RESET_TEXTMODULE_REFERENCE_SIZES,
+ WinEDA_PcbFrame::Process_Special_Functions )
+ EVT_MENU( ID_MENU_PCB_RESET_TEXTMODULE_VALUE_SIZES,
+ WinEDA_PcbFrame::Process_Special_Functions )
// Menu Help
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
=== modified file 'pcbnew/pcbnew_id.h'
--- pcbnew/pcbnew_id.h 2010-08-17 10:41:44 +0000
+++ pcbnew/pcbnew_id.h 2010-11-11 19:13:34 +0000
@@ -52,6 +52,7 @@
ID_POPUP_PCB_ROTATE_TEXTMODULE,
ID_POPUP_PCB_EDIT_TEXTMODULE,
ID_POPUP_PCB_DELETE_TEXTMODULE,
+ ID_POPUP_PCB_RESET_TEXTMODULE_SIZE,
ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST,
ID_POPUP_PCB_ROTATE_TEXTEPCB,
@@ -213,6 +214,8 @@
ID_MENU_LIST_NETS,
ID_MENU_PCB_CLEAN,
ID_MENU_PCB_SWAP_LAYERS,
+ ID_MENU_PCB_RESET_TEXTMODULE_REFERENCE_SIZES,
+ ID_MENU_PCB_RESET_TEXTMODULE_VALUE_SIZES,
ID_GEN_EXPORT_FILE_VRML,
ID_TOOLBARH_PCB_MODE_MODULE,
Follow ups