Commit 135a6274 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: enhanced Pin editor dialog.

parent 8e538ddd
#include "fctsys.h"
#include "macros.h"
#include "gr_basic.h"
#include "libeditframe.h"
#include "class_libentry.h"
#include "lib_pin.h"
#include "dialog_lib_edit_pin.h"
......@@ -7,17 +12,24 @@
wxPoint DIALOG_LIB_EDIT_PIN::s_LastPos( -1, -1 );
wxSize DIALOG_LIB_EDIT_PIN::s_LastSize;
DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent ) :
DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin ) :
DIALOG_LIB_EDIT_PIN_BASE( parent )
{
m_dummyPin = new LIB_PIN( *aPin );
m_panelShowPin->SetBackgroundColour( MakeColour( g_DrawBgColor ) );
/* Required to make escape key work correctly in wxGTK. */
SetFocus();
// Set tab order
m_textPinName-> MoveAfterInTabOrder(this);
m_textPadName-> MoveAfterInTabOrder(m_textPinName);
m_sdbSizerButtonsOK->SetDefault();
}
DIALOG_LIB_EDIT_PIN::~DIALOG_LIB_EDIT_PIN()
{
delete m_dummyPin;
}
void DIALOG_LIB_EDIT_PIN::SetLastSizeAndPosition()
{
if( s_LastPos.x != -1 )
......@@ -32,6 +44,37 @@ void DIALOG_LIB_EDIT_PIN::SetLastSizeAndPosition()
Center();
}
/*
* Draw (on m_panelShowPin) the pin currently edited
* accroding to current settings in dialog
*/
void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelShowPin );
wxSize dc_size = dc.GetSize();
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Calculate a suitable scale to fit the available draw area
EDA_RECT bBox = m_dummyPin->GetBoundingBox();
double xscale = (double) dc_size.x / bBox.GetWidth();
double yscale = (double) dc_size.y / bBox.GetHeight();
double scale = MIN( xscale, yscale );
// Give a 10% margin
scale *= 0.9;
dc.SetUserScale( scale, scale );
wxPoint offset = bBox.Centre();
NEGATE( offset.x );
NEGATE( offset.y );
GRResetPenAndBrush( &dc );
m_dummyPin->Draw( NULL, &dc, offset, -1, wxCOPY,
NULL, DefaultTransform );
event.Skip();
}
void DIALOG_LIB_EDIT_PIN::OnCloseDialog( wxCloseEvent& event )
{
// Save the dialog's position
......@@ -56,6 +99,26 @@ void DIALOG_LIB_EDIT_PIN::OnOKButtonClick( wxCommandEvent& event )
EndModal( wxID_OK );
}
// Called when a pin properties changes
void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
{
int units = ((LIB_EDIT_FRAME*)GetParent())->m_InternalUnits;
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize(), units );
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize(), units);
int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
int pinLength = ReturnValueFromString( g_UserUnit, GetLength(), units );
int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
m_dummyPin->SetName( GetName() );
m_dummyPin->SetNameTextSize( pinNameSize );
m_dummyPin->SetNumber( GetPadName() );
m_dummyPin->SetNumberTextSize( pinNumSize );
m_dummyPin->SetOrientation( pinOrient );
m_dummyPin->SetLength( pinLength );
m_dummyPin->SetShape( pinShape );
m_panelShowPin->Refresh();
}
void DIALOG_LIB_EDIT_PIN::SetOrientationList( const wxArrayString& list,
......
......@@ -13,17 +13,22 @@
/** Implementing DIALOG_LIB_EDIT_PIN_BASE */
class DIALOG_LIB_EDIT_PIN : public DIALOG_LIB_EDIT_PIN_BASE
{
static wxSize s_LastSize; ///< last position and size
static wxPoint s_LastPos;
static wxSize s_LastSize; ///< last position and size
static wxPoint s_LastPos;
LIB_PIN * m_dummyPin; // a working copy used to show changes
public:
/** Constructor */
DIALOG_LIB_EDIT_PIN( wxWindow* parent );
DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin );
~DIALOG_LIB_EDIT_PIN();
void SetLastSizeAndPosition();
void OnCloseDialog( wxCloseEvent& event );
void OnCancelButtonClick( wxCommandEvent& event );
void OnOKButtonClick( wxCommandEvent& event );
void OnPaintShowPanel( wxPaintEvent& event );
void OnPropertiesChange( wxCommandEvent& event );
void SetOrientationList( const wxArrayString& list, const char *** aBitmaps );
void SetOrientation( int orientation )
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -22,6 +22,8 @@ class wxBitmapComboBox;
#include <wx/combobox.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/statbox.h>
#include <wx/panel.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -33,60 +35,48 @@ class wxBitmapComboBox;
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIB_EDIT_PIN_BASE : public wxDialog
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnCloseDialog( wxCloseEvent& event ){ OnCloseDialog( event ); }
void _wxFB_OnCBpartSelection( wxCommandEvent& event ){ OnCBpartSelection( event ); }
void _wxFB_OnCancelButtonClick( wxCommandEvent& event ){ OnCancelButtonClick( event ); }
void _wxFB_OnOKButtonClick( wxCommandEvent& event ){ OnOKButtonClick( event ); }
protected:
enum
{
ID_M_TEXTPINNAME = 1000,
ID_M_TEXTPINNAMETEXTSIZE,
ID_M_STATICTEXTPADNAME,
ID_M_TEXTPADNAME,
ID_M_STATICTEXTNAMESIZE,
ID_M_TEXTPINNAMETEXTSIZE,
ID_M_STATICNAMETEXTSIZEUNITS,
ID_M_STATICTEXTPADNAMESIZE,
ID_M_TEXTPADNAMETEXTSIZE,
ID_M_STATICNUMBERTEXTSIZEUNITS,
ID_M_STATICTEXTPINLEN,
ID_M_TEXTLENGTH,
ID_M_STATICLENGTHUNITS,
};
wxStaticText* m_staticTextPinName;
wxTextCtrl* m_textPinName;
wxStaticText* m_staticTextNameSize;
wxTextCtrl* m_textPinNameTextSize;
wxStaticText* m_staticNameTextSizeUnits;
wxStaticText* m_staticTextPadName;
wxTextCtrl* m_textPadName;
wxStaticText* m_staticTextPadNameSize;
wxTextCtrl* m_textPadNameTextSize;
wxStaticText* m_staticNumberTextSizeUnits;
wxStaticText* m_staticTextOrient;
wxBitmapComboBox* m_choiceOrientation;
wxStaticText* m_staticTextPinLen;
wxTextCtrl* m_textLength;
wxStaticText* m_staticLengthUnits;
wxStaticText* m_staticTextEType;
wxBitmapComboBox* m_choiceElectricalType;
wxStaticText* m_staticTextGstyle;
wxBitmapComboBox* m_choiceStyle;
wxCheckBox* m_checkApplyToAllParts;
wxCheckBox* m_checkApplyToAllConversions;
wxCheckBox* m_checkShow;
wxStaticText* m_staticTextNameSize;
wxTextCtrl* m_textPinNameTextSize;
wxStaticText* m_staticNameTextSizeUnits;
wxStaticText* m_staticTextPadNameSize;
wxTextCtrl* m_textPadNameTextSize;
wxStaticText* m_staticNumberTextSizeUnits;
wxStaticText* m_staticTextPinLen;
wxTextCtrl* m_textLength;
wxStaticText* m_staticLengthUnits;
wxPanel* m_panelShowPin;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK;
......@@ -94,14 +84,16 @@ class DIALOG_LIB_EDIT_PIN_BASE : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); }
virtual void OnPropertiesChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCBpartSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 487,344 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 499,372 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIB_EDIT_PIN_BASE();
};
......
......@@ -319,7 +319,7 @@ void LIB_ARC::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_ARC::GetPenSize()
int LIB_ARC::GetPenSize() const
{
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......
......@@ -102,7 +102,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize( ) const;
/**
* See LIB_DRAW_ITEM::BeginEdit().
......
......@@ -236,7 +236,7 @@ void LIB_BEZIER::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_BEZIER::GetPenSize()
int LIB_BEZIER::GetPenSize() const
{
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......
......@@ -72,7 +72,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize( ) const;
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
......
......@@ -191,7 +191,7 @@ void LIB_CIRCLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_CIRCLE::GetPenSize()
int LIB_CIRCLE::GetPenSize() const
{
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......
......@@ -67,7 +67,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize( ) const;
virtual EDA_RECT GetBoundingBox() const;
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
......
......@@ -185,7 +185,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize() = 0;
virtual int GetPenSize() const = 0;
/**
* Write draw item object to \a aFile in "*.lib" format.
......
......@@ -272,7 +272,7 @@ bool LIB_FIELD::Load( char* line, wxString& errorMsg )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_FIELD::GetPenSize()
int LIB_FIELD::GetPenSize() const
{
return ( m_Thickness == 0 ) ? g_DrawDefaultLineThickness : m_Thickness;
}
......
......@@ -86,10 +86,10 @@ public:
void SetId( int aId ) { m_id = aId; }
/**
* Function GetPenSize virtual pure
* Function GetPenSize virtual
* @return the size of the "pen" that be used to draw or plot this item
*/
int GetPenSize( );
virtual int GetPenSize( ) const;
/**
* Writes field object out to a FILE in "*.lib" format.
......
This diff is collapsed.
......@@ -355,7 +355,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item.
*/
virtual int GetPenSize();
virtual int GetPenSize() const;
void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
int aOrientation, int aDrawMode, int aColor = -1 );
......
......@@ -233,7 +233,7 @@ void LIB_POLYLINE::AddPoint( const wxPoint& point )
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_POLYLINE::GetPenSize()
int LIB_POLYLINE::GetPenSize() const
{
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......
......@@ -86,7 +86,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize( ) const;
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
......
......@@ -166,7 +166,7 @@ void LIB_RECTANGLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFil
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_RECTANGLE::GetPenSize()
int LIB_RECTANGLE::GetPenSize() const
{
return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
}
......
......@@ -72,7 +72,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize( ) const;
virtual EDA_RECT GetBoundingBox() const;
......
......@@ -93,7 +93,7 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg )
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
if( cnt >= 8 ) // if quoted loadng failed, load as not quoted
{
m_Text = FROM_UTF8( buf );
......@@ -112,7 +112,7 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg )
errorMsg.Printf( _( "text only had %d parameters of the required 8" ), cnt );
return false;
}
/* Convert '~' to spaces (only if text is not quoted). */
m_Text = FROM_UTF8( buf );
m_Text.Replace( wxT( "~" ), wxT( " " ) );
......@@ -286,7 +286,7 @@ void LIB_TEXT::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int LIB_TEXT::GetPenSize( )
int LIB_TEXT::GetPenSize( ) const
{
int pensize = m_Thickness;
......
......@@ -94,7 +94,7 @@ public:
/**
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize( ) const;
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
......
......@@ -46,7 +46,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
int item_flags = m_drawItem->m_Flags; // save flags to restore them after editing
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
DIALOG_LIB_EDIT_PIN dlg( this );
DIALOG_LIB_EDIT_PIN dlg( this, pin );
wxString units = GetUnitsLabel( g_UserUnit );
dlg.SetOrientationList( LIB_PIN::GetOrientationNames(), LIB_PIN::GetOrientationSymbols() );
......
......@@ -5,6 +5,7 @@
#include "fctsys.h"
#include "common.h"
#include "gr_basic.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
......@@ -133,6 +134,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
scale *= 0.7;
dc.SetUserScale( scale, scale );
GRResetPenAndBrush( &dc );
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
event.Skip();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment