Ver código fonte

show all, still working on displaying it nicely

bscheibel 4 anos atrás
pai
commit
bd10d14e26

+ 8 - 0
app/static/css/style.css

@@ -58,8 +58,16 @@ body {
         border: 3px solid black;
         border-collapse: collapse;
 }
+.indent {
+    margin-left: 10
+}
+.text {
+    font-size: 2px;
+    font-size: 1vw;
+}
 /* Style the image inside the centered container, if needed */
 .centered img {
   max-width: 140%;
   /*border-radius: 50%;
 }
+

+ 21 - 6
app/templates/show_image.html

@@ -8,8 +8,10 @@
 <div class="split left">
 <div class="header_centered">
   <h1>Drawing</h1>
+           <p><a  href="http://localhost:5000/"> Upload another drawing </a></p>
 </div>
   <div class="centered">
+
     {% if filename %}
       <img src="{{ url_for('send_file', filename=filename) }}"/>
     {% else %}
@@ -21,17 +23,30 @@
 
 <div class="split right">
   <div class="top">
-    <div style="text-indent:50px;">
       <h1>Extracted Tolerances</h1>
-      <p>Maße: {{ dims }} </p>
-      <p><a  href="http://localhost:5000/"> Upload another drawing </a></p>
+            <font size="1" face="Courier New" >
+            <table>
+                <tr>
+                  <td><h2>Important?</h2></td>
+                  <td><h2>Target Values</h2></td>
+                  <td><h2>Actual Values</h2></td>
+                </tr>
+                {% for d in dims %}
+                <tr>
+                        <td><input type="checkbox" name="check" value="checked"></td>
+                        <td> {{ d }}</td>
+                        <td><input type="text" name="actual"></td>
+                </tr>
+                {% endfor %}
+        </table>
+        </font>
     </div>
-  </div>
 
 
-  <div class="bottom">
+  <div class="bottom indent">
     <div style="text-indent:50px;">
       <h1>Additional Requirements:</h1>
+      <div style="text-indent:20px">
       <table>
 
         {% for k in isos %}
@@ -40,7 +55,7 @@
                 </tr>
         {% endfor %}
       </table>
-
+    </div>
     </div>
     </div>
 </div>

+ 15 - 13
app/views.py

@@ -1,6 +1,4 @@
 from app import app
-import os
-from flask import make_response
 from flask import Flask, request, redirect, url_for, send_from_directory, render_template
 import subprocess
 import order_bounding_boxes_in_each_block
@@ -21,18 +19,24 @@ def allowed_file(filename):
     return '.' in filename and \
            filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
 
+def convert_pdf(filename):
+    PDFFILE = UPLOAD_FOLDER +"/" + filename
+    subprocess.call(['pdftoppm', '-jpeg', '-singlefile',
+                     PDFFILE, '/home/bscheibel/uploads_app/out'])
+
+def extract_all(uuid, filename):
+    order_bounding_boxes_in_each_block.main(uuid, UPLOAD_FOLDER + "/" + filename)
+    subprocess.call(['python3','/home/bscheibel/PycharmProjects/dxf_reader/clustering_precomputed_dbscan.py', str(uuid), str(uuid)+"out.html",'localhost'])
+
 @app.route('/', methods=['GET', 'POST'])
 def upload_file():
     if request.method == 'POST':
         file = request.files['file']
         if file and allowed_file(file.filename):
-
             filename = file.filename
-            #image = wandImage(filename=filename)
-            #image.save(os.path).join(app.config["UPLOAD_FOLDER"], filename)
             file.save(os.path.join(app.config["UPLOAD_FOLDER"], filename))
             uuid = random.randint(100,10000000)
-            order_bounding_boxes_in_each_block.main(uuid, UPLOAD_FOLDER+"/"+filename)
+            extract_all(uuid, filename)
             return redirect(url_for('uploaded_file', filename=filename, uuid=uuid))
     return '''
     <!doctype html>
@@ -43,10 +47,6 @@ def upload_file():
          <input type=submit value=Upload>
     </form>
     '''
-def convert_pdf(filename):
-    PDFFILE = UPLOAD_FOLDER +"/" + filename
-    subprocess.call(['pdftoppm', '-jpeg', '-singlefile',
-                     PDFFILE, '/home/bscheibel/uploads_app/out'])
 
 @app.route('/show/<filename>&<uuid>')
 def uploaded_file(filename, uuid):
@@ -54,9 +54,11 @@ def uploaded_file(filename, uuid):
     if filename.endswith(".pdf") or filename.endswith(".PDF"):
         convert_pdf(filename)
         db = redis.Redis("localhost")
-        #uuid = "dd"
-        isos = json.loads(db.get(uuid))
-        return render_template('show_image.html', filename=file_out, isos=isos)
+        iso = db.get(uuid+"dims")
+        print(iso)
+        isos = json.loads(db.get(uuid+"isos"))
+        dims = json.loads(db.get(uuid+"dims"))
+        return render_template('show_image.html', filename=file_out, isos=isos, dims=dims)
 
     else:
         filename = filename

+ 8 - 7
order_bounding_boxes_in_each_block.py

@@ -7,7 +7,7 @@ import re
 import json
 
 def get_bound_box(uuid, file):
-    print(file)
+    #print(file)
     response = open(file)
     html_doc = response.read()
     response.close()
@@ -52,9 +52,6 @@ def get_bound_box(uuid, file):
 
         #print("\n")"""
 
-
-    db = redis.Redis("localhost")
-    db.set(uuid, "test")
     return new_all_elements, uuid
 
 def pdf_to_html(uuid,filepath):
@@ -69,7 +66,7 @@ def extract_isos(result):
         #print(element)
         for x in element:
             new_arr += x[4] + " "
-        print(new_arr)
+        #print(new_arr)
         if re.search(reg,new_arr):
             #print(new_arr)
             found = re.findall(reg, new_arr)
@@ -86,8 +83,12 @@ def main(uuid, result):
     isos = extract_isos(res)
     isos_j = json.dumps(isos)
     db = redis.Redis("localhost")
-    print(isos)
-    db.set(uuid, str(isos_j))
+    #print(isos)
+    db.set(str(uuid)+"isos", str(isos_j))
+    #print(db.get(uuid))
+
+
+
 
 """file = "/home/bscheibel/PycharmProjects/dxf_reader/drawings/5129275_Rev01-GV12.html"
 res, uuid = get_bound_box("uuu", file)