diff --git a/src/Gui/ViewProviderMaterialObject.cpp b/src/Gui/ViewProviderMaterialObject.cpp index 508e51169..089c89730 100644 --- a/src/Gui/ViewProviderMaterialObject.cpp +++ b/src/Gui/ViewProviderMaterialObject.cpp @@ -59,8 +59,6 @@ ViewProviderMaterialObject::~ViewProviderMaterialObject() } - - /** * Returns the pixmap for the list item. */ diff --git a/src/Mod/CMakeLists.txt b/src/Mod/CMakeLists.txt index 3070b1a61..b63fac633 100644 --- a/src/Mod/CMakeLists.txt +++ b/src/Mod/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(Image) add_subdirectory(Mesh) add_subdirectory(Part) +add_subdirectory(Material) add_subdirectory(PartDesign) add_subdirectory(Raytracing) add_subdirectory(Drawing) @@ -37,9 +38,10 @@ add_subdirectory(Assembly) if(FREECAD_BUILD_CAM) add_subdirectory(Cam) endif(FREECAD_BUILD_CAM) -if(FREECAD_BUILD_FEM) +#if(FREECAD_BUILD_FEM) add_subdirectory(Fem) -endif(FREECAD_BUILD_FEM) +# MESSAGE("Build FEM") +#endif(FREECAD_BUILD_FEM) if(FREECAD_BUILD_SANDBOX) add_subdirectory(Sandbox) endif(FREECAD_BUILD_SANDBOX) diff --git a/src/Mod/Material/CMakeLists.txt b/src/Mod/Material/CMakeLists.txt new file mode 100644 index 000000000..624e443b0 --- /dev/null +++ b/src/Mod/Material/CMakeLists.txt @@ -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 +) diff --git a/src/Mod/Material/Init.py b/src/Mod/Material/Init.py new file mode 100644 index 000000000..7bc099dd4 --- /dev/null +++ b/src/Mod/Material/Init.py @@ -0,0 +1,31 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2013 - Juergen Riegel * +#* * +#* 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") + diff --git a/src/Mod/Material/InitGui.py b/src/Mod/Material/InitGui.py new file mode 100644 index 000000000..64fccf8a7 --- /dev/null +++ b/src/Mod/Material/InitGui.py @@ -0,0 +1,23 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2013 - Juergen Riegel * +#* * +#* 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 * +#* * +#*************************************************************************** + + diff --git a/src/Mod/Material/Material.py b/src/Mod/Material/Material.py new file mode 100644 index 000000000..78ca2e103 --- /dev/null +++ b/src/Mod/Material/Material.py @@ -0,0 +1,28 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2013 - Juergen Riegel * +#* * +#* 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) + diff --git a/src/Mod/Material/StandardMaterial/Readme.txt b/src/Mod/Material/StandardMaterial/Readme.txt new file mode 100644 index 000000000..1344bebd6 --- /dev/null +++ b/src/Mod/Material/StandardMaterial/Readme.txt @@ -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 \ No newline at end of file diff --git a/src/Mod/Material/StandardMaterial/Steel.FCMat b/src/Mod/Material/StandardMaterial/Steel.FCMat new file mode 100644 index 000000000..eae6febd0 --- /dev/null +++ b/src/Mod/Material/StandardMaterial/Steel.FCMat @@ -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 \ No newline at end of file diff --git a/src/Mod/Material/importFCMat.py b/src/Mod/Material/importFCMat.py new file mode 100644 index 000000000..28c7636ef --- /dev/null +++ b/src/Mod/Material/importFCMat.py @@ -0,0 +1,66 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2013 - Juergen Riegel * +#* * +#* 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 diff --git a/src/Mod/Material/materials-editor.ui b/src/Mod/Material/materials-editor.ui new file mode 100644 index 000000000..29fdabdba --- /dev/null +++ b/src/Mod/Material/materials-editor.ui @@ -0,0 +1,486 @@ + + + Dialog + + + + 0 + 0 + 422 + 470 + + + + Dialog + + + + + + + + + + Material + + + + + + + + 0 + 0 + + + + + Steel + + + + + + + + Wood + + + + + Brick + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Delete + + + + + + + Import... + + + + + + + Export... + + + + + + + + + + + true + + + 2 + + + true + + + 150 + + + true + + + + Property + + + + + Value + + + + + General + + + + 75 + false + true + + + + + + 200 + 200 + 200 + + + + + + + + + + 200 + 200 + 200 + + + + + + Name + + + Steel + + + + + Description + + + A long description of this steel material and its milagrous properties + + + ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled + + + + + + Mechanical + + + + 75 + true + + + + + + 200 + 200 + 200 + + + + + + + + + + 200 + 200 + 200 + + + + + + Young Module + + + 0.00001 + + + + + + Architectural + + + + 75 + true + + + + + + 200 + 200 + 200 + + + + + + + + + + 200 + 200 + 200 + + + + + + Vendor + + + Steel Prod. Co. Inc. Ltd. Pty. + + + + + Product URL + + + http://www.steel.com/steel1234 + + + + + Other Property + + + Some absurd value + + + + + + Rendering + + + + 75 + true + + + + + + 200 + 200 + 200 + + + + + + + + + + 200 + 200 + 200 + + + + + + + 123 + 123 + 123 + + + + + + Diffuse Color + + + rgb(255,0,0) + + + + + Specular Color + + + rgb(255,255,255) + + + + + Specular Intensity Item + + + 100 + + + + + + Vector rendering + + + + 75 + true + + + + + + 200 + 200 + 200 + + + + + + + + + + 200 + 200 + 200 + + + + + + View Color + + + rgb(255,0,0) + + + + + Section Fill + + + slant fill + + + + + View Linewidth + + + 1px + + + + + Section Linewidth + + + 4px + + + + + + + + + + + Add new property + + + + + + Group + + + + + + + + General + + + + + Mechanical + + + + + Architectural + + + + + Rendering + + + + + + + + Name + + + + + + + + + + + + + + + Add new property... + + + + + + + false + + + Delete property + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + +