Commit 25973e56 authored by dickelbeck's avatar dickelbeck
Browse files

Isaac's next layer selection and configuration work step

parent 07ae1615
Loading
Loading
Loading
Loading
+144 −27
Original line number Original line Diff line number Diff line
@@ -149,7 +149,38 @@ enum ELEMENTS_NUMBERS
    PAD_CMP_VISIBLE
    PAD_CMP_VISIBLE
};
};
    
    
/**
 * Function IsValidLayerIndex
 * tests whether a given integer is a valid layer index
 * @param aLayerIndex = Layer index to test
 * @return true if aLayerIndex is a valid layer index
*/
inline bool IsValidLayerIndex( int aLayerIndex )
{
    return aLayerIndex >= 0 && aLayerIndex < NB_LAYERS;
}


/**
 * Function IsValidCopperLayerIndex
 * tests whether an integer is a valid copper layer index
 * @param aLayerIndex = Layer index to test
 * @return true if aLayerIndex is a valid copper layer index
*/
inline bool IsValidCopperLayerIndex( int aLayerIndex )
{
    return aLayerIndex >= FIRST_COPPER_LAYER && aLayerIndex <= LAST_COPPER_LAYER;
}
    
/**
 * Function IsValidNonCopperLayerIndex
 * tests whether an integer is a valid non copper layer index
 * @param aLayerIndex = Layer index to test
 * @return true if aLayerIndex is a valid non copper layer index
*/
inline bool IsValidNonCopperLayerIndex( int aLayerIndex )
{
    return aLayerIndex >= FIRST_NO_COPPER_LAYER && aLayerIndex <= LAST_NO_COPPER_LAYER;
}
    
    
// Class for handle current printed board design settings
// Class for handle current printed board design settings
class EDA_BoardDesignSettings
class EDA_BoardDesignSettings
@@ -176,25 +207,17 @@ public:
    int    m_MaskMargin;                            // Solder mask margin
    int    m_MaskMargin;                            // Solder mask margin
    int    m_LayerThickness;                        // Layer Thickness for 3D viewer
    int    m_LayerThickness;                        // Layer Thickness for 3D viewer


    // Color options for screen display of the Printed Board:
protected:
//@@IMB: Not used    int    m_PcbGridColor;                          // Grid color
    int    m_EnabledLayers;                         // Bit-mask for layer enabling

    int    m_VisibleLayers;                         // Bit-mask for layer visibility
	int    m_EnabledLayers;                         // IMB: Paving the road
    int    m_VisibleElements;                       // Bit-mask for element category visibility
	int    m_VisibleLayers;                         // IMB: Bit-mask for layer visibility
	int    m_VisibleElements;                       // IMB: Bit-mask for elements visibility


public:
    // Color options for screen display of the Printed Board:
    int    m_LayerColor[32];                        // Layer colors (tracks and graphic items)
    int    m_LayerColor[32];                        // Layer colors (tracks and graphic items)


    int    m_ViaColor[4];                           // Via color (depending on is type)
    int    m_ViaColor[4];                           // Via color (depending on is type)


//@@IMB: Not used    int    m_ModuleTextCMPColor;                // Text module color for modules on the COMPONENT layer
//@@IMB: Not used    int    m_ModuleTextCUColor;                 // Text module color for modules on the COPPER layer
//@@IMB: Not used    int    m_ModuleTextNOVColor;                // Text module color for "invisible" texts (must be BLACK if really not displayed)
//@@IMB: Not used    int    m_AnchorColor;                       // Anchor color for modules and texts

//@@IMB: Not used    int    m_PadCUColor;                        // Pad color for the COPPER side of the pad
//@@IMB: Not used    int    m_PadCMPColor;                       // Pad color for the COMPONENT side of the pad

    // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors)
    // Pad color for the pads of both sides is m_PadCUColor OR m_PadCMPColor (in terms of colors)


    int    m_RatsnestColor;                         // Ratsnest color
    int    m_RatsnestColor;                         // Ratsnest color
@@ -205,40 +228,134 @@ public:


    /**
    /**
     * Function GetVisibleLayers
     * Function GetVisibleLayers
     * returns a bit-map of all the layers that are visible.
     * returns a bit-mask of all the layers that are visible
     * @return int - the visible layers in bit-mapped form.
     * @return int - the visible layers in bit-mapped form.
     */
     */
    int GetVisibleLayers() const;
    int GetVisibleLayers() const;


    void SetVisibleLayers( int Mask );
    /**
     * Function SetVisibleLayers
     * changes the bit-mask of visible layers
     * @param aMask = The new bit-mask of visible layers
     */
    void SetVisibleLayers( int aMask );
    
    
    /**
    /**
     * Function IsLayerVisible
     * Function IsLayerVisible
     * @param LayerNumber The number of the layer to be tested.
     * tests whether a given layer is visible
     * @param aLayerIndex = The index of the layer to be tested
     * @return bool - true if the layer is visible.
     * @return bool - true if the layer is visible.
     */
     */
    inline bool IsLayerVisible( int LayerNumber ) const
    inline bool IsLayerVisible( int aLayerIndex ) const
    {
    {
        if( LayerNumber < 0 || LayerNumber >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers
        if( aLayerIndex < 0 || aLayerIndex >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers
            return false;
            return false;
        return (bool)( m_VisibleLayers & 1 << LayerNumber );
        // If a layer is disabled, it is automatically invisible
        return (bool)( m_VisibleLayers & m_EnabledLayers & 1 << aLayerIndex );
    }
    }


    void SetLayerVisibility( int LayerNumber, bool State );
    /**
     * Function SetLayerVisibility
     * changes the visibility of a given layer
     * @param aLayerIndex = The index of the layer to be changed
     * @param aNewState = The new visibility state of the layer
     */
    void SetLayerVisibility( int aLayerIndex, bool aNewState );

    /**
     * Function GetVisibleElements
     * returns a bit-mask of all the element categories that are visible
     * @return int - the visible element categories in bit-mapped form.
     */
    inline int GetVisibleElements() const
    {
        return m_VisibleElements;
    }

    /**
     * Function SetVisibleElements
     * changes the bit-mask of visible element categories
     * @param aMask = The new bit-mask of visible element categories
     */
    inline void SetVisibleElements( int aMask )
    {
        m_VisibleElements = aMask;
    }
    
    
    /**
    /**
     * Function IsElementVisible
     * Function IsElementVisible
     * @param ElementNumber The number of the element to be tested.
     * tests whether a given element category is visible
     * @return bool - true if the elememt is visible.
     * @param aCategoryIndex = The index of the element category to be tested.
     * @return bool - true if the element is visible.
     */
     */
    inline bool IsElementVisible( int ElementNumber ) const
    inline bool IsElementVisible( int aCategoryIndex ) const
    {
    {
        if( ElementNumber < 0 || ElementNumber > PAD_CMP_VISIBLE )
        if( aCategoryIndex < 0 || aCategoryIndex > PAD_CMP_VISIBLE )
            return false;
            return false;
        return (bool)( m_VisibleElements & 1 << ElementNumber );
        return (bool)( m_VisibleElements & 1 << aCategoryIndex );
    }

    /**
     * Function SetElementVisibility
     * changes the visibility of an element category
     * @param aCategoryIndex = The index of the element category to be changed
     * @param aNewState = The new visibility state of the element category
     */
    void SetElementVisibility( int aCategoryIndex, bool aNewState );

    /**
     * Function GetEnabledLayers
     * returns a bit-mask of all the layers that are enabled
     * @return int - the enabled layers in bit-mapped form.
     */
    inline int GetEnabledLayers() const
    {
        return m_EnabledLayers;
    }

    /**
     * Function SetEnabledLayers
     * changes the bit-mask of enabled layers
     * @param aMask = The new bit-mask of enabled layers
     */
    void SetEnabledLayers( int aMask )
    {
        // TODO; ensure consistency with m_CopperLayerCount
        m_EnabledLayers = aMask;
        // A disabled layer cannot be visible
        m_VisibleLayers &= aMask;
    }

    /**
     * Function IsLayerEnabled
     * tests whether a given layer is enabled
     * @param aLayerIndex = The index of the layer to be tested
     * @return bool - true if the layer is enabled
     */
    inline bool IsLayerEnabled( int aLayerIndex )
    {
        return (bool)( m_EnabledLayers & 1 << aLayerIndex );
    }
    }


    void SetElementVisibility( int ElementNumber, bool State );
    /**
     * Function GetCopperLayerCount
     * @return int - the number of neabled copper layers
     */
    inline int GetCopperLayerCount() const
    {
        return m_CopperLayerCount;
    }

    /**
     * Function SetCopperLayerCount
     * do what its name says...
     * @param aNewLayerCount = The new number of enabled copper layers
     */
    inline void SetCopperLayerCount( int aNewLayerCount )
    {
        // TODO; ensure consistency with the m_EnabledLayers member
        m_CopperLayerCount = aNewLayerCount;
    }
};
};




+3 −2
Original line number Original line Diff line number Diff line
@@ -25,8 +25,8 @@ set(PCBNEW_SRCS
    cross-probing.cpp
    cross-probing.cpp
    debug_kbool_key_file_fct.cpp
    debug_kbool_key_file_fct.cpp
    deltrack.cpp
    deltrack.cpp
    dialog_copper_layers_setup_base.cpp
#    dialog_copper_layers_setup_base.cpp
    dialog_copper_layers_setup.cpp
#    dialog_copper_layers_setup.cpp
    dialog_copper_zones.cpp
    dialog_copper_zones.cpp
    dialog_copper_zones_base.cpp
    dialog_copper_zones_base.cpp
    dialog_design_rules.cpp
    dialog_design_rules.cpp
@@ -50,6 +50,7 @@ set(PCBNEW_SRCS
    dialog_graphic_item_properties.cpp
    dialog_graphic_item_properties.cpp
    dialog_graphic_item_properties_base.cpp
    dialog_graphic_item_properties_base.cpp
#   dialog_initpcb.cpp
#   dialog_initpcb.cpp
    dialog_layers_setup.cpp
    dialog_netlist.cpp
    dialog_netlist.cpp
    dialog_netlist_fbp.cpp
    dialog_netlist_fbp.cpp
    dialog_pcb_text_properties.cpp
    dialog_pcb_text_properties.cpp
+64 −22
Original line number Original line Diff line number Diff line
@@ -129,9 +129,11 @@ BOARD::~BOARD()


wxString BOARD::GetLayerName( int aLayerIndex ) const
wxString BOARD::GetLayerName( int aLayerIndex ) const
{
{
    if( ! IsValidLayerIndex( aLayerIndex ))
        return wxEmptyString;

    // copper layer names are stored in the BOARD.
    // copper layer names are stored in the BOARD.
    if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount()
    if( IsValidCopperLayerIndex( aLayerIndex ) && m_BoardSettings->IsLayerEnabled( aLayerIndex ))
       || aLayerIndex == LAST_COPPER_LAYER )
    {
    {
        // default names were set in BOARD::BOARD() but they may be
        // default names were set in BOARD::BOARD() but they may be
        // over-ridden by BOARD::SetLayerName()
        // over-ridden by BOARD::SetLayerName()
@@ -144,9 +146,9 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const


bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
{
{
    if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount()
    if( ! IsValidCopperLayerIndex( aLayerIndex ))
       || aLayerIndex==LAST_COPPER_LAYER )
        return false;
    {

    if( aLayerName == wxEmptyString  || aLayerName.Len() > 20 )
    if( aLayerName == wxEmptyString  || aLayerName.Len() > 20 )
        return false;
        return false;


@@ -154,20 +156,20 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
    if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND )
    if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND )
        return false;
        return false;


        // ensure unique-ness of layer names
    wxString NameTemp = aLayerName;
        for( int layer = 0;  layer<GetCopperLayerCount() || layer==LAST_COPPER_LAYER;  )

    // replace any spaces with underscores before we do any comparing
    NameTemp.Replace( wxT( " " ), wxT( "_" ) );

    if( m_BoardSettings->IsLayerEnabled( aLayerIndex ))
    {
    {
            if( layer!=aLayerIndex && aLayerName == m_Layer[layer].m_Name )
        for( int i = 0; i < NB_COPPER_LAYERS; i++ )
        {
            if( i != aLayerIndex && m_BoardSettings->IsLayerEnabled( i ) && NameTemp == m_Layer[i].m_Name )
                return false;
                return false;

            if( ++layer == GetCopperLayerCount() )
                layer = LAST_COPPER_LAYER;
        }
        }


        m_Layer[aLayerIndex].m_Name = aLayerName;
        m_Layer[aLayerIndex].m_Name = NameTemp;

        // replace any spaces with underscores
        m_Layer[aLayerIndex].m_Name.Replace( wxT( " " ), wxT( "_" ) );


        return true;
        return true;
    }
    }
@@ -178,7 +180,12 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )


LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
{
{
    if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() )
    if( ! IsValidCopperLayerIndex( aLayerIndex ))
        return LT_SIGNAL;

    //@@IMB: The original test was broken due to the discontinuity
    // in the layer sequence.
    if( m_BoardSettings->IsLayerEnabled( aLayerIndex ))
        return m_Layer[aLayerIndex].m_Type;
        return m_Layer[aLayerIndex].m_Type;
    return LT_SIGNAL;
    return LT_SIGNAL;
}
}
@@ -186,7 +193,12 @@ LAYER_T BOARD::GetLayerType( int aLayerIndex ) const


bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType )
bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType )
{
{
    if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() )
    if( ! IsValidCopperLayerIndex( aLayerIndex ))
        return false;

    //@@IMB: The original test was broken due to the discontinuity
    // in the layer sequence.
    if( m_BoardSettings->IsLayerEnabled( aLayerIndex ))
    {
    {
        m_Layer[aLayerIndex].m_Type = aLayerType;
        m_Layer[aLayerIndex].m_Type = aLayerType;
        return true;
        return true;
@@ -239,6 +251,36 @@ int BOARD::GetCopperLayerCount() const
    return m_BoardSettings->m_CopperLayerCount;
    return m_BoardSettings->m_CopperLayerCount;
}
}


int BOARD::GetEnabledLayers() const
{
    return m_BoardSettings->GetEnabledLayers();
}

int BOARD::GetVisibleLayers() const
{
    return m_BoardSettings->GetVisibleLayers();
}

void BOARD::SetEnabledLayers( int aLayerMask )
{
    m_BoardSettings->SetEnabledLayers( aLayerMask );
}

void BOARD::SetVisibleLayers( int aLayerMask )
{
    m_BoardSettings->SetVisibleLayers( aLayerMask );
}

void BOARD::SetVisibleElements( int aMask )
{
    m_BoardSettings->SetVisibleElements( aMask );
}

int  BOARD::GetVisibleElements() const
{
    return m_BoardSettings->GetVisibleElements();
}



wxPoint& BOARD::GetPosition()
wxPoint& BOARD::GetPosition()
{
{
+53 −4
Original line number Original line Diff line number Diff line
@@ -207,6 +207,55 @@ public:
     */
     */
    int      GetCopperLayerCount() const;
    int      GetCopperLayerCount() const;


    /**
     * Function GetEnabledLayers
     * is a proxy function that calls the correspondent function in m_BoardSettings
     * Returns a bit-mask of all the layers that are enabled
     * @return int - the enabled layers in bit-mapped form.
     */
    int GetEnabledLayers() const;

    /**
     * Function GetVisibleLayers
     * is a proxy function that calls the correspondent function in m_BoardSettings
     * Returns a bit-mask of all the layers that are visible
     * @return int - the visible layers in bit-mapped form.
     */
    int GetVisibleLayers() const;

    /**
     * Function SetEnabledLayers
     * is a proxy function that calls the correspondent function in m_BoardSettings
     * Changes the bit-mask of enabled layers
     * @param aMask = The new bit-mask of enabled layers
     */
    void SetEnabledLayers( int aLayerMask );

    /**
     * Function SetVisibleLayers
     * is a proxy function that calls the correspondent function in m_BoardSettings
     * changes the bit-mask of visible layers
     * @param aMask = The new bit-mask of visible layers
     */
    void SetVisibleLayers( int aLayerMask );

    /**
     * Function SetVisibleElements
     * is a proxy function that calls the correspondent function in m_BoardSettings
     * changes the bit-mask of visible element categories
     * @param aMask = The new bit-mask of visible element categories
     */
    void SetVisibleElements( int aMask );

    /**
     * Function GetVisibleElements
     * is a proxy function that calls the correspondent function in m_BoardSettings
     * returns a bit-mask of all the element categories that are visible
     * @return int - the visible element categories in bit-mapped form.
     */
    int  GetVisibleElements() const;


    /**
    /**
     * Function GetLayerName
     * Function GetLayerName
     * returns the name of the copper layer given by aLayerIndex.
     * returns the name of the copper layer given by aLayerIndex.
+33 −50
Original line number Original line Diff line number Diff line
@@ -222,7 +222,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()


//@@IMB: Not used    m_PcbGridColor = DARKGRAY;                      // Grid color
//@@IMB: Not used    m_PcbGridColor = DARKGRAY;                      // Grid color


    m_EnabledLayers     = 0x1fffffff;               // IMB: All layers enabled at first. TODO: Use a macro for the initial value.
    m_EnabledLayers     = ALL_LAYERS;               // All layers enabled at first.
    m_VisibleLayers     = 0xffffffff;               // IMB: All layers visible at first. TODO: Use a macro for the initial value.
    m_VisibleLayers     = 0xffffffff;               // IMB: All layers visible at first. TODO: Use a macro for the initial value.
    m_VisibleElements   = 0x00000fff;               // IMB: All elements visible at first. TODO: Use a macro for the initial value.
    m_VisibleElements   = 0x00000fff;               // IMB: All elements visible at first. TODO: Use a macro for the initial value.


@@ -252,45 +252,28 @@ int EDA_BoardDesignSettings::GetVisibleLayers() const
    return m_VisibleLayers;
    return m_VisibleLayers;
}
}


void EDA_BoardDesignSettings::SetVisibleLayers( int Mask )
void EDA_BoardDesignSettings::SetVisibleLayers( int aMask )
{
{
    m_VisibleLayers = Mask & 0x1fffffff;
    m_VisibleLayers = aMask & m_EnabledLayers & ALL_LAYERS;
}
}


/* //@@IMB: Made inline
void EDA_BoardDesignSettings::SetLayerVisibility( int aLayerIndex, bool aNewState )
bool EDA_BoardDesignSettings::IsLayerVisible( int LayerNumber ) const
{
{
    if( LayerNumber < 0 || LayerNumber >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers
    // Altough Pcbnew uses only 29, Gerbview uses all 32 layers
        return false;
    if( aLayerIndex < 0 || aLayerIndex >= 32 )
    return (bool)( m_VisibleLayers & 1 << LayerNumber );
}
*/

void EDA_BoardDesignSettings::SetLayerVisibility( int LayerNumber, bool State )
{
    if( LayerNumber < 0 || LayerNumber >= 32 ) //@@IMB: Altough Pcbnew uses only 29, Gerbview uses all 32 layers
        return;
        return;
    if( State )
    if( aNewState && IsLayerEnabled( aLayerIndex ))
        m_VisibleLayers |= 1 << LayerNumber;
        m_VisibleLayers |= 1 << aLayerIndex;
    else
    else
        m_VisibleLayers &= ~( 1 << LayerNumber );
        m_VisibleLayers &= ~( 1 << aLayerIndex );
}
}


/* //@@IMB: Made inline
void EDA_BoardDesignSettings::SetElementVisibility( int aElementCategory, bool aNewState )
bool EDA_BoardDesignSettings::IsElementVisible( int ElementNumber ) const
{
    if( ElementNumber < 0 || ElementNumber > PAD_CMP_VISIBLE )
        return false;
    return (bool)( m_VisibleElements & 1 << ElementNumber );
}
*/

void EDA_BoardDesignSettings::SetElementVisibility( int ElementNumber, bool State )
{
{
    if( ElementNumber < 0 || ElementNumber > PAD_CMP_VISIBLE )
    if( aElementCategory < 0 || aElementCategory > PAD_CMP_VISIBLE )
        return;
        return;
    if( State )
    if( aNewState )
        m_VisibleElements |= 1 << ElementNumber;
        m_VisibleElements |= 1 << aElementCategory;
    else
    else
        m_VisibleElements &= ~( 1 << ElementNumber );
        m_VisibleElements &= ~( 1 << aElementCategory );
}
}
Loading