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
597e98db
Commit
597e98db
authored
Feb 13, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cursor is in world coordinates.
parent
f9f0b46b
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
81 additions
and
130 deletions
+81
-130
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+0
-11
cairo_gal.cpp
common/gal/cairo/cairo_gal.cpp
+11
-11
graphics_abstraction_layer.cpp
common/gal/graphics_abstraction_layer.cpp
+3
-0
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+5
-18
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+22
-22
cairo_gal.h
include/gal/cairo/cairo_gal.h
+4
-4
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+7
-13
opengl_gal.h
include/gal/opengl/opengl_gal.h
+0
-5
view_controls.h
include/view/view_controls.h
+9
-8
wx_view_controls.h
include/view/wx_view_controls.h
+2
-18
router_tool.cpp
pcbnew/router/router_tool.cpp
+1
-1
drawing_tool.cpp
pcbnew/tools/drawing_tool.cpp
+12
-13
edit_tool.cpp
pcbnew/tools/edit_tool.cpp
+5
-6
No files found.
common/drawpanel_gal.cpp
View file @
597e98db
...
...
@@ -45,8 +45,6 @@
#include <profile.h>
#endif
/* __WXDEBUG__ */
#define METRIC_UNIT_LENGTH (1e9)
EDA_DRAW_PANEL_GAL
::
EDA_DRAW_PANEL_GAL
(
wxWindow
*
aParentWindow
,
wxWindowID
aWindowId
,
const
wxPoint
&
aPosition
,
const
wxSize
&
aSize
,
GalType
aGalType
)
:
...
...
@@ -61,11 +59,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
SwitchBackend
(
aGalType
);
SetBackgroundStyle
(
wxBG_STYLE_CUSTOM
);
// Initial display settings
m_gal
->
SetLookAtPoint
(
VECTOR2D
(
0
,
0
)
);
m_gal
->
SetZoomFactor
(
1.0
);
m_gal
->
ComputeWorldScreenMatrix
();
m_painter
=
new
KIGFX
::
PCB_PAINTER
(
m_gal
);
m_view
=
new
KIGFX
::
VIEW
(
true
);
...
...
@@ -220,10 +213,6 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
return
;
}
m_gal
->
SetWorldUnitLength
(
1.0
/
METRIC_UNIT_LENGTH
*
2.54
);
// 1 inch in nanometers
m_gal
->
SetScreenDPI
(
106
);
// Display resolution setting
m_gal
->
ComputeWorldScreenMatrix
();
wxSize
size
=
GetClientSize
();
m_gal
->
ResizeScreen
(
size
.
GetX
(),
size
.
GetY
()
);
...
...
common/gal/cairo/cairo_gal.cpp
View file @
597e98db
...
...
@@ -70,7 +70,7 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
SetSize
(
aParent
->
GetSize
()
);
screenSize
=
VECTOR2D
(
aParent
->
GetSize
()
);
initCursor
(
20
);
initCursor
();
// Grid color settings are different in Cairo and OpenGL
SetGridColor
(
COLOR4D
(
0.1
,
0.1
,
0.1
,
0.8
)
);
...
...
@@ -881,11 +881,10 @@ void CAIRO_GAL::skipMouseEvent( wxMouseEvent& aEvent )
}
void
CAIRO_GAL
::
initCursor
(
int
aCursorSize
)
void
CAIRO_GAL
::
initCursor
()
{
cursorPixels
=
new
wxBitmap
(
aCursorSize
,
aCursorSize
);
cursorPixelsSaved
=
new
wxBitmap
(
aCursorSize
,
aCursorSize
);
cursorSize
=
aCursorSize
;
cursorPixels
=
new
wxBitmap
(
cursorSize
,
cursorSize
);
cursorPixelsSaved
=
new
wxBitmap
(
cursorSize
,
cursorSize
);
wxMemoryDC
cursorShape
(
*
cursorPixels
);
...
...
@@ -896,8 +895,8 @@ void CAIRO_GAL::initCursor( int aCursorSize )
cursorShape
.
SetPen
(
pen
);
cursorShape
.
Clear
();
cursorShape
.
DrawLine
(
0
,
aCursorSize
/
2
,
aCursorSize
,
aC
ursorSize
/
2
);
cursorShape
.
DrawLine
(
aCursorSize
/
2
,
0
,
aCursorSize
/
2
,
aC
ursorSize
);
cursorShape
.
DrawLine
(
0
,
cursorSize
/
2
,
cursorSize
,
c
ursorSize
/
2
);
cursorShape
.
DrawLine
(
cursorSize
/
2
,
0
,
cursorSize
/
2
,
c
ursorSize
);
}
...
...
@@ -921,14 +920,15 @@ void CAIRO_GAL::blitCursor( wxBufferedDC& clientDC )
}
// Store pixels that are going to be overpainted
cursorSave
.
Blit
(
0
,
0
,
cursorSize
,
cursorSize
,
&
clientDC
,
cursorPosition
.
x
,
cursorPosition
.
y
);
VECTOR2D
cursorScreen
=
ToScreen
(
cursorPosition
)
-
cursorSize
/
2
;
cursorSave
.
Blit
(
0
,
0
,
cursorSize
,
cursorSize
,
&
clientDC
,
cursorScreen
.
x
,
cursorScreen
.
y
);
// Draw the cursor
clientDC
.
Blit
(
cursor
Position
.
x
,
cursorPositio
n
.
y
,
cursorSize
,
cursorSize
,
clientDC
.
Blit
(
cursor
Screen
.
x
,
cursorScree
n
.
y
,
cursorSize
,
cursorSize
,
&
cursorShape
,
0
,
0
,
wxOR
);
savedCursorPosition
.
x
=
(
wxCoord
)
cursor
Positio
n
.
x
;
savedCursorPosition
.
y
=
(
wxCoord
)
cursor
Positio
n
.
y
;
savedCursorPosition
.
x
=
(
wxCoord
)
cursor
Scree
n
.
x
;
savedCursorPosition
.
y
=
(
wxCoord
)
cursor
Scree
n
.
y
;
}
...
...
common/gal/graphics_abstraction_layer.cpp
View file @
597e98db
...
...
@@ -39,7 +39,10 @@ GAL::GAL() :
SetIsStroke
(
true
);
SetFillColor
(
COLOR4D
(
0.0
,
0.0
,
0.0
,
0.0
)
);
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
SetLookAtPoint
(
VECTOR2D
(
0
,
0
)
);
SetZoomFactor
(
1.0
);
SetWorldUnitLength
(
1.0
/
METRIC_UNIT_LENGTH
*
2.54
);
// 1 inch in nanometers
SetScreenDPI
(
106
);
// Display resolution setting
SetDepthRange
(
VECTOR2D
(
GAL
::
MIN_DEPTH
,
GAL
::
MAX_DEPTH
)
);
SetFlip
(
false
,
false
);
SetLineWidth
(
1.0
);
...
...
common/gal/opengl/opengl_gal.cpp
View file @
597e98db
...
...
@@ -86,7 +86,6 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
SetSize
(
aParent
->
GetSize
()
);
screenSize
=
VECTOR2D
(
aParent
->
GetSize
()
);
initCursor
(
80
);
// Grid color settings are different in Cairo and OpenGL
SetGridColor
(
COLOR4D
(
0.8
,
0.8
,
0.8
,
0.1
)
);
...
...
@@ -769,8 +768,8 @@ void OPENGL_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
{
// Now we should only store the position of the mouse cursor
// The real drawing routines are in blitCursor()
cursorPosition
=
VECTOR2D
(
aCursorPosition
.
x
,
screenSize
.
y
-
aCursorPosition
.
y
);
// invert Y axis
VECTOR2D
screenCursor
=
worldScreenMatrix
*
aCursorPosition
;
cursorPosition
=
screenWorldMatrix
*
VECTOR2D
(
screenCursor
.
x
,
screenSize
.
y
-
screenCursor
.
y
);
}
...
...
@@ -780,13 +779,9 @@ void OPENGL_GAL::drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd
// We do not need a very precise comparison here (the lineWidth is set by GAL::DrawGrid())
if
(
fabs
(
lineWidth
-
2.0
*
gridLineWidth
/
worldScale
)
<
0.1
)
{
glLineWidth
(
1.0
);
}
else
{
glLineWidth
(
2.0
);
}
glColor4d
(
gridColor
.
r
,
gridColor
.
g
,
gridColor
.
b
,
gridColor
.
a
);
...
...
@@ -970,12 +965,6 @@ void OPENGL_GAL::initGlew()
}
void
OPENGL_GAL
::
initCursor
(
int
aCursorSize
)
{
cursorSize
=
aCursorSize
;
}
void
OPENGL_GAL
::
blitCursor
()
{
if
(
!
isCursorEnabled
)
...
...
@@ -983,11 +972,9 @@ void OPENGL_GAL::blitCursor()
compositor
.
SetBuffer
(
OPENGL_COMPOSITOR
::
DIRECT_RENDERING
);
VECTOR2D
cursorBegin
=
ToWorld
(
cursorPosition
-
VECTOR2D
(
cursorSize
/
2
,
cursorSize
/
2
)
);
VECTOR2D
cursorEnd
=
ToWorld
(
cursorPosition
+
VECTOR2D
(
cursorSize
/
2
,
cursorSize
/
2
)
);
VECTOR2D
cursorCenter
=
(
cursorBegin
+
cursorEnd
)
/
2.0
;
VECTOR2D
cursorBegin
=
cursorPosition
-
cursorSize
/
(
2
*
worldScale
);
VECTOR2D
cursorEnd
=
cursorPosition
+
cursorSize
/
(
2
*
worldScale
);
VECTOR2D
cursorCenter
=
(
cursorBegin
+
cursorEnd
)
/
2
;
glDisable
(
GL_TEXTURE_2D
);
glLineWidth
(
1.0
);
...
...
common/view/wx_view_controls.cpp
View file @
597e98db
...
...
@@ -68,11 +68,6 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled )
void
WX_VIEW_CONTROLS
::
onMotion
(
wxMouseEvent
&
aEvent
)
{
m_mousePosition
.
x
=
aEvent
.
GetX
();
m_mousePosition
.
y
=
aEvent
.
GetY
();
updateCursor
();
bool
isAutoPanning
=
false
;
if
(
m_autoPanEnabled
)
...
...
@@ -82,7 +77,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
{
if
(
m_state
==
DRAG_PANNING
)
{
VECTOR2D
d
=
m_dragStartPoint
-
m_mousePosition
;
VECTOR2D
d
=
m_dragStartPoint
-
VECTOR2D
(
aEvent
.
GetX
(),
aEvent
.
GetY
()
)
;
VECTOR2D
delta
=
m_view
->
ToWorld
(
d
,
false
);
m_view
->
SetCenter
(
m_lookStartPoint
+
delta
);
...
...
@@ -197,8 +192,6 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir
=
m_view
->
ToWorld
(
dir
,
false
);
m_view
->
SetCenter
(
m_view
->
GetCenter
()
+
dir
*
m_autoPanSpeed
);
updateCursor
();
// Notify tools that the cursor position has changed in the world coordinates
wxMouseEvent
moveEvent
(
EVT_REFRESH_MOUSE
);
...
...
@@ -236,7 +229,7 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
}
const
VECTOR2D
WX_VIEW_CONTROLS
::
GetMousePosition
()
const
VECTOR2D
WX_VIEW_CONTROLS
::
GetMousePosition
()
const
{
wxPoint
msp
=
wxGetMousePosition
();
wxPoint
winp
=
m_parentPanel
->
GetScreenPosition
();
...
...
@@ -245,6 +238,22 @@ const VECTOR2D WX_VIEW_CONTROLS::GetMousePosition() const
}
VECTOR2D
WX_VIEW_CONTROLS
::
GetCursorPosition
()
const
{
if
(
m_forceCursorPosition
)
return
m_forcedPosition
;
else
{
VECTOR2D
mousePosition
=
GetMousePosition
();
if
(
m_snappingEnabled
)
return
m_view
->
ToWorld
(
m_view
->
GetGAL
()
->
GetGridPoint
(
mousePosition
)
);
else
return
m_view
->
ToWorld
(
mousePosition
);
}
}
bool
WX_VIEW_CONTROLS
::
handleAutoPanning
(
const
wxMouseEvent
&
aEvent
)
{
VECTOR2D
p
(
aEvent
.
GetX
(),
aEvent
.
GetY
()
);
...
...
@@ -255,17 +264,19 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
double
borderEndX
=
m_view
->
GetScreenPixelSize
().
x
-
borderStart
;
double
borderEndY
=
m_view
->
GetScreenPixelSize
().
y
-
borderStart
;
m_panDirection
=
VECTOR2D
();
if
(
p
.
x
<
borderStart
)
m_panDirection
.
x
=
-
(
borderStart
-
p
.
x
);
else
if
(
p
.
x
>
borderEndX
)
m_panDirection
.
x
=
(
p
.
x
-
borderEndX
);
else
m_panDirection
.
x
=
0
;
if
(
p
.
y
<
borderStart
)
m_panDirection
.
y
=
-
(
borderStart
-
p
.
y
);
else
if
(
p
.
y
>
borderEndY
)
m_panDirection
.
y
=
(
p
.
y
-
borderEndY
);
else
m_panDirection
.
y
=
0
;
bool
borderHit
=
(
m_panDirection
.
x
!=
0
||
m_panDirection
.
y
!=
0
);
...
...
@@ -302,14 +313,3 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
wxASSERT_MSG
(
false
,
wxT
(
"This line should never be reached"
)
);
return
false
;
// Should not be reached, just avoid the compiler warnings..
}
void
WX_VIEW_CONTROLS
::
updateCursor
()
{
if
(
m_forceCursorPosition
)
m_cursorPosition
=
m_view
->
ToScreen
(
m_forcedPosition
);
else
if
(
m_snappingEnabled
)
m_cursorPosition
=
m_view
->
GetGAL
()
->
GetGridPoint
(
m_mousePosition
);
else
m_cursorPosition
=
m_mousePosition
;
}
include/gal/cairo/cairo_gal.h
View file @
597e98db
...
...
@@ -283,8 +283,6 @@ private:
wxPoint
savedCursorPosition
;
///< The last cursor position
wxBitmap
*
cursorPixels
;
///< Cursor pixels
wxBitmap
*
cursorPixelsSaved
;
///< Saved cursor pixels
int
cursorSize
;
///< Cursor size
VECTOR2D
cursorPosition
;
///< Current cursor position
/// Maximum number of arguments for one command
static
const
int
MAX_CAIRO_ARGUMENTS
=
6
;
...
...
@@ -354,8 +352,10 @@ private:
*/
void
skipMouseEvent
(
wxMouseEvent
&
aEvent
);
/// @copydoc GAL::initCursor()
virtual
void
initCursor
(
int
aCursorSize
);
/**
* @brief Prepares cursor bitmap.
*/
virtual
void
initCursor
();
/**
* @brief Blits cursor into the current screen.
...
...
include/gal/graphics_abstraction_layer.h
View file @
597e98db
...
...
@@ -720,17 +720,15 @@ public:
/// @brief Draw the grid
void
DrawGrid
();
/**
* Function GetGridPoint()
* For a given point it returns the nearest point belonging to the grid.
* For a given point it returns the nearest point belonging to the grid
in screen coordinates
.
*
* @param aPoint is the point for which the grid point is searched.
* @return The nearest grid point.
* @return The nearest grid point
in screen coordinates
.
*/
VECTOR2D
GetGridPoint
(
const
VECTOR2D
&
aPoint
)
const
;
/**
* @brief Change the grid display style.
*
...
...
@@ -786,7 +784,7 @@ public:
/**
* @brief Set the cursor size.
*
* @param aCursorSize is the size of the cursor.
* @param aCursorSize is the size of the cursor
expressed in pixels
.
*/
inline
void
SetCursorSize
(
unsigned
int
aCursorSize
)
{
...
...
@@ -829,6 +827,8 @@ public:
/// Depth level on which the grid is drawn
static
const
int
GRID_DEPTH
=
1024
;
static
const
double
METRIC_UNIT_LENGTH
=
1e9
;
protected
:
std
::
stack
<
double
>
depthStack
;
///< Stored depth values
VECTOR2D
screenSize
;
///< Screen size in screen coordinates
...
...
@@ -870,7 +870,8 @@ protected:
bool
isCursorEnabled
;
///< Is the cursor enabled?
COLOR4D
cursorColor
;
///< Cursor color
int
cursorSize
;
///< Size of the cursor in pixels
unsigned
int
cursorSize
;
///< Size of the cursor in pixels
VECTOR2D
cursorPosition
;
///< Current cursor position (world coordinates)
/// Instance of object that stores information about how to draw texts
STROKE_FONT
strokeFont
;
...
...
@@ -889,13 +890,6 @@ protected:
*/
virtual
void
drawGridLine
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
)
=
0
;
/**
* @brief Initialize the cursor.
*
* @param aCursorSize is the size of the cursor.
*/
virtual
void
initCursor
(
int
aCursorSize
)
=
0
;
static
const
int
MIN_DEPTH
=
-
2048
;
static
const
int
MAX_DEPTH
=
2047
;
};
...
...
include/gal/opengl/opengl_gal.h
View file @
597e98db
...
...
@@ -299,8 +299,6 @@ private:
bool
isShaderInitialized
;
///< Was the shader initialized?
bool
isGrouping
;
///< Was a group started?
VECTOR2D
cursorPosition
;
///< Current cursor position
// Polygon tesselation
/// The tessellator
GLUtesselator
*
tesselator
;
...
...
@@ -364,9 +362,6 @@ private:
/// Initialize GLEW
void
initGlew
();
/// @copydoc GAL::initCursor()
virtual
void
initCursor
(
int
aCursorSize
);
/**
* @brief Blits cursor into the current screen.
*/
...
...
include/view/view_controls.h
View file @
597e98db
...
...
@@ -108,21 +108,22 @@ public:
/**
* Function GetMousePosition()
* Returns the current mouse pointer position in
the
screen coordinates. Note, that it may be
* Returns the current mouse pointer position in screen coordinates. Note, that it may be
* different from the cursor position if snapping is enabled (@see GetCursorPosition()).
*
* @return The current mouse pointer position.
* @return The current mouse pointer position
in screen coordinates
.
*/
virtual
const
VECTOR2D
GetMousePosition
()
const
=
0
;
virtual
VECTOR2D
GetMousePosition
()
const
=
0
;
/**
* Function GetCursorPosition()
* Returns the current cursor position in the screen coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled (@see GetMousePosition()).
* Returns the current cursor position in world coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled or cursor position
* is forced to specific point.
*
* @return The current cursor position in
screen
coordinates.
* @return The current cursor position in
world
coordinates.
*/
virtual
const
VECTOR2D
GetCursorPosition
()
const
=
0
;
virtual
VECTOR2D
GetCursorPosition
()
const
=
0
;
/**
...
...
@@ -131,7 +132,7 @@ public:
* @param aEnabled enable forced cursor position
* @param aPosition the position
*/
virtual
void
ForceCursorPosition
(
bool
aEnabled
,
const
VECTOR2D
&
aPosition
=
VECTOR2D
(
0
,
0
)
)
virtual
void
ForceCursorPosition
(
bool
aEnabled
,
const
VECTOR2D
&
aPosition
=
VECTOR2D
(
0
,
0
)
)
{
m_forcedPosition
=
aPosition
;
m_forceCursorPosition
=
aEnabled
;
...
...
include/view/wx_view_controls.h
View file @
597e98db
...
...
@@ -58,13 +58,6 @@ public:
void
onEnter
(
wxMouseEvent
&
WXUNUSED
(
aEvent
)
);
void
onTimer
(
wxTimerEvent
&
WXUNUSED
(
aEvent
)
);
///> @copydoc VIEW_CONTROLS::SetSnapping()
void
SetSnapping
(
bool
aEnabled
)
{
VIEW_CONTROLS
::
SetSnapping
(
aEnabled
);
updateCursor
();
}
/**
* Function SetGrabMouse()
* Enables/disables mouse cursor grabbing (limits the movement field only to the panel area).
...
...
@@ -88,13 +81,10 @@ public:
}
/// @copydoc VIEW_CONTROLS::GetMousePosition()
const
VECTOR2D
GetMousePosition
()
const
;
VECTOR2D
GetMousePosition
()
const
;
/// @copydoc VIEW_CONTROLS::GetCursorPosition()
const
VECTOR2D
GetCursorPosition
()
const
{
return
m_cursorPosition
;
}
VECTOR2D
GetCursorPosition
()
const
;
/// Event that forces mouse move event in the dispatcher (eg. used in autopanning, when mouse
/// cursor does not move in screen coordinates, but does in world coordinates)
...
...
@@ -119,12 +109,6 @@ private:
*/
bool
handleAutoPanning
(
const
wxMouseEvent
&
aEvent
);
/**
* Function updateCursor()
* Recomputes the cursor coordinates basing on the current snapping settings and mouse position.
*/
void
updateCursor
();
/// Current state of VIEW_CONTROLS
STATE
m_state
;
...
...
pcbnew/router/router_tool.cpp
View file @
597e98db
...
...
@@ -281,7 +281,7 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent )
else
{
m_endItem
=
NULL
;
m_endSnapPoint
=
getView
()
->
ToWorld
(
ctls
->
GetCursorPosition
()
);
m_endSnapPoint
=
ctls
->
GetCursorPosition
(
);
ctls
->
ForceCursorPosition
(
false
);
}
...
...
pcbnew/tools/drawing_tool.cpp
View file @
597e98db
...
...
@@ -109,7 +109,7 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
break
;
...
...
@@ -254,7 +254,7 @@ int DRAWING_TOOL::draw( STROKE_T aShape )
{
// Enable 45 degrees lines only mode by holding shift
bool
linesAngle45
=
evt
->
Modifier
(
MD_SHIFT
);
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
break
;
...
...
@@ -343,7 +343,6 @@ int DRAWING_TOOL::draw( STROKE_T aShape )
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
setTransitions
();
return
0
;
...
...
@@ -377,7 +376,7 @@ int DRAWING_TOOL::DrawText( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
{
...
...
@@ -465,7 +464,7 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
{
...
...
@@ -606,14 +605,14 @@ int DRAWING_TOOL::DrawZone( TOOL_EVENT& aEvent )
Activate
();
VECTOR2
D
lastCursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
lastCursorPos
=
controls
->
GetCursorPosition
(
);
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
// Enable 45 degrees lines only mode by holding shift
bool
linesAngle45
=
evt
->
Modifier
(
MD_SHIFT
);
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
{
...
...
@@ -750,14 +749,14 @@ int DRAWING_TOOL::DrawKeepout( TOOL_EVENT& aEvent )
Activate
();
VECTOR2
D
lastCursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
lastCursorPos
=
controls
->
GetCursorPosition
(
);
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
// Enable 45 degrees lines only mode by holding shift
bool
linesAngle45
=
evt
->
Modifier
(
MD_SHIFT
);
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
{
...
...
@@ -867,7 +866,7 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
target
->
SetLayer
(
EDGE_N
);
target
->
SetWidth
(
board
->
GetDesignSettings
().
m_EdgeSegmentWidth
);
target
->
SetSize
(
Millimeter2iu
(
5
)
);
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
target
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
// Add a VIEW_GROUP that serves as a preview for the new item
...
...
@@ -883,7 +882,7 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
{
...
...
@@ -944,7 +943,7 @@ int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent )
}
// Init the new item attributes
VECTOR2
D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
VECTOR2
I
cursorPos
=
controls
->
GetCursorPosition
(
);
module
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
// Add a VIEW_GROUP that serves as a preview for the new item
...
...
@@ -961,7 +960,7 @@ int DRAWING_TOOL::PlaceModule( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
cursorPos
=
controls
->
GetCursorPosition
(
);
if
(
evt
->
IsCancel
()
)
{
...
...
pcbnew/tools/edit_tool.cpp
View file @
597e98db
...
...
@@ -81,7 +81,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
if
(
!
makeSelection
(
selection
)
)
return
0
;
VECTOR2
D
dragPosition
;
// The last position of the cursor while dragging
VECTOR2
I
dragPosition
;
// The last position of the cursor while dragging
m_dragging
=
false
;
// Are selected items being dragged?
bool
restore
=
false
;
// Should items' state be restored when finishing the tool?
...
...
@@ -131,8 +131,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
if
(
m_dragging
)
{
// Drag items to the current cursor position
VECTOR2D
movement
=
(
getView
()
->
ToWorld
(
controls
->
GetCursorPosition
()
)
-
dragPosition
);
VECTOR2I
movement
=
(
controls
->
GetCursorPosition
()
-
dragPosition
);
for
(
unsigned
int
i
=
0
;
i
<
selection
.
items
.
GetCount
();
++
i
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
i
)
);
...
...
@@ -151,7 +150,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
}
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
dragPosition
=
getView
()
->
ToWorld
(
controls
->
GetCursorPosition
()
);
dragPosition
=
controls
->
GetCursorPosition
(
);
}
else
if
(
evt
->
IsMouseUp
(
BUT_LEFT
)
||
evt
->
IsClick
(
BUT_LEFT
)
)
...
...
@@ -205,7 +204,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
{
// Display properties dialog
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
0
)
);
VECTOR2I
cursor
=
getView
()
->
ToWorld
(
getViewControls
()
->
GetCursorPosition
()
);
VECTOR2I
cursor
=
getView
Controls
()
->
GetCursorPosition
(
);
// Check if user wants to edit pad or module properties
if
(
item
->
Type
()
==
PCB_MODULE_T
)
...
...
@@ -451,7 +450,7 @@ wxPoint EDIT_TOOL::getModificationPoint( const SELECTION_TOOL::SELECTION& aSelec
}
else
{
VECTOR2I
cursor
=
getView
()
->
ToWorld
(
getViewControls
()
->
GetCursorPosition
()
);
VECTOR2I
cursor
=
getView
Controls
()
->
GetCursorPosition
(
);
return
wxPoint
(
cursor
.
x
,
cursor
.
y
);
}
}
...
...
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