KiCad PCB EDA Suite
MWAVE_POLYGONAL_SHAPE_DLG Class Reference
Inheritance diagram for MWAVE_POLYGONAL_SHAPE_DLG:

Public Member Functions

 MWAVE_POLYGONAL_SHAPE_DLG (PCB_EDIT_FRAME *parent, const wxPoint &pos)
 
 ~MWAVE_POLYGONAL_SHAPE_DLG ()
 

Private Member Functions

void OnOkClick (wxCommandEvent &event)
 
void OnCancelClick (wxCommandEvent &event)
 
void ReadDataShapeDescr (wxCommandEvent &event)
 Function ReadDataShapeDescr read a description shape file File format is Unit=MM XScale=271.501 YScale=1.00133. More...
 
void AcceptOptions (wxCommandEvent &event)
 

Private Attributes

PCB_EDIT_FRAMEm_Parent
 
wxRadioBox * m_ShapeOptionCtrl
 
EDA_SIZE_CTRLm_SizeCtrl
 

Detailed Description

Definition at line 391 of file microwave.cpp.

Constructor & Destructor Documentation

MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG ( PCB_EDIT_FRAME parent,
const wxPoint pos 
)

Definition at line 436 of file microwave.cpp.

References g_UserUnit, PolyEdges, and ShapeSize.

437  :
438  wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
439  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
440 {
441  m_Parent = parent;
442 
443  PolyEdges.clear();
444 
445  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
446  SetSizer( MainBoxSizer );
447  wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
448  wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
449  MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
450  MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
451 
452  wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) );
453  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
454 
455  Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
456  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
457 
458  Button = new wxButton( this, ID_READ_SHAPE_FILE,
459  _( "Read Shape Description File..." ) );
460  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
461 
462  wxString shapelist[3] =
463  {
464  _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" )
465  };
466 
467  m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ),
468  wxDefaultPosition, wxDefaultSize, 3,
469  shapelist, 1,
470  wxRA_SPECIFY_COLS );
471  LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
472 
473  m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, g_UserUnit, LeftBoxSizer );
474 
475  GetSizer()->SetSizeHints( this );
476 }
static wxSize ShapeSize
Definition: microwave.cpp:57
wxRadioBox * m_ShapeOptionCtrl
Definition: microwave.cpp:395
PCB_EDIT_FRAME * m_Parent
Definition: microwave.cpp:394
EDA_SIZE_CTRL * m_SizeCtrl
Definition: microwave.cpp:396
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
static std::vector< wxRealPoint > PolyEdges
Definition: microwave.cpp:55
MWAVE_POLYGONAL_SHAPE_DLG::~MWAVE_POLYGONAL_SHAPE_DLG ( )
inline

Definition at line 400 of file microwave.cpp.

400 { };

Member Function Documentation

void MWAVE_POLYGONAL_SHAPE_DLG::AcceptOptions ( wxCommandEvent &  event)
private
void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick ( wxCommandEvent &  event)
private

Definition at line 479 of file microwave.cpp.

References PolyEdges.

480 {
481  PolyEdges.clear();
482  EndModal( wxID_CANCEL );
483 }
static std::vector< wxRealPoint > PolyEdges
Definition: microwave.cpp:55
void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick ( wxCommandEvent &  event)
private

Definition at line 486 of file microwave.cpp.

References EDA_SIZE_CTRL::GetValue(), m_ShapeOptionCtrl, m_SizeCtrl, PolyShapeType, and ShapeSize.

487 {
489  PolyShapeType = m_ShapeOptionCtrl->GetSelection();
490  EndModal( wxID_OK );
491 }
static wxSize ShapeSize
Definition: microwave.cpp:57
wxRadioBox * m_ShapeOptionCtrl
Definition: microwave.cpp:395
static int PolyShapeType
Definition: microwave.cpp:58
EDA_SIZE_CTRL * m_SizeCtrl
Definition: microwave.cpp:396
wxSize GetValue()
Definition: wxwineda.cpp:255
void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr ( wxCommandEvent &  event)
private

Function ReadDataShapeDescr read a description shape file File format is Unit=MM XScale=271.501 YScale=1.00133.

$COORD 0 0.6112600148417837 0.001851851851851852 0.6104800531118608 .... $ENDCOORD

Each line is the X Y coord (normalized units from 0 to 1)

Definition at line 494 of file microwave.cpp.

References DisplayError(), EDA_FILE_SELECTOR(), LINE_READER::Line(), m_SizeCtrl, PolyEdges, FILTER_READER::ReadLine(), EDA_POSITION_CTRL::SetValue(), ShapeScaleX, and ShapeScaleY.

495 {
496  static wxString lastpath; // To remember the last open path during a session
497  wxString mask = wxT( "*.*" );
498 
499  wxString FullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ),
500  lastpath, FullFileName,
501  wxEmptyString, mask,
502  this, wxFD_OPEN, true );
503  if( FullFileName.IsEmpty() )
504  return;
505 
506  wxFileName fn( FullFileName );
507  lastpath = fn.GetPath();
508  PolyEdges.clear();
509 
510  FILE* File = wxFopen( FullFileName, wxT( "rt" ) );
511 
512  if( File == NULL )
513  {
514  DisplayError( this, _( "File not found" ) );
515  return;
516  }
517 
518  double unitconv = IU_PER_MM;
519  ShapeScaleX = ShapeScaleY = 1.0;
520 
521  FILE_LINE_READER fileReader( File, FullFileName );
522  FILTER_READER reader( fileReader );
523 
524  LOCALE_IO toggle;
525 
526  while( reader.ReadLine() )
527  {
528  char* Line = reader.Line();
529  char* param1 = strtok( Line, " =\n\r" );
530  char* param2 = strtok( NULL, " \t\n\r" );
531 
532  if( strncasecmp( param1, "Unit", 4 ) == 0 )
533  {
534  if( strncasecmp( param2, "inch", 4 ) == 0 )
535  unitconv = IU_PER_MILS*1000;
536 
537  if( strncasecmp( param2, "mm", 2 ) == 0 )
538  unitconv = IU_PER_MM;
539  }
540 
541  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
542  break;
543 
544  if( strncasecmp( param1, "$COORD", 6 ) == 0 )
545  {
546  while( reader.ReadLine() )
547  {
548  Line = reader.Line();
549  param1 = strtok( Line, " \t\n\r" );
550  param2 = strtok( NULL, " \t\n\r" );
551 
552  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
553  break;
554 
555  wxRealPoint coord( atof( param1 ), atof( param2 ) );
556  PolyEdges.push_back( coord );
557  }
558  }
559 
560  if( strncasecmp( Line, "XScale", 6 ) == 0 )
561  ShapeScaleX = atof( param2 );
562 
563  if( strncasecmp( Line, "YScale", 6 ) == 0 )
564  ShapeScaleY = atof( param2 );
565  }
566 
567  ShapeScaleX *= unitconv;
568  ShapeScaleY *= unitconv;
569 
570  m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
571 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
EDA_SIZE_CTRL * m_SizeCtrl
Definition: microwave.cpp:396
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
static double ShapeScaleX
Definition: microwave.cpp:56
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
static double ShapeScaleY
Definition: microwave.cpp:56
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
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
static std::vector< wxRealPoint > PolyEdges
Definition: microwave.cpp:55

Member Data Documentation

PCB_EDIT_FRAME* MWAVE_POLYGONAL_SHAPE_DLG::m_Parent
private

Definition at line 394 of file microwave.cpp.

wxRadioBox* MWAVE_POLYGONAL_SHAPE_DLG::m_ShapeOptionCtrl
private

Definition at line 395 of file microwave.cpp.

Referenced by OnOkClick().

EDA_SIZE_CTRL* MWAVE_POLYGONAL_SHAPE_DLG::m_SizeCtrl
private

Definition at line 396 of file microwave.cpp.

Referenced by OnOkClick(), and ReadDataShapeDescr().


The documentation for this class was generated from the following file: