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 393 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 438 of file microwave.cpp.

References g_UserUnit, ID_READ_SHAPE_FILE, PolyEdges, and ShapeSize.

439  :
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, g_UserUnit, LeftBoxSizer );
476 
477  GetSizer()->SetSizeHints( this );
478 }
static wxSize ShapeSize
Definition: microwave.cpp:58
wxRadioBox * m_ShapeOptionCtrl
Definition: microwave.cpp:397
PCB_EDIT_FRAME * m_Parent
Definition: microwave.cpp:396
EDA_SIZE_CTRL * m_SizeCtrl
Definition: microwave.cpp:398
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
static std::vector< wxRealPoint > PolyEdges
Definition: microwave.cpp:56
MWAVE_POLYGONAL_SHAPE_DLG::~MWAVE_POLYGONAL_SHAPE_DLG ( )
inline

Definition at line 402 of file microwave.cpp.

References ID_READ_SHAPE_FILE, OnCancelClick(), OnOkClick(), and ReadDataShapeDescr().

402 { };

Member Function Documentation

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

Definition at line 481 of file microwave.cpp.

References PolyEdges.

Referenced by ~MWAVE_POLYGONAL_SHAPE_DLG().

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

Definition at line 488 of file microwave.cpp.

References PolyShapeType, and ShapeSize.

Referenced by ~MWAVE_POLYGONAL_SHAPE_DLG().

489 {
491  PolyShapeType = m_ShapeOptionCtrl->GetSelection();
492  EndModal( wxID_OK );
493 }
static wxSize ShapeSize
Definition: microwave.cpp:58
wxRadioBox * m_ShapeOptionCtrl
Definition: microwave.cpp:397
static int PolyShapeType
Definition: microwave.cpp:59
EDA_SIZE_CTRL * m_SizeCtrl
Definition: microwave.cpp:398
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 496 of file microwave.cpp.

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

Referenced by ~MWAVE_POLYGONAL_SHAPE_DLG().

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

Member Data Documentation

PCB_EDIT_FRAME* MWAVE_POLYGONAL_SHAPE_DLG::m_Parent
private

Definition at line 396 of file microwave.cpp.

wxRadioBox* MWAVE_POLYGONAL_SHAPE_DLG::m_ShapeOptionCtrl
private

Definition at line 397 of file microwave.cpp.

EDA_SIZE_CTRL* MWAVE_POLYGONAL_SHAPE_DLG::m_SizeCtrl
private

Definition at line 398 of file microwave.cpp.


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