2012-07-13 18:55:29 +00:00
|
|
|
/**
|
|
|
|
* @file dialog_keepout_area_properties.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-03-25 17:02:29 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-07-13 18:55:29 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#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 <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2012-07-13 18:55:29 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <zones.h>
|
|
|
|
#include <base_units.h>
|
|
|
|
|
|
|
|
#include <class_zone_settings.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <dialog_keepout_area_properties_base.h>
|
|
|
|
|
|
|
|
#include <wx/imaglist.h> // needed for wx/listctrl.h, in wxGTK 2.8.12
|
|
|
|
#include <wx/listctrl.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class DIALOG_KEEPOUT_AREA_PROPERTIES
|
|
|
|
* is the derived class from dialog_copper_zone_frame created by wxFormBuilder
|
|
|
|
*/
|
|
|
|
class DIALOG_KEEPOUT_AREA_PROPERTIES : public DIALOG_KEEPOUT_AREA_PROPERTIES_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
|
|
|
|
|
|
|
|
private:
|
2013-03-25 17:02:29 +00:00
|
|
|
PCB_BASE_FRAME* m_parent;
|
* 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
|
|
|
wxConfigBase* m_config; ///< Current config
|
2012-07-13 18:55:29 +00:00
|
|
|
ZONE_SETTINGS m_zonesettings;
|
|
|
|
ZONE_SETTINGS* m_ptr;
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
std::vector<LAYER_NUM> m_layerId; ///< Handle the real layer number from layer
|
2012-07-13 18:55:29 +00:00
|
|
|
///< name position in m_LayerSelectionCtrl
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function initDialog
|
|
|
|
* fills in the dialog controls using the current settings.
|
|
|
|
*/
|
|
|
|
void initDialog();
|
|
|
|
|
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AcceptOptionsForKeepOut
|
|
|
|
* Test validity of options, and copy options in m_zonesettings, for keepout zones
|
|
|
|
* @return bool - false if incorrect options, true if ok.
|
|
|
|
*/
|
|
|
|
bool AcceptOptionsForKeepOut();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function makeLayerBitmap
|
|
|
|
* creates the colored rectangle bitmaps used in the layer selection widget.
|
|
|
|
* @param aColor is the color to fill the rectangle with.
|
|
|
|
*/
|
2012-09-02 12:06:47 +00:00
|
|
|
wxBitmap makeLayerBitmap( EDA_COLOR_T aColor );
|
2012-07-13 18:55:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define LAYER_BITMAP_SIZE_X 20
|
|
|
|
#define LAYER_BITMAP_SIZE_Y 10
|
|
|
|
|
|
|
|
ZONE_EDIT_T InvokeKeepoutAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
|
|
|
|
{
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
|
|
|
|
|
|
|
|
ZONE_EDIT_T result = ZONE_EDIT_T( dlg.ShowModal() );
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) :
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( aParent )
|
|
|
|
{
|
2013-03-25 17:02:29 +00:00
|
|
|
m_parent = aParent;
|
* 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
|
|
|
m_config = Kiface().KifaceSettings();
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
m_ptr = aSettings;
|
|
|
|
m_zonesettings = *aSettings;
|
|
|
|
|
|
|
|
SetReturnCode( ZONE_ABORT ); // Will be changed on button OK ckick
|
|
|
|
|
|
|
|
initDialog();
|
|
|
|
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2013-03-25 18:48:07 +00:00
|
|
|
Center();
|
2012-07-13 18:55:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog()
|
|
|
|
{
|
2013-03-25 17:02:29 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( m_zonesettings.m_Zone_45_Only )
|
|
|
|
m_OrientEdgesOpt->SetSelection( 1 );
|
|
|
|
|
|
|
|
switch( m_zonesettings.m_Zone_HatchingStyle )
|
|
|
|
{
|
|
|
|
case CPolyLine::NO_HATCH:
|
|
|
|
m_OutlineAppearanceCtrl->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPolyLine::DIAGONAL_EDGE:
|
|
|
|
m_OutlineAppearanceCtrl->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPolyLine::DIAGONAL_FULL:
|
|
|
|
m_OutlineAppearanceCtrl->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create one column in m_LayerSelectionCtrl
|
2013-03-25 17:02:29 +00:00
|
|
|
wxListItem column0;
|
|
|
|
column0.SetId( 0 );
|
|
|
|
m_LayerSelectionCtrl->InsertColumn( 0, column0 );
|
2012-07-13 18:55:29 +00:00
|
|
|
// Build copper layer list and append to layer widget
|
|
|
|
int layerCount = board->GetCopperLayerCount();
|
|
|
|
wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
|
|
|
|
m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL );
|
|
|
|
for( int ii = 0; ii < layerCount; ii++ )
|
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layerNumber = LAYER_N_BACK;
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
if( layerCount <= 1 || ii < layerCount - 1 )
|
|
|
|
layerNumber = ii;
|
|
|
|
else if( ii == layerCount - 1 )
|
|
|
|
layerNumber = LAYER_N_FRONT;
|
|
|
|
|
2013-03-25 17:02:29 +00:00
|
|
|
m_layerId.insert( m_layerId.begin(), layerNumber );
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
msg = board->GetLayerName( layerNumber );
|
2013-03-25 13:37:48 +00:00
|
|
|
EDA_COLOR_T layerColor = board->GetLayerColor( layerNumber );
|
2012-07-13 18:55:29 +00:00
|
|
|
imageList->Add( makeLayerBitmap( layerColor ) );
|
2013-03-25 13:37:48 +00:00
|
|
|
int itemIndex = m_LayerSelectionCtrl->InsertItem( 0, msg, ii );
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
if( m_zonesettings.m_CurrentZone_Layer == layerNumber )
|
|
|
|
m_LayerSelectionCtrl->Select( itemIndex );
|
|
|
|
}
|
|
|
|
|
2013-03-25 18:48:07 +00:00
|
|
|
m_LayerSelectionCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE);
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
// Init keepout parameters:
|
|
|
|
m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() );
|
|
|
|
m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() );
|
2012-07-14 16:27:25 +00:00
|
|
|
m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() );
|
2012-07-13 18:55:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( ZONE_ABORT );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( AcceptOptionsForKeepOut() )
|
|
|
|
{
|
|
|
|
*m_ptr = m_zonesettings;
|
|
|
|
EndModal( ZONE_OK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut()
|
|
|
|
{
|
|
|
|
// Init keepout parameters:
|
|
|
|
m_zonesettings.SetIsKeepout( true );
|
|
|
|
m_zonesettings.SetDoNotAllowTracks( m_cbTracksCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowVias( m_cbViasCtrl->GetValue() );
|
2012-07-14 16:27:25 +00:00
|
|
|
m_zonesettings.SetDoNotAllowCopperPour( m_cbCopperPourCtrl->GetValue() );
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
// Test for not allowed items: should have at least one item not allowed:
|
|
|
|
if( ! m_zonesettings.GetDoNotAllowTracks() &&
|
|
|
|
! m_zonesettings.GetDoNotAllowVias() &&
|
2012-07-14 16:27:25 +00:00
|
|
|
! m_zonesettings.GetDoNotAllowCopperPour() )
|
2012-07-13 18:55:29 +00:00
|
|
|
{
|
|
|
|
DisplayError( NULL,
|
|
|
|
_("Tracks, vias and pads are allowed. The keepout is useless" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the layer selection for this zone
|
|
|
|
int ii = m_LayerSelectionCtrl->GetFirstSelected();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
{
|
|
|
|
DisplayError( NULL, _( "No layer selected." ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-25 17:02:29 +00:00
|
|
|
m_zonesettings.m_CurrentZone_Layer = m_layerId[ii];
|
2012-07-13 18:55:29 +00:00
|
|
|
switch( m_OutlineAppearanceCtrl->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_zonesettings.m_Zone_HatchingStyle = CPolyLine::NO_HATCH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
m_zonesettings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
m_zonesettings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-03-25 17:02:29 +00:00
|
|
|
if( m_config )
|
2012-07-13 18:55:29 +00:00
|
|
|
{
|
2013-03-25 17:02:29 +00:00
|
|
|
m_config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
|
2012-07-13 18:55:29 +00:00
|
|
|
(long) m_zonesettings.m_Zone_HatchingStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_OrientEdgesOpt->GetSelection() == 0 )
|
|
|
|
m_zonesettings.m_Zone_45_Only = false;
|
|
|
|
else
|
|
|
|
m_zonesettings.m_Zone_45_Only = true;
|
|
|
|
|
|
|
|
m_zonesettings.m_ZonePriority = 0; //m_PriorityLevelCtrl->GetValue();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( EDA_COLOR_T aColor )
|
2012-07-13 18:55:29 +00:00
|
|
|
{
|
|
|
|
wxBitmap bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
|
|
|
|
wxBrush brush;
|
|
|
|
wxMemoryDC iconDC;
|
|
|
|
|
|
|
|
iconDC.SelectObject( bitmap );
|
|
|
|
brush.SetColour( MakeColour( aColor ) );
|
2014-01-08 01:34:04 +00:00
|
|
|
|
|
|
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
|
|
|
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
|
|
|
#else
|
2012-07-13 18:55:29 +00:00
|
|
|
brush.SetStyle( wxSOLID );
|
2014-01-08 01:34:04 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
iconDC.SetBrush( brush );
|
|
|
|
iconDC.DrawRectangle( 0, 0, LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
|
|
|
|
|
|
|
|
return bitmap;
|
|
|
|
}
|