Hi everyone,
I have a problem I really don't understand. For a project, I created a toolbar (like ActionBar_ plugin) to launch some macros and plugins. To launch my macros, I used IJ.runMacroFile(macroFile, arguments); My problem is: I have one macro which works perfectly when I do Plugins>Macros>Run. But doesn't work when I launch it from my toolbar. This macro helps to select a precise point of an image. It creates an other image as a "zoom", and copies (in the zoom frame) an area around the cursor (I hope I'm clear enough...). To get the cursor position, I used getCursorLoc(x, y, z, flags); in a loop. I have a condition to stop when flags!=0 and leftButton!=0 : the user clicked somewhere, I open a window to confirm his selection. Like I said, when I launch my macro from ImageJ menu, it works perfectly. But when I launch it from my toolbar, it seems to be in a infinite loop. After some debug, I think that 'flags' is always at 0 in my macro... [I don't know if my explanation is really clear... I'll try to copy my macro if you need it.] What could cause this problem? Is there a notion of threads? Thanks, Amelie Marzin |
Trying to help you I ran a macro from the plugins>macros>run menu while recording, and it wrote "runMacro(<macrofile>)" instead of "runMacroFile(<macrofile>, <args>)".
Maybe there are two methods and you are calling a different one than the menu. If your macro is not so long, it might help if you paste it in your next email, so we can run it by ourselves :) On Apr 5, 2011, at 2:50 PM, Amelie Marzin wrote: > Hi everyone, > > I have a problem I really don't understand. > > For a project, I created a toolbar (like ActionBar_ plugin) to launch some macros and plugins. To launch my macros, I used > IJ.runMacroFile(macroFile, arguments); > > My problem is: I have one macro which works perfectly when I do Plugins>Macros>Run. But doesn't work when I launch it from my toolbar. > This macro helps to select a precise point of an image. It creates an other image as a "zoom", and copies (in the zoom frame) an area around the cursor (I hope I'm clear enough...). > To get the cursor position, I used > getCursorLoc(x, y, z, flags); > in a loop. I have a condition to stop when flags!=0 and leftButton!=0 : the user clicked somewhere, I open a window to confirm his selection. > > Like I said, when I launch my macro from ImageJ menu, it works perfectly. But when I launch it from my toolbar, it seems to be in a infinite loop. After some debug, I think that 'flags' is always at 0 in my macro... > > [I don't know if my explanation is really clear... I'll try to copy my macro if you need it.] > > > What could cause this problem? Is there a notion of threads? > > Thanks, > > Amelie Marzin ------------------------------------------------------------ Juanjo Vega ([hidden email]) Unidad de Biocomputación. Laboratorio B-13. Centro Nacional de Biotecnología. CNB-CSIC. C\ Darwin, 3. Campus de Cantoblanco. Universidad Autónoma de Madrid. 28049, Madrid, Spain. http://www.cnb.csic.es http://www.biocomp.cnb.csic.es +34 91 585 4510 "Las mejores almas son capaces de los mayores vicios como de las mayores virtudes, y aquellos que caminan despacio por el camino recto pueden llegar más lejos que los que corren pero se apartan de él." - Discurso del Método, René Descartes. |
In reply to this post by Amelie Marzin
Unfortunately, my macro is quite long, plus I have some difficulties to paste it (I work on a different computer, which prevent file transfert...).
I tried to use IJ.runMacro(<macro>, <args>) and even IJ.run("Run ...","run=[<macrofile>]") : same problem. It seems that because my macro is not launch from from the usual frame, it doesn't get all informations... If you have any idea, it would be really useful. Even if it's not code, I can explore and test by myself ! |
It's a bit difficult to figure out what's going wrong with your macro without having a look to it.
People use to paste small versions of their code focusing the problem, so we can debug the problematic part of it. I don't have many new ideas about this issue, but I think that you may try to develop a plugin just for the part about that "flag" to see if you still have the same problem. Anyway, I think it should work from the action bar as well. I call plugins from a menu in one of my plugins by using "IJ.run(..." and it works. Hope this helps On Apr 7, 2011, at 11:27 AM, Amelie Marzin wrote: > Unfortunately, my macro is quite long, plus I have some difficulties to paste it (I work on a different computer, which prevent file transfert...). > > I tried to use IJ.runMacro(<macro>, <args>) and even IJ.run("Run ...","run=[<macrofile>]") : same problem. > > It seems that because my macro is not launch from from the usual frame, it doesn't get all informations... > > If you have any idea, it would be really useful. Even if it's not code, I can explore and test by myself ! ------------------------------------------------------------ Juanjo Vega ([hidden email]) Unidad de Biocomputación. Laboratorio B-13. Centro Nacional de Biotecnología. CNB-CSIC. C\ Darwin, 3. Campus de Cantoblanco. Universidad Autónoma de Madrid. 28049, Madrid, Spain. http://www.cnb.csic.es http://www.biocomp.cnb.csic.es +34 91 585 4510 "Las mejores almas son capaces de los mayores vicios como de las mayores virtudes, y aquellos que caminan despacio por el camino recto pueden llegar más lejos que los que corren pero se apartan de él." - Discurso del Método, René Descartes. |
Amélie,
I would suggest that you use a Tool macro instead of a simple macro loop that waits for a getCursorLoc flags event. So basically your plugin should only install and select this Tool. Then clicking in the image will trigger the Tool macro, and this is very reliably handled by ImageJ. Jerome On Thu, Apr 7, 2011 at 11:38 AM, Juanjo Vega <[hidden email]> wrote: > It's a bit difficult to figure out what's going wrong with your macro > without having a look to it. > > People use to paste small versions of their code focusing the problem, so > we can debug the problematic part of it. > > I don't have many new ideas about this issue, but I think that you may try > to develop a plugin just for the part about that "flag" to see if you still > have the same problem. > > Anyway, I think it should work from the action bar as well. I call plugins > from a menu in one of my plugins by using "IJ.run(..." and it works. > > Hope this helps > > On Apr 7, 2011, at 11:27 AM, Amelie Marzin wrote: > > > Unfortunately, my macro is quite long, plus I have some difficulties to > paste it (I work on a different computer, which prevent file transfert...). > > > > I tried to use IJ.runMacro(<macro>, <args>) and even IJ.run("Run > ...","run=[<macrofile>]") : same problem. > > > > It seems that because my macro is not launch from from the usual frame, > it doesn't get all informations... > > > > If you have any idea, it would be really useful. Even if it's not code, I > can explore and test by myself ! > > ------------------------------------------------------------ > Juanjo Vega ([hidden email]) > > Unidad de Biocomputación. Laboratorio B-13. > Centro Nacional de Biotecnología. CNB-CSIC. > C\ Darwin, 3. Campus de Cantoblanco. > Universidad Autónoma de Madrid. > 28049, Madrid, Spain. > > http://www.cnb.csic.es > http://www.biocomp.cnb.csic.es > > +34 91 585 4510 > > "Las mejores almas son capaces de los mayores vicios como de las mayores > virtudes, y aquellos que caminan despacio por el camino recto pueden > llegar más lejos que los que corren pero se apartan de él." - Discurso > del Método, René Descartes. > |
Free forum by Nabble | Edit this page |