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