Loading gwl-graphics/gwl/source/viewport-html-div.lisp +77 −17 Original line number Diff line number Diff line Loading @@ -22,17 +22,17 @@ (in-package :gwl) ;; Create viewport-html-div for 3D visualization in a page section ;; Define viewport-html-div for 3D visualization in a page section (define-object viewport-html-div (base-html-div) :input-slots ((display-list-objects nil) (display-list-object-roots nil) (width 400) (height 300) (display-controls-hash nil) (image-format-default :svg) (vector-graphics-onclick? nil) (projection-vector (getf *standard-views* :trimetric)) (background-color (lookup-color (getf *colors-default* :background) :format :decimal)) (foreground-color (lookup-color (getf *colors-default* :foreground) :format :decimal)) Loading @@ -44,7 +44,7 @@ :computed-slots ((div-style (format nil "width: ~apx; height: ~apx;" (the width) (the height))) (inner-html (with-cl-who-string () (inner-html (with-lhtml-string () (str (ecase (the image-format) (:svg (the svg-content)) (:png (the png-content)) Loading @@ -54,11 +54,11 @@ (:script (str (the viewport-js-text))))) (svg-content (if (the no-graphics?) (with-cl-who-string () (with-lhtml-string () ((:div :id "empty-viewport" :class "empty-viewport") (:p "No graphics objects specified"))) (with-error-handling () (with-cl-who-string () (with-lhtml-string () (str (with-output-to-string (ss) (with-format (svg ss :id (the svg-id) Loading @@ -68,18 +68,62 @@ (png-content "<p>PNG graphics not implemented yet</p>") (jpeg-content "<p>JPEG graphics not implemented yet</p>") (x3dom-content "<p>X3DOM graphics not implemented yet</p>") (a-frame-content "<p>A-Frame graphics not implemented yet</p>") (x3dom-content (if (the no-graphics?) (with-lhtml-string () ((:div :id "empty-viewport" :class "empty-viewport") (:p "No graphics objects specified"))) (with-error-handling () (with-lhtml-string () ;; FLAG -- why need this span? ((:span :id (string-append (the x3dom-id) "-span")) ((:|X3D| :id (the x3dom-id) :style "background: #d3d3d3" :width (format nil "~apx" (the width)) :height (format nil "~apx" (the height))) (:|Scene| ((:|navigationinfo| :|id| "navi" :|transitionTime| "0.0")) (str (with-output-to-string (ss) (with-format (x3d ss) (write-the view-object cad-output))))))))))) (a-frame-content "<p>A-Frame graphics not implemented yet</p>") (no-graphics? (and (null (the display-list-objects)) (null (the display-list-object-roots)))) (svg-id (string-append (the dom-id) "-svg-section")) (x3dom-id (string-append (the dom-id) "-x3dom-section")) (viewport-js-text (ecase (the image-format) (:x3dom (format nil " function x3draw~a() { console.log('running x3draw for ~a'); if (typeof x3dom !== 'undefined') { x3dom.reload(); } var x3domElem = document.getElementById('~a'); if (x3domElem && x3domElem.runtime) { x3domElem.runtime.resetView(); x3domElem.runtime.fitAll(); } console.log('Done running x3draw'); } // Execute x3draw when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', x3draw~a); } else { x3draw~a(); } " (the dom-id) (the dom-id) (the x3dom-id) (the dom-id) (the dom-id))) (:svg (format nil " if (document.getElementById('~a')) { Loading @@ -93,7 +137,8 @@ if (document.getElementById('~a')) { center: true }); };" (the svg-id) (the dom-id) (the svg-id))) ((:png :jpeg :x3dom :a-frame) "")))) ((:png :jpeg :a-frame) "")))) :objects ((view-object :type 'web-drawing Loading @@ -115,21 +160,36 @@ if (document.getElementById('~a')) { :computed-slots ((use-svgpanzoom? t) (use-x3dom? t) ;; Enable x3dom support (body (with-lhtml-string () (str (the development-links)) (:h1 "Test Page with Viewport") (:p "This page demonstrates the new viewport-html-div component:") (str (the view-1 div)) (:h2 "SVG Format") (str (the view-svg div)) (:h2 "X3DOM Format") (str (the view-x3dom div)) (:p "End of test page.")))) :objects ((box-1 :type 'box :display-controls (list :color :blue :line-thickness 2) :length 20 :width (* +phi+ (the-child length)) :height (* +phi+ (the-child width))) (view-1 :type 'viewport-html-div (view-svg :type 'viewport-html-div :width 500 :height 400 :image-format :svg :display-list-objects (the objects)) (view-x3dom :type 'viewport-html-div :width 500 :height 400 :image-format :x3dom :display-list-objects (the objects)))) (with-all-servers (server) (publish-gwl-app "/test-view" 'test-viewport-page Loading Loading
gwl-graphics/gwl/source/viewport-html-div.lisp +77 −17 Original line number Diff line number Diff line Loading @@ -22,17 +22,17 @@ (in-package :gwl) ;; Create viewport-html-div for 3D visualization in a page section ;; Define viewport-html-div for 3D visualization in a page section (define-object viewport-html-div (base-html-div) :input-slots ((display-list-objects nil) (display-list-object-roots nil) (width 400) (height 300) (display-controls-hash nil) (image-format-default :svg) (vector-graphics-onclick? nil) (projection-vector (getf *standard-views* :trimetric)) (background-color (lookup-color (getf *colors-default* :background) :format :decimal)) (foreground-color (lookup-color (getf *colors-default* :foreground) :format :decimal)) Loading @@ -44,7 +44,7 @@ :computed-slots ((div-style (format nil "width: ~apx; height: ~apx;" (the width) (the height))) (inner-html (with-cl-who-string () (inner-html (with-lhtml-string () (str (ecase (the image-format) (:svg (the svg-content)) (:png (the png-content)) Loading @@ -54,11 +54,11 @@ (:script (str (the viewport-js-text))))) (svg-content (if (the no-graphics?) (with-cl-who-string () (with-lhtml-string () ((:div :id "empty-viewport" :class "empty-viewport") (:p "No graphics objects specified"))) (with-error-handling () (with-cl-who-string () (with-lhtml-string () (str (with-output-to-string (ss) (with-format (svg ss :id (the svg-id) Loading @@ -68,18 +68,62 @@ (png-content "<p>PNG graphics not implemented yet</p>") (jpeg-content "<p>JPEG graphics not implemented yet</p>") (x3dom-content "<p>X3DOM graphics not implemented yet</p>") (a-frame-content "<p>A-Frame graphics not implemented yet</p>") (x3dom-content (if (the no-graphics?) (with-lhtml-string () ((:div :id "empty-viewport" :class "empty-viewport") (:p "No graphics objects specified"))) (with-error-handling () (with-lhtml-string () ;; FLAG -- why need this span? ((:span :id (string-append (the x3dom-id) "-span")) ((:|X3D| :id (the x3dom-id) :style "background: #d3d3d3" :width (format nil "~apx" (the width)) :height (format nil "~apx" (the height))) (:|Scene| ((:|navigationinfo| :|id| "navi" :|transitionTime| "0.0")) (str (with-output-to-string (ss) (with-format (x3d ss) (write-the view-object cad-output))))))))))) (a-frame-content "<p>A-Frame graphics not implemented yet</p>") (no-graphics? (and (null (the display-list-objects)) (null (the display-list-object-roots)))) (svg-id (string-append (the dom-id) "-svg-section")) (x3dom-id (string-append (the dom-id) "-x3dom-section")) (viewport-js-text (ecase (the image-format) (:x3dom (format nil " function x3draw~a() { console.log('running x3draw for ~a'); if (typeof x3dom !== 'undefined') { x3dom.reload(); } var x3domElem = document.getElementById('~a'); if (x3domElem && x3domElem.runtime) { x3domElem.runtime.resetView(); x3domElem.runtime.fitAll(); } console.log('Done running x3draw'); } // Execute x3draw when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', x3draw~a); } else { x3draw~a(); } " (the dom-id) (the dom-id) (the x3dom-id) (the dom-id) (the dom-id))) (:svg (format nil " if (document.getElementById('~a')) { Loading @@ -93,7 +137,8 @@ if (document.getElementById('~a')) { center: true }); };" (the svg-id) (the dom-id) (the svg-id))) ((:png :jpeg :x3dom :a-frame) "")))) ((:png :jpeg :a-frame) "")))) :objects ((view-object :type 'web-drawing Loading @@ -115,21 +160,36 @@ if (document.getElementById('~a')) { :computed-slots ((use-svgpanzoom? t) (use-x3dom? t) ;; Enable x3dom support (body (with-lhtml-string () (str (the development-links)) (:h1 "Test Page with Viewport") (:p "This page demonstrates the new viewport-html-div component:") (str (the view-1 div)) (:h2 "SVG Format") (str (the view-svg div)) (:h2 "X3DOM Format") (str (the view-x3dom div)) (:p "End of test page.")))) :objects ((box-1 :type 'box :display-controls (list :color :blue :line-thickness 2) :length 20 :width (* +phi+ (the-child length)) :height (* +phi+ (the-child width))) (view-1 :type 'viewport-html-div (view-svg :type 'viewport-html-div :width 500 :height 400 :image-format :svg :display-list-objects (the objects)) (view-x3dom :type 'viewport-html-div :width 500 :height 400 :image-format :x3dom :display-list-objects (the objects)))) (with-all-servers (server) (publish-gwl-app "/test-view" 'test-viewport-page Loading