Jump to content

AC Phasor Diagram


xod
 Share

Recommended Posts

I'm working on a plugin for personal use. It's based on toe_head2001's code (Spoked wheel).
 
I want to add text above phasors: red = V1, orange = V2, blue = V3 but I don't know how to do that.
 
I used a few options, but the text intersecting vectors at an agle of rotation.
 
Maybe someone helps me.
 

Spoiler

// Name: AC Phasor Diagram
// Submenu: Render
// Author:
// Title:
// Version: 1.0
// Desc:
// Keywords:
// URL:
// Help:


#region UICode
DoubleSliderControl Amount1 = 0.8; // [0.1,0.8] Voltage circle diameter
DoubleSliderControl Amount2 = 0.7; // [0.1,0.8] Current circle diameter
IntSliderControl Amount3 = 3; // [1,10] Circle thickness
IntSliderControl Amount4 = 3; // [1,10] Voltage phasor thickness
IntSliderControl Amount5 = 3; // [1,10] Current phasor thickness
IntSliderControl Amount6 = 0; // [-360,360] Rotating voltage phasor
IntSliderControl Amount7 = -5; // [-360,360] Rotating current phasor
CheckboxControl Amount8 = false; // [0,1] Change the sequence
#endregion


void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    
    float centerX = ((selection.Right - selection.Left) / 2f) + selection.Left;
    float centerY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    float diameterU = (float)Amount1 * Math.Min(selection.Width - 4, selection.Height - 4);
    float diameterI = (float)Amount2 * Math.Min(selection.Width - 4, selection.Height - 4);
    float radiusU = diameterU / 2f;
    float offsetXU = centerX - radiusU;
    float offsetYU = centerY - radiusU;
    float radiusI = diameterI / 2f;
    float offsetXI = centerX - radiusI;
    float offsetYI = centerY - radiusI;
    float startU = (float)(Amount6)-90; // 0 grade = 90 - 90 Ufazor 'R'
    float startI = (float)(Amount7)-90; // 0 grade = 90 - 90 Ifazor 'R'
    float sweep = 360f / 3; // 120 de grade
    bool sequence = Amount8;


    dst.CopySurface(src, rect.Location, rect);


    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics cerc = ra.Graphics;
        cerc.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        cerc.Clip = new Region(rect);


        using (Pen cercPen = new Pen(ColorBgra.Black))
        {


// Desenează Cerc Fazori Curenti
            cercPen.Color = ColorBgra.AntiqueWhite; // Culoare cerc curenti
            cercPen.Width = Amount3; // Grosime Cerc
            cercPen.DashStyle = DashStyle.Solid; // Linie Cerc
            cerc.DrawEllipse(cercPen, offsetXI, offsetYI, diameterI, diameterI);
           
 // ******* // Fazor curent 'S'
            cercPen.Width = Amount5; // Grosime Fazori Curenti
            cercPen.DashStyle = DashStyle.Dash; // Linie fazor curent
            cercPen.Color = (ColorBgra.Orange); // Culoare Fazor 'S'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            } 
 // ******* // Fazor curent 'T'
            cercPen.DashStyle = DashStyle.Dash; // Linie fazor curent
            cercPen.Color = (ColorBgra.Blue); // Culoare Fazor 'T'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep * 2;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            }
 // ******* // Fazor curent 'R'           
           cercPen.DashStyle = DashStyle.Dash; // Linie fazor curent
           cercPen.Color = (ColorBgra.Red); // Culoare Fazor 'R'
            {
                 if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep * 3;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);   
            }        
 // Desenează Cerc Fazori Tensiuni
            cercPen.Color = ColorBgra.LightGray; // Culoare cerc tensiuni
            cercPen.Width = Amount3; // Grosime Cerc
            cercPen.DashStyle = DashStyle.Solid; // Linie Cerc
            cerc.DrawEllipse(cercPen, offsetXU, offsetYU, diameterU, diameterU);
            
 // Desenează Fazori
 // ******* // Fazor tensiune 'S'
            cercPen.Width = Amount4; // Grosime Fazori Tensiune
            cercPen.DashStyle = DashStyle.Solid; // Linie fazor tensiune
            cercPen.Color = (ColorBgra.Orange); // Culoare Fazor 'S'
            {
                if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
           
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            }
 // ******* // Fazor tensiune 'T'
            cercPen.DashStyle = DashStyle.Solid; // Linie fazor tensiune
            cercPen.Color = (ColorBgra.Blue); // Culoare Fazor 'T'
            {
                if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep * 2;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
                }


 // ******* // Fazor tensiune 'R'
            cercPen.DashStyle = DashStyle.Solid; // Linie fazor tensiune
            cercPen.Color = (ColorBgra.Red); // Culoare Fazor 'R'
            {
                 if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep * 3;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
                }
            }  
         }
     } 

 

Edited by xod
Link to comment
Share on other sites

Here you go. The new code I added is at the bottom of the script.

 

Spoiler

 


// Name: AC Phasor Diagram
// Submenu: Render
// Author:
// Title:
// Version: 1.0
// Desc:
// Keywords:
// URL:
// Help:

#region UICode
DoubleSliderControl Amount1 = 0.8; // [0.1,0.8] Voltage circle diameter
DoubleSliderControl Amount2 = 0.7; // [0.1,0.8] Current circle diameter
IntSliderControl Amount3 = 3; // [1,10] Circle thickness
IntSliderControl Amount4 = 3; // [1,10] Voltage phasor thickness
IntSliderControl Amount5 = 3; // [1,10] Current phasor thickness
IntSliderControl Amount6 = -30; // [-360,360] Rotating voltage phasor
IntSliderControl Amount7 = -5; // [-360,360] Rotating current phasor
CheckboxControl Amount8 = false; // [0,1] Change the sequence
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   
    float centerX = ((selection.Right - selection.Left) / 2f) + selection.Left;
    float centerY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    float diameterU = (float)Amount1 * Math.Min(selection.Width - 4, selection.Height - 4);
    float diameterI = (float)Amount2 * Math.Min(selection.Width - 4, selection.Height - 4);
    float radiusU = diameterU / 2f;
    float offsetXU = centerX - radiusU;
    float offsetYU = centerY - radiusU;
    float radiusI = diameterI / 2f;
    float offsetXI = centerX - radiusI;
    float offsetYI = centerY - radiusI;
    float startU = (float)(Amount6)-90; // 0 grade = 90 - 90 Ufazor 'R'
    float startI = (float)(Amount7)-90; // 0 grade = 90 - 90 Ifazor 'R'
    float sweep = 360f / 3; // 120 de grade
    bool sequence = Amount8;

    dst.CopySurface(src, rect.Location, rect);

    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics cerc = ra.Graphics;
        cerc.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        cerc.Clip = new Region(rect);

        using (Pen cercPen = new Pen(ColorBgra.Black))
        {

// Desenează Cerc Fazori Curenti
            cercPen.Color = ColorBgra.AntiqueWhite; // Culoare cerc curenti
            cercPen.Width = Amount3; // Grosime Cerc
            cercPen.DashStyle = DashStyle.Solid; // Linie Cerc
            cerc.DrawEllipse(cercPen, offsetXI, offsetYI, diameterI, diameterI);
          
// ******* // Fazor curent 'S'
            cercPen.Width = Amount5; // Grosime Fazori Curenti
            cercPen.DashStyle = DashStyle.Dash; // Linie fazor curent
            cercPen.Color = (ColorBgra.Orange); // Culoare Fazor 'S'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            }
// ******* // Fazor curent 'T'
            cercPen.DashStyle = DashStyle.Dash; // Linie fazor curent
            cercPen.Color = (ColorBgra.Blue); // Culoare Fazor 'T'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep * 2;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            }
// ******* // Fazor curent 'R'          
           cercPen.DashStyle = DashStyle.Dash; // Linie fazor curent
           cercPen.Color = (ColorBgra.Red); // Culoare Fazor 'R'
            {
                 if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep * 3;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);  
            }       
// Desenează Cerc Fazori Tensiuni
            cercPen.Color = ColorBgra.LightGray; // Culoare cerc tensiuni
            cercPen.Width = Amount3; // Grosime Cerc
            cercPen.DashStyle = DashStyle.Solid; // Linie Cerc
            cerc.DrawEllipse(cercPen, offsetXU, offsetYU, diameterU, diameterU);
           
// Desenează Fazori
// ******* // Fazor tensiune 'S'
            cercPen.Width = Amount4; // Grosime Fazori Tensiune
            cercPen.DashStyle = DashStyle.Solid; // Linie fazor tensiune
            cercPen.Color = (ColorBgra.Orange); // Culoare Fazor 'S'
            {
                if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
          
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            }
// ******* // Fazor tensiune 'T'
            cercPen.DashStyle = DashStyle.Solid; // Linie fazor tensiune
            cercPen.Color = (ColorBgra.Blue); // Culoare Fazor 'T'
            {
                if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep * 2;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
                }

// ******* // Fazor tensiune 'R'
            cercPen.DashStyle = DashStyle.Solid; // Linie fazor tensiune
            cercPen.Color = (ColorBgra.Red); // Culoare Fazor 'R'
            {
                 if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep * 3;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
                }
        }
       
        StringFormat format = new StringFormat();
        format.Alignment = StringAlignment.Center;
        format.LineAlignment = StringAlignment.Center;
        using (SolidBrush textBrush = new SolidBrush(Color.Black))
        using (Font textFont = new Font("Arial", 16, FontStyle.Bold))
        {
            for (int fazor = 1; fazor < 4; fazor++)
            {
                float angle = startU + sweep * fazor;
                double radian = Math.PI / 180 * angle;
                float endX = (float)((radiusU + 20) * Math.Sin(radian));
                float helperAngle = 90 - angle;
                double helperRadian = Math.PI / 180 * helperAngle;
                float endY = (float)((radiusU + 20) * Math.Sin(helperRadian));
               
                switch (fazor)
                {
                    case 1:
                        textBrush.Color = Color.Blue;
                        break;
                    case 2:
                        textBrush.Color = Color.Orange;
                        break;
                    case 3:
                        textBrush.Color = Color.Red;
                        break;
                }
                cerc.DrawString(fazor.ToString() + "V", textFont, textBrush, centerX - endX, centerY - endY, format);
            }
        }
     }
}

 

  • Upvote 2
Link to comment
Share on other sites

toe_head2001, God bless you!
This is exactly what I wanted.

 

I will try to understand the code because I want to do the same for the currents: I1, I2, I3.
 
THANK YOU!

 

Edited by xod
  • Upvote 1
Link to comment
Share on other sites

I don't think this plugin will interest someone.
 
Perhaps only those who have the same job as mine.
 
For me it is quite useful and I thank once again to toe_head2001 that helped me a lot.
 
 
 
Spoiler

V7qot56.png

 

 
Spoiler

// Name: AC Phasor Diagram
// Submenu: Render
// Author:
// Title:
// Version: 1.0
// Desc:
// Keywords:
// URL:
// Help:

#region UICode
DoubleSliderControl Amount1 = 0.75; // [0.1,0.8] Voltage circle diameter
DoubleSliderControl Amount2 = 0.6; // [0.1,0.8] Current circle diameter
IntSliderControl Amount3 = 2; // [1,10] Circle thickness
IntSliderControl Amount4 = 3; // [1,10] Voltage phasor thickness
IntSliderControl Amount5 = 3; // [1,10] Current phasor thickness
IntSliderControl Amount6 = 0; // [-360,360] Rotating voltage phasor
IntSliderControl Amount7 = -5; // [-360,360] Rotating current phasor
CheckboxControl Amount8 = false; // [0,1] Change the sequence
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   
    float centerX = ((selection.Right - selection.Left) / 2f) + selection.Left;
    float centerY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    float diameterU = (float)Amount1 * Math.Min(selection.Width - 4, selection.Height - 4);
    float diameterI = (float)Amount2 * Math.Min(selection.Width - 4, selection.Height - 4);
    float radiusU = diameterU / 2f;
    float offsetXU = centerX - radiusU;
    float offsetYU = centerY - radiusU;
    float radiusI = diameterI / 2f;
    float offsetXI = centerX - radiusI;
    float offsetYI = centerY - radiusI;
    float startU = (float)(Amount6)-90; // 0 grade = 90 - 90 Ufazor 'R'
    float startI = (float)(Amount7)-90; // 0 grade = 90 - 90 Ifazor 'R'
    float sweep = 360f / 3; // 120 de grade
    bool sequence = Amount8;
    float dirTxt = centerY - selection.Height/24;

    dst.CopySurface(src, rect.Location, rect);

    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics cerc = ra.Graphics;
        cerc.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        cerc.Clip = new Region(rect);

        StringFormat format = new StringFormat();
        format.Alignment = StringAlignment.Center;
        format.LineAlignment = StringAlignment.Center;

        using (Pen cercPen = new Pen(ColorBgra.Black))
        using (SolidBrush textBrush = new SolidBrush(Color.Black))
        using (Font textFont = new Font("Tahoma", 12, FontStyle.Regular))
        {
// Desenează cerc fazori curenti
            cercPen.Color = ColorBgra.AntiqueWhite; // Culoare cerc fazori curenti
            cercPen.Width = Amount3; // Grosime linie cerc
            cercPen.DashStyle = DashStyle.Solid; // Stil linie cerc
            cerc.DrawEllipse(cercPen, offsetXI, offsetYI, diameterI, diameterI);
            
// Desenează cerc fazori tensiuni + axe
            cercPen.Color = ColorBgra.LightGray; // Culoare cerc tensiuni
            cercPen.Width = Amount3; // Grosime cerc
            cercPen.DashStyle = DashStyle.Solid; // Stil linie cerc
            cerc.DrawEllipse(cercPen, offsetXU, offsetYU, diameterU, diameterU);
            {
            for ( int axes = 1; axes < 5; axes++)
            { 
            float angleU = (axes * 90) - 30 + sweep;    
            double radianU = Math.PI / 180 * angleU;   
            float endX = (float)(radiusU * Math.Sin(radianU));    
            float helperAngleU = 90 - angleU;
            double helperRadianU = Math.PI / 180 * helperAngleU;
            float endY = (float)(radiusU * Math.Sin(helperRadianU));
            cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY);
            }
        }
// Desenează fazori curenti       
// ******* // Fazor curent 'S'
            cercPen.Width = Amount5; // Grosime linie fazor curent
            cercPen.DashStyle = DashStyle.Dash; // Stil linie fazor curent
            cercPen.Color = ColorBgra.Orange; // Culoare fazor 'S'
            textBrush.Color = Color.Orange; // Culoare text 'I2'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float endXtxt = (float)((radiusI + 20) * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                float endYtxt = (float)((radiusI + 20) * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY); //desenează fazor
                cerc.DrawString( "I" + 2.ToString(), textFont, textBrush, centerX - endXtxt, centerY - endYtxt, format);
                if (sequence)
                {
                textBrush.Color = Color.Black; // Culoare text    
                cerc.DrawString( "→  DIRECTION OF ROTATION →", textFont, textBrush, centerX, centerY - dirTxt, format);
                }
                if (!sequence)
                {
                textBrush.Color = Color.Black; // Culoare text    
                cerc.DrawString( "→  DIRECTION OF ROTATION →", textFont, textBrush, centerX, centerY + dirTxt, format);
                }
            }
// ******* // Fazor curent 'T'
            cercPen.Width = Amount5; // Grosime linie fazor curent
            cercPen.DashStyle = DashStyle.Dash; // Stil linie fazor curent
            cercPen.Color = ColorBgra.Blue; // Culoare fazor 'T'
            textBrush.Color = Color.Blue; // Culoare text 'I3'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep * 2;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float endXtxt = (float)((radiusI + 20) * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                float endYtxt = (float)((radiusI + 20) * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY); //desenează fazor
                cerc.DrawString( "I" + 3.ToString(), textFont, textBrush, centerX - endXtxt, centerY - endYtxt, format);
            }
// ******* // Fazor curent 'R'          
            cercPen.Width = Amount5; // Grosime linie fazor curent
            cercPen.DashStyle = DashStyle.Dash; // Stil linie fazor curent
            cercPen.Color = ColorBgra.Red; // Culoare fazor 'R'
            textBrush.Color = Color.Red; // Culoare text 'I1'
            {
                if (!sequence)
                {
                startI = startI + 120;
                }
                float angleI = startI + sweep * 3;
                double radianI = Math.PI / 180 * angleI;
                float endX = (float)(radiusI * Math.Sin(radianI));
                float endXtxt = (float)((radiusI + 20) * Math.Sin(radianI));
                float helperAngleI = 90 - angleI;
                double helperRadianI = Math.PI / 180 * helperAngleI;
                float endY = (float)(radiusI * Math.Sin(helperRadianI));
                float endYtxt = (float)((radiusI + 20) * Math.Sin(helperRadianI));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY); //desenează fazor
                cerc.DrawString( "I" + 1.ToString(), textFont, textBrush, centerX - endXtxt, centerY - endYtxt, format);
            }       
//Desenează fazori tensiune
// ******* // Fazor tensiune 'S'
            cercPen.Width = Amount4; // Grosime fazori tensiune
            cercPen.DashStyle = DashStyle.Solid; // Stil linie fazor tensiune
            cercPen.Color = ColorBgra.Orange; // Culoare fazor 'S'
            textBrush.Color = Color.Orange; // Culoare text 'V2'
            {
                if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float endXtxt = (float)((radiusU + 20) * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                float endYtxt = (float)((radiusU + 20) * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY); //desenează fazor
                cerc.DrawString( "V" + 2.ToString(), textFont, textBrush, centerX - endXtxt, centerY - endYtxt, format);
            }
// ******* // Fazor tensiune 'T'
            cercPen.Width = Amount4; // Grosime fazor tensiune
            cercPen.DashStyle = DashStyle.Solid; // Stil linie fazor tensiune
            cercPen.Color = ColorBgra.Blue; // Culoare fazor 'T'
            textBrush.Color = Color.Blue; // Culoare text 'V3'
            {
                if (!sequence)
                {
                startU = startU + 120;
                }
                float angleU = startU + sweep * 2;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float endXtxt = (float)((radiusU + 20) * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                float endYtxt = (float)((radiusU + 20) * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY); //desenează fazor
                cerc.DrawString( "V" + 3.ToString(), textFont, textBrush, centerX - endXtxt, centerY - endYtxt, format);
                }

// ******* // Fazor tensiune 'R'
            cercPen.Width = Amount4; // Grosime fazor tensiune
            cercPen.DashStyle = DashStyle.Solid; // Stil linie fazor tensiune
            cercPen.Color = ColorBgra.Red; // Culoare fazor 'R'
            textBrush.Color = Color.Red; // Culoare text 'V1'
            {
                if (!sequence)
              {
                startU = startU + 120;
                }
                float angleU = startU + sweep * 3;
                double radianU = Math.PI / 180 * angleU;
                float endX = (float)(radiusU * Math.Sin(radianU));
                float endXtxt = (float)((radiusU + 20) * Math.Sin(radianU));
                float helperAngleU = 90 - angleU;
                double helperRadianU = Math.PI / 180 * helperAngleU;
                float endY = (float)(radiusU * Math.Sin(helperRadianU));
                float endYtxt = (float)((radiusU + 20) * Math.Sin(helperRadianU));
                cerc.DrawLine(cercPen, centerX, centerY, centerX - endX, centerY - endY); //desenează fazor
                cerc.DrawString( "V" + 1.ToString(), textFont, textBrush, centerX - endXtxt, centerY - endYtxt, format);
                }
              }
           }
}

 

 

 
Edited by xod
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...