+ hide input shape after creating fem object, give feedback on wrong selection for nodes set

This commit is contained in:
wmayer 2015-04-22 22:45:07 +02:00
parent f4f7759bba
commit bf2266aee3
3 changed files with 26 additions and 18 deletions

View File

@ -185,10 +185,8 @@ void CmdFemAddPart::activated(int iMsg)
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());
@ -199,7 +197,6 @@ void CmdFemAddPart::activated(int iMsg)
commitCommand();
updateActive();
}
bool CmdFemAddPart::isActive(void)
@ -558,7 +555,7 @@ bool CmdFemDefineNodesSet::isActive(void)
DEF_STD_CMD_A(CmdFemCreateNodesSet);
CmdFemCreateNodesSet::CmdFemCreateNodesSet()
:Command("Fem_CreateNodesSet")
: Command("Fem_CreateNodesSet")
{
sAppModule = "Fem";
sGroup = QT_TR_NOOP("Fem");
@ -567,30 +564,32 @@ CmdFemCreateNodesSet::CmdFemCreateNodesSet()
sWhatsThis = "Fem_CreateNodesSet";
sStatusTip = sToolTipText;
sPixmap = "Fem_FemMesh_createnodebypoly";
}
void CmdFemCreateNodesSet::activated(int iMsg)
{
Gui::SelectionFilter ObjectFilter("SELECT Fem::FemSetNodesObject COUNT 1");
Gui::SelectionFilter FemMeshFilter ("SELECT Fem::FemMeshObject COUNT 1");
Gui::SelectionFilter FemMeshFilter("SELECT Fem::FemMeshObject COUNT 1");
if (ObjectFilter.match()) {
Fem::FemSetNodesObject *NodesObj = static_cast<Fem::FemSetNodesObject*>(ObjectFilter.Result[0][0].getObject());
openCommand("Edit nodes-set");
openCommand("Edit nodes set");
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",NodesObj->getNameInDocument());
}else if (FemMeshFilter.match()) {
}
else if (FemMeshFilter.match()) {
Fem::FemMeshObject *MeshObj = static_cast<Fem::FemMeshObject*>(FemMeshFilter.Result[0][0].getObject());
std::string FeatName = getUniqueObjectName("NodesSet");
openCommand("Create a new nodes-set");
openCommand("Create nodes set");
doCommand(Doc,"App.activeDocument().addObject('Fem::FemSetNodesObject','%s')",FeatName.c_str());
doCommand(Gui,"App.activeDocument().%s.FemMesh = App.activeDocument().%s",FeatName.c_str(),MeshObj->getNameInDocument());
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
}
else {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdFemCreateNodesSet", "Wrong selection"),
qApp->translate("CmdFemCreateNodesSet", "Select a single FEM mesh or nodes set, please."));
}
}

View File

@ -68,10 +68,11 @@ TaskDlgMeshShapeNetgen::~TaskDlgMeshShapeNetgen()
void TaskDlgMeshShapeNetgen::open()
{
//select->activate();
//Edge2TaskObject->execute();
//param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster);
// a transaction is already open at creation time of the mesh
if (!Gui::Command::hasPendingCommand()) {
QString msg = tr("Edit FEM mesh");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
}
void TaskDlgMeshShapeNetgen::clicked(int button)
@ -99,8 +100,16 @@ bool TaskDlgMeshShapeNetgen::accept()
Gui::WaitCursor wc;
FemMeshShapeNetgenObject->recompute();
}
// hide the input object
App::DocumentObject* obj = FemMeshShapeNetgenObject->Shape.getValue();
if (obj) {
Gui::Application::Instance->hideViewProvider(obj);
}
//FemSetNodesObject->Label.setValue(name->name);
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
return true;
}

View File

@ -67,12 +67,12 @@ class _CommandNewMechanicalAnalysis:
FreeCADGui.doCommand("App.activeDocument().addObject('Fem::FemMeshShapeNetgenObject','" + sel[0].Name + "_Mesh')")
FreeCADGui.doCommand("App.activeDocument().ActiveObject.Shape = App.activeDocument()." + sel[0].Name)
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [App.activeDocument().ActiveObject]")
FreeCADGui.doCommand("Gui.activeDocument().hide('" + sel[0].Name + "')")
#FreeCADGui.doCommand("Gui.activeDocument().hide('" + sel[0].Name + "')")
#FreeCADGui.doCommand("App.activeDocument().ActiveObject.touch()")
#FreeCADGui.doCommand("App.activeDocument().recompute()")
FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
FreeCAD.ActiveDocument.commitTransaction()
#FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.Selection.clearSelection()
def IsActive(self):