private double prescaleKoefficient = 1.10; // we don't want the figure to keep the whole space. The higher is the value the bigger are margins

        /// <summary>
        /// we calculate here the dimensions which should be set to contain all the geometric entities in drawing panel.
        /// By the way, drawing panel can be larger than control, then the scrollbars appear
        /// </summary>
        private void recalculateRequiredDrawingWidth()
        {
            double xll          = structToRender.GetBoundingBox().XLowerLeft;
            double yll          = structToRender.GetBoundingBox().YLowerLeft;
            double xur          = structToRender.GetBoundingBox().XUpperRight;
            double yur          = structToRender.GetBoundingBox().YUpperRight;
            double domainHeight = prescaleKoefficient * Math.Abs(yur - yll);
            double domainWidth  = prescaleKoefficient * Math.Abs(xll - xur);

            requiredCanvasHeight = internalScaleFactor * domainHeight;
            requiredCanvasWidth  = internalScaleFactor * domainWidth;
        }
예제 #2
0
        /// <summary>
        /// Setup only INITIAL logical and graphical datastructures.
        /// </summary>
        /// <param name="in_savedStructureOfDxf">Logical structure of DXF as read from file</param>
        public void setupLogicalAndGraphicalDXFstructures(LOGICAL.completeDxfStruct in_savedStructureOfDxf)
        {
            savedStructureOfDxf = in_savedStructureOfDxf;
            //generate primal drawing structure
            MyDxfBoundingBox obtainedBox2 = savedStructureOfDxf.GetBoundingBox();

            if (obtainedBox2.XLowerLeft != 0)
            {
                offsetOfDxfHorizontal = 0 - obtainedBox2.XLowerLeft;
            }
            if (obtainedBox2.YLowerLeft != 0)
            {
                offsetOfDxfVertical = 0 - obtainedBox2.YLowerLeft;
            }
            primalDrawingStructure = new CompleteDxfDrawingStruct(null);
            int currentSizeOfDxfStruct = savedStructureOfDxf.getSize();

            for (int i = 0; i < currentSizeOfDxfStruct; i++)
            {
                DXFdrawingEntry  someEntry   = savedStructureOfDxf.getItemByIndex(i);
                MyDxfBoundingBox obtainedBox = someEntry.GetBoundingBox();
                //offsets to centralize the drawing in the box
                Pen usedPen = null;
                if ((collectionOfLayerDefinitions != null) && (collectionOfLayerDefinitions.ContainsKey(someEntry.layerIdentifier)))
                {
                    usedPen = collectionOfLayerDefinitions[someEntry.layerIdentifier].Item2;
                }
                else
                {
                    usedPen = new Pen(Color.Black);
                }

                if (someEntry is MyDxfLine)
                {
                    MyDxfLine castLine = someEntry as MyDxfLine;

                    DXFentryForDisplay theLineForDisplay = new MyDxfLineForDisplay(castLine.XStart + offsetOfDxfHorizontal, castLine.YStart + offsetOfDxfVertical, castLine.XEnd + offsetOfDxfHorizontal, castLine.YEnd + offsetOfDxfVertical, usedPen);
                    primalDrawingStructure.addSingleEntry(theLineForDisplay, obtainedBox.XLowerLeft + offsetOfDxfHorizontal, obtainedBox.YLowerLeft + offsetOfDxfVertical, obtainedBox.XUpperRight + offsetOfDxfHorizontal, obtainedBox.YUpperRight + offsetOfDxfVertical);
                }
                else if (someEntry is MyDxfArc)
                {
                    MyDxfArc           castArc          = someEntry as MyDxfArc;
                    DXFentryForDisplay theArcForDisplay = new MyDxfArcForDisplay(castArc.XCenter + offsetOfDxfHorizontal, castArc.YCenter + offsetOfDxfVertical, castArc.Radius, castArc.StartAngleDegree, castArc.EndAngleDegree, usedPen);
                    primalDrawingStructure.addSingleEntry(theArcForDisplay, obtainedBox.XLowerLeft + offsetOfDxfHorizontal, obtainedBox.YLowerLeft + offsetOfDxfVertical, obtainedBox.XUpperRight + offsetOfDxfHorizontal, obtainedBox.YUpperRight + offsetOfDxfVertical);
                }
            }
            //performing flip on draw structure is done by means of graphical container
        }