private void Format_Grid(DataGridView dgv) { if (dgv.Name == dgv_cab1.Name) { CableData.Cable_Length = MyList.StringToDouble(txt_cab1_lc.Text, 0.0); CableData.Strand_Area = MyList.StringToDouble(txt_cab1_a.Text, 0.0); CableData.Elasticity_Modulus = MyList.StringToDouble(txt_cab1_Es.Text, 0.0); CableData.Strands_Number = MyList.StringToInt(txt_cab1_Ns.Text, 0); CableData.Jacking_End_Slip = MyList.StringToDouble(txt_cab1_Sl.Text, 0.0); CableData.Friction_Coefficient = MyList.StringToDouble(txt_cab1_mu.Text, 0.0); CableData.Wobble_Coefficient = MyList.StringToDouble(txt_cab1_k.Text, 0.0); } CableData.Read_Data_From_Grid(dgv); try { chk_support.Checked = CableData.Height_from_sofit.F1 != 0.0; chk_deff.Checked = CableData.Height_from_sofit.F2 != 0.0; chk_L8.Checked = CableData.Height_from_sofit.F3 != 0.0; chk_L4.Checked = CableData.Height_from_sofit.F4 != 0.0; chk_3L8.Checked = CableData.Height_from_sofit.F5 != 0.0; chk_L2.Checked = CableData.Height_from_sofit.F6 != 0.0; } catch (Exception ex) { } }
private void finish_process() { isCableInstantiated = false; iCable = null; nodeDataController = null; iCableDataController = null; isConnected = false; }
private void btn_ok_Click(object sender, EventArgs e) { //Average_Forces_after_friction_and_Slip avf = new Average_Forces_after_friction_and_Slip(); CableData.Cable_Length = MyList.StringToDouble(txt_cab1_lc.Text, 0.0); CableData.Strand_Area = MyList.StringToDouble(txt_cab1_a.Text, 0.0); CableData.Elasticity_Modulus = MyList.StringToDouble(txt_cab1_Es.Text, 0.0); CableData.Strands_Number = MyList.StringToInt(txt_cab1_Ns.Text, 0); CableData.Jacking_End_Slip = MyList.StringToDouble(txt_cab1_Sl.Text, 0.0); //avf.Sheathing_Type = MyList.StringToDouble(txt_cab1_lc.Text, 0.0); CableData.Friction_Coefficient = MyList.StringToDouble(txt_cab1_mu.Text, 0.0); CableData.Wobble_Coefficient = MyList.StringToDouble(txt_cab1_k.Text, 0.0); #region Chiranjit [2013 06 20] CableData.PresenseOfCable.F1 = chk_support.Checked ? (Cable_No == 7) ? 1.052 : 2.0 : 0.0; CableData.PresenseOfCable.F2 = chk_deff.Checked ? (Cable_No == 7) ? 1.052 : 2.0 :0.0; CableData.PresenseOfCable.F3 = chk_L8.Checked ? (Cable_No == 7) ? 1.052 : 2.0 : 0.0; CableData.PresenseOfCable.F4 = chk_L4.Checked ? (Cable_No == 7) ? 1.052 : 2.0 :0.0; CableData.PresenseOfCable.F5 = chk_3L8.Checked ? (Cable_No == 7) ? 1.052 : 2.0 :0.0; CableData.PresenseOfCable.F6 = chk_L2.Checked ? (Cable_No == 7) ? 1.052 : 2.0 :0.0; #endregion Chiranjit [2013 06 20] CableData.Read_Data_From_Grid(dgv_cab1); Cable_Calculations.Add(string.Format("Cable {0}", Cable_No)); Cable_Calculations.Add(string.Format("-------")); Cable_Calculations.Add(string.Format("")); Cable_Calculations.Add(string.Format("Total Length of Cable = {0:f3} m.", CableData.Cable_Length)); Cable_Calculations.Add(string.Format("Area of the Strand = a = {0:f3} Sq.mm", CableData.Strand_Area)); Cable_Calculations.Add(string.Format("Modulus of Elasticity = Es = {0:f3} Gpa", CableData.Elasticity_Modulus)); Cable_Calculations.Add(string.Format("Number of Strands = Ns = {0}", CableData.Strands_Number)); Cable_Calculations.Add(string.Format("Slip at Jacking End = Sl = {0:f3} mm.", CableData.Jacking_End_Slip)); Cable_Calculations.Add(string.Format("Type of Sheathing = HDPE")); Cable_Calculations.Add(string.Format("Coefficient of Friction (µ) = {0:f3}", CableData.Friction_Coefficient)); Cable_Calculations.Add(string.Format("Wobble Coefficient (k) = {0:f3}", CableData.Wobble_Coefficient)); Cable_Calculations.Add(""); Cable_Calculations.Add(""); Cable_Calculations.Add(string.Format("TABLE 9.{0}: SUMMARY of Average Forces after friction and Slip in Cable {0}:", Cable_No)); Cable_Calculations.Add(string.Format("-----------------------------------------------------------------------------")); Cable_Calculations.Add(""); Cable_Calculations.AddRange(CableData.Get_Table_Data()); Cable_Calculations.Add(""); Cable_Calculations.Add(""); Cable_Calculations.Add(string.Format("Calculation Details for TABLE {0}, for Cable {1}:", (8 + Cable_No), Cable_No)); Cable_Calculations.Add("---------------------------------------------"); Cable_Calculations.Add(""); Cable_Calculations.Add(""); Cable_Calculations.AddRange(CableData.list); this.DialogResult = DialogResult.OK; this.Close(); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Space)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (Input.GetMouseButton(0)) { Debug.DrawRay(transform.position, ray.direction * hit.distance, Color.yellow); mousePos = yOffset(hit.point, 0.5f); if (hit.collider.tag == "Node" && !isCableInstantiated) { isCableInstantiated = true; initialMousePos = yOffset(hit.point, 0.5f); // ケーブル生成 iCable = Instantiate(cable, hit.point, cable.transform.rotation).gameObject; // ケーブルと元ノードのデータ制御を取得 iCableDataController = iCable.GetComponent <CableData>(); nodeDataController = hit.collider.GetComponent <NodeData>(); // 生成したケーブルにケーブルIDを登録 iCableDataController.cableId = lastCableId++; // 生成したケーブルに元ノードのノードIDを登録 iCableDataController.sourceId = nodeDataController.nodeId; // ノードに生成したケーブルのケーブルIDを追加 nodeDataController.connectedCableIds.Add(iCableDataController.cableId); } if (isCableInstantiated && !isConnected) { // 元ノードからマウスカーソルの方向に伸びるようにするスクリプト mediumPos = (mousePos - initialMousePos) / 2.0f; // オブジェクトの中心は2点間の中間 float dist = Vector3.Distance(mousePos, initialMousePos); // 距離を算出 iCable.transform.position = mediumPos + initialMousePos; // 元ノードのベクトルにオブジェクトの中心ベクトルを足す iCable.transform.localScale = new Vector3(iCable.transform.localScale.x, iCable.transform.localScale.y, dist); // 元ノードからマウスカーソルまで伸ばす Vector3 lookVec = new Vector3(mousePos.x, 0.5f, mousePos.z); // 以下2行はマウスカーソルの方向に向ける iCable.transform.LookAt(lookVec); } } else if (Input.GetMouseButtonUp(0)) { if (hit.collider.tag == "Node" && isCableInstantiated) { // 先ノードのデータ制御を取得 nodeDataController = hit.collider.GetComponent <NodeData>(); // 接続先ノードは元ノードでなければ接続する。 // 元ノードであるときは接続しないでケーブルを消す if (nodeDataController.nodeId != iCableDataController.sourceId) { isConnected = true; // ケーブルに先ノードIDを登録 iCableDataController.targetId = nodeDataController.nodeId; // 先ノードにケーブルIDを登録 nodeDataController.connectedCableIds.Add(iCableDataController.cableId); // 終了処理的な? finish_process(); } else { Debug.Log("nodeId error"); Destroy(iCable.gameObject); finish_process(); } } else { Debug.Log("isCableInstantiated is false"); Destroy(iCable.gameObject); finish_process(); } } } } }