- Implemented map saving to DB
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 18 Apr 2006 15:54:32 +0000 (15:54 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 18 Apr 2006 15:54:32 +0000 (15:54 +0000)
- Context menus working on map
- Toolbar added to map window
- Various minor changes

21 files changed:
include/netxms_maps.h
src/console/nxav/AlarmBrowser.cpp
src/console/nxav/MainFrm.cpp
src/console/nxav/comm.cpp
src/console/nxav/nxav.cpp
src/console/nxav/nxav.h
src/console/nxav/tools.cpp
src/console/win32/MapFrame.cpp
src/console/win32/MapFrame.h
src/console/win32/MapView.cpp
src/console/win32/MapView.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/libnxmap/map.cpp
src/libnxmap/submap.cpp
src/server/core/map.cpp
src/server/core/session.cpp
src/server/tools/nxconfig/ProcessingPage.cpp
src/server/tools/nxconfig/nxconfig.cpp
src/server/tools/nxconfig/nxconfig.h

index 8ff2658..2b0aa26 100644 (file)
 #define MAP_ACCESS_DELETE     0x0008
 
 
+//
+// Object link types
+//
+
+#define LINK_TYPE_NORMAL      0
+#define LINK_TYPE_VPN         1
+
+
 //
 // Object-on-map structure
 //
@@ -198,7 +206,7 @@ public:
    DWORD GetSubmapCount(void) { return m_dwNumSubmaps; }
    nxSubmap *GetSubmap(DWORD dwObjectId);
    nxSubmap *GetSubmapByIndex(DWORD dwIndex) { return dwIndex < m_dwNumSubmaps ? m_ppSubmaps[dwIndex] : NULL; }
-   BOOL IsSubmapExist(DWORD dwObjectId);
+   BOOL IsSubmapExist(DWORD dwObjectId, BOOL bLock = TRUE);
 
    void CreateMessage(CSCPMessage *pMsg);
    void ModifyFromMessage(CSCPMessage *pMsg);
index 48390bf..74cff68 100644 (file)
@@ -50,7 +50,7 @@ CAlarmBrowser::CAlarmBrowser()
        //}}AFX_DATA_INIT
 
    if (m_hHook == NULL)
-      m_hHook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, theApp.m_hInstance, GetCurrentThreadId());
+      m_hHook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, appAlarmViewer.m_hInstance, GetCurrentThreadId());
 }
 
 CAlarmBrowser::~CAlarmBrowser()
index e8d8f82..c830a53 100644 (file)
@@ -156,7 +156,7 @@ void CMainFrame::OnViewRefresh()
    }
    else
    {
-      theApp.ErrorBox(dwRetCode, _T("Error loading alarm list: %s"));
+      appAlarmViewer.ErrorBox(dwRetCode, _T("Error loading alarm list: %s"));
    }
 
    GenerateHtml(strHTML);
@@ -251,7 +251,7 @@ void CMainFrame::OnAlarmUpdate(WPARAM wParam, LPARAM lParam)
             m_pAlarmList[m_dwNumAlarms].pUserData = (void *)time(NULL);
             m_dwNumAlarms++;
             SortAlarms();
-            PlayAlarmSound(pAlarm, TRUE, g_hSession, &theApp.m_soundCfg);
+            PlayAlarmSound(pAlarm, TRUE, g_hSession, &appAlarmViewer.m_soundCfg);
          }
          break;
       case NX_NOTIFY_ALARM_DELETED:
@@ -259,7 +259,7 @@ void CMainFrame::OnAlarmUpdate(WPARAM wParam, LPARAM lParam)
          for(i = 0; i < m_dwNumAlarms; i++)
             if (m_pAlarmList[i].dwAlarmId == pAlarm->dwAlarmId)
             {
-               PlayAlarmSound(&m_pAlarmList[i], FALSE, g_hSession, &theApp.m_soundCfg);
+               PlayAlarmSound(&m_pAlarmList[i], FALSE, g_hSession, &appAlarmViewer.m_soundCfg);
                m_iNumAlarms[m_pAlarmList[i].wSeverity]--;
                m_dwNumAlarms--;
                if (m_dwNumAlarms > 0)
@@ -343,7 +343,7 @@ void CMainFrame::OnTimer(UINT nIDEvent)
          if ((m_pAlarmList[i].pUserData != 0) &&
              (now - (time_t)m_pAlarmList[i].pUserData > 60))
          {
-            PlayAlarmSound(&m_pAlarmList[i], TRUE, g_hSession, &theApp.m_soundCfg);
+            PlayAlarmSound(&m_pAlarmList[i], TRUE, g_hSession, &appAlarmViewer.m_soundCfg);
             m_pAlarmList[i].pUserData = (void *)now;
          }
    }
index f20c1e2..5ca2cce 100644 (file)
@@ -68,7 +68,7 @@ inline void SetInfoText(HWND hWnd, char *pszText)
 
 static void __EventHandler(NXC_SESSION hSession, DWORD dwEvent, DWORD dwCode, void *pArg)
 {
-   theApp.EventHandler(dwEvent, dwCode, pArg);
+   appAlarmViewer.EventHandler(dwEvent, dwCode, pArg);
 }
 
 
index 6581e85..32a8544 100644 (file)
@@ -36,7 +36,7 @@ CAlarmViewApp::CAlarmViewApp()
 /////////////////////////////////////////////////////////////////////////////
 // The one and only CAlarmViewApp object
 
-CAlarmViewApp theApp;
+CAlarmViewApp appAlarmViewer;
 
 /////////////////////////////////////////////////////////////////////////////
 // CAlarmViewApp initialization
index 2ccf178..025d22f 100644 (file)
@@ -59,7 +59,7 @@ protected:
 };
 
 
-extern CAlarmViewApp theApp;
+extern CAlarmViewApp appAlarmViewer;
 
 
 /////////////////////////////////////////////////////////////////////////////
index 99b9e7a..bb655b7 100644 (file)
@@ -47,11 +47,11 @@ BOOL FileFromResource(UINT nResId, TCHAR *pszFileName)
    HANDLE hFile;
    BOOL bResult = FALSE;
 
-   hResource = FindResource(theApp.m_hInstance, MAKEINTRESOURCE(nResId), _T("File"));
+   hResource = FindResource(appAlarmViewer.m_hInstance, MAKEINTRESOURCE(nResId), _T("File"));
    if (hResource != NULL)
    {
-      dwSize = SizeofResource(theApp.m_hInstance, hResource);
-      hMem = LoadResource(theApp.m_hInstance, hResource);
+      dwSize = SizeofResource(appAlarmViewer.m_hInstance, hResource);
+      hMem = LoadResource(appAlarmViewer.m_hInstance, hResource);
       if (hMem != NULL)
       {
          pData = (BYTE *)LockResource(hMem);
index 3f600a7..7a86462 100644 (file)
@@ -11,6 +11,9 @@
 static char THIS_FILE[] = __FILE__;
 #endif
 
+#define MAP_SECTION     _T("MapFrame")
+
+
 /////////////////////////////////////////////////////////////////////////////
 // CMapFrame
 
@@ -18,10 +21,16 @@ IMPLEMENT_DYNCREATE(CMapFrame, CMDIChildWnd)
 
 CMapFrame::CMapFrame()
 {
+   m_bShowToolBar = theApp.GetProfileInt(MAP_SECTION, _T("ShowToolBar"), TRUE);
+   m_bShowToolBox = theApp.GetProfileInt(MAP_SECTION, _T("ShowToolBox"), FALSE);
+   m_bShowStatusBar = theApp.GetProfileInt(MAP_SECTION, _T("ShowStatusBar"), TRUE);
 }
 
 CMapFrame::~CMapFrame()
 {
+   theApp.WriteProfileInt(MAP_SECTION, _T("ShowToolBar"), m_bShowToolBar);
+   theApp.WriteProfileInt(MAP_SECTION, _T("ShowToolBox"), m_bShowToolBox);
+   theApp.WriteProfileInt(MAP_SECTION, _T("ShowStatusBar"), m_bShowStatusBar);
 }
 
 
@@ -43,6 +52,19 @@ BEGIN_MESSAGE_MAP(CMapFrame, CMDIChildWnd)
        ON_UPDATE_COMMAND_UI(ID_MAP_FORWARD, OnUpdateMapForward)
        ON_COMMAND(ID_MAP_HOME, OnMapHome)
        ON_COMMAND(ID_MAP_SAVE, OnMapSave)
+       ON_COMMAND(ID_MAP_REDOLAYOUT, OnMapRedolayout)
+       ON_WM_PAINT()
+       ON_COMMAND(ID_MAP_SHOW_STATUSBAR, OnMapShowStatusbar)
+       ON_UPDATE_COMMAND_UI(ID_MAP_SHOW_STATUSBAR, OnUpdateMapShowStatusbar)
+       ON_COMMAND(ID_MAP_SHOW_TOOLBAR, OnMapShowToolbar)
+       ON_UPDATE_COMMAND_UI(ID_MAP_SHOW_TOOLBAR, OnUpdateMapShowToolbar)
+       ON_COMMAND(ID_MAP_SHOW_TOOLBOX, OnMapShowToolbox)
+       ON_UPDATE_COMMAND_UI(ID_MAP_SHOW_TOOLBOX, OnUpdateMapShowToolbox)
+       ON_WM_CONTEXTMENU()
+       ON_COMMAND(ID_OBJECT_PROPERTIES, OnObjectProperties)
+       ON_UPDATE_COMMAND_UI(ID_OBJECT_PROPERTIES, OnUpdateObjectProperties)
+       ON_COMMAND(ID_OBJECT_LASTDCIVALUES, OnObjectLastdcivalues)
+       ON_UPDATE_COMMAND_UI(ID_OBJECT_LASTDCIVALUES, OnUpdateObjectLastdcivalues)
        //}}AFX_MSG_MAP
    ON_MESSAGE(NXCM_OBJECT_CHANGE, OnObjectChange)
 END_MESSAGE_MAP()
@@ -68,8 +90,19 @@ int CMapFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    RECT rect;
    static TBBUTTON tbButtons[] =
    {
-      { 0, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
-      { 1, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }
+      { 5, ID_MAP_BACK, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 6, ID_MAP_FORWARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 5, ID_MAP_HOME, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0 },
+      { 0, ID_MAP_ZOOMIN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 1, ID_MAP_ZOOMOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0 },
+      { 2, ID_MAP_SAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 4, ID_FILE_PRINT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0 },
+      { 3, ID_VIEW_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 3, ID_MAP_REDOLAYOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },
+      { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0 }
    };
 
        if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
@@ -77,19 +110,24 @@ int CMapFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        
    GetClientRect(&rect);
 
-   m_wndToolBox.Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, rect, this, 0);
+   m_wndToolBox.Create(NULL, _T(""),
+                       m_bShowToolBox ? (WS_CHILD | WS_VISIBLE) : WS_CHILD,
+                       rect, this, 0);
 
-   //EnableDocking(CBRS_ALIGN_ANY);
+   // Create image list for toolbar
+   m_imageList.Create(16, 16, ILC_COLOR24 | ILC_MASK, 8, 1);
+   m_imageList.Add(theApp.LoadIcon(IDI_ZOOMIN));
+   m_imageList.Add(theApp.LoadIcon(IDI_ZOOMOUT));
+   m_imageList.Add(theApp.LoadIcon(IDI_SAVE));
+   m_imageList.Add(theApp.LoadIcon(IDI_REFRESH));
+   m_imageList.Add(theApp.LoadIcon(IDI_PRINT));
+   m_imageList.Add(theApp.LoadIcon(IDI_BACK));
+   m_imageList.Add(theApp.LoadIcon(IDI_FORWARD));
 
    // Create toolbar
-   //m_wndToolBar.CreateEx(this);
-   //m_wndToolBar.LoadToolBar(IDT_MAP);
-   //FloatControlBar(&m_wndToolBar, TRUE, FALSE);
-/*   m_wndToolBar.Create(WS_CHILD | WS_VISIBLE | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT, rect, this, ID_TOOLBAR_CTRL);
-   m_wndToolBar.SetExtendedStyle(WS_EX_WINDOWEDGE);
-   m_wndToolBar.SetButtonSize(CSize(20, 20));
-   m_wndToolBar.LoadImages(IDB_HIST_SMALL_COLOR, HINST_COMMCTRL);
-   m_wndToolBar.AddButtons(2, tbButtons);*/
+   m_wndToolBar.Create(WS_CHILD | (m_bShowToolBar ? WS_VISIBLE : 0) | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT, rect, this, ID_TOOLBAR_CTRL);
+   m_wndToolBar.SetImageList(&m_imageList);
+   m_wndToolBar.AddButtons(sizeof(tbButtons) / sizeof(TBBUTTON), tbButtons);
 
    // Create and initialize map view
    m_wndMapView.Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this, 0);
@@ -100,22 +138,36 @@ int CMapFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 }
 
 
+//
+// Redo map frame layout after resize or configuration change
+//
+
+void CMapFrame::RedoLayout()
+{
+   int nToolBarHeight, nToolBoxWidth;
+   RECT rect;
+
+   GetClientRect(&rect);
+
+   m_wndToolBar.AutoSize();
+   nToolBarHeight = m_bShowToolBar ? (GetWindowSize(&m_wndToolBar).cy + 1) : 0;
+   nToolBoxWidth = m_bShowToolBox ? 150 : 0;
+
+   m_wndToolBox.SetWindowPos(NULL, 0, nToolBarHeight, nToolBoxWidth, rect.bottom, SWP_NOZORDER);
+   m_wndMapView.SetWindowPos(NULL, nToolBoxWidth, nToolBarHeight,
+                             rect.right - nToolBoxWidth, rect.bottom - nToolBarHeight,
+                             SWP_NOZORDER);    
+}
+
+
 //
 // WM_SIZE message handler
 //
 
 void CMapFrame::OnSize(UINT nType, int cx, int cy) 
 {
-   int nToolBarHeight = 0;
-   int nToolBoxWidth;
-
        CMDIChildWnd::OnSize(nType, cx, cy);
-//   m_wndToolBar.AutoSize();
-   //nToolBarHeight = GetWindowSize(&m_wndToolBar).cy;
-   nToolBoxWidth = 150;
-   m_wndToolBox.SetWindowPos(NULL, 0, 0, nToolBoxWidth, cy, SWP_NOZORDER);
-   m_wndMapView.SetWindowPos(NULL, nToolBoxWidth, nToolBarHeight,
-                             cx - nToolBoxWidth, cy - nToolBarHeight, SWP_NOZORDER);   
+   RedoLayout();
 }
 
 
@@ -321,3 +373,166 @@ void CMapFrame::OnMapSave()
       theApp.ErrorBox(dwResult, _T("Cannot save map on server: %s"));
    }
 }
+
+
+//
+// WM_COMMAND::ID_MAP_REDOLAYOUT message handlers
+//
+
+void CMapFrame::OnMapRedolayout() 
+{
+   m_wndMapView.DoSubmapLayout();
+   m_wndMapView.Update();
+}
+
+
+//
+// WM_PAINT message handler
+//
+
+void CMapFrame::OnPaint() 
+{
+       CPaintDC dc(this); // device context for painting
+   RECT rect;
+
+   if (m_bShowToolBar)
+   {
+      GetClientRect(&rect);
+      rect.top = GetWindowSize(&m_wndToolBar).cy;
+      dc.DrawEdge(&rect, EDGE_ETCHED, BF_TOP);
+   }
+}
+
+
+//
+// WM_COMMAND::ID_MAP_SHOW_STATUSBAR message handlers
+//
+
+void CMapFrame::OnMapShowStatusbar() 
+{
+       // TODO: Add your command handler code here
+       
+}
+
+void CMapFrame::OnUpdateMapShowStatusbar(CCmdUI* pCmdUI) 
+{
+   pCmdUI->SetCheck(m_bShowStatusBar);
+}
+
+
+//
+// WM_COMMAND::ID_MAP_SHOW_TOOLBAR message handlers
+//
+
+void CMapFrame::OnMapShowToolbar() 
+{
+   m_bShowToolBar = !m_bShowToolBar;
+   m_wndToolBar.ShowWindow(m_bShowToolBar ? SW_SHOWNOACTIVATE : SW_HIDE);
+   RedoLayout();
+}
+
+void CMapFrame::OnUpdateMapShowToolbar(CCmdUI* pCmdUI) 
+{
+   pCmdUI->SetCheck(m_bShowToolBar);
+}
+
+
+//
+// WM_COMMAND::ID_MAP_SHOW_TOOLBOX message handlers
+//
+
+void CMapFrame::OnMapShowToolbox() 
+{
+   m_bShowToolBox = !m_bShowToolBox;
+   m_wndToolBox.ShowWindow(m_bShowToolBox ? SW_SHOWNOACTIVATE : SW_HIDE);
+   RedoLayout();
+}
+
+void CMapFrame::OnUpdateMapShowToolbox(CCmdUI* pCmdUI) 
+{
+   pCmdUI->SetCheck(m_bShowToolBox);
+}
+
+
+//
+// WM_CONTEXTMENU message handler
+//
+
+void CMapFrame::OnContextMenu(CWnd* pWnd, CPoint point) 
+{
+   CMenu *pMenu;
+
+   pMenu = theApp.GetContextMenu(9);
+   pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this, NULL);
+}
+
+
+//
+// WM_COMMAND::ID_OBJECT_PROPERTIES message handlers
+//
+
+void CMapFrame::OnObjectProperties() 
+{
+   DWORD dwCount, *pdwList;
+
+   pdwList = m_wndMapView.GetSelectedObjects(&dwCount);
+   if (dwCount == 1)
+      theApp.ObjectProperties(*pdwList);
+   safe_free(pdwList);
+}
+
+void CMapFrame::OnUpdateObjectProperties(CCmdUI* pCmdUI) 
+{
+   pCmdUI->Enable(m_wndMapView.GetSelectionCount() == 1);
+}
+
+
+//
+// WM_COMMAND::ID_OBJECT_LASTDCIVALUES message handlers
+//
+
+void CMapFrame::OnObjectLastdcivalues() 
+{
+   DWORD i, dwCount, *pdwList;
+   NXC_OBJECT *pObject;
+
+   pdwList = m_wndMapView.GetSelectedObjects(&dwCount);
+   for(i = 0; i < dwCount; i++)
+   {
+      pObject = NXCFindObjectById(g_hSession, pdwList[i]);
+      if ((pObject != NULL) && (pObject->iClass == OBJECT_NODE))
+         theApp.ShowLastValues(pObject);
+   }
+   safe_free(pdwList);
+}
+
+void CMapFrame::OnUpdateObjectLastdcivalues(CCmdUI* pCmdUI) 
+{
+   pCmdUI->Enable(CurrObjectIsNode());
+}
+
+
+//
+// Determine if currenly selected object on map is node
+//
+
+BOOL CMapFrame::CurrObjectIsNode()
+{
+   DWORD i, dwCount, *pdwList;
+   NXC_OBJECT *pObject;
+   BOOL bRet = FALSE;
+
+   pdwList = m_wndMapView.GetSelectedObjects(&dwCount);
+   for(i = 0; i < dwCount; i++)
+   {
+      pObject = NXCFindObjectById(g_hSession, pdwList[i]);
+      if (pObject != NULL)
+      {
+         bRet = (pObject->iClass == OBJECT_NODE);
+         if (!bRet)
+            break;
+      }
+   }
+   safe_free(pdwList);
+   return bRet;
+}
index 207d6dc..fef644b 100644 (file)
@@ -38,8 +38,14 @@ public:
 
 // Implementation
 protected:
+       BOOL CurrObjectIsNode(void);
+       void RedoLayout(void);
+       BOOL m_bShowToolBox;
+       BOOL m_bShowStatusBar;
+       BOOL m_bShowToolBar;
+       CImageList m_imageList;
        CMapToolbox m_wndToolBox;
-       CToolBar m_wndToolBar;
+       CToolBarCtrl m_wndToolBar;
        CMapView m_wndMapView;
        virtual ~CMapFrame();
 
@@ -61,6 +67,19 @@ protected:
        afx_msg void OnUpdateMapForward(CCmdUI* pCmdUI);
        afx_msg void OnMapHome();
        afx_msg void OnMapSave();
+       afx_msg void OnMapRedolayout();
+       afx_msg void OnPaint();
+       afx_msg void OnMapShowStatusbar();
+       afx_msg void OnUpdateMapShowStatusbar(CCmdUI* pCmdUI);
+       afx_msg void OnMapShowToolbar();
+       afx_msg void OnUpdateMapShowToolbar(CCmdUI* pCmdUI);
+       afx_msg void OnMapShowToolbox();
+       afx_msg void OnUpdateMapShowToolbox(CCmdUI* pCmdUI);
+       afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
+       afx_msg void OnObjectProperties();
+       afx_msg void OnUpdateObjectProperties(CCmdUI* pCmdUI);
+       afx_msg void OnObjectLastdcivalues();
+       afx_msg void OnUpdateObjectLastdcivalues(CCmdUI* pCmdUI);
        //}}AFX_MSG
    afx_msg void OnObjectChange(WPARAM wParam, NXC_OBJECT *pObject);
        DECLARE_MESSAGE_MAP()
index b4b8131..a8c1c1a 100644 (file)
@@ -68,6 +68,8 @@ BEGIN_MESSAGE_MAP(CMapView, CWnd)
        ON_WM_SIZE()
        ON_WM_HSCROLL()
        ON_WM_VSCROLL()
+       ON_WM_RBUTTONDOWN()
+       ON_WM_RBUTTONUP()
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -455,6 +457,7 @@ void CMapView::DoSubmapLayout()
                   {
                      pLinkList[j].dwId1 = pIndex[i].dwKey;
                      pLinkList[j].dwId2 = pdwSubnetList[k];
+                     pLinkList[j].nType = LINK_TYPE_NORMAL;
                   }
                }
             }
@@ -539,24 +542,10 @@ DWORD CMapView::PointInObject(POINT pt)
 
 
 //
-// WM_LBUTTONDBLCLK message handler
-//
-
-void CMapView::OnLButtonDblClk(UINT nFlags, CPoint point) 
-{
-   DWORD dwId;
-
-   dwId = PointInObject(point);
-   if (dwId != 0)
-      OpenSubmap(dwId);
-}
-
-
-//
-// WM_LBUTTONDOWN message handler
+// Generic processing for mouse button down message (either left or right)
 //
 
-void CMapView::OnLButtonDown(UINT nFlags, CPoint point) 
+void CMapView::OnMouseButtonDown(UINT nFlags, POINT point)
 {
    m_ptMouseOpStart = point;
    m_dwFocusedObject = PointInObject(point);
@@ -597,10 +586,10 @@ void CMapView::OnLButtonDown(UINT nFlags, CPoint point)
 
 
 //
-// WM_LBUTTONUP message handler
+// Generic processing for mouse button up message (either left or right)
 //
 
-void CMapView::OnLButtonUp(UINT nFlags, CPoint point) 
+void CMapView::OnMouseButtonUp(UINT nFlags, POINT point)
 {
    ReleaseCapture();
    switch(m_nState)
@@ -628,6 +617,62 @@ void CMapView::OnLButtonUp(UINT nFlags, CPoint point)
 }
 
 
+//
+// WM_LBUTTONDBLCLK message handler
+//
+
+void CMapView::OnLButtonDblClk(UINT nFlags, CPoint point) 
+{
+   DWORD dwId;
+
+   dwId = PointInObject(point);
+   if (dwId != 0)
+      OpenSubmap(dwId);
+}
+
+
+//
+// WM_LBUTTONDOWN message handler
+//
+
+void CMapView::OnLButtonDown(UINT nFlags, CPoint point) 
+{
+   OnMouseButtonDown(nFlags, point);
+}
+
+
+//
+// WM_LBUTTONUP message handler
+//
+
+void CMapView::OnLButtonUp(UINT nFlags, CPoint point) 
+{
+   OnMouseButtonUp(nFlags, point);
+}
+
+
+//
+// WM_RBUTTONDOWN message handler
+//
+
+void CMapView::OnRButtonDown(UINT nFlags, CPoint point) 
+{
+   OnMouseButtonDown(nFlags, point);
+}
+
+
+//
+// WM_RBUTTONUP message handler
+//
+
+void CMapView::OnRButtonUp(UINT nFlags, CPoint point) 
+{
+   OnMouseButtonUp(nFlags, point);
+   ClientToScreen(&point);
+   GetParent()->SendMessage(WM_CONTEXTMENU, (WPARAM)m_hWnd, MAKELONG(point.x, point.y));
+}
+
+
 //
 // WM_MOUSEMOVE message handler
 //
@@ -827,6 +872,7 @@ void CMapView::OpenSubmap(DWORD dwId, BOOL bAddToHistory)
       m_pSubmap = pSubmap;
       if (!m_pSubmap->IsLayoutCompleted())
          DoSubmapLayout();
+      ClearSelection(FALSE);
       m_ptMapSize = m_pSubmap->GetMinSize();
       ScalePosMapToScreen(&m_ptMapSize);
       Update();
@@ -1268,3 +1314,28 @@ void CMapView::OnObjectChange(DWORD dwObjectId, NXC_OBJECT *pObject)
       Update();
    }
 }
+
+
+//
+// Get list of selected objects
+//
+
+DWORD *CMapView::GetSelectedObjects(DWORD *pdwNumObjects)
+{
+   DWORD i, dwCount, *pdwList;
+
+   pdwList = (DWORD *)malloc(sizeof(DWORD) * m_pSubmap->GetNumObjects());
+   for(i = 0, dwCount = 0; i < m_pSubmap->GetNumObjects(); i++)
+      if (m_pSubmap->GetObjectStateFromIndex(i) & MOS_SELECTED)
+      {
+         pdwList[dwCount] = m_pSubmap->GetObjectIdFromIndex(i);
+         dwCount++;
+      }
+   *pdwNumObjects = dwCount;
+   if (dwCount == 0)
+   {
+      free(pdwList);
+      pdwList = NULL;
+   }
+   return pdwList;
+}
index d310bcf..38ecb50 100644 (file)
@@ -83,6 +83,7 @@ public:
 
 // Implementation
 public:
+       void DoSubmapLayout(void);
        void OnObjectChange(DWORD dwObjectId, NXC_OBJECT *pObject);
        BOOL CanGoForward(void);
        BOOL CanGoBack(void);
@@ -106,6 +107,8 @@ public:
 
        // Generated message map functions
 protected:
+       void OnMouseButtonDown(UINT nFlags, POINT point);
+       void OnMouseButtonUp(UINT nFlags, POINT point);
        void AddToHistory(DWORD dwId);
        DWORD m_dwHistory[MAX_HISTORY_SIZE];
        DWORD m_dwHistoryPos;
@@ -136,7 +139,6 @@ protected:
    DWORD m_dwNumObjects;
        CFont m_fontList[3];
        int m_nScale;
-       void DoSubmapLayout(void);
        void DrawObject(CDC &dc, DWORD dwIndex, CImageList *pImageList,
                    POINT ptOffset, BOOL bUpdateInfo);
        void DrawOnBitmap(CBitmap &bitmap, BOOL bSelectionOnly, RECT *prcSel);
@@ -153,10 +155,13 @@ protected:
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
        afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+       afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
+       afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 
 public:
+       DWORD * GetSelectedObjects(DWORD *pdwNumObjects);
    nxMap *GetMap(void) { return m_pMap; }
 };
 
index deb6f34..f25ae6c 100644 (file)
@@ -16,9 +16,9 @@ Class7=CEventBrowser
 Class9=CMapView
 
 ResourceCount=138
-Resource1=IDD_CREATE_VPNC (English (U.S.))
+Resource1=IDD_OBJECT_CAPS (English (U.S.))
 Resource2=IDD_OBJECT_NODE_GENERAL
-Resource3=IDA_AGENT_CFG_EDITOR (English (U.S.))
+Resource3=IDD_DCI_TRANSFORM (English (U.S.))
 Resource4=IDD_SELECT_OBJECT
 Resource5=IDD_SELECT_ACTION
 Class2=CChildView
@@ -32,9 +32,9 @@ Resource7=IDD_NEW_USER
 Class12=CObjectBrowser
 Resource8=IDD_CREATE_CONTAINER
 Class13=CObjectPropDlg
-Resource9=IDD_OBJECT_NODE_POLL (English (U.S.))
-Resource10=IDD_DESKTOP_SAVE_AS (English (U.S.))
-Resource11=IDD_NEW_ACTION (English (U.S.))
+Resource9=IDA_SERVER_CFG_EDITOR (English (U.S.))
+Resource10=IDA_DC_EDITOR (English (U.S.))
+Resource11=IDD_OBJTOOL_OPTIONS (English (U.S.))
 Resource12=IDR_CTRLPANEL (English (U.S.))
 Resource13=IDR_EVENTS (English (U.S.))
 Resource14=IDR_MAPFRAME (English (U.S.))
@@ -42,17 +42,17 @@ Resource15=IDR_OBJECTS (English (U.S.))
 Resource16=IDD_DUMMY (English (U.S.))
 Class14=CEventEditor
 Class15=CEditEventDlg
-Resource17=IDD_EDIT_TRAP_ARG (English (U.S.))
+Resource17=IDA_EVENT_EDITOR (English (U.S.))
 Class16=CDebugFrame
-Resource18=IDD_OBJECT_VPNC_GENERAL (English (U.S.))
+Resource18=IDD_REQUEST_PROCESSING (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
 Resource20=IDD_SELECT_EVENT
 Class17=CObjectPreview
-Resource21=IDA_DC_EDITOR (English (U.S.))
+Resource21=IDD_CREATE_TG (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource22=IDD_GRAPH_PROP_SETTINGS (English (U.S.))
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
@@ -61,14 +61,14 @@ Class24=CObjectPropCaps
 Class25=CObjectPropSheet
 Resource24=IDA_MDI_DEFAULT
 Class26=CRequestProcessingDlg
-Resource25=IDD_EDIT_TRAP (English (U.S.))
+Resource25=IDA_NETMAP (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
 Resource27=IDD_EDIT_RULE_ALARM
-Resource28=IDD_CREATE_NETSRV (English (U.S.))
+Resource28=IDA_PACKAGE_MGR (English (U.S.))
 Class27=CObjectPropsGeneral
-Resource29=IDD_SET_PASSWORD (English (U.S.))
+Resource29=IDD_GRAPH_PROP_DATA (English (U.S.))
 Class28=CObjectPropsSecurity
-Resource30=IDD_OBJECT_SECURITY (English (U.S.))
+Resource30=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
 Resource31=IDD_SELECT_USER
 Resource32=IDD_OBJECT_SECURITY
 Class29=CUserSelectDlg
@@ -79,36 +79,36 @@ Class31=CNewUserDlg
 Resource35=IDD_THRESHOLD
 Resource36=IDA_EPP
 Class32=CUserPropDlg
-Resource37=IDA_SCRIPT_MANAGER (English (U.S.))
+Resource37=IDD_DATA_QUERY (English (U.S.))
 Resource38=IDD_ABOUTBOX
 Class33=CGroupPropDlg
 Resource39=IDD_CP_GENERAL
 Resource40=IDA_TRAP_EDITOR
 Resource41=IDM_VIEW_SPECIFIC
-Resource42=IDD_SELECT_OBJECT (English (U.S.))
+Resource42=IDD_OBJECT_VPNC_GENERAL (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
 Class36=CNetSummaryFrame
 Class37=CDataCollectionEditor
-Resource43=IDA_LAST_VALUES (English (U.S.))
+Resource43=IDD_CREATE_CONTAINER (English (U.S.))
 Class38=CDCIPropPage
-Resource44=IDA_TRAP_EDITOR (English (U.S.))
+Resource44=IDD_NEW_ACTION (English (U.S.))
 Class39=CDCIDataView
-Resource45=IDD_MIB_BROWSER (English (U.S.))
+Resource45=IDD_CREATE_VPNC (English (U.S.))
 Class40=CGraph
 Class41=CGraphFrame
 Class42=CDCIThresholdsPage
-Resource46=IDD_ACTION_PROPERTIES (English (U.S.))
-Resource47=IDD_ABOUTBOX (English (U.S.))
+Resource46=IDD_CHANGE_IP (English (U.S.))
+Resource47=IDD_EDIT_TRAP (English (U.S.))
 Resource48=IDM_CONTEXT
 Class43=CThresholdDlg
-Resource49=IDA_GRAPH (English (U.S.))
+Resource49=IDD_ACTION_PROPERTIES (English (U.S.))
 Resource50=IDD_EDIT_TRAP_ARG
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
-Resource51=IDA_MDI_DEFAULT (English (U.S.))
+Resource51=IDD_SELECT_OBJECT (English (U.S.))
 Resource52=IDD_CREATE_NODE
 Class48=CObjectSelDlg
 Resource53=IDD_OBJECT_CAPS
@@ -117,22 +117,22 @@ Class49=CRuleCommentDlg
 Resource55=IDD_DCI_COLLECTION
 Class50=CEventSelDlg
 Resource56=IDD_DATA_QUERY
-Resource57=IDD_DCI_COLLECTION (English (U.S.))
+Resource57=IDD_LASTVAL_PROP (English (U.S.))
 Resource58=IDD_CREATE_TG
-Resource59=IDD_OBJECT_PRESENTATION (English (U.S.))
-Resource60=IDA_ACTION_EDITOR (English (U.S.))
+Resource59=IDD_DCI_SCHEDULE (English (U.S.))
+Resource60=IDD_CP_GENERAL (English (U.S.))
 Class51=CObjectPropsPresentation
-Resource61=IDD_OBJTOOL_OPTIONS (English (U.S.))
+Resource61=IDD_SET_PASSWORD (English (U.S.))
 Resource62=IDD_EDIT_RULE_COMMENT
 Class52=CRuleSeverityDlg
 Resource63=IDD_ACTION_PROPERTIES
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
-Resource64=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
+Resource64=IDD_CREATE_TEMPLATE (English (U.S.))
 Resource65=IDD_DCI_TRANSFORM
-Resource66=IDD_EDIT_EVENT (English (U.S.))
-Resource67=IDD_DCI_DATA_EXPORT (English (U.S.))
-Resource68=IDD_EDIT_IP_SUBNET (English (U.S.))
+Resource66=IDD_EDIT_TRAP_ARG (English (U.S.))
+Resource67=IDD_EDIT_EVENT (English (U.S.))
+Resource68=IDD_OBJECT_GENERAL (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
 Resource69=IDA_ACTION_EDITOR
@@ -143,18 +143,18 @@ Class58=CEditActionDlg
 Resource72=IDA_NETMAP
 Class59=CActionSelDlg
 Resource73=IDD_MIB_BROWSER
-Resource74=IDD_REMOVE_TEMPLATE
-Resource75=IDD_SELECT_INTERNAL_ITEM (English (U.S.))
+Resource74=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource75=IDA_ACTION_EDITOR (English (U.S.))
 Resource76=IDD_USER_PROPERTIES
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
 Resource77=IDR_MAINFRAME
 Class62=CCreateNodeDlg
-Resource78=IDD_CREATE_NODE (English (U.S.))
+Resource78=IDR_MAINFRAME (English (U.S.))
 Resource79=IDT_MAP (English (U.S.))
-Resource80=IDD_SELECT_USER (English (U.S.))
+Resource80=IDD_OBJECT_NODE_POLL (English (U.S.))
 Class63=CDCITransformPage
-Resource81=IDA_SERVER_CFG_EDITOR (English (U.S.))
+Resource81=IDD_CREATE_NODE (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
@@ -171,7 +171,7 @@ Resource89=IDA_ALARM_BROWSER
 Class69=CDataQueryDlg
 Resource90=IDD_EDIT_RULE_SEVERITY
 Class70=CTrapEditDlg
-Resource91=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource91=IDD_SELECT_INTERNAL_ITEM (English (U.S.))
 Class71=CTrapParamDlg
 Resource92=IDD_EDIT_EVENT
 Resource93=IDD_CREATE_TEMPLATE
@@ -179,91 +179,91 @@ Class72=CGraphPropDlg
 Class73=CColorSelector
 Class74=CPackageMgr
 Resource94=IDD_GROUP_PROPERTIES
-Resource95=IDD_SELECT_ACTION (English (U.S.))
-Resource96=IDD_INPUT_BOX (English (U.S.))
-Resource97=IDD_OBJTOOL_GENERAL (English (U.S.))
-Resource98=IDD_NEW_USER (English (U.S.))
-Resource99=IDA_ALARM_BROWSER (English (U.S.))
-Resource100=IDD_OBJECT_CAPS (English (U.S.))
-Resource101=IDD_EDIT_RULE_SEVERITY (English (U.S.))
-Resource102=IDD_GRAPH_PROP_DATA (English (U.S.))
-Resource103=IDD_EDIT_VARIABLE (English (U.S.))
-Resource104=IDD_EDIT_RULE_COMMENT (English (U.S.))
-Resource105=IDD_GRAPH_PROP_SETTINGS (English (U.S.))
-Resource106=IDA_OBJECT_BROWSER (English (U.S.))
-Resource107=IDD_SAVE_AGENT_CFG (English (U.S.))
+Resource95=IDD_REMOVE_TEMPLATE
+Resource96=IDA_GRAPH (English (U.S.))
+Resource97=IDD_USER_PROPERTIES (English (U.S.))
+Resource98=IDD_OBJECT_RELATIONS (English (U.S.))
+Resource99=IDD_OBJECT_PRESENTATION (English (U.S.))
+Resource100=IDD_SELECT_AGENT_PARAM (English (U.S.))
+Resource101=IDD_OBJECT_STATUS (English (U.S.))
+Resource102=IDA_SCRIPT_MANAGER (English (U.S.))
+Resource103=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource104=IDD_EDIT_IP_SUBNET (English (U.S.))
+Resource105=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
+Resource106=IDD_EDIT_RULE_COMMENT (English (U.S.))
+Resource107=IDD_OBJECT_SECURITY (English (U.S.))
 Class75=CInternalItemSelDlg
-Resource108=IDD_DCI_TRANSFORM (English (U.S.))
+Resource108=IDA_MDI_DEFAULT (English (U.S.))
 Class76=CAgentParamSelDlg
-Resource109=IDD_SELECT_AGENT_PARAM (English (U.S.))
+Resource109=IDA_TRAP_EDITOR (English (U.S.))
 Class77=CInputBox
-Resource110=IDD_CREATE_TEMPLATE (English (U.S.))
+Resource110=IDA_EPP (English (U.S.))
 Class78=CCreateNetSrvDlg
-Resource111=IDD_DATA_QUERY (English (U.S.))
+Resource111=IDA_ALARM_BROWSER (English (U.S.))
 Class79=CNetSrvPropsGeneral
 Resource112=IDD_LOGIN (English (U.S.))
 Class80=CNodePropsPolling
 Class81=CDeploymentView
 Class82=CLastValuesView
 Class83=CValueList
-Resource113=IDD_REQUEST_PROCESSING (English (U.S.))
+Resource113=IDD_INPUT_BOX (English (U.S.))
 Class84=CObjectPropsRelations
-Resource114=IDD_EDIT_RULE_ALARM (English (U.S.))
+Resource114=IDD_OBJTOOL_GENERAL (English (U.S.))
 Class85=CSaveDesktopDlg
-Resource115=IDD_SELECT_EVENT (English (U.S.))
+Resource115=IDD_SAVE_AGENT_CFG (English (U.S.))
 Class86=CGraphSettingsPage
-Resource116=IDD_THRESHOLD (English (U.S.))
+Resource116=IDD_EDIT_VARIABLE (English (U.S.))
 Class87=CGraphDataPage
-Resource117=IDM_CONTEXT (English (U.S.))
+Resource117=IDD_EDIT_RULE_ALARM (English (U.S.))
 Class88=CRemoveTemplateDlg
-Resource118=IDD_DCI_SCHEDULE (English (U.S.))
+Resource118=IDD_SELECT_USER (English (U.S.))
 Class89=CAddrChangeDlg
-Resource119=IDA_EPP (English (U.S.))
+Resource119=IDD_SELECT_EVENT (English (U.S.))
 Class90=CLastValuesPropDlg
 Class91=CAgentCfgEditor
-Resource120=IDA_EVENT_EDITOR (English (U.S.))
+Resource120=IDM_CONTEXT (English (U.S.))
 Class92=CDataExportDlg
 Class93=CServerCfgEditor
-Resource121=IDD_OBJECT_RELATIONS (English (U.S.))
-Resource122=IDA_NETMAP (English (U.S.))
+Resource121=IDA_AGENT_CFG_EDITOR (English (U.S.))
+Resource122=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Class94=CEditVariableDlg
-Resource123=IDD_OBJECT_GENERAL (English (U.S.))
+Resource123=IDD_CREATE_NETSRV (English (U.S.))
 Class95=CCreateVPNConnDlg
-Resource124=IDR_MAINFRAME (English (U.S.))
+Resource124=IDD_THRESHOLD (English (U.S.))
 Class96=CVPNCPropsGeneral
-Resource125=IDD_LASTVAL_PROP (English (U.S.))
+Resource125=IDD_ABOUTBOX (English (U.S.))
 Class97=CEditSubnetDlg
-Resource126=IDA_PACKAGE_MGR (English (U.S.))
-Resource127=IDD_NEW_OBJECT_TOOL (English (U.S.))
+Resource126=IDD_SELECT_ACTION (English (U.S.))
+Resource127=IDD_GROUP_PROPERTIES (English (U.S.))
 Class98=CModifiedAgentCfgDlg
 Class99=CSimpleSplitter
 Class100=CAdvSplitter
-Resource128=IDD_CREATE_CONTAINER (English (U.S.))
+Resource128=IDD_OBJTOOL_COLUMNS
 Class101=CTableView
 Class102=CWaitView
 Class103=CWebBrowser
 Class104=CSyslogBrowser
 Class105=CLPPList
-Resource129=IDD_USER_PROPERTIES (English (U.S.))
+Resource129=IDD_DESKTOP_SAVE_AS (English (U.S.))
 Class106=CDCISchedulePage
-Resource130=IDD_CREATE_TG (English (U.S.))
+Resource130=IDA_OBJECT_BROWSER (English (U.S.))
 Class107=CObjectPropsStatus
 Class108=CObjectToolsEditor
-Resource131=IDD_OBJTOOL_COLUMNS
-Resource132=IDD_CHANGE_IP (English (U.S.))
+Resource131=IDM_VIEW_SPECIFIC (English (U.S.))
+Resource132=IDD_DCI_COLLECTION (English (U.S.))
 Class109=CObjToolPropGeneral
-Resource133=IDD_OBJECT_STATUS (English (U.S.))
+Resource133=IDD_NEW_USER (English (U.S.))
 Class110=CObjToolPropColumns
-Resource134=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource134=IDD_DCI_DATA_EXPORT (English (U.S.))
 Class111=CNewObjectToolDlg
 Class112=CObjToolPropOptions
 Class113=CScriptManager
 Class114=CScriptView
-Resource135=IDM_VIEW_SPECIFIC (English (U.S.))
+Resource135=IDD_MIB_BROWSER (English (U.S.))
 Class115=CTrapLogBrowser
 Class116=CViewEditor
-Resource136=IDD_CP_GENERAL (English (U.S.))
-Resource137=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
+Resource136=IDD_NEW_OBJECT_TOOL (English (U.S.))
+Resource137=IDA_LAST_VALUES (English (U.S.))
 Class117=CSNMPWalkDlg
 Class118=CMapToolbox
 Class119=CMapControlBox
@@ -934,7 +934,8 @@ Command159=ID_MAP_SHOW_TOOLBOX
 Command160=ID_MAP_SHOW_TOOLBAR
 Command161=ID_MAP_SHOW_STATUSBAR
 Command162=ID_MAP_SAVE
-CommandCount=162
+Command163=ID_MAP_REDOLAYOUT
+CommandCount=163
 
 [ACL:IDA_MDI_DEFAULT (English (U.S.))]
 Type=1
@@ -1598,70 +1599,77 @@ Command68=ID_ACTION_RENAME
 Command69=ID_ACTION_DELETE
 Command70=ID_ACTION_PROPERTIES
 Command71=ID_POLL_RESTART
-Command72=ID_OBJECT_OPEN
-Command73=ID_OBJECT_OPENPARENT
-Command74=ID_OBJECT_CREATE_NODE
-Command75=ID_OBJECT_CREATE_CONTAINER
-Command76=ID_OBJECT_CREATE_TEMPLATEGROUP
-Command77=ID_OBJECT_CREATE_TEMPLATE
-Command78=ID_OBJECT_BIND
-Command79=ID_OBJECT_RENAME
-Command80=ID_OBJECT_DELETE
-Command81=ID_OBJECT_MANAGE
-Command82=ID_OBJECT_UNMANAGE
-Command83=ID_OBJECT_POLL_STATUS
-Command84=ID_OBJECT_POLL_CONFIGURATION
-Command85=ID_OBJECT_DATACOLLECTION
-Command86=ID_OBJECT_PROPERTIES
-Command87=ID_EVENT_NEW
-Command88=ID_EVENT_EDIT
-Command89=ID_EVENT_DELETE
-Command90=ID_TRAP_NEW
-Command91=ID_TRAP_EDIT
-Command92=ID_TRAP_DELETE
-Command93=ID_GRAPH_PRESETS_LAST10MINUTES
-Command94=ID_GRAPH_PRESETS_LAST30MINUTES
-Command95=ID_GRAPH_PRESETS_LASTHOUR
-Command96=ID_GRAPH_PRESETS_LAST2HOURS
-Command97=ID_GRAPH_PRESETS_LAST4HOURS
-Command98=ID_GRAPH_PRESETS_LASTDAY
-Command99=ID_GRAPH_PRESETS_LASTWEEK
-Command100=ID_GRAPH_PRESETS_LASTMONTH
-Command101=ID_GRAPH_PRESETS_LASTYEAR
-Command102=ID_GRAPH_AUTOSCALE
-Command103=ID_GRAPH_LEGEND
-Command104=ID_GRAPH_RULER
-Command105=ID_GRAPH_PROPERTIES
-Command106=ID_PACKAGE_INSTALL
-Command107=ID_PACKAGE_REMOVE
-Command108=ID_PACKAGE_DEPLOY
-Command109=ID_ITEM_SHOWDATA
-Command110=ID_ITEM_GRAPH
-Command111=ID_ITEM_EXPORTDATA
-Command112=ID_LASTVALUES_PROPERTIES
-Command113=ID_VARIABLE_NEW
-Command114=ID_VARIABLE_EDIT
-Command115=ID_VARIABLE_DELETE
-Command116=ID_EDIT_UNDO
-Command117=ID_EDIT_REDO
-Command118=ID_EDIT_CUT
-Command119=ID_EDIT_COPY
-Command120=ID_EDIT_PASTE
-Command121=ID_EDIT_DELETE
-Command122=ID_EDIT_SELECT_ALL
-Command123=ID_CONFIG_SAVE
-Command124=ID_CONFIG_SAVEANDAPPLY
-Command125=ID_OBJECTTOOLS_NEW
-Command126=ID_OBJECTTOOLS_EDIT
-Command127=ID_OBJECTTOOLS_DELETE
-Command128=ID_SCRIPT_NEW
-Command129=ID_SCRIPT_EDIT
-Command130=ID_SCRIPT_SAVE
-Command131=ID_SCRIPT_RENAME
-Command132=ID_SCRIPT_DELETE
-Command133=ID_SCRIPT_VIEWASLIST
-Command134=ID_SCRIPT_VIEWASTREE
-CommandCount=134
+Command72=ID_MAP_BACK
+Command73=ID_MAP_FORWARD
+Command74=ID_MAP_HOME
+Command75=ID_OBJECT_CREATE_NODE
+Command76=ID_OBJECT_CREATE_CONTAINER
+Command77=ID_OBJECT_CREATE_TEMPLATEGROUP
+Command78=ID_OBJECT_CREATE_TEMPLATE
+Command79=ID_OBJECT_CREATE_SERVICE
+Command80=ID_OBJECT_CREATE_VPNCONNECTOR
+Command81=ID_OBJECT_BIND
+Command82=ID_OBJECT_UNBIND
+Command83=ID_OBJECT_RENAME
+Command84=ID_OBJECT_DELETE
+Command85=ID_OBJECT_CHANGEIPADDRESS
+Command86=ID_OBJECT_AGENTCFG
+Command87=ID_OBJECT_MANAGE
+Command88=ID_OBJECT_UNMANAGE
+Command89=ID_OBJECT_POLL_STATUS
+Command90=ID_OBJECT_POLL_CONFIGURATION
+Command91=ID_OBJECT_DATACOLLECTION
+Command92=ID_OBJECT_LASTDCIVALUES
+Command93=ID_OBJECT_PROPERTIES
+Command94=ID_EVENT_NEW
+Command95=ID_EVENT_EDIT
+Command96=ID_EVENT_DELETE
+Command97=ID_TRAP_NEW
+Command98=ID_TRAP_EDIT
+Command99=ID_TRAP_DELETE
+Command100=ID_GRAPH_PRESETS_LAST10MINUTES
+Command101=ID_GRAPH_PRESETS_LAST30MINUTES
+Command102=ID_GRAPH_PRESETS_LASTHOUR
+Command103=ID_GRAPH_PRESETS_LAST2HOURS
+Command104=ID_GRAPH_PRESETS_LAST4HOURS
+Command105=ID_GRAPH_PRESETS_LASTDAY
+Command106=ID_GRAPH_PRESETS_LASTWEEK
+Command107=ID_GRAPH_PRESETS_LASTMONTH
+Command108=ID_GRAPH_PRESETS_LASTYEAR
+Command109=ID_GRAPH_AUTOSCALE
+Command110=ID_GRAPH_LEGEND
+Command111=ID_GRAPH_RULER
+Command112=ID_GRAPH_PROPERTIES
+Command113=ID_PACKAGE_INSTALL
+Command114=ID_PACKAGE_REMOVE
+Command115=ID_PACKAGE_DEPLOY
+Command116=ID_ITEM_SHOWDATA
+Command117=ID_ITEM_GRAPH
+Command118=ID_ITEM_EXPORTDATA
+Command119=ID_LASTVALUES_PROPERTIES
+Command120=ID_VARIABLE_NEW
+Command121=ID_VARIABLE_EDIT
+Command122=ID_VARIABLE_DELETE
+Command123=ID_EDIT_UNDO
+Command124=ID_EDIT_REDO
+Command125=ID_EDIT_CUT
+Command126=ID_EDIT_COPY
+Command127=ID_EDIT_PASTE
+Command128=ID_EDIT_DELETE
+Command129=ID_EDIT_SELECT_ALL
+Command130=ID_CONFIG_SAVE
+Command131=ID_CONFIG_SAVEANDAPPLY
+Command132=ID_OBJECTTOOLS_NEW
+Command133=ID_OBJECTTOOLS_EDIT
+Command134=ID_OBJECTTOOLS_DELETE
+Command135=ID_SCRIPT_NEW
+Command136=ID_SCRIPT_EDIT
+Command137=ID_SCRIPT_SAVE
+Command138=ID_SCRIPT_RENAME
+Command139=ID_SCRIPT_DELETE
+Command140=ID_SCRIPT_VIEWASLIST
+Command141=ID_SCRIPT_VIEWASTREE
+CommandCount=141
 
 [DLG:IDD_SET_PASSWORD (English (U.S.))]
 Type=1
index 9b138d4..0256bb7 100644 (file)
@@ -537,6 +537,7 @@ BEGIN
         END
         MENUITEM SEPARATOR
         MENUITEM "&Save\tCtrl+S",               ID_MAP_SAVE
+        MENUITEM "&Redo layout",                ID_MAP_REDOLAYOUT
     END
 END
 
@@ -691,10 +692,11 @@ BEGIN
     BEGIN
         MENUITEM "&Restart",                    ID_POLL_RESTART
     END
-    POPUP "Object"
+    POPUP "Object (map)"
     BEGIN
-        MENUITEM "&Open",                       ID_OBJECT_OPEN
-        MENUITEM "Open parent",                 ID_OBJECT_OPENPARENT
+        MENUITEM "&Back",                       ID_MAP_BACK
+        MENUITEM "&Forward",                    ID_MAP_FORWARD
+        MENUITEM "&Home",                       ID_MAP_HOME
         MENUITEM SEPARATOR
         POPUP "&Create"
         BEGIN
@@ -705,10 +707,17 @@ BEGIN
 
             MENUITEM "&Template...",                ID_OBJECT_CREATE_TEMPLATE
 
+            MENUITEM "&Service...",                 ID_OBJECT_CREATE_SERVICE
+            MENUITEM "&VPN Connector...",           ID_OBJECT_CREATE_VPNCONNECTOR
+
         END
         MENUITEM "&Bind...",                    ID_OBJECT_BIND
+        MENUITEM "U&nbind...",                  ID_OBJECT_UNBIND
         MENUITEM "&Rename",                     ID_OBJECT_RENAME
         MENUITEM "&Delete",                     ID_OBJECT_DELETE
+        MENUITEM "Change &IP address...",       ID_OBJECT_CHANGEIPADDRESS
+        MENUITEM SEPARATOR
+        MENUITEM "&Edit agent's configuration", ID_OBJECT_AGENTCFG
         MENUITEM SEPARATOR
         MENUITEM "&Manage",                     ID_OBJECT_MANAGE
         MENUITEM "&Unmanage",                   ID_OBJECT_UNMANAGE
@@ -720,6 +729,8 @@ BEGIN
         END
         MENUITEM SEPARATOR
         MENUITEM "D&ata collection",            ID_OBJECT_DATACOLLECTION
+        MENUITEM "&Last DCI values",            ID_OBJECT_LASTDCIVALUES
+        MENUITEM SEPARATOR
         MENUITEM "&Properties...",              ID_OBJECT_PROPERTIES
     END
     POPUP "Event"
@@ -2975,6 +2986,17 @@ BEGIN
     IDR_ALARMS              "\nAlarm Browser\nAlarm Browser"
 END
 
+STRINGTABLE DISCARDABLE 
+BEGIN
+    ID_MAP_ZOOMIN           "Zoom in\nZoom in"
+    ID_MAP_ZOOMOUT          "Zoom out\nZoom out"
+    ID_MAP_SAVE             "Save current map layout on server\nSave map"
+    ID_MAP_BACK             "Back\nBack"
+    ID_MAP_FORWARD          "Forward\nForward"
+    ID_MAP_HOME             "Open root submap\nOpen root submap"
+    ID_MAP_REDOLAYOUT       "Redo submap layout\nRedo submap layout"
+END
+
 #endif    // English (U.S.) resources
 /////////////////////////////////////////////////////////////////////////////
 
index 83a0b8b..bbfcf4e 100644 (file)
 #define ID_MAP_BACK                     33004
 #define ID_MAP_FORWARD                  33005
 #define ID_MAP_HOME                     33006
+#define ID_MAP_REDOLAYOUT               33007
 #define IDS_GETFOLDERPATH_FAILED        61216
 #define IDS_WORKDIR_CREATION_FAILED     61217
 #define IDS_SCINTILLA_INIT_FAILED       61218
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        312
-#define _APS_NEXT_COMMAND_VALUE         33007
+#define _APS_NEXT_COMMAND_VALUE         33008
 #define _APS_NEXT_CONTROL_VALUE         1343
 #define _APS_NEXT_SYMED_VALUE           127
 #endif
index e86eb9f..3e34f2c 100644 (file)
@@ -144,12 +144,13 @@ nxSubmap *nxMap::GetSubmap(DWORD dwObjectId)
 // Check if submap for given object exists
 //
 
-BOOL nxMap::IsSubmapExist(DWORD dwObjectId)
+BOOL nxMap::IsSubmapExist(DWORD dwObjectId, BOOL bLock)
 {
    BOOL bRet = FALSE;
    DWORD i;
 
-   Lock();
+   if (bLock)
+      Lock();
 
    for(i = 0; i < m_dwNumSubmaps; i++)
    {
@@ -160,7 +161,8 @@ BOOL nxMap::IsSubmapExist(DWORD dwObjectId)
       }
    }
 
-   Unlock();
+   if (bLock)
+      Unlock();
    return bRet;
 }
 
index 121b695..6cc0c27 100644 (file)
@@ -146,6 +146,7 @@ void nxSubmap::ModifyFromMessage(CSCPMessage *pMsg)
          m_pObjectList[i].dwId = pdwList[j++];
          m_pObjectList[i].x = pdwList[j++];
          m_pObjectList[i].y = pdwList[j++];
+         m_pObjectList[i].dwState = 0;
       }
       free(pdwList);
    }
index 30f1178..319fbb0 100644 (file)
@@ -42,6 +42,17 @@ static nxSubmap *CreateSubmapSrv(DWORD dwObjectId, nxMap *pMap)
 }
 
 
+//
+// Constructor for new empty nxSubmapSrv object
+//
+
+nxSubmapSrv::nxSubmapSrv(DWORD dwObjectId, DWORD dwMapId)
+            :nxSubmap(dwObjectId)
+{
+   m_dwMapId = dwMapId;
+}
+
+
 //
 // Constructor for creating submap object from database
 // Expected field order:
@@ -103,13 +114,67 @@ nxSubmapSrv::nxSubmapSrv(DB_RESULT hData, int nRow, DWORD dwMapId)
 
 
 //
-// Constructor for new empty nxSubmapSrv object
+// Save submap to database
+// Will return appropriate RCC, ready for sending to client
+// Intended to be called only from nxMapSrv::SaveToDB()
 //
 
-nxSubmapSrv::nxSubmapSrv(DWORD dwObjectId, DWORD dwMapId)
-            :nxSubmap(dwObjectId)
+DWORD nxSubmapSrv::SaveToDB(void)
 {
-   m_dwMapId = dwMapId;
+   TCHAR szQuery[256];
+   DB_RESULT hResult;
+   BOOL bExist;
+   DWORD i, dwResult = RCC_DB_FAILURE;
+
+   // Check if submap record exist in database
+   _sntprintf(szQuery, 256, _T("SELECT submap_id FROM submaps WHERE map_id=%d AND submap_id=%d"),
+              m_dwMapId, m_dwId);
+   hResult = DBSelect(g_hCoreDB, szQuery);
+   if (hResult == NULL)
+      goto exit_save;
+
+   bExist = (DBGetNumRows(hResult) > 0);
+   DBFreeResult(hResult);
+
+   if (bExist)
+   {
+      _sntprintf(szQuery, 256, _T("UPDATE submaps SET attributes=%d WHERE map_id=%d AND submap_id=%d"),
+                 m_dwAttr, m_dwMapId, m_dwId);
+   }
+   else
+   {
+      _sntprintf(szQuery, 256, _T("INSERT INTO submaps (map_id,submap_id,attributes) VALUES (%d,%d,%d)"),
+                 m_dwMapId, m_dwId, m_dwAttr);
+   }
+   if (!DBQuery(g_hCoreDB, szQuery))
+      goto exit_save;
+
+   // Save object positions
+   // INSERT is used because old records was deleted by nxMapSrv::SaveToDB()
+   for(i = 0; i < m_dwNumObjects; i++)
+   {
+      _sntprintf(szQuery, 256, _T("INSERT INTO submap_object_positions (map_id,submap_id,object_id,x,y) VALUES (%d,%d,%d,%d,%d)"),
+                 m_dwMapId, m_dwId, m_pObjectList[i].dwId, m_pObjectList[i].x,
+                 m_pObjectList[i].y);
+      if (!DBQuery(g_hCoreDB, szQuery))
+         goto exit_save;
+   }
+
+   // Save links between objects
+   // INSERT is used because old records was deleted by nxMapSrv::SaveToDB()
+   for(i = 0; i < m_dwNumLinks; i++)
+   {
+      _sntprintf(szQuery, 256, _T("INSERT INTO submap_links (map_id,submap_id,object_id1,object_id2,link_type) VALUES (%d,%d,%d,%d,%d)"),
+                 m_dwMapId, m_dwId, m_pLinkList[i].dwId1, m_pLinkList[i].dwId2,
+                 m_pLinkList[i].nType);
+      if (!DBQuery(g_hCoreDB, szQuery))
+         goto exit_save;
+   }
+
+   dwResult = RCC_SUCCESS;
+
+exit_save:
+   return dwResult;
 }
 
 
@@ -166,6 +231,94 @@ nxMapSrv::nxMapSrv(DB_RESULT hData, int nRow)
 }
 
 
+//
+// Save map to database
+// Will return appropriate RCC, ready for sending to client
+//
+
+DWORD nxMapSrv::SaveToDB(void)
+{
+   DWORD i, dwNumRows, dwId, dwResult = RCC_DB_FAILURE;
+   DB_RESULT hResult;
+   TCHAR szQuery[1024], *pszEscName, *pszEscDescr;
+   BOOL bExist;
+
+   Lock();
+
+   // Check if map record exist in database
+   _sntprintf(szQuery, 256, _T("SELECT map_id FROM maps WHERE map_id=%d"), m_dwMapId);
+   hResult = DBSelect(g_hCoreDB, szQuery);
+   if (hResult == NULL)
+      goto exit_save;
+
+   bExist = (DBGetNumRows(hResult) > 0);
+   DBFreeResult(hResult);
+
+   pszEscName = EncodeSQLString(m_pszName);
+   pszEscDescr = EncodeSQLString(m_pszDescription);
+   if (bExist)
+   {
+      _sntprintf(szQuery, 1024, _T("UPDATE maps SET map_name='%s',description='%s',root_object_id=%d WHERE map_id=%d"),
+                 pszEscName, pszEscDescr, m_dwObjectId, m_dwMapId);
+   }
+   else
+   {
+      _sntprintf(szQuery, 1024, _T("INSERT INTO maps (map_id,map_name,description,root_object_id) VALUES (%d,'%s','%s',%d)"),
+                 m_dwMapId, pszEscName, pszEscDescr, m_dwObjectId);
+   }
+   free(pszEscName);
+   free(pszEscDescr);
+   if (!DBQuery(g_hCoreDB, szQuery))
+      goto exit_save;
+
+   // Save ACL
+   _sntprintf(szQuery, 256, _T("DELETE FROM map_access_lists WHERE map_id=%d"), m_dwMapId);
+   if (!DBQuery(g_hCoreDB, szQuery))
+      goto exit_save;
+
+   for(i = 0; i < m_dwACLSize; i++)
+   {
+      _sntprintf(szQuery, 1024, _T("INSERT INTO map_access_lists (map_id,user_id,access_rights) VALUES (%d,%d,%d)"),
+                 m_dwMapId, m_pACL[i].dwUserId, m_pACL[i].dwAccess);
+      if (!DBQuery(g_hCoreDB, szQuery))
+         goto exit_save;
+   }
+
+   // Delete non-existing submaps
+   _sntprintf(szQuery, 1024, _T("SELECT submap_id FROM submaps WHERE map_id=%d"), m_dwMapId);
+   hResult = DBSelect(g_hCoreDB, szQuery);
+   if (hResult == NULL)
+      goto exit_save;
+   dwNumRows = DBGetNumRows(hResult);
+   for(i = 0; i < dwNumRows; i++)
+   {
+      dwId = DBGetFieldULong(hResult, i, 0);
+      if (!IsSubmapExist(dwId, FALSE))
+      {
+         _sntprintf(szQuery, 1024, _T("DELETE FROM submaps WHERE map_id=%d AND submap_id=%d"),
+                    m_dwMapId, dwId);
+         DBQuery(g_hCoreDB, szQuery);
+      }
+   }
+   DBFreeResult(hResult);
+
+   // Save submaps
+   _sntprintf(szQuery, 1024, _T("DELETE FROM submap_object_positions WHERE map_id=%d"), m_dwMapId);
+   DBQuery(g_hCoreDB, szQuery);
+
+   _sntprintf(szQuery, 1024, _T("DELETE FROM submap_links WHERE map_id=%d"), m_dwMapId);
+   DBQuery(g_hCoreDB, szQuery);
+
+   dwResult = RCC_SUCCESS;
+   for(i = 0; (i < m_dwNumSubmaps) && (dwResult == RCC_SUCCESS); i++)
+      dwResult = ((nxSubmapSrv *)m_ppSubmaps[i])->SaveToDB();
+
+exit_save:
+   Unlock();
+   return dwResult;
+}
+
+
 //
 // Common initialization for nxMapSrv constructors
 //
index dcd1844..608236c 100644 (file)
@@ -6522,7 +6522,7 @@ void ClientSession::SaveMap(CSCPMessage *pRequest)
 void ClientSession::ProcessSubmapData(CSCPMessage *pRequest)
 {
    CSCPMessage msg;
-   DWORD dwId;
+   DWORD dwId, dwResult;
    nxSubmapSrv *pSubmap;
    BOOL bSend = FALSE;
 
@@ -6540,9 +6540,10 @@ void ClientSession::ProcessSubmapData(CSCPMessage *pRequest)
       }
       if (pRequest->IsEndOfSequence())
       {
+         dwResult = m_pActiveMap->SaveToDB();
          m_pActiveMap->DecRefCount();
          m_dwFlags &= ~CSF_RECEIVING_MAP_DATA;
-         msg.SetVariable(VID_RCC, RCC_SUCCESS);
+         msg.SetVariable(VID_RCC, dwResult);
          bSend = TRUE;
       }
    }
index 4df8d81..1278a17 100644 (file)
@@ -68,9 +68,9 @@ BOOL CProcessingPage::OnInitDialog()
 
    // Create image list
    m_imageList.Create(16, 16, ILC_MASK | ILC_COLOR24, 4, 1);
-   m_imageList.Add(theApp.LoadIcon(IDI_RUNNING));
-   m_imageList.Add(theApp.LoadIcon(IDI_OK));
-   m_imageList.Add(theApp.LoadIcon(IDI_FAILED));
+   m_imageList.Add(appNxConfig.LoadIcon(IDI_RUNNING));
+   m_imageList.Add(appNxConfig.LoadIcon(IDI_OK));
+   m_imageList.Add(appNxConfig.LoadIcon(IDI_FAILED));
    m_wndListCtrl.SetImageList(&m_imageList, LVSIL_SMALL);
 
        return TRUE;
index 9fbfae7..5a9a68a 100644 (file)
@@ -49,7 +49,7 @@ CNxconfigApp::CNxconfigApp()
 /////////////////////////////////////////////////////////////////////////////
 // The one and only CNxconfigApp object
 
-CNxconfigApp theApp;
+CNxconfigApp appNxConfig;
 
 /////////////////////////////////////////////////////////////////////////////
 // CNxconfigApp initialization
index 74b2e54..985dba1 100644 (file)
@@ -134,7 +134,7 @@ BOOL ExecSQLBatch(DB_HANDLE hConn, TCHAR *pszFile);
 // Global variables
 //
 
-extern CNxconfigApp theApp;
+extern CNxconfigApp appNxConfig;
 extern TCHAR *g_pszDBEngines[];
 extern TCHAR g_szWizardErrorText[];