Arch: Added materials support

This commit is contained in:
Yorik van Havre 2015-04-15 22:08:54 -03:00
parent f068e723ea
commit 6750127a05
13 changed files with 969 additions and 11 deletions

View File

@ -48,3 +48,4 @@ from ArchPanel import *
from ArchEquipment import *
from ArchCutPlane import *
from ArchServer import *
from ArchMaterial import *

View File

@ -193,7 +193,7 @@ def removeComponents(objectsList,host=None):
a.remove(o)
h.Objects = a
def makeComponent(baseobj=None,name="Component"):
def makeComponent(baseobj=None,name="Component",delete=False):
'''makeComponent([baseobj]): creates an undefined, non-parametric Arch
component from the given base object'''
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
@ -206,6 +206,8 @@ def makeComponent(baseobj=None,name="Component"):
if baseobj.isDerivedFrom("Part::Feature"):
obj.Shape = baseobj.Shape
obj.Placement = baseobj.Placement
if delete:
FreeCAD.ActiveDocument.removeObject(baseobj.Name)
elif isinstance(baseobj,Part.Shape):
obj.Shape = baseobj
return obj

View File

@ -296,7 +296,7 @@ class Component:
obj.addProperty("App::PropertyString","Description","Arch",translate("Arch","An optional description for this component"))
obj.addProperty("App::PropertyString","Tag","Arch",translate("Arch","An optional tag for this component"))
obj.addProperty("App::PropertyMap","IfcAttributes","Arch",translate("Arch","Custom IFC properties and attributes"))
obj.addProperty("App::PropertyMap","Material","Arch",translate("Arch","A material for this object"))
obj.addProperty("App::PropertyLink","BaseMaterial","Material",translate("Arch","A material for this object"))
obj.addProperty("App::PropertyEnumeration","Role","Arch",translate("Arch","The role of this object"))
obj.addProperty("App::PropertyBool","MoveWithHost","Arch",translate("Arch","Specifies if this object must move together when its host is moved"))
obj.Proxy = self
@ -326,6 +326,9 @@ class Component:
pl = obj.Placement
obj.Shape = obj.CloneOf.Shape.copy()
obj.Placement = pl
if hasattr(obj,"BaseMaterial"):
if hasattr(obj.CloneOf,"BaseMaterial"):
obj.BaseMaterial = obj.CloneOf.BaseMaterial
return True
return False
@ -654,6 +657,13 @@ class ViewProviderComponent:
self.Object = vobj.Object
def updateData(self,obj,prop):
if prop == "BaseMaterial":
if obj.BaseMaterial:
if 'Color' in obj.BaseMaterial.Material:
if "(" in obj.BaseMaterial.Material['Color']:
c = tuple([float(f) for f in obj.BaseMaterial.Material['Color'].strip("()").split(",")])
if obj.ViewObject:
obj.ViewObject.ShapeColor = c
return
def getIcon(self):

View File

@ -0,0 +1,230 @@
#***************************************************************************
#* *
#* Copyright (c) 2015 - Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
import FreeCAD
if FreeCAD.GuiUp:
import FreeCADGui, Arch_rc, os
from PySide import QtCore, QtGui
from DraftTools import translate
__title__ = "Arch Material Managment"
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"
def makeMaterial(name="Material"):
'''makeMaterial(name): makes an Material object'''
obj = FreeCAD.ActiveDocument.addObject("App::MaterialObjectPython",name)
obj.Label = name
_ArchMaterial(obj)
_ViewProviderArchMaterial(obj.ViewObject)
getMaterialContainer().addObject(obj)
return obj
def getMaterialContainer():
'''getMaterialContainer(): returns a group object to put materials in'''
for obj in FreeCAD.ActiveDocument.Objects:
if obj.Name == "MaterialContainer":
return obj
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","MaterialContainer")
obj.Label = "Materials"
return obj
class _CommandArchMaterial:
"the Arch Material command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Material',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Material","Set material..."),
'Accel': "M, T",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Material","Creates or edits the material definition of a selected object.")}
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create material"))
FreeCADGui.addModule("Arch")
FreeCADGui.Control.closeDialog()
FreeCADGui.doCommand("mat = Arch.makeMaterial()")
for obj in sel:
if hasattr(obj,"BaseMaterial"):
FreeCADGui.doCommand("FreeCAD.ActiveDocument."+obj.Name+".BaseMaterial = mat")
FreeCADGui.doCommandGui("mat.ViewObject.startEditing()")
FreeCAD.ActiveDocument.commitTransaction()
def IsActive(self):
if FreeCAD.ActiveDocument:
return True
else:
return False
class _ArchMaterial:
"The Material object"
def __init__(self,obj):
self.Type = "Material"
obj.Proxy = self
def execute(self,obj):
return
class _ViewProviderArchMaterial:
"A View Provider for the MechanicalMaterial object"
def __init__(self,vobj):
vobj.Proxy = self
def getIcon(self):
return ":/icons/Arch_Material.svg"
def attach(self, vobj):
return
def updateData(self, obj, prop):
return
def onChanged(self, vobj, prop):
return
def setEdit(self,vobj,mode):
taskd = _ArchMaterialTaskPanel(vobj.Object)
FreeCADGui.Control.showDialog(taskd)
return True
def unsetEdit(self,vobj,mode):
FreeCADGui.Control.closeDialog()
return
def __getstate__(self):
return None
def __setstate__(self,state):
return None
class _ArchMaterialTaskPanel:
'''The editmode TaskPanel for MechanicalMaterial objects'''
def __init__(self,obj=None):
self.cards = None
self.obj = obj
self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0]+".ui")
self.color = QtGui.QColor(128,128,128)
colorPix = QtGui.QPixmap(16,16)
colorPix.fill(self.color)
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.ButtonColor,QtCore.SIGNAL("pressed()"),self.getColor)
QtCore.QObject.connect(self.form.ButtonUrl,QtCore.SIGNAL("pressed()"),self.openUrl)
QtCore.QObject.connect(self.form.ButtonEditor,QtCore.SIGNAL("pressed()"),self.openEditor)
self.fillMaterialCombo()
if self.obj:
if hasattr(self.obj,"Material"):
self.material = self.obj.Material
self.setFields()
def setFields(self):
"sets the task box contents from self.material"
if 'Name' in self.material:
self.form.FieldName.setText(self.material['Name'])
if 'Description' in self.material:
self.form.FieldDescription.setText(self.material['Description'])
if 'Color' in self.material:
if "(" in self.material['Color']:
c = tuple([float(f) for f in self.material['Color'].strip("()").split(",")])
self.color = QtGui.QColor()
self.color.setRgbF(c[0],c[1],c[2])
colorPix = QtGui.QPixmap(16,16)
colorPix.fill(self.color)
self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix))
self.form.FieldColor.setText(self.material['Color'])
if 'StandardCode' in self.material:
self.form.FieldCode.setText(self.material['StandardCode'])
if 'ProductURL' in self.material:
self.form.FieldUrl.setText(self.material['ProductURL'])
def getFields(self):
"sets self.material from the contents of the task box"
self.material['Name'] = self.form.FieldName.text()
self.material['Description'] = self.form.FieldDescription.text()
self.material['Color'] = str(self.color.getRgbF()[:3])
self.material['StandardCode'] = self.form.FieldCode.text()
self.material['ProductURL'] = self.form.FieldUrl.text()
def accept(self):
self.getFields()
if self.obj:
if hasattr(self.obj,"Material"):
self.obj.Material = self.material
self.obj.Label = self.material['Name']
FreeCADGui.Control.closeDialog()
def reject(self):
FreeCADGui.Control.closeDialog()
def chooseMat(self, card):
"sets self.material from a card"
if card in self.cards:
import importFCMat
self.material = importFCMat.read(self.cards[card])
self.setFields()
def getColor(self):
"opens a color picker dialog"
self.color = QtGui.QColorDialog.getColor()
colorPix = QtGui.QPixmap(16,16)
colorPix.fill(self.color)
self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix))
def fillMaterialCombo(self):
"fills the combo with the existing FCMat cards"
# look for cards in both resources dir and user folder.
# User cards with same name will override system cards
paths = [FreeCAD.getResourceDir() + os.sep + "Mod" + os.sep + "Material" + os.sep + "StandardMaterial"]
paths.append(FreeCAD.ConfigGet("UserAppData"))
self.cards = {}
for p in paths:
for f in os.listdir(p):
b,e = os.path.splitext(f)
if e.upper() == ".FCMAT":
self.cards[b] = p + os.sep + f
if self.cards:
for k,i in self.cards.items():
self.form.comboBox_MaterialsInDir.addItem(k)
def openEditor(self):
"opens the full material editor from the material module"
self.getFields()
if self.material:
import MaterialEditor
self.material = MaterialEditor.editMaterial(self.material)
self.setFields()
def openUrl(self):
self.getFields()
if self.material:
if 'ProductURL' in self.material:
QtGui.QDesktopServices.openUrl(self.material['ProductURL'])
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Material',_CommandArchMaterial())

View File

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ArchMaterial</class>
<widget class="QWidget" name="ArchMaterial">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>223</width>
<height>233</height>
</rect>
</property>
<property name="windowTitle">
<string>Arch material</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="comboBox_MaterialsInDir">
<item>
<property name="text">
<string>Choose preset...</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="FieldName"/>
</item>
<item>
<widget class="QPushButton" name="ButtonEditor">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="edit-paste">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="FieldDescription"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="FieldColor">
<property name="text">
<string>()</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonColor">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Code</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="FieldCode"/>
</item>
<item>
<widget class="QPushButton" name="ButtonCode">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="web-browser">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="FieldUrl">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonUrl">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="web-browser">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -693,6 +693,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
self.coords.point.setValues(0,len(p),p)
self.pointset.numPoints.setValue(len(p))
self.lineset.coordIndex.setValues(0,len(p)+1,range(len(p))+[-1])
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)
def onChanged(self,vobj,prop):
if prop == "ShowNodes":

View File

@ -605,6 +605,8 @@ class _Window(ArchComponent.Component):
obj.addProperty("App::PropertyLength","Height","Arch",translate("Arch","The height of this window (for preset windows only)"))
obj.addProperty("App::PropertyVector","Normal","Arch",translate("Arch","The normal direction of this window"))
obj.addProperty("App::PropertyInteger","Preset","Arch","")
obj.addProperty("App::PropertyLink","PanelMaterial","Material",translate("Arch","A material for this object"))
obj.addProperty("App::PropertyLink","GlassMaterial","Material",translate("Arch","A material for this object"))
obj.setEditorMode("Preset",2)
self.Type = "Window"

View File

@ -30,6 +30,8 @@ SET(Arch_SRCS
ArchEquipment.py
ArchCutPlane.py
ArchServer.py
ArchMaterial.py
ArchMaterial.ui
)
SOURCE_GROUP("" FILES ${Arch_SRCS})

View File

@ -74,7 +74,8 @@ class ArchWorkbench(Workbench):
"Arch_Window","Arch_Roof","Arch_Axis",
"Arch_SectionPlane","Arch_Space","Arch_Stairs",
"Arch_Panel","Arch_Equipment",
"Arch_Frame","Arch_CutPlane","Arch_Add","Arch_Remove","Arch_Survey"]
"Arch_Frame","Arch_Material","Arch_CutPlane",
"Arch_Add","Arch_Remove","Arch_Survey"]
self.utilities = ["Arch_Component","Arch_SplitMesh","Arch_MeshToShape",
"Arch_SelectNonSolidMeshes","Arch_RemoveShape",
"Arch_CloseHoles","Arch_MergeWalls","Arch_Check",

View File

@ -54,6 +54,7 @@
<file>icons/Arch_Bimserver.svg</file>
<file>icons/Git.svg</file>
<file>icons/Arch_Component.svg</file>
<file>icons/Arch_Material.svg</file>
<file>ui/archprefs-base.ui</file>
<file>ui/archprefs-defaults.ui</file>
<file>ui/archprefs-import.ui</file>

View File

@ -0,0 +1,510 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2816"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="Arch_Material.svg">
<defs
id="defs2818">
<linearGradient
inkscape:collect="always"
id="linearGradient4044">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4046" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4048" />
</linearGradient>
<linearGradient
id="linearGradient3681">
<stop
id="stop3697"
offset="0"
style="stop-color:#fff110;stop-opacity:1;" />
<stop
style="stop-color:#cf7008;stop-opacity:1;"
offset="1"
id="stop3685" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2824" />
<inkscape:perspective
id="perspective3622"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3622-9"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3653"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3675"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3697"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3720"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3742"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3764"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3785"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3806"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3806-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3835"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3614"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3614-8"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3643"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3643-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3672"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3672-5"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3701"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3701-8"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3746"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.67643728,-0.81829155,2.4578314,1.8844554,-26.450606,18.294947)"
id="pattern5231"
xlink:href="#Strips1_1-4"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5224"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-4"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-4"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<inkscape:perspective
id="perspective5224-9"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,39.618381,8.9692804)"
id="pattern5231-4"
xlink:href="#Strips1_1-6"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5224-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-6"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-0"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<pattern
patternTransform="matrix(0.66513382,-1.0631299,2.4167603,2.4482973,-49.762569,2.9546807)"
id="pattern5296"
xlink:href="#pattern5231-3"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5288"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,-26.336284,10.887197)"
id="pattern5231-3"
xlink:href="#Strips1_1-4-3"
inkscape:collect="always" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-4-3"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-4-6"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<pattern
patternTransform="matrix(0.42844886,-0.62155849,1.5567667,1.431396,27.948414,13.306456)"
id="pattern5330"
xlink:href="#Strips1_1-9"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5323"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-9"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-3"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<inkscape:perspective
id="perspective5361"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5383"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5411"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3681"
id="linearGradient3687"
x1="37.89756"
y1="41.087898"
x2="4.0605712"
y2="40.168594"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3681"
id="linearGradient3695"
x1="31.777767"
y1="40.24213"
x2="68.442062"
y2="54.041203"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.25023482,-0.66040068,0.68751357,0.24036653,-8.7488565,43.149938)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512"
id="radialGradient278"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513" />
<stop
style="stop-color:#fff520;stop-opacity:0.89108908;"
offset="0.50000000"
id="stop12517" />
<stop
style="stop-color:#fff300;stop-opacity:0.0000000;"
offset="1.0000000"
id="stop12514" />
</linearGradient>
<radialGradient
r="14.375"
fy="125"
fx="55"
cy="125"
cx="55"
gradientUnits="userSpaceOnUse"
id="radialGradient4017"
xlink:href="#linearGradient12512"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044"
id="linearGradient4060"
x1="15.78776"
y1="50.394047"
x2="27.641447"
y2="39.95837"
gradientUnits="userSpaceOnUse" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512-2"
id="radialGradient278-5"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512-2">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513-3" />
<stop
style="stop-color:#ffd820;stop-opacity:0.89108908;"
offset="0.5"
id="stop12517-1" />
<stop
style="stop-color:#ff8000;stop-opacity:0;"
offset="1"
id="stop12514-6" />
</linearGradient>
<radialGradient
r="14.375"
fy="125"
fx="55"
cy="125"
cx="55"
gradientUnits="userSpaceOnUse"
id="radialGradient4078"
xlink:href="#linearGradient12512-2"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.75"
inkscape:cx="88.674331"
inkscape:cy="16.741705"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:object-paths="true"
inkscape:object-nodes="true"
inkscape:window-width="1920"
inkscape:window-height="1053"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:snap-nodes="false"
inkscape:snap-global="false" />
<metadata
id="metadata2821">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
sodipodi:type="arc"
style="fill:#f4a200;fill-opacity:1;stroke:url(#linearGradient4060);stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
id="path4042"
sodipodi:cx="27.641447"
sodipodi:cy="39.95837"
sodipodi:rx="20.956074"
sodipodi:ry="20.956074"
d="m 48.597521,39.95837 a 20.956074,20.956074 0 1 1 -41.9121477,0 20.956074,20.956074 0 1 1 41.9121477,0 z"
transform="matrix(1.2751074,0,0,1.28117,-3.5618174,-19.40621)" />
<path
sodipodi:type="arc"
style="color:#000000;fill:url(#radialGradient4078);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000024;marker:none;visibility:visible;display:block"
id="path12511"
sodipodi:cx="55"
sodipodi:cy="125"
sodipodi:rx="14.375"
sodipodi:ry="14.375"
d="m 69.375,125 a 14.375,14.375 0 1 1 -28.75,0 14.375,14.375 0 1 1 28.75,0 z"
transform="matrix(0.99878142,0,0,1.0035302,-34.6176,-100.93815)"
inkscape:export-filename="/home/jimmac/ximian_art/icons/nautilus/suse93/stock_new-16.png"
inkscape:export-xdpi="33.852203"
inkscape:export-ydpi="33.852203" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -444,9 +444,9 @@ def insert(filename,docname,skip=[],only=[],root=None):
obj.IfcAttributes = a
break
if not obj:
obj = baseobj
obj = Arch.makeComponent(baseobj,name=name,delete=True)
if obj:
sols = str(baseobj.Shape.Solids) if hasattr(baseobj,"Shape") else "[]"
sols = str(obj.Shape.Solids) if hasattr(obj,"Shape") else "[]"
if DEBUG: print sols
objects[pid] = obj

View File

@ -45,19 +45,21 @@ class UiLoader(QtUiTools.QUiLoader):
class MaterialEditor(QtGui.QDialog):
def __init__(self, obj = None, prop = None):
"Initializes, optionally with an object name and a material property name to edit"
def __init__(self, obj = None, prop = None, material = None):
"""Initializes, optionally with an object name and a material property name to edit, or directly
with a material dictionary."""
QtGui.QDialog.__init__(self)
self.obj = obj
self.prop = prop
self.material = material
self.customprops = []
# load the UI file from the same directory as this script
loader = UiLoader(self)
widget = loader.load(os.path.dirname(__file__)+os.sep+"materials-editor.ui")
#QtCore.QMetaObject.connectSlotsByName(widget)
self.ui = self
print self.ui
print dir(self.ui)
#print self.ui
#print dir(self.ui)
# additional UI fixes and tweaks
self.ButtonURL.setIcon(QtGui.QIcon(":/icons/internet-web-browser.svg"))
self.ButtonDeleteProperty.setEnabled(False)
@ -81,8 +83,12 @@ class MaterialEditor(QtGui.QDialog):
QtCore.QObject.connect(self.ButtonOpen, QtCore.SIGNAL("clicked()"), self.openfile)
QtCore.QObject.connect(self.ButtonSave, QtCore.SIGNAL("clicked()"), self.savefile)
# update the editor with the contents of the property, if we have one
d = None
if self.prop and self.obj:
d = FreeCAD.ActiveDocument.getObject(self.obj).getPropertyByName(self.prop)
elif self.material:
d = self.material
if d:
self.updateContents(d)
def updateCards(self):
@ -100,7 +106,7 @@ class MaterialEditor(QtGui.QDialog):
if self.cards:
self.ComboMaterial.clear()
self.ComboMaterial.addItem("") # add a blank item first
for k,i in self.cards.iteritems():
for k,i in self.cards.items():
self.ComboMaterial.addItem(k)
def updateContents(self,data):
@ -108,7 +114,7 @@ class MaterialEditor(QtGui.QDialog):
#print type(data)
if isinstance(data,dict):
self.clearEditor()
for k,i in data.iteritems():
for k,i in data.items():
k = self.expandKey(k)
slot = self.Editor.findItems(k,QtCore.Qt.MatchRecursive,0)
if len(slot) == 1:
@ -257,4 +263,14 @@ def openEditor(obj = None, prop = None):
an object name and material property name to edit"""
editor = MaterialEditor(obj,prop)
editor.show()
def editMaterial(material):
"""editMaterial(material): opens the editor to edit the contents
of the given material dictionary. Returns the modified material."""
editor = MaterialEditor(material=material)
result = editor.exec_()
if result:
return editor.getDict()
else:
return material