[FEM] add missing analysis deletion handling
as it was, one could delete the analysis container breaking everything. Now you get a warning. - also fix typos
This commit is contained in:
@@ -20,34 +20,37 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <Standard_math.hxx>
|
||||
# include <boost_bind_bind.hpp>
|
||||
# include <QAction>
|
||||
# include <QApplication>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
# include <QTextStream>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderAnalysis.h"
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/ActionFunction.h>
|
||||
|
||||
#include <Mod/Fem/App/FemAnalysis.h>
|
||||
#include <Mod/Fem/App/FemSolverObject.h>
|
||||
#include <Mod/Fem/App/FemResultObject.h>
|
||||
#include <Mod/Fem/App/FemMeshObject.h>
|
||||
#include <Mod/Fem/App/FemSetObject.h>
|
||||
#include <Mod/Fem/App/FemConstraint.h>
|
||||
#include <App/MaterialObject.h>
|
||||
#include <App/TextDocument.h>
|
||||
|
||||
#include <Gui/ActionFunction.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include <Mod/Fem/App/FemAnalysis.h>
|
||||
#include <Mod/Fem/App/FemConstraint.h>
|
||||
#include <Mod/Fem/App/FemMeshObject.h>
|
||||
#include <Mod/Fem/App/FemResultObject.h>
|
||||
#include <Mod/Fem/App/FemSetObject.h>
|
||||
#include <Mod/Fem/App/FemSolverObject.h>
|
||||
|
||||
#include "ViewProviderAnalysis.h"
|
||||
#include "TaskDlgAnalysis.h"
|
||||
|
||||
|
||||
#ifdef FC_USE_VTK
|
||||
#include <Mod/Fem/App/FemPostObject.h>
|
||||
#endif
|
||||
@@ -84,12 +87,6 @@ std::vector<App::DocumentObject*> ViewProviderFemAnalysis::claimChildren(void)co
|
||||
return Gui::ViewProviderDocumentObjectGroup::claimChildren();
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::canDelete(App::DocumentObject* obj) const
|
||||
{
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderFemAnalysis::getDisplayModes(void) const
|
||||
{
|
||||
return { "Analysis" };
|
||||
@@ -161,12 +158,6 @@ void ViewProviderFemAnalysis::unsetEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// do nothing special on deletion
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::canDragObjects() const
|
||||
{
|
||||
return true;
|
||||
@@ -220,6 +211,45 @@ void ViewProviderFemAnalysis::dropObject(App::DocumentObject* obj)
|
||||
ViewProviderDocumentObjectGroup::dropObject(obj);
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::onDelete(const std::vector<std::string>&)
|
||||
{
|
||||
// warn the user if the object has childs
|
||||
|
||||
auto objs = claimChildren();
|
||||
if (!objs.empty())
|
||||
{
|
||||
// generate dialog
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"The analysis is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
bodyMessageStream << '\n';
|
||||
for (auto ObjIterator : objs)
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
|
||||
bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?");
|
||||
// show and evaluate the dialog
|
||||
int DialogResult = QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
if (DialogResult == QMessageBox::Yes)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::canDelete(App::DocumentObject* obj) const
|
||||
{
|
||||
// deletions of objects from a FemAnalysis don't necesarily destroy anything
|
||||
// thus we can pass this action
|
||||
// we can warn the user if necessary in the object's ViewProvider in the onDelete() function
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Python feature -----------------------------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
|
||||
@@ -47,13 +47,15 @@ public:
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
virtual std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
||||
// handling when object is deleted
|
||||
virtual bool onDelete(const std::vector<std::string>&);
|
||||
/// Asks the view provider if the given object can be deleted.
|
||||
virtual bool canDelete(App::DocumentObject* obj) const;
|
||||
|
||||
//virtual std::vector<App::DocumentObject*> claimChildren3D(void)const;
|
||||
void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
/// A list of all possible display modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
// shows solid in the tree
|
||||
|
||||
@@ -683,7 +683,7 @@ bool ViewProviderFemPostObject::onDelete(const std::vector<std::string>&)
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"The page is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
"The pipeline is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
bodyMessageStream << '\n';
|
||||
for (auto ObjIterator : objs)
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
|
||||
|
||||
@@ -64,7 +64,7 @@ bool ViewProviderSolver::onDelete(const std::vector<std::string>&)
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"The page is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
"The solver is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
bodyMessageStream << '\n';
|
||||
for (auto ObjIterator : objs)
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
|
||||
|
||||
Reference in New Issue
Block a user