PD: Remove dead code from workbench class

This commit is contained in:
wmayer
2024-07-05 13:14:12 +02:00
committed by wwmayer
parent e9f908dc9f
commit fc9a8f4e76
2 changed files with 7 additions and 154 deletions

View File

@@ -68,111 +68,18 @@ namespace sp = std::placeholders;
/// @namespace PartDesignGui @class Workbench
TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench)
Workbench::Workbench() {
}
Workbench::Workbench() = default;
Workbench::~Workbench() {
Workbench::~Workbench()
{
WorkflowManager::destruct();
}
void Workbench::_switchToDocument(const App::Document* /*doc*/)
{
// TODO Commented out for thurther remove or rewrite (2015-09-04, Fat-Zer)
// if (doc == NULL) return;
//
// PartDesign::Body* activeBody = NULL;
// std::vector<App::DocumentObject*> bodies = doc->getObjectsOfType(PartDesign::Body::getClassTypeId());
//
// // No tip, so build up structure or migrate
// if (!doc->Tip.getValue())
// {
// ;/*if (doc->countObjects() == 0){
// buildDefaultPartAndBody(doc);
// activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
// assert(activeBody);
// } else {
// // empty document with no tip, so do migration
// _doMigration(doc);
// activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
// assert(activeBody);
// }
// */
// }
// else
// {
// App::Part *docPart = dynamic_cast<App::Part *>(doc->Tip.getValue());
// if (docPart) {
// App::Part *viewPart = Gui::Application::Instance->activeView()->getActiveObject<App::Part *>("Part");
// if (viewPart != docPart)
// Gui::Application::Instance->activeView()->setActiveObject(docPart, "Part");
// //if (docPart->countObjectsOfType(PartDesign::Body::getClassTypeId()) < 1)
// // setUpPart(docPart);
// PartDesign::Body *tempBody = dynamic_cast<PartDesign::Body *> (docPart->getObjectsOfType(PartDesign::Body::getClassTypeId()).front());
// if (tempBody) {
// PartDesign::Body *viewBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
// activeBody = viewBody;
// if (!viewBody)
// activeBody = tempBody;
// else if (!docPart->hasObject(viewBody))
// activeBody = tempBody;
//
// if (activeBody != viewBody)
// Gui::Application::Instance->activeView()->setActiveObject(activeBody, PDBODYKEY);
// }
// }
// }
//
// /*if (activeBody == NULL) {
// QMessageBox::critical(Gui::getMainWindow(), QObject::tr("Could not create body"),
// QObject::tr("No body was found in this document, and none could be created. Please report this bug."
// "We recommend you do not use this document with the PartDesign workbench until the bug has been fixed."
// ));
// }*/
}
void Workbench::slotActiveDocument(const Gui::Document& /*Doc*/)
{
// _switchToDocument(Doc.getDocument());
}
void Workbench::slotNewDocument(const App::Document& /*Doc*/)
{
// _switchToDocument(&Doc);
}
void Workbench::slotFinishRestoreDocument(const App::Document& /*Doc*/)
{
// _switchToDocument(&Doc);
}
void Workbench::slotDeleteDocument(const App::Document&)
{
//ActivePartObject = 0;
//ActiveGuiDoc = 0;
//ActiveAppDoc = 0;
//ActiveVp = 0;
}
/*
This does not work for Std_DuplicateSelection:
Tree.cpp gives: "Cannot reparent unknown object", probably because the signalNewObject is emitted
before the duplication of the object has been completely finished
void Workbench::slotNewObject(const App::DocumentObject& obj)
{
if ((obj.getDocument() == ActiveAppDoc) && (ActivePartObject != NULL)) {
// Add the new object to the active Body
// Note: Will this break Undo? But how else can we catch Edit->Duplicate selection?
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",
ActivePartObject->getNameInDocument(), obj.getNameInDocument());
}
}
*/
void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const
{
auto selection = Gui::Selection().getSelection();
// Add move Tip Command
if ( !selection.empty() ) {
if (!selection.empty()) {
App::DocumentObject *feature = selection.front().pObject;
PartDesign::Body *body = nullptr;
@@ -434,7 +341,6 @@ void Workbench::activated()
"PartDesign_Mirrored",
"PartDesign_LinearPattern",
"PartDesign_PolarPattern",
// "PartDesign_Scaled",
"PartDesign_MultiTransform",
nullptr};
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
@@ -444,37 +350,18 @@ void Workbench::activated()
"PartDesign_MultiTransform"
));
// make the previously used active Body active again
//PartDesignGui::ActivePartObject = NULL;
_switchToDocument(App::GetApplication().getActiveDocument());
addTaskWatcher(Watcher);
if(App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign")->GetBool("SwitchToTask", true))
Gui::Control().showTaskView();
//NOLINTBEGIN
// Let us be notified when a document is activated, so that we can update the ActivePartObject
activeDoc = Gui::Application::Instance->signalActiveDocument.connect(std::bind(&Workbench::slotActiveDocument, this, sp::_1));
createDoc = App::GetApplication().signalNewDocument.connect(std::bind(&Workbench::slotNewDocument, this, sp::_1));
finishDoc = App::GetApplication().signalFinishRestoreDocument.connect(std::bind(&Workbench::slotFinishRestoreDocument, this, sp::_1));
deleteDoc = App::GetApplication().signalDeleteDocument.connect(std::bind(&Workbench::slotDeleteDocument, this, sp::_1));
//NOLINTEND
}
void Workbench::deactivated()
{
// Let us be notified when a document is activated, so that we can update the ActivePartObject
activeDoc.disconnect();
createDoc.disconnect();
finishDoc.disconnect();
deleteDoc.disconnect();
removeTaskWatcher();
// reset the active Body
Gui::Command::doCommand(Gui::Command::Doc,"import PartDesignGui");
Gui::Workbench::deactivated();
}
Gui::MenuItem* Workbench::setupMenuBar() const
@@ -536,7 +423,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "PartDesign_LinearPattern"
<< "PartDesign_PolarPattern"
<< "PartDesign_MultiTransform";
// << "PartDesign_Scaled"
// dressups
Gui::MenuItem* dressups = new Gui::MenuItem;
@@ -572,7 +458,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Separator"
<< "Part_CheckGeometry"
<< "Separator"
// << "PartDesign_Migrate"
<< "PartDesign_Sprocket";
// For 0.13 a couple of python packages like numpy, matplotlib and others
@@ -650,16 +535,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
*part << "PartDesign_Mirrored"
<< "PartDesign_LinearPattern"
<< "PartDesign_PolarPattern"
// << "PartDesign_Scaled"
<< "PartDesign_MultiTransform";
return root;
}
Gui::ToolBarItem* Workbench::setupCommandBars() const
{
// Part tools
Gui::ToolBarItem* root = new Gui::ToolBarItem;
return root;
}

View File

@@ -30,8 +30,6 @@
namespace Gui {
class MenuItem;
class Document;
class ViewProviderDocumentObject;
}
@@ -48,7 +46,7 @@ public:
Workbench();
~Workbench() override;
/** Run some actions when the workbench gets activated. */
/** Run some actions when the workbench gets activated. */
void activated() override;
/** Run some actions when the workbench gets deactivated. */
void deactivated() override;
@@ -57,29 +55,8 @@ public:
void setupContextMenu(const char* recipient, Gui::MenuItem*) const override;
protected:
Gui::MenuItem* setupMenuBar() const override;
Gui::ToolBarItem* setupToolBars() const override;
Gui::ToolBarItem* setupCommandBars() const override;
private:
/// Refresh the Body's highlighting when a document becomes active
void slotActiveDocument(const Gui::Document&);
/// Refresh the highlighting. Migrate legacy documents on loading
void slotFinishRestoreDocument(const App::Document&);
/// Ensure that there are base planes and a body in a new document
void slotNewDocument(const App::Document&);
/// Update the ActivePartObject etc. when a document is closed
void slotDeleteDocument(const App::Document&);
// Add new objects to the body, if appropriate
//void slotNewObject(const App::DocumentObject& obj);
void _switchToDocument(const App::Document* doc);
private:
boost::signals2::connection activeDoc;
boost::signals2::connection createDoc;
boost::signals2::connection finishDoc;
boost::signals2::connection deleteDoc;
Gui::MenuItem* setupMenuBar() const override;
Gui::ToolBarItem* setupToolBars() const override;
};
} // namespace PartDesignGui