mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Intégration de la documentation statique
This commit is contained in:
parent
918f715eb1
commit
6d487f9ea5
@ -38,6 +38,7 @@ def init(cont):
|
||||
|
||||
twin.manip_init() # Manipulation du modèle 3D
|
||||
twin.cmd_init() # Commandes
|
||||
twin.manip_init() # Cacher les objets de l'aide
|
||||
|
||||
# Mémorisation de la position et orientation des composants du système
|
||||
scene.objects['Portail']['init_lx']=scene.objects['Portail'].worldPosition.x
|
||||
|
Binary file not shown.
BIN
portail_coulissant/portail_coulissant-16.blend
Normal file
BIN
portail_coulissant/portail_coulissant-16.blend
Normal file
Binary file not shown.
6
twin.py
6
twin.py
@ -150,6 +150,7 @@ def cmd_init():
|
||||
windows=("Doc", "Doc_chap-general", "Doc_chap-system", "Doc_chap-python", "About")
|
||||
for window in windows:
|
||||
scene.objects[window].setVisible(False,True)
|
||||
twin_doc.init_hide()
|
||||
# twin_doc.init()
|
||||
|
||||
##
|
||||
@ -254,12 +255,7 @@ def cmd_click(cont):
|
||||
|
||||
# Aide
|
||||
if obj.name=="Doc-cmd-colbox" :
|
||||
print ("Début")
|
||||
twin_doc.open()
|
||||
for item in scene.objects:
|
||||
print (item.name)
|
||||
# print("Objets de la scene : ", scene.objects)
|
||||
print ("Fin")
|
||||
|
||||
###############################################################################
|
||||
# Manipulation du mécanisme
|
||||
|
180
twin_doc.py
180
twin_doc.py
@ -133,10 +133,10 @@ card_dict_url=[
|
||||
card_description.update({"dict-card" : [card_dict_title, card_dict_text, card_dict_url]})
|
||||
|
||||
# Objet (POO)
|
||||
card_oop_title="Programmation\norientée objet (POO)"
|
||||
card_oop_text="\nFIXME"
|
||||
card_oop_url=[["w3schools.com : classes & objects","https://www.w3schools.com/python/python_classes.asp"]]
|
||||
card_description.update({"oop-card" : [card_oop_title, card_oop_text, card_oop_url]})
|
||||
# card_oop_title="Programmation\norientée objet (POO)"
|
||||
# card_oop_text="\nFIXME"
|
||||
# card_oop_url=[["w3schools.com : classes & objects","https://www.w3schools.com/python/python_classes.asp"]]
|
||||
# card_description.update({"oop-card" : [card_oop_title, card_oop_text, card_oop_url]})
|
||||
|
||||
# Console
|
||||
card_console_title="Console"
|
||||
@ -172,6 +172,14 @@ card_description.update({"python-card" : [card_python_title, card_python_text, c
|
||||
# Initialisation de la documentation
|
||||
##
|
||||
|
||||
def init_hide():
|
||||
for card in card_description:
|
||||
scene.objects["Doc_page-"+card].setVisible(False,True)
|
||||
|
||||
##
|
||||
# Initialisation de la documentation
|
||||
##
|
||||
|
||||
def init():
|
||||
|
||||
# UI : information
|
||||
@ -205,8 +213,9 @@ def init():
|
||||
scene.objects['Doc_chap-system-url'+str(i)+'-colbox'].suspendPhysics()
|
||||
scene.objects['Doc_chap-system-url'+str(i)].color = color_doc_chap
|
||||
|
||||
# Chargement du texte
|
||||
text_load()
|
||||
# Chargement du texte en mode dynamique
|
||||
if scene.objects['Doc']['static']== False :
|
||||
text_load()
|
||||
|
||||
# Mémorisation de la position des pages
|
||||
for page in chap:
|
||||
@ -239,7 +248,12 @@ def open():
|
||||
scene.objects['Twins-text'].setVisible(False,True) # Crash de UPBGE sur la supression de l'Overlay
|
||||
scene.objects['Doc_close'].color= color_doc_fct
|
||||
scene.objects['Doc'].setVisible(True,True)
|
||||
text_hide()
|
||||
if scene.objects['Doc']['static']:
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
for i in range (13):
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-ref'].setVisible(False, False)
|
||||
else:
|
||||
text_hide()
|
||||
|
||||
# Placer le nouveau chapitre
|
||||
name_chap = scene.objects['Doc']['page_chap']
|
||||
@ -265,15 +279,18 @@ def open():
|
||||
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox']['Url'] = card_description[name_fct][2][i][1]
|
||||
|
||||
# Afficher le texte de la carte active
|
||||
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
if scene.objects['Doc']['static'] :
|
||||
pass
|
||||
else:
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
else:
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
|
||||
##
|
||||
# Fermer la documentation
|
||||
@ -373,6 +390,7 @@ def hl (cont):
|
||||
def chapter(cont):
|
||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and cont.sensors['Click'].positive:
|
||||
obj = cont.owner
|
||||
name_chap = scene.objects['Doc']['page_chap']
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
|
||||
# Enlever l'ancien chapitre
|
||||
@ -382,7 +400,25 @@ def chapter(cont):
|
||||
scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.y = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_ly']
|
||||
scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.z = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lz']
|
||||
if scene.objects['Doc']['page_chap'] != "general" and scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['page_fct'] !="":
|
||||
text_hide(scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['page_fct'])
|
||||
if scene.objects['Doc']['static'] :
|
||||
# scene.objects['Doc-'+scene.objects['Doc']['page_chap']].color = color_doc_chap
|
||||
# scene.objects['Doc-'+scene.objects['Doc']['page_chap']+'-text'].color = color_doc_chap
|
||||
# scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.x = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lx']
|
||||
# scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.y = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_ly']
|
||||
# scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.z = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lz']
|
||||
# if scene.objects['Doc']['page_chap'] != "general" and scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['page_fct'] !="":
|
||||
name_chap = scene.objects['Doc']['page_chap']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.x = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lx']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.y = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_ly']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(False,True)
|
||||
else:
|
||||
# scene.objects['Doc-'+scene.objects['Doc']['page_chap']].color = color_doc_chap
|
||||
# scene.objects['Doc-'+scene.objects['Doc']['page_chap']+'-text'].color = color_doc_chap
|
||||
# scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.x = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lx']
|
||||
# scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.y = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_ly']
|
||||
# scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']].worldPosition.z = scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['init_lz']
|
||||
text_hide(scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['page_fct'])
|
||||
|
||||
# Placer le nouveau chapitre
|
||||
name_chap= obj.name[4:-7]
|
||||
@ -410,14 +446,24 @@ def chapter(cont):
|
||||
|
||||
# Afficher le texte de la carte active
|
||||
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
if scene.objects['Doc']['static'] :
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lx']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.x
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_ly']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.y
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition = scene.objects['Doc'].worldPosition
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(True,True)
|
||||
else:
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
else:
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
if scene.objects['Doc']['static'] :
|
||||
pass
|
||||
else:
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
|
||||
##
|
||||
# Afficher les details de la fonction à partir d'une carte
|
||||
@ -432,7 +478,13 @@ def card (cont):
|
||||
|
||||
# Enlever l'ancienne carte
|
||||
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
text_hide(scene.objects['Doc_chap-'+name_chap]['page_fct'])
|
||||
if scene.objects['Doc']['static'] :
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.x = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lx']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.y = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_ly']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz']
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(False,True)
|
||||
else:
|
||||
text_hide(scene.objects['Doc_chap-'+name_chap]['page_fct'])
|
||||
scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']].color = color_doc_fct
|
||||
scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']+'-text'].color = color_doc_fct
|
||||
scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']+'-icon'].color = color_doc_fct
|
||||
@ -442,9 +494,16 @@ def card (cont):
|
||||
scene.objects[name_fct].color = color_doc_activate
|
||||
scene.objects[name_fct+'-icon'].color = color_doc_activate
|
||||
scene.objects[name_fct+'-text'].color = color_doc_activate
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
if scene.objects['Doc']['static'] :
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lx']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.x
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_ly']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.y
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition = scene.objects['Doc'].worldPosition
|
||||
scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(True,True)
|
||||
else:
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
|
||||
# URL
|
||||
if name_chap == "system" or name_chap == "python":
|
||||
@ -529,70 +588,5 @@ def text_load():
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=lines[i]
|
||||
|
||||
###############################################################################
|
||||
# Génération statique des pages (fichiers *_doc-fr.blend)
|
||||
# Lecture des pages statiques
|
||||
###############################################################################
|
||||
|
||||
# Sortir de la génération
|
||||
def text_gene_end(cont):
|
||||
if scene.objects['Doc_chap-python']['generated'] == True :
|
||||
if scene.objects['Doc_chap-system']['generated'] == True :
|
||||
print ("Génération des pages effectuée.")
|
||||
for item in scene.objects:
|
||||
print (item.name)
|
||||
bge.logic.endGame()
|
||||
|
||||
# Génération des pages
|
||||
def text_gene(cont):
|
||||
obj = cont.owner
|
||||
print ("Génération des pages de la documentation pour le chapitre : "+ obj.name +" ...")
|
||||
if obj.name == "Doc_chap-system":
|
||||
chap_card = system_card
|
||||
if obj.name == "Doc_chap-python":
|
||||
chap_card = python_card
|
||||
|
||||
# Création des objets 3D
|
||||
i=0
|
||||
for card in chap_card :
|
||||
print ("Génération de la page : "+ card)
|
||||
|
||||
# Repère page
|
||||
rep= scene.addObject('Doc_text-ref', None, 0.00, True)
|
||||
|
||||
# Texte de la page
|
||||
lines = card_description[card][1].split("\n")
|
||||
for j in range (13):
|
||||
doc_text= scene.addObject('Doc_text-l'+str(j+1)+'-ref', None, 0.00, True)
|
||||
doc_text.name = 'Doc_text-l'+str(j+1)+'-'+str(card)
|
||||
# doc_text.worldPosition.x = scene.objects['Doc_text-l'+str(j+1)+'-ref'].worldPosition.x
|
||||
# doc_text.worldPosition.y = scene.objects['Doc_text-l'+str(j+1)+'-ref'].worldPosition.y
|
||||
# doc_text.worldPosition.z = scene.objects['Doc_text-l'+str(j+1)+'-ref'].worldPosition.z
|
||||
# doc_text.setVisible(False, False)
|
||||
if j >= len(lines):
|
||||
doc_text['Text']=""
|
||||
else:
|
||||
if len(lines[j]) ==0:
|
||||
doc_text['Text']=""
|
||||
else:
|
||||
doc_text['Text']=lines[j]
|
||||
print ("Génération de la ligne : "+ doc_text.name +" : "+doc_text['Text'])
|
||||
|
||||
# if j >= len(lines):
|
||||
# scene.objects['Doc_text-l'+str(j+1)+'-'+str(card)]['Text']=""
|
||||
# else:
|
||||
# if len(lines[j]) ==0:
|
||||
# scene.objects['Doc_text-l'+str(j+1)+'-'+str(card)]['Text']=""
|
||||
# else:
|
||||
# scene.objects['Doc_text-l'+str(j+1)+'-'+str(card)]['Text']=lines[j]
|
||||
# time.sleep(0.1)
|
||||
doc_text.setParent(rep)
|
||||
time.sleep(0.5)
|
||||
|
||||
# Déplacement du repère page
|
||||
rep.worldPosition.x = obj.worldPosition.x + i*100
|
||||
rep.worldPosition.y = obj.worldPosition.y
|
||||
rep.worldPosition.z = obj.worldPosition.z
|
||||
i+=1
|
||||
|
||||
# Fin
|
||||
print ("Génération des pages de la documentation pour le chapitre : "+ obj.name +" Ok")
|
||||
obj['generated']= True
|
||||
|
Loading…
Reference in New Issue
Block a user