netrender:
authorMartin Poirier <theeth@yahoo.com>
Fri, 8 Jan 2010 02:33:20 +0000 (02:33 +0000)
committerMartin Poirier <theeth@yahoo.com>
Fri, 8 Jan 2010 02:33:20 +0000 (02:33 +0000)
thumbnails on the web interface (resized with imagemagick or compatible if present, fullsize otherwise)
Clicking on the "show" link shows the thumbnail associated with one frame. Clicking on a second one shows all frames in the range. Clicking on more frames extends the range. Clicking on a thumbnail (or on the show link of a visible thumbnail) hides all thumbnails.

release/scripts/io/netrender/master.py
release/scripts/io/netrender/master_html.py
release/scripts/io/netrender/netrender.css
release/scripts/io/netrender/netrender.js
release/scripts/io/netrender/utils.py

index aa109c8b6f345febba3d3517a991b4ab18d192a2..3ff3758f66e41094c11431110ad2c4ab8e6824a9 100644 (file)
@@ -258,6 +258,12 @@ class RenderHandler(http.server.BaseHTTPRequestHandler):
                                     bpy.ops.image.open(path = job.save_path + "%04d" % frame_number + ".exr")
                                     img = bpy.data.images["%04d" % frame_number + ".exr"]
                                     img.save(filename)
+                                    
+                                    try:
+                                        process = subprocess.Popen(["convert", filename, "-resize", "300x300", filename])
+                                        process.wait()                                        
+                                    except:
+                                        pass
                                 
                                 f = open(filename, 'rb')
                                 self.send_head(content = "image/jpeg")
index f55712caa0fc331ea040357306a843c45787a160..3fff6d0b88c632906faaafce3e1af09eeee45072 100644 (file)
@@ -37,8 +37,11 @@ def get(handler):
         output("<link rel='stylesheet' href='/html/netrender.css' type='text/css'>")
 
 
-    def link(text, url):
-        return "<a href='%s'>%s</a>" % (url, text)
+    def link(text, url, script=""):
+        return "<a href='%s' %s>%s</a>" % (url, script, text)
+
+    def tag(name, text, attr=""):
+        return "<%s %s>%s</%s>" % (name, attr, text, name)
 
     def startTable(border=1, class_style = None, caption = None):
         output("<table border='%i'" % border)
@@ -259,7 +262,7 @@ def get(handler):
             output("<h2>Frames</h2>")
 
             startTable()
-            headerTable("no", "status", "render time", "slave", "log", "result")
+            headerTable("no", "status", "render time", "slave", "log", "result", "")
 
             for frame in job.frames:
                 rowTable(
@@ -269,7 +272,8 @@ def get(handler):
                          frame.slave.name if frame.slave else "&nbsp;",
                          link("view log", logURL(job_id, frame.number)) if frame.log_path else "&nbsp;",
                          link("view result", renderURL(job_id, frame.number))  + " [" +
-                         link("jpeg", renderURL(job_id, frame.number, exr = False)) + "]" if frame.status == DONE else "&nbsp;"
+                         tag("span", "show", attr="class='thumb' onclick='showThumb(%s, %i)'" % (job.id, frame.number)) + "]" if frame.status == DONE else "&nbsp;",
+                         "<img name='thumb%i' title='hide thumbnails' src='' class='thumb' onclick='showThumb(%s, %i)'>" % (frame.number, job.id, frame.number)
                          )
 
             endTable()
index 87de1083315d4d5ee3f5fcf36b77530461862ebb..cc8a93bb9a71aaea6d67fca80875a9c42239c6da 100644 (file)
@@ -60,7 +60,6 @@ button {
        cursor: pointer;
 }
 
-
 .cache {
        display: none;
 }
@@ -72,4 +71,14 @@ button {
 .rules {
        width: 60em;
        text-align: left;
-}
\ No newline at end of file
+}
+
+img.thumb {
+       display: none;
+       cursor: pointer;
+}
+
+span.thumb {
+       text-decoration: underline;
+       cursor: pointer;
+}
index cf4ab39a6fa787ea0f30363a40566fd1961ed616..9bdd048d3c4f71b2e1c97dca93e5b3807b595a9e 100644 (file)
@@ -1,3 +1,7 @@
+lastFrame = -1
+maxFrame = -1
+minFrame = -1
+
 function request(url, data)
 {
        xmlhttp = new XMLHttpRequest();
@@ -46,6 +50,70 @@ function balance_enable(id, value)
        request("/balance_enable", "{" + id + ":" + value + "}");
 }
 
+function showThumb(job, frame)
+{
+       if (lastFrame != -1) {
+               if (maxFrame != -1 && minFrame != -1) {
+                       if (frame >= minFrame && frame <= maxFrame) {
+                               for(i = minFrame; i <= maxFrame; i=i+1) {
+                                       toggleThumb(job, i);
+                               }
+                               minFrame = -1;
+                               maxFrame = -1;
+                               lastFrame = -1;
+                       } else if (frame > maxFrame) {
+                               for(i = maxFrame+1; i <= frame; i=i+1) {
+                                       toggleThumb(job, i);
+                               }
+                               maxFrame = frame;
+                               lastFrame = frame;
+                       } else {
+                               for(i = frame; i <= minFrame-1; i=i+1) {
+                                       toggleThumb(job, i);
+                               }
+                               minFrame = frame;
+                               lastFrame = frame;
+                       }
+               } else if (frame == lastFrame) {
+                       toggleThumb(job, frame);
+               } else if (frame < lastFrame) {
+                       minFrame = frame;
+                       maxFrame = lastFrame;
+
+                       for(i = minFrame; i <= maxFrame-1; i=i+1) {
+                               toggleThumb(job, i);
+                       }
+                       lastFrame = frame;
+               } else {
+                       minFrame = lastFrame;
+                       maxFrame = frame;
+
+                       for(i = minFrame+1; i <= maxFrame; i=i+1) {
+                               toggleThumb(job, i);
+                       }
+                       lastFrame = frame;
+               }
+       } else {
+               toggleThumb(job, frame);
+       }
+}
+
+function toggleThumb(job, frame)
+{
+       img = document.images["thumb" + frame];
+       url = "/render_" + job + "_" + frame + ".jpg"
+
+       if (img.style.display == "block") {
+               img.style.display = "none";
+               img.src = "";
+               lastFrame = -1;
+       } else {
+               img.src = url;
+               img.style.display = "block";
+               lastFrame = frame;
+       }
+}
+
 function returnObjById( id )
 {
     if (document.getElementById)
index e9103db8da7400fadbab885b4c36157f5c3e487b..7e644c83e5fdd5bd236b28475a7621793d2293ed 100644 (file)
@@ -148,8 +148,8 @@ def fileURL(job_id, file_index):
 def logURL(job_id, frame_number):
     return "/log_%s_%i.log" % (job_id, frame_number)
 
-def renderURL(job_id, frame_number, exr = True):
-    return "/render_%s_%i.%s" % (job_id, frame_number, "exr" if exr else "jpg")
+def renderURL(job_id, frame_number):
+    return "/render_%s_%i.exr" % (job_id, frame_number)
 
 def cancelURL(job_id):
     return "/cancel_%s" % (job_id)