73 Tcl_Obj* returnObj = NULL;
75 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
77 cout <<
"DEBUG do_layerline: Item: " << item <<
" (" << item.
length() <<
")" << endl;
84 cerr <<
"Error in do_layerline: Item " << item <<
" must be a micrograph!" << endl;
85 returnObj = Tcl_NewObj();
97 if ( field ) mg = field->
mg;
98 }
else if ( item.
contains(
"Micrograph") ) {
100 for ( mg = field->
mg; mg && mg->
id !=
id; mg = mg->
next ) ;
107 if ( filename.
length() < 1 ) filename = mg->
fps;
108 if ( filename.
length() < 1 ) filename = mg->
fmg;
112 if ( filename.
length() ) {
116 if ( filename2.
base() ==
base )
break;
121 returnObj = Tcl_NewObj();
122 sprintf(
string,
"Image %s not found!", filename.
c_str());
123 Tcl_AppendToObj(returnObj,
string, strlen(
string));
126 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
128 cout <<
"DEBUG do_layerline: Action: " << action <<
" (" << action.
length() <<
")" << endl;
130 if ( action ==
"count" ) {
132 }
else if ( action ==
"ids" ) {
134 }
else if ( action ==
"renumber" ) {
136 }
else if ( action ==
"distance" ) {
138 }
else if ( action ==
"fom" ) {
140 }
else if ( action ==
"select" ) {
142 }
else if ( action ==
"move" ) {
144 }
else if ( action ==
"create" ) {
146 }
else if ( action ==
"delete" ) {
149 }
else if ( action ==
"order" ) {
151 }
else if ( action ==
"generate" ) {
153 }
else if ( action ==
"mask" ) {
155 }
else if ( action ==
"plot" ) {
157 }
else if ( action ==
"bessel" ) {
160 cerr <<
"Error: Action " << action <<
" not recognized!" << endl;
164 returnObj = Tcl_NewObj();
165 Tcl_SetIntObj(returnObj, 0);
173 Tcl_Obj* returnObj = Tcl_NewObj();
179 for ( line = mg->
layer; line; line = line->
next ) nll++;
181 Tcl_SetIntObj(returnObj, nll);
188 Tcl_Obj* returnObj = Tcl_NewObj();
194 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
197 for ( line = mg->
layer; line; line = line->
next )
if ( line->
fom >= fom_cut ) {
198 sprintf(
string,
" %d", line->
number);
199 Tcl_AppendToObj(returnObj,
string, strlen(
string));
208 Tcl_Obj* returnObj = Tcl_NewObj();
212 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id1);
213 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &id2);
218 for ( line = mg->
layer; line && line->
number != id2; line = line->
next ) ;
222 for ( line = mg->
layer; line && line->
number != id1; line = line->
next ) ;
223 if ( line ) line->
number = id2;
227 Tcl_SetIntObj(returnObj, id2);
234 Tcl_Obj* returnObj = Tcl_NewObj();
240 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &
id);
243 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
247 Tcl_SetDoubleObj(returnObj, d);
254 Tcl_Obj* returnObj = Tcl_NewObj();
260 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &
id);
263 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
265 if ( line ) fom = line->
fom;
267 Tcl_SetDoubleObj(returnObj, fom);
274 Tcl_Obj* returnObj = Tcl_NewObj();
278 double x(0), y(0), w(0);
280 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
281 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
282 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &w);
291 for ( line = mg->
layer; line; line = line->
next ) {
298 if ( dmin <= w )
id = i;
301 Tcl_SetIntObj(returnObj,
id);
308 Tcl_Obj* returnObj = Tcl_NewObj();
311 double d(0), dx(0), dy(0);
313 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &
id);
314 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &dx);
315 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &dy);
320 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
327 Tcl_SetIntObj(returnObj,
id);
334 Tcl_Obj* returnObj = Tcl_NewObj();
340 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &
id);
341 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &x);
342 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &y);
358 Tcl_SetIntObj(returnObj,
id);
365 Tcl_Obj* returnObj = Tcl_NewObj();
370 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
376 if ( action ==
"all" || action ==
"mg" ) {
378 for ( mg = field->
mg; mg; mg = mg->
next ) {
385 if ( action ==
"fom" ) {
386 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
387 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &n);
389 if ( field )
for ( mg = field->
mg; mg; mg = mg->
next ) {
390 for ( line = mg->
layer; line; line = line->
next )
391 if ( line->
fom < fom_cut ) line->
sel = 0;
395 if ( field )
for ( mg = field->
mg; mg && mg->
img_num != n; mg = mg->
next ) ;
397 for ( line = mg->
layer; line; line = line->
next )
398 if ( line->
fom < fom_cut ) line->
sel = 0;
403 if ( objc > 3 ) Tcl_GetIntFromObj(NULL, objv[3], &
id);
404 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &n);
407 if ( field )
for ( mg = field->
mg; mg; mg = mg->
next ) {
408 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
413 if ( field )
for ( mg = field->
mg; mg && mg->
img_num != n; mg = mg->
next ) ;
415 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
423 Tcl_SetIntObj(returnObj,
id);
430 Tcl_Obj* returnObj = Tcl_NewObj();
434 Bstring action = Tcl_GetStringFromObj(objv[4], NULL);
438 if ( action ==
"all" ) {
442 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &
id);
445 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
452 Tcl_SetIntObj(returnObj,
id);
459 Tcl_Obj* returnObj = Tcl_NewObj();
461 int id(-1), order(0), set_order(0);
463 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &
id);
465 Tcl_GetIntFromObj(NULL, objv[5], &order);
472 for ( line = mg->
layer; line && line->
number !=
id; line = line->
next ) ;
474 if ( set_order ) line->
order = order;
475 else order = line->
order;
479 Tcl_SetIntObj(returnObj, order);
486 Tcl_Obj* returnObj = Tcl_NewObj();
488 int n(0), ind_lim(3);
490 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &ind_lim);
495 Tcl_SetIntObj(returnObj, n);
502 Tcl_Obj* returnObj = Tcl_NewObj();
507 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &width);
512 Tcl_SetIntObj(returnObj, n);
519 Tcl_Obj* returnObj = Tcl_NewObj();
521 int l(0), len(p->
sizeX()), i;
526 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &l);
527 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &len);
530 for ( line = mg->
layer; line && line->
number != l; line = line->
next ) ;
533 sprintf(
string,
"%d", len);
534 Tcl_AppendToObj(returnObj,
string, strlen(
string));
535 for ( i=0; i<p->
sizeX(); i++ ) {
536 sprintf(
string,
" %g", plot[i]);
537 Tcl_AppendToObj(returnObj,
string, strlen(
string));
548 Tcl_Obj* returnObj = Tcl_NewObj();
553 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &n);
554 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &radius);
555 if ( objc > 6 ) Tcl_GetIntFromObj(NULL, objv[6], &len);
557 if ( radius < 1 )
return returnObj;
561 double j, scale =
TWOPI*radius/realsizeX;
563 sprintf(
string,
"%d", len);
564 Tcl_AppendToObj(returnObj,
string, strlen(
string));
565 for ( x=0; x<len; x++ ) {
566 j = jn(n, (x - len/2)*scale);
567 sprintf(
string,
" %g", j*j);
568 Tcl_AppendToObj(returnObj,
string, strlen(
string));