00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <string.h>
00024 #include <stdlib.h>
00025 #include "AtomRep.h"
00026 #include "Inform.h"
00027 #include "utilities.h"
00028 #include "config.h"
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 #define DEF_CART_RES 12.0
00077
00078
00079 #define DEF_BOND_RES 10.0
00080
00081
00082 #define DEF_SPH_RES 12.0
00083
00084
00085 #define DEF_LIC_RES 10.0
00086
00087
00088 #define DEF_LINE_RES 1.0
00089
00090
00091 #define DEF_POINT_SIZE 1.0
00092
00093
00094 #define UNUSED {0, 0.0}
00095
00096
00097 const AtomRepParamStruct AtomRepInfo[AtomRep::TOTAL] = {
00098
00099
00100
00101
00102
00103 { "Lines", 2, {
00104 { AtomRep::LINETHICKNESS, DEF_LINE_RES },
00105 { AtomRep::ISOLINETHICKNESS, 0.0f },
00106 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00107 },
00108
00109
00110 { "Bonds", 2, {
00111 { AtomRep::BONDRAD, 0.3f },
00112 { AtomRep::BONDRES, DEF_BOND_RES },
00113 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00114 },
00115
00116
00117 { "DynamicBonds", 3, {
00118 { AtomRep::SPHERERAD, 3.0f },
00119 { AtomRep::BONDRAD, 0.3f },
00120 { AtomRep::BONDRES, DEF_BOND_RES },
00121 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00122 },
00123
00124
00125 { "HBonds", 3, {
00126 { AtomRep::BONDRAD, 3.0f},
00127 { AtomRep::SPHERERAD, 20.0f},
00128 { AtomRep::LINETHICKNESS, 1.0f},
00129 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00130 },
00131
00132
00133
00134
00135
00136
00137
00138 { "Points", 1, {
00139 { AtomRep::LINETHICKNESS, DEF_POINT_SIZE},
00140 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00141 },
00142
00143
00144 { "VDW", 2, {
00145 { AtomRep::SPHERERAD, 1.0f},
00146 { AtomRep::SPHERERES, DEF_SPH_RES },
00147 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00148 },
00149
00150
00151 { "CPK", 5, {
00152 { AtomRep::SPHERERAD, 1.0f},
00153 { AtomRep::BONDRAD, 0.3f},
00154 { AtomRep::SPHERERES, DEF_SPH_RES},
00155 { AtomRep::BONDRES, DEF_BOND_RES},
00156 { AtomRep::ISOLINETHICKNESS, 0.0f },
00157 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00158 },
00159
00160
00161 { "Licorice", 4, {
00162 { AtomRep::BONDRAD, 0.3f },
00163 { AtomRep::SPHERERES, DEF_LIC_RES},
00164 { AtomRep::BONDRES, DEF_LIC_RES},
00165 { AtomRep::ISOLINETHICKNESS, 0.0f },
00166 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00167 },
00168
00169
00170 #ifdef VMDPOLYHEDRA
00171
00172 { "Polyhedra", 1, {
00173 { AtomRep::SPHERERAD, 3.0f },
00174 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00175 },
00176 #endif
00177
00178
00179
00180
00181
00182
00183 { "Trace", 2, {
00184 { AtomRep::BONDRAD, 0.3f},
00185 { AtomRep::BONDRES, DEF_BOND_RES},
00186 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00187 },
00188
00189
00190 { "Tube", 2, {
00191 { AtomRep::BONDRAD, 0.3f },
00192 { AtomRep::BONDRES, DEF_BOND_RES},
00193 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00194 },
00195
00196
00197 { "Ribbons", 3, {
00198 { AtomRep::BONDRAD, 0.3f},
00199 { AtomRep::BONDRES, DEF_BOND_RES},
00200 { AtomRep::LINETHICKNESS, 2.0f},
00201 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00202 },
00203
00204
00205 { "NewRibbons", 4, {
00206 { AtomRep::BONDRAD, 0.3f },
00207 { AtomRep::BONDRES, 10.0f },
00208 { AtomRep::LINETHICKNESS, 3.0f},
00209 { AtomRep::SPHERERAD, 0},
00210 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00211 },
00212
00213
00214 { "Cartoon", 3, {
00215 { AtomRep::BONDRAD, 2.1f},
00216 { AtomRep::BONDRES, DEF_CART_RES },
00217 { AtomRep::LINETHICKNESS, 5.0f},
00218 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00219 },
00220
00221
00222 { "NewCartoon", 4, {
00223 { AtomRep::BONDRAD, 0.3f },
00224 { AtomRep::BONDRES, 10.0f },
00225 { AtomRep::LINETHICKNESS, 4.5f},
00226 { AtomRep::SPHERERAD, 0},
00227 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00228 },
00229
00230 #ifdef VMDWITHCARBS
00231
00232 { "PaperChain", 2, {
00233 { AtomRep::LINETHICKNESS, 1.0f },
00234 { AtomRep::ISOSTEPSIZE, 10 },
00235 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00236 },
00237
00238
00239 { "Twister", 7, {
00240 { AtomRep::LINETHICKNESS, 1 },
00241 { AtomRep::BONDRES, 0 },
00242 { AtomRep::SPHERERAD, 10 },
00243 { AtomRep::BONDRAD, 0.3f },
00244 { AtomRep::SPHERERES, 0.05f },
00245 { AtomRep::ISOSTEPSIZE, 10 },
00246 { AtomRep::ISOLINETHICKNESS, 5 },
00247 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00248 },
00249 #endif
00250
00251
00252
00253
00254
00255
00256 #ifdef VMDQUICKSURF
00257
00258 { "QuickSurf", 4, {
00259 { AtomRep::SPHERERAD, 1.0f },
00260 { AtomRep::BONDRAD, 0.5f },
00261 { AtomRep::GRIDSPACING, 1.0f},
00262 { AtomRep::BONDRES, 0 },
00263 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00264 },
00265 #endif
00266
00267 #ifdef VMDMSMS
00268
00269 { "MSMS", 4, {
00270 { AtomRep::SPHERERAD, 1.5f },
00271 { AtomRep::SPHERERES, 1.5f },
00272 { AtomRep::LINETHICKNESS, 0},
00273 { AtomRep::BONDRES, 0},
00274 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00275 },
00276 #endif
00277
00278 #ifdef VMDSURF
00279
00280 { "Surf", 2, {
00281 { AtomRep::SPHERERAD, 1.4f },
00282 { AtomRep::BONDRES, 0},
00283 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00284 },
00285 #endif
00286
00287
00288 { "VolumeSlice", 4, {
00289 { AtomRep::SPHERERAD, 0.5f },
00290 { AtomRep::SPHERERES, 0 },
00291 { AtomRep::LINETHICKNESS, 0 },
00292 { AtomRep::BONDRES, 2 },
00293 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00294 },
00295
00296
00297 { "Isosurface", 6, {
00298 { AtomRep::SPHERERAD, 0.5f },
00299 { AtomRep::SPHERERES, 0},
00300 { AtomRep::LINETHICKNESS, 2},
00301 { AtomRep::BONDRES, 2},
00302 { AtomRep::ISOSTEPSIZE, 1},
00303 { AtomRep::ISOLINETHICKNESS, 1},
00304 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00305 },
00306
00307
00308 { "FieldLines", 5, {
00309 { AtomRep::SPHERERES, 0},
00310 { AtomRep::SPHERERAD, 1.8f},
00311 { AtomRep::BONDRAD, 10.0f},
00312 { AtomRep::BONDRES, 50.0f},
00313 { AtomRep::LINETHICKNESS, 1},
00314 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00315 },
00316
00317
00318 { "Orbital", 10, {
00319 { AtomRep::SPHERERAD, 0.05f},
00320 { AtomRep::SPHERERES, 0},
00321 { AtomRep::LINETHICKNESS, 0},
00322 { AtomRep::BONDRES, 0},
00323 { AtomRep::GRIDSPACING, 0.075f},
00324 { AtomRep::ISOLINETHICKNESS, 1},
00325 { AtomRep::WAVEFNCTYPE, 0},
00326 { AtomRep::WAVEFNCSPIN, 0},
00327 { AtomRep::WAVEFNCEXCITATION, 0},
00328 { AtomRep::ISOSTEPSIZE, 1},
00329 UNUSED, UNUSED }
00330 },
00331
00332
00333 { "Beads", 2, {
00334 { AtomRep::SPHERERAD, 1.0f},
00335 { AtomRep::SPHERERES, DEF_SPH_RES },
00336 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00337 },
00338
00339
00340 { "Dotted", 2, {
00341 { AtomRep::SPHERERAD, 1.0f},
00342 { AtomRep::SPHERERES, DEF_SPH_RES},
00343 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00344 },
00345
00346
00347 { "Solvent", 3, {
00348 { AtomRep::SPHERERAD, 0 },
00349
00350
00351 { AtomRep::SPHERERES, 7.0f},
00352 { AtomRep::LINETHICKNESS, 1.0f },
00353 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00354 }
00355 };
00356
00357
00359
00360 AtomRep::AtomRep(void) {
00361 int i, j;
00362
00363
00364 repMethod = DEFAULT_ATOMREP;
00365 repData = repDataStorage[repMethod];
00366 strcpy(cmdStr, AtomRepInfo[repMethod].name);
00367 for(j=0; j < TOTAL; j++) {
00368 memset(repDataStorage[j], 0, MAX_ATOMREP_DATA*sizeof(float));
00369 for(i=0; i < AtomRepInfo[j].numdata ; i++)
00370 repDataStorage[j][AtomRepInfo[j].repdata[i].index] =
00371 AtomRepInfo[j].repdata[i].defValue;
00372 }
00373
00374 }
00375
00376 AtomRep::~AtomRep(void) { }
00377
00379
00380 int AtomRep::parse_cmd(const char *newcmd) {
00381 int argc, i, j;
00382 char *argv[256], *cmdStrTok = NULL;
00383
00384
00385 if(newcmd && strlen(newcmd) > MAX_ATOMREP_CMD) {
00386 msgErr << "Atom representation string is too long (over ";
00387 msgErr << MAX_ATOMREP_CMD << " characters)." << sendmsg;
00388 return FALSE;
00389 }
00390
00391
00392 if (!strupncmp(newcmd, "off", 3)) newcmd = "Lines";
00393
00394
00395 if(!newcmd || !(cmdStrTok = str_tokenize(newcmd, &argc, argv))) {
00396
00397 return TRUE;
00398 }
00399
00400
00401 for(i=0; i < AtomRep::TOTAL; i++) {
00402 const AtomRepParamStruct *ari = &(AtomRepInfo[i]);
00403
00404 if(!strupncmp(argv[0], ari->name, CMDLEN)) {
00405
00406 if((argc - 1) > ari->numdata) {
00407 msgErr << "Incorrect atom representation command '" << newcmd << "':";
00408 msgErr << "\n '" << ari->name << "' only takes " << ari->numdata;
00409 msgErr << " arguments maximum." << sendmsg;
00410
00411 delete [] cmdStrTok;
00412 return FALSE;
00413 }
00414
00415
00416 repMethod = i;
00417 repData = repDataStorage[i];
00418
00419
00420 for(j=1; j < argc; j++) {
00421
00422 if(!(argv[j][0] == '-' && argv[j][1] == '\0'))
00423 repData[ari->repdata[j-1].index] = (float) atof(argv[j]);
00424 }
00425
00426
00427 break;
00428 }
00429 }
00430
00431
00432 if(i == AtomRep::TOTAL) {
00433 msgErr << "Unknown atom representation command '" << newcmd << "'.";
00434 msgErr << sendmsg;
00435
00436 delete [] cmdStrTok;
00437 return FALSE;
00438 }
00439
00440
00441 strcpy(cmdStr, newcmd);
00442
00443 delete [] cmdStrTok;
00444 return TRUE;
00445 }
00446
00447
00449
00450
00451 AtomRep &AtomRep::operator=(const AtomRep &ar) {
00452 strcpy(cmdStr, ar.cmdStr);
00453 repMethod = ar.repMethod;
00454 repData = repDataStorage[repMethod];
00455 for(int j=0; j < TOTAL; j++)
00456 for(int i=0; i < MAX_ATOMREP_DATA; i++)
00457 repDataStorage[j][i] = ar.repDataStorage[j][i];
00458
00459 return *this;
00460 }
00461