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
99408024
Commit
99408024
authored
Jan 31, 2009
by
charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleaning. Some bugs fixed. Added contributors to list in About Kicad.
parent
5813a12e
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
227 additions
and
184 deletions
+227
-184
CHANGELOG.txt
CHANGELOG.txt
+4
-1
about_kicad.cpp
common/about_kicad.cpp
+3
-1
base_struct.cpp
common/base_struct.cpp
+4
-5
class_drawsheet.cpp
eeschema/class_drawsheet.cpp
+12
-0
class_drawsheet.h
eeschema/class_drawsheet.h
+7
-0
class_libentry.cpp
eeschema/class_libentry.cpp
+2
-2
class_schematic_items.cpp
eeschema/class_schematic_items.cpp
+62
-2
class_schematic_items.h
eeschema/class_schematic_items.h
+12
-0
class_text-label.cpp
eeschema/class_text-label.cpp
+41
-0
class_text-label.h
eeschema/class_text-label.h
+19
-0
classes_body_items.cpp
eeschema/classes_body_items.cpp
+8
-7
component_class.cpp
eeschema/component_class.cpp
+1
-1
eeredraw.cpp
eeschema/eeredraw.cpp
+1
-30
locate.cpp
eeschema/locate.cpp
+45
-130
onleftclick.cpp
eeschema/onleftclick.cpp
+6
-5
No files found.
CHANGELOG.txt
View file @
99408024
...
...
@@ -9,7 +9,10 @@ email address.
================================================================================
++All:
Print functions and display zoom level modified to use the new zoom implementation
Comments adde in some functions.
Comments added in some functions.
Code cleaning
some bugs fixed.
Added contributors to list in about Kicad.
2009-Jan-29 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
...
...
common/about_kicad.cpp
View file @
99408024
...
...
@@ -110,9 +110,11 @@ InitKiCadAbout( wxAboutDialogInfo& info )
/* Add developers */
info
.
AddDeveloper
(
wxT
(
"Jean-Pierre Charras <jean-pierre.charras@inpg.fr>"
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Jerry Jacobs <jerkejacobs@gmail.com>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Dick Hollenbeck <dick@softplc.com>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Jerry Jacobs <jerkejacobs@gmail.com>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Jonas Diemer <diemer@gmx.de>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"KBool Library <http://boolean.klaasholwerda.nl/bool.html>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Rok Markovic <rok@kanardia.eu>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Vesa Solonen <vesa.solonen@hut.fi>"
)
)
);
info
.
AddDeveloper
(
SetMsg
(
wxT
(
"Wayne Stambaugh <stambaughw@verizon.net>"
)
)
);
...
...
common/base_struct.cpp
View file @
99408024
...
...
@@ -209,18 +209,17 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )
*/
{
int
dx
,
dy
;
int
spot_cX
,
spot_cY
;
wxPoint
location
;
dx
=
(
int
)
((
Pitch
()
*
GetLength
()
)
/
2
);
dy
=
m_Size
.
y
/
2
;
/* Is the ref point inside the text area ? */
spot_cX
=
posref
.
x
-
m_Pos
.
x
;
spot_cY
=
posref
.
y
-
m_Pos
.
y
;
location
=
posref
-
m_Pos
;
RotatePoint
(
&
spot_cX
,
&
spot_cY
,
-
m_Orient
);
RotatePoint
(
&
location
,
-
m_Orient
);
if
(
(
abs
(
spot_cX
)
<=
abs
(
dx
)
)
&&
(
abs
(
spot_cY
)
<=
abs
(
dy
)
)
)
if
(
(
abs
(
location
.
x
)
<=
abs
(
dx
)
)
&&
(
abs
(
location
.
y
)
<=
abs
(
dy
)
)
)
return
true
;
return
false
;
...
...
eeschema/class_drawsheet.cpp
View file @
99408024
...
...
@@ -374,6 +374,18 @@ EDA_Rect DrawSheetStruct::GetBoundingBox()
return
box
;
}
/************************************************/
bool
DrawSheetStruct
::
HitTest
(
const
wxPoint
&
aPosRef
)
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect
rect
=
GetBoundingBox
();
return
rect
.
Inside
(
aPosRef
);
}
/************************************/
int
DrawSheetStruct
::
ComponentCount
()
...
...
eeschema/class_drawsheet.h
View file @
99408024
...
...
@@ -129,10 +129,17 @@ public:
void
Draw
(
WinEDA_DrawPanel
*
aPanel
,
wxDC
*
aDC
,
const
wxPoint
&
aOffset
,
int
aDrawMode
,
int
aColor
=
-
1
);
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
HitTest
(
const
wxPoint
&
aPosRef
);
/** Function GetBoundingBox
* @return an EDA_Rect giving the bouding box of the sheet
*/
EDA_Rect
GetBoundingBox
();
void
SwapData
(
DrawSheetStruct
*
copyitem
);
/** Function ComponentCount
...
...
eeschema/class_libentry.cpp
View file @
99408024
...
...
@@ -249,8 +249,8 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
}
// Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */
NEGATE
(
ymax
);
NEGATE
(
ymin
);
//
Y is not is screen axis sense
// Ensure H > 0
(wxRect assume it)
NEGATE
(
ymax
);
NEGATE
(
ymin
);
//
y coordinates are screen oriented
// Ensure H > 0
if
(
ymax
<
ymin
)
EXCHG
(
ymax
,
ymin
);
BoundaryBox
.
SetX
(
xmin
);
BoundaryBox
.
SetWidth
(
xmax
-
xmin
);
...
...
eeschema/class_schematic_items.cpp
View file @
99408024
...
...
@@ -40,9 +40,9 @@ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id )
}
/*************************************/
/*************************************
***
/
wxPoint
DrawBusEntryStruct
::
m_End
()
const
/*************************************/
/*************************************
***
/
// retourne la coord de fin du raccord
{
...
...
@@ -98,6 +98,21 @@ bool DrawBusEntryStruct::Save( FILE* aFile ) const
}
/*********************************************/
EDA_Rect
DrawBusEntryStruct
::
GetBoundingBox
()
/*********************************************/
{
int
dx
=
m_Pos
.
x
-
m_End
().
x
;
int
dy
=
m_Pos
.
y
-
m_End
().
y
;
EDA_Rect
box
(
wxPoint
(
m_Pos
.
x
,
m_Pos
.
y
),
wxSize
(
dx
,
dy
)
);
box
.
Normalize
();
int
width
=
MAX
(
m_Width
,
g_DrawMinimunLineWidth
);
box
.
Inflate
(
width
/
2
,
width
/
2
);
return
box
;
}
/****************************/
/* class DrawJunctionStruct */
/***************************/
...
...
@@ -143,6 +158,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const
EDA_Rect
DrawJunctionStruct
::
GetBoundingBox
()
// return a bounding box
{
int
width
=
DRAWJUNCTION_SIZE
*
2
;
int
xmin
=
m_Pos
.
x
-
DRAWJUNCTION_SIZE
;
...
...
@@ -153,6 +169,21 @@ EDA_Rect DrawJunctionStruct::GetBoundingBox()
return
ret
;
};
/*********************************************************/
bool
DrawJunctionStruct
::
HitTest
(
const
wxPoint
&
aPosRef
)
/*********************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
wxPoint
dist
=
aPosRef
-
m_Pos
;
if
(
sqrt
(
((
double
)
dist
.
x
*
dist
.
x
)
+
((
double
)
dist
.
y
*
dist
.
y
)
)
<
DRAWJUNCTION_SIZE
)
return
true
;
return
false
;
}
#if defined(DEBUG)
void
DrawJunctionStruct
::
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
...
...
@@ -188,6 +219,35 @@ DrawNoConnectStruct* DrawNoConnectStruct::GenCopy()
return
newitem
;
}
/*********************************************/
EDA_Rect
DrawNoConnectStruct
::
GetBoundingBox
()
/*********************************************/
{
const
int
DELTA
=
DRAWNOCONNECT_SIZE
/
2
;
EDA_Rect
box
(
wxPoint
(
m_Pos
.
x
-
DELTA
,
m_Pos
.
y
-
DELTA
),
wxSize
(
2
*
DELTA
,
2
*
DELTA
)
);
box
.
Normalize
();
return
box
;
}
/*********************************************************/
bool
DrawNoConnectStruct
::
HitTest
(
const
wxPoint
&
aPosRef
)
/*********************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
int
width
=
g_DrawMinimunLineWidth
;
int
delta
=
(
DRAWNOCONNECT_SIZE
+
width
)
/
2
;
wxPoint
dist
=
aPosRef
-
m_Pos
;
if
(
(
ABS
(
dist
.
x
)
<=
delta
)
&&
(
ABS
(
dist
.
y
)
<=
delta
)
)
return
true
;
return
false
;
}
/**
* Function Save
...
...
eeschema/class_schematic_items.h
View file @
99408024
...
...
@@ -162,6 +162,12 @@ public:
*/
bool
Save
(
FILE
*
aFile
)
const
;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
HitTest
(
const
wxPoint
&
aPosRef
);
EDA_Rect
GetBoundingBox
();
};
...
...
@@ -261,6 +267,12 @@ public:
}
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
HitTest
(
const
wxPoint
&
aPosRef
);
EDA_Rect
GetBoundingBox
();
DrawJunctionStruct
*
GenCopy
();
...
...
eeschema/class_text-label.cpp
View file @
99408024
...
...
@@ -35,6 +35,16 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
m_IsDangling
=
FALSE
;
}
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
SCH_TEXT
::
HitTest
(
const
wxPoint
&
aPosRef
)
{
EDA_Rect
rect
=
GetBoundingBox
();
return
rect
.
Inside
(
aPosRef
);
}
/*********************************************/
SCH_TEXT
*
SCH_TEXT
::
GenCopy
()
...
...
@@ -290,6 +300,19 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
return
success
;
}
/************************************************/
bool
SCH_GLOBALLABEL
::
HitTest
(
const
wxPoint
&
aPosRef
)
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect
rect
=
GetBoundingBox
();
return
rect
.
Inside
(
aPosRef
);
}
/***********************************************************************************/
SCH_HIERLABEL
::
SCH_HIERLABEL
(
const
wxPoint
&
pos
,
const
wxString
&
text
)
:
...
...
@@ -327,6 +350,18 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
return
success
;
}
/************************************************/
bool
SCH_HIERLABEL
::
HitTest
(
const
wxPoint
&
aPosRef
)
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect
rect
=
GetBoundingBox
();
return
rect
.
Inside
(
aPosRef
);
}
/*********************************************************************************************/
void
SCH_LABEL
::
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
...
...
@@ -426,7 +461,9 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
}
}
/****************************************/
EDA_Rect
SCH_HIERLABEL
::
GetBoundingBox
()
/****************************************/
{
int
x
,
y
,
dx
,
dy
,
length
,
height
;
...
...
@@ -639,7 +676,9 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
}
/******************************************/
EDA_Rect
SCH_GLOBALLABEL
::
GetBoundingBox
()
/******************************************/
{
int
x
,
y
,
dx
,
dy
,
length
,
height
;
...
...
@@ -688,7 +727,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
}
/***********************************/
EDA_Rect
SCH_TEXT
::
GetBoundingBox
()
/***********************************/
{
int
x
,
y
,
dx
,
dy
,
length
,
height
;
...
...
eeschema/class_text-label.h
View file @
99408024
...
...
@@ -102,6 +102,13 @@ public:
void
SwapData
(
SCH_TEXT
*
copyitem
);
void
Place
(
WinEDA_SchematicFrame
*
frame
,
wxDC
*
DC
);
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
HitTest
(
const
wxPoint
&
aPosRef
);
EDA_Rect
GetBoundingBox
();
/**
...
...
@@ -175,6 +182,12 @@ public:
*/
bool
Save
(
FILE
*
aFile
)
const
;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
HitTest
(
const
wxPoint
&
aPosRef
);
EDA_Rect
GetBoundingBox
();
};
...
...
@@ -212,6 +225,12 @@ public:
*/
bool
Save
(
FILE
*
aFile
)
const
;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool
HitTest
(
const
wxPoint
&
aPosRef
);
EDA_Rect
GetBoundingBox
();
};
...
...
eeschema/classes_body_items.cpp
View file @
99408024
...
...
@@ -557,10 +557,10 @@ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, const int aTrans
{
wxPoint
ref
,
start
,
end
;
for
(
unsigned
ii
=
0
;
ii
<
m_PolyPoints
.
size
()
-
1
;
ii
++
)
for
(
unsigned
ii
=
1
;
ii
<
GetCornerCount
()
;
ii
++
)
{
start
=
TransformCoordinate
(
aTransMat
,
m_PolyPoints
[
0
]
);
end
=
TransformCoordinate
(
aTransMat
,
m_PolyPoints
[
1
]
);
start
=
TransformCoordinate
(
aTransMat
,
m_PolyPoints
[
ii
-
1
]
);
end
=
TransformCoordinate
(
aTransMat
,
m_PolyPoints
[
ii
]
);
ref
=
aPosRef
-
start
;
end
-=
start
;
...
...
@@ -584,14 +584,15 @@ EDA_Rect LibDrawPolyline::GetBoundaryBox()
ymin
=
ymax
=
m_PolyPoints
[
0
].
y
;
for
(
unsigned
ii
=
1
;
ii
<
GetCornerCount
();
ii
++
)
{
xmin
=
MIN
(
xmin
,
m_PolyPoints
[
0
].
x
);
xmax
=
MAX
(
xmax
,
m_PolyPoints
[
0
].
x
);
ymin
=
MIN
(
ymin
,
m_PolyPoints
[
0
].
y
);
ymax
=
MAX
(
ymax
,
m_PolyPoints
[
0
].
y
);
xmin
=
MIN
(
xmin
,
m_PolyPoints
[
ii
-
1
].
x
);
xmax
=
MAX
(
xmax
,
m_PolyPoints
[
ii
-
1
].
x
);
ymin
=
MIN
(
ymin
,
m_PolyPoints
[
ii
].
y
);
ymax
=
MAX
(
ymax
,
m_PolyPoints
[
ii
].
y
);
}
BoundaryBox
.
SetX
(
xmin
);
BoundaryBox
.
SetWidth
(
xmax
-
xmin
);
BoundaryBox
.
SetY
(
ymin
);
BoundaryBox
.
SetHeight
(
ymax
-
ymin
);
BoundaryBox
.
Inflate
(
m_Width
,
m_Width
);
return
BoundaryBox
;
}
eeschema/component_class.cpp
View file @
99408024
...
...
@@ -353,7 +353,7 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
int
y2
=
m_Transform
[
1
][
0
]
*
xm
+
m_Transform
[
1
][
1
]
*
ym
;
// H and W must be > 0
for wxRect
:
// H and W must be > 0:
if
(
x2
<
x1
)
EXCHG
(
x2
,
x1
);
if
(
y2
<
y1
)
...
...
eeschema/eeredraw.cpp
View file @
99408024
...
...
@@ -294,16 +294,6 @@ void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint
}
EDA_Rect
DrawNoConnectStruct
::
GetBoundingBox
()
{
const
int
DELTA
=
(
DRAWNOCONNECT_SIZE
/
2
);
EDA_Rect
box
(
wxPoint
(
m_Pos
.
x
-
DELTA
,
m_Pos
.
y
-
DELTA
),
wxSize
(
2
*
DELTA
,
2
*
DELTA
)
);
box
.
Normalize
();
return
box
;
}
/**************************************************************/
void
DrawBusEntryStruct
::
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
DrawMode
,
int
Color
)
...
...
@@ -329,16 +319,6 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
}
EDA_Rect
DrawBusEntryStruct
::
GetBoundingBox
()
{
int
dx
=
m_Pos
.
x
-
m_End
().
x
;
int
dy
=
m_Pos
.
y
-
m_End
().
y
;
EDA_Rect
box
(
wxPoint
(
m_Pos
.
x
,
m_Pos
.
y
),
wxSize
(
dx
,
dy
)
);
box
.
Normalize
();
return
box
;
}
/*****************************************************************************
* Routine to redraw polyline struct. *
...
...
@@ -411,7 +391,6 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
* Utilisee dans les deplacements de blocs
*/
{
int
Width
;
int
DrawMode
=
g_XorMode
;
int
width
=
g_DrawMinimunLineWidth
;
...
...
@@ -477,15 +456,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
{
DrawJunctionStruct
*
Struct
;
Struct
=
(
DrawJunctionStruct
*
)
DrawStruct
;
Width
=
DRAWJUNCTION_SIZE
;
GRFilledRect
(
&
panel
->
m_ClipBox
,
DC
,
Struct
->
m_Pos
.
x
-
Width
+
dx
,
Struct
->
m_Pos
.
y
-
Width
+
dy
,
Struct
->
m_Pos
.
x
+
Width
+
dx
,
Struct
->
m_Pos
.
y
+
Width
+
dy
,
g_GhostColor
,
g_GhostColor
);
Struct
->
Draw
(
panel
,
DC
,
wxPoint
(
0
,
0
),
DrawMode
,
g_GhostColor
);
break
;
}
...
...
eeschema/locate.cpp
View file @
99408024
...
...
@@ -22,11 +22,9 @@ static SCH_ITEM* LastSnappedStruct = NULL;
static
int
PickedBoxMinX
,
PickedBoxMinY
,
PickedBoxMaxX
,
PickedBoxMaxY
;
static
bool
IsBox1InBox2
(
int
StartX1
,
int
StartY1
,
int
EndX1
,
int
EndY1
,
int
StartX2
,
int
StartY2
,
int
EndX2
,
int
EndY2
);
static
bool
IsPointInBox
(
wxPoint
aPosRef
,
int
BoxX1
,
int
BoxY1
,
int
BoxX2
,
int
BoxY2
);
static
bool
IsPointOnSegment
(
wxPoint
aPosRef
,
wxPoint
aSegmStart
,
wxPoint
aSegmEnd
,
int
aDist
=
0
);
static
bool
SnapPoint2
(
const
wxPoint
&
aPosRef
,
int
SearchMask
,
SCH_ITEM
*
DrawList
,
DrawPickedStruct
*
DontSnapList
,
int
zoom_value
);
SCH_ITEM
*
DrawList
,
DrawPickedStruct
*
DontSnapList
,
double
aScaleFactor
);
/*********************************************************************/
...
...
@@ -37,7 +35,7 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen )
* If more than 1 component is found, a pointer to the smaller component is returned
*/
{
SCH_COMPONENT
*
DrawLibItem
=
NULL
,
*
LastDrawLibItem
=
NULL
;
SCH_COMPONENT
*
component
=
NULL
,
*
lastcomponent
=
NULL
;
SCH_ITEM
*
DrawList
;
EDA_Rect
BoundaryBox
;
float
sizeref
=
0
,
sizecurr
;
...
...
@@ -50,34 +48,39 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen )
DrawList
,
NULL
,
Screen
->
GetZoom
()
)
)
==
FALSE
)
{
if
(
(
SnapPoint2
(
Screen
->
m_Curseur
,
LIBITEM
,
DrawList
,
NULL
,
Screen
->
Get
Zoom
()
)
)
==
FALSE
)
DrawList
,
NULL
,
Screen
->
Get
ScalingFactor
()
)
)
==
FALSE
)
break
;
}
DrawLibItem
=
(
SCH_COMPONENT
*
)
LastSnappedStruct
;
DrawList
=
DrawLibItem
->
Next
();
if
(
LastDrawLibItem
==
NULL
)
// First time a component is located
component
=
(
SCH_COMPONENT
*
)
LastSnappedStruct
;
DrawList
=
component
->
Next
();
if
(
lastcomponent
==
NULL
)
// First time a component is located
{
LastDrawLibItem
=
DrawLibItem
;
BoundaryBox
=
LastDrawLibItem
->
GetBoundaryBox
();
lastcomponent
=
component
;
BoundaryBox
=
lastcomponent
->
GetBoundaryBox
();
sizeref
=
ABS
(
(
float
)
BoundaryBox
.
GetWidth
()
*
BoundaryBox
.
GetHeight
()
);
}
else
{
BoundaryBox
=
DrawLibItem
->
GetBoundaryBox
();
BoundaryBox
=
component
->
GetBoundaryBox
();
sizecurr
=
ABS
(
(
float
)
BoundaryBox
.
GetWidth
()
*
BoundaryBox
.
GetHeight
()
);
if
(
sizeref
>
sizecurr
)
// a smallest component is found
{
sizeref
=
sizecurr
;
LastDrawLibItem
=
DrawLibItem
;
lastcomponent
=
component
;
}
}
}
return
LastDrawLibItem
;
return
lastcomponent
;
}
/* SearchMask = (bitwise OR):
/********************************************************************************/
SCH_ITEM
*
PickStruct
(
const
wxPoint
&
refpos
,
BASE_SCREEN
*
screen
,
int
SearchMask
)
/******************************************************************************/
/* Search an item at pos refpos
* SearchMask = (bitwise OR):
* LIBITEM
* WIREITEM
* BUSITEM
...
...
@@ -100,29 +103,16 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen )
*
*
* Return:
* -Bloc search:
* pointeur sur liste de pointeurs de structures si Plusieurs
* structures selectionnees.
* pointeur sur la structure si 1 seule
*
* Positon serach:
* pointeur sur la structure.
* Si pas de structures selectionnees: retourne NULL
* pointer on item found or NULL
*
*/
/********************************************************************************/
SCH_ITEM
*
PickStruct
(
const
wxPoint
&
refpos
,
BASE_SCREEN
*
screen
,
int
SearchMask
)
/******************************************************************************/
/* Search an item at pos refpos
*/
{
bool
Snapped
;
if
(
screen
==
NULL
||
screen
->
EEDrawList
==
NULL
)
return
NULL
;
if
(
(
Snapped
=
SnapPoint2
(
refpos
,
SearchMask
,
screen
->
EEDrawList
,
NULL
,
screen
->
Get
Zoom
()
)
)
!=
FALSE
)
screen
->
EEDrawList
,
NULL
,
screen
->
Get
ScalingFactor
()
)
)
!=
FALSE
)
{
return
LastSnappedStruct
;
}
...
...
@@ -135,6 +125,11 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask )
/************************************************************************/
/* Search items in block
* Return:
* pointeur sur liste de pointeurs de structures si Plusieurs
* structures selectionnees.
* pointeur sur la structure si 1 seule
*
*/
{
int
x
,
y
,
OrigX
,
OrigY
;
...
...
@@ -195,11 +190,9 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask )
* The routine returns TRUE if point was snapped. *
*****************************************************************************/
bool
SnapPoint2
(
const
wxPoint
&
aPosRef
,
int
SearchMask
,
SCH_ITEM
*
DrawList
,
DrawPickedStruct
*
DontSnapList
,
int
zoom_value
)
SCH_ITEM
*
DrawList
,
DrawPickedStruct
*
DontSnapList
,
double
aScaleFactor
)
{
int
x1
,
y1
,
x2
,
y2
;
DrawPickedStruct
*
DontSnap
;
int
dx
,
dy
;
for
(
;
DrawList
!=
NULL
;
DrawList
=
DrawList
->
Next
()
)
{
...
...
@@ -282,30 +275,19 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
#define STRUCT ( (DrawJunctionStruct*) DrawList )
if
(
!
(
SearchMask
&
JUNCTIONITEM
)
)
break
;
dx
=
DRAWJUNCTION_SIZE
/
2
;
x1
=
STRUCT
->
m_Pos
.
x
-
dx
;
y1
=
STRUCT
->
m_Pos
.
y
-
dx
;
x2
=
STRUCT
->
m_Pos
.
x
+
dx
;
y2
=
STRUCT
->
m_Pos
.
y
+
dx
;
if
(
IsPointInBox
(
aPosRef
,
x1
,
y1
,
x2
,
y2
)
)
if
(
STRUCT
->
HitTest
(
aPosRef
)
)
{
LastSnappedStruct
=
DrawList
;
return
TRUE
;
}
break
;
case
DRAW_NOCONNECT_STRUCT_TYPE
:
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) DrawList )
if
(
!
(
SearchMask
&
NOCONNECTITEM
)
)
break
;
dx
=
(
DRAWNOCONNECT_SIZE
*
zoom_value
)
/
2
;
x1
=
STRUCT
->
m_Pos
.
x
-
dx
;
y1
=
STRUCT
->
m_Pos
.
y
-
dx
;
x2
=
STRUCT
->
m_Pos
.
x
+
dx
;
y2
=
STRUCT
->
m_Pos
.
y
+
dx
;
if
(
IsPointInBox
(
aPosRef
,
x1
,
y1
,
x2
,
y2
)
)
if
(
STRUCT
->
HitTest
(
aPosRef
)
)
{
LastSnappedStruct
=
DrawList
;
return
TRUE
;
...
...
@@ -313,21 +295,20 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break
;
case
DRAW_MARKER_STRUCT_TYPE
:
{
#undef STRUCT
#define STRUCT ( (DrawMarkerStruct*) DrawList )
if
(
!
(
SearchMask
&
MARKERITEM
)
)
break
;
dx
=
(
DRAWMARKER_SIZE
*
zoom_value
)
/
2
;
x1
=
STRUCT
->
m_Pos
.
x
-
dx
;
y1
=
STRUCT
->
m_Pos
.
y
-
dx
;
x2
=
STRUCT
->
m_Pos
.
x
+
dx
;
y2
=
STRUCT
->
m_Pos
.
y
+
dx
;
if
(
IsPointInBox
(
aPosRef
,
x1
,
y1
,
x2
,
y2
)
)
int
size
=
(
int
)((
DRAWMARKER_SIZE
/
aScaleFactor
)
/
2
);
wxPoint
dist
=
aPosRef
-
STRUCT
->
m_Pos
;
if
(
(
abs
(
dist
.
x
)
<=
size
)
&&
(
abs
(
dist
.
y
)
<=
size
)
)
{
LastSnappedStruct
=
DrawList
;
return
TRUE
;
}
break
;
}
case
TYPE_SCH_LABEL
:
case
TYPE_SCH_TEXT
:
...
...
@@ -335,31 +316,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
#define STRUCT ( (SCH_TEXT*) DrawList )
if
(
!
(
SearchMask
&
(
TEXTITEM
|
LABELITEM
)
)
)
break
;
dx
=
STRUCT
->
m_Size
.
x
*
STRUCT
->
GetLength
();
dy
=
STRUCT
->
m_Size
.
y
;
x1
=
x2
=
STRUCT
->
m_Pos
.
x
;
y1
=
y2
=
STRUCT
->
m_Pos
.
y
;
switch
(
STRUCT
->
m_Orient
)
{
case
0
:
/* HORIZONTAL Left justified */
x2
+=
dx
;
y2
-=
dy
;
break
;
case
1
:
/* VERTICAL UP */
x2
-=
dy
;
y2
-=
dx
;
break
;
case
2
:
/* horizontal Right justified */
x2
-=
dx
;
y2
-=
dy
;
break
;
case
3
:
/* vertical DOWN */
x2
-=
dy
;
y2
+=
dx
;
break
;
}
if
(
IsPointInBox
(
aPosRef
,
x1
,
y1
,
x2
,
y2
)
)
if
(
STRUCT
->
HitTest
(
aPosRef
)
)
{
LastSnappedStruct
=
DrawList
;
return
TRUE
;
...
...
@@ -368,36 +325,23 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
case
TYPE_SCH_GLOBALLABEL
:
case
TYPE_SCH_HIERLABEL
:
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) DrawList )
#define STRUCT ( (SCH_
GLOBAL
LABEL*) DrawList )
if
(
!
(
SearchMask
&
LABELITEM
)
)
break
;
dx
=
STRUCT
->
m_Size
.
x
*
(
STRUCT
->
GetLength
()
+
1
);
/* longueur */
dy
=
STRUCT
->
m_Size
.
y
/
2
;
/* Demi hauteur */
x1
=
x2
=
STRUCT
->
m_Pos
.
x
;
y1
=
y2
=
STRUCT
->
m_Pos
.
y
;
switch
(
STRUCT
->
m_Orient
)
if
(
STRUCT
->
HitTest
(
aPosRef
)
)
{
case
0
:
/* HORIZONTAL */
x2
-=
dx
;
y2
+=
dy
;
y1
-=
dy
;
break
;
case
1
:
/* VERTICAL UP */
x1
-=
dy
;
x2
+=
dy
;
y2
+=
dx
;
break
;
case
2
:
/* horizontal inverse */
x2
+=
dx
;
y2
+=
dy
;
y1
-=
dy
;
LastSnappedStruct
=
DrawList
;
return
TRUE
;
}
break
;
case
3
:
/* vertical DOWN */
x1
-=
dy
;
x2
+=
dy
;
y2
-=
dx
;
case
TYPE_SCH_HIERLABEL
:
#undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) DrawList )
if
(
!
(
SearchMask
&
LABELITEM
)
)
break
;
}
if
(
IsPointInBox
(
aPosRef
,
x1
,
y1
,
x2
,
y2
)
)
if
(
STRUCT
->
HitTest
(
aPosRef
)
)
{
LastSnappedStruct
=
DrawList
;
return
TRUE
;
...
...
@@ -447,13 +391,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
#define STRUCT ( (DrawSheetStruct*) DrawList )
if
(
!
(
SearchMask
&
SHEETITEM
)
)
break
;
/* Recalcul des coordonnees de l'encadrement du composant */
x1
=
STRUCT
->
m_Pos
.
x
;
y1
=
STRUCT
->
m_Pos
.
y
;
x2
=
STRUCT
->
m_Pos
.
x
+
STRUCT
->
m_Size
.
x
;
y2
=
STRUCT
->
m_Pos
.
y
+
STRUCT
->
m_Size
.
y
;
if
(
IsPointInBox
(
aPosRef
,
x1
,
y1
,
x2
,
y2
)
)
if
(
STRUCT
->
HitTest
(
aPosRef
)
)
{
LastSnappedStruct
=
DrawList
;
return
TRUE
;
...
...
@@ -724,29 +662,6 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
}
/**********************************************************************/
static
bool
IsPointInBox
(
wxPoint
aPosRef
,
int
BoxX1
,
int
BoxY1
,
int
BoxX2
,
int
BoxY2
)
/**********************************************************************/
/* Routine detectant que le point pX,pY est dans le rectangle (Box)
* Retourne TRUE ou FALSE.
*
*/
{
if
(
BoxX1
>
BoxX2
)
EXCHG
(
BoxX1
,
BoxX2
);
if
(
BoxY1
>
BoxY2
)
EXCHG
(
BoxY1
,
BoxY2
);
if
(
(
aPosRef
.
x
>=
BoxX1
)
&&
(
aPosRef
.
x
<=
BoxX2
)
&&
(
aPosRef
.
y
>=
BoxY1
)
&&
(
aPosRef
.
y
<=
BoxY2
)
)
return
TRUE
;
else
return
FALSE
;
}
/********************************************************************************/
static
bool
IsPointOnSegment
(
wxPoint
aPosRef
,
wxPoint
aSegmStart
,
wxPoint
aSegmEnd
,
int
aDist
)
/********************************************************************************/
...
...
eeschema/onleftclick.cpp
View file @
99408024
...
...
@@ -324,11 +324,12 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void
WinEDA_SchematicFrame
::
OnLeftDClick
(
wxDC
*
DC
,
const
wxPoint
&
MousePos
)
/***************************************************************************/
/* Appel� sur un double click:
* pour un �l�ment editable (textes, composant):
* appel de l'editeur correspondant.
* pour une connexion en cours:
* termine la connexion
/** Function OnLeftDClick
* called on a double click event from the drawpanel mouse handler
* if an editable item is found (text, component)
* Call the suitable dialog editor.
* Id a creat command is in progress:
* validate and finish the command
*/
{
EDA_BaseStruct
*
DrawStruct
=
GetScreen
()
->
GetCurItem
();
...
...
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