Commit df487255 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Restore library editor value field rename behaviour and other minor fixes.

parent 6886e50d
...@@ -4,6 +4,19 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,19 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-dec-02 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
* Move color configuration dialog to dialogs folder.
* Simplify color configuration dialog design, remove enable grid checkbox( I
think we have enough places to do this), and remove abbreviated labels.
* Restore changing value field behavior to create new component from the
current one and handle all of the potential library naming conflict issues.
* Create a toolbar button perform the same function as renaming the value
field for improved usability.
* Add new copy component bitmap contributed by Jean-Pierre Charras.
2010-dec-02, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2010-dec-02, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
Pcbnew: Pcbnew:
...@@ -24,6 +37,7 @@ Gerbview: ...@@ -24,6 +37,7 @@ Gerbview:
On the other hand, Gerber doc is not clear about the meaning of A and B scale. On the other hand, Gerber doc is not clear about the meaning of A and B scale.
(Alas! Gerber doc is not clear about most of advanced commands) (Alas! Gerber doc is not clear about most of advanced commands)
2010-nov-19 UPDATE Wayne Stambaugh <stambaughw@verizon.net> 2010-nov-19 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================ ================================================================================
++EESchema ++EESchema
......
...@@ -64,6 +64,7 @@ set(BITMAP_SRCS ...@@ -64,6 +64,7 @@ set(BITMAP_SRCS
component_select_alternate_shape.xpm component_select_alternate_shape.xpm
config.xpm config.xpm
CopyBlock.xpm CopyBlock.xpm
copyComponent.xmp
copy.xpm copy.xpm
copper_layers_setup.cpp copper_layers_setup.cpp
Cursor_Shape.xpm Cursor_Shape.xpm
......
/* XPM */
const char *copyComponent_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 16 1",
"& c #080685",
"; c #CE3338",
". c #098409",
"+ c #ABAAAA",
": c #D44751",
"* c #885684",
"$ c #9794D7",
"@ c #BFB7ED",
"- c #640650",
" c None",
"= c #F80B0C",
"O c #ECECFC",
"# c #7F6CB6",
"% c #D3CFF7",
"o c #147A04",
"X c #4E9C54",
/* pixels */
" .......X ",
" oOOOOO X.+ ",
"oo.OO@#$@%XX ",
" +oOO$&&&$+.+ ",
" oOO$&&&&@ooo+ ",
" .O%%@$&&*.++++",
" .%====-&-;+ ",
".oo@=O%@#&&*=+ ",
"++===O#&&&&&&: ",
" +=OO#&&&&#=++",
" + =OO%#&&$@===",
" =O%%%#$%#=++",
" +=%O%%%@%;;+ ",
" ===@@@@@$:=++ ",
" ++=======;++ ",
" ++++++++ "
};
...@@ -27,6 +27,7 @@ set(EESCHEMA_SRCS ...@@ -27,6 +27,7 @@ set(EESCHEMA_SRCS
database.cpp database.cpp
delete.cpp delete.cpp
delsheet.cpp delsheet.cpp
dialogs/dialog_color_config.cpp
dialogs/dialog_plot_schematic_DXF.cpp dialogs/dialog_plot_schematic_DXF.cpp
dialogs/dialog_plot_schematic_DXF_base.cpp dialogs/dialog_plot_schematic_DXF_base.cpp
dialogs/dialog_plot_schematic_HPGL.cpp dialogs/dialog_plot_schematic_HPGL.cpp
...@@ -73,7 +74,6 @@ set(EESCHEMA_SRCS ...@@ -73,7 +74,6 @@ set(EESCHEMA_SRCS
dialogs/dialog_SVG_print_base.cpp dialogs/dialog_SVG_print_base.cpp
edit_component_in_schematic.cpp edit_component_in_schematic.cpp
edit_label.cpp edit_label.cpp
eelayer.cpp
eelibs_read_libraryfiles.cpp eelibs_read_libraryfiles.cpp
eeredraw.cpp eeredraw.cpp
eeschema.cpp eeschema.cpp
......
...@@ -1597,6 +1597,14 @@ LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias ) ...@@ -1597,6 +1597,14 @@ LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias )
} }
void LIB_COMPONENT::RemoveAllAliases()
{
// Remove all of the aliases except the root alias.
while( m_aliases.size() > 1 )
m_aliases.pop_back();
}
LIB_ALIAS* LIB_COMPONENT::GetAlias( const wxString& aName ) LIB_ALIAS* LIB_COMPONENT::GetAlias( const wxString& aName )
{ {
wxCHECK2_MSG( !aName.IsEmpty(), return NULL, wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
...@@ -1619,3 +1627,13 @@ LIB_ALIAS* LIB_COMPONENT::GetAlias( size_t aIndex ) ...@@ -1619,3 +1627,13 @@ LIB_ALIAS* LIB_COMPONENT::GetAlias( size_t aIndex )
return m_aliases[aIndex]; return m_aliases[aIndex];
} }
void LIB_COMPONENT::AddAlias( const wxString& aName )
{
wxCHECK_RET( !HasAlias( aName ),
wxT( "Component <" ) + GetName() + wxT( "> already has an alias <" ) +
aName + wxT( ">. Bad programmer." ) );
m_aliases.push_back( new LIB_ALIAS( aName, this ) );
}
...@@ -201,6 +201,18 @@ public: ...@@ -201,6 +201,18 @@ public:
LIB_ALIAS* GetAlias( const wxString& aName ); LIB_ALIAS* GetAlias( const wxString& aName );
/**
* Function AddAlias
*
* Add an alias \a aName to the component.
*
* Duplicate alias names are not added to the alias list. Debug builds will raise an
* assertion. Release builds will fail silenetly.
*
* @param aName - Name of alias to add.
*/
void AddAlias( const wxString& aName );
/** /**
* Test if alias \a aName is in component alias list. * Test if alias \a aName is in component alias list.
* *
...@@ -217,6 +229,8 @@ public: ...@@ -217,6 +229,8 @@ public:
LIB_ALIAS* RemoveAlias( LIB_ALIAS* aAlias ); LIB_ALIAS* RemoveAlias( LIB_ALIAS* aAlias );
void RemoveAllAliases();
wxArrayString& GetFootPrints() { return m_FootprintList; } wxArrayString& GetFootPrints() { return m_FootprintList; }
EDA_Rect GetBoundaryBox( int aUnit, int aConvert ); EDA_Rect GetBoundaryBox( int aUnit, int aConvert );
......
This diff is collapsed.
#ifndef _DIALOG_COLOR_CONFIG_H_
#define _DIALOG_COLOR_CONFIG_H_
#include "wx/statline.h"
class wxBoxSizer;
class wxStaticLine;
class wxStdDialogButtonSizer;
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 16;
const int BUTT_SIZE_Y = 16;
/********************/
/* Layer menu list. */
/********************/
struct ColorButton
{
wxString m_Name;
int m_Layer;
};
struct ButtonIndex
{
wxString m_Name;
ColorButton* m_Buttons;
};
/***********************************************/
/* Derived class for the frame color settings. */
/***********************************************/
class DIALOG_COLOR_CONFIG: public wxDialog
{
private:
DECLARE_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG )
WinEDA_DrawFrame* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxBoxSizer* ColumnBoxSizer;
wxBoxSizer* RowBoxSizer;
wxBitmapButton* BitmapButton;
wxRadioBox* m_SelBgColor;
wxStaticLine* Line;
wxStdDialogButtonSizer* StdDialogButtonSizer;
wxButton* Button;
// Creation
bool Create( wxWindow* aParent,
wxWindowID aId = wxID_ANY,
const wxString& aCaption = _( "EESchema Colors" ),
const wxPoint& aPosition = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize,
long aStyle = wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER );
// Initializes member variables
void Init();
// Creates the controls and sizers
void CreateControls();
wxBitmap GetBitmapResource( const wxString& aName );
wxIcon GetIconResource( const wxString& aName );
static bool ShowToolTips();
void UpdateLayerSettings();
void SetColor( wxCommandEvent& aEvent );
void OnOkClick( wxCommandEvent& aEvent );
void OnCancelClick( wxCommandEvent& aEvent );
void OnApplyClick( wxCommandEvent& aEvent );
public:
// Constructors and destructor
DIALOG_COLOR_CONFIG();
DIALOG_COLOR_CONFIG( WinEDA_DrawFrame* aParent );
~DIALOG_COLOR_CONFIG();
};
#endif // _DIALOG_COLOR_CONFIG_H_
This diff is collapsed.
/*************/
/* eelayer.h */
/*************/
#ifndef _EELAYER_H_
#define _EELAYER_H_
#include "wx/statline.h"
#include "general.h"
class wxBoxSizer;
class wxStaticLine;
class wxStdDialogButtonSizer;
// Specify how many elements are contained within laytool_list[]
const int NB_BUTT = 23; // Includes an element associated with the grid
// Specify how many elements are contained within laytool_index[]
const int BUTTON_GROUPS = 5;
// Specify the numbers associated with assorted controls
enum col_sel_id {
ID_DIALOG = 1800,
ID_CHECKBOX_SHOW_GRID,
ID_RADIOBOX_BACKGROUND_COLOR,
ID_COLOR_SETUP
};
// #define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_TITLE _("EESchema Colors")
#define SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME ID_DIALOG
// #define SYMBOL_WINEDA_SETCOLORSFRAME_SIZE wxSize(400, 300)
// #define SYMBOL_WINEDA_SETCOLORSFRAME_POSITION wxDefaultPosition
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 16;
const int BUTT_SIZE_Y = 16;
// Macro utile :
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])
/********************/
/* Layer menu list. */
/********************/
struct ColorButton
{
wxString m_Name;
int* m_Color;
int m_Id;
wxBitmapButton* m_Button;
};
struct ButtonIndex
{
wxString m_Name; // Title
int m_Index; // Index to last bitmap button in group
};
static ColorButton Layer_Wire_Item =
{
_( "Wire" ), // Title
ADR( LAYER_WIRE ) // Adr of optional parameter
};
static ColorButton Layer_Bus_Item =
{
_( "Bus" ), // Title
ADR( LAYER_BUS ) // Adr of optional parameter
};
static ColorButton Layer_Junction_Item =
{
_( "Junction" ), // Title
ADR( LAYER_JUNCTION ) // Adr of optional parameter
};
static ColorButton Layer_LocalLabel_Item =
{
_( "Label" ), // Title
ADR( LAYER_LOCLABEL ) // Adr of optional parameter
};
static ColorButton Layer_GlobLabel_Item =
{
_( "GlobLabel" ), // Title
ADR( LAYER_GLOBLABEL ) // Adr of optional parameter
};
static ColorButton Layer_NetNam_Item =
{
_( "Netname" ), // Title
ADR( LAYER_NETNAM ) // Adr of optional parameter
};
static ColorButton Layer_Notes_Item =
{
_( "Notes" ), // Title
ADR( LAYER_NOTES ) // Adr of optional parameter
};
static ColorButton Layer_NoConnect_Item =
{
_( "NoConn" ), // Title
ADR( LAYER_NOCONNECT ) // Adr of optional parameter
};
static ColorButton Layer_BodyDevice_Item =
{
_( "Body" ), // Title
ADR( LAYER_DEVICE ) // Adr of optional parameter
};
static ColorButton Layer_BodyBackgroundDevice_Item =
{
_( "Body Bg" ), // Title
ADR( LAYER_DEVICE_BACKGROUND ) // Adr of optional parameter
};
static ColorButton Layer_Pin_Item =
{
_( "Pin" ), // Title
ADR( LAYER_PIN ) // Adr of optional parameter
};
static ColorButton Layer_PinNum_Item =
{
_( "PinNum" ), // Title
ADR( LAYER_PINNUM ) // Adr of optional parameter
};
static ColorButton Layer_PinNam_Item =
{
_( "PinNam" ), // Title
ADR( LAYER_PINNAM ) // Adr of optional parameter
};
static ColorButton Layer_Reference_Item =
{
_( "Reference" ), // Title
ADR( LAYER_REFERENCEPART ) // Adr of optional parameter
};
static ColorButton Layer_Value_Item =
{
_( "Value" ), // Title
ADR( LAYER_VALUEPART ) // Adr of optional parameter
};
static ColorButton Layer_Fields_Item =
{
_( "Fields" ), // Title
ADR( LAYER_FIELDS ) // Adr of optional parameter
};
static ColorButton Layer_Sheet_Item =
{
_( "Sheet" ), // Title
ADR( LAYER_SHEET ) // Adr of optional parameter
};
static ColorButton Layer_SheetFileName_Item =
{
_( "Sheetfile" ), // Title
ADR( LAYER_SHEETFILENAME ) // Adr of optional parameter
};
static ColorButton Layer_SheetName_Item =
{
_( "SheetName" ), // Title
ADR( LAYER_SHEETNAME ) // Adr of optional parameter
};
static ColorButton Layer_SheetLabel_Item =
{
_( "SheetLabel (Pin Sheet)" ), // Title
ADR( LAYER_SHEETLABEL ) // Adr of optional parameter
};
static ColorButton Layer_HierarchicalLabel_Item =
{
_( "Hierarchical Label" ), // Title
ADR( LAYER_HIERLABEL ) // Adr of optional parameter
};
static ColorButton Layer_Erc_Warning_Item =
{
_( "Erc Warning" ), // Title
ADR( LAYER_ERC_WARN ) // Adr of optional parameter
};
static ColorButton Layer_Erc_Error_Item =
{
_( "Erc Error" ), // Title
ADR( LAYER_ERC_ERR ) // Adr of optional parameter
};
static ColorButton* laytool_list[NB_BUTT] = {
&Layer_Wire_Item,
&Layer_Bus_Item,
&Layer_Junction_Item,
&Layer_LocalLabel_Item,
&Layer_GlobLabel_Item,
&Layer_NetNam_Item,
&Layer_Notes_Item,
&Layer_NoConnect_Item,
&Layer_BodyDevice_Item,
&Layer_BodyBackgroundDevice_Item,
&Layer_Pin_Item,
&Layer_PinNum_Item,
&Layer_PinNam_Item,
&Layer_Reference_Item,
&Layer_Value_Item,
&Layer_Fields_Item,
&Layer_Sheet_Item,
&Layer_SheetFileName_Item,
&Layer_SheetName_Item,
&Layer_SheetLabel_Item,
&Layer_HierarchicalLabel_Item,
&Layer_Erc_Warning_Item,
&Layer_Erc_Error_Item,
};
static ButtonIndex Msg_General =
{
_( "General" ), // Title
7 // Index to first bitmap button in group
};
static ButtonIndex MsgDevice_Item =
{
_( "Device" ), // Title
15 // Index to first bitmap button in group
};
static ButtonIndex Msg_Sheets =
{
_( "Sheets" ), // Title
20 // Index to first bitmap button in group
};
static ButtonIndex Msg_ErcMarck =
{
_( "Erc Mark" ), // Title
22 // Index to first bitmap button in group
};
static ButtonIndex Msg_Other =
{
_( "Other" ), // Title
23 // Index to first bitmap button in group
};
static ButtonIndex* laytool_index[BUTTON_GROUPS] = {
&Msg_General,
&MsgDevice_Item,
&Msg_Sheets,
&Msg_ErcMarck,
&Msg_Other
};
/***********************************************/
/* Derived class for the frame color settings. */
/***********************************************/
class WinEDA_SetColorsFrame: public wxDialog
{
private:
DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame )
DECLARE_EVENT_TABLE()
WinEDA_DrawFrame* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxBoxSizer* ColumnBoxSizer;
wxBoxSizer* RowBoxSizer;
wxStaticText* Label;
wxBitmapButton* BitmapButton;
wxCheckBox* m_ShowGrid;
wxRadioBox* m_SelBgColor;
wxStaticLine* Line;
wxStdDialogButtonSizer* StdDialogButtonSizer;
wxButton* Button;
// Creation
bool Create( wxWindow* parent,
wxWindowID id = SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
// Initializes member variables
void Init();
// Creates the controls and sizers
void CreateControls();
wxBitmap GetBitmapResource( const wxString& name );
wxIcon GetIconResource( const wxString& name );
static bool ShowToolTips();
void UpdateLayerSettings();
void SetColor( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnApplyClick( wxCommandEvent& event );
public:
// Constructors and destructor
WinEDA_SetColorsFrame();
WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos );
~WinEDA_SetColorsFrame();
};
#endif // _EELAYER_H_
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "dialog_hotkeys_editor.h" #include "dialog_hotkeys_editor.h"
#include "dialogs/dialog_color_config.h"
#include "dialogs/dialog_eeschema_config.h" #include "dialogs/dialog_eeschema_config.h"
#include "dialogs/dialog_eeschema_options.h" #include "dialogs/dialog_eeschema_options.h"
...@@ -41,23 +42,22 @@ void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event ) ...@@ -41,23 +42,22 @@ void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
} }
void LIB_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
{
DIALOG_COLOR_CONFIG dlg( this );
dlg.ShowModal();
}
void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos;
wxFileName fn; wxFileName fn;
WinEDA_SchematicFrame * schFrame = ( WinEDA_SchematicFrame * ) GetParent(); WinEDA_SchematicFrame * schFrame = ( WinEDA_SchematicFrame * ) GetParent();
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 5;
switch( id ) switch( id )
{ {
case ID_COLORS_SETUP:
DisplayColorSetupFrame( this, pos );
break;
case ID_CONFIG_SAVE: case ID_CONFIG_SAVE:
schFrame->SaveProjectFile( this, false ); schFrame->SaveProjectFile( this, false );
break; break;
...@@ -103,6 +103,14 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -103,6 +103,14 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
} }
void WinEDA_SchematicFrame::OnColorConfig( wxCommandEvent& aEvent )
{
DIALOG_COLOR_CONFIG dlg( this );
dlg.ShowModal();
}
void WinEDA_SchematicFrame::InstallConfigFrame( wxCommandEvent& event ) void WinEDA_SchematicFrame::InstallConfigFrame( wxCommandEvent& event )
{ {
DIALOG_EESCHEMA_CONFIG CfgFrame( this, this ); DIALOG_EESCHEMA_CONFIG CfgFrame( this, this );
...@@ -114,19 +122,10 @@ void WinEDA_SchematicFrame::InstallConfigFrame( wxCommandEvent& event ) ...@@ -114,19 +122,10 @@ void WinEDA_SchematicFrame::InstallConfigFrame( wxCommandEvent& event )
void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos;
wxFileName fn; wxFileName fn;
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 5;
switch( id ) switch( id )
{ {
case ID_COLORS_SETUP:
DisplayColorSetupFrame( this, pos );
break;
case ID_CONFIG_SAVE: case ID_CONFIG_SAVE:
SaveProjectFile( this, false ); SaveProjectFile( this, false );
break; break;
......
...@@ -136,6 +136,7 @@ enum id_eeschema_frm ...@@ -136,6 +136,7 @@ enum id_eeschema_frm
ID_LIBEDIT_SAVE_CURRENT_LIB, ID_LIBEDIT_SAVE_CURRENT_LIB,
ID_LIBEDIT_SAVE_CURRENT_PART, ID_LIBEDIT_SAVE_CURRENT_PART,
ID_LIBEDIT_NEW_PART, ID_LIBEDIT_NEW_PART,
ID_LIBEDIT_NEW_PART_FROM_EXISTING,
ID_LIBEDIT_GET_FRAME_EDIT_PART, ID_LIBEDIT_GET_FRAME_EDIT_PART,
ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
ID_LIBEDIT_DELETE_PART, ID_LIBEDIT_DELETE_PART,
......
...@@ -93,6 +93,7 @@ typedef enum ...@@ -93,6 +93,7 @@ typedef enum
LAYER_ERC_WARN, LAYER_ERC_WARN,
LAYER_ERC_ERR, LAYER_ERC_ERR,
LAYER_DEVICE_BACKGROUND, LAYER_DEVICE_BACKGROUND,
LAYER_GRID,
MAX_LAYER /* Maximum layers */ MAX_LAYER /* Maximum layers */
} LayerNumber; } LayerNumber;
......
...@@ -157,7 +157,6 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib ...@@ -157,7 +157,6 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
{ {
SAFE_DELETE( m_component ); SAFE_DELETE( m_component );
m_aliasName.Empty(); m_aliasName.Empty();
m_oldRootName.Empty();
} }
m_component = new LIB_COMPONENT( *component ); m_component = new LIB_COMPONENT( *component );
...@@ -171,7 +170,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib ...@@ -171,7 +170,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
return false; return false;
} }
m_oldRootName = m_aliasName = aEntry->GetName(); m_aliasName = aEntry->GetName();
m_unit = 1; m_unit = 1;
m_convert = 1; m_convert = 1;
...@@ -454,7 +453,6 @@ All changes will be lost. Discard changes?" ) ) ) ...@@ -454,7 +453,6 @@ All changes will be lost. Discard changes?" ) ) )
{ {
SAFE_DELETE( m_component ); SAFE_DELETE( m_component );
m_aliasName.Empty(); m_aliasName.Empty();
m_oldRootName.Empty();
} }
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -510,7 +508,6 @@ lost!\n\nClear the current component from the screen?" ) ) ) ...@@ -510,7 +508,6 @@ lost!\n\nClear the current component from the screen?" ) ) )
return; return;
} }
m_oldRootName.Empty();
LIB_COMPONENT* component = new LIB_COMPONENT( name ); LIB_COMPONENT* component = new LIB_COMPONENT( name );
component->GetReferenceField().m_Text = dlg.GetReference(); component->GetReferenceField().m_Text = dlg.GetReference();
component->SetPartCount( dlg.GetPartCount() ); component->SetPartCount( dlg.GetPartCount() );
...@@ -575,7 +572,6 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory() ...@@ -575,7 +572,6 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory()
LIB_COMPONENT* oldComponent; LIB_COMPONENT* oldComponent;
LIB_COMPONENT* Component; LIB_COMPONENT* Component;
wxString msg; wxString msg;
wxString rootName;
if( m_component == NULL ) if( m_component == NULL )
{ {
...@@ -594,18 +590,12 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory() ...@@ -594,18 +590,12 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory()
GetBaseScreen()->ClrModify(); GetBaseScreen()->ClrModify();
// If the component root name was changed, that is still the name of the component oldComponent = m_library->FindComponent( m_component->GetName() );
// in the library.
if( !m_oldRootName.IsEmpty() && m_oldRootName != m_component->GetName() )
rootName = m_oldRootName;
else
rootName = m_component->GetName();
oldComponent = m_library->FindComponent( rootName );
if( oldComponent != NULL ) if( oldComponent != NULL )
{ {
msg.Printf( _( "Component \"%s\" exists. Change it?" ), GetChars( rootName ) ); msg.Printf( _( "Component \"%s\" already exists. Change it?" ),
GetChars( m_component->GetName() ) );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
......
...@@ -85,6 +85,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame ) ...@@ -85,6 +85,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame )
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart ) EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::CreateNewLibraryPart ) EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::CreateNewLibraryPart )
EVT_TOOL( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnCreateNewPartFromExisting )
EVT_TOOL( ID_LIBEDIT_SELECT_PART, LIB_EDIT_FRAME::LoadOneLibraryPart ) EVT_TOOL( ID_LIBEDIT_SELECT_PART, LIB_EDIT_FRAME::LoadOneLibraryPart )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList ) EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList )
...@@ -115,6 +117,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame ) ...@@ -115,6 +117,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame )
EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp ) EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::OnColorConfig )
EVT_MENU( ID_CONFIG_REQ, LIB_EDIT_FRAME::InstallConfigFrame ) EVT_MENU( ID_CONFIG_REQ, LIB_EDIT_FRAME::InstallConfigFrame )
EVT_MENU( ID_CONFIG_SAVE, LIB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_SAVE, LIB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_CONFIG_READ, LIB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_READ, LIB_EDIT_FRAME::Process_Config )
...@@ -145,6 +148,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame ) ...@@ -145,6 +148,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo ) EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo )
EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo ) EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib )
...@@ -1058,3 +1062,16 @@ void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event ) ...@@ -1058,3 +1062,16 @@ void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event )
DIALOG_LIBEDIT_DIMENSIONS dlg( this ); DIALOG_LIBEDIT_DIMENSIONS dlg( this );
dlg.ShowModal(); dlg.ShowModal();
} }
void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
{
wxCHECK_RET( m_component != NULL,
wxT( "Cannot create new part from non-existant current part." ) );
INSTALL_DC( dc, DrawPanel );
DrawPanel->CursorOff( &dc );
EditField( &dc, &m_component->GetValueField() );
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( &dc );
}
...@@ -26,9 +26,6 @@ class DIALOG_LIB_EDIT_TEXT; ...@@ -26,9 +26,6 @@ class DIALOG_LIB_EDIT_TEXT;
class LIB_EDIT_FRAME : public WinEDA_DrawFrame class LIB_EDIT_FRAME : public WinEDA_DrawFrame
{ {
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
wxString m_oldRootName; ///< The actual pointer of the component loaded from
///< a library. Do not do anything with this pointer.
///< It is to be used for reference purposes only.
public: public:
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any) WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
...@@ -58,6 +55,7 @@ public: ...@@ -58,6 +55,7 @@ public:
void InstallConfigFrame( wxCommandEvent& event ); void InstallConfigFrame( wxCommandEvent& event );
void InstallDimensionsDialog( wxCommandEvent& event ); void InstallDimensionsDialog( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
void OnPlotCurrentComponent( wxCommandEvent& event ); void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
...@@ -67,6 +65,7 @@ public: ...@@ -67,6 +65,7 @@ public:
void OnSelectPart( wxCommandEvent& event ); void OnSelectPart( wxCommandEvent& event );
void DeleteOnePart( wxCommandEvent& event ); void DeleteOnePart( wxCommandEvent& event );
void CreateNewLibraryPart( wxCommandEvent& event ); void CreateNewLibraryPart( wxCommandEvent& event );
void OnCreateNewPartFromExisting( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event ); void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event ); void InstallFieldsEditorDialog( wxCommandEvent& event );
void LoadOneLibraryPart( wxCommandEvent& event ); void LoadOneLibraryPart( wxCommandEvent& event );
......
...@@ -16,77 +16,136 @@ ...@@ -16,77 +16,136 @@
#include "template_fieldnames.h" #include "template_fieldnames.h"
void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* Field ) void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField )
{ {
wxString Text; wxString text;
wxString title; wxString title;
wxString caption;
wxString oldName; wxString oldName;
if( Field == NULL ) if( aField == NULL )
return; return;
title = Field->GetName(); LIB_COMPONENT* parent = aField->GetParent();
Text = Field->m_Text;
wxTextEntryDialog dlg( this, title + wxT( ":" ), _( "Edit field" ), Text ); // Editing the component value field is equivalent to creating a new component based
// on the current component. Set the dialog message to inform the user.
if( aField->m_FieldId == VALUE )
{
caption = _( "Component Name" );
title = _( "Enter a name to create a new component based on this one." );
}
else
{
caption = _( "Edit Field" );
title.Printf( _( "Enter a new value for the %s field." ),
GetChars( aField->GetName().Lower() ) );
}
if( dlg.ShowModal() != wxID_OK || dlg.GetValue() == Text ) wxTextEntryDialog dlg( this, title, caption, aField->m_Text );
if( dlg.ShowModal() != wxID_OK || dlg.GetValue() == aField->m_Text )
return; return;
Text = dlg.GetValue(); text = dlg.GetValue();
Text.Replace( wxT( " " ), wxT( "_" ) ); text.Replace( wxT( " " ), wxT( "_" ) );
if( ( Field->m_FieldId == REFERENCE || Field->m_FieldId == VALUE ) && Text.IsEmpty ( ) ) if( ( aField->m_FieldId == REFERENCE || aField->m_FieldId == VALUE ) && text.IsEmpty ( ) )
{ {
DisplayError( this, title + _( " field cannot be empty." ) ); title.Printf( _( "A %s field cannot be empty." ), GetChars(aField->GetName().Lower() ) );
DisplayError( this, title );
return; return;
} }
wxString fieldText = Field->GetFullText( m_unit ); wxString fieldText = aField->GetFullText( m_unit );
LIB_COMPONENT* parent = Field->GetParent();
/* If the value field is changed, this is equivalent to creating a new /* If the value field is changed, this is equivalent to creating a new component from
* component from the old one. Check for an existing library entry of * the old one. Rename the component and remove any conflicting aliases to prevent name
* this "new" component and change the value only if there is no existing * errors when updating the library.
* entry with the same name.
*/ */
if( Field->m_FieldId == VALUE && Text != Field->m_Text ) if( aField->m_FieldId == VALUE )
{ {
wxString msg; wxString msg;
/* Test for an existing name in the current components alias list and in // Test the current library for name conflicts.
* the current library. if( m_library->FindEntry( text ) != NULL )
*/ {
if( ( parent->HasAlias( Text ) && !parent->GetAlias( Text )->IsRoot() ) msg.Printf( _( "The name <%s> conflicts with an existing entry in the component \
|| ( m_library && m_library->FindEntry( Text ) != NULL ) ) library <%s>.\n\nDo you wish to replace the current component in library with this one?" ),
GetChars( text ),
GetChars( m_library->GetName() ) );
int rsp = wxMessageBox( msg, _( "Confirm" ),
wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT, this );
if( rsp == wxNO )
return;
}
// Test the current component for name conflicts.
if( parent->HasAlias( text ) )
{
msg.Printf( _( "The current component already has an alias named <%s>.\n\nDo you \
wish to remove this alias from the component?" ),
GetChars( text ),
GetChars( m_library->GetName() ) );
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
if( rsp == wxNO )
return;
parent->RemoveAlias( text );
}
parent->SetName( text );
// Test the library for any conflicts with the any aliases in the current component.
if( parent->GetAliasCount() > 1 && m_library->Conflicts( parent ) )
{ {
msg.Printf( _( "The field name <%s> conflicts with an existing \ msg.Printf( _( "The new component contains alias names that conflict with entries \
entry in the component library <%s>.\nPlease choose another name that does \ in the component library <%s>.\n\nDo you wish to remove all of the conflicting aliases from \
not conflict with any library entries." ), this component?" ),
GetChars( Text ),
GetChars( m_library->GetName() ) ); GetChars( m_library->GetName() ) );
DisplayError( this, msg );
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
if( rsp == wxNO )
{
parent->SetName( fieldText );
return; return;
} }
wxArrayString aliases = parent->GetAliasNames( false );
for( size_t i = 0; i < aliases.GetCount(); i++ )
{
if( m_library->FindEntry( aliases[ i ] ) != NULL )
parent->RemoveAlias( aliases[ i ] );
}
} }
if( Field->m_FieldId == VALUE && Field->m_Text == m_aliasName ) if( !parent->HasAlias( m_aliasName ) )
m_aliasName = Text; m_aliasName = text;
}
else
{
aField->SetText( text );
}
if( !Field->InEditMode() ) if( !aField->InEditMode() )
{ {
SaveCopyInUndoList( parent ); SaveCopyInUndoList( parent );
( (LIB_DRAW_ITEM*) Field )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, ( (LIB_DRAW_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform ); &fieldText, DefaultTransform );
} }
Field->SetText( Text );
if( !Field->InEditMode() ) if( !aField->InEditMode() )
{ {
fieldText = Field->GetFullText( m_unit ); fieldText = aField->GetFullText( m_unit );
( (LIB_DRAW_ITEM*) Field )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, ( (LIB_DRAW_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform ); &fieldText, DefaultTransform );
} }
......
...@@ -188,7 +188,6 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, ...@@ -188,7 +188,6 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel,
/**************/ /**************/
void SeedLayers(); void SeedLayers();
EDA_Colors ReturnLayerColor( int Layer ); EDA_Colors ReturnLayerColor( int Layer );
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, const wxPoint& pos );
/**************/ /**************/
......
...@@ -75,7 +75,7 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame ) ...@@ -75,7 +75,7 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
ID_PREFERENCES_HOTKEY_END, ID_PREFERENCES_HOTKEY_END,
WinEDA_SchematicFrame::Process_Config ) WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config ) EVT_MENU( ID_COLORS_SETUP, WinEDA_SchematicFrame::OnColorConfig )
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::OnSetOptions ) EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::OnSetOptions )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
......
...@@ -119,6 +119,10 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() ...@@ -119,6 +119,10 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
wxBitmap( import_cmp_from_lib_xpm ), wxBitmap( import_cmp_from_lib_xpm ),
_( "Load component to edit from the current lib" ) ); _( "Load component to edit from the current lib" ) );
m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART_FROM_EXISTING, wxEmptyString,
wxBitmap( copyComponent_xpm ),
_( "Create a new component from the current one" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString, m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString,
wxBitmap( save_part_in_mem_xpm ), wxBitmap( save_part_in_mem_xpm ),
_( "Update current component in current library" ) ); _( "Update current component in current library" ) );
......
...@@ -60,6 +60,7 @@ extern const char* component_select_unit_xpm[]; ...@@ -60,6 +60,7 @@ extern const char* component_select_unit_xpm[];
extern const char* config_xpm[]; extern const char* config_xpm[];
extern const char* copper_layers_setup_xpm[]; extern const char* copper_layers_setup_xpm[];
extern const char* copyblock_xpm[]; extern const char* copyblock_xpm[];
extern const char* copyComponent_xpm[];
extern const char* copy_button[]; extern const char* copy_button[];
extern const char* cursor_shape_xpm[]; extern const char* cursor_shape_xpm[];
extern const char* cursor_xpm[]; extern const char* cursor_xpm[];
......
...@@ -102,6 +102,7 @@ public: ...@@ -102,6 +102,7 @@ public:
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ); void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels );
......
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