Skip to content
Snippets Groups Projects
Commit ac19dee9 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

New IntensityDataFFTPresenter introduced

parent 6f127602
Branches
Tags
No related merge requests found
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
#include "SavePlotAssistant.h" #include "SavePlotAssistant.h"
#include "projectmanager.h" #include "projectmanager.h"
#include "ComboProperty.h" #include "ComboProperty.h"
#include "IntensityDataFFTPresenter.h"
#include <QAction> #include <QAction>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMouseEvent> #include <QMouseEvent>
#include <QSettings> #include <QSettings>
#include "IntensityDataFunctions.h"
namespace { namespace {
...@@ -99,20 +99,13 @@ void IntensityDataCanvas::onMousePress(QMouseEvent* event) ...@@ -99,20 +99,13 @@ void IntensityDataCanvas::onMousePress(QMouseEvent* event)
void IntensityDataCanvas::onfftAction() void IntensityDataCanvas::onfftAction()
{ {
auto dataItem = intensityDataItem(); if(m_fftPresenter) {
// returning ColorMap to non-fft presentation
if(m_backup) m_colorMap->setItem(intensityDataItem());
{ m_fftPresenter.reset();
dataItem->setOutputData(m_backup.release()); } else {
} m_fftPresenter.reset(new IntensityDataFFTPresenter);
m_colorMap->setItem(m_fftPresenter->fftItem(intensityDataItem()));
else
{
m_backup.reset(new OutputData<double>);
m_backup->copyFrom(*dataItem->getOutputData());
dataItem->setOutputData(
(IntensityDataFunctions::createFFT(*dataItem->getOutputData())).release());
} }
} }
...@@ -126,6 +119,11 @@ void IntensityDataCanvas::subscribeToItem() ...@@ -126,6 +119,11 @@ void IntensityDataCanvas::subscribeToItem()
} }
void IntensityDataCanvas::unsubscribeFromItem()
{
m_fftPresenter.reset();
}
IntensityDataItem* IntensityDataCanvas::intensityDataItem() IntensityDataItem* IntensityDataCanvas::intensityDataItem()
{ {
IntensityDataItem* result = dynamic_cast<IntensityDataItem*>(currentItem()); IntensityDataItem* result = dynamic_cast<IntensityDataItem*>(currentItem());
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
class SessionItem; class SessionItem;
class IntensityDataItem; class IntensityDataItem;
class ColorMapCanvas; class ColorMapCanvas;
class IntensityDataFFTPresenter;
class QAction; class QAction;
//! The IntensityDataCanvas class represents IntensityDataItem as color map, //! The IntensityDataCanvas class represents IntensityDataItem as color map,
...@@ -48,7 +49,8 @@ public slots: ...@@ -48,7 +49,8 @@ public slots:
void onfftAction(); void onfftAction();
protected: protected:
virtual void subscribeToItem(); void subscribeToItem();
void unsubscribeFromItem();
private: private:
IntensityDataItem* intensityDataItem(); IntensityDataItem* intensityDataItem();
...@@ -61,7 +63,7 @@ private: ...@@ -61,7 +63,7 @@ private:
QAction* m_savePlotAction; QAction* m_savePlotAction;
QAction* m_fftAction; QAction* m_fftAction;
std::unique_ptr<OutputData<double>> m_backup; std::unique_ptr<IntensityDataFFTPresenter> m_fftPresenter;
}; };
......
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h
//! @brief Defines class IntensityDataFFTPresenter
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************** //
#include "IntensityDataFFTPresenter.h"
#include "IntensityDataFunctions.h"
#include "IntensityDataItem.h"
#include "SessionModel.h"
#include "GUIHelpers.h"
#include <QWidget>
IntensityDataFFTPresenter::IntensityDataFFTPresenter(QWidget* parent)
: QObject(parent)
, m_fftModel(new SessionModel("TempFFTModel"))
, m_fftItem(nullptr)
{
m_fftItem
= dynamic_cast<IntensityDataItem*>(m_fftModel->insertNewItem(Constants::IntensityDataType));
}
IntensityDataItem* IntensityDataFFTPresenter::fftItem(IntensityDataItem* origItem)
{
if (!origItem)
throw GUIHelpers::Error("IntensityDataFFTPresenter::fftItem() -> Error. Empty item.");
m_fftItem->setOutputData(
IntensityDataFunctions::createFFT(*origItem->getOutputData()).release());
return m_fftItem;
}
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file GUI/coregui/Views/IntensityDataWidgets/IntensityDataFFTPresenter.h
//! @brief Defines class IntensityDataFFTPresenter
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************** //
#ifndef INTENSITYDATAFFTPRESENTER_H
#define INTENSITYDATAFFTPRESENTER_H
#include "WinDllMacros.h"
#include <QObject>
class SessionModel;
class IntensityDataItem;
class QWidget;
//! Provides support in Fast Fourier transformation of IntensityDataItem.
//! Contains own model to hold IntensityDataItem with fft-transformed results.
class BA_CORE_API_ IntensityDataFFTPresenter : public QObject {
Q_OBJECT
public:
IntensityDataFFTPresenter(QWidget* parent = nullptr);
IntensityDataItem* fftItem(IntensityDataItem* origItem);
private:
SessionModel *m_fftModel;
IntensityDataItem* m_fftItem;
};
#endif // INTENSITYDATAFFTPRESENTER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment