2013-08-13 17:51:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 CERN
|
2017-06-10 08:07:11 +00:00
|
|
|
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-08-13 17:51:22 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2016-06-11 13:51:05 +00:00
|
|
|
/**
|
|
|
|
* @file pagelayout_editor/events_functions.cpp
|
|
|
|
* @brief page layout editor command event functions.
|
|
|
|
*/
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wx/treectrl.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
#include <pl_editor_frame.h>
|
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <pl_editor_id.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <menus_helpers.h>
|
|
|
|
#include <worksheet_shape_builder.h>
|
2018-01-29 08:39:13 +00:00
|
|
|
#include <worksheet_dataitem.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <design_tree_frame.h>
|
|
|
|
#include <properties_frame.h>
|
|
|
|
#include <dialog_page_settings.h>
|
|
|
|
#include <invoke_pl_editor_dialog.h>
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
|
|
|
|
EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow )
|
|
|
|
|
|
|
|
// Desing tree event:
|
|
|
|
EVT_TREE_SEL_CHANGED( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeSelection )
|
|
|
|
EVT_TREE_ITEM_MIDDLE_CLICK( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeMiddleClick )
|
|
|
|
EVT_TREE_ITEM_RIGHT_CLICK( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeRightClick )
|
|
|
|
|
|
|
|
// 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 )
|
2013-08-13 17:51:22 +00:00
|
|
|
EVT_MENU( ID_APPEND_DESCR_FILE, PL_EDITOR_FRAME::Files_io )
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
EVT_MENU( ID_GEN_PLOT, PL_EDITOR_FRAME::ToPlotter )
|
|
|
|
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory )
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit )
|
|
|
|
|
|
|
|
// menu Preferences
|
2018-05-14 17:34:18 +00:00
|
|
|
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Config )
|
2013-07-20 19:36:19 +00:00
|
|
|
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
|
2013-07-21 14:15:07 +00:00
|
|
|
EVT_MENU( ID_MENU_SWITCH_BGCOLOR, PL_EDITOR_FRAME::Process_Config )
|
|
|
|
EVT_MENU( ID_MENU_GRID_ONOFF, PL_EDITOR_FRAME::Process_Config )
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-04-25 13:04:38 +00:00
|
|
|
EVT_TOOL( wxID_DELETE, PL_EDITOR_FRAME::Process_Special_Functions )
|
2013-07-26 12:50:29 +00:00
|
|
|
EVT_TOOL( wxID_UNDO, PL_EDITOR_FRAME::GetLayoutFromUndoList )
|
|
|
|
EVT_TOOL( wxID_REDO, PL_EDITOR_FRAME::GetLayoutFromRedoList )
|
2013-07-19 18:27:22 +00:00
|
|
|
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 )
|
2016-09-09 18:29:21 +00:00
|
|
|
EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
|
2016-06-11 13:51:05 +00:00
|
|
|
EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::Process_Special_Functions )
|
2013-07-19 18:27:22 +00:00
|
|
|
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
|
|
|
|
EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions)
|
|
|
|
|
2017-06-10 08:07:11 +00:00
|
|
|
// the ID_NO_TOOL_SELECTED id TOOL does not existing currently, but the right click
|
|
|
|
// popup menu can generate this event.
|
2013-07-19 18:27:22 +00:00
|
|
|
EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
|
2018-03-11 17:38:27 +00:00
|
|
|
EVT_TOOL( ID_POPUP_CANCEL_CURRENT_COMMAND, PL_EDITOR_FRAME::Process_Special_Functions )
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
|
|
|
PL_EDITOR_FRAME::Process_Special_Functions )
|
|
|
|
|
2016-06-11 13:51:05 +00:00
|
|
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::OnUpdateSelectTool )
|
2017-06-10 08:07:11 +00:00
|
|
|
|
2016-06-11 13:51:05 +00:00
|
|
|
EVT_UPDATE_UI( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::OnUpdateSelectTool )
|
2013-07-19 18:27:22 +00:00
|
|
|
EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode )
|
2013-08-13 17:51:22 +00:00
|
|
|
EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode )
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/* Handles the selection of tools, menu, and popup menu commands.
|
|
|
|
*/
|
|
|
|
void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
int idx;
|
|
|
|
wxString msg;
|
|
|
|
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
|
|
|
WORKSHEET_DATAITEM* item = NULL;
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_NO_TOOL_SELECTED:
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2015-02-26 10:33:15 +00:00
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2016-06-11 13:51:05 +00:00
|
|
|
case ID_ZOOM_SELECTION:
|
2017-06-10 08:07:11 +00:00
|
|
|
// This tool is located on the main toolbar: switch it on or off on click
|
|
|
|
if( GetToolId() != ID_ZOOM_SELECTION )
|
|
|
|
SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
|
|
|
|
else
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2016-06-11 13:51:05 +00:00
|
|
|
break;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
case ID_SELECT_PAGE_NUMBER:
|
|
|
|
m_canvas->Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SHEET_SET:
|
|
|
|
{
|
2018-08-04 11:18:15 +00:00
|
|
|
DIALOG_PAGES_SETTINGS dlg( this, wxSize( MAX_PAGE_SIZE_EDITORS_MILS,
|
|
|
|
MAX_PAGE_SIZE_EDITORS_MILS ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
dlg.SetWksFileName( GetCurrFileName() );
|
|
|
|
dlg.EnableWksFileNamePicker( false );
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
|
|
|
cmd.SetId( ID_ZOOM_PAGE );
|
|
|
|
wxPostEvent( this, cmd );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2018-03-11 17:38:27 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
{
|
|
|
|
m_canvas->EndMouseCapture();
|
|
|
|
SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetNoToolSelected();
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DESIGN_TREE_ITEM_DELETE:
|
|
|
|
case ID_POPUP_ITEM_DELETE:
|
2019-04-25 13:04:38 +00:00
|
|
|
case wxID_DELETE:
|
2013-07-19 18:27:22 +00:00
|
|
|
// Delete item, and select the previous item
|
|
|
|
item = m_treePagelayout->GetPageLayoutSelectedItem();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
break;
|
|
|
|
|
2013-07-26 12:50:29 +00:00
|
|
|
SaveCopyInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
idx = pglayout.GetItemIndex( item );
|
|
|
|
pglayout.Remove( item );
|
|
|
|
RebuildDesignTree();
|
|
|
|
|
|
|
|
if( id == ID_POPUP_DESIGN_TREE_ITEM_DELETE )
|
|
|
|
{
|
|
|
|
item = pglayout.GetItem( (unsigned) (idx-1) );
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
m_treePagelayout->SelectCell( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
item = NULL;
|
|
|
|
OnModify();
|
|
|
|
m_canvas->Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ITEM_ADD_LINE:
|
2013-07-26 12:50:29 +00:00
|
|
|
SaveCopyInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
idx = m_treePagelayout->GetSelectedItemIndex();
|
|
|
|
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_SEGMENT, idx );
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
|
|
|
|
{
|
2013-07-26 12:50:29 +00:00
|
|
|
RemoveLastCommandInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
pglayout.Remove( item );
|
|
|
|
RebuildDesignTree();
|
|
|
|
item = NULL;
|
|
|
|
}
|
2013-08-13 17:51:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Put the new item in move mode, after putting the cursor
|
|
|
|
// on the start point:
|
|
|
|
wxPoint position = item->GetStartPosUi();
|
|
|
|
SetCrossHairPosition( position, false );
|
|
|
|
position = GetCrossHairPosition();
|
|
|
|
|
|
|
|
if( m_canvas->IsPointOnDisplay( position ) )
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
else
|
|
|
|
RedrawScreen( position, true );
|
|
|
|
|
|
|
|
item->SetFlags( NEW_ITEM );
|
|
|
|
MoveItem( item );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ITEM_ADD_RECT:
|
2013-07-26 12:50:29 +00:00
|
|
|
SaveCopyInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
idx = m_treePagelayout->GetSelectedItemIndex();
|
|
|
|
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_RECT, idx );
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
|
|
|
|
{
|
2013-07-26 12:50:29 +00:00
|
|
|
RemoveLastCommandInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
pglayout.Remove( item );
|
|
|
|
RebuildDesignTree();
|
|
|
|
item = NULL;
|
|
|
|
}
|
2013-08-13 17:51:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Put the new item in move mode, after putting the cursor
|
|
|
|
// on the start point:
|
|
|
|
wxPoint position = item->GetStartPosUi();
|
|
|
|
SetCrossHairPosition( position, false );
|
|
|
|
position = GetCrossHairPosition();
|
|
|
|
|
|
|
|
if( m_canvas->IsPointOnDisplay( position ) )
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
else
|
|
|
|
RedrawScreen( position, true );
|
|
|
|
|
|
|
|
item->SetFlags( NEW_ITEM );
|
|
|
|
MoveItem( item );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ITEM_ADD_TEXT:
|
2013-07-26 12:50:29 +00:00
|
|
|
SaveCopyInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
idx = m_treePagelayout->GetSelectedItemIndex();
|
|
|
|
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_TEXT, idx );
|
|
|
|
if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
|
|
|
|
{
|
2013-07-26 12:50:29 +00:00
|
|
|
RemoveLastCommandInUndoList();
|
2013-07-19 18:27:22 +00:00
|
|
|
pglayout.Remove( item );
|
|
|
|
RebuildDesignTree();
|
|
|
|
item = NULL;
|
|
|
|
}
|
2013-08-13 17:51:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Put the new text in move mode:
|
|
|
|
item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
|
|
|
|
MoveItem( item );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
break;
|
|
|
|
|
2013-10-18 17:38:03 +00:00
|
|
|
case ID_POPUP_ITEM_ADD_BITMAP:
|
|
|
|
SaveCopyInUndoList();
|
|
|
|
idx = m_treePagelayout->GetSelectedItemIndex();
|
|
|
|
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx );
|
|
|
|
if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL )
|
|
|
|
{
|
|
|
|
RemoveLastCommandInUndoList();
|
|
|
|
pglayout.Remove( item );
|
|
|
|
RebuildDesignTree();
|
|
|
|
item = NULL;
|
|
|
|
}
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
// Put the new text in move mode:
|
|
|
|
item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
|
|
|
|
MoveItem( item );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-08-13 17:51:22 +00:00
|
|
|
case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT:
|
|
|
|
cmd.SetId( ID_APPEND_DESCR_FILE );
|
2013-07-19 18:27:22 +00:00
|
|
|
wxPostEvent( this, cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ITEM_PLACE:
|
|
|
|
item = GetScreen()->GetCurItem();
|
2013-07-26 12:50:29 +00:00
|
|
|
PlaceItem( item );
|
2013-07-19 18:27:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ITEM_PLACE_CANCEL:
|
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
m_canvas->EndMouseCapture();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ITEM_MOVE_START_POINT:
|
2013-07-23 16:45:23 +00:00
|
|
|
item = m_treePagelayout->GetPageLayoutSelectedItem();
|
2013-07-24 15:11:35 +00:00
|
|
|
// Ensure flags are properly set
|
2013-07-23 16:45:23 +00:00
|
|
|
item->ClearFlags( LOCATE_ENDPOINT );
|
2013-07-24 15:11:35 +00:00
|
|
|
item->SetFlags( LOCATE_STARTPOINT );
|
2013-07-23 16:45:23 +00:00
|
|
|
MoveItem( item );
|
|
|
|
break;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
case ID_POPUP_ITEM_MOVE_END_POINT:
|
2013-07-23 16:45:23 +00:00
|
|
|
item = m_treePagelayout->GetPageLayoutSelectedItem();
|
2013-07-24 15:11:35 +00:00
|
|
|
// Ensure flags are properly set
|
2013-07-23 16:45:23 +00:00
|
|
|
item->ClearFlags( LOCATE_STARTPOINT );
|
2013-07-24 15:11:35 +00:00
|
|
|
item->SetFlags( LOCATE_ENDPOINT );
|
2013-07-23 16:45:23 +00:00
|
|
|
MoveItem( item );
|
|
|
|
break;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
case ID_POPUP_ITEM_MOVE:
|
|
|
|
item = m_treePagelayout->GetPageLayoutSelectedItem();
|
2013-07-23 16:45:23 +00:00
|
|
|
item->ClearFlags( LOCATE_ENDPOINT|LOCATE_STARTPOINT );
|
2013-07-19 18:27:22 +00:00
|
|
|
MoveItem( item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
OnModify();
|
|
|
|
m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
|
|
|
|
m_treePagelayout->SelectCell( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-13 17:51:22 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2013-07-19 18:27:22 +00:00
|
|
|
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." ) );
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint position = aPanel->GetParent()->GetCrossHairPosition()
|
2013-07-19 18:27:22 +00:00
|
|
|
- ( initialCursorPosition - initialPositionUi );
|
2014-05-19 18:24:07 +00:00
|
|
|
wxPoint previous_position;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
if( (item->GetFlags() & LOCATE_STARTPOINT) )
|
2014-05-19 18:24:07 +00:00
|
|
|
{
|
|
|
|
previous_position = item->GetStartPosUi();
|
2013-07-26 12:50:29 +00:00
|
|
|
item->MoveStartPointToUi( position );
|
2014-05-19 18:24:07 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
else if( (item->GetFlags() & LOCATE_ENDPOINT) )
|
2014-05-19 18:24:07 +00:00
|
|
|
{
|
|
|
|
previous_position = item->GetEndPosUi();
|
2013-07-26 12:50:29 +00:00
|
|
|
item->MoveEndPointToUi( position );
|
2014-05-19 18:24:07 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
else
|
2014-05-19 18:24:07 +00:00
|
|
|
{
|
|
|
|
previous_position = item->GetStartPosUi();
|
2013-07-26 12:50:29 +00:00
|
|
|
item->MoveToUi( position );
|
2014-05-19 18:24:07 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2014-05-19 18:24:07 +00:00
|
|
|
// 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.
|
2015-02-17 18:47:21 +00:00
|
|
|
if( previous_position != position )
|
2013-07-26 12:50:29 +00:00
|
|
|
aPanel->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-08-13 17:51:22 +00:00
|
|
|
/*
|
|
|
|
* Function abortMoveItem: called when an item is currently moving,
|
|
|
|
* and when the user aborts the move command.
|
|
|
|
* Restores the initial position of the item
|
|
|
|
*/
|
2013-07-19 18:27:22 +00:00
|
|
|
static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
|
|
|
{
|
|
|
|
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen();
|
|
|
|
WORKSHEET_DATAITEM *item = screen->GetCurItem();
|
2013-08-13 17:51:22 +00:00
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
if( item->GetFlags() & NEW_ITEM )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2013-08-13 17:51:22 +00:00
|
|
|
PL_EDITOR_FRAME* plframe = (PL_EDITOR_FRAME*) aPanel->GetParent();
|
|
|
|
plframe->RemoveLastCommandInUndoList();
|
|
|
|
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
|
|
|
pglayout.Remove( item );
|
|
|
|
plframe->RebuildDesignTree();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-08-13 17:51:22 +00:00
|
|
|
else
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2013-08-13 17:51:22 +00:00
|
|
|
if( (item->GetFlags() & LOCATE_STARTPOINT) )
|
|
|
|
{
|
|
|
|
item->MoveStartPointTo( initialPosition );
|
|
|
|
}
|
|
|
|
else if( (item->GetFlags() & LOCATE_ENDPOINT) )
|
|
|
|
{
|
|
|
|
item->MoveEndPointTo( initialPosition );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
item->MoveTo( initialPosition );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aPanel->SetMouseCapture( NULL, NULL );
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
aPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) );
|
|
|
|
initialPosition = aItem->GetStartPos();
|
|
|
|
initialPositionUi = aItem->GetStartPosUi();
|
2013-08-03 05:15:23 +00:00
|
|
|
initialCursorPosition = GetCrossHairPosition();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
if( (aItem->GetFlags() & LOCATE_ENDPOINT) )
|
|
|
|
{
|
|
|
|
initialPosition = aItem->GetEndPos();
|
|
|
|
initialPositionUi = aItem->GetEndPosUi();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( initialPositionUi, false );
|
|
|
|
initialCursorPosition = GetCrossHairPosition();
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-24 15:11:35 +00:00
|
|
|
if( m_canvas->IsPointOnDisplay( initialCursorPosition ) )
|
|
|
|
{
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RedrawScreen( initialCursorPosition, true );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_canvas->SetMouseCapture( moveItem, abortMoveItem );
|
|
|
|
GetScreen()->SetCurItem( aItem );
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2013-07-26 12:50:29 +00:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2013-08-13 17:51:22 +00:00
|
|
|
aItem->ClearFlags( NEW_ITEM );
|
|
|
|
|
2013-07-26 12:50:29 +00:00
|
|
|
// Save the curren layout before changes
|
|
|
|
if( (aItem->GetFlags() & LOCATE_STARTPOINT) )
|
|
|
|
{
|
|
|
|
aItem->MoveStartPointTo( initialPosition );
|
|
|
|
}
|
2015-02-17 18:47:21 +00:00
|
|
|
else if( aItem->GetFlags() & LOCATE_ENDPOINT )
|
2013-07-26 12:50:29 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/* 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();
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode( wxCommandEvent& event )
|
|
|
|
{
|
2013-08-13 17:51:22 +00:00
|
|
|
WORKSHEET_DATAITEM::m_SpecialMode = (event.GetId() == ID_SHOW_PL_EDITOR_MODE);
|
2013-07-19 18:27:22 +00:00
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Close( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event)
|
|
|
|
{
|
2015-02-17 18:47:21 +00:00
|
|
|
wxMessageBox( wxT( "Not yet available" ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnTreeSelection( wxTreeEvent& event )
|
|
|
|
{
|
|
|
|
WORKSHEET_DATAITEM* item = GetSelectedItem();
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
|
|
|
|
|
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnTreeMiddleClick( wxTreeEvent& event )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-08-13 17:51:22 +00:00
|
|
|
extern void AddNewItemsCommand( wxMenu* aMainMenu );
|
2015-02-17 18:47:21 +00:00
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnTreeRightClick( wxTreeEvent& event )
|
|
|
|
{
|
|
|
|
m_treePagelayout->SelectCell( event.GetItem() );
|
|
|
|
|
|
|
|
wxMenu popMenu;
|
2013-08-13 17:51:22 +00:00
|
|
|
AddNewItemsCommand( &popMenu );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
popMenu.AppendSeparator();
|
|
|
|
AddMenuItem( &popMenu, ID_POPUP_DESIGN_TREE_ITEM_DELETE, _( "Delete" ),
|
|
|
|
KiBitmap( delete_xpm ) );
|
|
|
|
|
|
|
|
PopupMenu( &popMenu );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
event.Check( WORKSHEET_DATAITEM::m_SpecialMode == false );
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:47:21 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
event.Check( WORKSHEET_DATAITEM::m_SpecialMode == true );
|
|
|
|
}
|
2016-06-11 13:51:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2018-04-14 15:44:17 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2016-06-11 13:51:05 +00:00
|
|
|
}
|