1
/**********************************************************************
2
EngineColorsWidget - Widget for setting the engine color map.
4
Copyright (C) 2008 Tim Vandermeersch
6
This file is part of the Avogadro molecular editor project.
7
For more information, see <http://avogadro.openmolecules.net/>
9
Avogadro is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
14
Avogadro is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23
**********************************************************************/
25
#include "enginecolorswidget.h"
27
#include <avogadro/engine.h>
28
#include <avogadro/color.h>
29
#include <avogadro/pluginmanager.h>
36
class EngineColorsWidgetPrivate
39
EngineColorsWidgetPrivate() : engine(0), currentSettingsWidget(0) {};
42
PluginManager *pluginManager;
43
QWidget *currentSettingsWidget;
46
EngineColorsWidget::EngineColorsWidget( PluginManager *pluginManager,
48
: QWidget(parent), d(new EngineColorsWidgetPrivate)
51
d->pluginManager = pluginManager;
53
foreach(Color *color, pluginManager->colors())
55
ui.colorCombo->addItem(color->name());
58
connect(ui.colorCombo, SIGNAL(currentIndexChanged(int)),
59
this, SLOT(colorChanged(int)));
60
// we should actually check the engine settings for the current color choice
63
EngineColorsWidget::~EngineColorsWidget()
65
d->currentSettingsWidget = NULL;
69
void EngineColorsWidget::colorChanged(int index)
71
Color *color = d->pluginManager->colors().at(index);
76
d->engine->setColorMap(color);
77
if (d->currentSettingsWidget) {
78
d->currentSettingsWidget->hide();
79
ui.verticalLayout->removeWidget(d->currentSettingsWidget);
81
// Remove the bottom spacer
83
space = ui.verticalLayout->takeAt(-1);
84
ui.verticalLayout->removeItem(space);
86
d->currentSettingsWidget = NULL;
89
if (color->settingsWidget()) {
90
d->currentSettingsWidget = color->settingsWidget();
91
ui.verticalLayout->addWidget(d->currentSettingsWidget);
92
ui.verticalLayout->addStretch();
93
d->currentSettingsWidget->show();
97
void EngineColorsWidget::setEngine( Engine *engine )
100
//ui.colorCombo->setEnabled(true);
103
} // end namespace Avogadro
105
#include "enginecolorswidget.moc"