Freshen microwave polygon dialog and remove a bunch of dead code.

This commit is contained in:
Jeff Young 2021-08-03 01:11:11 +01:00
parent 43523df843
commit 95b87ba29a
31 changed files with 126 additions and 260 deletions

View File

@ -328,7 +328,6 @@ set( COMMON_SRCS
eda_item.cpp
eda_pattern_match.cpp
eda_rect.cpp
eda_size_ctrl.cpp
eda_units.cpp
env_paths.cpp
env_vars.cpp

View File

@ -23,7 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
#include <eda_draw_frame.h>
#include <string_utils.h>
#include <macros.h>

View File

@ -1,103 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <eda_base_frame.h>
#include <dialog_helpers.h>
#include <base_units.h>
/********************************************************/
/* Class to display and edit a coordinated INCHES or MM */
/********************************************************/
EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& aPos,
EDA_UNITS user_unit, wxBoxSizer* BoxSizer )
{
m_UserUnit = user_unit;
m_TextX = new wxStaticText( parent, -1, title + wxS( " " ) + _( "X:" ) );
BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition );
BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_TextY = new wxStaticText( parent, -1, title + wxS( " " ) + _( "Y:" ) );
BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString );
BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
SetValue( aPos.x, aPos.y );
}
EDA_POSITION_CTRL::~EDA_POSITION_CTRL()
{
delete m_TextX;
delete m_TextY;
delete m_FramePosX;
delete m_FramePosY;
}
/* Returns (in internal units) to coordinate between (in user units)
*/
wxPoint EDA_POSITION_CTRL::GetValue() const
{
return wxPoint( ValueFromString( m_UserUnit, m_FramePosX->GetValue() ),
ValueFromString( m_UserUnit, m_FramePosY->GetValue() ) );
}
void EDA_POSITION_CTRL::Enable( bool x_win_on, bool y_win_on )
{
m_FramePosX->Enable( x_win_on );
m_FramePosY->Enable( y_win_on );
}
void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
{
m_FramePosX->SetValue( StringFromValue( m_UserUnit, x_value ) );
m_FramePosY->SetValue( StringFromValue( m_UserUnit, y_value ) );
}
/*******************/
/* EDA_SIZE_CTRL */
/*******************/
EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& aSize,
EDA_UNITS aUnit, wxBoxSizer* aBoxSizer )
: EDA_POSITION_CTRL( parent, title, wxPoint( aSize.x, aSize.y ), aUnit, aBoxSizer )
{
}
wxSize EDA_SIZE_CTRL::GetValue() const
{
wxPoint pos = EDA_POSITION_CTRL::GetValue();
return wxSize( pos.x, pos.y );
}

View File

@ -32,7 +32,7 @@
#include <bom_plugins.h>
#include <confirm.h>
#include <dialog_bom_base.h>
#include <dialog_helpers.h>
#include <string_utils.h>
#include <eeschema_settings.h>
#include <gestfich.h>
#include <dialogs/html_messagebox.h>

View File

@ -46,7 +46,6 @@
#include <project/project_file.h>
#include <project/net_settings.h>
#include <core/mirror.h>
#include <dialog_helpers.h>
#include <trigo.h>
using KIGFX::SCH_RENDER_SETTINGS;

View File

@ -39,7 +39,7 @@
#include <sch_plugins/legacy/sch_legacy_plugin.h>
#include <sch_plugins/kicad/sch_sexpr_plugin.h>
#include <dialogs/dialog_lib_new_symbol.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
#include <wx/clipbrd.h>
#include <wx/filedlg.h>
#include <wx/log.h>

View File

@ -26,7 +26,6 @@
#include <eeschema_id.h>
#include <symbol_edit_frame.h>
#include <sch_painter.h>
#include <dialog_helpers.h>
#include <bitmaps.h>
#include <symbol_library_manager.h>
#include <tool/action_toolbar.h>

View File

@ -26,7 +26,6 @@
#include <bitmaps.h>
#include <symbol_library.h>
#include <confirm.h>
#include <dialog_helpers.h>
#include <dialog_choose_symbol.h>
#include <eeschema_id.h>
#include <eeschema_settings.h>

View File

@ -60,7 +60,7 @@
#include <tools/sch_editor_control.h>
#include <drawing_sheet/ds_proxy_undo_item.h>
#include <dialog_update_from_pcb.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )

View File

@ -27,7 +27,6 @@
#include <gerbview_id.h>
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
#include <dialog_helpers.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_manager.h>
#include <tool/selection.h>

View File

@ -19,15 +19,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <wx/wupdlock.h>
#include <wx/stattext.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <bitmaps.h>
#include <gerbview_id.h>
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
#include <dialog_helpers.h>
#include <string_utils.h>
#include <wx/wupdlock.h>
#include <tool/actions.h>
#include <tool/action_toolbar.h>
#include <tools/gerbview_actions.h>

View File

@ -22,20 +22,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_helpers.h
* @brief Helper dialog and control classes.
* @note Due to use of wxFormBuilder to create dialogs many of them should be removed.
*/
#ifndef DIALOG_HELPERS_H_
#define DIALOG_HELPERS_H_
#ifndef EDA_LIST_DIALOG_H
#define EDA_LIST_DIALOG_H
#include <../common/dialogs/eda_list_dialog_base.h>
#include <eda_units.h>
void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput );
class EDA_DRAW_FRAME;
@ -90,45 +83,4 @@ private:
};
/**
* Object to edit/enter a coordinate (pair of values) ( INCHES or MM ) in dialog boxes.
*/
class EDA_POSITION_CTRL
{
public:
EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit,
EDA_UNITS user_unit, wxBoxSizer* BoxSizer );
~EDA_POSITION_CTRL();
void Enable( bool x_win_on, bool y_win_on );
void SetValue( int x_value, int y_value );
wxPoint GetValue() const;
EDA_UNITS m_UserUnit;
wxTextCtrl* m_FramePosX;
wxTextCtrl* m_FramePosY;
private:
wxStaticText* m_TextX;
wxStaticText* m_TextY;
};
/**
* Object to edit/enter a size (pair of values for X and Y size ( INCHES or MM ) in dialog boxes.
*/
class EDA_SIZE_CTRL : public EDA_POSITION_CTRL
{
public:
EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& size_to_edit,
EDA_UNITS user_unit, wxBoxSizer* BoxSizer );
~EDA_SIZE_CTRL() { }
wxSize GetValue() const;
};
#endif // DIALOG_HELPERS_H_
#endif // EDA_LIST_DIALOG_H

View File

@ -32,6 +32,8 @@
#include <wx/filename.h>
void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput );
/**
* Convert the old `~...~` overbar notation to the new `~{...}` one.
*/

View File

@ -29,10 +29,7 @@
*/
#include <base_units.h>
#include <dialog_helpers.h>
#include <eda_item.h>
#include <gr_basic.h>
#include <drawing_sheet/ds_draw_item.h>
#include <drawing_sheet/ds_data_item.h>
#include <drawing_sheet/ds_data_model.h>
#include <drawing_sheet/ds_painter.h>

View File

@ -26,7 +26,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <dialog_helpers.h>
#include <string_utils.h>
#include "pcb_calculator_frame.h"

View File

@ -19,12 +19,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vector>
#include <array>
#include <iostream>
#include <string>
#include <dialog_helpers.h>
#include <string_utils.h>
#include "class_regulator_data.h"
#include "pcb_calculator_frame.h"

View File

@ -27,9 +27,8 @@
#include <cassert>
#include <cmath>
#include <kiface_i.h>
#include <dialog_helpers.h>
#include "attenuators/attenuator_classes.h"
#include <string_utils.h>
#include "class_regulator_data.h"
#include "pcb_calculator_frame.h"
#include "pcb_calculator_settings.h"

View File

@ -47,7 +47,7 @@
#include <wx/textdlg.h>
#include <locale_io.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
// Some wx widget ID to know what widget has fired a event:

View File

@ -24,10 +24,8 @@
*/
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <board_commit.h>
#include <board.h>
#include <pcb_target.h>
#include <dialog_target_properties_base.h>
#include <widgets/unit_binder.h>

View File

@ -36,7 +36,7 @@
#include <wx/choicdlg.h>
#include <wx/treebook.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
// some define to choose how copper layers widgets are shown

View File

@ -38,7 +38,6 @@
#include <scintilla_tricks.h>
#include <drc/drc_rule_parser.h>
#include <tools/drc_tool.h>
#include <dialog_helpers.h>
PANEL_SETUP_RULES::PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
PANEL_SETUP_RULES_BASE( aParent->GetTreebook() ),

View File

@ -28,7 +28,7 @@
#include <string_utils.h>
#include <macros.h>
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
#include <filter_reader.h>
#include <fp_lib_table.h>
#include <validators.h>

View File

@ -29,7 +29,6 @@
#include <board.h>
#include <footprint.h>
#include <confirm.h>
#include <dialog_helpers.h>
#include <eda_pattern_match.h>
#include <footprint_info.h>
#include <footprint_viewer_frame.h>

View File

@ -24,22 +24,18 @@
*/
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <board.h>
#include <footprint.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
#include "footprint_wizard_frame.h"
#include <wildcards_and_files_ext.h>
#include <dialogs/dialog_footprint_wizard_list.h>
#include <base_units.h>
#include <widgets/wx_grid.h>
#include <wx/listbox.h>
#include <wx/msgdlg.h>
#include <tool/tool_manager.h>
#include "footprint_wizard_frame.h"
void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )

View File

@ -32,7 +32,7 @@ using namespace std::placeholders;
#include <connectivity/connectivity_data.h>
#include <dialog_choose_footprint.h>
#include <dialog_get_footprint_by_name.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
#include <footprint_edit_frame.h>
#include <footprint_info_impl.h>
#include <footprint_tree_pane.h>

View File

@ -77,7 +77,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
}
wxString value = StringFromValue( editFrame.GetUserUnits(), gap_size );
WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create microwave footprint" ), value );
WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create Microwave Footprint" ), value );
if( dlg.ShowQuasiModal() != wxID_OK )
return nullptr; // cancelled by user
@ -92,7 +92,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
double fcoeff = 10.0, fval;
msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
WX_TEXT_ENTRY_DIALOG angledlg( &editFrame, _( "Angle in degrees:" ),
_( "Create microwave footprint" ), msg );
_( "Create Microwave Footprint" ), msg );
if( angledlg.ShowQuasiModal() != wxID_OK )
return nullptr; // cancelled by user

View File

@ -25,16 +25,11 @@
*/
#include <confirm.h>
#include <trigo.h>
#include <string_utils.h>
#include <widgets/unit_binder.h>
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <dialog_shim.h>
#include <locale_io.h>
#include <richio.h>
#include <filter_reader.h>
#include <base_units.h>
#include <validators.h>
#include <dialogs/dialog_text_entry.h>
#include <board.h>
#include <footprint.h>
@ -49,12 +44,12 @@
#include <wx/filedlg.h>
#include <wx/radiobox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
static std::vector< wxRealPoint > PolyEdges;
static double ShapeScaleX, ShapeScaleY;
static wxSize ShapeSize;
static int PolyShapeType;
static std::vector< wxRealPoint > g_PolyEdges;
static double g_ShapeScaleX, g_ShapeScaleY;
static wxSize g_ShapeSize;
static int g_PolyShapeType;
enum id_mw_cmd {
@ -66,7 +61,12 @@ class MWAVE_POLYGONAL_SHAPE_DLG : public DIALOG_SHIM
{
public:
MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos );
~MWAVE_POLYGONAL_SHAPE_DLG() { };
~MWAVE_POLYGONAL_SHAPE_DLG()
{
delete m_sizeX;
delete m_sizeY;
};
bool TransferDataFromWindow() override;
@ -93,9 +93,10 @@ private:
DECLARE_EVENT_TABLE()
PCB_EDIT_FRAME* m_Parent;
wxRadioBox* m_ShapeOptionCtrl;
EDA_SIZE_CTRL* m_SizeCtrl;
PCB_EDIT_FRAME* m_frame;
wxRadioBox* m_shapeOptionCtrl;
UNIT_BINDER* m_sizeX;
UNIT_BINDER* m_sizeY;
};
@ -107,40 +108,74 @@ END_EVENT_TABLE()
MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent,
const wxPoint& framepos ) :
DIALOG_SHIM( parent, -1, _( "Complex shape" ), framepos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
DIALOG_SHIM( parent, -1, _( "Complex Shape" ), framepos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
m_sizeX(),
m_sizeY()
{
m_Parent = parent;
m_frame = parent;
PolyEdges.clear();
g_PolyEdges.clear();
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( MainBoxSizer );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxBoxSizer* mainBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( mainBoxSizer );
wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
// Controls
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, ID_READ_SHAPE_FILE,
_( "Read Shape Description File..." ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
wxBoxSizer* topBoxSizer = new wxBoxSizer( wxHORIZONTAL );
mainBoxSizer->Add( topBoxSizer, 1, wxGROW | wxALL, 5 );
wxString shapelist[] = { _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" ) };
m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ),
m_shapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape" ),
wxDefaultPosition, wxDefaultSize, 3,
shapelist, 1,
wxRA_SPECIFY_COLS );
LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
topBoxSizer->Add( m_shapeOptionCtrl, 1, wxGROW | wxALL, 5 );
m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, parent->GetUserUnits(),
LeftBoxSizer );
auto sizeSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _( "Size" ) ),
wxVERTICAL );
wxBoxSizer* xSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* ySizer = new wxBoxSizer( wxHORIZONTAL );
topBoxSizer->Add( sizeSizer, 1, wxGROW | wxALL, 5 );
sizeSizer->Add( xSizer, 0, 0, 5 );
sizeSizer->Add( ySizer, 0, 0, 5 );
wxStaticText* xLabel = new wxStaticText( this, -1, _( "X:" ) );
wxTextCtrl* xCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString );
wxStaticText* xUnits = new wxStaticText( this, -1, _( "units" ) );
xSizer->Add( xLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
xSizer->Add( xCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 );
xSizer->Add( xUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
m_sizeX = new UNIT_BINDER( m_frame, xLabel, xCtrl, xUnits );
wxStaticText* yLabel = new wxStaticText( this, -1, _( "Y:" ) );
wxTextCtrl* yCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString );
wxStaticText* yUnits = new wxStaticText( this, -1, _( "units" ) );
ySizer->Add( yLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
ySizer->Add( yCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 );
ySizer->Add( yUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
m_sizeY = new UNIT_BINDER( m_frame, yLabel, yCtrl, yUnits );
// Buttons
wxBoxSizer* buttonsBoxSizer = new wxBoxSizer( wxHORIZONTAL );
mainBoxSizer->Add( buttonsBoxSizer, 0, wxALL, 5 );
wxButton* btn = new wxButton( this, ID_READ_SHAPE_FILE, _( "Read Shape Description File..." ) );
buttonsBoxSizer->Add( btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 10 );
buttonsBoxSizer->AddStretchSpacer();
wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
buttonsBoxSizer->Add( sdbSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton* sdbSizerOK = new wxButton( this, wxID_OK );
sdbSizer->AddButton( sdbSizerOK );
wxButton* sdbSizerCancel = new wxButton( this, wxID_CANCEL );
sdbSizer->AddButton( sdbSizerCancel );
sdbSizer->Realize();
GetSizer()->SetSizeHints( this );
}
@ -148,7 +183,7 @@ MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent,
void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick( wxCommandEvent& event )
{
PolyEdges.clear();
g_PolyEdges.clear();
event.Skip();
}
@ -158,8 +193,9 @@ bool MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow()
if( !wxDialog::TransferDataFromWindow() )
return false;
ShapeSize = m_SizeCtrl->GetValue();
PolyShapeType = m_ShapeOptionCtrl->GetSelection();
g_ShapeSize.x = m_sizeX->GetValue();
g_ShapeSize.y = m_sizeY->GetValue();
g_PolyShapeType = m_shapeOptionCtrl->GetSelection();
return true;
}
@ -167,19 +203,19 @@ bool MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow()
void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
{
static wxString lastpath; // To remember the last open path during a session
static wxString s_lastpath; // To remember the last open path during a session
wxString fullFileName;
wxString mask = wxFileSelectorDefaultWildcardStr;
fullFileName = wxFileSelector( _( "Shape Description File" ), lastpath,
fullFileName = wxFileSelector( _( "Shape Description File" ), s_lastpath,
fullFileName, wxEmptyString, mask, wxFD_OPEN, this );
if( fullFileName.IsEmpty() )
return;
wxFileName fn( fullFileName );
lastpath = fn.GetPath();
PolyEdges.clear();
s_lastpath = fn.GetPath();
g_PolyEdges.clear();
FILE* File = wxFopen( fullFileName, wxT( "rt" ) );
@ -190,7 +226,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
}
double unitconv = IU_PER_MM;
ShapeScaleX = ShapeScaleY = 1.0;
g_ShapeScaleX = g_ShapeScaleY = 1.0;
FILE_LINE_READER fileReader( File, fullFileName );
FILTER_READER reader( fileReader );
@ -227,21 +263,22 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
break;
wxRealPoint coord( atof( param1 ), atof( param2 ) );
PolyEdges.push_back( coord );
g_PolyEdges.push_back( coord );
}
}
if( strncasecmp( Line, "XScale", 6 ) == 0 )
ShapeScaleX = atof( param2 );
g_ShapeScaleX = atof( param2 );
if( strncasecmp( Line, "YScale", 6 ) == 0 )
ShapeScaleY = atof( param2 );
g_ShapeScaleY = atof( param2 );
}
ShapeScaleX *= unitconv;
ShapeScaleY *= unitconv;
g_ShapeScaleX *= unitconv;
g_ShapeScaleY *= unitconv;
m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
m_sizeX->SetValue( (int) g_ShapeScaleX );
m_sizeY->SetValue( (int) g_ShapeScaleY );
}
@ -262,23 +299,23 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
if( ret != wxID_OK )
{
PolyEdges.clear();
g_PolyEdges.clear();
return nullptr;
}
if( PolyShapeType == 2 ) // mirrored
ShapeScaleY = -ShapeScaleY;
if( g_PolyShapeType == 2 ) // mirrored
g_ShapeScaleY = -g_ShapeScaleY;
ShapeSize.x = KiROUND( ShapeScaleX );
ShapeSize.y = KiROUND( ShapeScaleY );
g_ShapeSize.x = KiROUND( g_ShapeScaleX );
g_ShapeSize.y = KiROUND( g_ShapeScaleY );
if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
if(( g_ShapeSize.x ) == 0 || ( g_ShapeSize.y == 0 ) )
{
editFrame.ShowInfoBarError( _( "Shape has a null size." ) );
return nullptr;
}
if( PolyEdges.size() == 0 )
if( g_PolyEdges.size() == 0 )
{
editFrame.ShowInfoBarError( _( "Shape has no points." ) );
return nullptr;
@ -291,7 +328,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
// We try to place the footprint anchor to the middle of the shape len
wxPoint offset;
offset.x = -ShapeSize.x / 2;
offset.x = -g_ShapeSize.x / 2;
auto it = footprint->Pads().begin();
@ -300,7 +337,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
pad1->SetX( pad1->GetPos0().x );
pad2 = *( ++it );
pad2->SetX0( offset.x + ShapeSize.x );
pad2->SetX0( offset.x + g_ShapeSize.x );
pad2->SetX( pad2->GetPos0().x );
// Add a polygonal edge (corners will be added later) on copper layer
@ -313,17 +350,17 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
// Get the corner buffer of the polygonal edge
std::vector<wxPoint> polyPoints;
polyPoints.reserve( PolyEdges.size() + 2 );
polyPoints.reserve( g_PolyEdges.size() + 2 );
// Init start point coord:
polyPoints.emplace_back( wxPoint( offset.x, 0 ) );
wxPoint last_coordinate;
for( wxRealPoint& pt: PolyEdges ) // Copy points
for( wxRealPoint& pt: g_PolyEdges ) // Copy points
{
last_coordinate.x = KiROUND( pt.x * ShapeScaleX );
last_coordinate.y = -KiROUND( pt.y * ShapeScaleY );
last_coordinate.x = KiROUND( pt.x * g_ShapeScaleX );
last_coordinate.y = -KiROUND( pt.y * g_ShapeScaleY );
last_coordinate += offset;
polyPoints.push_back( last_coordinate );
}
@ -332,7 +369,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
if( last_coordinate.y != 0 )
polyPoints.emplace_back( wxPoint( last_coordinate.x, 0 ) );
switch( PolyShapeType )
switch( g_PolyShapeType )
{
case 0: // shape from file
case 2: // shape from file, mirrored (the mirror is already done)
@ -354,7 +391,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape()
// Set the polygon outline thickness to 0, only the polygonal shape is filled
// without extra thickness.
shape->SetWidth( 0 );
PolyEdges.clear();
g_PolyEdges.clear();
editFrame.OnModify();
return footprint;

View File

@ -34,7 +34,6 @@
#include <kiface_i.h>
#include <confirm.h>
#include <dialog_helpers.h>
#include <pcb_base_frame.h>
#include <base_units.h>
#include <widgets/msgpanel.h>

View File

@ -22,7 +22,6 @@
#include <tool/actions.h>
#include <footprint_edit_frame.h>
#include <dialog_helpers.h>
#include <pcbnew_id.h>
#include <bitmaps.h>
#include <tool/action_toolbar.h>

View File

@ -30,7 +30,6 @@
#include <bitmaps.h>
#include <board.h>
#include <board_design_settings.h>
#include <dialog_helpers.h>
#include <kiface_i.h>
#include <macros.h>
#include <pcb_edit_frame.h>

View File

@ -23,7 +23,7 @@
#include <bitmaps.h>
#include <board.h>
#include <board_design_settings.h>
#include <dialog_helpers.h>
#include <eda_list_dialog.h>
#include <footprint_edit_frame.h>
#include <menus_helpers.h>
#include <pcb_display_options.h>