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

New IntensityDataFFTPresenter introduced

parent 6f127602
No related branches found
No related tags found
No related merge requests found
......@@ -20,11 +20,11 @@
#include "SavePlotAssistant.h"
#include "projectmanager.h"
#include "ComboProperty.h"
#include "IntensityDataFFTPresenter.h"
#include <QAction>
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QSettings>
#include "IntensityDataFunctions.h"
namespace {
......@@ -99,20 +99,13 @@ void IntensityDataCanvas::onMousePress(QMouseEvent* event)
void IntensityDataCanvas::onfftAction()
{
auto dataItem = intensityDataItem();
if(m_backup)
{
dataItem->setOutputData(m_backup.release());
}
else
{
m_backup.reset(new OutputData<double>);
m_backup->copyFrom(*dataItem->getOutputData());
dataItem->setOutputData(
(IntensityDataFunctions::createFFT(*dataItem->getOutputData())).release());
if(m_fftPresenter) {
// returning ColorMap to non-fft presentation
m_colorMap->setItem(intensityDataItem());
m_fftPresenter.reset();
} else {
m_fftPresenter.reset(new IntensityDataFFTPresenter);
m_colorMap->setItem(m_fftPresenter->fftItem(intensityDataItem()));
}
}
......@@ -126,6 +119,11 @@ void IntensityDataCanvas::subscribeToItem()
}
void IntensityDataCanvas::unsubscribeFromItem()
{
m_fftPresenter.reset();
}
IntensityDataItem* IntensityDataCanvas::intensityDataItem()
{
IntensityDataItem* result = dynamic_cast<IntensityDataItem*>(currentItem());
......
......@@ -22,6 +22,7 @@
class SessionItem;
class IntensityDataItem;
class ColorMapCanvas;
class IntensityDataFFTPresenter;
class QAction;
//! The IntensityDataCanvas class represents IntensityDataItem as color map,
......@@ -48,7 +49,8 @@ public slots:
void onfftAction();
protected:
virtual void subscribeToItem();
void subscribeToItem();
void unsubscribeFromItem();
private:
IntensityDataItem* intensityDataItem();
......@@ -61,7 +63,7 @@ private:
QAction* m_savePlotAction;
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.
Finish editing this message first!
Please register or to comment