Skip to content
Snippets Groups Projects
Commit d2162f38 authored by tolgayurt's avatar tolgayurt
Browse files

added all plot steps

parent 8498e96a
Branches
No related tags found
No related merge requests found
...@@ -43,7 +43,8 @@ INSTALLED_APPS = [ ...@@ -43,7 +43,8 @@ INSTALLED_APPS = [
'shapely', 'shapely',
'path', 'path',
'mplcursors', 'mplcursors',
'mpld3' 'mpld3',
'jquery',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
This diff is collapsed.
<!DOCTYPE HTML> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8"> <title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head> </head>
<body> <body>
{%for container_plots in containers %} {% autoescape off %}
<h1>Container</h1> <div style="padding-right: 15px; padding-left: 15px;">
{%for plot in container_plots%}
{{plot|safe}} <ul class="nav nav-tabs tabs-left">
{%endfor%} <li class="active"><a data-toggle="tab" href="#home">Home</a></li>
<hr> {%for tab in containers%}
{%endfor%} {% with forloop.counter|stringformat:"i" as strvalue%}
<li><a data-toggle="tab" href={{"#id"|add:strvalue}}>{{"#id"|add:strvalue}}</a></li>
{%endwith%}
{%endfor %}
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
{%for tab in containers%}
{% with forloop.counter|stringformat:"i" as strrvalue%}
<div id={{"id"|add:strrvalue}} class="tab-pane fade">
<h3>{{"id"|add:strrvalue}}</h3>
<p>{{tab|safe}}</p>
</div>
{%endwith%}
{%endfor %}
</div>
</div>
<div style="padding-right: 15px; padding-left: 15px;">
<ul class="nav nav-tabs ">
{%for tab in containers2%}
{% with forloop.counter|stringformat:"i" as str2value%}
{%if forloop.first %}
<li class="active"><a data-toggle="tab" href={{"#idd"|add:str2value}}>{{"#idd"|add:str2value}}</a></li>
{%else%}
<li><a data-toggle="tab" href={{"#idd"|add:str2value}}>{{"#idd"|add:str2value}}</a></li>
{%endif%}
{%endwith%}
{%endfor %}
</ul>
<div class="tab-content">
{%for tab2 in containers2%}
{% with forloop.counter|stringformat:"i" as str2value%}
{%if forloop.first %}
<div id={{"idd"|add:str2value}} class="tab-pane fade in active">
<h3>{{"idd"|add:str2value}}</h3>
<p>{{tab2|safe}}</p>
{% else %}
<div id={{"idd"|add:str2value}} class="tab-pane fade">
<h3>{{"idd"|add:str2value}}</h3>
<p>{{tab2|safe}}</p>
</div>
{% endif %}
{%endwith%}
{%endfor %}
</div>
</div>
</div>
{% endautoescape %}
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -7,8 +7,37 @@ ...@@ -7,8 +7,37 @@
</head> </head>
<body> <body>
{% autoescape off %} {% autoescape off %}
<h1>Polygons</h1>
{{polygons_plot}} {{polygons_plot}}
{% endautoescape %} <hr>
<h1> Highclasses</h1>
{%for hc in hc_plot%}
<h2>Highclass {{forloop.counter|add:"-1"}}</h2>
{{hc}}
{% if forloop.last is not True%}
<hr style="border: 2px dashed #C0C0C0" >
{%else%}
<hr>
{%endif%}
{%endfor%}
<h1>Highclasses -> Container</h1>
{{container_plot}}
{%for mini_container in mini_container_plot%}
<h2>Highclass-Container {{forloop.counter|add:"-1"}} -> Mini-Containers </h2>
{{mini_container}}
{% if forloop.last is not True%}
<hr style="border: 2px dashed #C0C0C0" >
{%else%}
<hr>
{%endif%}
{%endfor%}
<h1>End Container</h1>
{{end_container_plot}}
{% endautoescape %}
</body> </body>
</html> </html>
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
</head>
<body>
<div>
{% autoescape off %}
<h1>Polygons</h1>
{{polygons_plot}}
<hr>
<h1> Highclasses</h1>
{{hc_plot}}
<hr>
<h1>Highclasses -> Container</h1>
{{container_plot}}
<hr>
<h2>Highclass-Container -> Mini-Containers </h2>
{{mini_container_plot}}
<hr>
<h1>End Container</h1>
{{end_container_plot}}
{% endautoescape %}
</div>
</body>
</html>
\ No newline at end of file
...@@ -4,5 +4,5 @@ from . import views ...@@ -4,5 +4,5 @@ from . import views
urlpatterns = [ urlpatterns = [
path('plot/', views.index, name='index'), path('plot/', views.index, name='index'),
#path('json/', views.get_json_view, name='index2'), path('json/', views.get_json_view, name='index2'),
] ]
\ No newline at end of file
...@@ -18,17 +18,93 @@ import math ...@@ -18,17 +18,93 @@ import math
from plots import plot_helpers from plots import plot_helpers
from bokeh.plotting import figure, output_file, show from bokeh.plotting import figure, output_file, show
from bokeh.resources import CDN from bokeh.resources import CDN
from bokeh.models.widgets import Panel, Tabs
from bokeh.layouts import layout
from bokeh.models.widgets import Tabs, Panel
from bokeh.io import curdoc
from bokeh.plotting import figure
# def index(request): # def index(request):
# return HttpResponse("Hello, world. You're at the polls index.") # return HttpResponse("Hello, world. You're at the polls index.")
def index(request): def index(request):
# list_hc = height_classes(polygons)
# list_containers = building_containers(list_hc)
# list_mini_containers = pack_mini_containers(list_containers)
# end_container = End_Container(list_mini_containers, True)
#[(0.5, 0), (0, 1), (1, 0), (0.5, 0)] #[(0.5, 0), (0, 1), (1, 0), (0.5, 0)]
convex_polygons = poly.create_multiple_convex_polygons(10,3) convex_polygons = poly.create_multiple_convex_polygons(14,3)
polygons_plot=poly.plot_polygons(convex_polygons,False,500,500) polygons_plot= poly.plot_polygons(convex_polygons,plot_width=300,plot_height=300,render=False)
html_polygons = file_html(polygons_plot, CDN, "my plot") html_polygons = file_html(polygons_plot, CDN, "my plot")
return render(request, 'plots/index.html', context={'polygons_plot': html_polygons,})
high_classes = poly.height_classes(convex_polygons)
# hc_plot_helper=[]
# for hc in high_classes:
# hc_plot = hc.plot_hc(render=False,plot_width=300,plot_height=300)
# html_hc = file_html(hc_plot, CDN, "my plot")
# hc_plot_helper.append(html_hc)
hc_tab_list = []
counter = 0
for hc in high_classes:
hc_plot = hc.plot_hc(render=False,plot_width=300,plot_height=300)
# html_container = file_html(container_plot, CDN, "my plot")
# container_plot_helper.append(html_container)
tab = Panel(child=hc_plot, title="High-Class {}".format(counter, counter))
hc_tab_list.append(tab)
counter += 1
hc_tabs = Tabs(tabs=hc_tab_list)
hc_plot_helper = file_html(hc_tabs, CDN, "my plot")
list_containers = poly.building_containers(high_classes)
container_plot_helper = []
tab_list=[]
counter = 0
for container in list_containers:
container_plot = container.plot_container_steps(plot_width=500,colums=3,plot_height=500,render=False)
#html_container = file_html(container_plot, CDN, "my plot")
#container_plot_helper.append(html_container)
tab = Panel(child=container_plot, title="High-Class {} -> Container {}".format(counter, counter))
tab_list.append(tab)
counter += 1
tabs = Tabs(tabs=tab_list)
container_plot_helper= file_html(tabs, CDN, "my plot")
mini_containers_tuple = poly.pack_mini_containers(list_containers,plot_steps=True)
list_mini_containers = mini_containers_tuple[0]
mini_container_plots = mini_containers_tuple[1]
mini_plot = poly.plot_mini_containers(mini_container_plots,render=False)
mini_plots=[]
mini_plots_tabs=[]
for counter,m_plot in enumerate(mini_plot):
print(m_plot)
# print(m_plot[0])
# print(m_plot[1])
tab = Panel(child=m_plot, title="Container {} -> Mini-Container {}".format(counter, counter))
mini_plots_tabs.append(tab)
#m_plot = layout([[m_plot]],sizing_mode="scale_both")
#mini_plots.append(file_html( m_plot, CDN, "my plot"))
#tabs.append(Panel(child=m_plot, title="circle {}".format(counter)))
mini_tabs = Tabs(tabs=mini_plots_tabs)
mini_html_plots = file_html(mini_tabs, CDN, "my plot")
#tab =Tabs(tabs=tabs)
#mini_html_plots= mini_plots
end_container = poly.End_Container(list_mini_containers)
end_container_plot= end_container.plot_container(render=False)
end_container_html =file_html(end_container_plot, CDN, "my plot2")
return render(request, 'plots/index0.html', context={'polygons_plot': html_polygons,'hc_plot': hc_plot_helper,'container_plot': container_plot_helper,
'mini_container_plot': mini_html_plots, 'end_container_plot':end_container_html})
# 'high_classes': plot_high_class_list,}) # 'high_classes': plot_high_class_list,})
# 'hc_container': hc_container}) # 'hc_container': hc_container})
...@@ -36,13 +112,54 @@ def index(request): ...@@ -36,13 +112,54 @@ def index(request):
# def get_json_view(request): def get_json_view(request):
# convex_polygons = poly.create_multiple_convex_polygons(10, 3) convex_polygons = poly.create_multiple_convex_polygons(14, 3)
# hc = poly.height_classes(convex_polygons) #polygons_plot = poly.plot_polygons(convex_polygons, plot_width=300, plot_height=300, render=False)
# containers = poly.building_containers(hc) #html_polygons = file_html(polygons_plot, CDN, "my plot")
# list_hc = poly.height_classes(convex_polygons)
# container_plots=[] list_containers = poly.building_containers(list_hc)
# for container in containers:
# container_plots.append(container.plots) tab_list=[]
# #g = convex_polygons[0].plot_polygon() counter=0
# return render(request, 'plots/get.html', context={'containers': container_plots,}) for container in list_containers:
\ No newline at end of file container_plot = container.plot_container_steps(plot_width=500, colums=3, plot_height=500, render=False)
#tab1 = Panel(child=container_plot, title="High-Class {} -> Container {}".format(counter,counter))
tab_list.append(file_html(container_plot, CDN, "my plot"))
counter +=1
#html_container = file_html(tab_list, CDN, "my plot")
#container_plot_helper.append(html_container)
#tabs = Tabs(tabs=tab_list)
response = tab_list
mini_containers_tuple = poly.pack_mini_containers(list_containers, plot_steps=True)
list_mini_containers = mini_containers_tuple[0]
mini_container_plots = mini_containers_tuple[1]
mini_plot = poly.plot_mini_containers(mini_container_plots, render=False)
mini_plots = []
tabs = []
for counter, m_plot in enumerate(mini_plot):
mini_plots.append(file_html(m_plot, CDN, "my plot"))
# tabs.append(Panel(child=m_plot, title="circle {}".format(counter)))
# tab =Tabs(tabs=tabs)
mini_html_plots = mini_plots
# fig1 = figure()
# fig1.circle([0, 1, 2], [1, 3, 2])
# fig2 = figure()
# fig2.circle([0, 0, 2], [4, -1, 1])
# fig3 = figure()
# fig3.circle([0, 4, 3], [1, 2, 0])
#
# l1 = layout([[fig1, fig2]])
# l2 = layout([[fig3]])
#
# tab1 = Panel(child=fig1, title="This is Tab 1")
# tab2 = Panel(child=fig2, title="This is Tab 2")
# tabs = Tabs(tabs=[tab1, tab2])
# response =file_html(tabs, CDN, "my plot")
#show(tabs)
return render(request, 'plots/get.html', context={'containers': response,'containers2':mini_plots})
\ No newline at end of file
...@@ -4,4 +4,5 @@ path==15.0.0 ...@@ -4,4 +4,5 @@ path==15.0.0
numpy==1.19.2 numpy==1.19.2
mplcursors==0.3 mplcursors==0.3
mpld3 mpld3
bokeh bokeh
\ No newline at end of file django-jquery
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment