|
@@ -61,6 +61,7 @@ import com.bumptech.glide.Glide
|
|
|
import com.framework.mvvm.model.db.entity.StrInfosforEquip
|
|
|
import com.framework.mvvm.mv.AdmViewModel
|
|
|
import com.google.gson.Gson
|
|
|
+import com.google.gson.reflect.TypeToken
|
|
|
import com.lzy.okgo.OkGo
|
|
|
import com.lzy.okgo.callback.FileCallback
|
|
|
import com.lzy.okgo.model.Response
|
|
@@ -240,6 +241,9 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
private lateinit var webview: WebView
|
|
|
private lateinit var quesIma: ImageView
|
|
|
private lateinit var problemLl: LinearLayoutCompat
|
|
|
+ private lateinit var ProblemRg: RadioGroup
|
|
|
+ private lateinit var pointRb: RadioButton
|
|
|
+ private lateinit var lineRb: RadioButton
|
|
|
private lateinit var problemClose: TextView
|
|
|
private lateinit var problemDone: TextView
|
|
|
private lateinit var problemSave: TextView
|
|
@@ -417,6 +421,9 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
addSpaceDetail2 = findViewById(R.id.addSpaceDetail2)
|
|
|
resetSpaceState = findViewById(R.id.resetSpaceState)
|
|
|
problemLl = findViewById(R.id.problemLl)
|
|
|
+ ProblemRg = findViewById(R.id.ProblemRg)
|
|
|
+ pointRb = findViewById(R.id.pointRb)
|
|
|
+ lineRb = findViewById(R.id.lineRb)
|
|
|
problemClose = findViewById(R.id.problemClose)
|
|
|
problemDone = findViewById(R.id.problemDone)
|
|
|
problemSave = findViewById(R.id.problemSave)
|
|
@@ -557,16 +564,129 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
realDistance = distance * scene.defaultPointScale / graphyView.scale
|
|
|
var hasChoose = false
|
|
|
for (point in scene.pointItemList) {
|
|
|
- val sqrt = Math.sqrt(
|
|
|
- Math.pow(
|
|
|
- Math.abs(x - point.data.mX).toDouble(),
|
|
|
- 2.0
|
|
|
- ) + Math.pow(Math.abs(y - point.data.mY).toDouble(), 2.0)
|
|
|
- ).toInt()
|
|
|
- if (sqrt < realDistance) {
|
|
|
- hasChoose = true
|
|
|
- showDotDetail(point)
|
|
|
- break
|
|
|
+ if (!CommonUtils.IsNull(point.data.points.size) && point.data.points.size > 1) {
|
|
|
+ var dist = 500.00
|
|
|
+ for (index in 0..point.data.points.size - 2) {
|
|
|
+ val point1 = point.data.points.get(index)
|
|
|
+ var point2 = point.data.points.get(index + 1)
|
|
|
+
|
|
|
+ val l1 = Math.sqrt(
|
|
|
+ Math.pow(
|
|
|
+ Math.abs(point1.x - point2.x).toDouble(),
|
|
|
+ 2.0
|
|
|
+ ) + Math.pow(Math.abs(point1.y - point2.y).toDouble(), 2.0)
|
|
|
+ ).toFloat()
|
|
|
+ val l2 = Math.sqrt(
|
|
|
+ Math.pow(
|
|
|
+ Math.abs(point1.x - x).toDouble(),
|
|
|
+ 2.0
|
|
|
+ ) + Math.pow(Math.abs(point1.y + y).toDouble(), 2.0)
|
|
|
+ ).toFloat()
|
|
|
+ val l3 = Math.sqrt(
|
|
|
+ Math.pow(
|
|
|
+ Math.abs(point2.x - x).toDouble(),
|
|
|
+ 2.0
|
|
|
+ ) + Math.pow(Math.abs(point2.y + y).toDouble(), 2.0)
|
|
|
+ ).toFloat()
|
|
|
+ val halfP = (l1 + l2 + l3) / 2
|
|
|
+ val s =
|
|
|
+ Math.sqrt(halfP * (halfP - l1) * (halfP - l2) * (halfP - l3).toDouble())
|
|
|
+ val h = 2 * s / l1
|
|
|
+ if (h < dist) {
|
|
|
+ dist = h
|
|
|
+ var k1: Float
|
|
|
+ if (point1.x - point2.x == 0f) {
|
|
|
+ k1 = 0f
|
|
|
+ } else {
|
|
|
+ k1 = (point1.y - point2.y) / (point1.x - point2.x)
|
|
|
+ }
|
|
|
+
|
|
|
+ val b1 = point1.y - k1 * point1.x
|
|
|
+
|
|
|
+ var k2: Float
|
|
|
+ if (k1 == 0f) {
|
|
|
+ k2 = 0f
|
|
|
+ } else {
|
|
|
+ k2 = -1 / k1
|
|
|
+ }
|
|
|
+
|
|
|
+ val b2 = y - k2 * x
|
|
|
+
|
|
|
+ val x1 = (b2 - b1) / (k1 - k2)
|
|
|
+ val y1 = k2 * (x) + b2
|
|
|
+
|
|
|
+ if (point1.x - point2.x == 0f) {
|
|
|
+ scene.point.mX = point1.x
|
|
|
+ if (Math.abs(k1) == 0f) {
|
|
|
+ scene.point.mY = y
|
|
|
+ } else {
|
|
|
+ if (point1.y - point2.y == 0f) {
|
|
|
+ scene.point.mY = -point1.y
|
|
|
+ } else {
|
|
|
+ scene.point.mY = y1
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (Math.abs(k1) == 0f) {
|
|
|
+ scene.point.mX = x
|
|
|
+ } else {
|
|
|
+ scene.point.mX = x1
|
|
|
+ }
|
|
|
+ if (point1.y - point2.y == 0f) {
|
|
|
+ scene.point.mY = -point1.y
|
|
|
+ } else {
|
|
|
+ scene.point.mY = y1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ hasChoose = true
|
|
|
+ ProblemRg.visibility = View.GONE
|
|
|
+ pointRb.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+
|
|
|
+ }
|
|
|
+ lineRb.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+
|
|
|
+ }
|
|
|
+ lineRb.isChecked = true
|
|
|
+ for (p in point.data.points) {
|
|
|
+ var pipe = PipeLine()
|
|
|
+ var pointf = PointF()
|
|
|
+ pointf.x = p.x
|
|
|
+ pointf.y = p.y
|
|
|
+ scene.pipeLineList.add(pointf)
|
|
|
+ pipe.points!!.addAll(scene.pipeLineList)
|
|
|
+ var item = PipeLineItem(pipe, null)
|
|
|
+ item!!.isVisible = true
|
|
|
+ item!!.zOrder = 100000f
|
|
|
+ scene.drawingPipeItemList.add(item)
|
|
|
+
|
|
|
+ }
|
|
|
+ showDotDetail(point)
|
|
|
+ break
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ val sqrt = Math.sqrt(
|
|
|
+ Math.pow(
|
|
|
+ Math.abs(x - point.data.mX).toDouble(),
|
|
|
+ 2.0
|
|
|
+ ) + Math.pow(Math.abs(y - point.data.mY).toDouble(), 2.0)
|
|
|
+ ).toInt()
|
|
|
+ if (sqrt < realDistance) {
|
|
|
+ hasChoose = true
|
|
|
+ ProblemRg.visibility = View.GONE
|
|
|
+ pointRb.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+
|
|
|
+ }
|
|
|
+ lineRb.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+
|
|
|
+ }
|
|
|
+ pointRb.isChecked = true
|
|
|
+ showDotDetail(point)
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (!hasChoose) {
|
|
@@ -1052,6 +1172,28 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
ProblemDot.mY = 0f
|
|
|
spaceStructure.visibility = View.GONE
|
|
|
problemLl.visibility = View.VISIBLE
|
|
|
+ ProblemRg.visibility = View.VISIBLE
|
|
|
+ pointRb.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+ if (isChecked) {
|
|
|
+ scene.type = "dot"
|
|
|
+ for (item in scene.drawingPipeItemList) {
|
|
|
+ scene.removeItem(item)
|
|
|
+ }
|
|
|
+ scene.pipeLineList.clear()
|
|
|
+ scene.drawingPipeItemList.clear()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lineRb.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+ if (isChecked) {
|
|
|
+ scene.type = "pipe"
|
|
|
+ if (addPoint != null) {
|
|
|
+ scene.removeItem(addPoint!!)
|
|
|
+ scene.pointItemList.remove(addPoint)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pointRb.isChecked = true
|
|
|
showDotDetail(null)
|
|
|
initProblemPicture(null)
|
|
|
|
|
@@ -1361,16 +1503,21 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
mPoints.add(point3)
|
|
|
|
|
|
for (model in list) {
|
|
|
- var position = gson.fromJson(model.position, Position::class.java)
|
|
|
- val polygonContainsPoint = Lasso.isPolygonContainsPoint(
|
|
|
- mPoints,
|
|
|
- android.graphics.Point(
|
|
|
- position.x.toFloat().toInt(),
|
|
|
- position.y.toFloat().toInt()
|
|
|
- )
|
|
|
- )
|
|
|
- if (polygonContainsPoint) {
|
|
|
+ if (model.geomType.equals("point")) {
|
|
|
+ var position = gson.fromJson(model.position, Position::class.java)
|
|
|
+// val polygonContainsPoint = Lasso.isPolygonContainsPoint(
|
|
|
+// mPoints,
|
|
|
+// android.graphics.Point(
|
|
|
+// position.x.toFloat().toInt(),
|
|
|
+// position.y.toFloat().toInt()
|
|
|
+// )
|
|
|
+// )
|
|
|
+// if (polygonContainsPoint) {
|
|
|
val point = Point()
|
|
|
+ val f = PointF()
|
|
|
+ f.x = position.x.toFloat()
|
|
|
+ f.y = position.y.toFloat()
|
|
|
+ point.points.add(f)
|
|
|
point.mX = position.x.toFloat()
|
|
|
point.mY = position.y.toFloat()
|
|
|
point.id = model.id
|
|
@@ -1382,7 +1529,25 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
}
|
|
|
|
|
|
})
|
|
|
+ } else if (model.geomType.equals("line")) {
|
|
|
+ val geomList = gson.fromJson<List<PointF>>(
|
|
|
+ model.position,
|
|
|
+ object : TypeToken<List<PointF?>?>() {}.type
|
|
|
+ )
|
|
|
+ val point = Point()
|
|
|
+ point.points.addAll(geomList)
|
|
|
+ point.id = model.id
|
|
|
+ point.content = model.content
|
|
|
+ point.photos = model.photos
|
|
|
+ val addPoint = graphyHelper.addPoint(point)
|
|
|
+ addPoint.setOnActionMove(object : PointItem.ActionMove {
|
|
|
+ override fun onActionMove(event: MotionEvent) {
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1780,6 +1945,11 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
scene.removeItem(addPoint!!)
|
|
|
scene.pointItemList.remove(addPoint)
|
|
|
}
|
|
|
+ for (item in scene.drawingPipeItemList) {
|
|
|
+ scene.removeItem(item)
|
|
|
+ }
|
|
|
+ scene.drawingPipeItemList.clear()
|
|
|
+ scene.pipeLineList.clear()
|
|
|
scene.type = "normal"
|
|
|
problemLl.visibility = View.GONE
|
|
|
spaceStructure.visibility = View.VISIBLE
|
|
@@ -1787,10 +1957,16 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
|
|
|
/** 问题-保存 */
|
|
|
problemSave.setOnClickListener {
|
|
|
- if ((point == null || point.data.mX == 0f) && ProblemDot.mX == 0f) {
|
|
|
+ if (pointRb.isChecked && (point == null || point.data.mX == 0f) && ProblemDot.mX == 0f) {
|
|
|
ToastUtils.showMyToast("请扎点")
|
|
|
return@setOnClickListener
|
|
|
}
|
|
|
+ if (point == null) {
|
|
|
+ if (lineRb.isChecked && (CommonUtils.IsNull(scene.drawingPipeItemList) || scene.drawingPipeItemList.size == 1)) {
|
|
|
+ ToastUtils.showMyToast("请扎点")
|
|
|
+ return@setOnClickListener
|
|
|
+ }
|
|
|
+ }
|
|
|
scene.choseSpace?.let {
|
|
|
graphyVM.addProblem(
|
|
|
point,
|
|
@@ -1798,9 +1974,15 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
problemDesc.text.toString(),
|
|
|
it,
|
|
|
ProblemDot.mX,
|
|
|
- ProblemDot.mY
|
|
|
+ ProblemDot.mY,
|
|
|
+ scene.drawingPipeItemList, lineRb.isChecked
|
|
|
)
|
|
|
}
|
|
|
+ for (item in scene.drawingPipeItemList) {
|
|
|
+ scene.removeItem(item)
|
|
|
+ }
|
|
|
+ scene.pipeLineList.clear()
|
|
|
+ scene.drawingPipeItemList.clear()
|
|
|
scene.type = "normal"
|
|
|
problemLl.visibility = View.GONE
|
|
|
}
|