diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc648a62..8bf03ffff 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,10 +95,18 @@ FIND_FILE(HRline history5.dll ENV PATH) Find_File(qtgui QtGui4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) Find_File(qtgl QtOpenGL4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) Find_File(qtcore QtCore4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - -install(FILES ${qtgui} ${qtgl} ${qtcore} ${Rline} ${HRline} +Find_File(qtsvg QtSvg4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) +Find_File(qtxml QtXml4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) +Find_File(qsvg qsvg4.dll PATHS ${QT_PLUGINS_DIR}/iconengines NO_DEFAULT_PATH) +install(FILES ${qtgui} ${qtgl} ${qtcore} ${Rline} ${HRline} ${qtsvg} ${qtxml} DESTINATION bin ) +message("tt: ${QT_PLUGINS_DIR} ${qsvg}") +install(FILES ${qsvg} +DESTINATION bin/iconengines +) + + ENDIF(WIN32) @@ -140,7 +148,7 @@ IF(WIN32) set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " Push \\\"ATENDATA\\\" Push \\\"$INSTDIR\\\\share\\\\aten\\\" - Call WriteEnvStr + Call WriteEnvStr " ) set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " diff --git a/src/classes/measurement.cpp b/src/classes/measurement.cpp index d5a26f771..e7a4a6286 100644 --- a/src/classes/measurement.cpp +++ b/src/classes/measurement.cpp @@ -24,15 +24,17 @@ #include "classes/cell.h" // Geometry types -int GT_natoms_[GT_NITEMS] = { 0,2,3,4 }; -int natoms_from_GT(GeometryType gt) - { return GT_natoms_[gt]; } +int MeasurementAtoms[Measurement::nMeasurementTypes] = { 0,2,3,4 }; +int Measurement::nMeasurementAtoms(Measurement::MeasurementType mt) +{ + return MeasurementAtoms[mt]; +} // Constructor Measurement::Measurement() { // Private variables - type_ = GT_NONE; + type_ = Measurement::NoMeasurement; for (int n=0; n<4; n++) atoms_[n] = NULL; value_ = 0.0; // Public variables @@ -41,13 +43,13 @@ Measurement::Measurement() } // Set type of Measurement -void Measurement::setType(GeometryType gt) +void Measurement::setType(Measurement::MeasurementType gt) { type_ = gt; } // Return type of Measurement -GeometryType Measurement::type() +Measurement::MeasurementType Measurement::type() { return type_; } @@ -75,13 +77,13 @@ void Measurement::calculate(Cell *cell) { switch (type_) { - case (GT_DISTANCE): + case (Measurement::DistanceMeasurement): value_ = cell->distance(atoms_[0],atoms_[1]); break; - case (GT_ANGLE): + case (Measurement::AngleMeasurement): value_ = cell->angle(atoms_[0],atoms_[1],atoms_[2]) * DEGRAD; break; - case (GT_TORSION): + case (Measurement::TorsionMeasurement): value_ = cell->torsion(atoms_[0],atoms_[1],atoms_[2],atoms_[3]) * DEGRAD; break; default: diff --git a/src/classes/measurement.h b/src/classes/measurement.h index e551863b9..8d2a7aff1 100644 --- a/src/classes/measurement.h +++ b/src/classes/measurement.h @@ -22,10 +22,6 @@ #ifndef ATEN_MEASUREMENT_H #define ATEN_MEASUREMENT_H -// Geometry types -enum GeometryType { GT_NONE, GT_DISTANCE, GT_ANGLE, GT_TORSION, GT_NITEMS }; -int natoms_from_GT(GeometryType); - // Forward Declarations class Atom; class Cell; @@ -38,13 +34,16 @@ class Measurement Measurement(); // List pointers Measurement *next, *prev; + // Geometry types + enum MeasurementType { NoMeasurement, DistanceMeasurement, AngleMeasurement, TorsionMeasurement, nMeasurementTypes }; + static int nMeasurementAtoms(MeasurementType); /* // Measurement Data */ private: // Type of Measurement - GeometryType type_; + MeasurementType type_; // Atoms involved Measurement Atom* atoms_[4]; // Value of Measurement @@ -52,9 +51,9 @@ class Measurement public: // Set type of Measurement - void setType(GeometryType gt); + void setType(MeasurementType gt); // Return type of Measurement - GeometryType type(); + MeasurementType type(); // Calculate Measurement value void calculate(Cell *cell); // Return value of the Measurement diff --git a/src/classes/pattern.h b/src/classes/pattern.h index b1ec88671..b07a4d69b 100644 --- a/src/classes/pattern.h +++ b/src/classes/pattern.h @@ -22,11 +22,8 @@ #ifndef ATEN_PATTERN_H #define ATEN_PATTERN_H -//#include "classes/atom.h" #include "templates/vector3.h" #include "templates/list.h" -//#include "classes/ring.h" -//#include "energy/forms.h" #include "classes/forcefield.h" // Forward declarations diff --git a/src/classes/undostate.cpp b/src/classes/undostate.cpp index 5fa4597d9..94fa3f349 100644 --- a/src/classes/undostate.cpp +++ b/src/classes/undostate.cpp @@ -32,8 +32,8 @@ Change::Change() vecData_[1] = NULL; vecData_[2] = NULL; vecData_[3] = NULL; - type_ = UE_NONE; - direction_ = UD_REVERSE; + type_ = Change::NoEvent; + direction_ = Change::Reverse; // Public variables prev = NULL; next = NULL; @@ -61,7 +61,7 @@ Change::~Change() void Change::set(int ue, Atom *i, Atom *j) { dbgBegin(Debug::Calls,"Change::set[Atom]"); - direction_ = (ue > 0 ? UD_REVERSE : UD_FORWARDS); + direction_ = (ue > 0 ? Change::Reverse : Change::Forwards); type_ = (UndoEvent) abs(ue); // Copy atom data from source atoms, unless they are NULL if (i != NULL) @@ -83,7 +83,7 @@ void Change::set(int ue, Atom *i, Atom *j) void Change::set(int ue, int i, int j, int k, int l, int m) { dbgBegin(Debug::Calls,"Change::set[int]"); - direction_ = (ue > 0 ? UD_REVERSE : UD_FORWARDS); + direction_ = (ue > 0 ? Change::Reverse : Change::Forwards); type_ = (UndoEvent) abs(ue); data_[0] = i; data_[1] = j; @@ -97,7 +97,7 @@ void Change::set(int ue, int i, int j, int k, int l, int m) void Change::set(int ue, Vec3 *v1, Vec3 *v2, Vec3 *v3, Vec3 *v4) { dbgBegin(Debug::Calls,"Change::set[vector]"); - direction_ = (ue > 0 ? UD_REVERSE : UD_FORWARDS); + direction_ = (ue > 0 ? Change::Reverse : Change::Forwards); type_ = (UndoEvent) abs(ue); // Copy data from source vectors, unless they are NULL if (v1 != NULL) @@ -133,9 +133,9 @@ void Change::reverse(Model *m) Bond *b; switch (type_) { - // Atom creation (UD_REVERSE) and deletion (UD_FORWARDS) - case (UE_ATOM): - if (direction_ == UD_REVERSE) + // Atom creation (Change::Reverse) and deletion (Change::Forwards) + case (Change::AtomEvent): + if (direction_ == Change::Reverse) { // We delete the atom at the position referenced by the ID in the atom id = atomData_[0]->id(); @@ -151,11 +151,11 @@ void Change::reverse(Model *m) else m->addCopy(modelatoms[id-1], atomData_[0]); } break; - // Bond creation (UD_REVERSE) and deletion (UD_FORWARDS) - case (UE_BOND): + // Bond creation (Change::Reverse) and deletion (Change::Forwards) + case (Change::BondEvent): i = modelatoms[data_[0]]; j = modelatoms[data_[1]]; - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { // Delete bond between stored atom ids msg(Debug::Verbose,"Reversing bond creation - atom ids = %i %i\n", data_[0], data_[1]); @@ -168,10 +168,10 @@ void Change::reverse(Model *m) m->bondAtoms(i,j,(Bond::BondType) data_[2]); } break; - // Atom selection (UD_REVERSE) and deselection (UD_FORWARDS) - case (UE_SELECT): + // Atom selection (Change::Reverse) and deselection (Change::Forwards) + case (Change::SelectEvent): i = modelatoms[data_[0]]; - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing atom selection - atom id = %i\n", data_[0]); m->deselectAtom(i); @@ -182,12 +182,12 @@ void Change::reverse(Model *m) m->selectAtom(i); } break; - // Bond order change - from data[3] to data[2] (UD_REVERSE) or vice versa (UD_FORWARDS) - case (UE_BONDORDER): + // Bond order change - from data[3] to data[2] (Change::Reverse) or vice versa (Change::Forwards) + case (Change::BondEventORDER): i = modelatoms[data_[0]]; j = modelatoms[data_[1]]; b = i->findBond(j); - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing bond order change - atoms %i-%i, old = %i, new = %i\n", i->id(), j->id(), data_[3], data_[2]); m->changeBond(b,(Bond::BondType) data_[2]); @@ -198,30 +198,30 @@ void Change::reverse(Model *m) m->changeBond(b,(Bond::BondType) data_[3]); } break; - // Geometry measurement creation (UD_REVERSE) and deletion (UD_FORWARDS) - case (UE_MEASUREMENT): + // Geometry measurement creation (Change::Reverse) and deletion (Change::Forwards) + case (Change::MeasurementEvent): i = modelatoms[data_[1]]; j = modelatoms[data_[2]]; k = modelatoms[data_[3]]; l = modelatoms[data_[4]]; - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { - GeometryType gt = (GeometryType) data_[0]; - msg(Debug::Verbose,"Reversing measurement - type = %i\n", gt); - Measurement *me = m->findMeasurement(gt, i, j, k, l); + Measurement::MeasurementType mt = (Measurement::MeasurementType) data_[0]; + msg(Debug::Verbose,"Reversing measurement - type = %i\n", mt); + Measurement *me = m->findMeasurement(mt, i, j, k, l); if (me != NULL) m->removeMeasurement(me); } else { - GeometryType gt = (GeometryType) data_[0]; - msg(Debug::Verbose,"Replaying measurement - type = %i\n", gt); - m->addMeasurement(gt, i, j, k, l); + Measurement::MeasurementType mt = (Measurement::MeasurementType) data_[0]; + msg(Debug::Verbose,"Replaying measurement - type = %i\n", mt); + m->addMeasurement(mt, i, j, k, l); } break; - // Atom transmute - from data[2] to data[1] (UD_REVERSE) or vice versa (UD_FORWARDS) - case (UE_TRANSMUTE): + // Atom transmute - from data[2] to data[1] (Change::Reverse) or vice versa (Change::Forwards) + case (Change::TransmuteEvent): i = modelatoms[data_[0]]; - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing atom transmute - atom %i, old = %i, new = %i\n", i->id(), data_[2], data_[1]); m->transmuteAtom(i,data_[1]); @@ -232,9 +232,9 @@ void Change::reverse(Model *m) m->transmuteAtom(i,data_[2]); } break; - // Cell change - from matrix[1] to matrix[0] (UD_REVERSE) or vice versa (UD_FORWARDS) - case (UE_CELL): - if (direction_ == UD_REVERSE) + // Cell change - from matrix[1] to matrix[0] (Change::Reverse) or vice versa (Change::Forwards) + case (Change::CellEvent): + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing cell change\n"); if (vecData_[0] == NULL) m->removeCell(); @@ -247,10 +247,10 @@ void Change::reverse(Model *m) else m->setCell(*vecData_[2], *vecData_[3]); } break; - // Atom label change - from data[2] to data[1] (UD_REVERSE) or vice versa (UD_FORWARDS) - case (UE_LABEL): + // Atom label change - from data[2] to data[1] (Change::Reverse) or vice versa (Change::Forwards) + case (Change::LabelEvent): i = modelatoms[data_[0]]; - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing atom label change - atom %i, from %i to %i\n",data_[0],data_[2],data_[1]); i->setLabels(data_[1]); @@ -261,10 +261,10 @@ void Change::reverse(Model *m) i->setLabels(data_[2]); } break; - // Atom position change - add (UD_REVERSE) or subtract (UD_FORWARDS) vecData_[0] - case (UE_TRANSLATE): + // Atom position change - add (Change::Reverse) or subtract (Change::Forwards) vecData_[0] + case (Change::TranslateEvent): i = modelatoms[data_[0]]; - if (direction_ == UD_REVERSE) + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing atom translation - atom %i, subtracting %f %f %f\n", data_[0], vecData_[0]->x, vecData_[0]->y, vecData_[0]->z); i->r() -= *vecData_[0]; @@ -275,9 +275,9 @@ void Change::reverse(Model *m) i->r() += *vecData_[0]; } break; - // Atom list position change - -data[1] (UD_REVERSE) or +data[1] places in list (UD_FORWARDS) - case (UE_SHIFT): - if (direction_ == UD_REVERSE) + // Atom list position change - -data[1] (Change::Reverse) or +data[1] places in list (Change::Forwards) + case (Change::ShiftEvent): + if (direction_ == Change::Reverse) { msg(Debug::Verbose,"Reversing atom shift - atom %i moves %i places\n", data_[0]+data_[1], -data_[1]); m->atoms_.move(data_[0]+data_[1], -data_[1]); @@ -301,10 +301,10 @@ void Change::perform(Model *m) { dbgBegin(Debug::Calls,"Change::perform"); // Re-use the commands in Change::revert, performing the change in the opposite direction - direction_ = (direction_ == UD_REVERSE ? UD_FORWARDS : UD_REVERSE); + direction_ = (direction_ == Change::Reverse ? Change::Forwards : Change::Reverse); // Now just call reverse instead, and then set the old direction back at the end reverse(m); - direction_ = (direction_ == UD_REVERSE ? UD_FORWARDS : UD_REVERSE); + direction_ = (direction_ == Change::Reverse ? Change::Forwards : Change::Reverse); dbgEnd(Debug::Calls,"Change::perform"); } @@ -313,25 +313,25 @@ void Change::perform(Model *m) */ // Set log point at start of state -void Undostate::setStartLog(ChangeLog log, int value) +void Undostate::setStartLog(Change::ChangeLog log, int value) { startLogs_[log] = value; } // Get structure log point at start of state -int Undostate::startLog(ChangeLog log) +int Undostate::startLog(Change::ChangeLog log) { return startLogs_[log]; } // Set log point at end of state -void Undostate::setEndLog(ChangeLog log, int value) +void Undostate::setEndLog(Change::ChangeLog log, int value) { endLogs_[log] = value; } // Get structure log point at end of state -int Undostate::endLog(ChangeLog log) +int Undostate::endLog(Change::ChangeLog log) { return endLogs_[log]; } @@ -381,11 +381,11 @@ void Undostate::perform(Model *m) dbgEnd(Debug::Calls,"Undostate::perform"); } -// Check differences between LOG_STRUCTURE and LOG_COORDS for start/end points +// Check differences between Change::StructureLog and Change::CoordinateLog for start/end points bool Undostate::doLogsDiffer() { - if (startLogs_[LOG_STRUCTURE] != endLogs_[LOG_STRUCTURE]) return TRUE; - if (startLogs_[LOG_COORDS] != endLogs_[LOG_COORDS]) return TRUE; - if (startLogs_[LOG_SELECTION] != endLogs_[LOG_SELECTION]) return TRUE; + if (startLogs_[Change::StructureLog] != endLogs_[Change::StructureLog]) return TRUE; + if (startLogs_[Change::CoordinateLog] != endLogs_[Change::CoordinateLog]) return TRUE; + if (startLogs_[Change::SelectionLog] != endLogs_[Change::SelectionLog]) return TRUE; return FALSE; } diff --git a/src/classes/undostate.h b/src/classes/undostate.h index 24b7cd462..8a07907ae 100644 --- a/src/classes/undostate.h +++ b/src/classes/undostate.h @@ -22,15 +22,6 @@ #ifndef ATEN_UNDOLEVEL_H #define ATEN_UNDOLEVEL_H -// Change logs -enum ChangeLog { LOG_STRUCTURE, LOG_COORDS, LOG_VISUAL, LOG_SELECTION, LOG_CAMERA, LOG_TOTAL, LOG_NITEMS }; - -// State change events -enum UndoEvent { UE_NONE, UE_ATOM, UE_BOND, UE_MEASUREMENT, UE_SELECT, UE_TRANSMUTE, UE_BONDORDER, UE_CELL, UE_LABEL, UE_TRANSLATE, UE_SHIFT }; - -// State change directions -enum UndoDirection { UD_REVERSE, UD_FORWARDS }; - #include "classes/dnchar.h" #include "templates/list.h" #include "templates/vector3.h" @@ -49,6 +40,12 @@ class Change ~Change(); // List pointers Change *prev, *next; + // Change logs + enum ChangeLog { StructureLog, CoordinateLog, VisualLog, SelectionLog, CameraLog, TotalLog, nChangeLogs }; + // State change events + enum UndoEvent { NoEvent, AtomEvent, BondEvent, MeasurementEvent, SelectEvent, TransmuteEvent, BondEventORDER, CellEvent, LabelEvent, TranslateEvent, ShiftEvent }; + // State change directions + enum UndoDirection { Reverse, Forwards }; /* // Data @@ -103,9 +100,9 @@ class Undostate // Short text describing the change Dnchar description_; // Logs at start of state - int startLogs_[LOG_NITEMS]; + int startLogs_[Change::nChangeLogs]; // Logs at end of state - int endLogs_[LOG_NITEMS]; + int endLogs_[Change::nChangeLogs]; public: // Add change to undostate @@ -113,14 +110,14 @@ class Undostate // Return number of changes in list int nChanges(); // Set log point at start of state - void setStartLog(ChangeLog log, int value); + void setStartLog(Change::ChangeLog log, int value); // Get structure log point at start of state - int startLog(ChangeLog log); + int startLog(Change::ChangeLog log); // Set log point at end of state - void setEndLog(ChangeLog log, int value); + void setEndLog(Change::ChangeLog log, int value); // Get structure log point at end of state - int endLog(ChangeLog log); - // Check difference between LOG_STRUCTURE and LOG_COORDS between start/end points + int endLog(Change::ChangeLog log); + // Check difference between Change::StructureLog and Change::CoordinateLog between start/end points bool doLogsDiffer(); // Set the text associated with the current undo state void setDescription(const char *s); diff --git a/src/command/cell.cpp b/src/command/cell.cpp index 41ab54638..4c55338ba 100644 --- a/src/command/cell.cpp +++ b/src/command/cell.cpp @@ -88,7 +88,7 @@ int CommandData::function_CA_CELL(Command *&c, Bundle &obj) { if (obj.notifyNull(BP_MODEL)) return CR_FAIL; obj.m->setCell(c->arg3d(0), c->arg3d(3)); - obj.m->logChange(LOG_VISUAL); + obj.m->logChange(Change::VisualLog); obj.m->calculateDensity(); return CR_SUCCESS; } @@ -102,7 +102,7 @@ int CommandData::function_CA_CELLAXES(Command *&c, Bundle &obj) mat.rows[1] = c->arg3d(3); mat.rows[2] = c->arg3d(6); obj.m->setCell(mat); - obj.m->logChange(LOG_VISUAL); + obj.m->logChange(Change::VisualLog); obj.m->calculateDensity(); return CR_SUCCESS; } diff --git a/src/command/prefs.cpp b/src/command/prefs.cpp index 3e86c7348..c7a717f59 100644 --- a/src/command/prefs.cpp +++ b/src/command/prefs.cpp @@ -29,7 +29,7 @@ int CommandData::function_CA_ATOMDETAIL(Command *&c, Bundle &obj) { prefs.setAtomDetail(c->argi(0)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -38,7 +38,7 @@ int CommandData::function_CA_ATOMDETAIL(Command *&c, Bundle &obj) int CommandData::function_CA_BONDDETAIL(Command *&c, Bundle &obj) { prefs.setBondDetail(c->argi(0)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -51,7 +51,7 @@ int CommandData::function_CA_COLOUR(Command *&c, Bundle &obj) Vec3 colvec = c->arg3f(1); GLfloat alpha = (c->hasArg(4) ? (GLfloat) c->argd(4) : 1.0f); prefs.setPenColour(col, colvec.x, colvec.y, colvec.z, alpha); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -102,7 +102,7 @@ int CommandData::function_CA_ELEMENTAMBIENT(Command *&c, Bundle &obj) elements.setAmbientColour(el,0,c->argi(1)); elements.setAmbientColour(el,1,c->argi(2)); elements.setAmbientColour(el,2,c->argi(3)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -115,7 +115,7 @@ int CommandData::function_CA_ELEMENTDIFFUSE(Command *&c, Bundle &obj) elements.setDiffuseColour(el,0,c->argi(1)); elements.setDiffuseColour(el,1,c->argi(2)); elements.setDiffuseColour(el,2,c->argi(3)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -126,7 +126,7 @@ int CommandData::function_CA_ELEMENTRADIUS(Command *&c, Bundle &obj) int el = elements.find(c->argc(0)); if (el == 0) return CR_FAIL; elements.setAtomicRadius(el, c->argd(1)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -148,7 +148,7 @@ int CommandData::function_CA_GL(Command *&c, Bundle &obj) if (c->argb(1)) prefs.addGlOption(go); else prefs.removeGlOption(go); if (gui.exists()) gui.mainView.initGl(); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -193,7 +193,7 @@ int CommandData::function_CA_RADIUS(Command *&c, Bundle &obj) int CommandData::function_CA_SHININESS(Command *&c, Bundle &obj) { prefs.setShininess(c->argi(0)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); return CR_SUCCESS; } @@ -205,7 +205,7 @@ int CommandData::function_CA_SHOW(Command *&c, Bundle &obj) if (vo != Prefs::nViewObjects) { prefs.setVisible(vo, c->argb(1)); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } else return CR_FAIL; @@ -219,7 +219,7 @@ int CommandData::function_CA_STYLE(Command *&c, Bundle &obj) if (ds != Atom::nDrawStyles) { prefs.setRenderStyle(ds); - if (obj.m != NULL) obj.m->logChange(LOG_VISUAL); + if (obj.m != NULL) obj.m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } else return CR_FAIL; diff --git a/src/command/select.cpp b/src/command/select.cpp index e5631c24f..661290c04 100644 --- a/src/command/select.cpp +++ b/src/command/select.cpp @@ -242,7 +242,7 @@ int CommandData::function_CA_SELECTTYPE(Command *&c, Bundle &obj) // Write results msg(Debug::None,"Type description score = %i. Matched %i atoms.\n", matchscore, count); // Update model and delete temporary atomtype - obj.m->logChange(LOG_SELECTION); + obj.m->logChange(Change::SelectionLog); return CR_SUCCESS; } else msg(Debug::None,"Can't test atomtype description without a valid pattern definition!\n"); diff --git a/src/gui/actions.cpp b/src/gui/actions.cpp index 571c5c21e..59293e227 100644 --- a/src/gui/actions.cpp +++ b/src/gui/actions.cpp @@ -44,7 +44,7 @@ void AtenForm::on_StyleToolBar_actionTriggered(QAction *action) // Inform the displayed model m = master.currentModel()->renderSource(); m->projectAll(); - m->logChange(LOG_VISUAL); + m->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } diff --git a/src/gui/analyse_funcs.cpp b/src/gui/analyse_funcs.cpp index 3fac1ccce..795600053 100644 --- a/src/gui/analyse_funcs.cpp +++ b/src/gui/analyse_funcs.cpp @@ -26,42 +26,42 @@ void AtenForm::on_MeasureDistanceButton_clicked(bool on) { - if (on) setUserAction(on, UA_GEOMDIST); + if (on) setUserAction(on, Canvas::MeasureDistanceAction); } void AtenForm::on_MeasureAngleButton_clicked(bool on) { - if (on) setUserAction(on, UA_GEOMANGLE); + if (on) setUserAction(on, Canvas::MeasureAngleAction); } void AtenForm::on_MeasureTorsionButton_clicked(bool on) { - if (on) setUserAction(on, UA_GEOMTORSION); + if (on) setUserAction(on, Canvas::MeasureTorsionAction); } void AtenForm::on_RemoveMeasurementsButton_clicked(bool on) { - master.currentModel()->removeMeasurements(GT_DISTANCE); - master.currentModel()->removeMeasurements(GT_ANGLE); - master.currentModel()->removeMeasurements(GT_TORSION); + master.currentModel()->removeMeasurements(Measurement::DistanceMeasurement); + master.currentModel()->removeMeasurements(Measurement::AngleMeasurement); + master.currentModel()->removeMeasurements(Measurement::TorsionMeasurement); gui.mainView.postRedisplay(); } void AtenForm::on_MeasureDistanceSelectionButton_clicked(bool on) { - master.currentModel()->addMeasurementsInSelection(GT_DISTANCE); + master.currentModel()->addMeasurementsInSelection(Measurement::DistanceMeasurement); gui.mainView.postRedisplay(); } void AtenForm::on_MeasureAngleSelectionButton_clicked(bool on) { - master.currentModel()->addMeasurementsInSelection(GT_ANGLE); + master.currentModel()->addMeasurementsInSelection(Measurement::AngleMeasurement); gui.mainView.postRedisplay(); } void AtenForm::on_MeasureTorsionSelectionButton_clicked(bool on) { - master.currentModel()->addMeasurementsInSelection(GT_TORSION); + master.currentModel()->addMeasurementsInSelection(Measurement::TorsionMeasurement); gui.mainView.postRedisplay(); } diff --git a/src/gui/atomlist_funcs.cpp b/src/gui/atomlist_funcs.cpp index 7951a3eb7..55674effb 100644 --- a/src/gui/atomlist_funcs.cpp +++ b/src/gui/atomlist_funcs.cpp @@ -82,7 +82,7 @@ void AtenForm::refreshAtomPage() listSelectionPoint = -1; } listLastModel = m; - if (listStructurePoint != (m->log(LOG_STRUCTURE) + m->log(LOG_COORDS))) + if (listStructurePoint != (m->log(Change::StructureLog) + m->log(Change::CoordinateLog))) { //printf("List must be cleared and repopulated...\n"); // Clear the current list @@ -138,10 +138,10 @@ void AtenForm::refreshAtomPage() } } // Set new log points - listStructurePoint = m->log(LOG_STRUCTURE) + m->log(LOG_COORDS); - listSelectionPoint = m->log(LOG_SELECTION); + listStructurePoint = m->log(Change::StructureLog) + m->log(Change::CoordinateLog); + listSelectionPoint = m->log(Change::SelectionLog); } - else if (listSelectionPoint != m->log(LOG_SELECTION)) + else if (listSelectionPoint != m->log(Change::SelectionLog)) { // If we haven't cleared and repopulated the list and the selection point is old, go through the list and apply the new atom selection // Grab the list of TTreeWidgetItems @@ -151,7 +151,7 @@ void AtenForm::refreshAtomPage() i = ri->item->atom(); ui.AtomTree->setItemSelected(ri->item, i->isSelected()); } - listSelectionPoint = m->log(LOG_SELECTION); + listSelectionPoint = m->log(Change::SelectionLog); } for (n=0; n<6; n++) ui.AtomTree->resizeColumnToContents(n); REFRESHING = FALSE; @@ -195,7 +195,7 @@ void AtenForm::on_ShiftDownButton_clicked(bool checked) void AtenForm::on_MoveToStartButton_clicked(bool checked) { master.currentModel()->moveSelectionToStart(); - master.currentModel()->logChange(LOG_STRUCTURE); + master.currentModel()->logChange(Change::StructureLog); refreshAtomPage(); gui.modelChanged(FALSE,FALSE,FALSE); } @@ -203,7 +203,7 @@ void AtenForm::on_MoveToStartButton_clicked(bool checked) void AtenForm::on_MoveToEndButton_clicked(bool checked) { master.currentModel()->moveSelectionToEnd(); - master.currentModel()->logChange(LOG_STRUCTURE); + master.currentModel()->logChange(Change::StructureLog); refreshAtomPage(); gui.modelChanged(FALSE,FALSE,FALSE); } diff --git a/src/gui/canvas-qt.cpp b/src/gui/canvas-qt.cpp index 3e7bcbc29..db6c5d57e 100644 --- a/src/gui/canvas-qt.cpp +++ b/src/gui/canvas-qt.cpp @@ -116,5 +116,5 @@ void canvas::configure() h = (float)context_widget->height(); do_projection(); // Flag that render source needs to be reprojected - if (displaymodel != NULL) displaymodel->logChange(LOG_VISUAL); + if (displaymodel != NULL) displaymodel->logChange(Change::VisualLog); } diff --git a/src/gui/canvas.cpp b/src/gui/canvas.cpp index 309c8cf7a..3b7a87508 100644 --- a/src/gui/canvas.cpp +++ b/src/gui/canvas.cpp @@ -36,8 +36,8 @@ Canvas::Canvas() drawing_ = FALSE; displayModel_ = NULL; drawPixelWidth_ = 1.0; - activeMode_ = UA_NONE; - selectedMode_ = UA_PICKSELECT; + activeMode_ = Canvas::NoAction; + selectedMode_ = Canvas::SelectAction; list_[0] = 0; contextWidget_ = NULL; subselectEnabled_ = FALSE; @@ -137,7 +137,7 @@ void Canvas::configure() height_ = (float)contextWidget_->height(); doProjection(); // Flag that render source needs to be reprojected - if (displayModel_ != NULL) displayModel_->logChange(LOG_VISUAL); + if (displayModel_ != NULL) displayModel_->logChange(Change::VisualLog); } /* @@ -601,7 +601,7 @@ void Canvas::useSelectedMode() } // Return the currently selected mode -UserAction Canvas::selectedMode() +Canvas::UserAction Canvas::selectedMode() { return selectedMode_; } diff --git a/src/gui/canvas.h b/src/gui/canvas.h index 08fc28515..10796de32 100644 --- a/src/gui/canvas.h +++ b/src/gui/canvas.h @@ -27,22 +27,6 @@ #include "base/prefs.h" #include "render/gl2ps_extra.h" - -// Actions -enum UserAction { UA_NONE, - UA_PICKSELECT, UA_PICKFRAG, UA_PICKELEMENT, UA_PICKRADIAL, - UA_GEOMSELECT, UA_GEOMDIST, UA_GEOMANGLE, UA_GEOMTORSION, - UA_POSSELECT, UA_POSCENTRE, UA_POSTRANSLATE, UA_POSROTATE, - UA_DRAWATOM, UA_DRAWCHAIN, UA_TRANSATOM, UA_DELATOM, UA_PROBEATOM, - UA_BONDSINGLE, UA_BONDDOUBLE, UA_BONDTRIPLE, UA_DELBOND, - UA_ROTATEXY, UA_ROTATEZ, UA_MOVECAM, UA_ZOOMCAM, - UA_MANIPROTXY, UA_MANIPROTZ, UA_MANIPTRANS, - UA_ATOMADDHYDROGEN, - UA_NITEMS }; - -// Keyboard Key Codes (translated from GTK/KDE keysyms) -enum key_code { KC_OTHER, KC_ESCAPE, KC_SHIFT_L, KC_SHIFT_R, KC_CONTROL_L, KC_CONTROL_R, KC_ALT_L, KC_ALT_R, KC_LEFT, KC_RIGHT, KC_UP, KC_DOWN, KC_NITEMS }; - // GL Objects enum GlObject { GLOB_STICKATOM, GLOB_TUBEATOM, GLOB_SPHEREATOM, GLOB_UNITATOM, GLOB_WIRETUBEATOM, GLOB_WIRESPHEREATOM, GLOB_WIREUNITATOM, GLOB_CYLINDER, GLOB_SELCYLINDER, GLOB_WIRECYLINDER, GLOB_SELWIRECYLINDER, GLOB_GLOBE, GLOB_GUIDE, GLOB_CIRCLE, GLOB_CELLAXES, GLOB_SELTUBEATOM, GLOB_SELSPHEREATOM, GLOB_SELUNITATOM, GLOB_WIREUNITCUBE, GLOB_UNITCUBE, GLOB_TUBEARROW, GLOB_MODEL, GLOB_NITEMS }; @@ -65,6 +49,21 @@ class Canvas // Constructor Canvas(); + // Actions + enum UserAction { NoAction, SelectAction, SelectMoleculeAction, SelectElementAction, SelectRadialAction, MeasureDistanceAction, MeasureAngleAction, MeasureTorsionAction, EditDrawAction, EditChainAction, EditTransmuteAction, EditDeleteAction, EditProbeAction, EditBondSingleAction, EditBondDoubleAction, EditBondTripleAction, EditDeleteBondAction, EditAddHydrogenAction, RotateXYAction, RotateZAction, TranslateAction, ZoomAction, TransformRotateXYAction, TransformRotateZAction, TransformTranslateAction, nUserActions }; + /*UA_PICKSELECT, UA_PICKFRAG, UA_PICKELEMENT, UA_PICKRADIAL, + UA_GEOMSELECT, UA_GEOMDIST, UA_GEOMANGLE, UA_GEOMTORSION, + UA_POSSELECT, UA_POSCENTRE, UA_POSTRANSLATE, UA_POSROTATE, + UA_DRAWATOM, UA_DRAWCHAIN, UA_TRANSATOM, UA_DELATOM, UA_PROBEATOM, + UA_BONDSINGLE, UA_BONDDOUBLE, UA_BONDTRIPLE, UA_DELBOND, + UA_ROTATEXY, UA_ROTATEZ, UA_MOVECAM, UA_ZOOMCAM, + UA_MANIPROTXY, UA_MANIPROTZ, UA_MANIPTRANS, + UA_ATOMADDHYDROGEN, + *//*UA_NITEMS };*/ + // Keyboard Key Codes (translated from GTK/KDE keysyms) + enum KeyCode { OtherKey, EscapeKey, LeftShiftKey, RightShiftKey, LeftControlKey, RightControlKey, LeftAltKey, RightAltKey, LeftKey, RightKey, UpKey, DownKey, nKeyCodes }; + //KC_OTHER, KC_ESCAPE, KC_SHIFT_L, KC_SHIFT_R, KC_CONTROL_L, KC_CONTROL_R, KC_ALT_L, KC_ALT_R, KC_LEFT, KC_RIGHT, KC_UP, KC_DOWN, KC_NITEMS }; + /* // Base rendering context */ @@ -73,7 +72,7 @@ class Canvas const char *name_; // Width, height, and aspect ratio of the canvas double width_, height_, aspect_; - // Point at which the stored atom display list was valid (sum of LOG_STRUCTURE and LOG_COORDS points) + // Point at which the stored atom display list was valid (sum of Change::StructureLog and Change::CoordinateLog points) int renderPoint_; // Flag to indicate whether we may draw to the canvas bool valid_; @@ -282,9 +281,9 @@ class Canvas // Inform the canvas of a mouse wheel scroll event void informScroll(bool); // Inform the canvas of a keydown event - void informKeyDown(key_code); + void informKeyDown(KeyCode); // Inform the canvas of a keydown event - void informKeyUp(key_code); + void informKeyUp(KeyCode); }; #endif diff --git a/src/gui/edit_funcs.cpp b/src/gui/edit_funcs.cpp index 057184655..891b74585 100644 --- a/src/gui/edit_funcs.cpp +++ b/src/gui/edit_funcs.cpp @@ -32,22 +32,22 @@ void AtenForm::setSketchElement(int el) void AtenForm::on_DrawAtomButton_clicked(bool on) { - if (on) setUserAction(on, UA_DRAWATOM); + if (on) setUserAction(on, Canvas::EditDrawAction); } void AtenForm::on_DrawChainButton_clicked(bool on) { - if (on) setUserAction(on, UA_DRAWCHAIN); + if (on) setUserAction(on, Canvas::EditChainAction); } void AtenForm::on_DrawDeleteButton_clicked(bool on) { - if (on) setUserAction(on, UA_DELATOM); + if (on) setUserAction(on, Canvas::EditDeleteAction); } void AtenForm::on_DrawTransmuteButton_clicked(bool on) { - if (on) setUserAction(on, UA_TRANSATOM); + if (on) setUserAction(on, Canvas::EditTransmuteAction); } void AtenForm::on_BondToleranceSpin_valueChanged(double d) @@ -57,22 +57,22 @@ void AtenForm::on_BondToleranceSpin_valueChanged(double d) void AtenForm::on_BondSingleButton_clicked(bool on) { - if (on) setUserAction(on, UA_BONDSINGLE); + if (on) setUserAction(on, Canvas::EditBondSingleAction); } void AtenForm::on_BondDoubleButton_clicked(bool on) { - if (on) setUserAction(on, UA_BONDDOUBLE); + if (on) setUserAction(on, Canvas::EditBondDoubleAction); } void AtenForm::on_BondTripleButton_clicked(bool on) { - if (on) setUserAction(on, UA_BONDTRIPLE); + if (on) setUserAction(on, Canvas::EditBondTripleAction); } void AtenForm::on_BondDeleteButton_clicked(bool on) { - if (on) setUserAction(on, UA_DELBOND); + if (on) setUserAction(on, Canvas::EditDeleteBondAction); } void AtenForm::on_ElementHButton_clicked(bool on) @@ -92,12 +92,12 @@ void AtenForm::on_ElementNButton_clicked(bool on) void AtenForm::on_AtomAddHydrogenButton_clicked(bool on) { - if (on) setUserAction(on, UA_ATOMADDHYDROGEN); + if (on) setUserAction(on, Canvas::EditAddHydrogenAction); } void AtenForm::on_ProbeAtomButton_clicked(bool on) { - if (on) setUserAction(on, UA_PROBEATOM); + if (on) setUserAction(on, Canvas::EditProbeAction); } void AtenForm::on_ElementUserButton_clicked(bool on) diff --git a/src/gui/fileactions.cpp b/src/gui/fileactions.cpp index 3d6c8a14c..4f44ebcaa 100644 --- a/src/gui/fileactions.cpp +++ b/src/gui/fileactions.cpp @@ -50,7 +50,7 @@ void AtenForm::on_actionFileOpen_triggered(bool checked) addRecent(gui.loadModelDialog->selectedFilename()); } refreshModelTabs(); - master.currentModel()->logChange(LOG_VISUAL); + master.currentModel()->logChange(Change::VisualLog); gui.modelChanged(); } } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 8859e7957..601fb9611 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -365,31 +365,31 @@ bool GuiQt::saveBeforeClose() */ // Convert Qt keysym to key_code -key_code GuiQt::convertToKeyCode(int sym) +Canvas::KeyCode GuiQt::convertToKeyCode(int sym) { - key_code result = KC_OTHER; + Canvas::KeyCode result = Canvas::OtherKey; switch (sym) { case (Qt::Key_Left): - result = KC_LEFT; + result = Canvas::LeftKey; break; case (Qt::Key_Right): - result = KC_RIGHT; + result = Canvas::RightKey; break; case (Qt::Key_Up): - result = KC_UP; + result = Canvas::UpKey; break; case (Qt::Key_Down): - result = KC_DOWN; + result = Canvas::DownKey; break; case (Qt::Key_Shift): - result = KC_SHIFT_L; + result = Canvas::LeftShiftKey; break; case (Qt::Key_Control): - result = KC_CONTROL_L; + result = Canvas::LeftControlKey; break; case (Qt::Key_Alt): - result = KC_ALT_L; + result = Canvas::LeftAltKey; break; } return result; diff --git a/src/gui/gui.h b/src/gui/gui.h index 7a0e165d3..2edad0d4e 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -127,7 +127,7 @@ class GuiQt */ public: // Convert Qt key code value to internal key - key_code convertToKeyCode(int); + Canvas::KeyCode convertToKeyCode(int); /* // Windows / Dialogs diff --git a/src/gui/icons/uninstall.ico b/src/gui/icons/uninstall.ico index a36a6ac9f..af48381c9 100644 Binary files a/src/gui/icons/uninstall.ico and b/src/gui/icons/uninstall.ico differ diff --git a/src/gui/input.cpp b/src/gui/input.cpp index c6e6ba1c7..8e0a8bdb1 100644 --- a/src/gui/input.cpp +++ b/src/gui/input.cpp @@ -64,7 +64,7 @@ void Canvas::informMouseUp(Prefs::MouseButton button, double x, double y) void Canvas::informMouseMove(double x, double y) { // Perform action associated with mode (if any) - if (activeMode_ != UA_NONE) modeMotion(x,y); + if (activeMode_ != Canvas::NoAction) modeMotion(x,y); rMouseLast_.set(x,y,0.0); } @@ -75,7 +75,7 @@ void Canvas::informScroll(bool dir) } // Inform key down -void Canvas::informKeyDown(key_code key) +void Canvas::informKeyDown(Canvas::KeyCode key) { // Check datamodel... if (displayModel_ == NULL) return; @@ -85,38 +85,38 @@ void Canvas::informKeyDown(key_code key) viewtarget = displayModel_; switch (key) { - case (KC_SHIFT_L): + case (Canvas::LeftShiftKey): keyModifier_[Prefs::ShiftKey] = TRUE; break; - case (KC_SHIFT_R): + case (Canvas::RightShiftKey): keyModifier_[Prefs::ShiftKey] = TRUE; break; - case (KC_CONTROL_L): + case (Canvas::LeftControlKey): keyModifier_[Prefs::CtrlKey] = TRUE; break; - case (KC_CONTROL_R): + case (Canvas::RightControlKey): keyModifier_[Prefs::CtrlKey] = TRUE; break; - case (KC_ALT_L): + case (Canvas::LeftAltKey): keyModifier_[Prefs::AltKey] = TRUE; break; - case (KC_ALT_R): + case (Canvas::RightAltKey): keyModifier_[Prefs::AltKey] = TRUE; break; //case (GDK_Escape): master.check_before_close(); break; - case (KC_LEFT): + case (Canvas::LeftKey): viewtarget->rotate(-10.0,0.0); postRedisplay(); break; - case (KC_RIGHT): + case (Canvas::RightKey): viewtarget->rotate(10.0,0.0); postRedisplay(); break; - case (KC_UP): + case (Canvas::UpKey): viewtarget->rotate(0.0,-10.0); postRedisplay(); break; - case (KC_DOWN): + case (Canvas::DownKey): viewtarget->rotate(0.0,10.0); postRedisplay(); break; @@ -124,26 +124,26 @@ void Canvas::informKeyDown(key_code key) } // Inform key up -void Canvas::informKeyUp(key_code key) +void Canvas::informKeyUp(Canvas::KeyCode key) { switch (key) { - case (KC_SHIFT_L): + case (Canvas::LeftShiftKey): keyModifier_[Prefs::ShiftKey] = FALSE; break; - case (KC_SHIFT_R): + case (Canvas::RightShiftKey): keyModifier_[Prefs::ShiftKey] = FALSE; break; - case (KC_CONTROL_L): + case (Canvas::LeftControlKey): keyModifier_[Prefs::CtrlKey] = FALSE; break; - case (KC_CONTROL_R): + case (Canvas::RightControlKey): keyModifier_[Prefs::CtrlKey] = FALSE; break; - case (KC_ALT_L): + case (Canvas::LeftAltKey): keyModifier_[Prefs::AltKey] = FALSE; break; - case (KC_ALT_R): + case (Canvas::RightAltKey): keyModifier_[Prefs::AltKey] = FALSE; break; } @@ -167,13 +167,13 @@ void Canvas::setSelectedMode(UserAction ua) // Prepare canvas / model depending on the mode switch (ua) { - case (UA_GEOMDIST): - case (UA_GEOMANGLE): - case (UA_GEOMTORSION): - case (UA_BONDSINGLE): - case (UA_BONDDOUBLE): - case (UA_BONDTRIPLE): - case (UA_DELBOND): + case (Canvas::MeasureDistanceAction): + case (Canvas::MeasureAngleAction): + case (Canvas::MeasureTorsionAction): + case (Canvas::EditBondSingleAction): + case (Canvas::EditBondDoubleAction): + case (Canvas::EditBondTripleAction): + case (Canvas::EditDeleteBondAction): subselectEnabled_ = TRUE; subselection_.clear(); break; @@ -224,7 +224,7 @@ void Canvas::beginMode(Prefs::MouseButton button) } } // Now prepare for the action - if (activeMode_ == UA_NONE) + if (activeMode_ == Canvas::NoAction) { switch (prefs.mouseAction(button)) { @@ -234,7 +234,7 @@ void Canvas::beginMode(Prefs::MouseButton button) // Some modes require actions to be done when the button is first depressed switch (activeMode_) { - case (UA_DRAWCHAIN): + case (Canvas::EditChainAction): // If there is currently no atom under the mouse, draw one... if (atomHover_ == NULL) { @@ -249,17 +249,16 @@ void Canvas::beginMode(Prefs::MouseButton button) break; 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; + if (manipulate && zrotate) activeMode_ = Canvas::TransformRotateZAction; + else if (manipulate) activeMode_ = Canvas::TransformRotateXYAction; + else if (zrotate) activeMode_ = Canvas::RotateZAction; + else activeMode_ = Canvas::RotateXYAction; break; case (Prefs::ZoomAction): - activeMode_ = UA_ZOOMCAM; + activeMode_ = Canvas::ZoomAction; break; case (Prefs::TranslateAction): - activeMode_ = UA_MOVECAM; - manipulate ? activeMode_ = UA_MANIPTRANS : activeMode_ = UA_MOVECAM; + activeMode_ = (manipulate ? Canvas::TransformTranslateAction : Canvas::TranslateAction); break; } // If we're manipulating, prepare the transform @@ -297,13 +296,14 @@ void Canvas::endMode(Prefs::MouseButton button) atoms = new Atom*[4]; // Reset mouse button flag mouseButton_[button] = FALSE; + // Copy the current mode and reset it so we redraw properly + Canvas::UserAction endingMode = activeMode_; + activeMode_ = Canvas::NoAction; // Finalize the action - switch (activeMode_) + switch (endingMode) { - // Group all the plain selection modes together (one for each toolbar in a diff. window) - case (UA_PICKSELECT): - case (UA_GEOMSELECT): - case (UA_POSSELECT): + // Plain atom / box select + case (Canvas::SelectAction): area = fabs(rMouseUp_.x - rMouseDown_.x) * fabs(rMouseUp_.y - rMouseDown_.y); displayModel_->beginUndostate("Change Selection"); displayModel_->projectAll(); @@ -320,26 +320,24 @@ void Canvas::endMode(Prefs::MouseButton button) } else displayModel_->selectBox(rMouseDown_.x, rMouseDown_.y, rMouseUp_.x, rMouseUp_.y); displayModel_->endUndostate(); - // Set activeMode_ early to prevent presistence of selection box - activeMode_ = UA_NONE; gui.modelChanged(TRUE,FALSE,FALSE); break; // Now do the rest - case (UA_PICKFRAG): + case (Canvas::SelectMoleculeAction): displayModel_->beginUndostate("Select Molecule"); if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); if (atomHover_ != NULL) displayModel_->selectTree(atomHover_); displayModel_->endUndostate(); gui.modelChanged(TRUE,FALSE,FALSE); break; - case (UA_PICKELEMENT): + case (Canvas::SelectElementAction): displayModel_->beginUndostate("Select Element"); if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); if (atomHover_ != NULL) displayModel_->selectElement(atomHover_); displayModel_->endUndostate(); gui.modelChanged(TRUE,FALSE,FALSE); break; - case (UA_PICKRADIAL): + case (Canvas::SelectRadialAction): displayModel_->beginUndostate("Select Radial"); if (!keyModifier_[Prefs::ShiftKey]) displayModel_->selectNone(); if (atomHover_ != NULL) @@ -352,7 +350,7 @@ void Canvas::endMode(Prefs::MouseButton button) gui.modelChanged(TRUE,FALSE,FALSE); break; // Measurements - case (UA_GEOMDIST): + case (Canvas::MeasureDistanceAction): // Must be two atoms in subselection to continue if (subselection_.nItems() != 2) break; displayModel_->beginUndostate("Measure Distance"); @@ -362,7 +360,7 @@ void Canvas::endMode(Prefs::MouseButton button) subselection_.clear(); gui.modelChanged(FALSE,FALSE,FALSE); break; - case (UA_GEOMANGLE): + case (Canvas::MeasureAngleAction): // Must be two atoms in subselection to continue if (subselection_.nItems() != 3) break; displayModel_->beginUndostate("Measure Angle"); @@ -372,7 +370,7 @@ void Canvas::endMode(Prefs::MouseButton button) subselection_.clear(); gui.modelChanged(FALSE,FALSE,FALSE); break; - case (UA_GEOMTORSION): + case (Canvas::MeasureTorsionAction): // Must be two atoms in subselection to continue if (subselection_.nItems() != 4) break; displayModel_->beginUndostate("Measure Torsion"); @@ -383,7 +381,7 @@ void Canvas::endMode(Prefs::MouseButton button) gui.modelChanged(FALSE,FALSE,FALSE); break; // Draw single atom - case (UA_DRAWATOM): + case (Canvas::EditDrawAction): // Make sure we don't draw on top of an existing atom if (atomHover_ == NULL) { @@ -395,7 +393,7 @@ void Canvas::endMode(Prefs::MouseButton button) gui.modelChanged(TRUE,FALSE,TRUE); break; // Draw chains of atoms - case (UA_DRAWCHAIN): + case (Canvas::EditChainAction): // If there is no atom under the mouse we draw one i = displayModel_->atomOnScreen(rMouseUp_.x,rMouseUp_.y); if ((atomHover_ == i) && (i != NULL)) break; @@ -412,31 +410,35 @@ void Canvas::endMode(Prefs::MouseButton button) // Search for existing bond between atoms b = i->findBond(atomHover_); if (b == NULL) bt = Bond::Single; - else bt = Bond::increaseBondType(b->order()); + else + { + bt = Bond::increaseBondType(b->order()); + displayModel_->unbondAtoms(i,atomHover_); + } displayModel_->bondAtoms(i,atomHover_,bt); } displayModel_->endUndostate(); gui.modelChanged(TRUE,FALSE,TRUE); break; - case (UA_TRANSATOM): + case (Canvas::EditTransmuteAction): displayModel_->beginUndostate("Transmute"); displayModel_->transmuteAtom(atomHover_, master.sketchElement()); displayModel_->endUndostate(); gui.modelChanged(TRUE,FALSE,TRUE); break; - case (UA_DELATOM): + case (Canvas::EditDeleteAction): displayModel_->beginUndostate("Delete Atom"); displayModel_->deleteAtom(atomHover_); displayModel_->endUndostate(); gui.modelChanged(TRUE,FALSE,TRUE); break; - case (UA_PROBEATOM): + case (Canvas::EditProbeAction): if (atomHover_ != NULL) atomHover_->print(); break; // Bonding - case (UA_BONDSINGLE): - case (UA_BONDDOUBLE): - case (UA_BONDTRIPLE): + case (Canvas::EditBondSingleAction): + case (Canvas::EditBondDoubleAction): + case (Canvas::EditBondTripleAction): // Must be two atoms in subselection to continue if (subselection_.nItems() != 2) break; subselection_.fillArray(2,atoms); @@ -444,19 +446,19 @@ void Canvas::endMode(Prefs::MouseButton button) if (b == NULL) { displayModel_->beginUndostate("Bond Atoms"); - displayModel_->bondAtoms(atoms[0],atoms[1],Bond::BondType(activeMode_-UA_BONDSINGLE+1)); + displayModel_->bondAtoms(atoms[0],atoms[1],Bond::BondType(endingMode-Canvas::EditBondSingleAction+1)); displayModel_->endUndostate(); } else { displayModel_->beginUndostate("Change Bond"); - displayModel_->changeBond(b,Bond::BondType(activeMode_-UA_BONDSINGLE+1)); + displayModel_->changeBond(b,Bond::BondType(endingMode-Canvas::EditBondSingleAction+1)); displayModel_->endUndostate(); } subselection_.clear(); gui.modelChanged(FALSE,FALSE,FALSE); break; - case (UA_DELBOND): + case (Canvas::EditDeleteBondAction): // Must be two atoms in subselection to continue if (subselection_.nItems() != 2) break; subselection_.fillArray(2,atoms); @@ -470,7 +472,7 @@ void Canvas::endMode(Prefs::MouseButton button) gui.modelChanged(FALSE,FALSE,FALSE); break; // Misc - case (UA_ATOMADDHYDROGEN): + case (Canvas::EditAddHydrogenAction): if (atomHover_ != NULL) { displayModel_->beginUndostate("Add Hydrogen to Atom"); @@ -480,25 +482,24 @@ void Canvas::endMode(Prefs::MouseButton button) } break; // Model transformations - case (UA_MANIPROTXY): - case (UA_MANIPROTZ): - case (UA_MANIPTRANS): + case (Canvas::TransformRotateXYAction): + case (Canvas::TransformRotateZAction): + case (Canvas::TransformTranslateAction): // Clear list of rSelection_ if nothing was moved if (!hasMoved_) rSelection_.clear(); displayModel_->finalizeTransform(rSelection_); gui.modelChanged(TRUE,FALSE,FALSE); break; // View changes (no action) - case (UA_ROTATEXY): - case (UA_ROTATEZ): - case (UA_MOVECAM): - case (UA_ZOOMCAM): + case (Canvas::RotateXYAction): + case (Canvas::RotateZAction): + case (Canvas::TranslateAction): + case (Canvas::ZoomAction): break; default: - printf("No button_up handler defined for UserAction %i.\n", activeMode_); + printf("No endMode handler defined for UserAction %i.\n", endingMode); break; } - activeMode_ = UA_NONE; dbgEnd(Debug::Calls,"Canvas::endMode"); } @@ -523,36 +524,36 @@ void Canvas::modeMotion(double x, double y) // Use activeMode_ to determine what needs to be performed switch (activeMode_) { - case (UA_NONE): + case (Canvas::NoAction): break; - case (UA_ROTATEXY): + case (Canvas::RotateXYAction): displayModel_->rotate(delta.x/2.0,delta.y/2.0); break; - case (UA_ROTATEZ): + case (Canvas::RotateZAction): displayModel_->zRotate(delta.x/2.0); break; - case (UA_MOVECAM): + case (Canvas::TranslateAction): displayModel_->adjustCamera(delta/15.0,0.0); break; - case (UA_MANIPROTXY): + case (Canvas::ZoomAction): + if (prefs.hasPerspective()) displayModel_->adjustCamera(0.0,0.0,delta.y,0.0); + else displayModel_->adjustOrthoSize(delta.y); + calculateDrawPixelWidth(); + break; + case (Canvas::TransformRotateXYAction): displayModel_->rotateSelectionWorld(delta.x/2.0,delta.y/2.0); hasMoved_ = TRUE; break; - case (UA_MANIPROTZ): + case (Canvas::TransformRotateZAction): displayModel_->rotateSelectionZaxis(delta.x/2.0); hasMoved_ = TRUE; break; - case (UA_MANIPTRANS): + case (Canvas::TransformTranslateAction): delta.y = -delta.y; delta /= displayModel_->translateScale() * 2.0; displayModel_->translateSelectionWorld(delta); hasMoved_ = TRUE; break; - case (UA_ZOOMCAM): - if (prefs.hasPerspective()) displayModel_->adjustCamera(0.0,0.0,delta.y,0.0); - else displayModel_->adjustOrthoSize(delta.y); - calculateDrawPixelWidth(); - break; default: break; } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 68b975f6e..6364597a9 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -123,7 +123,7 @@ class AtenForm : public QMainWindow // Select Toolbar */ private: - void setUserAction(bool checked, UserAction ua); + void setUserAction(bool checked, Canvas::UserAction ua); private slots: void on_actionSelectAtoms_triggered(bool on); void on_actionSelectMolecules_triggered(bool on); diff --git a/src/gui/mainwindow_funcs.cpp b/src/gui/mainwindow_funcs.cpp index 01f4d0580..9026c88f7 100644 --- a/src/gui/mainwindow_funcs.cpp +++ b/src/gui/mainwindow_funcs.cpp @@ -35,11 +35,17 @@ const char *BIF_filters[BIF_NITEMS] = { "Windows Bitmap (*.bmp)", "Joint Photographic Experts Group (*.jpg)", "Portable Network Graphics (*.png)", "Portable Pixmap (*.ppm)", "X11 Bitmap (*.xbm)", "X11 Pixmap (*.xpm)" }; const char *BIF_extensions[BIF_NITEMS] = { "bmp", "jpg", "png", "ppm", "xbm", "xpm" }; bitmap_format BIF_from_text(const char *s) - { return (bitmap_format) enumSearch("bitmap format",BIF_NITEMS,BIF_extensions,s); } +{ + return (bitmap_format) enumSearch("bitmap format",BIF_NITEMS,BIF_extensions,s); +} const char *filter_from_BIF(bitmap_format bif) - { return BIF_filters[bif]; } +{ + return BIF_filters[bif]; +} const char *extension_from_BIF(bitmap_format bif) - { return BIF_extensions[bif]; } +{ + return BIF_extensions[bif]; +} // Constructor AtenForm::AtenForm(QMainWindow *parent) : QMainWindow(parent) @@ -65,12 +71,12 @@ void AtenForm::closeEvent(QCloseEvent *event) */ // Change user interaction mode -void AtenForm::setUserAction(bool on, UserAction ua) +void AtenForm::setUserAction(bool on, Canvas::UserAction ua) { // We pass all changes to the user interaction mode through here. // This way we can 'link' the selectToolBar and all the other buttons.... if (!on) return; - if ((ua >= UA_PICKSELECT) && (ua <= UA_PICKRADIAL)) + if ((ua >= Canvas::SelectAction) && (ua <= Canvas::SelectRadialAction)) { // One of the select actions in selectGroup dummyButton->setChecked(TRUE); @@ -86,15 +92,15 @@ void AtenForm::setUserAction(bool on, UserAction ua) void AtenForm::keyPressEvent(QKeyEvent *event) { - key_code kc = gui.convertToKeyCode(event->key()); - if (kc != KC_OTHER) gui.mainView.informKeyDown(kc); + Canvas::KeyCode kc = gui.convertToKeyCode(event->key()); + if (kc != Canvas::OtherKey) gui.mainView.informKeyDown(kc); else event->ignore(); } void AtenForm::keyReleaseEvent(QKeyEvent *event) { - key_code kc = gui.convertToKeyCode(event->key()); - if (kc != KC_OTHER) gui.mainView.informKeyUp(kc); + Canvas::KeyCode kc = gui.convertToKeyCode(event->key()); + if (kc != Canvas::OtherKey) gui.mainView.informKeyUp(kc); else event->ignore(); } @@ -191,7 +197,7 @@ void AtenForm::loadRecent() if (f != NULL) { f->execute(filename.get()); - master.currentModel()->logChange(LOG_VISUAL); + master.currentModel()->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } else @@ -314,12 +320,12 @@ void AtenForm::runScript() QAction *action = qobject_cast (sender()); if (!action) { - printf("AtenForm::run_script - Sender was not a QAction.\n"); + printf("AtenForm::runScript - Sender was not a QAction.\n"); return; } // Find the CommandList from the loadedscripts() Reflist Refitem *ri = scriptActions_.search(action); - if (ri == NULL) printf("AtenForm::run_script - Could not find QAction in Reflist.\n"); + if (ri == NULL) printf("AtenForm::runScript - Could not find QAction in Reflist.\n"); else { // Execute the script @@ -351,17 +357,17 @@ void AtenForm::on_actionMouseTranslate_triggered(bool checked) */ void AtenForm::on_actionSelectAtoms_triggered(bool on) { - setUserAction(on, UA_PICKSELECT); + setUserAction(on, Canvas::SelectAction); } void AtenForm::on_actionSelectMolecules_triggered(bool on) { - setUserAction(on, UA_PICKFRAG); + setUserAction(on, Canvas::SelectMoleculeAction); } void AtenForm::on_actionSelectElement_triggered(bool on) { - setUserAction(on, UA_PICKELEMENT); + setUserAction(on, Canvas::SelectElementAction); } /* @@ -415,7 +421,7 @@ void AtenForm::switchStack(int buttonid, bool checked) { // If the state of the button is *not* checked then we hide the stack since no buttons are checked. Otherwise, uncheck all other buttons and show the corresponding widget in the stack for this button. int n; - UserAction ua = gui.mainView.selectedMode(); + Canvas::UserAction ua = gui.mainView.selectedMode(); if (checked) { for (n=0; nsetChecked(FALSE); @@ -424,14 +430,14 @@ void AtenForm::switchStack(int buttonid, bool checked) } else ui.MainWindowStack->hide(); // Choose a plain selection mode again... - if ((ua == UA_NONE) || (ua > UA_PICKRADIAL)) + if ((ua == Canvas::NoAction) || (ua > Canvas::SelectRadialAction)) { ui.actionSelectAtoms->setChecked(TRUE); - setUserAction(TRUE, UA_PICKSELECT); + setUserAction(TRUE, Canvas::SelectAction); } //ui.actionSelectAtoms->setChecked(TRUE); //set_useraction(TRUE, UA_PICKSELECT); - master.currentModel()->logChange(LOG_CAMERA); + master.currentModel()->logChange(Change::CameraLog); } void AtenForm::on_ShowAtomPageButton_clicked(bool checked) diff --git a/src/gui/modelactions.cpp b/src/gui/modelactions.cpp index e2adf342b..4e7bc1beb 100644 --- a/src/gui/modelactions.cpp +++ b/src/gui/modelactions.cpp @@ -77,5 +77,5 @@ void AtenForm::on_actionModelShowAll_triggered(bool checked) // Make all atoms in model visible Model *m = master.currentModel(); for (Atom *i = m->atoms(); i != NULL; i = i->next) m->setHidden(i, FALSE); - m->logChange(LOG_VISUAL); + m->logChange(Change::VisualLog); } diff --git a/src/gui/prefs_funcs.cpp b/src/gui/prefs_funcs.cpp index ab30ab1da..17ec8c8c4 100644 --- a/src/gui/prefs_funcs.cpp +++ b/src/gui/prefs_funcs.cpp @@ -123,7 +123,7 @@ void AtenPrefs::on_ElementAmbientColourButton_clicked(bool checked) ui.ElementAmbientColourFrame->setColour(newcol); ui.ElementAmbientColourFrame->update(); // Re-set atom colours in model(s) - master.currentModel()->logChange(LOG_VISUAL); + master.currentModel()->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } @@ -143,7 +143,7 @@ void AtenPrefs::on_ElementDiffuseColourButton_clicked(bool checked) ui.ElementDiffuseColourFrame->setColour(newcol); ui.ElementDiffuseColourFrame->update(); // Re-set atom colours in model(s) - master.currentModel()->logChange(LOG_VISUAL); + master.currentModel()->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } @@ -155,7 +155,7 @@ void AtenPrefs::updateAfterViewPrefs() { gui.mainView.createLists(); master.currentModel()->renderSource()->projectAll(); - master.currentModel()->renderSource()->logChange(LOG_VISUAL); + master.currentModel()->renderSource()->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } @@ -212,7 +212,7 @@ void AtenPrefs::on_BondQualitySpin_valueChanged(int value) void AtenPrefs::setVisibleObject(Prefs::ViewObject vo, int state) { prefs.setVisible(vo, (state == Qt::Checked ? TRUE : FALSE)); - master.currentModel()->logChange(LOG_VISUAL); + master.currentModel()->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } @@ -308,7 +308,7 @@ void AtenPrefs::on_SpotlightSpecularColourButton_clicked(bool checked) void AtenPrefs::on_ShininessSpin_valueChanged(int value) { prefs.setShininess(value); - master.currentModel()->logChange(LOG_VISUAL); + master.currentModel()->logChange(Change::VisualLog); gui.mainView.postRedisplay(); } diff --git a/src/gui/tcanvas_funcs.cpp b/src/gui/tcanvas_funcs.cpp index 480c10d48..9769a7375 100644 --- a/src/gui/tcanvas_funcs.cpp +++ b/src/gui/tcanvas_funcs.cpp @@ -60,7 +60,7 @@ void TCanvas::resizeGL(int width, int height) if (widgetCanvas_ != NULL) { widgetCanvas_->configure(); - if (widgetCanvas_->displayModel() != NULL) widgetCanvas_->displayModel()->logChange(LOG_CAMERA); + if (widgetCanvas_->displayModel() != NULL) widgetCanvas_->displayModel()->logChange(Change::CameraLog); } else printf("NO CANVAS SET RESIZE\n"); } diff --git a/src/gui/trajectoryactions.cpp b/src/gui/trajectoryactions.cpp index 51a73c015..015f6f2be 100644 --- a/src/gui/trajectoryactions.cpp +++ b/src/gui/trajectoryactions.cpp @@ -31,28 +31,28 @@ void AtenForm::on_actionFrameNext_triggered(bool checked) { master.currentModel()->seekNextFrame(); - master.currentModel()->renderSource()->logChange(LOG_CAMERA); + master.currentModel()->renderSource()->logChange(Change::CameraLog); gui.modelChanged(TRUE,TRUE,FALSE); } void AtenForm::on_actionFramePrevious_triggered(bool checked) { master.currentModel()->seekPreviousFrame(); - master.currentModel()->renderSource()->logChange(LOG_CAMERA); + master.currentModel()->renderSource()->logChange(Change::CameraLog); gui.modelChanged(TRUE,TRUE,FALSE); } void AtenForm::on_actionFrameFirst_triggered(bool checked) { master.currentModel()->seekFirstFrame(); - master.currentModel()->renderSource()->logChange(LOG_CAMERA); + master.currentModel()->renderSource()->logChange(Change::CameraLog); gui.modelChanged(TRUE,TRUE,FALSE); } void AtenForm::on_actionFrameLast_triggered(bool checked) { master.currentModel()->seekLastFrame(); - master.currentModel()->renderSource()->logChange(LOG_CAMERA); + master.currentModel()->renderSource()->logChange(Change::CameraLog); gui.modelChanged(TRUE,TRUE,FALSE); } diff --git a/src/gui/viewactions.cpp b/src/gui/viewactions.cpp index e564cf47f..d80efafad 100644 --- a/src/gui/viewactions.cpp +++ b/src/gui/viewactions.cpp @@ -69,7 +69,7 @@ void AtenForm::on_actionViewModel_triggered(bool checked) master.currentModel()->setRenderFromSelf(); Model *m = master.currentModel()->renderSource(); m->calculateViewMatrix(); - m->logChange(LOG_CAMERA); + m->logChange(Change::CameraLog); gui.modelChanged(); } @@ -79,7 +79,7 @@ void AtenForm::on_actionViewTrajectory_triggered(bool checked) master.currentModel()->setRenderFromFrames(); Model *m = master.currentModel()->renderSource(); m->calculateViewMatrix(); - m->logChange(LOG_CAMERA); + m->logChange(Change::CameraLog); gui.modelChanged(); } diff --git a/src/methods/cg.cpp b/src/methods/cg.cpp index 68cce56ab..bc7c12cbb 100644 --- a/src/methods/cg.cpp +++ b/src/methods/cg.cpp @@ -148,7 +148,7 @@ void MethodCg::minimise(Model *srcmodel, double econ, double fcon) // Calculate fresh new forces for the model, log changes / update, and exit. srcmodel->calculateForces(srcmodel); srcmodel->updateMeasurements(); - srcmodel->logChange(LOG_COORDS); + srcmodel->logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"MethodCg::minimise"); } diff --git a/src/methods/mc.cpp b/src/methods/mc.cpp index 52007c02b..bafbf9a16 100644 --- a/src/methods/mc.cpp +++ b/src/methods/mc.cpp @@ -305,7 +305,7 @@ bool MonteCarlo::minimise(Model* srcmodel, double econ, double fcon) srcmodel->energy.print(); // Finalise - srcmodel->logChange(LOG_COORDS); + srcmodel->logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"MonteCarlo::minimise"); return TRUE; @@ -688,7 +688,7 @@ bool MonteCarlo::disorder(Model *destmodel) //else printf("Patterns are NOT valid.\n"); //if (destmodel->isExpressionValid()) printf("Expression is valid...\n"); //else printf("Expression is NOT valid.\n"); - destmodel->logChange(LOG_COORDS); + destmodel->logChange(Change::CoordinateLog); gui.mainWindow->refreshDisorderPage(); gui.modelChanged(); dbgEnd(Debug::Calls,"MonteCarlo::insert"); diff --git a/src/methods/sd.cpp b/src/methods/sd.cpp index beea31bc3..f467588ea 100644 --- a/src/methods/sd.cpp +++ b/src/methods/sd.cpp @@ -119,7 +119,7 @@ void MethodSd::minimise(Model* srcmodel, double econ, double fcon) // Calculate fresh new forces for the model, log changes / update, and exit. srcmodel->calculateForces(srcmodel); srcmodel->updateMeasurements(); - srcmodel->logChange(LOG_COORDS); + srcmodel->logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"MethodSd::minimise"); } diff --git a/src/model/atom.cpp b/src/model/atom.cpp index 334c24a7b..c3c7dab11 100644 --- a/src/model/atom.cpp +++ b/src/model/atom.cpp @@ -47,12 +47,12 @@ Atom *Model::addAtom(short int newel, Vec3 pos) newatom->r() = pos; mass_ += elements.atomicMass(newel); calculateDensity(); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_ATOM,newatom); + newchange->set(Change::AtomEvent,newatom); } dbgEnd(Debug::Calls,"Model::addAtom"); return newatom; @@ -65,14 +65,14 @@ Atom *Model::addCopy(Atom *source) Atom *newatom = atoms_.add(); newatom->copy(source); newatom->setId(atoms_.nItems() - 1); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); mass_ += elements.atomicMass(newatom->element()); calculateDensity(); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_ATOM,newatom); + newchange->set(Change::AtomEvent,newatom); } dbgEnd(Debug::Calls,"Model::addCopy"); return newatom; @@ -86,14 +86,14 @@ Atom *Model::addCopy(Atom *afterthis, Atom *source) //printf("Adding copy after... %li %li\n",afterthis,source); newatom->copy(source); renumberAtoms( (afterthis != NULL ? afterthis->prev : NULL) ); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); mass_ += elements.atomicMass(newatom->element()); calculateDensity(); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_ATOM,newatom); + newchange->set(Change::AtomEvent,newatom); } dbgEnd(Debug::Calls,"Model::addCopy"); return newatom; @@ -110,12 +110,12 @@ void Model::removeAtom(Atom *xatom) // Renumber the ids of all atoms in the list after this one for (Atom *i = xatom->next; i != NULL; i = i->next) i->decreaseId(); if (xatom->isSelected()) deselectAtom(xatom); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(-UE_ATOM,xatom); + newchange->set(-Change::AtomEvent,xatom); } atoms_.remove(xatom); dbgEnd(Debug::Calls,"Model::removeAtom"); @@ -162,12 +162,12 @@ void Model::transmuteAtom(Atom *i, short int el) i->setElement(el); mass_ += elements.atomicMass(i); calculateDensity(); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_TRANSMUTE,i->id(),oldel,el); + newchange->set(Change::TransmuteEvent,i->id(),oldel,el); } } } @@ -269,7 +269,7 @@ void Model::zeroForcesFixed() void Model::setHidden(Atom *i, bool hidden) { i->setHidden(hidden); - logChange(LOG_VISUAL); + logChange(Change::VisualLog); } // Normalise forces @@ -300,13 +300,13 @@ void Model::normaliseForces(double norm) void Model::translateAtom(Atom *target, Vec3 delta) { target->r() += delta; - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_TRANSLATE,target->id()); - newchange->set(UE_TRANSLATE,&delta); + newchange->set(Change::TranslateEvent,target->id()); + newchange->set(Change::TranslateEvent,&delta); } } @@ -316,12 +316,12 @@ void Model::positionAtom(Atom *target, Vec3 newr) static Vec3 delta; delta = newr - target->r(); target->r() = newr; - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_TRANSLATE,target->id()); - newchange->set(UE_TRANSLATE,&delta); + newchange->set(Change::TranslateEvent,target->id()); + newchange->set(Change::TranslateEvent,&delta); } } diff --git a/src/model/bond.cpp b/src/model/bond.cpp index 332853d3e..e6fc42eac 100644 --- a/src/model/bond.cpp +++ b/src/model/bond.cpp @@ -44,12 +44,12 @@ void Model::bondAtoms(Atom *i, Atom *j, Bond::BondType bt) if (b->order() != bt) { b->setOrder(bt); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_BOND,i->id(),j->id(),bt); + newchange->set(Change::BondEvent,i->id(),j->id(),bt); } } } @@ -60,12 +60,12 @@ void Model::bondAtoms(Atom *i, Atom *j, Bond::BondType bt) b->setAtoms(i,j); i->acceptBond(b); j->acceptBond(b); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_BOND,i->id(),j->id(),bt); + newchange->set(Change::BondEvent,i->id(),j->id(),bt); } } } @@ -117,12 +117,12 @@ void Model::unbondAtoms(Atom *i, Atom *j, Bond *bij) Bond::BondType bt = b->order(); b->atomI()->detachBond(b); b->atomJ()->detachBond(b); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(-UE_BOND,i->id(),j->id(),bt); + newchange->set(-Change::BondEvent,i->id(),j->id(),bt); } dbgEnd(Debug::Calls,"Model::unbondAtoms"); } @@ -144,7 +144,7 @@ void Model::clearBonding() bref = i->bonds(); } } - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::clearBonding"); } @@ -305,12 +305,12 @@ void Model::changeBond(Bond *b, Bond::BondType bt) { Bond::BondType oldorder = b->order(); b->setOrder(bt); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_BONDORDER,b->atomI()->id(),b->atomJ()->id(),oldorder,bt); + newchange->set(Change::BondEventORDER,b->atomI()->id(),b->atomJ()->id(),oldorder,bt); } } diff --git a/src/model/cell.cpp b/src/model/cell.cpp index a33339cdc..a9edd97b1 100644 --- a/src/model/cell.cpp +++ b/src/model/cell.cpp @@ -64,12 +64,12 @@ void Model::setCell(Vec3 lengths, Vec3 angles) Vec3 oldangles = cell_.angles(); // Set new axes cell_.set(lengths, angles); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_CELL, &oldlengths, &oldangles, &lengths, &angles); + newchange->set(Change::CellEvent, &oldlengths, &oldangles, &lengths, &angles); } dbgEnd(Debug::Calls,"Model::setCell[vectors]"); } @@ -84,12 +84,12 @@ void Model::setCell(Mat3 axes) oldlengths = cell_.lengths(); // Set new axes cell_.set(axes); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_CELL, &oldlengths, &oldangles, &cell_.lengths(), &cell_.angles()); + newchange->set(Change::CellEvent, &oldlengths, &oldangles, &cell_.lengths(), &cell_.angles()); } dbgEnd(Debug::Calls,"Model::setCell[axes]"); } @@ -99,8 +99,8 @@ void Model::removeCell() { dbgBegin(Debug::Calls,"Model::removeCell"); cell_.reset(); - logChange(LOG_VISUAL); - logChange(LOG_STRUCTURE); + logChange(Change::VisualLog); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::removeCell"); } @@ -110,7 +110,7 @@ void Model::foldAllAtoms() dbgBegin(Debug::Calls,"Model::foldAllAtoms"); // Standard fold - individual atoms for (Atom *i = atoms_.first(); i != NULL; i = i->next) cell_.fold(i); - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"Model::foldAllAtoms"); } @@ -146,7 +146,7 @@ void Model::foldAllMolecules() } } } - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"Model::foldAllMolecules"); } @@ -259,7 +259,7 @@ void Model::scaleCell(const Vec3 &scale) } // Set new cell and update model setCell(newaxes); - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"Model::scaleCell"); } @@ -376,7 +376,7 @@ void Model::replicateCell(const Vec3 &neg, const Vec3 &pos) } master.cancelProgress(); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::replicateCell"); } diff --git a/src/model/expression.cpp b/src/model/expression.cpp index 5ac7c997a..6e13d193f 100644 --- a/src/model/expression.cpp +++ b/src/model/expression.cpp @@ -33,7 +33,7 @@ Forcefield *Model::forcefield() // Return whether the expression is valid bool Model::isExpressionValid() { - return (expressionPoint_ == logs_[LOG_STRUCTURE] ? TRUE : FALSE); + return (expressionPoint_ == logs_[Change::StructureLog] ? TRUE : FALSE); } // Manually invalidates the expression @@ -117,7 +117,7 @@ bool Model::createExpression(bool vdwOnly) ffa = uniqueTypes_.add(); ffa->copy(ri->item); } - expressionPoint_ = logs_[LOG_STRUCTURE]; + expressionPoint_ = logs_[Change::StructureLog]; dbgEnd(Debug::Calls,"Model::createExpression"); return TRUE; } diff --git a/src/model/glyph.cpp b/src/model/glyph.cpp index 033da44bb..8a1d8134e 100644 --- a/src/model/glyph.cpp +++ b/src/model/glyph.cpp @@ -25,7 +25,7 @@ // Create new glyph in this model Glyph *Model::addGlyph() { - logChange(LOG_VISUAL); + logChange(Change::VisualLog); return glyphs_.add(); } diff --git a/src/model/measure.cpp b/src/model/measure.cpp index c490ae281..d73f70377 100644 --- a/src/model/measure.cpp +++ b/src/model/measure.cpp @@ -40,9 +40,9 @@ void Model::measureDistance(Atom *i, Atom *j) { // Measure distances between atoms dbgBegin(Debug::Calls,"Model::measureDistance"); - Measurement *newdist = findMeasurement(GT_DISTANCE,i,j); + Measurement *newdist = findMeasurement(Measurement::DistanceMeasurement,i,j); // If this distance isn't currently in the list, add it. Otherwise, delete it - if (newdist == NULL) addMeasurement(GT_DISTANCE,i,j); + if (newdist == NULL) addMeasurement(Measurement::DistanceMeasurement,i,j); else removeMeasurement(newdist); dbgEnd(Debug::Calls,"Model::measureDistance"); } @@ -52,9 +52,9 @@ void Model::measureAngle(Atom *i, Atom *j, Atom *k) { // Measure angles between atoms dbgBegin(Debug::Calls,"Model::measureAngle"); - Measurement *newangle = findMeasurement(GT_ANGLE,i,j,k); + Measurement *newangle = findMeasurement(Measurement::AngleMeasurement,i,j,k); // Check that this angle isn't already in the list. If it is, delete it - if (newangle == NULL) addMeasurement(GT_ANGLE,i,j,k); + if (newangle == NULL) addMeasurement(Measurement::AngleMeasurement,i,j,k); else removeMeasurement(newangle); dbgEnd(Debug::Calls,"Model::measureAngle"); } @@ -64,9 +64,9 @@ void Model::measureTorsion(Atom *i, Atom *j, Atom *k, Atom *l) { // Measure torsions between atoms dbgBegin(Debug::Calls,"Model::measureTorsion"); - Measurement *newtorsion = findMeasurement(GT_TORSION,i,j,k,l); + Measurement *newtorsion = findMeasurement(Measurement::TorsionMeasurement,i,j,k,l); // If this torsion isn't in the list, add it. Otherwise, delete it. - if (newtorsion == NULL) addMeasurement(GT_TORSION,i,j,k,l); + if (newtorsion == NULL) addMeasurement(Measurement::TorsionMeasurement,i,j,k,l); else removeMeasurement(newtorsion); dbgEnd(Debug::Calls,"Model::measureTorsion"); } @@ -80,17 +80,17 @@ void Model::removeMeasurement(Measurement *me) { Change *newchange = recordingState_->addChange(); Atom **atoms = me->atoms(); - GeometryType type = me->type(); + Measurement::MeasurementType type = me->type(); switch (type) { - case (GT_DISTANCE): - newchange->set(-UE_MEASUREMENT, type, atoms[0]->id(), atoms[1]->id()); + case (Measurement::DistanceMeasurement): + newchange->set(-Change::MeasurementEvent, type, atoms[0]->id(), atoms[1]->id()); break; - case (GT_ANGLE): - newchange->set(-UE_MEASUREMENT, type, atoms[0]->id(), atoms[1]->id(), atoms[2]->id()); + case (Measurement::AngleMeasurement): + newchange->set(-Change::MeasurementEvent, type, atoms[0]->id(), atoms[1]->id(), atoms[2]->id()); break; - case (GT_TORSION): - newchange->set(-UE_MEASUREMENT, type, atoms[0]->id(), atoms[1]->id(), atoms[2]->id(), atoms[3]->id()); + case (Measurement::TorsionMeasurement): + newchange->set(-Change::MeasurementEvent, type, atoms[0]->id(), atoms[1]->id(), atoms[2]->id(), atoms[3]->id()); break; } } @@ -99,7 +99,7 @@ void Model::removeMeasurement(Measurement *me) } // Clear measurements of specific type -void Model::removeMeasurements(GeometryType gt) +void Model::removeMeasurements(Measurement::MeasurementType gt) { dbgBegin(Debug::Calls,"Model::removeMeasurements"); Measurement *me = measurements_.first(), *meNext; @@ -131,7 +131,7 @@ void Model::removeMeasurements(Atom *xatom) { remove = FALSE; atoms = m->atoms(); - for (n=0; ntype()); n++) if (atoms[n] == xatom) remove = TRUE; + for (n=0; ntype()); n++) if (atoms[n] == xatom) remove = TRUE; if (remove) { nextm = m->next; @@ -144,7 +144,7 @@ void Model::removeMeasurements(Atom *xatom) } // Add Measurement -void Model::addMeasurement(GeometryType gt, Atom *first, ...) +void Model::addMeasurement(Measurement::MeasurementType gt, Atom *first, ...) { dbgBegin(Debug::Calls,"Model::addMeasurement"); Atom *i, **atoms; @@ -152,7 +152,7 @@ void Model::addMeasurement(GeometryType gt, Atom *first, ...) newm->setType(gt); newm->setAtom(0, first); // Get remaining atoms_... - int nexpected = natoms_from_GT(gt); + int nexpected = Measurement::nMeasurementAtoms(gt); va_list vars; va_start(vars,first); for (int n=1; natoms(); switch (gt) { - case (GT_DISTANCE): - newchange->set(UE_MEASUREMENT, gt, atoms[0]->id(), atoms[1]->id()); + case (Measurement::DistanceMeasurement): + newchange->set(Change::MeasurementEvent, gt, atoms[0]->id(), atoms[1]->id()); break; - case (GT_ANGLE): - newchange->set(UE_MEASUREMENT, gt, atoms[0]->id(), atoms[1]->id(), atoms[2]->id()); + case (Measurement::AngleMeasurement): + newchange->set(Change::MeasurementEvent, gt, atoms[0]->id(), atoms[1]->id(), atoms[2]->id()); break; - case (GT_TORSION): - newchange->set(UE_MEASUREMENT, gt, atoms[0]->id(), atoms[1]->id(), atoms[2]->id(), atoms[3]->id()); + case (Measurement::TorsionMeasurement): + newchange->set(Change::MeasurementEvent, gt, atoms[0]->id(), atoms[1]->id(), atoms[2]->id(), atoms[3]->id()); break; } } @@ -196,14 +196,14 @@ void Model::addMeasurement(GeometryType gt, Atom *first, ...) } // Add measurements in selection -void Model::addMeasurementsInSelection(GeometryType gt) +void Model::addMeasurementsInSelection(Measurement::MeasurementType gt) { dbgBegin(Debug::Calls,"Model::addMeasurementsInSelection"); Atom *i, *j, *k, *l; Refitem *b1, *b2, *b3; switch (gt) { - case (GT_DISTANCE): + case (Measurement::DistanceMeasurement): i = firstSelected(); while (i != NULL) { @@ -219,7 +219,7 @@ void Model::addMeasurementsInSelection(GeometryType gt) i = i->nextSelected(); } break; - case (GT_ANGLE): + case (Measurement::AngleMeasurement): j = firstSelected(); while (j != NULL) { @@ -243,7 +243,7 @@ void Model::addMeasurementsInSelection(GeometryType gt) j = j->nextSelected(); } break; - case (GT_TORSION): + case (Measurement::TorsionMeasurement): // Find bond j-k where both are selected j = firstSelected(); while (j != NULL) @@ -288,7 +288,7 @@ void Model::addMeasurementsInSelection(GeometryType gt) } // Find Measurement -Measurement *Model::findMeasurement(GeometryType gt, Atom *first, ...) +Measurement *Model::findMeasurement(Measurement::MeasurementType gt, Atom *first, ...) { dbgBegin(Debug::Calls,"Model::findMeasurement"); Measurement *result, *m; @@ -296,7 +296,7 @@ Measurement *Model::findMeasurement(GeometryType gt, Atom *first, ...) bool proceed; Atom *searchatoms[4], **matoms; searchatoms[0] = first; - int nexpected = natoms_from_GT(gt); + int nexpected = Measurement::nMeasurementAtoms(gt); va_list vars; va_start(vars,first); proceed = TRUE; diff --git a/src/model/model.cpp b/src/model/model.cpp index e8d20aff9..53705daa0 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -37,7 +37,7 @@ Model::Model() projectionPoint_ = -1; cameraRotation_ = 0.0; orthoSize_ = 20.0; - for (int n=0; n= LOG_TOTAL) printf("Invalid log quantity passed.\n"); + if (cl >= Change::TotalLog) printf("Invalid log quantity passed.\n"); logs_[cl] ++; - // For all logs except LOG_CAMERA we also update the total log - if (cl != LOG_CAMERA) logs_[LOG_TOTAL] ++; + // For all logs except Change::CameraLog we also update the total log + if (cl != Change::CameraLog) logs_[Change::TotalLog] ++; } // Copy logs void Model::copyLogs(int *newlogs) { - logs_[LOG_STRUCTURE] = newlogs[LOG_STRUCTURE]; - logs_[LOG_COORDS] = newlogs[LOG_COORDS]; - logs_[LOG_SELECTION] = newlogs[LOG_SELECTION]; + logs_[Change::StructureLog] = newlogs[Change::StructureLog]; + logs_[Change::CoordinateLog] = newlogs[Change::CoordinateLog]; + logs_[Change::SelectionLog] = newlogs[Change::SelectionLog]; } // Clear @@ -158,7 +158,7 @@ void Model::clear() patterns_.clear(); frames_.clear(); // Reset logs and log points - for (int n=0; naddChange(); - newchange->set(UE_LABEL,i->id(),oldlabels,i->labels()); + newchange->set(Change::LabelEvent,i->id(),oldlabels,i->labels()); } } @@ -268,7 +268,7 @@ void Model::removeLabel(Atom *i, Atom::AtomLabel al) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(-UE_LABEL,i->id(),oldlabels,i->labels()); + newchange->set(-Change::LabelEvent,i->id(),oldlabels,i->labels()); } } @@ -281,7 +281,7 @@ void Model::clearLabels(Atom *i) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_LABEL,i->id(),oldlabels,0); + newchange->set(Change::LabelEvent,i->id(),oldlabels,0); } } @@ -361,7 +361,7 @@ void Model::bohrToAngstrom() lengths *= ANGBOHR; cell_.set(lengths,cell_.angles()); } - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"Model::bohrToAngstrom"); } @@ -412,7 +412,7 @@ void Model::print() void Model::printLogs() { msg(Debug::None,"Logs for model '%s':\n",name_.get()); - msg(Debug::None,"Structure [%i], Coordinates [%i], Visual [%i], Selection [%i], Camera [%i], Total [%i]\n", logs_[LOG_STRUCTURE], logs_[LOG_COORDS], logs_[LOG_VISUAL], logs_[LOG_SELECTION], logs_[LOG_CAMERA], logs_[LOG_TOTAL]); + msg(Debug::None,"Structure [%i], Coordinates [%i], Visual [%i], Selection [%i], Camera [%i], Total [%i]\n", logs_[Change::StructureLog], logs_[Change::CoordinateLog], logs_[Change::VisualLog], logs_[Change::SelectionLog], logs_[Change::CameraLog], logs_[Change::TotalLog]); msg(Debug::None,"Expression point : %i\n", expressionPoint_); msg(Debug::None," Patterns point : %i\n", patternsPoint_); msg(Debug::None,"Projection point : %i\n", projectionPoint_); @@ -530,7 +530,7 @@ double Model::calculateRmsForce() */ // Return the log quantity specified -int Model::log(ChangeLog cl) +int Model::log(Change::ChangeLog cl) { return logs_[cl]; } @@ -538,17 +538,17 @@ int Model::log(ChangeLog cl) // Reset all logs to zero void Model::resetLogs() { - for (int i=0; i atoms_.nItems()) msg(Debug::None,"New pattern '%s' extends %i atoms past number of atoms in owner model.\n",patname,(start + mols*numatoms) - atoms_.nItems()); dbgEnd(Debug::Calls,"Model::addPattern"); @@ -207,7 +207,7 @@ bool Model::autocreatePatterns() if (atoms_.nItems() == 0) { msg(Debug::None,"No patterns defined for model '%s' - no atoms present.\n",name_.get()); - patternsPoint_ = logs_[LOG_STRUCTURE]; + patternsPoint_ = logs_[Change::StructureLog]; dbgEnd(Debug::Calls,"Model::autocreatePatterns"); return TRUE; } @@ -329,7 +329,7 @@ bool Model::autocreatePatterns() selectNone(); // Patterns depend only on the properties / relation of the atoms, and not the positions.. - patternsPoint_ = logs_[LOG_STRUCTURE]; + patternsPoint_ = logs_[Change::StructureLog]; dbgEnd(Debug::Calls,"Model::autocreatePatterns"); return TRUE; diff --git a/src/model/select.cpp b/src/model/select.cpp index 3d11f317c..815ae9ac0 100644 --- a/src/model/select.cpp +++ b/src/model/select.cpp @@ -33,12 +33,12 @@ void Model::selectAtom(Atom *i) { i->setSelected(TRUE); nSelected_ ++; - logChange(LOG_SELECTION); + logChange(Change::SelectionLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_SELECT,i->id()); + newchange->set(Change::SelectEvent,i->id()); } } dbgEnd(Debug::MoreCalls,"Model::selectAtom (%li)",i); @@ -59,12 +59,12 @@ void Model::deselectAtom(Atom *i) { i->setSelected(FALSE); nSelected_ --; - logChange(LOG_SELECTION); + logChange(Change::SelectionLog); // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(-UE_SELECT,i->id()); + newchange->set(-Change::SelectEvent,i->id()); } } dbgEnd(Debug::MoreCalls,"Model::deselectAtom (%li)",i); diff --git a/src/model/selection.cpp b/src/model/selection.cpp index 00fcb6e6d..2bce319f4 100644 --- a/src/model/selection.cpp +++ b/src/model/selection.cpp @@ -58,12 +58,12 @@ void Model::shiftSelectionUp() if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_SHIFT,oldid,-1); + newchange->set(Change::ShiftEvent,oldid,-1); } } i = next; } - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::shiftSelectionUp"); } @@ -101,12 +101,12 @@ void Model::shiftSelectionDown() if (recordingState_ != NULL) { Change *newchange = recordingState_->addChange(); - newchange->set(UE_SHIFT,oldid,1); + newchange->set(Change::ShiftEvent,oldid,1); } } i = next; } - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::shiftSelectionDown"); } @@ -126,7 +126,7 @@ void Model::moveSelectionToStart() } // Renumber atoms renumberAtoms(); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::moveSelectionToStart"); } @@ -146,7 +146,7 @@ void Model::moveSelectionToEnd() } // Renumber atoms renumberAtoms(); - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::moveSelectionToEnd"); } @@ -167,7 +167,7 @@ Vec3 Model::selectionCog() void Model::selectionSetHidden(bool hidden) { for (Atom *i = firstSelected(); i != NULL; i = i->nextSelected()) setHidden(i, hidden); - logChange(LOG_VISUAL); + logChange(Change::VisualLog); } // Fix selected atom positions @@ -189,6 +189,6 @@ void Model::selectionSetStyle(Atom::DrawStyle ds) { // Sets all atoms currently selected to have the drawing style specified for (Atom *i = atoms_.first(); i != NULL; i = i->next) if (i->isSelected()) i->setStyle(ds); - logChange(LOG_VISUAL); + logChange(Change::VisualLog); } diff --git a/src/model/trajectory.cpp b/src/model/trajectory.cpp index d7c4ade06..098edf0de 100644 --- a/src/model/trajectory.cpp +++ b/src/model/trajectory.cpp @@ -237,7 +237,7 @@ void Model::seekFirstFrame() bool success = trajectoryFilter_->execute("", trajectoryFile_, FALSE, frames_.first()); } framePosition_ = 1; - logChange(LOG_VISUAL); + logChange(Change::VisualLog); // Recalculate the view matrix for the trajectory frame, since it may have been changed by another frame model currentFrame_->calculateViewMatrix(); msg(Debug::None,"Seek to frame %i\n",framePosition_); @@ -266,7 +266,7 @@ void Model::seekNextFrame() if (trajectoryCached_) currentFrame_ = currentFrame_->next; else success = trajectoryFilter_->execute("", trajectoryFile_, FALSE, frames_.first()); framePosition_ ++; - logChange(LOG_VISUAL); + logChange(Change::VisualLog); // Recalculate the view matrix for the trajectory frame, since it may have been changed by another frame model currentFrame_->calculateViewMatrix(); msg(Debug::None,"Seek to frame %i\n",framePosition_); @@ -300,7 +300,7 @@ void Model::seekPreviousFrame() bool success = trajectoryFilter_->execute("", trajectoryFile_, FALSE, frames_.first()); } framePosition_ --; - logChange(LOG_VISUAL); + logChange(Change::VisualLog); // Recalculate the view matrix for the trajectory frame, since it may have been changed by another frame model currentFrame_->calculateViewMatrix(); msg(Debug::None,"Seek to frame %i\n",framePosition_); @@ -327,7 +327,7 @@ void Model::seekLastFrame() bool success = trajectoryFilter_->execute("", trajectoryFile_, FALSE, frames_.first()); } framePosition_ = totalFrames_; - logChange(LOG_VISUAL); + logChange(Change::VisualLog); // Recalculate the view matrix for the trajectory frame, since it may have been changed by another frame model currentFrame_->calculateViewMatrix(); msg(Debug::None,"Seek to frame %i\n",framePosition_); diff --git a/src/model/transform.cpp b/src/model/transform.cpp index 9713ef3b2..6a8113ec5 100644 --- a/src/model/transform.cpp +++ b/src/model/transform.cpp @@ -71,7 +71,7 @@ void Model::finalizeTransform(Reflist< Atom,Vec3 > &originalr) // Called after mouse-up. // Atom positions may have moved outside the boundaries of the box, so need to re-fold. foldAllAtoms(); - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); projectAll(); beginUndostate("Transform Selection"); // Go through list of atoms in 'originalr', work out delta, and store @@ -83,8 +83,8 @@ void Model::finalizeTransform(Reflist< Atom,Vec3 > &originalr) { delta = ri->item->r() - ri->data; newchange = recordingState_->addChange(); - newchange->set(UE_TRANSLATE,ri->item->id()); - newchange->set(UE_TRANSLATE,&delta); + newchange->set(Change::TranslateEvent,ri->item->id()); + newchange->set(Change::TranslateEvent,&delta); } } endUndostate(); @@ -119,7 +119,7 @@ void Model::rotateSelectionWorld(double dx, double dy) newr = (rotmat * newr) + localcog; i->r() = (viewMatrixInverse_ * newr) + cell_.centre();; } - logChange(LOG_VISUAL); + logChange(Change::VisualLog); projectSelection(); dbgEnd(Debug::Calls,"Model::rotateSelectionWorld"); } @@ -168,7 +168,7 @@ void Model::rotateSelectionVector(Vec3 origin, Vec3 vector, doub //i->r() = tempv; i = i->nextSelected(); } - logChange(LOG_STRUCTURE); + logChange(Change::StructureLog); dbgEnd(Debug::Calls,"Model::rotateSelectionVector"); } @@ -201,7 +201,7 @@ void Model::translateSelectionWorld(const Vec3 &v) newr = (viewMatrixInverse_ * newr) + cell_.centre(); i->r() = newr; } - logChange(LOG_VISUAL); + logChange(Change::VisualLog); projectSelection(); dbgEnd(Debug::Calls,"Model::translateSelectionWorld"); } @@ -212,7 +212,7 @@ void Model::translateSelectionLocal(const Vec3 &tvec) // Translate the model's current selection by the vector supplied. dbgBegin(Debug::Calls,"Model::translateSelectionLocal"); for (Atom *i = firstSelected(); i != NULL; i = i->nextSelected()) translateAtom(i,tvec); - //logChange(LOG_VISUAL); + //logChange(Change::VisualLog); projectSelection(); dbgEnd(Debug::Calls,"Model::translateSelectionLocal"); } @@ -233,7 +233,7 @@ void Model::mirrorSelectionLocal(int axis) // Store new coordinate i->r() = mimd + cog; } - logChange(LOG_VISUAL); + logChange(Change::VisualLog); projectSelection(); dbgEnd(Debug::Calls,"Model::mirrorSelectionLocal"); } diff --git a/src/model/typing.cpp b/src/model/typing.cpp index 8c456e32f..5b998de0e 100644 --- a/src/model/typing.cpp +++ b/src/model/typing.cpp @@ -124,7 +124,7 @@ bool Model::typeAll() msg(Debug::None,"Done.\n"); } // Log change in the model - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"Model::typeAll"); return TRUE; } @@ -259,6 +259,6 @@ void Model::selectionSetType(ForcefieldAtom *ffa, bool fixed) { dbgBegin(Debug::Calls,"Pattern::selectionSetType"); for (Atom *i = firstSelected(); i != NULL; i = i->nextSelected()) setAtomtype(i, ffa, fixed); - logChange(LOG_COORDS); + logChange(Change::CoordinateLog); dbgEnd(Debug::Calls,"Pattern::selectionSetType"); } diff --git a/src/model/undo.cpp b/src/model/undo.cpp index 835e0e727..070326f71 100644 --- a/src/model/undo.cpp +++ b/src/model/undo.cpp @@ -49,11 +49,11 @@ void Model::beginUndostate(const char *text) // Create a new state for us to add to recordingState_ = new Undostate; recordingState_->setDescription(text); - recordingState_->setStartLog(LOG_STRUCTURE, logs_[LOG_STRUCTURE]); - recordingState_->setStartLog(LOG_COORDS, logs_[LOG_COORDS]); - recordingState_->setStartLog(LOG_SELECTION, logs_[LOG_SELECTION]); + recordingState_->setStartLog(Change::StructureLog, logs_[Change::StructureLog]); + recordingState_->setStartLog(Change::CoordinateLog, logs_[Change::CoordinateLog]); + recordingState_->setStartLog(Change::SelectionLog, logs_[Change::SelectionLog]); msg(Debug::Verbose,"Undo list prepped for new state.\n"); - msg(Debug::Verbose," --- Logs at start of state are: structure = %i, coords = %i, selection = %i\n", logs_[LOG_STRUCTURE], logs_[LOG_COORDS], logs_[LOG_SELECTION]); + msg(Debug::Verbose," --- Logs at start of state are: structure = %i, coords = %i, selection = %i\n", logs_[Change::StructureLog], logs_[Change::CoordinateLog], logs_[Change::SelectionLog]); dbgEnd(Debug::Calls,"Model::beginUndostate"); } @@ -75,9 +75,9 @@ void Model::endUndostate() dbgEnd(Debug::Calls,"Model::endUndostate"); return; } - recordingState_->setEndLog(LOG_STRUCTURE, logs_[LOG_STRUCTURE]); - recordingState_->setEndLog(LOG_COORDS, logs_[LOG_COORDS]); - recordingState_->setEndLog(LOG_SELECTION, logs_[LOG_SELECTION]); + recordingState_->setEndLog(Change::StructureLog, logs_[Change::StructureLog]); + recordingState_->setEndLog(Change::CoordinateLog, logs_[Change::CoordinateLog]); + recordingState_->setEndLog(Change::SelectionLog, logs_[Change::SelectionLog]); // Delete all redo (i.e. future) states from the undo list if (currentUndostate_ == NULL) undoStates_.clear(); else for (Undostate *u = currentUndostate_->next; u != NULL; u = undoStates_.removeAndGetNext(u)); @@ -86,7 +86,7 @@ void Model::endUndostate() // Set the current undo level to the new state and nullify the pointer currentUndostate_ = recordingState_; msg(Debug::Verbose,"Undo list now has %i states (%i events caught in last state).\n",undoStates_.nItems(),currentUndostate_->nChanges()); - msg(Debug::Verbose," --- Logs at end of state are: structure = %i, coords = %i, selection = %i\n", logs_[LOG_STRUCTURE], logs_[LOG_COORDS], logs_[LOG_SELECTION]); + msg(Debug::Verbose," --- Logs at end of state are: structure = %i, coords = %i, selection = %i\n", logs_[Change::StructureLog], logs_[Change::CoordinateLog], logs_[Change::SelectionLog]); // Nullify the redostate pointer, since we must now be at the top of the undo stack currentRedoState_ = NULL; recordingState_ = NULL; @@ -104,10 +104,10 @@ void Model::undo() { // Undo the changes currentUndostate_->reverse(this); - logs_[LOG_STRUCTURE] = currentUndostate_->startLog(LOG_STRUCTURE); - logs_[LOG_COORDS] = currentUndostate_->startLog(LOG_COORDS); + logs_[Change::StructureLog] = currentUndostate_->startLog(Change::StructureLog); + logs_[Change::CoordinateLog] = currentUndostate_->startLog(Change::CoordinateLog); // Log a visual change if necessary - if (currentUndostate_->doLogsDiffer()) logChange(LOG_VISUAL); + if (currentUndostate_->doLogsDiffer()) logChange(Change::VisualLog); // Set new undo/redo pointers currentRedoState_ = currentUndostate_; currentUndostate_ = currentUndostate_->prev; @@ -124,10 +124,10 @@ void Model::redo() { // Undo the changes currentRedoState_->perform(this); - logs_[LOG_STRUCTURE] = currentRedoState_->endLog(LOG_STRUCTURE); - logs_[LOG_COORDS] = currentRedoState_->endLog(LOG_COORDS); + logs_[Change::StructureLog] = currentRedoState_->endLog(Change::StructureLog); + logs_[Change::CoordinateLog] = currentRedoState_->endLog(Change::CoordinateLog); // Log a visual change if necessary - if (currentRedoState_->doLogsDiffer()) logChange(LOG_VISUAL); + if (currentRedoState_->doLogsDiffer()) logChange(Change::VisualLog); // Set new undo/redo pointers currentUndostate_ = currentRedoState_; currentRedoState_ = currentRedoState_->next; diff --git a/src/model/view.cpp b/src/model/view.cpp index 4c6e75172..69b4d6f67 100644 --- a/src/model/view.cpp +++ b/src/model/view.cpp @@ -117,7 +117,7 @@ void Model::setRotation(double rotx, double roty) // Recalculate view matrix calculateViewMatrix(); // Log camera change - logChange(LOG_CAMERA); + logChange(Change::CameraLog); dbgEnd(Debug::Calls,"Model::setRotation"); } @@ -155,7 +155,7 @@ void Model::adjustCamera(double dx, double dy, double dz, double angle) } calculateViewMatrix(); // Log camera change - logChange(LOG_CAMERA); + logChange(Change::CameraLog); dbgEnd(Debug::Calls,"Model::adjustCamera"); } @@ -169,7 +169,7 @@ void Model::adjustOrthoSize(double delta) calculateViewMatrix(); gui.mainView.doProjection(); // Log camera change - logChange(LOG_CAMERA); + logChange(Change::CameraLog); dbgEnd(Debug::Calls,"Model::adjustOrthoSize"); } @@ -201,7 +201,7 @@ void Model::resetCamera(const Vec3 &newr) // Recalculate viewing matrix calculateViewMatrix(); // Log camera change - logChange(LOG_CAMERA); + logChange(Change::CameraLog); dbgEnd(Debug::Calls,"Model::resetCamera"); } @@ -241,7 +241,7 @@ void Model::resetView() // Recalculate viewing matrix calculateViewMatrix(); // Log camera change - logChange(LOG_CAMERA); + logChange(Change::CameraLog); dbgEnd(Debug::Calls,"Model::resetView"); } @@ -273,7 +273,7 @@ void Model::rotate(double dx, double dy) // Recalculate view matrix calculateViewMatrix(); // Log camera change - logChange(LOG_CAMERA); + logChange(Change::CameraLog); dbgEnd(Debug::Calls,"Model::rotate"); } @@ -293,10 +293,10 @@ void Model::projectAll() { // Transform the model coordinates of all atoms into world GL and 2D screen coordinates dbgBegin(Debug::Calls,"Model::projectAll"); - if (projectionPoint_ != (logs_[LOG_COORDS] + logs_[LOG_CAMERA])) + if (projectionPoint_ != (logs_[Change::CoordinateLog] + logs_[Change::CameraLog])) { if (gui.mainView.isValid()) for (Atom *i = atoms_.first(); i != NULL; i = i->next) projectAtom(i); - projectionPoint_ = logs_[LOG_COORDS] + logs_[LOG_CAMERA]; + projectionPoint_ = logs_[Change::CoordinateLog] + logs_[Change::CameraLog]; } dbgEnd(Debug::Calls,"Model::projectAll"); } diff --git a/src/render/extra.cpp b/src/render/extra.cpp index 73d48a515..b329d611d 100644 --- a/src/render/extra.cpp +++ b/src/render/extra.cpp @@ -40,7 +40,7 @@ void Canvas::renderExtra3d() switch (activeMode_) { // Draw on the bounding sphere of a radial selection - case (UA_PICKRADIAL): + case (Canvas::SelectRadialAction): i = atomHover_; if (i == NULL) break; // Work out the radius of the sphere @@ -58,7 +58,7 @@ void Canvas::renderExtra3d() glPopMatrix(); break; // Draw on bond and new atom for chain drawing - case (UA_DRAWCHAIN): + case (Canvas::EditChainAction): if (atomHover_ == NULL) break; r = atomHover_->r(); // We need to project a point from the mouse position onto the canvas plane, unless the mouse is over an existing atom in which case we snap to its position instead @@ -119,29 +119,27 @@ void Canvas::renderExtra2d() // Those for active modes (when button is down)... switch (activeMode_) { - case (UA_NONE): + case (Canvas::NoAction): break; // Only selection mode where we draw a selection box - case (UA_PICKSELECT): - case (UA_GEOMSELECT): - case (UA_POSSELECT): + case (Canvas::SelectAction): glEnable(GL_LINE_STIPPLE); glLineStipple(1,0x5555); rectanglePrimitive(rMouseDown_.x, height_-rMouseDown_.y, rMouseLast_.x, height_-rMouseLast_.y); glDisable(GL_LINE_STIPPLE); break; // Draw line from last atom in selection list (if any) to the current mouse pos - case (UA_GEOMDIST): - case (UA_GEOMANGLE): - case (UA_GEOMTORSION): + case (Canvas::MeasureDistanceAction): + case (Canvas::MeasureAngleAction): + case (Canvas::MeasureTorsionAction): break; } // ...and those for selected modes (whether the button is down or not). switch (selectedMode_) { // Draw on distance ruler for drawing modes - case (UA_DRAWATOM): - case (UA_DRAWCHAIN): + case (Canvas::EditDrawAction): + case (Canvas::EditChainAction): // Get angstrom length dx = 1.0 / drawPixelWidth_; halfw = width_ / 2.0; diff --git a/src/render/model.cpp b/src/render/model.cpp index 9860ced48..df2533967 100644 --- a/src/render/model.cpp +++ b/src/render/model.cpp @@ -102,7 +102,7 @@ void Canvas::renderModelMeasurements() glBegin(GL_LINE_STRIP); switch (m->type()) { - case (GT_DISTANCE): + case (Measurement::DistanceMeasurement): ri = atoms[0]->r(); rj = atoms[1]->r(); labpos = (ri + rj) * 0.5; @@ -110,7 +110,7 @@ void Canvas::renderModelMeasurements() glVertex3d(rj.x, rj.y, rj.z); sprintf(text,"%f A",m->value()); break; - case (GT_ANGLE): + case (Measurement::AngleMeasurement): ri = atoms[0]->r(); rj = atoms[1]->r(); rk = atoms[2]->r(); @@ -120,7 +120,7 @@ void Canvas::renderModelMeasurements() glVertex3d(rk.x, rk.y, rk.z); sprintf(text,"%f Deg",m->value()); break; - case (GT_TORSION): + case (Measurement::TorsionMeasurement): ri = atoms[0]->r(); rj = atoms[1]->r(); rk = atoms[2]->r(); diff --git a/src/render/render.cpp b/src/render/render.cpp index f3d5b1883..19ffeeebd 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -118,7 +118,7 @@ void Canvas::renderScene(Model *source) // Draw the main model parts // If renderPoint_ matches the model's total change point (from get_point()) then just re-render the stored display list. If not, create the display list. glPushMatrix(); - if (renderPoint_ == displayModel_->log(LOG_TOTAL)) glCallList(list_[GLOB_MODEL]); + if (renderPoint_ == displayModel_->log(Change::TotalLog)) glCallList(list_[GLOB_MODEL]); else { msg(Debug::Verbose,"Recreating display list for model '%s'...", displayModel_->name()); @@ -133,7 +133,7 @@ void Canvas::renderScene(Model *source) // Render force arrows if (prefs.shouldRender(Prefs::ViewForceArrows)) renderModelForceArrows(); glEndList(); - renderPoint_ = displayModel_->log(LOG_TOTAL); + renderPoint_ = displayModel_->log(Change::TotalLog); msg(Debug::Verbose," Done. (New point = %i)\n",renderPoint_); } // Render surfaces