Commit 51c45793 authored by Locatelli's avatar Locatelli
Browse files

Integrate Rois

parent 81a8157e
......@@ -69,10 +69,12 @@ JSON = \
ploty2_SOURCES = \
main.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
manager/ServerRequesterManager.cpp \
manager/PlotManager.cpp \
manager/InterfaceManager.cpp \
manager/OffScreenPlotManager.cpp \
manager/mpl/MplEventManager.cpp \
$(PLOT) \
......@@ -93,6 +95,7 @@ mplplot_SOURCES = \
mainplot.cpp \
manager/ServerRequesterManager.cpp \
manager/ServerSubscriberManager.cpp \
manager/InterfaceManager.cpp \
manager/mpl/MplEventManager.cpp \
$(PLOT) \
$(PROTOBUF) \
......@@ -109,9 +112,11 @@ mplplot_LDADD = $(LIBS) $(RM_LIBS) \
test_SOURCES = \
maintest.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
manager/ServerRequesterManager.cpp \
manager/InterfaceManager.cpp \
manager/PlotManager.cpp \
manager/OffScreenPlotManager.cpp \
manager/mpl/MplEventManager.cpp \
......@@ -131,8 +136,10 @@ test_LDADD = $(LIBS) $(RM_LIBS) \
test2_SOURCES = \
maintest2.cpp \
manager/ThreadPoolManager.cpp \
manager/RequestDealerManager.cpp \
manager/ServerSubscriberManager.cpp \
manager/InterfaceManager.cpp \
manager/ServerRequesterManager.cpp \
manager/PlotManager.cpp \
manager/OffScreenPlotManager.cpp \
......
This diff is collapsed.
......@@ -17,7 +17,7 @@
*/
#include "PropertyPlotDataContainer.h"
#include <sstream>
#include "manager/ServerRequesterManager.h"
#include "protobuf/generated/DataPlotMessages.pb.h"
#include "plot/PlotType.h"
......@@ -130,6 +130,74 @@ PropertyPlotDataContainer::PropertyPlotDataContainer(const proto::PlotPropertyDa
optimizationFitColor.push_back(color);
}
nbRoisId = plotMessage.nbrois_id();
DBGMSG("x0_parent_id " << plotMessage.x0_parent_id().size());
DBGMSG("y0_parent_id " << plotMessage.y0_parent_id().size());
DBGMSG("x1_parent_id " << plotMessage.x1_parent_id().size());
DBGMSG("y1_parent_id " << plotMessage.y1_parent_id().size());
DBGMSG("sum_parent_id " << plotMessage.sum_parent_id().size());
for (auto id : plotMessage.x0_parent_id()) {
roiX0_parent_ids.push_back(id);
}
for (auto id : plotMessage.y0_parent_id()) {
roiY0_parent_ids.push_back(id);
}
for (auto id : plotMessage.x1_parent_id()) {
roiX1_parent_ids.push_back(id);
}
for (auto id : plotMessage.y1_parent_id()) {
roiY1_parent_ids.push_back(id);
}
for (auto id : plotMessage.sum_parent_id()) {
roiSum_parent_ids.push_back(id);
}
if (nbRoisId > 0) {
int32 nbrois = ServerRequesterManager::getInstance()->getInt32PropertyValue(nbRoisId);
for (uint32 i = 0; i < roiX0_parent_ids.size(); ++i) {
roiX0_ids.push_back(ServerRequesterManager::getInstance()->getDynamicPropertyIds(roiX0_parent_ids[i]));
roiY0_ids.push_back(ServerRequesterManager::getInstance()->getDynamicPropertyIds(roiY0_parent_ids[i]));
roiX1_ids.push_back(ServerRequesterManager::getInstance()->getDynamicPropertyIds(roiX1_parent_ids[i]));
roiY1_ids.push_back(ServerRequesterManager::getInstance()->getDynamicPropertyIds(roiY1_parent_ids[i]));
roiSum_ids.push_back(ServerRequesterManager::getInstance()->getDynamicPropertyIds(roiSum_parent_ids[i]));
}
}
for(auto vect : roiX0_ids) {
for(auto id : vect) {
DBGMSG("roiX0_id " << id);
}
}
for(auto vect : roiY0_ids) {
for(auto id : vect) {
DBGMSG("roiY0_id " << id);
}
}
for(auto vect : roiX1_ids) {
for(auto id : vect) {
DBGMSG("roiX1_id " << id);
}
}
for(auto vect : roiY1_ids) {
for(auto id : vect) {
DBGMSG("roiY1_id " << id);
}
}
for(auto vect : roiSum_ids) {
for(auto id : vect) {
DBGMSG("roiSum_id " << id);
}
}
roiSelectedPlotId = plotMessage.selectedplot_id();
roiSelectedRoiId = plotMessage.selectedroi_id();
roiSelectedX0Id = plotMessage.selectedx0_id();
roiSelectedY0Id = plotMessage.selectedy0_id();
roiSelectedX1Id = plotMessage.selectedx1_id();
roiSelectedY1Id = plotMessage.selectedy1_id();
roiCommandAddId = plotMessage.commandroiadd_id();
roiCommandRazId = plotMessage.commandroiraz_id();
hasx = false;
hasy = false;
hasz = false;
......
......@@ -74,6 +74,25 @@ public:
std::vector<int32> optimizationFitFoundId; //! Property id list for optimization fit found
std::vector<int32> optimizationFitYId; //! Property id list for optimization fit y values found
std::vector<std::string> optimizationFitColor; //! Color of optimization fit
int32 nbRoisId;
std::vector<int32> roiX0_parent_ids;
std::vector<int32> roiY0_parent_ids;
std::vector<int32> roiX1_parent_ids;
std::vector<int32> roiY1_parent_ids;
std::vector<int32> roiSum_parent_ids;
std::vector<std::vector<int32>> roiX0_ids;
std::vector<std::vector<int32>> roiY0_ids;
std::vector<std::vector<int32>> roiX1_ids;
std::vector<std::vector<int32>> roiY1_ids;
std::vector<std::vector<int32>> roiSum_ids;
int32 roiSelectedPlotId;
int32 roiSelectedRoiId;
int32 roiSelectedX0Id;
int32 roiSelectedY0Id;
int32 roiSelectedX1Id;
int32 roiSelectedY1Id;
int32 roiCommandAddId;
int32 roiCommandRazId;
bool hasx; //! Flag tells if there is x data (run getPlotType() before)
bool hasy; //! Flag tells if there is y data (run getPlotType() before)
......
......@@ -26,7 +26,6 @@
#include "Common.h"
#include "manager/OffScreenPlotManager.h"
#include "manager/PlotManager.h"
#include "Trace.h"
#include "Error.h"
#include "manager/RequestDealerManager.h"
......@@ -128,8 +127,8 @@ int main(int32 argc, char* argv[]) {
serverLogSubscriberThread.join();
// Reset manager
manager::RequestDealerManager::resetInstance();
OffScreenPlotManager::resetInstance();
PlotManager::resetInstance();
manager::ServerRequesterManager::resetInstance();
}
......
......@@ -43,6 +43,7 @@
#include "view/qt/QtUpdateContainer.h"
#include "view/qt/QtUpdateThread.h"
#include "manager/mpl/MplEventManager.h"
#include "manager/ServerSubscriberManager.h"
using namespace std;
using namespace cameo;
......@@ -187,7 +188,9 @@ int32 main(int32 argc, char* argv[]) {
catch (Error& e) {
err = EXIT_FAILURE;
}
DBGMSG("app::exec");
app->exec();
DBGMSG("window::reset");
window.reset();
}
}
......@@ -201,13 +204,13 @@ int32 main(int32 argc, char* argv[]) {
err = EXIT_FAILURE;
}
DBGMSG("ServerRequester::resetInstance");
// Clean manager
manager::ServerRequesterManager::resetInstance();
DBGMSG("datachangesubscriber->cancel");
// Cancel subscriber
datachangesubscriber->cancel();
requesterdb.reset();
}
exit:
......@@ -217,7 +220,7 @@ exit:
datachangesubscriber.reset();
mpl.reset();
nomadserver.reset();
datachangesubscriber.reset();
// Terminate cameo application
application::This::terminate();
return err;
......
/*
* 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 "InterfaceManager.h"
#include "plot/property/PropertyPlot.h"
#include "view/qt/QtWindow.h"
#include "plot/PlotWindow.h"
#include "Trace.h"
#include "Error.h"
using namespace std;
namespace manager {
InterfaceManager* InterfaceManager::m_Instance = nullptr;
/*
* constructor
*/
InterfaceManager::InterfaceManager() {
m_QtWindow = nullptr;
m_PlotWindow = nullptr;
m_PropertyPlot = nullptr;
}
/*
* resetInstance
*/
void InterfaceManager::resetInstance() {
if (m_Instance != nullptr) {
delete m_Instance;
m_Instance = nullptr;
}
}
/*
* getInstance
*/
InterfaceManager* InterfaceManager::getInstance() {
if (m_Instance == nullptr) {
m_Instance = new InterfaceManager();
}
return m_Instance;
}
/*
* init
*/
void InterfaceManager::init(plot::PlotWindow* plotWindow) {
m_PlotWindow = plotWindow;
}
/*
* init
*/
void InterfaceManager::init(view::qt::QtWindow* qtWindow) {
m_QtWindow = qtWindow;
}
/*
* init
*/
void InterfaceManager::init(plot::property::PropertyPlot* propertyplot) {
m_PropertyPlot = propertyplot;
}
/*
* home
*/
void InterfaceManager::home() throw (Error) {
m_PlotWindow->home();
}
/*
* back
*/
void InterfaceManager::back() throw (Error) {
m_PlotWindow->back();
}
/*
* pan
*/
void InterfaceManager::pan(bool on) throw (Error) {
m_PlotWindow->pan(on);
}
/*
* zoom
*/
void InterfaceManager::zoom(bool on) throw (Error) {
m_PlotWindow->zoom(on);
}
/*
* grid
*/
void InterfaceManager::grid(bool on) throw (Error) {
m_PlotWindow->grid(on);
}
/*
* log
*/
void InterfaceManager::log(bool on) throw (Error) {
m_PlotWindow->log(on);
}
/*
* ratio
*/
void InterfaceManager::ratio(bool on) throw (Error) {
m_PlotWindow->ratio(on);
}
/*
* filesave
*/
void InterfaceManager::filesave() throw (Error) {
m_PlotWindow->filesave();
}
/*
* colorMap
*/
void InterfaceManager::colorMap(const string& name) throw (Error) {
m_PlotWindow->colorMap(name);
}
/*
* colorLimits
*/
void InterfaceManager::colorLimits(float64 min, float64 max) throw (Error) {
m_PlotWindow->colorLimits(min, max);
}
/*
* getPropertyPlotDataContainer
*/
datacontainer::PropertyPlotDataContainer& InterfaceManager::getPropertyPlotDataContainer() {
return m_PlotWindow->getPropertyPlotDataContainer();
}
/*
* toDataCoord
*/
vector<float64> InterfaceManager::toDataCoord(float64 x, float64 y, int32 devicePixelRatio) throw (Error) {
return m_PlotWindow->toDataCoord(x, y, devicePixelRatio);
}
/*
* checkLegendPick
*/
void InterfaceManager::checkLegendPick(float64 x, float64 y) throw (Error) {
m_PlotWindow->checkLegendPick(x , y);
}
/*
* allowRoiFunctionnalities
*/
void InterfaceManager::allowRoiFunctionnalities() {
if (m_QtWindow) {
m_QtWindow->allowRoiFunctionnalities();
}
}
/*
* newRoiStart
*/
void InterfaceManager::newRoiStart(uint32 id, const std::string& color) throw (Error) {
if (m_PropertyPlot) {
m_PropertyPlot->newRoiStart(id, color);
}
}
/*
* modifyRoiStart
*/
void InterfaceManager::modifyRoiStart(uint32 id, const std::string& color) throw (Error) {
if (m_PropertyPlot) {
m_PropertyPlot->modifyRoiStart(id, color);
}
}
/*
* modifyRoiEnd
*/
void InterfaceManager::modifyRoiEnd(uint32 id, const std::string& color) throw (Error) {
if (m_PropertyPlot) {
m_PropertyPlot->modifyRoiEnd(id, color);
}
}
/*
* deleteRoi
*/
void InterfaceManager::deleteRoi(uint32 id) throw (Error) {
if (m_PropertyPlot) {
m_PropertyPlot->deleteRoi(id);
}
}
/*
* showRoiCoord
*/
void InterfaceManager::showRoiCoord(uint32 id, float64 x0, float64 y0, float64 x1, float64 y1) {
if (m_QtWindow) {
m_QtWindow->showRoiCoord(id, x0, y0, x1, y1);
}
}
/*
* updateRoi
*/
void InterfaceManager::updateRoi(const std::vector<std::vector<float64>>& rects) {
if (m_QtWindow) {
m_QtWindow->updateRoi(rects);
}
}
/*
* updateRoi
*/
void InterfaceManager::updateRoi(int32 n, const std::vector<float64>& vect) {
if (m_QtWindow) {
m_QtWindow->updateRoi(n ,vect);
}
}
/*
* updateSum
*/
void InterfaceManager::updateSum(uint32 id, float64 sum) {
if (m_QtWindow) {
m_QtWindow->updateSum(id, sum);
}
}
}
/*
* 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 INTERFACEMANAGER_H
#define INTERFACEMANAGER_H
#include <common/base/BaseTypes.h>
#include <memory>
#include <vector>
#include <map>
#include "Error.h"
namespace plot {
class PlotWindow;
namespace property {
class PropertyPlot;
}
}
namespace view {
namespace qt {
class QtWindow;
}
}
namespace datacontainer {
class PropertyPlotDataContainer;
}
namespace manager {
class InterfaceManager {
public:
/*!
* \brief get singleton instance
* \return instance
*/
static InterfaceManager* getInstance();
/*!
* \brief reset instance
*/
static void resetInstance();
void init(plot::PlotWindow* plotWindow);
void init(view::qt::QtWindow* qtWindow);
void init(plot::property::PropertyPlot* propertyplot);
/*!
* \brief Reset zoom, go to original view
* \throws Error
*/
void home() throw (Error);
/*!
* \brief Back to previous zoom view
* \throws Error
*/
void back() throw (Error);
/*!
* \brief Toogle pan state (on or off)
* \param[in] on The state of pan
* \throws Error
*/
void pan(bool on) throw (Error);
/*!
* \brief Toogle zoom state (on or off)
* \param[in] on The state of zoom
* \throws Error
*/
void zoom(bool on) throw (Error);
/*!
* \brief Toogle grid state (on or off)
* \param[in] on The state of grid
* \throws Error
*/
void grid(bool on) throw (Error);
/*!
* \brief Toogle log state (on or off)
* \param[in] on The state of log
* \throws Error
*/
void log(bool on) throw (Error);
/*!
* \brief Toogle log ratio (on or off)
* \param[in] on The ratio of log
* \throws Error
*/
void ratio(bool on) throw (Error);
/*!
* \brief Image File save
* \throws Error
*/
void filesave() throw (Error);
/*!
* \brief set color map
* \param[in] name the label
* \throws Error
*/
void colorMap(const std::string& name) throw (Error);
/*!
* \brief set color limits
* \param[in] min The minimum value in %
* \param[in] max The minimum value in %
* \throws Error
*/
void colorLimits(float64 min, float64 max) throw (Error);
/*!
* \brief getter
* \return Property Data plot container
*/
datacontainer::PropertyPlotDataContainer& getPropertyPlotDataContainer();
std::vector<float64> toDataCoord(float64 x, float64 y, int32 devicePixelRatio) throw (Error) ;
void checkLegendPick(float64 x, float64 y) throw (Error) ;
void allowRoiFunctionnalities();
/*!
* \brief Start of sequence add a roi
* \param[in] id The id of the roi
* \param[in] color The color of the roi box
* \throws Error
*/
void newRoiStart