Module: nagvis
Branch: master
Commit: 467d4675a5e65698d559a4b2ebe0dff7be5fa018
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=467d4675a5e65698d559a4b2ebe0dff7be5fa018

Author: Lars Michelsen <[email protected]>
Date:   Sat Oct 17 14:29:55 2009 +0200

#140 dynamic icon position depending on icon scale on automap is now active

---

 share/server/core/classes/NagVisAutoMap.php      |    3 +--
 share/server/core/classes/objects/NagVisHost.php |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/share/server/core/classes/NagVisAutoMap.php 
b/share/server/core/classes/NagVisAutoMap.php
index 2074d4f..e748ece 100644
--- a/share/server/core/classes/NagVisAutoMap.php
+++ b/share/server/core/classes/NagVisAutoMap.php
@@ -259,10 +259,9 @@ class NagVisAutoMap extends GlobalMap {
                // default margin is 0.11,0.055
                $str .= 'margin="0.0,0.0", ';
                $str .= 'ratio="auto", ';
-               //$str .= 'shape="none", ';
                $str .= 'shape="rect", ';
                $str .= 'color="white", ';
-               // FIXME: This should be scaled by the choosen iconset
+               // This may be altered by the single objects depending on the 
icon size
                $str .= 'width="'.$this->pxToInch(16).'", ';
                $str .= 'height="'.$this->pxToInch(16).'", ';
                $str .= 'fontcolor=black, fontsize=10';
diff --git a/share/server/core/classes/objects/NagVisHost.php 
b/share/server/core/classes/objects/NagVisHost.php
index 532ec38..98f583e 100644
--- a/share/server/core/classes/objects/NagVisHost.php
+++ b/share/server/core/classes/objects/NagVisHost.php
@@ -70,6 +70,9 @@ class NagVisHost extends NagiosHost {
                $strReturn = '';
                
                if(!in_array($this->getName(), $arrHostnamesParsed)) {
+                       // Get the image size
+                       list($width, $height, $type, $attr) = 
getimagesize($this->CORE->MAINCFG->getValue('paths', 'icon').$this->icon);
+                       
                        $strReturn .= 
$this->getType().'_'.$this->getObjectId().' [ ';
                        $strReturn .= 'label="", ';
                        $strReturn .= 'URL="'.str_replace(array('[htmlcgi]', 
'[host_name]'),
@@ -81,6 +84,15 @@ class NagVisHost extends NagiosHost {
                        /*if($layer == 0) {
                                $strReturn .= 'shape="egg",';
                        }*/
+                       
+                       // This should be scaled by the choosen iconset
+                       if($width != 16) {
+                               $strReturn .= 
'width="'.$this->pxToInch($width).'", ';
+                       }
+                       if($height != 16) {
+                               $strReturn .= 
'height="'.$this->pxToInch($height).'", ';
+                       }
+                       
                        $strReturn .= 'layer="'.$layer.'"';
                        $strReturn .= ' ];'."\n ";
                        
@@ -98,6 +110,15 @@ class NagVisHost extends NagiosHost {
                return $strReturn;
        }
        
+       /**
+        * This methods converts pixels to inches
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       private function pxToInch($px) {
+               return number_format($px/72, 4, '.','');
+       }
+       
        # End public methods
        # 
#########################################################################
 }


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to