working on tree reload bugs

This commit is contained in:
Peter Cottle 2012-10-13 15:44:36 -07:00
parent 3bc67d66d3
commit ec5c40141c
3 changed files with 44 additions and 12 deletions

View file

@ -86,6 +86,12 @@ GitEngine.prototype.loadTree = function(tree) {
// first clear everything
this.removeAll();
this.instantiateFromTree(tree);
this.reloadGraphics();
};
GitEngine.prototype.instantiateFromTree = function(tree) {
// now we do the loading part
var createdSoFar = {};
_.each(tree.commits, function(commitJSON) {
@ -100,7 +106,18 @@ GitEngine.prototype.loadTree = function(tree) {
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
this.HEAD = HEAD;
};
GitEngine.prototype.reloadGraphics = function() {
// this just basically makes the HEAD branch. the head branch really should have been
// a member of a collection and not this annoying edge case stuff...
console.log('calling when git engine ready');
gitVisuals.whenGitEngineReady(this);
// when the paper is ready
gitVisuals.drawTreeFirstTime();
console.log('refreshing hars');
gitVisuals.refreshTreeHarsh();
};
@ -172,12 +189,7 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
};
GitEngine.prototype.removeAll = function() {
this.branchCollection.each(function(branch) {
branch.get('visBranch').remove();
}, this);
this.commitCollection.each(function(commit) {
commit.get('visNode').removeAll();
}, this);
gitVisuals.resetAll();
this.branchCollection.reset();
this.commitCollection.reset();

View file

@ -439,6 +439,7 @@ var VisNode = VisBase.extend({
setDepthBasedOn: function(depthIncrement) {
if (this.get('depth') === undefined) {
debugger
throw new Error('no depth yet!');
}
var pos = this.get('pos');

View file

@ -33,11 +33,33 @@ function GitVisuals(options) {
events.on('gitEngineReady', this.whenGitEngineReady, this);
}
GitVisuals.prototype.resetAll = function() {
this.visEdgeCollection.each(function(visEdge) {
visEdge.remove();
}, this);
this.visBranchCollection.each(function(visBranch) {
visBranch.remove();
}, this);
_.each(this.visNodeMap, function(visNode) {
visNode.remove();
}, this);
this.visEdgeCollection.reset();
this.visBranchCollection.reset();
this.visNodeMap = {};
this.rootCommit = null;
this.commitMap = {};
};
GitVisuals.prototype.whenGitEngineReady = function(gitEngine) {
// seed this with the HEAD pseudo-branch
this.visBranchCollection.add(new VisBranch({
var headBranch = new VisBranch({
branch: gitEngine.HEAD
}));
});
this.visBranchCollection.add(headBranch);
};
GitVisuals.prototype.getScreenBounds = function() {
@ -304,10 +326,7 @@ GitVisuals.prototype.calcDepth = function() {
var maxDepth = this.calcDepthRecursive(this.rootCommit, 0);
if (maxDepth > 15) {
// issue warning
events.trigger('issueWarning',
'Max Depth Exceeded! Visuals may degrade here. ' +
'Please start fresh'
);
// TODO
}
var depthIncrement = this.getDepthIncrement(maxDepth);