1 /* 2 3 ***************************************************************************** 4 * Author: * 5 * ------ * 6 * Anton Kokalj Email: Tone.Kokalj@ijs.si * 7 * Department of Physical and Organic Chemistry Phone: x 386 1 477 3523 * 8 * Jozef Stefan Institute Fax: x 386 1 477 3811 * 9 * Jamova 39, SI-1000 Ljubljana * 10 * SLOVENIA * 11 * * 12 * Source: $XCRYSDEN_TOPDIR/C/crySurfArgs.c 13 * ------ * 14 * Copyright (c) 1996-2003 by Anton Kokalj * 15 ***************************************************************************** 16 17 */ 18 19 #include <togl.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <string.h> 23 #include <math.h> 24 #include "xcGLparam.h" 25 #include "struct.h" 26 #include "isosurf.h" 27 #include "memory.h" 28 #include "molsurf.h" 29 #include "xcfunc.h" 30 31 32 int 33 VerifyReadSurfOpt(const char *option, size_t n, 34 struct READSURF_OPT *opts, char *argv[]) 35 { 36 char *opt; 37 int i; 38 39 i=0; 40 opt = opts[i].option; 41 while( opt ) { 42 if ( strncmp( option, opt, n ) == 0 ) { 43 if ( opts[i].flag == XC_FORBIDDEN ) { 44 fprintf(stderr, "option %s not allowed !!!\nError while executing %s %s", option, argv[0], argv[1]); 45 return XC_ERROR; 46 } else { 47 return XC_OK; 48 } 49 } 50 opt = opts[++i].option; 51 } 52 53 fprintf(stderr, "option %s not known !!!\nError while executing %s %s", 54 option, argv[0], argv[1]); 55 return XC_ERROR; 56 } 57 58 59 int 60 cryReadSurfARGS(ClientData clientData,Tcl_Interp *interp, 61 int argc, char *argv[], NEW_WIN_CONTEXT *wc, MOL_SURF *mols, 62 struct READSURF_OPT *opt) 63 { 64 register int i, j; 65 66 for (i=4; i<argc; i+=2) { 67 /* -TYPE */ 68 if ( strcmp(argv[i], "-type") == 0 ) { 69 if ( !VerifyReadSurfOpt("-type", 5, opt, argv) ) return XC_ERROR; 70 71 if ( strncmp(argv[i+1], "gaus", 4) == 0 ) mols->type = MOLS_GAUSSIAN; 72 else if ( strcmp(argv[i+1], "exp") == 0 ) mols->type = MOLS_EXP; 73 else if ( strncmp(argv[i+1], "unig", 4) == 0 ) 74 mols->type = MOLS_UNIGAUSS; 75 else if ( strncmp(argv[i+1], "unie", 4) == 0 ) 76 mols->type = MOLS_UNIEXP; 77 else if ( strncmp(argv[i+1], "distf", 5) == 0 ) 78 mols->type = MOLS_DISTFUNC; 79 else if ( strncmp(argv[i+1], "fs", 2) == 0 || 80 strncmp(argv[i+1], "fermis", 6) == 0 ) 81 mols->type = MOLS_FERMISURFACE; 82 else { 83 char rss[1024]; 84 snprintf(rss, sizeof(rss),"unknown option \"%s\", while executing \"%s %s -type option\" command; option should be gauss, exp, unigauss, uniexp, distfuncor fermisurface\n", argv[i+1], argv[0], argv[1]); 85 Tcl_SetResult(interp, rss, TCL_VOLATILE); 86 return TCL_ERROR; 87 } 88 } 89 /* -RENDER */ 90 else if ( strncmp(argv[i], "-rend", 5) == 0 ) { 91 int index, rend; 92 if ( !VerifyReadSurfOpt("-rend", 3, opt, argv) ) return TCL_ERROR; 93 94 if ( Tcl_GetInt(interp, argv[i+1], &rend) == TCL_ERROR ) { 95 char rss[1024]; 96 snprintf(rss, sizeof(rss),"wanted integer, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 97 Tcl_SetResult(interp, rss, TCL_VOLATILE); 98 return TCL_ERROR; 99 } 100 index = FindSurfaceOfWindow( wc, mols ); 101 if ( index < 0 ) { 102 char rss[1024]; 103 snprintf(rss, sizeof(rss), "couldn't find surface #%d on window %s !!!\n", 104 mols->isosurf_index, argv[1]); 105 Tcl_SetResult(interp, rss, TCL_VOLATILE); 106 return TCL_ERROR; 107 } 108 wc->VPf.surface[index] = 1; 109 110 } 111 /* -FS */ 112 else if ( strncmp(argv[i], "-fs", 3) == 0 ) { 113 int argcList; 114 const char **argvList; 115 if ( !VerifyReadSurfOpt("-fs", 3, opt, argv) ) return TCL_ERROR; 116 117 Tcl_SplitList(interp, argv[i+1], &argcList, &argvList); 118 if ( !ReadFS_ARGS(interp, argcList, argvList, wc, mols) ) 119 return TCL_ERROR; 120 } 121 /* -RADIUS */ 122 else if ( strncmp(argv[i], "-radi", 5) == 0 ) { 123 if ( !VerifyReadSurfOpt("-radi", 5, opt, argv) ) return TCL_ERROR; 124 125 if ( strcmp(argv[i+1], "cov") == 0 ) mols->rad = rcov; 126 else if ( strcmp(argv[i+1], "VdW") == 0 ) mols->rad = rvdw; 127 else { 128 char rss[1024]; 129 snprintf(rss, sizeof(rss),"unknown option \"%s\", while executing \"%s %s -radius option\" command; option should be cov or VdW\n", 130 argv[i+1], argv[0], argv[1]); 131 Tcl_SetResult(interp, rss, TCL_VOLATILE); 132 return TCL_ERROR; 133 } 134 } 135 /* -LEVEL */ 136 else if ( strncmp(argv[i], "-leve", 5) == 0 ) { 137 double level; 138 if ( !VerifyReadSurfOpt("-leve", 5, opt, argv) ) return TCL_ERROR; 139 140 if ( Tcl_GetDouble(interp, argv[i+1], &level) == TCL_ERROR ) { 141 char rss[1024]; 142 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 143 Tcl_SetResult(interp, rss, TCL_VOLATILE); 144 return TCL_ERROR; 145 } 146 mols->isolevel = (float) level; 147 } 148 /* -CUTOFF */ 149 else if ( strncmp(argv[i], "-cuto", 5) == 0 ) { 150 double cutoff; 151 if ( !VerifyReadSurfOpt("-cuto", 5, opt, argv) ) return TCL_ERROR; 152 153 if ( Tcl_GetDouble(interp, argv[i+1], &cutoff) == TCL_ERROR ) { 154 char rss[1024]; 155 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 156 Tcl_SetResult(interp, rss, TCL_VOLATILE); 157 return TCL_ERROR; 158 } 159 mols->cutoff = (float) cutoff; 160 } 161 /* -COLORSHEME */ 162 else if ( strncmp(argv[i], "-colo", 5) == 0 ) { 163 if ( !VerifyReadSurfOpt("-colo", 5, opt, argv) ) return TCL_ERROR; 164 165 if ( strncmp(argv[i+1], "atom", 4) == 0 ) 166 mols->colorscheme = MOLS_ATOMIC; 167 else if ( strncmp(argv[i+1], "mono", 4) == 0 ) 168 mols->colorscheme = MOLS_MONOCHROME; 169 else { 170 char rss[1024]; 171 snprintf(rss, sizeof(rss),"unknown option \"%s\", while executing \"cry_molsurf %s -colorscheme option\" command; option should be atomic or monocolor\n", argv[i+1], argv[1]); 172 Tcl_SetResult(interp, rss, TCL_VOLATILE); 173 return TCL_ERROR; 174 } 175 } 176 /* -DRAWSTYLE */ 177 else if ( strncmp(argv[i], "-draw", 5) == 0 ) { 178 if ( !VerifyReadSurfOpt("-draw", 5, opt, argv) ) return TCL_ERROR; 179 180 if ( strcmp(argv[i+1], "solid") == 0 ) 181 mols->dispt.drawstyle = ISOSURF_SOLID; 182 else if ( strcmp(argv[i+1], "wire") == 0 ) 183 mols->dispt.drawstyle = ISOSURF_WIRE; 184 else if ( strcmp(argv[i+1], "dot") == 0 ) 185 mols->dispt.drawstyle = ISOSURF_DOT; 186 else { 187 char rss[1024]; 188 snprintf(rss, sizeof(rss),"unknown option \"%s\", while executing \"%s %s -drawstyle option\" command; option should be solid, wire or dot\n", 189 argv[i+1], argv[0], argv[1]); 190 Tcl_SetResult(interp, rss, TCL_VOLATILE); 191 return TCL_ERROR; 192 } 193 } 194 /* -TRANSPARENT */ 195 else if ( strncmp(argv[i], "-tran", 5) == 0 ) { 196 int transp; 197 if ( !VerifyReadSurfOpt("-tran", 5, opt, argv) ) return TCL_ERROR; 198 199 if ( Tcl_GetInt(interp, argv[i+1], &transp) == TCL_ERROR ) { 200 char rss[1024]; 201 snprintf(rss, sizeof(rss),"wanted integer, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 202 Tcl_SetResult(interp, rss, TCL_VOLATILE); 203 return TCL_ERROR; 204 } 205 mols->dispt.transparent = transp; 206 } Codec(int codec_id,CodecInst * codec_inst)207 /* -SHADEMODEL */ 208 else if ( strncmp(argv[i], "-shade", 6) == 0 ) { 209 if ( !VerifyReadSurfOpt("-shade", 6, opt, argv) ) return TCL_ERROR; 210 211 if ( strncmp(argv[i+1], "smooth", 6) == 0 ) 212 mols->dispt.shademodel = GL_SMOOTH; 213 else if ( strncmp(argv[i+1], "flat", 4) == 0 ) 214 mols->dispt.shademodel = GL_FLAT; 215 else { 216 char rss[1024]; 217 snprintf(rss, sizeof(rss),"unknown option \"%s\", while executing \"%s %s -shademodel option\" command; option should be smooth or flat\n", 218 argv[i+1], argv[0], argv[1]); 219 Tcl_SetResult(interp, rss, TCL_VOLATILE); 220 return TCL_ERROR; 221 } 222 } 223 /* -MONOCOLOR */ 224 else if ( strncmp(argv[i], "-mono", 5) == 0 ) { 225 double rgba; 226 int argcList; 227 const char **argvList; 228 if ( !VerifyReadSurfOpt("-mono", 5, opt, argv) ) return TCL_ERROR; 229 CodecNumber(const CodecInst & codec_inst,int * mirror_id)230 Tcl_SplitList(interp, argv[i+1], &argcList, &argvList); 231 for (j=0; j<argcList; j++) { 232 if ( Tcl_GetDouble(interp, argvList[j], &rgba) == TCL_ERROR ) { 233 char rss[1024]; 234 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 235 Tcl_SetResult(interp, rss, TCL_VOLATILE); 236 return TCL_ERROR; 237 } 238 mols->monocolor[j] = (float) rgba; 239 mols->back_monocolor[j] = 1.0 - (float) rgba; 240 } 241 if ( j < 4) { 242 mols->monocolor[3] = 0.5; 243 mols->back_monocolor[3] = 0.5; 244 } 245 } 246 247 /* -FRONTMONOCOLOR */ 248 else if ( strncmp(argv[i], "-frontmonocolor", 10) == 0 ) { 249 double rgba; 250 int argcList; 251 const char **argvList; 252 if ( !VerifyReadSurfOpt("-frontmonocolor", 10, opt, argv) ) return TCL_ERROR; 253 254 Tcl_SplitList(interp, argv[i+1], &argcList, &argvList); 255 for (j=0; j<argcList; j++) { 256 if ( Tcl_GetDouble(interp, argvList[j], &rgba) == TCL_ERROR ) { 257 char rss[1024]; 258 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\"", argv[i+1]); 259 Tcl_SetResult(interp, rss, TCL_VOLATILE); 260 return TCL_ERROR; 261 } 262 mols->monocolor[j] = (float) rgba; 263 } 264 if ( j < 4 ) mols->monocolor[3] = 0.5; 265 } 266 267 /* -BACKMONOCOLOR */ 268 else if ( strncmp(argv[i], "-backmonocolor", 9) == 0 ) { 269 double rgba; 270 int argcList; 271 const char **argvList; 272 if ( !VerifyReadSurfOpt("-backmonocolor", 9, opt, argv) ) return TCL_ERROR; 273 274 Tcl_SplitList(interp, argv[i+1], &argcList, &argvList); 275 for (j=0; j<argcList; j++) { 276 if ( Tcl_GetDouble(interp, argvList[j], &rgba) == TCL_ERROR ) { 277 char rss[1024]; 278 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\"", argv[i+1]); 279 Tcl_SetResult(interp, rss, TCL_VOLATILE); 280 return TCL_ERROR; 281 } 282 mols->back_monocolor[j] = (float) rgba; 283 } 284 if ( j < 4 ) mols->back_monocolor[3] = 0.5; 285 } 286 287 /* -SURFACETYPE */ 288 else if ( strncmp(argv[i], "-surf", 5) == 0 ) { 289 if ( !VerifyReadSurfOpt("-surf", 5, opt, argv) ) return TCL_ERROR; 290 291 if ( strncmp(argv[i+1], "mols", 4) == 0 ) 292 mols->surftype = MOLS_MOLSURF; 293 else if ( strncmp(argv[i+1], "gap", 3) == 0 ) 294 mols->surftype = MOLS_GAP; 295 else { 296 char rss[1024]; 297 snprintf(rss, sizeof(rss),"unknown option \"%s\", while executing \"%s %s -surftype option\" command; option should be molsurf or gap\n", 298 argv[i+1], argv[0], argv[1]); 299 Tcl_SetResult(interp, rss, TCL_VOLATILE); 300 return TCL_ERROR; 301 } 302 } 303 304 /* -RESOLUTION */ 305 else if ( strncmp(argv[i], "-res", 4) == 0 ) { 306 double res; 307 if ( !VerifyReadSurfOpt("-res", 5, opt, argv) ) return TCL_ERROR; 308 309 if ( Tcl_GetDouble(interp, argv[i+1], &res) == TCL_ERROR ) { 310 char rss[1024]; 311 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 312 Tcl_SetResult(interp, rss, TCL_VOLATILE); 313 return TCL_ERROR; 314 } 315 mols->d = (float) res; 316 } 317 318 /* -SMOOTHSTEPS */ 319 else if ( strncmp(argv[i], "-smooths", 8) == 0 ) { CodecId(const CodecInst & codec_inst)320 int nstep; 321 if ( !VerifyReadSurfOpt("-smooths", 8, opt, argv) ) return TCL_ERROR; 322 323 if ( Tcl_GetInt(interp, argv[i+1], &nstep) == TCL_ERROR ) { 324 char rss[1024]; CodecId(const char * payload_name,int frequency,int channels)325 snprintf(rss, sizeof(rss),"wanted integer, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 326 Tcl_SetResult(interp, rss, TCL_VOLATILE); 327 return TCL_ERROR; 328 } 329 mols->smooth_nstep = nstep; 330 } 331 332 /* -SMOOTHWEIGHT */ 333 else if ( strncmp(argv[i], "-smoothw", 8) == 0 ) { 334 double weight; 335 if ( !VerifyReadSurfOpt("-smoothw", 8, opt, argv) ) return TCL_ERROR; 336 337 if ( Tcl_GetDouble(interp, argv[i+1], &weight) == TCL_ERROR ) { 338 char rss[1024]; 339 snprintf(rss, sizeof(rss),"wanted double, but got \"%s\", while executing %s %s %s %s ...", argv[i+1], argv[0], argv[1], argv[2], argv[3]); 340 Tcl_SetResult(interp, rss, TCL_VOLATILE); 341 342 return TCL_ERROR; 343 } 344 mols->smooth_weight = (float) weight; 345 } 346 347 /* -FRONTFACE */ 348 else if ( strncmp(argv[i], "-frontface", 7) == 0 ) { 349 if ( strcmp(argv[i+1], "CW") == 0 ) 350 mols->frontface = GL_CW; 351 else if ( strcmp(argv[i+1], "CCW") == 0 ) 352 mols->frontface = GL_CCW; 353 } ReceiverCodecNumber(const CodecInst & codec_inst,int * mirror_id)354 355 /* -REVERTNORMALS */ 356 else if ( strncmp(argv[i], "-revertnormals", 8) == 0 ) { 357 int revertnormals; 358 if ( Tcl_GetInt(interp, argv[i+1], &revertnormals) == TCL_ERROR ) { 359 char rss[1024]; 360 snprintf(rss, sizeof(rss),"wanted int, but got \"%s\"", argv[i+1]); 361 Tcl_SetResult(interp, rss, TCL_VOLATILE); 362 return TCL_ERROR; 363 } 364 mols->revertnormals = revertnormals; 365 } 366 367 else { 368 char rss[1024]; 369 snprintf(rss, sizeof(rss), 370 "Usage: %s <tolg> -ident indent options ...", argv[0]); 371 Tcl_SetResult(interp, rss, TCL_VOLATILE); 372 return TCL_ERROR; CodecFreq(int codec_id)373 } 374 } 375 return TCL_OK; 376 } 377 378 379 int 380 ReadFS_ARGS(Tcl_Interp *interp, int argc, const char *argv[], 381 NEW_WIN_CONTEXT *wc, MOL_SURF *mols) 382 { BasicCodingBlock(int codec_id)383 register int i; 384 int gridindex = -1, gridsubindex = -1, bandindex = -1; 385 struct DATAGRID *grid; 386 387 /* -fs { 388 -gridindex <index> \ 389 -gridsubindex <subindex> \ 390 -bandindex <index> \ 391 -celltype para|bz \ 392 -cropbz 0|1 \ NetEQDecoders()393 -displaycell 0|1 \ ? 394 -celldisplaytype wire|rod|solid ? 395 } 396 */ 397 for (i=0; i<argc; i+=2) { 398 /* -GRIDINDEX */ MirrorID(int codec_id)399 if ( strncmp(argv[i], "-gridi", 6) == 0 ) { 400 if ( Tcl_GetInt(interp, argv[i+1], &gridindex) == TCL_ERROR ) { 401 char rss[1024]; 402 snprintf(rss, sizeof(rss),"wanted integer for -gridindex but got %s, while parsing -fs option !!!\n", argv[i+1]); 403 Tcl_SetResult(interp, rss, TCL_VOLATILE); 404 return XC_ERROR; 405 } 406 } 407 /* -GRIDSUBINDEX */ CreateCodecInstance(const CodecInst & codec_inst,int cng_pt_nb,int cng_pt_wb,int cng_pt_swb,int cng_pt_fb,bool enable_red,int red_payload_type)408 else if ( strncmp(argv[i], "-grids", 6) == 0 ) { 409 if ( Tcl_GetInt(interp, argv[i+1], &gridsubindex) == TCL_ERROR ) { 410 char rss[1024]; 411 snprintf(rss, sizeof(rss),"wanted integer for -gridsubindex but got %s, while parsing -fs option !!!\n", argv[i+1]); 412 Tcl_SetResult(interp, rss, TCL_VOLATILE); 413 return XC_ERROR; 414 } 415 } 416 /* -BANDINDEX */ 417 else if ( strncmp(argv[i], "-bandi", 6) == 0 ) { 418 if ( Tcl_GetInt(interp, argv[i+1], &bandindex) == TCL_ERROR ) { 419 char rss[1024]; 420 snprintf(rss, sizeof(rss),"wanted integer for -bandindex but got %s, while parsing -fs option !!!\n", argv[i+1]); 421 Tcl_SetResult(interp, rss, TCL_VOLATILE); 422 return XC_ERROR; 423 } 424 } 425 /* -CELLTYPE */ 426 else if ( strncmp(argv[i], "-cellt", 6) == 0 ) { 427 if ( strncmp(argv[i+1], "para", 4) == 0 ) 428 mols->fs.celltype = XCR_PARAPIPEDAL; 429 else if ( strncmp(argv[i+1], "bz", 2) == 0 ) 430 mols->fs.celltype = XCR_BZ; 431 else { 432 char rss[1024]; 433 snprintf(rss, sizeof(rss),"invalid cell type %s, must be para or bz !!!\n", argv[i+1]); 434 Tcl_SetResult(interp, rss, TCL_VOLATILE); 435 return XC_ERROR; 436 } 437 } 438 /* -CROPBZ */ 439 else if ( strncmp(argv[i], "-cropb", 6) == 0 ) { 440 int cropbz; 441 if ( Tcl_GetInt(interp, argv[i+1], &cropbz) == TCL_ERROR ) { 442 char rss[1024]; 443 snprintf(rss, sizeof(rss),"wanted 0 or 1 for -cropbz but got %s, while parsing -fs option !!!\n", argv[i+1]); 444 Tcl_SetResult(interp, rss, TCL_VOLATILE); 445 return XC_ERROR; 446 } 447 mols->fs.cropbz = (short int) cropbz; 448 } 449 /* -DISPLAYCELL */ IsRateValid(int codec_id,int rate)450 else if ( strncmp(argv[i], "-displayc", 9) == 0 ) { 451 if ( Tcl_GetInt(interp, argv[i+1], &wc->VPf.dispLattice) == TCL_ERROR ) { 452 char rss[1024]; 453 snprintf(rss, sizeof(rss),"wanted 0 or 1 for -displaycell but got %s, while parsing -fs option !!!\n", argv[i+1]); 454 Tcl_SetResult(interp, rss, TCL_VOLATILE); 455 return XC_ERROR; 456 } 457 } 458 /* -CELLDISPLAYTYPE */ 459 else if ( strncmp(argv[i], "-celld", 6) == 0 ) { IsILBCRateValid(int rate,int frame_size_samples)460 if ( strncmp(argv[i+1], "w", 1) == 0 ) 461 wc->VPf.dispLatType = CELL_WIRE; 462 else if ( strncmp(argv[i+1], "r", 1) == 0 ) 463 wc->VPf.dispLatType = CELL_ROD; 464 else if ( strncmp(argv[i+1], "solidw", 6 ) == 0 ) 465 wc->VPf.dispLatType = CELL_SOLID_AND_WIRE; 466 else if ( strncmp(argv[i+1], "solidr", 6 ) == 0 ) 467 wc->VPf.dispLatType = CELL_SOLID_AND_ROD; 468 else if ( strncmp(argv[i+1], "s", 1) == 0 ) 469 wc->VPf.dispLatType = CELL_SOLID; 470 else { 471 char rss[1024]; 472 snprintf(rss, sizeof(rss),"unknown celldisplaytype %s, must be one of wire, rod, solid, solidwire or solidrod !!!\n", argv[i+1]); IsAMRRateValid(int rate)473 Tcl_SetResult(interp, rss, TCL_VOLATILE); 474 return XC_ERROR; 475 } 476 } 477 /* -INTERPOLATIONDEGREE */ 478 else if ( strncmp(argv[i], "-interpolationdegree", 15) == 0 ) { 479 const char **argvList; 480 int argcList; 481 int ia, n[3]; 482 483 Tcl_SplitList(interp, argv[i+1], &argcList, &argvList); 484 if ( argcList != 3 ) { 485 char rss[1024]; 486 snprintf(rss, sizeof(rss), 487 "wanted three elements but got %d elements", argcList); 488 Tcl_SetResult(interp, rss, TCL_VOLATILE); 489 return TCL_ERROR; 490 } 491 for (ia=0; ia<3; ia++) { IsAMRwbRateValid(int rate)492 if ( Tcl_GetInt(interp, argvList[ia], &(n[ia])) == TCL_ERROR ) { 493 char rss[1024]; 494 snprintf(rss, sizeof(rss), "wanted integer but got %s", argvList[ia]); 495 Tcl_SetResult(interp, rss, TCL_VOLATILE); 496 return TCL_ERROR; 497 } 498 } 499 500 mols->interp_n[0] = n[0]; 501 mols->interp_n[1] = n[1]; 502 mols->interp_n[2] = n[2]; 503 } 504 505 /* -WIRECELLCOLOR */ 506 else if ( strncmp(argv[i], "-wirecellcolor", 10) == 0 ) { 507 GetGlParam color; 508 if ( !xcSplitList( XC_GET_RGBA, interp, argv + i + 1, &color ) ) 509 return TCL_ERROR; 510 COPY_V (4, mols->fs.wirecellcolor, color.vec); 511 } IsG7291RateValid(int rate)512 513 /* -SOLIDCELLCOLOR */ 514 else if ( strncmp(argv[i], "-solidcellcolor", 11) == 0 ) { 515 GetGlParam color; 516 if ( !xcSplitList( XC_GET_RGBA, interp, argv + i + 1, &color ) ) 517 return TCL_ERROR; 518 COPY_V (4, mols->fs.solidcellcolor, color.vec); 519 } 520 521 else { 522 char rss[1024]; 523 snprintf(rss, sizeof(rss), "unknown option %s, must be one of -gridindex, -bandindex, -celltype, -cropbz, -displaycell, -celldisplaytype, -wirecellcolor or -solidcellcolor", argv[i]); 524 Tcl_SetResult(interp, rss, TCL_VOLATILE); 525 return XC_ERROR; 526 } 527 } 528 529 /**************************************************/ 530 /* mandatory options are -gridindex and -bandindex */ 531 /**************************************************/ 532 if ( bandindex < 0 || gridindex < 0 || gridsubindex < 0 ) { 533 Tcl_SetResult(interp, "-gridindex, -gridsubindex and -bandindex options must be specified within -fs { options } !!!\n", TCL_STATIC); 534 return XC_ERROR; IsSpeexRateValid(int rate)535 } 536 537 if ( (grid = FindDataGrid( gridindex )) == NULL ) { 538 char rss[1024]; 539 snprintf(rss, sizeof(rss), "can't find grid %d !!!\n", gridindex); 540 Tcl_SetResult(interp, rss, TCL_VOLATILE); 541 return XC_ERROR; 542 } else mols->fs.gridindex = gridindex; 543 544 if ( gridsubindex < grid->n_of_subgrids) ValidPayloadType(int payload_type)545 mols->fs.gridsubindex = gridsubindex; 546 else { 547 char rss[1024]; 548 snprintf(rss, sizeof(rss), "to large gridsubindex %d, must be lower than %d !!!\n", OwnsDecoder(int codec_id)549 gridsubindex, grid->n_of_subgrids); 550 Tcl_SetResult(interp, rss, TCL_VOLATILE); 551 return XC_ERROR; 552 } 553 if ( bandindex < grid->nband ) 554 mols->fs.bandindex = bandindex; 555 else { 556 char rss[1024]; 557 snprintf(rss, sizeof(rss), "to large bandindex %d, must be lower than %d !!!\n", 558 gridsubindex, grid->nband); 559 Tcl_SetResult(interp, rss, TCL_VOLATILE); 560 return XC_ERROR; 561 } 562 return XC_OK; 563 } 564 565