Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
wmayer 2014-02-10 10:52:42 +01:00
commit 12dbea7b90
12 changed files with 181 additions and 84 deletions

View File

@ -92,6 +92,7 @@ MESSAGE(STATUS "includedir: ${CMAKE_INSTALL_INCLUDEDIR}")
# == Win32 is default behaviour use the LibPack copied in Source tree ==========
if(MSVC)
OPTION(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." ON)
OPTION(FREECAD_LIBPACK_USEPYSIDE "Use PySide in LibPack rather to PyQt and Swig." ON)
set(FREECAD_LIBPACK_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory of the FreeCAD LibPack")
else(MSVC)
OPTION(FREECAD_LIBPACK_USE "Use the LibPack to Build FreeCAD (only Win32 so far)." OFF)

View File

@ -151,7 +151,25 @@ set(QT_RCC_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/rcc.exe)
set(QT_HELPCOMPILER_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qhelpgenerator.exe)
set(QT_COLLECTIOMGENERATOR_EXECUTABLE ${FREECAD_LIBPACK_DIR}/bin/qcollectiongenerator.exe)
if(FREECAD_LIBPACK_USEPYSIDE)
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
SET(SHIBOKEN_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/shiboken)
SET(SHIBOKEN_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/shiboken-python2.6_d.lib)
set(SHIBOKEN_BINARY ${FREECAD_LIBPACK_DIR}/bin/shiboken)
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide
# PYSIDE_LIBRARY - Files to link against to use PySide
# PYSIDE_PYTHONPATH - Path to where the PySide Python module files could be found
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide
SET(PYSIDE_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/PySide)
SET(PYSIDE_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6_d.lib)
#SET(PYSIDE_PYTHONPATH ${FREECAD_LIBPACK_DIR}/pyside/Lib/site-packages)
#SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)
endif(FREECAD_LIBPACK_USEPYSIDE)
MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
SET(${_qt4_files})
@ -428,4 +446,4 @@ set(SHIBOKEN_BINARY ${FREECAD_LIBPACK_DIR}/bin/shiboken)
SET(PYSIDE_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/PySide)
SET(PYSIDE_LIBRARY optimized ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6.lib debug ${FREECAD_LIBPACK_DIR}/lib/pyside-python2.6_d.lib)
SET(PYSIDE_PYTHONPATH ${FREECAD_LIBPACK_DIR}/pyside/Lib/site-packages)
SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)
SET(PYSIDE_TYPESYSTEMS ${FREECAD_LIBPACK_DIR}/pyside/share/PySide/typesystems)

View File

@ -162,12 +162,19 @@ void InputField::newInput(const QString & text)
void InputField::pushToHistory(const QString &valueq)
{
std::string value;
QString val;
if(valueq.isEmpty())
value = this->text().toUtf8().constData();
val = this->text();
else
value = valueq.toUtf8().constData();
val = valueq;
// check if already in:
std::vector<QString> hist = InputField::getHistory();
for(std::vector<QString>::const_iterator it = hist.begin();it!=hist.end();++it)
if( *it == val)
return;
std::string value(val.toUtf8());
if(_handle.isValid()){
char hist1[21];
char hist0[21];
@ -205,7 +212,7 @@ void InputField::setToLastUsedValue(void)
{
std::vector<QString> hist = getHistory();
if(hist.size()>0)
this->setText(hist[0]);
this->setValue(Base::Quantity::parse(hist[0]));
}
@ -322,6 +329,17 @@ void InputField::setMinimum(double m)
Minimum = m;
}
void InputField::setUnitText(QString str)
{
Base::Quantity quant = Base::Quantity::parse(str);
setUnit(quant.getUnit());
}
QString InputField::getUnitText(void)
{
return actUnitStr;
}
// get the value of the minimum property
int InputField::historySize(void)const
{

View File

@ -52,6 +52,7 @@ class GuiExport InputField : public QLineEdit
Q_PROPERTY(double maximum READ maximum WRITE setMaximum )
Q_PROPERTY(double minimum READ minimum WRITE setMinimum )
Q_PROPERTY(int historySize READ historySize WRITE setHistorySize )
Q_PROPERTY(QString unit READ getUnitText WRITE setUnitText )
public:
@ -88,7 +89,10 @@ public:
int historySize(void)const;
/// set the value of the minimum property
void setHistorySize(int);
/// set the unit by a string (can be used in the *.ui file)
void setUnitText(QString);
/// get the unit as a string (can be used in the *.ui file)
QString getUnitText(void);
/// set the number portion selected (use after setValue())
void selectNumber(void);

View File

@ -29,7 +29,10 @@
# include <strstream>
# include <Bnd_Box.hxx>
# include <BRepBndLib.hxx>
# include <BRepAlgo_NormalProjection.hxx>
# include <BRepExtrema_DistShapeShape.hxx>
# include <TopoDS_Vertex.hxx>
# include <BRepBuilderAPI_MakeVertex.hxx>
# include <gp_Pnt.hxx>
#endif
#include <Base/Writer.h>
@ -326,6 +329,7 @@ SMESH_Mesh* FemMesh::getSMesh()
return myMesh;
}
SMESH_Gen * FemMesh::getGenerator()
{
return myGen;
@ -404,8 +408,37 @@ std::set<long> FemMesh::getSurfaceNodes(const TopoDS_Face &face)const
std::set<long> result;
const SMESHDS_Mesh* data = myMesh->GetMeshDS();
BRepAlgo_NormalProjection algo;
Bnd_Box box;
BRepBndLib::Add(face, box);
// limit where the mesh node belongs to the face:
double limit = box.SquareExtent()/10000.0;
box.Enlarge(limit);
// get the actuall transform of the FemMesh
const Base::Matrix4D Mtrx(getTransform());
SMDS_NodeIteratorPtr aNodeIter = myMesh->GetMeshDS()->nodesIterator();
for (int i=0;aNodeIter->more();i++) {
const SMDS_MeshNode* aNode = aNodeIter->next();
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
// Apply the matrix to hold the BoundBox in absolute space.
vec = Mtrx * vec;
if(!box.IsOut(gp_Pnt(vec.x,vec.y,vec.z))){
// create a Vertex
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(vec.x,vec.y,vec.z));
TopoDS_Shape s = aBuilder.Vertex();
// measure distance
BRepExtrema_DistShapeShape measure(face,s);
measure.Perform();
if (!measure.IsDone() || measure.NbSolution() < 1)
continue;
if(measure.Value() < limit)
result.insert(aNode->GetID());
}
}
return result;
}

View File

@ -89,7 +89,7 @@
<UserDocu>Get the node position vector by an Node-ID</UserDocu>
</Documentation>
</Methode>
<Methode Name="getNodesByFace">
<Methode Name="getNodesByFace" Const="true">
<Documentation>
<UserDocu>Return a list of node IDs which belong to a TopoFace</UserDocu>
</Documentation>

View File

@ -30,6 +30,7 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <Base/VectorPy.h>
#include <Base/MatrixPy.h>
@ -534,13 +535,17 @@ PyObject* FemMeshPy::getNodesByFace(PyObject *args)
try {
const TopoDS_Shape& sh = static_cast<Part::TopoShapeFacePy*>(pW)->getTopoShapePtr()->_Shape;
const TopoDS_Face& fc = TopoDS::Face(sh);
if (sh.IsNull()) {
PyErr_SetString(PyExc_Exception, "Face is empty");
return 0;
}
Py::List ret;
throw Py::Exception("Not yet implemented");
std::set<long> resultSet = getFemMeshPtr()->getSurfaceNodes(fc);
for( std::set<long>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
ret.append(Py::Int(*it));
return Py::new_reference_to(ret);
}
catch (Standard_Failure) {

View File

@ -218,13 +218,14 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
{
/* std::set<long>& nodeSet;
for (Py::List::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
nodeSet.i (double)Py::Int(*it);
}
setHighlightNodes*/
throw Py::AttributeError("Not yet implemented");
std::set<long> res;
for( Py::List::iterator it = arg.begin(); it!= arg.end();++it){
Py::Int id(*it);
if(id)
res.insert(id);
}
this->getViewProviderFemMeshPtr()->setHighlightNodes(res);
}
Py::List ViewProviderFemMeshPy::getVisibleElementFaces(void) const

View File

@ -220,7 +220,7 @@ class _JobControlTaskPanel:
self.formUi = form_class()
self.form = QtGui.QWidget()
self.formUi.setupUi(self.form)
self.params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Machining_Distortion")
#self.params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
#Connect Signals and Slots
QtCore.QObject.connect(self.formUi.toolButton_chooseOutputDir, QtCore.SIGNAL("clicked()"), self.chooseOutputDir)
@ -235,7 +235,7 @@ class _JobControlTaskPanel:
def update(self):
'fills the widgets'
self.formUi.lineEdit_outputDir.setText(self.params.GetString("JobDir",'/'))
self.formUi.lineEdit_outputDir.setText(tempfile.gettempdir())
return
def accept(self):
@ -294,7 +294,32 @@ class _JobControlTaskPanel:
return
filename_without_suffix = MeshObject.Name
filename = dirName + '/' + MeshObject.Name + '.inp'
MeshObject.FemMesh.writeABAQUS(filename)
# now open again and write the setup:
inpfile = open(filename,'a')
inpfile.write('*MATERIAL, Name='+matmap['General_name'] + '\n')
#*MATERIAL, Name=steel
#*ELASTIC
#28000000, 0.3
#*SOLID SECTION, Elset=Eall, Material=steel
#*STEP
#*STATIC
#*BOUNDARY
#Nfix1,3,3,0
#Nfix2,2,3,0
#Nfix3,1,3,0
#*DLOAD
#*INCLUDE, INPUT=load.dlo
#*NODE FILE
#U
#*EL FILE
#S, E
#*END STEP
#current_file_name
#young_modulus = float(matmap['FEM_youngsmodulus'])

View File

@ -128,20 +128,13 @@ class _ViewProviderMechanicalMaterial:
class _MechanicalMaterialTaskPanel:
'''The editmode TaskPanel for MechanicalMaterial objects'''
def __init__(self,obj):
# the panel has a tree widget that contains categories
# for the subcomponents, such as additions, subtractions.
# the categories are shown only if they are not empty.
form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Fem/MechanicalMaterial.ui")
self.obj = obj
self.formUi = form_class()
self.form = QtGui.QWidget()
self.formUi.setupUi(self.form)
self.form=FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/MechanicalMaterial.ui")
self.params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
QtCore.QObject.connect(self.formUi.pushButton_MatWeb, QtCore.SIGNAL("clicked()"), self.goMatWeb)
QtCore.QObject.connect(self.formUi.comboBox_MaterialsInDir, QtCore.SIGNAL("currentIndexChanged(int)"), self.chooseMat)
QtCore.QObject.connect(self.form.pushButton_MatWeb, QtCore.SIGNAL("clicked()"), self.goMatWeb)
QtCore.QObject.connect(self.form.comboBox_MaterialsInDir, QtCore.SIGNAL("currentIndexChanged(int)"), self.chooseMat)
self.update()
@ -150,10 +143,11 @@ class _MechanicalMaterialTaskPanel:
matmap = self.obj.Material
matmap['Mechanical_youngsmodulus'] = str(self.formUi.spinBox_young_modulus.value() * 1e+6)
matmap['FEM_poissonratio'] = str(self.formUi.spinBox_poisson_ratio.value())
matmap['Mechanical_youngsmodulus'] = self.form.spinBox_young_modulus.text()
matmap['FEM_poissonratio'] = str(self.form.spinBox_poisson_ratio.value())
self.obj.Material = matmap
print matmap
def transferFrom(self):
@ -161,11 +155,11 @@ class _MechanicalMaterialTaskPanel:
matmap = self.obj.Material
if matmap.has_key('Mechanical_youngsmodulus'):
print float(matmap['Mechanical_youngsmodulus'])
self.formUi.spinBox_young_modulus.setValue(float(matmap['Mechanical_youngsmodulus'])/1e+6)
print matmap['Mechanical_youngsmodulus']
self.form.spinBox_young_modulus.setText(matmap['Mechanical_youngsmodulus'])
if matmap.has_key('FEM_poissonratio'):
print float(matmap['FEM_poissonratio'])
self.formUi.spinBox_poisson_ratio.setValue(float(matmap['FEM_poissonratio']))
#print float(matmap['FEM_poissonratio'])
self.form.spinBox_poisson_ratio.setValue(float(matmap['FEM_poissonratio']))
def isAllowedAlterSelection(self):
return False
@ -178,8 +172,8 @@ class _MechanicalMaterialTaskPanel:
def update(self):
'fills the widgets'
self.formUi.spinBox_young_modulus.setValue(0.0)
self.formUi.spinBox_poisson_ratio.setValue(0.0)
#self.form.spinBox_young_modulus.setValue(0.0)
#self.form.spinBox_poisson_ratio.setValue(0.0)
self.transferFrom()
self.fillMaterialCombo()
@ -187,10 +181,12 @@ class _MechanicalMaterialTaskPanel:
return
def accept(self):
print 'accept(self)'
self.transferTo()
FreeCADGui.ActiveDocument.resetEdit()
def reject(self):
print 'reject(self)'
FreeCADGui.ActiveDocument.resetEdit()
def saveMat(self):
@ -207,12 +203,12 @@ class _MechanicalMaterialTaskPanel:
def chooseMat(self,index):
if index == 0:return
import Material
print index
#print index
name = self.pathList[index-1]
print 'Import ', str(name)
#print 'Import ', str(name)
self.obj.Material = Material.importFCMat(str(name))
print self.obj.Material
#print self.obj.Material
self.transferFrom()
@ -221,13 +217,13 @@ class _MechanicalMaterialTaskPanel:
matmap = self.obj.Material
dirname = FreeCAD.ConfigGet("AppHomePath")+"data/Mod/Material/StandardMaterial"
self.pathList = glob.glob(dirname + '/*.FCMat')
self.formUi.comboBox_MaterialsInDir.clear()
self.form.comboBox_MaterialsInDir.clear()
if(matmap.has_key('General_name')):
self.formUi.comboBox_MaterialsInDir.addItem(matmap['General_name'])
self.form.comboBox_MaterialsInDir.addItem(matmap['General_name'])
else:
self.formUi.comboBox_MaterialsInDir.addItem('-> choose Material')
self.form.comboBox_MaterialsInDir.addItem('-> choose Material')
for i in self.pathList:
self.formUi.comboBox_MaterialsInDir.addItem(os.path.basename(i) )
self.form.comboBox_MaterialsInDir.addItem(os.path.basename(i) )

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>196</width>
<height>142</height>
<width>188</width>
<height>124</height>
</rect>
</property>
<property name="windowTitle">
@ -34,27 +34,17 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Young's Modulus:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="spinBox_young_modulus">
<item row="0" column="1">
<widget class="Gui::InputField" name="spinBox_young_modulus">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -70,28 +60,31 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="decimals">
<property name="unit" stdset="0">
<string>Pa</string>
</property>
<property name="decimals" stdset="0">
<number>3</number>
</property>
<property name="maximum">
<property name="maximum" stdset="0">
<double>2000.000000000000000</double>
</property>
<property name="singleStep">
<property name="singleStep" stdset="0">
<double>2.000000000000000</double>
</property>
<property name="value">
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_6">
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Young's Mod.(GPa)</string>
<string>Poisson Ratio:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="spinBox_poisson_ratio">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -122,17 +115,17 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Poisson Ratio</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -117,11 +117,6 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
ui->lengthEdit2->setMaximum(INT_MAX);
ui->lengthEdit2->setValue(l2);
// if it is a newly created object use the last value of the history
if(newObj){
ui->lengthEdit->setToLastUsedValue();
ui->lengthEdit2->setToLastUsedValue();
}
ui->checkBoxMidplane->setChecked(midplane);
// According to bug #0000521 the reversed option
@ -148,6 +143,14 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,bool newObj, QWidg
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
updateUI(index);
// if it is a newly created object use the last value of the history
if(newObj){
ui->lengthEdit->setToLastUsedValue();
ui->lengthEdit2->setToLastUsedValue();
}
}
void TaskPadParameters::updateUI(int index)