--- a/client/js/renderer/scene.js Tue Sep 15 17:09:42 2015 +0200
+++ b/client/js/renderer/scene.js Wed Sep 16 17:36:46 2015 +0200
@@ -1201,13 +1201,19 @@
},
parameters: function(_params){
+ this.removeRepresentationsOfType("View");
if ($.isEmptyObject(_params)){
- this.view = this.addRepresentation("View", this.renkan.project.get("views").first());
- this.view.autoScale();
+ this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
+ if (!this.renkan.options.default_view){
+ this.view.autoScale();
+ }
return;
}
- if (typeof _params.idView !== 'undefined' && typeof this.renkan.project.get("views").at(_params.idView) !== 'undefined'){
- this.view = this.addRepresentation("View", this.renkan.project.get("views").at(_params.idView));
+ if (typeof _params.idView !== 'undefined'){
+ this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(_params.idView)));
+ if (!this.renkan.options.default_view){
+ this.view.autoScale();
+ }
}
if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){
var viewParams = _params.view.split(",");
@@ -1227,8 +1233,8 @@
this.view.init();
}
}
- if(!this.view){
- this.view = this.addRepresentation("View", this.renkan.project.get("views").first());
+ if (!this.view){
+ this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
this.view.autoScale();
}
//other parameters must go after because most of them depends on a view that must be initialize before
@@ -1237,6 +1243,20 @@
this.highlightModel(this.renkan.project.get("nodes").get(_params.idNode));
}
},
+ validViewIndex: function(index){
+ //check if the view index exist (negative index is from the end) and return the correct index or false if doesn't exist
+ var _index = parseInt(index);
+ var validIndex = 0;
+ if (_index < 0){
+ validIndex = this.renkan.project.get("views").length + _index;
+ } else {
+ validIndex = _index;
+ }
+ if (typeof this.renkan.project.get("views").at(_index) === 'undefined'){
+ validIndex = 0;
+ }
+ return validIndex;
+ },
foldBins: function() {
var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
bins = this.renkan.$.find(".Rk-Bins");