Skip to content

Commit

Permalink
Merge pull request #2445 from alicevision/dev/sequencePlayerModifs
Browse files Browse the repository at this point in the history
[ui] Sequence Player UI Modifications
  • Loading branch information
cbentejac authored Jul 11, 2024
2 parents 204de11 + 3c5e1ad commit cf656b6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 19 deletions.
58 changes: 47 additions & 11 deletions meshroom/ui/qml/Utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ function intToString(v) {

// Convert a plain text to an html escaped string.
function plainToHtml(t) {
var escaped = t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') // escape text
return escaped.replace(/\n/g, '<br>') // replace line breaks
var escaped = t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') // escape text
return escaped.replace(/\n/g, '<br>') // replace line breaks
}

function divmod(x, y) {
// Perform the division and get the quotient
const quotient = Math.floor(x / y);
const quotient = Math.floor(x / y)
// Compute the remainder
const remainder = x % y;
return [quotient, remainder];
const remainder = x % y
return [quotient, remainder]
}

function sec2timeHMS(totalSeconds) {
Expand All @@ -30,7 +30,7 @@ function sec2timeHMS(totalSeconds) {
hours: hours,
minutes: minutes,
seconds: seconds
};
}
}

function sec2timecode(timeSeconds) {
Expand All @@ -43,22 +43,22 @@ function sec2timecode(timeSeconds) {
function sec2timeStr(timeSeconds) {
// Need to decide the rounding precision first
// to propagate the right values
if(timeSeconds >= 60.0) {
if (timeSeconds >= 60.0) {
timeSeconds = Math.round(timeSeconds)
} else {
timeSeconds = parseFloat(timeSeconds.toFixed(2))
}
var timeObj = sec2timeHMS(timeSeconds)
var timeStr = ""
if(timeObj.hours > 0) {
if (timeObj.hours > 0) {
timeStr += timeObj.hours + "h"
}
if(timeObj.hours > 0 || timeObj.minutes > 0) {
if (timeObj.hours > 0 || timeObj.minutes > 0) {
timeStr += timeObj.minutes + "m"
}
if(timeObj.hours === 0) {
if (timeObj.hours === 0) {
// seconds only matter if the elapsed time is less than 1 hour
if(timeObj.minutes === 0) {
if (timeObj.minutes === 0) {
// If less than a minute, keep millisecond precision
timeStr += timeObj.seconds.toFixed(2) + "s"
} else {
Expand All @@ -68,3 +68,39 @@ function sec2timeStr(timeSeconds) {
}
return timeStr
}

function GB2GBMBKB(GB) {
// Convert GB to GB, MB, KB
var GBInt = Math.floor(GB)
var MB = Math.floor((GB - GBInt) * 1024)
var KB = Math.floor(((GB - GBInt) * 1024 - MB) * 1024)
return {
GB: GBInt,
MB: MB,
KB: KB
}
}

function GB2SizeStr(GB) {
// Convert GB to a human readable size string
// e.g. 1.23GB, 456MB, 789KB
// We only use one unit at a time
var sizeObj = GB2GBMBKB(GB)
var sizeStr = ""
if (sizeObj.GB > 0) {
sizeStr += sizeObj.GB
if (sizeObj.MB > 0 && sizeObj.GB < 10) {
sizeStr += "." + Math.floor(sizeObj.MB / 1024 * 1000)
}
sizeStr += "GB"
} else if (sizeObj.MB > 0) {
sizeStr = sizeObj.MB
if (sizeObj.KB > 0 && sizeObj.MB < 10) {
sizeStr += "." + Math.floor(sizeObj.KB / 1024 * 1000)
}
sizeStr += "MB"
} else if (sizeObj.GB === 0 && sizeObj.MB === 0) {
sizeStr += sizeObj.KB + "KB"
}
return sizeStr
}
12 changes: 6 additions & 6 deletions meshroom/ui/qml/Viewer/SequencePlayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ FloatingPane {

color: palette.text
horizontalAlignment: Text.AlignHCenter
selectByMouse: true

text: m.frame

onEditingFinished: {
Expand Down Expand Up @@ -308,6 +310,7 @@ FloatingPane {
id: fpsTextInput

Layout.preferredWidth: fpsMetrics.width
selectByMouse: true

text: !focus ? m.fps + " FPS" : m.fps
color: palette.text
Expand Down Expand Up @@ -482,18 +485,15 @@ FloatingPane {
ProgressBar {
id: occupiedCacheProgressBar

property string occupiedCache: viewer.ramInfo ? Format.GB2SizeStr(viewer.ramInfo.y) : 0

width: parent.width

from: 0
to: settings_SequencePlayer.maxCacheMemory
value: viewer && viewer.ramInfo != undefined ? viewer.ramInfo.y : 0

ToolTip.text: {
if (viewer && viewer.ramInfo != undefined) {
return "Occupied cache: "+ viewer.ramInfo.y + " GB" + "\n" + "On max cache memory set: " + settings_SequencePlayer.maxCacheMemory + " GB"
}
return "Unknown occupied cache (max cache memory set: " + settings_SequencePlayer.maxCacheMemory + ")"
}
ToolTip.text: "Occupied cache: " + occupiedCache + "\n" + "On max cache memory set: " + settings_SequencePlayer.maxCacheMemory + " GB"
ToolTip.visible: hovered
ToolTip.delay: 100
}
Expand Down
3 changes: 1 addition & 2 deletions meshroom/ui/qml/Viewer/Viewer2D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ FocusScope {
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput))) ? getSequence() : []) }),
'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize }),
'useSequence': Qt.binding(function() {
let attr = root.displayedNode ? root.displayedNode.attributes.get(outputAttribute.name) : undefined
return (root.enableSequencePlayer && !useExternal && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput)) && (attr.desc.semantic === "imageList" || attr.desc.semantic === "sequence"))
return (root.enableSequencePlayer && !useExternal && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput && (displayedAttr.desc.semantic === "imageList" || displayedAttr.desc.semantic === "sequence"))))
}),
'fetchingSequence': Qt.binding(function() { return sequencePlayer.loading }),
'memoryLimit': Qt.binding(function() { return sequencePlayer.settings_SequencePlayer.maxCacheMemory }),
Expand Down

0 comments on commit cf656b6

Please sign in to comment.