Skip to content

Commit

Permalink
Add debug panel
Browse files Browse the repository at this point in the history
Also set loading panel to a fixed height and increased the
z-index of the app bar to move it above the CodeMirror
scrollbar
  • Loading branch information
eulertour committed Nov 7, 2019
1 parent af4b35f commit fd5d435
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 20 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -12,6 +12,7 @@
"chroma-js": "^2.0.4",
"codemirror": "^5.49.2",
"core-js": "^2.6.5",
"json-formatter-js": "^2.2.1",
"two.js": "https://github.com/jonobr1/two.js",
"vue": "^2.6.10",
"vue-material": "^1.0.0-beta-11",
Expand Down
7 changes: 7 additions & 0 deletions src/App.vue
Expand Up @@ -41,3 +41,10 @@ export default {
position: relative;
}
</style>

<style scoped>
.v-app-bar.v-app-bar--fixed {
/* .CodeMirror-vscrollbar has z-index: 6 */
z-index: 10;
}
</style>
89 changes: 89 additions & 0 deletions src/components/DebugPanel.vue
@@ -0,0 +1,89 @@
<template>
<div id="debug-container" class="title mt-5 pa-4" v-if="visible">
<div class="headline">Prior Scene</div>
<div id="prior-scene-container" class="mb-4"/>

<div class="headline">
Scene Diff
<v-icon v-if="!$store.getters.sceneIsValid" color="red">
mdi-alert-circle
</v-icon>
</div>
<div id="scene-diff-container" class="mb-4"/>

<div class="headline">
Animation Diff
<v-icon v-if="!$store.getters.animationIsValid" color="red">
mdi-alert-circle
</v-icon>
</div>
<div id="animation-diff-container"/>
</div>
</template>

<script>
import { mapState } from 'vuex'
import JSONFormatter from 'json-formatter-js'
export default {
name: 'DebugPanel',
props: {
visible: Boolean,
},
data() {
return {
needsJsonUpdate: false,
}
},
computed: mapState({
priorScene: 'priorScene',
sceneDiff: 'sceneDiff',
sceneIsValid: 'sceneIsValid',
animationDiff: 'animationDiff',
animationIsValid: 'animationIsValid',
}),
mounted() {
this.updateJson("prior-scene-container", this.priorScene);
this.updateJson("scene-diff-container", this.sceneDiff);
this.updateJson("animation-diff-container", this.animationDiff);
},
watch: {
priorScene(newPriorScene) {
this.updateJson("prior-scene-container", newPriorScene);
},
sceneDiff(newSceneDiff) {
this.updateJson("scene-diff-container", newSceneDiff);
},
animationDiff(newAnimationDiff) {
this.updateJson("animation-diff-container", newAnimationDiff);
},
visible(newlyVisible) {
this.needsJsonUpdate = newlyVisible;
}
},
updated() {
if (this.needsJsonUpdate) {
this.updateJson("prior-scene-container", this.priorScene);
this.updateJson("scene-diff-container", this.sceneDiff);
this.updateJson("animation-diff-container", this.animationDiff);
this.needsJsonUpdate = false;
}
},
methods: {
updateJson(containerId, json) {
let container = document.getElementById(containerId);
if (container.childNodes.length !== 0) {
container.childNodes[0].remove();
}
container.appendChild(new JSONFormatter(json).render());
}
}
}
</script>

<style>
#debug-container {
width: 100%;
border: 1px solid black;
}
</style>
19 changes: 11 additions & 8 deletions src/components/MobjectLab.vue
Expand Up @@ -94,7 +94,7 @@
/>
<v-card v-else
class="d-flex justify-center align-center"
height="100%"
height="500px"
width="100%"
>
<v-progress-circular indeterminate/>
Expand All @@ -105,6 +105,7 @@
<span class="title">Render</span>
</v-btn>
</div>
<DebugPanel v-bind:visible="debug"/>
</div>
<div id="visualization-placeholder">
<div id="visualization">
Expand All @@ -126,11 +127,13 @@
v-bind:scene="scene"
v-bind:finished="animationIndex === animations.length - 1 && animationOffset === 1"
/>
<!-- Debug Info -->
</div>
</div>
<div class="corner-button-container">
<v-dialog v-model="dialog" width="500px">
<v-btn class="mr-4" v-on:click="()=>{debug = !debug}" fab large>
<v-icon large>mdi-bug</v-icon>
</v-btn>
<v-dialog v-model="releaseNotesDialog" width="500px">
<template v-slot:activator="{ on }">
<v-btn v-on="on" fab large>
<v-icon large>mdi-information</v-icon>
Expand All @@ -140,13 +143,10 @@
<v-card-title class="headline grey lighten-2 mb-3" primary-title>
Release Notes
</v-card-title>

<v-card-text class="title">
<span v-html="releaseNotes"></span>
</v-card-text>

<v-divider></v-divider>

<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" text v-on:click="dialog = false">
Expand All @@ -170,6 +170,7 @@ import Timeline from './Timeline.vue'
import VideoControls from './VideoControls.vue'
import CodeMirror from './CodeMirror.vue'
import chroma from 'chroma-js'
import DebugPanel from './DebugPanel.vue'
export default {
name: 'MobjectLab',
Expand All @@ -180,6 +181,7 @@ export default {
Timeline,
VideoControls,
CodeMirror,
DebugPanel,
},
computed: {
currentAnimation() {
Expand Down Expand Up @@ -213,7 +215,8 @@ export default {
data() {
return {
releaseNotes: consts.RELEASE_NOTES,
dialog: false,
releaseNotesDialog: false,
debug: true,
code: consts.EXAMPLE_CODE,
displayCode: true,
expandedPanel: [1],
Expand Down Expand Up @@ -311,7 +314,7 @@ export default {
},
methods: {
runManim: function() {
let scene = window.manimlib.get_scene(this.code, ["GroupExample"]);
let scene = window.manimlib.get_scene(this.code, ["SquareToCircle"]);
scene.render();
// // Uncomment if using Groups
Expand Down
24 changes: 12 additions & 12 deletions src/plugins/vuex.js
Expand Up @@ -55,29 +55,29 @@ const store = new Vuex.Store({
ret = _.difference(ret, state.sceneDiff.remove);
return ret;
},
animationIsValid(state, getters) {
let sceneBeforeAnimation = getters.sceneBeforeAnimation;
for (let mobjectName of (state.animationDiff['add'] || [])) {
if (sceneBeforeAnimation.includes(mobjectName)) {
sceneIsValid(state) {
let priorScene = state.priorScene;
for (let mobjectName of (state.sceneDiff['add'] || [])) {
if (priorScene.includes(mobjectName)) {
return false;
}
}
for (let mobjectName of (state.animationDiff['remove'] || [])) {
if (!sceneBeforeAnimation.includes(mobjectName)) {
for (let mobjectName of (state.sceneDiff['remove'] || [])) {
if (!priorScene.includes(mobjectName)) {
return false;
}
}
return true;
},
sceneIsValid(state) {
let priorScene = state.priorScene;
for (let mobjectName of (state.sceneDiff['add'] || [])) {
if (priorScene.includes(mobjectName)) {
animationIsValid(state, getters) {
let sceneBeforeAnimation = getters.sceneBeforeAnimation;
for (let mobjectName of (state.animationDiff['add'] || [])) {
if (sceneBeforeAnimation.includes(mobjectName)) {
return false;
}
}
for (let mobjectName of (state.sceneDiff['remove'] || [])) {
if (!priorScene.includes(mobjectName)) {
for (let mobjectName of (state.animationDiff['remove'] || [])) {
if (!sceneBeforeAnimation.includes(mobjectName)) {
return false;
}
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -4707,6 +4707,11 @@ jsesc@~0.5.0:
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=

json-formatter-js@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/json-formatter-js/-/json-formatter-js-2.2.1.tgz#b101d628e86f028dc9cf9a7e1c83c65e536c9f87"
integrity sha1-sQHWKOhvAo3Jz5p+HIPGXlNsn4c=

json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
Expand Down

0 comments on commit fd5d435

Please sign in to comment.