Exchange position of selected objects

Bug #171944 reported by Bug Importer
2
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Roland Meub

Bug Description

a new button in command toolbar (the rotate, reflect,...) : "exchange 2
objects", exchange position of 2 objects, in order to replace an object or
to choose the object better for one position.

Revision history for this message
Bug Importer (bug-importer) wrote :

I have forgotten: exchange position and layer

Ryan Lerch (ryanlerch)
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Roland Meub (roland-meub) wrote :

I've also missed this feature several times, so I took a dive into the code and implemented it.
Would it be possible to integrate this ?

A patch against the current branch lp:inkscape is attached.

Revision history for this message
jazzynico (jazzynico) wrote :

Thanks for this patch!

Tested on Ubuntu 9.10.
Looks fine with shapes, freehand and text, even when more than 2 objects are selected, and with groups.
Doesn't seem to work well with 3Dboxes (unexpected translations...). Did you notice that?

Changed in inkscape:
assignee: nobody → Roland Meub (roland-meub)
status: Confirmed → In Progress
Revision history for this message
Jon A. Cruz (jon-joncruz) wrote :

Looks promising... however has anyone examined what this does to the raw SVG internally? Might need to have someone test locally and see.

Revision history for this message
Roland Meub (roland-meub) wrote :

You are right, there is something wrong with the 3DBoxes. I will look after this...

This operation should do the same to the raw SVG as when the user moves the objects by hand.
I've just checked it for a rect and a path.
For a rect, the y- and y attributes are changed; for paths a translate-transformation is done.

Revision history for this message
Roland Meub (roland-meub) wrote :

After some debugging, I've found out that the issue with the 3DBoxes seems to be a general problem.
I've just tried to vertically center two new created 3DBoxes with the "align and distribute" dialog and
this didn't work either.

I think, the root cause for this is, that after creation of both 3DBoxes, they are linked to the same perspective.
This somehow seems to cause the trouble.
After I've moved the second 3DBox, the error behavior vanished for to position exchange function as
well as for the align and distribute functions.

I've attached a tar.gz archive containing two SVG-files. one with the 3DBox issue appearing and one
where it is vanished.

Revision history for this message
jazzynico (jazzynico) wrote :

Yes, there are some issues with the 3Dboxes, and this bug is probably not due to your code.

As for the SVG, the changes look clean, and I see nothing unusual.
Works well with connectors too.
I really like it!

Revision history for this message
Roland Meub (roland-meub) wrote :

As discussed on the inkscape-devel list, this button should better
be placed into the "align-and-distribute" dialog. So I rearranged the
dialog elements as proposed and moved the implementation to the
dialog.

Here is a new patch containing the rearranged dialog and the
exchange feature within the dialog

Revision history for this message
jazzynico (jazzynico) wrote :

I think that your patch is almost ready for commit, but there's a couple of things that could be easily improved.
1. Could you remove the unused space at the bottom of the distribute section?
2. When using more than two objects, the rotation is counter-clockwise. Is it possible to set it clockwise instead?

The icon is consistent with the menu bars ones, but a little fat compared to those used in the align and distribute dialog (but I'm not an icon expert).

Thanks!

Revision history for this message
Roland Meub (roland-meub) wrote :

Of cause, I can remove the unused space at the bottom of the distribution section and
I will also change the icon which has really to fat lines.

But I'm not sure, whether it makes sense to change the rotation algorithm as you proposed.
The point is that the position exchange only depends on the order in which
the objects are selected.
- The first selected object moves to the position of the last selected object
- the second selected object moves to the position of the first selected object
- the 3rd moves to the position of the second selected object ...

I can change it so that the 1st moves to the 2nd, 2nd to 3rd, ... and last to the 1st.
This might make more sense but it still only depends on the order in which the
objects are selected.

Revision history for this message
jazzynico (jazzynico) wrote :

> Of cause, I can remove the unused space at the bottom of the distribution section
> and I will also change the icon which has really to fat lines.

Thanks!

> But I'm not sure, whether it makes sense to change the rotation algorithm as you proposed.
> The point is that the position exchange only depends on the order in which
> the objects are selected.

Ok. That's something I didn't understand correctly because I always tested the patch by drag-selecting the objects. But your explanation is clear. I think it's worth discussing it on the dev-list (where the clockwise rotation has been suggested).

Revision history for this message
ScislaC (scislac) wrote :

When I tested by doing Select All (Ctrl+A) it rotates clockwise for me (which could also just be related to the layout of the items).

Revision history for this message
Roland Meub (roland-meub) wrote : Re: [Bug 171944] Re: to exchange position of two objects

Just a few words to clearify the logic behind:
The current implementation exchanges positions of objects according to
the order in which they
where selected:
The 1st selected object moves to postion of 2nd, the 2nd to the position
of the 3rd, ... and the last
to the position of the first.

This brings me to the question whether we should really try to implement a
strict (for example clockwise) rotate order.
The point is, that it's not ever possible to decide the right order.
Imagine cases where all three objects are located at the same Y or X
position)
With more than three objects, we'll face that much situations where its
difficult to decide the right order.

I would propose to stick to the simple rule already implemented.

ScislaC schrieb:
> When I tested by doing Select All (Ctrl+A) it rotates clockwise for me
> (which could also just be related to the layout of the items).
>
>

Revision history for this message
su_v (suv-lp) wrote : Re: to exchange position of two objects

drag-selecting (or Ctrl+A) adds the objects to the selection set according to z-order - attaching my playground for exchanging (multiple) selected objects with different stacking order.

Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
Roland Meub (roland-meub) wrote :

Here is my next (hopefully final) patch for this.
Beside the little changes in the Dialog box and at the icon it adds the clockwise exchange order.
The discussion on the devel-list gave me some Ideas how to implement this.

Revision history for this message
su_v (suv-lp) wrote :

As a casual user I preferred the (more) predictable results of the previous version (exchange-positions-2.diff).

1) selecting a horizontal row of elements (by dragging a selection window or selecting them individually) seems unpredictable with 'exchange-positions-3' and does not always return to the initial sort order after a 'round-trip' (test case used: 171944-shuffle2.svg, objects on layer 'vertical').
'exchange-positions-2' exchanged the selected objects according to z-order (when selected w/ dragging a selection window) by moving the first object to the last position and shifting the other objects one position up. With the new version I have a hard time detecting a logic in the way linear arranged objects change their position.

2) Exchanging multiple selected elements that are arranged around a center (objects on layer 'spiral up/down', 'circle') seems to give the same and predictable results as in 'exchange-positions-2'.

Revision history for this message
su_v (suv-lp) wrote :

... illustrating my previous comment.

Revision history for this message
Roland Meub (roland-meub) wrote :

You're right, I've also had a hard time with the current implementation and objects in a row.
I's really not predictable.

On the other hand, it might be valuable in situations where objects are more located around
a circle and when the Z-Order is more mixed. In this case the second implementation would
have done the rotation in an unexpeced order.
And also the first implementation using the selection order might have vale for the expert user
because one is able to influence the rotation order by selecting the single object one after the other.

So, since we have enough space in the Rearrange area of the dialog, why don't we put buttons for all three variants into the dialog ?
It should be very few work and everyone is free to use the rotation strategy appropriate for his situation.

Revision history for this message
Roland Meub (roland-meub) wrote :
Revision history for this message
Roland Meub (roland-meub) wrote :
Revision history for this message
ScislaC (scislac) wrote :

Updated patch to apply against current head (and properly saved/optimized icons portion).

Revision history for this message
jazzynico (jazzynico) wrote :

Committed in the trunk, revision 9681, so that users can test without having to patch.
Thanks!

Changed in inkscape:
milestone: none → 0.49
status: In Progress → Fix Committed
summary: - to exchange position of two objects
+ Exchange position of selected objects
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.