public void draw3DShape(Shape shape) { switch (shape.getTypeDraw()) { case TypeDraw.Cube: Cube cube = (Cube)shape; foreach (Line _line in cube.getListLine()) { //g.DrawLine(pen, _line.getStartPoint(), _line.getEndPoint()); drawLinebyMidPoint(_line, _line.getDottedLineFlag()); } break; case TypeDraw.Cylinder: Cylinder cylinder = (Cylinder)shape; foreach (Shape _s in cylinder.getListShape()) { if (_s.getTypeDraw() == TypeDraw.Line) { drawLinebyMidPoint((Line)_s); } else if (_s.getTypeDraw() == TypeDraw.Ellipse) { Ellipse _e = (Ellipse)_s; MidPoint_Ellipse(_e); //, _e.getDottedEllipseFlag()); } } break; } }
public void drawCube(Point3D point3d, int width, int height, int depth) { if (point3d != null) { Cube cube = (Cube)shape; //cube = new Cube(point3d, width, height, depth); cube.setColor(color); cube.setPoint3D(point3d); cube.setWidth(width); cube.setHeight(height); cube.setDepth(depth); if (cube != null) { foreach (Line _line in cube.getListLine()) { //g.DrawLine(pen, _line.getStartPoint(), _line.getEndPoint()); drawLinebyMidPoint(_line, _line.getDottedLineFlag()); } } //break; addShapeToShapeSet(); resetShape(); } }
public void paint(Object sender, PaintEventArgs e) { if (!choosedFlag) { List <Shape> _shapeSet; if (check2d) { _shapeSet = shapeSet; } else { _shapeSet = shapeSet3D; } foreach (Shape s in _shapeSet) { Pen pen = new Pen(s.getColor(), 3); Graphics g = frm.panel1.CreateGraphics(); switch (s.getTypeDraw()) { case TypeDraw.Line: Line line = (Line)s; //g.DrawLine(pen, line.getStartPoint().X, line.getStartPoint().Y, line.getEndPoint().X, line.getEndPoint().Y); //DDA_Line2(line); //drawLinebyMidPoint(line); DDA_Line2(line); break; case TypeDraw.Rectangle: Rectangle retangle = (Rectangle)s; List <Line> listLines = retangle.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; case TypeDraw.Triangle: Triangle triangle = (Triangle)s; listLines = triangle.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; case TypeDraw.Parallelogram: Parallelogram parallelogram = (Parallelogram)s; listLines = parallelogram.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; case TypeDraw.Circle: Circle circle = (Circle)s; MidPoint_Circle(circle); break; case TypeDraw.Ellipse: Ellipse ellipse = (Ellipse)s; MidPoint_Ellipse(ellipse); //,true); break; //case TypeDraw.Cube: // Cube cube = (Cube)s; //g.DrawLine(new Pen(Color.Black), 200, 200, 400, 200); //g.DrawLine(new Pen(Color.Black), 200, 200, 200, 400); //g.DrawLine(new Pen(Color.Red), 200, 0, 200, 200); //g.DrawLine(new Pen(Color.Red), 200, 200, 400, 200); //g.DrawLine(new Pen(Color.Aqua), 200, 200, 400, 400); //if(cube!=null) // foreach (Line _line in cube.getListLine()) // { // //g.DrawLine(pen, _line.getStartPoint(), _line.getEndPoint()); // drawLinebyMidPoint(_line,_line.getDottedLineFlag()); // } //break; //case TypeDraw.Cylinder: //Cylinder cylinder = (Cylinder)s; //g.DrawLine(new Pen(Color.Black), 200, 200, 400, 200); //g.DrawLine(new Pen(Color.Black), 200, 200, 200, 400); ////g.DrawLine(new Pen(Color.Red), 200, 0, 200, 200); ////g.DrawLine(new Pen(Color.Red), 200, 200, 400, 200); //g.DrawLine(new Pen(Color.Aqua), 200, 200, 400, 400); //foreach(Shape _s in cylinder.getListShape()) //{ // if (_s.getTypeDraw() == TypeDraw.Line) // drawLinebyMidPoint((Line)_s); // else if (_s.getTypeDraw() == TypeDraw.Ellipse) { // Ellipse _e = (Ellipse)_s; // MidPoint_Ellipse(_e);//, _e.getDottedEllipseFlag()); // } //} //break; case TypeDraw.Square: Square square = (Square)s; listLines = square.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; } g.Dispose(); } } else { if (choosedShape != null) { if (shape != null && shape.getTransformFlag()) { Transform.translationTransform(shape); getInfoShape(); } //Pen pen = new Pen(choosedShape.getColor(), 3); //Graphics g = frm.panel1.CreateGraphics(); if (check2d) { switch (choosedShape.getTypeDraw()) { case TypeDraw.Line: Line line = (Line)choosedShape; //g.DrawLine(pen, line.getStartPoint().X, line.getStartPoint().Y, line.getEndPoint().X, line.getEndPoint().Y); //DDA_Line2(line); DDA_Line2(line); break; case TypeDraw.Rectangle: Rectangle retangle = (Rectangle)choosedShape; List <Line> listLines = retangle.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; case TypeDraw.Triangle: Triangle triangle = (Triangle)choosedShape; listLines = triangle.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; case TypeDraw.Parallelogram: Parallelogram parallelogram = (Parallelogram)choosedShape; listLines = parallelogram.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; case TypeDraw.Circle: Circle circle = (Circle)choosedShape; MidPoint_Circle(circle); break; case TypeDraw.Ellipse: Ellipse ellipse = (Ellipse)choosedShape; MidPoint_Ellipse(ellipse); break; case TypeDraw.Square: Square square = (Square)choosedShape; listLines = square.getAllLines(); if (listLines != null) { foreach (Line _line in listLines) { DDA_Line2(_line); } } break; //case TypeDraw.Cube: // Cube cube = (Cube)choosedShape; // if (cube != null) // foreach (Line _line in cube.getListLine()) // { // //g.DrawLine(pen, _line.getStartPoint(), _line.getEndPoint()); // drawLinebyMidPoint(_line, _line.getDottedLineFlag()); // } // break; //case TypeDraw.Cylinder: // Cylinder cylinder = (Cylinder)choosedShape; // foreach (Shape _s in cylinder.getListShape()) // { // if (_s.getTypeDraw() == TypeDraw.Line) // drawLinebyMidPoint((Line)_s); // else if (_s.getTypeDraw() == TypeDraw.Ellipse) // { // Ellipse _e = (Ellipse)_s; // MidPoint_Ellipse(_e, _e.getDottedEllipseFlag()); // } // } // break; } //g.Dispose(); } else { switch (choosedShape.getTypeDraw()) { case TypeDraw.Cube: Cube cube = (Cube)choosedShape; if (cube != null) { foreach (Line _line in cube.getListLine()) { //g.DrawLine(pen, _line.getStartPoint(), _line.getEndPoint()); drawLinebyMidPoint(_line, _line.getDottedLineFlag()); } } break; case TypeDraw.Cylinder: Cylinder cylinder = (Cylinder)choosedShape; foreach (Shape _s in cylinder.getListShape()) { if (_s.getTypeDraw() == TypeDraw.Line) { drawLinebyMidPoint((Line)_s); } else if (_s.getTypeDraw() == TypeDraw.Ellipse) { Ellipse _e = (Ellipse)_s; MidPoint_Ellipse(_e); //, _e.getDottedEllipseFlag()); } } break; } } } } //getInfoShape(); }