diff --git a/J3D_BCK_Editor/File_Edit/Plot.cs b/J3D_BCK_Editor/File_Edit/Plot.cs index 8c8081c..de0b0d8 100644 --- a/J3D_BCK_Editor/File_Edit/Plot.cs +++ b/J3D_BCK_Editor/File_Edit/Plot.cs @@ -8,6 +8,7 @@ using System.Drawing.Drawing2D; using System.Windows.Forms.DataVisualization.Charting; using System.Globalization; + using EN = System.Environment; @@ -15,7 +16,7 @@ namespace J3D_BCK_Editor.File_Edit { class Plot : BCK_State { - public void Draw(PictureBox pictureBox1) + public void Draw(PictureBox pictureBox1 , float scale = 1) { //宣言 int pl_sfn, pl_cfn, pl_tan; @@ -23,6 +24,8 @@ public void Draw(PictureBox pictureBox1) float dgv3_va, dgv3_ta, dgv3_ta2, lineF; PointF p_line, p_line2,p0,p1,p2; + float plot_scale = scale; + if (0 >= scale) plot_scale = 1; //描画先とするImageオブジェクトを作成する Bitmap canvas = new Bitmap(pictureBox1.ClientRectangle.Width, pictureBox1.ClientRectangle.Height); @@ -118,11 +121,18 @@ public void Draw(PictureBox pictureBox1) p0 = new PointF(dgv3_fn - Math.Abs(dgv3_fn0-dgv3_fn)/3, dgv3_va - ((dgv3_ta/92)*((dgv3_fn - Math.Abs(dgv3_fn0 - dgv3_fn) / 3)) ) / 3); //p0 = new PointF(dgv3_fn - Math.Abs(dgv3_fn2 - dgv3_fn) / 3, dgv3_fn - Math.Abs(dgv3_fn2 - dgv3_fn) / 3 * (dgv3_ta/92)/3 ); p1 = new PointF(dgv3_fn, dgv3_va); - + + p0.X *= plot_scale; + p0.Y *= 0.8f; + p1.X *= plot_scale; + p1.Y *= 0.8f; + //タンジェントモードなし if ((3 + pl_tan) == 3) { //タンジェントモード「なし」のポイント設定&初期化 p2 = new PointF(dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn)/3, dgv3_va + ((dgv3_ta / 92)*((dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3)) ) / 3); + p2.X *= plot_scale; + p2.Y *= 0.8f; //p2 = new PointF(dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3, dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3 * (dgv3_ta/92)/3 ); //先頭と末尾だけポイント数を減らす @@ -149,9 +159,15 @@ public void Draw(PictureBox pictureBox1) //タンジェントモードあり else if ((3 + pl_tan)==4) { + dgv3_ta2 = 0; //タンジェントモード「あり」のポイント設定&初期化 - dgv3_ta2 = float.Parse(string.Format("{0:0.##########}", dgv3.Rows[i + 3].Cells["Rotation_Value"].Value, CultureInfo.InvariantCulture.NumberFormat)); - p2 = new PointF(dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3, dgv3_va + ((dgv3_ta2 / 92)*(dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3)) / 3); + if (dgv3.RowCount < i + (3 + pl_tan)) + { + dgv3_ta2 = float.Parse(string.Format("{0:0.##########}", dgv3.Rows[i + (3 + pl_tan) + 3].Cells["Rotation_Value"].Value, CultureInfo.InvariantCulture.NumberFormat)) / frac; + } + p2 = new PointF(dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3, dgv3_va + ((dgv3_ta2 / 92)*(dgv3_fn + Math.Abs(dgv3_fn2 - dgv3_fn) / 3)) / 3); + p2.X *= plot_scale; + p2.Y *= 0.8f; //p2 = new PointF(dgv3_fn, (dgv3_ta2 / 92) *3); //先頭と末尾だけポイント数を減らす @@ -194,15 +210,22 @@ public void Draw(PictureBox pictureBox1) - Bitmap canvas2 = new Bitmap(Frame_Num+20,360+20) ; + Bitmap canvas2 = new Bitmap(Convert.ToInt32((Frame_Num+20) *plot_scale),Convert.ToInt32 ((360+20)*0.8f)) ; Graphics g2 = Graphics.FromImage(canvas2); g2.Clear(Color.Transparent); //描画 + g2.TranslateTransform(0, canvas2.Height / 2); - g2.DrawLine(penG, new PointF(0, -180), new PointF(0,180)); - g2.DrawLine(penR, new PointF(0, 0), new PointF(Int32.Parse(Txt_Total_Frame.Text), 0)); - g2.DrawBeziers(penB, point2); + //g2.ScaleTransform(5F, 5F); + g2.DrawLine(penG, new PointF(0, -180*0.8f ), new PointF(0,180 * 0.8f)); + g2.DrawLine(penR, new PointF(0, 0), new PointF(Int32.Parse(Txt_Total_Frame.Text) * plot_scale, 0)); + g2.DrawLine(penR, new PointF(0, -90 * 0.8f), new PointF(5, -90 * 0.8f)); + g2.DrawLine(penR, new PointF(0, 90 * 0.8f), new PointF(5, 90 * 0.8f)); + g2.DrawBeziers(penB, point2); + + //g2.InterpolationMode = InterpolationMode.HighQualityBicubic; + //g2.DrawImage(canvas2, 0, 0, canvas2.Width * plot_scale, canvas2.Height * plot_scale); //ピクチャボックスに表示 pictureBox1.Image = canvas2; pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); diff --git a/J3D_BCK_Editor/Form1.Designer.cs b/J3D_BCK_Editor/Form1.Designer.cs index d21ce8f..85ecaa6 100644 --- a/J3D_BCK_Editor/Form1.Designer.cs +++ b/J3D_BCK_Editor/Form1.Designer.cs @@ -80,6 +80,9 @@ private void InitializeComponent() this.デバッグ = new System.Windows.Forms.TextBox(); this.panel1 = new System.Windows.Forms.Panel(); this.tabPage6 = new System.Windows.Forms.TabPage(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -502,6 +505,9 @@ private void InitializeComponent() // // tabPage5 // + this.tabPage5.Controls.Add(this.button2); + this.tabPage5.Controls.Add(this.label5); + this.tabPage5.Controls.Add(this.textBox1); this.tabPage5.Controls.Add(this.panel1); this.tabPage5.Controls.Add(this.comboBox1); this.tabPage5.Controls.Add(this.button1); @@ -517,7 +523,7 @@ private void InitializeComponent() // this.comboBox1.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); this.comboBox1.FormattingEnabled = true; - this.comboBox1.Location = new System.Drawing.Point(373, 331); + this.comboBox1.Location = new System.Drawing.Point(361, 345); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(196, 35); this.comboBox1.TabIndex = 5; @@ -526,7 +532,7 @@ private void InitializeComponent() // // button1 // - this.button1.Location = new System.Drawing.Point(575, 331); + this.button1.Location = new System.Drawing.Point(572, 345); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(139, 35); this.button1.TabIndex = 2; @@ -576,6 +582,35 @@ private void InitializeComponent() this.tabPage6.Text = "デバッグ"; this.tabPage6.UseVisualStyleBackColor = true; // + // textBox1 + // + this.textBox1.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.textBox1.Location = new System.Drawing.Point(8, 346); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(100, 34); + this.textBox1.TabIndex = 7; + this.textBox1.Text = "1"; + this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 331); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(87, 12); + this.label5.TabIndex = 8; + this.label5.Text = "拡大倍率(Float)"; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(114, 345); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(136, 35); + this.button2.TabIndex = 9; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -605,6 +640,7 @@ private void InitializeComponent() this.tabPage4.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).EndInit(); this.tabPage5.ResumeLayout(false); + this.tabPage5.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); @@ -668,6 +704,9 @@ private void InitializeComponent() public System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.TabPage tabPage6; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox textBox1; } } diff --git a/J3D_BCK_Editor/Form1.cs b/J3D_BCK_Editor/Form1.cs index 2da7b4e..bc5d26c 100644 --- a/J3D_BCK_Editor/Form1.cs +++ b/J3D_BCK_Editor/Form1.cs @@ -161,9 +161,28 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) } Plot pt = new Plot(); pt.Draw(pictureBox1); - pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; - - + //pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; + + + } + + private void button2_Click(object sender, EventArgs e) + { + if ((dataGridView1.Rows.Count == 0) || (dataGridView2.Rows.Count == 0) || (dataGridView3.Rows.Count == 0) || (dataGridView4.Rows.Count == 0)) + { + return; + } + Plot pt = new Plot(); + pt.Draw(pictureBox1,float.Parse( textBox1.Text)); + } + + private void textBox1_KeyPress(object sender, KeyPressEventArgs e) + { + //0~9と、バックスペース以外の時は、イベントをキャンセルする + if ((e.KeyChar < '0' || '9' < e.KeyChar) && e.KeyChar != '\b' && e.KeyChar != '.') + { + e.Handled = true; + } } } }