示例#1
0
    def showContextMenu(self, pos):
        item = self.itemAt(pos)
        menu = QMenu()
        it = QTreeWidgetItem.UserType + 1
        if item.type() == it:
            HelperMethods.addActions(menu, self.actionDeleteObject)
            self.index = item.parent().indexOfChild(item)

        menu.exec_(self.mapToGlobal(pos))
    def simulationToolBar(self, numWidgets):

        if not hasattr(self, 'SimToolBar'):
            self.SimToolBar = QToolBar(self.tr("Simulation Tools"))
            self.SimToolBar.setObjectName("SimToolBar")
            self.SimToolBar.setAllowedAreas(
                Qt.TopToolBarArea | Qt.BottomToolBarArea | Qt.LeftToolBarArea | Qt.RightToolBarArea)

        self.SimToolBar.clear()
        HelperMethods.addActions(self.SimToolBar, self.simulationMenuActions[0:numWidgets])
        self.addToolBar(Qt.TopToolBarArea, self.SimToolBar)
示例#3
0
    def fileNew(self):

        if not self.okToContinue():
            return

        fname = managerFile.fileNew(self.filename)

        if fname:
            HelperMethods.setEnabled(self.fileMenuActions[2:4], True)
            self.filename = fname
            self.dirty = True
            self.setTitle(fname)
            self.newSim()
示例#4
0
    def loadFile(self, fname=None):

        if fname is None:
            action = self.sender()
            if isinstance(action, QAction):
                fname = action.data()
                if not self.okToContinue():
                    return
            else:
                return

        if fname:
            self.filename = None
            self.addRecentFile(fname)
            self.filename = fname
            self.dirty = False
            HelperMethods.setEnabled(self.fileMenuActions[2:4], True)
            self.setTitle(fname)
            self.openSim()
    def geometryToolBar(self, reset=False, LoadImage=False):
        if not hasattr(self, 'GeometryToolBar'):
            self.GeometryToolBar = QToolBar(self.tr("Geometry Tools"))
            self.GeometryToolBar.setObjectName("GeometryToolBar")
            self.GeometryToolBar.setAllowedAreas(
                Qt.TopToolBarArea | Qt.BottomToolBarArea | Qt.LeftToolBarArea | Qt.RightToolBarArea)

        self.GeometryToolBar.clear()
        if LoadImage:
            HelperMethods.addActions(self.GeometryToolBar, self.geometryMenuActions[4])
            self.addToolBar(Qt.RightToolBarArea, self.GeometryToolBar)
            return

        if reset:
            return
        else:
            HelperMethods.addActions(self.GeometryToolBar, self.geometryMenuActions[2:])
            # self.addToolBarBreak(Qt.TopToolBarArea)
            self.addToolBar(Qt.RightToolBarArea, self.GeometryToolBar)
示例#6
0
    def updateFileMenu(self):

        self.menuFile.clear()
        HelperMethods.addActions(self.menuFile, self.fileMenuActions[0:-2])
        current = self.filename if self.filename is not None else None
        recentFiles = []

        for fname in self.recentFiles:
            if fname != current and QFile.exists(fname):
                recentFiles.append(fname)
        if recentFiles:
            self.menuFile.addSeparator()
            for i, fname in enumerate(recentFiles):
                action = QAction(
                    QIcon(":/logo_SimNDT.png"),
                    "&%d %s" % (i + 1, QFileInfo(fname).fileName()), self)
                action.setData(fname)
                self.connect(action, SIGNAL("triggered()"), self.loadFile)
                self.menuFile.addAction(action)

        self.menuFile.addSeparator()
        self.menuFile.addAction(self.fileMenuActions[-2])
        self.menuFile.addAction(self.fileMenuActions[-1])
示例#7
0
    def newSim(self):

        self.initSim()

        self.simulationToolBar(1)
        self.geometryToolBar(reset=True)

        HelperMethods.setEnabled(self.menuNew_Simulation_Scenario, True)
        HelperMethods.setEnabled(self.geometryMenuActions[0], True)
        HelperMethods.setEnabled(self.geometryMenuActions[4], True)

        # Show loadImage in Geometric Toolbar
        self.geometryToolBar(LoadImage=True)
        self.updateUI()
示例#8
0
    def __init__(self, parent=None):

        super(TreeWidget, self).__init__(parent)

        self.setGeometry(QRect(0, 0, 350, 840))
        self.setHeaderLabels(["", ""])
        self.setMaximumWidth(450)
        self.setMinimumWidth(150)
        # self.setRootIsDecorated(True)
        self.setAlternatingRowColors(True)
        self.setColumnCount(2)
        self.header().resizeSection(0, 200)

        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showContextMenu)

        self.actionDeleteObject = HelperMethods.createAction(
            self,
            "Delete Selected Object",
            self.deleteObject,
            icon="delete.png")

        self.deleteDone = MySignal()
    def runEngine(self, isView=False, isReceiverPlot=False):

        self.dirty = True

        self.menuFile.menuAction().setEnabled(False)
        self.menuConfiguration.menuAction().setEnabled(False)
        self.menuPlotting_Tools.menuAction().setEnabled(False)
        self.menuTools.menuAction().setEnabled(False)
        HelperMethods.setEnabled(self.fileMenuActions, False)
        HelperMethods.setEnabled(self.geometryMenuActions, False)
        HelperMethods.setEnabled(self.inspectionMenuActions, False)
        HelperMethods.setEnabled(self.simulationMenuActions, False)

        self.statusBarWidget.startSimulation(self.SimNDT_Simulation.TimeSteps)

        if isView:
            self.statusBarWidget.viewOn()
        else:
            self.statusBarWidget.updateGeometryFrame()

        simPack = SimPack(self.SimNDT_Scenario, self.SimNDT_Materials,
                          self.SimNDT_Boundaries, self.SimNDT_Inspection,
                          self.SimNDT_Source, self.SimNDT_Transducers,
                          self.SimNDT_Signal, self.SimNDT_Simulation)

        engine = EngineController(simPack, isView, isReceiverPlot,
                                  self.statusBarWidget, self)

        state = engine.run()

        self.statusBarWidget.endSimulation()

        self.PauseSimulation = False

        if state == "Stop":
            self.StopSimulation = False
            self.status.showMessage("Stop by User!!!!!", 15000)
            message = WarningParms("Stop by User!!!")
            message.exec_()
        else:
            self.status.showMessage("Done", 15000)
            message = DoneParms()
            message.exec_()

        self.menuFile.menuAction().setEnabled(True)
        self.menuConfiguration.menuAction().setEnabled(True)
        self.menuPlotting_Tools.menuAction().setEnabled(True)
        self.menuTools.menuAction().setEnabled(True)
        HelperMethods.setEnabled(self.fileMenuActions, True)
        HelperMethods.setEnabled(self.geometryMenuActions, True)
        HelperMethods.setEnabled(self.inspectionMenuActions, True)
        HelperMethods.setEnabled(self.simulationMenuActions, True)

        self.setPlotInspectionsMenu()
        self.SimNDT_Receivers = Receivers(self.SimNDT_Inspection.Name)
        self.SimNDT_Receivers.setReceivers(engine)
示例#10
0
    def updateUI(self):

        if self.SimNDT_Scenario is not None:

            try:
                self.GraphicView.imshow(self.SimNDT_Scenario.I)

            except Exception as e:
                msgBox = WarningParms(
                    "Unable to display GRAPHICS!!!. Incompatible Graphic Card, %s"
                    % e)
                if msgBox.exec_():
                    sys.exit()

            HelperMethods.setEnabled(self.menuNew_Simulation_Scenario, True)
            HelperMethods.setEnabled(self.fileMenuActions[2:5], True)
            HelperMethods.setEnabled(self.geometryMenuActions[0:], True)
            HelperMethods.setEnabled(self.configurationMenuActions[0], True)

            self.addDockWidget(Qt.LeftDockWidgetArea, self.treeDockWidget)
            self.treeDockWidget.show()

            self.geometryToolBar()
            self.simulationToolBar(2)
            self.statusBarWidget.zoomSpinBox.setVisible(True)

        if self.SimNDT_Materials is not None:
            HelperMethods.setEnabled(self.configurationMenuActions[1], True)
            self.simulationToolBar(3)

        if self.SimNDT_Boundaries is not None:

            if np.size(self.SimNDT_Scenario.Iabs) == 1:
                self.GraphicView.imshow(self.SimNDT_Scenario.I)
            else:
                self.GraphicView.imshow(self.SimNDT_Scenario.Iabs)
            HelperMethods.setEnabled(self.menuInspection_Setup, True)
            HelperMethods.setEnabled(self.inspectionMenuActions[:], True)
            self.simulationToolBar(6)

        if self.SimNDT_Inspection is not None:
            HelperMethods.setEnabled(self.simulationMenuActions[6], True)
            self.simulationToolBar(7)

        if self.SimNDT_Simulation is not None:
            HelperMethods.setEnabled(self.simulationMenuActions[7], True)
            self.simulationToolBar(8)

        if self.SimNDT_Check:
            HelperMethods.setEnabled(self.actionRun_Simulation, True)
            if not self.OpenSimFile:
                self.simulationToolBar(9)

        self.treeWidget.update(self.SimNDT_Scenario, self.SimNDT_ObjectList,
                               self.SimNDT_Materials, self.SimNDT_Boundaries,
                               self.SimNDT_Inspection, self.SimNDT_Source,
                               self.SimNDT_Transducers, self.SimNDT_Signal,
                               self.SimNDT_Simulation)
示例#11
0
    def setPlotInspectionsMenu(self):

        HelperMethods.setEnabled(self.actionPlot_Receiver_Signals_SingleLaunch,
                                 False)
        HelperMethods.setEnabled(self.actionPlot_Receiver_Signals_Spectra,
                                 False)

        HelperMethods.setEnabled(self.actionPlot_Receivers_Signals_LinearScan,
                                 False)
        HelperMethods.setEnabled(self.actionPlot_Receivers_Signals_Tomography,
                                 False)

        Name = self.SimNDT_Inspection.Name
        if Name == "Transmission" or Name == "PulseEcho":
            self.menuPlotting_Tools.menuAction().setVisible(True)
            HelperMethods.setEnabled(
                self.actionPlot_Receiver_Signals_SingleLaunch, True)
        elif Name == "LinearScan":
            self.menuPlotting_Tools.menuAction().setVisible(True)
            HelperMethods.setEnabled(
                self.actionPlot_Receivers_Signals_LinearScan, True)
        elif Name == 'Tomography':
            self.menuPlotting_Tools.menuAction().setVisible(True)
            HelperMethods.setEnabled(
                self.actionPlot_Receivers_Signals_Tomography, True)
示例#12
0
    def openSim(self):
        data2load = {}
        data2load = loadmat(self.filename,
                            squeeze_me=True,
                            struct_as_record=False)

        self.OpenSimFile = True
        if "Info" in data2load:
            self.SimNDT_Info = HelperMethods.mat2Obj(data2load["Info"], Info())

        if "Scenario" in data2load:
            Width = getattr(data2load["Scenario"], 'Width')
            Height = getattr(data2load["Scenario"], 'Height')
            Pixel_mm = getattr(data2load["Scenario"], 'Pixel_mm')
            Label = getattr(data2load["Scenario"], 'Label')
            self.SimNDT_Scenario = Scenario(Width=Width,
                                            Height=Height,
                                            Pixel_mm=Pixel_mm,
                                            Label=Label)
            self.SimNDT_Scenario = HelperMethods.mat2Obj(
                data2load["Scenario"], self.SimNDT_Scenario)

        self.SimNDT_Materials = HelperMethods.loadDataFromList(
            data2load, 'Materials', Material())
        self.SimNDT_Boundaries = HelperMethods.loadDataFromList(
            data2load, "Boundaries", Boundary())
        self.SimNDT_Transducers = HelperMethods.loadDataFromList(
            data2load, "Transducers", Transducer())

        geoLabels = ["ellipse", "circle", "square", "rectangle"]
        geoObjects = [Ellipse(), Circle(), Square(), Rectangle()]
        self.SimNDT_ObjectList = HelperMethods.loadDataFromListWithLabels(
            data2load, 'GeometricObjects', geoLabels, geoObjects)

        ConcreteLabels = [
            "Concrete2Phase", "Concrete2PhaseImmersion", "Concrete3Phase",
            "Concrete3PhaseImmersion"
        ]
        ConcreteObjects = [
            Concrete2Phase(),
            Concrete2PhaseImmersion(),
            Concrete3Phase(),
            Concrete3PhaseImmersion()
        ]

        if "ConcreteMicrostructure" in data2load:
            self.SimNDT_ConcreteMicrostructure = HelperMethods.loadDataWithLabels(
                data2load, 'ConcreteMicrostructure', ConcreteLabels,
                ConcreteObjects)

        if "Inspection" in data2load:
            inspLabels = [
                'Transmission', 'PulseEcho', 'LinearScan', 'Tomography'
            ]
            inspObjects = [
                Transmission(),
                PulseEcho(),
                LinearScan(),
                Tomography()
            ]
            self.SimNDT_Inspection = HelperMethods.loadDataWithLabels(
                data2load, "Inspection", inspLabels, inspObjects)

        if "Source" in data2load:
            self.SimNDT_Source = HelperMethods.mat2Obj(data2load["Source"],
                                                       Source())

        if "Signal" in data2load:
            self.SimNDT_Signal = HelperMethods.mat2Obj(data2load["Signal"],
                                                       Signals())

        if "Simulation" in data2load:
            self.SimNDT_Simulation = HelperMethods.mat2Obj(
                data2load["Simulation"], Simulation())

        if "Receivers" in data2load:
            self.SimNDT_Receivers = HelperMethods.mat2Obj(
                data2load["Receivers"], Receivers())

            self.setPlotInspectionsMenu()

        self.updateUI()
示例#13
0
    def createToolBar(self):

        self.fileToolBar = self.addToolBar("File Tools")
        self.fileToolBar.setObjectName("FileToolBar")
        HelperMethods.addActions(self.fileToolBar, self.fileMenuActions[:-2])
示例#14
0
    def createMenus(self):

        newFileAction = HelperMethods.createAction(
            self, "&New Simulation", self.fileNew, QKeySequence.New,
            "document-new.png", self.tr("New Simulation File"))
        fileOpenAction = HelperMethods.createAction(
            self, "&Open existing Simulation", self.fileOpen,
            QKeySequence.Open, 'document-open.png',
            self.tr("Open an existing Simulation"))
        fileSaveAction = HelperMethods.createAction(
            self, "&Save Simulation", self.fileSave, QKeySequence.Save,
            "document-save.png", self.tr("Save the current Simulation"))
        fileSaveAsAction = HelperMethods.createAction(
            self,
            "Save &As",
            self.fileSaveAs,
            QKeySequence.SaveAs,
            icon="document-save-as.png",
            tip=self.tr("Save Simulation File As"))

        fileOpenAction.setIcon(self.style().standardIcon(
            QStyle.SP_DirOpenIcon))
        # fileSaveAction.setIcon(self.style().standardIcon(QStyle.SP_FileDialogNewFolder))

        fileExportMatlabAction = HelperMethods.createAction(
            self,
            "Export in .mat File",
            self.exportMatlab,
            "Ctrl+E",
            icon="exportMatlab.png",
            tip=self.tr("Export in .mat File"))

        fileResetAction = HelperMethods.createAction(self,
                                                     "Reset Settings",
                                                     self.resetSettings,
                                                     icon="reset.png")

        fileQuitAction = HelperMethods.createAction(
            self, "&Quit", self.close, "Ctrl+Q", "close",
            self.tr("Close the application"))

        self.fileMenuActions = (newFileAction, fileOpenAction, fileSaveAction,
                                fileSaveAsAction, fileExportMatlabAction, None,
                                fileResetAction, fileQuitAction)

        HelperMethods.setEnabled(self.fileMenuActions[2:5], False)
        self.connect(self.menuFile, SIGNAL("aboutToShow()"),
                     self.updateFileMenu)

        self.geometryMenuActions = (
            self.actionNew_Geometry_Model, None, self.actionAdd_Ellipse,
            self.actionAdd_Rectangle, self.actionLoad_Scenario_From_Image,
            None, self.actionPreview_Labeled_Scenario,
            self.actionRotate_The_Scenario_90_Clockwise,
            self.actionRotate_The_Scenario_90_Counter_Clockwise)

        HelperMethods.setEnabled(self.menuNew_Simulation_Scenario, False)
        HelperMethods.setEnabled(self.geometryMenuActions, False)

        self.configurationMenuActions = (self.actionMaterials_Setup,
                                         self.actionBoundaty_Conditions_Setup)
        HelperMethods.setEnabled(self.configurationMenuActions, False)

        self.inspectionMenuActions = (self.actionSingle_Launch_Inspection,
                                      self.actionLinear_Scan_Inspections,
                                      self.actionTomography_Inspections)
        inspectionGroup = QActionGroup(self)
        HelperMethods.addActions(inspectionGroup, self.inspectionMenuActions)

        HelperMethods.setEnabled(self.menuInspection_Setup, False)
        HelperMethods.setEnabled(self.actionSimulation_Setup, False)
        HelperMethods.setEnabled(self.actionCheck_Simulation_Setup, False)
        HelperMethods.setEnabled(self.actionRun_Simulation, False)

        self.actionSignal = HelperMethods.createAction(self, "&Signal Setup",
                                                       self.signalSetup,
                                                       "Ctrl+Shift+p",
                                                       "signal.png",
                                                       self.tr("Signal Setup"))

        self.simulationMenuActions = (self.actionNew_Geometry_Model,
                                      self.actionMaterials_Setup,
                                      self.actionBoundaty_Conditions_Setup,
                                      self.actionSingle_Launch_Inspection,
                                      self.actionLinear_Scan_Inspections,
                                      self.actionTomography_Inspections,
                                      self.actionSimulation_Setup,
                                      self.actionCheck_Simulation_Setup,
                                      self.actionRun_Simulation)

        self.menuPlotting_Tools.menuAction().setVisible(False)

        # self.menuAdd_Microstructure.menuAction().setVisible(False)
        # self.menuTools.menuAction().setVisible(False)

        helpAboutAction = HelperMethods.createAction(self, "&About SimNDT",
                                                     self.helpAbout)
        helpHelpAction = HelperMethods.createAction(self, self.tr("&Help"),
                                                    self.helpHelp,
                                                    QKeySequence.HelpContents)

        helpMenu = self.menubar.addMenu(self.tr("&Help"))
        HelperMethods.addActions(helpMenu, (helpAboutAction, helpHelpAction))
示例#15
0
 def showContextMenu(self, pos):
     menu = QMenu()
     HelperMethods.addActions(menu, self.parent.actionAdd_Ellipse)
     HelperMethods.addActions(menu, self.parent.actionAdd_Rectangle)
     menu.exec_(self.mapToGlobal(pos))