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
4b277784
Commit
4b277784
authored
Feb 10, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic text placing tool.
parent
02316e02
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
4 deletions
+77
-4
edit_pcb_text.cpp
pcbnew/edit_pcb_text.cpp
+3
-2
common_actions.cpp
pcbnew/tools/common_actions.cpp
+4
-0
common_actions.h
pcbnew/tools/common_actions.h
+3
-0
drawing_tool.cpp
pcbnew/tools/drawing_tool.cpp
+64
-2
drawing_tool.h
pcbnew/tools/drawing_tool.h
+2
-0
pcb_tools.cpp
pcbnew/tools/pcb_tools.cpp
+1
-0
No files found.
pcbnew/edit_pcb_text.cpp
View file @
4b277784
...
...
@@ -195,7 +195,8 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
textePcb
->
Copy
(
aText
);
GetBoard
()
->
Add
(
textePcb
);
textePcb
->
SetFlags
(
IS_NEW
);
StartMoveTextePcb
(
textePcb
,
aDC
,
false
);
// Don't erase aText when copying
if
(
aDC
)
StartMoveTextePcb
(
textePcb
,
aDC
,
false
);
// Don't erase aText when copying
}
else
{
...
...
@@ -222,7 +223,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
textePcb
->
DeleteStructure
();
textePcb
=
NULL
;
}
else
else
if
(
aDC
)
{
StartMoveTextePcb
(
textePcb
,
aDC
);
}
...
...
pcbnew/tools/common_actions.cpp
View file @
4b277784
...
...
@@ -68,3 +68,7 @@ TOOL_ACTION COMMON_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle",
TOOL_ACTION
COMMON_ACTIONS
::
drawArc
(
"pcbnew.InteractiveDrawing.arc"
,
AS_GLOBAL
,
'A'
,
"Draw an arc"
,
"Draw an arc"
);
TOOL_ACTION
COMMON_ACTIONS
::
drawText
(
"pcbnew.InteractiveDrawing.text"
,
AS_GLOBAL
,
'T'
,
"Add a text"
,
"Add a text"
);
pcbnew/tools/common_actions.h
View file @
4b277784
...
...
@@ -65,4 +65,7 @@ public:
/// Activation of the drawing tool (arc)
static
TOOL_ACTION
drawArc
;
/// Activation of the drawing tool (text)
static
TOOL_ACTION
drawText
;
};
pcbnew/tools/drawing_tool.cpp
View file @
4b277784
...
...
@@ -30,6 +30,7 @@
#include <view/view_controls.h>
#include <class_board.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_manager.h>
#include <confirm.h>
...
...
@@ -159,7 +160,7 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
{
DRAWSEGMENT
*
newItem
=
new
DRAWSEGMENT
(
graphic
);
view
->
Add
(
newItem
);
getModel
<
BOARD
>
(
PCB_T
)
->
Add
(
newItem
);
board
->
Add
(
newItem
);
newItem
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
}
...
...
@@ -291,7 +292,7 @@ int DRAWING_TOOL::draw( STROKE_T aShape )
{
DRAWSEGMENT
*
newItem
=
new
DRAWSEGMENT
(
graphic
);
view
->
Add
(
newItem
);
getModel
<
BOARD
>
(
PCB_T
)
->
Add
(
newItem
);
board
->
Add
(
newItem
);
newItem
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
if
(
m_continous
)
...
...
@@ -342,9 +343,70 @@ int DRAWING_TOOL::draw( STROKE_T aShape )
}
int
DRAWING_TOOL
::
DrawText
(
TOOL_EVENT
&
aEvent
)
{
KIGFX
::
VIEW
*
view
=
getView
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
// Init the new item attributes
TEXTE_PCB
*
newText
=
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
CreateTextePcb
(
NULL
);
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
preview
.
Add
(
newText
);
view
->
Add
(
&
preview
);
controls
->
ShowCursor
(
true
);
controls
->
SetSnapping
(
true
);
controls
->
SetAutoPan
(
true
);
Activate
();
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
VECTOR2D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
if
(
evt
->
IsCancel
()
)
{
// it was already added by CreateTextPcb()
getModel
<
BOARD
>
(
PCB_T
)
->
Delete
(
newText
);
break
;
}
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
newText
->
ClearFlags
();
view
->
Add
(
newText
);
// board->Add( newText ); // it is already added by CreateTextePcb()
newText
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
break
;
}
else
if
(
evt
->
IsMotion
()
)
{
newText
->
SetTextPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
// Show a preview of the item
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
}
controls
->
ShowCursor
(
false
);
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
setTransitions
();
return
0
;
}
void
DRAWING_TOOL
::
setTransitions
()
{
Go
(
&
DRAWING_TOOL
::
DrawLine
,
COMMON_ACTIONS
::
drawLine
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawCircle
,
COMMON_ACTIONS
::
drawCircle
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawArc
,
COMMON_ACTIONS
::
drawArc
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawText
,
COMMON_ACTIONS
::
drawText
.
MakeEvent
()
);
}
pcbnew/tools/drawing_tool.h
View file @
4b277784
...
...
@@ -55,6 +55,8 @@ public:
int
DrawArc
(
TOOL_EVENT
&
aEvent
);
int
DrawText
(
TOOL_EVENT
&
aEvent
);
private
:
///> Starts drawing a selected shape.
int
draw
(
STROKE_T
aShape
);
...
...
pcbnew/tools/pcb_tools.cpp
View file @
4b277784
...
...
@@ -58,6 +58,7 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawLine
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawCircle
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawArc
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawText
);
// Register tools
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
...
...
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