FEM: cpp commands, comment analysis and solver command as they are created in Python
This commit is contained in:
@@ -100,68 +100,6 @@ std::string gethideMeshShowPartStr(std::string showConstr="")
|
||||
}
|
||||
|
||||
|
||||
//================================================================================================
|
||||
DEF_STD_CMD_A(CmdFemCreateAnalysis);
|
||||
|
||||
CmdFemCreateAnalysis::CmdFemCreateAnalysis()
|
||||
: Command("FEM_CreateAnalysis")
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Create a FEM analysis");
|
||||
sToolTipText = QT_TR_NOOP("Create a FEM analysis");
|
||||
sWhatsThis = "FEM_CreateAnalysis";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-analysis";
|
||||
}
|
||||
|
||||
void CmdFemCreateAnalysis::activated(int)
|
||||
{
|
||||
#ifndef FCWithNetgen
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Your FreeCAD is built without NETGEN support. Meshing will not work...."));
|
||||
return;
|
||||
#endif
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Fillet works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
std::string AnalysisName = getUniqueObjectName("FemAnalysis");
|
||||
|
||||
std::string MeshName = getUniqueObjectName((std::string(base->getNameInDocument()) +"_Mesh").c_str());
|
||||
|
||||
|
||||
openCommand("Create FEM analysis");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemAnalysis','%s')",AnalysisName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemMeshShapeNetgenObject','%s')",MeshName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().ActiveObject.Shape = App.activeDocument().%s",base->getNameInDocument());
|
||||
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",AnalysisName.c_str(),MeshName.c_str());
|
||||
addModule(Gui,"FemGui");
|
||||
doCommand(Gui,"FemGui.setActiveAnalysis(App.activeDocument().%s)",AnalysisName.c_str());
|
||||
commitCommand();
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
||||
bool CmdFemCreateAnalysis::isActive(void)
|
||||
{
|
||||
return !FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
|
||||
}
|
||||
|
||||
|
||||
//================================================================================================
|
||||
DEF_STD_CMD_A(CmdFemAddPart);
|
||||
|
||||
@@ -226,6 +164,72 @@ bool CmdFemAddPart::isActive(void)
|
||||
|
||||
|
||||
//================================================================================================
|
||||
// analysis
|
||||
/* done in Python
|
||||
DEF_STD_CMD_A(CmdFemCreateAnalysis);
|
||||
|
||||
CmdFemCreateAnalysis::CmdFemCreateAnalysis()
|
||||
: Command("FEM_CreateAnalysis")
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Create a FEM analysis");
|
||||
sToolTipText = QT_TR_NOOP("Create a FEM analysis");
|
||||
sWhatsThis = "FEM_CreateAnalysis";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-analysis";
|
||||
}
|
||||
|
||||
void CmdFemCreateAnalysis::activated(int)
|
||||
{
|
||||
#ifndef FCWithNetgen
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Your FreeCAD is built without NETGEN support. Meshing will not work...."));
|
||||
return;
|
||||
#endif
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Fillet works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
std::string AnalysisName = getUniqueObjectName("FemAnalysis");
|
||||
|
||||
std::string MeshName = getUniqueObjectName((std::string(base->getNameInDocument()) +"_Mesh").c_str());
|
||||
|
||||
|
||||
openCommand("Create FEM analysis");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemAnalysis','%s')",AnalysisName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemMeshShapeNetgenObject','%s')",MeshName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().ActiveObject.Shape = App.activeDocument().%s",base->getNameInDocument());
|
||||
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",AnalysisName.c_str(),MeshName.c_str());
|
||||
addModule(Gui,"FemGui");
|
||||
doCommand(Gui,"FemGui.setActiveAnalysis(App.activeDocument().%s)",AnalysisName.c_str());
|
||||
commitCommand();
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
||||
bool CmdFemCreateAnalysis::isActive(void)
|
||||
{
|
||||
return !FemGui::ActiveAnalysisObserver::instance()->hasActiveObject();
|
||||
}
|
||||
*/
|
||||
|
||||
//================================================================================================
|
||||
// solver
|
||||
/* done in Python
|
||||
DEF_STD_CMD_A(CmdFemCreateSolver);
|
||||
|
||||
CmdFemCreateSolver::CmdFemCreateSolver()
|
||||
@@ -267,9 +271,10 @@ bool CmdFemCreateSolver::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//================================================================================================
|
||||
// Constraints
|
||||
DEF_STD_CMD_A(CmdFemConstraintBearing);
|
||||
|
||||
CmdFemConstraintBearing::CmdFemConstraintBearing()
|
||||
@@ -1617,9 +1622,9 @@ bool CmdFemPostPipelineFromResult::isActive(void)
|
||||
void CreateFemCommands(void)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
//rcCmdMgr.addCommand(new CmdFemCreateAnalysis());
|
||||
rcCmdMgr.addCommand(new CmdFemAddPart());
|
||||
//rcCmdMgr.addCommand(new CmdFemCreateSolver()); // Solver will be extended and created in python
|
||||
//rcCmdMgr.addCommand(new CmdFemCreateAnalysis()); // Analysis is created in python
|
||||
//rcCmdMgr.addCommand(new CmdFemCreateSolver()); // Solver will be extended and created in python
|
||||
rcCmdMgr.addCommand(new CmdFemCreateNodesSet());
|
||||
rcCmdMgr.addCommand(new CmdFemDefineNodesSet());
|
||||
rcCmdMgr.addCommand(new CmdFemConstraintBearing());
|
||||
|
||||
Reference in New Issue
Block a user