Browse Source

*********************************** wx *********************************

zhangweixin 3 years ago
parent
commit
39f9df7e70

BIN
.idea/caches/build_file_checksums.ser


+ 23 - 13
app/src/main/java/cn/sagacloud/cadengine/MainActivity.kt

@@ -13,33 +13,44 @@ import android.util.Log
 import cn.sagacloud.android.cadengine.FloorScene
 import cn.sagacloud.android.cadengine.test.GraphyFmItem
 import cn.sagacloud.android.cadengine.test.GraphyTwoItem
+import com.sybotan.android.graphy.SGraphyView
 import kotlinx.android.synthetic.main.activity_main.*
 import org.jetbrains.anko.doAsync
 import org.jetbrains.anko.uiThread
 
 class MainActivity : AppCompatActivity() {
     val scene = FloorScene()
-    val path = "base/0d5b6dd89b7011eb88b7b12cd4310b6f.jsonz"
+    val path = "base/1f3b3482b2f411eb8c7f7b6673028f6a.jsonz"
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_main)
         addPermission()
         graphyView.scene = scene
+        /** view 实例 */
+        val sGraphyView = SGraphyView(this)
+        /** 添加到外层控件中 */
+        fl_layout.addView(sGraphyView)
 
         /** 开启异步 */
         doAsync {
 //            scene.loadUrl("http://adm.sagacloud.cn/image-service/common/file_get?systemId=revit&key=base/61a99fc1a66b11eb8f633d7605ae9def.jsonz")
 //            scene.loadUrl("http://api.sagacloud.cn/dp-auxiliary/image-service/common/file_get?systemId=revit&key=Fl42010500018b580334dcf111e8a553db1eadfac99320190803114958bim.jsonz",false)
-//            val downloadGZIPMap = HttpDownloadMap.downloadGZIPMap(path)
-//            if (downloadGZIPMap!=null) {
-//                scene.loadData(downloadGZIPMap!!)
-//            }
+            val downloadGZIPMap = HttpDownloadMap.downloadGZIPMap(path)
+            if (downloadGZIPMap!=null) {
+                scene.loadData(downloadGZIPMap!!)
+            }
             val graphyFmItem = GraphyFmItem()
+            /** item 显示 */
             graphyFmItem.show()
+            /** item 隐藏 */
+            graphyFmItem.hide()
+            /** 不跟随view 缩放,false 是跟随,true 是不跟随 */
             graphyFmItem.isVisible = true
+            /** 一定 item 到指定位置 */
             graphyFmItem.moveTo(300f,300f)
-//            graphyFmItem.rotate = 60f // (20f*Math.PI / 180f) as Float
+            /** 旋转单位为 度 */
+            graphyFmItem.rotate = 60f // (20f*Math.PI / 180f) as Float
             graphyFmItem.isTransform = false
             scene.addItem(graphyFmItem)
             val graphyTwoItem = GraphyTwoItem()
@@ -50,7 +61,7 @@ class MainActivity : AppCompatActivity() {
 //            graphyTwoItem.show()
 //            graphyTwoItem.flag = true
 //            graphyTwoItem.parent = graphyFmItem
-            graphyTwoItem.moveTo(100f,100f)
+//            graphyTwoItem.moveTo(100f,100f)
             graphyTwoItem.color = Color.RED
 
 
@@ -58,15 +69,14 @@ class MainActivity : AppCompatActivity() {
             /** 主线程处理ui */
             uiThread {
 
-
                 /** 适应屏幕大小 */
                 graphyView.fitSceneToView()
                 /** 限定移动范围不超出屏幕 */
-//                graphyView.moveRange()
-                graphyView.post {
-                    Log.e("viewW",graphyView.width.toString())
-                }
-                Log.e("viewH",graphyView.measuredHeight.toString())
+                graphyView.moveRange()
+//                graphyView.post {
+//                    Log.e("viewW",graphyView.width.toString())
+//                }
+//                Log.e("viewH",graphyView.measuredHeight.toString())
             }
         }
     } // Function onCreate()

+ 1 - 0
build.gradle

@@ -30,6 +30,7 @@ buildscript {
         mavenCentral()
         jcenter()
         google()
+        maven{url MAVEN_REPO_PUBLIC_URL}
     }
     dependencies {
 

+ 5 - 5
cadengine/build.gradle

@@ -83,13 +83,13 @@ dependencies {
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // Sybotan依赖
-//    implementation group: "cn.sagacloud", name: "sybotan-android-base", version: SYBOTAN_ANDROID_VERSION
-//    implementation group: "cn.sagacloud", name: "sybotan-android-graphy", version: SYBOTAN_ANDROID_VERSION
-//    implementation group: "cn.sagacloud", name: "sybotan-android-database", version: SYBOTAN_ANDROID_VERSION
+    implementation group: "cn.sagacloud", name: "sybotan-android-base", version: SYBOTAN_ANDROID_VERSION
+    implementation group: "cn.sagacloud", name: "sybotan-android-graphy", version: SYBOTAN_ANDROID_VERSION
+    implementation group: "cn.sagacloud", name: "sybotan-android-database", version: SYBOTAN_ANDROID_VERSION
     implementation group: 'cn.sagacloud', name: 'saga-kotlin-base', version: SAGA_KOTLIN_VERSION
     implementation group: 'cn.sagacloud', name: 'saga-kotlin-database', version: SAGA_KOTLIN_VERSION
-    implementation project(':sybotan-android-base')
-    implementation project(':sybotan-android-database')
+//    implementation project(':sybotan-android-base')
+//    implementation project(':sybotan-android-database')
     implementation project(':sybotan-android-graphy')
 
     //noinspection GradleDependency

+ 16 - 16
cadengine/src/main/java/cn/sagacloud/android/cadengine/FloorScene.kt

@@ -165,14 +165,14 @@ open class FloorScene : SGraphyScene() {
                 addWall(wall);
             }
         }
-
-        // 添加虚拟墙
-        if (elements.virtualWalls != null) {
-            for (wall in elements.virtualWalls!!) {
-                addVirtualWall(wall);
-            }
-        }
-
+//
+//        // 添加虚拟墙
+//        if (elements.virtualWalls != null) {
+//            for (wall in elements.virtualWalls!!) {
+//                addVirtualWall(wall);
+//            }
+//        }
+//
         // 添加柱子
         if (elements.columns != null) {
             for (column in elements.columns!!) {
@@ -193,15 +193,15 @@ open class FloorScene : SGraphyScene() {
                 addSpaceName(space)
             }
         }
-
+//
         // 添加门
-        if (elements.doors != null) {
-            for (door in elements.doors!!) {
-                addDoor(door);
-            }
-        }
-
-        // 添加窗户
+//        if (elements.doors != null) {
+//            for (door in elements.doors!!) {
+//                addDoor(door);
+//            }
+//        }
+//
+//        // 添加窗户
         if (elements.windows != null) {
             for (window in elements.windows!!) {
                 addWindow(window);

+ 41 - 79
cadengine/src/main/java/cn/sagacloud/android/cadengine/items/SpaceItem.kt

@@ -15,8 +15,6 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
     private val paint = Paint()
     /** 墙轮廓 */
     private var spacePath: Path? = null
-    /** 空间轮廓线坐标list  */
-    private val pointArr = ArrayList<ArrayList<PointF>>()
     /** X坐标最小值  */
     private var minX = 0f
     /** X坐标最大值  */
@@ -26,6 +24,8 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
     /** Y坐标最大值  */
     private var maxY = 0f
 
+    private var a=(1+Math.random()*(10-1+1))
+
     init {
         try {
             zOrder = 1f
@@ -34,12 +34,10 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
                 maxX = data.outLine!![0][0].x
                 minY = data.outLine!![0][0].y
                 maxY = data.outLine!![0][0].y
-
                 for (line in data.outLine!!) {
                     if (line.size < 1) {
                         continue
                     }
-
                     val path = Path()
                     path.moveTo(line[0].x, -line[0].y)
                     for (p in line) {
@@ -60,43 +58,15 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
                     path.close()
                     if (spacePath == null) {
                         spacePath = path;
-                    } else {
-                        // spacePath.b
-                    }
+                    } else { // spacePath.b
+                         }
                 }
             }
         } catch (e: Exception) {
             e.printStackTrace()
         }
-
-        //if (data.outLine!!.size > 0) {
-//            val tempArr = this.data.OutLine
-//            this.minX = tempArr[0][0].x
-//            this.maxX = this.minX
-//            this.minY = -(tempArr[0][0].y)
-//            this.maxY = this.minY
-            // 处理轮廓点数组,同时计算最大最小值
-//            this.pointArr = tempArr.map(t => {
-//                var tempArr = t.map(it => {
-//                    var x = it.X,
-//                    y = -it.Y
-//                    if (x < this.minX) {
-//                        this.minX = x
-//                    }
-//                    if (y < this.minY) {
-//                        this.minY = y
-//                    }
-//                    if (x > this.maxX) {
-//                        this.maxX = x
-//                    }
-//                    if (y > this.maxY) {
-//                        this.maxY = y
-//                    }
-//                    return SPoint(x, y)
-//                })
-//                return tempArr
-//            })
-        //}
+        setColor(paint, a.toInt())
+        paint.style = Paint.Style.FILL
     } // Constructor
 
     /**
@@ -109,47 +79,6 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
     } // Function boundingRect()
 
     /**
-     * 判断点是否在区域内
-     *
-     * @param x
-     * @param y
-     */
-    override fun contains(x: Float, y: Float): Boolean {
-//        if (this.data?.OutLine!!.size > 0) {
-//            var nCross: Double = 0.0
-//            var point = ArrayList<String>()
-//            point.add("x")
-//            point.add("y")
-//            var APoints = this.data?.OutLine!!.get(0)
-//            var length = APoints.size
-//            var p1: ArrayList<Point>? = null
-//            var p2: ArrayList<Point>? = null
-//            var i: Int? = null
-//            var xinters: Double? = null
-//            p1 = APoints.get(0)
-//            i == 1
-//            while (i!! <= length){
-//                p2 = APoints.get((i % length))
-//                if (point[0] > Math.min(p1.X, p2.X) && point[0] <= Math.max(p1.X, p2.X)) {
-//                    if (point[1] <= Math.max(p1.Y, p2.Y)) {
-//                        if (p1.X != p2.X) {
-//                            //计算位置信息
-//                            xinters = ((point[0] - p1.X) * (p2.Y - p1.Y)) / (p2.X - p1.X) + p1.Y
-//                            if (p1.Y == p2.Y || point[1] <= xinters) {
-//                                nCross++
-//                            }
-//                        }
-//                    }
-//                }
-//                p1 = p2
-//                i++
-//            }
-//            return nCross % 2 === 1
-//        }
-        return false
-    } // Function contains()
-
-    /**
      * Item绘制操作
      *
      * @param   canvas          画布
@@ -157,11 +86,44 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
      */
     override fun onDraw(canvas : Canvas) {
         if (null != spacePath) {
-            paint.style = Paint.Style.FILL
-            paint.color = Opt.spaceColor;
             canvas.drawPath(spacePath!!, paint)
 
         }
     } // Function onDraw()
 
+    fun setColor(pen:Paint,a:Int){
+        when(a){
+            1 ->{
+                pen.color =  Color.argb(20,139,0,139)
+            }
+            2 ->{
+                pen.color = Color.argb(20,220,20,60)
+            }
+            3 ->{
+                pen.color = Color.argb(20,255,20,147)
+            }
+            4 ->{
+                pen.color = Color.argb(20,75,0,130)
+            }
+            5 ->{
+                pen.color = Color.argb(20,123,104,238)
+            }
+            6 ->{
+                pen.color = Color.argb(20,0,0,205)
+            }
+            7 ->{
+                pen.color = Color.argb(20,119,136,153)
+            }
+            8 ->{
+                pen.color = Color.argb(20,	30,144,255)
+            }
+            9 ->{
+                pen.color = Color.argb(20,255,182,193)
+            }
+            10 ->{
+                pen.color = Color.argb(20,123,104,238)
+            }
+        }
+    } // Fun
+
 } // Class SpaceItem

+ 4 - 7
cadengine/src/main/java/cn/sagacloud/android/cadengine/items/WallItem.kt

@@ -8,7 +8,7 @@ import com.sybotan.android.graphy.SGraphyItem
 /**
  * 墙item
  *
- * @author  郝建龙
+ * @author  张维新
  */
 class WallItem(private val data: Wall, parent: SGraphyItem? = null) : SGraphyItem(parent) {
     /** 画笔 */
@@ -34,12 +34,10 @@ class WallItem(private val data: Wall, parent: SGraphyItem? = null) : SGraphyIte
                 maxX = data.outLine!![0][0].x
                 minY = data.outLine!![0][0].y
                 maxY = data.outLine!![0][0].y
-
                 for (line in data.outLine!!) {
                     if (line.size < 1) {
                         continue
                     }
-
                     val path = Path()
                     path.moveTo(line[0].x, -line[0].y)
                     for (p in line) {
@@ -64,6 +62,8 @@ class WallItem(private val data: Wall, parent: SGraphyItem? = null) : SGraphyIte
         } catch (e: Exception) {
             e.printStackTrace()
         }
+        paint.style = Paint.Style.FILL
+        paint.color = Opt.wallColor
     } // Constructor
 
     /**
@@ -79,14 +79,11 @@ class WallItem(private val data: Wall, parent: SGraphyItem? = null) : SGraphyIte
      * Item绘制操作
      *
      * @param   canvas          画布
-     * @param   rect            绘制区域
      */
     override fun onDraw(canvas : Canvas) {
-        paint.style = Paint.Style.FILL
-        paint.color = Opt.wallColor
+
         for (path in pathList) {
             canvas.drawPath(path, paint)
         }
-
     } // Function onDraw()
 } // Class WallItem

+ 1 - 1
cadengine/src/main/java/cn/sagacloud/android/cadengine/test/GraphyFmItem.kt

@@ -105,7 +105,7 @@ class GraphyFmItem(parent: SGraphyItem? = null) : SGraphyItem(parent) {
      *  点击
      */
     override fun onSingleTapUp(e: SMotionEvent): Boolean {
-       Log.e("被点击1","**************************************")
+       Log.e("被点击1","$e**************************************")
         return true
     }