NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/Ruler/Ruler.widget.php

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * Ruler Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id: Ruler.widget.php,v 1.11 2005/05/04 20:02:23 pspencer Exp $
7  * @purpose     Ruler Widget class
8  * @author      DM Solutions Group (assefa@dmsolutions.ca)
9  * @copyright
10  * <b>Copyright (c) 2002, DM Solutions Group Inc.</b>
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  */
29
30
31 include_once(dirname(__FILE__)."/../NavTool.php");
32
33
34 /**
35  * Ruler
36  *
37  * @desc A widget to measure distances
38  */
39 class Ruler extends NavTool
40 {
41     var $mnNumberOfPoints = 100;
42     var $mnSpaceBetweenPoints = 15;
43
44     /**
45      * construct a new ruler widget
46      */
47     function Ruler()
48     {
49         // invoke constructor of parent
50         parent::NavTool();
51
52         $this->SetNavCommand("RULER");
53         $this->maAttributes["UNITS"] = new StringAttribute( "UNITS", true,
54             array( "INCHES", "FEET", "MILES", "METERS", "KILOMETERS", "DEGREES", "PIXELS" ) );
55         $this->maAttributes["NUMBEROFPOINTS"] = new IntegerAttribute( "NUMBEROFPOINTS", false, 0 );        $this->maAttributes["SPACEBETWEENPOINTS"] = new IntegerAttribute( "SPACEBETWEENPOINTS", false, 0 );
56
57         // set the description for this widget
58         $this->szWidgetDescription = <<<EOT
59 The Ruler widget is a tool that allows the user to interactively drawn line segments on the map
60 and display the cumulative distance of the segments in ground units.
61 EOT;
62
63         $this->mnMaturityLevel = MATURITY_BETA;
64         $this->mbNavSubmit = false;
65     }
66
67     /**
68      * validate a unit of measurement
69      */
70     function IsUnitValid($szUnit)
71     {
72         $aValidUnits = array(trim($this->moMLT->get("6", "Inches")),
73                              trim($this->moMLT->get("7", "Feet")),
74                              trim($this->moMLT->get("8", "Miles")),
75                              trim($this->moMLT->get("9", "Meters")),
76                              trim($this->moMLT->get("10", "Kilometers")),
77                              trim($this->moMLT->get("11", "Degrees")),
78                              trim($this->moMLT->get("12", "Pixels")));
79
80         $nCount = count($aValidUnits);
81         $bFound = false;
82
83         for ($i=0; $i<$nCount; $i++)
84         {
85             if(strcasecmp($aValidUnits[$i], trim($szUnit)) == 0)
86             {
87                 $bFound = true;
88                 break;
89             }
90         }
91         return $bFound;
92     }
93
94     /**
95      * return an abbreviation for a unit of measurement
96      */
97     function GetUnitAbbbreviation($szUnit)
98     {
99         //assuming the unit is valid
100         //if ($this->IsUnitValid($szInUnit))
101         $szUnit = trim(strtoupper($szUnit));
102
103         $szResult = "";
104         switch ($szUnit)
105         {
106             case "INCHES":
107               $szResult = trim($this->moMLT->get("13", "in."));
108               break;
109
110             case "FEET":
111               $szResult = trim($this->moMLT->get("14", "ft"));
112               break;
113
114             case "MILES":
115               $szResult = trim($this->moMLT->get("15", "mi"));
116               break;
117
118             case "METERS":
119               $szResult = trim($this->moMLT->get("16", "m"));
120               break;
121
122             case "KILOMETERS":
123               $szResult = trim($this->moMLT->get("17", "km"));
124               break;
125
126             case "DEGREES":
127               $szResult = trim($this->moMLT->get("18", "dd"));
128               break;
129
130             case "PIXELS":
131               $szResult = trim($this->moMLT->get("19", "px"));
132               break;
133
134             default:
135               break;
136         }
137
138         return $szResult;
139     }
140
141     /**
142      * convert a measurement from a unit to meters
143      */
144     function ConvertToMeter($szInUnit, $dfValue)
145     {
146         //assuming the unit is valid
147         //if ($this->IsUnitValid($szInUnit))
148         $dfResult = -1.0;
149
150         $aMeterPerUnit = array(); //how many meters are there in the unit
151         $aMeterPerUnit[0] =  0.0254; //inches
152         $aMeterPerUnit[1] =  0.3048; //feet
153         $aMeterPerUnit[2] =  1609.3445; //Miles
154         $aMeterPerUnit[3] =  1.0; //Meters
155         $aMeterPerUnit[4] =  1000.0; //Kilometers
156         $aMeterPerUnit[5] =  110570; //using value a 0 latitude 1degree = 110.57km
157
158
159         $szInUnit = trim(strtoupper($szInUnit));
160         switch ($szInUnit)
161         {
162             case "INCHES":
163               $dfResult = $dfValue * $aMeterPerUnit[0];
164               break;
165
166             case "FEET":
167                $dfResult = $dfValue * $aMeterPerUnit[1];
168               break;
169
170             case "MILES":
171               $dfResult = $dfValue * $aMeterPerUnit[2];
172               break;
173
174             case "METERS":
175               $dfResult = $dfValue * $aMeterPerUnit[3];
176               break;
177
178             case "KILOMETERS":
179               $dfResult = $dfValue * $aMeterPerUnit[4];
180               break;
181
182             case "DEGREES":
183               $dfResult = $dfValue * $aMeterPerUnit[5];
184               break;
185
186             default:
187               break;
188         }
189
190         return $dfResult;
191
192     }
193
194     /**
195      * convert a measurement from meters to a unit
196      */
197     function ConvertFromMeter($szInUnit, $dfValue)
198     {
199         //assuming the unit is valid
200         //if ($this->IsUnitValid($szInUnit))
201         $dfResult = -1.0;
202
203         $aUnitPerMeter = array(); //how many units in one meters
204         $aUnitPerMeter[0] =  39.37; //inches
205         $aUnitPerMeter[1] =  3.2808; //feet
206         $aUnitPerMeter[2] =  0.00062137; //Miles
207         $aUnitPerMeter[3] =  1.0; //Meters
208         $aUnitPerMeter[4] =  0.001; //Kilometers
209         $aUnitPerMeter[5] =  0.000009044; //using value a 0 latitude 1degree = 110.57km
210
211         $szInUnit = trim(strtoupper($szInUnit));
212         switch ($szInUnit)
213         {
214             case "INCHES":
215               $dfResult = $dfValue * $aUnitPerMeter[0];
216               break;
217
218             case "FEET":
219                $dfResult = $dfValue * $aUnitPerMeter[1];
220               break;
221
222             case "MILES":
223               $dfResult = $dfValue * $aUnitPerMeter[2];
224               break;
225
226             case "METERS":
227               $dfResult = $dfValue * $aUnitPerMeter[3];
228               break;
229
230             case "KILOMETERS":
231               $dfResult = $dfValue * $aUnitPerMeter[4];
232               break;
233
234             case "DEGREES":
235               $dfResult = $dfValue * $aUnitPerMeter[5];
236               break;
237
238             default:
239               break;
240         }
241
242         return $dfResult;
243
244     }
245
246     /**
247      * arbitrarily convert a measurement from one unit to another
248      */
249     function ConvertUnit($szInUnit, $szOutUnit, $dfValue)
250     {
251         $bInFound = $this->IsUnitValid($szInUnit);
252         $bOutFound = $this->IsUnitValid($szOutUnit);
253
254
255         if (!$bInFound || !$bOutFound)
256         {
257             //echo "units invalid <br>";
258             return -1.0;
259         }
260
261         $dfValue = $this->ConvertToMeter($szInUnit, $dfValue);
262         //echo "after convert to meter = $dfValue <br>";
263         $dfValue = $this->ConvertFromMeter($szOutUnit, $dfValue);
264         //echo "after convert from meter = $dfValue <br>";
265
266         return $dfValue;
267     }
268
269     /**
270      * the javascript functions to be called as the page loads
271      */
272     function GetJavascriptInitFunctions()
273     {
274         $aReturn = array();
275
276         $aReturn = parent::GetJavascriptInitFunctions();
277
278         $szJsFunctionName = "RulerInit";
279         $szFunction = "$szJsFunctionName();\n";
280         $aReturn[$szJsFunctionName] = $szFunction;
281
282
283         return $aReturn;
284     }
285
286     /**
287      * javascript include files
288      */
289     function GetJavascriptIncludeFunctions()
290     {
291         $aReturn = array();
292         
293         $aReturn = parent::GetJavascriptIncludeFunctions();
294
295         $szJsIncludeName = "cwc_dhtml.js";
296         $szInclude = "<script language=\"JavaScript\" src=\"".$_SESSION["gszCoreWebPath"]."/widgets/js/cwc_dhtml.js\" type=\"text/javascript\"></script>";
297         $aReturn[$szJsIncludeName] = $szInclude;
298
299         $szJsIncludeName = "dhtmlapi.js";
300         $szInclude = "<script language=\"JavaScript\" src=\"".$_SESSION["gszCoreWebPath"]."/widgets/js/dhtmlapi.js\" type=\"text/javascript\"></script>";
301         $aReturn[$szJsIncludeName] = $szInclude;
302
303         $szJsIncludeName = "toolsobj.js";
304         $szInclude = "<script language=\"JavaScript\" src=\"".$_SESSION["gszCoreWebPath"]."/widgets/js/toolsobj.js\" type=\"text/javascript\"></script>";
305         $aReturn[$szJsIncludeName] = $szInclude;
306
307         $szJsIncludeName = "eventslib.js";
308         $szInclude = "<script language=\"JavaScript\" src=\"".$_SESSION["gszCoreWebPath"]."/widgets/js/eventslib.js\" type=\"text/javascript\"></script>";
309         $aReturn[$szJsIncludeName] = $szInclude;
310         return $aReturn;
311     }
312
313     /**
314      * @desc javascript mousemove functions
315      */
316     function GetJavascriptOnMouseMoveFunctions()
317     {
318         $aReturn = array();
319
320         $aReturn = parent::GetJavascriptOnMouseMoveFunctions();
321
322         $szJsFunctionName = "RulerWMouseMove";
323         $szFunction = "$szJsFunctionName(e);\n";
324         $aReturn[$szJsFunctionName] = $szFunction;
325
326         return $aReturn;
327     }
328
329     /**
330      * @desc general javascript functions
331      */
332     function GetJavascriptFunctions()
333     {
334         $oApp = GetChameleonApplication();
335         $aReturn = array();
336
337         if (isset($this->maSharedResourceWidgets["CWCJSAPI"]))
338           $bCWCJSAPI = 1;
339         else
340           $bCWCJSAPI = 0;
341
342         $aReturn = parent::GetJavascriptFunctions();
343         
344         $szRulerPix = $oApp->findFile( "images/ruler_pix.gif" );
345         $szRulerPix = $oApp->fileSystemToURL( $szRulerPix );
346         $szRulerNode = $oApp->findFile( "images/ruler_node.gif" );
347         $szRulerNode = $oApp->fileSystemToURL( $szRulerNode );
348         
349         $szJsFunctionName = "RulerInit";
350         $szFunction = <<<EOT
351 /**
352  * {$szJsFunctionName}
353  * called to initialize the ruler widget.
354  */
355 function {$szJsFunctionName}()
356 {
357     // draw all distance points
358     //drawDistPt();
359     var sId = "";
360     var content = "<IMG  SRC='{$szRulerPix}'><BR>";
361     var content2 = "<IMG  SRC='{$szRulerNode}'><BR>";
362     for (var i=1; i<= gRulerNbPoints; i++)
363     {
364         sId = "pix"+i;
365         CWCDHTML_CreateLayer(sId, -10, -10, 10, 10, false, content);
366         CWCDHTML_SetLayerZOrder( sId, 20 );
367         
368         sId = "pInf"+i;
369         CWCDHTML_CreateLayer(sId, -10, -10, 10, 10, false, content2);
370         CWCDHTML_SetLayerZOrder( sId, 20 );
371         
372     }
373     // instantiate the distancetool object
374     //MapLayerDiv is created in MapDHTMLWidget.php.
375     //gMapWhspc and gMapWvspc are created in MapDHTMLWidget and are
376     //the TL position of the map.
377     DistTool = new distancetool(getObject("MapLayerDiv"), gRulerNbPoints,
378                                 gMapWhspc, gMapWvspc);
379
380     // initialize mouse event for the layer named 'MapLayerDiv'
381     //setMapDraggable("MapLayerDiv");
382 }
383 EOT;
384
385     $aReturn[$szJsFunctionName] = $szFunction;
386
387     $szJsFunctionName = "RulerWMouseMove";
388     $szFunction = <<<EOT
389 /**
390  * {$szJsFunctionName}
391  * called when the mouse moves for the Ruler widget.
392  */
393 function {$szJsFunctionName}(e)
394 {
395
396     //make sure that the forms varaibales are initialized.
397     //It seems like that in IE, the mouse move may be called before.
398     if ({$this->mszHTMLForm} == null ||
399       {$this->mszHTMLForm}.NAV_CMD == null)
400       return true;
401
402     if({$this->mszHTMLForm}.NAV_CMD.value != "RULER")
403     {
404         //if ruler result is present rest the text field.
405         if ({$this->mszHTMLForm}.RULER_RESULT != null)
406         {
407             {$this->mszHTMLForm}.RULER_RESULT.value = "";
408         }
409
410         //reset the first click.
411         gRulerfirstClickDist = true;
412
413         if (gRulerHideLayers)
414         {
415             for(var i=1; i<=gRulerNbPoints; i++)
416             {
417                 hide("pix" + i);
418             }
419             for(var i=1; i<=gRulerNbPoints; i++)
420             {
421                 hide("pInf" + i);
422             }
423             //lets only do this once :)
424             gRulerHideLayers = false;
425         }
426         
427         //remove handlers if they were ours
428         if (document.onDblClick==stopDist)
429             document.onDblClick = null;
430         if (document.onKeyPress==stopDist)
431             document.onKeyPress= null;
432
433         return true;
434     }
435     
436     //ruler tool is active
437     var obj = "MapLayerDiv";
438     if (isNav4 || isNav6)
439     {
440         document.captureEvents(Event.MOUSEDOWN);
441         document.captureEvents(Event.MOUSEMOVE);
442         document.captureEvents(Event.DBLCLICK);
443         document.captureEvents(Event.RESIZE);
444     }
445     if(isNav4)
446     {
447         getObject(obj).onmouseout= mouseOutMap;
448         document.onmousedown=startDist;
449         document.onDblClick=stopDist ;
450         document.onKeyPress=stopDist;
451     }
452     else if (isIE4 || isNav6)
453     {
454         var layer  = document.getElementById("MapLayerDiv");
455         document.onmousedown=startDist;
456         document.ondblclick=stopDist;
457         document.onkeypress=stopDist;
458         //layer.onmouseout=outIE;
459         if (isNav6)
460         {
461           document.addEventListener("dblclick",stopDist,true);
462           document.addEventListener("keypress",stopDist,true);
463         }
464
465     }
466     distIt(e);
467 }
468 EOT;
469     $aReturn[$szJsFunctionName] = $szFunction;
470
471     if ($bCWCJSAPI)
472     {
473
474         $szJsFunctionName = "RulerWRegisterForEvent";
475         $szFunction = <<<EOT
476 /**
477  * {$szJsFunctionName}
478  * called to register and even when the map extents chnages (JSAPI)
479  */
480 function {$szJsFunctionName}()
481 {
482     goCWCJSAPI.RegisterEvent(MAP_EXTENT_CHANGED, "RulerWMapExtentsChanged");
483 }
484 EOT;
485     
486        $aReturn[$szJsFunctionName] = $szFunction;
487
488        $szJsFunctionName = "RulerWMapExtentsChanged";
489        $szFunction = <<<EOT
490 /**
491  * {$szJsFunctionName}
492  * called when the mapextents are changed to update the ruler global variables(JSAPI)
493  */
494 function {$szJsFunctionName}()
495 {
496     gRulercMapWidth = goCWCJSAPI.oMap.width;
497     gRulercMapHeight = goCWCJSAPI.oMap.height;
498     gRulermapMinX = goCWCJSAPI.oMap.minx;
499     gRulermapMaxY = goCWCJSAPI.oMap.maxx;
500
501     dfPixelSize = (goCWCJSAPI.oMap.maxx - goCWCJSAPI.oMap.minx)/goCWCJSAPI.oMap.width;
502
503     szMapUnit = goCWCJSAPI.oMap.GetUnitString(goCWCJSAPI.oMap.units);
504
505     gRulergblPixelSize = goCWCJSAPI.oMap.ConvertUnit(szMapUnit, gRulerUserUnit, dfPixelSize);
506
507 }
508 EOT;
509     
510     $aReturn[$szJsFunctionName] = $szFunction;
511     }//if jsapi
512  
513     return $aReturn;
514     }
515
516
517     /**
518      * javascript variables
519      */
520     function GetJavascriptVariables()
521     {
522         if (isset($this->moMapObject))
523         {
524             $poMap = $this->moMapObject->oMap;
525
526             $dfPixelSize = ($poMap->extent->maxx - $poMap->extent->minx)/
527                           $poMap->width;
528             $nUnits = $this->moMapObject->oMap->units;
529         }
530         else
531         {
532             if (!defined( "MS_INCHES" ))
533             {
534                 define( "MS_INCHES", 0 );
535                 define( "MS_FEET", 1 );
536                 define( "MS_MILES", 2 );
537                 define( "MS_METERS", 3 );
538                 define( "MS_KILOMETERS", 4 );
539                 define( "MS_DEGREES", 5 );
540                 define( "MS_PIXELS", 6 );
541                 define( "MS_DD", 7 );
542             }
543             $nUnits = 3;
544             $dfPixelSize = 1;
545         }
546         //echo "orig pix value = $dfPixelSize <br>";
547         $szUserUnit = "";
548         if (isset($this->maParams["UNITS"]))
549             $szUserUnit = strtoupper($this->maParams["UNITS"]);
550
551         $szMapUnits = "";
552         switch ($nUnits)
553         {
554             case MS_INCHES:
555               $szMapUnits = trim($this->moMLT->get("6", "Inches"));
556               break;
557
558             case MS_FEET:
559                $szMapUnits = trim($this->moMLT->get("7", "Feet"));
560               break;
561
562             case MS_MILES:
563               $szMapUnits = trim($this->moMLT->get("8", "Miles"));
564               break;
565
566             case MS_METERS:
567               $szMapUnits = trim($this->moMLT->get("9", "Meters"));
568               break;
569
570             case MS_KILOMETERS:
571               $szMapUnits = trim($this->moMLT->get("10", "Kilometers"));
572               break;
573
574             case MS_DD:
575               $szMapUnits = trim($this->moMLT->get("11", "Degrees"));
576               break;
577
578             case MS_PIXELS:
579               $szMapUnits = trim($this->moMLT->get("12", "Pixels"));
580               break;
581         }
582
583 /* -------------------------------------------------------------------- */
584 /*      if the user given units are diffrent fromn the map units,       */
585 /*      convert the pixel size.                                         */
586 /* -------------------------------------------------------------------- */
587         if ($szMapUnits != "" && $szUserUnit != "" &&
588             $szUserUnit != $szMapUnits)
589         {
590             //echo "convert from $szMapUnits to $szUserUnit <br>";
591             $dfPixelSize =
592               $this->ConvertUnit($szMapUnits, $szUserUnit$dfPixelSize);
593
594             //echo "converted pix value = $dfPixelSize <br>";
595
596             if ($dfPixelSize > 0)
597               $szUnits = $szUserUnit;
598             else
599             {
600                 $_SESSION['gErrorManager']->setError(ERR_WARNING,
601                   trim($this->moMLT->get("22", "ERROR: Unit value could not be used in Ruler.widget.php.")));
602                 $szUnits = trim($this->moMLT->get("12", "Pixels"));
603                 $dfPixelSize = 1.0;
604             }
605         }
606         else
607         {
608             $szUnits = $szMapUnits;
609         }
610
611         $szUserUnit = $szUnits;
612         $szUnits = $this->GetUnitAbbbreviation($szUnits);
613
614         $aReturn = array();
615         $aReturn = parent::GetJavascriptVariables();
616
617         $szVariable = "gRulergblPixelSize";
618         $szValue = " var $szVariable = $dfPixelSize;\n";
619         $aReturn[$szVariable] = $szValue;
620
621         $szVariable = "gRulermapMinX";
622         if (is_object($this->moMapObject))
623         {
624             $nMinX = $poMap->extent->minx;
625         }
626         else
627             $nMinX = 0;
628         $szValue = " var $szVariable = ".$nMinX.";\n";
629         $aReturn[$szVariable] = $szValue;
630
631         $szVariable = "gRulermapMaxY";
632         if (is_object($this->moMapObject))
633         {
634             $nMaxX = $poMap->extent->maxx;
635         }
636         else
637             $nMaxX = 0;
638         $szValue = " var $szVariable = ".$nMaxX.";\n";
639         $aReturn[$szVariable] = $szValue;
640
641         $szVariable = "gRulerMapImgOX";
642         $szValue = " var $szVariable = gMapWhspc;\n";
643         $aReturn[$szVariable] = $szValue;
644
645         $szVariable = "gRulerMapImgOY";
646         $szValue = " var $szVariable = gMapWvspc;\n";
647         $aReturn[$szVariable] = $szValue;
648
649         $szVariable = "gRulerCurrentTool";
650         $szValue = " var $szVariable = \"distance\";\n";
651         $aReturn[$szVariable] = $szValue;
652
653         $szVariable = "gRulerfirstClickDist";
654         $szValue = " var $szVariable = \"true\";\n";
655         $aReturn[$szVariable] = $szValue;
656
657         $szVariable = "gRulercMapWidth";
658         if (is_object($this->moMapObject))
659         {
660             $nWidth = $poMap->width;
661         }
662         else
663             $nWidth = 1;
664         $szValue = " var $szVariable = ".$nWidth.";\n";
665         $aReturn[$szVariable] = $szValue;
666
667         $szVariable = "gRulercMapHeight";
668         if (is_object($this->moMapObject))
669         {
670             $nHeight = $poMap->height;
671         }
672         else
673             $nHeight = 1;
674         $szValue = " var $szVariable = ".$nHeight.";\n";
675         $aReturn[$szVariable] = $szValue;
676
677         $szVariable = "gRulerg_digitTool";
678         $szValue = " var $szVariable = \"true\";\n";
679         $aReturn[$szVariable] = $szValue;
680
681         $szVariable = "gRulerg_end_digit";
682         $szValue = " var $szVariable = \"false\";\n";
683         $aReturn[$szVariable] = $szValue;
684
685         $szVariable = "gRulerareaMode";
686         $szValue = " var $szVariable = \"false\";\n";
687         $aReturn[$szVariable] = $szValue;
688
689         $szVariable = "gRulerareaString";
690         $szValue = " var $szVariable = \"\";\n";
691         $aReturn[$szVariable] = $szValue;
692
693         $szVariable = "gRulersUnits";
694         $szValue = " var $szVariable = \"$szUnits\";\n";
695         $aReturn[$szVariable] = $szValue;
696
697         $szVariable = "gRulerHideLayers";
698         $szValue = " var $szVariable = 0;\n";
699         $aReturn[$szVariable] = $szValue;
700
701         $szVariable = "gRulerFirstUse";
702         $szValue = " var $szVariable = true;\n";
703         $aReturn[$szVariable] = $szValue;
704
705         $nPoints = $this->mnNumberOfPoints;
706         if (isset($this->maParams["NUMBEROFPOINTS"]))
707           $nPoints = intval($this->maParams["NUMBEROFPOINTS"]);
708
709         $szVariable = "gRulerNbPoints";
710         $szValue = " var $szVariable = $nPoints;\n";
711         $aReturn[$szVariable] = $szValue;
712
713         $szVariable = "gRulerUserUnit";
714         $szValue = " var $szVariable = \"$szUserUnit\";\n";
715         $aReturn[$szVariable] = $szValue;
716         
717         $nSpaceBetween = $this->mnSpaceBetweenPoints;
718         if (isset($this->maParams["SPACEBETWEENPOINTS"]))
719           $nSpaceBetween = intval($this->maParams["SPACEBETWEENPOINTS"]);
720         if ($nSpaceBetween <=0)
721           $nSpaceBetween = $this->mnSpaceBetweenPoints;
722
723         $szVariable = "gRulerSpaceBetweenPoints";
724         $szValue = " var $szVariable = $nSpaceBetween;\n";
725         $aReturn[$szVariable] = $szValue;
726
727         return $aReturn;
728     }
729     
730     /**
731      * return an array of javascript functions needed by the Ruler widget
732      * and called when the page is loaded.
733      * @return array of name = function values
734      */
735     function GetJavascriptOnLoadFunctions()
736     {
737         $aReturn = array();
738         
739         $aReturn = parent::GetJavascriptOnLoadFunctions();
740
741         if (isset($this->maSharedResourceWidgets["CWCJSAPI"]))
742         {
743              $szJsFunctionName = "RulerWRegisterForEvent";
744              $szFunction = "$szJsFunctionName();\n";
745              $aReturn[$szJsFunctionName] = $szFunction;
746         }
747
748         return $aReturn;
749     }
750     
751 }
752 ?>
753
Note: See TracBrowser for help on using the browser.