From b318c8f49a301ffad64d39b64113c5a4cc1dd67f Mon Sep 17 00:00:00 2001 From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk> Date: Thu, 1 Oct 2015 15:45:13 +0100 Subject: [PATCH] Re #12808. Added the new tool to Pick tab. --- Code/Mantid/Images/images.qrc | 2 ++ .../InstrumentWindowMaskTab.cpp | 7 +++--- .../InstrumentWindowPickTab.cpp | 23 ++++++++++++++++++- .../InstrumentWindowPickTab.h | 3 ++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Code/Mantid/Images/images.qrc b/Code/Mantid/Images/images.qrc index d68c46cd1be..f574b14d849 100644 --- a/Code/Mantid/Images/images.qrc +++ b/Code/Mantid/Images/images.qrc @@ -67,6 +67,7 @@ <file>eraser.png</file> <file>selection-box-ring.png</file> <file>selection-circle-ring.png</file> + <file>brush.png</file> </qresource> <qresource prefix="/MaskTools"> <file>selection-circle.png</file> @@ -74,5 +75,6 @@ <file>selection-box-ring.png</file> <file>selection-circle-ring.png</file> <file>selection-edit.png</file> + <file>brush.png</file> </qresource> </RCC> diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp index 490946237f7..3cce4254663 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp @@ -123,9 +123,9 @@ m_left(NULL), m_top(NULL), m_right(NULL), m_bottom(NULL) m_free_draw = new QPushButton(); m_free_draw->setCheckable(true); m_free_draw->setAutoExclusive(true); - m_free_draw->setIcon(QIcon(":/MaskTools/selection-box-ring.png")); - m_free_draw->setToolTip("Draw a free shape (Shift+Alt+F)"); - m_free_draw->setShortcut(QKeySequence("Shift+Alt+F")); + m_free_draw->setIcon(QIcon(":/MaskTools/brush.png")); + m_free_draw->setToolTip("Draw an arbitrary shape (Shift+Alt+A)"); + m_free_draw->setShortcut(QKeySequence("Shift+Alt+A")); QHBoxLayout* toolBox = new QHBoxLayout(); toolBox->addWidget(m_move); @@ -419,6 +419,7 @@ void InstrumentWindowMaskTab::setActivity() */ void InstrumentWindowMaskTab::shapeCreated() { + if (!isVisible()) return; if (m_activity != DrawFree) { setSelectActivity(); diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp index 145028cc8e3..f49c0a553da 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp @@ -197,6 +197,12 @@ m_plotTypeCache(0) m_ring_rectangle->setIcon(QIcon(":/PickTools/selection-box-ring.png")); m_ring_rectangle->setToolTip("Draw a rectangular ring"); + m_free_draw = new QPushButton(); + m_free_draw->setCheckable(true); + m_free_draw->setAutoExclusive(true); + m_free_draw->setIcon(QIcon(":/PickTools/brush.png")); + m_free_draw->setToolTip("Draw an arbitrary shape"); + m_edit = new QPushButton(); m_edit->setCheckable(true); m_edit->setAutoExclusive(true); @@ -222,6 +228,7 @@ m_plotTypeCache(0) toolBox->addWidget(m_rectangle,0,3); toolBox->addWidget(m_ring_ellipse,0,4); toolBox->addWidget(m_ring_rectangle,0,5); + toolBox->addWidget(m_free_draw,0,6); toolBox->addWidget(m_one,1,0); toolBox->addWidget(m_tube,1,1); toolBox->addWidget(m_peak,1,2); @@ -237,6 +244,7 @@ m_plotTypeCache(0) connect(m_ellipse,SIGNAL(clicked()),this,SLOT(setSelectionType())); connect(m_ring_ellipse,SIGNAL(clicked()),this,SLOT(setSelectionType())); connect(m_ring_rectangle,SIGNAL(clicked()),this,SLOT(setSelectionType())); + connect(m_free_draw,SIGNAL(clicked()),this,SLOT(setSelectionType())); connect(m_edit,SIGNAL(clicked()),this,SLOT(setSelectionType())); // lay out the widgets @@ -438,6 +446,14 @@ void InstrumentWindowPickTab::setSelectionType() plotType = DetectorPlotController::Single; m_instrWindow->getSurface()->startCreatingShape2D("ring rectangle",Qt::green,QColor(255,255,255,80)); } + else if (m_free_draw->isChecked()) + { + m_selectionType = Draw; + m_activeTool->setText("Tool: Arbitrary shape"); + surfaceMode = ProjectionSurface::DrawFreeMode; + plotType = DetectorPlotController::Single; + m_instrWindow->getSurface()->startCreatingFreeShape(Qt::green,QColor(255,255,255,80)); + } else if (m_edit->isChecked()) { m_selectionType = Draw; @@ -629,6 +645,8 @@ void InstrumentWindowPickTab::selectTool(const ToolType tool) break; case DrawEllipse: m_ellipse->setChecked(true); break; + case DrawFree: m_free_draw->setChecked(true); + break; case EditShape: m_edit->setChecked(true); break; default: throw std::invalid_argument("Invalid tool type."); @@ -669,7 +687,10 @@ void InstrumentWindowPickTab::updateSelectionInfoDisplay() void InstrumentWindowPickTab::shapeCreated() { if ( !isVisible() ) return; - selectTool( EditShape ); + if (!m_free_draw->isChecked()) + { + selectTool( EditShape ); + } } /** diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h index ec169a6b904..5bcdf5c420f 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h @@ -47,7 +47,7 @@ public: /// SelectPeak: click on a peak marker or draw a rubber-band selector to select peak /// markers. Selected peaks can be deleted by pressing the Delete key. enum SelectionType {Single=0,AddPeak,ErasePeak,SingleDetectorSelection,Tube, Draw}; - enum ToolType {Zoom,PixelSelect,TubeSelect,PeakSelect,PeakErase, DrawEllipse, DrawRectangle, EditShape}; + enum ToolType {Zoom,PixelSelect,TubeSelect,PeakSelect,PeakErase, DrawEllipse, DrawRectangle, DrawFree, EditShape}; InstrumentWindowPickTab(InstrumentWindow* instrWindow); bool canUpdateTouchedDetector()const; @@ -91,6 +91,7 @@ private: QPushButton *m_ellipse; ///< Button switching on drawing a elliptical selection region QPushButton *m_ring_ellipse; ///< Button switching on drawing a elliptical ring selection region QPushButton *m_ring_rectangle; ///< Button switching on drawing a rectangular ring selection region + QPushButton *m_free_draw; ///< Button switching on drawing a region of arbitrary shape QPushButton *m_edit; ///< Button switching on edditing the selection region bool m_plotSum; -- GitLab