QXRD  0.11.16
Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
QxrdCalibrantDialog Class Reference

#include <qxrdcalibrantdialog.h>

Inheritance diagram for QxrdCalibrantDialog:
Inheritance graph
[legend]
Collaboration diagram for QxrdCalibrantDialog:
Collaboration graph
[legend]

Public Slots

void calibrantTableContextMenu (const QPoint &pos)
 
void calibrantDSpacingsContextMenu (const QPoint &pos)
 
void onCalibrantChanged ()
 
void onCalibrantClick (const QModelIndex &item)
 
void onCalibrantDoubleClick (const QModelIndex &item)
 

Public Member Functions

 QxrdCalibrantDialog (QxrdExperimentPtr expt, QxrdCenterFinderWPtr cf)
 
virtual ~QxrdCalibrantDialog ()
 

Private Member Functions

void doCopyFromTable (QTableView *table)
 
void doDuplicateCalibrant (int n)
 
void doDeleteCalibrant (int n)
 
void doCalibrantProperties (int n)
 

Private Attributes

QxrdExperimentWPtr m_Experiment
 
QxrdCenterFinderWPtr m_CenterFinder
 
QxrdCalibrantLibraryWPtr m_CalibrantLibrary
 
QxrdCalibrantLibraryModelWPtr m_CalibrantLibraryModel
 
QxrdCalibrantDSpacingsModelWPtr m_CalibrantDSpacingsModel
 
QxrdCalibrantDSpacingsWPtr m_CalibrantDSpacings
 

Detailed Description

Definition at line 14 of file qxrdcalibrantdialog.h.

Constructor & Destructor Documentation

QxrdCalibrantDialog::QxrdCalibrantDialog ( QxrdExperimentPtr  expt,
QxrdCenterFinderWPtr  cf 
)

Definition at line 14 of file qxrdcalibrantdialog.cpp.

References calibrantDSpacingsContextMenu(), calibrantTableContextMenu(), m_CalibrantDSpacings, m_CalibrantDSpacingsModel, m_CalibrantLibrary, m_CalibrantLibraryModel, m_CenterFinder, m_Experiment, onCalibrantChanged(), onCalibrantClick(), onCalibrantDoubleClick(), and QcepDoubleProperty::valueChanged().

14  :
15  QDockWidget(),
16  m_Experiment(expt),
17  m_CenterFinder(cf)
18 {
19  setupUi(this);
20 
23 
24  if (cfp && exp) {
25  m_CalibrantLibrary = exp->calibrantLibrary();
26  m_CalibrantLibraryModel = exp->calibrantLibraryModel();
27 
28  m_CalibrantDSpacings = exp->calibrantDSpacings();
29  m_CalibrantDSpacingsModel = exp->calibrantDSpacingsModel();
30  }
31 
34 
35  if (lib && dsp) {
36  m_CalibrantTableView -> setModel(lib.data());
37  m_CalibrantDSpacingsView -> setModel(dsp.data());
38  }
39 
40  m_CalibrantTableView->horizontalHeader()->setStretchLastSection(true);
41  m_CalibrantDSpacingsView->horizontalHeader()->setStretchLastSection(true);
42 
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);
48 #else
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);
53 #endif
54 
55  connect(m_CalibrantTableView, &QTableView::customContextMenuRequested, this, &QxrdCalibrantDialog::calibrantTableContextMenu);
56  connect(m_CalibrantDSpacingsView, &QTableView::customContextMenuRequested, this, &QxrdCalibrantDialog::calibrantDSpacingsContextMenu);
57 
58  connect(m_CalibrantTableView, &QTableView::clicked, this, &QxrdCalibrantDialog::onCalibrantClick);
59  connect(m_CalibrantTableView, &QTableView::doubleClicked, this, &QxrdCalibrantDialog::onCalibrantDoubleClick);
60 
61  connect(lib.data(), &QAbstractItemModel::dataChanged,
63 
64  if (cfp) {
65  connect(cfp->prop_Energy(), &QcepDoubleProperty::valueChanged,
67  }
68 
70 }
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdExperimentWPtr m_Experiment
QSharedPointer< QxrdCalibrantLibraryModel > QxrdCalibrantLibraryModelPtr
QxrdCalibrantDSpacingsModelWPtr m_CalibrantDSpacingsModel
QxrdCalibrantDSpacingsWPtr m_CalibrantDSpacings
QSharedPointer< QxrdCalibrantDSpacingsModel > QxrdCalibrantDSpacingsModelPtr
QxrdCalibrantLibraryModelWPtr m_CalibrantLibraryModel
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 calibrantTableContextMenu(const QPoint &pos)

Here is the call graph for this function:

QxrdCalibrantDialog::~QxrdCalibrantDialog ( )
virtual

Definition at line 72 of file qxrdcalibrantdialog.cpp.

73 {
74 }

Member Function Documentation

void QxrdCalibrantDialog::calibrantDSpacingsContextMenu ( const QPoint &  pos)
slot

Definition at line 141 of file qxrdcalibrantdialog.cpp.

References doCopyFromTable().

Referenced by QxrdCalibrantDialog().

142 {
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));
147 
148  if (chosen == copy) {
149  doCopyFromTable(m_CalibrantDSpacingsView);
150  }
151 }
void doCopyFromTable(QTableView *table)

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdCalibrantDialog::calibrantTableContextMenu ( const QPoint &  pos)
slot

Definition at line 101 of file qxrdcalibrantdialog.cpp.

References doCalibrantProperties(), doCopyFromTable(), doDeleteCalibrant(), doDuplicateCalibrant(), and m_CalibrantLibrary.

Referenced by QxrdCalibrantDialog().

102 {
103  QModelIndex index = m_CalibrantTableView->indexAt(pos);
105  QxrdCalibrantPtr cal;
106 
107  if (index.isValid() && lib) {
108  cal = lib->calibrant(index.row());
109  }
110 
111  QMenu *menu = new QMenu(this);
112  QAction *copy = menu->addAction("Copy");
113  QAction *dupe = NULL;
114  QAction *props = NULL;
115  QAction *del = NULL;
116 
117  if (cal) {
118  dupe = menu->addAction(tr("Duplicate Calibrant %1").arg(cal->get_Name()));
119  props = menu->addAction(tr("Calibrant %1 Properties...").arg(cal->get_Name()));
120 
121  if (!cal->isLocked()) {
122  del = menu->addAction(tr("Delete Calibrant %1...").arg(cal->get_Name()));
123  }
124  }
125 
126  QAction *chosen = menu->exec(m_CalibrantTableView->viewport()->mapToGlobal(pos));
127 
128  if (chosen) {
129  if (chosen == copy) {
130  doCopyFromTable(m_CalibrantTableView);
131  } else if (chosen == dupe) {
132  doDuplicateCalibrant(index.row());
133  } else if (chosen == props) {
134  doCalibrantProperties(index.row());
135  } else if (chosen == del) {
136  doDeleteCalibrant(index.row());
137  }
138  }
139 }
void doCopyFromTable(QTableView *table)
QSharedPointer< QxrdCalibrantLibrary > QxrdCalibrantLibraryPtr
QSharedPointer< QxrdCalibrant > QxrdCalibrantPtr
QxrdCalibrantLibraryWPtr m_CalibrantLibrary

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdCalibrantDialog::doCalibrantProperties ( int  n)
private

Definition at line 241 of file qxrdcalibrantdialog.cpp.

References m_CalibrantLibrary, and m_CalibrantLibraryModel.

Referenced by calibrantTableContextMenu().

242 {
245 
246  if (lib && mdl) {
247  QxrdCalibrantPtr cal = lib->calibrant(n);
248 
249  QxrdCalibrantPropertiesDialog dlg(this, cal);
250 
251  if (dlg.exec() == QDialog::Accepted) {
252  mdl->calibrantChanged(n);
253  }
254  }
255 }
QSharedPointer< QxrdCalibrantLibraryModel > QxrdCalibrantLibraryModelPtr
QSharedPointer< QxrdCalibrantLibrary > QxrdCalibrantLibraryPtr
QSharedPointer< QxrdCalibrant > QxrdCalibrantPtr
QxrdCalibrantLibraryModelWPtr m_CalibrantLibraryModel
QxrdCalibrantLibraryWPtr m_CalibrantLibrary

Here is the caller graph for this function:

void QxrdCalibrantDialog::doCopyFromTable ( QTableView *  table)
private

Definition at line 153 of file qxrdcalibrantdialog.cpp.

Referenced by calibrantDSpacingsContextMenu(), and calibrantTableContextMenu().

154 {
155  QAbstractItemModel *model = table->model();
156  QItemSelectionModel *selected = table->selectionModel();
157 
158  int nRows = model->rowCount();
159  int nCols = model->columnCount();
160 
161  int firstRowSel = -1, lastRowSel = -1;
162  int firstColSel = -1, lastColSel = -1;
163 
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) {
168  firstRowSel = row;
169  }
170 
171  if (firstColSel == -1 || firstColSel > col) {
172  firstColSel = col;
173  }
174 
175  if (lastRowSel == -1 || lastRowSel < row) {
176  lastRowSel = row;
177  }
178 
179  if (lastColSel == -1 || lastColSel < col) {
180  lastColSel = col;
181  }
182  }
183  }
184  }
185 
186  if (firstRowSel >= 0 && lastRowSel >= 0 && firstColSel >= 0 && lastColSel >= 0) {
187  QString result;
188 
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())) {
193  result.append("\t");
194  }
195  }
196 
197  if (selected->isSelected(model->index(row,col))) {
198  result.append(model->data(model->index(row,col)).toString());
199  }
200  }
201 
202  result.append("\n");
203  }
204 
205  QClipboard *clip = QApplication::clipboard();
206 
207  clip->setText(result);
208  } else {
209  printf("No cells selected\n");
210  }
211 }

Here is the caller graph for this function:

void QxrdCalibrantDialog::doDeleteCalibrant ( int  n)
private

Definition at line 236 of file qxrdcalibrantdialog.cpp.

Referenced by calibrantTableContextMenu().

237 {
238  printf("Delete Calibrant %d\n", n);
239 }

Here is the caller graph for this function:

void QxrdCalibrantDialog::doDuplicateCalibrant ( int  n)
private

Definition at line 231 of file qxrdcalibrantdialog.cpp.

Referenced by calibrantTableContextMenu().

232 {
233  printf("Duplicate Calibrant %d\n", n);
234 }

Here is the caller graph for this function:

void QxrdCalibrantDialog::onCalibrantChanged ( )
slot

Definition at line 77 of file qxrdcalibrantdialog.cpp.

References m_CalibrantDSpacings, m_CalibrantDSpacingsModel, m_CalibrantLibrary, and m_CenterFinder.

Referenced by QxrdCalibrantDialog().

78 {
83 
84  if (lib && dsp && cf && model) {
85  double energy = cf->get_Energy();
86 
87  dsp->clear();
88 
89  for (int i=0; i<lib->count(); i++) {
90  QxrdCalibrantPtr cal = lib->calibrant(i);
91 
92  if (cal && cal->get_IsUsed()) {
93  dsp->merge(cal->dSpacings(energy));
94  }
95  }
96 
97  model -> everythingChanged(dsp->count());
98  }
99 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCalibrantDSpacingsModelWPtr m_CalibrantDSpacingsModel
QxrdCalibrantDSpacingsWPtr m_CalibrantDSpacings
QSharedPointer< QxrdCalibrantLibrary > QxrdCalibrantLibraryPtr
QSharedPointer< QxrdCalibrantDSpacingsModel > QxrdCalibrantDSpacingsModelPtr
QSharedPointer< QxrdCalibrant > QxrdCalibrantPtr
QSharedPointer< QxrdCalibrantDSpacings > QxrdCalibrantDSpacingsPtr
QxrdCalibrantLibraryWPtr m_CalibrantLibrary
QxrdCenterFinderWPtr m_CenterFinder

Here is the caller graph for this function:

void QxrdCalibrantDialog::onCalibrantClick ( const QModelIndex &  item)
slot

Definition at line 213 of file qxrdcalibrantdialog.cpp.

Referenced by QxrdCalibrantDialog().

214 {
215 // printf("Single click [%d,%d]\n", item.column(), item.row());
216 }

Here is the caller graph for this function:

void QxrdCalibrantDialog::onCalibrantDoubleClick ( const QModelIndex &  item)
slot

Definition at line 218 of file qxrdcalibrantdialog.cpp.

References m_CalibrantLibraryModel.

Referenced by QxrdCalibrantDialog().

219 {
220 // printf("Double click [%d,%d]\n", item.column(), item.row());
221 
222  if (item.column() == 0) {
224 
225  if (lib) {
226  lib->toggleIsUsed(item.row());
227  }
228  }
229 }
QSharedPointer< QxrdCalibrantLibraryModel > QxrdCalibrantLibraryModelPtr
QxrdCalibrantLibraryModelWPtr m_CalibrantLibraryModel

Here is the caller graph for this function:

Member Data Documentation

QxrdCalibrantDSpacingsWPtr QxrdCalibrantDialog::m_CalibrantDSpacings
private

Definition at line 43 of file qxrdcalibrantdialog.h.

Referenced by onCalibrantChanged(), and QxrdCalibrantDialog().

QxrdCalibrantDSpacingsModelWPtr QxrdCalibrantDialog::m_CalibrantDSpacingsModel
private

Definition at line 42 of file qxrdcalibrantdialog.h.

Referenced by onCalibrantChanged(), and QxrdCalibrantDialog().

QxrdCalibrantLibraryWPtr QxrdCalibrantDialog::m_CalibrantLibrary
private
QxrdCalibrantLibraryModelWPtr QxrdCalibrantDialog::m_CalibrantLibraryModel
private
QxrdCenterFinderWPtr QxrdCalibrantDialog::m_CenterFinder
private

Definition at line 39 of file qxrdcalibrantdialog.h.

Referenced by onCalibrantChanged(), and QxrdCalibrantDialog().

QxrdExperimentWPtr QxrdCalibrantDialog::m_Experiment
private

Definition at line 38 of file qxrdcalibrantdialog.h.

Referenced by QxrdCalibrantDialog().


The documentation for this class was generated from the following files: