~adamwolf/kicad/python-directory

« back to all changes in this revision

Viewing changes to pcbnew/footprint_wizard.cpp

  • Committer: Miguel Angel Ajo
  • Date: 2013-03-16 03:27:48 UTC
  • Revision ID: miguelangel@nbee.es-20130316032748-c62tonmgjy9qu51g
Allow plugins to be reloaded without closing/opening pcbnew, next step is plugin editor, just a few lines away...

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
 
95
95
void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
96
96
{
97
 
    if( m_FootprintWizard == NULL )
 
97
    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
 
98
 
 
99
    if( !footprintWizard )
98
100
        return;
99
101
 
100
102
    SetCurItem( NULL );
101
103
    // Delete the current footprint
102
104
    GetBoard()->m_Modules.DeleteAll();
103
 
    MODULE* m = m_FootprintWizard->GetModule();
 
105
    MODULE* m = footprintWizard->GetModule();
104
106
 
105
107
    if( m )
106
108
    {
112
114
    }
113
115
    else
114
116
    {
115
 
        printf( "m_FootprintWizard->GetModule() returns NULL\n" );
 
117
        printf( "footprintWizard->GetModule() returns NULL\n" );
116
118
    }
117
119
 
118
120
    m_canvas->Refresh();
119
121
}
120
122
 
121
123
 
 
124
FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_FRAME::GetMyWizard()
 
125
{
 
126
    if( m_wizardName.Length()==0 )
 
127
        return NULL;
 
128
 
 
129
    FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName );
 
130
 
 
131
    if( !footprintWizard )
 
132
    {
 
133
        wxMessageBox( _( "Couldn't reload footprint wizard" ) );
 
134
        return NULL;
 
135
    }
 
136
 
 
137
    return footprintWizard;
 
138
}
 
139
 
 
140
 
122
141
MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
123
142
{
124
 
    if( m_FootprintWizard )
 
143
    FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName );
 
144
 
 
145
    if( footprintWizard )
125
146
    {
126
 
        return m_FootprintWizard->GetModule();
 
147
        return footprintWizard->GetModule();
127
148
    }
128
149
    else
129
150
    {
139
160
 
140
161
    selectWizard->ShowModal();
141
162
 
142
 
    m_FootprintWizard = selectWizard->GetWizard();
 
163
    FOOTPRINT_WIZARD* footprintWizard = selectWizard->GetWizard();
143
164
 
144
 
    if( m_FootprintWizard )
145
 
    {
146
 
        m_wizardName = m_FootprintWizard->GetName();
147
 
        m_wizardDescription = m_FootprintWizard->GetDescription();
 
165
    if( footprintWizard )
 
166
    {
 
167
        m_wizardName = footprintWizard->GetName();
 
168
        m_wizardDescription = footprintWizard->GetDescription();
 
169
    }
 
170
    else
 
171
    {
 
172
        m_wizardName = wxT( "" );
 
173
        m_wizardDescription = wxT( "" );
148
174
    }
149
175
 
150
176
    ReloadFootprint();
169
195
{
170
196
    int page = m_PageList->GetSelection();
171
197
 
 
198
    FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
 
199
 
 
200
    if( !footprintWizard )
 
201
        return;
 
202
 
172
203
    if( page<0 )
173
204
        return;
174
205
 
175
206
    int             n = m_ParameterGrid->GetNumberRows();
176
207
    wxArrayString   arr;
177
 
    wxArrayString   ptList = m_FootprintWizard->GetParameterTypes( page );
 
208
    wxArrayString   ptList = footprintWizard->GetParameterTypes( page );
178
209
 
179
210
    for( int i = 0; i<n; i++ )
180
211
    {
184
215
        // unit convert it back from the user format
185
216
        if( ptList[i]==wxT( "IU" ) )
186
217
        {
187
 
            LOCALE_IO toggle;
188
 
            double dValue;
 
218
            LOCALE_IO   toggle;
 
219
            double      dValue;
189
220
 
190
221
            value.ToDouble( &dValue );
191
222
 
205
236
        arr.Add( value );
206
237
    }
207
238
 
208
 
    wxString res = m_FootprintWizard->SetParameterValues( page, arr );
 
239
    wxString res = footprintWizard->SetParameterValues( page, arr );
209
240
 
210
241
    ReloadFootprint();
211
242
    DisplayWizardInfos();