Commit 96e0bebd authored by charras's avatar charras

code cleaning

parent db6630b8
......@@ -218,9 +218,8 @@ public:
MODULE* module,
int angle,
bool incremental );
void Place_Module( MODULE* module, wxDC* DC );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule,
wxDC* DC, const wxPoint& pos );
void Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest = false );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
// Graphic items edition:
void InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem, wxDC* aDC );
......
No preview for this file type
This diff is collapsed.
......@@ -38,7 +38,8 @@ set(PCBNEW_SRCS
dialog_drc.cpp
dialog_edit_module_text.cpp
dialog_edit_module_text_base.cpp
# dialog_edit_module.cpp
dialog_edit_module.cpp
dialog_exchange_modules_base.cpp
dialog_freeroute_exchange.cpp
# dialog_gendrill.cpp
dialog_general_options.cpp
......
......@@ -68,9 +68,8 @@ class NETINFO_LIST
{
private:
BOARD* m_Parent;
// boost::ptr_vector<NETINFO_ITEM*> m_NetBuffer; // nets buffer list (name, design constraints ..
std::vector<NETINFO_ITEM*> m_NetBuffer; // nets buffer list (name, design constraints ..
public:
std::vector<D_PAD*> m_PadsFullList; // Entry for a sorted pad list (used in ratsnest calculations)
......@@ -115,17 +114,19 @@ public:
return m_PadsFullList.size();
}
/** Function GetPad
* @return the pad idx from m_PadsFullList
*/
D_PAD* GetPad( unsigned aIdx)
D_PAD* GetPad( unsigned aIdx )
{
if (aIdx < m_PadsFullList.size() )
if( aIdx < m_PadsFullList.size() )
return m_PadsFullList[aIdx];
else
return NULL;
}
private:
/** Function Build_Pads_Full_List
......@@ -156,10 +157,12 @@ public:
int m_NbNodes; // Pads count for this net
int m_NbLink; // Ratsnets count for this net
int m_NbNoconn; // Ratsnets remaining to route count
int m_ForceWidth; // specific width (O = default width)
int m_ForceWidth; // specific width (0 = default width)
std::vector <D_PAD*> m_ListPad; // List of pads connected to this net
unsigned m_RatsnestStart; // debut de liste ratsnests du net (included)
unsigned m_RatsnestEnd; // fin de liste ratsnests du net (excluded)
unsigned m_RatsnestStartIdx; /* Starting point of ratsnests of this net (included)
* in a general buffer of ratsnest (a vector<RATSNEST_ITEM*> buffer)
*/
unsigned m_RatsnestEndIdx; // Ending point of ratsnests of this net (excluded) in this buffer
NETINFO_ITEM( BOARD_ITEM* aParent );
~NETINFO_ITEM();
......
......@@ -19,8 +19,8 @@ NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent )
SetNet( 0 );
m_NbNodes = m_NbLink = m_NbNoconn = 0;
m_ForceWidth = 0;
m_RatsnestStart = 0; // debut de liste ratsnests du net
m_RatsnestEnd = 0; // fin de liste ratsnests du net
m_RatsnestStartIdx = 0; // Starting point of ratsnests of this net in a general buffer of ratsnest
m_RatsnestEndIdx = 0; // Ending point of ratsnests of this net
}
......
......@@ -86,7 +86,8 @@ void NETINFO_LIST::BuildListOfNets()
DeleteData(); // Remove all nets info and free memory
// Create and add the "unconnected net"
// Create and add the "unconnected net", always existing,
// used to handle pads and tracks that are not member of a "real" net
net_item = new NETINFO_ITEM( m_Parent );
AppendNet( net_item );
......
......@@ -4,10 +4,18 @@
/* include in modedit.cpp */
/************************************************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "appl_wxstruct.h"
#include "gestfich.h"
#include "3d_struct.h"
#include "3d_viewer.h"
#include "dialog_edit_module.h"
#include <wx/version.h>
extern bool GoToEditor;
/**************************************/
/* class WinEDA_ModulePropertiesFrame */
......@@ -652,8 +660,7 @@ void WinEDA_ModulePropertiesFrame::GotoModuleEditor( wxCommandEvent& event )
void WinEDA_ModulePropertiesFrame::ExchangeModule( wxCommandEvent& event )
/**********************************************************************/
{
m_Parent->InstallExchangeModuleFrame( m_CurrentModule,
m_DC, wxPoint( -1, -1 ) );
m_Parent->InstallExchangeModuleFrame( m_CurrentModule );
// Attention: si il y a eu echange, m_CurrentModule a t delete!
m_Parent->SetCurItem( NULL );
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_exchange_modules_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_EXCHANGE_MODULE_BASE::DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Current Module"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
bLeftSizer->Add( m_staticText6, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_OldModule = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
bLeftSizer->Add( m_OldModule, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Current Value"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
bLeftSizer->Add( m_staticText7, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_OldValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
bLeftSizer->Add( m_OldValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText8 = new wxStaticText( this, wxID_ANY, _("New Module"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText8->Wrap( -1 );
bLeftSizer->Add( m_staticText8, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_NewModule = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bLeftSizer->Add( m_NewModule, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bUpperSizer->Add( bLeftSizer, 1, 0, 5 );
wxBoxSizer* bMiddleSizer;
bMiddleSizer = new wxBoxSizer( wxVERTICAL );
wxString m_SelectionChoices[] = { _("Change module"), _("Change same modules"), _("Ch. same module+value"), _("Change all") };
int m_SelectionNChoices = sizeof( m_SelectionChoices ) / sizeof( wxString );
m_Selection = new wxRadioBox( this, ID_SELECTION_CLICKED, _("wxRadioBox"), wxDefaultPosition, wxDefaultSize, m_SelectionNChoices, m_SelectionChoices, 1, wxRA_SPECIFY_COLS );
m_Selection->SetSelection( 0 );
bMiddleSizer->Add( m_Selection, 0, wxALL, 5 );
bUpperSizer->Add( bMiddleSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
m_OKbutton = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_OKbutton, 0, wxALL, 5 );
m_Quitbutton = new wxButton( this, wxID_CANCEL, _("Quit"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_Quitbutton, 0, wxALL, 5 );
m_Browsebutton = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_Browsebutton, 0, wxALL, 5 );
bUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 );
m_WinMessages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_WinMessages->SetMinSize( wxSize( 450,300 ) );
bMainSizer->Add( m_WinMessages, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
// Connect Events
m_Selection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this );
m_OKbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this );
m_Quitbutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this );
m_Browsebutton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this );
}
DIALOG_EXCHANGE_MODULE_BASE::~DIALOG_EXCHANGE_MODULE_BASE()
{
// Disconnect Events
m_Selection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnSelectionClicked ), NULL, this );
m_OKbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnOkClick ), NULL, this );
m_Quitbutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::OnQuit ), NULL, this );
m_Browsebutton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXCHANGE_MODULE_BASE::BrowseAndSelectFootprint ), NULL, this );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_exchange_modules_base__
#define __dialog_exchange_modules_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/radiobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_SELECTION_CLICKED 1000
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EXCHANGE_MODULE_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EXCHANGE_MODULE_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticText6;
wxTextCtrl* m_OldModule;
wxStaticText* m_staticText7;
wxTextCtrl* m_OldValue;
wxStaticText* m_staticText8;
wxTextCtrl* m_NewModule;
wxRadioBox* m_Selection;
wxButton* m_OKbutton;
wxButton* m_Quitbutton;
wxButton* m_Browsebutton;
wxTextCtrl* m_WinMessages;
// Virtual event handlers, overide them in your derived class
virtual void OnSelectionClicked( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnQuit( wxCommandEvent& event ){ event.Skip(); }
virtual void BrowseAndSelectFootprint( wxCommandEvent& event ){ event.Skip(); }
public:
DIALOG_EXCHANGE_MODULE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Exchange Modules"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 416,469 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EXCHANGE_MODULE_BASE();
};
#endif //__dialog_exchange_modules_base__
......@@ -15,14 +15,12 @@
#include "3d_struct.h"
#include "3d_viewer.h"
#include "dialog_edit_module.h"
#include "protos.h"
/* Variables locales: */
bool GoToEditor = FALSE;
/* class WinEDA_ModulePropertiesFrame */
#include "dialog_edit_module.cpp"
/*******************************************************************/
void WinEDA_BasePcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC * DC )
/*******************************************************************/
......
......@@ -265,8 +265,11 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, bool Append )
/* Rebuild the new pad list (for drc and ratsnet control ...) */
GetBoard()->m_Status_Pcb = 0;
// Display the loaded board:
DrawPanel->Refresh( true);
wxSafeYield(); // Needed if we want to see the board now.
// Compile rastnest and displays net info
Compile_Ratsnest( NULL, true );
GetBoard()->DisplayInfo( this );
......
......@@ -642,7 +642,7 @@ int ChangeSideNumLayer( int oldlayer )
/*****************************************************************/
void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC )
void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest )
/*****************************************************************/
/* Place a l'endroit pointe par la souris le module deja existant selectionne
......@@ -688,8 +688,8 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC )
EraseDragListe();
}
/* affichage chevelu general si necessaire */
Compile_Ratsnest( DC, true );
if( !aDoNotRecreateRatsnest )
Compile_Ratsnest( DC, true );
module->DisplayInfo( this );
......
......@@ -13,6 +13,7 @@
#include "protos.h"
#define DBG_BUID_NETINFO
/* local variables */
static std::vector <D_PAD*> s_localPadBuffer; // for local ratsnest calculations when moving a footprint: buffer of pads to consider
......@@ -107,7 +108,10 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
GetBoard()->m_Status_Pcb = 0; /* we want a full ratnest computation, from the scratch */
MsgPanel->EraseMsgBox();
MsgPanel->EraseMsgBox();
#ifdef DBG_BUID_NETINFO
wxSafeYield();
#endif
// Rebuild the full pads and net info list
......@@ -124,6 +128,9 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
msg.Printf( wxT( " %d" ), m_Pcb->m_NetInfo->GetNetsCount() );
Affiche_1_Parametre( this, 8, wxT( "Nets" ), msg, CYAN );
}
#ifdef DBG_BUID_NETINFO
wxSafeYield();
#endif
/* Compute the full ratsnest
* which can be see like all the possible links or logical connections.
......@@ -449,7 +456,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
DisplayError(this,wxT("Build_Board_Ratsnest() error: net not found") );
return;
}
net->m_RatsnestStart = m_Pcb->GetRatsnestsCount();
net->m_RatsnestStartIdx = m_Pcb->GetRatsnestsCount();
int num_block = 0;
for( unsigned ii = 0; ii < net->m_ListPad.size(); ii++ )
......@@ -473,14 +480,14 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
icnt = gen_rats_block_to_block( DrawPanel, m_Pcb->m_FullRatsnest, pstart, pend );
}
net->m_RatsnestEnd = m_Pcb->GetRatsnestsCount();
net->m_RatsnestEndIdx = m_Pcb->GetRatsnestsCount();
/* sort by lenght */
if( (net->m_RatsnestEnd - net->m_RatsnestStart) > 1 )
if( (net->m_RatsnestEndIdx - net->m_RatsnestStartIdx) > 1 )
{
RATSNEST_ITEM* rats = &m_Pcb->m_FullRatsnest[0];
qsort( rats + net->m_RatsnestStart,
net->m_RatsnestEnd - net->m_RatsnestStart,
qsort( rats + net->m_RatsnestStartIdx,
net->m_RatsnestEndIdx - net->m_RatsnestStartIdx,
sizeof(RATSNEST_ITEM), sort_by_length );
}
}
......@@ -555,7 +562,7 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR
/* Search a link from a block to an other block */
min_rats = NULL;
for( unsigned ii = net->m_RatsnestStart; ii < net->m_RatsnestEnd; ii++ )
for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ )
{
rats = &aRatsnestBuffer[ii];
if( rats->m_PadStart->GetSubRatsnest() == rats->m_PadEnd->GetSubRatsnest() ) // Same block
......@@ -691,14 +698,14 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
num_block = MAX( num_block, subnet );
}
for( unsigned ii = net->m_RatsnestStart; ii < net->m_RatsnestEnd; ii++ )
for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ )
{
m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_ACTIF;
}
/* a - tst connection between pads */
rats = &m_Pcb->m_FullRatsnest[0];
int icnt = tst_rats_pad_to_pad( num_block, rats + net->m_RatsnestStart, rats + net->m_RatsnestEnd );
int icnt = tst_rats_pad_to_pad( num_block, rats + net->m_RatsnestStartIdx, rats + net->m_RatsnestEndIdx );
/* b - test connexion between blocks (Iteration) */
while( icnt > 1 )
......
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