KiCad PCB EDA Suite
microwave.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <class_drawpanel.h>
34 #include <confirm.h>
35 #include <trigo.h>
36 #include <kicad_string.h>
37 #include <gestfich.h>
38 #include <pcb_edit_frame.h>
39 #include <dialog_helpers.h>
40 #include <richio.h>
41 #include <filter_reader.h>
42 #include <gr_basic.h>
43 #include <macros.h>
44 #include <base_units.h>
45 #include <validators.h>
46 #include <dialog_text_entry.h>
47 
48 #include <class_board.h>
49 #include <class_module.h>
50 #include <class_edge_mod.h>
51 
53 
54 #include <pcbnew.h>
55 
56 static std::vector< wxRealPoint > PolyEdges;
57 static double ShapeScaleX, ShapeScaleY;
58 static wxSize ShapeSize;
59 static int PolyShapeType;
60 
61 
62 static void Exit_Self( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
63 
65  wxDC* aDC,
66  const wxPoint& aPosition,
67  bool aErase );
68 
69 
72 
74 static bool s_inductorInProgress = false;
75 
76 
77 /* This function shows on screen the bounding box of the inductor that will be
78  * created at the end of the build inductor process
79  */
80 static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
81  const wxPoint& aPosition, bool aErase )
82 {
83  /* Calculate the orientation and size of the box containing the inductor:
84  * the box is a rectangle with height = length/2
85  * the shape is defined by a rectangle, nor necessary horizontal or vertical
86  */
87  GRSetDrawMode( aDC, GR_XOR );
88 
89  wxPoint poly[5];
90  wxPoint pt = s_inductor_pattern.m_End - s_inductor_pattern.m_Start;
91  double angle = -ArcTangente( pt.y, pt.x );
92  int len = KiROUND( EuclideanNorm( pt ) );
93 
94  // calculate corners
95  pt.x = 0; pt.y = len / 4;
96  RotatePoint( &pt, angle );
97  poly[0] = s_inductor_pattern.m_Start + pt;
98  poly[1] = s_inductor_pattern.m_End + pt;
99  pt.x = 0; pt.y = -len / 4;
100  RotatePoint( &pt, angle );
101  poly[2] = s_inductor_pattern.m_End + pt;
102  poly[3] = s_inductor_pattern.m_Start + pt;
103  poly[4] = poly[0];
104 
105  if( aErase )
106  {
107  GRPoly( aPanel->GetClipBox(), aDC, 5, poly, false, 0, YELLOW, YELLOW );
108  }
109 
110  s_inductor_pattern.m_End = aPanel->GetParent()->GetCrossHairPosition();
111  pt = s_inductor_pattern.m_End - s_inductor_pattern.m_Start;
112  angle = -ArcTangente( pt.y, pt.x );
113  len = KiROUND( EuclideanNorm( pt ) );
114 
115  // calculate new corners
116  pt.x = 0; pt.y = len / 4;
117  RotatePoint( &pt, angle );
118  poly[0] = s_inductor_pattern.m_Start + pt;
119  poly[1] = s_inductor_pattern.m_End + pt;
120  pt.x = 0; pt.y = -len / 4;
121  RotatePoint( &pt, angle );
122  poly[2] = s_inductor_pattern.m_End + pt;
123  poly[3] = s_inductor_pattern.m_Start + pt;
124  poly[4] = poly[0];
125 
126  GRPoly( aPanel->GetClipBox(), aDC, 5, poly, false, 0, YELLOW, YELLOW );
127 }
128 
129 
130 void Exit_Self( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
131 {
132  if( aPanel->IsMouseCaptured() )
133  aPanel->CallMouseCapture( aDC, wxDefaultPosition, false );
134 
135  s_inductorInProgress = false;
136  aPanel->SetMouseCapture( NULL, NULL );
137 }
138 
139 
141 {
143  {
144  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
145  m_canvas->SetMouseCapture( NULL, NULL );
146 
147  wxString errorMessage;
148 
149  // Prepare parameters for inductor
150  // s_inductor_pattern.m_Start is already initialized,
151  // when s_inductor_pattern.m_Flag == false
152  s_inductor_pattern.m_Width = GetDesignSettings().GetCurrentTrackWidth();
153  s_inductor_pattern.m_End = GetCrossHairPosition();
154 
155  wxASSERT( s_inductorInProgress );
156  s_inductorInProgress = false;
157 
158  MODULE* footprint = MWAVE::CreateMicrowaveInductor( s_inductor_pattern, this, errorMessage );
159 
160  if( footprint )
161  {
162  SetMsgPanel( footprint );
163  footprint->Draw( m_canvas, DC, GR_OR );
164  }
165 
166  else if( !errorMessage.IsEmpty() )
167  DisplayError( this, errorMessage );
168 
169  return;
170  }
171 
172  s_inductor_pattern.m_Start = GetCrossHairPosition();
173  s_inductor_pattern.m_End = s_inductor_pattern.m_Start;
174 
175  s_inductorInProgress = true;
176 
177  // Update the initial coordinates.
179  UpdateStatusBar();
180 
182  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
183 }
184 
185 
187  int aTextSize, int aPadCount )
188 {
189  MODULE* module = CreateNewModule( aValue );
190  AddModuleToBoard( module );
191 
192  if( aTextSize > 0 )
193  {
194  module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) );
195  module->Reference().SetThickness( aTextSize/5 );
196  module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) );
197  module->Value().SetThickness( aTextSize/5 );
198  }
199 
200  // Create 2 pads used in gaps and stubs. The gap is between these 2 pads
201  // the stub is the pad 2
202  wxString Line;
203  int pad_num = 1;
204 
205  while( aPadCount-- )
206  {
207  D_PAD* pad = new D_PAD( module );
208 
209  module->PadsList().PushFront( pad );
210 
212  pad->SetSize( wxSize( tw, tw ) );
213 
214  pad->SetPosition( module->GetPosition() );
215  pad->SetShape( PAD_SHAPE_RECT );
217  pad->SetLayerSet( F_Cu );
218 
219  Line.Printf( wxT( "%d" ), pad_num );
220  pad->SetName( Line );
221  pad_num++;
222  }
223 
224  return module;
225 }
226 
227 
229 {
230  int oX;
231  D_PAD* pad;
232  MODULE* module;
233  wxString msg, cmp_name;
234  int pad_count = 2;
235  int angle = 0;
236  // Ref and value text size (O = use board default value.
237  // will be set to a value depending on the footprint size, if possible
238  int text_size = 0;
239 
240  // Enter the size of the gap or stub
241  int gap_size = GetDesignSettings().GetCurrentTrackWidth();
242 
243  switch( shape_type )
244  {
245  case 0:
246  msg = _( "Gap Size:" );
247  cmp_name = "muwave_gap";
248  text_size = gap_size;
249  break;
250 
251  case 1:
252  msg = _( "Stub Size:" );
253  cmp_name = "muwave_stub";
254  text_size = gap_size;
255  pad_count = 2;
256  break;
257 
258  case 2:
259  msg = _( "Arc Stub Radius Value:" );
260  cmp_name = "muwave_arcstub";
261  pad_count = 1;
262  break;
263 
264  default:
265  msg = wxT( "???" );
266  break;
267  }
268 
269  wxString value = StringFromValue( GetUserUnits(), gap_size );
270  WX_TEXT_ENTRY_DIALOG dlg( this, msg, _( "Create microwave module" ), value );
271 
272  if( dlg.ShowModal() != wxID_OK )
273  {
275  return NULL; // cancelled by user
276  }
277 
278  value = dlg.GetValue();
279  gap_size = ValueFromString( GetUserUnits(), value );
280 
281  bool abort = false;
282 
283  if( shape_type == 2 )
284  {
285  double fcoeff = 10.0, fval;
286  msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
287  WX_TEXT_ENTRY_DIALOG angledlg( this, _( "Angle in degrees:" ),
288  _( "Create microwave module" ), msg );
289 
290  if( angledlg.ShowModal() != wxID_OK )
291  {
293  return NULL; // cancelled by user
294  }
295 
296  msg = angledlg.GetValue();
297 
298  if( !msg.ToDouble( &fval ) )
299  {
300  DisplayError( this, _( "Incorrect number, abort" ) );
301  abort = true;
302  }
303 
304  angle = std::abs( KiROUND( fval * fcoeff ) );
305 
306  if( angle > 1800 )
307  angle = 1800;
308  }
309 
310  if( abort )
311  {
313  return NULL;
314  }
315 
316  module = CreateMuWaveBaseFootprint( cmp_name, text_size, pad_count );
317  pad = module->PadsList();
318 
319  switch( shape_type )
320  {
321  case 0: //Gap :
322  oX = -( gap_size + pad->GetSize().x ) / 2;
323  pad->SetX0( oX );
324 
325  pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
326 
327  pad = pad->Next();
328 
329  pad->SetX0( oX + gap_size + pad->GetSize().x );
330  pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
331  break;
332 
333  case 1: //Stub :
334  pad->SetName( wxT( "1" ) );
335  pad = pad->Next();
336  pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 );
337  pad->SetSize( wxSize( pad->GetSize().x, gap_size ) );
338  pad->SetY( pad->GetPos0().y + pad->GetPosition().y );
339  break;
340 
341  case 2: // Arc Stub created by a polygonal approach:
342  {
343  pad->SetShape( PAD_SHAPE_CUSTOM );
345 
346  int numPoints = (angle / 50) + 3; // Note: angles are in 0.1 degrees
347  std::vector<wxPoint> polyPoints;
348  polyPoints.reserve( numPoints );
349 
350  polyPoints.push_back( wxPoint( 0, 0 ) );
351 
352  int theta = -angle / 2;
353 
354  for( int ii = 1; ii<numPoints - 1; ii++ )
355  {
356  wxPoint pt( 0, -gap_size );
357  RotatePoint( &pt.x, &pt.y, theta );
358  polyPoints.push_back( pt );
359 
360  theta += 50;
361 
362  if( theta > angle / 2 )
363  theta = angle / 2;
364  }
365 
366  // Close the polygon:
367  polyPoints.push_back( polyPoints[0] );
368 
369  pad->AddPrimitive( polyPoints, 0 ); // add a polygonal basic shape
370  }
371  break;
372 
373  default:
374  break;
375  }
376 
377  module->CalculateBoundingBox();
378  GetBoard()->m_Status_Pcb = 0;
379  OnModify();
380  return module;
381 }
382 
383 
384 /**************** Polygon Shapes ***********************/
385 
386 enum id_mw_cmd {
388 };
389 
390 
391 /* Setting polynomial form parameters
392  */
393 class MWAVE_POLYGONAL_SHAPE_DLG : public wxDialog
394 {
395 private:
397  wxRadioBox* m_ShapeOptionCtrl;
399 
400 public:
401  MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos );
403 
404 private:
405  void OnOkClick( wxCommandEvent& event );
406  void OnCancelClick( wxCommandEvent& event );
407 
424  void ReadDataShapeDescr( wxCommandEvent& event );
425  void AcceptOptions( wxCommandEvent& event );
426 
427  DECLARE_EVENT_TABLE()
428 };
429 
430 
431 BEGIN_EVENT_TABLE( MWAVE_POLYGONAL_SHAPE_DLG, wxDialog )
432  EVT_BUTTON( wxID_OK, MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick )
433  EVT_BUTTON( wxID_CANCEL, MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick )
435 END_EVENT_TABLE()
436 
437 
439  const wxPoint& framepos ) :
440  wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
441  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
442 {
443  m_Parent = parent;
444 
445  PolyEdges.clear();
446 
447  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
448  SetSizer( MainBoxSizer );
449  wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
450  wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
451  MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
452  MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
453 
454  wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) );
455  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
456 
457  Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
458  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
459 
460  Button = new wxButton( this, ID_READ_SHAPE_FILE,
461  _( "Read Shape Description File..." ) );
462  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
463 
464  wxString shapelist[3] =
465  {
466  _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" )
467  };
468 
469  m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ),
470  wxDefaultPosition, wxDefaultSize, 3,
471  shapelist, 1,
472  wxRA_SPECIFY_COLS );
473  LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
474 
475  m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, parent->GetUserUnits(),
476  LeftBoxSizer );
477 
478  GetSizer()->SetSizeHints( this );
479 }
480 
481 
482 void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick( wxCommandEvent& event )
483 {
484  PolyEdges.clear();
485  EndModal( wxID_CANCEL );
486 }
487 
488 
489 void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick( wxCommandEvent& event )
490 {
491  ShapeSize = m_SizeCtrl->GetValue();
492  PolyShapeType = m_ShapeOptionCtrl->GetSelection();
493  EndModal( wxID_OK );
494 }
495 
496 
498 {
499  static wxString lastpath; // To remember the last open path during a session
500  wxString mask = wxT( "*.*" );
501 
502  wxString FullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ),
503  lastpath, FullFileName,
504  wxEmptyString, mask,
505  this, wxFD_OPEN, true );
506  if( FullFileName.IsEmpty() )
507  return;
508 
509  wxFileName fn( FullFileName );
510  lastpath = fn.GetPath();
511  PolyEdges.clear();
512 
513  FILE* File = wxFopen( FullFileName, wxT( "rt" ) );
514 
515  if( File == NULL )
516  {
517  DisplayError( this, _( "File not found" ) );
518  return;
519  }
520 
521  double unitconv = IU_PER_MM;
522  ShapeScaleX = ShapeScaleY = 1.0;
523 
524  FILE_LINE_READER fileReader( File, FullFileName );
525  FILTER_READER reader( fileReader );
526 
527  LOCALE_IO toggle;
528 
529  while( reader.ReadLine() )
530  {
531  char* Line = reader.Line();
532  char* param1 = strtok( Line, " =\n\r" );
533  char* param2 = strtok( NULL, " \t\n\r" );
534 
535  if( strncasecmp( param1, "Unit", 4 ) == 0 )
536  {
537  if( strncasecmp( param2, "inch", 4 ) == 0 )
538  unitconv = IU_PER_MILS*1000;
539 
540  if( strncasecmp( param2, "mm", 2 ) == 0 )
541  unitconv = IU_PER_MM;
542  }
543 
544  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
545  break;
546 
547  if( strncasecmp( param1, "$COORD", 6 ) == 0 )
548  {
549  while( reader.ReadLine() )
550  {
551  Line = reader.Line();
552  param1 = strtok( Line, " \t\n\r" );
553  param2 = strtok( NULL, " \t\n\r" );
554 
555  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
556  break;
557 
558  wxRealPoint coord( atof( param1 ), atof( param2 ) );
559  PolyEdges.push_back( coord );
560  }
561  }
562 
563  if( strncasecmp( Line, "XScale", 6 ) == 0 )
564  ShapeScaleX = atof( param2 );
565 
566  if( strncasecmp( Line, "YScale", 6 ) == 0 )
567  ShapeScaleY = atof( param2 );
568  }
569 
570  ShapeScaleX *= unitconv;
571  ShapeScaleY *= unitconv;
572 
573  m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
574 }
575 
576 
578 {
579  D_PAD* pad1, * pad2;
580  MODULE* module;
581  wxString cmp_name;
582  int pad_count = 2;
583  EDGE_MODULE* edge;
584 
585  MWAVE_POLYGONAL_SHAPE_DLG dlg( this, wxDefaultPosition );
586 
587  int ret = dlg.ShowModal();
588 
590 
591  if( ret != wxID_OK )
592  {
593  PolyEdges.clear();
594  return NULL;
595  }
596 
597  if( PolyShapeType == 2 ) // mirrored
599 
602 
603  if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
604  {
605  DisplayError( this, _( "Shape has a null size!" ) );
606  return NULL;
607  }
608 
609  if( PolyEdges.size() == 0 )
610  {
611  DisplayError( this, _( "Shape has no points!" ) );
612  return NULL;
613  }
614 
615  cmp_name = wxT( "muwave_polygon" );
616 
617  // Create a footprint with 2 pads, orientation = 0, pos 0
618  module = CreateMuWaveBaseFootprint( cmp_name, 0, pad_count );
619 
620  // We try to place the footprint anchor to the middle of the shape len
621  wxPoint offset;
622  offset.x = -ShapeSize.x / 2;
623 
624  pad1 = module->PadsList();
625  pad1->SetX0( offset.x );
626  pad1->SetX( pad1->GetPos0().x );
627 
628  pad2 = pad1->Next();
629  pad2->SetX0( offset.x + ShapeSize.x );
630  pad2->SetX( pad2->GetPos0().x );
631 
632  // Add a polygonal edge (corners will be added later) on copper layer
633  edge = new EDGE_MODULE( module );
634  edge->SetShape( S_POLYGON );
635  edge->SetLayer( F_Cu );
636 
637  module->GraphicalItemsList().PushFront( edge );
638 
639  // Get the corner buffer of the polygonal edge
640  std::vector<wxPoint> polyPoints;
641  polyPoints.reserve( PolyEdges.size() + 2 );
642 
643  // Init start point coord:
644  polyPoints.push_back( wxPoint( offset.x, 0 ) );
645 
646  wxPoint last_coordinate;
647 
648  for( unsigned ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points
649  {
650  last_coordinate.x = KiROUND( PolyEdges[ii].x * ShapeScaleX );
651  last_coordinate.y = -KiROUND( PolyEdges[ii].y * ShapeScaleY );
652  last_coordinate += offset;
653  polyPoints.push_back( last_coordinate );
654  }
655 
656  // finish the polygonal shape
657  if( last_coordinate.y != 0 )
658  polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
659 
660  switch( PolyShapeType )
661  {
662  case 0: // shape from file
663  case 2: // shape from file, mirrored (the mirror is already done)
664  break;
665 
666  case 1: // Symmetric shape: add the symmetric (mirrored) shape
667  for( int ndx = polyPoints.size() - 1; ndx >= 0; --ndx )
668  {
669  wxPoint pt = polyPoints[ndx];
670  pt.y = -pt.y; // mirror about X axis
671  polyPoints.push_back( pt );
672  }
673  break;
674  }
675 
676  edge->SetPolyPoints( polyPoints );
677  // Set the polygon outline thickness to 0, only the polygonal shape is filled
678  // without extra thickness
679  edge->SetWidth( 0 );
680  PolyEdges.clear();
681  module->CalculateBoundingBox();
682  GetBoard()->m_Status_Pcb = 0;
683  OnModify();
684  return module;
685 }
686 
687 
688 void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule )
689 {
690  int gap_size, oX;
691  D_PAD* pad, * next_pad;
692  wxString msg;
693 
694  if( aModule == NULL )
695  return;
696 
697  // Test if module is a gap type (name begins with GAP, and has 2 pads).
698  msg = aModule->GetReference().Left( 3 );
699 
700  if( msg != wxT( "GAP" ) )
701  return;
702 
703  pad = aModule->PadsList();
704 
705  if( pad == NULL )
706  {
707  DisplayError( this, _( "No pad for this footprint" ) );
708  return;
709  }
710 
711  next_pad = pad->Next();
712 
713  if( next_pad == NULL )
714  {
715  DisplayError( this, _( "Only one pad for this footprint" ) );
716  return;
717  }
718 
719  aModule->Draw( m_canvas, DC, GR_XOR );
720 
721  // Calculate the current dimension.
722  gap_size = next_pad->GetPos0().x - pad->GetPos0().x - pad->GetSize().x;
723 
724  // Entrer the desired length of the gap.
725  msg = StringFromValue( GetUserUnits(), gap_size );
726  WX_TEXT_ENTRY_DIALOG dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg );
727 
728  if( dlg.ShowModal() != wxID_OK )
729  return; // cancelled by user
730 
731  msg = dlg.GetValue();
732  gap_size = ValueFromString( GetUserUnits(), msg );
733 
734  // Updating sizes of pads forming the gap.
736  pad->SetSize( wxSize( tw, tw ) );
737 
738  pad->SetY0( 0 );
739  oX = -( gap_size + pad->GetSize().x ) / 2;
740  pad->SetX0( oX );
741 
742  wxPoint padpos = pad->GetPos0() + aModule->GetPosition();
743 
744  RotatePoint( &padpos.x, &padpos.y,
745  aModule->GetPosition().x, aModule->GetPosition().y, aModule->GetOrientation() );
746 
747  pad->SetPosition( padpos );
748 
750  next_pad->SetSize( wxSize( tw, tw ) );
751 
752  next_pad->SetY0( 0 );
753  next_pad->SetX0( oX + gap_size + next_pad->GetSize().x );
754 
755  padpos = next_pad->GetPos0() + aModule->GetPosition();
756 
757  RotatePoint( &padpos.x, &padpos.y,
758  aModule->GetPosition().x, aModule->GetPosition().y, aModule->GetOrientation() );
759 
760  next_pad->SetPosition( padpos );
761 
762  aModule->Draw( m_canvas, DC, GR_OR );
763 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
static wxSize ShapeSize
Definition: microwave.cpp:58
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:701
TEXTE_MODULE & Reference()
Definition: class_module.h:513
void SetShape(STROKE_T aShape)
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
wxRadioBox * m_ShapeOptionCtrl
Definition: microwave.cpp:397
This file is part of the common library TODO brief description.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:179
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
void PushFront(T *aNewElement)
Function PushFront puts aNewElement at front of list sequence.
Definition: dlist.h:240
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
PCB_EDIT_FRAME * m_Parent
Definition: microwave.cpp:396
id_mw_cmd
Definition: microwave.cpp:386
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw draws the footprint to the aDC.
Class BOARD to handle a board.
Parameters for construction of a microwave inductor.
polygon (not yet used for tracks, but could be in microwave apps)
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
BOARD * GetBoard() const
void Edit_Gap(wxDC *DC, MODULE *Module)
Function Edit_Gap edits the GAP module if it has changed the position and/or size of the pads that fo...
Definition: microwave.cpp:688
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
const wxPoint & GetPos0() const
Definition: class_pad.h:263
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
virtual EDA_RECT * GetClipBox()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:409
static int PolyShapeType
Definition: microwave.cpp:59
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
EDA_SIZE_CTRL * m_SizeCtrl
Definition: microwave.cpp:398
MODULE * CreateNewModule(const wxString &aModuleName)
Function CreateNewModule Creates a new module or footprint, at position 0,0 The new module contains o...
void SetY0(int y)
Definition: class_pad.h:265
#define abs(a)
Definition: auxiliary.h:84
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
void Begin_Self(wxDC *DC)
Definition: microwave.cpp:140
This file contains miscellaneous commonly used macros and functions.
virtual EDA_DRAW_FRAME * GetParent() const =0
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter...
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: class_pad.h:253
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
MODULE * Create_MuWavePolygonShape()
Definition: microwave.cpp:577
MODULE * Create_MuWaveComponent(int shape_type)
Create_MuWaveComponent creates a module "GAP" or "STUB" used in micro wave designs.
Definition: microwave.cpp:228
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:170
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12)...
Definition: class_pad.h:182
static double ShapeScaleX
Definition: microwave.cpp:57
double GetOrientation() const
Definition: class_module.h:189
void OnOkClick(wxCommandEvent &event)
Definition: microwave.cpp:489
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void ReadDataShapeDescr(wxCommandEvent &event)
Function ReadDataShapeDescr read a description shape file File format is Unit=MM XScale=271.501 YScale=1.00133.
Definition: microwave.cpp:497
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
void OnCancelClick(wxCommandEvent &event)
Definition: microwave.cpp:482
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
D_PAD * Next() const
Definition: class_pad.h:160
static void Exit_Self(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: microwave.cpp:130
Helper dialog and control classes.
const wxSize & GetSize() const
Definition: class_pad.h:269
void SetSize(const wxSize &aSize)
Definition: class_pad.h:268
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:409
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
Definition: gr_basic.h:38
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:401
wxString GetValue()
virtual void UpdateStatusBar() override
Update the status bar information.
void SetY(int y)
Definition: class_pad.h:259
MODULE * CreateMicrowaveInductor(INDUCTOR_PATTERN &aPattern, PCB_EDIT_FRAME *aPcbFrame, wxString &aErrorMessage)
Creates an S-shaped coil footprint for microwave applications.
static void ShowBoundingBoxMicroWaveInductor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: microwave.cpp:80
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:463
MODULE * CreateMuWaveBaseFootprint(const wxString &aValue, int aTextSize, int aPadCount)
Function CreateMuWaveBaseFootprint create a basic footprint for micro wave applications.
Definition: microwave.cpp:186
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
static MWAVE::INDUCTOR_PATTERN s_inductor_pattern
An inductor pattern temporarily used during mu-wave inductor creation
Definition: microwave.cpp:71
void AddPrimitive(const SHAPE_POLY_SET &aPoly, int aThickness)
Has meaning only for free shape pads.
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
#define IU_PER_MILS
Definition: plotter.cpp:134
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:217
wxString StringFromValue(EDA_UNITS_T aUnits, int aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:210
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
void SetX0(int x)
Definition: class_pad.h:266
Module description (excepted pads)
static double ShapeScaleY
Definition: microwave.cpp:57
const wxPoint GetPosition() const override
Definition: class_pad.h:220
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
EDGE_MODULE class definition.
static bool s_inductorInProgress
A flag set to true when mu-wave inductor is being created
Definition: microwave.cpp:74
Definition: colors.h:68
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
void SetX(int x)
Definition: class_pad.h:260
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
Class FILTER_READER reads lines of text from another LINE_READER, but only returns non-comment lines ...
Definition: filter_reader.h:37
const wxPoint GetPosition() const override
Definition: class_module.h:184
Custom text control validator definitions.
static std::vector< wxRealPoint > PolyEdges
Definition: microwave.cpp:56
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:240
void SetWidth(int aWidth)