From c1c9701ca2231915ac6853dd96b44abe652bb20e Mon Sep 17 00:00:00 2001 From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk> Date: Mon, 4 Feb 2013 10:52:52 +0000 Subject: [PATCH] Added tool tips, changed the buttons. Re #6160. --- Code/Mantid/Images/images.qrc | 29 ++++--- Code/Mantid/Images/selection-box-ring.png | Bin 0 -> 993 bytes Code/Mantid/Images/selection-circle-ring.png | Bin 0 -> 984 bytes .../InstrumentWindowMaskTab.cpp | 82 ++++++++++++++++-- .../InstrumentWindowMaskTab.h | 6 ++ 5 files changed, 97 insertions(+), 20 deletions(-) create mode 100644 Code/Mantid/Images/selection-box-ring.png create mode 100644 Code/Mantid/Images/selection-circle-ring.png diff --git a/Code/Mantid/Images/images.qrc b/Code/Mantid/Images/images.qrc index ea165a279b5..ff93a66fa52 100644 --- a/Code/Mantid/Images/images.qrc +++ b/Code/Mantid/Images/images.qrc @@ -11,20 +11,21 @@ <file>Mantid_Logo_Transparent.png</file> <file>data_replace.png</file> <file>panning.png</file> - </qresource> + </qresource> <qresource prefix="/win"> - <file>folder-remote.png</file> - <file>folder.png</file> - <file>document.png</file> - <file>office-document.png</file> - <file>txt_file.png</file> - <file>text-x-python.png</file> - <file>unknown.png</file> - <file>download.png</file> - <file>upload.png</file> - <file>system-software-update.png</file> - <file>dialog-ok.png</file> - <file>file_pdf.png</file> + <file>folder-remote.png</file> + <file>folder.png</file> + <file>document.png</file> + <file>office-document.png</file> + <file>txt_file.png</file> + <file>text-x-python.png</file> + <file>unknown.png</file> + <file>download.png</file> + <file>upload.png</file> + <file>system-software-update.png</file> + <file>dialog-ok.png</file> + <file>file_pdf.png</file> + <file>selection-circle-ring.png</file> </qresource> <qresource prefix="/Icons"> <file>LoadFile.png</file> @@ -43,5 +44,7 @@ <file>selection-pointer.png</file> <file>selection-circle.png</file> <file>selection-box.png</file> + <file>selection-box-ring.png</file> + <file>selection-circle-ring.png</file> </qresource> </RCC> diff --git a/Code/Mantid/Images/selection-box-ring.png b/Code/Mantid/Images/selection-box-ring.png new file mode 100644 index 0000000000000000000000000000000000000000..1e31d0f6c1c570eecea397ea66d87c284dbf4f97 GIT binary patch literal 993 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GA|hzm>B|mLR^7@ zET#WNi~lDt`d_@`f6dYV?Mp7Tthn2<;$Gv5M~9#M2Pzl^qaiR{Lm*!H!xW(37)yfu zf*Bm1-ADs*lDyqr7&=&GJ%Aj}0*}aI1_o|n5N2eUHAey{$X?><>&kwYiG@pv!&pOW z5m3n2)5S4F;_}o!My>+}9L%}Tv(EmPw@II?+w550D4^)kVP<hId`+uW=jlhjhn>6C zF2r_3Ke!l^cKDCKv*A9bS-lF+3i%#y-16*;YF#m7cP-P)cb98?fd(^py85}Sb4q9e E0J^bOO#lD@ literal 0 HcmV?d00001 diff --git a/Code/Mantid/Images/selection-circle-ring.png b/Code/Mantid/Images/selection-circle-ring.png new file mode 100644 index 0000000000000000000000000000000000000000..2bfd7e7f690194f874f85ded0dd750df14df9b37 GIT binary patch literal 984 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GA|hzm>B|mLR^7@ zEi3LFe)1p47zLvtFw#QckhD(*(9et|L4Lsu4$p3+fjCLt?k)@+tg;?J4rhT!WHAE+ zw=f7ZGR&GI0Tg5}@$_|NzstnJrOtgltUneg<l^b#7$R}GwBM7D!GMFQ^}qeDZH|jF zpDcQGL^Vm!KzrG&>8$I+YnMtYGP8-=b~9_R%&pk#cV!x5g>2@uT{-rDtJl3|a5rFR U{h++@4$wRXPgg&ebxsLQ06h3UrvLx| literal 0 HcmV?d00001 diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp index 399b639d474..d2dfc7b556d 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.cpp @@ -42,6 +42,7 @@ #include <QMessageBox> #include <QApplication> #include <QFileDialog> +#include <QToolTip> #include "MantidQtAPI/FileDialogHandler.h" @@ -88,13 +89,13 @@ m_userEditing(true) m_ring_ellipse = new QPushButton(); m_ring_ellipse->setCheckable(true); m_ring_ellipse->setAutoExclusive(true); - m_ring_ellipse->setIcon(QIcon(":/MaskTools/selection-circle.png")); + m_ring_ellipse->setIcon(QIcon(":/MaskTools/selection-circle-ring.png")); m_ring_ellipse->setToolTip("Draw an elliptical ring"); m_ring_rectangle = new QPushButton(); m_ring_rectangle->setCheckable(true); m_ring_rectangle->setAutoExclusive(true); - m_ring_rectangle->setIcon(QIcon(":/MaskTools/selection-box.png")); + m_ring_rectangle->setIcon(QIcon(":/MaskTools/selection-box-ring.png")); m_ring_rectangle->setToolTip("Draw a rectangular ring "); QHBoxLayout* toolBox = new QHBoxLayout(); @@ -136,7 +137,7 @@ m_userEditing(true) // Algorithm buttons - m_apply = new QPushButton("Apply"); + m_apply = new QPushButton("Apply Mask(s) to Workspace(data)"); m_apply->setToolTip("Apply current mask to the data workspace. Cannot be reverted."); connect(m_apply,SIGNAL(clicked()),this,SLOT(applyMask())); @@ -145,30 +146,47 @@ m_userEditing(true) connect(m_clear_all,SIGNAL(clicked()),this,SLOT(clearMask())); m_save_as_workspace_exclude = new QAction("As Mask to workspace",this); + m_save_as_workspace_exclude->setToolTip("Save current mask to mask workspace."); connect(m_save_as_workspace_exclude,SIGNAL(activated()),this,SLOT(saveMaskToWorkspace())); m_save_as_workspace_include = new QAction("As ROI to workspace",this); + m_save_as_workspace_include->setToolTip("Save current mask as ROI to mask workspace."); connect(m_save_as_workspace_include,SIGNAL(activated()),this,SLOT(saveInvertedMaskToWorkspace())); m_save_as_file_exclude = new QAction("As Mask to file",this); + m_save_as_file_exclude->setToolTip("Save current mask to mask file."); connect(m_save_as_file_exclude,SIGNAL(activated()),this,SLOT(saveMaskToFile())); m_save_as_file_include = new QAction("As ROI to file",this); + m_save_as_file_include->setToolTip("Save current mask as ROI to mask file."); connect(m_save_as_file_include,SIGNAL(activated()),this,SLOT(saveInvertedMaskToFile())); + m_save_as_cal_file_exclude = new QAction("As Mask to cal file",this); + m_save_as_cal_file_exclude->setToolTip("Save current mask to cal file."); + connect(m_save_as_cal_file_exclude,SIGNAL(activated()),this,SLOT(saveMaskToCalFile())); + + m_save_as_cal_file_include = new QAction("As ROI to cal file",this); + m_save_as_cal_file_include->setToolTip("Save current mask as ROI to cal file."); + connect(m_save_as_cal_file_include,SIGNAL(activated()),this,SLOT(saveInvertedMaskToCalFile())); + m_saveButton = new QPushButton("Save"); m_saveButton->setToolTip("Save current masking to a file or a workspace."); QMenu* saveMenu = new QMenu(this); saveMenu->addAction(m_save_as_workspace_include); saveMenu->addAction(m_save_as_workspace_exclude); + saveMenu->addSeparator(); saveMenu->addAction(m_save_as_file_include); saveMenu->addAction(m_save_as_file_exclude); + saveMenu->addSeparator(); + saveMenu->addAction(m_save_as_cal_file_include); + saveMenu->addAction(m_save_as_cal_file_exclude); + connect(saveMenu,SIGNAL(hovered(QAction*)),this,SLOT(showSaveMenuTooltip(QAction*))); m_saveButton->setMenu(saveMenu); QGridLayout* buttons = new QGridLayout(); - buttons->addWidget(m_apply,0,0); - buttons->addWidget(m_clear_all,0,1); - buttons->addWidget(m_saveButton,1,0,1,2); + buttons->addWidget(m_apply,0,0,1,2); + buttons->addWidget(m_saveButton,1,0); + buttons->addWidget(m_clear_all,1,1); layout->addLayout(buttons); @@ -453,7 +471,22 @@ void InstrumentWindowMaskTab::saveInvertedMaskToFile() void InstrumentWindowMaskTab::saveMaskToFile() { - saveMaskingToFile(false); + saveMaskingToFile(false); +} + +void InstrumentWindowMaskTab::saveMaskToCalFile() +{ + saveMaskingToCalFile(false); +} + +void InstrumentWindowMaskTab::saveInvertedMaskToCalFile() +{ + saveMaskingToCalFile(true); +} + +void InstrumentWindowMaskTab::showSaveMenuTooltip(QAction *action) +{ + QToolTip::showText(QCursor::pos(),action->toolTip(),this); } /** @@ -507,6 +540,41 @@ void InstrumentWindowMaskTab::saveMaskingToFile(bool invertMask) QApplication::restoreOverrideCursor(); } +/** + * Save the constructed mask to a cal file. + * The mask is not applied to the data workspace being displayed. + * @param invertMask :: if true, the selected mask will be inverted; if false, the mask will be used as is + */ +void InstrumentWindowMaskTab::saveMaskingToCalFile(bool invertMask) +{ + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + + // Make sure we have stored the Mask in the helper MaskWorkspace + storeMask(); + + setSelectActivity(); + Mantid::API::MatrixWorkspace_sptr outputWS = createMaskWorkspace(false,true); + if (outputWS) + { + clearShapes(); + QString saveDir = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("defaultsave.directory")); + QString fileName = QFileDialog::getSaveFileName(m_instrWindow,"Select location and name for the mask file",saveDir,"cal files (*.cal)"); + + std::cerr << "File " << fileName.toStdString() << std::endl; + + if (!fileName.isEmpty()) + { + Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("MaskWorkspaceToCalFile",-1); + alg->setPropertyValue("InputWorkspace",outputWS->name()); + alg->setPropertyValue("OutputFile",fileName.toStdString()); + alg->setProperty("Invert",invertMask); + alg->execute(); + } + Mantid::API::AnalysisDataService::Instance().remove( outputWS->name() ); + } + QApplication::restoreOverrideCursor(); +} + /** * Generate a unique name for the mask worspace which will be saved in the ADS. * It will have a form MaskWorkspace[_#] diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.h b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.h index cc6f79bbc5b..be27b529557 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.h +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowMaskTab.h @@ -65,6 +65,9 @@ protected slots: void saveInvertedMaskToFile(); void saveMaskToWorkspace(); void saveMaskToFile(); + void saveMaskToCalFile(); + void saveInvertedMaskToCalFile(); + void showSaveMenuTooltip(QAction*); void doubleChanged(QtProperty*); protected: @@ -75,6 +78,7 @@ protected: boost::shared_ptr<Mantid::API::MatrixWorkspace> createMaskWorkspace(bool invertMask, bool temp = false); void saveMaskingToWorkspace(bool invertMask = false); void saveMaskingToFile(bool invertMask = false); + void saveMaskingToCalFile(bool invertMask = false); std::string generateMaskWorkspaceName(bool temp = false) const; void enableApply(bool on); void enableClear(bool on); @@ -101,6 +105,8 @@ protected: QAction* m_save_as_workspace_exclude; QAction* m_save_as_file_include; QAction* m_save_as_file_exclude; + QAction* m_save_as_cal_file_include; + QAction* m_save_as_cal_file_exclude; // properties bool m_userEditing; -- GitLab