9#include "PointTableModel.h" 
   19#include "CnetDisplayProperties.h" 
   20#include "ControlMeasure.h" 
   21#include "ControlPoint.h" 
   23#include "IException.h" 
   27#include "SpecialPixel.h" 
   29#include "AbstractTableDelegate.h" 
   30#include "AbstractPointItem.h" 
   31#include "TableColumn.h" 
   32#include "TableColumnList.h" 
   33#include "PointTableDelegate.h" 
   34#include "AbstractTreeModel.h" 
   38  PointTableModel::PointTableModel(AbstractTreeModel *model) :
 
   39    AbstractTableModel(model, new PointTableDelegate) {
 
   40    connect(model, SIGNAL(filterCountsChanged(
int, 
int)),
 
   41        this, SIGNAL(filterCountsChanged(
int, 
int)));
 
   43        SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
 
   45        SLOT(handleTreeSelectionChanged(QList< AbstractTreeItem * >)));
 
   49  PointTableModel::~PointTableModel() {
 
   53  QList< AbstractTreeItem * > PointTableModel::getItems(
 
   55    return getSortedItems(start, end, AbstractTreeModel::PointItems);
 
   59  QList< AbstractTreeItem * > PointTableModel::getItems(
 
   60    AbstractTreeItem *item1, AbstractTreeItem *item2) {
 
   61    return getSortedItems(item1, item2, AbstractTreeModel::PointItems);
 
   65  int PointTableModel::getVisibleRowCount()
 const {
 
   66    return getDataModel()->getVisibleItemCount(AbstractTreeModel::PointItems,
 
   71  QList< AbstractTreeItem * > PointTableModel::getSelectedItems() {
 
   72    return getDataModel()->getSelectedItems(AbstractTreeModel::PointItems,
 
   77  QString PointTableModel::getWarningMessage(AbstractTreeItem 
const *row,
 
   78      TableColumn 
const *column, QString valueToSave)
 const {
 
   79    return getPointWarningMessage(row, column, valueToSave);
 
   83  void PointTableModel::setGlobalSelection(
bool selected) {
 
   84    return getDataModel()->setGlobalSelection(selected,
 
   85        AbstractTreeModel::AllItems);
 
   89  int PointTableModel::indexOfVisibleItem(
 
   90    AbstractTreeItem 
const *item)
 const {
 
   91    return getDataModel()->indexOfVisibleItem(item,
 
   92        AbstractTreeModel::PointItems,
 
   97  void PointTableModel::resetColumnHeaders() {
 
   98    TableColumnList *columns = getColumns();
 
   99    AbstractPointItem::resetColumnHeaders(columns);
 
  103  QString PointTableModel::getPointWarningMessage(
 
  104    AbstractTreeItem 
const *row, TableColumn 
const *column,
 
  105    QString valueToSave) {
 
  106    QString colTitle = column->getTitle();
 
  107    AbstractPointItem::Column colType =
 
  108      AbstractPointItem::getColumn(colTitle);
 
  111    CnetDisplayProperties *displayProperties = CnetDisplayProperties::getInstance();
 
  114      case AbstractPointItem::EditLock:
 
  115        if (valueToSave.toLower() == 
"no" &&
 
  116            row->getFormattedData(colTitle).toLower() == 
"yes") {
 
  117          warningText = 
"Are you sure you want to unlock control point [" +
 
  118              row->getFormattedData() + 
"] for editing?";
 
  121      case AbstractPointItem::APrioriSPCoord1Sigma:
 
  122      case AbstractPointItem::APrioriSPCoord2Sigma:
 
  123      case AbstractPointItem::APrioriSPCoord3Sigma: {
 
  124          ControlPoint *point = (ControlPoint *) row->getPointer();
 
  127          if (displayProperties->coordinateDisplayType() == CnetDisplayProperties::LatLonRadius) {
 
  128            bool latSigmaValid = (point->GetAprioriSurfacePoint().
 
  129                GetLatSigmaDistance().isValid());
 
  130            bool lonSigmaValid = (point->GetAprioriSurfacePoint().
 
  131                GetLonSigmaDistance().isValid());
 
  132            bool radiusSigmaValid = (point->GetAprioriSurfacePoint().
 
  133                GetLocalRadiusSigma().isValid());
 
  135            if (!latSigmaValid && !lonSigmaValid && !radiusSigmaValid &&
 
  136                valueToSave.toLower() != 
"null") {
 
  137              warningText = 
"The sigma values are currently null. The other " 
  138                  "sigmas will be set to 10,000, which currently represents " 
  139                  "'free'. Is this okay?";
 
  142              bool xSigmaValid = (point->GetAprioriSurfacePoint().
 
  143                  GetXSigma().isValid());
 
  144              bool ySigmaValid = (point->GetAprioriSurfacePoint().
 
  145                  GetYSigma().isValid());
 
  146              bool zSigmaValid = (point->GetAprioriSurfacePoint().
 
  147                  GetZSigma().isValid());
 
  149              if (!xSigmaValid && !ySigmaValid && !zSigmaValid &&
 
  150                  valueToSave.toLower() != 
"null") {
 
  151                warningText = 
"The sigma values are currently null. The other " 
  152                    "sigmas will be set to 10,000, which currently represents " 
  153                    "'free'. Is this okay?";
 
  159      case AbstractPointItem::APrioriSPCoord1:
 
  160      case AbstractPointItem::APrioriSPCoord2:
 
  161      case AbstractPointItem::APrioriSPCoord3: {
 
  162          ControlPoint *point = (ControlPoint *) row->getPointer();
 
  165          if (displayProperties->coordinateDisplayType() == CnetDisplayProperties::LatLonRadius) {
 
  166            bool latValid = (point->GetAprioriSurfacePoint().
 
  167                GetLatitude().isValid());
 
  168            bool lonValid = (point->GetAprioriSurfacePoint().
 
  169                GetLongitude().isValid());
 
  170            bool radiusValid = (point->GetAprioriSurfacePoint().
 
  171                GetLocalRadius().isValid());
 
  173            if (!latValid && !lonValid && !radiusValid &&
 
  174                valueToSave.toLower() != 
"null") {
 
  175              warningText = 
"Some of the a priori surface point values are " 
  176                  "currently null. The surface point lat and lon will be set " 
  177                  "to 0 if they are null, and the radius will be set to " 
  178                  "10,000 if it is null. Is this okay?";
 
  182            bool xValid = (point->GetAprioriSurfacePoint().
 
  184            bool yValid = (point->GetAprioriSurfacePoint().
 
  186            bool zValid = (point->GetAprioriSurfacePoint().
 
  189            if (!xValid && !yValid && !zValid &&
 
  190                valueToSave.toLower() != 
"null") {
 
  191              warningText = 
"Some of the a priori surface point values are " 
  192                  "currently null. The surface point lat and lon will be set " 
  193                  "to 0 if they are null, and the radius will be set to " 
  194                  "10,000 if it is null. Is this okay?";
 
  208  void PointTableModel::handleTreeSelectionChanged(
 
  209    QList< AbstractTreeItem * > newlySelectedItems) {
 
  210    AbstractTableModel::handleTreeSelectionChanged(
 
  211      newlySelectedItems, AbstractTreeItem::Point);
 
  213    QList<AbstractTreeItem *> measureParentItems;
 
  214    foreach (AbstractTreeItem * item, newlySelectedItems) {
 
  215      if (item->getPointerType() == AbstractTreeItem::Measure) {
 
  216        measureParentItems.append(item->parent());
 
  220    if (measureParentItems.size()) {
 
  221      AbstractTableModel::handleTreeSelectionChanged(
 
  222        measureParentItems, AbstractTreeItem::Point);
 
  227  TableColumnList *PointTableModel::createColumns() {
 
  228    return AbstractPointItem::createColumns();
 
This is free and unencumbered software released into the public domain.