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
6d14766e
Commit
6d14766e
authored
Jul 23, 2009
by
charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uploaded forgotten files
parent
9d6daf56
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
333 additions
and
0 deletions
+333
-0
class_undoredo_container.cpp
common/class_undoredo_container.cpp
+203
-0
class_undoredo_container.h
include/class_undoredo_container.h
+130
-0
No files found.
common/class_undoredo_container.cpp
0 → 100644
View file @
6d14766e
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2009 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
*/
#include "fctsys.h"
#include "common.h"
#include "base_struct.h"
//#include "sch_item_struct.h"
#include "base_struct.h"
#include "class_undoredo_container.h"
PICKED_ITEMS_LIST
::
PICKED_ITEMS_LIST
()
{
m_UndoRedoType
=
0
;
};
PICKED_ITEMS_LIST
::~
PICKED_ITEMS_LIST
()
{
}
void
PICKED_ITEMS_LIST
::
PushItem
(
ITEM_PICKER
&
aItem
)
{
m_ItemsList
.
push_back
(
aItem
);
}
ITEM_PICKER
PICKED_ITEMS_LIST
::
PICKED_ITEMS_LIST
::
PopItem
()
{
ITEM_PICKER
item
;
if
(
m_ItemsList
.
size
()
!=
0
)
{
item
=
m_ItemsList
.
back
();
m_ItemsList
.
pop_back
();
}
return
item
;
}
void
PICKED_ITEMS_LIST
::
PICKED_ITEMS_LIST
::
ClearItemsList
()
/* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
*/
{
m_ItemsList
.
clear
();
}
ITEM_PICKER
PICKED_ITEMS_LIST
::
GetItemWrapper
(
unsigned
int
aIdx
)
{
ITEM_PICKER
picker
;
if
(
aIdx
<
m_ItemsList
.
size
()
)
picker
=
m_ItemsList
[
aIdx
];
return
picker
;
}
EDA_BaseStruct
*
PICKED_ITEMS_LIST
::
GetItemData
(
unsigned
int
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
return
m_ItemsList
[
aIdx
].
m_Item
;
else
return
NULL
;
}
EDA_BaseStruct
*
PICKED_ITEMS_LIST
::
GetImage
(
unsigned
int
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
return
m_ItemsList
[
aIdx
].
m_Link
;
else
return
NULL
;
}
int
PICKED_ITEMS_LIST
::
GetItemStatus
(
unsigned
int
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
return
m_ItemsList
[
aIdx
].
m_UndoRedoStatus
;
else
return
0
;
}
bool
PICKED_ITEMS_LIST
::
SetItem
(
EDA_BaseStruct
*
aItem
,
unsigned
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
{
m_ItemsList
[
aIdx
].
m_Item
=
aItem
;
return
true
;
}
else
return
false
;
}
bool
PICKED_ITEMS_LIST
::
SetLink
(
EDA_BaseStruct
*
aItem
,
unsigned
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
{
m_ItemsList
[
aIdx
].
m_Link
=
aItem
;
return
true
;
}
else
return
false
;
}
bool
PICKED_ITEMS_LIST
::
SetItem
(
EDA_BaseStruct
*
aItem
,
int
aStatus
,
unsigned
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
{
m_ItemsList
[
aIdx
].
m_Item
=
aItem
;
m_ItemsList
[
aIdx
].
m_UndoRedoStatus
=
aStatus
;
return
true
;
}
else
return
false
;
}
bool
PICKED_ITEMS_LIST
::
SetItemStatus
(
int
aStatus
,
unsigned
aIdx
)
{
if
(
aIdx
<
m_ItemsList
.
size
()
)
{
m_ItemsList
[
aIdx
].
m_UndoRedoStatus
=
aStatus
;
return
true
;
}
else
return
false
;
}
bool
PICKED_ITEMS_LIST
::
RemoveItem
(
unsigned
aIdx
)
{
if
(
aIdx
>=
m_ItemsList
.
size
()
)
return
false
;
m_ItemsList
.
erase
(
m_ItemsList
.
begin
()
+
aIdx
);
return
true
;
}
/**********************************************/
/********** UNDO_REDO_CONTAINER ***************/
/**********************************************/
UNDO_REDO_CONTAINER
::
UNDO_REDO_CONTAINER
()
{
}
UNDO_REDO_CONTAINER
::~
UNDO_REDO_CONTAINER
()
{
ClearCommandList
();
}
void
UNDO_REDO_CONTAINER
::
ClearCommandList
()
{
for
(
unsigned
ii
=
0
;
ii
<
m_CommandsList
.
size
();
ii
++
)
delete
m_CommandsList
[
ii
];
m_CommandsList
.
clear
();
}
void
UNDO_REDO_CONTAINER
::
PushCommand
(
PICKED_ITEMS_LIST
*
aItem
)
{
m_CommandsList
.
push_back
(
aItem
);
}
PICKED_ITEMS_LIST
*
UNDO_REDO_CONTAINER
::
PopCommand
()
{
if
(
m_CommandsList
.
size
()
!=
0
)
{
PICKED_ITEMS_LIST
*
item
=
m_CommandsList
.
back
();
m_CommandsList
.
pop_back
();
return
item
;
}
return
NULL
;
}
include/class_undoredo_container.h
0 → 100644
View file @
6d14766e
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2009 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
*/
#ifndef _CLASS_UNDOREDO_CONTAINER_H
#define _CLASS_UNDOREDO_CONTAINER_H
#include <vector>
/**
* @info Undo Redo considerations:
* Basically we have 3 cases
* New item
* Deleted item
* Modified item
* there is also a specfific case in eeschema, when wires are modified
* If an item is modified, a copy of the "old" item parameters value is held.
* When an item is deleted or added (new item) the pointer points the item, and there is
* no other copy.
* However, because there are some commands that concern a lot of items
* and modify them, but modifications are easy tu undo/redo,
* so a copy of old items is not necessary. They are block command
* Move block
* Rotate block
* Mirror or Flip block
* and they are undo/redo by the same command
*/
class
ITEM_PICKER
{
public
:
int
m_UndoRedoStatus
;
// type of operation to undo/redo for this item
EDA_BaseStruct
*
m_Item
;
/* Pointer on the schematic or board item that is concerned,
* or in undo redo commands, the copy of an edited item.
*/
EDA_BaseStruct
*
m_Link
;
/* Pointer on an other item. Used in undo redo command
* used when a duplicate exists i.e. when an item is modified,
* and the copy of initial item exists (the duplicate)
* m_Item points the duplicate (i.e the old copy of an active item)
* and m_Link points the active item in schematic
*/
public
:
ITEM_PICKER
(
EDA_BaseStruct
*
aItem
=
NULL
,
int
aUndoRedoStatus
=
0
)
{
m_UndoRedoStatus
=
aUndoRedoStatus
;
m_Item
=
aItem
;
m_Link
=
NULL
;
}
};
/* Class PICKED_ITEMS_LIST
* is a holder to handle information on schematic or board items.
* The information held is a pointer on each item, and the command made.
*/
class
PICKED_ITEMS_LIST
{
public
:
int
m_UndoRedoType
;
// type of operation to undo/redo
// UNSPECIFIED (0), IS_NEW, IS_DELETED, IS_CHANGED
wxPoint
m_TransformPoint
;
// used to undo redo command by the same command:
// we usually need to know the rotate point or the move vector
private
:
std
::
vector
<
ITEM_PICKER
>
m_ItemsList
;
public
:
PICKED_ITEMS_LIST
();
~
PICKED_ITEMS_LIST
();
void
PushItem
(
ITEM_PICKER
&
aItem
);
ITEM_PICKER
PopItem
();
void
ClearItemsList
();
unsigned
GetCount
()
{
return
m_ItemsList
.
size
();
}
ITEM_PICKER
GetItemWrapper
(
unsigned
int
aIdx
);
EDA_BaseStruct
*
GetItemData
(
unsigned
int
aIdx
);
EDA_BaseStruct
*
GetImage
(
unsigned
int
aIdx
);
int
GetItemStatus
(
unsigned
int
aIdx
);
bool
SetItem
(
EDA_BaseStruct
*
aItem
,
unsigned
aIdx
);
bool
SetItem
(
EDA_BaseStruct
*
aItem
,
int
aStatus
,
unsigned
aIdx
);
bool
SetLink
(
EDA_BaseStruct
*
aItem
,
unsigned
aIdx
);
bool
SetItemStatus
(
int
aStatus
,
unsigned
aIdx
);
bool
RemoveItem
(
unsigned
aIdx
);
};
/**
* Class UNDO_REDO_CONTAINER
* is a holder to handle alist of undo (or redo) command.
* this class handles a list of ITEM_PICKER (each manage one schematic or board item).
*/
class
UNDO_REDO_CONTAINER
{
public
:
std
::
vector
<
PICKED_ITEMS_LIST
*>
m_CommandsList
;
// the list of possible undo/redo commands
public
:
UNDO_REDO_CONTAINER
();
~
UNDO_REDO_CONTAINER
();
void
PushCommand
(
PICKED_ITEMS_LIST
*
aCommand
);
PICKED_ITEMS_LIST
*
PopCommand
();
void
ClearCommandList
();
};
#endif // _CLASS_UNDOREDO_CONTAINER_H
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