Пример #1
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.PaintTo3D (IPaintTo3D)"/>
 /// </summary>
 /// <param name="paintTo3D"></param>
 public override void PaintTo3D(IPaintTo3D paintTo3D)
 {
     if (!paintTo3D.SelectMode)
     {
         if (colorDef != null)
         {
             paintTo3D.SetColor(colorDef.Color);
         }
     }
     if (OnPaintTo3D != null && OnPaintTo3D(this, paintTo3D))
     {
         return;
     }
     if (paintTo3D.SelectMode)
     {
         // paintTo3D.Points(new GeoPoint[] { this.location }, (float)this.size);
         // im Selectmode gibts Abstürze bei "0901_06_01_0.dxf", wenn man eine Bemaßung markiert
         // und die normale Darstellung verwendet
         paintTo3D.Points(new GeoPoint[] { location }, (float)size, this.symbol | PointSymbol.Select);
     }
     else
     {
         paintTo3D.Points(new GeoPoint[] { location }, 1.0f, symbol);
         // folgendes geht viel schneller:
         //paintTo3D.Polyline(new GeoPoint[] { location - size * GeoVector.XAxis, location + size * GeoVector.XAxis });
         //paintTo3D.Polyline(new GeoPoint[] { location - size * GeoVector.YAxis, location + size * GeoVector.YAxis });
         //paintTo3D.Polyline(new GeoPoint[] { location - size * GeoVector.ZAxis, location + size * GeoVector.ZAxis });
     }
 }
Пример #2
0
 void IFeedBack.PaintTo3D(IPaintTo3D paintTo3D)
 {
     paintTo3D.UseZBuffer(true);
     paintTo3D.Blending(true);
     paintTo3D.SetColor(color);
     GeoPoint[] pnts = new GeoPoint[4];
     pnts[0] = pln.ToGlobal(new GeoPoint2D(-width / 2, -height / 2));
     pnts[1] = pln.ToGlobal(new GeoPoint2D(width / 2, -height / 2));
     pnts[2] = pln.ToGlobal(new GeoPoint2D(width / 2, height / 2));
     pnts[3] = pln.ToGlobal(new GeoPoint2D(-width / 2, height / 2));
     GeoVector[] norm = new GeoVector[4];
     norm[0] = pln.Normal;
     norm[1] = pln.Normal;
     norm[2] = pln.Normal;
     norm[3] = pln.Normal;
     int[] ind = new int[6];
     ind[0] = 0;
     ind[1] = 1;
     ind[2] = 2;
     ind[3] = 0;
     ind[4] = 2;
     ind[5] = 3;
     paintTo3D.Triangle(pnts, norm, ind);
     paintTo3D.Blending(false);
     paintTo3D.UseZBuffer(true);
 }
Пример #3
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.PaintTo3D (IPaintTo3D)"/>
 /// </summary>
 /// <param name="paintTo3D"></param>
 public override void PaintTo3D(IPaintTo3D paintTo3D)
 {
     if (OnPaintTo3D != null && OnPaintTo3D(this, paintTo3D))
     {
         return;
     }
     if (!paintTo3D.SelectMode)
     {
         if (colorDef != null)
         {
             paintTo3D.SetColor(colorDef.Color);
         }
     }
     if (lineWidth != null)
     {
         paintTo3D.SetLineWidth(lineWidth);
     }
     if (linePattern != null)
     {
         paintTo3D.SetLinePattern(linePattern);
     }
     else
     {
         paintTo3D.SetLinePattern(null);
     }
     paintTo3D.Polyline(new GeoPoint[] { startPoint, endPoint });
 }
Пример #4
0
 public static void PaintHandle(IPaintTo3D paintTo3D, PointF pf, int width, Color color)
 {
     paintTo3D.SetColor(color);
     paintTo3D.SetLineWidth(null);
     paintTo3D.SetLinePattern(null);
     paintTo3D.Line2D((int)pf.X - width, (int)pf.Y - width, (int)pf.X - width, (int)pf.Y + width);
     paintTo3D.Line2D((int)pf.X - width, (int)pf.Y + width, (int)pf.X + width, (int)pf.Y + width);
     paintTo3D.Line2D((int)pf.X + width, (int)pf.Y + width, (int)pf.X + width, (int)pf.Y - width);
     paintTo3D.Line2D((int)pf.X + width, (int)pf.Y - width, (int)pf.X - width, (int)pf.Y - width);
     //paintTo3D.Point2D((int)pf.X + width, (int)pf.Y + width);
     //paintTo3D.Point2D((int)pf.X + width, (int)pf.Y - width);
     //paintTo3D.Point2D((int)pf.X - width, (int)pf.Y + width);
     //paintTo3D.Point2D((int)pf.X - width, (int)pf.Y - width);
 }
Пример #5
0
        private void RepaintZoomRect(Rectangle IsInvalid, IView View, IPaintTo3D PaintToActive)
        {
            if (View != activeView)
            {
                return;                     // nur ein Fadenkreuz bzw. Rechteck
            }
            Color bckgnd = Frame.GetColorSetting("Colors.Background", Color.AliceBlue);
            Color infocolor;

            if (bckgnd.GetBrightness() > 0.5)
            {
                infocolor = Color.Black;
            }
            else
            {
                infocolor = Color.White;
            }
            Rectangle ClipRect = View.Canvas.ClientRectangle;

            switch (Mode)
            {
            case 0:     // Fadenkreuz zeichnen
                PaintToActive.SetColor(infocolor);
                PaintToActive.Line2D(FirstPoint.X, ClipRect.Top, FirstPoint.X, ClipRect.Bottom);
                PaintToActive.Line2D(ClipRect.Left, FirstPoint.Y, ClipRect.Right, FirstPoint.Y);
                break;

            case 1:     // Rechteck zeichnen
                PaintToActive.SetColor(infocolor);
                PaintToActive.Line2D(FirstPoint.X, FirstPoint.Y, SecondPoint.X, FirstPoint.Y);
                PaintToActive.Line2D(SecondPoint.X, FirstPoint.Y, SecondPoint.X, SecondPoint.Y);
                PaintToActive.Line2D(SecondPoint.X, SecondPoint.Y, FirstPoint.X, SecondPoint.Y);
                PaintToActive.Line2D(FirstPoint.X, SecondPoint.Y, FirstPoint.X, FirstPoint.Y);
                break;
            }
        }
Пример #6
0
 public static void PaintHandle(IPaintTo3D paintTo3D, int x, int y, int width, Color color)
 {
     paintTo3D.SetLineWidth(null); // dünnstmöglich
     paintTo3D.SetLinePattern(null);
     paintTo3D.SetColor(color);
     paintTo3D.Line2D(x - width, y - width, x - width, y + width);
     paintTo3D.Line2D(x - width, y + width, x + width, y + width);
     paintTo3D.Line2D(x + width, y + width, x + width, y - width);
     paintTo3D.Line2D(x + width, y - width, x - width, y - width);
     // ohne die folgenden Aufrufe fehlt meist ein Punkt im Quadrat
     // hängt vom OpenGl Treiber ab: manchmal sind diese Punkte versetzt
     //paintTo3D.Point2D(x - width, y - width);
     //paintTo3D.Point2D(x - width, y + width);
     //paintTo3D.Point2D(x + width, y + width);
     //paintTo3D.Point2D(x + width, y - width);
 }
Пример #7
0
        void OnRepaint(IView View, IPaintTo3D paintTo3D)
        {
            BoundingRect ext;

            if (layoutPatch.Area == null)
            {
                ext = new BoundingRect(0.0, 0.0, layoutView.Layout.PaperWidth, layoutView.Layout.PaperHeight);
            }
            else
            {
                ext = layoutPatch.Area.Extent;
            }
            LayoutView lv = View as LayoutView;

            if (lv != null)
            {
                GeoPoint2D clipll = lv.layoutToScreen * ext.GetLowerLeft();
                GeoPoint2D clipur = lv.layoutToScreen * ext.GetUpperRight();
                paintTo3D.SetColor(Color.LightGray);
                paintTo3D.FillRect2D(clipll.PointF, clipur.PointF);
            }
        }
Пример #8
0
        void IView.OnPaint(PaintEventArgs e)
        {
            IPaintTo3D paintTo3D = canvas.PaintTo3D;
            Rectangle  clr       = e.ClipRectangle;

            if (!IsInitialized)
            {
                ZoomTotal(1.1);
            }

            //PaintToOpenGl paintTo3D = new PaintToOpenGl(1e-3); // woher nehmen?
            // IntPtr dc = e.Graphics.GetHdc();
            //paintTo3D.Init(dc, condorCtrl.ClientRectangle.Width, condorCtrl.ClientRectangle.Height, false);
            IPaintTo3D ipaintTo3D = paintTo3D;

            // ipaintTo3D.Init(condorCtrl); // das erzeugt jedesmal einen neuen renderContext, das kann doch nicht richtig sein
            ipaintTo3D.MakeCurrent();
            ipaintTo3D.Clear(Color.Black); // damit ist black die Backgroundcolor

            //e.Graphics.FillRectangle(Brushes.Black, e.Graphics.ClipBounds);
            GeoPoint2D ll        = layoutToScreen * new GeoPoint2D(0.0, 0.0);
            GeoPoint2D ur        = layoutToScreen * new GeoPoint2D(layout.PaperWidth, layout.PaperHeight);
            RectangleF paperrect = RectangleF.FromLTRB((float)ll.x, (float)ur.y, (float)ur.x, (float)ll.y);

            //e.Graphics.FillRectangle(Brushes.White, paperrect);

            //BoundingCube bc = new BoundingCube(ll.x, ur.x, ll.y, ur.y, -1.0, 1.0);
            //ipaintTo3D.SetProjection(new Projection(Projection.StandardProjection.FromTop), bc);
            ipaintTo3D.UseZBuffer(false);
            ipaintTo3D.SetColor(Color.White);
            ipaintTo3D.FillRect2D(ll.PointF, ur.PointF);

            //ipaintTo3D.FinishPaint();// DEBUG
            //return; // DEBUG

            ipaintTo3D.AvoidColor(Color.White);

            if (RepaintActionEvent != null)
            {
                RepaintActionEvent(this, ipaintTo3D);
            }

            for (int i = 0; i < layout.Patches.Length; ++i)
            {
                LayoutPatch  lp        = layout.Patches[i];
                BoundingRect paperRect = new BoundingRect(0.0, 0.0, layout.PaperWidth, layout.PaperHeight);

                BoundingRect ext;
                if (lp.Area != null)
                {
                    ext = lp.Area.Extent;
                }
                else
                {
                    ext = paperRect;
                }

                GeoPoint2D clipll = layoutToScreen * ext.GetLowerLeft();
                GeoPoint2D clipur = layoutToScreen * ext.GetUpperRight();
                Rectangle  clipRectangle = Rectangle.FromLTRB((int)clipll.x, (int)clipur.y, (int)clipur.x, (int)clipll.y);
                Projection pr = lp.Projection.Clone();
                double     factor, dx, dy;
                pr.GetPlacement(out factor, out dx, out dy);
                pr.SetPlacement(layoutToScreen.Factor * factor, ll.x + layoutToScreen.Factor * dx, ll.y - layoutToScreen.Factor * dy);
                pr.Precision = lp.Model.Extent.Size / 1000;

                ipaintTo3D.Precision = pr.Precision;
                ipaintTo3D.SetProjection(pr, lp.Model.Extent);
                ipaintTo3D.UseZBuffer(true);
                ipaintTo3D.SetClip(clipRectangle);
                ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.All);
                // lp.Model.ClearDisplayLists();
                lp.Model.RecalcDisplayLists(ipaintTo3D);
                if (lp.Projection.ShowFaces)
                {
                    ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.FacesOnly);
                    foreach (KeyValuePair <Layer, IPaintTo3DList> kv in lp.Model.layerFaceDisplayList)
                    {
                        if (lp.IsLayerVisible(kv.Key) || lp.Model.nullLayer == kv.Key)
                        {
                            ipaintTo3D.List(kv.Value);
                        }
                    }
                }
                ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.CurvesOnly);
                foreach (KeyValuePair <Layer, IPaintTo3DList> kv in lp.Model.layerCurveDisplayList)
                {
                    if (lp.IsLayerVisible(kv.Key) || lp.Model.nullLayer == kv.Key)
                    {
                        ipaintTo3D.List(kv.Value);
                    }
                }
                ipaintTo3D.SetClip(Rectangle.Empty);
            }
            ipaintTo3D.FinishPaint();
        }