Commit 96e7961e authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #6162. Returning the reverted code

parent 927a4d4d
......@@ -173,7 +173,10 @@ namespace DataObjects
*/
void PeaksWorkspace::removePeak(const int peakNum)
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::removePeak(): peakNum is out of range.");
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 )
{
throw std::invalid_argument("PeaksWorkspace::removePeak(): peakNum is out of range.");
}
peaks.erase(peaks.begin()+peakNum);
}
......@@ -200,7 +203,10 @@ namespace DataObjects
*/
API::IPeak & PeaksWorkspace::getPeak(const int peakNum)
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::getPeak(): peakNum is out of range.");
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 )
{
throw std::invalid_argument("PeaksWorkspace::getPeak(): peakNum is out of range.");
}
return peaks[peakNum];
}
......@@ -211,7 +217,10 @@ namespace DataObjects
*/
const API::IPeak & PeaksWorkspace::getPeak(const int peakNum) const
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::getPeak(): peakNum is out of range.");
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 )
{
throw std::invalid_argument("PeaksWorkspace::getPeak(): peakNum is out of range.");
}
return peaks[peakNum];
}
......
<RCC>
<qresource prefix="/">
<file>pvIcon.png</file>
<file>MantidSplashScreen.png</file>
<file>MantidPlot_Icon_32offset.png</file>
<file>SNS_logo_trans_back.gif</file>
<file>Tessella_Logo_Transparent.gif</file>
<file>Mantid_Logo_Transparent_Cropped.png</file>
<file>HFIR_logo_small.png</file>
<file>ISIS_Logo_Transparent.gif</file>
<file>Mantid_Logo_Transparent.png</file>
<file>data_replace.png</file>
</qresource>
<qresource prefix="/Icons">
<file>LoadFile.png</file>
</qresource>
<qresource prefix="/PickTools">
<file>selection-tube.png</file>
<file>selection-box.png</file>
<file>selection-circle.png</file>
<file>selection-pointer.png</file>
<file>selection-text.png</file>
<file>selection-peak.png</file>
</qresource>
<qresource prefix="/MaskTools">
<file>selection-pointer.png</file>
<file>selection-circle.png</file>
<file>selection-box.png</file>
</qresource>
<qresource prefix="/">
<file>pvIcon.png</file>
<file>MantidSplashScreen.png</file>
<file>MantidPlot_Icon_32offset.png</file>
<file>SNS_logo_trans_back.gif</file>
<file>Tessella_Logo_Transparent.gif</file>
<file>Mantid_Logo_Transparent_Cropped.png</file>
<file>HFIR_logo_small.png</file>
<file>ISIS_Logo_Transparent.gif</file>
<file>Mantid_Logo_Transparent.png</file>
<file>data_replace.png</file>
</qresource>
<qresource prefix="/Icons">
<file>LoadFile.png</file>
</qresource>
<qresource prefix="/PickTools">
<file>selection-tube.png</file>
<file>selection-box.png</file>
<file>selection-circle.png</file>
<file>selection-pointer.png</file>
<file>selection-text.png</file>
<file>selection-peak.png</file>
<file>selection-peaks.png</file>
</qresource>
<qresource prefix="/MaskTools">
<file>selection-pointer.png</file>
<file>selection-circle.png</file>
<file>selection-box.png</file>
</qresource>
</RCC>
......@@ -201,6 +201,7 @@ set ( MANTID_SRCS src/Mantid/AbstractMantidLog.cpp
src/Mantid/InstrumentWidget/InstrumentTreeModel.cpp
src/Mantid/InstrumentWidget/InstrumentTreeWidget.cpp
src/Mantid/InstrumentWidget/InstrumentWindow.cpp
src/Mantid/InstrumentWidget/InstrumentWindowTab.cpp
src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.cpp
src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp
src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp
......@@ -219,7 +220,6 @@ set ( MANTID_SRCS src/Mantid/AbstractMantidLog.cpp
src/Mantid/InstrumentWidget/PeakOverlay.cpp
src/Mantid/InstrumentWidget/OneCurvePlot.cpp
src/Mantid/InstrumentWidget/CollapsiblePanel.cpp
src/Mantid/InstrumentWidget/DetSelector.cpp
src/Mantid/InstrumentWidget/XIntegrationControl.cpp
src/Mantid/InstrumentWidget/Shape2D.cpp
src/Mantid/InstrumentWidget/Shape2DCollection.cpp
......@@ -425,6 +425,7 @@ set ( MANTID_HDRS src/Mantid/AbstractMantidLog.h
src/Mantid/InstrumentWidget/InstrumentTreeModel.h
src/Mantid/InstrumentWidget/InstrumentTreeWidget.h
src/Mantid/InstrumentWidget/InstrumentWindow.h
src/Mantid/InstrumentWidget/InstrumentWindowTab.h
src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h
src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h
src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.h
......@@ -443,7 +444,6 @@ set ( MANTID_HDRS src/Mantid/AbstractMantidLog.h
src/Mantid/InstrumentWidget/Projection3D.h
src/Mantid/InstrumentWidget/OneCurvePlot.h
src/Mantid/InstrumentWidget/CollapsiblePanel.h
src/Mantid/InstrumentWidget/DetSelector.h
src/Mantid/InstrumentWidget/XIntegrationControl.h
src/Mantid/InstrumentWidget/Shape2D.h
src/Mantid/InstrumentWidget/Shape2DCollection.h
......@@ -672,6 +672,7 @@ set ( MANTID_MOC_FILES src/Mantid/AlgorithmMonitor.h
src/Mantid/InstrumentWidget/InstrumentTreeModel.h
src/Mantid/InstrumentWidget/InstrumentTreeWidget.h
src/Mantid/InstrumentWidget/InstrumentWindow.h
src/Mantid/InstrumentWidget/InstrumentWindowTab.h
src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h
src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h
src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.h
......
//--------------------------------
// Includes
//--------------------------------
#include "DetSelector.h"
#include "MantidKernel/System.h"
#include <QPainter>
#include <algorithm>
DetSelector::DetSelector():
m_xStart(0),m_yStart(0),m_inProgress(false),m_color(Qt::blue)
{
}
void DetSelector::draw(QPainter& painter)
{
UNUSED_ARG(painter);
}
DetSelector* DetSelector::create(DetSelectionType type)
{
switch(type)
{
case Single:
return new DetSelector();
default:
return new BoxDetSelector();
};
}
void DetSelector::start(int x, int y)
{
m_xStart = x;
m_yStart = y;
m_inProgress = true;
}
void DetSelector::stop()
{
m_inProgress = false;
}
void BoxDetSelector::draw(QPainter& painter)
{
if (!m_inProgress) return;
painter.setPen(m_color);
painter.drawRect(m_xStart,m_yStart,m_xEnd,m_yEnd);
}
void BoxDetSelector::move(int x, int y)
{
if (!m_inProgress) return;
m_xEnd = x;
m_yEnd = y;
if (m_xEnd < m_xStart) std::swap(m_xEnd,m_xStart);
if (m_yEnd < m_yStart) std::swap(m_yEnd,m_yStart);
}
#ifndef DETSELECTOR_H_
#define DETSELECTOR_H_
#include <QColor>
/**
\class DetSelector
\brief class to pick group of detectors
\author Roman Tolchenov
\date 10 Feb 2011
Copyright &copy; 2007 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
*/
class QPainter;
/**
* Enumerates the ways teh detectors can be selected.
* SingleDetectorSelection separates ways of selecting a single detector from
* those of groups of detectors
*/
enum DetSelectionType {Single=0,Peak,SingleDetectorSelection,BoxType,Tube};
class DetSelector
{
public:
DetSelector(); ///< Constructor
virtual ~DetSelector(){} ///< Destructor
virtual void draw(QPainter& painter);
virtual void start(int x, int y);
virtual void move(int , int ){}
virtual void stop();
static DetSelector* create(DetSelectionType type);
protected:
int m_xStart;
int m_yStart;
bool m_inProgress;
QColor m_color;
};
class BoxDetSelector: public DetSelector
{
public:
void draw(QPainter& painter);
void move(int x, int y);
protected:
int m_xEnd;
int m_yEnd;
};
#endif /*DETSELECTOR_H_*/
......@@ -441,9 +441,11 @@ void InstrumentWindow::setSurfaceType(int type)
setSurface(surface);
// make sure to switch to the right instrument display
selectOpenGLDisplay( useOpenGL );
m_renderTab->init();
m_pickTab->init();
m_maskTab->init();
// m_renderTab->init();
// m_pickTab->init();
// m_maskTab->init();
InstrumentWindowTab* tab = dynamic_cast<InstrumentWindowTab*>(mControlsTab->currentWidget());
if ( tab ) tab->initOnShow();
connect(surface,SIGNAL(singleDetectorTouched(int)),this,SLOT(singleDetectorTouched(int)));
connect(surface,SIGNAL(singleDetectorPicked(int)),this,SLOT(singleDetectorPicked(int)));
......@@ -526,6 +528,8 @@ void InstrumentWindow::tabChanged(int i)
m_instrumentActor->accept(SetAllVisibleVisitor());
}
setInfoText(surface->getInfoText());
InstrumentWindowTab* tab = dynamic_cast<InstrumentWindowTab*>(mControlsTab->widget(i));
if ( tab ) tab->initOnShow();
updateInstrumentView();
}
......@@ -971,7 +975,7 @@ void InstrumentWindow::showEvent(QShowEvent* e)
QWidget * InstrumentWindow::createInstrumentTreeTab(QTabWidget* ControlsTab)
{
QWidget* instrumentTree=new QWidget(ControlsTab);
InstrumentWindowTab* instrumentTree=new InstrumentWindowTab(ControlsTab);
QVBoxLayout* instrumentTreeLayout=new QVBoxLayout(instrumentTree);
//Tree Controls
mInstrumentTree = new InstrumentTreeWidget(0);
......
......@@ -48,7 +48,7 @@
#include <algorithm>
InstrumentWindowMaskTab::InstrumentWindowMaskTab(InstrumentWindow* instrWindow):
QFrame(instrWindow),
InstrumentWindowTab(instrWindow),
m_instrumentWindow(instrWindow),
m_activity(Select),
m_hasMaskToApply(false),
......@@ -170,7 +170,7 @@ m_userEditing(true)
}
void InstrumentWindowMaskTab::init()
void InstrumentWindowMaskTab::initOnShow()
{
connect(m_instrumentWindow->getSurface(),SIGNAL(shapeCreated()),this,SLOT(shapeCreated()));
connect(m_instrumentWindow->getSurface(),SIGNAL(shapeSelected()),this,SLOT(shapeSelected()));
......@@ -186,36 +186,36 @@ void InstrumentWindowMaskTab::setActivity()
if (m_move->isChecked())
{
m_activity = Move;
m_instrumentWindow->getSurface()->setInteractionModeMove();
m_instrumentWindow->getSurface()->setInteractionMode(ProjectionSurface::MoveMode);
}
else if (m_pointer->isChecked())
{
m_activity = Select;
m_instrumentWindow->getSurface()->setInteractionModeDraw();
m_instrumentWindow->getSurface()->setInteractionMode(ProjectionSurface::DrawMode);
}
else if (m_ellipse->isChecked())
{
m_activity = DrawEllipse;
m_instrumentWindow->getSurface()->startCreatingShape2D("ellipse",borderColor,fillColor);
m_instrumentWindow->getSurface()->setInteractionModeDraw();
m_instrumentWindow->getSurface()->setInteractionMode(ProjectionSurface::DrawMode);
}
else if (m_rectangle->isChecked())
{
m_activity = DrawEllipse;
m_instrumentWindow->getSurface()->startCreatingShape2D("rectangle",borderColor,fillColor);
m_instrumentWindow->getSurface()->setInteractionModeDraw();
m_instrumentWindow->getSurface()->setInteractionMode(ProjectionSurface::DrawMode);
}
else if (m_ring_ellipse->isChecked())
{
m_activity = DrawEllipse;
m_instrumentWindow->getSurface()->startCreatingShape2D("ring ellipse",borderColor,fillColor);
m_instrumentWindow->getSurface()->setInteractionModeDraw();
m_instrumentWindow->getSurface()->setInteractionMode(ProjectionSurface::DrawMode);
}
else if (m_ring_rectangle->isChecked())
{
m_activity = DrawEllipse;
m_instrumentWindow->getSurface()->startCreatingShape2D("ring rectangle",borderColor,fillColor);
m_instrumentWindow->getSurface()->setInteractionModeDraw();
m_instrumentWindow->getSurface()->setInteractionMode(ProjectionSurface::DrawMode);
}
}
......
#ifndef INSTRUMENTWINDOWMASKTAB_H_
#define INSTRUMENTWINDOWMASKTAB_H_
#include "InstrumentWindowTab.h"
#include "MantidGLWidget.h"
#include "DetSelector.h"
#include <QFrame>
#include <QMap>
......@@ -43,13 +43,13 @@ namespace Mantid
/**
* Implements the Mask tab in InstrumentWindow
*/
class InstrumentWindowMaskTab: public QFrame
class InstrumentWindowMaskTab: public InstrumentWindowTab
{
Q_OBJECT
public:
enum Activity {Move = 0, Select = 1, DrawEllipse};
InstrumentWindowMaskTab(InstrumentWindow* instrWindow);
void init();
void initOnShow();
signals:
void executeAlgorithm(const QString&, const QString&);
protected slots:
......
......@@ -52,83 +52,12 @@ struct Sqrt
}
};
/**
* Dialog for converting x-values to time of flight needed for peak selection.
*/
class InputConvertUnitsParametersDialog : public QDialog
{
public:
InputConvertUnitsParametersDialog(QWidget* parent);
int getEMode()const;
double getEFixed()const;
double getDelta()const;
private:
QComboBox* m_emode;
QLineEdit* m_efixed;
QLineEdit* m_delta;
};
InputConvertUnitsParametersDialog::InputConvertUnitsParametersDialog(QWidget* parent):QDialog(parent)
{
QGridLayout* input_layout = new QGridLayout();
QLabel* label = new QLabel("Units have to be converted to TOF.\nPlease specify additional information.");
m_emode = new QComboBox();
QStringList emodeOptions;
emodeOptions << "Elastic" << "Direct" << "Indirect";
m_emode->insertItems(0,emodeOptions);
QLabel* emode_label = new QLabel("EMode");
m_efixed = new QLineEdit();
m_efixed->setText("0.0");
QLabel* efixed_label = new QLabel("EFixed");
m_delta = new QLineEdit();
m_delta->setText("0.0");
QLabel* delta_label = new QLabel("Delta");
input_layout->addWidget(label,0,0,1,2);
input_layout->addWidget(emode_label,1,0);
input_layout->addWidget(m_emode,1,1);
input_layout->addWidget(efixed_label,2,0);
input_layout->addWidget(m_efixed,2,1);
input_layout->addWidget(delta_label,3,0);
input_layout->addWidget(m_delta,3,1);
QHBoxLayout* button_layout = new QHBoxLayout();
QPushButton* ok_button = new QPushButton("OK");
button_layout->addStretch();
button_layout->addWidget(ok_button);
connect(ok_button,SIGNAL(clicked()),this,SLOT(close()));
QVBoxLayout* main_layout = new QVBoxLayout(this);
main_layout->addLayout(input_layout);
main_layout->addStretch();
main_layout->addLayout(button_layout);
}
int InputConvertUnitsParametersDialog::getEMode()const
{
return m_emode->currentIndex();
}
double InputConvertUnitsParametersDialog::getEFixed()const
{
return m_efixed->text().toDouble();
}
double InputConvertUnitsParametersDialog::getDelta()const
{
return m_delta->text().toDouble();
}
// --- InstrumentWindowPickTab --- //
/**
* Constructor.
* @param instrWindow :: Parent InstrumentWindow.
*/
InstrumentWindowPickTab::InstrumentWindowPickTab(InstrumentWindow* instrWindow):
QFrame(instrWindow),
InstrumentWindowTab(instrWindow),
m_instrWindow(instrWindow),
m_currentDetID(-1),
m_tubeXUnits(DETECTOR_ID),
......@@ -214,11 +143,6 @@ m_freezePlot(false)
m_one->setToolTip("Select single pixel");
m_one->setIcon(QIcon(":/PickTools/selection-pointer.png"));
m_box = new QPushButton();
m_box->setCheckable(true);
m_box->setAutoExclusive(true);
m_box->setIcon(QIcon(":/PickTools/selection-box.png"));
m_tube = new QPushButton();
m_tube->setCheckable(true);
m_tube->setAutoExclusive(true);
......@@ -229,20 +153,25 @@ m_freezePlot(false)
m_peak->setCheckable(true);
m_peak->setAutoExclusive(true);
m_peak->setIcon(QIcon(":/PickTools/selection-peak.png"));
m_peak->setToolTip("Select single crystal peak");
m_peak->setToolTip("Add single crystal peak");
m_peakSelect = new QPushButton();
m_peakSelect->setCheckable(true);
m_peakSelect->setAutoExclusive(true);
m_peakSelect->setIcon(QIcon(":/PickTools/selection-peaks.png"));
m_peakSelect->setToolTip("Select single crystal peak(s)");
QHBoxLayout* toolBox = new QHBoxLayout();
toolBox->addWidget(m_one);
toolBox->addWidget(m_box);
m_box->setVisible(false); //Hidden by Owen Arnold 14/02/2011 because box picking doesn't exhibit correct behaviour and is not necessary for current release
toolBox->addWidget(m_tube);
toolBox->addWidget(m_peak);
toolBox->addWidget(m_peakSelect);
toolBox->addStretch();
toolBox->setSpacing(2);
connect(m_one,SIGNAL(clicked()),this,SLOT(setSelectionType()));
connect(m_box,SIGNAL(clicked()),this,SLOT(setSelectionType()));
connect(m_tube,SIGNAL(clicked()),this,SLOT(setSelectionType()));
connect(m_peak,SIGNAL(clicked()),this,SLOT(setSelectionType()));
connect(m_peakSelect,SIGNAL(clicked()),this,SLOT(setSelectionType()));
setSelectionType();
// lay out the widgets
......@@ -256,9 +185,10 @@ m_freezePlot(false)
/**
* Initialise the tab.
*/
void InstrumentWindowPickTab::init()
void InstrumentWindowPickTab::initOnShow()
{
m_emode = -1;
// Make the state of the display view consistent with the current selection type
setSelectionType();
}
/**
......@@ -664,16 +594,12 @@ void InstrumentWindowPickTab::plotTubeIntegrals(int detid)
*/
void InstrumentWindowPickTab::setSelectionType()
{
ProjectionSurface::InteractionMode surfaceMode = ProjectionSurface::PickMode;
if (m_one->isChecked())
{
m_selectionType = Single;
m_activeTool->setText("Tool: Pixel selection");
}
else if (m_box->isChecked())
{
m_selectionType = BoxType;
m_activeTool->setText("Tool: Box selection");
}
else if (m_tube->isChecked())
{
m_selectionType = Tube;
......@@ -681,12 +607,21 @@ void InstrumentWindowPickTab::setSelectionType()
}
else if (m_peak->isChecked())
{
m_selectionType = Peak;
m_activeTool->setText("Tool: Single crystal peak selection");
m_selectionType = AddPeak;
m_activeTool->setText("Tool: Add a single crystal peak");
}
else if (m_peakSelect->isChecked())
{
m_selectionType = SelectPeak;
m_activeTool->setText("Tool: Select crystal peak(s)");
surfaceMode = ProjectionSurface::DrawMode;
}
ProjectionSurface* surface = m_instrWindow->getSurface();
if ( surface ) surface->setInteractionMode( surfaceMode );
m_plot->clearAll();
m_plot->replot();
setPlotCaption();
m_instrWindow->updateInstrumentView();
}
/**
......@@ -763,7 +698,7 @@ void InstrumentWindowPickTab::showEvent (QShowEvent *)
ProjectionSurface* surface = mInstrumentDisplay->getSurface();
if (surface)
{
surface->setInteractionModePick();
surface->setInteractionMode(ProjectionSurface::PickMode);
}
mInstrumentDisplay->setMouseTracking(true);
}
......@@ -1206,7 +1141,7 @@ void InstrumentWindowPickTab::changedIntegrationRange(double,double)
*/
void InstrumentWindowPickTab::mouseLeftInstrmentDisplay()
{
if (m_selectionType != Peak)
if (m_selectionType < SelectPeak)
{
updatePick(-1);
}
......
#ifndef INSTRUMENTWINDOWPICKTAB_H_
#define INSTRUMENTWINDOWPICKTAB_H_
#include "InstrumentWindowTab.h"
#include "MantidGLWidget.h"
#include "DetSelector.h"
#include "MantidGeometry/ICompAssembly.h"
#include "MantidAPI/MatrixWorkspace.h"
#include <QFrame>