Skip to content

Commit

Permalink
Corrected rendering of drawing ruler, and added display of current bo…
Browse files Browse the repository at this point in the history
…nd length when drawing chains. Fixed placement of new atoms when drawing. More fixes to Windows CMake files.
  • Loading branch information
t.youngs committed Apr 18, 2008
1 parent 9bcc19e commit 2861fd9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 36 deletions.
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -133,27 +132,35 @@ 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 "[email protected]")
SET(CPACK_NSIS_MODIFY_PATH ON)
SET(CPACK_NSIS_CONTACT "[email protected]")
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
"
)
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)
Expand Down
9 changes: 5 additions & 4 deletions NSIS.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/base/prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file modified src/gui/icons/uninstall.ico
Binary file not shown.
10 changes: 7 additions & 3 deletions src/model/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,21 @@ Vec3<double> Model::guideToModel(double sx, double sy)
dbgBegin(Debug::Calls,"Model::guideToModel");
static Vec4<double> guidepoint;
static Vec3<double> newpoint;
static Mat4<double> 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
Expand Down
52 changes: 31 additions & 21 deletions src/render/extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> r, mouse;
static char s[64];
static Vec3<double> r, mouse, textpos;
static Vec3<double> tempv;
static Atom *i;
// Draw on the selection highlights (for atoms in canvas.subsel)
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand All @@ -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...
Expand Down Expand Up @@ -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<double> 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)
{
Expand Down

0 comments on commit 2861fd9

Please sign in to comment.