2 #include "ui_qxrdcalibrantdialog.h"
36 m_CalibrantTableView -> setModel(lib.data());
37 m_CalibrantDSpacingsView -> setModel(dsp.data());
40 m_CalibrantTableView->horizontalHeader()->setStretchLastSection(
true);
41 m_CalibrantDSpacingsView->horizontalHeader()->setStretchLastSection(
true);
43 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
44 m_CalibrantTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
45 m_CalibrantTableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
46 m_CalibrantDSpacingsView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
47 m_CalibrantDSpacingsView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
49 m_CalibrantTableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
50 m_CalibrantTableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
51 m_CalibrantDSpacingsView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
52 m_CalibrantDSpacingsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
61 connect(lib.data(), &QAbstractItemModel::dataChanged,
84 if (lib && dsp && cf && model) {
85 double energy = cf->get_Energy();
89 for (
int i=0; i<lib->count(); i++) {
92 if (cal && cal->get_IsUsed()) {
93 dsp->merge(cal->dSpacings(energy));
97 model -> everythingChanged(dsp->count());
103 QModelIndex index = m_CalibrantTableView->indexAt(pos);
107 if (index.isValid() && lib) {
108 cal = lib->calibrant(index.row());
111 QMenu *menu =
new QMenu(
this);
112 QAction *copy = menu->addAction(
"Copy");
113 QAction *dupe = NULL;
114 QAction *props = NULL;
118 dupe = menu->addAction(tr(
"Duplicate Calibrant %1").arg(cal->get_Name()));
119 props = menu->addAction(tr(
"Calibrant %1 Properties...").arg(cal->get_Name()));
121 if (!cal->isLocked()) {
122 del = menu->addAction(tr(
"Delete Calibrant %1...").arg(cal->get_Name()));
126 QAction *chosen = menu->exec(m_CalibrantTableView->viewport()->mapToGlobal(pos));
129 if (chosen == copy) {
131 }
else if (chosen == dupe) {
133 }
else if (chosen == props) {
135 }
else if (chosen == del) {
143 QModelIndex index = m_CalibrantDSpacingsView->indexAt(pos);
144 QMenu *menu =
new QMenu(
this);
145 QAction *copy = menu->addAction(
"Copy");
146 QAction *chosen = menu->exec(m_CalibrantDSpacingsView->viewport()->mapToGlobal(pos));
148 if (chosen == copy) {
155 QAbstractItemModel *model = table->model();
156 QItemSelectionModel *selected = table->selectionModel();
158 int nRows = model->rowCount();
159 int nCols = model->columnCount();
161 int firstRowSel = -1, lastRowSel = -1;
162 int firstColSel = -1, lastColSel = -1;
164 for (
int row = 0; row<nRows; row++) {
165 for (
int col = 0; col<nCols; col++) {
166 if (selected->isSelected(model->index(row, col))) {
167 if (firstRowSel == -1 || firstRowSel > row) {
171 if (firstColSel == -1 || firstColSel > col) {
175 if (lastRowSel == -1 || lastRowSel < row) {
179 if (lastColSel == -1 || lastColSel < col) {
186 if (firstRowSel >= 0 && lastRowSel >= 0 && firstColSel >= 0 && lastColSel >= 0) {
189 for (
int row = firstRowSel; row <= lastRowSel; row++) {
190 for (
int col = firstColSel; col <= lastColSel; col++) {
191 if (col != firstColSel) {
192 if (selected->columnIntersectsSelection(col,QModelIndex())) {
197 if (selected->isSelected(model->index(row,col))) {
198 result.append(model->data(model->index(row,col)).toString());
205 QClipboard *clip = QApplication::clipboard();
207 clip->setText(result);
209 printf(
"No cells selected\n");
222 if (item.column() == 0) {
226 lib->toggleIsUsed(item.row());
233 printf(
"Duplicate Calibrant %d\n", n);
238 printf(
"Delete Calibrant %d\n", n);
251 if (dlg.exec() == QDialog::Accepted) {
252 mdl->calibrantChanged(n);
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdExperimentWPtr m_Experiment
QSharedPointer< QxrdCalibrantLibraryModel > QxrdCalibrantLibraryModelPtr
void doCopyFromTable(QTableView *table)
QWeakPointer< QxrdCenterFinder > QxrdCenterFinderWPtr
virtual ~QxrdCalibrantDialog()
QxrdCalibrantDSpacingsModelWPtr m_CalibrantDSpacingsModel
QxrdCalibrantDialog(QxrdExperimentPtr expt, QxrdCenterFinderWPtr cf)
QxrdCalibrantDSpacingsWPtr m_CalibrantDSpacings
void onCalibrantChanged()
QSharedPointer< QxrdCalibrantLibrary > QxrdCalibrantLibraryPtr
void doCalibrantProperties(int n)
QSharedPointer< QxrdCalibrantDSpacingsModel > QxrdCalibrantDSpacingsModelPtr
QSharedPointer< QxrdCalibrant > QxrdCalibrantPtr
QxrdCalibrantLibraryModelWPtr m_CalibrantLibraryModel
QSharedPointer< QxrdCalibrantDSpacings > QxrdCalibrantDSpacingsPtr
void onCalibrantClick(const QModelIndex &item)
void onCalibrantDoubleClick(const QModelIndex &item)
void calibrantDSpacingsContextMenu(const QPoint &pos)
void valueChanged(double val, int index)
QxrdCalibrantLibraryWPtr m_CalibrantLibrary
QxrdCenterFinderWPtr m_CenterFinder
void doDuplicateCalibrant(int n)
void calibrantTableContextMenu(const QPoint &pos)
void doDeleteCalibrant(int n)