Commit 9d79d64d authored by David Thompson's avatar David Thompson Committed by Kitware Robot

Merge topic 'dock-widgets'

180f3b55 Enable - but hide - rather than omit ParaView UI components.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: T.J. Corona's avatarT.J. Corona <tj.corona@kitware.com>
Merge-request: !675
parents 77bc693f 180f3b55
......@@ -89,8 +89,8 @@ set(modelbuilder_SOURCE_FILES
# the module.cmake file for the modules pointing to the paths for the
# GUI-xmls. We process those here.
set (application_gui_xmls
# "${CMAKE_CURRENT_SOURCE_DIR}/ParaViewSources.xml"
# "${CMAKE_CURRENT_SOURCE_DIR}/ParaViewFilters.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/postprocessing-filters.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/postprocessing-sources.xml"
)
foreach (module IN LISTS VTK_MODULES_ENABLED)
get_property(gui_xml GLOBAL PROPERTY ${module}_PARAVIEW_GUI_XMLS)
......@@ -123,7 +123,7 @@ build_paraview_client(modelbuilder
PVMAIN_WINDOW_INCLUDE mbMainWindow.h
BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/modelbuilder.icns"
APPLICATION_ICON "${CMAKE_CURRENT_SOURCE_DIR}/modelbuilder.ico"
# GUI_CONFIGURATION_XMLS ${application_gui_xmls}
GUI_CONFIGURATION_XMLS ${application_gui_xmls}
SOURCES ${modelbuilder_SOURCE_FILES}
INSTALL_RUNTIME_DIR "${VTK_INSTALL_RUNTIME_DIR}"
INSTALL_LIBRARY_DIR "${VTK_INSTALL_LIBRARY_DIR}"
......
......@@ -25,6 +25,7 @@
#include "pqAutoLoadPluginXMLBehavior.h"
#include "pqDeleteReaction.h"
#include "pqInterfaceTracker.h"
#include "pqPVApplicationCore.h"
#include "pqParaViewBehaviors.h"
#include "pqParaViewMenuBuilders.h"
#include "pqStandardViewFrameActionsImplementation.h"
......@@ -78,6 +79,15 @@ static void hideToolBar(QMainWindow* mw, const QString& name)
}
}
static void showToolBar(QMainWindow* mw, const QString& name)
{
auto tb = findToolBar(mw, name);
if (tb)
{
tb->show();
}
}
static QAction* findAction(QToolBar* toolbar, const QString& name)
{
if (toolbar)
......@@ -117,6 +127,15 @@ static void hideAction(QToolBar* tb, const QString& name)
}
}
static void showAction(QToolBar* tb, const QString& name)
{
auto act = findAction(tb, name);
if (act)
{
act->setVisible(true);
}
}
static void hideAction(QAction* act)
{
if (act)
......@@ -125,6 +144,14 @@ static void hideAction(QAction* act)
}
}
static void showAction(QAction* act)
{
if (act)
{
act->setVisible(true);
}
}
//-----------------------------------------------------------------------------
mbMainWindow::mbMainWindow()
{
......@@ -162,10 +189,16 @@ mbMainWindow::mbMainWindow()
pqParaViewMenuBuilders::buildEditMenu(*this->Internals->menu_Edit);
// Populate sources menu.
// pqParaViewMenuBuilders::buildSourcesMenu(*this->Internals->menuSources, this);
pqParaViewMenuBuilders::buildSourcesMenu(*this->Internals->menuSources, this);
// Populate filters menu.
// pqParaViewMenuBuilders::buildFiltersMenu(*this->Internals->menuFilters, this);
pqParaViewMenuBuilders::buildFiltersMenu(*this->Internals->menuFilters, this);
// Hide sources and filters menus by default.
this->Internals->menuSources->menuAction()->setVisible(false);
this->Internals->menuFilters->menuAction()->setVisible(false);
this->Internals->menuSources->setEnabled(false);
this->Internals->menuFilters->setEnabled(false);
// Populate Tools menu.
pqParaViewMenuBuilders::buildToolsMenu(*this->Internals->menuTools);
......@@ -264,6 +297,29 @@ mbMainWindow::mbMainWindow()
QObject::connect(this->Internals->proxyTabWidget, SIGNAL(deleteRequested(pqPipelineSource*)),
reactionDel, SLOT(deleteSource(pqPipelineSource*)));
// Prepare sources and filters from XML
// Load the filter and source XML configurations like
// ParaView's branded_paraview_initializer.cxx.in would:
auto pvapp = pqPVApplicationCore::instance();
QString root(":/modelbuilder/Configuration");
QDir dir(root);
QStringList files = dir.entryList(QDir::Files);
foreach (QString file, files)
{
pvapp->loadConfiguration(root + QString("/") + file);
}
// Set up but hide the pipeline browser dock-widget by default.
pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(
*this->Internals->pipelineBrowser->contextMenu());
// Turn off post-processing functionality by default.
// NB: This is fragile! The timer below is set for 20ms
// because pqPersistentMainWindowStateBehavior::restoreState
// is scheduled to occur at 10ms after the event loop starts.
// If ParaView changes, then this timer must change.
QTimer::singleShot(20, this, SLOT(prepare()));
// Enable the colormap editor.
this->Internals->colorMapEditorDock->hide();
pqApplicationCore::instance()->registerManager(
......@@ -278,6 +334,61 @@ mbMainWindow::~mbMainWindow()
delete this->Internals;
}
//-----------------------------------------------------------------------------
void mbMainWindow::prepare()
{
this->togglePostProcessingMode(false);
}
//-----------------------------------------------------------------------------
void mbMainWindow::togglePostProcessingMode(bool enablePostProcessing)
{
auto pipelineBrowserDock = this->Internals->pipelineBrowserDock;
auto pipelineBrowserAction = pipelineBrowserDock->toggleViewAction();
if (enablePostProcessing)
{
this->Internals->menuSources->menuAction()->setVisible(true);
this->Internals->menuFilters->menuAction()->setVisible(true);
this->Internals->menuSources->setEnabled(true);
this->Internals->menuFilters->setEnabled(true);
pipelineBrowserAction->setEnabled(true);
pipelineBrowserAction->setVisible(true);
pipelineBrowserAction->setChecked(true);
pipelineBrowserDock->show();
showToolBar(this, "&Common");
showToolBar(this, "&Data Analysis");
showToolBar(this, "VCR Controls");
showToolBar(this, "Current Time Controls");
showAction(findToolBar(this, "Main Controls"), "Find data...");
showAction(findActionByName(this, "actionFileLoadServerState"));
showAction(findActionByName(this, "actionFileSaveServerState"));
}
else
{
this->Internals->menuSources->menuAction()->setVisible(false);
this->Internals->menuFilters->menuAction()->setVisible(false);
this->Internals->menuSources->setEnabled(false);
this->Internals->menuFilters->setEnabled(false);
pipelineBrowserAction->setEnabled(false);
pipelineBrowserAction->setVisible(false);
pipelineBrowserAction->setChecked(false);
pipelineBrowserDock->hide();
hideToolBar(this, "&Common");
hideToolBar(this, "&Data Analysis");
hideToolBar(this, "VCR Controls");
hideToolBar(this, "Current Time Controls");
hideAction(findToolBar(this, "Main Controls"), "Find data...");
hideAction(findActionByName(this, "actionFileLoadServerState"));
hideAction(findActionByName(this, "actionFileSaveServerState"));
}
}
//-----------------------------------------------------------------------------
void mbMainWindow::showHelpForProxy(const QString& groupname, const QString& proxyname)
{
......
......@@ -22,6 +22,10 @@ public:
mbMainWindow();
~mbMainWindow();
public slots:
void prepare();
void togglePostProcessingMode(bool enablePostProcessing);
protected slots:
void showHelpForProxy(const QString& groupname, const QString& proxyname);
......
......@@ -36,6 +36,16 @@
<property name="title">
<string>&amp;File</string>
</property>
</widget>
<widget class="QMenu" name="menuSources">
<property name="title">
<string>&amp;Sources</string>
</property>
</widget>
<widget class="QMenu" name="menuFilters">
<property name="title">
<string>Fi&amp;lters</string>
</property>
</widget>
<widget class="QMenu" name="menu_Edit">
<property name="title">
......@@ -65,10 +75,28 @@
<addaction name="menu_File"/>
<addaction name="menu_Edit"/>
<addaction name="menu_View"/>
<addaction name="menuSources"/>
<addaction name="menuFilters"/>
<addaction name="menuTools"/>
<addaction name="menu_Macros"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QDockWidget" name="pipelineBrowserDock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Pipeline Browser</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="pqPipelineBrowserWidget" name="pipelineBrowser">
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
</widget>
</widget>
<widget class="QDockWidget" name="proxyTabDock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
......@@ -110,7 +138,13 @@
<widget class="pqColorMapEditor" name="colorMapEditorPanel"/>
</widget>
</widget>
<customwidgets>
<customwidgets>
<customwidget>
<class>pqPipelineBrowserWidget</class>
<extends>QWidget</extends>
<header>pqPipelineBrowserWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>pqViewManager</class>
<extends>QWidget</extends>
......
......@@ -21,15 +21,15 @@ set(PLUGIN_CONFIG_XMLS
postprocessing-sources.xml
)
# Before we process PLUGIN_RSRCS, append an additional entry
# that we generate from configuration XMLs:
set(generated_rsrc "${CMAKE_CURRENT_BINARY_DIR}/cmbPostProcessingModePluginConfig.qrc")
generate_qt_resource_from_files(
"${generated_rsrc}"
"/cmbPostProcessingModePlugin/Configuration"
"${PLUGIN_CONFIG_XMLS}"
)
list(APPEND PLUGIN_RSRCS "${generated_rsrc}")
## Before we process PLUGIN_RSRCS, append an additional entry
## that we generate from configuration XMLs:
#set(generated_rsrc "${CMAKE_CURRENT_BINARY_DIR}/cmbPostProcessingModePluginConfig.qrc")
#generate_qt_resource_from_files(
# "${generated_rsrc}"
# "/cmbPostProcessingModePlugin/Configuration"
# "${PLUGIN_CONFIG_XMLS}"
#)
#list(APPEND PLUGIN_RSRCS "${generated_rsrc}")
# Register the behavior with ParaView
add_paraview_action_group(PLUGIN_ACTION_IFACES PLUGIN_ACTION_IFACE_SRCS
......
......@@ -24,6 +24,7 @@
#include <QMenu>
#include <QMenuBar>
#include <QMetaObject>
#include <QTimer>
#include <QToolBar>
#include <QWidget>
......@@ -41,15 +42,10 @@ public:
Ui::pqCMBPostProcessingModeBehavior Actions;
QAction* ModeAction;
QWidget ActionsOwner;
QMenu* MenuSources;
QMenu* MenuFilters;
std::vector<QToolBar*> PostProcessingToolBars;
std::vector<QAction*> PostProcessingActions;
};
pqCMBPostProcessingModeBehavior::pqCMBPostProcessingModeBehavior(QObject* parent)
: Superclass(parent)
, m_menusBuilt(false)
{
m_p = new pqInternal;
m_p->Actions.setupUi(&m_p->ActionsOwner);
......@@ -66,6 +62,7 @@ pqCMBPostProcessingModeBehavior::pqCMBPostProcessingModeBehavior(QObject* parent
this->setExclusive(false);
QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(switchModes(QAction*)));
QTimer::singleShot(0, this, SLOT(prepare()));
}
pqCMBPostProcessingModeBehavior::~pqCMBPostProcessingModeBehavior()
......@@ -81,177 +78,13 @@ pqCMBPostProcessingModeBehavior* pqCMBPostProcessingModeBehavior::instance()
return s_postMode;
}
void pqCMBPostProcessingModeBehavior::switchModes(QAction* a)
{
this->buildMenus();
for (auto act : m_p->PostProcessingActions)
{
if (act)
{
act->setVisible(a->isChecked());
}
}
if (a->isChecked())
{
m_p->MenuSources->setEnabled(true);
m_p->MenuFilters->setEnabled(true);
m_p->MenuSources->menuAction()->setVisible(true);
m_p->MenuFilters->menuAction()->setVisible(true);
m_p->Actions.pipelineBrowserDock->show();
for (auto tbar : m_p->PostProcessingToolBars)
{
if (tbar)
{
tbar->show();
}
}
}
else
{
m_p->MenuSources->menuAction()->setVisible(false);
m_p->MenuFilters->menuAction()->setVisible(false);
m_p->MenuSources->setEnabled(false);
m_p->MenuFilters->setEnabled(false);
m_p->Actions.pipelineBrowserDock->hide();
for (auto tbar : m_p->PostProcessingToolBars)
{
if (tbar)
{
tbar->hide();
}
}
// TODO: We could do something fancy here like:
// for each view v
// for each representation r
// if !pipline-source(r).isA('pqSMTKResource') then r.setVisibility(false)
// to disable all post-processing filter representations.
}
}
static QAction* findMenuAction(QMenuBar* bar, const QString& name)
{
foreach (QAction* act, bar->actions())
{
if (act->text() == name)
{
return act;
}
}
return nullptr;
}
static QToolBar* findToolBar(QMainWindow* mw, const QString& name)
{
foreach (QToolBar* bar, mw->findChildren<QToolBar*>())
{
if (bar->windowTitle() == name)
{
return bar;
}
}
return nullptr;
}
static QAction* findActionByName(QMainWindow* mw, const QString& name)
void pqCMBPostProcessingModeBehavior::prepare()
{
if (mw)
{
foreach (QAction* act, mw->findChildren<QAction*>())
{
if (act->objectName() == name)
{
return act;
}
}
}
return nullptr;
QObject::connect(this, SIGNAL(togglePostProcessingMode(bool)), pqCoreUtilities::mainWidget(),
SLOT(togglePostProcessingMode(bool)));
}
static QAction* findAction(QToolBar* toolbar, const QString& name)
{
if (toolbar)
{
foreach (QAction* bar, toolbar->findChildren<QAction*>())
{
if (bar->text() == name)
{
return bar;
}
}
}
return nullptr;
}
void pqCMBPostProcessingModeBehavior::buildMenus()
void pqCMBPostProcessingModeBehavior::switchModes(QAction* a)
{
if (m_menusBuilt)
{
return;
}
if (QMainWindow* mw = dynamic_cast<QMainWindow*>(pqCoreUtilities::mainWidget()))
{
m_menusBuilt = true;
// Build the source and filter menus:
m_p->MenuSources = mw->menuBar()->addMenu("&Sources");
pqParaViewMenuBuilders::buildSourcesMenu(*m_p->MenuSources, mw);
m_p->MenuFilters = mw->menuBar()->addMenu("&Filters");
pqParaViewMenuBuilders::buildFiltersMenu(*m_p->MenuFilters, mw);
QAction* toolsMenu = findMenuAction(mw->menuBar(), "&Tools");
mw->menuBar()->insertMenu(toolsMenu, m_p->MenuSources);
mw->menuBar()->insertMenu(toolsMenu, m_p->MenuFilters);
// Move the pipeline browser widget from our UI file to the
// main window and dock it on the left, like ParaView:
m_p->Actions.pipelineBrowserDock->setParent(mw);
mw->addDockWidget(Qt::LeftDockWidgetArea, m_p->Actions.pipelineBrowserDock);
QDockWidget* propDock = mw->findChild<QDockWidget*>("proxyTabDock");
if (propDock)
{
// Be tricky here: we just added the pipeline browser panel, so it is not
// located anywhere we have control over. But the user has placed the propDock
// panel where he wants it and that position is saved across restarts (unlike
// the pipeline browser). So, first, split the propDock widget (which moves
// the pipeline browser into a good place next to the propDoc, but leaves it
// below the propDock, which is not nice). However, now we can split the
// pipeline browser leaving the propDock beneath it. And if the user has tabbed
// the propDock then the pipeline browser should now be tabbed with it.
//
// We only do this once at creation time. The rest of the time, the panel will
// remember its location if the user moves it.
mw->splitDockWidget(propDock, m_p->Actions.pipelineBrowserDock, Qt::Vertical);
mw->splitDockWidget(m_p->Actions.pipelineBrowserDock, propDock, Qt::Vertical);
}
// Load the filter and source XML configurations like
// ParaView's branded_paraview_initializer.cxx.in would:
auto pvapp = pqPVApplicationCore::instance();
QString root(":/cmbPostProcessingModePlugin/Configuration");
QDir dir(root);
QStringList files = dir.entryList(QDir::Files);
foreach (QString file, files)
{
pvapp->loadConfiguration(root + QString("/") + file);
}
// Loading these configurations creates some toolbars
// we want to disable when not in post-processing mode.
// Collect them:
m_p->PostProcessingToolBars.push_back(findToolBar(mw, "&Common"));
m_p->PostProcessingToolBars.push_back(findToolBar(mw, "&Data Analysis"));
m_p->PostProcessingToolBars.push_back(findToolBar(mw, "VCR Controls"));
m_p->PostProcessingToolBars.push_back(findToolBar(mw, "Current Time Controls"));
m_p->PostProcessingActions.push_back(
findAction(findToolBar(mw, "Main Controls"), "Find data..."));
m_p->PostProcessingActions.push_back(findActionByName(mw, "actionFileLoadServerState"));
m_p->PostProcessingActions.push_back(findActionByName(mw, "actionFileSaveServerState"));
}
if (!m_menusBuilt)
{
std::cerr << "Warning: Could not add post-processing menu items. Sorry.\n";
}
emit togglePostProcessingMode(a->isChecked());
}
......@@ -25,15 +25,27 @@ public:
static pqCMBPostProcessingModeBehavior* instance();
signals:
void togglePostProcessingMode(bool enablePostProcessing);
protected slots:
/**\brief This slot is invoked the first time events are processed after the constructor is run.
*
* It must run in the main event loop since pqCoreUtilities::mainWidget() returns
* nullptr inside the constructor when the plugin is set to autoload.
*/
virtual void prepare();
/**\brief This slot is invoked when the post-processing mode button is toggled.
*
* It emits togglePostProcessingMode(bool) which can be connected to the main
* window (when the main widget is of time mbMainWindow).
*/
virtual void switchModes(QAction* a);
protected:
class pqInternal;
pqInternal* m_p;
bool m_menusBuilt;
void buildMenus();
private:
Q_DISABLE_COPY(pqCMBPostProcessingModeBehavior);
......
......@@ -30,32 +30,8 @@
<string>Enable ParaView's pipeline inspector, filters, and sources.</string>
</property>
</action>
<widget class="QDockWidget" name="pipelineBrowserDock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Pipeline Browser</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="pqPipelineBrowserWidget" name="pipelineBrowser">
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
</widget>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>pqPipelineBrowserWidget</class>
<extends>QWidget</extends>
<header>pqPipelineBrowserWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="pqCMBPostProcessingModeBehavior.qrc"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment