added cartography hatches and grains

This commit is contained in:
Mario Voigt 2021-07-05 14:00:54 +02:00
parent f54fb7f7e8
commit 3964634190
5 changed files with 463 additions and 0 deletions

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Hatches And Grains</name>
<id>fablabchemnitz.de.hatches_and_grains</id>
<param name="tab" type="notebook">
<page name="splash" gui-text="Hatches">
<label>Create standardized hatches to differentiate or prioritize cartographic objects.</label>
<label appearance="header">Hatches settings</label>
<param name="type" type="optiongroup" appearance="combo" gui-text="Sort of hatches:">
<option value="h">Continuous</option>
<option value="d">Discontinuous</option>
</param>
<param name="angle" type="optiongroup" appearance="combo" gui-text="Orientation:">
<option value="0">―</option>
<option value="135"></option>
<option value="90">|</option>
<option value="45"></option>
</param>
<param name="thickness" type="optiongroup" appearance="combo" gui-text="Thickness:">
<option value="1">1px</option>
<option value="3">3px</option>
<option value="5">5px</option>
</param>
<param name="spacing" type="optiongroup" appearance="combo" gui-text="Spacing:">
<option value="8">8px</option>
<option value="10">10px</option>
<option value="12">12px</option>
<option value="15">15px</option>
<option value="20">20px</option>
<option value="25">25px</option>
<option value="30">30px</option>
<option value="40">40px</option>
<option value="50">50px</option>
</param>
<label appearance="header">Hatches color</label>
<param name="hcolor" type="color" gui-text="Hatches color" />
</page>
<page name="grains_page" gui-text="Grains">
<label>Create standardized grains to differentiate or prioritize cartographic objects.</label>
<label appearance="header">Grains settings</label>
<param name="type_grain" type="optiongroup" appearance="combo" gui-text="Grains:">
<option value="grain_v">V</option>
<option value="grain_m">ʌ</option>
<option value="grain_p">+</option>
<option value="grain_x">X</option>
<option value="grain_c">○</option>
<option value="grain_r">●</option>
</param>
<param name="size" type="optiongroup" appearance="combo" gui-text="Size:">
<option value="1">Very small</option>
<option value="2">Small</option>
<option value="3">Medium</option>
<option value="4">Large</option>
</param>
<label appearance="header">Grain color</label>
<param name="gcolor" type="color" gui-text="Grain color" />
</page>
<page name="info" gui-text="Information">
<label xml:space="preserve">
This mapping module is intended for the community of geographers and cartographers.
It makes it possible to create visual variables like "hatch" or "grain" on surface or point implantation, in order to differentiate or prioritize the cartographic information.
Laurent Porcheret
Géographe - cartographe / Geographer - cartographer
Sorbonne université - INSPE de Paris
V.15.01.2020</label>
</page>
</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Shape/Pattern from existing Object(s)"/>
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">hatches_grains.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,144 @@
#!/bin/env python3
#
# Copyright (C) 2020 Marc Jeanmougin, Laurent Porcheret
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
# Thanks to Bénédicte Cuperly for reminding me to do this and for her feedback
""" Geography patterns """
import math
import inkex
from inkex import Pattern, PathElement, Circle, Rectangle, AbortExtension
GRAIN_V="m 0 0 10 20 10 -20"
GRAIN_VI="m 0 20 10 -20 10 20"
GRAIN_PLUS="M 10 0 10 20 M 0 10 20 10"
GRAIN_X="M 0 0 20 20 M 0 20 20 0"
class Geography(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument('--tab', default='grains_page', help='grains_page or hatches_page')
pars.add_argument('--type', default='h', help='h|d')
pars.add_argument('--angle', default='0', help='angle')
pars.add_argument('--thickness', default='1', help='width')
pars.add_argument('--spacing', default='8', help='spacing between hatches')
pars.add_argument('--type_grain', default='grain_v', help='Shape of patterns (v^+xoO)')
pars.add_argument('--size', default='1', help='size of grain')
pars.add_argument('--hcolor', default=inkex.Color(255), type=inkex.Color, help='color of hatches')
pars.add_argument('--gcolor', default=inkex.Color(255), type=inkex.Color, help='color of grains')
def effect(self):
#step 0: find desired id
i=self.get_id()
#step 1: add stuff in defs if not present
if self.svg.getElementById(i) is None:
#construct it
newNode = self.svg.defs.add(Pattern())
self.construct(newNode)
#step 2: assign
for node in self.svg.selection.values():
node.style['fill'] = "url(#"+i+")"
node.set('fill', "url(#"+i+")")
def construct(self, node):
if(self.options.tab == "grains_page"):
self.construct_grain(node)
else:
self.construct_hatch(node)
node.set('patternUnits', "userSpaceOnUse")
node.set('id', self.get_id())
def get_id(self):
if(self.options.tab=="grains_page"):
return "inkgeo_"+self.options.type_grain+"_"+self.options.size+"_"+str(int(self.options.gcolor))
else:
return "inkgeo_"+self.options.type+"_"+self.options.angle+"_"+self.options.thickness+"_"+self.options.spacing+"_"+str(int(self.options.hcolor))
def construct_grain(self, node):
size=str(math.sqrt(float(self.options.size)))
node.set('width', "100")
node.set('height', "100")
n1=0
n2=0
node.style="stroke-width:4;"
if self.options.type_grain == "grain_c" or self.options.type_grain == "grain_r":
n1 = node.add(Circle())
n2 = node.add(Circle())
n1.set('cx',10)
n1.set('cy',10)
n1.set('r',10)
n2.set('cx',10)
n2.set('cy',10)
n2.set('r',10)
if self.options.type_grain == "grain_c":
node.style.set_color(self.options.gcolor, 'stroke')
node.set('fill', "none")
else:
node.style.set_color(self.options.gcolor, 'stroke')
node.style.set_color(self.options.gcolor, 'fill')
else:
node.style.set_color(self.options.gcolor, 'stroke')
node.set('fill', "none")
#paths
n1 = node.add(PathElement())
n2 = node.add(PathElement())
if self.options.type_grain == "grain_v":
n1.set('d', GRAIN_V)
n2.set('d', GRAIN_V)
elif self.options.type_grain == "grain_m":
n1.set('d', GRAIN_VI)
n2.set('d', GRAIN_VI)
elif self.options.type_grain == "grain_p":
n1.set('d', GRAIN_PLUS)
n2.set('d', GRAIN_PLUS)
elif self.options.type_grain == "grain_x":
n1.set('d', GRAIN_X)
n2.set('d', GRAIN_X)
n1.set('transform', "translate(5,5)scale("+size+")")
n2.set('transform', "translate(55,55)scale("+size+")")
node.set('patternTransform', "scale(0.1)")
def construct_hatch(self,node):
h = int(self.options.spacing)+int(self.options.thickness)
node.set('width', str(h))
node.set('patternTransform', "rotate("+self.options.angle+")")
r = node.add(Rectangle())
r.set('x', "0")
r.set('y', "0")
r.set('height', self.options.thickness)
r.style.set_color(self.options.hcolor, 'fill')
if self.options.type=="h":
node.set('height',str(h))
r.set('width', str(h))
else:
node.set('height',str(2*h))
r.set('width', str(h/2))
r2 = node.add(Rectangle())
r2.set('x', str(h/2))
r2.set('y', str(h))
r2.set('width', str(h/2))
r2.set('height', self.options.thickness)
r2.style.set_color(self.options.hcolor, 'fill')
if __name__ == '__main__':
Geography().run()

View File

@ -0,0 +1,128 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: hatches_grains\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-28 11:27+0200\n"
"PO-Revision-Date: 2020-09-28 11:32+0200\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.3\n"
#: hatches_grains.inx:3
msgid "Hatches and grains"
msgstr "Hachures et grains"
#: hatches_grains.inx:11
msgid "Hatches"
msgstr "Hachures"
#: hatches_grains.inx:12
msgid ""
"\n"
"Create standardized hatches to differentiate or prioritize cartographic "
"objects. \n"
" "
msgstr ""
"\n"
"Crée des hachures standardisées pour différencier ou prioriser des objets "
"cartographiques.\n"
" "
#: hatches_grains.inx:16
msgid "Hatches settings"
msgstr "Paramètres de hachures"
#: hatches_grains.inx:18
msgid "Sort of hatches:"
msgstr "Type de hachures :"
#: hatches_grains.inx:23
msgid "Orientation:"
msgstr "Orientation :"
#: hatches_grains.inx:30
msgid "Thickness:"
msgstr "Épaisseur :"
#: hatches_grains.inx:37
msgid "Spacing:"
msgstr "Espacement :"
#: hatches_grains.inx:49 hatches_grains.inx:50
msgid "Hatches color"
msgstr "Couleur de hachures"
#: hatches_grains.inx:55
msgid "Grains"
msgstr "Grains"
#: hatches_grains.inx:57
msgid ""
"\n"
"Create standardized grains to differentiate or prioritize cartographic "
"objects.\n"
" "
msgstr ""
"\n"
"Crée des grains standardisées pour différencier ou prioriser des objets "
"cartographiques.\n"
" "
#: hatches_grains.inx:61
msgid "Grains settings"
msgstr "Paramètres de grains"
#: hatches_grains.inx:63
msgid "Grains:"
msgstr "Grains :"
#: hatches_grains.inx:72
msgid "Size:"
msgstr "Taille :"
#: hatches_grains.inx:79 hatches_grains.inx:80
msgid "Grain color"
msgstr "Couleur de grains"
#: hatches_grains.inx:86
msgid "Information"
msgstr "Information"
#: hatches_grains.inx:87
msgid ""
"\n"
"This mapping module is intended for the community of geographers and "
"cartographers.\n"
"\n"
"It makes it possible to create visual variables like \"hatch\" or \"grain\" "
"on surface or point implantation, in order to differentiate or prioritize "
"the cartographic information.\n"
"\n"
"Laurent Porcheret \n"
"Géographe - cartographe / Geographer - cartographer\n"
"Sorbonne université - INSPE de Paris\n"
"V.15.01.2020"
msgstr ""
"\n"
"Ce module est destiné à la communauté des géographes et des cartographes.\n"
"Il permet de créer des variables visuelles telles que des hachures ou des "
"grains sur des surfaces ou des ponctuels, pour différencier ou hiérarchiser "
"des informations cartographiques.\n"
"\n"
"Laurent Porcheret \n"
"Géographe - cartographe / Geographer - cartographer\n"
"Sorbonne université - INSPE de Paris"
#: hatches_grains.inx:102
msgid "Cartography"
msgstr "Cartographie"

View File

@ -0,0 +1,110 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-28 11:33+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: hatches_grains.inx:3
msgid "Hatches and grains"
msgstr ""
#: hatches_grains.inx:11
msgid "Hatches"
msgstr ""
#: hatches_grains.inx:12
msgid ""
"\n"
"Create standardized hatches to differentiate or prioritize cartographic "
"objects. \n"
" "
msgstr ""
#: hatches_grains.inx:16
msgid "Hatches settings"
msgstr ""
#: hatches_grains.inx:18
msgid "Sort of hatches:"
msgstr ""
#: hatches_grains.inx:23
msgid "Orientation:"
msgstr ""
#: hatches_grains.inx:30
msgid "Thickness:"
msgstr ""
#: hatches_grains.inx:37
msgid "Spacing:"
msgstr ""
#: hatches_grains.inx:49 hatches_grains.inx:50
msgid "Hatches color"
msgstr ""
#: hatches_grains.inx:55
msgid "Grains"
msgstr ""
#: hatches_grains.inx:57
msgid ""
"\n"
"Create standardized grains to differentiate or prioritize cartographic "
"objects.\n"
" "
msgstr ""
#: hatches_grains.inx:61
msgid "Grains settings"
msgstr ""
#: hatches_grains.inx:63
msgid "Grains:"
msgstr ""
#: hatches_grains.inx:72
msgid "Size:"
msgstr ""
#: hatches_grains.inx:79 hatches_grains.inx:80
msgid "Grain color"
msgstr ""
#: hatches_grains.inx:86
msgid "Information"
msgstr ""
#: hatches_grains.inx:87
msgid ""
"\n"
"This mapping module is intended for the community of geographers and "
"cartographers.\n"
"\n"
"It makes it possible to create visual variables like \"hatch\" or \"grain\" "
"on surface or point implantation, in order to differentiate or prioritize "
"the cartographic information.\n"
"\n"
"Laurent Porcheret \n"
"Géographe - cartographe / Geographer - cartographer\n"
"Sorbonne université - INSPE de Paris\n"
"V.15.01.2020"
msgstr ""
#: hatches_grains.inx:102
msgid "Cartography"
msgstr ""