Focus souris sur le composants hors fonctionnement du cycle, focus aussi sur les actionneurs

This commit is contained in:
Philippe Roy 2023-01-11 18:48:45 +01:00
parent b3b34743aa
commit d42127601a
6 changed files with 108 additions and 25 deletions

Binary file not shown.

View File

@ -52,7 +52,6 @@ def init(cont):
twin.manip_init() # Manipulation du modèle 3D
twin.cmd_init() # Commandes
# twin.manip_init() # Cacher les objets de l'aide
# Brochage
for pin in pin_config:
@ -67,7 +66,18 @@ def init(cont):
scene.objects['Engrenage']['init_ry']=scene.objects['Engrenage'].worldOrientation.to_euler().y
scene.objects['Engrenage']['init_rz']=scene.objects['Engrenage'].worldOrientation.to_euler().z
# Description des composants sensibles
# Groupe de focus pour les actionneurs
twin.cycle_def_focusgroup([["Moteur","blue"] ,
["Reducteur","blue"],
["Pattes moteur","blue"],
["Engrenage","blue-dark"],
["Engrennage patte","blue-dark"],
["Engrenage vis1","grey"],
["Engrenage vis2","grey"],
["Engrenage vis3","grey"]], "Moteur : mot_o(True | False), mot_f(True | False)")
twin.cycle_def_focusgroup([["Led", "led_yellow"]], "Gyrophare : gyr(True | False)")
# Focus sur les boutons et capteurs
scene.objects['Bp cote cour']['description']="Bouton poussoir coté cour : bp_int()"
scene.objects['Bp cote rue']['description']="Bouton poussoir coté rue : bp_ext()"
scene.objects['Microrupteur fdc ouvert']['description']="Capteur fin de course portail ouvert : fdc_o()"
@ -208,6 +218,11 @@ def ir_emet (cont):
if scene.objects['System']['run'] :
obj = cont.owner
# Mouse over
if obj['mo'] == True and obj['click'] == False and obj.color !=color_hl:
obj.color =color_hl
return
# Passif
if obj['active'] == False and obj.color !=color_passive:
obj.color =color_passive
@ -219,6 +234,7 @@ def ir_emet (cont):
if scene.objects['System']['twins']:
if scene.objects['Emetteur IR']['pin'] is not None:
scene.objects['Emetteur IR']['pin'].write(0)
return
# Active
if obj['active']:
@ -259,9 +275,15 @@ def ir_recep (cont):
if scene.objects['System']['run'] :
obj = cont.owner
# Mouse over
if obj['mo'] == True and obj['click'] == False and obj.color !=color_hl:
obj.color =color_hl
return
# Passif
if obj['active'] == False and obj.color !=color_passive:
obj.color =color_passive
return
# Active
if obj['active']:

95
twin.py
View File

@ -46,6 +46,12 @@ color_activated = (0.8, 0.619, 0.021, 1) # bouton activé numériquement unique
color_activated_real = (0.799, 0.031, 0.038, 1) # élément activé physiquement uniquement : rouge (hors clic)
color_activated_dbl = (0.246, 0.687, 0.078, 1) # élément activé physiquement et numériquement : vert clair
color_blue = (0.007, 0.111, 0.638, 1) # Couleur Blue (Actionneur type moteur)
color_blue_dark = (0.004, 0.054, 0.296, 1) # Couleur Blue (Actionneur type moteur)
color_grey = (0.285, 0.285, 0.285, 1) # Couleur Blue (Actionneur type moteur)
color_led_yellow = (0.799, 0.617, 0.021, 1) # Couleur Led Jaune
# Constantes
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
@ -511,13 +517,6 @@ def cycle_run ():
# FIXME : Relancer la maquette
pass
def light_refresh(cont):
pass
# scene.objects['Sun'].applyMovement((0, 0, 0), True)
# scene.objects['System'].applyRotation((0, 0, 0), False)
# scene.objects['System'].applyMovement((0,0,0), False)
# pass
##
# Arrêt et réinitialisation du cycle (forçage)
##
@ -548,28 +547,47 @@ def cycle_end (cont):
##
def cycle_hl(cont):
obj = cont.owner
# Passif
if "active" in obj.getPropertyNames():
if obj['active'] == False:
obj.color = color_passive
return
if "-colbox" in cont.owner.name:
obj= scene.objects[cont.owner.name[:-7]]
else:
obj = cont.owner
# Activation
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['System']['run']:
obj.color = color_hl
if cont.sensors['MO'].status == JUST_ACTIVATED:
obj['mo'] = True
# Composant avec un goupe de couleur (type actionneur)
if "color_group" in obj.getPropertyNames():
for obj_name in obj['color_group']:
scene.objects[obj_name].color = color_hl
else:
obj.color = color_hl
# Description
if obj['description'] is not None:
scene.objects['Cmd-text']['Text']=obj['description']
scene.objects['Cmd-text'].setVisible(True,True)
# Désactivation
if cont.sensors['MO'].status == JUST_RELEASED and scene.objects['System']['run']:
obj.color = color_active
if cont.sensors['MO'].status == JUST_RELEASED :
obj['mo'] = False
scene.objects['Cmd-text']['Text']=""
# Composant passif
if "active" in obj.getPropertyNames():
if obj['active'] == False: # Composant passif
obj.color = color_passive
return
# Composant avec un goupe de couleur (type actionneur)
if "color_group" in obj.getPropertyNames():
for obj_name in obj['color_group']:
cycle_actuator_color(obj_name)
return
# Composant simple
obj.color = color_active
##
# Click sur les éléments cliquables du système (activation numérique)
##
@ -607,8 +625,12 @@ def cycle_click(cont):
##
def cycle_sensitive_color(obj):
# Mouse over
if obj['mo'] == True and obj['click'] == False and obj.color !=color_hl:
obj.color =color_hl
# Jumeau
elif scene.objects['System']['twins']:
if obj['activated_real'] ==False and obj['activated']==False and obj.color !=color_active:
obj.color =color_active
@ -620,12 +642,29 @@ def cycle_sensitive_color(obj):
obj.color =color_activated
elif obj['activated_real'] ==False and obj['activated']==False and obj.color !=color_activated:
obj.color =color_active
# Uniquement maquette 3D
else:
if obj['activated'] == True and obj.color !=color_activated:
obj.color =color_activated
elif obj['activated'] == False and obj.color !=color_active:
obj.color =color_active
##
# Couleurs des actionneurs
##
def cycle_actuator_color(name):
obj = scene.objects[name]
if obj['color']== "blue":
obj.color = color_blue
elif obj['color']== "blue-dark":
obj.color = color_blue_dark
elif obj['color']== "grey":
obj.color = color_grey
elif obj['color']== "led_yellow":
obj.color = color_led_yellow
##
# Comportement standard des boutons
##
@ -652,7 +691,11 @@ def cycle_voy(cont):
obj = cont.owner
obj_on=scene.objects[obj.name+"-on"]
if scene.objects['System']['run']:
# Mouse over
if obj['mo'] == True and obj.color !=color_hl:
obj.color =color_hl
elif scene.objects['System']['run']:
# Activation
if obj['activated'] and obj_on.visible == False:
@ -673,3 +716,17 @@ def cycle_voy(cont):
if scene.objects['System']['twins']:
if obj['pin'] is not None:
obj['pin'].write(0)
##
# Mise en couleur des actionneurs
##
def cycle_def_focusgroup(focusgroup, description):
group=[]
for obj in focusgroup:
group.append(obj[0])
for obj in focusgroup:
scene.objects[obj[0]]['color_group'] = group
scene.objects[obj[0]]['color'] = obj[1]
scene.objects[obj[0]]['description']=description
cycle_actuator_color(obj[0])

View File

@ -1,5 +1,6 @@
import bge # Bibliothèque Blender Game Engine (UPBGE)
import bpy # Blender
import sys
import webbrowser
import numpy as np
@ -216,7 +217,9 @@ def quality_up(cont):
eevee.use_eevee_smaa = False
else:
eevee.use_eevee_smaa = True
eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
print (sys.platform)
if sys.platform=="linux": # Plantage sur Windows
eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
# Boutons < et >
if scene.objects['About']['quality']==4:
@ -237,7 +240,8 @@ def quality_down(cont):
eevee.use_eevee_smaa = False
else:
eevee.use_eevee_smaa = True
eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
if sys.platform=="Linux": # Plantage sur Windows
eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
# Boutons < et >
if scene.objects['About']['quality']==0:

View File

@ -1,7 +1,7 @@
<data>
<screen>
<width>1325</width>
<height>745</height>
<width>1609</width>
<height>905</height>
<quality>1</quality>
</screen>
</data>