From 38a5e9af4bc1d2c1bd36bfba2111334d1bcb56bf Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 25 May 2013 11:01:44 +0200 Subject: [PATCH] 3D viewer: fix Bug #1183581 (pcbnew 3D viewer: recent UI inconsistency ) Pcbnew: fix bug in drag module: connected tracks were not dragged. worksheet: code cleaning. --- 3d-viewer/3d_frame.cpp | 2 +- 3d-viewer/3d_toolbar.cpp | 47 +++- 3d-viewer/3d_viewer.h | 4 +- 3d-viewer/dialogs/dialog_3D_view_option.cpp | 253 ++++++++++---------- common/dialogs/dialog_page_settings.cpp | 15 +- common/title_block_shapes.cpp | 160 +------------ common/worksheet.cpp | 123 +++++++++- include/worksheet.h | 4 +- include/worksheet_shape_builder.h | 38 +++ pcbnew/dragsegm.cpp | 4 +- 10 files changed, 346 insertions(+), 304 deletions(-) diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index eb67b42f0a..6167ca7154 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -100,7 +100,7 @@ END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, CreateStatusBar( 5 ); SetStatusWidths( 5, dims ); - ReCreateMenuBar(); + CreateMenuBar(); ReCreateHToolbar(); // ReCreateAuxiliaryToolbar(); diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp index db0b4582b7..5b49f781f5 100644 --- a/3d-viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_toolbar.cpp @@ -136,7 +136,7 @@ void EDA_3D_FRAME::ReCreateVToolbar() } -void EDA_3D_FRAME::ReCreateMenuBar() +void EDA_3D_FRAME::CreateMenuBar() { wxMenuBar* menuBar = new wxMenuBar; wxMenu* fileMenu = new wxMenu; @@ -180,15 +180,12 @@ void EDA_3D_FRAME::ReCreateMenuBar() item = AddMenuItem( prefsMenu, ID_MENU3D_USE_COPPER_THICKNESS, _( "Show Copper Thickness" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]); item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF, _( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]); item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF, _( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]); item = AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF, _( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK ); @@ -196,27 +193,59 @@ void EDA_3D_FRAME::ReCreateMenuBar() item = AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF, _( "Show &Silkscreen Layer" ), KiBitmap( add_text_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN]); item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF, _( "Show Solder &Mask Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK]); item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF, _( "Show Solder &Paste Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE]); item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF, _( "Show &Comments and Drawings Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]); item = AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF, _( "Show &Eco Layers" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK ); - item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO]); + SetMenuBarOptionsState(); SetMenuBar( menuBar ); } +void EDA_3D_FRAME::SetMenuBarOptionsState() +{ + wxMenuBar* menuBar = GetMenuBar(); + + if( menuBar == NULL ) + return; + + wxMenuItem* item; + // Set the state of toggle menus according to the current display options + item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]); + + item = menuBar->FindItem( ID_MENU3D_MODULE_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]); + + item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]); + + item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]); + + item = menuBar->FindItem( ID_MENU3D_SILKSCREEN_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN]); + + item = menuBar->FindItem( ID_MENU3D_SOLDER_MASK_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK]); + + item = menuBar->FindItem( ID_MENU3D_SOLDER_PASTE_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE]); + + item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]); + + item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO]); +} void EDA_3D_FRAME::SetToolbars() { diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index ec3cf50677..98f7b22350 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -118,7 +118,9 @@ private: void Install_3D_ViewOptionDialog( wxCommandEvent& event ); // initialisation - void ReCreateMenuBar(); + void CreateMenuBar(); + void SetMenuBarOptionsState(); // Set the state of toggle menus according + // to the current display options void ReCreateHToolbar(); void ReCreateVToolbar(); void SetToolbars(); diff --git a/3d-viewer/dialogs/dialog_3D_view_option.cpp b/3d-viewer/dialogs/dialog_3D_view_option.cpp index a7104db35e..e42abb5a40 100644 --- a/3d-viewer/dialogs/dialog_3D_view_option.cpp +++ b/3d-viewer/dialogs/dialog_3D_view_option.cpp @@ -1,125 +1,128 @@ - -#include "dialog_3D_view_option_base.h" -#include <3d_viewer.h> -#include - -class DIALOG_3D_VIEW_OPTIONS : public DIALOG_3D_VIEW_OPTIONS_BASE -{ -public: - DIALOG_3D_VIEW_OPTIONS( EDA_3D_FRAME* parent ); - -private: - EDA_3D_FRAME* m_parent; - - void initDialog(); - - // Event functions: - void OnShowAllClick( wxCommandEvent& event ); - void OnShowNoneClick( wxCommandEvent& event ); - void OnOKClick( wxCommandEvent& event ); -}; - -void EDA_3D_FRAME::Install_3D_ViewOptionDialog( wxCommandEvent& event ) -{ - DIALOG_3D_VIEW_OPTIONS dlg( this ); - dlg.ShowModal(); -} - - -DIALOG_3D_VIEW_OPTIONS::DIALOG_3D_VIEW_OPTIONS( EDA_3D_FRAME* parent ) - :DIALOG_3D_VIEW_OPTIONS_BASE( parent ) -{ - m_parent = parent; - - initDialog(); - - Layout(); - GetSizer()->SetSizeHints(this); - Centre(); -} - -void DIALOG_3D_VIEW_OPTIONS::initDialog() -{ - m_bitmapCuThickness->SetBitmap( KiBitmap( use_3D_copper_thickness_xpm ) ); - m_bitmap3Dshapes->SetBitmap( KiBitmap( shape_3d_xpm ) ); - m_bitmapAreas->SetBitmap( KiBitmap( add_zone_xpm ) ); - m_bitmapSilkscreen->SetBitmap( KiBitmap( add_text_xpm ) ); - m_bitmapSolderMask->SetBitmap( KiBitmap( pads_mask_layers_xpm ) ); - m_bitmapSolderPaste->SetBitmap( KiBitmap( pads_mask_layers_xpm ) ); - m_bitmapAdhesive->SetBitmap( KiBitmap( tools_xpm ) ); - m_bitmapComments->SetBitmap( KiBitmap( edit_sheet_xpm ) ); - m_bitmapECO->SetBitmap( KiBitmap( edit_sheet_xpm ) ); - - // Check/uncheck checkboxes - m_checkBoxCuThickness->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] ); - m_checkBox3Dshapes->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] ); - m_checkBoxAreas->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] ); - m_checkBoxSilkscreen->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] ); - m_checkBoxSolderMask->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] ); - m_checkBoxSolderpaste->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] ); - m_checkBoxAdhesive->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] ); - m_checkBoxComments->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] ); - m_checkBoxECO->SetValue( - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] ); -} - -void DIALOG_3D_VIEW_OPTIONS::OnShowAllClick( wxCommandEvent& event ) -{ - bool state = true; - m_checkBoxCuThickness->SetValue( state ); - m_checkBox3Dshapes->SetValue( state ); - m_checkBoxAreas->SetValue( state ); - m_checkBoxSilkscreen->SetValue( state ); - m_checkBoxSolderMask->SetValue( state ); - m_checkBoxSolderpaste->SetValue( state ); - m_checkBoxAdhesive->SetValue( state ); - m_checkBoxComments->SetValue( state ); - m_checkBoxECO->SetValue( state ); -} - -void DIALOG_3D_VIEW_OPTIONS::OnShowNoneClick( wxCommandEvent& event ) -{ - bool state = false; - m_checkBoxCuThickness->SetValue( state ); - m_checkBox3Dshapes->SetValue( state ); - m_checkBoxAreas->SetValue( state ); - m_checkBoxSilkscreen->SetValue( state ); - m_checkBoxSolderMask->SetValue( state ); - m_checkBoxSolderpaste->SetValue( state ); - m_checkBoxAdhesive->SetValue( state ); - m_checkBoxComments->SetValue( state ); - m_checkBoxECO->SetValue( state ); -} - -void DIALOG_3D_VIEW_OPTIONS::OnOKClick( wxCommandEvent& event ) -{ - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] = - m_checkBoxCuThickness->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] = - m_checkBox3Dshapes->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] = - m_checkBoxAreas->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] = - m_checkBoxSilkscreen->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] = - m_checkBoxSolderMask->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] = - m_checkBoxSolderpaste->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] = - m_checkBoxAdhesive->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] = - m_checkBoxComments->GetValue(); - g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] = - m_checkBoxECO->GetValue(); - - EndModal( wxID_OK ); - m_parent->NewDisplay(); -} + +#include "dialog_3D_view_option_base.h" +#include <3d_viewer.h> +#include + +class DIALOG_3D_VIEW_OPTIONS : public DIALOG_3D_VIEW_OPTIONS_BASE +{ +public: + DIALOG_3D_VIEW_OPTIONS( EDA_3D_FRAME* parent ); + +private: + EDA_3D_FRAME* m_parent; + + void initDialog(); + + // Event functions: + void OnShowAllClick( wxCommandEvent& event ); + void OnShowNoneClick( wxCommandEvent& event ); + void OnOKClick( wxCommandEvent& event ); +}; + +void EDA_3D_FRAME::Install_3D_ViewOptionDialog( wxCommandEvent& event ) +{ + DIALOG_3D_VIEW_OPTIONS dlg( this ); + if( dlg.ShowModal() == wxID_OK ) + { + SetMenuBarOptionsState(); + NewDisplay(); + } +} + + +DIALOG_3D_VIEW_OPTIONS::DIALOG_3D_VIEW_OPTIONS( EDA_3D_FRAME* parent ) + :DIALOG_3D_VIEW_OPTIONS_BASE( parent ) +{ + m_parent = parent; + + initDialog(); + + Layout(); + GetSizer()->SetSizeHints(this); + Centre(); +} + +void DIALOG_3D_VIEW_OPTIONS::initDialog() +{ + m_bitmapCuThickness->SetBitmap( KiBitmap( use_3D_copper_thickness_xpm ) ); + m_bitmap3Dshapes->SetBitmap( KiBitmap( shape_3d_xpm ) ); + m_bitmapAreas->SetBitmap( KiBitmap( add_zone_xpm ) ); + m_bitmapSilkscreen->SetBitmap( KiBitmap( add_text_xpm ) ); + m_bitmapSolderMask->SetBitmap( KiBitmap( pads_mask_layers_xpm ) ); + m_bitmapSolderPaste->SetBitmap( KiBitmap( pads_mask_layers_xpm ) ); + m_bitmapAdhesive->SetBitmap( KiBitmap( tools_xpm ) ); + m_bitmapComments->SetBitmap( KiBitmap( edit_sheet_xpm ) ); + m_bitmapECO->SetBitmap( KiBitmap( edit_sheet_xpm ) ); + + // Check/uncheck checkboxes + m_checkBoxCuThickness->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] ); + m_checkBox3Dshapes->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] ); + m_checkBoxAreas->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] ); + m_checkBoxSilkscreen->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] ); + m_checkBoxSolderMask->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] ); + m_checkBoxSolderpaste->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] ); + m_checkBoxAdhesive->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] ); + m_checkBoxComments->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] ); + m_checkBoxECO->SetValue( + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] ); +} + +void DIALOG_3D_VIEW_OPTIONS::OnShowAllClick( wxCommandEvent& event ) +{ + bool state = true; + m_checkBoxCuThickness->SetValue( state ); + m_checkBox3Dshapes->SetValue( state ); + m_checkBoxAreas->SetValue( state ); + m_checkBoxSilkscreen->SetValue( state ); + m_checkBoxSolderMask->SetValue( state ); + m_checkBoxSolderpaste->SetValue( state ); + m_checkBoxAdhesive->SetValue( state ); + m_checkBoxComments->SetValue( state ); + m_checkBoxECO->SetValue( state ); +} + +void DIALOG_3D_VIEW_OPTIONS::OnShowNoneClick( wxCommandEvent& event ) +{ + bool state = false; + m_checkBoxCuThickness->SetValue( state ); + m_checkBox3Dshapes->SetValue( state ); + m_checkBoxAreas->SetValue( state ); + m_checkBoxSilkscreen->SetValue( state ); + m_checkBoxSolderMask->SetValue( state ); + m_checkBoxSolderpaste->SetValue( state ); + m_checkBoxAdhesive->SetValue( state ); + m_checkBoxComments->SetValue( state ); + m_checkBoxECO->SetValue( state ); +} + +void DIALOG_3D_VIEW_OPTIONS::OnOKClick( wxCommandEvent& event ) +{ + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] = + m_checkBoxCuThickness->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] = + m_checkBox3Dshapes->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] = + m_checkBoxAreas->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] = + m_checkBoxSilkscreen->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] = + m_checkBoxSolderMask->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] = + m_checkBoxSolderpaste->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] = + m_checkBoxAdhesive->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] = + m_checkBoxComments->GetValue(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] = + m_checkBoxECO->GetValue(); + + EndModal( wxID_OK ); +} diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 996997d1f4..c0287516c9 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -616,23 +616,27 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() // Get logical page size and margins. PAGE_INFO pageDUMMY; - pageDUMMY.SetWidthMils( clamped_layout_size.x ); - pageDUMMY.SetHeightMils( clamped_layout_size.y ); - // Get page type int idx = m_paperSizeComboBox->GetSelection(); if( idx < 0 ) idx = 0; - wxString paperType = m_pageFmt[idx].Left( m_pageFmt[idx].Index( wxT( " " ) ) ); + wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' ); + bool portrait = clamped_layout_size.x < clamped_layout_size.y; + pageDUMMY.SetType( pageFmtName, portrait ); + if( m_customFmt ) + { + pageDUMMY.SetWidthMils( clamped_layout_size.x ); + pageDUMMY.SetHeightMils( clamped_layout_size.y ); + } // Draw layout preview. wxString emptyString; GRResetPenAndBrush( &memDC ); DrawPageLayout( &memDC, NULL, pageDUMMY, - paperType, emptyString, emptyString, + emptyString, emptyString, m_tb, m_Screen->m_NumberOfScreens, m_Screen->m_ScreenNumber, 1, appScale, DARKGRAY, RED ); @@ -684,7 +688,6 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() &PAGE_INFO::C, &PAGE_INFO::D, &PAGE_INFO::E, - //&PAGE_INFO::GERBER, &PAGE_INFO::USLetter, &PAGE_INFO::USLegal, &PAGE_INFO::USLedger, diff --git a/common/title_block_shapes.cpp b/common/title_block_shapes.cpp index ea30406cf9..b76062935b 100644 --- a/common/title_block_shapes.cpp +++ b/common/title_block_shapes.cpp @@ -35,10 +35,8 @@ #include #include -#include #include #include -#include #include #define GRID_REF_W Mm2mils( 1.8 ) // height of the band reference grid @@ -72,26 +70,6 @@ #define BLOCK_COMMENT3_Y (TEXTSIZE * 17) #define BLOCK_COMMENT4_Y (TEXTSIZE * 19) -/* - * Basic texts in Ki_WorkSheetData struct use format "C" type to - * identify the user text which should be shown, at runtime. - * Currently formats are % and a letter , or 2 letters - * - * %% = replaced by % - * %K = Kicad version - * %Z = paper format name (A4, USLetter) - * %Y = company name - * %D = date - * %R = revision - * %S = sheet number - * %N = number of sheets - * %Cx = comment (x = 0 to 9 to identify the comment) - * %F = filename - * %P = sheet path or sheet full name - * %T = title - * Other fields like Developer, Verifier, Approver could use %Cx - * and are seen as comments for format - */ // Text attributes set in m_Flags (ORed bits) #define USE_BOLD 1 // has meaning for texts @@ -321,15 +299,6 @@ Ki_WorkSheetData WS_Segm7 = #include -// Helper function which returns the text corresponding to the aIdent identifier -static wxString BuildFullText( const wxString& aTextbase, - const TITLE_BLOCK& aTitleBlock, - const wxString& aPaperFormat, - const wxString& aFileName, - const wxString& aSheetPathHumanReadable, - int aSheetCount, int aSheetNumber ); - - void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const wxString& aPaperFormat, const wxString& aFileName, @@ -342,6 +311,12 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( FRMREF_TXTSIZE * m_milsToIu ); wxString msg; + m_titleBlock = &aTitleBlock, + m_paperFormat = &aPaperFormat, + m_fileName = &aFileName, + m_sheetFullName = &aSheetPathHumanReadable; + + // Left top corner position wxPoint lt_corner; lt_corner.x = m_LTmargin.x; @@ -460,8 +435,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( msg.Empty(); if( WsItem->m_Type == WS_TEXT && WsItem->m_TextBase ) - msg = BuildFullText( WsItem->m_TextBase, aTitleBlock, aPaperFormat, aFileName, - aSheetPathHumanReadable, m_sheetCount, m_sheetNumber ); + msg = BuildFullText( WsItem->m_TextBase ); switch( WsItem->m_Type ) { @@ -508,123 +482,3 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( } } } - -// returns the full text corresponding to the aTextbase, -// after replacing format symbols by the corresponding value -wxString BuildFullText( const wxString& aTextbase, - const TITLE_BLOCK& aTitleBlock, - const wxString& aPaperFormat, - const wxString& aFileName, - const wxString& aSheetPathHumanReadable, - int aSheetCount, int aSheetNumber ) -{ - wxString msg; - - /* Known formats - * %% = replaced by % - * %K = Kicad version - * %Z = paper format name (A4, USLetter) - * %Y = company name - * %D = date - * %R = revision - * %S = sheet number - * %N = number of sheets - * %Cx = comment (x = 0 to 9 to identify the comment) - * %F = filename - * %P = sheet path (sheet full name) - * %T = title - */ - - for( unsigned ii = 0; ii < aTextbase.Len(); ii++ ) - { - if( aTextbase[ii] != '%' ) - { - msg << aTextbase[ii]; - continue; - } - ii++; - if( ii >= aTextbase.Len() ) - break; - - wxChar format = aTextbase[ii]; - switch( format ) - { - case '%': - msg += '%'; - break; - - case 'D': - msg += aTitleBlock.GetDate(); - break; - - case 'R': - msg += aTitleBlock.GetRevision(); - break; - - case 'K': - msg += g_ProductName + wxGetApp().GetAppName(); - msg += wxT( " " ) + GetBuildVersion(); - break; - - case 'Z': - msg += aPaperFormat; - break; - - case 'S': - msg << aSheetNumber; - break; - - case 'N': - msg << aSheetCount; - break; - - case 'F': - { - wxFileName fn( aFileName ); - msg += fn.GetFullName(); - } - break; - - case 'P': - msg += aSheetPathHumanReadable; - break; - - case 'Y': - msg = aTitleBlock.GetCompany(); - break; - - case 'T': - msg += aTitleBlock.GetTitle(); - break; - - case 'C': - format = aTextbase[++ii]; - switch( format ) - { - case '1': - msg += aTitleBlock.GetComment1(); - break; - - case '2': - msg += aTitleBlock.GetComment2(); - break; - - case '3': - msg += aTitleBlock.GetComment3(); - break; - - case '4': - msg += aTitleBlock.GetComment4(); - break; - - default: - break; - } - - default: - break; - } - } - - return msg; -} diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 4fe2dd0a76..7d639f479c 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -31,6 +31,7 @@ #include +#include #include #include #include @@ -39,12 +40,12 @@ #include #include #include +#include #include void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, const PAGE_INFO& aPageInfo, - const wxString& aPaperFormat, const wxString &aFullSheetName, const wxString& aFileName, TITLE_BLOCK& aTitleBlock, @@ -67,7 +68,7 @@ void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, drawList.SetSheetCount( aSheetCount ); drawList.BuildWorkSheetGraphicList( - aPaperFormat, aFullSheetName, aFileName, + aPageInfo.GetType(), aFullSheetName, aFileName, aTitleBlock, aLineColor, aTextColor ); // Draw item list @@ -139,12 +140,11 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); } - wxString paper = pageInfo.GetType(); TITLE_BLOCK t_block = GetTitleBlock(); EDA_COLOR_T color = RED; DrawPageLayout( aDC, m_canvas, pageInfo, - paper, aFilename, GetScreenDesc(), t_block, + aFilename, GetScreenDesc(), t_block, aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, color, color ); } @@ -205,6 +205,121 @@ wxString EDA_DRAW_FRAME::GetScreenDesc() return msg; } +// returns the full text corresponding to the aTextbase, +// after replacing format symbols by the corresponding value +wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) +{ + wxString msg; + + /* Known formats + * %% = replaced by % + * %K = Kicad version + * %Z = paper format name (A4, USLetter) + * %Y = company name + * %D = date + * %R = revision + * %S = sheet number + * %N = number of sheets + * %Cx = comment (x = 0 to 9 to identify the comment) + * %F = filename + * %P = sheet path (sheet full name) + * %T = title + */ + + for( unsigned ii = 0; ii < aTextbase.Len(); ii++ ) + { + if( aTextbase[ii] != '%' ) + { + msg << aTextbase[ii]; + continue; + } + ii++; + if( ii >= aTextbase.Len() ) + break; + + wxChar format = aTextbase[ii]; + switch( format ) + { + case '%': + msg += '%'; + break; + + case 'D': + msg += m_titleBlock->GetDate(); + break; + + case 'R': + msg += m_titleBlock->GetRevision(); + break; + + case 'K': + msg += g_ProductName + wxGetApp().GetAppName(); + msg += wxT( " " ) + GetBuildVersion(); + break; + + case 'Z': + msg += *m_paperFormat; + break; + + case 'S': + msg << m_sheetNumber; + break; + + case 'N': + msg << m_sheetCount; + break; + + case 'F': + { + wxFileName fn( *m_fileName ); + msg += fn.GetFullName(); + } + break; + + case 'P': + msg += *m_sheetFullName; + break; + + case 'Y': + msg = m_titleBlock->GetCompany(); + break; + + case 'T': + msg += m_titleBlock->GetTitle(); + break; + + case 'C': + format = aTextbase[++ii]; + switch( format ) + { + case '1': + msg += m_titleBlock->GetComment1(); + break; + + case '2': + msg += m_titleBlock->GetComment2(); + break; + + case '3': + msg += m_titleBlock->GetComment3(); + break; + + case '4': + msg += m_titleBlock->GetComment4(); + break; + + default: + break; + } + + default: + break; + } + } + + return msg; +} + void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ) diff --git a/include/worksheet.h b/include/worksheet.h index 62d7adccfd..6df596d889 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -31,8 +31,7 @@ public: * @param aDC The device context. * @param aCanvas The EDA_DRAW_PANEL to draw into, or NULL if the page * layout is not drawn into the main panel. - * @param aPageInfo for margins and page siez (in mils). - * @param aPaperFormat The paper size type, for basic inscriptions. + * @param aPageInfo for margins and page size (in mils). * @param aFullSheetName The sheetpath (full sheet name), for basic inscriptions. * @param aFileName The file name, for basic inscriptions. * @param aTitleBlock The sheet title block, for basic inscriptions. @@ -50,7 +49,6 @@ public: */ void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, const PAGE_INFO& aPageInfo, - const wxString& aPaperFormat, const wxString &aFullSheetName, const wxString& aFileName, TITLE_BLOCK& aTitleBlock, diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 2a6757c626..172885cdec 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -137,6 +137,11 @@ class WS_DRAW_ITEM_LIST int m_sheetNumber; // the value of the sheet number, for basic inscriptions int m_sheetCount; // the value of the number of sheets, in schematic // for basic inscriptions, in schematic + const TITLE_BLOCK* m_titleBlock; // for basic inscriptions + const wxString* m_paperFormat; // for basic inscriptions + const wxString* m_fileName; // for basic inscriptions + const wxString* m_sheetFullName; // for basic inscriptions + public: WS_DRAW_ITEM_LIST() @@ -146,6 +151,10 @@ public: m_penSize = 1; m_sheetNumber = 1; m_sheetCount = 1; + m_titleBlock = NULL; + m_paperFormat = NULL; + m_fileName = NULL; + m_sheetFullName = NULL; } ~WS_DRAW_ITEM_LIST() @@ -256,6 +265,35 @@ public: const wxString& aSheetPathHumanReadable, const TITLE_BLOCK& aTitleBlock, EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ); + /** + * Function BuildFullText + * returns the full text corresponding to the aTextbase, + * after replacing format symbols by the corresponding value + * + * Basic texts in Ki_WorkSheetData struct use format notation + * like "Title %T" to identify at run time the full text + * to display. + * Currently format identifier is % followed by a letter or 2 letters + * + * %% = replaced by % + * %K = Kicad version + * %Z = paper format name (A4, USLetter) + * %Y = company name + * %D = date + * %R = revision + * %S = sheet number + * %N = number of sheets + * %Cx = comment (x = 0 to 9 to identify the comment) + * %F = filename + * %P = sheet path or sheet full name + * %T = title + * Other fields like Developer, Verifier, Approver could use %Cx + * and are seen as comments for format + * + * @param aTextbase = the text with format symbols + * @return the text, after replacing the format symbols by the actual value + */ + wxString BuildFullText( const wxString& aTextbase ); }; diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 7870710fd0..0cde2b7614 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -227,13 +227,13 @@ void DRAG_LIST::fillList( CONNECTIONS& aConnections ) if( pad->HitTest( track->GetStart() ) ) { track->start = pad; - track->SetState( START_ON_PAD, false ); + track->SetState( START_ON_PAD, true ); } if( pad->HitTest( track->GetEnd() ) ) { track->end = pad; - track->SetState( END_ON_PAD, false ); + track->SetState( END_ON_PAD, true ); } DRAG_SEGM_PICKER wrapper( track );