Commit 1ab96213 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Add a signal for pixel masking

When picking a single pixel, 2 behaviours are possible : either it's for
masking, and then the picked pixel must be masked on screen immediately,
or it's for picking and then nothing happens to the instrument.
Separating the signals allows for calling the appropriate slot depending
on the current tab.
parent 56fceb46
......@@ -147,6 +147,8 @@ public:
/// Save settings for the projection surface to a project file
virtual std::string saveToProject() const;
void setCurrentTab(int currentTab) { m_currentTab = currentTab; }
//-----------------------------------
// Mask methods
//-----------------------------------
......@@ -267,6 +269,7 @@ signals:
// detector selection
void singleComponentTouched(size_t /*_t1*/);
void singleComponentPicked(size_t /*_t1*/);
void singleComponentPickedForMasking(size_t /*_t1*/);
// shape manipulation
void signalToStartCreatingShape2D(const QString &type,
......@@ -387,6 +390,7 @@ private:
/// Set when the picking image must be redrawn regardless of the interaction
/// mode
mutable bool m_redrawPicking;
int m_currentTab;
friend class InstrumentWidgetEncoder;
friend class InstrumentWidgetDecoder;
......
......@@ -356,6 +356,7 @@ void InstrumentWidget::resetSurface() {
* Select the tab to be displayed
*/
void InstrumentWidget::selectTab(int tab) {
getSurface()->setCurrentTab(tab);
mControlsTab->setCurrentIndex(tab);
}
......@@ -576,7 +577,13 @@ void InstrumentWidget::setupColorMap() { emit colorMapChanged(); }
/**
* Connected to QTabWidget::currentChanged signal
*/
void InstrumentWidget::tabChanged(int /*unused*/) { updateInfoText(); }
void InstrumentWidget::tabChanged(int /*unused*/) {
updateInfoText();
auto surface = getSurface();
if (surface) {
surface->setCurrentTab(getCurrentTab());
}
}
/**
* Change color map button slot. This provides the file dialog box to select
......
......@@ -375,7 +375,7 @@ InstrumentWidgetMaskTab::InstrumentWidgetMaskTab(InstrumentWidget *instrWidget)
*/
void InstrumentWidgetMaskTab::initSurface() {
connect(m_instrWidget->getSurface().get(),
SIGNAL(singleComponentPicked(size_t)), this,
SIGNAL(singleComponentPickedForMasking(size_t)), this,
SLOT(singlePixelPicked(size_t)));
connect(m_instrWidget->getSurface().get(), SIGNAL(shapeCreated()), this,
SLOT(shapeCreated()));
......
......@@ -849,7 +849,11 @@ void ProjectionSurface::selectMultipleMasks(const QRect &rect) {
*/
void ProjectionSurface::pickComponentAt(int x, int y) {
size_t pickID = getPickID(x, y);
emit singleComponentPicked(pickID);
if (m_currentTab == 2) {
emit singleComponentPickedForMasking(pickID);
} else {
emit singleComponentPicked(pickID);
}
}
void ProjectionSurface::touchComponentAt(int x, int y) {
......
Supports Markdown
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