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
00070
00071
00072
00073
00074
00075
00076
00077 #include <gtk/gtk.h>
00078 #include "config.h"
00079 #include "gxsm/plugin.h"
00080
00081
00082 static void stop_ccr_init( void );
00083 static void stop_ccr_about( void );
00084 static void stop_ccr_configure( void );
00085 static void stop_ccr_cleanup( void );
00086
00087
00088 #define GXSM_ONE_SRC_PLUGIN__DEF
00089
00090
00091
00092 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00093
00094 static gboolean stop_ccr_run( Scan *Src, Scan *Dest );
00095 #else
00096
00097 static gboolean stop_ccr_run( Scan *Src1, Scan *Src2, Scan *Dest );
00098 #endif
00099
00100
00101 GxsmPlugin stop_ccr_pi = {
00102 NULL,
00103 NULL,
00104 0,
00105 NULL,
00106
00107
00108
00109
00110 "stop_ccr-"
00111 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00112 "M1S"
00113 #else
00114 "M2S"
00115 #endif
00116 "-BG",
00117
00118
00119
00120
00121
00122 NULL,
00123
00124 "Stop band zeroing, C conj., all rectangles",
00125
00126 "Percy Zahl",
00127
00128 N_("_Math/_Background/"),
00129
00130 N_("Stop CC"),
00131
00132 N_("Stop band zeroing, C conj., all rectangles"),
00133
00134 "Stop band zeroing, CC",
00135 NULL,
00136 NULL,
00137
00138
00139 stop_ccr_init,
00140
00141
00142 NULL,
00143
00144
00145 stop_ccr_about,
00146
00147
00148 stop_ccr_configure,
00149
00150
00151 NULL,
00152
00153
00154 stop_ccr_cleanup
00155 };
00156
00157
00158
00159
00160 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00161 GxsmMathOneSrcPlugin stop_ccr_m1s_pi
00162 #else
00163 GxsmMathTwoSrcPlugin stop_ccr_m2s_pi
00164 #endif
00165 = {
00166
00167 stop_ccr_run
00168 };
00169
00170
00171 static const char *about_text = N_("Gxsm stop_ccr Plugin\n\n"
00172 "Stop band zeroing, C conj., all rectangles");
00173
00174
00175
00176 GxsmPlugin *get_gxsm_plugin_info ( void ){
00177 stop_ccr_pi.description = g_strdup_printf(N_("Gxsm MathOneArg stop_ccr plugin %s"), VERSION);
00178 return &stop_ccr_pi;
00179 }
00180
00181
00182
00183
00184 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00185 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) {
00186 return &stop_ccr_m1s_pi;
00187 }
00188 #else
00189 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) {
00190 return &stop_ccr_m2s_pi;
00191 }
00192 #endif
00193
00194
00195
00196 static void stop_ccr_init(void)
00197 {
00198 PI_DEBUG (DBG_L2, "stop_ccr Plugin Init");
00199 }
00200
00201
00202 static void stop_ccr_about(void)
00203 {
00204 const gchar *authors[] = { stop_ccr_pi.authors, NULL};
00205 gtk_widget_show(gnome_about_new ( stop_ccr_pi.name,
00206 VERSION,
00207 N_("(C) 2000 the Free Software Foundation"),
00208 about_text,
00209 authors,
00210 NULL, NULL, NULL
00211 ));
00212 }
00213
00214
00215 static void stop_ccr_configure(void)
00216 {
00217 if(stop_ccr_pi.app)
00218 stop_ccr_pi.app->message("stop_ccr Plugin Configuration");
00219 }
00220
00221
00222 static void stop_ccr_cleanup(void)
00223 {
00224 PI_DEBUG (DBG_L2, "stop_ccr Plugin Cleanup");
00225 }
00226
00227
00228
00229 #define LL_DEBUG(STR)
00230 static gboolean stop_ccr_run(Scan *Src, Scan *Dest)
00231 {
00232 int num_rects=0;
00233 int n_obj = Src->number_of_object ();
00234
00235 LL_DEBUG( "stop_ccr_run:: numobj=" << n_obj );
00236
00237 CopyScan(Src, Dest);
00238 LL_DEBUG( "stop_ccr_run:: copy done" );
00239
00240 if (n_obj < 1)
00241 return MATH_SELECTIONERR;
00242
00243 while (n_obj--){
00244 LL_DEBUG( "stop_ccr_run:: checking obj " << n_obj );
00245 scan_object_data *obj_data = Src->get_object_data (n_obj);
00246
00247 if (strncmp (obj_data->get_name (), "Rectangle", 9) )
00248 continue;
00249
00250 if (obj_data->get_num_points () != 2)
00251 continue;
00252
00253 LL_DEBUG( "stop_ccr_run:: processing rect" << n_obj );
00254
00255
00256 double x0,y0,x1,y1;
00257 obj_data->get_xy (0, x0, y0);
00258 obj_data->get_xy (1, x1, y1);
00259
00260 LL_DEBUG( "AA rect sel: "
00261 "(" << x0 << ", " << y0 << "),"
00262 "(" << x1 << ", " << y1 << ")" );
00263
00264
00265 Point2D p[2];
00266 Src->World2Pixel (x0, y0, p[0].x, p[0].y);
00267 Src->World2Pixel (x1, y1, p[1].x, p[1].y);
00268
00269 LL_DEBUG( "Pix rect sel: "
00270 "(" << p[0].x << ", " << p[0].y << "),"
00271 "(" << p[1].x << ", " << p[1].y << ")" );
00272
00273
00274 MOUSERECT msr, msrPktSym;
00275 MkMausSelect(p, &msr, Dest->mem2d->GetNx(), Dest->mem2d->GetNy());
00276 MkMausSelect(p, &msrPktSym, Dest->mem2d->GetNx(), Dest->mem2d->GetNy());
00277
00278 if (msr.xSize < 1 || msr.ySize < 1)
00279 continue;
00280
00281
00282 LL_DEBUG( "stop_ccr_run:: zero rect" );
00283 LL_DEBUG( "(" << msr.xLeft << ", " << msr.yTop << "),("
00284 << msr.xSize << ", " << msr.ySize << ")" );
00285 Dest->mem2d->data->set_all_Z (ZEROVALUE, -1, msr.xLeft,msr.yTop, msr.xSize, msr.ySize);
00286
00287
00288 msr.yTop = Dest->mem2d->GetNy()-msrPktSym.yBottom-1;
00289 msr.yBottom = Dest->mem2d->GetNy()-msrPktSym.yTop-1;
00290 msr.xLeft = Dest->mem2d->GetNx()-msrPktSym.xRight-1;
00291 msr.xRight = Dest->mem2d->GetNx()-msrPktSym.xLeft-1;
00292
00293
00294 LL_DEBUG( "stop_ccr_run:: zero CC rect" );
00295 LL_DEBUG( "(" << msr.xLeft << ", " << msr.yTop << "),("
00296 << msr.xSize << ", " << msr.ySize << ")" );
00297 Dest->mem2d->data->set_all_Z (ZEROVALUE, -1, msr.xLeft,msr.yTop, msr.xSize, msr.ySize);
00298
00299
00300 ++num_rects;
00301 LL_DEBUG( "stop_ccr_run:: processer rects=" << num_rects );
00302 }
00303
00304 if (!num_rects)
00305 return MATH_SELECTIONERR;
00306
00307 return MATH_OK;
00308 }
00309
00310