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 396 of file muonde.cpp.

Constructor & Destructor Documentation

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

Definition at line 441 of file muonde.cpp.

References g_UserUnit, PolyEdges, and ShapeSize.

442  :
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 }
wxRadioBox * m_ShapeOptionCtrl
Definition: muonde.cpp:400
PCB_EDIT_FRAME * m_Parent
Definition: muonde.cpp:399
EDA_SIZE_CTRL * m_SizeCtrl
Definition: muonde.cpp:401
static wxSize ShapeSize
Definition: muonde.cpp:57
static std::vector< wxRealPoint > PolyEdges
Definition: muonde.cpp:55
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
MWAVE_POLYGONAL_SHAPE_DLG::~MWAVE_POLYGONAL_SHAPE_DLG ( )
inline

Definition at line 405 of file muonde.cpp.

405 { };

Member Function Documentation

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

Definition at line 484 of file muonde.cpp.

References PolyEdges.

485 {
486  PolyEdges.clear();
487  EndModal( wxID_CANCEL );
488 }
static std::vector< wxRealPoint > PolyEdges
Definition: muonde.cpp:55
void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick ( wxCommandEvent &  event)
private

Definition at line 491 of file muonde.cpp.

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

492 {
494  PolyShapeType = m_ShapeOptionCtrl->GetSelection();
495  EndModal( wxID_OK );
496 }
wxRadioBox * m_ShapeOptionCtrl
Definition: muonde.cpp:400
static int PolyShapeType
Definition: muonde.cpp:58
EDA_SIZE_CTRL * m_SizeCtrl
Definition: muonde.cpp:401
static wxSize ShapeSize
Definition: muonde.cpp:57
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 499 of file muonde.cpp.

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

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 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
static double ShapeScaleX
Definition: muonde.cpp:56
static double ShapeScaleY
Definition: muonde.cpp:56
EDA_SIZE_CTRL * m_SizeCtrl
Definition: muonde.cpp:401
static std::vector< wxRealPoint > PolyEdges
Definition: muonde.cpp:55
Class FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
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 DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
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

Member Data Documentation

PCB_EDIT_FRAME* MWAVE_POLYGONAL_SHAPE_DLG::m_Parent
private

Definition at line 399 of file muonde.cpp.

wxRadioBox* MWAVE_POLYGONAL_SHAPE_DLG::m_ShapeOptionCtrl
private

Definition at line 400 of file muonde.cpp.

Referenced by OnOkClick().

EDA_SIZE_CTRL* MWAVE_POLYGONAL_SHAPE_DLG::m_SizeCtrl
private

Definition at line 401 of file muonde.cpp.

Referenced by OnOkClick(), and ReadDataShapeDescr().


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