9#include "AbstractMeasureItem.h"
15#include "CnetDisplayProperties.h"
16#include "ControlMeasure.h"
17#include "ControlMeasureLogData.h"
18#include "ControlPoint.h"
19#include "IException.h"
22#include "TableColumn.h"
23#include "TableColumnList.h"
27 QString AbstractMeasureItem::getColumnName(Column col) {
44 return "Measure Type";
45 case Obsolete_Eccentricity:
46 return "Obsolete_Eccentricity";
48 return "Goodness of Fit";
50 return "Minimum Pixel Z-Score";
52 return "Maximum Pixel Z-Score";
54 return "Sample Shift";
58 return "Sample Sigma";
62 return "A Priori Sample";
64 return "A Priori Line";
68 return "Rejected by Jigsaw";
70 return "Residual Sample";
72 return "Residual Line";
73 case ResidualMagnitude:
74 return "Residual Magnitude";
81 AbstractMeasureItem::Column AbstractMeasureItem::getColumn(
82 QString columnTitle) {
83 for (
int i = 0; i < COLS; i++) {
84 if (columnTitle == getColumnName((Column) i))
88 QString msg =
"Column title [" + columnTitle +
"] does not match any of "
89 "the defined column types";
94 TableColumnList *AbstractMeasureItem::createColumns() {
95 TableColumnList *columnList =
new TableColumnList;
97 columnList->append(
new TableColumn(getColumnName(PointId),
true,
false));
98 columnList->append(
new TableColumn(getColumnName(ImageId),
true,
100 columnList->append(
new TableColumn(getColumnName(Sample),
true,
false));
101 columnList->append(
new TableColumn(getColumnName(Line),
true,
false));
102 columnList->append(
new TableColumn(getColumnName(EditLock),
false,
104 columnList->append(
new TableColumn(getColumnName(Ignored),
false,
true));
105 columnList->append(
new TableColumn(getColumnName(Reference),
true,
true));
106 columnList->append(
new TableColumn(getColumnName(Type),
false,
false));
107 columnList->append(
new TableColumn(getColumnName(Obsolete_Eccentricity),
true,
109 columnList->append(
new TableColumn(getColumnName(GoodnessOfFit),
true,
111 columnList->append(
new TableColumn(getColumnName(MinPixelZScore),
true,
113 columnList->append(
new TableColumn(getColumnName(MaxPixelZScore),
true,
115 columnList->append(
new TableColumn(getColumnName(SampleShift),
true,
117 columnList->append(
new TableColumn(getColumnName(LineShift),
true,
119 columnList->append(
new TableColumn(getColumnName(SampleSigma),
false,
121 columnList->append(
new TableColumn(getColumnName(LineSigma),
false,
123 columnList->append(
new TableColumn(getColumnName(APrioriSample),
true,
125 columnList->append(
new TableColumn(getColumnName(APrioriLine),
true,
127 columnList->append(
new TableColumn(getColumnName(Diameter),
false,
129 columnList->append(
new TableColumn(getColumnName(JigsawRejected),
true,
131 columnList->append(
new TableColumn(getColumnName(ResidualSample),
true,
133 columnList->append(
new TableColumn(getColumnName(ResidualLine),
true,
135 columnList->append(
new TableColumn(getColumnName(ResidualMagnitude),
141 AbstractMeasureItem::AbstractMeasureItem(ControlMeasure *cm,
142 int avgCharWidth, AbstractTreeItem *parent)
143 : AbstractTreeItem(parent) {
146 calcDataWidth(avgCharWidth);
148 connect(m_measure, SIGNAL(destroyed(
QObject *)),
this, SLOT(sourceDeleted()));
152 AbstractMeasureItem::~AbstractMeasureItem() {
157 QVariant AbstractMeasureItem::getData()
const {
158 return getData(getColumnName(ImageId));
162 QVariant AbstractMeasureItem::getData(QString columnTitle)
const {
164 Column column = getColumn(columnTitle);
166 switch ((Column) column) {
168 return QVariant((QString) m_measure->Parent()->GetId());
170 return QVariant(CnetDisplayProperties::getInstance()->getImageName(
171 (QString) m_measure->GetCubeSerialNumber()));
173 return QVariant(m_measure->GetSample());
175 return QVariant(m_measure->GetLine());
177 if (m_measure->IsEditLocked())
178 return QVariant(
"Yes");
180 return QVariant(
"No");
182 if (m_measure->IsIgnored())
183 return QVariant(
"Yes");
185 return QVariant(
"No");
187 if (m_measure->Parent()->GetRefMeasure() == m_measure)
188 return QVariant(
"Yes");
190 return QVariant(
"No");
193 (QString)m_measure->MeasureTypeToString(m_measure->GetType()));
194 case Obsolete_Eccentricity:
196 m_measure->GetLogData(
197 ControlMeasureLogData::Obsolete_Eccentricity).GetNumericalValue());
200 m_measure->GetLogData(
201 ControlMeasureLogData::GoodnessOfFit).GetNumericalValue());
204 m_measure->GetLogData(ControlMeasureLogData::MinimumPixelZScore).
205 GetNumericalValue());
208 m_measure->GetLogData(ControlMeasureLogData::MaximumPixelZScore).
209 GetNumericalValue());
211 return QVariant(m_measure->GetSampleShift());
213 return QVariant(m_measure->GetLineShift());
215 return QVariant(m_measure->GetSampleSigma());
217 return QVariant(m_measure->GetLineSigma());
219 return QVariant(m_measure->GetAprioriSample());
221 return QVariant(m_measure->GetAprioriLine());
223 return QVariant(m_measure->GetDiameter());
225 if (m_measure->IsRejected())
226 return QVariant(
"Yes");
228 return QVariant(
"No");
230 return QVariant(m_measure->GetSampleResidual());
232 return QVariant(m_measure->GetLineResidual());
233 case ResidualMagnitude:
235 m_measure->GetResidualMagnitude());
243 void AbstractMeasureItem::setData(QString
const &columnTitle,
244 QString
const &newData) {
246 Column column = getColumn(columnTitle);
248 switch ((Column) column) {
253 m_measure->SetCubeSerialNumber(
254 CnetDisplayProperties::getInstance()->getSerialNumber(newData));
257 m_measure->SetCoordinate(catchNull(newData),
258 m_measure->GetLine());
261 m_measure->SetCoordinate(m_measure->GetSample(),
265 if (newData ==
"Yes")
266 m_measure->SetEditLock(
true);
268 m_measure->SetEditLock(
false);
271 if (newData ==
"Yes")
272 m_measure->SetIgnored(
true);
273 else if (newData ==
"No")
274 m_measure->SetIgnored(
false);
281 m_measure->SetType(m_measure->StringToMeasureType(
282 CnetDisplayProperties::getInstance()->getSerialNumber(
285 case Obsolete_Eccentricity:
286 setLogData(m_measure, ControlMeasureLogData::Obsolete_Eccentricity, newData);
289 setLogData(m_measure, ControlMeasureLogData::GoodnessOfFit, newData);
292 setLogData(m_measure, ControlMeasureLogData::MinimumPixelZScore,
296 setLogData(m_measure, ControlMeasureLogData::MaximumPixelZScore,
306 m_measure->SetSampleSigma(catchNull(newData));
309 m_measure->SetLineSigma(catchNull(newData));
312 m_measure->SetAprioriSample(catchNull(newData));
315 m_measure->SetAprioriLine(catchNull(newData));
318 m_measure->SetDiameter(catchNull(newData));
324 m_measure->SetResidual(
325 catchNull(newData), m_measure->GetLineResidual());
328 m_measure->SetResidual(
329 m_measure->GetSampleResidual(), catchNull(newData));
331 case ResidualMagnitude:
344 bool AbstractMeasureItem::isDataEditable(QString columnTitle)
const {
345 bool parentLocked = !m_measure->Parent() ||
346 m_measure->Parent()->IsEditLocked();
347 bool locked = m_measure->IsEditLocked() || parentLocked;
349 if (getColumn(columnTitle) == EditLock && !parentLocked) {
357 void AbstractMeasureItem::deleteSource() {
359 if (m_measure->Parent()->IsEditLocked()) {
360 QString msg =
"Measures in point [" +
361 getFormattedData(getColumnName(PointId)) +
362 "] cannot be deleted because point is edit locked";
363 throw IException(IException::User, msg, _FILEINFO_);
366 else if (m_measure->IsEditLocked()) {
367 QString msg =
"Measure [" + getFormattedData() +
"] in point [" +
368 getFormattedData(getColumnName(PointId)) +
369 "] cannot be deleted because m_measure is edit locked";
370 throw IException(IException::User, msg, _FILEINFO_);
379 ControlMeasure *tempMeasure = m_measure;
381 tempMeasure->Parent()->Delete(tempMeasure);
386 AbstractTreeItem::InternalPointerType AbstractMeasureItem::getPointerType()
388 return AbstractTreeItem::Measure;
392 void *AbstractMeasureItem::getPointer()
const {
397 bool AbstractMeasureItem::hasMeasure(ControlMeasure *m)
const {
398 return m_measure == m;
402 void AbstractMeasureItem::sourceDeleted() {
407 void AbstractMeasureItem::setLogData(ControlMeasure *m_measure,
408 int m_measureLogDataEnum,
const QString &value) {
410 QString newDataStr = value.toLower();
411 ControlMeasureLogData::NumericLogDataType type =
412 (ControlMeasureLogData::NumericLogDataType) m_measureLogDataEnum;
414 if (newDataStr ==
"null") {
415 m_measure->DeleteLogData(type);
418 m_measure->SetLogData(ControlMeasureLogData(type,
@ Programmer
This error is for when a programmer made an API call that was illegal.
This is free and unencumbered software released into the public domain.