Skip to content

Commit

Permalink
Overhaul to rendering engine. Moved RenderPrimitives to separate file…
Browse files Browse the repository at this point in the history
…s (engine_primitives.h|cpp). Made an external instantiation of RenderEngine, rather than it being owned by TCanvas. Moved main scene rendering code from TCanvas to RenderEngine. Added default use of QGLPixelBuffer for offscreen rendering. Removed references to stored Model pixel data throughout, since it was no longer used. Moved VBO check and setup code to RenderEngine constructor. Removed self-handling of QGLFormat. Renamed Prefs::useFrameBuffer_ to Prefs::usePixelBuffers_. Removed Prefs::useNiceText_ option since it is no longer valid. Added separate primitive lists for line objects (renamed from stickLines_ etc.) to make handling easier. Fragment rendering now is filtered into the GuiObject (or NormalGuiLineObject and SelectedGuiLineObject) lists.
  • Loading branch information
trisyoungs committed Jul 15, 2012
1 parent 9b65cb1 commit 15138ed
Show file tree
Hide file tree
Showing 47 changed files with 1,550 additions and 1,532 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(Aten)
set(DESCRIPTION "Aten - Atomic configuration builder and editor")
set(AUTHOR "Tristan Youngs")
set(VERSION_MAJOR "1")
set(VERSION_MINOR "828")
set(VERSION_MINOR "829")
set(VERSION_PATCH "1")

set(CMAKE_BUILD_TYPE "Release")
Expand Down
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<h1>Known Bugs</h1>

<ul>
<li>When manipulating an atom selection, undoing afterwards does not undo Fold</li>
<li>UnitCell:mim(Atom*,Vec3) returns incorrect position - where is it used?</li>
<li>Glyph list not updated on model load.</li>
<li>Model not updated when changing glyph selection?</li>
<li>Image saving is slow - code undergoing rewrite.</li>
<li>Running from CLI with unset DISPLAY variable causes segfault.</li>
</ul>

Expand Down
4 changes: 2 additions & 2 deletions aten.kdev4
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[Project]
Manager=KDevCustomMakeManager
Name=aten
Manager=KDevCMakeManager
Name=aten-pixmap
2 changes: 1 addition & 1 deletion aten.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Name, brief description, and version
Summary: Aten - Atomic configuration builder and editor
Name: %{shortname}
Version: 1.828
Version: 1.829
Release: 1
License: GPL
%define fullname %{name}-%{version}
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
AC_PREREQ(2.60)

# Set program name, version, bug-address and source directory
m4_define([ATEN_VERSION],[1.828])
m4_define([ATEN_VERSION],[1.829])
AC_INIT(aten,ATEN_VERSION,[email protected])
AC_CONFIG_SRCDIR([src/main.cpp])

Expand Down
15 changes: 5 additions & 10 deletions data/filters/gromacs
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,13 @@ filter(type="exportexpression",name="Gromacs .top File", extension="top", glob="
i = p.atoms[n];
i.bit = chgrp;
# All atoms attached to this atom which have only one bond will be part of the same charge group
for (Bond x = i.bonds; x; ++x)
for (Bond bnd = i.bonds; bnd; ++bnd)
{
i.bit = chgrp;
# All atoms attached to this atom which have only one bond will be part of the same charge group
for (Bond x = i.bonds; x; ++x)
{
j = x.partner(i);
if ((j.nBonds != 1) || (j.bit != 0)) continue;
j.bit = chgrp;
}
++chgrp;
j = bnd.partner(i);
if ((j.nBonds != 1) || (j.bit != 0)) continue;
j.bit = chgrp;
}
++chgrp;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions extra/aten.dsc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Format: 1.0
Source: aten
Version: 1.828
Version: 1.829
Binary: aten
Maintainer: Tristan Youngs <[email protected]>
Architecture: any
Build-Depends: debhelper (>= 4.1.16), libqt4-dev | libqt4-core, libqt4-opengl-dev, libreadline5-dev | libreadline-dev, libgl1-mesa-dev, pkgconfig | pkg-config, libncurses5
Files:
4aec60597e330aeae02c1af550c6deab 4293031 aten-1.828.tar.gz
4aec60597e330aeae02c1af550c6deab 4293031 aten-1.829.tar.gz
29 changes: 8 additions & 21 deletions src/classes/prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,13 @@ Prefs::Prefs()
partitionGridSize_.set(50,50,50);

// Rendering Options
useNiceText_ = TRUE;
distanceLabelFormat_ = "%0.3f ";
angleLabelFormat_ = "%0.2f";
chargeLabelFormat_ = "(%0.3f e)";
labelSize_ = 10;
labelSize_ = 1.5;
manualSwapBuffers_ = FALSE;
mouseMoveFilter_ = 10;
useFrameBuffer_ = FALSE;
usePixelBuffers_ = TRUE;
renderDashedAromatics_ = TRUE;
nModelsPerRow_ = 2;
drawHydrogenBonds_ = FALSE;
Expand Down Expand Up @@ -1892,29 +1891,17 @@ const char *Prefs::chargeLabelFormat()
}

// Set the scale of labels in the model
void Prefs::setLabelSize(int size)
void Prefs::setLabelSize(double size)
{
labelSize_ = size;
}

// Return the current label scale
int Prefs::labelSize() const
double Prefs::labelSize() const
{
return labelSize_;
}

// Set whether to use nice text rendering
void Prefs::setUseNiceText(bool b)
{
useNiceText_ = b;
}

// Return whether to use nice text rendering
bool Prefs::useNiceText() const
{
return useNiceText_;
}

// Set manual swapbuffers
void Prefs::setManualSwapBuffers(bool on)
{
Expand All @@ -1928,15 +1915,15 @@ bool Prefs::manualSwapBuffers() const
}

// Return whether manual buffer swapping is enabled
bool Prefs::useFrameBuffer() const
bool Prefs::usePixelBuffers() const
{
return useFrameBuffer_;
return usePixelBuffers_;
}

// Set manual swapbuffers
void Prefs::setUseFrameBuffer(bool on)
void Prefs::setUsePixelBuffers(bool on)
{
useFrameBuffer_ = on;
usePixelBuffers_ = on;
}

// Return whether to use solid or dashed circles for aromatic ring rendering
Expand Down
26 changes: 10 additions & 16 deletions src/classes/prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,12 @@ class Prefs
Dnchar angleLabelFormat_;
// C-style format for charge label values
Dnchar chargeLabelFormat_;
// Pointsize for labels
int labelSize_;
// Use QGlWidget::renderText (FALSE) or QPainter::drawText (TRUE) for labels etc.
bool useNiceText_;
// Relative size for text labels, in percentage of view height
double labelSize_;
// Flag to manually perform swapBuffers
bool manualSwapBuffers_;
// Flag to use framebuffer for image saving rather than the renderPixmap() method
bool useFrameBuffer_;
// Flag to use pixelbuffers for image saving rather than the renderPixmap() method
bool usePixelBuffers_;
// Whether to use solid or dashed circles for aromatic ring rendering
bool renderDashedAromatics_;
// Mouse move event filter rate
Expand All @@ -341,21 +339,17 @@ class Prefs
// Return C-style format for charge label values
const char *chargeLabelFormat();
// Set the pointsize of labels in the model
void setLabelSize(int size);
void setLabelSize(double size);
// Return the current label pointsize
int labelSize() const;
// Set whether to use nice text rendering
void setUseNiceText(bool b);
// Return whether to use nice text rendering
bool useNiceText() const;
double labelSize() const;
// Set manual swapbuffers
void setManualSwapBuffers(bool on);
// Return whether manual buffer swapping is enabled
bool manualSwapBuffers() const;
// Set usage of framebuffer in image saving
void setUseFrameBuffer(bool on);
// Return whether to use framebuffer for image saving
bool useFrameBuffer() const;
// Set usage of pixelbuffers in image saving
void setUsePixelBuffers(bool on);
// Return whether to use pixelbuffers for image saving
bool usePixelBuffers() const;
// Return whether to use solid or dashed circles for aromatic ring rendering
bool renderDashedAromatics();
// Set whether to use solid or dashed circles for aromatic ring rendering
Expand Down
27 changes: 9 additions & 18 deletions src/command/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
int movieSetup(bool pre, int height)
{
static bool framemodel = prefs.frameCurrentModel(), frameview = prefs.frameWholeView(), viewglobe = prefs.viewRotationGlobe();
static int oldlabelsize = prefs.labelSize();
if (pre)
{
// Check that defined encoder exe exists
Expand Down Expand Up @@ -65,21 +64,13 @@ int movieSetup(bool pre, int height)
} while (fileExists(basename));
msg.print("First temporary basename for movie images is '%s'.\n", basename.get());

// Temporarily adjust label size...
oldlabelsize = prefs.labelSize();
int newlabelsize = int (oldlabelsize*( (1.0*height / gui.mainCanvas()->height()) ));
prefs.setLabelSize(newlabelsize);

return runid;
}
else
{
prefs.setFrameCurrentModel(framemodel);
prefs.setFrameWholeView(frameview);
prefs.setViewRotationGlobe(viewglobe);

// Restore label size
prefs.setLabelSize(oldlabelsize);
}
}

Expand Down Expand Up @@ -172,8 +163,8 @@ bool Command::function_SaveBitmap(CommandNode *c, Bundle &obj, ReturnValue &rv)
if (obj.notifyNull(Bundle::ModelPointer)) return FALSE;

// Convert format to bitmap_format
GuiQt::BitmapFormat bf = GuiQt::bitmapFormat(c->argc(0));
if (bf == GuiQt::nBitmapFormats)
RenderEngine::BitmapFormat bf = RenderEngine::bitmapFormat(c->argc(0));
if (bf == RenderEngine::nBitmapFormats)
{
msg.print("Unrecognised bitmap format.\n");
return FALSE;
Expand Down Expand Up @@ -202,9 +193,9 @@ bool Command::function_SaveBitmap(CommandNode *c, Bundle &obj, ReturnValue &rv)
msg.print("Maximum number of frames for image redirect reached. Raising error...\n");
result = FALSE;
}
else result = gui.saveImage(filename, bf, width, height, quality);
else result = engine().saveImage(filename, bf, width, height, quality);
}
else result = gui.saveImage(c->argc(1), bf, width, height, quality);
else result = engine().saveImage(c->argc(1), bf, width, height, quality);

prefs.setViewRotationGlobe(viewglobe);
return result;
Expand Down Expand Up @@ -235,7 +226,7 @@ bool Command::function_SaveMovie(CommandNode *c, Bundle &obj, ReturnValue &rv)

// Check initial movie 'setup'
int runid = movieSetup(TRUE, height);
if (runid == -1 ) return FALSE;
if (runid == -1) return FALSE;

// Save all trajectory frame images
QPixmap pixmap;
Expand All @@ -249,9 +240,9 @@ bool Command::function_SaveMovie(CommandNode *c, Bundle &obj, ReturnValue &rv)
{
obj.m->seekTrajectoryFrame(n, TRUE);
basename.sprintf("%s%caten-movie-%i-%i-%09i.png", prefs.tempDir(), PATHSEP, gui.pid(), runid, n);
gui.mainCanvas()->postRedisplay(TRUE);
// gui.mainCanvas()->postRedisplay();

pixmap = gui.mainCanvas()->generateImage(width, height, TRUE);
pixmap = engine().renderSceneImage(RenderEngine::HighQuality, width, height);
pixmap.save(basename.get(), "png", -1);
files << basename.get();

Expand Down Expand Up @@ -321,9 +312,9 @@ bool Command::function_SaveVibrationMovie(CommandNode *c, Bundle &obj, ReturnVal
obj.rs()->setVibrationFrameIndex(n);

basename.sprintf("%s%caten-movie-%i-%i-%09i.png", prefs.tempDir(), PATHSEP, gui.pid(), runid, n);
gui.mainCanvas()->postRedisplay(TRUE);
// gui.mainCanvas()->postRedisplay();

pixmap = gui.mainCanvas()->generateImage(width, height, TRUE);
pixmap = engine().renderSceneImage(RenderEngine::HighQuality, width, height);
pixmap.save(basename.get(), "png", -1);

if (!progress.update(progid,n))
Expand Down
20 changes: 10 additions & 10 deletions src/gui/contextmenu_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Atom *target = NULL;
void GuiQt::updateContextMenu()
{
msg.enter("GuiQt::updateContextMenu");
Model *viewTarget = gui.mainCanvas()->displayModel();
Model *viewTarget = aten.currentModel();
// Enable bond, angle, and torsion editing
int nselected = (viewTarget == NULL ? 0 : viewTarget->nSelected());
mainWindow_->ui.actionSetBondLength->setEnabled(FALSE);
Expand Down Expand Up @@ -65,7 +65,7 @@ void GuiQt::callContextMenu(Atom *undermouse, int x, int y)
// If the atom under the mouse is selected, just run the popup. If it is not selected, deselect everything else and select it
QPoint pos(x,y);
// printf("AtomPopup: model %li, undermouse = %li, nselected = %i\n", viewTarget, target, viewTarget->nSelected());
Model *viewTarget = gui.mainCanvas()->displayModel();
Model *viewTarget = aten.currentModel();
if (!target->isSelected())
{
viewTarget->beginUndoState("Select atom (Context Menu)");
Expand All @@ -86,7 +86,7 @@ void GuiQt::callContextMenu(Atom *undermouse, int x, int y)
// Set atom style
void AtenForm::setAtomStyle(Atom::DrawStyle ds)
{
if ((target == NULL) || (gui.mainCanvas()->displayModel()->nSelected() > 1)) CommandNode::run(Command::AtomStyle, "c", Atom::drawStyle(ds));
if ((target == NULL) || (aten.currentModel()->nSelected() > 1)) CommandNode::run(Command::AtomStyle, "c", Atom::drawStyle(ds));
else CommandNode::run(Command::AtomStyle, "ci", Atom::drawStyle(ds), target->id()+1);
target = NULL;
}
Expand Down Expand Up @@ -118,7 +118,7 @@ void AtenForm::on_actionAtomStyleScaled_triggered(bool checked)
// Set atom labels
void AtenForm::setAtomLabel(Atom::AtomLabel al)
{
if ((target == NULL) || (gui.mainCanvas()->displayModel()->nSelected() > 1)) CommandNode::run(Command::Label, "c", Atom::atomLabel(al));
if ((target == NULL) || (aten.currentModel()->nSelected() > 1)) CommandNode::run(Command::Label, "c", Atom::atomLabel(al));
else CommandNode::run(Command::Label, "ci", Atom::atomLabel(al), target->id()+1);
target = NULL;
gui.mainCanvas()->postRedisplay();
Expand All @@ -128,7 +128,7 @@ void AtenForm::setAtomLabel(Atom::AtomLabel al)
void AtenForm::removeAtomLabels(bool all)
{
if (all) CommandNode::run(Command::ClearLabels, "");
else if ((target == NULL) || (gui.mainCanvas()->displayModel()->nSelected() > 1)) CommandNode::run(Command::RemoveLabels, "");
else if ((target == NULL) || (aten.currentModel()->nSelected() > 1)) CommandNode::run(Command::RemoveLabels, "");
else CommandNode::run(Command::RemoveLabels, "i", target->id()+1);
target = NULL;
gui.mainCanvas()->postRedisplay();
Expand Down Expand Up @@ -236,7 +236,7 @@ void AtenForm::on_actionOrderReorder_triggered(bool checked)
// Set atom hidden
void AtenForm::setAtomHidden(bool hidden)
{
if ((target == NULL) || (gui.mainCanvas()->displayModel()->nSelected() > 1))
if ((target == NULL) || (aten.currentModel()->nSelected() > 1))
{
if (hidden) CommandNode::run(Command::Hide, "");
else CommandNode::run(Command::Show, "");
Expand All @@ -261,14 +261,14 @@ void AtenForm::on_actionAtomProbe_triggered(bool checked)

void AtenForm::on_actionAtomFixPosition_triggered(bool checked)
{
if ((target == NULL) || (gui.mainCanvas()->displayModel()->nSelected() > 1)) CommandNode::run(Command::Fix, "");
if ((target == NULL) || (aten.currentModel()->nSelected() > 1)) CommandNode::run(Command::Fix, "");
else CommandNode::run(Command::Fix, "i", target->id()+1);
gui.mainCanvas()->postRedisplay();
}

void AtenForm::on_actionAtomFreePosition_triggered(bool checked)
{
if ((target == NULL) || (gui.mainCanvas()->displayModel()->nSelected() > 1)) CommandNode::run(Command::Free, "");
if ((target == NULL) || (aten.currentModel()->nSelected() > 1)) CommandNode::run(Command::Free, "");
else CommandNode::run(Command::Free, "i", target->id()+1);
gui.mainCanvas()->postRedisplay();
}
Expand Down Expand Up @@ -296,7 +296,7 @@ void AtenForm::on_actionCentreAtOrigin_triggered(bool checked)

void AtenForm::on_actionCreateFragment_triggered(bool checked)
{
Model *viewTarget = gui.mainCanvas()->displayModel();
Model *viewTarget = aten.currentModel();
aten.addFragmentFromSelection(viewTarget, "Selections");
gui.fragmentsWidget->refresh();
}
Expand All @@ -322,7 +322,7 @@ void AtenForm::createGlyph()
// Create glyph in model
CommandNode::run(Command::NewGlyph, "c", Glyph::glyphType(gt));
// Set data to atom selection
Model *viewTarget = gui.mainCanvas()->displayModel();
Model *viewTarget = aten.currentModel();
n = 1;
for (Refitem<Atom,int> *ri = viewTarget->selection(); ri != NULL; ri = ri->next)
{
Expand Down
Loading

0 comments on commit 15138ed

Please sign in to comment.