Example #1
0
def addIconToFCAD(iconFile, path=None):
    if not path:
        path = iconPath
    try:
        path = os.path.join(path, iconFile)
        FreeCADGui.addIcon(path, path)
    except AssertionError:
        pass
    return path
Example #2
0
    def Initialize(self):
        import FreeCADGui
        import MachinekitPreferences
        FreeCADGui.addPreferencePage(MachinekitPreferences.Page, 'Machinekit')
        FreeCADGui.addIcon('preferences-machinekit', self.Icon)

        import MachinekitCommands
        MachinekitCommands.SetupToolbar(self)
        MachinekitCommands.SetupMenu(self)
        pass
Example #3
0
def addIconToFCAD(iconFile, path=None):
    iconName = ':asm3/icons/' + iconFile
    if not path:
        path = iconPath
    try:
        path = os.path.join(path, iconFile)
        FreeCADGui.addIcon(iconName, path)
    except AssertionError:
        pass
    return iconName
def Setup():
    global _setup
    if not _setup:
        import FreeCADGui
        import machinekit

        icon = machinekit.FileResource('machinekiticon.svg')
        FreeCADGui.addIcon('preferences-machinekit', icon)
        FreeCADGui.addPreferencePage(PageGeneral, 'Machinekit')
        FreeCADGui.addPreferencePage(PageHUD, 'Machinekit')
        _setup = True
Example #5
0
def getIcon(obj, disabled=False, path=None):
    if not path:
        path = iconPath
    if not getattr(obj, '_icon', None):
        obj._icon = addIconToFCAD(obj._iconName, path)
    if not disabled:
        return obj._icon
    if not getattr(obj, '_iconDisabled', None):
        name = getattr(obj, '_iconDisabledName', None)
        if name:
            obj._iconDisabled = addIconToFCAD(name, path)
        else:
            key = os.path.join(path, obj._iconName) + '.disabled'
            fmt = None
            try:
                if FreeCADGui.isIconCached(key):
                    obj._iconDisabled = key
                    return key
                else:
                    fmt = 'PNG'
            except Exception:
                pass
            pixmap = FreeCADGui.getIcon(obj._icon).pixmap(*iconSize,
                                                          mode=QIcon.Disabled)
            icon = QIcon(pixmapDisabled)
            icon.paint(QPainter(pixmap), 0, 0, iconSize[0], iconSize[1],
                       Qt.AlignCenter)
            data = QByteArray()
            buf = QBuffer(data)
            buf.open(QIODevice.WriteOnly)
            if fmt:
                pixmap.save(buf, fmt)
                FreeCADGui.addIcon(key, data.data(), fmt)
            else:
                pixmap.save(buf, 'XPM')
                key = data.data().decode('latin1')
            obj._iconDisabled = key
    return obj._iconDisabled
Example #6
0
    def Initialize(self):
        import os
        import FreeCAD as App
        import FreeCADGui as Gui
        import MBDyn_locator
        MBDwbPath = os.path.dirname(MBDyn_locator.__file__)
        MBDwb_icons_path = os.path.join(MBDwbPath, 'icons')
        MBDwb_setting_ui_path = os.path.join(MBDwbPath, 'resources','wb_settings_widgets')
        import MBDyn_guitools.m_values
        import MBDyn_guitools.MBDynFreeCAD
        import MBDyn_guitools.body_AS4_cmd
        import MBDyn_guitools.ref_cmd
        import MBDyn_guitools.struct_node_cmd
        import MBDyn_guitools.revpin_joint_AS4_2_cmd
        import MBDyn_guitools.hinge_joint_AS4_cmd
        import MBDyn_guitools.postproc_AS4_cmd
        import MBDyn_guitools.total_joint_cmd
        import MBDyn_guitools.total_pinjoint_cmd
        import MBDyn_guitools.inline_joint_cmd
        import MBDyn_guitools.ramp_drive_cmd
        import MBDyn_guitools.axial_rot_joint_AS4_cmd

        from MBDyn_settings.wdgt_solver_settings import wdgt_solver_settings
        self.list = ["mbdyn_configure", "mbdyn_launchGui", "body_sel_cmd",
                    "ref_cmd", "struct_node_cmd", "revpin_joint_cmd",
                    "hinge_joint_cmd", "total_joint_cmd", "total_pinjoint_cmd",
                    "axial_rot_joint_cmd", "inline_joint_cmd", "ramp_drive_cmd", "postproc_cmd"]
        self.appendToolbar("Mbdyn_comands", self.list)
        self.appendMenu("Mbdyn_menu", self.list)
        Log("Loading MyModule... done\n")
        # Add preferences page on the main window toolbar: Edit/ preferences.../mbdyn
        general_setting_ui = os.path.join(MBDwb_setting_ui_path, 'ui_general_settings.ui')
        Gui.addPreferencePage(general_setting_ui, "MBDyn")
        Gui.addPreferencePage(wdgt_solver_settings, "MBDyn")
        img_path = os.path.join(MBDwb_icons_path, 'preferences-MBDyn.svg')
        # The commande Gui.addIcon gives me the following warning (on freecad 0.19):
        # <string>:86: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
        Gui.addIcon("preferences-mbdyn", img_path)
Example #7
0
def addIconToFCAD(iconFile, path=None):
    if not path:
        path = iconPath
    key = os.path.splitext(iconFile)[0]
    try:
        path = os.path.join(path, iconFile)
        paths = _iconPaths[key]
        if not paths:
            paths.append(path)
        else:
            try:
                idx = paths.index(path)
                if idx > 0:
                    key += str(idx)
            except ValueError:
                key += len(paths)
                paths.append(path)
        FreeCADGui.addIcon(key, path)
        if addIconContext:
            addIconContext(key, path + '-|')
    except AssertionError:
        pass
    return key