diff --git a/src/git.js b/src/git.js index 5cfd3c17..3bec7224 100644 --- a/src/git.js +++ b/src/git.js @@ -92,8 +92,9 @@ GitEngine.prototype.printAndCopyTree = function() { GitEngine.prototype.loadTree = function(tree) { // first clear everything + // debugger this.removeAll(); - + this.instantiateFromTree(tree); this.reloadGraphics(); @@ -111,10 +112,12 @@ GitEngine.prototype.instantiateFromTree = function(tree) { this.commitCollection.add(commit); }, this); + gitVisuals.paperReady = false; _.each(tree.branches, function(branchJSON) { var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id); this.branchCollection.add(branch); }, this); + gitVisuals.paperReady = true; var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id); this.HEAD = HEAD; @@ -122,11 +125,14 @@ GitEngine.prototype.instantiateFromTree = function(tree) { GitEngine.prototype.reloadGraphics = function() { var rootCommit = null; + this.commitCollection.each(function(commit) { + console.log('finding commit from collection', commit.get('id')); if (commit.get('id') == 'C0') { rootCommit = commit; } }); + gitVisuals.rootCommit = rootCommit; // this just basically makes the HEAD branch. the head branch really should have been @@ -135,9 +141,9 @@ GitEngine.prototype.reloadGraphics = function() { gitVisuals.whenGitEngineReady(this); // when the paper is ready - gitVisuals.drawTreeFirstTime(); + gitVisuals.drawTreeFromReload(); - console.log('refreshing hars'); + console.log('refreshing harsh'); gitVisuals.refreshTreeHarsh(); }; @@ -209,10 +215,10 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) { }; GitEngine.prototype.removeAll = function() { - gitVisuals.resetAll(); - this.branchCollection.reset(); this.commitCollection.reset(); + + gitVisuals.resetAll(); }; GitEngine.prototype.getDetachedHead = function() { diff --git a/src/tree.js b/src/tree.js index 710696a1..6a49db23 100644 --- a/src/tree.js +++ b/src/tree.js @@ -123,10 +123,14 @@ var VisBranch = VisBase.extend({ }, getRectPosition: function() { + console.log('before text pos'); var pos = this.getTextPosition(); + console.log('wut'); var f = this.get('flip'); // first get text width and height + console.log('before text size'); var textSize = this.getTextSize(); + console.log('text size'); return { x: pos.x - 0.5 * textSize.w - this.get('hPad'), y: pos.y - 0.5 * textSize.h - this.get('vPad') @@ -274,10 +278,13 @@ var VisBranch = VisBase.extend({ }, genGraphics: function(paper) { - var textPos = this.getTextPosition(); + var textPos = this.getTextPosition(); var name = this.getName(); - var text = paper.text(textPos.x, textPos.y, String(name)); + var text; + + // when from a reload, we dont need to generate the text + text = paper.text(textPos.x, textPos.y, String(name)); text.attr({ 'font-size': 14, 'font-family': 'Monaco, Courier, font-monospace', diff --git a/src/visuals.js b/src/visuals.js index 63ce2703..a9291bee 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -369,6 +369,7 @@ GitVisuals.prototype.addBranch = function(branch) { this.visBranchCollection.add(visBranch); if (this.paperReady) { + console.log('PAPEPR IS READY'); visBranch.genGraphics(paper); } }; @@ -494,19 +495,33 @@ GitVisuals.prototype.visBranchesFront = function() { }); }; +GitVisuals.prototype.drawTreeFromReload = function() { + this.paperReady = true; + this.calcTreeCoords(); + + this.visBranchCollection.each(function(visBranch) { + visBranch.genGraphics(paper, { + fromReload: true + }); + }, this); +}; + GitVisuals.prototype.drawTreeFirstTime = function() { this.paperReady = true; this.calcTreeCoords(); _.each(this.visNodeMap, function(visNode) { + console.log('visnode map is doing', visNode); visNode.genGraphics(paper); }, this); this.visEdgeCollection.each(function(edge) { + console.log('vis edge collection', edge); edge.genGraphics(paper); }, this); this.visBranchCollection.each(function(visBranch) { + console.log('vis rabnch', visBranch); visBranch.genGraphics(paper); }, this);