Commit 9a16f89e authored by Locatelli's avatar Locatelli
Browse files

Add count activated property

parent ab75950d
......@@ -4,7 +4,7 @@
* Use async method for filling data vectors for accelerating process
* Create for offscreen empty spies, remove multiplot files at the start of server
* Remove multiplot files at the start of server
* Multiclient options
- no offscreen log, webspy plots
......@@ -14,19 +14,12 @@
- Try create a plot with all plots (subplot)
- For PN do something for detecting channel problem (using CPU of mpda_dpp?) or in nomad?
* ROI
* Cut windows
* Bugs:
- Plot1D crash after several time using it, see core file, pb QT event
- Problem to pass from empty plot to others
- Problem close a plot take a time in cameo, so if restarting a new before finishing previous does not worked
* Multithread:
- Create a poll of thread for doing works
* Does we limits x data for plot 1D (as doing in plot2d)?
* Spy
- Set log activated to offscreen for spy
\ No newline at end of file
- Set log activated to offscreen for spy
* Offscreen log
- do recover system
\ No newline at end of file
......@@ -204,6 +204,7 @@ PropertyPlotDataContainer::PropertyPlotDataContainer(const ploty::PlotPropertyDa
roiSelectedY1Id = plotMessage.selectedy1_id();
roiCommandAddId = plotMessage.commandroiadd_id();
roiCommandRazId = plotMessage.commandroiraz_id();
countActivatedId = plotMessage.countactivated_id();
hasx = false;
hasy = false;
......
......@@ -97,6 +97,7 @@ public:
int32 roiSelectedY1Id; //! Property id of the selected roi Y1 for adding or removing roi command
int32 roiCommandAddId; //! Add Command id
int32 roiCommandRazId; //! Raz Command id
int32 countActivatedId; //! Command Status property id
bool hasx; //! Flag tells if there is x data (run getPlotType() before)
bool hasy; //! Flag tells if there is y data (run getPlotType() before)
......
......@@ -135,6 +135,10 @@ void PropertyPlot::newRoiCancel() throw (Error) {
*/
void PropertyPlot::modifyRoiStart(uint32 id, const std::string& color) throw (Error) {
if (m_MplRoi) {
bool activated = ServerRequesterManager::getInstance()->getBoolPropertyValue(m_DataCont.countActivatedId);
if (activated == true) {
throw Error("PropertyPlot", "modifyRoiStart", "Can't modify roi during an acquisition");
}
m_MplRoi->modifyRoiStart(id, color);
}
}
......@@ -146,6 +150,10 @@ void PropertyPlot::modifyRoiEnd(uint32 id, const std::string& color) throw (Erro
if (m_MplRoi) {
int32 nplot = 0;
if (id == m_DataCont.roiX0_ids[nplot].size()) {
bool activated = ServerRequesterManager::getInstance()->getBoolPropertyValue(m_DataCont.countActivatedId);
if (activated == true) {
throw Error("PropertyPlot", "modifyRoiEnd", "Can't modify roi during an acquisition");
}
// New roi in server
ServerRequesterManager::getInstance()->setInt32PropertyValue(m_DataCont.roiSelectedPlotId, (int32) nplot);
ServerRequesterManager::getInstance()->setInt32PropertyValue(m_DataCont.roiSelectedRoiId, (int32) id);
......@@ -166,6 +174,10 @@ void PropertyPlot::modifyRoiEnd(uint32 id, const std::string& color) throw (Erro
void PropertyPlot::deleteRoi(uint32 id) throw (Error) {
if (m_MplRoi) {
try {
bool activated = ServerRequesterManager::getInstance()->getBoolPropertyValue(m_DataCont.countActivatedId);
if (activated == true) {
throw Error("PropertyPlot", "deleteRoi", "Can't delete roi during an acquisition");
}
int32 nplot = 0;
ServerRequesterManager::getInstance()->setInt32PropertyValue(m_DataCont.roiSelectedPlotId, (int32) nplot);
ServerRequesterManager::getInstance()->setInt32PropertyValue(m_DataCont.roiSelectedRoiId, (int32) id);
......
......@@ -21,6 +21,7 @@
#include <QLabel>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QErrorMessage>
#include <boost/lexical_cast.hpp>
#include <iomanip>
......@@ -116,11 +117,6 @@ QtRoiWidget::QtRoiWidget(QtWindow* qtWindow, QtToolBar& toolbar, uint32 indice,
m_Modify->setMaximumWidth(BUTTON_WIDTH);
layout->addWidget(m_Modify.get());
// m_SetToServer = new QPushButton(tr("&To server"));
// m_SetToServer->setMinimumWidth(BUTTON_WIDTH);
// m_SetToServer->setMaximumWidth(BUTTON_WIDTH);
// layout->addWidget(m_SetToServer);
m_Delete.reset(new QPushButton(tr("&Delete")));
m_Delete->setEnabled(true);
m_Delete->setMinimumWidth(BUTTON_WIDTH);
......@@ -202,16 +198,10 @@ void QtRoiWidget::modifyRoi() {
m_Validate->setVisible(true);
}
catch(...) {
Error("QtRoiWidget", "modifyRoi", "Error executing modify");
QMessageBox::warning(this, "Modify ROI", "Can't modify a ROI during an acquisition", QMessageBox::Ok, QMessageBox::Ok);
}
}
///*
// * setToServer
// */
//void QtRoiWidget::setToServer() {
//}
/*
* validateRoi
*/
......@@ -226,7 +216,7 @@ void QtRoiWidget::validateRoi() {
m_QtWindow->validateRoi(m_Id);
}
catch(...) {
Error("QtRoiWidget", "newRoi", "Error executing newRoi");
QMessageBox::warning(this, "Validate ROI", "Can't validate a ROI during an acquisition", QMessageBox::Ok, QMessageBox::Ok);
}
}
......@@ -235,24 +225,13 @@ void QtRoiWidget::validateRoi() {
*/
void QtRoiWidget::deleteRoi() {
try {
QMessageBox msgBox;
QIcon plotIcon("/usr/share/icons/Ploty2/plot.png");
msgBox.setWindowIcon(plotIcon);
msgBox.setWindowTitle("Delete ROI");
msgBox.setText("Do you want to delete this ROI?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
int ret = QMessageBox::question(this, "Delete ROI", "Do you want to delete this ROI?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (ret == QMessageBox::Yes) {
manager::InterfaceManager::getInstance(m_QtWindow->getPlotId())->deleteRoi(m_Id);
m_QtWindow->deleteRoi(m_Id);
}
else {
// do nothing
}
}
catch(...) {
Error("QtRoiWidget", "deleteRoi", "Error executing deleteRoi");
QMessageBox::warning(this, "Delete ROI", "Can't delete a ROI during an acquisition", QMessageBox::Ok, QMessageBox::Ok);
}
}
......
......@@ -95,7 +95,14 @@ public:
*/
void setId(uint32 id);
/*!
* \brief Disable roi changes
*/
void disableChanges();
/*!
* \brief Enable roi changes
*/
void enableChanges();
public Q_SLOTS:
......@@ -105,12 +112,6 @@ public Q_SLOTS:
*/
void modifyRoi();
// /*!
// * \brief GUI signal execution when y value changed
// * \param[in] value The new value of the spin or slider (use int and not int32 for qt library)
// */
// void setToServer();
/*!
* \brief Validate a roi
*/
......@@ -141,7 +142,6 @@ private:
std::unique_ptr<QLabel> m_SumLabel; //!
std::unique_ptr<QLabel> m_Sum; //!
std::unique_ptr<QPushButton> m_Modify;
// QPushButton* m_SetToServer;
std::unique_ptr<QPushButton> m_Delete;
std::unique_ptr<QPushButton> m_Validate;
std::unique_ptr<QPushButton> m_Cancel;
......
......@@ -180,6 +180,7 @@ void QtWindow::switchPlot(plot::PlotType plottype) {
m_StatusWidget->hide();
}
m_ToolBar->switchPlot(plottype);
unique_lock<recursive_mutex> lock(m_RoiMutex);
for(auto& roi : m_RoiWidgets) {
roi->switchPlot(plottype);
}
......@@ -220,6 +221,7 @@ void QtWindow::allowRoiFunctionnalities() {
*/
void QtWindow::newRoi() {
unique_lock<recursive_mutex> lock(m_RoiMutex);
uint32 newRoiId = m_RoiWidgets.size();
unique_ptr<QtRoiWidget> roi = make_unique<QtRoiWidget>(this, *m_ToolBar, newRoiId, ROI_COLOR);
roi->newRoi();
......@@ -238,6 +240,7 @@ void QtWindow::newRoi() {
* modifyRoi
*/
void QtWindow::modifyRoi(uint32 id) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
for(uint32 i = 0 ; i < m_RoiWidgets.size(); ++i) {
if (i == id) {
m_RoiWidgets[i]->disableChanges();
......@@ -249,6 +252,7 @@ void QtWindow::modifyRoi(uint32 id) {
* validateRoi
*/
void QtWindow::validateRoi(uint32 id) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
for(uint32 i = 0 ; i < m_RoiWidgets.size(); ++i) {
if (i == id) {
m_RoiWidgets[i]->enableChanges();
......@@ -260,6 +264,7 @@ void QtWindow::validateRoi(uint32 id) {
* deleteRoi
*/
void QtWindow::deleteRoi(uint32 id) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
m_Layout->removeWidget(m_RoiWidgets[id].get());
m_RoiWidgets.erase(m_RoiWidgets.begin() + id);
for(uint32 i = id ; i < m_RoiWidgets.size(); ++i) {
......@@ -271,6 +276,7 @@ void QtWindow::deleteRoi(uint32 id) {
* updateRoi
*/
void QtWindow::updateRoi(const std::vector<RoiRectangle>& rects) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
for(auto& iter : m_RoiWidgets) {
m_Layout->removeWidget(iter.get());
}
......@@ -290,6 +296,7 @@ void QtWindow::updateRoi(const std::vector<RoiRectangle>& rects) {
* updateRoi
*/
void QtWindow::updateRoi(int32 n,const RectangleCoord& rect) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
m_RoiWidgets[n]->showRoiCoord(rect);
}
......@@ -297,6 +304,7 @@ void QtWindow::updateRoi(int32 n,const RectangleCoord& rect) {
*updateSum
*/
void QtWindow::updateRoiSum(uint32 id, float64 sum) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
m_RoiWidgets[id]->updateSum(sum);
}
......@@ -304,6 +312,7 @@ void QtWindow::updateRoiSum(uint32 id, float64 sum) {
* showRoiCoord
*/
void QtWindow::showRoiCoord(uint32 id, const RectangleCoord& rect) {
unique_lock<recursive_mutex> lock(m_RoiMutex);
if (id < m_RoiWidgets.size()) {
m_RoiWidgets[id]->showRoiCoord(rect);
}
......
......@@ -22,6 +22,7 @@
#include <QMainWindow>
#include <memory>
#include <common/base/BaseTypes.h>
#include <mutex>
QT_BEGIN_NAMESPACE
class QToolBar;
......@@ -349,6 +350,7 @@ private:
plot::PlotType m_Plottype; //! The plot type
std::vector<std::unique_ptr<QtRoiWidget>> m_RoiWidgets; //! Plot widget
std::recursive_mutex m_RoiMutex;
std::unique_ptr<QtStatisticWidget> m_StatisticWidget; //! Stats widget
static const std::string ROI_COLOR; // ROI color
static const std::string CUT_COLOR; // CUT color
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment