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

added javascript static files for bokeh plot and made it offline and changed...

added javascript static files for bokeh plot and made it offline and changed /index/ view to start page
parent f46c1c75
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -3,12 +3,10 @@ ...@@ -3,12 +3,10 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Packing Algorithm</title> <title>Packing Algorithm</title>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.2.3.min.js" {%load static %}
crossorigin="anonymous"></script> <script src="{% static 'plots/js/bokeh-2.2.3.min.js' %}"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js" <script src="{% static 'plots/js/bokeh-widgets-2.2.3.min.js' %}"></script>
crossorigin="anonymous"></script> <script src="{% static 'plots/js/bokeh-tables-2.2.3.min.js' %}"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.3.min.js"
crossorigin="anonymous"></script>
</head> </head>
<body> <body>
...@@ -16,7 +14,7 @@ ...@@ -16,7 +14,7 @@
<div style='display:inline'> <div style='display:inline'>
<h1>Drawn Polygons</h1> <h1>Drawn Polygons</h1>
{{ response|safe }} {{ response|safe }}
<form style='display:inline' action="/index/" method="post"> <form style='display:inline' action="{% url 'start-page' %}" method="post">
{% csrf_token %} {% csrf_token %}
<label for="drawn_polygons"><b>Load/Clear drawn Polygons</b></label> <label for="drawn_polygons"><b>Load/Clear drawn Polygons</b></label>
<input id="drawn_polygons" type="hidden" name="drawn_polygons" value="test"> <input id="drawn_polygons" type="hidden" name="drawn_polygons" value="test">
...@@ -38,7 +36,7 @@ ...@@ -38,7 +36,7 @@
</form> </form>
</div> </div>
<div> <div>
<form action="/create_convex_polygons/" target="_blank" method="post"> <form action="/create_convex_polygons/" method="post">
{% csrf_token %} {% csrf_token %}
<label for="polygon_count"><b>Create Random Polygons, Number of Polygons</b></label> <label for="polygon_count"><b>Create Random Polygons, Number of Polygons</b></label>
<input id="polygon_count" type="number" min="0" name="polygon_count" value=5> <input id="polygon_count" type="number" min="0" name="polygon_count" value=5>
......
<!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>Packed Polygons Steps</h1>
{{polygons_plot}}
{{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
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
{%load static %}
<script src="{% static 'plots/js/bokeh-2.2.3.min.js' %}"></script>
<script src="{% static 'plots/js/bokeh-widgets-2.2.3.min.js' %}"></script>
<script src="{% static 'plots/js/bokeh-tables-2.2.3.min.js' %}"></script>
<title>Packed Polygons</title> <title>Packed Polygons</title>
</head> </head>
<body> <body>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.2.3.min.js"
crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js"
crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.3.min.js"
crossorigin="anonymous"></script>
</head>
<body>
<div>
{{ response|safe }}
<form action="/test/" method="post">
{% csrf_token %}
<label for="your_name">Load the drawn Polygons</label>
<input id="your_name" type="hidden" name="your_name" value="test">
<input type="submit" onclick="myFunction()" value="load">
</form>
</div>
<div style='display:inline'>
<form style='display:inline' action="/csv_polygons/" method="post">
{% csrf_token %}
<label for="load_csv_polygons">Load CSV Polygons</label>
<input id="load_csv_polygons" type="hidden" name="load_csv_polygons" value="test">
<input type="submit" value="load">
</form>
</div>
<form style='display:inline' action="/csv_polygons/" method="get">
{% csrf_token %}
<label for="clear_csv_polygons"></label>
<input id="clear_csv_polygons" type="hidden" name="clear_csv_polygons" value="test">
<input type="submit" value="clear">
</form>
<div>
<form action="/packing_rect_container/" target="_blank" method="get">
{% csrf_token %}
<label for="pack_rect_container">Packing Rectengular Container</label>
<input id="pack_rect_container" type="hidden" name="pack_polygon" value="test">
<input type="submit" onclick="packPolygons()" value="pack">
</form>
</div>
<div>
<form action="/packing_rotated_rect_container/" target="_blank" method="get">
{% csrf_token %}
<label for="pack_rotated_rect_container">Packing Rotated Rectengular Container</label>
<input id="pack_rotated_rect_container" type="hidden" name="pack_polygon" value="test">
<input type="submit" onclick="packPolygons()" value="pack">
</form>
</div>
<div>
<form action="/packing_convex_container/" target="_blank" method="post">
{% csrf_token %}
<label for="pack_convex_container">Packing Convex Container (degree between 1-360)</label>
<input id="pack_convex_container" type="number" min="1" max="360" name="angle" value=10>
<input type="submit" value="pack">
</form>
</div>
<div>
{% autoescape off %}
<h1>Drawn Convex Polygons</h1>
{{drawn_polygons|safe}}
<h1>Csv input Convex Polygons</h1>
{{csv_polygons|safe}}
<h1>Convex Polygons to Pack</h1>
{{polygons_single_plot|safe}}
{% endautoescape %}
</div>
</body>
<script>
function myFunction() {
var ds = Bokeh.documents[0].get_model_by_name('my-data-source');
var dict1 = {x:ds.data["x"], y:ds.data["y"]};
document.getElementById("your_name").value =JSON.stringify(dict1);
}
</script>
</html>
\ No newline at end of file
...@@ -4,11 +4,7 @@ from plots.views import PolygonEditView, PackingRectContainer, PackingRotatedRec ...@@ -4,11 +4,7 @@ from plots.views import PolygonEditView, PackingRectContainer, PackingRotatedRec
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('plot/', views.index, name='index'), path('', PolygonEditView.as_view(), name='start-page'),
#path('json/', views.get_json_view, name='index2'),
#path('test/', views.test, name='index3'),
#path('hello/', views.hello, name='index4'),
path('index/', PolygonEditView.as_view(), name='index4'),
path('packing_rect_container/', PackingRectContainer.as_view(), name='rect_container'), path('packing_rect_container/', PackingRectContainer.as_view(), name='rect_container'),
path('packing_rotated_rect_container/', PackingRotatedRectContainer.as_view(), name='rotated_rect_container'), path('packing_rotated_rect_container/', PackingRotatedRectContainer.as_view(), name='rotated_rect_container'),
path('packing_convex_container/', PackingConvexContainer.as_view(), name='convex_container'), path('packing_convex_container/', PackingConvexContainer.as_view(), name='convex_container'),
......
...@@ -42,6 +42,7 @@ from bokeh.models.callbacks import CustomJS ...@@ -42,6 +42,7 @@ from bokeh.models.callbacks import CustomJS
from bokeh.embed import json_item from bokeh.embed import json_item
import json import json
import pandas import pandas
from django.urls import reverse
def index(request): def index(request):
...@@ -111,7 +112,7 @@ class ClearPolygons(View): ...@@ -111,7 +112,7 @@ class ClearPolygons(View):
PolygonEditView.plot_min_x = 0 PolygonEditView.plot_min_x = 0
PolygonEditView.plot_max_y = 100 PolygonEditView.plot_max_y = 100
PolygonEditView.plot_min_y = 0 PolygonEditView.plot_min_y = 0
return HttpResponseRedirect('/index/') return HttpResponseRedirect(reverse('start-page'))
class CreateConvexPolygons(View): class CreateConvexPolygons(View):
...@@ -132,7 +133,7 @@ class CreateConvexPolygons(View): ...@@ -132,7 +133,7 @@ class CreateConvexPolygons(View):
PolygonEditView.plot_max_y = max(all_y_values) PolygonEditView.plot_max_y = max(all_y_values)
PolygonEditView.plot_min_y = min(all_y_values) PolygonEditView.plot_min_y = min(all_y_values)
return HttpResponseRedirect('/index/') return HttpResponseRedirect(reverse('start-page'))
class CSVPolygons(View): class CSVPolygons(View):
...@@ -149,7 +150,7 @@ class CSVPolygons(View): ...@@ -149,7 +150,7 @@ class CSVPolygons(View):
else: else:
polygons_single_plot_html = "No Polygons" polygons_single_plot_html = "No Polygons"
PolygonEditView.context["polygons_single_plot"] = polygons_single_plot_html PolygonEditView.context["polygons_single_plot"] = polygons_single_plot_html
return HttpResponseRedirect('/index/') return HttpResponseRedirect('//')
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
df = pandas.read_csv('plots/polygon.txt',sep="#") df = pandas.read_csv('plots/polygon.txt',sep="#")
...@@ -170,7 +171,7 @@ class CSVPolygons(View): ...@@ -170,7 +171,7 @@ class CSVPolygons(View):
PolygonEditView.plot_max_y = max(all_y_values) PolygonEditView.plot_max_y = max(all_y_values)
PolygonEditView.plot_min_y = min(all_y_values) PolygonEditView.plot_min_y = min(all_y_values)
return HttpResponseRedirect('/index/') return HttpResponseRedirect(reverse('start-page'))
...@@ -227,12 +228,11 @@ class PolygonEditView(View): ...@@ -227,12 +228,11 @@ class PolygonEditView(View):
polygons_x_y_tuple = list(zip(dict_poly["x"], dict_poly["y"])) polygons_x_y_tuple = list(zip(dict_poly["x"], dict_poly["y"]))
for x,y in polygons_x_y_tuple: for x,y in polygons_x_y_tuple:
polygon_list.append(list(zip(x,y))) polygon_list.append(list(zip(x,y)))
print(polygon_list) drawn_polygons = []
drawn_polygons=[]
polygon_max_x_list=[] polygon_max_x_list=[]
polygon_min_x_list = [] polygon_min_x_list = []
polygon_min_y_list = [] polygon_min_y_list = []
polygon_max_y_list=[] polygon_max_y_list = []
for polygon in polygon_list: for polygon in polygon_list:
try: try:
polygon2 = poly.ConvexPolygon(polygon) polygon2 = poly.ConvexPolygon(polygon)
...@@ -260,5 +260,5 @@ class PolygonEditView(View): ...@@ -260,5 +260,5 @@ class PolygonEditView(View):
polygons_single_plot_html = file_html(polygons_single_plot, CDN, "single plot") polygons_single_plot_html = file_html(polygons_single_plot, CDN, "single plot")
PolygonEditView.context["polygons_single_plot"] = polygons_single_plot_html PolygonEditView.context["polygons_single_plot"] = polygons_single_plot_html
return HttpResponseRedirect('/index/') return HttpResponseRedirect(reverse('start-page'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment