From 82ac76703960b5e3bc082e427175d16535c124c1 Mon Sep 17 00:00:00 2001 From: "t.youngs" Date: Thu, 27 Mar 2008 14:14:58 +0000 Subject: [PATCH] Reformatted PrefsData (now Prefs) enums and associated methods. Removed QS_* enum (charge source) since it wasn't really doing anything. Changed spotlight component enums (SL_*) to represent generic GL lighting components. --- src/base/cli.cpp | 34 +-- src/base/elements.cpp | 16 +- src/base/elements.h | 2 +- src/base/generator.cpp | 2 +- src/base/master.cpp | 94 +++--- src/base/master.h | 13 +- src/base/prefs.cpp | 551 ++++++++++++++++++----------------- src/base/prefs.h | 167 +++++------ src/base/spacegroup.cpp | 2 +- src/classes/atomtype.cpp | 2 +- src/classes/energystore.cpp | 6 +- src/classes/forcefield.cpp | 2 +- src/classes/forcefield.h | 2 +- src/command/atom.cpp | 2 +- src/command/bonds.cpp | 2 +- src/command/cell.cpp | 4 +- src/command/charge.cpp | 2 +- src/command/commands.h | 2 +- src/command/functions.cpp | 2 +- src/command/prefs.cpp | 32 +- src/command/select.cpp | 2 +- src/command/system.cpp | 6 +- src/command/transform.cpp | 2 +- src/energy/ewald.cpp | 8 +- src/gui/canvas.cpp | 18 +- src/gui/canvas.h | 12 +- src/gui/disorder_funcs.cpp | 2 +- src/gui/gui.cpp | 4 +- src/gui/input.cpp | 72 +++-- src/gui/mainwindow_funcs.cpp | 6 +- src/gui/prefs.h | 4 +- src/gui/prefs_funcs.cpp | 66 ++--- src/gui/tcanvas_funcs.cpp | 20 +- src/main.cpp | 18 +- src/methods/mc.cpp | 3 +- src/model/cell.cpp | 2 +- src/model/model.cpp | 81 +++-- src/model/model.h | 4 +- src/parse/filter.cpp | 12 +- src/parse/filter.h | 2 +- src/parse/forcefield.cpp | 10 +- src/parse/probe.cpp | 10 +- src/render/atoms.cpp | 12 +- src/render/extra.cpp | 4 +- src/render/gl2ps.cpp | 24 +- src/render/gl2ps.h | 12 +- src/render/model.cpp | 8 +- src/render/render.cpp | 20 +- src/render/surface.cpp | 2 +- 49 files changed, 676 insertions(+), 709 deletions(-) diff --git a/src/base/cli.cpp b/src/base/cli.cpp index b9faaaaaf..44431cb61 100644 --- a/src/base/cli.cpp +++ b/src/base/cli.cpp @@ -84,7 +84,7 @@ Cli cliSwitches[] = { }; // Parse debug options -void MasterData::debugCli(int argc, char *argv[]) +void Master::debugCli(int argc, char *argv[]) { int n, o; bool isShort, match; @@ -154,13 +154,13 @@ void MasterData::debugCli(int argc, char *argv[]) } // Parse all options -int MasterData::parseCli(int argc, char *argv[]) +int Master::parseCli(int argc, char *argv[]) { int argn, opt, ntried = 0, n, el; bool isShort, match; char *arg; CommandList *cl; - ZmapType zm; + Prefs::ZmapType zm; Refitem *ri; Filter *f, *modelfilter = NULL; // Cycle over program arguments and available CLI options (skip [0] which is the binary run) @@ -194,7 +194,7 @@ int MasterData::parseCli(int argc, char *argv[]) break; // Force bonding calculation of atoms on load case (Cli::BondSwitch): - prefs.setBondOnLoad(PS_YES); + prefs.setBondOnLoad(Prefs::SwitchOn); break; // Set trajectory cache limit case (Cli::CacheSwitch): @@ -202,12 +202,12 @@ int MasterData::parseCli(int argc, char *argv[]) break; // Force model centering on load (for non-periodic systems) case (Cli::CentreSwitch): - prefs.setCentreOnLoad(PS_YES); + prefs.setCentreOnLoad(Prefs::SwitchOn); break; // Read script commands from passed string case (Cli::CommandSwitch): cl = master.commands.add(); - if (cl->cacheLine(argv[++argn])) master.setProgramMode(PM_COMMAND); + if (cl->cacheLine(argv[++argn])) master.setProgramMode(Master::CommandMode); else { master.commands.remove(cl); @@ -220,7 +220,7 @@ int MasterData::parseCli(int argc, char *argv[]) break; // Force folding (MIM'ing) of atoms in periodic systems on load case (Cli::FoldSwitch): - prefs.setFoldOnLoad(PS_YES); + prefs.setFoldOnLoad(Prefs::SwitchOn); break; // Set forced model load format case (Cli::FormatSwitch): @@ -240,7 +240,7 @@ int MasterData::parseCli(int argc, char *argv[]) break; // Enter interactive mode case (Cli::InteractiveSwitch): - master.setProgramMode(PM_INTERACTIVE); + master.setProgramMode(Master::InteractiveMode); break; // Set type mappings case (Cli::MapSwitch): @@ -257,28 +257,28 @@ int MasterData::parseCli(int argc, char *argv[]) break; // Prohibit bonding calculation of atoms on load case (Cli::NoBondSwitch): - prefs.setBondOnLoad(PS_NO); + prefs.setBondOnLoad(Prefs::SwitchOff); break; // Prohibit model centering on load (for non-periodic systems) case (Cli::NoCentreSwitch): - prefs.setCentreOnLoad(PS_NO); + prefs.setCentreOnLoad(Prefs::SwitchOff); break; // Prohibit folding (MIM'ing) of atoms in periodic systems on load case (Cli::NoFoldSwitch): - prefs.setFoldOnLoad(PS_NO); + prefs.setFoldOnLoad(Prefs::SwitchOff); break; // Force packing (application of symmetry operators) on load case (Cli::NoPackSwitch): - prefs.setPackOnLoad(PS_NO); + prefs.setPackOnLoad(Prefs::SwitchOff); break; // Prohibit packing (application of symmetry operators) on load case (Cli::PackSwitch): - prefs.setPackOnLoad(PS_YES); + prefs.setPackOnLoad(Prefs::SwitchOn); break; // Cache a script file case (Cli::ScriptSwitch): cl = master.scripts.add(); - if (cl->load(argv[++argn])) master.setProgramMode(PM_COMMAND); + if (cl->load(argv[++argn])) master.setProgramMode(Master::CommandMode); else { master.scripts.remove(cl); @@ -291,8 +291,8 @@ int MasterData::parseCli(int argc, char *argv[]) break; // Set the type of element (Z) mapping to use in name conversion case (Cli::ZmapSwitch): - zm = ZM_from_text(argv[++argn]); - if (zm != ZM_NITEMS) prefs.setZmapType(zm); + zm = Prefs::zmapType(argv[++argn]); + if (zm != Prefs::nZmapTypes) prefs.setZmapType(zm); break; default: printf("Unrecognised command-line option '%s'.\n",argv[argn]); @@ -321,7 +321,7 @@ int MasterData::parseCli(int argc, char *argv[]) } // Usage help -void MasterData::printUsage() const +void Master::printUsage() const { printf("Usage: aten [options] [ ...]\n"); printf("\nProgram Options:\n"); diff --git a/src/base/elements.cpp b/src/base/elements.cpp index 6a907c808..4408d4c7f 100644 --- a/src/base/elements.cpp +++ b/src/base/elements.cpp @@ -426,7 +426,7 @@ int ElementMap::find(const char *query) switch (prefs.zmapType()) { // Automatic determination - case (ZM_AUTO): + case (Prefs::AutoZmap): // First, try pure numeric conversion result = numberToZ(query); if (result != -1) break; @@ -440,25 +440,25 @@ int ElementMap::find(const char *query) result = ffToZ(query); break; // Name search - case (ZM_NAME): + case (Prefs::NameZmap): result = nameToZ(query); break; // Search loaded forcefields for atom names - case (ZM_FORCEFIELD): + case (Prefs::ForcefieldZmap): result = ffToZ(query); // Attempt an alpha conversion if the FF conversion failed if (result == -1) result = alphaToZ(query); break; // Convert based on alpha-part of atom name only - case (ZM_ALPHA): + case (Prefs::AlphaZmap): result = alphaToZ(query); break; // Convert based on first alpha-part of atom name only - case (ZM_FIRSTALPHA): + case (Prefs::FirstAlphaZmap): result = firstAlphaToZ(query); break; // Convert based on numeric part only - case (ZM_NUMERIC): + case (Prefs::NumericZmap): result = numberToZ(query); break; } @@ -467,10 +467,10 @@ int ElementMap::find(const char *query) } // Search for element named 'query' in the list of known elements, using the specified algorithm -int ElementMap::find(const char *query, ZmapType zmt) +int ElementMap::find(const char *query, Prefs::ZmapType zmt) { // Store the old zmapping type, and temporarily set a new one - ZmapType last = prefs.zmapType(); + Prefs::ZmapType last = prefs.zmapType(); prefs.setZmapType(zmt); int result = find(query); prefs.setZmapType(last); diff --git a/src/base/elements.h b/src/base/elements.h index 34d6418e4..5173b75a0 100644 --- a/src/base/elements.h +++ b/src/base/elements.h @@ -78,7 +78,7 @@ class ElementMap // Return atomic number of element in string int find(const char*); // Return atomic number of element in string, specifying algorithm - int find(const char*, ZmapType); + int find(const char*, Prefs::ZmapType); // Return number of defined elements int nElements(); diff --git a/src/base/generator.cpp b/src/base/generator.cpp index 002045842..56ca5c31e 100644 --- a/src/base/generator.cpp +++ b/src/base/generator.cpp @@ -28,7 +28,7 @@ #define FVSX 0.83333333 // Define spacegroup generators in the master -Generator MasterData::generators[] = { +Generator Master::generators[] = { { "x,y,z", Mat3( 1,0,0,0,1,0,0,0,1), Vec3(0 ,0 ,0 ) }, { "-x,-y,-z", Mat3(-1,0,0,0,-1,0,0,0,-1), Vec3(0 ,0 ,0 ) }, { "-x,y,-z", Mat3(-1,0,0,0,1,0,0,0,-1), Vec3(0 ,0 ,0 ) }, diff --git a/src/base/master.cpp b/src/base/master.cpp index a3e0c806b..6f04e5745 100644 --- a/src/base/master.cpp +++ b/src/base/master.cpp @@ -29,16 +29,16 @@ #include "parse/parser.h" #include -MasterData master; +Master master; // Constructor -MasterData::MasterData() +Master::Master() { // Models modelId_ = 0; // Modes - programMode_ = PM_GUI; + programMode_ = Master::GuiMode; // Store pointers to member functions initCommands(); @@ -52,14 +52,14 @@ MasterData::MasterData() } // Destructor -MasterData::~MasterData() +Master::~Master() { clear(); delete userClipboard; } // Clear -void MasterData::clear() +void Master::clear() { models_.clear(); forcefields_.clear(); @@ -73,7 +73,7 @@ void MasterData::clear() */ // Set the active model -void MasterData::setCurrentModel(Model *m) +void Master::setCurrentModel(Model *m) { dbgBegin(Debug::Calls,"master::setCurrentModel"); // Set current.m and tell the mainview canvas to display it @@ -92,43 +92,43 @@ void MasterData::setCurrentModel(Model *m) */ // Return current active model for editing -Model *MasterData::currentModel() const +Model *Master::currentModel() const { return current.m; } // Return first item in the model list -Model *MasterData::models() const +Model *Master::models() const { return models_.first(); } // Return nth item in the model list -Model *MasterData::model(int n) +Model *Master::model(int n) { return models_[n]; } // Return the current model's index in the model list -int MasterData::currentModelIndex() const +int Master::currentModelIndex() const { return models_.indexOf(current.m); } // Return index of specified model -int MasterData::modelIndex(Model *m) const +int Master::modelIndex(Model *m) const { return models_.indexOf(m); } // Return the number of models in the model list -int MasterData::nModels() const +int Master::nModels() const { return models_.nItems(); } // Add model -Model *MasterData::addModel() +Model *Master::addModel() { dbgBegin(Debug::Calls,"master::addModel"); current.m = models_.add(); @@ -141,7 +141,7 @@ Model *MasterData::addModel() } // Remove model -void MasterData::removeModel(Model *xmodel) +void Master::removeModel(Model *xmodel) { // Remove this model from the model_list in the main window dbgBegin(Debug::Calls,"master::removeModel"); @@ -160,7 +160,7 @@ void MasterData::removeModel(Model *xmodel) } // Find model by name -Model *MasterData::findModel(const char *s) const +Model *Master::findModel(const char *s) const { // Search model list for name 's' (script function) dbgBegin(Debug::Calls,"master::findModel"); @@ -175,25 +175,25 @@ Model *MasterData::findModel(const char *s) const */ // Return list of surfaces -Grid *MasterData::grids() const +Grid *Master::grids() const { return grids_.first(); } // Return number of surfaces loaded -int MasterData::nGrids() const +int Master::nGrids() const { return grids_.nItems(); } // Return specified surface -Grid *MasterData::grid(int id) +Grid *Master::grid(int id) { return grids_[id]; } // Add new surface -Grid *MasterData::addGrid() +Grid *Master::addGrid() { dbgBegin(Debug::Calls,"master::addGrid"); current.g = grids_.add(); @@ -204,7 +204,7 @@ Grid *MasterData::addGrid() } // Remove surface -void MasterData::removeGrid(Grid *xgrid) +void Master::removeGrid(Grid *xgrid) { Grid *g; xgrid->next != NULL ? g = xgrid->next : g = xgrid->prev; @@ -219,7 +219,7 @@ void MasterData::removeGrid(Grid *xgrid) */ // Load forcefield -Forcefield *MasterData::loadForcefield(const char *filename) +Forcefield *Master::loadForcefield(const char *filename) { dbgBegin(Debug::Calls,"master::loadForcefield"); Forcefield *newff = forcefields_.add(); @@ -240,7 +240,7 @@ Forcefield *MasterData::loadForcefield(const char *filename) } // Unload forcefield from the master's list -void MasterData::removeForcefield(Forcefield *xff) +void Master::removeForcefield(Forcefield *xff) { dbgBegin(Debug::Calls,"master::removeForcefield"); Forcefield *newff; @@ -256,7 +256,7 @@ void MasterData::removeForcefield(Forcefield *xff) } // Find forcefield by name -Forcefield *MasterData::findForcefield(const char *s) const +Forcefield *Master::findForcefield(const char *s) const { // Search forcefield list for name 's' (script function) dbgBegin(Debug::Calls,"master::findForcefield"); @@ -268,7 +268,7 @@ Forcefield *MasterData::findForcefield(const char *s) const } // Dereference forcefield -void MasterData::dereferenceForcefield(Forcefield *xff) +void Master::dereferenceForcefield(Forcefield *xff) { // Remove references to the forcefield in the models dbgBegin(Debug::Calls,"master::dereferenceForcefield"); @@ -297,7 +297,7 @@ void MasterData::dereferenceForcefield(Forcefield *xff) } // Set the default forcefield -void MasterData::setDefaultForcefield(Forcefield *ff) +void Master::setDefaultForcefield(Forcefield *ff) { defaultForcefield_ = ff; if (defaultForcefield_ == NULL) msg(Debug::None,"Default forcefield has been unset.\n"); @@ -305,43 +305,43 @@ void MasterData::setDefaultForcefield(Forcefield *ff) } // Return the first ff in the list -Forcefield *MasterData::forcefields() const +Forcefield *Master::forcefields() const { return forcefields_.first(); } // Return the number of loaded forcefields -int MasterData::nForcefields() const +int Master::nForcefields() const { return forcefields_.nItems(); } // Set active forcefield -void MasterData::setCurrentForcefield(Forcefield *ff) +void Master::setCurrentForcefield(Forcefield *ff) { current.ff = ff; } // Set active forcefield by ID -void MasterData::setCurrentForcefield(int id) +void Master::setCurrentForcefield(int id) { current.ff = forcefields_[id]; } // Return the active forcefield -Forcefield *MasterData::currentForcefield() const +Forcefield *Master::currentForcefield() const { return current.ff; } // Return ID of current forcefield -int MasterData::currentForcefieldId() const +int Master::currentForcefieldId() const { return forcefields_.indexOf(current.ff); } // Get the current default forcefield -Forcefield *MasterData::defaultForcefield() const +Forcefield *Master::defaultForcefield() const { return defaultForcefield_; } @@ -351,7 +351,7 @@ Forcefield *MasterData::defaultForcefield() const */ // Load filters -bool MasterData::openFilters(const char *path, bool isdatadir) +bool Master::openFilters(const char *path, bool isdatadir) { dbgBegin(Debug::Calls,"master::openFilters"); // Load in model filters @@ -404,7 +404,7 @@ bool MasterData::openFilters(const char *path, bool isdatadir) } // Read commands from filter file -bool MasterData::loadFilter(const char *filename) +bool Master::loadFilter(const char *filename) { dbgBegin(Debug::Calls,"master::loadFilter"); FilterType ft; @@ -412,7 +412,7 @@ bool MasterData::loadFilter(const char *filename) bool foundmain, error; VariableList *vars; int success; - ZmapType zm; + Prefs::ZmapType zm; ifstream filterfile(filename,ios::in); // Pre-read first line to check @@ -450,7 +450,7 @@ bool MasterData::loadFilter(const char *filename) } // Set filter partners -void MasterData::partnerFilters() +void Master::partnerFilters() { dbgBegin(Debug::Calls,"master::partnerFilters"); // Loop through import filters and search / set export partners @@ -504,7 +504,7 @@ void MasterData::partnerFilters() } // Find filter with specified type and nickname -Filter *MasterData::findFilter(FilterType ft, const char *nickname) const +Filter *Master::findFilter(FilterType ft, const char *nickname) const { dbgBegin(Debug::Calls,"master::findFilter"); Filter *result; @@ -516,7 +516,7 @@ Filter *MasterData::findFilter(FilterType ft, const char *nickname) const } // Return first filter in list (of a given type) -Filter *MasterData::filters(FilterType ft) const +Filter *Master::filters(FilterType ft) const { return filters_[ft].first(); } @@ -526,27 +526,27 @@ Filter *MasterData::filters(FilterType ft) const */ // Initialise a progress indicator -void MasterData::initialiseProgress(const char *jobtitle, int totalsteps) +void Master::initialiseProgress(const char *jobtitle, int totalsteps) { gui.progressCreate(jobtitle, totalsteps); } // Update the number of steps (returns if the dialog was canceled) -bool MasterData::updateProgress(int currentstep) +bool Master::updateProgress(int currentstep) { return gui.progressUpdate(currentstep); } // Terminate the current progress -void MasterData::cancelProgress() +void Master::cancelProgress() { gui.progressTerminate(); } // Spacegroup name search -int MasterData::findSpacegroupByName(const char *name) const +int Master::findSpacegroupByName(const char *name) const { - dbgBegin(Debug::Calls,"MasterData::findSpacegroupByName"); + dbgBegin(Debug::Calls,"Master::findSpacegroupByName"); int result = 0; for (int n=1; n<231; n++) if (strcmp(spacegroups[n].name,name) == 0) @@ -554,14 +554,14 @@ int MasterData::findSpacegroupByName(const char *name) const result = n; break; } - dbgEnd(Debug::Calls,"MasterData::findSpacegroupByName"); + dbgEnd(Debug::Calls,"Master::findSpacegroupByName"); return result; } // Cell type from spacegrgoup -CellType MasterData::spacegroupCellType(int sg) const +CellType Master::spacegroupCellType(int sg) const { - dbgBegin(Debug::Calls,"MasterData::spacegroupCellType"); + dbgBegin(Debug::Calls,"Master::spacegroupCellType"); CellType result = CT_NONE; // None if (sg == 0) result = CT_NONE; @@ -575,6 +575,6 @@ CellType MasterData::spacegroupCellType(int sg) const else if (sg < 195) result = CT_NONE; // Cubic else result = CT_CUBIC; - dbgBegin(Debug::Calls,"MasterData::spacegroupCellType"); + dbgBegin(Debug::Calls,"Master::spacegroupCellType"); return result; } diff --git a/src/base/master.h b/src/base/master.h index 7b8dca7f3..28972098a 100644 --- a/src/base/master.h +++ b/src/base/master.h @@ -37,16 +37,15 @@ class Forcefield; class Grid; class Clipboard; -// Program Modes -enum ProgramMode { PM_COMMAND, PM_INTERACTIVE, PM_GUI, PM_NONE }; - // Master -class MasterData +class Master { public: // Constructor / Destructor - MasterData(); - ~MasterData(); + Master(); + ~Master(); + // Program mode enum + enum ProgramMode { CommandMode, InteractiveMode, GuiMode, NoMode }; // Remove all dynamic data void clear(); @@ -257,6 +256,6 @@ class MasterData Reflist typeMap; }; -extern MasterData master; +extern Master master; #endif diff --git a/src/base/prefs.cpp b/src/base/prefs.cpp index 845fe828c..a591aee90 100644 --- a/src/base/prefs.cpp +++ b/src/base/prefs.cpp @@ -26,88 +26,109 @@ #include "base/prefs.h" #include "base/sysfunc.h" -PrefsData prefs; +Prefs prefs; // GL Options -const char *GO_keywords[GO_NITEMS] = { "fog", "linealias", "polyalias", "backcull", "__DUMMY__" }; -GlOption GO_from_text(const char *s) - { return (GlOption) int(pow(2,enumSearch("GL option",GO_NITEMS,GO_keywords,s))); } +const char *GlOptionKeywords[Prefs::nGlOptions] = { "fog", "linealias", "polyalias", "backcull", "__DUMMY__" }; +Prefs::GlOption Prefs::glOption(const char *s) +{ + return (Prefs::GlOption) int(pow(2,enumSearch("GL option",Prefs::nGlOptions,GlOptionKeywords,s))); +} // Mouse buttons -const char *MB_keywords[MB_NITEMS] = { "left", "middle", "right", "wheel" }; -MouseButton MB_from_text(const char *s) - { return (MouseButton) enumSearch("mouse button",MB_NITEMS,MB_keywords,s); } -const char *text_from_MB(MouseButton i) - { return MB_keywords[i]; } +const char *MouseButtonKeywords[Prefs::nMouseButtons] = { "left", "middle", "right", "wheel" }; +Prefs::MouseButton Prefs::mouseButton(const char *s) +{ + return (Prefs::MouseButton) enumSearch("mouse button", Prefs::nMouseButtons, MouseButtonKeywords, s); +} +const char *Prefs::mouseButtonKeyword(Prefs::MouseButton i) +{ + return MouseButtonKeywords[i]; +} // Mouse actions -const char *MA_strings[MA_NITEMS] = { "None", "Rotate", "Translate", "Interact", "Zoom", "Z-Rotate" }; -MouseAction MA_from_text(const char *s) - { return (MouseAction) enumSearch("mouse action",MA_NITEMS,MA_strings,s); } -const char *text_from_MA(MouseAction i) - { return MA_strings[i]; } -const char **get_MA_strings() - { return MA_strings; } +const char *MouseActionKeywords[Prefs::nMouseActions] = { "None", "Rotate", "Translate", "Interact", "Zoom", "Z-Rotate" }; +Prefs::MouseAction Prefs::mouseAction(const char *s) +{ + return (Prefs::MouseAction) enumSearch("mouse action", Prefs::nMouseActions, MouseActionKeywords, s); +} +const char *Prefs::mouseActionKeyword(Prefs::MouseAction i) +{ + return MouseActionKeywords[i]; +} // Key modifiers -const char *MK_strings[MK_NITEMS] = { "Shift", "Ctrl", "Alt" }; -const char **get_MK_strings() - { return MK_strings; } -ModifierKey MK_from_text(const char *s) - { return (ModifierKey) enumSearch("modifier key",MK_NITEMS,MK_strings,s); } -const char *KA_strings[KA_NITEMS] = { "None", "Transform", "ZRotate" }; -const char **get_KA_strings() - { return KA_strings; } -KeyAction KA_from_text(const char *s) - { return (KeyAction) enumSearch("key action",KA_NITEMS,KA_strings,s); } +const char *ModifierKeyKeywords[Prefs::nModifierKeys] = { "Shift", "Ctrl", "Alt" }; +Prefs::ModifierKey Prefs::modifierKey(const char *s) +{ + return (Prefs::ModifierKey) enumSearch("modifier key", Prefs::nModifierKeys, ModifierKeyKeywords, s); +} + +// Key actions +const char *KeyActionKeywords[Prefs::nKeyActions] = { "None", "Transform", "ZRotate" }; +Prefs::KeyAction Prefs::keyAction(const char *s) +{ + return (Prefs::KeyAction) enumSearch("key action", Prefs::nKeyActions, KeyActionKeywords, s); +} // Colours -const char *COL_strings[COL_NITEMS] = { "General pen colour", "Background", "Atom Colour Scheme - Lo", - "Atom Colour Scheme = Mid", "Atom Colour Scheme = Hi", "Specular reflection" }; -const char *COL_keywords[COL_NITEMS] = { "pen", "bg", "schemelo", "schememid", "schemehi", "specular" }; -const char *text_from_COL(Colour i) - { return COL_strings[i]; } -Colour COL_from_text(const char *s) - { return (Colour) enumSearch("colour",COL_NITEMS,COL_keywords,s); } +//const char *ColourKeywords[Prefs::nColours] = { "General pen colour", "Background", "Atom Colour Scheme - Lo", "Atom Colour Scheme = Mid", "Atom Colour Scheme = Hi", "Specular reflection" }; +const char *ColourKeywords[Prefs::nColours] = { "pen", "bg", "schemelo", "schememid", "schemehi", "specular" }; +//const char *Prefs::colourKeyword(Colour i) +// { return COL_strings[i]; } +Prefs::Colour Prefs::colour(const char *s) +{ + return (Prefs::Colour) enumSearch("colour", Prefs::nColours, ColourKeywords, s); +} // Density calculation units -const char *DU_strings[DU_NITEMS] = { "g / cm**3", "atoms / A**3" }; -const char *DU_keywords[DU_NITEMS] = { "gpercm", "atomsperang" }; -const char *text_from_DU(DensityUnit i) - { return DU_strings[i]; } -DensityUnit DU_from_text(const char *s) - { return (DensityUnit) enumSearch("density units",DU_NITEMS,DU_keywords,s); } +//const char *DensityUnit[DU_NITEMS] = { "g / cm**3", "atoms / A**3" }; +const char *DensityUnitKeywords[Prefs::nDensityUnits] = { "gpercm", "atomsperang" }; +const char *Prefs::densityUnitKeyword(Prefs::DensityUnit i) +{ + return DensityUnitKeywords[i]; +} +Prefs::DensityUnit Prefs::densityUnit(const char *s) +{ + return (Prefs::DensityUnit) enumSearch("density unit", Prefs::nDensityUnits, DensityUnitKeywords, s); +} // Energy Units -const char *EU_strings[EU_NITEMS] = { "J/mol", "kJ/mol", "cal/mol", "kcal/mol", "eV/mol", "Ha/mol" }; -const char *EU_keywords[EU_NITEMS] = { "j", "kj", "cal", "kcal", "ev", "ha" }; -const char *text_from_EU(EnergyUnit i) - { return EU_strings[i]; } -EnergyUnit EU_from_text(const char *s) - { return (EnergyUnit) enumSearch("energy units",EU_NITEMS,EU_keywords,s); } +const char *EnergyUnitFormatted[Prefs::nEnergyUnits] = { "J/mol", "kJ/mol", "cal/mol", "kcal/mol", "eV/mol", "Ha/mol" }; +const char *EnergyUnitKeywords[Prefs::nEnergyUnits] = { "j", "kj", "cal", "kcal", "ev", "ha" }; +const char *Prefs::energyUnitKeyword(Prefs::EnergyUnit i) +{ + return EnergyUnitKeywords[i]; +} +Prefs::EnergyUnit Prefs::energyUnit(const char *s) +{ + return (Prefs::EnergyUnit) enumSearch("energy unit", Prefs::nEnergyUnits, EnergyUnitKeywords, s); +} // ZMapping types -const char *ZM_keywords[ZM_NITEMS] = { "alpha", "firstalpha", "name", "numeric", "ff", "auto" }; -ZmapType ZM_from_text(const char *s) - { return (ZmapType) enumSearch("element mapping style",ZM_NITEMS,ZM_keywords,s); } +const char *ZM_keywords[Prefs::nZmapTypes] = { "alpha", "firstalpha", "name", "numeric", "ff", "auto" }; +Prefs::ZmapType Prefs::zmapType(const char *s) + { return (Prefs::ZmapType) enumSearch("element mapping style",Prefs::nZmapTypes,ZM_keywords,s); } const char **get_ZM_keywords() { return ZM_keywords; } // View Objects -const char *VO_keywords[VO_NITEMS] = { "atoms", "cell", "cellaxes", "cellrepeat", "forcearrows", "globe", "labels", "measurements", "regions" }; -ViewObject VO_from_text(const char *s) - { return (ViewObject) enumSearch("view object",VO_NITEMS,VO_keywords,s); } +const char *ViewObjectKeywords[Prefs::nViewObjects] = { "atoms", "cell", "cellaxes", "cellrepeat", "forcearrows", "globe", "labels", "measurements", "regions" }; +Prefs::ViewObject Prefs::viewObject(const char *s) +{ + return (Prefs::ViewObject) enumSearch("view object", Prefs::nViewObjects, ViewObjectKeywords, s); +} // Guide Geometries -const char *GG_strings[GG_NITEMS] = { "Square", "Hexagonal" }; +const char *GG_strings[Prefs::nGuideGeometries] = { "Square", "Hexagonal" }; const char **get_GG_strings() { return GG_strings; } // Constructor -PrefsData::PrefsData() +Prefs::Prefs() { // Rendering - Style - colourScheme_ = AC_ELEMENT; + colourScheme_ = Prefs::ElementScheme; nScaleSegments_ = 2; scaleColours_ = NULL; setScaleColours(); @@ -123,18 +144,18 @@ PrefsData::PrefsData() perspective_ = TRUE; perspectiveFov_ = 20.0; spotlightActive_ = TRUE; - spotlightColour_[SL_AMBIENT][0] = 0.0f; - spotlightColour_[SL_AMBIENT][1] = 0.0f; - spotlightColour_[SL_AMBIENT][2] = 0.0f; - spotlightColour_[SL_AMBIENT][3] = 1.0f; - spotlightColour_[SL_DIFFUSE][0] = 0.8f; - spotlightColour_[SL_DIFFUSE][1] = 0.8f; - spotlightColour_[SL_DIFFUSE][2] = 0.8f; - spotlightColour_[SL_DIFFUSE][3] = 1.0f; - spotlightColour_[SL_SPECULAR][0] = 0.7f; - spotlightColour_[SL_SPECULAR][1] = 0.7f; - spotlightColour_[SL_SPECULAR][2] = 0.7f; - spotlightColour_[SL_SPECULAR][3] = 1.0f; + spotlightColour_[Prefs::AmbientComponent][0] = 0.0f; + spotlightColour_[Prefs::AmbientComponent][1] = 0.0f; + spotlightColour_[Prefs::AmbientComponent][2] = 0.0f; + spotlightColour_[Prefs::AmbientComponent][3] = 1.0f; + spotlightColour_[Prefs::DiffuseComponent][0] = 0.8f; + spotlightColour_[Prefs::DiffuseComponent][1] = 0.8f; + spotlightColour_[Prefs::DiffuseComponent][2] = 0.8f; + spotlightColour_[Prefs::DiffuseComponent][3] = 1.0f; + spotlightColour_[Prefs::SpecularComponent][0] = 0.7f; + spotlightColour_[Prefs::SpecularComponent][1] = 0.7f; + spotlightColour_[Prefs::SpecularComponent][2] = 0.7f; + spotlightColour_[Prefs::SpecularComponent][3] = 1.0f; spotlightPosition_[0] = 1.0f; spotlightPosition_[1] = 1.0f; spotlightPosition_[2] = 1.0f; @@ -149,16 +170,16 @@ PrefsData::PrefsData() // Rendering - Objects labelScale_ = 4.0; - renderObjects_[VO_ATOMS] = TRUE;//TGAY - renderObjects_[VO_LABELS] = TRUE; - renderObjects_[VO_MEASUREMENTS] = TRUE; - renderObjects_[VO_GLOBE] = TRUE; - renderObjects_[VO_CELL] = TRUE; - renderObjects_[VO_CELLAXES] = TRUE; - renderObjects_[VO_CELLREPEAT] = FALSE; - renderObjects_[VO_REGIONS] = TRUE; - renderObjects_[VO_FORCEARROWS] = FALSE; - renderObjects_[VO_SURFACES] = TRUE; + renderObjects_[Prefs::ViewAtoms] = TRUE;//TGAY + renderObjects_[Prefs::ViewLabels] = TRUE; + renderObjects_[Prefs::ViewMeasurements] = TRUE; + renderObjects_[Prefs::ViewGlobe] = TRUE; + renderObjects_[Prefs::ViewCell] = TRUE; + renderObjects_[Prefs::ViewCellAXES] = TRUE; + renderObjects_[Prefs::ViewCellREPEAT] = FALSE; + renderObjects_[Prefs::ViewRegions] = TRUE; + renderObjects_[Prefs::ViewForceArrows] = FALSE; + renderObjects_[Prefs::ViewSurfaces] = TRUE; renderStyle_ = Atom::StickStyle; // Build @@ -168,32 +189,32 @@ PrefsData::PrefsData() guideSpacing_ = 1.0; guideTicks_ = 5; guideExtent_ = 10; - guideShape_ = GG_SQUARE; + guideShape_ = Prefs::SquareGuide; // Input - mouseAction_[MB_LEFT] = MA_INTERACT; - mouseAction_[MB_MIDDLE] = MA_VIEWTRANSLATE; - mouseAction_[MB_RIGHT] = MA_VIEWROTATE; - mouseAction_[MB_WHEEL] = MA_VIEWZOOM; - keyAction_[MK_SHIFT] = KA_ZROTATE; - keyAction_[MK_CTRL] = KA_MANIPULATE; - keyAction_[MK_ALT] = KA_NONE; + mouseAction_[Prefs::LeftButton] = Prefs::InteractAction; + mouseAction_[Prefs::MiddleButton] = Prefs::TranslateAction; + mouseAction_[Prefs::RightButton] = Prefs::RotateAction; + mouseAction_[Prefs::WheelButton] = Prefs::ZoomAction; + keyAction_[Prefs::ShiftKey] = Prefs::ZrotateKeyAction; + keyAction_[Prefs::CtrlKey] = Prefs::ManipulateKeyAction; + keyAction_[Prefs::AltKey] = Prefs::NoKeyAction; // Colours - setColour(COL_SPECREFLECT, 0.9f, 0.9f, 0.9f, 1.0f); - setColour(COL_PEN, 0.0f, 0.0f, 0.0f, 1.0f); - setColour(COL_BG, 1.0f, 1.0f, 1.0f, 1.0f); - setColour(COL_SCHEMELO, 1.0f, 0.0f, 0.0f, 1.0f); - setColour(COL_SCHEMEMID, 0.7f, 0.7f, 0.7f, 1.0f); - setColour(COL_SCHEMEHI, 0.0f, 0.0f, 1.0f, 1.0f); - colourSchemeLo_[AC_ELEMENT] = 0.0; - colourSchemeLo_[AC_CHARGE] = -1.0; - colourSchemeLo_[AC_VELOCITY] = 0.0; - colourSchemeLo_[AC_FORCE] = 0.0; - colourSchemeHi_[AC_ELEMENT] = 0.0; - colourSchemeHi_[AC_CHARGE] = 1.0; - colourSchemeHi_[AC_VELOCITY] = 200.0; - colourSchemeHi_[AC_FORCE] = 10000.0; + setColour(Prefs::SpecularColour, 0.9f, 0.9f, 0.9f, 1.0f); + setColour(Prefs::PenColour, 0.0f, 0.0f, 0.0f, 1.0f); + setColour(Prefs::BackgroundColour, 1.0f, 1.0f, 1.0f, 1.0f); + setColour(Prefs::SchemeLoColour, 1.0f, 0.0f, 0.0f, 1.0f); + setColour(Prefs::SchemeMidColour, 0.7f, 0.7f, 0.7f, 1.0f); + setColour(Prefs::SchemeHiColour, 0.0f, 0.0f, 1.0f, 1.0f); + colourSchemeLo_[Prefs::ElementScheme] = 0.0; + colourSchemeLo_[Prefs::ChargeScheme] = -1.0; + colourSchemeLo_[Prefs::VelocityScheme] = 0.0; + colourSchemeLo_[Prefs::ForceScheme] = 0.0; + colourSchemeHi_[Prefs::ElementScheme] = 0.0; + colourSchemeHi_[Prefs::ChargeScheme] = 1.0; + colourSchemeHi_[Prefs::VelocityScheme] = 200.0; + colourSchemeHi_[Prefs::ForceScheme] = 10000.0; // Methods modelUpdate_ = 5; @@ -201,24 +222,24 @@ PrefsData::PrefsData() maxRingSize_ = 6; // File - bondOnLoad_ = PS_ASFILTER; - foldOnLoad_ = PS_ASFILTER; - centreOnLoad_ = PS_ASFILTER; - packOnLoad_ = PS_ASFILTER; + bondOnLoad_ = Prefs::SwitchAsFilter; + foldOnLoad_ = Prefs::SwitchAsFilter; + centreOnLoad_ = Prefs::SwitchAsFilter; + packOnLoad_ = Prefs::SwitchAsFilter; loadAllCoords_ = TRUE; cacheLimit_ = 1024; - zmapType_ = ZM_AUTO; + zmapType_ = Prefs::AutoZmap; coordsInBohr_ = FALSE; - // Units - energyConversions_[EU_J] = 1.0; - energyConversions_[EU_KJ] = 1000.0; - energyConversions_[EU_CAL] = 4.184; - energyConversions_[EU_KCAL] = 4184.0; - energyConversions_[EU_EV] = 96485.14925; - energyConversions_[EU_HARTREE] = 2625494.616; - setEnergyUnit(EU_KJ); - densityUnit_ = DU_GPERCM; + // Energy unit conversion factors to J + energyConversions_[Prefs::Joules] = 1.0; + energyConversions_[Prefs::KiloJoules] = 1000.0; + energyConversions_[Prefs::Calories] = 4.184; + energyConversions_[Prefs::KiloCalories] = 4184.0; + energyConversions_[Prefs::ElectronVolts] = 96485.14925; + energyConversions_[Prefs::Hartree] = 2625494.616; + setEnergyUnit(Prefs::KiloJoules); + densityUnit_ = Prefs::GramsPerCm; // Energy electrostaticsMethod_ = EM_EWALDAUTO; @@ -238,7 +259,7 @@ PrefsData::PrefsData() } // Destructor -PrefsData::~PrefsData() +Prefs::~Prefs() { if (scaleColours_ != NULL) { @@ -248,9 +269,9 @@ PrefsData::~PrefsData() } // Load user preferences file -void PrefsData::load(const char *filename) +void Prefs::load(const char *filename) { - dbgBegin(Debug::Calls,"PrefsData::load"); + dbgBegin(Debug::Calls,"Prefs::load"); int success; // Open the file ifstream prefsfile(filename,ios::in); @@ -258,7 +279,7 @@ void PrefsData::load(const char *filename) { printf("Couldn't open preferences file in '%s'\n",filename); prefsfile.close(); - dbgEnd(Debug::Calls,"PrefsData::load"); + dbgEnd(Debug::Calls,"Prefs::load"); return; } // Create script structure and initialise @@ -292,72 +313,72 @@ void PrefsData::load(const char *filename) */ // Set the visibility of an object -void PrefsData::setVisible(ViewObject vo, bool b) +void Prefs::setVisible(ViewObject vo, bool b) { renderObjects_[vo] = b; } // Return whether the specified object is visible (i.e. should be rendered) -bool PrefsData::shouldRender(ViewObject vo) +bool Prefs::shouldRender(ViewObject vo) { return renderObjects_[vo]; } // Set the drawing style of models -void PrefsData::setRenderStyle(Atom::DrawStyle ds) +void Prefs::setRenderStyle(Atom::DrawStyle ds) { renderStyle_ = ds; } // Return the current drawing style of models -Atom::DrawStyle PrefsData::renderStyle() +Atom::DrawStyle Prefs::renderStyle() { return renderStyle_; } // Set the scale of labels in the model -void PrefsData::setLabelScale(double v) +void Prefs::setLabelScale(double v) { labelScale_ = v; } // Return the current label scale -double PrefsData::labelScale() +double Prefs::labelScale() { return labelScale_; } // Return the current rotation globe size in pixels -int PrefsData::globeSize() +int Prefs::globeSize() { return globeSize_; } // Set positive repeat cell value -void PrefsData::setRepeatCellsPos(int i, int r) +void Prefs::setRepeatCellsPos(int i, int r) { repeatCellsPos_.set(i,r); } // Get positive repeat cell value -int PrefsData::repeatCellsPos(int i) +int Prefs::repeatCellsPos(int i) { return repeatCellsPos_.get(i); } // Set negative repeat cell value -void PrefsData::setRepeatCellsNeg(int i, int r) +void Prefs::setRepeatCellsNeg(int i, int r) { repeatCellsNeg_.set(i,r); } // Get negative repeat cell value -int PrefsData::repeatCellsNeg(int i) +int Prefs::repeatCellsNeg(int i) { return repeatCellsNeg_.get(i); } -double PrefsData::screenRadius(Atom *i) +double Prefs::screenRadius(Atom *i) { // Simple routine that returns the screen 'radius' of the supplied atom, which depends on its drawing style Atom::DrawStyle dstyle; @@ -371,109 +392,109 @@ double PrefsData::screenRadius(Atom *i) */ // Sets the specified atom size to the given value -void PrefsData::setAtomSize(Atom::DrawStyle ds, double f) +void Prefs::setAtomSize(Atom::DrawStyle ds, double f) { atomSize_[(int)ds] = f; } // Return the specified atom size -GLdouble PrefsData::atomSize(Atom::DrawStyle ds) +GLdouble Prefs::atomSize(Atom::DrawStyle ds) { return atomSize_[(int)ds]; } // Sets the tube size in DS_TUBE -void PrefsData::setTubeSize(double f) +void Prefs::setTubeSize(double f) { tubeSize_ = f; } // Return the tube size used in DS_TUBE -GLdouble PrefsData::tubeSize() +GLdouble Prefs::tubeSize() { return tubeSize_; } // Sets the detail for atom quadrics -void PrefsData::setAtomDetail(int n) +void Prefs::setAtomDetail(int n) { atomDetail_ = n; } // Return the current detail of atom quadrics -int PrefsData::atomDetail() +int Prefs::atomDetail() { return atomDetail_; } // Sets the detail for bond quadrics -void PrefsData::setBondDetail(int n) +void Prefs::setBondDetail(int n) { bondDetail_ = n; } // Return the current detail of bond quadrics -int PrefsData::bondDetail() +int Prefs::bondDetail() { return bondDetail_; } // Sets the scale of selected atoms -void PrefsData::setSelectionScale(double f) +void Prefs::setSelectionScale(double f) { selectionScale_ = f; } // Return the scale of selected atoms -GLdouble PrefsData::selectionScale() +GLdouble Prefs::selectionScale() { return selectionScale_; } // Return whether perspective viewing is enabled -bool PrefsData::hasPerspective() +bool Prefs::hasPerspective() { return perspective_; } // Sets perspective viewing on/off -void PrefsData::setPerspective(bool b) +void Prefs::setPerspective(bool b) { perspective_ = b; } // Set the perspective field of view angle -void PrefsData::setPerspectiveFov(double fov) +void Prefs::setPerspectiveFov(double fov) { perspectiveFov_ = fov; } // Return the perspective field of view angle -double PrefsData::perspectiveFov() +double Prefs::perspectiveFov() { return perspectiveFov_; } // Set status of spotlight -void PrefsData::setSpotlightActive(bool status) +void Prefs::setSpotlightActive(bool status) { spotlightActive_ = status; } // Return status of spotlight -bool PrefsData::spotlightActive() +bool Prefs::spotlightActive() { return spotlightActive_; } // Set element of spotlight colour component -void PrefsData::setSpotlightColour(SpotlightComponent sc, int i, GLfloat value) +void Prefs::setSpotlightColour(Prefs::ColourComponent sc, int i, GLfloat value) { spotlightColour_[sc][i] = value; } // Set spotlight colour component -void PrefsData::setSpotlightColour(SpotlightComponent sc, GLfloat r, GLfloat g, GLfloat b) +void Prefs::setSpotlightColour(Prefs::ColourComponent sc, GLfloat r, GLfloat g, GLfloat b) { spotlightColour_[sc][0] = r; spotlightColour_[sc][1] = g; @@ -481,13 +502,13 @@ void PrefsData::setSpotlightColour(SpotlightComponent sc, GLfloat r, GLfloat g, } // Return spotlight colour component -GLfloat *PrefsData::spotlightColour(SpotlightComponent sc) +GLfloat *Prefs::spotlightColour(Prefs::ColourComponent sc) { return spotlightColour_[sc]; } // Set spotlight position -void PrefsData::setSpotlightPosition(GLfloat x, GLfloat y, GLfloat z) +void Prefs::setSpotlightPosition(GLfloat x, GLfloat y, GLfloat z) { spotlightPosition_[0] = x; spotlightPosition_[1] = y; @@ -495,44 +516,44 @@ void PrefsData::setSpotlightPosition(GLfloat x, GLfloat y, GLfloat z) } // Set individual element of spotlight position -void PrefsData::setSpotlightPosition(int component, GLfloat f) +void Prefs::setSpotlightPosition(int component, GLfloat f) { spotlightPosition_[component] = f; } // Return spotlight position -GLfloat *PrefsData::spotlightPosition() +GLfloat *Prefs::spotlightPosition() { return spotlightPosition_; } // Set atom colour scheme -void PrefsData::setColourScheme(AtomColours ac) +void Prefs::setColourScheme(Prefs::ColourScheme ac) { colourScheme_ = ac; } // Return atom colour scheme -AtomColours PrefsData::colourScheme() +Prefs::ColourScheme Prefs::colourScheme() { return colourScheme_; } // Get number of segments in colour scale -int PrefsData::nScaleSegments() +int Prefs::nScaleSegments() { return nScaleSegments_; } // Set number of segments in colour scale -void PrefsData::setScaleSegments(int nsegments) +void Prefs::setScaleSegments(int nsegments) { nScaleSegments_ = nsegments; setScaleColours(); } // Copy colour scale segment into supplied array -void PrefsData::copyScaleColour(int n, GLfloat *v) +void Prefs::copyScaleColour(int n, GLfloat *v) { // Check range of requested colour if ((n < 0) || (n > (3+2*nScaleSegments_))) @@ -553,7 +574,7 @@ void PrefsData::copyScaleColour(int n, GLfloat *v) } // Set colours in colour scale -void PrefsData::setScaleColours() +void Prefs::setScaleColours() { static int lastnsegments = -1, n; static double delta; @@ -571,26 +592,26 @@ void PrefsData::setScaleColours() lastnsegments = nScaleSegments_; } // Set values of lo, mid, and hi colours. - scaleColours_[0][0] = colours_[COL_SCHEMELO][0]; - scaleColours_[0][1] = colours_[COL_SCHEMELO][1]; - scaleColours_[0][2] = colours_[COL_SCHEMELO][2]; - scaleColours_[0][3] = colours_[COL_SCHEMELO][3]; - scaleColours_[nScaleSegments_+1][0] = colours_[COL_SCHEMEMID][0]; - scaleColours_[nScaleSegments_+1][1] = colours_[COL_SCHEMEMID][1]; - scaleColours_[nScaleSegments_+1][2] = colours_[COL_SCHEMEMID][2]; - scaleColours_[nScaleSegments_+1][3] = colours_[COL_SCHEMEMID][3]; - scaleColours_[nScaleSegments_*2+2][0] = colours_[COL_SCHEMEHI][0]; - scaleColours_[nScaleSegments_*2+2][1] = colours_[COL_SCHEMEHI][1]; - scaleColours_[nScaleSegments_*2+2][2] = colours_[COL_SCHEMEHI][2]; - scaleColours_[nScaleSegments_*2+2][3] = colours_[COL_SCHEMEHI][3]; + scaleColours_[0][0] = colours_[Prefs::SchemeLoColour][0]; + scaleColours_[0][1] = colours_[Prefs::SchemeLoColour][1]; + scaleColours_[0][2] = colours_[Prefs::SchemeLoColour][2]; + scaleColours_[0][3] = colours_[Prefs::SchemeLoColour][3]; + scaleColours_[nScaleSegments_+1][0] = colours_[Prefs::SchemeMidColour][0]; + scaleColours_[nScaleSegments_+1][1] = colours_[Prefs::SchemeMidColour][1]; + scaleColours_[nScaleSegments_+1][2] = colours_[Prefs::SchemeMidColour][2]; + scaleColours_[nScaleSegments_+1][3] = colours_[Prefs::SchemeMidColour][3]; + scaleColours_[nScaleSegments_*2+2][0] = colours_[Prefs::SchemeHiColour][0]; + scaleColours_[nScaleSegments_*2+2][1] = colours_[Prefs::SchemeHiColour][1]; + scaleColours_[nScaleSegments_*2+2][2] = colours_[Prefs::SchemeHiColour][2]; + scaleColours_[nScaleSegments_*2+2][3] = colours_[Prefs::SchemeHiColour][3]; // Interpolate between the lo and mid points. delta = 1.0 / (nScaleSegments_ + 1); for (n=0; n v) +void Prefs::setEwaldKvec(Vec3 v) { ewaldKvec_ = v; } // Return the Ewald k-vector extents -Vec3 PrefsData::ewaldKvec() +Vec3 Prefs::ewaldKvec() { return ewaldKvec_; } // Sets the Ewald precision -void PrefsData::setEwaldPrecision(double d) +void Prefs::setEwaldPrecision(double d) { ewaldPrecision_ = d; } // Return the Ewald precision -double PrefsData::ewaldPrecision() +double Prefs::ewaldPrecision() { return ewaldPrecision_; } // Set the Gaussian width to use in the Ewald sum -void PrefsData::setEwaldAlpha(double d) +void Prefs::setEwaldAlpha(double d) { ewaldAlpha_ = d; } // Return the Ewald alpha value -double PrefsData::ewaldAlpha() +double Prefs::ewaldAlpha() { return ewaldAlpha_; } // Flag to indicate validity of automatic Ewald params (invalidated on cell change) -bool PrefsData::hasValidEwaldAuto() +bool Prefs::hasValidEwaldAuto() { return validEwaldAuto_; } // Flag the Ewald auto params as invalid -void PrefsData::invalidateEwaldAuto() +void Prefs::invalidateEwaldAuto() { validEwaldAuto_ = FALSE; } // Sets the VDW cutoff radius to use -void PrefsData::setVdwCutoff(double d) +void Prefs::setVdwCutoff(double d) { vdwCutoff_ = d; } // Return the VDW cutoff radius -double PrefsData::vdwCutoff() +double Prefs::vdwCutoff() { return vdwCutoff_; } // Sets the electrostatic cutoff radius to use -void PrefsData::setElecCutoff(double d) +void Prefs::setElecCutoff(double d) { elecCutoff_ = d; } // Return the electrostatic cutoff radius -double PrefsData::elecCutoff() +double Prefs::elecCutoff() { return elecCutoff_; } // Sets the vdw radius scaling factor -void PrefsData::setVdwScale(double d) +void Prefs::setVdwScale(double d) { vdwScale_ = d; } // Return the VDW radius scaling factor -double PrefsData::vdwScale() +double Prefs::vdwScale() { return vdwScale_; } -// Set the charge source for the model -void PrefsData::setChargeSource(ChargeSource cs) -{ - chargeSource_ = cs; -} - -// Get the charge source for the model -ChargeSource PrefsData::chargeSource() -{ - return chargeSource_; -} - /* // Undo levels */ // Set the maximum number of undo levels allowed -void PrefsData::setMaxUndoLevels(int n) +void Prefs::setMaxUndoLevels(int n) { maxUndoLevels_ = n; } // Return the maximum number of undo levels allowed -int PrefsData::maxUndoLevels() +int Prefs::maxUndoLevels() { return maxUndoLevels_; } diff --git a/src/base/prefs.h b/src/base/prefs.h index 38dd9db94..1b55a7c64 100644 --- a/src/base/prefs.h +++ b/src/base/prefs.h @@ -27,81 +27,64 @@ #include "classes/atom.h" #include -// Atom colouring scheme -enum AtomColours { AC_ELEMENT, AC_CHARGE, AC_VELOCITY, AC_FORCE, AC_NITEMS }; - -// Preferences switches -enum PrefSwitch { PS_ASFILTER=-1, PS_NO, PS_YES }; - -// View Objects -enum ViewObject { VO_ATOMS, VO_CELL, VO_CELLAXES, VO_CELLREPEAT, VO_FORCEARROWS, VO_GLOBE, VO_LABELS, VO_MEASUREMENTS, VO_REGIONS, VO_SURFACES, VO_NITEMS }; -ViewObject VO_from_text(const char*); - -// GL Options -enum GlOption { GO_FOG=1, GO_LINEALIASING=2, GO_POLYALIASING=4, GO_BACKCULLING=8, GO_DUMMY=16, GO_NITEMS=5 }; -GlOption GO_from_text(const char*); - -// Mouse buttons -enum MouseButton { MB_LEFT, MB_MIDDLE, MB_RIGHT, MB_WHEEL, MB_NITEMS }; -MouseButton MB_from_text(const char*); -const char *text_from_MB(MouseButton); - -// Mouse Actions -enum MouseAction { MA_NONE, MA_VIEWROTATE, MA_VIEWTRANSLATE, MA_INTERACT, MA_VIEWZOOM, MA_VIEWZROTATE, MA_NITEMS }; -MouseAction MA_from_text(const char*); -const char *text_from_MA(MouseAction); -const char **get_MA_strings(); - -// Modifier keys -enum ModifierKey { MK_SHIFT, MK_CTRL, MK_ALT, MK_NITEMS }; -const char **get_MK_strings(); -ModifierKey MK_from_text(const char*); - -// Modifier actions -enum KeyAction { KA_NONE, KA_MANIPULATE, KA_ZROTATE, KA_NITEMS }; -const char **get_KA_strings(); -KeyAction KA_from_text(const char*); - -// Colours -enum Colour { COL_PEN, COL_BG, COL_SCHEMELO, COL_SCHEMEMID, COL_SCHEMEHI, COL_SPECREFLECT, COL_NITEMS }; -const char *text_from_COL(Colour); -Colour COL_from_text(const char*); - -// Density calculation units -enum DensityUnit { DU_GPERCM, DU_ATOMSPERANG, DU_NITEMS }; -const char *text_from_DU(DensityUnit); -DensityUnit DU_from_text(const char*); - -// Drawing guide geometry -enum GuideGeometry { GG_SQUARE, GG_HEXAGONAL, GG_NITEMS }; -const char **get_GG_strings(); - -// Energy Units -enum EnergyUnit { EU_J, EU_KJ, EU_CAL, EU_KCAL, EU_EV, EU_HARTREE, EU_NITEMS }; -const char *text_from_EU(EnergyUnit); -EnergyUnit EU_from_text(const char*); - -// Name->Z mapping methods -enum ZmapType { ZM_ALPHA, ZM_FIRSTALPHA, ZM_NAME, ZM_NUMERIC, ZM_FORCEFIELD, ZM_AUTO, ZM_NITEMS }; -ZmapType ZM_from_text(const char*); -const char **get_ZM_keywords(); - -// Charge source -enum ChargeSource { QS_MODEL, QS_FF, QS_GASTEIGER, QS_QEQ, QS_NITEMS }; - -// Spotlight Components -enum SpotlightComponent { SL_AMBIENT, SL_DIFFUSE, SL_SPECULAR, SL_NITEMS }; - // Forward declarations class Cell; // Prefs -class PrefsData +class Prefs { + /* + // Enumerations + */ + public: + // Mouse buttons + enum MouseButton { LeftButton, MiddleButton, RightButton, WheelButton, nMouseButtons }; + static MouseButton mouseButton(const char*); + static const char *mouseButtonKeyword(MouseButton); + // Mouse Actions + enum MouseAction { NoAction, RotateAction, TranslateAction, InteractAction, ZoomAction, ZrotateAction, nMouseActions }; + static MouseAction mouseAction(const char*); + static const char *mouseActionKeyword(MouseAction); + // Modifier keys + enum ModifierKey { ShiftKey, CtrlKey, AltKey, nModifierKeys }; + static ModifierKey modifierKey(const char*); + // Modifier actions + enum KeyAction { NoKeyAction, ManipulateKeyAction, ZrotateKeyAction, nKeyActions }; + static KeyAction keyAction(const char*); + // Colours + enum Colour { PenColour, BackgroundColour, SchemeLoColour, SchemeMidColour, SchemeHiColour, SpecularColour, nColours }; + static const char *colourKeyword(Colour); + static Colour colour(const char*); + // Energy Units + enum EnergyUnit { Joules, KiloJoules, Calories, KiloCalories, ElectronVolts, Hartree, nEnergyUnits }; + static const char *energyUnitKeyword(EnergyUnit); + static EnergyUnit energyUnit(const char*); + // Density calculation units + enum DensityUnit { GramsPerCm, AtomsPerAngstrom, nDensityUnits }; + static const char *densityUnitKeyword(DensityUnit); + static DensityUnit densityUnit(const char*); + // View Objects + enum ViewObject { ViewAtoms, ViewCell, ViewCellAXES, ViewCellREPEAT, ViewForceArrows, ViewGlobe, ViewLabels, ViewMeasurements, ViewRegions, ViewSurfaces, nViewObjects }; + static ViewObject viewObject(const char*); + // GL Options + enum GlOption { FogOption=1, LineAliasOption=2, PolyAliasOption=4, BackCullOption=8, DummyOption=16, nGlOptions=5 }; + static GlOption glOption(const char*); + // Atom colouring scheme + enum ColourScheme { ElementScheme, ChargeScheme, VelocityScheme, ForceScheme, nColourSchemes }; + // Preferences switches + enum PrefSwitch { SwitchAsFilter=-1, SwitchOff, SwitchOn }; + // Drawing guide geometry + enum GuideGeometry { SquareGuide, HexagonalGuide, nGuideGeometries }; + // Name->Z mapping methods + enum ZmapType { AlphaZmap, FirstAlphaZmap, NameZmap, NumericZmap, ForcefieldZmap, AutoZmap, nZmapTypes }; + static ZmapType zmapType(const char*); + // Spotlight Components + enum ColourComponent { AmbientComponent, DiffuseComponent, SpecularComponent, nColourComponents }; + public: // Constructor / Destructor - PrefsData(); - ~PrefsData(); + Prefs(); + ~Prefs(); // Load prefs from file void load(const char*); // Set GUI controls to reflect prefs choices @@ -112,7 +95,7 @@ class PrefsData */ private: // List of visibilities of renderable objects - bool renderObjects_[VO_NITEMS]; + bool renderObjects_[Prefs::nViewObjects]; // Repeat units in positive xyz directions Vec3 repeatCellsPos_; // Repeat units in negative xyz directions @@ -171,11 +154,11 @@ class PrefsData // Whether the spotlight is on bool spotlightActive_; // Spotlight components - GLfloat spotlightColour_[SL_NITEMS][4]; + GLfloat spotlightColour_[Prefs::nColourComponents][4]; // Spotlight position GLfloat spotlightPosition_[3]; // Atom colouring style - AtomColours colourScheme_; + Prefs::ColourScheme colourScheme_; // Number of segments between lo/hi and mid colours in colour scale int nScaleSegments_; // Graduated colour scale colours @@ -215,19 +198,19 @@ class PrefsData // Return status of spotlight bool spotlightActive(); // Set spotlight colour component - void setSpotlightColour(SpotlightComponent sc, int i, GLfloat value); - void setSpotlightColour(SpotlightComponent sc, GLfloat r, GLfloat g, GLfloat b); + void setSpotlightColour(ColourComponent sc, int i, GLfloat value); + void setSpotlightColour(ColourComponent sc, GLfloat r, GLfloat g, GLfloat b); // Return spotlight colour component - GLfloat *spotlightColour(SpotlightComponent sc); + GLfloat *spotlightColour(ColourComponent sc); // Set spotlight position void setSpotlightPosition(GLfloat r, GLfloat g, GLfloat b); void setSpotlightPosition(int component, GLfloat f); // Return spotlight position GLfloat *spotlightPosition(); // Set atom colour scheme - void setColourScheme(AtomColours ac); + void setColourScheme(Prefs::ColourScheme ac); // Return atom colour scheme - AtomColours colourScheme(); + Prefs::ColourScheme colourScheme(); // Set number of segments in colour scale void setScaleSegments(int nsegments); // Get number of segments in colour scale @@ -279,11 +262,11 @@ class PrefsData */ private: // RGB colour values - GLfloat colours_[COL_NITEMS][4]; + GLfloat colours_[Prefs::nColours][4]; // Numerical low limit corresponding to COL_ACSCHEMELO - double colourSchemeLo_[AC_NITEMS]; + double colourSchemeLo_[Prefs::nColourSchemes]; // Numerical high limit corresponding to COL_ACSCHEMELO - double colourSchemeHi_[AC_NITEMS]; + double colourSchemeHi_[Prefs::nColourSchemes]; public: // Set the specified colour to the integer RGB values supplied @@ -318,7 +301,7 @@ class PrefsData // Size limit (kbytes) for caching trajectory frames int cacheLimit_; // Type of name->Z mapping to use - ZmapType zmapType_; + Prefs::ZmapType zmapType_; public: // Sets whether to calculate bonding on model load @@ -346,9 +329,9 @@ class PrefsData // Return the cache limit for trajectory files int cacheLimit(); // Sets the style of element conversion to use - void setZmapType(ZmapType i); + void setZmapType(Prefs::ZmapType i); // Return the style of element conversion in use - ZmapType zmapType(); + Prefs::ZmapType zmapType(); // Sets whether to convert coords from Bohr to Angstrom on load void setCoordsInBohr(bool b); // Whether coordinates should be converted from Bohr to Angstrom @@ -371,11 +354,11 @@ class PrefsData // Whether to show the drawing guide bool showGuide_; // Geometry of the grid in the drawing guide - GuideGeometry guideShape_; + Prefs::GuideGeometry guideShape_; // User-definable mouse button actions - MouseAction mouseAction_[MB_NITEMS]; + MouseAction mouseAction_[Prefs::nMouseButtons]; // User-definable key modifier actions - KeyAction keyAction_[MK_NITEMS]; + KeyAction keyAction_[Prefs::nModifierKeys]; public: // Sets the bonding tolerance @@ -403,9 +386,9 @@ class PrefsData // Return whether the draw guide is visible bool isGuideVisible(); // Sets the shape of the drawing guide - void setGuideShape(GuideGeometry g); + void setGuideShape(Prefs::GuideGeometry g); // Return guide shape - GuideGeometry guideShape(); + Prefs::GuideGeometry guideShape(); // Sets the action for the specified mouse button void setMouseAction(MouseButton mb, MouseAction ma); // Return the action associated with the specified mouse button @@ -446,7 +429,7 @@ class PrefsData // Internal energy units to use for forcefield storage, energy calculation etc. EnergyUnit energyUnit_; // Conversion factors for energy units - double energyConversions_[EU_NITEMS]; + double energyConversions_[Prefs::nEnergyUnits]; // Factor to convert from atomic units to internal units double elecConvert_; @@ -486,8 +469,6 @@ class PrefsData double vdwCutoff_, elecCutoff_; // Scale factor for VDW radii (used in disorder build) double vdwScale_; - // Where to get charges from for the model - ChargeSource chargeSource_; // Whether the automatic Ewald setup is valid bool validEwaldAuto_; @@ -541,10 +522,6 @@ class PrefsData void setVdwScale(double d); // Return the VDW radius scaling factor double vdwScale(); - // Set the charge source for the model - void setChargeSource(ChargeSource cs); - // Get the charge source for the model - ChargeSource chargeSource(); /* // Undo levels @@ -560,6 +537,6 @@ class PrefsData int maxUndoLevels(); }; -extern PrefsData prefs; +extern Prefs prefs; #endif diff --git a/src/base/spacegroup.cpp b/src/base/spacegroup.cpp index abda8b2bf..21c096bef 100644 --- a/src/base/spacegroup.cpp +++ b/src/base/spacegroup.cpp @@ -28,7 +28,7 @@ Spacegroup::~Spacegroup() } // Define spacegroups and their symmetry generators -Spacegroup MasterData::spacegroups[] = { +Spacegroup Master::spacegroups[] = { { "None", "None", 0}, // 0 (no spacegroup) { "P1", "P1", 1, // 1 { 0 } }, diff --git a/src/classes/atomtype.cpp b/src/classes/atomtype.cpp index 26ed87716..a5d8d5ecc 100644 --- a/src/classes/atomtype.cpp +++ b/src/classes/atomtype.cpp @@ -169,7 +169,7 @@ void Atomtype::setElements(const char *ellist, Forcefield *ff) else { // WATCH Since Atomtype::el became Atomtype::characterElement_, this does not get set. Should it have been set before? WATCH - el = elements.find(parser.argc(n),ZM_ALPHA); + el = elements.find(parser.argc(n),Prefs::AlphaZmap); if (el == 0) { nAllowedElements_ --; diff --git a/src/classes/energystore.cpp b/src/classes/energystore.cpp index 7ad6cc9f5..c097013ef 100644 --- a/src/classes/energystore.cpp +++ b/src/classes/energystore.cpp @@ -298,7 +298,7 @@ void EnergyStore::print() dbgEnd(Debug::Calls,"EnergyStore::print"); return; } - msg(Debug::None,"Energy (%s):\n",text_from_EU(prefs.energyUnit())); + msg(Debug::None,"Energy (%s):\n",Prefs::energyUnitKeyword(prefs.energyUnit())); msg(Debug::None," Bond : %13.6f\n",totBond_); msg(Debug::None," Angle : %13.6f\n",totAngle_); msg(Debug::None,"Torsion : %13.6f\n",totTorsion_); @@ -318,7 +318,7 @@ void EnergyStore::printSummary() dbgEnd(Debug::Calls,"EnergyStore::printSummary"); return; } - msg(Debug::None,"Etot = %13.6e %s, b a t = %13.6e %13.6e %13.6e v = %13.6e e = %13.6e\n", total_, text_from_EU(prefs.energyUnit()), totBond_, totAngle_, totTorsion_, totVdw_, totElec_); + msg(Debug::None,"Etot = %13.6e %s, b a t = %13.6e %13.6e %13.6e v = %13.6e e = %13.6e\n", total_, Prefs::energyUnitKeyword(prefs.energyUnit()), totBond_, totAngle_, totTorsion_, totVdw_, totElec_); dbgEnd(Debug::Calls,"EnergyStore::printSummary"); } @@ -332,7 +332,7 @@ void EnergyStore::printEwald() dbgEnd(Debug::Calls,"EnergyStore::printEwald"); return; } - msg(Debug::None,"Ewald Energy (%s):\n",text_from_EU(prefs.energyUnit())); + msg(Debug::None,"Ewald Energy (%s):\n",Prefs::energyUnitKeyword(prefs.energyUnit())); msg(Debug::None," Real : %13.6f\n",totEwaldReal_); msg(Debug::None,"Recip : %13.6f\n",totEwaldRecip_); msg(Debug::None," Self : %13.6f\n",totEwaldSelf_); diff --git a/src/classes/forcefield.cpp b/src/classes/forcefield.cpp index 087281128..807fd3d2f 100644 --- a/src/classes/forcefield.cpp +++ b/src/classes/forcefield.cpp @@ -565,7 +565,7 @@ ForcefieldBound *Forcefield::findTorsion(ForcefieldAtom *ffi, ForcefieldAtom *ff return result; } -void Forcefield::convertParameters(EnergyUnit ff_eunit) +void Forcefield::convertParameters(Prefs::EnergyUnit ff_eunit) { // Convert units of all the energetic parameters within the forcefield from the unit supplied into program internal units (specified in prefs) // Check for 'NULL' pointers for ff_param variables (for e.g. rule-based forcefields) diff --git a/src/classes/forcefield.h b/src/classes/forcefield.h index 3196f2ef8..e52c4d3a4 100644 --- a/src/classes/forcefield.h +++ b/src/classes/forcefield.h @@ -333,7 +333,7 @@ class Forcefield */ public: // Convert the parameters in the FF to the internal working energy unit - void convertParameters(EnergyUnit); + void convertParameters(Prefs::EnergyUnit); // Get the bond order of the bond ij (here for convenience) double bondOrder(Atom*, Atom*); }; diff --git a/src/command/atom.cpp b/src/command/atom.cpp index 58b250aac..5cb2eacb6 100644 --- a/src/command/atom.cpp +++ b/src/command/atom.cpp @@ -99,7 +99,7 @@ int CommandData::function_CA_NEWATOMFRAC(Command *&c, Bundle &obj) int CommandData::function_CA_CHAIN(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; - Atom *i = obj.m->addAtom(elements.find(c->argc(0),ZM_ALPHA), c->parent()->penPosition); + Atom *i = obj.m->addAtom(elements.find(c->argc(0),Prefs::AlphaZmap), c->parent()->penPosition); if (obj.i != NULL) obj.m->bondAtoms(obj.i,i,Bond::Single); master.current.i = i; return CR_SUCCESS; diff --git a/src/command/bonds.cpp b/src/command/bonds.cpp index 61452696b..d7e8a9f8d 100644 --- a/src/command/bonds.cpp +++ b/src/command/bonds.cpp @@ -83,7 +83,7 @@ int CommandData::function_CA_REBOND(Command *&c, Bundle &obj) obj.m->clearBonding(); obj.m->calculateBonding(); } - else if (prefs.bondOnLoad() != PS_NO) + else if (prefs.bondOnLoad() != Prefs::SwitchOff) { obj.m->clearBonding(); obj.m->calculateBonding(); diff --git a/src/command/cell.cpp b/src/command/cell.cpp index 8307992c5..be366e847 100644 --- a/src/command/cell.cpp +++ b/src/command/cell.cpp @@ -29,7 +29,7 @@ int CommandData::function_CA_FOLD(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; if (c->parent()->inputFile() == NULL) obj.m->foldAllAtoms(); - else if (prefs.foldOnLoad() != PS_NO) obj.m->foldAllAtoms(); + else if (prefs.foldOnLoad() != Prefs::SwitchOff) obj.m->foldAllAtoms(); return CR_SUCCESS; } @@ -46,7 +46,7 @@ int CommandData::function_CA_PACK(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; if (c->parent()->inputFile() == NULL) obj.m->pack(); - else if (prefs.packOnLoad() != PS_NO) obj.m->pack(); + else if (prefs.packOnLoad() != Prefs::SwitchOff) obj.m->pack(); return CR_SUCCESS; } diff --git a/src/command/charge.cpp b/src/command/charge.cpp index 439a82b14..b09a6d09d 100644 --- a/src/command/charge.cpp +++ b/src/command/charge.cpp @@ -28,7 +28,7 @@ int CommandData::function_CA_CHARGEFF(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; - obj.m->assignCharges(QS_FF); + obj.m->assignForcefieldCharges(); return CR_SUCCESS; } diff --git a/src/command/commands.h b/src/command/commands.h index 04638e4dd..47f19e6e9 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -369,7 +369,7 @@ class CommandData */ private: // Provide full access to the master - friend class MasterData; + friend class Master; // All command functions int function_CA_ROOTNODE(Command *&c, Bundle &obj); // Analyse commands diff --git a/src/command/functions.cpp b/src/command/functions.cpp index f818dfd00..ae2940aa4 100644 --- a/src/command/functions.cpp +++ b/src/command/functions.cpp @@ -23,7 +23,7 @@ #include "base/master.h" // Initialise Command Pointers -void MasterData::initCommands() +void Master::initCommands() { /* // Store pointers to all command functions diff --git a/src/command/prefs.cpp b/src/command/prefs.cpp index 423646837..00358ad19 100644 --- a/src/command/prefs.cpp +++ b/src/command/prefs.cpp @@ -46,8 +46,8 @@ int CommandData::function_CA_BONDDETAIL(Command *&c, Bundle &obj) // Colours int CommandData::function_CA_COLOUR(Command *&c, Bundle &obj) { - Colour col = COL_from_text(c->argc(0)); - if (col == COL_NITEMS) return CR_FAIL; + Prefs::Colour col = Prefs::colour(c->argc(0)); + if (col == Prefs::nColours) return CR_FAIL; Vec3 colvec = c->arg3f(1); GLfloat alpha = (c->hasArg(4) ? (GLfloat) c->argd(4) : 1.0f); prefs.setColour(col, colvec.x, colvec.y, colvec.z, alpha); @@ -59,8 +59,8 @@ int CommandData::function_CA_COLOUR(Command *&c, Bundle &obj) // Set density unit to use in output ('densityunits ') int CommandData::function_CA_DENSITYUNITS(Command *&c, Bundle &obj) { - DensityUnit du = DU_from_text(c->argc(0)); - if (du == DU_NITEMS) return CR_FAIL; + Prefs::DensityUnit du = Prefs::densityUnit(c->argc(0)); + if (du == Prefs::nDensityUnits) return CR_FAIL; else prefs.setDensityUnits(du); return CR_SUCCESS; } @@ -134,8 +134,8 @@ int CommandData::function_CA_ELEMENTRADIUS(Command *&c, Bundle &obj) // Set energy unit to use in output ('energyunits ') int CommandData::function_CA_ENERGYUNITS(Command *&c, Bundle &obj) { - EnergyUnit eu = EU_from_text(c->argc(0)); - if (eu == EU_NITEMS) return CR_FAIL; + Prefs::EnergyUnit eu = Prefs::energyUnit(c->argc(0)); + if (eu == Prefs::nEnergyUnits) return CR_FAIL; else prefs.setEnergyUnit(eu); return CR_SUCCESS; } @@ -143,8 +143,8 @@ int CommandData::function_CA_ENERGYUNITS(Command *&c, Bundle &obj) // GL Options int CommandData::function_CA_GL(Command *&c, Bundle &obj) { - GlOption go = GO_from_text(c->argc(0)); - if (go == GO_NITEMS) return CR_FAIL; + Prefs::GlOption go = Prefs::glOption(c->argc(0)); + if (go == Prefs::nGlOptions) return CR_FAIL; if (c->argb(1)) prefs.addGlOption(go); else prefs.removeGlOption(go); if (gui.exists()) gui.mainView.initGl(); @@ -163,9 +163,9 @@ int CommandData::function_CA_INTRA(Command *&c, Bundle &obj) // Key bindings int CommandData::function_CA_KEY(Command *&c, Bundle &obj) { - ModifierKey mk = MK_from_text(c->argc(0)); - KeyAction ka = KA_from_text(c->argc(1)); - if ((mk != MK_NITEMS) && (ka != KA_NITEMS)) prefs.setKeyAction(mk,ka); + Prefs::ModifierKey mk = Prefs::modifierKey(c->argc(0)); + Prefs::KeyAction ka = Prefs::keyAction(c->argc(1)); + if ((mk != Prefs::nModifierKeys) && (ka != Prefs::nKeyActions)) prefs.setKeyAction(mk,ka); else return CR_FAIL; return CR_SUCCESS; } @@ -173,9 +173,9 @@ int CommandData::function_CA_KEY(Command *&c, Bundle &obj) // Mouse bindings int CommandData::function_CA_MOUSE(Command *&c, Bundle &obj) { - MouseButton mb = MB_from_text(c->argc(0)); - MouseAction ma = MA_from_text(c->argc(1)); - if ((ma != MA_NITEMS) && (mb != MB_NITEMS)) prefs.setMouseAction(mb,ma); + Prefs::MouseButton mb = Prefs::mouseButton(c->argc(0)); + Prefs::MouseAction ma = Prefs::mouseAction(c->argc(1)); + if ((ma != Prefs::nMouseActions) && (mb != Prefs::nMouseButtons)) prefs.setMouseAction(mb,ma); else return CR_FAIL; return CR_SUCCESS; } @@ -201,8 +201,8 @@ int CommandData::function_CA_SHININESS(Command *&c, Bundle &obj) // Render Objects int CommandData::function_CA_SHOW(Command *&c, Bundle &obj) { - ViewObject vo = VO_from_text(c->argc(0)); - if (vo != VO_NITEMS) + Prefs::ViewObject vo = Prefs::viewObject(c->argc(0)); + if (vo != Prefs::nViewObjects) { prefs.setVisible(vo, c->argb(1)); if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); diff --git a/src/command/select.cpp b/src/command/select.cpp index 56fa0e5b8..ae6985439 100644 --- a/src/command/select.cpp +++ b/src/command/select.cpp @@ -49,7 +49,7 @@ int CommandData::function_CA_SELECTATOM(Command *&c, Bundle &obj) int CommandData::function_CA_SELECTELEMENT(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; - int el = elements.find(c->argc(0), ZM_ALPHA); + int el = elements.find(c->argc(0), Prefs::AlphaZmap); for (Atom *i = obj.m->atoms(); i != NULL; i = i->next) if (i->element() == el) obj.m->selectAtom(i); return CR_SUCCESS; } diff --git a/src/command/system.cpp b/src/command/system.cpp index 6fbec014e..af0729433 100644 --- a/src/command/system.cpp +++ b/src/command/system.cpp @@ -28,11 +28,11 @@ int CommandData::function_CA_GUI(Command *&c, Bundle &obj) { // If we're in interactive mode, just set program mode and let main.cpp handle it. - if (master.programMode() == PM_INTERACTIVE) master.setProgramMode(PM_GUI); + if (master.programMode() == Master::InteractiveMode) master.setProgramMode(Master::GuiMode); else if (!gui.exists()) { // Set program mode and start gui - master.setProgramMode(PM_GUI); + master.setProgramMode(Master::GuiMode); // Add empty model if none were specified on the command line if (master.nModels() == 0) Model *m = master.addModel(); gui.run(0, NULL); @@ -61,7 +61,7 @@ int CommandData::function_CA_SEED(Command *&c, Bundle &obj) int CommandData::function_CA_QUIT(Command *&c, Bundle &obj) { // Set program mode here, in case we are running in PM_COMMAND - master.setProgramMode(PM_NONE); + master.setProgramMode(Master::NoMode); // If the GUI is active, close it... if (gui.exists()) gui.saveBeforeClose(); return CR_EXIT; diff --git a/src/command/transform.cpp b/src/command/transform.cpp index f2d1bb0bc..e511969e8 100644 --- a/src/command/transform.cpp +++ b/src/command/transform.cpp @@ -28,7 +28,7 @@ int CommandData::function_CA_CENTRE(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; if (c->parent()->inputFile() == NULL) obj.m->centre(c->arg3d(0)); - else if (prefs.centreOnLoad() != PS_NO) obj.m->centre(c->arg3d(0)); + else if (prefs.centreOnLoad() != Prefs::SwitchOff) obj.m->centre(c->arg3d(0)); return CR_SUCCESS; } diff --git a/src/energy/ewald.cpp b/src/energy/ewald.cpp index e7ece9523..8feab40d2 100644 --- a/src/energy/ewald.cpp +++ b/src/energy/ewald.cpp @@ -34,13 +34,13 @@ #include "base/mathfunc.h" #include "model/model.h" -void PrefsData::estimateEwaldParameters(Cell *cell) +void Prefs::estimateEwaldParameters(Cell *cell) { // Estimate alpha and kmax parameters based on a given precision value - dbgBegin(Debug::Calls,"PrefsData::estimateEwaldParameterss"); + dbgBegin(Debug::Calls,"Prefs::estimateEwaldParameterss"); if (prefs.hasValidEwaldAuto()) { - dbgEnd(Debug::Calls,"PrefsData::estimateEwaldParameters"); + dbgEnd(Debug::Calls,"Prefs::estimateEwaldParameters"); return; } // Estimate ewaldAlpha_ @@ -63,7 +63,7 @@ void PrefsData::estimateEwaldParameters(Cell *cell) } msg(Debug::None,"Pattern::ewald_estimate_parameters : For precision = %6.4e, alpha = %8.6f and kmax = %i %i %i.\n", ewaldPrecision_, ewaldAlpha_, ewaldKvec_.x, ewaldKvec_.y, ewaldKvec_.z); validEwaldAuto_ = TRUE; - dbgEnd(Debug::Calls,"PrefsData::estimateEwaldParameters"); + dbgEnd(Debug::Calls,"Prefs::estimateEwaldParameters"); } // Ewald Energy Real-space contributions diff --git a/src/gui/canvas.cpp b/src/gui/canvas.cpp index 0a4648aa6..01f3abaae 100644 --- a/src/gui/canvas.cpp +++ b/src/gui/canvas.cpp @@ -183,7 +183,7 @@ void Canvas::initGl() createLists(); // Clear colour - GLfloat *clrcol = prefs.colour(COL_BG); + GLfloat *clrcol = prefs.colour(Prefs::BackgroundColour); glClearColor(clrcol[0],clrcol[1],clrcol[2],clrcol[3]); glClearDepth(1.0); // Perspective hint @@ -199,32 +199,32 @@ void Canvas::initGl() //glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); // Set up the light model glEnable(GL_LIGHTING); - glLightfv(GL_LIGHT0,GL_AMBIENT,prefs.spotlightColour(SL_AMBIENT)); - glLightfv(GL_LIGHT0,GL_DIFFUSE,prefs.spotlightColour(SL_DIFFUSE)); - glLightfv(GL_LIGHT0,GL_SPECULAR,prefs.spotlightColour(SL_SPECULAR)); + glLightfv(GL_LIGHT0,GL_AMBIENT,prefs.spotlightColour(Prefs::AmbientComponent)); + glLightfv(GL_LIGHT0,GL_DIFFUSE,prefs.spotlightColour(Prefs::DiffuseComponent)); + glLightfv(GL_LIGHT0,GL_SPECULAR,prefs.spotlightColour(Prefs::SpecularComponent)); glLightfv(GL_LIGHT0,GL_POSITION,prefs.spotlightPosition()); prefs.spotlightActive() ? glEnable(GL_LIGHT0) : glDisable(GL_LIGHT0); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); // Configure antialiasing - if (prefs.hasGlOption(GO_LINEALIASING)) + if (prefs.hasGlOption(Prefs::LineAliasOption)) { glEnable(GL_BLEND); glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); glEnable(GL_LINE_SMOOTH); } - if (prefs.hasGlOption(GO_POLYALIASING)) + if (prefs.hasGlOption(Prefs::PolyAliasOption)) { glEnable(GL_BLEND); glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST); glEnable(GL_POLYGON_SMOOTH); } // Configure fog effects - if (prefs.hasGlOption(GO_FOG)) + if (prefs.hasGlOption(Prefs::FogOption)) { glFogi(GL_FOG_MODE, GL_LINEAR); - glFogfv(GL_FOG_COLOR, prefs.colour(COL_BG)); + glFogfv(GL_FOG_COLOR, prefs.colour(Prefs::BackgroundColour)); glFogf(GL_FOG_DENSITY, 0.35f); glHint(GL_FOG_HINT, GL_NICEST); glFogf(GL_FOG_START,prefs.fogNear()); @@ -234,7 +234,7 @@ void Canvas::initGl() else glDisable(GL_FOG); // Configure face culling glCullFace(GL_BACK); - prefs.hasGlOption(GO_BACKCULLING) ? glEnable( GL_CULL_FACE ) : glDisable(GL_CULL_FACE); + prefs.hasGlOption(Prefs::BackCullOption) ? glEnable( GL_CULL_FACE ) : glDisable(GL_CULL_FACE); // Test // End Test endGl(); diff --git a/src/gui/canvas.h b/src/gui/canvas.h index 368264b12..edf149117 100644 --- a/src/gui/canvas.h +++ b/src/gui/canvas.h @@ -244,17 +244,17 @@ class Canvas // Selected interaction mode (from GUI) UserAction selectedMode_; // Button flags (uses enum 'MouseButton') - bool mouseButton_[MB_NITEMS]; + bool mouseButton_[Prefs::nMouseButtons]; // Key flags (uses enum 'ModifierKey') - bool keyModifier_[MK_NITEMS]; + bool keyModifier_[Prefs::nModifierKeys]; // Begin an action on the model (called from MouseButtondown) - void beginMode(MouseButton); + void beginMode(Prefs::MouseButton); // Handle mouse motion while performing actions void modeMotion(double, double); // Handle mousewheel scroll events void modeScroll(bool); // End an action on the model (called from MouseButtonup) - void endMode(MouseButton); + void endMode(Prefs::MouseButton); // Whether the mouse has moved between begin_mode() and end_mode() calls bool hasMoved_; @@ -266,9 +266,9 @@ class Canvas // Return the currently selected mode UserAction selectedMode(); // Inform the canvas of a mouse down event - void informMouseDown(MouseButton, double, double); + void informMouseDown(Prefs::MouseButton, double, double); // Inform the canvas of a mouse up event - void informMouseUp(MouseButton, double, double); + void informMouseUp(Prefs::MouseButton, double, double); // Inform the canvas of a mouse move event void informMouseMove(double, double); // Inform the canvas of a mouse wheel scroll event diff --git a/src/gui/disorder_funcs.cpp b/src/gui/disorder_funcs.cpp index c187c7e55..eeb24dfb3 100644 --- a/src/gui/disorder_funcs.cpp +++ b/src/gui/disorder_funcs.cpp @@ -196,7 +196,7 @@ void AtenForm::on_ComponentRegionCombo_currentIndexChanged(int index) void AtenForm::on_ShowRegionsCheck_clicked(bool checked) { - prefs.setVisible(VO_REGIONS, checked); + prefs.setVisible(Prefs::ViewRegions, checked); gui.mainView.postRedisplay(); } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index bc08a790b..d78df55a6 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -169,8 +169,8 @@ void GuiQt::updateLabels() s += ftoa(m->density()); switch (prefs.densityUnit()) { - case (DU_GPERCM): s += " g cm-3)"; break; - case (DU_ATOMSPERANG): s += " atoms Å-3)"; break; + case (Prefs::GramsPerCm): s += " g cm-3)"; break; + case (Prefs::AtomsPerAngstrom): s += " atoms Å-3)"; break; } } mainWindow->statusLabel->setText(s); diff --git a/src/gui/input.cpp b/src/gui/input.cpp index 05401dd34..50901053f 100644 --- a/src/gui/input.cpp +++ b/src/gui/input.cpp @@ -25,12 +25,8 @@ #include "gui/canvas.h" #include "model/model.h" -// Static variables -//bool Canvas::mouseAction_[MB_NITEMS]; -//bool Canvas::keyModifier_[MK_NITEMS]; - // Inform mouse down -void Canvas::informMouseDown(MouseButton button, double x, double y) +void Canvas::informMouseDown(Prefs::MouseButton button, double x, double y) { rMouseDown_.set(x,y,0.0); rMouseUp_.set(x,y,0.0); @@ -52,7 +48,7 @@ void Canvas::informMouseDown(MouseButton button, double x, double y) } // Inform mouse up -void Canvas::informMouseUp(MouseButton button, double x, double y) +void Canvas::informMouseUp(Prefs::MouseButton button, double x, double y) { // Only finalise the mode if the button is the same as the one that caused the mousedown event. if (mouseButton_[button]) @@ -90,22 +86,22 @@ void Canvas::informKeyDown(key_code key) switch (key) { case (KC_SHIFT_L): - keyModifier_[MK_SHIFT] = TRUE; + keyModifier_[Prefs::ShiftKey] = TRUE; break; case (KC_SHIFT_R): - keyModifier_[MK_SHIFT] = TRUE; + keyModifier_[Prefs::ShiftKey] = TRUE; break; case (KC_CONTROL_L): - keyModifier_[MK_CTRL] = TRUE; + keyModifier_[Prefs::CtrlKey] = TRUE; break; case (KC_CONTROL_R): - keyModifier_[MK_CTRL] = TRUE; + keyModifier_[Prefs::CtrlKey] = TRUE; break; case (KC_ALT_L): - keyModifier_[MK_ALT] = TRUE; + keyModifier_[Prefs::AltKey] = TRUE; break; case (KC_ALT_R): - keyModifier_[MK_ALT] = TRUE; + keyModifier_[Prefs::AltKey] = TRUE; break; //case (GDK_Escape): master.check_before_close(); break; case (KC_LEFT): @@ -133,22 +129,22 @@ void Canvas::informKeyUp(key_code key) switch (key) { case (KC_SHIFT_L): - keyModifier_[MK_SHIFT] = FALSE; + keyModifier_[Prefs::ShiftKey] = FALSE; break; case (KC_SHIFT_R): - keyModifier_[MK_SHIFT] = FALSE; + keyModifier_[Prefs::ShiftKey] = FALSE; break; case (KC_CONTROL_L): - keyModifier_[MK_CTRL] = FALSE; + keyModifier_[Prefs::CtrlKey] = FALSE; break; case (KC_CONTROL_R): - keyModifier_[MK_CTRL] = FALSE; + keyModifier_[Prefs::CtrlKey] = FALSE; break; case (KC_ALT_L): - keyModifier_[MK_ALT] = FALSE; + keyModifier_[Prefs::AltKey] = FALSE; break; case (KC_ALT_R): - keyModifier_[MK_ALT] = FALSE; + keyModifier_[Prefs::AltKey] = FALSE; break; } } @@ -190,7 +186,7 @@ void Canvas::setSelectedMode(UserAction ua) } // Begin Mode -void Canvas::beginMode(MouseButton button) +void Canvas::beginMode(Prefs::MouseButton button) { dbgBegin(Debug::Calls,"widgetCanvas::beginMode"); static bool manipulate, zrotate; @@ -216,12 +212,12 @@ void Canvas::beginMode(MouseButton button) { if (keyModifier_[n]) { - switch (prefs.keyAction((ModifierKey(n)))) + switch (prefs.keyAction(Prefs::ModifierKey(n))) { - case (KA_MANIPULATE): + case (Prefs::ManipulateKeyAction): manipulate = TRUE; break; - case (KA_ZROTATE): + case (Prefs::ZrotateKeyAction): zrotate = TRUE; break; } @@ -233,7 +229,7 @@ void Canvas::beginMode(MouseButton button) switch (prefs.mouseAction(button)) { // Main interactor - selection, sketching, measuring - case (MA_INTERACT): + case (Prefs::InteractAction): useSelectedMode(); // Some modes require actions to be done when the button is first depressed switch (activeMode_) @@ -251,17 +247,17 @@ void Canvas::beginMode(MouseButton button) break; } break; - case (MA_VIEWROTATE): + case (Prefs::RotateAction): // Check for multiple key modifiers first. if (manipulate && zrotate) activeMode_ = UA_MANIPROTZ; else if (manipulate) activeMode_ = UA_MANIPROTXY; else if (zrotate) activeMode_ = UA_ROTATEZ; else activeMode_ = UA_ROTATEXY; break; - case (MA_VIEWZOOM): + case (Prefs::ZoomAction): activeMode_ = UA_ZOOMCAM; break; - case (MA_VIEWTRANSLATE): + case (Prefs::TranslateAction): activeMode_ = UA_MOVECAM; manipulate ? activeMode_ = UA_MANIPTRANS : activeMode_ = UA_MOVECAM; break; @@ -282,7 +278,7 @@ void Canvas::beginMode(MouseButton button) } // End Mode -void Canvas::endMode(MouseButton button) +void Canvas::endMode(Prefs::MouseButton button) { // Finalize the current action on the model dbgBegin(Debug::Calls,"Canvas::endMode"); @@ -309,11 +305,11 @@ void Canvas::endMode(MouseButton button) area = fabs(rMouseUp_.x - rMouseDown_.x) * fabs(rMouseUp_.y - rMouseDown_.y); displayModel_->beginUndostate("Change Selection"); // If SHIFT is not held down, deselect the current selection - if (!keyModifier_[MK_SHIFT]) displayModel_->selectNone(); + if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); // Do either point select or box select based on the size of the selected area if (area < 100.0) { - if (keyModifier_[MK_SHIFT]) + if (keyModifier_[Prefs::ShiftKey]) { if (atomHover_ != NULL) displayModel_->selectionToggle(atomHover_); } @@ -325,19 +321,19 @@ void Canvas::endMode(MouseButton button) // Now do the rest case (UA_PICKFRAG): displayModel_->beginUndostate("Select Molecule"); - if (!keyModifier_[MK_SHIFT]) displayModel_->selectNone(); + if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); if (atomHover_ != NULL) displayModel_->selectTree(atomHover_); displayModel_->endUndostate(); break; case (UA_PICKELEMENT): displayModel_->beginUndostate("Select Element"); - if (!keyModifier_[MK_SHIFT]) displayModel_->selectNone(); + if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); if (atomHover_ != NULL) displayModel_->selectElement(atomHover_); displayModel_->endUndostate(); break; case (UA_PICKRADIAL): displayModel_->beginUndostate("Select Radial"); - if (!keyModifier_[MK_SHIFT]) displayModel_->selectNone(); + if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); if (atomHover_ != NULL) { radius = (rMouseDown_-rMouseUp_).magnitude(); @@ -559,19 +555,19 @@ void Canvas::modeScroll(bool scrollup) // For view operations when we have a trajectory, apply all movement to the parent model viewtarget = displayModel_->trajectoryParent(); if (viewtarget == NULL) viewtarget = displayModel_; - switch (prefs.mouseAction(MB_WHEEL)) + switch (prefs.mouseAction(Prefs::WheelButton)) { - case (MA_NONE): + case (Prefs::NoAction): break; - case (MA_INTERACT): + case (Prefs::InteractAction): useSelectedMode(); break; - case (MA_VIEWROTATE): + case (Prefs::RotateAction): scrollup ? viewtarget->rotate(1.0,0.0) : viewtarget->rotate(-1.0,0.0); break; - case (MA_VIEWTRANSLATE): + case (Prefs::TranslateAction): break; - case (MA_VIEWZOOM): + case (Prefs::ZoomAction): if (prefs.hasPerspective()) scrollup ? viewtarget->adjustCamera(0.0,0.0,-5.0,0.0) : viewtarget->adjustCamera(0.0,0.0,5.0,0.0); else scrollup ? viewtarget->adjustOrthoSize(1.0) : viewtarget->adjustOrthoSize(-1.0); diff --git a/src/gui/mainwindow_funcs.cpp b/src/gui/mainwindow_funcs.cpp index 4d12db2f4..a4b755916 100644 --- a/src/gui/mainwindow_funcs.cpp +++ b/src/gui/mainwindow_funcs.cpp @@ -333,17 +333,17 @@ void AtenForm::runScript() */ void AtenForm::on_actionMouseInteract_triggered(bool checked) { - prefs.setMouseAction(MB_LEFT, MA_INTERACT); + prefs.setMouseAction(Prefs::LeftButton, Prefs::InteractAction); } void AtenForm::on_actionMouseRotate_triggered(bool checked) { - prefs.setMouseAction(MB_LEFT, MA_VIEWROTATE); + prefs.setMouseAction(Prefs::LeftButton, Prefs::RotateAction); } void AtenForm::on_actionMouseTranslate_triggered(bool checked) { - prefs.setMouseAction(MB_LEFT, MA_VIEWTRANSLATE); + prefs.setMouseAction(Prefs::LeftButton, Prefs::TranslateAction); } /* diff --git a/src/gui/prefs.h b/src/gui/prefs.h index 690e4cc69..28d054746 100644 --- a/src/gui/prefs.h +++ b/src/gui/prefs.h @@ -45,7 +45,7 @@ class AtenPrefs : public QDialog private: void updateAfterViewPrefs(); void setRadiusChanged(Atom::DrawStyle ds, double value); - void setVisibleObject(ViewObject vo, int state); + void setVisibleObject(Prefs::ViewObject vo, int state); private slots: void on_StickRadiusSpin_valueChanged(double value); void on_TubeRadiusSpin_valueChanged(double value); @@ -65,7 +65,7 @@ class AtenPrefs : public QDialog */ private: void spotlightPosChanged(int i, double value); - void spotlightColourChanged(SpotlightComponent); + void spotlightColourChanged(Prefs::ColourComponent); private slots: void on_SpotlightGroup_clicked(bool checked); void on_SpotlightAmbientColourButton_clicked(bool checked); diff --git a/src/gui/prefs_funcs.cpp b/src/gui/prefs_funcs.cpp index b6f7f463c..de0399ca2 100644 --- a/src/gui/prefs_funcs.cpp +++ b/src/gui/prefs_funcs.cpp @@ -68,29 +68,29 @@ void AtenPrefs::setControls() ui.SelectionScaleSpin->setValue(prefs.selectionScale()); ui.AtomQualitySpin->setValue(prefs.atomDetail()); ui.BondQualitySpin->setValue(prefs.bondDetail()); - ui.GlobeVisibleCheck->setChecked(prefs.shouldRender(VO_GLOBE)); - ui.CellVisibleCheck->setChecked(prefs.shouldRender(VO_CELL)); - ui.AxesVisibleCheck->setChecked(prefs.shouldRender(VO_CELLAXES)); - ui.AtomsVisibleCheck->setChecked(prefs.shouldRender(VO_ATOMS)); + ui.GlobeVisibleCheck->setChecked(prefs.shouldRender(Prefs::ViewGlobe)); + ui.CellVisibleCheck->setChecked(prefs.shouldRender(Prefs::ViewCell)); + ui.AxesVisibleCheck->setChecked(prefs.shouldRender(Prefs::ViewCellAXES)); + ui.AtomsVisibleCheck->setChecked(prefs.shouldRender(Prefs::ViewAtoms)); ui.ShininessSpin->setValue(prefs.shininess()); // Set controls in Lighting page - ui.SpotlightAmbientColourFrame->setColour(prefs.spotlightColour(SL_AMBIENT)); - ui.SpotlightDiffuseColourFrame->setColour(prefs.spotlightColour(SL_DIFFUSE)); - ui.SpotlightSpecularColourFrame->setColour(prefs.spotlightColour(SL_SPECULAR)); + ui.SpotlightAmbientColourFrame->setColour(prefs.spotlightColour(Prefs::AmbientComponent)); + ui.SpotlightDiffuseColourFrame->setColour(prefs.spotlightColour(Prefs::DiffuseComponent)); + ui.SpotlightSpecularColourFrame->setColour(prefs.spotlightColour(Prefs::SpecularComponent)); GLfloat *pos = prefs.spotlightPosition(); ui.SpotlightPositionXSpin->setValue(pos[0]); ui.SpotlightPositionYSpin->setValue(pos[1]); ui.SpotlightPositionZSpin->setValue(pos[2]); // Set controls in interaction page - ui.LeftMouseCombo->setCurrentIndex(prefs.mouseAction(MB_LEFT)); - ui.MiddleMouseCombo->setCurrentIndex(prefs.mouseAction(MB_MIDDLE)); - ui.RightMouseCombo->setCurrentIndex(prefs.mouseAction(MB_RIGHT)); - ui.WheelMouseCombo->setCurrentIndex(prefs.mouseAction(MB_WHEEL)); - ui.ShiftButtonCombo->setCurrentIndex(prefs.keyAction(MK_SHIFT)); - ui.CtrlButtonCombo->setCurrentIndex(prefs.keyAction(MK_CTRL)); - ui.AltButtonCombo->setCurrentIndex(prefs.keyAction(MK_ALT)); + ui.LeftMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::LeftButton)); + ui.MiddleMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::MiddleButton)); + ui.RightMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::RightButton)); + ui.WheelMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::WheelButton)); + ui.ShiftButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::ShiftKey)); + ui.CtrlButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::CtrlKey)); + ui.AltButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::AltKey)); dbgBegin(Debug::Calls,"AtenPrefs::setControls"); } @@ -211,7 +211,7 @@ void AtenPrefs::on_BondQualitySpin_valueChanged(int value) updateAfterViewPrefs(); } -void AtenPrefs::setVisibleObject(ViewObject vo, int state) +void AtenPrefs::setVisibleObject(Prefs::ViewObject vo, int state) { prefs.setVisible(vo, (state == Qt::Checked ? TRUE : FALSE)); master.currentModel()->logChange(LOG_VISUAL); @@ -220,22 +220,22 @@ void AtenPrefs::setVisibleObject(ViewObject vo, int state) void AtenPrefs::on_AtomsVisibleCheck_stateChanged(int state) { - setVisibleObject(VO_ATOMS, state); + setVisibleObject(Prefs::ViewAtoms, state); } void AtenPrefs::on_CellVisibleCheck_stateChanged(int state) { - setVisibleObject(VO_CELL, state); + setVisibleObject(Prefs::ViewCell, state); } void AtenPrefs::on_AxesVisibleCheck_stateChanged(int state) { - setVisibleObject(VO_CELLAXES, state); + setVisibleObject(Prefs::ViewCellAXES, state); } void AtenPrefs::on_GlobeVisibleCheck_stateChanged(int state) { - setVisibleObject(VO_GLOBE, state); + setVisibleObject(Prefs::ViewGlobe, state); } /* @@ -271,7 +271,7 @@ void AtenPrefs::on_SpotlightPositionZSpin_valueChanged(double value) spotlightPosChanged(2, value); } -void AtenPrefs::spotlightColourChanged(SpotlightComponent sc) +void AtenPrefs::spotlightColourChanged(Prefs::ColourComponent sc) { // Get current component colour and convert it to a QColor GLfloat *col = prefs.spotlightColour(sc); @@ -282,9 +282,9 @@ void AtenPrefs::spotlightColourChanged(SpotlightComponent sc) // Store new colour prefs.setSpotlightColour(sc, newcol.redF(), newcol.greenF(), newcol.blueF()); TColourFrame *colframe; - if (sc == SL_AMBIENT) colframe = ui.SpotlightAmbientColourFrame; - else if (sc == SL_DIFFUSE) colframe = ui.SpotlightDiffuseColourFrame; - else if (sc == SL_SPECULAR) colframe = ui.SpotlightSpecularColourFrame; + if (sc == Prefs::AmbientComponent) colframe = ui.SpotlightAmbientColourFrame; + else if (sc == Prefs::DiffuseComponent) colframe = ui.SpotlightDiffuseColourFrame; + else if (sc == Prefs::SpecularComponent) colframe = ui.SpotlightSpecularColourFrame; colframe->setColour(newcol); colframe->update(); // Update display @@ -294,17 +294,17 @@ void AtenPrefs::spotlightColourChanged(SpotlightComponent sc) void AtenPrefs::on_SpotlightAmbientColourButton_clicked(bool checked) { - spotlightColourChanged(SL_AMBIENT); + spotlightColourChanged(Prefs::AmbientComponent); } void AtenPrefs::on_SpotlightDiffuseColourButton_clicked(bool checked) { - spotlightColourChanged(SL_DIFFUSE); + spotlightColourChanged(Prefs::DiffuseComponent); } void AtenPrefs::on_SpotlightSpecularColourButton_clicked(bool checked) { - spotlightColourChanged(SL_SPECULAR); + spotlightColourChanged(Prefs::SpecularComponent); } void AtenPrefs::on_ShininessSpin_valueChanged(int value) @@ -320,35 +320,35 @@ void AtenPrefs::on_ShininessSpin_valueChanged(int value) void AtenPrefs::on_LeftMouseCombo_currentIndexChanged(int ma) { - prefs.setMouseAction(MB_LEFT, (MouseAction) ma); + prefs.setMouseAction(Prefs::LeftButton, (Prefs::MouseAction) ma); } void AtenPrefs::on_MiddleMouseCombo_currentIndexChanged(int ma) { - prefs.setMouseAction(MB_MIDDLE, (MouseAction) ma); + prefs.setMouseAction(Prefs::MiddleButton, (Prefs::MouseAction) ma); } void AtenPrefs::on_RightMouseCombo_currentIndexChanged(int ma) { - prefs.setMouseAction(MB_RIGHT, (MouseAction) ma); + prefs.setMouseAction(Prefs::RightButton, (Prefs::MouseAction) ma); } void AtenPrefs::on_WheelMouseCombo_currentIndexChanged(int ma) { - prefs.setMouseAction(MB_WHEEL, (MouseAction) ma); + prefs.setMouseAction(Prefs::WheelButton, (Prefs::MouseAction) ma); } void AtenPrefs::on_ShiftButtonCombo_currentIndexChanged(int ka) { - prefs.setKeyAction(MK_SHIFT, (KeyAction) ka); + prefs.setKeyAction(Prefs::ShiftKey, (Prefs::KeyAction) ka); } void AtenPrefs::on_CtrlButtonCombo_currentIndexChanged(int ka) { - prefs.setKeyAction(MK_CTRL, (KeyAction) ka); + prefs.setKeyAction(Prefs::CtrlKey, (Prefs::KeyAction) ka); } void AtenPrefs::on_AltButtonCombo_currentIndexChanged(int ka) { - prefs.setKeyAction(MK_ALT, (KeyAction) ka); + prefs.setKeyAction(Prefs::AltKey, (Prefs::KeyAction) ka); } diff --git a/src/gui/tcanvas_funcs.cpp b/src/gui/tcanvas_funcs.cpp index 7ba753c3b..5309fcd5e 100644 --- a/src/gui/tcanvas_funcs.cpp +++ b/src/gui/tcanvas_funcs.cpp @@ -69,10 +69,10 @@ void TCanvas::mousePressEvent(QMouseEvent *event) { // Handle button presses (button down) from the mouse dbgBegin(Debug::Calls,"TCanvas::mousePressEvent"); - MouseButton button; - if (event->button() == Qt::LeftButton) button = MB_LEFT; - else if (event->button() == Qt::MidButton) button = MB_MIDDLE; - else if (event->button() == Qt::RightButton) button = MB_RIGHT; + Prefs::MouseButton button; + if (event->button() == Qt::LeftButton) button = Prefs::LeftButton; + else if (event->button() == Qt::MidButton) button = Prefs::MiddleButton; + else if (event->button() == Qt::RightButton) button = Prefs::RightButton; else { dbgEnd(Debug::Calls,"TCanvas::mousePressEvent"); @@ -82,7 +82,7 @@ void TCanvas::mousePressEvent(QMouseEvent *event) // isn't currently in progress. Set the UserAction based on the mouse button that sent // the signal, current selection / draw modes and key modifier states. // Preliminary check to see if RMB was pressed over an atom - if so , show the popup menu and exit. - if (button == MB_RIGHT) + if (button == Prefs::RightButton) { Atom *tempi = master.currentModel()->atomOnScreen(event->x(), event->y()); if (tempi != NULL) @@ -94,7 +94,7 @@ void TCanvas::mousePressEvent(QMouseEvent *event) } } // If the left mouse button is double-clicked over an atom, show the atomlist window - if ((button == MB_LEFT) && (event->type() == QEvent::MouseButtonDblClick)) + if ((button == Prefs::LeftButton) && (event->type() == QEvent::MouseButtonDblClick)) { Atom *tempi = widgetCanvas_->atomHover(); if (tempi != NULL) @@ -114,10 +114,10 @@ void TCanvas::mouseReleaseEvent(QMouseEvent *event) { // Handle button releases (button up) from the mouse dbgBegin(Debug::Calls,"TCanvas::mouseReleaseEvent"); - MouseButton button; - if (event->button() == Qt::LeftButton) button = MB_LEFT; - else if (event->button() == Qt::MidButton) button = MB_MIDDLE; - else if (event->button() == Qt::RightButton) button = MB_RIGHT; + Prefs::MouseButton button; + if (event->button() == Qt::LeftButton) button = Prefs::LeftButton; + else if (event->button() == Qt::MidButton) button = Prefs::MiddleButton; + else if (event->button() == Qt::RightButton) button = Prefs::RightButton; else { dbgEnd(Debug::Calls,"TCanvas::mouseReleaseEvent"); diff --git a/src/main.cpp b/src/main.cpp index c256c5307..44a1aaa5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,27 +74,27 @@ int main(int argc, char *argv[]) // Do various things depending on the program mode that has been set // Execute scripts / commands if they were provided - if (master.programMode() == PM_COMMAND) + if (master.programMode() == Master::CommandMode) { // Commands first for (CommandList *cl = master.commands.first(); cl != NULL; cl = cl->next) { - if (!cl->execute(NULL)) master.setProgramMode(PM_NONE); + if (!cl->execute(NULL)) master.setProgramMode(Master::NoMode); // Need to check program mode after each script since it can be changed - if (master.programMode() != PM_COMMAND) break; + if (master.programMode() != Master::CommandMode) break; } // Now scripts for (CommandList *cl = master.scripts.first(); cl != NULL; cl = cl->next) { - if (!cl->execute(NULL)) master.setProgramMode(PM_NONE); + if (!cl->execute(NULL)) master.setProgramMode(Master::NoMode); // Need to check program mode after each script since it can be changed - if (master.programMode() != PM_COMMAND) break; + if (master.programMode() != Master::CommandMode) break; } // All scripts done - set program mode to PM_GUI if it is still PM_COMMAND - if (master.programMode() == PM_COMMAND) master.setProgramMode(PM_GUI); + if (master.programMode() == Master::CommandMode) master.setProgramMode(Master::GuiMode); } // Enter interactive mode once any commands/scripts have been executed - if (master.programMode() == PM_INTERACTIVE) + if (master.programMode() == Master::InteractiveMode) { std::string cmd; printf("Entering interactive mode...\n"); @@ -106,11 +106,11 @@ int main(int argc, char *argv[]) master.interactiveScript.clear(); master.interactiveScript.cacheLine(cmd.c_str()); master.interactiveScript.execute(); - } while (master.programMode() == PM_INTERACTIVE); + } while (master.programMode() == Master::InteractiveMode); //master.set_program_mode(PM_NONE); } // Enter full GUI - if (master.programMode() == PM_GUI) + if (master.programMode() == Master::GuiMode) { // Add empty model if none were specified on the command line if (master.nModels() == 0) Model *m = master.addModel(); diff --git a/src/methods/mc.cpp b/src/methods/mc.cpp index 476d3bb4b..141bb2e13 100644 --- a/src/methods/mc.cpp +++ b/src/methods/mc.cpp @@ -269,7 +269,6 @@ bool MethodMc::minimise(Model* srcmodel, double econ, double fcon) dbgEnd(Debug::Calls,"MethodMc::minimise"); return FALSE; } - srcmodel->assignCharges(prefs.chargeSource()); // Create coordinate backup model for minimisation Model bakmodel; @@ -658,7 +657,7 @@ bool MethodMc::disorder(Model *destmodel) //printf("ACCEPTING MOVE : edelta = %20.14f\n",edelta); // Fold the molecule's atoms and recalculate its centre of geometry //cfg->fold_molecule(p,mol); - //destmodel->set_AtomColours(NULL); + //destmodel->set_Prefs::ColourScheme(NULL); // Update energy and move counters //ecurrent = enew; //currentVdwEnergy = destmodel->energy.get_vdw(); diff --git a/src/model/cell.cpp b/src/model/cell.cpp index 7c682ee58..dc2062fd0 100644 --- a/src/model/cell.cpp +++ b/src/model/cell.cpp @@ -255,7 +255,7 @@ void Model::scaleCell(const Vec3 &scale) if (calcenergy) { newe = totalEnergy(this); - msg(Debug::None,"Energy change was %12.7e %s\n", newe-olde, text_from_EU(prefs.energyUnit())); + msg(Debug::None,"Energy change was %12.7e %s\n", newe-olde, Prefs::energyUnitKeyword(prefs.energyUnit())); } // Set new cell and update model setCell(newaxes); diff --git a/src/model/model.cpp b/src/model/model.cpp index 5a90c555e..1129f3e0d 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -172,59 +172,46 @@ void Model::calculateMass() */ // Assign charges from forcefield -void Model::assignCharges(ChargeSource qs) +void Model::assignForcefieldCharges() { // Assign atom-type charges from the currently associated forcefield to the model // Perform forcefield typing if necessary - dbgBegin(Debug::Calls,"Model::assignCharges"); - Pattern *p; + dbgBegin(Debug::Calls,"Model::assignForcefieldCharges"); Atom *i; Forcefield *xff, *patff; - switch (qs) + if (!arePatternsValid()) { - case (QS_MODEL): - break; - case (QS_FF): - if (!arePatternsValid()) - { - msg(Debug::None,"Model::assignCharges - Cannot assign atomic charges without a valid pattern setup.\n"); - break; - } - typeAll(); - p = patterns_.first(); - while (p != NULL) + msg(Debug::None,"Model::assignCharges - Cannot assign atomic charges without a valid pattern setup.\n"); + dbgEnd(Debug::Calls,"Model::assignForcefieldCharges"); + return; + } + typeAll(); + for (Pattern *p = patterns_.first(); p != NULL; p = p->next) + { + // Grab current model (global) forcefield + xff = forcefield_; + patff = p->forcefield(); + // Grab pattern forcefield in preference to model's + if (patff != NULL) xff = patff; + if (xff == NULL) + msg(Debug::None,"assignCharges : No forcefield is currently assigned to pattern %s. No charges assigned.\n",p->name()); + else + { + i = p->firstAtom(); + int ptotalatoms = p->totalAtoms(); + int count = 0; + while (count < ptotalatoms) { - // Grab current model (global) forcefield - xff = forcefield_; - patff = p->forcefield(); - // Grab pattern forcefield in preference to model's - if (patff != NULL) xff = patff; - if (xff == NULL) - msg(Debug::None,"assignCharges : No forcefield is currently assigned to pattern %s. No charges assigned.\n",p->name()); - else - { - i = p->firstAtom(); - int ptotalatoms = p->totalAtoms(); - int count = 0; - while (count < ptotalatoms) - { - i->setCharge(i->type()->charge()); - i = i->next; - count ++; - } - // Charge atoms in representative pattern molecule - for (i = p->molecule->atoms(); i != NULL; i = i->next) - i->setCharge(i->type()->charge()); - } - p = p->next; + i->setCharge(i->type()->charge()); + i = i->next; + count ++; } - break; - case (QS_GASTEIGER): - case (QS_QEQ): - printf("Gasteiger and QEq charges are not currently implemented.\n"); - break; + // Charge atoms in representative pattern molecule + for (i = p->molecule->atoms(); i != NULL; i = i->next) + i->setCharge(i->type()->charge()); + } } - dbgEnd(Debug::Calls,"Model::assignCharges"); + dbgEnd(Debug::Calls,"Model::assignForcefieldCharges"); } // Set model's forcefield @@ -341,10 +328,10 @@ void Model::calculateDensity() // Calculate density in the units specified by prefs.density_internal switch (prefs.densityUnit()) { - case (DU_GPERCM): + case (Prefs::GramsPerCm): density_ = (mass_ / AVOGADRO) / (cell_.volume() / 1.0E24); break; - case (DU_ATOMSPERANG): + case (Prefs::AtomsPerAngstrom): density_ = atoms_.nItems() / cell_.volume(); break; } @@ -395,7 +382,7 @@ void Model::print() msg(Debug::None," Name : %s\n",name_.get()); msg(Debug::None," File : %s\n",filename_.get()); msg(Debug::None," Mass : %f\n",mass_); - if (cell_.type() != CT_NONE) msg(Debug::None," Cell : %s\nDensity : %f %s\n",text_from_CT(cell_.type()),density_,text_from_DU(prefs.densityUnit())); + if (cell_.type() != CT_NONE) msg(Debug::None," Cell : %s\nDensity : %f %s\n",text_from_CT(cell_.type()),density_,Prefs::densityUnitKeyword(prefs.densityUnit())); msg(Debug::None," Atoms : %i\n",atoms_.nItems()); msg(Debug::None," Id El FFType X Y Z Q S \n"); // Print from pattern definition if possible, otherwise just use model atom list diff --git a/src/model/model.h b/src/model/model.h index fb03e4525..cab97ab84 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -393,8 +393,8 @@ class Model void setForcefield(Forcefield*); // Return the forcefield used by the model Forcefield *forcefield(); - // Assign charges according to prefs QS - void assignCharges(ChargeSource); + // Assign forcefield charges to model atoms + void assignForcefieldCharges(); // Reset all model charges to zero void clearCharges(); diff --git a/src/parse/filter.cpp b/src/parse/filter.cpp index 7e8502183..8b9d3fec7 100644 --- a/src/parse/filter.cpp +++ b/src/parse/filter.cpp @@ -49,7 +49,7 @@ Filter::Filter() type_ = FT_NITEMS; hasExtension_ = FALSE; hasZmapping_ = FALSE; - zmapping_ = ZM_ALPHA; + zmapping_ = Prefs::AlphaZmap; name_.set("unnamed"); glob_.set("*"); id_ = -1; @@ -134,7 +134,7 @@ bool Filter::load(ifstream &filterFile) CommandAction ca; FilterCommmand fc; char longname[256]; - ZmapType zm; + Prefs::ZmapType zm; int success, itemsleft; bool done, error; // First, we must add a command to the flowstack so we know when to return (or raise an error) @@ -190,8 +190,8 @@ bool Filter::load(ifstream &filterFile) break; // Set element zmapping to use for import case (FC_ZMAP): - zm = ZM_from_text(parser.argc(1)); - if (zm != ZM_NITEMS) + zm = Prefs::zmapType(parser.argc(1)); + if (zm != Prefs::nZmapTypes) { zmapping_ = zm; hasZmapping_ = TRUE; @@ -310,7 +310,7 @@ bool Filter::execute(const char *filename, ifstream *trajfile, bool trajheader, // Grab pointer Bundle from master Bundle &obj = master.current; // Set element mapping type to that specified in file - ZmapType temp_zmap = prefs.zmapType(); + Prefs::ZmapType temp_zmap = prefs.zmapType(); if (hasZmapping_) prefs.setZmapType(zmapping_); // Setup based on filter type... switch (type_) @@ -352,7 +352,7 @@ bool Filter::execute(const char *filename, ifstream *trajfile, bool trajheader, // Set variables commands_.variables.set("title",obj.m->name()); commands_.variables.set("npatterns",obj.m->nPatterns()); - commands_.variables.set("energyunit",text_from_EU(prefs.energyUnit())); + commands_.variables.set("energyunit",Prefs::energyUnitKeyword(prefs.energyUnit())); commands_.variables.set("ntypes",obj.m->nUniqueTypes()); // Open file... if (!commands_.setOutputFile(filename)) diff --git a/src/parse/filter.h b/src/parse/filter.h index f4e2139d5..618e30e05 100644 --- a/src/parse/filter.h +++ b/src/parse/filter.h @@ -83,7 +83,7 @@ class Filter // Whether separate zmapping has been defined bool hasZmapping_; // Type of element mapping to use - ZmapType zmapping_; + Prefs::ZmapType zmapping_; public: // Return the ID of the filter diff --git a/src/parse/forcefield.cpp b/src/parse/forcefield.cpp index c3d3da048..ecfa066b3 100644 --- a/src/parse/forcefield.cpp +++ b/src/parse/forcefield.cpp @@ -40,7 +40,7 @@ bool Forcefield::load(const char *filename) dbgBegin(Debug::Calls,"Forcefield::load"); bool done, okay; int success, n, m, count; - EnergyUnit ffunit = EU_J, newunit; + Prefs::EnergyUnit ffunit = Prefs::Joules, newunit; ifstream fffile(filename,ios::in); if (!fffile.good()) { @@ -75,11 +75,11 @@ bool Forcefield::load(const char *filename) okay = TRUE; break; case (FFK_UNITS): - newunit = EU_from_text(parser.argc(1)); - if (newunit != EU_NITEMS) + newunit = Prefs::energyUnit(parser.argc(1)); + if (newunit != Prefs::nEnergyUnits) { ffunit = newunit; - msg(Debug::None,"\t: Energy units are %s\n",text_from_EU(ffunit)); + msg(Debug::None,"\t: Energy units are %s\n", Prefs::energyUnitKeyword(ffunit)); okay = TRUE; } break; @@ -185,7 +185,7 @@ bool Forcefield::readTypes(ifstream &fffile) ffa->setTypeId(newffid); ffa->setName(parser.argc(1)); ffa->setEquivalent(parser.argc(1)); - ffa->atomType()->setCharacterElement(elements.find(parser.argc(2),ZM_ALPHA)); + ffa->atomType()->setCharacterElement(elements.find(parser.argc(2),Prefs::AlphaZmap)); ffa->setDescription(parser.argc(4)); ffa->atomType()->expand(parser.argc(3),this,ffa); } while (!done); diff --git a/src/parse/probe.cpp b/src/parse/probe.cpp index 765b8f7e3..5e2cc62f7 100644 --- a/src/parse/probe.cpp +++ b/src/parse/probe.cpp @@ -26,17 +26,17 @@ #include // Probe model -Filter *MasterData::probeFile(const char *filename, FilterType probetype) +Filter *Master::probeFile(const char *filename, FilterType probetype) { // From the supplied filename and file type, determine (as best we can) the format of the file - dbgBegin(Debug::Calls,"master::probeFile"); + dbgBegin(Debug::Calls,"Master::probeFile"); // Before we do the proper checking, make sure that the file exists and is readable ifstream probefile; probefile.open(filename,ios::in); if (!probefile.is_open()) { msg(Debug::None,"File '%s' does not exist.\n",filename); - dbgEnd(Debug::Calls,"master::probeFile"); + dbgEnd(Debug::Calls,"Master::probeFile"); return NULL; } probefile.close(); @@ -81,7 +81,7 @@ Filter *MasterData::probeFile(const char *filename, FilterType probetype) //if (parser.find_phrase(&modelfile,"GAMESS VERSION",10)) result = MF_GAMESSUS; //modelfile.close(); if (result == NULL) msg(Debug::None,"Couldn't determine format of file '%s'.\n",filename); - else msg(Debug::Verbose,"master::probeFile - Selected filter '%s'\n",result->name()); - dbgEnd(Debug::Calls,"master::probeFile"); + else msg(Debug::Verbose,"Master::probeFile - Selected filter '%s'\n",result->name()); + dbgEnd(Debug::Calls,"Master::probeFile"); return result; } diff --git a/src/render/atoms.cpp b/src/render/atoms.cpp index 5a0015744..4af420a9b 100644 --- a/src/render/atoms.cpp +++ b/src/render/atoms.cpp @@ -30,7 +30,7 @@ void Canvas::renderModelAtoms() static Atom::DrawStyle style_i, renderstyle; static GLfloat ambient[4], diffuse[4]; static short int cindex; - static AtomColours scheme; + static Prefs::ColourScheme scheme; static double radius, rij; static Vec3 ri, rj, rk, ijk; static Atom *i, *j; @@ -45,7 +45,7 @@ void Canvas::renderModelAtoms() cell = displayModel_->cell(); // Set polygon fill mode and specular reflection - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, prefs.colour(COL_SPECREFLECT)); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, prefs.colour(Prefs::SpecularColour)); glMateriali(GL_FRONT, GL_SHININESS, prefs.shininess()); while (i != NULL) @@ -57,7 +57,7 @@ void Canvas::renderModelAtoms() // Push the current matrix, translate to the atoms coordinates and set the drawing colour glPushMatrix(); // Define atom colours - if (scheme == AC_ELEMENT) + if (scheme == Prefs::ElementScheme) { cindex = i->element(); elements.copyAmbientColour(cindex, ambient); @@ -204,7 +204,7 @@ void Canvas::renderModelAtoms() //glEnd(); // Second pass to render selected sphere atoms (transparency) // Enable alpha component (if we weren't aliasing anyway) - if (!prefs.hasGlOption(GO_LINEALIASING) && !prefs.hasGlOption(GO_POLYALIASING)) glEnable(GL_BLEND); + if (!prefs.hasGlOption(Prefs::LineAliasOption) && !prefs.hasGlOption(Prefs::PolyAliasOption)) glEnable(GL_BLEND); glEnable(GL_LIGHTING); // Make sure lighting is on for (i = displayModel_->atoms(); i != NULL; i = i->next) { @@ -215,7 +215,7 @@ void Canvas::renderModelAtoms() if (!i->isSelected()) continue; if (i->isHidden()) continue; // Define atom colours - if (scheme == AC_ELEMENT) + if (scheme == Prefs::ElementScheme) { cindex = i->element(); elements.copyAmbientColour(cindex, ambient); @@ -285,7 +285,7 @@ void Canvas::renderModelAtoms() glPopMatrix(); } // Turn off blending (if not antialiasing) - if (!prefs.hasGlOption(GO_LINEALIASING) && !prefs.hasGlOption(GO_POLYALIASING)) glDisable(GL_BLEND); + if (!prefs.hasGlOption(Prefs::LineAliasOption) && !prefs.hasGlOption(Prefs::PolyAliasOption)) glDisable(GL_BLEND); // Reset line width to 1.0 glLineWidth(1.0); dbgEnd(Debug::Calls,"Canvas::renderModelAtoms"); diff --git a/src/render/extra.cpp b/src/render/extra.cpp index b0ec1fc86..77df08160 100644 --- a/src/render/extra.cpp +++ b/src/render/extra.cpp @@ -171,7 +171,7 @@ void Canvas::renderExtra2d() // Add text //text(1.0,h-12.0,displayModel_->name()); // Draw on colour scale if necessary - if (prefs.colourScheme() != AC_ELEMENT) + if (prefs.colourScheme() != Prefs::ElementScheme) { float midy = height_ / 2; //glBegin( @@ -219,7 +219,7 @@ void Canvas::renderRegions() i ++; } // Turn off blending (if not antialiasing) - if (!prefs.hasGlOption(GO_LINEALIASING) && !prefs.hasGlOption(GO_POLYALIASING)) glDisable(GL_BLEND); + if (!prefs.hasGlOption(Prefs::LineAliasOption) && !prefs.hasGlOption(Prefs::PolyAliasOption)) glDisable(GL_BLEND); glDisable(GL_LIGHTING); dbgEnd(Debug::Calls,"Canvas::renderRegions"); } diff --git a/src/render/gl2ps.cpp b/src/render/gl2ps.cpp index c57ba69d4..5de639175 100644 --- a/src/render/gl2ps.cpp +++ b/src/render/gl2ps.cpp @@ -90,7 +90,7 @@ /* Primitive types */ -#define GL2PS_NO_TYPE -1 +#define GL2PS_OFF_TYPE -1 #define GL2PS_TEXT 1 #define GL2PS_POINT 2 #define GL2PS_LINE 3 @@ -868,7 +868,7 @@ static GLint gl2psAddText(GLint type, const char *str, const char *fontname, if(!gl2ps || !str || !fontname) return GL2PS_UNINITIALIZED; - if(gl2ps->options & GL2PS_NO_TEXT) return GL2PS_SUCCESS; + if(gl2ps->options & GL2PS_OFF_TEXT) return GL2PS_SUCCESS; glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid); if(GL_FALSE == valid) return GL2PS_SUCCESS; /* the primitive is culled */ @@ -950,7 +950,7 @@ static void gl2psAdaptVertexForBlending(GL2PSvertex *v) if(!v || !gl2ps) return; - if(gl2ps->options & GL2PS_NO_BLENDING || !gl2ps->blending){ + if(gl2ps->options & GL2PS_OFF_BLENDING || !gl2ps->blending){ v->rgba[3] = 1.0F; return; } @@ -1220,7 +1220,7 @@ static void gl2psCreateSplitPrimitive(GL2PSprimitive *parent, GL2PSplane plane, case 2 : child->type = GL2PS_LINE; break; case 3 : child->type = GL2PS_TRIANGLE; break; case 4 : child->type = GL2PS_QUADRANGLE; break; - default: child->type = GL2PS_NO_TYPE; break; + default: child->type = GL2PS_OFF_TYPE; break; } } @@ -1886,7 +1886,7 @@ static GL2PSprimitive *gl2psCreateSplitPrimitive2D(GL2PSprimitive *parent, case 2 : child->type = GL2PS_LINE; break; case 3 : child->type = GL2PS_TRIANGLE; break; case 4 : child->type = GL2PS_QUADRANGLE; break; - default: child->type = GL2PS_NO_TYPE; break; /* FIXME */ + default: child->type = GL2PS_OFF_TYPE; break; /* FIXME */ } } child->boundary = 0; /* FIXME: not done! */ @@ -2709,7 +2709,7 @@ static void gl2psPrintPostScriptHeader(void) "/rThreshold %g def %% red component subdivision threshold\n" "/gThreshold %g def %% green component subdivision threshold\n" "/bThreshold %g def %% blue component subdivision threshold\n", - (gl2ps->options & GL2PS_NO_PS3_SHADING) ? "false" : "true", + (gl2ps->options & GL2PS_OFF_PS3_SHADING) ? "false" : "true", gl2ps->threshold[0], gl2ps->threshold[1], gl2ps->threshold[2]); gl2psPrintf("/BD { bind def } bind def\n" @@ -3451,7 +3451,7 @@ static void gl2psPDFgroupListInit(void) int i; GL2PSprimitive *p = NULL; GL2PSpdfgroup gro; - int lasttype = GL2PS_NO_TYPE; + int lasttype = GL2PS_OFF_TYPE; GL2PSrgba lastrgba = {-1.0F, -1.0F, -1.0F, -1.0F}; GLushort lastpattern = 0; GLint lastfactor = 0; @@ -5482,11 +5482,11 @@ static GLint gl2psPrintPrimitives(void) if(!gl2psListNbr(gl2ps->primitives)){ /* empty feedback buffer and/or nothing else to print */ - return GL2PS_NO_FEEDBACK; + return GL2PS_OFF_FEEDBACK; } switch(gl2ps->sort){ - case GL2PS_NO_SORT : + case GL2PS_OFF_SORT : gl2psListAction(gl2ps->primitives, gl2psbackends[gl2ps->format]->printPrimitive); gl2psListAction(gl2ps->primitives, gl2psFreePrimitive); /* reset the primitive list, waiting for the next viewport */ @@ -5559,7 +5559,7 @@ GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, } switch(sort){ - case GL2PS_NO_SORT : + case GL2PS_OFF_SORT : case GL2PS_SIMPLE_SORT : case GL2PS_BSP_SORT : gl2ps->sort = sort; @@ -5775,7 +5775,7 @@ GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, if((width <= 0) || (height <= 0)) return GL2PS_ERROR; - if(gl2ps->options & GL2PS_NO_PIXMAP) return GL2PS_SUCCESS; + if(gl2ps->options & GL2PS_OFF_PIXMAP) return GL2PS_SUCCESS; if((format != GL_RGB && format != GL_RGBA) || type != GL_FLOAT){ gl2psMsg(GL2PS_ERROR, "gl2psDrawPixels only implemented for " @@ -5810,7 +5810,7 @@ GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, switch(format){ case GL_RGBA: - if(gl2ps->options & GL2PS_NO_BLENDING || !gl2ps->blending){ + if(gl2ps->options & GL2PS_OFF_BLENDING || !gl2ps->blending){ /* special case: blending turned off */ prim->data.image->format = GL_RGB; size = height * width * 3; diff --git a/src/render/gl2ps.h b/src/render/gl2ps.h index 08d756893..59e77585a 100644 --- a/src/render/gl2ps.h +++ b/src/render/gl2ps.h @@ -100,7 +100,7 @@ /* Sorting algorithms */ -#define GL2PS_NO_SORT 1 +#define GL2PS_OFF_SORT 1 #define GL2PS_SIMPLE_SORT 2 #define GL2PS_BSP_SORT 3 @@ -110,7 +110,7 @@ #define GL2PS_INFO 1 #define GL2PS_WARNING 2 #define GL2PS_ERROR 3 -#define GL2PS_NO_FEEDBACK 4 +#define GL2PS_OFF_FEEDBACK 4 #define GL2PS_OVERFLOW 5 #define GL2PS_UNINITIALIZED 6 @@ -122,13 +122,13 @@ #define GL2PS_SILENT (1<<2) #define GL2PS_BEST_ROOT (1<<3) #define GL2PS_OCCLUSION_CULL (1<<4) -#define GL2PS_NO_TEXT (1<<5) +#define GL2PS_OFF_TEXT (1<<5) #define GL2PS_LANDSCAPE (1<<6) -#define GL2PS_NO_PS3_SHADING (1<<7) -#define GL2PS_NO_PIXMAP (1<<8) +#define GL2PS_OFF_PS3_SHADING (1<<7) +#define GL2PS_OFF_PIXMAP (1<<8) #define GL2PS_USE_CURRENT_VIEWPORT (1<<9) #define GL2PS_COMPRESS (1<<10) -#define GL2PS_NO_BLENDING (1<<11) +#define GL2PS_OFF_BLENDING (1<<11) #define GL2PS_TIGHT_BOUNDING_BOX (1<<12) /* Arguments for gl2psEnable/gl2psDisable */ diff --git a/src/render/model.cpp b/src/render/model.cpp index 439b911c3..614a9d7d9 100644 --- a/src/render/model.cpp +++ b/src/render/model.cpp @@ -157,8 +157,8 @@ void Canvas::renderModelForceArrows() void Canvas::renderModelCell() { // Draw the unit cell of the model - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, prefs.colour(COL_PEN)); - glColor3fv(prefs.colour(COL_PEN)); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, prefs.colour(Prefs::PenColour)); + glColor3fv(prefs.colour(Prefs::PenColour)); glLineWidth(1.0f); static Vec3 cellCentre, lengths; static Mat4 matrix; @@ -173,10 +173,10 @@ void Canvas::renderModelCell() displayModel_->cell()->axesForGl(glmat); glPushMatrix(); glMultMatrixd(glmat); - if (prefs.shouldRender(VO_CELL)) glCallList(list_[GLOB_WIREUNITCUBE]); + if (prefs.shouldRender(Prefs::ViewCell)) glCallList(list_[GLOB_WIREUNITCUBE]); lengths = displayModel_->cell()->lengths(); // Render cell axis arrows - if (prefs.shouldRender(VO_CELLAXES)) + if (prefs.shouldRender(Prefs::ViewCellAXES)) { glTranslated(-0.5,-0.5,-0.5); glScaled(1.0/lengths.x,1.0/lengths.y,1.0/lengths.z); diff --git a/src/render/render.cpp b/src/render/render.cpp index f4de98861..94c11a08e 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -79,7 +79,7 @@ void Canvas::renderScene(Model *source) } // Draw on the rotation globe - if (prefs.shouldRender(VO_GLOBE)) renderRotationGlobe(rotmat, camrot); + if (prefs.shouldRender(Prefs::ViewGlobe)) renderRotationGlobe(rotmat, camrot); // Reset projection matrix and set perspective view double top, bottom; @@ -128,25 +128,25 @@ void Canvas::renderScene(Model *source) // Draw the model cell (this also translates our drawing position to the -half cell point. renderModelCell(); // Draw the model's atoms, bonds, and selection - if (prefs.shouldRender(VO_ATOMS)) renderModelAtoms(); + if (prefs.shouldRender(Prefs::ViewAtoms)) renderModelAtoms(); // Render glyphs associated with the model renderModelGlyphs(); // Render force arrows - if (prefs.shouldRender(VO_FORCEARROWS)) renderModelForceArrows(); + if (prefs.shouldRender(Prefs::ViewForceArrows)) renderModelForceArrows(); glEndList(); renderPoint_ = displayModel_->log(LOG_TOTAL); msg(Debug::Verbose," Done. (New point = %i)\n",renderPoint_); } // Render surfaces - if (prefs.shouldRender(VO_SURFACES)) renderSurfaces(); + if (prefs.shouldRender(Prefs::ViewSurfaces)) renderSurfaces(); // Render MC regions - if ((displayModel_->cell()->type() != CT_NONE) && prefs.shouldRender(VO_REGIONS)) renderRegions(); - glColor3fv(prefs.colour(COL_PEN)); + if ((displayModel_->cell()->type() != CT_NONE) && prefs.shouldRender(Prefs::ViewRegions)) renderRegions(); + glColor3fv(prefs.colour(Prefs::PenColour)); renderExtra3d(); glPopMatrix(); // Draw replicated cells (using display list) - if (prefs.shouldRender(VO_CELLREPEAT)) + if (prefs.shouldRender(Prefs::ViewCellREPEAT)) { static Mat3 cellmat; static Vec3 cx, cy, cz; @@ -180,11 +180,11 @@ void Canvas::renderScene(Model *source) glClear(GL_DEPTH_BUFFER_BIT); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, prefs.colour(COL_PEN)); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, prefs.colour(Prefs::PenColour)); glDisable(GL_LIGHTING); - if (prefs.shouldRender(VO_LABELS)) renderModelLabels(); - if (prefs.shouldRender(VO_MEASUREMENTS)) renderModelMeasurements(); + if (prefs.shouldRender(Prefs::ViewLabels)) renderModelLabels(); + if (prefs.shouldRender(Prefs::ViewMeasurements)) renderModelMeasurements(); renderExtra2d(); glDisable(GL_COLOR_MATERIAL); diff --git a/src/render/surface.cpp b/src/render/surface.cpp index 54c2199b3..9123971dd 100644 --- a/src/render/surface.cpp +++ b/src/render/surface.cpp @@ -371,7 +371,7 @@ void cubeIt(Grid *g, SurfaceStyle ss) break; } // Set colour / transparency for surface - glMaterialfv(GL_FRONT, GL_SPECULAR, prefs.colour(COL_SPECREFLECT)); + glMaterialfv(GL_FRONT, GL_SPECULAR, prefs.colour(Prefs::SpecularColour)); glMateriali(GL_FRONT, GL_SHININESS, prefs.shininess()); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, g->colour()); // Generate surface