kicad/pcbnew/dialogs/dialog_non_copper_zones_pro...

162 lines
4.9 KiB
C++
Raw Normal View History

/**
* @file dialog_non_copper_zones_properties.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
* 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>
#include <confirm.h>
2018-01-29 20:58:58 +00:00
#include <pcb_edit_frame.h>
#include <widgets/unit_binder.h>
#include <class_zone.h>
#include <zones.h>
#include <dialog_non_copper_zones_properties_base.h>
class DIALOG_NON_COPPER_ZONES_EDITOR : public DIALOG_NONCOPPER_ZONES_PROPERTIES_BASE
{
private:
PCB_BASE_FRAME* m_parent;
2012-02-06 05:44:19 +00:00
ZONE_SETTINGS* m_ptr;
ZONE_SETTINGS m_settings; // working copy of zone settings
UNIT_BINDER m_minWidth;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void OnLayerSelection( wxDataViewEvent& event ) override;
public:
DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
};
int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings )
{
DIALOG_NON_COPPER_ZONES_EDITOR dlg( aParent, aSettings );
return dlg.ShowModal();
}
2012-02-06 05:44:19 +00:00
DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent,
ZONE_SETTINGS* aSettings ) :
DIALOG_NONCOPPER_ZONES_PROPERTIES_BASE( aParent ),
m_minWidth( aParent, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true )
{
m_parent = aParent;
2012-02-06 05:44:19 +00:00
m_ptr = aSettings;
m_settings = *aSettings;
m_settings.SetupLayersList( m_layers, m_parent, false );
FinishDialogSettings();
}
bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataToWindow()
{
m_minWidth.SetValue( m_settings.m_ZoneMinThickness );
m_ConstrainOpt->SetValue( m_settings.m_Zone_45_Only );
2012-02-06 05:44:19 +00:00
switch( m_settings.m_Zone_HatchingStyle )
{
case ZONE_CONTAINER::NO_HATCH: m_OutlineAppearanceCtrl->SetSelection( 0 ); break;
case ZONE_CONTAINER::DIAGONAL_EDGE: m_OutlineAppearanceCtrl->SetSelection( 1 ); break;
case ZONE_CONTAINER::DIAGONAL_FULL: m_OutlineAppearanceCtrl->SetSelection( 2 ); break;
}
return true;
}
void DIALOG_NON_COPPER_ZONES_EDITOR::OnLayerSelection( wxDataViewEvent& event )
{
if( event.GetColumn() != 0 )
return;
int row = m_layers->ItemToRow( event.GetItem() );
if( m_layers->GetToggleValue( row, 0 ) )
{
wxVariant layerID;
m_layers->GetValue( layerID, row, 2 );
m_settings.m_CurrentZone_Layer = ToLAYER_ID( layerID.GetInteger() );
// Turn all other checkboxes off.
for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
{
if( ii != row )
m_layers->SetToggleValue( false, ii, 0 );
}
}
}
bool DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow()
{
m_settings.m_ZoneMinThickness = m_minWidth.GetValue();
m_settings.m_FillMode = ZFM_POLYGONS; // Use always polygon fill mode
switch( m_OutlineAppearanceCtrl->GetSelection() )
{
case 0: m_settings.m_Zone_HatchingStyle = ZONE_CONTAINER::NO_HATCH; break;
case 1: m_settings.m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_EDGE; break;
case 2: m_settings.m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_FULL; break;
}
* 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* cfg = Kiface().KifaceSettings();
wxASSERT( cfg );
cfg->Write( ZONE_NET_OUTLINES_STYLE_KEY, (long) m_settings.m_Zone_HatchingStyle );
m_settings.m_Zone_45_Only = m_ConstrainOpt->GetValue();
2012-02-06 05:44:19 +00:00
// Get the layer selection for this zone
int layer = -1;
for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
{
if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
{
layer = ii;
break;
}
}
if( layer < 0 )
{
DisplayError( this, _( "No layer selected." ) );
return false;
}
2012-02-06 05:44:19 +00:00
*m_ptr = m_settings;
return true;
}
2012-02-06 05:44:19 +00:00