OpenModelica
OpenModelica copied to clipboard
Copy & Paste of diagram elements into the same diagram
Description
When copying a class instance from a diagram and paste it into the same diagram again the two instances are directly on top of each other and are both selected.
Steps to Reproduce
- Create a new class.
- Drag any other class onto it. E.g.:
Modelica.Blocks.Continuous.Integrator - Copy and paste the integrator instance with Ctrl+C and Ctrl+V.
- The two class instances are now directly on top of each other. When starting to move the copied class around the "old" class moves with it since both instances seem to be selected after the copying process.
Expected Behavior
Only the newly copied class is selected after the copying process (otherwise one always has to deselect both instances by clicking somewhere else and then clicking on the new component again).
The copied class is not directly instantiated on top of the old class but shifted for example 10 points in each direction. This allows the select to desired class (old or new) in the diagram window after the copying process.
The expected behavior is similar to the one in Dymola. There the result of the copying looks as follows:
Version and OS
- OpenModelica Version: 1.23.0
- OS: Windows 11, 64 bit
- MSL 4.0.0
Thanks for looking into this Aaron Buntrock - Bosch Rexroth
It is possible that after Ctrl+V the icons are attached to the mouse waiting for a click on their final position?
If I click somewhere after Ctrl+v, the instances are just deselected.
Only the newly copied class is selected after the copying process (otherwise one always has to deselect both instances by clicking somewhere else and then clicking on the new component again). The copied class is not directly instantiated on top of the old class but shifted for example 10 points in each direction. This allows the select to desired class (old or new) in the diagram window after the copying process.
AFAICT, this expected behaviour is already available if you press "duplicate" in the context menu (or Ctrl-D)? So I'm not sure this feature request is already effectively implemented?
Occasionally I find it useful to do ctrl-c/ctrl-v when copying instances and they end up on top of each other, e.g. when wanting to maintain alignment -- please don't move the resulting object arbitrarily when pasting!
@bilderbuchi Thanks for letting me know. For a single element the "duplicate" feature behaves just like I the expected behavior I described.
However, the duplicate feature can only be applied to one instance and not to multiple ones in contrast to ctrl-c/ctrl-v. In this case it is especially annoying from my opinion that not only the newly copied instances are selected. You have to move all copied instances to the new location one by another instead of moving the whole copied "system" at once. So maybe a compromise could be that they are copied one top of each other but only the new instances are selected?
However, the duplicate feature can only be applied to one instance and not to multiple ones in contrast to ctrl-c/ctrl-v.
I don't know what you mean? I just tried this and it works (OM 1.23) -- select multiple object (with Shift pressed), press Ctrl-D, you get a dialog prompting for the new names for all components sequentially, and afterwards you get the offset new entities, only new ones selected. What am I missing?
Note: Why you have to use Shift and not Ctrl to select multiple objects, in contrast to my experience with virtually any other tool, I don't know 🤷 , but that's another issue I'd say.
So maybe a compromise could be that they are copied one top of each other but only the new instances are selected?
This is what I would expect.
@bilderbuchi It seems that I was not familiar enough with the duplicate feature. However, its not possible to duplicate connection lines with this approach. I will add another issue for this and would leave this ticket for the selection topic (only the new instances).
For some reason we have 2 different implementations and both have their limitation. I personally prefer that we remove duplicate functionality and only have copy/paste. The copy/paste then needs to be updated to use the mouse position i.e., add the current mouse position as the offset when pasting items. For example, copy something in Dymola and then just move mouse to a new position and paste.
For some reason we have 2 different implementations and both have their limitation. I personally prefer that we remove duplicate functionality and only have copy/paste. The copy/paste then needs to be updated to use the mouse position i.e., add the current mouse position as the offset when pasting items. For example, copy something in Dymola and then just move mouse to a new position and paste.
If you go this route, please make sure that there is a viable approach to create aligned components. Paste-in-place is quite useful for creating a regular/aligned array of components. For example, if you don't move the mouse between copy and paste events, then paste at the original position.
We finally made a lot of progress in this direction. #13563, #13596, #13600, #13601, #13614 and #13623.
- It is now possible to paste items at the mouse position.
- Paste-in-place is possible if you don't move the mouse between copy and paste.
- Only the pasted items are selected.
- The duplicate use the implementation. The only difference is that in case of duplicate the items are moved to the right by grid size of coordinate system.
Good that we have this feature in 1.25.0
Works perfect with today's nightly. Thanks a lot.