Line palette, slope line l-size

15 views
Skip to first unread message

Nigel Cooke

unread,
Mar 12, 2024, 8:08:49 AMMar 12
to TopoDroid
Hi Marco,

I'm drawing a slope line in a sketch in version 6.2.47-34. It displays nicely in the Topodroid sketch and when I export to Therion format, the .th2 file contains the script for the slope line having the l-size set to 40. Eg:

line slope
  88.94 -140.89 89.22 -140.70 89.51 -140.51
  l-size 40
endline

Is there a setting to change the l-size of the slope lines or is that value a hard coded default? I can't find a way to change it in Topodroid. It always comes out as 40.

The problem I am having is that Therion displays it in my final map with really long perpendicular lines. I can play around with the value in the resultant .th2 file and shorten those lines but I'd rather do it at the source. Is there any way to change the l-size value coming out of Topodroid?

Cheers

Nigel

Balambér Hakapesz

unread,
Mar 12, 2024, 1:13:20 PMMar 12
to topo...@googlegroups.com
it is hard coded

Balázs Holl

--
You received this message because you are subscribed to the Google Groups "TopoDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topodroid+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topodroid/1c47de19-8e10-4db4-be36-69b0feeace71n%40googlegroups.com.

A Gott

unread,
Mar 12, 2024, 4:51:12 PMMar 12
to topo...@googlegroups.com
Hi Nigel,

Are you looking to change all line slopes to the same value in your therion files?

If so, then the best workaround may be to play around with the metapost in your thconfig files.

I will explain this in 4 sections: 1 how to find the metapost code, 2. where this goes in your thconfig file 3. the exact code to put into the layout of your thconfig file and 4. how to adjust this specific metapost code to get your desired results (whilst ignoring the l-size 40)

1. finding metapost code: it's explained here: metapost [Therion wiki] (speleo.sk)
but I use the method where you just put -d in the "command line options" box of the .thconfig window:
image.png

this makes one folders in your computer (thTMPDIR) with files inside only one is useful to us right now: "data.mp"

in this file is all the "metapost" our computers looks for when processing your therion files, two items cover your line slope.
def l_slope_SKBB (expr P,S)(text Q) =
def l_slope_BCRA (expr P,S)(text Q) =

SKBB is therions default code, over here in the UK we force it to use our own symbols "BCRA" by using "symbol-set BCRA" in our layout file of the thconfig.

2. where this goes in your thconfig file
so if you wish to modify Therions native line slope code, then you need everything between "def l_slope_SKBB" and the "enddef;" from the data.mp file

if you place the below code at the end of the layout file you are using then it should pick it up and know that you want to use the new symbol. (NCOOKE can be replaced with any word you wish, but most people stick to words like TEST or GOTT or something memorable to you (in my case surname).

Unfortunately this did not work for me, so I needed to work around by also inserting the following two commands prior to the exact code (3) below:
symbol-hide line slope
symbol-show line slope

this is because the BCRA symbol set seemed to be 'sticky' for this particular symbol

3. the exact code to put into the layout of your thconfig file
#########
symbol-assign line slope NCOOKE

code metapost
initsymbol ("l_slope_NCOOKE");

def l_slope_NCOOKE (expr P,S)(text Q) =
%show Q;
  T:=identity;
  numeric dirs[];
  numeric lengths[];
  for i=1Q: % AG20240312 change number prior to Q the higher the number the larger the line
    dirs[redpart i]:=greenpart i;
    lengths[redpart i]:=bluepart i;
  endfor;

  li:=length(P); % last

  alw_perpendicular:=true;

  for i=0 upto li:
    if unknown dirs[i]: dirs[i]:=-1;
    else:
      if dirs[i]>-1:
        dirs[i]:=((90-dirs[i]) - angle(thdir(P,i))) mod 360;
        alw_perpendicular:=false;
      fi;
    fi;
    if unknown lengths[i]: lengths[i]:=-1; fi;
  endfor;

%for i=0 upto li: show dirs[i]; endfor;

  ni:=0; % next
  pi:=0; % previous

  for i=0 upto li:
    d:=dirs[i];
    if d=-1:
      if (i=0) or (i=li):
        dirs[i] := angle(thdir(P,i) rotated 90) mod 360;
pi:=i;
      else:
        if ni<=i:
  for j=i upto li:
            ni:=j;
    exitif dirs[j]>-1;
  endfor;
fi;
w:=arclength(subpath(pi,i) of P) /
   arclength(subpath(pi,ni) of P);
dirs[i]:=w[dirs[pi],dirs[ni]];
%        if (dirs[i]-angle(thdir(P,i))) mod 360>180:
%          dirs[i]:=w[dirs[ni],dirs[pi]];
%   message("*******");
%        fi;
     fi;
    else:
      pi:=i;
    fi;
  endfor;

%for i=0 upto li: show dirs[i]; endfor;

  ni:=0; % next
  pi:=0; % previous

  for i=0 upto li:
    l:=lengths[i];
    if l=-1:
      if (i=0) or (i=li):
        lengths[i] := 1cm; % should never happen!
thwarning("slope width at the end point not specified");
pi:=i;
      else:
        if ni<=i:
  for j=i+1 upto li:
            ni:=j;
    exitif lengths[j]>-1;
  endfor;
fi;
w:=arclength(subpath(pi,i) of P) /
   arclength(subpath(pi,ni) of P);
lengths[i]:=w[lengths[pi],lengths[ni]];
pi:=i;
      fi;
    else:
      pi:=i;
    fi;
  endfor;

% for i=0 upto li: show lengths[i]; endfor;

  T:=identity;
  boolean par;
  offset:=0;
  dlzka := (arclength P);
  if dlzka>3u:
    offset := 0.3u;
  elseif dlzka>u:
    offset := 0.1u; %AG20240312 moves the start of the symbol away from the line end
  fi;
  dlzka:=dlzka-2offset;
  cas := offset;
  mojkrok:=adjust_step(dlzka,1.4u) / 2; %AG20240312 adjusting the number after the forward slash increases the frequency of lines
  pickup PenD;
  par := false;
  forever:
    t := arctime cas of P;
    if t mod 1>0:  % not a key point
      w := (arclength(subpath(floor t,t) of P) /
            arclength(subpath(floor t,ceiling t) of P));
      if alw_perpendicular:
        a := 90;
      else:
        a := w[dirs[floor t],dirs[ceiling t]];
      fi;
      l := w[lengths[floor t],lengths[ceiling t]];
    else:
      if alw_perpendicular:
        a := 90;
      else:
        a:= dirs[t];
      fi;
      l:=lengths[t];
    fi;

    a := a + angle(thdir(P,t));

    thdraw (point t of P) --
      ((point t of P) + if par: 0.333 * fi l * unitvector(dir(a)));
    cas := cas + mojkrok;
    par := not par;
    exitif cas > dlzka + offset + 0.1mm;  % for rounding errors
  endfor;
  if S = 1: pickup PenC; draw P fi;
%pickup pencircle scaled 3pt;
%for i=0 upto li: draw point i of P; endfor;
enddef;

endcode
#######

4. how to adjust the metapost code to get your desired results (whilst ignoring the l-size 40)
I have worked out which 3 of the above lines provide some movement to the line slope hairs, and I have noted them with my initials and todays date AG20240312

  for i=1Q: % AG20240312 change number prior to Q the higher the number the larger the line

As stated in the description - by increasing the number 1 you can increase the length of hairs coming out of the line slope.

    offset := 0.1u; %AG20240312 moves the start of the symbol away from the line end

largely useless for your query, but I worked out what it did, so I didn't really want to throw this knowledge away. I think where I have written, "line end" I meant line start. but it does also squish the hair together.

  mojkrok:=adjust_step(dlzka,1.4u) / 2; %AG20240312 adjusting the number after the forward slash increases the frequency of lines

The number two(2) is the important thing to change, by increasing or decreasing this figure it increases or decreases the frequency of lines decimals can also be used, such as .5 instead of 2 (ie 4 times less frequent)

Sent from my iPhone

On 12 Mar 2024, at 12:08, 'Nigel Cooke' via TopoDroid <topo...@googlegroups.com> wrote:

 Hi Marco,
--

Nigel Cooke

unread,
Mar 12, 2024, 8:13:58 PMMar 12
to TopoDroid
Thanks Balázs.

Nigel Cooke

unread,
Mar 12, 2024, 8:31:15 PMMar 12
to TopoDroid
Thanks Alastair. 
Brilliant response, very detailed. Not only have you solved my problem, I have learnt a bit more about MetaPost along the way and raised my confidence level with it.
I was trying to tackle the problem from the front end but your solution from the back end will work nicely. I don't want to touch the export files at all if I can help it. It simplifies and streamlines my workflow that way.
Cheers
Nigel

Alastair Gott

unread,
Mar 13, 2024, 3:18:22 AMMar 13
to topo...@googlegroups.com
Hi Nigel,

Not a problem, glad I’ve been able to help.

It doesn’t mean the coders on both the therion side and the topodroid side won’t go and implement a solution. I guess it would just need an option on the topodroid side for the scale of the line used. (Though simultaneously having that and the l-size could prove a little fraught as the two variables fight against each other).

If a variable were added for scale then (not being a coder) I think this would then need an “IF” statement in the l-slope symbol to decode the variable.

And an addition of another variable in the l-slope:

for i=[new variable]Q: % AG20240312 change number prior to Q the higher the number the larger the line.

Have a great day everyone.
Al.

Sent from my iPhone

On 13 Mar 2024, at 00:31, 'Nigel Cooke' via TopoDroid <topo...@googlegroups.com> wrote:



Marco Corvi

unread,
Mar 13, 2024, 3:51:48 AMMar 13
to topo...@googlegroups.com
Thanks Nigel to raising the issue and thanks Alan for the explanation of the metapost code
that draws lines of type slope in therion. it is quite sofisticated and interesting.
on the way i noticed that it can happen that a slope segment that starts outside the cave wall and
enters the cave wall is drawn for the part inside the cave.
i will be glad if you can come up with a solution to avoid this.

as for the therion side, if one does not specifies the l-side at any point of the slope line, therion
raises an error. this could be the place for a metapost global variable l-side, that can be overridden
in a layout config.

on the topodroid side the l-side is hardcoded in the method that exports a line in therion format.
l-size is very specific to therion.
it is to add a setting for the global value of l-side that replaced the hardcoded value "40", and i will do this.
it will be in the next version 6.2.55.

it would be nice to find a way to let the user set the l-side value for each slope line individually.
at the moment i have no clear idea how to go about it. topodroid is an app to take data and
make sketches in the cave, and the postprocessing of the final map is left to more feature rich
programs, therion being the first, although most cave cartographers use other programs.
maybe an edittext box in the line edit dialog - it would be ignored by most topodroid users, and
relevant for the few therion users, and only when they wants to change the l-side of a slope line.


Balambér Hakapesz

unread,
Mar 13, 2024, 4:29:03 AMMar 13
to topo...@googlegroups.com
I really like the long sloping lines on my cave maps, but they are more surface-covering shapes than lines.
Several parameters (density, length, ratio of short to long lines...) can be changed to reproduce the topography of a surface as much as possible. But this is not currently supported by TopoDroid, and I think that entering so many variables would slow down the caving and make things worse overall.
Short slope lines could be exported with fibers of density and length depending on the scale of the map.

Balázs.
image.png

Marco Corvi

unread,
Mar 13, 2024, 5:54:18 AMMar 13
to topo...@googlegroups.com
i agree with you.
slope line is non a line but a "collection" object that includes several segments.

the therion slope line tries to define the items of the collection thru a "simplified"
interface: a line and one or more (direction,length) pairs.
the steps are evenly spaced, and computed using (a multiple of) the drawing unit,
the relative lengths of the segments is hardcoded, 1/3.

topodroid uses the minimal therion format.
adding a user-settable l-side make this minimal choice a little more flexible.
the problem with topodroid is how to render the value of l-side on the screen
and how to make it adjustable through the graghical interface. 

Reply all
Reply to author
Forward
0 new messages