app_peakfind.C

Go to the documentation of this file.
00001 /* Gnome gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999 The Free Software Foundation
00006  *
00007  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00008  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024 
00025 /* ignore tag evaluated by for docuscangxsmplugins.pl -- this is no main plugin file
00026 % PlugInModuleIgnore
00027 */
00028 
00029 #include "app_peakfind.h"
00030 
00031 #define DSP_CMD_PRB_RUNPF  1515
00032 
00033 
00034 DSPPeakFindControl::DSPPeakFindControl (XSM_Hardware *Hard, GSList **RemoteEntryList, int InWindow)
00035 {
00036                 GtkWidget *box;
00037 
00038                 PI_DEBUG (DBG_L2, "DSPPeakFindControl::DSPPeakFindControl");
00039 
00040                 hard=Hard;
00041                 itab=0;
00042                 IdPFtmout=0;
00043                 PFtmoutms=2000;
00044 
00045                 PfpList = NULL;
00046 
00047 #define VOLT_MAX 10.
00048 #define VOLT_MIN -10.
00049 
00050                 Unity       = new UnitObj(" "," ");
00051                 Volt        = new UnitObj("V","V", "g", "Volt");
00052                 TimeUnitms  = new LinUnit("ms","ms", "Time", 1e-3);
00053                 TimeUnit    = new UnitObj("s","s", "g", "Time");
00054                 CPSUnit     = new CPSCNTUnit("Cps","Cps","Intensity");
00055                 EnergyUnit  = new UnitObj("eV","eV","Energy");
00056 
00057                 pfscan = new PeakFindScan;
00058 
00059                 AppWidgetInit("DSP Peakfind/Focus/Oszi Control");
00060 
00061                 PI_DEBUG (DBG_L2, "DSPPeakFindControl::DSPPeakFindControl widget setup ");
00062 
00063                 box = gtk_vbox_new (FALSE, 0);
00064                 gtk_widget_show (box);
00065                 gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00066 
00067                 notebook = gtk_notebook_new ();
00068                 gtk_widget_show (notebook);
00069                 gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, GNOME_PAD);
00070 
00071                 addPFfolder();
00072                 addPFcontrol(box);
00073 }
00074 
00075 DSPPeakFindControl::~DSPPeakFindControl (){
00076                 PI_DEBUG (DBG_L2, "DSPPeakFindControl::~DSPPeakFindControl" );
00077 
00078                 rmPFtmout();
00079 
00080                 //  nodestroy=TRUE;
00081                 //  while(gtk_events_pending()) gtk_main_iteration();
00082                 //  destroy();
00083                 //  while(gtk_events_pending()) gtk_main_iteration();
00084 
00085                 g_slist_foreach(PfpList, (GFunc) DSPPeakFindControl::delete_pfp_cb, this);
00086                 g_slist_free(PfpList);
00087   
00088                 delete pfscan;
00089   
00090                 delete Unity;
00091                 delete Volt;
00092                 delete TimeUnitms;
00093                 delete TimeUnit;
00094                 delete CPSUnit;
00095                 delete EnergyUnit;
00096   
00097                 PI_DEBUG (DBG_L2, "done." );
00098 }
00099 
00100 
00101 void DSPPeakFindControl::addPFcontrol(GtkWidget *box){
00102                 GtkWidget *frame_param, *vbox_param, *hbox_param;
00103 
00104                 GtkWidget *input;
00105                 GtkWidget *button;
00106 
00107                 Gtk_EntryControl *ec;
00108 
00109                 PI_DEBUG (DBG_L2, "Adding PF Control Widget" );
00110 
00111                 GSList *EC_list=(GSList*)gtk_object_get_data( GTK_OBJECT (widget), "Probe_EC_list"); // get list
00112 
00113                 frame_param = gtk_frame_new ("Global Peak Finder Control");
00114                 gtk_widget_show (frame_param);
00115                 gtk_container_add (GTK_CONTAINER (box), frame_param);
00116 
00117                 vbox_param = gtk_vbox_new (FALSE, 0);
00118                 gtk_widget_show (vbox_param);
00119                 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00120 
00121                 // PF parameters
00122                 input = mygtk_create_input("Timeout [ms]:", vbox_param, hbox_param);
00123                 ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &PFtmoutms, 100., 100000., "6.0f", input);
00124   
00125                 //  input = mygtk_add_input("Y0", hbox_param);
00126                 //  ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->y0, -200., 200., "5.3f", input);
00127 
00128 
00129                 hbox_param = gtk_hbox_new(FALSE, 0);
00130                 gtk_widget_show (hbox_param);
00131                 gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00132 
00133 #define DSP_CMD_PRB_RUNPFI0 1516
00134 #define DSP_CMD_PRB_DELPFI0 1517
00135 #define DSP_CMD_PRB_PFreset 1518
00136 #define DSP_CMD_PRB_PFsaveNc 1519
00137 
00138                 button = gtk_button_new_with_label("Run");
00139                 gtk_widget_show (button);
00140                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00141                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_PRB_RUNPFI0);
00142                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00143                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::CmdAction),
00144                                                          this);
00145 
00146                 button = gtk_button_new_with_label("Stop");
00147                 gtk_widget_show (button);
00148                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00149                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_PRB_DELPFI0);
00150                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00151                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::CmdAction),
00152                                                          this);
00153 
00154                 button = gtk_button_new_with_label("Reset");
00155                 gtk_widget_show (button);
00156                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00157                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_PRB_PFreset);
00158                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00159                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::CmdAction),
00160                                                          this);
00161 
00162                 button = gtk_button_new_with_label("SaveNc");
00163                 gtk_widget_show (button);
00164                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00165                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_PRB_PFsaveNc);
00166                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00167                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::CmdAction),
00168                                                          this);
00169 
00170   
00171                 // save list away...
00172                 gtk_object_set_data( GTK_OBJECT (widget), "Probe_EC_list", EC_list);
00173 }
00174 
00175 void DSPPeakFindControl::addPFfolder(){
00176 
00177 #define LABENTRYSIZES 70,100
00178 
00179                 static int bf_num=0;
00180                 GtkWidget *frame_param, *vbox_nb, *vbox_param, *hbox_param, *hbox, *vbox_r, *hbox_r, *hpaned;
00181                 GtkWidget *PeakFindCtrl;
00182 
00183                 GtkWidget *input;
00184                 GtkWidget *button;
00185 
00186                 Gtk_EntryControl *ec;
00187                 remote_action_cb *ra;
00188 
00189                 GSList *EC_list=(GSList*)gtk_object_get_data( GTK_OBJECT (widget), "Probe_EC_list"); // get list
00190 
00191                 gchar *tmp;
00192 
00193                 SPA_PeakFind_p *pfp;
00194 
00195                 PI_DEBUG (DBG_L2, "---- Adding PF Folder ----" );
00196 
00197                 pfp = new SPA_PeakFind_p(bf_num);
00198                 PfpList = g_slist_prepend( PfpList, pfp);
00199 
00200                 // add to notebook folder...
00201                 hpaned = gtk_hpaned_new ();
00202                 gtk_widget_show (hpaned);
00203                 //  gtk_container_add (GTK_CONTAINER (notebook), hpaned);
00204                 //  gtk_paned_set_position (GTK_PANED (hpaned), -1);
00205 
00206                 vbox_nb = gtk_vbox_new (FALSE, 0);
00207                 gtk_widget_show (vbox_nb);
00208                 gtk_paned_pack1 (GTK_PANED (hpaned), vbox_nb, FALSE, TRUE);
00209   
00210                 // set label
00211                 tmp = g_strdup_printf("PF-%d",++bf_num);
00212                 PeakFindCtrl = gtk_label_new (tmp);
00213                 g_free(tmp);
00214                 gtk_widget_show (PeakFindCtrl);
00215                 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hpaned, PeakFindCtrl);
00216                 itab++;
00217 // set_notebook_tab (notebook, itab++, PeakFindCtrl);
00218   
00219                 // make frame, attach to folder
00220                 frame_param = gtk_frame_new ("Peak Finder / Monitor");
00221                 gtk_widget_show (frame_param);
00222                 gtk_container_add (GTK_CONTAINER (vbox_nb), frame_param);
00223   
00224                 // make hbox, left visible, righr on demand !
00225                 hbox = gtk_hbox_new (FALSE, 0);
00226                 gtk_widget_show (hbox);
00227                 gtk_container_add (GTK_CONTAINER (frame_param), hbox);
00228 
00229                 vbox_param = gtk_vbox_new (FALSE, 0);
00230                 gtk_widget_show (vbox_param);
00231                 gtk_container_add (GTK_CONTAINER (hbox), vbox_param);
00232 
00233                 // make invisible vbox right --------------------
00234                 hbox_r = gtk_hbox_new (FALSE, 0);
00235                 vbox_r = gtk_vbox_new (FALSE, 0);
00236                 gtk_widget_set_usize(hbox_r, -1, -1);
00237                 gtk_widget_set_usize(vbox_r, 200, -1);
00238 
00239                 gtk_box_pack_start (GTK_BOX (hbox_r), vbox_r, TRUE, TRUE, 0);
00240                 gtk_widget_show (vbox_r);
00241 
00242                 gtk_paned_pack2 (GTK_PANED (hpaned), hbox_r, FALSE, TRUE);
00243 
00244                 // pfp->focview = new Focus<long> (this, pfp, vbox_r, hbox_r);
00245                 pfp->focview = new Focus (this, pfp, vbox_r, hbox_r);
00246 
00247                 // -----------------------------------------------
00248 
00249                 // Special PF Action Toolbar
00250                 GtkWidget *toolbar = gtk_toolbar_new(); // GTK_ORIENTATION_HORIZONTAL,
00251 //                                      GTK_TOOLBAR_TEXT ); // ?????****** fixme
00252                 gtk_container_set_border_width ( GTK_CONTAINER ( toolbar ) , 5 );
00253 //  gtk_toolbar_set_space_size ( GTK_TOOLBAR ( toolbar ), 5 ); // ???***** fixme
00254                 gtk_container_add ( GTK_CONTAINER ( vbox_param ) , toolbar );
00255                 gtk_widget_show (toolbar);
00256 
00257                 //       gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar ) );
00258 
00259                 button = gtk_toolbar_prepend_item
00260                                 (  GTK_TOOLBAR ( toolbar ),
00261                                    "XY0",
00262                                    "copy found XY0 to Xorg",
00263                                    "tooltip_private_text",
00264                                    NULL, //   GtkWidget     *icon,
00265                                    GTK_SIGNAL_FUNC (DSPPeakFindControl::PFcpyorg),
00266                                    this );
00267                 gtk_widget_show (button);
00268                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_pfp",  (gpointer)pfp);
00269                 ra = g_new( remote_action_cb, 1);
00270                 ra -> cmd = g_strdup_printf("%s_XY0_%d", DSPPeakFind_pi.name, pfp->index+1);
00271                 ra -> RemoteCb = &DSPPeakFindControl::PFcpyorg;
00272                 ra -> widget = button;
00273                 ra -> data = this;
00274                 gapp->RemoteActionList = g_slist_prepend
00275                                 ( gapp->RemoteActionList, ra );
00276                 PI_DEBUG (DBG_L2, "Adding new Remote Cmd: " << ra->cmd );
00277 
00278                 // ----------
00279 
00280                 button = gtk_toolbar_prepend_item
00281                                 (  GTK_TOOLBAR ( toolbar ),
00282                                    "Offset from Main",
00283                                    "copy XY Offset from main to XYorg",
00284                                    "tooltip_private_text",
00285                                    NULL, //   GtkWidget     *icon,
00286                                    GTK_SIGNAL_FUNC (DSPPeakFindControl::PFcpyFromM),
00287                                    this );
00288                 gtk_widget_show (button);
00289                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_pfp",  (gpointer)pfp);
00290                 ra = g_new( remote_action_cb, 1);
00291                 ra -> cmd = g_strdup_printf("%s_OffsetFromMain_%d", DSPPeakFind_pi.name, pfp->index+1);
00292                 ra -> RemoteCb = & DSPPeakFindControl::PFcpyFromM;
00293                 ra -> widget = button;
00294                 ra -> data = this;
00295                 gapp->RemoteActionList = g_slist_prepend
00296                                 ( gapp->RemoteActionList, ra );
00297                 PI_DEBUG (DBG_L2, "Adding new Remote Cmd: " << ra->cmd );
00298 
00299                 // ----------
00300 
00301                 button = gtk_toolbar_prepend_item
00302                                 (  GTK_TOOLBAR ( toolbar ),
00303                                    "Offset to Main",
00304                                    "copy XY0 Offset to main",
00305                                    "tooltip_private_text",
00306                                    NULL, //   GtkWidget     *icon,
00307                                    GTK_SIGNAL_FUNC (DSPPeakFindControl::PFcpyToM),
00308                                    this );
00309                 gtk_widget_show (button);
00310                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_pfp",  (gpointer)pfp);
00311                 ra = g_new( remote_action_cb, 1);
00312                 ra -> cmd = g_strdup_printf("%s_OffsetToMain_%d", DSPPeakFind_pi.name, pfp->index+1);
00313                 ra -> RemoteCb = &DSPPeakFindControl::PFcpyToM;
00314                 ra -> widget = button;
00315                 ra -> data = this;
00316                 gapp->RemoteActionList = g_slist_prepend
00317                                 ( gapp->RemoteActionList, ra );
00318                 PI_DEBUG (DBG_L2, "Adding new Remote Cmd: " << ra->cmd );
00319 
00320                 button = gtk_toolbar_prepend_item
00321                                 (  GTK_TOOLBAR ( toolbar ),
00322                                    "E from Main",
00323                                    "copy Energy from main",
00324                                    "tooltip_private_text",
00325                                    NULL, //   GtkWidget     *icon,
00326                                    GTK_SIGNAL_FUNC (DSPPeakFindControl::PFcpyEfromM),
00327                                    this );
00328                 gtk_widget_show (button);
00329                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_pfp",  (gpointer)pfp);
00330                 ra = g_new( remote_action_cb, 1);
00331                 ra -> cmd = g_strdup_printf("%s_EfromMain_%d", DSPPeakFind_pi.name, pfp->index+1);
00332                 ra -> RemoteCb = &DSPPeakFindControl::PFcpyEfromM;
00333                 ra -> widget = button;
00334                 ra -> data = this;
00335                 gapp->RemoteActionList = g_slist_prepend
00336                                 ( gapp->RemoteActionList, ra );
00337                 PI_DEBUG (DBG_L2, "Adding new Remote Cmd: " << ra->cmd );
00338 
00339 
00340                 button = gtk_toolbar_prepend_item
00341                                 (  GTK_TOOLBAR ( toolbar ),
00342                                    "Run PF",
00343                                    "run PF once",
00344                                    "tooltip_private_text",
00345                                    NULL, //   GtkWidget     *icon,
00346                                    GTK_SIGNAL_FUNC (DSPPeakFindControl::CmdAction),
00347                                    this );
00348                 gtk_widget_show (button);
00349                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_PRB_RUNPF);
00350                 gtk_object_set_data( GTK_OBJECT (button), "DSP_PFP", (gpointer)pfp );
00351                 ra = g_new( remote_action_cb, 1);
00352                 ra -> cmd = g_strdup_printf("%s_RunPF_%d", DSPPeakFind_pi.name, pfp->index+1);
00353                 ra -> RemoteCb = &DSPPeakFindControl::CmdAction;
00354                 ra -> widget = button;
00355                 ra -> data = this;
00356                 gapp->RemoteActionList = g_slist_prepend
00357                                 ( gapp->RemoteActionList, ra );
00358                 PI_DEBUG (DBG_L2, "Adding new Remote Cmd: " << ra->cmd );
00359 
00360                 button = gtk_check_button_new_with_label ("Follow");
00361                 gtk_widget_show (button);
00362                 gtk_container_add (GTK_CONTAINER ( toolbar ), button);
00363                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_pfp",  (gpointer)pfp);
00364                 gtk_signal_connect (GTK_OBJECT (button), "clicked",
00365                                                         GTK_SIGNAL_FUNC (DSPPeakFindControl::PFfollow),
00366                                                         this);
00367 
00368                 // PF parameters
00369                 input = mygtk_create_input("Xorg:", vbox_param, hbox_param, LABENTRYSIZES);
00370                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->xorg, -200., 200., "5.3f", input);
00371                 EC_list = g_slist_prepend( EC_list, ec);
00372   
00373                 input = mygtk_add_input("Yorg", hbox_param, LABENTRYSIZES);
00374                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->yorg, -200., 200., "5.3f", input);
00375                 EC_list = g_slist_prepend( EC_list, ec);
00376   
00377 
00378                 input = mygtk_add_input("rel.Lim.", hbox_param, LABENTRYSIZES);
00379                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->rellim, -200., 200., "5.3f", input);
00380                 //  EC_list = g_slist_prepend( EC_list, ec);
00381   
00382                 // ----------------------------------------
00383   
00384                 input = mygtk_create_input("X0:", vbox_param, hbox_param, LABENTRYSIZES);
00385                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->x0, -200., 200., "5.3f", input);
00386                 EC_list = g_slist_prepend( EC_list, ec);
00387   
00388                 input = mygtk_add_input("Y0", hbox_param, LABENTRYSIZES);
00389                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->y0, -200., 200., "5.3f", input);
00390                 EC_list = g_slist_prepend( EC_list, ec);
00391   
00392                 input = mygtk_add_input("abs.Lim.", hbox_param, LABENTRYSIZES);
00393                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->abslim, -200., 200., "5.3f", input);
00394                 //  EC_list = g_slist_prepend( EC_list, ec);
00395   
00396 
00397                 // ----------------------------------------
00398 
00399                 input = mygtk_create_input("Points:", vbox_param, hbox_param, LABENTRYSIZES);
00400                 ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &pfp->npkte, 3., 500., "3.0f", input);
00401                 //  EC_list = g_slist_prepend( EC_list, ec);
00402                 //  ec->Set_ChangeNoticeFkt(DSPPeakFindControl::ChangedNotify, this);
00403                 //  EC_list = g_slist_prepend( EC_list, ec);
00404                 //  *RemoteEntryList = PrbLower->AddEntry2RemoteList("SPA_PF_POINTS", *RemoteEntryList);
00405   
00406                 input = mygtk_add_input("#P2d", hbox_param, LABENTRYSIZES);
00407                 ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &pfp->npkte2d, 3, 41., "5.3f", input);
00408                 //  EC_list = g_slist_prepend( EC_list, ec);
00409 
00410                 input = mygtk_add_input("Radius", hbox_param, LABENTRYSIZES);
00411                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->radius, 0.01, 100., "5.3f", input);
00412                 //  EC_list = g_slist_prepend( EC_list, ec);
00413 
00414                 // ----------------------------------------
00415   
00416                 input = mygtk_create_input("Gatetime:", vbox_param, hbox_param, LABENTRYSIZES);
00417                 ec = new Gtk_EntryControl(TimeUnitms, MLD_WERT_NICHT_OK, &pfp->gate, 1e-3, 100., "3.0f", input);
00418                 //  EC_list = g_slist_prepend( EC_list, ec);
00419   
00420                 input = mygtk_add_input("Gate2d:", hbox_param, LABENTRYSIZES);
00421                 ec = new Gtk_EntryControl(TimeUnitms, MLD_WERT_NICHT_OK, &pfp->gate2d, 0.1e-3, 60., "4.1f", input);
00422                 //  EC_list = g_slist_prepend( EC_list, ec);
00423   
00424                 input = mygtk_add_input("Energy", hbox_param, LABENTRYSIZES);
00425                 ec = new Gtk_EntryControl(EnergyUnit, MLD_WERT_NICHT_OK, &pfp->energy, 0., 400., "5.3f", input);
00426                 EC_list = g_slist_prepend( EC_list, ec);
00427 
00428                 // ----------------------------------------
00429   
00430                 input = mygtk_create_input("Loops:", vbox_param, hbox_param, LABENTRYSIZES);
00431                 ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &pfp->maxloops, 0., 100., "3.0f", input);
00432                 //  EC_list = g_slist_prepend( EC_list, ec);
00433 
00434                 input = mygtk_add_input("Delta", hbox_param, LABENTRYSIZES);
00435                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->konvfac, 0., 100., "5.3f", input);
00436                 //  EC_list = g_slist_prepend( EC_list, ec);
00437   
00438                 input = mygtk_add_input("OffsetCorr.", hbox_param, LABENTRYSIZES);
00439                 ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &pfp->offsetcorrection, 0., 1000., "5.1f", input);
00440                 //  EC_list = g_slist_prepend( EC_list, ec);
00441   
00442                 // ----------------------------------------
00443 
00444                 hbox_param = gtk_hbox_new(FALSE, 0);
00445                 gtk_widget_show (hbox_param);
00446                 gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00447 
00448                 GtkWidget *radiobutton;
00449                 GSList    *radiogroup;
00450                 radiobutton = gtk_radio_button_new_with_label (NULL, "Fit Poly 2nd");
00451                 gtk_box_pack_start (GTK_BOX (hbox_param), radiobutton, TRUE, TRUE, 0);
00452                 gtk_widget_show (radiobutton);
00453                 gtk_object_set_data( GTK_OBJECT (radiobutton), "PF_MODE", (gpointer)PF_FITMODE_FIT2ND);
00454                 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00455                                                         GTK_SIGNAL_FUNC (PFsetmode), pfp);
00456 
00457                 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00458 
00459                 radiobutton = gtk_radio_button_new_with_label( radiogroup, "Gaus");
00460                 gtk_box_pack_start (GTK_BOX (hbox_param), radiobutton, TRUE, TRUE, 0);
00461                 gtk_widget_show (radiobutton);
00462                 gtk_object_set_data( GTK_OBJECT (radiobutton), "PF_MODE", (gpointer)PF_FITMODE_FITGAUS);
00463                 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00464                                                         GTK_SIGNAL_FUNC (PFsetmode), pfp);
00465 
00466                 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00467 
00468                 radiobutton = gtk_radio_button_new_with_label( radiogroup, "Lorenz");
00469                 gtk_box_pack_start (GTK_BOX (hbox_param), radiobutton, TRUE, TRUE, 0);
00470                 gtk_widget_show (radiobutton);
00471                 gtk_object_set_data( GTK_OBJECT (radiobutton), "PF_MODE", (gpointer)PF_FITMODE_FITLORENZ);
00472                 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00473                                                         GTK_SIGNAL_FUNC (PFsetmode), pfp);
00474 
00475                 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00476 
00477                 radiobutton = gtk_radio_button_new_with_label( radiogroup, "Disable");
00478                 gtk_box_pack_start (GTK_BOX (hbox_param), radiobutton, TRUE, TRUE, 0);
00479                 gtk_widget_show (radiobutton);
00480                 gtk_object_set_data( GTK_OBJECT (radiobutton), "PF_MODE", NULL);
00481                 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00482                                                         GTK_SIGNAL_FUNC (PFsetmode), pfp);
00483 
00484 
00485                 GtkWidget *Set = gtk_check_button_new_with_label ("-X");
00486                 gtk_widget_show (Set);
00487                 gtk_box_pack_start (GTK_BOX (hbox_param), Set, FALSE, FALSE, 0);
00488                 gtk_signal_connect (GTK_OBJECT (Set), "clicked",
00489                                                         GTK_SIGNAL_FUNC (on_mX_clicked),
00490                                                         pfp);
00491                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (Set), pfp->xsig < 0.);
00492 
00493                 Set = gtk_check_button_new_with_label ("-Y");
00494                 gtk_widget_show (Set);
00495                 gtk_box_pack_start (GTK_BOX (hbox_param), Set, FALSE, FALSE, 0);
00496                 gtk_signal_connect (GTK_OBJECT (Set), "clicked",
00497                                                         GTK_SIGNAL_FUNC (on_mY_clicked),
00498                                                         pfp);
00499                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (Set), pfp->ysig < 0.);
00500 
00501                 input = mygtk_create_input("X- fwhm:", vbox_param, hbox_param,LABENTRYSIZES);
00502                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->xfwhm, 0., 100., ".3f", input);
00503                 EC_list = g_slist_prepend( EC_list, ec);
00504                 input = mygtk_add_input("I0", hbox_param,LABENTRYSIZES);
00505                 ec = new Gtk_EntryControl(CPSUnit, MLD_WERT_NICHT_OK, &pfp->xI0, 0., 100., ".0f", input);
00506                 EC_list = g_slist_prepend( EC_list, ec);
00507                 input = mygtk_add_input("x0", hbox_param,LABENTRYSIZES);
00508                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->xxf0, 0., 100., ".3f", input);
00509                 EC_list = g_slist_prepend( EC_list, ec);
00510   
00511                 input = mygtk_create_input("Y- fwhm:", vbox_param, hbox_param,LABENTRYSIZES);
00512                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->yfwhm, 0., 100., ".3f", input);
00513                 EC_list = g_slist_prepend( EC_list, ec);
00514                 input = mygtk_add_input("I0", hbox_param,LABENTRYSIZES);
00515                 ec = new Gtk_EntryControl(CPSUnit, MLD_WERT_NICHT_OK, &pfp->yI0, 0., 100., ".0f", input);
00516                 EC_list = g_slist_prepend( EC_list, ec);
00517                 input = mygtk_add_input("x0", hbox_param,LABENTRYSIZES);
00518                 ec = new Gtk_EntryControl(Volt, MLD_WERT_NICHT_OK, &pfp->yxf0, 0., 100., ".3f", input);
00519                 EC_list = g_slist_prepend( EC_list, ec);
00520   
00521   
00522                 // graph color picker
00523   
00524                 // Checkbutton: PF on
00525   
00526                 // Checkbutton: to enable
00527   
00528                 // Buttons: Start/Stop
00529                 // ----------
00530                 hbox_param = gtk_hbox_new(FALSE, 0);
00531                 gtk_widget_show (hbox_param);
00532                 gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00533 
00534                 button = gtk_button_new_with_label("Run Peak Finder");
00535                 gtk_widget_show (button);
00536                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00537                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_PRB_RUNPF);
00538                 gtk_object_set_data( GTK_OBJECT (button), "DSP_PFP", (gpointer)pfp );
00539                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00540                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::CmdAction),
00541                                                          this);
00542 
00543                 button = gtk_button_new_with_label("add PF");
00544                 gtk_widget_show (button);
00545                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00546                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00547                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::PFadd),
00548                                                          this);
00549   
00550 
00551                 if(bf_num > 1){ // do not allow to kill the first one...
00552                                 button = gtk_button_new_with_label("del PF");
00553                                 gtk_widget_show (button);
00554                                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00555                                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_pfp",  (gpointer)pfp);
00556                                 gtk_object_set_data( GTK_OBJECT (button), "PF_folder_itab", (gpointer)(itab-1));
00557                                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00558                                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::PFremove),
00559                                                                          this);
00560                 }
00561   
00562                 button = gtk_button_new_with_label("Peak View >>");
00563                 gtk_widget_show (button);
00564                 gtk_container_add (GTK_CONTAINER (hbox_param), button);
00565                 gtk_object_set_data( GTK_OBJECT (button), "PF_BOX", (gpointer)hbox_r);
00566                 gtk_object_set_data( GTK_OBJECT (button), "PF_BOX_FLAG", NULL);
00567                 gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00568                                                          GTK_SIGNAL_FUNC (DSPPeakFindControl::PFExpandView),
00569                                                          this);
00570   
00571                 // save list away...
00572                 gtk_object_set_data( GTK_OBJECT (widget), "Probe_EC_list", EC_list);
00573 }
00574 
00575 void DSPPeakFindControl::update(){
00576                 g_slist_foreach (
00577                                 (GSList*) gtk_object_get_data (
00578                                                 GTK_OBJECT (widget), "Probe_EC_list"),
00579                                 (GFunc) App::update_ec, NULL);
00580 }
00581 
00582 void DSPPeakFindControl::CmdAction(GtkWidget *widget, void *vpc){
00583                 DSPPeakFindControl *pc = (DSPPeakFindControl*)vpc;
00584                 switch((int)gtk_object_get_data( GTK_OBJECT (widget), "DSP_cmd")){
00585                 case DSP_CMD_PRB_RUNPF:
00586                                 PI_DEBUG (DBG_L2, "PF-Test" ); 
00587                                 ((DSPPeakFindControl*)pc)->pfscan->PFrun
00588                                                 (pc->hard, 
00589                                                  (SPA_PeakFind_p *)
00590                                                  (gtk_object_get_data( GTK_OBJECT (widget), "DSP_PFP")) 
00591                                                                 );
00592                                 break;
00593                 case DSP_CMD_PRB_RUNPFI0:
00594                                 PI_DEBUG (DBG_L2, "add PFtmout");
00595                                 pc->addPFtmout();
00596                                 break;
00597                 case DSP_CMD_PRB_DELPFI0:
00598                                 PI_DEBUG (DBG_L2, "rm PFtmout");
00599                                 pc->rmPFtmout();
00600                                 break;
00601                 case DSP_CMD_PRB_PFreset:
00602                                 g_slist_foreach(pc->PfpList, (GFunc) DSPPeakFindControl::PFreset, pc);
00603                                 break;
00604                 case DSP_CMD_PRB_PFsaveNc:
00605                                 gchar *fname = gapp->file_dialog("Save Probe Scan", NULL, NULL, "Probescan.nc", "probesave");
00606                                 pc->pfscan->Save(fname);
00607                                 break;
00608                 }
00609                 pc->update();
00610 }
00611 
00612 void DSPPeakFindControl::on_mX_clicked(GtkWidget *button, SPA_PeakFind_p *pfp){
00613                 pfp->xsig = GTK_TOGGLE_BUTTON (button)->active ? -1.:1.;
00614 }
00615 void DSPPeakFindControl::on_mY_clicked(GtkWidget *button, SPA_PeakFind_p *pfp){
00616                 pfp->ysig = GTK_TOGGLE_BUTTON (button)->active ? -1.:1.;
00617 }
00618 
00619 void DSPPeakFindControl::PFsetmode(GtkWidget *widget, SPA_PeakFind_p *pfp){
00620                 pfp->SetFitMode((int)gtk_object_get_data( GTK_OBJECT (widget), "PF_MODE"));
00621 }
00622 
00623 void DSPPeakFindControl::PFadd(GtkWidget *widget, gpointer pc){
00624                 ((DSPPeakFindControl*)pc)->addPFfolder();
00625 }
00626 
00627 void DSPPeakFindControl::PFExpandView(GtkWidget *button, gpointer pc){
00628                 if(gtk_object_get_data( GTK_OBJECT (button), "PF_BOX_FLAG")){
00629                                 gtk_widget_hide( (GtkWidget*) gtk_object_get_data( GTK_OBJECT (button), "PF_BOX") );
00630                                 gtk_object_set_data( GTK_OBJECT (button), "PF_BOX_FLAG", NULL);
00631                                 //      gtk_label_set_text( GTK_LABEL ( GTK_BUTTON (button)), "View >>" );
00632                                 //      PI_DEBUG (DBG_L2, ">>>>" );
00633                 }else{
00634                                 gtk_widget_show( (GtkWidget*) gtk_object_get_data( GTK_OBJECT (button), "PF_BOX") );
00635                                 gtk_object_set_data( GTK_OBJECT (button), "PF_BOX_FLAG", (gpointer)1);
00636                                 //      gtk_label_set_text( GTK_LABEL ( GTK_BUTTON (button)), "View <<" );
00637                                 //      PI_DEBUG (DBG_L2, "<<<<<" );
00638                 }
00639 }
00640 
00641 void DSPPeakFindControl::PFremove(GtkWidget *widget, gpointer pc){
00642                 return; // disable remove 
00643 #if 0
00644                 // should remove EC_list entrys too... ???!!!
00645                 SPA_PeakFind_p *pfp = (SPA_PeakFind_p *) gtk_object_get_data( GTK_OBJECT (widget), "PF_folder_pfp");
00646                 gtk_notebook_remove_page (GTK_NOTEBOOK (((DSPPeakFindControl*)pc)->notebook), (int)gtk_object_get_data( GTK_OBJECT (widget), "PF_folder_itab") );
00647                 delete pfp;
00648                 ((DSPPeakFindControl*)pc)->PfpList = g_slist_remove( pc->PfpList, pfp );
00649 #endif
00650 }
00651 
00652 void DSPPeakFindControl::PFcpyorg(GtkWidget *widget, gpointer pc){
00653                 SPA_PeakFind_p *pfp =  (SPA_PeakFind_p*)gtk_object_get_data( GTK_OBJECT (widget), "PF_folder_pfp");
00654                 pfp->xorg=pfp->x0;
00655                 pfp->yorg=pfp->y0;
00656                 PI_DEBUG (DBG_L2, "----------- PFcpyorg !!! -------------" );
00657                 ((DSPPeakFindControl*)pc)->update();
00658 }
00659 
00660 void DSPPeakFindControl::PFcpyFromM(GtkWidget *widget, gpointer pc){
00661                 SPA_PeakFind_p *pfp =  (SPA_PeakFind_p*)gtk_object_get_data( GTK_OBJECT (widget), "PF_folder_pfp");
00662                 pfp->xorg=pfp->x0 = gapp->xsm->data.s.x0;
00663                 pfp->yorg=pfp->y0 = gapp->xsm->data.s.y0;
00664                 ((DSPPeakFindControl*)pc)->update();
00665 }
00666 
00667 void DSPPeakFindControl::PFcpyEfromM(GtkWidget *widget, gpointer pc){
00668                 SPA_PeakFind_p *pfp =  (SPA_PeakFind_p*)gtk_object_get_data( GTK_OBJECT (widget), "PF_folder_pfp");
00669                 pfp->energy = gapp->xsm->data.hardpars.SPA_Energy;
00670                 ((DSPPeakFindControl*)pc)->update();
00671 }
00672 
00673 void DSPPeakFindControl::PFcpyToM(GtkWidget *widget, gpointer pc){
00674                 SPA_PeakFind_p *pfp =  (SPA_PeakFind_p*)gtk_object_get_data( GTK_OBJECT (widget), "PF_folder_pfp");
00675                 gapp->xsm->data.s.x0 = pfp->xorg;
00676                 gapp->xsm->data.s.y0 = pfp->yorg;
00677                 gapp->spm_update_all();
00678 }
00679 
00680 void DSPPeakFindControl::PFfollow(GtkButton *button, gpointer pc){
00681                 SPA_PeakFind_p *pfp =  (SPA_PeakFind_p*)gtk_object_get_data( GTK_OBJECT (button), "PF_folder_pfp");
00682                 if (GTK_TOGGLE_BUTTON (button)->active)
00683                                 pfp->follow=TRUE;
00684                 else
00685                                 pfp->follow=FALSE;
00686 }
00687 
00688 void DSPPeakFindControl::PFenable(GtkWidget *widget, gpointer pc){
00689 }
00690 
00691 void DSPPeakFindControl::PFreset(SPA_PeakFind_p *pfp, gpointer pc){
00692                 pfp->count=0;
00693 }
00694 
00695 void DSPPeakFindControl::PFrunI0pfp(SPA_PeakFind_p *pfp, gpointer pc){
00696                 PI_DEBUG (DBG_L2, "PFrunI0 from list:" << pfp->index);
00697                 PI_DEBUG (DBG_L2, "PFrunI0 from list:" << pfp->index );
00698                 ((DSPPeakFindControl*)pc)->pfscan->PFrunI0(((DSPPeakFindControl*)pc)->hard, pfp);
00699                 ((DSPPeakFindControl*)pc)->update();
00700 }
00701 
00702 gint DSPPeakFindControl::PFtmoutfkt(DSPPeakFindControl *pc){
00703                 static int active=FALSE;
00704                 PI_DEBUG (DBG_L2, "DSPPeakFindControl::PFtmoutfkt");
00705                 PI_DEBUG (DBG_L2, "DSPPeakFindControl::PFtmoutfkt ----------------" );
00706                 if(active){
00707                                 PI_DEBUG (DBG_L2, "PFtmout called too fast, slowing down...");
00708                                 pc->PFtmoutms+=200;
00709                                 pc->update();
00710                                 pc->rmPFtmout();
00711                                 pc->addPFtmout();
00712                                 return FALSE;
00713                 }
00714                 active=TRUE;
00715                 PI_DEBUG (DBG_L2, "PF: running all BF...");
00716                 g_slist_foreach(pc->PfpList, (GFunc) DSPPeakFindControl::PFrunI0pfp, pc);
00717                 PI_DEBUG (DBG_L2, "PF: run done.");
00718                 active=FALSE;
00719                 return TRUE;
00720 }
00721 
00722 void DSPPeakFindControl::ChangedNotify(Param_Control* pcs, gpointer pc){
00723                 //  gchar *us = pcs->Get_UsrString();
00724                 //  PI_DEBUG (DBG_L2, "PRBC: " << us );
00725                 //  g_free(us);
00726 
00727                 //  ((DSPPeakFindControl*)pc)->updateDSP();
00728 }
00729 
00730 void DSPPeakFindControl::ExecCmd(int cmd){
00731                 gapp->xsm->hardware->ExecCmd(cmd);
00732 }
00733 

Generated on Sat Apr 1 09:04:11 2006 for GXSM by  doxygen 1.4.6