Eeschema: Adding line styling options

NEW: Adds support in eeschema for changing the default line style,
width and color on a case-by-case basis.

CHANGED: "Wire" lines now optionally include data on the line style,
width and color if they differ from the default.

Fixes: lp:594059
* https://bugs.launchpad.net/kicad/+bug/594059

Fixes: lp:1405026
* https://bugs.launchpad.net/kicad/+bug/1405026
This commit is contained in:
Seth Hillbrand 2017-10-31 09:33:37 -07:00 committed by jean-pierre charras
parent a8e98ade49
commit b576189a00
14 changed files with 1318 additions and 21 deletions

View File

@ -208,6 +208,7 @@ void GRResetPenAndBrush( wxDC* DC )
*/
void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
{
wxDash dots[2] = { 1, 3 };
// Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
// nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
if( width <= 1 )
@ -224,6 +225,11 @@ void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
{
wxPen pen;
pen.SetColour( Color.ToColour() );
if( style == wxPENSTYLE_DOT )
{
style = wxPENSTYLE_USER_DASH;
pen.SetDashes( 2, dots );
}
pen.SetWidth( width );
pen.SetStyle( style );
DC->SetPen( pen );
@ -356,18 +362,19 @@ void GRLine( EDA_RECT* ClipBox,
int x2,
int y2,
int width,
COLOR4D Color )
COLOR4D Color,
wxPenStyle aStyle)
{
GRSetColorPen( DC, Color, width );
GRSetColorPen( DC, Color, width, aStyle );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
GRLastMoveToX = x2;
GRLastMoveToY = y2;
}
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor )
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle )
{
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
}
@ -375,13 +382,15 @@ void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, COLOR4D Color )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
s_DC_lastcolor = COLOR4D::UNSPECIFIED;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
s_DC_lastcolor = COLOR4D::UNSPECIFIED;
GRSetColorPen( DC, Color, width );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_SHORT_DASH );
}
void GRDottedLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, COLOR4D Color )
{
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT );
}
@ -407,9 +416,7 @@ void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, COLOR4D Col
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color )
{
GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
GRSetColorPen( DC, Color, width );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT_DASH );
}

View File

@ -39,6 +39,8 @@ set( EESCHEMA_DLGS
dialogs/dialog_edit_label_base.cpp
dialogs/dialog_edit_libentry_fields_in_lib.cpp
dialogs/dialog_edit_libentry_fields_in_lib_base.cpp
dialogs/dialog_edit_line_style.cpp
dialogs/dialog_edit_line_style_base.cpp
dialogs/dialog_edit_one_field.cpp
dialogs/dialog_eeschema_options_base.cpp
dialogs/dialog_eeschema_options.cpp

View File

@ -0,0 +1,95 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Seth Hillbrand <hillbrand@ucdavis.edu>
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.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 <dialog_edit_line_style.h>
DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( wxWindow* parent ) :
DIALOG_EDIT_LINE_STYLE_BASE( parent )
{
m_sdbSizer1Apply->SetLabel( _( "Default" ) );
m_lineStyle->SetSelection( 0 );
m_lineWidth->SetFocus();
defaultStyle = 0;
defaultWidth = "";
m_sdbSizer1OK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
// On some windows manager (Unity, XFCE), this dialog is
// not always raised, depending on this dialog is run.
// Force it to be raised
Raise();
}
void DIALOG_EDIT_LINE_STYLE::resetDefaults( wxCommandEvent& event )
{
SetStyle( defaultStyle );
SetWidth( defaultWidth );
SetColor( defaultColor );
Refresh();
}
void DIALOG_EDIT_LINE_STYLE::SetColor( const COLOR4D& aColor )
{
m_colorPicker->SetColour( aColor.ToColour() );
}
void DIALOG_EDIT_LINE_STYLE::SetStyle( const int aStyle )
{
switch( aStyle )
{
case wxPENSTYLE_SHORT_DASH:
m_lineStyle->SetSelection( 1 );
break;
case wxPENSTYLE_DOT:
m_lineStyle->SetSelection( 2 );
break;
case wxPENSTYLE_DOT_DASH:
m_lineStyle->SetSelection( 3 );
break;
default:
m_lineStyle->SetSelection( 0 );
break;
}
}
int DIALOG_EDIT_LINE_STYLE::GetStyle()
{
const int retval[4] =
{
wxPENSTYLE_SOLID,
wxPENSTYLE_SHORT_DASH,
wxPENSTYLE_DOT,
wxPENSTYLE_DOT_DASH,
};
return retval[ m_lineStyle->GetSelection() ];
}

View File

@ -0,0 +1,67 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Seth Hillbrand <hillbrand@ucdavis.edu>
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.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
*/
#ifndef __dialog_edit_line_style__
#define __dialog_edit_line_style__
/**
* @file
* Subclass of DIALOG_EDIT_LINE_STYLE_BASE, which is generated by wxFormBuilder.
*/
#include <dialog_edit_line_style_base.h>
#include <sch_line.h>
class DIALOG_EDIT_LINE_STYLE : public DIALOG_EDIT_LINE_STYLE_BASE
{
public:
DIALOG_EDIT_LINE_STYLE( wxWindow* parent );
void SetWidth( const wxString& aWidth ) { m_lineWidth->SetValue( aWidth ); }
void SetDefaultWidth( const wxString& aWidth ) { defaultWidth = aWidth; }
wxString GetWidth() const { return m_lineWidth->GetValue(); }
COLOR4D GetColor() const { return COLOR4D( m_colorPicker->GetColour() ); }
void SetColor( const COLOR4D& aColor );
void SetDefaultColor( const COLOR4D& aColor ) { defaultColor = aColor; }
void SetStyle( const int aStyle );
void SetDefaultStyle( const int aStyle ) { defaultStyle = aStyle; }
int GetStyle();
void SetLineWidthUnits(const wxString& aUnits)
{
m_staticWidthUnits->SetLabel( aUnits );
}
private:
int defaultStyle;
wxString defaultWidth;
COLOR4D defaultColor;
void resetDefaults( wxCommandEvent& event ) override;
};
#endif // __dialog_edit_line_style__

View File

@ -0,0 +1,111 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 9 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_edit_line_style_base.h"
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_EDIT_LINE_STYLE_BASE, DIALOG_SHIM )
EVT_BUTTON( wxID_APPLY, DIALOG_EDIT_LINE_STYLE_BASE::_wxFB_resetDefaults )
END_EVENT_TABLE()
DIALOG_EDIT_LINE_STYLE_BASE::DIALOG_EDIT_LINE_STYLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* dlgBorderSizer;
dlgBorderSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General") ), wxVERTICAL );
wxBoxSizer* bSizer31;
bSizer31 = new wxBoxSizer( wxHORIZONTAL );
m_staticWidth1 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidth1->Wrap( -1 );
bSizer31->Add( m_staticWidth1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_lineWidth = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !m_lineWidth->HasFlag( wxTE_MULTILINE ) )
{
m_lineWidth->SetMaxLength( 6 );
}
#else
m_lineWidth->SetMaxLength( 6 );
#endif
bSizer31->Add( m_lineWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticWidthUnits = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("millimeter"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticWidthUnits->Wrap( -1 );
bSizer31->Add( m_staticWidthUnits, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
sbSizer1->Add( bSizer31, 0, wxALL|wxEXPAND, 1 );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
m_staticText5 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("C&olor:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bSizer5->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_colorPicker = new wxColourPickerCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxColour( 0, 0, 0 ), wxDefaultPosition, wxDefaultSize, wxCLRP_DEFAULT_STYLE );
bSizer5->Add( m_colorPicker, 0, wxALL, 5 );
bSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
sbSizer1->Add( bSizer5, 0, wxEXPAND|wxALL, 1 );
bSizer7->Add( sbSizer1, 3, wxALL|wxEXPAND, 5 );
wxString m_lineStyleChoices[] = { _("Solid"), _("Dashed"), _("Dotted"), _("Dash-Dot") };
int m_lineStyleNChoices = sizeof( m_lineStyleChoices ) / sizeof( wxString );
m_lineStyle = new wxRadioBox( this, wxID_ANY, _("&Pen Style"), wxDefaultPosition, wxDefaultSize, m_lineStyleNChoices, m_lineStyleChoices, 4, wxRA_SPECIFY_ROWS );
m_lineStyle->SetSelection( 1 );
bSizer7->Add( m_lineStyle, 2, wxALL|wxEXPAND, 5 );
dlgBorderSizer->Add( bSizer7, 1, wxEXPAND, 5 );
dlgBorderSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 1 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY );
m_sdbSizer1->AddButton( m_sdbSizer1Apply );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
dlgBorderSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 );
mainSizer->Add( dlgBorderSizer, 1, wxALL|wxEXPAND, 12 );
this->SetSizer( mainSizer );
this->Layout();
this->Centre( wxBOTH );
}
DIALOG_EDIT_LINE_STYLE_BASE::~DIALOG_EDIT_LINE_STYLE_BASE()
{
}

View File

@ -0,0 +1,721 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="13" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">table</property>
<property name="file">dialog_edit_line_style_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">dialog_edit_line_style</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_EDIT_LINE_STYLE_BASE</property>
<property name="pos"></property>
<property name="size">399,230</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Line Style</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></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 class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">mainSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">12</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">dlgBorderSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer7</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">3</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">General</property>
<property name="minimum_size"></property>
<property name="name">sbSizer1</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="0">
<property name="border">1</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer31</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<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="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">&amp;Width:</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_staticWidth1</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></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 class="sizeritem" expanded="0">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<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="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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength">6</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_lineWidth</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">bool</property>
<property name="validator_style">wxFILTER_NUMERIC</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable">m_isValid</property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></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="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">1</property>
<object class="wxStaticText" expanded="0">
<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="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">millimeter</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_staticWidthUnits</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></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 class="sizeritem" expanded="1">
<property name="border">1</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer5</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<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="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">C&amp;olor:</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_staticText5</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">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></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 class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxColourPickerCtrl" expanded="0">
<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="close_button">1</property>
<property name="colour">0,0,0</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="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_colorPicker</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">wxCLRP_DEFAULT_STYLE</property>
<property name="subclass">; forward_declare</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="OnColourChanged"></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 class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">2</property>
<object class="wxRadioBox" expanded="0">
<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="choices">&quot;Solid&quot; &quot;Dashed&quot; &quot;Dotted&quot; &quot;Dash-Dot&quot;</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">&amp;Pen Style</property>
<property name="majorDimension">4</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_lineStyle</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="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_ROWS</property>
<property name="subclass">; forward_declare</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="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="OnRadioBox"></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 class="sizeritem" expanded="1">
<property name="border">1</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">1</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick">resetDefaults</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 9 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_LINE_STYLE_BASE_H__
#define __DIALOG_EDIT_LINE_STYLE_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/clrpicker.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_LINE_STYLE_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EDIT_LINE_STYLE_BASE : public DIALOG_SHIM
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_resetDefaults( wxCommandEvent& event ){ resetDefaults( event ); }
protected:
wxStaticText* m_staticWidth1;
wxTextCtrl* m_lineWidth;
wxStaticText* m_staticWidthUnits;
wxStaticText* m_staticText5;
wxColourPickerCtrl* m_colorPicker;
wxRadioBox* m_lineStyle;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Apply;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void resetDefaults( wxCommandEvent& event ) { event.Skip(); }
public:
bool m_isValid;
DIALOG_EDIT_LINE_STYLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Line Style"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 399,230 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EDIT_LINE_STYLE_BASE();
};
#endif //__DIALOG_EDIT_LINE_STYLE_BASE_H__

View File

@ -87,6 +87,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = {
SCH_SHEET_PIN_T,
SCH_SHEET_T,
SCH_BITMAP_T,
SCH_LINE_T,
EOT
};

View File

@ -1147,6 +1147,27 @@ SCH_LINE* SCH_LEGACY_PLUGIN::loadWire( FILE_LINE_READER& aReader )
end.x = parseInt( aReader, line, &line );
end.y = parseInt( aReader, line, &line );
if( !is_eol( *line ) )
{
int size = parseInt( aReader, line, &line );
wire->SetLineWidth( size );
}
if( !is_eol( *line ) )
{
int style = parseInt( aReader, line, &line );
wire->SetLineStyle( style );
}
if( !is_eol( *line ) )
{
double color[ 4 ] = { 0. };
for( int i = 0; i < 4 && !is_eol( *line ); i++ )
color[i] = parseDouble( aReader, line, &line );
wire->SetLineColor( color[0], color[1], color[2], color[3] );
}
wire->SetStartPoint( begin );
wire->SetEndPoint( end );
@ -1958,6 +1979,9 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine )
const char* layer = "Notes";
const char* width = "Line";
bool styled = aLine->GetPenSize() != aLine->GetDefaultWidth()
|| aLine->GetLineStyle() != aLine->GetDefaultStyle()
|| aLine->GetLineColor() != aLine->GetDefaultColor();
if( aLine->GetLayer() == LAYER_WIRE )
layer = "Wire";
@ -1965,8 +1989,15 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine )
layer = "Bus";
m_out->Print( 0, "Wire %s %s\n", layer, width );
m_out->Print( 0, "\t%-4d %-4d %-4d %-4d\n", aLine->GetStartPoint().x, aLine->GetStartPoint().y,
m_out->Print( 0, "\t%-4d %-4d %-4d %-4d", aLine->GetStartPoint().x, aLine->GetStartPoint().y,
aLine->GetEndPoint().x, aLine->GetEndPoint().y );
if( styled )
m_out->Print( 0, " %-4d %-4d %-.4f %-.4f %-.4f %-.4f",
aLine->GetLineSize(), aLine->GetLineStyle(),
aLine->GetLineColor().r, aLine->GetLineColor().g,
aLine->GetLineColor().b, aLine->GetLineColor().a );
m_out->Print( 0, "\n");
}

View File

@ -37,8 +37,10 @@
#include <general.h>
#include <protos.h>
#include <sch_line.h>
#include <schframe.h>
#include <class_netlist_object.h>
#include <dialogs/dialog_edit_line_style.h>
SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
SCH_ITEM( NULL, SCH_LINE_T )
@ -46,6 +48,9 @@ SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
m_start = pos;
m_end = pos;
m_startIsDangling = m_endIsDangling = false;
m_size = 0;
m_style = 0;
m_color = COLOR4D::UNSPECIFIED;
switch( layer )
{
@ -69,6 +74,9 @@ SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
{
m_start = aLine.m_start;
m_end = aLine.m_end;
m_size = aLine.m_size;
m_style = aLine.m_style;
m_color = aLine.m_color;
m_startIsDangling = m_endIsDangling = false;
}
@ -201,8 +209,93 @@ bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
COLOR4D SCH_LINE::GetDefaultColor() const
{
return GetLayerColor( m_Layer );
}
void SCH_LINE::SetLineColor( const COLOR4D aColor )
{
if( aColor == GetDefaultColor() )
m_color = COLOR4D::UNSPECIFIED;
else
m_color = aColor;
}
void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
{
COLOR4D newColor(r, g, b, a);
if( newColor == GetDefaultColor() )
m_color = COLOR4D::UNSPECIFIED;
else
m_color = newColor;
}
COLOR4D SCH_LINE::GetLineColor() const
{
if( m_color == COLOR4D::UNSPECIFIED )
return GetLayerColor( m_Layer );
return m_color;
}
enum wxPenStyle SCH_LINE::GetDefaultStyle() const
{
if( m_Layer == LAYER_NOTES )
return wxPENSTYLE_SHORT_DASH;
return wxPENSTYLE_SOLID;
}
void SCH_LINE::SetLineStyle( const int aStyle )
{
if( aStyle == GetDefaultStyle() )
m_style = 0;
else
m_style = aStyle;
}
enum wxPenStyle SCH_LINE::GetLineStyle() const
{
if( m_style > 0 )
return (enum wxPenStyle) m_style;
if( m_Layer == LAYER_NOTES )
return wxPENSTYLE_SHORT_DASH;
return wxPENSTYLE_SOLID;
}
int SCH_LINE::GetDefaultWidth() const
{
if( m_Layer == LAYER_BUS )
return GetDefaultBusThickness();
return GetDefaultLineThickness();
}
void SCH_LINE::SetLineWidth( const int aSize )
{
if( aSize == GetDefaultWidth() )
m_size = 0;
else
m_size = aSize;
}
int SCH_LINE::GetPenSize() const
{
if( m_size > 0 )
return m_size;
if( m_Layer == LAYER_BUS )
return GetDefaultBusThickness();
@ -219,6 +312,8 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
if( Color != COLOR4D::UNSPECIFIED )
color = Color;
else if( m_color != COLOR4D::UNSPECIFIED )
color = m_color;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@ -233,10 +328,7 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
if( ( m_Flags & ENDPOINT ) == 0 )
end += offset;
if( m_Layer == LAYER_NOTES )
GRDashedLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color );
else
GRLine( panel->GetClipBox(), DC, start, end, width, color );
GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color, GetLineStyle() );
if( m_startIsDangling )
DrawDanglingSymbol( panel, DC, start, color );
@ -567,6 +659,20 @@ bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
return rect.Intersects( m_start, m_end );
}
void SCH_LINE::SwapData( SCH_ITEM* aItem )
{
SCH_LINE* item = (SCH_LINE*) aItem;
std::swap( m_Layer, item->m_Layer );
std::swap( m_start, item->m_start );
std::swap( m_end, item->m_end );
std::swap( m_startIsDangling, item->m_startIsDangling );
std::swap( m_endIsDangling, item->m_endIsDangling );
std::swap( m_style, item->m_style );
std::swap( m_size, item->m_size );
std::swap( m_color, item->m_color );
}
bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
{
@ -604,3 +710,53 @@ wxPoint SCH_LINE::MidPoint()
{
return wxPoint( ( m_start.x + m_end.x ) / 2, ( m_start.y + m_end.y ) / 2 );
}
int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
{
if( aLine == NULL )
return wxID_CANCEL;
// We purposely disallow editing everything except graphic lines
if( aLine->GetLayer() != LAYER_NOTES )
return wxID_CANCEL;
DIALOG_EDIT_LINE_STYLE dlg( this );
wxString units = GetUnitsLabel( g_UserUnit );
int old_style = aLine->GetLineStyle();
int old_width = aLine->GetPenSize();
COLOR4D old_color = aLine->GetLineColor();
dlg.SetDefaultStyle( aLine->GetDefaultStyle() );
dlg.SetDefaultWidth( StringFromValue( g_UserUnit, aLine->GetDefaultWidth(), false ) );
dlg.SetDefaultColor( aLine->GetDefaultColor() );
dlg.SetWidth( StringFromValue( g_UserUnit, old_width, false ) );
dlg.SetStyle( old_style );
dlg.SetLineWidthUnits( units );
dlg.SetColor( old_color );
dlg.Layout();
dlg.Fit();
dlg.SetMinSize( dlg.GetSize() );
if( dlg.ShowModal() == wxID_CANCEL )
return wxID_CANCEL;
int new_width = std::max( 1, ValueFromString( dlg.GetWidth() ) );
int new_style = dlg.GetStyle();
COLOR4D new_color = dlg.GetColor();
if( new_width != old_width || new_style != old_style || new_color != old_color )
{
SaveCopyInUndoList( (SCH_ITEM*) aLine, UR_CHANGED );
aLine->SetLineWidth( new_width );
aLine->SetLineStyle( new_style );
aLine->SetLineColor( new_color );
OnModify();
if( aRedraw )
m_canvas->Refresh();
}
return wxID_OK;
}

View File

@ -45,6 +45,9 @@ class SCH_LINE : public SCH_ITEM
bool m_endIsDangling; ///< True if end point is not connected.
wxPoint m_start; ///< Line start point
wxPoint m_end; ///< Line end point
int m_size; ///< Line pensize
int m_style; ///< Line style
COLOR4D m_color; ///< Line color
public:
SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
@ -76,6 +79,26 @@ public:
void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
enum wxPenStyle GetDefaultStyle() const;
void SetLineStyle( const int aStyle );
enum wxPenStyle GetLineStyle() const;
void SetLineColor( const COLOR4D aColor );
void SetLineColor( const double r, const double g, const double b, const double a );
COLOR4D GetLineColor() const;
COLOR4D GetDefaultColor() const;
int GetDefaultWidth() const;
void SetLineWidth( const int aSize );
int GetLineSize() const { return m_size; }
const EDA_RECT GetBoundingBox() const override;
/**
@ -147,6 +170,8 @@ public:
EDA_ITEM* Clone() const override;
void SwapData( SCH_ITEM* aItem ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override;
#endif

View File

@ -1064,6 +1064,8 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
break;
case SCH_LINE_T: // These items have no param to edit
EditLine( (SCH_LINE*) item, true );
break;
case SCH_MARKER_T:
case SCH_JUNCTION_T:
case SCH_NO_CONNECT_T:

View File

@ -1039,6 +1039,16 @@ private:
/// Loads the cache library associated to the aFileName
bool LoadCacheLibrary( const wxString& aFileName );
private:
/**
* Function EditLine
* displays the dialog for editing the parameters of \a aLine.
* @param aLine The Line/Wire/Bus to edit.
* @param aRedraw = true to refresh the screen
* @return The user response from the edit dialog.
*/
int EditLine( SCH_LINE* aLine, bool aRedraw );
public:
/**
* Function EditSheet

View File

@ -112,13 +112,15 @@ void GRForceBlackPen( bool flagforce );
bool GetGRForceBlackPenState( void );
void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor );
wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2, int width, COLOR4D Color );
int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color );
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color );
void GRDottedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color );
void GRMoveTo( int x, int y );
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
int x, int y, int width, COLOR4D Color );