source: main/branches/3D/openPLM/document3D/views.py @ 597

Revision 597, 3.0 KB checked in by agalech, 9 years ago (diff)

branch 3D: 3D view: make it possible to show/hide each shape of a stp file

Line 
1from openPLM.plmapp.base_views import handle_errors , get_generic_data
2from openPLM.document3D.forms import Form3D
3from django.shortcuts import render_to_response
4from django.template import RequestContext
5from openPLM.document3D.models import *
6
7
8
9"""
10def v_3D(request, obj_ref, obj_revi):
11
12    obj_type = "Document3D"         
13    return display_3d(request, obj_type , obj_ref, obj_revi)
14"""   
15def r2r(template, dictionary, request):
16    """
17    Shortcut for::
18       
19        render_to_response(template, dictionary,
20                              context_instance=RequestContext(request))
21    """
22    return render_to_response(template, dictionary,
23                              context_instance=RequestContext(request))
24 
25#@handle_errors
26
27def display_3d(request, obj_ref, obj_revi):
28
29    """ Manage html page for 3D
30 
31    Manage html page which displays the 3d files STEP (or other??) uploaded in the selected object.
32    It computes a context dictionnary based on
33   
34    .. include:: views_params.txt
35    """
36   
37    obj_type = "Document3D"
38   
39    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi)
40
41   
42   
43   
44   
45    if request.method == 'POST':
46        form = Form3D(request.POST, document=obj)
47        if form.is_valid():
48            options = form.cleaned_data
49            image = options["Display"]
50            multi_image=stp_to_jss.objects.filter(stp=image)
51            menu_navigabilite=stp_to_jss_navigabilite.objects.filter(stp=image)[0].js.name
52
53            #ctx.update({'current_page':'3D','select_stp_form': form,'images_3D':options["Display"].js.name})
54            ctx.update({'current_page':'3D','select_stp_form': form, 'multi_image3D' : multi_image ,'menu_navigabilite' : menu_navigabilite, })   
55            return r2r('Display3D.htm', ctx, request)
56       
57    else:
58        form = Form3D(document=obj)
59       
60 
61    image = form.fields["Display"].initial
62
63    if image is None:
64        multi_image=''
65        menu_navigabilite=''
66
67    else:
68
69        multi_image=stp_to_jss.objects.filter(stp=image)
70        menu_navigabilite=stp_to_jss_navigabilite.objects.filter(stp=image)[0].js.name
71        #print "EL numero de ficheros es " ,multi_image.count()
72
73       
74    ctx.update({'current_page':'3D','select_stp_form': form , 'multi_image3D' : multi_image , 'menu_navigabilite' : menu_navigabilite , })
75 
76    return r2r('Display3D.htm', ctx, request)
77
78
79   
80   
81   
82    #print "el total es"
83    #print stps.count()
84    #print stps[0].file.path
85
86
87               
88               
89
90    #if not hasattr(obj, "files"):
91    #    raise TypeError()
92    #if request.method == "POST":
93    #    formset = get_file_formset(obj, request.POST)
94    #    if formset.is_valid():
95    #        obj.update_file(formset)
96    #        return HttpResponseRedirect(".")
97    #else:
98    #    formset = get_file_formset(obj)
99    #ctx.update({'current_page':'3D',
100    #            'file_formset': formset})
101    #return r2r('3d.htm', ctx, request)
102##########################################################################################
Note: See TracBrowser for help on using the repository browser.