Commit ba6e2ffb authored by jean-pierre charras's avatar jean-pierre charras

Footprint Editor: New footprint creation: change defaults for ref and value...

Footprint Editor: New footprint creation: change defaults for ref and value texts: now Ref text is REF** and Value text  is the footprint name. Also Value is put on fab layer (front)
muonde.cpp: cleanup this very old code, and fix not working code.
parent 93b0a083
......@@ -276,22 +276,6 @@ public:
*/
void CursorGoto( const wxPoint& aPos, bool aWarp = true );
/**
* Function Save_Module_In_Library
* Save in an existing library a given footprint
* @param aLibName = name of the library to use
* @param aModule = the given footprint
* @param aOverwrite = true to overwrite an existing footprint, false to
* abort if an existing footprint with same name is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the
* footprint name
* @return : true if OK, false if abort
*/
bool Save_Module_In_Library( const wxString& aLibName,
MODULE* aModule,
bool aOverwrite,
bool aDisplayDialog );
/**
* Function SelectLibrary
* puts up a dialog and allows the user to pick a library, for unspecified use.
......@@ -316,17 +300,19 @@ public:
virtual void OnModify();
// Modules (footprints)
/**
* Function Create_1_Module
* Creates a new module or footprint : A new module contains 2 texts :
* First = REFERENCE
* Second = VALUE: "VAL**"
* the new module is added to the board module list
* @param aModuleName = name of the new footprint
* (will be the component reference in board)
* @return a pointer to the new module
* Function CreateNewModule
* Creates a new module or footprint, at position 0,0
* The new module contains only 2 texts: a reference and a value:
* Reference = REF**
* Value = "VAL**" or Footprint name in lib
* Note: they are dummy texts, which will be replaced by the actual texts
* when the fooprint is placed on a board and a netlist is read
* @param aModuleName = name of the new footprint in library
* @return a reference to the new module
*/
MODULE* Create_1_Module( const wxString& aModuleName );
MODULE* CreateNewModule( const wxString& aModuleName );
void Edit_Module( MODULE* module, wxDC* DC );
void Rotate_Module( wxDC* DC, MODULE* module, double angle, bool incremental );
......
......@@ -1602,12 +1602,15 @@ public:
void Edit_Gap( wxDC* DC, MODULE* Module );
/**
* Function Create_MuWaveBasicShape
* create a footprint with pad_count pads for micro wave applications.
* This footprint has pad_count pads:
* Function CreateMuWaveBaseFootprint
* create a basic footprint for micro wave applications.
* @param aValue = the text value
* @param aTextSize = the size of ref and value texts ( <= 0 to use board default values )
* @param aPadCount = number of pads
* Pads settings are:
* PAD_SMD, rectangular, H size = V size = current track width.
*/
MODULE* Create_MuWaveBasicShape( const wxString& name, int pad_count );
MODULE* CreateMuWaveBaseFootprint( const wxString& aValue, int aTextSize, int aPadCount );
/**
* Create_MuWaveComponent
......
......@@ -157,8 +157,11 @@ public:
*/
MODULE* GetParentModule() const;
const std::vector<wxPoint>& GetBezierPoints() const { return m_BezierPoints; };
const std::vector<wxPoint>& GetPolyPoints() const { return m_PolyPoints; };
// Accessors:
const std::vector<wxPoint>& GetBezierPoints() const { return m_BezierPoints; }
const std::vector<wxPoint>& GetPolyPoints() const { return m_PolyPoints; }
// same accessor, to add/change corners of the polygon
std::vector<wxPoint>& GetPolyPoints() { return m_PolyPoints; }
void SetBezierPoints( const std::vector<wxPoint>& aPoints )
{
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
......@@ -594,7 +594,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly )
}
bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary,
bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( const wxString& aLibrary,
MODULE* aModule,
bool aOverwrite,
bool aDisplayDialog )
......@@ -708,15 +708,18 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary,
}
MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
{
MODULE* module;
wxString moduleName;
wxPoint newpos;
// Creates a new footprint at position 0,0 which contains the minimal items:
// the reference and the value.
// Value : initialized to the footprint name.
// put on fab layer (front side)
// Reference : initialized to a default value (REF**).
// put on silkscreen layer (front side)
moduleName = aModuleName;
wxString moduleName = aModuleName;
// Ask for the new module reference
// Ask for the new module name
if( moduleName.IsEmpty() )
{
wxTextEntryDialog dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
......@@ -736,28 +739,33 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
}
// Creates the new module and add it to the head of the linked list of modules
module = new MODULE( GetBoard() );
MODULE* module = new MODULE( GetBoard() );
GetBoard()->Add( module );
// Update parameters: position, timestamp ...
newpos = GetCrossHairPosition();
module->SetPosition( newpos );
// Update parameters: timestamp ...
module->SetLastEditTime();
// Update its name in lib
module->SetFPID( FPID( moduleName ) );
wxPoint default_pos;
// Update reference:
module->SetReference( moduleName );
module->SetReference( wxT( "REF**" ) );
module->Reference().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Reference().SetSize( GetDesignSettings().m_ModuleTextSize );
default_pos.y = GetDesignSettings().m_ModuleTextSize.y / 2;
module->Reference().SetPosition( default_pos );
module->Reference().SetLayer( F_SilkS );
// Set the value field to a default value
module->SetValue( wxT( "VAL**" ) );
module->SetValue( moduleName );
module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->Value().SetSize( GetDesignSettings().m_ModuleTextSize );
module->SetPosition( wxPoint( 0, 0 ) );
default_pos.y = -default_pos.y;
module->Value().SetPosition( default_pos );
module->Value().SetLayer( F_Fab );
SetMsgPanel( module );
return module;
......
......@@ -300,7 +300,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCrossHairPosition( wxPoint( 0, 0 ) );
MODULE* module = Create_1_Module( wxEmptyString );
MODULE* module = CreateNewModule( wxEmptyString );
if( module ) // i.e. if create module command not aborted
{
......@@ -375,7 +375,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_SAVE_LIBMODULE:
if( GetBoard()->m_Modules && GetCurrentLib().size() )
{
Save_Module_In_Library( GetCurrentLib(), GetBoard()->m_Modules, true, true );
SaveFootprintInLibrary( GetCurrentLib(), GetBoard()->m_Modules, true, true );
GetScreen()->ClrModify();
}
break;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -158,6 +158,22 @@ public:
*/
void LoadModuleFromBoard( wxCommandEvent& event );
/**
* Function SaveFootprintInLibrary
* Save in an existing library a given footprint
* @param aLibName = name of the library to use
* @param aModule = the given footprint
* @param aOverwrite = true to overwrite an existing footprint, false to
* abort if an existing footprint with same name is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the
* footprint name
* @return : true if OK, false if abort
*/
bool SaveFootprintInLibrary( const wxString& aLibName,
MODULE* aModule,
bool aOverwrite,
bool aDisplayDialog );
/**
* Virtual Function OnModify()
* Must be called after a footprint change
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -488,7 +488,7 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
// at case ID_MODEDIT_SAVE_LIBMODULE
if( GetBoard()->m_Modules && GetCurrentLib().size() )
{
if( Save_Module_In_Library( GetCurrentLib(), GetBoard()->m_Modules, true, true ) )
if( SaveFootprintInLibrary( GetCurrentLib(), GetBoard()->m_Modules, true, true ) )
{
// save was correct
GetScreen()->ClrModify();
......
This diff is collapsed.
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