def setParams(self, params, negMsgHandler=None, sendToCover=True): """ set parameters from outside """ _infoer.function = str(self.setParams) _infoer.write("setParams") if not params.isVisible == self.params.isVisible: if params.isVisible and not self.__connected: connect(self.connectionPoint(), globalRenderer().connectionPoint()) self.__connected = True elif not params.isVisible and self.__connected: disconnect(self.connectionPoint(), globalRenderer().connectionPoint()) self.__connected = False realChange = ParamsDiff(self.params, params) VisItem.setParams(self, params, negMsgHandler, sendToCover) if params.clickedSensorID != None: msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, params.filename, params.clickedSensorID, True, True) covise.sendRendMsg(msg.c_str()) msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, params.filename, params.clickedSensorID, True, False) covise.sendRendMsg(msg.c_str()) # clickedSensorButtonEvent was handled and can be removed self.params.clickedSensorID = None self.sendParams()
def run(self, runmode, negMsgHandler=None): if runmode == RUN_ALL: _infoer.function = str(self.run) _infoer.write("go") self.__update() if not self.__connected and self.params.isVisible: VisItem.connectToCover(self, self) self.__connected = True if not self.__loaded: saveExecute(self.performerScene) self.__loaded = True # dont auto-activate sensors in recreation if negMsgHandler and negMsgHandler.getInRecreation() == False: # bei run() die sensoren starten # wird (ausserhalb von recreate) nur vom presentation manager aufgerufen for sensorID in self.params.autoActiveSensorIDs: msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, self.params.filename, sensorID, True, True) covise.sendRendMsg(msg.c_str()) msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, self.params.filename, sensorID, True, False) covise.sendRendMsg(msg.c_str())
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)