void ColorFilter::filterImage (const QImage &imageOriginal, QImage &imageFiltered, ColorFilterMode colorFilterMode, double low, double high, QRgb rgbBackground) { ENGAUGE_ASSERT (imageOriginal.width () == imageFiltered.width()); ENGAUGE_ASSERT (imageOriginal.height() == imageFiltered.height()); ENGAUGE_ASSERT (imageFiltered.format () == QImage::Format_RGB32); for (int x = 0; x < imageOriginal.width(); x++) { for (int y = 0; y < imageOriginal.height (); y++) { QColor pixel = imageOriginal.pixel (x, y); bool isOn = false; if (pixel.rgb() != rgbBackground) { isOn = pixelUnfilteredIsOn (colorFilterMode, pixel, rgbBackground, low, high); } imageFiltered.setPixel (x, y, (isOn ? QColor (Qt::black).rgb () : QColor (Qt::white).rgb ())); } } }
QString FormatDegreesMinutesSecondsPolarTheta::formatOutput (CoordUnitsPolarTheta coordUnits, double value, bool isNsHemisphere) const { LOG4CPP_INFO_S ((*mainCat)) << "FormatDegreesMinutesSecondsPolarTheta::formatOutput"; // See if similar method with hemisphere argument should have been called ENGAUGE_ASSERT (coordUnits != COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW); switch (coordUnits) { case COORD_UNITS_POLAR_THETA_DEGREES: return formatOutputDegrees (value); case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES: return formatOutputDegreesMinutes (value); case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS: return formatOutputDegreesMinutesSeconds (value); case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW: return formatOutputDegreesMinutesSecondsNsew (value, isNsHemisphere); default: break; } LOG4CPP_ERROR_S ((*mainCat)) << "FormatDegreesMinutesSecondsPolarTheta::formatOutput"; ENGAUGE_ASSERT (false); return ""; }
void DlgSettingsPointMatch::load (CmdMediator &cmdMediator) { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::load"; setCmdMediator (cmdMediator); // Flush old data if (m_modelPointMatchBefore != 0) { delete m_modelPointMatchBefore; } if (m_modelPointMatchAfter != 0) { delete m_modelPointMatchAfter; } // Save new data m_modelPointMatchBefore = new DocumentModelPointMatch (cmdMediator.document()); m_modelPointMatchAfter = new DocumentModelPointMatch (cmdMediator.document()); // Sanity checks. Incoming defaults must be acceptable to the local limits ENGAUGE_ASSERT (POINT_SIZE_MIN <= m_modelPointMatchAfter->maxPointSize()); ENGAUGE_ASSERT (POINT_SIZE_MAX > m_modelPointMatchAfter->maxPointSize()); // Populate controls m_spinPointSize->setValue(m_modelPointMatchAfter->maxPointSize()); int indexAccepted = m_cmbAcceptedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorAccepted())); ENGAUGE_ASSERT (indexAccepted >= 0); m_cmbAcceptedPointColor->setCurrentIndex(indexAccepted); int indexCandidate = m_cmbCandidatePointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorCandidate())); ENGAUGE_ASSERT (indexCandidate >= 0); m_cmbCandidatePointColor->setCurrentIndex(indexCandidate); int indexRejected = m_cmbRejectedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorRejected())); ENGAUGE_ASSERT (indexRejected >= 0); m_cmbRejectedPointColor->setCurrentIndex(indexRejected); initializeBox (); // Fix the preview size using an invisible boundary QGraphicsRectItem *boundary = m_scenePreview->addRect (QRect (0, 0, cmdMediator.document().pixmap().width (), cmdMediator.document().pixmap().height ())); boundary->setVisible (false); m_scenePreview->addPixmap (cmdMediator.document().pixmap()); updateControls(); enableOk (false); // Disable Ok button since there not yet any changes updatePreview(); }
void GridHealer::connectCloseGroups(QImage &imageToHeal) { LOG4CPP_INFO_S ((*mainCat)) << "GridHealer::connectCloseGroups"; // N*(N-1)/2 search for groups that are close to each other for (int iFrom = 0; iFrom < m_groupNumberToCentroid.count() - 1; iFrom++) { BoundaryGroup groupFrom = m_groupNumberToCentroid.keys().at (iFrom); ENGAUGE_ASSERT (m_groupNumberToCentroid.contains (groupFrom)); ENGAUGE_ASSERT (m_groupNumberToPixel.contains (groupFrom)); QPointF posCentroidFrom = m_groupNumberToCentroid [groupFrom]; QPointF pixelPointFrom = m_groupNumberToPixel [groupFrom]; for (int iTo = iFrom + 1; iTo < m_groupNumberToCentroid.count(); iTo++) { BoundaryGroup groupTo = m_groupNumberToCentroid.keys().at (iTo); ENGAUGE_ASSERT (m_groupNumberToCentroid.contains (groupTo)); ENGAUGE_ASSERT (m_groupNumberToPixel.contains (groupTo)); QPointF posCentroidTo = m_groupNumberToCentroid [groupTo]; QPointF pixelPointTo = m_groupNumberToPixel [groupTo]; QPointF separation = posCentroidFrom - posCentroidTo; double separationMagnitude = qSqrt (separation.x() * separation.x() + separation.y() * separation.y()); if (separationMagnitude < m_modelGridRemoval.closeDistance()) { // Draw line from pixelPointFrom to pixelPointTo int count = 1 + qMax (qAbs (pixelPointFrom.x() - pixelPointTo.x()), qAbs (pixelPointFrom.y() - pixelPointTo.y())); for (int index = 0; index < count; index++) { // Replace PIXEL_STATE_REMOVED by PIXEL_STATE_HEALED double s = (double) index / (double) (count - 1); int xCol = (int) (0.5 + (1.0 - s) * pixelPointFrom.y() + s * pixelPointTo.y()); int yRow = (int) (0.5 + (1.0 - s) * pixelPointFrom.x() + s * pixelPointTo.x()); m_pixels [yRow] [xCol] = PIXEL_STATE_HEALED; // Fill in the pixel imageToHeal.setPixel (QPoint (xCol, yRow), Qt::black); } } } } }
void DlgSettingsGridRemoval::load (CmdMediator &cmdMediator) { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::load"; setCmdMediator (cmdMediator); // Flush old data if (m_modelGridRemovalBefore != 0) { delete m_modelGridRemovalBefore; } if (m_modelGridRemovalAfter != 0) { delete m_modelGridRemovalAfter; } // Save new data m_modelGridRemovalBefore = new DocumentModelGridRemoval (cmdMediator.document()); m_modelGridRemovalAfter = new DocumentModelGridRemoval (cmdMediator.document()); // Sanity checks. Incoming defaults must be acceptable to the local limits ENGAUGE_ASSERT (CLOSE_DISTANCE_MIN <= m_modelGridRemovalAfter->closeDistance()); ENGAUGE_ASSERT (CLOSE_DISTANCE_MAX >= m_modelGridRemovalAfter->closeDistance()); // Populate controls m_chkRemoveGridLines->setChecked (m_modelGridRemovalAfter->removeDefinedGridLines()); m_editCloseDistance->setText (QString::number (m_modelGridRemovalAfter->closeDistance())); int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableX())); m_cmbDisableX->setCurrentIndex (indexDisableX); m_editCountX->setText(QString::number(m_modelGridRemovalAfter->countX())); m_editStartX->setText(QString::number(m_modelGridRemovalAfter->startX())); m_editStepX->setText(QString::number(m_modelGridRemovalAfter->stepX())); m_editStopX->setText(QString::number(m_modelGridRemovalAfter->stopX())); int indexDisableY = m_cmbDisableX->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableY())); m_cmbDisableY->setCurrentIndex (indexDisableY); m_editCountY->setText(QString::number(m_modelGridRemovalAfter->countY())); m_editStartY->setText(QString::number(m_modelGridRemovalAfter->startY())); m_editStepY->setText(QString::number(m_modelGridRemovalAfter->stepY())); m_editStopY->setText(QString::number(m_modelGridRemovalAfter->stopY())); m_scenePreview->clear(); m_scenePreview->addPixmap (cmdMediator.document().pixmap()); updateControls (); enableOk (false); // Disable Ok button since there not yet any changes updatePreview(); }
ExportAlignLinear::ExportAlignLinear(double xMin, double xMax) { ENGAUGE_ASSERT (xMin <= xMax); // Start with digit N=1, then keep adding to that digit until: // 1) number is between xMin and xMax in which case that value is the result // 2) number exceeds xMax in which case digit N+1 is added and this repeats double powerOf10 = qPow (10.0, (int) (log10 (qAbs (xMin)) + EPSILON)); int firstDigit = (int) (xMin / powerOf10); double digitsCurrent = firstDigit * powerOf10; // May or may not be less than xMax while (digitsCurrent > xMin) { digitsCurrent -= powerOf10; // Go backwards until less than xMin. Required only if xMin < 0 } double digitsHighestUnderXMin = digitsCurrent; do { digitsCurrent = digitsHighestUnderXMin; // Go back to highest value so far less than xMin while (digitsCurrent < xMin) { digitsCurrent += powerOf10; if (digitsCurrent < xMin) { digitsHighestUnderXMin = digitsCurrent; } } powerOf10 /= 10.0; } while (digitsCurrent > xMax); m_firstSimplestNumber = digitsCurrent; }
GridHealer::GridHealer(const QImage &imageBefore, const DocumentModelGridRemoval &modelGridRemoval) : m_boundaryGroupNext (BOUNDARY_GROUP_FIRST), m_modelGridRemoval (modelGridRemoval) { LOG4CPP_INFO_S ((*mainCat)) << "GridHealer::GridHealer"; // Prevent ambiguity between PixelState and the group numbers ENGAUGE_ASSERT (NUM_PIXEL_STATES < BOUNDARY_GROUP_FIRST); m_pixels.resize (imageBefore.height()); for (int row = 0; row < imageBefore.height(); row++) { m_pixels [row].resize (imageBefore.width()); for (int col = 0; col < imageBefore.width(); col++) { QRgb rgb = imageBefore.pixel(col, row); if (qGray (rgb) > 128) { m_pixels [row] [col] = PIXEL_STATE_BACKGROUND; } else { m_pixels [row] [col] = PIXEL_STATE_FOREGROUND; } } } }
double Matrix::determinant () const { ENGAUGE_ASSERT (m_rows == m_cols); double rtn; if (m_rows == 1) { rtn = m_vector [0]; } else { const int COL = 0; // We arbitrarily iterate through the first column // This is a recursive algorithm rtn = 0.0; double multiplier = +1; for (int row = 0; row < m_rows; row++) { Matrix min = minorReduced (row, COL); rtn += multiplier * get (row, COL) * min.determinant (); multiplier *= -1.0; } } return rtn; }
Matrix Matrix::minorReduced (int rowOmit, int colOmit) const { ENGAUGE_ASSERT (m_rows == m_cols); Matrix outMinor (m_rows - 1); int rowMinor = 0; for (int row = 0; row < m_rows; row++) { if (row != rowOmit) { int colMinor = 0; for (int col = 0; col < m_cols; col++) { if (col != colOmit) { outMinor.set (rowMinor, colMinor, get (row, col)); ++colMinor; } } ++rowMinor; } } return outMinor; }
void Document::initializeGridDisplay (const Transformation &transformation) { LOG4CPP_INFO_S ((*mainCat)) << "Document::initializeGridDisplay"; ENGAUGE_ASSERT (!m_coordSystemContext.modelGridDisplay().stable()); // Get graph coordinate bounds CallbackBoundingRects ftor (m_documentAxesPointsRequired, transformation); Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor, &CallbackBoundingRects::callback); iterateThroughCurvePointsAxes (ftorWithCallback); // Initialize. Note that if there are no graph points then these next steps have no effect bool isEmpty; QPointF boundingRectGraphMin = ftor.boundingRectGraphMin (isEmpty); QPointF boundingRectGraphMax = ftor.boundingRectGraphMax (isEmpty); if (!isEmpty) { GridInitializer gridInitializer; DocumentModelGridDisplay modelGridDisplay = gridInitializer.initializeWithWidePolarCoverage (boundingRectGraphMin, boundingRectGraphMax, modelCoords(), transformation, m_pixmap.size ()); m_coordSystemContext.setModelGridDisplay (modelGridDisplay); } }
void ViewProfileScale::paintEvent (QPaintEvent *event) { switch (m_colorFilterMode) { case COLOR_FILTER_MODE_FOREGROUND: paintForeground (); break; case COLOR_FILTER_MODE_HUE: paintHue (); break; case COLOR_FILTER_MODE_INTENSITY: paintIntensity (); break; case COLOR_FILTER_MODE_SATURATION: paintSaturation (); break; case COLOR_FILTER_MODE_VALUE: paintValue (); break; default: ENGAUGE_ASSERT (false); } QLabel::paintEvent (event); }
void DigitizeStateContext::appendNewCmd(QUndoCommand *cmd) { LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateContext::appendNewCmd"; ENGAUGE_ASSERT (m_cmdMediator != 0); m_cmdMediator->push (cmd); }
CmdDelete::CmdDelete (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader) : CmdAbstract (mainWindow, document, cmdDescription) { LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::CmdDelete"; QXmlStreamAttributes attributes = reader.attributes(); if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) || !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) || !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) { ENGAUGE_ASSERT (false); } QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString(); m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE); m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString(); m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString(); m_curvesGraphs.loadXml(reader); }
void Checker::prepareForDisplay (const QPolygonF &polygon, int pointRadius, const DocumentModelAxesChecker &modelAxesChecker, const DocumentModelCoords &modelCoords) { LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay"; ENGAUGE_ASSERT (polygon.count () == NUM_AXES_POINTS); // Convert pixel coordinates in QPointF to screen and graph coordinates in Point using // identity transformation, so this routine can reuse computations provided by Transformation QList<Point> points; QPolygonF::const_iterator itr; for (itr = polygon.begin (); itr != polygon.end (); itr++) { const QPointF &pF = *itr; Point p (DUMMY_CURVENAME, pF, pF); points.push_back (p); } // Screen and graph coordinates are treated as the same, so identity transform is used Transformation transformIdentity; transformIdentity.identity(); prepareForDisplay (points, pointRadius, modelAxesChecker, modelCoords, transformIdentity); }
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 } }
void DigitizeStateContext::setCursor (CmdMediator *cmdMediator) { LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateContext::setCursor"; ENGAUGE_ASSERT(m_currentState < m_states.count()); m_states [m_currentState]->setCursor (cmdMediator); }
void DigitizeStateContext::updateModelSegments(const DocumentModelSegments &modelSegments) { LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateContext::updateModelSegments"; ENGAUGE_ASSERT(m_currentState < m_states.count()); m_states [m_currentState]->updateModelSegments (modelSegments); }
void GraphicsLinesForCurves::removeTemporaryPointIfExists() { LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurves::removeTemporaryPointIfExists"; QString curveName = Point::curveNameFromPointIdentifier(Point::temporaryPointIdentifier()); ENGAUGE_ASSERT (m_graphicsLinesForCurve.contains (curveName)); m_graphicsLinesForCurve [curveName]->removeTemporaryPointIfExists (); }
void DlgSettingsDigitizeCurve::createControls (QGridLayout *layout, int &row) { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsDigitizeCurve::createControls"; m_boxCursor = new QGroupBox ("Cursor"); layout->addWidget (m_boxCursor, row++, 1, 1, 2); // Layout inside cursor group box QGridLayout *layoutCursor = new QGridLayout; m_boxCursor->setLayout (layoutCursor); int rowCursor = 0; QLabel *labelCursorType = new QLabel("Type:"); layoutCursor->addWidget (labelCursorType, rowCursor, 0); m_btnStandard = new QRadioButton ("Standard cross"); m_btnStandard->setWhatsThis (tr ("Selects the standard cross cursor")); layoutCursor->addWidget (m_btnStandard, rowCursor++, 1); connect (m_btnStandard, SIGNAL (toggled (bool)), this, SLOT (slotCursorStandard(bool))); m_btnCustom = new QRadioButton ("Custom cross"); m_btnCustom->setWhatsThis (tr ("Selects a custom cursor based on the settings selected below")); layoutCursor->addWidget (m_btnCustom, rowCursor++, 1); connect (m_btnCustom, SIGNAL (toggled (bool)), this, SLOT (slotCursorCustom(bool))); QLabel *labelSize = new QLabel("Size (pixels):"); layoutCursor->addWidget (labelSize, rowCursor, 0); m_cmbSize = new QComboBox; m_cmbSize->addItem (QString::number (CursorSizeToPixels (CURSOR_SIZE_16)), QVariant (CURSOR_SIZE_16)); m_cmbSize->addItem (QString::number (CursorSizeToPixels (CURSOR_SIZE_32)), QVariant (CURSOR_SIZE_32)); m_cmbSize->addItem (QString::number (CursorSizeToPixels (CURSOR_SIZE_48)), QVariant (CURSOR_SIZE_48)); m_cmbSize->addItem (QString::number (CursorSizeToPixels (CURSOR_SIZE_64)), QVariant (CURSOR_SIZE_64)); ENGAUGE_ASSERT (m_cmbSize->count() == NUM_CURSOR_SIZES); m_cmbSize->setWhatsThis (tr ("Horizontal and vertical size of the cursor in pixels")); layoutCursor->addWidget (m_cmbSize, rowCursor++, 1); connect (m_cmbSize, SIGNAL (currentIndexChanged (const QString &)), this, SLOT (slotCursorSize (const QString &))); QLabel *labelInnerRadius = new QLabel("Inner radius (pixels):"); layoutCursor->addWidget (labelInnerRadius, rowCursor, 0); m_spinInnerRadius = new QSpinBox; m_spinInnerRadius->setRange (INNER_RADIUS_MIN, INNER_RADIUS_MAX); m_spinInnerRadius->setWhatsThis (tr ("Radius of circle at the center of the cursor that will remain empty")); layoutCursor->addWidget (m_spinInnerRadius, rowCursor++, 1); connect (m_spinInnerRadius, SIGNAL (valueChanged(const QString &)), this, SLOT (slotCursorInnerRadius (const QString &))); QLabel *labelLineWidth = new QLabel("Line width (pixels):"); layoutCursor->addWidget (labelLineWidth, rowCursor, 0); m_spinLineWidth = new QSpinBox; m_spinLineWidth->setRange (LINE_WIDTH_MIN, LINE_WIDTH_MAX); m_spinLineWidth->setWhatsThis (tr ("Width of each arm of the cross of the cursor")); layoutCursor->addWidget (m_spinLineWidth, rowCursor++, 1); connect (m_spinLineWidth, SIGNAL (valueChanged(const QString &)), this, SLOT (slotCursorLineWidth (const QString &))); }
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); }
void CoordSystemContext::setCoordSystemIndex(CoordSystemIndex coordSystemIndex) { LOG4CPP_INFO_S ((*mainCat)) << "CoordSystemContext::setCoordSystemIndex" << " index=" << coordSystemIndex; ENGAUGE_ASSERT(coordSystemIndex < (unsigned int) m_coordSystems.count()); m_coordSystemIndex = coordSystemIndex; }
void DlgSettingsSegments::load (CmdMediator &cmdMediator) { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::load"; // Loading starts here m_loading = true; setCmdMediator (cmdMediator); // Flush old data if (m_modelSegmentsBefore != 0) { delete m_modelSegmentsBefore; } if (m_modelSegmentsAfter != 0) { delete m_modelSegmentsAfter; } // Save new data m_modelSegmentsBefore = new DocumentModelSegments (cmdMediator.document()); m_modelSegmentsAfter = new DocumentModelSegments (cmdMediator.document()); // Sanity checks. Incoming defaults must be acceptable to the local limits ENGAUGE_ASSERT (MIN_LENGTH_MIN <= m_modelSegmentsAfter->minLength ()); ENGAUGE_ASSERT (MIN_LENGTH_MAX >= m_modelSegmentsAfter->minLength ()); ENGAUGE_ASSERT (POINT_SEPARATION_MIN <= m_modelSegmentsAfter->pointSeparation()); ENGAUGE_ASSERT (POINT_SEPARATION_MAX >= m_modelSegmentsAfter->pointSeparation()); // Populate controls m_spinPointSeparation->setValue (m_modelSegmentsAfter->pointSeparation()); m_spinMinLength->setValue (m_modelSegmentsAfter->minLength()); m_chkFillCorners->setChecked (m_modelSegmentsAfter->fillCorners ()); m_spinLineWidth->setValue (m_modelSegmentsAfter->lineWidth()); int indexLineColor = m_cmbLineColor->findData(QVariant (m_modelSegmentsAfter->lineColor())); ENGAUGE_ASSERT (indexLineColor >= 0); m_cmbLineColor->setCurrentIndex(indexLineColor); // Loading finishes here m_loading = false; updateControls(); enableOk (false); // Disable Ok button since there not yet any changes updatePreview(); }
void DigitizeStateContext::updateModelDigitizeCurve (CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve) { LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateContext::updateModelDigitizeCurve"; ENGAUGE_ASSERT(m_currentState < m_states.count()); m_states [m_currentState]->updateModelDigitizeCurve (cmdMediator, modelDigitizeCurve); }
TransformationStateContext::TransformationStateContext(QGraphicsScene &scene, bool isGnuplot) : m_isGnuplot (isGnuplot) { m_states.insert (TRANSFORMATION_STATE_DEFINED , new TransformationStateDefined (*this, scene)); m_states.insert (TRANSFORMATION_STATE_UNDEFINED, new TransformationStateUndefined (*this, scene)); ENGAUGE_ASSERT (m_states.size () == NUM_TRANSFORMATION_STATES); m_currentState = NUM_TRANSFORMATION_STATES; // Value that forces a transition right away }
QPointF GridRemoval::clipY (const QPointF &posUnprojected, double yBoundary, const QPointF &posOther) const { double s = (yBoundary - posUnprojected.y()) / (posOther.y() - posUnprojected.y()); ENGAUGE_ASSERT ((-1.0 * EPSILON < s) && (s < 1.0 + EPSILON)); return QPointF ((1.0 - s) * posUnprojected.x() + s * posOther.x(), (1.0 - s) * posUnprojected.y() + s * posOther.y()); }
Point::Point(const QString &curveName, const QPointF &posScreen, double ordinal, const QPointF posGraph) : m_identifier (uniqueIdentifierGenerator(curveName)), m_posScreen (posScreen), m_posGraph (posGraph), m_ordinal (ordinal) { ENGAUGE_ASSERT (!curveName.isEmpty ()); }
Point::Point(const QString &curveName, const QPointF &posScreen, const QString &identifier, double ordinal, const QPointF posGraph) : m_identifier (identifier), m_posScreen (posScreen), m_posGraph (posGraph), m_ordinal (ordinal) { ENGAUGE_ASSERT (!curveName.isEmpty ()); }
void GraphicsLinesForCurves::removePoint(const QString &identifier) { LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurves::removePoint" << " point=" << identifier.toLatin1().data () << " curveCount=" << m_graphicsLinesForCurve.count(); QString curveName = Point::curveNameFromPointIdentifier(identifier); ENGAUGE_ASSERT (m_graphicsLinesForCurve.contains (curveName)); double ordinal = m_graphicsLinesForCurve [curveName]->identifierToOrdinal (identifier); m_graphicsLinesForCurve [curveName]->removePoint(ordinal); }
Matrix Matrix::inverseCramersRule (MatrixConsistent & matrixConsistent, double epsilonThreshold) const { ENGAUGE_ASSERT (m_rows == m_cols); Matrix inv (m_rows); int row, col; if (m_rows > 1) { // Compute cofactor matrix double multiplierStartForRow = 1.0; Matrix cofactor (m_rows); for (row = 0; row < m_rows; row++) { double multiplier = multiplierStartForRow; for (col = 0; col < m_cols; col++) { Matrix min = minorReduced (row, col); double element = multiplier * min.determinant (); multiplier *= -1.0; cofactor.set (row, col, element); } multiplierStartForRow *= -1.0; } // Compute adjoint Matrix adjoint = cofactor.transpose (); double determ = determinant (); if (valueFailsEpsilonTest (determ, epsilonThreshold)) { matrixConsistent = MATRIX_INCONSISTENT; return inv; } // Inverse is the adjoint divided by the determinant for (row = 0; row < m_rows; row++) { for (col = 0; col < m_cols; col++) { inv.set (row, col, adjoint.get (row, col) / determ); } } } else { double denominator = get (0, 0); if (valueFailsEpsilonTest (denominator, epsilonThreshold)) { matrixConsistent = MATRIX_INCONSISTENT; return inv; } inv.set (0, 0, 1.0 / denominator); } return inv; }
void Checker::prepareForDisplay (const QList<Point> &points, int pointRadius, const DocumentModelAxesChecker &modelAxesChecker, const DocumentModelCoords &modelCoords, const Transformation &transformation) { LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay " << " transformation=" << transformation; ENGAUGE_ASSERT (points.count () == NUM_AXES_POINTS); // Remove previous lines deleteSide (m_sideLeft); deleteSide (m_sideTop); deleteSide (m_sideRight); deleteSide (m_sideBottom); // Get the min and max of x and y double xFrom, xTo, yFrom, yTo; int i; for (i = 0; i < NUM_AXES_POINTS; i++) { if (i == 0) { xFrom = points.at(i).posGraph().x(); xTo = points.at(i).posGraph().x(); yFrom = points.at(i).posGraph().y(); yTo = points.at(i).posGraph().y(); } xFrom = qMin (xFrom, points.at(i).posGraph().x()); xTo = qMax (xTo , points.at(i).posGraph().x()); yFrom = qMin (yFrom, points.at(i).posGraph().y()); yTo = qMax (yTo , points.at(i).posGraph().y()); } // Min and max of angles needs special processing since periodicity introduces some ambiguity. This is a noop for rectangular coordinates // and for polar coordinates when periodicity is not an issue adjustPolarAngleRanges (modelCoords, transformation, points, xFrom, xTo, yFrom); // Draw the bounding box as four sides. In polar plots the bottom side is zero-length, with pie shape resulting createSide (pointRadius, points, modelCoords, xFrom, yFrom, xFrom, yTo , transformation, m_sideLeft); createSide (pointRadius, points, modelCoords, xFrom, yTo , xTo , yTo , transformation, m_sideTop); createSide (pointRadius, points, modelCoords, xTo , yTo , xTo , yFrom, transformation, m_sideRight); createSide (pointRadius, points, modelCoords, xTo , yFrom, xFrom, yFrom, transformation, m_sideBottom); updateModelAxesChecker (modelAxesChecker); }