00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #include <gtk/gtk.h>
00070 #include "config.h"
00071 #include "gxsm/plugin.h"
00072
00073 #include "gxsm/unit.h"
00074 #include "gxsm/pcs.h"
00075 #include "gxsm/xsmtypes.h"
00076 #include "gxsm/glbvars.h"
00077
00078 #include "include/dsp-pci32/xsm/xsmcmd.h"
00079
00080
00081
00082 static void DriftComp_about( void );
00083 static void DriftComp_query( void );
00084 static void DriftComp_cleanup( void );
00085
00086 static void DriftComp_show_callback( GtkWidget*, void* );
00087 static void DriftComp_StartScan_callback( gpointer );
00088
00089 GxsmPlugin DriftComp_pi = {
00090 NULL,
00091 NULL,
00092 0,
00093 NULL,
00094 "DriftComp",
00095 "+spmHARD +STM +AFM",
00096 NULL,
00097 "Percy Zahl",
00098 N_("_Windows/"),
00099 N_("Drift Comp."),
00100 N_("open the drift compensation controlwindow"),
00101 "drift compensation control",
00102 NULL,
00103 NULL,
00104 NULL,
00105 DriftComp_query,
00106 DriftComp_about,
00107 NULL,
00108 NULL,
00109 DriftComp_cleanup
00110 };
00111
00112 static const char *about_text = N_("Gxsm DriftComp Plugin:\n"
00113 "This plugin runs a control window to enable "
00114 "drift-compensation between scans (movie). "
00115 "Therfore a drift speed and direction can be specified.\n"
00116 "May be extended to inner scan corrections... PZ"
00117 );
00118
00119 GxsmPlugin *get_gxsm_plugin_info ( void ){
00120 DriftComp_pi.description = g_strdup_printf(N_("Gxsm DriftComp plugin %s"), VERSION);
00121 return &DriftComp_pi;
00122 }
00123
00124
00125
00126
00127
00128 typedef struct AntiDrift_Param{
00129 double vx, vy, tx, ty;
00130 double px, py, tcx, tcy;
00131 int mode;
00132 };
00133
00134 typedef union AmpIndex {
00135 struct { unsigned char ch, x, y, z; } s;
00136 unsigned long l;
00137 };
00138
00139 class DriftControl : public AppBase{
00140 public:
00141 DriftControl();
00142 virtual ~DriftControl();
00143
00144 static void ChangedNotify(Param_Control* pcs, gpointer data);
00145 void update();
00146
00147 private:
00148 UnitObj *Unity, *Volt, *Time, *Speed, *Creep;
00149 AntiDrift_Param adp;
00150 };
00151
00152 DriftControl *DriftCompClass = NULL;
00153
00154 static void DriftComp_query(void)
00155 {
00156 static GnomeUIInfo menuinfo[] = {
00157 { GNOME_APP_UI_ITEM,
00158 DriftComp_pi.menuentry, DriftComp_pi.help,
00159 (gpointer) DriftComp_show_callback, NULL,
00160 NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BLANK,
00161 0, GDK_CONTROL_MASK, NULL },
00162
00163 GNOMEUIINFO_END
00164 };
00165
00166 gnome_app_insert_menus
00167 ( GNOME_APP(DriftComp_pi.app->getApp()),
00168 DriftComp_pi.menupath, menuinfo );
00169
00170
00171 DriftCompClass = new DriftControl;
00172
00173 DriftCompClass->SetResName ("WindowDriftControl", "false", xsmres.geomsave);
00174
00175 DriftComp_pi.app->ConnectPluginToStartScanEvent
00176 ( DriftComp_StartScan_callback );
00177
00178 DriftComp_pi.status = g_strconcat(N_("Plugin query has attached "),
00179 DriftComp_pi.name,
00180 N_(": DriftComp is created."),
00181 NULL);
00182 }
00183
00184 static void DriftComp_about(void)
00185 {
00186 const gchar *authors[] = { "Percy Zahl", NULL};
00187 gtk_widget_show(gnome_about_new ( DriftComp_pi.name,
00188 VERSION,
00189 N_("(C) 2000 the Free Software Foundation"),
00190 about_text,
00191 authors,
00192 NULL, NULL, NULL
00193 ));
00194 }
00195
00196 static void DriftComp_cleanup( void ){
00197 PI_DEBUG (DBG_L2, "DriftComp Plugin Cleanup" );
00198 gchar *mp = g_strconcat(DriftComp_pi.menupath, DriftComp_pi.menuentry, NULL);
00199 gnome_app_remove_menus (GNOME_APP( DriftComp_pi.app->getApp() ), mp, 1);
00200 g_free(mp);
00201
00202
00203 if( DriftCompClass )
00204 delete DriftCompClass ;
00205
00206 g_free( DriftComp_pi.status );
00207 }
00208
00209 static void DriftComp_show_callback( GtkWidget* widget, void* data){
00210 if( DriftCompClass )
00211 DriftCompClass->show();
00212 }
00213
00214 static void DriftComp_StartScan_callback( gpointer ){
00215 DriftCompClass->update();
00216 }
00217
00218
00219 DriftControl::DriftControl ()
00220 {
00221 Gtk_EntryControl *ec;
00222
00223 Unity = new UnitObj(" "," ");
00224 Volt = new UnitObj("V","V");
00225 Speed = new UnitObj("A/min","A/min");
00226 Creep = new UnitObj("A/Vs","A/Vs");
00227 Time = new UnitObj("s","s");
00228
00229 GSList *EC_list=NULL;
00230
00231 GtkWidget *box;
00232 GtkWidget *frame_param;
00233 GtkWidget *vbox_param, *hbox_param;
00234 GtkWidget *input;
00235
00236 XsmRescourceManager xrm("PluginDriftControl");
00237 xrm.Get("adp.vx", &adp.vx, "0");
00238 xrm.Get("adp.vy", &adp.vy, "0");
00239 xrm.Get("adp.tx", &adp.tx, "0");
00240 xrm.Get("adp.ty", &adp.ty, "0");
00241 xrm.Get("adp.px", &adp.px, "0");
00242 xrm.Get("adp.py", &adp.py, "0");
00243 xrm.Get("adp.tcx", &adp.tcx, "0");
00244 xrm.Get("adp.tcy", &adp.tcy, "0");
00245 xrm.Get("adp.mode", &adp.mode, "0");
00246
00247 AppWidgetInit(ANTIDRIFT_TITLE);
00248
00249 box = gtk_vbox_new (FALSE, 0);
00250 gtk_widget_show (box);
00251 gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00252
00253
00254 frame_param = gtk_frame_new (N_("thermic drift"));
00255 gtk_widget_show (frame_param);
00256 gtk_container_add (GTK_CONTAINER (box), frame_param);
00257
00258 vbox_param = gtk_vbox_new (FALSE, 0);
00259 gtk_widget_show (vbox_param);
00260 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00261
00262 input = mygtk_create_input("Vx", vbox_param, hbox_param);
00263 ec = new Gtk_EntryControl (Speed, MLD_WERT_NICHT_OK, &adp.vx, -1000., 1000., "5.1f", input);
00264 ec->Set_ChangeNoticeFkt(DriftControl::ChangedNotify, this);
00265 EC_list = g_slist_prepend( EC_list, ec);
00266
00267 input = mygtk_create_input("Vy", vbox_param, hbox_param);
00268 ec = new Gtk_EntryControl (Speed, MLD_WERT_NICHT_OK, &adp.vy, -1000., 1000., "5.1f", input);
00269 ec->Set_ChangeNoticeFkt(DriftControl::ChangedNotify, this);
00270 EC_list = g_slist_prepend( EC_list, ec);
00271
00272 input = mygtk_create_input("tx", vbox_param, hbox_param);
00273 ec = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &adp.tx, -1000., 1000., "5.1f", input);
00274 ec->Set_ChangeNoticeFkt(DriftControl::ChangedNotify, this);
00275 EC_list = g_slist_prepend( EC_list, ec);
00276
00277 input = mygtk_create_input("ty", vbox_param, hbox_param);
00278 ec = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &adp.ty, -1000., 1000., "5.1f", input);
00279 ec->Set_ChangeNoticeFkt(DriftControl::ChangedNotify, this);
00280 EC_list = g_slist_prepend( EC_list, ec);
00281
00282
00283
00284 gtk_object_set_data( GTK_OBJECT (widget), "DRIFT_EC_list", EC_list);
00285
00286 }
00287
00288 DriftControl::~DriftControl (){
00289
00290 XsmRescourceManager xrm("PluginDriftControl");
00291 xrm.Put("adp.vx", adp.vx);
00292 xrm.Put("adp.vy", adp.vy);
00293 xrm.Put("adp.tx", adp.tx);
00294 xrm.Put("adp.ty", adp.ty);
00295 xrm.Put("adp.px", adp.px);
00296 xrm.Put("adp.py", adp.py);
00297 xrm.Put("adp.tcx", adp.tcx);
00298 xrm.Put("adp.tcy", adp.tcy);
00299 xrm.Put("adp.mode", adp.mode);
00300
00301 delete Unity;
00302 delete Volt;
00303 delete Time;
00304 delete Speed;
00305 delete Creep;
00306 }
00307
00308 void DriftControl::update(){
00309 g_slist_foreach((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "DRIFT_EC_list"),
00310 (GFunc) App::update_ec, NULL);
00311 }
00312
00313 void DriftControl::ChangedNotify(Param_Control* pcs, gpointer data){
00314 PI_DEBUG (DBG_L2, "Drift Param. Changed!" );
00315 }