Hi Everyone,

I've had a little fun implementing this, I did opt for the .th file to
control the grid in the end, initially tried to use the map-connection
metapost to get the grid as a dotted line, but it wouldn't print when it's
been sent to two separate printers.

So now have adapted the metapost to implement the grid to be dashed as
below:
*code metapost*
*### change the Grid defined by AG as Line:User:Grid, in Excelgrid.th to be
a dotted line by robbing code from the metapost for map-connection and
amending it to make the arrowhead small/insignificant to the naked eye and
the dots spaced further apart*
*initsymbol("l_u_grid");*
*def l_u_grid (expr P) =*
*  thdrawoptions(dashed evenly scaled (20 * optical_zoom) withpen PenA);*
*  l_arrow_SKBB(P,1);*
*  thdrawoptions();*
*enddef;*

The grid has been implemented as a map which is brought in at the lowest
level, so that the grid shows underneath all of the drawing. .th file for
the grid can be found here:
cave-registry.org.uk/svn/PeakDistrict/Castleton/Excelgrid.th
<https://www.cave-registry.org.uk/svn/PeakDistrict/Castleton/Excelgrid.th>

Regards,
Alastair Gott.

On Thu, 18 Apr 2024 at 23:03, John <j...@k-stevens.co.uk> wrote:

> I also changed the cross size from the standard 5mm to 2mm ( from 10mm
> across to 4mm across) using
>
>
>
> #CHANGE CROSS HAIR SIZE
>
> #----------------------
>
> # from 5mm to 2mm
>
> def s_hgrid (expr xpos, ypos, xsize, ysize) =
>
>   pickup PenD;
>
>   draw (
>
>     if xpos < 0: 0 else: -2mm fi, 0
>
>   ) -- (
>
>     if xpos > 0: 0 else: 2mm fi, 0
>
>   );
>
>   draw (
>
>     0, if ypos < 0: 0 else: -2mm fi
>
>   ) -- (
>
>     0, if ypos > 0: 0 else: 2mm fi
>
>   );
>
> enddef;
>
> def s_vgrid_SM (expr xpos, ypos, xsize, ysize) =
>
>   pickup PenD;
>
>   draw (
>
>     if xpos < 0: 0 else: -xsize/4 fi, 0
>
>   ) -- (
>
>     if xpos > 0: 0 else: xsize/4 fi, 0
>
>   ) dashed evenly;
>
> enddef;
>
>
>
> so at a scale 1:2500, each cross is 10m across, a useful quick measurement
> guide.
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows
>
>
>
> *From: *A Gott <alastairg...@gmail.com>
> *Sent: *18 April 2024 22:22
> *To: *List for Therion users <therion@speleo.sk>
> *Subject: *Re: [Therion] More thoughts on Therion grids
>
>
>
> HI Everyone,
>
>
>
> I have just created the linked excel file for creating a bespoke grid
> using excel, it will autopopulate when you drag it down. For the
> horizontals and verticals select a full scrap/endscrap (plus space) set of
> cells to drag down and it will populate the next in the set.
>
>
>
> For the coordinates, select a full set of 4 station, fix, station, fix
> lines and drag them down and it will autopopulate, top boxes are the ones
> which need amending.
>
>
>
> To put it in a therion file, you will need to copy and "paste special
> values" into another excel window and then this should drop into a .th text
> file.
>
>
>
> Onedrive link to the excel file, let me know if you want it and can't
> download it.
>
> Therion_gridcreationfile.xlsx
> <https://1drv.ms/x/s!AuwW4uWNDvLvgcUF3sp4CLnQOAwUmw?e=kdU09y>
>
>
>
> Grid Labels shouldn't be too hard to implement, by creating a scrap with
> some coordinate stations in it and then placing the labels for those
> stations next to coordinate stations.
>
>
>
>
>
> Regards,
>
> Alastair.
>
>
>
> On Thu, 18 Apr 2024 at 19:40, A Gott <alastairg...@gmail.com> wrote:
>
> HI Therion Mailing list,
>
>
>
> I have spent a couple of days looking over a few options with getting a
> grid onto the survey I sent around last week. below are the things I have
> tried.
>
>    1. Manipulating Freq of grid spacing
>
>
>    2. Looking at C++ Therion code
>
>
>    3. Creating a Grid.pdf plan file - To save reading, my take away
>    was give up
>
>
>    4. Drawing Gridlines on .th2 for inclusion
>
>
>
> Two options now being considered:
>
>    1. using microsoft excel to create grid.th file
>
>
>    2. One for those with experience - Creating a script (Python?) to make
>    the grid
>
>
>
> My findings on 1-4 are:
>
>    1. *Manipulating Freq of grid spacing*
>
> I did this as this had been suggested to me and was a good solution, but
> at the 40-50m spacing required to get the grid to show in full this left
> the top right and bottom right corners with duplicate coordinates written
> over each other. for a finished survey, this would not be an optimal
> solution to the problem.
>
>
>
>    2. *Looking at C++ Therion code*
>
> I'm not a coder but I tried to look at the C++/Cxx code for therion to try
> and make some amendments, but didn't realise when I tried to use it in the
> thconfig file, that it doesn't work the same as "code metapost". but when
> taking a look at it I found chunks of the code which I thought were
> relevant, and include these below my signature.
>
> 3) *Creating a Grid.pdf plan file* - To save reading, my take away
> was give up
>
> As the Manipulation of the frequency of the Grid spacing went ok, I
> decided I could potentially use this to create a background for the survey
> but including it in the files, I didn't make a plan (and wouldn't repeat)
> but this went along the lines of:
>
>    1. screenshot Survey, include image of survey in th2 file, place
>    survey points at TR (top right) and BL coordinates required of the th2
>    file, set scrap scale as per survey scale.
>
>
>    2. create .th file which includes the two points as grid reference
>    points, create .thconfig file to replicate the grid formation with no
>    survey in it.
>
>
>    3. export to pdf, use online pdf converter to create .jpg file, and
>    then use paint to remove the overlapping coordinates in the top right and
>    bottom right of the grid.
>
>
>    4. use jpg as a background image in a .th2 file, include the
>    coordinates etc in the main survey master .th file.
>
>
>    5. attempt to use "sketches on" to import this grid into the lowest
>    part of the survey to ensure it is shown on the bottom.
>
>
>    6. give up waiting, as it was taking an age to 'warp' the sketch -
>    abandon this as an idea.
>
>
>
> 4) *Drawing Gridlines on .th2 for inclusion*
>
> I think I could have skipped some of the above steps and used John Stevens
> example of drawing gridlines on a .th2 file earlier, advantages - get
> gridlines where you want, disadvantages - time consuming and potential for
> gridlines which don't look as polished as if a piece of software were doing
> it for you.
>
>
>
>
> I'm now considering
>
>    1. *using microsoft excel to create grid.th <http://grid.th> file*
>
> creating a microsoft excel file to create a grid.th file which will use
> one scrap for each vertical gridline and one for each horizontal gridline.
>
> something along the lines of:
>
> survey gridlines
>
> scrap Vert1
>
> point 1 -1 station -name BotVert1
>
> point 1 0 station -name TopVert1
>
> line u:grid -clip off -place bottom
>
>   1 -1
>
>   1 0
>
> endline
> endscrap
>
>
>
> scrap Vert2
>
> point 2 -1 station -name BotVert2
>
> point 2 0 station -name TopVert2
>
> line u:grid -clip off -place bottom
>
>   2 -1
>
>   2 0
>
> endline
>
> endscrap
>
>
>
> map scrap verticals
>
> Vert1
>
> Vert2
>
> endmap
>
>
>
> map grid
>
> scrap verticals
>
> scrap horizontals
>
> scrap labels
>
> endmap
>
>
>
> centreline
>
>   cs OSGB:SK
>
>   station BotVert1
>
>   fix BotVert1 realX realY 0
>
>   station TopVert1
>
>   fix TopVert1 realX realY1 0
>
> ...etc...
>
>   endcentreline
>
>
>
>    2. *One for those with experience - Creating a script (Python?) to
>    make the grid*
>
> If anyone has any experience of it could they make a small script (like
> topparser is) that can make a .th file such as the above. My thoughts are
> that with a few small options this could be a quick win for a few people
> who are manually making their own grids.
>
>  Therion already has an option to output coordinates for the bbox, these
> could be inputted into the script and then an option selected for the
> coordinate system, grid spacing, labeling frequency and placement
>
>
>
>
>
> Regards,
> Alastair Gott.
> -------------------
>
> Therion source code I thought was most closely aligned to the above
> problem.
>
>
>
> *CXX to control grid formation and pattern*
>
> from line 775 on therion/thpdf.cxx
>
>
>
>   GRIDLIST.clear();
>
>   if (LAYOUT.grid > 0) {
>
>     converted_data scr;
>
>     double a,b,c,d;
>
>     parse_eps(LAYOUT.gridAA, "",0,0,a,b,c,d,scr,101);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[0].x = a;
>
>     LAYOUT.gridcell[0].y = b;
>
>     parse_eps(LAYOUT.gridAB, "",0,0,a,b,c,d,scr,102);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[1].x = a;
>
>     LAYOUT.gridcell[1].y = b;
>
>     parse_eps(LAYOUT.gridAC, "",0,0,a,b,c,d,scr,103);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[2].x = a;
>
>     LAYOUT.gridcell[2].y = b;
>
>     parse_eps(LAYOUT.gridBA, "",0,0,a,b,c,d,scr,104);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[3].x = a;
>
>     LAYOUT.gridcell[3].y = b;
>
>     parse_eps(LAYOUT.gridBB, "",0,0,a,b,c,d,scr,105);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[4].x = a;
>
>     LAYOUT.gridcell[4].y = b;
>
>     parse_eps(LAYOUT.gridBC, "",0,0,a,b,c,d,scr,106);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[5].x = a;
>
>     LAYOUT.gridcell[5].y = b;
>
>     parse_eps(LAYOUT.gridCA, "",0,0,a,b,c,d,scr,107);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[6].x = a;
>
>     LAYOUT.gridcell[6].y = b;
>
>     parse_eps(LAYOUT.gridCB, "",0,0,a,b,c,d,scr,108);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[7].x = a;
>
>     LAYOUT.gridcell[7].y = b;
>
>     parse_eps(LAYOUT.gridCC, "",0,0,a,b,c,d,scr,109);
> GRIDLIST.push_back(scr);scr.clear();
>
>     LAYOUT.gridcell[8].x = a;
>
>     LAYOUT.gridcell[8].y = b;
>
>   }
>
>
>
>   PATTERNLIST.clear();
>
>
>
>   std::ifstream P("patterns.dat");
>
>   if(!P) therror(("Can't open patterns definition file!"));
>
>   char buf[5000];
>
>   char delim[] = ":";
>
>   std::string line,num,pfile,bbox,xstep,ystep,matr;
>
>   while(P.getline(buf,5000,'\n')) {
>
>     num = strtok(buf,delim);
>
>     pfile = strtok(NULL,delim);
>
>     bbox = strtok(NULL,delim);
>
>     xstep = strtok(NULL,delim);
>
>     ystep = strtok(NULL,delim);
>
>     matr = strtok(NULL,delim);
>
> //    if (ALL_PATTERNS.count(num) > 0) {  // changed to patt.used flag
>
>                                           // because thsymbolset.cxx
>
>                                           // calls eps_parse after
>
>                                           // this function is called
>
>                                           // and patterns referenced
>
>                                           // there would be missing in
> this list
>
>       pattern patt;
>
>       patt.used = (ALL_PATTERNS.count(num) > 0);
>
>       patt.name = num;
>
>
>
>       matr.replace(matr.find("["),1,"");
>
>       matr.replace(matr.find("]"),1,"");
>
>       std::istringstream s1(matr);
>
>       s1 >> patt.xx >> patt.xy >> patt.yx >> patt.yy >> patt.x >> patt.y;
>
>       bbox.replace(bbox.find("["),1,"");
>
>       bbox.replace(bbox.find("]"),1,"");
>
>       std::istringstream s2(bbox);
>
>       s2 >> patt.llx >> patt.lly >> patt.urx >> patt.ury;
>
> //      F << "/Matrix " << matr << endl;
>
> //      F << "/BBox " << bbox << endl;
>
>       patt.xstep = atof(xstep.c_str());
>
>       patt.ystep = atof(ystep.c_str());
>
>
>
>       parse_eps(pfile , "", 0,0,
> patt.llx1,patt.lly1,patt.urx1,patt.ury1,patt.data,0);
>
>       PATTERNLIST.push_back(patt);
>
> //    }  // patt.used
>
>   }
>
>   P.close();
>
> }
>
>
>
> *Cxx for Bounding control*
>
> This was the first bit of code I noted down, before I kept proper refs of
> them, think it was Located in xtherion/thepsparse.cxx/from line 1336
>
>
>
>  if (J->second.minx > Llx) J->second.minx = Llx;
>
>             if (J->second.miny > Lly) J->second.miny = Lly;
>
>             if (J->second.maxx < Urx) J->second.maxx = Urx;
>
>             if (J->second.maxy < Ury) J->second.maxy = Ury;
>
>
>
> *Cxx for Layout Calibration*
>
> two bits of code seem to be working together with the use of
> LAYOUT.calibration_hdist
>
>
>
>    1. code from Therion/thpdf.cxx/1620-1621
>
> PAGEDEF << "\\pdfcatalog { /thCalibrate (HS=\\the\\adjustedHS,
> VS=\\the\\adjustedVS, HD=" <<
>                fmt::format("{}",thdouble(LAYOUT.calibration_hdist,10)) <<
> ")}";
>
>
>
> 2) code from therion/thexpmap.cxx/line 1862-1871
>
>   calpoint(0, lim.min.x, lim.min.y);
>
>   calpoint(1, (lim.min.x + lim.max.x) / 2.0,lim.min.y);
>
>   calpoint(2, lim.max.x, lim.min.y);
>
>   calpoint(3, lim.min.x, (lim.min.y + lim.max.y) / 2.0);
>
>   calpoint(4, lim.max.x, (lim.min.y + lim.max.y) / 2.0);
>
>   calpoint(5, lim.min.x, lim.max.y);
>
>   calpoint(6, (lim.min.x + lim.max.x) / 2.0,lim.max.y);
>
>   calpoint(7, lim.max.x, lim.max.y);
>
>   calpoint(8, (lim.min.x + lim.max.x) / 2.0, (lim.min.y + lim.max.y) /
> 2.0);
>
>   LAYOUT.calibration_hdist = lim.max.x - lim.min.x;
>
>
>
> *Cxx for Adjustments*
>
> code from Therion/thpdf.cxx/1598-1608
>
>
>
> PAGEDEF << "\\adjustedHS=" << fmt::format("{}",thdouble(HS,prec_xy)) <<
> "bp" <<
>
>       "\\advance\\adjustedHS by \\extraE" <<
>
>       "\\advance\\adjustedHS by \\extraW" <<
>
>       "\\advance\\adjustedHS by \\overlap" <<
>
>       "\\advance\\adjustedHS by \\overlap" <<  std::endl;
>
>
>
>     PAGEDEF << "\\adjustedVS=" << fmt::format("{}",thdouble(VS,prec_xy))
> << "bp" <<
>
>       "\\advance\\adjustedVS by \\extraN" <<
>
>       "\\advance\\adjustedVS by \\extraS" <<
>
>       "\\advance\\adjustedVS by \\overlap" <<
>
>       "\\advance\\adjustedVS by \\overlap" << std::endl;
>
>
> _______________________________________________
> Therion mailing list
> Therion@speleo.sk
> https://mailman.speleo.sk/listinfo/therion
>
_______________________________________________
Therion mailing list
Therion@speleo.sk
https://mailman.speleo.sk/listinfo/therion

Reply via email to