From 3b781edbda7d678df2cc102438f643844d0a27ee Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sat, 9 Aug 2014 23:52:22 -0400 Subject: [PATCH 1/8] Update Ubuntu README.rdoc --- Ubuntu README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ubuntu README.rdoc b/Ubuntu README.rdoc index b468eb4c..e6209f99 100644 --- a/Ubuntu README.rdoc +++ b/Ubuntu README.rdoc @@ -40,7 +40,7 @@ running this will check your system for requirements as well so you will need to alright now we can download metamaps from the master using git -"git clone https://github.com/Connoropolous/metamaps_gen002.git" +"git clone https://github.com/Connoropolous/metamaps_gen002.git[https://github.com/Connoropolous/metamaps_gen002.git]" now there is a couple other things we are going to need which is nodejs, postgresql, libpq-dev and redis-server From bef531fb0706809549cc514b39cd7370c74b8993 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sat, 9 Aug 2014 23:53:13 -0400 Subject: [PATCH 2/8] Update Ubuntu README.rdoc --- Ubuntu README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ubuntu README.rdoc b/Ubuntu README.rdoc index e6209f99..983a7169 100644 --- a/Ubuntu README.rdoc +++ b/Ubuntu README.rdoc @@ -40,7 +40,7 @@ running this will check your system for requirements as well so you will need to alright now we can download metamaps from the master using git -"git clone https://github.com/Connoropolous/metamaps_gen002.git[https://github.com/Connoropolous/metamaps_gen002.git]" +"git clone {https://github.com/Connoropolous/metamaps_gen002.git}[https://github.com/Connoropolous/metamaps_gen002.git]" now there is a couple other things we are going to need which is nodejs, postgresql, libpq-dev and redis-server From 2d70c1b0a6b3800822e22ffc3a1ca65a0a4bb089 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sat, 9 Aug 2014 23:53:55 -0400 Subject: [PATCH 3/8] Update and rename Ubuntu README.rdoc to Ubuntu README.md --- Ubuntu README.rdoc => Ubuntu README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Ubuntu README.rdoc => Ubuntu README.md (95%) diff --git a/Ubuntu README.rdoc b/Ubuntu README.md similarity index 95% rename from Ubuntu README.rdoc rename to Ubuntu README.md index 983a7169..b468eb4c 100644 --- a/Ubuntu README.rdoc +++ b/Ubuntu README.md @@ -40,7 +40,7 @@ running this will check your system for requirements as well so you will need to alright now we can download metamaps from the master using git -"git clone {https://github.com/Connoropolous/metamaps_gen002.git}[https://github.com/Connoropolous/metamaps_gen002.git]" +"git clone https://github.com/Connoropolous/metamaps_gen002.git" now there is a couple other things we are going to need which is nodejs, postgresql, libpq-dev and redis-server From b896770db8682d425643a502861fc2caade2778f Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 10 Aug 2014 00:01:09 -0400 Subject: [PATCH 4/8] Update Ubuntu README.md --- Ubuntu README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ubuntu README.md b/Ubuntu README.md index b468eb4c..8596b0a4 100644 --- a/Ubuntu README.md +++ b/Ubuntu README.md @@ -56,7 +56,7 @@ Install the specific version of ruby needed this will take some time *Note you w "rvm install ruby-1.9.3-p125" -Now we also need to rename your database file which is in ./config/database.default.yml to database.yml +Now we also need to rename your database file which is in ./config/database.yml.default to database.yml now run inside your metamaps_gen002 folder From 01b93fa6f47213e99f65be150b725dc6d3988835 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 10 Aug 2014 00:08:32 -0400 Subject: [PATCH 5/8] Update Ubuntu README.md --- Ubuntu README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ubuntu README.md b/Ubuntu README.md index 8596b0a4..beefc79f 100644 --- a/Ubuntu README.md +++ b/Ubuntu README.md @@ -70,13 +70,13 @@ alright now we need to make sure your postgres password is the same as it is lis Select postgres like this -"\password postgres" +"\password postgres;" set the password to 3112 Then to quit -"\q" +"\q;" now we can run the rake install and db creation From b15da256fa70fcd98a49d04d0d1a8313ec1a8afb Mon Sep 17 00:00:00 2001 From: Robert Best Date: Sat, 16 Aug 2014 12:46:06 -0400 Subject: [PATCH 6/8] Included title box size in zoom to extents and put a limits on the zooming --- Gemfile.lock | 49 ---- .../javascripts/metamaps/Metamaps.JIT.js | 183 ++++++------ db/schema.rb | 266 +++++++++--------- 3 files changed, 216 insertions(+), 282 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a8354dc6..b4efab8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,8 +39,6 @@ GEM rails (~> 3.1) builder (3.0.4) cancan (1.6.10) - childprocess (0.5.3) - ffi (~> 1.0, >= 1.0.11) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.4) @@ -52,7 +50,6 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) - commonwatir (4.0.0) devise (3.2.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -61,8 +58,6 @@ GEM warden (~> 1.2.3) erubis (2.7.0) execjs (2.0.2) - ffi (1.9.0) - ffi (1.9.0-x86-mingw32) formtastic (2.2.1) actionpack (>= 3.0) formula (1.0.1) @@ -80,8 +75,6 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) - mini_magick (3.5.0) - subexec (~> 0.2.1) mini_portile (0.6.0) multi_json (1.10.0) nokogiri (1.6.2.1) @@ -96,7 +89,6 @@ GEM mime-types pg (0.17.1) pg (0.17.1-x86-mingw32) - phantomjs (1.9.7.1) polyglot (0.3.4) rack (1.4.5) rack-cache (1.2) @@ -123,28 +115,19 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.3.2) - rautomation (0.15.0) - ffi (= 1.9.0) rdoc (3.12.2) json (~> 1.4) redis (2.2.2) - rubyzip (1.1.6) sass (3.3.7) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - selenium-webdriver (2.42.0) - childprocess (>= 0.5.0) - multi_json (~> 1.0) - rubyzip (~> 1.0) - websocket (~> 1.0.4) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - subexec (0.2.3) thor (0.19.1) thread_safe (0.3.3) tilt (1.4.1) @@ -157,36 +140,6 @@ GEM json (>= 1.8.0) warden (1.2.3) rack (>= 1.0) - watir (5.0.0) - commonwatir (~> 4) - watir-webdriver - watir (5.0.0-x86-mingw32) - commonwatir (~> 4) - watir-classic (~> 4.0) - watir-webdriver - watir-classic (4.0.1) - ffi (~> 1.0) - multi_json - nokogiri (>= 1.5.7.rc3) - rautomation (~> 0.7) - win32-process (>= 0.5.5) - win32screenshot (~> 1.0.9) - windows-pr (>= 0.6.6) - watir-webdriver (0.6.10) - selenium-webdriver (>= 2.18.0) - websocket (1.0.7) - win32-api (1.5.1-x86-mingw32) - win32-process (0.7.4) - ffi (>= 1.0.0) - win32screenshot (1.0.10) - ffi (~> 1.0) - mini_magick (~> 3.5.0) - rautomation (~> 0.7) - windows-api (0.4.2) - win32-api (>= 1.4.5) - windows-pr (1.2.3) - win32-api (>= 1.4.5) - windows-api (>= 0.4.0) PLATFORMS ruby @@ -205,10 +158,8 @@ DEPENDENCIES json paperclip pg - phantomjs rails (= 3.2.17) rails3-jquery-autocomplete redis (= 2.2.2) sass-rails uglifier (>= 1.0.3) - watir diff --git a/app/assets/javascripts/metamaps/Metamaps.JIT.js b/app/assets/javascripts/metamaps/Metamaps.JIT.js index 7a8c8362..c0250038 100644 --- a/app/assets/javascripts/metamaps/Metamaps.JIT.js +++ b/app/assets/javascripts/metamaps/Metamaps.JIT.js @@ -1461,119 +1461,102 @@ Metamaps.JIT = { if (Metamaps.Selected.Nodes.length > 0) { var nodes = Metamaps.Selected.Nodes; + } + else { + var nodes = _.values(Metamaps.Visualize.mGraph.graph.nodes); + } - if(nodes.length > 1){ - nodes.forEach(function (n) { - var x = n.pos.x, - y = n.pos.y; + if(nodes.length > 1){ + nodes.forEach(function (n) { + var x = n.pos.x, + y = n.pos.y; - if (counter == 0){ - maxX = x; - minX = x; - maxY = y; - minY = y; - } + if (counter == 0){ + maxX = x; + minX = x; + maxY = y; + minY = y; + } - maxX = Math.max(x,maxX); - maxY = Math.max(y,maxY); - minX = Math.min(x,minX); - minY = Math.min(y,minY); + var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'), + dim = n.getData('dim'), + ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); - counter++; - }); + console.log(dim); - var spanX = maxX - minX; - var spanY = maxY - minY; - var ratioX = spanX / width; - var ratioY = spanY / height; + var height = 25 * arrayOfLabelLines.length; - var newRatio = Math.max(ratioX,ratioY); + var index, lineWidths = []; + for (index = 0; index < arrayOfLabelLines.length; ++index) { + lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width) + } + var width = Math.max.apply(null, lineWidths) + 8; - var canvas = Metamaps.Visualize.mGraph.canvas; + maxX = Math.max(x + width /2,maxX); + maxY = Math.max(y + n.getData("height") + 5 + height,maxY); + minX = Math.min(x - width /2,minX); + minY = Math.min(y - dim,minY); - canvas.scale(1/newRatio*0.8,1/newRatio*0.8); + counter++; + }); - counter = 0; + var spanX = maxX - minX; + var spanY = maxY - minY; + var ratioX = spanX / width; + var ratioY = spanY / height; - nodes.forEach(function (n) { - var x = n.pos.x, - y = n.pos.y; + var newRatio = Math.max(ratioX,ratioY); + var scaleMultiplier = 1/newRatio*0.9; - if (counter == 0){ - maxX = x; - minX = x; - maxY = y; - minY = y; - } - - maxX = Math.max(x,maxX); - maxY = Math.max(y,maxY); - minX = Math.min(x,minX); - minY = Math.min(y,minY); - - counter++; - }); + var canvas = Metamaps.Visualize.mGraph.canvas; + if(canvas.scaleOffsetX *scaleMultiplier<= 3 && canvas.scaleOffsetX*scaleMultiplier >= 0.2){ + canvas.scale(scaleMultiplier,scaleMultiplier); } + else if(canvas.scaleOffsetX * scaleMultiplier > 3){ + scaleMultiplier = 3/ canvas.scaleOffsetX; + canvas.scale(scaleMultiplier,scaleMultiplier); + } + else{ + scaleMultiplier = 0.2/ canvas.scaleOffsetX; + canvas.scale(scaleMultiplier,scaleMultiplier); + } + + + counter = 0; + + nodes.forEach(function (n) { + var x = n.pos.x, + y = n.pos.y; + + if (counter == 0){ + maxX = x; + minX = x; + maxY = y; + minY = y; + } + + var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'), + dim = n.getData('dim'), + ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); + + console.log(dim); + + var height = 25 * arrayOfLabelLines.length; + + var index, lineWidths = []; + for (index = 0; index < arrayOfLabelLines.length; ++index) { + lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width) + } + var width = Math.max.apply(null, lineWidths) + 8; + + maxX = Math.max(x + width /2,maxX); + maxY = Math.max(y + n.getData("height") + 5 + height,maxY); + minX = Math.min(x - width /2,minX); + minY = Math.min(y - dim,minY); + + counter++; + }); } - else{ - var nodes = Metamaps.Visualize.mGraph.graph; - - if(Object.keys(nodes).length >1){ - nodes.eachNode(function (n) { - var x = n.pos.x, - y = n.pos.y; - - if (counter == 0){ - maxX = x; - minX = x; - maxY = y; - minY = y; - } - - maxX = Math.max(x,maxX); - maxY = Math.max(y,maxY); - minX = Math.min(x,minX); - minY = Math.min(y,minY); - - counter++; - }); - - var spanX = maxX - minX; - var spanY = maxY - minY; - var ratioX = spanX / width; - var ratioY = spanY / height; - - var newRatio = Math.max(ratioX,ratioY); - - var canvas = Metamaps.Visualize.mGraph.canvas; - - canvas.scale(1/newRatio*0.8,1/newRatio*0.8); - - counter = 0; - - nodes.eachNode(function (n) { - var x = n.pos.x, - y = n.pos.y; - - if (counter == 0){ - maxX = x; - minX = x; - maxY = y; - minY = y; - } - - maxX = Math.max(x,maxX); - maxY = Math.max(y,maxY); - minX = Math.min(x,minX); - minY = Math.min(y,minY); - - counter++; - }); - } - } - - - var cogX = (maxX + minX)/2; var cogY = (maxY + minY)/2; diff --git a/db/schema.rb b/db/schema.rb index 4c22e7e5..50334775 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,133 +1,133 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20140815162253) do - - create_table "in_metacode_sets", :force => true do |t| - t.integer "metacode_id" - t.integer "metacode_set_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id" - add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id" - - create_table "mappings", :force => true do |t| - t.text "category" - t.integer "xloc" - t.integer "yloc" - t.integer "topic_id" - t.integer "synapse_id" - t.integer "map_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "maps", :force => true do |t| - t.text "name" - t.boolean "arranged" - t.text "desc" - t.text "permission" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "featured" - t.string "screenshot_file_name" - t.string "screenshot_content_type" - t.integer "screenshot_file_size" - t.datetime "screenshot_updated_at" - end - - create_table "metacode_sets", :force => true do |t| - t.string "name" - t.text "desc" - t.integer "user_id" - t.boolean "mapperContributed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id" - - create_table "metacodes", :force => true do |t| - t.text "name" - t.string "icon" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "synapses", :force => true do |t| - t.text "desc" - t.text "category" - t.text "weight" - t.text "permission" - t.integer "node1_id" - t.integer "node2_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "topics", :force => true do |t| - t.text "name" - t.text "desc" - t.text "link" - t.text "permission" - t.integer "user_id" - t.integer "metacode_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "image_file_name" - t.string "image_content_type" - t.integer "image_file_size" - t.datetime "image_updated_at" - t.string "audio_file_name" - t.string "audio_content_type" - t.integer "audio_file_size" - t.datetime "audio_updated_at" - end - - create_table "users", :force => true do |t| - t.string "name" - t.string "email" - t.text "settings" - t.string "code", :limit => 8 - t.string "joinedwithcode", :limit => 8 - t.string "crypted_password" - t.string "password_salt" - t.string "persistence_token" - t.string "perishable_token" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "encrypted_password", :limit => 128, :default => "" - t.string "remember_token" - t.datetime "remember_created_at" - t.string "reset_password_token" - t.datetime "last_sign_in_at" - t.string "last_sign_in_ip" - t.integer "sign_in_count", :default => 0 - t.datetime "current_sign_in_at" - t.string "current_sign_in_ip" - t.datetime "reset_password_sent_at" - t.boolean "admin" - t.string "image_file_name" - t.string "image_content_type" - t.integer "image_file_size" - t.datetime "image_updated_at" - end - - add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true - -end +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20140815162253) do + + create_table "in_metacode_sets", :force => true do |t| + t.integer "metacode_id" + t.integer "metacode_set_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id" + add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id" + + create_table "mappings", :force => true do |t| + t.text "category" + t.integer "xloc" + t.integer "yloc" + t.integer "topic_id" + t.integer "synapse_id" + t.integer "map_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "maps", :force => true do |t| + t.text "name" + t.boolean "arranged" + t.text "desc" + t.text "permission" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "featured" + t.string "screenshot_file_name" + t.string "screenshot_content_type" + t.integer "screenshot_file_size" + t.datetime "screenshot_updated_at" + end + + create_table "metacode_sets", :force => true do |t| + t.string "name" + t.text "desc" + t.integer "user_id" + t.boolean "mapperContributed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id" + + create_table "metacodes", :force => true do |t| + t.text "name" + t.string "icon" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "synapses", :force => true do |t| + t.text "desc" + t.text "category" + t.text "weight" + t.text "permission" + t.integer "node1_id" + t.integer "node2_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "topics", :force => true do |t| + t.text "name" + t.text "desc" + t.text "link" + t.text "permission" + t.integer "user_id" + t.integer "metacode_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "image_file_name" + t.string "image_content_type" + t.integer "image_file_size" + t.datetime "image_updated_at" + t.string "audio_file_name" + t.string "audio_content_type" + t.integer "audio_file_size" + t.datetime "audio_updated_at" + end + + create_table "users", :force => true do |t| + t.string "name" + t.string "email" + t.text "settings" + t.string "code", :limit => 8 + t.string "joinedwithcode", :limit => 8 + t.string "crypted_password" + t.string "password_salt" + t.string "persistence_token" + t.string "perishable_token" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "encrypted_password", :limit => 128, :default => "" + t.string "remember_token" + t.datetime "remember_created_at" + t.string "reset_password_token" + t.datetime "last_sign_in_at" + t.string "last_sign_in_ip" + t.integer "sign_in_count", :default => 0 + t.datetime "current_sign_in_at" + t.string "current_sign_in_ip" + t.datetime "reset_password_sent_at" + t.boolean "admin" + t.string "image_file_name" + t.string "image_content_type" + t.integer "image_file_size" + t.datetime "image_updated_at" + end + + add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + +end From 0160f56238b4ffaf8f69f2ef69e36e22f729a675 Mon Sep 17 00:00:00 2001 From: Robert Best Date: Fri, 26 Sep 2014 22:40:31 -0400 Subject: [PATCH 7/8] partially finished fixes to zoomextents --- app/assets/javascripts/metamaps/JIT.js | 6 ++ .../javascripts/metamaps/Metamaps.GlobalUI.js | 17 ++++ .../javascripts/metamaps/Metamaps.JIT.js | 90 +++++++++++++++---- app/assets/javascripts/metamaps/Metamaps.js | 3 + 4 files changed, 99 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/metamaps/JIT.js b/app/assets/javascripts/metamaps/JIT.js index de6aacb7..c43788bc 100644 --- a/app/assets/javascripts/metamaps/JIT.js +++ b/app/assets/javascripts/metamaps/JIT.js @@ -2489,7 +2489,11 @@ Extras.Classes.Navigation = new Class({ if (!Metamaps.Mouse.boxStartCoordinates && (e.shiftKey || rightClick)) { Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos(); } + Metamaps.Mouse.didPan = false; + + + // END METAMAPS CODE this.pos = eventInfo.getPos(); @@ -2557,6 +2561,8 @@ Extras.Classes.Navigation = new Class({ // START METAMAPS CODE if (Metamaps.Mouse.didPan) Metamaps.JIT.SmoothPanning(); + + // END METAMAPS CODE } diff --git a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js index 13278b28..f1c40b25 100644 --- a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js @@ -372,6 +372,23 @@ Metamaps.GlobalUI.Search = { self.close(0, true); } break; + case 65: + case 97: + e.preventDefault(); + if (e.ctrlKey){ + Metamaps.Visualize.mGraph.graph.eachNode(function (n) { + Metamaps.Control.selectNode(n,e); + }); + + Metamaps.Visualize.mGraph.plot(); + } + + break; + case 69: + case 101: + e.preventDefault(); + Metamaps.JIT.zoomExtents(); + break; default: break; //console.log(e.which); } diff --git a/app/assets/javascripts/metamaps/Metamaps.JIT.js b/app/assets/javascripts/metamaps/Metamaps.JIT.js index c0250038..810f2b2e 100644 --- a/app/assets/javascripts/metamaps/Metamaps.JIT.js +++ b/app/assets/javascripts/metamaps/Metamaps.JIT.js @@ -313,7 +313,7 @@ Metamaps.JIT = { if (Metamaps.Mouse.boxStartCoordinates) { Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); - Metamaps.JIT.selectWithBox(e); + Metamaps.JIT.zoomToBox(); return; } @@ -663,8 +663,6 @@ Metamaps.JIT = { var scale = dist / lastDist; - console.log(scale); - if (8 >= Metamaps.Visualize.mGraph.canvas.scaleOffsetX * scale && Metamaps.Visualize.mGraph.canvas.scaleOffsetX * scale >= 1) { Metamaps.Visualize.mGraph.canvas.scale(scale, scale); } @@ -945,7 +943,9 @@ Metamaps.JIT = { var fromNodeY = -1 * synapse.get('edge').nodeFrom.pos.y; var toNodeX = synapse.get('edge').nodeTo.pos.x; var toNodeY = -1 * synapse.get('edge').nodeTo.pos.y; - + var from = synapse.get('edge').nodeFrom; + var to = synapse.get('edge').nodeTo; + var maxX = fromNodeX; var maxY = fromNodeY; var minX = fromNodeX; @@ -964,7 +964,7 @@ Metamaps.JIT = { (eX > maxBoxX) ? (maxBoxX = eX):(minBoxX = eX); (eY > maxBoxY) ? (maxBoxY = eY):(minBoxY = eY); - //Fins the slopes from the synapse fromNode to the 4 corners of the selection box + //Find the slopes from the synapse fromNode to the 4 corners of the selection box var slopes = []; slopes.push( (sY - fromNodeY) / (sX - fromNodeX) ); slopes.push( (sY - fromNodeY) / (eX - fromNodeX) ); @@ -983,6 +983,10 @@ Metamaps.JIT = { var b = fromNodeY - synSlope * fromNodeX; var selectTest = false; + if (from.name == 'node 3' && to.name == 'node1'){ + console.log(from.pos.x,-1*from.pos.y,to.pos.x,-1*to.pos.y,sX,sY,eX,eY); + } + //if the synapse slope is within a range that would intersect with the selection box if (synSlope <= maxSlope && synSlope >= minSlope){ @@ -1003,17 +1007,18 @@ Metamaps.JIT = { testY = sY; testX = (testY - b)/synSlope; - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ selectTest = true; } testY = eY; testX = (testY - b)/synSlope; - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ selectTest = true; } } + //console.log('From '+from.name + ' to ' + to.name + ' is a ' +selectTest); //The test synapse was selected! if(selectTest){ if(e.ctrlKey){ @@ -1078,15 +1083,23 @@ Metamaps.JIT = { // wait a certain length of time, then check again, then run this code setTimeout(function () { if (!Metamaps.JIT.nodeWasDoubleClicked()) { - if (!e.shiftKey) { + if (!e.shiftKey && !e.ctrlKey) { Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllEdges(); } - if (node.selected) { - Metamaps.Control.deselectNode(node); - } else { + if(e.ctrlKey || e.shiftKey){ + if (node.selected) { + Metamaps.Control.deselectNode(node); + } else { + Metamaps.Control.selectNode(node,e); + } + } + else{ + Metamaps.Control.deselectAllNodes(); + Metamaps.Control.deselectAllEdges(); Metamaps.Control.selectNode(node,e); } + //trigger animation to final styles Metamaps.Visualize.mGraph.fx.animate({ modes: ['edge-property:lineWidth:color:alpha'], @@ -1111,7 +1124,6 @@ Metamaps.JIT = { // create new menu for clicked on node var rightclickmenu = document.createElement("div"); rightclickmenu.className = "rightclickmenu"; - // add the proper options to the menu var menustring = '
    '; @@ -1139,7 +1151,7 @@ Metamaps.JIT = { top: e.clientY }); //add the menu to the page - $('#center-container').append(rightclickmenu); + $('#infovis-canvaswidget').append(rightclickmenu); // attach events to clicks on the list items @@ -1452,6 +1464,54 @@ Metamaps.JIT = { canvas.translate(-1*offsetX,-1*offsetY); }, + zoomToBox: function () { + var sX = Metamaps.Mouse.boxStartCoordinates.x, + sY = Metamaps.Mouse.boxStartCoordinates.y, + eX = Metamaps.Mouse.boxEndCoordinates.x, + eY = Metamaps.Mouse.boxEndCoordinates.y; + + Metamaps.JIT.centerMap(); + + var height = $(document).height(), + width = $(document).width(); + + var spanX = Math.abs(sX - eX); + var spanY = Math.abs(sY - eY); + var ratioX = width / spanX; + var ratioY = height / spanY; + console.log(ratioX,ratioY); + + var newRatio = Math.min(ratioX,ratioY); + + var canvas = Metamaps.Visualize.mGraph.canvas; + + if(canvas.scaleOffsetX *newRatio<= 5 && canvas.scaleOffsetX*newRatio >= 0.2){ + canvas.scale(newRatio,newRatio); + } + else if(canvas.scaleOffsetX * newRatio > 5){ + newRatio = 5/ canvas.scaleOffsetX; + canvas.scale(newRatio,newRatio); + } + else{ + newRatio = 0.2/ canvas.scaleOffsetX; + canvas.scale(newRatio,newRatio); + } + + + + + + var cogX = (sX + eX)/2; + var cogY = (sY + eY)/2; + + canvas.translate(-1* cogX, -1* cogY); + + + Metamaps.Mouse.boxStartCoordinates = false; + Metamaps.Mouse.boxEndCoordinates = false; + Metamaps.Visualize.mGraph.plot(); + + }, zoomExtents: function () { Metamaps.JIT.centerMap(); var height = $(document).height(), @@ -1482,8 +1542,6 @@ Metamaps.JIT = { dim = n.getData('dim'), ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); - console.log(dim); - var height = 25 * arrayOfLabelLines.length; var index, lineWidths = []; @@ -1539,8 +1597,6 @@ Metamaps.JIT = { dim = n.getData('dim'), ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); - console.log(dim); - var height = 25 * arrayOfLabelLines.length; var index, lineWidths = []; diff --git a/app/assets/javascripts/metamaps/Metamaps.js b/app/assets/javascripts/metamaps/Metamaps.js index c7b6e3e6..6f4473f9 100644 --- a/app/assets/javascripts/metamaps/Metamaps.js +++ b/app/assets/javascripts/metamaps/Metamaps.js @@ -47,6 +47,7 @@ Metamaps.Touch = { Metamaps.Mouse = { didPan: false, + didBoxZoom: false, changeInX: 0, changeInY: 0, edgeHoveringOver: false, @@ -1718,11 +1719,13 @@ Metamaps.Control = { if (Metamaps.Selected.Nodes.indexOf(node) != -1) return; node.selected = true; node.setData('dim', 30, 'current'); + /* if(!(e.ctrlKey) && !(e.altKey)){ node.eachAdjacency(function (adj) { Metamaps.Control.selectEdge(adj); }); } + */ Metamaps.Selected.Nodes.push(node); }, From 2de7167c2c71ff3219ea28c2a8d3834ccff35536 Mon Sep 17 00:00:00 2001 From: Robert Best Date: Sun, 28 Sep 2014 15:29:22 -0400 Subject: [PATCH 8/8] A bunch of fixes for selection with box, and zoom to extents --- .../javascripts/src/Metamaps.GlobalUI.js | 12 +- app/assets/javascripts/src/Metamaps.JIT.js | 114 +++++++++--------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js b/app/assets/javascripts/src/Metamaps.GlobalUI.js index 4c2d9a05..a425d78f 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js @@ -368,8 +368,12 @@ Metamaps.GlobalUI.Search = { break; case 65: case 97: - e.preventDefault(); + if (e.ctrlKey){ + Metamaps.Control.deselectAllNodes(); + Metamaps.Control.deselectAllEdges(); + + e.preventDefault(); Metamaps.Visualize.mGraph.graph.eachNode(function (n) { Metamaps.Control.selectNode(n,e); }); @@ -380,8 +384,10 @@ Metamaps.GlobalUI.Search = { break; case 69: case 101: - e.preventDefault(); - Metamaps.JIT.zoomExtents(); + if (e.ctrlKey){ + e.preventDefault(); + Metamaps.JIT.zoomExtents(); + } break; default: break; //console.log(e.which); diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index 9562e2fd..41481c56 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -938,7 +938,7 @@ Metamaps.JIT = { Metamaps.Control.deselectAllEdges(); } - //select all nodes, and their edges, that are within the box + //select all nodes that are within the box Metamaps.Visualize.mGraph.graph.eachNode(function (n) { var x = n.pos.x, y = n.pos.y; @@ -967,10 +967,8 @@ Metamaps.JIT = { var fromNodeY = -1 * synapse.get('edge').nodeFrom.pos.y; var toNodeX = synapse.get('edge').nodeTo.pos.x; var toNodeY = -1 * synapse.get('edge').nodeTo.pos.y; - var from = synapse.get('edge').nodeFrom; - var to = synapse.get('edge').nodeTo; - - var maxX = fromNodeX; + + var maxX = fromNodeX; var maxY = fromNodeY; var minX = fromNodeX; var minY = fromNodeY; @@ -1005,45 +1003,44 @@ Metamaps.JIT = { //Find synapse-in-question's slope var synSlope = (toNodeY - fromNodeY) / (toNodeX - fromNodeX); var b = fromNodeY - synSlope * fromNodeX; + + //Use the selection box edges as test cases for synapse intersection + var testX = sX; + var testY = synSlope * testX + b; + + var selectTest; - var selectTest = false; - if (from.name == 'node 3' && to.name == 'node1'){ - console.log(from.pos.x,-1*from.pos.y,to.pos.x,-1*to.pos.y,sX,sY,eX,eY); - } - - - //if the synapse slope is within a range that would intersect with the selection box - if (synSlope <= maxSlope && synSlope >= minSlope){ - var testX = sX; - var testY = synSlope * testX + b; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ - selectTest = true; - } - - testX = eX; - testY = synSlope * testX + b; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ - selectTest = true; - } - - testY = sY; - testX = (testY - b)/synSlope; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ - selectTest = true; - } - - testY = eY; - testX = (testY - b)/synSlope; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ - selectTest = true; - } + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ + selectTest = true; } - //console.log('From '+from.name + ' to ' + to.name + ' is a ' +selectTest); - //The test synapse was selected! + + testX = eX; + testY = synSlope * testX + b; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ + selectTest = true; + } + + testY = sY; + testX = (testY - b)/synSlope; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ + selectTest = true; + } + + testY = eY; + testX = (testY - b)/synSlope; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ + selectTest = true; + } + + //Case where the synapse is wholly enclosed in the seldction box + if(fromNodeX >= minBoxX && fromNodeX <= maxBoxX && fromNodeY >= minBoxY && fromNodeY <= maxBoxY && toNodeX >= minBoxX && toNodeX <= maxBoxX && toNodeY >= minBoxY && toNodeY <= maxBoxY){ + selectTest = true; + } + + //The test synapse was selected! if(selectTest){ if(e.ctrlKey){ if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ @@ -1520,7 +1517,6 @@ Metamaps.JIT = { var spanY = Math.abs(sY - eY); var ratioX = width / spanX; var ratioY = height / spanY; - console.log(ratioX,ratioY); var newRatio = Math.min(ratioX,ratioY); @@ -1536,11 +1532,7 @@ Metamaps.JIT = { else{ newRatio = 0.2/ canvas.scaleOffsetX; canvas.scale(newRatio,newRatio); - } - - - - + } var cogX = (sX + eX)/2; var cogY = (sY + eY)/2; @@ -1558,6 +1550,7 @@ Metamaps.JIT = { var height = $(document).height(), width = $(document).width(), maxX, minX, maxY, minY, counter = 0; + var canvas = Metamaps.Visualize.mGraph.canvas; if (Metamaps.Selected.Nodes.length > 0) { @@ -1581,7 +1574,7 @@ Metamaps.JIT = { var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'), dim = n.getData('dim'), - ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); + ctx = canvas.getCtx(); var height = 25 * arrayOfLabelLines.length; @@ -1607,7 +1600,6 @@ Metamaps.JIT = { var newRatio = Math.max(ratioX,ratioY); var scaleMultiplier = 1/newRatio*0.9; - var canvas = Metamaps.Visualize.mGraph.canvas; if(canvas.scaleOffsetX *scaleMultiplier<= 3 && canvas.scaleOffsetX*scaleMultiplier >= 0.2){ canvas.scale(scaleMultiplier,scaleMultiplier); } @@ -1620,7 +1612,6 @@ Metamaps.JIT = { canvas.scale(scaleMultiplier,scaleMultiplier); } - counter = 0; nodes.forEach(function (n) { @@ -1636,7 +1627,7 @@ Metamaps.JIT = { var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'), dim = n.getData('dim'), - ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); + ctx = canvas.getCtx(); var height = 25 * arrayOfLabelLines.length; @@ -1653,12 +1644,21 @@ Metamaps.JIT = { counter++; }); + + var cogX = (maxX + minX)/2; + var cogY = (maxY + minY)/2; + + canvas.translate(-1* cogX, -1* cogY); + $(document).trigger(Metamaps.JIT.events.zoom, [event]); } + else if(nodes.length == 1){ + nodes.forEach(function (n) { + var x = n.pos.x, + y = n.pos.y; - var cogX = (maxX + minX)/2; - var cogY = (maxY + minY)/2; - - canvas.translate(-1* cogX, -1* cogY); - $(document).trigger(Metamaps.JIT.events.zoom, [event]); + canvas.translate(-1* x, -1* y); + $(document).trigger(Metamaps.JIT.events.zoom, [event]); + }); + } } }; \ No newline at end of file