void DlgSettingsExportFormat::slotInclude ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotInclude";

  // Perform forward pass to get included curves in the proper order
  int i;
  QStringList included;
  for (i = 0; i < m_listExcluded->count(); i++) {
    if (m_listExcluded->item(i)->isSelected()) {
      included += m_listExcluded->item(i)->text();
    }
  }

  // Add the included curves to the included list
  for (i = 0; i < included.count(); i++) {
    QString curveName = included.at (i);
    m_listIncluded->addItem (curveName);
  }

  // Perform backwards pass to remove the included curves from the excluded list
  QStringList excluded;
  for (i = m_listExcluded->count() - 1; i>= 0; i--) {
    QString curveName = m_listExcluded->item(i)->text();
    QListWidgetItem *item = m_listExcluded->item (i);
    if (included.contains (curveName)) {
      m_listExcluded->removeItemWidget (item);
      delete item;
    } else {
      excluded += item->text();
    }
  }

  m_modelExportAfter->setCurveNamesNotExported(excluded);
  updateControls();
  updatePreview();
}
void TransformationStateContext::triggerStateTransition (TransformationState transformationState,
        CmdMediator &cmdMediator,
        const Transformation &transformation,
        const QString &selectedGraphCurve)
{
    LOG4CPP_INFO_S ((*mainCat)) << "TransformationStateContext::triggerStateTransition";

    // Transition if we are not already at the requested state
    if (transformationState != m_currentState) {

        // End the current state if there is one
        if (m_currentState != NUM_TRANSFORMATION_STATES) {
            m_states[m_currentState]->end(cmdMediator,
                                          transformation);
        }

        m_currentState = transformationState;

        // Start the requested state
        m_states[m_currentState]->begin(cmdMediator,
                                        transformation,
                                        selectedGraphCurve);
    }
}
void GraphicsScene::updatePointMembership (CmdMediator &cmdMediator)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::updatePointMembership";

  CallbackSceneUpdateAfterCommand ftor (m_graphicsLinesForCurves,
                                        *this,
                                        cmdMediator.document ());
  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
                                                                                                     &CallbackSceneUpdateAfterCommand::callback);

  // First pass:
  // 1) Mark all points as Not Wanted (this is done while creating the map)
  m_graphicsLinesForCurves.lineMembershipReset ();

  // Next pass:
  // 1) Existing points that are found in the map are marked as Wanted
  // 2) Add new points that were just created in the Document. The new points are marked as Wanted
  cmdMediator.iterateThroughCurvePointsAxes (ftorWithCallback);
  cmdMediator.iterateThroughCurvesPointsGraphs (ftorWithCallback);

  // Next pass:
  // 1) Remove points that were just removed from the Document
  m_graphicsLinesForCurves.lineMembershipPurge (cmdMediator.document().modelCurveStyles());
}
void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
                                      int colLabel)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createXLabel";

  int row = 1; // Skip first row

  QLabel *title;
  if (true) {
    title = new QLabel (tr ("X Label:"));
  } else {
    title = new QLabel (tr ("Theta Label:"));
  }
  layoutHeader->addWidget (title, row++, colLabel, 1, 1);

  m_editXLabel = new QLineEdit;
  if (true) {
    m_editXLabel->setWhatsThis (tr ("Label in the header for x values"));
  } else {
    m_editXLabel->setWhatsThis (tr ("Label in the header for theta values"));
  }
  layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
  connect (m_editXLabel, SIGNAL (textChanged (const QString &)), this, SLOT (slotXLabel(const QString &)));
}
DlgValidatorAbstract *DlgValidatorFactory::createWithNonPolar (CoordScale coordScale,
                                                               CoordUnitsNonPolarTheta coordUnits,
                                                               CoordUnitsDate coordUnitsDate,
                                                               CoordUnitsTime coordUnitsTime) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";

  switch (coordUnits) {
    case COORD_UNITS_NON_POLAR_THETA_DATE_TIME:
      return new DlgValidatorDateTime (coordScale,
                                       coordUnitsDate,
                                       coordUnitsTime);

    case COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS:
      return new DlgValidatorDegreesMinutesSeconds (coordScale);

    case COORD_UNITS_NON_POLAR_THETA_NUMBER:
      return new DlgValidatorNumber(coordScale);

    default:
      LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
      exit (-1);
  }
}
Exemple #6
0
void DlgEditPointGraph::initializeGraphCoordinates (const double *xInitialValue,
                                                    const double *yInitialValue,
                                                    const Transformation &transformation)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgEditPointGraph::initializeGraphCoordinates";

  QString xTheta, yRadius;
  if ((xInitialValue != 0) &&
      (yInitialValue != 0)) {

    FormatCoordsUnits format;
    format.unformattedToFormatted (*xInitialValue,
                                   *yInitialValue,
                                   m_modelCoords,
                                   m_modelGeneral,
                                   m_modelMainWindow,
                                   xTheta,
                                   yRadius,
                                   transformation);
  }

  m_editGraphX->setText (xTheta);
  m_editGraphY->setText (yRadius);
}
Exemple #7
0
void Point::saveXml(QXmlStreamWriter &writer) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Point::saveXml";

  writer.writeStartElement(DOCUMENT_SERIALIZE_POINT);
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_IDENTIFIER, m_identifier);
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_ORDINAL, QString::number (m_ordinal));

  // Variable m_identifierIndex is static, but for simplicity this is handled like other values. Those values are all
  // the same, but simplicity wins over a few extra bytes of storage
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_IDENTIFIER_INDEX, QString::number (m_identifierIndex));

  writer.writeStartElement(DOCUMENT_SERIALIZE_POINT_POSITION_SCREEN);
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_X, QString::number (m_posScreen.x()));
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_Y, QString::number (m_posScreen.y()));
  writer.writeEndElement();

  writer.writeStartElement(DOCUMENT_SERIALIZE_POINT_POSITION_GRAPH);
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_X, QString::number (m_posGraph.x()));
  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_Y, QString::number (m_posGraph.y()));
  writer.writeEndElement();

  writer.writeEndElement();
}
void DlgSettingsDigitizeCurve::createPreview (QGridLayout *layout,
                                         int &row)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsDigitizeCurve::createPreview";

  QLabel *labelPreview = new QLabel ("Preview");
  layout->addWidget (labelPreview, row++, 0, 1, 4);

  m_scenePreview = new QGraphicsScene (this);
  m_scenePreview->setSceneRect(0,
                               0,
                               IMAGE_WIDTH,
                               IMAGE_HEIGHT);

  m_viewPreview = new ViewPreview (m_scenePreview,
                                   ViewPreview::VIEW_ASPECT_RATIO_VARIABLE,
                                   this);
  m_viewPreview->setWhatsThis (tr ("Preview window showing the currently selected cursor"));
  m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  m_viewPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);

  layout->addWidget (m_viewPreview, row++, 0, 1, 4);
}
void DlgSettingsDigitizeCurve::load (CmdMediator &cmdMediator)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsDigitizeCurve::load";

  setCmdMediator (cmdMediator);

  // Flush old data
  if (m_modelDigitizeCurveBefore != 0) {
    delete m_modelDigitizeCurveBefore;
  }
  if (m_modelDigitizeCurveAfter != 0) {
    delete m_modelDigitizeCurveAfter;
  }

  // Save new data
  m_modelDigitizeCurveBefore = new DocumentModelDigitizeCurve (cmdMediator.document());
  m_modelDigitizeCurveAfter = new DocumentModelDigitizeCurve (cmdMediator.document());

  // Sanity checks. Incoming defaults must be acceptable to the local limits
  ENGAUGE_ASSERT (INNER_RADIUS_MIN <= m_modelDigitizeCurveAfter->cursorInnerRadius ());
  ENGAUGE_ASSERT (INNER_RADIUS_MAX >= m_modelDigitizeCurveAfter->cursorInnerRadius ());
  ENGAUGE_ASSERT (LINE_WIDTH_MIN <= m_modelDigitizeCurveAfter->cursorLineWidth ());
  ENGAUGE_ASSERT (LINE_WIDTH_MAX >= m_modelDigitizeCurveAfter->cursorLineWidth ());

  // Populate controls
  m_btnStandard->setChecked (m_modelDigitizeCurveAfter->cursorStandardCross());
  m_btnCustom->setChecked (!m_modelDigitizeCurveAfter->cursorStandardCross());
  m_spinInnerRadius->setValue (m_modelDigitizeCurveAfter->cursorInnerRadius());
  int index = m_cmbSize->findData (QVariant (m_modelDigitizeCurveAfter->cursorSize()));
  m_cmbSize->setCurrentIndex (index);
  m_spinLineWidth->setValue (m_modelDigitizeCurveAfter->cursorLineWidth());

  updateControls();
  enableOk (false); // Disable Ok button since there not yet any changes
  updatePreview();
}
void CurvesGraphs::loadPreVersion6(QDataStream &str)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CurvesGraphs::loadPreVersion6";

  int i;

  // Remove previous Curves. There is a DEFAULT_GRAPH_CURVE_NAME by default
  m_curvesGraphs.clear();

  qint32 numberCurvesGraphs;
  str >> numberCurvesGraphs;
  for (i = 0; i < numberCurvesGraphs; i++) {
    Curve curve (str);
    m_curvesGraphs.append (curve);
  }

  qint32 numberCurvesMeasures;
  str >> numberCurvesMeasures;
  for (i = 0; i < numberCurvesMeasures; i++) {
    Curve curve (str);

    // Measures get dropped on the floor
  }
}
Exemple #11
0
void CurvesGraphs::loadXml(QXmlStreamReader &reader)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CurvesGraphs::loadXml";

  bool success = true;

  // Read until end of this subtree
  while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
  (reader.name() != DOCUMENT_SERIALIZE_CURVES_GRAPHS)){

    if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
        (reader.name () == DOCUMENT_SERIALIZE_CURVE)) {

      Curve curve (reader);

      m_curvesGraphs.push_back (curve);

    } else {

      loadNextFromReader(reader);
      if (reader.hasError()) {
        // No need to set success flag, which raises the error, since error was already raised. Just
        // need to exit loop immediately
        break;
      }
      if (reader.atEnd()) {
        success = false;
        break;
      }
    }
  }

  if (!success) {
    reader.raiseError ("Cannot read graph curves data");
  }
}
const CurvesGraphs &Document::curvesGraphs () const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::curvesGraphs";

  return m_coordSystemContext.curvesGraphs();
}
const Curve *Document::curveForCurveName (const QString &curveName) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::curveForCurveName";

  return m_coordSystemContext.curveForCurveName (curveName);
}
CoordSystemIndex Document::coordSystemIndex() const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::coordSystemIndex";

  return m_coordSystemContext.coordSystemIndex();
}
unsigned int Document::coordSystemCount () const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::coordSystemCount";

  return m_coordSystemContext.coordSystemCount();
}
DlgValidatorAbstract::~DlgValidatorAbstract()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorAbstract::~DlgValidatorAbstract";
}
void BackgroundStateNone::fitInView (GraphicsView &view)
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::fitInView";

  view.fitInView (imageItem ().boundingRect());
}
void BackgroundStateNone::begin()
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::begin";

  setImageVisible (true);
}
void Document::iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::iterateThroughCurvesPointsGraphs";

  m_coordSystemContext.iterateThroughCurvesPointsGraphs(ftorWithCallback);
}
QStringList Document::curvesGraphsNames() const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::curvesGraphsNames";

  return m_coordSystemContext.curvesGraphsNames();
}
int Document::curvesGraphsNumPoints(const QString &curveName) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::curvesGraphsNumPoints";

  return m_coordSystemContext.curvesGraphsNumPoints(curveName);
}
void TutorialStateChecklistWizardPoints::slotPrevious ()
{
    LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateChecklistWizardPoints::slotPrevious";

    context().requestDelayedStateTransition (TUTORIAL_STATE_POINT_MATCH);
}
Document::Document (const QString &fileName) :
  m_name (fileName),
  m_documentAxesPointsRequired (DOCUMENT_AXES_POINTS_REQUIRED_3)
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::Document"
                              << " fileName=" << fileName.toLatin1().data();

  m_successfulRead = true;

  // Grab first few bytes to determine the version number
  QFile *file = new QFile (fileName);
  if (file->open(QIODevice::ReadOnly)) {

    QByteArray bytesStart = file->read (FOUR_BYTES);
    file->close ();

    if (bytesIndicatePreVersion6 (bytesStart)) {

      QFile *file = new QFile (fileName);
      if (file->open (QIODevice::ReadOnly)) {
        QDataStream str (file);

        m_coordSystemContext.addCoordSystems(NOMINAL_COORD_SYSTEM_COUNT);
        loadPreVersion6 (str);

      } else {

        m_successfulRead = false;
        m_reasonForUnsuccessfulRead = QObject::tr ("Operating system says file is not readable");

      }
    } else {

      QFile *file = new QFile (fileName);
      if (file->open (QIODevice::ReadOnly | QIODevice::Text)) {

        int version = versionFromFile (file);
        switch (version)
        {
          case VERSION_6:
            loadVersion6 (file);
            break;

          case VERSION_7:
          case VERSION_8:
          case VERSION_9:
          case VERSION_10:
          case VERSION_11:
            loadVersions7AndUp (file);
            break;

          default:
            m_successfulRead = false;
            m_reasonForUnsuccessfulRead = QString ("Engauge %1 %2 %3 %4 Engauge")
                                          .arg (VERSION_NUMBER)
                                          .arg (QObject::tr ("cannot read newer files from version"))
                                          .arg (version)
                                          .arg (QObject::tr ("of"));
            break;
        }

        // Close and deactivate
        file->close ();
        delete file;
        file = nullptr;

      } else {

        m_successfulRead = false;
        m_reasonForUnsuccessfulRead = QObject::tr ("Operating system says file is not readable");
      }
    }
  } else {
    file->close ();
    m_successfulRead = false;
    m_reasonForUnsuccessfulRead = QString ("%1 '%2' %3")
                                  .arg (QObject::tr ("File"))
                                  .arg (fileName)
                                  .arg (QObject::tr ("was not found"));
  }
}
void TutorialStateIntroduction::slotNext ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateIntroduction::slotNext";

  context().requestDelayedStateTransition (TUTORIAL_STATE_AXIS_POINTS);
}
void BackgroundStateNone::end()
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::end";

  setImageVisible (false);
}
void Document::addGraphCurveAtEnd (const QString &curveName)
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::addGraphCurveAtEnd";

  m_coordSystemContext.addGraphCurveAtEnd  (curveName);
}
void BackgroundStateNone::updateColorFilter (const Transformation & /* transformation */,
                                             const DocumentModelGridRemoval & /* modelGridRemoval */,
                                             const DocumentModelColorFilter & /* modelColorFilter */)
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::updateColorFilter";
}
void Document::addPointsInCurvesGraphs (CurvesGraphs &curvesGraphs)
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::addPointsInCurvesGraphs";

  m_coordSystemContext.addPointsInCurvesGraphs(curvesGraphs);
}
DlgValidatorAbstract::DlgValidatorAbstract(QObject *parent) :
  QDoubleValidator(parent)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorAbstract::DlgValidatorAbstract";
}
const CoordSystem &Document::coordSystem() const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Document::coordSystem";

  return m_coordSystemContext.coordSystem();
}