id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
35,871 | dropped-curve.lisp | lisp-mirror_gendl/surf/source/dropped-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object dropped-curve (curve)
:documentation (:description "Creates a 3D curve which is the <tt>curve-in</tt> dropped normally to the <tt>surface.</tt>.
The resulting 3D curve contains a uv-curve which is typically useful for trimming.
NOTE: Change from 1577p027 and forward -- the dropped curve now is a 3D curve which
can be drawn. It contains its uv representation on the surface. Previously, the uv-curve
was the actual dropped-curve.
"
:examples "<pre>
(in-package :surf)
(define-object test-trimmed-from-dropped-2 (trimmed-surface)
:computed-slots
((uv-inputs t)
(holes (list (the hole uv-curve)))
(island (the island-3d uv-curve))
(reverse-island? t) (reverse-holes? t)
(display-controls (list :color :blue :line-thickness 2)))
:hidden-objects
((basis-surface :type 'test-fitted-surface
:display-controls (list :color :grey-light-very)
:grid-length 10 :grid-width 10 :grid-height 5)
(island-3d :type 'dropped-curve
:curve-in (the raised-island)
:surface (the basis-surface))
(hole :type 'dropped-curve
:curve-in (the raised-hole)
:surface (the basis-surface))
(raised-hole :type 'b-spline-curve
:display-controls (list :color :grey-light-very)
:control-points (list (make-point 3.5 4.5 7)
(make-point 4.5 6 7)
(make-point 5.5 7 7)
(make-point 6 4.5 7)
(make-point 5.5 2 7)
(make-point 4.5 2 7)
(make-point 3.5 4.5 7)))
(raised-island :type 'b-spline-curve
:display-controls (list :color :grey-light-very)
:control-points (list (make-point 3 5 7)
(make-point 5 8 7)
(make-point 7 10 7)
(make-point 8 5 7)
(make-point 7 0 7)
(make-point 5 0 7)
(make-point 3 5 7)))))
(generate-sample-drawing
:objects (let ((self (make-object 'test-trimmed-from-dropped-2)))
(list (the basis-surface) self (the raised-hole)
(the raised-island)))
:projection-direction :trimetric)
</pre>")
:input-slots
("GDL NURBS Curve. The curve to be dropped to the surface."
curve-in
"GDL NURBS Surface. The surface on which the <tt>curve-in</tt> is to be dropped."
surface)
:computed-slots
((native-curve-uv (multiple-value-bind (control-points weights knots degree)
(get-b-spline-curve*-data
*geometry-kernel*
(let ((dropped-curves (drop-curve *geometry-kernel* (the curve-in) (the surface))))
(if (consp (rest dropped-curves))
(error "Dropping resulted in multiple curve segments. Dropped-curves is not yet implemented.
Please contact Genworks so we can expedite implementing this and provide a patch.")
(first dropped-curves))))
(make-b-spline-curve *geometry-kernel* control-points weights degree knots)))
(built-from (the 3d-curve)))
:hidden-objects
((uv-curve :type 'curve
:native-curve (the native-curve-uv))
(3d-curve :type 'b-spline-curve
:knot-vector (the uv-curve knot-vector)
:weights (the uv-curve weights)
:degree (the uv-curve degree)
:control-points (mapcar #'(lambda(point)
(the surface (point (get-x point) (get-y point))))
(the uv-curve control-points)))))
(define-object test-dropped-curve (dropped-curve)
:hidden-objects
((curve-in :type 'b-spline-curve
:control-points (list (make-point 3 5 1)
(make-point 5 8.0 1)
(make-point 7 10.0 1)
(make-point 8 5.0 1)
(make-point 7 0.0 1)
(make-point 5 0.0 1)
(make-point 3 5 1)))
(surface :type 'planar-surface
:p00 (make-point 0 0 0)
:p01 (make-point 0 10 0)
:p10 (make-point 10 0 0)
:p11 (make-point 15 15 0))))
(define-object test-dropped-curve-2 (dropped-curve)
:hidden-objects
((curve-in :type 'linear-curve
:start (the surface (point 0 0)) :end (the surface (point 1 1)))
(surface :type 'planar-surface
:p00 (make-point 0 0 0)
:p01 (make-point 0 10 0)
:p10 (make-point 10 0 0)
:p11 (make-point 15 15 0))))
| 6,125 | Common Lisp | .lisp | 121 | 35.471074 | 125 | 0.545439 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 903b4fe1f42809f771716267b64b6446351cde9b4a29b671ab3a25fb02be3ebc | 35,871 | [
-1
] |
35,872 | box-intersection .lisp | lisp-mirror_gendl/surf/source/box-intersection .lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(defun line-intersection (n)
(let ((x1 (first n))
(y1 (second n))
(x2 (third n))
(y2 (fourth n))
(x3 (fifth n))
(y3 (sixth n))
(x4 (seventh n))
(y4 (eighth n)))
(let ((denom (- (* (- y4 y3) (- x2 x1)) (* (- x4 x3) (- y2 y1))))
(ua-num (- (* (- x4 x3) (- y1 y3)) (* (- y4 y3) (- x1 x3))))
(ub-num (- (* (- x2 x1) (- y1 y3)) (* (- y2 y1) (- x1 x3))))
(dif-x-1 (- x1 x2))
(dif-y-1 (- y1 y2))
(dif-x-2 (- x3 x4))
(dif-y-2 (- y3 y4))
)
(cond
;; If the line is a point this can happen in 2D projection of 3D line
((and (zerop dif-x-1) (zerop dif-y-1)) nil)
((and (zerop dif-x-2) (zerop dif-y-2)) nil)
;; If the denominator and numerator for the equations for ua and
;; ub are 0 then the two lines are coincident.
;;((and (zerop denom) (zerop ua-num) (zerop ub-num)) (list x1 y1));;;?????? this condition is not 100% true ?????
;; If the denominator for the equations for ua and ub is 0 then
;; the two lines are parallel.
((zerop denom) nil)
(t
(let ((ua (/ ua-num denom))
(ub (/ ub-num denom)))
(if (and (<= 0 ua 1) (<= 0 ub 1))
(list (+ x1 (* ua (- x2 x1)))
(+ y1 (* ua (- y2 y1))))
nil)))))))
(defun get-box-corners (bounding-box)
(let ((min-y-1 (list (get-x (first bounding-box))
(get-y (first bounding-box))
(get-z (first bounding-box))))
(max-y-3 (list (get-x (second bounding-box))
(get-y (second bounding-box))
(get-z (second bounding-box)))))
(let ((min-y-2 (list (first max-y-3)
(second min-y-1)
(third min-y-1)))
(min-y-3 (list (first max-y-3)
(second min-y-1)
(third max-y-3)))
(min-y-4 (list (first min-y-1)
(second min-y-1)
(third max-y-3)))
(max-y-1 (list (first min-y-1)
(second max-y-3)
(third min-y-1)))
(max-y-2 (list (first max-y-3)
(second max-y-3)
(third min-y-1)))
(max-y-4 (list (first min-y-1)
(second max-y-3)
(third max-y-3))))
(list (list min-y-1 min-y-2 min-y-3 min-y-4) (list max-y-1 max-y-2 max-y-3 max-y-4)))))
(defun get-polygon-edges (points)
;;This converts the points, which specifies a polygon, in a list of lines defined by (X1 Y1) (X2 Y2)"
(let ((start (car (last points))))
(loop for point in points collect
(list start point)
do (setf start point ))))
(defun get-box-edges (bounding-box)
(append
(get-polygon-edges (first (get-box-corners bounding-box)))
(mapcan #'(lambda (min max)(list (list min max)))
(first (get-box-corners bounding-box))
(second (get-box-corners bounding-box)))
(get-polygon-edges (second (get-box-corners bounding-box)))))
(defun get-xy-boxs-intersection (bounding-box-1 bounding-box-2)
(remove nil
(mapcar #'(lambda (line)
(remove nil
(loop for i in
(get-box-edges bounding-box-1) collect
(line-intersection
(list (first (first line ))(second (first line ))(first (second line ))(second (second line ))
(first (first i ))(second (first i))(first (second i))(second (second i)))))))
(get-box-edges bounding-box-2))))
(defun get-xz-boxs-intersection (bounding-box-1 bounding-box-2)
(remove nil
(mapcar #'(lambda (line)
(remove nil
(loop for i in
(get-box-edges bounding-box-1) collect
(line-intersection
(list (first (first line ))(third (first line ))(first (second line ))(third (second line ))
(first (first i ))(third (first i))(first (second i))(third (second i)))))))
(get-box-edges bounding-box-2))))
(defun get-yz-boxs-intersection (bounding-box-1 bounding-box-2)
(remove nil
(mapcar #'(lambda (line)
(remove nil
(loop for i in
(get-box-edges bounding-box-1) collect
(line-intersection
(list (second (first line ))(third (first line ))(second (second line ))(third (second line ))
(second (first i ))(third (first i))(second (second i))(third (second i)))))))
(get-box-edges bounding-box-2))))
(defun box-intersection (bounding-box-1 bounding-box-2)
(let (( xyz-intersection (length (remove nil (list (get-xy-boxs-intersection bounding-box-1 bounding-box-2)
(get-xz-boxs-intersection bounding-box-1 bounding-box-2)
(get-yz-boxs-intersection bounding-box-1 bounding-box-2))))))
(if (cond (( = 3 xyz-intersection) t)) t nil)))
(define-object box-intersection-test (base-object)
:input-slots
((x-factor 0 :settable)
(y-factor 0 :settable)
(z-factor 0 :settable))
:computed-slots ()
:objects
((curve-1 :type 'b-spline-curve
:hidden? t
:degree 2
:control-points (list #(1.0 0.0 0.0)
#(1.0 0.5 0.5)
#(1.0 1.0 0.0)))
(curve-2 :type 'linear-curve
:hidden? t
:start #(0.0 0.0 0.0)
:end #(0.0 1.0 0.0))
(curve-11 :type 'b-spline-curve
:hidden? t
:degree 2
:control-points (list (make-point (+ (the x-factor) 0.0)
(+ (the y-factor) 0.0)
(+ (the z-factor) 0.0))
(make-point (+ (the x-factor) 0.0)
(+ (the y-factor) 0.5)
(+ (the z-factor) 0.5))
(make-point (+ (the x-factor) 0.0)
(+ (the y-factor) 1.0)
(+ (the z-factor) 0.0))))
(curve-22 :type 'linear-curve
:hidden? t
:start (make-point (+ (the x-factor) 1.0)
(+ (the y-factor) 0.0)
(+ (the z-factor) 0.0))
:end (make-point (+ (the x-factor) 1.0)
(+ (the y-factor) 1.0)
(+ (the z-factor) 0.0)))
(surface-1 :type 'ruled-surface
:display-controls (list :color :red)
:curve-1 (the curve-1)
:curve-2 (the curve-2))
(surface-2 :type 'ruled-surface
:display-controls (list :color :green)
:curve-1 (the curve-11)
:curve-2 (the curve-22))
(message :type 'general-note
:start (make-point 3 0 0)
:character-size 0.1
:display-controls (list :color :yellow)
:strings (format nil "box-intersection-message ~a" (box-intersection
(the surface-1 bounding-box)
(the surface-2 bounding-box))))
(test-brep-intersect :type 'brep-intersect
:brep (the surface-1 brep)
:other-brep (the surface-1 brep))
))
| 9,191 | Common Lisp | .lisp | 185 | 32.994595 | 134 | 0.463156 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 54d2b4d71f315c67a4b4156180fb5fc0651191867a1fd24cb942e78cd76ae979 | 35,872 | [
-1
] |
35,873 | extruded-solid.lisp | lisp-mirror_gendl/surf/source/extruded-solid.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object extruded-solid (brep)
:documentation (:description "Generates a brep by extruding a profile along an axis vector.")
:input-slots ("GDL Curve object. The profile to be extruded into a solid."
profile
("3D Vector. The direction of extrusion. Defaults
to (the (face-normal-vector :top))"
axis-vector (the (face-normal-vector :top)))
("Number. The distance to extrude the profile along the axis-vector.
Defaults to (the height)."
distance (the height))
("Number. Overall tolerance for the created brep solid. Defaults to nil.
Note that a value of nil indicates for SMLib a value of 1.0e-05 of the longest diagonal
length of the brep."
brep-tolerance nil))
:computed-slots ((%native-brep%
(if (or (and (atom (the profile))(the profile closed?))
(consp (the profile))
(and (atom (the profile))(> (the profile degree) 1)))
(let ((brep (make-brep *geometry-kernel*
:tolerance (the brep-tolerance))))
(add-linear-sweep-primitive
*geometry-kernel* brep
(if (listp (the profile))
(mapcar #'(lambda(curve)
(the-object curve (copy-new :finalize? nil)))
(the profile))
(list (the profile (copy-new :finalize? nil))))
(the axis-vector) (the distance))
(tag-edges *geometry-kernel* brep (get-long *geometry-kernel* brep))
(unless (the brep-tolerance)
(brep-reset-tolerance *geometry-kernel* brep))
brep)
(the ruled-surface brep %native-brep%))))
:hidden-objects
((decomposed-profile :type 'decomposed-curves
:curve-in (the profile))
(boxed-profile :type 'boxed-curve
:curve-in (the profile)
:center (translate-along-vector (the profile center)
(the axis-vector)
(the distance)))
(ruled-surface :type 'ruled-surface
:curve-1 (the profile)
:curve-2 (the boxed-profile))))
| 2,868 | Common Lisp | .lisp | 65 | 37.830769 | 95 | 0.695377 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7b51350b196aba9c763202cda6b8a2bbfd01f5af71a848acc3cf4de440f8521a | 35,873 | [
-1
] |
35,874 | shell.lisp | lisp-mirror_gendl/surf/source/shell.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object brep-shell (geometry-kernel-object-mixin base-object)
:input-slots (%native-shell% %native-brep% brep))
| 1,013 | Common Lisp | .lisp | 23 | 41.347826 | 71 | 0.743878 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 2812c7b9182776dc3f52a2d183c7a83c317455667841324593ad790b8380c1e1 | 35,874 | [
-1
] |
35,875 | validated-solid.lisp | lisp-mirror_gendl/surf/source/validated-solid.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object validated-solid (brep)
:input-slots ((brep nil) (%old-native-brep% nil))
:computed-slots ((%validation-results% (multiple-value-bind
(new-native-brep
tolerances-updated?
max-edge-uv-trim-curve-gap
max-vertex-edge-gap
max-vertex-face-gap)
(brep-validate-and-update-tolerances *geometry-kernel*
(if (the brep)
(the brep %native-brep%)
(the %old-native-brep%)))
(list :new-native-brep new-native-brep
:tolerances-updated? tolerances-updated?
:max-edge-uv-trim-curve-gap max-edge-uv-trim-curve-gap
:max-vertex-edge-gap max-vertex-edge-gap
:max-vertex-face-gap max-vertex-face-gap)))
(%native-brep% (getf (the %validation-results%) :new-native-brep))
(tolerances-updated? (ecase (getf (the %validation-results%) :tolerances-updated?)
(0 nil) (1 t)))
(max-edge-uv-trim-curve-gap (getf (the %validation-results%) :max-edge-uv-trim-curve-gap))
(max-vertex-edge-gap (getf (the %validation-results%) :max-vertex-edge-gap))
(max-vertex-face-gap (getf (the %validation-results%) :max-vertex-face-gap))))
| 2,870 | Common Lisp | .lisp | 44 | 41.363636 | 112 | 0.495874 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b4961d484413a6c04d5d27a76dc8e1ec96eb27a963de25967414961ae381f326 | 35,875 | [
-1
] |
35,876 | breps-display.lisp | lisp-mirror_gendl/surf/source/breps-display.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object breps-display (base-object)
:input-slots (brep-list)
:objects ((breps :type 'brep
:sequence (:size (length (the brep-list)))
:%native-brep% (the-object (nth (the-child index) (the brep-list))
%native-brep%))))
| 1,209 | Common Lisp | .lisp | 27 | 39 | 86 | 0.678328 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | fe965db88d451cfa1c2cf163ba6cda5dafadda75b31d60611d9025f9fd2b8b0c | 35,876 | [
-1
] |
35,877 | reparameterized-curve.lisp | lisp-mirror_gendl/surf/source/reparameterized-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object reparameterized-curve (curve)
:input-slots (curve-in (tolerance *3d-approximation-tolerance-default*))
:computed-slots ((native-curve (gprcap *geometry-kernel* (the curve-in native-curve)
:tolerance (the tolerance)))))
| 1,178 | Common Lisp | .lisp | 25 | 42.6 | 89 | 0.716915 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 157632483d4412ece590f1e22bb16373633e118018cd5176488f8fdf82542176 | 35,877 | [
-1
] |
35,878 | iso-curve.lisp | lisp-mirror_gendl/surf/source/iso-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object iso-curve (curve)
:documentation (:description "Represents an exact iso curve on the given surface in given direction at given parameter value."
:examples "<pre>
(in-package :gdl-user)
(define-object iso-curve-example (base-object)
:computed-slots
((parameter 0.5))
:objects
((surface :type 'surf::test-b-spline-surface)
(iso-curve :type 'iso-curve
:strings-for-display \"Iso at 0.5\"
:display-controls (list :color :red :line-thickness 3)
:surface (the surface)
:parameter (the parameter))))
(generate-sample-drawing :object-roots (list (make-object 'iso-curve-example))
:projection-direction (getf *standard-views* :trimetric))
</pre>")
:input-slots
("GDL object of type surface. The surface on which you want an iso curve." surface
"Number. The u or v will be fixed at this value.
This should be between the min and max values for the surface in the given direction. Note that
you can check the min and max for a surface with (the u-min), (the u-max), (the v-min), or (the v-max)."
parameter
("Keyword symbol, one of :u or :v. This is the parameter direction which will be fixed to the
parameter value given.
Default is :u."
fixed-parameter :v)
("Keyword symbol, one of :u or :v. This is the direction of the iso-curve. The other parameter will
be fixed on the surface at the given parameter value.
:note The name of this input-slot is somewhat anti-intuitive. If you want to
specify the U parameter, you give :v here, and if you want to specify
the V parameter, you give :u here. For an intuitive input which matches
the parameter value that you are giving, use fixed-parameter instead of this input-slot.
Default is (ecase (the fixed-parameter) (:u :v) (:v :u))."
u-or-v (ecase (the fixed-parameter) (:u :v) (:v :u))))
:computed-slots
((native-curve (funcall (read-from-string "smlib::get-iso-curve") (the surface) (the parameter) (the u-or-v)))
("List of GDL surfaces. For iso curve, this will contain the single surface on which the iso curve lies."
on-surfaces (list (the surface))))
:hidden-objects
((""
uv-curve :type 'uv-iso-curve
:pass-down (surface parameter u-or-v))))
(define-object uv-iso-curve ()
:documentation (:description "Convenience object to return UV parameter values on surface.")
:input-slots (surface parameter u-or-v)
:functions
(("2D point. The UV surface representation at the given parameter value.
:arguments (parameter \"Number. The parameter value you want.\")"
point
(parameter)
(ecase (the u-or-v)
(:v (make-point (the parameter) parameter))
(:u (make-point parameter (the parameter)))))))
;;
;; FLAG -- remove this defunct version.
;;
#+nil
(define-object uv-iso-curve ()
:documentation (:description "Convenience object to return UV parameter values on surface.")
:input-slots (surface parameter u-or-v)
:functions
(("2D point. The UV surface representation at the given parameter value.
:arguments (parameter \"Number. The parameter value you want.\")"
point
(parameter)
(ecase (the u-or-v)
(:u (make-point (the parameter) parameter))
(:v (make-point parameter (the parameter)))))))
| 4,287 | Common Lisp | .lisp | 90 | 42.255556 | 128 | 0.704022 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 4f4c33fb22c5f7b7fdad9199092e4ab92178dcc3b8711679a7ea238a96beddd5 | 35,878 | [
-1
] |
35,879 | degenerate-curve.lisp | lisp-mirror_gendl/surf/source/degenerate-curve.lisp | ;;
;; Copyright 2002-2011, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object degenerate-curve (curve)
:input-slots
((degree 3)
(point (make-point 0 0 0)))
:computed-slots
((native-curve-iw (make-degenerate-curve *geometry-kernel*
:point (the point)
:degree (the degree)))))
| 1,115 | Common Lisp | .lisp | 29 | 36 | 70 | 0.739535 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 8ad2129ebdde35a64c5d3222db54586b2b25fe8ddebae0b917ae5c7bde5116ed | 35,879 | [
-1
] |
35,880 | initialize.lisp | lisp-mirror_gendl/surf/source/initialize.lisp | (in-package :surf)
(defun initialize ()
(let ((anything-changed? nil))
(unless *geometry-kernel*
(setq anything-changed? t)
(make-geometry-kernel :vanilla))
anything-changed?))
| 202 | Common Lisp | .lisp | 7 | 24.285714 | 38 | 0.668394 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d9e8a3babd3751fa60e2e13d4be6926b40365ddad2dccb12a4b4c183ec82274c | 35,880 | [
-1
] |
35,881 | surface-grid-points.lisp | lisp-mirror_gendl/surf/source/surface-grid-points.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
;;
;; FLAG -- get rid of raw smlib calls in here
;;
#+nil
(define-object surface-grid-points (base-object)
:computed-slots
(( test-quad (smlib::approximated-surface-with-quads *geometry-kernel* (the test-surf native-surface) :tolerance 0.01 :tolerance-method 1))
(points (surf-grid-points *geometry-kernel*
(the test-surf
;; test
native-surface)
:u-parameters '(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0)
:v-parameters '(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0))))
:objects
((test-surf :type 'test-b-spline-surface)
(grid-pints :type 'grid-points-sequence
:sequence (:size (length (the points)))
:points-list (nth (the-child :index)
(the points)))
(test :type 'planar-surface
:p00 (make-point 0 0 0)
:p01 (make-point 0 1 0)
:p10 (make-point 1 0 0)
:p11 (make-point 2 1 0))))
#+nil
(define-object grid-points-sequence (base-object)
:input-slots
(points-list)
:objects
((point :type 'point
:sequence (:size (length (the points-list)))
:center (nth (the-child :index)
(the points-list)))))
| 2,345 | Common Lisp | .lisp | 54 | 33.277778 | 144 | 0.599455 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | cf7f20f994f7fc413523d3a655de4ea3870fee90259f219a2d5f062a3c3c64b7 | 35,881 | [
-1
] |
35,882 | dual-blend-surface.lisp | lisp-mirror_gendl/surf/source/dual-blend-surface.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object dual-blend-surface (general-dual-blend-surface)
:documentation (:description "Creates a smooth blend-surface between curve-1, lying on surface-1 and curve-2 on surface-2. The local start and end directions of this surface along curve-1 and curve-2 are determined from the cross-product between the tangent of these curves and the corresponding surface-normal at the same point. In this fashion a tangent blend is created between surface-1 and surface-2 that extends in a direction perpendicular to the input-curves. Takes the same inputs as general-dual-blend-surface, except for f-tangent-1 and f-tangent-2."
:examples "<pre>
(in-package :surf)
(define-object test-d-b-s (base-object)
:objects
((d-b-s :type 'dual-blend-surface
:display-controls (list :color :green)
:pass-down (curve-1 surface-1 curve-2 surface-2))
(surf-1-top :type 'linear-curve
:hidden? t
:start (make-point -5 -5 0)
:end (make-point 5 -5 0))
(surf-1-bottom :type 'linear-curve
:hidden? t
:start (make-point -7 -10 -2)
:end (make-point 7 -10 -2))
(surface-1 :type 'ruled-surface
:curve-1 (the surf-1-top)
:curve-2 (the surf-1-bottom))
(curve-1 :type 'iso-curve
:display-controls (list :color :red :line-thickness 4)
:surface (the surface-1)
:parameter 0
:u-or-v :v)
(surf-2-bottom :type 'linear-curve
:hidden? t
:start (make-point -5 5 0)
:end (make-point 5 5 0))
(surf-2-top :type 'linear-curve
:hidden? t
:start (make-point -7 10 2)
:end (make-point 7 10 2))
(surface-2 :type 'ruled-surface
:curve-1 (the surf-2-bottom)
:curve-2 (the surf-2-top))
(curve-2 :type 'iso-curve
:display-controls (list :color :blue :line-thickness 4)
:surface (the surface-2)
:parameter 0
:u-or-v :v)))
(generate-sample-drawing :object-roots (list (make-object 'test-d-b-s))
:projection-direction (getf *standard-views* :top))
</pre>")
:computed-slots
((f-tangent-1 #'(lambda(param)
(let* ((surface-uv (the curve-1 uv-curve (point param)))
(surface-normal (the surface-1 (normal (get-x surface-uv) (get-y surface-uv))))
(curve-tangent (the curve-1 (tangent param))))
(cross-vectors surface-normal curve-tangent))))
(f-tangent-2 #'(lambda(param)
(let* ((surface-uv (the curve-2 uv-curve (point param)))
(surface-normal (the surface-2 (normal (get-x surface-uv) (get-y surface-uv))))
(curve-tangent (the curve-2 (tangent param))))
(cross-vectors surface-normal curve-tangent))))))
;;
;; FLAG -- move to example and/or regression tests.
;;
;; Some lisps don't recognize the above dual-blend-surface definition while still
;; in this file.
;;
#+nil
(define-object test-d-b-s (base-object)
:objects
((d-b-s :type 'dual-blend-surface
:display-controls (list :color :green)
:pass-down (curve-1 surface-1 curve-2 surface-2))
(surf-1-top :type 'linear-curve
:hidden? t
:start (make-point -5 -5 0)
:end (make-point 5 -5 0))
(surf-1-bottom :type 'linear-curve
:hidden? t
:start (make-point -7 -10 -2)
:end (make-point 7 -10 -2))
(surface-1 :type 'ruled-surface
:curve-1 (the surf-1-top)
:curve-2 (the surf-1-bottom))
(curve-1 :type 'iso-curve
:display-controls (list :color :red :line-thickness 4)
:surface (the surface-1)
:parameter 0
:u-or-v :v)
(surf-2-bottom :type 'linear-curve
:hidden? t
:start (make-point -5 5 0)
:end (make-point 5 5 0))
(surf-2-top :type 'linear-curve
:hidden? t
:start (make-point -7 10 2)
:end (make-point 7 10 2))
(surface-2 :type 'ruled-surface
:curve-1 (the surf-2-bottom)
:curve-2 (the surf-2-top))
(curve-2 :type 'iso-curve
:display-controls (list :color :blue :line-thickness 4)
:surface (the surface-2)
:parameter 0
:u-or-v :v)))
| 5,795 | Common Lisp | .lisp | 120 | 35.483333 | 565 | 0.57732 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c86a25de6e9ca16055f51c46789b88d80e569b1ce6707f346906fb0b0675e46a | 35,882 | [
-1
] |
35,883 | cardinal-spline.lisp | lisp-mirror_gendl/surf/source/cardinal-spline.lisp | ;;
;; Copyright 2002-2011, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object cardinal-spline (curve)
:documentation (:description
"This object makes a Cardinal Spline, which defaults
to a Catmull-Rom Spline for nil tension-params (which means they all
default to 0.0)."
:author "Dave Cooper, Genworks International")
:input-slots ("List of 3D Points. The points through which the curve will pass." through-points
(tension-params nil)
("Boolean. Indicates whether the curve should close back to its start point. Default is <tt>nil</tt>."
periodic? nil)
("Keyword symbol. <tt>uniform</tt>, <tt>:chordal</tt> (or <tt>:chord-length</tt>), or <tt>centripetal</tt>.
Default is <tt>:uniform</tt>."
parameterization :uniform))
:computed-slots ((native-curve-iw (make-cardinal-spline *geometry-kernel*
:periodic? (the periodic?)
:tension-params (the tension-params)
:control-points (if (and (the periodic?)
(coincident-point? (first (the through-points))
(lastcar (the through-points))))
(butlast (the through-points))
(the through-points))
:parameterization (the parameterization)))))
(define-object test-cr (base-object)
:objects
((uniform :type 'test-uniform-cr)
(centripetal :type 'test-centripetal-cr)
(chordal :type 'test-chordal-cr)))
(define-object test-uniform-cr (cardinal-spline)
:computed-slots
(
(through-points (list (make-point 0 0 0)
(make-point 1 1 0)
(make-point 1.1 1 0)
(make-point 2 0 0)))
#+nil
(through-points
'(#(0.0 -91.0 0.0) #(96.0 -82.0 0.0) #(100.0 -68.5 0.0)
#(96.0 -54.99999999999999 0.0) #(0.0 -46.0 0.0)
#(-96.0 -54.99999999999999 0.0) #(-100.0 -68.5 0.0) #(-96.0 -82.0 0.0)))
(periodic? t)))
(define-object test-centripetal-cr (cardinal-spline)
:computed-slots
((parameterization :centripetal)
#+nil
(through-points (list (make-point 0 0 0)
(make-point 1 0 0)
(make-point 1 1 0)
(make-point 0 1 0)))
#+nil
(through-points (list (make-point 0 0 0)
(make-point 1 1 0)
(make-point 1.1 1 0)
(make-point 2 0 0)))
(through-points (list (make-point 0 0 0)
(make-point 0.9 1 0)
(make-point 1.1 1 0)
(make-point 2 0 0)))
#+nil
(through-points
'(#(0.0 -91.0 0.0) #(96.0 -82.0 0.0) #(100.0 -68.5 0.0)
#(96.0 -54.99999999999999 0.0) #(0.0 -46.0 0.0)
#(-96.0 -54.99999999999999 0.0) #(-100.0 -68.5 0.0) #(-96.0 -82.0 0.0)))
(periodic? t)))
(define-object test-chordal-cr (cardinal-spline)
:computed-slots
((parameterization :chordal)
(through-points (list (make-point 0 0 0)
(make-point 1 1 0)
(make-point 1.1 1 0)
(make-point 2 0 0)))
#+nil
(through-points
'(#(0.0 -91.0 0.0) #(96.0 -82.0 0.0) #(100.0 -68.5 0.0)
#(96.0 -54.99999999999999 0.0) #(0.0 -46.0 0.0)
#(-96.0 -54.99999999999999 0.0) #(-100.0 -68.5 0.0) #(-96.0 -82.0 0.0)))
(periodic? t)))
#+nil
(define-object test-b-spline-curves (base-object)
:input-slots
((control-points (list (make-point 0 0 0)
(make-point 2 3.0 0.0)
(make-point 4 2.0 0.0)
(make-point 5 0.0 0.0)
(make-point 4 -2.0 0.0)
(make-point 2 -3.0 0.0)
(make-point 0 0 0))))
:hidden-objects
((view :type 'base-view
:page-length (* 5 72) :page-width (* 5 72)
:pseudo-inputs (page-length page-width)
:objects (the children)))
:objects
((note :type 'general-note
:strings "Hey Now")
(curve :type 'b-spline-curve
:control-points (the control-points)
:degree 3
:display-controls (list :line-thickness 1
:color :orange))
(kcurve :type 'b-spline-curve
:control-points (the control-points)
:knot-vector '(0.0 0.0 0.0 0.0 1/8 1/2 6/8 1.0 1.0 1.0 1.0)
:degree 3
:display-controls (list :line-thickness 1
:color :red))
(points :type 'point
:sequence (:size (length (rest (the control-points))))
:center (nth (the-child index) (rest (the control-points)))
:display-controls (list :color :green))))
#+nil
(defun normalize (&key knot-vector u-min u-max)
(let* ((new-delta (- (apply #'max knot-vector) (apply #'min knot-vector)))
(old-delta (- u-max u-min))
(step-ratio (div old-delta new-delta)))
(mapcar #'(lambda(knot) (* knot step-ratio)) knot-vector)))
#+nil
(define-object display-pts ()
:objects
((through :type (if (typep self 'cardinal-spline) 'points-display 'null-object)
:points (when (typep self 'cardinal-spline) (the through-points))
:display-controls (list :color :green))
(control :type 'points-display
:points (the control-points)
:display-controls (list :color :red))))
#+nil
(define-object cardinal-spline* (cardinal-spline display-pts))
#+nil
(define-object b-spline-curve* (b-spline-curve display-pts))
#+nil
(define-object tom-cr (cardinal-spline*)
:computed-slots
((periodic? t)
(through-points
#+nil
(list (make-point 0 0 0) (make-point 1 1 0)
(make-point 1.1 1 0) (make-point 2 0 0))
'(#(0.0 -91.0 6.5) #(96.0 -82.0 6.5) #(100.0 -68.5 6.5)
#(96.0 -54.99999999999999 6.5) #(0.0 -46.0 6.5)
#(-96.0 -54.99999999999999 6.5) #(-100.0 -68.5 6.5) #(-96.0 -82.0 6.5)))))
#+nil
(define-object tom (base-object)
:objects
((uniform :type 'tom-cr :parameterization :uniform)
(centripetal :type 'tom-cr :parameterization :centripetal)
(chordal :type 'tom-cr :parameterization :chordal)
(alpha :type 'tom-cr :alpha 0.9)
(frank :type 'b-spline-curve*
:control-points (the uniform control-points)
:knot-vector (the centripetal knot-vector)
#+nil
(normalize :knot-vector (the centripetal knot-vector)
:u-min (the uniform u-min)
:u-max (the uniform u-max)))
(stein :type 'b-spline-curve*
:control-points (the centripetal control-points)
:knot-vector (the uniform knot-vector))
(frank-chordal :type 'b-spline-curve*
:control-points (the uniform control-points)
:knot-vector (the chordal knot-vector))
))
| 7,453 | Common Lisp | .lisp | 181 | 33.436464 | 110 | 0.602614 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ed1881df7148900fabd2d778f5ab63a1692fd8d890ddcb48ee0992df3018232e | 35,883 | [
-1
] |
35,884 | compatible-curves.lisp | lisp-mirror_gendl/surf/source/compatible-curves.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
;;
;; FLAG -- have to get rid of raw smlib call in here.
;;
(define-object compatible-curves (base-object)
:documentation (:description "Experimental. This primitive takes in a list of GDL
curve objects and will compute a sequence of new curve objects which have been made
to be compatible in terms of number of control points, knot vectors, and degree."
:author "Dave Cooper, Genworks"
:examples "<pre>
(in-package :gdl-user)
(define-object test-compatible-curves ()
:objects
((b-spline :type 'b-spline-curve
:control-points (list (make-point 0 0 0)
(make-point -1 0 0)
(make-point -1 1 0)
(make-point 0 1 0)))
(linear-curve :type 'linear-curve
:start (make-point 0 1 0)
:end (make-point 4 1 0))
(compatible-curves :type 'compatible-curves
:curve-list (list (the b-spline) (the linear-curve)))))
(generate-sample-drawing :object-roots (list (make-object 'test-compatible-curves)))
</pre>")
:input-slots (("List of GDL curve objects." curve-list)
("Tolerance is used to check knots removability for data reduction. A nil value indicates that no data reduction
is to be attempted. Defaults to nil." tolerance nil ))
:computed-slots ((%native-curves-list%
(if (the tolerance)
(approximated-compatible-curves *geometry-kernel*
(the curve-list) :tolerance (the tolerance))
(return-compatible-curves *geometry-kernel*
(mapcar #'(lambda(curve)
(the-object curve (copy-new :finalize? nil)))
(the curve-list))))))
:objects (("Sequence of GDL Curve objects. These are the resultant curves which
are supposed to be compatible."
curves :type 'curve
:sequence (:size (length (the %native-curves-list%)))
:native-curve (nth (the-child index) (the %native-curves-list%)))))
(define-object test-compatible-curves ()
:objects
((b-spline :type 'b-spline-curve
:control-points (list (make-point 0 0 0)
(make-point -1 0 0)
(make-point -1 1 0)
(make-point 0 1 0)))
(linear-curve :type 'linear-curve
:start (make-point 0 1 0)
:end (make-point 4 1 0))
(compatible-curves :type 'compatible-curves
:curve-list (list (the b-spline) (the linear-curve)))))
| 3,687 | Common Lisp | .lisp | 73 | 38.534247 | 130 | 0.607798 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a8b764593fa96d580d562aed2bc427253b99cc7bc3a7dde927d267125446aa64 | 35,884 | [
-1
] |
35,885 | 3d-curve.lisp | lisp-mirror_gendl/surf/source/3d-curve.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object 3d-curve (b-spline-curve)
:documentation (:description "Given a uv on-surface curve and its
surface, produce the corresponding 3d curve. Note this must be a true
on-surface curve, not just an arbitrary curve whose domain happens to
be in the parameter space of the surface.")
:input-slots ("GDL Curve object. Curve which is a proper on-surface
curve (e.g. produced by a project or drop operation
onto the surface)." uv-curve
"GDL Surface object. The surface corresponding to the given uv-curve."
surface)
:computed-slots ((knot-vector (the uv-curve knot-vector))
(weights (the uv-curve weights))
(degree (the uv-curve degree))
(control-points (mapcar #'(lambda(point)
(the surface (point (get-x point) (get-y point))))
(the uv-curve control-points)))))
(define-object 3d-approximated (approximated-curve)
:documentation (:description "Given a curve in uv parameter space of
a surface, produce a corresponding 3d curve with brute-force fitting
techniques.")
:input-slots
("GDL Curve object. Curve whose points are understood to be 2D u, v
parameter values on the surface."
uv-curve
"GDL Surface object. The surface corresponding to the given uv-curve."
surface
("Integer. How many point samples to take for fitting
purposes. Default is 42."
number-of-samples 42)
("Number. The tolerance for the final approximation, to be
multiplied by the 3d curve length. Default is 10e-5."
tolerance-factor 10e-5))
:hidden-objects
((3d-curve :type 'fitted-curve
:points (mapcar #'(lambda(point)
(the surface (point (get-x point) (get-y point))))
(the uv-curve (equi-spaced-points (the number-of-samples))))))
:computed-slots
((tolerance (* (the tolerance-factor) (the 3d-curve total-length)))
(curve-in (the 3d-curve))))
| 2,726 | Common Lisp | .lisp | 61 | 41.180328 | 73 | 0.732298 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e66fb451cbec2483de66aab719b9ac4e55aa91ef44ba518bd221fab015e4cf07 | 35,885 | [
-1
] |
35,886 | formats.lisp | lisp-mirror_gendl/surf/source/formats.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
;;
;; FLAG -- remove this package definition and move all low-level stuff to smlib layer.
;;
(eval-when (:compile-toplevel :load-toplevel :execute) (defpackage :smlib (:use)))
(define-format nurbs (base-format)
:slots ((assembly? nil)
(%assembly% nil)))
(define-format stl (nurbs)
:slots ((tolerance nil) (breps-format :brep)
(units *output-units-default*)
(units-scale 1)
(analytic-curves? t)
(objects nil))
:functions
((objects-output
()
(format *stream* "solid STL file created by Genworks GDL~%")
(with-format-slots (objects)
(dolist (object objects)
(let ((buffer-file (namestring (glisp:temporary-file :extension "stl"))))
(multiple-value-bind (result error)
(ignore-errors (the-object object (write-stl-file buffer-file)))
(declare (ignore result))
(if (typep error 'error)
(warn "Could not write STL output for ~s (~s), skipping (error was ~a)..."
object (the-object object root-path) error)
(progn
(with-open-file (in buffer-file)
(do ((line (read-line in nil nil) (read-line in nil nil)))
((null line))
(unless (or (search "solid" line)
(search "endsolid" line))
(write-string line *stream*)
(format *stream* "~%"))))
(delete-file buffer-file))))))
(format *stream* "endsolid STL file created by Genworks GDL")))
(finalize-output
()
(write-env (objects-output))
;;(write-env (newline-out))
)))
(define-format iges (nurbs)
:slots ((tolerance nil) (breps-format :breps) (units *output-units-default*) (units-scale 1) (analytic-curves? t)
(objects nil))
:functions
((objects-output
()
(with-format-slots (tolerance breps-format units units-scale analytic-curves? objects)
(let ((leaves (reverse (ensure-list objects))))
(let (entity-plist)
(dolist (leaf leaves)
(cond ((or (typep leaf 'trimmed-surface)(typep leaf 'face))
(push leaf (getf entity-plist :trimmed-surfaces)))
((and (typep leaf 'brep) (member breps-format '(:surfaces :trimmed-surfaces)))
(push leaf (getf entity-plist :trimmed-surfaces)))
((typep leaf 'surface) (push leaf (getf entity-plist :surfaces)))
((typep leaf 'curve) (push leaf (getf entity-plist :curves)))
((typep leaf 'point) (push leaf (getf entity-plist :points)))
((and (typep leaf 'brep) (member breps-format '(:breps :solids)))
(push leaf (getf entity-plist :solids)))
(t (let ((nurbs-reps (ensure-list (write-the-object leaf nurbs-reps))))
(dolist (nurbs nurbs-reps)
(cond ((typep nurbs 'surface) (push nurbs (getf entity-plist :surfaces)))
((typep nurbs 'curve) (push nurbs (getf entity-plist :curves)))
((typep nurbs 'point) (push nurbs (getf entity-plist :points)))
(t (error "~s is an unrecognized NURBS representation.~%" nurbs))))))))
(setq entity-plist (list :points (nreverse (getf entity-plist :points))
:curves (nreverse (getf entity-plist :curves))
:surfaces (nreverse (getf entity-plist :surfaces))
:trimmed-surfaces (nreverse (getf entity-plist :trimmed-surfaces))
:solids (nreverse (getf entity-plist :solids))))
(let ((buffer-file (namestring (glisp:temporary-file))))
(apply #'write-iges-file* *geometry-kernel* buffer-file
:quiet? t :units units :units-scale units-scale :tolerance tolerance
:write-analytic-curves? analytic-curves? entity-plist)
(let ((buffer (make-array 4096 :element-type '(unsigned-byte 8))))
(with-open-file (in buffer-file :element-type '(unsigned-byte 8))
(do ((count (read-sequence buffer in) (read-sequence buffer in)))
((<= count 0))
(write-sequence buffer *stream* :end count))))
(delete-file buffer-file))))))
(finalize-output
()
(write-env (objects-output))
;;(write-env (a "%Finalized Output"))
(write-env (newline-out)))))
(define-format step (nurbs)
:slots ((tolerance nil)
(breps-format :breps)
(units *output-units-default*)
(units-scale 1)
(analytic-curves? t)
(objects nil))
:functions
((assembly-output
()
(let ((buffer-file (namestring (glisp:temporary-file))))
(with-format-slots (%assembly%)
(smlib::write-hw-file-assembly *geometry-kernel* buffer-file %assembly%)
)
(let ((buffer (make-array 4096
:element-type '(unsigned-byte 8))))
(with-open-file (in buffer-file :element-type '(unsigned-byte 8))
(do ((count (read-sequence buffer in)
(read-sequence buffer in)))
((<= count 0))
(write-sequence buffer *stream* :end count))))
(delete-file buffer-file)))
(objects-output
()
(with-format-slots (tolerance breps-format units
units-scale analytic-curves?
objects)
(let ((leaves (reverse (ensure-list objects))))
(let (entity-plist)
(dolist (leaf leaves)
(cond ((or (typep leaf 'trimmed-surface)(typep leaf 'face))
(push leaf (getf entity-plist :trimmed-surfaces)))
((and (typep leaf 'brep)
(member breps-format
'(:surfaces :trimmed-surfaces)))
(push leaf (getf entity-plist :trimmed-surfaces)))
((typep leaf 'surface)
(push leaf (getf entity-plist :surfaces)))
((typep leaf 'curve)
(push leaf (getf entity-plist :curves)))
((typep leaf 'point)
(push leaf (getf entity-plist :points)))
((and (typep leaf 'brep)
(member breps-format '(:breps :solids)))
(push leaf (getf entity-plist :solids)))
(t (let ((nurbs-reps
(ensure-list
(write-the-object leaf nurbs-reps))))
(dolist (nurbs nurbs-reps)
(cond ((typep nurbs 'surface)
(push nurbs
(getf entity-plist :surfaces)))
((typep nurbs 'curve)
(push nurbs
(getf entity-plist :curves)))
((typep nurbs 'point)
(push nurbs
(getf entity-plist :points)))
(t (error "~s is an unrecognized NURBS representation.~%" nurbs))))))))
(setq entity-plist
(list :points (nreverse (getf entity-plist :points))
:curves (nreverse (getf entity-plist :curves))
:surfaces (nreverse (getf entity-plist :surfaces))
:trimmed-surfaces (nreverse
(getf entity-plist
:trimmed-surfaces))
:solids (nreverse (getf entity-plist :solids))))
(let ((buffer-file (namestring (glisp:temporary-file))))
(apply #'write-step-file* *geometry-kernel* buffer-file
:quiet? t :units units
:units-scale units-scale :tolerance tolerance
:write-analytic-curves? analytic-curves?
entity-plist)
(let ((buffer (make-array 4096
:element-type '(unsigned-byte 8))))
(with-open-file (in buffer-file :element-type '(unsigned-byte 8))
(do ((count (read-sequence buffer in)
(read-sequence buffer in)))
((<= count 0))
(write-sequence buffer *stream* :end count))))
(delete-file buffer-file))))))
(finalize-output
()
(with-format-slots (assembly?)
(if assembly?
(write-env (assembly-output))
(progn
(write-env (:objects-output))
;;(write-env (a "%Finalized Output"))
(write-env (:newline-out))))))))
(define-format native (nurbs)
:slots ((file-type :ascii) (objects nil))
:functions ((finalize-output
()
(write-env (:objects-output))
(write-env (:a "// Finalized Output"))
(write-env (:newline-out)))
(objects-output
()
(with-format-slots (file-type objects)
(let ((leaves (ensure-list objects)))
(let (entity-plist)
(dolist (leaf leaves)
(cond ((typep leaf 'brep) (push leaf (getf entity-plist :breps)))
((typep leaf 'surface) (push leaf (getf entity-plist :surfaces)))
((typep leaf 'curve) (push leaf (getf entity-plist :curves)))
(t (let ((nurbs-reps (ensure-list (write-the-object leaf nurbs-reps))))
(dolist (nurbs nurbs-reps)
(cond ((typep nurbs 'surface) (push nurbs (getf entity-plist :surfaces)))
((typep nurbs 'curve) (push nurbs (getf entity-plist :curves)))
(t (error "~s is an unrecognized NURBS representation.~%" nurbs))))))))
(setq entity-plist (list :curves (nreverse (getf entity-plist :curves))
:surfaces (nreverse (getf entity-plist :surfaces))
:breps (nreverse (getf entity-plist :breps))))
(let ((buffer-file (namestring (glisp:temporary-file))))
(apply #'write-native-file *geometry-kernel* buffer-file :quiet? t :file-type file-type entity-plist)
(if (and (glisp:featurep :excl)
(typep *stream* (read-from-string "excl:string-output-simple-stream")))
(with-open-file (in buffer-file)
(do ((line (read-line in nil nil) (read-line in nil nil)))
((null line))
(write-string line *stream*)
(write-char #\newline *stream*)))
(let ((buffer (make-array 4096 :element-type '(unsigned-byte 8))))
(with-open-file (in buffer-file :element-type '(unsigned-byte 8))
(do ((count (read-sequence buffer in) (read-sequence buffer in)))
((<= count 0))
(write-sequence buffer *stream* :end count)))))
(delete-file buffer-file))))))))
(defmethod encode-for-http ((self geometry-kernel-object-mixin))
(if (typep (the %parent%) 'remote-object)
(call-next-method)
(construct-object-for-http :gdl-geometry-kernel-instance
(list :smlib-string (with-output-to-string(ss)(with-format (native ss) (write-the cad-output)))))))
| 13,105 | Common Lisp | .lisp | 241 | 36.987552 | 131 | 0.516259 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 5643756da93befbd0ea0eca06f46bd13d0a31964d9702164fd20252b9aae11cc | 35,886 | [
-1
] |
35,887 | basic-surface.lisp | lisp-mirror_gendl/surf/source/basic-surface.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object basic-surface (surface)
:documentation (:description "This routine constructs a 3D surface by interpolating
a set of four boundary 3D curves."
:examples "
<pre>
(in-package :gdl-user)
(define-object test-basic-surface (base-object)
:computed-slots
((control-points-u-min (list (make-point 0 0 0 )
(make-point 1 0 0 )
(make-point 2 0 1 )
(make-point 3 0 0 )
(make-point 4 0 0 )))
(control-points-u-max (list (make-point 0 4 0 )
(make-point 1 4 0 )
(make-point 2 4 1 )
(make-point 3 4 0 )
(make-point 4 4 0 )))
(control-points-v-min (list (make-point 0 0 0 )
(make-point 0 1 0 )
(make-point 0 2 1 )
(make-point 0 3 0 )
(make-point 0 4 0 )))
(control-points-v-max (list (make-point 4 0 0 )
(make-point 4 1 0 )
(make-point 4 2 1 )
(make-point 4 3 0 )
(make-point 4 4 0 ))))
:objects
((surf-curve-u-min :type 'fitted-curve
:display-controls (list :color :green :line-thickness 2)
:points (the control-points-u-min))
(surf-curve-u-max :type 'fitted-curve
:display-controls (list :color :green :line-thickness 2)
:points (the control-points-u-max))
(surf-curve-v-min :type 'fitted-curve
:display-controls (list :color :blue :line-thickness 2)
:points (the control-points-v-min))
(surf-curve-v-max :type 'fitted-curve
:display-controls (list :color :blue :line-thickness 2)
:points (the control-points-v-max))
(surface :type 'basic-surface
:display-controls (list :color :red :line-thickness 0.5)
:curve-bottom (the surf-curve-u-min)
:curve-top (the surf-curve-u-max)
:curve-left (the surf-curve-v-min)
:curve-right (the surf-curve-v-max))
(arc-1 :type 'arc-curve
:display-controls (list :color :green :line-thickness 2)
:orientation (alignment :top (the (face-normal-vector :rear)))
:center (make-point 1 0 0)
:radius 1
:start-angle 0
:end-angle pi)
(arc-2 :type 'arc-curve
:display-controls (list :color :green :line-thickness 2)
:orientation (alignment :top (the (face-normal-vector :rear)))
:center (make-point 1 -2 0)
:radius 1
:start-angle 0
:end-angle pi)
(arc-3 :type 'arc-curve
:orientation (alignment :rear (the (face-normal-vector :right)))
:display-controls (list :color :blue :line-thickness 2)
:center (make-point 0 -1 0)
:radius 1
:start-angle 0
:end-angle pi)
(arc-4 :type 'arc-curve
:orientation (alignment :rear (the (face-normal-vector :left)))
:display-controls (list :color :blue :line-thickness 2)
:center (make-point 2 -1 0)
:radius 1
:start-angle 0
:end-angle pi)
(surf-arc :type 'basic-surface
:display-controls (list :color :red :line-thickness 0.5)
:curve-bottom (the arc-1 )
:curve-top (the arc-2 )
:curve-left (the arc-3 reverse )
:curve-right (the arc-4))))
(generate-sample-drawing
:objects (the-object (make-object 'test-basic-surface) surface)
:projection-direction (getf *standard-views* :tri-r-r))
</pre>")
:input-slots
(test
(with-suport-curve? t)
"GDL curve object. The curve corresponding to the surface bottom boundary ." curve-bottom
"GDL curve object. The curve corresponding to the surface top boundary." curve-top
"GDL curve object. The curve corresponding to the surface left boundary." curve-left
"GDL curve object. The curve corresponding to the surface right boundary." curve-right)
:computed-slots
((native-surface (the extended-v-max native-surface)))
:hidden-objects
((suport-curve-u :type 'linear-curve
:start (the curve-bottom (point 0.5))
:end (the curve-top (point 0.5)))
(suport-curve-v :type 'linear-curve
:start (the curve-left (point 0.5))
:end (the curve-right (point 0.5)))
(suport-curve :type 'linear-curve
:start (translate-along-vector
(the curve-left (point 0.5))
(subtract-vectors (the suport-curve-u (point 0.5))
(the suport-curve-v (point 0.5)))
(/(3d-distance (the suport-curve-u (point 0.5))
(the suport-curve-v (point 0.5))) 2))
:end (translate-along-vector
(the curve-right (point 0.5))
(subtract-vectors (the suport-curve-u (point 0.5))
(the suport-curve-v (point 0.5)))
(/(3d-distance (the suport-curve-u (point 0.5))
(the suport-curve-v (point 0.5))) 2)))
(surface-u :type 'lofted-surface
:display-controls (list :color :red :line-thickness 2)
:curves (if (the with-suport-curve?)
(list (the curve-bottom)
(the suport-curve)
(the curve-top))
(list (the curve-bottom)
(the curve-top))))
(extended-v-min :type 'extended-surface
:display-controls (list :color :green :line-thickness 2)
:surface (the surface-u)
:curve (the curve-left)
:direction :v
:which-end :start
:deformation-param 0.5)
(extended-v-max :type 'extended-surface
:display-controls (list :color :green :line-thickness 2)
:surface (the extended-v-min)
:curve (the curve-right)
:direction :v
:which-end :end
:deformation-param 0.5)))
| 7,734 | Common Lisp | .lisp | 157 | 33.598726 | 93 | 0.527643 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7d1bff7fe3982d3623f173a6e7634b29b3f8127c6f797cf7d89c905ebe79f419 | 35,887 | [
-1
] |
35,888 | parameters.lisp | lisp-mirror_gendl/surf/source/parameters.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(defvar *geometry-kernel* nil)
(defparameter *chain-beziers-for-display?* nil
"Boolean. Indicates whether display bezier curves within a single
nurbs curve should be chained. Might be necessary for filled rendering.
Legacy behavior was t. Now defaults to nil."
)
(defparameter *display-tolerance* 0.01
"Number. Default tolerance used in approximating non-cubic or rational
NURBS curves with cubic beziers for display with PDF and GWL web-based
image displays (PNG or JPEG). Smaller values give better display fidelity
for very small objects at the expense of speed, larger values sacrifice
display fidelity for better speed. Default value is 0.01, which should give
decent performance but might give distorted rendering for extremely small objects.
This could be made to be somewhat adaptive, i.e. resetting itself on the fly
to a smaller value when dealing with smaller curves. Please let us know if you
think this would be useful.
<p>
Note that 3rd degree non-rational curves do not require approximation and are not
affected by this paramter.
</p>
")
(defparameter *crease-angle-default* 1.5
"Number. The crease-angle for VRML indexed-face-set display. This is an angle in radians,
which if the two polygon faces have more than this angle between them, the edge
will not be smoothed.")
(defparameter *finalize-lofted-surfaces?* nil
"Boolean. For debugging of memory leak. If you experience high C heap usage,
set this to t. But be sure to watch out for Signal 11 in this case."
)
(defparameter *approximation-tolerance-factor* 5
"Number. Factor multiplied by minimum brep adaptive-tolerance to compute tolerance for boolean operations.")
(defparameter *3d-approximation-tolerance-default* 0.001
"Number. Tolerance used when approximating in e.g. Newton-Raphson iterations.")
(defparameter *boolean-operation-tolerance-default* nil
"Number or nil. Tolerance used when doing boolean operations. Defaults to nil, which
means that boolean operations will use the approximation-tolerance-adaptive computed
by each brep. Defaults to nil. Note: this used to default to 0.001 (same as *3d-approximation-tolerance-default*).")
(defparameter *angle-tolerance-radians-default* 0.5729577951308232
"Number. Angular tolerance (in radians) used when approximating in e.g. Newton-Raphson iterations.")
(defparameter *3d-tolerance-default* 0.00000001
"Number. Tolerance used for intersections etc. Defaults 1.0e-8.")
(defparameter *brep-tolerance-default* nil
"Number. Tolerance used for creating breps. Defaults to nil. Note: this used to default to 1.0e-08")
(defparameter *output-units-default* :inches "Keyword symbol, one of :inches, :millimeters, :feet, :miles, :meters, :kilometers,
:mils, :microns, :centimeters, :microinches, or :no-units-specified. This determines the units when outputting geometry.
This value can be overridden with the :units keyword to the with-writer (for IGES, and soon STEP and other formats). Default
value is :inches.")
(defparameter *isos-default* (list :n-u 11 :n-v 11)
"Plist with keys :n-u and :n-v. Specifies the default number of isoparametric curves to display for surfaces, if not present in display-controls")
(defparameter *brep-isos-default* nil ;;(list :n-u 8 :n-v 8)
"Plist with keys :n-u and :n-v, nil, or keyword :tess.
Specifies the default number of isoparametric curves to display for breps, if not present in display-controls.
nil indicates to display only the edge curves. Keyword :tess indicates to use tessellation-lines. Defaults to
nil.")
(defparameter *brep-vrml-timeout* 20)
(defparameter *nurbs-to-beziers-timeout* 2)
(defparameter *boolean-allow-multiple-regions?* nil "Boolean. This global parameter provides the default value
for the allow-multiple-regions? input to the boolean-merge family of primitives.
If set to non-nil, throw warning but not error if any of the input breps has more than one
infinite region. Defaults to nil.")
(defparameter *boolean-error-on-invalid-brep?* t "Boolean. This global parameter provides the default value
for the error-on-invalid-brep? input to the boolean-merge family of primitives.
If set to non-nil, we throw an error instead of a warning if the resulting brep does not
pass the built-in validation test. If nil, we throw a warning but continue to return the resulting brep.
Defaults to t.")
(defparameter *debug?* nil)
(defparameter *tess-min-number-of-segments* 0
"Integer. Min number of segments for curve tessellations for computing default tessellation-parameters.
Default is 0, which means the value is ignored.")
(defparameter *tess-max-3d-edge-factor* 0.1
"Number. Factor determining Max 3D edge length for a brep tessellation element for computing
default tessellation-parameters.. This is multiplied by the longest diagonal of the brep, so a
value of 0.1 would be 1/10 the diagonal. Defaults to 0.1.")
(defparameter *tess-min-parametric-ratio* 0
"Number. Minimum parametric ratio for brep tessellations for computing default tessellation-parameters.
Default is 0, which means the value is ignored.")
(defparameter *tess-max-chord-height* 0
"Number. Maximum deviation of tessellation chord from true surface in brep tessellations
for computing default tessellation-parameters. Default is 0, which means the value is ignored.")
(defparameter *tess-max-angle-degrees* 12
"Number. Maximum angle deviation in degrees of tessellation face or edge from true surface or curve
for computing default tessellation-parameters. Default is 15.")
(defparameter *tess-min-3d-edge* 0
"Number. Minimum 3D edge length for tessellation element for computing default tessellation-parameters.
Default is 0, which means the value is ignored.")
(defparameter *minimum-segment-length-default* 0.01)
(defparameter *tess-min-edge-ratio-uv* 0
"Number. Minimum edge UV ratio for tessellation element.
for computing default tessellation-parameters. Default is 0, which means the value is ignored.")
(defparameter *tess-max-aspect-ratio* 2.2 "Number. Maximum aspect
ration for tessellation element. for computing default
tessellation-parameters.
Default is 2.2. Note: this parameter does not seem to be respected in
all cases, we are looking into the cause of this.")
(defparameter *brep-wireframe-tessellation?* nil)
(defparameter *curve-tessellation?* nil)
| 7,376 | Common Lisp | .lisp | 117 | 59.57265 | 149 | 0.775115 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b3d5d00283e7be7f81281b3b562aff05678f0ded056553d903e9b85d5b1105f9 | 35,888 | [
-1
] |
35,889 | planar-section-curve.lisp | lisp-mirror_gendl/surf/source/planar-section-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object planar-section-curve (curve)
:documentation (:description "Produces a single curve by sectioning a surface with a plane. If multiple results are expected,
use planar-section-curves instead."
:examples "<pre>
(in-package :surf)
(define-object test-planar-section-curve (base-object)
:objects
((planar-section-curve :type 'planar-section-curve
:surface (the test-surf)
:plane-normal (the (face-normal-vector :top))
:plane-point (make-point 0 0 2)
:display-controls (list :color :red :line-thickness 4))
(test-surf :type 'test-fitted-surface )))
(generate-sample-drawing :object-roots (list (make-object 'test-planar-section-curve))
:projection-direction (getf *standard-views* :trimetric))
</pre>")
:input-slots
("GDL Surface, face, or trimmed surface. The surface to be sectioned with a plane."
surface
("Number. Tolerance used when approximating in e.g. Newton-Raphson iterations.
Default is *3d-approximation-tolerance-default*."
3d-approximation-tolerance *3d-approximation-tolerance-default*)
("Number. Angular tolerance (in radians) used when approximating in e.g. Newton-Raphson iterations.
Default is *angle-tolerance-radians-default*."
angle-tolerance-radians *angle-tolerance-radians-default*)
("Vector. The normal of the sectioning plane. Defaults to the top vector of the local reference box."
plane-normal (the (face-center :top)))
("3D Point. A point on the sectioning plane. Defaults to the center."
plane-point (the center)))
:computed-slots
(
(on-surfaces (list (the surface)))
("Boolean. This will be non-nil if the curve was generated successfully."
success? (the %native-curve-iw%))
(native-curve-iw% (getf (the results-plist) :3d-curve))
(results-plist (multiple-value-bind (3d-curves uv-curves 3d-approximation-tolerance angle-tolerance-radians)
(intersect-surface-with-plane *geometry-kernel*
(the surface)(the plane-normal)(the plane-point)
:3d-approximation-tolerance (the 3d-approximation-tolerance)
:angle-tolerance-radians (the angle-tolerance-radians)
:finalize-on self)
(if (consp (rest uv-curves))
(error "Intersecting resulted in ~a curves. Please use planar-section-curves instead.~%"
(length uv-curves))
(list :uv-curve (first uv-curves) :3d-curve (first 3d-curves)
:3d-approximation-tolerance 3d-approximation-tolerance
:angle-tolerance-radians angle-tolerance-radians))))
(native-trimmed-curve-iw (when (and (typep (the surface) 'face) (the native-curve-iw%))
(first (the surface (trim-curves-to-face (list (the native-curve-iw%)))))))
(%native-curve-iw% (or (the native-trimmed-curve-iw) (the native-curve-iw%)))
(native-curve-iw (or (the %native-curve-iw%) (error "The planar-section-curve found no results."))))
:hidden-objects
((%uv-curve% :type 'curve
:native-curve-iw (getf (the results-plist) :uv-curve)))
:functions
(("GDL Curve object. The UV curve for this curve in the context of the surface.
:&optional (surface (the surface)) \"GDL Surface object. The surface on which the UV curve lies.\""
uv-curve
(&optional (surface (the surface)))
(if (eql surface (first (the on-surfaces)))
(the %uv-curve%)
(error "This curve is not on that surface.")))))
(define-object planar-section-curves (base-object)
:documentation (:description "Produces multiple curves by sectioning a surface or a brep with a plane.
If a single result is expected, use planar-section-curve instead."
:examples "<pre>
(in-package :surf)
(define-object test-planar-section-curves (base-object)
:computed-slots
((points-data '(((0 0 0)(0 1 0)(1 1 0)(1 0 0))
((0 0 1) (0 1 1) (1 1 1) (1 0 1) )
((0 0 2) (0 1 2) (1 1 2) (1 0 2) )
((0 0 3) (0 1 3) (1 1 3) (1 0 3) )))
(control-points (mapcar #'(lambda(list) (mapcar #'apply-make-point list))
(the points-data))))
:objects
((planar-section-curve :type 'planar-section-curves
:surface (the test-surf)
:plane-normal (the (face-normal-vector :front))
:plane-point (make-point 0 0.5 0)
:display-controls (list :color :red :line-thickness 4))
(test-surf :type 'b-spline-surface
:control-points (the control-points)) ))
(generate-sample-drawing :object-roots
(list (make-object 'test-planar-section-curves))
:projection-direction
(getf *standard-views* :trimetric))
</pre>" )
:input-slots
(("GDL Surface object. The surface to be sectioned with a plane. Specify this or brep, not both."
surface nil)
("GDL Brep object. The brep to be sectioned with a plane. Specify this or surface, not both."
brep nil)
("Number. Tolerance used when approximating in e.g. Newton-Raphson iterations.
Default is *3d-approximation-tolerance-default*."
3d-approximation-tolerance *3d-approximation-tolerance-default*)
("Number. Angular tolerance (in radians) used when approximating in e.g. Newton-Raphson iterations.
Default is *angle-tolerance-radians-default*."
angle-tolerance-radians *angle-tolerance-radians-default*)
("Vector. The normal of the sectioning plane. Defaults to the top vector of the local reference box."
plane-normal (the (face-center :top)))
("3D Point. A point on the sectioning plane. Defaults to the center."
plane-point (the center)))
:computed-slots
(
(native-curves-iw (getf (the data-plist) :native-curves-iw))
(native-uv-curves-iw (getf (the data-plist) :native-uv-curves-iw))
("Number. The actual tolerance achieved by the operation."
3d-approximation-tolerance-achieved (getf (the data-plist) :3d-approximation-tolerance))
("Number. The actual angle tolerance achieved by the operation."
angle-tolerance-radians-achieved (getf (the data-plist) :angle-tolerance-radians))
(data-plist
(progn
(when (and (the brep) (the surface))
(error "planar-section-curves can only be called with brep or surface, not both.~%"))
(cond ((the surface)
(multiple-value-bind (3d-curves uv-curves 3d-approximation-tolerance angle-tolerance-radians)
(intersect-surface-with-plane *geometry-kernel* (the surface) (the plane-normal) (the plane-point)
:3d-approximation-tolerance (the 3d-approximation-tolerance)
:angle-tolerance-radians (the angle-tolerance-radians)
:finalize-on self)
(list :native-curves-iw 3d-curves :native-uv-curves-iw uv-curves
:3d-approximation-tolerance 3d-approximation-tolerance :angle-tolerance-radians angle-tolerance-radians)))
((the brep)
(multiple-value-bind (3d-curves uv-curves faces)
(brep-planar-section-curves *geometry-kernel*
(the brep %native-brep%)
(the plane-point)
(the plane-normal)
:tolerance (the 3d-approximation-tolerance)
:angle-tolerance-radians (the angle-tolerance-radians))
(list :native-curves-iw 3d-curves
:native-uv-curves-iw uv-curves
:faces faces)))
(t (error "planar-section-curves must be provided with a brep or a surface.")))))
(native-trimmed-curves-iw (if (typep (the surface) 'face)
(the surface (trim-curves-to-face (the native-curves-iw)))
(the native-curves-iw))))
:objects
(
(faces
:type 'face
:sequence (:size (length (getf (the data-plist) :faces)))
:%native-face% (nth (the-child index) (getf (the data-plist) :faces)))
("Sequence of GDL uv curve objects. The UV curves for each returned curve. This is also passed into each
curve object and available from there."
uv-curves
:type 'curve
:sequence (:size (length (getf (the data-plist) :native-uv-curves-iw)))
:native-curve-iw (nth (the-child index) (the native-uv-curves-iw)))
("Sequence of GDL Curve Objects. The curves resulting from sectioning."
curves ;;:type 'trimmed-curve
:type 'curve
:sequence (:size (length (the native-trimmed-curves-iw)))
:native-curve-iw (nth (the-child index) (the native-trimmed-curves-iw))
:face (when (the brep) (the (faces (the-child index))))
:pseudo-inputs (face)
:uv-curve (the (uv-curves (the-child index))))))
| 10,638 | Common Lisp | .lisp | 179 | 45.843575 | 128 | 0.614885 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 2f560775bc8ac075f8c18976a081b6ccf26109da3324e60ab8c14c4d3200b52b | 35,889 | [
-1
] |
35,890 | lofted-surface.lisp | lisp-mirror_gendl/surf/source/lofted-surface.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object lofted-surface (surface)
:documentation (:description "Loft of a surface through a list of curves with
various controls. "
:examples "<pre>
(in-package :surf)
(define-object test-lofted-surface (base-object)
:input-slots
((curves (list (the curve-1) (the curve-2) (the curve-3) (the curve-4) )))
:objects
((lofted-surface :type 'lofted-surface
:curves (the curves))
(curve-1 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 0)
(make-point 1 1 0)
(make-point 0 1 0)
(make-point 0 0 0) ))
(curve-2 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 1)
(make-point -1 1 1)
(make-point 0 1 1)
(make-point 0 0 1) ))
(curve-3 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 2)
(make-point -1 -1 2)
(make-point 0 -1 2)
(make-point 0 0 2) ))
(curve-4 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 3)
(make-point 1 -1 3)
(make-point 0 -1 3)
(make-point 0 0 3) ))))
(generate-sample-drawing :object-roots (make-object 'test-lofted-surface)
:projection-direction :trimetric)
</pre>" )
:input-slots
("List of GDL Curve objects. The curves through which the surface will be lofted."
curves
("List of curve parameters. The parameter value on the rail-1 which
should correspond to each respective profile curve. Defaults to the evenly
spaced parameters between the u-min and u-max of the rail-1, one for each
profile curve."
rail-1-params (when (the rail-1)
(the rail-1 (equi-spaced-parameters (length (the curves))))))
("GDL Curve object. Guide rail corresponding to minimum U parameter of
resulting surface. Defaults to nil."
rail-1 nil)
("Boolean. If specified as non-nil, then the rail-1 will be used
as a spine curve similar to what is described on page 462 of the NURBS book.
Default is nil."
rail-1-is-spine? nil)
("GDL Curve object. Guide rail corresponding to maximum U parameter
of resulting surface. Defaults to nil. If both rail-1 and rail2 are given,
then they must be synchronized."
rail-2 nil)
("Integer. The degree of the surface in the lofting direction. Defaults to 3."
v-degree 3)
("Number. The fitting tolerance to fit to the loft curves.
0 means to interpolate exactly. Default is 0"
tolerance 0)
("Boolean. Set this to t if the curves already have synchronized control points.
It makes the lofted-surface much lighter-weight in terms of its control mesh.
Default is NIL (which means the lofted-surface does not assume synchronized
control points on the profile curves)."
synchronized? nil)
("Boolean. If non-nil, we use the low-level nlib ascssk directly. If nil, we use
the SMLib make-skinned-surface routine. Default is nil"
use-ascssk? nil)
("GDL Curve object. Curve to use as spine for calling ascssk."
spine nil)
(spine-parameters (the spine (equi-spaced-parameters (length (the curves)))))
(align-profiles? nil)
(spine-z-axis (the (face-normal-vector :top)))
(subdivision-level 5)
(derivative-selection :all-derivatives)
(skinning-degree 3)
(u-or-v :u)
)
:computed-slots
(
(native-surface
(if (the use-ascssk?)
(skin-with-spine *geometry-kernel*
:profile-curves (mapsend (the curves) :copy-new)
:synchronized? (the synchronized?)
:spine-curve (if (the spine)
(the spine native-curve)
(error "You must give a rail-1 in this case."))
:spine-parameters (the spine-parameters)
:align-profiles? (the align-profiles?)
:spine-z-axis (the spine-z-axis)
:subdivision-level (the subdivision-level)
:derivative-selection (the derivative-selection)
:skinning-degree (the skinning-degree)
:u-or-v (the u-or-v))
(call-next-method)))
(native-surface-iw
(if (the use-ascssk?)
(call-next-method)
(let ((control-points-1 (when (the rail-2)
(length (the rail-1 b-spline-data))))
(control-points-2 (when (the rail-2)
(length (the rail-2 b-spline-data)))))
(when (and control-points-1 control-points-2
(/= control-points-1 control-points-2))
(error "For lofted-surface, rail-1 and rail-2, if both specified, must be synchronized."))
(loft-surface* *geometry-kernel* (the curves)
:synchronized? (the synchronized?)
:rail-1 (when (the rail-1)
(the rail-1 copy-new))
:rail-2 (when (the rail-2)
(the rail-2 copy-new))
:v-degree (the v-degree)
:tolerance (the tolerance)
:rail-1-params (the rail-1-params)
:rail-1-is-spine?
(cond ((and (the rail-1-is-spine?)
(not (the rail-1)))
(warn "You have to give a rail to give rail-1-is-spine?~%"))
((and (the rail-1-is-spine?)
(the rail-1)) t)
(t nil))))))))
(define-object test-lofted-surface ()
:input-slots
((curves (list (the curve-1) (the curve-2) (the curve-3) (the curve-4) )))
:objects
((lofted-surface :type 'lofted-surface
:curves (the curves))
(curve-1 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 0)
(make-point 1 1 0)
(make-point 0 1 0)
(make-point 0 0 0) ))
(curve-2 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 1)
(make-point -1 1 1)
(make-point 0 1 1)
(make-point 0 0 1) ))
(curve-3 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 2)
(make-point -1 -1 2)
(make-point 0 -1 2)
(make-point 0 0 2) ))
(curve-4 :type 'b-spline-curve
:display-controls (list :color :red :line-thickness 3)
:control-points (list (make-point 0 0 3)
(make-point 1 -1 3)
(make-point 0 -1 3)
(make-point 0 0 3) ))
))
| 9,125 | Common Lisp | .lisp | 177 | 35.039548 | 101 | 0.537227 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 301b037b9ed99ea6e98c2c1df3971aa2d13d4833bda44f3c9d8728572744b3bc | 35,890 | [
-1
] |
35,891 | circular-curve.lisp | lisp-mirror_gendl/surf/source/circular-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object circular-curve (arc-curve)
:documentation
(:description
"An full circule represented exactly as a quadratic NURBS
curve. Inputs and messages are the same as for arc-curve."
:examples "<pre>
(in-package :surf)
(define-object test-circular-curve (circular-curve)
:computed-slots
((center (make-point 0 0 0)) (radius 10)))
(generate-sample-drawing :objects (make-object 'test-circular-curve))
</pre>"))
;;
;; FLAG -- add Lift regression test in gendl/regression/source/
;;
| 1,404 | Common Lisp | .lisp | 36 | 36.222222 | 71 | 0.746637 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c01981191b123fed7479c1f2183ac50cec7b1d51af36be8f5e61fdf9dabbc0ef | 35,891 | [
-1
] |
35,892 | b-spline-surface.lisp | lisp-mirror_gendl/surf/source/b-spline-surface.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object b-spline-surface (surface)
:documentation (:description "A general b-spline surface specified with control points, weights, knots, and degree."
:examples "<pre>
(in-package :surf)
(define-object test-b-spline-surface (b-spline-surface)
:computed-slots
((points-data '(((0 0 0)(4 1 0)(8 1 0)(10 0 0)(8 -1 0)(4 -1 0)(0 0 0))
((0 0 2) (4 2 2) (8 2 2) (10 0 2) (8 -2 2) (4 -2 2) (0 0 2))
((0 0 4) (4 2 4) (8 2 4) (10 0 4) (8 -2 4) (4 -2 4) (0 0 4))
((0 0 7) (4 1 7) (8 1 7) (10 0 7) (8 -1 7) (4 -1 7) (0 0 7))))
(control-points (mapcar #'(lambda(list)
(mapcar #'apply-make-point list))
(the points-data)))
(display-controls (list :color :periwinkle :line-thickness 2))))
(generate-sample-drawing :object-roots (make-object 'test-b-spline-surface)
:projection-direction :trimetric)
</pre>")
:input-slots
("List of lists of 3D Points. The control net."
control-points
("Integer. Degree of surface in U direction. Defaults to 3." u-degree 3)
("List of Numbers. Knots in U direction. Default is NIL, which indicates a uniform knot vector in U direction."
u-knot-vector (make-uniform-knot-vector (length (first (the control-points))) (the u-degree)))
("Integer. Degree of surface in V direction. Defaults to 3."
v-degree 3)
("List of Numbers. Knots in V direction. Default is NIL, which indicates a uniform knot vector in V direction."
v-knot-vector (make-uniform-knot-vector (length (the control-points)) (the v-degree)))
("List of lists of numbers. A weight to match each control point. Should be congruent with control-points
(i.e. same number of rows and columns). Default is a value of 1.0 for each weight, resulting in a nonrational surface."
weights (make-list (length (the control-points))
:initial-element (make-list (length (first (the control-points))) :initial-element 1.0))))
:computed-slots
((native-surface (make-b-spline-surface *geometry-kernel* (the control-points)
(the weights)
(the u-degree) (the u-knot-vector)
(the v-degree) (the v-knot-vector)))))
(define-object test-b-spline-surface (b-spline-surface)
:input-slots ((display-controls (list :color :periwinkle :line-thickness 2))
(z-stretch 1))
:computed-slots
((points-data '(((0 0 0)(4 1 0)(8 1 0)(10 0 0)(8 -1 0)(4 -1 0)(0 0 0))
((0 0 2) (4 2 2) (8 2 2) (10 0 2) (8 -2 2) (4 -2 2) (0 0 2))
((0 0 4) (4 2 4) (8 2 4) (10 0 4) (8 -2 4) (4 -2 4) (0 0 4))
((0 0 7) (4 1 7) (8 1 7) (10 0 7) (8 -1 7) (4 -1 7) (0 0 7))))
(control-points (mapcar #'(lambda(list) (mapcar #'apply-make-point
(mapcar #'(lambda(list)
(list (first list)
(second list)
(* (third list) (the z-stretch))))
list)))
(the points-data))))
:hidden-objects ((view :type 'base-view
:pseudo-inputs (page-width page-length)
:projection-vector (getf *standard-views* :trimetric)
:page-width (* 5 72) :page-length (* 5 72)
:objects (list self))))
| 4,456 | Common Lisp | .lisp | 77 | 46.298701 | 121 | 0.587836 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b027760bee1bd1a8b3ce37a2af3525a2a3f5c8f0e71e63e797bc7db2ca19a801 | 35,892 | [
-1
] |
35,893 | offset-solid.lisp | lisp-mirror_gendl/surf/source/offset-solid.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object offset-solid (brep)
:documentation (:description "Offsets the faces of a brep by a certain distance.")
:input-slots
("GDL Brep object. The brep to be offset." brep
"Number. The distance to offset. Can be negative." distance
("Number. The tolerance to use for the shelling operation.
Defaults to (the adaptive-tolerance) of the input brep."
tolerance (the %actual-brep% adaptive-tolerance)))
:computed-slots
((%actual-brep%
(if (typep (the brep) 'brep) (the brep)
(the brep brep)))
(%native-brep%
(make-offset-brep *geometry-kernel*
(the %actual-brep% %native-brep%)
:distance (the distance)
:tolerance (the tolerance)))))
(define-object shelled-solid (brep)
:documentation (:description "Offsets the faces of a brep by a certain thickness.")
:input-slots
("GDL Brep object. Should be an open shell.
The brep to be shelled into a solid." brep
"Number. The distance to offset. Can be negative."
distance
("Number. The tolerance to use for the shelling operation.
Defaults to (the adaptive-tolerance) of the input brep."
tolerance (the %actual-brep% adaptive-tolerance))
)
:computed-slots
((%actual-brep%
(if (typep (the brep) 'brep) (the brep) (the brep brep)))
(%native-brep%
(make-shelled-brep *geometry-kernel*
(the %actual-brep% %native-brep%)
:distance (the distance)
:tolerance (the tolerance)))))
| 2,445 | Common Lisp | .lisp | 57 | 37.105263 | 85 | 0.684076 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 08d754b54ffe9875bad8211ce90f18261e3f8ed46ed19fda92f1b5514919491b | 35,893 | [
-1
] |
35,894 | split-surface.lisp | lisp-mirror_gendl/surf/source/split-surface.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object split-surface (surface)
:documentation (:description
"Given a NURBS and a parameter in U or V direction,
split the surface at the parameter and return one section or the other as the
toplevel self of this instance. Note that both resulting sections are also
reflected in (the surfaces) sequence which is a hidden child in this object.
As an alternative to a parameter, a projection-point and projection-vector
can also be given, and the U or V parameter at the resulting surface point
will be used as the parameter.
"
:examples "
<pre>
(in-package :gdl-user)
(define-object test-split-surface (base-object)
:computed-slots ((projection-point (make-point 10 0 3))
(projection-vector (make-vector 1 0 0))
(u-or-v :u :settable)
(keep-side :left :settable))
:objects
((test-surface :type 'test-b-spline-surface
:display-controls nil)
(split :type 'split-surface
:display-controls (list :color :red :line-thickness 3)
:surface-in (the test-surface)
:pass-down (keep-side u-or-v projection-point projection-vector))))
(generate-sample-drawing :object-roots (make-object 'test-split-surface)
:projection-direction (getf *standard-views* :trimetric))
</pre>
"
)
:input-slots
(("Keyword symbol, one of :u or :v. Determines the direction of the split."
u-or-v :u)
("GDL Surface object. The surface to be split." surface-in)
("Number. The parameter in U or V direction at which to do the split. This must
lie in the domain between (the u-min) [or (the v-min)] and (the u-max) [or (the v-max)]
of the surface-in. If it is outside this domain, a warning will be thrown and the
value will be pinned to the nearest value within the domain.
If this input is not specified and you specify a projection-point and projection-vector,
then this projected point will be used to establish the parameter for splitting. "
parameter (ecase (the u-or-v)
(:u (get-u (get-uv-point-of (the projected-point))))
(:v (get-v (get-uv-point-of (the projected-point))))))
("3D Point or nil. If given and parameter is not given,
this point will be projected onto the surface using (the projection-vector)
to establish the split parameter. Defaults to nil."
projection-point nil)
("3D Vector or nil. If given and parameter is not given,
this will be used to project (the projection-point)
onto the surface to establish the split parameter.
Defaults to nil." projection-vector nil)
("Keyword symbol, one of :left or :right. Determines which half of the split
surface to reflect in this instance. Both halves will be reflected in (the surfaces)
hidden-object sequence which is a child of this instance."
keep-side :left))
:computed-slots
((projected-points (when (and (the projection-point)
(the projection-vector))
(the surface-in (projected-points (the projection-point)
(the projection-vector)))))
(projected-point (least #'(lambda(point) (3d-distance (get-3d-point-of point) (the projection-point)))
(the projected-points)))
(pinned-parameter (if (< (the surface-in (evaluate (ecase (the u-or-v)
(:u :u-min)
(:v :v-min))))
(the parameter)
(the surface-in (evaluate (ecase (the u-or-v)
(:u :u-max)
(:v :v-max)))))
(the parameter)
(error "In split-surface at ~s, parameter must
be between the u-min and u-max of the surface-in."
(cons 'the (reverse (the root-path))))))
(%native-surfaces% (split-surface-at-param
*geometry-kernel*
:native-surface (the surface-in native-surface)
:u-or-v (ecase (the u-or-v) (:u :u) (:v :v))
:parameter (the pinned-parameter)))
(native-surface (ecase (the keep-side)
(:left (the (surfaces 0) native-surface))
(:right (the (surfaces 1) native-surface)))))
:hidden-objects
((surfaces :type 'surface
:sequence (:size 2)
:native-surface (nth (the-child index)
(the %native-surfaces%)))))
| 5,892 | Common Lisp | .lisp | 107 | 41.495327 | 106 | 0.606012 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d53c9572d8d61bf38f7c6bdd3586c335d557582185423d8b295c23257c3c6c33 | 35,894 | [
-1
] |
35,895 | swept-solid.lisp | lisp-mirror_gendl/surf/source/swept-solid.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object swept-solid (brep)
:documentation (:description "This primitive will take a brep as input,
and sweep all its faces in the given direction by the given distance,
to produce another brep."
:examples "<pre>
(in-package :gdl-user)
(define-object swept-solid-example (swept-solid)
:computed-slots
((facial-brep (the trimmed brep))
(vector (make-vector 0 0 1))
(distance 10)
(display-controls (list :isos (list :n-u 8 :n-v 8) :color :blue :transparency 0.3)))
:hidden-objects
((rectangle :type 'rectangular-surface
:width 20 :length 20)
(trim-curve :type 'global-filleted-polyline-curve
:vertex-list (list (translate (the center) :right 8 :rear 8)
(translate (the center) :left 8 :rear 8)
(translate (the center) :left 8 :front 8)
(translate (the center) :right 8 :front 8)
(translate (the center) :right 8 :rear 8))
:default-radius 3)
(trimmed :type 'trimmed-surface
:basis-surface (the rectangle)
:reverse-island? t
:island (the trim-curve))))
(generate-sample-drawing :objects (make-object 'swept-solid-example)
:projection-direction (getf *standard-views* :trimetric))
</pre>")
:input-slots ("GDL Brep object. The original brep, which can contain one or more faces, planar and/or non-planar."
facial-brep
"GDL Vector. The direction in which the sweep is desired."
vector
"Number. The distance over which the sweep is desired."
distance)
:computed-slots ((%native-brep%
(make-linear-swept-brep *geometry-kernel* (the facial-brep %native-brep%)
(the vector) (the distance)))))
| 2,979 | Common Lisp | .lisp | 59 | 38.711864 | 117 | 0.623074 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | cf5f70392e3a444b7c7eefb409d5325f8fcd57823d3e93b2ffc0a8e74d6e8765 | 35,895 | [
-1
] |
35,896 | joined-and-compatible-surfaces.lisp | lisp-mirror_gendl/surf/source/joined-and-compatible-surfaces.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
;;-------------------------------------------------------------------------
(define-object joined-surfaces (surface)
:documentation (:description "This routine joins two surfaces at a common boundary. The surfaces must already be compatible in the direction of the common boundary (same knots). If the surfaces are not compatible you can use first compatible-surfaces if applicable"
:examples "<pre>
(in-package :gdl-user)
(define-object join-surfaces-test (base-object)
:computed-slots ((surface-list (list (the surf-A) (the surf-B))))
:objects
((surf-A :type 'rectangular-surface
:display-controls (list :color :green-spring-medium)
:length 10
:width 10 )
(surf-B :type 'rectangular-surface
:display-controls (list :color :red)
:center (make-point 10 0 0 )
:length 10
:width 10 )
(join-A-and-B :type 'joined-surfaces
:display-controls (list :line-thickness 2)
:surface (the surf-A)
:other-surface (the surf-B))))
(generate-sample-drawing :object-roots
(list (the-object (make-object 'join-surfaces-test)
join-A-and-B)))
</pre>
")
:input-slots ("Gdl surface object. The first surface to be joined. Its u-max or v-max lays at the common boundary." surface
"Gdl surface object. The second surface to be joined . Its u-min or v-min lays at the common boundary." other-surface
("Number. This is a tolerance used for Knot removal. The knot corresponding to the merged boundary has multiplicity equal to the degree. Knot removal will be attempted using this tolerance. Default is *3d-tolerance-default*" tolerance *3d-tolerance-default*)
("Keyword symbol, one of :u or :v. If :u the common
boundary is for first surface u-max and for the second
surface u-min. Surfaces must already be compatible in
the u-direction. If :v the common boundary is for
first surface v-max and for the second surface
v-min. Surfaces must already be compatible in the
v-direction. Default is :u. " direction :u))
:computed-slots ((native-surface (join-surfaces *geometry-kernel* (the surface) (the other-surface)
:tolerance (the tolerance)
:direction (the direction )))))
(define-object compatible-surfaces (base-object)
:documentation (:description "This routine makes compatible a list of GDL surface, minimum 2 surfaces is required."
:examples "<pre>
(in-package :gdl-user)
(define-object compatible-surfaces-test (surface)
:computed-slots ((surface-list (list (the surf-A) (the surf-B))))
:objects
((make-compatible-A-and-B :type 'compatible-surfaces
:display-controls (list :line-thickness 2)
:surface-list (the surface-list))
(surf-A :type 'rectangular-surface
:display-controls (list :color :green-spring-medium)
:length 10
:width 10 )
(surf-B :type 'rectangular-surface
:display-controls (list :color :red)
:center (make-point 10 0 0 )
:length 10
:width 10 )))
(generate-sample-drawing :object-roots
(list (the-object (make-object 'compatible-surfaces-test)
make-compatible-A-and-B)))
</pre>
")
:input-slots ("List. A list of Gdl surface objects." surface-list)
:computed-slots ((native-surfaces-list (return-compatible-surfaces *geometry-kernel* (the surface-list))))
:objects ((surfaces :type 'surface
:sequence (:size (length (the native-surfaces-list)))
:native-surface (nth (the-child index) (the native-surfaces-list)))))
| 5,080 | Common Lisp | .lisp | 89 | 44.685393 | 277 | 0.622407 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 58b6ce12e09fb19b765d7d35376f9fa8aad88f80435513aa020a77320057c7ab | 35,896 | [
-1
] |
35,897 | elliptical-curve.lisp | lisp-mirror_gendl/surf/source/elliptical-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object elliptical-curve (curve ellipse)
:documentation (:description "An ellipse represented exactly as a quintic NURBS curve. Inputs are the same as for ellipse.
Messages are the union of those for ellipse and those for curve."
:examples "<pre>
(in-package :surf)
(define-object test-elliptical-curve (elliptical-curve)
:computed-slots
((center (make-point 0 0 0))
(major-axis-length 10)
(minor-axis-length 5)
(start-angle 0)
(end-angle 2pi)))
(generate-sample-drawing :objects (make-object 'test-elliptical-curve))
</pre>")
:computed-slots
((native-curve (make-elliptical-curve *geometry-kernel* (the center) (the orientation)
(the minor-axis-length) (the major-axis-length)
(the start-angle-normalized) (the end-angle-normalized)))))
| 1,835 | Common Lisp | .lisp | 39 | 40.025641 | 126 | 0.688 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 4d789bd7146395766f2c7f3a3f1c7575600c80cf411451a030fb41435c245151 | 35,897 | [
-1
] |
35,898 | arc-curve.lisp | lisp-mirror_gendl/surf/source/arc-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object arc-curve (curve arc)
:documentation (:description "An arc represented exactly as a quadratic NURBS curve. Inputs are the same as for arc.
Messages are the union of those for arc and those for curve."
:examples "<pre>
(in-package :surf)
(define-object test-arc-curve (arc-curve)
:computed-slots
((center (make-point 0 0 0)) (radius 10) (start-angle 0) (end-angle 2pi)))
(generate-sample-drawing :objects (make-object 'test-arc-curve))
(define-object test-arc-curve2 (arc-curve)
:computed-slots
((center (make-point 0 0 0)) (radius 5) (start-angle (* 0.25 pi)) (end-angle pi)))
(generate-sample-drawing :objects (make-object 'test-arc-curve))
</pre>")
:computed-slots
((native-curve (make-arc-curve *geometry-kernel* (the center) (the orientation)
(the radius) (the start-angle-normalized) (the end-angle-normalized)))))
;; (define-object test-arc-curve (arc-curve)
;; :computed-slots
;; ((center (make-point 0 0 0)) (radius 10) (start-angle 0) (end-angle 2pi))
;; :hidden-objects ((view :type 'base-view
;; :objects (list self)
;; :page-width (* 5 72) :page-length (* 5 72))))
;; (define-object test-arc-curve-2 (arc-curve)
;; :computed-slots
;; ((center (make-point 0 0 0)) (radius 10) (start-angle 0) (end-angle pi))
;;
;; :hidden-objects ((view :type 'base-view
;; :objects (list self)
;; :page-width (* 5 72) :page-length (* 5 72))))
| 2,502 | Common Lisp | .lisp | 51 | 44.137255 | 120 | 0.657334 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e33c803f728b6a544bb6dbfe4f0e460b2a6000e2d46fe53c505d4425584050a5 | 35,898 | [
-1
] |
35,899 | approximated-curve.lisp | lisp-mirror_gendl/surf/source/approximated-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object approximated-curve (curve)
:documentation (:description "This primitive accepts a NURBS curve and
computes a new NURBS curve with presumably fewer control points, and claims
to hold it to within a certain tolerance of the original curve.
The point at the start parameter and the end parameter in the result
curve will be fixed to be identical to the original curve.
You can use the pinned-parameters input-slot to specify additional parameter
values where the new curve will be pinned to be identical with the original curve.
NOTE: This object is currently non-functional and is expected to be
re-activated in GDL 1585.
"
:examples "
<pre>
(define-object approximated-curve-test (base-object)
:input-slots
((sample-b-spline-data
'((#(-7.773502691896258 10.0 0.0)
#(-7.76304131662674 10.0 0.0035356993309923)
#(-7.746775287947699 10.0 0.0067001904580447)
#(-7.7253289934578415 10.0 0.0091817670732663)
#(-7.709372706886673 10.0 0.0109178383762297)
#(-7.693497618275636 10.0 0.0129741578942581)
#(-7.676981089448407 10.0 0.0152725944452429)
#(-7.660626985913543 10.0 0.0176076438762828)
#(-7.644400043044812 10.0 0.0198301741704749)
#(-7.628572854579257 10.0 0.0218811393098875)
#(-7.612456095337886 10.0 0.023892087537815)
#(-7.596123157036033 10.0 0.025876731740358)
#(-7.5797886014351645 10.0 0.0278392394943197)
#(-7.563598247718005 10.0 0.0297977372116626)
#(-7.54734474235553 10.0 0.0317827355165938)
#(-7.530817428296935 10.0 0.0338094455691551)
#(-7.514499984995836 10.0 0.0358111584598995)
#(-7.498530032892328 10.0 0.037762615650263)
#(-7.482560694806967 10.0 0.0396996233035483)
#(-7.466938587271525 10.0 0.0415717500361984)
#(-7.45613073401155 10.0 0.0428492028474684)
#(-7.445702016561547 10.0 0.04407409984323)
#(-7.439862498458236 10.0 0.0447555129227675)
#(-7.429535001467346 10.0 0.0459531655261334)
#(-7.423946015929491 10.0 0.0465975377728551)
#(-7.413554192167366 10.0 0.0477892161812883)
#(-7.407595596706495 10.0 0.0484686195293404)
#(-7.396934499325897 10.0 0.049677834187285)
#(-7.391025013196135 10.0 0.0503446277462212)
#(-7.380668397266659 10.0 0.0515077909624895)
#(-7.374959869886305 10.0 0.0521461185088044)
#(-7.36464849713204 10.0 0.05329441651439)
#(-7.3587350147730115 10.0 0.0539501551169936)
#(-7.348489965069932 10.0 0.0550810605426388)
#(-7.342793963594458 10.0 0.0557070781305422)
#(-7.332490622079339 10.0 0.0568343892437064)
#(-7.3264770440672065 10.0 0.0574891649794912)
#(-7.316219293859572 10.0 0.0586004349229853)
#(-7.310517864890045 10.0 0.0592151399809975)
#(-7.300540086253307 10.0 0.0602855343476251)
#(-7.294748391590457 10.0 0.0609037603868834)
#(-7.284555892216601 10.0 0.061985955452512)
#(-7.278577998313509 10.0 0.062617198511794)
#(-7.268114585011737 10.0 0.0637157114288265)
#(-7.261986919319522 10.0 0.0643552477004073)
#(-7.2514547970306005 10.0 0.0654480650996109)
#(-7.245363578736502 10.0 0.066076354340049)
#(-7.235168395459871 10.0 0.0671217900147562)
#(-7.2293285386923625 10.0 0.0677172614089348)
#(-7.219456797793601 10.0 0.0687181850892115)
#(-7.21363748676987 10.0 0.0693049508093313)
#(-7.203721331045569 10.0 0.0702991235190865)
#(-7.197774951476638 10.0 0.0708918760373581)
#(-7.18753366922008 10.0 0.071906820780931)
#(-7.181328324859931 10.0 0.0725180648535886)
#(-7.170908624453838 10.0 0.0735382495023682)
#(-7.164741045570452 10.0 0.0741384240225961)
#(-7.154470299979475 10.0 0.0751317627718068)
#(-7.1483716586933825 10.0 0.0757179834474372)
#(-7.138406833936611 10.0 0.0766699111117332)
#(-7.132501722803377 10.0 0.0772306457809111)
#(-7.12244815794467 10.0 0.0781794021319588)
#(-7.116194798062766 10.0 0.0787657100109435)
#(-7.105880729941813 10.0 0.0797262397246034)
#(-7.099656569353997 10.0 0.0803020171513102)
#(-7.089330480447966 10.0 0.0812507479304588)
#(-7.083006810743995 10.0 0.0818277014224611)
#(-7.0730076945596645 10.0 0.0827335903150743)
#(-7.067069212658176 10.0 0.0832680013237252)
#(-7.057382524393892 10.0 0.0841338221164179)
#(-7.0513228782074515 10.0 0.0846717275930971)
#(-7.041364101581027 10.0 0.0855495109968372)
#(-7.035106540724323 10.0 0.0860970019877134)
#(-7.024857742651612 10.0 0.0869868797241497)
#(-7.018438815809276 10.0 0.087539916228507)
#(-7.008168401811841 10.0 0.0884178150543803)
#(-7.00184087536049 10.0 0.0889544270356334)
#(-6.9919619641004545 10.0 0.0897854973995385)
#(-6.985881827579846 10.0 0.0902930555610231)
#(-6.976281029598491 10.0 0.0910882693796495)
#(-6.970184675056803 10.0 0.091589260852436)
#(-6.960320705968006 10.0 0.0923932980242485)
#(-6.953917746465384 10.0 0.0929107533519837)
#(-6.943757762558306 10.0 0.0937245181023455)
#(-6.937303992646001 10.0 0.0942367919470313)
#(-6.9271520790382235 10.0 0.0950351703452132)
#(-6.920707811824021 10.0 0.0955372165209965)
#(-6.910885266876965 10.0 0.0962951353561948)
#(-6.904716963255798 10.0 0.096766697374172)
#(-6.895200295978004 10.0 0.0974873900684733)
#(-6.889018398304428 10.0 0.0979511004533426)
#(-6.8792396786986085 10.0 0.0986773910779738)
#(-6.8727507213 10.0 0.0991543261574633)
#(-6.86267690754424 10.0 0.0998867125969024)
#(-6.856136640740504 10.0 0.100356993136921)
#(-6.846050345447107 10.0 0.1010740145138523)
#(-6.839489198598122 10.0 0.1015350665777411)
#(-6.829441747557248 10.0 0.1022327061061873)
#(-6.82289308331905 10.0 0.1026819075455008)
#(-6.813152437915218 10.0 0.1033417487088309)
#(-6.806847948189532 10.0 0.103763701703458)
#(-6.7971454958195565 10.0 0.1044050485135838)
#(-6.790595307231813 10.0 0.10483231339683)
#(-6.780922064334754 10.0 0.1054546472054939)
#(-6.77458575320461 10.0 0.1058569326392236)
#(-6.7649029807976975 10.0 0.1064632879605449)
#(-6.758284636701557 10.0 0.1068717205935851)
#(-6.748340665523174 10.0 0.1074760046701189)
#(-6.741671570163981 10.0 0.1078750063466806)
#(-6.731717886166939 10.0 0.1084609002957398)
#(-6.7250260196879 10.0 0.1088483306291875)
#(-6.715132250830737 10.0 0.1094113701746257)
#(-6.708479289674014 10.0 0.1097833660497434)
#(-6.698863733855831 10.0 0.1103113585573882)
#(-6.692407555733223 10.0 0.1106596095578191)
#(-6.683112518678094 10.0 0.1111518410008553)
#(-6.67673768062156 10.0 0.1114832653763077)
#(-6.667240402771452 10.0 0.1119675047371582)
#(-6.660514775321519 10.0 0.1123033129775543)
#(-6.650681029972996 10.0 0.1127835983503758)
#(-6.643918945899163 10.0 0.1131064056804846)
#(-6.63405272844892 10.0 0.1135663439198465)
#(-6.627254408957563 10.0 0.1138754999668116)
#(-6.617707456082231 10.0 0.1142985673023449)
#(-6.611225484562257 10.0 0.1145786891314138)
#(-6.60204805594244 10.0 0.1149649311892426)
#(-6.595561879720703 10.0 0.1152306714612809)
#(-6.586146787784009 10.0 0.1156055153436167)
#(-6.579359503332465 10.0 0.1158674765410608)
#(-6.569607126249581 10.0 0.1162316741844863)
#(-6.562716518300558 10.0 0.1164802471836087)
#(-6.552941578381875 10.0 0.1168201535727847)
#(-6.546090216293524 10.0 0.1170494074887217)
#(-6.536674084104508 10.0 0.117351835565929)
#(-6.530101252192292 10.0 0.1175545076386553)
#(-6.521003931182706 10.0 0.1178230920419217)
#(-6.514431925615438 10.0 0.1180084927017307)
#(-6.505237782335364 10.0 0.1182554027074824)
#(-6.498513444650254 10.0 0.1184266239748961)
#(-6.488983008492481 10.0 0.1186555956582973)
#(-6.48200268637703 10.0 0.1188128917257091)
#(-6.472326149681036 10.0 0.119016053562057)
#(-6.465389207391072 10.0 0.1191511200864016)
#(-6.455601236135456 10.0 0.1193262289159263)
#(-6.448443729690395 10.0 0.1194424780868816)
#(-6.438958198675441 10.0 0.1195804860871952)
#(-6.432273317606395 10.0 0.1196673012040853)
#(-6.422976238615972 10.0 0.1197731501514096)
#(-6.4159621089377605 10.0 0.1198409999468651)
#(-6.4067002169151355 10.0 0.1199142428159179)
#(-6.399997171744239 10.0 0.119956098103827)
#(-6.390775586474153 10.0 0.1199979664750528)
#(-6.383766014520722 10.0 0.1200169608096984)
#(-6.374398451275458 10.0 0.1200248790095977)
#(-6.367508232676765 10.0 0.1200180617465295)
#(-6.358204641636406 10.0 0.1199913666687163)
#(-6.351212499117087 10.0 0.1199579262946732)
#(-6.34179811653411 10.0 0.1198940830107079)
#(-6.334722008984675 10.0 0.1198318598583616)
#(-6.325243506895607 10.0 0.1197286664953724)
#(-6.3181038668924225 10.0 0.1196359024164523)
#(-6.3086233644061815 10.0 0.1194922029896446)
#(-6.301482992162023 10.0 0.1193683670372235)
#(-6.2919924776063425 10.0 0.1191825584163038)
#(-6.284793044978927 10.0 0.1190252258627906)
#(-6.2753314970647045 10.0 0.1187965753264672)
#(-6.26821135846841 10.0 0.1186078391724031)
#(-6.259162952769228 10.0 0.1183465300397597)
#(-6.252357920075809 10.0 0.1181346604145395)
#(-6.243732250120057 10.0 0.1178464349390531)
#(-6.237024615970206 10.0 0.117607149463944)
#(-6.22847504378218 10.0 0.1172819358381489)
#(-6.221661738722191 10.0 0.1170066698163893)
#(-6.212734929396275 10.0 0.1166237921552943)
#(-6.205560407960056 10.0 0.1162969301785835)
#(-6.196251975857688 10.0 0.1158468244886666)
#(-6.188964185271005 10.0 0.1154735323164374)
#(-6.179555494737541 10.0 0.1149639153426461)
#(-6.172229381962318 10.0 0.1145450494936365)
#(-6.162856146944508 10.0 0.113980051461802)
#(-6.155565515353094 10.0 0.1135177665315744)
#(-6.146209923750142 10.0 0.1128942970314755)
#(-6.138855137820279 10.0 0.112380030061237)
#(-6.129655628386858 10.0 0.1117056172410459)
#(-6.122486612998066 10.0 0.111156182233171)
#(-6.11363265472315 10.0 0.110447376638818)
#(-6.10657159410418 10.0 0.1098584591558712)
#(-6.097764739903218 10.0 0.1090932742430056)
#(-6.0906136679603495 10.0 0.1084460244904774)
#(-6.081792237411942 10.0 0.1076133101575569)
#(-6.074656622637572 10.0 0.106911620109585)
#(-6.065558573551578 10.0 0.1059791445416934)
#(-6.058094902257685 10.0 0.105180297224725)
#(-6.04902211746673 10.0 0.1041654080838163)
#(-6.041837834442202 10.0 0.1033285781165379)
#(-6.032806538284214 10.0 0.102232676388748)
#(-6.025326943718607 10.0 0.1012858590168515)
#(-6.016324551464302 10.0 0.1000962619743535)
#(-6.009099370537937 10.0 0.0991026392362128)
#(-6.000144802087108 10.0 0.0978213410260762)
#(-5.992672802847265 10.0 0.0967077356358815)
#(-5.983682684099936 10.0 0.095311303764513)
#(-5.976390894901862 10.0 0.0941327969909632)
#(-5.967597701948485 10.0 0.092651171023629)
#(-5.960300625393035 10.0 0.091369004729541)
#(-5.951819042895475 10.0 0.0898129037222759)
#(-5.944827122197059 10.0 0.0884764825079818)
#(-5.9364937900430546 10.0 0.086815333082949)
#(-5.929316123058646 10.0 0.0853215712223041)
#(-5.920853977349434 10.0 0.0834809963775036)
#(-5.913697488126982 10.0 0.081855290446912)
#(-5.905045875020715 10.0 0.0797946852900259)
#(-5.897633195865675 10.0 0.077937627548088)
#(-5.888869222952547 10.0 0.0756214894583634)
#(-5.881576422780188 10.0 0.0735895003825018)
#(-5.8730488606276685 10.0 0.071078664456186)
#(-5.865886603820401 10.0 0.0688505661471062)
#(-5.857659076163453 10.0 0.0661282191187038)
#(-5.8506956581380045 10.0 0.0636758008622684)
#(-5.8427993520796395 10.0 0.0607060179365281)
#(-5.836006841543422 10.0 0.0579805075953104)
#(-5.828141782273885 10.0 0.0545732138995477)
#(-5.821264105869612 10.0 0.0513305536611062)
#(-5.813396489418997 10.0 0.0472425696093425)
#(-5.806736741014998 10.0 0.0434068855227238)
#(-5.799296800365852 10.0 0.0385347465920627)
#(-5.793149838865298 10.0 0.0339017049050897)
#(-5.786639267262249 10.0 0.02799360148602)
#(-5.781555952133565 10.0 0.0222871988704581)
#(-5.77690049447455 10.0 0.0149171833984971)
#(-5.774143850809992 10.0 0.0076254582681704)
#(-5.773504871989952 10.0 0.0021812762824132)
#(-5.77350372489622 10.0 -5.432357e-10))
(1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0)
(0.0 0.0 0.0 0.0 0.0160453781542143 0.0241470160269717
0.0317935799490915 0.0398053040025856 0.0478086834801164
0.0560582201696031 0.0639202701209087 0.0718503545073776
0.0797433850046513 0.087981750276748 0.0960087041824917
0.1039831218391125 0.112029495827222 0.1201752268087684
0.1282605498138822 0.136005192477863 0.1438242190390603
0.1519870644337011 0.1593306835295498 0.1598487740853562
0.1674658650196929 0.1680104087509454 0.175157710986505
0.1757272662987668 0.1833705173786548 0.183966778279312
0.1915177150798282 0.1921404682290536 0.1993060375256694
0.1999541159685396 0.2074081735084615 0.2080825976726782
0.2151502427534925 0.2158498418097879 0.2234099696672682
0.2241364268834526 0.2312069092585329 0.2319587197887401
0.2390267110021689 0.239803949187276 0.2470314540979864
0.2478347213119199 0.2551668057971311 0.2559965267399797
0.2633214412146924 0.2641776785913368 0.2711080693997827
0.271989626560843 0.2788004837617649 0.2797070543520855
0.2865857660092436 0.2875176520073938 0.294691617040477
0.2956498608401993 0.3028107414290341 0.303795386191314
0.3108677223812281 0.3118785660342093 0.3186289517157898
0.3196650325637266 0.3267875123448071 0.3278501223901527
0.3348376542335923 0.3359264409310518 0.343017473844114
0.3441328588668275 0.3507020846059745 0.3518424576829762
0.3585158400916831 0.3596816211629636 0.366600003006972
0.3677920713565625 0.3748151183901361 0.3760338998362696
0.3829150808161275 0.3841602009158513 0.3906373023990221
0.3919075328521676 0.3983652317385465 0.3996605911050301
0.406480133489536 0.4078018800878236 0.4145992363495962
0.4159473838404371 0.4227235238201337 0.4240980890623294
0.4304686564547328 0.4318684065502333 0.4382164439562757
0.4396413875379139 0.4463489290384909 0.4478003170276637
0.4544823491094193 0.4559601845464303 0.4626166004905004
0.4641208860785213 0.470751784887656 0.4722825236605759
0.4785036764886068 0.4800596220929673 0.486633503837215
0.4882158852069559 0.4943709597308301 0.4959785009914117
0.502479159396033 0.5041130660952415 0.5105726294674962
0.512232853709101 0.5186483892971976 0.5203348734927932
0.5267087790327916 0.5284214732034318 0.5344904142923997
0.5362284120119565 0.5421342182310729 0.5438970713133418
0.5502033260482438 0.5519924174541494 0.5583120642198542
0.5601275228154484 0.5665206241752909 0.5683627745511391
0.5742736086012711 0.5761409693620999 0.5819524448520371
0.5838447748901722 0.5899961210140513 0.591914606679692
0.5981367389758905 0.6000816954947563 0.6062612328823314
0.6082326078238199 0.6139891743550618 0.6159856782493418
0.6217020223331746 0.623723606100719 0.6295913193586837
0.6316385567589856 0.6377653030384736 0.6398391197873293
0.6458190701143912 0.6479190753033844 0.6541566170946882
0.6562837334911363 0.6618008400206912 0.6639528131422728
0.6699223065860094 0.6721006882862063 0.6775449581602477
0.6797481264419983 0.6856437214610128 0.6878732244971574
0.6935814940177247 0.695836808314546 0.7016366241440788
0.7039181313132697 0.709705856689687 0.7120136025880942
0.7177645246694223 0.7200984749442396 0.7258142875643973
0.7281744132589539 0.7339554983783031 0.7363420968538624
0.7420859180388898 0.7444989542058508 0.7497996761741695
0.7522377951739535 0.7574084721926538 0.7598713327198711
0.7650117024519579 0.7674992864084252 0.7730174533892418
0.7755310696517345 0.7811075108508807 0.7836474335589837
0.7892724115280283 0.7918388840494792 0.7974138106069117
0.8000067565215466 0.8056169748708625 0.8082365950205777
0.8135658669535445 0.816211334521307 0.8213255105466555
0.8239962101530169 0.829242574214828 0.8319390177427586
0.8370829503324179 0.8398048884169548 0.8454152884202761
0.8481643207745085 0.8532523057058028 0.856026821694725
0.8614897782714848 0.8642910800558162 0.8693003110837616
0.8721270103832023 0.8774885682570619 0.8803418933181856
0.8854532218703798 0.8883324456013311 0.8934528695387036
0.8963581057296763 0.9010534532900417 0.9039834043046125
0.9089319065807004 0.9118874759674483 0.9167609857678787
0.9197420129769963 0.9249624084248843 0.9279701042058975
0.9330316439657489 0.9360655784857183 0.9410404196288085
0.9441003962903061 0.9488799412961575 0.9519654097358451
0.9565785237508843 0.9596890256766235 0.9645868244983244
0.9677233670213087 0.9726644785371455 0.9758272871735215
0.9807483303509975 0.9839374252540747 0.9887471809818733
0.9919622857532446 0.996778435740851 1.0 1.0 1.0 1.0)
3)))
:objects ((profile :type 'b-spline-curve
:control-points (first (the sample-b-spline-data))
:weights (second (the sample-b-spline-data))
:knot-vector (third (the sample-b-spline-data))
:degree (fourth (the sample-b-spline-data)))
(approximate :type 'approximated-curve
:display-controls (list :color :red)
:tolerance 0.01
:pinned-parameters (list 0.1 0.5 0.7 0.9)
:match-parameterization? t
:curve-in (the profile))))
(generate-sample-drawing :object-roots (make-object 'approximated-curve-test)
:projection-direction (getf *standard-views* :front)
:page-width 1000)
</pre>
"
)
:input-slots
("GDL Curve object. The curve to be approximated with this curve."
curve-in
("Number. The maximum distance deviation from the curve-in to this curve.
Defaults to 1.0e-5 times the diagonal of the bounding box of the input curve."
tolerance (* 1.0e-5 (apply #'3d-distance (the curve-in bounding-box))))
("List of numbers. These are parameter values from the original curve
where the approximated curve will be forced to be identical to the original
curve. Defaults to nil."
pinned-parameters nil)
("Boolean. Indicates whether the new-curve should contain matching parameterization between breakpoints. If nil, the
parameterization can slip a little, but not very much. Allowing the parameterization between breakpoints to slip
results in somewhat fewer control points. Use non-nil only if a parameter-to-parameter match is important to your application.
The default is nil." match-parameterization? nil))
:computed-slots
((results (make-approximated-curve
*geometry-kernel*
:curve (the curve-in native-curve-iw)
:tolerance (to-double-float (the tolerance))
:match-parameterization? (the match-parameterization?)
:pinned-parameters (sort
(mapcar #'to-double-float
(the pinned-parameters))
#'<)))
(native-curve-iw (first (the results)))
("Number. This should reflect the actual tolerance achieved with the approximation.
In the case of smlib, it is not clear exactly what this value is supposed to mean --
from examples we have seen so far, the value appears to range between 0.0 and 1.0, and
it appears that values close to 1.0 indicate a close approximation, and values
close to 0.0 indicate a loose approximation.. "
achieved-tolerance (second (the results)))))
| 21,169 | Common Lisp | .lisp | 410 | 47.314634 | 127 | 0.758842 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 6cbb077dbf9ba8fe7d5aae1cd6dd7ffbb03bf556fcad958abc7a2dc2feca56ed | 35,899 | [
-1
] |
35,900 | projected-curve.lisp | lisp-mirror_gendl/surf/source/projected-curve.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(define-object projected-curve (curve)
:documentation (:description "Creates a 3D curve which is the <tt>curve-in</tt>
projected onto the <tt>surface.</tt> according to the <tt>projection-vector</tt>.
The resulting curve contains a uv-curve which is typically useful for trimming.
NOTE: Change from 1577p027 and forward -- the projected curve now is a 3D curve which
can be drawn. It contains its uv representation on the surface. Previously, the uv-curve
was the actual projected-curve.
"
:examples "<pre>
(in-package :surf)
(define-object test-trimmed-from-projected-2 (trimmed-surface)
:computed-slots
((uv-inputs t)
(island (the island-3d uv-curve))
(holes (list (the hole uv-curve)))
(display-controls (list :color :blue :line-thickness 2)))
:objects
((basis-surface :type 'test-fitted-surface
:display-controls (list :color :pink)
:grid-length 10 :grid-width 10 :grid-height 5
)
(raised-hole :type 'b-spline-curve
:display-controls (list :color :grey-light-very)
:control-points (list (make-point 3.5 4.5 7)
(make-point 4.5 6 7)
(make-point 5.5 7 7)
(make-point 6 4.5 7)
(make-point 5.5 2 7)
(make-point 4.5 2 7)
(make-point 3.5 4.5 7)))
(raised-island :type 'b-spline-curve
:display-controls (list :color :grey-light-very)
:control-points (list (make-point 3 5 7)
(make-point 5 8 7)
(make-point 7 10 7)
(make-point 8 5 7)
(make-point 7 0 7)
(make-point 5 0 7)
(make-point 3 5 7))))
:hidden-objects
((island-3d :type 'projected-curve
:curve-in (the raised-island)
:surface (the basis-surface)
:projection-vector (make-vector 0 0 -1))
(hole :type 'projected-curve
:curve-in (the raised-hole)
:surface (the basis-surface)
:projection-vector (make-vector 0 0 -1))))
(generate-sample-drawing
:objects (let ((self (make-object 'test-trimmed-from-projected-2)))
(list (the basis-surface) self (the raised-island)
(the raised-hole)))
:projection-direction :trimetric)
</pre>")
:input-slots
("GDL NURBS Curve. The curve to be projected to the surface."
curve-in
"GDL NURBS Surface. The surface on which the <tt>curve-in</tt> is to be projected."
surface
"3D Vector. The direction of projection."
projection-vector
("Number or nil. The tolerance used when projecting and creating new curves.
Defaults to nil, which uses the default of the geometry kernel."
approximation-tolerance nil)
("Number or nil. The angle tolerance used when projecting and creating new curves.
Defaults to nil, which uses the default of the geometry kernel."
angle-tolerance-radians nil)
)
:computed-slots
(
(native-curves-uv (let ((projected-curves
(project-curve *geometry-kernel* (the curve-in)
(the surface) (the projection-vector)
(when (the approximation-tolerance)
(the approximation-tolerance))
(when (the angle-tolerance-radians)
(the angle-tolerance-radians)))))
(mapcar #'(lambda(curve)
(multiple-value-bind (control-points weights knots degree)
(get-b-spline-curve*-data *geometry-kernel* curve)
(make-b-spline-curve *geometry-kernel* control-points weights degree knots)))
projected-curves)))
(native-curve-uv (if (= (length (the native-curves-uv)) 1)
(first (the native-curves-uv))
(the composed native-curve)))
(built-from (the 3d-curve)))
:hidden-objects
(("GDL UV curve object. The resultant projected-curve in the UV space of the surface."
uv-curve :type 'curve
:native-curve (the native-curve-uv))
(3d-curve :type 'b-spline-curve
:knot-vector (the uv-curve knot-vector)
:weights (the uv-curve weights)
:degree (the uv-curve degree)
:control-points (mapcar #'(lambda(point)
(the surface (point (get-x point) (get-y point))))
(the uv-curve control-points))))
:hidden-objects ((result-curves :type 'curve
:sequence (:size (length (the native-curves-uv)))
:native-curve (nth (the-child index) (the native-curves-uv)))
(composed :type 'composed-curve
:curves (the result-curves))))
| 6,454 | Common Lisp | .lisp | 123 | 36.593496 | 115 | 0.554297 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 38bdbe76df4f57c449866307657156aeaa6e7eac4f08edcb1d829bc40c15bcb0 | 35,900 | [
-1
] |
35,901 | quicklisp.txt | lisp-mirror_gendl/licenses/open-source/quicklisp.txt | License information
Copyright © 2010 Zachary Beane <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Portions of Quicklisp are derived from Pierre Mai's Deflate library,
which is available under the following terms:
Deflate --- RFC 1951 Deflate Decompression
Copyright (C) 2000-2009 PMSF IT Consulting Pierre R. Mai.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the author shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the author.
| 2,615 | Common Lisp | .lisp | 41 | 60.634146 | 79 | 0.797814 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b4581b7264f861b3093d6d25823889b98611c7cd5a0dfc85c702670cda53b046 | 35,901 | [
-1
] |
35,902 | p009.lisp | lisp-mirror_gendl/patches/1588/p009.lisp | (in-package :gdl)
(defparameter *1588p009-doc*
"Makes web-drawing and tasty respect background and foreground in *colors-default*.")
(#+allegro
excl:without-package-locks #-allegro progn
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(defmethod lookup-color ((color null) &key (format :decimal) (ground :foreground))
(unless (and (eql ground :foreground)
(eql (getf *colors-default* :foreground) :black))
(values (lookup-color (getf *colors-default* ground) :format format) nil)))))
(in-package :geom-base)
(#+allegro
excl:without-package-locks #-allegro progn
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-lens (pdf base-object) ()
:amend? t
:output-functions
((rgb-stroke-setting
()
(let* ((display-controls (find-in-hash self *display-controls*))
(color (or (getf display-controls :color)
(the color-decimal)))
(color-decimal (if (consp color) color
(coerce (lookup-color (or color (format-slot foreground-color))) 'list)))
(fill-color-decimal (coerce (lookup-color (getf (the display-controls) :fill-color)) 'list)))
(apply #'pdf:set-rgb-stroke color-decimal)
(apply #'pdf:set-rgb-fill (or fill-color-decimal color-decimal))))))
(define-object-amendment base-object ()
:computed-slots
((color-decimal (lookup-color (getf (the display-controls) :color)))))))
(in-package :raphael)
(#+allegro
excl:without-package-locks #-allegro progn
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-lens (raphael base-drawing) ()
:amend? t
:output-functions
((raphael-paper-def
(&key width length)
(format *stream* "var paper = Raphael('~a', ~a, ~a);
paper.canvas.style.backgroundColor = '~a';
if (typeof start === 'undefined') {
var start = function () {
this.lastdx ? this.odx += this.lastdx : this.odx = 0;
this.lastdy ? this.ody += this.lastdy : this.ody = 0;
this.animate({opacity: .5}, 500, \">\");
},
move_cb = function (dx, dy) {
this.transform(\"T\"+(dx+this.odx)+\",\"+(dy+this.ody));
this.lastdx = dx;
this.lastdy = dy;
this.animate({opacity: .5}, 500, \">\");
~a
},
move = function (dx, dy) {
this.transform(\"T\"+(dx+this.odx)+\",\"+(dy+this.ody));
this.lastdx = dx;
this.lastdy = dy;
this.animate({opacity: .5}, 500, \">\");
},
up = function () {
this.animate({opacity: 1.0}, 500, \">\");
~a
},
touchcoords = function () {~a}};
"
(the raphael-canvas-id) width length
(lookup-color (format-slot background-color) :format :hex)
;;
;; FLAG -- pass in the containing
;; base-ajax-graphics-sheet and refer
;; to that, instead of referring to
;; the parent here.
;;
(the parent (gdl-sjax-call :null-event? t :js-vals? t :function-key :on-drag))
(the parent (gdl-sjax-call :null-event? t :js-vals? t :function-key :on-drop))
(the parent (gdl-sjax-call :null-event? t :js-vals? t :function-key :on-touchmove))))))))
| 3,484 | Common Lisp | .lisp | 83 | 32.385542 | 99 | 0.57079 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | b6549cd223f450c0f945dc7447b757acec773ed120dcf06dec401399766e0285 | 35,902 | [
-1
] |
35,903 | p013.lisp | lisp-mirror_gendl/patches/1588/p013.lisp | (in-package :gdl)
(defparameter *1588p013-doc*
"Try to avoid resetting to defaults from query-plist.
")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("Void. Uncaches all cached data in slots and objects throughout the instance
tree from this node, forcing all code to run again the next time values are
demanded. This is useful for updating an existing model or part of an existing
model after making changes and recompiling/reloading the code of the underlying
definitions. Any set (modified) slot values will, however, be preserved
by the update."
update!
(&key (replace-bashed-values? t) immune-message-keys)
(let ((all-messages (the (:message-list)))
(methods (the (:message-list :category :functions)))
(immune-messages (append (list :$$ta2 :$$ta2-object
:$$tatu :$$tatu-object)
(ensure-list immune-message-keys)))
(true-root (if (and (the root parent) (the root parent root?)
(defaulting (the root parent root-object-object))
(eql (the root parent root-object-object) self))
(the root parent) (the root))))
(let ((cached-messages
(set-difference all-messages (append methods immune-messages))))
(dolist (key cached-messages)
(let ((key (glisp:intern (symbol-name key) :gdl-acc)))
(unbind-dependent-slots self key :updating? t))))
(let* ( ;;(root-path (remove :root-object-object (the root-path)))
(root-path (the root-path))
(root-path-length (length root-path))
(version-tree
(when replace-bashed-values?
(remove-if-not #'(lambda(node)
(let ((local-root-path (first node)))
(and (> (length local-root-path) root-path-length)
(equalp (subseq local-root-path
(- (length local-root-path)
root-path-length))
root-path))))
(gdl-acc::%version-tree% true-root)))))
(when *debug?* (print-variables version-tree))
(dolist (version-node version-tree (values))
(let ((root true-root)
(root-path (first version-node)) (value-plist (rest version-node)))
(mapc #'(lambda(key value)
(when (not (eql value 'gdl-acc::%default%))
;;
;; FLAG - make this into a more specific error check for
;; nonexistence of the object (e.g. not handled error).
;;
(with-error-handling (:timeout nil)
(the-object root (:follow-root-path root-path)
(:set-slot! key value :re-sort? nil)))))
(plist-keys value-plist) (plist-values value-plist)))))))
("NIL. Forcibly sets the value of the given slot to the given value. The slot must be defined
as <tt>:settable</tt> for this to work properly. Any dependent slots in the tree will
respond accordingly when they are next demanded. Note that the slot must be specified as a keyword
symbol (i.e. prepended with a colon (``:'')), otherwise it will be evaluated as a variable according
to normal Lisp functional evaluation rules.
<p>
Note also that this must not be called (either directly or indirectly)
from within the body of a Gendl computed-slot. The caching and
dependency tracking mechanism in Gendl will not work properly if this
is called from the body of a computed-slot, and furthermore a runtime
error will be generated.
</p>
:arguments (slot \"Keyword Symbol\"
value \"Lisp Object. (e.g. Number, String, List, etc.)\")
:&key ((remember? t) \"Boolean. Determines whether to save in current version-tree.\"
(warn-on-non-toplevel? t) \"Boolean. Determines whether to warn if this is called from the body of a cached slot.\" )"
set-slot!
(attribute value &key (remember? t) (warn-on-non-toplevel? t) (override-non-settable? *override-non-settables?*)
(re-sort? t) (keys-to-ignore (list :%primary?%)) (keys-to-forget (list :query-plist :cookies-received :view-toggle)))
(when (member attribute keys-to-forget) (setq remember? nil))
(unless (member attribute keys-to-ignore)
(unless (or (gethash attribute (the %settable-slots%))
(member attribute (the (message-list :category :required-input-slots))))
(let ((message (format nil "The slot ~s is not settable in ~a of type ~a."
attribute
(cons 'the (reverse (the root-path)))
(the type))))
(if override-non-settable?
(warn (format nil "~a Setting it anyway...
To get a continuable error instead, use :override-non-settable? t or
globally (setq *override-non-settables?* t).
Note that this behavior may change to error by default in a future GDL release.
"
message))
(cerror "Set the slot anyway." message))))
(when (and warn-on-non-toplevel?
*notify-cons*)
(warn "It is not recommended to call set-slot! from within dependency-tracking context, e.g. from the body of a computed-slot.
THIS CAN LEAD TO INCONSISTENT DEPENDENCY-TRACKING!!!
Set-slot was called on
~s
with value
~s
from
~s.~%"
(cons 'the (append (reverse (the root-path))
(list (make-keyword attribute))))
value
(cons 'the (append (reverse (the-object (first *notify-cons*) root-path))
(list (make-keyword (second *notify-cons*)))))))
(progn ;; bt:with-lock-held (*binding-lock*) FLAG - bring in later in bootstrapping.
(unless (eql attribute :%primary?%)
(when (not *run-with-dependency-tracking?*)
(error "Dependency Tracking must be enabled in order to forcibly
set slot values.
Please setq the variable `*run-with-dependency-tracking?*' to T,
make a fresh root-level object, and start again."))
(let (*leaf-resets*)
(let ((slot (glisp:intern (symbol-name attribute) :gdl-acc)))
(unbind-dependent-slots self slot)
(setf (slot-value self slot)
(list value nil t)))
(when remember?
(let ((root (let ((maybe-root (the :root)))
(if (the-object maybe-root root?)
maybe-root
(the-object maybe-root parent))))
(root-path (the root-path)
;;(remove :root-object-object (the root-path))
;;(the root-path)
))
(cond ((and (gdl-acc::%version-tree% root)
(not (find root-path (gdl-acc::%version-tree% root)
:test #'equalp :key #'first)))
(nconc (gdl-acc::%version-tree% root)
(list (list root-path))))
((null (gdl-acc::%version-tree% root))
(setf (gdl-acc::%version-tree% root)
(list (list root-path)))))
(when (the primary?)
(setf (getf (rest (assoc root-path (gdl-acc::%version-tree% root) :test #'equalp)) :%primary?%)
t))
(when re-sort?
(setf (gdl-acc::%version-tree% root)
(sort (gdl-acc::%version-tree% root)
#'(lambda(item1 item2)
(< (length (first item1)) (length (first item2))))))
(let ((non-root (remove nil (gdl-acc::%version-tree% root) :key #'first))
(root-list (find nil (gdl-acc::%version-tree% root) :key #'first)))
(let ((primaries (remove-if-not #'(lambda(item)
(or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list)))
non-root))
(non-primaries (remove-if #'(lambda(item)
(or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list)))
non-root)))
(setf (gdl-acc::%version-tree% root)
(cons (or root-list (list nil))
(append primaries non-primaries))))))
(setf (getf (rest (assoc root-path (gdl-acc::%version-tree% root) :test #'equalp)) attribute)
value)))
(when *eager-setting-enabled?*
(dolist (reset *leaf-resets*)
(the-object (first reset) (evaluate (second reset)))))))))))))
(defun read-snapshot (&key (filename "/tmp/snap.gdl") object keep-bashed-values? make-object-args
keys-to-ignore
(keys-to-ignore-default (list :query-plist :view-toggle :cookies-received)))
"GDL Instance. Reads the snapshot file indicated by filename. If no optional keyword <tt>object</tt>
argument is given, a new GDL instance based on the data in the snapshot file is returned. If an
<tt>object</tt> is given, the object should be compatible in type to that specified in the
snapshot file, and this existing object will be modified to contain the set slot values and
toplevel inputs as specified in the snapshot file.
:&key ((filename \"/tmp/snap.gdl\") \"String or pathname. File to be read.\"
(keep-bashed-values? nil) \"Boolean. Indicates whether to keep the currently bashed values in object before reading snap values into it.\"
(object nil) \"GDL object. Existing object to be modified with restored values.\")"
(let ((keys-to-ignore (append keys-to-ignore keys-to-ignore-default)))
(with-open-file (in filename)
(let ((package-form (read in)))
(when (or (null package-form) (not (find-package (second package-form))))
(error "Invalid package specification at beginning of ~a.~%" filename))
(let* ((*package* (find-package (second package-form))) (root-form (read in)))
(when (or (null root-form)
(not (eql (class-of (find-class (first root-form))) (find-class 'gdl-class))))
(error "Invalid object type specifier as first element of second form in ~a.~%" root-form))
(let ((object (cond ((and object keep-bashed-values?) object)
(object (the-object object restore-tree!) object)
(t (progn
(apply #'make-object (first root-form) make-object-args))))))
(let ((self object) (value-plist (rest root-form)))
(mapc #'(lambda(key expression)
(unless (member key keys-to-ignore)
(when self (the-object self (set-slot! key (eval expression) :re-sort? nil)))))
(plist-keys value-plist) (plist-values value-plist)))
(let (forms)
(do ((form (read in nil nil) (read in nil nil)))
((null form) forms)
(push form forms))
(setq forms (nreverse forms))
(let* ((forms (sort forms #'(lambda(item1 item2) (< (length item1) (length item2)))))
(primaries (remove-if-not #'(lambda(item) (or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list))) forms))
(non-primaries (remove-if #'(lambda(item) (or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list))) forms))
(forms (append primaries non-primaries)))
(dolist (form forms)
(let ((root-path (first form)) (value-plist (rest form)))
(let ((self
(with-error-handling (:timeout nil)
(the-object object (follow-root-path root-path)))))
(when self
(mapc #'(lambda(key expression)
(unless (member key keys-to-ignore)
(the-object self (set-slot! key (eval `(let ((self ,self)) ,expression)) :re-sort? nil))))
(plist-keys value-plist) (plist-values value-plist))))))))
object))))))
| 11,185 | Common Lisp | .lisp | 214 | 44.242991 | 146 | 0.645068 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 455fdc1ac73be5d157ccac94a247b67c84be3bc71b353bfa8ebf3abbb2d7c320 | 35,903 | [
-1
] |
35,904 | p005.lisp | lisp-mirror_gendl/patches/1588/p005.lisp | (in-package :surf)
(defparameter *1588p005-doc*
" Fix the order of the returned u,v point for the point function of uv-iso-curve.")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object uv-iso-curve ()
:documentation (:description "Convenience object to return UV parameter values on surface.")
:input-slots (surface parameter u-or-v)
:functions
(("2D point. The UV surface representation at the given parameter value.
:arguments (parameter \"Number. The parameter value you want.\")"
point
(parameter)
(ecase (the u-or-v)
(:v (make-point (the parameter) parameter))
(:u (make-point parameter (the parameter))))))))
| 701 | Common Lisp | .lisp | 17 | 36.588235 | 95 | 0.713004 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 973ac04739ce9134215f7e3d4f4c031c4d8c1254b742222f1421bafed178d5a0 | 35,904 | [
-1
] |
35,905 | p003.lisp | lisp-mirror_gendl/patches/1588/p003.lisp | (in-package :gdl)
(defparameter *1588p003-doc*
"Fix restore-slot-default to blank out version information at the true root
in the case that we are a root-object-object child of true parent.")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("NIL. Restores the value of the given slot to its default, thus ``undoing'' any forcibly set value
in the slot. Any dependent slots in the tree will respond accordingly when they are next demanded.
Note that the slot must be specified as a keyword symbol (i.e. prepended with a colon (``:'')),
otherwise it will be evaluated as a variable according to normal Lisp functional evaluation rules.
:arguments (slot \"Keyword Symbol\")
:key (force? \"Boolean. Specify as t if you want to force non-settable slots to recompute (e.g.
reading from databases or external files). Defaults to nil.\")"
restore-slot-default!
(attribute &key (force? *force-restore-slot-default?*))
(when (or force? (eql (the (slot-status attribute)) :set))
(let (*leaf-resets*)
(let ((slot (glisp:intern (symbol-name attribute) :gdl-acc)))
(unless (eq (first (ensure-list (slot-value self slot))) 'gdl-rule::%unbound%)
(unbind-dependent-slots self slot)
(setf (slot-value self slot)
(if *remember-previous-slot-values?*
(list 'gdl-rule::%unbound% nil nil (first (slot-value self slot)))
'gdl-rule::%unbound%))))
(let ((root (let ((maybe-root (the :root)))
(if (the-object maybe-root root?)
maybe-root
(the-object maybe-root parent))))
;;(root-path (remove :root-object-object (the root-path)))
(root-path (the root-path))
)
;;
;; FLAG -- this pushnew should never be necessary...
;;
(pushnew (list root-path)
(gdl-acc::%version-tree% root) :test #'equalp :key #'(lambda(item) (list (first item))))
(setf (rest (assoc root-path (gdl-acc::%version-tree% root) :test #'equalp))
(remove-plist-key (rest (assoc root-path
(gdl-acc::%version-tree% root) :test #'equalp)) attribute)))
(when *eager-setting-enabled?*
(dolist (reset *leaf-resets*)
(the-object (first reset) (evaluate (second reset)))))))))))
(format t "~&~%Changes in 1588p003:~%~%~a~%~%" *1588p003-doc*)
| 2,364 | Common Lisp | .lisp | 46 | 45.586957 | 103 | 0.671491 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a79b4148a3e9e0701861cd8fd006439ee445e7e49851c57dd52e96fdcae600f6 | 35,905 | [
-1
] |
35,906 | p001.lisp | lisp-mirror_gendl/patches/1588/p001.lisp | (in-package :gwl)
(defparameter *1588p001-doc*
"Makes the respondent default to the bashee for base-html-sheet, same as for base-ajax-sheet.")
(define-object-amendment base-html-sheet ()
:input-slots
((respondent (the bashee))))
(format t "~&~%Changes in 1588p001:~%~%~a~%~%" *1588p001-doc*)
| 304 | Common Lisp | .lisp | 7 | 40.714286 | 97 | 0.709898 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 23c76dc7cf1079ea1edee1bf19b9a6b44c1b74420aec4d6be8f2a3d7fe96473d | 35,906 | [
-1
] |
35,907 | p015.lisp | lisp-mirror_gendl/patches/1588/p015.lisp | ;;
;; Copyright 2015 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl)
(defparameter *1588p015-doc*
"Adds overridable initialize-instance! function to vanilla-mixin and calls this from make-object and make-object-internal.")
(defun make-object (object-type &rest args)
"GDL Object. Instantiates an object with specified initial values for input-slots.
:arguments (object-name \"Symbol. Should name a GDL object type.\"
arguments \"spliced-in plist. A plist of keyword symbols and values for initial <tt>input-slots</tt>.\")"
(let (*notify-cons*
(keys (plist-keys args))
(vals (plist-values args)))
(let ((object (apply #'make-instance
object-type
:allow-other-keys t
(append (list :%name% (list (format nil "~a" object-type) nil t)
:%parent% (list nil nil t))
(mapcan #'(lambda(key val)
(list key (list val nil t)))
keys vals)))))
(setf (gdl-acc::%root% object) object
(gdl-acc::%toplevel-inputs% object) args)
(the-object object initialize-instance!) object)))
(defun make-object-internal (object-type &rest args)
(let ((object (apply #'make-instance object-type :allow-other-keys t args)))
(the-object object initialize-instance!) object))
(define-object-amendment vanilla-mixin ()
:functions ((initialize-instance! ())))
(in-package :gdl-user)
(define-object make-object-regression& ()
:functions
((initialize-instance! ()
(format *standard-output* "Hey Now to *standard-out*.~%")
(format t "Hey Now to t.~%"))))
(define-object make-object-regression ()
:computed-slots ((regression-test-data (with-output-to-string (*standard-output*)
(make-object 'make-object-regression&)))
(seed-data "Hey Now to *standard-out*.
Hey Now to t.
" )
(pass? (equalp (the seed-data) (the regression-test-data)))))
(defun make-object-test () (the-object (make-object 'make-object-regression) pass?))
| 2,945 | Common Lisp | .lisp | 60 | 41.7 | 126 | 0.658931 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a55c0733576af530b8d8cdec079257a1fbd45e786ded798f9e93d5f963eb1940 | 35,907 | [
-1
] |
35,908 | p017.lisp | lisp-mirror_gendl/patches/1588/p017.lisp | ;;
;; Copyright 2002-2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl)
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(#+allegro
excl:without-package-locks
#-allegro progn
(defparameter *invalid-aggregate-behavior* :error
"Keyword symbol. Can be one of :error, :warn, or :ignore")
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '*invalid-aggregate-behavior* :gdl))
(defun add-notify-cons (notify-cons value &optional self message)
;;
;; FLAG -- this was added as a fix for github Issue #69, but causes
;; a regression by polluting the dependency graph with normal objects
;; which may then become unbound spuriously. Retracted until a more
;; benign fix for Issue #69 can be determined.
;;
;;(declare (ignore self message))
;;
;; FLAG -- we put back the extra tracking of notify-cons but only if
;; the message does not name a GDL object -- we don't want those
;; being the target of dependencies or they can be orphaned.
;;
(when (and self message)
(let ((aggregate (gdl-acc::%aggregate% (first notify-cons))))
(when (and (consp aggregate)
(not (consp (gdl-acc::%aggregate% self))))
(let ((agg (first aggregate)))
(if agg
(let ((num-value (gdl-acc::number-of-elements agg)))
(when (and (consp num-value)
(let ((value (funcall message self)))
(not
(and (consp value)
(typep (first value) 'gdl-basis)))))
(add-notify-cons (list self message) num-value)))
(let ((error-message (format nil "
!!!
Invalid internal Gendl data structure detected.
notify-cons = ~s
aggregate = ~a
value = ~s
self = ~a
message = ~s
!!!
"
notify-cons aggregate value self message)))
(ecase *invalid-aggregate-behavior*
(:error (error error-message))
(:warn (warn error-message))
(:ignore nil))))))))
(let ((second (second value)))
(if (and (listp second) (< (length second) *dep-hash-threshhold*))
(let ((matching-sublist (assoc (first notify-cons) (second value))))
(if matching-sublist (pushnew (second notify-cons) (rest matching-sublist))
(push (copy-list notify-cons) (second value))))
(progn
(when (listp second) (setf (second value) (alist-to-hash second)))
(pushnew (second notify-cons) (gethash (first notify-cons) (second value)))))))))
| 3,181 | Common Lisp | .lisp | 80 | 35.7 | 86 | 0.688535 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 19cc29d41125e80fdd46080446c26d727d0c318fc20f232334229e185c886048 | 35,908 | [
-1
] |
35,909 | p010.lisp | lisp-mirror_gendl/patches/1588/p010.lisp | (in-package :gdl)
(defparameter *1588p010-doc*
" Correct snap output for objects not made with root-object-object.")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("Void. Writes a file containing the toplevel inputs and modified settable-slots starting from the root of the
current instance. Typically this file can be read back into the system using the <tt>read-snapshot</tt> function.
:&key ((filename \"/tmp/snap.gdl\") \"String or pathname. The target file to be written.\"
(root-paths-to-ignore nil) \"List of root-paths or nil. Any objects with matching root-path will be ignored for the snapshot write.\"
)"
write-snapshot
(&key (filename "/tmp/snap.gdl") (root-paths-to-ignore nil))
(let (*print-level*
(root-object-object? (and (the parent) (the parent root?)
(defaulting (the parent root-object-object))
(eql (the parent root-object-object) self))))
(let ((root (if root-object-object? (the root parent) (the root))))
(setf (gdl-acc::%version-tree% root)
(sort (gdl-acc::%version-tree% root)
#'(lambda(item1 item2)
(< (length (first item1)) (length (first item2))))))
(with-open-file (out filename :direction :output :if-exists :supersede :if-does-not-exist :create)
(print `(in-package ,(make-keyword (package-name *package*))) out)
(mapcar #'(lambda(node)
(let ((root-path (first node)) (value-plist (rest node)))
(unless (or (member root-path root-paths-to-ignore :test #'equalp)
(and root-object-object?
(not (eql (lastcar root-path) :root-object-object))))
(when (or (and root-object-object? (null (rest root-path)))
(and (not root-object-object?) (null root-path)))
(setq root-path (the type)))
(when (and root-object-object? (consp (rest root-path)))
(setq root-path (butlast root-path)))
#+nil
(setq root-path (if (consp (rest root-path))
(if root-object-object? (butlast root-path) root-path)
(the type)))
(let ((keys (plist-keys value-plist)) (values (plist-values value-plist)))
(let ((snap (cons root-path
(append (when (atom root-path)
(let (result)
(let* ((toplevel-inputs
(remove-plist-key (the root active-inputs)
:remote-id))
(toplevel-input-keys (plist-keys toplevel-inputs))
(toplevel-input-values (plist-values toplevel-inputs)))
(mapc #'(lambda(key value)
(when (not (member key keys))
(push key result) (push value result)))
toplevel-input-keys toplevel-input-values))
(nreverse result)))
(mapcan #'(lambda(key val)
(let ((expression (readable-expression val self)))
(unless (eql expression :%unreadable%)
(list key expression))))
keys values))))) (print snap out))))))
(or (gdl-acc::%version-tree% root) (list nil))))))
filename))))
| 3,094 | Common Lisp | .lisp | 61 | 42.245902 | 140 | 0.627034 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 40ec2dc17063d81c874c4f9040e57026bdbe52815fa41008c9b1accda74a6f59 | 35,909 | [
-1
] |
35,910 | p011.lisp | lisp-mirror_gendl/patches/1588/p011.lisp |
;;
;; Copyright 2002-2015 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :geom-base)
(defparameter *1588p011-doc*
" Remove debug statements for x3d outpu9t")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-lens (x3d base-object) ()
:amend? t
:output-functions
((material-properties
()
(let* ((display-controls (find-in-hash self *display-controls*))
(color (getf display-controls :color))
(color (or color (getf (the display-controls) :color) :black)))
(cl-who:with-html-output (*stream* nil :indent nil)
(:|Material| :|diffuseColor| (write-the (rgb-color color))
:|ambientIntensity| (getf (the display-controls) :ambient-intensity)
:|emissiveColor| (write-the (rgb-color (getf (the display-controls) :emissive-color)))
:|shininess| (getf (the display-controls) :shininess)
:|specularColor| (write-the (rgb-color (getf (the display-controls) :specular-color)))
:|transparency| (getf (the display-controls) :transparency)
)))))))
| 1,814 | Common Lisp | .lisp | 42 | 40.119048 | 89 | 0.726394 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | acea47178fef77d6868ae4f7ed41105faa020363f361ca32d5832fbc4cb0af75 | 35,910 | [
-1
] |
35,911 | p014.lisp | lisp-mirror_gendl/patches/1588/p014.lisp | (in-package :com.genworks.lisp)
;;
;; temporary-folder is potentially platform-specific so it is defined here.
;;
(#+allegro
excl:without-package-locks
#-allegro progn
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(defparameter glisp::*temporary-folder* (user-homedir-pathname))
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'glisp::*temporary-folder* :glisp))
(defun temporary-folder (&key (create? t))
(let ((folder (merge-pathnames "tmp/" glisp::*temporary-folder*)))
(when create? (ensure-directories-exist folder))))))
| 604 | Common Lisp | .lisp | 15 | 36.133333 | 101 | 0.709402 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e7acddf4ebbd8f8c0ab35acd164f31b0311425bdfcdf034c820865d62ebee083 | 35,911 | [
-1
] |
35,912 | p004.lisp | lisp-mirror_gendl/patches/1588/p004.lisp | (in-package :gdl)
(defparameter *1588p004-doc*
"1. Fix restore-tree to restore to true root, and protect root-object-object
(the object of tasty or ta2) from being blown away and replaced with new object.
2. Make write-snapshot remove the root-object-object from root-paths if called on
root-object-object below toplevel parent.
3. Update the update! method to retrieve the version information from
the true root, in the case we are working on a root-object-object
below the toplevel parent.
")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("Void. Restores all settable-slots in this instance, and
recursively in all descendant instances, to their default values."
restore-tree!
(&key (quick? t)
(keep-function #'always)
(prune-function #'never)
(child-function (lambda(node) (the-object node safe-children))))
(let ((node (if (and (the parent) (the parent root?)
(defaulting (the parent root-object-object))
(eql (the parent root-object-object) self))
(the parent) self)))
(if quick?
(progn
(setf (gdl-acc::%version-tree% node) nil)
(the-object node (update! :immune-message-keys (list :root-object-object
:root-object-type)))
(unless (eql self node) (the-object node root-object-object update!)))
(maptree self
(lambda(node) (when (typep node 'gdl::gdl-basis) (the-object node restore-node!)))
keep-function
prune-function
child-function))))
("Void. Writes a file containing the toplevel inputs and modified settable-slots starting from the root of the
current instance. Typically this file can be read back into the system using the <tt>read-snapshot</tt> function.
:&key ((filename \"/tmp/snap.gdl\") \"String or pathname. The target file to be written.\"
(root-paths-to-ignore nil) \"List of root-paths or nil. Any objects with matching root-path will be ignored for the snapshot write.\"
)"
write-snapshot
(&key (filename "/tmp/snap.gdl") (root-paths-to-ignore nil))
(let (*print-level*
(root-object-object? (and (the parent) (the parent root?)
(defaulting (the parent root-object-object))
(eql (the parent root-object-object) self))))
(with-open-file (out filename :direction :output :if-exists :supersede :if-does-not-exist :create)
(print `(in-package ,(make-keyword (package-name *package*))) out)
(mapcar #'(lambda(node)
(let ((root-path (first node)) (value-plist (rest node)))
(unless (or (member root-path root-paths-to-ignore :test #'equalp)
(and root-object-object?
(not (eql (lastcar root-path) :root-object-object))))
(when root-object-object?
(setq root-path (if (consp (rest root-path))
(butlast root-path)
(the type))))
(let ((keys (plist-keys value-plist)) (values (plist-values value-plist)))
(let ((snap (cons root-path
(append (when (atom root-path)
(let (result)
(let* ((toplevel-inputs
(remove-plist-key (the root active-inputs)
:remote-id))
(toplevel-input-keys (plist-keys toplevel-inputs))
(toplevel-input-values (plist-values toplevel-inputs)))
(mapc #'(lambda(key value)
(when (not (member key keys))
(push key result) (push value result)))
toplevel-input-keys toplevel-input-values))
(nreverse result)))
(mapcan #'(lambda(key val)
(let ((expression (readable-expression val self)))
(unless (eql expression :%unreadable%)
(list key expression))))
keys values))))) (print snap out))))))
(or (gdl-acc::%version-tree% (if root-object-object? (the root parent) (the root)))
(list nil)))))
filename)
("Void. Uncaches all cached data in slots and objects throughout the instance
tree from this node, forcing all code to run again the next time values are
demanded. This is useful for updating an existing model or part of an existing
model after making changes and recompiling/reloading the code of the underlying
definitions. Any set (modified) slot values will, however, be preserved
by the update."
update!
(&key (replace-bashed-values? t) immune-message-keys)
(let ((all-messages (the (:message-list)))
(methods (the (:message-list :category :functions)))
(immune-messages (append (list :$$ta2 :$$ta2-object
:$$tatu :$$tatu-object)
(ensure-list immune-message-keys)))
(true-root (if (and (the root parent) (the root parent root?)
(defaulting (the root parent root-object-object))
(eql (the root parent root-object-object) self))
(the root parent) (the root))))
(let ((cached-messages
(set-difference all-messages (append methods immune-messages))))
(dolist (key cached-messages)
(let ((key (glisp:intern (symbol-name key) :gdl-acc)))
(unbind-dependent-slots self key :updating? t))))
(let* ( ;;(root-path (remove :root-object-object (the root-path)))
(root-path (the root-path))
(root-path-length (length root-path))
(version-tree
(when replace-bashed-values?
(remove-if-not #'(lambda(node)
(let ((local-root-path (first node)))
(and (> (length local-root-path) root-path-length)
(equalp (subseq local-root-path
(- (length local-root-path)
root-path-length))
root-path))))
(gdl-acc::%version-tree% true-root)))))
(when *debug?* (print-variables version-tree))
(dolist (version-node version-tree (values))
(let ((root true-root)
(root-path (first version-node)) (value-plist (rest version-node)))
(mapc #'(lambda(key value)
(when (not (eql value 'gdl-acc::%default%))
;;
;; FLAG - make this into a more specific error check for
;; nonexistence of the object (e.g. not handled error).
;;
(with-error-handling (:timeout nil)
(the-object root (:follow-root-path root-path)
(:set-slot! key value)))))
(plist-keys value-plist) (plist-values value-plist))))))))))
(format t "~&~%Changes in 1588p004:~%~%~a~%~%" *1588p004-doc*)
| 6,343 | Common Lisp | .lisp | 131 | 41.221374 | 140 | 0.652386 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 8d0a19a66769d492f1cb9beeadd03de329a8107ff927865df57bccae079bb9ea | 35,912 | [
-1
] |
35,913 | p008.lisp | lisp-mirror_gendl/patches/1588/p008.lisp |
;;
;; Copyright 2002-2015 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gwl)
;;
;; goes into gendl/gwl/ajax/source/ajax.lisp to replace the simple publish
;; of gdlAjax.
;;
(defun publish-gdlajax ()
(with-all-servers (server)
(publish :path "/gdlAjax" :function 'gdlAjax :server server)))
(publish-gdlajax)
| 1,139 | Common Lisp | .lisp | 29 | 36.37931 | 76 | 0.732664 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a8d65ea9a6380ef142aec28ce0da77f97ff7c10311b556ff62dfa6063b3e910e | 35,913 | [
-1
] |
35,914 | p016.lisp | lisp-mirror_gendl/patches/1588/p016.lisp | (in-package :gdl)
(defparameter *1588p016-doc*
"Improve sort ordering for input forms from snap files
and stored in version-tree root data structure")
(defun double-length-sort (&optional (list test-list))
(let ((first (safe-sort list #'(lambda(item1 item2)
(let ((first1 (first (first item1)))
(first2 (first (first item2))))
(< (if (consp first1) (length first1) 0)
(if (consp first2) (length first2) 0)))))))
(stable-sort first #'(lambda(x y) (< (length (first x)) (length (first y)))))))
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("Void. Uncaches all cached data in slots and objects throughout the instance
tree from this node, forcing all code to run again the next time values are
demanded. This is useful for updating an existing model or part of an existing
model after making changes and recompiling/reloading the code of the underlying
definitions. Any set (modified) slot values will, however, be preserved
by the update."
update!
(&key (replace-bashed-values? t) immune-message-keys)
(let ((all-messages (the (:message-list)))
(methods (the (:message-list :category :functions)))
(immune-messages (append (list :$$ta2 :$$ta2-object
:$$tatu :$$tatu-object)
(ensure-list immune-message-keys)))
(true-root (if (and (the root parent) (the root parent root?)
(defaulting (the root parent root-object-object))
(eql (the root parent root-object-object) self))
(the root parent) (the root))))
(let ((cached-messages
(set-difference all-messages (append methods immune-messages))))
(dolist (key cached-messages)
(let ((key (glisp:intern (symbol-name key) :gdl-acc)))
(unbind-dependent-slots self key :updating? t))))
(let* ( ;;(root-path (remove :root-object-object (the root-path)))
(root-path (the root-path))
(root-path-length (length root-path))
(version-tree
(when replace-bashed-values?
(remove-if-not #'(lambda(node)
(let ((local-root-path (first node)))
(and (> (length local-root-path) root-path-length)
(equalp (subseq local-root-path
(- (length local-root-path)
root-path-length))
root-path))))
(gdl-acc::%version-tree% true-root)))))
(dolist (version-node version-tree (values))
(let ((root true-root)
(root-path (first version-node)) (value-plist (rest version-node)))
(mapc #'(lambda(key value)
(when (not (eql value 'gdl-acc::%default%))
;;
;; FLAG - make this into a more specific error check for
;; nonexistence of the object (e.g. not handled error).
;;
(with-error-handling (:timeout nil)
(the-object root (:follow-root-path root-path)
(:set-slot! key value :re-sort? nil)))))
(plist-keys value-plist) (plist-values value-plist)))))))
("NIL. Forcibly sets the value of the given slot to the given value. The slot must be defined
as <tt>:settable</tt> for this to work properly. Any dependent slots in the tree will
respond accordingly when they are next demanded. Note that the slot must be specified as a keyword
symbol (i.e. prepended with a colon (``:'')), otherwise it will be evaluated as a variable according
to normal Lisp functional evaluation rules.
<p>
Note also that this must not be called (either directly or indirectly)
from within the body of a Gendl computed-slot. The caching and
dependency tracking mechanism in Gendl will not work properly if this
is called from the body of a computed-slot, and furthermore a runtime
error will be generated.
</p>
:arguments (slot \"Keyword Symbol\"
value \"Lisp Object. (e.g. Number, String, List, etc.)\")
:&key ((remember? t) \"Boolean. Determines whether to save in current version-tree.\"
(warn-on-non-toplevel? t) \"Boolean. Determines whether to warn if this is called from the body of a cached slot.\" )"
set-slot!
(attribute value &key (remember? t) (warn-on-non-toplevel? t) (override-non-settable? *override-non-settables?*)
(re-sort? t) (keys-to-ignore (list :%primary?%)) (keys-to-forget (list :query-plist :cookies-received :view-toggle)))
(when (member attribute keys-to-forget) (setq remember? nil))
(unless (member attribute keys-to-ignore)
(unless (or (gethash attribute (the %settable-slots%))
(member attribute (the (message-list :category :required-input-slots))))
(let ((message (format nil "The slot ~s is not settable in ~a of type ~a."
attribute
(cons 'the (reverse (the root-path)))
(the type))))
(if override-non-settable?
(warn (format nil "~a Setting it anyway...
To get a continuable error instead, use :override-non-settable? t or
globally (setq *override-non-settables?* t).
Note that this behavior may change to error by default in a future GDL release.
"
message))
(cerror "Set the slot anyway." message))))
(when (and warn-on-non-toplevel?
*notify-cons*)
(warn "It is not recommended to call set-slot! from within dependency-tracking context, e.g. from the body of a computed-slot.
THIS CAN LEAD TO INCONSISTENT DEPENDENCY-TRACKING!!!
Set-slot was called on
~s
with value
~s
from
~s.~%"
(cons 'the (append (reverse (the root-path))
(list (make-keyword attribute))))
value
(cons 'the (append (reverse (the-object (first *notify-cons*) root-path))
(list (make-keyword (second *notify-cons*)))))))
(progn ;; bt:with-lock-held (*binding-lock*) FLAG - bring in later in bootstrapping.
(unless (eql attribute :%primary?%)
(when (not *run-with-dependency-tracking?*)
(error "Dependency Tracking must be enabled in order to forcibly
set slot values.
Please setq the variable `*run-with-dependency-tracking?*' to T,
make a fresh root-level object, and start again."))
(let (*leaf-resets*)
(let ((slot (glisp:intern (symbol-name attribute) :gdl-acc)))
(unbind-dependent-slots self slot)
(setf (slot-value self slot)
(list value nil t)))
(when remember?
(let ((root (let ((maybe-root (the :root)))
(if (the-object maybe-root root?)
maybe-root
(the-object maybe-root parent))))
(root-path (the root-path)
;;(remove :root-object-object (the root-path))
;;(the root-path)
))
(cond ((and (gdl-acc::%version-tree% root)
(not (find root-path (gdl-acc::%version-tree% root)
:test #'equalp :key #'first)))
(nconc (gdl-acc::%version-tree% root)
(list (list root-path))))
((null (gdl-acc::%version-tree% root))
(setf (gdl-acc::%version-tree% root)
(list (list root-path)))))
(when (the primary?)
(setf (getf (rest (assoc root-path (gdl-acc::%version-tree% root) :test #'equalp)) :%primary?%)
t))
(when re-sort?
(setf (gdl-acc::%version-tree% root)
(double-length-sort (gdl-acc::%version-tree% root)))
(let ((non-root (remove nil (gdl-acc::%version-tree% root) :key #'first))
(root-list (find nil (gdl-acc::%version-tree% root) :key #'first)))
(let ((primaries (remove-if-not #'(lambda(item)
(or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list)))
non-root))
(non-primaries (remove-if #'(lambda(item)
(or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list)))
non-root)))
(setf (gdl-acc::%version-tree% root)
(cons (or root-list (list nil))
(append primaries non-primaries))))))
(setf (getf (rest (assoc root-path (gdl-acc::%version-tree% root) :test #'equalp)) attribute)
value)))
(when *eager-setting-enabled?*
(dolist (reset *leaf-resets*)
(the-object (first reset) (evaluate (second reset)))))))))))))
(defun read-snapshot (&key (filename "/tmp/snap.gdl") object keep-bashed-values? make-object-args
keys-to-ignore
(keys-to-ignore-default (list :query-plist :view-toggle :cookies-received)))
"GDL Instance. Reads the snapshot file indicated by filename. If no optional keyword <tt>object</tt>
argument is given, a new GDL instance based on the data in the snapshot file is returned. If an
<tt>object</tt> is given, the object should be compatible in type to that specified in the
snapshot file, and this existing object will be modified to contain the set slot values and
toplevel inputs as specified in the snapshot file.
:&key ((filename \"/tmp/snap.gdl\") \"String or pathname. File to be read.\"
(keep-bashed-values? nil) \"Boolean. Indicates whether to keep the currently bashed values in object before reading snap values into it.\"
(object nil) \"GDL object. Existing object to be modified with restored values.\")"
(let ((keys-to-ignore (append keys-to-ignore keys-to-ignore-default)))
(with-open-file (in filename)
(let ((package-form (read in)))
(when (or (null package-form) (not (find-package (second package-form))))
(error "Invalid package specification at beginning of ~a.~%" filename))
(let* ((*package* (find-package (second package-form))) (root-form (read in)))
(when (or (null root-form)
(not (eql (class-of (find-class (first root-form))) (find-class 'gdl-class))))
(error "Invalid object type specifier as first element of second form in ~a.~%" root-form))
(let* ((object (cond ((and object keep-bashed-values?) object)
(object (the-object object restore-tree!) object)
(t (progn
(apply #'make-object (first root-form) make-object-args))))))
(let ((self object) (value-plist (rest root-form)))
(mapc #'(lambda(key expression)
(unless (member key keys-to-ignore)
(when self (the-object self (set-slot! key (eval expression) :re-sort? nil)))))
(plist-keys value-plist) (plist-values value-plist)))
(let (forms)
(do ((form (read in nil nil) (read in nil nil)))
((null form) forms)
(push form forms))
(setq forms (nreverse forms))
(let* ((forms (double-length-sort forms))
(primaries (remove-if-not #'(lambda(item) (or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list))) forms))
(non-primaries (remove-if #'(lambda(item) (or (getf (rest item) :%primary?%)
(getf (rest item) :element-index-list))) forms))
(forms (append primaries non-primaries)))
(dolist (form forms)
(let ((root-path (first form)) (value-plist (rest form)))
(let ((self
(with-error-handling (:timeout nil)
(the-object object (follow-root-path root-path)))))
(when self
(mapc #'(lambda(key expression)
(unless (member key keys-to-ignore)
(the-object self (set-slot! key (eval `(let ((self ,self)) ,expression)) :re-sort? nil))))
(plist-keys value-plist) (plist-values value-plist))))))))
object))))))
| 11,439 | Common Lisp | .lisp | 218 | 44.509174 | 146 | 0.647268 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 45c627b83e07460e0101c552a8eb4b609ba04feb098a74c267d32f1a5bf0b68a | 35,914 | [
-1
] |
35,915 | p018.lisp | lisp-mirror_gendl/patches/1588/p018.lisp | (in-package :gwl)
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(#+allegro
excl:without-package-locks
#-allegro progn
(defun start-gwl (&key (port *aserve-port*) (listeners *aserve-listeners*)
(external-format :utf8-base))
(net.aserve:shutdown)
(let ((wait-time 1))
(block :outer
(do () ()
(let ((port port))
(block :inner
(do ((port-free? (client-test port) (client-test port)))
(port-free?
(format t (if (> wait-time 1) "~&Retrying AllegroServe on ~a...~%"
"~&Trying to start AllegroServe on ~a...~%") port)
(if (ignore-errors
(net.aserve:start :port port :listeners listeners
#-mswindows :external-format #-mswindows external-format))
(return-from :outer port)
(progn (sleep (random wait-time)) (return-from :inner))))
(incf port))))
(incf wait-time 0.1)))))))
| 880 | Common Lisp | .lisp | 26 | 29 | 77 | 0.636471 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 4e83832a9b09306870c3e2156fc9db549a611d87bd4c1b8bf83ab599f283ef76 | 35,915 | [
-1
] |
35,916 | p007.lisp | lisp-mirror_gendl/patches/1588/p007.lisp | ;;
;; Copyright 2002-2015 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :surf)
(#+allegro
excl:without-package-locks #-allegro progn
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment stitched-solid ()
:input-slots
(("Number. The tolerance to use for creating the brep and for sewing. Larger number is looser tolerance
and more likely to lead to success. Default is 0.0 which uses the SMLib defaults."
tolerance 0.0))
:computed-slots
((%native-brep% (progn (when (or (the trimmed-surfaces) (the proper-faces))
(error "stitched-solid is currently only implemented for plain untrimmed surfaces"))
(make-stitched-solid-brep *geometry-kernel*
:tolerance (the tolerance)
:surfaces (the plain-surfaces)
:proper-faces nil)))))
(define-object-amendment boolean-merge ()
:input-slots
(("Boolean. Indicates whether we should try to sew and orient the
resulting brep. This defaults to t for merge operation and nil otherwise."
sew-and-orient? (eql (the operation) :merge)))
:computed-slots
((%merge-and-brep
(progn
(when (or (> (the first-brep regions number-of-elements) 2)
(not (every #'(lambda(number) (<= number 2))
(mapcar #'(lambda(object) (the-object object regions number-of-elements))
(the rest-breps)))))
(let ((message (format nil "~%~%in ~a -~%~%Attempting booleans where brep has ~~a non-infinite regions.~%"
(cons 'the (reverse (the root-path))))))
(if (the allow-multiple-regions?)
(warn message
(1- (the first-brep regions number-of-elements)))
(error message
(1- (the first-brep regions number-of-elements))))))
(let ((count -1) (length (length (the rest-breps)))
merge-container current-breps (current-brep (the first-brep %native-brep%)))
(dolist (other-brep (the rest-breps))
(incf count)
(when *debug?*
(print-variables (the root-path)
(the first-brep root-path)
(the-object other-brep root-path)))
(when *debug?* (print-variables (the approximation-tolerance) (the angle-tolerance)))
(setq merge-container (make-merge-container *geometry-kernel*
current-brep
(the-object other-brep %native-brep%)
(the approximation-tolerance)
(the angle-tolerance)))
(ecase (the operation)
((:difference :union :intersection)
(setq current-brep
(do-boolean-merge-operation *geometry-kernel* merge-container
(the operation) (the make-manifold?)
:sew-and-orient? (the sew-and-orient?))))
((:merge)
(let ((try-manifold? (and (the make-manifold?) (= count (1- length)))))
(setq current-brep (do-boolean-merge-operation *geometry-kernel* merge-container
(the operation) try-manifold?
:make-manifold? try-manifold?
:sew-and-orient? (the sew-and-orient?)))))
(:extract_separate
(setq current-breps (do-boolean-separate-operation *geometry-kernel*
merge-container (the make-manifold?) (the sew-and-orient?))))))
(ecase (the operation)
((:difference :union :intersection :merge)
(list :merge-container merge-container :native-brep current-brep))
(:extract_separate (list :merge-container merge-container :native-breps current-breps))))))))))
| 4,482 | Common Lisp | .lisp | 90 | 40.566667 | 109 | 0.668435 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ef8dec000ede0c4c9da376314bede28b50d10ab566e928dfa647b777177f89c1 | 35,916 | [
-1
] |
35,917 | p019.lisp | lisp-mirror_gendl/patches/1588/p019.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl)
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(#+allegro
excl:without-package-locks
#-allegro progn
(define-object variable-sequence (quantification)
:documentation (:description "A variable-sequence quantification is generated as a result of specifying
<tt>:sequence (:indices ...))</tt> in an <tt>:objects</tt> specification. Unlike a normal sequence quantification (specified
with <tt>:sequence (:size ...))</tt>), elements can be surgically inserted and deleted from a variable-sequence.")
:input-slots
(:element-index-list
:child-types)
:computed-slots
((lock (bt:make-lock))
(ht (progn (the :child-types)
;;
;; FLAG -- consider increasing initial size or rehash-size
;;
(let ((ht (make-hash-table :size (length (the :element-index-list)))))
(dolist (index (the :element-index-list) ht)
(setf (gethash index ht) nil)))) :settable)
(safe-list-elements (multiple-value-bind (list error)
(ignore-errors
(let ((result-list nil))
(dolist (n (the element-index-list) (nreverse result-list))
(multiple-value-bind (object error)
(ignore-errors (the (:get-member n)))
(let
((child (cond ((typep error 'error)
(list :object-key (list (make-keyword (the %name%)) n)
:error error))
((typep object 'null-object)
nil)
(t object))))
(when child (push child result-list)))))))
(if (typep error 'error)
(list (list :object-key (make-keyword (format nil "~a[agg]" (the %name%)))
:error error))
list)))
(list-elements (mapcar #'(lambda(index)
(the (:get-member index)))
(the :element-index-list)))
(number-of-elements (length (the :element-index-list)))
(first (the (:get-member (first (the :element-index-list)))))
(last (the (:get-member (first (last (the :element-index-list)))))))
:functions
((exists? (index) (gethash index (the ht)))
("Void. Resets the variable sequence to its default list of indices (i.e. clears out any inserted or deleted elements and
re-evaluates the expression to compute the original list of indices)"
reset!
()
(progn ;;bt:with-lock-held ((the lock))
(the (restore-slot-default! :element-index-list))
(the (restore-slot-default! :ht))))
(instantiated-indices () (remove-if-not #'(lambda(index)
(second (multiple-value-list (gethash index (the :ht)))))
(the :element-index-list)))
(get-member
(index)
(multiple-value-bind (value found?)
(gethash index (the ht))
(cond (value value)
(found? (setf (gethash index (the :ht))
(make-object-internal
(the :child-types)
:%name% (list (glisp:intern
(symbol-name (the :name-for-display))
:gdl-acc) nil t)
:%parent% (list (the :parent) nil t)
:%root% (gdl-acc::%root% self)
:%aggregate% (list self nil t)
:%index% (list index nil t))))
(t (error "The element ~a is not active in ~s" index self)))))
(deactivate! (index) (the (:delete! index)))
("Void. Deletes the element identified with the given index.
:arguments (index \"Integer, Symbol, or other object matching with <tt>eql</tt>. The identifier used when the element was initialized or inserted.\")"
delete!
(index)
(bt:with-lock-held ((the lock))
(the (:set-slot! :ht (the :ht) :remember? nil))
(remhash index (the ht))
(the (:modify-attribute! :element-index-list
(remove index (the :element-index-list))))))
(activate! (index) (the (:insert! index)))
("Void. Inserts a new element identified with the given index.
:arguments (index \"Integer, Symbol, or other object matching with <tt>eql</tt>. The identifier to be used to access this element.\")"
insert!
(index)
(multiple-value-bind (value found?)
(gethash index (the ht))
(declare (ignore value))
(if (not found?)
(bt:with-lock-held ((the lock))
(setf (gethash index (the ht)) nil)
(the (set-slot! :ht (the ht) :remember? nil))
(the (set-slot! :element-index-list
(append (the element-index-list) (list index)))))
(error "The element ~a is already active in ~s" index self))))))))
(in-package :tasty)
(#+allegro
excl:without-package-locks #-allegro progn
(#+allegro
excl:without-redefinition-warnings #-allegro progn
(define-object-amendment value-inspector ()
:input-slots ((value (with-error-handling ()
(let (gdl::*notify-cons*)
(the parent-node (evaluate (the message)))))))
:functions
((get-value-element
(index)
(case (the value-type)
(:list (nth index (the value)))
(:gdl-sequence (let (gdl::*notify-cons*) (the value (get-member index))))))))))
| 5,761 | Common Lisp | .lisp | 135 | 36.725926 | 150 | 0.653909 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 45a13c7059e8b32bdb5dd64d7a797c8fe09cae2634d3061e0a43712d3ae27241 | 35,917 | [
-1
] |
35,918 | p002.lisp | lisp-mirror_gendl/patches/1588/p002.lisp | (in-package :gdl)
(defparameter *1588p002-doc*
"On Update!, pulls version-tree for true root down to
root-object-object, if the root-object-object is a child of the true
root and has its root set to itself. This is the case for the object
being inspected in ta2 and tasty, for example. This makes (the
update!) work as expected for the root-object-object of tasty or
ta2, even though the actual version-tree is stored at the
parent (i.e. at the true root).
NOTE: This patch is superseded by p004.")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("Void. Uncaches all cached data in slots and objects throughout the instance
tree from this node, forcing all code to run again the next time values are
demanded. This is useful for updating an existing model or part of an existing
model after making changes and recompiling/reloading the code of the underlying
definitions. Any set (modified) slot values will, however, be preserved
by the update."
update!
(&key (replace-bashed-values? t))
(let ((all-messages (the (:message-list)))
(methods (the (:message-list :category :functions)))
(immune-messages (list :$$ta2 :$$ta2-object
:$$tatu :$$tatu-object))
;;
;; FLAG -- get rid of special-casing and ignore-errors for root-object-object.
;;
(root-object-object-vt
(when (and (ignore-errors (the root-object-object))
(not (eql (the root-object-object) self)))
(mapcar #'(lambda(path)
(when (consp (rest path))
(cons (append (first path) (list :root-object-object))
(rest path))))
(gdl-acc::%version-tree% (ignore-errors (the root-object-object)))))))
(let ((cached-messages
(set-difference all-messages (append methods immune-messages))))
(dolist (key cached-messages)
(let ((key (glisp:intern (symbol-name key) :gdl-acc)))
(unbind-dependent-slots self key :updating? t))))
(let* ((root-path (remove :root-object-object (the root-path)))
;;(root-path (the root-path))
(root-path-length (length root-path))
(version-tree (if (and (the parent)
(ignore-errors (the parent root-object-object))
(eql (the parent root-object-object) self))
(remove-if-not #'(lambda(path)
(eql (lastcar (first path))
:root-object-object))
(gdl-acc::%version-tree% (the parent)))
(gdl-acc::%version-tree% (the root))))
(version-tree
(when replace-bashed-values?
(append
(remove-if-not #'(lambda(node)
(let ((local-root-path (first node)))
(and (> (length local-root-path) root-path-length)
(equalp (subseq local-root-path
(- (length local-root-path)
root-path-length))
root-path))))
version-tree)
root-object-object-vt))))
(when *debug?* (print-variables version-tree))
(dolist (version-node version-tree (values))
(let ((root (the root))
(root-path (first version-node)) (value-plist (rest version-node)))
(mapc #'(lambda(key value)
(when (not (eql value 'gdl-acc::%default%))
;;
;; FLAG - make this into a more specific error check for
;; nonexistence of the object (e.g. not handled error).
;;
(with-error-handling (:timeout nil)
(the-object root (:follow-root-path root-path)
(:set-slot! key value)))))
(plist-keys value-plist) (plist-values value-plist))))))))))
(format t "~&~%Changes in 1588p002:~%~%~a~%~%" *1588p002-doc*)
| 3,631 | Common Lisp | .lisp | 81 | 38.271605 | 82 | 0.653539 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 638353a3591ff159e015064247c2cd65e4365002761d466433c6e1f036e0e3cd | 35,918 | [
-1
] |
35,919 | p006.lisp | lisp-mirror_gendl/patches/1588/p006.lisp | (in-package :gdl)
(defparameter *1588p006-doc*
" Keep the items in internal %version-tree% sorted based on root-path length.")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("NIL. Restores the value of the given slot to its default, thus ``undoing'' any forcibly set value
in the slot. Any dependent slots in the tree will respond accordingly when they are next demanded.
Note that the slot must be specified as a keyword symbol (i.e. prepended with a colon (``:'')),
otherwise it will be evaluated as a variable according to normal Lisp functional evaluation rules.
:arguments (slot \"Keyword Symbol\")
:key (force? \"Boolean. Specify as t if you want to force non-settable slots to recompute (e.g.
reading from databases or external files). Defaults to nil.\")"
restore-slot-default!
(attribute &key (force? *force-restore-slot-default?*))
(when (or force? (eql (the (slot-status attribute)) :set))
(let (*leaf-resets*)
(let ((slot (glisp:intern (symbol-name attribute) :gdl-acc)))
(unless (eq (first (ensure-list (slot-value self slot))) 'gdl-rule::%unbound%)
(unbind-dependent-slots self slot)
(setf (slot-value self slot)
(if *remember-previous-slot-values?*
(list 'gdl-rule::%unbound% nil nil (first (slot-value self slot)))
'gdl-rule::%unbound%))))
(let ((root (let ((maybe-root (the :root)))
(if (the-object maybe-root root?)
maybe-root
(the-object maybe-root parent))))
;;(root-path (remove :root-object-object (the root-path)))
(root-path (the root-path))
)
;;
;; FLAG -- this pushnew should never be necessary...
;;
(pushnew (list root-path)
(gdl-acc::%version-tree% root) :test #'equalp :key #'(lambda(item) (list (first item))))
(setf (rest (assoc root-path (gdl-acc::%version-tree% root) :test #'equalp))
(remove-plist-key (rest (assoc root-path
(gdl-acc::%version-tree% root) :test #'equalp)) attribute))
(setf (gdl-acc::%version-tree% root)
(sort (gdl-acc::%version-tree% root)
#'(lambda(item1 item2)
(< (length (first item1)) (length (first item2)))))))
(when *eager-setting-enabled?*
(dolist (reset *leaf-resets*)
(the-object (first reset) (evaluate (second reset))))))))
("Void. Writes a file containing the toplevel inputs and modified settable-slots starting from the root of the
current instance. Typically this file can be read back into the system using the <tt>read-snapshot</tt> function.
:&key ((filename \"/tmp/snap.gdl\") \"String or pathname. The target file to be written.\"
(root-paths-to-ignore nil) \"List of root-paths or nil. Any objects with matching root-path will be ignored for the snapshot write.\"
)"
write-snapshot
(&key (filename "/tmp/snap.gdl") (root-paths-to-ignore nil))
(let (*print-level*
(root-object-object? (and (the parent) (the parent root?)
(defaulting (the parent root-object-object))
(eql (the parent root-object-object) self))))
(let ((root (if root-object-object? (the root parent) (the root))))
(setf (gdl-acc::%version-tree% root)
(sort (gdl-acc::%version-tree% root)
#'(lambda(item1 item2)
(< (length (first item1)) (length (first item2))))))
(with-open-file (out filename :direction :output :if-exists :supersede :if-does-not-exist :create)
(print `(in-package ,(make-keyword (package-name *package*))) out)
(mapcar #'(lambda(node)
(let ((root-path (first node)) (value-plist (rest node)))
(unless (or (member root-path root-paths-to-ignore :test #'equalp)
(and root-object-object?
(not (eql (lastcar root-path) :root-object-object))))
(when root-object-object?
(setq root-path (if (consp (rest root-path))
(butlast root-path)
(the type))))
(let ((keys (plist-keys value-plist)) (values (plist-values value-plist)))
(let ((snap (cons root-path
(append (when (atom root-path)
(let (result)
(let* ((toplevel-inputs
(remove-plist-key (the root active-inputs)
:remote-id))
(toplevel-input-keys (plist-keys toplevel-inputs))
(toplevel-input-values (plist-values toplevel-inputs)))
(mapc #'(lambda(key value)
(when (not (member key keys))
(push key result) (push value result)))
toplevel-input-keys toplevel-input-values))
(nreverse result)))
(mapcan #'(lambda(key val)
(let ((expression (readable-expression val self)))
(unless (eql expression :%unreadable%)
(list key expression))))
keys values))))) (print snap out))))))
(or (gdl-acc::%version-tree% root) (list nil))))))
filename))))
| 4,956 | Common Lisp | .lisp | 96 | 43.979167 | 140 | 0.6399 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 4b07082f154df7395a39fd65ae4ebb07490b8dbf08753ed790137f7b0bfc142f | 35,919 | [
-1
] |
35,920 | p012.lisp | lisp-mirror_gendl/patches/1588/p012.lisp | (in-package :gdl)
(defparameter *1588p012-doc*
" Add check for listp for root-path.")
(#+allegro
excl:without-redefinition-warnings
#-allegro progn
(define-object-amendment vanilla-mixin* ()
:functions
(("Void. Writes a file containing the toplevel inputs and modified settable-slots starting from the root of the
current instance. Typically this file can be read back into the system using the <tt>read-snapshot</tt> function.
:&key ((filename \"/tmp/snap.gdl\") \"String or pathname. The target file to be written.\"
(root-paths-to-ignore nil) \"List of root-paths or nil. Any objects with matching root-path will be ignored for the snapshot write.\"
)"
write-snapshot
(&key (filename "/tmp/snap.gdl") (root-paths-to-ignore nil))
(let (*print-level*
(root-object-object? (and (the parent) (the parent root?)
(defaulting (the parent root-object-object))
(eql (the parent root-object-object) self))))
(let ((root (if root-object-object? (the root parent) (the root))))
;;
;; Should always be sorted now.
;;
#+nil
(setf (gdl-acc::%version-tree% root)
(sort (gdl-acc::%version-tree% root)
#'(lambda(item1 item2)
(< (length (first item1)) (length (first item2))))))
(let* ((root-object-entry (when root-object-object?
(find :root-object-object (gdl-acc::%version-tree% root)
:key #'(lambda(item) (first (first item))))))
(version-tree (if root-object-entry
(cons root-object-entry
(remove :root-object-object (gdl-acc::%version-tree% root)
:key #'(lambda(item) (first (first item)))))
(gdl-acc::%version-tree% root))))
(with-open-file (out filename :direction :output :if-exists :supersede :if-does-not-exist :create)
(print `(in-package ,(make-keyword (package-name *package*))) out)
(mapcar #'(lambda(node)
(let ((root-path (first node)) (value-plist (rest node)))
(unless (or (member root-path root-paths-to-ignore :test #'equalp)
(and root-object-object?
(not (eql (lastcar root-path) :root-object-object))))
(when (or (and root-object-object? (null (rest root-path)))
(and (not root-object-object?) (null root-path)))
(setq root-path (the type)))
(when (and root-object-object? (consp root-path) (consp (rest root-path)))
(setq root-path (butlast root-path)))
(let ((keys (plist-keys value-plist)) (values (plist-values value-plist)))
(let ((snap (cons root-path
(append (when (atom root-path)
(let (result)
(let* ((toplevel-inputs
(remove-plist-key (the root active-inputs)
:remote-id))
(toplevel-input-keys (plist-keys toplevel-inputs))
(toplevel-input-values (plist-values toplevel-inputs)))
(mapc #'(lambda(key value)
(when (not (member key keys))
(push key result) (push value result)))
toplevel-input-keys toplevel-input-values))
(nreverse result)))
(mapcan #'(lambda(key val)
(let ((expression (readable-expression val self)))
(unless (eql expression :%unreadable%)
(list key expression))))
keys values))))) (print snap out))))))
(or version-tree (list nil)))))))
filename))))
| 3,403 | Common Lisp | .lisp | 69 | 40.826087 | 140 | 0.623708 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e21dc6aadcaf15f32b3cde2a9b9729440e46cbf4a9695d3179f37dcb93502ae2 | 35,920 | [
-1
] |
35,921 | assembly.lisp | lisp-mirror_gendl/apps/tree/source/assembly.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tree)
(defparameter *icon-hash* nil)
(define-object tree (sheet-section tree-node-mixin)
:documentation (:description "Implements an interactive grapical tree using HTML table elements.")
:input-slots
(("Function of one argument. This function takes a node in the tree as an argument, and should return
a plist with keys :function and :arguments, which is a function in the bashee which will be called
with the given arguments when the given node in the tree is clicked."
onclick-function nil)
(respondent (the parent))
(tree-style
(format nil "
table.Tree {border-style: solid;
cursor: default;
table-layout: fixed;
border-color: ~0@*~a;
border-width: 0px;}
table.Tree td.LeftBottomBorder {height: ~2@*~apx;
line-height: ~2@*~apx;
border-style: solid;
border-color: ~0@*~a;
border-width: 0px;
border-left-width: ~4@*~apx;
border-bottom-width: ~4@*~apx;}
table.Tree td.LeftBorder {height: ~2@*~apx;
line-height: ~2@*~apx;
border-style: solid;
border-color: ~0@*~a;
border-width: 0px;
border-left-width: ~4@*~apx;}
table.Tree td.EmptyLeftBorder {height: 2px;
line-height: 2px;
border-style: solid;
border-color: ~0@*~a;
border-width: 0px;
border-left-width: ~4@*~apx;}
table.Tree td.BottomBorder {height: ~2@*~apx;
line-height: ~2@*~apx;
border-style: solid;
border-color: ~0@*~a;
border-width: 0px;
border-bottom-width: ~4@*~apx;}
table.Tree td.Button {background-color: ~1@*~a;
text-align: center;
vertical-align: middle;
margin: 1px;
border-color: white;
border-top-width: ~4@*~apx;
border-bottom-width: ~4@*~apx;
height: ~3@*~apx ;
line-height: ~3@*~apx;}
table.Tree td.Content {
cursor: default;
height: ~3@*~apx;
line-height: ~3@*~apx;
vertical-align: middle;}
table.Tree td.Empty {
height: ~2@*~apx;
line-height: ~2@*~apx ;}
table.Tree td.EmptyRow {
border-width: 0px;
height: 2px;
line-height: 2px ;}
table.Tree td.HeaderCell {border-width: 0px;
width: ~5@*~apx;
line-height: 1px;
height: 1px;}
table.Tree td.HeaderCellSpace {border-width: 0px;
width: ~6@*~apx;
line-height: 1px;
height: 1px;
}
"
(the tree-color)(the button-color) (the half-height) (the row-height)
(the tree-width)(the cell-width) (half (the cell-width))))
(row-height 20)
(tree-width 1)
("String " tree-color "red")
("" button-color "blue")
(cell-width 6)
(half-height (half (the row-height)))
(tree-dom-id (the dom-id)))
:computed-slots ((style-view (with-cl-who-string ()
(write-the style-view))))
:trickle-down-slots (respondent))
(define-lens (html-format tree)()
:output-functions
((style-view
()
(with-cl-who ()
((:div :id "tree-css") ((:style :type "text/css" :media "screen")
(str (the tree-style))))))
(inner-html
()
(html-stream *stream*
((:div :id (the tree-dom-id)) (write-the tree))))))
(define-object tree-node-mixin (skeleton-ui-element)
:input-slots
(respondent
(onclick-function nil)
(target-object self)
(%tree-root% self :defaulting)
(depth (if (eql self (the %tree-root%)) 0 (1+ (the parent depth))))
(remaining-depth (if (or (null (the child-nodes)) (the closed?)) 0
(+ 1 (apply #'max (mapsend (the child-nodes) :remaining-depth)))))
(total-depth (if (eql self (the %tree-root%)) (the remaining-depth) (the parent total-depth)))
(last-node? (and (not (eql self (the %tree-root%))) (eql self (lastcar (the parent child-nodes))))))
:trickle-down-slots (%tree-root%)
:computed-slots
(
;;
;; FLAG -- to skeleton-ui-mixin and out of base-html-sheet.
;;
(base64-encoded-root-path (base64-encode-safe (format nil "~s" (the root-path))))
(dom-id (the base64-encoded-root-path))
(inner-html (with-output-to-string (*html-stream*)
(with-format (html-format *html-stream*)
(write-the inner-html))))
;;
;; endFLAG
;;
(closed? (not (eql self (the %tree-root%))) :settable)
(open? (not (the closed?)))
(child-nodes (list-elements (the nodes))))
:hidden-objects ((nodes :type 'tree-node-mixin
:sequence (:size (length (the target-object children)))
:pass-down (respondent onclick-function)
:target-object (nth (the-child index) (the target-object children))))
:functions
((toggle-state! () (the (set-slot! :closed? (not (the closed?)))))))
(define-lens (html-format tree-node-mixin)()
:output-functions
(
;;
;; required by skeleton-ui-mixin
;;
(inner-html () (write-the tree))
(tree
() (let ((*icon-hash* (make-hash-table)))
(html-stream *stream*
((:table :class "Tree" :border 0 :cellpadding 0 :cellspacing 0)
:newline
;; this first row sets up the column widths. table style is defined as fixed-width to enforce these
(:tr ((:td :class "HeaderCell") " ")
((:td :class "HeaderCell") " ")
(dotimes (i (twice (the total-depth))) (html ((:td :class "HeaderCell") " ")))
((:td :class "HeaderCellSpace") " ")
((:td :style "line-height: 1px; height: 1px; border-width: 0px;")" "))
(write-the tree-row)))))
(tree-row
() (html-stream *stream* :newline
((:tr :style "height: 10px;")
(let ((depth (the depth)))
(dotimes (n depth)
(cond
((and (= n (1- depth)) (the last-node?))
(setf (gethash n *icon-hash*) :l)
(html ((:td :class "Empty") " ") ((:td :class "LeftBottomBorder") " ")))
((= n (1- depth))
(setf (gethash n *icon-hash*) :t)
(html ((:td :class "Empty")" ") ((:td :class "LeftBottomBorder") " ")))
((member (gethash n *icon-hash*) (list :i :t))
(setf (gethash n *icon-hash*) :i)
(html ((:td :class "Empty")" ")
((:td :class "LeftBorder") " ")))
(t (html ((:td :colspan 2 :class "Empty")
:br))))))
(if (and (typep self 'tree-node-mixin) (the child-nodes))
(html
:newline
((:td :class "Button" :rowspan 2 :colspan 2
:style "cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :toggle-state!)))
(:b (:princ (if (the closed?) "+" "-")))))
(html ((:td :colspan 2 :class "BottomBorder") " ")))
((:td :class "Empty":rowspan 2 ) " " )
((:td :rowspan 2 :class "Content" :colspan (+ 1 (twice (- (the total-depth) (the depth)))))
((:span :style "cursor: pointer;"
:if* (the onclick-function)
:onclick (funcall (the onclick-function) (the target-object))
;;:onclick (the (gdl-ajax-call
;;(:apply (funcall (the onclick-function) (the target-object)))))
#+nil
(format nil "return gdlAjax('args=~a');"
(the (encode-ajax-args (:apply (funcall (the onclick-function)
(the target-object)))))))
(html (:princ (the target-object strings-for-display))))))
(let ((depth (the depth)))
(html (:tr
(dotimes (n depth)
(cond
((and (= n (1- depth)) (the last-node?))
(setf (gethash n *icon-hash*) :l)
(html ((:td :class "Empty")" ") ((:td :class "Empty")" ")))
((= n (1- depth))
(setf (gethash n *icon-hash*) :t)
(html ((:td :class "Empty")" ") ((:td :class "LeftBorder") " ")))
((member (gethash n *icon-hash*) (list :i :t))
(setf (gethash n *icon-hash*) :i)
(html ((:td :class "Empty")" ")
((:td :class "LeftBorder") " ")))
(t (html ((:td :colspan 2 :class "Empty") :br)))))
(unless (and (typep self 'tree-node-mixin) (the child-nodes))
(html ((:td :colspan 2 :class "Empty") " "))))))
(:tr
(let ((depth (the depth)))
(dotimes (n depth)
(cond
((and (= n (1- depth)) (the last-node?))
(setf (gethash n *icon-hash*) :l)
(html ((:td :class "EmptyRow") " ") ((:td :class "EmptyRow") " ")))
((= n (1- depth))
(setf (gethash n *icon-hash*) :t)
(html ((:td :class "EmptyRow")" ") ((:td :class "EmptyLeftBorder") " ")))
((member (gethash n *icon-hash*) (list :i :t))
(setf (gethash n *icon-hash*) :i)
(html ((:td :class "EmptyRow")" ")
((:td :class "EmptyLeftBorder") " ")))
(t (html ((:td :colspan 2 :class "EmptyRow") :br))))))
(if (and (typep self 'tree-node-mixin) (the child-nodes))
(html
:newline
((:td :class "EmptyRow") " ")
((:td :class (if (the closed?) "EmptyRow" "EmptyLeftBorder")) " "))
(html ((:td :colspan 2 :class "EmptyRow") " "))))
;;
;; FLAG -- when would self ever not be of type 'tree-node-mixin ??
;;
(when (and (typep self 'tree-node-mixin) (the open?))
(mapc #'(lambda(node) (write-the-object node (tree-row))) (the child-nodes)))))))
| 11,296 | Common Lisp | .lisp | 250 | 33.864 | 107 | 0.541581 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0013ea447049149c4a2a8bc9678de0dc2a4c11bb6011ae59eaee5b98f9bb1c71 | 35,921 | [
-1
] |
35,922 | newertree.lisp | lisp-mirror_gendl/apps/tree/source/newertree.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tree)
(defparameter *trap-errors?* t)
;;
;; FLAG -- this depends on jQuery. Assume the containing sheet has
;; :use-jquery? t
;;
;; This shoud be upgraded to avoid that assumption and check with the
;; containing sheet, and other sheets in the tree. If not using
;; jquery, then use it here.
;;
(define-object newertree (sheet-section)
:documentation (:description "Implements an interactive graphical tree from a nested list using HTML list element and CSS.")
:input-slots
(("Function of one argument. This function takes a node in the tree as an argument, and should return
a plist with keys :function and :arguments, which is a function in the bashee which will be called
with the given arguments when the given node in the tree is clicked."
onclick-function nil)
(respondent (the parent))
(tree-dom-id (the dom-id))
(target-object self)
(display-controls-hash nil)
(%tree-root% self)
(expand-mode :remember :settable)
(show-onmouseover-buttons? t)
)
:computed-slots
(
;;
;; This overrides the one from skeleton-ui-element because we don't want to filter
;; the root-object-object in the case of the tree.
;;
(base64-encoded-root-path (base64-encode-safe (format nil "~s" (the root-path))))
(tatu-color (or (when (getf (the local-display-controls) :color)
(string-append "#" (getf (the local-display-controls) :color)))
(multiple-value-bind (color error)
(ignore-errors (the target-object color-hex))
(if (typep error 'error) (lookup-color :red :format :hex) color))))
(tatu-line-thickness (or (getf (the local-display-controls) :line-thickness)
(or (ignore-errors (the target-object line-thickness)) 1)))
#+nil
(local-display-controls (gethash (the target-object) (the display-controls-hash)))
(local-display-controls
(or (gethash (the target-object) (the display-controls-hash))
(when (typep (the parent) 'newertree) (the parent local-display-controls))))
(kids-error (when (typep (the safe-children) 'error) (the safe-children)))
(safe-children (append (if *trap-errors?*
(the target-object safe-children)
(the target-object children))
(the target-object visible-children)))
(safe-strings-for-display
(let ((string (multiple-value-bind (strings error)
(ignore-errors (the target-object
strings-for-display))
(cond ((typep error 'error)
(format nil "! ~a ! from strings-for-display" error))
((the color-error?)
(format nil "~a ! ~a ! from color-hex" strings
(the color-or-error)))
(t strings)))))
(if (stringp string) string
(progn
(warn "safe-strings-for-display returned non-string: ~s.
Converting to a string to avoid error."
string)
(format nil "~s" string)))))
(color-or-error (multiple-value-bind (color error)
(ignore-errors (the target-object color-hex))
(if (typep error 'error) error color)))
(color-error? (typep (the color-or-error) 'error))
(color-hex (if (the color-error?) (lookup-color :red :format :hex) (the color-or-error)))
(safe-child-first (length (the target-object safe-children)))
(closed? (not (eql self (the %tree-root%))) :settable)
(open? (not (the closed?)))
(child-nodes (list-elements (the nodes)))
(inner-html
(with-cl-who-string ()
((:ul :id "tree-root" :class "tasty-tree")
(str (the tree-node-view)))))
(tree-node-view
(with-cl-who-string ()
((:li)
;;(:li :id "tree-node" :class "")
(when (the child-nodes)
(if (the closed?)
(progn (htm ((:span
:class "directory"
:title "Click to expand ..."
:onclick (the (gdl-ajax-call :function-key :toggle-state!))))))
(progn (htm ((:span
:class "expanded"
:onclick (the (gdl-ajax-call :function-key :toggle-state!))))))
))
(unless (the child-nodes)
(htm ((:span :class "leaf")))
)
((:span :class "container"
:onmouseover "$(this).children('.actions').css('display','inline')"
:onmouseout "$(this).children('.actions').hide()")
((:span :class "tree-node"
:style (when (or (the tatu-color)
(the tatu-line-thickness))
(format nil "~a~a"
(if (the tatu-color) (format nil " color: ~a; " (the tatu-color)) "")
(let ((font-weight
(cond
((or (null (the tatu-line-thickness))
(= (the tatu-line-thickness) 1) )400)
((minusp (the tatu-line-thickness)) 100)
((< (the tatu-line-thickness) 1) (* 400 (the tatu-line-thickness)))
((<= (the tatu-line-thickness) 3) (* 300 (the tatu-line-thickness)))
(t 900))))
(format nil " font-weight: ~a; " font-weight))))
:onclick (when (the onclick-function)
(funcall (the onclick-function) (the target-object))))
(esc (the safe-strings-for-display)))
;; here the intree command images are placed inside a span
(when (the show-onmouseover-buttons?)
(htm
((:span :class "actions"
:style "display:none;")
((:span :class "draw"
:onclick (the (gdl-ajax-call :function-key :set-and-call-click-mode!
:arguments (list :add-leaves)))
:title "Draw this object (AL)"))
((:span :class "inspect"
:onclick (the (gdl-ajax-call :function-key :set-and-call-click-mode!
:arguments (list :inspect)))
:title "Inspect this object"))
((:span :class "highlight"
:onclick (the (gdl-ajax-call :function-key :set-and-call-click-mode!
:arguments (list :highlight)))
:title "Toggle Leaves of this object")))))
)
;; if there are siblings, make them here (inside the li)
(when (and (typep self 'newertree)
(the open?)
(the child-nodes))
(htm
(:ul
(mapc #'(lambda (tree-node)
(str (the-object tree-node tree-node-view)))
(the child-nodes)))))))))
:functions
((toggle-state! ()
(the (set-slot! :closed? (not (the closed?))))
(the propogate-toggle!))
(propogate-toggle!
()
(ecase (the expand-mode)
(:auto-close (the %tree-root% (close-all! :except self))
(the expand-parents!))
(:children (mapc #'(lambda(node) (when (null (the-object node closed?))
(the-object node (set-slot! :closed? t))))
(the child-nodes)))
(:leaves (mapc #'(lambda(node) (the-object node open-all!))
(the child-nodes)))
(:remember ;; do nothing
))
)
(open-all!
()
(the (set-slot! :closed? nil))
(mapc #'(lambda(node) (the-object node open-all!))
(the child-nodes)))
(close-all!
(&key except)
(unless (eql self except) (the (set-slot! :closed? t)))
(mapc #'(lambda(node) (the-object node (close-all! :except except)))
(the child-nodes)))
(expand-parents!
()
(when (and (the parent)
(typep (the parent) 'newertree))
(the parent (set-slot! :closed? nil))
(the parent expand-parents!)))
(set-and-call-click-mode!
(mode)
(ecase mode
(:inspect (the inspector (set-object! (the target-object))))
(:add-leaves (the viewport (add-leaves! (the target-object))))
(:highlight (if (the viewport (leaves-displayed? (the target-object)))
(the viewport (delete-leaves! (the target-object)))
(the viewport (add-leaves*! (the target-object)))))
;;
;; Add :highlighted? entry to the dynamic (thread-local)
;; display-list parameter, not to the actual object. Object has
;; no guarantee of carrying the highlighted? slot and we are not
;; going to make base-object or vanilla-mixin even heavier by
;; adding yet another slots.
;;
;; For the time being, highlight functionality simply
;; adds/deletes individual leaves.
;;
#+nil
(:highlight (if (the target-object highlighted?)
(progn
(the target-object (set-slot! :highlighted? nil))
(the viewport (add-leaves! (the target-object))))
(progn
(the target-object (set-slot! :highlighted? t))
(the viewport (add-leaves! (the target-object)))
))))))
:hidden-objects ((nodes :type 'newertree
:sequence (:size (length (the safe-children)))
:pass-down (%tree-root% respondent onclick-function expand-mode display-controls-hash
show-onmouseover-buttons?
)
;;:visible-child? (>= (the-child index) (the safe-child-first))
;;:depth (1+ (the depth))
:target-object (let ((node (nth (the-child index) (the safe-children))))
(if (listp node)
(make-object 'tasty-child-error
:error (getf node :error)
:object-key (getf node :object-key))
node)))))
(define-object tasty-child-error ()
:input-slots (error object-key)
:computed-slots ((strings-for-display (format nil "~a threw error: ~a" (the object-key) (the error)))))
| 12,020 | Common Lisp | .lisp | 238 | 35.289916 | 126 | 0.530994 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | dcc22778723deef18a50bb0c616b198ebbc26fb65de8b71eaad835a3f2d04354 | 35,922 | [
-1
] |
35,923 | package.lisp | lisp-mirror_gendl/apps/tree/source/package.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(gwl:define-package :tree
(:documentation #.(glisp:system-description :tree))
(:export #:tree #:newtree #:newertree))
| 1,018 | Common Lisp | .lisp | 24 | 39.708333 | 71 | 0.733333 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 84f7974473475c057d683d2d3e255175300ec2b4a8e7bdb83e68495770bfc507 | 35,923 | [
-1
] |
35,924 | ajax.lisp | lisp-mirror_gendl/apps/tree/source/ajax.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tree)
(defun gdltreetoggle (req ent)
(let ((query (request-query req)))
(let* ((iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(plist (gwl::assoc-list-to-plist query :case-sensitive? t)))
(let ((respondent-root-path (getf plist :respondentRootPath))
(root-path (getf plist :rootPath)))
(setq respondent-root-path (base64-decode-list respondent-root-path)
root-path (base64-decode-list root-path))
(let ((object (the (follow-root-path root-path)))
(respondent (the (follow-root-path respondent-root-path))))
(the-object object toggle-state!)
(respond-with-new-html-sections req ent respondent))))))
(publish :path "/gdltreetoggle" :function 'gdltreetoggle)
(defun respond-with-new-html-sections (req ent self)
(let (replace-list)
(dolist (section (ensure-list (the html-sections)) (reverse replace-list))
(let ((status (the-object section (slot-status :inner-html))))
(when (eql status :unbound)
(when *debug?* (format t "pushing html for ~a...~%" (the-object section dom-id)))
(push (list (the-object section dom-id)
(the-object section inner-html)) replace-list))))
(with-http-response (req ent :content-type "text/xml")
(with-http-body (req ent)
(with-html-output(*html-stream* nil)
(:document
(dolist (replace-pair replace-list)
(htm
(:html-section (:|replaceId| (str (first replace-pair)))
(:|newHTML| (str (wrap-cdata (second replace-pair)))))))))))))
(defun wrap-cdata (string)
(string-append "<![CDATA[" string "]]>"))
| 2,702 | Common Lisp | .lisp | 53 | 43.377358 | 92 | 0.648762 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d087cf7882d5e26d80cff2e98c8bef45dd7b763abb9eb85f295875ed01465cd4 | 35,924 | [
-1
] |
35,925 | parameters.lisp | lisp-mirror_gendl/apps/tree/source/parameters.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tree)
(defparameter *debug?* nil)
| 915 | Common Lisp | .lisp | 22 | 39.136364 | 71 | 0.741826 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 719ec65c39d6910497c7b0c9869a2a924c0995338215fcb13189eab38d75f7fe | 35,925 | [
-1
] |
35,926 | lenses.lisp | lisp-mirror_gendl/apps/dom/plain-text/source/lenses.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-plain-text)
(defparameter *line-length* 72)
(define-lens (plain-text assembly) ()
:output-functions
((base
()
(dolist (chapter (list-elements (the :chapters)))
(write-the-object chapter (base))))))
(define-lens (plain-text section)()
:output-functions
((base
()
(write-env (:set-line-position 0)
(:set-newline-count 0))
(write-env (:newline-out)
(:newline-out)
(:a (the :heading-number))
" "
(:a (the :title))
(:newline-out)
(:newline-out))
(dolist (element (list-elements (the :elements)))
(write-the-object element (base))))))
(define-lens (plain-text marked-up-string)()
:output-functions
((base
()
(write-the :string (base)))))
(define-lens (plain-text item-list)()
:output-functions
((base
()
(write-env (:set-line-position 0)
(:set-newline-count 0))
(write-env (:newline-out)
(:newline-out)
"List Here"
(:newline-out)
(:newline-out)))))
(define-lens (plain-text figure)()
:output-functions
((base
())))
(define-lens (plain-text text-string)()
:output-functions
((base
()
(case (the :markup-tag)
(:verbatim
(write-env (:set-line-position 0))
(write-env (:newline-out)
(:newline-out)
(:a (the :data))
(:newline-out)
(:newline-out)))
(:index)
(otherwise
(let ((length (length (the :word-list)))
(count -1))
(dolist (word (the :word-list))
(if (eql word :newline)
(let ((new-value (1+ (write-env (:get-newline-count)))))
(write-env (:set-newline-count new-value))
(when (= new-value 2)
(write-env (:set-line-position 0)
(:newline-out)(:newline-out))))
(let ((word (case (the :markup-tag)
(:ref "??")
(otherwise word))))
(write-env (:set-newline-count 0))
(when (> (+ (write-env (:get-line-position))
(length word)) *line-length*)
(write-env (:newline-out)
(:set-line-position 0)))
(write-env (:a word))
(if (/= (incf count) length)
(write-env " ")
(write-env ""))
(let ((new-value (+ (write-env (:get-line-position)) (length word) 1)))
(write-env (:set-line-position new-value))))))))))))
| 3,149 | Common Lisp | .lisp | 100 | 26.65 | 79 | 0.623394 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7dfc0c4bd0076e187f7a544ce32e90c6c5e80c1172c732e37f768b7fd603af08 | 35,926 | [
-1
] |
35,927 | package.lisp | lisp-mirror_gendl/apps/dom/plain-text/source/package.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(gdl:define-package :com.genworks.dom-plain-text
(:use :com.genworks.dom :com.genworks.dom-writers))
| 977 | Common Lisp | .lisp | 23 | 41.043478 | 70 | 0.76 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d378ccdde5e58d3c7642f797ff713bca7153b577a34c1a790d99955ad527c9aa | 35,927 | [
-1
] |
35,928 | dom-writer.lisp | lisp-mirror_gendl/apps/dom/writers/source/dom-writer.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-writers)
(define-format dom-writer (base-format)
#|
:variables
((line-position 0)
(newline-count 0))
:methods
((:set-line-position
(value)
(setf (writer-variable line-position) value))
(:set-newline-count
(value)
(setf (writer-variable newline-count) value))
(:get-line-position
()
(writer-variable line-position))
(:get-newline-count
()
(writer-variable newline-count)))
|#
)
| 1,347 | Common Lisp | .lisp | 41 | 29.487805 | 70 | 0.724706 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 1182343252d78b04ca3db90db51e48d9483c8e48c98ef984efccff7217e4b96e | 35,928 | [
-1
] |
35,929 | package.lisp | lisp-mirror_gendl/apps/dom/writers/source/package.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(#+icad icad:def-icad-package
#-icad gdl:define-package :com.genworks.dom-writers
(:use :com.genworks.dom)
(:export plain-text latex html-write xml-write newline-count line-position))
| 1,074 | Common Lisp | .lisp | 25 | 41 | 77 | 0.761628 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 22c040007c1cba23303ea530c2f3e6905da61e3efdd9b71f8c06da950a9efdef | 35,929 | [
-1
] |
35,930 | html.lisp | lisp-mirror_gendl/apps/dom/writers/source/html.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-writers)
(define-format html-write (dom-writer))
| 928 | Common Lisp | .lisp | 22 | 40.909091 | 70 | 0.763858 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 9fab386f3bbe6e12183439bddc5bbf867d46233fccb7ecadd449e55e26643ae0 | 35,930 | [
-1
] |
35,931 | latex.lisp | lisp-mirror_gendl/apps/dom/writers/source/latex.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-writers)
(define-format latex (dom-writer))
| 923 | Common Lisp | .lisp | 22 | 40.681818 | 70 | 0.763657 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 8b445771a7cf12e3ecd0c2da0e58d339e0c6794b561897c0f1b6d7d4bac9893a | 35,931 | [
-1
] |
35,932 | plain-text.lisp | lisp-mirror_gendl/apps/dom/writers/source/plain-text.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-writers)
(define-format plain-text (dom-writer)) | 926 | Common Lisp | .lisp | 22 | 40.909091 | 70 | 0.763858 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 35d5a9104612a17d502b640f0f65d9802b10e8e38c2adfdc2bf4d5d3d09c272c | 35,932 | [
-1
] |
35,933 | package.lisp | lisp-mirror_gendl/apps/dom/latex/source/package.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(#+icad icad:def-icad-package
#-icad gdl:define-package :com.genworks.dom-latex
(:use :com.genworks.dom :com.genworks.dom-writers))
| 1,006 | Common Lisp | .lisp | 24 | 40.583333 | 70 | 0.759959 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 7eaa5871cf27473de9733769c84818e9bc8ca0fe42948a993b0381b22d272098 | 35,933 | [
-1
] |
35,934 | utilities.lisp | lisp-mirror_gendl/apps/dom/latex/source/utilities.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-latex)
(defun remove-keys (keys plist)
(let ((list (copy-list plist)))
(dolist (key keys list) (remf list key))))
#+nil
(defun replace-substring (string old new)
(let ((position (search old string)))
(if position
(string-append
(subseq string 0 position) new
(replace-substring (subseq string (+ position (length old))) old new))
string)))
(defun escape-string (string)
(replace-substring
(replace-substring
(replace-substring
(replace-substring
(replace-substring
(replace-substring string "#" "\\#") "$" "\\$") "_" "\\_") "^" "hat-") "&" "\\&") "%" "\\%"))
| 1,494 | Common Lisp | .lisp | 39 | 35.717949 | 100 | 0.706289 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 2e9ba510e4a18af54f3c463bfc042b9bbad5e5367498fb68d5a93e2058ece260 | 35,934 | [
-1
] |
35,935 | lenses.lisp | lisp-mirror_gendl/apps/dom/html/source/lenses.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.dom-html)
(defparameter *warn-on-unrecognized-tags?* t)
(publish-directory :prefix "/gdl/style/"
:destination (format nil "~a" (translate-logical-pathname "~/genworks/gwl-apps/training/g101/style/")))
(defparameter *index-hash* nil)
(defparameter *footnotes* nil)
(defparameter *footnotetext* nil)
(defparameter *debug-index* nil)
(define-lens (html-format assembly) ()
:output-functions
(
(main-sheet
()
(html
(:html (:head (:title (:princ (the title)))
(:body (:p (write-the contents))
(:p (write-the base)))))))
(base
()
(dolist (element (list-elements (the elements)))
(write-the-object element base)))
(cl-who-out
()
(with-cl-who ()
(:html (:head (:title (str (the title)))
((:link :href (the style-url) :rel "stylesheet" :type "text/css")))
(let ((*index-hash* (make-hash-table :test #'equalp))
(*footnotes* (make-array 50 :adjustable t :fill-pointer 0))
(*footnotetext* nil))
(htm
(:body (:div (write-the cl-who-contents-out))
(:div (write-the cl-who-base))
(when *footnotetext*
(htm (:div (:hr)
(dolist (elements *footnotetext*)
(htm (:p (dolist (element (list-elements elements))
(write-the-object element cl-who-base))))))))
(when (> (length *footnotes*) 0)
(htm (:div (write-the cl-who-footnotes))))
(:div (write-the cl-who-index))))))))
(cl-who-footnotes
()
(with-cl-who ()
(:p (:h2 "Footnotes"))
(loop for elements across *footnotes* as index upfrom 1
do (htm
(:p "[" (:a :name (format nil "FtNt~d" index) :href (format nil "#FtNtR~d" index)
(fmt "~d" index))
"] "
(dolist (element (list-elements elements))
(write-the-object element cl-who-base)))))))
(cl-who-index
()
(with-cl-who ()
(:p (:h2 "Index"))
(let* ((index-plist (list-hash *index-hash*))
(keys (sort (plist-keys index-plist) #'string-lessp)))
(htm (:ul
(dolist (key keys)
(dolist (target (gethash key *index-hash*))
(htm (:li ((:a :href (format nil "#~a" target)) (str key)))))))))))
(cl-who-base
()
(dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))
))
(define-lens (html-format yadd:assy)()
:output-functions
((cl-who-contents-out ())
(cl-who-out ())
(cl-who-base ())))
(define-lens (html-format base-document-component)()
:output-functions
((base ())
(contents
()
(html ((:a :href (format nil "#~a" (the label))) (:princ (the title)))
(:ol
(dolist (section (the sections-list))
(html (:li (write-the-object section contents)))))))
(cl-who-contents-out
()
(with-cl-who ()
((:a :href (format nil "#~a" (the label))) (str (the title)))
(:ol
(dolist (section (the sections-list))
(htm (:li (write-the-object section cl-who-contents-out)))))))
(cl-who-base ())))
(define-lens (html-format section)()
:output-functions
((base
()
(html ((:a :name (the label)))
(:h2 (:princ (the title)))
(dolist (element (list-elements (the elements)))
(write-the-object element base))))
(cl-who-base
()
(with-cl-who ()
((:a :name (the label)))
(:h2 (str (the title)))
(dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base))))))
(define-lens (html-format marked-up-string)()
:output-functions
((base
()
(print-messages markup-tag)
(case (the :markup-tag)
(:p (html (:p (dolist (element (list-elements (the :elements)))
(write-the-object element (:base))))))
(:define-object
(format t "Hey now")
(write-the yadd (find-object-doc (the (elements 0))) pretty-definition))
(:verbatim
(html (:pre
(dolist (element (list-elements (the :elements)))
(write-the-object element base)))))
(:emph (html (:i (dolist (element (list-elements (the :elements)))
(write-the-object element base)))))
(:texttt (html (:tt (dolist (element (list-elements (the :elements)))
(write-the-object element base)))))))
(cl-who-base
()
(with-cl-who ()
(case (the markup-tag)
(:p (htm (:p (dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base)))))
(:define-object
(let ((net.html.generator:*html-stream* *stream*))
(write-the yadd (find-object-doc (the (elements 0))) pretty-definition)))
(:verbatim
(htm (:pre
(dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))
((:emph :i) (htm (:i (dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))
((:textbf :b) (htm (:b (dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))
(:texttt (htm (:tt (dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))
(:underline (htm (:span :style "text-decoration: underline;"
(dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))
(:quote (htm (:blockquote (dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))
(:copyright (htm "©"))
(:rightarrow (htm "→"))
(:$ (htm "$"))
(:textgreater (htm ">"))
(:textasciitilde (htm "˜"))
((:index :indexed)
(dolist (element (list-elements (the elements)))
(let* ((data (the-object element data))
(anchor-tag (string (gensym))))
(push anchor-tag (gethash data *index-hash*))
(htm (:a :name anchor-tag))
(when (eq (the markup-tag) :indexed)
(write-the-object element cl-who-base)))))
(:footnote
(let ((index (1+ (vector-push-extend (the elements) *footnotes*))))
(htm (:a :name (format nil "FtNtR~d" index) :href (format nil "#FtNt~d" index)
(fmt "[~d]" index)))))
(:footnotetext
(push (the elements) *footnotetext*))
((:cite :href)
(let* ((args (list-elements (the elements)))
(target (the-object (car args) data)))
(htm (:a :href (if (eq (the markup-tag) :cite)
(format nil "#~a" target)
target)
(dolist (element (or (cdr args) args))
(write-the-object element cl-who-base))))))
;; :small and :tiny are always used as (:small (:verbatim ...)) and in most browsers,
;; verbatim is already small, so don't do anything.
((:no-op :small :tiny)
(dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))
(:include (dolist (element (list-elements (the elements)))
(let ((filename (the-object element data)))
(when (and (> (length filename) 8)
(string= filename "~/gendl/" :end1 8))
(setq filename (merge-pathnames (subseq filename 8)
(asdf:system-source-directory :gendl))))
(with-open-file (s filename)
(let ((buffer (make-string (file-length s))))
(read-sequence buffer s)
(htm (esc buffer)))))))
(otherwise (when *warn-on-unrecognized-tags?*
(warn "Markup tag ~s was not recognized~%" (the markup-tag))))
)))))
(define-lens (html-format item-list)()
:output-functions
((:base
()
(ecase (the style)
(:itemize (html (:ul (dolist (element (list-elements (the :elements)))
(write-the-object element (:base))))))
(:enumerate (html (:ol (dolist (element (list-elements (the :elements)))
(write-the-object element (:base))))))
(:description (html (:dl (dolist (element (list-elements (the :elements)))
(write-the-object element (:base))))))))
(cl-who-base
()
(with-cl-who ()
(ecase (the style)
(:itemize (htm (:ul (dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base)))))
(:enumerate (htm (:ol (dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base)))))
(:description (htm (:dl (dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base))))))))))
(define-lens (html-format item-list-item)()
:output-functions
((base
()
(if (typep (the word) 'null-part)
(html (:li
(dolist (element (list-elements (the :elements)))
(write-the-object element (:base)))))
(html (:dt (write-the word base))
(:dd (dolist (element (list-elements (the :elements)))
(write-the-object element (:base)))))))
(cl-who-base
()
(with-cl-who ()
(if (typep (the word) 'null-part)
(htm (:li
(dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base))))
(htm (:dt (write-the word cl-who-base))
(:dd (dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base)))))))))
(define-lens (html-format figure)()
:output-functions
((base
()
(html (:p (:table (:tr (:td (ecase (the style)
(:image-figure (html "Image Goes Here"))
(:boxed-figure (dolist (element (list-elements (the :elements)))
(write-the-object element (:base)))))))
(:tr (:td (:i (:princ (the caption)))))))))
(cl-who-base
()
(with-cl-who ()
(:p (:table (:tr (:td (ecase (the style)
(:image-figure
(htm (:img :src (let* ((image-file (if (stringp (the image-file))
(concatenate 'string "images/" (the image-file))
(namestring (the image-file))))
(png-file (when (string-equal (pathname-type image-file) "pdf")
(make-pathname :type "png" :defaults image-file))))
(when png-file
(uiop:run-program
(list (format nil "~a" *gs-path*)
"-q"
(format nil "-sDEVICE=~a" "png256")
(format nil "-sOutputFile=~a" png-file)
(format nil "-dTextAlphaBits=~a" *gs-text-alpha-bits*)
(format nil "-dGraphicsAlphaBits=~a" *gs-graphics-alpha-bits*)
"-dSAFER"
"-dBATCH"
"-dNOPAUSE"
image-file))
;;(uiop:copy-file png-file (merge-pathnames (file-namestring png-file) "~/tmp/images/"))
)
(namestring (merge-pathnames (file-namestring (or png-file image-file)) "images/")))
:style (format nil "width:~a;height:~a;" (the width) (the height))
:alt (the caption))))
(:boxed-figure (dolist (element (list-elements (the :elements)))
(write-the-object element cl-who-base))))))
(:tr (:td (:i (:princ (the caption)))))))))))
(define-lens (html-format blockquote) ()
:output-functions
((cl-who-base
()
(with-cl-who ()
(:blockquote (dolist (element (list-elements (the elements)))
(write-the-object element cl-who-base)))))))
(define-lens (html-format text-string)()
:output-functions
((base () (html (:princ-safe (the data))))
(cl-who-base () (with-cl-who () (esc (the data))))))
| 12,809 | Common Lisp | .lisp | 303 | 33.356436 | 108 | 0.569701 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 058172d52cfe5e2a810c9790841248818a73b42a273e86f1d16ef7cec2d01e58 | 35,935 | [
-1
] |
35,936 | package.lisp | lisp-mirror_gendl/apps/dom/html/source/package.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(gwl:define-package :com.genworks.dom-html
(:export #:*warn-on-unrecognized-tags?*)
(:use :cl-who :com.genworks.dom :com.genworks.dom-writers))
| 1,023 | Common Lisp | .lisp | 24 | 41.083333 | 70 | 0.753012 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | cfc226f9da2207e9669eed64f5bde1aadfee90089605876a6c8a8374c5a89372 | 35,936 | [
-1
] |
35,937 | assembly.lisp | lisp-mirror_gendl/apps/dom/test-parts/source/assembly.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(defparameter *assembly*
`((:document :title "Test Document"
:author "David J. Cooper Jr."
:company "Genworks International"
:date "January, 2001"
:textwidth 6.5
:textheight 8.5
:topmargin 0
:oddsidemargin 0
:evensidemargin 1.0
:class :article)
((:section :title "Executive Summary")
"This is a high-level "
(:emph "executive summary")
" of the whole paper.")
((:section :title "Sample List")
((:list :style :description)
((:item :word "Scope and Requirements")
"We currently know only a small portion of the required functions of the
system. We will only discover the full range of requirements with some initial deployment
and user feedback.")
((:item :word "Technology Landscape")
"The IT landscape changes constantly, different solutions vendors,
operating system platforms, programming languages, database systems, etc, constantly
vying for advantage. Along with this, various Corporate-wide ``one size fits all''
initiatives promise far-reaching solutions but lack the flexibility to meet all
specific needs in a timely and responsive manner."))
((:list :style :itemize)
(:item "Do start building a prototype system.")
(:item "Use only stable, well-defined technologies"))
((:list :style :enumerate)
(:item "Do start building a prototype system.")
(:item "Use only stable, well-defined technologies")))))
| 2,438 | Common Lisp | .lisp | 54 | 39.462963 | 90 | 0.694362 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d75126fc6e6c94dc384a7446ca2a01ca1842f8c72ce0cde1597768c8640be3d0 | 35,937 | [
-1
] |
35,938 | package.lisp | lisp-mirror_gendl/apps/dom/base/source/package.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(gwl:define-package :com.genworks.dom (:export #:base-document-component #:assembly #:section
#:marked-up-string
#:blockquote #:item-list #:item-list-item
#:description-title #:description-body
#:text-string #:figure #:rendered-figure
#:tag))
| 1,177 | Common Lisp | .lisp | 27 | 40.074074 | 94 | 0.719268 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e1d7b6357630ed3be71d245051052502913b9c2ef44e776cf10ffa69933c27f5 | 35,938 | [
-1
] |
35,939 | new-inspector.lisp | lisp-mirror_gendl/apps/tasty/source/new-inspector.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
#|
(in-package :tasty)
(defmacro ignore-errors-with-warning (&rest body)
(let ((values (gensym))
(error (gensym)))
`(let* ((,values (multiple-value-list (ignore-errors ,@body)))
(,error (second ,values)))
(if (and ,error (typep ,error 'error))
(progn (warn "~a" ,error)
(format nil "! ERROR: ~a !" ,error))
(apply #'values ,values)))))
(defun one-line (string)
(replace-regexp* (replace-regexp* string (format nil "~%") " ") "'" "\\'" ))
(defparameter *suppress-%%-messages?* t)
;;
;; FLAG -- replace with abstract associative map
;;
(defparameter *internal-keywords*
(list :query-plist :aggregate :all-mixins :background-color
:base64-encoded-root-path :bashee :beziers :bounding-bbox
:check-sanity? :color-decimal :color-hex :color-palette :cookies-received
:cookies-to-send :dash-pattern :dom-id :fill-color-decimal
:fixed-url-prefix :header-plist :home-page :instance-id
:last-visited-root-path :left-handed? :local-bbox :local-box
:local-center :local-left-handed? :local-orientation :main-view
:obliqueness :parent-tree :plain-url? :possible-nils
:quantify-box :query-toplevel :refresh-toggle :remote-id :respondent
:return-object :root-path-string :target :time-instantiated
:time-last-touched :transitory-slots :tree-root
:url-encoded-root-path :use-local-box? :viewable-slots
:viewpoints :visible-children :vrml-center))
(define-object new-inspector (sheet-section) ;;(base-html-sheet)
:input-slots
((node-root-path nil :settable)
root-object
tree-toplevel
tatu-root colors-default tree-type tree-node
display-controls-hash
perform-action-function click-mode
(relative-font-size "-1")
(js-to-eval "initInspectorTable();") ;; FLAG -- SvdE @ 090909 -- added slot to attach js for behavior inspector table
(node (when (the root-object) (the root-object (follow-root-path (the node-root-path)))))
(expand? (< (the depth) 1) :settable)
(depth 0)
)
:computed-slots
(
(show-settables? nil :settable)
(messages-local (set-difference (the node (message-list :message-type :local))
(append (the node (message-list :message-type :local
:category :methods))
(the node (message-list :message-type :local
:category :uncached-attributes)))))
#+nil
(messages (the (filter-messages
(set-difference (the :node (:message-list))
(append (the
:node
(:message-list :category :methods))
(the :node (:message-list
:category
:uncached-attributes)))))))
(message-category-list (the :node (:message-list :return-category? t)))
(message-local-list (the :node (:message-list :message-type :local)))
(message-list (the :node (:message-list)))
(category-list (let (result)
(dolist (entry (the message-category-list) (nreverse result))
(if (not (member entry (the message-list)))
(push entry result)))))
(type-list (let (result)
(dolist (entry (the message-list) (nreverse result))
(if (member entry (the message-local-list))
(push :local result)
(push :global result)))))
(message-triplets ;;message-category-type
(mapcar #'list
(the message-list)
(the category-list)
(the type-list)))
(messages-to-be-filtered (append (the :node (:message-list :category :methods))
(the :node (:message-list :category :uncached-attributes))))
(semi-filtered-message-triplets ;;message-category-type
(let (result)
(dolist (triplet (the message-triplets) (nreverse result))
(if (equal (member (first triplet) (the messages-to-be-filtered)) nil)
(push triplet result)))))
(filtered-message-triplets ;;message-category-type
(the (filter-messages (the semi-filtered-message-triplets))))
(check-links nil :settable)
(main-view
(with-cl-who-string ()
(if (the node)
(str (the inspector-node-view))
(str "No Object Instantiated"))))
(inspector-node-view
(with-cl-who-string ()
;; header first, conforming jquery ui style framework
((:div :class "header ui-widget-header")
(str (the node strings-for-display)))
;;(esc (format nil "~s" (cons 'the (reverse (butlast (the node-root-path))))))
;;(unless (butlast (the node-root-path))
;;(htm " Root Object")))
;;
;;FLAG -- SvdE @ 090909 -- Removed (the node type), now available in normal slot table
;;
#+nil
((:div :class "header")
((:span :class "ui-icon ui-icon-tag fltlft" :title "this Object is of type ..."))
"type: "(esc (format nil "~s" (the node type))))
;; rest of the inspector below, inside an UL/LI list, with tables for prop-value
;; all conforming ui style framework
;;((:ul :id "inspector-root" :class "tasty-inspector") ;;"tasty-inspector")
;; ((:li)
;;
;; FLAG 090908-JB: removing this arbitrary display code from the inspector for now
;;
((:table :class "inspector-table")
((:thead)
(:tr
(:th "slot-name")
(:th "value")
(:th "slot-category")
(:th "slot-type")
))
((:tbody)
;;
;; FLAG -- SvdE @ 090909 -- remove separate table for settable slots
;;
#+nil
((:tr :class "odd")
(:td (:span :class "ui-icon ui-icon-pencil"))
(:td "Settables")
(:td (str (the settables-form main-div)))
(:td "__global__")
)
;;
;; FLAG 090908-JB: this is old code from that builds the table
;;
(let ((count 1))
(dolist (inspector-node (list-elements (the nodes)))
(let ((message (the-object inspector-node message)))
(incf count)
(htm ((:tr :class (if (evenp count) "even" "odd"))
(:td (str (the-object inspector-node message)))
(:td
;;
;; FLAG -- push everything to do with node into inspector-node
;;
(let ((slot-status (if (the expand?) (the node (slot-status message)) :unbound)))
(case slot-status
(:unbound
(htm ((:span :style "color: blue; font-style: italic; cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :message-evaluate
:arguments (list message))))
"Unbound")))
(otherwise
(if (the-object inspector-node settable?)
(str (the-object inspector-node input-field html-string))
#+nil
(htm ((:input :type :text
:name (base64-encode-safe (string message))
:value (the-object inspector-node value)
)))
;;:onchange
;; (the (gdl-ajax-call :function-key :evaluate-slot
;; :arguments (list ))))
(str (the-object inspector-node value-display)))))))
(:td (str (the-object inspector-node message-category)))
(:td (str (the-object inspector-node message-type))))))))))
))
)
:hidden-objects
((nodes :type 'inspector-node
:depth (1+ (the depth))
:sequence (:size (length (the filtered-message-triplets)));;(length (the messages)))
:respondent (the respondent)
:message (first (nth (the-child index) (the filtered-message-triplets)));;(nth (the-child index) (the messages))
:message-category (second (nth (the-child index) (the filtered-message-triplets)))
:message-type (third (nth (the-child index) (the filtered-message-triplets)))
:parent-node (the node)
:pass-down (
tatu-root root-object
tree-toplevel tatu-root colors-default
tree-type tree-node display-controls-hash
perform-action-function click-mode relative-font-size))
(settables-form :type 'settables-form
:pass-down (show-settables?)))
:functions
(
(filter-messages
(message-triplets-list)
(safe-sort
(remove-if
#'(lambda (triplet)
(or (member (first triplet) *internal-keywords*)
(and *suppress-%%-messages?*
(let ((string (string (first triplet))))
(and
(> (length string) 2)
(or (string-equal (subseq string 0 2) "$$")
(and (eql (aref string 0) #\%)
(or (eql (aref string 1) #\%)
(eql
(aref string (1- (length string)))
#\%)))))))))
message-triplets-list)
#'string<
:key #'(lambda(triplet) (first triplet))))
(perform-action!
(object)
(the tatu-root (perform-action! object)))
(message-evaluate
(message)
;;
;; FLAG -- note we have to bash the view-toggle because no bashing
;; is actually happening when we evaluate the message, so the view
;; does not update by itself.
;;
(the toggle-view-toggle!)
(the (set-slot! :expand? t))
(multiple-value-bind (value error) (ignore-errors (the node (evaluate message)))
(let* ((error? (and error (typep error 'error))) (value (if error? (format nil "ERROR: ~a" error) value)))
(when error? (the node (set-slot! message value))))))
(set-object! (object) (the (set-slot! :node-root-path (the-object object root-path))))))
(define-object inspector-node (new-inspector)
:input-slots ((message nil)
(message-type nil)
(message-category nil)
;;
;; FLAG -- SvdE @090909 -- is :settable-optional-input-slots the correct category? ta2 inspector used required-input-slots
;;
(settable? (if (equal (the message-category) :settable-optional-input-slots) t nil))
parent-node
root-object
tatu-root
click-mode
(value (with-error-handling () (the parent-node (evaluate (the message))))))
:computed-slots ((value-type (if (the 3d-vector?)
:gdl-3d-point
(typecase (the value)
(list (when (consp (the value)) :list))
(gdl::quantification :gdl-sequence)
(gdl::gdl-basis :gdl-atom))))
(value-cardinality (case (the value-type)
(:list (length (the value)))
(:gdl-sequence (the value number-of-elements))
(otherwise 0)))
(truncated-sequence (unless (zerop (the value-cardinality))
(with-output-to-string (ss)
(let ((*print-length* 3))
(pprint (the value) ss)))))
(expanded? nil :settable)
(clickable? (and (not (the expanded?))
(or (member (the value-type)
(list :list :gdl-sequence :gdl-atom))
(and (eql (the value-type) :gdl-3d-point)
(member (the click-mode)
(list :add-leaves
:add-leaves*
:add-node
:draw-leaves
:draw-node
:delete-leaves))))))
(3d-vector? (and (typep (the value) 'vector)
(= (length (the value)) 3)
(every #'floatp (the value))))
(value-display
(let* ((value (the value))
(gdl-object? (eql (class-of (class-of value))
(find-class 'gdl-class))))
(with-cl-who-string ()
((:span :style (format nil "color: ~a; ~a"
(if (the clickable?) "blue" "black")
(if (the clickable?) "cursor: pointer;" ""))
:onclick (case (the value-type)
(:gdl-atom
(the (gdl-ajax-call
:function-key :perform-action!
:arguments (list value))))
(:gdl-3d-point
(print-variables (the clickable?)
(the click-mode))
(when (the clickable?)
(the (gdl-ajax-call
:function-key :perform-action!
:arguments (list (the point))))))
((:list :gdl-sequence)
(unless (the expanded?)
(the (gdl-ajax-call
;;:bashee self
:function-key :set-slot!
:arguments (list :expanded? t)))))))
(cond ((or (eql (the value-type) :list)
(eql (the value-type) :gdl-sequence))
(if (the expanded?)
(htm ((:table :border 1)
(:tr (:td ((:span :style "color: blue; cursor: pointer;"
:onclick (the (gdl-ajax-call
:function-key :set-slot!
:arguments (list :expanded? nil))))
"X"))
(:td (str
(ecase (the value-type)
(:list "A List")
(:gdl-sequence "A GDL Sequence")))))
(let ((index -1))
(dolist (row (list-elements (the sequence-elements)))
(htm (:tr (:td (str (incf index)))
(:td (str (the-object row value-display)))))))))
(htm (:pre (esc (the truncated-sequence))))))
(gdl-object? (htm (esc (format nil "~s" value))))
((eql (the value-type) :gdl-3d-point)
(htm (esc (the point strings-for-display))))
(t (htm (fmt "~s" value)))))))))
:objects ((point :type (if (the 3d-vector?) 'point 'null-object)
:center (when (the 3d-vector?) (the value))
:strings-for-display (format nil "~s" (the value)))
(sequence-elements :type 'inspector-node
:sequence (:size (the value-cardinality))
:pass-down (root-object tatu-root click-mode)
:value (the (get-value-element (the-child index)))))
:hidden-objects
(
(input-field :type 'text-form-control
:hidden? nil
:onchange (the (gdl-ajax-call :function-key :evaluate-input-field!
:arguments (list (the-child value))))
;;(the (set-slot! :value (the-child value)));;
;;(the (gdl-ajax-call :form-controls (the-child)))
;;:onfocus (the-child onchange)
:prompt nil
:default (the value)
:size 20)
)
:functions
(
;;
;; FLAG! --SvdE @ 090909 Does not work correctly
;;
(evaluate-input-field!
(input-value)
(the inspector node (set-slot! (the message) input-value)))
(get-value-element
(index)
(case (the value-type)
(:list (nth index (the value)))
(:gdl-sequence (the value (get-member index)))))))
(define-object settables-form (base-html-sheet)
:input-slots
(show-settables?))
(define-lens (html-format settables-form)()
:output-functions
((inner-html
()
(with-cl-who ()
(htm
((:span :style "cursor: pointer; color: blue; font-style: oblique;"
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-settables? (not (the show-settables?))))))
(str (if (the show-settables?) "X" "Show Settables!"))))))))
(define-object viewable-link (base-html-sheet)
:input-slots (node message)
:computed-slots ((strings-for-display (format nil "~a" (the message))))
:functions
((before-present!
()
(ignore-errors-with-warning (the node (evaluate (the message)))))))
(define-lens (html-format viewable-link)()
:output-functions
((main-sheet () (write-the return-object main-sheet))))
(define-object switch-viewables (base-html-sheet)
:input-slots
(return-object)
:computed-slots
((show-viewables? nil :settable)
(strings-for-display (if (the show-viewables?) "X" "Uncached Slots")))
:functions
((before-present! () (the (set-slot! :show-viewables? (not (the show-viewables?)))))))
(define-lens (html-format switch-viewables)()
:output-functions
((main-sheet () (write-the return-object main-sheet))))
|#
| 16,421 | Common Lisp | .lisp | 402 | 32.922886 | 125 | 0.611898 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 662d2574908a00885e4fee655785d4290dd3a382a8e35ab68066a5ed4dc09782 | 35,939 | [
-1
] |
35,940 | package.lisp | lisp-mirror_gendl/apps/tasty/source/package.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(gwl:define-package :tasty
(:documentation #.(glisp:system-description :tasty))
(:export #:assembly #:viewport #:inspector #:status-object #:menu-section #:*use-bsplines-for-vrml?*
#:*suppress-%%-messages?* #:*suppress-$$-messages?*))
| 1,158 | Common Lisp | .lisp | 25 | 43.44 | 103 | 0.728 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 94b77b88c3df0142e8c64538aae775649a542f4bec03b5b4e52b00d464b2ab31 | 35,940 | [
-1
] |
35,941 | part-type-form.lisp | lisp-mirror_gendl/apps/tasty/source/part-type-form.lisp | ;;
;; Copyright 2014 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(define-object part-type-form (base-html-sheet)
:input-slots
((object-type "robot:assembly" :settable)
make-instance-function set-root-function tatu-root package-default)
:computed-slots
(
(object-expression "" :settable)
(respondent (the tatu-root)))
:functions
((after-set!
()
(cond ((not (string-equal (the object-type) ""))
(funcall (the make-instance-function) (the object-type))
(the root-object-object update!))
((not (string-equal (the object-expression) ""))
(funcall (the set-root-function)
(let ((*package* (find-package (the package-default))))
(eval (read-safe-string (the object-expression))))))))))
(define-lens (html-format part-type-form)()
:output-functions
((main-sheet
()
(with-cl-who ()
(with-html-form ()
(:table (:tr ((:td :colspan 2 :align :center)
(:h3 "Specify object package and type, or an expression which returns an object.")
(:i "Default Package: the "
(:princ-safe (package-name (find-package (the package-default)))) " Package")))
(:tr ((:td :bgcolor (gethash :gold-bright *color-table*)) (:b "Class Package:Type"))
(:td ((:input :type :string :name :object-type :size 40 :value (the object-type)))))
(:tr ((:td :bgcolor (gethash :gold-bright *color-table*)) (:b "Object Expression"))
(:td ((:input :type :string :name :object-expression :size 40 :value
(the object-expression)))))
(:tr (:td :br) (:td ((:input :type :submit :name :submit :value " Browse!"))))))))))
(defparameter *test-self* nil)
(define-object required-inputs-form (base-html-sheet)
:input-slots
(root-object tatu-root)
:computed-slots
((respondent (the tatu-root))
(required-input-slots (the root-object (message-list :category :required-input-slots)))
(satisfied-toggle nil :settable)
(satisfied? (progn (the satisfied-toggle)
(let ((result t))
(dolist (slot (the required-input-slots))
(let ((status (the root-object (slot-status slot))))
(when (eql status :unbound) (setq result nil))))
result))))
:objects
((required-input-inputs :type 'text-form-control
:sequence (:size (length (the required-input-slots)))
:pseudo-inputs (keyword)
:size 20
:domain :pass-thru
:keyword (nth (the-child index)(the required-input-slots))
:default :unbound
:prompt (the-child keyword)))
:functions
(
(after-set!
()
(setq *test-self* (the root-object))
(format t "In the after-set! of the required-inputs-form...~%")
(dolist (slot (list-elements (the required-input-inputs)))
(unless (eql (the-object slot value) :unbound)
(the root-object (set-slot! (the-object slot keyword)
(the-object slot value)))))
(the (set-slot! :satisfied-toggle (not (the satisfied-toggle)))))))
(define-lens (html-format required-inputs-form)()
:output-functions
((main-sheet
()
(with-cl-who ()
(with-html-form (:cl-who? t)
(dolist (slot (list-elements (the required-input-inputs)))
(htm (:p (str (the-object slot html-string)))))
(:p ((:input :type :submit :name :submit :value " Browse!"))))))))
| 4,198 | Common Lisp | .lisp | 98 | 37.081633 | 93 | 0.655437 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a7c90c207dcce8d29b11195ea3ceea6cf49f49beebd6d61ebccc7558c4d008bd | 35,941 | [
-1
] |
35,942 | inspector.lisp | lisp-mirror_gendl/apps/tasty/source/inspector.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(defmacro ignore-errors-with-warning (&rest body)
(let ((values (gensym))
(error (gensym)))
`(let* ((,values (multiple-value-list (ignore-errors ,@body)))
(,error (second ,values)))
(if (and ,error (typep ,error 'error))
(progn (warn "~a" ,error)
(format nil "! ERROR: ~a !" ,error))
(apply #'values ,values)))))
;;
;; FLAG -- promote to utilities.
;;
(defun one-line (string)
(glisp:replace-regexp (glisp:replace-regexp string (format nil "~%") " ") "'" "\\'" ))
(defparameter *suppress-%%-messages?* t "Boolean. Set to nil if you want to see messages starting and ending with %% in tasty inspector. Defaults to t.")
(defparameter *suppress-$$-messages?* t "Boolean. Set to nil if you want to see messages starting with $$ in tasty inspector. Defaults to t.")
;;
;; FLAG -- replace with abstract associative map
;;
(defparameter *internal-keywords*
(list :query-plist :aggregate :all-mixins :background-color
:base64-encoded-root-path :bashee :beziers :bounding-bbox
:check-sanity? :color-decimal :color-hex :color-palette :cookies-received
:cookies-to-send :dash-pattern :dom-id :fill-color-decimal
:fixed-url-prefix :header-plist :home-page :instance-id
:last-visited-root-path :left-handed? ;;:local-bbox :local-box
:local-center :local-left-handed? :local-orientation :inner-html
:obliqueness :parent-tree :plain-url? :possible-nils
:quantify-box :query-toplevel :refresh-toggle :remote-id :respondent
:return-object :root-path-string :target :time-instantiated
:time-last-touched :transitory-slots :tree-root
:url-encoded-root-path :use-local-box? :viewable-slots
:viewpoints :visible-children :vrml-center))
(define-object inspector (base-html-sheet)
:input-slots
((node-root-path nil :settable)
root-object
tree-toplevel
tatu-root colors-default tree-type tree-node
display-controls-hash
perform-action-function click-mode
(relative-font-size "-1")
(node (when (the root-object) (the root-object (follow-root-path (the node-root-path)))))
(expand? (< (the depth) 1) :settable)
(depth 0)
)
:computed-slots
(
(show-settables? nil :settable)
(messages-local (set-difference (the node (message-list :message-type :local))
(append (the node (message-list :message-type :local
:category :methods))
(the node (message-list :message-type :local
:category :uncached-attributes)))))
(messages (safe-sort
(remove-if
#'(lambda (keyword)
(or (member keyword *internal-keywords*)
(and *suppress-$$-messages?*
(let ((string (string keyword)))
(and
(> (length string) 2) (string-equal (subseq string 0 2) "$$"))))
(and *suppress-%%-messages?*
(let ((string (string keyword)))
(and
(> (length string) 2)
(and (eql (aref string 0) #\%)
(or (eql (aref string 1) #\%)
(eql
(aref string (1- (length string)))
#\%))))))))
(set-difference (the :node (:message-list))
(append (the
:node
(:message-list :category :methods))
(the :node (:message-list
:category
:uncached-attributes)))))
#'string<))
(check-links nil :settable))
:hidden-objects
((values :type 'value-inspector
:depth (1+ (the depth))
:sequence (:size (length (the messages)))
:respondent (the respondent)
:message (nth (the-child index) (the messages))
:parent-node (the node)
:pass-down (
tatu-root root-object
tree-toplevel colors-default
tree-type tree-node display-controls-hash
perform-action-function click-mode relative-font-size))
(settables-form :type 'settables-form
:pass-down (show-settables? node tatu-root)))
:functions
(
(visit-definition-in-emacs
(definition)
(declare (ignore definition))
(error "Sorry! This is supposed to do 'lisp-find-definition' in emacs, but not working yet... Please send email to [email protected]"))
#+nil
(visit-definition-in-emacs
(definition)
(let ((emacs-lisp-command (format nil "(fi:lisp-find-definition ~s)" definition)))
(print-variables emacs-lisp-command)
#+allegro (lep::eval-in-emacs emacs-lisp-command)))
#+nil
(perform-action!
(object)
(the tatu-root (perform-action! object)))
(message-evaluate
(message)
;;
;; FLAG -- note we have to bash the view-toggle because no bashing
;; is actually happening when we evaluate the message, so the view
;; does not update by itself.
;;
(the toggle-view-toggle!)
(the (set-slot! :expand? t))
(ignore-errors-with-warning (the node (evaluate message)))
#+nil
(multiple-value-bind (value error) (ignore-errors (the node (evaluate message)))
(let* ((error? (and error (typep error 'error)))
(value (if error? (format nil "ERROR: ~a" error) value)))
(when error? (the node (set-slot! message value))))))
(set-object! (object) (the (set-slot! :node-root-path (the-object object root-path))))))
(define-lens (html-format inspector)()
:output-functions
((inner-html
()
(with-cl-who ()
(if (the node)
(write-the inspector-body)
(htm "No Object Instantiated"))))
(inspector-body
()
(with-cl-who ()
(:center
((:span :style "font-style: italic; font-weight: bold;")
(:p "Inspecting: "
(fmt "\"~a\"" (the node strings-for-display))
:br
"root-path: "
(esc (format nil "~s"
(cons 'the (reverse (butlast (the node-root-path))))))
(unless (butlast (the node-root-path))
(htm " [the root object]"))
:br
" type: " ((:span :style "color: blue; cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :visit-definition-in-emacs
:arguments (list (format nil "~s" (the node type))))))
(esc (format nil "~s" (the node type)))))))
((:table :class "inspector-table" :border 1)
(:tr (:td "Settables") (:td (str (the settables-form control-view))))
(when (the settables-form show-settables?)
(htm (:tr ((:td :colspan 2)
(str (the settables-form inner-html))))))
(let ((count -1))
(dolist (value-inspector (list-elements (the values)))
(let ((message (the-object value-inspector message)))
(incf count)
(htm (:tr
(:td (str (the-object value-inspector message)))
(:td
;;
;; FLAG -- push everything to do with node into value-inspector
;;
(let ((slot-status (if (the expand?)
(the node (slot-status message)) :unbound)))
(case slot-status
(:unbound
(htm ((:span :style "color: blue; font-style: italic; cursor: pointer;"
:onclick (the (gdl-ajax-call
:function-key :message-evaluate
:arguments (list message))))
"Unbound")))
(otherwise (str (the-object value-inspector value-display))))))))))))))))
(define-object value-inspector (inspector)
:input-slots ((message nil)
parent-node
root-object
tatu-root
click-mode
(value (with-error-handling ()
(the parent-node (evaluate (the message))))))
:computed-slots
((value-root-path (cons (the message) (the parent-node root-path)))
(value-type (if (the 3d-vector?)
:gdl-3d-point
(typecase (the value)
(list (when (consp (the value)) :list))
(gdl::quantification :gdl-sequence)
(gdl::gdl-basis (when (eql (the value root) (the node root)) :gdl-atom)))))
(value-cardinality (case (the value-type)
(:list (length (the value)))
(:gdl-sequence (the value number-of-elements))
(otherwise 0)))
(truncated-sequence (unless (zerop (the value-cardinality))
(with-output-to-string (ss)
(let ((*print-length* 3))
(pprint (the value) ss)))))
(expanded? nil :settable)
(clickable? (and (not (the expanded?))
(or (member (the value-type)
(list :list :gdl-sequence :gdl-atom))
(and (eql (the value-type) :gdl-3d-point)
(member (the click-mode)
(list :add-leaves
:add-leaves*
:add-node
:draw-leaves
:draw-node
:delete-leaves))))))
(3d-vector? (and (typep (the value) 'vector)
(= (length (the value)) 3)
(every #'floatp (the value))))
(value-display
(ignore-errors-with-warning
(let* ((value (the value))
(gdl-object? (or (eql (class-of (class-of value))
(find-class 'gdl-class))
(let ((printed (with-output-to-string (ss) (print-object value ss))))
(and (>= (length printed) 2)
(eql (aref printed 0) #\#)
(eql (aref printed 1) #\<))))))
(with-cl-who-string ()
((:span :style (format nil "color: ~a; ~a"
(if (the clickable?) "blue" "black")
(if (the clickable?) "cursor: pointer;" ""))
:onclick (case (the value-type)
(:gdl-atom
(the (gdl-ajax-call
:bashee (the tatu-root)
:function-key :perform-action!
:arguments
(list nil
:tasty-root (the tatu-root)
:root-object-rootpath (the value root-path)))))
(:gdl-3d-point
(when (the clickable?)
(the (gdl-ajax-call
:function-key :perform-action!
;;:arguments (list (the point))
:arguments (let ((object (make-object 'gdl::root-path-container
:root-path (the value-root-path))))
(list object))))))
((:list :gdl-sequence)
(unless (the expanded?)
(the (gdl-ajax-call
;;:bashee self
:function-key :set-slot!
:arguments (list :expanded? t)))))))
(cond ((or (eql (the value-type) :list)
(eql (the value-type) :gdl-sequence))
(if (the expanded?)
(htm ((:table :border 1)
(:tr
(:td ((:span :style "color: blue; cursor: pointer;"
:onclick (the (gdl-ajax-call
:function-key :set-slot!
:arguments (list :expanded? nil))))
"X"))
(:td (str
(ecase (the value-type)
(:list "A List")
(:gdl-sequence "A GDL Sequence")))))
(let ((index -1))
(dolist (row (list-elements (the sequence-elements)))
(htm (:tr (:td (str (incf index)))
(:td (str (the-object row value-display)))))))))
(htm (:pre (esc (the truncated-sequence))))))
(gdl-object? (htm (esc (format nil "~s" value))))
#+nil
((eql (the value-type) :gdl-3d-point)
(htm (esc (the point strings-for-display))))
((eql (the value-type) :gdl-3d-point)
(htm (esc (format nil "~s" value))))
(t (htm (fmt "~s" value))))))))))
:objects (
#+nil
(point :type (if (the 3d-vector?) 'point 'null-object)
:center (when (the 3d-vector?) (the value))
:strings-for-display (format nil "~s" (the value)))
(sequence-elements :type 'value-inspector
:sequence (:size (the value-cardinality))
:pass-down (root-object tatu-root click-mode)
:value (the (get-value-element (the-child index)))))
:functions
((get-value-element
(index)
(case (the value-type)
(:list (nth index (the value)))
(:gdl-sequence (the value (get-member index)))))))
(define-object settables-form (base-html-sheet)
:input-slots
(show-settables? node tatu-root)
:computed-slots
((settables
(let (settables)
(maphash #'(lambda(key val)(declare (ignore val))
(push key settables))
(the node %settable-slots%))
(nconc settables (the node (message-list :category :required-input-slots)))
(sort (remove-if
#'(lambda (keyword)
(or (member keyword *internal-keywords*)
(and *suppress-%%-messages?*
(let ((string (string keyword)))
(or (and (> (length string) 2)
(string-equal (subseq string 0 2) "$$"))
(and (eql (aref string 0) #\%)
(or (eql (aref string 1) #\%)
(eql
(aref string (1- (length string)))
#\%))))))
(let ((value (with-error-handling ()
(the node (evaluate keyword)))))
(or (eql (class-of (class-of value)) (find-class 'gdl-class))
(and (consp value)
(some #'(lambda(item) (eql (class-of (class-of item))
(find-class 'gdl-class)))
value))))))
settables) #'string<)))
(respondent (the tatu-root))
(control-view (with-cl-who-string ()
((:span :style "cursor: pointer; color: blue; font-style: oblique;"
:onclick (the (gdl-ajax-call
;;:respondent (the tatu-root)
:bashee self
:function-key :set-slot!
:arguments (list :show-settables? (not (the show-settables?))))))
(if (the show-settables?) (htm "X") (htm "Show Settables!")))))
(form-fields-hash (let ((ht (make-hash-table)))
(dolist (form-field (list-elements (the form-fields)) ht)
(setf (gethash (the-object form-field field-name) ht) form-field)))))
:hidden-objects ((reset-buttons :type 'button-form-control
:sequence (:size (length (the settables)))
:label "R"
:onclick (the (gdl-ajax-call
:function-key :restore-default-values!
:arguments (list (the (form-fields (the-child index))
keyword)))))
(submit-fields-button :type 'button-form-control
:label " OK "
:onclick nil)
(form-fields :type 'text-form-control
:pseudo-inputs (keyword)
:sequence (:size (length (the settables)))
;;
;; FLAG -- precompute this in a slot, and allow for unbound until clicked. ;;
:size (length (format nil "~s" (the-child default)))
:validation-function
#'(lambda(value)
(progn
(the node (set-slot-if-needed!
(the-child keyword) value :infer-types? nil))
(the tatu-root refresh-tasty-panes!)
t))
;;
;; FLAG -- Comment this out to disable ajax submittal
;;
:ajax-submit-on-change? t
;;:ajax-submit-on-enter? t
:domain :pass-thru
:keyword (nth (the-child index)(the settables))
:default (with-error-handling ()
(the node (evaluate (the-child keyword))))
:prompt (the-child keyword)))
:functions ((restore-default-values!
(message-keyword)
(the node (restore-slot-default! message-keyword))
;;
;; FLAG -- this seems to be unecessary -- why?
;;
(the-object (gethash message-keyword (the form-fields-hash))
(restore-slot-default! :value)))))
(define-lens (html-format settables-form)()
:output-functions
((inner-html
()
(with-cl-who ()
(when (the show-settables?)
(htm
(:table
(mapc #'(lambda(form-control reset-button)
(let ((message (the-object form-control keyword)))
(let ((remarks (the node (message-remarks message))))
(htm (:tr (:td (str (the-object reset-button form-control-string))
((:td :bgcolor :yellow)
(if (null remarks)
(htm (:b (str message)))
(htm ((:span :style "cursor: arrow;"
:title (one-line (second remarks)))
(:b (str message))))))
(:td (str (the-object form-control form-control-string)))
))))))
(list-elements (the form-fields)) (list-elements (the reset-buttons))))
(:p (str (the submit-fields-button form-control-string)))))))))
(define-object viewable-link (base-html-sheet)
:input-slots (node message)
:computed-slots ((strings-for-display (format nil "~a" (the message))))
:functions
((before-present!
()
(with-error-handling () (the node (evaluate (the message)))))))
(define-lens (html-format viewable-link)()
:output-functions
((main-sheet () (write-the return-object main-sheet))))
(define-object switch-viewables (base-html-sheet)
:input-slots
(return-object)
:computed-slots
((show-viewables? nil :settable)
(strings-for-display (if (the show-viewables?) "X" "Uncached Slots")))
:functions
((before-present! () (the (set-slot! :show-viewables? (not (the show-viewables?)))))))
(define-lens (html-format switch-viewables)()
:output-functions
((main-sheet () (write-the return-object main-sheet))))
;;
;; Test object to get form-controls working for readable Lisp objects
;;
#+nil
(define-object sample-form (base-ajax-sheet)
:computed-slots
((main-sheet-body (with-cl-who-string ()
(str (the item-1 html-string)))))
:objects
((item-1 :type 'text-form-control
:ajax-submit-on-change? t
:domain :symbol
:default "hey now")))
| 22,650 | Common Lisp | .lisp | 453 | 32.267108 | 153 | 0.482026 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 64d7c1f0e1282c14eba6dddc653d51cde17246f8b8dffe1829b84893e89870ca | 35,942 | [
-1
] |
35,943 | publish.lisp | lisp-mirror_gendl/apps/tasty/source/publish.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(defun publish-tasty (server)
(publish-gwl-app "/tasty" "tasty:assembly" :make-object-args (list :title "Genworks tasty") :server server))
(pushnew 'publish-tasty *publishers*)
| 1,092 | Common Lisp | .lisp | 24 | 42.75 | 111 | 0.741477 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | cd891ba19e7da6296c02009513da281fb173cc61fa82ff3c3374e49ea2e0f1fd | 35,943 | [
-1
] |
35,944 | test-part2.lisp | lisp-mirror_gendl/apps/tasty/source/test-part2.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
#+nil
(define-object ta2.1-test-part (base-object)
:input-slots
((control-points (list (make-point 0 0 0)
(make-point 2 3.0 0.0)
(make-point 4 2.0 0.0)
(make-point 5 0.0 0.0)
(make-point 4 -2.0 0.0)
(make-point 2 -3.0 0.0)
(make-point 0 0 0)))
(text "hello world" :settable)
)
:hidden-objects
((view :type 'base-view
:page-length (* 5 72) :page-width (* 5 72)
:objects (the children)))
:objects
((curves :type 'b-spline-curve-new-base-object
:sequence (:size 6)
:control-points (the control-points)
:degree (1+ (the-child :index))
:display-controls (if (the-child highlighted?)
(the-child aux-display-controls)
(list :line-thickness (* .3 (the-child index))
:color (ecase (the-child index)
(0 :red) (1 :orange) (2 :yellow) (3 :green)
(4 :blue) (5 :red-violet)))))
(curve-collection :type 'a-collection-curves
:control-points (the control-points))
(xbox :type 'my-box
:width 2
:length 2
:height 3)
#+nil
(points :type 'point
:sequence (:size (length (rest (the control-points))))
:center (nth (the-child index) (rest (the control-points)))
:display-controls (list :color :green))))
;;
;;FLAG -- Svde @ 14-08-09 -- This define-object has slots that can be incorporated into base-object itself,
;; to enable highlighting of objects in the viewport by switching between the 'aux-display-controls' and 'display-controls' using
;; the boolean 'highlighted?'.
;;
#+nil
(define-object b-spline-curve-new-base-object (b-spline-curve)
:input-slots
(("optional input-slot that defines the display properties of the object when highlighted in png, jpg, svg and vrml image formats.
The aux-display-controls are :settable, enabling to define your own highlight settings. aux-display-controls contains a list with the following two keys
:line-thickness and :color. The aux-display controls defaults to (list :line-thickness 3 :color :orange)"
aux-display-controls (list :line-thickness 3 :color :orange) :settable)
("optional boolean input-slot that indicates whether the object is highlighted in png and jpg image formats. If true, the object will be displayed showing the aux-display-controls. Defaults to nil."
highlighted? nil :settable))
)
#+nil
(define-object my-box (box)
:input-slots
((width nil :settable)
(length nil :settable)
(aux-display-controls (list :line-thickness 3 :color :orange) :settable)
(display-controls (if (the highlighted?)
(the aux-display-controls)))
(highlighted? nil :settable)
(strings-for-display (the name-for-display) :settable)
)
)
#+nil
(define-object a-collection-curves (base-object)
:input-slots
(control-points)
:hidden-objects
()
:objects
((curves :type 'b-spline-curve;;-new-base-object
:sequence (:size 6)
:control-points (the control-points)
:degree (1+ (the-child :index))
:display-controls (list :line-thickness (* .3 (the-child index))
:color (ecase (the-child index)
(0 :red) (1 :orange) (2 :yellow) (3 :green)
(4 :blue) (5 :red-violet))))
))
| 4,334 | Common Lisp | .lisp | 102 | 35.803922 | 202 | 0.657597 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | df032c684264b02b6e0486086bbf275ccc9017771cebfc846d193e5266d1aa01 | 35,944 | [
-1
] |
35,945 | test-part.lisp | lisp-mirror_gendl/apps/tasty/source/test-part.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gwl-user)
(define-object tasty-test-part (base-ajax-sheet)
:input-slots
((control-points (list (make-point 0 0 0)
(make-point 2 3.0 0.0)
(make-point 4 2.0 0.0)
(make-point 5 0.0 0.0)
(make-point 4 -2.0 0.0)
(make-point 2 -3.0 0.0)
(make-point 0 0 0))))
:objects
((model :type 'curves-model
:pass-down (control-points))))
(define-object curves-model (outline-specialization-mixin)
:input-slots (control-points)
:objects
((curves :type 'b-spline-curve
:sequence (:size 5)
:control-points (the control-points)
:degree (1+ (the-child :index))
:display-controls (list :line-thickness (* .3 (1+ (the-child index)))
:color (ecase (the-child index)
(0 :red) (1 :orange) (2 :yellow) (3 :green)
(4 :blue) (5 :red-violet)))))
:objects
((notes :type 'general-note
:sequence (:size (length (the control-points)))
:start (nth (the-child index) (the control-points))
:strings (format nil "C~a" (the-child index)))))
| 1,980 | Common Lisp | .lisp | 49 | 35.061224 | 74 | 0.669496 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 44f1b73001b09927a8b896a406b1756b4396f87f7267b5839300a245355f6225 | 35,945 | [
-1
] |
35,946 | menu.lisp | lisp-mirror_gendl/apps/tasty/source/menu.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(defun publish-tutorial (server)
(let ((tutorial-file
(or (probe-file (merge-pathnames "../doc/tutorial.pdf" (glisp:executable-homedir-pathname)))
(probe-file (merge-pathnames "gendl/documentation/tutorial/pdf/tutorial.pdf" glisp:*genworks-source-home*))
(warn "tutorial.pdf not found in distribution doc/ directory or source documentation directory for
publishing in tasty Help menu.~%"))))
(when tutorial-file (publish-file :path "/tutorial.pdf"
:server server
:file (namestring (truename tutorial-file))))))
(pushnew 'publish-tutorial *publishers*)
(define-object menu-section (sheet-section)
:input-slots (tatu-root
uri-static-gwl-images
uri-static-gwl-unpix
at-true-root?
(line-thickness-selected nil :settable)
(color nil :settable)
(show-line-thicknesses? nil :settable)
(show-colors? nil :settable)
(blue-arrow
(with-cl-who-string ()
((:span :style "font-weight: 900.0; color: blue;") "⇒")))
(green-arrow
(with-cl-who-string ()
((:span :style "font-weight: 900.0; color: green;") "⇒")))
(purple-arrow
(with-cl-who-string ()
((:span :style "font-weight: 900.0; color: purple;") "⇒")))
(selected-character-spaces " ")
)
:computed-slots
(
(tree-expand-mode (the tree expand-mode))
(js-to-eval "initMenus();")
(inner-html
(with-cl-who-string ()
(str (the menu-view))
(str (the toolbar-view))
))
(menu-view
(with-cl-who-string ()
((:ul :id "menu" :class "ui-state-active navbar ui-widget-header")
#+nil ;; --FLAG -- SvdE @ 12-08-09 -- no functions from the "file" menu are currently in use
((:li :id "menuFile" :class "top")
"File"
(:ul
(:li ((:a :href "#")"New"))
(:li ((:a :href "#")"Open"))
(:li ((:a :href "#")"Close"))
((:li :class "separator"):nbsp)
(:li ((:a :href "#")"Save"))
(:li ((:a :href "#")"Save as"))
((:li :class "separator"):nbsp)
(:li ((:a :href "#")"Export"))
((:li :class "separator"):nbsp)
(:li ((:a :href "#")"Exit"))))
((:li :id "menuEdit" :class "top")
"Edit"
(:ul
(:li ((:a :href "#")"Color"))
(:li ((:a :href "#")"Stroke"))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :update-node))))
"Update Object (U!)"))))
((:li :id "menuTree" :class "top")
"Tree"
(:ul
((:li :class "separator"):nbsp)
((:li :class "heading")"Object Click Mode:")
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :add-node))))
(fmt "~a Add Node... (AN)"
(if (eql (the click-mode value) :add-node)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :add-leaves))))
(fmt "~a Add Leaves... (AL)"
(if (eql (the click-mode value) :add-leaves)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :add-leaves*))))
(fmt "~a Add Leaves indiv... (AL*)"
(if (eql (the click-mode value) :add-leaves*)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :draw-node))))
(fmt "~a Draw Node (DN)"
(if (eql (the click-mode value) :draw-node)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :draw-leaves))))
(fmt "~a Draw Leaves (DL)"
(if (eql (the click-mode value) :draw-leaves)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :delete-leaves))))
(fmt "~a Clear Leaves (CL)"
(if (eql (the click-mode value) :delete-leaves)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :inspect))))
(fmt "~a Inspect Object (I)"
(if (eql (the click-mode value) :inspect)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :break))))
(fmt "~a Set Self to Object (SS)"
(if (eql (the click-mode value) :break)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :set-root))))
(fmt "~a Set Root to Object (SR)"
(if (eql (the click-mode value) :set-root)
(the blue-arrow)
(the selected-character-spaces)))))
((:li :class "heading") "Tree Actions")
#+nil
((:li :class (when (the at-true-root?) "heading"))
"Up Root! (UR!)")
#+nil
((:li :class (when (the at-true-root?) "heading"))
"Reset Root! (RR!)")
((:li :class (when (the at-true-root?) "disabled"))
(if (the at-true-root?)
(htm "Up Root! (UR!)")
(htm ((:a :href "#" :onclick (unless (the at-true-root?)
(the (gdl-ajax-call :function-key :up-root!))))
"Up Root! (UR!)"))))
((:li :class (when (the at-true-root?) "disabled"))
(if (the at-true-root?)
(htm "Reset Root! (RR!)")
(htm ((:a :href "#" :onclick (unless (the at-true-root?)
(the (gdl-ajax-call :function-key :reset-root!))))
"Reset Root! (RR!)"))))
((:li :class "heading") "Tree Navigation ")
;;
;; FLAG -- SvdE @ 12-08-09 -- Link functions in tree navigation sub-menu
;;
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-tree-expand-mode!
:arguments (list :leaves))))
(fmt "~a Expand to Leaves (L)"
(if (eql (the tree-expand-mode) :leaves)
(the green-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-tree-expand-mode!
:arguments (list :children))))
(fmt "~a Expand to Children (C)"
(if (eql (the tree-expand-mode) :children)
(the green-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-tree-expand-mode!
:arguments (list :auto-close))))
(fmt "~a Auto Close (A)"
(if (eql (the tree-expand-mode) :auto-close)
(the green-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-tree-expand-mode!
:arguments (list :remember))))
(fmt "~a Remember State (R)"
(if (eql (the tree-expand-mode) :remember)
(the green-arrow)
(the selected-character-spaces)))))))
((:li :id "menuView" :class "top")
"View"
(:ul
((:li :class "heading") "Viewport Actions")
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :reset-zoom!)))
"Fit to Window!"))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :clear!)))
"Clear View! (CL!)"))
#+nil ;; FLAG -- function not in use, could be used to restore all display settings to defaults
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-display-defaults!)))
"Restore Display Defaults!"))
((:li :class "separator"):nbsp)
((:li :class "heading") "Image Format")
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-image-format!
:arguments (list :png))))
(fmt "~a PNG"
(if (eql (the viewport image-format-selector value) :png)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-image-format!
:arguments (list :jpeg))))
(fmt "~a JPEG"
(if (eql (the viewport image-format-selector value) :jpeg)
(the blue-arrow)
(the selected-character-spaces)))))
#+nil
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-image-format!
:arguments (list :vrml))));;:web3d))))
(fmt "~a VRML"
(if (eql (the viewport image-format-selector value) :vrml)
(the blue-arrow)
(the selected-character-spaces)))))
#+nil
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-image-format!
:arguments (list :x3d))))
(fmt "~a X3D"
(if (eql (the viewport image-format-selector value) :x3d)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-image-format!
:arguments (list :x3dom))))
(fmt "~a X3DOM"
(if (eql (the viewport image-format-selector value) :x3dom)
(the blue-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-image-format!
:arguments (list :raphael))))
(fmt "~a SVG/VML"
(if (eql (the viewport image-format-selector value) :raphael)
(the blue-arrow)
(the selected-character-spaces)))))
((:li :class "separator"):nbsp)
((:li :class "heading") "Click Modes")
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-zoom!
:arguments (list :in))))
(fmt "~a Zoom in"
(if (eql (the viewport zoom-mode) :in)
(the green-arrow)
(the selected-character-spaces)))))
;;
;;FLAG -- SvdE @ 09-05-20 -- Zoom-out does not work
;;
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-zoom!
:arguments (list :out))))
(fmt "~a Zoom out"
(if (eql (the viewport zoom-mode) :out)
(the green-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-digitation-mode!
:arguments (list :measure-distance))))
(fmt "~a Measure distance"
(if (eql (the viewport digitation-mode) :measure-distance)
(the green-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-digitation-mode!
:arguments (list :report-point))))
(fmt "~a Get coordinates"
(if (eql (the viewport digitation-mode) :report-point)
(the green-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-digitation-mode!
:arguments (list :select-object))))
(fmt "~a Select object"
(if (eql (the viewport digitation-mode) :select-object)
(the green-arrow)
(the selected-character-spaces)))))
((:li :class "separator"):nbsp)
((:li :class "heading") "Perspective")
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :trimetric))))
(fmt "~a Trimetric"
(if (eql (the viewport view-selector value) :trimetric)
(the purple-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :front))))
(fmt "~a Front"
(if (eql (the viewport view-selector value) :front)
(the purple-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :rear))))
(fmt "~a Rear"
(if (eql (the viewport view-selector value) :rear)
(the purple-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :left))))
(fmt "~a Left"
(if (eql (the viewport view-selector value) :left)
(the purple-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :right))))
(fmt "~a Right"
(if (eql (the viewport view-selector value) :right)
(the purple-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :top))))
(fmt "~a Top"
(if (eql (the viewport view-selector value) :top)
(the purple-arrow)
(the selected-character-spaces)))))
(:li ((:a :href "#" :onclick (the (gdl-ajax-call :function-key :set-view!
:arguments (list :bottom))))
(fmt "~a Bottom"
(if (eql (the viewport view-selector value) :bottom)
(the purple-arrow)
(the selected-character-spaces)))))))
((:li :id "menuWindow" :class "top")
"Window"
(:ul
(:li ((:a :href "#"
:onclick "initApplicationLayout();PageLayout.open('north');PageLayout.resizeAll()")"Standard Mode"))
(:li ((:a :href "#"
:onclick "focusCenter();PageLayout.resizeAll()")"Expert Mode"))
(:li ((:a :href "#"
:onclick "focusCenter();PageLayout.resizeAll()")"End-User Mode (UI)"))))
((:li :id "menuHelp" :class "top")
"Help"
(:ul
(:li ((:a :href "/yadd" :target "_new") "Reference Documentation"))
(:li ((:a :href "/tutorial.pdf" :target "_new") "Tutorial/Manual"))
(:li ((:a :href "http://www.genworks.com" :target "_new") "Genworks Site"))
(:li ((:a :href "http://www.genworks.com/dl" :target "_new") "Check for Updates"))
(:li ((:a :href "http://www.genworks.com" :target "_new") "Contact Us"))
)))))
(toolbar-view
(with-cl-who-string
()
((:ul :id "toolbar" :class "navbar ui-widget-header")
((:li :id "tbarDrawObject")
((:span
:onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :add-leaves))))
(:img :src (string-append (the uri-static-gwl-unpix) "draw.png")
:height "32px"
:width "32px"
:alt "Draw Object (AL)"
:title "Draw Object (AL)"
:border "0")
((:span :class "tbartext")"Draw Object (AL)")))
((:li :id "tbarInspectObject")
((:span
:onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :inspect))))
(:img :src (string-append (the uri-static-gwl-unpix) "inspect.png")
:height "32px"
:width "32px"
:alt "InspectObject"
:title "Inspect Object"
:border "0")
((:span :class "tbartext")"Inspect Object (I)")))
((:li :id "tbarClearObject")
((:span
:onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :delete-leaves))))
(:img :src (string-append (the uri-static-gwl-unpix) "draw-erase.png")
:alt "ClearObject"
:height "32px"
:width "32px"
:title "Clear Object (DL)"
:border "0")
((:span :class "tbartext")"Clear Object (DL)")))
((:li :class "separator")
(:img :src (string-append (the uri-static-gwl-unpix) "tbar_separator.png")))
((:li :id "tbarClearView")
((:span
:onclick (the (gdl-ajax-call :function-key :clear!)))
(:img :src (string-append (the uri-static-gwl-unpix) "cleare-view.png")
:height "32px"
:width "32px"
:alt "ClearView"
:title "Clear View (CL!)"
:border "0")
((:span :class "tbartext")"Clear View (CL!)")))
((:li :id "tbarZoomIn")
((:span
:onclick (the (gdl-ajax-call :function-key :set-zoom!
:arguments (list :in))))
(:img :src (string-append (the uri-static-gwl-unpix) "viewmag+.png")
:alt "ZoomIn"
:height "32px"
:width "32px"
:title "Set click mode of the viewport to Zoom In"
:border "0")
((:span :class "tbartext")"Zoom In (+)")))
((:li :id "tbarZoomOut")
((:span
:onclick (the (gdl-ajax-call :function-key :set-zoom!
:arguments (list :out))))
(:img :src (string-append (the uri-static-gwl-unpix) "viewmag-.png")
:alt "ZoomOut"
:height "32px"
:width "32px"
:title "Set click mode of the viewport to Zoom Out"
:border "0")
((:span :class "tbartext")"Zoom Out (-)")))
((:li :class "separator")
(:img :src (string-append (the uri-static-gwl-unpix) "tbar_separator.png")))
(when (typep (the tatu-root root-object) 'base-html-sheet)
(htm
((:li :id "tbarUI")
((:span
;; we need to do use javascript as an :a is not possible in the menu
:onclick (format nil "window.location='~a'" (the tatu-root root-object url)))
(:img :src (string-append (the uri-static-gwl-unpix) "ui.png")
:height "32px"
:width "32px"
:alt "UI"
:title "Change to application User Interface (UI)"
:border "0")
((:span :class "tbartext")"User interface (UI)")))))
((:li :class "separator")
(:img :src (string-append (the uri-static-gwl-unpix) "tbar_separator.png")))
((:li :id "tbarSetSelf")
((:span
:onclick (the (gdl-ajax-call :function-key :set-click-mode!
:arguments (list :break))))
(:img :src (string-append (the uri-static-gwl-unpix) "break.png")
:height "32px"
:width "32px"
:alt "Break/Setself"
:title "Set click mode of an object in the tree to Break and Setself!"
:border "0")
((:span :class "tbartext")"Break/SetSelf")))
((:li :id "tbarUpdate")
((:span
:onclick (the (gdl-ajax-call :function-key :update-root!)))
;;:arguments (list :inspect))))
(:img :src (string-append (the uri-static-gwl-unpix) "update.png")
:height "32px"
:width "32px"
:alt "Update"
:title "Perform Full Update of the object tree!"
:border "0")
((:span :class "tbartext")"Update")))
(unless (the show-line-thicknesses?)
(htm ((:li :id "lineThicknesses")
((:span :style "cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-line-thicknesses? t))))
"Line Thicknesses"))))
(when (the show-line-thicknesses?)
(htm ((:li :id "lineThickness")
((:span :style " height: 32pt; cursor: pointer; "
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-line-thicknesses? nil))))
(:sup "X "))
(dolist (thickness '((0.5 "line-d.gif" )
(1.0 "line-1.gif" )
(2.0 "line-2.gif" )
(3.0 "line-3.gif" )
(4.0 "line-4.gif" )))
(htm
((:span :style "cursor: pointer;"
:title (format nil "Set Line Thickness to ~a" (first thickness))
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :line-thickness-selected
(first thickness)))))
(:img :border 0 :src (format nil "/images/gwl/~a" (second thickness)))))
(if (and (the line-thickness-selected)
(= (the line-thickness-selected) (first thickness)))
(htm ((:span :style " height: 32pt; cursor: pointer; color:green "
:title "Restore Default Line Thickness"
:onclick (the (gdl-ajax-call :function-key :restore-slot-default!
:arguments (list :line-thickness-selected))))
"⇐ " "")))
))))
(htm ((:li :id "colors")
(:table (:tr ((:td :style (format nil "width: 25pt; height: 25pt; cursor: pointer; ~a "
(if (the color)
(format nil "background: #~a;" (the color))
""))
:onclick (if (the color)
(the (gdl-ajax-call :function-key :restore-slot-default!
:arguments (list :color)))
(unless (the show-colors?)
(the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-colors? t))))))
)))))
(unless (the show-colors?)
(htm ((:li :id "colors")
((:span :style "cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-colors? t))))
"Colors"))))
(when (the show-colors?)
(htm ((:li :id "colors")
((:span :style "cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-colors? nil))))
"X")))
(str (the color-chooser full-grid)))
))))
:objects ((color-chooser :type 'color-chooser))
:functions
(
(update-root!
()
(the tatu-root update-root-object!))
(clear!
()
(the viewport clear!))
;;
;; FLAG SvdE @ 14-08-09 -- set-display-defaults! should be defined in viewport
;;
(set-display-defaults!
()
(the viewport set-display-defaults!))
(up-root!
()
(the parent up-root!)) ;;parent refers to the ojbect 'assembly' in assembly'.lisp
(reset-root!
()
(the parent reset-root!)) ;;parent refers to the ojbect 'assembly' in assembly'.lisp
(set-click-mode!
(mode)
(the click-mode (set-slot! :value mode)))
(set-image-format!
(format)
(the viewport image-format-selector (set-slot! :value format)))
(set-view!
(view)
(the viewport view-selector (set-slot! :value view)))
(set-zoom!
(zoom)
(the viewport (set-slot! :digitized-point nil))
(the viewport (set-slot! :digitized-distance nil))
(the viewport (set-slot! :digitation-mode :zoom-and-center))
(the viewport (set-slot! :zoom-mode zoom)))
(reset-zoom!
()
(the viewport reset-zoom!))
(set-digitation-mode!
(click-mode)
#+nil
(unless (eql click-mode :report-point)
(the viewport (set-slot! :digitized-point nil)))
(the viewport (set-slot! :digitized-point nil))
(the viewport (set-slot! :digitized-distance nil))
(the viewport (set-slot! :zoom-mode nil))
(the viewport (set-slot! :digitation-mode click-mode)))
(set-tree-expand-mode!
(expand-mode)
(the tree (set-slot! :expand-mode expand-mode)))
))
(define-object color-chooser ()
:input-slots
((components (list "FF" "CC" "99" "66" "33" "00"))
(cell-size 7))
:computed-slots
((full-grid
(let ((colors (the components)))
(with-cl-who-string ()
((:table :border "0" :cellspacing "0" :cellpadding "0")
(:tr (dolist (red colors)
(htm
(:td
((:table :border "0" :cellspacing "0" :cellpadding "0")
(dolist (green colors)
(htm
(:tr (dolist (blue colors)
(htm ((:td :style (format nil "cursor: pointer; background: #~a~a~a; height: ~apx; width: ~apx;"
red green blue
(the cell-size) (the cell-size))
:title (format nil "Set Color for Next Matched Object(s) to Hex RGB: ~a~a~a"
red green blue)
:onclick (the parent
(gdl-ajax-call :function-key :set-slot!
:arguments (list :color (format nil "~a~a~a" red green blue))))
))))))))))))))))))
| 32,507 | Common Lisp | .lisp | 584 | 34.44863 | 130 | 0.452425 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 6c0bfac3d2d6f439df407671dd3264b4882364afece0fd24223b9ebdf0411853 | 35,946 | [
-1
] |
35,947 | newer-inspector.lisp | lisp-mirror_gendl/apps/tasty/source/newer-inspector.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
#|
(in-package :tasty)
(defmacro ignore-errors-with-warning (&rest body)
(let ((values (gensym))
(error (gensym)))
`(let* ((,values (multiple-value-list (ignore-errors ,@body)))
(,error (second ,values)))
(if (and ,error (typep ,error 'error))
(progn (warn "~a" ,error)
(format nil "! ERROR: ~a !" ,error))
(apply #'values ,values)))))
(defun one-line (string)
(replace-regexp* (replace-regexp* string (format nil "~%") " ") "'" "\\'" ))
(defparameter *suppress-%%-messages?* t)
;;
;; FLAG -- replace with abstract associative map
;;
(defparameter *internal-keywords*
(list :query-plist :aggregate :all-mixins :background-color
:base64-encoded-root-path :bashee :beziers :bounding-bbox
:check-sanity? :color-decimal :color-hex :color-palette :cookies-received
:cookies-to-send :dash-pattern :dom-id :fill-color-decimal
:fixed-url-prefix :header-plist :home-page :instance-id
:last-visited-root-path :left-handed? :local-bbox :local-box
:local-center :local-left-handed? :local-orientation :main-view
:obliqueness :parent-tree :plain-url? :possible-nils
:quantify-box :query-toplevel :refresh-toggle :remote-id :respondent
:return-object :root-path-string :target :time-instantiated
:time-last-touched :transitory-slots :tree-root
:url-encoded-root-path :use-local-box? :viewable-slots
:viewpoints :visible-children :vrml-center))
(define-object newer-inspector (sheet-section) ;;(base-html-sheet)
:input-slots
((node-root-path nil :settable)
root-object
tree-toplevel
tatu-root
colors-default
tree-type
tree-node
display-controls-hash
perform-action-function
(relative-font-size "-1")
(message nil)
(message-type nil)
(parent-node nil)
click-mode
(value (with-error-handling
()
(the parent-node (evaluate (the message)))))
(node (when (the root-object) (the root-object (follow-root-path (the node-root-path)))))
(expand? (< (the depth) 1) :settable)
(depth 0)
)
:computed-slots
(
(show-settables? nil :settable)
(messages-local (set-difference (the node (message-list :message-type :local))
(append (the node (message-list :message-type :local
:category :methods))
(the node (message-list :message-type :local
:category :uncached-attributes)))))
(messages-2 (the (filter-messages
(set-difference (the :node (:message-list :return-category? t))
(append (the
:node
(:message-list :category :methods :return-category? t))
(the :node (:message-list
:category
:uncached-attributes :return-category? t)))))))
(messages (the (filter-messages
(set-difference (the :node (:message-list))
(append (the
:node
(:message-list :category :methods))
(the :node (:message-list
:category
:uncached-attributes)))))))
(check-links nil :settable)
(value-type (if (the 3d-vector?)
:gdl-3d-point
(typecase (the value)
(list (when (consp (the value)) :list))
(gdl::quantification :gdl-sequence)
(gdl::gdl-basis :gdl-atom))))
(value-cardinality (case (the value-type)
(:list (length (the value)))
(:gdl-sequence (the value number-of-elements))
(otherwise 0)))
(truncated-sequence (unless (zerop (the value-cardinality))
(with-output-to-string (ss)
(let ((*print-length* 3))
(pprint (the value) ss)))))
(expanded? nil :settable)
(clickable? (and (not (the expanded?))
(or (member (the value-type)
(list :list :gdl-sequence :gdl-atom))
(and (eql (the value-type) :gdl-3d-point)
(member (the click-mode)
(list :add-leaves
:add-leaves*
:add-node
:draw-leaves
:draw-node
:delete-leaves))))))
(3d-vector? (and (typep (the value) 'vector)
(= (length (the value)) 3)
(every #'floatp (the value))))
(value-display
(let* ((value (the value))
(gdl-object? (eql (class-of (class-of value))
(find-class 'gdl-class))))
(with-cl-who-string ()
((:span :style (format nil "color: ~a; ~a"
(if (the clickable?) "blue" "black")
(if (the clickable?) "cursor: pointer;" ""))
:onclick (case (the value-type)
(:gdl-atom
(the (gdl-ajax-call
:function-key :perform-action!
:arguments (list value))))
(:gdl-3d-point
(print-variables (the clickable?)
(the click-mode))
(when (the clickable?)
(the (gdl-ajax-call
:function-key :perform-action!
:arguments (list (the point))))))
((:list :gdl-sequence)
(unless (the expanded?)
(the (gdl-ajax-call
;;:bashee self
:function-key :set-slot!
:arguments (list :expanded? t)))))))
(cond ((or (eql (the value-type) :list)
(eql (the value-type) :gdl-sequence))
(if (the expanded?)
(htm ((:table :border 1)
(:tr (:td ((:span :style "color: blue; cursor: pointer;"
:onclick (the (gdl-ajax-call
:function-key :set-slot!
:arguments (list :expanded? nil))))
"X"))
(:td (str
(ecase (the value-type)
(:list "A List")
(:gdl-sequence "A GDL Sequence")))))
(let ((index -1))
(dolist (row (list-elements (the sequence-elements)))
(htm (:tr (:td (str (incf index)))
(:td (str (the-object row value-display)))))))))
(htm (:pre (esc (the truncated-sequence))))))
(gdl-object? (htm (esc (format nil "~s" value))))
((eql (the value-type) :gdl-3d-point)
(htm (esc (the point strings-for-display))))
(t (htm (fmt "~s" value))))))))
(main-view
(with-cl-who-string ()
(if (the node)
(str (the inspector-node-view))
(str "No Object Instantiated"))))
(inspector-node-view
(with-cl-who-string ()
;; header first, conforming jquery ui style framework
((:div :class "header ui-widget-header")
(str (the node strings-for-display)))
;;(esc (format nil "~s" (cons 'the (reverse (butlast (the node-root-path))))))
;;(unless (butlast (the node-root-path))
;;(htm " Root Object")))
((:div :class "header")
((:span :class "ui-icon ui-icon-tag fltlft" :title "this Object is of type ..."))
"type: "(esc (format nil "~s" (the node type))))
;; rest of the inspector below, inside an UL/LI list, with tables for prop-value
;; all conforming ui style framework
((:ul :id "inspector-root" :class "tasty-tree") ;;"tasty-inspector")
((:li)
;;
;; FLAG 090908-JB: removing this arbitrary display code from the inspector for now
;;
((:table :class "inspector-table")
((:thead)
(:th "slot-type")
(:th "slot-name")
(:th "value")
)
((:tbody)
((:tr)
(:td (:span :class "ui-icon ui-icon-pencil"))
(:td "Settables")
(:td (str (the settables-form main-div))))
;;
;; FLAG 090908-JB: this is old code from that builds the table
;;
(let ((count -1))
(dolist (inspector-node (list-elements (the nodes)))
(let ((message (the-object inspector-node message)))
(incf count)
(htm (:tr
(:td (str (the-object inspector-node message-type)))
(:td (str (the-object inspector-node message)))
(:td
;;
;; FLAG -- push everything to do with node into inspector-node
;;
(let ((slot-status (if (the expand?) (the node (slot-status message)) :unbound)))
(case slot-status
(:unbound
(htm ((:span :style "color: blue; font-style: italic; cursor: pointer;"
:onclick (the (gdl-ajax-call :function-key :message-evaluate
:arguments (list message))))
"Unbound")))
(otherwise (str (the-object inspector-node value-display)))))))))))))
))))
)
:objects
((point :type (if (the 3d-vector?) 'point 'null-object)
:center (when (the 3d-vector?) (the value))
:strings-for-display (format nil "~s" (the value)))
(sequence-elements :type 'inspector-node
:sequence (:size (the value-cardinality))
:pass-down (root-object tatu-root click-mode)
:value (the (get-value-element (the-child index)))))
:hidden-objects
((nodes :type 'newer-inspector ;;inspector-node
:depth (1+ (the depth))
:sequence (:size (length (the messages)))
:respondent (the respondent)
:message (nth (the-child index) (the messages))
:parent-node (the node)
:pass-down (
tatu-root root-object
tree-toplevel tatu-root colors-default
tree-type tree-node display-controls-hash
perform-action-function click-mode relative-font-size))
(settables-form :type 'settables-form
:pass-down (show-settables?)))
:functions
(
(get-value-element
(index)
(case (the value-type)
(:list (nth index (the value)))
(:gdl-sequence (the value (get-member index)))))
(filter-messages
(message-list)
(safe-sort
(remove-if
#'(lambda (keyword)
(or (member keyword *internal-keywords*)
(and *suppress-%%-messages?*
(let ((string (string keyword)))
(and
(> (length string) 2)
(or (string-equal (subseq string 0 2) "$$")
(and (eql (aref string 0) #\%)
(or (eql (aref string 1) #\%)
(eql
(aref string (1- (length string)))
#\%)))))))))
message-list)
#'string<))
(perform-action!
(object)
(the tatu-root (perform-action! object)))
(message-evaluate
(message)
;;
;; FLAG -- note we have to bash the view-toggle because no bashing
;; is actually happening when we evaluate the message, so the view
;; does not update by itself.
;;
(the toggle-view-toggle!)
(the (set-slot! :expand? t))
(multiple-value-bind (value error) (ignore-errors (the node (evaluate message)))
(let* ((error? (and error (typep error 'error))) (value (if error? (format nil "ERROR: ~a" error) value)))
(when error? (the node (set-slot! message value))))))
(set-object! (object) (the (set-slot! :node-root-path (the-object object root-path))))))
(define-object settables-form (base-html-sheet)
:input-slots
(show-settables?))
(define-lens (html-format settables-form)()
:output-functions
((main-view
()
(with-cl-who ()
(htm
((:span :style "cursor: pointer; color: blue; font-style: oblique;"
:onclick (the (gdl-ajax-call :function-key :set-slot!
:arguments (list :show-settables? (not (the show-settables?))))))
(str (if (the show-settables?) "X" "Show Settables!"))))))))
(define-object viewable-link (base-html-sheet)
:input-slots (node message)
:computed-slots ((strings-for-display (format nil "~a" (the message))))
:functions
((before-present!
()
(ignore-errors-with-warning (the node (evaluate (the message)))))))
(define-lens (html-format viewable-link)()
:output-functions
((main-sheet () (write-the return-object main-sheet))))
(define-object switch-viewables (base-html-sheet)
:input-slots
(return-object)
:computed-slots
((show-viewables? nil :settable)
(strings-for-display (if (the show-viewables?) "X" "Uncached Slots")))
:functions
((before-present! () (the (set-slot! :show-viewables? (not (the show-viewables?)))))))
(define-lens (html-format switch-viewables)()
:output-functions
((main-sheet () (write-the return-object main-sheet))))
|#
| 12,959 | Common Lisp | .lisp | 332 | 31.572289 | 114 | 0.612605 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | a0539075525b12fd12be47f7d373406d71a818e52a59d339a8e163787da36031 | 35,947 | [
-1
] |
35,948 | two-viewports.lisp | lisp-mirror_gendl/apps/tasty/source/two-viewports.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
;;
;; FLAG -- experimental, needs a lot of cleaning up to truly support two viewports.
;;
#+nil
(in-package :tasty)
#+nil
(define-object two-viewports (assembly)
:computed-slots
((html-sections (list (the tree)
(the tree-status-object)
(the viewport)
;;(the inspector)
(the viewport2)
(the viewport-status-object)
(the image-status-object)
)))
:objects
((part-type-form :type 'part-type-form
:pass-down (package-default)
:object-type "sppa::test-node"
:tatu-root self
:set-root-function #'(lambda(object) (the (set-root! object)))
:make-instance-function #'(lambda(type)
(the (make-root-instance type))))
(viewport2 :type 'viewport
:pass-down (root-object color-selected line-thickness-selected)
:image-format-default :png
;;:display-list-objects (list (the-child inspected-object))
:display-list-object-roots
(append (with-error-handling() (the-child inspected-object input-objects))
(with-error-handling() (the-child inspected-object explode-lines)))
:inspected-object (the inspector node)
:projection-vector (getf *standard-views* :trimetric)
:length 400
:width 500
:tatu-root self)
(viewport :type 'viewport
:pass-down (root-object color-selected line-thickness-selected)
:image-format-default :png
;;:display-list-objects (list (the-child inspected-object))
:display-list-object-roots
(when (typep (the-child inspected-object) (read-from-string "sppa::process-object"))
(list (the-child inspected-object output-object)))
:inspected-object (the inspector node)
:projection-vector (getf *standard-views* :trimetric)
:length 400
:width 500
:tatu-root self)
)
)
#+nil
(define-lens (html-format two-viewports)()
:output-functions
((main-sheet-body
()
(print-messages have-valid-instance?)
(if (the have-valid-instance?)
(write-the ui-sheet)
(write-the part-type-form main-sheet)))
(ui-sheet
()
(with-cl-who ()
;; This is the content of the Body of the basic
;; tasty layout Outer layout: center (has a Layout), west (has
;; additional Layout), north (menu), south (footer) Inner layout
;; in outer-center: center (main viewport), east (auxilary
;; views+help), north (contexthelp), west (inspector in 3 panes
;; side by side) Inner layout in outer-west: center (main tree),
;; south (inspector when traditional ta layout selected)
((:div :id "loader-message")
((:span :class "ui-icon ui-icon info" style"float: left; margin: 0.3em;")
(:span "Application is Loading")))
((:div :id "tabs" :class "page-layout-center")
((:ul :id "TabButtons" :class "pane")
(:li ((:a :href "#ApplicationLayout")(:span "Application")))
(:li ((:a :href "#Documentation")(:span "Documentation")))
)
;; wrap tab-panels in ui-layout-content div
((:div :id "TabPanelsContainer" :class "pane")
;; TAB #1
((:div :id "ApplicationLayout")
((:div :id "InnerLayout" :class "outer-center pane")
((:div :class "inner-center ui-widget pane")
((:div :class "header ui-widget-header")"After")
((:div :class "ui-widget-content")(str (the viewport main-div)))
((:div :class "footer ui-widget-header")
(:span "Click-mode: " (str (the viewport-status-object main-div))
" | Image format: " (str (the image-status-object main-div)))))
((:div :class "inner-west ui-widget pane")
((:div :class "header ui-widget-header")"Before")
((:div :class "ui-widget-content")
(str (the viewport2 main-div))
))
#+nil
((:div :class "inner-west ui-widget pane")
((:div :class "header ui-widget-header")"Inspector")
((:div :class "ui-widget-content")
(str (the inspector main-div))
))
((:div :class "inner-north ui-widget pane")
((:div :class "header ui-widget-header")"Inner North")
((:div :class "ui-widget-content")(:span "Inner North"))))
((:div :class "outer-west ui-widget pane")
((:div :class "header ui-widget-header")"Tree")
((:div :class "ui-widget-content")(str (the tree main-div)))
((:div :class "footer ui-widget-header")
"Click-mode:" (str (the tree-status-object main-div)))
)
((:div :class "outer-north ui-widget pane")
(str (the menu-section main-div))
)
((:div :class "outer-south ui-widget pane")
((:div :class "footer ui-widget-header")
((:span :class "fltrt")
"powered by " ((:a :href "http://www.genworks.com" :target "_new")"Genworks GDL")
"- empowered by " ((:a :href "http://www.ke-works.com" :target "_new")"KE-works"))
((:span) "GDL status: ")
((:span :id "gdlStatus")"Done.")
(:span " | ")
(:span
(when *developing?*
(write-the development-links)
;;(write-the break-link) (htm " | ")(write-the update-full-link)
))
#+nil
(when (typep (the root-object) 'base-html-sheet)
(htm (:span " | ")
((:a :href (the root-object url)) "Visit UI")))))
((:div :class "outer-east ui-widget pane")
((:div :class "header ui-widget-header")"Auxiliary")
((:div :class "ui-widget-content")(:span "Auxiliary Pane Content"))
)
);; #ApplicationLayout
;; TAB #2
((:div :id "Documentation" :class "ui-tabs-hide pane")
((:iframe :class "ui-widget-content" :src "/yadd" :width "100%" :height "500px"))
)
);; END TabPanelsContainer
)
))))
;;(publish-gwl-app "/t2v" "tasty::two-viewports" :make-object-args (list :title "Genworks tasty 2vp"))
| 6,806 | Common Lisp | .lisp | 161 | 35.248447 | 103 | 0.637284 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ead06b776d48a590c089b7e05f4afab059139bc6ed1ed4bcf242ccaf52e6b372 | 35,948 | [
-1
] |
35,949 | viewport.lisp | lisp-mirror_gendl/apps/tasty/source/viewport.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(define-object viewport (base-ajax-graphics-sheet)
:input-slots
(tatu-root root-object
(vector-graphics-onclick? (not (eql (the digitation-mode) :select-object)))
(color nil)
(line-thickness-selected nil)
onclick-function
(inspected-object nil)
(display-list-object-roots
(let (result)
;;(the recompute?)
(maphash #'(lambda(root-path value)
(declare (ignore value))
(push (if (listp root-path)
(the root-object (follow-root-path root-path))
root-path) result))
(the view-object-roots-root-paths-hash)) (nreverse result)))
(display-list-objects
(let (result)
(the recompute?)
(maphash #'(lambda(root-path value)
(declare (ignore value))
(push (the root-object (follow-root-path root-path)) result))
(the view-objects-root-paths-hash)) (nreverse result)))
(image-format-default :raphael)
)
:computed-slots
(;;(dom-id "ta2viewport")
(use-bsplines? (the use-bsplines-checkbox value))
#+nil
(js-to-eval (when (eql (the image-format) :raphael)
(the raphael-string)))
(recompute? nil :settable)
(respondent (the tatu-root))
;;
;; FLAG -- consider changing back to a list so we can preserve ordering.
;;
(view-object-roots-root-paths-hash (make-hash-table :test #'equalp
#+allegro :values #+allegro nil) :settable)
(view-objects-root-paths-hash (make-hash-table :test #'equalp
#+allegro :values #+allegro nil) :settable)
(display-controls-root-path-hash (make-hash-table :test #'equalp) :settable)
(display-controls-hash (let ((ht (make-hash-table)))
(maphash #'(lambda(root-path plist)
(setf (gethash (the root-object (follow-root-path root-path)) ht) plist))
(the display-controls-root-path-hash)) ht))
(operations-list nil :settable)
)
:hidden-objects
((clear-button :type 'button-form-control
:label "Clear!"
:onclick (the (gdl-ajax-call :function-key :clear!)))
(use-bsplines-checkbox :type 'checkbox-form-control
:default *use-bsplines-for-vrml?*
:prompt "Use Bsplines for VRML?")
)
:functions
(
;;
;; FLAG -- consider changing back to list here and on add-node!, to
;; preserve ordering.
;;
(add-leaves!
(object)
(the (add-display-controls! object))
(let ((hash (the view-object-roots-root-paths-hash))
(root-path (the-object object root-path)))
(the (set-slot! :view-object-roots-root-paths-hash
(progn (unless (second (multiple-value-list (gethash root-path hash)))
(setf (gethash root-path hash) t)) hash))))
(the (set-slot! :operations-list
(append (the operations-list)
(list (list :operation :add-leaves :object object))))))
(enter-debugger!
()
(when (typep (the image-url) 'error)
(let ((object (getf (lastcar (the operations-list)) :object)))
(set-self object)
(let ((*package* (symbol-package (the-object object root type))))
(let ((no-trap? (member :notrap net.aserve::*debug-current*)))
(unless no-trap?
(net.aserve::debug-on :notrap)
(format t "~&Disabling AllegroServe error trapping (i.e. enabling debugging)
-- you can re-enable it with (net.aserve::debug-off :notrap)~%")
(net.aserve::debug-on :notrap)))
(break (the image-url))))))
(pop-operation!
()
(let ((item (lastcar (the operations-list))))
(let ((operation (getf item :operation))
(object (getf item :object)))
(ecase operation
(:add-leaves (the (delete-leaves! object)))
(:add-leaves* (dolist (leaf (the-object object leaves))
(the (delete-leaves! leaf))))
(:add-node (the (delete-node! object))))))
(the (set-slot! :operations-list (butlast (the operations-list)))))
(add-leaves*!
(object)
(the (add-display-controls! object))
(dolist (leaf (the-object object leaves)) (the (add-node! leaf)))
(the (set-slot! :operations-list
(append (the operations-list)
(list (list :operation :add-leaves* :object object))))))
(leaves-displayed?
(object)
(gethash (the-object (first (the-object object leaves)) root-path)
(the view-objects-root-paths-hash)))
(toggle-leaves*!
(object)
(if (the (leaves-displayed? object))
(the (add-leaves*! object))
(the (delete-leaves! object))))
(delete-node!
(object)
(let ((display-controls-hash (the display-controls-root-path-hash))
(root-path (the-object object root-path)))
(the (clear-from-hash! :view-objects-root-paths-hash root-path))
(the (set-slot! :display-controls-root-path-hash
(progn
(maphash #'(lambda(key val)
(declare (ignore val))
(when (and (<= (length root-path) (length key))
(equalp (reverse root-path) (subseq (reverse key) 0
(length root-path))))
(remhash key display-controls-hash))) display-controls-hash)
display-controls-hash)))))
(delete-leaves!
(object)
(let ((display-controls-hash (the display-controls-root-path-hash))
(root-path (the-object object root-path)))
(dolist (hash-slot-key (list :view-object-roots-root-paths-hash
:view-objects-root-paths-hash))
(the (clear-from-hash! hash-slot-key root-path)))
(the (set-slot! :display-controls-root-path-hash
(progn
(maphash #'(lambda(key val)
(declare (ignore val))
(when (and (<= (length root-path) (length key))
(equalp (reverse root-path) (subseq (reverse key) 0
(length root-path))))
(remhash key display-controls-hash))) display-controls-hash)
display-controls-hash)))))
(clear-from-hash!
(slot-key root-path)
(let ((hash (the (evaluate slot-key))))
(the (set-slot! slot-key
(progn
(maphash #'(lambda(key val)
(declare (ignore val))
(when (or (and (<= (length root-path) (length key))
(equalp (reverse root-path)
(subseq (reverse key) 0 (length root-path)))))
(remhash key hash))) hash) hash)))))
(draw-leaves!
(object)
(the clear!) (the (add-leaves! object)))
(add-node!
(object)
(the (add-display-controls! object))
(let ((hash (the view-objects-root-paths-hash))
(root-path (the-object object root-path)))
(the (set-slot! :view-objects-root-paths-hash
(progn (setf (gethash root-path hash) t) hash))))
(the (set-slot! :operations-list
(append (the operations-list)
(list (list :operation :add-node :object object))))))
(draw-node!
(object)
(the clear!) (the (add-node! object)))
(add-display-controls!
(object)
(let ((hash (the display-controls-root-path-hash))
(root-path (the-object object root-path)))
(the (set-slot! :display-controls-root-path-hash
(progn (let ((color (the color))
(line-thickness (the line-thickness-selected)))
(if (or color line-thickness)
(setf (gethash root-path hash)
(list :line-thickness line-thickness
:color (the color)))
(when (gethash root-path hash) (remhash root-path hash))))
hash)))))
(clear! ()
(the (clear-display-controls!)) (the (clear-view-object-roots!)) (the (clear-view-objects!)))
(clear-display-controls!
() (let ((hash (the display-controls-root-path-hash)))
(the (set-slot! :display-controls-root-path-hash (progn (clrhash hash) hash)))))
(clear-view-object-roots!
() (let ((hash (the view-object-roots-root-paths-hash)))
(the (set-slot! :view-object-roots-root-paths-hash (progn (clrhash hash) hash)))))
(clear-view-objects!
() (let ((hash (the view-objects-root-paths-hash)))
(the (set-slot! :view-objects-root-paths-hash (progn (clrhash hash) hash)))))
(set-object-to-inspect!
(object)
(the inspector (set-object! object)))
;;
;; FLAG! -- SvdE @ 14-08-09 -- new functionality to be added for tasty beta release:
;; refresh viewport by redrawing all nodes from
;; :view-objects-root-paths-hash with default display-controls. Button in menu.lisp is present and linked.
;;
(set-display-defaults!
()
)
))
(define-lens (html-format viewport)()
:output-functions
(
(inner-html
()
(with-cl-who ()
(let ((*display-controls* (the display-controls-hash)))
(let ((image-format (if (the 2d-boxes?) (the image-format) :png)))
(ecase image-format
(:links (the (write-geometry-links)))
(:raphael (write-the vector-graphics))
((:png :jpeg) (write-the raster-graphics))
(:vrml (the (write-embedded-vrml-world :include-view-controls? nil)))
(:x3d (the (write-embedded-x3d-world :include-view-controls? nil)))
(:x3dom (the (write-embedded-x3dom-world :include-view-controls? nil))))))))))
| 11,794 | Common Lisp | .lisp | 242 | 34.479339 | 115 | 0.552309 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | aa635b0b1772e08e6b09f35923e92213748f5553b490379f58bc2b00ec91b451 | 35,949 | [
-1
] |
35,950 | status-object.lisp | lisp-mirror_gendl/apps/tasty/source/status-object.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(define-object status-object (base-ajax-sheet)
:input-slots
(status-message)
:computed-slots
((inner-html
(with-cl-who-string ()
((:span :class "statusmsg") (str (the status-message)))))))
| 1,128 | Common Lisp | .lisp | 28 | 36.928571 | 71 | 0.725092 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 8d15c652b1a5d521788ef2627afa25231e8ca657e985add16d362e22f77f430e | 35,950 | [
-1
] |
35,951 | zzinit.lisp | lisp-mirror_gendl/apps/tasty/source/zzinit.lisp | ;;
;; Copyright 2002-2011, 2012 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(glisp:set-features *these-features*) | 837 | Common Lisp | .lisp | 21 | 38.619048 | 70 | 0.759214 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | eb412195981f611674597035161ce1b0f9e5a9400c2d770f5d0aaec074f5d732 | 35,951 | [
-1
] |
35,952 | initialize.lisp | lisp-mirror_gendl/apps/tasty/source/initialize.lisp | ;;
;; Copyright 2002-2011 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(defun initialize ()) | 883 | Common Lisp | .lisp | 22 | 38.909091 | 70 | 0.760465 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 8c0b3b985f286ecb3f96721d8c228b5cbfebc2824d4bfdf991e665366c5db505 | 35,952 | [
-1
] |
35,953 | parameters.lisp | lisp-mirror_gendl/apps/tasty/source/parameters.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :tasty)
(defvar *debug?* nil)
(setq gwl:*bypass-security-check?* t)
(defparameter *tasty-developing?* nil)
(defparameter *use-bsplines-for-vrml?* nil)
(defparameter *these-features* (list :tasty))
(defparameter *settings* nil) | 1,137 | Common Lisp | .lisp | 27 | 39.444444 | 71 | 0.742466 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c549569dc5e88412f9bf58abf0d4ab08524962a3cc01abf03e79ecc25ac59552 | 35,953 | [
-1
] |
35,954 | assembly.lisp | lisp-mirror_gendl/apps/ta2/source/assembly.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
;;
;; Clean up this file.
;;
(define-object assembly (base-html-sheet base-object)
:input-slots
(;;(root-object nil :settable)
(root-object (the root-object-object) :settable)
(page-length (the click-mode page-length))
(initial-tree-depth 1)
(package-default :gdl-user)
(colors-default (list :headers (gethash :yellow *color-table*)))
(color-selected (the click-mode color-selected))
(line-thickness-selected (the click-mode line-thickness-selected))
(inspector-relative-font-size "-1")
(inspector-dimensions (list :width (the tree width) :length (- (the page-length) (the tree length))))
(tree-dimensions (list :width (the click-mode tree-width) :length (the click-mode tree-length)))
(viewport-dimensions (list :width 800 :length 550))
(tatu-update-function
#'(lambda()
(the (set-slot! :root-object (the root-object)))(the tree update!))))
:trickle-down-slots (colors-default)
:computed-slots
((html-sections (list (the tree) (the click-mode) (the viewport) (the inspector)))
(root-object-type 'null-part :settable)
)
:hidden-objects
(
(root-object-object :type (the root-object-type)
:tree-root (the-child)
:root (the-child)
:$$ta2-object self
:strings-for-display (format nil "~s" (the root-object-type)))
(part-type-form :type 'part-type-form
:pass-down (package-default)
:tatu-root self
:set-root-function #'(lambda(object) (the (set-root! object)))
:make-instance-function #'(lambda(type) (the (make-root-instance type))))
(tree :type 'object-tree
:pseudo-inputs (length width)
:tatu-root self
:length (getf (the tree-dimensions) :length)
:width (getf (the tree-dimensions) :width)
:display-controls-hash (the viewport display-controls-hash)
:click-mode (the click-mode click-mode)
:initial-depth (the initial-tree-depth)
:pass-down (root-object))
(click-mode :type 'click-mode
:clear-viewport-function #'(lambda() (the viewport clear!))
:object-update-function #'(lambda() (when (the root-object) (the root-object update!)))
:object-update-full-function #'(lambda() (when (the root-object) (the root-object root update!)))
:toggle-view-toggle-function #'(lambda() (the viewport (toggle-view-toggle!)))
:tatu-update-function (the tatu-update-function)
:up-root-function #'(lambda() (the up-root!))
:reset-root-function #'(lambda() (the reset-root!))
:pop-operation-function #'(lambda() (the viewport pop-operation!))
:debug-function #'(lambda() (the viewport enter-debugger!))
:pass-down (root-object)
:tatu-root self)
(viewport :type 'viewport
:pass-down (root-object color-selected line-thickness-selected)
:inspected-object (the inspector node)
:length (getf (the viewport-dimensions) :length (getf (the viewport-dimensions) :height))
:width (getf (the viewport-dimensions) :width)
:tatu-root self)
(inspector :type 'inspector
:pseudo-inputs (length width)
:pass-down (root-object colors-default)
:length (getf (the inspector-dimensions) :length)
:width (getf (the inspector-dimensions) :width)
:click-mode (the click-mode click-mode)
:relative-font-size (the inspector-relative-font-size)
:display-controls-hash (the viewport display-controls-hash)
:tatu-root self))
:functions
(
(make-root-instance
(type)
(the (set-slot! :root-object-type
(let ((*package* (find-package (the package-default))))
(read-safe-string type)))))
(set-root!
(object)
(when (typep object 'base-html-sheet) (the-object object (set-slot! :$$ta2-object self)))
(the (set-slot! :root-object object)))
(update-node!
(object)
;;
;; FLAG -- factor out repeated code between here and click-mode.lisp.
;;
(let ((standalone? (not (eql (the root) (the root-object root)))))
(if standalone?
(progn
(when object (the-object object update!))
(funcall (the tatu-update-function))
(the viewport (toggle-view-toggle!)))
(let ((root (the root))
(tatu-root-path (the root-path)))
(when object (the-object object update!))
(the-object root (follow-root-path tatu-root-path) viewport toggle-view-toggle!)
(list :go-to (the-object root (follow-root-path tatu-root-path)))))))
(up-root!
()
(unless (typep (the root-object parent) 'assembly)
(the (set-slot! :root-object (the root-object parent)))))
(reset-root!
()
(when (not (eql (the root-object) (the root-object-object)))
(the (set-slot! :root-object (the root-object-object)))))
(perform-action!
(object &key kids-error)
(ecase (the click-mode click-mode)
(:inspect (the inspector (set-object! object)))
(:set-root (the (set-root! object)))
(:update-node (the (update-node! object)))
(:draw-leaves (the viewport (draw-leaves! object)))
(:draw-node (the viewport (draw-node! object)))
(:add-leaves (the viewport (add-leaves! object)))
(:add-leaves* (the viewport (add-leaves*! object)))
(:delete-leaves (the viewport (delete-leaves! object)))
(:add-node (the viewport (add-node! object)))
(:break (set-self object)
(let ((*package* (symbol-package (the-object object root type))))
(format t "~aSelf is now set to to ~s, you may use command-line interaction....~%~%"
(if kids-error
(format nil "~&NOTE: Children cannot expand -- evaluate (the children) to reproduce the error.
The error was: ~a~%~%" kids-error) "")
object)
#+nil
(break "~aDebugging with self set to ~s..."
(if kids-error
(format nil "~&NOTE: Children cannot expand -- evaluate (the children) to reproduce the error.
The error was: ~a~%~%" kids-error) "")
object)))
;;(:uh (the viewport (set-sheet-object! object)))
))))
(define-lens (html-format assembly)()
:output-functions
((main-sheet
()
(if (typep (the root-object) 'null-part) (write-the part-type-form main-sheet)
(write-the (tatu-sheet))))
(tatu-sheet
()
(html
;;(format *html-stream* "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">~%")
;;(format *html-stream* "<!doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">~%")
(:html
(:head (:title "Genworks Ta2: " (:princ (the root-object strings-for-display)))
((:script :language "JavaScript" :type "text/javascript")
(:princ *javascript-functions*)))
(:body
((:table :cellpadding 1 :cellspacing 0 :bgcolor (gethash :grey-light-very *color-table*))
(:tr
((:div :style (format nil "overflow:auto; width: ~a" (the tree width)))
((:td :valign :top :width (format nil "~a" (the tree width)))
((:table :border 0 :cellpadding 1 :cellspacing 0 :bgcolor (gethash :blue-neon *color-table*))
(:tr
(:td
((:div :id (the tree dom-id) :style (format nil "overflow:auto; height: ~apx; width: ~apx"
(the tree length)
(the tree width)))
(:princ (the tree inner-html)))))
(:tr
(:td
((:div :style (format nil "overflow:auto; height: ~apx; width: ~apx;"
(the inspector length)
(the tree width))
:id (the inspector dom-id))
(:princ (the inspector inner-html))))))))
((:td :valign :top)
((:table :cellpadding 1 :cellspacing 0 :bgcolor (gethash :blue-neon *color-table*))
(:tr (:td ((:div :id (the click-mode dom-id)) (:princ (the click-mode inner-html)))))
(:tr ((:td :bgcolor :white) ((:div :id (the viewport dom-id))
(:princ (the viewport inner-html)))))))))))))))
| 8,975 | Common Lisp | .lisp | 195 | 38.933333 | 141 | 0.640149 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 4b59867159768e9718e9800406b2f3fd022c02d49e2df1d70d52fa14a6e77045 | 35,954 | [
-1
] |
35,955 | package.lisp | lisp-mirror_gendl/apps/ta2/source/package.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(gwl:define-package :ta2
(:export #:assembly))
#+nil
(gwl:define-package :ta2
(:documentation "Testing and Tracking Second Edition")
(:export #:assembly))
| 1,058 | Common Lisp | .lisp | 27 | 36.37037 | 71 | 0.736016 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 23d20e4ee97512bfa0e3b41409a1a482ec5b3191d59d9db64555989c102f81f6 | 35,955 | [
-1
] |
35,956 | part-type-form.lisp | lisp-mirror_gendl/apps/ta2/source/part-type-form.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(define-object part-type-form (base-html-sheet)
:input-slots
(make-instance-function set-root-function tatu-root package-default)
:computed-slots
((object-type "" :settable)
(object-expression "" :settable)
(respondent (the tatu-root)))
:functions
((after-set!
()
(cond ((not (string-equal (the object-type) ""))
(funcall (the make-instance-function) (the object-type)))
((not (string-equal (the object-expression) ""))
(funcall (the set-root-function)
(let ((*package* (find-package (the package-default))))
(eval (read-safe-string (the object-expression))))))))))
(define-lens (html-format part-type-form)()
:output-functions
((main-sheet
()
(html
(:html
(:head (:title "Specify Object Package and Type"))
(:body
(with-html-form ()
(:table (:tr ((:td :colspan 2 :align :center)
(:h3 "Specify object package and type, or an expression which returns an object.")
(:i "Default Package: the " (:princ-safe (package-name (find-package (the package-default)))) " Package")))
(:tr ((:td :bgcolor (gethash :gold-bright *color-table*)) (:b "Class Package:Type"))
(:td ((:input :type :string :name :object-type :size 40 :value (the object-type)))))
(:tr ((:td :bgcolor (gethash :gold-bright *color-table*)) (:b "Object Expression"))
(:td ((:input :type :string :name :object-expression :size 40 :value (the object-expression)))))
(:tr (:td :br) (:td ((:input :type :submit :name :submit :value " Browse!"))))))))))))
| 2,476 | Common Lisp | .lisp | 54 | 40.814815 | 117 | 0.663197 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 9caba594892bcfd42e60d3690b6400c27dc2c196d78b6098a4de466d50676b73 | 35,956 | [
-1
] |
35,957 | ajax.lisp | lisp-mirror_gendl/apps/ta2/source/ajax.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(defun reset-self (self)
(if (and (typep self 'base-html-sheet)
(not (typep self 'assembly))
(not (the parent))
(typep (the $$ta2) 'assembly))
(the $$ta2)
self))
#+nil
(defun reset-self (self)
self)
(defun ta2operate (req ent)
(let* ((query (request-query req))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(object (the root-object (follow-root-path
(read-safe-string
(base64-decode-safe (getf plist :|rootPath|)))))))
(the (perform-action! object))
(respond-with-new-html-sections req ent self)))
(publish :path "/ta2operate" :function 'ta2operate)
(defun ta2treetoggle (req ent)
(let ((query (request-query req)))
(let* (
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query)))
(let ((root-path (getf plist :|rootPath|)))
(setq root-path (base64-decode-safe root-path))
(when *debug?* (print-variables self root-path))
(let ((object (the (follow-root-path (read-safe-string root-path)))))
(the-object object toggle-state!)
(respond-with-new-html-sections req ent self))))))
(publish :path "/ta2treetoggle" :function 'ta2treetoggle)
(defun ta2evaluate (req ent)
(let* ((query (request-query req))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(message (make-keyword (base64-decode-safe (getf plist :|message|)))))
(with-http-response (req ent :content-type "text/xml")
(with-http-body (req ent)
(with-html-output(*html-stream* nil )
(:document (:html-section (:|newHTML| (str (wrap-cdata (with-output-to-string(*html-stream*)
(with-format (html-format *html-stream*)
(write-the inspector (message-value (make-keyword message))))))))
(:|replaceId| (str (format nil "inspector_~a" message))))))))))
(publish :path "/ta2evaluate" :function 'ta2evaluate)
(defun ta2setcontrol (req ent)
(let* ((query (request-query req))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(slot (make-keyword (getf plist :|control|)))
(value (getf plist :|value|)))
(if (eql (read-safe-string value) 'gdl::restore-default)
(the click-mode (restore-slot-default! slot))
(the click-mode (set-slot-if-needed! slot value)))
(respond-with-new-html-sections req ent self)))
(publish :path "/ta2setcontrol" :function 'ta2setcontrol)
(defun gdlsetslots (req ent)
(let* ((query (let ((query (request-query req))) query))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(root-path (base64-decode-list (getf plist :|rootPath|)))
(object (the root-object (follow-root-path root-path)))
(plist (remove-plist-key (remove-plist-key plist :|iid|) :|rootPath|)))
(let ((keys (read-safe-string (getf plist :|keys|)))
(values (base64-decode-list (getf plist :|values|))))
(mapc #'(lambda(key value)
(the-object object (set-slot-if-needed! key value :infer-types? nil))) keys values))
;;(funcall (the tatu-update-function))
;;(the viewport (toggle-view-toggle!))
(respond-with-new-html-sections req ent self)))
(publish :path "/gdlsetslots" :function 'gdlsetslots)
(defun gdlsetcontrol (req ent)
(let* ((query (request-query req))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(root-path (read-safe-string (getf plist :|rootPath|)))
(object (the (follow-root-path root-path)))
(slot (read-safe-string (getf plist :|control|)))
(value (getf plist :|value|)))
(if (eql (read-safe-string value) 'gdl::restore-default)
(the-object object (restore-slot-defaults! (ensure-list slot)))
(the-object object (set-slot-if-needed! slot value)))
(when (typep object 'web-drawing) (setq object (the-object object parent)))
(when (typep object 'base-html-graphics-sheet) (the-object object toggle-view-toggle!))
(respond-with-new-html-sections req ent self)))
(publish :path "/gdlsetcontrol" :function 'gdlsetcontrol)
(defun ta2setexpandmode (req ent)
(let* ((query (request-query req))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(mode (make-keyword (getf plist :|mode|))))
(the tree (set-slot! :expand-mode mode))
(respond-with-new-html-sections req ent self)))
(publish :path "/ta2setexpandmode" :function 'ta2setexpandmode)
(defun ta2clickbutton (req ent)
(let* ((query (let ((query (request-query req))) query))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(mode (getf plist :|mode|)))
(setq self (the click-mode))
(setq mode (make-keyword mode))
(case mode
(:break
#+nil
(let ((no-trap? (member :notrap net.aserve::*debug-current*)))
(unless no-trap?
(net.aserve::debug-on :notrap)
(format t "~&Disabling AllegroServe error trapping (i.e. enabling debugging)
-- you can re-enable it with (net.aserve::debug-off :notrap)~%")
(net.aserve::debug-on :notrap)))
(the (set-slot! :click-mode mode)))
(:clear! (funcall (the clear-viewport-function)))
(:update! (let ((standalone? (not (eql (the tatu-root root) (the tatu-root root-object root)))))
(if standalone?
(progn
(funcall (the object-update-function))
(funcall (the tatu-update-function))
(funcall (the toggle-view-toggle-function)))
(let ((root (the root))
(tatu-root-path (the tatu-root root-path)))
(funcall (the object-update-function))
(the-object root (follow-root-path tatu-root-path) viewport toggle-view-toggle!)))))
(:update-full! (let ((standalone? (not (eql (the tatu-root root) (the tatu-root root-object root)))))
(if standalone?
(progn
(funcall (the object-update-full-function))
(funcall (the tatu-update-function))
(funcall (the toggle-view-toggle-function)))
(let ((root (the root))
(tatu-root-path (the tatu-root root-path)))
(funcall (the object-update-full-function))
(the-object root (follow-root-path tatu-root-path) viewport toggle-view-toggle!)))))
(:up-root! (funcall (the up-root-function)))
(:reset-root! (funcall (the reset-root-function)))
(:undo (funcall (the pop-operation-function)))
(:debug (funcall (the debug-function)))
(otherwise (the (set-slot! :click-mode mode))))
(respond-with-new-html-sections req ent (the parent))))
(publish :path "/ta2clickbutton" :function 'ta2clickbutton)
(defun digitize-point (req ent)
(let* ((query (request-query req))
(iid (rest (assoc "iid" query :test #'string-equal)))
(self (first (gethash (make-keyword iid) gwl:*instance-hash-table*)))
(self (reset-self self))
(plist (gwl::assoc-list-to-plist query))
(self (the (follow-root-path (read-safe-string (getf plist :|rootPath|))))))
;;
;; FLAG -- this is internal stuff, should be handled by a simple function on the self object.
;;
(let ((local-point (make-point (- (parse-integer (getf plist :|x|))
(half (the view-object width)))
(let ((y (- (the view-object length) (parse-integer (getf plist :|y|)))))
(- y (half (the view-object length)))))))
(let ((digitized-point
(add-vectors (the view-object user-center)
(scalar*vector (/ (the view-object user-scale))
local-point))))
(ecase (the digitation-mode)
(:measure-distance
(let ((new-point (the view-object main-view (model-point (make-point (get-x local-point)
(get-y local-point)
0))))
(old-point (the digitized-point)))
(if (null old-point)
(progn
(the (set-slot! :digitized-point new-point))
(the (restore-slot-default! :digitized-distance)))
(progn
(the (set-slot! :digitized-distance (list :total (3d-distance old-point new-point)
:x (- (get-x new-point) (get-x old-point))
:y (- (get-y new-point) (get-y old-point))
:z (- (get-z new-point) (get-z old-point)))))
(the (restore-slot-default! :digitized-point))))))
(:report-point
(the (report-point (get-x local-point) (get-y local-point))))
(:zoom-and-center
(the view-object (set-slot! :user-center (make-point (get-x digitized-point)
(get-y digitized-point))))
(the view-object (set-slot! :user-scale
(* (the view-object user-scale) (the zoom-factor))))))))
(respond-with-new-html-sections req ent (the root))))
(publish :path "/digitizePoint" :function 'digitize-point)
(defun wrap-cdata (string)
(string-append "<![CDATA[" string "]]>"))
(defun respond-with-new-html-sections (req ent self)
(let (replace-list)
(dolist (section (the html-sections) (reverse replace-list))
(let ((status (the-object section (slot-status :inner-html))))
(when (eql status :unbound)
(when *debug?* (format t "pushing html for ~a...~%" (the-object section dom-id)))
(push (list (the-object section dom-id)
(the-object section inner-html)) replace-list))))
(with-http-response (req ent :content-type "text/xml")
(with-http-body (req ent)
(with-html-output(*html-stream* nil)
(:document
(dolist (replace-pair replace-list)
(htm
(:html-section (:|replaceId| (str (first replace-pair)))
(:|newHTML| (str (wrap-cdata (second replace-pair)))))))))))))
| 13,671 | Common Lisp | .lisp | 237 | 42.257384 | 135 | 0.55973 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d3fc9b285da199e685466b3bb60c2035e02f1c93e67f6ed0023958316f2f94da | 35,957 | [
-1
] |
35,958 | publish.lisp | lisp-mirror_gendl/apps/ta2/source/publish.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(publish :path "/ta2"
:function #'(lambda(req ent)
(gwl-make-object req ent "ta2:assembly")))
| 984 | Common Lisp | .lisp | 24 | 38.291667 | 71 | 0.729079 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c604d4b89e053060d03fc3370f9cfb6a5ab58a3e68f5692ae29b073c9fc6621f | 35,958 | [
-1
] |
35,959 | tests.lisp | lisp-mirror_gendl/apps/ta2/source/tests.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdl-user)
(define-object tatu-test (gwl:base-html-sheet)
:computed-slots
((list-test '(:a36 nil nil "W3b") :settable)
(nil-test nil :settable)
(keyword-test :a36 :settable)
(string-test "hello" :settable)
(number-test 45 :settable)))
(in-package :gwl-user)
(define-object tatu-children (base-html-sheet)
:computed-slots
((length 1 :settable)
(width 2 :settable)
(height 3 :settable)
(aapple (i-dont-know-how 1 2 3))
)
;; It would be great to be able to see kids 1-3 even though 4 can't appear. Then you can use
;; tatu to help track down the error that feeds kid-4's part type.
:objects
((kid-1 :type 'my-box
:pass-down (:length :width :height))
(kid-2 :type 'my-box
:pass-down (:length :width :height))
(kid-3 :type 'my-box
:pass-down (:length :width)
:height (error "This will cause all of the children not to appear This will cause all of the children not to appear This will cause all of the children not to appear This will cause all of the children not to appear This will cause all of the children not to appear"))
(kid-4 :type (if (> (the kid-3 volume) 10)
'my-box
'box)
:pass-down (:length :width :height))
(kid-5 :type 'my-box
:sequence (:size 5)
:display-controls (if (= (the-child index) 4)
(error "Can't compute display-controls")
(list :color :green))
:strings-for-display (if (= (the-child index) 3)
(error "Can't compute strings-for-display")
(format nil "kid-5 ~a" (the-child index))))
(kid-6 :type 'tatu-children)
))
(define-object my-box (box))
(define-object draw-error (base-object)
:objects
((box :type 'box
:height 20
:width 10
:length 10
:display-controls (list :color :green)
:center (translate (the center) :left 25))
(box-1 :type 'box
:height 1 ;;(/ 1 0)
:width 10
:length 10)))
(define-object measure-distance (base-object)
:objects
((left-box :type 'box
:display-controls (list :color :red)
:length 10 :width 20 :height 30
:center (translate (the center) :left 100))
(left-center-box :type 'box
:display-controls (list :color :orange)
:length 10 :width 20 :height 30
:center (translate (the center) :left 50))
(right-box :type 'box
:display-controls (list :color :green)
:length 10 :width 20 :height 30
:center (translate (the center) :right 100))
(right-center-box :type 'box
:display-controls (list :color :blue)
:length 10 :width 20 :height 30
:center (translate (the center) :right 50))
))
| 3,656 | Common Lisp | .lisp | 92 | 33.423913 | 272 | 0.66608 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | e4bd7360275303a9026ec77cdd713b64fdf816bd07afc5296a21dc9406aa901a | 35,959 | [
-1
] |
35,960 | action-object.lisp | lisp-mirror_gendl/apps/ta2/source/action-object.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(define-object action-object (base-html-sheet)
:input-slots
(node tatu-root tatu-color click-mode kids-error)
:computed-slots
((strings-for-display (multiple-value-bind (strings error)
(ignore-errors (the node strings-for-display))
(cond ((typep error 'error)
(format nil "! ~a ! from strings-for-display" error))
((the color-error?)
(format nil "~a ! ~a ! from color-hex" strings (the color-or-error)))
(t strings))))
(color-or-error (multiple-value-bind (color error)
(ignore-errors (the node color-hex))
(if (typep error 'error) error color)))
(color-error? (typep (the color-or-error) 'error))
(color-hex (if (the color-error?) (lookup-color :red :format :hex) (the color-or-error))))
:functions
((before-present!
()
;;
;; FLAG -- consider passing just the perform-action function and not the whole object
;;
(when (not (eql (the click-mode) :ui))
(the tatu-root (perform-action! (the node) :kids-error (the kids-error)))))))
| 1,960 | Common Lisp | .lisp | 45 | 38.533333 | 94 | 0.687467 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | acf18bd8578157a474ab59e17d7dba7af1d07dd113b656cc0618da68885fbf87 | 35,960 | [
-1
] |
35,961 | click-mode.lisp | lisp-mirror_gendl/apps/ta2/source/click-mode.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
;;
;; In general, return a URI for where to fetch the latest html for a div id.
;;
;;
;; FLAG -- why does this need base-html-sheet?
;;
(define-object click-mode (base-html-sheet)
:input-slots
(tatu-root pop-operation-function clear-viewport-function object-update-function object-update-full-function
toggle-view-toggle-function up-root-function reset-root-function debug-function
tatu-update-function root-object)
:computed-slots
((dom-id "ta2clickmode")
(click-mode :inspect :settable)
(color "Default" :settable)
(line-thickness -1 :settable)
(tree-width 400 :settable)
(tree-length 300 :settable)
(page-length 850 :settable)
(color-selected (unless (string-equal (the color) "default") (format nil "#~a" (the color))))
(line-thickness-selected (unless (= (the line-thickness) -1) (the line-thickness)))
(respondent (the tatu-root))
(mode-labels (let ((ht (make-hash-table)))
(dolist (pair (list (list :inspect "I...")
(list :draw-leaves "DL...")
(list :draw-node "DN...")
(list :add-leaves "AL...")
(list :add-leaves* "AL*...")
(list :delete-leaves "DL...")
(list :add-node "AN...")
(list :break "B...")
(list :ui "UI...")
(list :uh "UH...")
(list :clear! "CL!")
(list :update! "U!")
(list :update-full! "UF!")
(list :set-root "SR...")
(list :update-node "UN...")
(list :up-root! "UR!")
(list :reset-root! "RR!")) ht)
(setf (gethash (first pair) ht) (second pair))))))
:hidden-objects
(
(color-chooser :type 'color-chooser)
(line-thickness-selectors :type 'vanilla-mixin
:pseudo-inputs (line-thickness)
:sequence (:size 5)
:line-thickness (nth (the-child index) (list 0.5 1.0 2.0 3.0 4.0))
)
(line-thickness-default-setter :type 'general-callback)))
;;
;; FLAG -- merge these into generic setter object
;;
(define-object general-callback (base-html-sheet)
:input-slots (return-object function)
:functions
((before-present! () (funcall (the function)))
(write-html-sheet () (the return-object write-html-sheet))))
(define-lens (html-format click-mode)()
;; :amend? t
:output-functions
((inner-html
()
(with-html-form (:name "click-mode" :on-submit "return false;")
((:table :border 0 :cellpadding 0 :cellspacing 0)
(:tr
(:td
((:table :border 0 :cellpadding 0 :cellspacing 1)
(:tr
(let ((mode-labels (the mode-labels)))
(dolist (mode (list :inspect :draw-leaves :draw-node :add-leaves :add-leaves* :delete-leaves
:add-node :set-root :update-node :break :ui)) ;; :uh
(let ((label (gethash mode mode-labels))
(tooltip
(ecase mode
(:inspect "Set the inspector for subsequently seleted objects")
(:draw-leaves "Draw leaves (replacing existing displayed geometry) in graphics viewport for subsequently seleted objects.")
(:draw-node "Draw node (replacing existing displayed geometry) in graphics viewport for subsequently seleted objects.")
(:add-leaves "Add leaves in graphics viewport for subsequently selected objects.")
(:add-leaves* "Add leaves individually in graphics viewport (So they can be individually deleted later)")
(:delete-leaves "Delete leaves in graphics viewport for subsequently seleted objects.")
(:add-node "Add node in graphics viewport for subsequently seleted objects.")
(:set-root "Set the root of displayed tree to the next selected object.")
(:update-node "Apply Update action to the next selected object.")
(:break "Enter debugger with self set to next selected object.")
(:ui "Enter the base-html-sheet UI (if one exists) for the next selected object.")
(:uh "Display the base-html-sheet UI (if one exists) in place of the Graphics Viewport area for the next selected object."))))
(if (eql (the click-mode) mode)
(html ((:td :bgcolor (getf (the colors-default) :headers)) (:princ label)))
(html (:td ((:input :type :submit :name mode :value label
:title tooltip
:onclick (format nil "return ta2clickbutton('~a', '~a');" (the instance-id) mode)
:onmouseover (format nil "window.status='~a'; return true;" tooltip)
:onmouseout "window.status=''; return true;"))))))))
(:td ((:span :id "ta2status") "Done."))
))))
(:tr (:td
((:table :border 0 :cellpadding 0 :cellspacing 1)
(:tr (let ((mode-labels (the mode-labels)))
(dolist (mode (remove nil (list :clear! :update!
(when (not (eql (the root-object) (the root-object root))) :update-full!)
:up-root! :reset-root!)))
(let ((label (gethash mode mode-labels))
(tooltip (ecase mode
(:clear! "Clear Graphics Viewport.")
(:update! "Update from current node down for any changed object definitions.")
(:update-full! "Update from root for any changed object definitions.")
(:up-root! "Move up one level in tree if you are not already at the root level.")
(:reset-root! "Reset the tree to its original root level."))))
(if (eql (the click-mode) mode)
(html ((:td :bgcolor (getf (the colors-default) :headers)) (:princ label)))
(html (:td ((:input :type :submit :name mode :value label
:title tooltip
:onclick (format nil "return ta2clickbutton('~a', '~a');" (the instance-id) mode)
:onmouseover (format nil "window.status='~a'; return true;" tooltip)
:onmouseout "window.status=''; return true;"))))))))
(:td :br)
(:td
(if (= (the line-thickness) -1) (html (:small (:i "Default")))
(let ((image-file (cond ((<= (the line-thickness) 1.0) "line-1.gif")
((<= (the line-thickness) 2.0) "line-2.gif")
((<= (the line-thickness) 3.0) "line-3.gif")
(t "line-4.gif"))))
(html
((:span :style "cursor: pointer;"
:title "Reset Line Thickness to Default"
:onclick (format nil "return ta2setcontrol('~a', '~s', 'gdl::restore-default');"
(the instance-id) :line-thickness))
((:img :border nil :src (format nil "/images/gwl/~a" image-file))))))))
(:td
((:table :border 0 :cellpadding 0 :cellspacing 0)
(:tr
(mapc #'(lambda(selector image)
(html
(:td
((:span :style "cursor: pointer;"
:title "Set Line Thickness"
:onclick (format nil "return ta2setcontrol('~a', '~s', '~a');"
(the instance-id) :line-thickness (the-object selector line-thickness)))
((:img :border 0 :src (format nil "/images/gwl/~a" image)))))))
(list-elements (the line-thickness-selectors))
(list "line-1.gif" "line-1.gif" "line-2.gif" "line-3.gif" "line-4.gif")))))
(:td
(:table
(:tr
(:td (:table (:tr ((:td :if* (the color-selected)
:style (format nil "cursor:pointer; background: ~a; height: 10px; width: 10px;"
(the color-selected))
:title "Reset Color to Defaults"
:onclick (format nil "return ta2setcontrol('~a', '~s', 'gdl::restore-default');"
(the instance-id) :color))
(unless (the color-selected) (html (:princ (the color))))))))
(:td (write-the color-chooser (full-grid)))))))))))))))
(define-object color-chooser ()
:input-slots
((components (list "FF" "CC" "99" "66" "33" "00"))))
(define-lens (html-format color-chooser)()
:output-functions
((full-grid
(&key (cell-size 7))
(let ((colors (the components)))
(html ((:table :border "0" :cellspacing "0" :cellpadding "0")
(:tr (dolist (red colors)
(html
(:td
((:table :border "0" :cellspacing "0" :cellpadding "0")
(dolist (green colors)
(html
(:tr (dolist (blue colors)
(html ((:td :style (format nil "cursor: pointer; background: #~a~a~a; height: ~apx; width: ~apx;"
red green blue
cell-size cell-size)
:title (format nil "Set Color for Next Matched Object(s) to Hex RGB: ~a~a~a"
red green blue)
:onclick (format nil "return ta2setcontrol('~a', '~s', '~a');"
(the instance-id)
:color
(format nil "~a~a~a" red green blue))))))))))))))))))))
| 9,486 | Common Lisp | .lisp | 199 | 39.577889 | 130 | 0.610959 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | d5338de97bf0c90aff0678966783608150ec0d86b303e38227c0dbde95e8dfbd | 35,961 | [
-1
] |
35,962 | object-tree.lisp | lisp-mirror_gendl/apps/ta2/source/object-tree.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(defparameter *trap-errors?* t)
(define-object object-tree (base-html-sheet)
:input-slots
(root-object tatu-root display-controls-hash click-mode (initial-depth 2))
:computed-slots ((expand-mode :children :settable)
(dom-id "ta2tree")
)
:hidden-objects
((tree-root :type 'tree-node
:tree-toplevel self
:pass-down (tatu-root display-controls-hash click-mode expand-mode initial-depth)
:node (the root-object)))
:functions
((reset-recompute! ()
(the tree-root reset-recompute!))))
(define-lens (html-format object-tree)()
:output-functions
((inner-html
()
(with-html-form (:name "tree-form" :on-submit "return false;")
((:table
:width "100%"
:height "100%"
:bgcolor (gethash :grey *color-table*)
:cellpadding "0" :cellspacing "0" :border "0"
)
(:tr ((:td :valign :top )
(if (the root-object)
(write-the tree-root inner-html)
(html (:b (:big "No Current Instance"))))))
(:tr ((:td :valign :top)
(:table (:tr ((:td :if* (eql (the expand-mode) :leaves) :bgcolor :yellow)
(if (eql (the expand-mode) :leaves) (html (:b "L"))
(html ((:input :type :submit :value "L"
:onclick (format nil "return ta2setexpandmode('~a', ':leaves');" (the instance-id))
:title "Set Tree Expand Mode to \"leaves\".")))))
((:td :if* (eql (the expand-mode) :children) :bgcolor :yellow)
(if (eql (the expand-mode) :children) (html (:b "C"))
(html ((:input :type :submit :value "C"
:onclick (format nil "return ta2setexpandmode('~a', ':children');" (the instance-id))
:title "Set Tree Expand Mode to \"children\".")))))
((:td :if* (eql (the expand-mode) :remember) :bgcolor :yellow)
(if (eql (the expand-mode) :remember) (html (:b "R"))
(html ((:input :type :submit :value "R"
:onclick (format nil "return ta2setexpandmode('~a', ':remember');" (the instance-id))
:title "Set Tree Expand Mode to \"remember\".")))))
((:td :if* (eql (the expand-mode) :auto-close) :bgcolor :yellow)
(if (eql (the expand-mode) :auto-close) (html (:b "A"))
(html ((:input :type :submit :value "A"
:onclick (format nil "return ta2setexpandmode('~a', ':auto-close');" (the instance-id))
:title "Set Tree Expand Mode to \"auto-close\".")))))
)))))))))
;;
;; FLAG -- why does this need base-html-sheet?
;;
(define-object tree-node (base-html-sheet)
:input-slots
(node tatu-root tree-toplevel (depth 0) (total-depth (the remaining-depth))
initial-depth display-controls-hash click-mode expand-mode (visible-child? nil))
:computed-slots
(
(recompute? nil :settable)
(respondent (the tatu-root))
(closed? (>= (the depth) (the initial-depth)) :settable)
(open? (not (the closed?)))
(remaining-depth (if (or (zerop (the nodes number-of-elements)) (the closed?)) 0
(1+ (apply #'max (mapsend (list-elements (the :nodes)) :remaining-depth)))))
(tatu-color (or (getf (the local-display-controls) :color)
(the action-object color-hex)))
(tatu-line-thickness
(or (getf (the local-display-controls) :line-thickness)
(or (ignore-errors (the node line-thickness)) 1)))
(local-display-controls
(or (gethash (the node) (the display-controls-hash))
(when (typep (the parent) 'tree-node) (the parent local-display-controls))))
(kids-error (when (typep (the safe-children) 'error) (the safe-children)))
(safe-children (append (if *trap-errors?*
(the node safe-children)
(the node children))
(the node visible-children)))
(safe-child-first (length (the node safe-children)))
)
;;
;; FLAG -- add back support for visible-children.
;;
:hidden-objects
((nodes :type 'tree-node
:sequence (:size (progn (the recompute?) (length (the safe-children))))
:pass-down (tatu-root tree-toplevel total-depth display-controls-hash click-mode expand-mode initial-depth)
:visible-child? (>= (the-child index) (the safe-child-first))
:depth (1+ (the depth))
:node (let ((node (nth (the-child index) (the safe-children))))
(if (listp node)
(make-object 'ta2-child-error
:error (getf node :error)
:object-key (getf node :object-key))
node)))
(action-object :type 'action-object
:pass-down (node tatu-root tatu-color click-mode kids-error)))
:functions
((reset-recompute!
()
(the (set-slot! :recompute? (not (the recompute?))))
(mapc #'(lambda(child) (the-object child reset-recompute!)) (list-elements (the nodes))))
(open-all!
()
(the (set-slot! :closed? nil))
(mapc #'(lambda(node) (the-object node open-all!)) (list-elements (the nodes))))
(close-all!
()
(the (set-slot! :closed? t))
(mapc #'(lambda(node) (the-object node close-all!)) (list-elements (the nodes))))
(expand-parents!
()
(when (and (the parent)
(typep (the parent) 'tree-node))
(the parent (set-slot! :closed? nil))
(the parent expand-parents!)))
(toggle-state!
()
(the (set-slot! :closed? (the open?)))
(the propogate-toggle!))
(propogate-toggle!
()
(when (eql (the expand-mode) :auto-close) (the tree-toplevel tree-root close-all!))
(ecase (the expand-mode)
(:children (mapc #'(lambda(node) (when (null (the-object node closed?))
(the-object node (set-slot! :closed? t))))
(list-elements (the nodes))))
(:leaves (mapc #'(lambda(node) (the-object node open-all!)) (list-elements (the nodes))))
((:remember :auto-close)))
(when (eql (the expand-mode) :auto-close) (the expand-parents!))
)))
(defparameter *icon-hash* nil)
(define-lens (html-format tree-node)()
:output-functions
((inner-html
()
(let ((*icon-hash* (make-hash-table)))
(html ((:table :border "0"
:cellpadding "0" :cellspacing "0") (write-the (row-view))))))
(row-view
()
(html (:tr
(let ((depth (the :depth)))
(dotimes (n depth)
(cond ((and (= n (1- depth)) (the :last?))
(setf (gethash n *icon-hash*) :l)
(html ((:td :height 20 :width 20) ((:img :src "/images/gwl/l-t.gif")))))
((= n (1- depth))
(setf (gethash n *icon-hash*) :t)
(html ((:td :height 20 :width 20) ((:img :src "/images/gwl/t-t.gif")))))
((member (gethash n *icon-hash*) (list :i :t))
(setf (gethash n *icon-hash*) :i)
(html ((:td :height 20 :width 20) ((:img :src "/images/gwl/i-t.gif")))))
(t (html ((:td :height 20 :width 20) :br))))))
(if (not (zerop (the nodes number-of-elements)))
(html ((:td :height 20 :width 20)
((:span :style "cursor: pointer;"
:onclick (format nil "return ta2treetoggle('~a', '~a');"
(the instance-id)
(base64-encode-safe (format nil "~s" (the root-path-local)))))
((:img :src (cond ((the :closed?) "/images/gwl/plus.gif")
((the :open?) "/images/gwl/minus.gif"))
:border 0
:title (cond ((the :closed?) "Expand") ((the :open?) "Contract")))))))
(html ((:td :height 20 :width 20)
((:span :style "cursor: pointer;"
:onclick (format nil "return ta2treetoggle('~a', '~a');" (the instance-id)
(base64-encode-safe (format nil "~s" (the root-path-local)))))
(if (the kids-error)
(html
((:img :src "/images/gwl/nonplus.png"
:border 0
:title (format nil "Cannot Expand: ~a" (the kids-error)))))
(html ((:img :src "/images/gwl/leafbutn.gif"
:border 0))))))))
((:td :colspan (1+ (- (the :total-depth) (the :depth))) :nowrap :nowrap)
((:span :style "cursor: pointer;"
:onclick (unless (eql (the click-mode) :ui)
(format nil "return ta2operate('~a', '~a');"
(the instance-id)
(base64-encode-safe (format nil "~s" (the action-object node root-path))))))
(:princ (with-output-to-string(ss)
(let* ((simple-link? (and (eql (the click-mode) :ui)
(typep (the action-object node) 'base-html-sheet)))
(text (if simple-link?
(with-output-to-string(sss)
(html-stream
sss
((:a :href (the action-object node url))
(:princ (the action-object strings-for-display)))))
(the action-object strings-for-display))))
(html-stream ss ((:font :color (or (the tatu-color) :black))
(if (>= (the tatu-line-thickness) 2)
(html (:b (if simple-link?
(html (:princ text))
(html (:princ-safe text)))))
(let ((visible-child? (the visible-child?)))
(when visible-child? (html "["))
(if simple-link?
(html (:princ text))
(html (:princ-safe text)))
(when visible-child? (html "]"))))))))))))
(when (the :open?)
(mapc #'(lambda (node) (write-the-object node (row-view)))
(list-elements (the :nodes))))))))
(define-object ta2-child-error ()
:input-slots (error object-key)
:computed-slots ((strings-for-display (format nil "~a threw error: ~a" (the object-key) (the error)))))
| 13,003 | Common Lisp | .lisp | 231 | 37.155844 | 132 | 0.480607 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 0bb1a92624cd17314657f255befb63129545f5f9b6b5f16243b2f37543cae306 | 35,962 | [
-1
] |
35,963 | viewport.lisp | lisp-mirror_gendl/apps/ta2/source/viewport.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(define-object viewport (gwl:base-html-graphics-sheet)
:input-slots
(tatu-root root-object color-selected line-thickness-selected inspected-object)
:computed-slots
((dom-id "ta2viewport")
(recompute? nil :settable)
(respondent (the tatu-root))
(available-image-formats (list :png :jpeg :vrml :links))
;;
;; FLAG -- consider changing back to a list so we can preserve ordering.
;;
(view-object-roots-root-paths-hash (make-hash-table :test #'equalp
#+allegro :values #+allegro nil) :settable)
(view-object-roots (let (result)
(the recompute?)
(maphash #'(lambda(root-path value)
(declare (ignore value))
(push (the root-object (follow-root-path root-path)) result))
(the view-object-roots-root-paths-hash)) (nreverse result)))
(view-objects-root-paths-hash (make-hash-table :test #'equalp
#+allegro :values #+allegro nil) :settable)
(view-objects (let (result)
(the recompute?)
(maphash #'(lambda(root-path value)
(declare (ignore value))
(push (the root-object (follow-root-path root-path)) result))
(the view-objects-root-paths-hash)) (nreverse result)))
(display-controls-root-path-hash (make-hash-table :test #'equalp) :settable)
(display-controls-hash (let ((ht (make-hash-table)))
(maphash #'(lambda(root-path plist)
(setf (gethash (the root-object (follow-root-path root-path)) ht) plist))
(the display-controls-root-path-hash)) ht))
(operations-list nil :settable)
)
:hidden-objects
((view-object :type 'web-drawing
;;:dom-id (the dom-id) FLAG -- this is self-computed now, I think.
:page-length (the length)
:page-width (the width)
:projection-vector (getf *standard-views* (the view))
:objects (the view-objects)
;;:touched-geometry (the touched-geometry)
:object-roots (the view-object-roots)
:background-color :black
:field-of-view-default (the field-of-view-default)
:view (progn (when *debug?* (print-messages view)) (the view))
))
:functions
(
;;
;; FLAG -- consider changing back to list here and on add-node!, to
;; preserve ordering.
;;
(add-leaves!
(object)
(the (add-display-controls! object))
(let ((hash (the view-object-roots-root-paths-hash))
(root-path (the-object object root-path)))
(the (set-slot! :view-object-roots-root-paths-hash
(progn (unless (second (multiple-value-list (gethash root-path hash)))
(setf (gethash root-path hash) t)) hash))))
(the (set-slot! :operations-list
(append (the operations-list)
(list (list :operation :add-leaves :object object))))))
(enter-debugger!
()
(when (typep (the image-url) 'error)
(let ((object (getf (lastcar (the operations-list)) :object)))
(set-self object)
(let ((*package* (symbol-package (the-object object root type))))
(let ((no-trap? (member :notrap net.aserve::*debug-current*)))
(unless no-trap?
(net.aserve::debug-on :notrap)
(format t "~&Disabling AllegroServe error trapping (i.e. enabling debugging)
-- you can re-enable it with (net.aserve::debug-off :notrap)~%")
(net.aserve::debug-on :notrap)))
(break (the image-url))))))
(pop-operation!
()
(let ((item (lastcar (the operations-list))))
(let ((operation (getf item :operation))
(object (getf item :object)))
(ecase operation
(:add-leaves (the (delete-leaves! object)))
(:add-leaves* (dolist (leaf (the-object object leaves))
(the (delete-leaves! leaf))))
(:add-node (the (delete-node! object))))))
(the (set-slot! :operations-list (butlast (the operations-list)))))
(add-leaves*!
(object)
(the (add-display-controls! object))
(dolist (leaf (the-object object leaves)) (the (add-node! leaf)))
(the (set-slot! :operations-list
(append (the operations-list)
(list (list :operation :add-leaves* :object object))))))
(delete-node!
(object)
(let ((display-controls-hash (the display-controls-root-path-hash))
(root-path (the-object object root-path)))
(the (clear-from-hash! :view-objects-root-paths-hash root-path))
(the (set-slot! :display-controls-root-path-hash
(progn
(maphash #'(lambda(key val)
(declare (ignore val))
(when (and (<= (length root-path) (length key))
(equalp (reverse root-path) (subseq (reverse key) 0
(length root-path))))
(remhash key display-controls-hash))) display-controls-hash)
display-controls-hash)))))
(delete-leaves!
(object)
(let ((display-controls-hash (the display-controls-root-path-hash))
(root-path (the-object object root-path)))
(dolist (hash-slot-key (list :view-object-roots-root-paths-hash
:view-objects-root-paths-hash))
(the (clear-from-hash! hash-slot-key root-path)))
(the (set-slot! :display-controls-root-path-hash
(progn
(maphash #'(lambda(key val)
(declare (ignore val))
(when (and (<= (length root-path) (length key))
(equalp (reverse root-path) (subseq (reverse key) 0
(length root-path))))
(remhash key display-controls-hash))) display-controls-hash)
display-controls-hash)))))
(clear-from-hash!
(slot-key root-path)
(let ((hash (the (evaluate slot-key))))
(the (set-slot! slot-key
(progn
(maphash #'(lambda(key val)
(declare (ignore val))
(when (or (and (<= (length root-path) (length key))
(equalp (reverse root-path)
(subseq (reverse key) 0 (length root-path)))))
(progn (format t "Removing ~s from ~s~%" root-path hash))
(remhash key hash))) hash) hash)))))
(draw-leaves!
(object)
(the clear!) (the (add-leaves! object)))
(add-node!
(object)
(the (add-display-controls! object))
(let ((hash (the view-objects-root-paths-hash))
(root-path (the-object object root-path)))
(the (set-slot! :view-objects-root-paths-hash
(progn (setf (gethash root-path hash) t) hash))))
(the (set-slot! :operations-list
(append (the operations-list)
(list (list :operation :add-node :object object))))))
(draw-node!
(object)
(the clear!) (the (add-node! object)))
(add-display-controls!
(object)
(let ((hash (the display-controls-root-path-hash))
(root-path (the-object object root-path)))
(the (set-slot! :display-controls-root-path-hash
(progn (let ((color-decimal (gethash (the color-selected) *color-table-decimal*))
(line-thickness (the line-thickness-selected)))
(if (or color-decimal line-thickness)
(setf (gethash root-path hash) (list :color-decimal color-decimal :line-thickness line-thickness
:color (the color-selected)))
(when (gethash root-path hash) (remhash root-path hash))))
hash)))))
(clear! ()
(the (clear-display-controls!)) (the (clear-view-object-roots!)) (the (clear-view-objects!)))
(clear-display-controls!
() (let ((hash (the display-controls-root-path-hash)))
(the (set-slot! :display-controls-root-path-hash (progn (clrhash hash) hash)))))
(clear-view-object-roots!
() (let ((hash (the view-object-roots-root-paths-hash)))
(the (set-slot! :view-object-roots-root-paths-hash (progn (clrhash hash) hash)))))
(clear-view-objects!
() (let ((hash (the view-objects-root-paths-hash)))
(the (set-slot! :view-objects-root-paths-hash (progn (clrhash hash) hash)))))))
(define-lens (html-format viewport)()
:output-functions
((geometry-error
()
(print-messages operations-list)
(html-stream
*stream*
((:table :border 1 :cellspacing 0 :cellpadding 0 :bgcolor :white)
(:tr
((:td :width (the :view-object :width) :height (the :view-object :length))
((:span :style "color: red; font-style: italic") "Graphics Threw Error: " (:princ-safe (the image-url)))
:br
(let ((item (lastcar (the operations-list))))
(let ((operation (getf item :operation))
(object (getf item :object)))
(html
(:p :br "Operation: " (:prin1-safe operation)
:br "Object: " (:prin1-safe object)
:br "Root-path: " (:prin1-safe (the-object object root-path)))
(:p "Choices:"
(:ul
(:li ((:input :type :submit :value "Undo" :name :undo
:onclick (format nil "return ta2clickbutton('~a', '~a');" (the instance-id) :undo))))
(:li ((:input :type :submit :value "Debug" :name :undo
:onclick (format nil "return ta2clickbutton('~a', '~a');" (the instance-id) :debug))))))))))))))
(inner-html
()
(with-html-form (:name "viewport-form" :on-submit "return false;")
(let ((*display-controls* (the display-controls-hash)))
(ecase (the image-format)
(:links (the (write-geometry-links)))
((:png :jpeg) (the (write-geometry :include-view-controls? t :use-ajax? t)))
(:vrml (the (write-embedded-vrml-world :include-view-controls? t)))))))))
| 12,535 | Common Lisp | .lisp | 230 | 37.4 | 132 | 0.525343 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 26b7f9c7df78067d4e16d17202e49dc1d3c2437515228832f2fb886d016d78e5 | 35,963 | [
-1
] |
35,964 | javascript.lisp | lisp-mirror_gendl/apps/ta2/source/javascript.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(defparameter *javascript-functions*
"
function createRequest() {
var request
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (othermicrosoft) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (failed) {
request = false;
}
}
}
if (!request)
alert('failed to create XMLHttpRequest');
return request
}
function ta2operate (iid, rootPath) {
var myreq = createRequest();
var url = '/ta2operate';
var params = 'iid' + '=' + iid + '&' +
'rootPath' + '=' + rootPath;
ta2ajax(myreq, url, params);
}
function ta2treetoggle(iid, rootPath) {
var myreq = createRequest();
var url = '/ta2treetoggle';
var params = 'iid' + '=' + iid + '&' +
'rootPath' + '=' + rootPath;
ta2ajax(myreq, url, params);
}
function ta2clickbutton (iid, mode) {
var myreq = createRequest();
var url = '/ta2clickbutton';
var params = 'iid' + '=' + iid + '&' +
'mode' + '=' + mode;
ta2ajax(myreq, url, params);
}
function ta2setexpandmode (iid, mode) {
var myreq = createRequest();
var url = '/ta2setexpandmode';
var params = 'iid' + '=' + iid + '&' +
'mode' + '=' + mode;
ta2ajax(myreq, url, params);
}
function gdlsetslots (iid, rootPath, keys, values) {
var params = 'iid' + '=' + iid + '&' +
'rootPath' + '=' + rootPath + '&' +
'keys' + '=' + keys + '&' +
'values' + '=' + values;
var myreq = createRequest();
var url = '/gdlsetslots';
ta2ajax(myreq, url, params);
}
function gdlsetcontrol (iid, rootPath, control, value) {
var myreq = createRequest();
var url = '/gdlsetcontrol';
var params = 'iid' + '=' + iid + '&' +
'rootPath' + '=' + rootPath + '&' +
'control' + '=' + control + '&' +
'value' + '=' + value;
ta2ajax(myreq, url, params);
}
function ta2setcontrol (iid, control, value) {
var myreq = createRequest();
var url = '/ta2setcontrol';
var params = 'iid' + '=' + iid + '&' +
'control' + '=' + control + '&' +
'value' + '=' + value;
ta2ajax(myreq, url, params);
}
function ta2evaluate (iid, message) {
var myreq = createRequest();
var url = '/ta2evaluate';
var params = 'iid' + '=' + iid + '&' +
'message' + '=' + message;
ta2ajax(myreq, url, params);
}
function ta2ajax (myreq, url, params)
{
myreq.open('POST', url, true);
myreq.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
myreq.setRequestHeader('content-length', params.length);
myreq.setRequestHeader('user-agent', 'Firefox3-ajax');
myreq.setRequestHeader('connection', 'close');
myreq.onreadystatechange = function () {ta2update(myreq)};
// alert(myreq);
// alert(params + ' ' + params.length);
myreq.send(params);
}
function ta2update (myreq) {
if (myreq.readyState == 1)
document.getElementById('ta2status').innerHTML = 'Working...';
if (myreq.readyState == 2)
document.getElementById('ta2status').innerHTML = 'Still Working...';
if (myreq.readyState == 3)
document.getElementById('ta2status').innerHTML = 'Almost There...';
if ((myreq.readyState == 4) && (myreq.status == 200))
{
var root = myreq.responseXML.documentElement;
var children = root.childNodes;
for (i=0; i< children.length; i++)
{
var child=children[i];
var myid = child.getElementsByTagName('replaceId')[0].firstChild.data;
var newHTML = child.getElementsByTagName('newHTML')[0].firstChild.nodeValue;
document.getElementById(myid).innerHTML = newHTML;
}
document.getElementById('ta2status').innerHTML = 'Done.';
}}
/**
* returns the absolute left location of an element.
* param: e: element
* return: an integer representing the offset from left.
*/
function getElementLeftPosition(e){
var x=0;
while(e){
x+=e.offsetLeft;
e=e.offsetParent;
}
return x;
}
/**
* returns the absolute top location of an element.
* param: e: element
* return: an integer representing the offset from top.
*/
function getElementTopPosition(e){
var y=0;
while(e){
y+=e.offsetTop;
e=e.offsetParent;
}
return y;
}
function scrolledClientX (evt)
{
var x = evt.clientX-getElementLeftPosition(document.getElementById('myimage'));
var scroll = 0;
if (self.pageXOffset)
{scroll = self.pageXOffset;}
else if (document.documentElement && document.documentElement.scrollLeft)
{scroll = document.documentElement.scrollLeft;}
else if (document.body)
{scroll = document.body.scrollLeft;}
return scroll + x;
}
function scrolledClientY (evt)
{
var y = evt.clientY-getElementTopPosition(document.getElementById('myimage'));
var scroll = 0;
if (self.pageYOffset)
{scroll = self.pageYOffset;}
else if (document.documentElement && document.documentElement.scrollTop)
{scroll = document.documentElement.scrollTop;}
else if (document.body)
{scroll = document.body.scrollTop;}
return scroll + y;
}
function digitizePoint(evt, iid, rootPath)
{
var myreq = createRequest();
var url = '/digitizePoint';
var x = scrolledClientX(evt);
var y = scrolledClientY(evt);
//var x = evt.clientX-getElementLeftPosition(document.getElementById('myimage'));
//var y = evt.clientY-getElementTopPosition(document.getElementById('myimage'));
//var x = evt.pageX-getElementLeftPosition(document.getElementById('myimage'));
//var y = evt.pageY-getElementTopPosition(document.getElementById('myimage'));
var params = 'iid' + '=' + iid + '&' +
'rootPath' + '=' + rootPath + '&' +
'x' + '=' + x + '&' +
'y' + '=' + y;
myreq.open('POST', url, true);
myreq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
myreq.setRequestHeader('Content-length', params.length);
myreq.setRequestHeader('Connection', 'close');
myreq.onreadystatechange = function () {ta2update(myreq)};
myreq.send(params);
}
// This code was written by Tyler Akins and has been placed in the
// public domain. It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/_';
function encode64(input) {
var output = '';
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
keyStr.charAt(enc3) + keyStr.charAt(enc4);
} while (i < input.length);
return output;
}
function decode64(input) {
var output = '';
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
//input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
input = input.replace(/[^A-Za-z0-9\-\_\=]/g, '');
do {
enc1 = keyStr.indexOf(input.charAt(i++));
enc2 = keyStr.indexOf(input.charAt(i++));
enc3 = keyStr.indexOf(input.charAt(i++));
enc4 = keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
} while (i < input.length);
return output;
}
")
| 9,173 | Common Lisp | .lisp | 260 | 29.373077 | 84 | 0.625405 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 8e08403e5dac64adb07de3ccb95e4f886743ecb45d986b1eed78217210ed1469 | 35,964 | [
-1
] |
35,965 | parameters.lisp | lisp-mirror_gendl/apps/ta2/source/parameters.lisp | ;;
;; Copyright 2013 Genworks International
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :ta2)
(defvar *debug?* nil)
| 901 | Common Lisp | .lisp | 22 | 38.590909 | 71 | 0.741123 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 685939fe46950dbd53853d38c54e4aba0e16eb5271dedeac81b4ee47ff3810af | 35,965 | [
-1
] |
35,966 | assembly.lisp | lisp-mirror_gendl/apps/graphs/source/assembly.lisp | (in-package :graph-plot)
(define-object assembly (base-object)
:input-slots
((grid-increment 1)
(function #'identity) (range-min -5) (range-max 5) (increment 0.1)
(show-axes? t)
(show-grid? (the show-axes?))
(domain-min (apply #'min (the y-samples)))
(domain-max (apply #'max (the y-samples))))
:computed-slots
((range-interval (- (the range-max) (the range-min)))
(domain-interval (- (the domain-max) (the domain-min)))
(x-samples (list-of-numbers (the range-min) (the range-max) (the increment)))
(y-samples (mapcar #'(lambda(x) (funcall (the function) x)) (the x-samples)))
(curve-sample-points (mapcar #'(lambda(x y) (make-point x y 0))
(the x-samples) (the y-samples))))
:objects
(
(points-display :type 'points-display
:hidden? t
:points (the curve-sample-points))
(curve :type 'fitted-curve
:points (the curve-sample-points))
(x-axis :type (if (the show-axes?) 'line 'null-object)
:start (make-point (the range-min) 0 0)
:end (make-point (the range-max) 0 0)
:display-controls (list :color :green :line-style :dashed))
(x-grid :type (if (the show-grid?) 'line 'null-object)
:sequence (:size (floor (/ (the domain-interval) (the grid-increment))))
:display-controls (list :line-thickness 0.5 :color :grey)
:start (make-point (1+ (the range-min))
(+ (* (the-child index) (the grid-increment))
(floor (the domain-min))
(if (evenp (floor (the domain-min))) 0 1)) 0)
:end (make-point (1+ (the range-max))
(+ (* (the-child index) (the grid-increment))
(floor (the domain-min))
(if (evenp (floor (the domain-min))) 0 1)) 0))
(y-axis :type (if (the show-axes?) 'line 'null-object)
:start (make-point 0 (the domain-min) 0)
:end (make-point 0 (the domain-max) 0)
:display-controls (list :color :green :line-style :dashed))
(y-grid :type (if (the show-grid?) 'line 'null-object)
:sequence (:size (floor (/ (the range-interval) (the grid-increment))))
:display-controls (list :line-thickness 0.5 :color :grey)
:start (make-point (+ (* (the-child index) (the grid-increment))
(floor (the range-min)) 1)
(1- (the domain-min))
0)
:end (make-point (+ (* (the-child index) (the grid-increment))
(floor (the range-min)) 1)
(1- (the domain-max))
0))
))
| 2,415 | Common Lisp | .lisp | 54 | 38.666667 | 80 | 0.621062 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 11116d060c135d40f2dd889c786aae81efbb08c7ab717ecad927d86ddb0a272b | 35,966 | [
-1
] |
35,967 | definition-tree.lisp | lisp-mirror_gendl/apps/translators/xml/source/definition-tree.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdlxml)
(define-object definition-tree ()
:documentation (:description "Given a symbol naming a GDL object which is already defined in the system,
this object generates a tree of all the message categories and all the messages within each category.
This tree can then be used as the basis for generating a representation of the object definition in
an external format, such as GDLXML.")
:input-slots (name-symbol)
:computed-slots ((strings-for-display (format nil "Definition for ~s" (the name-symbol)))
(object-package (symbol-package (the name-symbol)))
(object-documentation (the canonical-instance documentation))
(class (find-class (the name-symbol)))
(canonical-instance (make-object (the name-symbol)))
;;
;; FLAG -- message-data should be defined on the meta-class (gdl-class).
;;
(message-data (the canonical-instance (message-list :category :all
:message-type :local
:return-category? t
:sort-order :by-category)))
;;
;; FLAG -- mixin-data should be defined on the meta-class (gdl-class).
;;
(mixin-data (the canonical-instance (mixins :local? t)))
(message-section-ht (let ((ht (make-hash-table)))
(mapc #'(lambda(message section) (push message (gethash section ht)))
(plist-keys (the message-data)) (plist-values (the message-data))) ht)))
:trickle-down-slots (canonical-instance name-symbol)
:objects ((sections :type 'message-section
:sequence (:size (hash-table-count (the message-section-ht)))
:plist (list-hash (the message-section-ht))
:name (nth (the-child index) (plist-keys (the-child plist)))
:keys (nth (the-child index) (plist-values (the-child plist))))))
(define-object message-section ()
:input-slots (name keys)
:computed-slots ((strings-for-display (format nil "~a" (the name)))
(section-key-and-modifiers
(ecase (the name)
(:required-input-slots (list :input-slots))
(:optional-input-slots (list :input-slots))
(:settable-optional-input-slots (list :input-slots :settable))
(:defaulted-input-slots (list :input-slots :defaulting))
(:settable-defaulted-input-slots (list :input-slots :settable :defaulting))
(:computed-slots (list :computed-slots))
(:settable-computed-slots (list :computed-slots :settable))
(:uncached-computed-slots (list :computed-slots :uncached))
(:objects (list :objects))
(:quantified-objects (list :objects))
(:hidden-objects (list :hidden-objects))
(:quantified-hidden-objects (list :hidden-objects))
(:functions (list :functions)))))
:objects ((messages :type 'message
:category (the name)
:sequence (:size (length (the keys)))
:section-key (first (the section-key-and-modifiers))
:modifiers (rest (the section-key-and-modifiers))
:key (nth (the-child index) (the keys)))))
(define-object message ()
:input-slots (section-key category key modifiers)
:computed-slots ((strings-for-display (format nil "~a" (the key)))
(source-list (let ((source-list (the canonical-instance (slot-source (the key)))))
(when (eql (first source-list) (the name-symbol)) (second source-list))))
(source-code-body (case (the category)
(:functions (second (the source-list)))
(otherwise (the source-list))))
(source-code-argument-list (case (the category)
(:functions (first (the source-list)))
(otherwise nil)))
(remark-string (getf (the canonical-instance (slot-documentation (the key)))
(the name-symbol)))))
| 4,678 | Common Lisp | .lisp | 89 | 45.258427 | 106 | 0.684246 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | 31805fcb0efc9b325ac06b0605b6502a8b61248af01ba5560b9d66bb8a15d7ae | 35,967 | [
-1
] |
35,968 | package.lisp | lisp-mirror_gendl/apps/translators/xml/source/package.lisp | ;;
;; Copyright 2002, 2009 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(gwl:define-package :gendlxml
(:documentation #.(glisp:system-description :translators))
(:nicknames :gdlxml)
(:export #:definition-tree #:xml2gdl #:xml2gendl #:gdl2xml #:gendl2xml #:object-definition))
| 1,075 | Common Lisp | .lisp | 24 | 43 | 96 | 0.754051 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | c31908e38fa811fd7ed8eeac22663e1ff9a5b56f0b9b09e6b6fe4e64de861016 | 35,968 | [
-1
] |
35,969 | xml2gdl.lisp | lisp-mirror_gendl/apps/translators/xml/source/xml2gdl.lisp | ;;
;; Copyright 2002, 2009, 2012 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; This source file contains free software: you can redistribute it
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :gdlxml)
(define-object xml2gdl ()
:input-slots
((xml-file "/tmp/test-file.xml") ;;(xml-file "/tmp/test.xml")
(output-file (format nil "/tmp/~a.lisp" (pathname-name (the xml-file))))
(print-right-margin 80)
(definition-lists (remove-if-not #'listp (rest (the gdlxml)))))
:computed-slots
((lxml (with-open-file (in (the xml-file))
(glisp:parse-xml in)))
(gdlxml (let ((list (first (the lxml))))
(when (eql (first list) :xml) (setq list (second (the lxml))))
(unless (ignore-errors (eql (make-keyword (first (first list))) :gdlxml))
(error "Badly formed gdlxml file. Exiting."))
list))
(package (find-package (getf (make-plist (rest (first (the gdlxml)))) :package))))
:objects
((object-definitions :type 'object-definition
:sequence (:size (length (the definition-lists)))
:definition-list (remove-if-not #'listp (nth (the-child index) (the definition-lists)))
:print-right-margin (the print-right-margin)
:package (the package)))
:functions
((write-gdl-file!
(&key (output-file (the output-file)))
(with-open-file (out output-file :direction :output :if-exists :supersede :if-does-not-exist :create)
(let ((*package* (the package)))
(format out "(in-package ~s)~%~%" (make-keyword (package-name (the package))))
(dolist (definition (list-elements (the object-definitions)))
(the-object definition (write-code-to-stream! out))))))))
(define-object object-definition ()
:input-slots
((expression `(define-object ,(the object-type-symbol) ,(the mixin-symbols)
,@(when (the documentation-plist)
`(:documentation ,(the documentation-plist)))
,@(mapcan #'(lambda(section)
(list (the-object section section-key)
(the-object section expression)))
(list-elements (the slot-sections)))))
definition-list
(package *package*)
(print-right-margin *print-right-margin*))
:computed-slots
((definition-key-list (mapcar #'(lambda(list)
(if (consp (first list))
(cons (make-keyword (first (first list)))
(make-plist (rest (first list))))
(cons (make-keyword (first list)) (rest list))))
(the definition-list)))
(define-object-plist (make-plist (rest (assoc :define-object (the definition-key-list)))))
(object-type-symbol (let ((*package* (the package)))
(read-safe-string (getf (the define-object-plist) :name))))
(documentation-plist (rest (assoc :documentation (the definition-key-list))))
(mixin-plists (let ((list (remove-if #'stringp (assoc :mixins (the definition-key-list)))))
(mapcar #'make-plist (mapcar #'rest (mapcar #'first (rest list))))))
(mixin-symbols (mapcar #'(lambda(plist)
(let ((*package* (the package)))
(read-safe-string (getf plist :name))))
(the mixin-plists)))
(slot-plists (let ((list (remove-if #'stringp (assoc :slots (the definition-key-list)))))
(let ((compound-ones (remove-if #'(lambda(list) (null (rest list))) (rest list)))
(simple-ones (remove-if-not #'(lambda(list) (null (rest list))) (rest list))))
(append (mapcar #'make-plist (mapcar #'rest (mapcar #'first simple-ones)))
(mapcar #'(lambda(compound)
(setq compound (remove-if-not #'listp compound))
(append (make-plist (rest (first compound)))
(mapcan #'(lambda(input-spec)
(setq input-spec (make-plist (rest (first input-spec))))
(list (make-keyword (getf input-spec :keyword))
(getf input-spec :default)))
(remove-if-not #'listp (second compound)))))
compound-ones)))))
(section-hash (let ((ht (make-hash-table)))
(dolist (plist (the slot-plists) ht)
(push (rest (rest plist))
(gethash (make-keyword (getf plist :section-key)) ht)))))
(section-keys (let (result) (maphash #'(lambda(key value)
(declare (ignore value))
(push key result)) (the section-hash))
(nreverse result)))
(strings-for-display (format nil "Definition for ~s" (the object-type-symbol))))
:objects
((slot-sections :type 'object-slot-section
:sequence (:size (length (the section-keys)))
:package (the package)
:print-right-margin (the print-right-margin)
:section-key (nth (the-child index) (the section-keys))
:spec-lists (gethash (the-child section-key) (the section-hash))))
:functions
((write-code-to-stream!
(stream)
(let ((*package* (the package)))
(format stream "(~s ~s ~s~%~%"
(first (the expression))
(second (the expression))
(third (the expression)))
(when (the documentation-plist)
(let ((*print-right-margin* (the print-right-margin)))
(write-string (with-output-to-string (ss)
(write-string " " ss)
(prin1 :documentation ss)
(format ss "~%")
(write-string " " ss)
(prin1 (the documentation-plist) ss)) stream)
(format stream "~%~%")))
(mapc #'(lambda(section)
(format stream " ~s~%" (the-object section section-key))
(format stream " (")
(write-string (the-object section pretty-string) stream)
(format stream ")")
(unless (the-object section last?)
(format stream "~%~%")))
(list-elements (the slot-sections)))
(format stream ")~%~%")))))
(define-object object-slot-section ()
:input-slots (section-key spec-lists package print-right-margin)
:computed-slots ((strings-for-display (format nil "~s" (the section-key)))
(expression (mapcar #'(lambda(message)
(the-object message expression))
(list-elements (the messages))))
(pretty-string (with-output-to-string(ss)
(mapc #'(lambda(message)
(let ((message-string (the-object message pretty-string)))
(when (the-object message first?)
(setq message-string (subseq message-string 1)))
(setq message-string
(glisp:replace-regexp message-string "\\n" (format nil "~% ")))
(unless (the-object message first?)
(setq message-string
(string-append (format nil "~%") message-string)))
(write-string message-string ss)))
(list-elements (the messages))))))
:objects
((messages :type 'object-slot-section-message
:sequence (:size (length (the spec-lists)))
:package (the package)
:print-right-margin (the print-right-margin)
:section-key (the section-key)
:spec-list (nth (the-child index) (the spec-lists)))))
(define-object object-slot-section-message ()
:input-slots (spec-list section-key package print-right-margin)
:computed-slots ((keyword (make-keyword (getf (the spec-list) :keyword)))
(default (let ((*package* (the package)))
(case (the section-key)
((:objects :hidden-objects)
(let ((plist (remove-plist-key (the spec-list) :keyword)))
(mapcan #'(lambda(key value)
(list key (read-safe-string value)))
(plist-keys plist) (plist-values plist))))
(otherwise (read-safe-string (getf (the spec-list) :default))))))
(remark-string (getf (the spec-list) :remark-string))
(settable (when (getf (the spec-list) :settable) :settable))
(defaulting (when (getf (the spec-list) :defaulting) :defaulting))
(uncached (when (getf (the spec-list) :uncached) :uncached))
(modifiers (remove nil (list (the settable) (the uncached) (the defaulting))))
(argument-list (let ((*package* (the package)))
(read-safe-string (getf (the spec-list) :argument-list))))
(strings-for-display (format nil "~s" (the keyword)))
(key-symbol (let ((*package* (the package)))
(intern (the keyword) *package*)))
(pretty-string (let ((*print-right-margin* (the print-right-margin))(*package* (the package)))
(with-output-to-string(ss)
(ecase (the section-key)
((:input-slots :computed-slots)
(pprint (the expression) ss))
(:functions
(when (the first?)
(write-string " " ss))
(unless (the first?)
(write-string " " ss))
(write-string "(" ss)
(when (the remark-string)
(prin1 (the remark-string) ss))
(format ss "~% ")
(prin1 (the key-symbol) ss)
(format ss "~% ")
(prin1 (the argument-list) ss)
(dolist (expression (the default))
(format ss "~% ")
(prin1 expression ss))
(write-string ")" ss))
((:objects :hidden-objects)
(when (the first?)
(write-string " " ss))
(unless (the first?)
(write-string " " ss))
(write-string "(" ss)
(when (the remark-string)
(print (the remark-string) ss))
(prin1 (the key-symbol) ss)
(mapc #'(lambda(key value)
(format ss "~% ")
(prin1 key ss)
(write-string " " ss)
(prin1 value ss))
(plist-keys (rest (the expression)))
(plist-values (rest (the expression))))
(write-string ")" ss)
)))))
(expression (if (the default)
(ecase (the section-key)
((:input-slots :computed-slots)
(append (when (the remark-string) (list (the remark-string)))
`(,(the key-symbol) ,(the default))
(the modifiers)))
(:functions (append (when (the remark-string)
(list (the remark-string)))
`(,(the key-symbol)
,(the argument-list)
,@(the default))))
((:objects :hidden-objects)
(append (when (the remark-string) (list (the remark-string)))
`(,(the key-symbol)
,@(the default)))))
(the key-symbol)))))
(defun make-plist (list)
(mapcan #'(lambda(key value) (list (make-keyword key) value))
(plist-keys list) (plist-values list)))
(defun xml2gdl (xml-file &key (output-file (format nil "/tmp/~a.lisp" (pathname-name xml-file)))
(print-right-margin 80)
(compile-and-load? nil))
"Void. Emits GDL source code representing the object definition in the given XML file. Optionally
compiles and loads this definition.
:arguments (xml-file \"String or pathname. Identifies the source XML file, which must be well-formed GDLXML.\")
:&key ((output-file \"/tmp/[name].lisp\") \"String or pathname. Identifies target output file of GDL source.\"
(print-right-margin 80) \"Number. The width for pretty-printing the GDL source code.\"
(compile-and-load? nil) \"Boolean. Determines whether the source should be compiled and loaded after writing.\")"
(the-object (make-object 'xml2gdl
:xml-file xml-file
:output-file output-file
:print-right-margin print-right-margin) (write-gdl-file!))
(format t "Wrote GDL source to ~a.~%" output-file)
(when compile-and-load? (load (compile-file output-file))))
| 12,070 | Common Lisp | .lisp | 253 | 39.486166 | 121 | 0.625033 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ca5482ec66cef5631fddfb33c3d93c6374e12f5ac5eec63b73517e856e3b9781 | 35,969 | [
-1
] |
35,970 | genworks.lisp | lisp-mirror_gendl/apps/translators/xml/source/genworks.lisp | ;;
;; Copyright 2002-2011, 2012 Genworks International and Genworks BV
;;
;; This source file is part of the General-purpose Declarative
;; Language project (GDL).
;;
;; and/or modify it under the terms of the GNU Affero General Public
;; License as published by the Free Software Foundation, either
;; version 3 of the License, or (at your option) any later version.
;;
;; This source file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public
;; License along with this source file. If not, see
;; <http://www.gnu.org/licenses/>.
;;
(in-package :com.genworks.lisp)
#+allegro (eval-when (:compile-toplevel :load-toplevel :execute) (require :pxml))
(defun parse-xml (xml-string &rest args)
#+allegro (apply #'net.xml.parser:parse-xml xml-string args)
#-allegro (declare (ignore xml-string))
#-allegro (warn "No XML parser found - please implement compatible call to net.xml.parser:parse-xml for the currently running lisp.~%"))
| 1,201 | Common Lisp | .lisp | 25 | 46.32 | 138 | 0.753425 | lisp-mirror/gendl | 0 | 0 | 0 | AGPL-3.0 | 9/19/2024, 11:44:17 AM (Europe/Amsterdam) | ae56b560becdfaf80d639924abc32f119fdadb3b73fedeea5776f8ac5f3dc976 | 35,970 | [
-1
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.