/* GEDDRAW (GED) -- GED 2D Drawing Functions */ /* GEDDRAW (GED) -- GED-2D-Zeichnungsfunktionen */ /* // Copyright (c) 1993-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (110310) BUGFIX: // Eliminated small angle measurement crossed markers. // rl (101019) RELEASED FOR BAE V7.6. // rl (100520) ENHANCEMENT: // Added n-edge, ellipse and oval polygon functions // to draw assistant dialog box. // rl (100127) ENHANCEMENT: // Added coordinate measurement arrow draw options. // rl (091021) RELEASED FOR BAE V7.4. // rl (090224) ENHANCEMENT: // Added coordinate measurement functions. // rl (081014) RELEASED FOR BAE V7.2. // rl (080502) ENHANCEMENT: // Added draw assistant dialog box. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (060616) BUGFIX: // Fixed problems with automatic layer selection for texts. // rl (060222) ENHANCEMENT: // Added distance marker text size manipulation option. // Creating distance and rule marker texts centered. // rl (060214) ENHANCEMENT: // Added trailing zero supression option to measurement functions. // rl (051023) ENHANCEMENT: // Added distance marker end arrow option. // Added measurement deletion function. // rl (050906) RELEASED FOR BAE V6.6. // rl (050124) ENHANCEMENT: // Added offset placement and H/V component separation to // distance measure function. // rl (040811) RELEASED FOR BAE V6.4. // rl (040121) ENHANCEMENT: // Added temporary rectangle/circle polyon creation functions. // rl (030904) RELEASED FOR BAE V6.2. // rl (030603) BUGFIX: // Fixed problem with floating point inaccuracy. // rl (030409) ENHANCEMENT: // Added RMB layer/polygon type change and undo support. // Added full default element layer support. // rl (030407) BUGFIX: // Fixed problems with degenerated horizontal arrows. // rl (021209) RELEASED FOR BAE V6.0. // rl (021112) ENHANCEMENT: // Added preservation of arrow width for current session. // rl (020618) RELEASED FOR BAE V5.4. // rl (020315) ENHANCEMENT: // Added angle measurement function. // rl (010625) RELEASED FOR BAE V5.0. // rl (010320) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // rl (000721) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (980929) RELEASED FOR BAE V4.2. // mb (980710) ENHANCEMENT: // Pulldown menu delimiters introduced. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (960919) RELEASED FOR BAE V3.4. // mb (960304) BUGFIX: // Function calling bugfixed angle() function corrected. // mb (95) RELEASED FOR BAE V3.2. // mb (941124) ENHANCEMENT: // Integrated RULER. // mb (941116) ORIGINAL CODING; retrieved from DRAFTUTL // mb (94) RELEASED FOR BAE V3.0 (DRAFTUTL). // mb (94) ENHANCEMENT (DRAFTUTL): // Introduced arrow draw function. // Integrated AREAMEAS, DISTMEAS. // mb (93) RELEASED FOR BAE V2.6 (DRAFTUTL). // mb (93) ORIGINAL CODING (DRAFTUTL). // // DESCRIPTION // // The geddraw User Language program provides a series of // advanced Layout Editor drawing functions such as producing // circles, rectangles and/or arrows, performing distance // and/or area measuring, and generating rulers. */ // Includes #include "lay.ulh" // User Language layout utilities #include "pop.ulh" // User Language popup utilities #include "popdraw.ulh" // User Language popup draw. util. // Disable undo state request #pragma ULCALLERNOUNDO // INI file parameter name definitions #define PAR_COORDTMODE "COORDTMODE_GED"// Coordinate text fraction mode #define PAR_DTEXTSIZE "DTEXTSIZE_GED" // Distance default text size [m] #define PAR_DTMINSIZE "DTMINSIZE_GED" // Distance min. text size [m] #define PAR_DINCHTEXT "DINCHTEXT_GED" // Distance inch units text #define PAR_DMMTEXT "DMMTEXT_GED" // Distance mm units text #define PAR_DDECDIG "DDECDIG_GED" // Distance digits after decimal point #define PAR_DTEXTSUF "DTEXTSUF_GED" // Distance text suffix #define PAR_DTEXTPREF "DTEXTPREF_GED" // Distance text prefix #define PAR_DAUTOSEL "DAUTOSEL_GED" // Distance graphic auto. group sel. #define PAR_DLONGLINE "DLONGLINE_GED" // Distance long line creation #define PAR_DENDMODE "DENDMODE_GED" // Distance end marker mode #define PAR_DENDARATIO "DENDARATIO_GED"// Distance end marker aspect ratio #define PAR_DENDHSCALE "DENDHSCALE_GED"// Distance end marker height scale #define PAR_ATEXTSIZE "ATEXTSIZE_GED" // Area text size string (mm) #define PAR_AINCHTEXT "AINCHTEXT_GED" // Area inch units text #define PAR_AMMTEXT "AMMTEXT_GED" // Area mm units text #define PAR_ADECDIG "ADECDIG_GED" // Area digits after decimal point #define PAR_WTEXTSIZE "WTEXTSIZE_GED" // Angle default text size [m] #define PAR_WDEGTEXT "WDEGTEXT_GED" // Angle units text #define PAR_WDECDIG "WDECDIG_GED" // Angle digits after decimal point #define PAR_WARCRED "WARCRED_GED" // Angle arc radius reduction factor #define PAR_RTEXTSIZE "RTEXTSIZE_GED" // Ruler documentation text size #define PAR_RULESHORT "RULESHORT_GED" // Ruler short line length factor #define PAR_RULEMIDDLE "RULEMIDDLE_GED"// Ruler middle line length factor #define PAR_RULELONG "RULELONG_GED" // Ruler long line length factor #define PAR_RULETEXT "RULETEXT_GED" // Ruler text offset factor #define PAR_DARROWW "DARROWW_GED" // Default arrow width #define PAR_DARROWHL "DARROWHL_GED" // Default arrow head relativ length #define PAR_DARROWHW "DARROWHW_GED" // Default arrow head relativ width #define PAR_TMPGRPNAME "TMPGRPNAME_GED"// Temporary group name #define PAR_TILECOVER "TILECOVER_GED" // Tile coverage factor #define PAR_TILERAD "TILERAD_GED" // Tile radius #define PAR_DRAWLAYER "DRAWLAYER_GED" // Draw assistant default layer #define PAR_DRAWPTYP "DRAWPOLYTYP_GED" // Draw assistant def. polygon type #define PAR_DRAWNETN "DRAWNETNAME_GED" // Draw assistant default net name #define PAR_DRAWLOOP "DRAWLOOP_GED" // Draw assistant default loop mode #define PAR_DRAWEDGE "DRAWPOLYEDGE_GED" // Draw assistant def. poly. edges #define PAR_DRAWORI "DRAWPOLYORI_GED" // Draw assistant def. poly. orient. #define PAR_DRAWSTEP "DRAWELLISTEP_GED" // Draw assistant def. ellipse steps #define PAR_DRAWDIM1 "DRAWPOLYDIM1_GED" // Draw assistant def. poly. width #define PAR_DRAWDIM2 "DRAWPOLYDIM2_GED" // Draw assistant def. poly. height #define PAR_DRAWCRAD "DRAWPOLYCRAD_GED" // Draw assistant def. poly. radius #define PAR_DRAWPLOTW "DRAWPLOTW_GED" // Draw assistant default plot width #define PAR_DRAWTEXT "DRAWTEXT_GED" // Draw assistant default text #define PAR_DRAWTEXTH "DRAWTEXTH_GED" // Draw assistant default text height #define PAR_DRAWTEXTC "DRAWTEXTC_GED" // Draw assistant default text centered #define PAR_LIBFNAME "DRAWLIBFN_GED" // Group library file name #define PAR_BRWHEIGHT "DRAWDISPH_LAY" // Group browse bitmap height #define PAR_LSTHEIGHT "DRAWLISTH_LAY" // Group browse listbox height #define PAR_DISPTEXT "DISPTEXT_LAY" // Display text flag #define PAR_CMEASLINE "CMEASLINE_GED" // Coordinate line draw mode #define PAR_CTEXTSIZE "CTEXTSIZE_GED" // Coordinate default text size [m] #define PAR_CINCHTEXT "CINCHTEXT_GED" // Coordinate inch units text #define PAR_CMMTEXT "CMMTEXT_GED" // Coordinate mm units text #define PAR_CDECDIG "CDECDIG_GED" // Coordinate digits after decimal point #define PAR_CARROWL "CARROWL_GED" // Coordinate arrow length #define PAR_CARROWH "CARROWH_GED" // Coordinate arrow height // Messages string UPRABORT = M_UPRABORT(); string REPDONE = M("Es wurden keine Fehler festgestellt.", "Operation completed without errors."); string UPRDRAW = M("Zeichnungsfunktion selektieren!", "Select Drawing Function!"); string UPRDRAW1 = M("Zeichnen &Rechtecke","Draw &Rectangles"); string UPRDRAW2 = M("Zeichnen &Kreise","Draw &Circles"); string UPRDRAW3 = M("Zeichnen &Pfeile","Draw Arro&ws"); string UPRDRAW4 = M("%&Distanz-Bemassung","%&Distance Measure"); string UPRDRAW5 = M("&Flaechen-Bemassung","Area &Measure"); string UPRDRAW6 = M("&Winkel-Bemassung","An&gle Measure"); string UPRDRAW7 = M("%&Lineal-Erzeugung","%Generate Ru&ler"); string UPRDRAW8 = M("%Bemassung/Lineal &entfernen", "%D&elete Measurement/Ruler"); string UPRDRAW9 = M("%Fl&aeche kacheln","%&Tile Polygon"); string UPRDRAW10 = M("%&Zeichenassistent","%Draw &Assistant"); string UPRDRAW11 = M("%Bemassung &X","%&X Dimensioning"); string UPRDRAW12 = M("Bemassung &Y","&Y Dimensioning"); string UPRDRAW13 = M("&Bemassung X/Y","X/Y Dimen&sioning"); string UPRRLAY = M("Lage fuer Rechtecke selektieren!", "Select Rectangle Layer!"); string UPRRCORNER1 = M("Erste Ecke des Rechtecks waehlen!", "Select Rectangle First Corner!"); string UPRRCORNER2 = M("Zweite Ecke des Rechtecks waehlen!", "Select Rectangle Second Corner!"); string UPRRCENTER = M("Mitte des Rechtecks waehlen!", "Select Rectangle Center!"); string UPRRCORNER = M("Aussenecke des Rechtecks waehlen!", "Select Rectangle Outer Corner!"); string UPRSCORNER1 = M("Erste Ecke des Quadrates waehlen!", "Select Square First Corner!"); string UPRSCORNER2 = M("Zweite Ecke des Quadrates waehlen!", "Select Square Second Corner!"); string UPRSCENTER = M("Mitte des Quadrates waehlen!", "Select Square Center!"); string UPRSCORNER = M("Aussenecke des Quadrates waehlen!", "Select Square Outer Corner!"); string UPRLCORNER1 = M("Ersten Eckpunkt der Linie waehlen!", "Select First Line Corner!"); string UPRLCORNER2 = M("Zweiten Eckpunkt der Linie waehlen!", "Select Second Line Corner!"); string UPRPCENTER = M("Mitte des Polygons waehlen!", "Select Polygon Center!"); string UPRPCORNER = M("Ecke des Polygons waehlen!", "Select Polygon Corner!"); string UPRCLAY = M("Lage fuer Kreise selektieren!", "Select Circle Layer!"); string UPRCCENTER = M("Kreis-Mittelpunkt waehlen!", "Select Circle Center Point!"); string UPRCRADIUS = M("Kreis-Radius waehlen!","Select Circle Radius!"); string UPRECENTER = M("Mitte der Ellipse waehlen!", "Select Ellipse Center!"); string UPRECORNER = M("Aussenecke des Ellipsenbereiches waehlen!", "Select Ellipse Range Outer Corner!"); string UPRECORNER1 = M("Erste Ecke des Ellipsenbereiches waehlen!", "Select Ellipse Range First Corner!"); string UPRECORNER2 = M("Zweite Ecke des Ellipsenbereiches waehlen!", "Select Ellipse Range Second Corner!"); string UPROCENTER = M("Mitte des Ovals waehlen!", "Select Oval Center!"); string UPROCORNER = M("Aussenecke des Ovalbereiches waehlen!", "Select Oval Range Outer Corner!"); string UPROCORNER1 = M("Erste Ecke des Ovalbereiches waehlen!", "Select Oval Range First Corner!"); string UPROCORNER2 = M("Zweite Ecke des Ovalbereiches waehlen!", "Select Oval Range Second Corner!"); string UPRCRAD = M("Radius","Radius"); string UPRCRADM = M("Radius [mm] ? ","Radius [mm] ? "); string UPRCRADI = M("Radius [Inch] ? ","Radius [Inch] ? "); string UPRARRWM = M("Pfeil Stiftbreite [mm] ? ", "Arrow Pen Width [mm] ? "); string UPRARRWI = M("Pfeil Stiftbreite [Inch] ? ", "Arrow Pen Width [Inch] ? "); string UPRARRLM = M("Laenge Pfeilspitze (0.0 kein Pfeil) [mm] ? ", "Arrow-head Length (0.0 no Arrow) Pen Width [mm] ? "); string UPRARRLI = M("Laenge Pfeilspitze (0.0 kein Pfeil) [Inch] ? ", "Arrow-head Length (0.0 no Arrow) [Inch] ? "); string UPRARRHM = M("Breite Pfeilspitze (0.0 kein Pfeil) [mm] ? ", "Arrow-head Width (0.0 no Arrow) [mm] ? "); string UPRARRHI = M("Breite Pfeilspitze (0.0 kein Pfeil) [Inch] ? ", "Arrow-head Width (0.0 no Arrow) [Inch] ? "); string UPRALAY = M("Pfeil Lage waehlen!","Select Arrow Layer!"); string UPRAPOS1 = M("Pfeil Startpunkt selektieren!", "Select Arrow Start Point!"); string UPRAPOS2 = M("Pfeil Endpunkt selektieren!", "Select Arrow End Point!"); string UPRFILLMODE = M("Fuellmodus selektieren!","Select Fill Mode!"); string UPRFILLON = M("%&Fuellen an","%&Fill On"); string UPRFILLOFF = M("Fuellen &aus","Fill &Off"); string UPRPOLYMODE = M("Polygonmodus selektieren!", "Select Polygon Mode!"); string UPRPOLYMODED = M("Polygonmodus :","Polygon Mode :"); string UPRPOLYTYPE = M("Polygontyp selektieren!", "Select Polygon Type!"); string UPRFILLAREA = M("%&Flaeche","%A&rea"); string UPRKOUTAREA = M("&Sperrflaeche","&Keep Out Area"); string UPRLINEAREA = M("&Linie","&Outline"); string UPRKOUTTAREA = M("&Temporaersperrflaeche", "&Temporary Keep Out Area"); string UPRSPTYPSFA = M("&Standard","&Standard"); string UPRSPTYPFFA = M("Nur &Flaechenfuellen","Only &Copper Fill"); string UPRSPTYPRFA = M("Nur Auto&routing","Only Auto &Routing"); string UPRSPTYPBFA = M("&Nur Fuellen && Routen","&Only Fill && Routing"); string UPRSPTYPSCF = M("&Standard","&Standard"); string UPRSPTYPFCF = M("Immer &Flaechenfuellen","Always &Solid Fill"); string UPRSPTYPHCF = M("Immer &Schraffieren","Alway &Hatch Fill"); string UPRSPTYPFULLFA = M("Vollcheck","Full Check"); string UPRSPTYPCROSSFA = M("Schnitt","Cross"); string UPRNIL = "--------"; string UPRMEASLAY = M("Lage fuer Bemassung selektieren!", "Select Measure Layer!"); string UPRTSIZEM = M("Textgroesse [mm] ? ","Text Size [mm] ? "); string UPRTSIZEI = M("Textgroesse [Inch] ? ","Text Size [Inch] ? "); string UPRDPOSM = M("Zu bemassenden Punkt waehlen!", "Select point to be measured!"); string UPRDPOSN = M("Bemassungsursprung waehlen!", "Select measurement origin!"); string UPRDPOS1 = M("Distanz-Startposition waehlen!", "Select Start Position!"); string UPRDPOS2 = M("Distanz-Endposition waehlen!", "Select End Position!"); string UPRDPOS3 = M("Distanz-Dokumentationsposition waehlen!", "Select Documentation Position!"); string UPRDPOS3H = M("Horizontaldistanz-Dokumentationsposition waehlen!", "Select Horizontal Documentation Position!"); string UPRDPOS3V = M("Vertikaldistanz-Dokumentationsposition waehlen!", "Select Vertical Documentation Position!"); string UPRDTEXTP = M("Distanztextprefix ? ","Distance Text Prefix ? "); string UPRDTEXTS = M("Distanztextsuffix ? ","Distance Text Suffix ? "); string UPRANGPOSV = M("Winkel-Scheitelpunkt waehlen!", "Select Vertex Position!"); string UPRANGPOS1 = M("1. Winkel-Schenkelpunkt waehlen!", "Select 1st Angle Side Position!"); string UPRANGPOS2 = M("2. Winkel-Schenkelpunkt waehlen!", "Select 2nd Angle Side Position!"); string UPRMAREA = M("Bemassungs-Flaeche(n) waehlen!", "Select Measure Polygon(s)!"); string UPRRULLAY = M("Lage fuer Lineal selektieren!", "Select Ruler Layer!"); string UPRRPOS1 = M("Lineal-Anfangsposition waehlen!", "Select Ruler Start Position!"); string UPRRPOS2 = M("Lineal-Endposition waehlen!", "Select Ruler End Position!"); string UPRDONE = M("&Fertig","&Done"); string UPRCONT = M("&Weiter","&Continue"); string UPRJUMPREL = M("%Sprung relati&v","%Jump Relati&ve"); string UPRJUMPABS = M("&Sprung absolut","&Jump Absolute"); string UPRNOJUMP = M("&1:1 Platzierung","Place &1:1"); string UPRSELPORI = M("%&Kante-/Ecke-Drehung","%&Edge/Corner Rotate"); string UPRSELLAY = M("%Lage &wechseln","%C&hange Layer"); string UPRTHEIGHT = M("Text&groesse","Text S&ize"); string UPRSELORIG = M("%Bemassungs&nullpunkt setzen", "%Set Measurement &Origin"); string UPRSELNLINE = M("%Keine Bemassungslinie","%No Measurement Line"); string UPRSELAL = M("%Laenge Pfeilspitze","%Arrow-head Length"); string UPRSELAH = M("Breite Pfeilspitze","Arrow-head Width"); string UPRSELLINE = M("Bemassungslinie","Measurement Line"); string UPRSELLIB = M("Gruppenbibliothek ? ","Group Library ? "); string UPRWIDTH = M("%&Pfeil Stiftbreite","%Arrow Pen &Width"); string UPRUNDO = M("%&Undo","%&Undo"); string UPRDIAG = M("%V&oller Abstand","%&Full Distance"); string UPRHORI = M("&Horizontalabstand","&Horizontal Distance"); string UPRVERT = M("V&ertikalabstand","V&ertical Distance"); string UPRBOTH = M("H+V ge&trennt","H+V &seperately"); string UPRPREFIX = M("%Text&prefix","%Text &Prefix"); string UPRSUFFIX = M("Texts&uffix","Text S&uffix"); string UPRSELMEAS = M("Bemassungs-/Lineallinie waehlen!", "Select Measurement/Rule Line!"); string UPRTILELAY = M("Lage fuer Kachelung selektieren!", "Select Tile Layer!"); string UPRTILEPOLY = M("Flaeche(n) zur Kachelung waehlen!", "Select Tile Polygon(s)!"); string UPRTILEC = M("Kacheleinstellungen","Tile Settings"); string UPRTILEXCNTD = M("Kachelelemente X-Richtung :","Tile X Count :"); string UPRTILEYCNTD = M("Kachelelemente Y-Richtung :","Tile Y Count :"); string UPRTILEXCNT = M("Anzahl Kachelelemente X-Richtung ? ", "Tile X Count ? "); string UPRTILEYCNT = M("Anzahl Kachelelemente Y-Richtung ? ", "Tile Y Count ? "); string UPRTILECOVERD = M("Kachelbedeckung [%] :","Tile Coverage [%] :"); string UPRTILECOVER = M("Kachelbedeckung [%] ? ","Tile Coverage [%] ? "); string UPRTILECORND = M("Eckenradius :","Corner Radius :"); string UPRTILECORNM = M("Eckenradius [mm] ? ","Corner Radius [mm] ? "); string UPRTILECORNI = M("Eckenradius [Inch] ? ","Corner Radius [Inch] ? "); string UPRDUNITMM = M("mm","mm"); string UPRDUNITMIL = M("mil","mil"); string UPRDRAWFUNC = M("Zeichenfunktionen","Draw Functions"); string UPRLAYER = M("Lage","Layer"); string UPRNLAYER = M("K","N"); string UPRPLAYER = M("V","P"); string UPRPOLY = M("Polygon","Polygon"); string UPRTEXT = M("Text","Text"); string UPRTEXTC = M("zentriert:","centered:"); string UPRTEXTCH = M("H","H"); string UPRTEXTCV = M("V","V"); string UPRNET = M("Netz :","Net :"); string UPRLOOP = M("Schleifeneingabe","Placement Loop"); string UPRSQUARE = M("Quadrat :","Square :"); string UPRRECTANGLE = M("Rechteck :","Rectangle :"); string UPRELLIPSE = M("Ellipse :","Ellipse :"); string UPROVAL = M("Oval :","Oval :"); string UPRLINE = M("Linie :","Line :"); string UPRPOLYE = M("-Eck :","Edges :"); string UPRCIRCLE = M("Kreis :","Circle :"); string UPRACTCC = M("Ecke,Ecke","Corner,Corner"); string UPRACTCN = M("Ecken","Corners"); string UPRACTCP = M("Mitte,Ecke","Center,Corner"); string UPRACTCPR = M("Mitte,Radius","Center,Radius"); string UPRACTPC = M("Rand,Mitte","Corner,Center"); string UPRBROWSE = M("&Browse","&Browse"); string UPRDIM1 = M("Breite :","Width :"); string UPRDIM2 = M("Hoehe :","Height :"); string UPRHEIGHT = M("Texthoehe :","Text Height :"); string UPRCRADD = M("Radius :","Radius :"); string UPRPWIDTH = M("Stiftbreite :","Plot Width :"); string UPRDNLIB = M("&Library","&Library"); string UPRDPLACE = M("&Platzieren","&Place"); string UPRXCNT = M("X :","X :"); string UPRYCNT = M("Y :","Y :"); string UPRSCALE = M("Skalierung :","Scale :"); string UPRNOLAYER = M("Keine Lagenvorgabe","No Layer Default"); string UPRPREFLAYER = M("Vorzugslage","Edit Layer Default"); string UPRSELLAYER = M("Lage waehlen!","Select Layer!"); string UPRGRPOFF = M("Erste Kopieposition waehlen!", "Select First Copy Position!"); string UPRGRPMAT = M("Diagonalecke erstes Matrixrechteck waehlen!", "Select First Matrix Rectangle Diagonal Vertice!"); string UPRPTYPESEL = M("Keine Polygontypvorgabe", "No default polygon type"); string REPGRPNAME = M("%s / %s","%s / %s"); string REPLIBN = M("%s","%s"); string ERRGRAPHIC = M("Fehler bei der Grafikerzeugung!", "Error creating graphic!"); string ERRTILERAD = M("Gewaehlter Bedeckungsgrad mit diesem Radius nicht erreichbar!", "Choosen tile coverage cannot be achieved with given tile radius!"); string ERRRULER = M("Fehler beim Erzeugen des Lineals!", "Error creating ruler!"); string ERRMEASGLUED = M("Bemassung/Lineal ist verankert!", "Measurement/Ruler is glued!"); string ERRDBLDRAWDB = M("Zeichenassistent ist bereits aktiv!", "Draw Assistant already active!"); string ERRNOWIN = M("Nur in Windowsumgebungen verfuegbar!", "Windows Environment needed!"); string ERRINPDATA = M("Ungueltige Eingabedaten!", "Invalid input data!"); string ERRINPVAL = M_ERRINPVAL(); string ERRNOPICK = M_ERRNOPICK(); // General constants double PI = cvtangle(180,1,2) /* PI value */; double DPI = cvtangle(360.0,1,2) /* Double PI value */; // Distance measure declarations int COORDTMODE = bae_iniintval(PAR_COORDTMODE,0) /* Coordinate text fraction mode */; double DTEXTSIZE = bae_inidblval(PAR_DTEXTSIZE,0.002) /* Default text size [m] */; double DTMINSIZE = bae_inidblval(PAR_DTMINSIZE,0.001) /* Default text minimum size [m] */; string DINCHTEXT = bae_inistrval(PAR_DINCHTEXT,"\"") /* Inch units text */; string DMMTEXT = bae_inistrval(PAR_DMMTEXT,"mm") /* mm units text */; int DDECDIG = bae_iniintval(PAR_DDECDIG,3) /* Digits after decimal point */; int DAUTOSEL = bae_iniintval(PAR_DAUTOSEL,0) /* Dist. graphic auto. group sel. */; int DLONGLINE = bae_iniintval(PAR_DLONGLINE,1) /* Distance long line creation */; int DENDMODE = bae_iniintval(PAR_DENDMODE,0) /* Distance end marker mode */; double DENDARATIO = bae_inidblval(PAR_DENDARATIO,1.0) /* Distance end marker aspect ratio */; double DENDHSCALE = bae_inidblval(PAR_DENDHSCALE,1.0) /* Distance end marker height scale */; string textpref = bae_inistrval(PAR_DTEXTPREF,"") /* Distance measure text prefix */; string textsuf = bae_inistrval(PAR_DTEXTSUF,"") /* Distance measure text suffix */; // Area measure declarations string ATEXTSIZE = bae_inistrval(PAR_ATEXTSIZE,"2 mm") /* Text size string (mm) */; string AINCHTEXT = bae_inistrval(PAR_AINCHTEXT,"\"^2") /* Inch units text */; string AMMTEXT = bae_inistrval(PAR_AMMTEXT,"mm^2") /* mm units text */; int ADECDIG = bae_iniintval(PAR_ADECDIG,2) /* Digits after decimal point */; double area /* Area value */; // Angle measure declarations string WTEXTSIZE = bae_inistrval(PAR_WTEXTSIZE,"2 mm") /* Text size string (mm) */; string WDEGTEXT = bae_inistrval(PAR_WDEGTEXT,M(" Grad"," degrees")) /* Units text */; int WDECDIG = bae_iniintval(PAR_WDECDIG,2) /* Digits after decimal point */; double WARCRED = bae_inidblval(PAR_WARCRED,0.9) /* Arc radius reduction factor */; // Coordinate measure declarations string CTEXTSIZE = bae_inistrval(PAR_CTEXTSIZE,"2 mm") /* Text size string (mm) */; string CINCHTEXT = bae_inistrval(PAR_CINCHTEXT,"\"") /* Inch units text */; string CMMTEXT = bae_inistrval(PAR_CMMTEXT,"mm") /* mm units text */; int CDECDIG = bae_iniintval(PAR_CDECDIG,3) /* Digits after decimal point */; // Ruler declarations double RTEXTSIZE = bae_inidblval(PAR_RTEXTSIZE,1.0) /* Ruler documentation text size */; double RULESHORT = bae_inidblval(PAR_RULESHORT,2.5) /* Ruler short line length factor */; double RULEMIDDLE = bae_inidblval(PAR_RULEMIDDLE,3.0) /* Ruler middle line length factor */; double RULELONG = bae_inidblval(PAR_RULELONG,4.0) /* Ruler long line length factor */; double RULETEXT = bae_inidblval(PAR_RULETEXT,5.0) /* Ruler text offset factor */; // Arrow declarations #define GV_ARROWW "arrow_width" // Arrow width buffer variable double DARROWW = bae_inidblval(PAR_DARROWW,0.0005) /* Arrow default width */; double DARROWHL = bae_inidblval(PAR_DARROWHL,3.0) /* Arrow head relative length */; double DARROWHW = bae_inidblval(PAR_DARROWHW,2.0)-0.5 /* Arrow head relative width */; // Temporary polygon definitions string TMPGRPNAME = bae_inistrval(PAR_TMPGRPNAME,M("temporaer","temporary")) /* Temporary elements group name */; // Globals int DISPTEXT = bae_iniintval(PAR_DISPTEXT,1) /* Text display mode */; #define COLFIN 2 // Fade in color value double BUTXSTEP = bae_swconfig(3)==2 ? 1.0 : 0.0 /* Menu action button x spacing */; #define BUTWIDTH 9.0 // Button width #define PICLABWIDTH 28.0 // Group display width int PICLABHEIGHT = bae_inidblval(PAR_BRWHEIGHT,5.0) /* Group display height */; int LISTBHEIGHT = bae_inidblval(PAR_LSTHEIGHT,3.0) /* Group name listbox height */; #define GV_EDGEFIELD "da_edgeidx" // Polygon edge count field index #define GV_STEPFIELD "da_stepidx" // Ellipse step field index #define GV_DIM1FIELD "da_dim1idx" // 1st dimension field index #define GV_DIM2FIELD "da_dim2idx" // 2nd dimension field index #define GV_RADFIELD "da_radidx" // Radius field index #define GV_PWIDTHFIELD "da_pwidth" // Plot width field index #define GV_NAMEFIELD "da_nameidx" // Polygon net name field index #define GV_LAYFIELD "da_layeridx" // Layer field index #define GV_TYPFIELD "da_typidx" // Polygon type field index #define GV_TYPLAST "da_ltyp" // Polygon last type #define GV_SUBFIELD "da_subidx" // Polygon sub type field index #define GV_LOOPFIELD "da_loopidx" // Placement loop mode field index #define GV_TEXTFIELD "da_textidx" // Text string field index #define GV_TEXTHFIELD "da_texthidx" // Text height field index #define GV_TEXTCHFIELD "da_txtchidx" // Text hor. centered field index #define GV_TEXTCVFIELD "da_txtcvidx" // Text ver. centered field index #define GV_UNITFIELD "da_units" // Coordinate units field index #define GV_LAYNUM "da_layer" // Layer code #define GV_GRPFIELD "da_grpidx" // Group element name field index #define GV_GRPSFIELD "da_grpsidx" // Group scale field index #define GV_GRPXFIELD "da_grpxidx" // Group x count field index #define GV_GRPYFIELD "da_grpyidx" // Group y count field index #define GV_LABFIELD "da_labidx" // Group element label field index #define GV_BMLABFIELD "da_bmlabidx" // Group bitmap field index #define GV_LIBFNAME "da_libfname" // Group library file name #define GV_DDBCL "da_ddbcl" // DDB element code #define GV_TILEXCNT "tilemat_x" // Tile matrix X count variable #define GV_TILEYCNT "tilemat_y" // Tile matrix Y count variable #define GV_TILEPTYP "tilemat_pt" // Tile matrix polygon type variable #define GV_MEASLINE "meas_line" // Measurement line draw flag #define GV_MEASAL "meas_al" // Measurement arrow length #define GV_MEASAH "meas_ah" // Measurement arrow height #define GV_MEASNX "meas_nx" // Measurement X origin #define GV_MEASNY "meas_ny" // Measurement Y origin #define GV_MEASFN "meas_fn" // Measurement file name #define GV_MEASEN "meas_en" // Measurement element name #define GV_MEASCL "meas_cl" // Measurement element class double TILECOVER = bae_inidblval(PAR_TILECOVER,50.0) /* Tile coverage percentage */; double TILERAD = bae_inidblval(PAR_TILERAD,0.0) /* Tile radius */; int POLYDRAWORI = bae_iniintval(PAR_DRAWORI,0) /* Default poly. orientation */; int edges = bae_iniintval(PAR_DRAWEDGE,3) /* Polygon edges */; index L_FIGURE lastfig[] /* Last figure list elements */; int lastvalid = 0 /* Last element valid list count */; int curlayer /* Current polygon layer */; int autolaysel = 1 /* Auto. layer selection request */; int laydefmode = ged_getlaydefmode() /* Layer default mode */; string curlayermsg /* Current layer prompt message */; int curpolytype = (-1) /* Current polygon type */; int lastpolytype = (-1) /* Last polygon type */; int curspolytype = 0 /* Current sub polygon type */; int curdisttype = 0 /* Current dist. measure type */; int curmeasline = 0 /* Current measurement line mode */; double curmeasal = 0.0015 /* Current measurement arrow length */; double curmeasah = 0.001 /* Current measurement arrow height */; int curtmp = 0 /* Current temporary flag */; double curx1,cury1 /* Distance start coordinates */; double curx2,cury2 /* Distance end coordinates */; double curw /* Current arrow width */; double currad /* Current radius */; static int color /* Current color */; int ddbcl = bae_planddbclass() /* Current element class */; // Main program void main() { index L_POLY poly /* Polygon index */; string poly_dis = "," /* Polygon items disable */; // Abort if invalid plan class if (varget(VAR_PDBOXIDX,0) && ddbcl==DDBCLUNDEF) error_class(); // Check if element type scan if (bae_iniintval(PAR_METYPSCAN,1)==1 && !bae_peekiact()) { forall (poly where poly.TYP!=L_POLYDOCLINE) { poly_dis=""; break; } } else { // Enable all menu items poly_dis=""; } // Ask for drafting function type bae_defmenusel(-1); bae_promptdialog(UPRDRAW); switch (bae_askmenu(14,UPRDRAW1,UPRDRAW2,UPRDRAW3,UPRDRAW4, poly_dis+UPRDRAW5,UPRDRAW6,UPRDRAW7,UPRDRAW8,UPRDRAW9,UPRDRAW10, UPRDRAW11,UPRDRAW12,UPRDRAW13,UPRABORT)) { // Draw rectangles case 0 : drawrectangles(); break; // Draw circles case 1 : drawcircles(); break; // Draw arrows case 2 : drawarrows(); break; // Distance measure case 3 : distmeasure(); break; // Area measure case 4 : areameasure(); break; // Angle measure case 5 : anglemeasure(); break; // Generate ruler case 6 : ruler(); break; // Delete measurement/ruler case 7 : deletemeasure(); break; // Tile polygon case 8 : polytile(); break; // Draw assistant case 9 : drawassistant(); break; // X measurement case 10 : coordmeasurement(0); break; // Y measurement case 11 : coordmeasurement(1); break; // X/Y measurement case 12 : coordmeasurement(2); break; // Abort on default default : } } // Basic graphic generation routines void drawrectangles() /* // Draw rectangles on selectable layer by selecting corner points */ { int cflag = 0 /* Change flag */; // Get the polygon type and layer curlayermsg=UPRRLAY; askpolydata(); // Repetively generate rectangles curx1=bae_planwsnx(); cury1=bae_planwsny(); while ((bae_promptdialog(UPRRCORNER1), bae_inpointmenu(curx1,cury1,curx1,cury1,0,polydatafunc)==0) && (bae_promptdialog(UPRRCORNER2), bae_inpoint(curx1,cury1,curx2,cury2,1)==0)) { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Create the polygon drawrect(curx1,cury1,curx2,cury2,0.0); if (ged_storepoly(curlayer,curpolytype,"",0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { if (curtmp) rs_assfigstrpred(lastfig[lastvalid], RS_GROUPNAME,TMPGRPNAME,"",""); // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); lastvalid++; } curx1=bae_planwsnx(); cury1=bae_planwsny(); } } void drawcircles() /* // Draw circles on selectable layer by center point and radius */ { int cflag = 0 /* Change flag */; // Get the polygon type and layer curlayermsg=UPRCLAY; askpolydata(); // Repetively generate circles curx1=bae_planwsnx(); cury1=bae_planwsny(); while ((bae_promptdialog(UPRCCENTER), bae_inpointmenu(curx1,cury1,curx1,cury1,0,polydatafunc)==0) && (bae_promptdialog(UPRCRADIUS), bae_inpoint(curx1,cury1,curx2,cury2,3)==0)) { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Create the polygon drawcircle(curx1,cury1,dist(curx1,cury1,curx2,cury2)); if (ged_storepoly(curlayer,curpolytype,"",0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); lastvalid++; } curx1=bae_planwsnx(); cury1=bae_planwsny(); } } void drawarrows() /* // Draw arrows on selectable layer by selecting start and end points */ { double nx,ny /* Arrow top base coordinates */; double angle /* Arrow angle */; int hfactx,hfacty /* Horizontal factors */; int cflag = 0 /* Change flag */; // Get the arrow width, type and layer curlayermsg=UPRALAY; askarrowdata(); // Repetively generate arrows curx1=bae_planwsnx(); cury1=bae_planwsny(); while ((bae_promptdialog(UPRAPOS1), bae_inpointmenu(curx1,cury1,curx1,cury1,0,arrowdatafunc)==0) && (bae_promptdialog(UPRAPOS2), bae_inpoint(curx1,cury1,curx2,cury2,2)==0)) { // Calculate the arrow angle angle=angle(curx1,cury1,curx2,cury2); // Set the horizontal and vertical factors if (angle<0.125*PI || (angle>0.875*PI && angle<1.125*PI) || angle>1.875*PI) { hfactx=0.0; hfacty=1.0; } else { hfactx=1.0; hfacty=0.0; } // Calculate the arrow top base coordinate nx=curx2-DARROWHL*curw*cos(angle); ny=cury2-DARROWHL*curw*sin(angle); // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Create the arrow polygon bae_clearpoints(); if (bae_storepoint( curx1-hfactx*curw*0.5,cury1+hfacty*curw*0.5,0) || bae_storepoint( curx1+hfactx*curw*0.5,cury1-hfacty*curw*0.5,0) || bae_storepoint(nx+hfactx*curw*0.5,ny-hfacty*curw*0.5,0) || bae_storepoint( nx+hfactx*DARROWHW*curw,ny-hfacty*DARROWHW*curw,0) || bae_storepoint(curx2,cury2,0) || bae_storepoint( nx-hfactx*DARROWHW*curw,ny+hfacty*DARROWHW*curw,0) || bae_storepoint(nx-hfactx*curw*0.5,ny+hfacty*curw*0.5,0) || curpolytype==L_POLYDOCLINE && bae_storepoint( curx1-hfactx*curw*0.5,cury1+hfacty*curw*0.5,0) || ged_storepoly(curlayer,curpolytype,"",0)) // Error creating polygon error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); lastvalid++; } curx1=bae_planwsnx(); cury1=bae_planwsny(); } } void askpolydata() /* // Ask user for polygon type and layer */ { // Evaluate the layer default mode switch (laydefmode) { // Pick layer case 1 : curlayer=ged_getpickpreflay(); break; // Last used layer case 2 : curlayer=ged_getlayerdefault(); break; case 0 : default : // Select polygon layer curlayer=ged_getpickpreflay(); autolaysel=0; } // Pre-check the layer if (!((curlayer>=0 && curlayer=DOCLAYBASE || curlayer==LAYERALL || curlayer==LAYERBTW || curlayer==LAYERTOP)) { curlayer=ged_getpickpreflay(); autolaysel=2; } // Get and check the polygon mode bae_promptdialog(UPRPOLYMODE); switch (bae_askmenu(5, UPRFILLAREA,UPRKOUTAREA,UPRLINEAREA,UPRKOUTTAREA,UPRABORT)) { // Filled rectangle case 0 : // Check if layer selection if (autolaysel!=1) if (bae_promptdialog(curlayermsg), ged_asklayer(curlayer,0)) error_abort(); curpolytype= curlayer>=DOCLAYBASE ? L_POLYDOCAREA : L_POLYCOPPASS; break; // Keepout rectangle case 1 : // Check if layer selection if (autolaysel!=1) if (bae_promptdialog(curlayermsg), ged_asklayer(curlayer,0)) error_abort(); curpolytype=L_POLYKEEPOUT; break; // Outline rectangle case 2 : if (curlayer=POWLAYBASE) curspolytype=0; // Make layer visible layerfadein(curlayer,COLFIN,1); return; } // Ask for polygon type bae_promptdialog(UPRPOLYTYPE); // Check if layer known if (curlayer!=LAYERINV) { switch (bae_askmenu(9, (polylaycheck(curlayer,L_POLYCOPPASS)==0 ? "" : ",")+ polytypename(L_POLYCOPPASS), (polylaycheck(curlayer,L_POLYKEEPOUT)==0 ? "" : ",")+ polytypename(L_POLYKEEPOUT), (polylaycheck(curlayer,L_POLYBRDOUT)==0 ? "" : ",")+ polytypename(L_POLYBRDOUT), (polylaycheck(curlayer,L_POLYCOPACT)==0 ? "" : ",")+ polytypename(L_POLYCOPACT), (polylaycheck(curlayer,L_POLYDOCLINE)==0 ? "" : ",")+ polytypename(L_POLYDOCLINE), (polylaycheck(curlayer,L_POLYDOCAREA)==0 ? "" : ",")+ polytypename(L_POLYDOCAREA), (polylaycheck(curlayer,L_POLYCOPFILL)==0 ? "" : ",")+ polytypename(L_POLYCOPFILL), (polylaycheck(curlayer,L_POLYSPPAREA)==0 ? "" : ",")+ polytypename(L_POLYSPPAREA),UPRABORT)) { // Passive Copper case 0 : curpolytype=L_POLYCOPPASS; break; // Keep Out Area case 1 : curpolytype=L_POLYKEEPOUT; break; // Board Outline case 2 : curpolytype=L_POLYBRDOUT; curlayer=LAYERBRD; break; // Active Copper case 3 : curpolytype=L_POLYCOPACT; break; // Documentary Line case 4 : curpolytype=L_POLYDOCLINE; break; // Documentary Area case 5 : curpolytype=L_POLYDOCAREA; break; // Copper Fill Area case 6 : curpolytype=L_POLYCOPFILL; break; // Split Power Plae Area case 7 : curpolytype=L_POLYSPPAREA; break; default : error_abort(); } } else { switch (bae_askmenu(9, (polytypecheck(L_POLYCOPPASS)==0 ? "" : ",")+ polytypename(L_POLYCOPPASS), (polytypecheck(L_POLYKEEPOUT)==0 ? "" : ",")+ polytypename(L_POLYKEEPOUT), (polytypecheck(L_POLYBRDOUT)==0 ? "" : ",")+ polytypename(L_POLYBRDOUT), (polytypecheck(L_POLYCOPACT)==0 ? "" : ",")+ polytypename(L_POLYCOPACT), (polytypecheck(L_POLYDOCLINE)==0 ? "" : ",")+ polytypename(L_POLYDOCLINE), (polytypecheck(L_POLYDOCAREA)==0 ? "" : ",")+ polytypename(L_POLYDOCAREA), (polytypecheck(L_POLYCOPFILL)==0 ? "" : ",")+ polytypename(L_POLYCOPFILL), (polytypecheck(L_POLYSPPAREA)==0 ? "" : ",")+ polytypename(L_POLYSPPAREA),UPRABORT)) { // Passive Copper case 0 : curpolytype=L_POLYCOPPASS; break; // Keep Out Area case 1 : curpolytype=L_POLYKEEPOUT; break; // Board Outline case 2 : curpolytype=L_POLYBRDOUT; curlayer=LAYERBRD; break; // Active Copper case 3 : curpolytype=L_POLYCOPACT; break; // Documentary Line case 4 : curpolytype=L_POLYDOCLINE; break; // Documentary Area case 5 : curpolytype=L_POLYDOCAREA; break; // Copper Fill Area case 6 : curpolytype=L_POLYCOPFILL; break; // Split Power Plae Area case 7 : curpolytype=L_POLYSPPAREA; break; default : error_abort(); } if (bae_promptdialog(UPRSELLAYER), ged_asklayer(curlayer,polylaytype(curpolytype))) error_abort(); } if (curpolytype==L_POLYKEEPOUT && curlayer>=POWLAYBASE) curspolytype=0; // Make layer visible layerfadein(curlayer,COLFIN,1); } void askarrowdata() /* // Ask user for polygon type and layer */ { // Evaluate the layer default mode switch (laydefmode) { // Pick layer case 1 : curlayer=ged_getpickpreflay(); break; // Last used layer case 2 : curlayer=ged_getlayerdefault(); break; case 0 : default : // Select polygon layer curlayer=ged_getpickpreflay(); autolaysel=0; } // Pre-check the layer if (!((curlayer>=0 && curlayer=DOCLAYBASE || curlayer==LAYERALL || curlayer==LAYERBTW || curlayer==LAYERTOP)) { curlayer=ged_getpickpreflay(); autolaysel=2; } // Get and check the arrow mode bae_promptdialog(UPRFILLMODE); switch (bae_askmenu(3,UPRFILLON,UPRFILLOFF,UPRABORT)) { // Filled arrow case 0 : // Check if layer selection if (autolaysel!=1) if (bae_promptdialog(curlayermsg), ged_asklayer(curlayer,0)) error_abort(); curpolytype= curlayer>=DOCLAYBASE ? L_POLYDOCAREA : L_POLYCOPPASS; break; // Outline arrow case 1 : if (curlayer=DOCLAYBASE) ? "" : ",")+ UPRLINEAREA,(lastvalid ? "" : ",")+UPRUNDO,UPRABORT)) { // Done case 0 : return(-1); // Continue case 1 : break; // Jump. relative case 2 : x=curx1; y=cury1; if (askcoord(x,y,0)) error_abort(); return(0); // Jump. absolute case 3 : x=bae_planwsnx(); y=bae_planwsny(); if (askcoord(x,y,1)) error_abort(); return(0); // Change layer case 4 : bae_promptdialog(curlayermsg); if (ged_asklayer(curlayer,curpolytype==L_POLYDOCLINE ? 3 : 0)) error_abort(); // Check if implicit polygon type change if (curlayer>=DOCLAYBASE) { if (curpolytype==L_POLYCOPPASS) curpolytype=L_POLYDOCAREA; } else { if (curpolytype==L_POLYDOCAREA) curpolytype=L_POLYCOPPASS; } // Set new default layer ged_setlayerdefault(curlayer); // Make layer visible layerfadein(curlayer,COLFIN,1); break; // Filled area case 5 : curpolytype= curlayer>=DOCLAYBASE ? L_POLYDOCAREA : L_POLYCOPPASS; curtmp=0; break; // Keepout area case 6 : curpolytype=L_POLYKEEPOUT; break; // Outline area case 7 : if (curlayer=DOCLAYBASE) ? "" : "," ; // Evaluate the selection switch (bae_askmenu(10,UPRDONE,UPRCONT,UPRJUMPREL,UPRJUMPABS,UPRSELLAY, UPRWIDTH,f_dis+UPRFILLON,f_dis+UPRFILLOFF, (lastvalid ? "" : ",")+UPRUNDO,UPRABORT)) { // Done case 0 : return(-1); // Continue case 1 : break; // Jump. relative case 2 : x=curx1; y=cury1; if (askcoord(x,y,0)) error_abort(); return(0); // Jump. absolute case 3 : x=bae_planwsnx(); y=bae_planwsny(); if (askcoord(x,y,1)) error_abort(); return(0); // Change layer case 4 : bae_promptdialog(curlayermsg); if (ged_asklayer(curlayer,curpolytype==L_POLYDOCLINE ? 3 : 0)) error_abort(); // Check if implicit polygon type change if (curlayer>=DOCLAYBASE) { if (curpolytype==L_POLYCOPPASS) curpolytype=L_POLYDOCAREA; } else { if (curpolytype==L_POLYDOCAREA) curpolytype=L_POLYCOPPASS; } // Set new default layer ged_setlayerdefault(curlayer); // Make layer visible layerfadein(curlayer,COLFIN,1); break; // Arrow width case 5 : if (askdist(curw, lay_defusrunit()?UPRARRWI:UPRARRWM,0) || curw<=0.0) // Invalid input value error_abort(); // Preserve arrow width for next call varset(GV_ARROWW,curw); break; // Filled arrow case 6 : curpolytype= curlayer>=DOCLAYBASE ? L_POLYDOCAREA : L_POLYCOPPASS; break; // Outline arrow case 7 : if (curlayer=DOCLAYBASE) { if (curpolytype==L_POLYCOPPASS) curpolytype=L_POLYDOCAREA; } else { if (curpolytype==L_POLYDOCAREA) curpolytype=L_POLYCOPPASS; } // Set new default layer ged_setlayerdefault(curlayer); // Make layer visible layerfadein(curlayer,COLFIN,1); break; // Abort case 5 : default : return(-1); } // Continue return(1); } int distdatafunc(double x,double y) /* // RMB distance type and layer callback function // Return value : // 1 to continue, 0 to set coordinates or (-1) on error // Parameters : // double x, y : Mouse coordinates */ { string newtext /* New text string */; double textsize /* Text size */; // Set current distance type menu item bae_defmenusel(7+curdisttype); switch (bae_askmenu(14,UPRDONE,UPRCONT,UPRJUMPREL,UPRJUMPABS,UPRNOJUMP, UPRSELLAY,UPRTHEIGHT,UPRDIAG,UPRHORI,UPRVERT,UPRBOTH,UPRPREFIX, UPRSUFFIX,UPRABORT)) { // Done case 0 : return(0); // Continue case 1 : break; // Jump. relative case 2 : x=curx1; y=cury1; if (askcoord(x,y,0)) return(-1); return(0); // Jump. absolute case 3 : x=curx1; y=cury1; if (askcoord(x,y,1)) return(-1); return(0); // Jump. to start position case 4 : x=curx1; y=cury1; return(0); // Change layer case 5 : bae_promptdialog(curlayermsg); if (ged_asklayer(curlayer,3)) return(-1); // Set new default layer ged_setlayerdefault(curlayer); // Make layer visible layerfadein(curlayer,COLFIN,1); // Delete old marker line if (lastvalid) ged_delelem(lastfig[0]); bae_clearpoints(); bae_storepoint(curx1,cury1,0); bae_storepoint(curx2,cury2,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)==0 && lay_lastfigelem(lastfig[0])==0) lastvalid=1; else lastvalid=0; break; // Text height case 6 : // Get the text size textsize=DTEXTSIZE; if (askdist(textsize,lay_defusrunit()?UPRTSIZEI:UPRTSIZEM,0) || textsize==0.0) break; DTEXTSIZE=textsize; varset(PAR_DTEXTSIZE,DTEXTSIZE); break; // Full distance case 7 : curdisttype=0; break; // Horizontal distance case 8 : curdisttype=1; break; // Vertical distance case 9 : curdisttype=2; break; // H+V distance seperately case 10 : curdisttype=3; break; // Text prefix case 11 : if ((newtext= bae_readedittext(UPRDTEXTP,textpref,MAXTEXTLEN))!=UINPOPABORT) textpref=newtext; break; // Text suffix case 12 : if ((newtext= bae_readedittext(UPRDTEXTS,textsuf,MAXTEXTLEN))!=UINPOPABORT) textsuf=newtext; break; // Abort case 13 : default : return(-1); } if (curdisttype==0) { bae_prtdialog(UPRDPOS3); } else if (curdisttype==2) { // Snap rubberband to horizontal selection bae_setdblpar(4,0.001); bae_setdblpar(5,0.0); bae_prtdialog(UPRDPOS3V); } else { // Snap rubberband to vertical direction bae_setdblpar(4,0.0); bae_setdblpar(5,0.001); bae_prtdialog(UPRDPOS3H); } // Continue return(1); } // Distance measure routines void distmeasure() /* // Distance measure function // Creates point-to-point distance marker on selectable doc layer // Units are determined by the current coordinate display mode // Text size is automatically scaled down if default size // does not fit to 3/4 of the distance markers */ { double xp,yp /* Distance placement coordinates */; double xnp,ynp /* Dist. placement trans. coords. */; double ysp /* Dist. placement shifted coord */; double xn2,yn2 /* 2nd position shifted coords. */; double ang /* Angle */; double sina, cosa /* Angle trigon. values */; string id /* Distance marker ID */; int infodisp /* Information display mode */; // Get the layer curlayermsg=UPRMEASLAY; asklayerdata(); // Select distance start coordinates curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRDPOS1); if (bae_inpointmenu(curx1,cury1,curx1,cury1,0,laydatafunc)) error_abort(); if (ged_getintpar(3,infodisp)) infodisp=0; // Select distance end coordinates bae_promptdialog(UPRDPOS2); if (bae_inpoint(curx1,cury1,curx2,cury2,infodisp ? 4 : 2)) error_abort(); if (curx1==curx2 && cury1==cury2) error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); bae_clearpoints(); bae_storepoint(curx1,cury1,0); bae_storepoint(curx2,cury2,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)==0 && lay_lastfigelem(lastfig[0])==0) lastvalid=1; // Snap rubberband to orthogonal direction angle selection bae_setdblpar(4,cury2-cury1); bae_setdblpar(5,curx1-curx2); // Select distance documentation coordinates bae_promptdialog(UPRDPOS3); if (bae_inpointmenu(curx1,cury1,xp,yp,12,distdatafunc)) { // Delete any marker line if (lastvalid) ged_delelem(lastfig[0]); error_abort(); } // Get new distance marker id id=createid(); switch (curdisttype) { // Full distance case 0 : // Use start point as coordinate origin xn2=curx2-curx1; yn2=cury2-cury1; xnp=xp-curx1; ynp=yp-cury1; ang=atan2(yn2,xn2); sina=sin(ang); cosa=cos(ang); ysp=(-sina*xnp)+cosa*ynp; xp=curx1-sina*ysp; yp=cury1+cosa*ysp; distmeasuredraw(xp,yp,xp+curx2-curx1,yp+cury2-cury1, curx1,cury1,curx2,cury2,id); break; // Horizontal distance case 1 : distmeasuredraw(curx1,yp,curx2,yp,curx1,cury1,curx2,cury2,id); break; // Vertical distance case 2 : distmeasuredraw(xp,cury1,xp,cury2,curx1,cury1,curx2,cury2,id); break; // Horizontal & vertical distance seperately case 3 : distmeasuredraw(curx1,yp,curx2,yp,curx1,cury1,curx2,cury2,id); // Snap rubberband to horizontal selection bae_setdblpar(4,0.001); bae_setdblpar(5,0.0); bae_promptdialog(UPRDPOS3V); if (bae_inpoint(curx1,cury1,xp,yp,12)) { // Delete any marker line if (lastvalid) ged_delelem(lastfig[0]); error_abort(); } distmeasuredraw(xp,cury1,xp,cury2,curx1,cury1,curx2,cury2,id); break; } // Delete any marker line if (lastvalid) ged_delelem(lastfig[0]); // Done bae_prtdialog(""); } void distmeasuredraw(double x1,double y1,double x2,double y2, double xo1,double yo1,double xo2,double yo2,string id) /* // Draw the distance measure marker between two points // Parameters : // double x1,y1 : Distance start coordinates // double x2,y2 : Distance end coordinates // double xo1,yo1 : Distance origin start coordinates // double xo2,yo2 : Distance origin end coordinates // string id : Distance marker ID */ { index L_FIGURE nfig /* New figure list index */; double xstep,ystep /* Distance step values */; double xnstep,ynstep /* Distance step normal values */; double length /* Distance */; double ang /* Distance angle */; string unitstr /* Distance unit doc. string */; string dstr /* Distance text string */; int dschr /* Distance string char. count */; int septext = 0 /* Distance text sep. placement */; double dsoff /* Distance string offset */; double tsize /* Text size */; double msize /* Marker size */; double asize /* Arrow size */; if (x1==x2 && y1==y2) return; // Get coordinate deltas xstep=x2-x1; ystep=y2-y1; // Calculate distance length=sqrt(xstep*xstep+ystep*ystep); // Adjust distance steps xstep/=length; ystep/=length; // Get distance normals xnstep=ystep; ynstep=(-xstep); // Calculate distance angle ang=atan2(ystep,xstep); // Get distance string unitstr=bae_getcoorddisp() ? DINCHTEXT : DMMTEXT; dstr= DDECDIG<0 ? bae_numstring(baecvtl(length),-DDECDIG) : ftoa(baecvtl(length),DDECDIG); if (COORDTMODE) replacedot(dstr); if (unitstr!="") dstr+=" "+unitstr; if (textpref!="") { if (textpref[strlen(textpref)-1]!=' ') textpref+=" "; dstr=textpref+dstr; } if (textsuf!="") { if (textsuf[0]!=' ') dstr+=" "; dstr+=textsuf; } // Get distance string character count dschr=strlen(dstr); // Check if text shorter than three quarters of distance length if (dschr*0.66*DTEXTSIZE<=length*0.75) tsize=DTEXTSIZE; else tsize=length*0.75*1.5/dschr; // Check if smaller than minimum size if (tsize0.0) { bae_storepoint(x1+xnstep*msize/2,y1+ynstep*msize/2,0); bae_storepoint(xo1,yo1,0); } else { bae_storepoint(xo1,yo1,0); bae_storepoint(x1-xnstep*msize/2,y1-ynstep*msize/2,0); } } else { bae_storepoint(x1+xnstep*msize/2,y1+ynstep*msize/2,0); bae_storepoint(x1-xnstep*msize/2,y1-ynstep*msize/2,0); } if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRGRAPHIC); if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); // Create first distance marker arrow if ((DENDMODE&0x03)!=0) { bae_clearpoints(); if (septext) { bae_storepoint(x1+(xnstep-DENDARATIO*xstep)*asize/2, y1+(ynstep-DENDARATIO*ystep)*asize/2,0); bae_storepoint(x1,y1,0); bae_storepoint(x1-(xnstep+DENDARATIO*xstep)*asize/2, y1-(ynstep+DENDARATIO*ystep)*asize/2,0); } else { bae_storepoint(x1+(xnstep+DENDARATIO*xstep)*asize/2, y1+(ynstep+DENDARATIO*ystep)*asize/2,0); bae_storepoint(x1,y1,0); bae_storepoint(x1-(xnstep-DENDARATIO*xstep)*asize/2, y1-(ynstep-DENDARATIO*ystep)*asize/2,0); } if (ged_storepoly(curlayer, (DENDMODE&0x03)==1 ? L_POLYDOCLINE : L_POLYDOCAREA,"",0)) error(ERRGRAPHIC); if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); } // Create first distance marker line bae_clearpoints(); bae_storepoint(x1,y1,0); if (!septext) { bae_storepoint(x1+xstep*dsoff,y1+ystep*dsoff,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRGRAPHIC); if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); // Create second distance marker line bae_clearpoints(); bae_storepoint(x2-xstep*dsoff,y2-ystep*dsoff,0); } bae_storepoint(x2,y2,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRGRAPHIC); if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); // Create second distance marker side bae_clearpoints(); if (DLONGLINE) { if ((xnstep*(x2-xo2)+ynstep*(y2-yo2))>0.0) { bae_storepoint(x2+xnstep*msize/2,y2+ynstep*msize/2,0); bae_storepoint(xo2,yo2,0); } else { bae_storepoint(xo2,yo2,0); bae_storepoint(x2-xnstep*msize/2,y2-ynstep*msize/2,0); } } else { bae_storepoint(x2+xnstep*msize/2,y2+ynstep*msize/2,0); bae_storepoint(x2-xnstep*msize/2,y2-ynstep*msize/2,0); } if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRGRAPHIC); if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); // Create second distance marker arrow if ((DENDMODE&0x03)!=0) { bae_clearpoints(); if (septext) { bae_storepoint(x2+(xnstep+DENDARATIO*xstep)*asize/2, y2+(ynstep+DENDARATIO*ystep)*asize/2,0); bae_storepoint(x2,y2,0); bae_storepoint(x2-(xnstep-DENDARATIO*xstep)*asize/2, y2-(ynstep-DENDARATIO*ystep)*asize/2,0); } else { bae_storepoint(x2+(xnstep-DENDARATIO*xstep)*asize/2, y2+(ynstep-DENDARATIO*ystep)*asize/2,0); bae_storepoint(x2,y2,0); bae_storepoint(x2-(xnstep+DENDARATIO*xstep)*asize/2, y2-(ynstep+DENDARATIO*ystep)*asize/2,0); } if (ged_storepoly(curlayer, (DENDMODE&0x03)==1 ? L_POLYDOCLINE : L_POLYDOCAREA,"",0)) error(ERRGRAPHIC); if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); } if (septext) { if (autolaysel==2) ged_setlaydefmode(0); bae_clriactqueue(); if (autolaysel!=1) // Layer selection laysel(7,curlayer); bae_storetextiact(1,dstr); /* Set text size */ bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); sprintf(unitstr,"%.5f mm",cvtlength(tsize,0,2)); bae_storetextiact(1,unitstr); /* Set text angle */ bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,6,LMB); sprintf(unitstr,"%.5f",cvtangle(ang,0,1)); bae_storetextiact(1,unitstr); /* Set text centered */ bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,12,LMB); bae_callmenu(MNU_GEDADDTEXT); if (autolaysel==2) ged_setlaydefmode(laydefmode); } else { // Create the distance documentary text if (ged_storetext(dstr,x1+xstep*length/2, y1+ystep*length/2,ang,tsize,curlayer,TEXTHCENT|TEXTVCENT)) error(ERRGRAPHIC); } if (DAUTOSEL && lay_lastfigelem(nfig)==0) ged_elemgrpchg(nfig,1); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); } // Area measure routines void areameasure() /* // Area measure function // Creates area size text on doc layer for selectable polygons // Units are determined by the current coordinate display mode */ { index L_FIGURE fig /* Figure list index */; string astr /* Area text string */; int cnt = 0 /* Element count */; // Get the layer curlayermsg=UPRMEASLAY; asklayerdata(); // Select polygon bae_prtdialog(UPRMAREA); while (ged_pickelem(fig,L_FIGPOLY)==0) { // Initalize area area=0.0; // Scan polygon if (lay_scanfelem(fig,0.0,0.0,0.0,1,0, NULL,areapolyfunc,NULL,NULL,NULL,NULL,NULL)!=0) error_scan(); // Convert area to output units area*=baecvtl(1.0); area*=baecvtl(1.0); astr= ADECDIG<0 ? bae_numstring(area,-ADECDIG) : ftoa(area,ADECDIG) ; if (COORDTMODE) replacedot(astr); astr+=" "+(bae_getcoorddisp() ? AINCHTEXT : AMMTEXT); if (autolaysel==2) ged_setlaydefmode(0); // Perform an add text call bae_clriactqueue(); if (autolaysel!=1) // Layer selection laysel(7,curlayer); // Area text bae_storetextiact(1,astr); // Text size bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); bae_storetextiact(1,ATEXTSIZE); // Call text creation menu call(MNU_GEDADDTEXT); if (autolaysel==2) ged_setlaydefmode(laydefmode); cnt++; } // No pick element found if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } int areapolyfunc(index L_POLY poly,int layer, int polyinws,int tree,index L_LEVEL level) /* // Polygon scan function // Return value : // zero if done or (-1) on error // Parameters : // index L_POLY poly : Polygon index // int layer : Polygon layer // int polyinws : Polygon in workspace flag // int tree : Polygon tree // index L_LEVEL level : Polygon level */ { index L_POINT point /* Point index */; struct ppoint { // Polygon point structure double x,y /* Polygon coordinates */; int typ /* Polygon type */; } pplist[] /* Polygon point list */; int pcnt = 0 /* Polygon point count */; double xs,ys /* Arc/triangle start coordinates */; double xm,ym /* Arc/triangle middle coords. */; double xe,ye /* Arc/triangle end coordinates */; double ang /* Arc/triangle angle */; double r /* Arc radius */; double la,lb,lc /* Triangle side lenghtes radius */; double s /* Triangle area calc. variable */; int i /* Loop control variable */; // Check if documentary line if (poly.TYP==L_POLYDOCLINE) // Zero area for line return(0); // Store all polygon points to point list forall (point of poly) { pplist[pcnt].x=point.X; pplist[pcnt].y=point.Y; pplist[pcnt].typ=point.TYP; // Increment point count pcnt++; } // Arc elemination loop for (i=0;i=0.0 ? sqrt(s) : 0.0; // Get area relativ angle ang=fmod(atan2(ys-ym,xs-xm)-atan2(ye-ym,xe-xm)+DPI,DPI); // Check if concave triangle if (ang>DPI/2.0) // Subtract triangle area area-=s; else // Add triangle area area+=s; } // Return without errors return(0); } // Angle measure routines void anglemeasure() /* // Angle measure function // Creates three-point angle marker on selectable doc layer // Text size is automatically scaled down if default size // does not fit to 3/4 of the angle markers */ { index L_FIGURE nfig /* New figure list index */; double xv,yv /* Angle vertex coordinates */; double xa1,ya1 /* Arrow marker start coordinates */; double xa2,ya2 /* Arrow marker end coordinates */; double x1step,y1step /* Angle first side step values */; double ang1 /* First side angle */; double length1 /* First side length */; double x2step,y2step /* Angle second side step values */; double xastep,yastep /* Arrow side step values */; double ang2 /* Second side angle */; double length2 /* Second side length */; double length /* Smaller side length */; double ang /* Angle */; double tsize /* Text size */; double thsize /* Text half size */; string astr /* Angle text string */; string id /* Distance marker ID */; // Get the layer curlayermsg=UPRMEASLAY; asklayerdata(); // Select first side point coordinates curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRANGPOS1); if (bae_inpointmenu(curx1,cury1,curx1,cury1,0,laydatafunc)) error_abort(); // Select angle vertex coordinates bae_promptdialog(UPRANGPOSV); if (bae_inpoint(curx1,cury1,xv,yv,2)) error_abort(); if (curx1==xv && cury1==yv) error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Get new marker id id=createid(); // Create first angle side marker line bae_clearpoints(); bae_storepoint(curx1,cury1,0); bae_storepoint(xv,yv,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0) || lay_lastfigelem(nfig)!=0) error(ERRGRAPHIC); if (lay_lastfigelem(nfig)==0) { rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); lay_lastfigelem(nfig); } // Select second side point coordinates bae_promptdialog(UPRANGPOS2); if (bae_inpoint(xv,yv,curx2,cury2,2) || (curx2==xv && cury2==yv) || (curx1==curx2 && cury1==cury2)) { ged_delelem(nfig); error_abort(); } // Create second angle side marker line bae_clearpoints(); bae_storepoint(curx2,cury2,0); bae_storepoint(xv,yv,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRGRAPHIC); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); // Get coordinate deltas x1step=curx1-xv; y1step=cury1-yv; x2step=curx2-xv; y2step=cury2-yv; // Calculate distances length1=sqrt(x1step*x1step+y1step*y1step); length2=sqrt(x2step*x2step+y2step*y2step); length=WARCRED*(length1=DPI) ang-=DPI; // Get angle string astr= WDECDIG<0 ? bae_numstring(cvtangle(ang,0,1),-WDECDIG) : ftoa(cvtangle(ang,0,1),WDECDIG) ; if (COORDTMODE) replacedot(astr); astr+=WDEGTEXT; // Create first angle marker arrow if ((DENDMODE&0x03)!=0) { bae_storetextiact(3,WTEXTSIZE); askdist(tsize,"",0); tsize*=DENDHSCALE; thsize=0.5*tsize; xastep=DENDARATIO*x1step; yastep=DENDARATIO*y1step; bae_clearpoints(); if (dist(curx1,cury1,curx2,cury2)=DOCLAYBASE) { if (curpolytype==L_POLYCOPPASS) curpolytype=L_POLYDOCAREA; } else { if (curpolytype==L_POLYDOCAREA) curpolytype=L_POLYCOPPASS; } // Set new default layer ged_setlayerdefault(curlayer); // Make layer visible layerfadein(curlayer,COLFIN,1); break; // No measurement line case 5 : curmeasline=0; break; // Measurement line case 6 : curmeasline=1; break; // Arrow length case 7 : dim=curmeasal; if (askdist(dim, lay_defusrunit()?UPRARRLI:UPRARRLM,0) || dim<0.0) break; // Preserve arrow length for next call curmeasal=dim; break; // Arrow height case 8 : dim=curmeasah; if (askdist(dim, lay_defusrunit()?UPRARRHI:UPRARRHM,0) || dim<0.0) break; // Preserve arrow height for next call curmeasah=dim; break; // Set origin case 9 : bae_promptdialog(UPRDPOSN); if (bae_inpoint(bae_planwsnx(),bae_planwsny(),curx1,cury1,0)) error_abort(); break; // Abort default : return(-1); } // Continue return(1); } int measxydatafunc(double x,double y) /* // RMB X/Y measurement callback function // Return value : // 1 to continue, 0 to set coordinates or (-1) on error // Parameters : // double x, y : Mouse coordinates */ { // Evaluate the selection switch (bae_askmenu(9,UPRDONE,UPRCONT,UPRJUMPREL,UPRJUMPABS, UPRSELLAY,UPRSELNLINE,UPRSELLINE,UPRSELORIG,UPRABORT)) { // Done case 0 : return(0); // Continue case 1 : break; // Jump. relative case 2 : x=curx1; y=cury1; if (askcoord(x,y,0)) error_abort(); return(0); // Jump. absolute case 3 : x=bae_planwsnx(); y=bae_planwsny(); if (askcoord(x,y,1)) error_abort(); return(0); // Change layer case 4 : bae_promptdialog(curlayermsg); if (ged_asklayer(curlayer,3)) error_abort(); if (curlayer>=DOCLAYBASE) { if (curpolytype==L_POLYCOPPASS) curpolytype=L_POLYDOCAREA; } else { if (curpolytype==L_POLYDOCAREA) curpolytype=L_POLYCOPPASS; } // Set new default layer ged_setlayerdefault(curlayer); // Make layer visible layerfadein(curlayer,COLFIN,1); break; // No measurement line case 5 : curmeasline=0; break; // Measurement line case 6 : curmeasline=1; break; // Set origin case 7 : bae_promptdialog(UPRDPOSN); if (bae_inpoint(bae_planwsnx(),bae_planwsny(),curx1,cury1,0)) error_abort(); break; // Abort default : return(-1); } // Continue return(1); } // Ruler generation routines void ruler() /* // Automatic ruler generation on documentary layer // Units are determined by the current coordinate display mode */ { index L_FIGURE nfig /* New figure list index */; double xstep,ystep /* Ruler step values */; double xnstep,ynstep /* Ruler step normal values */; int stepcnt /* Ruler step count */; double length /* Ruler length */; double curllength /* Current ruler line length */; double ang /* Ruler angle */; string nstr /* Ruler number string */; double cvtfac /* Unit conversion factor */; string id /* Distance marker ID */; int infodisp /* Information display mode */; int i /* Loop control variable */; // Get the layer curlayermsg=UPRRULLAY; asklayerdata(); // Select ruler start coordinates curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRRPOS1); if (bae_inpointmenu(curx1,cury1,curx1,cury1,0,laydatafunc)) error_abort(); if (ged_getintpar(3,infodisp)) infodisp=0; // Select ruler end coordinates bae_promptdialog(UPRRPOS2); if (bae_inpoint(curx1,cury1,curx2,cury2,infodisp ? 4 : 2)) error_abort(); if (curx1==curx2 && cury1==cury2) error(ERRINPDATA); // Get coordinate deltas xstep=curx2-curx1; ystep=cury2-cury1; // Calculate ruler length length=sqrt(xstep*xstep+ystep*ystep); // Get conversion factor cvtfac=bae_getcoorddisp()?1000.0/2.54:1000.0; // Get ruler line count stepcnt=length*cvtfac; // Adjust coordinate steps xstep/=cvtfac*length; ystep/=cvtfac*length; // Get step normals xnstep=ystep; ynstep=(-xstep); // Calculate ruler angle ang=atan2(ystep,xstep); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Get new distance marker id id=createid(); // Create long ruler side bae_clearpoints(); bae_storepoint(curx1,cury1,0); bae_storepoint(curx2,cury2,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRRULER); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); // Loop for all short ruler lines for (i=0;i<=stepcnt;i++) { // Long ruler line ? if (i%10==0) { // Set line length curllength=RULELONG; // Get number string nstr=itoa(i/10); // Create the number documentary text if (ged_storetext(nstr,curx1+i*xstep+RULETEXT*xnstep, cury1+i*ystep+RULETEXT*ynstep,ang,RTEXTSIZE/cvtfac, curlayer,TEXTHCENT)) error(ERRRULER); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); } // Middle ruler line ? else if (i%5==0) // Set line length curllength=RULEMIDDLE; // Short ruler line else // Set line length curllength=RULESHORT; // Create ruler line bae_clearpoints(); bae_storepoint(curx1+i*xstep,cury1+i*ystep,0); bae_storepoint(curx1+i*xstep+curllength*xnstep, cury1+i*ystep+curllength*ynstep,0); if (ged_storepoly(curlayer,L_POLYDOCLINE,"",0)) error(ERRRULER); if (lay_lastfigelem(nfig)==0) rs_assfigstrpred(nfig,RS_MEASUREID,id,"",""); } // Done bae_prtdialog(REPDONE); } void deletemeasure() /* // Delete a mouse-selectable measurement/ruler */ { index L_FIGURE fig /* Figure list element */; string delid /* Delete ID */; string id /* Current ID */; // Pick measurement polygon bae_promptdialog(UPRSELMEAS); if (ged_pickanyelem(fig,(1<=0 && (fig.TYP==L_FIGPOLY || fig.TYP==L_FIGTEXT) && lay_rulequery(RS_OCFIG,fig,RS_PCBSUBJ,RS_MEASUREID,"?s",id)>0 && id==delid) ged_delelem(fig); } static void polytile() /* // Tile polygon placement */ { index L_FIGURE fig /* Figure list index */; index L_POLY poly /* Polygon index */; index L_POINT point /* Point index */; int xcnt = 1 /* Number of x tiles */; int ycnt = 1 /* Number of y tiles */; double covfac /* Tile coverage factor */; double lx,ly,ux,uy /* Polygon boundaries */; double xstep,ystep /* Tile matrix element vector */; double xside,yside /* Tile size vector */; double xoff,yoff /* Tile placement offset vector */; double x,y /* Current tile base coordinates */; double p,q,s /* Quadratic equation variables */; int polytyp /* Polygon type */; int ptyp /* Polygon type index */; double pcol = 25.0 /* Parameter column */; double cy /* Dialog box current y coordinate */; int cunits = bae_getcoorddisp() ? 2 : 0 /* Coordinate display units */; int repflag /* Dialog box repeat flag */; int res /* Result buffer */; int varidx /* INI variable index */; int xcidx = (-1) /* X count dialog box item idx. */; int ycidx = (-1) /* Y count dialog box item idx. */; int tcidx = (-1) /* Tile cov. dialog box item idx. */; int cridx = (-1) /* Corner rad. dialog box item idx. */; int ptidx = (-1) /* Poly. type dialog box item idx. */; int cflag = 0 /* Change flag */; int i, j /* Loop control variables */; if (varget(GV_TILEXCNT,xcnt)) xcnt=1; if (varget(GV_TILEYCNT,ycnt)) ycnt=1; if (varget(GV_TILEPTYP,ptyp)) ptyp=0; // Ask for tile polygon layer curlayer=ged_getpickpreflay(); if (bae_promptdialog(UPRTILELAY),ged_asklayer(curlayer,0)) error_abort(); if (bae_dialclr()) { // Ask for x copy count and test it if (askint(xcnt,UPRTILEXCNT,5) || xcnt<=0) error(ERRINPVAL); // Ask for y copy count and test it if (askint(ycnt,UPRTILEYCNT,5) || ycnt<=0) error(ERRINPVAL); // Ask for tile coverage if (askdbl(TILECOVER,UPRTILECOVER,7) || TILECOVER<=0.0 || TILECOVER>=100.0) error(ERRINPVAL); // Ask for tile corner radiis if (askdist(TILERAD, lay_defusrunit()?UPRTILECORNI:UPRTILECORNM,0) || TILERAD<=0.0) error(ERRINPVAL); // Ask for tile polygon type bae_promptdialog(UPRPOLYMODE); if ((ptyp=bae_askmenu(3,UPRFILLAREA,UPRKOUTAREA,UPRABORT))<0 || ptyp>1) // Abort error_abort(); } else { do { // Init. the y coordinate bae_dialclr(); cy=DIAL_TOPMARG; // Store tile x count controls dial_label(0.0,cy,UPRTILEXCNTD); xcidx=bae_dialaddcontrol(PA_INT|PA_CHKLL|PA_HBRDREL,1,0, xcnt,0.0,0.0,0.0,"",30,DIAL_LEFTMARG+pcol,cy, DIAL_RIGHTEMARG,""); cy+=DIAL_CTRVSTEP; // Store tile y count controls dial_label(0.0,cy,UPRTILEYCNTD); ycidx=bae_dialaddcontrol(PA_INT|PA_CHKLL|PA_HBRDREL,1,0, ycnt,0.0,0.0,0.0,"",30,DIAL_LEFTMARG+pcol,cy, DIAL_RIGHTEMARG,""); cy+=DIAL_CTRVSTEP; // Store tile coverage controls dial_label(0.0,cy,UPRTILECOVERD); tcidx=bae_dialaddcontrol(PA_DBL|PA_CHKLL|PA_CHKUL|PA_HBRDREL, 0,0,0,0.0,100.0,TILECOVER,"",30,DIAL_LEFTMARG+pcol,cy, DIAL_RIGHTEMARG,""); cy+=DIAL_CTRVSTEP; // Store spacing controls dial_label(0.0,cy,UPRTILECORND); cridx=bae_dialaddcontrol(PA_DBL|PA_DIST|PA_HBRDREL,0,5,0,0.0, 0.0,TILERAD,"",0,DIAL_LEFTMARG+pcol,cy,DIAL_RIGHTEMARG,""); cy+=DIAL_CTRVSTEP; dial_label(0.0,cy,UPRPOLYMODED); ptidx=bae_dialaddcontrol(PA_RBF,0,0,ptyp,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+pcol,cy,0.0,UPRFILLAREA); bae_dialaddcontrol(PA_RBN,1,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+pcol+8.0,cy,0.0,UPRKOUTAREA); cy+=DIAL_CTRVSTEP; // Store coordinate unit controls bae_dialaddcontrol(PA_RBF,0,1,cunits,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+pcol,cy,0.0,UPRDUNITMM); bae_dialaddcontrol(PA_RBN,2,2,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG+pcol+8.0,cy,0.0,UPRDUNITMIL); cy+=DIAL_CTRVSTEP; // Store the OK and abort button with seperator dial_hsep(cy); dial_okabortini(cy,pcol+20.0+DIAL_RIGHTSMARG,3); // Display dialog box bae_setintpar(16,3090); res=bae_dialaskparams(UPRTILEC, cunits,DIAL_LEFTMARG+pcol+20.0+DIAL_RIGHTSMARG,cy); bae_dialgetdata(xcidx,xcnt,0.0,""); bae_dialgetdata(ycidx,ycnt,0.0,""); bae_dialgetdata(tcidx,0,TILECOVER,""); bae_dialgetdata(cridx,0,TILERAD,""); bae_dialgetdata(ptidx,ptyp,0.0,""); switch (res) { // Done case 0 : repflag=0; break; // Switch to mm units case 1 : cunits=0; break; // Switch to mil units case 2 : cunits=2; break; // Save parameters case 3 : varidx=0; bae_inidblset(varidx,PAR_TILECOVER,TILECOVER); bae_inidimset(varidx,PAR_TILERAD,TILERAD); bae_iniwrite(varidx); break; // Fail/abort case (-1) : default : error_abort(); } // Stop if no further repeat requests } while (repflag); } // Store settings for next call varset(GV_TILEXCNT,xcnt); varset(GV_TILEYCNT,ycnt); varset(GV_TILEPTYP,ptyp); varset(PAR_TILECOVER,TILECOVER); varset(PAR_TILERAD,TILERAD); if (ptyp==1) // Keepout rectangle polytyp=L_POLYKEEPOUT; else // Filled rectangle polytyp= curlayer>=DOCLAYBASE ? L_POLYDOCAREA : L_POLYCOPPASS; // Transform percentage to scale factor covfac=sqrt(TILECOVER*0.01); // Make layer visible layerfadein(curlayer,COLFIN,1); // Select polygon while (bae_prtdialog(UPRTILEPOLY),ged_pickelem(fig,L_FIGPOLY)==0) { poly=fig.POLY; // Loop for polygon points bae_clearpoints(); forall (point of poly) // Store point to internal list bae_storepoint(point.X,point.Y,point.TYP); // Get the polygon range bae_getpolyrange(lx,ly,ux,uy); // Calculate tile parameters xstep=(ux-lx)/xcnt; ystep=(uy-ly)/ycnt; if (TILERAD==0.0) { xside=xstep*covfac; yside=ystep*covfac; } else { p=ystep-xstep; q=-(4.0-PI)*TILERAD*TILERAD-xstep*ystep*TILECOVER*0.01; s=p*p-4.0*q; if (s<0.0) error(ERRTILERAD); xside=0.5*(-p+sqrt(s)); yside=ystep-xstep+xside; if (TILERAD*2.0>xside || TILERAD*2.0>yside) error(ERRTILERAD); } xoff=0.5*(xstep-xside); yoff=0.5*(ystep-yside); // Create the tile polygon matrix for (i=0;i0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw center square(s) case 5 : mousegrab(1); askpolytypelay(); // Repetively place squares while (1) { bae_promptdialog(UPRSCENTER); curx1=bae_planwsnx(); cury1=bae_planwsny(); if (dim1==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRSCORNER); bae_setdblpar(3,currad); if (bae_inpointmenu( curx1,cury1,curx2,cury2,7,drawrectfunc)) break; // Get first corner curx1=2.0*curx1-curx2; cury1=2.0*cury1-cury2; } else { dim1*=0.5; drawrect(-dim1,-dim1,dim1,dim1,currad); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim1; curx1-=dim1; cury1-=dim1; dim1*=2.0; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawrect(curx1,cury1,curx2,cury2,currad); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw corner rectangle(s) case 6 : mousegrab(1); askpolytypelay(); // Repetively place rectangles while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRRCORNER1); if (dim1==0.0 || dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRRCORNER2); bae_setdblpar(3,currad); if (bae_inpointmenu( curx1,cury1,curx2,cury2,1,drawrectfunc)) break; } else { drawrect(0.0,0.0,dim1,dim2,currad); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawrect(curx1,cury1,curx2,cury2,currad); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw center rectangle(s) case 7 : mousegrab(1); askpolytypelay(); // Repetively place rectangles while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRRCENTER); if (dim1==0.0 || dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRRCORNER); bae_setdblpar(3,currad); if (bae_inpointmenu( curx1,cury1,curx2,cury2,8,drawrectfunc)) break; // Get first corner curx1=2.0*curx1-curx2; cury1=2.0*cury1-cury2; } else { dim1*=0.5; dim2*=0.5; drawrect(-dim1,-dim2,dim1,dim2,currad); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; curx1-=dim1; cury1-=dim2; dim1*=2.0; dim2*=2.0; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawrect(curx1,cury1,curx2,cury2,currad); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw line(s) case 8 : mousegrab(1); curpolytype=L_POLYDOCLINE; if (curlayer==(LAYERINV+1)) curlayer=ged_getpickpreflay(); if (curlayer==LAYERINV) { bae_promptdialog(UPRSELLAYER); if (ged_asklayer(curlayer,3)) error_abort(); } // Repetively place lines while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRLCORNER1); if (dim1==0.0 && dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRLCORNER2); bae_setdblpar(3,currad); if (bae_inpointmenu( curx1,cury1,curx2,cury2,2,drawpolyfunc)) break; } else { drawline(0.0,0.0,dim1,dim2); if (bae_inpointmenu( curx1,cury1,curx1,cury1,9,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawline(curx1,cury1,curx2,cury2); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if (pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw center circle(s) case 9 : mousegrab(1); askpolytypelay(); // Repetively place circles while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRCCENTER); if (currad==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawrectfunc)) break; bae_promptdialog(UPRCRADIUS); if (bae_inpointmenu( curx1,cury1,curx2,cury2,3,drawpolyfunc)) break; } else { drawcircle(0.0,0.0,currad); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+currad; cury2=cury1; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawcircle(curx1,cury1,dist(curx1,cury1,curx2,cury2)); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw radius circle(s) case 15 : mousegrab(1); askpolytypelay(); // Repetively place circles while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRCRADIUS); if (bae_inpointmenu(curx1,cury1, curx1,cury1,0,drawrectfunc)) break; bae_promptdialog(UPRCCENTER); bae_setdblpar(3,currad); if (bae_inpoint(curx1,cury1,curx2,cury2,11)) break; // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawcircle(curx2,cury2,dist(curx1,cury1,curx2,cury2)); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Place text case 10 : mousegrab(1); if (curlayer==(LAYERINV+1)) curlayer=ged_getpickpreflay(); if (curlayer==LAYERINV) { bae_promptdialog(UPRSELLAYER); if (ged_asklayer(curlayer,7)) error_abort(); } // Repetively place texts while (1) { prevfound= lay_lastfigelem(prevfig)==0 ? 1 : 0 ; // Get layer default mode oldlaydefmode=ged_getlaydefmode(); ged_setlaydefmode(0); ged_setlayerdefault(curlayer); bae_clriactqueue(); laysel(7,curlayer); bae_storetextiact(textstr=="" ? 0 : 1,textstr); if (textheight!=0.0) { /* Set text size */ bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); sprintf(unitstr,"%.5f mm", cvtlength(textheight,0,2)); bae_storetextiact(1,unitstr); } bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,11,LMB); if ((textcent&1)!=0) { bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,12,LMB); } if ((textcent&2)!=0) { bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,13,LMB); } bae_callmenu(MNU_GEDADDTEXT); ged_setlaydefmode(oldlaydefmode); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Check if text placed successfully if (prevfound && lastfig[lastvalid]==prevfig) break; if (pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } else { break; } if (!loopmode) break; } exit(0); // Display group case 11 : // Create the group bitmap symboldraw(libfname,grpname); if (grpname=="") sprintf(msg,REPLIBN,convstring(libfname,2)); else sprintf(msg,REPGRPNAME,convstring(libfname,2), ddbcelemname(libfname,grpname,ddbcl,0)); bae_dialsetcurrent(boxidx); bae_dialsetdata(bmlabidx,PA_BMLAB,30,0.0,""); bae_dialsetdata(labidx,PA_LAB,0,0.0,msg); bae_dialsetcurrent(0); exit(0); // Place group case 12 : if (grpname=="") break; mousegrab(1); anglock=bae_getanglelock(); bae_setanglelock(0); // Repetively place group while (1) { prevfound= lay_lastfigelem(prevfig)==0 ? 1 : 0 ; bae_clriactqueue(); bae_storetextiact(1,libfname); bae_storetextiact(1,grpname); if (scale!=0.0 && scale!=1.0) { bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,12,LMB); bae_storetextiact(1,ftoa(scale,5)); } bae_callmenu(MNU_GEDLOADGRP); // Check if group placed successfully if (lay_lastfigelem(lastfig[0])!=0 || (prevfound && lastfig[0]==prevfig)) break; if (xcnt!=1 || ycnt!=1) { // Get group placement coordinates ged_getdblpar(0,curx1); ged_getdblpar(1,cury1); // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Put current mouse coordinate into grid bae_wsmouse(curx2,cury2,0); bae_storemouseiact(1,curx2,cury2,0,LMB); bae_inpoint(curx2,cury2,curx1,cury1,2); if (xcnt==1 || ycnt==1) { bae_promptdialog(UPRGRPOFF); if (bae_inpoint( curx1,cury1,curx2,cury2,2)) { bae_setintpar(0,rangedis); if (bae_getanglelock()==0) bae_setanglelock(anglock); error_abort(); } } else { bae_promptdialog(UPRGRPMAT); if (bae_inpoint( curx1,cury1,curx2,cury2,1)) { bae_setintpar(0,rangedis); if (bae_getanglelock()==0) bae_setanglelock(anglock); error_abort(); } } gx=curx2-curx1; gy=cury2-cury1; for (i=0;i0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } else { break; } if (!loopmode) break; } exit(0); // Draw edge center polygons case 18 : mousegrab(1); askpolytypelay(); // Repetively place polygons while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRPCORNER); if (bae_inpointmenu(curx1,cury1, curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRPCENTER); if (bae_inpoint(curx1,cury1,curx2,cury2,11)) break; // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawpoly(edges,curx2,cury2,curx1,cury1,0); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw center radius polygons case 19 : mousegrab(1); askpolytypelay(); // Repetively place polygons while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRPCENTER); if (currad==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRPCORNER); if (bae_inpointmenu( curx1,cury1,curx2,cury2,2,drawpolyfunc)) break; } else { drawpoly(edges,0.0,0.0,currad,0.0,1); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawnpolyfunc)) break; curx2=curx1+currad; cury2=cury1; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawpoly(edges,curx1,cury1,curx2,cury2, currad==0.0 ? 0 : 1); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw corner ellipse(s) case 20 : mousegrab(1); askpolytypelay(); // Repetively place ellipses while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRECORNER1); if (dim1==0.0 || dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRECORNER2); if (bae_inpointmenu( curx1,cury1,curx2,cury2,1,drawpolyfunc)) break; } else { drawrect(0.0,0.0,dim1,dim2,currad); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawellipse(steps,curx1,cury1,curx2,cury2); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw center ellipse(s) case 21 : mousegrab(1); askpolytypelay(); // Repetively place ellipses while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPRECENTER); if (dim1==0.0 || dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPRECORNER); if (bae_inpointmenu( curx1,cury1,curx2,cury2,8,drawpolyfunc)) break; // Get first corner curx1=2.0*curx1-curx2; cury1=2.0*cury1-cury2; } else { dim1*=0.5; dim2*=0.5; drawrect(-dim1,-dim2,dim1,dim2,currad); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; curx1-=dim1; cury1-=dim2; dim1*=2.0; dim2*=2.0; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawellipse(steps,curx1,cury1,curx2,cury2); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw corner oval(s) case 22 : mousegrab(1); askpolytypelay(); // Repetively place ovals while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPROCORNER1); if (dim1==0.0 || dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPROCORNER2); if (bae_inpointmenu( curx1,cury1,curx2,cury2,1,drawpolyfunc)) break; } else { drawoval(0.0,0.0,dim1,dim2); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawoval(curx1,cury1,curx2,cury2); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // Draw center oval(s) case 23 : mousegrab(1); askpolytypelay(); // Repetively place rectangles while (1) { curx1=bae_planwsnx(); cury1=bae_planwsny(); bae_promptdialog(UPROCENTER); if (dim1==0.0 || dim2==0.0) { if (bae_inpointmenu( curx1,cury1,curx1,cury1,0,drawpolyfunc)) break; bae_promptdialog(UPROCORNER); if (bae_inpointmenu( curx1,cury1,curx2,cury2,8,drawpolyfunc)) break; // Get first corner curx1=2.0*curx1-curx2; cury1=2.0*cury1-cury2; } else { dim1*=0.5; dim2*=0.5; drawoval(-dim1,-dim2,dim1,dim2); if (bae_inpointmenu( curx1,cury1,curx1,cury1,10,drawpolyfunc)) break; curx2=curx1+dim1; cury2=cury1+dim2; curx1-=dim1; cury1-=dim2; dim1*=2.0; dim2*=2.0; } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Create the polygon drawoval(curx1,cury1,curx2,cury2); if (ged_storepoly(curlayer,curpolytype,netname,0)) error(ERRGRAPHIC); // Get created element for undo if (lay_lastfigelem(lastfig[lastvalid])==0) { // Assign the polygon sub type rule rs_assfigintpred(lastfig[lastvalid], RS_POLYSUBTYPE,curspolytype,0,""); if ((curpolytype==L_POLYDOCLINE || curpolytype==L_POLYSPPAREA) && pwidth>0.0) { // Assign the plot width predicate rule rs_assfigdblpred(lastfig[lastvalid], RS_PLOTWIDTH,pwidth,0.0,""); ged_drawelem(lastfig[lastvalid],DM_SET); } lastvalid++; } if (!loopmode) break; } exit(0); // No default layer case 24 : curlayer=LAYERINV; break; // Use prefered as default layer case 25 : curlayer=LAYERINV+1; break; // Abort case (-1) : default : abortflag=1; } vardelete(GV_LAYFIELD); vardelete(GV_LAYNUM); vardelete(GV_TYPFIELD); vardelete(GV_TYPLAST); vardelete(GV_SUBFIELD); vardelete(GV_NAMEFIELD); vardelete(GV_DIM1FIELD); vardelete(GV_DIM2FIELD); vardelete(GV_RADFIELD); vardelete(GV_PWIDTHFIELD); vardelete(GV_TEXTFIELD); vardelete(GV_TEXTHFIELD); vardelete(GV_TEXTCHFIELD); vardelete(GV_TEXTCVFIELD); vardelete(GV_LOOPFIELD); vardelete(GV_UNITFIELD); vardelete(GV_GRPFIELD); vardelete(GV_GRPSFIELD); vardelete(GV_GRPXFIELD); vardelete(GV_GRPYFIELD); vardelete(GV_LABFIELD); vardelete(GV_BMLABFIELD); vardelete(GV_LIBFNAME); vardelete(GV_DDBCL); sprintf(varname,VAR_PDBOXSEQ,boxidx); vardelete(varname); sprintf(varname,VAR_PDBOXMODE,boxidx); vardelete(varname); bae_dialsetcurrent(boxidx); bae_dialclr(); bae_dialsetcurrent(0); if (abortflag) exit(0); } if (varget(GV_NAMEFIELD,namidx)==0) error(ERRDBLDRAWDB); // Check if dialog box support if (bae_dialclr()) error(ERRNOWIN); // Create the group bitmap symboldraw(libfname,grpname); bae_dialaddcontrol(PA_ACT,0,2,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG,cy,6.5,UPRLAYER); cx=DIAL_LEFTMARG+pcol; bae_dialaddcontrol(PA_ACT,0,24,0,0.0,0.0,0.0,"",0, cx,cy,1.5,UPRNLAYER); cx+=1.5 /* bae_dialgettextlen(0,UPRNLAYER) */+BUTXSTEP; bae_dialaddcontrol(PA_ACT,0,25,0,0.0,0.0,0.0,"",0, cx,cy,1.5,UPRPLAYER); cx+=1.5 /* bae_dialgettextlen(0,UPRPLAYER) */+BUTXSTEP; layidx=bae_dialaddcontrol(PA_LAB|PA_HBRDREL,0,0,0,0.0,0.0,0.0,"",0, cx,cy,DIAL_RIGHTSMARG,curlayer==LAYERINV ? UPRNOLAYER : (curlayer==LAYERINV+1) ? UPRPREFLAYER : purelayername(curlayer)); cy+=0.8; bae_dialaddcontrol(PA_ACT,0,16,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG,cy,6.5,UPRPOLY); anypflag= curlayer==LAYERINV || curlayer==(LAYERINV+1) ? 1 : 0 ; // Check polygon type if (curpolytype!=(-1)) { if (!anypflag) { if (polylaycheck(curlayer,curpolytype)!=0) { if (polylaycheck(curlayer,L_POLYCOPPASS)==0) curpolytype=L_POLYCOPPASS; else if ( polylaycheck(curlayer,L_POLYKEEPOUT)==0) curpolytype=L_POLYKEEPOUT; else if (polylaycheck( curlayer,L_POLYDOCLINE)==0) curpolytype=L_POLYDOCLINE; else if (polylaycheck( curlayer,L_POLYDOCAREA)==0) curpolytype=L_POLYDOCAREA; else if (polylaycheck( curlayer,L_POLYCOPFILL)==0) curpolytype=L_POLYCOPFILL; else if (polylaycheck( curlayer,L_POLYCOPACT)==0) curpolytype=L_POLYCOPACT; else if (polylaycheck( curlayer,L_POLYSPPAREA)==0) curpolytype=L_POLYSPPAREA; else if (polylaycheck( curlayer,L_POLYBRDOUT)==0) curpolytype=L_POLYBRDOUT; else curpolytype=(-1); } else if (polytypecheck(curpolytype)!=0) { curpolytype=(-1); } } } else if (polytypecheck(curpolytype)!=0) { curpolytype=(-1); } typidx=bae_dialaddcontrol(PA_SB|PA_HBRDREL,0,0,curpolytype, 0.0,0.0,0.0,"",0,DIAL_LEFTMARG+pcol,cy,DIAL_RIGHTEMARG,""); dial_sbentry(14,-1,UPRPTYPESEL); if (polytypecheck(L_POLYCOPPASS)==0 && (anypflag || polylaycheck(curlayer,L_POLYCOPPASS)==0)) dial_sbentry(14,L_POLYCOPPASS,polytypename(L_POLYCOPPASS)); if (polytypecheck(L_POLYKEEPOUT)==0 && (anypflag || polylaycheck(curlayer,L_POLYKEEPOUT)==0)) dial_sbentry(14,L_POLYKEEPOUT,polytypename(L_POLYKEEPOUT)); if (polytypecheck(L_POLYBRDOUT)==0 && (anypflag || polylaycheck(curlayer,L_POLYBRDOUT)==0)) dial_sbentry(14,L_POLYBRDOUT,polytypename(L_POLYBRDOUT)); if (polytypecheck(L_POLYCOPACT)==0 && (anypflag || polylaycheck(curlayer,L_POLYCOPACT)==0)) dial_sbentry(14,L_POLYCOPACT,polytypename(L_POLYCOPACT)); if (polytypecheck(L_POLYDOCLINE)==0 && (anypflag || polylaycheck(curlayer,L_POLYDOCLINE)==0)) dial_sbentry(14,L_POLYDOCLINE,polytypename(L_POLYDOCLINE)); if (polytypecheck(L_POLYDOCAREA)==0 && (anypflag || polylaycheck(curlayer,L_POLYDOCAREA)==0)) dial_sbentry(14,L_POLYDOCAREA,polytypename(L_POLYDOCAREA)); if (polytypecheck(L_POLYCOPFILL)==0 && (anypflag || polylaycheck(curlayer,L_POLYCOPFILL)==0)) dial_sbentry(14,L_POLYCOPFILL,polytypename(L_POLYCOPFILL)); if (polytypecheck(L_POLYSPPAREA)==0 && (anypflag || polylaycheck(curlayer,L_POLYSPPAREA)==0)) dial_sbentry(14,L_POLYSPPAREA,polytypename(L_POLYSPPAREA)); cy+=0.8; if (curpolytype==L_POLYCOPFILL) { subidx=bae_dialaddcontrol(PA_SB|PA_HBRDREL,0,0, ((curspolytype&L_POLYSOLIDCF) ? 1 : 0)+ ((curspolytype&L_POLYHATCHCF) ? 2 : 0),0.0,0.0, 0.0,"",0,DIAL_LEFTMARG+pcol,cy,DIAL_RIGHTEMARG,""); dial_sbentry(0,0,UPRSPTYPSCF); dial_sbentry(0,1,UPRSPTYPFCF); dial_sbentry(0,2,UPRSPTYPHCF); } else if (curpolytype==L_POLYKEEPOUT && (curlayerxe) { lx=xe; ux=xs; } else { lx=xs; ux=xe; } if (ys>ye) { ly=ye; uy=ys; } else { ly=ys; uy=ye; } bae_clearpoints(); // Check if round corners if (r==0.0) { // Draw the rectangle if (bae_storepoint(lx,ly,0) || bae_storepoint(lx,uy,0) || bae_storepoint(ux,uy,0) || bae_storepoint(ux,ly,0) || curpolytype==L_POLYDOCLINE && bae_storepoint(lx,ly,0)) error(ERRGRAPHIC); } else { // Adjust corner radius to dimensions rad=r; w=ux-lx; h=uy-ly; if (w<2.0*rad) rad=0.5*w; if (h<2.0*rad) rad=0.5*h; // Draw the rectangle with round corners if ( bae_storepoint(lx,ly+rad,0) || bae_storepoint(lx+rad,ly+rad,1) || bae_storepoint(lx+rad,ly,0) || bae_storepoint(ux-rad,ly,0) || bae_storepoint(ux-rad,ly+rad,1) || bae_storepoint(ux,ly+rad,0) || bae_storepoint(ux,uy-rad,0) || bae_storepoint(ux-rad,uy-rad,1) || bae_storepoint(ux-rad,uy,0) || bae_storepoint(lx+rad,uy,0) || bae_storepoint(lx+rad,uy-rad,1) || bae_storepoint(lx,uy-rad,0) || curpolytype==L_POLYDOCLINE && bae_storepoint(lx,ly+rad,0)) error(ERRGRAPHIC); } } void drawoval(double xs,double ys,double xe,double ye) /* // Draw an oval specified by range corner points // Parameters : // double xs,ys : Start point coordinates // double xe,ye : End point coordinates */ { double lx,ly /* Lower oval corner */; double ux,uy /* Upper rectangle corner */; double cx,cy /* Center coordinates */; double hw,hh /* Oval half dimensions */; if (xs>xe) { lx=xe; ux=xs; } else { lx=xs; ux=xe; } if (ys>ye) { ly=ye; uy=ys; } else { ly=ys; uy=ye; } bae_clearpoints(); // Get the oval dimensions hw=0.5*(ux-lx); hh=0.5*(uy-ly); // Get the center coordinates cx=0.5*(lx+ux); cy=0.5*(ly+uy); // Check oval orientation if (hw==hh) { drawcircle(cx,cy,hw); } else if (hwxu) { temp=xl; xl=xu; xu=temp; } if (yl>yu) { temp=yl; yl=yu; yu=temp; } // Get the center coordinates cx=(xl+xu)*0.5; cy=(yl+yu)*0.5; // Get the axis dimensions x_axis=(xu-xl)*0.5; y_axis=(yu-yl)*0.5; bae_clearpoints(); // Check the ellipse orientation if (x_axis>y_axis) { step=y_axis/edges; if (bae_storepoint(cx+x_axis,cy,0)) error(ERRGRAPHIC); for (y=step;y0.0;y-=step) if (bae_storepoint( cx-x_axis*sqrt(1.0-y*y/(y_axis*y_axis)),cy+y,0)) error(ERRGRAPHIC); if (bae_storepoint(cx-x_axis,cy,0)) error(ERRGRAPHIC); for (y=step;y0.0;y-=step) if (bae_storepoint( cx+x_axis*sqrt(1.0-y*y/(y_axis*y_axis)),cy-y,0)) error(ERRGRAPHIC); if (curpolytype==L_POLYDOCLINE && bae_storepoint(cx+x_axis,cy,0)) error(ERRGRAPHIC); } else { step=x_axis/edges; if (bae_storepoint(cx,cy+y_axis,0)) error(ERRGRAPHIC); for (x=step;x0.0;x-=step) if (bae_storepoint( cx+x,cy-y_axis*sqrt(1.0-x*x/(x_axis*x_axis)),0)) error(ERRGRAPHIC); if (bae_storepoint(cx,cy-y_axis,0)) error(ERRGRAPHIC); for (x=step;x0.0;x-=step) if (bae_storepoint( cx-x,cy+y_axis*sqrt(1.0-x*x/(x_axis*x_axis)),0)) error(ERRGRAPHIC); if (curpolytype==L_POLYDOCLINE && bae_storepoint(cx,cy+y_axis,0)) error(ERRGRAPHIC); } } void drawline(double xs,double ys,double xe,double ye) /* // Draw a line specified by start and end points // Parameters : // double xs,ys : Start point coordinates // double xe,ye : End point coordinates */ { bae_clearpoints(); // Draw the line if (bae_storepoint(xs,ys,0) || bae_storepoint(xe,ye,0)) error(ERRGRAPHIC); } void laysel(int laytyp,int layer) /* // Perform layer selection sequence for given layer type and layer code // Parameters : // int laytyp : Layer type // int layer : Layer code */ { string layname /* Documentary layer selection name */; switch (laytyp) { /* Documentary or signal layer */ case 0 : if (layer>=DOCLAYBASE) { sprintf(layname,"d%ds%s", ((layer-DOCLAYBASE)/DOCLAYSHIFT)+1, (layer&0x02) ? "a" : (layer&0x01) ? "2" : "1"); bae_storemenuiact(1,4+lay_menulaylinecnt(),LMB); bae_storetextiact(1,layname); } else if (layer>=0 && layer=0 && layer=0 && layer=DOCLAYBASE) { sprintf(layname,"d%ds%s", ((layer-DOCLAYBASE)/DOCLAYSHIFT)+1, (layer&0x02) ? "a" : (layer&0x01) ? "2" : "1"); bae_storetextiact(1,layname); } else { error_abort(); } break; /* Signal or power layer */ case 4 : if (layer>=POWLAYBASE && layer<(POWLAYBASE+POWLAYMAX)) { bae_storemenuiact(1,6+lay_menulaylinecnt(),LMB); bae_storemenuiact(1,layer-POWLAYBASE,LMB); } else if (layer>=0 && layer=DOCLAYBASE) { sprintf(layname,"d%ds%s", ((layer-DOCLAYBASE)/DOCLAYSHIFT)+1, (layer&0x02) ? "a" : (layer&0x01) ? "2" : "1"); bae_storetextiact(1,layname); } else if (layer>=POWLAYBASE) { sprintf(layname,"p%d",layer-POWLAYBASE+1); bae_storetextiact(1,layname); } else if (layer>=0 && layer=LAYERDRLZ && layer<=LAYERDRLD) { sprintf(layname,"dr%d",LAYERDRLD-layer); bae_storetextiact(1,layname); } else { error_abort(); } break; /* Pure power layer */ case 6 : if (layer>=POWLAYBASE && layer<(POWLAYBASE+POWLAYMAX)) bae_storemenuiact(1,layer-POWLAYBASE,LMB); else error_abort(); break; /* Documentary, signal or power layer */ case 7 : if (layer>=DOCLAYBASE) { sprintf(layname,"d%ds%s", ((layer-DOCLAYBASE)/DOCLAYSHIFT)+1, (layer&0x02) ? "a" : (layer&0x01) ? "2" : "1"); bae_storemenuiact(1,7+lay_menulaylinecnt(),LMB); bae_storetextiact(1,layname); } else if (layer>=POWLAYBASE) { bae_storemenuiact(1,6+lay_menulaylinecnt(),LMB); bae_storemenuiact(1,layer-POWLAYBASE,LMB); } else if (layer>=0 && layerwsydim ? wsxdim : wsydim)*0.05; if (bmp_setsize(wslx-wsbrd,wsuy+wsbrd, wsux+wsbrd,wsly-wsbrd,labwidth,labheight,xoff,yoff) || bae_dialbmpalloc(PICLABWIDTH,PICLABHEIGHT,30,0,0)!=30) { lay_macrelease(pool); return; } // Draw the picture label bitmap bae_popsetarea(30); // Scan object data if (DISPTEXT) lay_scanpool(pool,xoff-pool.MACRO.MNX,yoff-pool.MACRO.MNY,0.0, 1,1,NULL,polyfunc,pathfunc,textfunc,NULL,lchkfunc,NULL); else lay_scanpool(pool,xoff-pool.MACRO.MNX,yoff-pool.MACRO.MNY,0.0, 1,1,NULL,polyfunc,pathfunc,NULL,NULL,lchkfunc,NULL); // Release the macro element lay_macrelease(pool); // Switch back to default draw area bae_popsetarea(0); } static int polyfunc(index L_POLY poly,int layer, int polyinws,int tree,index L_LEVEL level) /* // Output an already transformed polygon data block // Return value : // zero if done or (-1) on file error // Parameters : // index L_POLY poly : Polygon // int layer : Polygon layer // int polyinws : Poly in workspace flag // int tree : Polygon tree number // index L_LEVEL level : Polygon level */ { index L_POINT point /* Polygon point */; int fillmode /* Popup polygon fill mode */; int powtree = (-1) /* Power plane tree number */; // Get the polygon fill mode by evaluating the polygon type switch (poly.TYP) { // Open line polygon types case L_POLYDOCLINE : fillmode=PPFM_LINE; break; // Closed line polygon types case L_POLYBRDOUT : case L_POLYKEEPOUT : case L_POLYCOPFILL : fillmode=PPFM_CLINE; break; case L_POLYSPPAREA : // Get the tree number from level if ((powtree=lay_getlevtreenum(level))<0) // Invalid level tree, use supplied tree powtree=tree; fillmode= powtree>=0 ? PPFM_CLINE : PPFM_FILL; break; // Filled polygon types case L_POLYCOPPASS : case L_POLYCOPACT : case L_POLYDOCAREA : fillmode=PPFM_FILL; break; // Ignore others default : return(0); } // Display the polygon bae_clearpoints(); forall (point of poly) btp_storepoint(point.X,point.Y,point.TYP); bae_popdrawpoly(color,DM_SET,fillmode); // Return without errors return(0); } static int pathfunc(index L_LINE path, int layer,int pathinws,index L_LEVEL level) /* // Output an already transformed path data block // Return value : // zero if done or (-1) on file error // Parameters : // index L_LINE path : Path // int layer : Path layer // int pathinws : Path in workspace flag // index L_LEVEL level : Path level */ { index L_POINT point /* Path point */; // Display the trace bae_clearpoints(); forall (point of path) btp_storepoint(point.X,point.Y,point.TYP); bae_popdrawpoly(color,DM_SET,PPFM_LINE); // Return without errors return(0); } static int textfunc(index L_TEXT textp,double tx,double ty,double tangle, int mirrflag,int layer,double tsize,string tstr,int textinws) /* // Vectorize a text data block // Return value : // zero if done or (-1) on error // Parameters : // index L_TEXT textp : Text index // double tx : Text X coordinate // double ty : Text Y coordinate // double tangle : Text rotation angle // int mirrflag : Text mirror flag // int layer : Text layer code // double tsize : Text size // string tstr : Text string // int textinws : Text in workspace flag */ { double vx, vy /* Text line vector coordinates */; // Check if attribute line display if (lay_getsctextdest(vx,vy)==1) // Draw the attribute line if (tlinefunc(tx,ty,vx,vy)) // Line draw failed return(-1); // Vectorize the text (if not empty string) if (tstr && lay_vecttext(tx,ty,tangle,mirrflag,tsize, (textp.MODE&TEXTOMSK)==TEXTPHYS,0,textp.MODE,tstr,tlinefunc)) // Vectorization failed return(-1); // Return without errors return(0); } static int lchkfunc(int layer) /* // Layer output check routine // Return value : // zero on scan stop request, 1 if scan allowed // Parameters : // int layer : Layer code */ { // Stop scan if layer is invisible return((color=bae_getcolor(layer))>0); } static int tlinefunc(double x1,double y1,double x2,double y2) /* // Draw a text line as path // Return value : // zero if done or (-1) on error // Parameters : // double x1 : First line point X coordinate // double y1 : First line point Y coordinate // double x2 : Second line point X coordinate // double y2 : Second line point Y coordinate */ { // Draw the line bae_clearpoints(); btp_storepoint(x1,y1,0); btp_storepoint(x2,y2,0); bae_popdrawpoly(color,DM_SET,PPFM_LINE); // Return without errors return(0); } string createid() /* // Generate new marker ID // Return value : // ID */ { string id /* ID */; int year,month,day /* Date */; int hour,min,sec /* Time */; // Get date and time get_date(day,month,year); get_time(hour,min,sec); // Build the ID sprintf(id,"%04d%02d%02d%02d%02d%02d", year+1900,month+1,day,hour,min,sec); // Return the ID return(id); } void replacedot(string valstr) /* // Replace dot by comma in value string // Parameters : // string valstr : Value string */ { char c /* Character buffer */; int i /* Loop control variable */; for (i=0;(c=valstr[i])!='\0';i++) if (c=='.') valstr[i]=','; } void normvect(double x,double y,double len) /* // Normalize vector // Parameters : // double x : Vector X coordinate // double y : Vector Y coordinate // double len : Vector original length return */ { // Get length len=sqrt(x*x+y*y); if (len==0.0) return; // Normalize data x/=len; y/=len; } // User Language program end