Ejemplo n.º 1
0
    def __init__(self, parent):
        self.testAlignObj = None

        FrameBase.__init__(self,
                           parent,
                           id=wx.ID_ANY,
                           title=u"test align gui",
                           pos=wx.DefaultPosition,
                           size=wx.Size(900, 600),
                           style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        bSizerFrameMain = wx.BoxSizer(wx.VERTICAL)

        self.panelMain = ScrolledPanelBase(self, wx.ID_ANY, wx.DefaultPosition,
                                           wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizerPanelMain = wx.BoxSizer(wx.VERTICAL)

        bSizerFile = wx.BoxSizer(wx.HORIZONTAL)

        self.staticTextFileNameRoot = wx.StaticText(self.panelMain, wx.ID_ANY,
                                                    u"File Name Root:",
                                                    wx.DefaultPosition,
                                                    wx.DefaultSize, 0)
        self.staticTextFileNameRoot.Wrap(-1)
        bSizerFile.Add(self.staticTextFileNameRoot, 0, wx.ALL, 5)

        self.textCtrlFileNameRoot = wx.TextCtrl(self.panelMain, wx.ID_ANY,
                                                u"ytesta", wx.DefaultPosition,
                                                wx.DefaultSize, 0)
        self.textCtrlFileNameRoot.SetMinSize(wx.Size(150, -1))

        bSizerFile.Add(self.textCtrlFileNameRoot, 0, wx.ALL, 5)

        self.staticTextExtension = wx.StaticText(self.panelMain, wx.ID_ANY,
                                                 u"Extension:",
                                                 wx.DefaultPosition,
                                                 wx.DefaultSize, 0)
        self.staticTextExtension.Wrap(-1)
        bSizerFile.Add(self.staticTextExtension, 0, wx.ALL, 5)

        self.textCtrlExtension = wx.TextCtrl(self.panelMain, wx.ID_ANY, u"dat",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        bSizerFile.Add(self.textCtrlExtension, 0, wx.ALL, 5)

        bSizerPanelMain.Add(bSizerFile, 0, wx.EXPAND, 5)

        bSizerMode = wx.BoxSizer(wx.HORIZONTAL)

        self.radioBoxModeChoices = [u"b", u"c", u"cghz", u"nocgh"]
        self.radioBoxMode = wx.RadioBox(self.panelMain, wx.ID_ANY, u"Mode",
                                        wx.DefaultPosition, wx.DefaultSize,
                                        self.radioBoxModeChoices, 1,
                                        wx.RA_SPECIFY_ROWS)
        self.radioBoxMode.SetSelection(0)
        bSizerMode.Add(self.radioBoxMode, 0, wx.ALL, 5)

        self.buttonFileUpdate = wx.Button(self.panelMain, wx.ID_ANY, u"UPDATE",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        bSizerMode.Add(self.buttonFileUpdate, 0, wx.ALL | wx.EXPAND, 5)

        self.textCtrlOutput = wx.TextCtrl(self.panelMain, wx.ID_ANY,
                                          wx.EmptyString, wx.DefaultPosition,
                                          wx.DefaultSize, 0)
        bSizerMode.Add(self.textCtrlOutput, 0, wx.ALL | wx.EXPAND, 5)

        self.buttonWriteReport = wx.Button(self.panelMain, wx.ID_ANY,
                                           u"Write Report", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        bSizerMode.Add(self.buttonWriteReport, 0, wx.ALL | wx.EXPAND, 5)

        bSizerPanelMain.Add(bSizerMode, 0, wx.EXPAND, 5)

        self.staticlineSep1 = wx.StaticLine(self.panelMain, wx.ID_ANY,
                                            wx.DefaultPosition, wx.DefaultSize,
                                            wx.LI_HORIZONTAL)
        bSizerPanelMain.Add(self.staticlineSep1, 0, wx.EXPAND | wx.ALL, 5)

        bSizerGrids = wx.BoxSizer(wx.HORIZONTAL)

        # Grid data
        dataLabels = [
            'Variables', 'Input Values (nm)', 'Residual Values (nm)', 'Weights'
        ]
        dataTypes = [
            gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_FLOAT + ':6,2',
            gridlib.GRID_VALUE_FLOAT + ':6,2',
            gridlib.GRID_VALUE_FLOAT + ':6,1'
        ]
        self.gridData1 = CustomDataGrid(self.panelMain, dataLabels, dataTypes)

        # Cell1 Defaults
        self.gridData1.SetDefaultCellFont(
            wx.Font(12, 70, 90, 90, False, wx.EmptyString))
        self.gridData1.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_TOP)
        bSizerGrids.Add(self.gridData1, 0, wx.ALL, 5)
        self.gridData1.Hide()

        self.staticlineGridSep = wx.StaticLine(self.panelMain, wx.ID_ANY,
                                               wx.DefaultPosition,
                                               wx.DefaultSize, wx.LI_VERTICAL)
        bSizerGrids.Add(self.staticlineGridSep, 0, wx.EXPAND | wx.ALL, 5)

        # Cell2 Defaults
        dataLabels = [
            'Compensator', 'Force', 'Solve Amount', 'Unit', 'Include Move',
            'Move Amount'
        ]
        dataTypes = [
            gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING,
            gridlib.GRID_VALUE_FLOAT + ':6,5', gridlib.GRID_VALUE_STRING,
            gridlib.GRID_VALUE_BOOL, gridlib.GRID_VALUE_FLOAT + ':6,5'
        ]
        self.gridData2 = CustomDataGrid(self.panelMain, dataLabels, dataTypes)

        self.gridData2.SetDefaultCellFont(
            wx.Font(12, 70, 90, 90, False, wx.EmptyString))
        self.gridData2.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_TOP)
        bSizerGrids.Add(self.gridData2, 0, wx.ALL, 5)
        self.gridData2.Hide()
        self.setupDataTable()

        bSizerPanelMain.Add(bSizerGrids, 1, wx.EXPAND, 5)

        self.staticlineSep2 = wx.StaticLine(self.panelMain, wx.ID_ANY,
                                            wx.DefaultPosition, wx.DefaultSize,
                                            wx.LI_HORIZONTAL)
        bSizerPanelMain.Add(self.staticlineSep2, 0, wx.EXPAND | wx.ALL, 5)

        bSizerControl = wx.BoxSizer(wx.HORIZONTAL)

        self.buttonSolve = wx.Button(self.panelMain, wx.ID_ANY, u"SOLVE",
                                     wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerControl.Add(self.buttonSolve, 1, wx.ALL | wx.EXPAND, 5)

        self.buttonMove = wx.Button(self.panelMain, wx.ID_ANY, u"MOVE",
                                    wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerControl.Add(self.buttonMove, 1, wx.ALL | wx.EXPAND, 5)

        bSizerPanelMain.Add(bSizerControl, 0, wx.EXPAND, 5)

        self.panelMain.SetSizer(bSizerPanelMain)
        self.panelMain.Layout()
        bSizerPanelMain.Fit(self.panelMain)
        bSizerFrameMain.Add(self.panelMain, 1, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(bSizerFrameMain)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.buttonFileUpdate.Bind(wx.EVT_BUTTON, self.onFileUpdate)
        self.buttonWriteReport.Bind(wx.EVT_BUTTON, self.onWriteReport)
        self.gridData1.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.onChangeParams)
        self.gridData2.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.onChangeParams)
        self.buttonSolve.Bind(wx.EVT_BUTTON, self.onSolve)
        self.buttonMove.Bind(wx.EVT_BUTTON, self.onMove)
Ejemplo n.º 2
0
class FrameMain(FrameBase):
    def __init__(self, parent):
        self.testAlignObj = None

        FrameBase.__init__(self,
                           parent,
                           id=wx.ID_ANY,
                           title=u"test align gui",
                           pos=wx.DefaultPosition,
                           size=wx.Size(900, 600),
                           style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        bSizerFrameMain = wx.BoxSizer(wx.VERTICAL)

        self.panelMain = ScrolledPanelBase(self, wx.ID_ANY, wx.DefaultPosition,
                                           wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizerPanelMain = wx.BoxSizer(wx.VERTICAL)

        bSizerFile = wx.BoxSizer(wx.HORIZONTAL)

        self.staticTextFileNameRoot = wx.StaticText(self.panelMain, wx.ID_ANY,
                                                    u"File Name Root:",
                                                    wx.DefaultPosition,
                                                    wx.DefaultSize, 0)
        self.staticTextFileNameRoot.Wrap(-1)
        bSizerFile.Add(self.staticTextFileNameRoot, 0, wx.ALL, 5)

        self.textCtrlFileNameRoot = wx.TextCtrl(self.panelMain, wx.ID_ANY,
                                                u"ytesta", wx.DefaultPosition,
                                                wx.DefaultSize, 0)
        self.textCtrlFileNameRoot.SetMinSize(wx.Size(150, -1))

        bSizerFile.Add(self.textCtrlFileNameRoot, 0, wx.ALL, 5)

        self.staticTextExtension = wx.StaticText(self.panelMain, wx.ID_ANY,
                                                 u"Extension:",
                                                 wx.DefaultPosition,
                                                 wx.DefaultSize, 0)
        self.staticTextExtension.Wrap(-1)
        bSizerFile.Add(self.staticTextExtension, 0, wx.ALL, 5)

        self.textCtrlExtension = wx.TextCtrl(self.panelMain, wx.ID_ANY, u"dat",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        bSizerFile.Add(self.textCtrlExtension, 0, wx.ALL, 5)

        bSizerPanelMain.Add(bSizerFile, 0, wx.EXPAND, 5)

        bSizerMode = wx.BoxSizer(wx.HORIZONTAL)

        self.radioBoxModeChoices = [u"b", u"c", u"cghz", u"nocgh"]
        self.radioBoxMode = wx.RadioBox(self.panelMain, wx.ID_ANY, u"Mode",
                                        wx.DefaultPosition, wx.DefaultSize,
                                        self.radioBoxModeChoices, 1,
                                        wx.RA_SPECIFY_ROWS)
        self.radioBoxMode.SetSelection(0)
        bSizerMode.Add(self.radioBoxMode, 0, wx.ALL, 5)

        self.buttonFileUpdate = wx.Button(self.panelMain, wx.ID_ANY, u"UPDATE",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        bSizerMode.Add(self.buttonFileUpdate, 0, wx.ALL | wx.EXPAND, 5)

        self.textCtrlOutput = wx.TextCtrl(self.panelMain, wx.ID_ANY,
                                          wx.EmptyString, wx.DefaultPosition,
                                          wx.DefaultSize, 0)
        bSizerMode.Add(self.textCtrlOutput, 0, wx.ALL | wx.EXPAND, 5)

        self.buttonWriteReport = wx.Button(self.panelMain, wx.ID_ANY,
                                           u"Write Report", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        bSizerMode.Add(self.buttonWriteReport, 0, wx.ALL | wx.EXPAND, 5)

        bSizerPanelMain.Add(bSizerMode, 0, wx.EXPAND, 5)

        self.staticlineSep1 = wx.StaticLine(self.panelMain, wx.ID_ANY,
                                            wx.DefaultPosition, wx.DefaultSize,
                                            wx.LI_HORIZONTAL)
        bSizerPanelMain.Add(self.staticlineSep1, 0, wx.EXPAND | wx.ALL, 5)

        bSizerGrids = wx.BoxSizer(wx.HORIZONTAL)

        # Grid data
        dataLabels = [
            'Variables', 'Input Values (nm)', 'Residual Values (nm)', 'Weights'
        ]
        dataTypes = [
            gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_FLOAT + ':6,2',
            gridlib.GRID_VALUE_FLOAT + ':6,2',
            gridlib.GRID_VALUE_FLOAT + ':6,1'
        ]
        self.gridData1 = CustomDataGrid(self.panelMain, dataLabels, dataTypes)

        # Cell1 Defaults
        self.gridData1.SetDefaultCellFont(
            wx.Font(12, 70, 90, 90, False, wx.EmptyString))
        self.gridData1.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_TOP)
        bSizerGrids.Add(self.gridData1, 0, wx.ALL, 5)
        self.gridData1.Hide()

        self.staticlineGridSep = wx.StaticLine(self.panelMain, wx.ID_ANY,
                                               wx.DefaultPosition,
                                               wx.DefaultSize, wx.LI_VERTICAL)
        bSizerGrids.Add(self.staticlineGridSep, 0, wx.EXPAND | wx.ALL, 5)

        # Cell2 Defaults
        dataLabels = [
            'Compensator', 'Force', 'Solve Amount', 'Unit', 'Include Move',
            'Move Amount'
        ]
        dataTypes = [
            gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING,
            gridlib.GRID_VALUE_FLOAT + ':6,5', gridlib.GRID_VALUE_STRING,
            gridlib.GRID_VALUE_BOOL, gridlib.GRID_VALUE_FLOAT + ':6,5'
        ]
        self.gridData2 = CustomDataGrid(self.panelMain, dataLabels, dataTypes)

        self.gridData2.SetDefaultCellFont(
            wx.Font(12, 70, 90, 90, False, wx.EmptyString))
        self.gridData2.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_TOP)
        bSizerGrids.Add(self.gridData2, 0, wx.ALL, 5)
        self.gridData2.Hide()
        self.setupDataTable()

        bSizerPanelMain.Add(bSizerGrids, 1, wx.EXPAND, 5)

        self.staticlineSep2 = wx.StaticLine(self.panelMain, wx.ID_ANY,
                                            wx.DefaultPosition, wx.DefaultSize,
                                            wx.LI_HORIZONTAL)
        bSizerPanelMain.Add(self.staticlineSep2, 0, wx.EXPAND | wx.ALL, 5)

        bSizerControl = wx.BoxSizer(wx.HORIZONTAL)

        self.buttonSolve = wx.Button(self.panelMain, wx.ID_ANY, u"SOLVE",
                                     wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerControl.Add(self.buttonSolve, 1, wx.ALL | wx.EXPAND, 5)

        self.buttonMove = wx.Button(self.panelMain, wx.ID_ANY, u"MOVE",
                                    wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerControl.Add(self.buttonMove, 1, wx.ALL | wx.EXPAND, 5)

        bSizerPanelMain.Add(bSizerControl, 0, wx.EXPAND, 5)

        self.panelMain.SetSizer(bSizerPanelMain)
        self.panelMain.Layout()
        bSizerPanelMain.Fit(self.panelMain)
        bSizerFrameMain.Add(self.panelMain, 1, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(bSizerFrameMain)
        self.Layout()

        self.Centre(wx.BOTH)

        # Connect Events
        self.buttonFileUpdate.Bind(wx.EVT_BUTTON, self.onFileUpdate)
        self.buttonWriteReport.Bind(wx.EVT_BUTTON, self.onWriteReport)
        self.gridData1.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.onChangeParams)
        self.gridData2.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.onChangeParams)
        self.buttonSolve.Bind(wx.EVT_BUTTON, self.onSolve)
        self.buttonMove.Bind(wx.EVT_BUTTON, self.onMove)

    def __del__(self):
        pass

    def setupDataTable(self):
        # formating the column sizes (for fitting labels)
        readonlyColAttr = gridlib.GridCellAttr()
        readonlyColAttr.SetReadOnly(True)
        readonly1Cols = [0, 1, 2]
        readonly2Cols = [0, 2, 3, 5]
        for col in readonly1Cols:
            self.gridData1.SetColAttr(col, readonlyColAttr)
        for col in readonly2Cols:
            self.gridData2.SetColAttr(col, readonlyColAttr)
        self.gridData1.SetRowLabelSize(1)
        self.gridData2.SetRowLabelSize(1)
        if self.testAlignObj == None:
            self.moveAmount = []
        else:
            self.moveAmount = [
                0.0 for i in range(len(self.testAlignObj.usedperts))
            ]  # reset moveAmount list
        self.refreshWidget(self.gridData1)
        self.refreshWidget(self.gridData2)

    def updateDataTable(self):
        for varInd in range(len(self.testAlignObj.allterms)):
            self.gridData1.SetCellValue(varInd, 0,
                                        self.testAlignObj.allterms[varInd])
            self.gridData1.SetCellValue(
                varInd, 1, self.testAlignObj.meas_variables[varInd])
            if self.testAlignObj.res == None:
                self.gridData1.SetCellValue(varInd, 2, 0.0)
            else:
                self.gridData1.SetCellValue(varInd, 2,
                                            self.testAlignObj.res[varInd])
            self.gridData1.SetCellValue(
                varInd, 3, float(self.testAlignObj.weights[varInd]))

        for cInd in range(len(self.testAlignObj.usedperts)):
            self.gridData2.SetCellValue(cInd, 0,
                                        self.testAlignObj.usedperts[cInd])
            self.gridData2.SetCellValue(cInd, 1,
                                        str(self.testAlignObj.force[cInd]))
            if self.testAlignObj.p == None:
                self.gridData2.SetCellValue(cInd, 2, 0.0)
            else:
                self.gridData2.SetCellValue(cInd, 2, self.testAlignObj.p[cInd])
            self.gridData2.SetCellValue(
                cInd, 3, self.testAlignObj.sens[
                    self.testAlignObj.usedperts[cInd]]['units'])
            if len(self.moveAmount) == 0 or self.moveAmount[cInd] == 0:
                self.gridData2.SetCellValue(cInd, 4, False)
            else:
                self.gridData2.SetCellValue(cInd, 4, True)
            # col 5, move_amount column
            if len(self.moveAmount) > 0:
                self.gridData2.SetCellValue(cInd, 5, self.moveAmount[cInd])
            else:
                self.gridData2.SetCellValue(cInd, 5, 0.0)

        self.gridData1.Show()
        self.gridData2.Show()
        self.gridData1.AutoSize()
        self.gridData2.AutoSize()
        self.refreshWidget(self.gridData1)
        self.refreshWidget(self.gridData2)

    # Virtual event handlers, overide them in your derived class
    def onFileUpdate(self, event):
        fileRoot = self.textCtrlFileNameRoot.GetValue()
        fileExt = self.textCtrlExtension.GetValue()
        modeSelect = self.radioBoxModeChoices[self.radioBoxMode.GetSelection()]
        if len(fileRoot) == 0 or len(fileExt) == 0:
            self.popErrorBox(
                'ERROR',
                'ERROR: file name root or file extension CANNOT be EMPTY!')
            return

        self.testAlignObj = testalign.TestAlign(force=modeSelect)
        self.testAlignObj.get_gsmeas_variables(fileRoot, fileExt)
        self.textCtrlOutput.SetValue(self.testAlignObj.writename)

        self.gridData1.ClearTable()  # clear before proceed.
        self.gridData2.ClearTable()  # clear.
        self.updateDataTable()
        self.setupDataTable()

    def onWriteReport(self, event):
        if self.testAlignObj != None:
            self.testAlignObj.write(self.textCtrlOutput.GetValue())

    def onChangeParams(self, event):
        row = event.GetRow()
        col = event.GetCol()

        if event.GetEventObject() == self.gridData1:  # update weights
            self.testAlignObj.weights[row] = self.gridData1.GetCellValue(
                row, col)
            self.testAlignObj.set_weights(self.testAlignObj.weights)
        else:
            if col == 1:  # update force
                forceData = self.gridData2.GetCellValue(row, col)
                if forceData == 'None':
                    forceData = None
                else:
                    forceData = float(forceData)
                self.testAlignObj.force[row] = forceData
                self.testAlignObj.set_force(self.testAlignObj.force)
            elif col == 4:  # update includes; moveAmount should be updated
                if self.gridData2.GetCellValue(row, col):
                    self.moveAmount[row] = -1 * self.gridData2.GetCellValue(
                        row, 2)
                    self.gridData2.SetReadOnly(row, 5,
                                               False)  # Edit ON for moveAmount
                    self.gridData2.SetCellValue(
                        row, 5,
                        self.moveAmount[row])  # Change the actual display
                else:
                    self.moveAmount[row] = 0.0
                    self.gridData2.SetReadOnly(row, 5,
                                               True)  # Edit OFF for moveAmount
                    self.gridData2.SetCellValue(
                        row, 5,
                        self.moveAmount[row])  # Change the actual display

            elif col == 5:
                self.moveAmount[row] = self.gridData2.GetCellValue(row, col)

        self.refreshWidget(self.gridData1)
        self.refreshWidget(self.gridData2)

    def onSolve(self, event):
        self.testAlignObj.solve()
        self.updateDataTable()
        event.Skip()

    def onMove(self, event):
        #self.testAlignObj.move_solve(exclude=self.excludeList)
        self.testAlignObj.move_solve2(self.moveAmount)
        self.updateDataTable()
        event.Skip()
Ejemplo n.º 3
0
    def __init__(self, parent, alignObj):
        self.alignObj = alignObj
        ScrolledPanelBase.__init__(self,
                                   parent,
                                   id=wx.ID_ANY,
                                   pos=wx.DefaultPosition,
                                   size=wx.DefaultSize,
                                   style=wx.TAB_TRAVERSAL)

        bSizerPanel = wx.BoxSizer(wx.VERTICAL)

        ##########################
        # Move Test panel title
        ##########################
        self.staticTextMoveTestTitle = wx.StaticText(
            self, wx.ID_ANY,
            u"Move Test (ID: " + self.alignObj.hexapodID + ")",
            wx.DefaultPosition, wx.DefaultSize, 0)
        self.staticTextMoveTestTitle.Wrap(-1)
        self.staticTextMoveTestTitle.SetFont(
            wx.Font(18, 70, 90, 92, False, wx.EmptyString))

        bSizerPanel.Add(self.staticTextMoveTestTitle, 0,
                        wx.ALIGN_CENTER | wx.ALL, 5)

        bSizerMoveGrid = wx.BoxSizer(wx.HORIZONTAL)

        ##########################
        # moveTest grid
        ##########################
        labels = [
            "Compensator", "POB Motion", "Solve Amounts", "Include", "Move",
            "Units"
        ]
        dataTypes = [
            gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING,
            gridlib.GRID_VALUE_FLOAT + ':6,9', gridlib.GRID_VALUE_BOOL,
            gridlib.GRID_VALUE_FLOAT + ':6,9', gridlib.GRID_VALUE_STRING
        ]
        self.moveTestGrid = CustomDataGrid(self, labels, dataTypes)
        self.updateMoveTestGrid()
        self.moveTestGrid.SetColLabelSize(30)
        self.moveTestGrid.SetColLabelAlignment(wx.ALIGN_CENTRE,
                                               wx.ALIGN_CENTRE)
        self.moveTestGrid.AutoSize()

        #####
        # Cell Attributes
        #####
        self.moveTestGrid.SetColReadOnly(0)
        self.moveTestGrid.SetColReadOnly(1)
        self.moveTestGrid.SetColReadOnly(2)
        self.moveTestGrid.SetColReadOnly(4)
        self.moveTestGrid.SetColReadOnly(5)

        bSizerMoveGrid.Add(self.moveTestGrid, 0, wx.ALL, 5)
        ########################################## END moveTestGrid ########################################

        bSizerMoveGridControl = wx.BoxSizer(wx.VERTICAL)

        self.buttonIncludeAll = wx.Button(self, wx.ID_ANY, u"Include All",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        bSizerMoveGridControl.Add(self.buttonIncludeAll, 0,
                                  wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.textCtrlFactor = wx.TextCtrl(self, wx.ID_ANY, u"0.5",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        bSizerMoveGridControl.Add(self.textCtrlFactor, 0, wx.ALL, 5)

        self.buttonFactor = wx.Button(self, wx.ID_ANY, u"Set Factor",
                                      wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerMoveGridControl.Add(self.buttonFactor, 0,
                                  wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        bSizerMoveGrid.Add(bSizerMoveGridControl, 0, wx.ALL, 5)

        bSizerPanel.Add(bSizerMoveGrid, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.buttonMove = wx.Button(self, wx.ID_ANY, u"MOVE",
                                    wx.DefaultPosition, wx.DefaultSize, 0)
        self.buttonMove.SetFont(wx.Font(14, 70, 90, 92, False, wx.EmptyString))
        if not HAS_POBTEST_MOD:
            self.buttonMove.SetToolTipString(
                u"Disabled due to \"pobtest module\" not found.")
            self.buttonMove.Enable(False)

        bSizerPanel.Add(self.buttonMove, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.SetSizer(bSizerPanel)
        self.Layout()

        # Connect Events
        self.moveTestGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
                               self.onMoveTestGridChange)
        self.buttonIncludeAll.Bind(wx.EVT_BUTTON, self.onInclude)
        self.buttonFactor.Bind(wx.EVT_BUTTON, self.onSetFactor)
        self.buttonMove.Bind(wx.EVT_BUTTON, self.onMove)
Ejemplo n.º 4
0
    def __init__(self, parent, alignObj, hexapodObj, actuator):
        self.alignObj = alignObj
        self.hexapodObj = hexapodObj
        self.currCapPos = numpy.zeros(6)
        self.homePositions = numpy.zeros(6)
        self.cap_change_amounts = numpy.zeros(6)
        HexapodActuatorWxScrolledPanel.__init__(self,
                                                parent,
                                                actuator,
                                                id=wx.ID_ANY,
                                                pos=wx.DefaultPosition,
                                                size=wx.DefaultSize,
                                                style=wx.TAB_TRAVERSAL)

        ##### Timers #####
        self.continuous_update_timer = wx.Timer(self, wx.NewId())
        ##################

        bSizerPanel = wx.BoxSizer(wx.HORIZONTAL)

        ############## Left Control Panel ###############
        bSizerLeftPanel = wx.BoxSizer(wx.VERTICAL)

        ### Display Title ###
        self.staticTextHexapodPositionsTitle = wx.StaticText(
            self, wx.ID_ANY,
            u"Hexapod Positions (ID: " + self.alignObj.hexapodID + ")",
            wx.DefaultPosition, wx.DefaultSize, 0)
        self.staticTextHexapodPositionsTitle.Wrap(-1)
        self.staticTextHexapodPositionsTitle.SetFont(
            wx.Font(18, 70, 90, 92, False, wx.EmptyString))

        bSizerLeftPanel.Add(self.staticTextHexapodPositionsTitle, 0,
                            wx.ALIGN_CENTER | wx.ALL, 5)

        ### positions and movement grid ###
        labels = [
            "Leg#", "Current Position (um)\nFrom Offset #1",
            "Offset Changes (um)\nMove", "Target Position (um)\nFrom Offset #1"
        ]
        datatypes = [
            gridlib.GRID_VALUE_NUMBER, gridlib.GRID_VALUE_FLOAT + ':6,3',
            gridlib.GRID_VALUE_FLOAT + ':6,3',
            gridlib.GRID_VALUE_FLOAT + ':6,3'
        ]
        self.gridPositions = CustomDataGrid(self, labels, datatypes)

        self.gridPositions.SetColLabelSize(30)
        self.gridPositions.AutoSize()

        ####################
        # Cell Attributes
        ####################
        self.gridPositions.SetColReadOnly(0)
        self.gridPositions.SetColReadOnly(1)
        self.gridPositions.SetColReadOnly(3)

        bSizerLeftPanel.Add(self.gridPositions, 1, wx.ALIGN_CENTER | wx.ALL, 5)

        notesString = \
      """
Notes:
A Positive Offset Change Move Causes:
    The leg length to increase
    The Cap Gauge gap to increase
    The Cap Gauge Voltage to decrease (Negative)
    The Motor to un-Screw from the flexure
    The M1 Mirror to translate -Z (down direction) 
"""
        self.staticTextNotes = wx.StaticText(self, wx.ID_ANY, notesString,
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.staticTextNotes.Wrap(-1)
        self.staticTextNotes.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        bSizerLeftPanel.Add(self.staticTextNotes, 0, wx.ALIGN_CENTER | wx.ALL,
                            5)

        ##### A spacer for the layout #####
        bSizerLeftPanel.AddSpacer((0, 0), 1, wx.EXPAND, 5)

        fgSizerControl = wx.FlexGridSizer(3, 2, 0, 0)
        fgSizerControl.SetFlexibleDirection(wx.HORIZONTAL)
        #fgSizerControl.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )

        self.buttonUpdatePositions = wx.Button(self, wx.ID_ANY,
                                               u"Update / Refresh",
                                               wx.DefaultPosition,
                                               wx.DefaultSize, 0)
        self.buttonUpdatePositions.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        fgSizerControl.Add(self.buttonUpdatePositions, 1,
                           wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.toggleBtnContinuousUpdates = wx.ToggleButton(
            self, wx.ID_ANY, u"Continuous Updates", wx.DefaultPosition,
            wx.DefaultSize, 0)
        self.toggleBtnContinuousUpdates.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        fgSizerControl.Add(self.toggleBtnContinuousUpdates, 0,
                           wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.buttonSaveOffsets = wx.Button(self, wx.ID_ANY, u"Save Offsets",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.buttonSaveOffsets.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        fgSizerControl.Add(self.buttonSaveOffsets, 1,
                           wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.buttonSelectOffsets = wx.Button(self, wx.ID_ANY,
                                             u"Select Offsets (0)",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.buttonSelectOffsets.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        fgSizerControl.Add(self.buttonSelectOffsets, 1,
                           wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.buttonBackToStart = wx.Button(self, wx.ID_ANY,
                                           u"Back To Home Offsets",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.buttonBackToStart.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        fgSizerControl.Add(self.buttonBackToStart, 1,
                           wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.buttonZeroChanges = wx.Button(self, wx.ID_ANY, u"Zero Changes",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.buttonZeroChanges.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        fgSizerControl.Add(self.buttonZeroChanges, 1,
                           wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        fgSizerControl.AddGrowableCol(0, 1)
        fgSizerControl.AddGrowableCol(1, 1)

        bSizerLeftPanel.Add(fgSizerControl, 0, wx.EXPAND, 5)

        bSizerPanel.Add(bSizerLeftPanel, 1, wx.EXPAND, 5)

        ################## Right Display Panel #################
        bSizerRightPanel = wx.BoxSizer(wx.VERTICAL)

        ##### setup canvas display for Cap Change ######
        self.figureCapChange = Figure()
        self.axesCapChange = self.figureCapChange.add_subplot(111)
        self.axesCapChange.grid(color='gray', linestyle='dashed')

        self.canvasCapChange = FigureCanvas(self, wx.ID_ANY,
                                            self.figureCapChange)
        bSizerRightPanel.Add(self.canvasCapChange, 1, wx.ALL | wx.EXPAND, 0)
        ################################################

        radioBoxCapChangeAlgoChoices = [u"Normal", u"Quick"]
        self.radioBoxCapChangeAlgo = wx.RadioBox(self, wx.ID_ANY,
                                                 u"Capgauge Change Algorithm",
                                                 wx.DefaultPosition,
                                                 wx.DefaultSize,
                                                 radioBoxCapChangeAlgoChoices,
                                                 1, wx.RA_SPECIFY_ROWS)
        self.radioBoxCapChangeAlgo.SetSelection(0)
        bSizerRightPanel.Add(self.radioBoxCapChangeAlgo, 0, wx.ALL, 5)

        bSizerRightControl = wx.BoxSizer(wx.HORIZONTAL)

        self.buttonCapgaugeChangePositions = wx.Button(
            self, wx.ID_ANY, u"Capgauge Change Positions", wx.DefaultPosition,
            wx.DefaultSize, 0)
        self.buttonCapgaugeChangePositions.SetFont(
            wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        bSizerRightControl.Add(self.buttonCapgaugeChangePositions, 1,
                               wx.ALIGN_CENTER | wx.ALL, 5)

        self.buttonStop = wx.Button(self, wx.ID_ANY, u"STOP",
                                    wx.DefaultPosition, wx.DefaultSize, 0)
        self.buttonStop.SetFont(wx.Font(12, 70, 90, 92, False, wx.EmptyString))
        bSizerRightControl.Add(self.buttonStop, 1, wx.ALIGN_CENTER | wx.ALL, 5)

        bSizerRightPanel.Add(bSizerRightControl, 0, wx.EXPAND, 5)

        bSizerPanel.Add(bSizerRightPanel, 1, wx.EXPAND, 5)

        self.SetSizer(bSizerPanel)
        self.Layout()

        # Connect Events
        self.gridPositions.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
                                self.onOffsetChanges)
        self.buttonUpdatePositions.Bind(wx.EVT_BUTTON, self.onUpdatePositions)
        self.toggleBtnContinuousUpdates.Bind(wx.EVT_TOGGLEBUTTON,
                                             self.onContinousUpdatesToggle)
        self.buttonSaveOffsets.Bind(wx.EVT_BUTTON, self.onSaveOffsets)
        self.buttonSelectOffsets.Bind(wx.EVT_BUTTON, self.onSelectOffsets)
        self.buttonBackToStart.Bind(wx.EVT_BUTTON, self.onBackToStart)
        self.buttonZeroChanges.Bind(wx.EVT_BUTTON, self.onZeroChanges)
        self.buttonCapgaugeChangePositions.Bind(wx.EVT_BUTTON,
                                                self.onCapChange)
        self.buttonStop.Bind(wx.EVT_BUTTON, self.onStop)
        self.Bind(wx.EVT_TIMER, self.onUpdatePositions,
                  self.continuous_update_timer)
        self.Bind(actuator_wx.EVT_ACTUATOR_DONE, self.onActuatorDoneEvent)

        # setup the home positions
        if self.hexapodObj == None:
            self.popAlertBox(
                "WARNING: hexapodObj is None.",
                "WARNING: hexapodObj is None. 'Hexapod Positions' display absolute capgauge readings."
            )
            print "WARNING: hexapodObj is None.", "WARNING: hexapodObj is None. 'Hexapod Positions' display absolute capgauge readings."
            self.buttonSelectOffsets.Enable(False)
            self.buttonBackToStart.Enable(False)
            self.buttonSaveOffsets.Enable(False)
        else:
            try:
                (dateObj, homePos,
                 comments) = self.hexapodObj.read_capGauge_file()
                self.homePositions = numpy.array(homePos)
            except IOError, e:
                self.popErrorBox(
                    "ERROR: Hexapod Home Positions ARE NOT SET.",
                    "ERROR: Hexapod home positions are not yet set. Please use the 'Rest Hexapod Initial Start Position' button in 'Input' tab to set home positions."
                )
                print "ERROR: Hexapod home positions are not yet set. Please use the 'Rest Hexapod Initial Start Position' button in 'Input' tab to set home positions, and then restart."
                self.buttonSelectOffsets.Enable(False)
                self.buttonBackToStart.Enable(False)
                self.buttonSaveOffsets.Enable(False)
Ejemplo n.º 5
0
class PanelMoveTest(ScrolledPanelBase):
    def __init__(self, parent, alignObj):
        self.alignObj = alignObj
        ScrolledPanelBase.__init__(self,
                                   parent,
                                   id=wx.ID_ANY,
                                   pos=wx.DefaultPosition,
                                   size=wx.DefaultSize,
                                   style=wx.TAB_TRAVERSAL)

        bSizerPanel = wx.BoxSizer(wx.VERTICAL)

        ##########################
        # Move Test panel title
        ##########################
        self.staticTextMoveTestTitle = wx.StaticText(
            self, wx.ID_ANY,
            u"Move Test (ID: " + self.alignObj.hexapodID + ")",
            wx.DefaultPosition, wx.DefaultSize, 0)
        self.staticTextMoveTestTitle.Wrap(-1)
        self.staticTextMoveTestTitle.SetFont(
            wx.Font(18, 70, 90, 92, False, wx.EmptyString))

        bSizerPanel.Add(self.staticTextMoveTestTitle, 0,
                        wx.ALIGN_CENTER | wx.ALL, 5)

        bSizerMoveGrid = wx.BoxSizer(wx.HORIZONTAL)

        ##########################
        # moveTest grid
        ##########################
        labels = [
            "Compensator", "POB Motion", "Solve Amounts", "Include", "Move",
            "Units"
        ]
        dataTypes = [
            gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_STRING,
            gridlib.GRID_VALUE_FLOAT + ':6,9', gridlib.GRID_VALUE_BOOL,
            gridlib.GRID_VALUE_FLOAT + ':6,9', gridlib.GRID_VALUE_STRING
        ]
        self.moveTestGrid = CustomDataGrid(self, labels, dataTypes)
        self.updateMoveTestGrid()
        self.moveTestGrid.SetColLabelSize(30)
        self.moveTestGrid.SetColLabelAlignment(wx.ALIGN_CENTRE,
                                               wx.ALIGN_CENTRE)
        self.moveTestGrid.AutoSize()

        #####
        # Cell Attributes
        #####
        self.moveTestGrid.SetColReadOnly(0)
        self.moveTestGrid.SetColReadOnly(1)
        self.moveTestGrid.SetColReadOnly(2)
        self.moveTestGrid.SetColReadOnly(4)
        self.moveTestGrid.SetColReadOnly(5)

        bSizerMoveGrid.Add(self.moveTestGrid, 0, wx.ALL, 5)
        ########################################## END moveTestGrid ########################################

        bSizerMoveGridControl = wx.BoxSizer(wx.VERTICAL)

        self.buttonIncludeAll = wx.Button(self, wx.ID_ANY, u"Include All",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        bSizerMoveGridControl.Add(self.buttonIncludeAll, 0,
                                  wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        self.textCtrlFactor = wx.TextCtrl(self, wx.ID_ANY, u"0.5",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        bSizerMoveGridControl.Add(self.textCtrlFactor, 0, wx.ALL, 5)

        self.buttonFactor = wx.Button(self, wx.ID_ANY, u"Set Factor",
                                      wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerMoveGridControl.Add(self.buttonFactor, 0,
                                  wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, 5)

        bSizerMoveGrid.Add(bSizerMoveGridControl, 0, wx.ALL, 5)

        bSizerPanel.Add(bSizerMoveGrid, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.buttonMove = wx.Button(self, wx.ID_ANY, u"MOVE",
                                    wx.DefaultPosition, wx.DefaultSize, 0)
        self.buttonMove.SetFont(wx.Font(14, 70, 90, 92, False, wx.EmptyString))
        if not HAS_POBTEST_MOD:
            self.buttonMove.SetToolTipString(
                u"Disabled due to \"pobtest module\" not found.")
            self.buttonMove.Enable(False)

        bSizerPanel.Add(self.buttonMove, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.SetSizer(bSizerPanel)
        self.Layout()

        # Connect Events
        self.moveTestGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
                               self.onMoveTestGridChange)
        self.buttonIncludeAll.Bind(wx.EVT_BUTTON, self.onInclude)
        self.buttonFactor.Bind(wx.EVT_BUTTON, self.onSetFactor)
        self.buttonMove.Bind(wx.EVT_BUTTON, self.onMove)

    def __del__(self):
        pass

    @handlesErrors
    def moveCompensators(self):
        """
        @Purpose:
            move the pob compensators; only gets call if pobtest module is presented.
            notes:
            RETRO:
                pobtest.retsphere.movex
                pobtest.retsphere.movey
                pobtest.retsphere.movez

            TRANS: (object)
                pobtest.tsxmotor.move
                pobtest.tsymotor.move
                pobtest.tszmotor.move
        """
        self.buttonMove.Enable(False)
        # functions corresponding to ordering: [xtrans_obj, ytrans_obj, ztrans_obj, xtran_retro, ytrans_retro, ztrans_retro]
        moveFuncts = [
            pobtest.tsxmotor.move, pobtest.tsymotor.move,
            pobtest.tszmotor.move, pobtest.retsphere.movex,
            pobtest.retsphere.movey, pobtest.retsphere.movez
        ]
        for ind in xrange(len(moveFuncts)):
            if self.moveTestGrid.GetCellValue(ind, 3):
                moveAmounts = self.moveTestGrid.GetCellValue(ind, 4)
                moveFuncts[ind](moveAmounts)
        self.getTopLevelWindow().statusBarMain.PulseStop()
        self.buttonMove.Enable(True)

    @handlesErrors
    def updateMoveTestGrid(self):
        """
        @Purpose:
            Initialize the moveTestGrid
        """
        XY_OBJECT_TO_RETRO_SCALE = -0.2
        compensators_map = {
            'xtrans_object': 'TS_X',
            'ytrans_object': 'TS_Y',
            'ztrans_object': 'TS_Z',
            'xtrans_retro': 'RET_X',
            'ytrans_retro': 'RET_Y',
            'ztrans_retro': 'RET_Z'
        }
        compensators = [
            'xtrans_object', 'ytrans_object', 'ztrans_object', 'xtrans_retro',
            'ytrans_retro', 'ztrans_retro'
        ]
        for ind in range(len(compensators)):
            self.moveTestGrid.SetCellValue(ind, 0,
                                           compensators[ind])  # compensators
            self.moveTestGrid.SetCellValue(ind, 1,
                                           compensators_map[compensators[ind]])
            try:
                comp_index = list(self.alignObj.usedperts).index(
                    compensators[ind])
                solve_amounts = self.alignObj.p_radians[comp_index]
                units = self.alignObj.units_radians[comp_index]
            except ValueError, e:
                if compensators[ind] == 'xtrans_retro':
                    solve_amounts = self.moveTestGrid.GetCellValue(
                        0, 2) * XY_OBJECT_TO_RETRO_SCALE
                    units = 'mm'
                elif compensators[ind] == 'ytrans_retro':
                    solve_amounts = self.moveTestGrid.GetCellValue(
                        1, 2) * XY_OBJECT_TO_RETRO_SCALE
                    units = 'mm'
                else:
                    raise e
            self.moveTestGrid.SetCellValue(ind, 2,
                                           solve_amounts)  # solve amounts
            self.moveTestGrid.SetCellValue(ind, 3, False)  # Include
            self.moveTestGrid.SetCellValue(ind, 4, 0.0)  # move (default = 0.0)
            self.moveTestGrid.SetCellValue(ind, 5, units)  # units
        self.refreshWidget(self.moveTestGrid)