Commit c974c42d authored by charras's avatar charras

eeschema: 2 bugs fixed

pcbnew: more about netclass work
parent e39e3d53
...@@ -115,7 +115,12 @@ static void RestoreOldWires( SCH_SCREEN* screen ) ...@@ -115,7 +115,12 @@ static void RestoreOldWires( SCH_SCREEN* screen )
void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
/*************************************************************/ /*************************************************************/
/* Create a new segment ( WIRE, BUS ). /* Creates a new segment ( WIRE, BUS ),
* or terminates the current segment
* If the end of the current segment is on an other segment, place a junction if needed
* and terminates the command
* If the end of the current segment is on a pin, terminates the command
* In others cases starts a new segment
*/ */
{ {
EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment; EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment;
...@@ -177,7 +182,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -177,7 +182,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine;
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
} }
else /* Trace en cours: Placement d'un point supplementaire */ else /* A segment is in progress: terminates the current segment and add a new segment */
{ {
nextsegment = oldsegment->Next(); nextsegment = oldsegment->Next();
if( !g_HVLines ) if( !g_HVLines )
...@@ -194,8 +199,9 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -194,8 +199,9 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* Creation du segment suivant ou fin de trac� si point sur pin, jonction ...*/ /* Creates the new segment, or terminates the command
if( IsTerminalPoint( (SCH_SCREEN*)GetScreen(), cursorpos, oldsegment->GetLayer() ) ) * if the end point is on a pin, jonction or an other wire or bus */
if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->GetLayer() ) )
{ {
EndSegment( DC ); return; EndSegment( DC ); return;
} }
...@@ -777,15 +783,15 @@ void IncrementLabelMember( wxString& name ) ...@@ -777,15 +783,15 @@ void IncrementLabelMember( wxString& name )
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
/***************************************************************************/ /***************************************************************************/
/* Returne TRUE si pos est un point possible pour terminer automatiquement un /* Return TRUE if pos can be a terminal point for a wire or a bus
* segment, c'est a dire pour * i.e. :
* - type WIRE, si il y a * for a WIRE, if at pos is found:
* - une jonction * - a junction
* - ou une pin * - or a pin
* - ou une extr�mit� unique de fil * - or an other wire
* *
* - type BUS, si il y a * - for a BUS, if at pos is found:
* - ou une extr�mit� unique de BUS * - a BUS
*/ */
{ {
EDA_BaseStruct* item; EDA_BaseStruct* item;
......
...@@ -242,7 +242,6 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc, ...@@ -242,7 +242,6 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
{ {
wxString fieldText; wxString fieldText;
LibDrawField* Field; LibDrawField* Field;
LIB_DRAW_ITEM* drawItem;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
GRSetDrawMode( dc, drawMode ); GRSetDrawMode( dc, drawMode );
...@@ -313,7 +312,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc, ...@@ -313,7 +312,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
for( Field = m_Fields; Field != NULL; Field = Field->Next() ) for( Field = m_Fields; Field != NULL; Field = Field->Next() )
{ {
if( onlySelected && drawItem->m_Selected == 0 ) if( onlySelected && Field->m_Selected == 0 )
continue; continue;
Field->Draw( panel, dc, offset, color, drawMode, NULL, Field->Draw( panel, dc, offset, color, drawMode, NULL,
......
...@@ -686,13 +686,45 @@ Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet, ...@@ -686,13 +686,45 @@ Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet,
return NULL; return NULL;
} }
/* helper function used to locate graphics items in a lib component (in library space)
* to a given location given in schematic space
* in schematic space, a component is an image of the lib component, rotated and mirorred
* by its mirror/rotation matrix
* this function calculates the invert matrix of the mirror/rotation matrix
* it is used to calculate the position in in library space from
* the position in schematic space of a test point, corresponding to a given component
*/
bool InvertMatrix(int aSource[2][2], int aDest[2][2] )
{
/* for a source matrix (a,b, c,d) a, if the first line, and cd the second line
* the invert matrix is 1/det * comatrix
* det = ad-bc
* comatrix = (d,-b, -c,a)
* a = aSource[0][0]
* b = aSource[0][1]
* c = aSource[1][0]
* d = aSource[1][1]
* in eeschema, values are 1, 0 or -1 only and we can use integers only
*/
bool success = true;
int det = aSource[0][0]*aSource[1][1] - aSource[0][1]*aSource[1][0];
wxASSERT(det);
if( det == 0 ) // Should not occur with eeschema matrix transform
det = 1;
aDest[0][0] = aSource[1][1]/det;
aDest[0][1] = -aSource[0][1]/det;
aDest[1][0] = -aSource[1][0]/det;
aDest[1][1] = aSource[0][0]/det;
return success;
}
LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
SCH_COMPONENT** libpart ) SCH_COMPONENT** libpart )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
SCH_COMPONENT* LibItem = NULL; SCH_COMPONENT* schItem = NULL;
LibDrawPin* Pin = NULL; LibDrawPin* Pin = NULL;
for( DrawStruct = DrawList; DrawStruct != NULL; for( DrawStruct = DrawList; DrawStruct != NULL;
...@@ -700,21 +732,36 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, ...@@ -700,21 +732,36 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
{ {
if( DrawStruct->Type() != TYPE_SCH_COMPONENT ) if( DrawStruct->Type() != TYPE_SCH_COMPONENT )
continue; continue;
LibItem = (SCH_COMPONENT*) DrawStruct; schItem = (SCH_COMPONENT*) DrawStruct;
Entry = CMP_LIBRARY::FindLibraryComponent( LibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( schItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
Pin = (LibDrawPin*) Entry->LocateDrawItem( LibItem->m_Multi, /* we use LocateDrawItem to locate pns. but this function suppose a component
LibItem->m_Convert, * at 0,0 location, in normal orientation/mirror
* So we must calculate the ref position in component space
*/
// Calculate the position relative to the component (in library space the component is at location 0,0)
wxPoint libPos = RefPos - schItem->m_Pos;
// Calculate the equivalent position of the test point for a normal orient component
int itransMat[2][2];
InvertMatrix(schItem->m_Transform, itransMat );
libPos = TransformCoordinate(itransMat, libPos);
// LocateDrawItem uses DefaultTransformMatrix as matrix orientation of the component
// so we must recalculate libPos for this orientation before calling LocateDrawItem
InvertMatrix(DefaultTransformMatrix, itransMat );
libPos = TransformCoordinate(itransMat, libPos);
wxPoint schPos = TransformCoordinate(schItem->m_Transform, libPos);
Pin = (LibDrawPin*) Entry->LocateDrawItem( schItem->m_Multi,
schItem->m_Convert,
COMPONENT_PIN_DRAW_TYPE, COMPONENT_PIN_DRAW_TYPE,
RefPos ); libPos );
if( Pin ) if( Pin )
break; break;
} }
if( libpart ) if( libpart )
*libpart = LibItem; *libpart = schItem;
return Pin; return Pin;
} }
......
...@@ -333,7 +333,6 @@ public: ...@@ -333,7 +333,6 @@ public:
virtual void SwitchLayer( wxDC* DC, int layer ); virtual void SwitchLayer( wxDC* DC, int layer );
// divers // divers
void AddHistory( int value, KICAD_T type ); // Add value in data list history
void InstallGridFrame( const wxPoint& pos ); void InstallGridFrame( const wxPoint& pos );
virtual void LoadSettings(); virtual void LoadSettings();
......
...@@ -56,10 +56,10 @@ public: ...@@ -56,10 +56,10 @@ public:
WinEDAChoiceBox* m_SelViaSizeBox; // a combo box to display and select current via diameter WinEDAChoiceBox* m_SelViaSizeBox; // a combo box to display and select current via diameter
wxTextCtrl* m_ClearanceBox; // a text ctrl to display the current tracks and vias clearance wxTextCtrl* m_ClearanceBox; // a text ctrl to display the current tracks and vias clearance
wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the current NetClass wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the current NetClass
bool m_TrackAndViasSizesList_Changed;
private: private:
bool m_TrackAndViasSizesList_Changed;
DRC* m_drc; ///< the DRC controller, see drc.cpp DRC* m_drc; ///< the DRC controller, see drc.cpp
// we'll use lower case function names for private member functions. // we'll use lower case function names for private member functions.
......
...@@ -79,7 +79,7 @@ BOARD::~BOARD() ...@@ -79,7 +79,7 @@ BOARD::~BOARD()
/** /**
* Function SetCurrentNetClass * Function SetCurrentNetClass
* Must be called after a netclass selection (or after a netclass parameter change * Must be called after a netclass selection (or after a netclass parameter change
* Initialise vias and tracks values displayed in comb boxs of the auxiliary toolbar * Initialise vias and tracks values displayed in combo boxs of the auxiliary toolbar
* and some others parametres (netclass name ....) * and some others parametres (netclass name ....)
* @param aNetClassName = the new netclass name * @param aNetClassName = the new netclass name
* @return true if lists of tracks and vias sizes are modified * @return true if lists of tracks and vias sizes are modified
...@@ -96,33 +96,33 @@ BOARD::~BOARD() ...@@ -96,33 +96,33 @@ BOARD::~BOARD()
m_CurrentNetClassName = netClass->GetName(); m_CurrentNetClassName = netClass->GetName();
// Initialize others values: // Initialize others values:
if( m_ViaSizeHistory.size() == 0 ) if( m_ViaSizeList.size() == 0 )
{ {
lists_sizes_modified = true; lists_sizes_modified = true;
m_ViaSizeHistory.push_back(0); m_ViaSizeList.push_back(0);
} }
if( m_TrackWidthHistory.size() == 0 ) if( m_TrackWidthList.size() == 0 )
{ {
lists_sizes_modified = true; lists_sizes_modified = true;
m_TrackWidthHistory.push_back(0); m_TrackWidthList.push_back(0);
} }
if( m_ViaSizeHistory[0] != netClass->GetViaDiameter() ) if( m_ViaSizeList[0] != netClass->GetViaDiameter() )
lists_sizes_modified = true; lists_sizes_modified = true;
m_ViaSizeHistory[0] = netClass->GetViaDiameter(); m_ViaSizeList[0] = netClass->GetViaDiameter();
if( m_TrackWidthHistory[0] != netClass->GetTrackWidth() ) if( m_TrackWidthList[0] != netClass->GetTrackWidth() )
lists_sizes_modified = true; lists_sizes_modified = true;
m_TrackWidthHistory[0] = netClass->GetTrackWidth(); m_TrackWidthList[0] = netClass->GetTrackWidth();
if( m_ViaSizeSelector >= m_ViaSizeHistory.size() ) if( m_ViaSizeSelector >= m_ViaSizeList.size() )
m_ViaSizeSelector = m_ViaSizeHistory.size(); m_ViaSizeSelector = m_ViaSizeList.size();
if( m_TrackWidthSelector >= m_TrackWidthHistory.size() ) if( m_TrackWidthSelector >= m_TrackWidthList.size() )
m_TrackWidthSelector = m_TrackWidthHistory.size(); m_TrackWidthSelector = m_TrackWidthList.size();
//Initialize track and via current size: //Initialize track and via current size:
g_DesignSettings.m_CurrentViaSize = m_ViaSizeHistory[m_ViaSizeSelector]; g_DesignSettings.m_CurrentViaSize = m_ViaSizeList[m_ViaSizeSelector];
g_DesignSettings.m_CurrentTrackWidth = m_TrackWidthHistory[m_TrackWidthSelector]; g_DesignSettings.m_CurrentTrackWidth = m_TrackWidthList[m_TrackWidthSelector];
return lists_sizes_modified; return lists_sizes_modified;
} }
......
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
std::vector<RATSNEST_ITEM> m_LocalRatsnest; /* Rastnest list relative to a given footprint std::vector<RATSNEST_ITEM> m_LocalRatsnest; /* Rastnest list relative to a given footprint
* (used while moving a footprint) */ * (used while moving a footprint) */
ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress
NETCLASSES m_NetClasses; ///< List of current netclasses. There is always the default netclass NETCLASSES m_NetClasses; ///< List of current netclasses. There is always the default netclass
wxString m_CurrentNetClassName; /* Current net class name used to display netclass info. wxString m_CurrentNetClassName; /* Current net class name used to display netclass info.
...@@ -108,11 +108,13 @@ public: ...@@ -108,11 +108,13 @@ public:
// handling of vias and tracks size: // handling of vias and tracks size:
// the first value is always the value of the current NetClass // the first value is always the value of the current NetClass
// The others values are extra values // The others values are extra values
std::vector <int> m_ViaSizeHistory; // Last used via sizes (max count = HISTORY_MAX_COUNT) std::vector <int> m_ViaSizeList; // vias sizes list(max count = HISTORY_MAX_COUNT)
std::vector <int> m_TrackWidthHistory; // Last used track widths (max count = HISTORY_MAX_COUNT) // The first value is the current netclass via size
unsigned m_ViaSizeSelector; // index for m_ViaSizeHistory to select the value std::vector <int> m_TrackWidthList; // tracks widths (max count = HISTORY_MAX_COUNT)
// O is the selection of the default value Netclass // The first value is the current netclass track width
unsigned m_TrackWidthSelector; // index for m_TrackWidthHistory to select the value unsigned m_ViaSizeSelector; // index for m_ViaSizeList to select the value
// 0 is the index selection of the default value Netclass
unsigned m_TrackWidthSelector; // index for m_TrackWidthList to select the value
/**********************************/ /**********************************/
public: public:
...@@ -372,7 +374,7 @@ public: ...@@ -372,7 +374,7 @@ public:
* @param aNetClassName = the new netclass name * @param aNetClassName = the new netclass name
* @return true if lists of tracks and vias sizes are modified * @return true if lists of tracks and vias sizes are modified
*/ */
bool SetCurrentNetClass( const wxString & aNetClassName); bool SetCurrentNetClass( const wxString& aNetClassName );
/** /**
* Function Save * Function Save
......
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dialog_track_options.h // Name: dialog_track_options.h
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Created: 17 feb 2009 // Created: 17 feb 2009
...@@ -17,18 +18,23 @@ ...@@ -17,18 +18,23 @@
*/ */
class DIALOG_TRACKS_OPTIONS : public DIALOG_TRACKS_OPTIONS_BASE class DIALOG_TRACKS_OPTIONS : public DIALOG_TRACKS_OPTIONS_BASE
{ {
public: private:
WinEDA_PcbFrame* m_Parent; WinEDA_PcbFrame* m_Parent;
std::vector <int> m_ViasDiameterList;
std::vector <int> m_TracksWidthList;
public: public:
DIALOG_TRACKS_OPTIONS( WinEDA_PcbFrame* parent ); DIALOG_TRACKS_OPTIONS( WinEDA_PcbFrame* parent );
~DIALOG_TRACKS_OPTIONS() {}; ~DIALOG_TRACKS_OPTIONS() {};
private: private:
void SetDisplayValue(); void MyInit();
virtual void OnInitDialog( wxInitDialogEvent& event ); void InitDimensionsLists();
virtual void OnCheckboxAllowsMicroviaClick( wxCommandEvent& event );
virtual void OnButtonOkClick( wxCommandEvent& event ); virtual void OnButtonOkClick( wxCommandEvent& event );
virtual void OnButtonCancelClick( wxCommandEvent& event ); virtual void OnButtonCancelClick( wxCommandEvent& event );
virtual void OnButtonAddViaSizeClick( wxCommandEvent& event );
virtual void OnButtonDeleteViaSizeClick( wxCommandEvent& event );
virtual void OnButtonAddTrackSizeClick( wxCommandEvent& event );
virtual void OnButtonDeleteTrackSizeClick( wxCommandEvent& event );
}; };
#endif // _DIALOG_TRACK_OPTIONS_H_ #endif // _DIALOG_TRACK_OPTIONS_H_
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -11,17 +11,17 @@ ...@@ -11,17 +11,17 @@
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/stattext.h> #include <wx/listbox.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/textctrl.h> #include <wx/button.h>
#include <wx/radiobox.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/checkbox.h> #include <wx/stattext.h>
#include <wx/button.h> #include <wx/textctrl.h>
#include <wx/radiobox.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -35,45 +35,55 @@ class DIALOG_TRACKS_OPTIONS_BASE : public wxDialog ...@@ -35,45 +35,55 @@ class DIALOG_TRACKS_OPTIONS_BASE : public wxDialog
private: private:
// Private event handlers // Private event handlers
void _wxFB_OnInitDialog( wxInitDialogEvent& event ){ OnInitDialog( event ); } void _wxFB_OnButtonAddViaSizeClick( wxCommandEvent& event ){ OnButtonAddViaSizeClick( event ); }
void _wxFB_OnCheckboxAllowsMicroviaClick( wxCommandEvent& event ){ OnCheckboxAllowsMicroviaClick( event ); } void _wxFB_OnButtonDeleteViaSizeClick( wxCommandEvent& event ){ OnButtonDeleteViaSizeClick( event ); }
void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); } void _wxFB_OnButtonAddTrackSizeClick( wxCommandEvent& event ){ OnButtonAddTrackSizeClick( event ); }
void _wxFB_OnButtonDeleteTrackSizeClick( wxCommandEvent& event ){ OnButtonDeleteTrackSizeClick( event ); }
void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); } void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); }
void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); }
protected: protected:
wxStaticText* m_ViaSizeTitle; enum
wxTextCtrl* m_OptViaSize; {
wxID_ADD_VIA_SIZE = 1000,
wxID_DELETED_WIA_SIEZ,
wxID_ALLOW_MICROVIA,
wxID_ADD_TRACK_WIDTH,
wxID_DELETED_TRACK_WIDTH,
};
wxListBox* m_ViaSizeListCtrl;
wxButton* m_buttonAddViasSize;
wxButton* m_button4;
wxStaticText* m_ViaDefaultDrillValueTitle; wxStaticText* m_ViaDefaultDrillValueTitle;
wxTextCtrl* m_OptViaDrill; wxTextCtrl* m_OptViaDrill;
wxStaticText* m_ViaAltDrillValueTitle; wxStaticText* m_ViaAltDrillValueTitle;
wxTextCtrl* m_OptCustomViaDrill; wxTextCtrl* m_OptCustomViaDrill;
wxRadioBox* m_OptViaType; wxRadioBox* m_OptViaType;
wxStaticText* m_MicroViaSizeTitle;
wxTextCtrl* m_MicroViaSizeCtrl;
wxStaticText* m_MicroViaDrillTitle;
wxTextCtrl* m_MicroViaDrillCtrl;
wxCheckBox* m_AllowMicroViaCtrl; wxRadioBox* m_AllowMicroViaCtrl;
wxStaticText* m_TrackWidthTitle; wxListBox* m_TrackWidthListCtrl;
wxTextCtrl* m_OptTrackWidth; wxButton* m_buttonAddTrackSize;
wxStaticText* m_TrackClearanceTitle; wxButton* m_buttonDeleteTrackWidth;
wxTextCtrl* m_OptTrackClearance;
wxStaticText* m_MaskClearanceTitle; wxStaticText* m_MaskClearanceTitle;
wxTextCtrl* m_OptMaskMargin; wxTextCtrl* m_OptMaskMargin;
wxButton* m_buttonOK; wxStdDialogButtonSizer* m_sdbButtonsSizer;
wxButton* m_buttonCANCEL; wxButton* m_sdbButtonsSizerOK;
wxButton* m_sdbButtonsSizerCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } virtual void OnButtonAddViaSizeClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCheckboxAllowsMicroviaClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonDeleteViaSizeClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOkClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonAddTrackSizeClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonDeleteTrackSizeClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOkClick( wxCommandEvent& event ){ event.Skip(); }
public: public:
DIALOG_TRACKS_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Tracks and Vias Sizes"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_TRACKS_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Tracks and Vias Sizes"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 627,351 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_TRACKS_OPTIONS_BASE(); ~DIALOG_TRACKS_OPTIONS_BASE();
}; };
......
...@@ -33,17 +33,17 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) ...@@ -33,17 +33,17 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
{ {
case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH: case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH:
g_DesignSettings.m_UseConnectedTrackWidth = not g_DesignSettings.m_UseConnectedTrackWidth; g_DesignSettings.m_UseConnectedTrackWidth = not g_DesignSettings.m_UseConnectedTrackWidth;
g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthHistory[m_SelTrackWidthBox->GetChoice()]; g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthList[m_SelTrackWidthBox->GetChoice()];
g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeHistory[m_SelViaSizeBox->GetChoice()]; g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeList[m_SelViaSizeBox->GetChoice()];
AuxiliaryToolBar_Update_UI( ); AuxiliaryToolBar_Update_UI( );
break; break;
case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES: case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES:
g_DesignSettings.m_UseConnectedTrackWidth = false; g_DesignSettings.m_UseConnectedTrackWidth = false;
GetBoard()->m_TrackWidthSelector = 0; GetBoard()->m_TrackWidthSelector = 0;
g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthHistory[0]; g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthList[0];
GetBoard()->m_ViaSizeSelector = 0; GetBoard()->m_ViaSizeSelector = 0;
g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeHistory[0]; g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeList[0];
AuxiliaryToolBar_Update_UI( ); AuxiliaryToolBar_Update_UI( );
break; break;
...@@ -65,7 +65,7 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) ...@@ -65,7 +65,7 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
g_DesignSettings.m_UseConnectedTrackWidth = false; g_DesignSettings.m_UseConnectedTrackWidth = false;
ii = id - ID_POPUP_PCB_SELECT_WIDTH1; ii = id - ID_POPUP_PCB_SELECT_WIDTH1;
GetBoard()->m_TrackWidthSelector = ii; GetBoard()->m_TrackWidthSelector = ii;
g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthHistory[ii]; g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthList[ii];
AuxiliaryToolBar_Update_UI( ); AuxiliaryToolBar_Update_UI( );
break; break;
...@@ -80,20 +80,20 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) ...@@ -80,20 +80,20 @@ void WinEDA_PcbFrame::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
ii = id - ID_POPUP_PCB_SELECT_VIASIZE1; ii = id - ID_POPUP_PCB_SELECT_VIASIZE1;
GetBoard()->m_ViaSizeSelector = ii; GetBoard()->m_ViaSizeSelector = ii;
g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeHistory[ii]; g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeList[ii];
AuxiliaryToolBar_Update_UI( ); AuxiliaryToolBar_Update_UI( );
break; break;
case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH: case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH:
ii = m_SelTrackWidthBox->GetChoice(); ii = m_SelTrackWidthBox->GetChoice();
g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthHistory[ii]; g_DesignSettings.m_CurrentTrackWidth = GetBoard()->m_TrackWidthList[ii];
GetBoard()->m_TrackWidthSelector = ii; GetBoard()->m_TrackWidthSelector = ii;
break; break;
case ID_AUX_TOOLBAR_PCB_VIA_SIZE: case ID_AUX_TOOLBAR_PCB_VIA_SIZE:
ii = m_SelViaSizeBox->GetChoice(); ii = m_SelViaSizeBox->GetChoice();
g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeHistory[ii]; g_DesignSettings.m_CurrentViaSize = GetBoard()->m_ViaSizeList[ii];
GetBoard()->m_ViaSizeSelector = ii; GetBoard()->m_ViaSizeSelector = ii;
break; break;
......
...@@ -357,14 +357,13 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -357,14 +357,13 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "TrackWidth" ) == 0 ) if( stricmp( Line, "TrackWidth" ) == 0 )
{ {
g_DesignSettings.m_CurrentTrackWidth = atoi( data ); g_DesignSettings.m_CurrentTrackWidth = atoi( data );
AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK );
continue; continue;
} }
if( stricmp( Line, "TrackWidthHistory" ) == 0 ) if( stricmp( Line, "TrackWidthList" ) == 0 )
{ {
int tmp = atoi( data ); int tmp = atoi( data );
AddHistory( tmp, TYPE_TRACK ); GetBoard()->m_TrackWidthList.push_back( tmp );
continue; continue;
} }
...@@ -407,7 +406,6 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -407,7 +406,6 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "ViaSize" ) == 0 ) if( stricmp( Line, "ViaSize" ) == 0 )
{ {
g_DesignSettings.m_CurrentViaSize = atoi( data ); g_DesignSettings.m_CurrentViaSize = atoi( data );
AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA );
continue; continue;
} }
...@@ -429,10 +427,10 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -429,10 +427,10 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
continue; continue;
} }
if( stricmp( Line, "ViaSizeHistory" ) == 0 ) if( stricmp( Line, "ViaSizeList" ) == 0 )
{ {
int tmp = atoi( data ); int tmp = atoi( data );
AddHistory( tmp, TYPE_VIA ); GetBoard()->m_ViaSizeList.push_back( tmp );
continue; continue;
} }
...@@ -508,9 +506,37 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -508,9 +506,37 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x;
continue; continue;
} }
if( stricmp( Line, "Pad2MaskClearance" ) == 0 )
{
g_DesignSettings.m_MaskMargin = atoi( data );
continue;
}
#endif #endif
} }
/* Ensure tracks and vias sizes lists are ok:
* Sort lists by by increasing value and remove duplicates
* (the first value is not tested, because it is the netclass value
*/
sort( GetBoard()->m_ViaSizeList.begin()+1, GetBoard()->m_ViaSizeList.end() );
sort( GetBoard()->m_TrackWidthList.begin()+1, GetBoard()->m_TrackWidthList.end() );
for( unsigned ii = 1; ii < GetBoard()->m_ViaSizeList.size()-1; ii++ )
{
if( GetBoard()->m_ViaSizeList[ii] == GetBoard()->m_ViaSizeList[ii+1] )
{
GetBoard()->m_ViaSizeList.erase(GetBoard()->m_ViaSizeList.begin()+ii);
ii--;
}
}
for( unsigned ii = 1; ii < GetBoard()->m_TrackWidthList.size()-1; ii++ )
{
if( GetBoard()->m_TrackWidthList[ii] == GetBoard()->m_TrackWidthList[ii+1] )
{
GetBoard()->m_TrackWidthList.erase(GetBoard()->m_TrackWidthList.begin()+ii);
ii--;
}
}
return 1; return 1;
} }
...@@ -543,8 +569,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -543,8 +569,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
} }
fprintf( aFile, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth ); fprintf( aFile, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth );
for( unsigned ii = 0; ii < aBoard->m_TrackWidthHistory.size(); ii++ ) // Save custom tracks width list (the first is not saved here: this is the netclass value
fprintf( aFile, "TrackWidthHistory %d\n", aBoard->m_TrackWidthHistory[ii] ); for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ )
fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] );
fprintf( aFile, "TrackClearence %d\n", g_DesignSettings.m_TrackClearance ); fprintf( aFile, "TrackClearence %d\n", g_DesignSettings.m_TrackClearance );
...@@ -558,8 +585,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -558,8 +585,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
fprintf( aFile, "ViaAltDrill %d\n", g_DesignSettings.m_ViaDrillCustomValue ); fprintf( aFile, "ViaAltDrill %d\n", g_DesignSettings.m_ViaDrillCustomValue );
fprintf( aFile, "ViaMinSize %d\n", g_DesignSettings.m_ViasMinSize ); fprintf( aFile, "ViaMinSize %d\n", g_DesignSettings.m_ViasMinSize );
for( unsigned ii = 0; ii < aBoard->m_ViaSizeHistory.size(); ii++ ) // Save custom vias diameters list (the first is not saved here: this is the netclass value
fprintf( aFile, "ViaSizeHistory %d\n", aBoard->m_ViaSizeHistory[ii] ); for( unsigned ii = 1; ii < aBoard->m_ViaSizeList.size(); ii++ )
fprintf( aFile, "ViaSizeList %d\n", aBoard->m_ViaSizeList[ii] );
fprintf( aFile, "MicroViaSize %d\n", g_DesignSettings.m_CurrentMicroViaSize); fprintf( aFile, "MicroViaSize %d\n", g_DesignSettings.m_CurrentMicroViaSize);
fprintf( aFile, "MicroViaDrill %d\n", g_DesignSettings.m_MicroViaDrill); fprintf( aFile, "MicroViaDrill %d\n", g_DesignSettings.m_MicroViaDrill);
...@@ -575,6 +603,7 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -575,6 +603,7 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth ); fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth );
fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y );
fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
fprintf( aFile, "Pad2MaskClearance %d\n", g_DesignSettings.m_MaskMargin );
fprintf( aFile, "AuxiliaryAxisOrg %d %d\n", fprintf( aFile, "AuxiliaryAxisOrg %d %d\n",
aFrame->m_Auxiliary_Axis_Position.x, aFrame->m_Auxiliary_Axis_Position.y ); aFrame->m_Auxiliary_Axis_Position.x, aFrame->m_Auxiliary_Axis_Position.y );
...@@ -966,12 +995,16 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile ) ...@@ -966,12 +995,16 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
DateAndTime( line ) ); DateAndTime( line ) );
fprintf( aFile, "# Created by Pcbnew%s\n\n", CONV_TO_UTF8( GetBuildVersion() ) ); fprintf( aFile, "# Created by Pcbnew%s\n\n", CONV_TO_UTF8( GetBuildVersion() ) );
GetBoard()->SynchronizeNetsAndNetClasses();
// Select default Netclass. Useful to save default values in headers
GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName( ));
m_TrackAndViasSizesList_Changed = true;
AuxiliaryToolBar_Update_UI();
WriteGeneralDescrPcb( aFile ); WriteGeneralDescrPcb( aFile );
WriteSheetDescr( GetScreen(), aFile ); WriteSheetDescr( GetScreen(), aFile );
WriteSetup( aFile, this, GetBoard() ); WriteSetup( aFile, this, GetBoard() );
GetBoard()->SynchronizeNetsAndNetClasses();
rc = GetBoard()->Save( aFile ); rc = GetBoard()->Save( aFile );
SetLocaleTo_Default( ); // revert to the current locale SetLocaleTo_Default( ); // revert to the current locale
......
...@@ -861,10 +861,10 @@ static wxMenu* Append_Track_Width_List( BOARD * aBoard ) ...@@ -861,10 +861,10 @@ static wxMenu* Append_Track_Width_List( BOARD * aBoard )
_( "Use track and via sizes from their Netclass values" ), _( "Use track and via sizes from their Netclass values" ),
true ); true );
for( unsigned ii = 0; ii < aBoard->m_TrackWidthHistory.size(); ii++ ) for( unsigned ii = 0; ii < aBoard->m_TrackWidthList.size(); ii++ )
{ {
value = To_User_Unit( g_UnitMetric, value = To_User_Unit( g_UnitMetric,
aBoard->m_TrackWidthHistory[ii], aBoard->m_TrackWidthList[ii],
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES ) // Affichage en mils if( g_UnitMetric == INCHES ) // Affichage en mils
msg.Printf( _( "Track %.1f" ), value * 1000 ); msg.Printf( _( "Track %.1f" ), value * 1000 );
...@@ -881,15 +881,15 @@ static wxMenu* Append_Track_Width_List( BOARD * aBoard ) ...@@ -881,15 +881,15 @@ static wxMenu* Append_Track_Width_List( BOARD * aBoard )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, true ); trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, true );
else else
{ {
if( aBoard->m_TrackWidthSelector < aBoard->m_TrackWidthHistory.size() ) if( aBoard->m_TrackWidthSelector < aBoard->m_TrackWidthList.size() )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_WIDTH1 + aBoard->m_TrackWidthSelector, true ); trackwidth_menu->Check( ID_POPUP_PCB_SELECT_WIDTH1 + aBoard->m_TrackWidthSelector, true );
} }
trackwidth_menu->AppendSeparator(); trackwidth_menu->AppendSeparator();
for( unsigned ii = 0; ii < aBoard->m_ViaSizeHistory.size(); ii++ ) for( unsigned ii = 0; ii < aBoard->m_ViaSizeList.size(); ii++ )
{ {
value = To_User_Unit( g_UnitMetric, value = To_User_Unit( g_UnitMetric,
aBoard->m_ViaSizeHistory[ii], aBoard->m_ViaSizeList[ii],
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES ) if( g_UnitMetric == INCHES )
msg.Printf( _( "Via %.1f" ), value * 1000 ); msg.Printf( _( "Via %.1f" ), value * 1000 );
...@@ -899,7 +899,7 @@ static wxMenu* Append_Track_Width_List( BOARD * aBoard ) ...@@ -899,7 +899,7 @@ static wxMenu* Append_Track_Width_List( BOARD * aBoard )
msg << _(" (from NetClass)" ); msg << _(" (from NetClass)" );
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, true ); trackwidth_menu->Append( ID_POPUP_PCB_SELECT_VIASIZE1 + ii, msg, wxEmptyString, true );
} }
if( aBoard->m_ViaSizeSelector < aBoard->m_ViaSizeHistory.size() ) if( aBoard->m_ViaSizeSelector < aBoard->m_ViaSizeList.size() )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + aBoard->m_ViaSizeSelector, true ); trackwidth_menu->Check( ID_POPUP_PCB_SELECT_VIASIZE1 + aBoard->m_ViaSizeSelector, true );
return trackwidth_menu; return trackwidth_menu;
......
...@@ -1251,9 +1251,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError ) ...@@ -1251,9 +1251,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
pcb->library->SetViaStartIndex( pcb->library->padstacks.size()-1 ); pcb->library->SetViaStartIndex( pcb->library->padstacks.size()-1 );
} }
for( unsigned i=0; i < aBoard->m_ViaSizeHistory.size(); ++i ) for( unsigned i=0; i < aBoard->m_ViaSizeList.size(); ++i )
{ {
int viaSize = aBoard->m_ViaSizeHistory[i]; int viaSize = aBoard->m_ViaSizeList[i];
if( viaSize == defaultViaSize ) if( viaSize == defaultViaSize )
continue; continue;
......
...@@ -87,30 +87,30 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI() ...@@ -87,30 +87,30 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI()
if( m_SelTrackWidthBox && m_TrackAndViasSizesList_Changed ) if( m_SelTrackWidthBox && m_TrackAndViasSizesList_Changed )
{ {
m_SelTrackWidthBox->Clear(); m_SelTrackWidthBox->Clear();
for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthHistory.size(); ii++ ) for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthList.size(); ii++ )
{ {
msg = _( "Track" ) + ReturnStringValue( GetBoard()->m_TrackWidthHistory[ii] ); msg = _( "Track" ) + ReturnStringValue( GetBoard()->m_TrackWidthList[ii] );
if( ii == 0 ) if( ii == 0 )
msg << _( " *" ); msg << _( " *" );
m_SelTrackWidthBox->Append( msg ); m_SelTrackWidthBox->Append( msg );
} }
} }
if( GetBoard()->m_TrackWidthSelector >= GetBoard()->m_TrackWidthHistory.size() ) if( GetBoard()->m_TrackWidthSelector >= GetBoard()->m_TrackWidthList.size() )
GetBoard()->m_TrackWidthSelector = 0; GetBoard()->m_TrackWidthSelector = 0;
m_SelTrackWidthBox->SetSelection( GetBoard()->m_TrackWidthSelector ); m_SelTrackWidthBox->SetSelection( GetBoard()->m_TrackWidthSelector );
if( m_SelViaSizeBox && m_TrackAndViasSizesList_Changed ) if( m_SelViaSizeBox && m_TrackAndViasSizesList_Changed )
{ {
m_SelViaSizeBox->Clear(); m_SelViaSizeBox->Clear();
for( unsigned ii = 0; ii < GetBoard()->m_ViaSizeHistory.size(); ii++ ) for( unsigned ii = 0; ii < GetBoard()->m_ViaSizeList.size(); ii++ )
{ {
msg = _( "Via" ) + ReturnStringValue( GetBoard()->m_ViaSizeHistory[ii] ); msg = _( "Via" ) + ReturnStringValue( GetBoard()->m_ViaSizeList[ii] );
if( ii == 0 ) if( ii == 0 )
msg << _( " *" ); msg << _( " *" );
m_SelViaSizeBox->Append( msg ); m_SelViaSizeBox->Append( msg );
} }
} }
if( GetBoard()->m_ViaSizeSelector >= GetBoard()->m_ViaSizeHistory.size() ) if( GetBoard()->m_ViaSizeSelector >= GetBoard()->m_ViaSizeList.size() )
GetBoard()->m_ViaSizeSelector = 0; GetBoard()->m_ViaSizeSelector = 0;
m_SelViaSizeBox->SetSelection( GetBoard()->m_ViaSizeSelector ); m_SelViaSizeBox->SetSelection( GetBoard()->m_ViaSizeSelector );
......
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