client/js/renderer/scene.js
changeset 524 904effa4b6d7
parent 520 f14ff8669037
child 525 03aa989092bb
equal deleted inserted replaced
523:dc04aa440c11 524:904effa4b6d7
  1199           var blob = new Blob([projectJSONStr], {type: "application/json;charset=utf-8"});
  1199           var blob = new Blob([projectJSONStr], {type: "application/json;charset=utf-8"});
  1200           filesaver(blob,fileNameToSaveAs);
  1200           filesaver(blob,fileNameToSaveAs);
  1201 
  1201 
  1202         },
  1202         },
  1203         parameters: function(_params){
  1203         parameters: function(_params){
       
  1204             this.removeRepresentationsOfType("View");
  1204             if ($.isEmptyObject(_params)){
  1205             if ($.isEmptyObject(_params)){
  1205                 this.view = this.addRepresentation("View", this.renkan.project.get("views").first());
  1206                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
  1206                 this.view.autoScale();
  1207                 if (!this.renkan.options.default_view){
       
  1208                     this.view.autoScale();
       
  1209                 }
  1207                 return;
  1210                 return;
  1208             }
  1211             }
  1209             if (typeof _params.idView !== 'undefined' && typeof this.renkan.project.get("views").at(_params.idView) !== 'undefined'){
  1212             if (typeof _params.idView !== 'undefined'){
  1210                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(_params.idView));
  1213                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(_params.idView)));
       
  1214                 if (!this.renkan.options.default_view){
       
  1215                     this.view.autoScale();
       
  1216                 }
  1211             }
  1217             }
  1212             if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){
  1218             if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){
  1213                 var viewParams = _params.view.split(",");
  1219                 var viewParams = _params.view.split(",");
  1214                 var params = {
  1220                 var params = {
  1215                         "project": this.renkan.project,
  1221                         "project": this.renkan.project,
  1225                     this.view = this.addRepresentation("View", null);
  1231                     this.view = this.addRepresentation("View", null);
  1226                     this.view.params = params;
  1232                     this.view.params = params;
  1227                     this.view.init();                    
  1233                     this.view.init();                    
  1228                 }
  1234                 }
  1229             }
  1235             }
  1230             if(!this.view){
  1236             if (!this.view){
  1231                 this.view = this.addRepresentation("View", this.renkan.project.get("views").first());
  1237                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
  1232                 this.view.autoScale();
  1238                 this.view.autoScale();
  1233             }
  1239             }
  1234             //other parameters must go after because most of them depends on a view that must be initialize before
  1240             //other parameters must go after because most of them depends on a view that must be initialize before
  1235             this.unhighlightAll();
  1241             this.unhighlightAll();
  1236             if (typeof _params.idNode !== 'undefined'){
  1242             if (typeof _params.idNode !== 'undefined'){
  1237                 this.highlightModel(this.renkan.project.get("nodes").get(_params.idNode));                 
  1243                 this.highlightModel(this.renkan.project.get("nodes").get(_params.idNode));                 
  1238             }
  1244             }
       
  1245         },
       
  1246         validViewIndex: function(index){
       
  1247             //check if the view index exist (negative index is from the end) and return the correct index or false if doesn't exist
       
  1248             var _index = parseInt(index);
       
  1249             var validIndex = 0;
       
  1250             if (_index < 0){
       
  1251                 validIndex = this.renkan.project.get("views").length + _index;
       
  1252             } else {
       
  1253                 validIndex = _index; 
       
  1254             }
       
  1255             if (typeof this.renkan.project.get("views").at(_index) === 'undefined'){
       
  1256                 validIndex = 0;
       
  1257             }
       
  1258             return validIndex;
  1239         },
  1259         },
  1240         foldBins: function() {
  1260         foldBins: function() {
  1241             var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
  1261             var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
  1242                 bins = this.renkan.$.find(".Rk-Bins");
  1262                 bins = this.renkan.$.find(".Rk-Bins");
  1243             var _this = this,
  1263             var _this = this,