FEM: constraints thermomechanical: object implementation

This commit is contained in:
vdwalts 2016-08-01 21:57:32 +01:00 committed by wmayer
parent 26dabdfca7
commit 5adea8f032
29 changed files with 2801 additions and 0 deletions

View File

@ -51,6 +51,9 @@
#include "FemConstraintGear.h"
#include "FemConstraintPulley.h"
#include "FemConstraintDisplacement.h"
#include "FemConstraintTemperature.h"
#include "FemConstraintHeatflux.h"
#include "FemConstraintInitialTemperature.h"
#include "FemConstraintPlaneRotation.h"
#include "FemConstraintContact.h"
@ -149,6 +152,9 @@ PyMODINIT_FUNC initFem()
Fem::ConstraintGear ::init();
Fem::ConstraintPulley ::init();
Fem::ConstraintDisplacement ::init();
Fem::ConstraintTemperature ::init();
Fem::ConstraintHeatflux ::init();
Fem::ConstraintInitialTemperature ::init();
Fem::ConstraintPlaneRotation ::init();
Fem::ConstraintContact ::init();

View File

@ -200,6 +200,12 @@ SET(FemConstraints_SRCS
FemConstraintPulley.h
FemConstraintDisplacement.h
FemConstraintDisplacement.cpp
FemConstraintTemperature.h
FemConstraintTemperature.cpp
FemConstraintHeatflux.h
FemConstraintHeatflux.cpp
FemConstraintInitialTemperature.h
FemConstraintInitialTemperature.cpp
FemConstraintPlaneRotation.cpp
FemConstraintPlaneRotation.h
FemConstraintContact.cpp

View File

@ -0,0 +1,85 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#endif
#include "FemConstraintHeatflux.h"
using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintHeatflux, Fem::Constraint);
ConstraintHeatflux::ConstraintHeatflux()
{
ADD_PROPERTY(AmbientTemp,(0.0));
/*ADD_PROPERTY(FaceTemp,(0.0));*/
ADD_PROPERTY(FilmCoef,(0.0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintHeatflux::execute(void)
{
return Constraint::execute();
}
const char* ConstraintHeatflux::getViewProviderName(void) const
{
return "FemGui::ViewProviderFemConstraintHeatflux";
}
void ConstraintHeatflux::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@ -0,0 +1,59 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef FEM_CONSTRAINTHEATFLUX_H
#define FEM_CONSTRAINTHEATFLUX_H
#include "FemConstraint.h"
namespace Fem {
class AppFemExport ConstraintHeatflux : public Fem::Constraint
{
PROPERTY_HEADER(Fem::ConstraintHeatflux);
public:
ConstraintHeatflux(void);
App::PropertyFloat AmbientTemp;
/*App::PropertyFloat FaceTemp;*/
App::PropertyFloat FilmCoef;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
/// recalculate the object
virtual App::DocumentObjectExecReturn *execute(void);
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const;
protected:
virtual void onChanged(const App::Property* prop);
};
}
#endif // FEM_CONSTRAINTHEATFLUX_H

View File

@ -0,0 +1,84 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#endif
#include "FemConstraintInitialTemperature.h"
using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintInitialTemperature, Fem::Constraint);
ConstraintInitialTemperature::ConstraintInitialTemperature()
{
ADD_PROPERTY(initialTemperature,(300.0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintInitialTemperature::execute(void)
{
return Constraint::execute();
}
const char* ConstraintInitialTemperature::getViewProviderName(void) const
{
return "FemGui::ViewProviderFemConstraintInitialTemperature";
}
void ConstraintInitialTemperature::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef FEM_CONSTRAINTINITIALTEMPERATURE_H
#define FEM_CONSTRAINTINITIALTEMPERATURE_H
#include "FemConstraint.h"
namespace Fem
{
class AppFemExport ConstraintInitialTemperature : public Fem::Constraint
{
PROPERTY_HEADER(Fem::ConstraintInitialTemperature);
public:
/// Constructor
ConstraintInitialTemperature(void);
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
//Temperature parameters
App::PropertyFloat initialTemperature;
/// recalculate the object
virtual App::DocumentObjectExecReturn *execute(void);
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const;
protected:
virtual void onChanged(const App::Property* prop);
};
} //namespace Fem
#endif // FEM_CONSTRAINTINITIALTEMPERATURE_H

View File

@ -0,0 +1,84 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#endif
#include "FemConstraintTemperature.h"
using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintTemperature, Fem::Constraint);
ConstraintTemperature::ConstraintTemperature()
{
ADD_PROPERTY(Temperature,(300.0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintTemperature::execute(void)
{
return Constraint::execute();
}
const char* ConstraintTemperature::getViewProviderName(void) const
{
return "FemGui::ViewProviderFemConstraintTemperature";
}
void ConstraintTemperature::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially
// because the NormalDirection has not been calculated yet
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef FEM_CONSTRAINTTEMPERATURE_H
#define FEM_CONSTRAINTTEMPERATURE_H
#include "FemConstraint.h"
namespace Fem
{
class AppFemExport ConstraintTemperature : public Fem::Constraint
{
PROPERTY_HEADER(Fem::ConstraintTemperature);
public:
/// Constructor
ConstraintTemperature(void);
// Read-only (calculated values). These trigger changes in the ViewProvider
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
//Temperature parameters
App::PropertyFloat Temperature;
/// recalculate the object
virtual App::DocumentObjectExecReturn *execute(void);
/// returns the type name of the ViewProvider
const char* getViewProviderName(void) const;
protected:
virtual void onChanged(const App::Property* prop);
};
} //namespace Fem
#endif // FEM_CONSTRAINTTEMPERATURE_H

View File

@ -52,6 +52,9 @@
#include "ViewProviderFemConstraintGear.h"
#include "ViewProviderFemConstraintPulley.h"
#include "ViewProviderFemConstraintDisplacement.h"
#include "ViewProviderFemConstraintTemperature.h"
#include "ViewProviderFemConstraintHeatflux.h"
#include "ViewProviderFemConstraintInitialTemperature.h"
#include "ViewProviderFemConstraintPlaneRotation.h"
#include "ViewProviderFemConstraintContact.h"
#include "ViewProviderResult.h"
@ -119,6 +122,9 @@ PyMODINIT_FUNC initFemGui()
FemGui::ViewProviderFemConstraintGear ::init();
FemGui::ViewProviderFemConstraintPulley ::init();
FemGui::ViewProviderFemConstraintDisplacement ::init();
FemGui::ViewProviderFemConstraintHeatflux ::init();
FemGui::ViewProviderFemConstraintTemperature ::init();
FemGui::ViewProviderFemConstraintInitialTemperature ::init();
FemGui::ViewProviderFemConstraintPlaneRotation::init();
FemGui::ViewProviderFemConstraintContact ::init();
FemGui::ViewProviderResult ::init();

View File

@ -65,6 +65,9 @@ set(FemGui_MOC_HDRS
TaskFemConstraintGear.h
TaskFemConstraintPulley.h
TaskFemConstraintDisplacement.h
TaskFemConstraintTemperature.h
TaskFemConstraintHeatflux.h
TaskFemConstraintInitialTemperature.h
TaskFemConstraintPlaneRotation.h
TaskFemConstraintContact.h
TaskTetParameter.h
@ -94,6 +97,9 @@ set(FemGui_UIC_SRCS
TaskFemConstraintForce.ui
TaskFemConstraintPressure.ui
TaskFemConstraintDisplacement.ui
TaskFemConstraintTemperature.ui
TaskFemConstraintHeatflux.ui
TaskFemConstraintInitialTemperature.ui
TaskFemConstraintPlaneRotation.ui
TaskFemConstraintContact.ui
TaskTetParameter.ui
@ -144,6 +150,15 @@ SET(FemGui_DLG_SRCS
TaskFemConstraintDisplacement.ui
TaskFemConstraintDisplacement.cpp
TaskFemConstraintDisplacement.h
TaskFemConstraintTemperature.ui
TaskFemConstraintTemperature.cpp
TaskFemConstraintTemperature.h
TaskFemConstraintHeatflux.ui
TaskFemConstraintHeatflux.cpp
TaskFemConstraintHeatflux.h
TaskFemConstraintInitialTemperature.ui
TaskFemConstraintInitialTemperature.cpp
TaskFemConstraintInitialTemperature.h
TaskFemConstraintPlaneRotation.ui
TaskFemConstraintPlaneRotation.cpp
TaskFemConstraintPlaneRotation.h
@ -194,6 +209,12 @@ SET(FemGui_SRCS_ViewProvider
ViewProviderFemConstraintPulley.h
ViewProviderFemConstraintDisplacement.cpp
ViewProviderFemConstraintDisplacement.h
ViewProviderFemConstraintTemperature.cpp
ViewProviderFemConstraintTemperature.h
ViewProviderFemConstraintHeatflux.cpp
ViewProviderFemConstraintHeatflux.h
ViewProviderFemConstraintInitialTemperature.cpp
ViewProviderFemConstraintInitialTemperature.h
ViewProviderFemConstraintPlaneRotation.cpp
ViewProviderFemConstraintPlaneRotation.h
ViewProviderFemConstraintContact.cpp

View File

@ -439,7 +439,50 @@ bool CmdFemConstraintContact::isActive(void)
}
//=====================================================================================
DEF_STD_CMD_A(CmdFemConstraintHeatflux);
CmdFemConstraintHeatflux::CmdFemConstraintHeatflux()
: Command("Fem_ConstraintHeatflux")
{
sAppModule = "Fem";
sGroup = QT_TR_NOOP("Fem");
sMenuText = QT_TR_NOOP("Constraint heatflux ");
sToolTipText = QT_TR_NOOP("Creates a FEM constraint for a heatflux acting on a face");
sWhatsThis = "Fem_ConstraintHeatflux";
sStatusTip = sToolTipText;
sPixmap = "fem-constraint-heatflux";
}
void CmdFemConstraintHeatflux::activated(int iMsg)
{
Fem::FemAnalysis *Analysis;
if(getConstraintPrerequisits(&Analysis))
return;
std::string FeatName = getUniqueObjectName("FemConstraintHeatflux");
openCommand("Make FEM constraint heatflux on face");
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintHeatflux\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.AmbientTemp = 300.0",FeatName.c_str()); //OvG: set default not equal to 0
doCommand(Doc,"App.activeDocument().%s.FilmCoef = 10.0",FeatName.c_str()); //OvG: set default not equal to 0
doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",
Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts
updateActive();
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
}
bool CmdFemConstraintHeatflux::isActive(void)
{
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
}
//=====================================================================================
DEF_STD_CMD_A(CmdFemConstraintForce);
CmdFemConstraintForce::CmdFemConstraintForce()
@ -655,6 +698,92 @@ bool CmdFemConstraintDisplacement::isActive(void)
{
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
}
//=====================================================================================
DEF_STD_CMD_A(CmdFemConstraintTemperature);
CmdFemConstraintTemperature::CmdFemConstraintTemperature()
: Command("Fem_ConstraintTemperature")
{
sAppModule = "Fem";
sGroup = QT_TR_NOOP("Fem");
sMenuText = QT_TR_NOOP("Constraint temperature ");
sToolTipText = QT_TR_NOOP("Creates a FEM constraint for a temperature acting on a face");
sWhatsThis = "Fem_ConstraintTemperature";
sStatusTip = sToolTipText;
sPixmap = "fem-constraint-temperature";
}
void CmdFemConstraintTemperature::activated(int iMsg)
{
Fem::FemAnalysis *Analysis;
if(getConstraintPrerequisits(&Analysis))
return;
std::string FeatName = getUniqueObjectName("FemConstraintTemperature");
openCommand("Make FEM constraint temperature on face");
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintTemperature\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",
Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts
updateActive();
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
}
bool CmdFemConstraintTemperature::isActive(void)
{
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
}
//=====================================================================================
DEF_STD_CMD_A(CmdFemConstraintInitialTemperature);
CmdFemConstraintInitialTemperature::CmdFemConstraintInitialTemperature()
: Command("Fem_ConstraintInitialTemperature")
{
sAppModule = "Fem";
sGroup = QT_TR_NOOP("Fem");
sMenuText = QT_TR_NOOP("Constraint initial temperature");
sToolTipText = QT_TR_NOOP("Creates a FEM constraint for initial temperature acting on a body");
sWhatsThis = "Fem_ConstraintInitialTemperature";
sStatusTip = sToolTipText;
sPixmap = "fem-constraint-InitialTemperature";
}
void CmdFemConstraintInitialTemperature::activated(int iMsg)
{
Fem::FemAnalysis *Analysis;
if(getConstraintPrerequisits(&Analysis))
return;
std::string FeatName = getUniqueObjectName("FemConstraintInitialTemperature");
openCommand("Make FEM constraint intial temperature on body");
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintInitialTemperature\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",
Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts
updateActive();
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
}
bool CmdFemConstraintInitialTemperature::isActive(void)
{
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
}
// #####################################################################################################
@ -1229,6 +1358,9 @@ void CreateFemCommands(void)
rcCmdMgr.addCommand(new CmdFemConstraintGear());
rcCmdMgr.addCommand(new CmdFemConstraintPulley());
rcCmdMgr.addCommand(new CmdFemConstraintDisplacement());
rcCmdMgr.addCommand(new CmdFemConstraintTemperature());
rcCmdMgr.addCommand(new CmdFemConstraintHeatflux());
rcCmdMgr.addCommand(new CmdFemConstraintInitialTemperature());
rcCmdMgr.addCommand(new CmdFemConstraintPlaneRotation());
rcCmdMgr.addCommand(new CmdFemConstraintContact());

View File

@ -0,0 +1,403 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintHeatflux.h"
#include "TaskFemConstraintHeatflux.h"
#include "ui_TaskFemConstraintHeatflux.h"
#include <App/Application.h>
#include <Gui/Command.h>
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintHeatflux */
TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-heatflux")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintHeatflux();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
QAction* action = new QAction(tr("Delete"), ui->lw_references);
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->if_ambienttemp, SIGNAL(valueChanged(double)),
this, SLOT(onAmbientTempChanged(double)));
//connect(ui->if_facetemp, SIGNAL(valueChanged(double)),
// this, SLOT(onFaceTempChanged(double)));
connect(ui->if_filmcoef, SIGNAL(valueChanged(double)),
this, SLOT(onFilmCoefChanged(double)));
this->groupLayout()->addWidget(proxy);
// Temporarily prevent unnecessary feature recomputes
ui->if_ambienttemp->blockSignals(true);
//ui->if_facetemp->blockSignals(true);
ui->if_filmcoef->blockSignals(true);
ui->lw_references->blockSignals(true);
ui->btnAdd->blockSignals(true);
ui->btnRemove->blockSignals(true);
// Get the feature data
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->if_ambienttemp->setMinimum(0);
ui->if_ambienttemp->setMaximum(FLOAT_MAX);
Base::Quantity t = Base::Quantity(pcConstraint->AmbientTemp.getValue(), Base::Unit::Temperature);
ui->if_ambienttemp->setValue(t);
ui->if_filmcoef->setMinimum(0);
ui->if_filmcoef->setMaximum(FLOAT_MAX);
Base::Quantity f = Base::Quantity(pcConstraint->FilmCoef.getValue(), Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
}
if (Objects.size() > 0) {
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
ui->if_ambienttemp->blockSignals(false);
//ui->if_facetemp->blockSignals(false);
ui->if_filmcoef->blockSignals(false);
ui->lw_references->blockSignals(false);
ui->btnAdd->blockSignals(false);
ui->btnRemove->blockSignals(false);
updateUI();
}
TaskFemConstraintHeatflux::~TaskFemConstraintHeatflux()
{
delete ui;
}
void TaskFemConstraintHeatflux::updateUI()
{
if (ui->lw_references->model()->rowCount() == 0) {
// Go into reference selection mode if no reference has been selected yet
onButtonReference(true);
return;
}
}
void TaskFemConstraintHeatflux::onAmbientTempChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->AmbientTemp.setValue(val);//[K]
}
/*void TaskFemConstraintHeatflux::onFaceTempChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->FaceTemp.setValue(val); //[K]
}*/
void TaskFemConstraintHeatflux::onFilmCoefChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->FilmCoef.setValue(val); // [W]/[[m^2]/[K]]
}
void TaskFemConstraintHeatflux::addToSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
if (selection.size()==0){
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
if (static_cast<std::string>(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
return;
}
std::vector<std::string> subNames=it->getSubNames();
if (subNames.size()>0){
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){
if (subNames[subIt].substr(0,4).compare(std::string("Face"))!=0){
QMessageBox::warning(this, tr("Selection error"),tr("Selection must only consist of faces!"));
return;
}
}
}
else{
//fix me, if an object is selected completely, getSelectionEx does not return any SubElements
}
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
bool addMe=true;
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(),SubElements.end(),subNames[subIt]);
itr!= SubElements.end();
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj==Objects[std::distance(SubElements.begin(),itr)]){//if selected sub element's object equals the one in old list then it was added before so don't add
addMe=false;
}
}
if (addMe){
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
}
}
}
//Update UI
pcConstraint->References.setValues(Objects,SubElements);
updateUI();
}
void TaskFemConstraintHeatflux::removeFromSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
if (selection.size()==0){
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<int> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
if (static_cast<std::string>(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
return;
}
std::vector<std::string> subNames=it->getSubNames();
if (subNames.size()>0){
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){
if (subNames[subIt].substr(0,4).compare(std::string("Face"))!=0){
QMessageBox::warning(this, tr("Selection error"),tr("Selection must only consist of faces!"));
return;
}
}
}
else{
//fix me, if an object is selected completely, getSelectionEx does not return any SubElements
}
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(),SubElements.end(),subNames[subIt]);
itr!= SubElements.end();
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj==Objects[std::distance(SubElements.begin(),itr)]){//if selected sub element's object equals the one in old list then it was added before so mark for deletion
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
}
}
}
}
std::sort(itemsToDel.begin(),itemsToDel.end());
while (itemsToDel.size()>0){
Objects.erase(Objects.begin()+itemsToDel.back());
SubElements.erase(SubElements.begin()+itemsToDel.back());
itemsToDel.pop_back();
}
//Update UI
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
ui->lw_references->clear();
for (unsigned int j=0;j<Objects.size();j++){
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
}
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
pcConstraint->References.setValues(Objects,SubElements);
updateUI();
}
void TaskFemConstraintHeatflux::setSelection(QListWidgetItem* item){
std::string docName=ConstraintView->getObject()->getDocument()->getName();
std::string s = item->text().toStdString();
std::string delimiter = ":";
size_t pos = 0;
std::string objName;
std::string subName;
pos = s.find(delimiter);
objName = s.substr(0, pos);
s.erase(0, pos + delimiter.length());
subName=s;
Gui::Selection().clearSelection();
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
}
void TaskFemConstraintHeatflux::onReferenceDeleted() {
TaskFemConstraintHeatflux::removeFromSelection();
}
const std::string TaskFemConstraintHeatflux::getReferences() const
{
int rows = ui->lw_references->model()->rowCount();
std::vector<std::string> items;
for (int r = 0; r < rows; r++) {
items.push_back(ui->lw_references->item(r)->text().toStdString());
}
return TaskFemConstraint::getReferences(items);
}
double TaskFemConstraintHeatflux::getAmbientTemp(void) const
{
Base::Quantity temperature = ui->if_ambienttemp->getQuantity();
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
}
double TaskFemConstraintHeatflux::getFilmCoef(void) const
{
Base::Quantity filmcoef = ui->if_filmcoef->getQuantity();
double filmcoef_in_units = filmcoef.getValueAs(Base::Quantity(1.0,Base::Unit::ThermalTransferCoefficient));
return filmcoef_in_units;
}
void TaskFemConstraintHeatflux::changeEvent(QEvent *e)
{
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->if_ambienttemp->blockSignals(true);
ui->if_filmcoef->blockSignals(true);
ui->retranslateUi(proxy);
ui->if_ambienttemp->blockSignals(false);
ui->if_filmcoef->blockSignals(false);
}
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintHeatflux::TaskDlgFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintHeatflux(ConstraintView);;
Content.push_back(parameter);
}
//==== calls from the TaskView ===============================================================
void TaskDlgFemConstraintHeatflux::open()
{
// a transaction is already open at creation time of the panel
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Constraint heat flux");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintHeatflux::accept()
{
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintHeatflux* parameterHeatflux = static_cast<const TaskFemConstraintHeatflux*>(parameter);
std::string scale = "1";
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.AmbientTemp = %f",
name.c_str(), parameterHeatflux->getAmbientTemp());
/*Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.FaceTemp = %f",
name.c_str(), parameterHeatflux->getFaceTemp());*/
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.FilmCoef = %f",
name.c_str(), parameterHeatflux->getFilmCoef());
scale = parameterHeatflux->getScale(); //OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s",
name.c_str(), scale.c_str()); //OvG: implement modified scale
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
return false;
}
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintHeatflux::reject()
{
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
return true;
}
#include "moc_TaskFemConstraintHeatflux.cpp"

View File

@ -0,0 +1,90 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_TASKVIEW_TaskFemConstraintHeatflux_H
#define GUI_TASKVIEW_TaskFemConstraintHeatflux_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "ViewProviderFemConstraintHeatflux.h"
#include <QObject>
#include <Base/Console.h>
#include <App/DocumentObject.h>
#include <QListWidgetItem>
class Ui_TaskFemConstraintHeatflux;
namespace FemGui {
class TaskFemConstraintHeatflux : public TaskFemConstraint
{
Q_OBJECT
public:
TaskFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView,QWidget *parent = 0);
virtual ~TaskFemConstraintHeatflux();
double getAmbientTemp(void) const;
/*double getFaceTemp(void) const;*/
double getFilmCoef(void) const;
virtual const std::string getReferences() const;
private Q_SLOTS:
void onReferenceDeleted(void);
void onAmbientTempChanged(double val);
/*void onFaceTempChanged(double val);*/
void onFilmCoefChanged(double val);
void addToSelection();
void removeFromSelection();
void setSelection(QListWidgetItem* item);
protected:
virtual void changeEvent(QEvent *e);
private:
//void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI();
Ui_TaskFemConstraintHeatflux* ui;
};
class TaskDlgFemConstraintHeatflux : public TaskDlgFemConstraint
{
Q_OBJECT
public:
TaskDlgFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView);
virtual void open();
virtual bool accept();
virtual bool reject();
};
} //namespace FemGui
#endif // GUI_TASKVIEW_TaskFemConstraintHeatflux_H

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TaskFemConstraintHeatflux</class>
<widget class="QWidget" name="TaskFemConstraintHeatflux">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>379</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>TaskFemConstraintHeatflux</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="lbl_references">
<property name="text">
<string>Select multiple face(s), click Add or Remove:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lw_references"/>
</item>
<item>
<layout class="QHBoxLayout" name="layoutAmbientTemp">
<item>
<widget class="QLabel" name="lbl_ambienttemp">
<property name="text">
<string>Ambient Temperature</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_ambienttemp">
<property name="text">
<string>300 K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">K</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layoutFilmCoef">
<item>
<widget class="QLabel" name="lbl_filmcoef">
<property name="text">
<string>Film coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_filmcoef">
<property name="text">
<string>1 W/m^2/K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">W/m^2/K</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

@ -0,0 +1,163 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintInitialTemperature.h"
#include "TaskFemConstraintInitialTemperature.h"
#include "ui_TaskFemConstraintInitialTemperature.h"
#include <App/Application.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintInitialTemperature */
TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-InitialTemperature")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintInitialTemperature();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
this->groupLayout()->addWidget(proxy);
// Get the feature data
Fem::ConstraintInitialTemperature* pcConstraint = static_cast<Fem::ConstraintInitialTemperature*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->if_temperature->setMinimum(0);
ui->if_temperature->setMaximum(FLOAT_MAX);
Base::Quantity t = Base::Quantity(pcConstraint->initialTemperature.getValue(), Base::Unit::Temperature);
ui->if_temperature->setValue(t);
}
TaskFemConstraintInitialTemperature::~TaskFemConstraintInitialTemperature()
{
delete ui;
}
double TaskFemConstraintInitialTemperature::get_temperature() const{
Base::Quantity temperature = ui->if_temperature->getQuantity();
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
}
void TaskFemConstraintInitialTemperature::changeEvent(QEvent *e){
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintInitialTemperature::TaskDlgFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature *ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintInitialTemperature(ConstraintView);;
Content.push_back(parameter);
}
//==== calls from the TaskView ===============================================================
void TaskDlgFemConstraintInitialTemperature::open()
{
// a transaction is already open at creation time of the panel
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Constraint initial temperature");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintInitialTemperature::accept()
{
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintInitialTemperature* parameterTemperature = static_cast<const TaskFemConstraintInitialTemperature*>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.initialTemperature = %f",
name.c_str(), parameterTemperature->get_temperature());
std::string scale = parameterTemperature->getScale(); //OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
return false;
}
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!ConstraintView->getObject()->isValid())
throw Base::Exception(ConstraintView->getObject()->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
return false;
}
return true;
}
bool TaskDlgFemConstraintInitialTemperature::reject()
{
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
return true;
}
#include "moc_TaskFemConstraintInitialTemperature.cpp"

View File

@ -0,0 +1,78 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H
#define GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "ViewProviderFemConstraintInitialTemperature.h"
#include <QObject>
#include <Base/Console.h>
#include <App/DocumentObject.h>
#include <QListWidgetItem>
class Ui_TaskFemConstraintInitialTemperature;
namespace FemGui {
class TaskFemConstraintInitialTemperature : public TaskFemConstraint
{
Q_OBJECT
public:
TaskFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature *ConstraintView,QWidget *parent = 0);
~TaskFemConstraintInitialTemperature();
double get_temperature()const;
protected:
void changeEvent(QEvent *e);
private:
//void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI();
Ui_TaskFemConstraintInitialTemperature* ui;
};
class TaskDlgFemConstraintInitialTemperature : public TaskDlgFemConstraint
{
Q_OBJECT
public:
TaskDlgFemConstraintInitialTemperature(ViewProviderFemConstraintInitialTemperature *ConstraintView);
void open();
bool accept();
bool reject();
};
} //namespace FemGui
#endif // GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TaskFemConstraintInitialTemperature</class>
<widget class="QWidget" name="TaskFemConstraintInitialTemperature">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>307</width>
<height>118</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Insert component's initial temperature:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_temperature">
<property name="text">
<string>300 K</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,323 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintTemperature.h"
#include "TaskFemConstraintTemperature.h"
#include "ui_TaskFemConstraintTemperature.h"
#include <App/Application.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
using namespace FemGui;
using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintTemperature */
TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-temperature")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintTemperature();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
QAction* action = new QAction(tr("Delete"), ui->lw_references);
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
this->groupLayout()->addWidget(proxy);
// Get the feature data
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->if_temperature->setMinimum(0);
ui->if_temperature->setMaximum(FLOAT_MAX);
Base::Quantity t = Base::Quantity(pcConstraint->Temperature.getValue(), Base::Unit::Temperature);
ui->if_temperature->setValue(t);
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
}
if (Objects.size() > 0) {
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
updateUI();
}
TaskFemConstraintTemperature::~TaskFemConstraintTemperature()
{
delete ui;
}
void TaskFemConstraintTemperature::updateUI()
{
if (ui->lw_references->model()->rowCount() == 0) {
// Go into reference selection mode if no reference has been selected yet
onButtonReference(true);
return;
}
}
void TaskFemConstraintTemperature::addToSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
if (selection.size()==0){
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
if (static_cast<std::string>(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
return;
}
std::vector<std::string> subNames=it->getSubNames();
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
bool addMe=true;
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(),SubElements.end(),subNames[subIt]);
itr!= SubElements.end();
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj==Objects[std::distance(SubElements.begin(),itr)]){//if selected sub element's object equals the one in old list then it was added before so don't add
addMe=false;
}
}
if (addMe){
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
}
}
}
//Update UI
pcConstraint->References.setValues(Objects,SubElements);
updateUI();
}
void TaskFemConstraintTemperature::removeFromSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
if (selection.size()==0){
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<int> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
if (static_cast<std::string>(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
return;
}
std::vector<std::string> subNames=it->getSubNames();
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(),SubElements.end(),subNames[subIt]);
itr!= SubElements.end();
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj==Objects[std::distance(SubElements.begin(),itr)]){//if selected sub element's object equals the one in old list then it was added before so mark for deletion
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
}
}
}
}
std::sort(itemsToDel.begin(),itemsToDel.end());
while (itemsToDel.size()>0){
Objects.erase(Objects.begin()+itemsToDel.back());
SubElements.erase(SubElements.begin()+itemsToDel.back());
itemsToDel.pop_back();
}
//Update UI
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
ui->lw_references->clear();
for (unsigned int j=0;j<Objects.size();j++){
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
}
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
pcConstraint->References.setValues(Objects,SubElements);
updateUI();
}
void TaskFemConstraintTemperature::setSelection(QListWidgetItem* item){
std::string docName=ConstraintView->getObject()->getDocument()->getName();
std::string s = item->text().toStdString();
std::string delimiter = ":";
size_t pos = 0;
std::string objName;
std::string subName;
pos = s.find(delimiter);
objName = s.substr(0, pos);
s.erase(0, pos + delimiter.length());
subName=s;
Gui::Selection().clearSelection();
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
}
void TaskFemConstraintTemperature::onReferenceDeleted() {
TaskFemConstraintTemperature::removeFromSelection();
}
const std::string TaskFemConstraintTemperature::getReferences() const
{
int rows = ui->lw_references->model()->rowCount();
std::vector<std::string> items;
for (int r = 0; r < rows; r++) {
items.push_back(ui->lw_references->item(r)->text().toStdString());
}
return TaskFemConstraint::getReferences(items);
}
double TaskFemConstraintTemperature::get_temperature() const{
Base::Quantity temperature = ui->if_temperature->getQuantity();
double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
return temperature_in_kelvin;
}
void TaskFemConstraintTemperature::changeEvent(QEvent *e)
{
// TaskBox::changeEvent(e);
// if (e->type() == QEvent::LanguageChange) {
// ui->if_pressure->blockSignals(true);
// ui->retranslateUi(proxy);
// ui->if_pressure->blockSignals(false);
// }
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintTemperature::TaskDlgFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintTemperature(ConstraintView);;
Content.push_back(parameter);
}
//==== calls from the TaskView ===============================================================
void TaskDlgFemConstraintTemperature::open()
{
// a transaction is already open at creation time of the panel
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Constraint temperature");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintTemperature::accept()
{
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintTemperature* parameterTemperature = static_cast<const TaskFemConstraintTemperature*>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Temperature = %f",
name.c_str(), parameterTemperature->get_temperature());
std::string scale = parameterTemperature->getScale(); //OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
return false;
}
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintTemperature::reject()
{
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
return true;
}
#include "moc_TaskFemConstraintTemperature.cpp"

View File

@ -0,0 +1,86 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_TASKVIEW_TaskFemConstraintTemperature_H
#define GUI_TASKVIEW_TaskFemConstraintTemperature_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "ViewProviderFemConstraintTemperature.h"
#include <QObject>
#include <Base/Console.h>
#include <App/DocumentObject.h>
#include <QListWidgetItem>
class Ui_TaskFemConstraintTemperature;
namespace FemGui {
class TaskFemConstraintTemperature : public TaskFemConstraint
{
Q_OBJECT
public:
TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent = 0);
~TaskFemConstraintTemperature();
const std::string getReferences() const;
double get_temperature()const;
private Q_SLOTS:
void onReferenceDeleted(void);
void addToSelection();
void removeFromSelection();
void setSelection(QListWidgetItem* item);
protected:
void changeEvent(QEvent *e);
private:
//void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI();
Ui_TaskFemConstraintTemperature* ui;
};
class TaskDlgFemConstraintTemperature : public TaskDlgFemConstraint
{
Q_OBJECT
public:
TaskDlgFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView);
void open();
bool accept();
bool reject();
};
} //namespace FemGui
#endif // GUI_TASKVIEW_TaskFemConstraintTemperature_H

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TaskFemConstraintTemperature</class>
<widget class="QWidget" name="TaskFemConstraintTemperature">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>309</width>
<height>233</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="lbl_info">
<property name="text">
<string>Select multiple face(s), click Add or Remove</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lw_references"/>
</item>
<item>
<layout class="QHBoxLayout" name="layoutTemperature">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Temperature</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_temperature">
<property name="text">
<string>300 K</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</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

@ -0,0 +1,110 @@
<?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>312</width>
<height>316</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>25</x>
<y>20</y>
<width>301</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Select the vertices, lines and surfaces: </string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>19</x>
<y>266</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Temperature:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>116</x>
<y>265</y>
<width>113</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>25</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>231</x>
<y>270</y>
<width>66</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>ºC</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>131</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>153</x>
<y>50</y>
<width>131</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>21</x>
<y>91</y>
<width>261</width>
<height>151</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,78 @@
<?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>307</width>
<height>156</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>70</x>
<y>5</y>
<width>161</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string>Insert component's
initial temperature:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>38</x>
<y>78</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Temperature:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>135</x>
<y>77</y>
<width>113</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>25</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>250</x>
<y>82</y>
<width>66</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>ºC</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,194 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Standard_math.hxx>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoTranslation.h>
# include <Inventor/nodes/SoRotation.h>
# include <Inventor/nodes/SoMultipleCopy.h>
# include <Inventor/nodes/SoCylinder.h>
# include <Inventor/nodes/SoSphere.h>
# include <Inventor/nodes/SoText3.h>
# include <Inventor/nodes/SoFont.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoMaterialBinding.h>
# include <Precision.hxx>
#endif
#include "Mod/Fem/App/FemConstraintHeatflux.h"
#include "TaskFemConstraintHeatflux.h"
#include "ViewProviderFemConstraintHeatflux.h"
#include <Base/Console.h>
#include <Gui/Control.h>
using namespace FemGui;
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintHeatflux, FemGui::ViewProviderFemConstraint)
ViewProviderFemConstraintHeatflux::ViewProviderFemConstraintHeatflux()
{
sPixmap = "fem-constraint-heatflux";
ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f));
}
ViewProviderFemConstraintHeatflux::~ViewProviderFemConstraintHeatflux()
{
}
//FIXME setEdit needs a careful review
bool ViewProviderFemConstraintHeatflux::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// When double-clicking on the item for this constraint the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgFemConstraintHeatflux *constrDlg = qobject_cast<TaskDlgFemConstraintHeatflux *>(dlg);
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = 0; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != NULL) {
// Ignore the request to open another dialog
return false;
} else {
constraintDialog = new TaskFemConstraintHeatflux(this);
return true;
}
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// start the edit dialog
if (constrDlg)
Gui::Control().showDialog(constrDlg);
else
Gui::Control().showDialog(new TaskDlgFemConstraintHeatflux(this));
return true;
}
else {
return ViewProviderDocumentObject::setEdit(ModNum);
}
}
#define HEIGHT (1.5)
#define RADIUS (0.3)
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
void ViewProviderFemConstraintHeatflux::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(this->getObject());
float scaledradius = RADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only
float scaledheight = HEIGHT * pcConstraint->Scale.getValue();
//float ambienttemp = pcConstraint->AmbientTemp.getValue();
////float facetemp = pcConstraint->FaceTemp.getValue();
//float filmcoef = pcConstraint->FilmCoef.getValue();
if (strcmp(prop->getName(),"Points") == 0) {
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
if (points.size() != normals.size())
return;
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
//Define base and normal directions
SbVec3f base(p->x, p->y, p->z);
SbVec3f dir(n->x, n->y, n->z);//normal
///Temperature indication
//define separator
SoSeparator* sep = new SoSeparator();
///draw a temp gauge,with sphere and a cylinder
//first move to correct postion
SoTranslation* trans = new SoTranslation();
SbVec3f newPos=base+scaledradius*dir*0.7;
trans->translation.setValue(newPos);
sep->addChild(trans);
//adjust orientation
SoRotation* rot = new SoRotation();
rot->rotation.setValue(SbRotation(SbVec3f(0,1,0),dir));
sep->addChild(rot);
//define color of shape
SoMaterial* myMaterial = new SoMaterial;
myMaterial->diffuseColor.set1Value(0,SbColor(0.65,0.1,0.25));//RGB
//myMaterial->diffuseColor.set1Value(1,SbColor(.1,.1,.1));//possible to adjust sides separately
sep->addChild(myMaterial);
//draw a sphere
SoSphere* sph = new SoSphere();
sph->radius.setValue(scaledradius*0.75);
sep->addChild(sph);
//translate postion
SoTranslation* trans2 = new SoTranslation();
trans2->translation.setValue(SbVec3f(0,scaledheight*0.375,0));
sep->addChild(trans2);
//draw a cylinder
SoCylinder* cyl = new SoCylinder();
cyl->height.setValue(scaledheight*0.5);
cyl->radius.setValue(scaledradius*0.375);
sep->addChild(cyl);
//translate postion
SoTranslation* trans3 = new SoTranslation();
trans3->translation.setValue(SbVec3f(0,scaledheight*0.375,0));
sep->addChild(trans3);
//define color of shape
SoMaterial *myMaterial2 = new SoMaterial;
myMaterial2->diffuseColor.set1Value(0,SbColor(1,1,1));//RGB
sep->addChild(myMaterial2);
//draw a cylinder
SoCylinder* cyl2 = new SoCylinder();
cyl2->height.setValue(scaledheight*0.25);
cyl2->radius.setValue(scaledradius*0.375);
sep->addChild(cyl2);
//translate postion
SoTranslation* trans4 = new SoTranslation();
trans4->translation.setValue(SbVec3f(0,-scaledheight*0.375,0));
sep->addChild(trans4);
//draw a cylinder
SoCylinder* cyl3 = new SoCylinder();
cyl3->height.setValue(scaledheight*0.05);
cyl3->radius.setValue(scaledradius*1);
sep->addChild(cyl3);
pShapeSep->addChild(sep);
n++;
}
}
// Gets called whenever a property of the attached object changes
ViewProviderFemConstraint::updateData(prop);
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_VIEWPROVIDERFEMCONSTRAINTHEATFLUX_H
#define GUI_VIEWPROVIDERFEMCONSTRAINTHEATFLUX_H
#include "ViewProviderFemConstraint.h"
namespace FemGui {
class FemGuiExport ViewProviderFemConstraintHeatflux : public FemGui::ViewProviderFemConstraint
{
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintHeatflux);
public:
ViewProviderFemConstraintHeatflux();
virtual ~ViewProviderFemConstraintHeatflux();
virtual void updateData(const App::Property*);
protected:
virtual bool setEdit(int ModNum);
};
}
#endif // GUI_VIEWPROVIDERFEMCONSTRAINTHEATFLUX_H

View File

@ -0,0 +1,104 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Standard_math.hxx>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoTranslation.h>
# include <Inventor/nodes/SoRotation.h>
# include <Inventor/nodes/SoMultipleCopy.h>
# include <Inventor/nodes/SoCylinder.h>
# include <Inventor/nodes/SoSphere.h>
# include <Inventor/nodes/SoText3.h>
# include <Inventor/nodes/SoFont.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoMaterialBinding.h>
# include <Precision.hxx>
#endif
#include "Mod/Fem/App/FemConstraintInitialTemperature.h"
#include "TaskFemConstraintInitialTemperature.h"
#include "ViewProviderFemConstraintInitialTemperature.h"
#include <Base/Console.h>
#include <Gui/Control.h>
using namespace FemGui;
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintInitialTemperature, FemGui::ViewProviderFemConstraint)
ViewProviderFemConstraintInitialTemperature::ViewProviderFemConstraintInitialTemperature()
{
sPixmap = "fem-constraint-InitialTemperature";
ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f));
}
ViewProviderFemConstraintInitialTemperature::~ViewProviderFemConstraintInitialTemperature()
{
}
//FIXME setEdit needs a careful review
bool ViewProviderFemConstraintInitialTemperature::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// When double-clicking on the item for this constraint the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgFemConstraintInitialTemperature *constrDlg = qobject_cast<TaskDlgFemConstraintInitialTemperature *>(dlg);
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = 0; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != NULL) {
// Ignore the request to open another dialog
return false;
} else {
constraintDialog = new TaskFemConstraintInitialTemperature(this);
return true;
}
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// start the edit dialog
if (constrDlg)
Gui::Control().showDialog(constrDlg);
else
Gui::Control().showDialog(new TaskDlgFemConstraintInitialTemperature(this));
return true;
}
else {
return ViewProviderDocumentObject::setEdit(ModNum);
}
}
void ViewProviderFemConstraintInitialTemperature::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
ViewProviderFemConstraint::updateData(prop);
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_VIEWPROVIDERFEMCONSTRAINTInitialTemperature_H
#define GUI_VIEWPROVIDERFEMCONSTRAINTInitialTemperature_H
#include "ViewProviderFemConstraint.h"
namespace FemGui {
class FemGuiExport ViewProviderFemConstraintInitialTemperature : public FemGui::ViewProviderFemConstraint
{
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintInitialTemperature);
public:
ViewProviderFemConstraintInitialTemperature();
virtual ~ViewProviderFemConstraintInitialTemperature();
virtual void updateData(const App::Property*);
protected:
virtual bool setEdit(int ModNum);
};
}
#endif // GUI_VIEWPROVIDERFEMCONSTRAINTInitialTemperature_H

View File

@ -0,0 +1,184 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Standard_math.hxx>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoTranslation.h>
# include <Inventor/nodes/SoRotation.h>
# include <Inventor/nodes/SoMultipleCopy.h>
# include <Inventor/nodes/SoCylinder.h>
# include <Inventor/nodes/SoSphere.h>
# include <Inventor/nodes/SoText3.h>
# include <Inventor/nodes/SoFont.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoMaterialBinding.h>
# include <Inventor/nodes/SoScale.h>
# include <Precision.hxx>
#endif
#include "Mod/Fem/App/FemConstraintTemperature.h"
#include "TaskFemConstraintTemperature.h"
#include "ViewProviderFemConstraintTemperature.h"
#include <Base/Console.h>
#include <Gui/Control.h>
using namespace FemGui;
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintTemperature, FemGui::ViewProviderFemConstraint)
ViewProviderFemConstraintTemperature::ViewProviderFemConstraintTemperature()
{
sPixmap = "fem-constraint-temperature";
ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f));
}
ViewProviderFemConstraintTemperature::~ViewProviderFemConstraintTemperature()
{
}
//FIXME setEdit needs a careful review
bool ViewProviderFemConstraintTemperature::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// When double-clicking on the item for this constraint the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgFemConstraintTemperature *constrDlg = qobject_cast<TaskDlgFemConstraintTemperature *>(dlg);
if (constrDlg && constrDlg->getConstraintView() != this)
constrDlg = 0; // another constraint left open its task panel
if (dlg && !constrDlg) {
if (constraintDialog != NULL) {
// Ignore the request to open another dialog
return false;
} else {
constraintDialog = new TaskFemConstraintTemperature(this);
return true;
}
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// start the edit dialog
if (constrDlg)
Gui::Control().showDialog(constrDlg);
else
Gui::Control().showDialog(new TaskDlgFemConstraintTemperature(this));
return true;
}
else {
return ViewProviderDocumentObject::setEdit(ModNum);
}
}
#define HEIGHT (1.5)
#define RADIUS (0.3)
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
void ViewProviderFemConstraintTemperature::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(this->getObject());
float scaledradius = RADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only
float scaledheight = HEIGHT * pcConstraint->Scale.getValue();
//float temperature = pcConstraint->temperature.getValue();
if (strcmp(prop->getName(),"Points") == 0) {
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
if (points.size() != normals.size())
return;
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
//Define base and normal directions
SbVec3f base(p->x, p->y, p->z);
SbVec3f dir(n->x, n->y, n->z);//normal
///Temperature indication
//define separator
SoSeparator* sep = new SoSeparator();
///draw a temp gauge,with sphere and a cylinder
//first move to correct postion
SoTranslation* trans = new SoTranslation();
SbVec3f newPos=base+scaledradius*dir*0.7;
trans->translation.setValue(newPos);
sep->addChild(trans);
//adjust orientation
SoRotation* rot = new SoRotation();
rot->rotation.setValue(SbRotation(SbVec3f(0,1,0),dir));
sep->addChild(rot);
//define color of shape
SoMaterial* myMaterial = new SoMaterial;
myMaterial->diffuseColor.set1Value(0,SbColor(1,0,0));//RGB
//myMaterial->diffuseColor.set1Value(1,SbColor(.1,.1,.1));//possible to adjust sides separately
sep->addChild(myMaterial);
//draw a sphere
SoSphere* sph = new SoSphere();
sph->radius.setValue(scaledradius*0.75);
sep->addChild(sph);
//translate postion
SoTranslation* trans2 = new SoTranslation();
trans2->translation.setValue(SbVec3f(0,scaledheight*0.375,0));
sep->addChild(trans2);
//draw a cylinder
SoCylinder* cyl = new SoCylinder();
cyl->height.setValue(scaledheight*0.5);
cyl->radius.setValue(scaledradius*0.375);
sep->addChild(cyl);
//translate postion
SoTranslation* trans3 = new SoTranslation();
trans3->translation.setValue(SbVec3f(0,scaledheight*0.375,0));
sep->addChild(trans3);
//define color of shape
SoMaterial *myMaterial2 = new SoMaterial;
myMaterial2->diffuseColor.set1Value(0,SbColor(1,1,1));//RGB
sep->addChild(myMaterial2);
//draw a cylinder
SoCylinder* cyl2 = new SoCylinder();
cyl2->height.setValue(scaledheight*0.25);
cyl2->radius.setValue(scaledradius*0.375);
sep->addChild(cyl2);
pShapeSep->addChild(sep);
n++;
}
}
// Gets called whenever a property of the attached object changes
ViewProviderFemConstraint::updateData(prop);
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_VIEWPROVIDERFEMCONSTRAINTTemperature_H
#define GUI_VIEWPROVIDERFEMCONSTRAINTTemperature_H
#include "ViewProviderFemConstraint.h"
namespace FemGui {
class FemGuiExport ViewProviderFemConstraintTemperature : public FemGui::ViewProviderFemConstraint
{
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintTemperature);
public:
ViewProviderFemConstraintTemperature();
virtual ~ViewProviderFemConstraintTemperature();
virtual void updateData(const App::Property*);
protected:
virtual bool setEdit(int ModNum);
};
}
#endif // GUI_VIEWPROVIDERFEMCONSTRAINTTemperature_H

View File

@ -78,6 +78,10 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Fem_ConstraintGear"
<< "Fem_ConstraintPulley"
<< "Separator"
<< "Fem_ConstraintTemperature"
<< "Fem_ConstraintHeatflux"
<< "Fem_ConstraintInitialTemperature"
<< "Separator"
<< "Fem_ControlSolver"
<< "Fem_RunSolver"
<< "Separator"
@ -131,6 +135,10 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Fem_ConstraintGear"
<< "Fem_ConstraintPulley"
<< "Separator"
<< "Fem_ConstraintTemperature"
<< "Fem_ConstraintHeatflux"
<< "Fem_ConstraintInitialTemperature"
<< "Separator"
<< "Fem_ControlSolver"
<< "Fem_RunSolver"
<< "Separator"