2007-08-20 01:20:48 +00:00
|
|
|
|
/****************************************************************/
|
|
|
|
|
/* Routines de deplacement automatique et rotation des MODULES */
|
|
|
|
|
/* routines et menu d'autoplacement */
|
|
|
|
|
/****************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Fichier automove.cpp */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
#include "confirm.h"
|
|
|
|
|
#include "kicad_string.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
#include "autorout.h"
|
|
|
|
|
#include "cell.h"
|
|
|
|
|
#include "id.h"
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* variables locales */
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2007-08-20 01:20:48 +00:00
|
|
|
|
FIXE_MODULE,
|
|
|
|
|
FREE_MODULE,
|
|
|
|
|
FIXE_ALL_MODULES,
|
|
|
|
|
FREE_ALL_MODULES
|
|
|
|
|
} SelectFixeFct;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Fonctions locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static int tri_modules( MODULE** pt_ref, MODULE** pt_compare );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/* Variables locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxString ModulesMaskSelection = wxT( "*" );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Traite les selections d'outils et les commandes appelees du menu POPUP
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int id = event.GetId();
|
|
|
|
|
wxPoint pos;
|
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
|
bool on_state;
|
|
|
|
|
|
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
|
|
|
|
|
switch( id ) // Arret eventuel de la commande de d<>placement en cours
|
|
|
|
|
{
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
|
|
|
|
if( DrawPanel->ManageCurseur
|
|
|
|
|
&& DrawPanel->ForceCloseManageCurseur )
|
|
|
|
|
{
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: // Arret de la commande de d<>placement en cours
|
|
|
|
|
if( DrawPanel->ManageCurseur
|
|
|
|
|
&& DrawPanel->ForceCloseManageCurseur )
|
|
|
|
|
{
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
|
}
|
|
|
|
|
m_ID_current_state = 0;
|
|
|
|
|
DisplayToolMsg( wxEmptyString );
|
|
|
|
|
DrawPanel->SetCursor( wxCursor( wxCURSOR_ARROW ) );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Erase rastnest if needed */
|
|
|
|
|
if( g_Show_Ratsnest )
|
|
|
|
|
DrawGeneralRatsnest( &dc );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
switch( id ) // Traitement des commandes
|
|
|
|
|
{
|
|
|
|
|
case ID_TOOLBARH_PCB_AUTOPLACE:
|
|
|
|
|
on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOPLACE );
|
|
|
|
|
if( on_state )
|
|
|
|
|
{
|
|
|
|
|
m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOROUTE, FALSE );
|
|
|
|
|
m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOPLACE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_HTOOL_current_state = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_TOOLBARH_PCB_AUTOROUTE:
|
|
|
|
|
on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOROUTE );
|
|
|
|
|
if( on_state )
|
|
|
|
|
{
|
|
|
|
|
m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOPLACE, FALSE );
|
|
|
|
|
m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOROUTE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_HTOOL_current_state = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE:
|
2008-04-17 16:25:29 +00:00
|
|
|
|
FixeModule( (MODULE*) GetScreen()->GetCurItem(), TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE:
|
2008-04-17 16:25:29 +00:00
|
|
|
|
FixeModule( (MODULE*) GetScreen()->GetCurItem(), FALSE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES:
|
|
|
|
|
FixeModule( NULL, FALSE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES:
|
|
|
|
|
FixeModule( NULL, TRUE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE:
|
2008-04-17 16:25:29 +00:00
|
|
|
|
AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(),
|
2007-08-20 01:20:48 +00:00
|
|
|
|
PLACE_1_MODULE, &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_ALL_MODULES:
|
|
|
|
|
AutoPlaceModule( NULL, PLACE_ALL, &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_NEW_MODULES:
|
|
|
|
|
AutoPlaceModule( NULL, PLACE_OUT_OF_BOARD, &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE:
|
|
|
|
|
AutoPlaceModule( NULL, PLACE_INCREMENTAL, &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES:
|
|
|
|
|
AutoMoveModulesOnPcb( &dc, FALSE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES:
|
|
|
|
|
AutoMoveModulesOnPcb( &dc, TRUE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_REORIENT_ALL_MODULES:
|
2008-07-12 07:25:35 +00:00
|
|
|
|
OnOrientFootprints( );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES:
|
|
|
|
|
Autoroute( &dc, ROUTE_ALL );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_MODULE:
|
|
|
|
|
Autoroute( &dc, ROUTE_MODULE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_PAD:
|
|
|
|
|
Autoroute( &dc, ROUTE_PAD );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_NET:
|
|
|
|
|
Autoroute( &dc, ROUTE_NET );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_RESET_UNROUTED:
|
|
|
|
|
Reset_Noroutable( &dc );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
DisplayError( this, wxT( "AutoPlace command error" ) );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
ReCompile_Ratsnest_After_Changes( &dc );
|
|
|
|
|
SetToolbars();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_PcbFrame::AutoMoveModulesOnPcb( wxDC* DC, bool PlaceModulesHorsPcb )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de repartition des composants dans un rectangle de format 4 / 3,
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* partant du curseur souris
|
|
|
|
|
* Les composants ayant le status FIXE ne sont normalement pas bouges
|
|
|
|
|
* Selon les flags:
|
|
|
|
|
* Tous les modules (non fixes) seront repartis
|
|
|
|
|
* Seuls les modules Hors PCB seront repartis
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MODULE** pt_Dmod, ** BaseListeModules;
|
|
|
|
|
MODULE* Module;
|
|
|
|
|
wxPoint start, current;
|
|
|
|
|
int Ymax_size, Xsize_allowed;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
int pas_grille = GetScreen()->GetGrid().x;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
bool EdgeExists;
|
|
|
|
|
float surface;
|
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
if( GetBoard()->m_Modules == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "No Modules!" ), 10 ); return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Confirmation */
|
|
|
|
|
if( !IsOK( this, _( "Move Modules ?" ) ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
EdgeExists = SetBoardBoundaryBoxFromEdgesOnly();
|
|
|
|
|
|
|
|
|
|
if( PlaceModulesHorsPcb && !EdgeExists )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this,
|
|
|
|
|
_(
|
2008-11-08 21:58:50 +00:00
|
|
|
|
"Autoplace modules: No board edges detected. Unable to place modules" ),
|
2007-08-20 01:20:48 +00:00
|
|
|
|
20 );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
Module = GetBoard()->m_Modules;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Module != NULL; Module = Module->Next() ) // remise a jour du rect d'encadrement
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
|
Module->SetRectangleExinscrit();
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
BaseListeModules = GenListeModules( GetBoard(), NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
/* Si repartition de modules Hors PCB, le curseur est mis au dessous
|
|
|
|
|
* du PCB, pour eviter de placer des composants dans la zone PCB
|
|
|
|
|
*/
|
|
|
|
|
if( PlaceModulesHorsPcb && EdgeExists )
|
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
|
if( GetScreen()->m_Curseur.y < (GetBoard()->m_BoundaryBox.GetBottom() + 2000) )
|
|
|
|
|
GetScreen()->m_Curseur.y = GetBoard()->m_BoundaryBox.GetBottom() + 2000;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* calcul de la surface occupee par les circuits */
|
|
|
|
|
surface = 0.0;
|
|
|
|
|
for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
|
|
|
|
|
{
|
|
|
|
|
Module = *pt_Dmod;
|
|
|
|
|
if( PlaceModulesHorsPcb && EdgeExists )
|
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
|
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
surface += Module->m_Surface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Xsize_allowed = (int) (sqrt( surface ) * 4.0 / 3.0);
|
|
|
|
|
|
|
|
|
|
/* Placement des modules */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
start = current = GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Ymax_size = 0;
|
|
|
|
|
|
|
|
|
|
for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
|
|
|
|
|
{
|
|
|
|
|
Module = *pt_Dmod;
|
2007-09-09 02:27:03 +00:00
|
|
|
|
if( Module->IsLocked() )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if( PlaceModulesHorsPcb && EdgeExists )
|
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
|
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( current.x > (Xsize_allowed + start.x) )
|
|
|
|
|
{
|
|
|
|
|
current.x = start.x;
|
|
|
|
|
current.y += Ymax_size + pas_grille;
|
|
|
|
|
Ymax_size = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->m_Curseur.x =
|
2007-08-20 01:20:48 +00:00
|
|
|
|
current.x + Module->m_Pos.x - Module->m_RealBoundaryBox.GetX();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->m_Curseur.y =
|
2007-08-20 01:20:48 +00:00
|
|
|
|
current.y + Module->m_Pos.y - Module->m_RealBoundaryBox.GetY();
|
|
|
|
|
Ymax_size = MAX( Ymax_size, Module->m_RealBoundaryBox.GetHeight() );
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
PutOnGrid( &GetScreen()->m_Curseur );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
|
Module->Draw( DrawPanel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Place_Module( Module, DC ); /* positionne Module et recalcule cadre */
|
|
|
|
|
|
|
|
|
|
current.x += Module->m_RealBoundaryBox.GetWidth() + pas_grille;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyFree( BaseListeModules );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
GetScreen()->SetRefreshReq();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/***********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Met a jour (FALSE ou TRUE) l'attribut FIXE sur le module Module,
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* ou sur tous les modules si Modulle == NULL
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( Module ) /* Traitement du module */
|
|
|
|
|
{
|
2007-09-09 02:27:03 +00:00
|
|
|
|
Module->SetLocked( Fixe );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Module->Display_Infos( this );
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
|
Module = GetBoard()->m_Modules;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
if( WildCompareString( ModulesMaskSelection, Module->m_Reference->m_Text ) )
|
|
|
|
|
{
|
2007-09-09 02:27:03 +00:00
|
|
|
|
Module->SetLocked( Fixe );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MODULE** GenListeModules( BOARD* Pcb, int* NbModules )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Cree par allocation memoire la liste ordonnee des structures D_MODULES
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* decrivant les modules a deplacer
|
|
|
|
|
* la fin de la liste est signalee par NULL
|
|
|
|
|
* Retourne egalement le nombre de modules par *NbModules
|
|
|
|
|
* Penser a desallouer la memoire apres usage
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MODULE* Module;
|
|
|
|
|
MODULE** ListeMod, ** PtList;
|
|
|
|
|
int NbMod;
|
|
|
|
|
|
|
|
|
|
/* Reservation de la memoire pour description des modules que l'on
|
|
|
|
|
* peut deplacer */
|
|
|
|
|
Module = Pcb->m_Modules;
|
|
|
|
|
NbMod = 0;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
NbMod++;
|
|
|
|
|
|
|
|
|
|
ListeMod = (MODULE**) MyZMalloc( (NbMod + 1) * sizeof(MODULE *) );
|
|
|
|
|
if( ListeMod == NULL )
|
|
|
|
|
{
|
|
|
|
|
if( NbModules != NULL )
|
|
|
|
|
*NbModules = 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PtList = ListeMod;
|
|
|
|
|
Module = Pcb->m_Modules;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
*PtList = Module; PtList++;
|
|
|
|
|
Module->SetRectangleExinscrit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tri par surface decroissante des modules ( on place les plus gros en 1er) */
|
|
|
|
|
qsort( ListeMod, NbMod, sizeof(MODULE * *),
|
|
|
|
|
( int( * ) ( const void*, const void* ) )tri_modules );
|
|
|
|
|
|
|
|
|
|
if( NbModules != NULL )
|
|
|
|
|
*NbModules = NbMod;
|
|
|
|
|
return ListeMod;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/**************************************************/
|
|
|
|
|
/* Routine de tri de modules, utilisee par qsort: */
|
|
|
|
|
/**************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static int tri_modules( MODULE** pt_ref, MODULE** pt_compare )
|
|
|
|
|
{
|
|
|
|
|
float ff;
|
|
|
|
|
|
|
|
|
|
ff = (*pt_ref)->m_Surface - (*pt_compare)->m_Surface;
|
|
|
|
|
if( ff < 0 )
|
|
|
|
|
return 1;
|
|
|
|
|
if( ff > 0 )
|
|
|
|
|
return -1;
|
|
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|