Module: nagvis Branch: master Commit: 4fa66ad5c87298f76a3b7cf30f7c06f19cf2fe15 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=4fa66ad5c87298f76a3b7cf30f7c06f19cf2fe15
Author: LaMi <[email protected]> Date: Fri Jan 8 10:35:35 2010 +0100 #4 Implemented first steps of the grid in WUI. The grid is shown and the icons are aligned to the upper left corner; Todo: Align objects on initial object creation, Add a quick link to toggle the grid --- docs/en_US/nagvis_config_format_description.html | 9 ++++ share/frontend/wui/classes/WuiMainCfg.php | 16 ++++++++ share/frontend/wui/classes/WuiViewMap.php | 1 + share/frontend/wui/js/wui.js | 45 ++++++++++++++++++++++ share/server/core/classes/GlobalMainCfg.php | 12 ++++++ share/userfiles/templates/default.wuiMap.html | 4 ++ 6 files changed, 87 insertions(+), 0 deletions(-) diff --git a/docs/en_US/nagvis_config_format_description.html b/docs/en_US/nagvis_config_format_description.html index 085ddff..e7ef679 100644 --- a/docs/en_US/nagvis_config_format_description.html +++ b/docs/en_US/nagvis_config_format_description.html @@ -293,6 +293,15 @@ <td>autoupdatefreq</td><td> 25 </td><td> In this interval the map gets backuped by the WUI. </td> </tr> <tr> + <td>grid_show</td><td>0</td><td>Enable/Disable a grid to make the alignment of objects easier in the WUI. Objects are aligned to the upper left corner after moving. <font color="#ff0000">(New in 1.5)</font></td> + </tr> + <tr> + <td>grid_color</td><td>#F7F7F7</td><td>The color of the grid lines. <font color="#ff0000">(New in 1.5)</font></td> + </tr> + <tr> + <td>grid_steps</td><td>32</td><td>Scale of the grid in px. <font color="#ff0000">(New in 1.5)</font></td> + </tr> + <tr> <td>headermenu</td><td>1</td><td>Enable/Disable the header menu in the WUI. <font color="#ff0000">(New in 1.5)</font></td> </tr> <tr> diff --git a/share/frontend/wui/classes/WuiMainCfg.php b/share/frontend/wui/classes/WuiMainCfg.php index d5dd7ed..a6f19b4 100644 --- a/share/frontend/wui/classes/WuiMainCfg.php +++ b/share/frontend/wui/classes/WuiMainCfg.php @@ -232,5 +232,21 @@ class WuiMainCfg extends GlobalMainCfg { return FALSE; } } + + /** + * Parses WUI specific settings + * + * @return String JSON Code + * @author Lars Michelsen <[email protected]> + */ + function parseWuiProperties() { + $arr = Array(); + + $arr['grid_show'] = $this->getValue('wui', 'grid_show'); + $arr['grid_color'] = $this->getValue('wui', 'grid_color'); + $arr['grid_steps'] = $this->getValue('wui', 'grid_steps'); + + return json_encode($arr); + } } ?> diff --git a/share/frontend/wui/classes/WuiViewMap.php b/share/frontend/wui/classes/WuiViewMap.php index 9c0130a..3cd39b0 100644 --- a/share/frontend/wui/classes/WuiViewMap.php +++ b/share/frontend/wui/classes/WuiViewMap.php @@ -60,6 +60,7 @@ class WuiViewMap { 'backgroundImg' => $this->MAP->MAPCFG->BACKGROUND->getFile(), 'base' => $this->CORE->getMainCfg()->getValue('paths', 'htmlbase'), 'generalProperties' => $this->CORE->getMainCfg()->parseGeneralProperties(), + 'wuiProperties' => $this->CORE->getMainCfg()->parseWuiProperties(), 'mapName' => $this->name, 'userName' => $this->CORE->getAuthentication()->getUser(), 'mapObjects' => $this->MAP->parseObjects(), diff --git a/share/frontend/wui/js/wui.js b/share/frontend/wui/js/wui.js index 421dd8b..6f1e2c5 100644 --- a/share/frontend/wui/js/wui.js +++ b/share/frontend/wui/js/wui.js @@ -36,6 +36,43 @@ var myshapex = 0; var myshapey = 0; var objid = 0; var viewType = ''; +var oWuiProperties; + +/** + * Parses a grind to make the alignment of the icons easier + * + * @author Lars Michelsen <[email protected]> + */ +function parseGrid() { + // Only show when user configured to see a grid + if(oWuiProperties.grid_show === 1) { + // Add an options: grid_show, grid_steps, grid_color + var grid = new jsGraphics('mymap'); + grid.setColor(oWuiProperties.grid_color); + grid.setStroke(1); + + var gridStep = oWuiProperties.grid_steps; + + // Start + var gridYStart = 0; + var gridXStart = 0; + + // End: Get screen height, width + var gridYEnd = pageHeight() - getHeaderHeight(); + var gridXEnd = pageWidth(); + + // Draw vertical lines + for(var gridX = 32; gridX < gridXEnd; gridX = gridX + gridStep) { + grid.drawLine(gridX, gridYStart, gridX, gridYEnd); + } + // Draw horizontal lines + for(var gridY = 32; gridY < gridYEnd; gridY = gridY + gridStep) { + grid.drawLine(gridXStart, gridY, gridXEnd, gridY); + } + + grid.paint(); + } +} // FIXME: Maybe move to nagvis-js frontend file to have it available in // regular frontend in the future @@ -309,6 +346,14 @@ function saveObjectAfterMoveAndDrop(oObj) { return; } + // When a grid is enabled align the dragged object in the nearest grid + if(oWuiProperties.grid_show === 1) { + var gridMoveX = oObj.x - (oObj.x % oWuiProperties.grid_steps); + var gridMoveY = oObj.y - (oObj.y % oWuiProperties.grid_steps); + + oObj.moveTo(gridMoveX, gridMoveY); + } + // Reset z-index to configured value oObj.setZ(oObj.defz); diff --git a/share/server/core/classes/GlobalMainCfg.php b/share/server/core/classes/GlobalMainCfg.php index 5e4752b..4b263d2 100644 --- a/share/server/core/classes/GlobalMainCfg.php +++ b/share/server/core/classes/GlobalMainCfg.php @@ -277,6 +277,18 @@ class GlobalMainCfg { 'maplocktime' => Array('must' => 0, 'editable' => 1, 'default' => '350', + 'match' => MATCH_INTEGER), + 'grid_show' => Array('must' => 0, + 'editable' => 1, + 'default' => 0, + 'match' => MATCH_BOOLEAN), + 'grid_color' => Array('must' => 0, + 'editable' => 1, + 'default' => '#F7F7F7', + 'match' => MATCH_COLOR), + 'grid_steps' => Array('must' => 0, + 'editable' => 1, + 'default' => 32, 'match' => MATCH_INTEGER)), 'paths' => Array( 'base' => Array('must' => 1, diff --git a/share/userfiles/templates/default.wuiMap.html b/share/userfiles/templates/default.wuiMap.html index 68c59b9..e4f4f7b 100644 --- a/share/userfiles/templates/default.wuiMap.html +++ b/share/userfiles/templates/default.wuiMap.html @@ -2,6 +2,7 @@ <script type="text/javascript"> oGeneralProperties = {$generalProperties}; +oWuiProperties = {$wuiProperties}; var mapname = '{$mapName}'; var username = '{$userName}'; @@ -26,6 +27,9 @@ var backupAvailable = {$backupAvailable}; </div> <script type="text/javascript"> +// Parses the grid if a user enabled it +parseGrid(); + // build the right-click menu initjsDOMenu(); ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
