pad editor: add option to show pad in outline mode. better code and fix minor issues.

This commit is contained in:
jean-pierre charras 2018-01-13 17:05:09 +01:00
parent 650207a6e1
commit 39dfc2c762
6 changed files with 187 additions and 30 deletions

View File

@ -36,7 +36,8 @@ do
echo "file $fl converted."
done
# covert .png files into .ico files using "icotools"
# covert .png files into .ico files using "icotool" from icoutils
# (see http://www.nongnu.org/icoutils/)
cd ../icons
for fl in $ICON_FILES
do

View File

@ -6,10 +6,10 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* 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
@ -121,6 +121,8 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
m_PadOrientCtrl->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_PadOrientCtrl );
m_cbShowPadOutline->SetValue( m_drawPadOutlineMode );
m_padMaster = &m_parent->GetDesignSettings().m_Pad_Master;
m_dummyPad = new D_PAD( (MODULE*) NULL );
@ -146,11 +148,14 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
FinishDialogSettings();
}
bool DIALOG_PAD_PROPERTIES::m_drawPadOutlineMode = false; // Stores the pad draw option during a session
void DIALOG_PAD_PROPERTIES::OnInitDialog( wxInitDialogEvent& event )
{
m_PadNumCtrl->SetFocus();
m_PadNumCtrl->SetSelection( -1, -1 );
m_selectedColor = COLOR4D( 1.0, 1.0, 1.0, 0.7 );
// Needed on some WM to be sure the pad is redrawn according to the final size
// of the canvas, with the right zoom factor
@ -211,7 +216,7 @@ void DIALOG_PAD_PROPERTIES::prepareCanvas()
// fix the pad render mode (filled/not filled)
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
bool filled = true; // could be an option in dialog
bool filled = !m_cbShowPadOutline->IsChecked();
settings->SetSketchMode( LAYER_PADS_TH, !filled );
settings->SetSketchMode( LAYER_PAD_FR, !filled );
settings->SetSketchMode( LAYER_PAD_BK, !filled );
@ -261,6 +266,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
drawInfo.m_Offset = m_dummyPad->GetPosition();
drawInfo.m_Display_padnum = true;
drawInfo.m_Display_netname = true;
drawInfo.m_ShowPadFilled = !m_drawPadOutlineMode;
if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
drawInfo.m_ShowNotPlatedHole = true;
@ -322,7 +328,6 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
// draw selected primitives:
COLOR4D hcolor = CYAN;
long select = m_listCtrlPrimitives->GetFirstSelected();
wxPoint start, end, center;
@ -340,33 +345,60 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
switch( primitive.m_Shape )
{
case S_SEGMENT: // usual segment : line with rounded ends
GRFilledSegment( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
primitive.m_Thickness, hcolor );
if( !m_drawPadOutlineMode )
GRFilledSegment( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
primitive.m_Thickness, m_selectedColor );
else
GRCSegm( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
primitive.m_Thickness, m_selectedColor );
break;
case S_ARC: // Arc with rounded ends
GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
dummySegment.GetCenter(), primitive.m_Thickness, hcolor );
if( !m_drawPadOutlineMode )
GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
dummySegment.GetCenter(), primitive.m_Thickness, m_selectedColor );
else
{
GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
dummySegment.GetCenter(), 0, m_selectedColor );
/* GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
dummySegment.GetCenter() - primitive.m_Thickness, 0, m_selectedColor );*/
}
break;
case S_CIRCLE: // ring or circle
if( primitive.m_Thickness )
{
GRCircle( NULL, &dc, dummySegment.GetCenter(), primitive.m_Radius,
primitive.m_Thickness, hcolor );
if( !m_drawPadOutlineMode )
GRCircle( NULL, &dc, dummySegment.GetCenter(), primitive.m_Radius,
primitive.m_Thickness, m_selectedColor );
else
{
GRCircle( NULL, &dc, dummySegment.GetCenter(),
primitive.m_Radius + primitive.m_Thickness/2, 0,
m_selectedColor );
GRCircle( NULL, &dc, dummySegment.GetCenter(),
primitive.m_Radius - primitive.m_Thickness/2, 0,
m_selectedColor );
}
}
else
{
GRFilledCircle( NULL, &dc, dummySegment.GetCenter(),
primitive.m_Radius, hcolor );
if( !m_drawPadOutlineMode )
GRFilledCircle( NULL, &dc, dummySegment.GetCenter(),
primitive.m_Radius, m_selectedColor );
else
GRCircle( NULL, &dc, dummySegment.GetCenter(),
primitive.m_Radius, 0, m_selectedColor );
}
break;
case S_POLYGON: // polygon
{
std::vector<wxPoint> poly = dummySegment.GetPolyPoints();
GRClosedPoly( NULL, &dc, poly.size(), &poly[0], /* filled */ true,
primitive.m_Thickness, hcolor, hcolor );
GRClosedPoly( NULL, &dc, poly.size(), &poly[0],
m_drawPadOutlineMode ? false : true,
primitive.m_Thickness, m_selectedColor, m_selectedColor );
}
break;
@ -805,6 +837,28 @@ void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event )
}
void DIALOG_PAD_PROPERTIES::onChangePadMode( wxCommandEvent& event )
{
m_drawPadOutlineMode = m_cbShowPadOutline->GetValue();
if( m_parent->IsGalCanvasActive() )
{
KIGFX::VIEW* view = m_panelShowPadGal->GetView();
// fix the pad render mode (filled/not filled)
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
settings->SetSketchMode( LAYER_PADS_TH, m_drawPadOutlineMode );
settings->SetSketchMode( LAYER_PAD_FR, m_drawPadOutlineMode );
settings->SetSketchMode( LAYER_PAD_BK, m_drawPadOutlineMode );
settings->SetSketchModeGraphicItems( m_drawPadOutlineMode );
}
redraw();
}
void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
{
bool is_custom = false;
@ -1184,7 +1238,14 @@ void DIALOG_PAD_PROPERTIES::redraw()
KIGFX::VIEW* view = m_panelShowPadGal->GetView();
m_panelShowPadGal->StopDrawing();
view->SetTopLayer( F_SilkS );
// The layer used to place primitive items selected when editing custom pad shapes
// we use here a layer never used in a pad:
#define SELECTED_ITEMS_LAYER Dwgs_User
view->SetTopLayer( SELECTED_ITEMS_LAYER );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
settings->SetLayerColor( SELECTED_ITEMS_LAYER, m_selectedColor );
view->Update( m_dummyPad );
@ -1203,7 +1264,7 @@ void DIALOG_PAD_PROPERTIES::redraw()
PAD_CS_PRIMITIVE& primitive = m_primitives[select];
DRAWSEGMENT* dummySegment = new DRAWSEGMENT;
dummySegment->SetLayer( F_SilkS );
dummySegment->SetLayer( SELECTED_ITEMS_LAYER );
primitive.ExportTo( dummySegment );
dummySegment->Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
dummySegment->Move( m_dummyPad->GetPosition() );
@ -1227,13 +1288,7 @@ void DIALOG_PAD_PROPERTIES::redraw()
}
break;
case S_POLYGON: // polygon
{
for( auto iter = dummySegment->GetPolyShape().Iterate(); iter; iter++ )
{
(*iter) += VECTOR2I( m_dummyPad->GetPosition() );
}
}
case S_POLYGON:
break;
default:

View File

@ -6,10 +6,10 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* 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
@ -90,6 +90,9 @@ private:
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
static bool m_drawPadOutlineMode; // Stores the pad draw option during a session
COLOR4D m_selectedColor; // Color used to draw selected primitives when
// editing a custom pad shape
private:
void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
@ -118,6 +121,7 @@ private:
void OnPadShapeSelection( wxCommandEvent& event ) override;
void OnDrillShapeSelected( wxCommandEvent& event ) override;
void onChangePadMode( wxCommandEvent& event ) override;
void PadOrientEvent( wxCommandEvent& event ) override;
void PadTypeSelected( wxCommandEvent& event ) override;

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Jul 2 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/text_ctrl_eval.h"
@ -656,6 +656,9 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
m_panelShowPadGal = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), wxDefaultSize, m_galOptions, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO);
bSizerDisplayPad->Add( m_panelShowPadGal, 4, wxEXPAND|wxRIGHT|wxTOP, 5 );
m_cbShowPadOutline = new wxCheckBox( this, wxID_ANY, _("Show pad in outline mode"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerDisplayPad->Add( m_cbShowPadOutline, 0, wxALL, 5 );
bSizerUpper->Add( bSizerDisplayPad, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
@ -725,6 +728,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
m_buttonGeometry->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onGeometryTransform ), NULL, this );
m_buttonImport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onImportPrimitives ), NULL, this );
m_panelShowPad->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this );
m_cbShowPadOutline->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onChangePadMode ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnCancel ), NULL, this );
}
@ -771,6 +775,7 @@ DIALOG_PAD_PROPERTIES_BASE::~DIALOG_PAD_PROPERTIES_BASE()
m_buttonGeometry->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onGeometryTransform ), NULL, this );
m_buttonImport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onImportPrimitives ), NULL, this );
m_panelShowPad->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this );
m_cbShowPadOutline->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onChangePadMode ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnCancel ), NULL, this );
}

View File

@ -10472,6 +10472,94 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show pad in outline mode</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbShowPadOutline</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">onChangePadMode</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Jul 2 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_PAD_PROPERTIES_BASE_H__
@ -11,7 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class TEXT_CTRL_EVAL;
class wxListView;
#include "dialog_shim.h"
#include <wx/string.h>
@ -177,6 +179,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
wxPanel* m_panelShowPad;
PCB_DRAW_PANEL_GAL* m_panelShowPadGal;
KIGFX::GAL_DISPLAY_OPTIONS m_galOptions;
wxCheckBox* m_cbShowPadOutline;
wxStaticText* m_staticTextWarningPadFlipped;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
@ -200,6 +203,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
virtual void onGeometryTransform( wxCommandEvent& event ) { event.Skip(); }
virtual void onImportPrimitives( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); }
virtual void onChangePadMode( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); }