From 2861fd9f0daeb36fc5e2da3ad73ce8a6702af40c Mon Sep 17 00:00:00 2001 From: "t.youngs" Date: Fri, 18 Apr 2008 15:43:46 +0000 Subject: [PATCH] Corrected rendering of drawing ruler, and added display of current bond length when drawing chains. Fixed placement of new atoms when drawing. More fixes to Windows CMake files. --- CMakeLists.txt | 21 ++++++++++----- NSIS.template.in | 9 ++++--- src/base/prefs.cpp | 2 +- src/gui/icons/uninstall.ico | Bin 5438 -> 15934 bytes src/model/view.cpp | 10 ++++--- src/render/extra.cpp | 52 +++++++++++++++++++++--------------- 6 files changed, 58 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf03ffff..629f36ec7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,10 +98,9 @@ Find_File(qtcore QtCore4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) Find_File(qtsvg QtSvg4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) Find_File(qtxml QtXml4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) Find_File(qsvg qsvg4.dll PATHS ${QT_PLUGINS_DIR}/iconengines NO_DEFAULT_PATH) -install(FILES ${qtgui} ${qtgl} ${qtcore} ${Rline} ${HRline} ${qtsvg} ${qtxml} +install(FILES ${qtgui} ${qtgl} ${qtcore} ${Rline} ${HRline} ${qtsvg} ${qtxml} ${CMAKE_CURRENT_SOURCE_DIR}/src/gui/icons/aten.ico DESTINATION bin ) -message("tt: ${QT_PLUGINS_DIR} ${qsvg}") install(FILES ${qsvg} DESTINATION bin/iconengines ) @@ -133,19 +132,25 @@ SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) SET(CPACK_PACKAGE_INSTALL_DIRECTORY "aten${VERSION_MAJOR}.${VERSION_MINOR}") IF(WIN32) + SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Aten-${VERSION_MAJOR}.${VERSION_MINOR}") # There is a bug in NSI that does not handle full unix paths properly. Make # sure there is at least one set of four (4) backlasshes. set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/gui/icons\\\\aten.ico") set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/gui/icons\\\\uninstall.ico") SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/gui/icons\\\\aten.bmp") - SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\aten.exe") + SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\aten.ico") SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} Aten") SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.projectaten.org") SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.projectaten.org") - SET(CPACK_NSIS_CONTACT "t.youngs@qub.ac.uk") - SET(CPACK_NSIS_MODIFY_PATH ON) + SET(CPACK_NSIS_CONTACT "tris@projectaten.org") + SET(CPACK_NSIS_MODIFY_PATH ON) SET(CPACK_PACKAGE_EXECUTABLES "aten" "aten") - set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\aten.lnk\\\" \\\"$INSTDIR\\\\bin\\\\aten.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\aten.ico\\\" + StrCmp $INSTALL_DESKTOP \\\"1\\\" 0 +2 + CreateShortCut \\\"$DESKTOP\\\\aten.lnk\\\" \\\"$INSTDIR\\\\bin\\\\aten.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\aten.ico\\\" +" + ) +set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " Push \\\"ATENDATA\\\" Push \\\"$INSTDIR\\\\share\\\\aten\\\" Call WriteEnvStr @@ -153,7 +158,9 @@ IF(WIN32) ) set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " Push \\\"ATENDATA\\\" - Call un.DeleteEnvStr + Call un.DeleteEnvStr + StrCmp $INSTALL_DESKTOP \\\"1\\\" 0 +2 + Delete \\\"$DESKTOP\\\\aten.lnk\\\" " ) Endif(WIN32) diff --git a/NSIS.template.in b/NSIS.template.in index a89f718e3..23311476a 100644 --- a/NSIS.template.in +++ b/NSIS.template.in @@ -73,12 +73,13 @@ Function .onInit ;Get installation folder from registry if available done: - StrCmp $SV_ALLUSERS "AllUsers" 0 +2 - StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + StrCmp $SV_ALLUSERS "AllUsers" 0 +3 + StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + !define ALL_USERS StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" - + noOptionsPage: FunctionEnd @@ -582,7 +583,7 @@ Section "Installer Section" InstSection ;Create shortcuts CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" -@CPACK_NSIS_CREATE_ICONS@ +@CPACK_NSIS_CREATE_ICONS@ @CPACK_NSIS_CREATE_ICONS_EXTRA@ CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" diff --git a/src/base/prefs.cpp b/src/base/prefs.cpp index 93fb4ec2d..9b0882809 100644 --- a/src/base/prefs.cpp +++ b/src/base/prefs.cpp @@ -177,7 +177,7 @@ Prefs::Prefs() // Build showGuide_ = FALSE; bondTolerance_ = 1.1; - drawDepth_ = 0.0; + drawDepth_ = 10.0; guideSpacing_ = 1.0; guideTicks_ = 5; guideExtent_ = 10; diff --git a/src/gui/icons/uninstall.ico b/src/gui/icons/uninstall.ico index af48381c9ea94ddb47e1090c44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.cpp +++ b/src/model/view.cpp @@ -389,17 +389,21 @@ Vec3 Model::guideToModel(double sx, double sy) dbgBegin(Debug::Calls,"Model::guideToModel"); static Vec4 guidepoint; static Vec3 newpoint; + static Mat4 rotmat; double radius, depth; - depth = prefs.drawDepth(); + depth = -rCamera_.z - prefs.drawDepth(); // First, project a point at the guide z-position into screen coordinates to get the guide 'yardstick' - newpoint.set(0.0,0.0,depth); + newpoint.set(rCamera_.x, rCamera_.y, depth); + rotmat = rotationMatrix_; + rotmat.invert(); + newpoint *= rotmat; guidepoint = worldToScreen(newpoint); radius = guidepoint.w; // Now, calculate the position of the clicked point on the guide newpoint.x = sx - (gui.mainView.width() / 2.0 ); newpoint.y = (gui.mainView.height() - sy) - (gui.mainView.height() / 2.0 ); newpoint /= radius; - newpoint.z = depth + rCamera_.z; + newpoint.z = -prefs.drawDepth(); // Convert this world coordinate into model coordinates by multiplying by the inverse of the PM matrix. newpoint *= viewMatrixInverse_; // Also need to account for periodic systems (which are translated so the cell midpoint is centred in the screen) by adding the cell's centre coordinate diff --git a/src/render/extra.cpp b/src/render/extra.cpp index b329d611d..b4f238b46 100644 --- a/src/render/extra.cpp +++ b/src/render/extra.cpp @@ -25,13 +25,17 @@ #include "methods/mc.h" #include "gui/canvas.h" +// Local variables +double editChainDistance = 0.0; + // Render other 3D objects void Canvas::renderExtra3d() { dbgBegin(Debug::Calls,"Canvas::renderExtra3d"); // Draw on 3D embellishments for active modes static double radius; - static Vec3 r, mouse; + static char s[64]; + static Vec3 r, mouse, textpos; static Vec3 tempv; static Atom *i; // Draw on the selection highlights (for atoms in canvas.subsel) @@ -41,16 +45,15 @@ void Canvas::renderExtra3d() { // Draw on the bounding sphere of a radial selection case (Canvas::SelectRadialAction): - i = atomHover_; - if (i == NULL) break; + if (atomHover_ == NULL) break; // Work out the radius of the sphere tempv = rMouseDown_ - rMouseUp_; radius = tempv.x * tempv.y; - radius /= i->screenRadius(); + radius /= atomHover_->screenRadius(); // Convert the pixel radius into model coordinate radius. We will have the selection 'hotspot' // radius of the atom from its screen projection, which itself depends on the drawing style... - radius *= prefs.screenRadius(i); - r = i->rWorld(); + radius *= prefs.screenRadius(atomHover_); + r = atomHover_->rWorld(); glPushMatrix(); glTranslatef(r.x,r.y,r.z); glScalef(radius,radius,radius); @@ -65,6 +68,7 @@ void Canvas::renderExtra3d() i = displayModel_->atomOnScreen(rMouseLast_.x, rMouseLast_.y); if (i == NULL) mouse = displayModel_->guideToModel(rMouseLast_); else mouse = i->r(); + textpos = mouse; mouse -= r; glPushMatrix(); glTranslated(r.x,r.y,r.z); @@ -95,6 +99,9 @@ void Canvas::renderExtra3d() } } glPopMatrix(); + // Draw text showing distance + sprintf(s," l = %f A",mouse.magnitude()); + glText(textpos,s); break; } dbgEnd(Debug::Calls,"Canvas::renderExtra3d"); @@ -105,7 +112,7 @@ void Canvas::renderExtra2d() { dbgBegin(Debug::Calls,"Canvas::renderExtra2d"); // Draw on any 2D objects, e.g. selection boxes, labels etc. - static int n, i; + static int n, i, skip; static double dx, dy, halfw; // First set up a 2D drawing area... glMatrixMode(GL_PROJECTION); // Swap to projection matrix... @@ -144,30 +151,33 @@ void Canvas::renderExtra2d() dx = 1.0 / drawPixelWidth_; halfw = width_ / 2.0; i = int( halfw / dx); - if (i < 2) break; + //if (i < 2) break; + skip = 1; + while ( (i/skip) > 5) + { + skip += (skip == 1 ? 4 : 5); + } glBegin(GL_LINES); - for (n = -i; n <= i; n++) + for (n = -i; n <= i; n ++) { - glVertex2d(halfw + n*dx, 10); + if ((n%skip) != 0) continue; glVertex2d(halfw + n*dx, 20); - glVertex2d(halfw + (n+0.5)*dx, 10); - glVertex2d(halfw + (n+0.5)*dx, 15); + glVertex2d(halfw + n*dx, 10); + if (n != i) glVertex2d(halfw + (n+0.5*skip)*dx, 15); + if (n != i) glVertex2d(halfw + (n+0.5*skip)*dx, 10); } glVertex2d(halfw - i*dx, 11); glVertex2d(halfw + i*dx, 11); glEnd(); - for (n = -i; n < 0; n++) glText(halfw + n*dx - 8, 1, itoa(n)); - for (n = 0; n <= i; n++) glText(halfw + n*dx - 3, 1, itoa(n)); + for (n = -i; n <= i; n++) + { + if ((n%skip) != 0) continue; + glText(halfw + n*dx - (n < 0 ? 8 : 3), height_, itoa(n)); + } break; } - // If the mouse is hovering over an atom, draw a circle around it... - if (atomHover_ != NULL) - { - Vec3 hoverpos = atomHover_->rScreen(); - circlePrimitive(hoverpos.x,hoverpos.y,atomHover_->screenRadius()); - } // Add text - //text(1.0,h-12.0,displayModel_->name()); + //glText(1.0,height_-12.0,displayModel_->name()); // Draw on colour scale if necessary if (prefs.colourScheme() != Prefs::ElementScheme) {