From 3964634190c1b8a0f238a066c306b39445af1b53 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Mon, 5 Jul 2021 14:00:54 +0200 Subject: [PATCH] added cartography hatches and grains --- .../hatches_grains.inx | 81 ++++++++++ .../hatches_grains.py | 144 ++++++++++++++++++ .../locale/fr/LC_MESSAGES/hatches_grains.mo | Bin 0 -> 2279 bytes .../locale/fr/hatches_grains.po | 128 ++++++++++++++++ .../locale/hatches_grains.pot | 110 +++++++++++++ 5 files changed, 463 insertions(+) create mode 100644 extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.inx create mode 100644 extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.py create mode 100644 extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/LC_MESSAGES/hatches_grains.mo create mode 100644 extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/hatches_grains.po create mode 100644 extensions/fablabchemnitz/cartography_hatches_grains/locale/hatches_grains.pot diff --git a/extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.inx b/extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.inx new file mode 100644 index 00000000..564b806a --- /dev/null +++ b/extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.inx @@ -0,0 +1,81 @@ + + + Hatches And Grains + fablabchemnitz.de.hatches_and_grains + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.py b/extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.py new file mode 100644 index 00000000..b4bad268 --- /dev/null +++ b/extensions/fablabchemnitz/cartography_hatches_grains/hatches_grains.py @@ -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() diff --git a/extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/LC_MESSAGES/hatches_grains.mo b/extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/LC_MESSAGES/hatches_grains.mo new file mode 100644 index 0000000000000000000000000000000000000000..46d34d30da6deca35fce0c4fef29613a9a294ffe GIT binary patch literal 2279 zcmcgsJ&zkj7+xR*SO_0MQ5qt>Ithu0tYbSuI`(u3aoio2ayct!PN_)dcE|SM-I--( z_H;)9qNG9;2uh?hT!}>&+iw{eHEa+ zjQ$Gx59n9WZ$5@Uw4ZnDANT?0zvA#cU>D9$ zu>K{G?S%N~CE#Ts$8{BWiO&J?3w9dZ2Xb6@fXu-Rcp3O9kmLFq$no9>;un06KR*8> zkp2A9;BP>z}O{`GbkvEj8@mN}^z2Za0Qel;`%HtR%!g_@ni=Qv_!6ywu8{k{Q!P)-g)! z2q~^ajg?Lq4m?cG5Sa2*80XXxtRnNI=H*zqQe<>2tP$5cai>sTQ)o}_Q+^02~-_}3+3l$I5W6)Fx;k8(hw=T@UYW+qtoqm`rUpv z*jhw&8tih7fa=WHdh8k?C%wlFwevW5ufF;gt81uBY_U|^X$~$e43?P(`&J?CiiJ2h zKmp?4SkHId)D{*Bk-&8vpj48Xmd?e&&>AkyXplySoTkxn`@!8hitx59U@6*j6O~5q zloJ%}+vuVdcDjp#`!CfFa_aBr};y>!&; zbi*yf1?r>GX@MhNp7`r13#B(GnFH1-DZD->fz>Vn%<(`)eQvX;Ev5?!W)ZJ+7P3W6glR1qFt$_t#^k;rl|gY z=SIkHcYY>u|E^Vmg)%s7IJ}Y4Rfs`;r% zrl@4Ml%D^`fo!EgI?vId7E##qZz&UvGKi8(y-IQMa2(+w@zPS&IO0J@g|vCK2T1?} zb%sklV1bYsD}%2AsaA#-`GKCwS1qa#iE7%21<0zm3!@VcOYYi3D4r@XF7W16OY@2@ ztj67t{b+?^MH`e1whXknO0=n>Rw5uOBA2f3VzZ?- r_?x-K`a^UB9!5gpvUq^k$RV`fU}@VyK4i|~8VB>w3!$9jEaKoV?d7eH literal 0 HcmV?d00001 diff --git a/extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/hatches_grains.po b/extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/hatches_grains.po new file mode 100644 index 00000000..62ff9b42 --- /dev/null +++ b/extensions/fablabchemnitz/cartography_hatches_grains/locale/fr/hatches_grains.po @@ -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 , 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" diff --git a/extensions/fablabchemnitz/cartography_hatches_grains/locale/hatches_grains.pot b/extensions/fablabchemnitz/cartography_hatches_grains/locale/hatches_grains.pot new file mode 100644 index 00000000..59fabdca --- /dev/null +++ b/extensions/fablabchemnitz/cartography_hatches_grains/locale/hatches_grains.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 ""