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 6.0
00080
00081
00082 #define DEF_SPH_RES 8.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 }
00107 },
00108
00109
00110 { "Bonds", 2, {
00111 { AtomRep::BONDRAD, 0.3f },
00112 { AtomRep::BONDRES, DEF_BOND_RES },
00113 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 }
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 }
00130 },
00131
00132
00133
00134
00135
00136
00137
00138 { "Points", 1, {
00139 { AtomRep::LINETHICKNESS, DEF_POINT_SIZE},
00140 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 }
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 }
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 }
00167 },
00168
00169
00170
00171
00172
00173
00174
00175 { "Trace", 2, {
00176 { AtomRep::BONDRAD, 0.3f},
00177 { AtomRep::BONDRES, DEF_BOND_RES},
00178 UNUSED, UNUSED, UNUSED, UNUSED }
00179 },
00180
00181
00182 { "Tube", 2, {
00183 { AtomRep::BONDRAD, 0.3f },
00184 { AtomRep::BONDRES, DEF_BOND_RES},
00185 UNUSED, UNUSED, UNUSED, UNUSED }
00186 },
00187
00188
00189 { "Ribbons", 3, {
00190 { AtomRep::BONDRAD, 0.3f},
00191 { AtomRep::BONDRES, DEF_BOND_RES},
00192 { AtomRep::LINETHICKNESS, 2.0f},
00193 UNUSED, UNUSED, UNUSED }
00194 },
00195
00196
00197 { "NewRibbons", 4, {
00198 { AtomRep::BONDRAD, 0.3f },
00199 { AtomRep::BONDRES, DEF_BOND_RES },
00200 { AtomRep::LINETHICKNESS, 3.0f},
00201 { AtomRep::SPHERERAD, 0},
00202 UNUSED, UNUSED }
00203 },
00204
00205
00206 { "Cartoon", 3, {
00207 { AtomRep::BONDRAD, 2.1f},
00208 { AtomRep::BONDRES, DEF_CART_RES },
00209 { AtomRep::LINETHICKNESS, 5.0f},
00210 UNUSED, UNUSED, UNUSED }
00211 },
00212
00213
00214 { "NewCartoon", 4, {
00215 { AtomRep::BONDRAD, 0.3f },
00216 { AtomRep::BONDRES, DEF_BOND_RES },
00217 { AtomRep::LINETHICKNESS, 4.5f},
00218 { AtomRep::SPHERERAD, 0},
00219 UNUSED, UNUSED }
00220 },
00221
00222 #ifdef VMDWITHCARBS
00223
00224 { "PaperChain", 2, {
00225 { AtomRep::LINETHICKNESS, 1.0f },
00226 { AtomRep::ISOSTEPSIZE, 10 },
00227 UNUSED, UNUSED, UNUSED, UNUSED, UNUSED }
00228 },
00229
00230
00231 { "Twister", 7, {
00232 { AtomRep::LINETHICKNESS, 1 },
00233 { AtomRep::BONDRES, 0 },
00234 { AtomRep::SPHERERAD, 10 },
00235 { AtomRep::BONDRAD, 0.3 },
00236 { AtomRep::SPHERERES, 0.05 },
00237 { AtomRep::ISOSTEPSIZE, 10 },
00238 { AtomRep::ISOLINETHICKNESS, 5 }
00239 }
00240 },
00241 #endif
00242
00243
00244
00245
00246
00247
00248 #ifdef VMDMSMS
00249
00250 { "MSMS", 4, {
00251 { AtomRep::SPHERERAD, 1.5f },
00252 { AtomRep::SPHERERES, 1.5f },
00253 { AtomRep::LINETHICKNESS, 0},
00254 { AtomRep::BONDRES, 0},
00255 UNUSED, UNUSED }
00256 },
00257 #endif
00258
00259 #ifdef VMDSURF
00260
00261 { "Surf", 2, {
00262 { AtomRep::SPHERERAD, 1.4f },
00263 { AtomRep::BONDRES, 0},
00264 UNUSED, UNUSED, UNUSED, UNUSED }
00265 },
00266 #endif
00267
00268
00269 { "VolumeSlice", 4, {
00270 { AtomRep::SPHERERAD, 0.5f },
00271 { AtomRep::SPHERERES, 0 },
00272 { AtomRep::LINETHICKNESS, 0 },
00273 { AtomRep::BONDRES, 2 },
00274 UNUSED, UNUSED }
00275 },
00276
00277
00278 { "Isosurface", 6, {
00279 { AtomRep::SPHERERAD, 0.5f },
00280 { AtomRep::SPHERERES, 0},
00281 { AtomRep::LINETHICKNESS, 2},
00282 { AtomRep::BONDRES, 2},
00283 { AtomRep::ISOSTEPSIZE, 1},
00284 { AtomRep::ISOLINETHICKNESS, 1},
00285 UNUSED }
00286 },
00287
00288 #ifdef VMDFIELDLINES
00289
00290 { "FieldLines", 5, {
00291 { AtomRep::SPHERERES, 0},
00292 { AtomRep::SPHERERAD, 1.8f},
00293 { AtomRep::BONDRAD, 10.0f},
00294 { AtomRep::BONDRES, 50.0f},
00295 { AtomRep::LINETHICKNESS, 1},
00296 UNUSED, UNUSED }
00297 },
00298 #endif
00299
00300
00301 { "Beads", 2, {
00302 { AtomRep::SPHERERAD, 1.0f},
00303 { AtomRep::SPHERERES, DEF_SPH_RES },
00304 UNUSED, UNUSED, UNUSED, UNUSED }
00305 },
00306
00307
00308 { "Dotted", 2, {
00309 { AtomRep::SPHERERAD, 1.0f},
00310 { AtomRep::SPHERERES, DEF_SPH_RES},
00311 UNUSED, UNUSED, UNUSED, UNUSED }
00312 },
00313
00314
00315 { "Solvent", 3, {
00316 { AtomRep::SPHERERAD, 0 },
00317
00318
00319 { AtomRep::SPHERERES, 7.0f},
00320 { AtomRep::LINETHICKNESS, 1.0f },
00321 UNUSED, UNUSED, UNUSED }
00322 }
00323 };
00324
00325
00327
00328 AtomRep::AtomRep(void) {
00329 int i, j;
00330
00331
00332 repMethod = DEFAULT_ATOMREP;
00333 repData = repDataStorage[repMethod];
00334 strcpy(cmdStr, AtomRepInfo[repMethod].name);
00335 for(j=0; j < TOTAL; j++) {
00336 memset(repDataStorage[j], 0, MAX_ATOMREP_DATA*sizeof(float));
00337 for(i=0; i < AtomRepInfo[j].numdata ; i++)
00338 repDataStorage[j][AtomRepInfo[j].repdata[i].index] =
00339 AtomRepInfo[j].repdata[i].defValue;
00340 }
00341
00342 }
00343
00344 AtomRep::~AtomRep(void) { }
00345
00347
00348 int AtomRep::parse_cmd(const char *newcmd) {
00349 int argc, i, j;
00350 char *argv[256], *cmdStrTok = NULL;
00351
00352
00353 if(newcmd && strlen(newcmd) > MAX_ATOMREP_CMD) {
00354 msgErr << "Atom representation string is too long (over ";
00355 msgErr << MAX_ATOMREP_CMD << " characters)." << sendmsg;
00356 return FALSE;
00357 }
00358
00359
00360 if (!strupncmp(newcmd, "off", 3)) newcmd = "Lines";
00361
00362
00363 if(!newcmd || !(cmdStrTok = str_tokenize(newcmd, &argc, argv))) {
00364
00365 return TRUE;
00366 }
00367
00368
00369 for(i=0; i < AtomRep::TOTAL; i++) {
00370 const AtomRepParamStruct *ari = &(AtomRepInfo[i]);
00371
00372 if(!strupncmp(argv[0], ari->name, CMDLEN)) {
00373
00374 if((argc - 1) > ari->numdata) {
00375 msgErr << "Incorrect atom representation command '" << newcmd << "':";
00376 msgErr << "\n '" << ari->name << "' only takes " << ari->numdata;
00377 msgErr << " arguments maximum." << sendmsg;
00378
00379 delete [] cmdStrTok;
00380 return FALSE;
00381 }
00382
00383
00384 repMethod = i;
00385 repData = repDataStorage[i];
00386
00387
00388 for(j=1; j < argc; j++) {
00389
00390 if(!(argv[j][0] == '-' && argv[j][1] == '\0'))
00391 repData[ari->repdata[j-1].index] = (float) atof(argv[j]);
00392 }
00393
00394
00395 break;
00396 }
00397 }
00398
00399
00400 if(i == AtomRep::TOTAL) {
00401 msgErr << "Unknown atom representation command '" << newcmd << "'.";
00402 msgErr << sendmsg;
00403
00404 delete [] cmdStrTok;
00405 return FALSE;
00406 }
00407
00408
00409 strcpy(cmdStr, newcmd);
00410
00411 delete [] cmdStrTok;
00412 return TRUE;
00413 }
00414
00415
00417
00418
00419 AtomRep &AtomRep::operator=(const AtomRep &ar) {
00420 strcpy(cmdStr, ar.cmdStr);
00421 repMethod = ar.repMethod;
00422 repData = repDataStorage[repMethod];
00423 for(int j=0; j < TOTAL; j++)
00424 for(int i=0; i < MAX_ATOMREP_DATA; i++)
00425 repDataStorage[j][i] = ar.repDataStorage[j][i];
00426
00427 return *this;
00428 }
00429