From: abn Date: Fri, 12 Sep 2014 09:55:59 +0000 (+0200) Subject: Properly integrating new Settings panel. "Default" won't work (but wasn't X-Git-Tag: V7_5_0a1~1^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0b0ae0fc3e2c5cfe8f03cf40e7eee698ecb5c09d;p=modules%2Fparavis.git Properly integrating new Settings panel. "Default" won't work (but wasn't working before either). --- diff --git a/src/PVGUI/CMakeLists.txt b/src/PVGUI/CMakeLists.txt index fc2bcaba..84dec7b1 100644 --- a/src/PVGUI/CMakeLists.txt +++ b/src/PVGUI/CMakeLists.txt @@ -30,6 +30,7 @@ INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ) # additional preprocessor / compiler flags @@ -58,6 +59,12 @@ SET(_link_LIBRARIES # --- headers --- +SET(_ui_files + resources/pqCustomSettingsWidget.ui + ) + +QT4_WRAP_UI(_ui_FORMS_HEADERS ${_ui_files}) + # header files / to be processed by moc SET(_moc_HEADERS PVGUI_Module.h @@ -79,7 +86,7 @@ SET(_other_HEADERS ) # header files / to install -SET(PVGUI_HEADERS ${_moc_HEADERS} ${_other_HEADERS}) +SET(PVGUI_HEADERS ${_moc_HEADERS} ${_other_HEADERS} ${_ui_FORMS_HEADERS}) # --- resources --- @@ -167,6 +174,7 @@ SET(PVGUI_SOURCES ${_rcc_SOURCES} ${vtkEDFCutter_SRCS} ${_VTK_wrap_SOURCES} + ${_ui_FORMS_HEADERS} ) # --- rules --- diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index c2847dab..8233ef9b 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -749,6 +749,8 @@ bool PVGUI_Module::pvInit() */ // End of Initializer code + MyCoreApp->settings(); + vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New()); new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET on creation @@ -1293,8 +1295,9 @@ void PVGUI_Module::createPreferences() setPreferenceProperty(aSaveType, "indexes", aIndices); //rnv: imp 21712: [CEA 581] Preference to display legend by default - int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab, - LightApp_Preferences::Bool, "PARAVIS", "show_color_legend"); + // [ABN]: now fixed in ParaView. +// int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab, +// LightApp_Preferences::Bool, "PARAVIS", "show_color_legend"); } /*! diff --git a/src/PVGUI/PVGUI_Module_widgets.cxx b/src/PVGUI/PVGUI_Module_widgets.cxx index 152f7dbf..b2650935 100644 --- a/src/PVGUI/PVGUI_Module_widgets.cxx +++ b/src/PVGUI/PVGUI_Module_widgets.cxx @@ -130,29 +130,7 @@ void PVGUI_Module::setupDockWidgets() myDockWidgets[propertiesDock] = true; - //Display Dock -// QDockWidget* displayDock = new QDockWidget( tr( "TTL_DISPLAY" ), desk ); -// displayDock->setObjectName("displayDock"); -// QWidget* displayWidgetFrame = new QWidget(displayDock); -// displayWidgetFrame->setObjectName("displayWidgetFrame"); -// displayDock->setWidget(displayWidgetFrame); -// -// QScrollArea* displayScrollArea = new QScrollArea(displayWidgetFrame); -// displayScrollArea->setObjectName("displayScrollArea"); -// displayScrollArea->setWidgetResizable(true); -// -// QVBoxLayout* verticalLayout = new QVBoxLayout(displayWidgetFrame); -// verticalLayout->setSpacing(0); -// verticalLayout->setContentsMargins(0, 0, 0, 0); -// -// pqDisplayProxyEditorWidget* displayWidget = new pqDisplayProxyEditorWidget(displayDock); -// displayWidget->setObjectName("displayWidget"); -// displayScrollArea->setWidget(displayWidget); -// verticalLayout->addWidget(displayScrollArea); -// -// myDockWidgets[displayDock] = true; - - // information dock + // Information dock QDockWidget* informationDock = new QDockWidget(tr( "TTL_INFORMATION" ), desk); informationDock->setObjectName("informationDock"); @@ -178,7 +156,7 @@ void PVGUI_Module::setupDockWidgets() myDockWidgets[informationDock] = true; desk->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North); - desk->tabifyDockWidget(propertiesDock, informationDock); + desk->tabifyDockWidget(informationDock, propertiesDock); propertiesDock->raise(); // Statistic View diff --git a/src/PVGUI/PVGUI_ParaViewSettingsPane.cxx b/src/PVGUI/PVGUI_ParaViewSettingsPane.cxx index 18e98213..fb095ece 100644 --- a/src/PVGUI/PVGUI_ParaViewSettingsPane.cxx +++ b/src/PVGUI/PVGUI_ParaViewSettingsPane.cxx @@ -23,625 +23,354 @@ // #include "PVGUI_ParaViewSettingsPane.h" -#include "ui_pqOptionsDialog.h" +#include "ui_pqCustomSettingsWidget.h" -#include +#include #include -//class OptionsDialogModelItem -//{ -//public: -// OptionsDialogModelItem(); -// OptionsDialogModelItem(const QString &name); -// ~OptionsDialogModelItem(); -// -// OptionsDialogModelItem *Parent; -// QString Name; -// QList Children; -//}; -// -// -//class OptionsDialogModel : public QAbstractItemModel -//{ -//public: -// OptionsDialogModel(QObject *parent=0); -// virtual ~OptionsDialogModel(); -// -// virtual int rowCount(const QModelIndex &parent=QModelIndex()) const; -// virtual int columnCount(const QModelIndex &parent=QModelIndex()) const; -// virtual QModelIndex index(int row, int column, -// const QModelIndex &parent=QModelIndex()) const; -// virtual QModelIndex parent(const QModelIndex &child) const; -// -// virtual QVariant data(const QModelIndex &index, -// int role=Qt::DisplayRole) const; -// -// QModelIndex getIndex(const QString &path) const; -// QString getPath(const QModelIndex &index) const; -// void addPath(const QString &path); -// bool removeIndex(const QModelIndex &index); -// -//private: -// QModelIndex getIndex(OptionsDialogModelItem *item) const; -// -//private: -// OptionsDialogModelItem *Root; -//}; +#include "pqActiveObjects.h" +#include "pqApplicationCore.h" +#include "pqProxyWidget.h" +#include "pqSearchBox.h" +#include "pqServer.h" +#include "pqSettings.h" +#include "pqUndoStack.h" +#include "vtkNew.h" +#include "vtkPVXMLElement.h" +#include "vtkSmartPointer.h" +#include "vtkSMProperty.h" +#include "vtkSMPropertyHelper.h" +#include "vtkSMPropertyIterator.h" +#include "vtkSMProxy.h" +#include "vtkSMProxyIterator.h" +#include "vtkSMSessionProxyManager.h" +#include "vtkSMSettings.h" +#include +#include +#include +#include +#include +#include +#include +#include -class OptionsDialogForm : public Ui::PVGUIOptionsFrame +// This class is revisited to hack on the SALOME's Preferences "Default" button +// to ParaView's "Default" behavior. +class PVGUI_ParaViewSettingsPane::pqInternals { public: - OptionsDialogForm(); - ~OptionsDialogForm(); + pqInternals() + { + // Get the containing preference tab to identify when it has focus + + } + ~pqInternals(); -// QMap Pages; -// OptionsDialogModel *Model; -// int ApplyUseCount; - //bool ApplyNeeded; + Ui::CustomSettingsWidget Ui; + + // Map from tab indices to stack widget indices. This is needed because there + // are more widgets in the stacked widgets than just what we add. + QMap TabToStackedWidgets; }; +bool PVGUI_ParaViewSettingsPane::ShowRestartRequired = false; //---------------------------------------------------------------------------- -//OptionsDialogModelItem::OptionsDialogModelItem() -// : Name(), Children() -//{ -// this->Parent = 0; -//} -// -//OptionsDialogModelItem::OptionsDialogModelItem(const QString &name) -// : Name(name), Children() -//{ -// this->Parent = 0; -//} -// -//OptionsDialogModelItem::~OptionsDialogModelItem() -//{ -// QList::Iterator iter = this->Children.begin(); -// for( ; iter != this->Children.end(); ++iter) -// { -// delete *iter; -// } -//} +PVGUI_ParaViewSettingsPane::PVGUI_ParaViewSettingsPane(QWidget *widgetParent) + : QtxUserDefinedContent(widgetParent), + Internals (new PVGUI_ParaViewSettingsPane::pqInternals()) +{ + Ui::CustomSettingsWidget &ui = this->Internals->Ui; + ui.setupUi(this); + ui.tabBar->setDocumentMode(false); + ui.tabBar->setDrawBase(false); + ui.tabBar->setExpanding(false); + ui.tabBar->setUsesScrollButtons(true); + // Hide restart message + ui.restartRequiredLabel->setVisible(PVGUI_ParaViewSettingsPane::ShowRestartRequired); -//---------------------------------------------------------------------------- -//OptionsDialogModel::OptionsDialogModel(QObject *parentObject) -// : QAbstractItemModel(parentObject) -//{ -// this->Root = new OptionsDialogModelItem(); -//} -// -//OptionsDialogModel::~OptionsDialogModel() -//{ -// delete this->Root; -//} -// -//int OptionsDialogModel::rowCount(const QModelIndex &parentIndex) const -//{ -// OptionsDialogModelItem *item = this->Root; -// if(parentIndex.isValid()) -// { -// item = reinterpret_cast( -// parentIndex.internalPointer()); -// } -// -// return item->Children.size(); -//} -// -//int OptionsDialogModel::columnCount(const QModelIndex &) const -//{ -// return 1; -//} -// -//QModelIndex OptionsDialogModel::index(int row, int column, -// const QModelIndex &parentIndex) const -//{ -// OptionsDialogModelItem *item = this->Root; -// if(parentIndex.isValid()) -// { -// item = reinterpret_cast( -// parentIndex.internalPointer()); -// } -// -// if(column == 0 && row >= 0 && row < item->Children.size()) -// { -// return this->createIndex(row, column, item->Children[row]); -// } -// -// return QModelIndex(); -//} -// -//QModelIndex OptionsDialogModel::parent(const QModelIndex &child) const -//{ -// if(child.isValid()) -// { -// OptionsDialogModelItem *item = -// reinterpret_cast(child.internalPointer()); -// return this->getIndex(item->Parent); -// } -// -// return QModelIndex(); -//} -// -//QVariant OptionsDialogModel::data(const QModelIndex &idx, int role) const -//{ -// if(idx.isValid()) -// { -// OptionsDialogModelItem *item = -// reinterpret_cast(idx.internalPointer()); -// if(role == Qt::DisplayRole || role == Qt::ToolTipRole) -// { -// return QVariant(item->Name); -// } -// } -// -// return QVariant(); -//} -// -//QModelIndex OptionsDialogModel::getIndex(const QString &path) const -//{ -// OptionsDialogModelItem *item = this->Root; -// QStringList names = path.split("."); -// QStringList::Iterator iter = names.begin(); -// for( ; item && iter != names.end(); ++iter) -// { -// OptionsDialogModelItem *child = 0; -// QList::Iterator jter = item->Children.begin(); -// for( ; jter != item->Children.end(); ++jter) -// { -// if((*jter)->Name == *iter) -// { -// child = *jter; -// break; -// } -// } -// -// item = child; -// } -// -// if(item && item != this->Root) -// { -// return this->getIndex(item); -// } -// -// return QModelIndex(); -//} -// -//QString OptionsDialogModel::getPath(const QModelIndex &idx) const -//{ -// if(idx.isValid()) -// { -// QString path; -// OptionsDialogModelItem *item = -// reinterpret_cast(idx.internalPointer()); -// if(item) -// { -// path = item->Name; -// item = item->Parent; -// } -// -// while(item && item != this->Root) -// { -// path.prepend(".").prepend(item->Name); -// item = item->Parent; -// } -// -// return path; -// } -// -// return QString(); -//} -// -//void OptionsDialogModel::addPath(const QString &path) -//{ -// OptionsDialogModelItem *item = this->Root; -// QStringList names = path.split("."); -// QStringList::Iterator iter = names.begin(); -// for( ; iter != names.end(); ++iter) -// { -// OptionsDialogModelItem *child = 0; -// QList::Iterator jter = item->Children.begin(); -// for( ; jter != item->Children.end(); ++jter) -// { -// if((*jter)->Name == *iter) -// { -// child = *jter; -// break; -// } -// } -// -// if(!child) -// { -// child = new OptionsDialogModelItem(*iter); -// child->Parent = item; -// QModelIndex parentIndex = this->getIndex(item); -// int row = item->Children.size(); -// this->beginInsertRows(parentIndex, row, row); -// item->Children.append(child); -// this->endInsertRows(); -// } -// -// item = child; -// } -//} -// -//bool OptionsDialogModel::removeIndex(const QModelIndex &idx) -//{ -// if(idx.isValid()) -// { -// OptionsDialogModelItem *item = -// reinterpret_cast(idx.internalPointer()); -// if(item->Children.size() == 0) -// { -// QModelIndex parentIndex = this->getIndex(item->Parent); -// this->beginRemoveRows(parentIndex, idx.row(), idx.row()); -// item->Parent->Children.removeAt(idx.row()); -// this->endRemoveRows(); -// delete item; -// return true; -// } -// } -// -// return false; -//} -// -//QModelIndex OptionsDialogModel::getIndex( -// OptionsDialogModelItem *item) const -//{ -// if(item && item->Parent) -// { -// return this->createIndex(item->Parent->Children.indexOf(item), 0, item); -// } -// -// return QModelIndex(); -//} + QList proxies_to_show; + pqServer* server = pqActiveObjects::instance().activeServer(); + vtkNew iter; + iter->SetSession(server->session()); + iter->SetModeToOneGroup(); + for (iter->Begin("settings"); !iter->IsAtEnd(); iter->Next()) + { + vtkSMProxy* proxy = iter->GetProxy(); + if (proxy) + { + proxies_to_show.push_back(proxy); + } + } -//---------------------------------------------------------------------------- -OptionsDialogForm::OptionsDialogForm() - : Ui::PVGUIOptionsFrame() + // Add color palette. + if (vtkSMProxy* proxy = server->proxyManager()->GetProxy("global_properties", "ColorPalette")) + { + proxies_to_show.push_back(proxy); + } + + foreach (vtkSMProxy* proxy, proxies_to_show) + { + QString proxyName = proxy->GetXMLName(); + + QScrollArea *scrollArea = new QScrollArea(this); + scrollArea->setObjectName(QString("ScrollArea%1").arg(proxyName)); + scrollArea->setWidgetResizable(true); + scrollArea->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); + scrollArea->setFrameShape(QFrame::NoFrame); + + QWidget* container = new QWidget(scrollArea); + container->setObjectName("Container"); + container->setContentsMargins(6, 0, 6, 0); + + QVBoxLayout* vbox = new QVBoxLayout(container); + vbox->setMargin(0); + vbox->setSpacing(0); + + pqProxyWidget* widget = new pqProxyWidget(proxy, container); + widget->setObjectName("ProxyWidget"); + widget->setApplyChangesImmediately(false); + widget->setView(NULL); + + widget->connect(this, SIGNAL(accepted()), SLOT(apply())); + widget->connect(this, SIGNAL(rejected()), SLOT(reset())); + this->connect(widget, SIGNAL(restartRequired()), SLOT(showRestartRequiredMessage())); + vbox->addWidget(widget); + + QSpacerItem* spacer = new QSpacerItem(0, 0,QSizePolicy::Fixed, + QSizePolicy::MinimumExpanding); + vbox->addItem(spacer); + + scrollArea->setWidget(container); + // show panel widgets + widget->updatePanel(); + + int tabIndex = ui.tabBar->addTab(proxy->GetXMLLabel()); + int stackIndex = ui.stackedWidget->addWidget(scrollArea); + this->Internals->TabToStackedWidgets[tabIndex] = stackIndex; + + this->connect(widget, SIGNAL(changeAvailable()), SLOT(onChangeAvailable())); + widget->connect(this, SIGNAL(filterWidgets(bool, QString)), SLOT(filterWidgets(bool, QString))); + } + + // Disable some buttons to start +// ui.buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false); +// ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + +// this->connect(ui.buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), +// SLOT(onRestoreDefaults())); +// this->connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(clicked(QAbstractButton*))); + this->connect(this, SIGNAL(accepted()), SLOT(onAccepted())); + this->connect(this, SIGNAL(rejected()), SLOT(onRejected())); + this->connect(ui.tabBar, SIGNAL(currentChanged(int)), this, SLOT(onTabIndexChanged(int))); + + this->connect(ui.SearchBox, SIGNAL(advancedSearchActivated(bool)), SLOT(filterPanelWidgets())); + this->connect(ui.SearchBox, SIGNAL(textChanged(QString)), SLOT(filterPanelWidgets())); + + // After all the tabs are set up, select the first + this->onTabIndexChanged(0); + + this->filterPanelWidgets(); +} + +//----------------------------------------------------------------------------- +PVGUI_ParaViewSettingsPane::~PVGUI_ParaViewSettingsPane() { -// this->Model = new OptionsDialogModel(); -// this->ApplyUseCount = 0; -// //this->ApplyNeeded = false; + delete this->Internals; + this->Internals = NULL; } -OptionsDialogForm::~OptionsDialogForm() +void PVGUI_ParaViewSettingsPane::store(QtxResourceMgr* , QtxPreferenceMgr* ) { -// delete this->Model; + emit this->accepted(); } +void PVGUI_ParaViewSettingsPane::retrieve(QtxResourceMgr* , QtxPreferenceMgr* ) +{ +// onRestoreDefaults(); +} -//---------------------------------------------------------------------------- -PVGUI_ParaViewSettingsPane::PVGUI_ParaViewSettingsPane(QWidget *widgetParent) - : QtxUserDefinedContent(widgetParent) +void PVGUI_ParaViewSettingsPane::showEvent(QShowEvent * ev) { - Form = new OptionsDialogForm(); - Form->setupUi(this); - - // Connect the button to the standard ParaView 4.2 setting reaction for now: - connect(Form->pvButton, SIGNAL(clicked()), - this, SLOT(onRequestParaviewSettings())); - - -//// this->Form->PageNames->setModel(this->Form->Model); -// -// // Hide the tree widget header view. -// this->Form->PageNames->header()->hide(); -// -// // Hide the apply and reset buttons until they are needed. -// //this->Form->ApplyButton->setEnabled(false); -// //this->Form->ResetButton->setEnabled(false); -// //this->Form->ApplyButton->hide(); -// //this->Form->ResetButton->hide(); -// -// this->connect(this->Form->PageNames->selectionModel(), -// SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), -// this, SLOT(changeCurrentPage())); -// //this->connect(this->Form->ApplyButton, SIGNAL(clicked()), -// // this, SLOT(applyChanges())); -// //this->connect(this->Form->ResetButton, SIGNAL(clicked()), -// // this, SLOT(resetChanges())); -// //this->connect(this->Form->CloseButton, SIGNAL(clicked()), -// // this, SLOT(accept())); -// -// // Code From pqApplicationOptionsDialog -// //this->setApplyNeeded(true); -// -// pqApplicationOptions* appOptions = new pqApplicationOptions; -// this->addOptions(appOptions); -// -// pqGlobalRenderViewOptions* renOptions = new pqGlobalRenderViewOptions; -// this->addOptions(renOptions); -// -// QStringList pages = appOptions->getPageList(); -// if(pages.size()) -// { -// this->setCurrentPage(pages[0]); -// } -// -// /// Add panes as plugins are loaded. -// QObject::connect(pqApplicationCore::instance()->getPluginManager(), -// SIGNAL(guiInterfaceLoaded(QObject*)), -// this, SLOT(pluginLoaded(QObject*))); -// -// // Load panes from already loaded plugins. -// foreach (QObject* plugin_interface, pqApplicationCore::instance()->interfaceTracker()->interfaces()) -// //pqApplicationCore::instance()->getPluginManager()->interfaces()) +// // Connect SALOME's default button to ParaView's default restore. +// LightApp_PreferencesDlg * prefDg; +// QWidget *w = this->parentWidget(); +// // UGLY!!! +// while (w) // { -// this->pluginLoaded(plugin_interface); +// LightApp_PreferencesDlg * prefDg = dynamic_cast( w ); +// if (prefDg) +// break; +// w = w->parentWidget(); // } +// if (prefDg) +// prefDg->connect(btn, SIGNAL(clicked()), this, SLOT(onRestoreDefaults())); + ev->accept(); } -PVGUI_ParaViewSettingsPane::~PVGUI_ParaViewSettingsPane() +void PVGUI_ParaViewSettingsPane::hideEvent(QHideEvent * ev) { - delete this->Form; + // Connect SALOME's default button to ParaView's default restore. + ev->accept(); } -void PVGUI_ParaViewSettingsPane::onRequestParaviewSettings() +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::clicked(QAbstractButton *button) { - pqApplicationSettingsReaction::showApplicationSettingsDialog(); +// Ui::CustomSettingsWidget &ui = this->Internals->Ui; +// QDialogButtonBox::ButtonRole role = ui.buttonBox->buttonRole(button); +// switch (role) +// { +// case QDialogButtonBox::AcceptRole: +// case QDialogButtonBox::ApplyRole: +// emit this->accepted(); +// break; +// +// case QDialogButtonBox::ResetRole: +// case QDialogButtonBox::RejectRole: +// emit this->rejected(); +// break; +// default: +// break; +// } } -/* -bool PVGUI_ParaViewSettingsPane::isApplyNeeded() const +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::onAccepted() { - return this->Form->ApplyNeeded; -} -*/ -/* -void PVGUI_ParaViewSettingsPane::setApplyNeeded(bool applyNeeded) -{ - if(applyNeeded != this->Form->ApplyNeeded) + // If there are any properties that needed to save their values in QSettings, + // do that. Otherwise, save to the vtkSMSettings singleton. + vtkSMSettings * settings = vtkSMSettings::GetInstance(); + pqServer* server = pqActiveObjects::instance().activeServer(); + vtkNew iter; + iter->SetSession(server->session()); + iter->SetModeToOneGroup(); + for (iter->Begin("settings"); !iter->IsAtEnd(); iter->Next()) { - if(!applyNeeded) + vtkSMProxy* proxy = iter->GetProxy(); + settings->SetProxySettings(proxy); + vtkSmartPointer iter2; + iter2.TakeReference(proxy->NewPropertyIterator()); + for (iter2->Begin(); !iter2->IsAtEnd(); iter2->Next()) { - this->Form->ApplyNeeded = false; - //this->Form->ApplyButton->setEnabled(false); - //this->Form->ResetButton->setEnabled(false); + vtkSMProperty* smproperty = iter2->GetProperty(); + if (smproperty && smproperty->GetHints() && + smproperty->GetHints()->FindNestedElementByName("SaveInQSettings")) + { + QString key = QString("%1.%2").arg(iter->GetKey()).arg(iter2->GetKey()); + this->saveInQSettings(key.toLatin1().data(), smproperty); + } } - else if(this->Form->ApplyUseCount > 0) + } + + // Save color palette settings + vtkSMProxy* paletteProxy = server->proxyManager()->GetProxy("global_properties", "ColorPalette"); + if (paletteProxy) + { + settings->SetProxySettings(paletteProxy); + } + + // Disable buttons +// Ui::CustomSettingsWidget &ui = this->Internals->Ui; +// ui.buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false); +// ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + + // In theory, the above changes are undo-redo able, the only things that's not + // undo-able is the "serialized" values. Hence we just clear the undo stack. + CLEAR_UNDO_STACK(); +} + +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::onRejected() +{ + // Disable buttons +// Ui::CustomSettingsWidget &ui = this->Internals->Ui; +// ui.buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false); +// ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); +} + +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::onRestoreDefaults() +{ + pqServer* server = pqActiveObjects::instance().activeServer(); + vtkSMSession * session = server->session(); + + vtkNew iter; + iter->SetSession(session); + iter->SetModeToOneGroup(); + for (iter->Begin("settings"); !iter->IsAtEnd(); iter->Next()) + { + vtkSMProxy* proxy = iter->GetProxy(); + if (proxy) { - this->Form->ApplyNeeded = true; - //this->Form->ApplyButton->setEnabled(true); - //this->Form->ResetButton->setEnabled(true); + proxy->ResetPropertiesToXMLDefaults(); } } + + vtkSMProxy* paletteProxy = server->proxyManager()->GetProxy("global_properties", "ColorPalette"); + if (paletteProxy) + { + paletteProxy->ResetPropertiesToXMLDefaults(); + } } -*/ -//void PVGUI_ParaViewSettingsPane::addOptions(const QString &path, pqOptionsPage *options) -//{ -// if(!options) -// { -// return; -// } -// -// // See if the page is a container. -// pqOptionsContainer *container = qobject_cast(options); -// if(!container && path.isEmpty()) -// { -// return; -// } -// -// // See if the page/container uses the apply button. -// if(options->isApplyUsed()) -// { -// this->Form->ApplyUseCount++; -// /*if(this->Form->ApplyUseCount == 1) -// { -// //this->Form->ApplyButton->show(); -// //this->Form->ResetButton->show(); -// //QObject::connect(this, SIGNAL(accepted()), this, SLOT(applyChanges())); -// }*/ -// -// //this->connect(options, SIGNAL(changesAvailable()), -// //this, SLOT(enableButtons())); -// } -// -// // Add the widget to the stack. -// this->Form->Stack->addWidget(options); -// -// // Add the page(s) to the map and the model. -// if(container) -// { -// // If the path is not empty, use it as the page prefix. -// QString prefix; -// if(!path.isEmpty()) -// { -// prefix = path; -// prefix.append("."); -// } -// -// container->setPagePrefix(prefix); -// -// // Get the list of pages from the container. -// QStringList pathList = container->getPageList(); -// QStringList::Iterator iter = pathList.begin(); -// for( ; iter != pathList.end(); ++iter) -// { -// this->Form->Pages.insert(prefix + *iter, options); -// this->Form->Model->addPath(prefix + *iter); -// } -// } -// else -// { -// this->Form->Pages.insert(path, options); -// this->Form->Model->addPath(path); -// } -//} -// -//void PVGUI_ParaViewSettingsPane::addOptions(pqOptionsContainer *options) -//{ -// this->addOptions(QString(), options); -//} -// -//void PVGUI_ParaViewSettingsPane::removeOptions(pqOptionsPage *options) -//{ -// if(!options) -// { -// return; -// } -// -// // Remove the widget from the stack. -// this->Form->Stack->removeWidget(options); -// -// // See if the options use the apply button. -// if(options->isApplyUsed()) -// { -// this->Form->ApplyUseCount--; -// /*if(this->Form->ApplyUseCount == 0) -// { -// //this->Form->ApplyNeeded = false; -// //this->Form->ApplyButton->setEnabled(false); -// //this->Form->ResetButton->setEnabled(false); -// //this->Form->ApplyButton->hide(); -// //this->Form->ResetButton->hide(); -// //QObject::disconnect(this, SIGNAL(accepted()), this, SLOT(applyChanges())); -// }*/ -// -// this->disconnect(options, 0, this, 0); -// } -// -// // Search the map for the paths to remove. -// QMap::Iterator iter = this->Form->Pages.begin(); -// while(iter != this->Form->Pages.end()) -// { -// if(*iter == options) -// { -// QString path = iter.key(); -// iter = this->Form->Pages.erase(iter); -// -// // Remove the item from the tree model as well. -// QModelIndex index = this->Form->Model->getIndex(path); -// QPersistentModelIndex parentIndex = index.parent(); -// if(this->Form->Model->removeIndex(index)) -// { -// // Remove any empty parent items. -// while(parentIndex.isValid() && -// this->Form->Model->rowCount(parentIndex) == 0) -// { -// index = parentIndex; -// parentIndex = index.parent(); -// -// // Make sure the index path isn't in the map. -// path = this->Form->Model->getPath(index); -// if(this->Form->Pages.find(path) == this->Form->Pages.end()) -// { -// if(!this->Form->Model->removeIndex(index)) -// { -// break; -// } -// } -// } -// } -// } -// else -// { -// ++iter; -// } -// } -//} -// -//void PVGUI_ParaViewSettingsPane::setCurrentPage(const QString &path) -//{ -// QModelIndex current = this->Form->Model->getIndex(path); -// this->Form->PageNames->setCurrentIndex(current); -//} -void PVGUI_ParaViewSettingsPane::applyChanges() +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::onTabIndexChanged(int index) { - //if(this->Form->ApplyNeeded) - // { -// BEGIN_UNDO_SET("Changed View Settings"); -// emit this->aboutToApplyChanges(); -// QMap::Iterator iter = this->Form->Pages.begin(); -// for( ; iter != this->Form->Pages.end(); ++iter) -// { -// (*iter)->applyChanges(); -// } -// -// //this->setApplyNeeded(false); -// emit this->appliedChanges(); -// END_UNDO_SET(); - //} + int stackWidgetIndex = this->Internals->TabToStackedWidgets[index]; + Ui::CustomSettingsWidget &ui = this->Internals->Ui; + ui.stackedWidget->setCurrentIndex(stackWidgetIndex); } -void PVGUI_ParaViewSettingsPane::resetChanges() +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::filterPanelWidgets() { - //if(this->Form->ApplyNeeded) - //{ -// QMap::Iterator iter = this->Form->Pages.begin(); -// for( ; iter != this->Form->Pages.end(); ++iter) -// { -// (*iter)->resetChanges(); -// } - - //this->setApplyNeeded(false); - //} + Ui::CustomSettingsWidget &ui = this->Internals->Ui; + emit this->filterWidgets( + ui.SearchBox->isAdvancedSearchActive(), ui.SearchBox->text()); } -//void PVGUI_ParaViewSettingsPane::changeCurrentPage() -//{ -// // Get the current index from the view. -// QModelIndex current = this->Form->PageNames->currentIndex(); -// -// // Look up the path for the current index. -// QString path = this->Form->Model->getPath(current); -// QMap::Iterator iter = this->Form->Pages.find(path); -// if(iter == this->Form->Pages.end()) -// { -// // If no page is found, show the blank page. -// this->Form->Stack->setCurrentWidget(this->Form->BlankPage); -// } -// else -// { -// this->Form->Stack->setCurrentWidget(*iter); -// pqOptionsContainer *container = qobject_cast(*iter); -// if(container) -// { -// // Get the path prefix from the container. -// QString prefix = container->getPagePrefix(); -// if(!prefix.isEmpty()) -// { -// // Remove the prefix from the path. -// path.remove(0, prefix.length()); -// } -// -// // Set the page on the container object. -// container->setPage(path); -// } -// } -//} -// -////----------------------------------------------------------------------------- -//void PVGUI_ParaViewSettingsPane::pluginLoaded(QObject* iface) -//{ -// pqViewOptionsInterface* viewOptions = -// qobject_cast(iface); -// if (viewOptions) -// { -// foreach(QString viewtype, viewOptions->viewTypes()) -// { -// // Try to create global view options -// pqOptionsContainer* globalOptions = -// viewOptions->createGlobalViewOptions(viewtype, this); -// if (globalOptions) -// { -// this->addOptions(globalOptions); -// } -// } -// } -//} +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::onChangeAvailable() +{ +// Ui::CustomSettingsWidget &ui = this->Internals->Ui; +// ui.buttonBox->button(QDialogButtonBox::Reset)->setEnabled(true); +// ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true); +} -void PVGUI_ParaViewSettingsPane::store(QtxResourceMgr* , QtxPreferenceMgr* ) +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::showRestartRequiredMessage() { - applyChanges(); + Ui::CustomSettingsWidget &ui = this->Internals->Ui; + ui.restartRequiredLabel->setVisible(true); + PVGUI_ParaViewSettingsPane::ShowRestartRequired = true; } -void PVGUI_ParaViewSettingsPane::retrieve(QtxResourceMgr* , QtxPreferenceMgr* ) +//----------------------------------------------------------------------------- +void PVGUI_ParaViewSettingsPane::saveInQSettings( + const char* key, vtkSMProperty* smproperty) { + pqSettings* settings = pqApplicationCore::instance()->settings(); + + // FIXME: handle all property types. This will only work for single value + // properties. + if (smproperty->IsA("vtkSMIntVectorProperty") || + smproperty->IsA("vtkSMIdTypeVectorProperty")) + { + settings->setValue(key, vtkSMPropertyHelper(smproperty).GetAsInt()); + } + else if (smproperty->IsA("vtkSMDoubleVectorProperty")) + { + settings->setValue(key, vtkSMPropertyHelper(smproperty).GetAsDouble()); + } + else if (smproperty->IsA("vtkSMStringVectorProperty")) + { + settings->setValue(key, vtkSMPropertyHelper(smproperty).GetAsString()); + } } diff --git a/src/PVGUI/PVGUI_ParaViewSettingsPane.h b/src/PVGUI/PVGUI_ParaViewSettingsPane.h index 193e3184..31729139 100644 --- a/src/PVGUI/PVGUI_ParaViewSettingsPane.h +++ b/src/PVGUI/PVGUI_ParaViewSettingsPane.h @@ -28,16 +28,18 @@ #include -#include - -#include "vtkPVConfig.h" - -class pqOptionsContainer; -class OptionsDialogForm; -class pqOptionsPage; -class QString; - - +class QAbstractButton; +class vtkSMProperty; +class QShowEvent; +class QHideEvent; + +/**! + * Almost identical copy/paste of what is found in + * /Qt/Components/pqSettingsDialog.h + * This is (almost) the same, except for the inheritance to QtxUserDefinedContent providing the link + * to SALOME preference mechanism. + * The UI content of pqSettingsDialog is put in a (PARAVIS) widget called pqCustomSettingsWidget. + */ class PVGUI_ParaViewSettingsPane : public QtxUserDefinedContent { Q_OBJECT @@ -50,25 +52,41 @@ public: virtual void store(QtxResourceMgr* theRes, QtxPreferenceMgr* thePref); virtual void retrieve(QtxResourceMgr* theRes, QtxPreferenceMgr* thePref); + signals: + void accepted(); // emulate the initial QDialogBox signal since some stuff are connected to it. + +protected: + virtual void showEvent(QShowEvent * ev); + virtual void hideEvent(QHideEvent * ev); + + // ---- From now on, this the same interface as in pqSettingsDialog + private slots: + void clicked(QAbstractButton*); + void onAccepted(); + void onRejected(); + void onRestoreDefaults(); -public slots: - /// Calls each page to apply any changes. - void applyChanges(); + void onTabIndexChanged(int index); + void onChangeAvailable(); + void showRestartRequiredMessage(); - /// Calls each page to reset any changes. - void resetChanges(); + void filterPanelWidgets(); - void onRequestParaviewSettings(); + signals: + void filterWidgets(bool showAdvanced, const QString& text); -signals: - /// Emitted before the option changes are applied. - void aboutToApplyChanges(); + private: + void saveInQSettings(const char* key, vtkSMProperty* smproperty); - /// Emitted after the option changes have been applied. - void appliedChanges(); + private: + Q_DISABLE_COPY(PVGUI_ParaViewSettingsPane); + class pqInternals; + pqInternals* Internals; -private: - OptionsDialogForm *Form; /// Stores the form and class data. + /// Set to true if a setting that requires a restart to take effect + /// is modified. Made static to persist across instantiations of + /// this class. + static bool ShowRestartRequired; }; #endif diff --git a/src/PVGUI/resources/pqCustomSettingsWidget.ui b/src/PVGUI/resources/pqCustomSettingsWidget.ui new file mode 100644 index 00000000..af91e80c --- /dev/null +++ b/src/PVGUI/resources/pqCustomSettingsWidget.ui @@ -0,0 +1,108 @@ + + + CustomSettingsWidget + + + + 0 + 0 + 681 + 599 + + + + + 0 + 0 + + + + Form + + + + + + 2 + + + + + pqSettingsDialog/showAdvancedProperties + + + true + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + 0 + + + + + + + + + + 16777215 + 20 + + + + + 75 + true + + + + * Restart required for some settings to take effect + + + true + + + + + + + + QTabBar + QWidget +
QTabBar
+ 1 +
+ + pqSearchBox + QWidget +
pqSearchBox.h
+ 1 +
+
+ + +
diff --git a/src/PVGUI/ui_pqOptionsDialog.h b/src/PVGUI/ui_pqOptionsDialog.h deleted file mode 100644 index b186890e..00000000 --- a/src/PVGUI/ui_pqOptionsDialog.h +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************** -** Form generated from reading ui file 'pqOptionsDialog.ui' -** -** Created: Wed Apr 21 12:59:58 2010 -** by: Qt User Interface Compiler version 4.5.3 -** -** WARNING! All changes made in this file will be lost when recompiling ui file! -********************************************************************************/ - -#ifndef UI_PQOPTIONSDIALOG_H -#define UI_PQOPTIONSDIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_PVGUIOptionsFrame -{ -public: - QGridLayout *gridLayout; - QHBoxLayout *hboxLayout; - QSpacerItem *spacerItem; - //QPushButton *ApplyButton; - //QPushButton *ResetButton; - //QPushButton *CloseButton; - QStackedWidget *Stack; - QWidget *BlankPage; - QTreeView *PageNames; - QFrame *Separator; - QPushButton * pvButton; - - void setupUi(QWidget *pvguiOptionsFrame) - { - if (pvguiOptionsFrame->objectName().isEmpty()) - pvguiOptionsFrame->setObjectName(QString::fromUtf8("pvguiOptionsFrame")); - pvguiOptionsFrame->resize(514, 382); - gridLayout = new QGridLayout(pvguiOptionsFrame); -#ifndef Q_OS_MAC - gridLayout->setSpacing(6); -#endif -#ifndef Q_OS_MAC - gridLayout->setMargin(9); -#endif - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - - pvButton = new QPushButton("Edit ParaView settings ...", pvguiOptionsFrame); - gridLayout->addWidget(pvButton, 0, 0, 1, 1); -// hboxLayout = new QHBoxLayout(); -//#ifndef Q_OS_MAC -// hboxLayout->setSpacing(6); -//#endif -// hboxLayout->setMargin(4); -// hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); -// spacerItem = new QSpacerItem(0, 26, QSizePolicy::Expanding, QSizePolicy::Minimum); -// -// hboxLayout->addItem(spacerItem); -// -// //ApplyButton = new QPushButton(pqOptionsFrame); -// //ApplyButton->setObjectName(QString::fromUtf8("ApplyButton")); -// -// //hboxLayout->addWidget(ApplyButton); -// -// //ResetButton = new QPushButton(pqOptionsFrame); -// //ResetButton->setObjectName(QString::fromUtf8("ResetButton")); -// -// //hboxLayout->addWidget(ResetButton); -// -// //CloseButton = new QPushButton(pqOptionsFrame); -// //CloseButton->setObjectName(QString::fromUtf8("CloseButton")); -// //CloseButton->setDefault(true); -// -// //hboxLayout->addWidget(CloseButton); -// -// -// gridLayout->addLayout(hboxLayout, 2, 0, 1, 2); -// -// Stack = new QStackedWidget(pqOptionsFrame); -// Stack->setObjectName(QString::fromUtf8("Stack")); -// BlankPage = new QWidget(); -// BlankPage->setObjectName(QString::fromUtf8("BlankPage")); -// Stack->addWidget(BlankPage); -// -// gridLayout->addWidget(Stack, 0, 1, 1, 1); -// -// PageNames = new QTreeView(pqOptionsFrame); -// PageNames->setObjectName(QString::fromUtf8("PageNames")); -// QSizePolicy sizePolicy(static_cast(0), static_cast(7)); -// sizePolicy.setHorizontalStretch(0); -// sizePolicy.setVerticalStretch(0); -// sizePolicy.setHeightForWidth(PageNames->sizePolicy().hasHeightForWidth()); -// PageNames->setSizePolicy(sizePolicy); -// PageNames->setMinimumSize(QSize(160, 0)); -// PageNames->setMaximumSize(QSize(160, 16777215)); -// -// gridLayout->addWidget(PageNames, 0, 0, 1, 1); -// -// Separator = new QFrame(pqOptionsFrame); -// Separator->setObjectName(QString::fromUtf8("Separator")); -// Separator->setFrameShape(QFrame::HLine); -// Separator->setFrameShadow(QFrame::Sunken); -// -// gridLayout->addWidget(Separator, 1, 0, 1, 2); -// -// //QWidget::setTabOrder(CloseButton, PageNames); -// //QWidget::setTabOrder(PageNames, ApplyButton); -// //QWidget::setTabOrder(ApplyButton, ResetButton); -// -// retranslateUi(pqOptionsFrame); -// -// Stack->setCurrentIndex(0); - - - QMetaObject::connectSlotsByName(pvguiOptionsFrame); - } // setupUi - - void retranslateUi(QWidget *pvguiOptionsFrame) - { - pvguiOptionsFrame->setWindowTitle(QApplication::translate("pvguiOptionsFrame", "Options", 0, QApplication::UnicodeUTF8)); - //ApplyButton->setText(QApplication::translate("pqOptionsFrame", "&Apply", 0, QApplication::UnicodeUTF8)); - //ResetButton->setText(QApplication::translate("pqOptionsFrame", "&Reset", 0, QApplication::UnicodeUTF8)); - //CloseButton->setText(QApplication::translate("pqOptionsFrame", "&Ok", 0, QApplication::UnicodeUTF8)); -#ifndef QT_NO_WHATSTHIS -// PageNames->setWhatsThis(QApplication::translate("pvguiOptionsFrame", "Select a category to show the options for that category.", 0, QApplication::UnicodeUTF8)); -#endif // QT_NO_WHATSTHIS - Q_UNUSED(pvguiOptionsFrame); - } // retranslateUi - -}; - -namespace Ui { - class PVGUIOptionsFrame: public Ui_PVGUIOptionsFrame {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_PQOPTIONSDIALOG_H