Ejemplo n.º 1
0
        public override void Draw(CustomGraphics g)
        {
            base.Draw(g);
            int w = (int)g.GetTextSize("+").Width;

            g.DrawLeftText("+", mPlusPoint.X - w / 2, mPlusPoint.Y);
        }
Ejemplo n.º 2
0
 protected void drawValue(double value)
 {
     if (ControlPanel.ChkShowValues.Checked)
     {
         var s = Utils.UnitText(value);
         if (mNameV)
         {
             Context.DrawCenteredVText(s, mValuePos.X, mValuePos.Y);
         }
         else
         {
             Context.DrawLeftText(s, mValuePos.X, mValuePos.Y);
         }
     }
 }
Ejemplo n.º 3
0
        public override void Draw(CustomGraphics g)
        {
            var bkColor = CustomGraphics.TextColor;
            var bkSize  = CustomGraphics.TextSize;

            CustomGraphics.TextColor = NeedsHighlight ? CustomGraphics.SelectColor : CustomGraphics.GrayColor;
            CustomGraphics.TextSize  = mSize;
            var size = g.GetTextSize(mText);

            P2.X = (int)(P1.X + size.Width);
            P2.Y = (int)(P1.Y + size.Height);
            g.DrawLeftText(mText, P1.X, (int)(P1.Y + size.Height / 2));
            setBbox(P1, P2);
            CustomGraphics.TextColor = bkColor;
            CustomGraphics.TextSize  = bkSize;
        }
Ejemplo n.º 4
0
        public override void Draw(CustomGraphics g)
        {
            setBbox(mPoint1, mPoint2, 16);

            /* draw collector */
            drawLead(mColl[0], mColl[1]);
            /* draw emitter */
            drawLead(mEmit[0], mEmit[1]);
            /* draw arrow */
            g.FillPolygon(NeedsHighlight ? CustomGraphics.SelectColor : CustomGraphics.GrayColor, mArrowPoly);
            /* draw base */
            drawLead(mPoint1, mTbase);

            /* draw dots */
            mCurCount_b = updateDotCount(-mIb, mCurCount_b);
            drawDots(mTbase, mPoint1, mCurCount_b);
            mCurCount_c = updateDotCount(-mIc, mCurCount_c);
            drawDots(mColl[1], mColl[0], mCurCount_c);
            mCurCount_e = updateDotCount(-mIe, mCurCount_e);
            drawDots(mEmit[1], mEmit[0], mCurCount_e);

            /* draw base rectangle */
            g.FillPolygon(NeedsHighlight ? CustomGraphics.SelectColor : CustomGraphics.GrayColor, mRectPoly);

            drawPosts();

            if (ControlPanel.ChkShowName.Checked)
            {
                if (mNameV)
                {
                    g.DrawCenteredVText(ReferenceName, mNamePos.X, mNamePos.Y);
                }
                else
                {
                    g.DrawLeftText(ReferenceName, mNamePos.X, mNamePos.Y);
                }
            }
        }
Ejemplo n.º 5
0
        public override void Draw(CustomGraphics g)
        {
            drawLead(mPtEnds[0], mPtCoil[0]);
            drawLead(mPtEnds[1], mPtCoil[1]);
            drawLead(mPtEnds[2], mPtCoil[2]);
            drawLead(mPtEnds[3], mPtCoil[3]);

            drawCoil(mPtCoil[0], mPtCoil[2], Volts[PRI_T], Volts[PRI_B], 90 * mDsign);
            drawCoil(mPtCoil[1], mPtCoil[3], Volts[SEC_T], Volts[SEC_B], -90 * mDsign * mPolarity);

            g.LineColor = NeedsHighlight ? CustomGraphics.SelectColor : CustomGraphics.GrayColor;
            g.DrawLine(mPtCore[0], mPtCore[2]);
            g.DrawLine(mPtCore[1], mPtCore[3]);
            if (mDots != null)
            {
                g.DrawCircle(mDots[0], 2.5f);
                g.DrawCircle(mDots[1], 2.5f);
            }

            mCurCounts[0] = updateDotCount(mCurrents[0], mCurCounts[0]);
            mCurCounts[1] = updateDotCount(mCurrents[1], mCurCounts[1]);
            for (int i = 0; i != 2; i++)
            {
                drawDots(mPtEnds[i], mPtCoil[i], mCurCounts[i]);
                drawDots(mPtCoil[i], mPtCoil[i + 2], mCurCounts[i]);
                drawDots(mPtEnds[i + 2], mPtCoil[i + 2], -mCurCounts[i]);
            }

            drawPosts();
            setBbox(mPtEnds[0], mPtEnds[mPolarity == 1 ? 3 : 1], 0);

            if (ControlPanel.ChkShowName.Checked)
            {
                g.DrawLeftText(ReferenceName, mNamePos.X, mNamePos.Y);
            }
        }
Ejemplo n.º 6
0
        public override void Draw(CustomGraphics g)
        {
            double vl = Volts[V_L];
            double vr = Volts[V_R];
            double vs = Volts[V_S];

            setBbox(mPoint1, mPoint2, HS);
            draw2Leads();

            int divide = (int)(SEGMENTS * mPosition);

            if (ControlPanel.ChkUseAnsiSymbols.Checked)
            {
                /* draw zigzag */
                for (int i = 0; i != SEGMENTS; i++)
                {
                    double v = vl + (vs - vl) * i / divide;
                    if (i >= divide)
                    {
                        v = vs + (vr - vs) * (i - divide) / (SEGMENTS - divide);
                    }
                    drawLead(mPs1[i], mPs2[i]);
                }
            }
            else
            {
                /* draw rectangle */
                drawLead(mRect1[0], mRect2[0]);
                for (int i = 0, j = 1; i != SEGMENTS; i++, j++)
                {
                    double v = vl + (vs - vl) * i / divide;
                    if (i >= divide)
                    {
                        v = vs + (vr - vs) * (i - divide) / (SEGMENTS - divide);
                    }
                    drawLead(mRect1[j], mRect3[j]);
                    drawLead(mRect2[j], mRect4[j]);
                }
                drawLead(mRect1[SEGMENTS + 1], mRect2[SEGMENTS + 1]);
            }

            /* draw slider */
            drawLead(mPost3, mCorner2);
            drawLead(mCorner2, mArrowPoint);
            drawLead(mArrow1, mArrowPoint);
            drawLead(mArrow2, mArrowPoint);

            /* draw dot */
            mCurCount1 = updateDotCount(mCurrent1, mCurCount1);
            mCurCount2 = updateDotCount(mCurrent2, mCurCount2);
            mCurCount3 = updateDotCount(mCurrent3, mCurCount3);
            if (CirSim.Sim.DragElm != this)
            {
                drawDots(mPoint1, mMidPoint, mCurCount1);
                drawDots(mPoint2, mMidPoint, mCurCount2);
                drawDots(mPost3, mCorner2, mCurCount3);
                drawDots(mCorner2, mMidPoint, mCurCount3 + Utils.Distance(mPost3, mCorner2));
            }
            drawPosts();

            if (ControlPanel.ChkShowValues.Checked && mResistance1 > 0 && (mFlags & FLAG_SHOW_VALUES) != 0)
            {
                /* check for vertical pot with 3rd terminal on left */
                bool reverseY = (mPost3.X < mLead1.X && mLead1.X == mLead2.X);
                /* check for horizontal pot with 3rd terminal on top */
                bool reverseX = (mPost3.Y < mLead1.Y && mLead1.X != mLead2.X);
                /* check if we need to swap texts (if leads are reversed, e.g. drawn right to left) */
                bool rev = (mLead1.X == mLead2.X && mLead1.Y < mLead2.Y) || (mLead1.Y == mLead2.Y && mLead1.X > mLead2.X);

                /* draw units */
                string s1         = Utils.UnitText(rev ? mResistance2 : mResistance1, "");
                string s2         = Utils.UnitText(rev ? mResistance1 : mResistance2, "");
                int    txtHeightH = CustomGraphics.FontText.Height / 2;
                int    txtWidth1  = (int)g.GetTextSize(s1).Width;
                int    txtWidth2  = (int)g.GetTextSize(s2).Width;

                /* vertical? */
                if (mLead1.X == mLead2.X)
                {
                    g.DrawLeftTopText(s1, !reverseY ? mArrowPoint.X : mArrowPoint.X - txtWidth1, Math.Min(mArrow1.Y, mArrow2.Y) + 4 * txtHeightH);
                    g.DrawLeftTopText(s2, !reverseY ? mArrowPoint.X : mArrowPoint.X - txtWidth2, Math.Max(mArrow1.Y, mArrow2.Y) - txtHeightH);
                }
                else
                {
                    g.DrawLeftTopText(s1, Math.Min(mArrow1.X, mArrow2.X) - txtWidth1, !reverseX ? (mArrowPoint.Y + txtHeightH + 10) : mArrowPoint.Y);
                    g.DrawLeftTopText(s2, Math.Max(mArrow1.X, mArrow2.X), !reverseX ? (mArrowPoint.Y + txtHeightH + 10) : mArrowPoint.Y);
                }
            }
            if (ControlPanel.ChkShowName.Checked)
            {
                if (mNameV)
                {
                    g.DrawCenteredVText(ReferenceName, mNamePos.X, mNamePos.Y);
                }
                else
                {
                    g.DrawLeftText(ReferenceName, mNamePos.X, mNamePos.Y);
                }
            }
        }
Ejemplo n.º 7
0
        public override void Draw(CustomGraphics g)
        {
            /* pick up global flags changes */
            if ((mFlags & FLAGS_GLOBAL) != mGlobalFlags)
            {
                SetPoints();
            }

            setBbox(mPoint1, mPoint2, HS);

            /* draw source/drain terminals */
            drawLead(mSrc[0], mSrc[1]);
            drawLead(mDrn[0], mDrn[1]);

            /* draw line connecting source and drain */
            bool enhancement = mVt > 0 && ShowBulk;

            for (int i = 0; i != SEGMENTS; i++)
            {
                if ((i == 1 || i == 4) && enhancement)
                {
                    continue;
                }
                double v = Volts[V_S] + (Volts[V_D] - Volts[V_S]) * i / SEGMENTS;
                drawLead(mPs1[i], mPs2[i]);
            }

            /* draw little extensions of that line */
            drawLead(mSrc[1], mSrc[2]);
            drawLead(mDrn[1], mDrn[2]);

            /* draw bulk connection */
            if (ShowBulk)
            {
                drawLead(mPnp == -1 ? mDrn[0] : mSrc[0], mBody[0]);
                drawLead(mBody[0], mBody[1]);
            }

            /* draw arrow */
            if (!DrawDigital)
            {
                g.FillPolygon(NeedsHighlight ? CustomGraphics.SelectColor : CustomGraphics.GrayColor, mArrowPoly);
            }

            /* draw gate */
            drawLead(mPoint1, mGate[1]);
            drawLead(mGate[0], mGate[2]);
            if (DrawDigital && mPnp == -1)
            {
                g.DrawCircle(mPcircle, mPcircler);
            }

            if ((mFlags & FLAG_SHOWVT) != 0)
            {
                string s = "" + (mVt * mPnp);
                drawCenteredLText(s, P2, false);
            }
            mCurCount = updateDotCount(-mIds, mCurCount);
            drawDots(mSrc[0], mSrc[1], mCurCount);
            drawDots(mDrn[1], mDrn[0], mCurCount);
            drawDots(mSrc[1], mDrn[1], mCurCount);

            if (ShowBulk)
            {
                mCurcountBody1 = updateDotCount(mDiodeCurrent1, mCurcountBody1);
                mCurcountBody2 = updateDotCount(mDiodeCurrent2, mCurcountBody2);
                drawDots(mSrc[0], mBody[0], -mCurcountBody1);
                drawDots(mBody[0], mDrn[0], mCurcountBody2);
            }

            drawPosts();

            if (ControlPanel.ChkShowName.Checked)
            {
                if (mNameV)
                {
                    g.DrawCenteredVText(ReferenceName, mNamePos.X, mNamePos.Y);
                }
                else
                {
                    g.DrawLeftText(ReferenceName, mNamePos.X, mNamePos.Y);
                }
            }
        }