Factor DIALOG_BLOCK_OPTIONS into separate compilation unit
This means the dialog can be accessed from both GAL and legacy modes. This also removes the use of static bools for passing the selection states and instead used a struct of values passed in by the calling code.
This commit is contained in:
parent
1077b679c5
commit
6ba9a512b6
|
@ -51,6 +51,7 @@ include_directories(
|
|||
|
||||
set( PCBNEW_DIALOGS
|
||||
dialogs/dialog_block_options_base.cpp
|
||||
dialogs/dialog_block_options.cpp
|
||||
dialogs/dialog_cleaning_options_base.cpp
|
||||
dialogs/dialog_cleaning_options.cpp
|
||||
dialogs/dialog_copper_zones.cpp
|
||||
|
|
116
pcbnew/block.cpp
116
pcbnew/block.cpp
|
@ -45,7 +45,7 @@
|
|||
#include <class_dimension.h>
|
||||
#include <class_zone.h>
|
||||
|
||||
#include <dialog_block_options_base.h>
|
||||
#include <dialog_block_options.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
#include <protos.h>
|
||||
|
@ -73,48 +73,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
|
|||
bool aErase );
|
||||
|
||||
|
||||
static bool blockIncludeModules = true;
|
||||
static bool blockIncludeLockedModules = true;
|
||||
static bool blockIncludeTracks = true;
|
||||
static bool blockIncludeZones = true;
|
||||
static bool blockIncludeItemsOnTechLayers = true;
|
||||
static bool blockIncludeBoardOutlineLayer = true;
|
||||
static bool blockIncludePcbTexts = true;
|
||||
static bool blockDrawItems = true;
|
||||
static bool blockIncludeItemsOnInvisibleLayers = false;
|
||||
|
||||
|
||||
/************************************/
|
||||
/* class DIALOG_BLOCK_OPTIONS */
|
||||
/************************************/
|
||||
|
||||
class DIALOG_BLOCK_OPTIONS : public DIALOG_BLOCK_OPTIONS_BASE
|
||||
{
|
||||
private:
|
||||
PCB_BASE_FRAME* m_Parent;
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* parent, const wxString& title );
|
||||
~DIALOG_BLOCK_OPTIONS()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void ExecuteCommand( wxCommandEvent& event ) override;
|
||||
void OnCancel( wxCommandEvent& event ) override
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
void checkBoxClicked( wxCommandEvent& aEvent ) override
|
||||
{
|
||||
if( m_Include_Modules->GetValue() )
|
||||
m_IncludeLockedModules->Enable();
|
||||
else
|
||||
m_IncludeLockedModules->Disable();
|
||||
}
|
||||
};
|
||||
static DIALOG_BLOCK_OPTIONS::OPTIONS blockOpts;
|
||||
|
||||
|
||||
static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title )
|
||||
|
@ -122,7 +81,7 @@ static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title
|
|||
wxPoint oldpos = parent->GetCrossHairPosition();
|
||||
|
||||
parent->GetCanvas()->SetIgnoreMouseEvents( true );
|
||||
DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, title );
|
||||
DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, blockOpts, title );
|
||||
|
||||
int cmd = dlg->ShowModal();
|
||||
dlg->Destroy();
|
||||
|
@ -135,49 +94,6 @@ static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title
|
|||
}
|
||||
|
||||
|
||||
DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* aParent, const wxString& aTitle ) :
|
||||
DIALOG_BLOCK_OPTIONS_BASE( aParent, -1, aTitle )
|
||||
{
|
||||
m_Parent = aParent;
|
||||
|
||||
m_Include_Modules->SetValue( blockIncludeModules );
|
||||
m_IncludeLockedModules->SetValue( blockIncludeLockedModules );
|
||||
|
||||
if( m_Include_Modules->GetValue() )
|
||||
m_IncludeLockedModules->Enable();
|
||||
else
|
||||
m_IncludeLockedModules->Disable();
|
||||
|
||||
m_Include_Tracks->SetValue( blockIncludeTracks );
|
||||
m_Include_Zones->SetValue( blockIncludeZones );
|
||||
m_Include_Draw_Items->SetValue( blockIncludeItemsOnTechLayers );
|
||||
m_Include_Edges_Items->SetValue( blockIncludeBoardOutlineLayer );
|
||||
m_Include_PcbTextes->SetValue( blockIncludePcbTexts );
|
||||
m_DrawBlockItems->SetValue( blockDrawItems );
|
||||
m_checkBoxIncludeInvisible->SetValue( blockIncludeItemsOnInvisibleLayers );
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
SetFocus();
|
||||
GetSizer()->SetSizeHints( this );
|
||||
Centre();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
|
||||
{
|
||||
blockIncludeModules = m_Include_Modules->GetValue();
|
||||
blockIncludeLockedModules = m_IncludeLockedModules->GetValue();
|
||||
blockIncludeTracks = m_Include_Tracks->GetValue();
|
||||
blockIncludeZones = m_Include_Zones->GetValue();
|
||||
blockIncludeItemsOnTechLayers = m_Include_Draw_Items->GetValue();
|
||||
blockIncludeBoardOutlineLayer = m_Include_Edges_Items->GetValue();
|
||||
blockIncludePcbTexts = m_Include_PcbTextes->GetValue();
|
||||
blockDrawItems = m_DrawBlockItems->GetValue();
|
||||
blockIncludeItemsOnInvisibleLayers = m_checkBoxIncludeInvisible->GetValue();
|
||||
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
|
||||
int PCB_EDIT_FRAME::BlockCommand( EDA_KEY aKey )
|
||||
{
|
||||
int cmd = 0;
|
||||
|
@ -397,16 +313,16 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|
|||
ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
|
||||
|
||||
// Add modules
|
||||
if( blockIncludeModules )
|
||||
if( blockOpts.includeModules )
|
||||
{
|
||||
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
|
||||
{
|
||||
LAYER_ID layer = module->GetLayer();
|
||||
|
||||
if( module->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete )
|
||||
&& ( !module->IsLocked() || blockIncludeLockedModules ) )
|
||||
&& ( !module->IsLocked() || blockOpts.includeLockedModules ) )
|
||||
{
|
||||
if( blockIncludeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) )
|
||||
if( blockOpts.includeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) )
|
||||
{
|
||||
picker.SetItem ( module );
|
||||
itemsList->PushItem( picker );
|
||||
|
@ -416,13 +332,13 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|
|||
}
|
||||
|
||||
// Add tracks and vias
|
||||
if( blockIncludeTracks )
|
||||
if( blockOpts.includeTracks )
|
||||
{
|
||||
for( TRACK* track = m_Pcb->m_Track; track != NULL; track = track->Next() )
|
||||
{
|
||||
if( track->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
||||
{
|
||||
if( blockIncludeItemsOnInvisibleLayers
|
||||
if( blockOpts.includeItemsOnInvisibleLayers
|
||||
|| m_Pcb->IsLayerVisible( track->GetLayer() ) )
|
||||
{
|
||||
picker.SetItem( track );
|
||||
|
@ -435,15 +351,15 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|
|||
// Add graphic items
|
||||
layerMask = LSET( Edge_Cuts );
|
||||
|
||||
if( blockIncludeItemsOnTechLayers )
|
||||
if( blockOpts.includeItemsOnTechLayers )
|
||||
layerMask.set();
|
||||
|
||||
if( !blockIncludeBoardOutlineLayer )
|
||||
if( !blockOpts.includeBoardOutlineLayer )
|
||||
layerMask.set( Edge_Cuts, false );
|
||||
|
||||
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
||||
{
|
||||
if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && ! blockIncludeItemsOnInvisibleLayers)
|
||||
if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && ! blockOpts.includeItemsOnInvisibleLayers)
|
||||
continue;
|
||||
|
||||
bool select_me = false;
|
||||
|
@ -461,7 +377,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|
|||
break;
|
||||
|
||||
case PCB_TEXT_T:
|
||||
if( !blockIncludePcbTexts )
|
||||
if( !blockOpts.includePcbTexts )
|
||||
break;
|
||||
|
||||
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
||||
|
@ -502,7 +418,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|
|||
}
|
||||
|
||||
// Add zones
|
||||
if( blockIncludeZones )
|
||||
if( blockOpts.includeZones )
|
||||
{
|
||||
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
|
||||
{
|
||||
|
@ -510,7 +426,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
|
|||
|
||||
if( area->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
||||
{
|
||||
if( blockIncludeItemsOnInvisibleLayers
|
||||
if( blockOpts.includeItemsOnInvisibleLayers
|
||||
|| m_Pcb->IsLayerVisible( area->GetLayer() ) )
|
||||
{
|
||||
BOARD_ITEM* zone_c = (BOARD_ITEM*) area;
|
||||
|
@ -582,7 +498,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
|
|||
screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
|
||||
GR_XOR, BLOCK_OUTLINE_COLOR );
|
||||
|
||||
if( blockDrawItems )
|
||||
if( blockOpts.drawItems )
|
||||
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
|
||||
}
|
||||
}
|
||||
|
@ -599,7 +515,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
|
|||
screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
|
||||
GR_XOR, BLOCK_OUTLINE_COLOR );
|
||||
|
||||
if( blockDrawItems )
|
||||
if( blockOpts.drawItems )
|
||||
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 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 <dialog_block_options.h>
|
||||
|
||||
#include <wxPcbStruct.h>
|
||||
|
||||
|
||||
DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* aParent,
|
||||
OPTIONS& aOptions, const wxString& aTitle ) :
|
||||
DIALOG_BLOCK_OPTIONS_BASE( aParent, -1, aTitle ),
|
||||
m_options( aOptions )
|
||||
{
|
||||
m_Include_Modules->SetValue( m_options.includeModules );
|
||||
m_IncludeLockedModules->SetValue( m_options.includeLockedModules );
|
||||
|
||||
if( m_Include_Modules->GetValue() )
|
||||
m_IncludeLockedModules->Enable();
|
||||
else
|
||||
m_IncludeLockedModules->Disable();
|
||||
|
||||
m_Include_Tracks->SetValue( m_options.includeTracks );
|
||||
m_Include_Zones->SetValue( m_options.includeZones );
|
||||
m_Include_Draw_Items->SetValue( m_options.includeItemsOnTechLayers );
|
||||
m_Include_Edges_Items->SetValue( m_options.includeBoardOutlineLayer );
|
||||
m_Include_PcbTextes->SetValue( m_options.includePcbTexts );
|
||||
m_DrawBlockItems->SetValue( m_options.drawItems );
|
||||
m_checkBoxIncludeInvisible->SetValue( m_options.includeItemsOnInvisibleLayers );
|
||||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
SetFocus();
|
||||
GetSizer()->SetSizeHints( this );
|
||||
Centre();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BLOCK_OPTIONS::checkBoxClicked( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( m_Include_Modules->GetValue() )
|
||||
m_IncludeLockedModules->Enable();
|
||||
else
|
||||
m_IncludeLockedModules->Disable();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
|
||||
{
|
||||
m_options.includeModules = m_Include_Modules->GetValue();
|
||||
m_options.includeLockedModules = m_IncludeLockedModules->GetValue();
|
||||
m_options.includeTracks = m_Include_Tracks->GetValue();
|
||||
m_options.includeZones = m_Include_Zones->GetValue();
|
||||
m_options.includeItemsOnTechLayers = m_Include_Draw_Items->GetValue();
|
||||
m_options.includeBoardOutlineLayer = m_Include_Edges_Items->GetValue();
|
||||
m_options.includePcbTexts = m_Include_PcbTextes->GetValue();
|
||||
m_options.drawItems = m_DrawBlockItems->GetValue();
|
||||
m_options.includeItemsOnInvisibleLayers = m_checkBoxIncludeInvisible->GetValue();
|
||||
|
||||
EndModal( wxID_OK );
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_BLOCK_OPTIONS_H_
|
||||
#define DIALOG_BLOCK_OPTIONS_H_
|
||||
|
||||
#include <dialogs/dialog_block_options_base.h>
|
||||
|
||||
class PCB_BASE_FRAME;
|
||||
|
||||
class DIALOG_BLOCK_OPTIONS : public DIALOG_BLOCK_OPTIONS_BASE
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Struct that will be set with the result of the user choices
|
||||
* in the dialog
|
||||
*/
|
||||
struct OPTIONS
|
||||
{
|
||||
bool includeModules = true;
|
||||
bool includeLockedModules = true;
|
||||
bool includeTracks = true;
|
||||
bool includeZones = true;
|
||||
bool includeItemsOnTechLayers = true;
|
||||
bool includeBoardOutlineLayer = true;
|
||||
bool includePcbTexts = true;
|
||||
bool drawItems = true;
|
||||
bool includeItemsOnInvisibleLayers = false;
|
||||
};
|
||||
|
||||
DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* aParent, OPTIONS& aOptions,
|
||||
const wxString& aTitle );
|
||||
|
||||
~DIALOG_BLOCK_OPTIONS()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
void ExecuteCommand( wxCommandEvent& event ) override;
|
||||
|
||||
void OnCancel( wxCommandEvent& event ) override
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
void checkBoxClicked( wxCommandEvent& aEvent ) override;
|
||||
|
||||
///< Reference to the options struct to fill
|
||||
OPTIONS& m_options;
|
||||
};
|
||||
|
||||
#endif // DIALOG_EXCHANGE_MODULES_H_
|
Loading…
Reference in New Issue