def on_exit(self): r.logInfo("EstateManagement exiting...") self.rexlogic.disconnect("OnIncomingEstateOwnerMessage(QVariantList)", self.onEstateOwnerMessage) self.uievents.isrunning = False self.window.on_exit() r.logInfo("EstateManagement done exiting...")
def __init__(self): Component.__init__(self) #loader = QUiLoader() uism = r.getUiSceneManager() #self.canvas = r.createCanvas(EXTERNAL) #group = QGroupBox() #box = QVBoxLayout(group) #button = QPushButton(group) #box.addWidget(button) #group.show() #self.canvas.AddWidget(group) lineedit = QLineEdit() self.widget = lineedit #lineedit.show() #uiprops = UiWidgetProperties("PythonQt Test") #uism.AddWidgetToScene(lineedit) #uiprops) #self.canvas.AddWidget(lineedit) uism = r.getUiSceneManager() uiprops = r.createUiWidgetProperty() uiprops.widget_name_ = "Test Widget" #uiprops.my_size_ = QSize(width, height) #self.proxywidget = uism.AddWidgetToScene(ui, uiprops) self.proxywidget = r.createUiProxyWidget(self.widget, uiprops) ##print widget, dir(widget) if not uism.AddProxyWidget(self.proxywidget): print "Adding the ProxyWidget to the bar failed." #self.canvas.Show() #QInputDialog.getText(None, "Mesh asset UUID", "Please give mesh asset UUID", QLineEdit.Normal, "") lineedit.connect('textChanged(QString)', self.changed) r.logInfo("TestGui inited.")
def __init__(self): Component.__init__(self) self.worldstream = None #self.worldstream = r.getServerConnection() self.queue = Queue.Queue() self.window = EstateManagementWindow(self, self.queue) self.uievents = UIEventManagement(self.window) self.rexlogic = r.getRexLogic() self.appdatafolder = "" try: self.appdatafolder = r.getApplicationDataDirectory() except: r.logInfo("Unexpected error:", sys.exc_info()[0]) self.rexlogic.connect("OnIncomingEstateOwnerMessage(QVariantList)", self.onEstateOwnerMessage) self.ents = [] self.managers = {} self.banned = {} self.accesslist = {} self.publicestate = True self.nameToUuidMapCache = {} self.savedusers = {} #self.estatesettings = EstateSettings(self.worldstream, self) self.estatesettings = None
def __init__(self, uistring, queue, endApplication, controller): self.controller = controller loader = QUiLoader() uifile = QFile(uistring) ui = loader.load(uifile) self.gui = ui width = ui.size.width() height = ui.size.height() uism = r.getUiSceneManager() # uiprops = r.createUiWidgetProperty(1) #1 is ModuleWidget, shown at toolbar # uiprops.SetMenuGroup(2) #2 is server tools group # uiprops.widget_name_ = "Local Scene" #uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it #self.proxywidget = r.createUiProxyWidget(ui, uiprops) self.proxywidget = r.createUiProxyWidget(ui) #if not uism.AddProxyWidget(self.proxywidget): if not uism.AddWidgetToScene(self.proxywidget): r.logInfo("Adding the ProxyWidget to the bar failed.") uism.AddWidgetToMenu(self.proxywidget, "Local Scene", "Server Tools", "./data/ui/images/menus/edbutton_LSCENE_normal.png") self.inputQueue = queue self.endApplication = endApplication self.tableitems = [] pass
def on_logout(self, id): r.logInfo("Object Edit resetting due to logout") self.deselect_all() self.sels = [] self.selection_box = None self.resetValues() self.resetManipulators()
def handleEstateUpdateMessage(self, args): agentid, sessionid, transactionid, method, invoice, paramlist = args len = paramlist.__len__() if(len!=10): r.logInfo('malformed estateupdateinfo') return self.queue.put(('EstateUpdate', paramlist))
def remove_highlight(self, ent): try: h = ent.highlight except AttributeError: r.logInfo("objectedit.remove_highlight called for a non-hilited entity: %d" % ent.id) else: h.Hide()
def on_exit(self): r.logInfo("Object Edit exiting..") # remove selection box component and entity # - no need its a temporary item #if self.selection_box_entity is not None and self.selection_box is not None: # self.selection_box_entity.RemoveComponentRaw(self.selection_box) # naali.removeEntity(self.selection_box_entity) # Connect to key pressed signal from input context self.edit_inputcontext.disconnectAll() self.deselect_all() """ # Disconnect cpp python handler self.cpp_python_handler.disconnect('ActivateEditing(bool)', self.on_activate_editing) self.cpp_python_handler.disconnect('ManipulationMode(int)', self.on_manupulation_mode_change) self.cpp_python_handler.disconnect('RemoveHightlight()', self.deselect_all) self.cpp_python_handler.disconnect('RotateValuesToNetwork(int, int, int)', self.changerot_cpp) self.cpp_python_handler.disconnect('ScaleValuesToNetwork(double, double, double)', self.changescale_cpp) self.cpp_python_handler.disconnect('PosValuesToNetwork(double, double, double)', self.changepos_cpp) self.cpp_python_handler.disconnect('CreateObject()', self.createObject) self.cpp_python_handler.disconnect('DuplicateObject()', self.duplicate) self.cpp_python_handler.disconnect('DeleteObject()', self.deleteObject) # Clean widgets self.cpp_python_handler.CleanPyWidgets() """ r.logInfo(".. done")
def on_mouseleftreleased(self, mouseinfo): self.left_button_down = False if self.active: #XXX something here? if self.sel_activated and self.dragging: for ent in self.sels: #~ print "LeftMouseReleased, networkUpdate call" parent, children = self.parentalCheck(ent) r.networkUpdate(ent.id) for child in children: child_id = int(child) r.networkUpdate(child_id) self.sel_activated = True if self.dragging: self.dragging = False self.manipulator.stopManipulating() self.manipulator.showManipulator(self.sels) self.usingManipulator = False if self.selection_rect_startpos is not None: self.selection_rect.hide() rectx, recty, rectwidth, rectheight = self.selectionRectDimensions( mouseinfo) if rectwidth != 0 and rectheight != 0: r.logInfo("The selection rect was at: (" + str(rectx) + ", " + str(recty) + ") and size was: (" + str(rectwidth) + ", " + str(rectheight) + ")") self.selection_rect.setGeometry(0, 0, 0, 0) self.selection_rect_startpos = None
def LeftMouseReleased(self, mouseinfo): self.left_button_down = False if self.active: #XXX something here? if self.sel_activated and self.dragging: for ent in self.sels: #~ print "LeftMouseReleased, networkUpdate call" parent, children = self.parentalCheck(ent) r.networkUpdate(ent.id) for child in children: child_id = int(child) r.networkUpdate(child_id) self.sel_activated = True if self.dragging: self.dragging = False self.manipulator.stopManipulating() self.duplicateDragStart = False #XXXchange? if self.selection_rect_startpos is not None: self.selection_rect.hide() rectx, recty, rectwidth, rectheight = self.selectionRectDimensions(mouseinfo) if rectwidth != 0 and rectheight != 0: r.logInfo("The selection rect was at: (" +str(rectx) + ", " +str(recty) + ") and size was: (" +str(rectwidth) +", "+str(rectheight)+")") self.selection_rect.setGeometry(0,0,0,0) self.selection_rect_startpos = None
def on_exit(self): r.logInfo("Object Edit exiting..") # Connect to key pressed signal from input context self.edit_inputcontext.disconnectAll() self.deselect_all() # Disconnect cpp python handler self.cpp_python_handler.disconnect('ActivateEditing(bool)', self.on_activate_editing) self.cpp_python_handler.disconnect('ManipulationMode(int)', self.on_manupulation_mode_change) self.cpp_python_handler.disconnect('RemoveHightlight()', self.deselect_all) self.cpp_python_handler.disconnect( 'RotateValuesToNetwork(int, int, int)', self.changerot_cpp) self.cpp_python_handler.disconnect( 'ScaleValuesToNetwork(double, double, double)', self.changescale_cpp) self.cpp_python_handler.disconnect( 'PosValuesToNetwork(double, double, double)', self.changepos_cpp) self.cpp_python_handler.disconnect('CreateObject()', self.createObject) self.cpp_python_handler.disconnect('DuplicateObject()', self.duplicate) self.cpp_python_handler.disconnect('DeleteObject()', self.deleteObject) # Clean widgets self.cpp_python_handler.CleanPyWidgets() r.logInfo(".. done")
def __init__(self, uistring, queue, endApplication, controller): self.controller = controller loader = QUiLoader() uifile = QFile(uistring) ui = loader.load(uifile) self.gui = ui width = ui.size.width() height = ui.size.height() uism = naali.ui # uiprops = r.createUiWidgetProperty(1) #1 is ModuleWidget, shown at toolbar # uiprops.SetMenuGroup(2) #2 is server tools group # uiprops.widget_name_ = "Local Scene" #uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it #self.proxywidget = r.createUiProxyWidget(ui, uiprops) self.proxywidget = r.createUiProxyWidget(ui) #if not uism.AddProxyWidget(self.proxywidget): if not uism.AddWidgetToScene(self.proxywidget): r.logInfo("Adding the ProxyWidget to the bar failed.") # TODO: Due to core UI API refactor AddWidgetToMenu doesn't exist anymore. #uism.AddWidgetToMenu(self.proxywidget, "Local Scene", "Server Tools", "./data/ui/images/menus/edbutton_LSCENE_normal.png") self.inputQueue = queue self.endApplication = endApplication self.tableitems = [] pass
def on_exit(self): r.logInfo("Object Edit exiting...") self.deselect_all() self.window.on_exit() r.logInfo(" ...exit done.")
def exit(self): r.logInfo("Circuits manager stopping...") self.m.send( Exit(), "on_exit" ) #am not running the manager properly so the stop doesn't propagate to components. fix when switch to dev branch of circuits XXX self.m.stop( ) #was not going to components now so made the exit event above as a quick fix
def removeSoundRuler(self, ent): if ent.prim and ent.prim.SoundID and ent.prim.SoundID not in (u'', '00000000-0000-0000-0000-000000000000'): try: sr = ent.soundruler except AttributeError: r.logInfo("objectedit.removeSoundRuler called for an object without one: %d" % ent.id) else: sr.Hide()
def create_playback_widget(self): if len(self.type) > 0 and naali.mediaplayerservice is not None: if naali.mediaplayerservice.IsMimeTypeSupported(self.type): self.playback_widget = naali.mediaplayerservice.GetPlayerWidget(str(self.__url)) self.__media_player_service_used = True r.logInfo("Media content supported for video playback: " + str(self.__url)) return self.playback_widget = PythonQt.QtWebKit.QWebView()
def sceneadded(self, name): #r.logInfo("CreateDestroy sceneadded called") self.scene = naali.getScene(name) self.scene.connect( "EntityCreated(Scene::Entity*, AttributeChange::Type)", self.handle_entity_created) r.logInfo("EntityCreated callback registered")
def on_exit(self): r.logInfo("TestGui starting exit...") #qtmod = r.getQtModule() #qtmod.DeleteCanvas(self.canvas) uism = naali.ui uism.RemoveProxyWidgetFromScene(self.proxywidget) r.logInfo("TestGui proxywidget removed from scene.")
def write(self, msg): self.buf += msg while '\n' in self.buf: line, self.buf = self.buf.split("\n", 1) try: r.logInfo(line) except ValueError: pass #somehow this isn't a string always r.logInfo("logging prob from py print: is not a string? " + str(type(line)))
def remove_highlight(self, ent): try: h = ent.highlight except AttributeError: r.logInfo( "objectedit.remove_highlight called for a non-hilited entity: %d" % ent.id) else: h.Hide()
def remove_highlight(self, ent): try: h = ent.highlight except AttributeError: try: r.logInfo("objectedit.remove_highlight called for a non-hilighted entity: %d" % ent.id) except ValueError: r.logInfo("objectedit.remove_highlight called, but entity already removed") else: ent.RemoveComponentRaw(h)
def remove_selected(self, ent): try: s = ent.selected except: try: r.logInfo("objectedit.remove_selected called for a non-selected entity: %d" % ent.id) except ValueError: r.logInfo("objectedit.remove_selected called, but entity already removed") else: ent.RemoveComponentRaw(s)
def create_playback_widget(self): if len(self.type) > 0 and naali.mediaplayerservice is not None: if naali.mediaplayerservice.IsMimeTypeSupported(self.type): self.playback_widget = naali.mediaplayerservice.GetPlayerWidget( str(self.__url)) self.__media_player_service_used = True r.logInfo("Media content supported for video playback: " + str(self.__url)) return self.playback_widget = PythonQt.QtWebKit.QWebView()
def update(self, deltatime): prev = None try: status = self.testgen.next() except StopIteration: # print "Test finished" return if status: r.logInfo("Test state: " + str(status)) prev = status
def removeSoundRuler(self, ent): if ent.prim and ent.prim.SoundID and ent.prim.SoundID not in ( u'', '00000000-0000-0000-0000-000000000000'): try: sr = ent.soundruler except AttributeError: r.logInfo( "objectedit.removeSoundRuler called for an object without one: %d" % ent.id) else: sr.Hide()
def removeSoundRuler(self, ent): try: if ent.prim and ent.prim.SoundID and ent.prim.SoundID not in (u'', '00000000-0000-0000-0000-000000000000'): try: sr = ent.soundruler except AttributeError: r.logInfo("objectedit.removeSoundRuler called for an object without one: %d" % ent.id) else: ent.RemoveComponentRaw(sr) except AttributeError: r.logInfo("objectedit.removeSoundRuler: entity already removed. Prim doesn't exist anymore")
def parseCapsUrl(self, cap_url): r.logInfo(cap_url) url_split = cap_url.split(':') if(url_split.__len__<3): r.logInfo("mallformed cap url for scene upload") return False surl = url_split[1] self.host = surl.split('/')[2] port_path = url_split[2] self.port = int(port_path.split('/')[0]) self.path = "/".join(port_path.split('/')[1:]) return True
def parseCapsUrl(self, cap_url): r.logInfo(cap_url) url_split = cap_url.split(':') if (url_split.__len__ < 3): r.logInfo("mallformed cap url for scene upload") return False surl = url_split[1] self.host = surl.split('/')[2] port_path = url_split[2] self.port = int(port_path.split('/')[0]) self.path = "/".join(port_path.split('/')[1:]) return True
def highlight(self, ent): try: ent.highlight except AttributeError: ent.GetOrCreateComponentRaw("EC_Highlight") h = ent.highlight if not h.IsVisible(): h.Show() else: r.logInfo("objectedit.highlight called for an already hilited entity: %d" % ent.id)
def read_inis(): thisdir = os.path.split(os.path.abspath(__file__))[0] for inifile in glob(os.path.join(thisdir, "*.ini")): cp = ConfigParser() cp.read([inifile]) for s in cp.sections(): cfdict = dict(cp.items(s)) try: modname, compname = s.rsplit('.', 1) except ValueError: r.logInfo("bad config section in " + inifile + ": " + s) continue yield modname, compname, cfdict
def remove_selected(self, ent): try: s = ent.selected except: try: r.logInfo( "objectedit.remove_selected called for a non-selected entity: %d" % ent.id) except ValueError: r.logInfo( "objectedit.remove_selected called, but entity already removed" ) else: ent.RemoveComponentRaw(s)
def remove_highlight(self, ent): try: h = ent.highlight except AttributeError: try: r.logInfo( "objectedit.remove_highlight called for a non-hilighted entity: %d" % ent.id) except ValueError: r.logInfo( "objectedit.remove_highlight called, but entity already removed" ) else: ent.RemoveComponentRaw(h)
def on_exit(self): try: # end incoming loop self.controller.isrunning = 0 self.proxywidget.hide() uism = r.getUiSceneManager() uism.RemoveWidgetFromMenu(self.proxywidget) uism.RemoveWidgetFromScene(self.proxywidget) return True except: r.logInfo("Estate Window failure:") traceback.print_exc() return False
def highlight(self, ent): try: ent.highlight except AttributeError: ent.GetOrCreateComponentRaw("EC_Highlight") h = ent.highlight if not h.IsVisible(): h.Show() else: r.logInfo( "objectedit.highlight called for an already hilited entity: %d" % ent.id)
def highlight(self, ent): try: ent.highlight except AttributeError: ent.createComponent("EC_Highlight") #print "created a new Highlight component" h = ent.highlight #print type(h), h if not h.IsVisible(): h.Show() else: r.logInfo("objectedit.highlight called for an already hilited entity: %d" % ent.id)
def safeCopy(self, srcPath, dstPath, fname, olList): # check if file exists if (os.access(dstPath, os.F_OK)): #r.logInfo("File allready exists:") #r.logInfo(dstPath) olList.append(fname) else: #print "Copying ", srcPath, " to ", dstPath if (os.access(srcPath, os.F_OK)): shutil.copyfile(srcPath, dstPath) else: r.logInfo("File defined does not exist:") r.logInfo(fname) olList.append(fname) # not removed when unloading
def safeCopy(self, srcPath, dstPath, fname, olList): # check if file exists if os.access(dstPath, os.F_OK): # r.logInfo("File allready exists:") # r.logInfo(dstPath) olList.append(fname) else: # print "Copying ", srcPath, " to ", dstPath if os.access(srcPath, os.F_OK): shutil.copyfile(srcPath, dstPath) else: r.logInfo("File defined does not exist:") r.logInfo(fname) olList.append(fname) # not removed when unloading
def on_exit(self): try: # end incoming loop self.controller.isrunning = 0 self.proxywidget.hide() uism = naali.ui # TODO: Due to core UI API refactor RemoveWidgetFromMenu doesn't exist anymore. # uism.RemoveWidgetFromMenu(self.proxywidget) uism.RemoveWidgetFromScene(self.proxywidget) return True except: r.logInfo("Estate Window failure:") traceback.print_exc() return False
def on_exit(self): try: # end incoming loop self.endmethod() self.queue.put('__end__', 'none') self.proxywidget.hide() uism = r.getUiSceneManager() uism.RemoveWidgetFromMenu(self.proxywidget) uism.RemoveWidgetFromScene(self.proxywidget) return True except: r.logInfo("LocalSceneWindow failure:") traceback.print_exc() return False
def load(circuitsmanager): for klass, cfg in modules: #~ modinst = klass() #~ circuitsmanager += modinst #print klass try: if cfg: modinst = klass(cfsection=cfg) else: modinst = klass() except Exception, exc: r.logInfo("failed to instantiate pymodule %s" % klass) r.logInfo(traceback.format_exc()) else: circuitsmanager += modinst # Equivalent to: tm.register(m)
def on_exit(self): try: # end incoming loop self.controller.isrunning = 0 self.proxywidget.hide() uism = naali.ui # TODO: Due to core UI API refactor RemoveWidgetFromMenu doesn't exist anymore. #uism.RemoveWidgetFromMenu(self.proxywidget) uism.RemoveWidgetFromScene(self.proxywidget) return True except: r.logInfo("Estate Window failure:") traceback.print_exc() return False
def highlight(self, ent): try: ent.highlight except AttributeError: ent.createComponent("EC_Highlight") #print "created a new Highlight component" h = ent.highlight #print type(h), h if not h.IsVisible(): h.Show() else: r.logInfo( "objectedit.highlight called for an already hilited entity: %d" % ent.id)
def removeSoundRuler(self, ent): try: if ent.prim and ent.prim.SoundID and ent.prim.SoundID not in ( u'', '00000000-0000-0000-0000-000000000000'): try: sr = ent.soundruler except AttributeError: r.logInfo( "objectedit.removeSoundRuler called for an object without one: %d" % ent.id) else: ent.RemoveComponentRaw(sr) except AttributeError: r.logInfo( "objectedit.removeSoundRuler: entity already removed. Prim doesn't exist anymore" )
def processIncoming(self): """ for receiving input message events from other threads """ while(self.inputQueue.qsize()): try: title, msg = self.inputQueue.get(0) if(title=="__end__"): self.controller.isrunning = 0 return if(title=="__unload__"): self.controller.unloadScene() return self.displayMessage(title, msg) except Queue.Empty: pass except: r.logInfo("Exception in processIncoming, LocalScene window")
def on_exit(self): try: # end incoming loop self.endmethod() self.queue.put("__end__", "none") self.proxywidget.hide() uism = naali.ui # TODO: Due to core UI API refactor RemoveWidgetFromMenu doesn't exist anymore. # uism.RemoveWidgetFromMenu(self.proxywidget) uism.RemoveWidgetFromScene(self.proxywidget) return True except: r.logInfo("LocalSceneWindow failure:") traceback.print_exc() return False
def deselect_all(self): if len(self.sels) > 0: for ent in self.sels: self.remove_highlight(ent) self.removeSoundRuler(ent) try: self.worldstream.SendObjectDeselectPacket(ent.id) except ValueError: r.logInfo("objectedit.deselect_all: entity doesn't exist anymore") self.sels = [] self.hideManipulator() self.prev_mouse_abs_x = 0 self.prev_mouse_abs_y = 0 self.canmove = False self.window.deselected()
def on_exit(self): r.logInfo("Object Edit exiting..") # Connect to key pressed signal from input context self.edit_inputcontext.disconnectAll() self.deselect_all() # Disconnect cpp python handler self.cpp_python_handler.disconnect('ActivateEditing(bool)', self.on_activate_editing) self.cpp_python_handler.disconnect('ManipulationMode(int)', self.on_manupulation_mode_change) self.cpp_python_handler.disconnect('RemoveHightlight()', self.deselect_all) self.cpp_python_handler.disconnect('RotateValuesToNetwork(int, int, int)', self.changerot_cpp) self.cpp_python_handler.disconnect('ScaleValuesToNetwork(double, double, double)', self.changescale_cpp) self.cpp_python_handler.disconnect('PosValuesToNetwork(double, double, double)', self.changepos_cpp) self.cpp_python_handler.disconnect('CreateObject()', self.createObject) self.cpp_python_handler.disconnect('DuplicateObject()', self.duplicate) self.cpp_python_handler.disconnect('DeleteObject()', self.deleteObject) # Clean widgets self.cpp_python_handler.CleanPyWidgets() r.logInfo(".. done")