FEM: Implement constraint displacement in C++
This commit is contained in:
parent
6a103493a1
commit
b1dc2cbf94
|
@ -50,6 +50,7 @@
|
||||||
#include "FemConstraintPressure.h"
|
#include "FemConstraintPressure.h"
|
||||||
#include "FemConstraintGear.h"
|
#include "FemConstraintGear.h"
|
||||||
#include "FemConstraintPulley.h"
|
#include "FemConstraintPulley.h"
|
||||||
|
#include "FemConstraintDisplacement.h"
|
||||||
|
|
||||||
#include "FemResultObject.h"
|
#include "FemResultObject.h"
|
||||||
#include "FemSolverObject.h"
|
#include "FemSolverObject.h"
|
||||||
|
@ -138,6 +139,7 @@ PyMODINIT_FUNC initFem()
|
||||||
Fem::ConstraintPressure ::init();
|
Fem::ConstraintPressure ::init();
|
||||||
Fem::ConstraintGear ::init();
|
Fem::ConstraintGear ::init();
|
||||||
Fem::ConstraintPulley ::init();
|
Fem::ConstraintPulley ::init();
|
||||||
|
Fem::ConstraintDisplacement ::init();
|
||||||
|
|
||||||
Fem::FemResultObject ::init();
|
Fem::FemResultObject ::init();
|
||||||
Fem::FemResultObjectPython ::init();
|
Fem::FemResultObjectPython ::init();
|
||||||
|
|
|
@ -110,6 +110,7 @@ SET(FemScripts_SRCS
|
||||||
MechanicalMaterial.py
|
MechanicalMaterial.py
|
||||||
SelectionObserverFem.py
|
SelectionObserverFem.py
|
||||||
TestFem.py
|
TestFem.py
|
||||||
|
ccxInpWriterFemConstraintDisplacement.py
|
||||||
|
|
||||||
TaskPanelFemBeamSection.ui
|
TaskPanelFemBeamSection.ui
|
||||||
TaskPanelFemShellThickness.ui
|
TaskPanelFemShellThickness.ui
|
||||||
|
@ -184,6 +185,8 @@ SET(FemConstraints_SRCS
|
||||||
FemConstraintGear.h
|
FemConstraintGear.h
|
||||||
FemConstraintPulley.cpp
|
FemConstraintPulley.cpp
|
||||||
FemConstraintPulley.h
|
FemConstraintPulley.h
|
||||||
|
FemConstraintDisplacement.h
|
||||||
|
FemConstraintDisplacement.cpp
|
||||||
)
|
)
|
||||||
SOURCE_GROUP("Constraints" FILES ${FemConstraints_SRCS})
|
SOURCE_GROUP("Constraints" FILES ${FemConstraints_SRCS})
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vecto
|
||||||
GProp_GProps props;
|
GProp_GProps props;
|
||||||
BRepGProp::VolumeProperties(toposhape._Shape, props);
|
BRepGProp::VolumeProperties(toposhape._Shape, props);
|
||||||
double lx = props.Mass();
|
double lx = props.Mass();
|
||||||
*scale = this->calcDrawScaleFactor(sqrt(lx)); //OvG: setup draw scale for constraint
|
*scale = this->calcDrawScaleFactor(sqrt(lx)*0.5); //OvG: setup draw scale for constraint
|
||||||
} else if (sh.ShapeType() == TopAbs_EDGE) {
|
} else if (sh.ShapeType() == TopAbs_EDGE) {
|
||||||
BRepAdaptor_Curve curve(TopoDS::Edge(sh));
|
BRepAdaptor_Curve curve(TopoDS::Edge(sh));
|
||||||
double fp = curve.FirstParameter();
|
double fp = curve.FirstParameter();
|
||||||
|
@ -185,7 +185,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vecto
|
||||||
double l = props.Mass();
|
double l = props.Mass();
|
||||||
// Create points with 10 units distance, but at least one at the beginning and end of the edge
|
// Create points with 10 units distance, but at least one at the beginning and end of the edge
|
||||||
int steps;
|
int steps;
|
||||||
if (l >= 100) //OvG: Increase 10 units distance proportionately to l for larger objects.
|
if (l >= 30) //OvG: Increase 10 units distance proportionately to l for larger objects.
|
||||||
{
|
{
|
||||||
*scale = this->calcDrawScaleFactor(l); //OvG: setup draw scale for constraint
|
*scale = this->calcDrawScaleFactor(l); //OvG: setup draw scale for constraint
|
||||||
steps = (int)round(l / (10*( *scale)));
|
steps = (int)round(l / (10*( *scale)));
|
||||||
|
@ -232,7 +232,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vecto
|
||||||
isoc.Load(GeomAbs_IsoV, ulp);
|
isoc.Load(GeomAbs_IsoV, ulp);
|
||||||
double lu = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0;
|
double lu = (l + GCPnts_AbscissaPoint::Length(isoc, Precision::Confusion()))/2.0;
|
||||||
int stepsv;
|
int stepsv;
|
||||||
if (lv >= 100) //OvG: Increase 10 units distance proportionately to lv for larger objects.
|
if (lv >= 30) //OvG: Increase 10 units distance proportionately to lv for larger objects.
|
||||||
{
|
{
|
||||||
*scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint
|
*scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint
|
||||||
stepsv = (int)round(lv / (10*( *scale)));
|
stepsv = (int)round(lv / (10*( *scale)));
|
||||||
|
@ -250,7 +250,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vecto
|
||||||
}
|
}
|
||||||
stepsv = stepsv>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:stepsv; //OvG: Place upper limit on number of steps
|
stepsv = stepsv>CONSTRAINTSTEPLIMIT?CONSTRAINTSTEPLIMIT:stepsv; //OvG: Place upper limit on number of steps
|
||||||
int stepsu;
|
int stepsu;
|
||||||
if (lu >= 100) //OvG: Increase 10 units distance proportionately to lu for larger objects.
|
if (lu >= 30) //OvG: Increase 10 units distance proportionately to lu for larger objects.
|
||||||
{
|
{
|
||||||
*scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint
|
*scale = this->calcDrawScaleFactor(lv,lu); //OvG: setup draw scale for constraint
|
||||||
stepsu = (int)round(lu / (10*( *scale)));
|
stepsu = (int)round(lu / (10*( *scale)));
|
||||||
|
|
101
src/Mod/Fem/App/FemConstraintDisplacement.cpp
Normal file
101
src/Mod/Fem/App/FemConstraintDisplacement.cpp
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 "FemConstraintDisplacement.h"
|
||||||
|
|
||||||
|
using namespace Fem;
|
||||||
|
|
||||||
|
PROPERTY_SOURCE(Fem::ConstraintDisplacement, Fem::Constraint);
|
||||||
|
|
||||||
|
ConstraintDisplacement::ConstraintDisplacement()
|
||||||
|
{
|
||||||
|
ADD_PROPERTY(xDisplacement,(0.0));
|
||||||
|
ADD_PROPERTY(yDisplacement,(0.0));
|
||||||
|
ADD_PROPERTY(zDisplacement,(0.0));
|
||||||
|
ADD_PROPERTY(xRotation,(0.0));
|
||||||
|
ADD_PROPERTY(yRotation,(0.0));
|
||||||
|
ADD_PROPERTY(zRotation,(0.0));
|
||||||
|
ADD_PROPERTY(xFree,(1));
|
||||||
|
ADD_PROPERTY(yFree,(1));
|
||||||
|
ADD_PROPERTY(zFree,(1));
|
||||||
|
ADD_PROPERTY(xFix,(0));
|
||||||
|
ADD_PROPERTY(yFix,(0));
|
||||||
|
ADD_PROPERTY(zFix,(0));
|
||||||
|
ADD_PROPERTY(rotxFree,(1));
|
||||||
|
ADD_PROPERTY(rotyFree,(1));
|
||||||
|
ADD_PROPERTY(rotzFree,(1));
|
||||||
|
ADD_PROPERTY(rotxFix,(0));
|
||||||
|
ADD_PROPERTY(rotyFix,(0));
|
||||||
|
ADD_PROPERTY(rotzFix,(0));
|
||||||
|
|
||||||
|
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
|
||||||
|
"Points where symbols are drawn");
|
||||||
|
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",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 *ConstraintDisplacement::execute(void)
|
||||||
|
{
|
||||||
|
return Constraint::execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ConstraintDisplacement::getViewProviderName(void) const
|
||||||
|
{
|
||||||
|
return "FemGui::ViewProviderFemConstraintDisplacement";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConstraintDisplacement::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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
82
src/Mod/Fem/App/FemConstraintDisplacement.h
Normal file
82
src/Mod/Fem/App/FemConstraintDisplacement.h
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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_CONSTRAINTDISPLACEMENT_H
|
||||||
|
#define FEM_CONSTRAINTDISPLACEMENT_H
|
||||||
|
|
||||||
|
#include "FemConstraint.h"
|
||||||
|
|
||||||
|
namespace Fem
|
||||||
|
{
|
||||||
|
|
||||||
|
class AppFemExport ConstraintDisplacement : public Fem::Constraint
|
||||||
|
{
|
||||||
|
PROPERTY_HEADER(Fem::ConstraintDisplacement);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Constructor
|
||||||
|
ConstraintDisplacement(void);
|
||||||
|
|
||||||
|
// Read-only (calculated values). These trigger changes in the ViewProvider
|
||||||
|
App::PropertyVectorList Points;
|
||||||
|
App::PropertyVectorList Normals;
|
||||||
|
|
||||||
|
//Displacement parameters
|
||||||
|
App::PropertyFloat xDisplacement;
|
||||||
|
App::PropertyFloat yDisplacement;
|
||||||
|
App::PropertyFloat zDisplacement;
|
||||||
|
App::PropertyFloat xRotation;
|
||||||
|
App::PropertyFloat yRotation;
|
||||||
|
App::PropertyFloat zRotation;
|
||||||
|
App::PropertyBool xFree;
|
||||||
|
App::PropertyBool yFree;
|
||||||
|
App::PropertyBool zFree;
|
||||||
|
App::PropertyBool xFix;
|
||||||
|
App::PropertyBool yFix;
|
||||||
|
App::PropertyBool zFix;
|
||||||
|
App::PropertyBool rotxFree;
|
||||||
|
App::PropertyBool rotyFree;
|
||||||
|
App::PropertyBool rotzFree;
|
||||||
|
App::PropertyBool rotxFix;
|
||||||
|
App::PropertyBool rotyFix;
|
||||||
|
App::PropertyBool rotzFix;
|
||||||
|
//App::PropertyBool element;
|
||||||
|
|
||||||
|
/// 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_CONSTRAINTDISPLACEMENT_H
|
|
@ -11,6 +11,8 @@ INSTALL(
|
||||||
Init.py
|
Init.py
|
||||||
InitGui.py
|
InitGui.py
|
||||||
|
|
||||||
|
ccxInpWriterFemConstraintDisplacement.py
|
||||||
|
|
||||||
convert2TetGen.py
|
convert2TetGen.py
|
||||||
|
|
||||||
SelectionObserverFem.py
|
SelectionObserverFem.py
|
||||||
|
@ -28,6 +30,7 @@ INSTALL(
|
||||||
|
|
||||||
_CommandMechanicalShowResult.py
|
_CommandMechanicalShowResult.py
|
||||||
_TaskPanelResultControl.py
|
_TaskPanelResultControl.py
|
||||||
|
|
||||||
TaskPanelShowDisplacement.ui
|
TaskPanelShowDisplacement.ui
|
||||||
|
|
||||||
_FemAnalysis.py
|
_FemAnalysis.py
|
||||||
|
|
|
@ -97,3 +97,27 @@ class FemCommands(object):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def hide_parts_constraints_show_meshes(self):
|
||||||
|
if FreeCAD.GuiUp:
|
||||||
|
for acnstrmesh in FreeCAD.activeDocument().Objects:
|
||||||
|
if "Constraint" in acnstrmesh.TypeId:
|
||||||
|
acnstrmesh.ViewObject.Visibility = False
|
||||||
|
if "Mesh" in acnstrmesh.TypeId:
|
||||||
|
aparttoshow = acnstrmesh.Name.replace("_Mesh","")
|
||||||
|
for apart in FreeCAD.activeDocument().Objects:
|
||||||
|
if aparttoshow == apart.Name:
|
||||||
|
apart.ViewObject.Visibility = False
|
||||||
|
acnstrmesh.ViewObject.Visibility = True #OvG: Hide constraints and parts and show meshes
|
||||||
|
|
||||||
|
def hide_meshes_show_parts_constraints(self):
|
||||||
|
if FreeCAD.GuiUp:
|
||||||
|
for acnstrmesh in FreeCAD.activeDocument().Objects:
|
||||||
|
if "Constraint" in acnstrmesh.TypeId:
|
||||||
|
acnstrmesh.ViewObject.Visibility = True
|
||||||
|
if "Mesh" in acnstrmesh.TypeId:
|
||||||
|
aparttoshow = acnstrmesh.Name.replace("_Mesh","")
|
||||||
|
for apart in FreeCAD.activeDocument().Objects:
|
||||||
|
if aparttoshow == apart.Name:
|
||||||
|
apart.ViewObject.Visibility = True
|
||||||
|
acnstrmesh.ViewObject.Visibility = False #OvG: Hide meshes and show constraints and meshed part e.g. on purging results
|
||||||
|
|
|
@ -175,13 +175,17 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
||||||
# Individual constraints are "Fem::ConstraintPressure" type
|
# Individual constraints are "Fem::ConstraintPressure" type
|
||||||
self.pressure_constraints = []
|
self.pressure_constraints = []
|
||||||
## @var beam_sections
|
## @var beam_sections
|
||||||
# set of beam sections from the analyis. Updated with update_objects
|
# set of beam sections from the analysis. Updated with update_objects
|
||||||
# Individual beam sections are Proxy.Type "FemBeamSection"
|
# Individual beam sections are Proxy.Type "FemBeamSection"
|
||||||
self.beam_sections = []
|
self.beam_sections = []
|
||||||
## @var shell_thicknesses
|
## @var shell_thicknesses
|
||||||
# set of shell thicknesses from the analyis. Updated with update_objects
|
# set of shell thicknesses from the analysis. Updated with update_objects
|
||||||
# Individual shell thicknesses are Proxy.Type "FemShellThickness"
|
# Individual shell thicknesses are Proxy.Type "FemShellThickness"
|
||||||
self.shell_thicknesses = []
|
self.shell_thicknesses = []
|
||||||
|
## @var displacement_constraints
|
||||||
|
# set of displacements for the analysis. Updated with update_objects
|
||||||
|
# Individual displacement_constraints are Proxy.Type "FemConstraintDisplacement"
|
||||||
|
self.displacement_constraints = []
|
||||||
|
|
||||||
for m in self.analysis.Member:
|
for m in self.analysis.Member:
|
||||||
if m.isDerivedFrom("Fem::FemSolverObjectPython"):
|
if m.isDerivedFrom("Fem::FemSolverObjectPython"):
|
||||||
|
@ -210,6 +214,10 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
||||||
PressureObjectDict = {}
|
PressureObjectDict = {}
|
||||||
PressureObjectDict['Object'] = m
|
PressureObjectDict['Object'] = m
|
||||||
self.pressure_constraints.append(PressureObjectDict)
|
self.pressure_constraints.append(PressureObjectDict)
|
||||||
|
elif m.isDerivedFrom("Fem::ConstraintDisplacement"): #OvG: Replacement reference to C++ implementation of Displacement Constraint
|
||||||
|
displacement_constraint_dict = {}
|
||||||
|
displacement_constraint_dict['Object'] = m
|
||||||
|
self.displacement_constraints.append(displacement_constraint_dict)
|
||||||
elif hasattr(m, "Proxy") and m.Proxy.Type == "FemBeamSection":
|
elif hasattr(m, "Proxy") and m.Proxy.Type == "FemBeamSection":
|
||||||
beam_section_dict = {}
|
beam_section_dict = {}
|
||||||
beam_section_dict['Object'] = m
|
beam_section_dict['Object'] = m
|
||||||
|
@ -240,7 +248,7 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
||||||
if has_no_references is True:
|
if has_no_references is True:
|
||||||
message += "More than one Material has empty References list (Only one empty References list is allowed!).\n"
|
message += "More than one Material has empty References list (Only one empty References list is allowed!).\n"
|
||||||
has_no_references = True
|
has_no_references = True
|
||||||
if not self.fixed_constraints:
|
if not (self.fixed_constraints):
|
||||||
message += "No fixed-constraint nodes defined in the Analysis\n"
|
message += "No fixed-constraint nodes defined in the Analysis\n"
|
||||||
if self.analysis_type == "static":
|
if self.analysis_type == "static":
|
||||||
if not (self.force_constraints or self.pressure_constraints):
|
if not (self.force_constraints or self.pressure_constraints):
|
||||||
|
@ -269,6 +277,7 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
||||||
inp_writer = iw.inp_writer(self.analysis, self.mesh, self.materials,
|
inp_writer = iw.inp_writer(self.analysis, self.mesh, self.materials,
|
||||||
self.fixed_constraints,
|
self.fixed_constraints,
|
||||||
self.force_constraints, self.pressure_constraints,
|
self.force_constraints, self.pressure_constraints,
|
||||||
|
self.displacement_constraints, #OvG: Stick to naming convention
|
||||||
self.beam_sections, self.shell_thicknesses,
|
self.beam_sections, self.shell_thicknesses,
|
||||||
self.analysis_type, self.eigenmode_parameters,
|
self.analysis_type, self.eigenmode_parameters,
|
||||||
self.working_dir)
|
self.working_dir)
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "ViewProviderFemConstraintPressure.h"
|
#include "ViewProviderFemConstraintPressure.h"
|
||||||
#include "ViewProviderFemConstraintGear.h"
|
#include "ViewProviderFemConstraintGear.h"
|
||||||
#include "ViewProviderFemConstraintPulley.h"
|
#include "ViewProviderFemConstraintPulley.h"
|
||||||
|
#include "ViewProviderFemConstraintDisplacement.h"
|
||||||
#include "ViewProviderResult.h"
|
#include "ViewProviderResult.h"
|
||||||
#include "Workbench.h"
|
#include "Workbench.h"
|
||||||
|
|
||||||
|
@ -102,6 +103,7 @@ PyMODINIT_FUNC initFemGui()
|
||||||
FemGui::ViewProviderFemConstraintPressure ::init();
|
FemGui::ViewProviderFemConstraintPressure ::init();
|
||||||
FemGui::ViewProviderFemConstraintGear ::init();
|
FemGui::ViewProviderFemConstraintGear ::init();
|
||||||
FemGui::ViewProviderFemConstraintPulley ::init();
|
FemGui::ViewProviderFemConstraintPulley ::init();
|
||||||
|
FemGui::ViewProviderFemConstraintDisplacement ::init();
|
||||||
FemGui::ViewProviderResult ::init();
|
FemGui::ViewProviderResult ::init();
|
||||||
FemGui::ViewProviderResultPython ::init();
|
FemGui::ViewProviderResultPython ::init();
|
||||||
FemGui::PropertyFemMeshItem ::init();
|
FemGui::PropertyFemMeshItem ::init();
|
||||||
|
|
|
@ -53,6 +53,7 @@ set(FemGui_MOC_HDRS
|
||||||
TaskFemConstraintPressure.h
|
TaskFemConstraintPressure.h
|
||||||
TaskFemConstraintGear.h
|
TaskFemConstraintGear.h
|
||||||
TaskFemConstraintPulley.h
|
TaskFemConstraintPulley.h
|
||||||
|
TaskFemConstraintDisplacement.h
|
||||||
TaskTetParameter.h
|
TaskTetParameter.h
|
||||||
TaskAnalysisInfo.h
|
TaskAnalysisInfo.h
|
||||||
TaskDriver.h
|
TaskDriver.h
|
||||||
|
@ -71,6 +72,7 @@ set(FemGui_UIC_SRCS
|
||||||
TaskFemConstraintFixed.ui
|
TaskFemConstraintFixed.ui
|
||||||
TaskFemConstraintForce.ui
|
TaskFemConstraintForce.ui
|
||||||
TaskFemConstraintPressure.ui
|
TaskFemConstraintPressure.ui
|
||||||
|
TaskFemConstraintDisplacement.ui
|
||||||
TaskTetParameter.ui
|
TaskTetParameter.ui
|
||||||
TaskAnalysisInfo.ui
|
TaskAnalysisInfo.ui
|
||||||
TaskDriver.ui
|
TaskDriver.ui
|
||||||
|
@ -101,6 +103,9 @@ SET(FemGui_DLG_SRCS
|
||||||
TaskFemConstraintGear.h
|
TaskFemConstraintGear.h
|
||||||
TaskFemConstraintPulley.cpp
|
TaskFemConstraintPulley.cpp
|
||||||
TaskFemConstraintPulley.h
|
TaskFemConstraintPulley.h
|
||||||
|
TaskFemConstraintDisplacement.ui
|
||||||
|
TaskFemConstraintDisplacement.cpp
|
||||||
|
TaskFemConstraintDisplacement.h
|
||||||
)
|
)
|
||||||
SOURCE_GROUP("Constraint-Dialogs" FILES ${FemGui_DLG_SRCS})
|
SOURCE_GROUP("Constraint-Dialogs" FILES ${FemGui_DLG_SRCS})
|
||||||
|
|
||||||
|
@ -143,6 +148,8 @@ SET(FemGui_SRCS_ViewProvider
|
||||||
ViewProviderFemConstraintGear.h
|
ViewProviderFemConstraintGear.h
|
||||||
ViewProviderFemConstraintPulley.cpp
|
ViewProviderFemConstraintPulley.cpp
|
||||||
ViewProviderFemConstraintPulley.h
|
ViewProviderFemConstraintPulley.h
|
||||||
|
ViewProviderFemConstraintDisplacement.cpp
|
||||||
|
ViewProviderFemConstraintDisplacement.h
|
||||||
ViewProviderResult.cpp
|
ViewProviderResult.cpp
|
||||||
ViewProviderResult.h
|
ViewProviderResult.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -80,6 +80,18 @@ bool getConstraintPrerequisits(Fem::FemAnalysis **Analysis)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//OvG: Visibility automation show parts and hide meshes on activation of a constraint
|
||||||
|
std::string gethideMeshShowPartStr()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
"for amesh in App.activeDocument().Objects:\n\
|
||||||
|
if \"Mesh\" in amesh.TypeId:\n\
|
||||||
|
aparttoshow = amesh.Name.replace(\"_Mesh\",\"\")\n\
|
||||||
|
for apart in App.activeDocument().Objects:\n\
|
||||||
|
if aparttoshow == apart.Name:\n\
|
||||||
|
apart.ViewObject.Visibility = True\n\
|
||||||
|
amesh.ViewObject.Visibility = False\n";
|
||||||
|
}
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
DEF_STD_CMD_A(CmdFemCreateAnalysis);
|
DEF_STD_CMD_A(CmdFemCreateAnalysis);
|
||||||
|
@ -278,6 +290,9 @@ void CmdFemConstraintBearing::activated(int iMsg)
|
||||||
openCommand("Make FEM constraint for bearing");
|
openCommand("Make FEM constraint for bearing");
|
||||||
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintBearing\",\"%s\")",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintBearing\",\"%s\")",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
|
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();
|
updateActive();
|
||||||
|
|
||||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
@ -317,6 +332,9 @@ void CmdFemConstraintFixed::activated(int iMsg)
|
||||||
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintFixed\",\"%s\")",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintFixed\",\"%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.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,"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();
|
updateActive();
|
||||||
|
|
||||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
@ -358,6 +376,9 @@ void CmdFemConstraintForce::activated(int iMsg)
|
||||||
doCommand(Doc,"App.activeDocument().%s.Reversed = False",FeatName.c_str()); //OvG: set default to False
|
doCommand(Doc,"App.activeDocument().%s.Reversed = False",FeatName.c_str()); //OvG: set default to False
|
||||||
doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1
|
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,"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();
|
updateActive();
|
||||||
|
|
||||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
@ -400,6 +421,9 @@ void CmdFemConstraintPressure::activated(int iMsg)
|
||||||
doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1
|
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]",
|
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",
|
||||||
Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
|
Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
|
||||||
|
|
||||||
|
doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts
|
||||||
|
|
||||||
updateActive();
|
updateActive();
|
||||||
|
|
||||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
@ -438,6 +462,9 @@ void CmdFemConstraintGear::activated(int iMsg)
|
||||||
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintGear\",\"%s\")",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintGear\",\"%s\")",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Diameter = 100.0",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.Diameter = 100.0",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
|
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();
|
updateActive();
|
||||||
|
|
||||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
@ -481,6 +508,9 @@ void CmdFemConstraintPulley::activated(int iMsg)
|
||||||
doCommand(Doc,"App.activeDocument().%s.Force = 100.0",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.Force = 100.0",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.TensionForce = 100.0",FeatName.c_str());
|
doCommand(Doc,"App.activeDocument().%s.TensionForce = 100.0",FeatName.c_str());
|
||||||
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
|
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();
|
updateActive();
|
||||||
|
|
||||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
@ -490,7 +520,48 @@ bool CmdFemConstraintPulley::isActive(void)
|
||||||
{
|
{
|
||||||
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
|
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
|
||||||
}
|
}
|
||||||
|
//=====================================================================================
|
||||||
|
|
||||||
|
DEF_STD_CMD_A(CmdFemConstraintDisplacement);
|
||||||
|
|
||||||
|
CmdFemConstraintDisplacement::CmdFemConstraintDisplacement()
|
||||||
|
: Command("Fem_ConstraintDisplacement")
|
||||||
|
{
|
||||||
|
sAppModule = "Fem";
|
||||||
|
sGroup = QT_TR_NOOP("Fem");
|
||||||
|
sMenuText = QT_TR_NOOP("Create FEM displacement constraint");
|
||||||
|
sToolTipText = QT_TR_NOOP("Create FEM constraint for a displacement acting on a face");
|
||||||
|
sWhatsThis = "Fem_ConstraintDisplacement";
|
||||||
|
sStatusTip = sToolTipText;
|
||||||
|
sPixmap = "fem-constraint-displacement";
|
||||||
|
}
|
||||||
|
|
||||||
|
void CmdFemConstraintDisplacement::activated(int iMsg)
|
||||||
|
{
|
||||||
|
Fem::FemAnalysis *Analysis;
|
||||||
|
|
||||||
|
if(getConstraintPrerequisits(&Analysis))
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string FeatName = getUniqueObjectName("FemConstraintDisplacement");
|
||||||
|
|
||||||
|
openCommand("Make FEM constraint displacement on face");
|
||||||
|
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintDisplacement\",\"%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 CmdFemConstraintDisplacement::isActive(void)
|
||||||
|
{
|
||||||
|
return FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
|
||||||
|
}
|
||||||
// #####################################################################################################
|
// #####################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -702,4 +773,5 @@ void CreateFemCommands(void)
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintPressure());
|
rcCmdMgr.addCommand(new CmdFemConstraintPressure());
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintGear());
|
rcCmdMgr.addCommand(new CmdFemConstraintGear());
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintPulley());
|
rcCmdMgr.addCommand(new CmdFemConstraintPulley());
|
||||||
|
rcCmdMgr.addCommand(new CmdFemConstraintDisplacement());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<file>icons/fem-fem-mesh-create-node-by-poly.svg</file>
|
<file>icons/fem-fem-mesh-create-node-by-poly.svg</file>
|
||||||
<file>icons/fem-analysis.svg</file>
|
<file>icons/fem-analysis.svg</file>
|
||||||
<file>icons/fem-solver.svg</file>
|
<file>icons/fem-solver.svg</file>
|
||||||
|
<file>icons/fem-constraint-displacement.svg</file>
|
||||||
<file>icons/fem-constraint-force.svg</file>
|
<file>icons/fem-constraint-force.svg</file>
|
||||||
<file>icons/fem-constraint-fixed.svg</file>
|
<file>icons/fem-constraint-fixed.svg</file>
|
||||||
<file>icons/fem-constraint-pressure.svg</file>
|
<file>icons/fem-constraint-pressure.svg</file>
|
||||||
|
|
218
src/Mod/Fem/Gui/Resources/icons/fem-constraint-displacement.svg
Normal file
218
src/Mod/Fem/Gui/Resources/icons/fem-constraint-displacement.svg
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="64px"
|
||||||
|
height="64px"
|
||||||
|
id="svg2860"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
inkscape:version="0.48.4 r9939"
|
||||||
|
sodipodi:docname="Fem_ConstraintDisplacement.svg"
|
||||||
|
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||||
|
version="1.1">
|
||||||
|
<defs
|
||||||
|
id="defs2862">
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3377"
|
||||||
|
id="radialGradient3703"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
cx="135.38333"
|
||||||
|
cy="97.369568"
|
||||||
|
fx="135.38333"
|
||||||
|
fy="97.369568"
|
||||||
|
r="19.467436"
|
||||||
|
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3377">
|
||||||
|
<stop
|
||||||
|
id="stop3379"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#faff2b;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3381"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#ffaa00;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3377"
|
||||||
|
id="radialGradient3705"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
cx="148.88333"
|
||||||
|
cy="81.869568"
|
||||||
|
fx="148.88333"
|
||||||
|
fy="81.869568"
|
||||||
|
r="19.467436"
|
||||||
|
gradientTransform="matrix(1.3852588,-0.05136783,0.03705629,0.9993132,-60.392403,7.7040438)" />
|
||||||
|
<inkscape:perspective
|
||||||
|
sodipodi:type="inkscape:persp3d"
|
||||||
|
inkscape:vp_x="0 : 32 : 1"
|
||||||
|
inkscape:vp_y="0 : 1000 : 0"
|
||||||
|
inkscape:vp_z="64 : 32 : 1"
|
||||||
|
inkscape:persp3d-origin="32 : 21.333333 : 1"
|
||||||
|
id="perspective2868" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="9.03125"
|
||||||
|
inkscape:cx="32"
|
||||||
|
inkscape:cy="32.055363"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:grid-bbox="true"
|
||||||
|
inkscape:window-width="1855"
|
||||||
|
inkscape:window-height="1056"
|
||||||
|
inkscape:window-x="65"
|
||||||
|
inkscape:window-y="24"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:snap-global="false" />
|
||||||
|
<metadata
|
||||||
|
id="metadata2865">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<g
|
||||||
|
id="g3618"
|
||||||
|
transform="matrix(0.51498391,0,0,0.49033246,-43.844928,-28.337883)">
|
||||||
|
<path
|
||||||
|
style="fill:url(#radialGradient3705);fill-opacity:1;fill-rule:evenodd;stroke:#7b5600;stroke-width:2.80832386;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
d="m 181.23365,60.447364 -41.75311,19.652299 22.79277,9.74401 1.71554,35.079827 34.90073,-21.47145 c 8.77297,-10.605473 11.81226,-24.974574 2.14058,-36.620683 -5.76166,-5.245683 -10.14552,-7.612661 -19.79651,-6.384003 z"
|
||||||
|
id="rect3522"
|
||||||
|
sodipodi:nodetypes="ccccccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:url(#radialGradient3703);fill-opacity:1;fill-rule:evenodd;stroke:#ff2600;stroke-width:2.80792084999999991;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
d="m 132.82272,84.89331 c 10.75418,-10.005637 21.38515,-6.127815 31.80315,7.238395 8.01928,12.601795 7.83274,24.767805 -0.57918,32.709415 -9.97656,5.54633 -24.96587,2.99222 -33.00616,-9.97927 -5.69827,-10.29304 -6.15159,-21.332455 1.78219,-29.96854 z"
|
||||||
|
id="rect3520"
|
||||||
|
sodipodi:nodetypes="ccccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#ff2600;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="m 28.785325,11.12855 0.0052,21.515011"
|
||||||
|
id="path2390"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#ff2600;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="M 36.737378,12.499439 36.570635,34.269187"
|
||||||
|
id="path2400"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="M 56.372527,2.2112135 C 53.300162,3.7484279 41.698378,10.10061 37.176513,12.380783"
|
||||||
|
id="path2412"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="M 61.760695,7.7936612 C 61.631216,7.9303412 44.151611,19.141175 42.930582,19.695228"
|
||||||
|
id="path2414"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="M 62.133726,14.965487 C 60.200318,16.337892 47.069308,24.807974 44.205044,26.601271"
|
||||||
|
id="path2418"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#ff2600;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="m 22.13757,16.880244 20.65028,3.300552"
|
||||||
|
id="path2424"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#ff2600;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="M 43.362992,26.815464 21.955804,23.581992"
|
||||||
|
id="path2432"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="m 36.981657,7.4999087 c 6.180714,-0.100942 7.85319,1.282121 10.423968,3.8930043 1.703939,2.222352 7.189786,8.432262 0.702143,16.721162"
|
||||||
|
id="path2424-3"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
d="m 43.384578,3.9792341 c 6.180714,-0.100942 7.410283,1.0606677 10.423967,3.893004 C 55.512484,10.09459 60.998331,16.3045 54.510688,24.5934"
|
||||||
|
id="path2424-3-5"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="M 14.615917,32.221453 14.394464,45.065744 4.2076125,52.041522 14.50519,45.065744 l 8.193772,6.975778"
|
||||||
|
id="path3944"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:14px;font-style:normal;font-weight:normal;line-height:20.00000029999999995%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||||
|
x="37.204151"
|
||||||
|
y="59.238754"
|
||||||
|
id="text3009"
|
||||||
|
sodipodi:linespacing="20%"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3011"></tspan></text>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:20px;font-style:normal;font-weight:normal;line-height:20.00000029999999995%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||||
|
x="35.98616"
|
||||||
|
y="58.574394"
|
||||||
|
id="text3013"
|
||||||
|
sodipodi:linespacing="20%"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3015"
|
||||||
|
x="35.98616"
|
||||||
|
y="58.574394" /></text>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:20px;font-style:normal;font-weight:normal;line-height:20.00000029999999995%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||||
|
x="37.64706"
|
||||||
|
y="57.910034"
|
||||||
|
id="text3017"
|
||||||
|
sodipodi:linespacing="20%"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3019"
|
||||||
|
x="37.64706"
|
||||||
|
y="57.910034" /></text>
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:20px;font-style:normal;font-weight:normal;line-height:20.0000003%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||||
|
x="33.771626"
|
||||||
|
y="57.02422"
|
||||||
|
id="text3021"
|
||||||
|
sodipodi:linespacing="20%"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3023"
|
||||||
|
x="33.771626"
|
||||||
|
y="57.02422">D</tspan></text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 9.6 KiB |
655
src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp
Normal file
655
src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp
Normal file
|
@ -0,0 +1,655 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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/FemConstraintDisplacement.h"
|
||||||
|
#include "TaskFemConstraintDisplacement.h"
|
||||||
|
#include "ui_TaskFemConstraintDisplacement.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::TaskFemConstraintDisplacement */
|
||||||
|
|
||||||
|
TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView,QWidget *parent)
|
||||||
|
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-displacement")
|
||||||
|
{
|
||||||
|
proxy = new QWidget(this);
|
||||||
|
ui = new Ui_TaskFemConstraintDisplacement();
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Connect decimal value inputs
|
||||||
|
connect(ui->spinxDisplacement, SIGNAL(valueChanged(double)), this, SLOT(x_changed(double)));
|
||||||
|
connect(ui->spinyDisplacement, SIGNAL(valueChanged(double)), this, SLOT(y_changed(double)));
|
||||||
|
connect(ui->spinzDisplacement, SIGNAL(valueChanged(double)), this, SLOT(z_changed(double)));
|
||||||
|
connect(ui->rotxv, SIGNAL(valueChanged(double)), this, SLOT(x_rot(double)));
|
||||||
|
connect(ui->rotyv, SIGNAL(valueChanged(double)), this, SLOT(y_rot(double)));
|
||||||
|
connect(ui->rotzv, SIGNAL(valueChanged(double)), this, SLOT(z_rot(double)));
|
||||||
|
// Connect check box values displacements
|
||||||
|
connect(ui->dispxfix, SIGNAL(stateChanged(int)), this, SLOT(fixx(int)));
|
||||||
|
connect(ui->dispxfree, SIGNAL(stateChanged(int)), this, SLOT(freex(int)));
|
||||||
|
connect(ui->dispyfix, SIGNAL(stateChanged(int)), this, SLOT(fixy(int)));
|
||||||
|
connect(ui->dispyfree, SIGNAL(stateChanged(int)), this, SLOT(freey(int)));
|
||||||
|
connect(ui->dispzfix, SIGNAL(stateChanged(int)), this, SLOT(fixz(int)));
|
||||||
|
connect(ui->dispzfree, SIGNAL(stateChanged(int)), this, SLOT(freez(int)));
|
||||||
|
// Connect to check box values for rotations
|
||||||
|
connect(ui->rotxfix, SIGNAL(stateChanged(int)), this, SLOT(rotfixx(int)));
|
||||||
|
connect(ui->rotxfree, SIGNAL(stateChanged(int)), this, SLOT(rotfreex(int)));
|
||||||
|
connect(ui->rotyfix, SIGNAL(stateChanged(int)), this, SLOT(rotfixy(int)));
|
||||||
|
connect(ui->rotyfree, SIGNAL(stateChanged(int)), this, SLOT(rotfreey(int)));
|
||||||
|
connect(ui->rotzfix, SIGNAL(stateChanged(int)), this, SLOT(rotfixz(int)));
|
||||||
|
connect(ui->rotzfree, SIGNAL(stateChanged(int)), this, SLOT(rotfreez(int)));
|
||||||
|
|
||||||
|
// Temporarily prevent unnecessary feature recomputes
|
||||||
|
ui->spinxDisplacement->blockSignals(true);
|
||||||
|
ui->spinyDisplacement->blockSignals(true);
|
||||||
|
ui->spinzDisplacement->blockSignals(true);
|
||||||
|
ui->rotxv->blockSignals(true);
|
||||||
|
ui->rotyv->blockSignals(true);
|
||||||
|
ui->rotzv->blockSignals(true);
|
||||||
|
ui->dispxfix->blockSignals(true);
|
||||||
|
ui->dispxfree->blockSignals(true);
|
||||||
|
ui->dispyfix->blockSignals(true);
|
||||||
|
ui->dispyfree->blockSignals(true);
|
||||||
|
ui->dispzfix->blockSignals(true);
|
||||||
|
ui->dispzfree->blockSignals(true);
|
||||||
|
ui->rotxfix->blockSignals(true);
|
||||||
|
ui->rotxfree->blockSignals(true);
|
||||||
|
ui->rotyfix->blockSignals(true);
|
||||||
|
ui->rotyfree->blockSignals(true);
|
||||||
|
ui->rotzfix->blockSignals(true);
|
||||||
|
ui->rotzfree->blockSignals(true);
|
||||||
|
|
||||||
|
// Get the feature data
|
||||||
|
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
|
||||||
|
double fStates[6];
|
||||||
|
bool bStates[12];
|
||||||
|
fStates[0]=pcConstraint->xDisplacement.getValue();
|
||||||
|
fStates[1]=pcConstraint->yDisplacement.getValue();
|
||||||
|
fStates[2]=pcConstraint->zDisplacement.getValue();
|
||||||
|
fStates[3]=pcConstraint->xRotation.getValue();
|
||||||
|
fStates[4]=pcConstraint->yRotation.getValue();
|
||||||
|
fStates[5]=pcConstraint->zRotation.getValue();
|
||||||
|
bStates[0]=pcConstraint->xFix.getValue();
|
||||||
|
bStates[1]=pcConstraint->xFree.getValue();
|
||||||
|
bStates[2]=pcConstraint->yFix.getValue();
|
||||||
|
bStates[3]=pcConstraint->yFree.getValue();
|
||||||
|
bStates[4]=pcConstraint->zFix.getValue();
|
||||||
|
bStates[5]=pcConstraint->zFree.getValue();
|
||||||
|
bStates[6]=pcConstraint->rotxFix.getValue();
|
||||||
|
bStates[7]=pcConstraint->rotxFree.getValue();
|
||||||
|
bStates[8]=pcConstraint->rotyFix.getValue();
|
||||||
|
bStates[9]=pcConstraint->rotyFree.getValue();
|
||||||
|
bStates[10]=pcConstraint->rotzFix.getValue();
|
||||||
|
bStates[11]=pcConstraint->rotzFree.getValue();
|
||||||
|
|
||||||
|
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||||
|
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||||
|
|
||||||
|
// Fill data into dialog elements
|
||||||
|
ui->spinxDisplacement->setValue(fStates[0]);
|
||||||
|
ui->spinyDisplacement->setValue(fStates[1]);
|
||||||
|
ui->spinzDisplacement->setValue(fStates[2]);
|
||||||
|
ui->rotxv->setValue(fStates[3]);
|
||||||
|
ui->rotyv->setValue(fStates[4]);
|
||||||
|
ui->rotzv->setValue(fStates[5]);
|
||||||
|
ui->dispxfix->setChecked(bStates[0]);
|
||||||
|
ui->dispxfree->setChecked(bStates[1]);
|
||||||
|
ui->dispyfix->setChecked(bStates[2]);
|
||||||
|
ui->dispyfree->setChecked(bStates[3]);
|
||||||
|
ui->dispzfix->setChecked(bStates[4]);
|
||||||
|
ui->dispzfree->setChecked(bStates[5]);
|
||||||
|
ui->rotxfix->setChecked(bStates[6]);
|
||||||
|
ui->rotxfree->setChecked(bStates[7]);
|
||||||
|
ui->rotyfix->setChecked(bStates[8]);
|
||||||
|
ui->rotyfree->setChecked(bStates[9]);
|
||||||
|
ui->rotzfix->setChecked(bStates[10]);
|
||||||
|
ui->rotzfree->setChecked(bStates[11]);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Allow signals again
|
||||||
|
ui->spinxDisplacement->blockSignals(false);
|
||||||
|
ui->spinyDisplacement->blockSignals(false);
|
||||||
|
ui->spinzDisplacement->blockSignals(false);
|
||||||
|
ui->rotxv->blockSignals(false);
|
||||||
|
ui->rotyv->blockSignals(false);
|
||||||
|
ui->rotzv->blockSignals(false);
|
||||||
|
ui->dispxfix->blockSignals(false);
|
||||||
|
ui->dispxfree->blockSignals(false);
|
||||||
|
ui->dispyfix->blockSignals(false);
|
||||||
|
ui->dispyfree->blockSignals(false);
|
||||||
|
ui->dispzfix->blockSignals(false);
|
||||||
|
ui->dispzfree->blockSignals(false);
|
||||||
|
ui->rotxfix->blockSignals(false);
|
||||||
|
ui->rotxfree->blockSignals(false);
|
||||||
|
ui->rotyfix->blockSignals(false);
|
||||||
|
ui->rotyfree->blockSignals(false);
|
||||||
|
ui->rotzfix->blockSignals(false);
|
||||||
|
ui->rotzfree->blockSignals(false);
|
||||||
|
|
||||||
|
//Selection buttons
|
||||||
|
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
|
||||||
|
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
|
||||||
|
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskFemConstraintDisplacement::~TaskFemConstraintDisplacement()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::updateUI()
|
||||||
|
{
|
||||||
|
if (ui->lw_references->model()->rowCount() == 0) {
|
||||||
|
// Go into reference selection mode if no reference has been selected yet
|
||||||
|
onButtonReference(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::x_changed(double val){
|
||||||
|
if (val!=0)
|
||||||
|
{
|
||||||
|
ui->dispxfree->setChecked(false);
|
||||||
|
ui->dispxfix->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::y_changed(double val){
|
||||||
|
if (val!=0)
|
||||||
|
{
|
||||||
|
ui->dispyfree->setChecked(false);
|
||||||
|
ui->dispyfix->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::z_changed(double val){
|
||||||
|
if (val!=0)
|
||||||
|
{
|
||||||
|
ui->dispzfree->setChecked(false);
|
||||||
|
ui->dispzfix->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::x_rot(double val){
|
||||||
|
if (val!=0)
|
||||||
|
{
|
||||||
|
ui->rotxfree->setChecked(false);
|
||||||
|
ui->rotxfix->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::y_rot(double val){
|
||||||
|
if (val!=0)
|
||||||
|
{
|
||||||
|
ui->rotyfree->setChecked(false);
|
||||||
|
ui->rotyfix->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::z_rot(double val){
|
||||||
|
if (val!=0)
|
||||||
|
{
|
||||||
|
ui->rotzfree->setChecked(false);
|
||||||
|
ui->rotzfix->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::fixx(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->dispxfree->setChecked(false);
|
||||||
|
ui->spinxDisplacement->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->spinxDisplacement->value()==0)
|
||||||
|
{
|
||||||
|
ui->dispxfree->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::freex(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->dispxfix->setChecked(false);
|
||||||
|
ui->spinxDisplacement->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->spinxDisplacement->value()==0)
|
||||||
|
{
|
||||||
|
ui->dispxfix->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::fixy(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->dispyfree->setChecked(false);
|
||||||
|
ui->spinyDisplacement->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->spinyDisplacement->value()==0)
|
||||||
|
{
|
||||||
|
ui->dispyfree->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::freey(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->dispyfix->setChecked(false);
|
||||||
|
ui->spinyDisplacement->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->spinyDisplacement->value()==0)
|
||||||
|
{
|
||||||
|
ui->dispyfix->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::fixz(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->dispzfree->setChecked(false);
|
||||||
|
ui->spinzDisplacement->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->spinzDisplacement->value()==0)
|
||||||
|
{
|
||||||
|
ui->dispzfree->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::freez(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->dispzfix->setChecked(false);
|
||||||
|
ui->spinzDisplacement->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->spinzDisplacement->value()==0)
|
||||||
|
{
|
||||||
|
ui->dispzfix->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::rotfixx(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->rotxfree->setChecked(false);
|
||||||
|
ui->rotxv->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->rotxv->value()==0)
|
||||||
|
{
|
||||||
|
ui->rotxfree->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::rotfreex(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->rotxfix->setChecked(false);
|
||||||
|
ui->rotxv->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->rotxv->value()==0)
|
||||||
|
{
|
||||||
|
ui->rotxfix->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::rotfixy(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->rotyfree->setChecked(false);
|
||||||
|
ui->rotyv->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->rotyv->value()==0)
|
||||||
|
{
|
||||||
|
ui->rotyfree->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::rotfreey(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->rotyfix->setChecked(false);
|
||||||
|
ui->rotyv->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->rotyv->value()==0)
|
||||||
|
{
|
||||||
|
ui->rotyfix->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::rotfixz(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->rotzfree->setChecked(false);
|
||||||
|
ui->rotzv->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->rotzv->value()==0)
|
||||||
|
{
|
||||||
|
ui->rotzfree->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::rotfreez(int val){
|
||||||
|
if (val==2)
|
||||||
|
{
|
||||||
|
ui->rotzfix->setChecked(false);
|
||||||
|
ui->rotzv->setValue(0);
|
||||||
|
}
|
||||||
|
else if (ui->rotzv->value()==0)
|
||||||
|
{
|
||||||
|
ui->rotzfix->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::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::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(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){
|
||||||
|
Objects.push_back(obj);
|
||||||
|
SubElements.push_back(subNames[subIt]);
|
||||||
|
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Update UI
|
||||||
|
pcConstraint->References.setValues(Objects,SubElements);
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::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::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 TaskFemConstraintDisplacement::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 TaskFemConstraintDisplacement::onReferenceDeleted() {
|
||||||
|
int row = ui->lw_references->currentIndex().row();
|
||||||
|
TaskFemConstraint::onReferenceDeleted(row);
|
||||||
|
ui->lw_references->model()->removeRow(row);
|
||||||
|
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string TaskFemConstraintDisplacement::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 TaskFemConstraintDisplacement::get_spinxDisplacement() const{return ui->spinxDisplacement->value();}
|
||||||
|
double TaskFemConstraintDisplacement::get_spinyDisplacement() const{return ui->spinyDisplacement->value();}
|
||||||
|
double TaskFemConstraintDisplacement::get_spinzDisplacement() const{return ui->spinzDisplacement->value();}
|
||||||
|
double TaskFemConstraintDisplacement::get_rotxv() const{return ui->rotxv->value();}
|
||||||
|
double TaskFemConstraintDisplacement::get_rotyv() const{return ui->rotyv->value();}
|
||||||
|
double TaskFemConstraintDisplacement::get_rotzv() const{return ui->rotzv->value();}
|
||||||
|
|
||||||
|
bool TaskFemConstraintDisplacement::get_dispxfix() const{return ui->dispxfix->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_dispxfree() const{return ui->dispxfree->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_dispyfix() const{return ui->dispyfix->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_dispyfree() const{return ui->dispyfree->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_dispzfix() const{return ui->dispzfix->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_dispzfree() const{return ui->dispzfree->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_rotxfix() const{return ui->rotxfix->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_rotxfree() const{return ui->rotxfree->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_rotyfix() const{return ui->rotyfix->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_rotyfree() const{return ui->rotyfree->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_rotzfix() const{return ui->rotzfix->isChecked();}
|
||||||
|
bool TaskFemConstraintDisplacement::get_rotzfree() const{return ui->rotzfree->isChecked();}
|
||||||
|
|
||||||
|
void TaskFemConstraintDisplacement::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
|
||||||
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView)
|
||||||
|
{
|
||||||
|
this->ConstraintView = ConstraintView;
|
||||||
|
assert(ConstraintView);
|
||||||
|
this->parameter = new TaskFemConstraintDisplacement(ConstraintView);;
|
||||||
|
|
||||||
|
Content.push_back(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==== calls from the TaskView ===============================================================
|
||||||
|
|
||||||
|
void TaskDlgFemConstraintDisplacement::open()
|
||||||
|
{
|
||||||
|
// a transaction is already open at creation time of the panel
|
||||||
|
if (!Gui::Command::hasPendingCommand()) {
|
||||||
|
QString msg = QObject::tr("Constraint normal stress");
|
||||||
|
Gui::Command::openCommand((const char*)msg.toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskDlgFemConstraintDisplacement::accept()
|
||||||
|
{
|
||||||
|
std::string name = ConstraintView->getObject()->getNameInDocument();
|
||||||
|
const TaskFemConstraintDisplacement* parameterDisplacement = static_cast<const TaskFemConstraintDisplacement*>(parameter);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xDisplacement = %f",
|
||||||
|
name.c_str(), parameterDisplacement->get_spinxDisplacement());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yDisplacement = %f",
|
||||||
|
name.c_str(), parameterDisplacement->get_spinyDisplacement());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zDisplacement = %f",
|
||||||
|
name.c_str(), parameterDisplacement->get_spinzDisplacement());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xRotation = %f",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotxv());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yRotation = %f",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotyv());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zRotation = %f",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotzv());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xFree = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_dispxfree() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.xFix = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_dispxfix() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yFree = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_dispyfree() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.yFix = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_dispyfix() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zFree = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_dispzfree() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.zFix = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_dispzfix() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotxFree = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotxfree() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotxFix = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotxfix() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotyFree = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotyfree() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotyFix = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotyfix() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotzFree = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotzfree() ? "True" : "False");
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.rotzFix = %s",
|
||||||
|
name.c_str(), parameterDisplacement->get_rotzfix() ? "True" : "False");
|
||||||
|
|
||||||
|
std::string scale = parameterDisplacement->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 TaskDlgFemConstraintDisplacement::reject()
|
||||||
|
{
|
||||||
|
Gui::Command::abortCommand();
|
||||||
|
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||||
|
Gui::Command::updateActive();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_TaskFemConstraintDisplacement.cpp"
|
121
src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h
Normal file
121
src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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_TaskFemConstraintDisplacement_H
|
||||||
|
#define GUI_TASKVIEW_TaskFemConstraintDisplacement_H
|
||||||
|
|
||||||
|
#include <Gui/TaskView/TaskView.h>
|
||||||
|
#include <Gui/Selection.h>
|
||||||
|
#include <Gui/TaskView/TaskDialog.h>
|
||||||
|
#include <Base/Quantity.h>
|
||||||
|
|
||||||
|
#include "TaskFemConstraint.h"
|
||||||
|
#include "ViewProviderFemConstraintDisplacement.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <Base/Console.h>
|
||||||
|
#include <App/DocumentObject.h>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
class Ui_TaskFemConstraintDisplacement;
|
||||||
|
|
||||||
|
namespace FemGui {
|
||||||
|
class TaskFemConstraintDisplacement : public TaskFemConstraint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView,QWidget *parent = 0);
|
||||||
|
~TaskFemConstraintDisplacement();
|
||||||
|
const std::string getReferences() const;
|
||||||
|
double get_spinxDisplacement()const;
|
||||||
|
double get_spinyDisplacement()const;
|
||||||
|
double get_spinzDisplacement()const;
|
||||||
|
double get_rotxv()const;
|
||||||
|
double get_rotyv()const;
|
||||||
|
double get_rotzv()const;
|
||||||
|
bool get_dispxfix()const;
|
||||||
|
bool get_dispxfree()const;
|
||||||
|
bool get_dispyfix()const;
|
||||||
|
bool get_dispyfree()const;
|
||||||
|
bool get_dispzfix()const;
|
||||||
|
bool get_dispzfree()const;
|
||||||
|
bool get_rotxfix()const;
|
||||||
|
bool get_rotxfree()const;
|
||||||
|
bool get_rotyfix()const;
|
||||||
|
bool get_rotyfree()const;
|
||||||
|
bool get_rotzfix()const;
|
||||||
|
bool get_rotzfree()const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onReferenceDeleted(void);
|
||||||
|
void x_changed(double);
|
||||||
|
void y_changed(double);
|
||||||
|
void z_changed(double);
|
||||||
|
void x_rot(double);
|
||||||
|
void y_rot(double);
|
||||||
|
void z_rot(double);
|
||||||
|
void fixx(int);
|
||||||
|
void freex(int);
|
||||||
|
void fixy(int);
|
||||||
|
void freey(int);
|
||||||
|
void fixz(int);
|
||||||
|
void freez(int);
|
||||||
|
void rotfixx(int);
|
||||||
|
void rotfreex(int);
|
||||||
|
void rotfixy(int);
|
||||||
|
void rotfreey(int);
|
||||||
|
void rotfixz(int);
|
||||||
|
void rotfreez(int);
|
||||||
|
|
||||||
|
void addToSelection();
|
||||||
|
void removeFromSelection();
|
||||||
|
void setSelection(QListWidgetItem* item);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||||
|
void updateUI();
|
||||||
|
Ui_TaskFemConstraintDisplacement* ui;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TaskDlgFemConstraintDisplacement : public TaskDlgFemConstraint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TaskDlgFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView);
|
||||||
|
void open();
|
||||||
|
bool accept();
|
||||||
|
bool reject();
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace FemGui
|
||||||
|
|
||||||
|
#endif // GUI_TASKVIEW_TaskFemConstraintDisplacement_H
|
368
src/Mod/Fem/Gui/TaskFemConstraintDisplacement.ui
Normal file
368
src/Mod/Fem/Gui/TaskFemConstraintDisplacement.ui
Normal file
|
@ -0,0 +1,368 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TaskFemConstraintDisplacement</class>
|
||||||
|
<widget class="QWidget" name="TaskFemConstraintDisplacement">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>800</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||||
|
<horstretch>3</horstretch>
|
||||||
|
<verstretch>80</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>800</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>800</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Prescribed Displacement</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="verticalLayoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>311</width>
|
||||||
|
<height>743</height>
|
||||||
|
</rect>
|
||||||
|
</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">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="dispx">
|
||||||
|
<property name="text">
|
||||||
|
<string>Displacement x</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dispxfree">
|
||||||
|
<property name="text">
|
||||||
|
<string>Free</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dispxfix">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fixed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="spinxDisplacement">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="dispy">
|
||||||
|
<property name="text">
|
||||||
|
<string>Displacement y</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dispyfree">
|
||||||
|
<property name="text">
|
||||||
|
<string>Free</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dispyfix">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fixed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="spinyDisplacement">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="dispz">
|
||||||
|
<property name="text">
|
||||||
|
<string>Displacement z</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dispzfree">
|
||||||
|
<property name="text">
|
||||||
|
<string>Free</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dispzfix">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fixed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="spinzDisplacement">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotations are only valid for Beam and Shell elements.</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="rotx">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotation x</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rotxfree">
|
||||||
|
<property name="text">
|
||||||
|
<string>Free</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rotxfix">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fixed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="rotxv">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="roty">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotation y</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rotyfree">
|
||||||
|
<property name="text">
|
||||||
|
<string>Free</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rotyfix">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fixed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="rotyv">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="rotz">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotation z</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rotzfree">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Free</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rotzfix">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fixed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="rotzv">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -395,6 +395,46 @@ void ViewProviderFemConstraint::updateFixed(const SoNode* node, const int idx, c
|
||||||
updateCube(sep, idx+CONE_CHILDREN+PLACEMENT_CHILDREN, width, width, width/4);
|
updateCube(sep, idx+CONE_CHILDREN+PLACEMENT_CHILDREN, width, width, width/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewProviderFemConstraint::createDisplacement(SoSeparator* sep, const double height, const double width, const bool gap)
|
||||||
|
{
|
||||||
|
createCone(sep, height, width);
|
||||||
|
createPlacement(sep, SbVec3f(0, -(height)/2-width/8 - (gap ? 1.0 : 0.1) * width/8, 0), SbRotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
SoSeparator* ViewProviderFemConstraint::createDisplacement(const double height, const double width, const bool gap)
|
||||||
|
{
|
||||||
|
SoSeparator* sep = new SoSeparator();
|
||||||
|
createDisplacement(sep, height, width, gap);
|
||||||
|
return sep;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderFemConstraint::updateDisplacement(const SoNode* node, const int idx, const double height, const double width, const bool gap)
|
||||||
|
{
|
||||||
|
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||||
|
updateCone(sep, idx, height, width);
|
||||||
|
updatePlacement(sep, idx+CONE_CHILDREN, SbVec3f(0, -(height)/2-width/8 - (gap ? 1.0 : 0.0) * width/8, 0), SbRotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderFemConstraint::createRotation(SoSeparator* sep, const double height, const double width, const bool gap)
|
||||||
|
{
|
||||||
|
createCylinder(sep, width/2, height/2);
|
||||||
|
createPlacement(sep, SbVec3f(0, -(height)*2-width/8 - (gap ? 1.0 : 0.1) * width/8, 0), SbRotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
SoSeparator* ViewProviderFemConstraint::createRotation(const double height, const double width, const bool gap)
|
||||||
|
{
|
||||||
|
SoSeparator* sep = new SoSeparator();
|
||||||
|
createRotation(sep, height, width, gap);
|
||||||
|
return sep;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderFemConstraint::updateRotation(const SoNode* node, const int idx, const double height, const double width, const bool gap)
|
||||||
|
{
|
||||||
|
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||||
|
updateCylinder(sep, idx, height/2, width/2);
|
||||||
|
updatePlacement(sep, idx+CYLINDER_CHILDREN, SbVec3f(0, -(height)*2-width/8 - (gap ? 1.0 : 0.0) * width/8, 0), SbRotation());
|
||||||
|
}
|
||||||
|
|
||||||
QObject* ViewProviderFemConstraint::findChildByName(const QObject* parent, const QString& name)
|
QObject* ViewProviderFemConstraint::findChildByName(const QObject* parent, const QString& name)
|
||||||
{
|
{
|
||||||
for (QObjectList::const_iterator o = parent->children().begin(); o != parent->children().end(); o++) {
|
for (QObjectList::const_iterator o = parent->children().begin(); o != parent->children().end(); o++) {
|
||||||
|
|
|
@ -87,6 +87,12 @@ protected:
|
||||||
static void createFixed(SoSeparator* sep, const double height, const double width, const bool gap = false);
|
static void createFixed(SoSeparator* sep, const double height, const double width, const bool gap = false);
|
||||||
static SoSeparator* createFixed(const double height, const double width, const bool gap = false);
|
static SoSeparator* createFixed(const double height, const double width, const bool gap = false);
|
||||||
static void updateFixed(const SoNode* node, const int idx, const double height, const double width, const bool gap = false);
|
static void updateFixed(const SoNode* node, const int idx, const double height, const double width, const bool gap = false);
|
||||||
|
static void createDisplacement(SoSeparator* sep, const double height, const double width, const bool gap = false);
|
||||||
|
static SoSeparator* createDisplacement(const double height, const double width, const bool gap = false);
|
||||||
|
static void updateDisplacement(const SoNode* node, const int idx, const double height, const double width, const bool gap = false);
|
||||||
|
static void createRotation(SoSeparator* sep, const double height, const double width, const bool gap = false);
|
||||||
|
static SoSeparator* createRotation(const double height, const double width, const bool gap = false);
|
||||||
|
static void updateRotation(const SoNode* node, const int idx, const double height, const double width, const bool gap = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SoFontStyle * pFont;
|
SoFontStyle * pFont;
|
||||||
|
|
309
src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp
Normal file
309
src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp
Normal file
|
@ -0,0 +1,309 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 <Precision.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Mod/Fem/App/FemConstraintDisplacement.h"
|
||||||
|
#include "TaskFemConstraintDisplacement.h"
|
||||||
|
#include "ViewProviderFemConstraintDisplacement.h"
|
||||||
|
#include <Base/Console.h>
|
||||||
|
#include <Gui/Control.h>
|
||||||
|
|
||||||
|
using namespace FemGui;
|
||||||
|
|
||||||
|
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement, FemGui::ViewProviderFemConstraint)
|
||||||
|
|
||||||
|
ViewProviderFemConstraintDisplacement::ViewProviderFemConstraintDisplacement()
|
||||||
|
{
|
||||||
|
sPixmap = "fem-constraint-displacement";
|
||||||
|
ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f));
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewProviderFemConstraintDisplacement::~ViewProviderFemConstraintDisplacement()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME setEdit needs a careful review
|
||||||
|
bool ViewProviderFemConstraintDisplacement::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();
|
||||||
|
TaskDlgFemConstraintDisplacement *constrDlg = qobject_cast<TaskDlgFemConstraintDisplacement *>(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 TaskFemConstraintDisplacement(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 TaskDlgFemConstraintDisplacement(this));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ViewProviderDocumentObject::setEdit(ModNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HEIGHT (4)
|
||||||
|
#define WIDTH (0.3)
|
||||||
|
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
|
||||||
|
|
||||||
|
void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop)
|
||||||
|
{
|
||||||
|
// Gets called whenever a property of the attached object changes
|
||||||
|
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(this->getObject());
|
||||||
|
float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only
|
||||||
|
float scaledheight = HEIGHT * pcConstraint->Scale.getValue();
|
||||||
|
bool xFree = pcConstraint->xFree.getValue();
|
||||||
|
bool yFree = pcConstraint->yFree.getValue();
|
||||||
|
bool zFree = pcConstraint->zFree.getValue();
|
||||||
|
bool rotxFree = pcConstraint->rotxFree.getValue();
|
||||||
|
bool rotyFree = pcConstraint->rotyFree.getValue();
|
||||||
|
bool rotzFree = pcConstraint->rotzFree.getValue();
|
||||||
|
|
||||||
|
#ifdef USE_MULTIPLE_COPY
|
||||||
|
//OvG: always need access to cp for scaling
|
||||||
|
SoMultipleCopy* cpx = new SoMultipleCopy();
|
||||||
|
SoMultipleCopy* cpy = new SoMultipleCopy();
|
||||||
|
SoMultipleCopy* cpz = new SoMultipleCopy();
|
||||||
|
SoMultipleCopy* cprotx = new SoMultipleCopy();
|
||||||
|
SoMultipleCopy* cproty = new SoMultipleCopy();
|
||||||
|
SoMultipleCopy* cprotz = new SoMultipleCopy();
|
||||||
|
if (pShapeSep->getNumChildren() == 0) {
|
||||||
|
// Set up the nodes
|
||||||
|
cpx->matrix.setNum(0);
|
||||||
|
cpx->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); //OvG: Scaling
|
||||||
|
|
||||||
|
cpy->matrix.setNum(0);
|
||||||
|
cpy->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); //OvG: Scaling
|
||||||
|
|
||||||
|
cpz->matrix.setNum(0);
|
||||||
|
cpz->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); //OvG: Scaling
|
||||||
|
|
||||||
|
cprotx->matrix.setNum(0);
|
||||||
|
cprotx->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); //OvG: Scaling
|
||||||
|
|
||||||
|
cproty->matrix.setNum(0);
|
||||||
|
cproty->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); //OvG: Scaling
|
||||||
|
|
||||||
|
cprotz->matrix.setNum(0);
|
||||||
|
cprotz->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); //OvG: Scaling
|
||||||
|
|
||||||
|
pShapeSep->addChild(cpx);
|
||||||
|
pShapeSep->addChild(cpy);
|
||||||
|
pShapeSep->addChild(cpz);
|
||||||
|
pShapeSep->addChild(cprotx);
|
||||||
|
pShapeSep->addChild(cproty);
|
||||||
|
pShapeSep->addChild(cprotz;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
#ifdef USE_MULTIPLE_COPY
|
||||||
|
cpx = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
|
||||||
|
cpx->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matricesx = cpx->matrix.startEditing();
|
||||||
|
|
||||||
|
cpy = static_cast<SoMultipleCopy*>(pShapeSep->getChild(1));
|
||||||
|
cpy->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matricesy = cpy->matrix.startEditing();
|
||||||
|
|
||||||
|
cpz = static_cast<SoMultipleCopy*>(pShapeSep->getChild(2));
|
||||||
|
cpz->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matricesz = cpz->matrix.startEditing();
|
||||||
|
|
||||||
|
cprotx = static_cast<SoMultipleCopy*>(pShapeSep->getChild(3));
|
||||||
|
cprotx->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matricesrotx = cprotx->matrix.startEditing();
|
||||||
|
|
||||||
|
cproty = static_cast<SoMultipleCopy*>(pShapeSep->getChild(4));
|
||||||
|
cproty->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matricesroty = cproty->matrix.startEditing();
|
||||||
|
|
||||||
|
cprotz = static_cast<SoMultipleCopy*>(pShapeSep->getChild(5));
|
||||||
|
cprotz->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matricesrotz = cprotz->matrix.startEditing();
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
int idy = 0;
|
||||||
|
int idz = 0;
|
||||||
|
int idrotx = 0;
|
||||||
|
int idroty = 0;
|
||||||
|
int idrotz = 0;
|
||||||
|
#else
|
||||||
|
// Note: Points and Normals are always updated together
|
||||||
|
pShapeSep->removeAllChildren();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
|
||||||
|
SbVec3f base(p->x, p->y, p->z);
|
||||||
|
SbVec3f dirx(1,0,0); //OvG: Make relevant to global axes
|
||||||
|
SbVec3f diry(0,1,0); //OvG: Make relevant to global axes
|
||||||
|
SbVec3f dirz(0,0,1); //OvG: Make relevant to global axes
|
||||||
|
SbRotation rotx(SbVec3f(0,-1,0), dirx); //OvG Tri-cones
|
||||||
|
SbRotation roty(SbVec3f(0,-1,0), diry);
|
||||||
|
SbRotation rotz(SbVec3f(0,-1,0), dirz);
|
||||||
|
#ifdef USE_MULTIPLE_COPY
|
||||||
|
SbMatrix mx;
|
||||||
|
SbMatrix my;
|
||||||
|
SbMatrix mz;
|
||||||
|
//OvG: Translation indication
|
||||||
|
if(!xFree)
|
||||||
|
{
|
||||||
|
SbMatrix mx;
|
||||||
|
mx.setTransform(base, rotx, SbVec3f(1,1,1));
|
||||||
|
matricesx[idx] = mx;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
if(!yFree)
|
||||||
|
{
|
||||||
|
SbMatrix my;
|
||||||
|
my.setTransform(base, roty, SbVec3f(1,1,1));
|
||||||
|
matricesy[idy] = my;
|
||||||
|
idy++;
|
||||||
|
}
|
||||||
|
if(!zFree)
|
||||||
|
{
|
||||||
|
SbMatrix mz;
|
||||||
|
mz.setTransform(base, rotz, SbVec3f(1,1,1));
|
||||||
|
matricesz[idz] = mz;
|
||||||
|
idz++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//OvG: Rotation indication
|
||||||
|
if(!rotxFree)
|
||||||
|
{
|
||||||
|
SbMatrix mrotx;
|
||||||
|
mrotx.setTransform(base, rotx, SbVec3f(1,1,1));
|
||||||
|
matricesrotx[idrotx] = mrotx;
|
||||||
|
idrotx++;
|
||||||
|
}
|
||||||
|
if(!rotyFree)
|
||||||
|
{
|
||||||
|
SbMatrix mroty;
|
||||||
|
mroty.setTransform(base, roty, SbVec3f(1,1,1));
|
||||||
|
matricesroty[idroty] = mroty;
|
||||||
|
idroty++;
|
||||||
|
}
|
||||||
|
if(!rotzFree)
|
||||||
|
{
|
||||||
|
SbMatrix mrotz;
|
||||||
|
mrotz.setTransform(base, rotz, SbVec3f(1,1,1));
|
||||||
|
matricesrotz[idrotz] = mrotz;
|
||||||
|
idrotz++;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
//OvG: Translation indication
|
||||||
|
if(!xFree)
|
||||||
|
{
|
||||||
|
SoSeparator* sepx = new SoSeparator();
|
||||||
|
createPlacement(sepx, base, rotx);
|
||||||
|
createDisplacement(sepx, scaledheight, scaledwidth); //OvG: Scaling
|
||||||
|
pShapeSep->addChild(sepx);
|
||||||
|
}
|
||||||
|
if(!yFree)
|
||||||
|
{
|
||||||
|
SoSeparator* sepy = new SoSeparator();
|
||||||
|
createPlacement(sepy, base, roty);
|
||||||
|
createDisplacement(sepy, scaledheight, scaledwidth); //OvG: Scaling
|
||||||
|
pShapeSep->addChild(sepy);
|
||||||
|
}
|
||||||
|
if(!zFree)
|
||||||
|
{
|
||||||
|
SoSeparator* sepz = new SoSeparator();
|
||||||
|
createPlacement(sepz, base, rotz);
|
||||||
|
createDisplacement(sepz, scaledheight, scaledwidth); //OvG: Scaling
|
||||||
|
pShapeSep->addChild(sepz);
|
||||||
|
}
|
||||||
|
|
||||||
|
//OvG: Rotation indication
|
||||||
|
if(!rotxFree)
|
||||||
|
{
|
||||||
|
SoSeparator* sepx = new SoSeparator();
|
||||||
|
createPlacement(sepx, base, rotx);
|
||||||
|
createRotation(sepx, scaledheight, scaledwidth); //OvG: Scaling
|
||||||
|
pShapeSep->addChild(sepx);
|
||||||
|
}
|
||||||
|
if(!rotyFree)
|
||||||
|
{
|
||||||
|
SoSeparator* sepy = new SoSeparator();
|
||||||
|
createPlacement(sepy, base, roty);
|
||||||
|
createRotation(sepy, scaledheight, scaledwidth); //OvG: Scaling
|
||||||
|
pShapeSep->addChild(sepy);
|
||||||
|
}
|
||||||
|
if(!rotzFree)
|
||||||
|
{
|
||||||
|
SoSeparator* sepz = new SoSeparator();
|
||||||
|
createPlacement(sepz, base, rotz);
|
||||||
|
createRotation(sepz, scaledheight, scaledwidth); //OvG: Scaling
|
||||||
|
pShapeSep->addChild(sepz);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
#ifdef USE_MULTIPLE_COPY
|
||||||
|
cpx->matrix.finishEditing();
|
||||||
|
cpy->matrix.finishEditing();
|
||||||
|
cpz->matrix.finishEditing();
|
||||||
|
cprotx->matrix.finishEditing();
|
||||||
|
cproty->matrix.finishEditing();
|
||||||
|
cprotz->matrix.finishEditing();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets called whenever a property of the attached object changes
|
||||||
|
ViewProviderFemConstraint::updateData(prop);
|
||||||
|
}
|
48
src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.h
Normal file
48
src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.h
Normal 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_VIEWPROVIDERFEMCONSTRAINTDISPLACEMENT_H
|
||||||
|
#define GUI_VIEWPROVIDERFEMCONSTRAINTDISPLACEMENT_H
|
||||||
|
|
||||||
|
#include "ViewProviderFemConstraint.h"
|
||||||
|
|
||||||
|
namespace FemGui {
|
||||||
|
|
||||||
|
class FemGuiExport ViewProviderFemConstraintDisplacement : public FemGui::ViewProviderFemConstraint
|
||||||
|
{
|
||||||
|
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintDisplacement);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ViewProviderFemConstraintDisplacement();
|
||||||
|
virtual ~ViewProviderFemConstraintDisplacement();
|
||||||
|
virtual void updateData(const App::Property*);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool setEdit(int ModNum);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_VIEWPROVIDERFEMCONSTRAINTDISPLACEMENT_H
|
|
@ -105,8 +105,8 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HEIGHT 4
|
#define WIDTH (2)
|
||||||
#define WIDTH (1.5*HEIGHT)
|
#define HEIGHT (1)
|
||||||
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
|
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
|
||||||
|
|
||||||
void ViewProviderFemConstraintFixed::updateData(const App::Property* prop)
|
void ViewProviderFemConstraintFixed::updateData(const App::Property* prop)
|
||||||
|
|
|
@ -105,7 +105,7 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARROWLENGTH 9
|
#define ARROWLENGTH (4)
|
||||||
#define ARROWHEADRADIUS (ARROWLENGTH/3)
|
#define ARROWHEADRADIUS (ARROWLENGTH/3)
|
||||||
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable
|
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ bool ViewProviderFemConstraintPressure::setEdit(int ModNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARROWLENGTH (6)
|
#define ARROWLENGTH (4)
|
||||||
#define ARROWHEADRADIUS (ARROWLENGTH/3)
|
#define ARROWHEADRADIUS (ARROWLENGTH/3)
|
||||||
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable
|
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||||
<< "Fem_CreateNodesSet"
|
<< "Fem_CreateNodesSet"
|
||||||
<< "Separator"
|
<< "Separator"
|
||||||
<< "Fem_ConstraintFixed"
|
<< "Fem_ConstraintFixed"
|
||||||
|
<< "Fem_ConstraintDisplacement"
|
||||||
|
<< "Separator"
|
||||||
<< "Fem_ConstraintForce"
|
<< "Fem_ConstraintForce"
|
||||||
<< "Fem_ConstraintPressure"
|
<< "Fem_ConstraintPressure"
|
||||||
<< "Fem_ConstraintBearing"
|
<< "Fem_ConstraintBearing"
|
||||||
|
@ -95,6 +97,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||||
<< "Fem_CreateNodesSet"
|
<< "Fem_CreateNodesSet"
|
||||||
<< "Separator"
|
<< "Separator"
|
||||||
<< "Fem_ConstraintFixed"
|
<< "Fem_ConstraintFixed"
|
||||||
|
<< "Fem_ConstraintDisplacement"
|
||||||
|
<< "Separator"
|
||||||
<< "Fem_ConstraintForce"
|
<< "Fem_ConstraintForce"
|
||||||
<< "Fem_ConstraintPressure"
|
<< "Fem_ConstraintPressure"
|
||||||
<< "Fem_ConstraintBearing"
|
<< "Fem_ConstraintBearing"
|
||||||
|
|
|
@ -49,6 +49,8 @@ class _CommandMechanicalShowResult(FemCommands):
|
||||||
QtGui.QMessageBox.critical(None, "Missing prerequisite", "No result found in active Analysis")
|
QtGui.QMessageBox.critical(None, "Missing prerequisite", "No result found in active Analysis")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.hide_parts_constraints_show_meshes()
|
||||||
|
|
||||||
import _TaskPanelResultControl
|
import _TaskPanelResultControl
|
||||||
taskd = _TaskPanelResultControl._TaskPanelResultControl()
|
taskd = _TaskPanelResultControl._TaskPanelResultControl()
|
||||||
FreeCADGui.Control.showDialog(taskd)
|
FreeCADGui.Control.showDialog(taskd)
|
||||||
|
|
|
@ -46,6 +46,7 @@ class _CommandPurgeFemResults(FemCommands):
|
||||||
fea = FemTools()
|
fea = FemTools()
|
||||||
fea.reset_all()
|
fea.reset_all()
|
||||||
|
|
||||||
|
self.hide_meshes_show_parts_constraints()
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())
|
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())
|
||||||
|
|
|
@ -47,6 +47,8 @@ class _CommandQuickAnalysis(FemCommands):
|
||||||
if ret_code == 0:
|
if ret_code == 0:
|
||||||
self.fea.load_results()
|
self.fea.load_results()
|
||||||
self.show_results_on_mesh()
|
self.show_results_on_mesh()
|
||||||
|
self.hide_parts_constraints_show_meshes()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print ("CalculiX failed ccx finished with error {}".format(ret_code))
|
print ("CalculiX failed ccx finished with error {}".format(ret_code))
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ class _CommandSolverJobControl(FemCommands):
|
||||||
self.is_active = 'with_solver'
|
self.is_active = 'with_solver'
|
||||||
|
|
||||||
def Activated(self):
|
def Activated(self):
|
||||||
|
|
||||||
|
self.hide_parts_constraints_show_meshes()
|
||||||
|
|
||||||
solver_obj = FreeCADGui.Selection.getSelection()[0]
|
solver_obj = FreeCADGui.Selection.getSelection()[0]
|
||||||
FreeCADGui.ActiveDocument.setEdit(solver_obj, 0)
|
FreeCADGui.ActiveDocument.setEdit(solver_obj, 0)
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class inp_writer:
|
||||||
def __init__(self, analysis_obj, mesh_obj, mat_obj,
|
def __init__(self, analysis_obj, mesh_obj, mat_obj,
|
||||||
fixed_obj,
|
fixed_obj,
|
||||||
force_obj, pressure_obj,
|
force_obj, pressure_obj,
|
||||||
|
displacement_obj,
|
||||||
beamsection_obj, shellthickness_obj,
|
beamsection_obj, shellthickness_obj,
|
||||||
analysis_type=None, eigenmode_parameters=None,
|
analysis_type=None, eigenmode_parameters=None,
|
||||||
dir_name=None):
|
dir_name=None):
|
||||||
|
@ -47,6 +48,7 @@ class inp_writer:
|
||||||
self.fixed_objects = fixed_obj
|
self.fixed_objects = fixed_obj
|
||||||
self.force_objects = force_obj
|
self.force_objects = force_obj
|
||||||
self.pressure_objects = pressure_obj
|
self.pressure_objects = pressure_obj
|
||||||
|
self.displacement_objects = displacement_obj
|
||||||
if eigenmode_parameters:
|
if eigenmode_parameters:
|
||||||
self.no_of_eigenfrequencies = eigenmode_parameters[0]
|
self.no_of_eigenfrequencies = eigenmode_parameters[0]
|
||||||
self.eigenfrequeny_range_low = eigenmode_parameters[1]
|
self.eigenfrequeny_range_low = eigenmode_parameters[1]
|
||||||
|
@ -71,12 +73,14 @@ class inp_writer:
|
||||||
inpfile.write('\n\n')
|
inpfile.write('\n\n')
|
||||||
self.write_element_sets_material_and_femelement_type(inpfile)
|
self.write_element_sets_material_and_femelement_type(inpfile)
|
||||||
self.write_node_sets_constraints_fixed(inpfile)
|
self.write_node_sets_constraints_fixed(inpfile)
|
||||||
|
self.write_displacement_nodes(inpfile)
|
||||||
if self.analysis_type is None or self.analysis_type == "static":
|
if self.analysis_type is None or self.analysis_type == "static":
|
||||||
self.write_node_sets_constraints_force(inpfile)
|
self.write_node_sets_constraints_force(inpfile)
|
||||||
self.write_materials(inpfile)
|
self.write_materials(inpfile)
|
||||||
self.write_femelementsets(inpfile)
|
self.write_femelementsets(inpfile)
|
||||||
self.write_step_begin(inpfile)
|
self.write_step_begin(inpfile)
|
||||||
self.write_constraints_fixed(inpfile)
|
self.write_constraints_fixed(inpfile)
|
||||||
|
self.write_displacement(inpfile)
|
||||||
if self.analysis_type is None or self.analysis_type == "static":
|
if self.analysis_type is None or self.analysis_type == "static":
|
||||||
self.write_constraints_force(inpfile)
|
self.write_constraints_force(inpfile)
|
||||||
self.write_constraints_pressure(inpfile)
|
self.write_constraints_pressure(inpfile)
|
||||||
|
@ -144,6 +148,25 @@ class inp_writer:
|
||||||
for i in n:
|
for i in n:
|
||||||
f.write(str(i) + ',\n')
|
f.write(str(i) + ',\n')
|
||||||
|
|
||||||
|
def write_displacement_nodes(self,f):
|
||||||
|
f.write('\n***********************************************************\n')
|
||||||
|
f.write('** Node sets for prescribed displacement constraint\n')
|
||||||
|
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||||
|
for fobj in self.displacement_objects:
|
||||||
|
disp_obj = fobj['Object']
|
||||||
|
f.write('*NSET,NSET='+disp_obj.Name + '\n')
|
||||||
|
for o, elem in disp_obj.References:
|
||||||
|
fo = o.Shape.getElement(elem)
|
||||||
|
n = []
|
||||||
|
if fo.ShapeType == 'Face':
|
||||||
|
n = self.mesh_object.FemMesh.getNodesByFace(fo)
|
||||||
|
elif fo.ShapeType == 'Edge':
|
||||||
|
n = self.mesh_object.FemMesh.getNodesByEdge(fo)
|
||||||
|
elif fo.ShapeType == 'Vertex':
|
||||||
|
n = self.mesh_object.FemMesh.getNodesByVertex(fo)
|
||||||
|
for i in n:
|
||||||
|
f.write(str(i) + ',\n')
|
||||||
|
|
||||||
def write_node_sets_constraints_force(self, f):
|
def write_node_sets_constraints_force(self, f):
|
||||||
f.write('\n***********************************************************\n')
|
f.write('\n***********************************************************\n')
|
||||||
f.write('** Node sets for loads\n')
|
f.write('** Node sets for loads\n')
|
||||||
|
@ -263,6 +286,41 @@ class inp_writer:
|
||||||
f.write(fix_obj_name + ',6\n')
|
f.write(fix_obj_name + ',6\n')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
|
def write_displacement(self,f):
|
||||||
|
f.write('\n***********************************************************\n')
|
||||||
|
f.write('** Displacement constraint applied\n')
|
||||||
|
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||||
|
for disp_obj in self.displacement_objects:
|
||||||
|
disp_obj_name = disp_obj['Object'].Name
|
||||||
|
f.write('*BOUNDARY\n')
|
||||||
|
if disp_obj['Object'].xFix == True:
|
||||||
|
f.write(disp_obj_name + ',1\n')
|
||||||
|
elif disp_obj['Object'].xFree == False:
|
||||||
|
f.write(disp_obj_name + ',1,1,'+str(disp_obj['Object'].xDisplacement)+'\n')
|
||||||
|
if disp_obj['Object'].yFix == True:
|
||||||
|
f.write(disp_obj_name + ',2\n')
|
||||||
|
elif disp_obj['Object'].yFree == False:
|
||||||
|
f.write(disp_obj_name + ',2,2,'+str(disp_obj['Object'].yDisplacement)+'\n')
|
||||||
|
if disp_obj['Object'].zFix == True:
|
||||||
|
f.write(disp_obj_name + ',3\n')
|
||||||
|
elif disp_obj['Object'].zFree == False:
|
||||||
|
f.write(disp_obj_name + ',3,3,'+str(disp_obj['Object'].zDisplacement)+'\n')
|
||||||
|
|
||||||
|
if self.beamsection_objects or self.shellthickness_objects:
|
||||||
|
if disp_obj['Object'].rotxFix == True:
|
||||||
|
f.write(disp_obj_name + ',4\n')
|
||||||
|
elif disp_obj['Object'].rotxFree == False:
|
||||||
|
f.write(disp_obj_name + ',4,4,'+str(disp_obj['Object'].xRotation)+'\n')
|
||||||
|
if disp_obj['Object'].rotyFix == True:
|
||||||
|
f.write(disp_obj_name + ',5\n')
|
||||||
|
elif disp_obj['Object'].rotyFree == False:
|
||||||
|
f.write(disp_obj_name + ',5,5,'+str(disp_obj['Object'].yRotation)+'\n')
|
||||||
|
if disp_obj['Object'].rotzFix == True:
|
||||||
|
f.write(disp_obj_name + ',6\n')
|
||||||
|
elif disp_obj['Object'].rotzFree == False:
|
||||||
|
f.write(disp_obj_name + ',6,6,'+str(disp_obj['Object'].zRotation)+'\n')
|
||||||
|
f.write('\n')
|
||||||
|
|
||||||
def write_constraints_force(self, f):
|
def write_constraints_force(self, f):
|
||||||
f.write('\n***********************************************************\n')
|
f.write('\n***********************************************************\n')
|
||||||
f.write('** Node loads\n')
|
f.write('** Node loads\n')
|
||||||
|
|
94
src/Mod/Fem/ccxInpWriterFemConstraintDisplacement.py
Normal file
94
src/Mod/Fem/ccxInpWriterFemConstraintDisplacement.py
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
import FreeCAD
|
||||||
|
import os
|
||||||
|
|
||||||
|
class ccxInpWriterFemConstraintDisplacement:
|
||||||
|
def __init__(self):
|
||||||
|
displacement_constraints = []
|
||||||
|
beam_sections = []
|
||||||
|
shell_thicknesses = []
|
||||||
|
f_mesh = None
|
||||||
|
dir_name=None
|
||||||
|
file_name=None
|
||||||
|
|
||||||
|
def writeFile(self):
|
||||||
|
print('started FemConstraintDisplacementInpFile')
|
||||||
|
import FemGui
|
||||||
|
f_analysis = FemGui.getActiveAnalysis()
|
||||||
|
displacement_constraints = []
|
||||||
|
beam_sections = []
|
||||||
|
shell_thicknesses = []
|
||||||
|
f_mesh = None
|
||||||
|
dir_name=None
|
||||||
|
file_name=None
|
||||||
|
for m in f_analysis.Member:
|
||||||
|
if m.isDerivedFrom("Fem::ConstraintDisplacement"):
|
||||||
|
displacement_constraint_dict = {}
|
||||||
|
displacement_constraint_dict['Object'] = m
|
||||||
|
displacement_constraints.append(displacement_constraint_dict)
|
||||||
|
elif m.isDerivedFrom("Fem::FemMeshObject"):
|
||||||
|
f_mesh=m
|
||||||
|
elif hasattr(m, "Proxy") and m.Proxy.Type == 'FemBeamSection':
|
||||||
|
beam_section_dict = {}
|
||||||
|
beam_section_dict['Object'] = m
|
||||||
|
beam_sections.append(beam_section_dict)
|
||||||
|
elif hasattr(m, "Proxy") and m.Proxy.Type == "FemShellThickness":
|
||||||
|
shell_thickness_dict = {}
|
||||||
|
shell_thickness_dict['Object'] = m
|
||||||
|
shell_thicknesses.append(shell_thickness_dict)
|
||||||
|
dir_name = FreeCAD.ActiveDocument.TransientDir.replace('\\', '/') + '/FemConstraints'
|
||||||
|
if not os.path.isdir(dir_name):
|
||||||
|
os.mkdir(dir_name)
|
||||||
|
file_name = dir_name + '/' + 'FemConstraintDisplacement.txt'
|
||||||
|
print(file_name)
|
||||||
|
inpfile = open(file_name, 'w')
|
||||||
|
inpfile.write('\n***********************************************************\n')
|
||||||
|
inpfile.write('** Node sets for prescribed displacement constraint\n')
|
||||||
|
#inpfile.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||||
|
for fobj in displacement_constraints:
|
||||||
|
disp_obj = fobj['Object']
|
||||||
|
inpfile.write('*NSET,NSET='+disp_obj.Name + '\n')
|
||||||
|
for o, elem in disp_obj.References:
|
||||||
|
fo = o.Shape.getElement(elem)
|
||||||
|
n = []
|
||||||
|
if fo.ShapeType == 'Face':
|
||||||
|
n = f_mesh.FemMesh.getNodesByFace(fo)
|
||||||
|
elif fo.ShapeType == 'Edge':
|
||||||
|
n = f_mesh.FemMesh.getNodesByEdge(fo)
|
||||||
|
elif fo.ShapeType == 'Vertex':
|
||||||
|
n = f_mesh.FemMesh.getNodesByVertex(fo)
|
||||||
|
for i in n:
|
||||||
|
inpfile.write(str(i) + ',\n')
|
||||||
|
inpfile.write('\n***********************************************************\n')
|
||||||
|
inpfile.write('** Displacement constraint applied\n')
|
||||||
|
#f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||||
|
for disp_obj in displacement_constraints:
|
||||||
|
disp_obj_name = disp_obj['Object'].Name
|
||||||
|
inpfile.write('*BOUNDARY\n')
|
||||||
|
if disp_obj['Object'].xFix == True:
|
||||||
|
inpfile.write(disp_obj_name + ',1\n')
|
||||||
|
elif disp_obj['Object'].xFree == False:
|
||||||
|
inpfile.write(disp_obj_name + ',1,1,'+str(disp_obj['Object'].xDisplacement)+'\n')
|
||||||
|
if disp_obj['Object'].yFix == True:
|
||||||
|
inpfile.write(disp_obj_name + ',2\n')
|
||||||
|
elif disp_obj['Object'].yFree == False:
|
||||||
|
inpfile.write(disp_obj_name + ',2,2,'+str(disp_obj['Object'].yDisplacement)+'\n')
|
||||||
|
if disp_obj['Object'].zFix == True:
|
||||||
|
inpfile.write(disp_obj_name + ',3\n')
|
||||||
|
elif disp_obj['Object'].zFree == False:
|
||||||
|
inpfile.write(disp_obj_name + ',3,3,'+str(disp_obj['Object'].zDisplacement)+'\n')
|
||||||
|
|
||||||
|
if beam_sections or shell_thicknesses:
|
||||||
|
if disp_obj['Object'].rotxFix == True:
|
||||||
|
inpfile.write(disp_obj_name + ',4\n')
|
||||||
|
elif disp_obj['Object'].rotxFree == False:
|
||||||
|
inpfile.write(disp_obj_name + ',4,4,'+str(disp_obj['Object'].xRotation)+'\n')
|
||||||
|
if disp_obj['Object'].rotyFix == True:
|
||||||
|
inpfile.write(disp_obj_name + ',5\n')
|
||||||
|
elif disp_obj['Object'].rotyFree == False:
|
||||||
|
inpfile.write(disp_obj_name + ',5,5,'+str(disp_obj['Object'].yRotation)+'\n')
|
||||||
|
if disp_obj['Object'].rotzFix == True:
|
||||||
|
inpfile.write(disp_obj_name + ',6\n')
|
||||||
|
elif disp_obj['Object'].rotzFree == False:
|
||||||
|
inpfile.write(disp_obj_name + ',6,6,'+str(disp_obj['Object'].zRotation)+'\n')
|
||||||
|
inpfile.close()
|
||||||
|
print('completed FemConstraintDisplacementInpFile')
|
Loading…
Reference in New Issue
Block a user