├── .gitignore ├── LICENSE ├── README.md ├── freecad └── mnesarco │ ├── __init__.py │ ├── asm3 │ ├── __init__.py │ └── animation.py │ ├── bumpversion.py │ ├── camera │ ├── __init__.py │ └── pov.py │ ├── config │ ├── __init__.py │ ├── config.py │ ├── dialog.py │ ├── hyperc.py │ ├── main.py │ ├── platform.py │ └── remote.py │ ├── files │ ├── __init__.py │ └── files.py │ ├── gui.py │ ├── hyperc │ ├── __init__.py │ ├── controller.py │ ├── driver.py │ ├── hyperc.py │ └── wire.py │ ├── init_gui.py │ ├── objects │ ├── __init__.py │ ├── hook.py │ └── named_objects.py │ ├── remote │ ├── __init__.py │ ├── exports.py │ ├── macros.py │ ├── page.py │ ├── remote.py │ ├── server.py │ └── workbenches.py │ ├── resources │ ├── __init__.py │ ├── icons │ │ ├── MnesarcoUtils.svg │ │ ├── add_camera.svg │ │ ├── camera.svg │ │ ├── config.svg │ │ ├── create_named_object.svg │ │ ├── del_camera.svg │ │ ├── fc_create_body.svg │ │ ├── fc_create_part.svg │ │ ├── fc_create_sketch.svg │ │ ├── fc_create_spreadsheet.svg │ │ ├── generic.svg │ │ ├── hyperc.svg │ │ ├── remote.svg │ │ ├── save_camera.svg │ │ ├── save_next.svg │ │ ├── svg.svg │ │ ├── timer.svg │ │ ├── timers.svg │ │ └── variables.svg │ ├── style │ │ ├── __init__.py │ │ └── py_editor.py │ ├── templates │ │ └── scripts │ │ │ └── default_script.py.txt │ └── ui │ │ ├── camera │ │ └── PointsOfViewPanel.ui │ │ ├── config │ │ ├── hyperc.ui │ │ ├── platform.ui │ │ └── remote.ui │ │ ├── objects │ │ └── NamedObject.ui │ │ ├── remote │ │ ├── css │ │ │ ├── base.css │ │ │ ├── compact.css │ │ │ └── default.css │ │ ├── favicon.ico │ │ ├── img │ │ │ ├── ajax-loader.gif │ │ │ ├── arrow-left.svg │ │ │ ├── freecad.svg │ │ │ ├── gen_macro_icons.py │ │ │ ├── macro-icon-1.svg │ │ │ ├── macro-icon-10.svg │ │ │ ├── macro-icon-100.svg │ │ │ ├── macro-icon-101.svg │ │ │ ├── macro-icon-102.svg │ │ │ ├── macro-icon-103.svg │ │ │ ├── macro-icon-104.svg │ │ │ ├── macro-icon-105.svg │ │ │ ├── macro-icon-106.svg │ │ │ ├── macro-icon-107.svg │ │ │ ├── macro-icon-108.svg │ │ │ ├── macro-icon-11.svg │ │ │ ├── macro-icon-12.svg │ │ │ ├── macro-icon-13.svg │ │ │ ├── macro-icon-14.svg │ │ │ ├── macro-icon-15.svg │ │ │ ├── macro-icon-16.svg │ │ │ ├── macro-icon-17.svg │ │ │ ├── macro-icon-18.svg │ │ │ ├── macro-icon-19.svg │ │ │ ├── macro-icon-2.svg │ │ │ ├── macro-icon-20.svg │ │ │ ├── macro-icon-21.svg │ │ │ ├── macro-icon-22.svg │ │ │ ├── macro-icon-23.svg │ │ │ ├── macro-icon-24.svg │ │ │ ├── macro-icon-25.svg │ │ │ ├── macro-icon-26.svg │ │ │ ├── macro-icon-27.svg │ │ │ ├── macro-icon-28.svg │ │ │ ├── macro-icon-29.svg │ │ │ ├── macro-icon-3.svg │ │ │ ├── macro-icon-30.svg │ │ │ ├── macro-icon-31.svg │ │ │ ├── macro-icon-32.svg │ │ │ ├── macro-icon-33.svg │ │ │ ├── macro-icon-34.svg │ │ │ ├── macro-icon-35.svg │ │ │ ├── macro-icon-36.svg │ │ │ ├── macro-icon-37.svg │ │ │ ├── macro-icon-38.svg │ │ │ ├── macro-icon-39.svg │ │ │ ├── macro-icon-4.svg │ │ │ ├── macro-icon-40.svg │ │ │ ├── macro-icon-41.svg │ │ │ ├── macro-icon-42.svg │ │ │ ├── macro-icon-43.svg │ │ │ ├── macro-icon-44.svg │ │ │ ├── macro-icon-45.svg │ │ │ ├── macro-icon-46.svg │ │ │ ├── macro-icon-47.svg │ │ │ ├── macro-icon-48.svg │ │ │ ├── macro-icon-49.svg │ │ │ ├── macro-icon-5.svg │ │ │ ├── macro-icon-50.svg │ │ │ ├── macro-icon-51.svg │ │ │ ├── macro-icon-52.svg │ │ │ ├── macro-icon-53.svg │ │ │ ├── macro-icon-54.svg │ │ │ ├── macro-icon-55.svg │ │ │ ├── macro-icon-56.svg │ │ │ ├── macro-icon-57.svg │ │ │ ├── macro-icon-58.svg │ │ │ ├── macro-icon-59.svg │ │ │ ├── macro-icon-6.svg │ │ │ ├── macro-icon-60.svg │ │ │ ├── macro-icon-61.svg │ │ │ ├── macro-icon-62.svg │ │ │ ├── macro-icon-63.svg │ │ │ ├── macro-icon-64.svg │ │ │ ├── macro-icon-65.svg │ │ │ ├── macro-icon-66.svg │ │ │ ├── macro-icon-67.svg │ │ │ ├── macro-icon-68.svg │ │ │ ├── macro-icon-69.svg │ │ │ ├── macro-icon-7.svg │ │ │ ├── macro-icon-70.svg │ │ │ ├── macro-icon-71.svg │ │ │ ├── macro-icon-72.svg │ │ │ ├── macro-icon-73.svg │ │ │ ├── macro-icon-74.svg │ │ │ ├── macro-icon-75.svg │ │ │ ├── macro-icon-76.svg │ │ │ ├── macro-icon-77.svg │ │ │ ├── macro-icon-78.svg │ │ │ ├── macro-icon-79.svg │ │ │ ├── macro-icon-8.svg │ │ │ ├── macro-icon-80.svg │ │ │ ├── macro-icon-81.svg │ │ │ ├── macro-icon-82.svg │ │ │ ├── macro-icon-83.svg │ │ │ ├── macro-icon-84.svg │ │ │ ├── macro-icon-85.svg │ │ │ ├── macro-icon-86.svg │ │ │ ├── macro-icon-87.svg │ │ │ ├── macro-icon-88.svg │ │ │ ├── macro-icon-89.svg │ │ │ ├── macro-icon-9.svg │ │ │ ├── macro-icon-90.svg │ │ │ ├── macro-icon-91.svg │ │ │ ├── macro-icon-92.svg │ │ │ ├── macro-icon-93.svg │ │ │ ├── macro-icon-94.svg │ │ │ ├── macro-icon-95.svg │ │ │ ├── macro-icon-96.svg │ │ │ ├── macro-icon-97.svg │ │ │ ├── macro-icon-98.svg │ │ │ ├── macro-icon-99.svg │ │ │ ├── macro.svg │ │ │ ├── noicon.svg │ │ │ ├── pages.svg │ │ │ ├── pin.svg │ │ │ ├── pin_gray.svg │ │ │ └── workbench.svg │ │ ├── index.html │ │ └── js │ │ │ ├── NoSleep │ │ │ ├── LICENSE.txt │ │ │ └── NoSleep.min.js │ │ │ └── remote.js │ │ ├── scripts │ │ └── CreatePanel.ui │ │ └── timers │ │ ├── CreatePanel.ui │ │ └── TimerSliderPanel.ui │ ├── scripts │ ├── __init__.py │ ├── dialogs.py │ ├── hook.py │ └── script.py │ ├── svg │ ├── __init__.py │ ├── hook.py │ ├── parser.py │ └── svg_file.py │ ├── timers │ ├── __init__.py │ ├── dialogs.py │ └── timer.py │ ├── utils │ ├── __init__.py │ ├── dialogs.py │ ├── editor.py │ ├── extension.py │ ├── files.py │ ├── graphics.py │ ├── math.py │ ├── menus.py │ ├── networking.py │ ├── platform.py │ ├── preferences.py │ ├── qt.py │ ├── signal.py │ ├── strings.py │ ├── timers.py │ ├── toolbars.py │ └── validation.py │ └── vendor │ └── fpo.py ├── manifest.ini └── package.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | __pycache__/ 3 | -------------------------------------------------------------------------------- /freecad/mnesarco/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | """ 22 | Collection of FreeCAD utilities for extension development 23 | """ 24 | 25 | __author__ = "Frank David Martinez M" 26 | __copyright__ = "Copyright (c) 2021, Frank David Martinez M. " 27 | __license__ = "GPL" 28 | __version__ = "0.2.15" 29 | __maintainer__ = "Frank David Martinez M. " 30 | __git__ = "https://github.com/mnesarco/fc-utils.git" 31 | __status__ = "Development" 32 | 33 | import FreeCAD as App 34 | 35 | -------------------------------------------------------------------------------- /freecad/mnesarco/asm3/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | -------------------------------------------------------------------------------- /freecad/mnesarco/bumpversion.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import re 22 | 23 | VER_PATTERN = r'(?P\d+)\.(?P\d+)\.(?P\d+)' 24 | 25 | targets = [ 26 | ('../../package.xml', re.compile(f'(){VER_PATTERN}()')), 27 | ('../../manifest.ini', re.compile(f'(version=){VER_PATTERN}')), 28 | ('./__init__.py', re.compile(f'(__version__ = "){VER_PATTERN}(")')), 29 | ] 30 | 31 | def repl(m: re.Match[str]) -> str: 32 | pre, maj, min, rev, *pos = m.groups() 33 | return f"{pre}{maj}.{min}.{int(rev)+1}{''.join(pos)}" 34 | 35 | for f, pat in targets: 36 | with open(f, 'r') as fin: 37 | content = fin.read() 38 | with open(f, 'w') as fout: 39 | fout.write(pat.sub(repl, content)) -------------------------------------------------------------------------------- /freecad/mnesarco/camera/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | """ 22 | Camera manipulation utilities 23 | """ 24 | -------------------------------------------------------------------------------- /freecad/mnesarco/config/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from .config import init_config 22 | -------------------------------------------------------------------------------- /freecad/mnesarco/config/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.utils.toolbars import add_global_action 22 | from freecad.mnesarco.resources import Icons, tr 23 | from freecad.mnesarco.gui import Gui 24 | 25 | class private: 26 | dialog = None 27 | 28 | 29 | def show_config(): 30 | from freecad.mnesarco.config import main 31 | private.dialog = main.ConfigDialog(Gui.getMainWindow()) 32 | private.dialog.show() 33 | 34 | 35 | def init_config(): 36 | add_global_action( 37 | name="ShowConfig", 38 | icon=Icons.config, 39 | action=show_config, 40 | menu=tr("Configuration"), 41 | activation=lambda: True) 42 | 43 | __all__ = ('init_config') 44 | -------------------------------------------------------------------------------- /freecad/mnesarco/config/main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.config import platform, dialog, hyperc, remote 22 | 23 | 24 | # +----------------------------------------------+ 25 | # | Pages API: | 26 | # | | 27 | # | class PageX(QtCore.QObject): | 28 | # | changed = QtCore.Signal() | 29 | # | def __init__(self, parent): | 30 | # | super(PageX, self).__init__(parent) | 31 | # | self.form = ... | 32 | # | self.title = ... | 33 | # | def validate(self) -> bool | 34 | # | def save(self) | 35 | # +----------------------------------------------+ 36 | # | Then add_page(PageX(self)) in setup + 37 | # +----------------------------------------------+ 38 | 39 | 40 | class ConfigDialog(dialog.ConfigDialog): 41 | 42 | def __init__(self, parent=None): 43 | super(ConfigDialog, self).__init__(parent) 44 | 45 | def setup(self): 46 | self.add_page(remote.RemoteConfig(self)) 47 | # self.add_page(hyperc.HyperControllerConfig(self)) 48 | self.add_page(platform.PlatformConfig(self)) 49 | -------------------------------------------------------------------------------- /freecad/mnesarco/config/platform.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import sys, os 22 | 23 | from freecad.mnesarco.utils.qt import QtCore 24 | from freecad.mnesarco.gui import Gui 25 | from freecad.mnesarco.resources import get_ui, tr 26 | from freecad.mnesarco.utils import preferences as pref 27 | 28 | 29 | class PlatformConfig(QtCore.QObject): 30 | 31 | changed = QtCore.Signal() 32 | 33 | def __init__(self, *args, **kwargs): 34 | super(PlatformConfig, self).__init__(*args, **kwargs) 35 | self.form = Gui.PySideUic.loadUi(get_ui('config', 'platform.ui')) 36 | self.retranslateUi() 37 | self.refresh() 38 | self.form.pathsInput.textChanged.connect(self.changed) 39 | 40 | 41 | def retranslateUi(self): 42 | self.title = tr("Platform") 43 | self.form.label.setText(tr("Additional python paths (one per line):")) 44 | self.form.labelSystemPaths.setText(tr("Core python paths:")) 45 | 46 | 47 | def refresh(self): 48 | additional = [] 49 | keys = pref.get_user_pref_keys(pref.PLUGIN_KEY, "Platform", "PythonPath", "Path", root="Plugins") 50 | if keys: 51 | for key in keys: 52 | path = pref.get_mnesarco_pref("Platform", "PythonPath", key) 53 | additional.append(path) 54 | 55 | system = [] 56 | for path in sys.path: 57 | if path not in additional: 58 | system.append(path) 59 | 60 | self.form.systemPaths.setText("\r\n".join(system)) 61 | self.form.pathsInput.setPlainText("\r\n".join(additional)) 62 | 63 | 64 | def validate(self): 65 | return True 66 | 67 | 68 | def save(self): 69 | pref.clear_mnesarco_pref("Platform", "PythonPath") 70 | additional = self.form.pathsInput.toPlainText().splitlines() 71 | i = 0 72 | added = set() 73 | for path in additional: 74 | path = path.strip() 75 | if path and path not in added and os.path.exists(path): 76 | pref.set_mnesarco_pref("Platform", "PythonPath", "Path{}".format(i), path) 77 | added.add(path) 78 | i += 1 79 | 80 | -------------------------------------------------------------------------------- /freecad/mnesarco/config/remote.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import re 22 | from freecad.mnesarco.utils.qt import QtCore 23 | from freecad.mnesarco.gui import Gui 24 | from freecad.mnesarco.resources import get_ui, tr 25 | from freecad.mnesarco.utils import preferences as pref 26 | from freecad.mnesarco.utils import networking 27 | from freecad.mnesarco.utils import validation 28 | 29 | 30 | class RemoteConfig(QtCore.QObject): 31 | 32 | changed = QtCore.Signal() 33 | 34 | def __init__(self, *args, **kwargs): 35 | super(RemoteConfig, self).__init__(*args, **kwargs) 36 | self.form = Gui.PySideUic.loadUi(get_ui('config', 'remote.ui')) 37 | self.retranslateUi() 38 | self.refresh() 39 | self.form.port_input.textChanged.connect(self.changed) 40 | 41 | def retranslateUi(self): 42 | self.title = tr("Remote") 43 | self.form.label_banner.setText(tr("Remote Control ({})".format(networking.get_local_ip()))) 44 | self.form.label_port.setText(tr("Port number:")) 45 | 46 | def refresh(self): 47 | port = str(pref.get_mnesarco_pref("Remote", "Port", default=8521)) 48 | self.form.port_input.setText(port) 49 | 50 | def validate(self): 51 | messages = [] 52 | if not validation.validate_int(self.form.port_input.text(), 1000, None, messages): 53 | self.message = tr('Port number: {}').format(messages[0]) 54 | return False 55 | if not validation.validate_required(self.form.port_input.text(), messages): 56 | self.message = tr('Port number: {}').format(messages[0]) 57 | return False 58 | return True 59 | 60 | def save(self): 61 | pref.set_mnesarco_pref("Remote", "Port", int(self.form.port_input.text())) 62 | 63 | -------------------------------------------------------------------------------- /freecad/mnesarco/files/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Frank David Martinez M. 2 | # 3 | # This file is part of Mnesarco Utils. 4 | # 5 | # Mnesarco Utils is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Mnesarco Utils is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Mnesarco Utils. If not, see . 17 | # 18 | 19 | from .files import init_files -------------------------------------------------------------------------------- /freecad/mnesarco/files/files.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 Frank David Martinez M. 2 | # 3 | # This file is part of Mnesarco Utils. 4 | # 5 | # Mnesarco Utils is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Mnesarco Utils is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Mnesarco Utils. If not, see . 17 | # 18 | 19 | from freecad.mnesarco.utils.toolbars import add_global_action 20 | from freecad.mnesarco.resources import Icons, tr 21 | from freecad.mnesarco.utils.extension import App, def_log 22 | 23 | log_err = def_log('Files') 24 | 25 | def init_files(): 26 | add_global_action( 27 | name="SaveAsNextFile", 28 | icon=Icons.save_next, 29 | action=cmd_save_as_next_file, 30 | menu=tr("Save current document and open as next file"), 31 | activation=lambda: App.Gui.activeDocument() 32 | ) 33 | 34 | def cmd_save_as_next_file(): 35 | import re 36 | from pathlib import Path 37 | doc = App.ActiveDocument 38 | try: 39 | doc.save() 40 | except Exception: 41 | App.Gui.SendMsgToActiveView("SaveAs") 42 | return 43 | 44 | name = doc.FileName 45 | sep = r'_next' 46 | pat = re.compile(rf'(.*?)({sep}(\d+))?\.FCStd') 47 | m = pat.fullmatch(name) 48 | if m: 49 | prefix, _, num = m.groups() 50 | num = int(num) + 1 if num is not None else 1 51 | next_name = Path(f"{prefix}{sep}{num:03d}.FCStd") 52 | while next_name.exists(): 53 | num += 1 54 | next_name = Path(f"{prefix}{sep}{num:03d}.FCStd") 55 | doc.saveAs(str(next_name)) 56 | else: 57 | log_err("Only .FCStd files are supported") -------------------------------------------------------------------------------- /freecad/mnesarco/gui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import FreeCADGui as Gui 22 | -------------------------------------------------------------------------------- /freecad/mnesarco/hyperc/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from .hyperc import init_hyperc 22 | 23 | -------------------------------------------------------------------------------- /freecad/mnesarco/hyperc/hyperc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.utils.toolbars import add_global_action 22 | from freecad.mnesarco.resources import Icons, tr 23 | from freecad.mnesarco.hyperc import controller 24 | from freecad.mnesarco import App 25 | from freecad.mnesarco.utils.extension import log 26 | 27 | def init_hyperc(): 28 | 29 | try: 30 | import serial 31 | serial_available = True 32 | except ImportError: 33 | serial_available = False 34 | log(tr("8D Hyper Controller is disabled because the python module 'pyserial' was not found.")) 35 | 36 | 37 | if serial_available: 38 | add_global_action( 39 | name="ToggleHyperController", 40 | icon=Icons.hyperc, 41 | action=lambda: controller.toggle(), 42 | menu=tr("Activate/Deactivate 8D Hyper Controller"), 43 | activation=lambda: App.ActiveDocument 44 | ) 45 | 46 | __all__ = ('init_hyperc') 47 | -------------------------------------------------------------------------------- /freecad/mnesarco/hyperc/wire.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | # +-------------------------------------------------------------------+ 22 | # | Data Record Format | 23 | # | | 24 | # | TAB NEW_LINE | 25 | # +-------------------------------------------------------------------+ 26 | 27 | class Packet: 28 | 29 | # Axes events 30 | X = 1 # X Orthogonal 31 | Y = 2 # Y Orthogonal 32 | Z = 3 # Z Orthogonal 33 | W = 4 # W custom axis 34 | RX = 5 # RX Rotational 35 | RY = 6 # RY Rotational 36 | RZ = 7 # RZ Rotational 37 | RW = 8 # C custom axis 38 | XY0 = 9 # Center of XY Joystick 39 | ZW0 = 10 # Center of ZW Joystick 40 | 41 | # Button Events 42 | BUTTON_XY_CLICK = 50 43 | BUTTON_XY_LONG_PRESS = 51 44 | BUTTON_ZW_CLICK = 60 45 | BUTTON_ZW_LONG_PRESS = 61 46 | BUTTON_A_CLICK = 70 47 | BUTTON_A_LONG_PRESS = 71 48 | BUTTON_B_CLICK = 80 49 | BUTTON_B_LONG_PRESS = 81 50 | BUTTON_C_CLICK = 90 51 | BUTTON_C_LONG_PRESS = 91 52 | 53 | # Knob events 54 | KNOB = 100 55 | 56 | # Other events 57 | COMMENT = 999 58 | 59 | __slots__ = ('event', 'data') 60 | 61 | def __init__(self, line): 62 | self.event = Packet.COMMENT 63 | self.data = 'Idle' 64 | if line: 65 | data = line.decode().rstrip().split('\t') 66 | self.event = int(data[0]) 67 | if data[0] == Packet.COMMENT: 68 | self.data = " ".join(data[1:]) 69 | else: 70 | self.data = int(data[1]) 71 | -------------------------------------------------------------------------------- /freecad/mnesarco/init_gui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.gui import Gui 22 | from freecad.mnesarco.scripts.hook import init_gui_scripts 23 | from freecad.mnesarco.timers import init_gui_timers 24 | from freecad.mnesarco.camera.pov import init_gui_pov 25 | from freecad.mnesarco.utils.platform import init_platform 26 | # from freecad.mnesarco.hyperc import init_hyperc 27 | from freecad.mnesarco.config import init_config 28 | from freecad.mnesarco.remote import init_remote 29 | from freecad.mnesarco.objects import init_objects 30 | from freecad.mnesarco.svg import init_svg 31 | from freecad.mnesarco.files import init_files 32 | 33 | def bootstrap(): 34 | init_platform() 35 | init_gui_scripts() 36 | init_gui_timers() 37 | init_gui_pov() 38 | # init_hyperc() 39 | init_config() 40 | init_remote() 41 | init_objects() 42 | init_svg() 43 | init_files() 44 | 45 | 46 | def bootstrap_hook(wb): 47 | Gui.getMainWindow().workbenchActivated.disconnect(bootstrap_hook) 48 | bootstrap() 49 | 50 | 51 | Gui.getMainWindow().workbenchActivated.connect(bootstrap_hook) 52 | 53 | -------------------------------------------------------------------------------- /freecad/mnesarco/objects/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from .hook import init_objects -------------------------------------------------------------------------------- /freecad/mnesarco/objects/hook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from .named_objects import NamedObjectForm 22 | from freecad.mnesarco.utils.toolbars import add_global_action 23 | from freecad.mnesarco.resources import Icons, tr 24 | from freecad.mnesarco.gui import Gui 25 | 26 | def init_objects(): 27 | add_global_action( 28 | name="NamedObject", 29 | icon=Icons.create_named_object, 30 | action=NamedObjectForm.create, 31 | menu=tr("Create Named Object"), 32 | activation=lambda: True 33 | ) 34 | -------------------------------------------------------------------------------- /freecad/mnesarco/remote/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from .remote import init_remote 22 | -------------------------------------------------------------------------------- /freecad/mnesarco/remote/exports.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import hashlib 22 | from pathlib import Path 23 | 24 | # Mapping from hashes to file paths 25 | allowed_files = {} 26 | 27 | # Mapping from hashes to macro file path 28 | macro_files = {} 29 | 30 | # Mapping from hashes to Workbench names 31 | workbench_keys = {} 32 | 33 | # Mapping from hashes to toolbar names 34 | toolbar_keys = {} 35 | 36 | # Mapping from hashes to action names 37 | action_keys = {} 38 | 39 | def export_file(path): 40 | key = '/' + hashlib.sha256(str(path).encode()).hexdigest() 41 | allowed_files[key] = str(path) 42 | return key 43 | 44 | 45 | def export_macro(macro): 46 | macro_files[macro.key] = macro.file 47 | return macro.key 48 | 49 | 50 | def export_workbench(wb): 51 | key = hashlib.sha256(str(wb.key).encode()).hexdigest() 52 | workbench_keys[key] = wb.key 53 | return key 54 | 55 | 56 | def export_toolbar(toolbar): 57 | key = hashlib.sha256(str(toolbar).encode()).hexdigest() 58 | toolbar_keys[key] = toolbar 59 | return key 60 | 61 | 62 | def export_action(toolbar, action): 63 | key = hashlib.sha256(str(toolbar + "." + action.objectName()).encode()).hexdigest() 64 | action_keys[key] = action 65 | return key 66 | 67 | 68 | def get_exported_action(key): 69 | return action_keys.get(key, None) 70 | 71 | 72 | def get_exported_file(key): 73 | return allowed_files.get(key, key) 74 | 75 | 76 | def get_exported_wb(key): 77 | return workbench_keys.get(key, None) 78 | 79 | 80 | def get_exported_toolbar(key): 81 | return toolbar_keys.get(key, None) 82 | 83 | 84 | def get_exported_macro(key): 85 | path = macro_files.get(key, None) 86 | if path and Path(path).exists(): 87 | return path 88 | 89 | -------------------------------------------------------------------------------- /freecad/mnesarco/remote/page.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | class Page: 22 | 23 | def title(self): 24 | return "Page" 25 | 26 | def sections(self): 27 | return [] 28 | 29 | def stylesheet(self): 30 | return "css/default.css" 31 | 32 | def data(self): 33 | return { 34 | 'title': self.title(), 35 | 'stylesheet': self.stylesheet(), 36 | 'sections': [s.data() for s in self.sections()] 37 | } 38 | 39 | class Section: 40 | 41 | def __init__(self, title, actions): 42 | self.title = title 43 | self.actions = actions 44 | 45 | def data(self): 46 | return { 47 | 'title': self.title, 48 | 'actions': [s.data() for s in self.actions] 49 | } 50 | 51 | class Action: 52 | 53 | def __init__(self, title, icon, action): 54 | self.title = title 55 | self.icon = icon 56 | self.action = action 57 | 58 | def data(self): 59 | return self.__dict__ -------------------------------------------------------------------------------- /freecad/mnesarco/remote/remote.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.utils.toolbars import add_global_action 22 | from freecad.mnesarco.resources import Icons, tr 23 | from freecad.mnesarco import App 24 | 25 | def start(): 26 | from freecad.mnesarco.remote.server import start_remote_server 27 | start_remote_server() 28 | 29 | 30 | def init_remote(): 31 | 32 | add_global_action( 33 | name="Remote", 34 | icon=Icons.remote, 35 | action=start, 36 | menu=tr("Start Remote Control Server"), 37 | activation=lambda: App.ActiveDocument 38 | ) 39 | 40 | __all__ = ('init_remote') 41 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/MnesarcoUtils.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/config.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/create_named_object.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/fc_create_body.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/fc_create_part.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/fc_create_spreadsheet.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/remote.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/icons/timer.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/style/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import re 22 | 23 | def merge(template, values): 24 | return re.sub(r'\{\{(\w+)\}\}', lambda m: str(values[m.group(1)]), template) 25 | 26 | 27 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/style/py_editor.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from . import merge 22 | 23 | base_background = "#eeeeee" 24 | 25 | styles = dict( 26 | background = base_background, 27 | text = "#222222", 28 | font_size = 12, 29 | scrollbar_background = "transparent", 30 | scrollbar_width = 15, 31 | scrollbar_handle_min_size = 20, 32 | scrollbar_handle_color = "#222222", 33 | scrollbar_border = "0px solid transparent", 34 | ) 35 | 36 | template = """ 37 | QWidget { 38 | background: {{background}}; 39 | color: {{text}}; 40 | font-size: {{font_size}}pt; 41 | font-family: Courier 42 | } 43 | 44 | QScrollBar:horizontal { 45 | border: {{scrollbar_border}}; 46 | background: {{scrollbar_background}}; 47 | height: {{scrollbar_width}}px; 48 | margin: 0 {{scrollbar_width}}px 0 0; 49 | } 50 | 51 | QScrollBar:vertical { 52 | border: {{scrollbar_border}}; 53 | background: {{scrollbar_background}}; 54 | width: {{scrollbar_width}}px; 55 | margin: 0 0 {{scrollbar_width}}px 0; 56 | } 57 | 58 | QScrollBar::handle:horizontal { 59 | background: {{scrollbar_handle_color}}; 60 | min-width: {{scrollbar_handle_min_size}}px; 61 | } 62 | 63 | QScrollBar::handle:vertical { 64 | background: {{scrollbar_handle_color}}; 65 | min-height: {{scrollbar_handle_min_size}}px; 66 | } 67 | 68 | """ 69 | 70 | stylesheet = merge(template, styles) 71 | 72 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/templates/scripts/default_script.py.txt: -------------------------------------------------------------------------------- 1 | # In this python script you can define independent 2 | # variables and time dependent functions. 3 | # 4 | # global variable TIME contains the current Tick. 5 | 6 | print(TIME) 7 | 8 | # To define a read/write independent variable: 9 | # define a python variable in the global scope 10 | 11 | scale = 2.0 12 | other = [5,10,15] 13 | my_options = ('Top', 'Right', 'Bottom', 'Left') 14 | name = "Hello" 15 | 16 | # To define a time dependent variable or a variable 17 | # dependent on other variables: 18 | # define a python function 19 | 20 | def Diameter(): 21 | return TIME * scale 22 | 23 | def Angle(): 24 | return (Diameter() * 5) % 360 25 | 26 | 27 | # To create not exposed functions or variables, 28 | # define a class to simulate a private namespace 29 | 30 | class private: 31 | 32 | my_private_var = 80 33 | 34 | def private_func(): 35 | pass 36 | 37 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/camera/PointsOfViewPanel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Add 27 | 28 | 29 | 30 | 31 | 32 | 33 | Update 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/config/hyperc.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 526 10 | 268 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Hyper Controller 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | true 34 | 35 | 36 | 37 | 38 | 0 39 | 0 40 | 506 41 | 208 42 | 43 | 44 | 45 | 46 | 47 | 48 | Port 49 | 50 | 51 | 52 | 53 | 54 | 55 | Baud rate 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/config/platform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 434 10 | 354 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | Additional Python Paths 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Core System Paths 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/config/remote.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 526 10 | 268 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Remote 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | true 34 | 35 | 36 | 37 | 38 | 0 39 | 0 40 | 506 41 | 208 42 | 43 | 44 | 45 | 46 | 47 | 48 | Port 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/objects/NamedObject.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Type: 30 | 31 | 32 | 33 | 34 | 35 | 36 | Name: 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | Qt::Horizontal 47 | 48 | 49 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/css/base.css: -------------------------------------------------------------------------------- 1 | /** 2 | * -*- coding: utf-8 -*- 3 | * 4 | * Copyright (C) 2021 Frank David Martinez M. 5 | * 6 | * This file is part of Mnesarco Utils. 7 | * 8 | * Mnesarco Mnesarco Utils is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Mnesarco Utils is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Mnesarco Utils. If not, see . 20 | * 21 | */ 22 | 23 | 24 | 25 | 26 | body { 27 | background-color: #000000; 28 | color: #ffffff; 29 | padding: 0px; 30 | margin: 0px; 31 | } 32 | 33 | .button, .button-wide { 34 | margin: 2px; 35 | padding: 5px; 36 | float: left; 37 | text-align: center; 38 | font-size: 0.7em; 39 | background: #333333; 40 | border: 1px solid #000000; 41 | border-radius: 4px; 42 | overflow: hidden; 43 | position: relative; 44 | height: 70px; 45 | } 46 | 47 | .section-header { 48 | margin: 2px; 49 | float: left; 50 | text-align: center; 51 | font-size: 0.7em; 52 | background: #FCE94F; 53 | border: 1px solid #444444; 54 | border-radius: 4px; 55 | overflow: hidden; 56 | position: relative; 57 | height: 80px; 58 | width: 4px; 59 | } 60 | 61 | .button { 62 | width: 64px; 63 | } 64 | 65 | .button-wide { 66 | width: 112px; 67 | } 68 | 69 | .button img, .button-wide img { 70 | width: 32px; 71 | height: 32px; 72 | margin-top: 5px; 73 | margin-left: auto; 74 | margin-right: auto; 75 | display: block; 76 | } 77 | 78 | .button span, .button-wide span { 79 | display: block; 80 | padding-left: 5px; 81 | padding-right: 5px; 82 | bottom: 5px; 83 | left: 0px; 84 | right: 0px; 85 | position: absolute; 86 | overflow: hidden; 87 | text-align: center; 88 | } 89 | 90 | .toolbar { 91 | width: 100%; 92 | background: #333333; 93 | padding: 0; 94 | margin: 0; 95 | position: fixed; 96 | top: 0; 97 | z-index: 999999; 98 | } 99 | 100 | .toolbar .tb-btn { 101 | float: left; 102 | width: 48px; 103 | height: 48px; 104 | margin: 7px; 105 | } 106 | 107 | .toolbar .tb-btn img { 108 | width: 100%; 109 | height: 100%; 110 | } 111 | 112 | .toolbar-sep { 113 | background: #000000; 114 | height: 6px; 115 | border-top: 1px solid #909090; 116 | width: 100%; 117 | } 118 | 119 | .toolbar-container { 120 | padding: 5px; 121 | } 122 | 123 | #fc-root { 124 | margin-top: 80px; 125 | } -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/css/compact.css: -------------------------------------------------------------------------------- 1 | /** 2 | * -*- coding: utf-8 -*- 3 | * 4 | * Copyright (C) 2021 Frank David Martinez M. 5 | * 6 | * This file is part of Mnesarco Utils. 7 | * 8 | * Mnesarco Utils is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Utils is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Mnesarco Utils. If not, see . 20 | * 21 | */ 22 | 23 | 24 | body { 25 | background-color: #000000; 26 | color: #ffffff; 27 | padding: 0px; 28 | margin: 0px; 29 | } 30 | 31 | .button, .button-wide { 32 | margin: 2px; 33 | padding: 5px; 34 | float: left; 35 | text-align: center; 36 | font-size: 0.7em; 37 | background: #333333; 38 | border: 1px solid #000000; 39 | border-radius: 4px; 40 | overflow: hidden; 41 | position: relative; 42 | height: 48px; 43 | } 44 | 45 | .section-header { 46 | margin: 2px; 47 | float: left; 48 | text-align: center; 49 | font-size: 0.7em; 50 | background: #FCE94F; 51 | border: 1px solid #444444; 52 | border-radius: 4px; 53 | overflow: hidden; 54 | position: relative; 55 | height: 58px; 56 | width: 4px; 57 | } 58 | 59 | .button { 60 | width: 48px; 61 | } 62 | 63 | .button-wide { 64 | width: 48px; 65 | } 66 | 67 | .button img, .button-wide img { 68 | width: 32px; 69 | height: 32px; 70 | margin-top: 5px; 71 | margin-left: auto; 72 | margin-right: auto; 73 | display: block; 74 | } 75 | 76 | .button span, .button-wide span { 77 | display: none; 78 | } 79 | 80 | .toolbar { 81 | width: 100%; 82 | background: #333333; 83 | padding: 0; 84 | margin: 0; 85 | position: fixed; 86 | top: 0; 87 | z-index: 999999; 88 | } 89 | 90 | .toolbar .tb-btn { 91 | float: left; 92 | width: 48px; 93 | height: 48px; 94 | margin: 7px; 95 | } 96 | 97 | .toolbar .tb-btn img { 98 | width: 100%; 99 | height: 100%; 100 | } 101 | 102 | .toolbar-sep { 103 | background: #000000; 104 | height: 6px; 105 | border-top: 1px solid #909090; 106 | width: 100%; 107 | } 108 | 109 | .toolbar-container { 110 | padding: 5px; 111 | } 112 | 113 | #fc-root { 114 | margin-top: 80px; 115 | } -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/css/default.css: -------------------------------------------------------------------------------- 1 | /** 2 | * -*- coding: utf-8 -*- 3 | * 4 | * Copyright (C) 2021 Frank David Martinez M. 5 | * 6 | * This file is part of Mnesarco Utils. 7 | * 8 | * Mnesarco Utils is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Utils is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Mnesarco Utils. If not, see . 20 | * 21 | */ 22 | 23 | 24 | body { 25 | background-color: #000000; 26 | color: #ffffff; 27 | padding: 0px; 28 | margin: 0px; 29 | } 30 | 31 | .button, .button-wide { 32 | margin: 2px; 33 | padding: 5px; 34 | float: left; 35 | text-align: center; 36 | font-size: 0.7em; 37 | background: #333333; 38 | border: 1px solid #000000; 39 | border-radius: 4px; 40 | overflow: hidden; 41 | position: relative; 42 | height: 70px; 43 | } 44 | 45 | .section-header { 46 | margin: 2px; 47 | float: left; 48 | text-align: center; 49 | font-size: 0.7em; 50 | background: #FCE94F; 51 | border: 1px solid #444444; 52 | border-radius: 4px; 53 | overflow: hidden; 54 | position: relative; 55 | height: 80px; 56 | width: 4px; 57 | } 58 | 59 | .button { 60 | width: 64px; 61 | } 62 | 63 | .button-wide { 64 | width: 112px; 65 | } 66 | 67 | .button img, .button-wide img { 68 | width: 32px; 69 | height: 32px; 70 | margin-top: 5px; 71 | margin-left: auto; 72 | margin-right: auto; 73 | display: block; 74 | } 75 | 76 | .button span, .button-wide span { 77 | display: block; 78 | padding-left: 5px; 79 | padding-right: 5px; 80 | bottom: 5px; 81 | left: 0px; 82 | right: 0px; 83 | position: absolute; 84 | overflow: hidden; 85 | text-align: center; 86 | } 87 | 88 | .toolbar { 89 | width: 100%; 90 | background: #333333; 91 | padding: 0; 92 | margin: 0; 93 | position: fixed; 94 | top: 0; 95 | z-index: 999999; 96 | } 97 | 98 | .toolbar .tb-btn { 99 | float: left; 100 | width: 48px; 101 | height: 48px; 102 | margin: 7px; 103 | } 104 | 105 | .toolbar .tb-btn img { 106 | width: 100%; 107 | height: 100%; 108 | } 109 | 110 | .toolbar-sep { 111 | background: #000000; 112 | height: 6px; 113 | border-top: 1px solid #909090; 114 | width: 100%; 115 | } 116 | 117 | .toolbar-container { 118 | padding: 5px; 119 | } 120 | 121 | #fc-root { 122 | margin-top: 80px; 123 | } -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mnesarco/FreeCAD_Utils/3096185014a9228093316496eef116a396f936c1/freecad/mnesarco/resources/ui/remote/favicon.ico -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mnesarco/FreeCAD_Utils/3096185014a9228093316496eef116a396f936c1/freecad/mnesarco/resources/ui/remote/img/ajax-loader.gif -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/gen_macro_icons.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | pattern = 'macro-icon-{}.svg' 4 | 5 | colors = [ 6 | '#FCE94F', 7 | '#8AE234', 8 | '#FCAF3E', 9 | '#729FCF', 10 | '#AD7FA8', 11 | '#E9B96E', 12 | '#34E0E2', 13 | '#FFFFFF', 14 | ] 15 | 16 | base = 12 17 | 18 | root = Path('.') 19 | current = base + 1 20 | for color in colors: 21 | for i in range(1,base+1): 22 | source = root.joinpath(pattern.format(i)) 23 | print("Source ", source) 24 | svg = source.read_text() 25 | svg2 = svg.replace('fill="#f00"', 'fill="{}"'.format(color)) 26 | root.joinpath(pattern.format(current)).write_text(svg2) 27 | current += 1 -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-10.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-100.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-101.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-102.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-103.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-104.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-105.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-106.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-107.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-108.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-11.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-12.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-13.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-14.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-16.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-17.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-18.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-19.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-20.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-21.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-22.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-23.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-24.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-25.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-26.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-27.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-28.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-29.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-30.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-31.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-32.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-33.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-34.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-35.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-36.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-37.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-38.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-39.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-4.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-40.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-41.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-42.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-45.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-46.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-47.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-48.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-49.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-5.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-50.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-51.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-52.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-53.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-54.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-55.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-56.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-57.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-58.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-59.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-6.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-60.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-61.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-62.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-63.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-64.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-65.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-66.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-67.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-68.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-69.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-7.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-70.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-71.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-72.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-73.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-74.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-75.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-76.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-77.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-78.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-79.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-8.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-80.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-81.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-82.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-83.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-84.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-85.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-86.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-87.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-88.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-89.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-9.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-90.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-91.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-92.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-93.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-94.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-95.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-96.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-97.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-98.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro-icon-99.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/macro.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/noicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/pages.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/img/pin_gray.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/index.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 25 | FreeCAD Macro Pad 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 |
38 | 41 |
42 | Macros 43 |
44 |
45 | Workbenches 46 |
47 |
48 | Wake lock 49 |
50 |
51 |
52 |
53 |
54 | 55 |
56 | 57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/remote/js/NoSleep/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Rich Tibbett 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/scripts/CreatePanel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 160 11 | 12 | 13 | 14 | Create Data Store for variables 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | QFrame::StyledPanel 24 | 25 | 26 | QFrame::Raised 27 | 28 | 29 | 30 | QLayout::SetMaximumSize 31 | 32 | 33 | 34 | 35 | Name: 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | QFrame::StyledPanel 49 | 50 | 51 | QFrame::Raised 52 | 53 | 54 | 55 | 56 | 57 | The name of the store will be used in expressions, it must be unique and cannot be changed later. 58 | 59 | 60 | Qt::PlainText 61 | 62 | 63 | true 64 | 65 | 66 | 67 | 68 | 69 | 70 | QLabel { background-color : white; color : red; padding: 3 } 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | 0 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/timers/CreatePanel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 160 11 | 12 | 13 | 14 | Create Data Store for variables 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | QFrame::StyledPanel 24 | 25 | 26 | QFrame::Raised 27 | 28 | 29 | 30 | QLayout::SetMaximumSize 31 | 32 | 33 | 34 | 35 | Name: 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | QFrame::StyledPanel 49 | 50 | 51 | QFrame::Raised 52 | 53 | 54 | 55 | 56 | 57 | label_descr 58 | 59 | 60 | Qt::PlainText 61 | 62 | 63 | true 64 | 65 | 66 | 67 | 68 | 69 | 70 | QLabel { background-color : white; color : red; padding: 3 } 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | 0 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /freecad/mnesarco/resources/ui/timers/TimerSliderPanel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 78 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Qt::Horizontal 30 | 31 | 32 | QSlider::TicksAbove 33 | 34 | 35 | 1 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /freecad/mnesarco/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | """ 22 | Extension to add python scripts that export vars and functions to be used in expressions. 23 | """ 24 | -------------------------------------------------------------------------------- /freecad/mnesarco/scripts/hook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco import App 22 | from freecad.mnesarco.utils import toolbars 23 | from freecad.mnesarco.resources import Icons, tr 24 | from freecad.mnesarco.scripts.script import ScriptObject 25 | 26 | def init_gui_scripts(): 27 | toolbars.add_global_action( 28 | name="CreatePyScript", 29 | icon=Icons.variables, 30 | action=ScriptObject.create, 31 | menu=tr("Create Python Script"), 32 | activation=lambda: App.ActiveDocument and App.ActiveDocument.FileName) 33 | -------------------------------------------------------------------------------- /freecad/mnesarco/svg/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | """ 22 | SVG manipulation utilities 23 | """ 24 | 25 | from .hook import init_svg -------------------------------------------------------------------------------- /freecad/mnesarco/svg/hook.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco import App 22 | from freecad.mnesarco.utils import toolbars 23 | from freecad.mnesarco.resources import Icons, tr 24 | 25 | def create(): 26 | from .svg_file import SvgFile 27 | import FreeCADGui as Gui # type: ignore 28 | obj = SvgFile.create("SvgFile") 29 | Gui.Selection.clearSelection() 30 | Gui.Selection.addSelection(App.ActiveDocument.Name, obj.Name) 31 | 32 | 33 | def init_svg(): 34 | toolbars.add_global_action( 35 | name="CreateSvgFileObject", 36 | icon=Icons.svg, 37 | action=create, 38 | menu=tr("Create Svg File Object"), 39 | activation=lambda: App.ActiveDocument) 40 | -------------------------------------------------------------------------------- /freecad/mnesarco/svg/parser.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from typing import Dict, List 22 | from xml.sax.handler import ContentHandler 23 | import xml.sax 24 | import xml.parsers.expat 25 | from itertools import chain 26 | 27 | class Group: 28 | xml_id: str 29 | children: List['Group'] 30 | ids: List[str] 31 | 32 | def __init__(self, xml_id: str) -> None: 33 | self.xml_id = xml_id 34 | self.children = [] 35 | self.ids = [] 36 | 37 | def get_ids(self) -> List[str]: 38 | ids = [*self.ids] 39 | for sub in self.children: 40 | ids += sub.get_ids() 41 | return ids 42 | 43 | class ExactGroups(ContentHandler): 44 | groups: Dict[str, Group] 45 | 46 | def __init__(self): 47 | self.groups = dict() 48 | self.stack = [Group('***')] 49 | 50 | def startElement(self, name, attrs): 51 | if 'id' in attrs: 52 | xml_id = attrs['id'] 53 | if not xml_id: 54 | return 55 | if name == 'g': 56 | g = Group(xml_id) 57 | self.stack[-1].children.append(g) 58 | self.stack.append(g) 59 | self.groups[xml_id] = g 60 | else: 61 | self.stack[-1].ids.append(xml_id) 62 | 63 | 64 | def endElement(self, name): 65 | if name == 'g' and len(self.stack) > 1: 66 | self.stack.pop() 67 | 68 | 69 | def parse_svg_groups(file_name: str) -> Dict[str, List[str]]: 70 | """ 71 | Parse the SVG file and extract a mapping of group and its children. 72 | 73 | :param str file_name: svg file path 74 | :return Dict[str, List[str]]: Map of group id to all children ids 75 | """ 76 | parser = xml.sax.make_parser() 77 | handler = ExactGroups() 78 | parser.setContentHandler(handler) 79 | with open(file_name) as svg: 80 | parser.parse(svg) 81 | return handler.groups 82 | -------------------------------------------------------------------------------- /freecad/mnesarco/timers/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from .timer import init_gui_timers 22 | -------------------------------------------------------------------------------- /freecad/mnesarco/timers/dialogs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import re 22 | from freecad.mnesarco import App 23 | from freecad.mnesarco.gui import Gui 24 | from freecad.mnesarco.resources import get_ui, tr 25 | 26 | 27 | class CreatePanel: 28 | 29 | VALID_NAME = re.compile(r'[a-zA-Z]\w+') 30 | 31 | def __init__(self, builder): 32 | self.form = Gui.PySideUic.loadUi(get_ui('timers', 'CreatePanel.ui')) 33 | self.form.setWindowTitle(tr('Create Timer')) 34 | self.form.label.setText(tr('Name:')) 35 | self.form.label_descr.setText(tr('The name will be used in expressions, it must be unique and cannot be changed later.')) 36 | self.form.errorMessage.setVisible(False) 37 | self.builder = builder 38 | 39 | def accept(self): 40 | self.form.errorMessage.setVisible(False) 41 | name = self.form.nameInput.text() 42 | if name and CreatePanel.VALID_NAME.match(name): 43 | if not App.ActiveDocument: 44 | App.newDocument() 45 | if not App.ActiveDocument.getObject(name): 46 | Gui.Control.closeDialog() 47 | self.create(name) 48 | else: 49 | self.form.errorMessage.setVisible(True) 50 | self.form.errorMessage.setText(tr("Duplicated name is not valid")) 51 | else: 52 | self.form.errorMessage.setVisible(True) 53 | self.form.errorMessage.setText(tr("Invalid name")) 54 | 55 | def create(self, name): 56 | self.builder(name) 57 | 58 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | """ 22 | API abstractions and utility methods/objects 23 | """ -------------------------------------------------------------------------------- /freecad/mnesarco/utils/dialogs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from PySide import QtCore, QtGui 22 | 23 | 24 | def error_dialog(msg, raise_exception=False, exception=None): 25 | diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error', msg) 26 | diag.setWindowModality(QtCore.Qt.ApplicationModal) 27 | diag.exec_() 28 | if raise_exception: 29 | raise(Exception(msg)) 30 | if exception: 31 | raise(exception) 32 | 33 | def message_dialog(msg): 34 | diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, 'Info', msg) 35 | diag.setWindowModality(QtCore.Qt.ApplicationModal) 36 | diag.exec_() 37 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/files.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from pathlib import Path 22 | 23 | 24 | def resolve_path(file, reference_file): 25 | """Returns absolute path to `file`, using `reference_file` to resolve relative paths""" 26 | file_path = Path(file) 27 | if not file_path.is_absolute(): 28 | file_path = Path(reference_file).parent.joinpath(file_path) 29 | return file_path 30 | 31 | 32 | def make_path_relative(path, reference_path): 33 | return Path(path).relative_to(Path(reference_path).parent) 34 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/math.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | def cmp(a, b): 22 | """Classic cmp returns -1, 0, 1""" 23 | return (a > b) - (a < b) 24 | 25 | 26 | def sign(a, b): 27 | """Classic sign of `b` - `a`""" 28 | if a > b: 29 | return -1 30 | else: 31 | return 1 -------------------------------------------------------------------------------- /freecad/mnesarco/utils/menus.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.utils.qt import QtGui 22 | from freecad.mnesarco.gui import Gui 23 | 24 | 25 | def find_or_add(root, name): 26 | for menu in root.findChildren(QtGui.QMenu): 27 | if menu.title() == name: 28 | return menu 29 | return root.addMenu(name) 30 | 31 | 32 | def add_menu(path, text, icon, handle): 33 | 34 | window = Gui.getMainWindow() 35 | bar = window.menuBar() 36 | menu = bar 37 | 38 | for name in path: 39 | menu = find_or_add(menu, name) 40 | 41 | for action in menu.actions(): 42 | if action.text() == text: 43 | menu.removeAction(action) 44 | break 45 | 46 | action = QtGui.QAction(QtGui.QIcon(icon), text, window.menuBar()) 47 | menu.addAction(action) 48 | action.triggered.connect(handle) 49 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/networking.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import socket 22 | 23 | 24 | def get_local_ip(): 25 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 26 | ip = None 27 | try: 28 | s.connect(("10.255.255.255", 1)) 29 | ip = s.getsockname()[0] 30 | except BaseException: 31 | ip = '127.0.0.1' 32 | finally: 33 | s.close() 34 | return ip 35 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/platform.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import sys 22 | import freecad.mnesarco.utils.preferences as pref 23 | from freecad.mnesarco.utils.extension import log 24 | from freecad.mnesarco.resources import tr 25 | 26 | 27 | def add_python_path(path): 28 | sys.path.insert(0, path) 29 | 30 | 31 | def add_additional_python_paths(): 32 | keys = pref.get_user_pref_keys(pref.PLUGIN_KEY, "Platform", "PythonPath", "Path", root="Plugins") 33 | if keys: 34 | for key in keys: 35 | path = pref.get_mnesarco_pref("Platform", "PythonPath", key) 36 | log(tr("[Python Path] Adding {}").format(path)) 37 | add_python_path(path) 38 | 39 | 40 | def init_platform(): 41 | add_additional_python_paths() 42 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/qt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from PySide import QtGui, QtCore 22 | from freecad.mnesarco.resources import Icons 23 | import re 24 | import tempfile 25 | from pathlib import Path 26 | import hashlib 27 | 28 | Qt = QtCore.Qt 29 | 30 | PIXMAP_PATTERN = re.compile(r'"([^"]*)"') 31 | 32 | def BasicQIcon(path): 33 | qicon = QtGui.QIcon() 34 | qicon.addPixmap(QtGui.QPixmap(str(path)), QtGui.QIcon.Normal, QtGui.QIcon.Off) 35 | return qicon 36 | 37 | 38 | def BasicListItem(text, icon=None, data=None, editable=False): 39 | qicon = BasicQIcon(icon or Icons.generic) 40 | item = QtGui.QListWidgetItem(qicon, text) 41 | item.setData(Qt.UserRole, str(data)) 42 | if editable: 43 | item.setFlags(item.flags() | Qt.ItemIsEditable) 44 | return item 45 | 46 | 47 | def pixmap_to_png(xpm): 48 | name = '{0}.png'.format(hashlib.md5(xpm.encode()).hexdigest()) 49 | tmp = Path(tempfile.gettempdir()).joinpath(name) 50 | if tmp.exists(): 51 | return str(tmp) 52 | else: 53 | tmp = str(tmp) 54 | data = PIXMAP_PATTERN.findall(xpm) 55 | pixmap = QtGui.QPixmap(data) 56 | pixmap.save(tmp, 'PNG') 57 | return tmp 58 | 59 | 60 | def extract_action_pixmap(action, size): 61 | name = '{0}.png'.format(action.objectName()) 62 | tmp = Path(tempfile.gettempdir()).joinpath(name) 63 | if tmp.exists(): 64 | return str(tmp) 65 | else: 66 | tmp = str(tmp) 67 | try: 68 | pixmap = action.icon().pixmap(size) 69 | pixmap.save(tmp, 'PNG') 70 | return tmp 71 | except BaseException: 72 | return None 73 | 74 | class SignalObject(QtCore.QObject): 75 | 76 | activate = QtCore.Signal(tuple) 77 | 78 | def __init__(self, *args, **kwargs): 79 | super(SignalObject, self).__init__(*args, **kwargs) 80 | 81 | def forward(self, target): 82 | self.activate.connect(target) 83 | 84 | def trigger(self, *args): 85 | self.activate.emit(tuple(args)) 86 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/signal.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.utils.math import cmp 22 | 23 | class DataSignal: 24 | 25 | RISING = '/' 26 | STEADY = '-' 27 | FALLING = '\\' 28 | MONOTONIC = '.' 29 | 30 | __slots__ = ('value', 'sensitivity', 'rising', 'falling', 'steady', 'data') 31 | 32 | def __init__(self, sensitivity=0): 33 | self.value = (0.0, 0.0) 34 | self.sensitivity = sensitivity 35 | self.steady = lambda to: None 36 | self.rising = lambda mag, to: None 37 | self.falling = lambda mag, to: None 38 | self.data = lambda mag, d: None 39 | 40 | 41 | def dispatch(self, c): 42 | 43 | """Dispatch events: rising, falling, steady, data""" 44 | 45 | a, b = self.value 46 | 47 | mag = abs(c - b) 48 | if mag < self.sensitivity: 49 | b = c 50 | mag = 0 51 | 52 | old_dir, new_dir = cmp(b, a), cmp(c, b) 53 | self.value = b, c 54 | 55 | if old_dir != new_dir: 56 | if old_dir < 0 and new_dir > 0: 57 | self.rising(mag, c) 58 | elif new_dir < 0 and old_dir > 0: 59 | self.falling(mag, c) 60 | else: 61 | self.steady(c) 62 | 63 | if mag > 0: 64 | self.data(mag, c) 65 | 66 | 67 | def proc(self, c): 68 | 69 | """ Returns a tuple (Event, Magnitude, Point)""" 70 | 71 | a, b = self.value 72 | 73 | mag = abs(c - b) 74 | if mag < self.sensitivity: 75 | b = c 76 | mag = 0 77 | 78 | old_dir, new_dir = cmp(b, a), cmp(c, b) 79 | self.value = b, c 80 | 81 | if old_dir == new_dir and old_dir != 0: 82 | return DataSignal.MONOTONIC, mag * new_dir, c 83 | elif new_dir > 0: 84 | return DataSignal.RISING, mag, c 85 | elif new_dir < 0: 86 | return DataSignal.FALLING, mag, c 87 | else: 88 | return DataSignal.STEADY, mag, c 89 | 90 | 91 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/strings.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import re 22 | 23 | def camel_terms(value): 24 | return re.findall('[A-Z][a-z]+|[0-9A-Z]+(?=[A-Z][a-z])|[0-9A-Z]{2,}|[a-z0-9]{2,}|[a-zA-Z0-9]', value) 25 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/timers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | from freecad.mnesarco.utils.qt import QtCore 22 | 23 | _timers = set() 24 | 25 | def execute_later(fn, delay=1): 26 | t = QtCore.QTimer() 27 | def timeout(): 28 | _timers.remove(t) 29 | t.deleteLater() 30 | fn() 31 | _timers.add(t) 32 | t.singleShot(delay, timeout) 33 | -------------------------------------------------------------------------------- /freecad/mnesarco/utils/validation.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2021 Frank David Martinez M. 4 | # 5 | # This file is part of Mnesarco Utils. 6 | # 7 | # Mnesarco Utils is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # Mnesarco Utils is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with Mnesarco Utils. If not, see . 19 | # 20 | 21 | import re 22 | from freecad.mnesarco.resources import tr 23 | 24 | INTEGER = re.compile(r'^-?\d+$') 25 | FLOAT = re.compile(r'^-?\d+(\.\d+)$') 26 | 27 | def push_message(messages, message): 28 | if messages is not None: 29 | messages.append(message) 30 | 31 | def validate_num(value, converter, pattern, messages, min, max, name): 32 | if not pattern.match(value): 33 | push_message(messages, tr('Invalid {}').format(name)) 34 | return False 35 | numval = converter(value) 36 | if min is not None and min > numval: 37 | push_message(messages, tr('Minimum allowed is {}').format(min)) 38 | return False 39 | if max is not None and max < numval: 40 | push_message(messages, tr('Maximum allowed is {}').format(max)) 41 | return False 42 | return True 43 | 44 | 45 | def validate_int(value, min=None, max=None, messages=None): 46 | return validate_num(value, int, INTEGER, messages, min, max, 'Integer') 47 | 48 | def validate_float(value, min=None, max=None, messages=None): 49 | return validate_num(value, float, FLOAT, messages, min, max, 'Number') 50 | 51 | def validate_required(value, messages=None): 52 | if not value or not str(value).strip(): 53 | push_message(messages, tr('Required')) 54 | return False 55 | return True -------------------------------------------------------------------------------- /manifest.ini: -------------------------------------------------------------------------------- 1 | ;*************************************************************************** 2 | ;* Meta Section * 3 | ;* General identification metadata * 4 | ;*************************************************************************** 5 | [general] 6 | version=0.2.15 7 | name=MnesarcoUtils 8 | title=Mnesarco Utils 9 | description=General purpose utilities and device drivers for FreeCAD 10 | iconPath=freecad/mnesarco/resources/icons/MnesarcoUtils.svg 11 | license=GPLv3 12 | licensePath=LICENSE 13 | authors=Frank Martinez 14 | categories=FreeCAD UI 15 | homepage=https://github.com/mnesarco/FreeCAD_Utils 16 | 17 | ;*************************************************************************** 18 | ;* Packages dependencies * 19 | ;*************************************************************************** 20 | [dependencies] 21 | workbenches= 22 | pylibs= 23 | optionalpylibs= 24 | external= 25 | 26 | ;*************************************************************************** 27 | ;* Install * 28 | ;*************************************************************************** 29 | [install] 30 | notesPath=README.md 31 | mode=git 32 | checkUpdates=true 33 | 34 | ;*************************************************************************** 35 | ;* Git config * 36 | ;*************************************************************************** 37 | [git] 38 | repository=https://github.com/mnesarco/FreeCAD_Utils.git 39 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mnesarco Utils 4 | A collection of tools mainly dedicated to scripting and experiments. 5 | 0.2.16 6 | Frank Martinez 7 | GPL-3.0 8 | https://github.com/mnesarco/FreeCAD_Utils 9 | https://github.com/mnesarco/FreeCAD_Utils/blob/main/README.md 10 | freecad/mnesarco/resources/icons/MnesarcoUtils.svg 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------