Macro: Switch between interactive and batch mode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro: Switch between interactive and batch mode

karo03
Hi, I have a possibly minor problem:
Inside a macro I would like to switch over into interactive mode e.g.  
to correct manually a mask automatically generated by "setThreshold
()" and "Convert to Mask" and than after finishing corrections to  
proceed with the macro. As far as I see "setBatchMode(false)" does  
not allow to interrupt macro processing.

Thanks in advance
KArsten
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Switch between interactive and batch mode

Volker Baecker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
As a workaround you can use something like this:

for (i=0;i<10;i++) {
        setBatchMode(false);
        newImage("wait", "8-bit White", 100, 100, 1);
        drawString("close to continue!", 10, 30);
        while(isOpen("wait")) {
                wait(10);
        }
        print(i);
        setBatchMode(true);
}

I don't know if there is a better way in ImageJ to do what you want.

Using my visual scripting plugin you can use:
        setBatchMode(false);
        call("operations.Operation.run", "wait for user","");
        setBatchMode(true);
in a macro, which opens a button with the text continue and stops the
macro until the button is pressed.

Volker


Karsten Rodenacker a écrit :

> Hi, I have a possibly minor problem:
> Inside a macro I would like to switch over into interactive mode e.g. to
> correct manually a mask automatically generated by "setThreshold()" and
> "Convert to Mask" and than after finishing corrections to proceed with
> the macro. As far as I see "setBatchMode(false)" does not allow to
> interrupt macro processing.
>
> Thanks in advance
> KArsten
>
> --passerelle antivirus du campus CNRS de Montpellier
> --
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGghdGxZKX7A/4oMERArnpAJ92o1Vq+37CkrQ9ZF0c0k9pUA3o4wCfYXKZ
3j/L07PcRibT4E8h05iOKqw=
=/m1/
-----END PGP SIGNATURE-----

--
passerelle antivirus du campus CNRS de Montpellier
--
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Switch between interactive and batch mode

jmutterer
In reply to this post by karo03
Karsten, you could split your macro and call each part from an "Action Tool"
toolbar button. You should remember to use global variables if you want to
share variables between macros.

If you don't want to use toolbar buttons because you need some special tools
installed, you can call bits of macro code or run macros files from an
"Action Bar" with buttons reflecting the proccessing steps. See
http://imagejdocu.tudor.lu/Members/jmutterer/Action_Bar/

Jerome

On 6/27/07, Karsten Rodenacker <[hidden email]> wrote:

>
> Hi, I have a possibly minor problem:
> Inside a macro I would like to switch over into interactive mode e.g.
> to correct manually a mask automatically generated by "setThreshold
> ()" and "Convert to Mask" and than after finishing corrections to
> proceed with the macro. As far as I see "setBatchMode(false)" does
> not allow to interrupt macro processing.
>
> Thanks in advance
> KArsten
>
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Switch between interactive and batch mode

karo03
In reply to this post by Volker Baecker
Thank you Volker and Jerome
The first workaround is good. Not just elegant but effective.
The splitting of the macro recommended by Jerome is slightly less  
elegant.
To use the visual script environment I will try later. It seems me a  
bit complicated to embed it into my actual ImageJ/plugin structure.  
Isn't it possible to have the "operation" plugin without the other  
things?
Regards
Karsten
Am 27.06.2007 um 09:52 schrieb Volker Bäcker:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
> As a workaround you can use something like this:
>
> for (i=0;i<10;i++) {
> setBatchMode(false);
> newImage("wait", "8-bit White", 100, 100, 1);
> drawString("close to continue!", 10, 30);
> while(isOpen("wait")) {
> wait(10);
> }
> print(i);
> setBatchMode(true);
> }
>
> I don't know if there is a better way in ImageJ to do what you want.
>
> Using my visual scripting plugin you can use:
> setBatchMode(false);
> call("operations.Operation.run", "wait for user","");
> setBatchMode(true);
> in a macro, which opens a button with the text continue and stops the
> macro until the button is pressed.
>
> Volker
>
>
> Karsten Rodenacker a écrit :
>> Hi, I have a possibly minor problem:
>> Inside a macro I would like to switch over into interactive mode  
>> e.g. to
>> correct manually a mask automatically generated by "setThreshold
>> ()" and
>> "Convert to Mask" and than after finishing corrections to proceed  
>> with
>> the macro. As far as I see "setBatchMode(false)" does not allow to
>> interrupt macro processing.
>>
>> Thanks in advance
>> KArsten
>>
>> --passerelle antivirus du campus CNRS de Montpellier
>> --
>>
>>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGghdGxZKX7A/4oMERArnpAJ92o1Vq+37CkrQ9ZF0c0k9pUA3o4wCfYXKZ
> 3j/L07PcRibT4E8h05iOKqw=
> =/m1/
> -----END PGP SIGNATURE-----
>
> --
> passerelle antivirus du campus CNRS de Montpellier
> --
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Switch between interactive and batch mode

Volker Baecker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Please look at
http://www.mri.cnrs.fr/mriwiki/index.php?pagename=Wait%20For%20User.
Tell me if it works.
Volker

Karsten Rodenacker a écrit :

> Thank you Volker and Jerome
> The first workaround is good. Not just elegant but effective.
> The splitting of the macro recommended by Jerome is slightly less elegant.
> To use the visual script environment I will try later. It seems me a bit
> complicated to embed it into my actual ImageJ/plugin structure. Isn't it
> possible to have the "operation" plugin without the other things?
> Regards
> Karsten
> Am 27.06.2007 um 09:52 schrieb Volker Bäcker:
>
> Hi,
> As a workaround you can use something like this:
>
> for (i=0;i<10;i++) {
>     setBatchMode(false);
>     newImage("wait", "8-bit White", 100, 100, 1);
>     drawString("close to continue!", 10, 30);
>     while(isOpen("wait")) {
>         wait(10);
>     }
>     print(i);
>     setBatchMode(true);
> }
>
> I don't know if there is a better way in ImageJ to do what you want.
>
> Using my visual scripting plugin you can use:
>     setBatchMode(false);
>     call("operations.Operation.run", "wait for user","");
>     setBatchMode(true);
> in a macro, which opens a button with the text continue and stops the
> macro until the button is pressed.
>
> Volker
>
>
> Karsten Rodenacker a écrit :
>>>> Hi, I have a possibly minor problem:
>>>> Inside a macro I would like to switch over into interactive mode e.g. to
>>>> correct manually a mask automatically generated by "setThreshold()" and
>>>> "Convert to Mask" and than after finishing corrections to proceed with
>>>> the macro. As far as I see "setBatchMode(false)" does not allow to
>>>> interrupt macro processing.
>>>>
>>>> Thanks in advance
>>>> KArsten
>>>>
>>>> --passerelle antivirus du campus CNRS de Montpellier
>>>> --
>>>>
>>
- --passerelle antivirus du campus CNRS de Montpellier
- --

> --passerelle antivirus du campus CNRS de Montpellier
> --


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGgmIOxZKX7A/4oMERAo9IAKC+ASpOQiRDyD6tIsB6Y/0/pxUsUwCgwUKo
TJL9jakVPcKnZ1L2r7+koyo=
=Y1f3
-----END PGP SIGNATURE-----

--
passerelle antivirus du campus CNRS de Montpellier
--