|
@@ -8,13 +8,6 @@
|
|
|
import Cocoa
|
|
|
import KMComponentLibrary
|
|
|
|
|
|
-enum KMMeasureType: Int, CaseIterable {
|
|
|
- case Line = 0
|
|
|
- case Multi_line
|
|
|
- case Polygon
|
|
|
- case Rectangle
|
|
|
-}
|
|
|
-
|
|
|
class KMMeasureController: NSViewController {
|
|
|
|
|
|
@IBOutlet var typeSegmented: ComponentSegmented!
|
|
@@ -27,6 +20,8 @@ class KMMeasureController: NSViewController {
|
|
|
@IBOutlet var fillColorGroup: ComponentCColorGroup!
|
|
|
@IBOutlet var opacitySlider: ComponentSlider!
|
|
|
@IBOutlet var opacitySelect: ComponentSelect!
|
|
|
+ @IBOutlet var colorBGViewHeightConst: NSLayoutConstraint!
|
|
|
+ @IBOutlet var opacityViewHeightConst: NSLayoutConstraint!
|
|
|
|
|
|
//Line
|
|
|
@IBOutlet var lineBGView: NSView!
|
|
@@ -37,6 +32,7 @@ class KMMeasureController: NSViewController {
|
|
|
@IBOutlet var linedashInfoView: NSView!
|
|
|
@IBOutlet var lineDashSlider: ComponentSlider!
|
|
|
@IBOutlet var lineDashSelect: ComponentSelect!
|
|
|
+ @IBOutlet var lineBGViewHeightConst: NSLayoutConstraint!
|
|
|
|
|
|
//Font
|
|
|
@IBOutlet var fontBGView: NSView!
|
|
@@ -51,7 +47,6 @@ class KMMeasureController: NSViewController {
|
|
|
@IBOutlet var displayLengthCheckBox: ComponentCheckBox!
|
|
|
@IBOutlet var displayArea_CheckBox: ComponentCheckBox!
|
|
|
|
|
|
-
|
|
|
private let line_Property = ComponentSegmentedProperty(size: .s, active: false, iconImage: NSImage(named: "measure_line_gray"), iconImage_active: NSImage(named: "measure_line"))
|
|
|
private let multiLine_Property = ComponentSegmentedProperty(size: .s, active: false, iconImage: NSImage(named: "measure_multiLine_gray"), iconImage_active: NSImage(named: "measure_multiLine"))
|
|
|
private let polygon_Property = ComponentSegmentedProperty(size: .s, active: false, iconImage: NSImage(named: "measure_polygon_gray"), iconImage_active: NSImage(named: "measure_polygon"))
|
|
@@ -63,8 +58,8 @@ class KMMeasureController: NSViewController {
|
|
|
private let dashProperty = ComponentCSelectorProperty.init(size: .s, state: .normal, text: "", iconImage: NSImage(named: "lineStyle_dash"))
|
|
|
|
|
|
private var annotations: [CPDFFreeTextAnnotation] = []
|
|
|
-
|
|
|
- var measureType: KMMeasureType = .Line
|
|
|
+
|
|
|
+ var annotationType: CAnnotationType = .measureLine
|
|
|
|
|
|
var pdfView: CPDFListView?
|
|
|
|
|
@@ -231,14 +226,14 @@ class KMMeasureController: NSViewController {
|
|
|
multiLine_Property.active = false
|
|
|
polygon_Property.active = false
|
|
|
rectangle_Property.active = false
|
|
|
-
|
|
|
- if measureType == .Line {
|
|
|
+
|
|
|
+ if annotationType == .measureLine {
|
|
|
line_Property.active = true
|
|
|
- } else if measureType == .Multi_line {
|
|
|
+ } else if annotationType == .measurePolyLine {
|
|
|
multiLine_Property.active = true
|
|
|
- } else if measureType == .Polygon {
|
|
|
+ } else if annotationType == .measurePolyGon {
|
|
|
polygon_Property.active = true
|
|
|
- } else if measureType == .Rectangle {
|
|
|
+ } else if annotationType == .measureSquare {
|
|
|
rectangle_Property.active = true
|
|
|
}
|
|
|
typeSegmented.reloadData()
|
|
@@ -292,22 +287,29 @@ class KMMeasureController: NSViewController {
|
|
|
firstAnnotation = annotations.first
|
|
|
}
|
|
|
|
|
|
-// //Font
|
|
|
-// var fontNameString: String?
|
|
|
-// var fontStyleString: String?
|
|
|
-// var fontSize: CGFloat?
|
|
|
-//
|
|
|
-// //Color
|
|
|
-// var fontColor: NSColor?
|
|
|
-// var borderColor: NSColor?
|
|
|
-// var fillColor: NSColor?
|
|
|
-// var opacity: CGFloat?
|
|
|
-//
|
|
|
-// //Line
|
|
|
-// var lineStyle: CPDFBorderStyle?
|
|
|
-// var lineWidth: CGFloat?
|
|
|
-// var dashPattern: CGFloat?
|
|
|
-//
|
|
|
+ //Color
|
|
|
+ var fontColor: NSColor?
|
|
|
+ var borderColor: NSColor?
|
|
|
+ var fillColor: NSColor?
|
|
|
+ var opacity: CGFloat?
|
|
|
+
|
|
|
+ //Font
|
|
|
+ var fontNameString: String?
|
|
|
+ var fontStyleString: String?
|
|
|
+ var fontSize: CGFloat?
|
|
|
+
|
|
|
+ //Line
|
|
|
+ var lineStyle: CPDFBorderStyle?
|
|
|
+ var lineWidth: CGFloat?
|
|
|
+ var dashPattern: CGFloat?
|
|
|
+ var startLineStyle = CPDFLineAnnotation.defaultArrow_StartLineStyle()
|
|
|
+ var endLineStyle = CPDFLineAnnotation.defaultArrow_EndLineStyle()
|
|
|
+
|
|
|
+ //Display Label
|
|
|
+ var displayLength: Bool = false
|
|
|
+ var displayArea: Bool = false
|
|
|
+
|
|
|
+ //
|
|
|
// if annotations.count == 0 {
|
|
|
// //Font
|
|
|
// fontNameString = CPDFFreeTextAnnotation.defaultFontName()
|
|
@@ -552,6 +554,36 @@ class KMMeasureController: NSViewController {
|
|
|
// lineDashSelect.resetText("-")
|
|
|
// }
|
|
|
|
|
|
+ //Color
|
|
|
+// @IBOutlet var colorBGView: NSView!
|
|
|
+// @IBOutlet var colorLabel: NSTextField!
|
|
|
+// @IBOutlet var fontColorGroup: ComponentCColorGroup!
|
|
|
+// @IBOutlet var borderColorGroup: ComponentCColorGroup!
|
|
|
+// @IBOutlet var fillColorGroup: ComponentCColorGroup!
|
|
|
+// @IBOutlet var opacitySlider: ComponentSlider!
|
|
|
+// @IBOutlet var opacitySelect: ComponentSelect!
|
|
|
+// @IBOutlet var colorBGViewHeightConst: NSLayoutConstraint!
|
|
|
+// @IBOutlet var opacityViewHeightConst: NSLayoutConstraint!
|
|
|
+//
|
|
|
+// //Line
|
|
|
+// @IBOutlet var lineBGView: NSView!
|
|
|
+// @IBOutlet var lineLabel: NSTextField!
|
|
|
+// @IBOutlet var lineTypeSelector: ComponentCSelectorGroup!
|
|
|
+// @IBOutlet var lineWidthSlider: ComponentSlider!
|
|
|
+// @IBOutlet var lineWidthSelect: ComponentSelect!
|
|
|
+// @IBOutlet var linedashInfoView: NSView!
|
|
|
+// @IBOutlet var lineDashSlider: ComponentSlider!
|
|
|
+// @IBOutlet var lineDashSelect: ComponentSelect!
|
|
|
+// @IBOutlet var lineBGViewHeightConst: NSLayoutConstraint!
|
|
|
+//
|
|
|
+// //Font
|
|
|
+// @IBOutlet var fontBGView: NSView!
|
|
|
+// @IBOutlet var fontLabel: NSTextField!
|
|
|
+// @IBOutlet var fontNameSelect: ComponentSelect!
|
|
|
+// @IBOutlet var fontStyleSelect: ComponentSelect!
|
|
|
+// @IBOutlet var fontSizeSelect: ComponentSelect!
|
|
|
+//
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -694,14 +726,15 @@ extension KMMeasureController: ComponentCSelectorGroupDelegate {
|
|
|
extension KMMeasureController: ComponentSegmentedDelegate {
|
|
|
func componentSegmentedDidSelected(_ view: ComponentSegmented, item: ComponentSegmentedItem) {
|
|
|
if item.properties == line_Property {
|
|
|
- measureType = .Line
|
|
|
+ annotationType = .measureLine
|
|
|
} else if item.properties == multiLine_Property {
|
|
|
- measureType = .Multi_line
|
|
|
+ annotationType = .measurePolyLine
|
|
|
} else if item.properties == polygon_Property {
|
|
|
- measureType = .Polygon
|
|
|
+ annotationType = .measurePolyGon
|
|
|
} else if item.properties == rectangle_Property {
|
|
|
- measureType = .Rectangle
|
|
|
+ annotationType = .measureSquare
|
|
|
}
|
|
|
+
|
|
|
reloadData()
|
|
|
}
|
|
|
}
|