the fair gds editor FingerMacro

Finger Macro

To use this macro select one or more boxes and the macro will replace it with a set of lines which are connected on one side. Similar shapes can be created with the parametric shape library

Download: finger.layout

   1 #!/usr/bin/layout
   2 #name=box->connected lines
   3 #help=Replaces a box with a set of lines;
   4 /***
   5  * written by Arun (arun@users.sf.net) 2006-03
   6  * using layout version 2006-3-15 (cvs)
   7  *
   8  * this is just to show what macros can do...
   9  * it worked for me, but your mileage may vary
  10  */
  11  
  12 int  main() 
  13 {
  14   cellList    *cells;
  15   elementList *elements;
  16       
  17   bool selected = 0; /* was something selected */    
  18   
  19   /* check if something was selected at all */
  20   for(cells = layout->drawing->firstCell; cells!=NULL; cells=cells->nextCell)
  21     {
  22       if(cells->thisCell!=NULL)
  23         {
  24           for(elements=cells->thisCell->firstElement; elements!=NULL; elements=elements->nextElement)
  25             {
  26               if(elements->thisElement!=NULL)
  27                 if(elements->thisElement->select)
  28                   selected=1;
  29             };
  30         };
  31     };
  32   
  33   if(!selected)
  34     {
  35       layout->showMessage("Macro Help","To use this macro select one or more boxes and the macro"+
  36                           " will replace it with a set of lines which are connected on one side.");
  37     }
  38   else
  39     {
  40       /* ask on which side the contact area should be */
  41       string s=layout->getText("Input","Please tell me on which side the lines should be connected (top, bottom, left, right):");
  42       
  43       double finger_width   = layout->getDouble("Input","Please input the line width:");
  44       double finger_spacing = layout->getDouble("Input","Please input the line spacing:");
  45       
  46       double user_unit = layout->drawing->userunits;
  47       
  48       /* from user units to internal units */
  49       finger_width   = finger_width   / user_unit;
  50       finger_spacing = finger_spacing / user_unit;
  51       
  52       /* loop over all cells */
  53       for(cells = layout->drawing->firstCell; cells!=NULL; cells=cells->nextCell)
  54         {
  55           if (cells->thisCell!=NULL)
  56             {
  57               /* loop over all elements,  */
  58               for(elements=cells->thisCell->firstElement; elements!=NULL; /*see end of for loop*/)
  59                 {
  60                   element     *element = elements->thisElement;
  61                   elementList *next;
  62                   
  63                   /* save ref to next element, in case we delete this one */
  64                   next = elements->nextElement;
  65                   
  66                   if (element!=NULL) 
  67                     {
  68                       /* only change selected boxes */
  69                       if(element->select && element->isBox()) 
  70                         {
  71                           /* get layer number */
  72                           int layernr = element->layerNum;
  73                           
  74                           /* get coordinates */
  75                           pointArray pa = element->getPoints();
  76                           
  77                           int x1,y1,x2,y2,x,y,tmp;
  78                           point p;
  79                           
  80                           if(pa.size()==2) /* shouldn't be anything else */
  81                             {
  82                               p=pa.point(0);
  83                               x1=p.x();
  84                               y1=p.y();
  85                               
  86                               p=pa.point(1);
  87                               x2=p.x();
  88                               y2=p.y();
  89                               
  90                               /* always make x1/y1 the lower left corner */
  91                               if(x1>x2) 
  92                                 {
  93                                   tmp = x1;
  94                                   x1  = x2;
  95                                   x2  = tmp;
  96                                 };
  97                               
  98                               if(y1>y2) 
  99                                 {
 100                                   tmp = y1;
 101                                   y1  = y2;
 102                                   y2  = tmp;
 103                                 };
 104                               
 105                               /* output new boxes */
 106                               if(s=="bottom")
 107                                 {                         
 108                                   cells->thisCell->addBox(x1,y1,x2-x1,finger_width,layernr);
 109                                   
 110                                   for( x=x1; x<x2-finger_width; x+=finger_width+finger_spacing)
 111                                     {
 112                                       cells->thisCell->addBox(x,y1+finger_width,finger_width,y2-y1-finger_width,layernr);
 113                                     };
 114                                 }
 115                               else if (s=="top")
 116                                 {
 117                                   cells->thisCell->addBox(x1,y2-finger_width,x2-x1,finger_width,layernr);
 118                                   
 119                                   for( x=x1; x<x2-finger_width; x+=finger_width+finger_spacing)
 120                                     {
 121                                       cells->thisCell->addBox(x,y1,finger_width,y2-y1-finger_width,layernr);
 122                                     };
 123                                   
 124                                 }
 125                               else if (s=="left")
 126                                 {
 127                                   cells->thisCell->addBox(x1,y1,finger_width,y2-y1,layernr);
 128                                   
 129                                   for( y=y1; y<y2-finger_width; y+=finger_width+finger_spacing)
 130                                     {
 131                                       cells->thisCell->addBox(x1+finger_width,y,x2-x1-finger_width,finger_width,layernr);
 132                                     };
 133                                   
 134                                 }
 135                               else if (s=="right")
 136                                 {
 137                                   cells->thisCell->addBox(x2-finger_width,y1,finger_width,y2-y1,layernr);
 138                                   
 139                                   for( y=y1; y<y2-finger_width; y+=finger_width+finger_spacing)
 140                                     {
 141                                       cells->thisCell->addBox(x1,y,x2-x1-finger_width,finger_width,layernr);
 142                                     };
 143                                   
 144                                 };
 145                             };
 146                           cells->thisCell->deleteElement(element);
 147                         };
 148                     };
 149                   elements=next; 
 150                 };/* end loop elements */
 151             };
 152         }; /* end loop cells */
 153     }; /* end if selected */
 154 };
 155 /* Local Variables:    */
 156 /* mode: c             */
 157 /* End:                */  

See also


CategoryMacro


FingerMacro (last edited 2011-02-28 14:00:04 by dslb-092-074-059-143)