11 #include "AbstractMeasureItem.h"
13 #include <QMessageBox>
17 #include "CnetDisplayProperties.h"
18 #include "ControlMeasure.h"
19 #include "ControlMeasureLogData.h"
20 #include "ControlPoint.h"
21 #include "IException.h"
24 #include "TableColumn.h"
25 #include "TableColumnList.h"
29 QString AbstractMeasureItem::getColumnName(Column col) {
46 return "Measure Type";
47 case Obsolete_Eccentricity:
48 return "Obsolete_Eccentricity";
50 return "Goodness of Fit";
52 return "Minimum Pixel Z-Score";
54 return "Maximum Pixel Z-Score";
56 return "Sample Shift";
60 return "Sample Sigma";
64 return "A Priori Sample";
66 return "A Priori Line";
70 return "Rejected by Jigsaw";
72 return "Residual Sample";
74 return "Residual Line";
75 case ResidualMagnitude:
76 return "Residual Magnitude";
84 AbstractMeasureItem::Column AbstractMeasureItem::getColumn(
85 QString columnTitle) {
86 for (
int i = 0; i < COLS; i++) {
87 if (columnTitle == getColumnName((Column) i))
91 QString msg =
"Column title [" + columnTitle +
"] does not match any of "
92 "the defined column types";
97 TableColumnList *AbstractMeasureItem::createColumns() {
98 TableColumnList *columnList =
new TableColumnList;
100 columnList->append(
new TableColumn(getColumnName(PointId),
true,
false));
101 columnList->append(
new TableColumn(getColumnName(ImageId),
true,
103 columnList->append(
new TableColumn(getColumnName(Sample),
true,
false));
104 columnList->append(
new TableColumn(getColumnName(Line),
true,
false));
105 columnList->append(
new TableColumn(getColumnName(EditLock),
false,
107 columnList->append(
new TableColumn(getColumnName(Ignored),
false,
true));
108 columnList->append(
new TableColumn(getColumnName(Reference),
true,
true));
109 columnList->append(
new TableColumn(getColumnName(Type),
false,
false));
110 columnList->append(
new TableColumn(getColumnName(Obsolete_Eccentricity),
true,
112 columnList->append(
new TableColumn(getColumnName(GoodnessOfFit),
true,
114 columnList->append(
new TableColumn(getColumnName(MinPixelZScore),
true,
116 columnList->append(
new TableColumn(getColumnName(MaxPixelZScore),
true,
118 columnList->append(
new TableColumn(getColumnName(SampleShift),
true,
120 columnList->append(
new TableColumn(getColumnName(LineShift),
true,
122 columnList->append(
new TableColumn(getColumnName(SampleSigma),
false,
124 columnList->append(
new TableColumn(getColumnName(LineSigma),
false,
126 columnList->append(
new TableColumn(getColumnName(APrioriSample),
true,
128 columnList->append(
new TableColumn(getColumnName(APrioriLine),
true,
130 columnList->append(
new TableColumn(getColumnName(Diameter),
false,
132 columnList->append(
new TableColumn(getColumnName(JigsawRejected),
true,
134 columnList->append(
new TableColumn(getColumnName(ResidualSample),
true,
136 columnList->append(
new TableColumn(getColumnName(ResidualLine),
true,
138 columnList->append(
new TableColumn(getColumnName(ResidualMagnitude),
144 AbstractMeasureItem::AbstractMeasureItem(ControlMeasure *cm,
145 int avgCharWidth, AbstractTreeItem *parent)
146 : AbstractTreeItem(parent) {
149 calcDataWidth(avgCharWidth);
151 connect(m_measure, SIGNAL(destroyed(
QObject *)),
this, SLOT(sourceDeleted()));
155 AbstractMeasureItem::~AbstractMeasureItem() {
160 QVariant AbstractMeasureItem::getData()
const {
161 return getData(getColumnName(ImageId));
165 QVariant AbstractMeasureItem::getData(QString columnTitle)
const {
167 Column column = getColumn(columnTitle);
169 switch ((Column) column) {
171 return QVariant((QString) m_measure->Parent()->
GetId());
173 return QVariant(CnetDisplayProperties::getInstance()->getImageName(
176 return QVariant(m_measure->GetSample());
178 return QVariant(m_measure->GetLine());
181 return QVariant(
"Yes");
183 return QVariant(
"No");
185 if (m_measure->IsIgnored())
186 return QVariant(
"Yes");
188 return QVariant(
"No");
191 return QVariant(
"Yes");
193 return QVariant(
"No");
197 case Obsolete_Eccentricity:
199 m_measure->GetLogData(
203 m_measure->GetLogData(
208 GetNumericalValue());
212 GetNumericalValue());
214 return QVariant(m_measure->GetSampleShift());
216 return QVariant(m_measure->GetLineShift());
218 return QVariant(m_measure->GetSampleSigma());
220 return QVariant(m_measure->GetLineSigma());
222 return QVariant(m_measure->GetAprioriSample());
224 return QVariant(m_measure->GetAprioriLine());
228 if (m_measure->IsRejected())
229 return QVariant(
"Yes");
231 return QVariant(
"No");
233 return QVariant(m_measure->GetSampleResidual());
235 return QVariant(m_measure->GetLineResidual());
236 case ResidualMagnitude:
246 void AbstractMeasureItem::setData(QString
const &columnTitle,
247 QString
const &newData) {
249 Column column = getColumn(columnTitle);
251 switch ((Column) column) {
257 CnetDisplayProperties::getInstance()->getSerialNumber(newData));
261 m_measure->GetLine());
268 if (newData ==
"Yes")
269 m_measure->SetEditLock(
true);
271 m_measure->SetEditLock(
false);
274 if (newData ==
"Yes")
275 m_measure->SetIgnored(
true);
276 else if (newData ==
"No")
277 m_measure->SetIgnored(
false);
285 CnetDisplayProperties::getInstance()->getSerialNumber(
288 case Obsolete_Eccentricity:
309 m_measure->SetSampleSigma(catchNull(newData));
312 m_measure->SetLineSigma(catchNull(newData));
315 m_measure->SetAprioriSample(catchNull(newData));
318 m_measure->SetAprioriLine(catchNull(newData));
328 catchNull(newData), m_measure->GetLineResidual());
332 m_measure->GetSampleResidual(), catchNull(newData));
334 case ResidualMagnitude:
347 bool AbstractMeasureItem::isDataEditable(QString columnTitle)
const {
348 bool parentLocked = !m_measure->Parent() ||
349 m_measure->Parent()->IsEditLocked();
350 bool locked = m_measure->
IsEditLocked() || parentLocked;
352 if (getColumn(columnTitle) == EditLock && !parentLocked) {
360 void AbstractMeasureItem::deleteSource() {
362 if (m_measure->Parent()->IsEditLocked()) {
363 QString msg =
"Measures in point [" +
364 getFormattedData(getColumnName(PointId)) +
365 "] cannot be deleted because point is edit locked";
370 QString msg =
"Measure [" + getFormattedData() +
"] in point [" +
371 getFormattedData(getColumnName(PointId)) +
372 "] cannot be deleted because m_measure is edit locked";
382 ControlMeasure *tempMeasure = m_measure;
384 tempMeasure->Parent()->
Delete(tempMeasure);
389 AbstractTreeItem::InternalPointerType AbstractMeasureItem::getPointerType()
391 return AbstractTreeItem::Measure;
395 void *AbstractMeasureItem::getPointer()
const {
400 bool AbstractMeasureItem::hasMeasure(ControlMeasure *m)
const {
401 return m_measure == m;
405 void AbstractMeasureItem::sourceDeleted() {
410 void AbstractMeasureItem::setLogData(ControlMeasure *m_measure,
411 int m_measureLogDataEnum,
const QString &value) {
414 QString newDataStr = value.toLower();
418 if (newDataStr ==
"null") {
419 m_measure->DeleteLogData(type);
422 m_measure->SetLogData(ControlMeasureLogData(type,