diff --git a/Code/Mantid/Images/images.qrc b/Code/Mantid/Images/images.qrc index b8526a8c993200ff784f45fc81e23078f9d8bcb7..4e5c74805b979a99b8dfd37b656a1aa1500019a4 100644 --- a/Code/Mantid/Images/images.qrc +++ b/Code/Mantid/Images/images.qrc @@ -1,13 +1,20 @@ <RCC> - <qresource> - <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="/"> + <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="/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> + </qresource> </RCC> diff --git a/Code/Mantid/Images/selection-box.png b/Code/Mantid/Images/selection-box.png new file mode 100644 index 0000000000000000000000000000000000000000..2bf6ad9cba5001328ed1adf4ac2edb5874fa4b26 Binary files /dev/null and b/Code/Mantid/Images/selection-box.png differ diff --git a/Code/Mantid/Images/selection-circle.png b/Code/Mantid/Images/selection-circle.png new file mode 100644 index 0000000000000000000000000000000000000000..950949395d4b113db2e272a9bbeb185eb513dd71 Binary files /dev/null and b/Code/Mantid/Images/selection-circle.png differ diff --git a/Code/Mantid/Images/selection-pointer.png b/Code/Mantid/Images/selection-pointer.png new file mode 100644 index 0000000000000000000000000000000000000000..0a08298a6e292d0f0fefee99fc00a6b8c9aaf67f Binary files /dev/null and b/Code/Mantid/Images/selection-pointer.png differ diff --git a/Code/Mantid/Images/selection-text.png b/Code/Mantid/Images/selection-text.png new file mode 100644 index 0000000000000000000000000000000000000000..a499a50a9dfeb7f86fbbf17fba52717d69e8a7dd Binary files /dev/null and b/Code/Mantid/Images/selection-text.png differ diff --git a/Code/Mantid/Images/selection-tube.png b/Code/Mantid/Images/selection-tube.png new file mode 100644 index 0000000000000000000000000000000000000000..44013fa23ae71f5c88b9e8ec0e271fa7dfd20f0e Binary files /dev/null and b/Code/Mantid/Images/selection-tube.png differ diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp index 31db3e08393a5985ec0a3f1f06afaf28a6538d40..133840bd459c79d50bf65fd6cd0daae830604fd5 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp @@ -47,7 +47,7 @@ InstrumentWindow::InstrumentWindow(const QString& label, ApplicationWindow *app QSplitter* controlPanelLayout = new QSplitter(Qt::Horizontal); //Add Tab control panel and Render window - mControlsTab = new QTabWidget(0,0); + mControlsTab = new QTabWidget(this,0); controlPanelLayout->addWidget(mControlsTab); controlPanelLayout->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); @@ -112,7 +112,15 @@ InstrumentWindow::InstrumentWindow(const QString& label, ApplicationWindow *app connect(app->mantidUI->getAlgMinitor(),SIGNAL(algorithmStarted(void*)),this,SLOT(block())); connect(app->mantidUI->getAlgMinitor(),SIGNAL(allAlgorithmsStopped()),this,SLOT(unblock())); - resize(600,650); + const int windowWidth = 600; + const int tabsSize = windowWidth / 3; + QList<int> sizes; + sizes << tabsSize << windowWidth - tabsSize; + controlPanelLayout->setSizes(sizes); + controlPanelLayout->setStretchFactor(0,0); + controlPanelLayout->setStretchFactor(1,1); + + resize(windowWidth,650); } /** diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp index 06dda3e965181ce09ff7fedce213a71f324f05b1..09fded25ead92744ab3896086f404221172b8573 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.cpp @@ -49,18 +49,30 @@ QFrame(instrWindow),m_instrWindow(instrWindow) m_plotPanel = panelStack->addPanel("Name",m_plot); // set up the tool bar - m_one = new QPushButton("One"); + m_one = new QPushButton(); m_one->setCheckable(true); m_one->setAutoExclusive(true); m_one->setChecked(true); - m_many = new QPushButton("Many"); - m_many->setCheckable(true); - m_many->setAutoExclusive(true); + + 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); + m_tube->setIcon(QIcon(":/PickTools/selection-tube.png")); QHBoxLayout* toolBox = new QHBoxLayout(); toolBox->addWidget(m_one); - toolBox->addWidget(m_many); - connect(m_one,SIGNAL(clicked()),this,SLOT(setPlotCaption())); - connect(m_many,SIGNAL(clicked()),this,SLOT(setPlotCaption())); + toolBox->addWidget(m_box); + toolBox->addWidget(m_tube); + 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())); + setSelectionType(); // lay out the widgets layout->addLayout(toolBox); @@ -83,90 +95,11 @@ void InstrumentWindowPickTab::updatePlot(const Instrument3DWidget::DetInfo & cur { if (m_one->isChecked()) {// plot spectrum of a single detector - const Mantid::MantidVec& x = ws->readX(wi); - const Mantid::MantidVec& y = ws->readY(wi); - m_plot->setXScale(x.front(),x.back()); - Mantid::MantidVec::const_iterator min_it = std::min_element(y.begin(),y.end()); - Mantid::MantidVec::const_iterator max_it = std::max_element(y.begin(),y.end()); - m_plot->setData(&x[0],&y[0],y.size()); - m_plot->setYScale(*min_it,*max_it); + plotSingle(cursorPos); } else {// plot integrals - Mantid::Geometry::IDetector_sptr det = ws->getInstrument()->getDetector(cursorPos.getDetID()); - boost::shared_ptr<const Mantid::Geometry::IComponent> parent = det->getParent(); - Mantid::Geometry::ICompAssembly_const_sptr ass = boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>(parent); - if (parent && ass) - { - const int n = ass->nelements(); - if (m_plotSum) // plot sums over detectors vs time bins - { - const Mantid::MantidVec& x = ws->readX(wi); - m_plot->setXScale(x.front(),x.back()); - std::vector<double> y(ws->blocksize()); - //std::cerr<<"plotting sum of " << ass->nelements() << " detectors\n"; - for(int i = 0; i < n; ++i) - { - Mantid::Geometry::IDetector_sptr idet = boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[i]); - if (idet) - { - int index = cursorPos.getIndexOf(idet->getID()); - if (index >= 0) - { - const Mantid::MantidVec& Y = ws->readY(index); - std::transform(y.begin(),y.end(),Y.begin(),y.begin(),std::plus<double>()); - } - } - } - Mantid::MantidVec::const_iterator min_it = std::min_element(y.begin(),y.end()); - Mantid::MantidVec::const_iterator max_it = std::max_element(y.begin(),y.end()); - m_plot->setData(&x[0],&y[0],y.size()); - m_plot->setYScale(*min_it,*max_it); - } - else // plot detector integrals vs detID - { - std::vector<double> x; - x.reserve(n); - std::map<double,double> ymap; - for(int i = 0; i < n; ++i) - { - Mantid::Geometry::IDetector_sptr idet = boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[i]); - if (idet) - { - const int id = idet->getID(); - int index = cursorPos.getIndexOf(id); - if (index >= 0) - { - x.push_back(id); - const Mantid::MantidVec& Y = ws->readY(index); - double sum = std::accumulate(Y.begin(),Y.end(),0); - ymap[id] = sum; - } - } - } - if (!x.empty()) - { - std::sort(x.begin(),x.end()); - std::vector<double> y(x.size()); - double ymin = DBL_MAX; - double ymax = -DBL_MAX; - for(int i = 0; i < x.size(); ++i) - { - const double val = ymap[x[i]]; - y[i] = val; - if (val < ymin) ymin = val; - if (val > ymax) ymax = val; - } - m_plot->setData(&x[0],&y[0],y.size()); - m_plot->setXScale(x.front(),x.back()); - m_plot->setYScale(ymin,ymax); - } - } - } - else - { - m_plot->clearCurve(); - } + plotTube(cursorPos); } } else @@ -227,7 +160,7 @@ void InstrumentWindowPickTab::plotContextMenu() void InstrumentWindowPickTab::setPlotCaption() { QString caption; - if (m_one->isChecked()) + if (m_selectionType == Single) { caption = "Plotting detector spectra"; } @@ -259,3 +192,117 @@ void InstrumentWindowPickTab::updatePick(const Instrument3DWidget::DetInfo & cur updatePlot(cursorPos); updateSelectionInfo(cursorPos); } + +void InstrumentWindowPickTab::plotSingle(const Instrument3DWidget::DetInfo & cursorPos) +{ + Mantid::API::MatrixWorkspace_const_sptr ws = cursorPos.getWorkspace(); + int wi = cursorPos.getWorkspaceIndex(); + const Mantid::MantidVec& x = ws->readX(wi); + const Mantid::MantidVec& y = ws->readY(wi); + m_plot->setXScale(x.front(),x.back()); + Mantid::MantidVec::const_iterator min_it = std::min_element(y.begin(),y.end()); + Mantid::MantidVec::const_iterator max_it = std::max_element(y.begin(),y.end()); + m_plot->setData(&x[0],&y[0],y.size()); + m_plot->setYScale(*min_it,*max_it); +} + +void InstrumentWindowPickTab::plotBox(const Instrument3DWidget::DetInfo & cursorPos) +{ +} + +void InstrumentWindowPickTab::plotTube(const Instrument3DWidget::DetInfo & cursorPos) +{ + Mantid::API::MatrixWorkspace_const_sptr ws = cursorPos.getWorkspace(); + int wi = cursorPos.getWorkspaceIndex(); + Mantid::Geometry::IDetector_sptr det = ws->getInstrument()->getDetector(cursorPos.getDetID()); + boost::shared_ptr<const Mantid::Geometry::IComponent> parent = det->getParent(); + Mantid::Geometry::ICompAssembly_const_sptr ass = boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>(parent); + if (parent && ass) + { + const int n = ass->nelements(); + if (m_plotSum) // plot sums over detectors vs time bins + { + const Mantid::MantidVec& x = ws->readX(wi); + m_plot->setXScale(x.front(),x.back()); + std::vector<double> y(ws->blocksize()); + //std::cerr<<"plotting sum of " << ass->nelements() << " detectors\n"; + for(int i = 0; i < n; ++i) + { + Mantid::Geometry::IDetector_sptr idet = boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[i]); + if (idet) + { + int index = cursorPos.getIndexOf(idet->getID()); + if (index >= 0) + { + const Mantid::MantidVec& Y = ws->readY(index); + std::transform(y.begin(),y.end(),Y.begin(),y.begin(),std::plus<double>()); + } + } + } + Mantid::MantidVec::const_iterator min_it = std::min_element(y.begin(),y.end()); + Mantid::MantidVec::const_iterator max_it = std::max_element(y.begin(),y.end()); + m_plot->setData(&x[0],&y[0],y.size()); + m_plot->setYScale(*min_it,*max_it); + } + else // plot detector integrals vs detID + { + std::vector<double> x; + x.reserve(n); + std::map<double,double> ymap; + for(int i = 0; i < n; ++i) + { + Mantid::Geometry::IDetector_sptr idet = boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[i]); + if (idet) + { + const int id = idet->getID(); + int index = cursorPos.getIndexOf(id); + if (index >= 0) + { + x.push_back(id); + const Mantid::MantidVec& Y = ws->readY(index); + double sum = std::accumulate(Y.begin(),Y.end(),0); + ymap[id] = sum; + } + } + } + if (!x.empty()) + { + std::sort(x.begin(),x.end()); + std::vector<double> y(x.size()); + double ymin = DBL_MAX; + double ymax = -DBL_MAX; + for(int i = 0; i < x.size(); ++i) + { + const double val = ymap[x[i]]; + y[i] = val; + if (val < ymin) ymin = val; + if (val > ymax) ymax = val; + } + m_plot->setData(&x[0],&y[0],y.size()); + m_plot->setXScale(x.front(),x.back()); + m_plot->setYScale(ymin,ymax); + } + } + } + else + { + m_plot->clearCurve(); + } +} + +void InstrumentWindowPickTab::setSelectionType() +{ + if (m_one->isChecked()) + { + m_selectionType = Single; + } + else if (m_box->isChecked()) + { + m_selectionType = Box; + } + else if (m_tube->isChecked()) + { + m_selectionType = Tube; + } + setPlotCaption(); +} diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h index 3426dfe378a3c458b195681d75665d50fd7569ec..a99c63761a4ead87a2b6db5815f0f35242445a3f 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h @@ -22,6 +22,7 @@ class InstrumentWindowPickTab: public QFrame { Q_OBJECT public: + enum SelectionType {Single,Box,Tube}; InstrumentWindowPickTab(InstrumentWindow* instrWindow); void updatePick(const Instrument3DWidget::DetInfo & cursorPos); private slots: @@ -29,16 +30,21 @@ private slots: void sumDetectors(); void integrateTimeBins(); void setPlotCaption(); + void setSelectionType(); private: void updatePlot(const Instrument3DWidget::DetInfo & cursorPos); void updateSelectionInfo(const Instrument3DWidget::DetInfo & cursorPos); + void plotSingle(const Instrument3DWidget::DetInfo & cursorPos); + void plotBox(const Instrument3DWidget::DetInfo & cursorPos); + void plotTube(const Instrument3DWidget::DetInfo & cursorPos); InstrumentWindow* m_instrWindow; Instrument3DWidget *mInstrumentDisplay; /* Pick tab controls */ OneCurvePlot* m_plot; QPushButton *m_one; ///< Button switching on single detector selection mode - QPushButton *m_many; ///< Botton switching on detector's parent selection mode + QPushButton *m_tube; ///< Button switching on detector's parent selection mode + QPushButton *m_box; ///< Button switching on box selection mode bool m_plotSum; // Actions to set integration option for the detector's parent selection mode QAction *m_sumDetectors; ///< Sets summation over detectors (m_plotSum = true) @@ -48,6 +54,7 @@ private: CollapsiblePanel* m_plotPanel; QTextEdit* m_selectionInfoDisplay; ///< Text control for displaying selection information CollapsiblePanel* m_infoPanel; + SelectionType m_selectionType; };