2011-11-10 15:55:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-28 10:00:48 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2016-11-20 23:35:08 +00:00
|
|
|
* Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-11-10 15:55:05 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
2017-09-19 13:51:12 +00:00
|
|
|
* @file microwave.cpp
|
2011-09-23 13:57:12 +00:00
|
|
|
* @brief Microwave pcb layout code.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <filter_reader.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <macros.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2018-03-12 22:45:17 +00:00
|
|
|
#include <validators.h>
|
|
|
|
#include <dialog_text_entry.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2017-02-23 08:00:37 +00:00
|
|
|
#include <microwave/microwave_inductor.h>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
static std::vector< wxRealPoint > PolyEdges;
|
2008-12-06 12:49:33 +00:00
|
|
|
static double ShapeScaleX, ShapeScaleY;
|
|
|
|
static wxSize ShapeSize;
|
|
|
|
static int PolyShapeType;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
static void Exit_Self( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
|
|
|
|
|
|
|
|
static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel,
|
2011-02-03 19:27:28 +00:00
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
|
2017-02-23 08:00:37 +00:00
|
|
|
///> An inductor pattern temporarily used during mu-wave inductor creation
|
|
|
|
static MWAVE::INDUCTOR_PATTERN s_inductor_pattern;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2017-02-23 08:00:37 +00:00
|
|
|
///> A flag set to true when mu-wave inductor is being created
|
|
|
|
static bool s_inductorInProgress = false;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
|
|
|
|
2009-11-23 21:03:26 +00:00
|
|
|
/* This function shows on screen the bounding box of the inductor that will be
|
|
|
|
* created at the end of the build inductor process
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
2010-07-17 11:14:57 +00:00
|
|
|
/* Calculate the orientation and size of the box containing the inductor:
|
2016-07-11 03:09:18 +00:00
|
|
|
* the box is a rectangle with height = length/2
|
2010-07-17 11:14:57 +00:00
|
|
|
* the shape is defined by a rectangle, nor necessary horizontal or vertical
|
2009-02-26 00:37:04 +00:00
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
GRSetDrawMode( aDC, GR_XOR );
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2010-07-17 11:14:57 +00:00
|
|
|
wxPoint poly[5];
|
2015-01-28 10:00:48 +00:00
|
|
|
wxPoint pt = s_inductor_pattern.m_End - s_inductor_pattern.m_Start;
|
2013-05-01 17:32:36 +00:00
|
|
|
double angle = -ArcTangente( pt.y, pt.x );
|
|
|
|
int len = KiROUND( EuclideanNorm( pt ) );
|
2010-07-17 11:14:57 +00:00
|
|
|
|
|
|
|
// calculate corners
|
|
|
|
pt.x = 0; pt.y = len / 4;
|
|
|
|
RotatePoint( &pt, angle );
|
2015-01-28 10:00:48 +00:00
|
|
|
poly[0] = s_inductor_pattern.m_Start + pt;
|
|
|
|
poly[1] = s_inductor_pattern.m_End + pt;
|
2010-07-17 11:14:57 +00:00
|
|
|
pt.x = 0; pt.y = -len / 4;
|
|
|
|
RotatePoint( &pt, angle );
|
2015-01-28 10:00:48 +00:00
|
|
|
poly[2] = s_inductor_pattern.m_End + pt;
|
|
|
|
poly[3] = s_inductor_pattern.m_Start + pt;
|
2010-07-17 11:14:57 +00:00
|
|
|
poly[4] = poly[0];
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
GRPoly( aPanel->GetClipBox(), aDC, 5, poly, false, 0, YELLOW, YELLOW );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
s_inductor_pattern.m_End = aPanel->GetParent()->GetCrossHairPosition();
|
|
|
|
pt = s_inductor_pattern.m_End - s_inductor_pattern.m_Start;
|
2013-05-01 17:32:36 +00:00
|
|
|
angle = -ArcTangente( pt.y, pt.x );
|
|
|
|
len = KiROUND( EuclideanNorm( pt ) );
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2010-07-17 11:14:57 +00:00
|
|
|
// calculate new corners
|
|
|
|
pt.x = 0; pt.y = len / 4;
|
|
|
|
RotatePoint( &pt, angle );
|
2015-01-28 10:00:48 +00:00
|
|
|
poly[0] = s_inductor_pattern.m_Start + pt;
|
|
|
|
poly[1] = s_inductor_pattern.m_End + pt;
|
2010-07-17 11:14:57 +00:00
|
|
|
pt.x = 0; pt.y = -len / 4;
|
|
|
|
RotatePoint( &pt, angle );
|
2015-01-28 10:00:48 +00:00
|
|
|
poly[2] = s_inductor_pattern.m_End + pt;
|
|
|
|
poly[3] = s_inductor_pattern.m_Start + pt;
|
2010-07-17 11:14:57 +00:00
|
|
|
poly[4] = poly[0];
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
GRPoly( aPanel->GetClipBox(), aDC, 5, poly, false, 0, YELLOW, YELLOW );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
void Exit_Self( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
if( aPanel->IsMouseCaptured() )
|
|
|
|
aPanel->CallMouseCapture( aDC, wxDefaultPosition, false );
|
|
|
|
|
2017-02-23 08:00:37 +00:00
|
|
|
s_inductorInProgress = false;
|
2015-01-28 10:00:48 +00:00
|
|
|
aPanel->SetMouseCapture( NULL, NULL );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Begin_Self( wxDC* DC )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
2017-02-23 08:00:37 +00:00
|
|
|
if( s_inductorInProgress )
|
2009-02-26 00:37:04 +00:00
|
|
|
{
|
2016-01-22 12:30:44 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
|
|
|
|
|
|
|
wxString errorMessage;
|
|
|
|
|
|
|
|
// Prepare parameters for inductor
|
|
|
|
// s_inductor_pattern.m_Start is already initialized,
|
|
|
|
// when s_inductor_pattern.m_Flag == false
|
|
|
|
s_inductor_pattern.m_Width = GetDesignSettings().GetCurrentTrackWidth();
|
|
|
|
s_inductor_pattern.m_End = GetCrossHairPosition();
|
|
|
|
|
2017-02-23 08:00:37 +00:00
|
|
|
wxASSERT( s_inductorInProgress );
|
|
|
|
s_inductorInProgress = false;
|
|
|
|
|
|
|
|
MODULE* footprint = MWAVE::CreateMicrowaveInductor( s_inductor_pattern, this, errorMessage );
|
2016-01-22 12:30:44 +00:00
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
{
|
|
|
|
SetMsgPanel( footprint );
|
|
|
|
footprint->Draw( m_canvas, DC, GR_OR );
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( !errorMessage.IsEmpty() )
|
|
|
|
DisplayError( this, errorMessage );
|
|
|
|
|
2009-02-26 00:37:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
s_inductor_pattern.m_Start = GetCrossHairPosition();
|
|
|
|
s_inductor_pattern.m_End = s_inductor_pattern.m_Start;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2017-02-23 08:00:37 +00:00
|
|
|
s_inductorInProgress = true;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Update the initial coordinates.
|
2013-08-03 05:15:23 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
2009-04-05 20:49:15 +00:00
|
|
|
UpdateStatusBar();
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( ShowBoundingBoxMicroWaveInductor, Exit_Self );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2009-02-26 00:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
MODULE* PCB_EDIT_FRAME::CreateMuWaveBaseFootprint( const wxString& aValue,
|
|
|
|
int aTextSize, int aPadCount )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
MODULE* module = CreateNewModule( aValue );
|
2018-04-04 07:27:51 +00:00
|
|
|
AddModuleToBoard( module );
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
if( aTextSize > 0 )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) );
|
2015-01-28 10:00:48 +00:00
|
|
|
module->Reference().SetThickness( aTextSize/5 );
|
2017-01-23 20:30:11 +00:00
|
|
|
module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) );
|
2015-01-28 10:00:48 +00:00
|
|
|
module->Value().SetThickness( aTextSize/5 );
|
|
|
|
}
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Create 2 pads used in gaps and stubs. The gap is between these 2 pads
|
|
|
|
// the stub is the pad 2
|
2015-01-28 10:00:48 +00:00
|
|
|
wxString Line;
|
|
|
|
int pad_num = 1;
|
|
|
|
|
|
|
|
while( aPadCount-- )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
D_PAD* pad = new D_PAD( module );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
module->PadsList().PushFront( pad );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
int tw = GetDesignSettings().GetCurrentTrackWidth();
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetSize( wxSize( tw, tw ) );
|
|
|
|
|
|
|
|
pad->SetPosition( module->GetPosition() );
|
2015-08-23 19:40:33 +00:00
|
|
|
pad->SetShape( PAD_SHAPE_RECT );
|
|
|
|
pad->SetAttribute( PAD_ATTRIB_SMD );
|
2014-06-24 16:17:18 +00:00
|
|
|
pad->SetLayerSet( F_Cu );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
Line.Printf( wxT( "%d" ), pad_num );
|
2017-08-11 09:22:13 +00:00
|
|
|
pad->SetName( Line );
|
2007-08-08 03:50:44 +00:00
|
|
|
pad_num++;
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-29 18:02:54 +00:00
|
|
|
int oX;
|
2008-12-06 12:49:33 +00:00
|
|
|
D_PAD* pad;
|
2011-12-14 04:29:25 +00:00
|
|
|
MODULE* module;
|
2007-08-08 03:50:44 +00:00
|
|
|
wxString msg, cmp_name;
|
|
|
|
int pad_count = 2;
|
2009-11-18 12:52:19 +00:00
|
|
|
int angle = 0;
|
2015-01-28 10:00:48 +00:00
|
|
|
// Ref and value text size (O = use board default value.
|
|
|
|
// will be set to a value depending on the footprint size, if possible
|
|
|
|
int text_size = 0;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Enter the size of the gap or stub
|
2014-05-13 09:22:51 +00:00
|
|
|
int gap_size = GetDesignSettings().GetCurrentTrackWidth();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
switch( shape_type )
|
|
|
|
{
|
|
|
|
case 0:
|
2017-12-11 11:54:17 +00:00
|
|
|
msg = _( "Gap Size:" );
|
|
|
|
cmp_name = "muwave_gap";
|
2015-01-28 10:00:48 +00:00
|
|
|
text_size = gap_size;
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2017-12-11 11:54:17 +00:00
|
|
|
msg = _( "Stub Size:" );
|
|
|
|
cmp_name = "muwave_stub";
|
2015-01-28 10:00:48 +00:00
|
|
|
text_size = gap_size;
|
2007-08-08 03:50:44 +00:00
|
|
|
pad_count = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2017-12-11 11:54:17 +00:00
|
|
|
msg = _( "Arc Stub Radius Value:" );
|
|
|
|
cmp_name = "muwave_arcstub";
|
2007-08-08 03:50:44 +00:00
|
|
|
pad_count = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
msg = wxT( "???" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-12 22:45:17 +00:00
|
|
|
wxString value = StringFromValue( g_UserUnit, gap_size );
|
|
|
|
WX_TEXT_ENTRY_DIALOG dlg( this, msg, _( "Create microwave module" ), value );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2010-07-20 18:11:34 +00:00
|
|
|
return NULL; // cancelled by user
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
2010-07-21 08:15:54 +00:00
|
|
|
value = dlg.GetValue();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
gap_size = ValueFromString( g_UserUnit, value );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
bool abort = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( shape_type == 2 )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2010-07-21 08:15:54 +00:00
|
|
|
double fcoeff = 10.0, fval;
|
2010-07-20 18:11:34 +00:00
|
|
|
msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
|
2018-03-12 22:45:17 +00:00
|
|
|
WX_TEXT_ENTRY_DIALOG angledlg( this, _( "Angle in degrees:" ),
|
|
|
|
_( "Create microwave module" ), msg );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-21 08:15:54 +00:00
|
|
|
if( angledlg.ShowModal() != wxID_OK )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2010-07-21 08:15:54 +00:00
|
|
|
return NULL; // cancelled by user
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-21 08:15:54 +00:00
|
|
|
msg = angledlg.GetValue();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( !msg.ToDouble( &fval ) )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Incorrect number, abort" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
abort = true;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
angle = std::abs( KiROUND( fval * fcoeff ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
if( angle > 1800 )
|
|
|
|
angle = 1800;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( abort )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-08 03:50:44 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
module = CreateMuWaveBaseFootprint( cmp_name, text_size, pad_count );
|
2017-04-25 09:06:24 +00:00
|
|
|
pad = module->PadsList();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
switch( shape_type )
|
|
|
|
{
|
|
|
|
case 0: //Gap :
|
2012-02-19 04:02:19 +00:00
|
|
|
oX = -( gap_size + pad->GetSize().x ) / 2;
|
|
|
|
pad->SetX0( oX );
|
|
|
|
|
|
|
|
pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
|
|
|
|
|
2008-12-06 12:49:33 +00:00
|
|
|
pad = pad->Next();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
pad->SetX0( oX + gap_size + pad->GetSize().x );
|
|
|
|
pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: //Stub :
|
2017-08-11 09:22:13 +00:00
|
|
|
pad->SetName( wxT( "1" ) );
|
2008-12-06 12:49:33 +00:00
|
|
|
pad = pad->Next();
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 );
|
|
|
|
pad->SetSize( wxSize( pad->GetSize().x, gap_size ) );
|
|
|
|
pad->SetY( pad->GetPos0().y + pad->GetPosition().y );
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
case 2: // Arc Stub created by a polygonal approach:
|
2013-04-25 16:29:35 +00:00
|
|
|
{
|
2017-09-19 13:51:12 +00:00
|
|
|
pad->SetShape( PAD_SHAPE_CUSTOM );
|
|
|
|
pad->SetAnchorPadShape( PAD_SHAPE_RECT );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
int numPoints = (angle / 50) + 3; // Note: angles are in 0.1 degrees
|
2017-09-19 13:51:12 +00:00
|
|
|
std::vector<wxPoint> polyPoints;
|
2013-04-25 16:29:35 +00:00
|
|
|
polyPoints.reserve( numPoints );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
polyPoints.push_back( wxPoint( 0, 0 ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
int theta = -angle / 2;
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
for( int ii = 1; ii<numPoints - 1; ii++ )
|
|
|
|
{
|
|
|
|
wxPoint pt( 0, -gap_size );
|
|
|
|
RotatePoint( &pt.x, &pt.y, theta );
|
|
|
|
polyPoints.push_back( pt );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
theta += 50;
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
if( theta > angle / 2 )
|
|
|
|
theta = angle / 2;
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
2013-04-25 16:29:35 +00:00
|
|
|
|
|
|
|
// Close the polygon:
|
|
|
|
polyPoints.push_back( polyPoints[0] );
|
2017-09-19 13:51:12 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
pad->AddPrimitive( polyPoints, 0 ); // add a polygonal basic shape
|
2013-04-25 16:29:35 +00:00
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
break;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
module->CalculateBoundingBox();
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-14 04:29:25 +00:00
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************** Polygon Shapes ***********************/
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
enum id_mw_cmd {
|
2007-10-07 03:08:24 +00:00
|
|
|
ID_READ_SHAPE_FILE = 1000
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Setting polynomial form parameters
|
2007-08-08 03:50:44 +00:00
|
|
|
*/
|
2015-01-28 10:00:48 +00:00
|
|
|
class MWAVE_POLYGONAL_SHAPE_DLG : public wxDialog
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* m_Parent;
|
2007-08-08 03:50:44 +00:00
|
|
|
wxRadioBox* m_ShapeOptionCtrl;
|
2011-09-06 19:42:46 +00:00
|
|
|
EDA_SIZE_CTRL* m_SizeCtrl;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
public:
|
2015-01-28 10:00:48 +00:00
|
|
|
MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos );
|
|
|
|
~MWAVE_POLYGONAL_SHAPE_DLG() { };
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
private:
|
2009-11-18 12:52:19 +00:00
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2011-11-10 15:55:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void ReadDataShapeDescr( wxCommandEvent& event );
|
|
|
|
void AcceptOptions( wxCommandEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
BEGIN_EVENT_TABLE( MWAVE_POLYGONAL_SHAPE_DLG, wxDialog )
|
|
|
|
EVT_BUTTON( wxID_OK, MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick )
|
|
|
|
EVT_BUTTON( ID_READ_SHAPE_FILE, MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr )
|
2009-11-18 12:52:19 +00:00
|
|
|
END_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent,
|
2011-03-01 19:26:17 +00:00
|
|
|
const wxPoint& framepos ) :
|
2013-11-15 09:28:31 +00:00
|
|
|
wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
|
|
|
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
PolyEdges.clear();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
Button = new wxButton( this, ID_READ_SHAPE_FILE,
|
|
|
|
_( "Read Shape Description File..." ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2010-07-17 11:14:57 +00:00
|
|
|
wxString shapelist[3] =
|
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
_( "Normal" ), _( "Symmetrical" ), _( "Mirrored" )
|
2010-07-17 11:14:57 +00:00
|
|
|
};
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 3,
|
|
|
|
shapelist, 1,
|
2007-08-08 03:50:44 +00:00
|
|
|
wxRA_SPECIFY_COLS );
|
|
|
|
LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
2012-04-16 17:39:32 +00:00
|
|
|
m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, g_UserUnit, LeftBoxSizer );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-11-10 15:55:05 +00:00
|
|
|
PolyEdges.clear();
|
2015-01-28 10:00:48 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
ShapeSize = m_SizeCtrl->GetValue();
|
|
|
|
PolyShapeType = m_ShapeOptionCtrl->GetSelection();
|
2015-01-28 10:00:48 +00:00
|
|
|
EndModal( wxID_OK );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
static wxString lastpath; // To remember the last open path during a session
|
|
|
|
wxString mask = wxT( "*.*" );
|
|
|
|
|
2015-09-25 19:38:09 +00:00
|
|
|
wxString FullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ),
|
|
|
|
lastpath, FullFileName,
|
|
|
|
wxEmptyString, mask,
|
|
|
|
this, wxFD_OPEN, true );
|
2007-08-08 03:50:44 +00:00
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
wxFileName fn( FullFileName );
|
|
|
|
lastpath = fn.GetPath();
|
|
|
|
PolyEdges.clear();
|
|
|
|
|
|
|
|
FILE* File = wxFopen( FullFileName, wxT( "rt" ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
if( File == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "File not found" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
double unitconv = IU_PER_MM;
|
|
|
|
ShapeScaleX = ShapeScaleY = 1.0;
|
2011-01-14 17:43:30 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
FILE_LINE_READER fileReader( File, FullFileName );
|
2011-01-14 17:43:30 +00:00
|
|
|
FILTER_READER reader( fileReader );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
LOCALE_IO toggle;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
while( reader.ReadLine() )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
char* Line = reader.Line();
|
|
|
|
char* param1 = strtok( Line, " =\n\r" );
|
|
|
|
char* param2 = strtok( NULL, " \t\n\r" );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( param1, "Unit", 4 ) == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( param2, "inch", 4 ) == 0 )
|
2015-01-28 10:00:48 +00:00
|
|
|
unitconv = IU_PER_MILS*1000;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( param2, "mm", 2 ) == 0 )
|
2015-01-28 10:00:48 +00:00
|
|
|
unitconv = IU_PER_MM;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( param1, "$COORD", 6 ) == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
while( reader.ReadLine() )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
Line = reader.Line();
|
2007-08-08 03:50:44 +00:00
|
|
|
param1 = strtok( Line, " \t\n\r" );
|
|
|
|
param2 = strtok( NULL, " \t\n\r" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
wxRealPoint coord( atof( param1 ), atof( param2 ) );
|
|
|
|
PolyEdges.push_back( coord );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( Line, "XScale", 6 ) == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
ShapeScaleX = atof( param2 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2016-08-16 08:27:09 +00:00
|
|
|
if( strncasecmp( Line, "YScale", 6 ) == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
ShapeScaleY = atof( param2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
ShapeScaleX *= unitconv;
|
|
|
|
ShapeScaleY *= unitconv;
|
|
|
|
|
|
|
|
m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
D_PAD* pad1, * pad2;
|
2011-12-14 04:29:25 +00:00
|
|
|
MODULE* module;
|
2007-08-08 03:50:44 +00:00
|
|
|
wxString cmp_name;
|
|
|
|
int pad_count = 2;
|
2008-12-29 18:02:54 +00:00
|
|
|
EDGE_MODULE* edge;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2017-12-11 11:54:17 +00:00
|
|
|
MWAVE_POLYGONAL_SHAPE_DLG dlg( this, wxDefaultPosition );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
int ret = dlg.ShowModal();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
if( ret != wxID_OK )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2011-11-10 15:55:05 +00:00
|
|
|
PolyEdges.clear();
|
2015-01-28 10:00:48 +00:00
|
|
|
return NULL;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( PolyShapeType == 2 ) // mirrored
|
|
|
|
ShapeScaleY = -ShapeScaleY;
|
2008-12-29 18:02:54 +00:00
|
|
|
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
ShapeSize.x = KiROUND( ShapeScaleX );
|
|
|
|
ShapeSize.y = KiROUND( ShapeScaleY );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Shape has a null size!" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
if( PolyEdges.size() == 0 )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Shape has no points!" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
cmp_name = wxT( "muwave_polygon" );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
// Create a footprint with 2 pads, orientation = 0, pos 0
|
|
|
|
module = CreateMuWaveBaseFootprint( cmp_name, 0, pad_count );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
// We try to place the footprint anchor to the middle of the shape len
|
|
|
|
wxPoint offset;
|
|
|
|
offset.x = -ShapeSize.x / 2;
|
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
pad1 = module->PadsList();
|
2015-01-28 10:00:48 +00:00
|
|
|
pad1->SetX0( offset.x );
|
|
|
|
pad1->SetX( pad1->GetPos0().x );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-11-04 08:48:34 +00:00
|
|
|
pad2 = pad1->Next();
|
2015-01-28 10:00:48 +00:00
|
|
|
pad2->SetX0( offset.x + ShapeSize.x );
|
|
|
|
pad2->SetX( pad2->GetPos0().x );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
// Add a polygonal edge (corners will be added later) on copper layer
|
2011-12-14 04:29:25 +00:00
|
|
|
edge = new EDGE_MODULE( module );
|
|
|
|
edge->SetShape( S_POLYGON );
|
2014-06-24 16:17:18 +00:00
|
|
|
edge->SetLayer( F_Cu );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
module->GraphicalItemsList().PushFront( edge );
|
2015-01-28 10:00:48 +00:00
|
|
|
|
|
|
|
// Get the corner buffer of the polygonal edge
|
2017-10-19 21:16:06 +00:00
|
|
|
std::vector<wxPoint> polyPoints;
|
2015-01-28 10:00:48 +00:00
|
|
|
polyPoints.reserve( PolyEdges.size() + 2 );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
|
|
// Init start point coord:
|
2015-01-28 10:00:48 +00:00
|
|
|
polyPoints.push_back( wxPoint( offset.x, 0 ) );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2015-11-04 08:48:34 +00:00
|
|
|
wxPoint last_coordinate;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-11-16 20:52:51 +00:00
|
|
|
for( unsigned ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
last_coordinate.x = KiROUND( PolyEdges[ii].x * ShapeScaleX );
|
|
|
|
last_coordinate.y = -KiROUND( PolyEdges[ii].y * ShapeScaleY );
|
|
|
|
last_coordinate += offset;
|
2011-08-08 23:50:55 +00:00
|
|
|
polyPoints.push_back( last_coordinate );
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
// finish the polygonal shape
|
|
|
|
if( last_coordinate.y != 0 )
|
|
|
|
polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
switch( PolyShapeType )
|
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
case 0: // shape from file
|
|
|
|
case 2: // shape from file, mirrored (the mirror is already done)
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
|
2015-01-28 10:00:48 +00:00
|
|
|
case 1: // Symmetric shape: add the symmetric (mirrored) shape
|
|
|
|
for( int ndx = polyPoints.size() - 1; ndx >= 0; --ndx )
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
2011-08-08 23:50:55 +00:00
|
|
|
wxPoint pt = polyPoints[ndx];
|
2008-12-29 18:02:54 +00:00
|
|
|
pt.y = -pt.y; // mirror about X axis
|
2011-08-08 23:50:55 +00:00
|
|
|
polyPoints.push_back( pt );
|
2008-12-29 18:02:54 +00:00
|
|
|
}
|
2007-08-08 03:50:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-10-19 21:16:06 +00:00
|
|
|
edge->SetPolyPoints( polyPoints );
|
2017-12-11 11:54:17 +00:00
|
|
|
// Set the polygon outline thickness to 0, only the polygonal shape is filled
|
|
|
|
// without extra thickness
|
|
|
|
edge->SetWidth( 0 );
|
2011-11-10 15:55:05 +00:00
|
|
|
PolyEdges.clear();
|
2011-12-14 04:29:25 +00:00
|
|
|
module->CalculateBoundingBox();
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-14 04:29:25 +00:00
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-08 03:50:44 +00:00
|
|
|
int gap_size, oX;
|
|
|
|
D_PAD* pad, * next_pad;
|
|
|
|
wxString msg;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aModule == NULL )
|
2009-11-18 12:52:19 +00:00
|
|
|
return;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Test if module is a gap type (name begins with GAP, and has 2 pads).
|
2013-03-13 18:53:58 +00:00
|
|
|
msg = aModule->GetReference().Left( 3 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
if( msg != wxT( "GAP" ) )
|
|
|
|
return;
|
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
pad = aModule->PadsList();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
if( pad == NULL )
|
|
|
|
{
|
2014-10-30 17:31:56 +00:00
|
|
|
DisplayError( this, _( "No pad for this footprint" ) );
|
2009-11-18 12:52:19 +00:00
|
|
|
return;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-11-04 08:48:34 +00:00
|
|
|
next_pad = pad->Next();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
if( next_pad == NULL )
|
|
|
|
{
|
2014-10-30 17:31:56 +00:00
|
|
|
DisplayError( this, _( "Only one pad for this footprint" ) );
|
2009-11-18 12:52:19 +00:00
|
|
|
return;
|
2007-08-08 03:50:44 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aModule->Draw( m_canvas, DC, GR_XOR );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Calculate the current dimension.
|
|
|
|
gap_size = next_pad->GetPos0().x - pad->GetPos0().x - pad->GetSize().x;
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Entrer the desired length of the gap.
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
msg = StringFromValue( g_UserUnit, gap_size );
|
2018-03-12 22:45:17 +00:00
|
|
|
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return; // cancelled by user
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2010-07-21 08:15:54 +00:00
|
|
|
msg = dlg.GetValue();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
gap_size = ValueFromString( g_UserUnit, msg );
|
2007-08-08 03:50:44 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Updating sizes of pads forming the gap.
|
2014-05-13 09:22:51 +00:00
|
|
|
int tw = GetDesignSettings().GetCurrentTrackWidth();
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetSize( wxSize( tw, tw ) );
|
|
|
|
|
|
|
|
pad->SetY0( 0 );
|
|
|
|
oX = -( gap_size + pad->GetSize().x ) / 2;
|
|
|
|
pad->SetX0( oX );
|
|
|
|
|
|
|
|
wxPoint padpos = pad->GetPos0() + aModule->GetPosition();
|
|
|
|
|
|
|
|
RotatePoint( &padpos.x, &padpos.y,
|
2013-03-13 18:53:58 +00:00
|
|
|
aModule->GetPosition().x, aModule->GetPosition().y, aModule->GetOrientation() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
pad->SetPosition( padpos );
|
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
tw = GetDesignSettings().GetCurrentTrackWidth();
|
2012-02-19 04:02:19 +00:00
|
|
|
next_pad->SetSize( wxSize( tw, tw ) );
|
|
|
|
|
|
|
|
next_pad->SetY0( 0 );
|
|
|
|
next_pad->SetX0( oX + gap_size + next_pad->GetSize().x );
|
|
|
|
|
|
|
|
padpos = next_pad->GetPos0() + aModule->GetPosition();
|
|
|
|
|
|
|
|
RotatePoint( &padpos.x, &padpos.y,
|
2013-03-13 18:53:58 +00:00
|
|
|
aModule->GetPosition().x, aModule->GetPosition().y, aModule->GetOrientation() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
next_pad->SetPosition( padpos );
|
|
|
|
|
|
|
|
aModule->Draw( m_canvas, DC, GR_OR );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|