Skip to content

Commit

Permalink
Merge pull request #213 from kbwbe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
kbwbe authored Feb 15, 2019
2 parents dfc367f + 9c37daa commit 4655a43
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__title__ = 'A2plus assembly Workbench - InitGui file'
__author__ = 'kbwbe'

A2P_VERSION = 'V0.3.8'
A2P_VERSION = 'V0.3.10'

import sys
PyVersion = sys.version_info[0]
Expand Down
32 changes: 13 additions & 19 deletions a2p_constraintDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,12 @@ def getMoveDistToStoredPosition(widg):

return fcCenter- widg.rect().center()
else:
#center = QtCore.QPoint(centerX,centerY)
return CONSTRAINT_DIALOG_STORED_POSITION - widg.rect().center()
widgetFrame = widg.frameGeometry()
x = widgetFrame.x()
y = widgetFrame.y()
widgetCorner = QtCore.QPoint(x,y)

return CONSTRAINT_DIALOG_STORED_POSITION - widgetCorner
#==============================================================================
class a2p_ConstraintValuePanel(QtGui.QDockWidget):

Expand All @@ -782,7 +786,6 @@ def __init__(self,constraintObject, mode):
self.constraintObject = constraintObject
self.resize(300,300)
#
print (constraintObject)
self.cvw = a2p_ConstraintValueWidget(
None,
constraintObject,
Expand All @@ -809,30 +812,25 @@ def __init__(self,constraintObject, mode):
solveConstraints(doc)
self.cvw.activateWindow()

def storeWindowCenterPosition(self):
def storeWindowPosition(self):
# ConstraintDialog has Priority on storing its position
if a2plib.getConstraintDialogRef() != None:
return
# self.rect().center() does not work here somehow
frame = QtGui.QDockWidget.geometry(self)
frame = QtGui.QDockWidget.frameGeometry(self)
x = frame.x()
y = frame.y()
width = frame.width()
height = frame.height()
centerX = x + width/2
centerY = y + height/2

global CONSTRAINT_DIALOG_STORED_POSITION
CONSTRAINT_DIALOG_STORED_POSITION = QtCore.QPoint(centerX,centerY)
CONSTRAINT_DIALOG_STORED_POSITION = QtCore.QPoint(x,y)

def onAcceptConstraint(self):
self.storeWindowCenterPosition()
self.storeWindowPosition()
self.Accepted.emit()
a2plib.setConstraintEditorRef(None)
self.deleteLater()

def onDeleteConstraint(self):
self.storeWindowCenterPosition()
self.storeWindowPosition()
self.Deleted.emit()
a2plib.setConstraintEditorRef(None)
self.deleteLater()
Expand Down Expand Up @@ -874,16 +872,12 @@ def onTimer(self):
self.resize(200,250)
# calculate window center position and save it
# self.rect().center() does not work here somehow
frame = QtGui.QDockWidget.geometry(self)
frame = QtGui.QDockWidget.frameGeometry(self)
x = frame.x()
y = frame.y()
width = frame.width()
height = frame.height()
centerX = x + width/2
centerY = y + height/2

global CONSTRAINT_DIALOG_STORED_POSITION
CONSTRAINT_DIALOG_STORED_POSITION = QtCore.QPoint(centerX,centerY)
CONSTRAINT_DIALOG_STORED_POSITION = QtCore.QPoint(x,y)

self.timer.start(100)

Expand Down
5 changes: 3 additions & 2 deletions a2p_convertPart.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ def Activated(self):
)
return

doc.openTransaction("part converted to A2plus")
convertToImportedPart(doc, selection[0])

return
doc.commitTransaction()

def IsActive(self):
"""Here you can define if the command must be active or not (greyed) if certain conditions
are met or not. This function is optional."""

return True


Expand Down
2 changes: 1 addition & 1 deletion a2p_importpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def IsActive(self):
return False

obj = selection[0]
if a2plib.isA2pPart(obj):
if a2plib.isConstrainedPart(FreeCAD.activeDocument(), obj):
return True
else:
return False
Expand Down
9 changes: 9 additions & 0 deletions a2plib.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,3 +747,12 @@ def makeDiffuseElement(color,trans):
elem = (color[0],color[1],color[2],trans/100.0)
return elem
#------------------------------------------------------------------------------
def isConstrainedPart(doc,obj):
if not isA2pPart(obj): return False
constraints = [ ob for ob in doc.Objects if 'ConstraintInfo' in ob.Content]
for c in constraints:
if c.Object1 == obj.Name:
return True
if c.Object2 == obj.Name:
return True
return False

0 comments on commit 4655a43

Please sign in to comment.