Skip to content

Commit

Permalink
Implement projector window functionality
Browse files Browse the repository at this point in the history
Beats me if this still works, have to setup the hardware to test this again, looks like it should - but I really need to detangle all the logic out of the draw call!
  • Loading branch information
CmdrDats committed Oct 17, 2021
1 parent c92a14f commit 4f6fbc6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/igoki/litequil.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns igoki.litequil
(:require [seesaw.core :as s])
(:import
(javax.swing JPanel JFrame SwingUtilities WindowConstants)
(java.awt Graphics2D Container Component Dimension Color Stroke Image BasicStroke RenderingHints Font Rectangle Polygon)
Expand Down Expand Up @@ -121,7 +122,12 @@

(defn sketch [options]
(let [{:keys [title size draw setup close]} options
local-frame (JFrame. ^String title)
local-frame
(s/frame
:title title
:icon "igoki48.png"
:resizable? true
:on-close :dispose)

sk (sketch-panel options)
local-panel (:panel sk)
Expand All @@ -144,8 +150,6 @@

(doto local-frame
(.pack)
(.setDefaultCloseOperation WindowConstants/DISPOSE_ON_CLOSE)
(.setResizable true)
(.setVisible true))

(.grabFocus local-panel)
Expand Down
18 changes: 12 additions & 6 deletions src/igoki/projector.clj
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
(util/vec->mat corners-mat (reverse corners))
corners-mat)))

(defmethod ui/draw :calibration-pattern [ctx]
(defn draw [ctx]
(lq/frame-rate 10)
;; If camera is reading, render black and quit.
(if (:reading @ctx)
Expand All @@ -142,8 +142,8 @@
(lq/background 255 255 255)
(lq/rect 0 0 (lq/width) (lq/height))
(lq/background 0 0 0)
#_(when-not homography)
(draw-checkerboard checker)
(when-not homography
(draw-checkerboard checker))

;; Draw screen intersection points
#_(do
Expand Down Expand Up @@ -231,19 +231,25 @@
(reset! ctx {:sketch (:sketch @ctx)})
(ui/transition ctx :calibration-pattern))


(defn start-cframe []
(reset! ctx
{})
(ui/start ctx nil)

(let [sketch
(lq/sketch
{:title "Move on board in camera view (place paper on board for contrast)"
:draw (partial #'draw ctx)
:size (or (-> @ctx :sketchconfig :size) [1280 720])})]
(swap! ctx assoc :sketch sketch))

(ui/add-camera-listeners
ui/ctx
(fn [ctx]
(pre-cam-reading))
(fn [ctx]
(post-cam-reading)))

(ui/transition ctx :calibration-pattern)

(doto
(Thread.
^Runnable
Expand Down
7 changes: 6 additions & 1 deletion src/igoki/ui/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[seesaw.dev :as sd]
[igoki.ui :as ui]
[igoki.calibration :as goban]
[igoki.projector :as projector]
[igoki.game :as game]
[igoki.simulated :as sim]))

Expand All @@ -22,7 +23,11 @@
:hgap 15
:align :left
:items
[(s/button :text "Projector Window")
[(s/button :text "Projector Window"
:listen
[:action
(fn [e]
(projector/start-cframe))])
(s/toggle :text "Dev Tools")
(s/toggle :text "Show Branches"
:listen
Expand Down

0 comments on commit 4f6fbc6

Please sign in to comment.