Add file importer, standard material and Yoriks gui prototype

This commit is contained in:
jriegel 2013-06-01 20:27:30 +02:00
parent fd262a24f6
commit f120990372
10 changed files with 697 additions and 4 deletions

View File

@ -59,8 +59,6 @@ ViewProviderMaterialObject::~ViewProviderMaterialObject()
} }
/** /**
* Returns the pixmap for the list item. * Returns the pixmap for the list item.
*/ */

View File

@ -8,6 +8,7 @@ add_subdirectory(Image)
add_subdirectory(Mesh) add_subdirectory(Mesh)
add_subdirectory(Part) add_subdirectory(Part)
add_subdirectory(Material)
add_subdirectory(PartDesign) add_subdirectory(PartDesign)
add_subdirectory(Raytracing) add_subdirectory(Raytracing)
add_subdirectory(Drawing) add_subdirectory(Drawing)
@ -37,9 +38,10 @@ add_subdirectory(Assembly)
if(FREECAD_BUILD_CAM) if(FREECAD_BUILD_CAM)
add_subdirectory(Cam) add_subdirectory(Cam)
endif(FREECAD_BUILD_CAM) endif(FREECAD_BUILD_CAM)
if(FREECAD_BUILD_FEM) #if(FREECAD_BUILD_FEM)
add_subdirectory(Fem) add_subdirectory(Fem)
endif(FREECAD_BUILD_FEM) # MESSAGE("Build FEM")
#endif(FREECAD_BUILD_FEM)
if(FREECAD_BUILD_SANDBOX) if(FREECAD_BUILD_SANDBOX)
add_subdirectory(Sandbox) add_subdirectory(Sandbox)
endif(FREECAD_BUILD_SANDBOX) endif(FREECAD_BUILD_SANDBOX)

View File

@ -0,0 +1,33 @@
SET(Material_SRCS
Init.py
InitGui.py
Material.py
importFCMat.py
)
SOURCE_GROUP("" FILES ${Material_SRCS})
# collect all the material cards:
FILE( GLOB MaterialLib_Files ./StandardMaterial/*.FCMat ./StandardMaterial/*.txt )
#SET (MaterialLib_Files
# StandardMaterial/Steel.FCMat
# StandardMaterial/Readme.txt
# )
SET(all_files ${Material_SRCS})
ADD_CUSTOM_TARGET(Material ALL
SOURCES ${all_files}
)
fc_copy_sources(Material "${CMAKE_BINARY_DIR}/Mod/Material" ${all_files})
fc_target_copy_resource(Material
${CMAKE_SOURCE_DIR}/src/Mod/Material
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Material
${MaterialLib_Files})
INSTALL(
FILES ${Material_SRCS}
DESTINATION Mod/Material
)

31
src/Mod/Material/Init.py Normal file
View File

@ -0,0 +1,31 @@
#***************************************************************************
#* *
#* Copyright (c) 2013 - Juergen Riegel <FreeCAD@juergen-riegel.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 *
#* *
#***************************************************************************
# Get the Parameter Group of this module
ParGrp = App.ParamGet("System parameter:Modules").GetGroup("Material")
# Set the needed information
ParGrp.SetString("HelpIndex", "http://free-cad.sf.net")
# import for the FreeCAD Material card
FreeCAD.addImportType("FreeCAD Material Card (*.FCMat)","importFCMat")

View File

@ -0,0 +1,23 @@
#***************************************************************************
#* *
#* Copyright (c) 2013 - Juergen Riegel <FreeCAD@juergen-riegel.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 *
#* *
#***************************************************************************

View File

@ -0,0 +1,28 @@
#***************************************************************************
#* *
#* Copyright (c) 2013 - Juergen Riegel <FreeCAD@juergen-riegel.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
def importFCMat(fileName):
FreeCAD.Console.PrintMsg(fileName)

View File

@ -0,0 +1,13 @@
This is the FreeCAD standard material library. Its intended to gather the most commen Material definitions.
How to do a description is explained here:
http://www.freecadweb.org/wiki/index.php?title=Material
To make the material description usefull for a lot of application only files with the (CC BY 3.0) license
will be accepted into the FreeCAD source distribution. For more detail about the license see here:
http://creativecommons.org/
Pleas help!
Enlargen the base of Materials for FreeCAD will greatly benefit the usability of FreeCAD. So please
help us to add new Materials, review existing ones or add additional vlaues.
2013 Juergen Riegel

View File

@ -0,0 +1,13 @@
; Standard Steel Material
; (c) Juergen Riegel 2013 (CC-BY 3.0)
[General]
; General name, need to be the same as the file name
Name=Steel
; Specific wight in kg/mm^3
SpecificWeight=7800.0e-12
[Mechanical]
; youngs modulus (or E-Module) in mPa (source: http://en.wikipedia.org/wiki/Young%27s_modulus)
YoungsModulus=200.0e12

View File

@ -0,0 +1,66 @@
#***************************************************************************
#* *
#* Copyright (c) 2013 - Juergen Riegel <FreeCAD@juergen-riegel.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, Material
__title__="FreeCAD material card importer"
__author__ = "Juergen Riegel"
__url__ = "http://free-cad.sourceforge.net"
def open(filename):
"called when freecad wants to open a file"
docname = os.path.splitext(os.path.basename(filename))[0]
doc = FreeCAD.newDocument(docname)
doc.Label = decode(docname)
FreeCAD.ActiveDocument = doc
read(filename)
return doc
def insert(filename,docname):
"called when freecad wants to import a file"
try:
doc = FreeCAD.getDocument(docname)
except:
doc = FreeCAD.newDocument(docname)
FreeCAD.ActiveDocument = doc
read(filename)
return doc
def decode(name):
"decodes encoded strings"
try:
decodedName = (name.decode("utf8"))
except UnicodeDecodeError:
try:
decodedName = (name.decode("latin1"))
except UnicodeDecodeError:
FreeCAD.Console.PrintError("Error: Couldn't determine character encoding")
decodedName = name
return decodedName
def read(filename):
FreeCAD.Console.PrintError("Not implemented yet")
def export(exportList,filename):
"called when freecad exports a file"
return

View File

@ -0,0 +1,486 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>422</width>
<height>470</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Material</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>Steel</string>
</property>
<property name="icon">
<iconset theme="gnome-dev-removable"/>
</property>
</item>
<item>
<property name="text">
<string>Wood</string>
</property>
</item>
<item>
<property name="text">
<string>Brick</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Import...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>Export...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>150</number>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Property</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
<item>
<property name="text">
<string>General</string>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<property name="text">
<string/>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<item>
<property name="text">
<string>Name</string>
</property>
<property name="text">
<string>Steel</string>
</property>
</item>
<item>
<property name="text">
<string>Description</string>
</property>
<property name="text">
<string>A long description of this steel material and its milagrous properties</string>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled</set>
</property>
</item>
</item>
<item>
<property name="text">
<string>Mechanical</string>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<property name="text">
<string/>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<item>
<property name="text">
<string>Young Module</string>
</property>
<property name="text">
<string>0.00001</string>
</property>
</item>
</item>
<item>
<property name="text">
<string>Architectural</string>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<property name="text">
<string/>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<item>
<property name="text">
<string>Vendor</string>
</property>
<property name="text">
<string>Steel Prod. Co. Inc. Ltd. Pty.</string>
</property>
</item>
<item>
<property name="text">
<string>Product URL</string>
</property>
<property name="text">
<string>http://www.steel.com/steel1234</string>
</property>
</item>
<item>
<property name="text">
<string>Other Property</string>
</property>
<property name="text">
<string>Some absurd value</string>
</property>
</item>
</item>
<item>
<property name="text">
<string>Rendering</string>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<property name="text">
<string/>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<property name="foreground">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>123</red>
<green>123</green>
<blue>123</blue>
</color>
</brush>
</property>
<item>
<property name="text">
<string>Diffuse Color</string>
</property>
<property name="text">
<string>rgb(255,0,0)</string>
</property>
</item>
<item>
<property name="text">
<string>Specular Color</string>
</property>
<property name="text">
<string>rgb(255,255,255)</string>
</property>
</item>
<item>
<property name="text">
<string>Specular Intensity Item</string>
</property>
<property name="text">
<string>100</string>
</property>
</item>
</item>
<item>
<property name="text">
<string>Vector rendering</string>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<property name="text">
<string/>
</property>
<property name="background">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>200</red>
<green>200</green>
<blue>200</blue>
</color>
</brush>
</property>
<item>
<property name="text">
<string>View Color</string>
</property>
<property name="text">
<string>rgb(255,0,0)</string>
</property>
</item>
<item>
<property name="text">
<string>Section Fill</string>
</property>
<property name="text">
<string>slant fill</string>
</property>
</item>
<item>
<property name="text">
<string>View Linewidth</string>
</property>
<property name="text">
<string>1px</string>
</property>
</item>
<item>
<property name="text">
<string>Section Linewidth</string>
</property>
<property name="text">
<string>4px</string>
</property>
</item>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Add new property</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Group</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>General</string>
</property>
</item>
<item>
<property name="text">
<string>Mechanical</string>
</property>
</item>
<item>
<property name="text">
<string>Architectural</string>
</property>
</item>
<item>
<property name="text">
<string>Rendering</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Add new property...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete property</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>