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
761375dd
Commit
761375dd
authored
May 13, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More compatibility fixes.
parent
3eaef97a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
39 deletions
+107
-39
draw_panel_gal.cpp
common/draw_panel_gal.cpp
+13
-5
context_menu.cpp
common/tool/context_menu.cpp
+1
-1
wxunittext.cpp
common/wxunittext.cpp
+70
-25
class_draw_panel_gal.h
include/class_draw_panel_gal.h
+8
-1
wxunittext.h
include/wxunittext.h
+8
-6
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+3
-0
pcbframe.cpp
pcbnew/pcbframe.cpp
+4
-1
No files found.
common/draw_panel_gal.cpp
View file @
761375dd
...
...
@@ -67,7 +67,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_viewControls
=
new
KIGFX
::
WX_VIEW_CONTROLS
(
m_view
,
this
);
Connect
(
wxEVT_PAINT
,
wxPaintEventHandler
(
EDA_DRAW_PANEL_GAL
::
onPaint
),
NULL
,
this
);
Connect
(
wxEVT_SIZE
,
wxSizeEventHandler
(
EDA_DRAW_PANEL_GAL
::
onSize
),
NULL
,
this
);
/* Generic events for the Tool Dispatcher */
...
...
@@ -184,10 +183,21 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
}
void
EDA_DRAW_PANEL_GAL
::
StartDrawing
()
{
m_pendingRefresh
=
false
;
Connect
(
wxEVT_PAINT
,
wxPaintEventHandler
(
EDA_DRAW_PANEL_GAL
::
onPaint
),
NULL
,
this
);
wxPaintEvent
redrawEvent
;
wxPostEvent
(
this
,
redrawEvent
);
}
void
EDA_DRAW_PANEL_GAL
::
StopDrawing
()
{
Disconnect
(
wxEVT_PAINT
,
wxPaintEventHandler
(
EDA_DRAW_PANEL_GAL
::
onPaint
),
NULL
,
this
)
;
m_pendingRefresh
=
true
;
m_refreshTimer
.
Stop
();
Disconnect
(
wxEVT_PAINT
,
wxPaintEventHandler
(
EDA_DRAW_PANEL_GAL
::
onPaint
),
NULL
,
this
);
}
...
...
@@ -198,8 +208,7 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
return
;
// Prevent refreshing canvas during backend switch
m_pendingRefresh
=
true
;
m_refreshTimer
.
Stop
();
StopDrawing
();
delete
m_gal
;
...
...
@@ -228,7 +237,6 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
m_view
->
SetGAL
(
m_gal
);
m_currentGal
=
aGalType
;
m_pendingRefresh
=
false
;
}
...
...
common/tool/context_menu.cpp
View file @
761375dd
...
...
@@ -110,7 +110,7 @@ void CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
{
int
key
=
aAction
.
GetHotKey
()
&
~
MD_MODIFIER_MASK
;
int
mod
=
aAction
.
GetHotKey
()
&
MD_MODIFIER_MASK
;
wxAcceleratorEntryFlags
flags
=
wxACCEL_NORMAL
;
int
flags
=
wxACCEL_NORMAL
;
switch
(
mod
)
{
...
...
common/wxunittext.cpp
View file @
761375dd
...
...
@@ -26,8 +26,12 @@
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <
wx/valnum.h
>
#include <
limits
>
#include <base_units.h>
#if wxCHECK_VERSION( 2, 9, 0 )
#include <wx/valnum.h>
#endif
#include <boost/optional.hpp>
WX_UNIT_TEXT
::
WX_UNIT_TEXT
(
wxWindow
*
aParent
,
const
wxString
&
aLabel
,
double
aValue
,
double
aStep
)
:
wxPanel
(
aParent
,
wxID_ANY
),
...
...
@@ -47,22 +51,29 @@ WX_UNIT_TEXT::WX_UNIT_TEXT( wxWindow* aParent, const wxString& aLabel, double aV
m_inputLabel
->
SetMinSize
(
size
);
sizer
->
Add
(
m_inputLabel
,
1
,
wxALIGN_CENTER_VERTICAL
|
wxALL
|
wxEXPAND
,
5
);
wxFloatingPointValidator
<
double
>
validator
(
4
,
NULL
,
wxNUM_VAL_NO_TRAILING_ZEROES
);
validator
.
SetRange
(
0.0
,
std
::
numeric_limits
<
double
>::
max
()
);
// Main input control
m_inputValue
=
new
wxTextCtrl
(
this
,
wxID_ANY
,
wxEmptyString
,
wxDefaultPosition
,
wxDefaultSize
,
wxTE_PROCESS_ENTER
);
m_inputValue
->
SetValidator
(
validator
);
SetValue
(
aValue
);
sizer
->
Add
(
m_inputValue
,
0
,
wxALIGN_CENTER_VERTICAL
|
wxALL
);
#if wxCHECK_VERSION( 2, 9, 0 ) // Sorry guys, I am tired of dealing with 2.8 compatibility
wxFloatingPointValidator
<
double
>
validator
(
4
,
NULL
,
wxNUM_VAL_NO_TRAILING_ZEROES
);
validator
.
SetRange
(
0.0
,
std
::
numeric_limits
<
double
>::
max
()
);
m_inputValue
->
SetValidator
(
validator
);
// Spin buttons for modifying values using the mouse
m_spinButton
=
new
wxSpinButton
(
this
,
wxID_ANY
);
m_spinButton
->
SetRange
(
std
::
numeric_limits
<
int
>::
min
(),
std
::
numeric_limits
<
int
>::
max
()
);
m_spinButton
->
SetCanFocus
(
false
);
sizer
->
Add
(
m_spinButton
,
0
,
wxALIGN_CENTER_VERTICAL
|
wxALL
);
Connect
(
wxEVT_SPIN_UP
,
wxSpinEventHandler
(
WX_UNIT_TEXT
::
onSpinUpEvent
),
NULL
,
this
);
Connect
(
wxEVT_SPIN_DOWN
,
wxSpinEventHandler
(
WX_UNIT_TEXT
::
onSpinDownEvent
),
NULL
,
this
);
#endif
sizer
->
AddSpacer
(
5
);
// Create units label
...
...
@@ -72,10 +83,6 @@ WX_UNIT_TEXT::WX_UNIT_TEXT( wxWindow* aParent, const wxString& aLabel, double aV
SetSizer
(
sizer
);
Layout
();
Connect
(
wxEVT_SPIN_UP
,
wxSpinEventHandler
(
WX_UNIT_TEXT
::
onSpinUpEvent
),
NULL
,
this
);
Connect
(
wxEVT_SPIN_DOWN
,
wxSpinEventHandler
(
WX_UNIT_TEXT
::
onSpinDownEvent
),
NULL
,
this
);
Connect
(
wxEVT_TEXT_ENTER
,
wxCommandEventHandler
(
WX_UNIT_TEXT
::
onEnter
),
NULL
,
this
);
}
...
...
@@ -98,49 +105,87 @@ void WX_UNIT_TEXT::SetValue( double aValue )
if
(
aValue
>=
0.0
)
{
m_inputValue
->
SetValue
(
Double2Str
(
aValue
)
);
m_inputValue
->
SetValue
(
wxString
(
Double2Str
(
aValue
).
c_str
(),
wxConvUTF8
)
);
m_inputValue
->
MarkDirty
();
}
}
double
WX_UNIT_TEXT
::
GetValue
(
EDA_UNITS_T
aUnit
)
const
/*boost::optional<double>
WX_UNIT_TEXT::GetValue( EDA_UNITS_T aUnit ) const
{
assert
(
false
);
// TODO
if( aUnit == m_units )
return GetValue(); // no conversion needed
switch( m_units )
{
case MILLIMETRES:
switch( aUnit )
{
case INCHES:
iu = Mils2iu( GetValue() * 1000.0 );
break;
case UNSCALED_UNITS:
iu = GetValue();
break;
}
break;
case INCHES:
switch( aUnit )
{
case MILLIMETRES:
return Mils2mm( GetValue() * 1000.0 );
break;
case UNSCALED_UNITS:
return Mils2iu( GetValue() * 1000.0 );
break;
}
break;
case UNSCALED_UNITS:
switch( aUnit )
{
case MILLIMETRES:
return Iu2Mils( GetValue() ) / 1000.0;
break;
// case INCHES:
// return
// break;
}
break;
}
assert( false ); // seems that there are some conversions missing
return 0.0;
}
}
*/
double
WX_UNIT_TEXT
::
GetValue
()
const
boost
::
optional
<
double
>
WX_UNIT_TEXT
::
GetValue
()
const
{
wxString
text
=
m_inputValue
->
GetValue
();
double
value
;
if
(
!
text
.
ToDouble
(
&
value
)
)
value
=
0.0
;
return
boost
::
optional
<
double
>
()
;
return
value
;
return
boost
::
optional
<
double
>
(
value
)
;
}
void
WX_UNIT_TEXT
::
onSpinUpEvent
(
wxSpinEvent
&
aEvent
)
{
SetValue
(
GetValue
()
+
m_step
);
SetValue
(
*
GetValue
()
+
m_step
);
}
void
WX_UNIT_TEXT
::
onSpinDownEvent
(
wxSpinEvent
&
aEvent
)
{
double
newValue
=
GetValue
()
-
m_step
;
double
newValue
=
*
GetValue
()
-
m_step
;
if
(
newValue
>=
0.0
)
SetValue
(
newValue
);
}
void
WX_UNIT_TEXT
::
onEnter
(
wxCommandEvent
&
aEvent
)
{
// Move focus to the next widget
Navigate
();
}
include/class_draw_panel_gal.h
View file @
761375dd
...
...
@@ -111,9 +111,16 @@ public:
m_eventDispatcher
=
aEventDispatcher
;
}
/**
* Function StartDrawing()
* Begins drawing if it was stopped previously.
*/
void
StartDrawing
();
/**
* Function StopDrawing()
* Prevents the GAL canvas from further drawing till it is recreated.
* Prevents the GAL canvas from further drawing till it is recreated
* or StartDrawing() is called.
*/
void
StopDrawing
();
...
...
include/wxunittext.h
View file @
761375dd
...
...
@@ -28,6 +28,11 @@
#include <common.h>
#include <wx/spinbutt.h>
namespace
boost
{
template
<
class
T
>
class
optional
;
}
class
wxTextCtrl
;
class
wxSpinButton
;
class
wxStaticText
;
...
...
@@ -42,7 +47,7 @@ public:
* @param aValue is the initial value for the control.
* @param aStep is the step size when using spin buttons.
*/
WX_UNIT_TEXT
(
wxWindow
*
aParent
,
const
wxString
&
aLabel
=
wxString
(
"Size:"
),
WX_UNIT_TEXT
(
wxWindow
*
aParent
,
const
wxString
&
aLabel
=
_
(
"Size:"
),
double
aValue
=
0
.
0
,
double
aStep
=
0
.
1
);
virtual
~
WX_UNIT_TEXT
();
...
...
@@ -69,13 +74,13 @@ public:
* they are converted first).
* @param aUnits is the wanted unit.
*/
virtual
double
GetValue
(
EDA_UNITS_T
aUnits
)
const
;
//
virtual double GetValue( EDA_UNITS_T aUnits ) const;
/**
* Function GetValue
* Returns the current value in currently used units.
*/
virtual
double
GetValue
()
const
;
virtual
boost
::
optional
<
double
>
GetValue
()
const
;
/**
* Function GetUnits
...
...
@@ -114,9 +119,6 @@ protected:
///> Spin down button click event handler.
void
onSpinDownEvent
(
wxSpinEvent
&
aEvent
);
///> On Enter press event handler.
void
onEnter
(
wxCommandEvent
&
aEvent
);
///> Label for the input (e.g. "Size:")
wxStaticText
*
m_inputLabel
;
...
...
pcbnew/basepcbframe.cpp
View file @
761375dd
...
...
@@ -159,6 +159,9 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
this
,
-
1
,
wxPoint
(
0
,
0
),
m_FrameSize
,
EDA_DRAW_PANEL_GAL
::
GAL_TYPE_CAIRO
)
);
// GAL should not be active yet
GetGalCanvas
()
->
StopDrawing
();
// Hide by default, it has to be explicitly shown
GetGalCanvas
()
->
Hide
();
...
...
pcbnew/pcbframe.cpp
View file @
761375dd
...
...
@@ -673,10 +673,13 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
if
(
aEnable
)
{
ViewReloadBoard
(
m_Pcb
);
GetGalCanvas
()
->
GetView
()
->
RecacheAllItems
();
m_toolManager
.
SetEnvironment
(
m_Pcb
,
GetGalCanvas
()
->
GetView
(),
GetGalCanvas
()
->
GetViewControls
(),
this
);
m_toolManager
.
ResetTools
(
TOOL_BASE
::
GAL_SWITCH
);
m_toolManager
.
ResetTools
(
TOOL_BASE
::
MODEL_RELOAD
);
GetGalCanvas
()
->
StartDrawing
();
}
}
...
...
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