gxsm_app.h

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00027 
00028 #ifndef GXSM_APP_H
00029 #define GXSM_APP_H
00030 
00031 #include <config.h>
00032 #include <gnome.h>
00033 #include <libgnome/libgnome.h>
00034 
00035 #include <gdk/gdk.h>
00036 #include <netcdf.hh>
00037 
00038 #include "gapp_service.h"
00039 #include "pcs.h"
00040 #include "surface.h"
00041 #include "monitor.h"
00042 #include "lineprofile.h"
00043 
00044 #include "xsmmath.h"
00045 #include "xsm_limits.h"
00046 
00047 #include "app_vobj.h"
00048 
00049 #include "plugin_ctrl.h"
00050 
00051 /* Client Windows... */
00052 class RemoteControl;
00053 class gxsm_plugins;
00054 
00055 class ChannelSelector : public AppBase{
00056 public:
00057   ChannelSelector(int ChAnz=MAX_CHANNELS);
00058   virtual ~ChannelSelector(){
00059     delete [] ChSDirWidget;
00060     delete [] ChModeWidget;
00061     delete [] ChViewWidget;
00062   };
00063 
00064   void SetSDir(int Channel, int Dir);
00065   void SetMode(int Channel, int Mode);
00066   void SetView(int Channel, int View);
00067 
00068   static void choice_ChView_callback (GtkWidget *widget, void *data);
00069   static void choice_ChMode_callback (GtkWidget *widget, void *data);
00070   static void choice_ChSDir_callback (GtkWidget *widget, void *data);
00071 
00072 private:
00073   GtkWidget **ChSDirWidget;
00074   GtkWidget **ChModeWidget;
00075   GtkWidget **ChViewWidget;
00076 };
00077 
00078 class MonitorControl : public AppBase, Monitor{
00079 public:
00080   MonitorControl();
00081   virtual ~MonitorControl();
00082 
00083   virtual void LogEvent(gchar *Action, gchar *Entry);
00084 private:
00085 };
00086 
00087 /* App. Main Window */
00088 
00089 class App : public GnomeAppService {
00090 public:
00091   App(int restarted=FALSE);
00092   virtual ~App();
00093 
00094   virtual void AppWidgetInit(int InWindow=FALSE){ InWindowFlg=FALSE; widget=app; };
00095   void build_gxsm();
00096 
00097 /* Menu - callbacks */
00098   static void file_open_callback (GtkWidget *widget, void *data);
00099   static void file_open_in_new_window_callback (GtkWidget *widget, void *data);
00100   static void file_browse_callback (GtkWidget *widget, void *data);
00101   static void file_save_callback (GtkWidget *widget, void *data);
00102   static void file_save_as_callback (GtkWidget *widget, void *data);
00103   static void file_import_callback (GtkWidget *widget, void *data);
00104   static void file_export_callback (GtkWidget *widget, void *data);
00105   static void file_print_callback (GtkWidget *widget, void *data);
00106   static void file_close_callback (GtkWidget *widget, void *data);
00107   static int file_exit_callback (GtkWidget *widget, void *data);
00108 
00109   static void edit_crop_callback (GtkWidget *widget, void *data);
00110   static void edit_copy_callback (GtkWidget *widget, void *data);
00111   
00112   static void action_toolbar_callback (GtkWidget *widget, void *data);
00113 
00114 // old:
00115   static void action_scan_callback (GtkWidget *widget, void *data);
00116   static void action_stopscan_callback (GtkWidget *widget, void *data);
00117 
00118   static void action_movie_callback (GtkWidget *widget, void *data);
00119   static void action_scan_add_callback (GtkWidget *widget, void *data);
00120   static void action_scan_add_movie_callback (GtkWidget *widget, void *data);
00121 
00122   static void view_autodisp_callback (GtkWidget *widget, void *data);
00123   static void view_autozoom_callback (GtkWidget *widget, void *data);
00124   static void view_tolerant_callback (GtkWidget *widget, void *data);
00125   static void view_palette_callback (GtkWidget *widget, void *data);
00126   static void view_zoom_in_callback (GtkWidget *widget, void *data);
00127   static void view_zoom_out_callback (GtkWidget *widget, void *data);
00128 
00129   static void math_onearg_nodest_callback (GtkWidget *widget, gboolean (*MOp)(MATHOPPARAMSNODEST));
00130   static void math_onearg_callback (GtkWidget *widget, gboolean (*MOp)(MATHOPPARAMS));
00131   static void math_twoarg_callback (GtkWidget *widget, gboolean (*MOp)(MATH2OPPARAMS));
00132   static void math_twoarg_no_same_size_check_callback (GtkWidget *widget, gboolean (*MOp)(MATH2OPPARAMS));
00133 
00134   static void tools_monitor_callback (GtkWidget *widget, void *data);
00135   static void tools_chanselwin_callback (GtkWidget *widget, void *data);
00136 
00137   static void tools_mkicons_callback (GtkWidget *widget, void *data);
00138   static void tools_remote_callback (GtkWidget *widget, void *data);
00139   static void tools_plugin_reload_callback (GtkWidget *widget, void *data);
00140   static void tools_plugin_info_callback (GtkWidget *widget, void *data);
00141 
00142   static void options_preferences_callback (GtkWidget *widget, void *data);
00143   static void options_save_preferences_callback (GtkWidget *widget, void *data);
00144   static void options_load_preferences_callback (GtkWidget *widget, void *data);
00145   static void options_save_values_callback (GtkWidget *widget, void *data);
00146   static void options_load_values_callback (GtkWidget *widget, void *data);
00147   static void options_save_geometry_callback (GtkWidget *widget, void *data);
00148   
00149   static void help_license_callback (GtkWidget *widget, void *data);
00150   static void help_home_callback (GtkWidget *widget, void *data);
00151   static void help_manual_callback (GtkWidget *widget, void *data);
00152   static void help_remote_tt_callback (GtkWidget *widget, void *data);
00153   static void help_about_callback (GtkWidget *widget, void *data);
00154   static void help_tip_callback (GtkWidget *widget, void *data);
00155 
00156   /* Window Delete Events */ 
00157   static gint close_scan_event_cb (GtkWidget *window, GdkEventAny* e, gpointer data);
00158  
00159   /* Main - Window - Callbacks */
00160   static void browse_callback(gchar *selection, App* ap);
00161 
00162   /* DND ... */
00163   static gboolean input_func(GIOChannel *source, GIOCondition condition, gpointer data);
00164   static void grab_url(const gchar *name);
00165   static void process_one_filename (GtkWidget * widget, const gchar *filename);
00166   static void filenames_dropped(GtkWidget * widget,
00167                                 GdkDragContext   *context,
00168                                 gint              x,
00169                                 gint              y,
00170                                 GtkSelectionData *selection_data,
00171                                 guint             info,
00172                                 guint             time);
00173   void configure_drop_on_widget(GtkWidget * widget);
00174   static void drag_data_get (GtkWidget        *widget,
00175                              GdkDragContext   *context,
00176                              GtkSelectionData *selection_data,
00177                              guint             info,
00178                              guint             time);
00179   void configure_drag_on_widget(GtkWidget * widget);
00180 
00181   /* Status Handling */
00182 
00183   void SetStatus(const gchar *mld, const gchar *val=NULL){
00184           if(val){
00185                   gchar *longmld = g_strdup_printf("%s: %s",mld, val);
00186                   gnome_appbar_set_status(GNOME_APPBAR (appbar), longmld);
00187                   g_free(longmld);
00188           }
00189           else
00190                   gnome_appbar_set_status(GNOME_APPBAR (appbar), mld);
00191           check_events();
00192   };
00193   void ClearStatus(){
00194           gnome_appbar_clear_stack(GNOME_APPBAR (appbar));
00195   };
00196 
00197   void SetProgress(gfloat p){
00198           if(p>=0. && p<=1.)
00199                   gnome_appbar_set_progress_percentage( GNOME_APPBAR (appbar), p);
00200   };
00201 
00202   /* Init Stuff */
00203   void gxsm_new_user_config(RES_ENTRY *res_def);
00204   static gint RemoveGxsmSplash(GtkWidget *widget);
00205   void GxsmSplash(gdouble progress=0., const gchar *text=NULL, const gchar *info=NULL);
00206 
00207   /* Application Windows: Creation Funktion and Widget-Pointer */
00208   GtkWidget* create_control();      // Leere "Main-VBox" (=> main_control)
00209 
00210   GtkWidget* create_spm_control (); // SPM Control Elements, added to main_control
00211   GtkWidget* create_spa_control ();  // Auto Save Control Elements, added to main_control
00212   GtkWidget* create_ui_control ();  // User Info Control Elements, added to main_control
00213   GtkWidget* create_as_control ();  // Auto Save Control Elements, added to main_control
00214   GtkWidget* main_control;
00215   GtkWidget* spm_control;
00216   GtkWidget* spa_control;
00217   GtkWidget* ui_control;
00218   GtkWidget* as_control;
00219 
00220   void spa_update();
00221   void spa_setdata();
00222 
00223   void ui_update();
00224   void ui_setcomment();
00225 
00226   void as_update();
00227   void as_setdata();
00228 
00229   void spm_update_all(int Vflg=0);
00230   void spm_freeze_scanparam();
00231   static void freeze_ec(Gtk_EntryControl* ec, gpointer data){ ec->Freeze(); };
00232 
00233   void spm_thaw_scanparam();
00234   static void thaw_ec(Gtk_EntryControl* ec, gpointer data){ ec->Thaw(); };
00235 
00236   void spa_show_scan_time();
00237 
00238   static void spm_range_check(Param_Control* pcs, gpointer data);
00239   static void spm_offset_check(Param_Control* pcs, gpointer data);
00240   static void spm_nlayer_update(Param_Control* pcs, gpointer data);
00241   static void spm_select_layer(Param_Control* pcs, gpointer data);
00242   static void spa_energy_check(Param_Control* pcs, gpointer data);
00243   static void spa_gate_check(Param_Control* pcs, gpointer data);
00244   void spa_mode_switch_check();
00245   void spa_SeV_unit_switch_check();
00246   static void spa_switch_unit(Param_Control* pcs, gpointer data);
00247   static void recalc_volt_from_new_Energy(double* x, double *Eneu);
00248 
00249   static void update_ec(Gtk_EntryControl* ec, gpointer data){ ec->Put_Value(); };
00250 
00251   ChannelSelector *channelselector;
00252   //  ProbeControl *probecontrol;
00253   //  GrOffsetControl *groffsetcontrol;
00254   MonitorControl *monitorcontrol;
00255   //  DriftControl *driftcontrol;
00256 
00257   //  OptiControl *opticontrol;
00258   //  OsziControl *oszicontrol;
00259 
00260   /* Main Menu Shell Referenz */
00261   GtkWidget *gxsmmenu;
00262 
00263   /* Main XSM Objekt */
00264   Surface *xsm;
00265 
00266   /* List of remotely acessable entrys */
00267   GSList *RemoteEntryList;
00268   GSList *RemoteActionList;
00269 
00270   /* Remote */
00271   RemoteControl *remotecontrol;
00272 
00273   /* Gxsm PlugIns management */  
00274 
00275   static gint Gxsm_Plugin_Check (const gchar *category);
00276   void reload_gxsm_plugins( gint killflag=FALSE );
00277   gxsm_plugins *GxsmPlugins;
00278 
00279   void ConnectPluginToSPMRangeEvent( void (*cbfkt)(gpointer) );
00280   void ConnectPluginToStartScanEvent( void (*cbfkt)(gpointer) );
00281   void ConnectPluginToStopScanEvent( void (*cbfkt)(gpointer) );
00282   void ConnectPluginToCDFLoadEvent( void (*cbfkt)(gpointer) ); // => NcFile *ncf
00283   void ConnectPluginToCDFSaveEvent( void (*cbfkt)(gpointer) ); // => NcFile *ncf
00284   void ConnectPluginToLoadFileEvent( void (*cbfkt)(gpointer) ); // => gchar **filename
00285   void ConnectPluginToSaveFileEvent( void (*cbfkt)(gpointer) ); // => gchar **filename
00286 
00287   void RegisterPluginToolbarButton (GtkObject *b, const gchar* ToolbarButtonName){ 
00288           gtk_object_set_data (GTK_OBJECT (app), ToolbarButtonName, b);
00289   };
00290 
00291   void ConnectPluginToGetNCInfoEvent (void (*cbfkt)(gchar *filename ) );
00292   void ConnectPluginToPrinterEvent ( void (*cbfkt)(GtkWidget*, void*) );
00293   void ConnectPluginToMkiconsEvent ( void (*cbfkt)(GtkWidget*, void*) );
00294 
00295   void PutPluginData (gchar *data){
00296           if (DataStack)
00297                   g_free (DataStack);
00298           DataStack = g_strdup (data);
00299   }
00300   gchar* GetPluginData (){
00301           gchar *tmp = NULL;
00302           if (DataStack){
00303                   tmp = g_strdup (DataStack);
00304                   g_free (DataStack);
00305                   DataStack = NULL;
00306           }
00307           return tmp;
00308   }
00309 
00310   void CallGetNCInfoPlugin (gchar *filename) {
00311     if (PluginCallGetNCInfo){
00312       PluginCallGetNCInfo (filename);
00313     }
00314   };
00315 
00316   static void CallPlugin( void (*cbfkt)( gpointer ), gpointer data);
00317 
00318   void SignalEventToPlugins( GList *PluginNotifyList, gpointer data );
00319 
00320   void SignalSPMRangeEventToPlugins(void){ 
00321     SignalEventToPlugins( PluginNotifyOnSPMRange, NULL ); 
00322   };
00323   void SignalStartScanEventToPlugins(void){ 
00324     SignalEventToPlugins( PluginNotifyOnStartScan, NULL ); 
00325   };
00326   void SignalStopScanEventToPlugins(void){ 
00327     SignalEventToPlugins( PluginNotifyOnStopScan, NULL ); 
00328   };
00329   void SignalCDFLoadEventToPlugins(NcFile *ncf){ 
00330     SignalEventToPlugins( PluginNotifyOnCDFLoad, (gpointer)ncf ); 
00331   };
00332   void SignalCDFSaveEventToPlugins(NcFile *ncf){ 
00333     SignalEventToPlugins( PluginNotifyOnCDFSave, (gpointer)ncf ); 
00334   };
00335   void SignalLoadFileEventToPlugins(gchar **filename){ 
00336     SignalEventToPlugins( PluginNotifyOnLoadFile, filename ); 
00337   };
00338   void SignalSaveFileEventToPlugins(gchar **filename){ 
00339     SignalEventToPlugins( PluginNotifyOnSaveFile, filename ); 
00340   };
00341 
00342 protected:
00343   GList *PluginNotifyOnSPMRange;
00344   GList *PluginNotifyOnStartScan;
00345   GList *PluginNotifyOnStopScan;
00346   GList *PluginNotifyOnCDFLoad;
00347   GList *PluginNotifyOnCDFSave;
00348   GList *PluginNotifyOnLoadFile;
00349   GList *PluginNotifyOnSaveFile;
00350 
00351   void (*PluginCallGetNCInfo)(gchar*);
00352   void (*PluginCallPrinter)(GtkWidget*, void*);
00353   void (*PluginCallMkicons)(GtkWidget*, void*);
00354 
00355 private:
00356   /* Gxsm Application */
00357 
00358   GtkWidget* app;
00359   GtkWidget* appbar;
00360 
00361   gchar *DataStack;
00362 };
00363 
00364 extern App *gapp;
00365 
00366 #endif

Generated on Sat Apr 1 09:03:58 2006 for GXSM by  doxygen 1.4.6