Skip to content

Commit

Permalink
Fixed - Changing atom colour through context menu would click OwnSche…
Browse files Browse the repository at this point in the history
…me 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.
  • Loading branch information
trisyoungs committed Aug 26, 2016
1 parent 029ac1b commit 5f7fbce
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 28 deletions.
2 changes: 0 additions & 2 deletions TODO2
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions src/command/atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/gui/mainwindow_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/mainwindow_panel_home.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 0 additions & 2 deletions src/gui/tmenubutton.hui
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
15 changes: 0 additions & 15 deletions src/gui/tmenubutton_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
11 changes: 6 additions & 5 deletions src/model/atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/model/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ void Model::selectionResetColour()
void Model::selectionSetStyle(Prefs::DrawStyle ds)
{
for (RefListItem<Atom,int>* 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
Expand Down

0 comments on commit 5f7fbce

Please sign in to comment.