Commit 58fc9d8f authored by dickelbeck's avatar dickelbeck

layer widget incorporation into pcbnew

parent c4bc7bb4
......@@ -5,6 +5,8 @@
#ifndef _BOARD_DESIGN_SETTING_H
#define _BOARD_DESIGN_SETTING_H
#include "pcbstruct.h" // NB_COLORS
// Class for handle current printed board design settings
class EDA_BoardDesignSettings
{
......@@ -38,7 +40,7 @@ protected:
public:
// Color options for screen display of the Printed Board:
int m_LayerColor[32]; // Layer colors (tracks and graphic items)
int m_LayerColor[NB_LAYERS]; ///< Layer colors (tracks and graphic items)
int m_ViaColor[4]; // Via color (depending on is type)
......@@ -120,7 +122,7 @@ public:
{
if( aCategoryIndex < 0 || aCategoryIndex > PAD_CMP_VISIBLE )
return false;
return (bool) ( m_VisibleElements & 1 << aCategoryIndex );
return (bool) ( m_VisibleElements & (1 << aCategoryIndex) );
}
......@@ -179,6 +181,34 @@ public:
* @param aNewLayerCount = The new number of enabled copper layers
*/
void SetCopperLayerCount( int aNewLayerCount );
/**
* Function GetLayerColor
* returns the color for aLayer which is one of the layer indices given
* in pcbstruct.h
*/
int GetLayerColor( int aLayer )
{
if( (unsigned) aLayer < (unsigned) NB_LAYERS )
{
return m_LayerColor[aLayer];
}
return -1;
}
/**
* Function SetLayerColor
* sets the color for aLayer which is one of the layer indices given
* in pcbstruct.h
*/
void SetLayerColor( int aLayer, int aColor )
{
if( (unsigned) aLayer < (unsigned) NB_LAYERS )
{
m_LayerColor[aLayer] = aColor;
}
}
};
......
......@@ -56,7 +56,8 @@ struct KEYWORD
* to the parser if it wants also to support them.
*/
enum DSN_SYNTAX_T {
DSN_NONE = -10,
DSN_NONE = -11,
DSN_COMMENT = -10,
DSN_STRING_QUOTE = -9,
DSN_QUOTE_DEF = -8,
DSN_DASH = -7,
......@@ -84,6 +85,7 @@ class DSNLEXER
LINE_READER reader;
int stringDelimiter;
bool space_in_quoted_tokens; ///< blank spaces within quoted strings
bool comments_are_tokens; ///< true if should return comments as tokens
wxString filename;
int prevTok; ///< curTok from previous NextTok() call.
......@@ -108,6 +110,18 @@ class DSNLEXER
}
/**
* Function readLineOrCmt
* reads a line from the LINE_READER and returns either:
* <ol>
* <li> a positive line length (a +1 if empty line)
* <li> zero of end of file.
* <li> DSN_COMMENT if the line is a comment
* </ol>
*/
int readLineOrCmt();
/**
* Function findToken
* takes a string and looks up the string in the list of expected
......@@ -172,6 +186,19 @@ public:
return old;
}
/**
* Function SetCommentsAreTokens
* changes the handling of comments. If set true, comments are returns
* as single line strings with a terminating newline, else they are
* consumed by the lexer and not returned.
*/
bool SetCommentsAreTokens( bool val )
{
bool old = comments_are_tokens;
comments_are_tokens = val;
return old;
}
/**
* Function NextTok
......
......@@ -55,14 +55,14 @@
#define NB_COPPER_LAYERS (LAST_COPPER_LAYER + 1)
#define FIRST_NO_COPPER_LAYER 16
#define ADHESIVE_N_BACK 16
#define ADHESIVE_N_FRONT 17
#define SOLDERPASTE_N_BACK 18
#define SOLDERPASTE_N_FRONT 19
#define SILKSCREEN_N_BACK 20
#define SILKSCREEN_N_FRONT 21
#define SOLDERMASK_N_BACK 22
#define SOLDERMASK_N_FRONT 23
#define ADHESIVE_N_BACK 16
#define ADHESIVE_N_FRONT 17
#define SOLDERPASTE_N_BACK 18
#define SOLDERPASTE_N_FRONT 19
#define SILKSCREEN_N_BACK 20
#define SILKSCREEN_N_FRONT 21
#define SOLDERMASK_N_BACK 22
#define SOLDERMASK_N_FRONT 23
#define DRAW_N 24
#define COMMENT_N 25
#define ECO1_N 26
......
......@@ -6,10 +6,9 @@
#define WXPCB_STRUCT_H
#include <vector>
#include "wxstruct.h"
#include "base_struct.h"
#include "layer_widget.h"
#ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000
......@@ -50,6 +49,46 @@ class GENERAL_COLLECTORS_GUIDE;
/*****************************************************/
class WinEDA_PcbFrame : public WinEDA_BasePcbFrame
{
protected:
/**
* Class LYRS
* is here to implement the abtract functions of LAYER_WIDGET so they
* may be tied into this frame's data.
*/
class LYRS : public LAYER_WIDGET
{
WinEDA_PcbFrame* myframe;
public:
LYRS( WinEDA_PcbFrame* aParent ) :
LAYER_WIDGET( aParent ),
myframe( aParent )
{
}
//-----<implement LAYER_WIDGET abstract functions>---
void OnLayerColorChange( int aLayer, int aColor );
bool OnLayerSelect( int aLayer );
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
void OnRenderColorChange( int aId, int aColor );
void OnRenderEnable( int aId, bool isEnabled );
//-----</implement LAYER_WIDGET abstract functions>---------------
};
/// render rows are fixed, layer rows are dynamically determined.
static LAYER_WIDGET::ROW renderRows[];
LYRS* m_Layers; // established in constructor
/**
* Function ReFillLayerWidget
* changes out all the layers in m_Layers and may be called upon
* loading a new BOARD.
*/
void ReFillLayerWidget();
public:
WinEDAChoiceBox* m_SelLayerBox; // a combo box to display and
// select active layer
......@@ -323,7 +362,17 @@ public:
void OnFileHistory( wxCommandEvent& event );
void Files_io( wxCommandEvent& event );
bool LoadOnePcbFile( const wxString& FileName, bool Append );
/**
* Function ReadPcbFile
* reads a board file <file>.brd
* @param Append if 0: a previously loaded board is deleted before loading
* the file else all items of the board file are added to the
* existing board
*/
int ReadPcbFile( FILE* File, bool Append );
bool SavePcbFile( const wxString& FileName );
int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( FILE* File );
......
......@@ -9,9 +9,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
# on other targets this should be as normal
##
if(APPLE)
set(PCBNEW_NAME PCBNew)
set(PCBNEW_NAME PCBNew)
else(APPLE)
set(PCBNEW_NAME pcbnew)
set(PCBNEW_NAME pcbnew)
endif(APPLE)
# Many of the commented out ones are nested in *.cpp files for dialogs
......@@ -111,6 +111,8 @@ set(PCBNEW_SRCS
ioascii.cpp
print_board_functions.cpp
printout_controler.cpp
layer_panel_base.cpp
layer_widget.cpp
librairi.cpp
loadcmp.cpp
locate.cpp
......
......@@ -209,36 +209,36 @@ wxString BOARD::GetDefaultLayerName( int aLayerNumber )
// Use a switch to explicitly show the mapping more clearly
switch( aLayerNumber )
{
case LAYER_N_FRONT: txt = _( "Front" ); break;
case LAYER_N_2: txt = _( "Inner2" ); break;
case LAYER_N_3: txt = _( "Inner3" ); break;
case LAYER_N_4: txt = _( "Inner4" ); break;
case LAYER_N_5: txt = _( "Inner5" ); break;
case LAYER_N_6: txt = _( "Inner6" ); break;
case LAYER_N_7: txt = _( "Inner7" ); break;
case LAYER_N_8: txt = _( "Inner8" ); break;
case LAYER_N_9: txt = _( "Inner9" ); break;
case LAYER_N_10: txt = _( "Inner10" ); break;
case LAYER_N_11: txt = _( "Inner11" ); break;
case LAYER_N_12: txt = _( "Inner12" ); break;
case LAYER_N_13: txt = _( "Inner13" ); break;
case LAYER_N_14: txt = _( "Inner14" ); break;
case LAYER_N_15: txt = _( "Inner15" ); break;
case LAYER_N_BACK: txt = _( "Back" ); break;
case ADHESIVE_N_BACK: txt = _( "Adhes_Back" ); break;
case ADHESIVE_N_FRONT: txt = _( "Adhes_Front" ); break;
case SOLDERPASTE_N_BACK: txt = _( "SoldP_Back" ); break;
case SOLDERPASTE_N_FRONT: txt = _( "SoldP_Front" ); break;
case SILKSCREEN_N_BACK: txt = _( "SilkS_Back" ); break;
case SILKSCREEN_N_FRONT: txt = _( "SilkS_Front" ); break;
case SOLDERMASK_N_BACK: txt = _( "Mask_Back" ); break;
case SOLDERMASK_N_FRONT: txt = _( "Mask_Front" ); break;
case DRAW_N: txt = _( "Drawings" ); break;
case COMMENT_N: txt = _( "Comments" ); break;
case ECO1_N: txt = _( "Eco1" ); break;
case ECO2_N: txt = _( "Eco2" ); break;
case EDGE_N: txt = _( "PCB_Edges" ); break;
default: txt = _( "BAD INDEX" ); break;
case LAYER_N_FRONT: txt = _( "Front" ); break;
case LAYER_N_2: txt = _( "Inner2" ); break;
case LAYER_N_3: txt = _( "Inner3" ); break;
case LAYER_N_4: txt = _( "Inner4" ); break;
case LAYER_N_5: txt = _( "Inner5" ); break;
case LAYER_N_6: txt = _( "Inner6" ); break;
case LAYER_N_7: txt = _( "Inner7" ); break;
case LAYER_N_8: txt = _( "Inner8" ); break;
case LAYER_N_9: txt = _( "Inner9" ); break;
case LAYER_N_10: txt = _( "Inner10" ); break;
case LAYER_N_11: txt = _( "Inner11" ); break;
case LAYER_N_12: txt = _( "Inner12" ); break;
case LAYER_N_13: txt = _( "Inner13" ); break;
case LAYER_N_14: txt = _( "Inner14" ); break;
case LAYER_N_15: txt = _( "Inner15" ); break;
case LAYER_N_BACK: txt = _( "Back" ); break;
case ADHESIVE_N_BACK: txt = _( "Adhes_Back" ); break;
case ADHESIVE_N_FRONT: txt = _( "Adhes_Front" ); break;
case SOLDERPASTE_N_BACK: txt = _( "SoldP_Back" ); break;
case SOLDERPASTE_N_FRONT: txt = _( "SoldP_Front" ); break;
case SILKSCREEN_N_BACK: txt = _( "SilkS_Back" ); break;
case SILKSCREEN_N_FRONT: txt = _( "SilkS_Front" ); break;
case SOLDERMASK_N_BACK: txt = _( "Mask_Back" ); break;
case SOLDERMASK_N_FRONT: txt = _( "Mask_Front" ); break;
case DRAW_N: txt = _( "Drawings" ); break;
case COMMENT_N: txt = _( "Comments" ); break;
case ECO1_N: txt = _( "Eco1" ); break;
case ECO2_N: txt = _( "Eco2" ); break;
case EDGE_N: txt = _( "PCB_Edges" ); break;
default: txt = _( "BAD INDEX" ); break;
}
return wxString( txt );
......@@ -351,11 +351,14 @@ LAYER_T LAYER::ParseType( const char* aType )
return LAYER_T( -1 );
}
int BOARD::GetCopperLayerCount() const
{
return m_BoardSettings->GetCopperLayerCount();
}
void BOARD::SetCopperLayerCount( int aCount )
{
m_BoardSettings->SetCopperLayerCount( aCount );
}
int BOARD::GetEnabledLayers() const
......@@ -393,6 +396,16 @@ int BOARD::GetVisibleElements() const
return m_BoardSettings->GetVisibleElements();
}
void BOARD::SetLayerColor( int aLayer, int aColor )
{
m_BoardSettings->SetLayerColor( aLayer, aColor );
}
int BOARD::GetLayerColor( int aLayer )
{
return m_BoardSettings->GetLayerColor( aLayer );
}
wxPoint& BOARD::GetPosition()
{
......
......@@ -87,6 +87,7 @@ public:
}
};
/**
* Class BOARD
* holds information pertinent to a PCBNEW printed circuit board.
......@@ -245,7 +246,10 @@ public:
* Function GetCopperLayerCount
* @return int - The number of copper layers in the BOARD.
*/
int GetCopperLayerCount() const;
int GetCopperLayerCount() const;
void SetCopperLayerCount( int aCount );
/**
* Function GetEnabledLayers
......@@ -255,14 +259,6 @@ public:
*/
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
......@@ -272,20 +268,20 @@ public:
void SetEnabledLayers( int aLayerMask );
/**
* Function SetVisibleLayers
* Function GetVisibleLayers
* 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
* Returns a bit-mask of all the layers that are visible
* @return int - the visible layers in bit-mapped form.
*/
void SetVisibleLayers( int aLayerMask );
int GetVisibleLayers() const;
/**
* Function SetVisibleElements
* Function SetVisibleLayers
* 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
* changes the bit-mask of visible layers
* @param aMask = The new bit-mask of visible layers
*/
void SetVisibleElements( int aMask );
void SetVisibleLayers( int aLayerMask );
/**
* Function GetVisibleElements
......@@ -295,10 +291,17 @@ public:
*/
int GetVisibleElements() const;
/**
* 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 GetLayerName
* returns the name of the copper layer given by aLayerIndex.
* returns the name of the layer given by aLayerIndex.
*
* @param aLayerIndex A layer index, like LAYER_N_BACK, etc.
* @return wxString - the layer name.
......@@ -336,6 +339,13 @@ public:
*/
bool SetLayerType( int aLayerIndex, LAYER_T aLayerType );
/**
* Function SetLayerColor
* changes a layer color for any valid layer, including non-copper ones.
*/
void SetLayerColor( int aLayer, int aColor );
int GetLayerColor( int aLayer );
/* Functions to get some items count */
int GetNumSegmTrack();
......
......@@ -85,7 +85,7 @@ int EDA_BoardDesignSettings::GetVisibleLayers() const
void EDA_BoardDesignSettings::SetVisibleLayers( int aMask )
{
// Altough Pcbnew uses only 29, Gerbview uses all 32 layers
// Although Pcbnew uses only 29, Gerbview uses all 32 layers
m_VisibleLayers = aMask & m_EnabledLayers & FULL_LAYERS;
}
......@@ -115,6 +115,8 @@ void EDA_BoardDesignSettings::SetElementVisibility( int aElementCategory, bool a
void EDA_BoardDesignSettings::SetCopperLayerCount( int aNewLayerCount )
{
// if( aNewLayerCount < 2 ) aNewLayerCount = 2;
m_CopperLayerCount = aNewLayerCount;
// ensure consistency with the m_EnabledLayers member
......@@ -135,23 +137,20 @@ void EDA_BoardDesignSettings::SetCopperLayerCount( int aNewLayerCount )
*/
void EDA_BoardDesignSettings::SetEnabledLayers( int aMask )
{
// Back and front layers are always enabled.
aMask |= LAYER_BACK | LAYER_FRONT;
m_EnabledLayers = aMask;
// Ensure consistency with m_CopperLayerCount
long enabledLayers = aMask & ~ALL_CU_LAYERS;
// Back and front layers are always existing (but not necessary enabled)
// so we must count them
enabledLayers |= LAYER_BACK|LAYER_FRONT;
// A disabled layer cannot be visible
m_VisibleLayers &= aMask;
long mask = 1;
// update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
m_CopperLayerCount = 0;
for( int ii = 0; ii < NB_COPPER_LAYERS; ii++, mask <<= 1 )
for( int ii = 0; aMask && ii < NB_COPPER_LAYERS; ii++, aMask >>= 1 )
{
if( (aMask & mask) )
m_CopperLayerCount ++;
if( aMask & 1 )
m_CopperLayerCount++;
}
// A disabled layer cannot be visible
m_VisibleLayers &= aMask;
}
......@@ -254,6 +254,9 @@ this file again."));
// Update info shown by the horizontal toolbars
GetBoard()->SetCurrentNetClass( NETCLASS::Default );
m_TrackAndViasSizesList_Changed = true;
ReFillLayerWidget();
ReCreateLayerBox( NULL );
AuxiliaryToolBar_Update_UI();
......
......@@ -176,13 +176,18 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery )
GetScreen()->SetGrid( gridsize );
g_HightLigt_Status = 0;
// Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
g_DesignSettings.SetEnabledLayers(ALL_LAYERS);
GetBoard()->SetEnabledLayers(ALL_LAYERS);
// Default copper layers count set to 2: double layer board
g_DesignSettings.SetCopperLayerCount(2);
GetBoard()->SetCopperLayerCount(2);
// Update display:
g_DesignSettings.SetVisibleLayers( ALL_LAYERS );
GetBoard()->SetVisibleLayers( ALL_LAYERS );
ReFillLayerWidget();
SetToolbars();
Zoom_Automatique( true );
......
......@@ -900,12 +900,6 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
}
/** ReadPcbFile
* Read a board file <file>.brd
* @param Append if 0: a previously loaded board is deleted before loading
* the file else all items of the board file are added to the
* existing board
*/
int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
{
char Line[1024];
......
......@@ -29,10 +29,17 @@
*/
#define STAND_ALONE 1 // define to enable test program for LAYER_WIDGET
//#define STAND_ALONE 1 // define to enable test program for LAYER_WIDGET
// also enable KICAD_AUIMANAGER and KICAD_AUITOOLBAR in ccmake to
// build this test program
#include <wx/wx.h>
#include <wx/statbmp.h>
#include "macros.h"
#include "common.h"
#include "colors.h"
#include "layer_widget.h"
#include "pcbstruct.h" // IsValidCopperLayerIndex()
......@@ -41,6 +48,11 @@
#define LYR_COLUMN_COUNT 4 ///< Layer tab column count
#define RND_COLUMN_COUNT 2 ///< Rendering tab column count
#define BUTT_SIZE_X 32
#define BUTT_SIZE_Y 22
#define BUTT_VOID 6
#define ID_SHOW_ALL_COPPERS wxID_HIGHEST
#define ID_SHOW_NO_COPPERS (wxID_HIGHEST+1)
......@@ -120,9 +132,9 @@ static int getDecodedId( int aControlId )
*/
static wxString makeColorTxt( int aColor )
{
char colorValue[64];
sprintf( colorValue, "0x%08x", aColor );
return wxString( CONV_FROM_UTF8(colorValue) );
wxString txt;
txt.Printf( wxT("0x%08x"), aColor );
return txt;
}
......@@ -200,10 +212,7 @@ void LAYER_WIDGET::OnLeftDownLayers( wxMouseEvent& event )
SelectLayerRow( row );
}
/**
* Function OnMiddleDownLayerColor
* is called only from a color button when user right clicks.
*/
void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& event )
{
wxBitmapButton* eventSource = (wxBitmapButton*) event.GetEventObject();
......@@ -228,10 +237,6 @@ void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& event )
}
/**
* Function OnRightDownLayers
* puts up a popup menu for the layer panel.
*/
void LAYER_WIDGET::OnRightDownLayers( wxMouseEvent& event )
{
wxMenu menu;
......@@ -262,7 +267,19 @@ void LAYER_WIDGET::OnPopupSelection( wxCommandEvent& event )
case ID_SHOW_NO_COPPERS:
visible = false;
L_change_coppers:
int lastCu = -1;
rowCount = GetLayerRowCount();
for( int row=rowCount-1; row>=0; --row )
{
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row*LYR_COLUMN_COUNT + 3 );
int layer = getDecodedId( cb->GetId() );
if( IsValidCopperLayerIndex( layer ) )
{
lastCu = row;
break;
}
}
for( int row=0; row<rowCount; ++row )
{
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row*LYR_COLUMN_COUNT + 3 );
......@@ -271,7 +288,13 @@ void LAYER_WIDGET::OnPopupSelection( wxCommandEvent& event )
if( IsValidCopperLayerIndex( layer ) )
{
cb->SetValue( visible );
OnLayerVisible( layer, visible );
bool isLastCopperLayer = (row==lastCu);
OnLayerVisible( layer, visible, isLastCopperLayer );
if( isLastCopperLayer )
break;
}
}
break;
......@@ -279,11 +302,6 @@ void LAYER_WIDGET::OnPopupSelection( wxCommandEvent& event )
}
/**
* Function OnLayerCheckBox
* handles the "is layer visible" checkbox and propogates the
* event to the client's notification function.
*/
void LAYER_WIDGET::OnLayerCheckBox( wxCommandEvent& event )
{
wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
......@@ -323,14 +341,6 @@ void LAYER_WIDGET::OnRenderCheckBox( wxCommandEvent& event )
}
/**
* Function getLayerComp
* returns the component within the m_LayersFlexGridSizer at aSizerNdx or
* NULL if \a aSizerNdx is out of range.
*
* @param aSizerNdx is the 0 based index into all the wxWindows which have
* been added to the m_LayersFlexGridSizer.
*/
wxWindow* LAYER_WIDGET::getLayerComp( int aSizerNdx )
{
if( (unsigned) aSizerNdx < m_LayersFlexGridSizer->GetChildren().GetCount() )
......@@ -338,10 +348,7 @@ wxWindow* LAYER_WIDGET::getLayerComp( int aSizerNdx )
return NULL;
}
/**
* Function findLayerRow
* returns the row index that \a aLayer resides in, or -1 if not found.
*/
int LAYER_WIDGET::findLayerRow( int aLayer )
{
int count = GetLayerRowCount();
......@@ -356,10 +363,7 @@ int LAYER_WIDGET::findLayerRow( int aLayer )
return -1;
}
/**
* Function insertLayerRow
* appends or inserts a new row in the layer portion of the widget.
*/
void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
{
wxASSERT( aRow >= 0 && aRow < MAX_LAYER_ROWS );
......@@ -402,6 +406,7 @@ void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
m_LayersFlexGridSizer->Insert( index+col, cb, 0, flags );
}
void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
{
wxASSERT( aRow >= 0 && aRow < MAX_LAYER_ROWS );
......@@ -421,7 +426,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
// could add a left click handler on the color button that toggles checkbox.
}
else // no color selection wanted
else // == -1, no color selection wanted
{
// need a place holder within the sizer to keep grid full.
wxPanel* invisible = new wxPanel( m_RenderScrolledWindow );
......@@ -441,7 +446,6 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
//-----<public>-------------------------------------------------------
/** Constructor */
LAYER_WIDGET::LAYER_WIDGET( wxWindow* parent ) :
LAYER_PANEL_BASE( parent )
{
......@@ -554,13 +558,13 @@ void LAYER_WIDGET::AppendLayerRow( const ROW& aRow )
{
int nextRow = GetLayerRowCount();
insertLayerRow( nextRow, aRow );
FitInside();
UpdateLayouts();
}
void LAYER_WIDGET::ClearLayerRows()
{
m_LayerScrolledWindow->DestroyChildren();
m_LayersFlexGridSizer->Clear( true );
}
......@@ -568,13 +572,13 @@ void LAYER_WIDGET::AppendRenderRow( const ROW& aRow )
{
int nextRow = GetRenderRowCount();
insertRenderRow( nextRow, aRow );
FitInside();
UpdateLayouts();
}
void LAYER_WIDGET::ClearRenderRows()
{
m_RenderScrolledWindow->DestroyChildren();
m_RenderFlexGridSizer->Clear( true );
}
......@@ -641,9 +645,17 @@ void LAYER_WIDGET::SetLayerVisible( int aLayer, bool isVisible )
}
}
void LAYER_WIDGET::UpdateLayouts()
{
m_LayersFlexGridSizer->Layout();
m_RenderFlexGridSizer->Layout();
}
#if defined(STAND_ALONE)
#include <wx/aui/aui.h>
/**
* Class MYFRAME
* is a test class here to exercise the LAYER_WIDGET and explore use cases.
......@@ -687,9 +699,9 @@ class MYFRAME : public wxFrame
return true;
}
void OnLayerVisible( int aLayer, bool isVisible )
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{
printf( "OnLayerVisible( aLayer:%d, isVisible:%d )\n", aLayer, isVisible );
printf( "OnLayerVisible( aLayer:%d, isVisible:%d isFinal:%d)\n", aLayer, isVisible, isFinal );
}
void OnRenderColorChange( int aId, int aColor )
......@@ -715,15 +727,23 @@ public:
MYLAYERS* lw = new MYLAYERS( this, this );
// add some layer rows
lw->AppendLayerRow( LAYER_WIDGET::ROW( wxT("layer 1"), 0, RED, _("RED"), false ) );
lw->AppendLayerRow( LAYER_WIDGET::ROW( wxT("layer 2"), 1, GREEN, _("GREEN"), true ) );
lw->AppendLayerRow( LAYER_WIDGET::ROW( wxT("brown_layer"), 2, BROWN, _("BROWN"), true ) );
lw->AppendLayerRow( LAYER_WIDGET::ROW( wxT("layer_4_you"), 3, BLUE, _("BLUE"), false ) );
static const LAYER_WIDGET::ROW layerRows[] = {
LAYER_WIDGET::ROW( wxT("layer 1"), 0, RED, _("RED"), false ),
LAYER_WIDGET::ROW( wxT("layer 2"), 1, GREEN, _("GREEN"), true ),
LAYER_WIDGET::ROW( wxT("brown_layer"), 2, BROWN, _("BROWN"), true ),
LAYER_WIDGET::ROW( wxT("layer_4_you"), 3, BLUE, _("BLUE"), false ),
};
lw->AppendLayerRows( layerRows, DIM(layerRows) );
// add some render rows
lw->AppendRenderRow( LAYER_WIDGET::ROW( wxT("With Very Large Ears"), 0, -1, _("Spock here") ) );
lw->AppendRenderRow( LAYER_WIDGET::ROW( wxT("With Legs"), 1, YELLOW ) );
lw->AppendRenderRow( LAYER_WIDGET::ROW( wxT("With Oval Eyes"), 1, BROWN, _("My eyes are upon you") ) );
static const LAYER_WIDGET::ROW renderRows[] = {
LAYER_WIDGET::ROW( wxT("With Very Large Ears"), 0, -1, _("Spock here") ),
LAYER_WIDGET::ROW( wxT("With Legs"), 1, YELLOW ),
LAYER_WIDGET::ROW( wxT("With Oval Eyes"), 1, BROWN, _("My eyes are upon you") ),
};
lw->AppendRenderRows( renderRows, DIM(renderRows) );
lw->SelectLayerRow( 1 );
......
......@@ -25,20 +25,7 @@
#ifndef LAYERWIDGET_H_
#define LAYERWIDGET_H_
#include <wx/wx.h>
#include <wx/statbmp.h>
#include <wx/aui/aui.h>
#include "macros.h"
#include "common.h"
#include "layer_panel_base.h"
#include "colors.h"
/* no external data knowledge needed or wanted
#include "pcbnew.h"
#include "wxPcbStruct.h"
*/
/**
......@@ -59,7 +46,6 @@
*/
class LAYER_WIDGET : public LAYER_PANEL_BASE
{
public:
/**
* Struct ROW
......@@ -88,11 +74,6 @@ public:
protected:
#define MAX_LAYER_ROWS 64
#define BUTT_SIZE_X 32
#define BUTT_SIZE_Y 22
#define BUTT_VOID 6
wxBitmap* m_BlankBitmap;
wxBitmap* m_RightArrowBitmap;
wxSize m_BitmapSize;
......@@ -190,6 +171,19 @@ public:
*/
void AppendLayerRow( const ROW& aRow );
#define MAX_LAYER_ROWS 64 ///< cannot append more than this number of rows
/**
* Function AppendLayerRows
* appends new rows in the layer portion of the widget. The user must
* ensure that ROW::id is unique for all existing rows on Windows.
*/
void AppendLayerRows( const ROW* aRowsArray, int aRowCount )
{
for( int row=0; row<aRowCount; ++row )
AppendLayerRow( aRowsArray[row] );
}
/**
* Function ClearLayerRows
* empties out the layer rows.
......@@ -203,6 +197,18 @@ public:
*/
void AppendRenderRow( const ROW& aRow );
/**
* Function AppendRenderRows
* appends new rows in the render portion of the widget. The user must
* ensure that ROW::id is unique for all existing rows on Windows.
*/
void AppendRenderRows( const ROW* aRowsArray, int aRowCount )
{
for( int row=0; row<aRowCount; ++row )
AppendRenderRow( aRowsArray[row] );
}
/**
* Function ClearRenderRows
* empties out the render rows.
......@@ -233,6 +239,7 @@ public:
*/
void SetLayerVisible( int aLayer, bool isVisible );
void UpdateLayouts();
//-----<abstract functions>-------------------------------------------
......@@ -254,8 +261,12 @@ public:
/**
* Function OnLayerVisible
* is called to notify client code about a layer visibility change.
*
* @param isFinal is true when this is the last of potentially several
* such calls, and can be used to decide when to update the screen only
* one time instead of several times in the midst of a multiple layer change.
*/
virtual void OnLayerVisible( int aLayer, bool isVisible ) = 0;
virtual void OnLayerVisible( int aLayer, bool isVisible, bool isFinal = true ) = 0;
/**
* Function OnRenderColorChange
......
......@@ -207,6 +207,25 @@ END_EVENT_TABLE()
///////****************************///////////:
// the fixed "Rendering" tab rows within the LAYER_WIDGET:
LAYER_WIDGET::ROW WinEDA_PcbFrame::renderRows[] = {
// text id color tooltip checked
LAYER_WIDGET::ROW( _( "Through Via"), 0, LIGHTBLUE, _("Show through vias") ),
LAYER_WIDGET::ROW( _( "Blind/Buried Via"), 1, YELLOW, _("Show blind or buried vias") ),
LAYER_WIDGET::ROW( _( "Micro Via" ), 2, BROWN, _("Show micro vias") ),
LAYER_WIDGET::ROW( _( "Ratsnets" ), 3, BLUE, _("Show the ratsnest") ),
LAYER_WIDGET::ROW( _( "Mod Text Back" ), 4, WHITE, _("Show footprint text residing on board's back") ),
LAYER_WIDGET::ROW( _( "Mod Text Front" ), 5, WHITE, _("Show footprint text residing on board's front") ),
LAYER_WIDGET::ROW( _( "Mod Text Hide" ), 6, WHITE, _("TBD") ),
LAYER_WIDGET::ROW( _( "Anchors" ), 7, WHITE, _("TBD") ),
// LAYER_WIDGET::ROW( _( "Grid" ), 8, WHITE, _("Show grid") ),
LAYER_WIDGET::ROW( _( "Not Connecteds" ), 9, -1, _("TBD") ),
LAYER_WIDGET::ROW( _( "Modules Front" ), 10, -1, _("TBD") ),
LAYER_WIDGET::ROW( _( "Modules Back" ), 11, -1, _("TBD") ),
};
WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
......@@ -223,6 +242,9 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_TrackAndViasSizesList_Changed = false;
m_show_microwave_tools = false;
m_Layers = new LYRS( this );
m_Layers->AppendRenderRows( renderRows, DIM(renderRows) );
SetBoard( new BOARD( NULL, this ) );
m_TrackAndViasSizesList_Changed = true;
......@@ -273,6 +295,15 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
vert.TopDockable( false ).BottomDockable( false );
horiz.LeftDockable( false ).RightDockable( false );
// LAYER_WIDGET is floatable, but initially docked at far right
wxAuiPaneInfo lyrs;
lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
lyrs.BestSize( m_Layers->GetBestSize() );
lyrs.CloseButton( false );
lyrs.Caption( wxT( "Layers" ) );
lyrs.IsFloatable();
if( m_HToolBar )
m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
......@@ -283,11 +314,13 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
if( m_AuxVToolBar )
m_auimgr.AddPane( m_AuxVToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_AuxVToolBar" ) ).Right().Row( 1 ).Hide() );
wxAuiPaneInfo( vert ).Name( wxT( "m_AuxVToolBar" ) ).Right().Row( 2 ).Hide() );
if( m_VToolBar )
m_auimgr.AddPane( m_VToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) );
m_auimgr.AddPane( m_Layers, lyrs.Right().Row( 0 ) );
if( m_OptionsToolBar )
m_auimgr.AddPane( m_OptionsToolBar,
......@@ -308,6 +341,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_AuxVToolBar->Show(m_show_microwave_tools);
#endif
ReFillLayerWidget(); // this is near end because contents establishes size
}
......@@ -319,6 +353,95 @@ WinEDA_PcbFrame::~WinEDA_PcbFrame()
delete m_drc;
}
//-----<LAYER_WIDGET callbacks>-------------------------------------------
void WinEDA_PcbFrame::LYRS::OnLayerColorChange( int aLayer, int aColor )
{
myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->DrawPanel->Refresh();
}
bool WinEDA_PcbFrame::LYRS::OnLayerSelect( int aLayer )
{
// @todo
return true;
}
void WinEDA_PcbFrame::LYRS::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{
BOARD* brd = myframe->GetBoard();
int visibleLayers = brd->GetVisibleLayers();
if( isVisible )
visibleLayers |= (1 << aLayer);
else
visibleLayers &= ~(1 << aLayer);
brd->SetVisibleLayers( visibleLayers );
if( isFinal )
myframe->DrawPanel->Refresh();
}
void WinEDA_PcbFrame::LYRS::OnRenderColorChange( int aId, int aColor )
{
// @todo
//myframe->GetBoard()->SetLayerColor( aId, aColor );
//myframe->DrawPanel->Refresh();
}
void WinEDA_PcbFrame::LYRS::OnRenderEnable( int aId, bool isEnabled )
{
// @todo
// mframe->GetBoard()->Set
}
//-----</LAYER_WIDGET callbacks>------------------------------------------
void WinEDA_PcbFrame::ReFillLayerWidget()
{
BOARD* brd = GetBoard();
int layer;
int enabledLayers = brd->GetEnabledLayers();
m_Layers->Freeze(); // no screen updates until done modifying
m_Layers->ClearLayerRows();
// show all coppers first, with front on top, back on bottom, then technical layers
layer = LAYER_N_FRONT;
if( enabledLayers & (1 << layer) )
{
m_Layers->AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("Front copper layer"), true ) );
}
for( layer = LAYER_N_FRONT-1; layer >= 1; --layer )
{
if( enabledLayers & (1 << layer) )
{
m_Layers->AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("An innner copper layer"), true ) );
}
}
layer = LAYER_N_BACK;
if( enabledLayers & (1 << layer) )
{
m_Layers->AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("Back copper layer"), true ) );
}
m_Layers->SelectLayer( LAYER_N_FRONT );
m_Layers->Thaw();
}
void WinEDA_PcbFrame::OnQuit( wxCommandEvent & WXUNUSED(event) )
{
Close(true);
......
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