Skip to content

Commit

Permalink
Refs #11717 Provide pop up for cmap editor
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonPiccardoSelg committed May 14, 2015
1 parent 0ce2394 commit ca4d3da
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 67 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/CMakeLists.txt
Expand Up @@ -6,6 +6,7 @@ set( INCLUDE_FILES
inc/MantidVatesSimpleGuiViewWidgets/CameraManager.h
inc/MantidVatesSimpleGuiViewWidgets/BackgroundRgbProvider.h
inc/MantidVatesSimpleGuiViewWidgets/ColorMapManager.h
inc/MantidVatesSimpleGuiViewWidgets/ColorMapEditorPanel.h
inc/MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.h
inc/MantidVatesSimpleGuiViewWidgets/ColorUpdater.h
inc/MantidVatesSimpleGuiViewWidgets/LibHelper.h
Expand All @@ -31,6 +32,7 @@ set( SOURCE_FILES
src/CameraManager.cpp
src/BackgroundRgbProvider.cpp
src/ColorMapManager.cpp
src/ColorMapEditorPanel.cpp
src/ColorSelectionWidget.cpp
src/ColorUpdater.cpp
src/MdViewerWidget.cpp
Expand All @@ -57,6 +59,7 @@ set( TEST_FILES
# Qt's moc preprocessor.
qt4_wrap_cpp( MOC_SOURCES
inc/MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.h
inc/MantidVatesSimpleGuiViewWidgets/ColorMapEditorPanel.h
inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h
inc/MantidVatesSimpleGuiViewWidgets/MultisliceView.h
inc/MantidVatesSimpleGuiViewWidgets/PeaksTableControllerVsi.h
Expand All @@ -76,6 +79,7 @@ qt4_wrap_cpp( MOC_SOURCES
# Qt's ui file processor.
qt4_wrap_ui( UI_BUILT_SOURCES
inc/MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.ui
inc/MantidVatesSimpleGuiViewWidgets/ColorMapEditorPanel.ui
inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.ui
inc/MantidVatesSimpleGuiViewWidgets/MultisliceView.ui
inc/MantidVatesSimpleGuiViewWidgets/PeaksWidget.ui
Expand Down
@@ -0,0 +1,69 @@
#ifndef COLORMAPEDITORPANEL_H
#define COLORMAPEDITORPANEL_H

#include "ui_ColorMapEditorPanel.h"
#include "MantidVatesSimpleGuiViewWidgets/WidgetDllOption.h"
#include <QWidget>
#include <QDialog>

namespace Mantid {
namespace Vates {
namespace SimpleGui {
/**
*
This class handles the color map editor.
@date 11/05/2015
Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ColorMapEditorPanel
: public QDialog {
Q_OBJECT
public:
/// Default constructor.
ColorMapEditorPanel(QWidget *parent = 0);
/// Default destructor.
~ColorMapEditorPanel();
/// Connect the panel to ParaView
void setUpPanel();
/// Filter events to check for show events.
bool eventFilter(QObject *obj, QEvent *ev);

signals:
void showPopUpWindow();
void hidePopUpWindow();

public slots:
// Show the window pop up
void onShowPopUpWindow();
// Hide the pop up window
void onHidePopUpWindow();

private:
Ui::ColorMapEditorPanel ui; ///< The dialog's UI form
};
}
}
}

#endif // COLORMAPEDITORPANEL_H
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ColorMapEditorPanel</class>
<widget class="QWidget" name="ColorMapEditorPanel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QDockWidget" name="dockWidget">
<widget class="pqColorMapEditor" name="ColorMapEditor"/>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pqColorMapEditor</class>
<extends>QWidget</extends>
<header>pqColorMapEditor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../icons/ViewWidgetsIcons.qrc"/>
</resources>
<connections/>
</ui>
Expand Up @@ -42,6 +42,7 @@ class RotationPointDialog;
class SaveScreenshotReaction;
class ViewBase;
class RebinDialog;
class ColorMapEditorPanel;
/**
*
This class represents the central widget for handling VATES visualization
Expand Down Expand Up @@ -119,10 +120,7 @@ protected slots:
void onUnbin();
/// On switching an MDEvent source to a temporary source.
void onSwitchSoures(std::string rebinnedWorkspaceName, std::string sourceType);
/// handles the position of the color editor panel
void handleColorMapEditorDockPosition(bool);
/// handles the position of the color editor panel when being undocked or redocked
void handleColorMapEditorDockWhenDocking(bool isFloating);

protected:
/// Handle workspace preDeletion tasks.
void preDeleteHandle(const std::string &wsName,
Expand Down Expand Up @@ -156,6 +154,7 @@ protected slots:
RebinAlgorithmDialogProvider m_rebinAlgorithmDialogProvider; ///<Provides dialogs to execute rebin algorithms
RebinnedSourcesManager m_rebinnedSourcesManager; ///<Holds the rebinned sources manager
QString m_rebinnedWorkspaceIdentifier; ///< Holds the identifier for temporary workspaces
ColorMapEditorPanel* m_colorMapEditorPanel; ///< Holder for the color map editor panel.

/// Setup color selection widget connections.
void connectColorSelectionWidget();
Expand Down
Expand Up @@ -247,22 +247,6 @@
</property>
</widget>
</widget>
<widget class="QDockWidget" name="colorMapEditorDock">
<property name="floating">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Color Map Editor</string>
</property>
<widget class="pqColorMapEditor" name="colorMapEditorPanel">
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
</widget>
</widget>
</widget>
</item>
<item>
Expand Down Expand Up @@ -332,12 +316,6 @@
<header>pqAxesToolbar.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>pqColorMapEditor</class>
<extends>QWidget</extends>
<header>pqColorMapEditor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../icons/ViewWidgetsIcons.qrc"/>
Expand Down
@@ -0,0 +1,70 @@
#include "MantidVatesSimpleGuiViewWidgets/ColorMapEditorPanel.h"
#include <pqApplicationCore.h>
#include <QWidget>
#include <QDialog>

namespace Mantid {
namespace Vates {
namespace SimpleGui {

ColorMapEditorPanel::ColorMapEditorPanel(QWidget *parent) : QDialog(parent) {}

ColorMapEditorPanel::~ColorMapEditorPanel() {}
/**
* Set up the connections for the pop up window
*/
void ColorMapEditorPanel::setUpPanel() {
this->ui.setupUi(this);
this->hide();
this->ui.dockWidget->installEventFilter(this);
pqApplicationCore::instance()->registerManager("COLOR_EDITOR_PANEL",
this->ui.dockWidget);

QObject::connect(this, SIGNAL(showPopUpWindow()), this,
SLOT(onShowPopUpWindow()), Qt::QueuedConnection);

QObject::connect(this, SIGNAL(hidePopUpWindow()), this,
SLOT(onHidePopUpWindow()), Qt::QueuedConnection);
}

/**
* Show the pop up window
*/
void ColorMapEditorPanel::onShowPopUpWindow() {
this->show();
this->raise();

this->ui.dockWidget->show();
this->ui.dockWidget->raise();
}

/**
* Hide the pop up window
*/
void ColorMapEditorPanel::onHidePopUpWindow() {
this->hide();
this->ui.dockWidget->hide();
}

/**
* This function listens to visibility changes of the ColorMapEditor widget
* and acts on them
* @param obj the subject of the event
* @param ev the actual event
* @return true if the event was handled
*/
bool ColorMapEditorPanel::eventFilter(QObject *obj, QEvent *ev) {
if (this->ui.dockWidget == obj && ev->type() == QEvent::ShowToParent) {
emit showPopUpWindow();
return true;
} else if (this->ui.dockWidget == obj && ev->type() == QEvent::Hide) {
// Note that we actively need to hide the dockWidget, or else
// it will not be set visible the next time!
emit hidePopUpWindow();
return true;
}
return QDialog::eventFilter(obj, ev);
}
}
}
}
Expand Up @@ -5,6 +5,7 @@
#include "MantidVatesSimpleGuiQtWidgets/ModeControlWidget.h"
#include "MantidVatesSimpleGuiQtWidgets/RotationPointDialog.h"
#include "MantidVatesSimpleGuiViewWidgets/BackgroundRgbProvider.h"
#include "MantidVatesSimpleGuiViewWidgets/ColorMapEditorPanel.h"
#include "MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.h"
#include "MantidVatesSimpleGuiViewWidgets/MultisliceView.h"
#include "MantidVatesSimpleGuiViewWidgets/SaveScreenshotReaction.h"
Expand Down Expand Up @@ -136,7 +137,7 @@ REGISTER_VATESGUI(MdViewerWidget)
*/
MdViewerWidget::MdViewerWidget() : VatesViewerInterface(), currentView(NULL),
dataLoader(NULL), hiddenView(NULL), lodAction(NULL), screenShot(NULL), viewLayout(NULL),
viewSettings(NULL), useCurrentColorMap(false), initialView(ModeControlWidget::STANDARD), m_rebinAlgorithmDialogProvider(this), m_rebinnedWorkspaceIdentifier("_tempvsi")
viewSettings(NULL), useCurrentColorMap(false), initialView(ModeControlWidget::STANDARD), m_rebinAlgorithmDialogProvider(this), m_rebinnedWorkspaceIdentifier("_tempvsi"), m_colorMapEditorPanel(NULL)
{
//this will initialize the ParaView application if needed.
VatesParaViewApplication::instance();
Expand Down Expand Up @@ -213,16 +214,11 @@ void MdViewerWidget::setupUiAndConnections()
SLOT(onRotationPoint()));

/// Provide access to the color-editor panel for the application.
pqApplicationCore::instance()->registerManager(
"COLOR_EDITOR_PANEL", this->ui.colorMapEditorDock);
this->ui.colorMapEditorDock->hide();

//
QObject::connect(this->ui.colorMapEditorDock, SIGNAL(visibilityChanged(bool)),
this, SLOT(handleColorMapEditorDockPosition(bool)));
QObject::connect(this->ui.colorMapEditorDock, SIGNAL(topLevelChanged(bool)),
this, SLOT(handleColorMapEditorDockWhenDocking(bool)));

if (!m_colorMapEditorPanel)
{
m_colorMapEditorPanel = new ColorMapEditorPanel(this);
m_colorMapEditorPanel->setUpPanel();
}

//this->connect(this->ui.proxiesPanel,SIGNAL(changeFinished(vtkSMProxy*)),SLOT(panelChanged()));
QAction* temp = new QAction(this);
Expand Down Expand Up @@ -250,36 +246,6 @@ void MdViewerWidget::panelChanged()
this->currentView->renderAll();
}

/**
* This is a hack to position the color map editor panel.
* We check if the visibility of the dock has changed and reposition it according to the VSI
*/
void MdViewerWidget::handleColorMapEditorDockPosition(bool)
{
// Get the position of the VSI
QRect rect = this->geometry();
QPoint pointGlobal = this->mapToGlobal(rect.topLeft());

// Set the color map editor dock to this position.
this->ui.colorMapEditorDock->move(pointGlobal.x(), pointGlobal.y());
}

/**
* We don't want the user to be able to redock the window. If the user tries to redock,
* then we hide the color map editor and set it back to floating.
*@param isFloating :: true if is floating
*/
void MdViewerWidget::handleColorMapEditorDockWhenDocking(bool isFloating)
{
// Hide the color map editor
this->ui.colorMapEditorDock->hide();

// If the color map editor is not floating, then make it floating
if (!isFloating)
{
this->ui.colorMapEditorDock->setFloating(true);
}
}

/**
* This function places the standard view to the main window, installs an
Expand Down Expand Up @@ -1076,6 +1042,8 @@ bool MdViewerWidget::eventFilter(QObject *obj, QEvent *ev)
this->currentView->hide();
this->useCurrentColorMap = false;

this->m_colorMapEditorPanel->hide();

return true;
}
}
Expand Down

0 comments on commit ca4d3da

Please sign in to comment.