예제 #1
0
    UpdateAxis
    (
        Smrf.WpfGraphicsLib.Axis oAxis,
        String sAxisLabel,
        Double dSourceCalculationNumber1,
        Double dSourceCalculationNumber2,
        Double dDestinationNumber1,
        Double dDestinationNumber2,
        Boolean bLogsUsed
    )
    {
        Debug.Assert(oAxis != null);
        Debug.Assert(sAxisLabel != null);
        Debug.Assert(oNodeXLControl != null);
        // AssertValid();

        oAxis.Label = sAxisLabel;

        Double dAxisLength =
            oAxis.IsXAxis ? oAxis.ActualWidth : oAxis.ActualHeight;

        if (dAxisLength == 0)
        {
            // The axis control hasn't been drawn yet.

            oAxis.SetRange(VertexLocationConverter.MinimumXYWorkbook, 0,
                VertexLocationConverter.MaximumXYWorkbook, 0, false);

            return;
        }

        // dSourceCalculationNumber1 and dDestinationNumber1 are not
        // necessarily at the near end of the axis.

        Double dNearSourceCalculationNumber, dNearDestinationNumber,
            dFarSourceCalculationNumber, dFarDestinationNumber,
            dNearOffset;

        if (dDestinationNumber2 >= dDestinationNumber1)
        {
            dNearSourceCalculationNumber = dSourceCalculationNumber1;
            dNearDestinationNumber = dDestinationNumber1;

            dFarSourceCalculationNumber = dSourceCalculationNumber2;
            dFarDestinationNumber = dDestinationNumber2;
        }
        else
        {
            dNearSourceCalculationNumber = dSourceCalculationNumber2;
            dNearDestinationNumber = dDestinationNumber2;

            dFarSourceCalculationNumber = dSourceCalculationNumber1;
            dFarDestinationNumber = dDestinationNumber1;
        }

        // Use the point-slope equation of a line to map destination units to
        // WPF units.

        Double dX1 = VertexLocationConverter.MinimumXYWorkbook;
        Double dY1 = 0;
        Double dX2 = VertexLocationConverter.MaximumXYWorkbook;
        Double dY2 = dAxisLength;

        Debug.Assert(dX1 != dX2);
        Double dM = (dY1 - dY2) / (dX1 - dX2);

        dNearOffset = dY1 + dM * (dNearDestinationNumber - dX1);
        Double dFarX = dY1 + dM * (dFarDestinationNumber - dX1);

        // Use Math.Max() to fix rounding errors that result in very small
        // negative offsets, which are prohibited.

        oAxis.SetRange(dNearSourceCalculationNumber, Math.Max(dNearOffset, 0),
            dFarSourceCalculationNumber, Math.Max(dAxisLength - dFarX, 0),
            bLogsUsed);
    }
 ShouldGroupByMotif
 (
     Smrf.NodeXL.Algorithms.Motifs eMotif
 )
 {
     return ( (m_oMotifUserSettings.MotifsToCalculate & eMotif) != 0 );
 }