From 71f188f3de4c67c9f2c07d48a8278b6cff18fac7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 24 May 2019 14:37:55 +0100 Subject: [PATCH] Hook up import-page-layout and change-background-color actions. --- common/page_layout/page_layout_reader.cpp | 8 +- common/page_layout/ws_draw_item.cpp | 16 + include/layers_id_colors_and_visibility.h | 2 + include/ws_draw_item.h | 2 + pagelayout_editor/CMakeLists.txt | 3 - pagelayout_editor/controle.cpp | 62 --- pagelayout_editor/events_functions.cpp | 356 ------------------ pagelayout_editor/pl_draw_panel_gal.cpp | 4 + pagelayout_editor/pl_editor_config.cpp | 73 ---- pagelayout_editor/pl_editor_frame.cpp | 169 ++++++++- pagelayout_editor/pl_editor_frame.h | 6 +- pagelayout_editor/pl_editor_id.h | 16 - pagelayout_editor/properties_frame.cpp | 1 + pagelayout_editor/toolbars_pl_editor.cpp | 15 +- pagelayout_editor/tools/pl_drawing_tools.cpp | 6 - pagelayout_editor/tools/pl_edit_tool.cpp | 29 +- pagelayout_editor/tools/pl_edit_tool.h | 2 + pagelayout_editor/tools/pl_selection_tool.cpp | 5 +- 18 files changed, 234 insertions(+), 541 deletions(-) delete mode 100644 pagelayout_editor/controle.cpp delete mode 100644 pagelayout_editor/events_functions.cpp delete mode 100644 pagelayout_editor/pl_editor_config.cpp diff --git a/common/page_layout/page_layout_reader.cpp b/common/page_layout/page_layout_reader.cpp index 09573b2280..f7cde80e54 100644 --- a/common/page_layout/page_layout_reader.cpp +++ b/common/page_layout/page_layout_reader.cpp @@ -748,10 +748,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append { #if 0 if( !fullFileName.IsEmpty() ) - { - wxLogMessage( wxT("Page layout file <%s> not found"), - fullFileName.GetData() ); - } + wxLogMessage( wxT("Page layout file <%s> not found"), fullFileName.GetData() ); #endif SetDefaultLayout(); return; @@ -771,8 +768,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append char * buffer = new char[filelen+10]; if( wksFile.Read( buffer, filelen ) != filelen ) - wxLogMessage( _("The file \"%s\" was not fully read"), - fullFileName.GetData() ); + wxLogMessage( _("The file \"%s\" was not fully read"), fullFileName.GetData() ); else { buffer[filelen]=0; diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index 066ef0c563..35053421ac 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -55,9 +55,25 @@ #include #include #include +#include // ============================ BASE CLASS ============================== +void WS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const +{ + aCount = 1; + + WORKSHEET_DATAITEM* dataItem = GetPeer(); + + if( dataItem->GetPage1Option() == FIRST_PAGE_ONLY ) + aLayers[0] = LAYER_WORKSHEET_PAGE1; + else if( dataItem->GetPage1Option() == SUBSEQUENT_PAGES ) + aLayers[0] = LAYER_WORKSHEET_PAGEn; + else + aLayers[0] = LAYER_WORKSHEET; +} + + // A generic HitTest that can be used by some, but not all, sub-classes. bool WS_DRAW_ITEM_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 0467c9a086..14b932fb14 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -195,6 +195,8 @@ enum GAL_LAYER_ID: int LAYER_VIAS_HOLES, ///< to draw via holes (pad holes do not use this layer) LAYER_DRC, ///< drc markers LAYER_WORKSHEET, ///< worksheet frame + LAYER_WORKSHEET_PAGE1, ///< for pageLayout editor previewing + LAYER_WORKSHEET_PAGEn, ///< for pageLayout editor previewing LAYER_GP_OVERLAY, ///< general purpose overlay LAYER_SELECT_OVERLAY, ///< currently selected items overlay LAYER_PCB_BACKGROUND, ///< PCB background color diff --git a/include/ws_draw_item.h b/include/ws_draw_item.h index 9d7319571a..71724e9f42 100644 --- a/include/ws_draw_item.h +++ b/include/ws_draw_item.h @@ -66,6 +66,8 @@ public: WORKSHEET_DATAITEM* GetPeer() const { return m_peer; } + void ViewGetLayers( int aLayers[], int& aCount ) const override; + virtual const wxPoint GetPosition() const = 0; virtual void SetPosition( wxPoint aPos ) = 0; virtual void SetEnd( wxPoint aPos ) { /* not all types will need this */ } diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index c0ceaa651d..a3db08e378 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -20,11 +20,8 @@ set( PL_EDITOR_SRCS dialogs/dialog_new_dataitem.cpp pl_editor_screen.cpp pl_editor_layout.cpp - events_functions.cpp - controle.cpp files.cpp page_layout_writer.cpp - pl_editor_config.cpp pl_editor_frame.cpp pl_editor_undo_redo.cpp properties_frame.cpp diff --git a/pagelayout_editor/controle.cpp b/pagelayout_editor/controle.cpp deleted file mode 100644 index 8405efce5f..0000000000 --- a/pagelayout_editor/controle.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file pagelayout_editor/controle.cpp - */ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * @author Jean-Pierre Charras, jp.charras at wanadoo.fr - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include - - -bool PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) -{ - bool eventHandled = true; - - // Filter out the 'fake' mouse motion after a keyboard movement - if( !aHotKey && m_movingCursorWithKeyboard ) - { - m_movingCursorWithKeyboard = false; - return false; - } - - wxPoint pos = aPosition; - wxPoint oldpos = GetCrossHairPosition(); - GeneralControlKeyMovement( aHotKey, &pos, true ); - - // Update cursor position. - SetCrossHairPosition( pos, true ); - RefreshCrossHair( oldpos, aPosition, aDC ); - - if( aHotKey ) - { - eventHandled = OnHotKey( aDC, aHotKey, aPosition ); - } - - UpdateStatusBar(); - - return eventHandled; -} diff --git a/pagelayout_editor/events_functions.cpp b/pagelayout_editor/events_functions.cpp deleted file mode 100644 index 196cb960de..0000000000 --- a/pagelayout_editor/events_functions.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. - * @author Jean-Pierre Charras, jp.charras at wanadoo.fr - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @file pagelayout_editor/events_functions.cpp - * @brief page layout editor command event functions. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) - EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow ) - // Menu Files: - EVT_MENU( wxID_NEW, PL_EDITOR_FRAME::Files_io ) - EVT_MENU( wxID_OPEN, PL_EDITOR_FRAME::Files_io ) - EVT_MENU( wxID_SAVE, PL_EDITOR_FRAME::Files_io ) - EVT_MENU( wxID_SAVEAS, PL_EDITOR_FRAME::Files_io ) - EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io ) - EVT_MENU( ID_APPEND_DESCR_FILE, PL_EDITOR_FRAME::Files_io ) - - EVT_MENU( ID_GEN_PLOT, PL_EDITOR_FRAME::ToPlotter ) - - EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory ) - - EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit ) - - // menu Preferences - EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Config ) - EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config ) - - EVT_TOOL( wxID_DELETE, PL_EDITOR_FRAME::Process_Special_Functions ) - EVT_TOOL( wxID_PRINT, PL_EDITOR_FRAME::ToPrinter ) - EVT_TOOL( wxID_PREVIEW, PL_EDITOR_FRAME::ToPrinter ) - EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions ) - EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) - EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) - EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner) - EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions) - - EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, - PL_EDITOR_FRAME::Process_Special_Functions ) - - EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode ) - EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode ) -END_EVENT_TABLE() - - -/* Handles the selection of tools, menu, and popup menu commands. - */ -void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) -{ - wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - cmd.SetEventObject( this ); - - switch( event.GetId() ) - { - case ID_SELECT_PAGE_NUMBER: - m_canvas->Refresh(); - break; - - case ID_SHEET_SET: - { - DIALOG_PAGES_SETTINGS dlg( this, wxSize( MAX_PAGE_SIZE_EDITORS_MILS, - MAX_PAGE_SIZE_EDITORS_MILS ) ); - dlg.SetWksFileName( GetCurrFileName() ); - dlg.EnableWksFileNamePicker( false ); - dlg.ShowModal(); - - cmd.SetId( ID_ZOOM_PAGE ); - wxPostEvent( this, cmd ); - } - break; - - case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT: - cmd.SetId( ID_APPEND_DESCR_FILE ); - wxPostEvent( this, cmd ); - break; - - default: - wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) ); - break; - } -} - - -/* - * Function moveItem: called when the mouse cursor is moving - * moves the item currently selected (or the start point or the end point) - * to the cursor position -DPOINT initialPosition; // The initial position of the item to move, in mm -wxPoint initialPositionUi; // The initial position of the item to move, in Ui -wxPoint initialCursorPosition; // The initial position of the cursor - -static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) -{ - PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen(); - WORKSHEET_DATAITEM *item = screen->GetCurItem(); - - wxCHECK_RET( (item != NULL), wxT( "Cannot move NULL item." ) ); - wxPoint position = aPanel->GetParent()->GetCrossHairPosition() - - ( initialCursorPosition - initialPositionUi ); - wxPoint previous_position; - - if( (item->GetFlags() & LOCATE_STARTPOINT) ) - { - previous_position = item->GetStartPosUi(); - item->MoveStartPointToUi( position ); - } - else if( (item->GetFlags() & LOCATE_ENDPOINT) ) - { - previous_position = item->GetEndPosUi(); - item->MoveEndPointToUi( position ); - } - else - { - previous_position = item->GetStartPosUi(); - item->MoveToUi( position ); - } - - // Draw the item item at it's new position, if it is modified, - // (does not happen each time the mouse is moved, because the - // item is placed on grid) - // to avoid useless computation time. - if( previous_position != position ) - aPanel->Refresh(); -} - - - * Function abortMoveItem: called when an item is currently moving, - * and when the user aborts the move command. - * Restores the initial position of the item -static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) -{ - PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen(); - WORKSHEET_DATAITEM *item = screen->GetCurItem(); - - if( item->GetFlags() & NEW_ITEM ) - { - PL_EDITOR_FRAME* plframe = (PL_EDITOR_FRAME*) aPanel->GetParent(); - plframe->RemoveLastCommandInUndoList(); - WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); - pglayout.Remove( item ); - } - else - { - if( (item->GetFlags() & LOCATE_STARTPOINT) ) - { - item->MoveStartPointTo( initialPosition ); - } - else if( (item->GetFlags() & LOCATE_ENDPOINT) ) - { - item->MoveEndPointTo( initialPosition ); - } - else - item->MoveTo( initialPosition ); - } - - aPanel->SetMouseCapture( NULL, NULL ); - screen->SetCurItem( NULL ); - aPanel->Refresh(); -} - - -void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem ) -{ - wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) ); - initialPosition = aItem->GetStartPos(); - initialPositionUi = aItem->GetStartPosUi(); - initialCursorPosition = GetCrossHairPosition(); - - if( (aItem->GetFlags() & LOCATE_ENDPOINT) ) - { - initialPosition = aItem->GetEndPos(); - initialPositionUi = aItem->GetEndPosUi(); - } - - if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) ) - { - SetCrossHairPosition( initialPositionUi, false ); - initialCursorPosition = GetCrossHairPosition(); - - if( m_canvas->IsPointOnDisplay( initialCursorPosition ) ) - { - m_canvas->MoveCursorToCrossHair(); - m_canvas->Refresh(); - } - else - { - RedrawScreen( initialCursorPosition, true ); - } - } - - m_canvas->SetMouseCapture( moveItem, abortMoveItem ); - GetScreen()->SetCurItem( aItem ); -} - - -* Save in Undo list the layout, and place an item being moved. -* @param aItem is the item moved -void PL_EDITOR_FRAME::PlaceItem( WORKSHEET_DATAITEM* aItem ) -{ - DPOINT currStartPos = aItem->GetStartPos(); - DPOINT currEndPos = aItem->GetEndPos(); - - aItem->ClearFlags( NEW_ITEM ); - - // Save the curren layout before changes - if( (aItem->GetFlags() & LOCATE_STARTPOINT) ) - { - aItem->MoveStartPointTo( initialPosition ); - } - else if( aItem->GetFlags() & LOCATE_ENDPOINT ) - { - aItem->MoveEndPointTo( initialPosition ); - } - else - aItem->MoveTo( initialPosition ); - - SaveCopyInUndoList(); - - // Re-place the item - aItem->MoveStartPointTo( currStartPos ); - aItem->MoveEndPointTo( currEndPos ); - - m_canvas->SetMouseCapture( NULL, NULL ); - GetScreen()->SetCurItem( NULL ); -} -*/ - - -/* called when the user select one of the 4 page corner as corner - * reference (or the left top paper corner) - */ -void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event ) -{ - m_originSelectChoice = m_originSelectBox->GetSelection(); - UpdateStatusBar(); // Update grid origin - m_canvas->Refresh(); -} - - -void PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode( wxCommandEvent& event ) -{ - WORKSHEET_DATAITEM::m_SpecialMode = (event.GetId() == ID_SHOW_PL_EDITOR_MODE); - m_canvas->Refresh(); -} - - -void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event ) -{ - Close( true ); -} - - -void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event) -{ - wxMessageBox( wxT( "Not yet available" ) ); -} - - -void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event) -{ - // static print data and page setup data, to remember settings during the session - static wxPrintData* s_PrintData; - static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL; - - const PAGE_INFO& pageInfo = GetPageSettings(); - - if( s_PrintData == NULL ) // First print - { - s_PrintData = new wxPrintData(); - s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH; - } - - if( !s_PrintData->Ok() ) - { - wxMessageBox( _( "Error Init Printer info" ) ); - return; - } - - if( s_pageSetupData == NULL ) - s_pageSetupData = new wxPageSetupDialogData( *s_PrintData ); - - s_pageSetupData->SetPaperId( pageInfo.GetPaperId() ); - s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); - - if( pageInfo.IsCustom() ) - { - if( pageInfo.IsPortrait() ) - s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ), - Mils2mm( pageInfo.GetHeightMils() ) ) ); - else - s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ), - Mils2mm( pageInfo.GetWidthMils() ) ) ); - } - - *s_PrintData = s_pageSetupData->GetPrintData(); - - if( event.GetId() == wxID_PREVIEW ) - InvokeDialogPrintPreview( this, s_PrintData ); - else - InvokeDialogPrint( this, s_PrintData, s_pageSetupData ); -} - - -void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event ) -{ - event.Check( WORKSHEET_DATAITEM::m_SpecialMode == false ); -} - - -void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event ) -{ - event.Check( WORKSHEET_DATAITEM::m_SpecialMode == true ); -} - - diff --git a/pagelayout_editor/pl_draw_panel_gal.cpp b/pagelayout_editor/pl_draw_panel_gal.cpp index 260fbd7d06..7d43f6ae53 100644 --- a/pagelayout_editor/pl_draw_panel_gal.cpp +++ b/pagelayout_editor/pl_draw_panel_gal.cpp @@ -50,6 +50,10 @@ PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindo setDefaultLayerDeps(); + m_view->SetLayerVisible( LAYER_WORKSHEET, true ); + m_view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, true ); + m_view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, false ); + m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); } diff --git a/pagelayout_editor/pl_editor_config.cpp b/pagelayout_editor/pl_editor_config.cpp deleted file mode 100644 index a9d9de8860..0000000000 --- a/pagelayout_editor/pl_editor_config.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file pl_editor_config.cpp - * @brief page layout editor configuration. -*/ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * @author Jean-Pierre Charras, jp.charras at wanadoo.fr - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define GROUP wxT("/pl_editor") - - -void PL_EDITOR_FRAME::Process_Config( wxCommandEvent& event ) -{ - int id = event.GetId(); - - switch( id ) - { - case wxID_PREFERENCES: - ShowPreferences( PlEditorHotkeysDescr, PlEditorHotkeysDescr, wxT( "pl_editor" ) ); - break; - - case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: - DisplayHotkeyList( this, PlEditorHotkeysDescr ); - break; - - default: - wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Config error" ) ); - break; - } -} - - -PARAM_CFG_ARRAY& PL_EDITOR_FRAME::GetConfigurationSettings() -{ - if( !m_configSettings.empty() ) - return m_configSettings; - - // Add settings here.... - - return m_configSettings; -} diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 343d3d65d5..57314d0d24 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -34,11 +35,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -51,6 +50,39 @@ #include #include #include +#include +#include + +BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) + EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow ) + // Menu Files: + EVT_MENU( wxID_NEW, PL_EDITOR_FRAME::Files_io ) + EVT_MENU( wxID_OPEN, PL_EDITOR_FRAME::Files_io ) + EVT_MENU( wxID_SAVE, PL_EDITOR_FRAME::Files_io ) + EVT_MENU( wxID_SAVEAS, PL_EDITOR_FRAME::Files_io ) + EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io ) + + EVT_MENU( ID_GEN_PLOT, PL_EDITOR_FRAME::ToPlotter ) + + EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory ) + + EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit ) + + // menu Preferences + EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Special_Functions ) + EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Special_Functions ) + + EVT_TOOL( wxID_PRINT, PL_EDITOR_FRAME::ToPrinter ) + EVT_TOOL( wxID_PREVIEW, PL_EDITOR_FRAME::ToPrinter ) + EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions ) + EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) + EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) + EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner) + EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions) + + EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode ) + EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode ) +END_EVENT_TABLE() PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : @@ -240,6 +272,139 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event ) } +/* Handles the selection of tools, menu, and popup menu commands. + */ +void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) +{ + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + + switch( event.GetId() ) + { + case wxID_PREFERENCES: + ShowPreferences( PlEditorHotkeysDescr, PlEditorHotkeysDescr, wxT( "pl_editor" ) ); + break; + + case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: + DisplayHotkeyList( this, PlEditorHotkeysDescr ); + break; + + case ID_SELECT_PAGE_NUMBER: + { + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 ); + view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 ); + m_canvas->Refresh(); + } + break; + + case ID_SHEET_SET: + { + DIALOG_PAGES_SETTINGS dlg( this, wxSize( MAX_PAGE_SIZE_EDITORS_MILS, + MAX_PAGE_SIZE_EDITORS_MILS ) ); + dlg.SetWksFileName( GetCurrFileName() ); + dlg.EnableWksFileNamePicker( false ); + dlg.ShowModal(); + + cmd.SetId( ID_ZOOM_PAGE ); + wxPostEvent( this, cmd ); + } + break; + + default: + wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) ); + break; + } +} + + +/* called when the user select one of the 4 page corner as corner + * reference (or the left top paper corner) + */ +void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event ) +{ + m_originSelectChoice = m_originSelectBox->GetSelection(); + UpdateStatusBar(); // Update grid origin + m_canvas->Refresh(); +} + + +void PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode( wxCommandEvent& event ) +{ + WORKSHEET_DATAITEM::m_SpecialMode = (event.GetId() == ID_SHOW_PL_EDITOR_MODE); + m_canvas->Refresh(); +} + + +void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event ) +{ + Close( true ); +} + + +void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event) +{ + wxMessageBox( wxT( "Not yet available" ) ); +} + + +void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event) +{ + // static print data and page setup data, to remember settings during the session + static wxPrintData* s_PrintData; + static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL; + + const PAGE_INFO& pageInfo = GetPageSettings(); + + if( s_PrintData == NULL ) // First print + { + s_PrintData = new wxPrintData(); + s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH; + } + + if( !s_PrintData->Ok() ) + { + wxMessageBox( _( "Error Init Printer info" ) ); + return; + } + + if( s_pageSetupData == NULL ) + s_pageSetupData = new wxPageSetupDialogData( *s_PrintData ); + + s_pageSetupData->SetPaperId( pageInfo.GetPaperId() ); + s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); + + if( pageInfo.IsCustom() ) + { + if( pageInfo.IsPortrait() ) + s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ), + Mils2mm( pageInfo.GetHeightMils() ) ) ); + else + s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ), + Mils2mm( pageInfo.GetWidthMils() ) ) ); + } + + *s_PrintData = s_pageSetupData->GetPrintData(); + + if( event.GetId() == wxID_PREVIEW ) + InvokeDialogPrintPreview( this, s_PrintData ); + else + InvokeDialogPrint( this, s_PrintData, s_pageSetupData ); +} + + +void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event ) +{ + event.Check( WORKSHEET_DATAITEM::m_SpecialMode == false ); +} + + +void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event ) +{ + event.Check( WORKSHEET_DATAITEM::m_SpecialMode == true ); +} + + const BOX2I PL_EDITOR_FRAME::GetDocumentExtents() const { BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU() ); diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index bc1c49625e..689385de0a 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -53,7 +53,6 @@ class PL_EDITOR_FRAME : public EDA_DRAW_FRAME wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages // usefull when there are some items which are // only on page 1, not on page 1 - wxPoint m_grid_origin; protected: @@ -197,7 +196,7 @@ public: * source code (mainly in dialogs). If you need to define a configuration * setting that need to be loaded at run time, this is the place to define it. */ - PARAM_CFG_ARRAY& GetConfigurationSettings(); + PARAM_CFG_ARRAY& GetConfigurationSettings() { return m_configSettings; } void LoadSettings( wxConfigBase* aCfg ) override; @@ -245,8 +244,6 @@ public: bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override; - void Process_Config( wxCommandEvent& event ); - /** * Function ToPlotter * Open a dialog frame to create plot and drill files @@ -261,7 +258,6 @@ public: void ToPrinter( wxCommandEvent& event ); void Files_io( wxCommandEvent& event ); - bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override; /** Virtual function PrintPage * used to print a page diff --git a/pagelayout_editor/pl_editor_id.h b/pagelayout_editor/pl_editor_id.h index c33b41ca6e..dfb092ea5d 100644 --- a/pagelayout_editor/pl_editor_id.h +++ b/pagelayout_editor/pl_editor_id.h @@ -43,10 +43,6 @@ enum pl_editor_ids { ID_MAIN_MENUBAR = ID_END_LIST, - ID_PL_EDITOR_SHOW_SOURCE, - ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR, - ID_DESIGN_TREE_FRAME, - ID_SHOW_REAL_MODE, ID_SHOW_PL_EDITOR_MODE, ID_SELECT_COORDINATE_ORIGIN, @@ -61,18 +57,6 @@ enum pl_editor_ids ID_PL_IMAGE_TOOL, ID_PL_DELETE_TOOL, - ID_POPUP_START_RANGE, - ID_POPUP_ITEM_DELETE, - ID_POPUP_DESIGN_TREE_ITEM_DELETE, - ID_POPUP_ITEM_APPEND_PAGE_LAYOUT, - ID_POPUP_ITEM_MOVE, - ID_POPUP_ITEM_PLACE, - ID_POPUP_ITEM_MOVE_START_POINT, - ID_POPUP_ITEM_MOVE_END_POINT, - ID_POPUP_ITEM_PLACE_CANCEL, - ID_POPUP_ITEM_EDIT_BITMAP, - ID_POPUP_END_RANGE, - ID_PLEDITOR_END_LIST }; diff --git a/pagelayout_editor/properties_frame.cpp b/pagelayout_editor/properties_frame.cpp index 4978e9367e..29392815c2 100644 --- a/pagelayout_editor/properties_frame.cpp +++ b/pagelayout_editor/properties_frame.cpp @@ -288,6 +288,7 @@ void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event ) // Be sure what is displayed is what is set for item // (mainly, texts can be modified if they contain "\n") CopyPrmsFromItemToPanel( dataItem ); + m_parent->GetGalCanvas()->GetView()->Update( drawItem ); } CopyPrmsFromPanelToGeneral(); diff --git a/pagelayout_editor/toolbars_pl_editor.cpp b/pagelayout_editor/toolbars_pl_editor.cpp index fe7a334330..987619bf86 100644 --- a/pagelayout_editor/toolbars_pl_editor.cpp +++ b/pagelayout_editor/toolbars_pl_editor.cpp @@ -132,16 +132,17 @@ void PL_EDITOR_FRAME::ReCreateVToolbar() m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize, KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); - m_drawToolBar->Add( PL_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_drawToolBar, this ); - m_drawToolBar->Add( PL_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PL_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PL_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PL_ACTIONS::placeImage, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::placeImage, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::appendImportedWorksheet, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_drawToolBar, this ); - m_drawToolBar->Add( PL_ACTIONS::deleteItemCursor, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PL_ACTIONS::deleteItemCursor, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Realize(); } @@ -165,5 +166,7 @@ void PL_EDITOR_FRAME::SyncMenusAndToolbars() m_drawToolBar->Toggle( PL_ACTIONS::placeText, GetToolId() == ID_PL_TEXT_TOOL ); m_drawToolBar->Toggle( PL_ACTIONS::placeImage, GetToolId() == ID_PL_IMAGE_TOOL ); m_drawToolBar->Toggle( PL_ACTIONS::deleteItemCursor, GetToolId() == ID_PL_DELETE_TOOL ); + + m_drawToolBar->Toggle( PL_ACTIONS::appendImportedWorksheet, false ); // Not really a tool m_drawToolBar->Refresh(); } diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index 294859e4f7..ce731798a5 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -79,12 +79,6 @@ TOOL_ACTION PL_ACTIONS::addImage( "plEditor.InteractiveDrawing.addImage", _( "Add Bitmap" ), _( "Add a bitmap image" ), image_xpm, AF_ACTIVATE ); -TOOL_ACTION PL_ACTIONS::appendImportedWorksheet( "plEditor.InteractiveDrawing.appendWorksheet", - AS_GLOBAL, 0, - _( "Append Existing Page Layout File..." ), - _( "Append an existing page layout design file to current file" ), - pagelayout_load_xpm, AF_ACTIVATE ); - PL_DRAWING_TOOLS::PL_DRAWING_TOOLS() : TOOL_INTERACTIVE( "plEditor.InteractiveDrawing" ), diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 5ba71f15e4..f0fe5a515f 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -36,6 +36,7 @@ #include #include #include +#include TOOL_ACTION PL_ACTIONS::move( "plEditor.InteractiveEdit.move", @@ -43,6 +44,12 @@ TOOL_ACTION PL_ACTIONS::move( "plEditor.InteractiveEdit.move", _( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE ); +TOOL_ACTION PL_ACTIONS::appendImportedWorksheet( "plEditor.InteractiveEdit.appendWorksheet", + AS_GLOBAL, 0, + _( "Append Existing Page Layout File..." ), + _( "Append an existing page layout design file to current file" ), + import_xpm, AF_ACTIVATE ); + TOOL_ACTION PL_ACTIONS::deleteItemCursor( "plEditor.InteractiveEdit.deleteTool", AS_GLOBAL, 0, _( "Delete Items" ), _( "Delete clicked items" ), @@ -304,6 +311,17 @@ bool PL_EDIT_TOOL::updateModificationPoint( SELECTION& aSelection ) } +int PL_EDIT_TOOL::ImportWorksheetContent( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE ); + m_frame->Files_io( evt ); + + m_frame->SetNoToolSelected(); + + return 0; +} + + int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) { SELECTION& selection = m_selectionTool->RequestSelection(); @@ -387,11 +405,12 @@ int PL_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent ) void PL_EDIT_TOOL::setTransitions() { - Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() ); + Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() ); - Go( &PL_EDIT_TOOL::DoDelete, PL_ACTIONS::doDelete.MakeEvent() ); - Go( &PL_EDIT_TOOL::DeleteItemCursor, PL_ACTIONS::deleteItemCursor.MakeEvent() ); + Go( &PL_EDIT_TOOL::ImportWorksheetContent, PL_ACTIONS::appendImportedWorksheet.MakeEvent() ); + Go( &PL_EDIT_TOOL::DoDelete, PL_ACTIONS::doDelete.MakeEvent() ); + Go( &PL_EDIT_TOOL::DeleteItemCursor, PL_ACTIONS::deleteItemCursor.MakeEvent() ); - Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() ); - Go( &PL_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() ); + Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() ); + Go( &PL_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() ); } diff --git a/pagelayout_editor/tools/pl_edit_tool.h b/pagelayout_editor/tools/pl_edit_tool.h index 5a9aaa27f6..064866de7c 100644 --- a/pagelayout_editor/tools/pl_edit_tool.h +++ b/pagelayout_editor/tools/pl_edit_tool.h @@ -50,6 +50,8 @@ public: int Undo( const TOOL_EVENT& aEvent ); int Redo( const TOOL_EVENT& aEvent ); + int ImportWorksheetContent( const TOOL_EVENT& aEvent ); + /** * Function DoDelete() * diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index 7a917af867..4a4fd3377a 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -34,10 +34,10 @@ #include #include #include +#include #include #include #include - #include "pl_selection_tool.h" /** @@ -743,6 +743,9 @@ int PL_SELECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) int PL_SELECTION_TOOL::ToggleBackgroundColor( const TOOL_EVENT& aEvent ) { m_frame->SetDrawBgColor( m_frame->GetDrawBgColor() == WHITE ? BLACK : WHITE ); + getView()->GetPainter()->GetSettings()->SetBackgroundColor( m_frame->GetDrawBgColor() ); + + m_frame->GetGalCanvas()->GetView()->UpdateAllLayersColor(); m_frame->GetCanvas()->Refresh(); return 0;