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 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, parent->GetUserUnits(),
476  LeftBoxSizer );
477 
478  GetSizer()->SetSizeHints( this );
479 }
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 GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
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 482 of file microwave.cpp.

References PolyEdges.

Referenced by ~MWAVE_POLYGONAL_SHAPE_DLG().

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

Definition at line 489 of file microwave.cpp.

References PolyShapeType, and ShapeSize.

Referenced by ~MWAVE_POLYGONAL_SHAPE_DLG().

490 {
492  PolyShapeType = m_ShapeOptionCtrl->GetSelection();
493  EndModal( wxID_OK );
494 }
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
wxSize GetValue()
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 497 of file microwave.cpp.

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

Referenced by ~MWAVE_POLYGONAL_SHAPE_DLG().

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 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:179
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
#define IU_PER_MILS
Definition: plotter.cpp:134
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:245
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: