00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: CmdMol.C,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.153 $ $Date: 2019年01月17日 21:20:58 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * Command objects for affecting molecules. 00019 * 00020 ***************************************************************************/ 00021 00022 #include <stdlib.h> 00023 00024 #include "config.h" 00025 #include "CmdMol.h" 00026 #include "Inform.h" 00027 #include "VMDDisplayList.h" 00028 00029 void CmdMolLoad::create_text(void) { 00030 *cmdText << "mol "; 00031 if (molid == -1) { 00032 *cmdText << "new {"; 00033 } else { 00034 *cmdText << "addfile {"; 00035 } 00036 00037 *cmdText << name << "} type {" << type << "}" 00038 << " first " << spec.first 00039 << " last " << spec.last 00040 << " step " << spec.stride 00041 << " waitfor " << spec.waitfor; 00042 00043 if (spec.autobonds == 0) 00044 *cmdText << " autobonds " << spec.autobonds; 00045 00046 if (spec.nvolsets > 0) { 00047 *cmdText << " volsets {"; 00048 for (int i=0; i<spec.nvolsets; i++) { 00049 *cmdText << spec.setids[i] << " "; 00050 } 00051 *cmdText << "}"; 00052 } 00053 00054 if (molid != -1) { 00055 *cmdText << " " << molid; 00056 } 00057 } 00058 00059 void CmdMolDelete::create_text(void) { 00060 *cmdText << "mol delete " << whichMol << ends; 00061 } 00062 00063 void CmdMolCancel::create_text(void) { 00064 *cmdText << "mol cancel " << whichMol << ends; 00065 } 00066 00067 void CmdMolActive::create_text(void) { 00068 *cmdText << "mol " << (yn ? "active " : "inactive ") << whichMol << ends; 00069 } 00070 00071 void CmdMolFix::create_text(void) { 00072 *cmdText << "mol " << (yn ? "fix " : "free ") << whichMol << ends; 00073 } 00074 00075 void CmdMolOn::create_text(void) { 00076 *cmdText << "mol " << (yn ? "on " : "off ") << whichMol << ends; 00077 } 00078 00079 void CmdMolTop::create_text(void) { 00080 *cmdText << "mol top " << whichMol << ends; 00081 } 00082 00083 void CmdMolSelect::create_text(void) { 00084 *cmdText << "mol selection "; 00085 if(sel) 00086 *cmdText << sel; 00087 *cmdText << ends; 00088 } 00089 00090 void CmdMolRep::create_text(void) { 00091 *cmdText << "mol representation "; 00092 if(sel) 00093 *cmdText << sel; 00094 *cmdText << ends; 00095 } 00096 00097 void CmdMolColor::create_text(void) { 00098 *cmdText << "mol color "; 00099 if(sel) 00100 *cmdText << sel; 00101 *cmdText << ends; 00102 } 00103 00104 void CmdMolMaterial::create_text(void) { 00105 *cmdText << "mol material "; 00106 if (mat) 00107 *cmdText << mat; 00108 *cmdText << ends; 00109 } 00110 00111 void CmdMolAddRep::create_text(void) { 00112 *cmdText << "mol addrep " << whichMol << ends; 00113 } 00114 00115 void CmdMolChangeRep::create_text(void) { 00116 *cmdText << "mol modrep " << repn << " " << whichMol << ends; 00117 } 00118 00119 void CmdMolChangeRepItem::create_text(void) { 00120 *cmdText << "mol mod"; 00121 if (repData == COLOR) 00122 *cmdText << "color "; 00123 else if (repData == REP) 00124 *cmdText << "style "; 00125 else if (repData == SEL) 00126 *cmdText << "select "; 00127 else if (repData == MAT) 00128 *cmdText << "material "; 00129 *cmdText << repn << " " << whichMol << " " << str << ends; 00130 } 00131 00132 void CmdMolRepSelUpdate::create_text() { 00133 *cmdText << "mol selupdate " << repn << " " << whichMol << " " << onoroff 00134 << ends; 00135 } 00136 00137 void CmdMolRepColorUpdate::create_text() { 00138 *cmdText << "mol colupdate " << repn << " " << whichMol << " " << onoroff 00139 << ends; 00140 } 00141 00142 void CmdMolDeleteRep::create_text(void) { 00143 *cmdText << "mol delrep " << repn << " " << whichMol << ends; 00144 } 00145 00146 void CmdMolReanalyze::create_text(void) { 00147 *cmdText << "mol reanalyze " << whichMol << ends; 00148 } 00149 00150 void CmdMolBondsRecalc::create_text(void) { 00151 *cmdText << "mol bondsrecalc " << whichMol << ends; 00152 } 00153 00154 void CmdMolSSRecalc::create_text(void) { 00155 *cmdText << "mol ssrecalc " << whichMol << ends; 00156 } 00157 00158 void CmdMolRename::create_text() { 00159 *cmdText << "mol rename " << whichMol << " {" << newname << "}" << ends; 00160 } 00161 CmdMolRename::CmdMolRename(int id, const char *nm) 00162 : Command(MOL_RENAME), whichMol(id) { 00163 newname = strdup(nm); 00164 } 00165 CmdMolRename::~CmdMolRename() { 00166 free(newname); 00167 } 00168 00169 void CmdMolShowPeriodic::create_text() { 00170 *cmdText << "mol showperiodic " << whichMol << " " << repn << " "; 00171 char buf[10]; 00172 buf[0] = '0円'; 00173 if (pbc & PBC_X) strcat(buf, "x"); 00174 if (pbc & PBC_Y) strcat(buf, "y"); 00175 if (pbc & PBC_Z) strcat(buf, "z"); 00176 if (pbc & PBC_OPX) strcat(buf, "X"); 00177 if (pbc & PBC_OPY) strcat(buf, "Y"); 00178 if (pbc & PBC_OPZ) strcat(buf, "Z"); 00179 if (pbc & PBC_NOSELF) strcat(buf, "n"); 00180 *cmdText << buf << ends; 00181 } 00182 00183 void CmdMolNumPeriodic::create_text() { 00184 *cmdText << "mol numperiodic " << whichMol << " " << repn << " " << nimages 00185 << ends; 00186 } 00187 00188 00189 void CmdMolShowInstances::create_text() { 00190 *cmdText << "mol showinstances " << whichMol << " " << repn << " "; 00191 char buf[10]; 00192 buf[0] = '0円'; 00193 if (instances == INSTANCE_NONE) strcat(buf, "none"); 00194 else if (instances & INSTANCE_ALL) strcat(buf, "all"); 00195 else if (instances & PBC_NOSELF) strcat(buf, "noself"); 00196 *cmdText << buf << ends; 00197 } 00198 00199 00200 void CmdMolScaleMinmax::create_text() { 00201 *cmdText << "mol scaleminmax " << whichMol << " " << repn << " "; 00202 if (reset) { 00203 *cmdText << "auto"; 00204 } else { 00205 *cmdText << scalemin << " " << scalemax; 00206 } 00207 *cmdText << ends; 00208 } 00209 00210 void CmdMolDrawFrames::create_text() { 00211 *cmdText << "mol drawframes " << whichMol << " " << repn << " {" 00212 << framespec << "}" << ends; 00213 } 00214 00215 void CmdMolSmoothRep::create_text() { 00216 *cmdText << "mol smoothrep " << whichMol << " " << repn << " " 00217 << winsize << ends; 00218 } 00219 00220 void CmdMolShowRep::create_text() { 00221 *cmdText << "mol showrep " << whichMol << " " << repn << " " 00222 << onoff << ends; 00223 } 00224