diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-09-17 15:55:38 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-09-17 15:55:38 -0500 |
commit | abae3c8d869d9ad43d798b23a1e97473c03ebcf8 (patch) | |
tree | a1df3595aa0d6de0c018ce17ace8225ba1d9803e | |
parent | f2d8861f28e235dcbcb13274771b072bd83205c2 (diff) | |
download | nanoengineer-abae3c8d869d9ad43d798b23a1e97473c03ebcf8.tar.gz nanoengineer-abae3c8d869d9ad43d798b23a1e97473c03ebcf8.zip |
tab crusading (python files)
38 files changed, 2314 insertions, 2314 deletions
diff --git a/cad/plugins/NanoVision-1/src/Plugins/RenderingEngines/OpenGL/NXOpenGLRenderingEngine.cpp b/cad/plugins/NanoVision-1/src/Plugins/RenderingEngines/OpenGL/NXOpenGLRenderingEngine.cpp index 34b05d2f8..adfa656b5 100644 --- a/cad/plugins/NanoVision-1/src/Plugins/RenderingEngines/OpenGL/NXOpenGLRenderingEngine.cpp +++ b/cad/plugins/NanoVision-1/src/Plugins/RenderingEngines/OpenGL/NXOpenGLRenderingEngine.cpp @@ -25,38 +25,38 @@ using namespace OpenBabel; /// Bypass OpenBabel's atom indexing int get_nv1_atom_id(OBAtom *atomPtr) { - NXAtomData *atomData = static_cast<NXAtomData*>(atomPtr->GetData(NXAtomDataType)); - assert(atomData != NULL); - int id = atomData->getIdx(); - return id; + NXAtomData *atomData = static_cast<NXAtomData*>(atomPtr->GetData(NXAtomDataType)); + assert(atomData != NULL); + int id = atomData->getIdx(); + return id; } /// Hack to bypass OpenBabel's atomicNum which is stored modulo 256 in a 'char' int get_atomic_num(OBAtom *atomPtr) { - NXAtomData *atomData = static_cast<NXAtomData*>(atomPtr->GetData(NXAtomDataType)); - assert(atomData != NULL); - int atomicNum = atomData->getAtomicNum(); - return atomicNum; + NXAtomData *atomData = static_cast<NXAtomData*>(atomPtr->GetData(NXAtomDataType)); + assert(atomData != NULL); + int atomicNum = atomData->getAtomicNum(); + return atomicNum; } #ifdef NX_DEBUG string get_atom_scenegraph_name(OBAtom *const atomPtr) { - string name = "atom_"; - name += NXUtility::itos(get_nv1_atom_id(atomPtr)); - name += "_(" + NXUtility::itos(atomPtr->GetAtomicNum()) + ')'; - return name; + string name = "atom_"; + name += NXUtility::itos(get_nv1_atom_id(atomPtr)); + name += "_(" + NXUtility::itos(atomPtr->GetAtomicNum()) + ')'; + return name; } string get_bond_scenegraph_name(OBBond *const bondPtr) { - return ("bond_" + - NXUtility::itos(get_nv1_atom_id(bondPtr->GetBeginAtom())) + - NXUtility::itos(get_nv1_atom_id(bondPtr->GetEndAtom())) - ); + return ("bond_" + + NXUtility::itos(get_nv1_atom_id(bondPtr->GetBeginAtom())) + + NXUtility::itos(get_nv1_atom_id(bondPtr->GetEndAtom())) + ); } #endif @@ -78,17 +78,17 @@ string get_bond_scenegraph_name(OBBond *const bondPtr) NXOpenGLRenderingEngine::NXOpenGLRenderingEngine(QWidget *parent) : QGLWidget(parent), NXRenderingEngine(), camera(this) { - initializeElementColorMap(); - initializeDefaultMaterials(); + initializeElementColorMap(); + initializeDefaultMaterials(); } NXOpenGLRenderingEngine::~NXOpenGLRenderingEngine() { - // clear top-level scenegraph nodes - NXRenderingEngine::deleteFrames(); - // clear lower-level scenegraph nodes - cleanupPlugins(); + // clear top-level scenegraph nodes + NXRenderingEngine::deleteFrames(); + // clear lower-level scenegraph nodes + cleanupPlugins(); } #if 0 @@ -137,77 +137,77 @@ bool NXOpenGLRenderingEngine::setRootMolecule(OpenBabel::OBMol *const molPtr) bool NXOpenGLRenderingEngine::initializeElementColorMap(void) { - elementColorMap.clear(); - elementColorMap[0] = NXRGBColor(204,0,0,255); - elementColorMap[1] = NXRGBColor(199,199,199,255); - elementColorMap[2] = NXRGBColor(107,115,140,255); - elementColorMap[3] = NXRGBColor(0,128,128,255); - elementColorMap[4] = NXRGBColor(250,171,255,255); - elementColorMap[5] = NXRGBColor(51,51,150,255); - elementColorMap[6] = NXRGBColor(99,99,99,255); - elementColorMap[7] = NXRGBColor(31,31,99,255); - elementColorMap[8] = NXRGBColor(128,0,0,255); - elementColorMap[9] = NXRGBColor(0,99,51,255); - elementColorMap[10] = NXRGBColor(107,115,140,255); - elementColorMap[11] = NXRGBColor(0,102,102,255); - elementColorMap[12] = NXRGBColor(224,153,230,255); - elementColorMap[13] = NXRGBColor(128,128,255,255); - elementColorMap[14] = NXRGBColor(41,41,41,255); - elementColorMap[15] = NXRGBColor(84,20,128,255); - elementColorMap[16] = NXRGBColor(219,150,0,255); - elementColorMap[17] = NXRGBColor(74,99,0,255); - elementColorMap[18] = NXRGBColor(107,115,140,255); - elementColorMap[19] = NXRGBColor(0,77,77,255); - elementColorMap[20] = NXRGBColor(201,140,204,255); - elementColorMap[21] = NXRGBColor(106,106,130,255); - elementColorMap[22] = NXRGBColor(106,106,130,255); - elementColorMap[23] = NXRGBColor(106,106,130,255); - elementColorMap[24] = NXRGBColor(106,106,130,255); - elementColorMap[25] = NXRGBColor(106,106,130,255); - elementColorMap[26] = NXRGBColor(106,106,130,255); - elementColorMap[27] = NXRGBColor(106,106,130,255); - elementColorMap[28] = NXRGBColor(106,106,130,255); - elementColorMap[29] = NXRGBColor(106,106,130,255); - elementColorMap[30] = NXRGBColor(106,106,130,255); - elementColorMap[31] = NXRGBColor(153,153,204,255); - elementColorMap[32] = NXRGBColor(102,115,26,255); - elementColorMap[33] = NXRGBColor(153,66,179,255); - elementColorMap[34] = NXRGBColor(199,79,0,255); - elementColorMap[35] = NXRGBColor(0,102,77,255); - elementColorMap[36] = NXRGBColor(107,115,140,255); - elementColorMap[51] = NXRGBColor(153,66,179,255); - elementColorMap[52] = NXRGBColor(230,89,0,255); - elementColorMap[53] = NXRGBColor(0,128,0,255); - elementColorMap[54] = NXRGBColor(102,115,140,255); - - elementColorMap[200] = NXRGBColor(102,102,204,255); // Ax5 - elementColorMap[201] = NXRGBColor(102,204,102,255); // Ss5 - elementColorMap[202] = NXRGBColor(102, 26,128,255); // Pl5 - elementColorMap[203] = NXRGBColor(102,204,204,255); // Sj5 - elementColorMap[204] = NXRGBColor(102,102,204,255); // Ae5 - elementColorMap[205] = NXRGBColor(102, 26,128,255); // Pe5 - elementColorMap[206] = NXRGBColor(102,204,102,255); // Sh5 - elementColorMap[207] = NXRGBColor( 77,179, 77,255); // Hp5 - elementColorMap[208] = NXRGBColor(156, 83, 8,255); // Gv5 - elementColorMap[209] = NXRGBColor(156, 83, 8,255); // Gr5 - elementColorMap[210] = NXRGBColor(109,207,206,255); // Ub5 - elementColorMap[211] = NXRGBColor(109,207,206,255); // Ux5 - elementColorMap[212] = NXRGBColor(207,109,206,255); // Uy5 - - elementColorMap[300] = NXRGBColor(102,102,204,255); // Ax3 - elementColorMap[301] = NXRGBColor(102,204,102,255); // Ss3 - elementColorMap[302] = NXRGBColor(102, 26,128,255); // Pl3 - elementColorMap[303] = NXRGBColor(102,204,204,255); // Sj3 - elementColorMap[304] = NXRGBColor( 26, 26,128,255); // Ae3 - elementColorMap[305] = NXRGBColor(102,204,102,255); // Se3 - elementColorMap[306] = NXRGBColor(153, 51,153,255); // Sh3 - elementColorMap[307] = NXRGBColor( 77,179, 77,255); // Hp3 - elementColorMap[310] = NXRGBColor(109,207,206,255); // Ub3 - elementColorMap[311] = NXRGBColor(109,207,206,255); // Ux3 - elementColorMap[312] = NXRGBColor(207,109,206,255); // Uy3 - - return true; - + elementColorMap.clear(); + elementColorMap[0] = NXRGBColor(204,0,0,255); + elementColorMap[1] = NXRGBColor(199,199,199,255); + elementColorMap[2] = NXRGBColor(107,115,140,255); + elementColorMap[3] = NXRGBColor(0,128,128,255); + elementColorMap[4] = NXRGBColor(250,171,255,255); + elementColorMap[5] = NXRGBColor(51,51,150,255); + elementColorMap[6] = NXRGBColor(99,99,99,255); + elementColorMap[7] = NXRGBColor(31,31,99,255); + elementColorMap[8] = NXRGBColor(128,0,0,255); + elementColorMap[9] = NXRGBColor(0,99,51,255); + elementColorMap[10] = NXRGBColor(107,115,140,255); + elementColorMap[11] = NXRGBColor(0,102,102,255); + elementColorMap[12] = NXRGBColor(224,153,230,255); + elementColorMap[13] = NXRGBColor(128,128,255,255); + elementColorMap[14] = NXRGBColor(41,41,41,255); + elementColorMap[15] = NXRGBColor(84,20,128,255); + elementColorMap[16] = NXRGBColor(219,150,0,255); + elementColorMap[17] = NXRGBColor(74,99,0,255); + elementColorMap[18] = NXRGBColor(107,115,140,255); + elementColorMap[19] = NXRGBColor(0,77,77,255); + elementColorMap[20] = NXRGBColor(201,140,204,255); + elementColorMap[21] = NXRGBColor(106,106,130,255); + elementColorMap[22] = NXRGBColor(106,106,130,255); + elementColorMap[23] = NXRGBColor(106,106,130,255); + elementColorMap[24] = NXRGBColor(106,106,130,255); + elementColorMap[25] = NXRGBColor(106,106,130,255); + elementColorMap[26] = NXRGBColor(106,106,130,255); + elementColorMap[27] = NXRGBColor(106,106,130,255); + elementColorMap[28] = NXRGBColor(106,106,130,255); + elementColorMap[29] = NXRGBColor(106,106,130,255); + elementColorMap[30] = NXRGBColor(106,106,130,255); + elementColorMap[31] = NXRGBColor(153,153,204,255); + elementColorMap[32] = NXRGBColor(102,115,26,255); + elementColorMap[33] = NXRGBColor(153,66,179,255); + elementColorMap[34] = NXRGBColor(199,79,0,255); + elementColorMap[35] = NXRGBColor(0,102,77,255); + elementColorMap[36] = NXRGBColor(107,115,140,255); + elementColorMap[51] = NXRGBColor(153,66,179,255); + elementColorMap[52] = NXRGBColor(230,89,0,255); + elementColorMap[53] = NXRGBColor(0,128,0,255); + elementColorMap[54] = NXRGBColor(102,115,140,255); + + elementColorMap[200] = NXRGBColor(102,102,204,255); // Ax5 + elementColorMap[201] = NXRGBColor(102,204,102,255); // Ss5 + elementColorMap[202] = NXRGBColor(102, 26,128,255); // Pl5 + elementColorMap[203] = NXRGBColor(102,204,204,255); // Sj5 + elementColorMap[204] = NXRGBColor(102,102,204,255); // Ae5 + elementColorMap[205] = NXRGBColor(102, 26,128,255); // Pe5 + elementColorMap[206] = NXRGBColor(102,204,102,255); // Sh5 + elementColorMap[207] = NXRGBColor( 77,179, 77,255); // Hp5 + elementColorMap[208] = NXRGBColor(156, 83, 8,255); // Gv5 + elementColorMap[209] = NXRGBColor(156, 83, 8,255); // Gr5 + elementColorMap[210] = NXRGBColor(109,207,206,255); // Ub5 + elementColorMap[211] = NXRGBColor(109,207,206,255); // Ux5 + elementColorMap[212] = NXRGBColor(207,109,206,255); // Uy5 + + elementColorMap[300] = NXRGBColor(102,102,204,255); // Ax3 + elementColorMap[301] = NXRGBColor(102,204,102,255); // Ss3 + elementColorMap[302] = NXRGBColor(102, 26,128,255); // Pl3 + elementColorMap[303] = NXRGBColor(102,204,204,255); // Sj3 + elementColorMap[304] = NXRGBColor( 26, 26,128,255); // Ae3 + elementColorMap[305] = NXRGBColor(102,204,102,255); // Se3 + elementColorMap[306] = NXRGBColor(153, 51,153,255); // Sh3 + elementColorMap[307] = NXRGBColor( 77,179, 77,255); // Hp3 + elementColorMap[310] = NXRGBColor(109,207,206,255); // Ub3 + elementColorMap[311] = NXRGBColor(109,207,206,255); // Ux3 + elementColorMap[312] = NXRGBColor(207,109,206,255); // Uy3 + + return true; + #if 0 // read from file - sensitive to location /// @todo Remove filename hardcoding ifstream elemColorMapFile("default-element-colors.txt", ios::in); @@ -218,7 +218,7 @@ bool NXOpenGLRenderingEngine::initializeElementColorMap(void) char linebuf[LINEBUF_SIZE]; elemColorMapFile.getline(linebuf, LINEBUF_SIZE); assert((int)elemColorMapFile.gcount() < LINEBUF_SIZE); - + istringstream line(linebuf); // ignore comment lines if(line.peek() == '#') continue; @@ -236,273 +236,273 @@ bool NXOpenGLRenderingEngine::initializeElementColorMap(void) void NXOpenGLRenderingEngine::initializeDefaultMaterials(void) { - defaultAtomMaterial.face = GL_FRONT; - defaultAtomMaterial.ambient[0] = 1.0f; - defaultAtomMaterial.ambient[1] = 1.0f; - defaultAtomMaterial.ambient[2] = 1.0f; - defaultAtomMaterial.ambient[3] = 1.0f; - - defaultAtomMaterial.diffuse[0] = 1.0f; - defaultAtomMaterial.diffuse[1] = 1.0f; - defaultAtomMaterial.diffuse[2] = 1.0f; - defaultAtomMaterial.diffuse[3] = 1.0f; - - defaultAtomMaterial.specular[0] = 0.5f; - defaultAtomMaterial.specular[1] = 0.5f; - defaultAtomMaterial.specular[2] = 0.5f; - defaultAtomMaterial.specular[3] = 1.0f; - - defaultAtomMaterial.shininess = 35.0; - - defaultAtomMaterial.emission[0] = 0.0f; - defaultAtomMaterial.emission[1] = 0.0f; - defaultAtomMaterial.emission[2] = 0.0f; - defaultAtomMaterial.emission[3] = 1.0f; - - defaultBondMaterial.face = GL_FRONT; - defaultBondMaterial.ambient[0] = 1.0f; - defaultBondMaterial.ambient[1] = 1.0f; - defaultBondMaterial.ambient[2] = 1.0f; - defaultBondMaterial.ambient[3] = 1.0f; - - defaultBondMaterial.diffuse[0] = 1.0f; - defaultBondMaterial.diffuse[1] = 1.0f; - defaultBondMaterial.diffuse[2] = 1.0f; - defaultBondMaterial.diffuse[3] = 1.0f; - - defaultBondMaterial.specular[0] = 0.5f; - defaultBondMaterial.specular[1] = 0.5f; - defaultBondMaterial.specular[2] = 0.5f; - defaultBondMaterial.specular[3] = 1.0f; - - defaultBondMaterial.shininess = 35.0; - - defaultBondMaterial.emission[0] = 0.0f; - defaultBondMaterial.emission[1] = 0.0f; - defaultBondMaterial.emission[2] = 0.0f; - defaultBondMaterial.emission[3] = 1.0f; + defaultAtomMaterial.face = GL_FRONT; + defaultAtomMaterial.ambient[0] = 1.0f; + defaultAtomMaterial.ambient[1] = 1.0f; + defaultAtomMaterial.ambient[2] = 1.0f; + defaultAtomMaterial.ambient[3] = 1.0f; + + defaultAtomMaterial.diffuse[0] = 1.0f; + defaultAtomMaterial.diffuse[1] = 1.0f; + defaultAtomMaterial.diffuse[2] = 1.0f; + defaultAtomMaterial.diffuse[3] = 1.0f; + + defaultAtomMaterial.specular[0] = 0.5f; + defaultAtomMaterial.specular[1] = 0.5f; + defaultAtomMaterial.specular[2] = 0.5f; + defaultAtomMaterial.specular[3] = 1.0f; + + defaultAtomMaterial.shininess = 35.0; + + defaultAtomMaterial.emission[0] = 0.0f; + defaultAtomMaterial.emission[1] = 0.0f; + defaultAtomMaterial.emission[2] = 0.0f; + defaultAtomMaterial.emission[3] = 1.0f; + + defaultBondMaterial.face = GL_FRONT; + defaultBondMaterial.ambient[0] = 1.0f; + defaultBondMaterial.ambient[1] = 1.0f; + defaultBondMaterial.ambient[2] = 1.0f; + defaultBondMaterial.ambient[3] = 1.0f; + + defaultBondMaterial.diffuse[0] = 1.0f; + defaultBondMaterial.diffuse[1] = 1.0f; + defaultBondMaterial.diffuse[2] = 1.0f; + defaultBondMaterial.diffuse[3] = 1.0f; + + defaultBondMaterial.specular[0] = 0.5f; + defaultBondMaterial.specular[1] = 0.5f; + defaultBondMaterial.specular[2] = 0.5f; + defaultBondMaterial.specular[3] = 1.0f; + + defaultBondMaterial.shininess = 35.0; + + defaultBondMaterial.emission[0] = 0.0f; + defaultBondMaterial.emission[1] = 0.0f; + defaultBondMaterial.emission[2] = 0.0f; + defaultBondMaterial.emission[3] = 1.0f; } void NXOpenGLRenderingEngine::initializeGL(void) { - glClearColor(1.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glEnable(GL_LIGHTING); - glEnable(GL_DEPTH_TEST); - - lightModel.setLocalViewer(1); - lightModel.setTwoSide(0); - lightModel.set(); - setupDefaultLights(); - -// camera.gluLookAt(0.0, 0.0, 1.0, -// 0.0, 0.0, 0.0, -// 0.0, 1.0, 0.0); -// camera.gluPerspective(55, (GLdouble)width()/(GLdouble)height(), 0.1, 50); - - NXNamedView defaultView("DefaultView", - NXQuaternion<double>(1.0, 0.0, 0.0, 0.0), - 10.0, - NXVector3d(0.0, 0.0, 0.0), - 1.0); - camera.setNamedView(defaultView); - camera.glViewport(0, 0, width(), height()); - - (void) glGetError(); // clear errors - // initializePlugins(); - + glClearColor(1.0, 1.0, 1.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + + lightModel.setLocalViewer(1); + lightModel.setTwoSide(0); + lightModel.set(); + setupDefaultLights(); + +// camera.gluLookAt(0.0, 0.0, 1.0, +// 0.0, 0.0, 0.0, +// 0.0, 1.0, 0.0); +// camera.gluPerspective(55, (GLdouble)width()/(GLdouble)height(), 0.1, 50); + + NXNamedView defaultView("DefaultView", + NXQuaternion<double>(1.0, 0.0, 0.0, 0.0), + 10.0, + NXVector3d(0.0, 0.0, 0.0), + 1.0); + camera.setNamedView(defaultView); + camera.glViewport(0, 0, width(), height()); + + (void) glGetError(); // clear errors + // initializePlugins(); + } void NXOpenGLRenderingEngine::setupDefaultLights(void) { // light model - lightModel.setLocalViewer(1); - lightModel.setTwoSide(0); - lightModel.set(); - + lightModel.setLocalViewer(1); + lightModel.setTwoSide(0); + lightModel.set(); + // initialize light data - GLint numSupportedOpenGLLights = 0; - glGetIntegerv(GL_MAX_LIGHTS, &numSupportedOpenGLLights); - lights.clear(); - for(GLint iLight=0; iLight<numSupportedOpenGLLights; ++iLight) - { - lights.push_back(GltLight(iLight+GL_LIGHT0)); - } - - GltColor const WHITE(1.0,1.0,1.0,1.0); - lights[0].isEnabled() = true; - lights[0].ambient() = 0.1 * WHITE; - lights[0].diffuse() = 0.5 * WHITE; - lights[0].specular() = 0.5 * WHITE; - lights[0].position() = Vector(-50.0, 70.0, 30.0); - lights[0].isDirectional() = true; - lights[0].inEyeSpace() = true; - lights[0].set(); - - lights[1].isEnabled() = true; - lights[1].ambient() = 0.1 * WHITE; - lights[1].diffuse() = 0.5 * WHITE; - lights[1].specular() = 0.5 * WHITE; - lights[1].position() = Vector(-20.0, 20.0, 20.0); - lights[1].isDirectional() = true; - lights[1].inEyeSpace() = true; - lights[1].set(); - - for(GLint iLight=2; iLight<numSupportedOpenGLLights; ++iLight) { - lights[iLight].isEnabled() = false; - lights[iLight].ambient() = 0.1 * WHITE; - lights[iLight].diffuse() = 0.5 * WHITE; - lights[iLight].specular() = 0.5 * WHITE; - lights[iLight].position() = Vector(0.0, 0.0, 100.0); - lights[iLight].set(); - } - + GLint numSupportedOpenGLLights = 0; + glGetIntegerv(GL_MAX_LIGHTS, &numSupportedOpenGLLights); + lights.clear(); + for(GLint iLight=0; iLight<numSupportedOpenGLLights; ++iLight) + { + lights.push_back(GltLight(iLight+GL_LIGHT0)); + } + + GltColor const WHITE(1.0,1.0,1.0,1.0); + lights[0].isEnabled() = true; + lights[0].ambient() = 0.1 * WHITE; + lights[0].diffuse() = 0.5 * WHITE; + lights[0].specular() = 0.5 * WHITE; + lights[0].position() = Vector(-50.0, 70.0, 30.0); + lights[0].isDirectional() = true; + lights[0].inEyeSpace() = true; + lights[0].set(); + + lights[1].isEnabled() = true; + lights[1].ambient() = 0.1 * WHITE; + lights[1].diffuse() = 0.5 * WHITE; + lights[1].specular() = 0.5 * WHITE; + lights[1].position() = Vector(-20.0, 20.0, 20.0); + lights[1].isDirectional() = true; + lights[1].inEyeSpace() = true; + lights[1].set(); + + for(GLint iLight=2; iLight<numSupportedOpenGLLights; ++iLight) { + lights[iLight].isEnabled() = false; + lights[iLight].ambient() = 0.1 * WHITE; + lights[iLight].diffuse() = 0.5 * WHITE; + lights[iLight].specular() = 0.5 * WHITE; + lights[iLight].position() = Vector(0.0, 0.0, 100.0); + lights[iLight].set(); + } + } void NXOpenGLRenderingEngine::resizeGL(int width, int height) { - camera.resizeViewport(width, height); - // camera.glSetViewport(); - // camera.glSetProjection(); + camera.resizeViewport(width, height); + // camera.glSetViewport(); + // camera.glSetProjection(); // glMatrixMode(GL_PROJECTION); // glLoadIdentity(); // gluPerspective(55, (GLdouble)width/(GLdouble)height, 0.1, 50); // camera.glGetProjection(); // camera.glGetViewport(); - + /* if(isOrthographicProjection) orthographicProjection.set(); else perspectiveProjection.set(); */ - - // viewport.set((GLint) width, (GLint) height);*/ + + // viewport.set((GLint) width, (GLint) height);*/ } void NXOpenGLRenderingEngine::paintGL(void) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - drawSkyBlueBackground(); - camera.glSetPosition(); - camera.glSetProjection(); - drawCompass(); - - if(currentFrameIndex >= 0) { - NXSGOpenGLNode *currentFrameSGNode = - static_cast<NXSGOpenGLNode*>(frames[currentFrameIndex]); - currentFrameSGNode->applyRecursive(); - } - glFlush(); - swapBuffers(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + drawSkyBlueBackground(); + camera.glSetPosition(); + camera.glSetProjection(); + drawCompass(); + + if(currentFrameIndex >= 0) { + NXSGOpenGLNode *currentFrameSGNode = + static_cast<NXSGOpenGLNode*>(frames[currentFrameIndex]); + currentFrameSGNode->applyRecursive(); + } + glFlush(); + swapBuffers(); } void NXOpenGLRenderingEngine::drawSkyBlueBackground(void) { - glDisable(GL_LIGHTING); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + glDisable(GL_LIGHTING); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); // * GLPane.py::standard_repaint_0() // * drawer.py::drawFullWindow() - GltColor vtColors0(0.9, 0.9, 0.9, 1.0); - GltColor vtColors1(0.9, 0.9, 0.9, 1.0); - GltColor vtColors2(0.33, 0.73, 1.0, 1.0); - GltColor vtColors3(0.33, 0.73, 1.0, 1.0); - glBegin(GL_QUADS); - vtColors0.glColor(); - glVertex3f(-1, -1, 0.999); - vtColors1.glColor(); - glVertex3f(1, -1, 0.999); - vtColors2.glColor(); - glVertex3f(1, 1, 0.999); - vtColors3.glColor(); - glVertex3f(-1, 1, 0.999); - glEnd(); - glEnable(GL_LIGHTING); + GltColor vtColors0(0.9, 0.9, 0.9, 1.0); + GltColor vtColors1(0.9, 0.9, 0.9, 1.0); + GltColor vtColors2(0.33, 0.73, 1.0, 1.0); + GltColor vtColors3(0.33, 0.73, 1.0, 1.0); + glBegin(GL_QUADS); + vtColors0.glColor(); + glVertex3f(-1, -1, 0.999); + vtColors1.glColor(); + glVertex3f(1, -1, 0.999); + vtColors2.glColor(); + glVertex3f(1, 1, 0.999); + vtColors3.glColor(); + glVertex3f(-1, 1, 0.999); + glEnd(); + glEnable(GL_LIGHTING); } void NXOpenGLRenderingEngine::drawCompass(void) { - // Coordinate axis - glBegin(GL_LINES); - // x-axis - glColor3f(1.0f, 0.0f, 0.0f); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(3.0, 0.0, 0.0); - - // y-axis - glColor3f(0.0f, 1.0, 0.0f); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(0.0, 3.0, 0.0); - - // z-axis - glColor3f(0.0f, 0.0, 1.0); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(0.0, 0.0, 3.0); - glEnd(); + // Coordinate axis + glBegin(GL_LINES); + // x-axis + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(3.0, 0.0, 0.0); + + // y-axis + glColor3f(0.0f, 1.0, 0.0f); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 3.0, 0.0); + + // z-axis + glColor3f(0.0f, 0.0, 1.0); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 0.0, 3.0); + glEnd(); } NXSGNode* NXOpenGLRenderingEngine::createSceneGraph (NXMoleculeSet *const molSetPtr) { - ClearResult(commandResult); - // Do nothing if no rendering plugins - if(!pluginsInitialized) { - SetResult(commandResult, - NX_INTERNAL_ERROR, - "Renderer-plugins not set/initialized"); - return NULL; - } - - QCursor originalCursor = cursor(); - setCursor(QCursor(Qt::BusyCursor)); - - renderedAtoms.clear(); - renderedBonds.clear(); - NXSGOpenGLNode *node = createOpenGLSceneGraph(molSetPtr); - - NXSGOpenGLRenderable *renderableNode = new NXSGOpenGLRenderable; - makeCurrent(); - assert(renderableNode->beginRender()); - assert(node->applyRecursive()); - assert(renderableNode->endRender()); - delete node; - node = NULL; - + ClearResult(commandResult); + // Do nothing if no rendering plugins + if(!pluginsInitialized) { + SetResult(commandResult, + NX_INTERNAL_ERROR, + "Renderer-plugins not set/initialized"); + return NULL; + } + + QCursor originalCursor = cursor(); + setCursor(QCursor(Qt::BusyCursor)); + + renderedAtoms.clear(); + renderedBonds.clear(); + NXSGOpenGLNode *node = createOpenGLSceneGraph(molSetPtr); + + NXSGOpenGLRenderable *renderableNode = new NXSGOpenGLRenderable; + makeCurrent(); + assert(renderableNode->beginRender()); + assert(node->applyRecursive()); + assert(renderableNode->endRender()); + delete node; + node = NULL; + #ifdef NX_DEBUG - NXSGNode const *const node1 = renderableNode; - ofstream sgFile((molSetPtr->getTitle() + ".sg").c_str(), ios::out); - sgFile << "digraph SG {" << endl; - if(sgFile) - node1->writeDotGraph(sgFile); - sgFile << "}" << endl; + NXSGNode const *const node1 = renderableNode; + ofstream sgFile((molSetPtr->getTitle() + ".sg").c_str(), ios::out); + sgFile << "digraph SG {" << endl; + if(sgFile) + node1->writeDotGraph(sgFile); + sgFile << "}" << endl; #endif - setCursor(originalCursor); - - return static_cast<NXSGNode*>(renderableNode); + setCursor(originalCursor); + + return static_cast<NXSGNode*>(renderableNode); } #if 0 // removed this method from NXRenderingEngine NXSGNode* createSceneGraph (OpenBabel::OBMol *const molPtr) { - // Do nothing if no rendering plugins - if(!pluginsInitialized) { - SetResult(commandResult, NX_INTERNAL_ERROR, + // Do nothing if no rendering plugins + if(!pluginsInitialized) { + SetResult(commandResult, NX_INTERNAL_ERROR, "Rendering plugin not set/initialized"); - return NULL; - } - ClearResult(commandResult); - NXSGOpenGLNode *node = createOpenGLSceneGraph(molPtr); - return static_cast<NXSGNode*>(node); + return NULL; + } + ClearResult(commandResult); + NXSGOpenGLNode *node = createOpenGLSceneGraph(molPtr); + return static_cast<NXSGNode*>(node); } #endif @@ -511,269 +511,269 @@ NXOpenGLRenderingEngine::createOpenGLSceneGraph(NXMoleculeSet *const molSetPtr) { /// @todo Trap soft-failure cases where pointer returned is non-NULL /// but commandResult shows error - NXSGOpenGLNode *moleculeSetNode = NULL; - try { - moleculeSetNode = new NXSGOpenGLNode; - SET_SCENEGRAPH_NAME(moleculeSetNode, - "Molecule_set_" + molSetPtr->getTitle()); - } - catch(...) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Failed to initialize scenegraph node for molecule set " + - molSetPtr->getTitle()); - return (NXSGOpenGLNode*) NULL; - } - + NXSGOpenGLNode *moleculeSetNode = NULL; + try { + moleculeSetNode = new NXSGOpenGLNode; + SET_SCENEGRAPH_NAME(moleculeSetNode, + "Molecule_set_" + molSetPtr->getTitle()); + } + catch(...) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Failed to initialize scenegraph node for molecule set " + + molSetPtr->getTitle()); + return (NXSGOpenGLNode*) NULL; + } + #if 0 /// @todo Post-FNANO08 (Dna rendering) - /// @fixme r1.0.0 hacks - // -- begin hacks -- - NXMoleculeSet::GroupClassification molSetClassification = - molSetPtr->getGroupClassification(); - switch(molSetClassification) { - case NXMoleculeSet::DNA_GROUP : - inDnaGroup = true; - // reset child-group flags - inDnaSegment = false; - inDnaStrand = false; - break; - case NXMoleculeSet::DNA_SEGMENT : - assert(inDnaGroup); - inDnaSegment = true; - // force strand mol-sets to follow corresponding segment - inDnaStrand = false; - dnaSegmentMolSetPtr = molSetPtr; - break; - case NXMoleculeSet::DNA_STRAND : - assert(inDnaGroup); - inDnaStrand = true; - inDnaSegment = false; - dnaStrandMolSetPtr = molSetPtr; - break; - case NXMoleculeSet::NONE: - inDnaGroup = false; - inDnaSegment = false; - inDnaStrand = false; - break; - default: - NXLOG_WARNING("NXOpenGLRenderingEngine", - string("Unknown group classification '") + - molSetPtr->getGroupClassificationString() + - "' - reverting to default"); - break; - } - // -- end hacks -- + /// @fixme r1.0.0 hacks + // -- begin hacks -- + NXMoleculeSet::GroupClassification molSetClassification = + molSetPtr->getGroupClassification(); + switch(molSetClassification) { + case NXMoleculeSet::DNA_GROUP : + inDnaGroup = true; + // reset child-group flags + inDnaSegment = false; + inDnaStrand = false; + break; + case NXMoleculeSet::DNA_SEGMENT : + assert(inDnaGroup); + inDnaSegment = true; + // force strand mol-sets to follow corresponding segment + inDnaStrand = false; + dnaSegmentMolSetPtr = molSetPtr; + break; + case NXMoleculeSet::DNA_STRAND : + assert(inDnaGroup); + inDnaStrand = true; + inDnaSegment = false; + dnaStrandMolSetPtr = molSetPtr; + break; + case NXMoleculeSet::NONE: + inDnaGroup = false; + inDnaSegment = false; + inDnaStrand = false; + break; + default: + NXLOG_WARNING("NXOpenGLRenderingEngine", + string("Unknown group classification '") + + molSetPtr->getGroupClassificationString() + + "' - reverting to default"); + break; + } + // -- end hacks -- #endif - - // cerr << "Creating OpenGL scenegraph for molecule-set " << molSetPtr->getTitle() << endl; - OBMolIterator molIter; - for(molIter = molSetPtr->moleculesBegin(); - molIter != molSetPtr->moleculesEnd(); - ++molIter) - { - if((*molIter)->Empty()) - continue; - NXSGOpenGLNode* molNode = createOpenGLSceneGraph(*molIter); - if(molNode != NULL && - commandResult.getResult() == (int) NX_CMD_SUCCESS) - { - bool childAdded = moleculeSetNode->addChild(molNode); - if(!childAdded) { - NX_DEBUG_FAIL; - return moleculeSetNode; - } - } - else { - NX_DEBUG_FAIL; - return moleculeSetNode; - } - /// @todo POST-FNANO: delete molNode upon failures? - } - - NXMoleculeSetIterator childrenIter; - for(childrenIter = molSetPtr->childrenBegin(); - childrenIter != molSetPtr->childrenEnd(); - ++childrenIter) - { - NXSGOpenGLNode *childMoleculeSetNode = createOpenGLSceneGraph(*childrenIter); - if(childMoleculeSetNode != NULL && - commandResult.getResult() == (int) NX_CMD_SUCCESS) - { - bool childAdded = moleculeSetNode->addChild(childMoleculeSetNode); - if(!childAdded) { - NX_DEBUG_FAIL; - return moleculeSetNode; - } - } - else { - NX_DEBUG_FAIL; - return moleculeSetNode; - } - /// @todo POST-FNANO: delete childMoleculeSetNode upon failures? - } - return moleculeSetNode; + + // cerr << "Creating OpenGL scenegraph for molecule-set " << molSetPtr->getTitle() << endl; + OBMolIterator molIter; + for(molIter = molSetPtr->moleculesBegin(); + molIter != molSetPtr->moleculesEnd(); + ++molIter) + { + if((*molIter)->Empty()) + continue; + NXSGOpenGLNode* molNode = createOpenGLSceneGraph(*molIter); + if(molNode != NULL && + commandResult.getResult() == (int) NX_CMD_SUCCESS) + { + bool childAdded = moleculeSetNode->addChild(molNode); + if(!childAdded) { + NX_DEBUG_FAIL; + return moleculeSetNode; + } + } + else { + NX_DEBUG_FAIL; + return moleculeSetNode; + } + /// @todo POST-FNANO: delete molNode upon failures? + } + + NXMoleculeSetIterator childrenIter; + for(childrenIter = molSetPtr->childrenBegin(); + childrenIter != molSetPtr->childrenEnd(); + ++childrenIter) + { + NXSGOpenGLNode *childMoleculeSetNode = createOpenGLSceneGraph(*childrenIter); + if(childMoleculeSetNode != NULL && + commandResult.getResult() == (int) NX_CMD_SUCCESS) + { + bool childAdded = moleculeSetNode->addChild(childMoleculeSetNode); + if(!childAdded) { + NX_DEBUG_FAIL; + return moleculeSetNode; + } + } + else { + NX_DEBUG_FAIL; + return moleculeSetNode; + } + /// @todo POST-FNANO: delete childMoleculeSetNode upon failures? + } + return moleculeSetNode; } NXSGOpenGLNode* NXOpenGLRenderingEngine::createOpenGLSceneGraph(OBMol *const molPtr) { - assert(!molPtr->Empty()); - + assert(!molPtr->Empty()); + #if 0 /// @todo Post-FNANO08 (Dna rendering) - /// @fixme r1.0.0 hacks - // -- begin hacks -- - if(inDnaGroup && inDnaSegment) { - NXSGOpenGLNode *molSceneGraphNode = - createOpenGLDnaSegmentSceneGraph(molPtr); - if(molSceneGraphNode != NULL) - return molSceneGraphNode; - } - else if(inDnaGroup && inDnaStrand) { - NXSGOpenGLNode *molSceneGraphNode = - createOpenGLDnaStrandSceneGraph(molPtr); - if(molSceneGraphNode != NULL) - return molSceneGraphNode; - } - // -- end hacks -- + /// @fixme r1.0.0 hacks + // -- begin hacks -- + if(inDnaGroup && inDnaSegment) { + NXSGOpenGLNode *molSceneGraphNode = + createOpenGLDnaSegmentSceneGraph(molPtr); + if(molSceneGraphNode != NULL) + return molSceneGraphNode; + } + else if(inDnaGroup && inDnaStrand) { + NXSGOpenGLNode *molSceneGraphNode = + createOpenGLDnaStrandSceneGraph(molPtr); + if(molSceneGraphNode != NULL) + return molSceneGraphNode; + } + // -- end hacks -- #endif - - Vector const canonicalZAxis(0.0, 0.0, 1.0); - OBAtomIterator atomIter; - + + Vector const canonicalZAxis(0.0, 0.0, 1.0); + OBAtomIterator atomIter; + // Find first atom that is not already rendered - // Necessary because bonds can bridge molecules and molecule-sets and in - // the case of the second to last molecules rendered, their first atoms - // may have been rendered while traversing the previous molecules. - - OBAtom *firstAtomPtr = molPtr->BeginAtom(atomIter); - - if(firstAtomPtr == (OBAtom*) NULL) { - string const source("Molecule scenegraph creation"); - string const msg("empty molecule slipped past check"); - SetResult(commandResult, NX_INTERNAL_ERROR, source + " - " + msg); - NX_DEBUG_FAIL; - return (NXSGOpenGLNode*) NULL; - } - - while(firstAtomPtr != (OBAtom*) NULL && isRendered(firstAtomPtr)) - firstAtomPtr = molPtr->NextAtom(atomIter); - - if(firstAtomPtr == (OBAtom*) NULL) { - NXSGOpenGLNode *nullFirstAtomNode = new NXSGOpenGLNode; - SET_SCENEGRAPH_NAME(nullFirstAtomNode, "Null_first_atom"); - return nullFirstAtomNode; - } - - Vector const firstAtomPosition(firstAtomPtr->GetX(), - firstAtomPtr->GetY(), - firstAtomPtr->GetZ()); - - NXSGOpenGLTranslate *rootMoleculeNode = NULL; - try { - rootMoleculeNode = - new NXSGOpenGLTranslate(firstAtomPosition.x(), - firstAtomPosition.y(), - firstAtomPosition.z()); - SET_SCENEGRAPH_NAME(rootMoleculeNode, "First_atom_position"); - } - catch(...) { - if(rootMoleculeNode != NULL) - delete rootMoleculeNode; - rootMoleculeNode = NULL; - SetResult(commandResult, - NX_INTERNAL_ERROR, - "Error translating to first atom position"); - NX_DEBUG_FAIL; - return NULL; - } - - NXSGOpenGLNode *firstAtomNode = - createOpenGLSceneGraph(molPtr, firstAtomPtr, canonicalZAxis); - if(firstAtomNode != NULL && - commandResult.getResult() == (int) NX_CMD_SUCCESS) - { + // Necessary because bonds can bridge molecules and molecule-sets and in + // the case of the second to last molecules rendered, their first atoms + // may have been rendered while traversing the previous molecules. + + OBAtom *firstAtomPtr = molPtr->BeginAtom(atomIter); + + if(firstAtomPtr == (OBAtom*) NULL) { + string const source("Molecule scenegraph creation"); + string const msg("empty molecule slipped past check"); + SetResult(commandResult, NX_INTERNAL_ERROR, source + " - " + msg); + NX_DEBUG_FAIL; + return (NXSGOpenGLNode*) NULL; + } + + while(firstAtomPtr != (OBAtom*) NULL && isRendered(firstAtomPtr)) + firstAtomPtr = molPtr->NextAtom(atomIter); + + if(firstAtomPtr == (OBAtom*) NULL) { + NXSGOpenGLNode *nullFirstAtomNode = new NXSGOpenGLNode; + SET_SCENEGRAPH_NAME(nullFirstAtomNode, "Null_first_atom"); + return nullFirstAtomNode; + } + + Vector const firstAtomPosition(firstAtomPtr->GetX(), + firstAtomPtr->GetY(), + firstAtomPtr->GetZ()); + + NXSGOpenGLTranslate *rootMoleculeNode = NULL; + try { + rootMoleculeNode = + new NXSGOpenGLTranslate(firstAtomPosition.x(), + firstAtomPosition.y(), + firstAtomPosition.z()); + SET_SCENEGRAPH_NAME(rootMoleculeNode, "First_atom_position"); + } + catch(...) { + if(rootMoleculeNode != NULL) + delete rootMoleculeNode; + rootMoleculeNode = NULL; + SetResult(commandResult, + NX_INTERNAL_ERROR, + "Error translating to first atom position"); + NX_DEBUG_FAIL; + return NULL; + } + + NXSGOpenGLNode *firstAtomNode = + createOpenGLSceneGraph(molPtr, firstAtomPtr, canonicalZAxis); + if(firstAtomNode != NULL && + commandResult.getResult() == (int) NX_CMD_SUCCESS) + { // submolecule scenegraph created completely and successfully - bool childAdded = rootMoleculeNode->addChild(firstAtomNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error adding child to first atom node"); - NX_DEBUG_FAIL; - return rootMoleculeNode; - } - } - else { - NX_DEBUG_FAIL; + bool childAdded = rootMoleculeNode->addChild(firstAtomNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error adding child to first atom node"); + NX_DEBUG_FAIL; + return rootMoleculeNode; + } + } + else { + NX_DEBUG_FAIL; // either scenegraph could not be created or was created partially // commandResult should hold the error - return rootMoleculeNode; - } - /// @todo POST-FNANO delete firstAtomNode upon failures? - + return rootMoleculeNode; + } + /// @todo POST-FNANO delete firstAtomNode upon failures? + // rest of the atoms - OBAtom *atomPtr = molPtr->NextAtom(atomIter); - for(; atomPtr != (OBAtom*) NULL; - atomPtr = molPtr->NextAtom(atomIter)) - { - if(isRendered(atomPtr)) // atom already rendered - continue; - - Vector const atomPosition(atomPtr->GetX(), - atomPtr->GetY(), - atomPtr->GetZ()); - Vector const atomRelativePosition = - (atomPosition - firstAtomPosition); + OBAtom *atomPtr = molPtr->NextAtom(atomIter); + for(; atomPtr != (OBAtom*) NULL; + atomPtr = molPtr->NextAtom(atomIter)) + { + if(isRendered(atomPtr)) // atom already rendered + continue; + + Vector const atomPosition(atomPtr->GetX(), + atomPtr->GetY(), + atomPtr->GetZ()); + Vector const atomRelativePosition = + (atomPosition - firstAtomPosition); // move scenegraph "cursor" to this atom - NXSGOpenGLTranslate *translateToAtomNode = NULL; - try { - translateToAtomNode = - new NXSGOpenGLTranslate(atomRelativePosition.x(), - atomRelativePosition.y(), - atomRelativePosition.z()); - SET_SCENEGRAPH_NAME(translateToAtomNode, - "Translate_to_" + get_atom_scenegraph_name(atomPtr)); - } - catch(...) { - if(translateToAtomNode != NULL) - delete translateToAtomNode; - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error translating to atom"); - NX_DEBUG_FAIL; - return rootMoleculeNode; - } - - bool childAdded = rootMoleculeNode->addChild(translateToAtomNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error adding translate-to-atom node to molecule root"); - NX_DEBUG_FAIL; - return rootMoleculeNode; - } - /// @todo POST-FNANO delete translateToAtomNode upon failure? - + NXSGOpenGLTranslate *translateToAtomNode = NULL; + try { + translateToAtomNode = + new NXSGOpenGLTranslate(atomRelativePosition.x(), + atomRelativePosition.y(), + atomRelativePosition.z()); + SET_SCENEGRAPH_NAME(translateToAtomNode, + "Translate_to_" + get_atom_scenegraph_name(atomPtr)); + } + catch(...) { + if(translateToAtomNode != NULL) + delete translateToAtomNode; + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error translating to atom"); + NX_DEBUG_FAIL; + return rootMoleculeNode; + } + + bool childAdded = rootMoleculeNode->addChild(translateToAtomNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error adding translate-to-atom node to molecule root"); + NX_DEBUG_FAIL; + return rootMoleculeNode; + } + /// @todo POST-FNANO delete translateToAtomNode upon failure? + // render subscenegraph rooted at this atom - NXSGOpenGLNode *atomNode = - createOpenGLSceneGraph(molPtr, atomPtr, canonicalZAxis); - - if(atomNode != NULL && - commandResult.getResult() == (int) NX_CMD_SUCCESS) - { - bool childAdded = translateToAtomNode->addChild(atomNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error submolecule scenegraph as child of " - "translation"); - NX_DEBUG_FAIL; - return rootMoleculeNode; - } - } - else { - NX_DEBUG_FAIL; - return rootMoleculeNode; - } - /// @todo POST-FNANO delete atomNode upon failures? - } // loop over atoms - - return rootMoleculeNode; + NXSGOpenGLNode *atomNode = + createOpenGLSceneGraph(molPtr, atomPtr, canonicalZAxis); + + if(atomNode != NULL && + commandResult.getResult() == (int) NX_CMD_SUCCESS) + { + bool childAdded = translateToAtomNode->addChild(atomNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error submolecule scenegraph as child of " + "translation"); + NX_DEBUG_FAIL; + return rootMoleculeNode; + } + } + else { + NX_DEBUG_FAIL; + return rootMoleculeNode; + } + /// @todo POST-FNANO delete atomNode upon failures? + } // loop over atoms + + return rootMoleculeNode; } #if 0 /// @todo Post-FNANO08 @@ -782,19 +782,19 @@ NXOpenGLRenderingEngine::createOpenGLSceneGraph(OBMol *const molPtr) NXSGOpenGLNode* NXOpenGLRenderingEngine::createOpenGLDnaSegmentSceneGraph(OBMol *const molPtr) { - RenderStyleMap::const_iterator pluginIter = renderStyleMap.find("dna"); - if(pluginIter == renderStyleMap.end()) { - NXLOG_WARNING("NXOpenGLRenderingEngine", - "No plugin found to render DNA segment - " - "reverting to default"); - return NULL; - } - - NXOpenGLRendererPlugin *const dnaPlugin = - static_cast<NXOpenGLRendererPlugin *const>(pluginIter->second); - - NXSGOpenGLNode *molSceneGraphNode = dnaPlugin->renderDnaSegment(molPtr); - return molSceneGraphNode; + RenderStyleMap::const_iterator pluginIter = renderStyleMap.find("dna"); + if(pluginIter == renderStyleMap.end()) { + NXLOG_WARNING("NXOpenGLRenderingEngine", + "No plugin found to render DNA segment - " + "reverting to default"); + return NULL; + } + + NXOpenGLRendererPlugin *const dnaPlugin = + static_cast<NXOpenGLRendererPlugin *const>(pluginIter->second); + + NXSGOpenGLNode *molSceneGraphNode = dnaPlugin->renderDnaSegment(molPtr); + return molSceneGraphNode; } @@ -804,25 +804,25 @@ NXOpenGLRenderingEngine::createOpenGLDnaSegmentSceneGraph(OBMol *const molPtr) NXSGOpenGLNode* NXOpenGLRenderingEngine::createOpenGLDnaStrandSceneGraph(OBMol *const molPtr) { - RenderStyleMap::const_iterator pluginIter = renderStyleMap.find("dna"); - if(pluginIter == renderStyleMap.end()) { - NXLOG_WARNING("NXOpenGLRenderingEngine", - "No plugin found to render DNA strand - " - "reverting to default"); - return NULL; - } - - NXOpenGLRendererPlugin *const dnaPlugin = - static_cast<NXOpenGLRendererPlugin *const>(pluginIter->second); - - assert(dnaSegmentMolSetPtr->moleculeCount() == 1); - assert(dnaSegmentMolSetPtr->childCount() == 0); - - // locate segment molecule - OBMol *const dnaSegmentMolPtr = *dnaSegmentMolSetPtr->moleculesBegin(); - NXSGOpenGLNode *molSceneGraphNode = - dnaPlugin->renderDnaStrand(molPtr, dnaSegmentMolPtr); - return molSceneGraphNode; + RenderStyleMap::const_iterator pluginIter = renderStyleMap.find("dna"); + if(pluginIter == renderStyleMap.end()) { + NXLOG_WARNING("NXOpenGLRenderingEngine", + "No plugin found to render DNA strand - " + "reverting to default"); + return NULL; + } + + NXOpenGLRendererPlugin *const dnaPlugin = + static_cast<NXOpenGLRendererPlugin *const>(pluginIter->second); + + assert(dnaSegmentMolSetPtr->moleculeCount() == 1); + assert(dnaSegmentMolSetPtr->childCount() == 0); + + // locate segment molecule + OBMol *const dnaSegmentMolPtr = *dnaSegmentMolSetPtr->moleculesBegin(); + NXSGOpenGLNode *molSceneGraphNode = + dnaPlugin->renderDnaStrand(molPtr, dnaSegmentMolPtr); + return molSceneGraphNode; } // -- end hacks -- #endif @@ -832,44 +832,44 @@ NXSGOpenGLNode* NXOpenGLRenderingEngine::getRotationNode(Vector const& zAxis, Vector const& newZAxis) { - double const dotProduct = zAxis * newZAxis; - - if(dotProduct < 0.99999) { - // Angle between both vectors is more than 0.25 degrees - // therefore there is a well-defined rotation - real const rotationAngleDeg = - acos(dotProduct) * 180.0 / M_PI; - - Vector rotationAxis = xProduct(zAxis, newZAxis); - rotationAxis.normalize(); - - NXSGOpenGLRotate *rotateZAxisNode = NULL; - try { - rotateZAxisNode = - new NXSGOpenGLRotate(rotationAngleDeg, - rotationAxis.x(), - rotationAxis.y(), - rotationAxis.z()); - SET_SCENEGRAPH_NAME(rotateZAxisNode, - "Rotate_Z_Axis"); - } - catch(...) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error creating axis rotation scenegraph node"); - NX_DEBUG_FAIL; - return NULL; - } - - return rotateZAxisNode; - } - else { - // length of cross-product is below 1% - // therefore the two z-axes are parallel to within numerical error - // bypass creation of rotation scenegraph node - return NULL; - - } - + double const dotProduct = zAxis * newZAxis; + + if(dotProduct < 0.99999) { + // Angle between both vectors is more than 0.25 degrees + // therefore there is a well-defined rotation + real const rotationAngleDeg = + acos(dotProduct) * 180.0 / M_PI; + + Vector rotationAxis = xProduct(zAxis, newZAxis); + rotationAxis.normalize(); + + NXSGOpenGLRotate *rotateZAxisNode = NULL; + try { + rotateZAxisNode = + new NXSGOpenGLRotate(rotationAngleDeg, + rotationAxis.x(), + rotationAxis.y(), + rotationAxis.z()); + SET_SCENEGRAPH_NAME(rotateZAxisNode, + "Rotate_Z_Axis"); + } + catch(...) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error creating axis rotation scenegraph node"); + NX_DEBUG_FAIL; + return NULL; + } + + return rotateZAxisNode; + } + else { + // length of cross-product is below 1% + // therefore the two z-axes are parallel to within numerical error + // bypass creation of rotation scenegraph node + return NULL; + + } + } /// Render given atom in the molecule in a depth-first manner @@ -879,236 +879,236 @@ NXOpenGLRenderingEngine::createOpenGLSceneGraph(OBMol *const molPtr, OBAtom *const atomPtr, Vector const& zAxis) { - // Precondition: *atomPtr shouldn't have been rendered - assert(renderedAtoms.find(atomPtr) == renderedAtoms.end()); - assert(atomPtr->GetParent() == molPtr); - + // Precondition: *atomPtr shouldn't have been rendered + assert(renderedAtoms.find(atomPtr) == renderedAtoms.end()); + assert(atomPtr->GetParent() == molPtr); + // Do nothing if no rendering plugins - if(!pluginsInitialized) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Rendering plugin not set/initialized"); - NX_DEBUG_FAIL; - return NULL; - } - + if(!pluginsInitialized) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Rendering plugin not set/initialized"); + NX_DEBUG_FAIL; + return NULL; + } + // translate origin to atom center - Vector atomPosition(atomPtr->GetX(), atomPtr->GetY(), atomPtr->GetZ()); - - + Vector atomPosition(atomPtr->GetX(), atomPtr->GetY(), atomPtr->GetZ()); + + // create scenegraph node and mark atom as rendered - // NXAtomRenderData atomRenderData(atomPtr->GetAtomicNum()); - // atomRenderData.addData(static_cast<void const *>(&defaultAtomMaterial)); - assert(atomPtr->HasData(NXAtomDataType)); - NXAtomData *atomData = - static_cast<NXAtomData*>(atomPtr->GetData(NXAtomDataType)); - assert(atomData->GetDataType() == NXAtomDataType); - assert(atomData != NULL); - - // default color - NXRGBColor defaultElementColor(0.0, 0.0, 0.0); - // Bypass OpenBabel's atomicNum because it is stored modulo 256 in a 'char' - int atomicNum = get_atomic_num(atomPtr); - map<uint, NXRGBColor>::iterator defaultElementColorIter = - elementColorMap.find(atomicNum); - if(defaultElementColorIter != elementColorMap.end()) { - defaultElementColor = defaultElementColorIter->second; - } - else { - cerr << "NXOpenGLRenderingEngine: no color found for atom with atomic num = " - << atomicNum << endl; - } - + // NXAtomRenderData atomRenderData(atomPtr->GetAtomicNum()); + // atomRenderData.addData(static_cast<void const *>(&defaultAtomMaterial)); + assert(atomPtr->HasData(NXAtomDataType)); + NXAtomData *atomData = + static_cast<NXAtomData*>(atomPtr->GetData(NXAtomDataType)); + assert(atomData->GetDataType() == NXAtomDataType); + assert(atomData != NULL); + + // default color + NXRGBColor defaultElementColor(0.0, 0.0, 0.0); + // Bypass OpenBabel's atomicNum because it is stored modulo 256 in a 'char' + int atomicNum = get_atomic_num(atomPtr); + map<uint, NXRGBColor>::iterator defaultElementColorIter = + elementColorMap.find(atomicNum); + if(defaultElementColorIter != elementColorMap.end()) { + defaultElementColor = defaultElementColorIter->second; + } + else { + cerr << "NXOpenGLRenderingEngine: no color found for atom with atomic num = " + << atomicNum << endl; + } + // set default material parameters - defaultAtomMaterial.ambient[0] = defaultElementColor.r; - defaultAtomMaterial.ambient[1] = defaultElementColor.g; - defaultAtomMaterial.ambient[2] = defaultElementColor.b; - defaultAtomMaterial.ambient[3] = 1.0; - defaultAtomMaterial.diffuse[0] = defaultElementColor.r; - defaultAtomMaterial.diffuse[1] = defaultElementColor.g; - defaultAtomMaterial.diffuse[2] = defaultElementColor.b; - defaultAtomMaterial.diffuse[3] = 1.0; - defaultAtomMaterial.specular[0] = defaultElementColor.r; - defaultAtomMaterial.specular[1] = defaultElementColor.g; - defaultAtomMaterial.specular[2] = defaultElementColor.b; - defaultAtomMaterial.specular[3] = 1.0; - - - string const& atomRenderStyleCode = atomData->getRenderStyleCode(); - atomData->addSupplementalData(static_cast<void const*>(&defaultAtomMaterial)); - /// @todo consider if supplemental data can be added repeatedly and the - /// corresponding vector grows needlessly - - - // The following dynamic_cast is ok because plugins were type-checked at - // initialization time - /// @fixme Use qobject_cast instead of static_cast? dynamic_cast won't work - NXOpenGLRendererPlugin *renderer = - static_cast<NXOpenGLRendererPlugin*>(renderStyleMap[atomRenderStyleCode]); - if(renderer == (NXOpenGLRendererPlugin*) NULL) { - SetResult(commandResult, - NX_PLUGIN_CAUSED_ERROR, - "No renderer-plugin found for rendering-style-code '" + - atomRenderStyleCode + "'"); - /// @todo POST-FNANO more descriptive error message - which atom# and moleculeSet - NX_DEBUG_FAIL; - return (NXSGOpenGLNode*) NULL; - } - NXSGOpenGLNode *const atomNode = renderer->renderAtom(*atomData); - if(atomNode == NULL) { - commandResult = renderer->getCommandResult(); - NX_DEBUG_FAIL; - return NULL; - } - SET_ATOM_SCENEGRAPH_NAME(atomNode, atomPtr); - renderedAtoms.insert(atomPtr); // mark as rendered - - // render outgoing bonds and neighbouring atoms (if applicable) as children - OBBondIterator bondIter; - OBBond *bondPtr(NULL); - for(bondPtr = atomPtr->BeginBond(bondIter); - bondPtr != NULL; - bondPtr = atomPtr->NextBond(bondIter)) - - { - OBAtom *const nbrAtomPtr = bondPtr->GetNbrAtom(atomPtr); - assert(nbrAtomPtr != atomPtr); - Vector const nbrAtomPosition(nbrAtomPtr->GetX(), - nbrAtomPtr->GetY(), - nbrAtomPtr->GetZ()); - Vector const nbrAtomRelativePosition = (nbrAtomPosition - atomPosition); - Vector newZAxis = nbrAtomRelativePosition; - newZAxis.normalize(); - - if(!isRendered(bondPtr)) { + defaultAtomMaterial.ambient[0] = defaultElementColor.r; + defaultAtomMaterial.ambient[1] = defaultElementColor.g; + defaultAtomMaterial.ambient[2] = defaultElementColor.b; + defaultAtomMaterial.ambient[3] = 1.0; + defaultAtomMaterial.diffuse[0] = defaultElementColor.r; + defaultAtomMaterial.diffuse[1] = defaultElementColor.g; + defaultAtomMaterial.diffuse[2] = defaultElementColor.b; + defaultAtomMaterial.diffuse[3] = 1.0; + defaultAtomMaterial.specular[0] = defaultElementColor.r; + defaultAtomMaterial.specular[1] = defaultElementColor.g; + defaultAtomMaterial.specular[2] = defaultElementColor.b; + defaultAtomMaterial.specular[3] = 1.0; + + + string const& atomRenderStyleCode = atomData->getRenderStyleCode(); + atomData->addSupplementalData(static_cast<void const*>(&defaultAtomMaterial)); + /// @todo consider if supplemental data can be added repeatedly and the + /// corresponding vector grows needlessly + + + // The following dynamic_cast is ok because plugins were type-checked at + // initialization time + /// @fixme Use qobject_cast instead of static_cast? dynamic_cast won't work + NXOpenGLRendererPlugin *renderer = + static_cast<NXOpenGLRendererPlugin*>(renderStyleMap[atomRenderStyleCode]); + if(renderer == (NXOpenGLRendererPlugin*) NULL) { + SetResult(commandResult, + NX_PLUGIN_CAUSED_ERROR, + "No renderer-plugin found for rendering-style-code '" + + atomRenderStyleCode + "'"); + /// @todo POST-FNANO more descriptive error message - which atom# and moleculeSet + NX_DEBUG_FAIL; + return (NXSGOpenGLNode*) NULL; + } + NXSGOpenGLNode *const atomNode = renderer->renderAtom(*atomData); + if(atomNode == NULL) { + commandResult = renderer->getCommandResult(); + NX_DEBUG_FAIL; + return NULL; + } + SET_ATOM_SCENEGRAPH_NAME(atomNode, atomPtr); + renderedAtoms.insert(atomPtr); // mark as rendered + + // render outgoing bonds and neighbouring atoms (if applicable) as children + OBBondIterator bondIter; + OBBond *bondPtr(NULL); + for(bondPtr = atomPtr->BeginBond(bondIter); + bondPtr != NULL; + bondPtr = atomPtr->NextBond(bondIter)) + + { + OBAtom *const nbrAtomPtr = bondPtr->GetNbrAtom(atomPtr); + assert(nbrAtomPtr != atomPtr); + Vector const nbrAtomPosition(nbrAtomPtr->GetX(), + nbrAtomPtr->GetY(), + nbrAtomPtr->GetZ()); + Vector const nbrAtomRelativePosition = (nbrAtomPosition - atomPosition); + Vector newZAxis = nbrAtomRelativePosition; + newZAxis.normalize(); + + if(!isRendered(bondPtr)) { // compute bond orientation - - // Rotate z-axis to align with bond-direction if necessary - NXSGOpenGLNode *rotateZAxisNode = getRotationNode(zAxis,newZAxis); - if(rotateZAxisNode == NULL) - rotateZAxisNode = atomNode; - - else { - bool childAdded = atomNode->addChild(rotateZAxisNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error adding rotation node as child to atom node"); - NX_DEBUG_FAIL; - return atomNode; - } - } - - void const *const defBondMatPtr = - static_cast<void const*>(&defaultBondMaterial); - NXBondData bondRenderData((BondType)bondPtr->GetBondOrder(), - bondPtr->GetLength()); - bondRenderData.addSupplementalData(defBondMatPtr); - NXSGOpenGLNode *const bondNode = renderer->renderBond(bondRenderData); - if(bondNode == NULL) { - commandResult = renderer->getCommandResult(); - NX_DEBUG_FAIL; - return atomNode; - } - SET_BOND_SCENEGRAPH_NAME(bondNode, bondPtr); - bool const childAdded = rotateZAxisNode->addChild(bondNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error adding bond node to z-axis rotation node"); - NX_DEBUG_FAIL; - return atomNode; - } - - markBondRendered(bondPtr); - - } // if bond not already rendered - - - if(!isRendered(nbrAtomPtr) && nbrAtomPtr->GetParent() == molPtr) { - + + // Rotate z-axis to align with bond-direction if necessary + NXSGOpenGLNode *rotateZAxisNode = getRotationNode(zAxis,newZAxis); + if(rotateZAxisNode == NULL) + rotateZAxisNode = atomNode; + + else { + bool childAdded = atomNode->addChild(rotateZAxisNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error adding rotation node as child to atom node"); + NX_DEBUG_FAIL; + return atomNode; + } + } + + void const *const defBondMatPtr = + static_cast<void const*>(&defaultBondMaterial); + NXBondData bondRenderData((BondType)bondPtr->GetBondOrder(), + bondPtr->GetLength()); + bondRenderData.addSupplementalData(defBondMatPtr); + NXSGOpenGLNode *const bondNode = renderer->renderBond(bondRenderData); + if(bondNode == NULL) { + commandResult = renderer->getCommandResult(); + NX_DEBUG_FAIL; + return atomNode; + } + SET_BOND_SCENEGRAPH_NAME(bondNode, bondPtr); + bool const childAdded = rotateZAxisNode->addChild(bondNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error adding bond node to z-axis rotation node"); + NX_DEBUG_FAIL; + return atomNode; + } + + markBondRendered(bondPtr); + + } // if bond not already rendered + + + if(!isRendered(nbrAtomPtr) && nbrAtomPtr->GetParent() == molPtr) { + // translate to neighbouring atom center - // double const bondLength = bondPtr->GetLength(); - NXSGOpenGLTranslate *translateToNbrAtomNode = NULL; - try { - translateToNbrAtomNode = - new NXSGOpenGLTranslate(nbrAtomRelativePosition.x(), - nbrAtomRelativePosition.y(), - nbrAtomRelativePosition.z()); - SET_SCENEGRAPH_NAME(translateToNbrAtomNode, - "Translate_to_" + get_atom_scenegraph_name(nbrAtomPtr)); - } - catch(...) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error creating trans-bond translation scenegraph node"); - NX_DEBUG_FAIL; - return atomNode; - } - bool const childAdded = atomNode->addChild(translateToNbrAtomNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error adding trans-bond translation node as child of" - " bond-node"); - NX_DEBUG_FAIL; - return atomNode; - } - + // double const bondLength = bondPtr->GetLength(); + NXSGOpenGLTranslate *translateToNbrAtomNode = NULL; + try { + translateToNbrAtomNode = + new NXSGOpenGLTranslate(nbrAtomRelativePosition.x(), + nbrAtomRelativePosition.y(), + nbrAtomRelativePosition.z()); + SET_SCENEGRAPH_NAME(translateToNbrAtomNode, + "Translate_to_" + get_atom_scenegraph_name(nbrAtomPtr)); + } + catch(...) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error creating trans-bond translation scenegraph node"); + NX_DEBUG_FAIL; + return atomNode; + } + bool const childAdded = atomNode->addChild(translateToNbrAtomNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error adding trans-bond translation node as child of" + " bond-node"); + NX_DEBUG_FAIL; + return atomNode; + } + // create scenegraph rooted at neighbouring atom - NXSGOpenGLNode *nbrAtomNode = - createOpenGLSceneGraph(molPtr, nbrAtomPtr, /*newZAxis*/ Vector(0.0, 0.0, 1.0)); - if(nbrAtomNode == NULL) { - NX_DEBUG_FAIL; - return atomNode; - } - else { - bool const childAdded = - translateToNbrAtomNode->addChild(nbrAtomNode); - if(!childAdded) { - SetResult(commandResult, NX_INTERNAL_ERROR, - "Error adding neighboring-atom scenegraph subtree" - " as child of trans-bond translation node"); - NX_DEBUG_FAIL; - return atomNode; - } - } - } // if neighbouring atom not already rendered - } - - return atomNode; + NXSGOpenGLNode *nbrAtomNode = + createOpenGLSceneGraph(molPtr, nbrAtomPtr, /*newZAxis*/ Vector(0.0, 0.0, 1.0)); + if(nbrAtomNode == NULL) { + NX_DEBUG_FAIL; + return atomNode; + } + else { + bool const childAdded = + translateToNbrAtomNode->addChild(nbrAtomNode); + if(!childAdded) { + SetResult(commandResult, NX_INTERNAL_ERROR, + "Error adding neighboring-atom scenegraph subtree" + " as child of trans-bond translation node"); + NX_DEBUG_FAIL; + return atomNode; + } + } + } // if neighbouring atom not already rendered + } + + return atomNode; } void NXOpenGLRenderingEngine::markBondRendered(OBBond *const bondPtr) { - OBAtom *const atom1 = bondPtr->GetBeginAtom(); - OBAtom *const atom2 = bondPtr->GetEndAtom(); - - pair<OBAtom*,OBAtom*> atomPair = ( atom1 < atom2 ? - make_pair(atom1, atom2) : - make_pair(atom2, atom1) ); - renderedBonds.insert(atomPair); + OBAtom *const atom1 = bondPtr->GetBeginAtom(); + OBAtom *const atom2 = bondPtr->GetEndAtom(); + + pair<OBAtom*,OBAtom*> atomPair = ( atom1 < atom2 ? + make_pair(atom1, atom2) : + make_pair(atom2, atom1) ); + renderedBonds.insert(atomPair); } bool NXOpenGLRenderingEngine::isRendered(OBAtom *const atomPtr) const { - set<OBAtom*>::const_iterator memberIter = renderedAtoms.find(atomPtr); - bool const result = (memberIter != renderedAtoms.end()); - return result; + set<OBAtom*>::const_iterator memberIter = renderedAtoms.find(atomPtr); + bool const result = (memberIter != renderedAtoms.end()); + return result; } bool NXOpenGLRenderingEngine::isRendered(OBBond *const bondPtr) const { - OBAtom *atom1 = bondPtr->GetBeginAtom(); - OBAtom *atom2 = bondPtr->GetEndAtom(); - - pair<OBAtom*,OBAtom*> atomPair = (atom1 < atom2 ? - make_pair(atom1, atom2) : - make_pair(atom2, atom1)); - - RenderedBondsTableType::const_iterator memberIter = - renderedBonds.find(atomPair); - - bool const result = (memberIter != renderedBonds.end()); - return result; + OBAtom *atom1 = bondPtr->GetBeginAtom(); + OBAtom *atom2 = bondPtr->GetEndAtom(); + + pair<OBAtom*,OBAtom*> atomPair = (atom1 < atom2 ? + make_pair(atom1, atom2) : + make_pair(atom2, atom1)); + + RenderedBondsTableType::const_iterator memberIter = + renderedBonds.find(atomPair); + + bool const result = (memberIter != renderedBonds.end()); + return result; } @@ -1117,275 +1117,275 @@ static inline double sqr(double const&x) { return x*x; } void NXOpenGLRenderingEngine::resetView(void) { // create axis-aligned bounding box - if(currentFrameIndex < 0) - return; - - NXMoleculeSet *molSetPtr = moleculeSets[currentFrameIndex]; - BoundingBox bbox = GetBoundingBox(molSetPtr); - Vector bboxMin = bbox.min(); - Vector bboxMax = bbox.max(); - - real const bboxXWidth = 1.0*(bboxMax.x() - bboxMin.x()); - real const bboxYWidth = 1.0*(bboxMax.y() - bboxMin.y()); - real const bboxZDepth = 1.0*(bboxMax.z() - bboxMin.z()); - - real const projCubeWidth = max(bboxXWidth, max(bboxYWidth, bboxZDepth)); - real const circumSphereRad = sqrt(3.0*0.25*projCubeWidth*projCubeWidth); -// sqrt(sqr(max(bboxMax.x(), bboxMin.x())) + -// sqr(max(bboxMax.y(), bboxMin.y())) + -// sqr(max(bboxMax.z(), bboxMin.z())) ); - real const circumSphereDia = 2.0 * circumSphereRad; - Vector const bboxCenter = bbox.center(); - - real l, r, b, t; - real const n = 0.25 * circumSphereRad; - real const f = 12.0 * circumSphereRad; - real const aspect = real(width()) / real(height()); - if(aspect < 1.0) { -// l = bboxCenter.x() - circumSphereDia; -// r = bboxCenter.x() + circumSphereDia; -// b = bboxCenter.y() - circumSphereDia / aspect; -// t = bboxCenter.y() + circumSphereDia / aspect; - l = -circumSphereRad; - r = -l; - b = -circumSphereRad / aspect; - t = -b; - } - else { -// l = bboxCenter.x() - aspect * circumSphereDia; -// r = bboxCenter.x() + aspect * circumSphereDia; -// b = bboxCenter.y() - circumSphereDia; -// t = bboxCenter.y() + circumSphereDia; - l = -aspect * circumSphereRad; - r = -l; - b = -circumSphereRad; - t = -b; - } - - // makeCurrent(); -// camera.gluLookAt(bboxCenter.x(), bboxCenter.y(), -// bboxCenter.z()+circumSphereDia, -// bboxCenter.x(), bboxCenter.y(), bboxCenter.z(), -// 0.0, 1.0, 0.0); + if(currentFrameIndex < 0) + return; + + NXMoleculeSet *molSetPtr = moleculeSets[currentFrameIndex]; + BoundingBox bbox = GetBoundingBox(molSetPtr); + Vector bboxMin = bbox.min(); + Vector bboxMax = bbox.max(); + + real const bboxXWidth = 1.0*(bboxMax.x() - bboxMin.x()); + real const bboxYWidth = 1.0*(bboxMax.y() - bboxMin.y()); + real const bboxZDepth = 1.0*(bboxMax.z() - bboxMin.z()); + + real const projCubeWidth = max(bboxXWidth, max(bboxYWidth, bboxZDepth)); + real const circumSphereRad = sqrt(3.0*0.25*projCubeWidth*projCubeWidth); +// sqrt(sqr(max(bboxMax.x(), bboxMin.x())) + +// sqr(max(bboxMax.y(), bboxMin.y())) + +// sqr(max(bboxMax.z(), bboxMin.z())) ); + real const circumSphereDia = 2.0 * circumSphereRad; + Vector const bboxCenter = bbox.center(); + + real l, r, b, t; + real const n = 0.25 * circumSphereRad; + real const f = 12.0 * circumSphereRad; + real const aspect = real(width()) / real(height()); + if(aspect < 1.0) { +// l = bboxCenter.x() - circumSphereDia; +// r = bboxCenter.x() + circumSphereDia; +// b = bboxCenter.y() - circumSphereDia / aspect; +// t = bboxCenter.y() + circumSphereDia / aspect; + l = -circumSphereRad; + r = -l; + b = -circumSphereRad / aspect; + t = -b; + } + else { +// l = bboxCenter.x() - aspect * circumSphereDia; +// r = bboxCenter.x() + aspect * circumSphereDia; +// b = bboxCenter.y() - circumSphereDia; +// t = bboxCenter.y() + circumSphereDia; + l = -aspect * circumSphereRad; + r = -l; + b = -circumSphereRad; + t = -b; + } + + // makeCurrent(); +// camera.gluLookAt(bboxCenter.x(), bboxCenter.y(), +// bboxCenter.z()+circumSphereDia, +// bboxCenter.x(), bboxCenter.y(), bboxCenter.z(), +// 0.0, 1.0, 0.0); // camera.gluPerspective(60.0, double(width())/double(height()), n, f); - -// camera.gluLookAt(0.0, 0.0, circumSphereRad, -// 0.0, 0.0, 0.0, -// 0.0, 1.0, 0.0); -// camera.glOrtho(l, r, b, t, n, f); - - NXNamedView defaultView("DefaultView", - NXQuaternion<double>(1.0, 0.0, 0.0, 1.0), - bboxYWidth, - NXVector3d(-bboxCenter.x(), - -bboxCenter.y(), - -bboxCenter.z()), - 1.0); - cerr << defaultView << endl; - camera.setNamedView(defaultView); - - // default HomeView: (1, 0, 0, 0) (10) (0, 0, 0) (1) - // orthographic projection as in GLPane.py::_setup_projection() - -// double const SCALE = 10.0 * 1.0e-13; -// double const VDIST = 6.0 * SCALE; -// camera.gluLookAt(0.0, 0.0, VDIST, -// 0.0, 0.0, 0.0, -// 0.0, 1.0, 0.0); -// double const NEAR = 0.25, FAR = 12.0; -// camera.glOrtho(-SCALE * aspect, SCALE * aspect, -// -SCALE , SCALE, -// VDIST * NEAR , VDIST * FAR); - - updateGL(); + +// camera.gluLookAt(0.0, 0.0, circumSphereRad, +// 0.0, 0.0, 0.0, +// 0.0, 1.0, 0.0); +// camera.glOrtho(l, r, b, t, n, f); + + NXNamedView defaultView("DefaultView", + NXQuaternion<double>(1.0, 0.0, 0.0, 1.0), + bboxYWidth, + NXVector3d(-bboxCenter.x(), + -bboxCenter.y(), + -bboxCenter.z()), + 1.0); + cerr << defaultView << endl; + camera.setNamedView(defaultView); + + // default HomeView: (1, 0, 0, 0) (10) (0, 0, 0) (1) + // orthographic projection as in GLPane.py::_setup_projection() + +// double const SCALE = 10.0 * 1.0e-13; +// double const VDIST = 6.0 * SCALE; +// camera.gluLookAt(0.0, 0.0, VDIST, +// 0.0, 0.0, 0.0, +// 0.0, 1.0, 0.0); +// double const NEAR = 0.25, FAR = 12.0; +// camera.glOrtho(-SCALE * aspect, SCALE * aspect, +// -SCALE , SCALE, +// VDIST * NEAR , VDIST * FAR); + + updateGL(); } void NXOpenGLRenderingEngine::setNamedView(NXNamedView const& view) { - makeCurrent(); - camera.setNamedView(view); - updateGL(); + makeCurrent(); + camera.setNamedView(view); + updateGL(); } /* FUNCTION: mousePressEvent */ void NXOpenGLRenderingEngine::mousePressEvent(QMouseEvent *mouseEvent) { - - if (mouseEvent->button() == Qt::LeftButton) { - if (mouseEvent->modifiers() == Qt::NoModifier) { + + if (mouseEvent->button() == Qt::LeftButton) { + if (mouseEvent->modifiers() == Qt::NoModifier) { printf("NXOpenGLRenderingEngine::mousePressEvent: rotate\n"); - camera.rotateStartEvent(mouseEvent->x(), mouseEvent->y()); - mouseEvent->accept(); - - } else if (mouseEvent->modifiers() == Qt::ControlModifier) { + camera.rotateStartEvent(mouseEvent->x(), mouseEvent->y()); + mouseEvent->accept(); + + } else if (mouseEvent->modifiers() == Qt::ControlModifier) { printf("NXOpenGLRenderingEngine::mousePressEvent: pan\n"); - camera.panStartEvent(mouseEvent->x(), mouseEvent->y()); - mouseEvent->accept(); - - } else if (mouseEvent->modifiers() == Qt::ShiftModifier) { + camera.panStartEvent(mouseEvent->x(), mouseEvent->y()); + mouseEvent->accept(); + + } else if (mouseEvent->modifiers() == Qt::ShiftModifier) { printf("NXOpenGLRenderingEngine::mousePressEvent: zoom\n"); - mouseEvent->accept(); - } - - } else { - mouseEvent->ignore(); - } - updateGL(); + mouseEvent->accept(); + } + + } else { + mouseEvent->ignore(); + } + updateGL(); } /* FUNCTION: mouseMoveEvent */ void NXOpenGLRenderingEngine::mouseMoveEvent(QMouseEvent *mouseEvent) { - - Qt::MouseButtons buttons = mouseEvent->buttons(); - if (buttons & Qt::LeftButton) { - if (mouseEvent->modifiers() == Qt::NoModifier) { - camera.rotatingEvent(mouseEvent->x(), mouseEvent->y()); - mouseEvent->accept(); - - } else if (mouseEvent->modifiers() == Qt::ControlModifier) { - camera.panEvent(mouseEvent->x(), mouseEvent->y()); - mouseEvent->accept(); - - } else if (mouseEvent->modifiers() == Qt::ShiftModifier) { - mouseEvent->accept(); - } - - } else { - mouseEvent->ignore(); - } - updateGL(); + + Qt::MouseButtons buttons = mouseEvent->buttons(); + if (buttons & Qt::LeftButton) { + if (mouseEvent->modifiers() == Qt::NoModifier) { + camera.rotatingEvent(mouseEvent->x(), mouseEvent->y()); + mouseEvent->accept(); + + } else if (mouseEvent->modifiers() == Qt::ControlModifier) { + camera.panEvent(mouseEvent->x(), mouseEvent->y()); + mouseEvent->accept(); + + } else if (mouseEvent->modifiers() == Qt::ShiftModifier) { + mouseEvent->accept(); + } + + } else { + mouseEvent->ignore(); + } + updateGL(); } /* FUNCTION: mouseReleaseEvent */ void NXOpenGLRenderingEngine::mouseReleaseEvent(QMouseEvent *mouseEvent) { - - if (mouseEvent->button() == Qt::LeftButton) { - if (mouseEvent->modifiers() == Qt::NoModifier) { - camera.rotateStopEvent(mouseEvent->x(), mouseEvent->y()); - mouseEvent->accept(); - - } else if (mouseEvent->modifiers() == Qt::ControlModifier) { - camera.panStopEvent(mouseEvent->x(), mouseEvent->y()); - mouseEvent->accept(); - - } else if (mouseEvent->modifiers() == Qt::ShiftModifier) { - mouseEvent->accept(); - } - - } else { - mouseEvent->ignore(); - } - updateGL(); + + if (mouseEvent->button() == Qt::LeftButton) { + if (mouseEvent->modifiers() == Qt::NoModifier) { + camera.rotateStopEvent(mouseEvent->x(), mouseEvent->y()); + mouseEvent->accept(); + + } else if (mouseEvent->modifiers() == Qt::ControlModifier) { + camera.panStopEvent(mouseEvent->x(), mouseEvent->y()); + mouseEvent->accept(); + + } else if (mouseEvent->modifiers() == Qt::ShiftModifier) { + mouseEvent->accept(); + } + + } else { + mouseEvent->ignore(); + } + updateGL(); } void NXOpenGLRenderingEngine::wheelEvent(QWheelEvent *event) { - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; - camera.advance(numSteps); - updateGL(); + int numDegrees = event->delta() / 8; + int numSteps = numDegrees / 15; + camera.advance(numSteps); + updateGL(); } /// Meant to be called after all renderer-plugins have been set against /// a render-style. This function initializes all plugins. Calling this /// function, then including more plugins and then calling this function again -/// will not initialize the newly +/// will not initialize the newly bool NXOpenGLRenderingEngine::initializePlugins(void) { - if(pluginsInitialized) - return true; - - bool success = true; - makeCurrent(); - map<string, NXRendererPlugin*>::iterator pluginIter; - for(pluginIter = renderStyleMap.begin(); - pluginIter != renderStyleMap.end(); - ++pluginIter) - { - // since default rendering style must also appear independently - // do not initialize - string const& renderStyleCode = pluginIter->first; - if(renderStyleCode == "def") - continue; - - NXRendererPlugin *plugin = pluginIter->second; - NXCommandResult const *const result = plugin->initialize(); - - if(result->getResult() != (int) NX_CMD_SUCCESS) { - success = false; - ostringstream logMsgStream; - logMsgStream << "Plugin for render-style " + pluginIter->first + - " couldn't be initialized. "; - vector<QString> const& msgs = result->getParamVector(); - vector<QString>::const_iterator msgIter; - for(msgIter = msgs.begin(); msgIter != msgs.end(); ++msgIter) { - logMsgStream << ' ' << qPrintable(*msgIter); - } - NXLOG_SEVERE("NXOpenGLRenderingEngine", logMsgStream.str()); - } - else { - NXLOG_INFO("NXOpenGLRenderingEngine", - "Initialized plugin for render-style " + - pluginIter->first); - } - } - - if(success) - pluginsInitialized = true; - - return success; + if(pluginsInitialized) + return true; + + bool success = true; + makeCurrent(); + map<string, NXRendererPlugin*>::iterator pluginIter; + for(pluginIter = renderStyleMap.begin(); + pluginIter != renderStyleMap.end(); + ++pluginIter) + { + // since default rendering style must also appear independently + // do not initialize + string const& renderStyleCode = pluginIter->first; + if(renderStyleCode == "def") + continue; + + NXRendererPlugin *plugin = pluginIter->second; + NXCommandResult const *const result = plugin->initialize(); + + if(result->getResult() != (int) NX_CMD_SUCCESS) { + success = false; + ostringstream logMsgStream; + logMsgStream << "Plugin for render-style " + pluginIter->first + + " couldn't be initialized. "; + vector<QString> const& msgs = result->getParamVector(); + vector<QString>::const_iterator msgIter; + for(msgIter = msgs.begin(); msgIter != msgs.end(); ++msgIter) { + logMsgStream << ' ' << qPrintable(*msgIter); + } + NXLOG_SEVERE("NXOpenGLRenderingEngine", logMsgStream.str()); + } + else { + NXLOG_INFO("NXOpenGLRenderingEngine", + "Initialized plugin for render-style " + + pluginIter->first); + } + } + + if(success) + pluginsInitialized = true; + + return success; } bool NXOpenGLRenderingEngine::cleanupPlugins(void) { - if(!pluginsInitialized) - return true; - - bool success = true; - makeCurrent(); - - map<string, NXRendererPlugin*>::iterator pluginIter; - for(pluginIter = renderStyleMap.begin(); - pluginIter != renderStyleMap.end(); - ++pluginIter) - { - // skip cleanup of default because it is an alias of another plugin - string const& renderStyleCode = pluginIter->first; - if(renderStyleCode == "def") - continue; - - NXRendererPlugin *plugin = pluginIter->second; - NXCommandResult const *const result = plugin->cleanup(); - - if(result->getResult() != (int) NX_CMD_SUCCESS) { - success = false; - ostringstream logMsgStream; - logMsgStream << "Plugin for render-style " + pluginIter->first + - " could not cleanup. "; - vector<QString> const& msgs = result->getParamVector(); - vector<QString>::const_iterator msgIter; - for(msgIter = msgs.begin(); msgIter != msgs.end(); ++msgIter) { - logMsgStream << ' ' << qPrintable(*msgIter); - } - NXLOG_SEVERE("NXOpenGLRenderingEngine", logMsgStream.str()); - success = false; - } - else { - NXLOG_INFO("NXOpenGLRenderingEngine", - "Cleaned up plugin for render-style " + - pluginIter->first); - } - } - - pluginsInitialized = false; - return success; + if(!pluginsInitialized) + return true; + + bool success = true; + makeCurrent(); + + map<string, NXRendererPlugin*>::iterator pluginIter; + for(pluginIter = renderStyleMap.begin(); + pluginIter != renderStyleMap.end(); + ++pluginIter) + { + // skip cleanup of default because it is an alias of another plugin + string const& renderStyleCode = pluginIter->first; + if(renderStyleCode == "def") + continue; + + NXRendererPlugin *plugin = pluginIter->second; + NXCommandResult const *const result = plugin->cleanup(); + + if(result->getResult() != (int) NX_CMD_SUCCESS) { + success = false; + ostringstream logMsgStream; + logMsgStream << "Plugin for render-style " + pluginIter->first + + " could not cleanup. "; + vector<QString> const& msgs = result->getParamVector(); + vector<QString>::const_iterator msgIter; + for(msgIter = msgs.begin(); msgIter != msgs.end(); ++msgIter) { + logMsgStream << ' ' << qPrintable(*msgIter); + } + NXLOG_SEVERE("NXOpenGLRenderingEngine", logMsgStream.str()); + success = false; + } + else { + NXLOG_INFO("NXOpenGLRenderingEngine", + "Cleaned up plugin for render-style " + + pluginIter->first); + } + } + + pluginsInitialized = false; + return success; } @@ -1393,29 +1393,29 @@ BoundingBox NXOpenGLRenderingEngine:: GetBoundingBox(NXMoleculeSet *const molSetPtr) { - - BoundingBox bbox; - + + BoundingBox bbox; + // include all atoms - OBMolIterator molIter; - for(molIter = molSetPtr->moleculesBegin(); - molIter != molSetPtr->moleculesEnd(); - ++molIter) - { - OBMol *const molPtr = *molIter; - bbox += GetBoundingBox(molPtr); - } - + OBMolIterator molIter; + for(molIter = molSetPtr->moleculesBegin(); + molIter != molSetPtr->moleculesEnd(); + ++molIter) + { + OBMol *const molPtr = *molIter; + bbox += GetBoundingBox(molPtr); + } + // include children molecule-sets - NXMoleculeSetIterator molSetIter; - for(molSetIter = molSetPtr->childrenBegin(); - molSetIter != molSetPtr->childrenEnd(); - ++molSetIter) - { - NXMoleculeSet *const molSetPtr = *molSetIter; - bbox += GetBoundingBox(molSetPtr); - } - return bbox; + NXMoleculeSetIterator molSetIter; + for(molSetIter = molSetPtr->childrenBegin(); + molSetIter != molSetPtr->childrenEnd(); + ++molSetIter) + { + NXMoleculeSet *const molSetPtr = *molSetIter; + bbox += GetBoundingBox(molSetPtr); + } + return bbox; } //.............................................................................. @@ -1423,21 +1423,21 @@ GetBoundingBox(NXMoleculeSet *const molSetPtr) BoundingBox NXOpenGLRenderingEngine::GetBoundingBox(OBMol *const molPtr) { - BoundingBox bbox; - OBAtomIterator atomIter; - OBAtom *atomPtr = NULL; - - for(atomPtr = molPtr->BeginAtom(atomIter); - atomPtr != NULL; - atomPtr = molPtr->NextAtom(atomIter)) - { - Vector atomPos(real(atomPtr->GetX()), - real(atomPtr->GetY()), - real(atomPtr->GetZ())); - bbox += atomPos; - } - - return bbox; + BoundingBox bbox; + OBAtomIterator atomIter; + OBAtom *atomPtr = NULL; + + for(atomPtr = molPtr->BeginAtom(atomIter); + atomPtr != NULL; + atomPtr = molPtr->NextAtom(atomIter)) + { + Vector atomPos(real(atomPtr->GetX()), + real(atomPtr->GetY()), + real(atomPtr->GetZ())); + bbox += atomPos; + } + + return bbox; } //.............................................................................. diff --git a/cad/src/cnt/commands/InsertNanotube/InsertNanotube_EditCommand.py b/cad/src/cnt/commands/InsertNanotube/InsertNanotube_EditCommand.py index 2f57a5554..be93e79d6 100644 --- a/cad/src/cnt/commands/InsertNanotube/InsertNanotube_EditCommand.py +++ b/cad/src/cnt/commands/InsertNanotube/InsertNanotube_EditCommand.py @@ -249,7 +249,7 @@ class InsertNanotube_EditCommand(EditCommand): self._revertNumber() - self._segmentList = [] + self._segmentList = [] self.win.win_update() def _createStructure(self): diff --git a/cad/src/command_support/DnaOrCnt_PropertyManager.py b/cad/src/command_support/DnaOrCnt_PropertyManager.py index 0d1549249..2ccc1236e 100644 --- a/cad/src/command_support/DnaOrCnt_PropertyManager.py +++ b/cad/src/command_support/DnaOrCnt_PropertyManager.py @@ -75,7 +75,7 @@ class DnaOrCnt_PropertyManager(EditCommand_PM): def show(self): """ Show this PM - """ + """ _superclass.show(self) if isinstance(self.showCursorTextCheckBox, PM_CheckBox): diff --git a/cad/src/commands/Fuse/FuseChunks_Command.py b/cad/src/commands/Fuse/FuseChunks_Command.py index 1e1dc394c..fe178b41b 100755 --- a/cad/src/commands/Fuse/FuseChunks_Command.py +++ b/cad/src/commands/Fuse/FuseChunks_Command.py @@ -359,7 +359,7 @@ class FuseChunks_Command(Move_Command, fusechunksBase): original list will be appended to self.overlapping_atoms (and will be eventually deleted) - """ + """ overlapping_atoms_to_delete = [] diff --git a/cad/src/commands/LightingScheme/LightingScheme_PropertyManager.py b/cad/src/commands/LightingScheme/LightingScheme_PropertyManager.py index a05b7d086..a3e13e71b 100644 --- a/cad/src/commands/LightingScheme/LightingScheme_PropertyManager.py +++ b/cad/src/commands/LightingScheme/LightingScheme_PropertyManager.py @@ -563,12 +563,11 @@ class LightingScheme_PropertyManager(Command_PropertyManager): def change_lighting(self, specularityValueJunk = None): """ - Updates win.glpane lighting using the current lighting parameters from - the light checkboxes and sliders. This is also the slot for the light - spin boxes. - @param specularityValueJunk: This value from the spin box is not used - We are interested in valueChanged signal - only + Updates win.glpane lighting using the current lighting parameters from + the light checkboxes and sliders. This is also the slot for the light + spin boxes. + @param specularityValueJunk: This value from the spin box is not used + We are interested in valueChanged signal only @type specularityValueJunk = int or None """ @@ -599,9 +598,9 @@ class LightingScheme_PropertyManager(Command_PropertyManager): def change_active_light(self, currentIndexJunk = None): """ - Slot for the Light number combobox. This changes the current light. - @param currentIndexJunk: This index value from the combobox is not used - We are interested in 'activated' signal only + Slot for the Light number combobox. This changes the current light. + @param currentIndexJunk: This index value from the combobox is not used + We are interested in 'activated' signal only @type currentIndexJunk = int or None """ self._updatePage_Lighting() diff --git a/cad/src/commands/PlaneProperties/PlanePropertyManager.py b/cad/src/commands/PlaneProperties/PlanePropertyManager.py index c3ca15ccd..54128565e 100755 --- a/cad/src/commands/PlaneProperties/PlanePropertyManager.py +++ b/cad/src/commands/PlaneProperties/PlanePropertyManager.py @@ -752,9 +752,9 @@ class PlanePropertyManager(EditCommand_PM): # checkbox is set. plane.glpane.gl_update() - def update_spinboxes(self): - """ - Update the width and height spinboxes. + def update_spinboxes(self): + """ + Update the width and height spinboxes. @see: Plane.resizeGeometry() This typically gets called when the plane is resized from the 3D workspace (which marks assy as modified) .So, update the spinboxes @@ -764,14 +764,14 @@ class PlanePropertyManager(EditCommand_PM): @see: Plane.resizeGeometry() @see: self._update_UI_do_updates() @see: Plane_EditCommand.command_update_internal_state() - """ - # blockSignals = True make sure that spinbox.valueChanged() + """ + # blockSignals = True make sure that spinbox.valueChanged() # signal is not emitted after calling spinbox.setValue(). This is done #because the spinbox valu changes as a result of resizing the plane #from the 3D workspace. - if self.command.hasValidStructure(): + if self.command.hasValidStructure(): self.heightDblSpinBox.setValue(self.command.struct.height, - blockSignals = True) + blockSignals = True) self.widthDblSpinBox.setValue(self.command.struct.width, blockSignals = True) diff --git a/cad/src/dna/commands/DnaStrand/DnaStrand_EditCommand.py b/cad/src/dna/commands/DnaStrand/DnaStrand_EditCommand.py index ac32aeb09..2a9037b2b 100644 --- a/cad/src/dna/commands/DnaStrand/DnaStrand_EditCommand.py +++ b/cad/src/dna/commands/DnaStrand/DnaStrand_EditCommand.py @@ -1003,7 +1003,7 @@ class DnaStrand_EditCommand(State_preMixin, EditCommand): item = (("Currently editing %r"%self.struct.name), noop, 'disabled') self.Menu_spec.append(item) - return + return #following should be self.struct.getDnaGroup or self.struct.getDnaGroup #need to formalize method name and then make change. dnaGroup = self.struct.parent_node_of_class(self.assy.DnaGroup) diff --git a/cad/src/dna/commands/InsertDna/InsertDna_EditCommand.py b/cad/src/dna/commands/InsertDna/InsertDna_EditCommand.py index 6952c6587..f8fbf316d 100644 --- a/cad/src/dna/commands/InsertDna/InsertDna_EditCommand.py +++ b/cad/src/dna/commands/InsertDna/InsertDna_EditCommand.py @@ -419,7 +419,7 @@ class InsertDna_EditCommand(EditCommand): self._fallbackDnaGroup = None - self._segmentList = [] + self._segmentList = [] self.win.win_update() def _createStructure(self): diff --git a/cad/src/dna/generators/Dna_Generator.py b/cad/src/dna/generators/Dna_Generator.py index 54bf3dd7f..020601ab5 100644 --- a/cad/src/dna/generators/Dna_Generator.py +++ b/cad/src/dna/generators/Dna_Generator.py @@ -800,20 +800,20 @@ class Dna_Generator: if not atomsScheduledForDeletionDict.has_key(id(a)): atomsScheduledForDeletionDict[id(a)] = a - #Add the axis atom to the atoms scheduled for deletion only when - #both the strand neighbors of this axis atom are scheduled for - #deletion. But this is not true if its a sticky end i.e. the - #axis atom has only one strand atom. To fix that problem - #we also check (second condition) if all the strand neighbors - #of an axis atom are scheduled for deletion... if so, ot also - #adds that axis atom to the atom scheduled for deletion) - #Axis atoms are explicitely deleted to fix part of memory - #leak bug 2880 (and thus no longer depends on dna updater - #to delete bare axis atoms .. which is good because there is a - #debug pref that permits bare axis atoms for some other - #uses -- Ninad 2008-05-15 + #Add the axis atom to the atoms scheduled for deletion only when + #both the strand neighbors of this axis atom are scheduled for + #deletion. But this is not true if its a sticky end i.e. the + #axis atom has only one strand atom. To fix that problem + #we also check (second condition) if all the strand neighbors + #of an axis atom are scheduled for deletion... if so, ot also + #adds that axis atom to the atom scheduled for deletion) + #Axis atoms are explicitely deleted to fix part of memory + #leak bug 2880 (and thus no longer depends on dna updater + #to delete bare axis atoms .. which is good because there is a + #debug pref that permits bare axis atoms for some other + #uses -- Ninad 2008-05-15 if len(strand_neighbors_to_delete) == 2 or \ - len(atm.strand_neighbors()) == len(strand_neighbors_to_delete): + len(atm.strand_neighbors()) == len(strand_neighbors_to_delete): if not atomsScheduledForDeletionDict.has_key(id(atm)): atomsScheduledForDeletionDict[id(atm)] = atm else: diff --git a/cad/src/experimental/NH1_Integration/HDF5_SimResults/lib/NE1_Simulation/SimResultsDataStore.py b/cad/src/experimental/NH1_Integration/HDF5_SimResults/lib/NE1_Simulation/SimResultsDataStore.py index 10d0e9d28..f5c29b5ce 100755 --- a/cad/src/experimental/NH1_Integration/HDF5_SimResults/lib/NE1_Simulation/SimResultsDataStore.py +++ b/cad/src/experimental/NH1_Integration/HDF5_SimResults/lib/NE1_Simulation/SimResultsDataStore.py @@ -8,445 +8,445 @@ class is really just a container for bond information. class SimResultsBond: - """ - A chemical bond. See L{SimResultsDataStore} for context. - """ + """ + A chemical bond. See L{SimResultsDataStore} for context. + """ - def __init__(self, atomId_1, atomId_2, order): - """ - Constructs a SimResultsBond with the given atom identifiers and order. - """ - self.atomId_1 = atomId_1 - self.atomId_2 = atomId_2 - self.order = order + def __init__(self, atomId_1, atomId_2, order): + """ + Constructs a SimResultsBond with the given atom identifiers and order. + """ + self.atomId_1 = atomId_1 + self.atomId_2 = atomId_2 + self.order = order class SimResultsDataStore: - """ - Encapsulates a simulation results data store. - - B{Atom Records Alignment -} - The arrays of atom identifiers, positions, and velocities within a given - frame are aligned. So the contents at index X of all three arrays correspond - to the same atom. - - B{Extension Data -} - Extension data can be stored in each frame. Such data could be used to plot - graphs, for example. Extension data exists as named floating point numbers, - integers, floating point number arrays, and integer arrays inside a named - data-set. - """ - - - def openDataStore(self, directory): - """ - Opens the simulation results data store, found in the given directory, - for read/write access. - @return: (0=successful or non-zero error code), (error description) - """ - print 'directory=%s' % directory - return 0 - - - def getNotes(self): - """Returns the user's notes for these simulation results.""" - pass - def setNotes(self, notes): - """Sets the user's notes for these simulation results.""" - pass - - - def getName(self): - """Returns the simulation name.""" - pass - def setName(self, name): - """Sets the simulation name.""" - pass - - - def getDescription(self): - """Returns the simulation description.""" - pass - def setDescription(self, description): - """Sets the simulation description.""" - pass - - - def getTimestep(self): - """Returns the simulation timestep in seconds.""" - pass - def setTimestep(self, timestep): - """ - Sets the simulation timestep. - @param timestep: duration in seconds - """ - pass - - - def getStartStep(self): - """Returns the simulation starting step number.""" - pass - def setStartStep(self, startStep): - """Sets the simulation starting step number.""" - pass - - - def getMaxSteps(self): - """Returns the maximum number of steps to simulate.""" - pass - def setMaxSteps(self, maxSteps): - """Sets the maximum number of steps to simulate.""" - pass - - - def getStepsPerFrame(self): - """Returns the number of steps per frame.""" - pass - def setStepsPerFrame(self, stepsPerFrame): - """Sets the number of steps per frame.""" - pass - - - def getEnvironmentTemperature(self): - """Returns the simulation environment temperature in Kelvin.""" - pass - def setEnvironmentTemperature(self, temperature): - """ - Sets the simulation environment temperature. - @param temperature: in Kelvin - """ - pass - - - def getEnvironmentPressure(self): - """Returns the simulation environment pressure in Pascals.""" - pass - def setEnvironmentPressure(self, pressure): - """ - Sets the simulation environment pressure. - @param pressure: in Pascals - """ - pass - - - def getFilePathKeys(self): - """ - Returns an array of file path keys. These file paths are for simulation - specification files, simulation workflow scripts, template files, etc. - """ - pass - def getFilePath(self, key): - """Returns the file path associated with the given key.""" - pass - def setFilePath(self, key, filePath): - """Associates the given file path with the given key.""" - pass - - - def getRunResult(self): - """ - Returns the simulation run's result and failure message if the - simulation failed. - @return: (0=success, 1=still running, 2=failure, 3=aborted), - (failure message) - """ - pass - def setRunResult(self, code, message): - """ - Sets the simulation run's result and failure message. - @param code: 0=success, 1=still running, 2=failure, 3=aborted - @param message: description of a simulation failure - """ - pass - - - def getStepCount(self): - """Returns the number of steps successfully simulated.""" - pass - def setStepCount(self, count): - """Sets the number of steps successfully simulated.""" - pass - - - def getStartTime(self): - """ - Returns the simulation start time. - @return: a U{datetime<http://docs.python.org/lib/datetime-datetime.html>} - object set to the simulation's start time - """ - pass - def setStartTime(self, startTime): - """ - Sets the simulation start time. - @param startTime: a U{datetime<http://docs.python.org/lib/datetime-datetime.html>} - object set to the simulation's start time - """ - pass - - - def getCPU_RunningTime(self): - """Returns the simulation CPU running time in seconds.""" - pass - def setCPU_RunningTime(self, cpuRunningTime): - """ - Set the simulation CPU running time. - @param cpuRunningTime: in seconds - """ - pass - - - def getWallRunningTime(self): - """Returns the simulation wall running time in seconds.""" - pass - def setWallRunningTime(self, wallRunningTime): - """ - Sets the simulation wall running time. - @param wallRunningTime: in seconds - """ - pass - - - def getExtDataNames(self): - """Returns an array of extension data-set names.""" - pass - def getExtDataKeys(self, extDataSetName): - """ - Returns an array of extension data-set keys for a given extension - data-set. - """ - pass - def getExtDataFloat(self, extDataSetName, key): - """ - Returns a floating point value stored in the extension data-set with the - given key. - """ - pass - def getExtDataInt(self, extDataSetName, key): - """ - Returns an integer value stored in the extension data-set with the - given key. - """ - pass - def getExtDataFloatArray(self, extDataSetName, key): - """ - Returns an array of floating point values stored in the extension - data-set with the given key. - """ - pass - def getExtDataIntArray(self, extDataSetName, key): - """ - Returns an array of integers stored in the extension data-set with the - given key. - """ - pass - def setExtDataFloat(self, extDataSetName, key, value): - """ - Sets a floating point value stored in the extension data-set with the - given key. - """ - pass - def setExtDataInt(self, extDataSetName, key, value): - """ - Sets an integer value stored in the extension data-set with the - given key. - """ - pass - def setExtDataFloatArray(self, extDataSetName, key, floatArray): - """ - Sets an array of floating point values stored in the extension data-set - with the given key. - """ - pass - def setExtDataIntArray(self, extDataSetName, key, intArray): - """ - Sets an array of integers stored in the extension data-set - with the given key. - """ - pass - - - def getFrameSetNames(self): - """ - Returns an array of frame-set names. These frame-set names are used to - get/set frame data. - """ - pass - def addFrameSet(self, name, aggregationMode): - """ - Adds a frame-set with the given name and aggregation mode. - @param aggregationMode: 0=per-time-step values are averaged (default), - 1=last per-time-step value is used - """ - pass - def removeFrameSet(self, name): - """Removes the frame-set with the given name.""" - pass - - - def getFrameCount(self, frameSetName): - """Returns the number of frames in a frame-set.""" - pass - def getFrameTimes(self, frameSetName): - """Returns an array of frame times (in seconds) for a frame-set.""" - pass - def getFrameTime(self, frameSetName, frameIndex): - """Returns a specific frame time (in seconds) for a frame-set.""" - pass - def addFrame(self, frameSetName, time): - """ - Adds a frame to the specified frame-set. - @param time: the frame's time in seconds - """ - pass - def removeFrame(self, frameSetName, frameIndex): - """Removes a frame from the specified frame-set.""" - pass - - - def getFrameAtomIds(self, frameSetName): - """Returns an array of atom identifiers for a frame-set.""" - pass - def setFrameAtomIds(self, frameSetName, atomIds): - """Sets the array of atom identifiers for a frame-set.""" - pass - - - def getFrameAtomPositions(self, frameSetName, frameIndex): - """ - Returns an array of Cartesian atom positions for a specified frame. Each - position is an array of length 3 corresponding to x, y, z coordinates in - meters. - """ - pass - def setFrameAtomPositions(self, frameSetName, frameIndex, positions): - """ - Sets the array of Cartesian atom positions for a specified frame. - @param positions: an array of arrays of length 3 corresponding to - x, y, z coordinates for each atom in meters - """ - pass - - - def getFrameAtomVelocities(self, frameSetName, frameIndex): - """ - Returns an array of atom velocities for a specified frame. Each velocity - is an array of length 3 corresponding to the x, y, z components of the - atom's velocity in m/s. - """ - pass - def setFrameAtomVelocities(self, frameSetName, frameIndex, velocities): - """ - Sets the array of atom velocities for a specified frame. - @param velocities: an array of arrays of length 3 corresponding to the - x, y, z components for each atom's velocity in m/s - """ - pass - - - def getFrameBonds(self, frameSetName, frameIndex): - """Returns an array of SimResultsBond objects for a specified frame.""" - pass - def setFrameBonds(self, frameSetName, frameIndex, bonds): - """Sets the array of SimResultsBond objects for a specified frame.""" - pass - - - def getFrameTotalEnergy(self, frameSetName, frameIndex): - """Returns the total energy for the specified frame in Joules.""" - pass - def setFrameTotalEnergy(self, frameSetName, frameIndex, totalEnergy): - """ - Sets the total energy for the specified frame. - @param totalEnergy: in Joules - """ - pass - - - def getFrameIdealTemperature(self, frameSetName, frameIndex): - """Returns the ideal temperature for the specified frame in Kelvin.""" - pass - def setFrameIdealTemperature(self, frameSetName, frameIndex, temperature): - """ - Sets the ideal temperature for the specified frame. - @param temperature: in Kelvin - """ - pass - - - def getFramePressure(self, frameSetName, frameIndex): - """Returns the pressure for the specified frame in Pascals.""" - pass - def setFramePressure(self, frameSetName, frameIndex, pressure): - """ - Sets the pressure for the specified frame. - @param pressure: in Pascals - """ - pass - - - def getFrameExtDataNames(self, frameSetName): - """Returns an array of extension data-set names for a given frame-set.""" - pass - def getFrameExtDataKeys(self, frameSetName, extDataSetName): - """ - Returns an array of extension data-set keys for a given extension - data-set. - """ - pass - def getFrameExtDataFloat(self, frameSetName, frameIndex, extDataSetName, - key): - """ - Returns a floating point value stored in the specified frame for the - given key. - """ - pass - def getFrameExtDataInt(self, frameSetName, frameIndex, extDataSetName, key): - """ - Returns an integer value stored in the specified frame for the given - key. - """ - pass - def getFrameExtDataFloatArray(self, frameSetName, frameIndex, - extDataSetName, key): - """ - Returns an array of floating point values stored in the specified frame - for the given key. - """ - pass - def getFrameExtDataIntArray(self, frameSetName, frameIndex, extDataSetName, - key): - """ - Returns an array of integers stored in the specified frame for the given - key. - """ - pass - def setFrameExtDataFloat(self, frameSetName, frameIndex, extDataSetName, - key, value): - """ - Sets a floating point value stored in the specified frame for the given - key. - """ - pass - def setFrameExtDataInt(self, frameSetName, frameIndex, extDataSetName, key, - value): - """ - Sets an integer value stored in the specified frame for the given - key. - """ - pass - def setFrameExtDataFloatArray(self, frameSetName, frameIndex, - extDataSetName, key, floatArray): - """ - Sets an array of floating point values stored in the specified - frame for the given key. - """ - pass - def setFrameExtDataIntArray(self, frameSetName, frameIndex, extDataSetName, - key, intArray): - """ - Sets an array of integers stored in the specified frame for the given - key. - """ - pass + """ + Encapsulates a simulation results data store. + + B{Atom Records Alignment -} + The arrays of atom identifiers, positions, and velocities within a given + frame are aligned. So the contents at index X of all three arrays correspond + to the same atom. + + B{Extension Data -} + Extension data can be stored in each frame. Such data could be used to plot + graphs, for example. Extension data exists as named floating point numbers, + integers, floating point number arrays, and integer arrays inside a named + data-set. + """ + + + def openDataStore(self, directory): + """ + Opens the simulation results data store, found in the given directory, + for read/write access. + @return: (0=successful or non-zero error code), (error description) + """ + print 'directory=%s' % directory + return 0 + + + def getNotes(self): + """Returns the user's notes for these simulation results.""" + pass + def setNotes(self, notes): + """Sets the user's notes for these simulation results.""" + pass + + + def getName(self): + """Returns the simulation name.""" + pass + def setName(self, name): + """Sets the simulation name.""" + pass + + + def getDescription(self): + """Returns the simulation description.""" + pass + def setDescription(self, description): + """Sets the simulation description.""" + pass + + + def getTimestep(self): + """Returns the simulation timestep in seconds.""" + pass + def setTimestep(self, timestep): + """ + Sets the simulation timestep. + @param timestep: duration in seconds + """ + pass + + + def getStartStep(self): + """Returns the simulation starting step number.""" + pass + def setStartStep(self, startStep): + """Sets the simulation starting step number.""" + pass + + + def getMaxSteps(self): + """Returns the maximum number of steps to simulate.""" + pass + def setMaxSteps(self, maxSteps): + """Sets the maximum number of steps to simulate.""" + pass + + + def getStepsPerFrame(self): + """Returns the number of steps per frame.""" + pass + def setStepsPerFrame(self, stepsPerFrame): + """Sets the number of steps per frame.""" + pass + + + def getEnvironmentTemperature(self): + """Returns the simulation environment temperature in Kelvin.""" + pass + def setEnvironmentTemperature(self, temperature): + """ + Sets the simulation environment temperature. + @param temperature: in Kelvin + """ + pass + + + def getEnvironmentPressure(self): + """Returns the simulation environment pressure in Pascals.""" + pass + def setEnvironmentPressure(self, pressure): + """ + Sets the simulation environment pressure. + @param pressure: in Pascals + """ + pass + + + def getFilePathKeys(self): + """ + Returns an array of file path keys. These file paths are for simulation + specification files, simulation workflow scripts, template files, etc. + """ + pass + def getFilePath(self, key): + """Returns the file path associated with the given key.""" + pass + def setFilePath(self, key, filePath): + """Associates the given file path with the given key.""" + pass + + + def getRunResult(self): + """ + Returns the simulation run's result and failure message if the + simulation failed. + @return: (0=success, 1=still running, 2=failure, 3=aborted), + (failure message) + """ + pass + def setRunResult(self, code, message): + """ + Sets the simulation run's result and failure message. + @param code: 0=success, 1=still running, 2=failure, 3=aborted + @param message: description of a simulation failure + """ + pass + + + def getStepCount(self): + """Returns the number of steps successfully simulated.""" + pass + def setStepCount(self, count): + """Sets the number of steps successfully simulated.""" + pass + + + def getStartTime(self): + """ + Returns the simulation start time. + @return: a U{datetime<http://docs.python.org/lib/datetime-datetime.html>} + object set to the simulation's start time + """ + pass + def setStartTime(self, startTime): + """ + Sets the simulation start time. + @param startTime: a U{datetime<http://docs.python.org/lib/datetime-datetime.html>} + object set to the simulation's start time + """ + pass + + + def getCPU_RunningTime(self): + """Returns the simulation CPU running time in seconds.""" + pass + def setCPU_RunningTime(self, cpuRunningTime): + """ + Set the simulation CPU running time. + @param cpuRunningTime: in seconds + """ + pass + + + def getWallRunningTime(self): + """Returns the simulation wall running time in seconds.""" + pass + def setWallRunningTime(self, wallRunningTime): + """ + Sets the simulation wall running time. + @param wallRunningTime: in seconds + """ + pass + + + def getExtDataNames(self): + """Returns an array of extension data-set names.""" + pass + def getExtDataKeys(self, extDataSetName): + """ + Returns an array of extension data-set keys for a given extension + data-set. + """ + pass + def getExtDataFloat(self, extDataSetName, key): + """ + Returns a floating point value stored in the extension data-set with the + given key. + """ + pass + def getExtDataInt(self, extDataSetName, key): + """ + Returns an integer value stored in the extension data-set with the + given key. + """ + pass + def getExtDataFloatArray(self, extDataSetName, key): + """ + Returns an array of floating point values stored in the extension + data-set with the given key. + """ + pass + def getExtDataIntArray(self, extDataSetName, key): + """ + Returns an array of integers stored in the extension data-set with the + given key. + """ + pass + def setExtDataFloat(self, extDataSetName, key, value): + """ + Sets a floating point value stored in the extension data-set with the + given key. + """ + pass + def setExtDataInt(self, extDataSetName, key, value): + """ + Sets an integer value stored in the extension data-set with the + given key. + """ + pass + def setExtDataFloatArray(self, extDataSetName, key, floatArray): + """ + Sets an array of floating point values stored in the extension data-set + with the given key. + """ + pass + def setExtDataIntArray(self, extDataSetName, key, intArray): + """ + Sets an array of integers stored in the extension data-set + with the given key. + """ + pass + + + def getFrameSetNames(self): + """ + Returns an array of frame-set names. These frame-set names are used to + get/set frame data. + """ + pass + def addFrameSet(self, name, aggregationMode): + """ + Adds a frame-set with the given name and aggregation mode. + @param aggregationMode: 0=per-time-step values are averaged (default), + 1=last per-time-step value is used + """ + pass + def removeFrameSet(self, name): + """Removes the frame-set with the given name.""" + pass + + + def getFrameCount(self, frameSetName): + """Returns the number of frames in a frame-set.""" + pass + def getFrameTimes(self, frameSetName): + """Returns an array of frame times (in seconds) for a frame-set.""" + pass + def getFrameTime(self, frameSetName, frameIndex): + """Returns a specific frame time (in seconds) for a frame-set.""" + pass + def addFrame(self, frameSetName, time): + """ + Adds a frame to the specified frame-set. + @param time: the frame's time in seconds + """ + pass + def removeFrame(self, frameSetName, frameIndex): + """Removes a frame from the specified frame-set.""" + pass + + + def getFrameAtomIds(self, frameSetName): + """Returns an array of atom identifiers for a frame-set.""" + pass + def setFrameAtomIds(self, frameSetName, atomIds): + """Sets the array of atom identifiers for a frame-set.""" + pass + + + def getFrameAtomPositions(self, frameSetName, frameIndex): + """ + Returns an array of Cartesian atom positions for a specified frame. Each + position is an array of length 3 corresponding to x, y, z coordinates in + meters. + """ + pass + def setFrameAtomPositions(self, frameSetName, frameIndex, positions): + """ + Sets the array of Cartesian atom positions for a specified frame. + @param positions: an array of arrays of length 3 corresponding to + x, y, z coordinates for each atom in meters + """ + pass + + + def getFrameAtomVelocities(self, frameSetName, frameIndex): + """ + Returns an array of atom velocities for a specified frame. Each velocity + is an array of length 3 corresponding to the x, y, z components of the + atom's velocity in m/s. + """ + pass + def setFrameAtomVelocities(self, frameSetName, frameIndex, velocities): + """ + Sets the array of atom velocities for a specified frame. + @param velocities: an array of arrays of length 3 corresponding to the + x, y, z components for each atom's velocity in m/s + """ + pass + + + def getFrameBonds(self, frameSetName, frameIndex): + """Returns an array of SimResultsBond objects for a specified frame.""" + pass + def setFrameBonds(self, frameSetName, frameIndex, bonds): + """Sets the array of SimResultsBond objects for a specified frame.""" + pass + + + def getFrameTotalEnergy(self, frameSetName, frameIndex): + """Returns the total energy for the specified frame in Joules.""" + pass + def setFrameTotalEnergy(self, frameSetName, frameIndex, totalEnergy): + """ + Sets the total energy for the specified frame. + @param totalEnergy: in Joules + """ + pass + + + def getFrameIdealTemperature(self, frameSetName, frameIndex): + """Returns the ideal temperature for the specified frame in Kelvin.""" + pass + def setFrameIdealTemperature(self, frameSetName, frameIndex, temperature): + """ + Sets the ideal temperature for the specified frame. + @param temperature: in Kelvin + """ + pass + + + def getFramePressure(self, frameSetName, frameIndex): + """Returns the pressure for the specified frame in Pascals.""" + pass + def setFramePressure(self, frameSetName, frameIndex, pressure): + """ + Sets the pressure for the specified frame. + @param pressure: in Pascals + """ + pass + + + def getFrameExtDataNames(self, frameSetName): + """Returns an array of extension data-set names for a given frame-set.""" + pass + def getFrameExtDataKeys(self, frameSetName, extDataSetName): + """ + Returns an array of extension data-set keys for a given extension + data-set. + """ + pass + def getFrameExtDataFloat(self, frameSetName, frameIndex, extDataSetName, + key): + """ + Returns a floating point value stored in the specified frame for the + given key. + """ + pass + def getFrameExtDataInt(self, frameSetName, frameIndex, extDataSetName, key): + """ + Returns an integer value stored in the specified frame for the given + key. + """ + pass + def getFrameExtDataFloatArray(self, frameSetName, frameIndex, + extDataSetName, key): + """ + Returns an array of floating point values stored in the specified frame + for the given key. + """ + pass + def getFrameExtDataIntArray(self, frameSetName, frameIndex, extDataSetName, + key): + """ + Returns an array of integers stored in the specified frame for the given + key. + """ + pass + def setFrameExtDataFloat(self, frameSetName, frameIndex, extDataSetName, + key, value): + """ + Sets a floating point value stored in the specified frame for the given + key. + """ + pass + def setFrameExtDataInt(self, frameSetName, frameIndex, extDataSetName, key, + value): + """ + Sets an integer value stored in the specified frame for the given + key. + """ + pass + def setFrameExtDataFloatArray(self, frameSetName, frameIndex, + extDataSetName, key, floatArray): + """ + Sets an array of floating point values stored in the specified + frame for the given key. + """ + pass + def setFrameExtDataIntArray(self, frameSetName, frameIndex, extDataSetName, + key, intArray): + """ + Sets an array of integers stored in the specified frame for the given + key. + """ + pass diff --git a/cad/src/experimental/NH1_Integration/lib/NE1_CorePlugins/EnergyMinimizer.py b/cad/src/experimental/NH1_Integration/lib/NE1_CorePlugins/EnergyMinimizer.py index 98ca80932..4bddcf495 100755 --- a/cad/src/experimental/NH1_Integration/lib/NE1_CorePlugins/EnergyMinimizer.py +++ b/cad/src/experimental/NH1_Integration/lib/NE1_CorePlugins/EnergyMinimizer.py @@ -9,23 +9,23 @@ from NE1_Simulation.Parameter import Parameter class EnergyMinimizer: - """ - Adjusts the positions of the given atoms so as to minimize the structure's - total energy. - """ - - - def minimize(self, structure, parameters): - """ - Minimizes the given structure with the given parameters. When NE1 starts - up, it reads some description of the EnergyMinimizer plugin to load - which includes a list of Parameters to use for the minimizer - configuration dialog. - - @param structure: whatever NE1 structure object - @param parameters: an array of L{NE1_Simulation.Parameter.Parameter} - objects - @return: the minimized structure object - """ - pass + """ + Adjusts the positions of the given atoms so as to minimize the structure's + total energy. + """ + + + def minimize(self, structure, parameters): + """ + Minimizes the given structure with the given parameters. When NE1 starts + up, it reads some description of the EnergyMinimizer plugin to load + which includes a list of Parameters to use for the minimizer + configuration dialog. + + @param structure: whatever NE1 structure object + @param parameters: an array of L{NE1_Simulation.Parameter.Parameter} + objects + @return: the minimized structure object + """ + pass diff --git a/cad/src/experimental/NH1_Integration/lib/NE1_JobManagement/NE1_Job.py b/cad/src/experimental/NH1_Integration/lib/NE1_JobManagement/NE1_Job.py index 42ec84a29..a6c27f0ba 100755 --- a/cad/src/experimental/NH1_Integration/lib/NE1_JobManagement/NE1_Job.py +++ b/cad/src/experimental/NH1_Integration/lib/NE1_JobManagement/NE1_Job.py @@ -6,116 +6,116 @@ A job that the NE1 Job Manager schedules and monitors. class NE1_Job: - """ - A job that the NE1 Job Manager schedules and monitors. Subclasses know how - to run themselves and can be polled. - - This is an abstract/interface class and should not be instantiated. - - The subclasses know how to run themselves and can be polled, etc. - The NH1_Job, when run, would communicate with the NH1 instance to launch - itself. The NE1 Job Manager could poll the NH1_Job for status. The NH1_Job - could provide call-backs to indicate simulation completion, failures, etc. - - """ - - - def getPriority(self): - """ - Returns the priority of this job. - @return: (0=low, 1=normal, 2=high) - """ - pass - - - def setPriority(self, priority): - """ - Sets the priority for this job. - @param priority: 0=low, 1=normal, 2=high - """ - pass - - - def run(self): - """ - Starts this job. - """ - pass - - - def pause(self, location): - """ - Pauses this job in-, or out-of-, memory. - @param location: 0=in-memory, 1=out-of-memory - """ - pass - - - def resume(self): - """ - Resumes this job from the paused state. - """ - pass - - - def abort(self): - """ - Abort this job. - """ - pass - - - def getStatus(self): - """ - Returns the status of this job. - @return: (0=idle, 1=running, 2=paused, 3=aborted, 4=failure), - (% complete), (text message) - """ - pass - - - def getAlertEmailAddress(self): - """ - Returns the email address to notify when this job completes or fails. - """ - pass - def setAlertEmailAddress(self, emailAddress): - """ - Sets the email address to notify when this job completes or fails. - """ - pass - - - def getPopUpNE1_Alert(self): - """ - Returns 1 if NE1 should pop up an alert when this job completes or - fails, and 0 otherwise. - """ - pass - def setPopUpNE1_Alert(self, popUp): - """ - Sets whether NE1 should pop up an alert when this job completes or - fails. - @param popUp: (1=do pop up an alert, 0=don't pop up an alert) - """ - pass - - - def getSchedule(self): - """ - Returns the time this job is scheduled to run. - @return: (0=later, 1=now), - (the later - U{datetime<http://docs.python.org/lib/datetime-datetime.html>} - object) - """ - pass - def setSchedule(self, nowOrLater, laterDatetime): - """ - Sets the time to run the job. - @param nowOrLater: 0=later, 1=now - @param laterDatetime: the later - U{datetime<http://docs.python.org/lib/datetime-datetime.html>} - object - """ - pass + """ + A job that the NE1 Job Manager schedules and monitors. Subclasses know how + to run themselves and can be polled. + + This is an abstract/interface class and should not be instantiated. + + The subclasses know how to run themselves and can be polled, etc. + The NH1_Job, when run, would communicate with the NH1 instance to launch + itself. The NE1 Job Manager could poll the NH1_Job for status. The NH1_Job + could provide call-backs to indicate simulation completion, failures, etc. + + """ + + + def getPriority(self): + """ + Returns the priority of this job. + @return: (0=low, 1=normal, 2=high) + """ + pass + + + def setPriority(self, priority): + """ + Sets the priority for this job. + @param priority: 0=low, 1=normal, 2=high + """ + pass + + + def run(self): + """ + Starts this job. + """ + pass + + + def pause(self, location): + """ + Pauses this job in-, or out-of-, memory. + @param location: 0=in-memory, 1=out-of-memory + """ + pass + + + def resume(self): + """ + Resumes this job from the paused state. + """ + pass + + + def abort(self): + """ + Abort this job. + """ + pass + + + def getStatus(self): + """ + Returns the status of this job. + @return: (0=idle, 1=running, 2=paused, 3=aborted, 4=failure), + (% complete), (text message) + """ + pass + + + def getAlertEmailAddress(self): + """ + Returns the email address to notify when this job completes or fails. + """ + pass + def setAlertEmailAddress(self, emailAddress): + """ + Sets the email address to notify when this job completes or fails. + """ + pass + + + def getPopUpNE1_Alert(self): + """ + Returns 1 if NE1 should pop up an alert when this job completes or + fails, and 0 otherwise. + """ + pass + def setPopUpNE1_Alert(self, popUp): + """ + Sets whether NE1 should pop up an alert when this job completes or + fails. + @param popUp: (1=do pop up an alert, 0=don't pop up an alert) + """ + pass + + + def getSchedule(self): + """ + Returns the time this job is scheduled to run. + @return: (0=later, 1=now), + (the later + U{datetime<http://docs.python.org/lib/datetime-datetime.html>} + object) + """ + pass + def setSchedule(self, nowOrLater, laterDatetime): + """ + Sets the time to run the job. + @param nowOrLater: 0=later, 1=now + @param laterDatetime: the later + U{datetime<http://docs.python.org/lib/datetime-datetime.html>} + object + """ + pass diff --git a/cad/src/experimental/NH1_Integration/lib/NE1_Lib/NE1_Lib.py b/cad/src/experimental/NH1_Integration/lib/NE1_Lib/NE1_Lib.py index c22889843..3fb00dbbb 100755 --- a/cad/src/experimental/NH1_Integration/lib/NE1_Lib/NE1_Lib.py +++ b/cad/src/experimental/NH1_Integration/lib/NE1_Lib/NE1_Lib.py @@ -6,72 +6,72 @@ NE1 core-library-related API. class NE1_Lib: - """ - Core NE1 methods (to support the NH1 wizard.) This API is just to give an - idea - still needs to be thought through. - - The premise of the getXxxUI() methods is that NE1 shall provide a set of - common UI for things for consistency, ie, so that the user only needs to - learn one widget for model tree node selection, and the same widget for - node selection is used everywhere. - """ - - - def getConstraintsSelectorUI(self): - """ - Returns the UI for selecting constraints. - """ - pass - - - def getMeasurementsSelectorUI(self): - """ - Returns the UI for selecting measurements. - """ - pass - - - def getAtomSetSelectorUI(self): - """ - Returns the UI for selecting atom set nodes from the model tree. - """ - pass - - - def detectUnMinized(self): - """ - Detects and reports whether there are un-minimized structures in any of - the simulation input files. - """ - pass - - - def checkJigSanity(self): - """ - Checks whether there are any unreasonable jig parameters in the - simulation. - """ - pass - - - def detectUnusedJigs(self): - """ - Detects and reports whether there are any unused jigs in the input MMP - files. - """ - pass - - - def detectReactionPoints(self): - """ - Detects and reports reaction points found in the structures in the - input files. - """ - pass - - - def checkSpinMultiplicity(self): - """ - Reports on spin mulitiplicity. - """ - pass + """ + Core NE1 methods (to support the NH1 wizard.) This API is just to give an + idea - still needs to be thought through. + + The premise of the getXxxUI() methods is that NE1 shall provide a set of + common UI for things for consistency, ie, so that the user only needs to + learn one widget for model tree node selection, and the same widget for + node selection is used everywhere. + """ + + + def getConstraintsSelectorUI(self): + """ + Returns the UI for selecting constraints. + """ + pass + + + def getMeasurementsSelectorUI(self): + """ + Returns the UI for selecting measurements. + """ + pass + + + def getAtomSetSelectorUI(self): + """ + Returns the UI for selecting atom set nodes from the model tree. + """ + pass + + + def detectUnMinized(self): + """ + Detects and reports whether there are un-minimized structures in any of + the simulation input files. + """ + pass + + + def checkJigSanity(self): + """ + Checks whether there are any unreasonable jig parameters in the + simulation. + """ + pass + + + def detectUnusedJigs(self): + """ + Detects and reports whether there are any unused jigs in the input MMP + files. + """ + pass + + + def detectReactionPoints(self): + """ + Detects and reports reaction points found in the structures in the + input files. + """ + pass + + + def checkSpinMultiplicity(self): + """ + Reports on spin mulitiplicity. + """ + pass diff --git a/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/Parameter.py b/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/Parameter.py index 2ed772f50..b932bf7db 100755 --- a/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/Parameter.py +++ b/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/Parameter.py @@ -10,131 +10,131 @@ IMAGE_2 class Parameter: - """ - A GUI editable key/value pair. When newly constructed, the value is - officially un-set (see the L{getValue} method.) - - This is an abstract/interface class and should not be instantiated. - """ - - - def __init__(self, key): - """ - Constructs a Parameter object with the given key - should only be called - by L{ParameterFactory}. - """ - hasValue = 0; - - - def getKey(self): - """ - Returns the dotted descriptor of what this parameter is. - """ - pass - - - def getValue(self): - """ - Returns whether this Parameter has a set value, and what that value is. - @return: (0=no value set, 1=value set), (value) - """ - pass - def setValue(self, value): - """ - Sets the value of this Parameter. - """ - pass - def unSetValue(self): - """ - Un-sets this Parameter's value. - """ - hasValue = 0; - + """ + A GUI editable key/value pair. When newly constructed, the value is + officially un-set (see the L{getValue} method.) + + This is an abstract/interface class and should not be instantiated. + """ + + + def __init__(self, key): + """ + Constructs a Parameter object with the given key - should only be called + by L{ParameterFactory}. + """ + hasValue = 0; + + + def getKey(self): + """ + Returns the dotted descriptor of what this parameter is. + """ + pass + + + def getValue(self): + """ + Returns whether this Parameter has a set value, and what that value is. + @return: (0=no value set, 1=value set), (value) + """ + pass + def setValue(self, value): + """ + Sets the value of this Parameter. + """ + pass + def unSetValue(self): + """ + Un-sets this Parameter's value. + """ + hasValue = 0; + class ParameterFactory: - """ - Creates fully configured Parameter subclass objects. - - Key names are dot-separated based on the L{SimSpecification} object model. - Here is the list of reserved key names: - - B{simSpec.timestep} [float seconds] - The amount of time - between the calculations of a system's state. Widget: lineedit, - min=0.05e-15, max=5.00e-15, default=0.1e-15, suffix=s - - B{simSpec.startStep} [integer] - The number of the first step - - usually zero, but may be non-zero when a simulation is continuing on - fromwhere a previous simulation stopped. Widget: lineedit, - min=0, max=-1, default=0 - - and etc. etc. for - - B{simSpec.}maxSteps, stepsPerFrame, - environmentTemperature, environmentPressure, workingDirectory - - B{simSpec.input.}type, file - - B{simSpec.motionPath.interval.}start, end - - B{simSpec.motionPath.interval.velocity.}fixed, xyzComponents, etc. - - B{simSpec.operation.}action - - B{simSpec.operation.}engine, atomSet, method, - basisSet, functional, multiplicity, integrator, energyAccuracy, - maxConvergenceAttempts, unscripted, applyFrom, applyTo - - B{simSpec.operation.constraint.}motion, atomSet - - B{simSpec.operation.measurement.}measure, atomSet - - B{simSpec.preSimChecks.}all, detectUnMinimized, checkJigSanity, - detectUnusedJigs, detectReactionPoints, checkSpinMultiplicity - """ - - - def createParameter(self, key): - """Returns a fully configured Parameter subclass for the given key.""" - pass + """ + Creates fully configured Parameter subclass objects. + + Key names are dot-separated based on the L{SimSpecification} object model. + Here is the list of reserved key names: + + B{simSpec.timestep} [float seconds] - The amount of time + between the calculations of a system's state. Widget: lineedit, + min=0.05e-15, max=5.00e-15, default=0.1e-15, suffix=s + + B{simSpec.startStep} [integer] - The number of the first step - + usually zero, but may be non-zero when a simulation is continuing on + fromwhere a previous simulation stopped. Widget: lineedit, + min=0, max=-1, default=0 + + and etc. etc. for + + B{simSpec.}maxSteps, stepsPerFrame, + environmentTemperature, environmentPressure, workingDirectory + + B{simSpec.input.}type, file + + B{simSpec.motionPath.interval.}start, end + + B{simSpec.motionPath.interval.velocity.}fixed, xyzComponents, etc. + + B{simSpec.operation.}action + + B{simSpec.operation.}engine, atomSet, method, + basisSet, functional, multiplicity, integrator, energyAccuracy, + maxConvergenceAttempts, unscripted, applyFrom, applyTo + + B{simSpec.operation.constraint.}motion, atomSet + + B{simSpec.operation.measurement.}measure, atomSet + + B{simSpec.preSimChecks.}all, detectUnMinimized, checkJigSanity, + detectUnusedJigs, detectReactionPoints, checkSpinMultiplicity + """ + + + def createParameter(self, key): + """Returns a fully configured Parameter subclass for the given key.""" + pass class ParameterSet: - """A set of Parameters.""" - - - def getGroupName(self): - """Returns this ParameterSet's group name for GUI use.""" - return self.groupName - - - def getParameter(self, key): - """ - Returns whether or not the Parameter with the given key is in this set, - and the Parameter itself if it is. - @return: (0=the Parameter for the given key is not in this set, 1=the - Parameter is present), (the Parameter) - """ - pass - def getParameterArray(self): - """ - Returns this object's Parameters in an array in the correct order. The - correct order is determined by each Parameter's "order" attribute. - """ - pass - def setParameter(self, Parameter): - """ - Sets the given parameter. Any existing Parameter with the same key will - be clobbered. - """ - # Insert the Parameter such that the array remains sorted by - # Parameter.order - pass - - - - - + """A set of Parameters.""" + + + def getGroupName(self): + """Returns this ParameterSet's group name for GUI use.""" + return self.groupName + + + def getParameter(self, key): + """ + Returns whether or not the Parameter with the given key is in this set, + and the Parameter itself if it is. + @return: (0=the Parameter for the given key is not in this set, 1=the + Parameter is present), (the Parameter) + """ + pass + def getParameterArray(self): + """ + Returns this object's Parameters in an array in the correct order. The + correct order is determined by each Parameter's "order" attribute. + """ + pass + def setParameter(self, Parameter): + """ + Sets the given parameter. Any existing Parameter with the same key will + be clobbered. + """ + # Insert the Parameter such that the array remains sorted by + # Parameter.order + pass + + + + + diff --git a/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/SimSpecification.py b/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/SimSpecification.py index 2a405de2b..7b43c499f 100755 --- a/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/SimSpecification.py +++ b/cad/src/experimental/NH1_Integration/lib/NE1_Simulation/SimSpecification.py @@ -18,370 +18,370 @@ The following is the object model of the SimSpecification module: IMAGE_1 The following is an example SimSpecification as it would appear in XML:: - <simSpecification name="Dual-H abstraction"> - <description> - Abstraction of two hydrogens from the DC10 deposition tooltip. - </description> - - <parameter key="timestep" value="0.1e-15" /> - <parameter key="startStep" value="0" /> - <parameter key="maxSteps" value="10000" /> - <parameter key="stepsPerFrame" value="10" /> - <parameter key="environmentTemperature" value="300.0" /> - <parameter key="environmentPressure" value="100000.0" /> - - <input name="abstractor"> - <parameter key="file" value="abstractor.mmp" /> - </input> - <input name="seed"> - <parameter key="file" value="diamond-fragment.mmp" /> - </input> - - <motionPath name="MotionPath1"> - <interval> - <parameter key="start" value="0.0" /> - <parameter key="end" value="180.0e-15" /> - <velocity> - <parameter key="fixed" value="true" /> - </velocity> - </interval> - <interval> - <parameter key="start" value="180e-15" /> - <parameter key="end" value="2345e-15" /> - <linearforce> - <parameter key="speed" value="200.0" /> - <parameter key="componentsXYZ" value="0.0 -5.0e-9 0.0" /> - </linearforce> - </interval> - </motionPath> - - <motionPath name="Anchor1"> - <interval> - <parameter name="start" value="0.0" /> - <parameter name="end" value="3300.0e-15" /> - <velocity> - <parameter key="fixed" value="true" /> - </velocity> - </interval> - </motionPath> - - <operation name="Force Field/Quantum Chemistry"> - <parameter key="action" value="dynamics" /> - - <method name="ND-1"> - <parameter key="engine" value="NanoDynamics-1" /> - <parameter key="atomSet" value="BulkAtomSet1" /> - </method> - - <method name="GAMESS"> - <parameter key="engine" value="GAMESS" /> - <parameter key="atomSet" value="Tooltip1" /> - <parameter key="method" value="Hartree-Fock" /> - <parameter key="basisSet" value="3-21G" /> - <parameter key="functional" value="" /> - <parameter key="multiplicity" value="auto" /> - <parameter key="integrator" value="coarse" /> - <parameter key="energyAccuracty" value="1.0e-5" /> - <parameter key="maxConvergenceAttempts" value="10" /> - <parameter key="unscripted" value="no" /> - <parameter key="applyFrom" value="0.0" /> - <parameter key="applyTo" value="20.0e-12" /> - </method> - - <constraint> - <parameter key="motion" value="MotionPath1" /> - <parameter key="atomSet" value="DC10" /> - </constraint> - <constraint> - <parameter key="motion" value="Anchor1" /> - <parameter key="atomSet" value="H-abstractor" /> - </constraint> - - <measurement> - <parameter key="measure" value="Thermo1" /> - <parameter key="atomSet" value="H-abstractor" /> - </measurement> - </operation> - - <preSimulationChecks> - <parameter key="all" value="false" /> - <parameter key="detectUnMinimized" value="true" /> - <parameter key="checkJigSanity" value="true" /> - <parameter key="detectUnusedJigs" value="false" /> - <parameter key="detectReactionPoints" value="true" /> - <parameter key="checkSpinMultiplicity" value="true" /> - </preSimulationChecks> - </simSpecification> + <simSpecification name="Dual-H abstraction"> + <description> + Abstraction of two hydrogens from the DC10 deposition tooltip. + </description> + + <parameter key="timestep" value="0.1e-15" /> + <parameter key="startStep" value="0" /> + <parameter key="maxSteps" value="10000" /> + <parameter key="stepsPerFrame" value="10" /> + <parameter key="environmentTemperature" value="300.0" /> + <parameter key="environmentPressure" value="100000.0" /> + + <input name="abstractor"> + <parameter key="file" value="abstractor.mmp" /> + </input> + <input name="seed"> + <parameter key="file" value="diamond-fragment.mmp" /> + </input> + + <motionPath name="MotionPath1"> + <interval> + <parameter key="start" value="0.0" /> + <parameter key="end" value="180.0e-15" /> + <velocity> + <parameter key="fixed" value="true" /> + </velocity> + </interval> + <interval> + <parameter key="start" value="180e-15" /> + <parameter key="end" value="2345e-15" /> + <linearforce> + <parameter key="speed" value="200.0" /> + <parameter key="componentsXYZ" value="0.0 -5.0e-9 0.0" /> + </linearforce> + </interval> + </motionPath> + + <motionPath name="Anchor1"> + <interval> + <parameter name="start" value="0.0" /> + <parameter name="end" value="3300.0e-15" /> + <velocity> + <parameter key="fixed" value="true" /> + </velocity> + </interval> + </motionPath> + + <operation name="Force Field/Quantum Chemistry"> + <parameter key="action" value="dynamics" /> + + <method name="ND-1"> + <parameter key="engine" value="NanoDynamics-1" /> + <parameter key="atomSet" value="BulkAtomSet1" /> + </method> + + <method name="GAMESS"> + <parameter key="engine" value="GAMESS" /> + <parameter key="atomSet" value="Tooltip1" /> + <parameter key="method" value="Hartree-Fock" /> + <parameter key="basisSet" value="3-21G" /> + <parameter key="functional" value="" /> + <parameter key="multiplicity" value="auto" /> + <parameter key="integrator" value="coarse" /> + <parameter key="energyAccuracty" value="1.0e-5" /> + <parameter key="maxConvergenceAttempts" value="10" /> + <parameter key="unscripted" value="no" /> + <parameter key="applyFrom" value="0.0" /> + <parameter key="applyTo" value="20.0e-12" /> + </method> + + <constraint> + <parameter key="motion" value="MotionPath1" /> + <parameter key="atomSet" value="DC10" /> + </constraint> + <constraint> + <parameter key="motion" value="Anchor1" /> + <parameter key="atomSet" value="H-abstractor" /> + </constraint> + + <measurement> + <parameter key="measure" value="Thermo1" /> + <parameter key="atomSet" value="H-abstractor" /> + </measurement> + </operation> + + <preSimulationChecks> + <parameter key="all" value="false" /> + <parameter key="detectUnMinimized" value="true" /> + <parameter key="checkJigSanity" value="true" /> + <parameter key="detectUnusedJigs" value="false" /> + <parameter key="detectReactionPoints" value="true" /> + <parameter key="checkSpinMultiplicity" value="true" /> + </preSimulationChecks> + </simSpecification> Packages may add their own custom parameters and they will be stored along with the reserved-key parameters. Custom parameters can be specified with the information necessary for viewing and editing them via some GUI. Here is what a fully defined parameter would look like in XML:: - <parameter key="simFlowScript" value="/Users/bh/tooltip_action.tcl"> - <label>Workflow script</label> - <widget>filechooser</widget> - <extension>.tcl</extension> - <tooltip>Simulation workflow script file</tooltip> - </parameter> + <parameter key="simFlowScript" value="/Users/bh/tooltip_action.tcl"> + <label>Workflow script</label> + <widget>filechooser</widget> + <extension>.tcl</extension> + <tooltip>Simulation workflow script file</tooltip> + </parameter> """ from Parameter import ParameterSet class SimInput(ParameterSet): - """Simulation input files. See L{SimSpecification} for context.""" - - - def __init__(self, name): - """Constructs a SimInput with the given name.""" - groupName = "Input files" - - - def getName(self): - """Returns this SimInput's name.""" - pass - def setName(self, name): - """Sets this SimInput's name.""" - pass + """Simulation input files. See L{SimSpecification} for context.""" + + + def __init__(self, name): + """Constructs a SimInput with the given name.""" + groupName = "Input files" + + + def getName(self): + """Returns this SimInput's name.""" + pass + def setName(self, name): + """Sets this SimInput's name.""" + pass class Action(ParameterSet): - """ - An external effect applied to a set of atoms. - See L{SimSpecification} for context. - - This is an abstract/interface class and should not be instantiated. - """ - pass + """ + An external effect applied to a set of atoms. + See L{SimSpecification} for context. + + This is an abstract/interface class and should not be instantiated. + """ + pass class Velocity(Action): - """ - A fixed velocity applied to a set of atoms. - See L{SimSpecification} for context. - """ - - - def __init__(self): - """Constructs a Velocity object.""" - groupName = "Velocity" + """ + A fixed velocity applied to a set of atoms. + See L{SimSpecification} for context. + """ + + + def __init__(self): + """Constructs a Velocity object.""" + groupName = "Velocity" class LinearForce(Action): - """ - A force applied to a set of atoms. - See L{SimSpecification} for context. - """ - - - def __init__(self): - """Constructs a LinearForce object.""" - groupName = "Linear force" + """ + A force applied to a set of atoms. + See L{SimSpecification} for context. + """ + + + def __init__(self): + """Constructs a LinearForce object.""" + groupName = "Linear force" class Torque(Action): - """ - A rotary force applied to a set of atoms. - See L{SimSpecification} for context. - """ - - - def __init__(self): - """Constructs a Torque object.""" - groupName = "Torque" - + """ + A rotary force applied to a set of atoms. + See L{SimSpecification} for context. + """ + + + def __init__(self): + """Constructs a Torque object.""" + groupName = "Torque" + class Interval(ParameterSet): - """ - A span of time and associated Action. - See L{SimSpecification} for context. - """ - - - def __init__(self): - """Constructs an Interval object.""" - groupName = "Interval" - - - def getAction(self): - """Returns the Action subclass for this interval.""" - pass - def setAction(self, Action): - """ - Sets the Action subclass for this interval. Clobbers any existing - Action. - """ - pass + """ + A span of time and associated Action. + See L{SimSpecification} for context. + """ + + + def __init__(self): + """Constructs an Interval object.""" + groupName = "Interval" + + + def getAction(self): + """Returns the Action subclass for this interval.""" + pass + def setAction(self, Action): + """ + Sets the Action subclass for this interval. Clobbers any existing + Action. + """ + pass class MotionPath(ParameterSet): - """ - A description of motion during simulation. - See L{SimSpecification} for context. - """ - - - def __init__(self, name): - """Constructs a MotionPath with the given name.""" - groupName = "Motion path" - - - def getName(self): - """Returns this MotionPath's name.""" - pass - def setName(self, name): - """Sets this MotionPath's name.""" - pass - - - def getIntervalArray(self): - """Returns this MotionPath's Interval as an array.""" - pass - def addInterval(self, interval): - """Adds the given Interval and returns an Interval index.""" - pass - def deleteInterval(self, intervalIndex): - """Deletes the Interval with the given index from this MotionPath.""" - pass + """ + A description of motion during simulation. + See L{SimSpecification} for context. + """ + + + def __init__(self, name): + """Constructs a MotionPath with the given name.""" + groupName = "Motion path" + + + def getName(self): + """Returns this MotionPath's name.""" + pass + def setName(self, name): + """Sets this MotionPath's name.""" + pass + + + def getIntervalArray(self): + """Returns this MotionPath's Interval as an array.""" + pass + def addInterval(self, interval): + """Adds the given Interval and returns an Interval index.""" + pass + def deleteInterval(self, intervalIndex): + """Deletes the Interval with the given index from this MotionPath.""" + pass class Method(ParameterSet): - """A simulation scheme. See L{SimSpecification} for context.""" - - - def __init__(self): - """Constructs a Method object.""" - groupName = "Method" + """A simulation scheme. See L{SimSpecification} for context.""" + + + def __init__(self): + """Constructs a Method object.""" + groupName = "Method" class Constraint(ParameterSet): - """Application of a Motion path on an atom set.""" - - - def __init__(self): - """Constructs a Constraint object.""" - groupName = "Constraint" + """Application of a Motion path on an atom set.""" + + + def __init__(self): + """Constructs a Constraint object.""" + groupName = "Constraint" class Measurement(ParameterSet): - """Application of a Measure on an atom set.""" - - - def __init__(self): - """Constructs a Measurement object.""" - groupName = "Measurement" + """Application of a Measure on an atom set.""" + + + def __init__(self): + """Constructs a Measurement object.""" + groupName = "Measurement" class Operation(ParameterSet): - """Describes the components of the actual simulation process.""" - - - def __init__(self): - """Constructs an Operation object.""" - groupName = "Operation" - - + """Describes the components of the actual simulation process.""" + + + def __init__(self): + """Constructs an Operation object.""" + groupName = "Operation" + + class SimSpecification(ParameterSet): - """ - Encapsulates all the particulars of a simulation such as input files, - entity traversal, level of theory, calculation, motion, and results. - """ - - - def __init__(self, name): - """Constructs a SimSpecification with the given name.""" - groupName = "Simulation specification" - - - def loadFromFile(self, filepath): - """ - Loads this SimSpecification from the given filepath. - @return: (0=successful or non-zero error code), (error description) - """ - pass - - - def writeToFile(self, filepath): - """ - Writes this SimSpecification to the given filepath. - @return: (0=successful or non-zero error code), (error description) - """ - pass - - - def getName(self): - """Returns this SimSpecification's name.""" - pass - def setName(self, name): - """Sets this SimSpecification's name.""" - pass - - - def getDescription(self): - """Returns this SimSpecification's description.""" - pass - def setDescription(self): - """Sets this SimSpecification's description.""" - pass - - - def getParameter(self, key): - """ - Returns the Parameter with the given key. A blank Parameter is returned - if no Parameter with the given key has been set. - """ - pass - def getParameterArray(self): - """Returns this object's Parameters in an array.""" - pass - def setParameter(self, Parameter): - """ - Sets the given parameter. Any existing Parameter with the same key will - be clobbered. - """ - pass - - - def getSimInputArray(self): - """Returns this SimSpecification's SimInputs in an array.""" - pass - def addSimInput(self, Input): - """ - Adds the given SimInput. Any existing SimInput with the same - name will be clobbered. - """ - pass - - - def getMotionPathArray(self): - """Returns this SimSpecification's MotionPaths in an array.""" - pass - def addMotionPath(self, MotionPath): - """ - Adds the given MotionPath. Any existing MotionPath with the same - name will be clobbered. - """ - pass - - - def getOperation(self): - """Returns this SimSpecification's Operation.""" - pass - def setOperation(self, Operation): - """ - Sets the given Operation. Any existing Operation will be clobbered. - """ - pass - - - def getPreSimulationChecks(self): - """ - Returns this SimSpecification's pre-simulation check Parameters in an - array. - """ - pass - def addPreSimulationCheck(self, Parameter): - """ - Adds the given pre-simulation check Parameter. Any existing pre-check - with the same key will be clobbered. - """ - pass + """ + Encapsulates all the particulars of a simulation such as input files, + entity traversal, level of theory, calculation, motion, and results. + """ + + + def __init__(self, name): + """Constructs a SimSpecification with the given name.""" + groupName = "Simulation specification" + + + def loadFromFile(self, filepath): + """ + Loads this SimSpecification from the given filepath. + @return: (0=successful or non-zero error code), (error description) + """ + pass + + + def writeToFile(self, filepath): + """ + Writes this SimSpecification to the given filepath. + @return: (0=successful or non-zero error code), (error description) + """ + pass + + + def getName(self): + """Returns this SimSpecification's name.""" + pass + def setName(self, name): + """Sets this SimSpecification's name.""" + pass + + + def getDescription(self): + """Returns this SimSpecification's description.""" + pass + def setDescription(self): + """Sets this SimSpecification's description.""" + pass + + + def getParameter(self, key): + """ + Returns the Parameter with the given key. A blank Parameter is returned + if no Parameter with the given key has been set. + """ + pass + def getParameterArray(self): + """Returns this object's Parameters in an array.""" + pass + def setParameter(self, Parameter): + """ + Sets the given parameter. Any existing Parameter with the same key will + be clobbered. + """ + pass + + + def getSimInputArray(self): + """Returns this SimSpecification's SimInputs in an array.""" + pass + def addSimInput(self, Input): + """ + Adds the given SimInput. Any existing SimInput with the same + name will be clobbered. + """ + pass + + + def getMotionPathArray(self): + """Returns this SimSpecification's MotionPaths in an array.""" + pass + def addMotionPath(self, MotionPath): + """ + Adds the given MotionPath. Any existing MotionPath with the same + name will be clobbered. + """ + pass + + + def getOperation(self): + """Returns this SimSpecification's Operation.""" + pass + def setOperation(self, Operation): + """ + Sets the given Operation. Any existing Operation will be clobbered. + """ + pass + + + def getPreSimulationChecks(self): + """ + Returns this SimSpecification's pre-simulation check Parameters in an + array. + """ + pass + def addPreSimulationCheck(self, Parameter): + """ + Adds the given pre-simulation check Parameter. Any existing pre-check + with the same key will be clobbered. + """ + pass diff --git a/cad/src/experimental/basic-qt-app/ticker.py b/cad/src/experimental/basic-qt-app/ticker.py index f48d3b7b0..39e6f678b 100755 --- a/cad/src/experimental/basic-qt-app/ticker.py +++ b/cad/src/experimental/basic-qt-app/ticker.py @@ -10,11 +10,11 @@ class Ticker(QObject): #timer.setSingleShot(True) self.connect(self.timer, SIGNAL("timeout()"), self.hello) timer.start(1000) - + def hello(self): print 'hi it works' return 4 - + x=Ticker() if __name__ == '__main__': diff --git a/cad/src/graphics/drawables/DirectionArrow.py b/cad/src/graphics/drawables/DirectionArrow.py index 87b9735f6..806aa2695 100644 --- a/cad/src/graphics/drawables/DirectionArrow.py +++ b/cad/src/graphics/drawables/DirectionArrow.py @@ -166,14 +166,14 @@ class DirectionArrow(DragHandler_API, Selobj_API): @type glpane: L{GLPane} @param color: Highlight color """ - q = self.parent.quat - glPushMatrix() - glTranslatef( self.parent.center[0], - self.parent.center[1], - self.parent.center[2]) - glRotatef( q.angle * ONE_RADIAN, - q.x, - q.y, + q = self.parent.quat + glPushMatrix() + glTranslatef( self.parent.center[0], + self.parent.center[1], + self.parent.center[2]) + glRotatef( q.angle * ONE_RADIAN, + q.x, + q.y, q.z) if self.flipDirection: diff --git a/cad/src/graphics/drawing/ColorSorter.py b/cad/src/graphics/drawing/ColorSorter.py index 1db4de603..9e0016530 100755 --- a/cad/src/graphics/drawing/ColorSorter.py +++ b/cad/src/graphics/drawing/ColorSorter.py @@ -397,7 +397,7 @@ class ColorSorter: else: opacity = 1.0 - if opacity >= 0.0 and opacity != 1.0: + if opacity >= 0.0 and opacity != 1.0: glDepthMask(GL_FALSE) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) @@ -463,10 +463,10 @@ class ColorSorter: ColorSorter.glpane.glprefs.sphereShader_desired() and drawing_globals.sphereShader_available() ) - if len(color) == 3: + if len(color) == 3: lcolor = (color[0], color[1], color[2], opacity) else: - lcolor = color + lcolor = color pass if sphereBatches and ColorSorter._parent_csdl: # Russ 080925: Added. @@ -519,10 +519,10 @@ class ColorSorter: ColorSorter._cur_shapelist.add_wiresphere( lcolor, pos, radius, ColorSorter._gl_name_stack[-1]) else: - if len(color) == 3: + if len(color) == 3: lcolor = (color[0], color[1], color[2], 1.0) else: - lcolor = color + lcolor = color ColorSorter.schedule(lcolor, drawwiresphere_worker, # Use constant-color line drawing. @@ -580,10 +580,10 @@ class ColorSorter: lcolor, pos1, pos2, radius, ColorSorter._gl_name_stack[-1], capped) else: - if len(color) == 3: + if len(color) == 3: lcolor = (color[0], color[1], color[2], opacity) else: - lcolor = color + lcolor = color # Russ 090119: Added. cylinderBatches = ( ColorSorter._permit_shaders and @@ -695,10 +695,10 @@ class ColorSorter: lcolor, pos_array, rad_array, ColorSorter._gl_name_stack[-1], capped) else: - if len(color) == 3: + if len(color) == 3: lcolor = (color[0], color[1], color[2], opacity) else: - lcolor = color + lcolor = color ColorSorter.schedule(lcolor, drawpolycone_worker, (pos_array, rad_array)) @@ -729,10 +729,10 @@ class ColorSorter: lcolor, pos_array, color_array, rad_array, ColorSorter._gl_name_stack[-1], capped) else: - if len(color) == 3: + if len(color) == 3: lcolor = (color[0], color[1], color[2], opacity) else: - lcolor = color + lcolor = color ColorSorter.schedule(lcolor, drawpolycone_multicolor_worker, @@ -751,10 +751,10 @@ class ColorSorter: if ColorSorter._relative_transforms(): ColorSorter._warn_transforms_nim("schedule_surface") - if len(color) == 3: + if len(color) == 3: lcolor = (color[0], color[1], color[2], 1.0) else: - lcolor = color + lcolor = color ColorSorter.schedule(lcolor, drawsurface_worker, (pos, radius, tm, nm)) schedule_surface = staticmethod(schedule_surface) diff --git a/cad/src/graphics/drawing/drawDnaLadder.py b/cad/src/graphics/drawing/drawDnaLadder.py index 44819412d..c9d2e44be 100755 --- a/cad/src/graphics/drawing/drawDnaLadder.py +++ b/cad/src/graphics/drawing/drawDnaLadder.py @@ -120,7 +120,7 @@ def drawDnaLadder(endCenter1, previousLadderBeam1Point = ladderBeam1Point previousLadderBeam2Point = ladderBeam2Point - pointOnAxis = pointOnAxis + unitVector*duplexRise + pointOnAxis = pointOnAxis + unitVector*duplexRise x += duplexRise ladderBeam1Point = previousPoint + \ diff --git a/cad/src/graphics/drawing/drawNanotubeLadder.py b/cad/src/graphics/drawing/drawNanotubeLadder.py index ff70a32b0..70d7acfc1 100644 --- a/cad/src/graphics/drawing/drawNanotubeLadder.py +++ b/cad/src/graphics/drawing/drawNanotubeLadder.py @@ -118,7 +118,7 @@ def drawNanotubeLadder(endCenter1, previousLadderBeam1Point = ladderBeam1Point previousLadderBeam2Point = ladderBeam2Point - pointOnAxis = pointOnAxis + unitVector * cntRise + pointOnAxis = pointOnAxis + unitVector * cntRise x += cntRise ladderBeam1Point = previousPoint + \ diff --git a/cad/src/graphics/drawing/drawPeptideTrace.py b/cad/src/graphics/drawing/drawPeptideTrace.py index 1f5c4f061..cd7735d2a 100644 --- a/cad/src/graphics/drawing/drawPeptideTrace.py +++ b/cad/src/graphics/drawing/drawPeptideTrace.py @@ -163,7 +163,7 @@ def drawPeptideTrace_orig(endCenter1, previousLadderBeam1Point = ladderBeam1Point previousLadderBeam2Point = ladderBeam2Point - pointOnAxis = pointOnAxis + unitVector * cntRise + pointOnAxis = pointOnAxis + unitVector * cntRise x += cntRise ladderBeam1Point = previousPoint + \ diff --git a/cad/src/graphics/drawing/drawers.py b/cad/src/graphics/drawing/drawers.py index dd215cfe3..2ff9f137c 100755 --- a/cad/src/graphics/drawing/drawers.py +++ b/cad/src/graphics/drawing/drawers.py @@ -836,7 +836,7 @@ def drawbrick(color, center, axis, l, h, w, opacity = 1.0): if len(color) == 3: color = (color[0], color[1], color[2], opacity) - if opacity != 1.0: + if opacity != 1.0: glDepthMask(GL_FALSE) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) @@ -860,7 +860,7 @@ def drawbrick(color, center, axis, l, h, w, opacity = 1.0): #bruce 060302 revised the contents of solidCubeList while fixing bug 1595 glCallList(drawing_globals.solidCubeList) - if opacity != 1.0: + if opacity != 1.0: glDisable(GL_BLEND) glDepthMask(GL_TRUE) @@ -1221,7 +1221,7 @@ def renderSurface(surfaceEntities, surfaceNormals): onevert(entity[1]) onevert(entity[2]) glEnd() - else: + else: glBegin(GL_QUADS) for entity in entityIndex: onevert(entity[0]) diff --git a/cad/src/graphics/drawing/gl_lighting.py b/cad/src/graphics/drawing/gl_lighting.py index b251c027a..05a24c2c3 100755 --- a/cad/src/graphics/drawing/gl_lighting.py +++ b/cad/src/graphics/drawing/gl_lighting.py @@ -53,7 +53,7 @@ try: from OpenGL.GL import glFogv # piotr 080515 except: # The installed version of OpenGL requires argument-typed glFog calls. - from OpenGL.GL import glFogf as glFog + from OpenGL.GL import glFogf as glFog from OpenGL.GL import glFogfv as glFogv pass diff --git a/cad/src/graphics/drawing/gl_shaders.py b/cad/src/graphics/drawing/gl_shaders.py index 6bd96f841..d4980cc4c 100644 --- a/cad/src/graphics/drawing/gl_shaders.py +++ b/cad/src/graphics/drawing/gl_shaders.py @@ -101,13 +101,13 @@ CHECK_TEXTURE_XFORM_LOADING = False # True ## Never check in a True value. # Exception Type: EXC_BAD_ACCESS (SIGSEGV) # Exception Codes: KERN_INVALID_ADDRESS at 0x0000000013b88000 # Thread 0 Crashed: -# 0 libSystem.B.dylib 0xffff08a0 __memcpy + 256 -# 1 libGLImage.dylib 0x913ea5e9 glgCopyRowsWithMemCopy( +# 0 libSystem.B.dylib 0xffff08a0 __memcpy + 256 +# 1 libGLImage.dylib 0x913ea5e9 glgCopyRowsWithMemCopy( # GLGOperation const*, unsigned long, GLDPixelMode const*) + 121 -# 2 libGLImage.dylib 0x913e8ac6 glgProcessPixelsWithProcessor + 326 -# 3 GLEngine 0x1ea16198 gleTextureImagePut + 1752 -# 4 GLEngine 0x1ea1f896 glTexSubImage2D_Exec + 1350 -# 5 libGL.dylib 0x91708cdb glTexSubImage2D + 155 +# 2 libGLImage.dylib 0x913e8ac6 glgProcessPixelsWithProcessor + 326 +# 3 GLEngine 0x1ea16198 gleTextureImagePut + 1752 +# 4 GLEngine 0x1ea1f896 glTexSubImage2D_Exec + 1350 +# 5 libGL.dylib 0x91708cdb glTexSubImage2D + 155 from geometry.VQT import A, norm diff --git a/cad/src/graphics/drawing/shader_objects_patch.py b/cad/src/graphics/drawing/shader_objects_patch.py index 4b92134a3..6c1703eab 100644 --- a/cad/src/graphics/drawing/shader_objects_patch.py +++ b/cad/src/graphics/drawing/shader_objects_patch.py @@ -123,7 +123,7 @@ glCompileShaderARB.errcheck = _afterCheck( GL_OBJECT_COMPILE_STATUS_ARB ) glLinkProgramARB.errcheck = _afterCheck( GL_OBJECT_LINK_STATUS_ARB ) ## Not sure why, but these give invalid operation :( ##if glValidateProgramARB and OpenGL.ERROR_CHECKING: -## glValidateProgramARB.errcheck = _afterCheck( GL_OBJECT_VALIDATE_STATUS_ARB ) +## glValidateProgramARB.errcheck = _afterCheck( GL_OBJECT_VALIDATE_STATUS_ARB ) base_glGetInfoLogARB = glGetInfoLogARB def glGetInfoLogARB( obj ): diff --git a/cad/src/graphics/drawing/vbo_patch.py b/cad/src/graphics/drawing/vbo_patch.py index 44a71ad86..a2074f70c 100644 --- a/cad/src/graphics/drawing/vbo_patch.py +++ b/cad/src/graphics/drawing/vbo_patch.py @@ -43,11 +43,11 @@ glBufferSubDataARB = wrapper.wrapper( glBufferSubDataARB ).setPyConverter( # Changed the "indices" argument type from ctypes.POINTER(ctypes.c_void_p) to # arrays.GLintArray, like the "first" argument of glMultiDrawArrays. glMultiDrawElementsVBO = platform.createExtensionFunction( - 'glMultiDrawElementsEXT', dll=platform.GL, - resultType=None, - argTypes=(constants.GLenum, arrays.GLsizeiArray, + 'glMultiDrawElementsEXT', dll=platform.GL, + resultType=None, + argTypes=(constants.GLenum, arrays.GLsizeiArray, constants.GLenum, arrays.GLintArray, constants.GLsizei,), - doc = ('glMultiDrawElementsEXT( GLenum(mode), GLsizeiArray(count), ' + doc = ('glMultiDrawElementsEXT( GLenum(mode), GLsizeiArray(count), ' 'GLenum(type), GLintArray(indices), GLsizei(primcount) ) -> None'), - argNames = ('mode', 'count', 'type', 'indices', 'primcount',), + argNames = ('mode', 'count', 'type', 'indices', 'primcount',), ) diff --git a/cad/src/graphics/rendering/povray/povray.py b/cad/src/graphics/rendering/povray/povray.py index e13eae233..47afeb30e 100755 --- a/cad/src/graphics/rendering/povray/povray.py +++ b/cad/src/graphics/rendering/povray/povray.py @@ -322,7 +322,7 @@ def launch_povray_or_megapov(win, info, povray_ini): #bruce 060707/11 revised th # unless it matters that it reads and discards stdout/stderr # (eg so large output would not block -- unlikely that this matters). # It doesn't echo stdout/stderr. See also blabout/blaberr in other files. Maybe fix this? ###@@@ - p.setWorkingDirectory(workdir) + p.setWorkingDirectory(workdir) p.start(program, arguments) # Put up hourglass cursor to indicate we are busy. Restore the cursor below. Mark 060621. diff --git a/cad/src/model/Chunk_Dna_methods.py b/cad/src/model/Chunk_Dna_methods.py index ea069d96a..08219bbe2 100644 --- a/cad/src/model/Chunk_Dna_methods.py +++ b/cad/src/model/Chunk_Dna_methods.py @@ -144,11 +144,11 @@ class Chunk_Dna_methods: ## (NodeWithAtomContents): else: item = (("%s of [%s]" % (strand.name, dnaGroup.name)), noop, - 'disabled') + 'disabled') contextMenuList.append(None) # adds a separator in the contextmenu - contextMenuList.append(item) + contextMenuList.append(item) item = (("Edit DnaStrand Properties..."), - strand.edit) + strand.edit) contextMenuList.append(item) contextMenuList.append(None) # separator diff --git a/cad/src/model/Plane.py b/cad/src/model/Plane.py index 343d99531..c7a75547c 100755 --- a/cad/src/model/Plane.py +++ b/cad/src/model/Plane.py @@ -288,7 +288,7 @@ class Plane(ReferenceGeometry): """ if not previewing: try: - self.fill_color = self.default_fill_color + self.fill_color = self.default_fill_color self.border_color = self.default_border_color self.opacity = self.default_opacity except: diff --git a/cad/src/model/jigs.py b/cad/src/model/jigs.py index 8283a74b9..1bf424d72 100755 --- a/cad/src/model/jigs.py +++ b/cad/src/model/jigs.py @@ -672,14 +672,14 @@ class Jig(NodeWith3DContents, Selobj_API): so all they need to override is mmp_record_jigspecific_midpart.] """ if mapping is not None: - ndix = mapping.atnums + ndix = mapping.atnums name = mapping.encode_name(self.name) # flags related to what we can do about atoms on this jig which have no encoding in mapping permit_fwd_ref = not mapping.min #bruce 051031 (kluge, mapping should say this more directly) permit_missing_jig_atoms = mapping.min #bruce 051031 (ditto on kluge) assert not (permit_fwd_ref and permit_missing_jig_atoms) # otherwise wouldn't know which one to do with missing atoms! else: - ndix = None + ndix = None name = self.name permit_fwd_ref = False #bruce 051031 permit_missing_jig_atoms = False # guess [bruce 051031] diff --git a/cad/src/operations/ops_display.py b/cad/src/operations/ops_display.py index 5abec53f4..0c4f26c79 100644 --- a/cad/src/operations/ops_display.py +++ b/cad/src/operations/ops_display.py @@ -234,12 +234,12 @@ class displaySlotsMixin: # it should be unpicked after changing its color. # The user has most likely selected the chunk to change its color # and won't like it still shown 'green'(the selection color) - # even after changing the color. so deselect it. + # even after changing the color. so deselect it. # The chunk is NOT unpicked IF the color is changed via chunk # property dialog. see ChunkProp.change_chunk_color for details. # This is intentional. - for ob in list: + for ob in list: ob.unpick() self.win_update() diff --git a/cad/src/outtakes/PeptideGroup.py b/cad/src/outtakes/PeptideGroup.py index 38495d7c7..72207d11b 100644 --- a/cad/src/outtakes/PeptideGroup.py +++ b/cad/src/outtakes/PeptideGroup.py @@ -102,11 +102,11 @@ class PeptideGroup(Group): def getProps(self): """ - Method to support Dna duplex editing. see Group.__init__ for - a comment + Method to support Dna duplex editing. see Group.__init__ for + a comment THIS IS THE DEFAULT IMPLEMENTATION. TO BE MODIFIED - """ + """ #Should it supply the Dna Segment list (children) and then add #individual segments when setProps is called?? # [probably not; see B&N email discussion from when this comment was added] @@ -116,10 +116,11 @@ class PeptideGroup(Group): def setProps(self, props): """ - Method to support Dna duplex editing. see Group.__init__ for - a comment + Method to support Dna duplex editing. see Group.__init__ for + a comment + THIS IS THE DEFAULT IMPLEMENTATION. TO BE MODIFIED - """ + """ #Should it accept the Dna Segment list and then add individual segments? pass diff --git a/cad/src/outtakes/TreeView.py b/cad/src/outtakes/TreeView.py index c652d9177..ce457e578 100755 --- a/cad/src/outtakes/TreeView.py +++ b/cad/src/outtakes/TreeView.py @@ -235,7 +235,7 @@ class TreeView(QTreeView): # try doing these first, but if that fails, do them after columns are made [as before]: qt4skipit('self.setSorting(-1)') - + self.setRootIsDecorated(1) qt4skipit('self.setShowSortIndicator(0) # [this used to be done after setResizePolicy]') diff --git a/cad/src/protein/commands/InsertPeptide/InsertPeptide_EditCommand.py b/cad/src/protein/commands/InsertPeptide/InsertPeptide_EditCommand.py index c09f21b58..4e3472f0c 100644 --- a/cad/src/protein/commands/InsertPeptide/InsertPeptide_EditCommand.py +++ b/cad/src/protein/commands/InsertPeptide/InsertPeptide_EditCommand.py @@ -218,7 +218,7 @@ class InsertPeptide_EditCommand(EditCommand): # peptide.kill_with_contents() # self._revertNumber() - self._peptideList = [] + self._peptideList = [] self.win.win_update() return diff --git a/cad/src/protein/commands/InsertPeptide/PeptideGenerator.py b/cad/src/protein/commands/InsertPeptide/PeptideGenerator.py index 6dd6b31ae..1b947ef54 100755 --- a/cad/src/protein/commands/InsertPeptide/PeptideGenerator.py +++ b/cad/src/protein/commands/InsertPeptide/PeptideGenerator.py @@ -969,8 +969,8 @@ class PeptideGenerator: atom.set_atomtype_but_dont_revise_singlets(atom_type) - ### debug - output in PDB format - ### print "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f" % ( n, name, "ALA", ' ', res_num, xyz[0], xyz[1], xyz[2]) + ### debug - output in PDB format + ### print "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f" % ( n, name, "ALA", ' ', res_num, xyz[0], xyz[1], xyz[2]) self.prev_psi = psi # Remember previous psi angle. diff --git a/cad/src/simulation/runSim.py b/cad/src/simulation/runSim.py index 8292d6cbd..c6847aa36 100755 --- a/cad/src/simulation/runSim.py +++ b/cad/src/simulation/runSim.py @@ -525,7 +525,7 @@ class SimRunner: os.mkdir(hdf5DataStoreDir) sleep(1) # Give GMX/HDF5 a chance to write basic info - + # Determine the GMX process id (pid) for passing to nv1. # # (Py)QProcess.pid() doesn't return anything useable @@ -560,7 +560,7 @@ class SimRunner: all_atoms = {} self.part.writemmpfile(inputFileName, add_atomids_to_dict = all_atoms) - + # Write a file that maps the ids of the atoms actually # used for simulation to the atom ids of the complete # structure stored in the MMP file above. @@ -1039,7 +1039,7 @@ class SimRunner: else: electrostaticFlag = self.getElectrostaticPrefValueForMinimize() -## electrostaticArg.append(str(electrostaticFlag)) +## electrostaticArg.append(str(electrostaticFlag)) electrostaticArg += str(electrostaticFlag) #bruce 070601 bugfix if (self.useGromacs): @@ -1068,9 +1068,9 @@ class SimRunner: # THE TIMESTEP ARGUMENT IS MISSING ON PURPOSE. # The timestep argument "-s + (movie.timestep)" is not supported for Alpha. #SIMOPT - electrostaticArg = '--enable-electrostatic=' + electrostaticArg = '--enable-electrostatic=' electrostaticFlag = self.getElectrostaticPrefValueForDynamics() -## electrostaticArg.append(str(electrostaticFlag)) +## electrostaticArg.append(str(electrostaticFlag)) electrostaticArg += str(electrostaticFlag) #bruce 070601 bugfix args = [program, @@ -1129,7 +1129,7 @@ class SimRunner: simopts.EnableElectrostatic = self.getElectrostaticPrefValueForDynamics() if mflag: self.set_minimize_threshhold_prefs(simopts) - if self.cmd_type == 'Adjust' or self.cmd_type == 'Adjust Atoms': + if self.cmd_type == 'Adjust' or self.cmd_type == 'Adjust Atoms': simopts.EnableElectrostatic = self.getElectrostaticPrefValueForAdjust() simopts.NeighborSearching = 0 else: @@ -1163,7 +1163,7 @@ class SimRunner: if self.useGromacs and env.prefs[electrostaticsForDnaDuringAdjust_prefs_key]: val = 1 else: - val = 0 + val = 0 return val def getElectrostaticPrefValueForMinimize(self): @@ -1173,14 +1173,14 @@ class SimRunner: if self.useGromacs and env.prefs[electrostaticsForDnaDuringMinimize_prefs_key]: val = 1 else: - val = 0 + val = 0 return val def getNeighborSearchingPrefValue(self): if env.prefs[neighborSearchingInGromacs_prefs_key]: val = 1 else: - val = 0 + val = 0 return val @@ -1191,7 +1191,7 @@ class SimRunner: if env.prefs[electrostaticsForDnaDuringDynamics_prefs_key]: val = 1 else: - val = 0 + val = 0 return val def set_minimize_threshhold_prefs(self, simopts): #bruce 060628, revised 060705 diff --git a/cad/tests/nanotube.py b/cad/tests/nanotube.py index 7c32fbe00..76452cf56 100755 --- a/cad/tests/nanotube.py +++ b/cad/tests/nanotube.py @@ -186,9 +186,9 @@ end molecular machine part Untitled outf.close() os.system("rasmol -xyz " + filename) def test(self): - mindist = None - maxdist = None - for a, b in self.bonds: + mindist = None + maxdist = None + for a, b in self.bonds: a, b = self.atoms[a-1], self.atoms[b-1] dist = ((a.x - b.x) ** 2 + (a.y - b.y) ** 2 + diff --git a/sim/src/experimental/units.py b/sim/src/experimental/units.py index b1722e89a..e85f349f7 100755 --- a/sim/src/experimental/units.py +++ b/sim/src/experimental/units.py @@ -24,40 +24,40 @@ class UnitsMismatch(Exception): class Quantity: def __init__(self,stuff,units=None): - if units == None: - stuff = stuff.copy() - c = stuff[coeff] - del stuff[coeff] - self.stuff = stuff - else: - c = 1. * stuff - self.stuff = units.copy() - for k in self.stuff.keys(): - if self.stuff[k] == 0: - del self.stuff[k] - self.stuff[coeff] = c + if units == None: + stuff = stuff.copy() + c = stuff[coeff] + del stuff[coeff] + self.stuff = stuff + else: + c = 1. * stuff + self.stuff = units.copy() + for k in self.stuff.keys(): + if self.stuff[k] == 0: + del self.stuff[k] + self.stuff[coeff] = c def __repr__(self): - str = '<%g' % self.stuff[coeff] - for k in self.stuff.keys(): - if k != coeff: - str = str + ' ' + k - if self.stuff[k] != 1: - str = str + '^' + `self.stuff[k]` - return str + '>' + str = '<%g' % self.stuff[coeff] + for k in self.stuff.keys(): + if k != coeff: + str = str + ' ' + k + if self.stuff[k] != 1: + str = str + '^' + `self.stuff[k]` + return str + '>' def __add__(self, other): - self.testUnitsMatch(other) - stuff = self.stuff.copy() - stuff[coeff] += other.stuff[coeff] - return Quantity(stuff) + self.testUnitsMatch(other) + stuff = self.stuff.copy() + stuff[coeff] += other.stuff[coeff] + return Quantity(stuff) def __neg__(self): - stuff = self.stuff.copy() - stuff[coeff] = -stuff[coeff] - return Quantity(stuff) + stuff = self.stuff.copy() + stuff[coeff] = -stuff[coeff] + return Quantity(stuff) def __sub__(self, other): return self + (-other) def __cmp__(self, other): - self.testUnitsMatch(other) - return cmp(self.stuff[coeff], other.stuff[coeff]) + self.testUnitsMatch(other) + return cmp(self.stuff[coeff], other.stuff[coeff]) def __mul__(self, other): if type(other) in (types.IntType, types.FloatType, types.ComplexType): stuff = self.stuff.copy() @@ -97,12 +97,12 @@ class Quantity: def unitsMatch(self, other): if not isinstance(other, Quantity): return False - otherkeys = other.stuff.keys() - for k in self.stuff.keys(): - if k not in otherkeys: - return False - if k != coeff and self.stuff[k] != other.stuff[k]: - return False + otherkeys = other.stuff.keys() + for k in self.stuff.keys(): + if k not in otherkeys: + return False + if k != coeff and self.stuff[k] != other.stuff[k]: + return False return True def testUnitsMatch(self, other): if not self.unitsMatch(other): |