-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
248 additions
and
7 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...ksptot_ma/launch_vehicle_designer/classes/UndoRedo/@LVD_UndoRedoState/LVD_UndoRedoState.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
classdef LVD_UndoRedoState < matlab.mixin.SetGet | ||
%LVD_UndoRedoState Summary of this class goes here | ||
% Detailed explanation goes here | ||
|
||
properties | ||
serialLvdData uint8 | ||
actionName(1,:) char | ||
end | ||
|
||
methods | ||
function obj = LVD_UndoRedoState(lvdData, actionName) | ||
obj.serialLvdData = getByteStreamFromArray(lvdData); | ||
obj.actionName = actionName; | ||
end | ||
|
||
function [lvdData, actionName] = getUndoData(obj) | ||
lvdData = getArrayFromByteStream(obj.serialLvdData); | ||
actionName = obj.actionName; | ||
end | ||
end | ||
end |
87 changes: 87 additions & 0 deletions
87
..._ma/launch_vehicle_designer/classes/UndoRedo/@LVD_UndoRedoStateSet/LVD_UndoRedoStateSet.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
classdef LVD_UndoRedoStateSet < matlab.mixin.SetGet | ||
%LVD_UndoRedoStateSet Summary of this class goes here | ||
% Detailed explanation goes here | ||
|
||
properties | ||
undo_states(:,1) LVD_UndoRedoState | ||
undo_pointer (1,1) double = 0 | ||
end | ||
|
||
methods | ||
function obj = LVD_UndoRedoStateSet() | ||
obj.undo_states = LVD_UndoRedoState.empty(1,0); | ||
end | ||
|
||
function addState(obj, hLvdFig, lvdData, actionName) | ||
if(obj.undo_pointer > length(obj.undo_states)) | ||
error('Undo/redo states and the pointer are out of sync.'); | ||
end | ||
|
||
if(obj.undo_pointer == 0) | ||
obj.undo_states = LVD_UndoRedoState.empty(1,0); | ||
obj.undo_states(end+1) = LVD_UndoRedoState(lvdData, actionName); | ||
obj.undo_pointer = 1; | ||
else | ||
t_undo_states = obj.undo_states(1:obj.undo_pointer,:); | ||
t_undo_states(end+1) = LVD_UndoRedoState(lvdData, actionName); | ||
obj.undo_states = t_undo_states; | ||
obj.undo_pointer = obj.undo_pointer + 1; | ||
end | ||
|
||
maxUndos = 25; | ||
if(obj.undo_pointer>maxUndos) | ||
obj.undo_states = obj.undo_states(end-(maxUndos-1):end,:); | ||
obj.undo_pointer = maxUndos; | ||
end | ||
|
||
curName = get(hLvdFig,'Name'); | ||
if(~strcmpi(curName(end),'*')) | ||
set(hLvdFig,'Name',[curName,'*']); | ||
end | ||
end | ||
|
||
function lvdData = undo(obj, curLvdData) | ||
lvdData = LvdData.empty(0,1); | ||
if(obj.undo_pointer < 1 || obj.undo_pointer > length(obj.undo_states)) | ||
return; | ||
end | ||
|
||
if(obj.undo_pointer == length(obj.undo_states)) | ||
obj.undo_states(end+1) = LVD_UndoRedoState(curLvdData, ''); | ||
end | ||
|
||
lvdData = obj.undo_states(obj.undo_pointer).getUndoData(); | ||
obj.undo_pointer = obj.undo_pointer - 1; | ||
end | ||
|
||
function lvdData = redo(obj) | ||
lvdData = LvdData.empty(0,1); | ||
if(obj.undo_pointer + 1 < 1 || obj.undo_pointer + 2 > length(obj.undo_states)) | ||
return; | ||
end | ||
|
||
lvdData = obj.undo_states(obj.undo_pointer+2).getUndoData(); | ||
obj.undo_pointer = obj.undo_pointer + 1; | ||
end | ||
|
||
function [tf, undoActionName] = shouldUndoMenuBeEnabled(obj) | ||
if(obj.undo_pointer > 0) | ||
undoActionName = obj.undo_states(obj.undo_pointer).actionName; | ||
tf = true; | ||
else | ||
undoActionName = ''; | ||
tf = false; | ||
end | ||
end | ||
|
||
function [tf, redoActionName] = shouldRedoMenuBeEnabled(obj) | ||
if(obj.undo_pointer + 1 > 0 && obj.undo_pointer + 1 < length(obj.undo_states)) | ||
redoActionName = obj.undo_states(obj.undo_pointer+1).actionName; | ||
tf = true; | ||
else | ||
redoActionName = ''; | ||
tf = false; | ||
end | ||
end | ||
end | ||
end |
Binary file modified
BIN
+1.53 KB
(100%)
kspTOT_MissionArchitect/LaunchVehicleDesigner/ma_LvdMainGUI.fig
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.