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
c7fe98db
Commit
c7fe98db
authored
Dec 07, 2011
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encapsulate SCH_BUS_ENTRY class.
parent
b6dcf9b7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
51 deletions
+90
-51
busentry.cpp
eeschema/busentry.cpp
+7
-3
sch_bus_entry.cpp
eeschema/sch_bus_entry.cpp
+66
-40
sch_bus_entry.h
eeschema/sch_bus_entry.h
+17
-8
No files found.
eeschema/busentry.cpp
View file @
c7fe98db
...
...
@@ -74,16 +74,20 @@ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int en
BusEntry
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
g_XorMode
);
wxSize
size
=
BusEntry
->
GetSize
();
switch
(
entry_shape
)
{
case
'\\'
:
s_LastShape
=
'\\'
;
BusEntry
->
m_Size
.
y
=
100
;
size
.
y
=
100
;
BusEntry
->
SetSize
(
size
);
break
;
case
'/'
:
s_LastShape
=
'/'
;
BusEntry
->
m_Size
.
y
=
-
100
;
size
.
y
=
-
100
;
BusEntry
->
SetSize
(
size
);
break
;
}
...
...
@@ -97,7 +101,7 @@ int SCH_EDIT_FRAME::GetBusEntryShape( SCH_BUS_ENTRY* BusEntry )
{
int
entry_shape
=
'\\'
;
if
(
BusEntry
->
m_Size
.
y
<
0
)
if
(
BusEntry
->
GetSize
()
.
y
<
0
)
entry_shape
=
'/'
;
return
entry_shape
;
...
...
eeschema/sch_bus_entry.cpp
View file @
c7fe98db
/***********************/
/* class SCH_BUS_ENTRY */
/***********************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sch_bus_entry.cpp
*
*/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -19,11 +45,11 @@
SCH_BUS_ENTRY
::
SCH_BUS_ENTRY
(
const
wxPoint
&
pos
,
int
shape
,
int
id
)
:
SCH_ITEM
(
NULL
,
SCH_BUS_ENTRY_T
)
{
m_
P
os
=
pos
;
m_
S
ize
.
x
=
100
;
m_
S
ize
.
y
=
100
;
m_
p
os
=
pos
;
m_
s
ize
.
x
=
100
;
m_
s
ize
.
y
=
100
;
m_Layer
=
LAYER_WIRE
;
m_
W
idth
=
0
;
m_
w
idth
=
0
;
if
(
id
==
BUS_TO_BUS
)
{
...
...
@@ -31,16 +57,16 @@ SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) :
}
if
(
shape
==
'/'
)
m_
S
ize
.
y
=
-
100
;
m_
s
ize
.
y
=
-
100
;
}
SCH_BUS_ENTRY
::
SCH_BUS_ENTRY
(
const
SCH_BUS_ENTRY
&
aBusEntry
)
:
SCH_ITEM
(
aBusEntry
)
{
m_
Pos
=
aBusEntry
.
m_P
os
;
m_
Size
=
aBusEntry
.
m_S
ize
;
m_
Width
=
aBusEntry
.
m_W
idth
;
m_
pos
=
aBusEntry
.
m_p
os
;
m_
size
=
aBusEntry
.
m_s
ize
;
m_
width
=
aBusEntry
.
m_w
idth
;
}
...
...
@@ -52,7 +78,7 @@ EDA_ITEM* SCH_BUS_ENTRY::doClone() const
wxPoint
SCH_BUS_ENTRY
::
m_End
()
const
{
return
wxPoint
(
m_
Pos
.
x
+
m_Size
.
x
,
m_Pos
.
y
+
m_S
ize
.
y
);
return
wxPoint
(
m_
pos
.
x
+
m_size
.
x
,
m_pos
.
y
+
m_s
ize
.
y
);
}
...
...
@@ -62,9 +88,9 @@ void SCH_BUS_ENTRY::SwapData( SCH_ITEM* aItem )
wxT
(
"Cannot swap bus entry data with invalid item."
)
);
SCH_BUS_ENTRY
*
item
=
(
SCH_BUS_ENTRY
*
)
aItem
;
EXCHG
(
m_
Pos
,
item
->
m_P
os
);
EXCHG
(
m_
Size
,
item
->
m_S
ize
);
EXCHG
(
m_
Width
,
item
->
m_W
idth
);
EXCHG
(
m_
pos
,
item
->
m_p
os
);
EXCHG
(
m_
size
,
item
->
m_s
ize
);
EXCHG
(
m_
width
,
item
->
m_w
idth
);
}
...
...
@@ -85,7 +111,7 @@ bool SCH_BUS_ENTRY::Save( FILE* aFile ) const
success
=
false
;
}
if
(
fprintf
(
aFile
,
"
\t
%-4d %-4d %-4d %-4d
\n
"
,
m_
Pos
.
x
,
m_P
os
.
y
,
m_End
().
x
,
m_End
().
y
)
==
EOF
)
m_
pos
.
x
,
m_p
os
.
y
,
m_End
().
x
,
m_End
().
y
)
==
EOF
)
{
success
=
false
;
}
...
...
@@ -116,8 +142,8 @@ bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
if
(
Name1
[
0
]
==
'B'
)
m_Layer
=
LAYER_BUS
;
if
(
!
aLine
.
ReadLine
()
||
sscanf
(
(
char
*
)
aLine
,
"%d %d %d %d "
,
&
m_
Pos
.
x
,
&
m_P
os
.
y
,
&
m_
Size
.
x
,
&
m_S
ize
.
y
)
!=
4
)
if
(
!
aLine
.
ReadLine
()
||
sscanf
(
(
char
*
)
aLine
,
"%d %d %d %d "
,
&
m_
pos
.
x
,
&
m_p
os
.
y
,
&
m_
size
.
x
,
&
m_s
ize
.
y
)
!=
4
)
{
aErrorMsg
.
Printf
(
wxT
(
"Eeschema file bus entry load error at line %d"
),
aLine
.
LineNumber
()
);
...
...
@@ -125,8 +151,8 @@ bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg )
return
false
;
}
m_
Size
.
x
-=
m_P
os
.
x
;
m_
Size
.
y
-=
m_P
os
.
y
;
m_
size
.
x
-=
m_p
os
.
x
;
m_
size
.
y
-=
m_p
os
.
y
;
return
true
;
}
...
...
@@ -136,11 +162,11 @@ EDA_RECT SCH_BUS_ENTRY::GetBoundingBox() const
{
EDA_RECT
box
;
box
.
SetOrigin
(
m_
P
os
);
box
.
SetOrigin
(
m_
p
os
);
box
.
SetEnd
(
m_End
()
);
box
.
Normalize
();
int
width
=
(
m_
Width
==
0
)
?
g_DrawDefaultLineThickness
:
m_W
idth
;
int
width
=
(
m_
width
==
0
)
?
g_DrawDefaultLineThickness
:
m_w
idth
;
box
.
Inflate
(
width
/
2
);
return
box
;
...
...
@@ -149,9 +175,9 @@ EDA_RECT SCH_BUS_ENTRY::GetBoundingBox() const
int
SCH_BUS_ENTRY
::
GetPenSize
()
const
{
int
pensize
=
(
m_
Width
==
0
)
?
g_DrawDefaultLineThickness
:
m_W
idth
;
int
pensize
=
(
m_
width
==
0
)
?
g_DrawDefaultLineThickness
:
m_w
idth
;
if
(
m_Layer
==
LAYER_BUS
&&
m_
W
idth
==
0
)
if
(
m_Layer
==
LAYER_BUS
&&
m_
w
idth
==
0
)
{
pensize
=
wxRound
(
g_DrawDefaultLineThickness
*
BUS_WIDTH_EXPAND
);
pensize
=
MAX
(
pensize
,
3
);
...
...
@@ -173,39 +199,39 @@ void SCH_BUS_ENTRY::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOff
GRSetDrawMode
(
aDC
,
aDrawMode
);
GRLine
(
&
aPanel
->
m_ClipBox
,
aDC
,
m_
Pos
.
x
+
aOffset
.
x
,
m_P
os
.
y
+
aOffset
.
y
,
GRLine
(
&
aPanel
->
m_ClipBox
,
aDC
,
m_
pos
.
x
+
aOffset
.
x
,
m_p
os
.
y
+
aOffset
.
y
,
m_End
().
x
+
aOffset
.
x
,
m_End
().
y
+
aOffset
.
y
,
GetPenSize
(),
color
);
}
void
SCH_BUS_ENTRY
::
Mirror_X
(
int
aXaxis_position
)
{
m_
P
os
.
y
-=
aXaxis_position
;
NEGATE
(
m_
P
os
.
y
);
m_
P
os
.
y
+=
aXaxis_position
;
NEGATE
(
m_
S
ize
.
y
);
m_
p
os
.
y
-=
aXaxis_position
;
NEGATE
(
m_
p
os
.
y
);
m_
p
os
.
y
+=
aXaxis_position
;
NEGATE
(
m_
s
ize
.
y
);
}
void
SCH_BUS_ENTRY
::
Mirror_Y
(
int
aYaxis_position
)
{
m_
P
os
.
x
-=
aYaxis_position
;
NEGATE
(
m_
P
os
.
x
);
m_
P
os
.
x
+=
aYaxis_position
;
NEGATE
(
m_
S
ize
.
x
);
m_
p
os
.
x
-=
aYaxis_position
;
NEGATE
(
m_
p
os
.
x
);
m_
p
os
.
x
+=
aYaxis_position
;
NEGATE
(
m_
s
ize
.
x
);
}
void
SCH_BUS_ENTRY
::
Rotate
(
wxPoint
rotationPoint
)
{
RotatePoint
(
&
m_
P
os
,
rotationPoint
,
900
);
RotatePoint
(
&
m_
Size
.
x
,
&
m_S
ize
.
y
,
900
);
RotatePoint
(
&
m_
p
os
,
rotationPoint
,
900
);
RotatePoint
(
&
m_
size
.
x
,
&
m_s
ize
.
y
,
900
);
}
void
SCH_BUS_ENTRY
::
GetEndPoints
(
std
::
vector
<
DANGLING_END_ITEM
>&
aItemList
)
{
DANGLING_END_ITEM
item
(
ENTRY_END
,
this
,
m_
P
os
);
DANGLING_END_ITEM
item
(
ENTRY_END
,
this
,
m_
p
os
);
aItemList
.
push_back
(
item
);
DANGLING_END_ITEM
item1
(
ENTRY_END
,
this
,
m_End
()
);
...
...
@@ -219,7 +245,7 @@ bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect )
// If either end of the bus entry is inside the selection rectangle, the entire
// bus entry is selected. Bus entries have a fixed length and angle.
if
(
aRect
.
Contains
(
m_
P
os
)
||
aRect
.
Contains
(
m_End
()
)
)
if
(
aRect
.
Contains
(
m_
p
os
)
||
aRect
.
Contains
(
m_End
()
)
)
m_Flags
|=
SELECTED
;
else
m_Flags
&=
~
SELECTED
;
...
...
@@ -230,7 +256,7 @@ bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect )
void
SCH_BUS_ENTRY
::
GetConnectionPoints
(
vector
<
wxPoint
>&
aPoints
)
const
{
aPoints
.
push_back
(
m_
P
os
);
aPoints
.
push_back
(
m_
p
os
);
aPoints
.
push_back
(
m_End
()
);
}
...
...
@@ -246,7 +272,7 @@ wxString SCH_BUS_ENTRY::GetSelectMenuText() const
bool
SCH_BUS_ENTRY
::
doHitTest
(
const
wxPoint
&
aPoint
,
int
aAccuracy
)
const
{
return
TestSegmentHit
(
aPoint
,
m_
P
os
,
m_End
(),
aAccuracy
);
return
TestSegmentHit
(
aPoint
,
m_
p
os
,
m_End
(),
aAccuracy
);
}
...
...
@@ -267,6 +293,6 @@ void SCH_BUS_ENTRY::doPlot( PLOTTER* aPlotter )
{
aPlotter
->
set_current_line_width
(
GetPenSize
()
);
aPlotter
->
set_color
(
ReturnLayerColor
(
GetLayer
()
)
);
aPlotter
->
move_to
(
m_
P
os
);
aPlotter
->
move_to
(
m_
p
os
);
aPlotter
->
finish_to
(
m_End
()
);
}
eeschema/sch_bus_entry.h
View file @
c7fe98db
...
...
@@ -46,11 +46,9 @@
*/
class
SCH_BUS_ENTRY
:
public
SCH_ITEM
{
wxPoint
m_Pos
;
public
:
int
m_Width
;
wxSize
m_Size
;
wxPoint
m_pos
;
int
m_width
;
wxSize
m_size
;
public
:
SCH_BUS_ENTRY
(
const
wxPoint
&
pos
=
wxPoint
(
0
,
0
),
int
shape
=
'\\'
,
int
id
=
WIRE_TO_BUS
);
...
...
@@ -66,6 +64,14 @@ public:
wxPoint
m_End
()
const
;
int
GetWidth
()
const
{
return
m_width
;
}
void
SetWidth
(
int
aWidth
)
{
m_width
=
aWidth
;
}
wxSize
GetSize
()
const
{
return
m_size
;
}
void
SetSize
(
const
wxSize
&
aSize
)
{
m_size
=
aSize
;
}
virtual
void
SwapData
(
SCH_ITEM
*
aItem
);
virtual
void
Draw
(
EDA_DRAW_PANEL
*
aPanel
,
wxDC
*
aDC
,
const
wxPoint
&
aOffset
,
...
...
@@ -113,7 +119,7 @@ public:
*/
virtual
void
Move
(
const
wxPoint
&
aMoveVector
)
{
m_
P
os
+=
aMoveVector
;
m_
p
os
+=
aMoveVector
;
}
/**
...
...
@@ -131,6 +137,9 @@ public:
virtual
bool
IsSelectStateChanged
(
const
wxRect
&
aRect
);
/**
* @copydoc SCH_ITEM::IsConnectable()
*/
virtual
bool
IsConnectable
()
const
{
return
true
;
}
virtual
void
GetConnectionPoints
(
vector
<
wxPoint
>&
aPoints
)
const
;
...
...
@@ -144,8 +153,8 @@ private:
virtual
bool
doHitTest
(
const
EDA_RECT
&
aRect
,
bool
aContained
,
int
aAccuracy
)
const
;
virtual
EDA_ITEM
*
doClone
()
const
;
virtual
void
doPlot
(
PLOTTER
*
aPlotter
);
virtual
wxPoint
doGetPosition
()
const
{
return
m_
P
os
;
}
virtual
void
doSetPosition
(
const
wxPoint
&
aPosition
)
{
m_
P
os
=
aPosition
;
}
virtual
wxPoint
doGetPosition
()
const
{
return
m_
p
os
;
}
virtual
void
doSetPosition
(
const
wxPoint
&
aPosition
)
{
m_
p
os
=
aPosition
;
}
};
...
...
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