Public Member Functions | |
| def | __init__ |
| def | initializeThreads |
| Defines the GUI thread variables, and initialized the class' lock. | |
| def | hitTest |
| Performs a mouse hit test. | |
| def | setStatusBarText |
| Sets the status bar text. | |
| def | createMap |
| Creates a the actual Map which is displayed onto the main window (onto the canavas to be precise). | |
| def | recreateMap |
| Re-Creates the map. | |
| def | redrawCycle |
| Handles a redraw cycle. | |
| def | createPanel |
| Creates new Panel and adds it to the frame. | |
| def | doBindings |
| Binds all useful Mouse and sizing events to this frame. | |
| def | handleMonitorErrorCallback |
| Callback function used by the network monitor to report errors back the main window. | |
| def | handleStartMonitoring |
| "Start Monitoring" Button handler. | |
| def | handleStopMonitoring |
| "Stop Monitoring" Button handler. | |
| def | handleGoHome |
| "Go Home" Button handler. | |
| def | handlePan |
| "Pan" Button handler. | |
| def | handleFreeZoom |
| "Zoom" Button handler. | |
| def | handleZoomIn |
| "Zoom In" Button handler. | |
| def | handleZoomOut |
| "Zoom Out" Button handler. | |
| def | handleCaptureScreenshot |
| "Capture ScreenShot" Button handler. | |
| def | handleConfigureNetwork |
| "Configure Network" Button handler. | |
| def | handleSetHomeLocation |
| "Set Home Location" Button handler. | |
| def | handleOptions |
| "Options" Button handler. | |
| def | handleViewFilter |
| "View Filter" Button handler. | |
| def | handleDisplaySettings |
| "Display Settings" Button handler. | |
| def | handleShowAbout |
| "About" Button handler. | |
| def | handleExit |
| Exits the application. | |
| def | handleDisplayToolWindow |
| Displays the informational tooltip window once the mouse has paused over an Endpoint. | |
| def | createStatusBar |
| Creates a new Status Bar. | |
| def | startAllThreads |
| Starts all GUI Threads. | |
| def | stopAllThreads |
| Stops all GUI Threads. | |
| def | startRedrawthread |
| Starts the Redraw thread. | |
| def | stopRedrawThread |
| Stops the Redraw thread. | |
| def | redrawThreadIsRunning |
| Returns true if the redraw thread is already running. | |
| def | mouseHoverThreadIsRunning |
| Returns true if the Mouse Hover thread is already running. | |
| def | startMouseHoverThread |
| Starts the Mouse Hover Thread. | |
| def | stopMouseHoverThread |
| Stops the Mouse Hover Thread. | |
| def | popupMenuCallBack |
| Main message handler. | |
| def | redrawCanavasLock |
| Repaints the canavas. | |
| def | die |
| Displays an error message right before exiting the application. | |
| def | OnCloseWindow |
| cleanly shuts down the window and all of its threads. | |
| def | doNothing |
Public Attributes | |
| mainApp | |
| selectedNetworkDevice | |
| dispConf | |
| optConfig | |
| toolbarContainer | |
| rubber_start | |
| rubber_end | |
| lbuttonDown | |
| displayMode | |
| displayer | |
| cursor | |
| currentZoomLevel | |
| currentMousePosition | |
| lastMouseMoveTime | |
| numPeers | |
| numDisplayedPeers | |
| tipWin | |
| canDisplayTipWin | |
| PeerFilter | |
| isWindowMinimined | |
| figure | |
| Add matplotlib gui hooks. | |
| canavas | |
| rclickMenu | |
| animLoaderIcon | |
| lck | |
| autoRedrawThread | |
| make sure only one of these is running at a time | |
| mouseHoverThread | |
| make sure only one of these is running at a time | |
| panelSize | |
| entListSelection | |
| fig_axes | |
| worldMainMap | |
| sizer | |
| panel | |
| statusBar | |
This is where the action is. All event processing is managed from this class, and just about all gui components originate from here in one way or another.
Definition at line 97 of file mainFrame.py.
| def objects.gui.mainFrame.mainFrame.__init__ | ( | self, | ||
| parent, | ||||
| id, | ||||
| title, | ||||
| eyeSpyApp, | ||||
| displayConfig, | ||||
| appConfig, | ||||
color = None, |
||||
dpi = None, |
||||
style = wx.NO_FULL_REPAINT_ON_RESIZE, |
||||
| kwargs | ||||
| ) |
Definition at line 99 of file mainFrame.py.
00100 : 00101 00102 startupSplah = startupSplashScreen(None) 00103 00104 self.mainApp = eyeSpyApp 00105 self.selectedNetworkDevice = None 00106 00107 self.dispConf = displayConfig 00108 self.optConfig = appConfig 00109 00110 wx.Frame.__init__(self, parent, id, title) 00111 00112 # set the icon 00113 appIcon = wx.Icon(globalStrings.eyespy_icon, wx.BITMAP_TYPE_ICO) 00114 self.SetIcon(appIcon) 00115 00116 00117 try: 00118 #self.menuBarContainer = mainFrameMenuBar(self) 00119 self.toolbarContainer = mainFrameToolbar(self) 00120 self.createStatusBar() 00121 self.createPanel() 00122 except exception, e: 00123 startupSplah.Close() 00124 self.die(e.reason) 00125 return 00126 00127 #rubberbanding related 00128 self.rubber_start = wx.Point(0,0) 00129 self.rubber_end = wx.Point(0,0) 00130 00131 self.lbuttonDown = False 00132 00133 self.initializeThreads() 00134 00135 #display related 00136 self.displayMode = VIEW_STATE_ZOOM 00137 self.displayer = applicationEntityDisplayer(self.dispConf) 00138 00139 self.cursor = wx.StockCursor(wx.CURSOR_ARROW) 00140 00141 self.currentZoomLevel = None 00142 00143 # network device selection 00144 saveDeviceSelection = appConfig.network_getSaveDeviceSelection() 00145 00146 if saveDeviceSelection == True: 00147 self.selectedNetworkDevice = appConfig.network_getSelectedDevice() 00148 00149 00150 # Mouse events 00151 self.currentMousePosition = None 00152 self.lastMouseMoveTime = None 00153 00154 self.numPeers = 0 00155 self.numDisplayedPeers = 0 00156 00157 # tip window 00158 self.tipWin = None 00159 self.canDisplayTipWin = True 00160 00161 #filtering 00162 self.PeerFilter = customFilter() 00163 00164 # window message related 00165 self.isWindowMinimined = False 00166 00167 ## Add matplotlib gui hooks 00168 self.figure = Figure(None, dpi) 00169 self.canavas = NoRepaintCanvas(self.panel, -1, self.figure) 00170 00171 ## draw the initial plot 00172 self.createMap(self.dispConf.map_getMapDetail(), self.dispConf.map_getDrawCSBorders(), self.dispConf.map_getDrawRivers()) 00173 00174 ## Additional initialization 00175 self._resizeflag = True 00176 self._SetSize() 00177 00178 # right click menu 00179 self.rclickMenu = mainFramePopupMenu(self) 00180 00181 #bind events 00182 self.doBindings() 00183 00184 self.animLoaderIcon = animatedLoaderIcon(self.toolbarContainer.toolbar, globalStrings.animated_img_in_progress, (800 - 50,3)) 00185 00186 self.startMouseHoverThread() 00187 00188 startupSplah.Close() 00189 00190 self.redrawCycle() 00191 00192 00193 # as a final step, check to see if the GEO IP Database is installed. 00194 # If it is not, then output a warning 00195 # check to see if any GEO IP files need to be updated 00196 geoUtils = geoIPUtils("") 00197 if (geoUtils.isGEOIPDatabaseInstalled() == False): 00198 00199 msg = "EyeSpy makes use of a non free GEO IP Database which is not shipped with the application.\n\n" 00200 msg += "EyeSpy supports the MaxMind Database which is available by either purchasing a commercial license from MaxMind " 00201 msg += "or by downloading a free, personal use copy of it from their web site. Once downloaded, the database can be imported using EyeSpy's 'About' page.\n\n" 00202 00203 msg += "Although EyeSpy is a free application, usage of the GEO IP Database is still bound by MaxMind's terms.\n\n" 00204 00205 msg += "For additional Information, please visit EyeSpy's home page." 00206 msg += "\n\n" 00207 msg += "( " + self.optConfig.navigation_getAppHomePage() + " )" 00208 00209 dlg = wx.MessageDialog(None, msg, 'Please Note...', wx.ICON_WARNING) 00210 result = dlg.ShowModal() 00211 dlg.Destroy() 00212 00213 00214 ## Defines the GUI thread variables, and initialized the class' lock
| def objects.gui.mainFrame.mainFrame.createMap | ( | self, | ||
| mapDetail, | ||||
| drawCSBorders, | ||||
| drawRivers | ||||
| ) |
Creates a the actual Map which is displayed onto the main window (onto the canavas to be precise).
Note that all parameters are retrieved from the application configuration file.
| mapDetail | Map Detail Level | |
| drawCSBorders | True if the map should display country and state borders | |
| drawRivers | True if the map should display rivers |
Definition at line 588 of file mainFrame.py.
00588 : 00589 ax = self.figure.add_axes([0,0,0.99,0.99]) 00590 self.fig_axes = figureAxesWrapper(ax) 00591 self.fig_axes.axes.set_axis_bgcolor('aqua') 00592 00593 self.worldMainMap = mainFrameMap(self.fig_axes) 00594 self.worldMainMap.createMap(mapDetail, drawCSBorders, drawRivers) 00595 00596 # set initial zoom 00597 self.fig_axes.computeFullXYLim() 00598 self.fig_axes.resetZoom() 00599 00600 filter = baseFilter() 00601 self.currentZoomLevel = filter.getUserFriendlyZoomLevel(self.fig_axes.getZoomFactor()) 00602 00603 00604 ## Re-Creates the map. This is usually done right after some map setting is being changed (the app allows you to do this without restarting).
| def objects.gui.mainFrame.mainFrame.createPanel | ( | self | ) |
Creates new Panel and adds it to the frame.
Definition at line 707 of file mainFrame.py.
00707 : 00708 00709 self.sizer = wx.BoxSizer(wx.VERTICAL) 00710 self.SetSizer(self.sizer) 00711 self.SetSize( wx.Size( 800, 600 ) ) 00712 00713 self.Centre() 00714 00715 self.panel = wx.Panel(self) 00716 00717 self.sizer.Add(self.panel, 1, wx.EXPAND) 00718 self.Layout() 00719 00720 00721 ## Binds all useful Mouse and sizing events to this frame.
| def objects.gui.mainFrame.mainFrame.createStatusBar | ( | self | ) |
| def objects.gui.mainFrame.mainFrame.die | ( | self, | ||
| why | ||||
| ) |
Displays an error message right before exiting the application.
Used if something catastrophic happens during startup.
| why | Error String |
Definition at line 1341 of file mainFrame.py.
01341 : 01342 dlg = wx.MessageDialog(None, why, 'Error', wx.ICON_ERROR) 01343 result = dlg.ShowModal() 01344 dlg.Destroy() 01345 01346 self.stopAllThreads() 01347 self.Destroy() 01348 01349 ## cleanly shuts down the window and all of its threads.
| def objects.gui.mainFrame.mainFrame.doBindings | ( | self | ) |
Binds all useful Mouse and sizing events to this frame.
Definition at line 723 of file mainFrame.py.
00723 : 00724 00725 self.Bind(wx.EVT_SIZE, self._OnSize) 00726 self.Bind(wx.EVT_IDLE, self._OnIdle) 00727 00728 self.Bind(wx.EVT_ICONIZE, self._OnMinimize) 00729 00730 self.canavas.Bind(wx.EVT_LEFT_DOWN, self._OnLButtonDown) 00731 self.canavas.Bind(wx.EVT_MOUSEWHEEL, self._OnMouseWheel) 00732 00733 self.canavas.Bind(wx.EVT_LEFT_UP, self._OnLButtonUp) 00734 self.canavas.Bind(wx.EVT_RIGHT_UP, self._OnRButtonUp) 00735 self.canavas.Bind(wx.EVT_MOTION, self._OnMouseMove) 00736 00737 00738 self.Connect(-1, -1, EVT_DISPLAY_TOOLINFOWIN, self.handleDisplayToolWindow) 00739 00740 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) 00741 00742 ## Callback function used by the network monitor to report errors back the main window.
| def objects.gui.mainFrame.mainFrame.doNothing | ( | self | ) |
| def objects.gui.mainFrame.mainFrame.handleCaptureScreenshot | ( | self, | ||
| event | ||||
| ) |
"Capture ScreenShot" Button handler.
This button will allow the user to save a ScreenShot to a file.
| event | Standard wx.Button event |
Definition at line 895 of file mainFrame.py.
00895 : 00896 saveDlg = pictureSaverDialog(self, self.figure) 00897 00898 00899 ## "Configure Network" Button handler. Will invoke the Network Configuration window.
| def objects.gui.mainFrame.mainFrame.handleConfigureNetwork | ( | self, | ||
| event | ||||
| ) |
"Configure Network" Button handler.
Will invoke the Network Configuration window.
| event | Standard wx.Button event |
Definition at line 902 of file mainFrame.py.
00902 : 00903 try: 00904 devDict = self.mainApp.netMon.getDeviceProperties() 00905 except exception, e: 00906 dlg = wx.MessageDialog(None, e.reason, 'Error', wx.ICON_ERROR) 00907 result = dlg.ShowModal() 00908 dlg.Destroy() 00909 logger.log(__name__ + ": " + e.reason) 00910 else: 00911 try: 00912 self.optConfig.loadConfig() 00913 except Exception, e: 00914 errMsg = "There was an error reading the options configuration file\nAlthough you configuration will be restored all application options will be set to their starting values. \nThis is usually due to a missing or corrupt configuration file\n\nDetailed Error:\n%s " % (str(e)) 00915 00916 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 00917 result = dlg.ShowModal() 00918 dlg.Destroy() 00919 00920 try: 00921 netSettings = networkSettings(self, devDict) 00922 netSettings.loadConfig(self.optConfig) 00923 except Exception, ex: 00924 errMsg = "Could not display Network Settings window: %s" % (str(ex)) 00925 00926 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 00927 result = dlg.ShowModal() 00928 dlg.Destroy() 00929 return 00930 try: 00931 if netSettings.ShowModal() == wx.ID_OK: 00932 self.selectedNetworkDevice = netSettings.chosenDevice 00933 saveDeviceSelection = netSettings.saveSelection 00934 00935 self.optConfig.network_setSaveDeviceSelection(saveDeviceSelection) 00936 00937 if saveDeviceSelection == True: 00938 self.optConfig.network_setSelectedDevice(self.selectedNetworkDevice) 00939 00940 except Exception, e: 00941 errMsg = "Could not save network settings: %s" % (str(e)) 00942 00943 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 00944 result = dlg.ShowModal() 00945 dlg.Destroy() 00946 00947 finally: 00948 if netSettings != None: 00949 netSettings.Destroy() 00950 00951 00952 ## "Set Home Location" Button handler. Will Allow the user to pin a new Home Location onto the map using the mouse.
| def objects.gui.mainFrame.mainFrame.handleDisplaySettings | ( | self, | ||
| event | ||||
| ) |
"Display Settings" Button handler.
Will bring up the Display Settings window.
| event | Standard wx.Button event |
Definition at line 1049 of file mainFrame.py.
01049 : 01050 try: 01051 self.dispConf.loadConfig() 01052 except Exception, ex: 01053 errMsg = "There was an error reading the display settings configuration file\nAlthough you configuration will be restored all display settings parameters will be set to their starting values. \nThis is usually due to a missing or corrupt configuration file\n\nDetailed Error:\n%s " % (str(ex)) 01054 01055 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 01056 result = dlg.ShowModal() 01057 dlg.Destroy() 01058 01059 ds = None 01060 01061 try: 01062 ds = displaySettings(self) 01063 ds.loadConfiguration(self.dispConf) 01064 except Exception, e: 01065 errMsg = "There was an error opening Display Settings window.\nDetailed Error:\n%s" % (str(e)) 01066 01067 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 01068 result = dlg.ShowModal() 01069 dlg.Destroy() 01070 return 01071 try: 01072 if ds.ShowModal() == wx.ID_OK: 01073 # save settings back to INI file 01074 self.dispConf.glb_setMinXferOptions(ds.getGlbPeerXferOptions()) 01075 self.dispConf.glb_setMaxIdleOptions(ds.getGlbPeerIdleOptions()) 01076 01077 self.dispConf.glb_setLineOptions(ds.getGlbLineOptions()) 01078 self.dispConf.glb_setLabelOptions(ds.getGlbLabelOptions()) 01079 01080 self.dispConf.glb_setDisplayScale(ds.getGlbDisplayScale()) 01081 self.dispConf.glb_setRefreshRate(ds.getGlbRefreshRate()) 01082 self.dispConf.glb_setDisplayLabel(ds.getGlbDisplayLabel()) 01083 01084 self.dispConf.app_setProcessColorCodes(ds.getAppColorDict()) 01085 self.dispConf.app_setProcessDefaultColor(ds.getAppDefaultColor()) 01086 01087 if ds.refreshRateConfigChanged == True and self.redrawThreadIsRunning() == True: 01088 try: 01089 dlg = wx.MessageDialog(None, "Refresh Rate change will take effect once monitoring is restarted.", 'Info', wx.ICON_EXCLAMATION) 01090 dlg.ShowModal() 01091 finally: 01092 dlg.Destroy() 01093 01094 # map options 01095 self.dispConf.map_setMapDetail(ds.getMapDetailLevel()) 01096 self.dispConf.map_setDrawCSBorders(ds.getMapDrawCSBorders()) 01097 self.dispConf.map_setDrawRivers(ds.getMapDrawRivers()) 01098 01099 if ds.mapOptionsChanged: 01100 self.recreateMap(self.dispConf.map_getMapDetail(), self.dispConf.map_getDrawCSBorders(), self.dispConf.map_getDrawRivers()) 01101 01102 # force a draw cycle 01103 self.redrawCycle() 01104 except Exception, e: 01105 errMsg = "There was an error saving display settings.\nDetailed Error:\n%s " % (str(e)) 01106 01107 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 01108 result = dlg.ShowModal() 01109 dlg.Destroy() 01110 01111 finally: 01112 if ds is not None: ds.Destroy() 01113 01114 01115 ## "About" Button handler. Will bring up the application's About window.
| def objects.gui.mainFrame.mainFrame.handleDisplayToolWindow | ( | self, | ||
| event | ||||
| ) |
Displays the informational tooltip window once the mouse has paused over an Endpoint.
| event | Standard wx.Button event |
Definition at line 1134 of file mainFrame.py.
01134 : 01135 if self.canDisplayTipWin == False: return 01136 01137 entList = copy.deepcopy(event.entityList) 01138 01139 x,y = self.currentMousePosition.x, self.currentMousePosition.y 01140 01141 # tipwindow takes screen coordinates so we have to transform 01142 x,y=self.ClientToScreen((x,y)) 01143 01144 entList = copy.deepcopy(entList) 01145 01146 tipWin = mainFrameToolWindow(self, entList, x, y) 01147 01148 01149 01150 ## Creates a new Status Bar
| def objects.gui.mainFrame.mainFrame.handleExit | ( | self, | ||
| event | ||||
| ) |
Exits the application.
| event | Standard wx.Button event |
Definition at line 1127 of file mainFrame.py.
01127 : 01128 self.OnCloseWindow(event) 01129 01130 01131 ## Displays the informational tooltip window once the mouse has paused over an Endpoint.
| def objects.gui.mainFrame.mainFrame.handleFreeZoom | ( | self, | ||
| event | ||||
| ) |
"Zoom" Button handler.
This button will cause the cursor to go into "Zoom" mode.
| event | Standard wx.Button event |
Definition at line 859 of file mainFrame.py.
00859 : 00860 self.cursor = wx.StockCursor(wx.CURSOR_ARROW) 00861 self.displayMode = VIEW_STATE_ZOOM 00862 00863 self.canavas.SetCursor(self.cursor) 00864 00865 00866 ## "Zoom In" Button handler. This button will cause the map to Zoom in predefined amount.
| def objects.gui.mainFrame.mainFrame.handleGoHome | ( | self, | ||
| event | ||||
| ) |
"Go Home" Button handler.
This button will cause the map to zoom all the way out.
| event | Standard wx.Button event |
Definition at line 824 of file mainFrame.py.
00824 : 00825 # restore the ax postion I saved at creation time 00826 self.lck.acquire(1) 00827 try: 00828 self.fig_axes.resetZoom() 00829 finally: 00830 self.lck.release() 00831 00832 # redraw map points if zoom level has changed 00833 filter = baseFilter() 00834 newZoomLevel = filter.getUserFriendlyZoomLevel(self.fig_axes.getZoomFactor()) 00835 00836 if self.currentZoomLevel is not None and (self.currentZoomLevel != newZoomLevel): 00837 self.redrawCycle() 00838 00839 self.currentZoomLevel = newZoomLevel 00840 00841 00842 #redraw the canavas 00843 self.redrawCanavasLock() 00844 00845 00846
| def objects.gui.mainFrame.mainFrame.handleMonitorErrorCallback | ( | self, | ||
| errorMsg | ||||
| ) |
Callback function used by the network monitor to report errors back the main window.
This is used to to display messages in a Dialog box visible to the user.
| errorMsg | Error message String |
Definition at line 746 of file mainFrame.py.
00746 : 00747 self.handleStopMonitoring(None) 00748 00749 err = "There was an error monitoring the network. Monitoring will now stop:\n\n%s" % errorMsg 00750 dlg = wx.MessageDialog(None, err, 'Error', wx.ICON_ERROR) 00751 result = dlg.ShowModal() 00752 dlg.Destroy() 00753 00754 00755
| def objects.gui.mainFrame.mainFrame.handleOptions | ( | self, | ||
| event | ||||
| ) |
"Options" Button handler.
Will bring up the Options window.
| event | Standard wx.Button event |
Definition at line 966 of file mainFrame.py.
00966 : 00967 try: 00968 self.optConfig.loadConfig() 00969 except Exception, e: 00970 errMsg = "There was an error reading the options configuration file\nAlthough you configuration will be restored all application options will be set to their starting values. \nThis is usually due to a missing or corrupt configuration file\n\nDetailed Error:\n%s " % (str(e)) 00971 00972 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 00973 result = dlg.ShowModal() 00974 dlg.Destroy() 00975 00976 try: 00977 opt = appOptions(self, self.mainApp.entityMan.geoIP) 00978 opt.loadConfiguration(self.optConfig) 00979 except Exception, e: 00980 errMsg = "There was an error displaying application options%s" % (str(e)) 00981 00982 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 00983 result = dlg.ShowModal() 00984 dlg.Destroy() 00985 00986 return 00987 00988 try: 00989 if opt.ShowModal() == wx.ID_OK: 00990 # write values back to the registry 00991 if opt.ipAddrValid == True: 00992 self.optConfig.ident_setIPAddr(opt.getIPAddress()) 00993 self.optConfig.ident_setIPGeoInfo(opt.getIPGeoInfo()) 00994 00995 if opt.coordValid == True: 00996 self.optConfig.ident_setManualCoord(opt.getCoordinates()) 00997 00998 if opt.getIdentifyByIP() == True: 00999 self.optConfig.ident_setIdentByIPAddr() 01000 else: 01001 self.optConfig.ident_setIdentByCoord() 01002 01003 self.optConfig.ident_setConfigValid(opt.getConfigValid()) 01004 01005 self.optConfig.network_setRecordTraffic(opt.getNetworkRecordTraffic()) 01006 self.optConfig.network_setNeverStopRecording(opt.getNetworkUnlimitedCapture()) 01007 self.optConfig.network_setRecordingMaxLimit(opt.getNetworkMaxStorage()) 01008 01009 if opt.networkSettingsChanged == True and self.redrawThreadIsRunning() == True: 01010 try: 01011 dlg = wx.MessageDialog(None, "Network Settings will take effect when monitoring is restarted", 'Info', wx.ICON_EXCLAMATION) 01012 result = dlg.ShowModal() 01013 finally: 01014 dlg.Destroy() 01015 01016 # force a draw cycle 01017 self.redrawCycle() 01018 01019 except Exception, e: 01020 errMsg = "There was an error saving options.\nDetailed Error:\n%s " % (str(e)) 01021 01022 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR) 01023 result = dlg.ShowModal() 01024 dlg.Destroy() 01025 finally: 01026 if opt is not None: 01027 opt.Destroy() 01028 01029 01030
| def objects.gui.mainFrame.mainFrame.handlePan | ( | self, | ||
| event | ||||
| ) |
"Pan" Button handler.
This button will cause the cursor to go into "Pan" mode.
| event | Standard wx.Button event |
Definition at line 849 of file mainFrame.py.
00849 : 00850 self.displayMode = VIEW_STATE_PAN 00851 self.cursor = wx.StockCursor(wx.CURSOR_SIZING) 00852 00853 self.canavas.SetCursor(self.cursor) 00854 00855 00856 ## "Zoom" Button handler. This button will cause the cursor to go into "Zoom" mode.
| def objects.gui.mainFrame.mainFrame.handleSetHomeLocation | ( | self, | ||
| event | ||||
| ) |
"Set Home Location" Button handler.
Will Allow the user to pin a new Home Location onto the map using the mouse.
| event | Standard wx.Button event |
Definition at line 955 of file mainFrame.py.
00955 : 00956 self.cursor = wx.StockCursor(wx.CURSOR_BULLSEYE) 00957 self.canavas.SetCursor(self.cursor) 00958 00959 self.displayMode = VIEW_STATE_SETHOMELOC 00960 00961 00962 00963 ## "Options" Button handler. Will bring up the Options window.
| def objects.gui.mainFrame.mainFrame.handleShowAbout | ( | self, | ||
| event | ||||
| ) |
"About" Button handler.
Will bring up the application's About window.
| event | Standard wx.Button event |
Definition at line 1118 of file mainFrame.py.
01118 : 01119 aboutDlg = aboutDialog(self, self.optConfig) 01120 aboutDlg.ShowModal() 01121 aboutDlg.Destroy() 01122 01123 01124 ## Exits the application
| def objects.gui.mainFrame.mainFrame.handleStartMonitoring | ( | self, | ||
| event | ||||
| ) |
"Start Monitoring" Button handler.
This button is essentially what "starts" the application.
| event | Standard wx.Button event |
Definition at line 758 of file mainFrame.py.
00758 : 00759 if self.redrawThreadIsRunning(): 00760 return 00761 00762 if self.selectedNetworkDevice == None: 00763 00764 dlg = wx.MessageDialog(None, 'No network device was selected, would you like to choose one now?', 00765 'Please Confirm', wx.YES_NO | wx.ICON_QUESTION) 00766 result = dlg.ShowModal() 00767 dlg.Destroy() 00768 00769 if result == wx.ID_YES: 00770 self.handleConfigureNetwork(event) 00771 else: 00772 return 00773 00774 # the device may have been open since the user was given 00775 # a choice 00776 if self.selectedNetworkDevice != None: 00777 00778 # give the user the option of starting from scratch 00779 if self.mainApp.entityMan.getEntityCollectionSize() > 0: 00780 dlg = wx.MessageDialog(None, 'Would you like to clear all data before proceeing?', 00781 'Please Confirm', wx.YES_NO | wx.ICON_QUESTION) 00782 result = dlg.ShowModal() 00783 dlg.Destroy() 00784 00785 if result == wx.ID_YES: 00786 self.mainApp.entityMan.removeAllEntities() 00787 self.mainApp.initStorage(True, True) 00788 else: 00789 self.mainApp.initStorage(False, True) 00790 else: 00791 self.mainApp.initStorage(True, True) 00792 00793 try: 00794 self.mainApp.startStorageManager() 00795 00796 self.mainApp.netMon.networkIface.registerErrorCallBackFunc(self.handleMonitorErrorCallback) 00797 self.mainApp.netMon.startListening(self.selectedNetworkDevice) 00798 except exception, e: 00799 dlg = wx.MessageDialog(None, e.reason, 'Error', wx.ICON_ERROR) 00800 result = dlg.ShowModal() 00801 dlg.Destroy() 00802 else: 00803 # start the drawing Thread 00804 self.startRedrawthread() 00805 self.animLoaderIcon.play() 00806 00807 ## "Stop Monitoring" Button handler. This button will stop all networking activities.
| def objects.gui.mainFrame.mainFrame.handleStopMonitoring | ( | self, | ||
| event | ||||
| ) |
"Stop Monitoring" Button handler.
This button will stop all networking activities.
| event | Standard wx.Button event |
Definition at line 810 of file mainFrame.py.
00810 : 00811 00812 if self.selectedNetworkDevice != None: 00813 self.mainApp.shutdownStorage() 00814 self.mainApp.netMon.stopListening() 00815 00816 # stop the drawing Thread 00817 self.stopRedrawThread() 00818 self.animLoaderIcon.stop() 00819 00820 00821 ## "Go Home" Button handler. This button will cause the map to zoom all the way out.
| def objects.gui.mainFrame.mainFrame.handleViewFilter | ( | self, | ||
| event | ||||
| ) |
"View Filter" Button handler.
Will bring up "Filters" window.
| event | Standard wx.Button event |
Definition at line 1033 of file mainFrame.py.
01033 : 01034 fs = None 01035 01036 try: 01037 fs = filterSettings(self, self.PeerFilter) 01038 if fs.ShowModal() == wx.ID_OK: 01039 if fs.somethingRemoved == True: 01040 self.redrawCycle() 01041 01042 finally: 01043 if fs is not None: fs.Destroy() 01044 01045 01046 ## "Display Settings" Button handler. Will bring up the Display Settings window.
| def objects.gui.mainFrame.mainFrame.handleZoomIn | ( | self, | ||
| event | ||||
| ) |
"Zoom In" Button handler.
This button will cause the map to Zoom in predefined amount.
| event | Standard wx.Button event |
Definition at line 869 of file mainFrame.py.
00869 : 00870 self.lck.acquire(1) 00871 try: 00872 self.fig_axes.zoomIn(self.canavas.GetSize()) 00873 finally: 00874 self.lck.release() 00875 00876 self.redrawCanavasLock() 00877 00878 00879 ## "Zoom Out" Button handler. This button will cause the map to Zoom Out predefined amount.
| def objects.gui.mainFrame.mainFrame.handleZoomOut | ( | self, | ||
| event | ||||
| ) |
"Zoom Out" Button handler.
This button will cause the map to Zoom Out predefined amount.
| event | Standard wx.Button event |
Definition at line 882 of file mainFrame.py.
00882 : 00883 self.lck.acquire(1) 00884 try: 00885 self.fig_axes.zoomOut(self.canavas.GetSize()) 00886 finally: 00887 self.lck.release() 00888 00889 self.redrawCanavasLock() 00890 00891 00892 ## "Capture ScreenShot" Button handler. This button will allow the user to save a ScreenShot to a file.
| def objects.gui.mainFrame.mainFrame.hitTest | ( | self, | ||
| pos | ||||
| ) |
Performs a mouse hit test.
Given a mouse position it will either return nothing or it will return a list of networkEntityObjects representing the Endpoints below right under mouse This method is normally called when the mouseHoverThread detects that the mouse has stopped moving
| pos | Mouse Position object |
Definition at line 232 of file mainFrame.py.
00232 : 00233 entityDict = self.mainApp.entityMan.getSafeFilteredEntityCollectionByGeoLoc(None) 00234 00235 w_h = self.canavas.get_width_height() 00236 x,y = pos.x, w_h[1] - pos.y 00237 00238 #get zoom factor 00239 zoomFactor = self.fig_axes.getZoomFactor() 00240 00241 #get hit range factor 00242 hitRange = zoomFactor/90 #(90 is the magic number) 00243 00244 mouseMapX, mouseMapY = self.fig_axes.getAxesXYFromMouseXY( x, y) 00245 00246 for key, entList in entityDict.iteritems(): 00247 00248 entX, entY = self.worldMainMap.main_map(key[0], key[1]) 00249 00250 #get deltas 00251 deltaX = abs(entX - mouseMapX) 00252 deltaY = abs(entY - mouseMapY) 00253 00254 if (mouseMapX >= entX - hitRange and mouseMapX <= entX + hitRange): 00255 if (mouseMapY >= entY - hitRange and mouseMapY <= entY + hitRange): 00256 # hit 00257 return entList 00258 return None 00259 00260 00261
| def objects.gui.mainFrame.mainFrame.initializeThreads | ( | self | ) |
Defines the GUI thread variables, and initialized the class' lock.
Definition at line 216 of file mainFrame.py.
00216 : 00217 self.lck = RLock() 00218 00219 #Redraw Thread 00220 self.autoRedrawThread = None 00221 00222 #Mouse Hover Thread 00223 self.mouseHoverThread = None 00224 00225 00226 ## Performs a mouse hit test. Given a mouse position it will either return nothing
| def objects.gui.mainFrame.mainFrame.mouseHoverThreadIsRunning | ( | self | ) |
Returns true if the Mouse Hover thread is already running.
Definition at line 1222 of file mainFrame.py.
01222 : 01223 if self.mouseHoverThread != None and self.mouseHoverThread.isAlive() == True: 01224 return True 01225 else: 01226 return False 01227 01228 01229 ## Starts the Mouse Hover Thread
| def objects.gui.mainFrame.mainFrame.OnCloseWindow | ( | self, | ||
| event | ||||
| ) |
cleanly shuts down the window and all of its threads.
| event | Standard wx.Button event |
Definition at line 1352 of file mainFrame.py.
01352 : 01353 self.stopAllThreads() 01354 self.Destroy() 01355 01356 self.mainApp.shutdownStorage() 01357 self.mainApp.storage.deleteStorage() 01358
| def objects.gui.mainFrame.mainFrame.popupMenuCallBack | ( | self, | ||
| event | ||||
| ) |
Main message handler.
| event | Standard wx.Button event |
Definition at line 1263 of file mainFrame.py.
01263 : 01264 itemTuple = self.rclickMenu.getMenuItem(event.GetId()) 01265 01266 menuName, menuCat, menuParam = itemTuple 01267 01268 if menuCat == "DISPLAY_SETTING": 01269 self.handleDisplaySettings(event) 01270 01271 if menuCat == "SHOW_OPTIONS": 01272 self.handleOptions(None) 01273 01274 if menuCat == "VIEW_FILTERS": 01275 self.handleViewFilter(None) 01276 01277 if menuCat == "SHOWDETAILS": 01278 peerList = peerGridDisplay(self) 01279 peerList.fromEntList(self.entListSelection) 01280 peerList.Show(True) 01281 01282 if menuCat == "SHOWDETAILSVIS": 01283 entDict = self.mainApp.entityMan.getSafeFilteredEntityCollectionByGeoLoc(None) 01284 01285 peerList = peerGridDisplay(self) 01286 01287 peerList.fromEntGeoLocDict(entDict) 01288 peerList.Show(True) 01289 01290 if menuCat == "SHOWDETAILSALL": 01291 entDict = self.mainApp.entityMan.getSafeEntityCollectionByPK() 01292 01293 peerList = peerGridDisplay(self) 01294 peerList.fromEntDict(entDict) 01295 peerList.Show(True) 01296 01297 if menuCat == "FILTERITEM": 01298 self.PeerFilter.addToFilter(menuParam) 01299 self.redrawCycle() 01300 01301 if menuCat == "DISPLAY_TRACE": 01302 01303 # this list should be 1 by now, but check again 01304 if len(self.entListSelection) == 0: 01305 return 01306 01307 ent = self.entListSelection[0] 01308 01309 traceDisplay = traceDisplayDialog(self, ent.foreignIPAddress, ent.selfPort, ent.foreignPort) 01310 traceDisplay.ShowModal() 01311 01312 # ok to display tip window again 01313 self.canDisplayTipWin = True 01314 01315 01316 01317 01318 """ global redrawing functions
| def objects.gui.mainFrame.mainFrame.recreateMap | ( | self, | ||
| mapDetail, | ||||
| drawCSBorders, | ||||
| drawRivers | ||||
| ) |
Re-Creates the map.
This is usually done right after some map setting is being changed (the app allows you to do this without restarting).
| mapDetail | Map Detail Level | |
| drawCSBorders | True if the map should display country and state borders | |
| drawRivers | True if the map should display rivers |
Definition at line 609 of file mainFrame.py.
00609 : 00610 00611 recycleThreads = self.redrawThreadIsRunning() 00612 00613 popup = wx.SplashScreen(wx.Image(name = globalStrings.redraw_map_message).ConvertToBitmap(), 00614 wx.SPLASH_CENTRE_ON_SCREEN , -1, self) 00615 00616 if recycleThreads: 00617 self.stopAllThreads() 00618 else: 00619 self.stopMouseHoverThread() 00620 00621 xlim, ylim = self.fig_axes.getCurrentXYLim() 00622 self.figure.clear() 00623 del self.worldMainMap 00624 del self.fig_axes.axes 00625 del self.fig_axes 00626 00627 self.createMap(mapDetail, drawCSBorders, drawRivers) 00628 00629 self.fig_axes.computeFullXYLim() 00630 self.fig_axes.setCurrentXYLim(xlim, ylim) 00631 00632 if recycleThreads: 00633 self.startAllThreads() 00634 else: 00635 self.startMouseHoverThread() 00636 00637 popup.Close() 00638 00639 ## Handles a redraw cycle.
| def objects.gui.mainFrame.mainFrame.redrawCanavasLock | ( | self | ) |
| def objects.gui.mainFrame.mainFrame.redrawCycle | ( | self, | ||
userPriority = False | ||||
| ) |
Handles a redraw cycle.
redraws all map plots while keeping the background (map) intact.
| userPriority | True if the user is actively interacting with the screen (i.e zoom or pan), in which case, skip this cycle |
Definition at line 643 of file mainFrame.py.
00643 : 00644 # don't redraw if user is trying to interact with the screen. 00645 if userPriority == True and self.lbuttonDown == True: 00646 return 00647 00648 start = time.time() 00649 00650 #take care of a few things before getting lock 00651 00652 displayConfigIsGood = True 00653 00654 00655 try: 00656 self.dispConf.loadConfig() 00657 except Exception, ex: 00658 print "there was an exception loading the display configuration: " + str(ex) 00659 00660 self.PeerFilter.setFromDisplayConfig(self.dispConf, self.fig_axes.getZoomFactor()) 00661 00662 try: 00663 self.optConfig.loadConfig() 00664 except Exception, ex: 00665 print "there was an exception loading the display configuration: " + str(ex) 00666 00667 00668 homeLon, homeLat, locValid = self.optConfig.ident_getConfigCoordinates() 00669 00670 latitudes = list() 00671 longitudes= list() 00672 00673 entityDict = self.mainApp.entityMan.getSafeFilteredEntityCollectionByGeoLoc(self.PeerFilter) 00674 00675 showLines = self.PeerFilter.shouldDisplayLines() 00676 showLabels = self.PeerFilter.shouldDisplayLabels() 00677 00678 self.displayer.setDisplayConfigurator(self.dispConf) 00679 00680 00681 self.lck.acquire(1) 00682 try: 00683 00684 displayedItems = self.worldMainMap.draw(entityDict, self.displayer, 00685 showLines, showLabels, 00686 homeLon, homeLat) 00687 00688 self.canavas.draw() 00689 00690 self.numPeers = self.mainApp.entityMan.getEntityCollectionSize() 00691 self.numDisplayedPeers = displayedItems 00692 00693 except Exception, e: 00694 logger.log(__name__ + ": Exception during redraw cycle.") 00695 logger.log(e) 00696 finally: 00697 end = time.time() 00698 #print "Draw Cycle Time: %3.3f" % (end - start) 00699 self.lck.release() 00700 00701 self.setStatusBarText(self.currentMousePosition) 00702 00703 00704 00705
| def objects.gui.mainFrame.mainFrame.redrawThreadIsRunning | ( | self | ) |
Returns true if the redraw thread is already running.
Definition at line 1212 of file mainFrame.py.
01212 : 01213 if self.autoRedrawThread != None and self.autoRedrawThread.isAlive() == True: 01214 return True 01215 else: 01216 return False 01217 01218 01219 ## Returns true if the Mouse Hover thread is already running
| def objects.gui.mainFrame.mainFrame.setStatusBarText | ( | self, | ||
| pos | ||||
| ) |
Sets the status bar text.
| pos | Mouse position (use to mark the longitude/latitude coordinates). |
Definition at line 569 of file mainFrame.py.
00569 : 00570 if pos == None: return 00571 00572 filter = baseFilter() 00573 zoomLevel = filter.getUserFriendlyZoomLevel(self.fig_axes.getZoomFactor()) 00574 00575 w_h = self.canavas.get_width_height() 00576 x,y = pos.x, w_h[1] - pos.y 00577 lon, lat = self.fig_axes.getLonLatFromMouseXY(x,y, self.worldMainMap.main_map) 00578 statusText = "lon:%4.2f, lat:%4.2f -- Zoom: %s -- Tracking: %d Peers -- Displaying: %d Peers" % (lon, lat, zoomLevel, self.numPeers, self.numDisplayedPeers) 00579 self.statusBar.SetStatusText(statusText) 00580 00581 00582 ## Creates a the actual Map which is displayed onto the main window (onto the canavas to be precise).
| def objects.gui.mainFrame.mainFrame.startAllThreads | ( | self | ) |
Starts all GUI Threads.
Definition at line 1162 of file mainFrame.py.
01162 : 01163 self.stopRedrawThread() 01164 self.stopMouseHoverThread() 01165 01166 self.startRedrawthread() 01167 self.startMouseHoverThread() 01168 01169 01170 ## Stops all GUI Threads
| def objects.gui.mainFrame.mainFrame.startMouseHoverThread | ( | self | ) |
Starts the Mouse Hover Thread.
Definition at line 1231 of file mainFrame.py.
01231 : 01232 01233 if self.mouseHoverThreadIsRunning() == True: 01234 return 01235 01236 logger.log(__name__ + "Starting Mouse Hover Thread") 01237 ## make sure only one of these is running at a time 01238 01239 01240 self.mouseHoverThread = mouseHoverThread(self) 01241 self.mouseHoverThread.reset() 01242 01243 self.mouseHoverThread.start() 01244 01245 ## Stops the Mouse Hover Thread
| def objects.gui.mainFrame.mainFrame.startRedrawthread | ( | self | ) |
Starts the Redraw thread.
Definition at line 1179 of file mainFrame.py.
01179 : 01180 if self.redrawThreadIsRunning() == True: 01181 return 01182 01183 logger.log(__name__ + "Starting Redraw Thread") 01184 ## make sure only one of these is running at a time 01185 01186 self.autoRedrawThread = redrawThread(self) 01187 self.autoRedrawThread.reset() 01188 01189 # display 01190 refreshInterval = self.dispConf.glb_getRefreshRate() 01191 01192 self.autoRedrawThread.setRefreshInterval(refreshInterval) 01193 01194 01195 self.autoRedrawThread.start() 01196 01197 01198 ## Stops the Redraw thread
| def objects.gui.mainFrame.mainFrame.stopAllThreads | ( | self | ) |
Stops all GUI Threads.
Definition at line 1172 of file mainFrame.py.
01172 : 01173 self.stopRedrawThread() 01174 self.stopMouseHoverThread() 01175 01176 01177 ## Starts the Redraw thread
| def objects.gui.mainFrame.mainFrame.stopMouseHoverThread | ( | self | ) |
Stops the Mouse Hover Thread.
Definition at line 1247 of file mainFrame.py.
01247 : 01248 # should never time out, but you never know 01249 logger.log(__name__ + "Stopping Mouse Hover Thread") 01250 01251 # sometime if the app is closed, this object is destroyed 01252 # probably because of a bug... 01253 if (self.mouseHoverThread != None): 01254 self.mouseHoverThread.killSignalAndWait(10); 01255 01256 """ context menu related
| def objects.gui.mainFrame.mainFrame.stopRedrawThread | ( | self | ) |
Stops the Redraw thread.
Definition at line 1200 of file mainFrame.py.
01200 : 01201 # should never time out, but you never know 01202 logger.log(__name__ + ": Stopping Redraw Thread") 01203 01204 # sometime if the app is closed, this object is destroyed 01205 # probably because of a bug... 01206 if (self.redrawThreadIsRunning() == True): 01207 self.autoRedrawThread.killSignalAndWait(5) 01208 01209 ## Returns true if the redraw thread is already running
Definition at line 183 of file mainFrame.py.
Definition at line 168 of file mainFrame.py.
Definition at line 158 of file mainFrame.py.
Definition at line 150 of file mainFrame.py.
Definition at line 140 of file mainFrame.py.
Definition at line 138 of file mainFrame.py.
Definition at line 106 of file mainFrame.py.
Definition at line 136 of file mainFrame.py.
Definition at line 135 of file mainFrame.py.
Definition at line 530 of file mainFrame.py.
Definition at line 590 of file mainFrame.py.
Definition at line 164 of file mainFrame.py.
Definition at line 151 of file mainFrame.py.
Definition at line 130 of file mainFrame.py.
Definition at line 217 of file mainFrame.py.
Definition at line 103 of file mainFrame.py.
Definition at line 154 of file mainFrame.py.
Definition at line 153 of file mainFrame.py.
Definition at line 107 of file mainFrame.py.
Definition at line 715 of file mainFrame.py.
Definition at line 268 of file mainFrame.py.
Definition at line 161 of file mainFrame.py.
Definition at line 178 of file mainFrame.py.
Definition at line 128 of file mainFrame.py.
Definition at line 127 of file mainFrame.py.
Definition at line 104 of file mainFrame.py.
Definition at line 709 of file mainFrame.py.
Definition at line 1153 of file mainFrame.py.
Definition at line 157 of file mainFrame.py.
Definition at line 118 of file mainFrame.py.
Definition at line 593 of file mainFrame.py.
1.5.8