Arch: Added option to create new material as a copy of an existing one in Arch Material dialog
This commit is contained in:
parent
89035021fb
commit
dbb8afbe1f
|
@ -174,6 +174,7 @@ class _ArchMaterialTaskPanel:
|
||||||
'''The editmode TaskPanel for MechanicalMaterial objects'''
|
'''The editmode TaskPanel for MechanicalMaterial objects'''
|
||||||
def __init__(self,obj=None):
|
def __init__(self,obj=None):
|
||||||
self.cards = None
|
self.cards = None
|
||||||
|
self.existingmaterials = []
|
||||||
self.obj = obj
|
self.obj = obj
|
||||||
self.form = FreeCADGui.PySideUic.loadUi(":/ui/ArchMaterial.ui")
|
self.form = FreeCADGui.PySideUic.loadUi(":/ui/ArchMaterial.ui")
|
||||||
self.color = QtGui.QColor(128,128,128)
|
self.color = QtGui.QColor(128,128,128)
|
||||||
|
@ -181,10 +182,12 @@ class _ArchMaterialTaskPanel:
|
||||||
colorPix.fill(self.color)
|
colorPix.fill(self.color)
|
||||||
self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix))
|
self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix))
|
||||||
QtCore.QObject.connect(self.form.comboBox_MaterialsInDir, QtCore.SIGNAL("currentIndexChanged(QString)"), self.chooseMat)
|
QtCore.QObject.connect(self.form.comboBox_MaterialsInDir, QtCore.SIGNAL("currentIndexChanged(QString)"), self.chooseMat)
|
||||||
|
QtCore.QObject.connect(self.form.comboBox_FromExisting, QtCore.SIGNAL("currentIndexChanged(int)"), self.fromExisting)
|
||||||
QtCore.QObject.connect(self.form.ButtonColor,QtCore.SIGNAL("pressed()"),self.getColor)
|
QtCore.QObject.connect(self.form.ButtonColor,QtCore.SIGNAL("pressed()"),self.getColor)
|
||||||
QtCore.QObject.connect(self.form.ButtonUrl,QtCore.SIGNAL("pressed()"),self.openUrl)
|
QtCore.QObject.connect(self.form.ButtonUrl,QtCore.SIGNAL("pressed()"),self.openUrl)
|
||||||
QtCore.QObject.connect(self.form.ButtonEditor,QtCore.SIGNAL("pressed()"),self.openEditor)
|
QtCore.QObject.connect(self.form.ButtonEditor,QtCore.SIGNAL("pressed()"),self.openEditor)
|
||||||
self.fillMaterialCombo()
|
self.fillMaterialCombo()
|
||||||
|
self.fillExistingCombo()
|
||||||
if self.obj:
|
if self.obj:
|
||||||
if hasattr(self.obj,"Material"):
|
if hasattr(self.obj,"Material"):
|
||||||
self.material = self.obj.Material
|
self.material = self.obj.Material
|
||||||
|
@ -235,6 +238,15 @@ class _ArchMaterialTaskPanel:
|
||||||
self.material = importFCMat.read(self.cards[card])
|
self.material = importFCMat.read(self.cards[card])
|
||||||
self.setFields()
|
self.setFields()
|
||||||
|
|
||||||
|
def fromExisting(self,index):
|
||||||
|
"sets the contents from an existing material"
|
||||||
|
if index > 0:
|
||||||
|
if index <= len(self.existingmaterials):
|
||||||
|
m = self.existingmaterials[index-1]
|
||||||
|
if m.Material:
|
||||||
|
self.material = m.Material
|
||||||
|
self.setFields()
|
||||||
|
|
||||||
def getColor(self):
|
def getColor(self):
|
||||||
"opens a color picker dialog"
|
"opens a color picker dialog"
|
||||||
self.color = QtGui.QColorDialog.getColor()
|
self.color = QtGui.QColorDialog.getColor()
|
||||||
|
@ -260,6 +272,17 @@ class _ArchMaterialTaskPanel:
|
||||||
for k in sorted(self.cards.keys()):
|
for k in sorted(self.cards.keys()):
|
||||||
self.form.comboBox_MaterialsInDir.addItem(k)
|
self.form.comboBox_MaterialsInDir.addItem(k)
|
||||||
|
|
||||||
|
def fillExistingCombo(self):
|
||||||
|
"fills the existing materials combo"
|
||||||
|
self.existingmaterials = []
|
||||||
|
for obj in FreeCAD.ActiveDocument.Objects:
|
||||||
|
if obj.isDerivedFrom("App::MaterialObject"):
|
||||||
|
if obj != self.obj:
|
||||||
|
self.existingmaterials.append(obj)
|
||||||
|
for m in self.existingmaterials:
|
||||||
|
self.form.comboBox_FromExisting.addItem(m.Label)
|
||||||
|
|
||||||
|
|
||||||
def openEditor(self):
|
def openEditor(self):
|
||||||
"opens the full material editor from the material module"
|
"opens the full material editor from the material module"
|
||||||
self.getFields()
|
self.getFields()
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>193</width>
|
<width>216</width>
|
||||||
<height>233</height>
|
<height>259</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -27,6 +27,19 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox_FromExisting">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy existing...</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user