Improved pathedit efficiency, fixed clone node when selecting last node in open path

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1244 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-01-19 15:08:30 +00:00
parent a6edbc58bb
commit 783ad05a45
1 changed files with 22 additions and 23 deletions

View File

@ -3313,16 +3313,11 @@ function BatchCommand(text) {
var is_closed = pathIsClosed(); var is_closed = pathIsClosed();
var last_pt = current_path_pts.length/2 - 1; var last_pt = current_path_pts.length/2 - 1;
if(is_closed && point == last_pt) {
current_path_pt = 0;
} else {
current_path_pt = point; current_path_pt = point;
}
$('#pathpointgrip_container circle').attr('stroke','#00F'); $('#pathpointgrip_container circle').attr('stroke','#00F');
var sel_point = (current_path_pt == 0 && is_closed)?last_pt:point; $('#pathpointgrip_' + point).attr('stroke','#0FF');
$('#pathpointgrip_' + sel_point).attr('stroke','#0FF');
var grip = $('#pathpointgrip_' + point); var grip = $('#pathpointgrip_' + point);
$('#ctrlpointgrip_container circle').attr('fill', '#EEE'); $('#ctrlpointgrip_container circle').attr('fill', '#EEE');
@ -3336,9 +3331,13 @@ function BatchCommand(text) {
var addAllPointGripsToPath = function(pointToSelect) { var addAllPointGripsToPath = function(pointToSelect) {
// loop through and show all pointgrips // loop through and show all pointgrips
var closed = pathIsClosed();
var len = current_path_pts.length; var len = current_path_pts.length;
for (var i = 0; i < len; i += 2) { for (var i = 0; i < len; i += 2) {
var grip = getElem("pathpointgrip_"+i/2); var grip = getElem("pathpointgrip_"+i/2);
// Skip last point if closed
if(!closed || i+2 < len) {
if (grip) { if (grip) {
assignAttributes(grip, { assignAttributes(grip, {
'cx': current_path_pts[i], 'cx': current_path_pts[i],
@ -3349,6 +3348,7 @@ function BatchCommand(text) {
else { else {
addPointGripToPath(current_path_pts[i], current_path_pts[i+1],i/2); addPointGripToPath(current_path_pts[i], current_path_pts[i+1],i/2);
} }
}
var index = i/2; var index = i/2;
var item = current_path.pathSegList.getItem(index); var item = current_path.pathSegList.getItem(index);
@ -3471,7 +3471,7 @@ function BatchCommand(text) {
var i = current_path_pt_drag * 2; var i = current_path_pt_drag * 2;
var last_index = current_path_pts.length/2 - 1; var last_index = current_path_pts.length/2 - 1;
var is_first = current_path_pt_drag == 0 || (is_closed && current_path_pt_drag == last_index); var is_first = current_path_pt_drag == 0; // || (is_closed && current_path_pt_drag == last_index);
var is_last = !is_closed && current_path_pt_drag == last_index; var is_last = !is_closed && current_path_pt_drag == last_index;
// if the image is rotated, then we must modify the x,y mouse coordinates // if the image is rotated, then we must modify the x,y mouse coordinates
@ -3573,11 +3573,6 @@ function BatchCommand(text) {
if (grip) { if (grip) {
grip.setAttribute("cx", mouse_x); grip.setAttribute("cx", mouse_x);
grip.setAttribute("cy", mouse_y); grip.setAttribute("cy", mouse_y);
if(is_closed && is_first) {
var grip = getElem("pathpointgrip_" + last_index);
grip.setAttribute("cx", mouse_x);
grip.setAttribute("cy", mouse_y);
}
call("changed", [grip]); call("changed", [grip]);
} }
@ -4263,6 +4258,10 @@ function BatchCommand(text) {
clonePathNode: function() { clonePathNode: function() {
var pt = current_path_pt, list = current_path.pathSegList; var pt = current_path_pt, list = current_path.pathSegList;
if(pt+1 >= list.numberOfItems) {
pt--;
}
var next_item = list.getItem(pt+1); var next_item = list.getItem(pt+1);
// Get point in between nodes // Get point in between nodes