← Back to team overview

kicad-developers team mailing list archive

Re: [Patch] pcbnew clipboard support

 

On 18.09.2017 00:32, Kristoffer Ödmark wrote:
> That being said, I dont like the way the ref.pt is set now either, which
> is not at all. Personally I would like have the components added at the
> point of the cursor, but I also believe having a copy functionality that
> is not perfect as of now is better than none at all.
> 
Hi Kristoffer,

Some more comments (after your most recent patches):
- if you select a single module on a PCB and try to copy/paste it, it
sometimes crashes (see attached trace)
- call the actions Cut/Copy/Paste, just like any other app.
- there's no Cut/Copy/Paste in the Edit menu.

Cheers,
Tom


0x00007fffdec60136 in KIGFX::RATSNEST_VIEWITEM::ViewDraw(int,
KIGFX::VIEW*) const () from
/home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
(gdb) bt
#0  0x00007fffdec60136 in KIGFX::RATSNEST_VIEWITEM::ViewDraw(int,
KIGFX::VIEW*) const () from
/home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
#1  0x00007fffdee24d00 in
KIGFX::VIEW::drawItem::operator()(KIGFX::VIEW_ITEM*) () from
/home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
#2  0x00007fffdee24c00 in bool RTree<KIGFX::VIEW_ITEM*, int, 2, float,
8, 4>::Search<KIGFX::VIEW::drawItem>(RTree<KIGFX::VIEW_ITEM*, int, 2,
float, 8, 4>::Node*, RTree<KIGFX::VIEW_ITEM*, int, 2, float, 8,
4>::Rect*, KIGFX::VIEW::drawItem&, int&) () from
/home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
#3  0x00007fffdee20237 in KIGFX::VIEW::redrawRect(BOX2<VECTOR2<int> >
const&) () from
/home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
#4  0x00007fffdee20a85 in KIGFX::VIEW::Redraw() () from
/home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
#5  0x00007fffdee90716 in EDA_DRAW_PANEL_GAL::onPaint(wxPaintEvent&) ()
from /home/twl/Kicad-dev/kicad-build/release/pcbnew/_pcbnew.kiface
#6  0x00007ffff6466bfe in
wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&,
wxEvent&) const () from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#7  0x00007ffff65da032 in
wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&) () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#8  0x00007ffff65da396 in
wxEvtHandler::SearchDynamicEventTable(wxEvent&) () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#9  0x00007ffff65da41e in wxEvtHandler::TryHereOnly(wxEvent&) () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#10 0x00007ffff65da4b3 in wxEvtHandler::ProcessEventLocally(wxEvent&) ()
from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#11 0x00007ffff65da515 in wxEvtHandler::ProcessEvent(wxEvent&) () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#12 0x00007ffff65db533 in wxEvtHandler::ProcessPendingEvents() () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#13 0x00007ffff646a7b7 in wxAppConsoleBase::ProcessPendingEvents() ()
from /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#14 0x00007ffff6d2ad82 in wxApp::DoIdle() () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#15 0x00007ffff6d2ae93 in ?? () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#16 0x00007ffff1df6ce5 in g_main_context_dispatch () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007ffff1df7048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007ffff1df730a in g_main_loop_run () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007ffff2b53447 in gtk_main () from
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#20 0x00007ffff6d3dab5 in wxGUIEventLoop::DoRun() () from
/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#21 0x00007ffff64a9d70 in wxEventLoopBase::Run() () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#22 0x00007ffff6468cdd in wxAppConsoleBase::MainLoop() () from
/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0


-
> I do not have the time currently to look into the ref.pt properly.
> 
> 
> On 09/17/2017 11:30 PM, Kristoffer Ödmark wrote:
>> I hope that the branch can be merged as is, and that the reference
>> point can be marked as a wishlist.
>>
>> I will think about the reference point. I do not know if I like the
>> extra step of adding a reference point compared to having it set
>> automatically.
>>
>> On Sep 17, 2017 22:38, "Tomasz Wlostowski" <tomasz.wlostowski@xxxxxxx
>> <mailto:tomasz.wlostowski@xxxxxxx>> wrote:
>>
>>     On 17.09.2017 19:56, Kristoffer Ödmark wrote:
>>      > Thanks for taking the time to test this, I know testing takes
>> time!
>>      >
>>      > I took a look at some of the things you mentioned.
>>      >
>>      >  - I fixed menu entries
>>      >  - I changed some names of functions ( still kept
>>     appendFromClipboard,
>>      > but made the action called pasteFromClipboard )
>>      >  - Footprints now render correctly
>>      >  - Added Cut functionality ( not thoroughly tested, just chained a
>>      > copyToClipboard and then a EDIT_TOOL::Remove action after that
>>      >
>>      > I am a bit unsure about how to proceed with the reference point
>> you
>>      > mentioned, but I think I understand what you want there.
>>      >
>>     Hi Kristoffer,
>>
>>     Thanks for your quick reaction. I agree with Simon's proposal
>> concerning
>>     the reference point.
>>
>>     Thx,
>>     Tom
>>      > Please have a look when appropriate, I rather not have to
>> update the
>>      > entire branch in a few months though
>>      >
>>      > - Kristoffer
>>      >
>>      > On 09/17/2017 05:33 PM, Tomasz Wlostowski wrote:
>>      >> On 17.09.2017 17:06, Kristoffer Ödmark wrote:
>>      >>> Hey again, I needed this feature again when copying some tedious
>>      >>> silkscreen drawings that I have not made into a footprint.
>>      >>>
>>      >>> Updated my branch to fit into master. I do agree that adding
>>     context
>>      >>> menu entries should be done, but I do not feel it necessary for
>>     merging
>>      >>> this unless any other bugs are found.
>>      >>
>>      >> Hi Kristoffer,
>>      >>
>>      >> I tried your patch and I would really love to merge it after some
>>      >> polishing up. Few observations below:
>>      >> - Menu items are necessary. I consider the feature incomplete if
>>     it can
>>      >> be only invoked by a keyboard shortcut. We have a lot of users
>>      >> complaining that some functions can be only accessed by
>>     shortcuts, why
>>      >> add another item to their list of complaints?
>>      >> - Missing 'Cut' function (Ctrl-X). If we are to add
>> copy-paste, it
>>      >> should work as in every other program.
>>      >> - Name internal events/actions correspondingly to the actions
>>     visible in
>>      >> the menus (e.g. copyToClipboard, pasteFromClipboard, etc.),
>>     using names
>>      >> like appendFromClipboard, etc. is IMHO confusing.
>>      >> - It would be useful to let the user select a reference point
>> with a
>>      >> mouse when copying/cutting items. This point would become
>>     attached to
>>      >> the mouse cursor when the items are being pasted.
>>      >> - While pasting a footprint, it only appears when you click LMB.
>>     Other
>>      >> items are displayed while moving the mouse in paste mode.
>>      >>
>>      >> Cheers,
>>      >> Tom
>>      >>
>>      >>
>>      >>
>>      >>>
>>      >>> I am unsure what you mean with netlist-path. If that is that the
>>      >>> timestamp or unique identifier is not there, then from what i
>>     gather
>>      >>> that is the same as manually adding a component in pcbnew.
>>      >>>
>>      >>> - Kristoffer
>>      >>>
>>      >>> On 06/23/2017 07:00 PM, Wayne Stambaugh wrote:
>>      >>>> Kristoffer,
>>      >>>>
>>      >>>> I finally had a chance to test this and it seems to work
>>     fine.  You
>>      >>>> definitely need to add copy and paste to the context menu and
>>     probably
>>      >>>> to the main menu as well.  While ctrl-c and ctrl-v are will
>> known,
>>      >>>> Pcbnew has never had a copy and paste feature so it may be
>>     wise to add
>>      >>>> the menu entries for existing users.  The only issue I see is
>>     that the
>>      >>>> netlist path is empty so I'm not sure how the this will
>> effect the
>>      >>>> ratsnest and connectivity algorithms.  I'm OK with it as long
>>     as no one
>>      >>>> else objects.
>>      >>>>
>>      >>>> Orson,
>>      >>>>
>>      >>>> would you please take a look at this when you get a chance to
>>     see if
>>      >>>> this makes sense as far as the tool framework goes.
>>      >>>>
>>      >>>> Thanks
>>      >>>>
>>      >>>> Wayne
>>      >>>>
>>      >>>> On 5/21/2017 4:32 PM, Kristoffer Ödmark wrote:
>>      >>>>> Hello!
>>      >>>>>
>>      >>>>> I fixed the kicad clipboard code according to your comments,
>>     it is now
>>      >>>>> linked to ctrl+c and ctrl+v, utilizing different code paths
>>      >>>>> depending on
>>      >>>>> what frame they are invoked at.
>>      >>>>>
>>      >>>>> I also fixed the crashes when trying to paste strange stuff.
>>      >>>>>
>>      >>>>> The code is available for testing at:
>>      >>>>>
>>      >>>>>
>>    
>> https://code.launchpad.net/~kristoffer-odmark/kicad/+git/kicad/+ref/copypasta
>>
>>    
>> <https://code.launchpad.net/~kristoffer-odmark/kicad/+git/kicad/+ref/copypasta>
>>
>>      >>>>>
>>      >>>>>
>>      >>>>>
>>      >>>>>
>>      >>>>> One thing is missing since I am unsure how to proceed,
>>      >>>>> the context menu entries.
>>      >>>>>
>>      >>>>> Should I create a new clipboard_tool.cpp/h file and add
>> context
>>      >>>>> entries
>>      >>>>> from there?
>>      >>>>>
>>      >>>>> Should I add the context entries in the files where they
>> are now?
>>      >>>>> ( selection menu for copying to clipboard, pcbnew_control for
>>     pasting,
>>      >>>>> module editor tool for pasting in module editor )
>>      >>>>>
>>      >>>>> Should I do it someway enterily different?
>>      >>>>>
>>      >>>>> Please advice
>>      >>>>>
>>      >>>>> - Kristoffer
>>      >>>>>
>>      >>>>>
>>      >>>>>
>>      >>>>> On 2017-05-08 15:41, Maciej Sumiński wrote:
>>      >>>>>> Hi Kristoffer,
>>      >>>>>>
>>      >>>>>> It is a neat feature. Your application is a good
>>     application, but I
>>      >>>>>> think it would really shine in the footprint editor.
>>      >>>>>> Unfortunately, it
>>      >>>>>> crashes when I tried to copy and paste a bunch of pads.
>>     Could you
>>      >>>>>> check it?
>>      >>>>>>
>>      >>>>>> IMHO it would be better to keep standard Ctrl+C and Ctrl+V
>> hot
>>      >>>>>> keys, as
>>      >>>>>> this is what people are likely to press when they want to
>>     copy or
>>      >>>>>> paste
>>      >>>>>> items. These two functions also deserve an entry in the
>>     right-click
>>      >>>>>> context menu. Let's not add more hidden features in KiCad.
>>      >>>>>>
>>      >>>>>> Speaking of which, you can also have a look at
>>      >>>>>> MODULE_EDITOR_TOOLS::{Copy,Paste}Items()
>>      >>>>>> (pcbnew/tools/module_editor_tools.cpp). Yes, you guessed it -
>>      >>>>>> there was
>>      >>>>>> already copy & paste for the module editor, but it was not
>>     properly
>>      >>>>>> exposed, mea culpa. We need to pick one way, and remove the
>>     other.
>>      >>>>>>
>>      >>>>>> There are also some code formatting violations that also
>>     should be
>>      >>>>>> handled before merging the patch. Tools like uncrustify or
>>      >>>>>> clang-format
>>      >>>>>> will do most of the boring work for you.
>>      >>>>>>
>>      >>>>>> If we decide to choose your way, then you need to add GPL
>>     license
>>      >>>>>> header
>>      >>>>>> for kicad_clipboard.{cpp,h} too.
>>      >>>>>>
>>      >>>>>> Regards,
>>      >>>>>> Orson
>>      >>>>>>
>>      >>>>>> On 05/04/2017 10:40 AM, Kristoffer Ödmark wrote:
>>      >>>>>>> Hello all!
>>      >>>>>>>
>>      >>>>>>> Last night I was doing some design that used a PCB antenna.
>>     I had
>>      >>>>>>> this
>>      >>>>>>> antenna design made in zones, It was very frustrating to
>>     try to copy
>>      >>>>>>> this between an old design and a new one since I had to
>> use a
>>      >>>>>>> texteditor
>>      >>>>>>> ( very glad that I could though ).
>>      >>>>>>>
>>      >>>>>>> After this I figured that this should be able to be
>> copy-pasted
>>      >>>>>>> between
>>      >>>>>>> pcbs.
>>      >>>>>>>
>>      >>>>>>> So I have now implemented a subclass of the PCB_IO, that can
>>      >>>>>>> format an
>>      >>>>>>> entire board or a selection to the clipboard in textformat,
>>     and then
>>      >>>>>>> created a subclass to the PCB_PARSER that parses from the
>>     clipboard
>>      >>>>>>> and
>>      >>>>>>> reuses the "append board" functionality to add them back.
>>     It also
>>      >>>>>>> does
>>      >>>>>>> remove the "path" properties of modules. This allows me to
>>      >>>>>>> copy-paste
>>      >>>>>>> things between different PCBs in kicad. The shortcut keys
>> are
>>      >>>>>>> ctrl+shift+c and ctrl+shift+v so that people dont use
>> this by
>>      >>>>>>> mistake :)
>>      >>>>>>>
>>      >>>>>>> I think that this might be useful for reusing designs in
>> some
>>      >>>>>>> manner,
>>      >>>>>>> and if this is in Kicad, my next step would be to start
>>     looking into
>>      >>>>>>> some tool to link the pasted modules to symbols in the
>>     schematic.
>>      >>>>>>>
>>      >>>>>>> Give me some insight on what you think about this please :)
>>      >>>>>>>
>>      >>>>>>> video: https://youtu.be/4SuUzma0Ua4
>>      >>>>>>>
>>      >>>>>>> (only tested in linux)
>>      >>>>>>>
>>      >>>>>>> - Kristoffer
>>      >>>>>>>
>>      >>>>>>>
>>      >>>>>>> _______________________________________________
>>      >>>>>>> Mailing list: https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>>>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>      >>>>>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>>>>> More help   : https://help.launchpad.net/ListHelp
>>     <https://help.launchpad.net/ListHelp>
>>      >>>>>>>
>>      >>>>>>
>>      >>>>>>
>>      >>>>>>
>>      >>>>>>
>>      >>>>>> _______________________________________________
>>      >>>>>> Mailing list: https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>      >>>>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>>>> More help   : https://help.launchpad.net/ListHelp
>>     <https://help.launchpad.net/ListHelp>
>>      >>>>>>
>>      >>>>>
>>      >>>>> _______________________________________________
>>      >>>>> Mailing list: https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>      >>>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>>> More help   : https://help.launchpad.net/ListHelp
>>     <https://help.launchpad.net/ListHelp>
>>      >>>>
>>      >>>>
>>      >>>> _______________________________________________
>>      >>>> Mailing list: https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>      >>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>>> More help   : https://help.launchpad.net/ListHelp
>>     <https://help.launchpad.net/ListHelp>
>>      >>>>
>>      >>>
>>      >>> _______________________________________________
>>      >>> Mailing list: https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>      >>> Unsubscribe : https://launchpad.net/~kicad-developers
>>     <https://launchpad.net/~kicad-developers>
>>      >>> More help   : https://help.launchpad.net/ListHelp
>>     <https://help.launchpad.net/ListHelp>
>>      >>
>>
>>



Follow ups

References