[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: PCB - How To Find A Component?
Hi all,
On Fri, 2009-02-13 at 05:53 -0500, gene wrote:
> > *Scrolling* to the selected part would be easier, and could be done as
> > a plugin. Compare with my findrat plugin:
> >
> > http://www.delorie.com/pcb/findrat.c
>
> >
>
> I don't even know where to begin :( How do the plugins get compiled and
> executed? Is there some docs somewhere?
>
> gene
>
> I tried to get a plug-in together using findrat.c (by DJ) as a template.
I does compile with some warnings and then segfaults when run.
gdb says the culprit lives in line 71, near the strcmp () call.
Maybe I'm overlooking something very obvious and better should restart
tomorrow morning after some coffee.
Anyway I think I would like my attempt sofar.
Kind regards,
Bert Timmerman.
/*!
* \file findelement.c
* \author Copyright (C) 2009 by Bert Timmerman <bert.timmerman@xxxxxxxxx>
* \brief Plug-in for PCB to find the specified element.
*
* Function to look up the specified PCB element on the screen.\n
* \n
* Compile like this:\n
* \n
* gcc -Ipath/to/pcb/src -Ipath/to/pcb -O2 -shared findelement.c -o findelement.so
* \n\n
* The resulting findelement.so file should go in $HOME/.pcb/plugins/\n
* \n
* \warning Be very strict in compiling this plug-in against the exact pcb
* sources you compiled/installed the pcb executable (i.e. src/pcb) with.\n
*
* Usage: FindElement(Refdes)\n
* \n
* If no argument is passed, no action is carried out.\n
*
* <hr>
* This program is free software; you can redistribute it and/or modify\n
* it under the terms of the GNU General Public License as published by\n
* the Free Software Foundation; either version 2 of the License, or\n
* (at your option) any later version.\n
* \n
* This program is distributed in the hope that it will be useful,\n
* but WITHOUT ANY WARRANTY; without even the implied warranty of\n
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.\n
* \n
* You should have received a copy of the GNU General Public License\n
* along with this program; if not, write to:\n
* the Free Software Foundation, Inc.,\n
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n
*/
#include <stdio.h>
#include <math.h>
#include "global.h"
#include "data.h"
#include "hid.h"
#include "misc.h"
#include "create.h"
#include "rtree.h"
#include "undo.h"
#include "set.h"
/*!
* \brief Find the specified element.
*
* Usage: FindElement(Refdes)\n
* If no argument is passed, no action is carried out.
*/
static int
find_element (int argc, char **argv)
{
if (argc > 0 && strcasecmp (argv[0], "") == 0)
{
Message ("WARNING: in FindElement the argument should be a non-empty string value.\n");
return 0;
}
else
{
SET_FLAG (NAMEONPCBFLAG, PCB);
ELEMENT_LOOP(PCB->Data);
{
if (strcmp (argv[0], NAMEONPCB_NAME(element)) == 0)
{
gui->set_crosshair
(
element->MarkX,
element->MarkY,
HID_SC_PAN_VIEWPORT
);
}
}
END_LOOP;
gui->invalidate_all ();
IncrementUndoSerialNumber ();
return 0;
};
}
static HID_Action findelement_action_list[] =
{
{"FindElement", NULL, find_element, "Find the specified element", NULL},
{"FE", NULL, find_element, "Find the specified element", NULL}
};
REGISTER_ACTIONS (findelement_action_list)
void
pcb_plugin_init()
{
register_findelement_action_list();
}
/* EOF */
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user