13 changed files with 304 additions and 176 deletions
-
1pagelayout_editor/CMakeLists.txt
-
71pagelayout_editor/menubar.cpp
-
34pagelayout_editor/pl_editor_frame.cpp
-
15pagelayout_editor/pl_editor_frame.h
-
10pagelayout_editor/pl_editor_id.h
-
20pagelayout_editor/toolbars_pl_editor.cpp
-
9pagelayout_editor/tools/pl_actions.cpp
-
1pagelayout_editor/tools/pl_actions.h
-
7pagelayout_editor/tools/pl_edit_tool.cpp
-
178pagelayout_editor/tools/pl_editor_control.cpp
-
77pagelayout_editor/tools/pl_editor_control.h
-
52pagelayout_editor/tools/pl_selection_tool.cpp
-
5pagelayout_editor/tools/pl_selection_tool.h
@ -0,0 +1,178 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 <fctsys.h>
|
|||
#include <kiway.h>
|
|||
#include <view/view.h>
|
|||
#include <tool/tool_manager.h>
|
|||
#include <tools/pl_actions.h>
|
|||
#include <tools/pl_editor_control.h>
|
|||
#include <tools/pl_selection_tool.h>
|
|||
#include <pl_editor_frame.h>
|
|||
#include <worksheet_painter.h>
|
|||
#include <confirm.h>
|
|||
#include <bitmaps.h>
|
|||
#include <properties_frame.h>
|
|||
|
|||
TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview", |
|||
AS_GLOBAL, 0, "", "" ); |
|||
|
|||
TOOL_ACTION PL_ACTIONS::toggleBackground( "plEditor.EditorControl.ToggleBackground", |
|||
AS_GLOBAL, 0, |
|||
_( "Background White" ), _( "Switch between white and black background" ), |
|||
palette_xpm ); |
|||
|
|||
|
|||
bool PL_EDITOR_CONTROL::Init() |
|||
{ |
|||
m_frame = getEditFrame<PL_EDITOR_FRAME>(); |
|||
return true; |
|||
} |
|||
|
|||
|
|||
void PL_EDITOR_CONTROL::Reset( RESET_REASON aReason ) |
|||
{ |
|||
if( aReason == MODEL_RELOAD ) |
|||
m_frame = getEditFrame<PL_EDITOR_FRAME>(); |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
wxCommandEvent evt( wxEVT_NULL, wxID_NEW ); |
|||
m_frame->Files_io( evt ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
wxCommandEvent evt( wxEVT_NULL, wxID_OPEN ); |
|||
m_frame->Files_io( evt ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
wxCommandEvent evt( wxEVT_NULL, wxID_SAVE ); |
|||
m_frame->Files_io( evt ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
wxCommandEvent evt( wxEVT_NULL, wxID_SAVEAS ); |
|||
m_frame->Files_io( evt ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
wxCommandEvent evt( wxEVT_NULL, ID_SHEET_SET ); |
|||
m_frame->Process_Special_Functions( evt ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::Print( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
m_frame->ToPrinter( false ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
wxMessageBox( wxT( "Not yet available" ) ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::Quit( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
m_frame->Close( false ); |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::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; |
|||
} |
|||
|
|||
|
|||
int PL_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) |
|||
{ |
|||
PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>(); |
|||
SELECTION& selection = selTool->GetSelection(); |
|||
|
|||
if( selection.GetSize() == 1 ) |
|||
{ |
|||
EDA_ITEM* item = (EDA_ITEM*) selection.Front(); |
|||
|
|||
MSG_PANEL_ITEMS msgItems; |
|||
item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); |
|||
m_frame->SetMsgPanel( msgItems ); |
|||
|
|||
WORKSHEET_DATAITEM* dataItem = static_cast<WS_DRAW_ITEM_BASE*>( item )->GetPeer(); |
|||
m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem ); |
|||
} |
|||
else |
|||
{ |
|||
m_frame->ClearMsgPanel(); |
|||
m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( nullptr ); |
|||
} |
|||
|
|||
m_frame->GetPropertiesFrame()->CopyPrmsFromGeneralToPanel(); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
void PL_EDITOR_CONTROL::setTransitions() |
|||
{ |
|||
Go( &PL_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::PageSetup, ACTIONS::pageSetup.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() ); |
|||
Go( &PL_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() ); |
|||
|
|||
Go( &PL_EDITOR_CONTROL::ToggleBackgroundColor, PL_ACTIONS::toggleBackground.MakeEvent() ); |
|||
|
|||
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent ); |
|||
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent ); |
|||
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent ); |
|||
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::SelectedItemsModified ); |
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#ifndef PL_EDITOR_CONTROL_H |
|||
#define PL_EDITOR_CONTROL_H |
|||
|
|||
#include <tool/tool_interactive.h> |
|||
|
|||
class PL_EDITOR_FRAME; |
|||
|
|||
|
|||
/** |
|||
* Class PL_EDITOR_CONTROL |
|||
* |
|||
* Handles actions specific to the schematic editor in eeschema. |
|||
*/ |
|||
class PL_EDITOR_CONTROL : public wxEvtHandler, public TOOL_INTERACTIVE |
|||
{ |
|||
public: |
|||
PL_EDITOR_CONTROL() : |
|||
TOOL_INTERACTIVE( "plEditor.EditorControl" ), |
|||
m_frame( nullptr ) |
|||
{ } |
|||
|
|||
~PL_EDITOR_CONTROL() { } |
|||
|
|||
/// @copydoc TOOL_INTERACTIVE::Init() |
|||
bool Init() override; |
|||
|
|||
/// @copydoc TOOL_INTERACTIVE::Reset() |
|||
void Reset( RESET_REASON aReason ) override; |
|||
|
|||
int New( const TOOL_EVENT& aEvent ); |
|||
int Open( const TOOL_EVENT& aEvent ); |
|||
int Save( const TOOL_EVENT& aEvent ); |
|||
int SaveAs( const TOOL_EVENT& aEvent ); |
|||
int PageSetup( const TOOL_EVENT& aEvent ); |
|||
int Print( const TOOL_EVENT& aEvent ); |
|||
int Plot( const TOOL_EVENT& aEvent ); |
|||
int Quit( const TOOL_EVENT& aEvent ); |
|||
|
|||
int ToggleBackgroundColor( const TOOL_EVENT& aEvent ); |
|||
|
|||
int UpdateMessagePanel( const TOOL_EVENT& aEvent ); |
|||
|
|||
private: |
|||
///> Sets up handlers for various events. |
|||
void setTransitions() override; |
|||
|
|||
private: |
|||
PL_EDITOR_FRAME* m_frame; |
|||
|
|||
}; |
|||
|
|||
|
|||
#endif // PL_EDITOR_CONTROL_H |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue