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
fb43f4ad
Commit
fb43f4ad
authored
Oct 16, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fp_lib_table dialog work
parent
80693fa7
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
416 additions
and
240 deletions
+416
-240
fp_lib_table.cpp
common/fp_lib_table.cpp
+46
-44
fp_lib_table.h
include/fp_lib_table.h
+51
-5
dialog_fp_lib_table.cpp
pcbnew/dialogs/dialog_fp_lib_table.cpp
+115
-5
dialog_fp_lib_table_base.cpp
pcbnew/dialogs/dialog_fp_lib_table_base.cpp
+119
-111
dialog_fp_lib_table_base.fbp
pcbnew/dialogs/dialog_fp_lib_table_base.fbp
+60
-60
dialog_fp_lib_table_base.h
pcbnew/dialogs/dialog_fp_lib_table_base.h
+25
-15
No files found.
common/fp_lib_table.cpp
View file @
fb43f4ad
...
...
@@ -178,6 +178,52 @@ std::vector<wxString> FP_LIB_TABLE::GetLogicalLibs()
}
FP_LIB_TABLE
::
ROW
*
FP_LIB_TABLE
::
FindRow
(
const
wxString
&
aNickName
)
const
{
// this function must be *super* fast, so therefore should not instantiate
// anything which would require using the heap.
const
FP_LIB_TABLE
*
cur
=
this
;
do
{
INDEX_CITER
it
=
cur
->
nickIndex
.
find
(
aNickName
);
if
(
it
!=
cur
->
nickIndex
.
end
()
)
{
return
(
FP_LIB_TABLE
::
ROW
*
)
&
cur
->
rows
[
it
->
second
];
// found
}
// not found, search fall back table(s), if any
}
while
(
(
cur
=
cur
->
fallBack
)
!=
0
);
return
0
;
// not found
}
bool
FP_LIB_TABLE
::
InsertRow
(
const
ROW
&
aRow
,
bool
doReplace
)
{
// this does not need to be super fast.
INDEX_CITER
it
=
nickIndex
.
find
(
aRow
.
nickName
);
if
(
it
==
nickIndex
.
end
()
)
{
rows
.
push_back
(
aRow
);
nickIndex
.
insert
(
INDEX_VALUE
(
aRow
.
nickName
,
rows
.
size
()
-
1
)
);
return
true
;
}
if
(
doReplace
)
{
rows
[
it
->
second
]
=
aRow
;
return
true
;
}
return
false
;
}
#if 0 // will need PLUGIN_RELEASER.
MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId )
throw( IO_ERROR )
...
...
@@ -256,47 +302,3 @@ void FP_LIB_TABLE::loadLib( ROW* aRow ) throw( IO_ERROR )
}
#endif
FP_LIB_TABLE
::
ROW
*
FP_LIB_TABLE
::
FindRow
(
const
wxString
&
aNickName
)
const
{
// this function must be *super* fast, so therefore should not instantiate
// anything which would require using the heap.
const
FP_LIB_TABLE
*
cur
=
this
;
do
{
INDEX_CITER
it
=
cur
->
nickIndex
.
find
(
aNickName
);
if
(
it
!=
cur
->
nickIndex
.
end
()
)
{
return
(
FP_LIB_TABLE
::
ROW
*
)
&
cur
->
rows
[
it
->
second
];
// found
}
// not found, search fall back table(s), if any
}
while
(
(
cur
=
cur
->
fallBack
)
!=
0
);
return
0
;
// not found
}
bool
FP_LIB_TABLE
::
InsertRow
(
const
ROW
&
aRow
,
bool
doReplace
)
{
// this does not need to be super fast.
INDEX_CITER
it
=
nickIndex
.
find
(
aRow
.
nickName
);
if
(
it
==
nickIndex
.
end
()
)
{
rows
.
push_back
(
aRow
);
nickIndex
.
insert
(
INDEX_VALUE
(
aRow
.
nickName
,
rows
.
size
()
-
1
)
);
return
true
;
}
if
(
doReplace
)
{
rows
[
it
->
second
]
=
aRow
;
return
true
;
}
return
false
;
}
include/fp_lib_table.h
View file @
fb43f4ad
...
...
@@ -82,6 +82,8 @@ class FP_LIB_TABLE_LEXER;
*/
class
FP_LIB_TABLE
:
public
wxGridTableBase
{
friend
class
DIALOG_FP_LIB_TABLE
;
public
:
/**
...
...
@@ -92,6 +94,7 @@ public:
class
ROW
{
friend
class
FP_LIB_TABLE
;
friend
class
DIALOG_FP_LIB_TABLE
;
public
:
...
...
@@ -148,8 +151,6 @@ public:
void
Format
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
const
throw
(
IO_ERROR
);
protected
:
ROW
(
FP_LIB_TABLE
*
aOwner
)
:
owner
(
aOwner
)
// lib( 0 )
...
...
@@ -316,9 +317,9 @@ public:
switch
(
aCol
)
{
case
1
:
r
.
SetType
(
aValue
);
case
2
:
r
.
SetFullURI
(
aValue
);
case
3
:
r
.
SetOptions
(
aValue
);
case
1
:
r
.
SetType
(
aValue
);
break
;
case
2
:
r
.
SetFullURI
(
aValue
);
break
;
case
3
:
r
.
SetOptions
(
aValue
);
break
;
}
}
}
...
...
@@ -330,6 +331,51 @@ public:
return
true
;
}
bool
InsertRows
(
size_t
aPos
=
0
,
size_t
aNumRows
=
1
)
{
if
(
aPos
<
rows
.
size
()
)
{
rows
.
insert
(
rows
.
begin
()
+
aPos
,
aNumRows
,
ROW
(
this
)
);
return
true
;
}
return
false
;
}
bool
AppendRows
(
size_t
aNumRows
=
1
)
{
while
(
aNumRows
--
)
rows
.
push_back
(
ROW
(
this
)
);
return
true
;
}
bool
DeleteRows
(
size_t
aPos
,
size_t
aNumRows
)
{
if
(
aPos
+
aNumRows
<=
rows
.
size
()
)
{
ROWS_ITER
start
=
rows
.
begin
()
+
aPos
;
rows
.
erase
(
start
,
start
+
aNumRows
);
return
true
;
}
return
false
;
}
void
Clear
()
{
rows
.
clear
();
}
wxString
GetColLabelValue
(
int
aCol
)
{
switch
(
aCol
)
{
case
0
:
return
_
(
"Nickname"
);
case
1
:
return
_
(
"Plugin"
);
case
2
:
return
_
(
"Library Path"
);
case
3
:
return
_
(
"Options"
);
default:
return
wxEmptyString
;
}
}
//-----</wxGridTableBase overloads>------------------------------------------
...
...
pcbnew/dialogs/dialog_fp_lib_table.cpp
View file @
fb43f4ad
...
...
@@ -24,7 +24,7 @@
*/
#include <fctsys.h>
#include <dialog_fp_lib_table_base.h>
#include <fp_lib_table.h>
...
...
@@ -35,11 +35,113 @@
*/
class
DIALOG_FP_LIB_TABLE
:
public
DIALOG_FP_LIB_TABLE_BASE
{
//-----<event handlers>----------------------------------
void
pageChangedHandler
(
wxAuiNotebookEvent
&
event
)
{
int
pageNdx
=
m_auinotebook
->
GetSelection
();
m_cur_grid
=
pageNdx
?
m_global_grid
:
m_project_grid
;
}
void
appendRowHandler
(
wxMouseEvent
&
event
)
{
D
(
printf
(
"%s
\n
"
,
__func__
);)
}
void
deleteRowHandler
(
wxMouseEvent
&
event
)
{
D
(
printf
(
"%s
\n
"
,
__func__
);)
}
void
moveUpHandler
(
wxMouseEvent
&
event
)
{
D
(
printf
(
"%s
\n
"
,
__func__
);)
}
void
moveDownHandler
(
wxMouseEvent
&
event
)
{
D
(
printf
(
"%s
\n
"
,
__func__
);)
}
void
onCancelButtonClick
(
wxCommandEvent
&
event
)
{
m_global
->
rows
=
m_orig_global
;
m_project
->
rows
=
m_orig_project
;
// @todo reindex, or add member function for wholesale row replacement
EndModal
(
wxID_CANCEL
);
}
void
onOKButtonClick
(
wxCommandEvent
&
event
)
{
EndModal
(
wxID_OK
);
}
//-----</event handlers>---------------------------------
// caller's tables are modified only on OK button.
FP_LIB_TABLE
*
m_global
;
FP_LIB_TABLE
*
m_project
;
// local copies are saved and restored if Cancel button.
FP_LIB_TABLE
::
ROWS
m_orig_global
;
FP_LIB_TABLE
::
ROWS
m_orig_project
;
wxGrid
*
m_cur_grid
;
///< changed based on tab choice
public
:
DIALOG_FP_LIB_TABLE
(
wxFrame
*
aParent
)
:
DIALOG_FP_LIB_TABLE_BASE
(
aParent
)
DIALOG_FP_LIB_TABLE
(
wxFrame
*
aParent
,
FP_LIB_TABLE
*
aGlobal
,
FP_LIB_TABLE
*
aProject
)
:
DIALOG_FP_LIB_TABLE_BASE
(
aParent
),
m_global
(
aGlobal
),
m_project
(
aProject
),
m_orig_global
(
aGlobal
->
rows
),
m_orig_project
(
aProject
->
rows
)
{
/*
GetSizer()->SetSizeHints( this );
Centre();
SetAutoLayout( true );
Layout();
*/
#if 1 && defined(DEBUG)
// put some dummy data into table(s)
FP_LIB_TABLE
::
ROW
row
(
m_global
);
row
.
SetNickName
(
wxT
(
"passives"
)
);
row
.
SetType
(
wxT
(
"kicad"
)
);
row
.
SetFullURI
(
wxT
(
"%G/passives"
)
);
row
.
SetOptions
(
wxT
(
"speed=fast,purpose=testing"
)
);
m_global
->
InsertRow
(
row
);
row
.
SetNickName
(
wxT
(
"micros"
)
);
row
.
SetType
(
wxT
(
"legacy"
)
);
row
.
SetFullURI
(
wxT
(
"%P/micros"
)
);
row
.
SetOptions
(
wxT
(
"speed=fast,purpose=testing"
)
);
m_global
->
InsertRow
(
row
);
row
.
owner
=
m_project
;
row
.
SetFullURI
(
wxT
(
"%P/chips"
)
);
m_project
->
InsertRow
(
row
);
#endif
m_global_grid
->
SetTable
(
m_global
);
m_project_grid
->
SetTable
(
m_project
);
//m_global_grid->AutoSize();
m_global_grid
->
AutoSizeColumns
(
false
);
//m_project_grid->AutoSize();
m_project_grid
->
AutoSizeColumns
(
false
);
//m_path_subs_grid->AutoSize();
m_path_subs_grid
->
AutoSizeColumns
(
false
);
}
};
...
...
@@ -47,9 +149,17 @@ public:
int
InvokePcbLibTableEditor
(
wxFrame
*
aParent
,
FP_LIB_TABLE
*
aGlobal
,
FP_LIB_TABLE
*
aProject
)
{
DIALOG_FP_LIB_TABLE
dlg
(
aParen
t
);
DIALOG_FP_LIB_TABLE
dlg
(
aParent
,
aGlobal
,
aProjec
t
);
dlg
.
Show
(
true
);
int
ret
=
dlg
.
ShowModal
();
switch
(
ret
)
{
case
wxID_OK
:
break
;
case
wxID_CANCEL
:
break
;
}
return
0
;
}
...
...
pcbnew/dialogs/dialog_fp_lib_table_base.cpp
View file @
fb43f4ad
This diff is collapsed.
Click to expand it.
pcbnew/dialogs/dialog_fp_lib_table_base.fbp
View file @
fb43f4ad
This diff is collapsed.
Click to expand it.
pcbnew/dialogs/dialog_fp_lib_table_base.h
View file @
fb43f4ad
...
...
@@ -42,32 +42,42 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM
private
:
protected
:
wxSplitterWindow
*
m_splitter
1
;
wxSplitterWindow
*
m_splitter
;
wxPanel
*
m_top
;
wxAuiNotebook
*
m_auinotebook
2
;
wxPanel
*
m_
panel4
;
wxGrid
*
m_g
rid1
;
wxPanel
*
m_p
anel5
;
wxGrid
*
m_
grid11
;
wxButton
*
m_
button1
;
wxButton
*
m_
button2
;
wxButton
*
m_
button3
;
wxButton
*
m_
button4
;
wxAuiNotebook
*
m_auinotebook
;
wxPanel
*
m_
global_panel
;
wxGrid
*
m_g
lobal_grid
;
wxPanel
*
m_p
roject_panel
;
wxGrid
*
m_
project_grid
;
wxButton
*
m_
append_button
;
wxButton
*
m_
delete_button
;
wxButton
*
m_
move_up_button
;
wxButton
*
m_
move_down_button
;
wxPanel
*
m_bottom
;
wxGrid
*
m_
grid2
;
wxGrid
*
m_
path_subs_grid
;
wxStdDialogButtonSizer
*
m_sdbSizer1
;
wxButton
*
m_sdbSizer1OK
;
wxButton
*
m_sdbSizer1Cancel
;
// Virtual event handlers, overide them in your derived class
virtual
void
pageChangedHandler
(
wxAuiNotebookEvent
&
event
)
{
event
.
Skip
();
}
virtual
void
appendRowHandler
(
wxMouseEvent
&
event
)
{
event
.
Skip
();
}
virtual
void
deleteRowHandler
(
wxMouseEvent
&
event
)
{
event
.
Skip
();
}
virtual
void
moveUpHandler
(
wxMouseEvent
&
event
)
{
event
.
Skip
();
}
virtual
void
moveDownHandler
(
wxMouseEvent
&
event
)
{
event
.
Skip
();
}
virtual
void
onCancelButtonClick
(
wxCommandEvent
&
event
)
{
event
.
Skip
();
}
virtual
void
onOKButtonClick
(
wxCommandEvent
&
event
)
{
event
.
Skip
();
}
public
:
DIALOG_FP_LIB_TABLE_BASE
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxString
&
title
=
_
(
"PCB Library Tables"
),
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxSize
(
-
1
,
-
1
),
long
style
=
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
);
DIALOG_FP_LIB_TABLE_BASE
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxString
&
title
=
_
(
"PCB Library Tables"
),
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxSize
(
864
,
652
),
long
style
=
wxDEFAULT_DIALOG_STYLE
|
wxRESIZE_BORDER
);
~
DIALOG_FP_LIB_TABLE_BASE
();
void
m_splitter
1
OnIdle
(
wxIdleEvent
&
)
void
m_splitterOnIdle
(
wxIdleEvent
&
)
{
m_splitter
1
->
SetSashPosition
(
254
);
m_splitter
1
->
Disconnect
(
wxEVT_IDLE
,
wxIdleEventHandler
(
DIALOG_FP_LIB_TABLE_BASE
::
m_splitter1
OnIdle
),
NULL
,
this
);
m_splitter
->
SetSashPosition
(
343
);
m_splitter
->
Disconnect
(
wxEVT_IDLE
,
wxIdleEventHandler
(
DIALOG_FP_LIB_TABLE_BASE
::
m_splitter
OnIdle
),
NULL
,
this
);
}
};
...
...
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