Commit b752cfde authored by Marco Mattila's avatar Marco Mattila

Add edit menu and right-click menu items to pcbnew for resetting module and...

Add edit menu and right-click menu items to pcbnew for resetting module and other text field sizes to current defaults set in Preferences->Dimensions->Texts and Drawings.
parent 58dcc12e
......@@ -344,6 +344,7 @@ set(BITMAP_SRCS
red.xpm
reload2.xpm
reload.xpm
Reset_Text.xpm
Resize_Sheet.xpm
right.xpm
Rotate_Field.xpm
......
/* XPM */
#ifndef XPMMAIN
extern const char *reset_text_xpm[];
#else
const char * reset_text_xpm[] = {
"16 16 3 1",
" c None",
". c #00009B",
"+ c #ACACAC",
" ",
" ",
" ...+ ",
" .++ ",
" ... .+ ",
" ..+.+ ",
" . .+++ ",
" . + + ",
" ..... + ",
" .+++ ",
" .+ ",
" .+ ",
" .+ ",
" .+ ",
" .+ ",
" ++ "};
#endif
......@@ -655,6 +655,34 @@ public:
EDA_TextStruct( const EDA_TextStruct& aText );
virtual ~EDA_TextStruct();
/**
* Function SetThickness
* sets text thickness.
* @param aNewThickness is the new text thickness.
*/
void SetThickness( int aNewThickness ) { m_Thickness = aNewThickness; };
/**
* Function GetThickness
* returns text thickness.
* @return int - text thickness.
*/
int GetThickness() const { return m_Thickness; };
/**
* Function SetSize
* sets text size.
* @param aNewSize is the new text size.
*/
void SetSize( wxSize aNewSize ) { m_Size = aNewSize; };
/**
* Function GetSize
* returns text size.
* @return wxSize - text size.
*/
wxSize GetSize() const { return m_Size; };
int GetLength() const { return m_Text.Length(); };
/**
......
......@@ -338,6 +338,7 @@ extern const char* red_xpm[];
extern const char* reload2_xpm[];
extern const char* reload_xpm[];
extern const char* repaint_xpm[];
extern const char* reset_text_xpm[];
extern const char* resize_sheet_xpm[];
extern const char* right_xpm[];
extern const char* rotate_field_xpm[];
......
......@@ -256,6 +256,24 @@ public:
wxDC* DC );
TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC );
/**
* Function ResetTextSize
* resets given field text size and width to current settings in
* Preferences->Dimensions->Texts and Drawings.
* @param aItem is the item to be reset, either TEXTE_PCB or TEXTE_MODULE.
* @param aDC is the drawing context.
*/
void ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC );
/**
* Function ResetModuleTextSizes
* resets text size and width of all module text fields of given field
* type to current settings in Preferences->Dimensions->Texts and Drawings.
* @param aType is the field type (TEXT_is_REFERENCE, TEXT_is_VALUE, or TEXT_is_DIVERS).
* @param aDC is the drawing context.
*/
void ResetModuleTextSizes( int aType, wxDC* aDC );
void InstallPadOptionsFrame( D_PAD* pad );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod,
wxDC* DC );
......
......@@ -199,13 +199,6 @@ int TEXTE_MODULE:: GetLength() const
return m_Text.Len();
}
void TEXTE_MODULE:: SetWidth( int new_width )
{
m_Thickness = new_width;
}
// Update draw coordinates
void TEXTE_MODULE:: SetDrawCoord()
{
......
......@@ -46,7 +46,6 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
void Copy( TEXTE_MODULE* source ); // copy structure
/* Gestion du texte */
void SetWidth( int new_width );
int GetLength() const; /* text length */
......
......@@ -187,7 +187,7 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
DisplayError(NULL, _("The text thickness is too large for the text size. It will be clamped"));
width = maxthickness;
}
m_CurrentTextMod->SetWidth( width );
m_CurrentTextMod->SetThickness( width );
m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1;
int text_orient = (m_Orient->GetSelection() == 0) ? 0 : 900;
......
......@@ -811,6 +811,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema();
break;
case ID_POPUP_PCB_RESET_TEXT_SIZE:
ResetTextSize( GetCurItem(), &dc );
break;
case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
DrawPanel->MouseToCursorSchema();
StartMoveTexteModule( (TEXTE_MODULE*) GetCurItem(), &dc );
......@@ -1012,6 +1016,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
Swap_Layers( event );
break;
case ID_MENU_PCB_RESET_TEXTMODULE_REFERENCE_SIZES:
ResetModuleTextSizes( TEXT_is_REFERENCE, &dc );
break;
case ID_MENU_PCB_RESET_TEXTMODULE_VALUE_SIZES:
ResetModuleTextSizes( TEXT_is_VALUE, &dc );
break;
case ID_PCB_USER_GRID_SETUP:
InstallGridFrame( pos );
break;
......
......@@ -266,3 +266,154 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC,
// Redraw text
Text->Draw( panel, DC, GR_XOR, MoveVector );
}
void WinEDA_BasePcbFrame::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
{
wxSize newSize;
int newThickness;
TEXTE_PCB* pcbText;
TEXTE_MODULE* moduleText;
EDA_TextStruct* text;
switch( aItem->Type() )
{
case TYPE_TEXTE:
newSize = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize;
newThickness = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth;
pcbText = (TEXTE_PCB*) aItem;
text = (EDA_TextStruct*) pcbText;
break;
case TYPE_TEXTE_MODULE:
newSize = g_ModuleTextSize;
newThickness = g_ModuleTextWidth;
moduleText = (TEXTE_MODULE*) aItem;
text = (EDA_TextStruct*) moduleText;
break;
default:
// Exit if aItem is not a text field
return;
break;
}
// Exit if there's nothing to do
if( text->GetSize() == newSize
&& text->GetThickness() == newThickness )
return;
// Push item to undo list
switch( aItem->Type() )
{
case TYPE_TEXTE:
SaveCopyInUndoList( pcbText, UR_CHANGED );
break;
case TYPE_TEXTE_MODULE:
SaveCopyInUndoList( moduleText->GetParent(), UR_CHANGED );
break;
default:
break;
}
// Apply changes
text->SetSize( newSize );
text->SetThickness( newThickness );
if( aDC )
DrawPanel->Refresh();
OnModify();
}
void WinEDA_BasePcbFrame::ResetModuleTextSizes( int aType, wxDC* aDC )
{
MODULE* module;
BOARD_ITEM* boardItem;
TEXTE_MODULE* item;
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
PICKED_ITEMS_LIST undoItemList;
unsigned int ii;
itemWrapper.m_PickedItemType = TYPE_MODULE;
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->GetThickness() != g_ModuleTextWidth )
undoItemList.PushItem( itemWrapper );
break;
case TEXT_is_VALUE:
item = module->m_Value;
if( item->GetSize() != g_ModuleTextSize
|| item->GetThickness() != g_ModuleTextWidth )
undoItemList.PushItem( itemWrapper );
break;
case TEXT_is_DIVERS:
// Go through all other module text fields
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->GetThickness() != g_ModuleTextWidth )
{
undoItemList.PushItem( itemWrapper );
break;
}
}
}
break;
default:
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->SetThickness( g_ModuleTextWidth );
module->m_Reference->SetSize( g_ModuleTextSize );
break;
case TEXT_is_VALUE:
module->m_Value->SetThickness( g_ModuleTextWidth );
module->m_Value->SetSize( g_ModuleTextSize );
break;
case TEXT_is_DIVERS:
for( boardItem = module->m_Drawings; boardItem;
boardItem = boardItem->Next() )
{
if( boardItem->Type() == TYPE_TEXTE_MODULE )
{
item = (TEXTE_MODULE*) boardItem;
item->SetThickness( g_ModuleTextWidth );
item->SetSize( g_ModuleTextSize );
}
}
break;
}
}
if( aDC )
DrawPanel->Refresh();
OnModify();
}
......@@ -765,13 +765,13 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( const wxString& aModuleName )
/* Update reference: */
Module->m_Reference->m_Text = moduleName;
Module->m_Reference->SetWidth( g_ModuleTextWidth );
Module->m_Reference->m_Size = g_ModuleTextSize;
Module->m_Reference->SetThickness( g_ModuleTextWidth );
Module->m_Reference->SetSize( g_ModuleTextSize );
/* Set the value field to a default value */
Module->m_Value->m_Text = wxT( "VAL**" );
Module->m_Value->SetWidth( g_ModuleTextWidth );
Module->m_Value->m_Size = g_ModuleTextSize;
Module->m_Value->SetThickness( g_ModuleTextWidth );
Module->m_Value->SetSize( g_ModuleTextSize );
Module->SetPosition( wxPoint( 0, 0 ) );
......
......@@ -292,6 +292,21 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
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" ) );
item->SetBitmap( reset_text_xpm );
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" ) );
item->SetBitmap( reset_text_xpm );
editMenu->Append( item );
/** Create View menu **/
wxMenu* viewMenu = new wxMenu;
......
......@@ -699,6 +699,8 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m
msg = AddHotkeyName( _( "Edit" ), g_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_TEXT_SIZE,
_( "Reset Size" ), reset_text_xpm );
}
if( !flags && FpText->m_Type == TEXT_is_DIVERS ) // Graphic texts can be deleted only if are not currently edited
......@@ -809,6 +811,8 @@ void WinEDA_PcbFrame::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_EDIT_TEXTEPCB,
msg, edit_text_xpm );
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_RESET_TEXT_SIZE,
_( "Reset Size" ), reset_text_xpm );
sub_menu_Text->AppendSeparator();
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB,
......
......@@ -139,6 +139,10 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
EVT_MENU( ID_PCB_GLOBAL_DELETE, WinEDA_PcbFrame::Process_Special_Functions )
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 )
......
......@@ -52,6 +52,7 @@ enum pcbnew_ids
ID_POPUP_PCB_ROTATE_TEXTMODULE,
ID_POPUP_PCB_EDIT_TEXTMODULE,
ID_POPUP_PCB_DELETE_TEXTMODULE,
ID_POPUP_PCB_RESET_TEXT_SIZE,
ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST,
ID_POPUP_PCB_ROTATE_TEXTEPCB,
......@@ -212,6 +213,8 @@ enum pcbnew_ids
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment