Commit ab75950d authored by Locatelli's avatar Locatelli
Browse files

Add Cut window

parent df508282
icons/cut.png

175 Bytes

......@@ -37,6 +37,11 @@ struct RectangleCoord {
Point2DCoord p1;
};
struct LineCoord {
Point2DCoord p0;
Point2DCoord p1;
};
struct RoiRectangle {
RectangleCoord rect;
float64 sum;
......
......@@ -33,7 +33,9 @@ PLOT = \
plot/Plot1D.cpp \
plot/Plot2D.cpp \
plot/PlotHisto.cpp \
plot/PlotWindow.cpp \
plot/window/CutPlotWindow.cpp \
plot/window/PlotWindow.cpp \
plot/window/PropertyPlotWindow.cpp \
plot/offscreen/OffScreenEmptyPlot.cpp \
plot/offscreen/OffScreenPlot.cpp \
plot/offscreen/OffScreenPlot1D.cpp \
......@@ -41,7 +43,8 @@ PLOT = \
plot/property/PropertyEmptyPlot.cpp \
plot/property/PropertyPlot.cpp \
plot/property/PropertyPlot1D.cpp \
plot/property/PropertyPlot2D.cpp
plot/property/PropertyPlot2D.cpp \
plot/cut/CutPlot1D.cpp
PROTOBUF = \
protobuf/generated/AnalysisRequests.pb.cc \
......@@ -53,11 +56,13 @@ PROTOBUF = \
DATACONT = \
datacontainer/PlotDataContainer.cpp \
datacontainer/CutPlotDataContainer.cpp \
datacontainer/PropertyPlotDataContainer.cpp \
datacontainer/UpdateContainer.cpp
MPLCPP = \
view/mpl/Mpl.cpp \
view/mpl/MplCut.cpp \
view/mpl/MplLock.cpp \
view/mpl/MplFigure.cpp \
view/mpl/MplPlot1D.cpp \
......@@ -66,6 +71,7 @@ MPLCPP = \
view/mpl/MplStatistics.cpp \
view/mpl/widgets/MplCursor.cpp \
view/mpl/widgets/MplLegend.cpp \
view/mpl/widgets/MplLineSelector.cpp \
view/mpl/widgets/MplRectangleSelector.cpp
JSON = \
......@@ -75,6 +81,7 @@ JSON = \
ploty2_SOURCES = \
main.cpp \
PlotId.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
......@@ -100,6 +107,7 @@ ploty2_LDADD = $(LIBS) $(RM_LIBS) \
mplplot_SOURCES = \
mainplot.cpp \
PlotId.cpp \
manager/AnalysisRequesterManager.cpp \
manager/ServerRequesterManager.cpp \
manager/ServerSubscriberManager.cpp \
......@@ -120,6 +128,7 @@ mplplot_LDADD = $(LIBS) $(RM_LIBS) \
offscreenplot_SOURCES = \
mainoffscreenplot.cpp \
PlotId.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
......@@ -145,6 +154,7 @@ offscreenplot_LDADD = $(LIBS) $(RM_LIBS) \
test_SOURCES = \
maintest.cpp \
PlotId.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
......@@ -169,6 +179,7 @@ test_LDADD = $(LIBS) $(RM_LIBS) \
test2_SOURCES = \
maintest2.cpp \
PlotId.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
......
This diff is collapsed.
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "PlotId.h"
uint32 PlotId::id = 1;
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PLOTID_H
#define PLOTID_H
#include <common/base/BaseTypes.h>
class PlotId {
public:
static uint32 id;
};
#endif // PLOTID_H
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "CutPlotDataContainer.h"
#include "PropertyPlotDataContainer.h"
#include "plot/PlotType.h"
#include "Trace.h"
using namespace std;
namespace datacontainer {
/*
* constructor
*/
CutPlotDataContainer::CutPlotDataContainer(const datacontainer::PropertyPlotDataContainer& plotMessage) {
plotKey = plotMessage.plotKey;
for (string key : plotMessage.keys) {
keys.push_back(key);
}
for (string key : plotMessage.legendKeys) {
legendKeys.push_back(key);
}
for (string color : plotMessage.colors) {
colors.push_back(color);
}
windowTitle = plotMessage.windowTitle;
plotTitle = plotMessage.plotTitle;
}
/*
* destructor
*/
CutPlotDataContainer::~CutPlotDataContainer() {
}
/*
* getPlotType
*/
plot::PlotType CutPlotDataContainer::getPlotType() {
return plot::PLOT_1D;
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CUTPLOTDATACONTAINER_H
#define CUTPLOTDATACONTAINER_H
#include <map>
#include "datacontainer/PlotDataContainer.h"
/*!
* \brief Class container of cut plot data info
*/
namespace datacontainer {
class PropertyPlotDataContainer;
class CutPlotDataContainer: public PlotDataContainer {
public:
/*!
* \brief constructor
* \param[in] propertyContainer The property plot data container for constructing this one
*/
CutPlotDataContainer(const datacontainer::PropertyPlotDataContainer& propertyContainer);
/*!
* \brief destructor
*/
virtual ~CutPlotDataContainer();
/*!
* \brief get plot type of this container
* \return Plot type
*/
virtual plot::PlotType getPlotType();
};
}
#endif //CUTPLOTDATACONTAINER_H
......@@ -43,6 +43,7 @@ public:
*/
virtual ~PlotDataContainer();
std::string plotKey; //! Plot key
std::vector<std::string> keys; //! keys of data
std::vector<std::string> legendKeys; //! keys of legend
std::vector<std::string> colors; //! colors string of data
......
......@@ -28,6 +28,13 @@ using namespace manager;
namespace datacontainer {
/*
* constructor
*/
PropertyPlotDataContainer::PropertyPlotDataContainer() {
}
/*
* constructor
*/
......
......@@ -40,13 +40,17 @@ public:
* \param[in] plotMessage The plot message container for constructing this one
*/
PropertyPlotDataContainer(const ploty::PlotPropertyDataMessage& plotMessage);
/*!
* \brief default constructor
*/
PropertyPlotDataContainer();
/*!
* \brief destructor
*/
virtual ~PropertyPlotDataContainer();
std::string plotKey; //! Plot key
std::vector<int32> dataXIds; //! Property Ids of data x
std::vector<int32> dataYIds; //! Property Ids of data y
std::vector<int32> dataZIds; //! Property Ids of data z
......
......@@ -33,6 +33,7 @@
#include "view/mpl/MplFigure.h"
#include "Trace.h"
#include "Error.h"
#include "PlotId.h"
#include "plot/offscreen/OffScreenEmptyPlot.h"
#include "plot/offscreen/OffScreenPlot1D.h"
#include "plot/offscreen/OffScreenPlot2D.h"
......@@ -41,7 +42,6 @@
using namespace std;
using namespace cameo;
/*!
* \brief crash handler method
* \param[in] sig the signal number which calling this method
......@@ -105,7 +105,7 @@ int32 main(int32 argc, char* argv[]) {
// 2D
for (int32 i = 0; i < data.xdata_size(); ++i) {
try {
plot::offscreen::OffScreenPlot2D plot(*figure, plotkey.str(), *mpl.get(), data);
plot::offscreen::OffScreenPlot2D plot(PlotId::id, *figure, plotkey.str(), *mpl.get(), data);
plot.display();
plot.save(pbfile.parent_path().parent_path().string(), dpi, pad);
} catch (Error& e) {
......@@ -116,7 +116,7 @@ int32 main(int32 argc, char* argv[]) {
// 1D
for (int32 i = 0; i < data.xdata_size(); ++i) {
try {
plot::offscreen::OffScreenPlot1D plot(*figure, plotkey.str(), *mpl.get(), data);
plot::offscreen::OffScreenPlot1D plot(PlotId::id, *figure, plotkey.str(), *mpl.get(), data);
plot.display();
plot.save(pbfile.parent_path().parent_path().string(), dpi, pad);
} catch (Error& e) {
......@@ -125,7 +125,7 @@ int32 main(int32 argc, char* argv[]) {
}
} else {
try {
plot::offscreen::OffScreenEmptyPlot plot(*figure, plotkey.str(), *mpl.get(), data);
plot::offscreen::OffScreenEmptyPlot plot(PlotId::id ,*figure, plotkey.str(), *mpl.get(), data);
plot.display();
plot.save(pbfile.parent_path().parent_path().string(), dpi, pad);
} catch (Error& e) {
......
......@@ -29,13 +29,12 @@
#include "Common.h"
#include "protobuf/generated/DataPlotMessages.pb.h"
#include "plot/PlotWindow.h"
#include "Trace.h"
#include "Error.h"
#include "PlotId.h"
#include "tests/Test.h"
#include "view/mpl/Mpl.h"
#include "view/mpl/MplLock.h"
//#include "view/mpl/MplRoi.h"
#include <QApplication>
#include "manager/RequestDealerManager.h"
......@@ -45,6 +44,7 @@
#include "view/qt/QtUpdateThread.h"
#include "manager/mpl/MplEventManager.h"
#include "manager/ServerSubscriberManager.h"
#include "plot/window/PropertyPlotWindow.h"
using namespace std;
using namespace cameo;
......@@ -53,8 +53,7 @@ using namespace plot;
unique_ptr<application::Instance> nomadserver; //! Instance of nomad server
shared_ptr<application::Subscriber> datachangesubscriber; //! Subcriber on data change publisher of the server
shared_ptr<QApplication> app;
unique_ptr<PlotWindow> window;
unique_ptr<window::PropertyPlotWindow> plotwindow;
/*!
* \brief crash handler method
......@@ -73,8 +72,8 @@ void crash_handler(int32 sig) {
*/
void us1_signal(int32 sig) {
DBGMSG("receive us1_signal : " << sig);
if (window.get() != nullptr) {
window->activateWindow();
if (plotwindow.get() != nullptr) {
plotwindow->activateWindow();
}
}
......@@ -192,19 +191,17 @@ int32 main(int32 argc, char* argv[]) {
DBGMSG("plotMessage.datay_ids_size() = " << plotMessage.datay_ids_size());
DBGMSG("plotMessage.dataz_ids_size() = " << plotMessage.dataz_ids_size());
window = make_unique<PlotWindow>(mpl, plotMessage);
plotwindow = make_unique<window::PropertyPlotWindow>(PlotId::id++, mpl, plotMessage);
try {
window->create(*app, datachangesubscriber);
window->display();
window->show();
plotwindow->create(*app, datachangesubscriber);
plotwindow->display();
plotwindow->show();
}
catch (Error& e) {
err = EXIT_FAILURE;
}
DBGMSG("app::exec");
app->exec();
DBGMSG("window::reset");
window.reset();
plotwindow.reset();
}
}
else {
......@@ -227,6 +224,7 @@ int32 main(int32 argc, char* argv[]) {
datachangesubscriber->cancel();
requesterdb.reset();
requesteranalysis.reset();
}
......
......@@ -17,67 +17,72 @@
*/
#include "InterfaceManager.h"
#include "plot/window/PlotWindow.h"
#include "plot/window/PropertyPlotWindow.h"
#include "plot/window/CutPlotWindow.h"
#include "plot/Plot2D.h"
#include "plot/property/PropertyPlot.h"
#include "plot/property/PropertyPlot2D.h"
#include "datacontainer/PropertyPlotDataContainer.h"
#include "datacontainer/CutPlotDataContainer.h"
#include "view/qt/QtWindow.h"
#include "plot/PlotWindow.h"
#include "Trace.h"
#include "Error.h"
#include "PlotId.h"
using namespace std;
namespace manager {
InterfaceManager* InterfaceManager::m_Instance = nullptr;
map<uint32, InterfaceManager*> InterfaceManager::m_Instances;
/*
* constructor
*/
InterfaceManager::InterfaceManager() {
m_QtWindow = nullptr;
m_PlotWindow = nullptr;
m_PropertyPlot = nullptr;
m_Plot = nullptr;
}
/*
* resetInstance
*/
void InterfaceManager::resetInstance() {
if (m_Instance != nullptr) {
delete m_Instance;
m_Instance = nullptr;
}
void InterfaceManager::resetInstance(uint32 id) {
delete m_Instances[id];
m_Instances.erase(id);
}
/*
* getInstance
*/
InterfaceManager* InterfaceManager::getInstance() {
if (m_Instance == nullptr) {
m_Instance = new InterfaceManager();
InterfaceManager* InterfaceManager::getInstance(uint32 id) {
if (m_Instances[id] == nullptr) {
m_Instances[id] = new InterfaceManager();
}
return m_Instance;
return m_Instances[id];
}
/*
* init
*/
void InterfaceManager::init(plot::PlotWindow* plotWindow) {
void InterfaceManager::init(plot::window::PlotWindow* plotWindow) {
m_PlotWindow = plotWindow;
}
/*
* init
*/
void InterfaceManager::init(view::qt::QtWindow* qtWindow) {
m_QtWindow = qtWindow;
void InterfaceManager::init(plot::property::PropertyPlot* propertyplot) {
m_PropertyPlot = propertyplot;
}
/*
* init
*/
void InterfaceManager::init(plot::property::PropertyPlot* propertyplot) {
m_PropertyPlot = propertyplot;
void InterfaceManager::init(plot::Plot* plot) {
m_Plot = plot;
}
/*
......@@ -150,11 +155,48 @@ void InterfaceManager::colorLimits(float64 min, float64 max) throw (Error) {
m_PlotWindow->colorLimits(min, max);
}
/*
* getPlotKey
*/
const std::string InterfaceManager::getPlotKey() const {
string plotkey;
plot::window::PropertyPlotWindow* pwindow = dynamic_cast<plot::window::PropertyPlotWindow*>(m_PlotWindow);
if (pwindow != nullptr) {
plotkey = pwindow->getPropertyPlotDataContainer().plotKey;
}
else {
plot::window::CutPlotWindow* cwindow = dynamic_cast<plot::window::CutPlotWindow*>(m_PlotWindow);
if (cwindow != nullptr) {
plotkey = cwindow->getCutPlotDataContainer().plotKey;
}
}
return plotkey;
}
/*
* isPropertyPlot
*/
bool InterfaceManager::isPropertyPlot() const {
plot::window::PropertyPlotWindow* pwindow = dynamic_cast<plot::window::PropertyPlotWindow*>(m_PlotWindow);
if (pwindow != nullptr) {
return true;
}
else {
return false;
}
}
/*
* getPropertyPlotDataContainer
*/
datacontainer::PropertyPlotDataContainer& InterfaceManager::getPropertyPlotDataContainer() {
return m_PlotWindow->getPropertyPlotDataContainer();
const datacontainer::PropertyPlotDataContainer& InterfaceManager::getPropertyPlotDataContainer() {
plot::window::PropertyPlotWindow* pwindow = dynamic_cast<plot::window::PropertyPlotWindow*>(m_PlotWindow);
if (pwindow != nullptr) {
return pwindow->getPropertyPlotDataContainer();
}
else {
return datacontainer::PropertyPlotDataContainer();
}
}
/*
......@@ -175,8 +217,8 @@ void InterfaceManager::checkLegendPick(const Point2DCoord& point) throw (Error)
* allowRoiFunctionnalities
*/
void InterfaceManager::allowRoiFunctionnalities() {
if (m_QtWindow) {
m_QtWindow->allowRoiFunctionnalities();
if (m_PlotWindow->getQtWindow()) {
m_PlotWindow->getQtWindow()->allowRoiFunctionnalities();
}
}
......@@ -229,8 +271,8 @@ void InterfaceManager::deleteRoi(uint32 id) throw (Error) {
* showRoiCoord
*/
void InterfaceManager::showRoiCoord(uint32 id, const RectangleCoord& rect) {
if (m_QtWindow) {
m_QtWindow->showRoiCoord(id, rect);
if (m_PlotWindow->getQtWindow()) {
m_PlotWindow->getQtWindow()->showRoiCoord(id, rect);
}
}
......@@ -238,8 +280,8 @@ void InterfaceManager::showRoiCoord(uint32 id, const RectangleCoord& rect) {
* updateRoi
*/
void InterfaceManager::updateRoi(const std::vector<RoiRectangle>& rects) {
if (m_QtWindow) {
m_QtWindow->updateRoi(rects);
if (m_PlotWindow->getQtWindow()) {
m_PlotWindow->getQtWindow()->updateRoi(rects);
}
}
......@@ -247,8 +289,8 @@ void InterfaceManager::updateRoi(const std::vector<RoiRectangle>& rects) {
* updateRoi
*/
void InterfaceManager::updateRoi(int32 n, const RectangleCoord& rect) {
if (m_QtWindow) {
m_QtWindow->updateRoi(n ,rect);
if (m_PlotWindow->getQtWindow()) {
m_PlotWindow->getQtWindow()->updateRoi(n ,rect);
}
}
......@@ -256,8 +298,8 @@ void InterfaceManager::updateRoi(int32 n, const RectangleCoord& rect) {
* updateSum
*/
void InterfaceManager::updateRoiSum(uint32 id, float64 sum) {
if (m_QtWindow) {
m_QtWindow->updateRoiSum(id, sum);
if (m_PlotWindow->getQtWindow()) {
m_PlotWindow->getQtWindow()->updateRoiSum(id, sum);
}
}
......@@ -265,8 +307,8 @@ void InterfaceManager::updateRoiSum(uint32 id, float64 sum) {
* statistic
*/
void InterfaceManager::statistic(const std::string& color) throw (Error) {
if (m_PropertyPlot) {
m_PropertyPlot->statistic(color);
if (m_Plot) {
m_Plot->statistic(color);
}