2013-07-19 18:27:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-08-13 17:51:22 +00:00
|
|
|
* 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
|
2013-07-19 18:27:22 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2016-06-11 13:51:05 +00:00
|
|
|
/**
|
|
|
|
* @file pl_editor_frame.cpp
|
|
|
|
*/
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <fctsys.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 <kiface_i.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <build_version.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <base_units.h>
|
|
|
|
#include <msgpanel.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
#include <pl_editor_frame.h>
|
|
|
|
#include <pl_editor_id.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
#include <class_pl_editor_screen.h>
|
|
|
|
#include <worksheet_shape_builder.h>
|
|
|
|
#include <class_worksheet_dataitem.h>
|
|
|
|
#include <design_tree_frame.h>
|
|
|
|
#include <properties_frame.h>
|
|
|
|
|
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
|
|
|
|
/*************************/
|
|
|
|
/* class PL_EDITOR_FRAME */
|
|
|
|
/*************************/
|
|
|
|
|
* 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
|
|
|
PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2014-04-19 18:47:20 +00:00
|
|
|
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
|
* 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
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2015-01-06 07:38:58 +00:00
|
|
|
m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
|
|
|
|
// when the screen shows a 1:1 image
|
|
|
|
// obviously depends on the monitor,
|
|
|
|
// but this is an acceptable value
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2014-06-20 11:13:04 +00:00
|
|
|
m_showAxis = false; // true to show X and Y axis on screen
|
2013-07-19 18:27:22 +00:00
|
|
|
m_showGridAxis = true;
|
2014-06-20 11:13:04 +00:00
|
|
|
m_showBorderAndTitleBlock = true; // true for reference drawings.
|
2015-05-19 16:39:05 +00:00
|
|
|
m_hotkeysDescrList = PlEditorHokeysDescr;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_originSelectChoice = 0;
|
2014-06-20 11:13:04 +00:00
|
|
|
SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
|
|
|
|
SetShowPageLimits( true );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-19 07:08:13 +00:00
|
|
|
m_designTreeWidth = 150;
|
|
|
|
m_propertiesFrameWidth = 200;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
if( m_canvas )
|
2016-06-11 13:51:05 +00:00
|
|
|
m_canvas->SetEnableBlockCommands( true );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
|
|
|
|
SetIcon( icon );
|
|
|
|
wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
|
|
|
|
SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
|
|
|
|
|
* 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
|
|
|
LoadSettings( config() );
|
2013-07-19 18:27:22 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
2015-05-12 09:05:36 +00:00
|
|
|
if( ! GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
|
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000;
|
|
|
|
|
|
|
|
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateOptToolbar();
|
|
|
|
|
|
|
|
wxWindow* stsbar = GetStatusBar();
|
|
|
|
int dims[] = {
|
|
|
|
|
|
|
|
// balance of status bar on far left is set to a default or whatever is left over.
|
|
|
|
-1,
|
|
|
|
|
|
|
|
// When using GetTextSize() remember the width of '1' is not the same
|
|
|
|
// as the width of '0' unless the font is fixed width, and it usually won't be.
|
|
|
|
|
|
|
|
// zoom:
|
|
|
|
GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
|
|
|
|
|
|
|
|
// cursor coords
|
|
|
|
GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
|
|
|
|
|
|
|
|
// delta distances
|
|
|
|
GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
|
|
|
|
|
|
|
|
// Coord origin (use the bigger message)
|
|
|
|
GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
|
|
|
|
|
|
|
|
// units display, Inches is bigger than mm
|
|
|
|
GetTextSize( _( "Inches" ), stsbar ).x + 10
|
|
|
|
};
|
|
|
|
|
|
|
|
SetStatusWidths( DIM( dims ), dims );
|
|
|
|
|
|
|
|
|
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
|
|
|
EDA_PANEINFO horiz;
|
|
|
|
horiz.HorizontalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO vert;
|
|
|
|
vert.VerticalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO mesg;
|
|
|
|
mesg.MessageToolbarPane();
|
|
|
|
|
|
|
|
m_propertiesPagelayout = new PROPERTIES_FRAME( this );
|
|
|
|
EDA_PANEINFO props;
|
|
|
|
props.LayersToolbarPane();
|
|
|
|
props.MinSize( m_propertiesPagelayout->GetMinSize() );
|
|
|
|
props.BestSize( m_propertiesFrameWidth, -1 );
|
|
|
|
props.Caption( _( "Properties" ) );
|
|
|
|
|
|
|
|
m_treePagelayout = new DESIGN_TREE_FRAME( this );
|
|
|
|
EDA_PANEINFO tree;
|
|
|
|
tree.LayersToolbarPane();
|
|
|
|
tree.MinSize( m_treePagelayout->GetMinSize() );
|
|
|
|
tree.BestSize( m_designTreeWidth, -1 );
|
|
|
|
tree.Caption( _( "Design" ) );
|
|
|
|
|
|
|
|
if( m_mainToolBar )
|
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
|
|
|
|
|
|
|
|
if( m_drawToolBar )
|
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_propertiesPagelayout,
|
|
|
|
props.Name( wxT( "m_propertiesPagelayout" ) ).Right().Layer( 1 ) );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_treePagelayout,
|
|
|
|
tree.Name( wxT( "m_treePagelayout" ) ).Left().Layer( 0 ) );
|
|
|
|
|
|
|
|
if( m_optionsToolBar )
|
|
|
|
m_auimgr.AddPane( m_optionsToolBar,
|
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
|
|
|
|
|
|
|
|
if( m_canvas )
|
|
|
|
m_auimgr.AddPane( m_canvas,
|
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane().Layer( 5 ) );
|
|
|
|
|
|
|
|
if( m_messagePanel )
|
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
|
|
|
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) );
|
|
|
|
|
|
|
|
m_auimgr.Update();
|
2014-06-07 16:20:23 +00:00
|
|
|
|
|
|
|
// Initialize the current page layout
|
|
|
|
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
|
|
|
#if 0 //start with empty layout
|
|
|
|
pglayout.AllowVoidList( true );
|
|
|
|
pglayout.ClearList();
|
|
|
|
#else // start with the default Kicad layout
|
|
|
|
pglayout.SetPageLayout();
|
|
|
|
#endif
|
|
|
|
OnNewPageLayout();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PL_EDITOR_FRAME::~PL_EDITOR_FRAME()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
* 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
|
|
|
bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
|
|
|
|
{
|
|
|
|
wxString fn = aFileSet[0];
|
|
|
|
|
|
|
|
if( !LoadPageLayoutDescrFile( fn ) )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format(
|
|
|
|
_( "Error when loading file '%s'" ),
|
|
|
|
GetChars( fn )
|
|
|
|
);
|
|
|
|
|
|
|
|
wxMessageBox( msg );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OnNewPageLayout();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|
|
|
{
|
|
|
|
if( GetScreen()->IsModify() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
wxString filename = GetCurrFileName();
|
2016-05-10 06:56:03 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( filename.IsEmpty() )
|
|
|
|
msg = _("Save changes in a new file before closing?");
|
|
|
|
else
|
|
|
|
msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"),
|
|
|
|
GetChars( filename ) );
|
|
|
|
|
|
|
|
int ii = DisplayExitDialog( this, msg );
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( ii )
|
|
|
|
{
|
|
|
|
case wxID_CANCEL:
|
|
|
|
Event.Veto();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case wxID_NO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_OK:
|
|
|
|
case wxID_YES:
|
|
|
|
{
|
|
|
|
if( filename.IsEmpty() )
|
|
|
|
{
|
2017-08-29 15:07:48 +00:00
|
|
|
wxFileDialog openFileDialog(this, _("Save As"), wxEmptyString,
|
2013-07-19 18:27:22 +00:00
|
|
|
wxEmptyString, PageLayoutDescrFileWildcard, wxFD_SAVE);
|
|
|
|
|
|
|
|
if (openFileDialog.ShowModal() == wxID_CANCEL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = openFileDialog.GetPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !SavePageLayoutDescrFile( filename ) )
|
|
|
|
{
|
|
|
|
msg.Printf( _("Unable to create <%s>"), GetChars( filename ) );
|
|
|
|
wxMessageBox( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// do not show the window because we do not want any paint event
|
|
|
|
Show( false );
|
2013-08-19 07:08:13 +00:00
|
|
|
|
* 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
|
|
|
// was: Pgm().SaveCurrentSetupValues( m_configSettings );
|
|
|
|
wxConfigSaveSetups( Kiface().KifaceSettings(), m_configSettings );
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2013-08-19 07:08:13 +00:00
|
|
|
// On Linux, m_propertiesPagelayout must be destroyed
|
|
|
|
// before deleting the main frame to avoid a crash when closing
|
|
|
|
m_propertiesPagelayout->Destroy();
|
2013-07-19 18:27:22 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double PL_EDITOR_FRAME::BestZoom()
|
|
|
|
{
|
|
|
|
int dx, dy;
|
|
|
|
wxSize size;
|
|
|
|
|
|
|
|
dx = GetPageLayout().GetPageSettings().GetWidthIU();
|
|
|
|
dy = GetPageLayout().GetPageSettings().GetHeightIU();
|
|
|
|
|
|
|
|
size = m_canvas->GetClientSize();
|
|
|
|
|
|
|
|
// Reserve no margin because best zoom shows the full page
|
|
|
|
// and margins are already included in function that draws the sheet refernces
|
|
|
|
double margin_scale_factor = 1.0;
|
|
|
|
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
|
|
|
|
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
|
|
|
|
|
|
|
|
double bestzoom = std::max( zx, zy );
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
return bestzoom;
|
|
|
|
}
|
|
|
|
|
2014-06-20 11:13:04 +00:00
|
|
|
static const wxChar designTreeWidthKey[] = wxT("DesignTreeWidth");
|
|
|
|
static const wxChar propertiesFrameWidthKey[] = wxT("PropertiesFrameWidth");
|
|
|
|
static const wxChar cornerOriginChoiceKey[] = wxT("CornerOriginChoice");
|
|
|
|
static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
* 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
|
|
|
void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
* 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
|
|
|
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2014-06-20 11:13:04 +00:00
|
|
|
aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
|
|
|
|
aCfg->Read( propertiesFrameWidthKey, &m_propertiesFrameWidth, 150);
|
|
|
|
aCfg->Read( cornerOriginChoiceKey, &m_originSelectChoice );
|
|
|
|
bool tmp;
|
|
|
|
aCfg->Read( blackBgColorKey, &tmp, false );
|
|
|
|
SetDrawBgColor( tmp ? BLACK : WHITE );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
* 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
|
|
|
void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
* 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
|
|
|
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
m_designTreeWidth = m_treePagelayout->GetSize().x;
|
|
|
|
m_propertiesFrameWidth = m_propertiesPagelayout->GetSize().x;
|
|
|
|
|
2014-06-20 11:13:04 +00:00
|
|
|
aCfg->Write( designTreeWidthKey, m_designTreeWidth);
|
|
|
|
aCfg->Write( propertiesFrameWidthKey, m_propertiesFrameWidth);
|
|
|
|
aCfg->Write( cornerOriginChoiceKey, m_originSelectChoice );
|
|
|
|
aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
* 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
|
|
|
// was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function UpdateTitleAndInfo
|
|
|
|
* displays the filename (if exists) of the current page layout descr file.
|
|
|
|
*/
|
|
|
|
void PL_EDITOR_FRAME::UpdateTitleAndInfo()
|
|
|
|
{
|
|
|
|
wxString title;
|
2016-09-26 17:15:33 +00:00
|
|
|
wxString file = GetCurrFileName();
|
|
|
|
|
|
|
|
title.Printf( _( "Page Layout Editor" ) + L" \u2014 %s",
|
|
|
|
!!file ? file : _( "no file selected" ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
SetTitle( title );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the filename of the current layout descr file
|
|
|
|
*/
|
|
|
|
const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
|
|
|
|
{
|
|
|
|
return BASE_SCREEN::m_PageLayoutDescrFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stores the current layout descr file filename
|
|
|
|
*/
|
|
|
|
void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
|
|
|
|
{
|
|
|
|
BASE_SCREEN::m_PageLayoutDescrFileName = aName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
|
|
|
|
{
|
|
|
|
m_pageLayout.SetPageSettings( aPageSettings );
|
|
|
|
|
|
|
|
if( GetScreen() )
|
|
|
|
GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PAGE_INFO& PL_EDITOR_FRAME::GetPageSettings() const
|
|
|
|
{
|
|
|
|
return m_pageLayout.GetPageSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
|
|
|
|
{
|
|
|
|
// this function is only needed because EDA_DRAW_FRAME is not compiled
|
|
|
|
// with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
|
|
|
|
// into an application specific source file.
|
|
|
|
return m_pageLayout.GetPageSettings().GetSizeIU();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TITLE_BLOCK& PL_EDITOR_FRAME::GetTitleBlock() const
|
|
|
|
{
|
|
|
|
return GetPageLayout().GetTitleBlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
|
|
|
|
{
|
|
|
|
m_pageLayout.SetTitleBlock( aTitleBlock );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the status bar information.
|
|
|
|
*/
|
|
|
|
void PL_EDITOR_FRAME::UpdateStatusBar()
|
|
|
|
{
|
|
|
|
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
|
|
|
|
|
|
|
|
if( !screen )
|
|
|
|
return;
|
|
|
|
|
2015-01-06 07:38:58 +00:00
|
|
|
// Display Zoom level:
|
|
|
|
EDA_DRAW_FRAME::UpdateStatusBar();
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// coodinate origin can be the paper Top Left corner,
|
|
|
|
// or each of 4 page corners
|
|
|
|
// We know the origin, and the orientation of axis
|
|
|
|
wxPoint originCoord;
|
|
|
|
int Xsign = 1;
|
|
|
|
int Ysign = 1;
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
WORKSHEET_DATAITEM dummy( WORKSHEET_DATAITEM::WS_SEGMENT );
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( m_originSelectChoice )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
default:
|
|
|
|
case 0: // Origin = paper Left Top corner
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 1: // Origin = page Right Bottom corner
|
|
|
|
Xsign = -1;
|
|
|
|
Ysign = -1;
|
|
|
|
dummy.SetStart( 0, 0, RB_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 2: // Origin = page Left Bottom corner
|
|
|
|
Ysign = -1;
|
|
|
|
dummy.SetStart( 0, 0, LB_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 3: // Origin = page Right Top corner
|
|
|
|
Xsign = -1;
|
|
|
|
dummy.SetStart( 0, 0, RT_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 4: // Origin = page Left Top corner
|
|
|
|
dummy.SetStart( 0, 0, LT_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetGridOrigin( originCoord );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Display absolute coordinates:
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint coord = GetCrossHairPosition() - originCoord;
|
2013-07-19 18:27:22 +00:00
|
|
|
double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign );
|
|
|
|
double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign );
|
|
|
|
|
2015-04-19 11:07:31 +00:00
|
|
|
wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
|
2013-07-26 12:50:29 +00:00
|
|
|
wxString absformatter = wxT( "X %.4g Y %.4g" );
|
|
|
|
wxString locformatter = wxT( "dx %.4g dy %.4g" );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( g_UserUnit )
|
|
|
|
{
|
|
|
|
case INCHES: // Should not be used in page layout editor
|
|
|
|
SetStatusText( _("inches"), 5 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MILLIMETRES:
|
|
|
|
SetStatusText( _("mm"), 5 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNSCALED_UNITS:
|
2013-07-24 15:11:35 +00:00
|
|
|
SetStatusText( wxEmptyString, 5 );
|
2013-07-19 18:27:22 +00:00
|
|
|
break;
|
2015-02-19 15:03:45 +00:00
|
|
|
|
|
|
|
case DEGREES:
|
|
|
|
wxASSERT( false );
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString line;
|
2013-07-24 15:11:35 +00:00
|
|
|
|
|
|
|
// Display page size
|
|
|
|
#define milsTomm (25.4/1000)
|
|
|
|
DSIZE size = GetPageSettings().GetSizeMils();
|
|
|
|
size = size * milsTomm;
|
|
|
|
line.Printf( pagesizeformatter, size.x, size.y );
|
|
|
|
SetStatusText( line, 0 );
|
|
|
|
|
|
|
|
// Display abs coordinates
|
2013-07-19 18:27:22 +00:00
|
|
|
line.Printf( absformatter, dXpos, dYpos );
|
|
|
|
SetStatusText( line, 2 );
|
|
|
|
|
|
|
|
// Display relative coordinates:
|
2013-08-03 05:15:23 +00:00
|
|
|
int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
|
|
|
|
int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
|
2013-07-19 18:27:22 +00:00
|
|
|
dXpos = To_User_Unit( g_UserUnit, dx * Xsign );
|
|
|
|
dYpos = To_User_Unit( g_UserUnit, dy * Ysign );
|
|
|
|
line.Printf( locformatter, dXpos, dYpos );
|
|
|
|
SetStatusText( line, 3 );
|
|
|
|
|
|
|
|
// Display corner reference for coord origin
|
|
|
|
line.Printf( _("coord origin: %s"),
|
|
|
|
m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
|
|
|
|
SetStatusText( line, 4 );
|
|
|
|
|
|
|
|
// Display units
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
|
2013-07-19 18:27:22 +00:00
|
|
|
bool aPrintMirrorMode, void * aData )
|
|
|
|
{
|
|
|
|
GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
|
|
|
|
DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
|
|
|
|
{
|
2013-07-20 19:36:19 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
if( aEraseBg )
|
|
|
|
m_canvas->EraseScreen( aDC );
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_canvas->DrawBackGround( aDC );
|
|
|
|
|
|
|
|
const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
|
|
|
WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
|
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
// the color to draw selected items
|
2014-06-20 11:13:04 +00:00
|
|
|
if( GetDrawBgColor() == WHITE )
|
2013-07-20 19:36:19 +00:00
|
|
|
WORKSHEET_DATAITEM::m_SelectedColor = DARKCYAN;
|
|
|
|
else
|
|
|
|
WORKSHEET_DATAITEM::m_SelectedColor = YELLOW;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
for( unsigned ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
break;
|
|
|
|
|
|
|
|
item->SetSelected( item == selecteditem );
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, GetCurrFileName() );
|
|
|
|
|
2014-06-16 16:32:23 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
if( IsShown() )
|
|
|
|
{
|
|
|
|
m_overlay.Reset();
|
|
|
|
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)aDC );
|
|
|
|
overlaydc.Clear();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
|
|
|
|
|
|
|
|
m_canvas->DrawCrossHair( aDC );
|
|
|
|
|
|
|
|
// Display the filename
|
|
|
|
UpdateTitleAndInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::RebuildDesignTree()
|
|
|
|
{
|
|
|
|
const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
2013-07-23 16:45:23 +00:00
|
|
|
int rectId = 0;
|
|
|
|
int lineId = 0;
|
|
|
|
int textId = 0;
|
|
|
|
int polyId = 0;
|
2013-10-18 17:38:03 +00:00
|
|
|
int bitmapId = 0;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
|
2013-07-23 16:45:23 +00:00
|
|
|
switch( item->GetType() )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2013-07-23 16:45:23 +00:00
|
|
|
case WORKSHEET_DATAITEM::WS_TEXT:
|
|
|
|
item->m_Name = wxString::Format( wxT("text%d:%s"), ++textId,
|
|
|
|
GetChars(item->GetClassName()) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM:: WS_SEGMENT:
|
|
|
|
item->m_Name = wxString::Format( wxT("segm%d:%s"), ++lineId,
|
|
|
|
GetChars(item->GetClassName()) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_RECT:
|
|
|
|
item->m_Name = wxString::Format( wxT("rect%d:%s"), ++rectId,
|
|
|
|
GetChars(item->GetClassName()) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
|
|
|
|
item->m_Name = wxString::Format( wxT("poly%d:%s"), ++polyId,
|
|
|
|
GetChars(item->GetClassName()) );
|
|
|
|
break;
|
2013-10-18 17:38:03 +00:00
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
|
|
|
item->m_Name = wxString::Format( wxT("bm%d:%s"), ++bitmapId,
|
|
|
|
GetChars(item->GetClassName()) );
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_treePagelayout->ReCreateDesignTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a new item to the page layout item list.
|
|
|
|
* aType = WS_TEXT, WS_SEGMENT, WS_RECT, WS_POLYPOLYGON
|
|
|
|
*/
|
|
|
|
WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
|
|
|
|
{
|
|
|
|
WORKSHEET_DATAITEM * item = NULL;
|
|
|
|
|
|
|
|
switch( aType )
|
|
|
|
{
|
|
|
|
case WORKSHEET_DATAITEM::WS_TEXT:
|
|
|
|
item = new WORKSHEET_DATAITEM_TEXT( wxT("Text") );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_SEGMENT:
|
|
|
|
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_SEGMENT );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_RECT:
|
|
|
|
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_RECT );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
|
|
|
|
item = new WORKSHEET_DATAITEM_POLYPOLYGON();
|
|
|
|
break;
|
2013-10-18 17:38:03 +00:00
|
|
|
|
|
|
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
|
|
|
{
|
|
|
|
wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
|
|
|
|
_( "Image Files " ) + wxImage::GetImageExtWildcard(),
|
|
|
|
wxFD_OPEN );
|
|
|
|
|
|
|
|
if( fileDlg.ShowModal() != wxID_OK )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
wxString fullFilename = fileDlg.GetPath();
|
|
|
|
|
|
|
|
if( !wxFileExists( fullFilename ) )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
BITMAP_BASE* image = new BITMAP_BASE();
|
|
|
|
|
|
|
|
if( !image->ReadImageFile( fullFilename ) )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Couldn't load image from <%s>" ),
|
|
|
|
GetChars( fullFilename ) );
|
|
|
|
delete image;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
item = new WORKSHEET_DATAITEM_BITMAP( image );
|
|
|
|
}
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
|
|
|
pglayout.Insert( item, aIdx );
|
|
|
|
RebuildDesignTree();
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns the current selected item, or NULL
|
|
|
|
*/
|
|
|
|
WORKSHEET_DATAITEM * PL_EDITOR_FRAME::GetSelectedItem()
|
|
|
|
{
|
|
|
|
WORKSHEET_DATAITEM* item = m_treePagelayout->GetPageLayoutSelectedItem();
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the page layout item found at position aPosition
|
|
|
|
* aPosition = the position (in user units) of the reference point
|
|
|
|
*/
|
|
|
|
WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetPageSettings();
|
|
|
|
TITLE_BLOCK t_block = GetTitleBlock();
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color = COLOR4D( RED ); // Needed, not used
|
2013-08-03 05:15:23 +00:00
|
|
|
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
|
|
|
|
|
|
|
|
WS_DRAW_ITEM_LIST drawList;
|
|
|
|
drawList.SetPenSize( 0 );
|
|
|
|
drawList.SetMilsToIUfactor( IU_PER_MILS );
|
|
|
|
drawList.SetSheetNumber( screen->m_ScreenNumber );
|
|
|
|
drawList.SetSheetCount( screen->m_NumberOfScreens );
|
|
|
|
drawList.SetFileName( GetCurrFileName() );
|
2015-04-03 09:13:06 +00:00
|
|
|
// GetScreenDesc() returns a temporary string. Store it to avoid issues.
|
|
|
|
wxString descr = GetScreenDesc();
|
|
|
|
drawList.SetSheetName( descr );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
|
|
|
|
|
|
|
|
// locate items.
|
|
|
|
// We do not use here the COLLECTOR classes in use in pcbnew and eeschema
|
|
|
|
// because the locate requirements are very basic.
|
|
|
|
std::vector <WS_DRAW_ITEM_BASE*> list;
|
|
|
|
drawList.Locate( list, aPosition );
|
2015-02-26 10:33:15 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( list.size() == 0 )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
WS_DRAW_ITEM_BASE* drawitem = list[0];
|
|
|
|
|
|
|
|
// Choose item in list if more than 1 item
|
|
|
|
if( list.size() > 1 )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxArrayString choices;
|
2013-07-19 18:27:22 +00:00
|
|
|
wxString text;
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint cursPos = GetCrossHairPosition();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < list.size(); ++ii )
|
|
|
|
{
|
|
|
|
drawitem = list[ii];
|
|
|
|
text = drawitem->GetParent()->m_Name;
|
|
|
|
|
|
|
|
if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
|
|
|
|
== (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
|
|
|
|
text << wxT(" ") << _("(start or end point)");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
|
|
|
|
text << wxT(" ") << _("(start point)");
|
|
|
|
|
|
|
|
if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
|
|
|
|
text << wxT(" ") << _("(end point)");
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ! drawitem->GetParent()->m_Info.IsEmpty() )
|
|
|
|
text << wxT(" \"") << drawitem->GetParent()->m_Info << wxT("\"");
|
|
|
|
|
|
|
|
choices.Add( text );
|
|
|
|
}
|
|
|
|
int selection = wxGetSingleChoiceIndex ( wxEmptyString,
|
|
|
|
_( "Selection Clarification" ),
|
|
|
|
choices, this );
|
|
|
|
if( selection < 0 )
|
|
|
|
return NULL;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( cursPos );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
drawitem = list[selection];
|
|
|
|
}
|
|
|
|
|
|
|
|
WORKSHEET_DATAITEM* item = drawitem->GetParent();
|
|
|
|
item->ClearFlags(LOCATE_STARTPOINT|LOCATE_ENDPOINT);
|
|
|
|
|
|
|
|
if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
|
|
|
|
item->SetFlags( LOCATE_STARTPOINT );
|
|
|
|
|
|
|
|
if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
|
|
|
|
item->SetFlags( LOCATE_ENDPOINT );
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
/* Must be called to initialize parameters when a new page layout
|
|
|
|
* description is loaded
|
|
|
|
*/
|
|
|
|
void PL_EDITOR_FRAME::OnNewPageLayout()
|
|
|
|
{
|
2013-07-26 12:50:29 +00:00
|
|
|
GetScreen()->ClearUndoRedoList();
|
2013-07-20 19:36:19 +00:00
|
|
|
GetScreen()->ClrModify();
|
|
|
|
m_propertiesPagelayout->CopyPrmsFromGeneralToPanel();
|
|
|
|
RebuildDesignTree();
|
2015-03-06 17:46:04 +00:00
|
|
|
Zoom_Automatique( false );
|
2013-07-20 19:36:19 +00:00
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
2015-01-06 07:38:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
const wxString PL_EDITOR_FRAME::GetZoomLevelIndicator() const
|
|
|
|
{
|
|
|
|
return EDA_DRAW_FRAME::GetZoomLevelIndicator();
|
|
|
|
}
|