00001 /* Gnome gxsm - Gnome X Scanning Microscopy 00002 * universal STM/AFM/SARLS/SPALEED/... controlling and 00003 * data analysis software 00004 * 00005 * plugin_helper reports your answers as 00006 author =Percy Zahl 00007 email =zahl@users.sf.net 00008 pluginname =merge_h 00009 pluginmenuentry =Merge H 00010 menupath =Math/Transformations/ 00011 entryplace =Transformations 00012 shortentryplace =TR 00013 abouttext =Merge two scans horizontally. 00014 smallhelp =merge horizontal 00015 longhelp =Merge two scans of same height horizontal 00016 * 00017 * Gxsm Plugin Name: merge_h.C 00018 * ======================================== 00019 * 00020 * Copyright (C) 1999 The Free Software Foundation 00021 * 00022 * Authors: Percy Zahl <zahl@fkp.uni-hannover.de> 00023 * additional features: Andreas Klust <klust@fkp.uni-hannover.de> 00024 * 00025 * This program is free software; you can redistribute it and/or modify 00026 * it under the terms of the GNU General Public License as published by 00027 * the Free Software Foundation; either version 2 of the License, or 00028 * (at your option) any later version. 00029 * 00030 * This program is distributed in the hope that it will be useful, 00031 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00032 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00033 * GNU General Public License for more details. 00034 * 00035 * You should have received a copy of the GNU General Public License 00036 * along with this program; if not, write to the Free Software 00037 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00038 */ 00039 00040 00041 /* Please do not change the Begin/End lines of this comment section! 00042 * this is a LaTeX style section used for auto generation of the PlugIn Manual 00043 * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks! 00044 * All "% PlugInXXX" commentary tags are mandatory 00045 * All "% OptPlugInXXX" tags are optional and can be removed or commented in 00046 * -------------------------------------------------------------------------------- 00047 % BeginPlugInDocuSection 00048 % PlugInDocuCaption: Horizontal merge 00049 % PlugInName: merge_h 00050 % PlugInAuthor: Percy Zahl 00051 % PlugInAuthorEmail: zahl@users.sf.net 00052 % PlugInMenuPath: Math/Transformations/Merge H 00053 00054 % PlugInDescription 00055 Used to horizontal merge to scans together. The scan are expected to 00056 have same height. 00057 00058 % PlugInUsage 00059 Call \GxsmMenu{Math/Transformations/Merge H}. 00060 00061 % OptPlugInSources 00062 The active and X channel are merged. 00063 00064 %% OptPlugInObjects 00065 %A optional rectangle is used for data extraction... 00066 00067 % OptPlugInDest 00068 The computation result is placed into an existing math channel, else 00069 into a new created math channel. 00070 00071 %% OptPlugInConfig 00072 %describe the configuration options of your plug in here! 00073 00074 %% OptPlugInNotes 00075 %The scan are expected to have same height. 00076 00077 % EndPlugInDocuSection 00078 * -------------------------------------------------------------------------------- 00079 */ 00080 00081 #include <gtk/gtk.h> 00082 #include "config.h" 00083 #include "gxsm/plugin.h" 00084 00085 // Plugin Prototypes 00086 static void merge_h_init( void ); 00087 static void merge_h_about( void ); 00088 static void merge_h_configure( void ); 00089 static void merge_h_cleanup( void ); 00090 00091 // Define Type of math plugin here, only one line should be commented in!! 00092 // #define GXSM_ONE_SRC_PLUGIN__DEF 00093 #define GXSM_TWO_SRC_PLUGIN__DEF 00094 00095 // Math-Run-Function, use only one of (automatically done :=) 00096 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00097 // "OneSrc" Prototype 00098 static gboolean merge_h_run( Scan *Src, Scan *Dest ); 00099 #else 00100 // "TwoSrc" Prototype 00101 static gboolean merge_h_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00102 #endif 00103 00104 // Fill in the GxsmPlugin Description here 00105 GxsmPlugin merge_h_pi = { 00106 NULL, // filled in and used by Gxsm, don't touch ! 00107 NULL, // filled in and used by Gxsm, don't touch ! 00108 0, // filled in and used by Gxsm, don't touch ! 00109 NULL, // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 00110 // filled in here by Gxsm on Plugin load, 00111 // just after init() is called !!! 00112 // ---------------------------------------------------------------------- 00113 // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc 00114 "merge_h-" 00115 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00116 "M1S" 00117 #else 00118 "M2S" 00119 #endif 00120 "-TR", 00121 // Plugin's Category - used to autodecide on Pluginloading or ignoring 00122 // NULL: load, else 00123 // example: "+noHARD +STM +AFM" 00124 // load only, if "+noHARD: no hardware" and Instrument is STM or AFM 00125 // +/-xxxHARD und (+/-INST or ...) 00126 NULL, 00127 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00128 "Horizontally merge two scans of same height", 00129 // Author(s) 00130 "Percy Zahl", 00131 // Menupath to position where it is appendet to 00132 N_("_Math/_Transformations/"), 00133 // Menuentry 00134 N_("Merge H"), 00135 // help text shown on menu 00136 N_("Horizontally merge two scans."), 00137 // more info... 00138 "Horizontally merge two scans of same height", 00139 NULL, // error msg, plugin may put error status msg here later 00140 NULL, // Plugin Status, managed by Gxsm, plugin may manipulate it too 00141 // init-function pointer, can be "NULL", 00142 // called if present at plugin load 00143 merge_h_init, 00144 // query-function pointer, can be "NULL", 00145 // called if present after plugin init to let plugin manage it install itself 00146 NULL, // query should be "NULL" for Gxsm-Math-Plugin !!! 00147 // about-function, can be "NULL" 00148 // can be called by "Plugin Details" 00149 merge_h_about, 00150 // configure-function, can be "NULL" 00151 // can be called by "Plugin Details" 00152 merge_h_configure, 00153 // run-function, can be "NULL", if non-Zero and no query defined, 00154 // it is called on menupath->"plugin" 00155 NULL, // run should be "NULL" for Gxsm-Math-Plugin !!! 00156 // cleanup-function, can be "NULL" 00157 // called if present at plugin removeal 00158 merge_h_cleanup 00159 }; 00160 00161 // special math Plugin-Strucure, use 00162 // GxsmMathOneSrcPlugin merge_h_m1s_pi -> "OneSrcMath" 00163 // GxsmMathTwoSrcPlugin merge_h_m2s_pi -> "TwoSrcMath" 00164 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00165 GxsmMathOneSrcPlugin merge_h_m1s_pi 00166 #else 00167 GxsmMathTwoSrcPlugin merge_h_m2s_pi 00168 #endif 00169 = { 00170 // math-function to run, see prototype(s) above!! 00171 merge_h_run 00172 }; 00173 00174 // Text used in Aboutbox, please update!! 00175 static const char *about_text = N_("Gxsm merge_h Plugin\n\n" 00176 "Horizontally merge two scans together."); 00177 00178 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 00179 // Essential Plugin Function!! 00180 GxsmPlugin *get_gxsm_plugin_info ( void ){ 00181 merge_h_pi.description = g_strdup_printf(N_("Gxsm MathOneArg merge_h plugin %s"), VERSION); 00182 return &merge_h_pi; 00183 } 00184 00185 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 00186 // used to find out which Math Type the Plugin is!! 00187 // Essential Plugin Function!! 00188 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00189 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) { 00190 return &merge_h_m1s_pi; 00191 } 00192 #else 00193 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00194 return &merge_h_m2s_pi; 00195 } 00196 #endif 00197 00198 /* Here we go... */ 00199 // init-Function 00200 static void merge_h_init(void) 00201 { 00202 PI_DEBUG (DBG_L2, "merge_h Plugin Init"); 00203 } 00204 00205 // about-Function 00206 static void merge_h_about(void) 00207 { 00208 const gchar *authors[] = { merge_h_pi.authors, NULL}; 00209 gtk_widget_show(gnome_about_new ( merge_h_pi.name, 00210 VERSION, 00211 N_("(C) 2000 the Free Software Foundation"), 00212 about_text, 00213 authors, 00214 NULL, NULL, NULL 00215 )); 00216 } 00217 00218 // configure-Function 00219 static void merge_h_configure(void) 00220 { 00221 if(merge_h_pi.app) 00222 merge_h_pi.app->message("merge_h Plugin Configuration"); 00223 } 00224 00225 // cleanup-Function 00226 static void merge_h_cleanup(void) 00227 { 00228 PI_DEBUG (DBG_L2, "merge_h Plugin Cleanup"); 00229 } 00230 00231 // run-Function 00232 static gboolean merge_h_run(Scan *Src1, Scan *Src2, Scan *Dest) 00233 { 00234 if(Src1->mem2d->GetNy() != Src2->mem2d->GetNy()) 00235 return MATH_SELECTIONERR; 00236 00237 Dest->mem2d->Resize(Src1->mem2d->GetNx()+Src2->mem2d->GetNx(), Src1->mem2d->GetNy()); 00238 Dest->data.s.nx = Dest->mem2d->GetNx(); 00239 Dest->data.s.ny = Dest->mem2d->GetNy(); 00240 Dest->data.s.rx = Src1->data.s.rx + Src2->data.s.rx; 00241 00242 Dest->mem2d->CopyFrom(Src1->mem2d, 0,0, 0,0, Src1->mem2d->GetNx(),Src1->mem2d->GetNy()); 00243 Dest->mem2d->CopyFrom(Src2->mem2d, 0,0, Src1->mem2d->GetNx(), 0,Src2->mem2d->GetNx(),Src2->mem2d->GetNy()); 00244 00245 return MATH_OK; 00246 } 00247 00248