Copyright (c) 2002, DM Solutions Group Inc. * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ include_once(dirname(__FILE__)."/../Widget.php"); include_once(dirname(__FILE__)."/../Button.php"); /** * ROIRectangleTool * * @desc A widget to draw a rectangular Region of Interest */ class ROIRectangleTool extends CWCWidget { /* the button that is the interface for this widget */ var $moButton; /** * construct a new ROI Rectangle Tool widget */ function ROIRectangleTool() { // invoke constructor of parent parent::CWCWidget(); // set the description for this widget $this->szWidgetDescription = <<moButton = new CWCButton( $this ); $this->mnMaturityLevel = MATURITY_BETA; } /** * */ function InitDefaults() { parent::InitDefaults(); $this->moButton->InitDefaults(); $this->moButton->SetOnClick('ROIRectTool'.$this->mnId); } /** * pass URL to button */ function ParseURL() { return $this->moButton->ParseURL(); } function GetHTMLHiddenVariables() { $aReturn = $this->moButton->GetHTMLHiddenVariables(); $szCmd = ''; if ($this->isVarSet('NAV_CMD')) $szCmd = $this->getVar('NAV_CMD'); $szVariable = "NAV_CMD"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; return $aReturn; } /** * GetJavascriptInitFunctions * * Functions to be called at the end of the load. */ function GetJavascriptInitFunctions() { $aReturn = $this->moButton->GetJavascriptInitFunctions(); $szJsFunctionName = "ROIRectToolInit"; $szFunction = "$szJsFunctionName();\n"; $aReturn[$szJsFunctionName] = $szFunction; $aReturn['InitCWCROIManagerForm'] = 'goCWCROIManager.SetFormObject('.$this->mszHTMLForm.');'; return $aReturn; } /** * javascript include files */ function GetJavascriptIncludeFunctions() { $aReturn = parent::GetJavascriptIncludeFunctions(); $szVar = "cwc_roi.js"; $aReturn[$szVar] = ''; $szVar = "cwc_dhtml.js"; $aReturn[$szVar] = ''; return $aReturn; } /** * @desc javascript mousemove functions */ function GetJavascriptOnMouseMoveFunctions() { $aReturn = parent::GetJavascriptOnMouseMoveFunctions(); $aReturn['ROIRectTool'] = 'ROIRectToolMouseMove(e);'; return $aReturn; } /** * @desc general javascript functions */ function GetJavascriptFunctions() { $aReturn = parent::GetJavascriptFunctions(); if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) $bCWCJSAPI = 1; else $bCWCJSAPI = 0; // add JSAPI mode functions if ($bCWCJSAPI) { $szJsFunctionName = "ROIRectangleToolWRegisterForEvent"; $szFunction = <<mnId; $szName = 'ROIRectTool'.$nId; $szFunction = << 0) { $szObjectJS .= " goCWCROIManager.UpdateLayerVisibility();\n"; } } $szName = 'ROIRectToolInitObjects'; $szFunction = <<=0 && gROIToolmouseY >=0) { gROIRectToolx1 = gROIToolmouseX; gROIRectTooly1 = gROIToolmouseY; ROIRectToolStartZoomBox(); gROIRectDragging = true; } return false; } EOT; $aReturn[$szName] = $szFunction; $szName = 'ROIRectToolMouseUp'; $szFunction = <<=0 && gROIToolmouseY >=0) { gROIRectToolx2 = gROIToolmouseX; gROIRectTooly2 = gROIToolmouseY; ROIRectToolStopZoomBox(); gROIRectDragging = false; } // return return false; } EOT; $aReturn[$szName] = $szFunction; $szName = 'ROIRectToolGetMousePosition'; $szFunction = << width || gROIToolmouseY < 0 || gROIToolmouseY > height) { gROIToolmouseX = -1; gROIToolmouseY = -1 } return true; } EOT; $aReturn[$szName] = $szFunction; $szName = 'ROIRectToolMouseMove'; $szFunction = <<=0 && gROIToolmouseY >=0 && {$this->mszHTMLForm}.NAV_CMD != null && {$this->mszHTMLForm}.NAV_CMD.value == "ROI_TOOL" && {$this->mnId} == goCWCROIManager.GetROITool()) { document.onmousedown = ROIRectToolMouseDown; document.onmouseup = ROIRectToolMouseUp; if (gROIRectDragging) { gROIRectToolx2 = gROIToolmouseX; gROIRectTooly2 = gROIToolmouseY; ROIRectToolUpdateZoomBox(); } } else { } return false; } EOT; $aReturn[$szName] = $szFunction; return $aReturn; } /** * GetJavascriptVariables * * Return JS global variables and global code. */ function GetJavascriptVariables() { $aReturn = array(); $szVariable = "gROIToolmouseX"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIToolmouseY"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectToolx1"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectTooly1"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectToolx2"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectTooly2"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectDragging"; $szValue = " var $szVariable = false;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "goROIRectObj"; $szValue = " var $szVariable = null;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectBoxTop"; $szValue = " var $szVariable = \"gROIRectBoxTop\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectBoxLeft"; $szValue = " var $szVariable = \"gROIRectBoxLeft\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectBoxBottom"; $szValue = " var $szVariable = \"gROIRectBoxBottom\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectBoxRight"; $szValue = " var $szVariable = \"gROIRectBoxRight\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gROIRectBoxFill"; $szValue = " var $szVariable = \"gROIRectBoxFill\";\n"; $aReturn[$szVariable] = $szValue; return $aReturn; } /** * return an array of javascript functions needed by the Ruler widget * and called when the page is loaded. * @return array of name = function values */ function GetJavascriptOnLoadFunctions() { $aReturn = parent::GetJavascriptOnLoadFunctions(); $aReturn["ROIRectToolInitObjects"] = " ROIRectToolInitObjects();\n"; if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) { $szJsFunctionName = "ROIRectangleToolWRegisterForEvent"; $szFunction = "$szJsFunctionName();\n"; $aReturn[$szJsFunctionName] = $szFunction; } return $aReturn; } /** * draw this widget on the page */ function DrawPublish($szPostEvent = "") { if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) $bCWCJSAPI = 1; else $bCWCJSAPI = 0; if (!$this->mbVisible) return ""; $szReturn = $this->moButton->DrawPublish(); return $szReturn; } } ?>