diff -r aae670254c49 -r 88e8673aaeeb client/js/renderer/scene.js --- a/client/js/renderer/scene.js Wed May 20 10:36:37 2015 +0200 +++ b/client/js/renderer/scene.js Wed May 20 10:39:35 2015 +0200 @@ -25,6 +25,7 @@ this.initialScale = 1; this.offset = paper.view.center; this.totalScroll = 0; + this.hiddenNodes = []; this.mouse_down = false; this.click_target = null; this.selected_target = null; @@ -82,7 +83,7 @@ this.image_cache = {}; this.icon_cache = {}; - ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) { + ['edit', 'remove', 'hide', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) { var img = new Image(); img.src = _renkan.options.static_url + 'img/' + imgname + '.png'; _this.icon_cache[imgname] = img; @@ -238,14 +239,26 @@ bindClick(".Rk-ZoomFit", "autoScale"); this.$.find(".Rk-ZoomSave").click( function() { // Save scale and offset point - _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } ); + _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset, hidden_nodes: _this.hiddenNodes } ); }); this.$.find(".Rk-ZoomSetSaved").click( function() { var view = _this.renkan.project.get("views").last(); if(view){ _this.setScale(view.get("zoom_level"), new paper.Point(view.get("offset"))); + _this.hiddenNodes = view.get("hidden_nodes"); + _this.hideNodes(); } }); + this.$.find(".Rk-ShowHiddenNodes").mouseenter( function() { + _this.showNodes(true); + _this.$.find(".Rk-ShowHiddenNodes").mouseleave( function() { + _this.hideNodes(false); + }); + }); + this.$.find(".Rk-ShowHiddenNodes").click( function() { + _this.showNodes(false); + _this.$.find(".Rk-ShowHiddenNodes").off( "mouseleave" ); + }); if(this.renkan.project.get("views").length > 0 && this.renkan.options.save_view){ this.$.find(".Rk-ZoomSetSaved").show(); } @@ -729,7 +742,7 @@ addRepresentations: function(_type, _collection) { var _this = this; _collection.forEach(function(_model) { - _this.addRepresentation(_type, _model); + //_this.addRepresentation(_type, _model); }); }, userTemplate: _.template( @@ -833,6 +846,7 @@ }); }, redraw: function() { + var _this = this; if(! this.redrawActive ) { return; } @@ -851,6 +865,38 @@ _tmpEdge.redraw(); this.click_target = _tmpEdge; }, + addHiddenNode: function(_model){ + this.hideNode(_model); + this.hiddenNodes.push(_model.id); + }, + hideNode: function(_model){ + var _this = this; + if (typeof _this.getRepresentationByModel(_model) !== 'undefined'){ + _this.getRepresentationByModel(_model).hide(); + } + }, + hideNodes: function(){ + var _this = this; + this.hiddenNodes.forEach(function(_id, index){ + var node = _this.renkan.project.get("nodes").get(_id); + if (typeof node !== 'undefined'){ + return _this.hideNode(_this.renkan.project.get("nodes").get(_id)); + }else{ + _this.hiddenNodes.splice(index, 1); + } + }); + paper.view.draw(); + }, + showNodes: function(ghost){ + var _this = this; + this.hiddenNodes.forEach(function(_id){ + _this.getRepresentationByModel(_this.renkan.project.get("nodes").get(_id)).show(ghost); + }); + if (!ghost){ + this.hiddenNodes = []; + } + paper.view.draw(); + }, findTarget: function(_hitResult) { if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { var _newTarget = _hitResult.item.__representation;