client/js/renderer/scene.js
changeset 554 32c7378d1c28
parent 547 0ce3dcdf24f7
child 555 49daeea94e88
equal deleted inserted replaced
553:d05ee3bcceab 554:32c7378d1c28
   337             }
   337             }
   338             _this.redrawActive = true;
   338             _this.redrawActive = true;
   339             _thRedraw();
   339             _thRedraw();
   340         });
   340         });
   341         
   341         
       
   342       //register router events
       
   343         this.renkan.router.on("router", function(_params){
       
   344             _this.setViewparameters(_params);
       
   345         });
       
   346         
   342         this.renkan.project.on("change:loadingStatus", function(){
   347         this.renkan.project.on("change:loadingStatus", function(){
   343             if (_this.renkan.project.get("loadingStatus")){
   348             if (_this.renkan.project.get("loadingStatus")){
   344                 var animate = _this.$.find(".loader").addClass("run");
   349                 var animate = _this.$.find(".loader").addClass("run");
   345                 var timer = setTimeout(function(){
   350                 var timer = setTimeout(function(){
   346                     _this.$.find(".loader").hide(250);
   351                     _this.$.find(".loader").hide(250);
   378                     el.val(_title);
   383                     el.val(_title);
   379                 }
   384                 }
   380             } else {
   385             } else {
   381                 el.text(_title);
   386                 el.text(_title);
   382             }
   387             }
   383         });
       
   384 
       
   385         //register router events
       
   386         this.renkan.router.on("router", function(_params){
       
   387             _this.setViewparameters(_params);
       
   388         });
   388         });
   389 
   389 
   390         if (_renkan.options.size_bug_fix) {
   390         if (_renkan.options.size_bug_fix) {
   391             var _delay = (
   391             var _delay = (
   392                     typeof _renkan.options.size_bug_fix === "number" ?
   392                     typeof _renkan.options.size_bug_fix === "number" ?
   492     };
   492     };
   493 
   493 
   494     _(Scene.prototype).extend({
   494     _(Scene.prototype).extend({
   495         fixSize: function() {
   495         fixSize: function() {
   496             if(typeof this.view === 'undefined') {
   496             if(typeof this.view === 'undefined') {
   497                 this.view = this.addRepresentation("View", this.renkan.project.get("views").first());
   497                 this.view = this.addRepresentation("View", this.renkan.project.get("views").last());
   498             }
   498             }
   499             this.view.autoScale();
   499             this.view.autoScale();
   500         },
   500         },
   501         drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
   501         drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
   502             var _options = this.renkan.options,
   502             var _options = this.renkan.options,
  1205         },
  1205         },
  1206         setViewparameters: function(_params){
  1206         setViewparameters: function(_params){
  1207             this.removeRepresentationsOfType("View");
  1207             this.removeRepresentationsOfType("View");
  1208             if ($.isEmptyObject(_params)){
  1208             if ($.isEmptyObject(_params)){
  1209                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
  1209                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
  1210                 if (!this.renkan.options.default_view){
       
  1211                     this.view.autoScale();
       
  1212                 }
       
  1213                 return;
  1210                 return;
  1214             }
  1211             }
  1215             if (typeof _params.viewIndex !== 'undefined'){
  1212             if (typeof _params.viewIndex !== 'undefined'){
  1216                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(_params.viewIndex)));
  1213                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(_params.viewIndex)));
  1217                 if (!this.renkan.options.default_view){
  1214             } else {
  1218                     this.view.autoScale();
  1215                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
  1219                 }
       
  1220             }
  1216             }
  1221             if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){
  1217             if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){
  1222                 var viewParams = _params.view.split(",");
  1218                 var viewParams = _params.view.split(",");
  1223                 var params = {
  1219                 var params = {
  1224                         "project": this.renkan.project,
  1220                         "project": this.renkan.project,
  1226                             "x": parseFloat(viewParams[0]),
  1222                             "x": parseFloat(viewParams[0]),
  1227                             "y": parseFloat(viewParams[1])
  1223                             "y": parseFloat(viewParams[1])
  1228                         },
  1224                         },
  1229                         "zoom_level": parseFloat(viewParams[2])
  1225                         "zoom_level": parseFloat(viewParams[2])
  1230                 };
  1226                 };
  1231                 if (this.view){
  1227                 this.view.setScale(params.zoom_level, new paper.Point(params.offset));
  1232                     this.view.setScale(params.zoom_level, new paper.Point(params.offset));
  1228             }
  1233                 } else{
  1229             //if view parameters = autoscale or views_parameters options is false, we apply a zoom fit on the view.
  1234                     this.view = this.addRepresentation("View", null);
  1230             if ((typeof _params.view !== 'undefined' && _params.view === "autoscale")){
  1235                     this.view.params = params;
       
  1236                     this.view.initWithParams();
       
  1237                 }
       
  1238             }
       
  1239             if (!this.view){
       
  1240                 this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view)));
       
  1241                 this.view.autoScale();
  1231                 this.view.autoScale();
       
  1232             }
       
  1233             //if viewsNodes = false or views_nodes options is false, we show all the node by default.
       
  1234             if (typeof _params.viewsNodes !== 'undefined'){
       
  1235                 if (_params.viewsNodes === "true"){
       
  1236                     this.view.hiddenNodes = (this.view.params.hidden_nodes || []).concat();
       
  1237                     this.view.hideNodes();
       
  1238                 } else {
       
  1239                     this.view.showNodes(false);
       
  1240                 }
  1242             }
  1241             }
  1243             //other parameters must go after because most of them depends on a view that must be initialize before
  1242             //other parameters must go after because most of them depends on a view that must be initialize before
  1244             this.unhighlightAll();
  1243             this.unhighlightAll();
  1245             if (typeof _params.idNode !== 'undefined'){
  1244             if (typeof _params.idNode !== 'undefined'){
  1246                 this.highlightModel(this.renkan.project.get("nodes").get(_params.idNode));
  1245                 this.highlightModel(this.renkan.project.get("nodes").get(_params.idNode));