|
@@ -4262,23 +4262,79 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
return
|
|
|
}
|
|
|
} else if type == .measure {
|
|
|
- if !IAPProductsManager.default().isAvailableAllFunction(){
|
|
|
- KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
- return
|
|
|
- }
|
|
|
+// if !IAPProductsManager.default().isAvailableAllFunction(){
|
|
|
+// KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
+// return
|
|
|
+// }
|
|
|
|
|
|
if !self.documentAllowsEdit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ self.listView.toolMode = .measureToolMode
|
|
|
+
|
|
|
+ if distanceMeasureInfoWindowController?.window?.isVisible == true {
|
|
|
+ distanceMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ } else if perimeterMeasureInfoWindowController?.window?.isVisible == true {
|
|
|
+ perimeterMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ } else if areaMeasureInfoWindowController?.window?.isVisible == true {
|
|
|
+ areaMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ }
|
|
|
+
|
|
|
+ if distanceMeasureInfoWindowController == nil {
|
|
|
+ let measureInfo = CPDFDistanceMeasureInfo()
|
|
|
+// distanceMeasureInfoWindowController = CDistanceMeasureInfoWindowController.init(measureInfo: measureInfo)
|
|
|
+ distanceMeasureInfoWindowController = CDistanceMeasureInfoWindowController()
|
|
|
+ distanceMeasureInfoWindowController?.measureInfo = measureInfo
|
|
|
+ distanceMeasureInfoWindowController?.delegate = self
|
|
|
+ }
|
|
|
+ if perimeterMeasureInfoWindowController == nil {
|
|
|
+ let measureInfo = CPDFPerimeterMeasureInfo()
|
|
|
+ perimeterMeasureInfoWindowController = CPerimeterMeasureInfoWindowController()
|
|
|
+ perimeterMeasureInfoWindowController?.measureInfo = measureInfo
|
|
|
+ perimeterMeasureInfoWindowController?.delegate = self
|
|
|
+ }
|
|
|
+ if areaMeasureInfoWindowController == nil {
|
|
|
+ let measureInfo = CPDFAreaMeasureInfo()
|
|
|
+ areaMeasureInfoWindowController = CAreaMeasureInfoWindowController()
|
|
|
+ areaMeasureInfoWindowController?.measureInfo = measureInfo
|
|
|
+ areaMeasureInfoWindowController?.delegate = self
|
|
|
+ }
|
|
|
+
|
|
|
if index == 1 {
|
|
|
-
|
|
|
+ self.listView.annotationType = .line
|
|
|
+
|
|
|
+ distanceMeasureInfoWindowController?.showWindow(nil)
|
|
|
+ distanceMeasureInfoWindowController?.lengthLabel.stringValue = ""
|
|
|
+ distanceMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
+ distanceMeasureInfoWindowController?.xLabel.stringValue = ""
|
|
|
+ distanceMeasureInfoWindowController?.yLabel.stringValue = ""
|
|
|
} else if index == 2 {
|
|
|
-
|
|
|
+ self.listView.annotationType = .polyLine
|
|
|
+
|
|
|
+ perimeterMeasureInfoWindowController?.showWindow(nil)
|
|
|
+ perimeterMeasureInfoWindowController?.lengthLabel.stringValue = ""
|
|
|
+ perimeterMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
} else if index == 3 {
|
|
|
-
|
|
|
+ self.listView.annotationType = .polyGon
|
|
|
+
|
|
|
+ areaMeasureInfoWindowController?.showWindow(nil)
|
|
|
+ areaMeasureInfoWindowController?.areaLabel.stringValue = ""
|
|
|
+ areaMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
} else if index == 4 {
|
|
|
-
|
|
|
+ self.listView.annotationType = .square
|
|
|
+
|
|
|
+ areaMeasureInfoWindowController?.showWindow(nil)
|
|
|
+ areaMeasureInfoWindowController?.areaLabel.stringValue = ""
|
|
|
+ areaMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
+ } else {
|
|
|
+ if let isVisible = distanceMeasureInfoWindowController!.window?.isVisible, isVisible {
|
|
|
+ distanceMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ } else if let isVisible = perimeterMeasureInfoWindowController!.window?.isVisible, isVisible {
|
|
|
+ perimeterMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ } else if let isVisible = areaMeasureInfoWindowController!.window?.isVisible, isVisible {
|
|
|
+ areaMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -4715,6 +4771,137 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// MARK: CDistanceMeasureInfoWindowControllerDelegate
|
|
|
+
|
|
|
+extension KMMainViewController : CDistanceMeasureInfoWindowControllerDelegate {
|
|
|
+ func distanceMeasureInfoWindowControllerSetting(_ distanceMeasureInfoWindowController: CDistanceMeasureInfoWindowController) {
|
|
|
+ let distanceSettingWC = CDistanceSettingWindowController(distanceMeasureInfo: self.distanceMeasureInfoWindowController!.measureInfo)
|
|
|
+ self.distanceMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ distanceSettingWC.delegate = self
|
|
|
+ distanceSettingWC.startModal("")
|
|
|
+ }
|
|
|
+
|
|
|
+ func cancelMeasureInfoWindowControllerSetting(_ distanceMeasureInfoWindowController: CDistanceMeasureInfoWindowController) {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: CPerimeterMeasureInfoWindowControllerDelegate
|
|
|
+
|
|
|
+extension KMMainViewController : CPerimeterMeasureInfoWindowControllerDelegate {
|
|
|
+ func perimeterMeasureInfoWindowControllerSetting(_ perimeterMeasureInfoWindowController: CPerimeterMeasureInfoWindowController) {
|
|
|
+ let distanceSettingWC = CDistanceSettingWindowController(perimeterMeasureInfo: self.perimeterMeasureInfoWindowController!.measureInfo)
|
|
|
+ self.distanceMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ distanceSettingWC.delegate = self
|
|
|
+ distanceSettingWC.startModal("")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: CAreaMeasureInfoWindowControllerDelegate
|
|
|
+
|
|
|
+extension KMMainViewController : CAreaMeasureInfoWindowControllerDelegate {
|
|
|
+ func areaMeasureInfoWindowControllerSetting(_ areaMeasureInfoWindowController: CAreaMeasureInfoWindowController) {
|
|
|
+ let areaSettingWC = CAreaSettingWindowController(measureInfo: self.areaMeasureInfoWindowController!.measureInfo)
|
|
|
+ self.areaMeasureInfoWindowController?.hideFloatingWindow()
|
|
|
+ areaSettingWC.delegate = self
|
|
|
+ areaSettingWC.startModal("")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: CDistanceSettingWindowControllerDelegate
|
|
|
+
|
|
|
+extension KMMainViewController : CDistanceSettingWindowControllerDelegate {
|
|
|
+ func distanceSettingWindowController(_ distanceSettingWindowController: CDistanceSettingWindowController, distanceMeasureInfo: CPDFDistanceMeasureInfo?) {
|
|
|
+ if distanceMeasureInfo != nil {
|
|
|
+ if self.listView.activeAnnotations.count > 0 {
|
|
|
+ if self.listView.activeAnnotation.isKind(of: CPDFLineAnnotation.self) {
|
|
|
+ (self.listView.activeAnnotation as! CPDFLineAnnotation).measureInfo = distanceMeasureInfo
|
|
|
+ self.listView.setNeedsDisplayAnnotationViewFor(self.listView.activeAnnotation.page)
|
|
|
+ }
|
|
|
+ self.distanceMeasureInfoWindowController?.reloadData(with: (self.listView.activeAnnotation as! CPDFLineAnnotation).measureInfo!)
|
|
|
+ } else {
|
|
|
+ distanceMeasureInfo?.leadLength = 0
|
|
|
+ self.listView.distanceMeasureInfo = distanceMeasureInfo
|
|
|
+ self.distanceMeasureInfoWindowController?.reloadData(with: self.listView.distanceMeasureInfo)
|
|
|
+ self.distanceMeasureInfoWindowController?.lengthLabel.stringValue = ""
|
|
|
+ self.distanceMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
+ self.distanceMeasureInfoWindowController?.xLabel.stringValue = ""
|
|
|
+ self.distanceMeasureInfoWindowController?.yLabel.stringValue = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.distanceMeasureInfoWindowController?.showWindow(self)
|
|
|
+ }
|
|
|
+
|
|
|
+ func distanceSettingWindowController(_ distanceSettingWindowController: CDistanceSettingWindowController, perimeterMeasureInfo: CPDFPerimeterMeasureInfo?) {
|
|
|
+ if perimeterMeasureInfo != nil {
|
|
|
+ if self.listView.activeAnnotations.count > 0 {
|
|
|
+ if self.listView.activeAnnotation.isKind(of: CPDFPolylineAnnotation.self) {
|
|
|
+ (self.listView.activeAnnotation as! CPDFPolylineAnnotation).measureInfo = perimeterMeasureInfo
|
|
|
+ self.listView.setNeedsDisplayAnnotationViewFor(self.listView.activeAnnotation.page)
|
|
|
+ }
|
|
|
+ self.perimeterMeasureInfoWindowController?.reloadData(with: (self.listView.activeAnnotation as! CPDFPolylineAnnotation).measureInfo!)
|
|
|
+ } else {
|
|
|
+ self.listView.perimeterMeasureInfo = perimeterMeasureInfo
|
|
|
+ self.perimeterMeasureInfoWindowController?.reloadData(with: self.listView.perimeterMeasureInfo)
|
|
|
+ self.perimeterMeasureInfoWindowController?.lengthLabel.stringValue = ""
|
|
|
+ self.perimeterMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.perimeterMeasureInfoWindowController?.showWindow(self)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: CAreaSettingWindowControllerDelegate
|
|
|
+
|
|
|
+extension KMMainViewController : CAreaSettingWindowControllerDelegate {
|
|
|
+ func areaSettingWindowController(_ areaSettingWindowController: CAreaSettingWindowController, measureInfo: CPDFAreaMeasureInfo?) {
|
|
|
+ if self.listView.annotationType == .square && self.listView.toolMode == .measureToolMode {
|
|
|
+ if measureInfo != nil {
|
|
|
+ if self.listView.activeAnnotations.count > 0 {
|
|
|
+ if self.listView.activeAnnotation.isKind(of: CPDFPolygonAnnotation.self) {
|
|
|
+ (self.listView.activeAnnotation as! CPDFPolygonAnnotation).measureInfo = measureInfo
|
|
|
+ self.listView.setNeedsDisplayAnnotationViewFor(self.listView.activeAnnotation.page)
|
|
|
+ }
|
|
|
+ self.areaMeasureInfoWindowController?.reloadData((self.listView.activeAnnotation as! CPDFPolygonAnnotation).measureInfo!)
|
|
|
+ } else {
|
|
|
+ self.listView.squareAreaMeasureInfo = measureInfo
|
|
|
+ self.areaMeasureInfoWindowController?.reloadData(self.listView.squareAreaMeasureInfo)
|
|
|
+ self.areaMeasureInfoWindowController?.areaLabel.stringValue = ""
|
|
|
+ self.areaMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.areaMeasureInfoWindowController?.showWindow(self)
|
|
|
+ } else if self.listView.annotationType == .polyGon && self.listView.toolMode == .measureToolMode {
|
|
|
+ if measureInfo != nil {
|
|
|
+ if self.listView.activeAnnotations.count > 0 {
|
|
|
+ if self.listView.activeAnnotation.isKind(of: CPDFPolygonAnnotation.self) {
|
|
|
+ (self.listView.activeAnnotation as! CPDFPolygonAnnotation).measureInfo = measureInfo
|
|
|
+ self.listView.setNeedsDisplayAnnotationViewFor(self.listView.activeAnnotation.page)
|
|
|
+ }
|
|
|
+ self.areaMeasureInfoWindowController?.reloadData((self.listView.activeAnnotation as! CPDFPolygonAnnotation).measureInfo!)
|
|
|
+ } else {
|
|
|
+ self.listView.polygonAreaMeasureInfo = measureInfo
|
|
|
+ self.areaMeasureInfoWindowController?.reloadData(self.listView.polygonAreaMeasureInfo)
|
|
|
+ self.areaMeasureInfoWindowController?.areaLabel.stringValue = ""
|
|
|
+ self.areaMeasureInfoWindowController?.angleLabel.stringValue = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.areaMeasureInfoWindowController?.showWindow(self)
|
|
|
+ } else {
|
|
|
+ if measureInfo != nil {
|
|
|
+ if self.listView.activeAnnotations.count > 0 {
|
|
|
+ if self.listView.activeAnnotation.isKind(of: CPDFPolygonAnnotation.self) {
|
|
|
+ (self.listView.activeAnnotation as! CPDFPolygonAnnotation).measureInfo = measureInfo
|
|
|
+ self.listView.setNeedsDisplayAnnotationViewFor(self.listView.activeAnnotation.page)
|
|
|
+ }
|
|
|
+ self.areaMeasureInfoWindowController?.reloadData((self.listView.activeAnnotation as! CPDFPolygonAnnotation).measureInfo!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.areaMeasureInfoWindowController?.showWindow(self)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// MARK: -
|
|
|
// MARK: - Mouse
|
|
|
extension KMMainViewController {
|