Skip to content

Commit

Permalink
Refs #6315. Merging color scaling fix.
Browse files Browse the repository at this point in the history
Merge branch 'bugfix/6777_auto_color_scaling' into feature/6315_build_pv_398

Conflicts:
	Code/Mantid/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp
  • Loading branch information
Michael Reuter committed Apr 9, 2013
2 parents fadc81d + 8464ec3 commit 6796b1d
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,20 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ColorSelectionWidget : public
/// Default destructor.
virtual ~ColorSelectionWidget() {}

/// Get the auto color scaling state
bool getAutoScaleState();
/// Get the log scale state
bool getLogScaleState();
/// Get the minimum color range value
double getMinRange();
/// Get the maximum color range value
double getMaxRange();

public slots:
/// Set state for all control widgets.
void enableControls(bool state);
/// Reset the widget's state.
void reset();
/// Set the color scale range into the range widgets.
void setColorScaleRange(double min, double max);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace Vates
{
namespace SimpleGui
{

class ColorSelectionWidget;

/**
*
This class handles the application of requests from the ColorSelectionWidget.
Expand Down Expand Up @@ -70,12 +73,30 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ColorUpdater
*/
void colorScaleChange(pqPipelineRepresentation *repr, double min,
double max);
/// Get the auto scaling state.
bool isAutoScale();
/// Get the logarithmic scaling state.
bool isLogScale();
/// Get the maximum color scaling range value.
double getMaximumRange();
/// Get the minimum color scaling range value.
double getMinimumRange();
/**
* Set logarithmic color scaling on the data.
* @param repr the representation to set logarithmic color scale
* @param state flag to determine whether or not to use log color scaling
*/
void logScale(pqPipelineRepresentation *repr, int state);
/// Print internal information.
void print();
/// Update the internal state.
void updateState(ColorSelectionWidget *cs);

private:
bool autoScaleState; ///< Holder for the auto scaling state
bool logScaleState; ///< Holder for the log scaling state
double minScale; ///< Holder for the minimum color range state
double maxScale; ///< Holder for the maximum color range state
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ protected slots:
void onWikiHelp();
/// Load and render data.
void onDataLoaded(pqPipelineSource *source);
/// Perform actions when rendering is done.
void renderingDone();
/// Execute view switch.
void switchViews(ModeControlWidget::Views v);

Expand All @@ -108,6 +110,7 @@ protected slots:
Ui::MdViewerWidgetClass ui; ///< The MD viewer's UI form
QHBoxLayout *viewLayout; ///< Layout manager for the view widget
pqViewSettingsReaction *viewSettings; ///< Holder for the view settings reaction
bool viewSwitched;

/// Check the environmental variables.
void checkEnvSetup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ThreeSliceView : public ViewB
* Correct an oddity in the creation of the 3D view so that the cuts
* are visibile.
*/
void correctVisibility();
//void correctVisibility();
/**
* ViewBase::destroyView
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace Vates
{
namespace SimpleGui
{

class ColorSelectionWidget;

/**
*
This class is an abstract base class for all of the Vates simple GUI's views.
Expand Down Expand Up @@ -65,8 +68,6 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ViewBase : public QWidget
virtual void checkViewOnSwitch();
/// Close view generated sub-windows.
virtual void closeSubWindows();
/// Correct post-accept visibility issues.
virtual void correctVisibility();
/// Creates a single view instance.
virtual pqRenderView *createRenderView(QWidget *container,
QString viewName=QString(""));
Expand Down Expand Up @@ -103,6 +104,8 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS ViewBase : public QWidget
virtual void resetDisplay() = 0;
/// Setup axis scales
virtual void setAxisScales();
/// Set the current color scale state
virtual void setColorScaleState(ColorSelectionWidget *cs);
/// Create source for plugin mode.
virtual void setPluginSource(QString pluginName, QString wsName);
/// Determines if source has timesteps (4D).
Expand Down Expand Up @@ -131,6 +134,8 @@ public slots:
void onResetCenterToData();
/// Reset center of rotation to given point.
void onResetCenterToPoint(double x, double y, double z);
/// Set color scaling for a view.
void setColorsForView();
/// Setup the animation controls.
void setTimeSteps(bool withUpdate = false);
/// Provide updates to UI.
Expand All @@ -148,6 +153,8 @@ public slots:
* @param state set to false to lock out all controls
*/
void lockColorControls(bool state=false);
/// Signal indicating rendering is done.
void renderingDone();
/// Signal to trigger pipeline update.
void triggerAccept();
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,69 @@ void ColorSelectionWidget::enableControls(bool state)
this->ui.presetButton->setEnabled(state);
}

/**
* This function returns the state of the automatic color scaling.
* Since a checkbox is used, the checked state is actually 2, so it needs
* to be decremented to cast to a boolean.
* @return the state of automatic color scaling
*/
bool ColorSelectionWidget::getAutoScaleState()
{
int state = this->ui.autoColorScaleCheckBox->isChecked();
if (Qt::Checked == state)
{
state -= 1;
}
return static_cast<bool>(state);
}

/**
* This function returns the state of the logarithmic color scaling.
* Since a checkbox is used, the checked state is actually 2, so it needs
* to be decremented to cast to a boolean.
* @return the state of logarithmic color scaling
*/
bool ColorSelectionWidget::getLogScaleState()
{
int state = this->ui.useLogScaleCheckBox->isChecked();
if (Qt::Checked == state)
{
state -= 1;
}
return static_cast<bool>(state);
}

/**
* This function returns the minimum range value for the color scaling.
* @return current minimum color scaling value
*/
double ColorSelectionWidget::getMinRange()
{
return this->ui.minValLineEdit->text().toDouble();
}

/**
* This function returns the maximum range value for the color scaling.
* @return current maximum color scaling value
*/
double ColorSelectionWidget::getMaxRange()
{
return this->ui.maxValLineEdit->text().toDouble();
}

/**
* This function returns the color selection widget to its original state.
* This means that automatic color scaling is on, log scaling is off and
* the color range line edits are empty.
*/
void ColorSelectionWidget::reset()
{
this->ui.autoColorScaleCheckBox->setChecked(true);
this->ui.useLogScaleCheckBox->setChecked(false);
this->ui.minValLineEdit->setText("");
this->ui.maxValLineEdit->setText("");
}

} // SimpleGui
} // Vates
} // Mantid
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MantidVatesSimpleGuiViewWidgets/ColorUpdater.h"
#include "MantidVatesSimpleGuiViewWidgets/ColorSelectionWidget.h"

#include <pqChartValue.h>
#include <pqColorMapModel.h>
Expand All @@ -10,14 +11,20 @@
#include <QColor>
#include <QList>

#include <limits>

namespace Mantid
{
namespace Vates
{
namespace SimpleGui
{

ColorUpdater::ColorUpdater()
ColorUpdater::ColorUpdater() :
autoScaleState(true),
logScaleState(false),
minScale(std::numeric_limits<double>::min()),
maxScale(std::numeric_limits<double>::max())
{
}

Expand Down Expand Up @@ -89,6 +96,63 @@ void ColorUpdater::logScale(pqPipelineRepresentation *repr, int state)
lut->getProxy()->UpdateVTKObjects();
}

/**
* This function takes information from the color selection widget and
* sets it into the internal state variables.
* @param cs : Reference to the color selection widget
*/
void ColorUpdater::updateState(ColorSelectionWidget *cs)
{
this->autoScaleState = cs->getAutoScaleState();
this->logScaleState = cs->getLogScaleState();
this->minScale = cs->getMinRange();
this->maxScale = cs->getMaxRange();
}

/**
* @return the current auto scaling state
*/
bool ColorUpdater::isAutoScale()
{
return this->autoScaleState;
}

/**
* @return the current logarithmic scaling state
*/
bool ColorUpdater::isLogScale()
{
return this->logScaleState;
}

/**
* @return the current maximum range for the color scaling
*/
double ColorUpdater::getMaximumRange()
{
return this->maxScale;
}

/**
* @return the current minimum range for the color scaling
*/
double ColorUpdater::getMinimumRange()
{
return this->minScale;
}

/**
* This function prints out the values of the current state of the
* color updater.
*/
void ColorUpdater::print()
{
std::cout << "Auto Scale: " << this->autoScaleState << std::endl;
std::cout << "Log Scale: " << this->logScaleState << std::endl;
std::cout << "Min Range: " << this->minScale << std::endl;
std::cout << "Max Range: " << this->maxScale << std::endl;
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void MdViewerWidget::internalSetup(bool pMode)
this->pluginMode = pMode;
this->rotPointDialog = NULL;
this->lodThreshold = 5.0;
this->viewSwitched = false;
}

/**
Expand Down Expand Up @@ -364,6 +365,11 @@ void MdViewerWidget::setParaViewComponentsForView()
SIGNAL(applied()),
this, SLOT(checkForUpdates()));

QObject::connect(this->currentView,
SIGNAL(renderingDone()),
this,
SLOT(renderingDone()));

SplatterPlotView *spv = dynamic_cast<SplatterPlotView *>(this->currentView);
if (spv)
{
Expand Down Expand Up @@ -416,6 +422,20 @@ void MdViewerWidget::onDataLoaded(pqPipelineSource* source)
this->renderAndFinalSetup();
}

/**
* This function is responsible for carrying out actions when ParaView
* says the rendering is completed. It currently handles making sure the
* color selection widget state is passed between views.
*/
void MdViewerWidget::renderingDone()
{
if (this->viewSwitched)
{
this->viewSwitched = false;
this->currentView->setColorsForView();
}
}

/**
* This function determines the type of source plugin and sets the workspace
* name so that the data can be retrieved and rendered.
Expand Down Expand Up @@ -450,6 +470,7 @@ void MdViewerWidget::renderWorkspace(QString wsname, int wstype)
void MdViewerWidget::renderAndFinalSetup()
{
this->currentView->render();
this->currentView->setColorsForView();
this->currentView->checkView();
this->currentView->setTimeSteps();
}
Expand Down Expand Up @@ -500,10 +521,12 @@ void MdViewerWidget::checkForUpdates()
*/
void MdViewerWidget::switchViews(ModeControlWidget::Views v)
{
this->viewSwitched = true;
this->currentView->closeSubWindows();
this->disconnectDialogs();
this->removeProxyTabWidgetConnections();
this->hiddenView = this->setMainViewWidget(this->ui.viewWidget, v);
this->hiddenView->setColorScaleState(this->ui.colorSelectionWidget);
this->hiddenView->hide();
this->viewLayout->removeWidget(this->currentView);
this->swapViews();
Expand All @@ -517,8 +540,8 @@ void MdViewerWidget::switchViews(ModeControlWidget::Views v)
this->hiddenView->destroyView();
delete this->hiddenView;
this->currentView->render();
this->currentView->setColorsForView();
this->currentView->checkViewOnSwitch();
this->currentView->correctVisibility();
this->updateAppState();
}

Expand Down Expand Up @@ -552,6 +575,8 @@ bool MdViewerWidget::eventFilter(QObject *obj, QEvent *ev)
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
builder->destroySources();
this->ui.modeControlWidget->setToStandardView();
this->ui.colorSelectionWidget->reset();
this->currentView->setColorScaleState(this->ui.colorSelectionWidget);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ void MultiSliceView::render()
this->checkSliceViewCompat();
this->setupData();
this->resetDisplay();
this->onAutoScale();
}

void MultiSliceView::renderAll()
Expand Down

0 comments on commit 6796b1d

Please sign in to comment.