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
8afe2dfb
Commit
8afe2dfb
authored
Feb 02, 2014
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eeschema: Fix bug #1271155 relative to Grid selection in Eeschema.
parent
5a6665ec
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
29 deletions
+57
-29
base_screen.cpp
common/base_screen.cpp
+15
-7
drawframe.cpp
common/drawframe.cpp
+16
-10
eeschema_config.cpp
eeschema/eeschema_config.cpp
+2
-1
files-io.cpp
eeschema/files-io.cpp
+1
-1
hierarch.cpp
eeschema/hierarch.cpp
+4
-0
libeditframe.cpp
eeschema/libeditframe.cpp
+1
-6
class_base_screen.h
include/class_base_screen.h
+15
-3
wxstruct.h
include/wxstruct.h
+3
-1
No files found.
common/base_screen.cpp
View file @
8afe2dfb
...
...
@@ -182,51 +182,59 @@ void BASE_SCREEN::GetGrids( GRIDS& aList )
}
void
BASE_SCREEN
::
SetGrid
(
const
wxRealPoint
&
size
)
int
BASE_SCREEN
::
SetGrid
(
const
wxRealPoint
&
size
)
{
wxASSERT
(
!
m_grids
.
empty
()
);
GRID_TYPE
nearest_grid
=
m_grids
[
0
];
int
gridIdx
=
0
;
for
(
unsigned
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
{
if
(
m_grids
[
i
].
m_Size
==
size
)
{
m_Grid
=
m_grids
[
i
];
return
;
return
m_grids
[
i
].
m_Id
-
ID_POPUP_GRID_LEVEL_1000
;
}
// keep track of the nearest larger grid size, if the exact size is not found
if
(
size
.
x
<
m_grids
[
i
].
m_Size
.
x
)
{
gridIdx
=
m_grids
[
i
].
m_Id
-
ID_POPUP_GRID_LEVEL_1000
;
nearest_grid
=
m_grids
[
i
];
}
}
m_Grid
=
nearest_grid
;
wxLogWarning
(
wxT
(
"Grid size( %f, %f ) not in grid list, falling back "
)
\
wxT
(
"to grid size( %f, %f )."
),
size
.
x
,
size
.
y
,
m_Grid
.
m_Size
.
x
,
m_Grid
.
m_Size
.
y
);
return
gridIdx
;
}
void
BASE_SCREEN
::
SetGrid
(
int
i
d
)
int
BASE_SCREEN
::
SetGrid
(
int
aCommandI
d
)
{
wxASSERT
(
!
m_grids
.
empty
()
);
for
(
unsigned
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
{
if
(
m_grids
[
i
].
m_Id
==
i
d
)
if
(
m_grids
[
i
].
m_Id
==
aCommandI
d
)
{
m_Grid
=
m_grids
[
i
];
return
;
return
m_grids
[
i
].
m_Id
-
ID_POPUP_GRID_LEVEL_1000
;
}
}
m_Grid
=
m_grids
[
0
];
wxLogWarning
(
wxT
(
"Grid ID %d not in grid list, falling back to "
)
\
wxT
(
"grid size( %g, %g )."
),
id
,
m_Grid
.
m_Size
.
x
,
m_Grid
.
m_Size
.
y
);
wxT
(
"grid size( %g, %g )."
),
aCommandId
,
m_Grid
.
m_Size
.
x
,
m_Grid
.
m_Size
.
y
);
return
m_grids
[
0
].
m_Id
-
ID_POPUP_GRID_LEVEL_1000
;
}
...
...
common/drawframe.cpp
View file @
8afe2dfb
...
...
@@ -60,7 +60,7 @@ static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
static
const
wxString
CursorShapeEntryKeyword
(
wxT
(
"CursorShape"
)
);
static
const
wxString
ShowGridEntryKeyword
(
wxT
(
"ShowGrid"
)
);
static
const
wxString
GridColorEntryKeyword
(
wxT
(
"GridColor"
)
);
static
const
wxString
LastGridSizeId
(
wxT
(
"_LastGridSize"
)
);
static
const
wxString
LastGridSizeId
Keyword
(
wxT
(
"_LastGridSize"
)
);
BEGIN_EVENT_TABLE
(
EDA_DRAW_FRAME
,
EDA_BASE_FRAME
)
...
...
@@ -334,7 +334,7 @@ void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,LAYER_MSK aPrintMask, bool aPrintMirro
void
EDA_DRAW_FRAME
::
OnSelectGrid
(
wxCommandEvent
&
event
)
{
int
*
clientData
;
int
i
d
=
ID_POPUP_GRID_LEVEL_100
;
int
eventI
d
=
ID_POPUP_GRID_LEVEL_100
;
if
(
event
.
GetEventType
()
==
wxEVT_COMMAND_COMBOBOX_SELECTED
)
{
...
...
@@ -351,11 +351,11 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
clientData
=
(
int
*
)
m_gridSelectBox
->
wxItemContainer
::
GetClientData
(
index
);
if
(
clientData
!=
NULL
)
i
d
=
*
clientData
;
eventI
d
=
*
clientData
;
}
else
{
i
d
=
event
.
GetId
();
eventI
d
=
event
.
GetId
();
/* Update the grid select combobox if the grid size was changed
* by menu event.
...
...
@@ -366,7 +366,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
{
clientData
=
(
int
*
)
m_gridSelectBox
->
wxItemContainer
::
GetClientData
(
i
);
if
(
clientData
&&
i
d
==
*
clientData
)
if
(
clientData
&&
eventI
d
==
*
clientData
)
{
m_gridSelectBox
->
SetSelection
(
i
);
break
;
...
...
@@ -375,9 +375,12 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
}
}
// Be sure m_LastGridSizeId is up to date.
m_LastGridSizeId
=
eventId
-
ID_POPUP_GRID_LEVEL_1000
;
BASE_SCREEN
*
screen
=
GetScreen
();
if
(
screen
->
GetGridId
()
==
i
d
)
if
(
screen
->
GetGridId
()
==
eventI
d
)
return
;
/*
...
...
@@ -385,8 +388,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
* may be used in the grid size combobox. Do not use the selection
* index returned by GetSelection().
*/
m_LastGridSizeId
=
id
-
ID_POPUP_GRID_LEVEL_1000
;
screen
->
SetGrid
(
id
);
screen
->
SetGrid
(
eventId
);
SetCrossHairPosition
(
RefPos
(
true
)
);
if
(
IsGalCanvasActive
()
)
...
...
@@ -598,7 +600,11 @@ void EDA_DRAW_FRAME::LoadSettings()
if
(
cfg
->
Read
(
m_FrameName
+
GridColorEntryKeyword
,
&
itmp
)
)
SetGridColor
(
ColorFromInt
(
itmp
)
);
cfg
->
Read
(
m_FrameName
+
LastGridSizeId
,
&
m_LastGridSizeId
,
0L
);
cfg
->
Read
(
m_FrameName
+
LastGridSizeIdKeyword
,
&
m_LastGridSizeId
,
0L
);
// m_LastGridSizeId is an offset, expected to be >= 0
if
(
m_LastGridSizeId
<
0
)
m_LastGridSizeId
=
0
;
}
...
...
@@ -612,7 +618,7 @@ void EDA_DRAW_FRAME::SaveSettings()
cfg
->
Write
(
m_FrameName
+
CursorShapeEntryKeyword
,
m_cursorShape
);
cfg
->
Write
(
m_FrameName
+
ShowGridEntryKeyword
,
IsGridVisible
()
);
cfg
->
Write
(
m_FrameName
+
GridColorEntryKeyword
,
(
long
)
GetGridColor
()
);
cfg
->
Write
(
m_FrameName
+
LastGridSizeId
,
(
long
)
m_LastGridSizeId
);
cfg
->
Write
(
m_FrameName
+
LastGridSizeId
Keyword
,
(
long
)
m_LastGridSizeId
);
}
...
...
eeschema/eeschema_config.cpp
View file @
8afe2dfb
...
...
@@ -302,7 +302,8 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
g_UserUnit
=
(
EDA_UNITS_T
)
dlg
.
GetUnitsSelection
();
GetScreen
()
->
SetGrid
(
grid_list
[
(
size_t
)
dlg
.
GetGridSelection
()
].
m_Size
);
wxRealPoint
gridsize
=
grid_list
[
(
size_t
)
dlg
.
GetGridSelection
()
].
m_Size
;
m_LastGridSizeId
=
GetScreen
()
->
SetGrid
(
gridsize
);
int
sep
,
firstId
;
dlg
.
GetRefIdSeparator
(
sep
,
firstId
);
...
...
eeschema/files-io.cpp
View file @
8afe2dfb
...
...
@@ -329,7 +329,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
*/
screen
->
SetZoom
(
32
);
screen
->
SetGrid
(
ID_POPUP_GRID_LEVEL_1000
+
m_LastGridSizeId
);
m_LastGridSizeId
=
screen
->
SetGrid
(
ID_POPUP_GRID_LEVEL_50
);
TITLE_BLOCK
tb
;
wxString
title
;
...
...
eeschema/hierarch.cpp
View file @
8afe2dfb
...
...
@@ -30,6 +30,7 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <id.h>
#include <wxEeschemaStruct.h>
#include <general.h>
...
...
@@ -274,7 +275,10 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
SCH_SCREEN
*
screen
=
m_CurrentSheet
->
LastScreen
();
// Switch to current sheet,
// and update the grid size, because it can be modified in latest screen
SetScreen
(
screen
);
GetScreen
()
->
SetGrid
(
m_LastGridSizeId
+
ID_POPUP_GRID_LEVEL_1000
);
// update the References
m_CurrentSheet
->
UpdateAllScreenReferences
();
...
...
eeschema/libeditframe.cpp
View file @
8afe2dfb
...
...
@@ -207,23 +207,18 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
m_tempCopyComponent
=
NULL
;
m_HotkeysZoomAndGridList
=
s_Libedit_Hokeys_Descr
;
m_editPinsPerPartOrConvert
=
false
;
// Initialize grid id to the default value 50 mils:
m_LastGridSizeId
=
ID_POPUP_GRID_LEVEL_50
-
ID_POPUP_GRID_LEVEL_1000
;
wxIcon
icon
;
icon
.
CopyFromBitmap
(
KiBitmap
(
libedit_icon_xpm
)
);
SetIcon
(
icon
);
SetScreen
(
new
SCH_SCREEN
()
);
GetScreen
()
->
m_Center
=
true
;
SetCrossHairPosition
(
wxPoint
(
0
,
0
)
);
// Initialize grid id to the default value 50 mils:
m_LastGridSizeId
=
ID_POPUP_GRID_LEVEL_50
-
ID_POPUP_GRID_LEVEL_1000
;
LoadSettings
();
SetSize
(
m_FramePos
.
x
,
m_FramePos
.
y
,
m_FrameSize
.
x
,
m_FrameSize
.
y
);
...
...
include/class_base_screen.h
View file @
8afe2dfb
...
...
@@ -402,13 +402,25 @@ public:
*/
const
GRID_TYPE
&
GetGrid
()
const
{
return
m_Grid
;
}
void
SetGrid
(
const
wxRealPoint
&
size
);
/**
* set the current grid size m_Grid.
* The size must be existing in grid list (in m_grids)
* If not, the near existing grid size is used
* @param size = the size of the new grid
* @return the grid id offset (id from ID_POPUP_GRID_LEVEL_1000 )
* of the currently selected grid.
*/
int
SetGrid
(
const
wxRealPoint
&
size
);
/**
* Function SetGrid
* sets the grid size from command ID.
* sets the grid size from command ID (not an index in grid list, but a wxID).
* @param aCommandId = the wxWidgets command ID
* @return the grid id offset (id from ID_POPUP_GRID_LEVEL_1000 )
* of the currently selected grid.
*/
void
SetGrid
(
int
id
);
int
SetGrid
(
int
aCommandId
);
void
SetGridList
(
GRIDS
&
sizelist
);
void
AddGrid
(
const
GRID_TYPE
&
grid
);
void
AddGrid
(
const
wxRealPoint
&
size
,
int
id
);
...
...
include/wxstruct.h
View file @
8afe2dfb
...
...
@@ -414,7 +414,9 @@ class EDA_DRAW_FRAME : public EDA_BASE_FRAME
protected
:
EDA_HOTKEY_CONFIG
*
m_HotkeysZoomAndGridList
;
int
m_LastGridSizeId
;
int
m_LastGridSizeId
;
// the command id offset (>= 0) of the last selected grid
// 0 is for the grid corresponding to
// a wxCommand ID = ID_POPUP_GRID_LEVEL_1000.
bool
m_DrawGrid
;
// hide/Show grid
EDA_COLOR_T
m_GridColor
;
// Grid color
...
...
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