Pulser3 Kurulum PDF İndir

Hazır Şekiller

Operatörün belirlenen parametrelerle hazır şekillerden G kod üretmesi için şekiller oluşturulabilir. Yeni bir hazır şekil eklemek için proje ağacındaki Shapes sekmesine sağ tılanarak Add New Shape butonuna basılır. Çıkan diyalog sayfasına şeklin ismi yazılır ve OK butonuna basılır. Oluşturulan şeklin üzerine çift tıklandığında içeriğine ulaşılır. Şekil oluşturmak için yine C# dili kullanılır. Her bir şekil Draw fonksiyonu içermeli ve oluşturulacak şeklin görseli bu fonksiyon içinde tanımlanmalıdır.

public void Draw(string selectedPropertyName)

{

   // Şekil bu fonksiyonun içinde oluşturulur

}

 

            Örnek bir şekil aşağıda oluşturulmuştur:

 

//------------------------------------------------------------------------------------

// BÖLÜM - 1

// Oluşturulacak şeklin yerel değişkenleri

//------------------------------------------------------------------------------------

private float partWidth = 400;

private float partHeight = 400;

 

private float edgeRadius1 = 40;

private float edgeRadius2 = 40;

private float edgeRadius3 = 40;

private float edgeRadius4 = 40;

 

private float xStartSpace = 20;

private float xEndSpace = 20;

private float yStartSpace = 20;

private float yEndSpace = 20;

 

//------------------------------------------------------------------------------------

// BÖLÜM - 2

// Oluşturulacak şeklin özellikleri

// Buraya eklenen özellikler şekil şekil düzenleme formunda otomatik olarak gösterilir

//------------------------------------------------------------------------------------

[Category("Part Dimension"),

DisplayName("A - Part Width"),

DescriptionAttribute("Width of the part")]

public float PartWidth

{

   get

   {

      return partWidth;

   }

   set

   {

      if (value != 0) partWidth = value;

   }

}

 

[Category("Part Dimension"),

DisplayName("B - Part Height"),

DescriptionAttribute("Height of the part")]

public float PartHeight

{

   get

   {

      return partHeight;

   }

   set

   {

      if (value != 0) partHeight = value;

   }

}

[Category("Spaces"),

DisplayName("A - Horizontal Start Space"),

DescriptionAttribute("Horizontal Start Space of shape")]

public float XStartSpace

{

   get

   {

      return xStartSpace;

   }

   set

   {

      if (value > 0) xStartSpace = value;

   }

}

 

[Category("Spaces"),

DisplayName("B - Horizontal End Space"),

DescriptionAttribute("Horizontal End Space of shape")]

public float XEndSpace

{

   get

   {

      return xEndSpace;

   }

   set

   {

      if (value > 0) xEndSpace = value;

   }

}

 

[Category("Spaces"),

DisplayName("C - Vertical Start Space"),

DescriptionAttribute("Vertical Start Space of shape")]

public float YStartSpace

{

   get

   {

      return yStartSpace;

   }

   set

   {

      if (value > 0) yStartSpace = value;

   }

}

 

[Category("Spaces"),

DisplayName("D - Vertical End Space"),

DescriptionAttribute("Vertical End Space of shape")]

public float YEndSpace

{

   get

   {

      return yEndSpace;

   }

   set

   {

      if (value > 0) yEndSpace = value;

   }

}

[Category("Shape Dimension"),

DisplayName("A - Edge Radius 1"),

DescriptionAttribute("Edge radius for first edge")]

public float EdgeRadius1

{

   get

   {

      return edgeRadius1;

   }

   set

   {

      if (value > 0) edgeRadius1 = value;

   }

}

 

[Category("Shape Dimension"),

DisplayName("B - Edge Radius 2"),

DescriptionAttribute("Edge radius for second edge")]

public float EdgeRadius2

{

   get

   {

      return edgeRadius2;

   }

   set

   {

      if (value > 0) edgeRadius2 = value;

   }

}

 

[Category("Shape Dimension"),

DisplayName("C - Edge Radius 3"),

DescriptionAttribute("Edge radius for third edge")]

public float EdgeRadius3

{

   get

   {

      return edgeRadius3;

   }

   set

   {

      if (value > 0) edgeRadius3 = value;

   }

}

 

[Category("Shape Dimension"),

DisplayName("D - Edge Radius 4"),

DescriptionAttribute("Edge radius for fourth edge")]

public float EdgeRadius4

{

   get

   {

      return edgeRadius4;

   }

   set

   {

      if (value > 0) edgeRadius4 = value;

   }

}

//------------------------------------------------------------------------------------

// BÖLÜM - 3

// Şeklin çizdirilmesi

// HSC Studio hazır şekilleri kullanıcıya göstermek istediğinde bu metodu çağırır

//------------------------------------------------------------------------------------

 

/// <summary>

/// Şekil bu metodun içinde çizdirilmelidir

/// <param name="selectedPropertyName">Üzerine tıklanan özellik

/// (Property) ismi</param>

/// </summary>

public void Draw(string selectedPropertyName)

{

 

   // ------ Şekil

   Contour c = new Contour();

   doc.Model.Add(c);

 

   Line line1 = new Line(XStartSpace + EdgeRadius1,

                            YStartSpace,

                            PartWidth - XEndSpace - EdgeRadius2,

                            YStartSpace);

   Arc arc2 = new Arc(PartWidth - XEndSpace - EdgeRadius2,

                            YStartSpace + EdgeRadius2,

                            EdgeRadius2, ToRadian(270.0F),

                            ToRadian(0.0F));

 

   Line line2 = new Line(PartWidth - XEndSpace,

                            YStartSpace + EdgeRadius2,

                            PartWidth - XEndSpace,

                            PartHeight - YEndSpace - EdgeRadius3);

   Arc arc3 = new Arc(PartWidth - XEndSpace - EdgeRadius3,

                            PartHeight - YEndSpace - EdgeRadius3,

                            EdgeRadius3,

                            ToRadian(0.0F),

                            ToRadian(90.0F));

 

   Line line3 = new Line(PartWidth - XEndSpace - EdgeRadius3,

                            PartHeight - YEndSpace,

                            XStartSpace + EdgeRadius4,

                            PartHeight - YEndSpace);

   Arc arc4 = new Arc(XStartSpace + EdgeRadius4,

                            PartHeight - YEndSpace - EdgeRadius4,

                            EdgeRadius4,

                            ToRadian(90.0F),

                            ToRadian(180.0F));

 

   Line line4 = new Line(XStartSpace,

                            PartHeight - YEndSpace - EdgeRadius4,

                            XStartSpace,

                            YStartSpace + EdgeRadius1);

   Arc arc1 = new Arc(XStartSpace + EdgeRadius1,

                            YStartSpace + EdgeRadius1,

                            EdgeRadius1,

                            ToRadian(180.0F),

                            ToRadian(270.0F));

   c.Add(line1);

   c.Add(arc2);

   c.Add(line2);

   c.Add(arc3);

   c.Add(line3);

   c.Add(arc4);

   c.Add(line4);

   c.Add(arc1);

   // ------ Şekil sonu

   // ------ Dış çerçeve

   Contour cBorder = new Contour();

   doc.Model.Add(cBorder);

 

   Line lineBorder1 = new Line(0, 0, PartWidth, 0);

   Line lineBorder2 = new Line(PartWidth, 0, PartWidth, PartHeight);

   Line lineBorder3 = new Line(PartWidth, PartHeight, 0, PartHeight);

   Line lineBorder4 = new Line(0, PartHeight, 0, 0);

   lineBorder1.Label = "Border";

   lineBorder2.Label = "Border";

   lineBorder3.Label = "Border";

   lineBorder4.Label = "Border";

   lineBorder1.Style.Color = new Color(0xFFFF0000, false);

   lineBorder2.Style.Color = new Color(0xFFFF0000, false);

   lineBorder3.Style.Color = new Color(0xFFFF0000, false);

   lineBorder4.Style.Color = new Color(0xFFFF0000, false);

 

   cBorder.Add(lineBorder1);

   cBorder.Add(lineBorder2);

   cBorder.Add(lineBorder3);

   cBorder.Add(lineBorder4);

   // ----- Dış çerçeve sonu

 

   // ----- Kılavuz göstergeleri

   if (selectedPropertyName == "A - Part Width")

   {

      Dimension d = new Dimension(0, -20, PartWidth, -20, 30);

      d.String = "Part Width : <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "B - Part Height")

   {

      Dimension d = new Dimension(-20, 0, -20, PartHeight, 30);

      d.String = "Part Height : <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "A - Horizontal Start Space")

   {

      Dimension d = new Dimension(0, -5, XStartSpace, -5, 30);

      d.String = "X StartSpace: <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "B - Horizontal End Space")

   {

      Dimension d = new Dimension(PartWidth - XEndSpace, -5, PartWidth, -5, 30);

      d.String = "X EndSpace: <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "C - Vertical Start Space")

   {

      Dimension d = new Dimension(-5, 0, -5, YStartSpace, 30);

      d.String = "Y StartSpace: <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "D - Vertical End Space")

   {

      Dimension d = new Dimension(-5, PartHeight - YEndSpace, -5, PartHeight, 30);

      d.String = "Y EndSpace: <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "A - Edge Radius 1")

   {

      Dimension d = new Dimension(XStartSpace, -5,

                                    XStartSpace + EdgeRadius1, -5, 30);

      d.String = "Radius 1 : <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "B - Edge Radius 2")

   {

      Dimension d = new Dimension(PartWidth - XEndSpace - EdgeRadius2,

                                    -5, PartWidth - XEndSpace, -5, 30);

      d.String = "Radius 2 : <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "C - Edge Radius 3")

   {

      Dimension d = new Dimension(PartWidth - XEndSpace - EdgeRadius3,

                                    PartHeight + 5, PartWidth - XEndSpace,

                                    PartHeight + 5, 30);

      d.String = "Radius 3 : <>";

      c.Add(d);

   }

   else if (selectedPropertyName == "D - Edge Radius 4")

   {

      Dimension d = new Dimension(XStartSpace, PartHeight + 5,

                                    XStartSpace + EdgeRadius1,

                                    PartHeight + 5, 30);

      d.String = "Radius 4 : <>";

      c.Add(d);

   }

   // ----- Kılavuz göstergeleri sonu

}

//------------------------------------------------------------------------------------

// BÖLÜM - 4

// Şeklin çizdirilmesi için kullanılan yardımcı metodlar/atamalar

// Zorunlu değildir. Ancak kodun tamamını Draw metodu

// içinde gerçekleştimek karmaşıklığa sebep olabileceğinden

// ayrı ayrı metodlara bölünmüştür

//------------------------------------------------------------------------------------

 

/// <summary>

/// Gönderilen derece değerini radyan'a dönüştürür

/// <param name="deg">Radyan cinsine dönüştürülmek istenen derece değeri</param>

/// </summary>

private float ToRadian(float deg)

{

   return (deg * (float)Math.PI) / 180.0F;

}