Пример #1
0
 def readPartcase(self):
     varNotFound = []
     for v in self._part.variables:
         if getExistingFilename(v.filename) == None:
             self._part.variables.remove(v)
             varNotFound.append( v.filename )
         else:
             self._dataFileNames[ v.name ] = v.filename
             self._dataVariableType[ v.name ] = v.variableDimension
     # check if file is transient
     self._isTransient = False
     filename = getExistingFilename(self._part.filename)
     if filename == None:
         raise CoviseFileNotFoundError(self._part.filename)
     in_file = open(filename, "rb") # open in binary mode (makes a difference on windows (read() may stop too early))
     # first check if we have TIMESTEP at the end
     in_file.seek(-100, os.SEEK_END)
     tail = in_file.read(100)
     if b"TIMESTEP" in tail:
         self._isTransient = True
     else:
         # if not already recognized as transient, check if we have SETELE at the beginning
         head = in_file.read(100)
         if b"SETELE" in head:
             # if we have, check the entire file since we might have nested sets
             in_file.seek(0, os.SEEK_BEGIN)
             line = in_file.readline()
             while line:
                 if b"TIMESTEP" in line:
                     self._isTransient = True
                     break
                 line = in_file.readline()
     in_file.close()
     return varNotFound
Пример #2
0
 def recreate(self, negMsgHandler, parentKey, offset):
     VrmlVisParams.mergeDefaultParams(
         self.params)  # explicitly call mergeDefaultParams of this class
     self.__initBase()
     VisItem.recreate(self, negMsgHandler, parentKey, offset)
     if getExistingFilename(self.params.filename) == None:
         raise CoviseFileNotFoundError(self.params.filename)
Пример #3
0
    def __update(self, negMsgHandler):
        """ __update is called from the run method to update the module parameter before execution
            + update module parameters """
        _infoer.function = str(self.__update)
        _infoer.write(" ")
        self.__init(negMsgHandler)
        #update params
        # check if filename exists
        if getExistingFilename(self.params.filename) == None:
            raise IOError(self.params.filename)
            """
            fn = os.path.basename(filename)
            # if a path allready was selected
            if not _newPath == None:
                fname = VRPCoviseNetAccess._newPath + fn
                # test new path
                if not os.access(fname, os.R_OK):
                    filename = VRPCoviseNetAccess.changePath(filename, fn)
                else:
                    filename = fname
            else:
                filename = VRPCoviseNetAccess.changePath(filename , fn)
            """

        self.rwCovise.set_grid_path(self.params.filename)
        self.rwCovise.set_stepNo(self.params.stepNo)
        if (self.params.rotate_output == True):
            self.rwCovise.set_rotate_output('TRUE')
        else:
            self.rwCovise.set_rotate_output('FALSE')
        self.rwCovise.set_rotation_axis(self.params.rotation_axis)
        self.rwCovise.set_rot_speed(self.params.rot_speed)
Пример #4
0
    def recreate(self, negMsgHandler, parentKey, offset):
        """ recreate is called after all classes of the session have been unpickled """
        _infoer.function = str(self.recreate)
        _infoer.write(" ")
        coDocumentMgrParams.mergeDefaultParams(self.params) # explicitly call mergeDefaultParams of this class
        self.__initBase()
        VisItem.recreate(self, negMsgHandler, parentKey, offset)
        self.params.changed = False

        if getExistingFilename(self.params.imageName) == None:
            raise CoviseFileNotFoundError(self.params.imageName)
Пример #5
0
    def recreate(self, negMsgHandler, parentKey, offset):
        """ recreate is called after all classes of the session have been unpickled """
        _infoer.function = str(self.recreate)
        _infoer.write(" ")
        coDocumentMgrParams.mergeDefaultParams(
            self.params)  # explicitly call mergeDefaultParams of this class
        self.__initBase()
        VisItem.recreate(self, negMsgHandler, parentKey, offset)
        self.params.changed = False

        if getExistingFilename(self.params.imageName) == None:
            raise CoviseFileNotFoundError(self.params.imageName)
Пример #6
0
 def readPartcase(self):
     varNotFound = []
     for v in self._part.variables:
         if getExistingFilename(v.filename) == None:
             self._part.variables.remove(v)
             varNotFound.append(v.filename)
         else:
             self._dataFileNames[v.name] = v.filename
             self._dataVariableType[v.name] = v.variableDimension
     # check if file is transient
     self._isTransient = False
     filename = getExistingFilename(self._part.filename)
     if filename == None:
         raise CoviseFileNotFoundError(self._part.filename)
     in_file = open(
         filename, "rb"
     )  # open in binary mode (makes a difference on windows (read() may stop too early))
     # first check if we have TIMESTEP at the end
     in_file.seek(-100, os.SEEK_END)
     tail = in_file.read(100)
     if b"TIMESTEP" in tail:
         self._isTransient = True
     else:
         # if not already recognized as transient, check if we have SETELE at the beginning
         head = in_file.read(100)
         if b"SETELE" in head:
             # if we have, check the entire file since we might have nested sets
             in_file.seek(0, os.SEEK_BEGIN)
             line = in_file.readline()
             while line:
                 if b"TIMESTEP" in line:
                     self._isTransient = True
                     break
                 line = in_file.readline()
     in_file.close()
     return varNotFound
Пример #7
0
 def setGridPath(self, filename, doWrite = False):
     # check if filename exists
     if not doWrite and (getExistingFilename(filename) == None):
         #raise IOError(filename)
         raise CoviseFileNotFoundError(filename)
         """
         fn = os.path.basename(filename)
         # if a path allready was selected
         if not _newPath == None:
             fname = _newPath + fn
             # test new path
             if not os.access(fname, os.R_OK):
                 filename = changePath(filename, fn)
             else:
                 filename = fname
         else:
             filename = changePath(filename , fn)
         """
     self._module.set_grid_path(filename)
     self.__gridPath = filename
Пример #8
0
 def recreate(self, negMsgHandler, parentKey, offset):
     VrmlVisParams.mergeDefaultParams(self.params)  # explicitly call mergeDefaultParams of this class
     self.__initBase()
     VisItem.recreate(self, negMsgHandler, parentKey, offset)
     if getExistingFilename(self.params.filename) == None:
         raise CoviseFileNotFoundError(self.params.filename)
Пример #9
0
    def setParamsCB(self, requestNr, key, params):
        """ received params from negotiator """
        _infoer.write('setParamsCB(requestNr %s, key %s, paramName= %s)' %
                      (str(requestNr), str(key), str(params.name)))

        if not key in self.__objects:
            return

        self.__objects[key].params = params

        self.sigGuiParamChanged.emit(key)
        #for compatibility
        Application.vrpApp.key2params[key] = params
        typeNr = self.__objects[key].type

        if (typeNr in [
                TYPE_SCENEGRAPH_ITEM, TYPE_COLOR_CREATOR, TYPE_COLOR_MGR,
                VIS_DOMAINLINES, TYPE_SCENEGRAPH_MGR, TYPE_DNA_MGR,
                TYPE_DNA_ITEM, TYPE_GENERIC_OBJECT_MGR, TYPE_GENERIC_OBJECT,
                TYPE_JOURNAL_STEP, TYPE_PROJECT, TYPE_CASE, TYPE_2D_GROUP,
                TYPE_3D_GROUP, TYPE_2D_CUTGEOMETRY_PART
        ]):
            pass
        elif typeNr in [
                VIS_STREAMLINE, VIS_MOVING_POINTS, VIS_PATHLINES,
                VIS_STREAMLINE_2D, VIS_PLANE, VIS_VECTOR, VIS_ISOPLANE,
                VIS_ISOCUTTER, VIS_CLIPINTERVAL, VIS_VECTORFIELD,
                VIS_DOMAINSURFACE
        ]:  #, VIS_POINTPROBING, VIS_MAGMATRACE
            #Application.vrpApp.mw.raisePanelForKey(key)
            theGuiMsgHandler().answerOk(requestNr)
            self.checkForUpdate(key, params)
        elif TYPE_CAD_PART == typeNr:  #TYPE_2D_PART == typeNr or
            """ CAD Change"
            if hasattr(params, 'featureAngleDefault'):
                VRPMainWindow.tesselationPanel.setParams(key)
                VRPMainWindow.tesselationPanel.setParams(params)
            """
            # vis = VRPMainWindow.globalAccessToTreeView.getItemData(key).isChecked
            vis = False
            paramsForTree = NamedCheckable(params.name, vis)
            Application.vrpApp.key2params[key] = params
            #Application.vrpApp.mw.raisePanelForKey(key)
        elif TYPE_2D_PART == typeNr:
            self.__copyNames.append(params.name)
        elif TYPE_2D_COMPOSED_PART == typeNr:
            if self.__objects[key].params.name == 'Composed.2DPart':
                parentPanelParams = Application.vrpApp.mw.getPanelForKey(
                    self.getParentOfObject(key)).getParams()
                self.__objects[key].params.name = parentPanelParams.name
                self.__objects[key].params.subKeys = parentPanelParams.subKeys
                self.__objects[
                    key].params.definitions = parentPanelParams.definitions
                #VRPMainWindow.globalAccessToTreeView.setItemData(key, parentPanelParams.name)
                Application.vrpApp.mw.globalAccessToTreeView().setItemData(
                    key, parentPanelParams.name)
                theGuiMsgHandler().setParams(key, params)
            #Application.vrpApp.mw.raisePanelForKey(key)
            theGuiMsgHandler().answerOk(requestNr)
            theGuiMsgHandler().runObject(key)
        elif TYPE_3D_PART == typeNr:
            self.__copyNames.append(params.name)
        elif TYPE_3D_COMPOSED_PART == typeNr:
            if self.__objects[key].params.name == 'Composed.3DPart':
                parentPanelParams = Application.vrpApp.mw.getPanelForKey(
                    self.getParentOfObject(key)).getParams()
                self.__objects[key].params.name = parentPanelParams.name
                self.__objects[key].params.subKeys = parentPanelParams.subKeys
                self.__objects[
                    key].params.velDefinitions = parentPanelParams.velDefinitions
                #VRPMainWindow.globalAccessToTreeView.setItemData(key, parentPanelParams.name)
                Application.vrpApp.mw.globalAccessToTreeView().setItemData(
                    key, parentPanelParams.name)
                theGuiMsgHandler().setParams(key, params)
            #Application.vrpApp.mw.raisePanelForKey(key)
            theGuiMsgHandler().answerOk(requestNr)
            theGuiMsgHandler().runObject(key)
        elif TYPE_PRESENTATION == typeNr:
            Application.vrpApp.mw.presenterManager.updateForObject(key)
            #Application.vrpApp.mw.raisePanelForKey(key)
        elif TYPE_JOURNAL == typeNr:
            Application.vrpApp.globalJournalMgrParams = params
            """
            if params.currentIdx==params.maxIdx:
                Application.vrpApp.mw.editRedoAction.setEnabled(False)
                Application.vrpApp.mw.editUndoAction.setEnabled(True)
            else:
                Application.vrpApp.mw.editUndoAction.setEnabled(True)
                Application.vrpApp.mw.editRedoAction.setEnabled(True)
            if params.currentIdx<=0:
                Application.vrpApp.mw.editUndoAction.setEnabled(False)
            """
        elif TYPE_PRESENTATION_STEP == typeNr:
            Application.vrpApp.mw.presenterManager.setParams(key, params)
        elif TYPE_VIEWPOINT == typeNr:
            # do not add the default viewpoints to listview
            if not params.view == None and not params.view == 'default':
                Application.vrpApp.mw.viewpointManager.addViewpoint(key)
            Application.vrpApp.mw.viewpointManager.setParams(key, params)
            #VRPMainWindow.globalAccessToTreeView.setItemSelected(key, True)
        elif TYPE_VIEWPOINT_MGR == typeNr:
            Application.vrpApp.mw.viewpointManager.updateForObject(key)
        elif TYPE_TRACKING_MGR == typeNr:
            Application.vrpApp.mw.trackingManager.updateForObject(key)
        elif VIS_2D_RAW == typeNr:
            """ CAD Change
            paramsForTreeView = NamedCheckable(params.name, params.isVisible)
            VRPMainWindow.globalAccessToTreeView.setItemData(key, paramsForTreeView)
            """
            self.refactoringThing02(requestNr, key, params)
            self.checkForUpdate(key, params)
            #need to do this for copieing 2d parts
            self.setParams(key, params)
        elif VIS_3D_BOUNDING_BOX == typeNr:
            self.refactoringThing02(requestNr, key, params)
        elif VIS_COVISE == typeNr or VIS_DOCUMENT == typeNr or TYPE_CAD_PRODUCT == typeNr:
            if not self.newCoviseFileName == None:
                if hasattr(params, 'documentName'):
                    # check if document exists
                    filename = self.newCoviseFileName
                    if getExistingFilename(filename) == None:
                        raise CoviseFileNotFoundError(filename)

                    params.documentName = os.path.basename(
                        filename)  #(self.newCoviseFileName)
                    params.documentName = params.documentName[:len(
                        params.documentName) - 4]
                    params.imageName = filename  #self.newCoviseFileName
                    params.name = params.documentName
                else:
                    params.filename = self.newCoviseFileName
                    params.name = os.path.basename(self.newCoviseFileName)
                self.newCoviseFileName = None
            if hasattr(params, 'documentName'):
                #Application.vrpApp.mw.raisePanelForKey(key)
                theGuiMsgHandler().answerOk(requestNr)
                # check if document exists
                filename = params.imageName
                if getExistingFilename(filename) == None:
                    raise CoviseFileNotFoundError(filename)
                params.imageName = filename
            if hasattr(params, 'isVisible'):
                p = NamedCheckable(params.name, params.isVisible)
            else:
                p = params.name
            Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, p)
            theGuiMsgHandler().setParams(key, params)
            theGuiMsgHandler().runObject(key)
        elif VIS_VRML == typeNr:
            if not self.newCoviseFileName == None:
                params.filename = self.newCoviseFileName
                params.name = os.path.basename(self.newCoviseFileName)
                self.newCoviseFileName = None
                theGuiMsgHandler().setParams(key, params)
            p = params.name
            Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, p)
        elif VIS_SCENE_OBJECT == typeNr:
            if not self.newCoviseFileName == None:
                params.filename = self.newCoviseFileName
                params.name = os.path.basename(self.newCoviseFileName)
                self.newCoviseFileName = None
                theGuiMsgHandler().setParams(key, params)
                theGuiMsgHandler().runObject(key)
            p = params.name
            Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, p)
        elif TYPE_COLOR_TABLE == typeNr:
            Application.vrpApp.mw.globalColorManager().setParams(key, params)
        else:
            assert False, 'unknown type'

        if key in Application.vrpApp.guiKey2visuKey:
            visKey = Application.vrpApp.guiKey2visuKey[key]
            self.__objects[visKey].params.name = params.name
            theGuiMsgHandler().setParams(visKey, self.__objects[visKey].params)

        theGuiMsgHandler().answerOk(requestNr)
Пример #10
0
    def setParamsCB(self, requestNr, key, params):
        """ received params from negotiator """
        _infoer.write('setParamsCB(requestNr %s, key %s, paramName= %s)' % ( str(requestNr), str(key), str(params.name)))

        if not key in self.__objects:
            return

        self.__objects[key].params = params

        self.sigGuiParamChanged.emit(key )
        #for compatibility
        Application.vrpApp.key2params[key] = params
        typeNr = self.__objects[key].type

        if (typeNr in [TYPE_SCENEGRAPH_ITEM, TYPE_COLOR_CREATOR, TYPE_COLOR_MGR, VIS_DOMAINLINES, TYPE_SCENEGRAPH_MGR, TYPE_DNA_MGR, TYPE_DNA_ITEM, TYPE_GENERIC_OBJECT_MGR, TYPE_GENERIC_OBJECT, TYPE_JOURNAL_STEP, TYPE_PROJECT, TYPE_CASE, TYPE_2D_GROUP, TYPE_3D_GROUP, TYPE_2D_CUTGEOMETRY_PART]):
            pass
        elif typeNr in [VIS_STREAMLINE, VIS_MOVING_POINTS, VIS_PATHLINES, VIS_STREAMLINE_2D, VIS_PLANE, VIS_VECTOR, VIS_ISOPLANE, VIS_ISOCUTTER, VIS_CLIPINTERVAL, VIS_VECTORFIELD, VIS_DOMAINSURFACE]: #, VIS_POINTPROBING, VIS_MAGMATRACE
            #Application.vrpApp.mw.raisePanelForKey(key)
            theGuiMsgHandler().answerOk(requestNr)
            self.checkForUpdate( key, params)
        elif TYPE_CAD_PART == typeNr:#TYPE_2D_PART == typeNr or 
            """ CAD Change"
            if hasattr(params, 'featureAngleDefault'):
                VRPMainWindow.tesselationPanel.setParams(key)
                VRPMainWindow.tesselationPanel.setParams(params)
            """
            # vis = VRPMainWindow.globalAccessToTreeView.getItemData(key).isChecked
            vis = False
            paramsForTree = NamedCheckable(params.name, vis)
            Application.vrpApp.key2params[key] = params
            #Application.vrpApp.mw.raisePanelForKey(key)
        elif TYPE_2D_PART == typeNr:
            self.__copyNames.append(params.name)
        elif TYPE_2D_COMPOSED_PART == typeNr:
            if self.__objects[key].params.name == 'Composed.2DPart':
                parentPanelParams = Application.vrpApp.mw.getPanelForKey(self.getParentOfObject(key)).getParams()
                self.__objects[key].params.name = parentPanelParams.name
                self.__objects[key].params.subKeys = parentPanelParams.subKeys
                self.__objects[key].params.definitions = parentPanelParams.definitions
                #VRPMainWindow.globalAccessToTreeView.setItemData(key, parentPanelParams.name)
                Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, parentPanelParams.name)
                theGuiMsgHandler().setParams( key, params )
            #Application.vrpApp.mw.raisePanelForKey(key)
            theGuiMsgHandler().answerOk(requestNr)
            theGuiMsgHandler().runObject(key)
        elif TYPE_3D_PART == typeNr:
            self.__copyNames.append(params.name)
        elif TYPE_3D_COMPOSED_PART == typeNr:
            if self.__objects[key].params.name == 'Composed.3DPart':
                parentPanelParams = Application.vrpApp.mw.getPanelForKey(self.getParentOfObject(key)).getParams()
                self.__objects[key].params.name = parentPanelParams.name
                self.__objects[key].params.subKeys = parentPanelParams.subKeys
                self.__objects[key].params.velDefinitions = parentPanelParams.velDefinitions
                #VRPMainWindow.globalAccessToTreeView.setItemData(key, parentPanelParams.name)
                Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, parentPanelParams.name)
                theGuiMsgHandler().setParams( key, params )
            #Application.vrpApp.mw.raisePanelForKey(key)
            theGuiMsgHandler().answerOk(requestNr)
            theGuiMsgHandler().runObject(key)
        elif TYPE_PRESENTATION == typeNr:
            Application.vrpApp.mw.presenterManager.updateForObject(key)
            #Application.vrpApp.mw.raisePanelForKey(key)
        elif TYPE_JOURNAL == typeNr:
            Application.vrpApp.globalJournalMgrParams = params
            """
            if params.currentIdx==params.maxIdx:
                Application.vrpApp.mw.editRedoAction.setEnabled(False)
                Application.vrpApp.mw.editUndoAction.setEnabled(True)
            else:
                Application.vrpApp.mw.editUndoAction.setEnabled(True)
                Application.vrpApp.mw.editRedoAction.setEnabled(True)
            if params.currentIdx<=0:
                Application.vrpApp.mw.editUndoAction.setEnabled(False)
            """
        elif TYPE_PRESENTATION_STEP == typeNr:
            Application.vrpApp.mw.presenterManager.setParams( key, params )
        elif TYPE_VIEWPOINT == typeNr:
            # do not add the default viewpoints to listview
            if not params.view == None and not params.view == 'default':
                Application.vrpApp.mw.viewpointManager.addViewpoint(key)
            Application.vrpApp.mw.viewpointManager.setParams( key, params )
            #VRPMainWindow.globalAccessToTreeView.setItemSelected(key, True)
        elif TYPE_VIEWPOINT_MGR == typeNr: 
            Application.vrpApp.mw.viewpointManager.updateForObject(key)
        elif TYPE_TRACKING_MGR == typeNr: 
            Application.vrpApp.mw.trackingManager.updateForObject(key)
        elif VIS_2D_RAW == typeNr:
            """ CAD Change
            paramsForTreeView = NamedCheckable(params.name, params.isVisible)
            VRPMainWindow.globalAccessToTreeView.setItemData(key, paramsForTreeView)
            """
            self.refactoringThing02(requestNr, key, params)
            self.checkForUpdate( key, params)
            #need to do this for copieing 2d parts
            self.setParams(key, params)
        elif VIS_3D_BOUNDING_BOX == typeNr:
            self.refactoringThing02(requestNr, key, params)
        elif VIS_COVISE==typeNr or VIS_DOCUMENT==typeNr or TYPE_CAD_PRODUCT==typeNr:
            if not self.newCoviseFileName==None:
                if hasattr( params, 'documentName' ):
                    # check if document exists
                    filename = self.newCoviseFileName
                    if getExistingFilename(filename) == None:
                        raise CoviseFileNotFoundError(filename)

                    params.documentName = os.path.basename(filename)#(self.newCoviseFileName)
                    params.documentName = params.documentName[:len(params.documentName)-4]
                    params.imageName = filename#self.newCoviseFileName
                    params.name = params.documentName
                else :
                    params.filename = self.newCoviseFileName
                    params.name = os.path.basename(self.newCoviseFileName)
                self.newCoviseFileName=None
            if hasattr( params, 'documentName' ):
                #Application.vrpApp.mw.raisePanelForKey(key)
                theGuiMsgHandler().answerOk(requestNr)
                # check if document exists
                filename = params.imageName
                if getExistingFilename(filename) == None:
                    raise CoviseFileNotFoundError(filename)
                params.imageName = filename
            if hasattr( params, 'isVisible'):
                p = NamedCheckable(params.name, params.isVisible)
            else:
                p = params.name
            Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, p)
            theGuiMsgHandler().setParams( key, params )
            theGuiMsgHandler().runObject(key)
        elif VIS_VRML==typeNr:
            if not self.newCoviseFileName==None:
                params.filename = self.newCoviseFileName
                params.name = os.path.basename(self.newCoviseFileName)
                self.newCoviseFileName=None
                theGuiMsgHandler().setParams( key, params )
            p = params.name
            Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, p)
        elif VIS_SCENE_OBJECT==typeNr:
            if not self.newCoviseFileName==None:
                params.filename = self.newCoviseFileName
                params.name = os.path.basename(self.newCoviseFileName)
                self.newCoviseFileName=None
                theGuiMsgHandler().setParams( key, params )
                theGuiMsgHandler().runObject(key)
            p = params.name
            Application.vrpApp.mw.globalAccessToTreeView().setItemData(key, p)
        elif TYPE_COLOR_TABLE==typeNr:
            Application.vrpApp.mw.globalColorManager().setParams( key, params)
        else:
            assert False, 'unknown type'

        if key in Application.vrpApp.guiKey2visuKey:
            visKey = Application.vrpApp.guiKey2visuKey[key]
            self.__objects[visKey].params.name = params.name
            theGuiMsgHandler().setParams( visKey, self.__objects[visKey].params )

        theGuiMsgHandler().answerOk(requestNr)