Ejemplo n.º 1
0
        /// <summary>
        /// Add Crease on specific location
        /// </summary>
        /// <param name="point1">first point of location where Crease add on</param>
        /// <param name="point2">second point of location where Crease add on</param>
        /// <returns>new created Crease</returns>
        public SlabShapeCrease AddCrease(PointF point1, PointF point2)
        {
            //create first vertex
            Transaction transaction = new Transaction(
                m_commandData.Application.ActiveUIDocument.Document, "AddCrease");

            transaction.Start();
            Vector4 v1 = new Vector4(new Autodesk.Revit.DB.XYZ(point1.X, point1.Y, 0));

            v1 = m_restoreMatrix.Transform(v1);
            SlabShapeVertex vertex1 = m_slabShapeEditor.DrawPoint(new Autodesk.Revit.DB.XYZ(v1.X, v1.Y, v1.Z));
            //create second vertex
            Vector4 v2 = new Vector4(new Autodesk.Revit.DB.XYZ(point2.X, point2.Y, 0));

            v2 = m_restoreMatrix.Transform(v2);
            SlabShapeVertex vertex2 = m_slabShapeEditor.DrawPoint(new Autodesk.Revit.DB.XYZ(v2.X, v2.Y, v2.Z));
            //create crease
            SlabShapeCreaseArray creases = m_slabShapeEditor.DrawSplitLine(vertex1, vertex2);

            SlabShapeCrease crease = creases.get_Item(0);

            transaction.Commit();
            //re-calculate geometry info
            GetSlabProfileInfo();
            return(crease);
        }
Ejemplo n.º 2
0
        Stream(ArrayList data, SlabShapeCrease slabCrease)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(SlabShapeCrease)));

            data.Add(new Snoop.Data.String("Crease type", slabCrease.CreaseType.ToString()));
            data.Add(new Snoop.Data.Object("Curve", slabCrease.Curve));
            data.Add(new Snoop.Data.Enumerable("End points", slabCrease.EndPoints));
        }
Ejemplo n.º 3
0
        private void Stream(ArrayList data, SlabShapeCrease slabCrease)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(SlabShapeCrease)));

            data.Add(new Snoop.Data.String("Crease type", slabCrease.CreaseType.ToString()));
            data.Add(new Snoop.Data.Object("Curve", slabCrease.Curve));
            data.Add(new Snoop.Data.Enumerable("End points", slabCrease.EndPoints));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// add vertex and crease, select new created vertex and crease
 /// </summary>
 /// <param name="sender">object who sent this event</param>
 /// <param name="e">event args</param>
 private void SlabShapePictureBox_MouseClick(object sender, MouseEventArgs e)
 {
     if (EditorState.AddCrease == editorState)
     {
         if (!m_slabProfile.CanCreateVertex(new PointF(e.X, e.Y)))
         {
             return;
         }
         m_lineTool.Points.Add(new PointF(e.X, e.Y));
         int lineSize = m_lineTool.Points.Count;
         if (0 == m_lineTool.Points.Count % 2)
         {
             m_createCreases.Add(
                 m_slabProfile.AddCrease((PointF)m_lineTool.Points[lineSize - 2],
                                         (PointF)m_lineTool.Points[lineSize - 1]));
         }
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.AddVertex == editorState)
     {
         SlabShapeVertex vertex = m_slabProfile.AddVertex(new PointF(e.X, e.Y));
         if (null == vertex)
         {
             return;
         }
         m_pointTool.Points.Add(new PointF(e.X, e.Y));
         //draw point as a short line, so add two points here
         m_pointTool.Points.Add(new PointF((float)(e.X + 2), (float)(e.Y + 2)));
         m_createdVertices.Add(vertex);
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.Select == editorState)
     {
         if (m_selectIndex >= 0)
         {
             m_clickedIndex = m_selectIndex;
             if (m_selectIndex <= m_createCreases.Count - 1)
             {
                 m_selectedCrease = (SlabShapeCrease)(m_createCreases[m_selectIndex]);
                 m_selectedVertex = null;
             }
             else
             {
                 //put all path (crease and vertex) in one arrayList, so reduce creases.count
                 int index = m_selectIndex - m_createCreases.Count;
                 m_selectedVertex = (SlabShapeVertex)(m_createdVertices[index]);
                 m_selectedCrease = null;
             }
         }
         else
         {
             m_selectedVertex = null; m_selectedCrease = null; m_clickedIndex = -1;
         }
     }
     this.SlabShapePictureBox.Refresh();
 }
Ejemplo n.º 5
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            SlabShapeCrease slabCrease = e.ObjToSnoop as SlabShapeCrease;

            if (slabCrease != null)
            {
                Stream(snoopCollector.Data(), slabCrease);
                return;
            }

            SlabShapeEditor slabEditor = e.ObjToSnoop as SlabShapeEditor;

            if (slabEditor != null)
            {
                Stream(snoopCollector.Data(), slabEditor);
                return;
            }

            SlabShapeVertex slabVertex = e.ObjToSnoop as SlabShapeVertex;

            if (slabVertex != null)
            {
                Stream(snoopCollector.Data(), slabVertex);
                return;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// add vertex and crease, select new created vertex and crease
 /// </summary>
 /// <param name="sender">object who sent this event</param>
 /// <param name="e">event args</param>
 private void SlabShapePictureBox_MouseClick(object sender, MouseEventArgs e)
 {
     if (EditorState.AddCrease == editorState)
     {
         if (!m_slabProfile.CanCreateVertex(new PointF(e.X, e.Y))) { return; }
         m_lineTool.Points.Add(new PointF(e.X, e.Y));
         int lineSize = m_lineTool.Points.Count;
         if (0 == m_lineTool.Points.Count % 2)
         {
             m_createCreases.Add(
                 m_slabProfile.AddCrease((PointF)m_lineTool.Points[lineSize - 2],
                 (PointF)m_lineTool.Points[lineSize - 1]));
         }
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.AddVertex == editorState)
     {
         SlabShapeVertex vertex = m_slabProfile.AddVertex(new PointF(e.X, e.Y));
         if (null == vertex) { return; }
         m_pointTool.Points.Add(new PointF(e.X, e.Y));
         //draw point as a short line, so add two points here
         m_pointTool.Points.Add(new PointF((float)(e.X + 2), (float)(e.Y + 2)));
         m_createdVertices.Add(vertex);
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.Select == editorState)
     {
         if (m_selectIndex >= 0)
         {
             m_clickedIndex = m_selectIndex;
             if (m_selectIndex <= m_createCreases.Count - 1)
             {
                 m_selectedCrease = (SlabShapeCrease)(m_createCreases[m_selectIndex]);
                 m_selectedVertex = null;
             }
             else
             {
                 //put all path (crease and vertex) in one arrayList, so reduce creases.count
                 int index = m_selectIndex - m_createCreases.Count;
                 m_selectedVertex = (SlabShapeVertex)(m_createdVertices[index]);
                 m_selectedCrease = null;
             }
         }
         else { m_selectedVertex = null; m_selectedCrease = null; m_clickedIndex = -1; }
     }
     this.SlabShapePictureBox.Refresh();
 }