Removed unused code
This commit is contained in:
parent
642662cc82
commit
e3b5963e55
|
@ -1,10 +1,9 @@
|
|||
(ns swinging-needle-meter.swinging-needle-meter
|
||||
(:require [clojure.string :as string]
|
||||
[re-com.core :refer [h-box v-box box gap line label title slider checkbox p]]
|
||||
[re-com.core :refer [box]]
|
||||
[re-com.box :refer [flex-child-style]]
|
||||
[re-com.util :refer [deref-or-value]]
|
||||
[re-com.validate :refer [number-or-string? css-style? html-attr? validate-args-macro]]
|
||||
[reagent.core :as reagent]
|
||||
[swinging-needle-meter.utils :refer [abs]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -87,7 +86,6 @@
|
|||
;; from the left end of the scale to right end, in degrees.
|
||||
(def full-scale-deflection 140)
|
||||
|
||||
|
||||
(defn deflection
|
||||
"Return the linear deflection of a needle given this `value` on the
|
||||
range `min-value`...`max-value`."
|
||||
|
@ -97,7 +95,6 @@
|
|||
limited (min (max (+ zero-offset (/ value range)) 0) 1)]
|
||||
(* (- limited 0.5) full-scale-deflection)))
|
||||
|
||||
|
||||
(defn polar-to-cartesian
|
||||
"Return, as a map with keys :x. :y, the cartesian coordinates at the point
|
||||
`radius` distance at `theta` (degrees) angle from a point at
|
||||
|
@ -108,7 +105,6 @@
|
|||
{:x (+ cx (* radius (.cos js/Math in-radians)))
|
||||
:y (+ cy (* radius (.sin js/Math in-radians)))}))
|
||||
|
||||
|
||||
(defn describe-arc
|
||||
"Return as a string an SVG path definition describing an arc centred
|
||||
at `cx`, cy` starting at `start-angle` and ending at `end-angle` (both
|
||||
|
@ -121,7 +117,6 @@
|
|||
sweep (if (> end-angle start-angle) 1 0)]
|
||||
(string/join " " ["M" (:x start) (:y start) "A" radius radius 0 large-arc? sweep (:x end) (:y end)])))
|
||||
|
||||
|
||||
(defn as-label
|
||||
"If this arg is a floating point number, format it to a reasonable width; else return it."
|
||||
[arg]
|
||||
|
@ -130,7 +125,6 @@
|
|||
(.toFixed arg 2)
|
||||
arg))
|
||||
|
||||
|
||||
(defn gradation
|
||||
"Return as a string an SVG path definition describing a radial stroke from a center
|
||||
at `cx`, cy` starting at `min-radius` and extending to `max-radius`."
|
||||
|
@ -151,13 +145,6 @@
|
|||
:x cx
|
||||
:y (- cy min-radius)} (as-label label)]])
|
||||
|
||||
|
||||
(defn as-mm
|
||||
"return the argument, as a string, with 'mm' appended"
|
||||
[arg]
|
||||
(str arg "mm"))
|
||||
|
||||
|
||||
(defn swinging-needle-meter
|
||||
"Render an SVG swinging needle meter"
|
||||
[& {:keys [model setpoint width height min-value max-value warn-value tolerance class gradations alarm-class cursor-class frame-class hub-class needle-class redzone-class scale-class target-class unit id style attr]
|
||||
|
@ -181,7 +168,6 @@
|
|||
{:pre [(validate-args-macro swinging-needle-args-desc args "swinging-needle")]}
|
||||
(let [model (deref-or-value model)
|
||||
setpoint (deref-or-value setpoint)
|
||||
mid-point-deflection (/ full-scale-deflection 2)
|
||||
cx (/ width 2)
|
||||
cy (* height 0.90)
|
||||
needle-length (* height 0.75)
|
||||
|
@ -217,7 +203,7 @@
|
|||
:y (/ height 2)
|
||||
:width "100"
|
||||
:id (str id "-current-value")
|
||||
:class "snm-value"}[:tspan (str (as-label model) (if unit " ") unit)]]
|
||||
:class "snm-value"}[:tspan (str (as-label model) (when unit " ") unit)]]
|
||||
[:path {:class scale-class
|
||||
:id (str id "-scale")
|
||||
:d (describe-arc cx cy scale-radius
|
||||
|
@ -237,7 +223,7 @@
|
|||
:id (str id "-needle")
|
||||
:d (str "M " cx "," (- cy needle-length) " " cx "," cy) ;; "M cx,20 cx,100"
|
||||
:transform (str "rotate( " (deflection model min-value max-value) "," cx "," cy ")") }]
|
||||
(if (> gradations 0)
|
||||
(when (> gradations 0)
|
||||
(apply vector (cons :g (map #(let
|
||||
[value (+ min-value
|
||||
(*
|
||||
|
|
|
@ -1,25 +1,40 @@
|
|||
(ns swinging-needle-meter.views
|
||||
(:require [re-frame.core :as rf]
|
||||
[re-com.core :refer [h-box v-box box gap line label title progress-bar slider checkbox p single-dropdown]]
|
||||
[re-com.util :refer [deref-or-value]]
|
||||
[re-com.core :refer [h-box v-box box label title slider p single-dropdown]]
|
||||
[swinging-needle-meter.swinging-needle-meter :refer [swinging-needle-meter swinging-needle-args-desc]]
|
||||
[swinging-needle-meter.utils :refer [panel-title title2 args-table github-hyperlink status-text]]
|
||||
[reagent.core :as reagent]
|
||||
[swinging-needle-meter.utils :refer [abs]]))
|
||||
[swinging-needle-meter.utils :refer [panel-title title2 args-table status-text]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;
|
||||
;;;; swinging-needle-meter: an experiment in animating SVG from re-frame.
|
||||
;;;; Draws heavily on re-com..
|
||||
;;;;
|
||||
;;;; This program is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU General Public License
|
||||
;;;; as published by the Free Software Foundation; either version 2
|
||||
;;;; of the License, or (at your option) any later version.
|
||||
;;;;
|
||||
;;;; This program 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 General Public License for more details.
|
||||
;;;;
|
||||
;;;; You should have received a copy of the GNU General Public License
|
||||
;;;; along with this program; if not, write to the Free Software
|
||||
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
;;;; USA.
|
||||
;;;;
|
||||
;;;; Copyright (C) 2017 Simon Brooke
|
||||
;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; ------------------------------------------------------------------------------------
|
||||
;; Demo: swinging-needle-meter
|
||||
;; ------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
(defn swinging-needle-demo
|
||||
[]
|
||||
(let [unit @(rf/subscribe [:unit])
|
||||
min-val @(rf/subscribe [:min-val])
|
||||
max-val @(rf/subscribe [:max-val])
|
||||
warn-val @(rf/subscribe [:warn-val])
|
||||
gradations @(rf/subscribe [:gradations])
|
||||
size @(rf/subscribe [:size])]
|
||||
(let [size @(rf/subscribe [:size])]
|
||||
(fn
|
||||
[]
|
||||
[v-box
|
||||
|
|
Loading…
Reference in a new issue