|
@@ -3,6 +3,8 @@ package cn.sagacloud.android.cadengine.items
|
|
|
import android.graphics.*
|
|
|
import android.os.Parcelable
|
|
|
import android.text.TextPaint
|
|
|
+import android.util.Log
|
|
|
+import android.widget.Toast
|
|
|
import cn.sagacloud.android.cadengine.Opt
|
|
|
import cn.sagacloud.android.cadengine.types.TunableSpace
|
|
|
import com.sybotan.android.graphy.SGraphyItem
|
|
@@ -20,7 +22,7 @@ class TunableSpaceItem(val data: TunableSpace, parent: SGraphyItem? = null) : SG
|
|
|
private val paintText = TextPaint()
|
|
|
|
|
|
/** 墙轮廓 */
|
|
|
- private var spacePath: Path? = null
|
|
|
+ private var spacePathList: ArrayList<Path> = ArrayList()
|
|
|
/** 空间轮廓线坐标list */
|
|
|
//private val pointArr = ArrayList<ArrayList<PointF>>()
|
|
|
/** X坐标最小值 */
|
|
@@ -40,42 +42,41 @@ class TunableSpaceItem(val data: TunableSpace, parent: SGraphyItem? = null) : SG
|
|
|
init {
|
|
|
try {
|
|
|
zOrder = 1f
|
|
|
- if (data.outLine != null && data.outLine!!.size > 0 && data.outLine!![0].size > 0) {
|
|
|
- minX = 9999999f
|
|
|
- maxX = -9999999f
|
|
|
- minY = 9999999f
|
|
|
- maxY = -9999999f
|
|
|
-
|
|
|
- for (line in data.outLine!!) {
|
|
|
- if (line.size < 1) {
|
|
|
- mPoints.add(PointF(data.outLine!![0][0].x, data.outLine!![0][0].y))
|
|
|
- continue
|
|
|
- }
|
|
|
- var path = Path()
|
|
|
- path.moveTo(line[0].x, -line[0].y)
|
|
|
- for (p in line) {
|
|
|
- if (p.x < minX) {
|
|
|
- minX = p.x
|
|
|
- }
|
|
|
- if (p.x > maxX) {
|
|
|
- maxX = p.x
|
|
|
- }
|
|
|
- if (-p.y < minY) {
|
|
|
- minY = -p.y
|
|
|
+ if (data.outLine != null && data.outLine!!.size > 0) {
|
|
|
+ for (outLineList in data.outLine!!){
|
|
|
+ minX = 9999999f
|
|
|
+ maxX = -9999999f
|
|
|
+ minY = 9999999f
|
|
|
+ maxY = -9999999f
|
|
|
+
|
|
|
+ for (line in outLineList) {
|
|
|
+ if (line.size < 1) {
|
|
|
+ mPoints.add(PointF(line[0].x, line[0].y))
|
|
|
+ continue
|
|
|
}
|
|
|
- if (-p.y > maxY) {
|
|
|
- maxY = -p.y
|
|
|
+ var path = Path()
|
|
|
+ path.moveTo(line[0].x, -line[0].y)
|
|
|
+ for (p in line) {
|
|
|
+ if (p.x < minX) {
|
|
|
+ minX = p.x
|
|
|
+ }
|
|
|
+ if (p.x > maxX) {
|
|
|
+ maxX = p.x
|
|
|
+ }
|
|
|
+ if (-p.y < minY) {
|
|
|
+ minY = -p.y
|
|
|
+ }
|
|
|
+ if (-p.y > maxY) {
|
|
|
+ maxY = -p.y
|
|
|
+ }
|
|
|
+ mPoints.add(PointF(p.x, p.y))
|
|
|
+ path.lineTo(p.x, -p.y)
|
|
|
}
|
|
|
- mPoints.add(PointF(p.x, p.y))
|
|
|
- path.lineTo(p.x, -p.y)
|
|
|
- }
|
|
|
- path.close()
|
|
|
- if (spacePath == null) {
|
|
|
- spacePath = path
|
|
|
- } else {
|
|
|
- // spacePath.b
|
|
|
+ path.close()
|
|
|
+ spacePathList.add(path)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
} catch (e: Exception) {
|
|
|
e.printStackTrace()
|
|
@@ -200,7 +201,7 @@ class TunableSpaceItem(val data: TunableSpace, parent: SGraphyItem? = null) : SG
|
|
|
* @param rect 绘制区域
|
|
|
*/
|
|
|
override fun onDraw(canvas: Canvas) {
|
|
|
- if (null != spacePath) {
|
|
|
+ if (spacePathList != null && spacePathList.size > 0) {
|
|
|
if (data.isShow) {
|
|
|
paint.color = Color.parseColor("#FFDAAD")
|
|
|
} else if (paint.color == Opt.spaceChoseColor) {
|
|
@@ -219,7 +220,9 @@ class TunableSpaceItem(val data: TunableSpace, parent: SGraphyItem? = null) : SG
|
|
|
}
|
|
|
outPaint.color = Color.parseColor("#7E96FF")
|
|
|
// canvas.drawPath(spacePath!!, outPaint)
|
|
|
- canvas.drawPath(spacePath!!, paint)
|
|
|
+ for (spacePath in spacePathList) {
|
|
|
+ canvas.drawPath(spacePath, paint)
|
|
|
+ }
|
|
|
}
|
|
|
super.onDraw(canvas)
|
|
|
} // Function onDraw()
|