Exemplo n.º 1
0
    def redrawScene(self):
        """Redraws the scene"""
        smartZoomLevel = Settings()['smartZoom']
        self.cflowSettings = getCflowSettings(self)
        if self.dirty():
            self.__displayProps = (self.cflowSettings.hidedocstrings,
                                   self.cflowSettings.hidecomments,
                                   self.cflowSettings.hideexcepts,
                                   smartZoomLevel)
        self.cflowSettings.itemID = 0
        self.cflowSettings = tweakSmartSettings(self.cflowSettings,
                                                smartZoomLevel)

        self.scene().clear()
        try:
            fileName = self.__parentWidget.getFileName()
            if not fileName:
                fileName = self.__parentWidget.getShortName()
            collapsedGroups = getCollapsedGroups(fileName)

            # Top level canvas has no adress and no parent canvas
            canvas = VirtualCanvas(self.cflowSettings, None, None,
                                   self.__validGroups, collapsedGroups, None)
            canvas.layoutModule(self.__cf)
            canvas.setEditor(self.__editor)
            width, height = canvas.render()
            self.scene().setSceneRect(0, 0, width, height)
            canvas.draw(self.scene(), 0, 0)
        except Exception as exc:
            logging.error(str(exc))
            raise
Exemplo n.º 2
0
    def redrawScene(self):
        """Redraws the scene"""
        smartZoomLevel = Settings()['smartZoom']
        self.cflowSettings = getCflowSettings(self)
        if self.dirty():
            self.__displayProps = (self.cflowSettings.hidedocstrings,
                                   self.cflowSettings.hidecomments,
                                   self.cflowSettings.hideexcepts,
                                   smartZoomLevel)
        self.cflowSettings.itemID = 0
        self.cflowSettings = tweakSmartSettings(self.cflowSettings,
                                                smartZoomLevel)

        try:
            fileName = self.__parentWidget.getFileName()
            if not fileName:
                fileName = self.__parentWidget.getShortName()
            collapsedGroups = getCollapsedGroups(fileName)

            # Top level canvas has no adress and no parent canvas
            self.__cleanupCanvas()
            self.__canvas = VirtualCanvas(self.cflowSettings, None, None,
                                          self.__validGroups, collapsedGroups,
                                          None)
            lStart = timer()
            self.__canvas.layoutModule(self.__cf)
            lEnd = timer()
            self.__canvas.setEditor(self.__editor)
            width, height = self.__canvas.render()
            rEnd = timer()
            self.scene().setSceneRect(0, 0, width, height)
            self.__canvas.draw(self.scene(), 0, 0)
            dEnd = timer()
            if self.isDebugMode():
                logging.info('Redrawing is done. Size: %d x %d', width, height)
                logging.info('Layout timing: %f', lEnd - lStart)
                logging.info('Render timing: %f', rEnd - lEnd)
                logging.info('Draw timing: %f', dEnd - rEnd)
        except Exception as exc:
            logging.error(str(exc))
            raise
Exemplo n.º 3
0
    def process(self):
        """ Parses the content and displays the results """

        if not self.__connected:
            self.__connectEditorSignals()

        content = self.__editor.text()
        cf = getControlFlowFromMemory(content)
        if cf.errors:
            self.__navBar.updateInfoIcon(self.__navBar.STATE_BROKEN_UTD)
            errors = []
            for err in cf.errors:
                if err[0] == -1 and err[1] == -1:
                    errors.append(err[2])
                elif err[1] == -1:
                    errors.append("[" + str(err[0]) + ":] " + err[2])
                elif err[0] == -1:
                    errors.append("[:" + str(err[1]) + "] " + err[2])
                else:
                    errors.append("[" + str(err[0]) + ":" + str(err[1]) +
                                  "] " + err[2])
            self.__navBar.setErrors(errors)
            return
        self.__cf = cf

        # Validate CML comments
        cmlWarnings = CMLVersion.validateCMLComments(self.__cf)
        if cmlWarnings:
            self.__cf.warnings += cmlWarnings

        # That will clear the error tooltip as well
        self.__navBar.updateInfoIcon(self.__navBar.STATE_OK_UTD)

        if self.__cf.warnings:
            warnings = []
            for warn in self.__cf.warnings:
                if warn[0] == -1 and warn[1] == -1:
                    warnings.append(warn[2])
                elif warn[1] == -1:
                    warnings.append("[" + str(warn[0]) + ":] " + warn[2])
                elif warn[0] == -1:
                    warnings.append("[:" + str(warn[1]) + "] " + warn[2])
                else:
                    warnings.append("[" + str(warn[0]) + ":" + str(warn[1]) +
                                    "] " + warn[2])
            self.__navBar.setWarnings(warnings)
        else:
            self.__navBar.clearWarnings()

        self.scene.clear()
        try:
            # Top level canvas has no adress and no parent canvas
            canvas = VirtualCanvas(self.cflowSettings, None, None, None)
            canvas.layoutModule(self.__cf)
            canvas.setEditor(self.__editor)
            width, height = canvas.render()
            self.scene.setSceneRect(0, 0, width, height)
            canvas.draw(self.scene, 0, 0)
        except Exception, exc:
            logging.error(str(exc))
            raise