예제 #1
0
function getCrossFromParams($params)
{
    extract($params);
    //if (!isset($round) ) $round = .12;
    if (!isset($totalSize)) {
        $totalSize = 140;
    }
    if (!isset($crossSize)) {
        $crossSize = $totalSize * 0.8;
    }
    $halfCross = $crossSize / 2;
    $gutter = ($totalSize - $crossSize) / 2;
    // label: 0= no label, 1=label in given cyl type; 2= both +/- cyl;
    //3= if minus show minus, if plus show minus and plus
    if (!isset($label)) {
        $label = 0;
    }
    if (!isset($doVertex)) {
        $doVertex = null;
    }
    if (!isset($doSphEquiv)) {
        $doSphEquiv = null;
    }
    if (!isset($rxString) && !isset($kString)) {
        return null;
    }
    //get the numbers and meridians if an Rx string is passed
    if (isset($rxString)) {
        $rxObject = rxStringBreaker($rxString);
        if ($doVertex == 1) {
            $rxObject = $rxObject->diffVertex(0);
        }
        if ($doSphEquiv == 1) {
            $rxObject = rxStringBreaker($rxObject->sphericalEquivalent());
        }
        $num1 = numToDiopterString($rxObject->sphP(), 1);
        $num2 = numToDiopterString($rxObject->sphP() + $rxObject->cylP(), 1);
        $meridian1 = $rxObject->axisP();
    }
    if (isset($kString)) {
        //	echo "string: " . $kString;
        $kObject = kStringBreaker($kString);
        $num1 = numToDiopterString($kObject->pwr1D(), 0) . "<br>(" . numToMMString($kObject->pwr1mm()) . ")";
        $num2 = numToDiopterString($kObject->pwr2D(), 0) . "<br>(" . numToMMString($kObject->pwr2mm()) . ")";
        $meridian1 = $kObject->meridian1;
        $meridian2 = $kObject->meridian2;
        if ($label > 0) {
            $niceString1 = $kObject->prettyStringD();
        }
        if ($label == 2) {
            $niceString2 = $kObject->prettyStringMM();
        }
    }
    if ($label > 0 && isset($rxString)) {
        if ($label == 1) {
            $niceString1 = $doVertex == 1 ? $rxObject->prettyStringMinus() : $rxObject->prettyString();
        }
        if ($label == 2) {
            $niceString1 = $rxObject->prettyStringPlus();
            $niceString2 = $rxObject->prettyStringMinus();
        }
        if ($label == 3) {
            $plusCyl = $rxObject->isPlusCyl();
            //the cyl type the original Rx was given in
            $niceString1 = $rxObject->prettyStringMinus();
            if ($plusCyl == 1) {
                $niceString2 = "(" . $rxObject->prettyStringPlus() . ")";
            }
        }
    }
    if (isset($bgImage)) {
        switch ($bgImage) {
            case "lens":
                if (isset($rxObject) && $rxObject->isToric() == 1) {
                    $image = "/images/crosses/toric_lens.png";
                } else {
                    $image = "/images/crosses/sphere_lens.png";
                }
                break;
            case "spherelens":
                $image = "/images/crosses/sphere_lens.png";
                break;
            case "toriclens":
                $image = "/images/crosses/toric_lens.png";
                break;
            default:
                $image = $bgImage;
        }
    }
    //start the html and CSS we'll be returning
    $html = "";
    if (isset($header)) {
        $html .= "<div class='opticalCrossLabel' style='font-weight:bold; text-align: center; margin: .5em;'>{$header}</div>";
    }
    $canvasCSS = "position: relative; height:" . $totalSize . "px; width: " . $totalSize . "px;";
    if (isset($image)) {
        $canvasCSS .= "background-image: url(" . $image . "); background-repeat:no-repeat;background-position:center; ";
    }
    $html .= "<div style='{$canvasCSS}'>";
    $labelCSS = "width: 40px; height: 25px; position: absolute; text-align: center;";
    //echo("toric " . $rxObject ->isToric()  );
    //don't need to worry about optical crosses if the lens is spherical
    if (isset($rxObject) && $rxObject->isToric() == 0) {
        // a spacer div
        $html .= "<div style='margin: 0 " . $gutter . "px " . $gutter * 2 . "px; width: " . $crossSize . "px; height: " . $crossSize . "px'>&nbsp;</div>";
        $html .= "<div style=' " . $labelCSS . " ; top: " . ($halfCross + 4) . "px; left: " . ($halfCross - 8) . "px; '>";
        $html .= numToDiopterString($num1, 1);
        $html .= "</div>";
    } else {
        //toric lenses
        //an url to the optical cross images (it will be completed below - we need to calculate the angle to get the correct image)
        if (!isset($crossImage)) {
            $crossImage = "http://www.eyedock.com/images/crosses/cross";
        }
        if (!isset($meridian2)) {
            $meridian2 = fixAxis($meridian1 + 90);
        }
        //find the closest 10 deg increment (for the image)
        $imageAngle = fixAxis($meridian1);
        $imageAngle = round($imageAngle / 10) * 10;
        if ($imageAngle > 90) {
            $imageAngle -= 90;
        }
        //echo $imageAngle;
        $radAngle1 = $meridian1 * (M_PI / 180);
        $radAngle2 = $meridian2 * (M_PI / 180);
        $x1 = intval(cos($radAngle1) * ($halfCross + $gutter) + $halfCross) - 6;
        $y1 = intval(-(sin($radAngle1) * ($halfCross + $gutter)) + $halfCross + $gutter / 2);
        $x2 = intval(cos($radAngle2) * ($halfCross + $gutter) + $halfCross) - 6;
        $y2 = intval(-(sin($radAngle2) * ($halfCross + $gutter)) + $halfCross + $gutter / 2);
        $crossCSS = "width: " . $crossSize . "px; height: " . $crossSize . "px; margin:" . $gutter . "px";
        $num1CSS = $labelCSS . "top: " . $y1 . "px; left: " . $x1 . "px; ";
        $num2CSS = $labelCSS . "top: " . $y2 . "px; left: " . $x2 . "px; ";
        $num1aCSS = $labelCSS . "bottom: " . ($y1 - $gutter / 2) . "px; right: " . $x1 . "px; ";
        $num2aCSS = $labelCSS . "bottom: " . ($y2 - $gutter / 2) . "px; right: " . $x2 . "px; ";
        $html .= "<img style='{$crossCSS}' src='" . $crossImage . $imageAngle . ".png" . "' />";
        $html .= "<div class='cross_num1' style='{$num1CSS}' >" . $num1 . "</div>";
        $html .= "<div class='cross_num2' style='{$num2CSS}' >" . $num2 . "</div>";
        $html .= "<div class='cross_meridian1' style='{$num1aCSS}' >" . numToAxisString($meridian1) . "</div>";
        $html .= "<div class='cross_meridian2' style='{$num2aCSS}' >" . numToAxisString($meridian2) . "</div>";
    }
    //  end toric lenses / crosses
    //add the labels, if wanted
    if (isset($niceString1)) {
        $css = "width: {$totalSize} px; text-align: center";
        $html .= "<div class='opticalCrossLabel' style='{$css}'>" . $niceString1 . "</div>";
        if (isset($niceString2)) {
            $html .= "<div class='opticalCrossLabel' style='{$css}'>" . $niceString2 . "</div>";
        }
    }
    if ($doVertex == 1) {
        $html .= "<div class='opticalCrossLabel' style='{$css} ;font-size:smaller;opticalCrossLabel margin: .5em;'>(vertexed) </div>";
    }
    $html .= "</div>";
    return $html;
}
예제 #2
0
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
//pass a keratometry string in one of these formats:
// 42/43 @ 90
// 42@180 / 43 @ 90
// if needed, make sure to URL encode: "@" = %40, "/" = %2F
include_once "../phpClasses/RxHelper.php";
include_once "../phpClasses/KeratoObject.php";
include_once "opticalcrossfunc.php";
$kerato = $_REQUEST['k'];
//escape slash with %2F, @ with %40
//echo $kerato;
//$subscriber = $_REQUEST['subscriber'];
$keratoObj = kStringBreaker($kerato);
$params['kString'] = $kerato;
$params['bgImage'] = "spherelens";
$params['label'] = "2";
echo "<table><tr><td style='padding: 20px'>";
echo getCrossFromParams($params);
echo "</td>\t<td>";
echo "<table>";
echo "<tr><th colspan=2><u>Keratometry</u></th></tr>";
//if ($rxObj->isToric() ) {
echo "<tr><td>Flat K: </td><td> " . $keratoObj->flatK(1, 1) . " @ " . $keratoObj->flatKMeridian();
echo "</td></tr>";
echo "<tr><td>Steep K: </td><td> " . $keratoObj->steepK(1, 1) . " @ " . $keratoObj->steepKMeridian();
echo "</td></tr>";
echo "<tr><td>Avg K: </td><td> " . $keratoObj->midK(1, 1);
echo " (" . $keratoObj->midK(1, 1, 1) . ")";
예제 #3
0
파일: search2.php 프로젝트: grlf/eyedock
if (($k || $all) && !$hasSign) {
    if ($isNumber) {
        $kValObj = new KvalObject($q);
        if ($kValObj->isValidK()) {
            if ($kValObj->isMM()) {
                $kInfo['label'] = $kValObj->prettyStringMM() . "mm = " . $kValObj->prettyStringD() . "D";
            }
            if ($kValObj->isD()) {
                $kInfo['label'] = $kValObj->prettyStringD() . "D = " . $kValObj->prettyStringMM() . "mm";
            }
            $kInfo['type'] = "keratometry";
            $kInfo['k'] = $q;
            array_push($return, $kInfo);
        }
    }
    $kObj = kStringBreaker($q);
    if ($kObj->isValidK()) {
        $kInfo['label'] = $kObj->prettyString() . ": get info";
        $kInfo['type'] = "keratometry";
        $kInfo['k'] = $kObj->prettyString();
        array_push($return, $kInfo);
    }
}
//-----------------------------for meds searchs (by name, chem, or company) ----------------------------
if (($meds || $all) && !$hasSign) {
    foreach ($phrase_array as $value) {
        $chem[] = " chem.pn_name LIKE '%{$value}%' ";
        $rx_comp[] = " comp.pn_name  LIKE '%{$value}%' ";
        $trade[] = " pn_trade LIKE '%{$value}%' ";
    }
    $chemString = implode(" AND ", $chem);