Displaying Graphics problem and buttons question

Hello everybody,
I'm a newbie here :)

I just changed my version of Igor from the 5.05A to the 6.34A and without changing it, I tryed to execute a graphical macro (listed under this message).

When this part of my program was executed by the version 5.05A, everything was displayed fast. But with the version 6.34A, it takes 4 times longer to display.

Do I have to add some flags or other commands to the code in order to adapt it to this new version ?
Or is my computer (Win7, Intel i3-3220, RAM:8Go, 64bits) not powerfull enough ?


Moreover, I want to include "buttons" in the last panel. But I didn't find how to make them work. When I clic on one button on the panel an error message appears (While starting up macro "macro": expected right parenthesis)

Do I need an additional function to link the button to the macro (or function) that I want to execute while pressing the button ?




Thank you very much :)
Macro GraphicsInit()
   
    Variable/G Isup, Iinf, Nsup, Ninf, Bsup, Binf           // Low and High limits
    Variable/G Iavg, Imed, Navg, Nmed, Bavg, Bmed       // Average and Median values

    Silent 1   
   
    DoWindow/K Prog_Window
   
    Display/W=(2,2,1145,595)/N=Prog_Window/K=1      // Creates main window
   
//          -------------------------------------------------------------------------  
//                      Displays the 3 maps:
   
    Display/HOST=Prog_Window/W=(2,22,200,200)/N=Map1; AppendImage Intensity
    ModifyImage Intensity ctab={*,*,SpectrumBlack,0}
    Label left "y position"
    Label bottom "x position"
    DrawText/W=Prog_Window 0.1,0.04,"Intensity"
   
   
    Display/HOST=Prog_Window/W=(202,22,400,200)/N=Map2; AppendImage Number
    ModifyImage Number ctab={*,*,Spectrum,0}
    Label left "y position"
    Label bottom "x position"
    DrawText/W=Prog_Window 0.31,0.04,"Number"
       
    Display/HOST=Prog_Window/W=(402,22,600,200)/N=Map3; AppendImage Brightness
    ModifyImage Brightness ctab={*,*,Spectrum,0}
    Label left "y position"
    Label bottom "x position"
    DrawText/W=Prog_Window 0.51,0.04,"Brightness"
       
//          -------------------------------------------------------------------------
//                  Displays the 3 Versus graphics:
   
    Display/HOST=Prog_Window/W=(630,15,805,190)/N=BvsN VBright vs VNum
    ModifyGraph mode=3,marker=19,rgb=(0,0,65280),msize=0.2
    Label left "Brightness"
    Label bottom "Number"
   
    Display/HOST=Prog_Window/W=(630,210,805,385)/N=BvsI VBright vs VInt
    ModifyGraph mode=3,marker=19,rgb=(0,0,65280),msize=0.2
    Label left "Brightness"
    Label bottom "Intensity"
   
    Display/HOST=Prog_Window/W=(630,405,805,580)/N=NvsI VNum vs VInt
    ModifyGraph mode=3,marker=19,rgb=(0,0,65280),msize=0.2
    Label left "Number"
    Label bottom "Intensity"
   
//          -------------------------------------------------------------------------  
//                  Displays the 3 histograms :
   
    Display/HOST=Prog_Window/W=(25,225,175,375) /N=Histogram1 IntensityHisto
    ModifyGraph mode=5,hbFill=2,toMode=1,rgb=(17408,17408,17408), log(left)=1;DelayUpdate
    Label left "Nb of Occurences"
    Label bottom "Intensity"
   
    Display/HOST=Prog_Window/W=(225,225,375,375) /N=Histogram2 NumberHisto
    ModifyGraph mode=5,hbFill=2,toMode=1,rgb=(17408,17408,17408), log(left)=1;DelayUpdate
    Label left "Nb of Occurences"
    Label bottom "Number"
       
    Display/HOST=Prog_Window/W=(425,225,575,375) /N=Histogram3 BrightnessHisto
    ModifyGraph mode=5,hbFill=2,toMode=1,rgb=(17408,17408,17408), log(left)=1;DelayUpdate
    Label left "Nb of Occurences"
    Label bottom "Brightness"  
   
//          -------------------------------------------------------------------------
//                  Creates an input panel:    
   
    NewPanel /K=1/W=(30,400,425,560)/HOST=Prog_Window
    ShowTools
    SetDrawLayer UserBack
    SetDrawEnv linebgc= (0,15872,65280),fillfgc= (0,15872,65280);DelayUpdate
    DrawRect 526,5,6,209
    SetDrawEnv fillfgc= (65535,65535,65535), textrgb= (26112,0,0);DelayUpdate
    DrawRect 26,45,83,70
    DrawText 31,65,"Intensity"
    SetDrawEnv fillfgc= (65535,65535,65535), textrgb= (26112,0,0);DelayUpdate
    DrawRect 26,95,83,120
    DrawText 31,115,"Number"
    SetDrawEnv fillfgc= (65535,65535,65535), textrgb= (26112,0,0);DelayUpdate
    DrawRect 18,156,90,181
    DrawText 23,176,"Brightness"
    SetDrawEnv textrgb= (65535,65535,65535);DelayUpdate
    DrawText 299,36,"Avg."
    SetDrawEnv textrgb= (65535,65535,65535);DelayUpdate
    DrawText 386,36,"Med."
    ValDisplay AvgI pos={285,46}, frame=2, labelBack=(65535,65535,65535), value=Iavg
    ValDisplay MedI pos={372,46}, frame=2, labelBack=(65535,65535,65535), value=Imed
    ValDisplay AvgN pos={285,104}, frame=2, labelBack=(65535,65535,65535), value=Navg
    ValDisplay MedN pos={372,104}, frame=2, labelBack=(65535,65535,65535), value=Nmed
    ValDisplay AvgB pos={285,158}, frame=2, labelBack=(65535,65535,65535), value=Bavg
    ValDisplay MedB pos={372,158}, frame=2, labelBack=(65535,65535,65535), value=Bmed
       
               
       
    SetVariable setvar0,pos={98,39},size={123,16},title="Inf. Lim."         // Input of the values for the
    SetVariable setvar0,limits={-5,200,0.01},value= Iinf                        // Intensity, the Number and
    SetVariable setvar1,pos={142,58},size={123,16},title="Sup. Lim."            // The Brightness
    SetVariable setvar1,limits={-5,200,0.01},value= Isup
    SetVariable setvar2,pos={98,92},size={123,16},title="Inf. Lim."
    SetVariable setvar2,limits={-5,200,0.01},value= Ninf
    SetVariable setvar3,pos={142,113},size={123,16},title="Sup. Lim."
    SetVariable setvar3,limits={-5,200,0.01},value= Nsup
    SetVariable setvar4,pos={98,149},size={123,16},title="Inf. Lim."
    SetVariable setvar4,limits={-5,200,0.01},value= Binf
    SetVariable setvar5,pos={142,172},size={123,16},title="Sup. Lim."
    SetVariable setvar5,limits={-5,200,0.01},value= Bsup
   
    Button LimIntensity proc=IntensityModif, pos={446,46}, title="ChangeInt"
    Button LimNumber proc=NumberModif, pos={446,113}, title="ChangeNum"
    Button LimBrightness proc=BrightnessModif, pos={444,158}, title="ChangeBright"
   
   
   
    DoAlert 0, "Graphics are now initialized"
   
   
endmacro
Quote:
Hello everybody, I'm a newbie here :)


Bienvenue!

When adding Igor code to a post on the forum, put the code between <igor> and </igor> tags to identify it as Igor code. This is explained here:
http://www.igorexchange.com/node/3221

I can't run your code because it references waves that I don't have. Create an experiment, simplified if possible, and post the experiment file as an attachement to a post in this thread.

Quote:
Do I need an additional function to link the button to the macro (or function) that I want to execute while pressing the button?


You have commands like this:
Button LimIntensity proc=IntensityModif, pos={446,46}, title="ChangeInt"


but your posted code does not include the IntensityModif function.

To see how to create a button with an action, in a new experiment create a new panel, add a button, kill the panel and look at the recreation macro. This is equivalent to the following commands:
NewPanel
ShowTools/A arrow
Button button0 title="Test",proc=ButtonProc
HideTools
DoWindow/K/R Panel0


See the reference documentation for Button. In the Details section, it explains the format and operation of the button action procedure.



Thank you very much for your answer !

Okay,
I tryed to simplify my code (please see experiment file attached).

In order to check my problem for displaying graphics in the main window, please execute in the "Programme" menu the macro: "GraphicsInit".
This problem is mainly a time of display problem.


Then inside the code, I put back the macro GraphicsInit() where there is the "button" I want to use.
This "button" is linked to the proc "ValuesModif()".

Before asking for help in the IgorExchange forum, I read the help files, the .pdf tutorials for Igor control panels [http://www.wavemetrics.net/doc/igorman/III-14%20Control%20Panels.pdf] but I didn't find or didn't understand the answer for my problem.

It's probably nothing (just a missing flag or something very easy to fix) but since it's the first time I'm using this kind of control, I don't know how to build a working "button"
Your experiment file requires the procedure file "Simplified Procedure.ipf". The best way to handle this is to "adopt" external files. To do that, hold down the shift key, pull down the File menu and select Adopt All. In the dialog, make sure User Procedure Files is checked (the others are recommended but less likely to be needed). You don't need to check the Adopt WaveMetrics Procedure Files, as anyone with a correct installation has those.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Info supplement for lag in display

I found, that, when changing the order of display :

Before = 3 Images, 3 Versus graphics, 3 histograms, 1 panel
After = 3 images, 3 histograms, 1 panel, 3 Versus graphics

the time to display the window is very fast untill the Versus Graphics are displayed.

I tried to display everything without the line :
ModifyGraph/W=Prog_Window#BvsI mode=3,marker=19,rgb=(0,0,65280),msize=0.2


[just adding // in front of the line],
and everything was displayed very fast.

The problem seems to be inside the "ModifyGraph" function.

When I write the instruction like this :

ModifyGraph/W=Prog_Window#BvsI mode=3,msize=0.2,rgb=(0,0,65280)


without the marker=xx instruction, the displaying time is acceptable (display just slows down a little bit).

But when I add this instruction (even if I replace another one with this one), everything is lagging.
I changed the display mode of the scatter plots to dots with size of 2. That improves the speed of displaying the graph a great deal. Since your markers are so small I don't think it changes the appearance a great deal.

As for Proc ValuesModif()...

1) Button action procedures are required to follow a very specific format. If you use the Control Properties dialog (the dialog you get if you double-click the button while in draw mode) you will find to the right of the menu where you choose an action procedure a button "New...". That will put up another dialog that gives a starter code for the action procedure. That is the easiest way to find the right format.

2) I do not recommend using Proc. It is better to use Functions, they are faster and new programming features are put into functions, and usually not into Procs. Functions, because they are compiled, must analyze the syntax and therefore can give you more complete error messages sooner. With a Proc you get an error message only for lines that actually execute, and only at run time when it is more difficult to deal with.

3) I recommend using the newer format for action procedures that use a structure, although for buttons the action is so simple it doesn't really make a lot of difference.


I started fixing ValuesModif():
Function ValuesModif(ctrlName) : ButtonControl
    String ctrlName

   
    Limitates()
   
    Make/N=100/D/O IntensityHisto;DelayUpdate   // Creates a vector to receive the Histogram
    Histogram/B=1 VInt,IntensityHisto               // Builds the histogram with auto-settings

    Make/N=100/D/O NumberHisto;DelayUpdate      // Creates a vector to receive the Histogram
    Histogram/B=1 VNum,NumberHisto              // Builds the histogram with auto-settings
   
    Make/N=100/D/O BrightnessHisto;DelayUpdate  // Creates a vector to receive the Histogram
    Histogram/B=1 VBright,BrightnessHisto           // Builds the histogram with auto-settings
   
    Wavestats/Q VInt
    NVAR Iavg
    Iavg=V_avg
    NVAR Imed
    Imed=Median(VInt)
   
    Wavestats/Q VNum
    NVAR Navg
    Navg=V_avg
    NVAR Nmed
    Nmed=Median(VNum)
   
    Wavestats/Q VBright
    NVAR Bavg
    Bavg=V_avg
    NVAR Bmed
    Bmed=Median(VBright)
   
    DoUpdate                                    // update windows

End

I don't know if I got it completely right because the function Median doesn't exist in the experiment. But the format is now correct for a button action procedure and the global references are declared.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thank you very much !

The dots with size of 2 in the graphics is perfect.

For the button function I didn't know I had to put a "ctrl" in input of the function even if I don't need one.

Function ValuesModif(ctrlName) : ButtonControl
    String ctrlName


The median function just calculates the median value of my vectors but this part was working well.


Thank you again for your help !