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
85e8b8bd
Commit
85e8b8bd
authored
Mar 13, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Yet another approach to 45 degree constraints.
parent
f9d5f584
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
17 deletions
+48
-17
edit_points.h
pcbnew/tools/edit_points.h
+9
-0
point_editor.cpp
pcbnew/tools/point_editor.cpp
+36
-17
point_editor.h
pcbnew/tools/point_editor.h
+3
-0
No files found.
pcbnew/tools/edit_points.h
View file @
85e8b8bd
...
@@ -59,6 +59,15 @@ public:
...
@@ -59,6 +59,15 @@ public:
*/
*/
virtual
void
Apply
()
=
0
;
virtual
void
Apply
()
=
0
;
/**
* Function Update()
*
* Updates contraint's traits.
*/
virtual
void
Update
()
{
}
protected
:
protected
:
EDIT_POINT
&
m_constrained
;
///< Point that is constrained by rules implemented by Apply()
EDIT_POINT
&
m_constrained
;
///< Point that is constrained by rules implemented by Apply()
};
};
...
...
pcbnew/tools/point_editor.cpp
View file @
85e8b8bd
...
@@ -134,7 +134,8 @@ private:
...
@@ -134,7 +134,8 @@ private:
POINT_EDITOR
::
POINT_EDITOR
()
:
POINT_EDITOR
::
POINT_EDITOR
()
:
TOOL_INTERACTIVE
(
"pcbnew.PointEditor"
),
m_selectionTool
(
NULL
),
m_dragPoint
(
NULL
)
TOOL_INTERACTIVE
(
"pcbnew.PointEditor"
),
m_selectionTool
(
NULL
),
m_dragPoint
(
NULL
),
m_original
(
VECTOR2I
(
0
,
0
)
)
{
{
}
}
...
@@ -175,7 +176,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
...
@@ -175,7 +176,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
PCB_EDIT_FRAME
*
editFrame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
PCB_EDIT_FRAME
*
editFrame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
EDA_ITEM
*
item
=
selection
.
items
.
GetPickedItem
(
0
);
EDA_ITEM
*
item
=
selection
.
items
.
GetPickedItem
(
0
);
EDIT_POINT
constrainer
(
VECTOR2I
(
0
,
0
)
);
EDIT_POINT
constrainer
(
VECTOR2I
(
0
,
0
)
);
boo
l
degree45
=
false
;
// 45 degree mode
boo
st
::
shared_ptr
<
EDIT_POINT_CONSTRAINT
>
degree45Constraint
;
m_editPoints
=
EDIT_POINTS_FACTORY
::
Make
(
item
);
m_editPoints
=
EDIT_POINTS_FACTORY
::
Make
(
item
);
if
(
!
m_editPoints
)
if
(
!
m_editPoints
)
...
@@ -232,27 +233,31 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
...
@@ -232,27 +233,31 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
editFrame
->
OnModify
();
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
controls
->
ForceCursorPosition
(
false
);
controls
->
ForceCursorPosition
(
false
);
m_original
=
*
m_dragPoint
;
// Save the original position
modified
=
true
;
modified
=
true
;
}
}
if
(
!!
evt
->
Modifier
(
MD_CTRL
)
!=
degree45
)
// 45 degrees mode
if
(
!!
evt
->
Modifier
(
MD_CTRL
)
!=
(
bool
)
degree45Constraint
)
// 45 degrees mode
{
{
degree45
=
evt
->
Modifier
(
MD_CTRL
);
if
(
!
degree45Constraint
)
if
(
degree45
)
{
{
// Find a proper constraining point for 45 degrees mode
// Find a proper constraining point for 45 degrees mode
constrainer
=
get45DegConstrainer
();
constrainer
=
get45DegConstrainer
();
m_dragPoint
->
SetConstrain
t
(
new
EPC_45DEGREE
(
*
m_dragPoint
,
constrainer
)
);
degree45Constraint
.
rese
t
(
new
EPC_45DEGREE
(
*
m_dragPoint
,
constrainer
)
);
}
}
else
else
{
{
m_dragPoint
->
ClearConstrain
t
();
degree45Constraint
.
rese
t
();
}
}
}
}
m_dragPoint
->
SetPosition
(
controls
->
GetCursorPosition
()
);
m_dragPoint
->
SetPosition
(
controls
->
GetCursorPosition
()
);
if
(
degree45Constraint
)
degree45Constraint
->
Apply
();
else
m_dragPoint
->
ApplyConstraint
();
m_dragPoint
->
ApplyConstraint
();
updateItem
();
updateItem
();
updatePoints
();
updatePoints
();
...
@@ -436,15 +441,15 @@ void POINT_EDITOR::updateItem() const
...
@@ -436,15 +441,15 @@ void POINT_EDITOR::updateItem() const
else
if
(
isModified
(
(
*
m_editPoints
)[
2
]
)
)
else
if
(
isModified
(
(
*
m_editPoints
)[
2
]
)
)
{
{
dimension
->
SetOrigin
(
wxPoint
(
m_dragPoint
->
GetPosition
().
x
,
m_dragPoint
->
GetPosition
().
y
)
);
dimension
->
SetOrigin
(
wxPoint
(
m_dragPoint
->
GetPosition
().
x
,
m_dragPoint
->
GetPosition
().
y
)
);
static_cast
<
EPC_LINE
*>
(
(
*
m_editPoints
)[
0
].
GetConstraint
()
)
->
Update
();
(
*
m_editPoints
)[
0
].
GetConstraint
(
)
->
Update
();
static_cast
<
EPC_LINE
*>
(
(
*
m_editPoints
)[
1
].
GetConstraint
()
)
->
Update
();
(
*
m_editPoints
)[
1
].
GetConstraint
(
)
->
Update
();
}
}
else
if
(
isModified
(
(
*
m_editPoints
)[
3
]
)
)
else
if
(
isModified
(
(
*
m_editPoints
)[
3
]
)
)
{
{
dimension
->
SetEnd
(
wxPoint
(
m_dragPoint
->
GetPosition
().
x
,
m_dragPoint
->
GetPosition
().
y
)
);
dimension
->
SetEnd
(
wxPoint
(
m_dragPoint
->
GetPosition
().
x
,
m_dragPoint
->
GetPosition
().
y
)
);
static_cast
<
EPC_LINE
*>
(
(
*
m_editPoints
)[
0
].
GetConstraint
()
)
->
Update
();
(
*
m_editPoints
)[
0
].
GetConstraint
(
)
->
Update
();
static_cast
<
EPC_LINE
*>
(
(
*
m_editPoints
)[
1
].
GetConstraint
()
)
->
Update
();
(
*
m_editPoints
)[
1
].
GetConstraint
(
)
->
Update
();
}
}
break
;
break
;
...
@@ -538,7 +543,9 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
...
@@ -538,7 +543,9 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
{
{
EDA_ITEM
*
item
=
m_editPoints
->
GetParent
();
EDA_ITEM
*
item
=
m_editPoints
->
GetParent
();
if
(
item
->
Type
()
==
PCB_LINE_T
)
switch
(
item
->
Type
()
)
{
case
PCB_LINE_T
:
{
{
const
DRAWSEGMENT
*
segment
=
static_cast
<
const
DRAWSEGMENT
*>
(
item
);
const
DRAWSEGMENT
*
segment
=
static_cast
<
const
DRAWSEGMENT
*>
(
item
);
{
{
...
@@ -555,8 +562,11 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
...
@@ -555,8 +562,11 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
break
;
break
;
}
}
}
}
break
;
}
}
else
if
(
item
->
Type
()
==
PCB_DIMENSION_T
)
case
PCB_DIMENSION_T
:
{
{
// Constraint for crossbar
// Constraint for crossbar
if
(
isModified
(
(
*
m_editPoints
)[
2
]
)
)
if
(
isModified
(
(
*
m_editPoints
)[
2
]
)
)
...
@@ -564,8 +574,17 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
...
@@ -564,8 +574,17 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const
else
if
(
isModified
(
(
*
m_editPoints
)[
3
]
)
)
else
if
(
isModified
(
(
*
m_editPoints
)[
3
]
)
)
return
(
*
m_editPoints
)[
2
];
return
(
*
m_editPoints
)[
2
];
else
return
EDIT_POINT
(
m_dragPoint
->
GetPosition
()
);
// no constraint
break
;
}
default
:
break
;
}
}
// In any other case we may align item to the current cursor position.
// In any other case we may align item to the current cursor position.
TODO wrong desc
return
EDIT_POINT
(
getViewControls
()
->
GetCursorPosition
()
)
;
return
m_original
;
}
}
pcbnew/tools/point_editor.h
View file @
85e8b8bd
...
@@ -62,6 +62,9 @@ private:
...
@@ -62,6 +62,9 @@ private:
///> Currently edited point, NULL if there is none.
///> Currently edited point, NULL if there is none.
EDIT_POINT
*
m_dragPoint
;
EDIT_POINT
*
m_dragPoint
;
///> Original position for the current drag point.
EDIT_POINT
m_original
;
///> Currently available edit points.
///> Currently available edit points.
boost
::
shared_ptr
<
EDIT_POINTS
>
m_editPoints
;
boost
::
shared_ptr
<
EDIT_POINTS
>
m_editPoints
;
...
...
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