Commit f601dff4 authored by dickelbeck's avatar dickelbeck
Browse files

Hot key operations for a single module such as Move 'M', Rotate 'R', Swap...

Hot key operations for a single module such as Move 'M', Rotate 'R', Swap Layer 'S', now operate only on unlocked modules 
and only on modules in the current layer.

parent ad61cdaa
Loading
Loading
Loading
Loading
+113 −87
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public:

    void Set_Rectangle_Encadrement(void); /* mise a jour du rect d'encadrement
                            en coord locales (orient 0 et origine = pos  module) */

    void SetRectangleExinscrit(void);   /* mise a jour du rect d'encadrement
                            et de la surface en coord reelles */

@@ -87,6 +88,31 @@ public:
    /* supprime du chainage la structure Struct */
    void UnLink( void );


    /**
     * Function IsLocked
     * @returns bool - true if the MODULE is locked, else false
     */
    bool IsLocked()
    {
        return (m_ModuleStatus & MODULE_is_LOCKED) != 0;
    }

    
    /**
     * Function SetLocked
     * sets the MODULE_is_LOCKED bit in the m_ModuleStatus
     * @param setLocked When true means turn on locked status, else unlock 
     */
    void SetLocked( bool setLocked )
    {
        if( setLocked )
            m_ModuleStatus |= MODULE_is_LOCKED;
        else
            m_ModuleStatus &= ~MODULE_is_LOCKED;
    }

    
    /* Readind and writing data on files */
    int WriteDescr( FILE * File );
    int Write_3D_Descr( FILE * File );
+221 −189
Original line number Diff line number Diff line
@@ -46,12 +46,16 @@ MODULE* module = NULL;
    case WXK_NUMPAD_DELETE:
        OnHotkeyDeleteItem(DC, DrawStruct);
        break;
		case WXK_BACK:{ 

    case WXK_BACK:
    { 
        if( m_ID_current_state == ID_TRACK_BUTT && 
						 GetScreen()->m_Active_Layer <= CMP_N ){
                     GetScreen()->m_Active_Layer <= CMP_N )
        {
            bool ItemFree = (GetScreen()->m_CurrentItem == NULL ) || 
                    (GetScreen()->m_CurrentItem->m_Flags == 0);
				if ( ItemFree ){
            if ( ItemFree )
            {
                //no track is currently being edited - select a segment and remove it.
                DrawStruct = PcbGeneralLocateAndDisplay();
                //don't let backspace delete modules!!
@@ -70,10 +74,12 @@ MODULE* module = NULL;
        }
        break; 
    }
    
    case WXK_END:
        DrawPanel->MouseToCursorSchema();
        End_Route( (TRACK *) (GetScreen()->m_CurrentItem), DC);
        break;

    case 'v':   // Switch to alternate layer and Place a via if a track is in progress
    case 'V':
        if ( m_ID_current_state != ID_TRACK_BUTT ) return;
@@ -94,9 +100,15 @@ MODULE* module = NULL;
    case 'r':   // Rotation
    case 'R':
        if ( ItemFree )
				module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE);
            module = Locate_Prefered_Module(m_Pcb, 
                CURSEUR_ON_GRILLE | IGNORE_LOCKED | MATCH_LAYER );
        else if (GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE)
        {
            module = (MODULE*)GetScreen()->m_CurrentItem;
            // @todo: might need to add a layer check in if() below
            if( module->IsLocked() )
                module = 0; // do not move it.
        }
        if ( module )
        {
            GetScreen()->m_CurrentItem = module;
@@ -108,9 +120,15 @@ MODULE* module = NULL;
    case 's':   // move to other side
    case 'S':
        if ( ItemFree )
				module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE);
            module = Locate_Prefered_Module(m_Pcb, 
                CURSEUR_ON_GRILLE | IGNORE_LOCKED | MATCH_LAYER );
        else if (GetScreen()->m_CurrentItem->m_StructType == TYPEMODULE)
        {
            module = (MODULE*)GetScreen()->m_CurrentItem;
            // @todo: might need to add a layer check in if() below
            if( module->IsLocked() )
                module = 0; // do not move it.
        }
        if ( module )
        {
            GetScreen()->m_CurrentItem = module;
@@ -119,13 +137,29 @@ MODULE* module = NULL;
        }
        break;
        
    case 'L':   // toggle module "MODULE_is_LOCKED" status:
    case 'l':
        // get any module, locked or not locked and toggle its locked status
        module = Locate_Prefered_Module( m_Pcb, CURSEUR_ON_GRILLE | MATCH_LAYER );
        if( module )
        {
            GetScreen()->m_CurrentItem = module;
            module->Display_Infos(this);
            module->SetLocked( !module->IsLocked() );
        }
        break;
        
    case 'g':
    case 'G':   // Start move (and drag) module
        g_Drag_Pistes_On = TRUE;
        // fall through

    case 'm':
    case 'M':   // Start move module
        if ( PopupOn ) break;
			if ( (module = Locate_Prefered_Module(m_Pcb, CURSEUR_ON_GRILLE)) != NULL)
        module = Locate_Prefered_Module( m_Pcb, 
            CURSEUR_ON_GRILLE | IGNORE_LOCKED | MATCH_LAYER );
        if( module )
        {
            GetScreen()->m_CurrentItem = module;
            module->Display_Infos(this);
@@ -136,8 +170,6 @@ MODULE* module = NULL;
}




/***********************************************************/
void WinEDA_ModuleEditFrame::OnHotKey(wxDC * DC, int hotkey,
                    EDA_BaseStruct * DrawStruct)
+971 −939
Original line number Diff line number Diff line
@@ -28,6 +28,25 @@ EDA_BaseStruct * Locate_MirePcb( EDA_BaseStruct * PtStruct, int LayerSearch, int
    else { ref_pos = ActiveScreen->m_MousePosition; }


/**
 * Function IsModuleLayerVisible
 * expects either of the two layers on which a module can reside, and returns
 * whether that layer is visible.
 * @param layer One of the two allowed layers for modules: CMP_N or CUIVRE_N
 * @return bool - true if the layer is visible, else false.
 */
bool inline IsModuleLayerVisible( int layer )
{
    if( layer==CMP_N )
        return DisplayOpt.Show_Modules_Cmp;
    
    else if( layer==CUIVRE_N )
        return DisplayOpt.Show_Modules_Cu;
    
    else
        return true;
}
    

/*************************************************************/
MODULE * ReturnModule(BOARD * pcb, const wxString & reference)
@@ -631,16 +650,16 @@ MODULE * Locate_Prefered_Module(BOARD * Pcb, int typeloc)
{
    MODULE*     pt_module;
    int         lx, ly;             /* dimensions du rectangle d'encadrement du module */
MODULE * module = NULL, /* module localise sur la couche active */
	* Altmodule = NULL; /* module localise sur les couches non actives */
int min_dim = 0x7FFFFFFF,	/* dim mini du module localise sur la couche active */
	alt_min_dim = 0x7FFFFFFF; /* dim mini du module localise sur les couches non actives */
    MODULE*     module = NULL;      /* module localise sur la couche active */
    MODULE*     Altmodule = NULL;   /* module localise sur les couches non actives */
    int         min_dim = 0x7FFFFFFF;     /* dim mini du module localise sur la couche active */
    int         alt_min_dim = 0x7FFFFFFF; /* dim mini du module localise sur les couches non actives */
    int         layer;              /* pour calcul de couches prioritaires */
    wxPoint     ref_pos;            /* coord du point de reference pour la localisation */

    SET_REF_POS(ref_pos);
    pt_module = Pcb->m_Modules;
	for(  ; pt_module != NULL ; pt_module = (MODULE *) pt_module->Pnext )
    for(  ;  pt_module;  pt_module = (MODULE*) pt_module->Pnext )
    {
        /* calcul des dimensions du cadre :*/
        lx = pt_module->m_BoundaryBox.GetWidth();
@@ -655,6 +674,10 @@ wxPoint ref_pos; /* coord du point de reference pour la localisation */
        if( ! pt_module->m_BoundaryBox.Inside(spot_cX, spot_cY) )
            continue;

        // if caller wants to ignore locked modules, and this one is locked, skip it.
        if( (typeloc & IGNORE_LOCKED) && pt_module->IsLocked() )
            continue;
        
        /* Localisation: test des dimensions minimales, choix du meilleur candidat */

        /* calcul de priorite: la priorite est donnee a la couche
@@ -662,39 +685,48 @@ wxPoint ref_pos; /* coord du point de reference pour la localisation */
            est sur couche serigr,adhesive cuivre, a la couche cmp si le module
            est sur couche serigr,adhesive composant */
        layer = pt_module->m_Layer;
		if( (layer == ADHESIVE_N_CU) || (layer == SILKSCREEN_N_CU) )

        if( layer==ADHESIVE_N_CU || layer==SILKSCREEN_N_CU )
            layer = CUIVRE_N;
		if( (layer == ADHESIVE_N_CMP) || (layer == SILKSCREEN_N_CMP) )

        else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP )
            layer = CMP_N;

        if( ((PCB_SCREEN*)ActiveScreen)->m_Active_Layer == layer )
        {
            if( min(lx,ly) <= min_dim )
				{ /* meilleure empreinte localisee sur couche active */
            { 
                /* meilleure empreinte localisee sur couche active */
                module = pt_module ; min_dim = min(lx,ly) ;
            }
        }

		else
        else if( !(typeloc & MATCH_LAYER) 
            && ( !(typeloc & VISIBLE_ONLY) || IsModuleLayerVisible( layer )) )
        {
            if( min(lx,ly) <= alt_min_dim )
				{	/* meilleure empreinte localisee sur autres couches */
				Altmodule = pt_module ; alt_min_dim = min(lx,ly) ;
            {   
                /* meilleure empreinte localisee sur autres couches */
                Altmodule = pt_module; 
                alt_min_dim = min(lx,ly);
            }
        }
    }
		}	/* fin boucle d'examen des modules */

    if( module )
    {
		return(module);
        return module;
    }

    if( Altmodule )
    {
		return(Altmodule);
        return Altmodule;
    }
	return(NULL);

    return NULL;
}


/*****************************************************************************/
TEXTE_MODULE * LocateTexteModule(BOARD * Pcb, MODULE ** PtModule, int typeloc)
/*****************************************************************************/
+6 −2
Original line number Diff line number Diff line
@@ -15,8 +15,12 @@

/* valeur de flag indicant si le pointeur de reference pour une localisation
est le curseur sur grille ou le curseur a deplacement fin hors grille */
#define CURSEUR_ON_GRILLE 0
#define CURSEUR_OFF_GRILLE 1
#define CURSEUR_ON_GRILLE   (0<<0)  
#define CURSEUR_OFF_GRILLE  (1<<1)
#define IGNORE_LOCKED       (1<<2)  ///< if module is locked, do not select for single module operation  
#define MATCH_LAYER         (1<<3)  ///< if module not on current layer, do not select 
#define VISIBLE_ONLY        (1<<4)  ///< if module not on a visible layer, do not select


#define START 0		/* ctes parametre dans les routines de localisation */
#define END 1