Ejemplo n.º 1
0
        public bool Init(bool showShapes)
        {
            chkShowShapes.Checked = showShapes;

            List <string> shapes = PosShape.GetAllPosShapes();

            if (shapes.Count == 0)
            {
                return(false);
            }

            try
            {
                foreach (string name in shapes)
                {
                    m_Copies.Add((PosShape)PosShape.GetPosShape(name).Clone());
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + ex.Message, "RebarPos", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return(false);
            }

            PopulateList();

            return(true);
        }
Ejemplo n.º 2
0
        private void SetReplaceShape(string name)
        {
            psvReplace.SetShape(name);

            m_ReplaceShape = name;
            PosShape shape = PosShape.GetPosShape(name);

            if (shape == null)
            {
                return;
            }
            m_ReplaceFields = shape.Fields;

            UpdateUI();
        }
Ejemplo n.º 3
0
        private void SetFindShape(string name)
        {
            psvFind.SetShape(name);

            m_FindShape = name;
            PosShape shape = PosShape.GetPosShape(name);

            if (shape == null)
            {
                return;
            }
            m_FindFields = shape.Fields;

            UpdateUI();
        }
Ejemplo n.º 4
0
        void cell_Paint(object sender, PaintEventArgs e)
        {
            if (init && !disposed && !Disposing && !IsDesigner)
            {
                Control cell      = (Control)sender;
                string  shapeName = (string)cell.Tag;
                if (string.IsNullOrEmpty(shapeName))
                {
                    return;
                }
                int           index   = layoutPanel.Controls.IndexOf(cell);
                PosShape      shape   = PosShape.GetPosShape(shapeName);
                List <string> lengths = new List <string>();
                if (pieceLengths.TryGetValue(index, out lengths) && (lengths.Count == 6))
                {
                    shape.SetShapeTexts(lengths[0], lengths[1], lengths[2], lengths[3], lengths[4], lengths[5]);
                }

                using (Bitmap bmp = shape.ToBitmap(device, view, model, CellBackColor, mCellSize.Width, mCellSize.Height))
                {
                    e.Graphics.DrawImageUnscaled(bmp, 0, 0);
                }

                shape.ClearShapeTexts();

                if (ShowShapeNames)
                {
                    using (Brush brush = new SolidBrush(IsDark(CellBackColor) ? Color.White : Color.Black))
                    {
                        e.Graphics.DrawString(shapeName, Font, brush, 4, 6);
                    }
                }

                if (mSelectedShape == shapeName)
                {
                    using (Pen pen = new Pen(mSelectionColor, 2.0f))
                    {
                        Rectangle rec = new Rectangle(0, 0, mCellSize.Width, mCellSize.Height);
                        rec.Inflate(-2, -2);
                        e.Graphics.DrawRectangle(pen, rec);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void SetShape(string shapeName)
        {
            SuspendUpdate();
            ClearItems();
            mShapeName = shapeName;

            if (!string.IsNullOrEmpty(mShapeName))
            {
                PosShape shape = PosShape.GetPosShape(shapeName);
                if (shape != null)
                {
                    PosShape shapeCopy = shape.Clone() as PosShape;
                    shapeCopy.ClearShapeTexts();
                    AddItem(shapeCopy);
                }
            }

            ResumeUpdate();
        }
Ejemplo n.º 6
0
        private void ApplyChanges()
        {
            string userFolder     = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "RebarPos");
            string userShapesFile = System.IO.Path.Combine(userFolder, "ShapeList.txt");
            string newShapesFile  = System.IO.Path.Combine(userFolder, "ShapeList.new");

            foreach (PosShape copy in m_Copies)
            {
                if (!copy.IsBuiltIn)
                {
                    if (PosShape.HasPosShape(copy.Name))
                    {
                        PosShape org = PosShape.GetPosShape(copy.Name);
                        org.Fields         = copy.Fields;
                        org.Formula        = copy.Formula;
                        org.FormulaBending = copy.FormulaBending;
                        org.Priority       = copy.Priority;
                        org.Items.Clear();
                        for (int i = 0; i < copy.Items.Count; i++)
                        {
                            org.Items.Add(copy.Items[i].Clone());
                        }
                    }
                    else
                    {
                        PosShape.AddPosShape(copy);
                    }
                }
            }

            try
            {
                PosShape.SavePosShapesToFile(newShapesFile);
                System.IO.File.Delete(userShapesFile);
                System.IO.File.Move(newShapesFile, userShapesFile);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + ex.Message, "RebarPos", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }

            PosShape.ReadPosShapesFromFile(userShapesFile);
        }
Ejemplo n.º 7
0
        private bool SetShape()
        {
            if (chkShowPieceLengths.Checked)
            {
                posShapeView.SetShape(m_Shape, txtA.Text, txtB.Text, txtC.Text, txtD.Text, txtE.Text, txtF.Text);
            }
            else
            {
                posShapeView.SetShape(m_Shape);
            }

            PosShape shape = PosShape.GetPosShape(m_Shape);

            if (shape == null)
            {
                return(false);
            }

            if (m_Bending)
            {
                m_Formula = shape.FormulaBending;
            }
            else
            {
                m_Formula = shape.Formula;
            }

            m_Fields     = shape.Fields;
            txtA.Enabled = btnSelectA.Enabled = btnMeasureA.Enabled = (m_Fields >= 1);
            txtB.Enabled = btnSelectB.Enabled = btnMeasureB.Enabled = (m_Fields >= 2);
            txtC.Enabled = btnSelectC.Enabled = btnMeasureC.Enabled = (m_Fields >= 3);
            txtD.Enabled = btnSelectD.Enabled = btnMeasureD.Enabled = (m_Fields >= 4);
            txtE.Enabled = btnSelectE.Enabled = btnMeasureE.Enabled = (m_Fields >= 5);
            txtF.Enabled = btnSelectF.Enabled = btnMeasureF.Enabled = (m_Fields >= 6);

            if (!txtA.Enabled)
            {
                txtA.Text = "";
            }
            if (!txtB.Enabled)
            {
                txtB.Text = "";
            }
            if (!txtC.Enabled)
            {
                txtC.Text = "";
            }
            if (!txtD.Enabled)
            {
                txtD.Text = "";
            }
            if (!txtE.Enabled)
            {
                txtE.Text = "";
            }
            if (!txtF.Enabled)
            {
                txtF.Text = "";
            }

            lblPosShape.Text = m_Shape;

            return(true);
        }
Ejemplo n.º 8
0
        public static List <PosCopy> ReadAllInSelection(IEnumerable <ObjectId> items, bool skipEmpty, PosGrouping grouping)
        {
            List <PosCopy> poslist = new List <PosCopy>();

            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in items)
                {
                    RebarPos pos = tr.GetObject(id, OpenMode.ForRead) as RebarPos;
                    if (pos != null)
                    {
                        // Skip empty pos numbers
                        if (skipEmpty && string.IsNullOrEmpty(pos.Pos))
                        {
                            continue;
                        }
                        // Skip detached pos
                        if (pos.Detached)
                        {
                            continue;
                        }

                        PosCopy copy = null;
                        if (grouping == PosGrouping.PosKey)
                        {
                            copy = poslist.Find(p => p.key == pos.PosKey);
                        }
                        else if (grouping == PosGrouping.PosKeyVarLength && !pos.CalcProperties.IsVarLength)
                        {
                            copy = poslist.Find(p => p.key == pos.PosKey);
                        }
                        else if (grouping == PosGrouping.PosMarker)
                        {
                            copy = poslist.Find(p => p.pos == pos.Pos);
                        }
                        else if (grouping == PosGrouping.PosKeyDifferentMarker)
                        {
                            copy = poslist.Find(p => p.key == pos.PosKey && p.pos == pos.Pos);
                        }
                        else if (grouping == PosGrouping.PosKeyDifferentMarkerVarLength && !pos.CalcProperties.IsVarLength)
                        {
                            copy = poslist.Find(p => p.key == pos.PosKey && p.pos == pos.Pos);
                        }

                        if (copy != null)
                        {
                            copy.list.Add(id);
                            if (pos.IncludeInBOQ)
                            {
                                copy.count += pos.CalcProperties.Count * pos.Multiplier;
                            }
                            copy.scale = Math.Max(copy.scale, pos.Scale);
                            copy.x     = Math.Min(copy.x, pos.BasePoint.X);
                            copy.y     = Math.Min(copy.y, pos.BasePoint.Y);
                        }
                        else
                        {
                            copy     = new PosCopy();
                            copy.key = pos.PosKey;
                            copy.list.Add(id);
                            copy.pos      = pos.Pos;
                            copy.newpos   = pos.Pos;
                            copy.existing = true;
                            if (pos.IncludeInBOQ)
                            {
                                copy.count = pos.CalcProperties.Count * pos.Multiplier;
                            }
                            copy.diameter = pos.Diameter;
                            copy.length   = pos.Length;

                            copy.a = pos.A;
                            copy.b = pos.B;
                            copy.c = pos.C;
                            copy.d = pos.D;
                            copy.e = pos.E;
                            copy.f = pos.F;

                            RebarPos.CalculatedProperties calc = pos.CalcProperties;
                            copy.fieldCount = calc.FieldCount;
                            copy.minA       = calc.MinA;
                            copy.minB       = calc.MinB;
                            copy.minC       = calc.MinC;
                            copy.minD       = calc.MinD;
                            copy.minE       = calc.MinE;
                            copy.minF       = calc.MinF;
                            copy.maxA       = calc.MaxA;
                            copy.maxB       = calc.MaxB;
                            copy.maxC       = calc.MaxC;
                            copy.maxD       = calc.MaxD;
                            copy.maxE       = calc.MaxE;
                            copy.maxF       = calc.MaxF;
                            copy.isVarA     = calc.IsVarA;
                            copy.isVarB     = calc.IsVarB;
                            copy.isVarC     = calc.IsVarC;
                            copy.isVarD     = calc.IsVarD;
                            copy.isVarE     = calc.IsVarE;
                            copy.isVarF     = calc.IsVarF;

                            copy.scale     = pos.Scale;
                            copy.x         = pos.BasePoint.X;
                            copy.y         = pos.BasePoint.Y;
                            copy.shapename = pos.Shape;
                            PosShape shape = PosShape.GetPosShape(copy.shapename);
                            if (shape != null)
                            {
                                copy.priority = shape.Priority;
                            }
                            copy.length1     = pos.CalcProperties.MinLength;
                            copy.length2     = pos.CalcProperties.MaxLength;
                            copy.isVarLength = pos.CalcProperties.IsVarLength;
                            poslist.Add(copy);
                        }
                    }
                }
            }

            return(poslist);
        }
Ejemplo n.º 9
0
 public static void DrawShape(string name, Point3d inspt, double height)
 {
     DrawShape(PosShape.GetPosShape(name), inspt, height);
 }
Ejemplo n.º 10
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (wd.RegenAbort || wd.IsDragging)
            {
                return(base.WorldDraw(drawable, wd));
            }

            RebarPos pos = drawable as RebarPos;

            if (pos == null)
            {
                return(base.WorldDraw(drawable, wd));
            }

            PosShape  shape    = PosShape.GetPosShape(pos.Shape);
            Extents3d?shapeExt = shape.Bounds;

            if (!shapeExt.HasValue)
            {
                return(base.WorldDraw(drawable, wd));
            }
            Extents3d ext = shapeExt.Value;

            WorldGeometry   g     = wd.Geometry;
            SubEntityTraits s     = wd.SubEntityTraits;
            TextStyle       style = new TextStyle();

            // Get geometry
            Point3d  pt   = pos.BasePoint;
            Vector3d dir  = pos.DirectionVector;
            Vector3d up   = pos.UpVector;
            Vector3d norm = pos.NormalVector;

            double w = pos.Width / dir.Length;
            double h = pos.Height / dir.Length;

            // Draw bound dimension lines
            foreach (RebarPos.BoundDimension dim in pos.GetBoundDimensions())
            {
                Line line = new Line(dim.TextPosition, pos.BasePoint);
                g.Draw(line);
            }

            // Draw shape
            double xmin = ext.MinPoint.X, ymin = ext.MinPoint.Y, xmax = ext.MaxPoint.X, ymax = ext.MaxPoint.Y;

            // Scale
            double scale = 0.025;
            // Client offsets
            double xoff = (w - scale * (xmax - xmin)) / 2.0;
            double yoff = 2.0 * h;//(h - scale * (ymax - ymin)) / 2.0;

            // Transform
            Matrix3d trans = Matrix3d.AlignCoordinateSystem(new Point3d(xmin, ymin, 0), Vector3d.XAxis / scale, Vector3d.YAxis / scale, Vector3d.ZAxis / scale, pt + dir * xoff + up * yoff, dir, up, norm);

            g.PushModelTransform(trans);

            // Draw shapes
            shape.SetShapeTexts(pos.A, pos.B, pos.C, pos.D, pos.E, pos.F);
            g.Draw(shape);
            shape.ClearShapeTexts();

            // Reset transform
            g.PopModelTransform();

            return(base.WorldDraw(drawable, wd));
        }