コード例 #1
0
ファイル: Document.cpp プロジェクト: mach0/engauge6
void Document::initializeGridDisplay (const Transformation &transformation)
{
    LOG4CPP_INFO_S ((*mainCat)) << "Document::initializeGridDisplay";

    ENGAUGE_ASSERT (!m_coordSystemContext.modelGridDisplay().stable());

    // Get graph coordinate bounds
    CallbackBoundingRects ftor (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;
    QRectF boundingRectGraph =  ftor.boundingRectGraph(isEmpty);
    if (!isEmpty) {

        GridInitializer gridInitializer;

        DocumentModelGridDisplay modelGridDisplay = gridInitializer.initialize (boundingRectGraph,
                modelCoords());
        m_coordSystemContext.setModelGridDisplay (modelGridDisplay);
    }
}
コード例 #2
0
void DlgSettingsExportFormat::initializeIntervalConstraints ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::initializeIntervalConstraints";

  const int MAX_POINTS_ACROSS_RANGE = 1000;

  // Get min and max of graph and screen coordinates
  CallbackBoundingRects ftor (mainWindow().transformation());

  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
                                                                                                     &CallbackBoundingRects::callback);
  cmdMediator().iterateThroughCurvesPointsGraphs (ftorWithCallback);

  // If there are no points, then interval will be zero. That special case must be handled downstream to prevent infinite loops
  bool isEmpty;
  double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
                              ftor.boundingRectGraph(isEmpty).height());
  double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
                               ftor.boundingRectScreen(isEmpty).height());
  m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
  m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
}