From 5f7fbcebf11b13f523e886870fb0b4722a646816 Mon Sep 17 00:00:00 2001 From: Tristan Youngs Date: Fri, 26 Aug 2016 16:06:08 +0100 Subject: [PATCH] Fixed - Changing atom colour through context menu would click OwnScheme button, potentially leaving two style buttons checked. Fixed - Changing style of atoms would not set the drawing style of the model to 'OwnStyle'. Removed TMenuButton::setGroupButtonChecked(QString,QString) since it didn't work well, and sent all calls through (QString,int) version. --- TODO2 | 2 -- src/command/atom.cpp | 1 + src/gui/mainwindow_context.cpp | 2 -- src/gui/mainwindow_panel_home.cpp | 4 ++-- src/gui/tmenubutton.hui | 2 -- src/gui/tmenubutton_funcs.cpp | 15 --------------- src/model/atom.cpp | 11 ++++++----- src/model/selection.cpp | 3 +++ 8 files changed, 12 insertions(+), 28 deletions(-) diff --git a/TODO2 b/TODO2 index d19aff966..36b1c61fe 100644 --- a/TODO2 +++ b/TODO2 @@ -2,8 +2,6 @@ TODO ==== Undo/Redo: * Add Grid-related undo/redo (e.g. title changes, colour etc.) -Trajectory handling: -o Inherit generates a crash when at first frame?? Add set members to Matrix class allowing axes to be set from atoms in models. Crash when tree selecting large models (recursion overflow?) - use array-based loop instead. Add specific line primitive class that allows chunking (for speedup of stick rendering, because otherwise an enormous array is continually deleted'd/new'd). diff --git a/src/command/atom.cpp b/src/command/atom.cpp index 21a64328e..a125881f5 100644 --- a/src/command/atom.cpp +++ b/src/command/atom.cpp @@ -38,6 +38,7 @@ bool Commands::function_AtomStyle(CommandNode* c, Bundle& obj, ReturnValue& rv) if (i == NULL) return false; obj.rs()->beginUndoState("Style individual atom"); obj.rs()->atomSetStyle(i, ds); + obj.rs()->setDrawStyle(Prefs::OwnStyle); obj.rs()->endUndoState(); } else diff --git a/src/gui/mainwindow_context.cpp b/src/gui/mainwindow_context.cpp index 0af52d1c5..353eef6a6 100644 --- a/src/gui/mainwindow_context.cpp +++ b/src/gui/mainwindow_context.cpp @@ -307,8 +307,6 @@ void AtenWindow::contextMenuColourChanged(QColor colour) { CommandNode::run(Commands::ColourAtoms, "dddd", colour.redF(), colour.greenF(), colour.blueF(), colour.alphaF()); - ui.HomeAppearanceOwnColourButton->click(); - updateWidgets(); } diff --git a/src/gui/mainwindow_panel_home.cpp b/src/gui/mainwindow_panel_home.cpp index a43eeb075..762258c77 100644 --- a/src/gui/mainwindow_panel_home.cpp +++ b/src/gui/mainwindow_panel_home.cpp @@ -72,8 +72,8 @@ void AtenWindow::updateHomePanel(Model* sourceModel) ui.HomeViewHBondsButton->setChecked(prefs.drawHydrogenBonds()); ui.HomeViewCorrectGridsButton->setChecked(prefs.correctTransparentGrids()); ui.HomeViewLockButton->setChecked(prefs.viewLock() == Prefs::FullLock); - if (sourceModel) TMenuButton::setGroupButtonChecked("ViewStyles", Prefs::drawStyle(sourceModel->drawStyle())); - if (sourceModel) TMenuButton::setGroupButtonChecked("ColourSchemes", Prefs::colouringScheme(sourceModel->colourScheme())); + if (sourceModel) TMenuButton::setGroupButtonChecked("ViewStyles", sourceModel->drawStyle()); + if (sourceModel) TMenuButton::setGroupButtonChecked("ColourSchemes", sourceModel->colourScheme()); Messenger::exit("AtenWindow::updateHomePanel"); } diff --git a/src/gui/tmenubutton.hui b/src/gui/tmenubutton.hui index 6f68a70ca..cc3057fc0 100644 --- a/src/gui/tmenubutton.hui +++ b/src/gui/tmenubutton.hui @@ -139,8 +139,6 @@ class TMenuButton : public QToolButton // Add this button to the named group void setGroup(QString groupName, int index = -1); // Check specified button in specified group - static bool setGroupButtonChecked(QString groupName, QString buttonText); - // Check specified button in specified group static bool setGroupButtonChecked(QString groupName, int buttonIndex); }; diff --git a/src/gui/tmenubutton_funcs.cpp b/src/gui/tmenubutton_funcs.cpp index 35a40fb83..fc1858a6b 100644 --- a/src/gui/tmenubutton_funcs.cpp +++ b/src/gui/tmenubutton_funcs.cpp @@ -487,21 +487,6 @@ void TMenuButton::setGroup(QString groupName, int index) index_ = index; } -// Check specified button in specified group -bool TMenuButton::setGroupButtonChecked(QString groupName, QString buttonText) -{ - // First, find named group - TMenuButtonGroup* group; - for (group = groups_.first(); group != NULL; group = group->next) if (group->name() == groupName) break; - if (!group) - { - Messenger::print("Internal error: No TMenuButton group named '%s'\n", qPrintable(groupName)); - return false; - } - - return group->setCurrentButton(buttonText); -} - // Check specified button in specified group bool TMenuButton::setGroupButtonChecked(QString groupName, int buttonIndex) { diff --git a/src/model/atom.cpp b/src/model/atom.cpp index 9fba3c9e7..c118d6b7a 100644 --- a/src/model/atom.cpp +++ b/src/model/atom.cpp @@ -395,18 +395,19 @@ void Model::atomResetColour(Atom* i) // Set style of individual atom void Model::atomSetStyle(Atom* i, Prefs::DrawStyle ds) { - // Sets all atoms currently selected to have the drawing style specified - Prefs::DrawStyle oldStyle = i->style(); - i->setStyle(ds); - logChange(Log::Style); + // Check current style + if (i->style() == ds) return; // Add the change to the undo state (if there is one) if (recordingState_ != NULL) { AtomStyleEvent* newchange = new AtomStyleEvent; - newchange->set(i->id(), oldStyle, ds); + newchange->set(i->id(), i->style(), ds); recordingState_->addEvent(newchange); } + + i->setStyle(ds); + logChange(Log::Style); } // Print coordinates of all atoms diff --git a/src/model/selection.cpp b/src/model/selection.cpp index 4a2012739..3b7d6ab40 100644 --- a/src/model/selection.cpp +++ b/src/model/selection.cpp @@ -222,6 +222,9 @@ void Model::selectionResetColour() void Model::selectionSetStyle(Prefs::DrawStyle ds) { for (RefListItem* ri = selection_.first(); ri != NULL; ri = ri->next) if (ri->item->isSelected()) atomSetStyle(ri->item, ds); + + // Make sure current drawStyle is 'own' + setDrawStyle(Prefs::OwnStyle); } // Select bound and selected atoms from the current atom