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
b28d1ea4
Commit
b28d1ea4
authored
Oct 19, 2008
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed the SCH_COMPONENT copy constructor, make GenCopy() inline
parent
84609e62
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
18 deletions
+42
-18
component_class.cpp
eeschema/component_class.cpp
+21
-17
component_class.h
eeschema/component_class.h
+21
-1
No files found.
eeschema/component_class.cpp
View file @
b28d1ea4
...
@@ -60,6 +60,26 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
...
@@ -60,6 +60,26 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
m_PrefixString
=
wxString
(
_
(
"U"
)
);
m_PrefixString
=
wxString
(
_
(
"U"
)
);
}
}
SCH_COMPONENT
::
SCH_COMPONENT
(
const
SCH_COMPONENT
&
aTemplate
)
:
SCH_ITEM
(
NULL
,
TYPE_SCH_COMPONENT
)
{
// assignment of all fields, including field vector elements, and linked list pointers
*
this
=
aTemplate
;
// set linked list pointers to null, before this they were copies of aTemplate's
Pback
=
NULL
;
Pnext
=
NULL
;
m_Son
=
NULL
;
// Re-parent the fields, which before this were aTemplate's parent
for
(
int
i
=
0
;
i
<
GetFieldCount
();
++
i
)
{
GetField
(
i
)
->
m_Parent
=
this
;
}
}
/**
/**
* Function AddHierarchicalReference
* Function AddHierarchicalReference
* adds a full hierachical reference (path + local reference)
* adds a full hierachical reference (path + local reference)
...
@@ -401,7 +421,7 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
...
@@ -401,7 +421,7 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
m_Fields
.
swap
(
copyitem
->
m_Fields
);
// std::vector's swap()
m_Fields
.
swap
(
copyitem
->
m_Fields
);
// std::vector's swap()
// Reparent items after copying data
// Reparent items after copying data
// (after swap(), m_Parent member does not point
s
the right parent):
// (after swap(), m_Parent member does not point
to
the right parent):
for
(
int
ii
=
0
;
ii
<
copyitem
->
GetFieldCount
();
++
ii
)
for
(
int
ii
=
0
;
ii
<
copyitem
->
GetFieldCount
();
++
ii
)
{
{
copyitem
->
GetField
(
ii
)
->
m_Parent
=
copyitem
;
copyitem
->
GetField
(
ii
)
->
m_Parent
=
copyitem
;
...
@@ -502,22 +522,6 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
...
@@ -502,22 +522,6 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
}
}
/**************************************************************/
SCH_COMPONENT
*
SCH_COMPONENT
::
GenCopy
()
/**************************************************************/
{
SCH_COMPONENT
*
new_item
=
new
SCH_COMPONENT
(
*
this
);
// Reset chain pointers:
new_item
->
Pback
=
new_item
->
Pnext
=
new_item
->
m_Son
=
NULL
;
// Reparent items after copy:
for
(
int
ii
=
0
;
ii
<
new_item
->
GetFieldCount
();
++
ii
)
{
new_item
->
GetField
(
ii
)
->
m_Parent
=
new_item
;
}
return
new_item
;
}
/*****************************************************************/
/*****************************************************************/
void
SCH_COMPONENT
::
SetRotationMiroir
(
int
type_rotate
)
void
SCH_COMPONENT
::
SetRotationMiroir
(
int
type_rotate
)
/******************************************************************/
/******************************************************************/
...
...
eeschema/component_class.h
View file @
b28d1ea4
...
@@ -98,6 +98,16 @@ private:
...
@@ -98,6 +98,16 @@ private:
public
:
public
:
SCH_COMPONENT
(
const
wxPoint
&
pos
=
wxPoint
(
0
,
0
),
SCH_ITEM
*
aParent
=
NULL
);
SCH_COMPONENT
(
const
wxPoint
&
pos
=
wxPoint
(
0
,
0
),
SCH_ITEM
*
aParent
=
NULL
);
/**
* Copy Constructor
* clones \a aTemplate into this object. All fields are copied as is except
* for the linked list management pointers which are set to NULL, and the
* SCH_CMP_FIELD's m_Parent pointers which are set to the new parent,
* i.e. this new object.
*/
SCH_COMPONENT
(
const
SCH_COMPONENT
&
aTemplate
);
~
SCH_COMPONENT
()
{
}
~
SCH_COMPONENT
()
{
}
virtual
wxString
GetClass
()
const
virtual
wxString
GetClass
()
const
...
@@ -125,7 +135,17 @@ public:
...
@@ -125,7 +135,17 @@ public:
void Load( FILE* aFile ) throw( Error );
void Load( FILE* aFile ) throw( Error );
*/
*/
SCH_COMPONENT
*
GenCopy
();
/**
* Function GenCopy
* returns a copy of this object but with the linked list pointers
* set to NULL.
* @return SCH_COMPONENT* - a copy of me.
*/
SCH_COMPONENT
*
GenCopy
()
{
return
new
SCH_COMPONENT
(
*
this
);
}
void
SetRotationMiroir
(
int
type
);
void
SetRotationMiroir
(
int
type
);
int
GetRotationMiroir
();
int
GetRotationMiroir
();
wxPoint
GetScreenCoord
(
const
wxPoint
&
coord
);
wxPoint
GetScreenCoord
(
const
wxPoint
&
coord
);
...
...
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