KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_multichannel_repeat_layout.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 John Beard, [email protected]
5 * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
26#include <widgets/wx_grid.h>
27#include <pcb_edit_frame.h>
29#include <zone.h>
30
32 PCB_BASE_FRAME* aFrame,
33 MULTICHANNEL_TOOL *aParentTool ) :
35 m_parentTool( aParentTool )
36{
37 auto data = m_parentTool->GetData();
38 m_refRAName->SetLabelText( data->m_refRA->m_area->GetZoneName() );
39
40 for( auto& ra : data->m_compatMap )
41 {
42 TABLE_ENTRY ent;
43
44 ent.m_doCopy = ra.second.m_isOk;
45 ent.m_errMsg = ra.second.m_errorMsg;
46 ent.m_isOK = ra.second.m_isOk;
47 ent.m_raName = ra.first->m_ruleName;
48 ent.m_targetRA = ra.first;
49
50 m_targetRAs.push_back( ent );
51 }
52
53 std::sort( m_targetRAs.begin(), m_targetRAs.end(),
54 [] ( const TABLE_ENTRY&a ,const TABLE_ENTRY& b ) -> int
55 {
56 if ( !a.m_isOK && b.m_isOK )
57 return 0;
58 else if ( a.m_isOK && !b.m_isOK )
59 return 1;
60 else
61 return a.m_raName < b.m_raName;
62 } );
63
64 int i = 0;
65
66 m_raGrid->ClearGrid();
67 m_raGrid->EnableEditing( true );
68 m_raGrid->HideRowLabels();
69 m_raGrid->SetColLabelValue( 0, wxT("Copy") );
70 m_raGrid->SetColLabelValue( 1, wxT("Target Rule Area") );
71 m_raGrid->SetColLabelValue( 2, wxT("Status") );
72 m_raGrid->AutoSizeColumn( 1 );
73 m_raGrid->AppendRows( m_targetRAs.size() - 1 );
74
75 for( TABLE_ENTRY& entry : m_targetRAs)
76 {
77 m_raGrid->SetCellValue( i, 1, entry.m_raName );
78 m_raGrid->SetCellValue( i, 2, entry.m_isOK ? _("OK") : entry.m_errMsg );
79 m_raGrid->SetCellRenderer( i, 0, new wxGridCellBoolRenderer);
80 m_raGrid->SetCellEditor( i, 0, new wxGridCellBoolEditor);
81 m_raGrid->SetCellValue( i, 0, entry.m_doCopy ? wxT("1") : wxT("") );
82 i++;
83 }
84
85 m_raGrid->SetMaxSize( wxSize( -1, 800 ) );
86 m_raGrid->Fit();
87
88 m_cbCopyPlacement->SetValue( data->m_options.m_copyPlacement );
89 m_cbCopyRouting->SetValue( data->m_options.m_copyRouting );
90 m_cbGroupItems->SetValue( data->m_options.m_groupItems );
91 m_cbIncludeLockedComponents->SetValue( data->m_options.m_includeLockedItems );
92 m_cbIncludeOffRAComponents->SetValue( data->m_options.m_moveOffRAComponents );
93
94 Layout();
97}
98
99
101{
102 auto data = m_parentTool->GetData();
103
104 for( size_t i = 0; i < m_targetRAs.size(); i++ )
105 {
106 wxString doCopy = m_raGrid->GetCellValue( i, 0 );
107
108 data->m_compatMap[m_targetRAs[i].m_targetRA].m_doCopy =
109 !doCopy.CompareTo( wxT( "1" ) ) ? true : false;
110 }
111
112 data->m_options.m_copyPlacement = m_cbCopyPlacement->GetValue();
113 data->m_options.m_copyRouting = m_cbCopyRouting->GetValue();
114 data->m_options.m_groupItems = m_cbGroupItems->GetValue();
115 data->m_options.m_includeLockedItems = m_cbIncludeLockedComponents->GetValue();
116 data->m_options.m_moveOffRAComponents = m_cbIncludeOffRAComponents->GetValue();
117
118 return true;
119}
120
121
123{
124 // fixme: I have no idea how to use this together with wxGrid so that it resizes correctly...
125
126 //if( !wxDialog::TransferDataToWindow() )
127 //return false;
128
129 return true;
130}
Class DIALOG_MULTICHANNEL_REPEAT_LAYOUT_BASE.
DIALOG_MULTICHANNEL_REPEAT_LAYOUT(PCB_BASE_FRAME *aFrame, MULTICHANNEL_TOOL *aParentTool)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
RULE_AREAS_DATA * GetData()
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
#define _(s)
wxString m_errMsg
bool m_isOK
wxString m_raName
RULE_AREA * m_targetRA
bool m_doCopy