Skip to content

Commit fe14d08

Browse files
SG-41208: Add softDeleted paint node property to support undo, redo and clear actions in Live Review (#1027)
### [SG-41208](https://jira.autodesk.com/browse/SG-41208): Add softDeleted paint node property to support undo, redo and clear actions in Live Review ### Summarize your change. A `softDeleted` property was added for each paint node stroke to support undo, redo and clear actions for OTIO-based Live Review. This new property is following the same pattern as the new `uuid` property. These aren't known by the C++ code responsible for rendering annotations, they are simply used to help with keeping the Annotate and the Live Review package synchronized in terms of the state of each annotation. For each undo, redo and clear action, the Annotate Mode will send an internal event with the least of stroke uuids affected by the action. The `name` field in the OTIO Paint schema was completely removed since it was decided it was actually needed since it isn't an OTIO effect. ### Describe the reason for the change. The `softDeleted` property was already added as a field in the OTIO Paint schema but it was also added as an RV node property to facilitate the interaction between the Live Review plugin that needs this information and the Annotate mode that is making the action. ### Describe what you have tested and on which operating system. Drawing, undoing, redoing and clearing strokes was tested on macOS 15.6.1. --------- Signed-off-by: Éloïse Brosseau <[email protected]>
1 parent 9e65427 commit fe14d08

File tree

3 files changed

+175
-88
lines changed

3 files changed

+175
-88
lines changed

src/plugins/rv-packages/annotate/annotate_mode.mu

Lines changed: 115 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,13 @@ class: AnnotateMinorMode : MinorMode
567567

568568
let uuid = generateUuid();
569569
let uuidProperty = "%s.uuid" % n;
570-
571570
newProperty(uuidProperty, StringType, 1);
572571
setStringProperty(uuidProperty, string[] {uuid}, true);
573572

573+
let softDeletedProperty = "%s.softDeleted" % n;
574+
newProperty(softDeletedProperty, IntType, 1);
575+
setIntProperty(softDeletedProperty, int[] {0}, true);
576+
574577
let stroke = n.split(".").back();
575578

576579
if (!propertyExists(orderName))
@@ -709,6 +712,10 @@ class: AnnotateMinorMode : MinorMode
709712
newProperty(uuidProperty, StringType, 1);
710713
setStringProperty(uuidProperty, string[] {uuid}, true);
711714

715+
let softDeletedProperty = "%s.softDeleted" % n;
716+
newProperty(softDeletedProperty, IntType, 1);
717+
setIntProperty(softDeletedProperty, int[] {0}, true);
718+
712719
let stroke = n.split(".").back();
713720

714721
if (!propertyExists(orderName))
@@ -1596,19 +1603,29 @@ class: AnnotateMinorMode : MinorMode
15961603
// clearAllUndo format: ["clearAllFrames", "node1", "stroke1", "node2", "stroke2"]
15971604
if (clearAllUndo.size() > 1 && clearAllUndo[0] == "clearAllFrames")
15981605
{
1606+
string[] affectedStrokes;
1607+
15991608
beginCompoundStateChange();
16001609

16011610
for (int i = 1; i < clearAllUndo.size(); i += 2)
16021611
{
16031612
let node = clearAllUndo[i];
16041613
let uuid = clearAllUndo[i + 1];
16051614

1615+
affectedStrokes.push_back(uuid);
1616+
16061617
let stroke = findStrokeByUuid(node, frame(), uuid);
16071618
if (stroke != "")
16081619
{
16091620
let parts = stroke.split(":"); // Stroke format: type:id:frame:user_processId
16101621
let frame = int(parts[2]);
16111622

1623+
let softDeleted = "%s.%s.softDeleted" % (node, stroke);
1624+
if (propertyExists(softDeleted))
1625+
{
1626+
setIntProperty(softDeleted, int[] {0}, true);
1627+
}
1628+
16121629
let orderName = frameOrderName(node, frame);
16131630

16141631
if (!propertyExists(orderName))
@@ -1629,6 +1646,13 @@ class: AnnotateMinorMode : MinorMode
16291646
setStringProperty(clearAllUndoProperty, string[] {}, true);
16301647

16311648
endCompoundStateChange();
1649+
1650+
if (affectedStrokes.size() > 0)
1651+
{
1652+
string eventContents = string.join(affectedStrokes, "|");
1653+
sendInternalEvent("undo-paint", eventContents);
1654+
}
1655+
16321656
return;
16331657
}
16341658
}
@@ -1669,6 +1693,12 @@ class: AnnotateMinorMode : MinorMode
16691693
let stroke = findStrokeByUuid(_currentNode, frame, uuid);
16701694
if (stroke != "")
16711695
{
1696+
let softDeleted = "%s.%s.softDeleted" % (_currentNode, stroke);
1697+
if (propertyExists(softDeleted))
1698+
{
1699+
setIntProperty(softDeleted, int[] {1}, true);
1700+
}
1701+
16721702
for_index(i; order)
16731703
{
16741704
if (order[i] == stroke)
@@ -1705,6 +1735,13 @@ class: AnnotateMinorMode : MinorMode
17051735
{
17061736
affectedStrokes.push_back(uuid);
17071737
let stroke = findStrokeByUuid(_currentNode, frame, uuid);
1738+
1739+
let softDeleted = "%s.%s.softDeleted" % (_currentNode, stroke);
1740+
if (propertyExists(softDeleted))
1741+
{
1742+
setIntProperty(softDeleted, int[] {0}, true);
1743+
}
1744+
17081745
order.push_back(stroke);
17091746
}
17101747

@@ -1742,19 +1779,29 @@ class: AnnotateMinorMode : MinorMode
17421779
// clearAllRedo format: ["clearAllFrames", "node1", "stroke1", "node2", "stroke2"]
17431780
if (clearAllRedo.size() > 1 && clearAllRedo[0] == "clearAllFrames")
17441781
{
1782+
string[] affectedStrokes;
1783+
17451784
beginCompoundStateChange();
17461785

17471786
for (int i = 1; i < clearAllRedo.size(); i += 2)
17481787
{
17491788
let node = clearAllRedo[i];
17501789
let uuid = clearAllRedo[i + 1];
17511790

1791+
affectedStrokes.push_back(uuid);
1792+
17521793
let stroke = findStrokeByUuid(node, frame(), uuid);
17531794
if (stroke != "")
17541795
{
17551796
let parts = stroke.split(":"); // Stroke format: type:id:frame:user_processId
17561797
let frame = int(parts[2]);
17571798

1799+
let softDeleted = "%s.%s.softDeleted" % (node, stroke);
1800+
if (propertyExists(softDeleted))
1801+
{
1802+
setIntProperty(softDeleted, int[] {1}, true);
1803+
}
1804+
17581805
let orderName = frameOrderName(node, frame);
17591806
if (propertyExists(orderName))
17601807
{
@@ -1781,6 +1828,13 @@ class: AnnotateMinorMode : MinorMode
17811828
setStringProperty(clearAllRedoProperty, string[] {}, true);
17821829

17831830
endCompoundStateChange();
1831+
1832+
if (affectedStrokes.size() > 0)
1833+
{
1834+
string eventContents = string.join(affectedStrokes, "|");
1835+
sendInternalEvent("redo-paint", eventContents);
1836+
}
1837+
17841838
return;
17851839
}
17861840
}
@@ -1821,6 +1875,12 @@ class: AnnotateMinorMode : MinorMode
18211875
let stroke = findStrokeByUuid(_currentNode, frame, uuid);
18221876
if (stroke != "")
18231877
{
1878+
let softDeleted = "%s.%s.softDeleted" % (_currentNode, stroke);
1879+
if (propertyExists(softDeleted))
1880+
{
1881+
setIntProperty(softDeleted, int[] {0}, true);
1882+
}
1883+
18241884
order.push_back(stroke);
18251885

18261886
undo.push_back(uuid);
@@ -1850,6 +1910,13 @@ class: AnnotateMinorMode : MinorMode
18501910
{
18511911
affectedStrokes.push_back(uuid);
18521912
let stroke = findStrokeByUuid(_currentNode, frame, uuid);
1913+
1914+
let softDeleted = "%s.%s.softDeleted" % (_currentNode, stroke);
1915+
if (propertyExists(softDeleted))
1916+
{
1917+
setIntProperty(softDeleted, int[] {1}, true);
1918+
}
1919+
18531920
for_index(i; order)
18541921
{
18551922
if (order[i] == stroke)
@@ -1917,6 +1984,7 @@ class: AnnotateMinorMode : MinorMode
19171984
{
19181985
string[] undo;
19191986
string[] redo;
1987+
string[] affectedStrokes;
19201988

19211989
for_each(stroke; order)
19221990
{
@@ -1926,6 +1994,13 @@ class: AnnotateMinorMode : MinorMode
19261994
{
19271995
let uuid = getStringProperty(uuidProperty).front();
19281996
undo.push_back(uuid);
1997+
affectedStrokes.push_back(uuid);
1998+
1999+
let softDeleted = "%s.%s.softDeleted" % (node, stroke);
2000+
if (propertyExists(softDeleted))
2001+
{
2002+
setIntProperty(softDeleted, int[] {1}, true);
2003+
}
19292004
}
19302005
}
19312006
undo.push_back(string(order.size()));
@@ -1952,6 +2027,12 @@ class: AnnotateMinorMode : MinorMode
19522027
clearAllUsersUndoRedoStacks(node, frame, excludeUser);
19532028

19542029
endCompoundStateChange();
2030+
2031+
if (affectedStrokes.size() > 0)
2032+
{
2033+
string eventContents = string.join(affectedStrokes, "|");
2034+
sendInternalEvent("clear-paint", eventContents);
2035+
}
19552036
}
19562037
}
19572038
}
@@ -1960,6 +2041,7 @@ class: AnnotateMinorMode : MinorMode
19602041
{
19612042
string[] clearAllActions;
19622043
clearAllActions.push_back("clearAllFrames");
2044+
string[] affectedStrokes;
19632045

19642046
beginCompoundStateChange();
19652047

@@ -1976,15 +2058,18 @@ class: AnnotateMinorMode : MinorMode
19762058
{
19772059
let uuidProperty = "%s.%s.uuid" % (node, stroke);
19782060

1979-
clearAllActions.push_back(node);
19802061
if (propertyExists(uuidProperty))
19812062
{
19822063
let uuid = getStringProperty(uuidProperty).front();
2064+
clearAllActions.push_back(node);
19832065
clearAllActions.push_back(uuid);
1984-
}
1985-
else
1986-
{
1987-
clearAllActions.push_back("");
2066+
affectedStrokes.push_back(uuid);
2067+
2068+
let softDeleted = "%s.%s.softDeleted" % (node, stroke);
2069+
if (propertyExists(softDeleted))
2070+
{
2071+
setIntProperty(softDeleted, int[] {1}, true);
2072+
}
19882073
}
19892074
}
19902075

@@ -2002,15 +2087,18 @@ class: AnnotateMinorMode : MinorMode
20022087
{
20032088
let uuidProperty = "%s.%s.uuid" % (node, stroke);
20042089

2005-
clearAllActions.push_back(node);
20062090
if (propertyExists(uuidProperty))
20072091
{
20082092
let uuid = getStringProperty(uuidProperty).front();
2093+
clearAllActions.push_back(node);
20092094
clearAllActions.push_back(uuid);
2010-
}
2011-
else
2012-
{
2013-
clearAllActions.push_back("");
2095+
affectedStrokes.push_back(uuid);
2096+
2097+
let softDeleted = "%s.%s.softDeleted" % (node, stroke);
2098+
if (propertyExists(softDeleted))
2099+
{
2100+
setIntProperty(softDeleted, int[] {1}, true);
2101+
}
20142102
}
20152103
}
20162104

@@ -2041,6 +2129,13 @@ class: AnnotateMinorMode : MinorMode
20412129
}
20422130

20432131
endCompoundStateChange();
2132+
2133+
if (affectedStrokes.size() > 0)
2134+
{
2135+
string eventContents = string.join(affectedStrokes, "|");
2136+
sendInternalEvent("clear-all-paint", eventContents);
2137+
}
2138+
20442139
updateFrameDependentState();
20452140
redraw();
20462141
}
@@ -2165,13 +2260,6 @@ class: AnnotateMinorMode : MinorMode
21652260
return if _syncAutoStart then CheckedMenuState else UncheckedMenuState;
21662261
}
21672262

2168-
method: undoSlot (void; bool checked)
2169-
{
2170-
undoPaint();
2171-
updateFrameDependentState();
2172-
redraw();
2173-
}
2174-
21752263
method: clearSlot (void; bool checked)
21762264
{
21772265
clearPaint(_currentNode, _currentNodeInfo.frame);
@@ -2197,6 +2285,13 @@ class: AnnotateMinorMode : MinorMode
21972285
redraw();
21982286
}
21992287

2288+
method: undoSlot (void; bool checked)
2289+
{
2290+
undoPaint();
2291+
updateFrameDependentState();
2292+
redraw();
2293+
}
2294+
22002295
method: redoSlot (void; bool checked)
22012296
{
22022297
redoPaint();
@@ -3034,6 +3129,8 @@ class: AnnotateMinorMode : MinorMode
30343129
_clearButton.setMenu(clearMenu);
30353130
_clearButton.setPopupMode(QToolButton.InstantPopup);
30363131

3132+
connect(clearMenu, QMenu.aboutToShow, undoRedoClearUpdate);
3133+
30373134
connect(_clearFrameAct, QAction.triggered, clearSlot);
30383135
connect(_clearAllFramesAct, QAction.triggered, clearAllSlot);
30393136
_clearButton.setStyleSheet("QToolButton::menu-indicator { subcontrol-position: bottom right; top: -2px; }");

0 commit comments

Comments
 (0)