Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
d65b6487
Commit
d65b6487
authored
Nov 02, 2010
by
Marco Serantoni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcbnew: layer combo update, code cleanup
parent
ed9213c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
185 additions
and
87 deletions
+185
-87
class_layerchoicebox.h
include/class_layerchoicebox.h
+55
-0
wxPcbStruct.h
include/wxPcbStruct.h
+3
-2
CMakeLists.txt
pcbnew/CMakeLists.txt
+1
-0
class_layerchoicebox.cpp
pcbnew/class_layerchoicebox.cpp
+115
-0
tool_pcb.cpp
pcbnew/tool_pcb.cpp
+11
-85
No files found.
include/class_layerchoicebox.h
0 → 100644
View file @
d65b6487
#ifndef CLASS_LAYERCHOICEBOX_H
#define CLASS_LAYERCHOICEBOX_H 1
#include <wx/bmpcbox.h>
/* class to display a layer list.
*
*/
class
WinEDALayerChoiceBox
:
public
wxBitmapComboBox
{
public
:
WinEDALayerChoiceBox
(
wxWindow
*
parent
,
wxWindowID
id
,
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxDefaultSize
,
int
n
=
0
,
const
wxString
choices
[]
=
NULL
);
WinEDALayerChoiceBox
(
wxWindow
*
parent
,
wxWindowID
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
const
wxArrayString
&
choices
);
// Get Current Item #
int
GetChoice
();
// Get Current Layer
int
GetLayerChoice
();
// Set Layer #
int
SetLayerSelection
(
int
layer
);
// Reload the Layers
void
Resync
();
};
#define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \
{ \
HK_SWITCH_LAYER_TO_COPPER, \
HK_SWITCH_LAYER_TO_INNER1, \
HK_SWITCH_LAYER_TO_INNER2, \
HK_SWITCH_LAYER_TO_INNER3, \
HK_SWITCH_LAYER_TO_INNER4, \
HK_SWITCH_LAYER_TO_INNER5, \
HK_SWITCH_LAYER_TO_INNER6, \
HK_SWITCH_LAYER_TO_INNER7, \
HK_SWITCH_LAYER_TO_INNER8, \
HK_SWITCH_LAYER_TO_INNER9, \
HK_SWITCH_LAYER_TO_INNER10, \
HK_SWITCH_LAYER_TO_INNER11, \
HK_SWITCH_LAYER_TO_INNER12, \
HK_SWITCH_LAYER_TO_INNER13, \
HK_SWITCH_LAYER_TO_INNER14, \
HK_SWITCH_LAYER_TO_COMPONENT \
};
#endif //CLASS_LAYERCHOICEBOX_H
include/wxPcbStruct.h
View file @
d65b6487
...
...
@@ -9,6 +9,7 @@
#include "wxstruct.h"
#include "base_struct.h"
#include "param_config.h"
#include "class_layerchoicebox.h"
#ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000
...
...
@@ -114,7 +115,7 @@ protected:
public
:
WinEDA
ChoiceBox
*
m_SelLayerBox
;
// a combo box to display and
WinEDA
LayerChoiceBox
*
m_SelLayerBox
;
// a combo box to display and
// select active layer
WinEDAChoiceBox
*
m_SelTrackWidthBox
;
// a combo box to display and
// select current track width
...
...
@@ -308,7 +309,7 @@ public:
void
ReCreateMicrowaveVToolbar
();
void
ReCreateOptToolbar
();
void
ReCreateMenuBar
();
WinEDAChoiceBox
*
ReCreateLayerBox
(
WinEDA_Toolbar
*
parent
);
WinEDA
Layer
ChoiceBox
*
ReCreateLayerBox
(
WinEDA_Toolbar
*
parent
);
/** Virtual Function OnModify()
* Must be called after a board change
...
...
pcbnew/CMakeLists.txt
View file @
d65b6487
...
...
@@ -32,6 +32,7 @@ set(PCBNEW_SRCS
block.cpp
block_module_editor.cpp
build_BOM_from_board.cpp
class_layerchoicebox.cpp
class_pcb_layer_widget.cpp
clean.cpp
# cleaningoptions_dialog.cpp
...
...
pcbnew/class_layerchoicebox.cpp
0 → 100644
View file @
d65b6487
#include "common.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "class_board_design_settings.h"
#include "colors_selection.h"
#include "bitmaps.h"
#include "pcbnew_id.h"
#include "hotkeys.h"
#include "help_common_strings.h"
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/bmpcbox.h>
#include <wx/wx.h>
#include "class_layerchoicebox.h"
/* class to display a layer list.
*
*/
WinEDALayerChoiceBox
::
WinEDALayerChoiceBox
(
wxWindow
*
parent
,
wxWindowID
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
int
n
,
const
wxString
choices
[]
)
:
wxBitmapComboBox
(
parent
,
id
,
wxEmptyString
,
pos
,
size
,
n
,
choices
,
wxCB_READONLY
)
{
}
WinEDALayerChoiceBox
::
WinEDALayerChoiceBox
(
wxWindow
*
parent
,
wxWindowID
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
const
wxArrayString
&
choices
)
:
wxBitmapComboBox
(
parent
,
id
,
wxEmptyString
,
pos
,
size
,
choices
,
wxCB_READONLY
)
{
}
// Get Current Item #
int
WinEDALayerChoiceBox
::
GetChoice
()
{
return
GetSelection
();
}
// Get Current Layer
int
WinEDALayerChoiceBox
::
GetLayerChoice
()
{
return
(
long
)
GetClientData
(
GetSelection
());
}
// Set Layer #
int
WinEDALayerChoiceBox
::
SetLayerSelection
(
int
layer
)
{
int
elements
=
GetCount
();
for
(
int
i
=
0
;
i
<
elements
;
i
++
)
if
(
GetClientData
(
i
)
==
(
void
*
)
layer
)
if
(
GetSelection
()
!=
i
)
// Element (i) is not selected
{
SetSelection
(
i
);
return
i
;
}
else
return
i
;
//If element already selected; do nothing
// Not Found
SetSelection
(
-
1
);
return
-
1
;
}
// Reload the Layers
void
WinEDALayerChoiceBox
::
Resync
()
{
BOARD
*
board
=
((
WinEDA_BasePcbFrame
*
)
GetParent
())
->
GetBoard
();
wxASSERT
(
board
!=
NULL
);
Clear
();
static
DECLARE_LAYERS_ORDER_LIST
(
layertranscode
);
static
DECLARE_LAYERS_HOTKEY
(
layerhk
);
for
(
int
i
=
0
;
i
<
LAYER_COUNT
;
i
++
)
{
wxBitmap
layerbmp
(
20
,
18
);
wxMemoryDC
bmpDC
;
wxBrush
brush
;
wxString
layername
;
int
layerid
=
layertranscode
[
i
];
// Prepare Bitmap
bmpDC
.
SelectObject
(
layerbmp
);
brush
.
SetColour
(
MakeColour
(
board
->
GetLayerColor
(
layerid
)
));
brush
.
SetStyle
(
wxSOLID
);
bmpDC
.
SetBrush
(
brush
);
bmpDC
.
DrawRectangle
(
0
,
0
,
layerbmp
.
GetWidth
(),
layerbmp
.
GetHeight
());
bmpDC
.
SetBrush
(
*
wxTRANSPARENT_BRUSH
);
bmpDC
.
SetPen
(
*
wxBLACK_PEN
);
bmpDC
.
DrawRectangle
(
0
,
0
,
layerbmp
.
GetWidth
(),
layerbmp
.
GetHeight
());
layername
=
board
->
GetLayerName
(
layerid
);
layername
.
Append
(
"
\t
"
);
layername
=
AddHotkeyName
(
layername
,
s_Board_Editor_Hokeys_Descr
,
layerhk
[
layerid
],
false
);
if
(
board
->
IsLayerEnabled
(
layerid
))
Append
(
layername
,
layerbmp
,
(
void
*
)
layerid
);
}
}
pcbnew/tool_pcb.cpp
View file @
d65b6487
...
...
@@ -27,6 +27,7 @@
#include "hotkeys.h"
#include "help_common_strings.h"
#include "class_layerchoicebox.h"
#define SEL_LAYER_HELP _( \
"Show active layer selections\nand select layer pair for route and place via" )
...
...
@@ -266,8 +267,13 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
_
(
"Perform design rules check"
)
);
m_HToolBar
->
AddSeparator
();
if
(
m_SelLayerBox
==
NULL
)
m_SelLayerBox
=
new
WinEDALayerChoiceBox
(
this
,
ID_TOOLBARH_PCB_SELECT_LAYER
);
ReCreateLayerBox
(
m_HToolBar
);
m_HToolBar
->
AddControl
(
m_SelLayerBox
);
PrepareLayerIndicator
();
// Initialize the bitmap with current
// active layer colors for the next tool
m_HToolBar
->
AddTool
(
ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR
,
wxEmptyString
,
...
...
@@ -685,97 +691,17 @@ void WinEDA_PcbFrame::syncLayerBox()
{
wxASSERT
(
m_SelLayerBox
);
// Enable the display on the correct layer
// To avoid reentrancy ( Bug wxGTK Linux version? ), the selection is
// made only if it needs changing ( corrected on wxGTK 2.6.0 )
int
count
=
m_SelLayerBox
->
GetCount
();
int
choice
=
m_SelLayerBox
->
GetChoice
();
int
layer
=
getActiveLayer
();
for
(
int
listNdx
=
0
;
listNdx
<
count
;
++
listNdx
)
{
int
clientData
=
(
int
)
(
size_t
)
m_SelLayerBox
->
wxItemContainer
::
GetClientData
(
listNdx
);
if
(
clientData
==
layer
)
{
if
(
listNdx
!=
choice
)
m_SelLayerBox
->
SetSelection
(
listNdx
);
break
;
}
}
m_SelLayerBox
->
SetLayerSelection
(
layer
);
}
WinEDAChoiceBox
*
WinEDA_PcbFrame
::
ReCreateLayerBox
(
WinEDA_Toolbar
*
parent
)
WinEDA
Layer
ChoiceBox
*
WinEDA_PcbFrame
::
ReCreateLayerBox
(
WinEDA_Toolbar
*
parent
)
{
if
(
m_SelLayerBox
==
NULL
)
{
if
(
parent
==
NULL
)
return
NULL
;
m_SelLayerBox
=
new
WinEDAChoiceBox
(
parent
,
ID_TOOLBARH_PCB_SELECT_LAYER
,
wxPoint
(
-
1
,
-
1
),
#if defined (__UNIX__)
// Width enough for the longest
// string: "Component (Page Down)"
// Maybe that string is too long?
wxSize
(
230
,
-
1
)
#else
wxSize
(
LISTBOX_WIDTH
+
30
,
-
1
)
#endif
);
parent
->
AddControl
(
m_SelLayerBox
);
}
int
layer_mask
=
GetBoard
()
->
GetEnabledLayers
();
unsigned
length
=
0
;
m_SelLayerBox
->
Clear
();
static
DECLARE_LAYERS_ORDER_LIST
(
layerOrder_for_display
);
for
(
int
idx
=
0
,
listNdx
=
0
;
idx
<=
EDGE_N
;
idx
++
)
{
int
layer
=
layerOrder_for_display
[
idx
];
// List to append hotkeys in layer box selection
static
const
int
HK_SwitchLayer
[
EDGE_N
+
1
]
=
{
HK_SWITCH_LAYER_TO_COPPER
,
HK_SWITCH_LAYER_TO_INNER1
,
HK_SWITCH_LAYER_TO_INNER2
,
HK_SWITCH_LAYER_TO_INNER3
,
HK_SWITCH_LAYER_TO_INNER4
,
HK_SWITCH_LAYER_TO_INNER5
,
HK_SWITCH_LAYER_TO_INNER6
,
HK_SWITCH_LAYER_TO_INNER7
,
HK_SWITCH_LAYER_TO_INNER8
,
HK_SWITCH_LAYER_TO_INNER9
,
HK_SWITCH_LAYER_TO_INNER10
,
HK_SWITCH_LAYER_TO_INNER11
,
HK_SWITCH_LAYER_TO_INNER12
,
HK_SWITCH_LAYER_TO_INNER13
,
HK_SWITCH_LAYER_TO_INNER14
,
HK_SWITCH_LAYER_TO_COMPONENT
};
if
(
g_TabOneLayerMask
[
layer
]
&
layer_mask
)
{
wxString
msg
=
GetBoard
()
->
GetLayerName
(
layer
);
msg
<<
wxT
(
" "
);
msg
=
AddHotkeyName
(
msg
,
s_Board_Editor_Hokeys_Descr
,
HK_SwitchLayer
[
layer
],
false
);
m_SelLayerBox
->
Append
(
msg
);
//D(printf("appending layername=%s, ndx=%d, layer=%d\n", CONV_TO_UTF8(msg), listNdx, layer );)
m_SelLayerBox
->
wxItemContainer
::
SetClientData
(
listNdx
,
(
void
*
)
layer
);
length
=
MAX
(
length
,
msg
.
Len
()
);
listNdx
++
;
}
}
if
(
m_SelLayerBox
==
NULL
)
return
NULL
;
m_SelLayerBox
->
Resync
();
m_SelLayerBox
->
SetToolTip
(
_
(
"+/- to switch"
)
);
syncLayerBox
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment