def initProject(self): # delete old project self.deleteProject() # create new project print('new project') reqId = theGuiMsgHandler().requestObject(typeNr = TYPE_PROJECT, callback = None, parentKey = SESSION_KEY) print('wait') theGuiMsgHandler().waitforAnswer(reqId) print('waitDone') # reset Navigation Mode navMode = covise.getCoConfigEntry("COVER.NavigationMode") if (navMode == "NavNone"): Application.vrpApp.mw.navigationModeNone() if (navMode == "Transform"): Application.vrpApp.mw.navigationModeTransform() if (navMode == "Measure"): Application.vrpApp.mw.navigationModeMeasure() # add Coxml Intitial File # NOTE: might be better in negotiator but the current file importing process does not easily allow that if (covise.getCoConfigEntry("vr-prepare.Coxml.InitialFile", "") != ""): resourceDir = covise.getCoConfigEntry("vr-prepare.Coxml.ResourceDirectory") initFile = covise.getCoConfigEntry("vr-prepare.Coxml.InitialFile") if (resourceDir != None) and (initFile != None): if os.path.exists(resourceDir + "/coxml/" + initFile): self.importFile(initFile) else: print("Error: Initial coxml file does not exist (%s)" % initFile)
def initProject(self): # delete old project self.deleteProject() # create new project print('new project') reqId = theGuiMsgHandler().requestObject(typeNr=TYPE_PROJECT, callback=None, parentKey=SESSION_KEY) print('wait') theGuiMsgHandler().waitforAnswer(reqId) print('waitDone') # reset Navigation Mode navMode = covise.getCoConfigEntry("COVER.NavigationMode") if (navMode == "NavNone"): Application.vrpApp.mw.navigationModeNone() if (navMode == "Transform"): Application.vrpApp.mw.navigationModeTransform() if (navMode == "Measure"): Application.vrpApp.mw.navigationModeMeasure() # add Coxml Intitial File # NOTE: might be better in negotiator but the current file importing process does not easily allow that if (covise.getCoConfigEntry("vr-prepare.Coxml.InitialFile", "") != ""): resourceDir = covise.getCoConfigEntry( "vr-prepare.Coxml.ResourceDirectory") initFile = covise.getCoConfigEntry("vr-prepare.Coxml.InitialFile") if (resourceDir != None) and (initFile != None): if os.path.exists(resourceDir + "/coxml/" + initFile): self.importFile(initFile) else: print("Error: Initial coxml file does not exist (%s)" % initFile)
def __init__(self): # list of the variables self.__vectorVariableNames = [] self.__scalarVariableNames = [] self.__scalarDecoration = "(scalar)" self.__vectorDecoration = "(vector)" self.__unsetDecoration = "" self.__postfixSeperator = " " # dictionaries to enable the buttons self._enableDictComposedMode = {} self._enableDictVectorVariable = {} self._enableDictScalarVariable = {} self._enableDictUnsetVariable = {} # list of disabled buttons self._disablees = [] self.__inFixedGridMode = False self.__useUnset = False self.vrpComboBoxGrid.hide() self.vrpLocalisationLabel.show() # set texts of push buttons NewArrowsCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.NewArrowsCuttingSurfaceText") if NewArrowsCuttingSurfaceText and hasattr(self, "CuttingSurfaceArrowPushButton"): self.CuttingSurfaceArrowPushButton.setText(NewArrowsCuttingSurfaceText) NewColoredCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.NewColoredCuttingSurfaceText") if NewColoredCuttingSurfaceText: self.CuttingSurfaceColoredPushButton.setText(NewColoredCuttingSurfaceText) self._disableMethodButts()
def __init__(self): #list of the variables self.__vectorVariableNames = [] self.__scalarVariableNames = [] self.__scalarDecoration = '(scalar)' self.__vectorDecoration = '(vector)' self.__unsetDecoration = '' self.__postfixSeperator = ' ' #dictionaries to enable the buttons self._enableDictComposedMode = {} self._enableDictVectorVariable = {} self._enableDictScalarVariable = {} self._enableDictUnsetVariable = {} #list of disabled buttons self._disablees = [] self.__inFixedGridMode = False self.__useUnset = False self.vrpComboBoxGrid.hide() self.vrpLocalisationLabel.show() #set texts of push buttons NewArrowsCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.NewArrowsCuttingSurfaceText") if NewArrowsCuttingSurfaceText and hasattr(self, 'CuttingSurfaceArrowPushButton') : self.CuttingSurfaceArrowPushButton.setText(NewArrowsCuttingSurfaceText) NewColoredCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.NewColoredCuttingSurfaceText") if NewColoredCuttingSurfaceText: self.CuttingSurfaceColoredPushButton.setText(NewColoredCuttingSurfaceText) self._disableMethodButts()
def __panelAccordingTaskType( self ): """ change the panel according the needs of the visualizer NOTE: changes identical for all types should be done in __init__ """ if self.__vector==PLANE: self.TabWidgetGeneralAdvanced.setTabEnabled(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentCuttingSurface), False) text = "Edit Plane on Cutting Surface:" ColoredCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.ColoredCuttingSurfaceText") if ColoredCuttingSurfaceText: text = ColoredCuttingSurfaceText self.vrpLabelTitle.setText(self.__tr(text)) self.vrpCheckBoxShow.show() if self.__vector==VECTOR: self.vrpCheckBoxShow.hide() self.TabWidgetGeneralAdvanced.setTabEnabled(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentCuttingSurface), True) text = "Edit Arrows on Cutting Surface:" ArrowsOnCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.ArrowsOnCuttingSurfaceText") if ArrowsOnCuttingSurfaceText: text = ArrowsOnCuttingSurfaceText self.vrpLabelTitle.setText(self.__tr(text)) title = "Arrows on Cutting Plane Adjustment" ArrowsOnCuttingSurfaceAdjustmentText = covise.getCoConfigEntry("vr-prepare.ArrowsOnCuttingSurfaceAdjustmentText") if ArrowsOnCuttingSurfaceAdjustmentText: title = ArrowsOnCuttingSurfaceAdjustmentText self.vrpGroupBoxAdjustment.setTitle(self.__tr(title))
def letUserAddCasefilename(self): _infoer.function = str(self.letUserAddCasefilename) _infoer.write("") #filetypes = 'Case-files (*.cocase)\n' filetypes = Utils.getImportFileTypes() filenamesQt = QtWidgets.QFileDialog.getOpenFileNames( self, self.__tr('Add Datasets'), self.__cocaseFilenameSuggestion, filetypes) if filenamesQt == "": self.statusMessage.emit(('Choosing filename cancelled', )) return for filenameQt in filenamesQt: filename = str(filenameQt) load = True if not os.access(filename, os.R_OK): QtWidgets.QMessageBox.information( self, covise.getCoConfigEntry("vr-prepare.ProductName"), self.__tr("The file \"") + filenameQt + self.__tr("\" is not accessable.\n") + self.__tr("You may check the permissions."), self.__tr("&Ok"), "", "", 0, 0) load = False #return if load: if str(filenameQt).endswith(".cocase"): self.addCasefilename(str(filenameQt)) elif os.path.splitext(str(filenameQt))[1].lower( ) in Utils.getImportFileTypesFlat(): self.addDatasetFilename(str(filenameQt)) else: print("Warning: Trying to add file of unknown type: ", str(filenameQt)) self.__cocaseFilenameSuggestion = str(filenameQt)
def __init__(self): #print "Ensight2CoviseGui.__init__" # init base class Ensight2CoviseGuiBase.__init__(self, None) # connect buttons self.outputDirLineEdit.returnPressed.connect(self.setOutputDir) self.byteswapped.stateChanged.connect(self.setByteswap) self.startConversionPushButton.clicked.connect(self.startConversion) # initialize output directory InitialDatasetSearchPath = covise.getCoConfigEntry( "vr-prepare.InitialDatasetSearchPath") if not InitialDatasetSearchPath: InitialDatasetSearchPath = os.getcwd() self.currentFilePath = InitialDatasetSearchPath self.scale = 1.0 # disable all buttons at beginning self.settingsFrame.setEnabled(False) self.startConversionFrame.setEnabled(False) self.outputDirFrame.setEnabled(False) self.isByteSwapped = True
def __init__(self, parent): QtWidgets.QDockWidget.__init__(self, coTranslate("Video Capture Manager"), parent) self.setWidget(VideoCaptureManagerBase(self)) #connection of the DockWidget visibilityChanged self.visibilityChanged.connect(self.visibilityChangedS) # connection of buttons self.widget().buttonCapture.clicked.connect(self.capture) self.widget().buttonPreview.clicked.connect(self.startPreview) self.widget().comboBox.activated.connect(self.selectMode) # connect open self.widget().pushButton.clicked.connect(self.openFile) # connect filename self.widget().lineEdit.returnPressed.connect(self.setFilename) self.widget().lineEdit.editingFinished.connect(self.checkFilename) self.widget().groupSettings.setVisible(True) self.widget().groupCapturing.setVisible(True) #self.recording = False; self.filename = "C:\capture.wmv" if covise.coConfigIsOn("COVER.Plugin.Video", False): filename = covise.getCoConfigEntry("COVER.Plugin.Video.Filename") if filename: self.filename = filename self.widget().lineEdit.setText(self.filename) self.oldFilename = self.filename self.freeCapture = False self.mode=0
def takeSnapshot(self): _infoer.function = str(self.takeSnapshot) _infoer.write("") filename = "" if covise.coConfigIsOn("vr-prepare.ShowSnapshotDialog", True): directory = covise.getCoConfigEntry("COVER.Plugin.PBufferSnapShot.Directory") if (directory == None): directory = "snapshot.png" else: directory = directory + "/" + "snapshot.png" filenameQt = QtWidgets.QFileDialog.getSaveFileName( self, self.__tr('Snapshot'), directory, self.__tr('Image (*.png)'), None, QtWidgets.QFileDialog.DontConfirmOverwrite) if filenameQt == "": return #filenameQt is filename + extension touple filename = filenameQt[0] print(filename) if not filename.lower().endswith(".png"): filename += ".png" if os.path.exists(filename): asker = ReallyWantToOverrideAsker(self, filename) decicion = asker.exec_() if decicion == QtWidgets.QDialog.Rejected: self.statusBar().showMessage( self.__tr('Cancelled overwrite of "%s"') % filename ) return msg = coGRSnapshotMsg( filename, "snapOnce" ) covise.sendRendMsg(msg.c_str())
def __update(self): """ __update is called from the run method to update the module parameter before execution + update module parameters """ _infoer.function = str(self.__update) _infoer.write(" ") if self.performerScene == None: self.performerScene = PerformerScene() theNet().add(self.performerScene) # update params self.performerScene.set_modelPath( covise.getCoConfigEntry("vr-prepare.Coxml.ResourceDirectory") + "/coxml/" + self.params.filename) self.performerScene.set_scale(self.params.scale) if (self.params.backface == True): self.performerScene.set_backface('TRUE') else: self.performerScene.set_backface('FALSE') if (self.params.orientation_iv == True): self.performerScene.set_orientation_iv('TRUE') else: self.performerScene.set_orientation_iv('FALSE') if (self.params.convert_xforms_iv == True): self.performerScene.set_convert_xforms_iv('TRUE') else: self.performerScene.set_convert_xforms_iv('FALSE') _infoer.write(" finished")
def takeSnapshot(self): _infoer.function = str(self.takeSnapshot) _infoer.write("") filename = "" if covise.coConfigIsOn("vr-prepare.ShowSnapshotDialog", True): directory = covise.getCoConfigEntry( "COVER.Plugin.PBufferSnapShot.Directory") if (directory == None): directory = "snapshot.png" else: directory = directory + "/" + "snapshot.png" filenameQt = QtWidgets.QFileDialog.getSaveFileName( self, self.__tr('Snapshot'), directory, self.__tr('Image (*.png)'), None, QtWidgets.QFileDialog.DontConfirmOverwrite) if filenameQt == "": return #filenameQt is filename + extension touple filename = filenameQt[0] print(filename) if not filename.lower().endswith(".png"): filename += ".png" if os.path.exists(filename): asker = ReallyWantToOverrideAsker(self, filename) decicion = asker.exec_() if decicion == QtWidgets.QDialog.Rejected: self.statusBar().showMessage( self.__tr('Cancelled overwrite of "%s"') % filename) return msg = coGRSnapshotMsg(filename, "snapOnce") covise.sendRendMsg(msg.c_str())
def sendLoadingFinishedUdpMessage(): '''Sends a message to Cyber-Classroom Ogre menu to stop loading-in-progress-screen.''' magicString = covise.getCoConfigEntry("vr-prepare.CCIntroUDP.MagicString") if not magicString: magicString = "CC_MOD_READY" magicPort = covise.getCoConfigEntry("vr-prepare.CCIntroUDP.MagicPort") if not magicPort: magicPort = "44449" destinationHost = covise.getCoConfigEntry("vr-prepare.CCIntroUDP.DestinationHost") if not destinationHost: destinationHost = "127.0.0.1" print("Sending", magicString, "to", destinationHost, magicPort) sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) sock.sendto( bytes(magicString, 'utf-8'), (destinationHost, int(magicPort)) )
def __init__(self): PartCuttingSurfaceVis.__init__(self,['GridIn0'],['GridIn1'],['DataIn4'],['DataIn0'], MAX_FLT) self.params = PartPlaneVisParams() self.params.name = 'Plane' NameColoredCuttingSurface = covise.getCoConfigEntry("vr-prepare.NameColoredCuttingSurface") if NameColoredCuttingSurface: self.params.name = NameColoredCuttingSurface self.params.option = 1 self.params.vector = 2
def sendLoadingFinishedUdpMessage(): '''Sends a message to Cyber-Classroom Ogre menu to stop loading-in-progress-screen.''' magicString = covise.getCoConfigEntry("vr-prepare.CCIntroUDP.MagicString") if not magicString: magicString = "CC_MOD_READY" magicPort = covise.getCoConfigEntry("vr-prepare.CCIntroUDP.MagicPort") if not magicPort: magicPort = "44449" destinationHost = covise.getCoConfigEntry( "vr-prepare.CCIntroUDP.DestinationHost") if not destinationHost: destinationHost = "127.0.0.1" print("Sending", magicString, "to", destinationHost, magicPort) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(bytes(magicString, 'utf-8'), (destinationHost, int(magicPort)))
def __init__(self, parent=None): Ui_GettingStartedWindowBase.__init__(self, parent) self.setupUi(self) str = "file:///" str = str + os.path.dirname(__file__) str = str + "/documents/" config = covise.getCoConfigEntry("vr-prepare.GettingStartedDocument") if config == None: config = "GettingStarted/index.html" str = str + config self.textBrowser.setSource(QtCore.QUrl(str))
def __init__(self): PartCuttingSurfaceVis.__init__(self, ['GridIn0'], ['GridIn1'], ['DataIn4'], ['DataIn0'], MAX_FLT) self.params = PartPlaneVisParams() self.params.name = 'Plane' NameColoredCuttingSurface = covise.getCoConfigEntry( "vr-prepare.NameColoredCuttingSurface") if NameColoredCuttingSurface: self.params.name = NameColoredCuttingSurface self.params.option = 1 self.params.vector = 2
def __readButtonConfig(self): # read buttons from config buttonList = covise.getCoConfigSubEntries("vr-prepare.TrackingManager.ButtonMap") completeButtonList = ['TRANS_LEFT', 'TRANS_RIGHT', 'TRANS_UP', 'TRANS_DOWN', 'TRANS_FRONT', 'TRANS_BACK', \ 'ROT_X_MINUS', 'ROT_X_PLUS', 'ROT_Y_MINUS', 'ROT_Y_PLUS', 'ROT_Z_MINUS', 'ROT_Z_PLUS', \ 'SCALE_PLUS', 'SCALE_MINUS'] for b in buttonList: if b in completeButtonList: self.__dict__[b] = int(covise.getCoConfigEntry("vr-prepare.TrackingManager.ButtonMap." + b, "button")) # if not all buttons are described in config.vr-prepare.xml for b in completeButtonList: if not b in self.__dict__.keys(): self.__dict__[b] = -1 TranslateBarrier = covise.getCoConfigEntry("vr-prepare.TrackingManager.TranslateBarrier") if TranslateBarrier: self.TranslateBarrier = float(TranslateBarrier) else: self.TranslateBarrier = 1.0 self.VRCJoystick = covise.coConfigIsOn("vr-prepare.TrackingManager.VRCJoystick", False) # buttons for vrml sensors ButtonSensor1 = covise.getCoConfigEntry("vr-prepare.TrackingManager.ButtonSensor1") ButtonSensor2 = covise.getCoConfigEntry("vr-prepare.TrackingManager.ButtonSensor2") if ButtonSensor1: self.BUTTON_SENSOR_1 = int(ButtonSensor1) else: self.BUTTON_SENSOR_1 = -1 if ButtonSensor2: self.BUTTON_SENSOR_2 = int(ButtonSensor2) else: self.BUTTON_SENSOR_2 = -1 WrlName = covise.getCoConfigEntry("vr-prepare.TrackingManager.WrlName") if WrlName: self.wrl_name = WrlName else: self.wrl_name = ""
def __setupTimeout(self): self.__1sTimer = QtCore.QTimer() self.__idleTimeElapsed = 0 # elapsed idle time in seconds self.__oldVRCInput = VRCInput() self.__negMsgHandler = None # store a reference to the negotiator to send keywords self.__1sTimer.timeout.connect(self.__1sTimerTimeout) VRCTimeout = covise.getCoConfigEntry("vr-prepare.TrackingManager.VRCTimeout") if VRCTimeout and int(VRCTimeout) != 0: self.__VRCTimeout = int(VRCTimeout) self.__1sTimer.start(1000)
def turntableAnimation(self): _infoer.function = str(self.turntableAnimation) _infoer.write("") time = covise.getCoConfigEntry("vr-prepare.TurntableAnimationTime") fTime = 10.0 if (time != None): try: fTime = float(time) except exception.ValueError: pass msg = coGRTurnTableAnimationMsg(fTime) covise.sendRendMsg(msg.c_str())
def __init__(self): # start cutting suface not on sampled grid if not covise.coConfigIsOn("vr-prepare.ArrowsOnSampledGrid", True) or not covise.coConfigIsOn("vr-prepare.UseSamplingModules", False): PartCuttingSurfaceVis.__init__(self, ['GridIn0'], [], [], ['DataIn0'], USER_DEFINED) # start cutting surface on sampled grid else: PartCuttingSurfaceVis.__init__(self, [], ['GridIn0'], ['DataIn0'], [], USER_DEFINED) self.params = PartVectorVisParams() self.params.name = 'Arrows' NameArrowsCuttingSurface = covise.getCoConfigEntry("vr-prepare.NameArrowsCuttingSurface") if NameArrowsCuttingSurface: self.params.name = NameArrowsCuttingSurface self.params.option = 1 self.params.vector = 3
def getColor(parent=None, color=None, palette=None): colors = [] # list of (name, (color tuple)) if (palette != None): entries = covise.getCoConfigSubEntries("vr-prepare.ColorPalette:" + palette) for entry in entries: name = entry.split(":")[-1] color = covise.getCoConfigEntry("vr-prepare.ColorPalette:" + palette + "." + entry) color = tuple([int(v) for v in color.split()]) colors.append((name, color)) if (len(colors) == 0): entries = covise.getCoConfigSubEntries("vr-prepare.ColorPalette") for entry in entries: name = entry.split(":")[-1] color = covise.getCoConfigEntry("vr-prepare.ColorPalette." + entry) color = tuple([int(v) for v in color.split()]) colors.append((name, color)) if (len(colors) > 0): cc = ColorChooser(parent) for (name, color) in colors: cc.addColor(name, color) cc.exec_() return cc.selectedColor # no palette, use default dialog if color == None: newcolor = QtWidgets.QColorDialog.getColor(parent) else: newcolor = QtWidgets.QColorDialog.getColor(QtGui.QColor(color[0], color[1], color[2]),parent) if newcolor.isValid(): return (newcolor.red(), newcolor.green(), newcolor.blue(), color[3]) else: return None
def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") QtWidgets.QWidget.__init__(self, parent) Ui_DataSetsSelectionBase.__init__(self) self.setupUi(self) self._caseFilenames = [] self._datasetFilenames = [] self.ServerhostcheckBox.setChecked(False) self.ServerhostcheckBox.setEnabled(False) self.ServerhostcheckBox.hide() self.__cocaseFilenameSuggestion = covise.getCoConfigEntry("vr-prepare.InitialDatasetSearchPath") if not self.__cocaseFilenameSuggestion: self.__cocaseFilenameSuggestion = os.getcwd()
def __setRightDomainEnabling(self, isPartChoice): _infoer.function = str(self.__setRightDomainEnabling) _infoer.write("") self.comboBoxDomain.setEnabled(isPartChoice) if not self.checkBoxFreeStartpoints.isChecked(): self.groupBoxRectPositioning.setEnabled(not isPartChoice) if self.checkBoxDomainFromList.isChecked(): #quick fix show/hide tracer self.checkBox5.setChecked(False) TraceFrom2DStyle = covise.getCoConfigEntry("vr-prepare.TraceFrom2DStyle") if TraceFrom2DStyle and TraceFrom2DStyle == "TRACE_FROM_2D_SAMPLE": pass else : self.numberStartpoints.setEnabled(not isPartChoice) # change interactor checkbox self.checkBox5.setEnabled(not isPartChoice) self.vrpCheckBoxShow.setEnabled((not isPartChoice) and COMPOSED_VELOCITY!=str(self.vrpLineEditVariable.text())) if isPartChoice: self.checkBoxFreeStartpoints.setChecked(False)
def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") QtWidgets.QWidget.__init__(self, parent) Ui_DataSetsSelectionBase.__init__(self) self.setupUi(self) self._caseFilenames = [] self._datasetFilenames = [] self.ServerhostcheckBox.setChecked(False) self.ServerhostcheckBox.setEnabled(False) self.ServerhostcheckBox.hide() self.__cocaseFilenameSuggestion = covise.getCoConfigEntry( "vr-prepare.InitialDatasetSearchPath") if not self.__cocaseFilenameSuggestion: self.__cocaseFilenameSuggestion = os.getcwd()
def __init__(self): # start cutting suface not on sampled grid if not covise.coConfigIsOn("vr-prepare.ArrowsOnSampledGrid", True) or not covise.coConfigIsOn( "vr-prepare.UseSamplingModules", False): PartCuttingSurfaceVis.__init__(self, ['GridIn0'], [], [], ['DataIn0'], USER_DEFINED) # start cutting surface on sampled grid else: PartCuttingSurfaceVis.__init__(self, [], ['GridIn0'], ['DataIn0'], [], USER_DEFINED) self.params = PartVectorVisParams() self.params.name = 'Arrows' NameArrowsCuttingSurface = covise.getCoConfigEntry( "vr-prepare.NameArrowsCuttingSurface") if NameArrowsCuttingSurface: self.params.name = NameArrowsCuttingSurface self.params.option = 1 self.params.vector = 3
def letUserAddCasefilename(self): _infoer.function = str(self.letUserAddCasefilename) _infoer.write("") #filetypes = 'Case-files (*.cocase)\n' filetypes = Utils.getImportFileTypes() filenamesQt = QtWidgets.QFileDialog.getOpenFileNames( self, self.__tr('Add Datasets'), self.__cocaseFilenameSuggestion, filetypes) if filenamesQt == "": self.statusMessage.emit(('Choosing filename cancelled',)) return for filenameQt in filenamesQt: filename = str(filenameQt) load = True if not os.access(filename, os.R_OK): QtWidgets.QMessageBox.information( self, covise.getCoConfigEntry("vr-prepare.ProductName"), self.__tr("The file \"") + filenameQt + self.__tr("\" is not accessable.\n") + self.__tr("You may check the permissions."), self.__tr("&Ok"), "", "", 0, 0) load = False #return if load: if str(filenameQt).endswith(".cocase") : self.addCasefilename(str(filenameQt)) elif os.path.splitext(str(filenameQt))[1].lower() in Utils.getImportFileTypesFlat(): self.addDatasetFilename(str(filenameQt)) else: print("Warning: Trying to add file of unknown type: ", str(filenameQt)) self.__cocaseFilenameSuggestion = str(filenameQt)
def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") Ui_CoxmlBrowserPanelBase.__init__(self, parent) self.setupUi(self) self.__mainWidget = None self.__pattern = re.compile(".*\.coxml$") # add a box for the widgets in the filterArea (ScrollArea). self.filterBox = QtWidgets.QFrame(self.filterArea) self.filterArea.setWidget(self.filterBox) # product line mapping from buttons to names in the coxml self.plButtonMapping = { self.plButton1: u"Room", self.plButton2: u"Tables", self.plButton3: u"Lights", self.plButton4: u"Ceiling Pendants", self.plButton5: u"Medical Equipment", self.plButton6: u"Accessories" } self.plButton7.setVisible(False) # we only have 6 product lines # tooltips for b, s in iter(self.plButtonMapping.items()): b.setToolTip(s) self.resourceDir = covise.getCoConfigEntry( "vr-prepare.Coxml.ResourceDirectory") if (self.resourceDir != None): self.coxmlDir = self.resourceDir + "/coxml/" self.__readDatabase() self.__setProductLine(u"Room") CoxmlBrowserPanelConnector(self)
def __update(self): """ __update is called from the run method to update the module parameter before execution + update module parameters """ _infoer.function = str(self.__update) _infoer.write(" ") if self.performerScene==None: self.performerScene = PerformerScene() theNet().add(self.performerScene) # update params self.performerScene.set_modelPath( covise.getCoConfigEntry("vr-prepare.Coxml.ResourceDirectory") + "/coxml/" + self.params.filename ) self.performerScene.set_scale(self.params.scale) if (self.params.backface == True): self.performerScene.set_backface('TRUE') else: self.performerScene.set_backface('FALSE') if (self.params.orientation_iv == True): self.performerScene.set_orientation_iv('TRUE') else: self.performerScene.set_orientation_iv('FALSE') if (self.params.convert_xforms_iv == True): self.performerScene.set_convert_xforms_iv('TRUE') else: self.performerScene.set_convert_xforms_iv('FALSE') _infoer.write(" finished")
def __init__(self): #print "Ensight2CoviseGui.__init__" # init base class Ensight2CoviseGuiBase.__init__(self, None) # connect buttons self.outputDirLineEdit.returnPressed.connect(self.setOutputDir) self.byteswapped.stateChanged.connect(self.setByteswap) self.startConversionPushButton.clicked.connect(self.startConversion) # initialize output directory InitialDatasetSearchPath = covise.getCoConfigEntry("vr-prepare.InitialDatasetSearchPath") if not InitialDatasetSearchPath: InitialDatasetSearchPath = os.getcwd() self.currentFilePath = InitialDatasetSearchPath self.scale = 1.0 # disable all buttons at beginning self.settingsFrame.setEnabled(False) self.startConversionFrame.setEnabled(False) self.outputDirFrame.setEnabled(False) self.isByteSwapped = True
def __init__(self, parent): QtWidgets.QDockWidget.__init__(self, coTranslate("Video Capture Manager"), parent) self.setWidget(VideoCaptureManagerBase(self)) #connection of the DockWidget visibilityChanged self.visibilityChanged.connect(self.visibilityChangedS) # connection of buttons self.widget().buttonCapture.clicked.connect(self.capture) self.widget().buttonPreview.clicked.connect(self.startPreview) self.widget().comboBox.activated.connect(self.selectMode) # connect open self.widget().pushButton.clicked.connect(self.openFile) # connect filename self.widget().lineEdit.returnPressed.connect(self.setFilename) self.widget().lineEdit.editingFinished.connect(self.checkFilename) self.widget().groupSettings.setVisible(True) self.widget().groupCapturing.setVisible(True) #self.recording = False; self.filename = "C:\capture.wmv" if covise.coConfigIsOn("COVER.Plugin.Video", False): filename = covise.getCoConfigEntry("COVER.Plugin.Video.Filename") if filename: self.filename = filename self.widget().lineEdit.setText(self.filename) self.oldFilename = self.filename self.freeCapture = False self.mode = 0
def parseCoxml(self): # open coxml dom = xml.dom.minidom.parse(covise.getCoConfigEntry("vr-prepare.Coxml.ResourceDirectory") + "/coxml/" + self.params.filename) # Class classElems = dom.getElementsByTagName("class") if len(classElems) > 0: self.params.classname = classElems[0].getAttribute("value") # Classification classificationElems = dom.getElementsByTagName("classification") if len(classificationElems) > 0: classificationElem = classificationElems[0] # name elems = classificationElem.getElementsByTagName("name") if len(elems) > 0: self.params.name = unicode(elems[0].getAttribute("value")) # product_line elems = classificationElem.getElementsByTagName("product_line") if len(elems) > 0: self.params.product_line = unicode(elems[0].getAttribute("value")) # model elems = classificationElem.getElementsByTagName("model") if len(elems) > 0: self.params.model = unicode(elems[0].getAttribute("value")) # description elems = classificationElem.getElementsByTagName("description") if (len(elems) > 0) and (elems[0].firstChild != None) and (elems[0].firstChild.nodeType == xml.dom.Node.TEXT_NODE): self.params.description = unicode(elems[0].firstChild.data) # Behaviors behaviorElems = dom.getElementsByTagName("behavior") if len(behaviorElems) > 0: for behaviorElem in behaviorElems[0].childNodes: if behaviorElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: self.params.behaviors.append(behaviorElem.nodeName) # VariantBehavior if (behaviorElem.nodeName == "VariantBehavior"): for groupElem in behaviorElem.childNodes: if groupElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: # group groupName = groupElem.getAttribute("name") variants = [] for variantElem in groupElem.childNodes: if variantElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: #variant variantName = variantElem.getAttribute("name") variants.append(variantName) if (groupName not in self.params.variant_selected): self.params.variant_selected[groupName] = variantName self.params.variant_groups[groupName] = variants # AppearanceBehavior if (behaviorElem.nodeName == "AppearanceBehavior"): for scopeElem in behaviorElem.childNodes: if scopeElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: # scope scopeName = scopeElem.getAttribute("name") # search color and palette for colorElem in scopeElem.childNodes: if colorElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE and colorElem.nodeName == "color": # color values = colorElem.getAttribute("value") color = tuple([int(float(v)*255.0) for v in values.split()]) if (len(color) == 4): self.params.appearance_colors[scopeName] = color elif colorElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE and colorElem.nodeName == "palette": # palette value = str(colorElem.getAttribute("value")) self.params.appearance_palettes[scopeName] = value # Misc geometryElems = dom.getElementsByTagName("geometry") if len(geometryElems) > 0: geometryElem = geometryElems[0] # width elems = geometryElem.getElementsByTagName("width") if len(elems) > 0: try: self.params.width = float(elems[0].getAttribute("value")) except: self.params.width = None # height elems = geometryElem.getElementsByTagName("height") if len(elems) > 0: try: self.params.height = float(elems[0].getAttribute("value")) except: self.params.height = None # length elems = geometryElem.getElementsByTagName("length") if len(elems) > 0: try: self.params.length = float(elems[0].getAttribute("value")) except: self.params.length = None
def __init__(self): InitialDatasetSearchPath = covise.getCoConfigEntry("vr-prepare.InitialDatasetSearchPath") if not InitialDatasetSearchPath: InitialDatasetSearchPath = os.getcwd() self.currentFilePath = InitialDatasetSearchPath self.ReadCfx_1 = 'None' self.scale=1.0 self.mirror=0 # 0=none, 1=X, 2=Y, 3=Z self.rotAxisX=1.0 self.rotAxisY=1.0 self.rotAxisZ=1.0 self.rotAngle=0.0 self.composedGrid = False self.noGrid = False self.processBoundaries = True self.numVariables = 0 self.fixdomain = "None" self.calculatePDYNFlag = False self.domains=[] self.coCaseFile = "None" self.reduce = False self.reductionFactor = 40.0 # # init base class # Cfx2CoviseGuiBase.__init__(self, None) # # remove unused menubar items # self.fileNewAction.setVisible(False) # # disable all buttons # self.gridFrame.setEnabled(False) self.reduceFrame.setEnabled(False) self.variableFrame.setEnabled(False) self.settingsFrame.setEnabled(False) self.startConversionFrame.setEnabled(False) self.outputDirFrame.setEnabled(False) # # register error log action # self.aErrorLogAction = ErrorLogAction() CoviseMsgLoop().register(self.aErrorLogAction) self.aErrorLogAction.register(self) # # register action to read message and boundaries self.aBoundaryCollectorAction = BoundariesCollectorAction() CoviseMsgLoop().register(self.aBoundaryCollectorAction) # # register choice action # self.domainsGetterAction = ChoiceGetterAction() self.RegionsSelectionGetterAction = ChoiceGetterAction() self.BoundarySelectionGetterAction = ChoiceGetterAction() self.scalar_dataGetterAction = ChoiceGetterAction() self.vector_dataGetterAction = ChoiceGetterAction() self.timestepsGetterAction = IntGetterAction() #self.first_timestepGetterAction = ChoiceGetterAction() #self.readGridGetterAction = ChoiceGetterAction() #self.readRegionsGetterAction = ChoiceGetterAction() #self.readBoundariesGetterAction = ChoiceGetterAction() self.boundary_scalar_dataGetterAction = ChoiceGetterAction() self.boundary_vector_dataGetterAction = ChoiceGetterAction() #self.grid_is_time_dependentGetterAction = ChoiceGetterAction() #self.zone_with_time_dependent_gridGetterAction = ChoiceGetterAction() #self.rotAxisGetterAction = ChoiceGetterAction() #self.point_on_rotAxisGetterAction = ChoiceGetterAction() #self.rot_Angle_pre_timestepGetterAction = ChoiceGetterAction() #self.transform_velocityGetterAction = ChoiceGetterAction() #self.transform_directionGetterAction = ChoiceGetterAction() #self.rotation_axisGetterAction = ChoiceGetterAction() #self.zone_to_transform_velocityGetterAction = ChoiceGetterAction() #self.angular_velocityGetterAction = ChoiceGetterAction() #self.rotate_velocityGetterAction = ChoiceGetterAction() self.domainsGetterAction.register(self) self.RegionsSelectionGetterAction.register(self) self.BoundarySelectionGetterAction.register(self) self.scalar_dataGetterAction.register(self) self.vector_dataGetterAction.register(self) #self.timestepsGetterAction.register(self) #self.first_timestepGetterAction.register(self) #self.readGridGetterAction.register(self) #self.readRegionsGetterAction.register(self) #self.readBoundariesGetterAction.register(self) self.boundary_scalar_dataGetterAction.register(self) self.boundary_vector_dataGetterAction.register(self) #self.grid_is_time_dependentGetterAction.register(self) #self.zone_with_time_dependent_gridGetterAction.register(self) #self.rotAxisGetterAction.register(self) #self.point_on_rotAxisGetterAction.register(self) #self.rot_Angle_pre_timestepGetterAction.register(self) #self.transform_velocityGetterAction.register(self) #self.transform_directionGetterAction.register(self) #self.rotation_axisGetterAction.register(self) #self.zone_to_transform_velocityGetterAction.register(self) #self.angular_velocityGetterAction.register(self) #self.rotate_velocityGetterAction.register(self) global theNet theNet = net() # # MODULE: ReadCfx # self.ReadCfx_1 = ReadCFX() theNet.add( self.ReadCfx_1 ) # # hang in variable-getters # self.ReadCfx_1.addNotifier('domains',self.domainsGetterAction) self.ReadCfx_1.addNotifier('RegionsSelection',self.RegionsSelectionGetterAction) self.ReadCfx_1.addNotifier('BoundarySelection',self.BoundarySelectionGetterAction) self.ReadCfx_1.addNotifier('scalar_data',self.scalar_dataGetterAction) self.ReadCfx_1.addNotifier('vector_data',self.vector_dataGetterAction) self.ReadCfx_1.addNotifier('timesteps',self.timestepsGetterAction) #self.ReadCfx_1.addNotifier('first_timestep',self.first_timestepGetterAction) #self.ReadCfx_1.addNotifier('readGrid',self.readGridGetterAction) #self.ReadCfx_1.addNotifier('readRegions',self.readRegionsGetterAction) #self.ReadCfx_1.addNotifier('readBoundaries',self.readBoundariesGetterAction) self.ReadCfx_1.addNotifier('boundary_scalar_data',self.boundary_scalar_dataGetterAction) self.ReadCfx_1.addNotifier('boundary_vector_data',self.boundary_vector_dataGetterAction) #self.ReadCfx_1.addNotifier('grid_is_time_dependent',self.grid_is_time_dependentGetterAction) #self.ReadCfx_1.addNotifier('zone_with_time_dependent_grid',self.zone_with_time_dependent_gridGetterAction) #self.ReadCfx_1.addNotifier('rotAxis',self.rotAxisGetterAction) #self.ReadCfx_1.addNotifier('point_on_rotAxis',self.point_on_rotAxisGetterAction) #self.ReadCfx_1.addNotifier('rot_Angle_pre_timestep',self.rot_Angle_pre_timestepGetterAction) #self.ReadCfx_1.addNotifier('transform_velocity',self.transform_velocityGetterAction) #self.ReadCfx_1.addNotifier('transform_direction',self.transform_directionGetterAction) #self.ReadCfx_1.addNotifier('rotation_axis',self.rotation_axisGetterAction) #self.ReadCfx_1.addNotifier('zone_to_transform_velocity',self.zone_to_transform_velocityGetterAction) #self.ReadCfx_1.addNotifier('angular_velocity',self.angular_velocityGetterAction) #self.ReadCfx_1.addNotifier('rotate_velocity',self.rotate_velocityGetterAction) # # connect buttons # self.cbNoGrid.stateChanged.connect(self.setNoGrid) self.cbNoGrid.stateChanged.connect(self.setComposedGrid) self.cbNoGrid.stateChanged.connect(self.setTransientGrid) self.cbNoGrid.currentIndexChanged.connect(self.setNumVar) self.cbNoGrid.stateChanged.connect(self.setPdyn) self.cbNoGrid.stateChanged.connect(self.setNoBound) self.cbNoGrid.currentIndexChanged.connect(self.setDomain) self.cbNoGrid.returnPressed.connect(self.setOutputDir) self.cbNoGrid.clicked.connect(self.addToCoCase) self.cbNoGrid.clicked.connect(self.startConversion)
def sendImagePathToWebserver(self): if covise.coConfigIsOn("vr-prepare.RemoteDeviceControll", False) and self.params.imageName != None: import os import vtrans import PathTranslator # starting point of # image path processing imageName = self.params.imageName sNum = '1' # compute the image corresponding to step number imageName = imageName.replace('\\', '/') ## just to be shure imageName = imageName.replace(os.sep, '/') pos = imageName.rfind('/') if pos >= 0: dirName = imageName[:pos] baseName = imageName[pos + 1:] imageNumber = int(self.params.pageNo) imageSuffix = '' nPos = baseName.rfind('.') if nPos >= 0: sNum = baseName[:nPos] imageSuffix = baseName[nPos + 1:] iNum = int(sNum) # for backward compatibility # in cc versions lesser than 3.2 # images were alloed to start with zero (0.png) if iNum == 0: imageNumber = int(self.params.pageNo) - 1 #compose all back togerther imageName = dirName + '/' + str( imageNumber) + '.' + imageSuffix # get the language environment settings coPath = vtrans.covisePath localePrefix = covise.getCoConfigEntry( "COVER.Localization.LocalePrefix") languageLocale = vtrans.languageLocale loc = localePrefix + "/" + languageLocale fullPathToImage = coPath + "/" + imageName # retrieve localized path fullPathToImage = PathTranslator.translate_path( loc, fullPathToImage) # retrieve relative path again imageName = fullPathToImage[len(coPath) + 1:] path_to_current_image = imageName # again... # this time for the browser # compute the image corresponding to step number path_to_current_image = path_to_current_image.replace('\\', '/') ## just to be shure path_to_current_image = path_to_current_image.replace(os.sep, '/') # pack the message msg = 'VRT IMAGE ' + path_to_current_image + '.' + str( self.params.maxPage) + '.' + sNum # send it away destinationHost = covise.getCoConfigEntry( "vr-prepare.RemoteDeviceHost") if not destinationHost: destinationHost = "127.0.0.1" destinationPort = covise.getCoConfigEntry( "vr-prepare.RemoteDevicePort") if not destinationPort: destinationPort = "44142" sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(str(msg), (destinationHost, int(destinationPort)))
def __setParams( self, params ): """ set update the panel with the information in the negotiator param class """ _infoer.function = str(self.__setParams) _infoer.write("") StreamlinesPanelBlockSignals( self, True ) # int is always the key # TODO CHANGE if isinstance( params, int): self.__key = params return self.__taskType = params.taskType if params.taskType == MOVING_POINTS: self.textTubeWidth.hide() self.TubeWidth.hide() else: self.TubeWidth.show() self.textTubeWidth.show() if hasattr(params, 'start_style'): if params.start_style != FREE: self.__startStyle = params.start_style self.__panelAccordingTaskType() if hasattr(params, 'numSteps'): self.NumberOfSteps.setText(str(params.numSteps)) if hasattr(params, 'duration'): self.DurationOfSteps.setText(str(params.duration)) if hasattr(params, 'sphereRadius'): self.RadiusOfSpheres.setText(str(params.sphereRadius)) else: self.RadiusOfSpheres.setText("0.2") if hasattr(params, 'tubeWidth'): self.TubeWidth.setText(str(params.tubeWidth)) else: self.TubeWidth.setText("0.0") self.nameWidget.setText(params.name) if hasattr(params, 'isVisible' ): self.visibilityCheckBox.setChecked(params.isVisible) if hasattr(params, 'variable' ): self.vrpLineEditVariable.setText(params.variable) if params.secondVariable!=None: self.vrpCheckBoxMapVariable.setChecked(True) self.vrpComboBoxVariable.setCurrentIndex(self.vrpComboBoxVariable.findText(params.secondVariable)) currentVariable = params.secondVariable else: self.vrpCheckBoxMapVariable.setChecked(False) currentVariable = params.variable if hasattr(params, 'start_style'): if params.start_style==3: self.checkBoxFreeStartpoints.setChecked(True) else: self.checkBoxFreeStartpoints.setChecked(False) self.__baseVariable = currentVariable currentColorTableKey = None if currentVariable!=None and params.colorTableKey!=None and currentVariable in params.colorTableKey: currentColorTableKey = params.colorTableKey[currentVariable] MainWindow.globalColorManager.update( self.colorMapCombobox, currentVariable, currentColorTableKey) if hasattr(params.boundingBox, 'getXMin' ): self.__boundingBox = params.boundingBox if self.__startStyle == PLANE: self.__rectangleManager.setBoundingBox( params.boundingBox ) elif self.__startStyle == LINE: self.__rectangleManager.setBoundingBox( params.boundingBox, LINE ) else: self.__rectangleManager.setBoundingBox( params.boundingBox ) if self.__startStyle == PLANE: self.__rectangleManager.setRectangle( params.alignedRectangle ) elif self.__startStyle == LINE: #self.__rectangleManager.setLine( params.lines3D ) self.__rectangleManager.setLine( params.alignedRectangle ) else: self.__rectangleManager.setRectangle( params.alignedRectangle ) self.numberStartpoints.setText(str(params.no_startp)) self.lengthTraces.setText(str(params.len)) self.tracingDirectionCB.setCurrentIndex(params.direction-1) self.vrpLineEditRelativeErrors.setText(str(params.eps)) self.vrpLineEditAbsoluteErrors.setText(str(params.abs)) self.vrpLineEditGridTolerance.setText(str(params.grid_tol)) self.vrpLineEditMinimumValue.setText(str(params.min_vel)) self.vrpLineEditMinimumValue_2.setText(str(params.maxOutOfDomain)) self.vrpCheckBoxShow.setChecked(params.showSmoke) self.checkBox5.setChecked(params.showInteractor) self.colorCreator=params.colorTableKey if (params.use2DPartKey==None) or (self.comboBoxDomain.count() == 1): self.checkBoxDomainFromList.setChecked(False) else : self.checkBoxDomainFromList.setChecked(True) if params.use2DPartKey in self.__key2UsePartIdx: self.comboBoxDomain.setCurrentIndex( self.__key2UsePartIdx[params.use2DPartKey] ) else : self.comboBoxDomain.setCurrentIndex( 0 ) self.__setRightDomainEnabling(self.checkBoxDomainFromList.isChecked()) if hasattr(params, 'tubeWidth'): if params.secondVariable != None and params.tubeWidth <= 0.0: self.vrpCheckBoxMapVariable.setEnabled(True) self.vrpComboBoxVariable.setEnabled(True) self.TubeWidth.setEnabled(False) elif params.secondVariable == None and params.tubeWidth > 0.0: self.vrpCheckBoxMapVariable.setEnabled(False) self.vrpComboBoxVariable.setEnabled(False) self.TubeWidth.setEnabled(True) elif params.secondVariable == None and params.tubeWidth <= 0.0: self.vrpCheckBoxMapVariable.setEnabled(True) self.vrpComboBoxVariable.setEnabled(True) self.TubeWidth.setEnabled(True) else: print("ERROR: Tube width > 0 and mapping of 2nd variable not supported") # show qLabel RadiusOfSpheres only if COMPLEX_OBJECT_TYPE is BAR_MAGNET or COMPASS # and if tube width is changed self.textRadiusOfSpheres.hide() self.RadiusOfSpheres.hide() if self.__taskType==PATHLINES and self.TubeWidth.text() != "0.0": complexObjetType = covise.getCoConfigEntry('TRACERConfig.COMPLEX_OBJECT_TYPE') if (complexObjetType == 'BAR_MAGNET') or (complexObjetType == 'COMPASS'): self.textRadiusOfSpheres.show() self.RadiusOfSpheres.show() StreamlinesPanelBlockSignals( self, False )
# # Translation functions for vr-prepare # Visenso GmbH # (c) 2012 # # $Id: vtrans.py 785 2014-09-02 08:23:06Z wlukutin $ import gettext import covise import os import sys covisePath = os.getenv("COVISE_PATH") vrPrepareDomain = covise.getCoConfigEntry("COVER.Localization.VrPrepareDomain") localePrefix = covise.getCoConfigEntry("COVER.Localization.LocalePrefix") languageLocale = covise.getCoConfigEntry("COVER.Localization.LanguageLocale") if vrPrepareDomain == None: vrPrepareDomain = "vr-prepare" if localePrefix == None: localePrefix = "share" + os.sep + "locale" if languageLocale == None: languageLocale = "de" print(covisePath) if covisePath != None and len(covisePath) > 0: if covisePath[len(covisePath) - 1] == ';': covisePath = covisePath[:-1]
from math import * from threading import * from coPyModules import * from CoviseMsgLoop import CoviseMsgLoop, CoviseMsgLoopAction from coviseModuleBase import * import time #-------- udpMode = False try: import covise from PyQt5.QtNetwork import QHostAddress, QUdpSocket # Set the socket parameters secondUDP_IP = covise.getCoConfigEntry("vr-prepare.SecondUDP.IP") if secondUDP_IP: host = QHostAddress(secondUDP_IP) else: host = QHostAddress("127.0.0.1") secondUDP_Port = covise.getCoConfigEntry("vr-prepare.SecondUDP.Port") if secondUDP_Port: port = int(secondUDP_Port) else: port = 6666 buf = 1024 addr = (host,port) # Create socket and bind to address if covise.coConfigIsOn("vr-prepare.SecondUDP"): UDPSock = QUdpSocket()
def setVRC(self, x, y, z, button, negMsgHandler = None): # recognize idle VRC inputs if ((self.__oldVRCInput.x == x) and (self.__oldVRCInput.y == y) and (self.__oldVRCInput.z == z) and (self.__oldVRCInput.button == button)): pass else: self.__idleTimeElapsed = 0 self.__oldVRCInput.x = x self.__oldVRCInput.y = y self.__oldVRCInput.z = z self.__oldVRCInput.button = button self.__negMsgHandler = negMsgHandler if not self.params.trackingGUIOn: return if self.VRCJoystick: temp = x x = -y y = -temp z = -z if self.params.oldX < x and x-self.params.oldX > self.TranslateBarrier: msg = coGRObjMoveObjMsg("", "translate", 0, -1, 0) self.params.oldX = x covise.sendRendMsg(msg.c_str()) elif self.params.oldX > x and self.params.oldX-x > self.TranslateBarrier: msg = coGRObjMoveObjMsg("", "translate", 0, 1, 0) self.params.oldX = x covise.sendRendMsg(msg.c_str()) if self.params.oldY < y and y-self.params.oldY > self.TranslateBarrier: msg = coGRObjMoveObjMsg("", "translate", -1, 0, 0) self.params.oldY = y covise.sendRendMsg(msg.c_str()) elif self.params.oldY > y and self.params.oldY-y > self.TranslateBarrier: msg = coGRObjMoveObjMsg("", "translate", 1, 0, 0) self.params.oldY = y covise.sendRendMsg(msg.c_str()) if self.params.oldZ < z and z-self.params.oldZ > self.TranslateBarrier: msg = coGRObjMoveObjMsg("", "translate", 0, 0, -1) self.params.oldZ = z covise.sendRendMsg(msg.c_str()) elif self.params.oldZ > z and self.params.oldZ-z > self.TranslateBarrier: msg = coGRObjMoveObjMsg("", "translate", 0, 0, 1) self.params.oldZ = z covise.sendRendMsg(msg.c_str()) if button == self.TRANS_LEFT: msg = coGRObjMoveObjMsg("", "translate", -1, 0, 0) covise.sendRendMsg(msg.c_str()) elif button == self.TRANS_RIGHT: msg = coGRObjMoveObjMsg("", "translate", 1, 0, 0) covise.sendRendMsg(msg.c_str()) elif button == self.TRANS_UP: msg = coGRObjMoveObjMsg("", "translate", 0, 0, 1) covise.sendRendMsg(msg.c_str()) elif button == self.TRANS_DOWN: msg = coGRObjMoveObjMsg("", "translate", 0, 0, -1) covise.sendRendMsg(msg.c_str()) elif button == self.TRANS_FRONT: msg = coGRObjMoveObjMsg("", "translate", 0, -1, 0) covise.sendRendMsg(msg.c_str()) elif button == self.TRANS_BACK: msg = coGRObjMoveObjMsg("", "translate", 0, 1, 0) covise.sendRendMsg(msg.c_str()) # rotation AND zoom must work simultaneously if button & self.ROT_X_PLUS == self.ROT_X_PLUS: msg = coGRObjMoveObjMsg("", "rotate", 1, 0, 0) covise.sendRendMsg(msg.c_str()) elif button & self.ROT_X_MINUS == self.ROT_X_MINUS: msg = coGRObjMoveObjMsg("", "rotate", -1, 0, 0) covise.sendRendMsg(msg.c_str()) elif button & self.ROT_Y_PLUS == self.ROT_Y_PLUS: msg = coGRObjMoveObjMsg("", "rotate", 0, 1, 0) covise.sendRendMsg(msg.c_str()) elif button & self.ROT_Y_MINUS == self.ROT_Y_MINUS: msg = coGRObjMoveObjMsg("", "rotate", 0, -1, 0) covise.sendRendMsg(msg.c_str()) elif button & self.ROT_Z_PLUS == self.ROT_Z_PLUS: msg = coGRObjMoveObjMsg("", "rotate", 0, 0, -1) covise.sendRendMsg(msg.c_str()) elif button & self.ROT_Z_MINUS == self.ROT_Z_MINUS: msg = coGRObjMoveObjMsg("", "rotate", 0, 0, 1) covise.sendRendMsg(msg.c_str()) if button & self.SCALE_PLUS == self.SCALE_PLUS: msg = coGRObjMoveObjMsg("", "scale", 1, 0, 0) covise.sendRendMsg(msg.c_str()) elif button & self.SCALE_MINUS == self.SCALE_MINUS: msg = coGRObjMoveObjMsg("", "scale", -1, 0, 0) covise.sendRendMsg(msg.c_str()) if button == self.BUTTON_SENSOR_1: msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, self.wrl_name, 0, True, True) covise.sendRendMsg(msg.c_str()) msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, self.wrl_name, 0, True, False) covise.sendRendMsg(msg.c_str()) if HAS_SOUND: winsound.PlaySound(None, winsound.SND_ASYNC) winsound.PlaySound(covise.getCoConfigEntry("vr-prepare.TrackingManager.ButtonSensor1Sound"), winsound.SND_ASYNC) elif button == self.BUTTON_SENSOR_2: msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, self.wrl_name, 1, True, True) covise.sendRendMsg(msg.c_str()) msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, self.wrl_name, 1, True, False) covise.sendRendMsg(msg.c_str()) if HAS_SOUND: winsound.PlaySound(None, winsound.SND_ASYNC) winsound.PlaySound(covise.getCoConfigEntry("vr-prepare.TrackingManager.ButtonSensor2Sound"), winsound.SND_ASYNC)
def parseCoxml(self): # open coxml dom = xml.dom.minidom.parse( covise.getCoConfigEntry("vr-prepare.Coxml.ResourceDirectory") + "/coxml/" + self.params.filename) # Class classElems = dom.getElementsByTagName("class") if len(classElems) > 0: self.params.classname = classElems[0].getAttribute("value") # Classification classificationElems = dom.getElementsByTagName("classification") if len(classificationElems) > 0: classificationElem = classificationElems[0] # name elems = classificationElem.getElementsByTagName("name") if len(elems) > 0: self.params.name = unicode(elems[0].getAttribute("value")) # product_line elems = classificationElem.getElementsByTagName("product_line") if len(elems) > 0: self.params.product_line = unicode( elems[0].getAttribute("value")) # model elems = classificationElem.getElementsByTagName("model") if len(elems) > 0: self.params.model = unicode(elems[0].getAttribute("value")) # description elems = classificationElem.getElementsByTagName("description") if (len(elems) > 0) and (elems[0].firstChild != None) and ( elems[0].firstChild.nodeType == xml.dom.Node.TEXT_NODE): self.params.description = unicode(elems[0].firstChild.data) # Behaviors behaviorElems = dom.getElementsByTagName("behavior") if len(behaviorElems) > 0: for behaviorElem in behaviorElems[0].childNodes: if behaviorElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: self.params.behaviors.append(behaviorElem.nodeName) # VariantBehavior if (behaviorElem.nodeName == "VariantBehavior"): for groupElem in behaviorElem.childNodes: if groupElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: # group groupName = groupElem.getAttribute("name") variants = [] for variantElem in groupElem.childNodes: if variantElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: #variant variantName = variantElem.getAttribute( "name") variants.append(variantName) if (groupName not in self.params.variant_selected): self.params.variant_selected[ groupName] = variantName self.params.variant_groups[ groupName] = variants # AppearanceBehavior if (behaviorElem.nodeName == "AppearanceBehavior"): for scopeElem in behaviorElem.childNodes: if scopeElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: # scope scopeName = scopeElem.getAttribute("name") # search color and palette for colorElem in scopeElem.childNodes: if colorElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE and colorElem.nodeName == "color": # color values = colorElem.getAttribute( "value") color = tuple([ int(float(v) * 255.0) for v in values.split() ]) if (len(color) == 4): self.params.appearance_colors[ scopeName] = color elif colorElem.nodeType == xml.dom.minidom.Node.ELEMENT_NODE and colorElem.nodeName == "palette": # palette value = str( colorElem.getAttribute("value")) self.params.appearance_palettes[ scopeName] = value # Misc geometryElems = dom.getElementsByTagName("geometry") if len(geometryElems) > 0: geometryElem = geometryElems[0] # width elems = geometryElem.getElementsByTagName("width") if len(elems) > 0: try: self.params.width = float(elems[0].getAttribute("value")) except: self.params.width = None # height elems = geometryElem.getElementsByTagName("height") if len(elems) > 0: try: self.params.height = float(elems[0].getAttribute("value")) except: self.params.height = None # length elems = geometryElem.getElementsByTagName("length") if len(elems) > 0: try: self.params.length = float(elems[0].getAttribute("value")) except: self.params.length = None
def restart(self): rendererRestartPreCommand = covise.getCoConfigEntry("vr-prepare.RendererRestartPreCommand") if rendererRestartPreCommand: os.system(rendererRestartPreCommand) self.__start()
from math import * from threading import * from coPyModules import * from CoviseMsgLoop import CoviseMsgLoop, CoviseMsgLoopAction from coviseModuleBase import * import time #-------- udpMode = False try: import covise from PyQt5.QtNetwork import QHostAddress, QUdpSocket # Set the socket parameters secondUDP_IP = covise.getCoConfigEntry("vr-prepare.SecondUDP.IP") if secondUDP_IP: host = QHostAddress(secondUDP_IP) else: host = QHostAddress("127.0.0.1") secondUDP_Port = covise.getCoConfigEntry("vr-prepare.SecondUDP.Port") if secondUDP_Port: port = int(secondUDP_Port) else: port = 6666 buf = 1024 addr = (host, port) # Create socket and bind to address if covise.coConfigIsOn("vr-prepare.SecondUDP"): UDPSock = QUdpSocket()
def sendImagePathToWebserver(self): if covise.coConfigIsOn("vr-prepare.RemoteDeviceControll", False) and self.params.imageName != None: import os import vtrans import PathTranslator # starting point of # image path processing imageName = self.params.imageName sNum = '1' # compute the image corresponding to step number imageName = imageName.replace('\\', '/') ## just to be shure imageName = imageName.replace(os.sep, '/') pos = imageName.rfind('/') if pos >= 0: dirName = imageName[:pos] baseName = imageName[pos+1:] imageNumber = int(self.params.pageNo) imageSuffix = '' nPos = baseName.rfind('.') if nPos >= 0: sNum = baseName[:nPos] imageSuffix = baseName[nPos+1:] iNum = int(sNum) # for backward compatibility # in cc versions lesser than 3.2 # images were alloed to start with zero (0.png) if iNum == 0: imageNumber = int(self.params.pageNo) - 1 #compose all back togerther imageName = dirName + '/' + str(imageNumber) + '.' + imageSuffix # get the language environment settings coPath = vtrans.covisePath localePrefix = covise.getCoConfigEntry("COVER.Localization.LocalePrefix") languageLocale = vtrans.languageLocale loc = localePrefix + "/" + languageLocale fullPathToImage = coPath + "/" +imageName # retrieve localized path fullPathToImage = PathTranslator.translate_path(loc, fullPathToImage) # retrieve relative path again imageName = fullPathToImage[len(coPath)+1:] path_to_current_image = imageName # again... # this time for the browser # compute the image corresponding to step number path_to_current_image = path_to_current_image.replace('\\', '/') ## just to be shure path_to_current_image = path_to_current_image.replace(os.sep, '/') # pack the message msg = 'VRT IMAGE ' + path_to_current_image + '.' + str(self.params.maxPage)+ '.' + sNum # send it away destinationHost = covise.getCoConfigEntry("vr-prepare.RemoteDeviceHost") if not destinationHost: destinationHost = "127.0.0.1" destinationPort = covise.getCoConfigEntry("vr-prepare.RemoteDevicePort") if not destinationPort: destinationPort = "44142" sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.sendto( str(msg),(destinationHost,int(destinationPort)) )