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
aa35b980
Commit
aa35b980
authored
Mar 24, 2010
by
charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eeschema: fixed some issues in undo/redo and ESC commands related to hierarchical sheets
parent
be946a75
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
119 additions
and
70 deletions
+119
-70
busentry.cpp
eeschema/busentry.cpp
+1
-2
class_drawsheet.cpp
eeschema/class_drawsheet.cpp
+16
-0
hotkeys.cpp
eeschema/hotkeys.cpp
+7
-5
onrightclick.cpp
eeschema/onrightclick.cpp
+7
-2
operations_on_items_lists.cpp
eeschema/operations_on_items_lists.cpp
+32
-19
protos.h
eeschema/protos.h
+11
-1
schedit.cpp
eeschema/schedit.cpp
+6
-6
schematic_undo_redo.cpp
eeschema/schematic_undo_redo.cpp
+2
-31
sheet.cpp
eeschema/sheet.cpp
+17
-0
sheetlab.cpp
eeschema/sheetlab.cpp
+20
-4
No files found.
eeschema/busentry.cpp
View file @
aa35b980
...
...
@@ -92,8 +92,7 @@ void WinEDA_SchematicFrame::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry,
if
(
BusEntry
==
NULL
)
return
;
if
(
(
BusEntry
->
m_Flags
&
IS_NEW
)
==
0
)
// => not already in edit, save
// shape */
if
(
(
BusEntry
->
m_Flags
&
IS_NEW
)
==
0
)
// not already in edit, save shape
{
delete
g_ItemToUndoCopy
;
g_ItemToUndoCopy
=
BusEntry
->
GenCopy
();
...
...
eeschema/class_drawsheet.cpp
View file @
aa35b980
...
...
@@ -208,6 +208,22 @@ void SCH_SHEET::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
return
;
}
}
else
/* save old text in undo list */
{
if
(
g_ItemToUndoCopy
&&
(
g_ItemToUndoCopy
->
Type
()
==
Type
()
)
)
{
/* restore old values and save new ones */
SwapData
(
(
SCH_SHEET
*
)
g_ItemToUndoCopy
);
/* save in undo list */
frame
->
SaveCopyInUndoList
(
this
,
UR_CHANGED
);
/* restore new values */
SwapData
(
(
SCH_SHEET
*
)
g_ItemToUndoCopy
);
SAFE_DELETE
(
g_ItemToUndoCopy
);
}
}
SCH_ITEM
::
Place
(
frame
,
DC
);
//puts it on the EEDrawList.
if
(
isnew
)
...
...
eeschema/hotkeys.cpp
View file @
aa35b980
...
...
@@ -551,7 +551,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
GetScreen
()
->
SetCurItem
(
(
SCH_ITEM
*
)
DrawStruct
);
// Create the events for moving a component or other schematic item
wxCommandEvent
eventMoveComponent
(
wxEVT_COMMAND_TOOL_CLICKED
,
wxCommandEvent
eventMove
OrDrag
Component
(
wxEVT_COMMAND_TOOL_CLICKED
,
HK_Descr
->
m_IdMenuEvent
);
wxCommandEvent
eventMoveItem
(
wxEVT_COMMAND_TOOL_CLICKED
,
ID_POPUP_SCH_MOVE_ITEM_REQUEST
);
...
...
@@ -564,21 +564,23 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
{
// select the correct event for moving an schematic object
// and add it to the event queue
case
DRAW_SHEET_STRUCT_TYPE
:
case
TYPE_SCH_COMPONENT
:
wxPostEvent
(
this
,
eventMoveComponent
);
wxPostEvent
(
this
,
eventMove
OrDrag
Component
);
break
;
case
TYPE_SCH_TEXT
:
case
TYPE_SCH_LABEL
:
case
TYPE_SCH_GLOBALLABEL
:
case
TYPE_SCH_HIERLABEL
:
case
DRAW_SHEET_STRUCT_TYPE
:
case
DRAW_PART_TEXT_STRUCT_TYPE
:
case
DRAW_BUSENTRY_STRUCT_TYPE
:
if
(
HK_Descr
->
m_Idcommand
!=
HK_DRAG
)
wxPostEvent
(
this
,
eventMoveItem
);
break
;
case
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE
:
if
(
HK_Descr
->
m_Idcommand
!=
HK_DRAG
)
wxPostEvent
(
this
,
eventMovePinsheet
);
break
;
...
...
eeschema/onrightclick.cpp
View file @
aa35b980
...
...
@@ -439,11 +439,11 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
msg
=
AddHotkeyName
(
_
(
"Rotate Hierarchical Label"
),
s_Schematic_Hokeys_Descr
,
HK_ROTATE
);
ADD_MENUITEM
(
PopMenu
,
ID_POPUP_SCH_ROTATE_TEXT
,
_
(
"Rotate Hierarchical Label"
)
,
rotate_glabel_xpm
);
msg
,
rotate_glabel_xpm
);
msg
=
AddHotkeyName
(
_
(
"Edit Hierarchical Label"
),
s_Schematic_Hokeys_Descr
,
HK_EDIT
);
ADD_MENUITEM
(
PopMenu
,
ID_POPUP_SCH_EDIT_TEXT
,
_
(
"Edit Hierarchical Label"
)
,
edit_text_xpm
);
msg
,
edit_text_xpm
);
msg
=
AddHotkeyName
(
_
(
"Delete Hierarchical Label"
),
s_Schematic_Hokeys_Descr
,
HK_DELETE
);
ADD_MENUITEM
(
PopMenu
,
ID_POPUP_SCH_DELETE
,
...
...
@@ -678,6 +678,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
s_Schematic_Hokeys_Descr
,
HK_MOVE_COMPONENT_OR_ITEM
);
ADD_MENUITEM
(
PopMenu
,
ID_POPUP_SCH_MOVE_ITEM_REQUEST
,
msg
,
move_sheet_xpm
);
msg
=
AddHotkeyName
(
_
(
"Drag Sheet"
),
s_Schematic_Hokeys_Descr
,
HK_DRAG
);
ADD_MENUITEM
(
PopMenu
,
ID_POPUP_SCH_DRAG_CMP_REQUEST
,
msg
,
move_sheet_xpm
);
}
if
(
Sheet
->
m_Flags
)
...
...
eeschema/operations_on_items_lists.cpp
View file @
aa35b980
...
...
@@ -181,79 +181,92 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
}
/* Routine to create a new copy of given struct.
/** function DuplicateStruct
* Routine to create a new copy of given struct.
* The new object is not put in draw list (not linked)
* @param aDrawStruct = the SCH_ITEM to duplicate
* @param aClone (default = false)
* if true duplicate also some parameters that must be unique
* (timestamp and sheet name)
* aClone must be false. use true only is undo/redo duplications
*/
SCH_ITEM
*
DuplicateStruct
(
SCH_ITEM
*
DrawStruct
)
SCH_ITEM
*
DuplicateStruct
(
SCH_ITEM
*
aDrawStruct
,
bool
aClone
)
{
SCH_ITEM
*
NewDrawStruct
=
NULL
;
if
(
DrawStruct
==
NULL
)
if
(
a
DrawStruct
==
NULL
)
{
wxMessageBox
(
wxT
(
"DuplicateStruct error: NULL struct"
)
);
return
NULL
;
}
switch
(
DrawStruct
->
Type
()
)
switch
(
a
DrawStruct
->
Type
()
)
{
case
DRAW_POLYLINE_STRUCT_TYPE
:
NewDrawStruct
=
(
(
SCH_POLYLINE
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_POLYLINE
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
DRAW_SEGMENT_STRUCT_TYPE
:
NewDrawStruct
=
(
(
SCH_LINE
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_LINE
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
DRAW_BUSENTRY_STRUCT_TYPE
:
NewDrawStruct
=
(
(
SCH_BUS_ENTRY
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_BUS_ENTRY
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
DRAW_JUNCTION_STRUCT_TYPE
:
NewDrawStruct
=
(
(
SCH_JUNCTION
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_JUNCTION
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
TYPE_SCH_MARKER
:
NewDrawStruct
=
(
(
SCH_MARKER
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_MARKER
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
DRAW_NOCONNECT_STRUCT_TYPE
:
NewDrawStruct
=
(
(
SCH_NO_CONNECT
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_NO_CONNECT
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
TYPE_SCH_TEXT
:
NewDrawStruct
=
(
(
SCH_TEXT
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_TEXT
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
TYPE_SCH_LABEL
:
NewDrawStruct
=
(
(
SCH_LABEL
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_LABEL
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
TYPE_SCH_HIERLABEL
:
NewDrawStruct
=
(
(
SCH_HIERLABEL
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_HIERLABEL
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
TYPE_SCH_GLOBALLABEL
:
NewDrawStruct
=
(
(
SCH_GLOBALLABEL
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_GLOBALLABEL
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
TYPE_SCH_COMPONENT
:
NewDrawStruct
=
(
(
SCH_COMPONENT
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_COMPONENT
*
)
a
DrawStruct
)
->
GenCopy
();
break
;
case
DRAW_SHEET_STRUCT_TYPE
:
NewDrawStruct
=
(
(
SCH_SHEET
*
)
DrawStruct
)
->
GenCopy
();
NewDrawStruct
=
(
(
SCH_SHEET
*
)
aDrawStruct
)
->
GenCopy
();
if
(
aClone
)
{
((
SCH_SHEET
*
)
NewDrawStruct
)
->
m_SheetName
=
((
SCH_SHEET
*
)
aDrawStruct
)
->
m_SheetName
;
}
break
;
default:
{
wxString
msg
;
msg
<<
wxT
(
"DuplicateStruct error: unexpected StructType "
)
<<
DrawStruct
->
Type
()
<<
wxT
(
" "
)
<<
DrawStruct
->
GetClass
();
<<
aDrawStruct
->
Type
()
<<
wxT
(
" "
)
<<
a
DrawStruct
->
GetClass
();
wxMessageBox
(
msg
);
}
break
;
}
NewDrawStruct
->
m_Image
=
DrawStruct
;
if
(
aClone
)
NewDrawStruct
->
m_TimeStamp
=
aDrawStruct
->
m_TimeStamp
;
NewDrawStruct
->
m_Image
=
aDrawStruct
;
return
NewDrawStruct
;
}
eeschema/protos.h
View file @
aa35b980
...
...
@@ -71,11 +71,21 @@ bool LibItemInBox( int x1, int y1, int x2, int y2,
/************/
/* BLOCK.CPP */
/************/
SCH_ITEM
*
DuplicateStruct
(
SCH_ITEM
*
DrawStruct
);
void
DeleteStruct
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
SCH_ITEM
*
DrawStruct
);
// operations_on_item_lists.cpp
/** function DuplicateStruct
* Routine to create a new copy of given struct.
* @param aDrawStruct = the SCH_ITEM to duplicate
* @param aClone (defualt = true)
* if true duplicate also some parameters that must be unique
* (timestamp and sheet name)
* aClone must be false. use true only is undo/redo duplications
*/
SCH_ITEM
*
DuplicateStruct
(
SCH_ITEM
*
DrawStruct
,
bool
aClone
=
false
);
/*************/
/* LOCATE.CPP */
/*************/
...
...
eeschema/schedit.cpp
View file @
aa35b980
...
...
@@ -397,20 +397,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case
ID_POPUP_SCH_DRAG_CMP_REQUEST
:
case
ID_POPUP_SCH_MOVE_CMP_REQUEST
:
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if
(
screen
->
GetCurItem
()
->
Type
()
!=
TYPE_SCH_COMPONENT
)
// component, like Field, text..) or a hierachical sheet
if
(
(
screen
->
GetCurItem
()
->
Type
()
!=
TYPE_SCH_COMPONENT
)
&&
(
screen
->
GetCurItem
()
->
Type
()
!=
DRAW_SHEET_STRUCT_TYPE
)
)
screen
->
SetCurItem
(
LocateSmallestComponent
(
screen
)
);
if
(
screen
->
GetCurItem
()
==
NULL
)
break
;
// fall through
case
ID_POPUP_SCH_MOVE_ITEM_REQUEST
:
DrawPanel
->
MouseToCursorSchema
();
if
(
id
==
ID_POPUP_SCH_DRAG_CMP_REQUEST
)
{
// The easiest way to handle a drag component
is to simulate a
// block drag command
// The easiest way to handle a drag component
or sheet command
//
is to simulate a
block drag command
if
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
)
{
if
(
!
HandleBlockBegin
(
&
dc
,
BLOCK_DRAG
,
...
...
eeschema/schematic_undo_redo.cpp
View file @
aa35b980
...
...
@@ -180,35 +180,6 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
}
/** function CloneStruct
* must be used only in undo/redo functions
*
* Routine to create a new copy of given schatic object.
* It does the same job as DuplicateStruct, but
* but clone time stamp and sheet name when cloning a SCH_SHEET objects
* (because time stamp and sheets name must be unique
* DuplicateStruct does not copy these members
*/
static
SCH_ITEM
*
CloneStruct
(
SCH_ITEM
*
aDrawStruct
)
{
SCH_ITEM
*
item
=
DuplicateStruct
(
aDrawStruct
);
if
(
item
==
NULL
)
return
NULL
;
item
->
m_TimeStamp
=
aDrawStruct
->
m_TimeStamp
;
switch
(
item
->
Type
()
)
{
case
DRAW_SHEET_STRUCT_TYPE
:
((
SCH_SHEET
*
)
item
)
->
m_SheetName
=
((
SCH_SHEET
*
)
aDrawStruct
)
->
m_SheetName
;
break
;
default:
break
;
}
return
item
;
}
/** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list.
...
...
@@ -260,7 +231,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
switch
(
aCommandType
)
{
case
UR_CHANGED
:
/* Create a copy of item */
CopyOfItem
=
CloneStruct
(
aItem
);
CopyOfItem
=
DuplicateStruct
(
aItem
,
true
);
itemWrapper
.
m_Link
=
CopyOfItem
;
if
(
CopyOfItem
)
commandToUndo
->
PushItem
(
itemWrapper
);
...
...
@@ -330,7 +301,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
* If this link is not null, the copy is already done
*/
if
(
commandToUndo
->
GetPickedItemLink
(
ii
)
==
NULL
)
commandToUndo
->
SetPickedItemLink
(
CloneStruct
(
item
),
ii
);
commandToUndo
->
SetPickedItemLink
(
DuplicateStruct
(
item
,
true
),
ii
);
wxASSERT
(
commandToUndo
->
GetPickedItemLink
(
ii
)
);
break
;
...
...
eeschema/sheet.cpp
View file @
aa35b980
...
...
@@ -106,6 +106,9 @@ structures and cannot be undone.\nOk to continue renaming?" );
}
}
else
SaveCopyInUndoList
(
aSheet
,
UR_CHANGED
);
aSheet
->
m_FileNameSize
=
ReturnValueFromString
(
g_UnitMetric
,
dlg
.
GetFileNameTextSize
(),
m_InternalUnits
);
...
...
@@ -202,6 +205,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC )
screen
->
SetCurItem
(
NULL
);
aPanel
->
ManageCurseur
=
NULL
;
aPanel
->
ForceCloseManageCurseur
=
NULL
;
SAFE_DELETE
(
g_ItemToUndoCopy
);
}
...
...
@@ -213,6 +217,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC )
SCH_SHEET
*
WinEDA_SchematicFrame
::
CreateSheet
(
wxDC
*
aDC
)
{
g_ItemToRepeat
=
NULL
;
SAFE_DELETE
(
g_ItemToUndoCopy
);
SCH_SHEET
*
sheet
=
new
SCH_SHEET
(
GetScreen
()
->
m_Curseur
);
...
...
@@ -273,6 +278,12 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
DrawPanel
->
ManageCurseur
=
MoveOrResizeSheet
;
DrawPanel
->
ForceCloseManageCurseur
=
ExitSheet
;
DrawPanel
->
ManageCurseur
(
DrawPanel
,
aDC
,
true
);
if
(
(
aSheet
->
m_Flags
&
IS_NEW
)
==
0
)
// not already in edit, save a copy for undo/redo
{
delete
g_ItemToUndoCopy
;
g_ItemToUndoCopy
=
DuplicateStruct
(
aSheet
,
true
);
}
}
...
...
@@ -291,4 +302,10 @@ void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
DrawPanel
->
ForceCloseManageCurseur
=
ExitSheet
;
DrawPanel
->
ManageCurseur
(
DrawPanel
,
aDC
,
true
);
DrawPanel
->
CursorOn
(
aDC
);
if
(
(
aSheet
->
m_Flags
&
IS_NEW
)
==
0
)
// not already in edit, save a copy for undo/redo
{
delete
g_ItemToUndoCopy
;
g_ItemToUndoCopy
=
DuplicateStruct
(
aSheet
,
true
);
}
}
eeschema/sheetlab.cpp
View file @
aa35b980
...
...
@@ -168,9 +168,14 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
void
SCH_SHEET_PIN
::
Place
(
WinEDA_SchematicFrame
*
frame
,
wxDC
*
DC
)
{
SCH_SHEET
*
Sheet
=
(
SCH_SHEET
*
)
GetParent
();
SAFE_DELETE
(
g_ItemToUndoCopy
);
if
(
m_Flags
&
IS_NEW
)
int
flags
=
m_Flags
;
m_Flags
=
0
;
if
(
flags
&
IS_NEW
)
{
frame
->
SaveCopyInUndoList
(
Sheet
,
UR_CHANGED
);
if
(
Sheet
->
m_Label
==
NULL
)
Sheet
->
m_Label
=
this
;
else
...
...
@@ -188,10 +193,19 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
}
}
m_Flags
=
0
;
m_Pos
.
x
=
Sheet
->
m_Pos
.
x
;
else
// pin sheet was existing and only moved
{
wxPoint
tmp
=
m_Pos
;
m_Pos
=
s_InitialPosition
;
m_Edge
=
0
;
if
(
m_Pos
.
x
>
(
Sheet
->
m_Pos
.
x
+
(
Sheet
->
m_Size
.
x
/
2
)
)
)
m_Edge
=
1
;
frame
->
SaveCopyInUndoList
(
Sheet
,
UR_CHANGED
);
m_Pos
=
tmp
;
}
m_Pos
.
x
=
Sheet
->
m_Pos
.
x
;
m_Edge
=
0
;
if
(
frame
->
GetScreen
()
->
m_Curseur
.
x
>
(
Sheet
->
m_Pos
.
x
+
(
Sheet
->
m_Size
.
x
/
2
)
)
)
{
m_Edge
=
1
;
...
...
@@ -350,11 +364,13 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet,
if
(
(
HLabel
==
NULL
)
||
SheetLabel
)
{
Display
Error
(
this
,
_
(
"No new hierarchical labels found"
),
10
);
Display
InfoMessage
(
this
,
_
(
"No new hierarchical labels found"
),
10
);
return
NULL
;
}
OnModify
(
);
SAFE_DELETE
(
g_ItemToUndoCopy
);
SaveCopyInUndoList
(
Sheet
,
UR_CHANGED
);
NewSheetLabel
=
new
SCH_SHEET_PIN
(
Sheet
,
wxPoint
(
0
,
0
),
HLabel
->
m_Text
);
NewSheetLabel
->
m_Flags
=
IS_NEW
;
...
...
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