def __init__(self, cg): self.cg=cg base.accept("q", sys.exit) base.accept("escape", sys.exit) base.accept("+", self.zoomPlus) base.accept("-", self.zoomMoins) base.accept("arrow_left", self.deplaceGauche) base.accept("arrow_right", self.deplaceDroite) base.accept("arrow_up", self.deplaceHaut) base.accept("arrow_down", self.deplaceBas) #base.accept("mouse1", clicGauche) #base.accept("mouse2", clicCentre) #base.accept("mouse3", clicDroit) self.gui = Gui(theme = rtheme.RTheme()) self.bas = Bas() self.gui.add(self.bas) self.haut = Haut() self.gui.add(self.haut) self.droite = Droite(self) self.gui.add(self.droite) self.gauche = Gauche(self) self.gui.add(self.gauche) self.quit = self.gui.add(Icon("rtheme/twotone/x.png", x="right", y="top")) self.quit.onClick = sys.exit self.chargement = self.gui.add(Icon("rtheme/twotone/gear.png", x="left", y="top"))
class Interface: def __init__(self, cg): self.cg=cg base.accept("q", sys.exit) base.accept("escape", sys.exit) base.accept("+", self.zoomPlus) base.accept("-", self.zoomMoins) base.accept("arrow_left", self.deplaceGauche) base.accept("arrow_right", self.deplaceDroite) base.accept("arrow_up", self.deplaceHaut) base.accept("arrow_down", self.deplaceBas) #base.accept("mouse1", clicGauche) #base.accept("mouse2", clicCentre) #base.accept("mouse3", clicDroit) self.gui = Gui(theme = rtheme.RTheme()) self.bas = Bas() self.gui.add(self.bas) self.haut = Haut() self.gui.add(self.haut) self.droite = Droite(self) self.gui.add(self.droite) self.gauche = Gauche(self) self.gui.add(self.gauche) self.quit = self.gui.add(Icon("rtheme/twotone/x.png", x="right", y="top")) self.quit.onClick = sys.exit self.chargement = self.gui.add(Icon("rtheme/twotone/gear.png", x="left", y="top")) #self.chargement.onHover = self.afficheDetailChargement def zoomPlus(self): p = base.camera.getPos() base.camera.setPos(p[0], p[1]*0.75, p[2]) def zoomMoins(self): p = base.camera.getPos() base.camera.setPos(p[0], p[1]*1.333, p[2]) deltaCamX = 0.01 deltaCamY = 0.01 def deplaceHaut(self): self.droite.snapLibre.onClick() p = base.camera.getPos() base.camera.setPos(p[0], p[1], p[2]+self.deltaCamY*p[1]) def deplaceBas(self): self.droite.snapLibre.onClick() p = base.camera.getPos() base.camera.setPos(p[0], p[1], p[2]-self.deltaCamY*p[1]) def deplaceGauche(self): self.droite.snapLibre.onClick() p = base.camera.getPos() base.camera.setPos(p[0]+self.deltaCamX*p[1], p[1], p[2]) def deplaceDroite(self): self.droite.snapLibre.onClick() p = base.camera.getPos() base.camera.setPos(p[0]-self.deltaCamX*p[1], p[1], p[2]) def select(self, type, affiche=True): type=type.lower() liste = self.cg.elements[type][:] if not affiche: for element in self.cg.elements[type]: self.cg.effaceCategorie(element) else: self.cg.charge(liste, tuile=None)#self.cg.tuile((self.cg.GPSCoord[0], 0.0, self.cg.GPSCoord[1]))) def afficheTexte(self, texte, orientation="centre", section=None, forceRefresh=False): """Affiche le texte sur l'écran, si texte==None, alors efface le dernier texte affiché""" try: if texte!=None: if orientation=="bas": self.bas.bas.text=texte elif orientation=="haut": self.bas.haut.text=texte else: self.bas.centre.text=texte except NameError: return if forceRefresh: self.gui._doMouse() self.gui._doDrag() self.gui._reSize() self.gui._layout() self.gui._draw() base.graphicsEngine.renderFrame() def snapMode(self): if self.droite.snapLibre.value: return "libre" if self.droite.snapGPS.value: return "gps" if self.droite.snapContenu.value: return "contenu" return "snap err" def parsageActif(self): if self.droite.parsage.value: return True return False def setObjetEnAttente(self, vrai): self.chargement.visable = vrai if vrai: self.afficheTexte(texte="Objets restants a afficher : "+str(len(self.cg.objetsAAfficher) + len(self.cg.objetsACharger) + len(self.cg.objetsAFabriquer)), orientation = "haut") else: self.afficheTexte(texte="", orientation = "haut")