Skip to content

Commit

Permalink
Added library commands and drag&drop for rearranging and copying of t…
Browse files Browse the repository at this point in the history
…ools
  • Loading branch information
mlampert committed Nov 29, 2019
1 parent 09b406c commit fd629df
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 65 deletions.
36 changes: 18 additions & 18 deletions src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<widget class="QWidget" name="toolTableGroup" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
Expand All @@ -111,12 +111,27 @@
</property>
<item>
<widget class="QTableView" name="toolTable">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
Expand Down Expand Up @@ -157,24 +172,9 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="toolUp">
<widget class="QPushButton" name="toolEnumerate">
<property name="text">
<string>Up</string>
</property>
<property name="icon">
<iconset resource="../../../../../Gui/Icons/resource.qrc">
<normaloff>:/icons/button_up.svg</normaloff>:/icons/button_up.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="toolDown">
<property name="text">
<string>Down</string>
</property>
<property name="icon">
<iconset resource="../../../../../Gui/Icons/resource.qrc">
<normaloff>:/icons/button_down.svg</normaloff>:/icons/button_down.svg</iconset>
<string>Enumerate</string>
</property>
</widget>
</item>
Expand Down
20 changes: 19 additions & 1 deletion src/Mod/Path/PathScripts/PathToolBit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@ def translate(context, text, disambig=None):
}


def _findTool(path, typ):
def _findTool(path, typ, dbg=False):
if os.path.exists(path):
if dbg:
PathLog.debug("Found {} at {}".format(typ, path))
return path

def searchFor(pname, fname):
if dbg:
PathLog.debug("Looking for {}".format(pname))
if fname:
for p in PathPreferences.searchPathsTool(typ):
f = os.path.join(p, fname)
if dbg:
PathLog.debug(" Checking {}".format(f))
if os.path.exists(f):
if dbg:
PathLog.debug(" Found {} at {}".format(typ, f))
return f
if pname and '/' != pname:
ppname, pfname = os.path.split(pname)
Expand All @@ -78,6 +86,16 @@ def findTemplate(path):
'''findTemplate(path) ... search for path, full and partially in all known template directories.'''
return _findTool(path, 'Template')

def findBit(path):
if path.endswith('.fctb'):
return _findTool(path, 'Bit')
return _findTool("{}.fctb".format(path), 'Bit')

def findLibrary(path, dbg=False):
if path.endswith('.fctl'):
return _findTool(path, 'Library', dbg)
return _findTool("{}.fctl".format(path), 'Library', dbg)

def updateConstraint(sketch, name, value):
for i, constraint in enumerate(sketch.Constraints):
if constraint.Name.split(';')[0] == name:
Expand Down
Loading

0 comments on commit fd629df

Please sign in to comment.