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
025d4cf2
Commit
025d4cf2
authored
Apr 30, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alternative way of handling grid settings in GAL.
parent
4be876a1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
57 deletions
+62
-57
draw_frame.cpp
common/draw_frame.cpp
+29
-51
draw_frame.h
include/draw_frame.h
+7
-0
common_actions.cpp
pcbnew/tools/common_actions.cpp
+8
-5
common_actions.h
pcbnew/tools/common_actions.h
+1
-0
pcbnew_control.cpp
pcbnew/tools/pcbnew_control.cpp
+16
-1
pcbnew_control.h
pcbnew/tools/pcbnew_control.h
+1
-0
No files found.
common/draw_frame.cpp
View file @
025d4cf2
...
...
@@ -387,46 +387,17 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
else
{
eventId
=
event
.
GetId
();
/* Update the grid select combobox if the grid size was changed
* by menu event.
*/
if
(
m_gridSelectBox
!=
NULL
)
{
for
(
size_t
i
=
0
;
i
<
m_gridSelectBox
->
GetCount
();
i
++
)
{
clientData
=
(
int
*
)
m_gridSelectBox
->
wxItemContainer
::
GetClientData
(
i
);
if
(
clientData
&&
eventId
==
*
clientData
)
{
m_gridSelectBox
->
SetSelection
(
i
);
break
;
}
}
}
}
// Be sure m_LastGridSizeId is up to date.
m_LastGridSizeId
=
eventId
-
ID_POPUP_GRID_LEVEL_1000
;
BASE_SCREEN
*
screen
=
GetScreen
();
if
(
screen
->
GetGridId
()
==
eventId
)
return
;
int
idx
=
eventId
-
ID_POPUP_GRID_LEVEL_1000
;
/*
* This allows for saving non-sequential command ID offsets used that
* may be used in the grid size combobox. Do not use the selection
* index returned by GetSelection().
*/
screen
->
SetGrid
(
eventId
);
SetCrossHairPosition
(
RefPos
(
true
)
);
// Notify GAL
TOOL_MANAGER
*
mgr
=
GetToolManager
();
if
(
IsGalCanvasActive
()
)
{
GetGalCanvas
()
->
GetGAL
()
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGrid
().
m_Size
)
);
GetGalCanvas
()
->
GetView
()
->
MarkTargetDirty
(
KIGFX
::
TARGET_NONCACHED
);
}
if
(
mgr
&&
IsGalCanvasActive
()
)
mgr
->
RunAction
(
"common.Control.gridPreset"
,
true
,
idx
);
else
SetPresetGrid
(
idx
);
m_canvas
->
Refresh
();
}
...
...
@@ -556,14 +527,7 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
void
EDA_DRAW_FRAME
::
SetNextGrid
()
{
if
(
m_gridSelectBox
)
{
m_gridSelectBox
->
SetSelection
(
(
m_gridSelectBox
->
GetSelection
()
+
1
)
%
m_gridSelectBox
->
GetCount
()
);
wxCommandEvent
cmd
(
wxEVT_COMMAND_COMBOBOX_SELECTED
);
// cmd.SetEventObject( this );
OnSelectGrid
(
cmd
);
}
SetPresetGrid
(
(
m_gridSelectBox
->
GetSelection
()
+
1
)
%
m_gridSelectBox
->
GetCount
()
);
}
...
...
@@ -571,17 +535,31 @@ void EDA_DRAW_FRAME::SetPrevGrid()
{
if
(
m_gridSelectBox
)
{
int
cnt
=
m_gridSelectBox
->
GetSelection
();
int
idx
=
m_gridSelectBox
->
GetSelection
();
if
(
--
cnt
<
0
)
cnt
=
m_gridSelectBox
->
GetCount
()
-
1
;
if
(
--
idx
<
0
)
idx
=
m_gridSelectBox
->
GetCount
()
-
1
;
SetPresetGrid
(
idx
);
}
}
m_gridSelectBox
->
SetSelection
(
cnt
);
wxCommandEvent
cmd
(
wxEVT_COMMAND_COMBOBOX_SELECTED
);
// cmd.SetEventObject( this );
OnSelectGrid
(
cmd
);
void
EDA_DRAW_FRAME
::
SetPresetGrid
(
int
aIndex
)
{
if
(
aIndex
<
0
||
aIndex
>=
(
int
)
m_gridSelectBox
->
GetCount
()
)
{
wxASSERT_MSG
(
false
,
"Invalid grid index"
);
return
;
}
if
(
m_gridSelectBox
)
m_gridSelectBox
->
SetSelection
(
aIndex
);
// Be sure m_LastGridSizeId is up to date.
m_LastGridSizeId
=
aIndex
;
GetScreen
()
->
SetGrid
(
aIndex
+
ID_POPUP_GRID_LEVEL_1000
);
SetCrossHairPosition
(
RefPos
(
true
)
);
}
...
...
include/draw_frame.h
View file @
025d4cf2
...
...
@@ -439,6 +439,13 @@ public:
*/
virtual
void
SetPrevGrid
();
/**
* Function SetPresetGrid()
* changes the grid size to one of the preset values.
* @param aIndex is the index from the list.
*/
void
SetPresetGrid
(
int
aIndex
);
/**
* Command event handler for selecting grid sizes.
*
...
...
pcbnew/tools/common_actions.cpp
View file @
025d4cf2
...
...
@@ -303,26 +303,29 @@ TOOL_ACTION COMMON_ACTIONS::layerChanged( "pcbnew.Control.layerChanged",
// Grid control
TOOL_ACTION
COMMON_ACTIONS
::
gridFast1
(
"
pcbnew
.Control.gridFast1"
,
TOOL_ACTION
COMMON_ACTIONS
::
gridFast1
(
"
common
.Control.gridFast1"
,
AS_GLOBAL
,
MD_ALT
+
int
(
'1'
),
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
gridFast2
(
"
pcbnew
.Control.gridFast2"
,
TOOL_ACTION
COMMON_ACTIONS
::
gridFast2
(
"
common
.Control.gridFast2"
,
AS_GLOBAL
,
MD_ALT
+
int
(
'2'
),
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
gridNext
(
"
pcbnew
.Control.gridNext"
,
TOOL_ACTION
COMMON_ACTIONS
::
gridNext
(
"
common
.Control.gridNext"
,
AS_GLOBAL
,
'`'
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
gridPrev
(
"
pcbnew
.Control.gridPrev"
,
TOOL_ACTION
COMMON_ACTIONS
::
gridPrev
(
"
common
.Control.gridPrev"
,
AS_GLOBAL
,
MD_CTRL
+
int
(
'`'
),
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
gridSetOrigin
(
"
pcbnew
.Control.gridSetOrigin"
,
TOOL_ACTION
COMMON_ACTIONS
::
gridSetOrigin
(
"
common
.Control.gridSetOrigin"
,
AS_GLOBAL
,
0
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
gridPreset
(
"common.Control.gridPreset"
,
AS_GLOBAL
,
0
,
""
,
""
);
// Track & via size control
TOOL_ACTION
COMMON_ACTIONS
::
trackWidthInc
(
"pcbnew.EditorControl.trackWidthInc"
,
...
...
pcbnew/tools/common_actions.h
View file @
025d4cf2
...
...
@@ -223,6 +223,7 @@ public:
static
TOOL_ACTION
gridNext
;
static
TOOL_ACTION
gridPrev
;
static
TOOL_ACTION
gridSetOrigin
;
static
TOOL_ACTION
gridPreset
;
// Track & via size control
static
TOOL_ACTION
trackWidthInc
;
...
...
pcbnew/tools/pcbnew_control.cpp
View file @
025d4cf2
...
...
@@ -446,6 +446,21 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
}
int
PCBNEW_CONTROL
::
GridPreset
(
const
TOOL_EVENT
&
aEvent
)
{
long
idx
=
aEvent
.
Parameter
<
long
>
();
m_frame
->
SetPresetGrid
(
idx
);
BASE_SCREEN
*
screen
=
m_frame
->
GetScreen
();
GRID_TYPE
grid
=
screen
->
GetGrid
(
idx
);
getView
()
->
GetGAL
()
->
SetGridSize
(
VECTOR2D
(
grid
.
m_Size
)
);
getView
()
->
MarkTargetDirty
(
KIGFX
::
TARGET_NONCACHED
);
return
0
;
}
// Miscellaneous
int
PCBNEW_CONTROL
::
ResetCoords
(
const
TOOL_EVENT
&
aEvent
)
{
...
...
@@ -549,7 +564,7 @@ void PCBNEW_CONTROL::SetTransitions()
Go
(
&
PCBNEW_CONTROL
::
GridNext
,
COMMON_ACTIONS
::
gridNext
.
MakeEvent
()
);
Go
(
&
PCBNEW_CONTROL
::
GridPrev
,
COMMON_ACTIONS
::
gridPrev
.
MakeEvent
()
);
Go
(
&
PCBNEW_CONTROL
::
GridSetOrigin
,
COMMON_ACTIONS
::
gridSetOrigin
.
MakeEvent
()
);
//Go( &PCBNEW_CONTROL::GridSetPreset, COMMON_ACTIONS::gridSet
Preset.MakeEvent() );
Go
(
&
PCBNEW_CONTROL
::
GridPreset
,
COMMON_ACTIONS
::
grid
Preset
.
MakeEvent
()
);
// Miscellaneous
Go
(
&
PCBNEW_CONTROL
::
ResetCoords
,
COMMON_ACTIONS
::
resetCoords
.
MakeEvent
()
);
...
...
pcbnew/tools/pcbnew_control.h
View file @
025d4cf2
...
...
@@ -72,6 +72,7 @@ public:
int
GridNext
(
const
TOOL_EVENT
&
aEvent
);
int
GridPrev
(
const
TOOL_EVENT
&
aEvent
);
int
GridSetOrigin
(
const
TOOL_EVENT
&
aEvent
);
int
GridPreset
(
const
TOOL_EVENT
&
aEvent
);
// Miscellaneous
int
ResetCoords
(
const
TOOL_EVENT
&
aEvent
);
...
...
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