Switch to Waveform via Script

User avatar
SirEdric
Fusionator
Posts: 2053
Joined: Tue Aug 05, 2014 10:04 am
Answers: 4
Real name: Eric Westphal
Been thanked: 160 times
Contact:

Switch to Waveform via Script

#1

Post by SirEdric » Mon Dec 02, 2019 4:47 am

Hey there.

Is there any way to toggle the individual Display Views between 2DViewer, Waveform, Verctorscope,..... via Script?

To explain further, with == comp:GetPreviewList().Left.View:GetViewerList()
I do get the type of the left viewer like
1 = 2D Viewer (0x0000000036FA2B40) [App: 'Fusion' on 127.0.0.1, UUID: 196adb6e-81a8-459d-8dd2-e66465fae07c]
or
1 = Waveform (0x000000002140A380) [App: 'Fusion' on 127.0.0.1, UUID: 196adb6e-81a8-459d-8dd2-e66465fae07c]

But there's no SetViewer() function AFAICT....?

Cheers.

Eric.

User avatar
AndrewHazelden
Fusionator
Posts: 1523
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 6
Location: West Dover, Nova Scotia, Canada
Been thanked: 95 times
Contact:

Re: Switch to Waveform via Script

#2

Post by AndrewHazelden » Mon Dec 02, 2019 6:00 am

Hi @SirEdric.

Building on top of the information on the "Adjusting Fusion/Resolve Views Layouts With Actions" WSL post, in Fusion/Resolve v16 you could can use an action based approach to toggle UI elements like this:

Code: Select all

comp:DoAction("Fusion_View_Show", {view = "Keyframes"}) -- show the "Keyframes" view
comp:DoAction("Fusion_View_Show", {view = "Spline"}) -- show the "Spline" view
wrote:Is there any way to toggle the individual Display Views between 2DViewer, Waveform, Verctorscope,..... via Script?

From running the "UI Manager Lua & Python" Reactor atom package provided script Action Printout.lua I can see these two actions exist in Fusion:

Code: Select all

comp:DoAction("Viewer_SubView_Enable")
comp:DoAction("Viewer_SubView_Swap")

The next step is the real problem though — I don't have a clear idea of how to define the Viewer 1 or Viewer 2 targets with those actions, or how to specify the arguments for which SubView you want to toggle. That is something only Peter Loveday, or the Fusion 17 scripting documentation might be able to explain (pending a newer guide even exists next year which is anyone's guess). :mrgreen:

User avatar
SirEdric
Fusionator
Posts: 2053
Joined: Tue Aug 05, 2014 10:04 am
Answers: 4
Real name: Eric Westphal
Been thanked: 160 times
Contact:

Re: Switch to Waveform via Script

#3

Post by SirEdric » Mon Dec 02, 2019 6:04 am

Hey Andrew.

Thanks! Much appreciated as always!
I don't want to change the SubViews though, but the two big ones....:-)

But...yeah...no clue either from the Fu8 Scripting Manual.....

User avatar
AndrewHazelden
Fusionator
Posts: 1523
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 6
Location: West Dover, Nova Scotia, Canada
Been thanked: 95 times
Contact:

Re: Switch to Waveform via Script

#4

Post by AndrewHazelden » Mon Dec 02, 2019 6:15 am

Well, if it's not SubView customization you are after, then you might be able to get some ideas from @MelbFilm's post here that explores the undocumented but oh-so-spicy comp.CurrentFrame:SetViewLayout() function:

Dual Monitor Setup for FU 16 - Hack/Beta


Also, if by chance you had a rare bit of available time, you could try to push forward the R&D on the "ACTION_GET_UI_LAYOUT" and "ACTION_SET_UI_LAYOUT" actions which I think is another way to burst the Lua scripted Fusion v16 UI customization nut 🌰 wide open. :)

(BTW I hoped for a walnut emoji in the last sentence but the best I could muster is a chestnut emoji, sorry.)

User avatar
Movalex
Sir Requestalot
Posts: 152
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 43 times
Contact:

Re: Switch to Waveform via Script

#5

Post by Movalex » Mon Dec 02, 2019 10:51 am

@SirEdric
You can reach Viewer methods with Python command:
  1. left_view = comp.GetPreviewList()['LeftView']['View'] # works in Fusion16 only
  2.  
  3. print(dir(left_view))
you will get this list for viewer operations:
  1. ['AddToolAction', 'AddView', 'Comp', 'Composition', 'CurrentViewer', 'DisableCurrentTools', 'DisableSelectedTools', 'DoAction', 'EnableLUT', 'EnableStereo', 'GetBuffer', 'GetData', 'GetID', 'GetLocked', 'GetPos', 'GetPosTable', 'GetPrefs', 'GetPreview', 'GetReg', 'GetRot', 'GetRotTable', 'GetScale', 'GetScaleFit', 'GetSplit', 'GetSplitTable', 'GetStereoMethod', 'GetStereoSource', 'GetViewerList', 'ID', 'IsLUTEnabled', 'IsStereoEnabled', 'IsStereoSwapped', 'IsWipeEnabled', 'LoadLUTFile', 'LoadPrefs', 'QueueAction', 'Refresh', 'Remove', 'ResetView', 'SavePrefs', 'SetBuffer', 'SetData', 'SetLocked', 'SetPos', 'SetRot', 'SetScale', 'SetSplit', 'SetStereoMethod', 'SetStereoSource', 'ShowLUTEditor', 'ShowQuadView', 'ShowSubView', 'ShowTabs', 'ShowingQuadView', 'ShowingSubView', 'SwapStereo', 'SwapSubView', 'TriggerEvent', 'Undock', 'WipeEnable']
Therefore you can toggle SubView with
  1. lv = comp:GetPreviewList().LeftView.View
  2. lv:ShowSubView()
  3. lv:SwapSubView()
It also toggles with lv:DoAction("Viewer_SubView_Enable", {})
or lv:DoAction("Viewer_SubView_Enable", {show=true}) and lv:DoAction("Viewer_SubView_Enable", {show=false})
So we just have to figure out, which parameters to use to toggle any particular SubView... And I have no Idea, which is that :)
Last edited by Movalex on Mon Dec 02, 2019 2:58 pm, edited 2 times in total.

User avatar
SirEdric
Fusionator
Posts: 2053
Joined: Tue Aug 05, 2014 10:04 am
Answers: 4
Real name: Eric Westphal
Been thanked: 160 times
Contact:

Re: Switch to Waveform via Script

#6

Post by SirEdric » Mon Dec 02, 2019 2:15 pm

Movalex wrote:
Mon Dec 02, 2019 10:51 am
So we just have to figure out, which parameters to use to toggle any particular SubView... And I have no Idea, which is that
Now, this makes us two...:-)

User avatar
Movalex
Sir Requestalot
Posts: 152
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 43 times
Contact:

Re: Switch to Waveform via Script

#7

Post by Movalex » Mon Dec 02, 2019 2:54 pm

SirEdric wrote:
Mon Dec 02, 2019 2:15 pm
Now, this makes us two.
Such a nice company!
BTW, if the comp layout is saved with SubView toggled on, this is what we've got in LeftView layout section:
Vectorscope:
ID = "GLVectorViewer"
Historgam:
ID = "GLHistogramViewer"
3DHistogram:
ID = "GL3DHistogramViewer"
Waveform:
ID = "GLWaveformViewer"
2D Viewer
ID = "GLImageViewer"

settings structure with Histogram enabled:
  1.                
  2. LeftView = {
  3.                     PickH = 1,
  4.                     SubView = {
  5.                         Enabled = true,
  6.                         Navigator = false,
  7.                         GL3DHistogramViewer = {
  8.                             AutoBounds = true
  9.                         },
  10.                         GLVectorViewer = {
  11.                             AutoBounds = true
  12.                         },
  13.                         Magnifier = false,
  14.                         ID = "GLHistogramViewer",
  15.                         GLWaveformViewer = {
  16.                             AutoBounds = true
  17.                         },
  18.                         GLHistogramViewer = {
  19.                             AutoBounds = true
  20.                         },
  21.                         GLImageViewer = {
  22.                             AutoBounds = true
  23.                         },
  24.                         Viewer = {
  25.                             ScaleMode = 0,
  26.                             Smooth = false,
  27.                             PixelGrid = true,
  28.                         }
  29.                     },
  30.                     PickW = 1,
  31.                     Viewer = {
  32.                         ScaleMode = 1,
  33.                         Region = {
  34.                             Top = 1,
  35.                             Bottom = 0,
  36.                             Enable = false,
  37.                             Right = 1,
  38.                             Left = 0,
  39.                         },
  40.                     },

User avatar
SirEdric
Fusionator
Posts: 2053
Joined: Tue Aug 05, 2014 10:04 am
Answers: 4
Real name: Eric Westphal
Been thanked: 160 times
Contact:

Re: Switch to Waveform via Script

#8

Post by SirEdric » Tue Dec 03, 2019 12:56 am

Thanks for all the cool tips, guys.
Most interestingly
lv = comp:GetPreviewList().LeftView.View
lv:ShowSubView()
==lv:GetPrefs().SubView

returns quite nicely:
table: 0x2f0c0d18
GLHistogramViewer = table: 0x2f0c0d60
AutoBounds = true
Enabled = true


So if there only was a lv:SetPrefs() method, we would be fine. But there isn't.
So I tried lv:SavePrefs('EricsView'), hoping for a hackaround where one could create a 'pseudo prefs file',
and then apply it to the view with lv:LoadPrefs('EricsView').
But apparently SavePrefs doesn't save anything I could find on Disk....

Added in 20 minutes 28 seconds:
Hmmmm....actually the settings *do* get saved, since I can see them in the RMB->Settings menu....