C:/mesDocs/QT_confDbVis_canvas/mainPanel.py

Go to the documentation of this file.
00001 import time
00002 import os
00003 import string
00004 
00005 
00006 #from wxPython.wx import *
00007 from qt import *
00008 from GUImainPanel import *
00009 
00010 from cdbVisCore import *
00011 from objectclasses import *
00012 # from selectPanel import *
00013 from MiniatureWindow import *
00014 # from visWindow import *
00015 # from EnhancedStatusBar import *
00016 # from CreateDeviceType import *
00017 # from CreateDevice import *
00018 # from CreateLinkType import *
00019 # from CreateLink import *
00020 # from LogWindow import *
00021 # import helper
00022 
00023 ##########################################################################
00024 # Main Panel class
00025 ##########################################################################
00026 
00027 # Internal window IDs
00028 ID_SELECT_WINDOW = 5101
00029 ID_SELECT_SASH   = 5102
00030 ID_VIS_WINDOW    = 5103
00031 ID_WINDOW_LEFT1  = 5104
00032 ID_RIGHT_SASH = 5106
00033 ID_RIGHT_PANEL = 5107
00034 
00035 ##
00036 #  mainPanel contains the main panel within the main window
00037 #         It inherits from wxPanel as well as from dbUpdate, so that
00038 #         database changes are propagated to sub-windows.
00039 #     
00040 class mainPanel(GUImainPanel, dbUpdate): #(wxPanel, dbUpdate):
00041     
00042     ##
00043     #  Constructor.
00044     # 
00045     #             @parent - parent window (usually mainWindow)
00046     #             @id - window id set by parent
00047     #             @main - reference to the MainWindow instance
00048     #         
00049     def __init__(self,main = None,parent = None,name = None,modal = 0,fl = 0):
00050         GUImainPanel.__init__(self,main,parent,name)
00051         self.setOpaqueResize(True)
00052         self.main = main
00053         
00054         # Sash window events
00055         #SELECT SASH
00056 #         EVT_SASH_DRAGGED_RANGE(self, ID_SELECT_SASH, ID_SELECT_SASH, self.OnSashDrag)
00057         #RIGHT SASH
00058 #       EVT_SASH_DRAGGED_RANGE(self,ID_RIGHT_SASH,ID_RIGHT_SASH,self.OnSashDrag)
00059         #WINDOW SIZE, VISUAL AREA GETS IT ALL
00060 #         EVT_SIZE(self, self.OnSize)
00061 
00062         # Visualization window
00063 #         self.visWindow = visWindow(self, ID_VIS_WINDOW, self.main)
00064 #       self.visWindow.show()
00065         #make visWindow a dropable place for objects
00066 #       dt2 = helper.TextDropTarget(self.visWindow,self.main)
00067 #       self.visWindow.SetDropTarget(dt2)
00068         
00069         # Sashwindow to separate the two main windows (vis window and selection window)
00070 #         win = QWidget(self) # wxSashLayoutWindow(self, ID_SELECT_SASH, wxDefaultPosition, wxSize(200, 200), wxNO_BORDER | wxSW_3D)
00071 #         win.SetDefaultSize(wxSize(240, 1000))
00072 #         win.SetOrientation(wxLAYOUT_VERTICAL)
00073 #         win.SetAlignment(wxLAYOUT_LEFT)
00074 #         win.SetSashVisible(wxSASH_RIGHT, True)
00075 
00076         # selection-Window
00077 #         self.selectWindow = selectWindow(win, ID_SELECT_WINDOW, self.main) #win er eg. parent
00078 #         self.selectPanel = win
00079 
00080 #       self.areawindow = SystemWindow(self,self.main)
00081 
00082     ##
00083     #  Return reference to the ConfDB
00084     #   
00085     #   !return - reference to the ConfDB.
00086     #   
00087     def GetCdb(self):
00088         return self.GetParent().GetCdb() # same as self.main.GetCdb()
00089     
00090     ##
00091     #  Return the visual window instance
00092     #   
00093     #   !return - instance of the visual window
00094     #   
00095     def GetVisWindow(self):
00096         return self.visWindow
00097         
00098 
00099     ##
00100     #  Return the selection window instance
00101     #   
00102     #   !return - instance of the selection window
00103     #   
00104     def GetSelectWindow(self):
00105         return self.selectWindow
00106 
00107     ##
00108     #  Return the miniature window instance
00109     # 
00110     #   !return - instance of the miniature window
00111     #   
00112     def GetAreaWindow(self):
00113         return self.areawindow
00114 
00115     ##
00116     #  Close or open the miniature window.
00117     # 
00118     #   @close - True if the miniature window should be closed, False if it should be shown
00119     #   
00120     def CloseAreaWindow(self,close):
00121         
00122         if close:
00123             self.areawindow.Show(False)
00124             
00125         else:
00126             self.areawindow.Show(True)
00127 
00128     ##
00129     #  Inform other windows that the state of the database changed
00130     #             Inherited from dbUpdate interface class
00131     # 
00132     #       @evtReason - constant telling current state of ConfDB (DB_DISCONNECTED or DB_CONNECTED)
00133     #       @cdb - reference to the ConfDB class
00134     #         
00135     def OnDbUpdate(self, evtReason, cdb):
00136                 self.selectWindow.OnDbUpdate(evtReason, cdb)
00137                 self.visWindow.OnDbUpdate(evtReason, cdb)
00138 #               self.areawindow.OnDbUpdate(evtReason,cdb)
00139 
00140     ##
00141     #  When the sash between the visual window and the selection window is being dragged;
00142     #   the size of the two windows are being resized.
00143     #         
00144     def OnSashDrag(self, event):
00145 
00146         if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
00147             self.main.ShowError("The sash was dragged out of range.",ERR_ERROR)
00148             return False
00149 
00150         eID = event.GetId()
00151 
00152         if eID == ID_SELECT_SASH:
00153             self.selectPanel.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
00154             self.selectPanel.Refresh()
00155        
00156         #algorithm update 
00157         wxLayoutAlgorithm().LayoutWindow(self, self.visWindow)
00158         self.visWindow.Refresh()
00159        
00160 
00161     ##
00162     #  Resize the windows on resize event
00163     #             The visWindow should get all the space left.
00164     #         
00165     def OnSize(self, event):
00166 
00167         wxLayoutAlgorithm().LayoutWindow(self, self.visWindow)
00168         
00169         
00170 
00171 
00172 

Generated on Fri Aug 31 11:11:15 2007 for CDBVis by  doxygen 1.5.3