Skip to content

Commit

Permalink
Merge pull request #717 from mantidproject/feature/11677_fix_splatter…
Browse files Browse the repository at this point in the history
…plot_not_in_focus_issue

 fix splatterplot not in focus issue
  • Loading branch information
OwenArnold committed May 11, 2015
2 parents f162c47 + 91bedd6 commit 2b4d99f
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 72 deletions.
12 changes: 12 additions & 0 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/MdConstants.h
Expand Up @@ -41,6 +41,18 @@ namespace MantidQt
{
public:

// MD ParaView plugin names
static const QString MantidParaViewSplatterPlot;
static const QString MantidParaViewSpecialCoordinates;
static const QString MDPeaksFilter;
static const QString MantidParaViewPeaksFilter;
static const QString PeakDimensions;
static const QString PeaksWorkspace;
static const QString Delimiter;
static const QString WorkspaceName;
static const QString ProbePoint;
static const QString Threshold;

MdConstants();

~MdConstants();
Expand Down
12 changes: 12 additions & 0 deletions Code/Mantid/MantidQt/API/src/MdConstants.cpp
Expand Up @@ -8,6 +8,18 @@ namespace MantidQt
{
namespace API
{
// Specifiers for ParaView filters
const QString MdConstants::MantidParaViewSplatterPlot = "MantidParaViewSplatterPlot";
const QString MdConstants::MantidParaViewSpecialCoordinates = "SpecialCoordinates";
const QString MdConstants::MDPeaksFilter = "MDPeaksFilter";
const QString MdConstants::MantidParaViewPeaksFilter = "MantidParaViewPeaksFilter";
const QString MdConstants::PeakDimensions = "Peak Dimensions";
const QString MdConstants::PeaksWorkspace = "PeaksWorkspace";
const QString MdConstants::Delimiter = "Delimiter";
const QString MdConstants::WorkspaceName = "WorkspaceName";
const QString MdConstants::ProbePoint = "ProbePoint";
const QString MdConstants::Threshold = "Threshold";

MdConstants::MdConstants() : m_colorScaleStandardMax(0.1), m_logScaleDefaultValue(0.1)
{
initializeSettingsConstants();
Expand Down
Expand Up @@ -61,10 +61,10 @@ namespace Mantid

/**
* Set the Rgb values for the color of the view's background.
* @param viewSwitched Is this the initial loading or were the views switched?
* @param useCurrentBackgroundColor Is this the initial loading or were the views switched?
* @param view The view which has its background color set.
*/
void setBackgroundColor(pqRenderView* view, bool viewSwitched);
void setBackgroundColor(pqRenderView* view, bool useCurrentBackgroundColor);

/**
* Listen to a change in the background color
Expand All @@ -80,17 +80,17 @@ namespace Mantid
private:
/**
* Get the Rgb values for the color of the view's background from the user setting.
* @param viewSwitched Is this the initial loading or were the views switched?
* @param useCurrentBackgroundColor Is this the initial loading or were the views switched?
* @returns A vector with the RGB values
*/
std::vector<double> getRgbFromSetting(bool viewSwitched);
std::vector<double> getRgbFromSetting(bool useCurrentBackgroundColor);

/**
* Get the Rgb values for the color of the view's background
* @param viewSwitched Is this the initial loading or were the views switched?
* @param useCurrentBackgroundColor Is this the initial loading or were the views switched?
* @returns A vector with the RGB values
*/
std::vector<double> getRgb(bool viewSwitched);
std::vector<double> getRgb(bool useCurrentBackgroundColor);

/**
* Callback function for background color changing events
Expand Down
Expand Up @@ -144,7 +144,7 @@ protected slots:
QHBoxLayout *viewLayout; ///< Layout manager for the view widget
pqApplicationSettingsReaction *viewSettings; ///< Holder for the view settings reaction
bool viewSwitched;
bool useCurrentColorMap;
bool useCurrentColorSettings;
ModeControlWidget::Views initialView; ///< Holds the initial view
MantidQt::API::MdSettings mdSettings;///<Holds the MD settings which are used to persist data
MantidQt::API::MdConstants mdConstants;/// < Holds the MD constants
Expand Down
Expand Up @@ -61,6 +61,7 @@ public slots:
void removeLayout(QWidget *widget);
void createTable();
void updatePeakWorkspaceColor();
void setPeakSourceColorToDefault();
std::map<std::string, QColor> getColors();
MantidQt::SliceViewer::PeakPalette m_peakPalette;
boost::shared_ptr<CameraManager> m_cameraManager;
Expand Down
Expand Up @@ -75,7 +75,7 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ViewBase : public QWidget
virtual pqRenderView *createRenderView(QWidget *container,
QString viewName=QString(""));
/// Remove all filters of a given name: i.e. Slice.
virtual void destroyFilter(pqObjectBuilder *builder, const QString &name);
virtual void destroyFilter(const QString &name);
/// Destroy sources and view relevant to mode switching.
virtual void destroyView() = 0;
/// Retrieve the current time step.
Expand All @@ -99,8 +99,8 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ViewBase : public QWidget
virtual bool hasWorkspaceType(const QString &wsTypeName);
/// Check if file/workspace is a MDHistoWorkspace.
virtual bool isMDHistoWorkspace(pqPipelineSource *src);
/// Check if file/workspace is a temporary workspace
virtual bool isTemporaryWorkspace(pqPipelineSource* src);
/// Check if file/workspace is an internally rebinned workspace
virtual bool isInternallyRebinnedWorkspace(pqPipelineSource* src);
/// Check if file/workspace is a Peaks one.
virtual bool isPeaksWorkspace(pqPipelineSource *src);
/// Prints properties for given source.
Expand All @@ -120,7 +120,7 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ViewBase : public QWidget
/// Determines if source has timesteps (4D).
virtual bool srcHasTimeSteps(pqPipelineSource *src);
/// Set the the background color for the view
virtual void setColorForBackground(bool viewSwitched);
virtual void setColorForBackground(bool useCurrentColorSettings);
/// Sets the splatterplot button to the desired visibility.
virtual void setSplatterplot(bool visibility);
/// Initializes the settings of the color scale
Expand Down Expand Up @@ -249,7 +249,7 @@ public slots:
RebinnedSourcesManager* m_rebinnedSourcesManager;
const pqColorMapModel* m_currentColorMapModel;

QString m_temporaryWorkspaceIdentifier;
QString m_internallyRebinnedWorkspaceIdentifier;
};

}
Expand Down
Expand Up @@ -37,10 +37,10 @@ namespace Mantid
update();
}

std::vector<double> BackgroundRgbProvider::getRgb(bool viewSwitched)
std::vector<double> BackgroundRgbProvider::getRgb(bool useCurrentBackgroundColor)
{
// Get the rgb setting from the config file
std::vector<double> userSettingRgb = getRgbFromSetting(viewSwitched);
std::vector<double> userSettingRgb = getRgbFromSetting(useCurrentBackgroundColor);

// Normalize the entries to 256
userSettingRgb[0] = userSettingRgb[0]/255.0;
Expand All @@ -50,13 +50,13 @@ namespace Mantid
return userSettingRgb;
}

std::vector<double> BackgroundRgbProvider::getRgbFromSetting(bool viewSwitched)
std::vector<double> BackgroundRgbProvider::getRgbFromSetting(bool useCurrentBackgroundColor)
{
// Set the mantid default here
std::vector<double> background;
QColor userBackground;

if (viewSwitched)
if (useCurrentBackgroundColor)
{
// Update the settings
update();
Expand Down Expand Up @@ -113,9 +113,9 @@ namespace Mantid
m_mdSettings.setLastSessionBackgroundColor(currentBackgroundColor);
}

void BackgroundRgbProvider::setBackgroundColor(pqRenderView* view, bool viewSwitched)
void BackgroundRgbProvider::setBackgroundColor(pqRenderView* view, bool useCurrentBackgroundColor)
{
std::vector<double> backgroundRgb = getRgb(viewSwitched);
std::vector<double> backgroundRgb = getRgb(useCurrentBackgroundColor);

vtkSMDoubleVectorProperty* background = vtkSMDoubleVectorProperty::SafeDownCast(view->getViewProxy()->GetProperty("Background"));

Expand Down
Expand Up @@ -136,7 +136,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), useCurrentColorSettings(false), initialView(ModeControlWidget::STANDARD), m_rebinAlgorithmDialogProvider(this), m_rebinnedWorkspaceIdentifier("_tempvsi")
{
//this will initialize the ParaView application if needed.
VatesParaViewApplication::instance();
Expand Down Expand Up @@ -651,10 +651,10 @@ void MdViewerWidget::renderWorkspace(QString workspaceName, int workspaceType, s
this->currentView->initializeColorScale();
}

// Set usage of current color map to true, since we have loade the VSI
if (!this->useCurrentColorMap)
// Set usage of current color settings to true, since we have loade the VSI
if (!this->useCurrentColorSettings)
{
this->useCurrentColorMap = true;
this->useCurrentColorSettings = true;
}

QString sourcePlugin = "";
Expand Down Expand Up @@ -885,7 +885,7 @@ ModeControlWidget::Views MdViewerWidget::checkViewAgainstWorkspace(ModeControlWi
void MdViewerWidget::setupPluginMode()
{
GlobalInterpreterLock gil;
this->useCurrentColorMap = false; // Don't use the current color map at start up.
this->useCurrentColorSettings = false; // Don't use the current color map at start up.
this->setupUiAndConnections();
this->createMenus();
this->setupMainView();
Expand Down Expand Up @@ -924,7 +924,7 @@ void MdViewerWidget::renderAndFinalSetup()
*/
void MdViewerWidget::setColorForBackground()
{
this->currentView->setColorForBackground(this->viewSwitched);
this->currentView->setColorForBackground(this->useCurrentColorSettings);
}

/**
Expand Down Expand Up @@ -1035,7 +1035,7 @@ bool MdViewerWidget::eventFilter(QObject *obj, QEvent *ev)
this->currentView ->destroyAllSourcesInView();
this->currentView->updateSettings();
this->currentView->hide();
this->useCurrentColorMap = false;
this->useCurrentColorSettings = false;

return true;
}
Expand Down Expand Up @@ -1411,7 +1411,7 @@ void MdViewerWidget::dropEvent(QDropEvent *e) {
void MdViewerWidget::setColorMap()
{
// If it is not the first startup of the color map, then we want to use the current color map
this->ui.colorSelectionWidget->loadColorMap(this->useCurrentColorMap);
this->ui.colorSelectionWidget->loadColorMap(this->useCurrentColorSettings);
}

} // namespace SimpleGui
Expand Down
Expand Up @@ -396,6 +396,9 @@ void PeaksTableControllerVsi::removeLayout(QWidget *widget) {
* Remove the table.
*/
void PeaksTableControllerVsi::removeTable() {
// Reset the color of peaks sources
setPeakSourceColorToDefault();

destroySinglePeakSource();
if (m_peaksTabWidget) {
m_peaksTabWidget->deleteLater();
Expand Down Expand Up @@ -609,6 +612,50 @@ void PeaksTableControllerVsi::onPeaksSorted(
m_presenter->sortPeaksWorkspace(columnToSortBy, sortAscending, ws);
// Update the tabs
}

/**
* Reset the color of the peaks workspace glyphs to white
*/
void PeaksTableControllerVsi::setPeakSourceColorToDefault() {
pqServer *server = pqActiveObjects::instance().activeServer();
pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel();
QList<pqPipelineSource *> sources = smModel->findItems<pqPipelineSource *>(server);
for (QList<pqPipelineSource *>::iterator src = sources.begin(); src != sources.end(); ++src) {

std::string xmlName((*src)->getProxy()->GetXMLName());
if ((xmlName.find("Peaks Source") != std::string::npos)) {
double red = 1.0;
double green = 1.0;
double blue = 1.0;

pqDataRepresentation *rep =
(*src)
->getRepresentation(pqActiveObjects::instance().activeView());
if (!rep)
{
continue;
}
pqPipelineRepresentation *pipelineRepresentation =
qobject_cast<pqPipelineRepresentation *>(rep);
if (!pipelineRepresentation)
{
continue;
}
pipelineRepresentation->getProxy()->UpdatePropertyInformation();

vtkSMDoubleVectorProperty *prop =
vtkSMDoubleVectorProperty::SafeDownCast(
pipelineRepresentation->getProxy()->GetProperty(
"AmbientColor"));
prop->SetElement(0, red);
prop->SetElement(1, green);
prop->SetElement(2, blue);
pipelineRepresentation->getProxy()->UpdateVTKObjects();
pipelineRepresentation->updateHelperProxies();
pqActiveObjects::instance().activeView()->forceRender();
}
}
}
}
}
}

0 comments on commit 2b4d99f

Please sign in to comment.