Give GROUP_PROPERTIES_DIALOG its own files.
This commit is contained in:
parent
2a5cd08abb
commit
f7a6dc26e9
|
@ -99,6 +99,7 @@ set( PCBNEW_DIALOGS
|
|||
dialogs/dialog_global_edit_text_and_graphics.cpp
|
||||
dialogs/dialog_global_edit_text_and_graphics_base.cpp
|
||||
dialogs/dialog_global_fp_lib_table_config.cpp
|
||||
dialogs/dialog_group_properties.cpp
|
||||
dialogs/dialog_group_properties_base.cpp
|
||||
dialogs/dialog_push_pad_properties.cpp
|
||||
dialogs/dialog_push_pad_properties_base.cpp
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 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 <tool/tool_manager.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/pcb_picker_tool.h>
|
||||
#include <status_popup.h>
|
||||
#include <board_commit.h>
|
||||
#include <bitmaps.h>
|
||||
#include <dialogs/dialog_group_properties.h>
|
||||
|
||||
|
||||
DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
|
||||
PCB_GROUP* aGroup ) :
|
||||
DIALOG_GROUP_PROPERTIES_BASE( aParent ),
|
||||
m_brdEditor( aParent ),
|
||||
m_toolMgr( aParent->GetToolManager() ),
|
||||
m_group( aGroup )
|
||||
{
|
||||
m_bpAddMember->SetBitmap( KiBitmap( small_plus_xpm ) );
|
||||
m_bpRemoveMember->SetBitmap( KiBitmap( trash_xpm ) );
|
||||
|
||||
m_nameCtrl->SetValue( m_group->GetName() );
|
||||
|
||||
for( BOARD_ITEM* item : m_group->GetItems() )
|
||||
m_membersList->Append( item->GetSelectMenuText( m_brdEditor->GetUserUnits() ), item );
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
SetInitialFocus( m_nameCtrl );
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_GROUP_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
// Don't do anything here; it gets called every time we re-show the dialog after
|
||||
// picking a new member.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_GROUP_PROPERTIES::TransferDataFromWindow()
|
||||
{
|
||||
BOARD_COMMIT commit( m_brdEditor );
|
||||
commit.Modify( m_group );
|
||||
|
||||
m_group->SetName( m_nameCtrl->GetValue() );
|
||||
|
||||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
m_group->RemoveAll();
|
||||
|
||||
for( size_t ii = 0; ii < m_membersList->GetCount(); ++ii )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_membersList->GetClientData( ii ) );
|
||||
PCB_GROUP* existingGroup = item->GetParentGroup();
|
||||
|
||||
if( existingGroup )
|
||||
{
|
||||
commit.Modify( existingGroup );
|
||||
existingGroup->RemoveItem( item );
|
||||
}
|
||||
|
||||
m_group->AddItem( item );
|
||||
}
|
||||
|
||||
commit.Push( _( "Modified group" ) );
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, m_group );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::OnMemberSelected( wxCommandEvent& aEvent )
|
||||
{
|
||||
int selected = m_membersList->GetSelection();
|
||||
|
||||
if( selected >= 0 )
|
||||
{
|
||||
WINDOW_THAWER thawer( m_brdEditor );
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_membersList->GetClientData( selected ) );
|
||||
|
||||
m_brdEditor->FocusOnItem( item );
|
||||
m_brdEditor->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::OnAddMember( wxCommandEvent& event )
|
||||
{
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::pickNewGroupMember, true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::DoAddMember( EDA_ITEM* aItem )
|
||||
{
|
||||
for( size_t ii = 0; ii < m_membersList->GetCount(); ++ii )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( m_membersList->GetClientData( ii ) ) )
|
||||
return;
|
||||
}
|
||||
|
||||
if( aItem == m_group )
|
||||
return;
|
||||
|
||||
m_membersList->Append( aItem->GetSelectMenuText( m_brdEditor->GetUserUnits() ), aItem );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::OnRemoveMember( wxCommandEvent& event )
|
||||
{
|
||||
int selected = m_membersList->GetSelection();
|
||||
|
||||
if( selected >= 0 )
|
||||
m_membersList->Delete( selected );
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 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_GROUP_PROPERTIES_H
|
||||
#define DIALOG_GROUP_PROPERTIES_H
|
||||
|
||||
#include <dialogs/dialog_group_properties_base.h>
|
||||
|
||||
class PCB_BASE_EDIT_FRAME;
|
||||
class TOOL_MANAGER;
|
||||
class PCB_GROUP;
|
||||
|
||||
|
||||
class DIALOG_GROUP_PROPERTIES : public DIALOG_GROUP_PROPERTIES_BASE
|
||||
{
|
||||
private:
|
||||
PCB_BASE_EDIT_FRAME* m_brdEditor;
|
||||
TOOL_MANAGER* m_toolMgr;
|
||||
PCB_GROUP* m_group;
|
||||
|
||||
public:
|
||||
DIALOG_GROUP_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, PCB_GROUP* aTarget );
|
||||
~DIALOG_GROUP_PROPERTIES() { }
|
||||
|
||||
void OnMemberSelected( wxCommandEvent& event ) override;
|
||||
void OnAddMember( wxCommandEvent& event ) override;
|
||||
void OnRemoveMember( wxCommandEvent& event ) override;
|
||||
|
||||
void DoAddMember( EDA_ITEM* aItem );
|
||||
|
||||
private:
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
};
|
||||
|
||||
#endif // DIALOG_GROUP_PROPERTIES_H
|
|
@ -29,141 +29,7 @@
|
|||
#include <status_popup.h>
|
||||
#include <board_commit.h>
|
||||
#include <bitmaps.h>
|
||||
#include <dialogs/dialog_group_properties_base.h>
|
||||
#include "edit_tool.h"
|
||||
|
||||
class DIALOG_GROUP_PROPERTIES : public DIALOG_GROUP_PROPERTIES_BASE
|
||||
{
|
||||
private:
|
||||
PCB_BASE_EDIT_FRAME* m_brdEditor;
|
||||
TOOL_MANAGER* m_toolMgr;
|
||||
PCB_GROUP* m_group;
|
||||
|
||||
public:
|
||||
DIALOG_GROUP_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, PCB_GROUP* aTarget );
|
||||
~DIALOG_GROUP_PROPERTIES() { }
|
||||
|
||||
void OnMemberSelected( wxCommandEvent& event ) override;
|
||||
void OnAddMember( wxCommandEvent& event ) override;
|
||||
void OnRemoveMember( wxCommandEvent& event ) override;
|
||||
|
||||
void DoAddMember( EDA_ITEM* aItem );
|
||||
|
||||
private:
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
};
|
||||
|
||||
|
||||
DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
|
||||
PCB_GROUP* aGroup ) :
|
||||
DIALOG_GROUP_PROPERTIES_BASE( aParent ),
|
||||
m_brdEditor( aParent ),
|
||||
m_toolMgr( aParent->GetToolManager() ),
|
||||
m_group( aGroup )
|
||||
{
|
||||
m_bpAddMember->SetBitmap( KiBitmap( small_plus_xpm ) );
|
||||
m_bpRemoveMember->SetBitmap( KiBitmap( trash_xpm ) );
|
||||
|
||||
m_nameCtrl->SetValue( m_group->GetName() );
|
||||
|
||||
for( BOARD_ITEM* item : m_group->GetItems() )
|
||||
m_membersList->Append( item->GetSelectMenuText( m_brdEditor->GetUserUnits() ), item );
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
SetInitialFocus( m_nameCtrl );
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_GROUP_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
// Don't do anything here; it gets called every time we re-show the dialog after
|
||||
// picking a new member.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_GROUP_PROPERTIES::TransferDataFromWindow()
|
||||
{
|
||||
BOARD_COMMIT commit( m_brdEditor );
|
||||
commit.Modify( m_group );
|
||||
|
||||
m_group->SetName( m_nameCtrl->GetValue() );
|
||||
|
||||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
m_group->RemoveAll();
|
||||
|
||||
for( size_t ii = 0; ii < m_membersList->GetCount(); ++ii )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_membersList->GetClientData( ii ) );
|
||||
PCB_GROUP* existingGroup = item->GetParentGroup();
|
||||
|
||||
if( existingGroup )
|
||||
{
|
||||
commit.Modify( existingGroup );
|
||||
existingGroup->RemoveItem( item );
|
||||
}
|
||||
|
||||
m_group->AddItem( item );
|
||||
}
|
||||
|
||||
commit.Push( _( "Modified group" ) );
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, m_group );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::OnMemberSelected( wxCommandEvent& aEvent )
|
||||
{
|
||||
int selected = m_membersList->GetSelection();
|
||||
|
||||
if( selected >= 0 )
|
||||
{
|
||||
WINDOW_THAWER thawer( m_brdEditor );
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_membersList->GetClientData( selected ) );
|
||||
|
||||
m_brdEditor->FocusOnItem( item );
|
||||
m_brdEditor->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::OnAddMember( wxCommandEvent& event )
|
||||
{
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::pickNewGroupMember, true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::DoAddMember( EDA_ITEM* aItem )
|
||||
{
|
||||
for( size_t ii = 0; ii < m_membersList->GetCount(); ++ii )
|
||||
{
|
||||
if( aItem == static_cast<BOARD_ITEM*>( m_membersList->GetClientData( ii ) ) )
|
||||
return;
|
||||
}
|
||||
|
||||
if( aItem == m_group )
|
||||
return;
|
||||
|
||||
m_membersList->Append( aItem->GetSelectMenuText( m_brdEditor->GetUserUnits() ), aItem );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GROUP_PROPERTIES::OnRemoveMember( wxCommandEvent& event )
|
||||
{
|
||||
int selected = m_membersList->GetSelection();
|
||||
|
||||
if( selected >= 0 )
|
||||
m_membersList->Delete( selected );
|
||||
}
|
||||
#include <dialogs/dialog_group_properties.h>
|
||||
|
||||
|
||||
class GROUP_CONTEXT_MENU : public ACTION_MENU
|
||||
|
|
Loading…
Reference in New Issue