How to use user-defined symbols
Hello everyone - I have been struggling for the last several days trying to figure out how to build and use my own symbols. I need a symbol for two kinds of formations - Stalactiflats and Stalagmaflats. These are basically stalagmites which are fat (several feet diameter) and flat on top like a table (or flat on the bottom). It appears there are two problems to solve. The first, which I address in this question, is how to get xTherion to use a custom symbol. The second is to figure out how to draw the symbol in Metapost. For now I am ignoring the second problem. One step at a time! After spending several hours going through Therion By Example, I was able to get a custom symbol to work, but only by replacing an existing symbol. I used the NSS "gradient point" example. Changing the Metapost code as shown does not produce any error messages. However, it also does not produce a symbol in the PDF output. All I get is a red dot. =============== code metapost def p_stalagmaflat_AMER (expr pos,theta,sc,al) = U:=(.15u, .4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Left Hand side thdraw (-.3u, -.2u) -- (-.7u, .1u); thdraw (-.2u, -.1u) -- (-.4u, .6u); #Centerline thdraw (0u, 0u) -- (0u, .9u); #Right side thdraw (.3u, -.2u) -- (.7u, .1u); thdraw (.2u, -.1u) -- (.4u, .6u); enddef; initsymbol ("p_stalagmaflat_AMER"); endcode ================== Since I am not replacing an existing symbol, I leave out the "symbol-assign" line. In xTherion I try to use this by inserting a point of type "u" and adding an option "-subtype stalagmaflat". I think this is where I am missing something ... How to call the custom symbol with a "u" point. Is this the right syntax? In the worst case I suppose I could set it up to replace a symbol that I won't use for this cave - a ladder, for example. That would probably cause quite a bit of confusion down the road, so I would much prefer to avoid it. I am using Therion 5.3.13 on 64-bit Fedora 20. Thanks - Bill Gee
Bill, There are two kinds of symbols in Therion - first one are symbols which are included to Therion in time of compilation - like symbol "stalagmite". Second kind are user symbols. The definition of user symbol should be like: def u_p_stalagmaflat_AMER (expr pos,theta,sc,al) = In XTherion you call it as: point u:stalagmaflat_AMER Red are symbols which definition is not known. M. Odesláno z iPhonu 2. 2. 2014 v 22:00, Bill Gee <bgee@campercaver.net>:
Hello everyone -
I have been struggling for the last several days trying to figure out how to build and use my own symbols. I need a symbol for two kinds of formations - Stalactiflats and Stalagmaflats. These are basically stalagmites which are fat (several feet diameter) and flat on top like a table (or flat on the bottom).
It appears there are two problems to solve. The first, which I address in this question, is how to get xTherion to use a custom symbol. The second is to figure out how to draw the symbol in Metapost. For now I am ignoring the second problem. One step at a time!
After spending several hours going through Therion By Example, I was able to get a custom symbol to work, but only by replacing an existing symbol. I used the NSS "gradient point" example.
Changing the Metapost code as shown does not produce any error messages. However, it also does not produce a symbol in the PDF output. All I get is a red dot.
=============== code metapost
def p_stalagmaflat_AMER (expr pos,theta,sc,al) = U:=(.15u, .4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC;
#Left Hand side thdraw (-.3u, -.2u) -- (-.7u, .1u); thdraw (-.2u, -.1u) -- (-.4u, .6u);
#Centerline thdraw (0u, 0u) -- (0u, .9u);
#Right side thdraw (.3u, -.2u) -- (.7u, .1u); thdraw (.2u, -.1u) -- (.4u, .6u);
enddef;
initsymbol ("p_stalagmaflat_AMER");
endcode ==================
Since I am not replacing an existing symbol, I leave out the "symbol-assign" line.
In xTherion I try to use this by inserting a point of type "u" and adding an option "-subtype stalagmaflat".
I think this is where I am missing something ... How to call the custom symbol with a "u" point. Is this the right syntax?
In the worst case I suppose I could set it up to replace a symbol that I won't use for this cave - a ladder, for example. That would probably cause quite a bit of confusion down the road, so I would much prefer to avoid it.
I am using Therion 5.3.13 on 64-bit Fedora 20.
Thanks - Bill Gee _______________________________________________ Therion mailing list Therion@speleo.sk http://mailman.speleo.sk/mailman/listinfo/therion
Hi Martin - Thanks! Just one error ... The definition is p_u_stalagmaflat_AMER. You got the u and p reversed. Took me a couple of hours to figure that one out today, but I eventually got it. The new symbol is working for me. It goes on the map like it should. I have two followup questions: 1) The map legend labels the symbol as "point u:stalagmaflat_AMER". I tried to use a text line in the thconfig file, but it has no apparent effect. If I put it inside the layout/endlayout pair, therion throws an error. If I put it outside the layout/endlayout section, then no error - and no change. 2) It would be handy to split the Metapost code out to an include file. I tried to use both source and input to read a file, but therion did not like them. Is there a way to do this? The only example I found in the Wiki has the entire layout section in a separate file. I just want to split the Metapost code out. Bill Gee On Sunday, February 02, 2014 23:06:21 Martin Sluka wrote:
Bill, There are two kinds of symbols in Therion - first one are symbols which are included to Therion in time of compilation - like symbol "stalagmite". Second kind are user symbols. The definition of user symbol should be like:
def u_p_stalagmaflat_AMER (expr pos,theta,sc,al) =
In XTherion you call it as:
point u:stalagmaflat_AMER
Red are symbols which definition is not known.
M.
Odesláno z iPhonu
2. 2. 2014 v 22:00, Bill Gee <bgee@campercaver.net>:
Hello everyone -
I have been struggling for the last several days trying to figure out how to build and use my own symbols. I need a symbol for two kinds of formations - Stalactiflats and Stalagmaflats. These are basically stalagmites which are fat (several feet diameter) and flat on top like a table (or flat on the bottom).
It appears there are two problems to solve. The first, which I address in this question, is how to get xTherion to use a custom symbol. The second is to figure out how to draw the symbol in Metapost. For now I am ignoring the second problem. One step at a time!
After spending several hours going through Therion By Example, I was able to get a custom symbol to work, but only by replacing an existing symbol. I used the NSS "gradient point" example.
Changing the Metapost code as shown does not produce any error messages. However, it also does not produce a symbol in the PDF output. All I get is a red dot.
===============
code metapost
def p_stalagmaflat_AMER (expr pos,theta,sc,al) =
U:=(.15u, .4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC;
#Left Hand side thdraw (-.3u, -.2u) -- (-.7u, .1u); thdraw (-.2u, -.1u) -- (-.4u, .6u);
#Centerline thdraw (0u, 0u) -- (0u, .9u);
#Right side thdraw (.3u, -.2u) -- (.7u, .1u); thdraw (.2u, -.1u) -- (.4u, .6u);
enddef;
initsymbol ("p_stalagmaflat_AMER");
endcode
==================
Since I am not replacing an existing symbol, I leave out the "symbol-assign" line.
In xTherion I try to use this by inserting a point of type "u" and adding an option "-subtype stalagmaflat".
I think this is where I am missing something ... How to call the custom symbol with a "u" point. Is this the right syntax?
In the worst case I suppose I could set it up to replace a symbol that I won't use for this cave - a ladder, for example. That would probably cause quite a bit of confusion down the road, so I would much prefer to avoid it.
I am using Therion 5.3.13 on 64-bit Fedora 20.
Thanks - Bill Gee _______________________________________________ Therion mailing list Therion@speleo.sk http://mailman.speleo.sk/mailman/listinfo/therion
_______________________________________________ Therion mailing list Therion@speleo.sk http://mailman.speleo.sk/mailman/listinfo/therion
two followup questions:
1) The map legend labels the symbol as "point u:stalagmaflat_AMER". I tried to use a text line in the thconfig file, but it has no apparent effect. If I put it inside the layout/endlayout pair, therion throws an error. If I put it outside the layout/endlayout section, then no error - and no change.
It needs to go in the th-config outside of a layout. See page 48 of Therion Book on 'text' translations. You probably need to define a legend entry as well. Here is an example I use towards the end of my custom symbol rope definition metapost... initsymbol("l_u_rope") def l_u_rope_legend = l_u_rope(((.2,.2) -- (.8,.8)) inscale) enddef; endcode #Need to add next line to all thconfig files to define legend text text en "line u:rope" "rope" #text to appear in legend
2) It would be handy to split the Metapost code out to an include file. I tried to use both source and input to read a file, but therion did not like them. Is there a way to do this?
The only example I found in the Wiki has the entire layout section in a separate file. I just want to split the Metapost code out.
You should use 'input' defined in or via your th-config, and you will need to have at least the metapost encapsulated in a 'code metapost' 'endcode' block I expect. I have never included less than a whole 'layout' 'end layout' in one file but see no reason why it would work. I suggest if you are having trouble, start with all explicitly typed in a th-config, then once you have that working, progressively split out portions into an 'included' file. If you have syntax correct, it should work just the same. Bruce
You may use several layouts in export definition. export map -layout a -layout b ... M. Odesláno z iPhonu 4. 2. 2014 v 7:07, Bruce <bruce@tomo.co.nz>:
two followup questions:
1) The map legend labels the symbol as "point u:stalagmaflat_AMER". I tried to use a text line in the thconfig file, but it has no apparent effect. If I put it inside the layout/endlayout pair, therion throws an error. If I put it outside the layout/endlayout section, then no error - and no change.
It needs to go in the th-config outside of a layout. See page 48 of Therion Book on 'text' translations. You probably need to define a legend entry as well. Here is an example I use towards the end of my custom symbol rope definition metapost...
initsymbol("l_u_rope")
def l_u_rope_legend = l_u_rope(((.2,.2) -- (.8,.8)) inscale) enddef; endcode #Need to add next line to all thconfig files to define legend text text en "line u:rope" "rope" #text to appear in legend
2) It would be handy to split the Metapost code out to an include file. I tried to use both source and input to read a file, but therion did not like them. Is there a way to do this?
The only example I found in the Wiki has the entire layout section in a separate file. I just want to split the Metapost code out.
You should use 'input' defined in or via your th-config, and you will need to have at least the metapost encapsulated in a 'code metapost' 'endcode' block I expect. I have never included less than a whole 'layout' 'end layout' in one file but see no reason why it would work. I suggest if you are having trouble, start with all explicitly typed in a th-config, then once you have that working, progressively split out portions into an 'included' file. If you have syntax correct, it should work just the same.
Bruce
_______________________________________________ Therion mailing list Therion@speleo.sk http://mailman.speleo.sk/mailman/listinfo/therion
Hi Bruce - Thanks for your response. I tried adding a text line in the thconfig file, but it does not change the legend. With the line at either the top or bottom, no error is produced - it just doesn't work. If I put the line inside the layout block, then Therion throws a compile error. Below is the thconfig file I am using. I also attach a screen clip from the resulting map. Thanks - Bill Gee ==================== encoding utf-8 source MillCreekCave.th # This layout is for the main 2D map, all on one page layout mainmap units imperial scale-bar 20 feet page-numbers on scale 1 200 color map-fg [100 86 66] map-comment "A compass and tape survey of Mill Creek Cave, Pulaski County, Missouri" statistics explo all legend on symbol-set UIS # section for PDF properties doc-author "Bill Gee" doc-title "Map of Mill Creek Cave" doc-subject "Plan map of Mill Creek Cave" # Section for map photos map-image 32 30 center DSC_0004.JPG map-image 52 105 center DSC_0056.JPG # Include custom Metapost code for special symbols # source CustomSymbolsCode.txt # Custom metapost code code metapost # This code defines a gradient point that looks like the NSS-standard symbol def p_gradient_AMER (expr pos,theta,sc,al) = U:=(.15u, .4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Left Hand side thdraw (-.3u, -.2u) -- (-.7u, .1u); thdraw (-.2u, -.1u) -- (-.4u, .6u); #Centerline thdraw (0u, 0u) -- (0u, .9u); #Right side thdraw (.3u, -.2u) -- (.7u, .1u); thdraw (.2u, -.1u) -- (.4u, .6u); enddef; # This code defines a stalagmaflat symbol. def p_u_stalagmaflat_AMER (expr pos,theta,sc,al) = U:=(0.3u, 0.4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Draw and paint the symbol thfill (0.2u,-0.4u)--(0.1u,0.2u)--(0.3u,0.2u)--(0.3u,0.4u)--(-0.3u,0.4u)--(-0.3u,0.2u)--(-0.1u,0.2u)--(-0.2u,-0.4u)-- cycle; enddef; # This code redefines the stalagmite symbol. def p_stalagmite_AMER (expr pos,theta,sc,al) = U:=(0.2u, 0.4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Draw and paint the symbol thfill (0.2u,-0.4u)--(0.0u,0.4u)--(-0.2u,-0.4u)--cycle; enddef; # This code redefines the stalactite symbol. def p_stalactite_AMER (expr pos,theta,sc,al) = U:=(0.2u, 0.4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Draw and paint the symbol thfill (0.2u,0.4u)--(-0.2u,0.4u)--(0.0u,-0.4u)--cycle; enddef; # This code redefines the pillar symbol. def p_pillar_AMER (expr pos,theta,sc,al) = U:=(0.2u, 0.4u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; #Draw and paint the symbol thfill (0.2u,-0.4u)--(0.1u,0.0u)--(0.2u,0.4u)--(-0.2u,0.4u)--(-0.1u,0.0u)--(-0.2u,-0.4u)-- cycle; enddef; # Redefine popcorn to use hollow circles instead of filled-in def p_popcorn_AMER (expr pos,theta,sc,al)= U:=(.5u,.2u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; thdraw (-.5u,-.2u)--(.5u,-.2u); pickup PenD; thdraw (-.3u,-.2u)--(-.3u,.0u); thdraw (0,-.2u)--(0,.0u); thdraw (.3u,-.2u)--(.3u,.0u); thdraw fullcircle scaled .2u shifted (-.3u,.1u); thdraw fullcircle scaled .2u shifted (0,.1u); thdraw fullcircle scaled .2u shifted (.3u,.1u); enddef; # Define a dotted dripline def l_u_dripline_AMER (expr Path) = T:=identity; pickup PenC; draw Path dashed withdots scaled (.75*optical_zoom) withpen PenA; enddef; # Initialize the new symbols initsymbol ("p_gradient_AMER"); initsymbol ("p_stalagmite_AMER"); initsymbol ("p_stalactite_AMER"); initsymbol ("p_u_stalagmaflat_AMER"); initsymbol ("p_pillar_AMER"); initsymbol ("p_popcorn_AMER"); initsymbol ("l_u_dripline_AMER"); let p_gradient=p_gradient_AMER; let p_stalagmite=p_stalagmite_AMER; let p_stalactite=p_stalactite_AMER; let p_pillar=p_pillar_AMER; let p_popcorn=p_popcorn_AMER; endcode symbol-assign point gradient AMER symbol-assign point stalagmite AMER symbol-assign point stalactite AMER symbol-assign point pillar AMER symbol-assign point popcorn AMER endlayout # Change the legend callout for stalagmaflats text en_US "point u:stalagmaflat.AMER" "stalagmaflat" export map -proj plan -layout mainmap -o MillCreekCave.pdf ===================== On Tuesday, February 04, 2014 19:07:42 Bruce wrote:
two followup questions:
1) The map legend labels the symbol as "point u:stalagmaflat_AMER". I
tried to use a text line in the thconfig file, but it has no apparent effect. If I put it inside the layout/endlayout pair, therion throws an error. If I put it outside the layout/endlayout section, then no error - and no change.
It needs to go in the th-config outside of a layout. See page 48 of Therion Book on 'text' translations. You probably need to define a legend entry as well. Here is an example I use towards the end of my custom symbol rope definition metapost...
initsymbol("l_u_rope")
def l_u_rope_legend = l_u_rope(((.2,.2) -- (.8,.8)) inscale) enddef; endcode #Need to add next line to all thconfig files to define legend text text en "line u:rope" "rope" #text to appear in legend
Bill You have the symbols appearing in your legend and presumably in your maps and the text redefinition looks OK-ish. One thing to note is that metapost (or something) renders quite a few characters as '.'. I think underscore may be one of them. This might have been confusing you. So try this; text en_US "point u:stalagmaflat_AMER" "stalagmaflat" Also, it may be conversion to email has altered the start of your layout definition. Check that the layout definition starts on a new line, and is not part of the commented line. Bruce -----Original Message----- From: therion-bounces@speleo.sk [mailto:therion-bounces@speleo.sk] On Behalf Of Bill Gee Sent: Sunday, 9 February 2014 5:37 a.m. To: therion@speleo.sk Subject: [Therion] Changing text on a legend entry Hi Bruce - Thanks for your response. I tried adding a text line in the thconfig file, but it does not change the legend. With the line at either the top or bottom, no error is produced - it just doesn't work. If I put the line inside the layout block, then Therion throws a compile error. Below is the thconfig file I am using. I also attach a screen clip from the resulting map. Thanks - Bill Gee ==================== encoding utf-8 source MillCreekCave.th # This layout is for the main 2D map, all on one page <layout must start on new line> layout mainmap units imperial scale-bar 20 feet page-numbers on scale 1 200 ..
Hi Bruce - Thanks for the suggestion. Indeed it turned out to be that simple. I changed the text line to use an underscore instead of a dot, and now it comes out correctly. I think the email conversion must have messed up the look of the layout line. It is correct in the original file, and it compiles without error. Bill Gee On Sunday, February 09, 2014 08:07:17 Bruce wrote:
Bill
You have the symbols appearing in your legend and presumably in your maps and the text redefinition looks OK-ish.
One thing to note is that metapost (or something) renders quite a few characters as '.'. I think underscore may be one of them. This might have been confusing you. So try this;
text en_US "point u:stalagmaflat_AMER" "stalagmaflat"
Also, it may be conversion to email has altered the start of your layout definition. Check that the layout definition starts on a new line, and is not part of the commented line.
Bruce
-----Original Message----- From: therion-bounces@speleo.sk [mailto:therion-bounces@speleo.sk] On Behalf Of Bill Gee Sent: Sunday, 9 February 2014 5:37 a.m. To: therion@speleo.sk Subject: [Therion] Changing text on a legend entry
Hi Bruce -
Thanks for your response. I tried adding a text line in the thconfig file, but
it does not change the legend. With the line at either the top or bottom, no
error is produced - it just doesn't work. If I put the line inside the layout
block, then Therion throws a compile error.
Below is the thconfig file I am using. I also attach a screen clip from the
resulting map.
Thanks - Bill Gee
====================
encoding utf-8
source MillCreekCave.th
# This layout is for the main 2D map, all on one page <layout must start on new line>
layout mainmap
units imperial
scale-bar 20 feet
page-numbers on
scale 1 200
..
participants (3)
-
Bill Gee -
Bruce -
Martin Sluka