Beispiel #1
0
QStringList GraphicsScene::positionHasChangedPointIdentifiers () const
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::positionHasChangedPointIdentifiers";

  QStringList movedIds;

  const QList<QGraphicsItem*> &items = QGraphicsScene::items();
  QList<QGraphicsItem*>::const_iterator itr;
  for (itr = items.begin(); itr != items.end(); itr++) {

    const QGraphicsItem *item = *itr;

    // Skip the image and only keep the Points
    bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT);
    if (isPoint) {

      QString identifier = item->data (DATA_KEY_IDENTIFIER).toString ();
      bool positionHasChanged = item->data (DATA_KEY_POSITION_HAS_CHANGED).toBool ();

      LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsScene::positionHasChangedPointIdentifiers"
                                   << " identifier=" << identifier.toLatin1().data()
                                   << " positionHasChanged=" << (positionHasChanged ? "yes" : "no");

      if (isPoint && positionHasChanged) {

        // Add Point to the list
        movedIds << item->data(DATA_KEY_IDENTIFIER).toString ();

      }
    }
  }

  return  movedIds;
}
void DigitizeStateSelect::handleContextMenuEventAxis34 (CmdMediator *cmdMediator,
                                                        const QString &pointIdentifier)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSelect::handleContextMenuEventAxis34";

  QPointF posScreen = cmdMediator->document().positionScreen (pointIdentifier);
  QPointF posGraphBefore = cmdMediator->document().positionGraph (pointIdentifier);
  bool isXOnly = cmdMediator->document().isXOnly (pointIdentifier);

  // Ask user for coordinates
  double x = posGraphBefore.x();
  double y = posGraphBefore.y();

  DlgEditPointAxis *dlg = new DlgEditPointAxis (context().mainWindow(),
                                                cmdMediator->document().modelCoords(),
                                                cmdMediator->document().modelGeneral(),
                                                context().mainWindow().modelMainWindow(),
                                                context().mainWindow().transformation(),
                                                cmdMediator->document().documentAxesPointsRequired(),
                                                isXOnly,
                                                &x,
                                                &y);
  int rtn = dlg->exec ();

  QPointF posGraphAfter = dlg->posGraph (isXOnly); // This call returns new values for isXOnly and the graph position
  delete dlg;

  if (rtn == QDialog::Accepted) {

    // User wants to edit this axis point, but let's perform sanity checks first

    bool isError;
    QString errorMessage;

    context().mainWindow().cmdMediator()->document().checkEditPointAxis(pointIdentifier,
                                                                        posScreen,
                                                                        posGraphAfter,
                                                                        isError,
                                                                        errorMessage);

    if (isError) {

      QMessageBox::warning (0,
                            engaugeWindowTitle(),
                            errorMessage);

    } else {

      // Create a command to edit the point
      CmdEditPointAxis *cmd = new CmdEditPointAxis (context().mainWindow(),
                                                    cmdMediator->document(),
                                                    pointIdentifier,
                                                    posGraphBefore,
                                                    posGraphAfter,
                                                    isXOnly);
      context().appendNewCmd(cmdMediator,
                             cmd);
    }
  }
}
Beispiel #3
0
QVariant CurveNameList::data (const QModelIndex &index,
                              int role) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::data"
                               << " isRoot=" << (index.isValid () ? "no" : "yes")
                               << " role=" << roleAsString (role).toLatin1 ().data ();

  if (!index.isValid ()) {
    // Root item
    return QVariant ();
  }

  int row = index.row ();
  if (row < 0 || row >= m_modelCurvesEntries.count ()) {
    return QVariant();
  }

  if ((role != Qt::DisplayRole) &&
      (role != Qt::EditRole)) {
    return QVariant();
  }

  CurveNameListEntry curvesEntry (m_modelCurvesEntries.at (row));

  if (index.column () == 0) {
    return curvesEntry.curveNameCurrent();
  } else if (index.column () == 1) {
    return curvesEntry.curveNameOriginal();
  } else if (index.column () == 2) {
    return curvesEntry.numPoints ();
  } else {
    ENGAUGE_ASSERT (false);
    return curvesEntry.curveNameOriginal(); // Default if asserts are disabled
 }
}
Beispiel #4
0
void FormatCoordsUnits::formattedToUnformatted (const QString &xThetaFormatted,
                                                const QString &yRadiusFormatted,
                                                const DocumentModelCoords &modelCoords,
                                                double &xThetaUnformatted,
                                                double &yRadiusUnformatted) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnits::formattedToUnformatted";

  FormatCoordsUnitsStrategyNonPolarTheta formatNonPolarTheta;
  FormatCoordsUnitsStrategyPolarTheta formatPolarTheta;

  if (modelCoords.coordsType() == COORDS_TYPE_CARTESIAN) {

    xThetaUnformatted = formatNonPolarTheta.formattedToUnformatted (xThetaFormatted,
                                                                    modelCoords.coordUnitsX(),
                                                                    modelCoords.coordUnitsDate(),
                                                                    modelCoords.coordUnitsTime());
    yRadiusUnformatted = formatNonPolarTheta.formattedToUnformatted (yRadiusFormatted,
                                                                     modelCoords.coordUnitsY(),
                                                                     modelCoords.coordUnitsDate(),
                                                                     modelCoords.coordUnitsTime());

  } else {

    xThetaUnformatted = formatPolarTheta.formattedToUnformatted (xThetaFormatted,
                                                                 modelCoords.coordUnitsTheta());
    yRadiusUnformatted = formatNonPolarTheta.formattedToUnformatted (yRadiusFormatted,
                                                                     modelCoords.coordUnitsRadius(),
                                                                     modelCoords.coordUnitsDate(),
                                                                     modelCoords.coordUnitsTime());

  }
}
void DigitizeStatePointMatch::createTemporaryPoint (CmdMediator *cmdMediator,
                                                    const QPoint &posScreen)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::createTemporaryPoint";

  GeometryWindow *NULL_GEOMETRY_WINDOW = nullptr;

  const DocumentModelPointMatch &modelPointMatch = cmdMediator->document().modelPointMatch();

  // Get point style for current graph, and then override with candidate color
  const CurveStyles &curveStyles = cmdMediator->document().modelCurveStyles();
  PointStyle pointStyle = curveStyles.pointStyle (activeCurve());
  pointStyle.setPaletteColor (modelPointMatch.paletteColorCandidate());

  // Temporary point that user can see while DlgEditPoint is active
  GraphicsPoint *point = context().mainWindow().scene().createPoint(Point::temporaryPointIdentifier (),
                                                                    pointStyle,
                                                                    posScreen,
                                                                    NULL_GEOMETRY_WINDOW);

  context().mainWindow().scene().removeTemporaryPointIfExists(); // Only one temporary point at a time is allowed

  context().mainWindow().scene().addTemporaryPoint (Point::temporaryPointIdentifier(),
                                                    point);
  m_posCandidatePoint = posScreen;
}
Beispiel #6
0
int CurveNameList::rowCount (const QModelIndex & /* parent */) const
{
  int count = m_modelCurvesEntries.count ();

  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::rowCount count=" << count;

  return count;
}
void DigitizeStateContext::setDragMode (QGraphicsView::DragMode dragMode)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateContext::setDragMode";

  if (m_imageIsLoaded) {
    m_view.setDragMode (dragMode);
  }
}
GridLineFactory::GridLineFactory(QGraphicsScene &scene,
                                 const DocumentModelCoords &modelCoords) :
  m_scene (scene),
  m_pointRadius (0.0),
  m_modelCoords (modelCoords),
  m_isChecker (false)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::GridLineFactory";
}
Beispiel #9
0
QCursor DigitizeStateAxis::cursor() const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::cursor";

  CursorFactory cursorFactory;
  QCursor cursor = cursorFactory.generate (context().cmdMediator().document().modelDigitizeCurve());

  return cursor;
}
QStandardItem *CurveNameList::item(int row, int column) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::item"
                               << " row=" << row;

  ENGAUGE_ASSERT (row < rowCount ());

  return QStandardItemModel::item (row, column);
}
bool CurveNameList::setData (const QModelIndex &index,
                             const QVariant &value,
                             int role)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::setData"
                               << " row=" << index.row()
                               << " value=" << value.toString().toLatin1().data()
                               << " role=" << roleAsString (role).toLatin1().data();

  bool success;
  if (role == Qt::EditRole) {

    // Each curve name must be unique
    if (curveNameIsAcceptable (value.toString(),
                               index.row())) {

      // Curve name is fine
      QModelIndex idxOld = QStandardItemModel::index (index.row(), CURVE_NAME_LIST_COLUMN_CURRENT);

      // Old and new curve names
      QString curveCurrentOld = data (idxOld).toString ();
      QString curveCurrentNew = value.toString ();

      // Remove old entry after saving original curve name
      QString curveOriginal;
      if (m_currentCurveToOriginalCurve.contains (curveCurrentOld)) {

        // Remember old original curve name
        curveOriginal = m_currentCurveToOriginalCurve [curveCurrentOld];

        // Remove old entry
        m_currentCurveToOriginalCurve.remove (curveCurrentOld);

        // Add new entry
        m_currentCurveToOriginalCurve [curveCurrentNew] = curveOriginal;
      }

      success = QStandardItemModel::setData (index,
                                             value,
                                             role);
    } else {

      // Curve name is unacceptable
      success = false;

    }
  } else {

    // For non-edits, this method just calls the superclass method
    success = QStandardItemModel::setData (index,
                                           value,
                                           role);
  }

  return success;
}
Beispiel #12
0
void Checker::bindItemToScene(QGraphicsItem *item) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "Checker::bindItemToScene";

  item->setOpacity (CHECKER_OPACITY);
  item->setZValue (Z_VALUE_IN_FRONT);
  item->setToolTip (QObject::tr ("Axes checker. If this does not align with the axes, then the axes points should be checked"));

  m_scene.addItem (item);
}
QGraphicsItem *GridLineFactory::lineItem (const QPointF &posStartScreen,
                                          const QPointF &posEndScreen) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::lineItem"
                               << " posStartScreen=" << QPointFToString (posStartScreen).toLatin1().data()
                               << " posEndScreen=" << QPointFToString (posEndScreen).toLatin1().data();

  return new QGraphicsLineItem (QLineF (posStartScreen,
                                        posEndScreen));
}
int FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber (double valueUnformatted,
                                                                        double valueUnformattedOther,
                                                                        bool isXTheta,
                                                                        const DocumentModelGeneral &modelGeneral,
                                                                        const Transformation &transformation) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber";

  const double PIXEL_SHIFT = 1;
  const int DEFAULT_PRECISION = 5; // Precision used before transformation is available. Equal or greater than x/y pixel counts

  if (transformation.transformIsDefined()) {

    // Measure the resolution if the point is moved some number of pixels in screen coordinates
    QPointF posGraph;
    if (isXTheta) {

      posGraph = QPointF (valueUnformatted,
                          valueUnformattedOther);

    } else {

      posGraph = QPointF (valueUnformattedOther,
                          valueUnformatted);

    }

    QPointF posScreen, posScreenShifted, posGraphShifted;

    transformation.transformRawGraphToScreen (posGraph,
                                              posScreen);

    posScreenShifted = posScreen + QPointF (PIXEL_SHIFT, PIXEL_SHIFT);

    transformation.transformScreenToRawGraph (posScreenShifted,
                                              posGraphShifted);

    double xResolutionPerPixel = (posGraphShifted.x() - posGraph.x()) / PIXEL_SHIFT;
    double yResolutionPerPixel = (posGraphShifted.y() - posGraph.y()) / PIXEL_SHIFT;
    double resolutionPerPixel = (isXTheta ? xResolutionPerPixel : yResolutionPerPixel);

    // Compute number of digits ahead of the decimal point (any single decimal place would work but the decimal point is easiest)
    int powerValue = qFloor (qLn (qAbs (valueUnformatted)) / qLn (10.0));
    int powerResolution = qFloor (qLn (qAbs (resolutionPerPixel)) / qLn (10.0));

    int numberDigitsForResolution = powerValue - powerResolution + 1 + modelGeneral.extraPrecision();

    return numberDigitsForResolution + 1; // Add one just to be safe

  } else {

    return DEFAULT_PRECISION;
  }
}
void GraphicsLinesForCurves::updateAfterCommand (GraphicsScene &scene,
                                                 const CurveStyles &curveStyles,
                                                 const QString &curveName,
                                                 const Point &point)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsLinesForCurves::updateAfterCommand"
                               << " point=" << point.identifier().toLatin1().data()
                               << " curveCount=" << m_graphicsLinesForCurve.count();

  ENGAUGE_ASSERT (m_graphicsLinesForCurve.contains (curveName));
  m_graphicsLinesForCurve [curveName]->updateAfterCommand (scene,
                                                           curveStyles.pointStyle(curveName),
                                                           point);
}
GridLineFactory::GridLineFactory(QGraphicsScene &scene,
                                 int pointRadius,
                                 const QList<Point> &pointsToIsolate,
                                 const DocumentModelCoords &modelCoords) :
  m_scene (scene),
  m_pointRadius (pointRadius),
  m_pointsToIsolate (pointsToIsolate),
  m_modelCoords (modelCoords),
  m_isChecker (true)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::GridLineFactory"
                               << " pointRadius=" << pointRadius
                               << " pointsToIsolate=" << pointsToIsolate.count();
}
Beispiel #17
0
void DigitizeStateAxis::createTemporaryPoint (const QPointF &posScreen)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::createTemporaryPoint";

  // Temporary point that user can see while DlgEditPoint is active
  const Curve &curveAxes = context().cmdMediator().curveAxes();
  PointStyle pointStyleAxes = curveAxes.curveStyle().pointStyle();
  GraphicsPoint *point = context().mainWindow().scene().createPoint(Point::temporaryPointIdentifier (),
                                                                    pointStyleAxes,
                                                                    posScreen);

  context().mainWindow().scene().addTemporaryPoint (Point::temporaryPointIdentifier(),
                                                    point);
}
QVariant GraphicsPointEllipse::itemChange(GraphicsItemChange change,
                                          const QVariant &value)
{
  if (change == QGraphicsItem::ItemPositionHasChanged) {

    LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointEllipse::itemChange"
                                 << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
                                 << " positionHasChanged";

    setData (DATA_KEY_POSITION_HAS_CHANGED, QVariant (true));
  }

  return QGraphicsEllipseItem::itemChange(change,
                                          value);
}
CallbackSearchReturn CallbackDocumentHash::callback (const QString &curveName,
                                                     const Point &point)
{
  // LOG4CPP_DEBUG_S is below

  // Capture all important information about the point into the hash. A single string representing all of the point's details is
  // created, which can be logged, and then that string is added to the hash

  QString details;

  details += curveName.toLatin1();
  details += " " + point.identifier ();
  details += " " + QPointFToString (point.posScreen());

  if (point.hasOrdinal ()) {
    details += " " + QString::number (point.ordinal ());
  }

  if (point.isAxisPoint()) {

    if (m_documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_3) {

      // Axis point has one or coordinate
      if (point.isXOnly()) {

        details += " " + QString::number (point.posGraph().x());

      } else {

        details += " " + QString::number (point.posGraph().y());

      }

    } else {

      // Axis point has two coordinates
      details += " " + QPointFToString (point.posGraph());

    }
  }

  LOG4CPP_DEBUG_S ((*mainCat)) << "CallbackDocumentHash::callback details=" << details.toLatin1().data();

  // Add details to hash
  m_documentHash.addData (details.toLatin1());

  return CALLBACK_SEARCH_RETURN_CONTINUE;
}
void DigitizeStateAxis::createTemporaryPoint (CmdMediator *cmdMediator,
                                              const QPointF &posScreen)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::createTemporaryPoint";

  GeometryWindow *NULL_GEOMETRY_WINDOW = nullptr;

  // Temporary point that user can see while DlgEditPointAxis is active
  const Curve &curveAxes = cmdMediator->curveAxes();
  PointStyle pointStyleAxes = curveAxes.curveStyle().pointStyle();
  GraphicsPoint *point = context().mainWindow().scene().createPoint(Point::temporaryPointIdentifier (),
                                                                    pointStyleAxes,
                                                                    posScreen,
                                                                    NULL_GEOMETRY_WINDOW);

  context().mainWindow().scene().addTemporaryPoint (Point::temporaryPointIdentifier(),
                                                    point);
}
Beispiel #21
0
void FormatCoordsUnits::unformattedToFormatted (double xThetaUnformatted,
                                                double yRadiusUnformatted,
                                                const DocumentModelCoords &modelCoords,
                                                QString &xThetaFormatted,
                                                QString &yRadiusFormatted,
                                                const Transformation &transformation) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnits::unformattedToFormatted";

  FormatCoordsUnitsStrategyNonPolarTheta formatNonPolarTheta;
  FormatCoordsUnitsStrategyPolarTheta formatPolarTheta;

  if (modelCoords.coordsType() == COORDS_TYPE_CARTESIAN) {

    xThetaFormatted = formatNonPolarTheta.unformattedToFormatted (xThetaUnformatted,
                                                                  modelCoords.coordUnitsX(),
                                                                  modelCoords.coordUnitsDate(),
                                                                  modelCoords.coordUnitsTime(),
                                                                  IS_X_THETA,
                                                                  transformation,
                                                                  yRadiusUnformatted);
    yRadiusFormatted = formatNonPolarTheta.unformattedToFormatted (yRadiusUnformatted,
                                                                   modelCoords.coordUnitsY(),
                                                                   modelCoords.coordUnitsDate(),
                                                                   modelCoords.coordUnitsTime(),
                                                                   IS_NOT_X_THETA,
                                                                   transformation,
                                                                   xThetaUnformatted);
    
  } else {
    
    xThetaFormatted = formatPolarTheta.unformattedToFormatted (xThetaUnformatted,
                                                               modelCoords.coordUnitsTheta(),
                                                               transformation,
                                                               yRadiusUnformatted);
    yRadiusFormatted = formatNonPolarTheta.unformattedToFormatted (yRadiusUnformatted,
                                                                   modelCoords.coordUnitsRadius(),
                                                                   modelCoords.coordUnitsDate(),
                                                                   modelCoords.coordUnitsTime(),
                                                                   IS_NOT_X_THETA,
                                                                   transformation,
                                                                   xThetaUnformatted);
  }
}
void GridLineFactory::finishActiveGridLine (const QPointF &posStartScreen,
                                            const QPointF &posEndScreen,
                                            double yFrom,
                                            double yTo,
                                            const Transformation &transformation,
                                            GridLine &gridLine) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::finishActiveGridLine"
                               << " posStartScreen=" << QPointFToString (posStartScreen).toLatin1().data()
                               << " posEndScreen=" << QPointFToString (posEndScreen).toLatin1().data()
                               << " yFrom=" << yFrom
                               << " yTo=" << yTo;

  QGraphicsItem *item;
  if ((m_modelCoords.coordsType() == COORDS_TYPE_POLAR) &&
      (yFrom == yTo)) {

    // Linear cartesian radius
    double radiusLinearCartesian = yFrom;
    if (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
      radiusLinearCartesian = transformation.logToLinearRadius(yFrom,
                                                               m_modelCoords.originRadius());
    } else {
      radiusLinearCartesian -= m_modelCoords.originRadius();
    }

    // Draw along an arc since this is a side of constant radius, and we have polar coordinates
    item = ellipseItem (transformation,
                        radiusLinearCartesian,
                        posStartScreen,
                        posEndScreen);

  } else {

    // Draw straight line
    item = lineItem (posStartScreen,
                     posEndScreen);
  }

  gridLine.add (item);
  bindItemToScene (item);
}
void CurveNameList::setItem(int row,
                            int column,
                            QStandardItem *item)
{
  // LOG4CPP is below

  ENGAUGE_ASSERT (column == CURVE_NAME_LIST_COLUMN_CURRENT);

  QString before = currentCurvesAsString ();

  QStandardItemModel::setItem (row,
                               column,
                               item);

  QString after = currentCurvesAsString ();

  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::setItem"
                               << " row=" << row
                               << " before=" << before.toLatin1().data()
                               << " after=" << after.toLatin1().data();
}
bool CurveNameList::removeRows (int row,
                                int count,
                                const QModelIndex &parent)
{
  // LOG4CPP is below

  bool skip = (count != 1 || row < 0 || row > rowCount () || parent.isValid());

  QString before, after;
  if (!skip) {

    before = currentCurvesAsString ();

    // As documented for QAbstractItemModel, beginRemoveRows "emits the rowsAboutToBeRemoved() signal which connected views
    // (or proxies) must handle before the data is removed. Otherwise, the views may end up in an invalid state."
    beginRemoveRows (QModelIndex (),
                     row,
                     row + count - 1);

    // We do not call QStandardItemModel::removeRow or QAbstractItemModel::removeRow here since that leads to an infinite loop when it calls this method
    for (int rowRemove = row; rowRemove < row + count; rowRemove++) {
      QStandardItemModel::removeRows (row,
                                      count,
                                      parent);
    }

    endRemoveRows ();

    after = currentCurvesAsString ();
  }

  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::removeRows"
                               << " row=" << row
                               << " count=" << count
                               << " isRoot=" << (parent.isValid () ? "no" : "yes")
                               << " skip=" << (skip ? "yes" : "no")
                               << " before=" << before.toLatin1().data()
                               << " after=" << after.toLatin1().data();
  return true;
}
void DigitizeStatePointMatch::popCandidatePoint (CmdMediator *cmdMediator)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::popCandidatePoint";

  if (m_candidatePoints.count() > 0) {

    // Pop next point from list onto screen
    QPoint posScreen = m_candidatePoints.first();
    m_candidatePoints.pop_front ();

    createTemporaryPoint(cmdMediator,
                         posScreen);

  } else {

    // No more points. Inform user
    QMessageBox::information (nullptr,
                              QObject::tr ("Point Match"),
                              QObject::tr ("There are no more matching points"));

  }
}
Beispiel #26
0
bool CurveNameList::removeRows (int row,
                                int count,
                                const QModelIndex &parent)
{
  bool skip = (count != 1 || row < 0 || row > rowCount () || parent.isValid());

  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::removeRows"
                               << " row=" << row
                               << " count=" << count
                               << " isRoot=" << (parent.isValid () ? "no" : "yes")
                               << " skip=" << (skip ? "yes" : "no");

  bool success = false;

  beginRemoveRows (QModelIndex (),
                   row,
                   row + count - 1);

  m_modelCurvesEntries.removeAt (row);

  endRemoveRows ();

  return success;
}
void CurveNameList::insertRow (int row,
                               const QString &curveCurrent,
                               const QString &curveOriginal,
                               unsigned int pointCount)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "CurveNameList::insertRow"
                               << " row=" <<row
                               << " curveCurrent=" << curveCurrent.toLatin1().data()
                               << " curveOriginal=" << curveOriginal.toLatin1().data()
                               << " points=" << pointCount;

  QStandardItem *item = new QStandardItem (curveCurrent);
  QStandardItemModel::insertRow (row, item);

  // Documentation for QAbstractItemModels says beginInsertRows/endInsertRows send off a rowsAboutToBeInserted signal
  beginInsertRows (QModelIndex (),
                   row,
                   row);

  m_currentCurveToOriginalCurve [curveCurrent] = curveOriginal;
  m_originalCurveToPointCount [curveOriginal] = pointCount;

  endInsertRows ();
}
Beispiel #28
0
FormatCoordsUnits::FormatCoordsUnits()
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnits::FormatCoordsUnits";
}
Beispiel #29
0
QCursor DigitizeStateSegment::cursor(CmdMediator * /* cmdMediator */) const
{
    LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::cursor";

    return QCursor (Qt::ArrowCursor);
}
GridLine *GridLineFactory::createGridLine (double xFrom,
                                           double yFrom,
                                           double xTo,
                                           double yTo,
                                           const Transformation &transformation)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GridLineFactory::createGridLine"
                               << " xFrom=" << xFrom
                               << " yFrom=" << yFrom
                               << " xTo=" << xTo
                               << " yTo=" << yTo;

  GridLine *gridLine = new GridLine ();

  // Originally a complicated algorithm tried to intercept a straight line from (xFrom,yFrom) to (xTo,yTo). That did not work well since:
  // 1) Calculations for mostly orthogonal cartesian coordinates worked less well with non-orthogonal polar coordinates
  // 2) Ambiguity in polar coordinates between the shorter and longer paths between (theta0,radius) and (theta1,radius)
  //
  // Current algorithm breaks up the interval between (xMin,yMin) and (xMax,yMax) into many smaller pieces and stitches the
  // desired pieces together. For straight lines in linear graphs this algorithm is very much overkill, but there is no significant
  // penalty and this approach works in every situation

  // Should give single-pixel resolution on most images, and 'good enough' resolution on extremely large images
  const int NUM_STEPS = 1000;

  bool stateSegmentIsActive = false;
  QPointF posStartScreen (0, 0);

  // Loop through steps. Final step i=NUM_STEPS does final processing if a segment is active
  for (int i = 0; i <= NUM_STEPS; i++) {

    double s = (double) i / (double) NUM_STEPS;

    // Interpolate coordinates assuming normal linear scaling
    double xGraph = (1.0 - s) * xFrom + s * xTo;
    double yGraph = (1.0 - s) * yFrom + s * yTo;

    // Replace interpolated coordinates using log scaling if appropriate, preserving the same ranges
    if (m_modelCoords.coordScaleXTheta() == COORD_SCALE_LOG) {
      xGraph = qExp ((1.0 - s) * qLn (xFrom) + s * qLn (xTo));
    }
    if (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
      yGraph = qExp ((1.0 - s) * qLn (yFrom) + s * qLn (yTo));
    }

    QPointF pointScreen;
    transformation.transformRawGraphToScreen (QPointF (xGraph, yGraph),
                                              pointScreen);

    double distanceToNearestPoint = minScreenDistanceFromPoints (pointScreen);
    if ((distanceToNearestPoint < m_pointRadius) ||
        (i == NUM_STEPS)) {

        // Too close to point, so point is not included in side. Or this is the final iteration of the loop
      if (stateSegmentIsActive) {

        // State transition
        finishActiveGridLine (posStartScreen,
                              pointScreen,
                              yFrom,
                              yTo,
                              transformation,
                              *gridLine);
        stateSegmentIsActive = false;

      }
    } else {

      // Outside point, so include point in side
      if (!stateSegmentIsActive) {

        // State transition
        stateSegmentIsActive = true;
        posStartScreen = pointScreen;

      }
    }
  }

  return gridLine;
}