2013-11-18 17:52:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-01-19 11:35:35 +00:00
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-11-18 17:52:18 +00:00
|
|
|
*
|
2019-01-19 11:35:35 +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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2013-11-18 17:52:18 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
/*
|
|
|
|
* Edit properties of Lines, Circles, Arcs and Polygons for PCBNew and ModEdit
|
2013-11-19 18:58:12 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <class_drawpanel.h>
|
2018-06-11 15:03:16 +00:00
|
|
|
#include <pcb_base_edit_frame.h>
|
2016-04-11 14:27:32 +00:00
|
|
|
#include <wx/valnum.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
2018-06-11 15:03:16 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
|
|
|
#include <html_messagebox.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_drawsegment.h>
|
2018-06-11 15:03:16 +00:00
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <widgets/unit_binder.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <dialog_graphic_item_properties_base.h>
|
2013-11-19 18:58:12 +00:00
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
class DIALOG_GRAPHIC_ITEM_PROPERTIES : public DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE
|
2008-12-23 13:15:08 +00:00
|
|
|
{
|
|
|
|
private:
|
2018-06-11 15:03:16 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* m_parent;
|
2015-02-06 21:49:40 +00:00
|
|
|
DRAWSEGMENT* m_item;
|
2018-06-11 15:03:16 +00:00
|
|
|
EDGE_MODULE* m_moduleItem;
|
|
|
|
|
|
|
|
UNIT_BINDER m_startX, m_startY;
|
|
|
|
UNIT_BINDER m_endX, m_endY;
|
|
|
|
UNIT_BINDER m_angle;
|
|
|
|
UNIT_BINDER m_thickness;
|
2018-07-22 12:50:35 +00:00
|
|
|
UNIT_BINDER m_bezierCtrl1X, m_bezierCtrl1Y;
|
|
|
|
UNIT_BINDER m_bezierCtrl2X, m_bezierCtrl2Y;
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
wxFloatingPointValidator<double> m_AngleValidator;
|
|
|
|
double m_AngleValue;
|
|
|
|
|
2008-12-23 13:15:08 +00:00
|
|
|
public:
|
2018-09-12 19:39:37 +00:00
|
|
|
DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BOARD_ITEM* aItem );
|
2012-02-12 19:39:37 +00:00
|
|
|
~DIALOG_GRAPHIC_ITEM_PROPERTIES() {};
|
2008-12-23 13:15:08 +00:00
|
|
|
|
|
|
|
private:
|
2016-09-24 18:53:15 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2016-07-18 16:28:02 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
void OnInitDlg( wxInitDialogEvent& event ) override
|
2016-07-18 16:28:02 +00:00
|
|
|
{
|
|
|
|
// Call the default wxDialog handler of a wxInitDialogEvent
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool Validate() override;
|
2008-12-23 13:15:08 +00:00
|
|
|
};
|
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
|
2018-09-12 19:39:37 +00:00
|
|
|
BOARD_ITEM* aItem ):
|
2016-04-11 14:27:32 +00:00
|
|
|
DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( aParent ),
|
2018-06-11 15:03:16 +00:00
|
|
|
m_startX( aParent, m_startXLabel, m_startXCtrl, m_startXUnits ),
|
|
|
|
m_startY( aParent, m_startYLabel, m_startYCtrl, m_startYUnits ),
|
|
|
|
m_endX( aParent, m_endXLabel, m_endXCtrl, m_endXUnits ),
|
|
|
|
m_endY( aParent, m_endYLabel, m_endYCtrl, m_endYUnits ),
|
|
|
|
m_angle( aParent, m_angleLabel, m_angleCtrl, m_angleUnits ),
|
|
|
|
m_thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true ),
|
2018-07-22 12:50:35 +00:00
|
|
|
m_bezierCtrl1X( aParent, m_BezierPointC1XLabel, m_BezierC1X_Ctrl, m_BezierPointC1XUnit ),
|
|
|
|
m_bezierCtrl1Y( aParent, m_BezierPointC1YLabel, m_BezierC1Y_Ctrl, m_BezierPointC1YUnit ),
|
|
|
|
m_bezierCtrl2X( aParent, m_BezierPointC2XLabel, m_BezierC2X_Ctrl, m_BezierPointC2XUnit ),
|
|
|
|
m_bezierCtrl2Y( aParent, m_BezierPointC2YLabel, m_BezierC2Y_Ctrl, m_BezierPointC2YUnit ),
|
2016-04-11 14:27:32 +00:00
|
|
|
m_AngleValidator( 1, &m_AngleValue ),
|
|
|
|
m_AngleValue( 0.0 )
|
2008-12-23 13:15:08 +00:00
|
|
|
{
|
2012-02-12 19:39:37 +00:00
|
|
|
m_parent = aParent;
|
2018-06-11 15:03:16 +00:00
|
|
|
m_item = dynamic_cast<DRAWSEGMENT*>( aItem );
|
|
|
|
m_moduleItem = dynamic_cast<EDGE_MODULE*>( aItem );
|
2016-04-11 14:27:32 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
m_angle.SetUnits( DEGREES );
|
2016-04-11 14:27:32 +00:00
|
|
|
m_AngleValidator.SetRange( -360.0, 360.0 );
|
2018-06-11 15:03:16 +00:00
|
|
|
m_angleCtrl->SetValidator( m_AngleValidator );
|
|
|
|
m_AngleValidator.SetWindow( m_angleCtrl );
|
2016-04-11 14:27:32 +00:00
|
|
|
|
2018-08-27 13:52:46 +00:00
|
|
|
// Configure the layers list selector
|
|
|
|
if( m_moduleItem )
|
2018-12-04 22:15:14 +00:00
|
|
|
{
|
|
|
|
LSET forbiddenLayers = LSET::ForbiddenFootprintLayers();
|
|
|
|
|
|
|
|
// If someone went to the trouble of setting the layer in a text editor, then there's
|
|
|
|
// very little sense in nagging them about it.
|
|
|
|
forbiddenLayers.set( m_item->GetLayer(), false );
|
|
|
|
|
|
|
|
m_LayerSelectionCtrl->SetNotAllowedLayerSet( forbiddenLayers );
|
|
|
|
}
|
2018-08-27 13:52:46 +00:00
|
|
|
|
|
|
|
m_LayerSelectionCtrl->SetLayersHotkeys( false );
|
|
|
|
m_LayerSelectionCtrl->SetBoardFrame( m_parent );
|
|
|
|
m_LayerSelectionCtrl->Resync();
|
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
SetInitialFocus( m_startXCtrl );
|
2016-04-11 14:27:32 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
m_StandardButtonsSizerOK->SetDefault();
|
2008-12-23 13:15:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-12 19:39:37 +00:00
|
|
|
void PCB_BASE_EDIT_FRAME::InstallGraphicItemPropertiesDialog( BOARD_ITEM* aItem )
|
2008-12-23 13:15:08 +00:00
|
|
|
{
|
2015-02-06 21:49:40 +00:00
|
|
|
wxCHECK_RET( aItem != NULL, wxT( "InstallGraphicItemPropertiesDialog() error: NULL item" ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2018-09-12 19:39:37 +00:00
|
|
|
DIALOG_GRAPHIC_ITEM_PROPERTIES dlg( this, aItem );
|
2013-11-18 17:52:18 +00:00
|
|
|
dlg.ShowModal();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2018-09-12 19:39:37 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-23 13:15:08 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 18:58:12 +00:00
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
|
2008-12-23 13:15:08 +00:00
|
|
|
{
|
2018-06-11 15:03:16 +00:00
|
|
|
if( !m_item )
|
|
|
|
return false;
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2017-12-21 18:47:03 +00:00
|
|
|
// Only an arc has a angle parameter. So do not show this parameter for other shapes
|
|
|
|
if( m_item->GetShape() != S_ARC )
|
2018-06-11 15:03:16 +00:00
|
|
|
m_angle.Show( false );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2018-07-22 12:50:35 +00:00
|
|
|
// Only a Bezeier curve has control points. So do not show these parameters for other shapes
|
|
|
|
if( m_item->GetShape() != S_CURVE )
|
|
|
|
{
|
|
|
|
m_bezierCtrl1X.Show( false );
|
|
|
|
m_bezierCtrl1Y.Show( false );
|
|
|
|
m_bezierCtrl2X.Show( false );
|
|
|
|
m_bezierCtrl2Y.Show( false );
|
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
// Change texts according to the segment shape:
|
2015-02-06 21:49:40 +00:00
|
|
|
switch( m_item->GetShape() )
|
2009-01-05 05:21:35 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
case S_CIRCLE:
|
2015-02-06 21:49:40 +00:00
|
|
|
SetTitle( _( "Circle Properties" ) );
|
2018-06-11 15:03:16 +00:00
|
|
|
m_startXLabel->SetLabel( _( "Center X:" ) );
|
|
|
|
m_startYLabel->SetLabel( _( "Center Y:" ) );
|
|
|
|
m_endXLabel->SetLabel( _( "Radius:" ) );
|
|
|
|
m_endY.Show( false );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2015-02-06 21:49:40 +00:00
|
|
|
SetTitle( _( "Arc Properties" ) );
|
2018-06-11 15:03:16 +00:00
|
|
|
m_startXLabel->SetLabel( _( "Center X:" ) );
|
|
|
|
m_startYLabel->SetLabel( _( "Center Y:" ) );
|
|
|
|
m_endXLabel->SetLabel( _( "Start Point X:" ) );
|
|
|
|
m_endYLabel->SetLabel( _( "Start Point Y:" ) );
|
2013-05-05 07:17:48 +00:00
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
m_AngleValue = m_item->GetAngle() / 10.0;
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
break;
|
|
|
|
|
2017-12-21 18:47:03 +00:00
|
|
|
case S_POLYGON:
|
|
|
|
SetTitle( _( "Polygon Properties" ) );
|
|
|
|
m_fgUpperLeftGridSizer->Show( false );
|
|
|
|
break;
|
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
case S_SEGMENT:
|
|
|
|
SetTitle( _( "Line Segment Properties" ) );
|
2017-12-21 18:47:03 +00:00
|
|
|
break;
|
2015-02-06 21:49:40 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-01-05 05:21:35 +00:00
|
|
|
}
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
m_startX.SetValue( m_item->GetStart().x );
|
|
|
|
m_startY.SetValue( m_item->GetStart().y );
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-04-27 16:09:05 +00:00
|
|
|
if( m_item->GetShape() == S_CIRCLE )
|
|
|
|
{
|
2018-06-11 15:03:16 +00:00
|
|
|
m_endX.SetValue( m_item->GetRadius() );
|
2018-04-27 16:09:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-11 15:03:16 +00:00
|
|
|
m_endX.SetValue( m_item->GetEnd().x );
|
|
|
|
m_endY.SetValue( m_item->GetEnd().y );
|
2018-04-27 16:09:05 +00:00
|
|
|
}
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-07-22 12:50:35 +00:00
|
|
|
// For Bezier curve:
|
|
|
|
m_bezierCtrl1X.SetValue( m_item->GetBezControl1().x );
|
|
|
|
m_bezierCtrl1Y.SetValue( m_item->GetBezControl1().y );
|
|
|
|
m_bezierCtrl2X.SetValue( m_item->GetBezControl2().x );
|
|
|
|
m_bezierCtrl2Y.SetValue( m_item->GetBezControl2().y );
|
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
m_thickness.SetValue( m_item->GetWidth() );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
if( m_LayerSelectionCtrl->SetLayerSelection( m_item->GetLayer() ) < 0 )
|
2008-12-23 13:15:08 +00:00
|
|
|
{
|
2019-01-19 11:35:35 +00:00
|
|
|
wxMessageBox( _( "This item was on a non-existing or forbidden layer.\n"
|
|
|
|
"It has been moved to the first allowed layer. Please fix it." ) );
|
2018-12-04 22:15:14 +00:00
|
|
|
m_LayerSelectionCtrl->SetSelection( 0 );
|
2008-12-23 13:15:08 +00:00
|
|
|
}
|
2016-04-11 14:27:32 +00:00
|
|
|
|
|
|
|
return DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataToWindow();
|
2008-12-23 13:15:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
|
2008-12-23 13:15:08 +00:00
|
|
|
{
|
2016-04-11 14:27:32 +00:00
|
|
|
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() )
|
|
|
|
return false;
|
2015-02-06 21:49:40 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
LAYER_NUM layer = m_LayerSelectionCtrl->GetLayerSelection();
|
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
BOARD_COMMIT commit( m_parent );
|
|
|
|
commit.Modify( m_item );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
m_item->SetStartX( m_startX.GetValue() );
|
|
|
|
m_item->SetStartY( m_startY.GetValue() );
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-04-27 16:09:05 +00:00
|
|
|
if( m_item->GetShape() == S_CIRCLE )
|
|
|
|
{
|
2018-06-11 15:03:16 +00:00
|
|
|
m_item->SetEnd( m_item->GetStart() + wxPoint( m_endX.GetValue(), 0 ) );
|
2018-04-27 16:09:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-11 15:03:16 +00:00
|
|
|
m_item->SetEndX( m_endX.GetValue() );
|
|
|
|
m_item->SetEndY( m_endY.GetValue() );
|
2018-04-27 16:09:05 +00:00
|
|
|
}
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-07-22 12:50:35 +00:00
|
|
|
// For Bezier curve: Set the two control points
|
|
|
|
if( m_item->GetShape() == S_CURVE )
|
2018-06-11 15:03:16 +00:00
|
|
|
{
|
2018-07-22 12:50:35 +00:00
|
|
|
m_item->SetBezControl1( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue() ) );
|
|
|
|
m_item->SetBezControl2( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_moduleItem )
|
|
|
|
{ // We are editing a footprint.
|
|
|
|
// Init the item coordinates relative to the footprint anchor,
|
|
|
|
// that are coordinate references
|
2018-06-11 15:03:16 +00:00
|
|
|
m_moduleItem->SetStart0( m_moduleItem->GetStart() );
|
|
|
|
m_moduleItem->SetEnd0( m_moduleItem->GetEnd() );
|
2018-07-22 12:50:35 +00:00
|
|
|
|
|
|
|
if( m_moduleItem->GetShape() == S_CURVE )
|
|
|
|
{
|
|
|
|
m_moduleItem->SetBezier0_C1( wxPoint( m_bezierCtrl1X.GetValue(), m_bezierCtrl1Y.GetValue() ) );
|
|
|
|
m_moduleItem->SetBezier0_C2( wxPoint( m_bezierCtrl2X.GetValue(), m_bezierCtrl2Y.GetValue() ) );
|
|
|
|
}
|
2018-06-11 15:03:16 +00:00
|
|
|
}
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-06-11 15:03:16 +00:00
|
|
|
m_item->SetWidth( m_thickness.GetValue() );
|
|
|
|
m_item->SetLayer( ToLAYER_ID( layer ) );
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
if( m_item->GetShape() == S_ARC )
|
2016-04-11 14:27:32 +00:00
|
|
|
m_item->SetAngle( m_AngleValue * 10.0 );
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2018-07-22 12:50:35 +00:00
|
|
|
m_item->RebuildBezierToSegmentsPointsList( m_item->GetWidth() );
|
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
commit.Push( _( "Modify drawing properties" ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
m_parent->SetMsgPanel( m_item );
|
2008-12-23 13:15:08 +00:00
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
return true;
|
2008-12-23 13:15:08 +00:00
|
|
|
}
|
2015-02-06 21:49:40 +00:00
|
|
|
|
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate()
|
2015-02-06 21:49:40 +00:00
|
|
|
{
|
|
|
|
wxArrayString error_msgs;
|
|
|
|
|
2016-04-11 14:27:32 +00:00
|
|
|
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::Validate() )
|
|
|
|
return false;
|
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
// Type specific checks.
|
|
|
|
switch( m_item->GetShape() )
|
|
|
|
{
|
|
|
|
case S_ARC:
|
|
|
|
// Check angle of arc.
|
2018-06-11 15:03:16 +00:00
|
|
|
if( m_angle.GetValue() == 0 )
|
2018-05-21 16:35:00 +00:00
|
|
|
error_msgs.Add( _( "The arc angle cannot be zero." ) );
|
2015-02-06 21:49:40 +00:00
|
|
|
// Fall through.
|
2018-06-11 15:03:16 +00:00
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
case S_CIRCLE:
|
|
|
|
// Check radius.
|
2018-06-11 15:03:16 +00:00
|
|
|
if( m_startX.GetValue() == m_endX.GetValue() && m_startY.GetValue() == m_endY.GetValue() )
|
2015-02-06 21:49:40 +00:00
|
|
|
error_msgs.Add( _( "The radius must be greater than zero." ) );
|
|
|
|
break;
|
|
|
|
|
2017-10-19 21:16:06 +00:00
|
|
|
case S_POLYGON:
|
|
|
|
break;
|
|
|
|
|
2015-02-06 21:49:40 +00:00
|
|
|
default:
|
|
|
|
// Check start and end are not the same.
|
2018-06-11 15:03:16 +00:00
|
|
|
if( m_startX.GetValue() == m_endX.GetValue() && m_startY.GetValue() == m_endY.GetValue() )
|
2015-02-06 21:49:40 +00:00
|
|
|
error_msgs.Add( _( "The start and end points cannot be the same." ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-01-18 08:31:56 +00:00
|
|
|
// Check the item thickness. Note the polygon outline thickness is allowed
|
|
|
|
// to be set to 0, because if the shape is exactly the polygon, its outline
|
|
|
|
// thickness must be 0
|
2018-06-11 15:03:16 +00:00
|
|
|
int thickness = m_thickness.GetValue();
|
2015-02-06 21:49:40 +00:00
|
|
|
|
2018-01-18 08:31:56 +00:00
|
|
|
if( m_item->GetShape() == S_POLYGON )
|
|
|
|
{
|
|
|
|
if( thickness < 0 )
|
|
|
|
error_msgs.Add( _( "The polygon outline thickness must be >= 0." ) );
|
|
|
|
}
|
2018-06-11 15:03:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( thickness <= 0 )
|
|
|
|
error_msgs.Add( _( "The item thickness must be greater than zero." ) );
|
|
|
|
}
|
2015-02-06 21:49:40 +00:00
|
|
|
|
|
|
|
if( error_msgs.GetCount() )
|
|
|
|
{
|
2015-09-11 13:08:53 +00:00
|
|
|
HTML_MESSAGE_BOX dlg( this, _( "Error List" ) );
|
2015-02-06 21:49:40 +00:00
|
|
|
dlg.ListSet( error_msgs );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_msgs.GetCount() == 0;
|
|
|
|
}
|